mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-27 04:18:42 +00:00
Do not insert one entry PHI nodes in split exit blocks!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10348 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
1 parent
73d8d55e0e
commit
010ba10032
1 file changed
+11
-1
@@ -162,6 +162,15 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
|
||||
// incoming edges in BB into new PHI nodes in NewBB.
|
||||
//
|
||||
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();
|
||||
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
|
||||
// edge
|
||||
// edge.
|
||||
PN->addIncoming(NewPHI, NewBB);
|
||||
}
|
||||
}
|
||||
|
||||
// Now that the PHI nodes are updated, actually move the edges from
|
||||
// Preds to point to NewBB instead of BB.
|
||||
|
||||
Reference in new issue
Block a user