Skip to content

Commit a2137b4

Browse files
committed
[VPlan] Add insertOnEdge (NFC).
1 parent 1a77b55 commit a2137b4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4173,6 +4173,21 @@ class VPBlockUtils {
41734173
return cast<BlockTy>(&Block);
41744174
});
41754175
}
4176+
4177+
static void insertOnEdge(VPBlockBase *From, VPBlockBase *To,
4178+
VPBlockBase *BlockPtr) {
4179+
unsigned SuccIdx =
4180+
std::distance(From->getSuccessors().begin(),
4181+
find_if(From->getSuccessors(),
4182+
[To](VPBlockBase *Succ) { return To == Succ; }));
4183+
unsigned PredIx =
4184+
std::distance(To->getPredecessors().begin(),
4185+
find_if(To->getPredecessors(), [From](VPBlockBase *Pred) {
4186+
return From == Pred;
4187+
}));
4188+
VPBlockUtils::connectBlocks(From, BlockPtr, -1, SuccIdx);
4189+
VPBlockUtils::connectBlocks(BlockPtr, To, PredIx, -1);
4190+
}
41764191
};
41774192

41784193
class VPInterleavedAccessInfo {

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,7 @@ 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::connectBlocks(CurrentBlock, Region, -1, 0);
364-
VPBlockUtils::connectBlocks(Region, SplitBlock, 0, -1);
363+
VPBlockUtils::insertOnEdge(CurrentBlock, SplitBlock, Region);
365364
}
366365
}
367366

0 commit comments

Comments
 (0)