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

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 3 07:22:45 PST 2026


Mel-Chen wrote:

I'd like to discuss the strided access analysis approach.
The current analysis in `convertToStridedAccesses` was ported from `RISCVGatherScatterLowering`, which differs from our downstream implementation that uses SCEV analysis on scalar values during legality. @eas suggested we should base this on SCEV.
I have two approaches:
Approach 1: Analyze scalar values with SCEV before VPlan, pass results via map to `convertToStridedAccesses`.
Approach 2: Use `vputils::getSCEVExprForVPValue` to analyze directly in VPlan (it already supports `VPWidenGEPRecipe`). The challenge is expanding the stride SCEV to a VPValue. Currently `VPExpandSCEVRecipe` must be placed at the beginning of the entry block, so we'd need to either relax this restriction, or introduce a SCEV-to-recipe expander.

@fhahn @lukel97 @eas @arcbbb Thoughts on which approach is preferred?

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


More information about the llvm-commits mailing list