1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt -passes='print<scalar-evolution>' < %s -disable-output 2>&1 | FileCheck %s
4 @constant = dso_local global i8 0, align 4
5 @another_constant = dso_local global i8 0, align 4
7 define i1 @binary_or.i1(i1 %x, i1 %y) {
8 ; CHECK-LABEL: 'binary_or.i1'
9 ; CHECK-NEXT: Classifying expressions for: @binary_or.i1
10 ; CHECK-NEXT: %r = or i1 %x, %y
11 ; CHECK-NEXT: --> (%x umax %y) U: full-set S: full-set
12 ; CHECK-NEXT: Determining loop execution counts for: @binary_or.i1
18 define i2 @binary_or.i2(i2 %x, i2 %y) {
19 ; CHECK-LABEL: 'binary_or.i2'
20 ; CHECK-NEXT: Classifying expressions for: @binary_or.i2
21 ; CHECK-NEXT: %r = or i2 %x, %y
22 ; CHECK-NEXT: --> %r U: full-set S: full-set
23 ; CHECK-NEXT: Determining loop execution counts for: @binary_or.i2
29 define i1 @binary_or.4ops.i1(i1 %x, i1 %y, i1 %z, i1 %a) {
30 ; CHECK-LABEL: 'binary_or.4ops.i1'
31 ; CHECK-NEXT: Classifying expressions for: @binary_or.4ops.i1
32 ; CHECK-NEXT: %t0 = or i1 %x, %y
33 ; CHECK-NEXT: --> (%x umax %y) U: full-set S: full-set
34 ; CHECK-NEXT: %t1 = or i1 %z, %a
35 ; CHECK-NEXT: --> (%z umax %a) U: full-set S: full-set
36 ; CHECK-NEXT: %r = or i1 %t0, %t1
37 ; CHECK-NEXT: --> (%x umax %y umax %z umax %a) U: full-set S: full-set
38 ; CHECK-NEXT: Determining loop execution counts for: @binary_or.4ops.i1
46 define i1 @binary_and.i1(i1 %x, i1 %y) {
47 ; CHECK-LABEL: 'binary_and.i1'
48 ; CHECK-NEXT: Classifying expressions for: @binary_and.i1
49 ; CHECK-NEXT: %r = and i1 %x, %y
50 ; CHECK-NEXT: --> (%x umin %y) U: full-set S: full-set
51 ; CHECK-NEXT: Determining loop execution counts for: @binary_and.i1
57 define i2 @binary_and.i2(i2 %x, i2 %y) {
58 ; CHECK-LABEL: 'binary_and.i2'
59 ; CHECK-NEXT: Classifying expressions for: @binary_and.i2
60 ; CHECK-NEXT: %r = and i2 %x, %y
61 ; CHECK-NEXT: --> %r U: full-set S: full-set
62 ; CHECK-NEXT: Determining loop execution counts for: @binary_and.i2
68 define i1 @binary_and.4ops.i1(i1 %x, i1 %y, i1 %z, i1 %a) {
69 ; CHECK-LABEL: 'binary_and.4ops.i1'
70 ; CHECK-NEXT: Classifying expressions for: @binary_and.4ops.i1
71 ; CHECK-NEXT: %t0 = and i1 %x, %y
72 ; CHECK-NEXT: --> (%x umin %y) U: full-set S: full-set
73 ; CHECK-NEXT: %t1 = and i1 %z, %a
74 ; CHECK-NEXT: --> (%z umin %a) U: full-set S: full-set
75 ; CHECK-NEXT: %r = and i1 %t0, %t1
76 ; CHECK-NEXT: --> (%x umin %y umin %z umin %a) U: full-set S: full-set
77 ; CHECK-NEXT: Determining loop execution counts for: @binary_and.4ops.i1
85 define i1 @binary_xor.i1(i1 %x, i1 %y) {
86 ; CHECK-LABEL: 'binary_xor.i1'
87 ; CHECK-NEXT: Classifying expressions for: @binary_xor.i1
88 ; CHECK-NEXT: %r = xor i1 %x, %y
89 ; CHECK-NEXT: --> (%x + %y) U: full-set S: full-set
90 ; CHECK-NEXT: Determining loop execution counts for: @binary_xor.i1
96 define i2 @binary_xor.i2(i2 %x, i2 %y) {
97 ; CHECK-LABEL: 'binary_xor.i2'
98 ; CHECK-NEXT: Classifying expressions for: @binary_xor.i2
99 ; CHECK-NEXT: %r = xor i2 %x, %y
100 ; CHECK-NEXT: --> %r U: full-set S: full-set
101 ; CHECK-NEXT: Determining loop execution counts for: @binary_xor.i2
107 define i1 @binary_xor.4ops.i1(i1 %x, i1 %y, i1 %z, i1 %a) {
108 ; CHECK-LABEL: 'binary_xor.4ops.i1'
109 ; CHECK-NEXT: Classifying expressions for: @binary_xor.4ops.i1
110 ; CHECK-NEXT: %t0 = xor i1 %x, %y
111 ; CHECK-NEXT: --> (%x + %y) U: full-set S: full-set
112 ; CHECK-NEXT: %t1 = xor i1 %z, %a
113 ; CHECK-NEXT: --> (%z + %a) U: full-set S: full-set
114 ; CHECK-NEXT: %r = xor i1 %t0, %t1
115 ; CHECK-NEXT: --> (%x + %y + %z + %a) U: full-set S: full-set
116 ; CHECK-NEXT: Determining loop execution counts for: @binary_xor.4ops.i1
124 define i1 @logical_or(i1 %x, i1 %y) {
125 ; CHECK-LABEL: 'logical_or'
126 ; CHECK-NEXT: Classifying expressions for: @logical_or
127 ; CHECK-NEXT: %r = select i1 %x, i1 true, i1 %y
128 ; CHECK-NEXT: --> (true + ((true + %x) umin_seq (true + %y))) U: full-set S: full-set
129 ; CHECK-NEXT: Determining loop execution counts for: @logical_or
131 %r = select i1 %x, i1 true, i1 %y
135 define i1 @logical_and(i1 %x, i1 %y) {
136 ; CHECK-LABEL: 'logical_and'
137 ; CHECK-NEXT: Classifying expressions for: @logical_and
138 ; CHECK-NEXT: %r = select i1 %x, i1 %y, i1 false
139 ; CHECK-NEXT: --> (%x umin_seq %y) U: full-set S: full-set
140 ; CHECK-NEXT: Determining loop execution counts for: @logical_and
142 %r = select i1 %x, i1 %y, i1 false
146 define i1 @select_x_or_false(i1 %c, i1 %x) {
147 ; CHECK-LABEL: 'select_x_or_false'
148 ; CHECK-NEXT: Classifying expressions for: @select_x_or_false
149 ; CHECK-NEXT: %r = select i1 %c, i1 %x, i1 false
150 ; CHECK-NEXT: --> (%c umin_seq %x) U: full-set S: full-set
151 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_false
153 %r = select i1 %c, i1 %x, i1 false
157 define i1 @select_false_or_x(i1 %c, i1 %x) {
158 ; CHECK-LABEL: 'select_false_or_x'
159 ; CHECK-NEXT: Classifying expressions for: @select_false_or_x
160 ; CHECK-NEXT: %r = select i1 %c, i1 false, i1 %x
161 ; CHECK-NEXT: --> ((true + %c) umin_seq %x) U: full-set S: full-set
162 ; CHECK-NEXT: Determining loop execution counts for: @select_false_or_x
164 %r = select i1 %c, i1 false, i1 %x
168 define i1 @select_x_or_true(i1 %c, i1 %x) {
169 ; CHECK-LABEL: 'select_x_or_true'
170 ; CHECK-NEXT: Classifying expressions for: @select_x_or_true
171 ; CHECK-NEXT: %r = select i1 %c, i1 %x, i1 true
172 ; CHECK-NEXT: --> (true + (%c umin_seq (true + %x))) U: full-set S: full-set
173 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_true
175 %r = select i1 %c, i1 %x, i1 true
179 define i1 @select_true_or_x(i1 %c, i1 %x) {
180 ; CHECK-LABEL: 'select_true_or_x'
181 ; CHECK-NEXT: Classifying expressions for: @select_true_or_x
182 ; CHECK-NEXT: %r = select i1 %c, i1 true, i1 %x
183 ; CHECK-NEXT: --> (true + ((true + %c) umin_seq (true + %x))) U: full-set S: full-set
184 ; CHECK-NEXT: Determining loop execution counts for: @select_true_or_x
186 %r = select i1 %c, i1 true, i1 %x
190 define i32 @select_x_or_zero(i1 %c, i32 %x) {
191 ; CHECK-LABEL: 'select_x_or_zero'
192 ; CHECK-NEXT: Classifying expressions for: @select_x_or_zero
193 ; CHECK-NEXT: %r = select i1 %c, i32 %x, i32 0
194 ; CHECK-NEXT: --> %r U: full-set S: full-set
195 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_zero
197 %r = select i1 %c, i32 %x, i32 0
201 define i32 @select_zero_or_x(i1 %c, i32 %x) {
202 ; CHECK-LABEL: 'select_zero_or_x'
203 ; CHECK-NEXT: Classifying expressions for: @select_zero_or_x
204 ; CHECK-NEXT: %r = select i1 %c, i32 0, i32 %x
205 ; CHECK-NEXT: --> %r U: full-set S: full-set
206 ; CHECK-NEXT: Determining loop execution counts for: @select_zero_or_x
208 %r = select i1 %c, i32 0, i32 %x
212 define i32 @select_x_or_allones(i1 %c, i32 %x) {
213 ; CHECK-LABEL: 'select_x_or_allones'
214 ; CHECK-NEXT: Classifying expressions for: @select_x_or_allones
215 ; CHECK-NEXT: %r = select i1 %c, i32 %x, i32 -1
216 ; CHECK-NEXT: --> %r U: full-set S: full-set
217 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_allones
219 %r = select i1 %c, i32 %x, i32 -1
223 define i32 @select_allones_or_x(i1 %c, i32 %x) {
224 ; CHECK-LABEL: 'select_allones_or_x'
225 ; CHECK-NEXT: Classifying expressions for: @select_allones_or_x
226 ; CHECK-NEXT: %r = select i1 %c, i32 -1, i32 %x
227 ; CHECK-NEXT: --> %r U: full-set S: full-set
228 ; CHECK-NEXT: Determining loop execution counts for: @select_allones_or_x
230 %r = select i1 %c, i32 -1, i32 %x
234 define i32 @select_x_or_intmax(i1 %c, i32 %x) {
235 ; CHECK-LABEL: 'select_x_or_intmax'
236 ; CHECK-NEXT: Classifying expressions for: @select_x_or_intmax
237 ; CHECK-NEXT: %r = select i1 %c, i32 %x, i32 2147483647
238 ; CHECK-NEXT: --> %r U: full-set S: full-set
239 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_intmax
241 %r = select i1 %c, i32 %x, i32 2147483647
245 define i32 @select_intmax_or_x(i1 %c, i32 %x) {
246 ; CHECK-LABEL: 'select_intmax_or_x'
247 ; CHECK-NEXT: Classifying expressions for: @select_intmax_or_x
248 ; CHECK-NEXT: %r = select i1 %c, i32 2147483647, i32 %x
249 ; CHECK-NEXT: --> %r U: full-set S: full-set
250 ; CHECK-NEXT: Determining loop execution counts for: @select_intmax_or_x
252 %r = select i1 %c, i32 2147483647, i32 %x
256 define i32 @select_x_or_intmin(i1 %c, i32 %x) {
257 ; CHECK-LABEL: 'select_x_or_intmin'
258 ; CHECK-NEXT: Classifying expressions for: @select_x_or_intmin
259 ; CHECK-NEXT: %r = select i1 %c, i32 %x, i32 -2147483648
260 ; CHECK-NEXT: --> %r U: full-set S: full-set
261 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_intmin
263 %r = select i1 %c, i32 %x, i32 -2147483648
267 define i32 @select_intmin_or_x(i1 %c, i32 %x) {
268 ; CHECK-LABEL: 'select_intmin_or_x'
269 ; CHECK-NEXT: Classifying expressions for: @select_intmin_or_x
270 ; CHECK-NEXT: %r = select i1 %c, i32 -2147483648, i32 %x
271 ; CHECK-NEXT: --> %r U: full-set S: full-set
272 ; CHECK-NEXT: Determining loop execution counts for: @select_intmin_or_x
274 %r = select i1 %c, i32 -2147483648, i32 %x
278 define i32 @select_x_or_constant(i1 %c, i32 %x) {
279 ; CHECK-LABEL: 'select_x_or_constant'
280 ; CHECK-NEXT: Classifying expressions for: @select_x_or_constant
281 ; CHECK-NEXT: %r = select i1 %c, i32 %x, i32 42
282 ; CHECK-NEXT: --> %r U: full-set S: full-set
283 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_constant
285 %r = select i1 %c, i32 %x, i32 42
289 define i32 @select_constant_or_x(i1 %c, i32 %y) {
290 ; CHECK-LABEL: 'select_constant_or_x'
291 ; CHECK-NEXT: Classifying expressions for: @select_constant_or_x
292 ; CHECK-NEXT: %r = select i1 %c, i32 42, i32 %y
293 ; CHECK-NEXT: --> %r U: full-set S: full-set
294 ; CHECK-NEXT: Determining loop execution counts for: @select_constant_or_x
296 %r = select i1 %c, i32 42, i32 %y
300 define i32 @select_between_constants(i1 %c, i32 %y) {
301 ; CHECK-LABEL: 'select_between_constants'
302 ; CHECK-NEXT: Classifying expressions for: @select_between_constants
303 ; CHECK-NEXT: %r = select i1 %c, i32 42, i32 24
304 ; CHECK-NEXT: --> %r U: [8,59) S: [8,59)
305 ; CHECK-NEXT: Determining loop execution counts for: @select_between_constants
307 %r = select i1 %c, i32 42, i32 24
311 define i32 @select_x_or_y(i1 %c, i32 %x, i32 %y) {
312 ; CHECK-LABEL: 'select_x_or_y'
313 ; CHECK-NEXT: Classifying expressions for: @select_x_or_y
314 ; CHECK-NEXT: %r = select i1 %c, i32 %x, i32 %y
315 ; CHECK-NEXT: --> %r U: full-set S: full-set
316 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_y
318 %r = select i1 %c, i32 %x, i32 %y
322 define i32 @select_x_or_y__noundef(i1 %c, i32 noundef %x, i32 noundef %y) {
323 ; CHECK-LABEL: 'select_x_or_y__noundef'
324 ; CHECK-NEXT: Classifying expressions for: @select_x_or_y__noundef
325 ; CHECK-NEXT: %r = select i1 %c, i32 %x, i32 %y
326 ; CHECK-NEXT: --> %r U: full-set S: full-set
327 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_y__noundef
329 %r = select i1 %c, i32 %x, i32 %y
333 define i32 @select_x_or_constantexpr(i1 %c, i32 %x) {
334 ; CHECK-LABEL: 'select_x_or_constantexpr'
335 ; CHECK-NEXT: Classifying expressions for: @select_x_or_constantexpr
336 ; CHECK-NEXT: %r = select i1 %c, i32 %x, i32 ptrtoint (ptr @constant to i32)
337 ; CHECK-NEXT: --> %r U: full-set S: full-set
338 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_constantexpr
340 %r = select i1 %c, i32 %x, i32 ptrtoint (ptr @constant to i32)
344 define i32 @select_constantexpr_or_x(i1 %c, i32 %x) {
345 ; CHECK-LABEL: 'select_constantexpr_or_x'
346 ; CHECK-NEXT: Classifying expressions for: @select_constantexpr_or_x
347 ; CHECK-NEXT: %r = select i1 %c, i32 ptrtoint (ptr @constant to i32), i32 %x
348 ; CHECK-NEXT: --> %r U: full-set S: full-set
349 ; CHECK-NEXT: Determining loop execution counts for: @select_constantexpr_or_x
351 %r = select i1 %c, i32 ptrtoint (ptr @constant to i32), i32 %x
355 define ptr @select_x_or_nullptr(i1 %c, ptr %x) {
356 ; CHECK-LABEL: 'select_x_or_nullptr'
357 ; CHECK-NEXT: Classifying expressions for: @select_x_or_nullptr
358 ; CHECK-NEXT: %r = select i1 %c, ptr %x, ptr null
359 ; CHECK-NEXT: --> %r U: full-set S: full-set
360 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_nullptr
362 %r = select i1 %c, ptr %x, ptr null
366 define ptr @select_null_or_x(i1 %c, ptr %x) {
367 ; CHECK-LABEL: 'select_null_or_x'
368 ; CHECK-NEXT: Classifying expressions for: @select_null_or_x
369 ; CHECK-NEXT: %r = select i1 %c, ptr null, ptr %x
370 ; CHECK-NEXT: --> %r U: full-set S: full-set
371 ; CHECK-NEXT: Determining loop execution counts for: @select_null_or_x
373 %r = select i1 %c, ptr null, ptr %x
377 define ptr @select_x_or_constantptr(i1 %c, ptr %x) {
378 ; CHECK-LABEL: 'select_x_or_constantptr'
379 ; CHECK-NEXT: Classifying expressions for: @select_x_or_constantptr
380 ; CHECK-NEXT: %r = select i1 %c, ptr %x, ptr @constant
381 ; CHECK-NEXT: --> %r U: full-set S: full-set
382 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_constantptr
384 %r = select i1 %c, ptr %x, ptr @constant
388 define ptr @select_constantptr_or_x(i1 %c, ptr %x) {
389 ; CHECK-LABEL: 'select_constantptr_or_x'
390 ; CHECK-NEXT: Classifying expressions for: @select_constantptr_or_x
391 ; CHECK-NEXT: %r = select i1 %c, ptr @constant, ptr %x
392 ; CHECK-NEXT: --> %r U: full-set S: full-set
393 ; CHECK-NEXT: Determining loop execution counts for: @select_constantptr_or_x
395 %r = select i1 %c, ptr @constant, ptr %x
399 define ptr @select_between_constantptrs(i1 %c, ptr %x) {
400 ; CHECK-LABEL: 'select_between_constantptrs'
401 ; CHECK-NEXT: Classifying expressions for: @select_between_constantptrs
402 ; CHECK-NEXT: %r = select i1 %c, ptr @constant, ptr @another_constant
403 ; CHECK-NEXT: --> %r U: [0,-3) S: [-9223372036854775808,9223372036854775805)
404 ; CHECK-NEXT: Determining loop execution counts for: @select_between_constantptrs
406 %r = select i1 %c, ptr @constant, ptr @another_constant
410 define ptr @tautological_select() {
411 ; CHECK-LABEL: 'tautological_select'
412 ; CHECK-NEXT: Classifying expressions for: @tautological_select
413 ; CHECK-NEXT: %s = select i1 true, ptr @constant, ptr @another_constant
414 ; CHECK-NEXT: --> @constant U: [0,-3) S: [-9223372036854775808,9223372036854775805)
415 ; CHECK-NEXT: %r = getelementptr i8, ptr %s
416 ; CHECK-NEXT: --> @constant U: [0,-3) S: [-9223372036854775808,9223372036854775805)
417 ; CHECK-NEXT: Determining loop execution counts for: @tautological_select
419 %s = select i1 true, ptr @constant, ptr @another_constant
420 %r = getelementptr i8, ptr %s
424 define ptr @tautological_select_like_phi(i32 %tc) {
425 ; CHECK-LABEL: 'tautological_select_like_phi'
426 ; CHECK-NEXT: Classifying expressions for: @tautological_select_like_phi
427 ; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %latch ]
428 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,101) S: [0,101) Exits: 100 LoopDispositions: { %loop: Computable }
429 ; CHECK-NEXT: %r = phi ptr [ @constant, %truebb ], [ @another_constant, %falsebb ]
430 ; CHECK-NEXT: --> @constant U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: @constant LoopDispositions: { %loop: Invariant }
431 ; CHECK-NEXT: %iv.next = add i32 %iv, 1
432 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,102) S: [1,102) Exits: 101 LoopDispositions: { %loop: Computable }
433 ; CHECK-NEXT: Determining loop execution counts for: @tautological_select_like_phi
434 ; CHECK-NEXT: Loop %loop: backedge-taken count is 100
435 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 100
436 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is 100
437 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 100
438 ; CHECK-NEXT: Predicates:
439 ; CHECK-NEXT: Loop %loop: Trip multiple is 101
445 %iv = phi i32[ 0, %entry ], [ %iv.next, %latch ]
446 br i1 true, label %truebb, label %falsebb
455 %r = phi ptr [ @constant, %truebb], [ @another_constant, %falsebb]
456 %iv.next = add i32 %iv, 1
457 %done = icmp eq i32 %iv, 100
458 br i1 %done, label %end, label %loop
464 define i32 @umin_seq_x_y(i32 %x, i32 %y) {
465 ; CHECK-LABEL: 'umin_seq_x_y'
466 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y
467 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %y, i32 %x)
468 ; CHECK-NEXT: --> (%x umin %y) U: full-set S: full-set
469 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %umin
470 ; CHECK-NEXT: --> (%x umin_seq %y) U: full-set S: full-set
471 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y
473 %umin = call i32 @llvm.umin(i32 %y, i32 %x)
474 %x.is.zero = icmp eq i32 %x, 0
475 %r = select i1 %x.is.zero, i32 0, i32 %umin
479 define i32 @umin_seq_x_y_tautological(i32 %x, i32 %y) {
480 ; CHECK-LABEL: 'umin_seq_x_y_tautological'
481 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_tautological
482 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %y, i32 %x)
483 ; CHECK-NEXT: --> (%x umin %y) U: full-set S: full-set
484 ; CHECK-NEXT: %r = select i1 %umin.is.zero, i32 0, i32 %umin
485 ; CHECK-NEXT: --> (%x umin %y) U: full-set S: full-set
486 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_tautological
488 %umin = call i32 @llvm.umin(i32 %y, i32 %x)
489 %umin.is.zero = icmp eq i32 %umin, 0
490 %r = select i1 %umin.is.zero, i32 0, i32 %umin
493 define i32 @umin_seq_x_y_tautological_wrongtype(i32 %x, i32 %y) {
494 ; CHECK-LABEL: 'umin_seq_x_y_tautological_wrongtype'
495 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_tautological_wrongtype
496 ; CHECK-NEXT: %umax = call i32 @llvm.umax.i32(i32 %y, i32 %x)
497 ; CHECK-NEXT: --> (%x umax %y) U: full-set S: full-set
498 ; CHECK-NEXT: %r = select i1 %umax.is.zero, i32 0, i32 %umax
499 ; CHECK-NEXT: --> (%x umax %y) U: full-set S: full-set
500 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_tautological_wrongtype
502 %umax = call i32 @llvm.umax(i32 %y, i32 %x)
503 %umax.is.zero = icmp eq i32 %umax, 0
504 %r = select i1 %umax.is.zero, i32 0, i32 %umax
508 define i32 @umin_seq_x_y_wrongtype0(i32 %x, i32 %y) {
509 ; CHECK-LABEL: 'umin_seq_x_y_wrongtype0'
510 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_wrongtype0
511 ; CHECK-NEXT: %umax = call i32 @llvm.umax.i32(i32 %y, i32 %x)
512 ; CHECK-NEXT: --> (%x umax %y) U: full-set S: full-set
513 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %umax
514 ; CHECK-NEXT: --> %r U: full-set S: full-set
515 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_wrongtype0
517 %umax = call i32 @llvm.umax(i32 %y, i32 %x)
518 %x.is.zero = icmp eq i32 %x, 0
519 %r = select i1 %x.is.zero, i32 0, i32 %umax
522 define i32 @umin_seq_x_y_wrongtype1(i32 %x, i32 %y) {
523 ; CHECK-LABEL: 'umin_seq_x_y_wrongtype1'
524 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_wrongtype1
525 ; CHECK-NEXT: %smax = call i32 @llvm.smax.i32(i32 %y, i32 %x)
526 ; CHECK-NEXT: --> (%x smax %y) U: full-set S: full-set
527 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %smax
528 ; CHECK-NEXT: --> %r U: full-set S: full-set
529 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_wrongtype1
531 %smax = call i32 @llvm.smax(i32 %y, i32 %x)
532 %x.is.zero = icmp eq i32 %x, 0
533 %r = select i1 %x.is.zero, i32 0, i32 %smax
536 define i32 @umin_seq_x_y_wrongtype2(i32 %x, i32 %y) {
537 ; CHECK-LABEL: 'umin_seq_x_y_wrongtype2'
538 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_wrongtype2
539 ; CHECK-NEXT: %smin = call i32 @llvm.smin.i32(i32 %y, i32 %x)
540 ; CHECK-NEXT: --> (%x smin %y) U: full-set S: full-set
541 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %smin
542 ; CHECK-NEXT: --> %r U: full-set S: full-set
543 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_wrongtype2
545 %smin = call i32 @llvm.smin(i32 %y, i32 %x)
546 %x.is.zero = icmp eq i32 %x, 0
547 %r = select i1 %x.is.zero, i32 0, i32 %smin
551 define i32 @umin_seq_x_y_wrongtype3(i32 %x, i32 %y, i32 %z) {
552 ; CHECK-LABEL: 'umin_seq_x_y_wrongtype3'
553 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_wrongtype3
554 ; CHECK-NEXT: %umax = call i32 @llvm.umax.i32(i32 %x, i32 %z)
555 ; CHECK-NEXT: --> (%x umax %z) U: full-set S: full-set
556 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %umax, i32 %y)
557 ; CHECK-NEXT: --> ((%x umax %z) umin %y) U: full-set S: full-set
558 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %umin
559 ; CHECK-NEXT: --> %r U: full-set S: full-set
560 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_wrongtype3
562 %umax = call i32 @llvm.umax(i32 %x, i32 %z)
563 %umin = call i32 @llvm.umin(i32 %umax, i32 %y)
564 %x.is.zero = icmp eq i32 %x, 0
565 %r = select i1 %x.is.zero, i32 0, i32 %umin
569 define i32 @umin_seq_y_x(i32 %x, i32 %y) {
570 ; CHECK-LABEL: 'umin_seq_y_x'
571 ; CHECK-NEXT: Classifying expressions for: @umin_seq_y_x
572 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %x, i32 %y)
573 ; CHECK-NEXT: --> (%x umin %y) U: full-set S: full-set
574 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %umin
575 ; CHECK-NEXT: --> (%y umin_seq %x) U: full-set S: full-set
576 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_y_x
578 %umin = call i32 @llvm.umin(i32 %x, i32 %y)
579 %x.is.zero = icmp eq i32 %y, 0
580 %r = select i1 %x.is.zero, i32 0, i32 %umin
584 define i32 @umin_seq_x_x_y_z(i32 %x, i32 %y, i32 %z) {
585 ; CHECK-LABEL: 'umin_seq_x_x_y_z'
586 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_x_y_z
587 ; CHECK-NEXT: %umin0 = call i32 @llvm.umin.i32(i32 %z, i32 %x)
588 ; CHECK-NEXT: --> (%x umin %z) U: full-set S: full-set
589 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %umin0, i32 %y)
590 ; CHECK-NEXT: --> (%x umin %y umin %z) U: full-set S: full-set
591 ; CHECK-NEXT: %r0 = select i1 %x.is.zero, i32 0, i32 %umin
592 ; CHECK-NEXT: --> (%x umin_seq (%y umin %z)) U: full-set S: full-set
593 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %r0
594 ; CHECK-NEXT: --> (%x umin_seq (%y umin %z)) U: full-set S: full-set
595 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_x_y_z
597 %umin0 = call i32 @llvm.umin(i32 %z, i32 %x)
598 %umin = call i32 @llvm.umin(i32 %umin0, i32 %y)
599 %x.is.zero = icmp eq i32 %x, 0
600 %r0 = select i1 %x.is.zero, i32 0, i32 %umin
601 %r = select i1 %x.is.zero, i32 0, i32 %r0
605 define i32 @umin_seq_x_y_z(i32 %x, i32 %y, i32 %z) {
606 ; CHECK-LABEL: 'umin_seq_x_y_z'
607 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_z
608 ; CHECK-NEXT: %umin0 = call i32 @llvm.umin.i32(i32 %z, i32 %x)
609 ; CHECK-NEXT: --> (%x umin %z) U: full-set S: full-set
610 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %umin0, i32 %y)
611 ; CHECK-NEXT: --> (%x umin %y umin %z) U: full-set S: full-set
612 ; CHECK-NEXT: %r0 = select i1 %y.is.zero, i32 0, i32 %umin
613 ; CHECK-NEXT: --> (%y umin_seq (%x umin %z)) U: full-set S: full-set
614 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %r0
615 ; CHECK-NEXT: --> (%x umin_seq %y umin_seq %z) U: full-set S: full-set
616 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_z
618 %umin0 = call i32 @llvm.umin(i32 %z, i32 %x)
619 %umin = call i32 @llvm.umin(i32 %umin0, i32 %y)
620 %x.is.zero = icmp eq i32 %x, 0
621 %y.is.zero = icmp eq i32 %y, 0
622 %r0 = select i1 %y.is.zero, i32 0, i32 %umin
623 %r = select i1 %x.is.zero, i32 0, i32 %r0
627 define i32 @umin_seq_a_b_c_d(i32 %a, i32 %b, i32 %c, i32 %d) {
628 ; CHECK-LABEL: 'umin_seq_a_b_c_d'
629 ; CHECK-NEXT: Classifying expressions for: @umin_seq_a_b_c_d
630 ; CHECK-NEXT: %umin1 = call i32 @llvm.umin.i32(i32 %c, i32 %d)
631 ; CHECK-NEXT: --> (%c umin %d) U: full-set S: full-set
632 ; CHECK-NEXT: %r1 = select i1 %c.is.zero, i32 0, i32 %umin1
633 ; CHECK-NEXT: --> (%c umin_seq %d) U: full-set S: full-set
634 ; CHECK-NEXT: %umin0 = call i32 @llvm.umin.i32(i32 %a, i32 %b)
635 ; CHECK-NEXT: --> (%a umin %b) U: full-set S: full-set
636 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %umin0, i32 %r1)
637 ; CHECK-NEXT: --> ((%c umin_seq %d) umin %a umin %b) U: full-set S: full-set
638 ; CHECK-NEXT: %r = select i1 %d.is.zero, i32 0, i32 %umin
639 ; CHECK-NEXT: --> (%d umin_seq (%a umin %b umin %c)) U: full-set S: full-set
640 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_a_b_c_d
642 %umin1 = call i32 @llvm.umin(i32 %c, i32 %d)
643 %c.is.zero = icmp eq i32 %c, 0
644 %r1 = select i1 %c.is.zero, i32 0, i32 %umin1
646 %umin0 = call i32 @llvm.umin(i32 %a, i32 %b)
647 %umin = call i32 @llvm.umin(i32 %umin0, i32 %r1)
648 %d.is.zero = icmp eq i32 %d, 0
649 %r = select i1 %d.is.zero, i32 0, i32 %umin
653 define i32 @umin_seq_x_y_zext_both(i8 %x.narrow, i32 %y) {
654 ; CHECK-LABEL: 'umin_seq_x_y_zext_both'
655 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_zext_both
656 ; CHECK-NEXT: %x = zext i8 %x.narrow to i32
657 ; CHECK-NEXT: --> (zext i8 %x.narrow to i32) U: [0,256) S: [0,256)
658 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %y, i32 %x)
659 ; CHECK-NEXT: --> ((zext i8 %x.narrow to i32) umin %y) U: [0,256) S: [0,256)
660 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %umin
661 ; CHECK-NEXT: --> ((zext i8 %x.narrow to i32) umin_seq %y) U: [0,256) S: [0,256)
662 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_zext_both
664 %x = zext i8 %x.narrow to i32
665 %umin = call i32 @llvm.umin(i32 %y, i32 %x)
666 %x.is.zero = icmp eq i32 %x, 0
667 %r = select i1 %x.is.zero, i32 0, i32 %umin
671 define i32 @umin_seq_x_y_zext_in_umin(i8 %x.narrow, i32 %y) {
672 ; CHECK-LABEL: 'umin_seq_x_y_zext_in_umin'
673 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_zext_in_umin
674 ; CHECK-NEXT: %x = zext i8 %x.narrow to i32
675 ; CHECK-NEXT: --> (zext i8 %x.narrow to i32) U: [0,256) S: [0,256)
676 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %y, i32 %x)
677 ; CHECK-NEXT: --> ((zext i8 %x.narrow to i32) umin %y) U: [0,256) S: [0,256)
678 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %umin
679 ; CHECK-NEXT: --> ((zext i8 %x.narrow to i32) umin_seq %y) U: [0,256) S: [0,256)
680 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_zext_in_umin
682 %x = zext i8 %x.narrow to i32
683 %umin = call i32 @llvm.umin(i32 %y, i32 %x)
684 %x.is.zero = icmp eq i8 %x.narrow, 0
685 %r = select i1 %x.is.zero, i32 0, i32 %umin
689 define i8 @umin_seq_x_y_zext_in_iszero(i8 %x, i8 %y) {
690 ; CHECK-LABEL: 'umin_seq_x_y_zext_in_iszero'
691 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_zext_in_iszero
692 ; CHECK-NEXT: %x.wide = zext i8 %x to i32
693 ; CHECK-NEXT: --> (zext i8 %x to i32) U: [0,256) S: [0,256)
694 ; CHECK-NEXT: %umin = call i8 @llvm.umin.i8(i8 %y, i8 %x)
695 ; CHECK-NEXT: --> (%x umin %y) U: full-set S: full-set
696 ; CHECK-NEXT: %r = select i1 %x.is.zero, i8 0, i8 %umin
697 ; CHECK-NEXT: --> (%x umin_seq %y) U: full-set S: full-set
698 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_zext_in_iszero
700 %x.wide = zext i8 %x to i32
701 %umin = call i8 @llvm.umin.i8(i8 %y, i8 %x)
702 %x.is.zero = icmp eq i32 %x.wide, 0
703 %r = select i1 %x.is.zero, i8 0, i8 %umin
707 define i32 @umin_seq_x_y_zext_of_umin(i8 %x, i8 %y) {
708 ; CHECK-LABEL: 'umin_seq_x_y_zext_of_umin'
709 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_zext_of_umin
710 ; CHECK-NEXT: %umin.narrow = call i8 @llvm.umin.i8(i8 %y, i8 %x)
711 ; CHECK-NEXT: --> (%x umin %y) U: full-set S: full-set
712 ; CHECK-NEXT: %umin = zext i8 %umin.narrow to i32
713 ; CHECK-NEXT: --> ((zext i8 %x to i32) umin (zext i8 %y to i32)) U: [0,256) S: [0,256)
714 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %umin
715 ; CHECK-NEXT: --> ((zext i8 %x to i32) umin_seq (zext i8 %y to i32)) U: [0,256) S: [0,256)
716 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_zext_of_umin
718 %umin.narrow = call i8 @llvm.umin.i8(i8 %y, i8 %x)
719 %umin = zext i8 %umin.narrow to i32
720 %x.is.zero = icmp eq i8 %x, 0
721 %r = select i1 %x.is.zero, i32 0, i32 %umin
725 define i32 @umin_seq_x_y_sext_both(i8 %x.narrow, i32 %y) {
726 ; CHECK-LABEL: 'umin_seq_x_y_sext_both'
727 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_sext_both
728 ; CHECK-NEXT: %x = sext i8 %x.narrow to i32
729 ; CHECK-NEXT: --> (sext i8 %x.narrow to i32) U: [-128,128) S: [-128,128)
730 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %y, i32 %x)
731 ; CHECK-NEXT: --> ((sext i8 %x.narrow to i32) umin %y) U: full-set S: full-set
732 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %umin
733 ; CHECK-NEXT: --> ((sext i8 %x.narrow to i32) umin_seq %y) U: full-set S: full-set
734 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_sext_both
736 %x = sext i8 %x.narrow to i32
737 %umin = call i32 @llvm.umin(i32 %y, i32 %x)
738 %x.is.zero = icmp eq i32 %x, 0
739 %r = select i1 %x.is.zero, i32 0, i32 %umin
743 define i32 @umin_seq_x_y_sext_in_umin(i8 %x.narrow, i32 %y) {
744 ; CHECK-LABEL: 'umin_seq_x_y_sext_in_umin'
745 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_sext_in_umin
746 ; CHECK-NEXT: %x = sext i8 %x.narrow to i32
747 ; CHECK-NEXT: --> (sext i8 %x.narrow to i32) U: [-128,128) S: [-128,128)
748 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %y, i32 %x)
749 ; CHECK-NEXT: --> ((sext i8 %x.narrow to i32) umin %y) U: full-set S: full-set
750 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %umin
751 ; CHECK-NEXT: --> %r U: full-set S: full-set
752 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_sext_in_umin
754 %x = sext i8 %x.narrow to i32
755 %umin = call i32 @llvm.umin(i32 %y, i32 %x)
756 %x.is.zero = icmp eq i8 %x.narrow, 0
757 %r = select i1 %x.is.zero, i32 0, i32 %umin
761 define i8 @umin_seq_x_y_sext_in_iszero(i8 %x, i8 %y) {
762 ; CHECK-LABEL: 'umin_seq_x_y_sext_in_iszero'
763 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_sext_in_iszero
764 ; CHECK-NEXT: %x.wide = sext i8 %x to i32
765 ; CHECK-NEXT: --> (sext i8 %x to i32) U: [-128,128) S: [-128,128)
766 ; CHECK-NEXT: %umin = call i8 @llvm.umin.i8(i8 %y, i8 %x)
767 ; CHECK-NEXT: --> (%x umin %y) U: full-set S: full-set
768 ; CHECK-NEXT: %r = select i1 %x.is.zero, i8 0, i8 %umin
769 ; CHECK-NEXT: --> %r U: full-set S: full-set
770 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_sext_in_iszero
772 %x.wide = sext i8 %x to i32
773 %umin = call i8 @llvm.umin.i8(i8 %y, i8 %x)
774 %x.is.zero = icmp eq i32 %x.wide, 0
775 %r = select i1 %x.is.zero, i8 0, i8 %umin
779 define i32 @umin_seq_x_y_sext_of_umin(i8 %x, i8 %y) {
780 ; CHECK-LABEL: 'umin_seq_x_y_sext_of_umin'
781 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_sext_of_umin
782 ; CHECK-NEXT: %umin.narrow = call i8 @llvm.umin.i8(i8 %y, i8 %x)
783 ; CHECK-NEXT: --> (%x umin %y) U: full-set S: full-set
784 ; CHECK-NEXT: %umin = sext i8 %umin.narrow to i32
785 ; CHECK-NEXT: --> (sext i8 (%x umin %y) to i32) U: [-128,128) S: [-128,128)
786 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %umin
787 ; CHECK-NEXT: --> %r U: [-128,128) S: [-128,128)
788 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_sext_of_umin
790 %umin.narrow = call i8 @llvm.umin.i8(i8 %y, i8 %x)
791 %umin = sext i8 %umin.narrow to i32
792 %x.is.zero = icmp eq i8 %x, 0
793 %r = select i1 %x.is.zero, i32 0, i32 %umin
797 define i32 @umin_seq_x_y_zext_vs_sext(i8 %x.narrow, i32 %y) {
798 ; CHECK-LABEL: 'umin_seq_x_y_zext_vs_sext'
799 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_zext_vs_sext
800 ; CHECK-NEXT: %x.zext = zext i8 %x.narrow to i32
801 ; CHECK-NEXT: --> (zext i8 %x.narrow to i32) U: [0,256) S: [0,256)
802 ; CHECK-NEXT: %x.sext = sext i8 %x.narrow to i32
803 ; CHECK-NEXT: --> (sext i8 %x.narrow to i32) U: [-128,128) S: [-128,128)
804 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %y, i32 %x.zext)
805 ; CHECK-NEXT: --> ((zext i8 %x.narrow to i32) umin %y) U: [0,256) S: [0,256)
806 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %umin
807 ; CHECK-NEXT: --> %r U: [0,256) S: [0,256)
808 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_zext_vs_sext
810 %x.zext = zext i8 %x.narrow to i32
811 %x.sext = sext i8 %x.narrow to i32
812 %umin = call i32 @llvm.umin(i32 %y, i32 %x.zext)
813 %x.is.zero = icmp eq i32 %x.sext, 0
814 %r = select i1 %x.is.zero, i32 0, i32 %umin
817 define i32 @umin_seq_x_y_sext_vs_zext(i8 %x.narrow, i32 %y) {
818 ; CHECK-LABEL: 'umin_seq_x_y_sext_vs_zext'
819 ; CHECK-NEXT: Classifying expressions for: @umin_seq_x_y_sext_vs_zext
820 ; CHECK-NEXT: %x.zext = zext i8 %x.narrow to i32
821 ; CHECK-NEXT: --> (zext i8 %x.narrow to i32) U: [0,256) S: [0,256)
822 ; CHECK-NEXT: %x.sext = sext i8 %x.narrow to i32
823 ; CHECK-NEXT: --> (sext i8 %x.narrow to i32) U: [-128,128) S: [-128,128)
824 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %y, i32 %x.sext)
825 ; CHECK-NEXT: --> ((sext i8 %x.narrow to i32) umin %y) U: full-set S: full-set
826 ; CHECK-NEXT: %r = select i1 %x.is.zero, i32 0, i32 %umin
827 ; CHECK-NEXT: --> %r U: full-set S: full-set
828 ; CHECK-NEXT: Determining loop execution counts for: @umin_seq_x_y_sext_vs_zext
830 %x.zext = zext i8 %x.narrow to i32
831 %x.sext = sext i8 %x.narrow to i32
832 %umin = call i32 @llvm.umin(i32 %y, i32 %x.sext)
833 %x.is.zero = icmp eq i32 %x.zext, 0
834 %r = select i1 %x.is.zero, i32 0, i32 %umin
838 define i32 @select_x_or_zero_expanded(i1 %c, i32 %x) {
839 ; CHECK-LABEL: 'select_x_or_zero_expanded'
840 ; CHECK-NEXT: Classifying expressions for: @select_x_or_zero_expanded
841 ; CHECK-NEXT: %c.splat = sext i1 %c to i32
842 ; CHECK-NEXT: --> (sext i1 %c to i32) U: [-1,1) S: [-1,1)
843 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %c.splat, i32 %x)
844 ; CHECK-NEXT: --> ((sext i1 %c to i32) umin %x) U: full-set S: full-set
845 ; CHECK-NEXT: %r = select i1 %v0.is.zero, i32 0, i32 %umin
846 ; CHECK-NEXT: --> ((sext i1 %c to i32) umin_seq %x) U: full-set S: full-set
847 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_zero_expanded
849 %c.splat = sext i1 %c to i32
850 %umin = call i32 @llvm.umin(i32 %c.splat, i32 %x)
851 %v0.is.zero = icmp eq i32 %c.splat, 0
852 %r = select i1 %v0.is.zero, i32 0, i32 %umin
856 define i32 @select_zero_or_x_expanded(i1 %c, i32 %y) {
857 ; CHECK-LABEL: 'select_zero_or_x_expanded'
858 ; CHECK-NEXT: Classifying expressions for: @select_zero_or_x_expanded
859 ; CHECK-NEXT: %c.splat = sext i1 %c to i32
860 ; CHECK-NEXT: --> (sext i1 %c to i32) U: [-1,1) S: [-1,1)
861 ; CHECK-NEXT: %c.splat.not = xor i32 %c.splat, -1
862 ; CHECK-NEXT: --> (-1 + (-1 * (sext i1 %c to i32))<nsw>)<nsw> U: [-1,1) S: [-1,1)
863 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %c.splat.not, i32 %y)
864 ; CHECK-NEXT: --> ((-1 + (-1 * (sext i1 %c to i32))<nsw>)<nsw> umin %y) U: full-set S: full-set
865 ; CHECK-NEXT: %r = select i1 %v0.is.zero, i32 0, i32 %umin
866 ; CHECK-NEXT: --> ((-1 + (-1 * (sext i1 %c to i32))<nsw>)<nsw> umin_seq %y) U: full-set S: full-set
867 ; CHECK-NEXT: Determining loop execution counts for: @select_zero_or_x_expanded
869 %c.splat = sext i1 %c to i32
870 %c.splat.not = xor i32 %c.splat, -1
871 %umin = call i32 @llvm.umin(i32 %c.splat.not, i32 %y)
872 %v0.is.zero = icmp eq i32 %c.splat.not, 0
873 %r = select i1 %v0.is.zero, i32 0, i32 %umin
876 define i32 @select_zero_or_x_expanded2(i1 %c, i32 %y) {
877 ; CHECK-LABEL: 'select_zero_or_x_expanded2'
878 ; CHECK-NEXT: Classifying expressions for: @select_zero_or_x_expanded2
879 ; CHECK-NEXT: %c.not = xor i1 %c, true
880 ; CHECK-NEXT: --> (true + %c) U: full-set S: full-set
881 ; CHECK-NEXT: %c.not.splat = sext i1 %c.not to i32
882 ; CHECK-NEXT: --> (sext i1 (true + %c) to i32) U: [-1,1) S: [-1,1)
883 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %c.not.splat, i32 %y)
884 ; CHECK-NEXT: --> ((sext i1 (true + %c) to i32) umin %y) U: full-set S: full-set
885 ; CHECK-NEXT: %r = select i1 %v0.is.zero, i32 0, i32 %umin
886 ; CHECK-NEXT: --> ((sext i1 (true + %c) to i32) umin_seq %y) U: full-set S: full-set
887 ; CHECK-NEXT: Determining loop execution counts for: @select_zero_or_x_expanded2
889 %c.not = xor i1 %c, -1
890 %c.not.splat = sext i1 %c.not to i32
891 %umin = call i32 @llvm.umin(i32 %c.not.splat, i32 %y)
892 %v0.is.zero = icmp eq i32 %c.not.splat, 0
893 %r = select i1 %v0.is.zero, i32 0, i32 %umin
897 define i32 @select_x_or_constant_expanded(i1 %c, i32 %x) {
898 ; CHECK-LABEL: 'select_x_or_constant_expanded'
899 ; CHECK-NEXT: Classifying expressions for: @select_x_or_constant_expanded
900 ; CHECK-NEXT: %c.splat = sext i1 %c to i32
901 ; CHECK-NEXT: --> (sext i1 %c to i32) U: [-1,1) S: [-1,1)
902 ; CHECK-NEXT: %x.off = sub i32 %x, 42
903 ; CHECK-NEXT: --> (-42 + %x) U: full-set S: full-set
904 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %c.splat, i32 %x.off)
905 ; CHECK-NEXT: --> ((sext i1 %c to i32) umin (-42 + %x)) U: full-set S: full-set
906 ; CHECK-NEXT: %r.off = select i1 %v0.is.zero, i32 0, i32 %umin
907 ; CHECK-NEXT: --> ((sext i1 %c to i32) umin_seq (-42 + %x)) U: full-set S: full-set
908 ; CHECK-NEXT: %r = add i32 %r.off, 42
909 ; CHECK-NEXT: --> (42 + ((sext i1 %c to i32) umin_seq (-42 + %x))) U: full-set S: full-set
910 ; CHECK-NEXT: Determining loop execution counts for: @select_x_or_constant_expanded
912 %c.splat = sext i1 %c to i32
913 %x.off = sub i32 %x, 42
914 %umin = call i32 @llvm.umin(i32 %c.splat, i32 %x.off)
915 %v0.is.zero = icmp eq i32 %c.splat, 0
916 %r.off = select i1 %v0.is.zero, i32 0, i32 %umin
917 %r = add i32 %r.off, 42
921 define i32 @select_constant_or_y_expanded(i1 %c, i32 %y) {
922 ; CHECK-LABEL: 'select_constant_or_y_expanded'
923 ; CHECK-NEXT: Classifying expressions for: @select_constant_or_y_expanded
924 ; CHECK-NEXT: %c.splat = sext i1 %c to i32
925 ; CHECK-NEXT: --> (sext i1 %c to i32) U: [-1,1) S: [-1,1)
926 ; CHECK-NEXT: %c.splat.not = xor i32 %c.splat, -1
927 ; CHECK-NEXT: --> (-1 + (-1 * (sext i1 %c to i32))<nsw>)<nsw> U: [-1,1) S: [-1,1)
928 ; CHECK-NEXT: %y.off = sub i32 %y, 42
929 ; CHECK-NEXT: --> (-42 + %y) U: full-set S: full-set
930 ; CHECK-NEXT: %umin = call i32 @llvm.umin.i32(i32 %c.splat.not, i32 %y.off)
931 ; CHECK-NEXT: --> ((-42 + %y) umin (-1 + (-1 * (sext i1 %c to i32))<nsw>)<nsw>) U: full-set S: full-set
932 ; CHECK-NEXT: %r.off = select i1 %v0.is.zero, i32 0, i32 %umin
933 ; CHECK-NEXT: --> ((-1 + (-1 * (sext i1 %c to i32))<nsw>)<nsw> umin_seq (-42 + %y)) U: full-set S: full-set
934 ; CHECK-NEXT: %r = add i32 %r.off, 42
935 ; CHECK-NEXT: --> (42 + ((-1 + (-1 * (sext i1 %c to i32))<nsw>)<nsw> umin_seq (-42 + %y))) U: full-set S: full-set
936 ; CHECK-NEXT: Determining loop execution counts for: @select_constant_or_y_expanded
938 %c.splat = sext i1 %c to i32
939 %c.splat.not = xor i32 %c.splat, -1
940 %y.off = sub i32 %y, 42
941 %umin = call i32 @llvm.umin(i32 %c.splat.not, i32 %y.off)
942 %v0.is.zero = icmp eq i32 %c.splat.not, 0
943 %r.off = select i1 %v0.is.zero, i32 0, i32 %umin
944 %r = add i32 %r.off, 42
948 declare i8 @llvm.umin.i8(i8, i8)
949 declare i8 @llvm.umax.i8(i8, i8)
950 declare i8 @llvm.smin.i8(i8, i8)
951 declare i8 @llvm.smax.i8(i8, i8)
953 declare i32 @llvm.umin(i32, i32)
954 declare i32 @llvm.umax(i32, i32)
955 declare i32 @llvm.smin(i32, i32)
956 declare i32 @llvm.smax(i32, i32)