1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
6 define i32 @test_simple_case(i32 %start, i32 %len) {
7 ; CHECK-LABEL: 'test_simple_case'
8 ; CHECK-NEXT: Classifying expressions for: @test_simple_case
9 ; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %backedge ]
10 ; CHECK-NEXT: --> {%start,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
11 ; CHECK-NEXT: %iv.minus.1 = add i32 %iv, -1
12 ; CHECK-NEXT: --> {(-1 + %start),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
13 ; CHECK-NEXT: %iv.next = add i32 %iv, -1
14 ; CHECK-NEXT: --> {(-1 + %start),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
15 ; CHECK-NEXT: %loop_cond = call i1 @cond()
16 ; CHECK-NEXT: --> %loop_cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
17 ; CHECK-NEXT: Determining loop execution counts for: @test_simple_case
18 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
19 ; CHECK-NEXT: exit count for loop: %start
20 ; CHECK-NEXT: exit count for range_check_block: ***COULDNOTCOMPUTE***
21 ; CHECK-NEXT: exit count for backedge: ***COULDNOTCOMPUTE***
22 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
23 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is %start
24 ; CHECK-NEXT: symbolic max exit count for loop: %start
25 ; CHECK-NEXT: symbolic max exit count for range_check_block: ***COULDNOTCOMPUTE***
26 ; CHECK-NEXT: symbolic max exit count for backedge: ***COULDNOTCOMPUTE***
27 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
33 %iv = phi i32 [%start, %entry], [%iv.next, %backedge]
34 %zero_check = icmp ne i32 %iv, 0
35 br i1 %zero_check, label %range_check_block, label %failed_1
38 %iv.minus.1 = add i32 %iv, -1
39 %range_check = icmp ult i32 %iv.minus.1, %len
40 br i1 %range_check, label %backedge, label %failed_2
43 %iv.next = add i32 %iv, -1
44 %loop_cond = call i1 @cond()
45 br i1 %loop_cond, label %done, label %loop
57 define i32 @test_litter_conditions(i32 %start, i32 %len) {
58 ; CHECK-LABEL: 'test_litter_conditions'
59 ; CHECK-NEXT: Classifying expressions for: @test_litter_conditions
60 ; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %backedge ]
61 ; CHECK-NEXT: --> {%start,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
62 ; CHECK-NEXT: %fake_1 = call i1 @cond()
63 ; CHECK-NEXT: --> %fake_1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
64 ; CHECK-NEXT: %and_1 = and i1 %zero_check, %fake_1
65 ; CHECK-NEXT: --> (%zero_check umin %fake_1) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
66 ; CHECK-NEXT: %iv.minus.1 = add i32 %iv, -1
67 ; CHECK-NEXT: --> {(-1 + %start),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
68 ; CHECK-NEXT: %fake_2 = call i1 @cond()
69 ; CHECK-NEXT: --> %fake_2 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
70 ; CHECK-NEXT: %and_2 = and i1 %range_check, %fake_2
71 ; CHECK-NEXT: --> (%range_check umin %fake_2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
72 ; CHECK-NEXT: %iv.next = add i32 %iv, -1
73 ; CHECK-NEXT: --> {(-1 + %start),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
74 ; CHECK-NEXT: %loop_cond = call i1 @cond()
75 ; CHECK-NEXT: --> %loop_cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
76 ; CHECK-NEXT: Determining loop execution counts for: @test_litter_conditions
77 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
78 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
79 ; CHECK-NEXT: exit count for range_check_block: ***COULDNOTCOMPUTE***
80 ; CHECK-NEXT: exit count for backedge: ***COULDNOTCOMPUTE***
81 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
82 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is %start
83 ; CHECK-NEXT: symbolic max exit count for loop: %start
84 ; CHECK-NEXT: symbolic max exit count for range_check_block: ***COULDNOTCOMPUTE***
85 ; CHECK-NEXT: symbolic max exit count for backedge: ***COULDNOTCOMPUTE***
86 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
92 %iv = phi i32 [%start, %entry], [%iv.next, %backedge]
93 %zero_check = icmp ne i32 %iv, 0
94 %fake_1 = call i1 @cond()
95 %and_1 = and i1 %zero_check, %fake_1
96 br i1 %and_1, label %range_check_block, label %failed_1
99 %iv.minus.1 = add i32 %iv, -1
100 %range_check = icmp ult i32 %iv.minus.1, %len
101 %fake_2 = call i1 @cond()
102 %and_2 = and i1 %range_check, %fake_2
103 br i1 %and_2, label %backedge, label %failed_2
106 %iv.next = add i32 %iv, -1
107 %loop_cond = call i1 @cond()
108 br i1 %loop_cond, label %done, label %loop
120 define i32 @test_litter_conditions_bad_context(i32 %start, i32 %len) {
121 ; CHECK-LABEL: 'test_litter_conditions_bad_context'
122 ; CHECK-NEXT: Classifying expressions for: @test_litter_conditions_bad_context
123 ; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %backedge ]
124 ; CHECK-NEXT: --> {%start,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
125 ; CHECK-NEXT: %fake_1 = call i1 @cond()
126 ; CHECK-NEXT: --> %fake_1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
127 ; CHECK-NEXT: %and_1 = and i1 %zero_check, %fake_1
128 ; CHECK-NEXT: --> (%zero_check umin %fake_1) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
129 ; CHECK-NEXT: %iv.minus.1 = add i32 %iv, -1
130 ; CHECK-NEXT: --> {(-1 + %start),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
131 ; CHECK-NEXT: %fake_2 = call i1 @cond()
132 ; CHECK-NEXT: --> %fake_2 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
133 ; CHECK-NEXT: %and_2 = and i1 %range_check, %fake_2
134 ; CHECK-NEXT: --> (%range_check umin %fake_2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
135 ; CHECK-NEXT: %iv.next = add i32 %iv, -1
136 ; CHECK-NEXT: --> {(-1 + %start),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
137 ; CHECK-NEXT: %loop_cond = call i1 @cond()
138 ; CHECK-NEXT: --> %loop_cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
139 ; CHECK-NEXT: Determining loop execution counts for: @test_litter_conditions_bad_context
140 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
141 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
142 ; CHECK-NEXT: exit count for range_check_block: ***COULDNOTCOMPUTE***
143 ; CHECK-NEXT: exit count for backedge: ***COULDNOTCOMPUTE***
144 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
145 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is %start
146 ; CHECK-NEXT: symbolic max exit count for loop: %start
147 ; CHECK-NEXT: symbolic max exit count for range_check_block: ***COULDNOTCOMPUTE***
148 ; CHECK-NEXT: symbolic max exit count for backedge: ***COULDNOTCOMPUTE***
149 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
155 %iv = phi i32 [%start, %entry], [%iv.next, %backedge]
156 %zero_check = icmp ne i32 %iv, 0
157 %fake_1 = call i1 @cond()
158 %and_1 = and i1 %zero_check, %fake_1
159 %iv.minus.1 = add i32 %iv, -1
160 %range_check = icmp ult i32 %iv.minus.1, %len
161 %fake_2 = call i1 @cond()
162 %and_2 = and i1 %range_check, %fake_2
163 br i1 %and_1, label %range_check_block, label %failed_1
166 br i1 %and_2, label %backedge, label %failed_2
169 %iv.next = add i32 %iv, -1
170 %loop_cond = call i1 @cond()
171 br i1 %loop_cond, label %done, label %loop
183 define i32 @test_and_conditions(i32 %start, i32 %len) {
184 ; CHECK-LABEL: 'test_and_conditions'
185 ; CHECK-NEXT: Classifying expressions for: @test_and_conditions
186 ; CHECK-NEXT: %iv = phi i32 [ %start, %entry ], [ %iv.next, %backedge ]
187 ; CHECK-NEXT: --> {%start,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
188 ; CHECK-NEXT: %iv.minus.1 = add i32 %iv, -1
189 ; CHECK-NEXT: --> {(-1 + %start),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
190 ; CHECK-NEXT: %both_checks = and i1 %zero_check, %range_check
191 ; CHECK-NEXT: --> (%range_check umin %zero_check) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
192 ; CHECK-NEXT: %iv.next = add i32 %iv, -1
193 ; CHECK-NEXT: --> {(-1 + %start),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
194 ; CHECK-NEXT: %loop_cond = call i1 @cond()
195 ; CHECK-NEXT: --> %loop_cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
196 ; CHECK-NEXT: Determining loop execution counts for: @test_and_conditions
197 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
198 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
199 ; CHECK-NEXT: exit count for backedge: ***COULDNOTCOMPUTE***
200 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
201 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is %start
202 ; CHECK-NEXT: symbolic max exit count for loop: %start
203 ; CHECK-NEXT: symbolic max exit count for backedge: ***COULDNOTCOMPUTE***
204 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
210 %iv = phi i32 [%start, %entry], [%iv.next, %backedge]
211 %zero_check = icmp ne i32 %iv, 0
212 %iv.minus.1 = add i32 %iv, -1
213 %range_check = icmp ult i32 %iv.minus.1, %len
214 %both_checks = and i1 %zero_check, %range_check
215 br i1 %both_checks, label %backedge, label %failed
218 %iv.next = add i32 %iv, -1
219 %loop_cond = call i1 @cond()
220 br i1 %loop_cond, label %done, label %loop
229 define i32 @test_mixup_constant_symbolic(i32 %end, i32 %len) {
230 ; CHECK-LABEL: 'test_mixup_constant_symbolic'
231 ; CHECK-NEXT: Classifying expressions for: @test_mixup_constant_symbolic
232 ; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]
233 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,1001) S: [0,1001) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
234 ; CHECK-NEXT: %iv.next = add i32 %iv, 1
235 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,1002) S: [1,1002) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
236 ; CHECK-NEXT: %loop_cond = call i1 @cond()
237 ; CHECK-NEXT: --> %loop_cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
238 ; CHECK-NEXT: Determining loop execution counts for: @test_mixup_constant_symbolic
239 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
240 ; CHECK-NEXT: exit count for loop: %end
241 ; CHECK-NEXT: exit count for range_check_block: 1000
242 ; CHECK-NEXT: exit count for backedge: ***COULDNOTCOMPUTE***
243 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 1000
244 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (1000 umin %end)
245 ; CHECK-NEXT: symbolic max exit count for loop: %end
246 ; CHECK-NEXT: symbolic max exit count for range_check_block: 1000
247 ; CHECK-NEXT: symbolic max exit count for backedge: ***COULDNOTCOMPUTE***
248 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
254 %iv = phi i32 [0, %entry], [%iv.next, %backedge]
255 %zero_check = icmp ne i32 %iv, %end
256 br i1 %zero_check, label %range_check_block, label %failed_1
259 %range_check = icmp ult i32 %iv, 1000
260 br i1 %range_check, label %backedge, label %failed_2
263 %iv.next = add i32 %iv, 1
264 %loop_cond = call i1 @cond()
265 br i1 %loop_cond, label %done, label %loop
277 define i32 @test_mixup_constant_symbolic_merged(i32 %end, i32 %len) {
278 ; CHECK-LABEL: 'test_mixup_constant_symbolic_merged'
279 ; CHECK-NEXT: Classifying expressions for: @test_mixup_constant_symbolic_merged
280 ; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]
281 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,1001) S: [0,1001) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
282 ; CHECK-NEXT: %and = and i1 %zero_check, %range_check
283 ; CHECK-NEXT: --> (%range_check umin %zero_check) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
284 ; CHECK-NEXT: %iv.next = add i32 %iv, 1
285 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,1002) S: [1,1002) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
286 ; CHECK-NEXT: %loop_cond = call i1 @cond()
287 ; CHECK-NEXT: --> %loop_cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
288 ; CHECK-NEXT: Determining loop execution counts for: @test_mixup_constant_symbolic_merged
289 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
290 ; CHECK-NEXT: exit count for loop: (1000 umin %end)
291 ; CHECK-NEXT: exit count for backedge: ***COULDNOTCOMPUTE***
292 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 1000
293 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (1000 umin %end)
294 ; CHECK-NEXT: symbolic max exit count for loop: (1000 umin %end)
295 ; CHECK-NEXT: symbolic max exit count for backedge: ***COULDNOTCOMPUTE***
296 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
302 %iv = phi i32 [0, %entry], [%iv.next, %backedge]
303 %zero_check = icmp ne i32 %iv, %end
304 %range_check = icmp ult i32 %iv, 1000
305 %and = and i1 %zero_check, %range_check
306 br i1 %and, label %backedge, label %failed_1
309 %iv.next = add i32 %iv, 1
310 %loop_cond = call i1 @cond()
311 br i1 %loop_cond, label %done, label %loop
320 define i32 @test_two_phis(i32 %start_1, i32 %start_2, i32 %len) {
321 ; CHECK-LABEL: 'test_two_phis'
322 ; CHECK-NEXT: Classifying expressions for: @test_two_phis
323 ; CHECK-NEXT: %iv_1 = phi i32 [ %start_1, %entry ], [ %iv_1.next, %backedge ]
324 ; CHECK-NEXT: --> {%start_1,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
325 ; CHECK-NEXT: %iv_2 = phi i32 [ %start_2, %entry ], [ %iv_2.next, %backedge ]
326 ; CHECK-NEXT: --> {%start_2,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
327 ; CHECK-NEXT: %scam_1 = call i1 @cond()
328 ; CHECK-NEXT: --> %scam_1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
329 ; CHECK-NEXT: %c1 = and i1 %zero_check_1, %scam_1
330 ; CHECK-NEXT: --> (%zero_check_1 umin %scam_1) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
331 ; CHECK-NEXT: %scam_2 = call i1 @cond()
332 ; CHECK-NEXT: --> %scam_2 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
333 ; CHECK-NEXT: %c2 = and i1 %zero_check_2, %scam_2
334 ; CHECK-NEXT: --> (%zero_check_2 umin %scam_2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
335 ; CHECK-NEXT: %iv.minus.1 = add i32 %iv_1, -1
336 ; CHECK-NEXT: --> {(-1 + %start_1),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
337 ; CHECK-NEXT: %iv_1.next = add i32 %iv_1, -1
338 ; CHECK-NEXT: --> {(-1 + %start_1),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
339 ; CHECK-NEXT: %iv_2.next = add i32 %iv_2, -1
340 ; CHECK-NEXT: --> {(-1 + %start_2),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
341 ; CHECK-NEXT: %loop_cond = call i1 @cond()
342 ; CHECK-NEXT: --> %loop_cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
343 ; CHECK-NEXT: Determining loop execution counts for: @test_two_phis
344 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
345 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
346 ; CHECK-NEXT: exit count for zero_check_block: ***COULDNOTCOMPUTE***
347 ; CHECK-NEXT: exit count for range_check_block: ***COULDNOTCOMPUTE***
348 ; CHECK-NEXT: exit count for backedge: ***COULDNOTCOMPUTE***
349 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
350 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (%start_1 umin_seq %start_2)
351 ; CHECK-NEXT: symbolic max exit count for loop: %start_1
352 ; CHECK-NEXT: symbolic max exit count for zero_check_block: %start_2
353 ; CHECK-NEXT: symbolic max exit count for range_check_block: ***COULDNOTCOMPUTE***
354 ; CHECK-NEXT: symbolic max exit count for backedge: ***COULDNOTCOMPUTE***
355 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
361 %iv_1 = phi i32 [%start_1, %entry], [%iv_1.next, %backedge]
362 %iv_2 = phi i32 [%start_2, %entry], [%iv_2.next, %backedge]
363 %scam_1 = call i1 @cond()
364 %zero_check_1 = icmp ne i32 %iv_1, 0
365 %c1 = and i1 %zero_check_1, %scam_1
366 br i1 %c1, label %zero_check_block, label %failed_1
369 %scam_2 = call i1 @cond()
370 %zero_check_2 = icmp ne i32 %iv_2, 0
371 %c2 = and i1 %zero_check_2, %scam_2
372 br i1 %c2, label %range_check_block, label %failed_1
375 %iv.minus.1 = add i32 %iv_1, -1
376 %range_check = icmp ult i32 %iv.minus.1, %len
377 br i1 %range_check, label %backedge, label %failed_2
380 %iv_1.next = add i32 %iv_1, -1
381 %iv_2.next = add i32 %iv_2, -1
382 %loop_cond = call i1 @cond()
383 br i1 %loop_cond, label %done, label %loop
395 define i32 @test_two_phis_simple(i32 %start_1, i32 %start_2, i32 %len) {
396 ; CHECK-LABEL: 'test_two_phis_simple'
397 ; CHECK-NEXT: Classifying expressions for: @test_two_phis_simple
398 ; CHECK-NEXT: %iv_1 = phi i32 [ %start_1, %entry ], [ %iv_1.next, %backedge ]
399 ; CHECK-NEXT: --> {%start_1,+,-1}<%loop> U: full-set S: full-set Exits: ((-1 * (%start_1 umin_seq %start_2)) + %start_1) LoopDispositions: { %loop: Computable }
400 ; CHECK-NEXT: %iv_2 = phi i32 [ %start_2, %entry ], [ %iv_2.next, %backedge ]
401 ; CHECK-NEXT: --> {%start_2,+,-1}<%loop> U: full-set S: full-set Exits: ((-1 * (%start_1 umin_seq %start_2)) + %start_2) LoopDispositions: { %loop: Computable }
402 ; CHECK-NEXT: %iv_1.next = add i32 %iv_1, -1
403 ; CHECK-NEXT: --> {(-1 + %start_1),+,-1}<%loop> U: full-set S: full-set Exits: (-1 + (-1 * (%start_1 umin_seq %start_2)) + %start_1) LoopDispositions: { %loop: Computable }
404 ; CHECK-NEXT: %iv_2.next = add i32 %iv_2, -1
405 ; CHECK-NEXT: --> {(-1 + %start_2),+,-1}<%loop> U: full-set S: full-set Exits: (-1 + (-1 * (%start_1 umin_seq %start_2)) + %start_2) LoopDispositions: { %loop: Computable }
406 ; CHECK-NEXT: Determining loop execution counts for: @test_two_phis_simple
407 ; CHECK-NEXT: Loop %loop: <multiple exits> backedge-taken count is (%start_1 umin_seq %start_2)
408 ; CHECK-NEXT: exit count for loop: %start_1
409 ; CHECK-NEXT: exit count for backedge: %start_2
410 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
411 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (%start_1 umin_seq %start_2)
412 ; CHECK-NEXT: symbolic max exit count for loop: %start_1
413 ; CHECK-NEXT: symbolic max exit count for backedge: %start_2
414 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (%start_1 umin_seq %start_2)
415 ; CHECK-NEXT: Predicates:
416 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
422 %iv_1 = phi i32 [%start_1, %entry], [%iv_1.next, %backedge]
423 %iv_2 = phi i32 [%start_2, %entry], [%iv_2.next, %backedge]
424 %zero_check_1 = icmp ne i32 %iv_1, 0
425 br i1 %zero_check_1, label %backedge, label %exit
428 %zero_check_2 = icmp ne i32 %iv_2, 0
429 %iv_1.next = add i32 %iv_1, -1
430 %iv_2.next = add i32 %iv_2, -1
431 br i1 %zero_check_2, label %loop, label %exit
437 define i32 @test_two_phis_arithmetic_and(i32 %start_1, i32 %start_2, i32 %len) {
438 ; CHECK-LABEL: 'test_two_phis_arithmetic_and'
439 ; CHECK-NEXT: Classifying expressions for: @test_two_phis_arithmetic_and
440 ; CHECK-NEXT: %iv_1 = phi i32 [ %start_1, %entry ], [ %iv_1.next, %backedge ]
441 ; CHECK-NEXT: --> {%start_1,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
442 ; CHECK-NEXT: %iv_2 = phi i32 [ %start_2, %entry ], [ %iv_2.next, %backedge ]
443 ; CHECK-NEXT: --> {%start_2,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
444 ; CHECK-NEXT: %scam_1 = call i1 @cond()
445 ; CHECK-NEXT: --> %scam_1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
446 ; CHECK-NEXT: %c1 = and i1 %zero_check_1, %scam_1
447 ; CHECK-NEXT: --> (%zero_check_1 umin %scam_1) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
448 ; CHECK-NEXT: %scam_2 = call i1 @cond()
449 ; CHECK-NEXT: --> %scam_2 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
450 ; CHECK-NEXT: %c2 = and i1 %zero_check_2, %scam_2
451 ; CHECK-NEXT: --> (%zero_check_2 umin %scam_2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
452 ; CHECK-NEXT: %merged_cond = and i1 %c1, %c2
453 ; CHECK-NEXT: --> (%zero_check_1 umin %zero_check_2 umin %scam_1 umin %scam_2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
454 ; CHECK-NEXT: %iv.minus.1 = add i32 %iv_1, -1
455 ; CHECK-NEXT: --> {(-1 + %start_1),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
456 ; CHECK-NEXT: %iv_1.next = add i32 %iv_1, -1
457 ; CHECK-NEXT: --> {(-1 + %start_1),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
458 ; CHECK-NEXT: %iv_2.next = add i32 %iv_2, -1
459 ; CHECK-NEXT: --> {(-1 + %start_2),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
460 ; CHECK-NEXT: %loop_cond = call i1 @cond()
461 ; CHECK-NEXT: --> %loop_cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
462 ; CHECK-NEXT: Determining loop execution counts for: @test_two_phis_arithmetic_and
463 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
464 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
465 ; CHECK-NEXT: exit count for range_check_block: ***COULDNOTCOMPUTE***
466 ; CHECK-NEXT: exit count for backedge: ***COULDNOTCOMPUTE***
467 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
468 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (%start_1 umin %start_2)
469 ; CHECK-NEXT: symbolic max exit count for loop: (%start_1 umin %start_2)
470 ; CHECK-NEXT: symbolic max exit count for range_check_block: ***COULDNOTCOMPUTE***
471 ; CHECK-NEXT: symbolic max exit count for backedge: ***COULDNOTCOMPUTE***
472 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
478 %iv_1 = phi i32 [%start_1, %entry], [%iv_1.next, %backedge]
479 %iv_2 = phi i32 [%start_2, %entry], [%iv_2.next, %backedge]
480 %scam_1 = call i1 @cond()
481 %zero_check_1 = icmp ne i32 %iv_1, 0
482 %c1 = and i1 %zero_check_1, %scam_1
483 %scam_2 = call i1 @cond()
484 %zero_check_2 = icmp ne i32 %iv_2, 0
485 %c2 = and i1 %zero_check_2, %scam_2
486 %merged_cond = and i1 %c1, %c2
487 br i1 %merged_cond, label %range_check_block, label %failed_1
490 %iv.minus.1 = add i32 %iv_1, -1
491 %range_check = icmp ult i32 %iv.minus.1, %len
492 br i1 %range_check, label %backedge, label %failed_2
495 %iv_1.next = add i32 %iv_1, -1
496 %iv_2.next = add i32 %iv_2, -1
497 %loop_cond = call i1 @cond()
498 br i1 %loop_cond, label %done, label %loop
510 ; TODO: Symbolic max can be start1 umax_seq start2
511 define i32 @test_two_phis_logical_or(i32 %start_1, i32 %start_2, i32 %len) {
512 ; CHECK-LABEL: 'test_two_phis_logical_or'
513 ; CHECK-NEXT: Classifying expressions for: @test_two_phis_logical_or
514 ; CHECK-NEXT: %iv_1 = phi i32 [ %start_1, %entry ], [ %iv_1.next, %backedge ]
515 ; CHECK-NEXT: --> {%start_1,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
516 ; CHECK-NEXT: %iv_2 = phi i32 [ %start_2, %entry ], [ %iv_2.next, %backedge ]
517 ; CHECK-NEXT: --> {%start_2,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
518 ; CHECK-NEXT: %scam_1 = call i1 @cond()
519 ; CHECK-NEXT: --> %scam_1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
520 ; CHECK-NEXT: %c1 = and i1 %zero_check_1, %scam_1
521 ; CHECK-NEXT: --> (%zero_check_1 umin %scam_1) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
522 ; CHECK-NEXT: %scam_2 = call i1 @cond()
523 ; CHECK-NEXT: --> %scam_2 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
524 ; CHECK-NEXT: %c2 = and i1 %zero_check_2, %scam_2
525 ; CHECK-NEXT: --> (%zero_check_2 umin %scam_2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
526 ; CHECK-NEXT: %merged_cond = select i1 %c1, i1 true, i1 %c2
527 ; CHECK-NEXT: --> (true + ((true + (%zero_check_1 umin %scam_1)) umin_seq (true + (%zero_check_2 umin %scam_2)))) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
528 ; CHECK-NEXT: %iv.minus.1 = add i32 %iv_1, -1
529 ; CHECK-NEXT: --> {(-1 + %start_1),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
530 ; CHECK-NEXT: %iv_1.next = add i32 %iv_1, -1
531 ; CHECK-NEXT: --> {(-1 + %start_1),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
532 ; CHECK-NEXT: %iv_2.next = add i32 %iv_2, -1
533 ; CHECK-NEXT: --> {(-1 + %start_2),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
534 ; CHECK-NEXT: %loop_cond = call i1 @cond()
535 ; CHECK-NEXT: --> %loop_cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
536 ; CHECK-NEXT: Determining loop execution counts for: @test_two_phis_logical_or
537 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
538 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
539 ; CHECK-NEXT: exit count for range_check_block: ***COULDNOTCOMPUTE***
540 ; CHECK-NEXT: exit count for backedge: ***COULDNOTCOMPUTE***
541 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
542 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
543 ; CHECK-NEXT: symbolic max exit count for loop: ***COULDNOTCOMPUTE***
544 ; CHECK-NEXT: symbolic max exit count for range_check_block: ***COULDNOTCOMPUTE***
545 ; CHECK-NEXT: symbolic max exit count for backedge: ***COULDNOTCOMPUTE***
546 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
552 %iv_1 = phi i32 [%start_1, %entry], [%iv_1.next, %backedge]
553 %iv_2 = phi i32 [%start_2, %entry], [%iv_2.next, %backedge]
554 %scam_1 = call i1 @cond()
555 %zero_check_1 = icmp ne i32 %iv_1, 0
556 %c1 = and i1 %zero_check_1, %scam_1
557 %scam_2 = call i1 @cond()
558 %zero_check_2 = icmp ne i32 %iv_2, 0
559 %c2 = and i1 %zero_check_2, %scam_2
560 %merged_cond = select i1 %c1, i1 true, i1 %c2
561 br i1 %merged_cond, label %range_check_block, label %failed_1
564 %iv.minus.1 = add i32 %iv_1, -1
565 %range_check = icmp ult i32 %iv.minus.1, %len
566 br i1 %range_check, label %backedge, label %failed_2
569 %iv_1.next = add i32 %iv_1, -1
570 %iv_2.next = add i32 %iv_2, -1
571 %loop_cond = call i1 @cond()
572 br i1 %loop_cond, label %done, label %loop
584 define i32 @test_two_phis_logical_and(i32 %start_1, i32 %start_2, i32 %len) {
585 ; CHECK-LABEL: 'test_two_phis_logical_and'
586 ; CHECK-NEXT: Classifying expressions for: @test_two_phis_logical_and
587 ; CHECK-NEXT: %iv_1 = phi i32 [ %start_1, %entry ], [ %iv_1.next, %backedge ]
588 ; CHECK-NEXT: --> {%start_1,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
589 ; CHECK-NEXT: %iv_2 = phi i32 [ %start_2, %entry ], [ %iv_2.next, %backedge ]
590 ; CHECK-NEXT: --> {%start_2,+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
591 ; CHECK-NEXT: %scam_1 = call i1 @cond()
592 ; CHECK-NEXT: --> %scam_1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
593 ; CHECK-NEXT: %c1 = and i1 %zero_check_1, %scam_1
594 ; CHECK-NEXT: --> (%zero_check_1 umin %scam_1) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
595 ; CHECK-NEXT: %scam_2 = call i1 @cond()
596 ; CHECK-NEXT: --> %scam_2 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
597 ; CHECK-NEXT: %c2 = and i1 %zero_check_2, %scam_2
598 ; CHECK-NEXT: --> (%zero_check_2 umin %scam_2) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
599 ; CHECK-NEXT: %merged_cond = select i1 %c1, i1 %c2, i1 false
600 ; CHECK-NEXT: --> ((%zero_check_1 umin %scam_1) umin_seq (%zero_check_2 umin %scam_2)) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
601 ; CHECK-NEXT: %iv.minus.1 = add i32 %iv_1, -1
602 ; CHECK-NEXT: --> {(-1 + %start_1),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
603 ; CHECK-NEXT: %iv_1.next = add i32 %iv_1, -1
604 ; CHECK-NEXT: --> {(-1 + %start_1),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
605 ; CHECK-NEXT: %iv_2.next = add i32 %iv_2, -1
606 ; CHECK-NEXT: --> {(-1 + %start_2),+,-1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
607 ; CHECK-NEXT: %loop_cond = call i1 @cond()
608 ; CHECK-NEXT: --> %loop_cond U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
609 ; CHECK-NEXT: Determining loop execution counts for: @test_two_phis_logical_and
610 ; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
611 ; CHECK-NEXT: exit count for loop: ***COULDNOTCOMPUTE***
612 ; CHECK-NEXT: exit count for range_check_block: ***COULDNOTCOMPUTE***
613 ; CHECK-NEXT: exit count for backedge: ***COULDNOTCOMPUTE***
614 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is -1
615 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (%start_1 umin_seq %start_2)
616 ; CHECK-NEXT: symbolic max exit count for loop: (%start_1 umin_seq %start_2)
617 ; CHECK-NEXT: symbolic max exit count for range_check_block: ***COULDNOTCOMPUTE***
618 ; CHECK-NEXT: symbolic max exit count for backedge: ***COULDNOTCOMPUTE***
619 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
625 %iv_1 = phi i32 [%start_1, %entry], [%iv_1.next, %backedge]
626 %iv_2 = phi i32 [%start_2, %entry], [%iv_2.next, %backedge]
627 %scam_1 = call i1 @cond()
628 %zero_check_1 = icmp ne i32 %iv_1, 0
629 %c1 = and i1 %zero_check_1, %scam_1
630 %scam_2 = call i1 @cond()
631 %zero_check_2 = icmp ne i32 %iv_2, 0
632 %c2 = and i1 %zero_check_2, %scam_2
633 %merged_cond = select i1 %c1, i1 %c2, i1 false
634 br i1 %merged_cond, label %range_check_block, label %failed_1
637 %iv.minus.1 = add i32 %iv_1, -1
638 %range_check = icmp ult i32 %iv.minus.1, %len
639 br i1 %range_check, label %backedge, label %failed_2
642 %iv_1.next = add i32 %iv_1, -1
643 %iv_2.next = add i32 %iv_2, -1
644 %loop_cond = call i1 @cond()
645 br i1 %loop_cond, label %done, label %loop