----------------------------------------
define i32 @src(i32 %x, i1 %zerodef) {
%0:
%assume = icmp slt i32 %x, 0
assume i1 %assume
%c = ctlz i32 %x, %zerodef
ret i32 %c
}
=>
define i32 @tgt(i32 %x, i1 %zerodef) {
%0:
%assume = icmp slt i32 %x, 0
assume i1 %assume
ret i32 0
}
Transformation seems to be correct!Proof: https://alive2.llvm.org/ce/z/rU6o1d
Solves second case in https://bugs.llvm.org/show_bug.cgi?id=50173
Enhance isKnownNegative to know that ashr of negative constant is still negative? Then we could remove the match here.