diff options
author | Chris Lattner <sabre@nondot.org> | 2004-05-01 23:27:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-05-01 23:27:23 +0000 |
commit | 63d75af9202a6eca0451098d34d4f7119d90f175 (patch) | |
tree | 70ab40a7c6312c9bcae5e0c231b06c6ee6fbe726 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | b643a9e675b4b1513083938898ea097d9290d3f0 (diff) | |
download | bcm5719-llvm-63d75af9202a6eca0451098d34d4f7119d90f175.tar.gz bcm5719-llvm-63d75af9202a6eca0451098d34d4f7119d90f175.zip |
Make sure to reprocess instructions used by deleted instructions to avoid
missing opportunities for combination.
llvm-svn: 13309
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 03be9cd2393..138dc962532 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2997,6 +2997,8 @@ bool InstCombiner::runOnFunction(Function &F) { 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 @@ bool InstCombiner::runOnFunction(Function &F) { } 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; } } |