diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-12 22:14:27 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-12 22:14:27 +0000 |
commit | 2ef1236e4abc91fdd0477e504a12b8dabfe4ab27 (patch) | |
tree | 1ba028fac4f95139e4929c39b50da945aa909377 /lib | |
parent | 9989a4e2a1490f597dc2bd6963a18abe69a71a0e (diff) | |
download | external_llvm-2ef1236e4abc91fdd0477e504a12b8dabfe4ab27.zip external_llvm-2ef1236e4abc91fdd0477e504a12b8dabfe4ab27.tar.gz external_llvm-2ef1236e4abc91fdd0477e504a12b8dabfe4ab27.tar.bz2 |
Make getNumBackEdges more efficient
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9063 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/LoopInfo.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index 8c42562..e92f10d 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; } |