Skip to content

Commit 68746a8

Browse files
committed
[LV] Move all VPlan transforms after initial VPlan construction.
Reorder VPlan transforms slightly so they are all grouped together, after disabling Value -> VPValue lookup. In terms of codegen impact, this should be NFC modulo a small number of instruction reorderings. Preparation to split up tryToBuildVPlanWithVPRecipes in a follow-up. Reviewed By: Ayal Differential Revision: https://reviews.llvm.org/D154640
1 parent 34f7396 commit 68746a8

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9053,18 +9053,10 @@ std::optional<VPlanPtr> LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
90539053
// bring the VPlan to its final state.
90549054
// ---------------------------------------------------------------------------
90559055

9056-
VPlanTransforms::removeRedundantCanonicalIVs(*Plan);
9057-
VPlanTransforms::removeRedundantInductionCasts(*Plan);
9058-
90599056
// Adjust the recipes for any inloop reductions.
90609057
adjustRecipesForReductions(cast<VPBasicBlock>(TopRegion->getExiting()), Plan,
90619058
RecipeBuilder, Range.Start);
90629059

9063-
// Sink users of fixed-order recurrence past the recipe defining the previous
9064-
// value and introduce FirstOrderRecurrenceSplice VPInstructions.
9065-
if (!VPlanTransforms::adjustFixedOrderRecurrences(*Plan, Builder))
9066-
return std::nullopt;
9067-
90689060
// Interleave memory: for each Interleave Group we marked earlier as relevant
90699061
// for this VPlan, replace the Recipes widening its memory instructions with a
90709062
// single VPInterleaveRecipe at its insertion point.
@@ -9121,6 +9113,14 @@ std::optional<VPlanPtr> LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
91219113
// in ways that accessing values using original IR values is incorrect.
91229114
Plan->disableValue2VPValue();
91239115

9116+
// Sink users of fixed-order recurrence past the recipe defining the previous
9117+
// value and introduce FirstOrderRecurrenceSplice VPInstructions.
9118+
if (!VPlanTransforms::adjustFixedOrderRecurrences(*Plan, Builder))
9119+
return std::nullopt;
9120+
9121+
VPlanTransforms::removeRedundantCanonicalIVs(*Plan);
9122+
VPlanTransforms::removeRedundantInductionCasts(*Plan);
9123+
91249124
VPlanTransforms::optimizeInductions(*Plan, *PSE.getSE());
91259125
VPlanTransforms::removeDeadRecipes(*Plan);
91269126

llvm/test/Transforms/LoopVectorize/interleaved-accesses.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,11 +1505,11 @@ define void @PR34743(ptr %a, ptr %b, i64 %n) {
15051505
; CHECK-NEXT: [[WIDE_VEC:%.*]] = load <8 x i16>, ptr [[TMP7]], align 4
15061506
; CHECK-NEXT: [[STRIDED_VEC:%.*]] = shufflevector <8 x i16> [[WIDE_VEC]], <8 x i16> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
15071507
; CHECK-NEXT: [[STRIDED_VEC4]] = shufflevector <8 x i16> [[WIDE_VEC]], <8 x i16> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
1508-
; CHECK-NEXT: [[TMP8:%.*]] = sext <4 x i16> [[STRIDED_VEC]] to <4 x i32>
1509-
; CHECK-NEXT: [[TMP9:%.*]] = shufflevector <4 x i16> [[VECTOR_RECUR]], <4 x i16> [[STRIDED_VEC4]], <4 x i32> <i32 3, i32 4, i32 5, i32 6>
1510-
; CHECK-NEXT: [[TMP10:%.*]] = sext <4 x i16> [[TMP9]] to <4 x i32>
1508+
; CHECK-NEXT: [[TMP8:%.*]] = shufflevector <4 x i16> [[VECTOR_RECUR]], <4 x i16> [[STRIDED_VEC4]], <4 x i32> <i32 3, i32 4, i32 5, i32 6>
1509+
; CHECK-NEXT: [[TMP9:%.*]] = sext <4 x i16> [[TMP8]] to <4 x i32>
1510+
; CHECK-NEXT: [[TMP10:%.*]] = sext <4 x i16> [[STRIDED_VEC]] to <4 x i32>
15111511
; CHECK-NEXT: [[TMP11:%.*]] = sext <4 x i16> [[STRIDED_VEC4]] to <4 x i32>
1512-
; CHECK-NEXT: [[TMP12:%.*]] = mul nsw <4 x i32> [[TMP10]], [[TMP8]]
1512+
; CHECK-NEXT: [[TMP12:%.*]] = mul nsw <4 x i32> [[TMP9]], [[TMP10]]
15131513
; CHECK-NEXT: [[TMP13:%.*]] = mul nsw <4 x i32> [[TMP12]], [[TMP11]]
15141514
; CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds i32, ptr [[B]], i64 [[INDEX]]
15151515
; CHECK-NEXT: store <4 x i32> [[TMP13]], ptr [[TMP14]], align 4, !alias.scope !36, !noalias !39

0 commit comments

Comments
 (0)