[PATCH] D145425: [InstCombine] Transform `(icmp ult/uge (and X, Y), X)` -> `(icmp ne/eq (and X, Y), X)`

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 28 21:37:17 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:4222
+   if (Pred == ICmpInst::ICMP_UGE)
+    return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1);
+
----------------
nikic wrote:
> nikic wrote:
> > For symmetry with the or fold, I think we want `X & Y == Y` to `X | ~Y == -1` for freely invertible Y (https://alive2.llvm.org/ce/z/wt3Cg6).
> And `X & Y == Y` to `~X & Y == 0` as well, based on what the final version of D144610 implemented.
> 
> IIRC one of those folds also got implemented for constants previously, so we can drop that then.
Done, although (as you can see from the stack) that actually had fairly large implications for: foldICmpWithLowBitMaskedVal so added patches for that as well.

But the logic is there in: D159059


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145425/new/

https://reviews.llvm.org/D145425



More information about the llvm-commits mailing list