aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/LoopInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Analysis/LoopInfo.cpp')
-rw-r--r--lib/Analysis/LoopInfo.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index 8c42562370..e92f10d49c 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -33,17 +33,16 @@ bool Loop::isLoopExit(const BasicBlock *BB) const {
return false;
}
+/// getNumBackEdges - Calculate the number of back edges to the loop header.
+///
unsigned Loop::getNumBackEdges() const {
unsigned NumBackEdges = 0;
BasicBlock *H = getHeader();
- for (std::vector<BasicBlock*>::const_iterator I = Blocks.begin(),
- E = Blocks.end(); I != E; ++I)
- for (succ_iterator SI = succ_begin(*I), SE = succ_end(*I);
- SI != SE; ++SI)
- if (*SI == H)
- ++NumBackEdges;
-
+ for (pred_iterator I = pred_begin(H), E = pred_end(H); I != E; ++I)
+ if (contains(*I))
+ ++NumBackEdges;
+
return NumBackEdges;
}