Skip to content

Commit 725eb6b

Browse files
committed
[VPlan] Move createVPIRBasicBlock helper to VPIRBasicBlock (NFC).
Move the helper to VPIRBasicBlock to allow easier re-use outside VPlan.cpp
1 parent 0547e57 commit 725eb6b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -863,10 +863,10 @@ VPlan::~VPlan() {
863863
delete BackedgeTakenCount;
864864
}
865865

866-
static VPIRBasicBlock *createVPIRBasicBlockFor(BasicBlock *BB) {
867-
auto *VPIRBB = new VPIRBasicBlock(BB);
866+
VPIRBasicBlock *VPIRBasicBlock::fromBasicBlock(BasicBlock *IRBB) {
867+
auto *VPIRBB = new VPIRBasicBlock(IRBB);
868868
for (Instruction &I :
869-
make_range(BB->begin(), BB->getTerminator()->getIterator()))
869+
make_range(IRBB->begin(), IRBB->getTerminator()->getIterator()))
870870
VPIRBB->appendRecipe(new VPIRInstruction(I));
871871
return VPIRBB;
872872
}
@@ -875,7 +875,8 @@ VPlanPtr VPlan::createInitialVPlan(Type *InductionTy,
875875
PredicatedScalarEvolution &PSE,
876876
bool RequiresScalarEpilogueCheck,
877877
bool TailFolded, Loop *TheLoop) {
878-
VPIRBasicBlock *Entry = createVPIRBasicBlockFor(TheLoop->getLoopPreheader());
878+
VPIRBasicBlock *Entry =
879+
VPIRBasicBlock::fromBasicBlock(TheLoop->getLoopPreheader());
879880
VPBasicBlock *VecPreheader = new VPBasicBlock("vector.ph");
880881
auto Plan = std::make_unique<VPlan>(Entry, VecPreheader);
881882

@@ -915,7 +916,7 @@ VPlanPtr VPlan::createInitialVPlan(Type *InductionTy,
915916
// we unconditionally branch to the scalar preheader. Do nothing.
916917
// 3) Otherwise, construct a runtime check.
917918
BasicBlock *IRExitBlock = TheLoop->getUniqueExitBlock();
918-
auto *VPExitBlock = createVPIRBasicBlockFor(IRExitBlock);
919+
auto *VPExitBlock = VPIRBasicBlock::fromBasicBlock(IRExitBlock);
919920
// The connection order corresponds to the operands of the conditional branch.
920921
VPBlockUtils::insertBlockAfter(VPExitBlock, MiddleVPBB);
921922
VPBlockUtils::connectBlocks(MiddleVPBB, ScalarPH);
@@ -991,7 +992,7 @@ void VPlan::prepareToExecute(Value *TripCountV, Value *VectorTripCountV,
991992
/// have a single predecessor, which is rewired to the new VPIRBasicBlock. All
992993
/// successors of VPBB, if any, are rewired to the new VPIRBasicBlock.
993994
static void replaceVPBBWithIRVPBB(VPBasicBlock *VPBB, BasicBlock *IRBB) {
994-
VPIRBasicBlock *IRVPBB = createVPIRBasicBlockFor(IRBB);
995+
VPIRBasicBlock *IRVPBB = VPIRBasicBlock::fromBasicBlock(IRBB);
995996
for (auto &R : make_early_inc_range(*VPBB)) {
996997
assert(!R.isPhi() && "Tried to move phi recipe to end of block");
997998
R.moveBefore(*IRVPBB, IRVPBB->end());

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3318,6 +3318,10 @@ class VPIRBasicBlock : public VPBasicBlock {
33183318
return V->getVPBlockID() == VPBlockBase::VPIRBasicBlockSC;
33193319
}
33203320

3321+
/// Create a VPIRBasicBlock from \p IRBB containing VPIRInstructions for all
3322+
/// instructions in \p IRBB, except its terminator which is managed in VPlan.
3323+
static VPIRBasicBlock *fromBasicBlock(BasicBlock *IRBB);
3324+
33213325
/// The method which generates the output IR instructions that correspond to
33223326
/// this VPBasicBlock, thereby "executing" the VPlan.
33233327
void execute(VPTransformState *State) override;

0 commit comments

Comments
 (0)