Factor out the predicate code for loopsimplify form exit blocks into

a separate helper function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86159 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2009-11-05 19:21:41 +00:00
parent b5b10c25f7
commit f17e9511f1
2 changed files with 12 additions and 6 deletions

View File

@ -572,6 +572,10 @@ public:
/// normal form. /// normal form.
bool isLoopSimplifyForm() const; bool isLoopSimplifyForm() const;
/// hasDedicatedExits - Return true if no exit block for the loop
/// has a predecessor that is outside the loop.
bool hasDedicatedExits() const;
/// getUniqueExitBlocks - Return all unique successor blocks of this loop. /// getUniqueExitBlocks - Return all unique successor blocks of this loop.
/// These are the blocks _outside of the current loop_ which are branched to. /// These are the blocks _outside of the current loop_ which are branched to.
/// This assumes that loop is in canonical form. /// This assumes that loop is in canonical form.

View File

@ -286,12 +286,14 @@ bool Loop::isLCSSAForm() const {
/// the LoopSimplify form transforms loops to, which is sometimes called /// the LoopSimplify form transforms loops to, which is sometimes called
/// normal form. /// normal form.
bool Loop::isLoopSimplifyForm() const { bool Loop::isLoopSimplifyForm() const {
// Normal-form loops have a preheader. // Normal-form loops have a preheader, a single backedge, and all of their
if (!getLoopPreheader()) // exits have all their predecessors inside the loop.
return false; return getLoopPreheader() && getLoopLatch() && hasDedicatedExits();
// Normal-form loops have a single backedge. }
if (!getLoopLatch())
return false; /// hasDedicatedExits - Return true if no exit block for the loop
/// has a predecessor that is outside the loop.
bool Loop::hasDedicatedExits() const {
// Sort the blocks vector so that we can use binary search to do quick // Sort the blocks vector so that we can use binary search to do quick
// lookups. // lookups.
SmallPtrSet<BasicBlock *, 16> LoopBBs(block_begin(), block_end()); SmallPtrSet<BasicBlock *, 16> LoopBBs(block_begin(), block_end());