[llvm] [InstCombine] Make the `(icmp eq/ne (and X, Y), X)` canonicalization work for non-const operands (PR #84688)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 10 12:59:32 PDT 2024


================
@@ -7221,6 +7219,11 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
           foldICmpCommutative(I.getSwappedPredicate(), Op1, Op0, I))
     return Res;
 
+  // Need this to be after foldICmpCommutative so we do mask folds before
+  // transforming the `and`.
----------------
nikic wrote:

If we canonicalize to a new form, then we do need to be able to handle that new form in transforms, otherwise it doesn't make a lot of sense...

Simplifying `(-1 << y) | x == 0` to `x >> y == 0` does seem like a generally valuable fold to me as well.

https://github.com/llvm/llvm-project/pull/84688


More information about the llvm-commits mailing list