[llvm] [InstCombine] Make the `(icmp eq/ne (and X, Y), X)` canonicalization work for non-const operands (PR #84688)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 10 13:28:08 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`.
----------------
goldsteinn wrote:
its `&` not `|` I think (https://alive2.llvm.org/ce/z/V56XYP). I did try adding it and it cleans up about half the regressions but it doesn't handle things like:
```
define i1 @src_is_notmask_ashr(i16 %x_in, i8 %y, i16 %z)
```
AFAICT, the `or` case needs to be re-inverted and sent back through `foldICmpWithLowBitMaskedVal` at which point I figured just moving it was better.
https://github.com/llvm/llvm-project/pull/84688
More information about the llvm-commits
mailing list