Skip to content

Commit 56b05a0

Browse files
committed
[VPlan] Use VFxUF in VPWidenPointerInductionRecipe.
Use VFxUF VPValue instead of computing VF * UF explicitly.
1 parent 5ae8f25 commit 56b05a0

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3364,9 +3364,8 @@ void VPWidenPointerInductionRecipe::execute(VPTransformState &State) {
33643364
if (CurrentPart == 0) {
33653365
// The recipe represents the first part of the pointer induction. Create the
33663366
// GEP to increment the phi across all unrolled parts.
3367-
unsigned UF = getParent()->getPlan()->getUF();
33683367
Value *NumUnrolledElems =
3369-
State.Builder.CreateMul(RuntimeVF, ConstantInt::get(PhiType, UF));
3368+
State.get(&getParent()->getPlan()->getVFxUF(), true);
33703369

33713370
Value *InductionGEP = GetElementPtrInst::Create(
33723371
State.Builder.getInt8Ty(), NewPointerPhi,

llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-gep.ll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ define void @pointer_induction_used_as_vector(ptr noalias %start.1, ptr noalias
6969
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
7070
; CHECK-NEXT: [[TMP7:%.*]] = call i64 @llvm.vscale.i64()
7171
; CHECK-NEXT: [[TMP8:%.*]] = mul i64 [[TMP7]], 2
72-
; CHECK-NEXT: [[TMP9:%.*]] = mul i64 [[TMP8]], 1
73-
; CHECK-NEXT: [[TMP10:%.*]] = mul i64 1, [[TMP9]]
72+
; CHECK-NEXT: [[TMP10:%.*]] = mul i64 1, [[TMP6]]
7473
; CHECK-NEXT: [[TMP11:%.*]] = mul i64 [[TMP8]], 0
7574
; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[TMP11]], i64 0
7675
; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <vscale x 2 x i64> [[DOTSPLATINSERT]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
@@ -162,8 +161,7 @@ define void @pointer_induction(ptr noalias %start, i64 %N) {
162161
; CHECK-NEXT: [[INDEX2:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
163162
; CHECK-NEXT: [[TMP7:%.*]] = call i64 @llvm.vscale.i64()
164163
; CHECK-NEXT: [[TMP8:%.*]] = mul i64 [[TMP7]], 2
165-
; CHECK-NEXT: [[TMP9:%.*]] = mul i64 [[TMP8]], 1
166-
; CHECK-NEXT: [[TMP10:%.*]] = mul i64 1, [[TMP9]]
164+
; CHECK-NEXT: [[TMP10:%.*]] = mul i64 1, [[TMP6]]
167165
; CHECK-NEXT: [[TMP11:%.*]] = mul i64 [[TMP8]], 0
168166
; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[TMP11]], i64 0
169167
; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <vscale x 2 x i64> [[DOTSPLATINSERT]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer

llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ define i32 @pointer_iv_mixed(ptr noalias %a, ptr noalias %b, i64 %n) #0 {
240240
; CHECK-NEXT: [[POINTER_PHI:%.*]] = phi ptr [ [[A]], [[VECTOR_PH]] ], [ [[PTR_IND:%.*]], [[VECTOR_BODY]] ]
241241
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
242242
; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <vscale x 2 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP12:%.*]], [[VECTOR_BODY]] ]
243-
; CHECK-NEXT: [[TMP7:%.*]] = call i64 @llvm.vscale.i64()
244-
; CHECK-NEXT: [[TMP8:%.*]] = shl nuw nsw i64 [[TMP7]], 3
243+
; CHECK-NEXT: [[TMP8:%.*]] = shl nuw nsw i64 [[TMP5]], 3
245244
; CHECK-NEXT: [[TMP9:%.*]] = call <vscale x 2 x i64> @llvm.stepvector.nxv2i64()
246245
; CHECK-NEXT: [[TMP10:%.*]] = shl <vscale x 2 x i64> [[TMP9]], splat (i64 2)
247246
; CHECK-NEXT: [[VECTOR_GEP:%.*]] = getelementptr i8, ptr [[POINTER_PHI]], <vscale x 2 x i64> [[TMP10]]
@@ -315,8 +314,7 @@ define void @phi_used_in_vector_compare_and_scalar_indvar_update_and_store(ptr %
315314
; CHECK: vector.body:
316315
; CHECK-NEXT: [[POINTER_PHI:%.*]] = phi ptr [ [[PTR:%.*]], [[VECTOR_PH]] ], [ [[PTR_IND:%.*]], [[VECTOR_BODY]] ]
317316
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
318-
; CHECK-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64()
319-
; CHECK-NEXT: [[TMP3:%.*]] = shl nuw nsw i64 [[TMP2]], 2
317+
; CHECK-NEXT: [[TMP3:%.*]] = shl nuw nsw i64 [[TMP0]], 2
320318
; CHECK-NEXT: [[TMP4:%.*]] = call <vscale x 2 x i64> @llvm.stepvector.nxv2i64()
321319
; CHECK-NEXT: [[TMP5:%.*]] = shl <vscale x 2 x i64> [[TMP4]], splat (i64 1)
322320
; CHECK-NEXT: [[VECTOR_GEP:%.*]] = getelementptr i8, ptr [[POINTER_PHI]], <vscale x 2 x i64> [[TMP5]]

llvm/test/Transforms/LoopVectorize/RISCV/strided-accesses.ll

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,7 @@ define void @single_constant_stride_ptr_iv(ptr %p) {
172172
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
173173
; CHECK-NEXT: [[TMP9:%.*]] = call i64 @llvm.vscale.i64()
174174
; CHECK-NEXT: [[TMP10:%.*]] = mul i64 [[TMP9]], 4
175-
; CHECK-NEXT: [[TMP11:%.*]] = mul i64 [[TMP10]], 1
176-
; CHECK-NEXT: [[TMP12:%.*]] = mul i64 8, [[TMP11]]
175+
; CHECK-NEXT: [[TMP12:%.*]] = mul i64 8, [[TMP8]]
177176
; CHECK-NEXT: [[TMP13:%.*]] = mul i64 [[TMP10]], 0
178177
; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 4 x i64> poison, i64 [[TMP13]], i64 0
179178
; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <vscale x 4 x i64> [[DOTSPLATINSERT]], <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
@@ -771,8 +770,7 @@ define void @double_stride_ptr_iv(ptr %p, ptr %p2, i64 %stride) {
771770
; STRIDED-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
772771
; STRIDED-NEXT: [[TMP14:%.*]] = call i64 @llvm.vscale.i64()
773772
; STRIDED-NEXT: [[TMP15:%.*]] = mul i64 [[TMP14]], 4
774-
; STRIDED-NEXT: [[TMP16:%.*]] = mul i64 [[TMP15]], 1
775-
; STRIDED-NEXT: [[TMP17:%.*]] = mul i64 [[STRIDE]], [[TMP16]]
773+
; STRIDED-NEXT: [[TMP17:%.*]] = mul i64 [[STRIDE]], [[TMP13]]
776774
; STRIDED-NEXT: [[TMP18:%.*]] = mul i64 [[TMP15]], 0
777775
; STRIDED-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 4 x i64> poison, i64 [[TMP18]], i64 0
778776
; STRIDED-NEXT: [[DOTSPLAT:%.*]] = shufflevector <vscale x 4 x i64> [[DOTSPLATINSERT]], <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
@@ -784,8 +782,7 @@ define void @double_stride_ptr_iv(ptr %p, ptr %p2, i64 %stride) {
784782
; STRIDED-NEXT: [[VECTOR_GEP:%.*]] = getelementptr i8, ptr [[POINTER_PHI]], <vscale x 4 x i64> [[TMP21]]
785783
; STRIDED-NEXT: [[TMP22:%.*]] = call i64 @llvm.vscale.i64()
786784
; STRIDED-NEXT: [[TMP23:%.*]] = mul i64 [[TMP22]], 4
787-
; STRIDED-NEXT: [[TMP24:%.*]] = mul i64 [[TMP23]], 1
788-
; STRIDED-NEXT: [[TMP25:%.*]] = mul i64 [[STRIDE]], [[TMP24]]
785+
; STRIDED-NEXT: [[TMP25:%.*]] = mul i64 [[STRIDE]], [[TMP13]]
789786
; STRIDED-NEXT: [[TMP26:%.*]] = mul i64 [[TMP23]], 0
790787
; STRIDED-NEXT: [[DOTSPLATINSERT13:%.*]] = insertelement <vscale x 4 x i64> poison, i64 [[TMP26]], i64 0
791788
; STRIDED-NEXT: [[DOTSPLAT14:%.*]] = shufflevector <vscale x 4 x i64> [[DOTSPLATINSERT13]], <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer

0 commit comments

Comments
 (0)