Closed
Description
Alive2 proof: https://alive2.llvm.org/ce/z/44YNAL (contains generalized pattern)
Motivating example
define i1 @src(i8 %a) {
entry:
%conv = sext i8 %a to i32
%0 = and i32 %conv, -2147483647
%cmp = icmp eq i32 %0, 1
ret i1 %cmp
}
can be folded to:
define i1 @tgt(i8 %a) {
entry:
%and = and i8 %a, -127
%cmp = icmp eq i8 %and, 1
ret i1 %cmp
}
Real-world motivation
This snippet of IR is derived from abseil-cpp/float_conversion.cc@FloatToBuffer (after O3 pipeline).
The example above is a reduced version. If you're interested in the original suboptimal IR and optimal IR, email me please.
Let me know if you can confirm that it's an optimization opportunity, thanks.