1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-max-iterations=0 -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 declare void @non_exit_use(i32 %i) #0
9 define void @sle_pre_inc(i32 %len) willreturn {
10 ; CHECK-LABEL: 'sle_pre_inc'
11 ; CHECK-NEXT: Determining loop execution counts for: @sle_pre_inc
12 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (0 smax (1 + %len))
13 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 2147483647
14 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (0 smax (1 + %len))
15 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (0 smax (1 + %len))
16 ; CHECK-NEXT: Predicates:
17 ; CHECK-NEXT: Loop %for.body: Trip multiple is 1
23 %iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
24 call void @non_exit_use(i32 %iv) nounwind willreturn
26 %cmp = icmp sle i32 %iv, %len
27 br i1 %cmp, label %for.body, label %for.end
33 define void @sle_post_inc(i32 %len) willreturn {
34 ; CHECK-LABEL: 'sle_post_inc'
35 ; CHECK-NEXT: Determining loop execution counts for: @sle_post_inc
36 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + (1 smax (1 + %len)))<nsw>
37 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 2147483646
38 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + (1 smax (1 + %len)))<nsw>
39 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + (1 smax (1 + %len)))<nsw>
40 ; CHECK-NEXT: Predicates:
41 ; CHECK-NEXT: Loop %for.body: Trip multiple is 1
47 %iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
48 call void @non_exit_use(i32 %iv) nounwind willreturn
50 %cmp = icmp sle i32 %inc, %len
51 br i1 %cmp, label %for.body, label %for.end
57 define void @sle_pre_inc_infinite(i32 %len) {
58 ; CHECK-LABEL: 'sle_pre_inc_infinite'
59 ; CHECK-NEXT: Determining loop execution counts for: @sle_pre_inc_infinite
60 ; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
61 ; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
62 ; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
63 ; CHECK-NEXT: Loop %for.body: Unpredictable predicated backedge-taken count.
69 %iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
70 call void @non_exit_use(i32 %iv) nounwind willreturn
72 %cmp = icmp sle i32 %iv, %len
73 br i1 %cmp, label %for.body, label %for.end
79 define void @ule_pre_inc(i32 %len) willreturn {
80 ; CHECK-LABEL: 'ule_pre_inc'
81 ; CHECK-NEXT: Determining loop execution counts for: @ule_pre_inc
82 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (1 + %len)
83 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -1
84 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (1 + %len)
85 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (1 + %len)
86 ; CHECK-NEXT: Predicates:
87 ; CHECK-NEXT: Loop %for.body: Trip multiple is 1
93 %iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
94 call void @non_exit_use(i32 %iv) nounwind willreturn
96 %cmp = icmp ule i32 %iv, %len
97 br i1 %cmp, label %for.body, label %for.end
103 define void @ule_post_inc(i32 %len) willreturn {
104 ; CHECK-LABEL: 'ule_post_inc'
105 ; CHECK-NEXT: Determining loop execution counts for: @ule_post_inc
106 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + (1 umax (1 + %len)))
107 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2
108 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + (1 umax (1 + %len)))
109 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + (1 umax (1 + %len)))
110 ; CHECK-NEXT: Predicates:
111 ; CHECK-NEXT: Loop %for.body: Trip multiple is 1
117 %iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
118 call void @non_exit_use(i32 %iv) nounwind willreturn
119 %inc = add i32 %iv, 1
120 %cmp = icmp ule i32 %inc, %len
121 br i1 %cmp, label %for.body, label %for.end
127 define void @ule_pre_inc_infinite(i32 %len) {
128 ; CHECK-LABEL: 'ule_pre_inc_infinite'
129 ; CHECK-NEXT: Determining loop execution counts for: @ule_pre_inc_infinite
130 ; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
131 ; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
132 ; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
133 ; CHECK-NEXT: Loop %for.body: Unpredictable predicated backedge-taken count.
139 %iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
140 call void @non_exit_use(i32 %iv) nounwind willreturn
141 %inc = add i32 %iv, 1
142 %cmp = icmp ule i32 %iv, %len
143 br i1 %cmp, label %for.body, label %for.end
149 define void @sge_pre_inc(i32 %end) willreturn {
150 ; CHECK-LABEL: 'sge_pre_inc'
151 ; CHECK-NEXT: Determining loop execution counts for: @sge_pre_inc
152 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
153 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2147483548
154 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
155 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
156 ; CHECK-NEXT: Predicates:
157 ; CHECK-NEXT: Loop %for.body: Trip multiple is 1
163 %iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
164 call void @non_exit_use(i32 %iv) nounwind willreturn
165 %inc = add i32 %iv, -1
166 %cmp = icmp sge i32 %iv, %end
167 br i1 %cmp, label %for.body, label %for.end
173 define void @sge_post_inc(i32 %end) willreturn {
174 ; CHECK-LABEL: 'sge_post_inc'
175 ; CHECK-NEXT: Determining loop execution counts for: @sge_post_inc
176 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
177 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2147483548
178 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
179 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
180 ; CHECK-NEXT: Predicates:
181 ; CHECK-NEXT: Loop %for.body: Trip multiple is 1
187 %iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
188 call void @non_exit_use(i32 %iv) nounwind willreturn
189 %inc = add i32 %iv, -1
190 %cmp = icmp sge i32 %iv, %end
191 br i1 %cmp, label %for.body, label %for.end
197 define void @sge_pre_inc_infinite(i32 %end) {
198 ; CHECK-LABEL: 'sge_pre_inc_infinite'
199 ; CHECK-NEXT: Determining loop execution counts for: @sge_pre_inc_infinite
200 ; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
201 ; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
202 ; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
203 ; CHECK-NEXT: Loop %for.body: Unpredictable predicated backedge-taken count.
209 %iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
210 call void @non_exit_use(i32 %iv) nounwind willreturn
211 %inc = add i32 %iv, -1
212 %cmp = icmp sge i32 %iv, %end
213 br i1 %cmp, label %for.body, label %for.end
219 define void @use_pre_inc(i32 %end) willreturn {
220 ; CHECK-LABEL: 'use_pre_inc'
221 ; CHECK-NEXT: Determining loop execution counts for: @use_pre_inc
222 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (100 + (-1 * (100 umin (-1 + %end)))<nsw>)<nsw>
223 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 100
224 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (100 + (-1 * (100 umin (-1 + %end)))<nsw>)<nsw>
225 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (100 + (-1 * (100 umin (-1 + %end)))<nsw>)<nsw>
226 ; CHECK-NEXT: Predicates:
227 ; CHECK-NEXT: Loop %for.body: Trip multiple is 1
233 %iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
234 call void @non_exit_use(i32 %iv) nounwind willreturn
235 %inc = add i32 %iv, -1
236 %cmp = icmp uge i32 %iv, %end
237 br i1 %cmp, label %for.body, label %for.end
243 define void @use_post_inc(i32 %end) willreturn {
244 ; CHECK-LABEL: 'use_post_inc'
245 ; CHECK-NEXT: Determining loop execution counts for: @use_post_inc
246 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (99 + (-1 * (99 umin (-1 + %end)))<nsw>)<nsw>
247 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 99
248 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (99 + (-1 * (99 umin (-1 + %end)))<nsw>)<nsw>
249 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (99 + (-1 * (99 umin (-1 + %end)))<nsw>)<nsw>
250 ; CHECK-NEXT: Predicates:
251 ; CHECK-NEXT: Loop %for.body: Trip multiple is 1
257 %iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
258 call void @non_exit_use(i32 %iv) nounwind willreturn
259 %inc = add i32 %iv, -1
260 %cmp = icmp uge i32 %inc, %end
261 br i1 %cmp, label %for.body, label %for.end
267 define void @uge_pre_inc_infinite(i32 %end) {
268 ; CHECK-LABEL: 'uge_pre_inc_infinite'
269 ; CHECK-NEXT: Determining loop execution counts for: @uge_pre_inc_infinite
270 ; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
271 ; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
272 ; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
273 ; CHECK-NEXT: Loop %for.body: Unpredictable predicated backedge-taken count.
279 %iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
280 call void @non_exit_use(i32 %iv) nounwind willreturn
281 %inc = add i32 %iv, -1
282 %cmp = icmp uge i32 %iv, %end
283 br i1 %cmp, label %for.body, label %for.end
289 define void @pr54191(i64 %n) mustprogress {
290 ; CHECK-LABEL: 'pr54191'
291 ; CHECK-NEXT: Determining loop execution counts for: @pr54191
292 ; CHECK-NEXT: Loop %loop: backedge-taken count is ((-2 + %n) /u 2)
293 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 4611686018427387902
294 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is ((-2 + %n) /u 2)
295 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is ((-2 + %n) /u 2)
296 ; CHECK-NEXT: Predicates:
297 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
300 %guard = icmp sgt i64 %n, 1
301 br i1 %guard, label %loop, label %exit
304 %iv = phi i64 [ 2, %entry ], [ %iv.next, %loop ]
305 %iv.next = add nuw nsw i64 %iv, 2
306 %cmp = icmp sle i64 %iv.next, %n
307 br i1 %cmp, label %loop, label %exit