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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112594 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2010-08-31 07:55:56 +00:00
parent da2ae63206
commit 7c37f6d2d9

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;
}