[llvm] [WIP][ScalarEvolution] Replace getSCEV call with computeConstantRange (PR #152769)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 8 11:50:55 PDT 2025


================
@@ -6945,7 +6945,16 @@ const ConstantRange &ScalarEvolution::getRangeRef(
         ConstantRange RangeFromOps(BitWidth, /*isFullSet=*/false);
 
         for (const auto &Op : Phi->operands()) {
-          auto OpRange = getRangeRef(getSCEV(Op), SignHint, Depth + 1);
+          ConstantRange OpRange = RangeFromOps;
+          if (auto *S = getExistingSCEV(Op)) {
+            OpRange = getRangeRef(S, SignHint, Depth + 1);
+          } else {
+            if (!Op->getType()->isIntOrIntVectorTy())
+              break;
+            SimplifyQuery SQ(DL, &DT, &AC, Phi, true);
----------------
nikic wrote:

This should use the terminator of the incoming block instead of the phi as context instruction.

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


More information about the llvm-commits mailing list