[clang] [llvm] [ValueTracking] Extend computeConstantRange for add/sub, sext/zext/trunc (PR #181110)

Guy David via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 17 07:08:16 PST 2026


================
@@ -10041,6 +10045,34 @@ static void setLimitsForBinOp(const BinaryOperator &BO, APInt &Lower,
   default:
     break;
   }
+
+  ConstantRange CR = ConstantRange::getNonEmpty(Lower, Upper);
+  bool IsDisjointOr = BO.getOpcode() == Instruction::Or &&
+                      cast<PossiblyDisjointInst>(&BO)->isDisjoint();
+  if (BO.getOpcode() == Instruction::Add ||
+      BO.getOpcode() == Instruction::Sub || IsDisjointOr) {
+    // Limit recursion depth more aggressively for binary operations.
+    unsigned NewDepth = std::max(Depth * 2, 1u);
----------------
guy-david wrote:

The idea is to reach the maximum depth (6) faster by multiplying by 2 instead of incrementing by 1.
I'll gather the new perf numbers soon.

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


More information about the cfe-commits mailing list