Skip to content

Commit 7897ab7

Browse files
committed
!fixup address latest comments, thanks!
1 parent a87d409 commit 7897ab7

File tree

6 files changed

+10
-23
lines changed

6 files changed

+10
-23
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2670,15 +2670,16 @@ void InnerLoopVectorizer::createInductionAdditionalBypassValues(
26702670
// Otherwise it is computed.
26712671
Value *EndValueFromAdditionalBypass = MainVectorTripCount;
26722672
if (OrigPhi != OldInduction) {
2673+
auto *BinOp = II.getInductionBinOp();
26732674
// Fast-math-flags propagate from the original induction instruction.
2674-
if (isa_and_nonnull<FPMathOperator>(II.getInductionBinOp()))
2675+
if (isa_and_nonnull<FPMathOperator>(BinOp))
26752676
BypassBuilder.setFastMathFlags(
26762677
II.getInductionBinOp()->getFastMathFlags());
26772678

26782679
// Compute the end value for the additional bypass.
2679-
EndValueFromAdditionalBypass = emitTransformedIndex(
2680-
BypassBuilder, MainVectorTripCount, II.getStartValue(), Step,
2681-
II.getKind(), II.getInductionBinOp());
2680+
EndValueFromAdditionalBypass =
2681+
emitTransformedIndex(BypassBuilder, MainVectorTripCount,
2682+
II.getStartValue(), Step, II.getKind(), BinOp);
26822683
EndValueFromAdditionalBypass->setName("ind.end");
26832684
}
26842685

@@ -8857,15 +8858,11 @@ static void addCanonicalIVRecipes(VPlan &Plan, Type *IdxTy, bool HasNUW,
88578858
/// Create and return a ResumePhi for \p PhiR, if it is wide induction recipe.
88588859
/// If the induction recipe is not canonical, creates a VPDerivedIVRecipe to
88598860
/// compute the end value of the induction.
8860-
static VPValue *addResumePhiRecipeForInduction(VPHeaderPHIRecipe *PhiR,
8861+
static VPValue *addResumePhiRecipeForInduction(VPWidenInductionRecipe *WideIV,
88618862
VPBuilder &VectorPHBuilder,
88628863
VPBuilder &ScalarPHBuilder,
88638864
VPTypeAnalysis &TypeInfo,
88648865
VPValue *VectorTC) {
8865-
auto *WideIV = dyn_cast<VPWidenInductionRecipe>(PhiR);
8866-
if (!WideIV)
8867-
return nullptr;
8868-
88698866
auto *WideIntOrFp = dyn_cast<VPWidenIntOrFpInductionRecipe>(WideIV);
88708867
// Truncated wide inductions resume from the last lane of their vector value
88718868
// in the last vector iteration which is handled elsewhere.
@@ -8916,9 +8913,9 @@ static void addScalarResumePhis(VPRecipeBuilder &Builder, VPlan &Plan) {
89168913
break;
89178914

89188915
auto *VectorPhiR = cast<VPHeaderPHIRecipe>(Builder.getRecipe(ScalarPhiI));
8919-
if (isa<VPWidenInductionRecipe>(VectorPhiR)) {
8916+
if (auto *WideIVR = dyn_cast<VPWidenInductionRecipe>(VectorPhiR)) {
89208917
if (VPValue *ResumePhi = addResumePhiRecipeForInduction(
8921-
VectorPhiR, VectorPHBuilder, ScalarPHBuilder, TypeInfo,
8918+
WideIVR, VectorPHBuilder, ScalarPHBuilder, TypeInfo,
89228919
&Plan.getVectorTripCount())) {
89238920
ScalarPhiIRI->addOperand(ResumePhi);
89248921
continue;
@@ -10084,6 +10081,7 @@ static void preparePlanForMainVectorLoop(VPlan &MainPlan, VPlan &EpiPlan) {
1008410081
0, MainPlan.getOrAddLiveIn(Constant::getNullValue(IRI->getType())));
1008510082
ResumePhi->eraseFromParent();
1008610083
}
10084+
VPlanTransforms::removeDeadRecipes(MainPlan);
1008710085

1008810086
using namespace VPlanPatternMatch;
1008910087
VPBasicBlock *MainScalarPH = MainPlan.getScalarPreheader();

llvm/test/Transforms/LoopVectorize/AArch64/low_trip_count_predicates.ll

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ target triple = "aarch64-unknown-linux-gnu"
3535
; DEBUG: LV: can fold tail by masking.
3636
; DEBUG: Executing best plan with VF=vscale x 16, UF=1
3737

38-
; TODO: Clean up unused add instruction computing the end value of the
39-
; induction, which gets created during execution of the main plan once
40-
; VPlan's scope includes both vector loops.
4138
define void @low_vf_ic_is_better(ptr nocapture noundef %p, i32 %tc, i16 noundef %val) {
4239
; CHECK-VS1-LABEL: define void @low_vf_ic_is_better(
4340
; CHECK-VS1-SAME: ptr nocapture noundef [[P:%.*]], i32 [[TC:%.*]], i16 noundef [[VAL:%.*]]) #[[ATTR0:[0-9]+]] {
@@ -77,7 +74,6 @@ define void @low_vf_ic_is_better(ptr nocapture noundef %p, i32 %tc, i16 noundef
7774
; CHECK-VS1-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP3]], [[N_MOD_VF]]
7875
; CHECK-VS1-NEXT: [[TMP18:%.*]] = call i64 @llvm.vscale.i64()
7976
; CHECK-VS1-NEXT: [[TMP19:%.*]] = mul i64 [[TMP18]], 16
80-
; CHECK-VS1-NEXT: [[TMP40:%.*]] = add i64 [[TMP0]], [[N_VEC]]
8177
; CHECK-VS1-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 16 x i8> poison, i8 [[CONV]], i64 0
8278
; CHECK-VS1-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 16 x i8> [[BROADCAST_SPLATINSERT]], <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer
8379
; CHECK-VS1-NEXT: br label %[[VECTOR_BODY:.*]]
@@ -186,7 +182,6 @@ define void @low_vf_ic_is_better(ptr nocapture noundef %p, i32 %tc, i16 noundef
186182
; CHECK-VS2-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP3]], [[N_MOD_VF]]
187183
; CHECK-VS2-NEXT: [[TMP18:%.*]] = call i64 @llvm.vscale.i64()
188184
; CHECK-VS2-NEXT: [[TMP19:%.*]] = mul i64 [[TMP18]], 8
189-
; CHECK-VS2-NEXT: [[TMP40:%.*]] = add i64 [[TMP0]], [[N_VEC]]
190185
; CHECK-VS2-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 8 x i8> poison, i8 [[CONV]], i64 0
191186
; CHECK-VS2-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 8 x i8> [[BROADCAST_SPLATINSERT]], <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer
192187
; CHECK-VS2-NEXT: br label %[[VECTOR_BODY:.*]]

llvm/test/Transforms/LoopVectorize/AArch64/sve-tail-folding-forced.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ target triple = "aarch64-unknown-linux-gnu"
1111
; VPLANS-LABEL: Checking a loop in 'simple_memset'
1212
; VPLANS: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF>=1' {
1313
; VPLANS-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
14-
; VPLANS-NEXT: Live-in vp<[[VTC:%.+]]> = vector-trip-count
15-
; VPLANS-NEXT: vp<[[TC:%[0-9]+]]> = original trip-count
14+
; VPLANS: vp<[[TC:%[0-9]+]]> = original trip-count
1615
; VPLANS-EMPTY:
1716
; VPLANS-NEXT: ir-bb<entry>:
1817
; VPLANS-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (1 umax %n)

llvm/test/Transforms/LoopVectorize/X86/gather_scatter.ll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,6 @@ define void @test_gather_not_profitable_pr48429(i32 %d, ptr readonly noalias %pt
639639
; AVX512: vector.ph:
640640
; AVX512-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP3]], 16
641641
; AVX512-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP3]], [[N_MOD_VF]]
642-
; AVX512-NEXT: [[TMP36:%.*]] = mul i64 [[N_VEC]], 4
643-
; AVX512-NEXT: [[TMP37:%.*]] = getelementptr i8, ptr [[PTR]], i64 [[TMP36]]
644642
; AVX512-NEXT: [[TMP13:%.*]] = mul i64 [[N_VEC]], 64
645643
; AVX512-NEXT: [[IND_END:%.*]] = getelementptr i8, ptr [[DEST]], i64 [[TMP13]]
646644
; AVX512-NEXT: br label [[VECTOR_BODY:%.*]]

llvm/test/Transforms/LoopVectorize/epilog-vectorization-any-of-reductions.ll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,6 @@ define i1 @any_of_reduction_i1_epilog2(ptr %start, ptr %end, i64 %x) {
331331
; CHECK: vector.ph:
332332
; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP3]], 4
333333
; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP3]], [[N_MOD_VF]]
334-
; CHECK-NEXT: [[TMP50:%.*]] = mul i64 [[N_VEC]], 16
335-
; CHECK-NEXT: [[TMP51:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP50]]
336334
; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i64> poison, i64 [[X]], i64 0
337335
; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i64> [[BROADCAST_SPLATINSERT]], <4 x i64> poison, <4 x i32> zeroinitializer
338336
; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]

llvm/test/Transforms/LoopVectorize/optimal-epilog-vectorization.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ define dso_local signext i32 @f2(ptr noalias %A, ptr noalias %B, i32 signext %n)
175175
; CHECK: vector.ph:
176176
; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[WIDE_TRIP_COUNT]], 4
177177
; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[WIDE_TRIP_COUNT]], [[N_MOD_VF]]
178-
; CHECK-NEXT: [[TMP34:%.*]] = trunc i64 [[N_VEC]] to i32
179178
; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
180179
; CHECK: vector.body:
181180
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]

0 commit comments

Comments
 (0)