Skip to content

Commit 1a77b55

Browse files
committed
[VPlan] Add PredIdx and SuccIdx arguments to connectBlocks (NFC).
1 parent 7ac62f3 commit 1a77b55

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4117,13 +4117,21 @@ class VPBlockUtils {
41174117
/// the successors of \p From and \p From to the predecessors of \p To. Both
41184118
/// VPBlockBases must have the same parent, which can be null. Both
41194119
/// VPBlockBases can be already connected to other VPBlockBases.
4120-
static void connectBlocks(VPBlockBase *From, VPBlockBase *To) {
4120+
static void connectBlocks(VPBlockBase *From, VPBlockBase *To,
4121+
unsigned PredIdx = -1u, unsigned SuccIdx = -1u) {
41214122
assert((From->getParent() == To->getParent()) &&
41224123
"Can't connect two block with different parents");
4123-
assert(From->getNumSuccessors() < 2 &&
4124+
assert((SuccIdx != -1u || From->getNumSuccessors() < 2) &&
41244125
"Blocks can't have more than two successors.");
4125-
From->appendSuccessor(To);
4126-
To->appendPredecessor(From);
4126+
if (SuccIdx == -1u)
4127+
From->appendSuccessor(To);
4128+
else
4129+
From->getSuccessors()[SuccIdx] = To;
4130+
4131+
if (PredIdx == -1u)
4132+
To->appendPredecessor(From);
4133+
else
4134+
To->getPredecessors()[PredIdx] = From;
41274135
}
41284136

41294137
/// Disconnect VPBlockBases \p From and \p To bi-directionally. Remove \p To

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,8 @@ static void addReplicateRegions(VPlan &Plan) {
360360
// Record predicated instructions for above packing optimizations.
361361
VPBlockBase *Region = createReplicateRegion(RepR, Plan);
362362
Region->setParent(CurrentBlock->getParent());
363-
VPBlockUtils::disconnectBlocks(CurrentBlock, SplitBlock);
364-
VPBlockUtils::connectBlocks(CurrentBlock, Region);
365-
VPBlockUtils::connectBlocks(Region, SplitBlock);
363+
VPBlockUtils::connectBlocks(CurrentBlock, Region, -1, 0);
364+
VPBlockUtils::connectBlocks(Region, SplitBlock, 0, -1);
366365
}
367366
}
368367

0 commit comments

Comments
 (0)