Skip to content

Commit 20177c4

Browse files
committed
[VPlan] Turn private members of VPlanTransforms to static funcs (NFC)
Private members of VPlanTransforms are only used inside VPlanTransforms.cpp, just make them static.
1 parent d332d88 commit 20177c4

File tree

2 files changed

+34
-47
lines changed

2 files changed

+34
-47
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -357,18 +357,9 @@ static void addReplicateRegions(VPlan &Plan) {
357357
}
358358
}
359359

360-
void VPlanTransforms::createAndOptimizeReplicateRegions(VPlan &Plan) {
361-
// Convert masked VPReplicateRecipes to if-then region blocks.
362-
addReplicateRegions(Plan);
363-
364-
bool ShouldSimplify = true;
365-
while (ShouldSimplify) {
366-
ShouldSimplify = sinkScalarOperands(Plan);
367-
ShouldSimplify |= mergeReplicateRegionsIntoSuccessors(Plan);
368-
ShouldSimplify |= VPlanTransforms::mergeBlocksIntoPredecessors(Plan);
369-
}
370-
}
371-
bool VPlanTransforms::mergeBlocksIntoPredecessors(VPlan &Plan) {
360+
/// Remove redundant VPBasicBlocks by merging them into their predecessor if
361+
/// the predecessor has a single successor.
362+
static bool mergeBlocksIntoPredecessors(VPlan &Plan) {
372363
SmallVector<VPBasicBlock *> WorkList;
373364
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
374365
vp_depth_first_deep(Plan.getEntry()))) {
@@ -395,7 +386,25 @@ bool VPlanTransforms::mergeBlocksIntoPredecessors(VPlan &Plan) {
395386
return !WorkList.empty();
396387
}
397388

398-
void VPlanTransforms::removeRedundantInductionCasts(VPlan &Plan) {
389+
void VPlanTransforms::createAndOptimizeReplicateRegions(VPlan &Plan) {
390+
// Convert masked VPReplicateRecipes to if-then region blocks.
391+
addReplicateRegions(Plan);
392+
393+
bool ShouldSimplify = true;
394+
while (ShouldSimplify) {
395+
ShouldSimplify = sinkScalarOperands(Plan);
396+
ShouldSimplify |= mergeReplicateRegionsIntoSuccessors(Plan);
397+
ShouldSimplify |= mergeBlocksIntoPredecessors(Plan);
398+
}
399+
}
400+
401+
/// Remove redundant casts of inductions.
402+
///
403+
/// Such redundant casts are casts of induction variables that can be ignored,
404+
/// because we already proved that the casted phi is equal to the uncasted phi
405+
/// in the vectorized loop. There is no need to vectorize the cast - the same
406+
/// value can be used for both the phi and casts in the vector loop.
407+
static void removeRedundantInductionCasts(VPlan &Plan) {
399408
for (auto &Phi : Plan.getVectorLoopRegion()->getEntryBasicBlock()->phis()) {
400409
auto *IV = dyn_cast<VPWidenIntOrFpInductionRecipe>(&Phi);
401410
if (!IV || IV->getTruncInst())
@@ -426,7 +435,9 @@ void VPlanTransforms::removeRedundantInductionCasts(VPlan &Plan) {
426435
}
427436
}
428437

429-
void VPlanTransforms::removeRedundantCanonicalIVs(VPlan &Plan) {
438+
/// Try to replace VPWidenCanonicalIVRecipes with a widened canonical IV
439+
/// recipe, if it exists.
440+
static void removeRedundantCanonicalIVs(VPlan &Plan) {
430441
VPCanonicalIVPHIRecipe *CanonicalIV = Plan.getCanonicalIV();
431442
VPWidenCanonicalIVRecipe *WidenNewIV = nullptr;
432443
for (VPUser *U : CanonicalIV->users()) {
@@ -462,7 +473,7 @@ void VPlanTransforms::removeRedundantCanonicalIVs(VPlan &Plan) {
462473
}
463474
}
464475

465-
void VPlanTransforms::removeDeadRecipes(VPlan &Plan) {
476+
static void removeDeadRecipes(VPlan &Plan) {
466477
ReversePostOrderTraversal<VPBlockDeepTraversalWrapper<VPBlockBase *>> RPOT(
467478
Plan.getEntry());
468479

@@ -531,7 +542,11 @@ static VPValue *createScalarIVSteps(VPlan &Plan, const InductionDescriptor &ID,
531542
return Steps;
532543
}
533544

534-
void VPlanTransforms::optimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
545+
/// If any user of a VPWidenIntOrFpInductionRecipe needs scalar values,
546+
/// provide them by building scalar steps off of the canonical scalar IV and
547+
/// update the original IV's users. This is an optional optimization to reduce
548+
/// the needs of vector extracts.
549+
static void optimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
535550
SmallVector<VPRecipeBase *> ToRemove;
536551
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
537552
bool HasOnlyVectorVFs = !Plan.hasVF(ElementCount::getFixed(1));
@@ -560,7 +575,9 @@ void VPlanTransforms::optimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
560575
}
561576
}
562577

563-
void VPlanTransforms::removeRedundantExpandSCEVRecipes(VPlan &Plan) {
578+
/// Remove redundant EpxandSCEVRecipes in \p Plan's entry block by replacing
579+
/// them with already existing recipes expanding the same SCEV expression.
580+
static void removeRedundantExpandSCEVRecipes(VPlan &Plan) {
564581
DenseMap<const SCEV *, VPValue *> SCEV2VPV;
565582

566583
for (VPRecipeBase &R :

llvm/lib/Transforms/Vectorize/VPlanTransforms.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -98,36 +98,6 @@ struct VPlanTransforms {
9898
/// VPlan directly.
9999
static void dropPoisonGeneratingRecipes(
100100
VPlan &Plan, function_ref<bool(BasicBlock *)> BlockNeedsPredication);
101-
102-
private:
103-
/// Remove redundant VPBasicBlocks by merging them into their predecessor if
104-
/// the predecessor has a single successor.
105-
static bool mergeBlocksIntoPredecessors(VPlan &Plan);
106-
107-
/// Remove redundant casts of inductions.
108-
///
109-
/// Such redundant casts are casts of induction variables that can be ignored,
110-
/// because we already proved that the casted phi is equal to the uncasted phi
111-
/// in the vectorized loop. There is no need to vectorize the cast - the same
112-
/// value can be used for both the phi and casts in the vector loop.
113-
static void removeRedundantInductionCasts(VPlan &Plan);
114-
115-
/// Try to replace VPWidenCanonicalIVRecipes with a widened canonical IV
116-
/// recipe, if it exists.
117-
static void removeRedundantCanonicalIVs(VPlan &Plan);
118-
119-
static void removeDeadRecipes(VPlan &Plan);
120-
121-
/// If any user of a VPWidenIntOrFpInductionRecipe needs scalar values,
122-
/// provide them by building scalar steps off of the canonical scalar IV and
123-
/// update the original IV's users. This is an optional optimization to reduce
124-
/// the needs of vector extracts.
125-
static void optimizeInductions(VPlan &Plan, ScalarEvolution &SE);
126-
127-
/// Remove redundant EpxandSCEVRecipes in \p Plan's entry block by replacing
128-
/// them with already existing recipes expanding the same SCEV expression.
129-
static void removeRedundantExpandSCEVRecipes(VPlan &Plan);
130-
131101
};
132102

133103
} // namespace llvm

0 commit comments

Comments
 (0)