Summary
Since llvm will generate the following ir:
define i32 @and_to_xor1(i32 %0, i32 %1) local_unnamed_addr #0 {
%3 = shl nsw i32 %0, 1
%4 = mul nsw i32 %1, %0
%5 = xor i32 %4, -1
%6 = and i32 %3, %5
%7 = add nsw i32 %6, %4
ret i32 %7
}but InstCombine can not simplify this code shape.
So I use this patch to achieve this.
Test Plan:
check-llvm
https://alive2.llvm.org/ce/z/NrJRbF