[llvm] [LAA] Rework getStrideFromPointer, improve speculation (PR #212816)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 14 02:06:28 PDT 2026
================
@@ -3100,17 +3079,16 @@ static const SCEV *getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *L
if (!SE->isLoopInvariant(V, Lp))
return nullptr;
- // Look for the loop invariant symbolic value.
- if (isa<SCEVUnknown>(V))
- return V;
-
- // Look through multiplies that scale a stride by a constant.
- match(V, m_scev_Mul(m_SCEVConstant(), m_SCEV(V)));
- if (auto *C = dyn_cast<SCEVIntegralCastExpr>(V))
- if (isa<SCEVUnknown>(C->getOperand()))
- return V;
+ // Strip an optional scaling factor, and let the caller handle the integral
+ // cast. We need to match the ScalingFactor from before.
+ // TODO: If the scaling factor here is a known divisior of what it should be,
+ // we can speculate non-unit strides.
+ if (match(V, m_scev_Mul(m_scev_SpecificInt(*ScalingFactor * AllocSz),
+ m_scev_IntegralCastOrSelf(m_SCEVUnknown()))))
----------------
fhahn wrote:
I think this causes some regressions compared to current `main`. Could you rebase and check the impact on the tests added in 4f4a268a65ba69279fed5f2063ad49eb5d5d89a4?
https://github.com/llvm/llvm-project/pull/212816
More information about the llvm-commits
mailing list