From b643a9e675b4b1513083938898ea097d9290d3f0 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 1 May 2004 23:19:52 +0000 Subject: Make sure the instruction combiner doesn't lose track of instructions when replacing them, missing the opportunity to do simplifications llvm-svn: 13308 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp') 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(); - 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(I->getOperand(i))) + WorkList.push_back(OpI); + // Everything uses the new instruction now... I->replaceAllUsesWith(Result); -- cgit v1.2.3