[PATCH] D65046: [InstCombine] Fold "x ?% y ==/!= 0" to "x & (y-1) ==/!= 0" iff y is power-of-two

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 09:36:52 PDT 2019


RKSimon added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1335
+    return nullptr;
+  // This may increase instruction count, we don't enforce that Y is a constant.
+  Value *Mask = Builder.CreateAdd(Y, Constant::getAllOnesValue(Y->getType()));
----------------
lebedev.ri wrote:
> RKSimon wrote:
> > Do we need a ICmpInst::isEquality(Pred) test?
> This is valid both for equality and all unsigned predicates: https://rise4fun.com/Alive/wp0N
> But not signed ones: https://rise4fun.com/Alive/I67
> 
> Regardless, see beginning of the function:
> ```
>   // This fold is only valid for equality predicates.
>   if (!I.isEquality())
>     return nullptr;
> ```
Cheers - I missed that - maybe add a TODO that other unsigned predicates could be supported?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65046





More information about the llvm-commits mailing list