Make sure the instruction combiner doesn't lose track of instructions

when replacing them, missing the opportunity to do simplifications

llvm-svn: 13308
This commit is contained in:
Chris Lattner 2004-05-01 23:19:52 +00:00
parent 4cbd160b45
commit b643a9e675
1 changed files with 6 additions and 3 deletions

View File

@ -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);