Don't perform an extra traversal of the function just to do cleanup. We can safely simplify instructions after each block has been processed without worrying about iterator invalidation.

llvm-svn: 112594
This commit is contained in:
Owen Anderson 2010-08-31 07:55:56 +00:00
parent b70dc8777e
commit ce401be792
1 changed files with 4 additions and 5 deletions

View File

@ -102,7 +102,7 @@ bool CorrelatedValuePropagation::runOnFunction(Function &F) {
bool Changed = false;
for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI)
for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) {
for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ) {
Instruction *II = BI++;
if (SelectInst *SI = dyn_cast<SelectInst>(II))
@ -110,10 +110,9 @@ bool CorrelatedValuePropagation::runOnFunction(Function &F) {
else if (PHINode *P = dyn_cast<PHINode>(II))
Changed |= processPHI(P);
}
if (Changed)
for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI)
SimplifyInstructionsInBlock(FI);
SimplifyInstructionsInBlock(FI);
}
return Changed;
}