[llvm] [LV] Convert gather loads with constant stride into strided loads (PR #147297)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 13 01:42:13 PST 2026


Mel-Chen wrote:

> I think another thing that may also work is just getting the pointer SCEV and use that exclusively without looking at the pointer recipe at all. It should be a pointer AddRec (like `{%base-ptr,+,%stride}`), with a loop invariant step. For the stride itself, you should be able to just create an ExpandSCEV recipe in the vector preheader.
> 
> Then what's left is creating the scalar pointer in the vector loop, right? The AddRec would need to be expanded in the loop, but should be fairly straight forward to something lile `ptradd %base-ptr, (%canonical-iv * %stride)`? (I think the patch already somewhat implicitly tries to do that by creating a new replicate recipe, but overall that seems much more complex)

We’ve now switched to using VPlan-based SCEV for stride info analysis. This does allow us to handle more cases. While some cases still require improvements to vputils::getSCEVExprForVPValue to be supported, overall this looks like a viable direction.

My replies may be delayed until the end of February due to the Lunar New Year holiday. Please feel free to review in the meantime. :)

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


More information about the llvm-commits mailing list