[llvm] [InstCombine] Folding `(icmp eq/ne (and X, -P2), INT_MIN)` (PR #110880)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 3 01:02:29 PDT 2024


================
@@ -5015,6 +5015,22 @@ Instruction *InstCombinerImpl::foldICmpBinOp(ICmpInst &I,
     }
   }
 
+  // (icmp eq/ne (X, -P2), INT_MIN)
+  //	-> (icmp slt/sge X, INT_MIN + P2)
+  if (ICmpInst::isEquality(Pred) && BO0 &&
+      match(I.getOperand(1), m_SignMask())) {
+    Value *X;
+    if (match(BO0, m_And(m_Value(X), m_CheckedInt([](const APInt &C) {
+                           return C.isZero() || C.isNegatedPowerOf2();
+                         })))) {
----------------
nikic wrote:

Use `m_NegatedPower2OrZero` instead?

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


More information about the llvm-commits mailing list