[llvm] 725eb6b - [VPlan] Move createVPIRBasicBlock helper to VPIRBasicBlock (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 30 14:12:42 PDT 2024
Author: Florian Hahn
Date: 2024-09-30T22:12:09+01:00
New Revision: 725eb6bb12e7471149fb7362093deb6a710fe258
URL: https://github.com/llvm/llvm-project/commit/725eb6bb12e7471149fb7362093deb6a710fe258
DIFF: https://github.com/llvm/llvm-project/commit/725eb6bb12e7471149fb7362093deb6a710fe258.diff
LOG: [VPlan] Move createVPIRBasicBlock helper to VPIRBasicBlock (NFC).
Move the helper to VPIRBasicBlock to allow easier re-use outside
VPlan.cpp
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 6ddbfcf0ecfe58..4247d20cb0e530 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -863,10 +863,10 @@ VPlan::~VPlan() {
delete BackedgeTakenCount;
}
-static VPIRBasicBlock *createVPIRBasicBlockFor(BasicBlock *BB) {
- auto *VPIRBB = new VPIRBasicBlock(BB);
+VPIRBasicBlock *VPIRBasicBlock::fromBasicBlock(BasicBlock *IRBB) {
+ auto *VPIRBB = new VPIRBasicBlock(IRBB);
for (Instruction &I :
- make_range(BB->begin(), BB->getTerminator()->getIterator()))
+ make_range(IRBB->begin(), IRBB->getTerminator()->getIterator()))
VPIRBB->appendRecipe(new VPIRInstruction(I));
return VPIRBB;
}
@@ -875,7 +875,8 @@ VPlanPtr VPlan::createInitialVPlan(Type *InductionTy,
PredicatedScalarEvolution &PSE,
bool RequiresScalarEpilogueCheck,
bool TailFolded, Loop *TheLoop) {
- VPIRBasicBlock *Entry = createVPIRBasicBlockFor(TheLoop->getLoopPreheader());
+ VPIRBasicBlock *Entry =
+ VPIRBasicBlock::fromBasicBlock(TheLoop->getLoopPreheader());
VPBasicBlock *VecPreheader = new VPBasicBlock("vector.ph");
auto Plan = std::make_unique<VPlan>(Entry, VecPreheader);
@@ -915,7 +916,7 @@ VPlanPtr VPlan::createInitialVPlan(Type *InductionTy,
// we unconditionally branch to the scalar preheader. Do nothing.
// 3) Otherwise, construct a runtime check.
BasicBlock *IRExitBlock = TheLoop->getUniqueExitBlock();
- auto *VPExitBlock = createVPIRBasicBlockFor(IRExitBlock);
+ auto *VPExitBlock = VPIRBasicBlock::fromBasicBlock(IRExitBlock);
// The connection order corresponds to the operands of the conditional branch.
VPBlockUtils::insertBlockAfter(VPExitBlock, MiddleVPBB);
VPBlockUtils::connectBlocks(MiddleVPBB, ScalarPH);
@@ -991,7 +992,7 @@ void VPlan::prepareToExecute(Value *TripCountV, Value *VectorTripCountV,
/// have a single predecessor, which is rewired to the new VPIRBasicBlock. All
/// successors of VPBB, if any, are rewired to the new VPIRBasicBlock.
static void replaceVPBBWithIRVPBB(VPBasicBlock *VPBB, BasicBlock *IRBB) {
- VPIRBasicBlock *IRVPBB = createVPIRBasicBlockFor(IRBB);
+ VPIRBasicBlock *IRVPBB = VPIRBasicBlock::fromBasicBlock(IRBB);
for (auto &R : make_early_inc_range(*VPBB)) {
assert(!R.isPhi() && "Tried to move phi recipe to end of block");
R.moveBefore(*IRVPBB, IRVPBB->end());
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index c4567362eaffc7..8392aec8ad396e 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -3318,6 +3318,10 @@ class VPIRBasicBlock : public VPBasicBlock {
return V->getVPBlockID() == VPBlockBase::VPIRBasicBlockSC;
}
+ /// Create a VPIRBasicBlock from \p IRBB containing VPIRInstructions for all
+ /// instructions in \p IRBB, except its terminator which is managed in VPlan.
+ static VPIRBasicBlock *fromBasicBlock(BasicBlock *IRBB);
+
/// The method which generates the output IR instructions that correspond to
/// this VPBasicBlock, thereby "executing" the VPlan.
void execute(VPTransformState *State) override;
More information about the llvm-commits
mailing list