[llvm] [SCEV] Fix infinite recursion in getZeroExtendExpr via missing Depth propagation (PR #184958)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 6 06:24:50 PST 2026
================
@@ -2719,11 +2719,11 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
if (match(B, m_scev_ZExt(m_scev_Add(InnerAdd)))) {
const SCEV *NarrowA = getTruncateExpr(A, InnerAdd->getType());
if (NarrowA == getNegativeSCEV(InnerAdd->getOperand(0)) &&
- getZeroExtendExpr(NarrowA, B->getType()) == A &&
+ getZeroExtendExpr(NarrowA, B->getType(), Depth) == A &&
----------------
dean-mccoppin wrote:
Good point — `Depth + 1` is more consistent with every other recursive call site and I have no strong reason to prefer `Depth` here. The guard check at line 2722 is a speculative equality probe rather than a deeper recursive computation, which was my original (weak) justification, but `Depth + 1` is equally correct and avoids the inconsistency. I'll update both sites.
https://github.com/llvm/llvm-project/pull/184958
More information about the llvm-commits
mailing list