[llvm] [InstCombine] Add transforms for `(or/and (icmp eq/ne X,0),(icmp eq/ne X,Pow2OrZero))` (PR #94648)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 8 11:48:19 PDT 2024


================
@@ -3240,6 +3277,11 @@ Value *InstCombinerImpl::foldAndOrOfICmps(ICmpInst *LHS, ICmpInst *RHS,
   ICmpInst::Predicate PredL = LHS->getPredicate(), PredR = RHS->getPredicate();
   Value *LHS0 = LHS->getOperand(0), *RHS0 = RHS->getOperand(0);
   Value *LHS1 = LHS->getOperand(1), *RHS1 = RHS->getOperand(1);
+  if (!IsLogical)
+    if (Value *V =
+            foldAndOrOfICmpsWithPow2AndWithZero(Builder, LHS, RHS, IsAnd, Q))
+      return V;
----------------
nikic wrote:

Why did you add this fold in this position? New exotic folds usually get added to the end, not the start of functions. Especially weird to see this interleaved with a bunch of variable declarations that you aren't using.

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


More information about the llvm-commits mailing list