[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 22:12:59 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);
+
----------------
goldstein.w.n wrote:
> 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
Also note just about no compile time blowback for any of the changes (was a bit concerned as implemented two recursive functions):
https://llvm-compile-time-tracker.com/compare.php?from=692344d87357ded619d216b265a9375f4326d8fb&to=facaede5ae43806d3123c18823cc173a4b3970ec&stat=instructions%3Au


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