[llvm] a6c4969 - [VPlan] Do not create dummy entry block (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 25 01:53:16 PDT 2021
Author: Florian Hahn
Date: 2021-10-25T09:52:58+01:00
New Revision: a6c4969f5f451d40a1eef86e75689e2d90aa3a4a
URL: https://github.com/llvm/llvm-project/commit/a6c4969f5f451d40a1eef86e75689e2d90aa3a4a
DIFF: https://github.com/llvm/llvm-project/commit/a6c4969f5f451d40a1eef86e75689e2d90aa3a4a.diff
LOG: [VPlan] Do not create dummy entry block (NFC).
At the moment a dummy entry block is created at the beginning of VPlan
construction. This dummy block is later removed again.
This means it is not easy to identify the VPlan header block in a
general fashion, because during recipe creation it is the single
successor of the entry block, while later it is the entry block.
To make getting the header easier, just skip creating the dummy block.
Reviewed By: Ayal
Differential Revision: https://reviews.llvm.org/D111299
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index ea3b773d2c20e..3612ae28165c4 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9291,20 +9291,22 @@ VPlanPtr LoopVectorizationPlanner::buildVPlanWithVPRecipes(
// Create a dummy pre-entry VPBasicBlock to start building the VPlan.
auto Plan = std::make_unique<VPlan>();
- VPBasicBlock *VPBB = new VPBasicBlock("Pre-Entry");
- Plan->setEntry(VPBB);
// Scan the body of the loop in a topological order to visit each basic block
// after having visited its predecessor basic blocks.
LoopBlocksDFS DFS(OrigLoop);
DFS.perform(LI);
+ VPBasicBlock *VPBB = nullptr;
for (BasicBlock *BB : make_range(DFS.beginRPO(), DFS.endRPO())) {
// Relevant instructions from basic block BB will be grouped into VPRecipe
// ingredients and fill a new VPBasicBlock.
unsigned VPBBsForBB = 0;
auto *FirstVPBBForBB = new VPBasicBlock(BB->getName());
- VPBlockUtils::insertBlockAfter(FirstVPBBForBB, VPBB);
+ if (VPBB)
+ VPBlockUtils::insertBlockAfter(FirstVPBBForBB, VPBB);
+ else
+ Plan->setEntry(FirstVPBBForBB);
VPBB = FirstVPBBForBB;
Builder.setInsertPoint(VPBB);
@@ -9363,17 +9365,11 @@ VPlanPtr LoopVectorizationPlanner::buildVPlanWithVPRecipes(
}
}
+ assert(isa<VPBasicBlock>(Plan->getEntry()) &&
+ !Plan->getEntry()->getEntryBasicBlock()->empty() &&
+ "entry block must be set to a non-empty VPBasicBlock");
RecipeBuilder.fixHeaderPhis();
- // Discard empty dummy pre-entry VPBasicBlock. Note that other VPBasicBlocks
- // may also be empty, such as the last one VPBB, reflecting original
- // basic-blocks with no recipes.
- VPBasicBlock *PreEntry = cast<VPBasicBlock>(Plan->getEntry());
- assert(PreEntry->empty() && "Expecting empty pre-entry block.");
- VPBlockBase *Entry = Plan->setEntry(PreEntry->getSingleSuccessor());
- VPBlockUtils::disconnectBlocks(PreEntry, Entry);
- delete PreEntry;
-
// ---------------------------------------------------------------------------
// Transform initial VPlan: Apply previously taken decisions, in order, to
// bring the VPlan to its final state.
More information about the llvm-commits
mailing list