[llvm] [ConstraintElim] Use ConstantRange information for ConstraintElimination (PR #180862)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 12 03:42:34 PST 2026


================
@@ -1141,6 +1169,19 @@ void State::addInfoFor(BasicBlock &BB) {
           continue;
         WorkList.push_back(FactOrCheck::getCheck(DTN, &U));
       }
+      // Target operands feeding into comparisons for computeConstantRange.
+      // Only explore two levels deep, and exclude eq and ne because of
+      // outsized compile time impact and marginal benefit.
+      if (!Cmp->isEquality()) {
+        for (Value *Op : Cmp->operands()) {
+          if (auto *OpI = dyn_cast<Instruction>(Op)) {
+            addConstantRangeFact(OpI, DT.getNode(OpI->getParent()));
+            for (Value *SubOp : OpI->operands())
+              if (auto *SubI = dyn_cast<Instruction>(SubOp))
+                addConstantRangeFact(SubI, DT.getNode(SubI->getParent()));
+          }
----------------
fhahn wrote:

Would it be sufficient to only add constant range facts for values that are variables in constraints, i.e. automatically skipping all intermediate expressions that get decomposed anyways?

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


More information about the llvm-commits mailing list