Skip to content

Commit e232d28

Browse files
committed
[VPlan] Move plain CFG construction to VPlanConstruction. (NFC)
Follow-up as discussed in #129402. After bc03d6c, the VPlanHCFGBuilder doesn't actually build a HCFG any longer. Move what remains directly into VPlanConstruction.cpp.
1 parent 30747cf commit e232d28

File tree

9 files changed

+358
-464
lines changed

9 files changed

+358
-464
lines changed

llvm/lib/Transforms/Vectorize/CMakeLists.txt

-1
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

+6-16
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"
@@ -9557,13 +9556,8 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
95579556
return !CM.requiresScalarEpilogue(VF.isVector());
95589557
},
95599558
Range);
9560-
auto Plan = std::make_unique<VPlan>(OrigLoop);
9561-
// Build hierarchical CFG.
9562-
// TODO: Convert to VPlan-transform and consolidate all transforms for VPlan
9563-
// creation.
9564-
VPlanHCFGBuilder HCFGBuilder(OrigLoop, LI, *Plan);
9565-
HCFGBuilder.buildPlainCFG();
9566-
9559+
DenseMap<VPBlockBase *, BasicBlock *> VPB2IRBB;
9560+
auto Plan = VPlanTransforms::buildPlainCFG(OrigLoop, *LI, VPB2IRBB);
95679561
VPlanTransforms::createLoopRegions(*Plan, Legal->getWidestInductionType(),
95689562
PSE, RequiresScalarEpilogueCheck,
95699563
CM.foldTailByMasking(), OrigLoop);
@@ -9642,7 +9636,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
96429636
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(RPOT)) {
96439637
// Handle VPBBs down to the latch.
96449638
if (VPBB == LoopRegion->getExiting()) {
9645-
assert(!HCFGBuilder.getIRBBForVPB(VPBB) &&
9639+
assert(!VPB2IRBB.contains(VPBB) &&
96469640
"the latch block shouldn't have a corresponding IRBB");
96479641
VPBlockUtils::connectBlocks(PrevVPBB, VPBB);
96489642
break;
@@ -9658,7 +9652,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
96589652
// FIXME: At the moment, masks need to be placed at the beginning of the
96599653
// block, as blends introduced for phi nodes need to use it. The created
96609654
// blends should be sunk after the mask recipes.
9661-
RecipeBuilder.createBlockInMask(HCFGBuilder.getIRBBForVPB(VPBB));
9655+
RecipeBuilder.createBlockInMask(VPB2IRBB.lookup(VPBB));
96629656
}
96639657

96649658
// Convert input VPInstructions to widened recipes.
@@ -9862,12 +9856,8 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlan(VFRange &Range) {
98629856
assert(!OrigLoop->isInnermost());
98639857
assert(EnableVPlanNativePath && "VPlan-native path is not enabled.");
98649858

9865-
// Create new empty VPlan
9866-
auto Plan = std::make_unique<VPlan>(OrigLoop);
9867-
// Build hierarchical CFG
9868-
VPlanHCFGBuilder HCFGBuilder(OrigLoop, LI, *Plan);
9869-
HCFGBuilder.buildPlainCFG();
9870-
9859+
DenseMap<VPBlockBase *, BasicBlock *> VPB2IRBB;
9860+
auto Plan = VPlanTransforms::buildPlainCFG(OrigLoop, *LI, VPB2IRBB);
98719861
VPlanTransforms::createLoopRegions(*Plan, Legal->getWidestInductionType(),
98729862
PSE, true, false, OrigLoop);
98739863

0 commit comments

Comments
 (0)