mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-18 12:29:21 +00:00
Fix Transforms/LoopUnswitch/2006-06-13-SingleEntryPHI.ll, a loop unswitch
bug exposed by the recent lcssa work. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28779 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2c54676d70
commit
f7a1212850
@ -401,7 +401,7 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val,Loop *L){
|
|||||||
<< Cost << "\n");
|
<< Cost << "\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is a trivial condition to unswitch (which results in no code
|
// If this is a trivial condition to unswitch (which results in no code
|
||||||
// duplication), do it now.
|
// duplication), do it now.
|
||||||
Constant *CondVal;
|
Constant *CondVal;
|
||||||
@ -456,6 +456,18 @@ BasicBlock *LoopUnswitch::SplitEdge(BasicBlock *BB, BasicBlock *Succ) {
|
|||||||
// If the successor only has a single pred, split the top of the successor
|
// If the successor only has a single pred, split the top of the successor
|
||||||
// block.
|
// block.
|
||||||
assert(SP == BB && "CFG broken");
|
assert(SP == BB && "CFG broken");
|
||||||
|
|
||||||
|
// If this block has a single predecessor, remove any phi nodes. Unswitch
|
||||||
|
// expect that, after split the edges from inside the loop to the exit
|
||||||
|
// block, that there will be no phi nodes in the new exit block. Single
|
||||||
|
// entry phi nodes break this assumption.
|
||||||
|
BasicBlock::iterator I = Succ->begin();
|
||||||
|
while (PHINode *PN = dyn_cast<PHINode>(I)) {
|
||||||
|
PN->replaceAllUsesWith(PN->getIncomingValue(0));
|
||||||
|
PN->eraseFromParent();
|
||||||
|
I = Succ->begin();
|
||||||
|
}
|
||||||
|
|
||||||
return SplitBlock(Succ, Succ->begin());
|
return SplitBlock(Succ, Succ->begin());
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, if BB has a single successor, split it at the bottom of the
|
// Otherwise, if BB has a single successor, split it at the bottom of the
|
||||||
|
Loading…
Reference in New Issue
Block a user