diff options
author | Chris Lattner <sabre@nondot.org> | 2010-02-13 04:15:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-02-13 04:15:26 +0000 |
commit | 2f36ea8b74f2d81b0d14cbaf11f2158c97355dfd (patch) | |
tree | 3794e8f1198296ef2fcea178f4e1e5c5e97d3c05 | |
parent | 3f65b5e733e01faeb9db825515ca00e544fb988a (diff) | |
download | external_llvm-2f36ea8b74f2d81b0d14cbaf11f2158c97355dfd.zip external_llvm-2f36ea8b74f2d81b0d14cbaf11f2158c97355dfd.tar.gz external_llvm-2f36ea8b74f2d81b0d14cbaf11f2158c97355dfd.tar.bz2 |
iterate over preds using PHI information when available instead of
using pred_begin/end. It is much faster.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96079 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Utils/BreakCriticalEdges.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp index 19c7206..eb3e3b2 100644 --- a/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -229,9 +229,18 @@ BasicBlock *llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, // loop header) then NewBB dominates DestBB. SmallVector<BasicBlock*, 8> OtherPreds; - for (pred_iterator I = pred_begin(DestBB), E = pred_end(DestBB); I != E; ++I) - if (*I != NewBB) - OtherPreds.push_back(*I); + // If there is a PHI in the block, loop over predecessors with it, which is + // faster than iterating pred_begin/end. + if (PHINode *PN = dyn_cast<PHINode>(DestBB->begin())) { + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) + if (PN->getIncomingBlock(i) != NewBB) + OtherPreds.push_back(PN->getIncomingBlock(i)); + } else { + for (pred_iterator I = pred_begin(DestBB), E = pred_end(DestBB); + I != E; ++I) + if (*I != NewBB) + OtherPreds.push_back(*I); + } bool NewBBDominatesDestBB = true; @@ -382,9 +391,8 @@ BasicBlock *llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, } // Update ProfileInfo if it is around. - if (ProfileInfo *PI = P->getAnalysisIfAvailable<ProfileInfo>()) { - PI->splitEdge(TIBB,DestBB,NewBB,MergeIdenticalEdges); - } + if (ProfileInfo *PI = P->getAnalysisIfAvailable<ProfileInfo>()) + PI->splitEdge(TIBB, DestBB, NewBB, MergeIdenticalEdges); return NewBB; } |