summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LoopInfo.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-16 16:16:23 +0000
committerDan Gohman <gohman@apple.com>2009-07-16 16:16:23 +0000
commit1511f701e7316635868e81753788d1192ac770b3 (patch)
tree0dbee0885232f72c978c72fe05ec1c530de9e679 /llvm/lib/Analysis/LoopInfo.cpp
parent79d1215d83b14d26ef7dd287eced32849a44a524 (diff)
downloadbcm5719-llvm-1511f701e7316635868e81753788d1192ac770b3.tar.gz
bcm5719-llvm-1511f701e7316635868e81753788d1192ac770b3.zip
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
Diffstat (limited to 'llvm/lib/Analysis/LoopInfo.cpp')
-rw-r--r--llvm/lib/Analysis/LoopInfo.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index 63de1aa7aee..d350fa6f9eb 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/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
//
OpenPOWER on IntegriCloud