Skip to content

Commit e0cfe7c

Browse files
committed
Address review comments
- Move `setStepValue` to `VPWidenInductionRecipe` - Make `simplifyBranchConditionForVFAndUF` a static, non-member function - Update a lit test
1 parent 135d7ab commit e0cfe7c

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,9 @@ class VPWidenInductionRecipe : public VPHeaderPHIRecipe {
17281728
VPValue *getStepValue() { return getOperand(1); }
17291729
const VPValue *getStepValue() const { return getOperand(1); }
17301730

1731+
/// Update the step value of the recipe.
1732+
void setStepValue(VPValue *V) { setOperand(1, V); }
1733+
17311734
PHINode *getPHINode() const { return cast<PHINode>(getUnderlyingValue()); }
17321735

17331736
/// Returns the induction descriptor for the recipe.
@@ -1802,9 +1805,6 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe {
18021805
VPSlotTracker &SlotTracker) const override;
18031806
#endif
18041807

1805-
/// Update the step value of the recipe.
1806-
void setStepValue(VPValue *V) { setOperand(1, V); }
1807-
18081808
VPValue *getVFValue() { return getOperand(2); }
18091809
const VPValue *getVFValue() const { return getOperand(2); }
18101810

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,9 +1160,11 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
11601160
return MadeChange;
11611161
}
11621162

1163-
bool VPlanTransforms::simplifyBranchConditionForVFAndUF(
1164-
VPlan &Plan, ElementCount BestVF, unsigned BestUF,
1165-
PredicatedScalarEvolution &PSE) {
1163+
/// Try to simplify the branch condition of \p Plan. This may restrict the
1164+
/// resulting plan to \p BestVF and \p BestUF.
1165+
static bool simplifyBranchConditionForVFAndUF(VPlan &Plan, ElementCount BestVF,
1166+
unsigned BestUF,
1167+
PredicatedScalarEvolution &PSE) {
11661168
VPRegionBlock *VectorRegion = Plan.getVectorLoopRegion();
11671169
VPBasicBlock *ExitingVPBB = VectorRegion->getExitingBasicBlock();
11681170
auto *Term = &ExitingVPBB->back();
@@ -1212,7 +1214,7 @@ bool VPlanTransforms::simplifyBranchConditionForVFAndUF(
12121214

12131215
VPBlockUtils::connectBlocks(Preheader, Header);
12141216
VPBlockUtils::connectBlocks(ExitingVPBB, Exit);
1215-
simplifyRecipes(Plan, *CanIVTy);
1217+
VPlanTransforms::simplifyRecipes(Plan, *CanIVTy);
12161218
} else {
12171219
// The vector region contains header phis for which we cannot remove the
12181220
// loop region yet.

llvm/lib/Transforms/Vectorize/VPlanTransforms.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,6 @@ struct VPlanTransforms {
9898
unsigned BestUF,
9999
PredicatedScalarEvolution &PSE);
100100

101-
/// Try to simplify the branch condition of \p Plan. This may restrict the
102-
/// resulting plan to \p BestVF and \p BestUF.
103-
static bool simplifyBranchConditionForVFAndUF(VPlan &Plan,
104-
ElementCount BestVF,
105-
unsigned BestUF,
106-
PredicatedScalarEvolution &PSE);
107-
108101
/// Apply VPlan-to-VPlan optimizations to \p Plan, including induction recipe
109102
/// optimizations, dead recipe removal, replicate region optimizations and
110103
/// block merging.

llvm/test/Transforms/LoopVectorize/AArch64/transform-narrow-interleave-to-widen-memory-remove-loop-region.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ define void @load_store_interleave_group_tc_2(ptr noalias %data) {
5151
; VF4-NEXT: br label %[[VECTOR_BODY:.*]]
5252
; VF4: [[VECTOR_BODY]]:
5353
; VF4-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[PRED_STORE_CONTINUE6:.*]] ]
54-
; VF4-NEXT: [[VEC_IND:%.*]] = phi <4 x i64> [ <i64 0, i64 1, i64 2, i64 3>, %[[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], %[[PRED_STORE_CONTINUE6]] ]
55-
; VF4-NEXT: [[TMP0:%.*]] = icmp ule <4 x i64> [[VEC_IND]], splat (i64 1)
54+
; VF4-NEXT: [[VEC_IND:%.*]] = phi <4 x i8> [ <i8 0, i8 1, i8 2, i8 3>, %[[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], %[[PRED_STORE_CONTINUE6]] ]
55+
; VF4-NEXT: [[TMP0:%.*]] = icmp ule <4 x i8> [[VEC_IND]], splat (i8 1)
5656
; VF4-NEXT: [[TMP1:%.*]] = extractelement <4 x i1> [[TMP0]], i32 0
5757
; VF4-NEXT: br i1 [[TMP1]], label %[[PRED_STORE_IF:.*]], label %[[PRED_STORE_CONTINUE:.*]]
5858
; VF4: [[PRED_STORE_IF]]:
@@ -109,7 +109,7 @@ define void @load_store_interleave_group_tc_2(ptr noalias %data) {
109109
; VF4-NEXT: store i64 [[TMP32]], ptr [[TMP31]], align 8
110110
; VF4-NEXT: br label %[[PRED_STORE_CONTINUE6]]
111111
; VF4: [[PRED_STORE_CONTINUE6]]:
112-
; VF4-NEXT: [[VEC_IND_NEXT]] = add <4 x i64> [[VEC_IND]], splat (i64 4)
112+
; VF4-NEXT: [[VEC_IND_NEXT]] = add <4 x i8> [[VEC_IND]], splat (i8 4)
113113
; VF4-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
114114
; VF4-NEXT: br i1 true, label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
115115
; VF4: [[MIDDLE_BLOCK]]:

0 commit comments

Comments
 (0)