Skip to content
Snippets Groups Projects
Commit f98db5e6 authored by Devang Patel's avatar Devang Patel
Browse files

Preserve LCSSA.

llvm-svn: 41246
parent 77621351
No related branches found
No related tags found
No related merge requests found
......@@ -835,7 +835,7 @@ bool LoopIndexSplit::splitLoop(SplitInfo &SD) {
assert (!L->contains(ExitDest) && " Unable to find exit edge destination");
//[*] Split Exit Edge.
SplitEdge(ExitingBlock, FalseHeader, this);
BasicBlock *TL_ExitBlock = SplitEdge(ExitingBlock, FalseHeader, this);
//[*] Eliminate split condition's false branch from True loop.
BranchInst *BR = cast<BranchInst>(SplitBlock->getTerminator());
......@@ -853,6 +853,20 @@ bool LoopIndexSplit::splitLoop(SplitInfo &SD) {
FBR->setUnconditionalDest(FBR->getSuccessor(1));
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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment