[llvm-dev] Why doesn't this `and` get eliminated

John Regehr via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 11 22:03:54 PDT 2020


alive2 agrees with Craig:

----------------------------------------
define i32 @src(i32 %0) {
%1:
   %2 = and i32 %0, 7
   %3 = icmp eq i32 %2, 7
   %4 = zext i1 %3 to i32
   ret i32 %4
}
=>
define i32 @tgt(i32 %0) {
%1:
   %x3 = icmp eq i32 %0, 7
   %x4 = zext i1 %x3 to i32
   ret i32 %x4
}
Transformation doesn't verify!
ERROR: Value mismatch

Example:
i32 %0 = #x0000000f (15)

Source:
i32 %2 = #x00000007 (7)
i1 %3 = #x1 (1)
i32 %4 = #x00000001 (1)

Target:
i1 %x3 = #x0 (0)
i32 %x4 = #x00000000 (0)
Source value: #x00000001 (1)
Target value: #x00000000 (0)



More information about the llvm-dev mailing list