mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Make getNumBackEdges more efficient
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9063 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9989a4e2a1
commit
2ef1236e4a
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user