[llvm-commits] [llvm] r96079 - /llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp
Chris Lattner
sabre at nondot.org
Fri Feb 12 20:15:27 PST 2010
Author: lattner
Date: Fri Feb 12 22:15:26 2010
New Revision: 96079
URL: http://llvm.org/viewvc/llvm-project?rev=96079&view=rev
Log:
iterate over preds using PHI information when available instead of
using pred_begin/end. It is much faster.
Modified:
llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp
Modified: llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp?rev=96079&r1=96078&r2=96079&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp Fri Feb 12 22:15:26 2010
@@ -229,9 +229,18 @@
// 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 @@
}
// 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;
}
More information about the llvm-commits
mailing list