[llvm] 6abce17 - [VPlan] Use Exiting-block instead of Exit-block terminology (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sat May 28 13:16:23 PDT 2022
Author: Florian Hahn
Date: 2022-05-28T21:16:05+01:00
New Revision: 6abce17fc285747fb9b5522db2acab5fc06cabe6
URL: https://github.com/llvm/llvm-project/commit/6abce17fc285747fb9b5522db2acab5fc06cabe6
DIFF: https://github.com/llvm/llvm-project/commit/6abce17fc285747fb9b5522db2acab5fc06cabe6.diff
LOG: [VPlan] Use Exiting-block instead of Exit-block terminology (NFC).
In LLVM's common loop terminology, an exit block is a block outside a
loop with a predecessor inside the loop. An exiting block is a block
inside the loop which branches to an exit block outside the loop.
This patch updates a few places where VPlan was using ExitBlock for a
block exiting a region. Those instances have been updated to use
ExitingBlock.
Reviewed By: Ayal
Differential Revision: https://reviews.llvm.org/D126173
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp
llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp
llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 1a0dea02b340d..579d2dfb357dd 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3694,7 +3694,7 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State,
// Forget the original basic block.
PSE.getSE()->forgetLoop(OrigLoop);
- VPBasicBlock *LatchVPBB = Plan.getVectorLoopRegion()->getExitBasicBlock();
+ VPBasicBlock *LatchVPBB = Plan.getVectorLoopRegion()->getExitingBasicBlock();
Loop *VectorLoop = LI->getLoopFor(State.CFG.VPBB2IRBB[LatchVPBB]);
if (Cost->requiresScalarEpilogue(VF)) {
// No edge from the middle block to the unique exit block has been inserted
@@ -3905,7 +3905,7 @@ void InnerLoopVectorizer::fixReduction(VPReductionPHIRecipe *PhiR,
Type *PhiTy = OrigPhi->getType();
VPBasicBlock *LatchVPBB =
- PhiR->getParent()->getEnclosingLoopRegion()->getExitBasicBlock();
+ PhiR->getParent()->getEnclosingLoopRegion()->getExitingBasicBlock();
BasicBlock *VectorLoopLatch = State.CFG.VPBB2IRBB[LatchVPBB];
// If tail is folded by masking, the vector value to leave the loop should be
// a Select choosing between the vectorized LoopExitInst and vectorized Phi,
@@ -8684,7 +8684,7 @@ static void addCanonicalIVRecipes(VPlan &Plan, Type *IdxTy, DebugLoc DL,
{CanonicalIVPHI}, DL);
CanonicalIVPHI->addOperand(CanonicalIVIncrement);
- VPBasicBlock *EB = TopRegion->getExitBasicBlock();
+ VPBasicBlock *EB = TopRegion->getExitingBasicBlock();
if (IsVPlanNative)
EB->setCondBit(nullptr);
EB->appendRecipe(CanonicalIVIncrement);
@@ -8978,7 +8978,7 @@ VPlanPtr LoopVectorizationPlanner::buildVPlanWithVPRecipes(
Ind->moveBefore(*HeaderVPBB, HeaderVPBB->getFirstNonPhi());
// Adjust the recipes for any inloop reductions.
- adjustRecipesForReductions(cast<VPBasicBlock>(TopRegion->getExit()), Plan,
+ adjustRecipesForReductions(cast<VPBasicBlock>(TopRegion->getExiting()), Plan,
RecipeBuilder, Range.Start);
// Introduce a recipe to combine the incoming and previous values of a
@@ -9066,7 +9066,7 @@ VPlanPtr LoopVectorizationPlanner::buildVPlanWithVPRecipes(
// Fold Exit block into its predecessor if possible.
// TODO: Fold block earlier once all VPlan transforms properly maintain a
// VPBasicBlock as exit.
- VPBlockUtils::tryToMergeBlockIntoPredecessor(TopRegion->getExit());
+ VPBlockUtils::tryToMergeBlockIntoPredecessor(TopRegion->getExiting());
assert(VPlanVerifier::verifyPlanIsValid(*Plan) && "VPlan is invalid");
return Plan;
@@ -9110,8 +9110,8 @@ VPlanPtr LoopVectorizationPlanner::buildVPlan(VFRange &Range) {
// code-generation.
VPRegionBlock *LoopRegion = Plan->getVectorLoopRegion();
VPBasicBlock *Preheader = LoopRegion->getEntryBasicBlock();
- VPBasicBlock *Exit = LoopRegion->getExitBasicBlock();
- VPBlockBase *Latch = Exit->getSinglePredecessor();
+ VPBasicBlock *Exiting = LoopRegion->getExitingBasicBlock();
+ VPBlockBase *Latch = Exiting->getSinglePredecessor();
VPBlockBase *Header = Preheader->getSingleSuccessor();
// 1. Move preheader block out of main vector loop.
@@ -9120,16 +9120,16 @@ VPlanPtr LoopVectorizationPlanner::buildVPlan(VFRange &Range) {
VPBlockUtils::connectBlocks(Preheader, LoopRegion);
Plan->setEntry(Preheader);
- // 2. Disconnect backedge and exit block.
+ // 2. Disconnect backedge and exiting block.
VPBlockUtils::disconnectBlocks(Latch, Header);
- VPBlockUtils::disconnectBlocks(Latch, Exit);
+ VPBlockUtils::disconnectBlocks(Latch, Exiting);
- // 3. Update entry and exit of main vector loop region.
+ // 3. Update entry and exiting of main vector loop region.
LoopRegion->setEntry(Header);
- LoopRegion->setExit(Latch);
+ LoopRegion->setExiting(Latch);
- // 4. Remove exit block.
- delete Exit;
+ // 4. Remove exiting block.
+ delete Exiting;
addCanonicalIVRecipes(*Plan, Legal->getWidestInductionType(), DebugLoc(),
true, true);
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 17df347e0866f..d2e844fb09525 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -158,25 +158,25 @@ void VPBlockBase::setPlan(VPlan *ParentPlan) {
}
/// \return the VPBasicBlock that is the exit of Block, possibly indirectly.
-const VPBasicBlock *VPBlockBase::getExitBasicBlock() const {
+const VPBasicBlock *VPBlockBase::getExitingBasicBlock() const {
const VPBlockBase *Block = this;
while (const VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block))
- Block = Region->getExit();
+ Block = Region->getExiting();
return cast<VPBasicBlock>(Block);
}
-VPBasicBlock *VPBlockBase::getExitBasicBlock() {
+VPBasicBlock *VPBlockBase::getExitingBasicBlock() {
VPBlockBase *Block = this;
while (VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block))
- Block = Region->getExit();
+ Block = Region->getExiting();
return cast<VPBasicBlock>(Block);
}
VPBlockBase *VPBlockBase::getEnclosingBlockWithSuccessors() {
if (!Successors.empty() || !Parent)
return this;
- assert(Parent->getExit() == this &&
- "Block w/o successors not the exit of its parent.");
+ assert(Parent->getExiting() == this &&
+ "Block w/o successors not the exiting block of its parent.");
return Parent->getEnclosingBlockWithSuccessors();
}
@@ -261,7 +261,7 @@ VPBasicBlock::createEmptyBasicBlock(VPTransformState::CFGState &CFG) {
// Hook up the new basic block to its predecessors.
for (VPBlockBase *PredVPBlock : getHierarchicalPredecessors()) {
- VPBasicBlock *PredVPBB = PredVPBlock->getExitBasicBlock();
+ VPBasicBlock *PredVPBB = PredVPBlock->getExitingBasicBlock();
auto &PredVPSuccessors = PredVPBB->getSuccessors();
BasicBlock *PredBB = CFG.VPBB2IRBB[PredVPBB];
@@ -298,14 +298,14 @@ VPBasicBlock::createEmptyBasicBlock(VPTransformState::CFGState &CFG) {
"Trying to reset an existing successor block.");
PredBBTerminator->setSuccessor(idx, NewBB);
} else {
- // PredVPBB is the exit block of a loop region. Connect its successor
+ // PredVPBB is the exiting block of a loop region. Connect its successor
// outside the region.
auto *LoopRegion = cast<VPRegionBlock>(PredVPBB->getParent());
assert(!LoopRegion->isReplicator() &&
"predecessor must be in a loop region");
assert(PredVPSuccessors.empty() &&
- LoopRegion->getExitBasicBlock() == PredVPBB &&
- "PredVPBB must be the exit block of its parent region");
+ LoopRegion->getExitingBasicBlock() == PredVPBB &&
+ "PredVPBB must be the exiting block of its parent region");
assert(this == LoopRegion->getSingleSuccessor() &&
"the current block must be the single successor of the region");
PredBBTerminator->setSuccessor(0, NewBB);
@@ -334,7 +334,7 @@ void VPBasicBlock::execute(VPTransformState *State) {
State->CFG.PrevBB = NewBB;
} else if (PrevVPBB && /* A */
!((SingleHPred = getSingleHierarchicalPredecessor()) &&
- SingleHPred->getExitBasicBlock() == PrevVPBB &&
+ SingleHPred->getExitingBasicBlock() == PrevVPBB &&
PrevVPBB->getSingleHierarchicalSuccessor() &&
(SingleHPred->getParent() == getEnclosingLoopRegion() &&
!IsLoopRegion(SingleHPred))) && /* B */
@@ -345,7 +345,7 @@ void VPBasicBlock::execute(VPTransformState *State) {
// is PrevVPBB and the latter has a single (hierarchical) successor which
// both are in the same non-replicator region; and
// C. when the current VPBB is an entry of a region replica - where PrevVPBB
- // is the exit of this region from a previous instance, or the
+ // is the exiting VPBB of this region from a previous instance, or the
// predecessor of this region.
NewBB = createEmptyBasicBlock(State->CFG);
@@ -986,7 +986,7 @@ void VPlan::execute(VPTransformState *State) {
}
}
- VPBasicBlock *LatchVPBB = getVectorLoopRegion()->getExitBasicBlock();
+ VPBasicBlock *LatchVPBB = getVectorLoopRegion()->getExitingBasicBlock();
BasicBlock *VectorLatchBB = State->CFG.VPBB2IRBB[LatchVPBB];
// Fix the latch value of canonical, reduction and first-order recurrences
@@ -1187,8 +1187,8 @@ void VPlanPrinter::dumpBlock(const VPBlockBase *Block) {
void VPlanPrinter::drawEdge(const VPBlockBase *From, const VPBlockBase *To,
bool Hidden, const Twine &Label) {
// Due to "dot" we print an edge between two regions as an edge between the
- // exit basic block and the entry basic of the respective regions.
- const VPBlockBase *Tail = From->getExitBasicBlock();
+ // exiting basic block and the entry basic of the respective regions.
+ const VPBlockBase *Tail = From->getExitingBasicBlock();
const VPBlockBase *Head = To->getEntryBasicBlock();
OS << Indent << getUID(Tail) << " -> " << getUID(Head);
OS << " [ label=\"" << Label << '\"';
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 7072deb6a7860..876092dc88461 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -493,11 +493,11 @@ class VPBlockBase {
const VPBasicBlock *getEntryBasicBlock() const;
VPBasicBlock *getEntryBasicBlock();
- /// \return the VPBasicBlock that is the exit of this VPBlockBase,
+ /// \return the VPBasicBlock that is the exiting this VPBlockBase,
/// recursively, if the latter is a VPRegionBlock. Otherwise, if this
/// VPBlockBase is a VPBasicBlock, it is returned.
- const VPBasicBlock *getExitBasicBlock() const;
- VPBasicBlock *getExitBasicBlock();
+ const VPBasicBlock *getExitingBasicBlock() const;
+ VPBasicBlock *getExitingBasicBlock();
const VPBlocksTy &getSuccessors() const { return Successors; }
VPBlocksTy &getSuccessors() { return Successors; }
@@ -2109,7 +2109,7 @@ class VPBasicBlock : public VPBlockBase {
};
/// VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks
-/// which form a Single-Entry-Single-Exit subgraph of the output IR CFG.
+/// which form a Single-Entry-Single-Exiting subgraph of the output IR CFG.
/// A VPRegionBlock may indicate that its contents are to be replicated several
/// times. This is designed to support predicated scalarization, in which a
/// scalar if-then code structure needs to be generated VF * UF times. Having
@@ -2120,25 +2120,26 @@ class VPRegionBlock : public VPBlockBase {
/// Hold the Single Entry of the SESE region modelled by the VPRegionBlock.
VPBlockBase *Entry;
- /// Hold the Single Exit of the SESE region modelled by the VPRegionBlock.
- VPBlockBase *Exit;
+ /// Hold the Single Exiting block of the SESE region modelled by the
+ /// VPRegionBlock.
+ VPBlockBase *Exiting;
/// An indicator whether this region is to generate multiple replicated
/// instances of output IR corresponding to its VPBlockBases.
bool IsReplicator;
public:
- VPRegionBlock(VPBlockBase *Entry, VPBlockBase *Exit,
+ VPRegionBlock(VPBlockBase *Entry, VPBlockBase *Exiting,
const std::string &Name = "", bool IsReplicator = false)
- : VPBlockBase(VPRegionBlockSC, Name), Entry(Entry), Exit(Exit),
+ : VPBlockBase(VPRegionBlockSC, Name), Entry(Entry), Exiting(Exiting),
IsReplicator(IsReplicator) {
assert(Entry->getPredecessors().empty() && "Entry block has predecessors.");
- assert(Exit->getSuccessors().empty() && "Exit block has successors.");
+ assert(Exiting->getSuccessors().empty() && "Exit block has successors.");
Entry->setParent(this);
- Exit->setParent(this);
+ Exiting->setParent(this);
}
VPRegionBlock(const std::string &Name = "", bool IsReplicator = false)
- : VPBlockBase(VPRegionBlockSC, Name), Entry(nullptr), Exit(nullptr),
+ : VPBlockBase(VPRegionBlockSC, Name), Entry(nullptr), Exiting(nullptr),
IsReplicator(IsReplicator) {}
~VPRegionBlock() override {
@@ -2172,22 +2173,22 @@ class VPRegionBlock : public VPBlockBase {
// DominatorTreeBase representing the Graph type.
VPBlockBase &front() const { return *Entry; }
- const VPBlockBase *getExit() const { return Exit; }
- VPBlockBase *getExit() { return Exit; }
+ const VPBlockBase *getExiting() const { return Exiting; }
+ VPBlockBase *getExiting() { return Exiting; }
- /// Set \p ExitBlock as the exit VPBlockBase of this VPRegionBlock. \p
- /// ExitBlock must have no successors.
- void setExit(VPBlockBase *ExitBlock) {
- assert(ExitBlock->getSuccessors().empty() &&
+ /// Set \p ExitingBlock as the exiting VPBlockBase of this VPRegionBlock. \p
+ /// ExitingBlock must have no successors.
+ void setExiting(VPBlockBase *ExitingBlock) {
+ assert(ExitingBlock->getSuccessors().empty() &&
"Exit block cannot have successors.");
- Exit = ExitBlock;
- ExitBlock->setParent(this);
+ Exiting = ExitingBlock;
+ ExitingBlock->setParent(this);
}
/// Returns the pre-header VPBasicBlock of the loop region.
VPBasicBlock *getPreheaderVPBB() {
assert(!isReplicator() && "should only get pre-header of loop regions");
- return getSinglePredecessor()->getExitBasicBlock();
+ return getSinglePredecessor()->getExitingBasicBlock();
}
/// An indicator whether this region is to generate multiple replicated
@@ -2321,11 +2322,11 @@ struct GraphTraits<Inverse<VPRegionBlock *>>
using nodes_iterator = df_iterator<NodeRef>;
static NodeRef getEntryNode(Inverse<GraphRef> N) {
- return N.Graph->getExit();
+ return N.Graph->getExiting();
}
static nodes_iterator nodes_begin(GraphRef N) {
- return nodes_iterator::begin(N->getExit());
+ return nodes_iterator::begin(N->getExiting());
}
static nodes_iterator nodes_end(GraphRef N) {
@@ -2871,8 +2872,8 @@ class VPBlockUtils {
R.moveBefore(*PredVPBB, PredVPBB->end());
VPBlockUtils::disconnectBlocks(PredVPBB, VPBB);
auto *ParentRegion = cast<VPRegionBlock>(Block->getParent());
- if (ParentRegion->getExit() == Block)
- ParentRegion->setExit(PredVPBB);
+ if (ParentRegion->getExiting() == Block)
+ ParentRegion->setExiting(PredVPBB);
SmallVector<VPBlockBase *> Successors(Block->successors());
for (auto *Succ : Successors) {
VPBlockUtils::disconnectBlocks(Block, Succ);
diff --git a/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp b/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp
index 57f98ea20d2ba..c6d5fbd6ad424 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp
@@ -329,7 +329,7 @@ VPRegionBlock *PlainCFGBuilder::buildPlainCFG() {
// 5. Final Top Region setup. Set outermost loop pre-header and single exit as
// Top Region entry and exit.
TopRegion->setEntry(PreheaderVPBB);
- TopRegion->setExit(LoopExitVPBB);
+ TopRegion->setExiting(LoopExitVPBB);
return TopRegion;
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp b/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp
index 40960906510c9..d6ba1e9820ba3 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp
@@ -130,9 +130,9 @@ VPlanPredicator::getEdgeTypeBetween(VPBlockBase *FromBlock,
// predecessor blocks.
void VPlanPredicator::createOrPropagatePredicates(VPBlockBase *CurrBlock,
VPRegionBlock *Region) {
- // Blocks that dominate region exit inherit the predicate from the region.
+ // Blocks that dominate region exiting inherit the predicate from the region.
// Return after setting the predicate.
- if (VPDomTree.dominates(CurrBlock, Region->getExit())) {
+ if (VPDomTree.dominates(CurrBlock, Region->getExiting())) {
VPValue *RegionBP = Region->getPredicate();
CurrBlock->setPredicate(RegionBP);
return;
diff --git a/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp b/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
index fe9eb77901cf4..bc6a9c973ba70 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
@@ -43,9 +43,9 @@ static bool hasDuplicates(const SmallVectorImpl<VPBlockBase *> &VPBlockVec) {
/// \p Region. Checks in this function are generic for VPBlockBases. They are
/// not specific for VPBasicBlocks or VPRegionBlocks.
static void verifyBlocksInRegion(const VPRegionBlock *Region) {
- for (const VPBlockBase *VPB :
- make_range(df_iterator<const VPBlockBase *>::begin(Region->getEntry()),
- df_iterator<const VPBlockBase *>::end(Region->getExit()))) {
+ for (const VPBlockBase *VPB : make_range(
+ df_iterator<const VPBlockBase *>::begin(Region->getEntry()),
+ df_iterator<const VPBlockBase *>::end(Region->getExiting()))) {
// Check block's parent.
assert(VPB->getParent() == Region && "VPBlockBase has wrong parent");
@@ -94,13 +94,14 @@ static void verifyBlocksInRegion(const VPRegionBlock *Region) {
/// VPBlockBases. Do not recurse inside nested VPRegionBlocks.
static void verifyRegion(const VPRegionBlock *Region) {
const VPBlockBase *Entry = Region->getEntry();
- const VPBlockBase *Exit = Region->getExit();
+ const VPBlockBase *Exiting = Region->getExiting();
- // Entry and Exit shouldn't have any predecessor/successor, respectively.
+ // Entry and Exiting shouldn't have any predecessor/successor, respectively.
assert(!Entry->getNumPredecessors() && "Region entry has predecessors.");
- assert(!Exit->getNumSuccessors() && "Region exit has successors.");
+ assert(!Exiting->getNumSuccessors() &&
+ "Region exiting block has successors.");
(void)Entry;
- (void)Exit;
+ (void)Exiting;
verifyBlocksInRegion(Region);
}
@@ -111,9 +112,9 @@ static void verifyRegionRec(const VPRegionBlock *Region) {
verifyRegion(Region);
// Recurse inside nested regions.
- for (const VPBlockBase *VPB :
- make_range(df_iterator<const VPBlockBase *>::begin(Region->getEntry()),
- df_iterator<const VPBlockBase *>::end(Region->getExit()))) {
+ for (const VPBlockBase *VPB : make_range(
+ df_iterator<const VPBlockBase *>::begin(Region->getEntry()),
+ df_iterator<const VPBlockBase *>::end(Region->getExiting()))) {
if (const auto *SubRegion = dyn_cast<VPRegionBlock>(VPB))
verifyRegionRec(SubRegion);
}
@@ -170,19 +171,19 @@ bool VPlanVerifier::verifyPlanIsValid(const VPlan &Plan) {
return false;
}
- const VPBasicBlock *Exit = dyn_cast<VPBasicBlock>(TopRegion->getExit());
- if (!Exit) {
- errs() << "VPlan exit block is not a VPBasicBlock\n";
+ const VPBasicBlock *Exiting = dyn_cast<VPBasicBlock>(TopRegion->getExiting());
+ if (!Exiting) {
+ errs() << "VPlan exiting block is not a VPBasicBlock\n";
return false;
}
- if (Exit->empty()) {
- errs() << "VPlan vector loop exit must end with BranchOnCount "
+ if (Exiting->empty()) {
+ errs() << "VPlan vector loop exiting block must end with BranchOnCount "
"VPInstruction but is empty\n";
return false;
}
- auto *LastInst = dyn_cast<VPInstruction>(std::prev(Exit->end()));
+ auto *LastInst = dyn_cast<VPInstruction>(std::prev(Exiting->end()));
if (!LastInst || LastInst->getOpcode() != VPInstruction::BranchOnCount) {
errs() << "VPlan vector loop exit must end with BranchOnCount "
"VPInstruction\n";
@@ -197,8 +198,8 @@ bool VPlanVerifier::verifyPlanIsValid(const VPlan &Plan) {
errs() << "region entry block has predecessors\n";
return false;
}
- if (Region->getExit()->getNumSuccessors() != 0) {
- errs() << "region exit block has successors\n";
+ if (Region->getExiting()->getNumSuccessors() != 0) {
+ errs() << "region exiting block has successors\n";
return false;
}
}
More information about the llvm-commits
mailing list