1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

Make getNumBackEdges more efficient

llvm-svn: 9063
This commit is contained in:
Chris Lattner 2003-10-12 22:14:27 +00:00
parent 6a014a4eb7
commit be9a1813c6

View File

@ -33,17 +33,16 @@ bool Loop::isLoopExit(const BasicBlock *BB) const {
return false; return false;
} }
/// getNumBackEdges - Calculate the number of back edges to the loop header.
///
unsigned Loop::getNumBackEdges() const { unsigned Loop::getNumBackEdges() const {
unsigned NumBackEdges = 0; unsigned NumBackEdges = 0;
BasicBlock *H = getHeader(); BasicBlock *H = getHeader();
for (std::vector<BasicBlock*>::const_iterator I = Blocks.begin(), for (pred_iterator I = pred_begin(H), E = pred_end(H); I != E; ++I)
E = Blocks.end(); I != E; ++I) if (contains(*I))
for (succ_iterator SI = succ_begin(*I), SE = succ_end(*I); ++NumBackEdges;
SI != SE; ++SI)
if (*SI == H)
++NumBackEdges;
return NumBackEdges; return NumBackEdges;
} }