Skip to content

Commit fd4bcc7

Browse files
committed
[VPlan] Move plain CFG construction to VPlanConstruction. (NFC)
1 parent 2a8344e commit fd4bcc7

File tree

8 files changed

+371
-476
lines changed

8 files changed

+371
-476
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"
@@ -9332,13 +9331,8 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
93329331
return !CM.requiresScalarEpilogue(VF.isVector());
93339332
},
93349333
Range);
9335-
auto Plan = std::make_unique<VPlan>(OrigLoop);
9336-
// Build hierarchical CFG.
9337-
// TODO: Convert to VPlan-transform and consoliate all transforms for VPlan
9338-
// creation.
9339-
VPlanHCFGBuilder HCFGBuilder(OrigLoop, LI, *Plan);
9340-
HCFGBuilder.buildPlainCFG();
9341-
9334+
DenseMap<VPBlockBase *, BasicBlock *> VPB2IRBB;
9335+
auto Plan = VPlanTransforms::buildPlainCFG(OrigLoop, *LI, VPB2IRBB);
93429336
VPlanTransforms::introduceRegions(*Plan, Legal->getWidestInductionType(), PSE,
93439337
RequiresScalarEpilogueCheck,
93449338
CM.foldTailByMasking(), OrigLoop);
@@ -9417,7 +9411,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
94179411
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(RPOT)) {
94189412
// Handle VPBBs down to the latch.
94199413
if (VPBB == LoopRegion->getExiting()) {
9420-
assert(!HCFGBuilder.getIRBBForVPB(VPBB) &&
9414+
assert(!VPB2IRBB.contains(VPBB) &&
94219415
"the latch block shouldn't have a corresponding IRBB");
94229416
VPBlockUtils::connectBlocks(PrevVPBB, VPBB);
94239417
break;
@@ -9433,7 +9427,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
94339427
// FIXME: At the moment, masks need to be placed at the beginning of the
94349428
// block, as blends introduced for phi nodes need to use it. The created
94359429
// blends should be sunk after the mask recipes.
9436-
RecipeBuilder.createBlockInMask(HCFGBuilder.getIRBBForVPB(VPBB));
9430+
RecipeBuilder.createBlockInMask(VPB2IRBB.lookup(VPBB));
94379431
}
94389432

94399433
// Convert input VPInstructions to widened recipes.
@@ -9637,12 +9631,8 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlan(VFRange &Range) {
96379631
assert(!OrigLoop->isInnermost());
96389632
assert(EnableVPlanNativePath && "VPlan-native path is not enabled.");
96399633

9640-
// Create new empty VPlan
9641-
auto Plan = std::make_unique<VPlan>(OrigLoop);
9642-
// Build hierarchical CFG
9643-
VPlanHCFGBuilder HCFGBuilder(OrigLoop, LI, *Plan);
9644-
HCFGBuilder.buildPlainCFG();
9645-
9634+
DenseMap<VPBlockBase *, BasicBlock *> VPB2IRBB;
9635+
auto Plan = VPlanTransforms::buildPlainCFG(OrigLoop, *LI, VPB2IRBB);
96469636
VPlanTransforms::introduceRegions(*Plan, Legal->getWidestInductionType(), PSE,
96479637
true, false, OrigLoop);
96489638

0 commit comments

Comments
 (0)