[llvm] [LV] Support strided load with a stride of -1 (PR #128718)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu May 15 03:54:01 PDT 2025
================
@@ -1115,6 +1115,7 @@ class LoopVectorizationCostModel {
CM_Widen_Reverse, // For consecutive accesses with stride -1.
CM_Interleave,
CM_GatherScatter,
+ CM_Strided,
----------------
Mel-Chen wrote:
> I recently put up #139150 to start in this direction. I have a few follow up patches that should get us close
This is a good direction, but the current patch doesn't yet address the issue we're facing.
So for now, I've made a small change in `legalizeAndOptimizeInductions`.a55afd43f8ef3d7536507fc2b5a23397e5b02365
While it's still not very effective at converting widen induction variables into derived ones in more complex use-chain scenarios, like:
```
; CHECK-NEXT: ir<[[WIDEN_IV:%.+]]> = WIDEN-INDUCTION ir<%n>, ir<-1>, vp<[[VF]]>
; CHECK-NEXT: WIDEN ir<[[IDX:%.+]]> = add nsw ir<[[WIDEN_IV]]>, ir<-1>
; CHECK-NEXT: WIDEN-CAST ir<[[ZEXT_IDX:%.+]]> = zext ir<[[IDX]]> to i64
; CHECK-NEXT: CLONE ir<[[LD_IDX:%.+]]> = getelementptr inbounds ir<%B>, ir<[[ZEXT_IDX]]>
; CHECK-NEXT: vp<[[LD_PTR:%.+]]> = vector-pointer ir<[[LD_IDX]]>
; CHECK-NEXT: WIDEN ir<[[LD:%.+]]> = load vp<[[LD_PTR]]>, stride = ir<-4>, runtimeVF = vp<[[VF]]>
```
, it at least allows us to continue to try this path and ensures that the lit test cases of EVL folding remain vectorizable.
https://github.com/llvm/llvm-project/pull/128718
More information about the llvm-commits
mailing list