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 | 216d4d85fd8d5fdc4caafb7250fad75b015c8e6c (patch) | |
| tree | 02ed23595c85b7dda4b196a85872b68ba2a20931 /lib/Transforms/Scalar/InstructionCombining.cpp | |
| parent | 951fdb9764ea7abd1f409712636cf80a86140d90 (diff) | |
Make sure the instruction combiner doesn't lose track of instructions
when replacing them, missing the opportunity to do simplifications
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/InstructionCombining.cpp')
| -rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 9 | 
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 18de1269e9..03be9cd239 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<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);  | 
