diff options
author | Chris Lattner <sabre@nondot.org> | 2004-05-01 23:19:52 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-05-01 23:19:52 +0000 |
commit | b643a9e675b4b1513083938898ea097d9290d3f0 (patch) | |
tree | 9d1c53229ca59b07771ec867c2a9851b0e28f864 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | 4cbd160b45a8066bb07310608f310e068a39a688 (diff) | |
download | bcm5719-llvm-b643a9e675b4b1513083938898ea097d9290d3f0.tar.gz bcm5719-llvm-b643a9e675b4b1513083938898ea097d9290d3f0.zip |
Make sure the instruction combiner doesn't lose track of instructions
when replacing them, missing the opportunity to do simplifications
llvm-svn: 13308
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 18de1269e9d..03be9cd2393 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2934,9 +2934,8 @@ bool InstCombiner::runOnFunction(Function &F) { bool Changed = false; TD = &getAnalysis<TargetData>(); - for (inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i) { - WorkList.push_back(&*i); - } + for (inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i) + WorkList.push_back(&*i); while (!WorkList.empty()) { @@ -2998,6 +2997,10 @@ bool InstCombiner::runOnFunction(Function &F) { BasicBlock *InstParent = I->getParent(); InstParent->getInstList().insert(I, Result); + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) + if (Instruction *OpI = dyn_cast<Instruction>(I->getOperand(i))) + WorkList.push_back(OpI); + // Everything uses the new instruction now... I->replaceAllUsesWith(Result); |