[PATCH] D63505: [InstCombine] Fold icmp eq/ne (and %x, ~C), 0 -> %x u</u>= 0 earlier, C+1 is power of 2.
Huihui Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 18 11:58:32 PDT 2019
huihuiz marked an inline comment as done.
huihuiz added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1643-1645
// Don't perform the following transforms if the AND has multiple uses
if (!And->hasOneUse())
return nullptr;
----------------
lebedev.ri wrote:
> Why are we restricting this fold to single-use `and`?
Same reason in D63026 (resolving PR10267)
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1656-1657
+ // ((X & ~7) == 0) --> X u< 8
+ // If X is (BinOp Y, C3), allow other rules to fold C3 with C2.
+ if (!match(X, m_c_BinOp(m_Value(), m_Constant())) &&
+ (~(*C2) + 1).isPowerOf2()) {
----------------
lebedev.ri wrote:
> Why do we care about that? Seems rather arbitrary.
take this test as example
```
define i1 @test_shift_and_cmp_changed2(i8 %p) {
%shlp = shl i8 %p, 5
%andp = and i8 %shlp, -64
%cmp = icmp ult i8 %andp, 32
ret i1 %cmp
}
```
we do miss fold for (X >> C3) & C2 != C1 --> (X & (C2 << C3)) != (C1 << C3)
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63505/new/
https://reviews.llvm.org/D63505
More information about the llvm-commits
mailing list