[llvm] [InstCombine] Fold `icmp eq/ne (X and C), 0` when partial bits are known (PR #85863)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 10:04:47 PDT 2024


================
@@ -1771,11 +1771,14 @@ Instruction *InstCombinerImpl::foldICmpAndConstConst(ICmpInst &Cmp,
       return new ICmpInst(NewPred, X, Zero);
     }
 
-    APInt NewC2 = *C2;
     KnownBits Know = computeKnownBits(And->getOperand(0), 0, And);
+    if (Know.One.intersects(*C2))
+      return replaceInstUsesWith(
+          Cmp, ConstantInt::getBool(Cmp.getType(), isICMP_NE));
----------------
goldsteinn wrote:

Hmm? What are you trying to indicate?

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


More information about the llvm-commits mailing list