A loop latch phi node may have uses inside loop, not just in loop header.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47093 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel
2008-02-13 22:23:07 +00:00
parent 7649127ec1
commit ea06906559
2 changed files with 79 additions and 4 deletions
+5 -4
View File
@@ -151,7 +151,7 @@ namespace {
/// Update ExitBB PHINodes' to reflect this change.
void updatePHINodes(BasicBlock *ExitBB, BasicBlock *Latch,
BasicBlock *Header,
PHINode *IV, Instruction *IVIncrement);
PHINode *IV, Instruction *IVIncrement, Loop *LP);
/// moveExitCondition - Move exit condition EC into split condition block CondBB.
void moveExitCondition(BasicBlock *CondBB, BasicBlock *ActiveBB,
@@ -1597,7 +1597,7 @@ void LoopIndexSplit::moveExitCondition(BasicBlock *CondBB, BasicBlock *ActiveBB,
new BranchInst(OrigDestBB, ExitingBB);
// Update PHINodes
updatePHINodes(ExitBB, ExitingBB, CondBB, IV, IVAdd);
updatePHINodes(ExitBB, ExitingBB, CondBB, IV, IVAdd, LP);
// Fix dominator info.
// ExitBB is now dominated by CondBB
@@ -1637,7 +1637,8 @@ void LoopIndexSplit::moveExitCondition(BasicBlock *CondBB, BasicBlock *ActiveBB,
/// Update ExitBB PHINodes' to reflect this change.
void LoopIndexSplit::updatePHINodes(BasicBlock *ExitBB, BasicBlock *Latch,
BasicBlock *Header,
PHINode *IV, Instruction *IVIncrement) {
PHINode *IV, Instruction *IVIncrement,
Loop *LP) {
for (BasicBlock::iterator BI = ExitBB->begin(), BE = ExitBB->end();
BI != BE; ++BI) {
@@ -1653,7 +1654,7 @@ void LoopIndexSplit::updatePHINodes(BasicBlock *ExitBB, BasicBlock *Latch,
for (Value::use_iterator UI = PHV->use_begin(), E = PHV->use_end();
UI != E; ++UI)
if (PHINode *U = dyn_cast<PHINode>(*UI))
if (U->getParent() == Header) {
if (LP->contains(U->getParent())) {
NewV = U;
break;
}