diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 18de1269e9d..03be9cd2393 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/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);