aboutsummaryrefslogtreecommitdiffstats
path: root/test/Analysis
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-02-19 18:12:07 +0000
committerDan Gohman <gohman@apple.com>2010-02-19 18:12:07 +0000
commit00cb5b724547a821516292fe5cded7c6a5358bda (patch)
treea7de32f5f0495e9ca18a39599e62d221d4edf950 /test/Analysis
parent6b89aa57e6506f073579398bd74845db9463b9f1 (diff)
downloadexternal_llvm-00cb5b724547a821516292fe5cded7c6a5358bda.zip
external_llvm-00cb5b724547a821516292fe5cded7c6a5358bda.tar.gz
external_llvm-00cb5b724547a821516292fe5cded7c6a5358bda.tar.bz2
Teach ScalarEvolution how to compute a tripcount for a loop with
true or false as its exit condition. These are usually eliminated by SimplifyCFG, but the may be left around during a pass which wishes to preserve the CFG. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96683 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r--test/Analysis/ScalarEvolution/trip-count10.ll76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/Analysis/ScalarEvolution/trip-count10.ll b/test/Analysis/ScalarEvolution/trip-count10.ll
new file mode 100644
index 0000000..0a992f9
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/trip-count10.ll
@@ -0,0 +1,76 @@
+; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s
+
+; Trip counts with trivial exit conditions.
+
+; CHECK: Determining loop execution counts for: @a
+; CHECK: Loop %loop: Unpredictable backedge-taken count.
+; CHECK: Loop %loop: Unpredictable max backedge-taken count.
+
+; CHECK: Determining loop execution counts for: @b
+; CHECK: Loop %loop: backedge-taken count is false
+; CHECK: Loop %loop: max backedge-taken count is false
+
+; CHECK: Determining loop execution counts for: @c
+; CHECK: Loop %loop: backedge-taken count is false
+; CHECK: Loop %loop: max backedge-taken count is false
+
+; CHECK: Determining loop execution counts for: @d
+; CHECK: Loop %loop: Unpredictable backedge-taken count.
+; CHECK: Loop %loop: Unpredictable max backedge-taken count.
+
+define void @a(i64 %n) nounwind {
+entry:
+ %t0 = icmp sgt i64 %n, 0
+ br i1 %t0, label %loop, label %return
+
+loop:
+ %i = phi i64 [ %i.next, %loop ], [ 0, %entry ]
+ %i.next = add nsw i64 %i, 1
+ %exitcond = icmp eq i64 %i.next, %n
+ br i1 false, label %return, label %loop
+
+return:
+ ret void
+}
+define void @b(i64 %n) nounwind {
+entry:
+ %t0 = icmp sgt i64 %n, 0
+ br i1 %t0, label %loop, label %return
+
+loop:
+ %i = phi i64 [ %i.next, %loop ], [ 0, %entry ]
+ %i.next = add nsw i64 %i, 1
+ %exitcond = icmp eq i64 %i.next, %n
+ br i1 true, label %return, label %loop
+
+return:
+ ret void
+}
+define void @c(i64 %n) nounwind {
+entry:
+ %t0 = icmp sgt i64 %n, 0
+ br i1 %t0, label %loop, label %return
+
+loop:
+ %i = phi i64 [ %i.next, %loop ], [ 0, %entry ]
+ %i.next = add nsw i64 %i, 1
+ %exitcond = icmp eq i64 %i.next, %n
+ br i1 false, label %loop, label %return
+
+return:
+ ret void
+}
+define void @d(i64 %n) nounwind {
+entry:
+ %t0 = icmp sgt i64 %n, 0
+ br i1 %t0, label %loop, label %return
+
+loop:
+ %i = phi i64 [ %i.next, %loop ], [ 0, %entry ]
+ %i.next = add nsw i64 %i, 1
+ %exitcond = icmp eq i64 %i.next, %n
+ br i1 true, label %loop, label %return
+
+return:
+ ret void
+}