|
@@ -1279,12 +1279,6 @@ static void moveBBContents(BasicBlock *FromBB, Instruction *InsertBefore) {
|
|
|
FromBB->getTerminator()->getIterator());
|
|
|
}
|
|
|
|
|
|
-static void updateIncomingBlock(BasicBlock *CurrBlock, BasicBlock *OldPred,
|
|
|
- BasicBlock *NewPred) {
|
|
|
- for (PHINode &PHI : CurrBlock->phis())
|
|
|
- PHI.replaceIncomingBlockWith(OldPred, NewPred);
|
|
|
-}
|
|
|
-
|
|
|
/// Update BI to jump to NewBB instead of OldBB. Records updates to
|
|
|
/// the dominator tree in DTUpdates, if DT should be preserved.
|
|
|
static void updateSuccessor(BranchInst *BI, BasicBlock *OldBB,
|
|
@@ -1349,7 +1343,7 @@ static void moveLCSSAPhis(BasicBlock *InnerExit, BasicBlock *InnerLatch,
|
|
|
// Now adjust the incoming blocks for the LCSSA PHIs.
|
|
|
// For PHIs moved from Inner's exit block, we need to replace Inner's latch
|
|
|
// with the new latch.
|
|
|
- updateIncomingBlock(InnerLatch, InnerLatch, OuterLatch);
|
|
|
+ InnerLatch->replacePhiUsesWith(InnerLatch, OuterLatch);
|
|
|
}
|
|
|
|
|
|
bool LoopInterchangeTransform::adjustLoopBranches() {
|
|
@@ -1416,8 +1410,8 @@ bool LoopInterchangeTransform::adjustLoopBranches() {
|
|
|
InnerLoopHeaderSuccessor, DTUpdates);
|
|
|
|
|
|
// Adjust reduction PHI's now that the incoming block has changed.
|
|
|
- updateIncomingBlock(InnerLoopHeaderSuccessor, InnerLoopHeader,
|
|
|
- OuterLoopHeader);
|
|
|
+ InnerLoopHeaderSuccessor->replacePhiUsesWith(InnerLoopHeader,
|
|
|
+ OuterLoopHeader);
|
|
|
|
|
|
updateSuccessor(InnerLoopHeaderBI, InnerLoopHeaderSuccessor,
|
|
|
OuterLoopPreHeader, DTUpdates);
|
|
@@ -1449,7 +1443,7 @@ bool LoopInterchangeTransform::adjustLoopBranches() {
|
|
|
moveLCSSAPhis(InnerLoopLatchSuccessor, InnerLoopLatch, OuterLoopLatch);
|
|
|
// For PHIs in the exit block of the outer loop, outer's latch has been
|
|
|
// replaced by Inners'.
|
|
|
- updateIncomingBlock(OuterLoopLatchSuccessor, OuterLoopLatch, InnerLoopLatch);
|
|
|
+ OuterLoopLatchSuccessor->replacePhiUsesWith(OuterLoopLatch, InnerLoopLatch);
|
|
|
|
|
|
// Now update the reduction PHIs in the inner and outer loop headers.
|
|
|
SmallVector<PHINode *, 4> InnerLoopPHIs, OuterLoopPHIs;
|
|
@@ -1476,10 +1470,10 @@ bool LoopInterchangeTransform::adjustLoopBranches() {
|
|
|
}
|
|
|
|
|
|
// Update the incoming blocks for moved PHI nodes.
|
|
|
- updateIncomingBlock(OuterLoopHeader, InnerLoopPreHeader, OuterLoopPreHeader);
|
|
|
- updateIncomingBlock(OuterLoopHeader, InnerLoopLatch, OuterLoopLatch);
|
|
|
- updateIncomingBlock(InnerLoopHeader, OuterLoopPreHeader, InnerLoopPreHeader);
|
|
|
- updateIncomingBlock(InnerLoopHeader, OuterLoopLatch, InnerLoopLatch);
|
|
|
+ OuterLoopHeader->replacePhiUsesWith(InnerLoopPreHeader, OuterLoopPreHeader);
|
|
|
+ OuterLoopHeader->replacePhiUsesWith(InnerLoopLatch, OuterLoopLatch);
|
|
|
+ InnerLoopHeader->replacePhiUsesWith(OuterLoopPreHeader, InnerLoopPreHeader);
|
|
|
+ InnerLoopHeader->replacePhiUsesWith(OuterLoopLatch, InnerLoopLatch);
|
|
|
|
|
|
return true;
|
|
|
}
|