mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Do not erase induction variable increment if it is used outside the loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51280 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -596,11 +596,27 @@ bool LoopIndexSplit::processOneIterationLoop(SplitInfo &SD) {
|
||||
if (isa<PHINode>(I) || I == LTerminator)
|
||||
continue;
|
||||
|
||||
if (I == IndVarIncrement)
|
||||
I->replaceAllUsesWith(ExitValue);
|
||||
else
|
||||
if (I == IndVarIncrement) {
|
||||
// Replace induction variable increment if it is not used outside
|
||||
// the loop.
|
||||
bool UsedOutsideLoop = false;
|
||||
for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
|
||||
UI != E; ++UI) {
|
||||
if (Instruction *Use = dyn_cast<Instruction>(UI))
|
||||
if (!L->contains(Use->getParent())) {
|
||||
UsedOutsideLoop = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!UsedOutsideLoop) {
|
||||
I->replaceAllUsesWith(ExitValue);
|
||||
I->eraseFromParent();
|
||||
}
|
||||
}
|
||||
else {
|
||||
I->replaceAllUsesWith(UndefValue::get(I->getType()));
|
||||
I->eraseFromParent();
|
||||
I->eraseFromParent();
|
||||
}
|
||||
}
|
||||
|
||||
LPM->deleteLoopFromQueue(L);
|
||||
|
Reference in New Issue
Block a user