diff options
author | Gabor Greif <ggreif@gmail.com> | 2010-07-12 10:59:23 +0000 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2010-07-12 10:59:23 +0000 |
commit | 8629f12bb828b7a5fb65356acd6239092bc288d5 (patch) | |
tree | c00aa10d3f437eeb563369a3826397a6ac27e872 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | d993402df30d8ca7cdefd2c5cd8ca4d99854b489 (diff) | |
download | bcm5719-llvm-8629f12bb828b7a5fb65356acd6239092bc288d5.tar.gz bcm5719-llvm-8629f12bb828b7a5fb65356acd6239092bc288d5.zip |
cache dereferenced iterators
llvm-svn: 108133
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 5a431660b27..fd3ed3ea2d6 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1513,17 +1513,19 @@ static bool SimplifyCondBranchToCondBranch(BranchInst *PBI, BranchInst *BI) { // Okay, we're going to insert the PHI node. Since PBI is not the only // predecessor, compute the PHI'd conditional value for all of the preds. // Any predecessor where the condition is not computable we keep symbolic. - for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) - if ((PBI = dyn_cast<BranchInst>((*PI)->getTerminator())) && + for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { + BasicBlock *P = *PI; + if ((PBI = dyn_cast<BranchInst>(P->getTerminator())) && PBI != BI && PBI->isConditional() && PBI->getCondition() == BI->getCondition() && PBI->getSuccessor(0) != PBI->getSuccessor(1)) { bool CondIsTrue = PBI->getSuccessor(0) == BB; NewPN->addIncoming(ConstantInt::get(Type::getInt1Ty(BB->getContext()), - CondIsTrue), *PI); + CondIsTrue), P); } else { - NewPN->addIncoming(BI->getCondition(), *PI); + NewPN->addIncoming(BI->getCondition(), P); } + } BI->setCondition(NewPN); return true; |