aboutsummaryrefslogtreecommitdiffstats
path: root/test/Analysis/ScalarEvolution/range-signedness.ll
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/ScalarEvolution/range-signedness.ll')
-rw-r--r--test/Analysis/ScalarEvolution/range-signedness.ll39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/Analysis/ScalarEvolution/range-signedness.ll b/test/Analysis/ScalarEvolution/range-signedness.ll
new file mode 100644
index 0000000..d04fc9e
--- /dev/null
+++ b/test/Analysis/ScalarEvolution/range-signedness.ll
@@ -0,0 +1,39 @@
+; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s
+
+define void @x(i1* %cond) {
+; CHECK-LABEL: Classifying expressions for: @x
+ entry:
+ br label %loop
+
+ loop:
+ %idx = phi i8 [ 0, %entry ], [ %idx.inc, %loop ]
+; CHECK: %idx = phi i8 [ 0, %entry ], [ %idx.inc, %loop ]
+; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,-128) S: [0,-128)
+
+ %idx.inc = add nsw i8 %idx, 1
+
+ %c = load volatile i1, i1* %cond
+ br i1 %c, label %loop, label %exit
+
+ exit:
+ ret void
+}
+
+define void @y(i8* %addr) {
+; CHECK-LABEL: Classifying expressions for: @y
+ entry:
+ br label %loop
+
+ loop:
+ %idx = phi i8 [-5, %entry ], [ %idx.inc, %loop ]
+; CHECK: %idx = phi i8 [ -5, %entry ], [ %idx.inc, %loop ]
+; CHECK-NEXT: --> {-5,+,1}<%loop> U: [-5,6) S: [-5,6)
+
+ %idx.inc = add i8 %idx, 1
+
+ %continue = icmp slt i8 %idx.inc, 6
+ br i1 %continue, label %loop, label %exit
+
+ exit:
+ ret void
+}