[llvm] [ScalarEvolution] Limit recursion in getRangeRef for PHI nodes. (PR #152823)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 14 02:31:21 PDT 2026
================
@@ -6963,8 +6992,13 @@ const ConstantRange &ScalarEvolution::getRangeRef(
// A range of Phi is a subset of union of all ranges of its input.
if (PHINode *Phi = dyn_cast<PHINode>(V)) {
+ // SCEVExpander sometimes creates SCEVUnknowns that are secretly
+ // AddRecs; return the range for the corresponding AddRec.
+ if (auto *AR = dyn_cast<SCEVAddRecExpr>(getSCEV(V)))
+ return getRangeRef(AR, SignHint, Depth + 1);
+
// Make sure that we do not run over cycled Phis.
- if (PendingPhiRanges.insert(Phi).second) {
+ if (RangeRefPHIAllowedOperands(DT, Phi)) {
----------------
nikic wrote:
I think what I had in mind when writing that comment was doing per operand ValueTracking queries, rather than just the one on the phi. ValueTracking does not fully recurse through phis.
https://github.com/llvm/llvm-project/pull/152823
More information about the llvm-commits
mailing list