mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-14 15:19:33 +00:00
Add an isLoopSimplifyForm() predicate, following the example of
isLCSSAForm(), to test whether a loop is in the form guaranteed by the LoopSimplify pass. llvm-svn: 76077
This commit is contained in:
parent
a5941105f6
commit
69d03cf2ee
@ -551,6 +551,11 @@ public:
|
||||
/// isLCSSAForm - Return true if the Loop is in LCSSA form
|
||||
bool isLCSSAForm() const;
|
||||
|
||||
/// isLoopSimplifyForm - Return true if the Loop is in the form that
|
||||
/// the LoopSimplify form transforms loops to, which is sometimes called
|
||||
/// normal form.
|
||||
bool isLoopSimplifyForm() const;
|
||||
|
||||
private:
|
||||
friend class LoopInfoBase<BasicBlock, Loop>;
|
||||
explicit Loop(BasicBlock *BB) : LoopBase<BasicBlock, Loop>(BB) {}
|
||||
|
@ -276,6 +276,30 @@ bool Loop::isLCSSAForm() const {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// isLoopSimplifyForm - Return true if the Loop is in the form that
|
||||
/// the LoopSimplify form transforms loops to, which is sometimes called
|
||||
/// normal form.
|
||||
bool Loop::isLoopSimplifyForm() const {
|
||||
// Normal-form loops have a preheader.
|
||||
if (!getLoopPreheader())
|
||||
return false;
|
||||
// Normal-form loops have a single backedge.
|
||||
if (!getLoopLatch())
|
||||
return false;
|
||||
// Each predecessor of each exit block of a normal loop is contained
|
||||
// within the loop.
|
||||
SmallVector<BasicBlock *, 4> ExitBlocks;
|
||||
getExitBlocks(ExitBlocks);
|
||||
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i)
|
||||
for (pred_iterator PI = pred_begin(ExitBlocks[i]),
|
||||
PE = pred_end(ExitBlocks[i]); PI != PE; ++PI)
|
||||
if (!contains(*PI))
|
||||
return false;
|
||||
// All the requirements are met.
|
||||
return true;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// LoopInfo implementation
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user