[llvm] [SCCP] Relax two-instruction range checks (PR #158495)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 07:54:19 PDT 2025


================
@@ -284,6 +286,54 @@ static Value *simplifyInstruction(SCCPSolver &Solver,
     return Sub;
   }
 
+  // Relax range checks.
+  if (auto *ICmp = dyn_cast<ICmpInst>(&Inst)) {
+    Value *X;
+    auto MatchTwoInstructionExactRangeCheck =
+        [&]() -> std::optional<ConstantRange> {
+      const APInt *RHSC;
+      if (!match(ICmp->getOperand(1), m_APInt(RHSC)))
+        return std::nullopt;
+
+      Value *LHS = ICmp->getOperand(0);
+      ICmpInst::Predicate Pred = ICmp->getPredicate();
+      const APInt *Offset;
+      if (match(LHS, m_OneUse(m_AddLike(m_Value(X), m_APInt(Offset)))))
----------------
dtcxzyw wrote:

It is tuned based on the feedback from opt-bench. See the ir diff in previous runs.

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


More information about the llvm-commits mailing list