[llvm] [LV] Support strided memory accesses with a stride of -1 (PR #128718)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 13 01:27:02 PDT 2025


================
@@ -6132,6 +6174,16 @@ void LoopVectorizationCostModel::setCostBasedWideningDecision(ElementCount VF) {
                "Expected consecutive stride.");
         InstWidening Decision =
             ConsecutiveStride == 1 ? CM_Widen : CM_Widen_Reverse;
+        // Consider using strided load/store for consecutive reverse accesses to
+        // achieve more efficient memory operations.
+        if (ConsecutiveStride == -1 && stridedAccessCanBeWidened(&I, VF)) {
----------------
lukel97 wrote:

I can't imagine any target that would want to emit a non-decreasing consecutive strided access instead of a regular unit-stride access. So I think `Legal->isConsecutivePtr(ScalarTy, Ptr) != -1` makes more sense. 

In any case, aren't `stridedAccessCanBeWidened` and `setCostBasedWideningDecision` both checking `Legal->isConsecutivePtr(ScalarTy, Ptr) != -1` currently?

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


More information about the llvm-commits mailing list