[llvm] [InstCombine] Improve folding of `icmp pred (and X, Mask/~Mask), Y)` (PR #81562)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 12 23:27:57 PST 2024


================
@@ -4068,11 +4068,117 @@ Instruction *InstCombinerImpl::foldSelectICmp(ICmpInst::Predicate Pred,
   return nullptr;
 }
 
+// Returns whether V is a Mask ((X + 1) & X == 0) or ~Mask (-Pow2OrZero)
+static bool isMaskOrZero(const Value *V, bool Not, const SimplifyQuery &Q,
+                         unsigned Depth = 0) {
+  if (Not ? match(V, m_NegatedPower2OrZero()) : match(V, m_LowBitMaskOrZero()))
+    return true;
+  if (V->getType()->getScalarSizeInBits() == 1)
+    return true;
+  if (Depth++ >= MaxAnalysisRecursionDepth)
----------------
goldsteinn wrote:

No meaningful affect: https://llvm-compile-time-tracker.com/compare.php?from=fb48fd18c240574841378defacadff34238089bb&to=ec40daf22da38fb28165ea1e757493470fec218e&stat=instructions:u

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


More information about the llvm-commits mailing list