forked from OSchip/llvm-project
[NFC][LoopUnrollAndJam] Use BasicBlock::replacePhiUsesWith instead of
static function updatePHIBlocks. Reviewed By: dmgreen Differential Revision: https://reviews.llvm.org/D85673
This commit is contained in:
parent
fa2b836ea3
commit
aa994d9867
|
@ -459,14 +459,6 @@ llvm::UnrollAndJamLoop(Loop *L, unsigned Count, unsigned TripCount,
|
|||
// finish up connecting the blocks and phi nodes. At this point LastValueMap
|
||||
// is the last unrolled iterations values.
|
||||
|
||||
// Update Phis in BB from OldBB to point to NewBB
|
||||
auto updatePHIBlocks = [](BasicBlock *BB, BasicBlock *OldBB,
|
||||
BasicBlock *NewBB) {
|
||||
for (PHINode &Phi : BB->phis()) {
|
||||
int I = Phi.getBasicBlockIndex(OldBB);
|
||||
Phi.setIncomingBlock(I, NewBB);
|
||||
}
|
||||
};
|
||||
// Update Phis in BB from OldBB to point to NewBB and use the latest value
|
||||
// from LastValueMap
|
||||
auto updatePHIBlocksAndValues = [](BasicBlock *BB, BasicBlock *OldBB,
|
||||
|
@ -525,10 +517,10 @@ llvm::UnrollAndJamLoop(Loop *L, unsigned Count, unsigned TripCount,
|
|||
cast<BranchInst>(SubLoopBlocksLast.back()->getTerminator());
|
||||
SubTerm->setSuccessor(!SubLoopContinueOnTrue, SubLoopBlocksFirst[0]);
|
||||
SubTerm->setSuccessor(SubLoopContinueOnTrue, AftBlocksFirst[0]);
|
||||
updatePHIBlocks(SubLoopBlocksFirst[0], ForeBlocksLast[0],
|
||||
ForeBlocksLast.back());
|
||||
updatePHIBlocks(SubLoopBlocksFirst[0], SubLoopBlocksLast[0],
|
||||
SubLoopBlocksLast.back());
|
||||
SubLoopBlocksFirst[0]->replacePhiUsesWith(ForeBlocksLast[0],
|
||||
ForeBlocksLast.back());
|
||||
SubLoopBlocksFirst[0]->replacePhiUsesWith(SubLoopBlocksLast[0],
|
||||
SubLoopBlocksLast.back());
|
||||
|
||||
for (unsigned It = 1; It != Count; It++) {
|
||||
// Replace the conditional branch of the previous iteration subloop with an
|
||||
|
@ -538,10 +530,10 @@ llvm::UnrollAndJamLoop(Loop *L, unsigned Count, unsigned TripCount,
|
|||
BranchInst::Create(SubLoopBlocksFirst[It], SubTerm);
|
||||
SubTerm->eraseFromParent();
|
||||
|
||||
updatePHIBlocks(SubLoopBlocksFirst[It], ForeBlocksLast[It],
|
||||
ForeBlocksLast.back());
|
||||
updatePHIBlocks(SubLoopBlocksFirst[It], SubLoopBlocksLast[It],
|
||||
SubLoopBlocksLast.back());
|
||||
SubLoopBlocksFirst[It]->replacePhiUsesWith(ForeBlocksLast[It],
|
||||
ForeBlocksLast.back());
|
||||
SubLoopBlocksFirst[It]->replacePhiUsesWith(SubLoopBlocksLast[It],
|
||||
SubLoopBlocksLast.back());
|
||||
movePHIs(SubLoopBlocksFirst[It], SubLoopBlocksFirst[0]);
|
||||
}
|
||||
|
||||
|
@ -555,8 +547,8 @@ llvm::UnrollAndJamLoop(Loop *L, unsigned Count, unsigned TripCount,
|
|||
assert(AftTerm->getSuccessor(ContinueOnTrue) == LoopExit &&
|
||||
"Expecting the ContinueOnTrue successor of AftTerm to be LoopExit");
|
||||
}
|
||||
updatePHIBlocks(AftBlocksFirst[0], SubLoopBlocksLast[0],
|
||||
SubLoopBlocksLast.back());
|
||||
AftBlocksFirst[0]->replacePhiUsesWith(SubLoopBlocksLast[0],
|
||||
SubLoopBlocksLast.back());
|
||||
|
||||
for (unsigned It = 1; It != Count; It++) {
|
||||
// Replace the conditional branch of the previous iteration subloop with an
|
||||
|
@ -566,8 +558,8 @@ llvm::UnrollAndJamLoop(Loop *L, unsigned Count, unsigned TripCount,
|
|||
BranchInst::Create(AftBlocksFirst[It], AftTerm);
|
||||
AftTerm->eraseFromParent();
|
||||
|
||||
updatePHIBlocks(AftBlocksFirst[It], SubLoopBlocksLast[It],
|
||||
SubLoopBlocksLast.back());
|
||||
AftBlocksFirst[It]->replacePhiUsesWith(SubLoopBlocksLast[It],
|
||||
SubLoopBlocksLast.back());
|
||||
movePHIs(AftBlocksFirst[It], AftBlocksFirst[0]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue