Skip to content

Commit c144157

Browse files
committed
[SLP]Use last pointer instead of first for reversed strided stores.
Need to use the last address of the vectorized stores for the strided stores, not the first one, to correctly store the data.
1 parent f0f02b9 commit c144157

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13169,6 +13169,10 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
1316913169
} else {
1317013170
assert(E->State == TreeEntry::StridedVectorize &&
1317113171
"Expected either strided or conseutive stores.");
13172+
if (!E->ReorderIndices.empty()) {
13173+
SI = cast<StoreInst>(E->Scalars[E->ReorderIndices.front()]);
13174+
Ptr = SI->getPointerOperand();
13175+
}
1317213176
Align CommonAlignment = computeCommonAlignment<StoreInst>(E->Scalars);
1317313177
Type *StrideTy = DL->getIndexType(SI->getPointerOperandType());
1317413178
auto *Inst = Builder.CreateIntrinsic(

llvm/test/Transforms/SLPVectorizer/RISCV/strided-stores-vectorized.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ define void @store_reverse(ptr %p3) {
55
; CHECK-LABEL: @store_reverse(
66
; CHECK-NEXT: entry:
77
; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i64, ptr [[P3:%.*]], i64 8
8-
; CHECK-NEXT: [[ARRAYIDX14:%.*]] = getelementptr inbounds i64, ptr [[P3]], i64 4
8+
; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i64, ptr [[P3]], i64 7
99
; CHECK-NEXT: [[TMP0:%.*]] = load <4 x i64>, ptr [[P3]], align 8
1010
; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i64>, ptr [[ARRAYIDX1]], align 8
1111
; CHECK-NEXT: [[TMP2:%.*]] = shl <4 x i64> [[TMP0]], [[TMP1]]
12-
; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v4i64.p0.i64(<4 x i64> [[TMP2]], ptr align 8 [[ARRAYIDX14]], i64 -8, <4 x i1> <i1 true, i1 true, i1 true, i1 true>, i32 4)
12+
; CHECK-NEXT: call void @llvm.experimental.vp.strided.store.v4i64.p0.i64(<4 x i64> [[TMP2]], ptr align 8 [[ARRAYIDX2]], i64 -8, <4 x i1> <i1 true, i1 true, i1 true, i1 true>, i32 4)
1313
; CHECK-NEXT: ret void
1414
;
1515
entry:

0 commit comments

Comments
 (0)