From: Owen Anderson Date: Tue, 31 Aug 2010 18:55:52 +0000 (+0000) Subject: Only try to clean up the current block if we changed that block already. X-Git-Tag: llvmorg-2.8.0-rc0~380 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=048efbe225be6b313e09ba30648e195d53c5ce0c;p=platform%2Fupstream%2Fllvm.git Only try to clean up the current block if we changed that block already. llvm-svn: 112625 --- diff --git a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp index a62eb20a88e4..c673b0b33268 100644 --- a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp +++ b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp @@ -100,19 +100,25 @@ bool CorrelatedValuePropagation::processPHI(PHINode *P) { bool CorrelatedValuePropagation::runOnFunction(Function &F) { LVI = &getAnalysis(); - bool Changed = false; + bool FnChanged = false; for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) { + bool BBChanged = false; for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ) { Instruction *II = BI++; if (SelectInst *SI = dyn_cast(II)) - Changed |= processSelect(SI); + BBChanged |= processSelect(SI); else if (PHINode *P = dyn_cast(II)) - Changed |= processPHI(P); + BBChanged |= processPHI(P); } - SimplifyInstructionsInBlock(FI); + // Propagating correlated values might leave cruft around. + // Try to clean it up before we continue. + if (BBChanged) + SimplifyInstructionsInBlock(FI); + + FnChanged |= BBChanged; } - return Changed; + return FnChanged; }