Skip to content

Commit 1bb836a

Browse files
committed
[VPlan] Move plain CFG construction to VPlanConstruction. (NFC)
1 parent 4d6cabd commit 1bb836a

File tree

8 files changed

+381
-488
lines changed

8 files changed

+381
-488
lines changed

llvm/lib/Transforms/Vectorize/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ add_llvm_component_library(LLVMVectorize
2424
VPlan.cpp
2525
VPlanAnalysis.cpp
2626
VPlanConstruction.cpp
27-
VPlanHCFGBuilder.cpp
2827
VPlanRecipes.cpp
2928
VPlanSLP.cpp
3029
VPlanTransforms.cpp

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
#include "VPlan.h"
6060
#include "VPlanAnalysis.h"
6161
#include "VPlanCFG.h"
62-
#include "VPlanHCFGBuilder.h"
6362
#include "VPlanHelpers.h"
6463
#include "VPlanPatternMatch.h"
6564
#include "VPlanTransforms.h"
@@ -9306,13 +9305,8 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
93069305
return !CM.requiresScalarEpilogue(VF.isVector());
93079306
},
93089307
Range);
9309-
auto Plan = std::make_unique<VPlan>(OrigLoop);
9310-
// Build hierarchical CFG.
9311-
// TODO: Convert to VPlan-transform and consoliate all transforms for VPlan
9312-
// creation.
9313-
VPlanHCFGBuilder HCFGBuilder(OrigLoop, LI, *Plan);
9314-
HCFGBuilder.buildPlainCFG();
9315-
9308+
DenseMap<VPBlockBase *, BasicBlock *> VPB2IRBB;
9309+
auto Plan = VPlanTransforms::buildPlainCFG(OrigLoop, *LI, VPB2IRBB);
93169310
VPlanTransforms::introduceTopLevelVectorLoopRegion(
93179311
*Plan, Legal->getWidestInductionType(), PSE, RequiresScalarEpilogueCheck,
93189312
CM.foldTailByMasking(), OrigLoop);
@@ -9391,7 +9385,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
93919385
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(RPOT)) {
93929386
// Handle VPBBs down to the latch.
93939387
if (VPBB == LoopRegion->getExiting()) {
9394-
assert(!HCFGBuilder.getIRBBForVPB(VPBB) &&
9388+
assert(!VPB2IRBB.contains(VPBB) &&
93959389
"the latch block shouldn't have a corresponding IRBB");
93969390
VPBlockUtils::connectBlocks(PrevVPBB, VPBB);
93979391
break;
@@ -9407,7 +9401,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
94079401
// FIXME: At the moment, masks need to be placed at the beginning of the
94089402
// block, as blends introduced for phi nodes need to use it. The created
94099403
// blends should be sunk after the mask recipes.
9410-
RecipeBuilder.createBlockInMask(HCFGBuilder.getIRBBForVPB(VPBB));
9404+
RecipeBuilder.createBlockInMask(VPB2IRBB.lookup(VPBB));
94119405
}
94129406

94139407
// Convert input VPInstructions to widened recipes.
@@ -9610,13 +9604,8 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlan(VFRange &Range) {
96109604
// the vectorization pipeline.
96119605
assert(!OrigLoop->isInnermost());
96129606
assert(EnableVPlanNativePath && "VPlan-native path is not enabled.");
9613-
9614-
// Create new empty VPlan
9615-
auto Plan = std::make_unique<VPlan>(OrigLoop);
9616-
// Build hierarchical CFG
9617-
VPlanHCFGBuilder HCFGBuilder(OrigLoop, LI, *Plan);
9618-
HCFGBuilder.buildPlainCFG();
9619-
9607+
DenseMap<VPBlockBase *, BasicBlock *> VPB2IRBB;
9608+
auto Plan = VPlanTransforms::buildPlainCFG(OrigLoop, *LI, VPB2IRBB);
96209609
VPlanTransforms::introduceTopLevelVectorLoopRegion(
96219610
*Plan, Legal->getWidestInductionType(), PSE, true, false, OrigLoop);
96229611

0 commit comments

Comments
 (0)