define i1 @src(i32 %arg0, i32 %arg1) {
%1 = ashr i32 %arg0, 31
%2 = lshr i32 %1, 1
%3 = xor i32 %2, %arg0
%4 = ashr i32 %arg1, 31
%5 = lshr i32 %4, 1
%6 = xor i32 %5, %arg1
%7 = icmp eq i32 %3, %6
ret i1 %7
}
define i1 @tgt(i32 %arg0, i32 %arg1) {
%1 = icmp eq i32 %arg0, %arg1
ret i1 %1
}
This pattern may be generalized to folding icmp eq f(a), f(b) to icmp eq a, b when f is a one-to-one function
alive2: https://alive2.llvm.org/ce/z/MjuQvH
godbolt: https://godbolt.org/z/EMG9xrzPM
This pattern is found in https://github.com/dtcxzyw/llvm-opt-benchmark/blob/1d00b842a6755156e5cef3059f19fafdedce899b/bench/zed-rs/optimized/1j4zsx5ep6sgayh5fdkarbyql.ll