defm CLZ : UnaryInt<ctlz>;
defm CTZ : UnaryInt<cttz>;
defm POPCNT : UnaryInt<ctpop>;
+
+// Expand the "don't care" operations to supported operations.
+def : Pat<(ctlz_zero_undef Int32:$src), (CLZ_I32 Int32:$src)>;
+def : Pat<(ctlz_zero_undef Int64:$src), (CLZ_I64 Int64:$src)>;
+def : Pat<(cttz_zero_undef Int32:$src), (CTZ_I32 Int32:$src)>;
+def : Pat<(cttz_zero_undef Int64:$src), (CTZ_I64 Int64:$src)>;
ret i32 %a
}
+; CHECK-LABEL: clz32_zero_undef:
+; CHECK-NEXT: (setlocal @0 (argument 0))
+; CHECK-NEXT: (setlocal @1 (clz @0))
+; CHECK-NEXT: (return @1)
+define i32 @clz32_zero_undef(i32 %x) {
+ %a = call i32 @llvm.ctlz.i32(i32 %x, i1 true)
+ ret i32 %a
+}
+
; CHECK-LABEL: ctz32:
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (ctz @0))
ret i32 %a
}
+; CHECK-LABEL: ctz32_zero_undef:
+; CHECK-NEXT: (setlocal @0 (argument 0))
+; CHECK-NEXT: (setlocal @1 (ctz @0))
+; CHECK-NEXT: (return @1)
+define i32 @ctz32_zero_undef(i32 %x) {
+ %a = call i32 @llvm.cttz.i32(i32 %x, i1 true)
+ ret i32 %a
+}
+
; CHECK-LABEL: popcnt32:
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (popcnt @0))
ret i64 %a
}
+; CHECK-LABEL: clz64_zero_undef:
+; CHECK-NEXT: (setlocal @0 (argument 0))
+; CHECK-NEXT: (setlocal @1 (clz @0))
+; CHECK-NEXT: (return @1)
+define i64 @clz64_zero_undef(i64 %x) {
+ %a = call i64 @llvm.ctlz.i64(i64 %x, i1 true)
+ ret i64 %a
+}
+
; CHECK-LABEL: ctz64:
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (ctz @0))
ret i64 %a
}
+; CHECK-LABEL: ctz64_zero_undef:
+; CHECK-NEXT: (setlocal @0 (argument 0))
+; CHECK-NEXT: (setlocal @1 (ctz @0))
+; CHECK-NEXT: (return @1)
+define i64 @ctz64_zero_undef(i64 %x) {
+ %a = call i64 @llvm.cttz.i64(i64 %x, i1 true)
+ ret i64 %a
+}
+
; CHECK-LABEL: popcnt64:
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (popcnt @0))