[llvm] [LAA][LV]Allow recognition of strided pointers with constant stride (PR #171151)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 5 02:02:07 PST 2026
================
@@ -2975,6 +2975,8 @@ static const SCEV *getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *L
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;
----------------
fhahn wrote:
> How is this correct to return V as stride if we stripped multiplication by a constant above?
The result should only be used to add a SCEV assumption `%stride == 1`, and the full pointer SCEV we use contructed from the original pointer via `PSE.getSCEV(Ptr)`
> Are you trying to speculate V to be one because you want some memory dependences checks to be emitted at all and not because you want some access to become unit-striped?
In cases where the constant multiplier matches the access size, this should result unit-strided accesses, like in the test case for the patch, right?
https://github.com/llvm/llvm-project/pull/171151
More information about the llvm-commits
mailing list