diff options
author | Dan Gohman <gohman@apple.com> | 2009-07-16 16:16:23 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-07-16 16:16:23 +0000 |
commit | 937738649386b8188524d0cd61943214a5b93cf6 (patch) | |
tree | 2babcd964f9a5a5dfa4548014074a508954c0f69 /lib/Analysis/LoopInfo.cpp | |
parent | 6d53f55291c8541a508a8c26d847b942196f6f1c (diff) | |
download | external_llvm-937738649386b8188524d0cd61943214a5b93cf6.zip external_llvm-937738649386b8188524d0cd61943214a5b93cf6.tar.gz external_llvm-937738649386b8188524d0cd61943214a5b93cf6.tar.bz2 |
Add an isLoopSimplifyForm() predicate, following the example of
isLCSSAForm(), to test whether a loop is in the form guaranteed
by the LoopSimplify pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LoopInfo.cpp')
-rw-r--r-- | lib/Analysis/LoopInfo.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index 63de1aa..d350fa6 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -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 // |