1 ; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s
3 declare void @llvm.experimental.guard(i1, ...)
4 declare void @llvm.assume(i1)
6 define void @s_0(i32 %n, i1* %cond) {
7 ; CHECK-LABEL: Classifying expressions for: @s_0
12 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
13 %iv.inc = add i32 %iv, 1
14 %iv.sext = sext i32 %iv to i64
15 ; CHECK: %iv.sext = sext i32 %iv to i64
16 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop>
17 %cmp = icmp slt i32 %iv, %n
18 call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
19 %c = load volatile i1, i1* %cond
20 br i1 %c, label %loop, label %leave
26 define void @s_1(i1* %cond) {
27 ; CHECK-LABEL: Classifying expressions for: @s_1
32 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
33 %iv.inc = add i32 %iv, 3
34 %iv.sext = sext i32 %iv to i64
35 ; CHECK: %iv.sext = sext i32 %iv to i64
36 ; CHECK-NEXT: --> {0,+,3}<nuw><nsw><%loop>
37 %cmp = icmp slt i32 %iv, 10000
38 call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
39 %c = load volatile i1, i1* %cond
40 br i1 %c, label %loop, label %leave
46 define void @s_2(i1* %cond) {
47 ; CHECK-LABEL: Classifying expressions for: @s_2
52 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
53 %iv.inc = add i32 %iv, 3
54 %iv.sext = sext i32 %iv to i64
55 %cmp = icmp slt i32 %iv, 10000
56 ; CHECK: %iv.sext = sext i32 %iv to i64
57 ; CHECK-NEXT: --> {0,+,3}<nuw><nsw><%loop>
58 call void @llvm.assume(i1 %cmp)
59 %c = load volatile i1, i1* %cond
60 br i1 %c, label %loop, label %leave
66 define void @s_3(i32 %start, i1* %cond) {
67 ; CHECK-LABEL: Classifying expressions for: @s_3
72 %iv = phi i32 [ %start, %entry ], [ %iv.inc, %be ]
73 %cmp = icmp slt i32 %iv, 10000
74 br i1 %cmp, label %be, label %leave
77 %iv.inc = add i32 %iv, 3
78 %iv.inc.sext = sext i32 %iv.inc to i64
79 ; CHECK: %iv.inc.sext = sext i32 %iv.inc to i64
80 ; CHECK-NEXT: --> {(sext i32 (3 + %start) to i64),+,3}<nsw><%loop>
81 %c = load volatile i1, i1* %cond
82 br i1 %c, label %loop, label %leave
88 define void @s_4(i32 %start, i1* %cond) {
89 ; CHECK-LABEL: Classifying expressions for: @s_4
94 %iv = phi i32 [ %start, %entry ], [ %iv.inc, %be ]
95 %cmp = icmp sgt i32 %iv, -1000
96 br i1 %cmp, label %be, label %leave
99 %iv.inc = add i32 %iv, -3
100 %iv.inc.sext = sext i32 %iv.inc to i64
101 ; CHECK: %iv.inc.sext = sext i32 %iv.inc to i64
102 ; CHECK-NEXT: --> {(sext i32 (-3 + %start) to i64),+,-3}<nsw><%loop>
103 %c = load volatile i1, i1* %cond
104 br i1 %c, label %loop, label %leave
110 define void @u_0(i32 %n, i1* %cond) {
111 ; CHECK-LABEL: Classifying expressions for: @u_0
116 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
117 %iv.inc = add i32 %iv, 1
118 %iv.zext = zext i32 %iv to i64
119 ; CHECK: %iv.zext = zext i32 %iv to i64
120 ; CHECK-NEXT: --> {0,+,1}<nuw><%loop>
121 %cmp = icmp ult i32 %iv, %n
122 call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
123 %c = load volatile i1, i1* %cond
124 br i1 %c, label %loop, label %leave
130 define void @u_1(i1* %cond) {
131 ; CHECK-LABEL: Classifying expressions for: @u_1
136 %iv = phi i32 [ 0, %entry ], [ %iv.inc, %loop ]
137 %iv.inc = add i32 %iv, 3
138 %iv.zext = zext i32 %iv to i64
139 ; CHECK: %iv.zext = zext i32 %iv to i64
140 ; CHECK-NEXT: --> {0,+,3}<nuw><%loop>
141 %cmp = icmp ult i32 %iv, 10000
142 call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
143 %c = load volatile i1, i1* %cond
144 br i1 %c, label %loop, label %leave
150 define void @u_2(i1* %cond) {
151 ; CHECK-LABEL: Classifying expressions for: @u_2
156 %iv = phi i32 [ 30000, %entry ], [ %iv.inc, %loop ]
157 %iv.inc = add i32 %iv, -2
158 %iv.zext = zext i32 %iv to i64
159 %cmp = icmp ugt i32 %iv.inc, -10000
160 ; CHECK: %iv.zext = zext i32 %iv to i64
161 ; CHECK-NEXT: --> {30000,+,-2}<nw><%loop>
162 call void @llvm.assume(i1 %cmp)
163 %c = load volatile i1, i1* %cond
164 br i1 %c, label %loop, label %leave
170 define void @u_3(i32 %start, i1* %cond) {
171 ; CHECK-LABEL: Classifying expressions for: @u_3
176 %iv = phi i32 [ %start, %entry ], [ %iv.inc, %be ]
177 %cmp = icmp ult i32 %iv, 10000
178 br i1 %cmp, label %be, label %leave
181 %iv.inc = add i32 %iv, 3
182 %iv.inc.zext = zext i32 %iv.inc to i64
183 ; CHECK: %iv.inc.zext = zext i32 %iv.inc to i64
184 ; CHECK-NEXT: --> {(zext i32 (3 + %start) to i64),+,3}<nuw><%loop>
185 %c = load volatile i1, i1* %cond
186 br i1 %c, label %loop, label %leave