mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 17:29:19 +00:00
Make sure to reprocess instructions used by deleted instructions to avoid
missing opportunities for combination. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13309 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
216d4d85fd
commit
00d513182d
@ -2997,6 +2997,8 @@ bool InstCombiner::runOnFunction(Function &F) {
|
|||||||
BasicBlock *InstParent = I->getParent();
|
BasicBlock *InstParent = I->getParent();
|
||||||
InstParent->getInstList().insert(I, Result);
|
InstParent->getInstList().insert(I, Result);
|
||||||
|
|
||||||
|
// Make sure that we reprocess all operands now that we reduced their
|
||||||
|
// use counts.
|
||||||
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
|
||||||
if (Instruction *OpI = dyn_cast<Instruction>(I->getOperand(i)))
|
if (Instruction *OpI = dyn_cast<Instruction>(I->getOperand(i)))
|
||||||
WorkList.push_back(OpI);
|
WorkList.push_back(OpI);
|
||||||
@ -3009,14 +3011,19 @@ bool InstCombiner::runOnFunction(Function &F) {
|
|||||||
} else {
|
} else {
|
||||||
DEBUG(std::cerr << "IC: MOD = " << *I);
|
DEBUG(std::cerr << "IC: MOD = " << *I);
|
||||||
|
|
||||||
BasicBlock::iterator II = I;
|
|
||||||
|
|
||||||
// If the instruction was modified, it's possible that it is now dead.
|
// If the instruction was modified, it's possible that it is now dead.
|
||||||
// if so, remove it.
|
// if so, remove it.
|
||||||
if (dceInstruction(II)) {
|
if (isInstructionTriviallyDead(I)) {
|
||||||
// Instructions may end up in the worklist more than once. Erase them
|
// Make sure we process all operands now that we are reducing their
|
||||||
// all.
|
// use counts.
|
||||||
|
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
|
||||||
|
if (Instruction *OpI = dyn_cast<Instruction>(I->getOperand(i)))
|
||||||
|
WorkList.push_back(OpI);
|
||||||
|
|
||||||
|
// Instructions may end up in the worklist more than once. Erase all
|
||||||
|
// occurrances of this instruction.
|
||||||
removeFromWorkList(I);
|
removeFromWorkList(I);
|
||||||
|
I->getParent()->getInstList().erase(I);
|
||||||
Result = 0;
|
Result = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user