[llvm-commits] [llvm] r41246 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
Devang Patel
dpatel at apple.com
Tue Aug 21 12:47:46 PDT 2007
Author: dpatel
Date: Tue Aug 21 14:47:46 2007
New Revision: 41246
URL: http://llvm.org/viewvc/llvm-project?rev=41246&view=rev
Log:
Preserve LCSSA.
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=41246&r1=41245&r2=41246&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Tue Aug 21 14:47:46 2007
@@ -835,7 +835,7 @@
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 @@
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;
}
More information about the llvm-commits
mailing list