Skip to content

Commit 1fcac6d

Browse files
committed
!fixup, address comments.
1 parent b57e641 commit 1fcac6d

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6905,14 +6905,14 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
69056905
if (isa<VPPartialReductionRecipe>(&R))
69066906
return true;
69076907

6908-
// The VPlan-based cost model can analysis if recipes is scalar
6908+
// The VPlan-based cost model can analyze if recipes are scalar
69096909
// recursively, but legacy cost model cannot.
69106910
if (auto *WidenMemR = dyn_cast<VPWidenMemoryRecipe>(&R)) {
6911-
if (WidenMemR &&
6911+
auto *AddrI = dyn_cast<Instruction>(
6912+
getLoadStorePointerOperand(&WidenMemR->getIngredient()));
6913+
if (WidenMemR && AddrI &&
69126914
vputils::isSingleScalar(WidenMemR->getAddr()) !=
6913-
CostCtx.CM.Legal->isUniform(
6914-
getLoadStorePointerOperand(&WidenMemR->getIngredient()),
6915-
VF))
6915+
CostCtx.isLegacyUniformAfterVectorization(AddrI, VF))
69166916
return true;
69176917
}
69186918

llvm/test/Transforms/LoopVectorize/RISCV/gather-scatter-cost.ll

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,14 @@ exit:
185185
ret void
186186
}
187187

188-
define void @store_to_addr_generated_from_invariant_addr(ptr noalias %p1, ptr noalias %p2, ptr %p3, i64 %N) {
188+
define void @store_to_addr_generated_from_invariant_addr(ptr noalias %p0, ptr noalias %p1, ptr noalias %p2, ptr %p3, i64 %N) {
189189
; CHECK-LABEL: @store_to_addr_generated_from_invariant_addr(
190190
; CHECK-NEXT: entry:
191191
; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[N:%.*]], 1
192192
; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
193193
; CHECK: vector.ph:
194+
; CHECK-NEXT: [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <vscale x 2 x ptr> poison, ptr [[P0:%.*]], i64 0
195+
; CHECK-NEXT: [[BROADCAST_SPLAT1:%.*]] = shufflevector <vscale x 2 x ptr> [[BROADCAST_SPLATINSERT2]], <vscale x 2 x ptr> poison, <vscale x 2 x i32> zeroinitializer
194196
; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 2 x i64> @llvm.stepvector.nxv2i64()
195197
; CHECK-NEXT: [[TMP2:%.*]] = mul <vscale x 2 x i64> [[TMP1]], splat (i64 1)
196198
; CHECK-NEXT: [[INDUCTION:%.*]] = add <vscale x 2 x i64> zeroinitializer, [[TMP2]]
@@ -203,7 +205,7 @@ define void @store_to_addr_generated_from_invariant_addr(ptr noalias %p1, ptr no
203205
; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[TMP4]], i64 0
204206
; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 2 x i64> [[BROADCAST_SPLATINSERT]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
205207
; CHECK-NEXT: [[TMP5:%.*]] = getelementptr i32, ptr [[P1:%.*]], <vscale x 2 x i64> [[VEC_IND]]
206-
; CHECK-NEXT: call void @llvm.vp.scatter.nxv2p0.nxv2p0(<vscale x 2 x ptr> zeroinitializer, <vscale x 2 x ptr> align 8 [[TMP5]], <vscale x 2 x i1> splat (i1 true), i32 [[TMP3]])
208+
; CHECK-NEXT: call void @llvm.vp.scatter.nxv2p0.nxv2p0(<vscale x 2 x ptr> [[BROADCAST_SPLAT1]], <vscale x 2 x ptr> align 8 [[TMP5]], <vscale x 2 x i1> splat (i1 true), i32 [[TMP3]])
207209
; CHECK-NEXT: [[TMP6:%.*]] = load i64, ptr [[P2:%.*]], align 4
208210
; CHECK-NEXT: [[BROADCAST_SPLATINSERT1:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[TMP6]], i64 0
209211
; CHECK-NEXT: [[BROADCAST_SPLAT2:%.*]] = shufflevector <vscale x 2 x i64> [[BROADCAST_SPLATINSERT1]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
@@ -215,23 +217,23 @@ define void @store_to_addr_generated_from_invariant_addr(ptr noalias %p1, ptr no
215217
; CHECK-NEXT: [[AVL_NEXT]] = sub nuw i64 [[AVL]], [[TMP8]]
216218
; CHECK-NEXT: [[VEC_IND_NEXT]] = add <vscale x 2 x i64> [[VEC_IND]], [[BROADCAST_SPLAT]]
217219
; CHECK-NEXT: [[TMP9:%.*]] = icmp eq i64 [[AVL_NEXT]], 0
218-
; CHECK-NEXT: br i1 [[TMP9]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP14:![0-9]+]]
220+
; CHECK-NEXT: br i1 [[TMP9]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP12:![0-9]+]]
219221
; CHECK: middle.block:
220222
; CHECK-NEXT: br label [[EXIT:%.*]]
221223
; CHECK: scalar.ph:
222224
; CHECK-NEXT: br label [[LOOP:%.*]]
223225
; CHECK: loop:
224226
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
225227
; CHECK-NEXT: [[ARRAYIDX11:%.*]] = getelementptr i32, ptr [[P1]], i64 [[IV]]
226-
; CHECK-NEXT: store ptr null, ptr [[ARRAYIDX11]], align 8
228+
; CHECK-NEXT: store ptr [[P0]], ptr [[ARRAYIDX11]], align 8
227229
; CHECK-NEXT: [[TMP10:%.*]] = load i64, ptr [[P2]], align 4
228230
; CHECK-NEXT: [[BITS_TO_GO:%.*]] = getelementptr i8, ptr [[P3]], i64 [[TMP10]]
229231
; CHECK-NEXT: store i32 0, ptr [[BITS_TO_GO]], align 4
230232
; CHECK-NEXT: store i32 0, ptr [[BITS_TO_GO]], align 4
231233
; CHECK-NEXT: store i8 0, ptr [[BITS_TO_GO]], align 1
232234
; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
233235
; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[IV]], [[N]]
234-
; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[EXIT]], label [[LOOP]], !llvm.loop [[LOOP15:![0-9]+]]
236+
; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[EXIT]], label [[LOOP]], !llvm.loop [[LOOP13:![0-9]+]]
235237
; CHECK: exit:
236238
; CHECK-NEXT: ret void
237239
;
@@ -241,7 +243,7 @@ entry:
241243
loop:
242244
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
243245
%arrayidx11 = getelementptr i32, ptr %p1, i64 %iv
244-
store ptr null, ptr %arrayidx11, align 8
246+
store ptr %p0, ptr %arrayidx11, align 8
245247
%0 = load i64, ptr %p2, align 4
246248
%bits_to_go = getelementptr i8, ptr %p3, i64 %0
247249
store i32 0, ptr %bits_to_go, align 4

0 commit comments

Comments
 (0)