You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[InstCombine] Fold (x == A) || (x & -Pow2) == A + 1 into range check
Extends `foldAndOrOfICmpsUsingRanges` to recognize and fold idioms of
the form `(x == A) || (x & -Pow2) == A + 1`, where A + 1 is aligned to
the mask and A > |mask|.
These patterns represent a special case of contiguous range checks and
can be optimized into an addition and comparison.
```llvm
define i1 @src(i32 %x) {
%icmp1 = icmp eq i32 %x, 127
%and = and i32 %x, -32
%icmp2 = icmp eq i32 %and, 128
%ret = or i1 %icmp1, %icmp2
ret i1 %ret
}
define i1 @tgt(i32 %x) {
%1 = add i32 %x, -127
%2 = icmp ult i32 %1, 33
ret i1 %2
}
```
Alive2 Proof: https://alive2.llvm.org/ce/z/gwELqs
0 commit comments