forked from OSchip/llvm-project
Do not insert one entry PHI nodes in split exit blocks!
llvm-svn: 10348
This commit is contained in:
parent
ddc088a9e4
commit
6c237bcdf2
|
@ -162,6 +162,15 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
|
||||||
// incoming edges in BB into new PHI nodes in NewBB.
|
// incoming edges in BB into new PHI nodes in NewBB.
|
||||||
//
|
//
|
||||||
if (!Preds.empty()) { // Is the loop not obviously dead?
|
if (!Preds.empty()) { // Is the loop not obviously dead?
|
||||||
|
if (Preds.size() == 1) {
|
||||||
|
// No need to insert one operand PHI nodes! Instead, just update the
|
||||||
|
// incoming block ID's.
|
||||||
|
for (BasicBlock::iterator I = BB->begin();
|
||||||
|
PHINode *PN = dyn_cast<PHINode>(I); ++I) {
|
||||||
|
unsigned i = PN->getBasicBlockIndex(Preds[0]);
|
||||||
|
PN->setIncomingBlock(i, NewBB);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (BasicBlock::iterator I = BB->begin();
|
for (BasicBlock::iterator I = BB->begin();
|
||||||
PHINode *PN = dyn_cast<PHINode>(I); ++I) {
|
PHINode *PN = dyn_cast<PHINode>(I); ++I) {
|
||||||
|
|
||||||
|
@ -175,9 +184,10 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an incoming value to the PHI node in the loop for the preheader
|
// Add an incoming value to the PHI node in the loop for the preheader
|
||||||
// edge
|
// edge.
|
||||||
PN->addIncoming(NewPHI, NewBB);
|
PN->addIncoming(NewPHI, NewBB);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now that the PHI nodes are updated, actually move the edges from
|
// Now that the PHI nodes are updated, actually move the edges from
|
||||||
// Preds to point to NewBB instead of BB.
|
// Preds to point to NewBB instead of BB.
|
||||||
|
|
Loading…
Reference in New Issue