Skip to content

Commit 507ff08

Browse files
committed
[VPlan] Move runtime check blocks to correct position during exec (NFC).
Move adjusting the position of completely disconnected IR blocks to VPIRBasicBlock::execute.
1 parent 2d216a9 commit 507ff08

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7268,8 +7268,6 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
72687268

72697269
// 1. Set up the skeleton for vectorization, including vector pre-header and
72707270
// middle block. The vector loop is created during VPlan execution.
7271-
BasicBlock *EntryBB =
7272-
cast<VPIRBasicBlock>(BestVPlan.getEntry())->getIRBasicBlock();
72737271
State.CFG.PrevBB = ILV.createVectorizedLoopSkeleton();
72747272
replaceVPBBWithIRVPBB(BestVPlan.getScalarPreheader(),
72757273
State.CFG.PrevBB->getSingleSuccessor());
@@ -7303,13 +7301,6 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
73037301
//
73047302
//===------------------------------------------------===//
73057303

7306-
// Move check blocks to their final position.
7307-
// TODO: Move as part of VPIRBB execute and update impacted tests.
7308-
if (BasicBlock *MemCheckBlock = ILV.RTChecks.getMemRuntimeChecks().second)
7309-
MemCheckBlock->moveAfter(EntryBB);
7310-
if (BasicBlock *SCEVCheckBlock = ILV.RTChecks.getSCEVChecks().second)
7311-
SCEVCheckBlock->moveAfter(EntryBB);
7312-
73137304
BestVPlan.execute(&State);
73147305

73157306
// 2.5 When vectorizing the epilogue, fix reduction resume values from the

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,9 @@ void VPBasicBlock::connectToPredecessors(VPTransformState &State) {
493493
void VPIRBasicBlock::execute(VPTransformState *State) {
494494
assert(getHierarchicalSuccessors().size() <= 2 &&
495495
"VPIRBasicBlock can have at most two successors at the moment!");
496+
// Move completely disconnected blocks to their final position.
497+
if (IRBB->hasNPredecessors(0) && succ_begin(IRBB) == succ_end(IRBB))
498+
IRBB->moveAfter(State->CFG.PrevBB);
496499
State->Builder.SetInsertPoint(IRBB->getTerminator());
497500
State->CFG.PrevBB = IRBB;
498501
State->CFG.VPBB2IRBB[this] = IRBB;

0 commit comments

Comments
 (0)