forked from OSchip/llvm-project
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:
parent
b70dc8777e
commit
ce401be792
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue