mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-21 03:32:21 +00:00
Preserve LCSSA.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41246 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e79bad66e0
commit
60cbab4252
@ -835,7 +835,7 @@ bool LoopIndexSplit::splitLoop(SplitInfo &SD) {
|
|||||||
assert (!L->contains(ExitDest) && " Unable to find exit edge destination");
|
assert (!L->contains(ExitDest) && " Unable to find exit edge destination");
|
||||||
|
|
||||||
//[*] Split Exit Edge.
|
//[*] Split Exit Edge.
|
||||||
SplitEdge(ExitingBlock, FalseHeader, this);
|
BasicBlock *TL_ExitBlock = SplitEdge(ExitingBlock, FalseHeader, this);
|
||||||
|
|
||||||
//[*] Eliminate split condition's false branch from True loop.
|
//[*] Eliminate split condition's false branch from True loop.
|
||||||
BranchInst *BR = cast<BranchInst>(SplitBlock->getTerminator());
|
BranchInst *BR = cast<BranchInst>(SplitBlock->getTerminator());
|
||||||
@ -853,6 +853,20 @@ bool LoopIndexSplit::splitLoop(SplitInfo &SD) {
|
|||||||
FBR->setUnconditionalDest(FBR->getSuccessor(1));
|
FBR->setUnconditionalDest(FBR->getSuccessor(1));
|
||||||
removeBlocks(TBB, FalseLoop, cast<BasicBlock>(FBR->getSuccessor(0)));
|
removeBlocks(TBB, FalseLoop, cast<BasicBlock>(FBR->getSuccessor(0)));
|
||||||
|
|
||||||
|
//[*] Preserve LCSSA
|
||||||
|
for(BasicBlock::iterator BI = FalseHeader->begin(), BE = FalseHeader->end();
|
||||||
|
BI != BE; ++BI) {
|
||||||
|
if (PHINode *PN = dyn_cast<PHINode>(BI)) {
|
||||||
|
Value *V1 = PN->getIncomingValueForBlock(TL_ExitBlock);
|
||||||
|
PHINode *newPHI = new PHINode(PN->getType(), PN->getName());
|
||||||
|
newPHI->addIncoming(V1, ExitingBlock);
|
||||||
|
TL_ExitBlock->getInstList().push_front(newPHI);
|
||||||
|
PN->removeIncomingValue(TL_ExitBlock);
|
||||||
|
PN->addIncoming(newPHI, TL_ExitBlock);
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user