mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-19 04:29:21 +00:00
Fix IndVarsSimplify/2006-06-16-Indvar-LCSSA-Crash.ll, a case where a
"LCSSA" phi node causes indvars to break dominance properties. This fixes causes indvars to avoid inserting aggressive code in this case, instead indvars should be fixed to be more aggressive in the face of lcssa phi's. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28850 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
98c3e1cc92
commit
eb83f4e6cd
@ -321,11 +321,26 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L) {
|
||||
HasConstantItCount) {
|
||||
// Find out if this predictably varying value is actually used
|
||||
// outside of the loop. "extra" as opposed to "intra".
|
||||
std::vector<User*> ExtraLoopUsers;
|
||||
std::vector<Instruction*> ExtraLoopUsers;
|
||||
for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
|
||||
UI != E; ++UI)
|
||||
if (!L->contains(cast<Instruction>(*UI)->getParent()))
|
||||
ExtraLoopUsers.push_back(*UI);
|
||||
UI != E; ++UI) {
|
||||
Instruction *User = cast<Instruction>(*UI);
|
||||
if (!L->contains(User->getParent())) {
|
||||
// If this is a PHI node in the exit block and we're inserting,
|
||||
// into the exit block, it must have a single entry. In this
|
||||
// case, we can't insert the code after the PHI and have the PHI
|
||||
// still use it. Instead, don't insert the the PHI.
|
||||
if (PHINode *PN = dyn_cast<PHINode>(User)) {
|
||||
// FIXME: This is a case where LCSSA pessimizes code, this
|
||||
// should be fixed better.
|
||||
if (PN->getNumOperands() == 2 &&
|
||||
PN->getParent() == BlockToInsertInto)
|
||||
continue;
|
||||
}
|
||||
ExtraLoopUsers.push_back(User);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ExtraLoopUsers.empty()) {
|
||||
// Okay, this instruction has a user outside of the current loop
|
||||
// and varies predictably in this loop. Evaluate the value it
|
||||
|
Loading…
Reference in New Issue
Block a user