[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat May 1 18:27:01 PDT 2004
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.196 -> 1.197
---
Log message:
Make sure to reprocess instructions used by deleted instructions to avoid
missing opportunities for combination.
---
Diffs of the changes: (+12 -5)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.196 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.197
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.196 Sat May 1 18:19:52 2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sat May 1 18:27:23 2004
@@ -2997,6 +2997,8 @@
BasicBlock *InstParent = I->getParent();
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)
if (Instruction *OpI = dyn_cast<Instruction>(I->getOperand(i)))
WorkList.push_back(OpI);
@@ -3009,14 +3011,19 @@
} else {
DEBUG(std::cerr << "IC: MOD = " << *I);
- BasicBlock::iterator II = I;
-
// If the instruction was modified, it's possible that it is now dead.
// if so, remove it.
- if (dceInstruction(II)) {
- // Instructions may end up in the worklist more than once. Erase them
- // all.
+ if (isInstructionTriviallyDead(I)) {
+ // Make sure we process all operands now that we are reducing their
+ // 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);
+ I->getParent()->getInstList().erase(I);
Result = 0;
}
}
More information about the llvm-commits
mailing list