1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
4 ; TODO: the instructions with poison operands should return poison
6 declare i81 @llvm.smax.i81(i81, i81)
7 declare i8 @llvm.smax.i8(i8, i8)
8 declare <2 x i8> @llvm.smax.v2i8(<2 x i8>, <2 x i8>)
9 declare i3 @llvm.smin.i3(i3, i3)
10 declare i8 @llvm.smin.i8(i8, i8)
11 declare <2 x i8> @llvm.smin.v2i8(<2 x i8>, <2 x i8>)
12 declare i8 @llvm.umax.i8(i8, i8)
13 declare <2 x i8> @llvm.umax.v2i8(<2 x i8>, <2 x i8>)
14 declare i8 @llvm.umin.i8(i8, i8)
15 declare <2 x i8> @llvm.umin.v2i8(<2 x i8>, <2 x i8>)
16 declare void @llvm.assume(i1)
18 @g = external dso_local global [9 x i32], align 4
20 define i8 @constexpr_maxvalue() {
21 ; CHECK-LABEL: @constexpr_maxvalue(
22 ; CHECK-NEXT: ret i8 ptrtoint (ptr @g to i8)
24 %umin = call i8 @llvm.umin.i8(i8 255, i8 ptrtoint (ptr @g to i8))
28 define i8 @constexpr_maxvalue_commute() {
29 ; CHECK-LABEL: @constexpr_maxvalue_commute(
30 ; CHECK-NEXT: ret i8 ptrtoint (ptr @g to i8)
32 %umin = call i8 @llvm.umin.i8(i8 ptrtoint (ptr @g to i8), i8 255)
36 define i81 @smax_sameval(i81 %x) {
37 ; CHECK-LABEL: @smax_sameval(
38 ; CHECK-NEXT: ret i81 [[X:%.*]]
40 %r = call i81 @llvm.smax.i81(i81 %x, i81 %x)
44 define i3 @smin_sameval(i3 %x) {
45 ; CHECK-LABEL: @smin_sameval(
46 ; CHECK-NEXT: ret i3 [[X:%.*]]
48 %r = call i3 @llvm.smin.i3(i3 %x, i3 %x)
52 define <2 x i8> @umax_sameval(<2 x i8> %x) {
53 ; CHECK-LABEL: @umax_sameval(
54 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
56 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> %x, <2 x i8> %x)
60 define <2 x i8> @umin_sameval(<2 x i8> %x) {
61 ; CHECK-LABEL: @umin_sameval(
62 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
64 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> %x)
68 define i81 @smax_undef(i81 %x) {
69 ; CHECK-LABEL: @smax_undef(
70 ; CHECK-NEXT: ret i81 1208925819614629174706175
72 %r = call i81 @llvm.smax.i81(i81 undef, i81 %x)
76 define i81 @smax_poison(i81 %x) {
77 ; CHECK-LABEL: @smax_poison(
78 ; CHECK-NEXT: ret i81 1208925819614629174706175
80 %r = call i81 @llvm.smax.i81(i81 poison, i81 %x)
84 define i3 @smin_undef(i3 %x) {
85 ; CHECK-LABEL: @smin_undef(
86 ; CHECK-NEXT: ret i3 -4
88 %r = call i3 @llvm.smin.i3(i3 %x, i3 undef)
92 define i3 @smin_poison(i3 %x) {
93 ; CHECK-LABEL: @smin_poison(
94 ; CHECK-NEXT: ret i3 -4
96 %r = call i3 @llvm.smin.i3(i3 %x, i3 poison)
100 define <2 x i8> @umax_undef(<2 x i8> %x) {
101 ; CHECK-LABEL: @umax_undef(
102 ; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
104 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> undef, <2 x i8> %x)
108 define <2 x i8> @umax_poison(<2 x i8> %x) {
109 ; CHECK-LABEL: @umax_poison(
110 ; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
112 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> poison, <2 x i8> %x)
116 define <2 x i8> @umin_undef(<2 x i8> %x) {
117 ; CHECK-LABEL: @umin_undef(
118 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
120 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> undef)
124 define <2 x i8> @umin_poison(<2 x i8> %x) {
125 ; CHECK-LABEL: @umin_poison(
126 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
128 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> poison)
132 define i8 @smax_maxval(i8 %x) {
133 ; CHECK-LABEL: @smax_maxval(
134 ; CHECK-NEXT: ret i8 127
136 %r = call i8 @llvm.smax.i8(i8 %x, i8 127)
140 define <2 x i8> @smax_maxval_commute(<2 x i8> %x) {
141 ; CHECK-LABEL: @smax_maxval_commute(
142 ; CHECK-NEXT: ret <2 x i8> <i8 127, i8 127>
144 %r = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 127, i8 127>, <2 x i8> %x)
148 define i8 @smin_minval(i8 %x) {
149 ; CHECK-LABEL: @smin_minval(
150 ; CHECK-NEXT: ret i8 -128
152 %r = call i8 @llvm.smin.i8(i8 -128, i8 %x)
156 define <2 x i8> @smin_minval_commute(<2 x i8> %x) {
157 ; CHECK-LABEL: @smin_minval_commute(
158 ; CHECK-NEXT: ret <2 x i8> <i8 -128, i8 -128>
160 %r = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> <i8 -128, i8 -128>)
164 define i8 @umax_maxval(i8 %x) {
165 ; CHECK-LABEL: @umax_maxval(
166 ; CHECK-NEXT: ret i8 -1
168 %r = call i8 @llvm.umax.i8(i8 %x, i8 255)
172 define <2 x i8> @umax_maxval_commute(<2 x i8> %x) {
173 ; CHECK-LABEL: @umax_maxval_commute(
174 ; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
176 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 255, i8 255>, <2 x i8> %x)
180 define i8 @umin_minval(i8 %x) {
181 ; CHECK-LABEL: @umin_minval(
182 ; CHECK-NEXT: ret i8 0
184 %r = call i8 @llvm.umin.i8(i8 0, i8 %x)
188 define <2 x i8> @umin_minval_commute(<2 x i8> %x) {
189 ; CHECK-LABEL: @umin_minval_commute(
190 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
192 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> zeroinitializer)
196 define i8 @smax_minval(i8 %x) {
197 ; CHECK-LABEL: @smax_minval(
198 ; CHECK-NEXT: ret i8 [[X:%.*]]
200 %r = call i8 @llvm.smax.i8(i8 %x, i8 -128)
204 define <2 x i8> @smax_minval_commute(<2 x i8> %x) {
205 ; CHECK-LABEL: @smax_minval_commute(
206 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
208 %r = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 -128, i8 -128>, <2 x i8> %x)
212 define i8 @smin_maxval(i8 %x) {
213 ; CHECK-LABEL: @smin_maxval(
214 ; CHECK-NEXT: ret i8 [[X:%.*]]
216 %r = call i8 @llvm.smin.i8(i8 127, i8 %x)
220 define <2 x i8> @smin_maxval_commute(<2 x i8> %x) {
221 ; CHECK-LABEL: @smin_maxval_commute(
222 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
224 %r = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> <i8 127, i8 127>)
228 define i8 @umax_minval(i8 %x) {
229 ; CHECK-LABEL: @umax_minval(
230 ; CHECK-NEXT: ret i8 [[X:%.*]]
232 %r = call i8 @llvm.umax.i8(i8 %x, i8 0)
236 define <2 x i8> @umax_minval_commute(<2 x i8> %x) {
237 ; CHECK-LABEL: @umax_minval_commute(
238 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
240 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> zeroinitializer, <2 x i8> %x)
244 define i8 @umin_maxval(i8 %x) {
245 ; CHECK-LABEL: @umin_maxval(
246 ; CHECK-NEXT: ret i8 [[X:%.*]]
248 %r = call i8 @llvm.umin.i8(i8 255, i8 %x)
252 define <2 x i8> @umin_maxval_commute(<2 x i8> %x) {
253 ; CHECK-LABEL: @umin_maxval_commute(
254 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
256 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> <i8 255, i8 255>)
260 define <2 x i8> @smax_maxval_partial_undef(<2 x i8> %x) {
261 ; CHECK-LABEL: @smax_maxval_partial_undef(
262 ; CHECK-NEXT: ret <2 x i8> <i8 127, i8 127>
264 %r = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 undef, i8 127>, <2 x i8> %x)
268 define <2 x i8> @smin_minval_partial_undef(<2 x i8> %x) {
269 ; CHECK-LABEL: @smin_minval_partial_undef(
270 ; CHECK-NEXT: ret <2 x i8> <i8 -128, i8 -128>
272 %r = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> <i8 -128, i8 undef>)
276 define <2 x i8> @umax_maxval_partial_undef(<2 x i8> %x) {
277 ; CHECK-LABEL: @umax_maxval_partial_undef(
278 ; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
280 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 255, i8 undef>, <2 x i8> %x)
284 define <2 x i8> @umin_minval_partial_undef(<2 x i8> %x) {
285 ; CHECK-LABEL: @umin_minval_partial_undef(
286 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
288 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> <i8 undef, i8 0>)
292 define <2 x i8> @smax_minval_partial_undef(<2 x i8> %x) {
293 ; CHECK-LABEL: @smax_minval_partial_undef(
294 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
296 %r = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 undef, i8 -128>, <2 x i8> %x)
300 define <2 x i8> @smin_maxval_partial_undef(<2 x i8> %x) {
301 ; CHECK-LABEL: @smin_maxval_partial_undef(
302 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
304 %r = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> <i8 undef, i8 127>)
308 define <2 x i8> @umax_minval_partial_undef(<2 x i8> %x) {
309 ; CHECK-LABEL: @umax_minval_partial_undef(
310 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
312 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 0, i8 undef>, <2 x i8> %x)
316 define <2 x i8> @umin_maxval_partial_undef(<2 x i8> %x) {
317 ; CHECK-LABEL: @umin_maxval_partial_undef(
318 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
320 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> <i8 255, i8 undef>)
324 define i8 @umax_umax(i8 %x, i8 %y) {
325 ; CHECK-LABEL: @umax_umax(
326 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
327 ; CHECK-NEXT: ret i8 [[M]]
329 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
330 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %m)
334 define i8 @umax_umax_commute1(i8 %x, i8 %y) {
335 ; CHECK-LABEL: @umax_umax_commute1(
336 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
337 ; CHECK-NEXT: ret i8 [[M]]
339 %m = call i8 @llvm.umax.i8(i8 %y, i8 %x)
340 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %m)
344 define i8 @umax_umax_commute2(i8 %x, i8 %y) {
345 ; CHECK-LABEL: @umax_umax_commute2(
346 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
347 ; CHECK-NEXT: ret i8 [[M]]
349 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
350 %m2 = call i8 @llvm.umax.i8(i8 %m, i8 %x)
354 define <2 x i8> @umax_umax_commute3(<2 x i8> %x, <2 x i8> %y) {
355 ; CHECK-LABEL: @umax_umax_commute3(
356 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.umax.v2i8(<2 x i8> [[Y:%.*]], <2 x i8> [[X:%.*]])
357 ; CHECK-NEXT: ret <2 x i8> [[M]]
359 %m = call <2 x i8> @llvm.umax.v2i8(<2 x i8> %y, <2 x i8> %x)
360 %m2 = call <2 x i8> @llvm.umax.v2i8(<2 x i8> %m, <2 x i8> %x)
364 define i8 @umin_umin(i8 %x, i8 %y) {
365 ; CHECK-LABEL: @umin_umin(
366 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
367 ; CHECK-NEXT: ret i8 [[M]]
369 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
370 %m2 = call i8 @llvm.umin.i8(i8 %x, i8 %m)
374 define i8 @umin_umin_commute1(i8 %x, i8 %y) {
375 ; CHECK-LABEL: @umin_umin_commute1(
376 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
377 ; CHECK-NEXT: ret i8 [[M]]
379 %m = call i8 @llvm.umin.i8(i8 %y, i8 %x)
380 %m2 = call i8 @llvm.umin.i8(i8 %x, i8 %m)
384 define <2 x i8> @umin_umin_commute2(<2 x i8> %x, <2 x i8> %y) {
385 ; CHECK-LABEL: @umin_umin_commute2(
386 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.umin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]])
387 ; CHECK-NEXT: ret <2 x i8> [[M]]
389 %m = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> %y)
390 %m2 = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %m, <2 x i8> %x)
394 define i8 @umin_umin_commute3(i8 %x, i8 %y) {
395 ; CHECK-LABEL: @umin_umin_commute3(
396 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
397 ; CHECK-NEXT: ret i8 [[M]]
399 %m = call i8 @llvm.umin.i8(i8 %y, i8 %x)
400 %m2 = call i8 @llvm.umin.i8(i8 %m, i8 %x)
404 define i8 @smax_smax(i8 %x, i8 %y) {
405 ; CHECK-LABEL: @smax_smax(
406 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
407 ; CHECK-NEXT: ret i8 [[M]]
409 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
410 %m2 = call i8 @llvm.smax.i8(i8 %x, i8 %m)
414 define <2 x i8> @smax_smax_commute1(<2 x i8> %x, <2 x i8> %y) {
415 ; CHECK-LABEL: @smax_smax_commute1(
416 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.smax.v2i8(<2 x i8> [[Y:%.*]], <2 x i8> [[X:%.*]])
417 ; CHECK-NEXT: ret <2 x i8> [[M]]
419 %m = call <2 x i8> @llvm.smax.v2i8(<2 x i8> %y, <2 x i8> %x)
420 %m2 = call <2 x i8> @llvm.smax.v2i8(<2 x i8> %x, <2 x i8> %m)
424 define i8 @smax_smax_commute2(i8 %x, i8 %y) {
425 ; CHECK-LABEL: @smax_smax_commute2(
426 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
427 ; CHECK-NEXT: ret i8 [[M]]
429 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
430 %m2 = call i8 @llvm.smax.i8(i8 %m, i8 %x)
434 define i8 @smax_smax_commute3(i8 %x, i8 %y) {
435 ; CHECK-LABEL: @smax_smax_commute3(
436 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
437 ; CHECK-NEXT: ret i8 [[M]]
439 %m = call i8 @llvm.smax.i8(i8 %y, i8 %x)
440 %m2 = call i8 @llvm.smax.i8(i8 %m, i8 %x)
444 define <2 x i8> @smin_smin(<2 x i8> %x, <2 x i8> %y) {
445 ; CHECK-LABEL: @smin_smin(
446 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.smin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]])
447 ; CHECK-NEXT: ret <2 x i8> [[M]]
449 %m = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> %y)
450 %m2 = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> %m)
454 define i8 @smin_smin_commute1(i8 %x, i8 %y) {
455 ; CHECK-LABEL: @smin_smin_commute1(
456 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
457 ; CHECK-NEXT: ret i8 [[M]]
459 %m = call i8 @llvm.smin.i8(i8 %y, i8 %x)
460 %m2 = call i8 @llvm.smin.i8(i8 %x, i8 %m)
464 define i8 @smin_smin_commute2(i8 %x, i8 %y) {
465 ; CHECK-LABEL: @smin_smin_commute2(
466 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
467 ; CHECK-NEXT: ret i8 [[M]]
469 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
470 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 %x)
474 define i8 @smin_smin_commute3(i8 %x, i8 %y) {
475 ; CHECK-LABEL: @smin_smin_commute3(
476 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
477 ; CHECK-NEXT: ret i8 [[M]]
479 %m = call i8 @llvm.smin.i8(i8 %y, i8 %x)
480 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 %x)
484 define i8 @umax_umin(i8 %x, i8 %y) {
485 ; CHECK-LABEL: @umax_umin(
486 ; CHECK-NEXT: ret i8 [[X:%.*]]
488 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
489 %m2 = call i8 @llvm.umin.i8(i8 %x, i8 %m)
493 define i8 @umax_umin_commute1(i8 %x, i8 %y) {
494 ; CHECK-LABEL: @umax_umin_commute1(
495 ; CHECK-NEXT: ret i8 [[X:%.*]]
497 %m = call i8 @llvm.umax.i8(i8 %y, i8 %x)
498 %m2 = call i8 @llvm.umin.i8(i8 %x, i8 %m)
502 define i8 @umax_umin_commute2(i8 %x, i8 %y) {
503 ; CHECK-LABEL: @umax_umin_commute2(
504 ; CHECK-NEXT: ret i8 [[X:%.*]]
506 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
507 %m2 = call i8 @llvm.umin.i8(i8 %m, i8 %x)
511 define <2 x i8> @umax_umin_commute3(<2 x i8> %x, <2 x i8> %y) {
512 ; CHECK-LABEL: @umax_umin_commute3(
513 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
515 %m = call <2 x i8> @llvm.umax.v2i8(<2 x i8> %y, <2 x i8> %x)
516 %m2 = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %m, <2 x i8> %x)
520 define i8 @umin_umax(i8 %x, i8 %y) {
521 ; CHECK-LABEL: @umin_umax(
522 ; CHECK-NEXT: ret i8 [[X:%.*]]
524 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
525 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %m)
529 define i8 @umin_umax_commute1(i8 %x, i8 %y) {
530 ; CHECK-LABEL: @umin_umax_commute1(
531 ; CHECK-NEXT: ret i8 [[X:%.*]]
533 %m = call i8 @llvm.umin.i8(i8 %y, i8 %x)
534 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %m)
538 define <2 x i8> @umin_umax_commute2(<2 x i8> %x, <2 x i8> %y) {
539 ; CHECK-LABEL: @umin_umax_commute2(
540 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
542 %m = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> %y)
543 %m2 = call <2 x i8> @llvm.umax.v2i8(<2 x i8> %m, <2 x i8> %x)
547 define i8 @umin_umax_commute3(i8 %x, i8 %y) {
548 ; CHECK-LABEL: @umin_umax_commute3(
549 ; CHECK-NEXT: ret i8 [[X:%.*]]
551 %m = call i8 @llvm.umin.i8(i8 %y, i8 %x)
552 %m2 = call i8 @llvm.umax.i8(i8 %m, i8 %x)
556 define i8 @smax_smin(i8 %x, i8 %y) {
557 ; CHECK-LABEL: @smax_smin(
558 ; CHECK-NEXT: ret i8 [[X:%.*]]
560 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
561 %m2 = call i8 @llvm.smin.i8(i8 %x, i8 %m)
565 define <2 x i8> @smax_smin_commute1(<2 x i8> %x, <2 x i8> %y) {
566 ; CHECK-LABEL: @smax_smin_commute1(
567 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
569 %m = call <2 x i8> @llvm.smax.v2i8(<2 x i8> %y, <2 x i8> %x)
570 %m2 = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> %m)
574 define i8 @smax_smin_commute2(i8 %x, i8 %y) {
575 ; CHECK-LABEL: @smax_smin_commute2(
576 ; CHECK-NEXT: ret i8 [[X:%.*]]
578 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
579 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 %x)
583 define i8 @smax_smin_commute3(i8 %x, i8 %y) {
584 ; CHECK-LABEL: @smax_smin_commute3(
585 ; CHECK-NEXT: ret i8 [[X:%.*]]
587 %m = call i8 @llvm.smax.i8(i8 %y, i8 %x)
588 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 %x)
592 define <2 x i8> @smin_smax(<2 x i8> %x, <2 x i8> %y) {
593 ; CHECK-LABEL: @smin_smax(
594 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
596 %m = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> %y)
597 %m2 = call <2 x i8> @llvm.smax.v2i8(<2 x i8> %x, <2 x i8> %m)
601 define i8 @smin_smax_commute1(i8 %x, i8 %y) {
602 ; CHECK-LABEL: @smin_smax_commute1(
603 ; CHECK-NEXT: ret i8 [[X:%.*]]
605 %m = call i8 @llvm.smin.i8(i8 %y, i8 %x)
606 %m2 = call i8 @llvm.smax.i8(i8 %x, i8 %m)
610 define i8 @smin_smax_commute2(i8 %x, i8 %y) {
611 ; CHECK-LABEL: @smin_smax_commute2(
612 ; CHECK-NEXT: ret i8 [[X:%.*]]
614 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
615 %m2 = call i8 @llvm.smax.i8(i8 %m, i8 %x)
619 define i8 @smin_smax_commute3(i8 %x, i8 %y) {
620 ; CHECK-LABEL: @smin_smax_commute3(
621 ; CHECK-NEXT: ret i8 [[X:%.*]]
623 %m = call i8 @llvm.smin.i8(i8 %y, i8 %x)
624 %m2 = call i8 @llvm.smax.i8(i8 %m, i8 %x)
628 ; Negative test - mismatched intrinsics.
630 define i8 @smax_umin(i8 %x, i8 %y) {
631 ; CHECK-LABEL: @smax_umin(
632 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
633 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[M]], i8 [[X]])
634 ; CHECK-NEXT: ret i8 [[M2]]
636 %m = call i8 @llvm.smax.i8(i8 %y, i8 %x)
637 %m2 = call i8 @llvm.umin.i8(i8 %m, i8 %x)
641 ; Negative test - mismatched intrinsics.
643 define i8 @smax_umax(i8 %x, i8 %y) {
644 ; CHECK-LABEL: @smax_umax(
645 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
646 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[M]], i8 [[X]])
647 ; CHECK-NEXT: ret i8 [[M2]]
649 %m = call i8 @llvm.smax.i8(i8 %y, i8 %x)
650 %m2 = call i8 @llvm.umax.i8(i8 %m, i8 %x)
654 ; Negative test - mismatched intrinsics.
656 define i8 @umax_smin(i8 %x, i8 %y) {
657 ; CHECK-LABEL: @umax_smin(
658 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
659 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[M]], i8 [[X]])
660 ; CHECK-NEXT: ret i8 [[M2]]
662 %m = call i8 @llvm.umax.i8(i8 %y, i8 %x)
663 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 %x)
667 ; Negative test - mismatched intrinsics.
669 define i8 @umin_smin(i8 %x, i8 %y) {
670 ; CHECK-LABEL: @umin_smin(
671 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
672 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[M]], i8 [[X]])
673 ; CHECK-NEXT: ret i8 [[M2]]
675 %m = call i8 @llvm.umin.i8(i8 %y, i8 %x)
676 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 %x)
680 define i8 @umax_umax_constants(i8 %x) {
681 ; CHECK-LABEL: @umax_umax_constants(
682 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 9)
683 ; CHECK-NEXT: ret i8 [[M]]
685 %m = call i8 @llvm.umax.i8(i8 %x, i8 9)
686 %m2 = call i8 @llvm.umax.i8(i8 7, i8 %m)
690 define i8 @umax_umax_constants_commute1(i8 %x) {
691 ; CHECK-LABEL: @umax_umax_constants_commute1(
692 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 -128, i8 [[X:%.*]])
693 ; CHECK-NEXT: ret i8 [[M]]
695 %m = call i8 @llvm.umax.i8(i8 128, i8 %x)
696 %m2 = call i8 @llvm.umax.i8(i8 7, i8 %m)
700 define i8 @umax_umax_constants_commute2(i8 %x) {
701 ; CHECK-LABEL: @umax_umax_constants_commute2(
702 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 -56)
703 ; CHECK-NEXT: ret i8 [[M]]
705 %m = call i8 @llvm.umax.i8(i8 %x, i8 200)
706 %m2 = call i8 @llvm.umax.i8(i8 %m, i8 127)
710 define <2 x i8> @umax_umax_constants_commute3(<2 x i8> %x) {
711 ; CHECK-LABEL: @umax_umax_constants_commute3(
712 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 -2, i8 -2>, <2 x i8> [[X:%.*]])
713 ; CHECK-NEXT: ret <2 x i8> [[M]]
715 %m = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 254, i8 254>, <2 x i8> %x)
716 %m2 = call <2 x i8> @llvm.umax.v2i8(<2 x i8> %m, <2 x i8> <i8 128, i8 128>)
720 define i8 @umin_umin_constants(i8 %x) {
721 ; CHECK-LABEL: @umin_umin_constants(
722 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 7)
723 ; CHECK-NEXT: ret i8 [[M]]
725 %m = call i8 @llvm.umin.i8(i8 %x, i8 7)
726 %m2 = call i8 @llvm.umin.i8(i8 9, i8 %m)
730 define i8 @umin_umin_constants_commute1(i8 %x) {
731 ; CHECK-LABEL: @umin_umin_constants_commute1(
732 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 7, i8 [[X:%.*]])
733 ; CHECK-NEXT: ret i8 [[M]]
735 %m = call i8 @llvm.umin.i8(i8 7, i8 %x)
736 %m2 = call i8 @llvm.umin.i8(i8 128, i8 %m)
740 define <2 x i8> @umin_umin_constants_commute2(<2 x i8> %x) {
741 ; CHECK-LABEL: @umin_umin_constants_commute2(
742 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.umin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> <i8 127, i8 127>)
743 ; CHECK-NEXT: ret <2 x i8> [[M]]
745 %m = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> <i8 127, i8 127>)
746 %m2 = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %m, <2 x i8> <i8 200, i8 undef>)
750 define i8 @umin_umin_constants_commute3(i8 %x) {
751 ; CHECK-LABEL: @umin_umin_constants_commute3(
752 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 -128, i8 [[X:%.*]])
753 ; CHECK-NEXT: ret i8 [[M]]
755 %m = call i8 @llvm.umin.i8(i8 128, i8 %x)
756 %m2 = call i8 @llvm.umin.i8(i8 %m, i8 254)
760 define i8 @smax_smax_constants(i8 %x) {
761 ; CHECK-LABEL: @smax_smax_constants(
762 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 9)
763 ; CHECK-NEXT: ret i8 [[M]]
765 %m = call i8 @llvm.smax.i8(i8 %x, i8 9)
766 %m2 = call i8 @llvm.smax.i8(i8 7, i8 %m)
770 define <2 x i8> @smax_smax_constants_commute1(<2 x i8> %x) {
771 ; CHECK-LABEL: @smax_smax_constants_commute1(
772 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 7, i8 7>, <2 x i8> [[X:%.*]])
773 ; CHECK-NEXT: ret <2 x i8> [[M]]
775 %m = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 7, i8 7>, <2 x i8> %x)
776 %m2 = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 -127, i8 -127>, <2 x i8> %m)
780 define i8 @smax_smax_constants_commute2(i8 %x) {
781 ; CHECK-LABEL: @smax_smax_constants_commute2(
782 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 0)
783 ; CHECK-NEXT: ret i8 [[M]]
785 %m = call i8 @llvm.smax.i8(i8 %x, i8 0)
786 %m2 = call i8 @llvm.smax.i8(i8 %m, i8 -1)
790 define i8 @smax_smax_constants_commute3(i8 %x) {
791 ; CHECK-LABEL: @smax_smax_constants_commute3(
792 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 -1, i8 [[X:%.*]])
793 ; CHECK-NEXT: ret i8 [[M]]
795 %m = call i8 @llvm.smax.i8(i8 -1, i8 %x)
796 %m2 = call i8 @llvm.smax.i8(i8 %m, i8 -127)
800 define <2 x i8> @smin_smin_constants(<2 x i8> %x) {
801 ; CHECK-LABEL: @smin_smin_constants(
802 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.smin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> <i8 7, i8 7>)
803 ; CHECK-NEXT: ret <2 x i8> [[M]]
805 %m = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> <i8 7, i8 7>)
806 %m2 = call <2 x i8> @llvm.smin.v2i8(<2 x i8> <i8 undef, i8 9>, <2 x i8> %m)
810 define i8 @smin_smin_constants_commute1(i8 %x) {
811 ; CHECK-LABEL: @smin_smin_constants_commute1(
812 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 -127, i8 [[X:%.*]])
813 ; CHECK-NEXT: ret i8 [[M]]
815 %m = call i8 @llvm.smin.i8(i8 -127, i8 %x)
816 %m2 = call i8 @llvm.smin.i8(i8 7, i8 %m)
820 define i8 @smin_smin_constants_commute2(i8 %x) {
821 ; CHECK-LABEL: @smin_smin_constants_commute2(
822 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 -1)
823 ; CHECK-NEXT: ret i8 [[M]]
825 %m = call i8 @llvm.smin.i8(i8 %x, i8 -1)
826 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 0)
830 define i8 @smin_smin_constants_commute3(i8 %x) {
831 ; CHECK-LABEL: @smin_smin_constants_commute3(
832 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 -127, i8 [[X:%.*]])
833 ; CHECK-NEXT: ret i8 [[M]]
835 %m = call i8 @llvm.smin.i8(i8 -127, i8 %x)
836 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 -1)
840 ; Negative test - undef in inner constant must not propagate.
842 define <2 x i8> @umin_umin_constants_partial_undef(<2 x i8> %x) {
843 ; CHECK-LABEL: @umin_umin_constants_partial_undef(
844 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.umin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> <i8 7, i8 undef>)
845 ; CHECK-NEXT: [[M2:%.*]] = call <2 x i8> @llvm.umin.v2i8(<2 x i8> <i8 9, i8 9>, <2 x i8> [[M]])
846 ; CHECK-NEXT: ret <2 x i8> [[M2]]
848 %m = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> <i8 7, i8 undef> )
849 %m2 = call <2 x i8> @llvm.umin.v2i8(<2 x i8> <i8 9, i8 9>, <2 x i8> %m)
853 ; Negative test - undef in inner constant must not propagate.
855 define <2 x i8> @smax_smax_constants_partial_undef(<2 x i8> %x) {
856 ; CHECK-LABEL: @smax_smax_constants_partial_undef(
857 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.smax.v2i8(<2 x i8> [[X:%.*]], <2 x i8> <i8 undef, i8 10>)
858 ; CHECK-NEXT: [[M2:%.*]] = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 9, i8 9>, <2 x i8> [[M]])
859 ; CHECK-NEXT: ret <2 x i8> [[M2]]
861 %m = call <2 x i8> @llvm.smax.v2i8(<2 x i8> %x, <2 x i8> <i8 undef, i8 10> )
862 %m2 = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 9, i8 9>, <2 x i8> %m)
866 define i1 @smax_slt(i8 %x, i8 %y) {
867 ; CHECK-LABEL: @smax_slt(
868 ; CHECK-NEXT: ret i1 false
870 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
871 %r = icmp slt i8 %m, %x
875 define i1 @smax_sge(i8 %x, i8 %y) {
876 ; CHECK-LABEL: @smax_sge(
877 ; CHECK-NEXT: ret i1 true
879 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
880 %r = icmp sge i8 %m, %x
884 define i1 @umax_ult(i8 %x, i8 %y) {
885 ; CHECK-LABEL: @umax_ult(
886 ; CHECK-NEXT: ret i1 false
888 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
889 %r = icmp ult i8 %m, %x
893 define i1 @umax_uge(i8 %x, i8 %y) {
894 ; CHECK-LABEL: @umax_uge(
895 ; CHECK-NEXT: ret i1 true
897 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
898 %r = icmp uge i8 %m, %x
902 define i1 @smax_sgt(i8 %x, i8 %y) {
903 ; CHECK-LABEL: @smax_sgt(
904 ; CHECK-NEXT: ret i1 false
906 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
907 %r = icmp sgt i8 %x, %m
911 define i1 @smax_sle(i8 %x, i8 %y) {
912 ; CHECK-LABEL: @smax_sle(
913 ; CHECK-NEXT: ret i1 true
915 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
916 %r = icmp sle i8 %x, %m
920 define i1 @umax_ugt(i8 %x, i8 %y) {
921 ; CHECK-LABEL: @umax_ugt(
922 ; CHECK-NEXT: ret i1 false
924 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
925 %r = icmp ugt i8 %x, %m
929 define i1 @umax_ule(i8 %x, i8 %y) {
930 ; CHECK-LABEL: @umax_ule(
931 ; CHECK-NEXT: ret i1 true
933 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
934 %r = icmp ule i8 %x, %m
938 define i1 @smin_sgt(i8 %x, i8 %y) {
939 ; CHECK-LABEL: @smin_sgt(
940 ; CHECK-NEXT: ret i1 false
942 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
943 %r = icmp sgt i8 %m, %x
947 define i1 @smin_sle(i8 %x, i8 %y) {
948 ; CHECK-LABEL: @smin_sle(
949 ; CHECK-NEXT: ret i1 true
951 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
952 %r = icmp sle i8 %m, %x
956 define i1 @umin_ugt(i8 %x, i8 %y) {
957 ; CHECK-LABEL: @umin_ugt(
958 ; CHECK-NEXT: ret i1 false
960 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
961 %r = icmp ugt i8 %m, %x
965 define i1 @umin_ule(i8 %x, i8 %y) {
966 ; CHECK-LABEL: @umin_ule(
967 ; CHECK-NEXT: ret i1 true
969 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
970 %r = icmp ule i8 %m, %x
974 define i1 @smin_slt(i8 %x, i8 %y) {
975 ; CHECK-LABEL: @smin_slt(
976 ; CHECK-NEXT: ret i1 false
978 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
979 %r = icmp slt i8 %x, %m
983 define i1 @smin_sge(i8 %x, i8 %y) {
984 ; CHECK-LABEL: @smin_sge(
985 ; CHECK-NEXT: ret i1 true
987 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
988 %r = icmp sge i8 %x, %m
992 define i1 @umin_ult(i8 %x, i8 %y) {
993 ; CHECK-LABEL: @umin_ult(
994 ; CHECK-NEXT: ret i1 false
996 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
997 %r = icmp ult i8 %x, %m
1001 define i1 @umin_uge(i8 %x, i8 %y) {
1002 ; CHECK-LABEL: @umin_uge(
1003 ; CHECK-NEXT: ret i1 true
1005 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1006 %r = icmp uge i8 %x, %m
1010 define i1 @smaxmin_sge(i8 %x, i8 %y, i8 %z) {
1011 ; CHECK-LABEL: @smaxmin_sge(
1012 ; CHECK-NEXT: ret i1 true
1014 %max = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1015 %min = call i8 @llvm.smin.i8(i8 %z, i8 %x)
1016 %c = icmp sge i8 %max, %min
1020 define i1 @smaxmin_sgt(i8 %x, i8 %y, i8 %z) {
1021 ; CHECK-LABEL: @smaxmin_sgt(
1022 ; CHECK-NEXT: ret i1 false
1024 %max = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1025 %min = call i8 @llvm.smin.i8(i8 %z, i8 %x)
1026 %c = icmp sgt i8 %min, %max
1030 define i1 @smaxmin_sle(i8 %x, i8 %y, i8 %z) {
1031 ; CHECK-LABEL: @smaxmin_sle(
1032 ; CHECK-NEXT: ret i1 true
1034 %max = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1035 %min = call i8 @llvm.smin.i8(i8 %z, i8 %x)
1036 %c = icmp sle i8 %min, %max
1040 define i1 @smaxmin_slt(i8 %x, i8 %y, i8 %z) {
1041 ; CHECK-LABEL: @smaxmin_slt(
1042 ; CHECK-NEXT: ret i1 false
1044 %max = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1045 %min = call i8 @llvm.smin.i8(i8 %z, i8 %x)
1046 %c = icmp slt i8 %max, %min
1050 define i1 @umaxmin_uge(i8 %x, i8 %y, i8 %z) {
1051 ; CHECK-LABEL: @umaxmin_uge(
1052 ; CHECK-NEXT: ret i1 true
1054 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1055 %min = call i8 @llvm.umin.i8(i8 %z, i8 %x)
1056 %c = icmp uge i8 %max, %min
1060 define i1 @umaxmin_ugt(i8 %x, i8 %y, i8 %z) {
1061 ; CHECK-LABEL: @umaxmin_ugt(
1062 ; CHECK-NEXT: ret i1 false
1064 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1065 %min = call i8 @llvm.umin.i8(i8 %z, i8 %x)
1066 %c = icmp ugt i8 %min, %max
1070 define i1 @umaxmin_ule(i8 %x, i8 %y, i8 %z) {
1071 ; CHECK-LABEL: @umaxmin_ule(
1072 ; CHECK-NEXT: ret i1 true
1074 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1075 %min = call i8 @llvm.umin.i8(i8 %z, i8 %x)
1076 %c = icmp ule i8 %min, %max
1080 define i1 @umaxmin_ult(i8 %x, i8 %y, i8 %z) {
1081 ; CHECK-LABEL: @umaxmin_ult(
1082 ; CHECK-NEXT: ret i1 false
1084 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1085 %min = call i8 @llvm.umin.i8(i8 %z, i8 %x)
1086 %c = icmp ult i8 %max, %min
1090 ; Negative test - should reduce via instcombine, but not here.
1092 define i1 @smax_eq(i8 %x, i8 %y) {
1093 ; CHECK-LABEL: @smax_eq(
1094 ; CHECK-NEXT: [[MAX:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1095 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[MAX]], [[X]]
1096 ; CHECK-NEXT: ret i1 [[R]]
1098 %max = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1099 %r = icmp eq i8 %max, %x
1103 ; Negative test - should reduce via instcombine, but not here.
1105 define i1 @smax_eq_commute(i8 %x, i8 %y) {
1106 ; CHECK-LABEL: @smax_eq_commute(
1107 ; CHECK-NEXT: [[MAX:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1108 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[X]], [[MAX]]
1109 ; CHECK-NEXT: ret i1 [[R]]
1111 %max = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1112 %r = icmp eq i8 %x, %max
1116 ; Negative test - should reduce via instcombine, but not here.
1118 define i1 @umax_eq(i8 %x, i8 %y) {
1119 ; CHECK-LABEL: @umax_eq(
1120 ; CHECK-NEXT: [[MAX:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1121 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[MAX]], [[X]]
1122 ; CHECK-NEXT: ret i1 [[R]]
1124 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1125 %r = icmp eq i8 %max, %x
1129 ; Negative test - should reduce via instcombine, but not here.
1131 define i1 @umax_eq_commute(i8 %x, i8 %y) {
1132 ; CHECK-LABEL: @umax_eq_commute(
1133 ; CHECK-NEXT: [[MAX:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1134 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[X]], [[MAX]]
1135 ; CHECK-NEXT: ret i1 [[R]]
1137 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1138 %r = icmp eq i8 %x, %max
1142 define i8 @smax_smax_smax(i8 %x, i8 %y) {
1143 ; CHECK-LABEL: @smax_smax_smax(
1144 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1145 ; CHECK-NEXT: ret i8 [[M1]]
1147 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1148 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1149 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1153 define i8 @smax_smax_smin(i8 %x, i8 %y) {
1154 ; CHECK-LABEL: @smax_smax_smin(
1155 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1156 ; CHECK-NEXT: ret i8 [[M1]]
1158 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1159 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1160 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1164 define i8 @smax_smax_umax(i8 %x, i8 %y) {
1165 ; CHECK-LABEL: @smax_smax_umax(
1166 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1167 ; CHECK-NEXT: ret i8 [[M1]]
1169 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1170 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1171 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1175 define i8 @smax_smax_umin(i8 %x, i8 %y) {
1176 ; CHECK-LABEL: @smax_smax_umin(
1177 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1178 ; CHECK-NEXT: ret i8 [[M1]]
1180 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1181 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1182 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1186 define i8 @smax_smin_smax(i8 %x, i8 %y) {
1187 ; CHECK-LABEL: @smax_smin_smax(
1188 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1189 ; CHECK-NEXT: ret i8 [[M2]]
1191 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1192 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1193 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1197 define i8 @smax_smin_smin(i8 %x, i8 %y) {
1198 ; CHECK-LABEL: @smax_smin_smin(
1199 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1200 ; CHECK-NEXT: ret i8 [[M2]]
1202 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1203 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1204 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1208 define i8 @smax_smin_umax(i8 %x, i8 %y) {
1209 ; CHECK-LABEL: @smax_smin_umax(
1210 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1211 ; CHECK-NEXT: ret i8 [[M2]]
1213 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1214 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1215 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1219 define i8 @smax_smin_umin(i8 %x, i8 %y) {
1220 ; CHECK-LABEL: @smax_smin_umin(
1221 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1222 ; CHECK-NEXT: ret i8 [[M2]]
1224 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1225 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1226 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1230 define i8 @smax_umax_smax(i8 %x, i8 %y) {
1231 ; CHECK-LABEL: @smax_umax_smax(
1232 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1233 ; CHECK-NEXT: ret i8 [[M2]]
1235 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1236 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1237 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1241 define i8 @smax_umax_smin(i8 %x, i8 %y) {
1242 ; CHECK-LABEL: @smax_umax_smin(
1243 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1244 ; CHECK-NEXT: ret i8 [[M1]]
1246 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1247 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1248 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1252 ; This could simplify (commuted min/max op).
1254 define i8 @smax_umax_umax(i8 %x, i8 %y) {
1255 ; CHECK-LABEL: @smax_umax_umax(
1256 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1257 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y]], i8 [[X]])
1258 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smax.i8(i8 [[M1]], i8 [[M2]])
1259 ; CHECK-NEXT: ret i8 [[R]]
1261 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1262 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1263 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1267 ; This could combine - smax(x,y) - but does not simplify.
1269 define i8 @smax_umax_umin(i8 %x, i8 %y) {
1270 ; CHECK-LABEL: @smax_umax_umin(
1271 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1272 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y]], i8 [[X]])
1273 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smax.i8(i8 [[M1]], i8 [[M2]])
1274 ; CHECK-NEXT: ret i8 [[R]]
1276 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1277 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1278 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1282 define i8 @smax_umin_smax(i8 %x, i8 %y) {
1283 ; CHECK-LABEL: @smax_umin_smax(
1284 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1285 ; CHECK-NEXT: ret i8 [[M2]]
1287 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1288 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1289 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1293 define i8 @smax_umin_smin(i8 %x, i8 %y) {
1294 ; CHECK-LABEL: @smax_umin_smin(
1295 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1296 ; CHECK-NEXT: ret i8 [[M1]]
1298 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1299 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1300 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1304 ; This could combine - smax(x,y) - but does not simplify.
1306 define i8 @smax_umin_umax(i8 %x, i8 %y) {
1307 ; CHECK-LABEL: @smax_umin_umax(
1308 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1309 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y]], i8 [[X]])
1310 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smax.i8(i8 [[M1]], i8 [[M2]])
1311 ; CHECK-NEXT: ret i8 [[R]]
1313 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1314 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1315 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1319 ; This could simplify (commuted min/max op).
1321 define i8 @smax_umin_umin(i8 %x, i8 %y) {
1322 ; CHECK-LABEL: @smax_umin_umin(
1323 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1324 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y]], i8 [[X]])
1325 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smax.i8(i8 [[M1]], i8 [[M2]])
1326 ; CHECK-NEXT: ret i8 [[R]]
1328 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1329 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1330 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1334 define i8 @smin_smax_smax(i8 %x, i8 %y) {
1335 ; CHECK-LABEL: @smin_smax_smax(
1336 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1337 ; CHECK-NEXT: ret i8 [[M2]]
1339 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1340 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1341 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1345 define i8 @smin_smax_smin(i8 %x, i8 %y) {
1346 ; CHECK-LABEL: @smin_smax_smin(
1347 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1348 ; CHECK-NEXT: ret i8 [[M2]]
1350 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1351 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1352 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1356 define i8 @smin_smax_umax(i8 %x, i8 %y) {
1357 ; CHECK-LABEL: @smin_smax_umax(
1358 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1359 ; CHECK-NEXT: ret i8 [[M2]]
1361 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1362 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1363 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1367 define i8 @smin_smax_umin(i8 %x, i8 %y) {
1368 ; CHECK-LABEL: @smin_smax_umin(
1369 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1370 ; CHECK-NEXT: ret i8 [[M2]]
1372 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1373 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1374 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1378 define i8 @smin_smin_smax(i8 %x, i8 %y) {
1379 ; CHECK-LABEL: @smin_smin_smax(
1380 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1381 ; CHECK-NEXT: ret i8 [[M1]]
1383 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1384 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1385 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1389 define i8 @smin_smin_smin(i8 %x, i8 %y) {
1390 ; CHECK-LABEL: @smin_smin_smin(
1391 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1392 ; CHECK-NEXT: ret i8 [[M1]]
1394 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1395 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1396 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1400 define i8 @smin_smin_umax(i8 %x, i8 %y) {
1401 ; CHECK-LABEL: @smin_smin_umax(
1402 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1403 ; CHECK-NEXT: ret i8 [[M1]]
1405 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1406 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1407 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1411 define i8 @smin_smin_umin(i8 %x, i8 %y) {
1412 ; CHECK-LABEL: @smin_smin_umin(
1413 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1414 ; CHECK-NEXT: ret i8 [[M1]]
1416 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1417 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1418 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1422 define i8 @smin_umax_smax(i8 %x, i8 %y) {
1423 ; CHECK-LABEL: @smin_umax_smax(
1424 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1425 ; CHECK-NEXT: ret i8 [[M1]]
1427 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1428 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1429 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1433 define i8 @smin_umax_smin(i8 %x, i8 %y) {
1434 ; CHECK-LABEL: @smin_umax_smin(
1435 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1436 ; CHECK-NEXT: ret i8 [[M2]]
1438 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1439 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1440 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1444 ; This could simplify (commuted min/max op).
1446 define i8 @smin_umax_umax(i8 %x, i8 %y) {
1447 ; CHECK-LABEL: @smin_umax_umax(
1448 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1449 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y]], i8 [[X]])
1450 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smin.i8(i8 [[M1]], i8 [[M2]])
1451 ; CHECK-NEXT: ret i8 [[R]]
1453 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1454 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1455 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1459 ; This could combine - smin(x,y) - but does not simplify.
1461 define i8 @smin_umax_umin(i8 %x, i8 %y) {
1462 ; CHECK-LABEL: @smin_umax_umin(
1463 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1464 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y]], i8 [[X]])
1465 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smin.i8(i8 [[M1]], i8 [[M2]])
1466 ; CHECK-NEXT: ret i8 [[R]]
1468 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1469 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1470 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1474 define i8 @smin_umin_smax(i8 %x, i8 %y) {
1475 ; CHECK-LABEL: @smin_umin_smax(
1476 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1477 ; CHECK-NEXT: ret i8 [[M1]]
1479 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1480 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1481 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1485 define i8 @smin_umin_smin(i8 %x, i8 %y) {
1486 ; CHECK-LABEL: @smin_umin_smin(
1487 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1488 ; CHECK-NEXT: ret i8 [[M2]]
1490 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1491 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1492 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1496 ; This could combine - smin(x,y) - but does not simplify.
1498 define i8 @smin_umin_umax(i8 %x, i8 %y) {
1499 ; CHECK-LABEL: @smin_umin_umax(
1500 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1501 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y]], i8 [[X]])
1502 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smin.i8(i8 [[M1]], i8 [[M2]])
1503 ; CHECK-NEXT: ret i8 [[R]]
1505 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1506 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1507 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1511 ; This could simplify (commuted min/max op).
1513 define i8 @smin_umin_umin(i8 %x, i8 %y) {
1514 ; CHECK-LABEL: @smin_umin_umin(
1515 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1516 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y]], i8 [[X]])
1517 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smin.i8(i8 [[M1]], i8 [[M2]])
1518 ; CHECK-NEXT: ret i8 [[R]]
1520 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1521 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1522 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1526 ; This could simplify (commuted min/max op).
1528 define i8 @umax_smax_smax(i8 %x, i8 %y) {
1529 ; CHECK-LABEL: @umax_smax_smax(
1530 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1531 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y]], i8 [[X]])
1532 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umax.i8(i8 [[M1]], i8 [[M2]])
1533 ; CHECK-NEXT: ret i8 [[R]]
1535 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1536 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1537 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1541 ; This could combine - umax(x,y) - but does not simplify.
1543 define i8 @umax_smax_smin(i8 %x, i8 %y) {
1544 ; CHECK-LABEL: @umax_smax_smin(
1545 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1546 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y]], i8 [[X]])
1547 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umax.i8(i8 [[M1]], i8 [[M2]])
1548 ; CHECK-NEXT: ret i8 [[R]]
1550 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1551 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1552 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1556 define i8 @umax_smax_umax(i8 %x, i8 %y) {
1557 ; CHECK-LABEL: @umax_smax_umax(
1558 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1559 ; CHECK-NEXT: ret i8 [[M2]]
1561 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1562 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1563 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1567 define i8 @umax_smax_umin(i8 %x, i8 %y) {
1568 ; CHECK-LABEL: @umax_smax_umin(
1569 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1570 ; CHECK-NEXT: ret i8 [[M1]]
1572 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1573 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1574 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1578 ; This could combine - umax(x,y) - but does not simplify.
1580 define i8 @umax_smin_smax(i8 %x, i8 %y) {
1581 ; CHECK-LABEL: @umax_smin_smax(
1582 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1583 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y]], i8 [[X]])
1584 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umax.i8(i8 [[M1]], i8 [[M2]])
1585 ; CHECK-NEXT: ret i8 [[R]]
1587 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1588 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1589 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1593 ; This could simplify (commuted min/max op).
1595 define i8 @umax_smin_smin(i8 %x, i8 %y) {
1596 ; CHECK-LABEL: @umax_smin_smin(
1597 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1598 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y]], i8 [[X]])
1599 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umax.i8(i8 [[M1]], i8 [[M2]])
1600 ; CHECK-NEXT: ret i8 [[R]]
1602 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1603 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1604 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1608 define i8 @umax_smin_umax(i8 %x, i8 %y) {
1609 ; CHECK-LABEL: @umax_smin_umax(
1610 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1611 ; CHECK-NEXT: ret i8 [[M2]]
1613 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1614 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1615 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1619 define i8 @umax_smin_umin(i8 %x, i8 %y) {
1620 ; CHECK-LABEL: @umax_smin_umin(
1621 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1622 ; CHECK-NEXT: ret i8 [[M1]]
1624 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1625 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1626 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1630 define i8 @umax_umax_smax(i8 %x, i8 %y) {
1631 ; CHECK-LABEL: @umax_umax_smax(
1632 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1633 ; CHECK-NEXT: ret i8 [[M1]]
1635 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1636 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1637 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1641 define i8 @umax_umax_smin(i8 %x, i8 %y) {
1642 ; CHECK-LABEL: @umax_umax_smin(
1643 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1644 ; CHECK-NEXT: ret i8 [[M1]]
1646 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1647 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1648 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1652 define i8 @umax_umax_umax(i8 %x, i8 %y) {
1653 ; CHECK-LABEL: @umax_umax_umax(
1654 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1655 ; CHECK-NEXT: ret i8 [[M1]]
1657 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1658 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1659 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1663 define i8 @umax_umax_umin(i8 %x, i8 %y) {
1664 ; CHECK-LABEL: @umax_umax_umin(
1665 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1666 ; CHECK-NEXT: ret i8 [[M1]]
1668 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1669 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1670 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1674 define i8 @umax_umin_smax(i8 %x, i8 %y) {
1675 ; CHECK-LABEL: @umax_umin_smax(
1676 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1677 ; CHECK-NEXT: ret i8 [[M2]]
1679 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1680 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1681 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1685 define i8 @umax_umin_smin(i8 %x, i8 %y) {
1686 ; CHECK-LABEL: @umax_umin_smin(
1687 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1688 ; CHECK-NEXT: ret i8 [[M2]]
1690 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1691 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1692 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1696 define i8 @umax_umin_umax(i8 %x, i8 %y) {
1697 ; CHECK-LABEL: @umax_umin_umax(
1698 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1699 ; CHECK-NEXT: ret i8 [[M2]]
1701 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1702 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1703 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1707 define i8 @umax_umin_umin(i8 %x, i8 %y) {
1708 ; CHECK-LABEL: @umax_umin_umin(
1709 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1710 ; CHECK-NEXT: ret i8 [[M2]]
1712 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1713 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1714 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1718 ; This could simplify (commuted min/max op).
1720 define i8 @umin_smax_smax(i8 %x, i8 %y) {
1721 ; CHECK-LABEL: @umin_smax_smax(
1722 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1723 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y]], i8 [[X]])
1724 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umin.i8(i8 [[M1]], i8 [[M2]])
1725 ; CHECK-NEXT: ret i8 [[R]]
1727 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1728 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1729 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1733 ; This could combine - umin(x,y) - but does not simplify.
1735 define i8 @umin_smax_smin(i8 %x, i8 %y) {
1736 ; CHECK-LABEL: @umin_smax_smin(
1737 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1738 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y]], i8 [[X]])
1739 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umin.i8(i8 [[M1]], i8 [[M2]])
1740 ; CHECK-NEXT: ret i8 [[R]]
1742 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1743 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1744 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1748 define i8 @umin_smax_umax(i8 %x, i8 %y) {
1749 ; CHECK-LABEL: @umin_smax_umax(
1750 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1751 ; CHECK-NEXT: ret i8 [[M1]]
1753 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1754 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1755 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1759 define i8 @umin_smax_umin(i8 %x, i8 %y) {
1760 ; CHECK-LABEL: @umin_smax_umin(
1761 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1762 ; CHECK-NEXT: ret i8 [[M2]]
1764 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1765 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1766 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1770 ; This could combine - umin(x,y) - but does not simplify.
1772 define i8 @umin_smin_smax(i8 %x, i8 %y) {
1773 ; CHECK-LABEL: @umin_smin_smax(
1774 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1775 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y]], i8 [[X]])
1776 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umin.i8(i8 [[M1]], i8 [[M2]])
1777 ; CHECK-NEXT: ret i8 [[R]]
1779 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1780 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1781 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1785 ; This could simplify (commuted min/max op).
1787 define i8 @umin_smin_smin(i8 %x, i8 %y) {
1788 ; CHECK-LABEL: @umin_smin_smin(
1789 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1790 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y]], i8 [[X]])
1791 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umin.i8(i8 [[M1]], i8 [[M2]])
1792 ; CHECK-NEXT: ret i8 [[R]]
1794 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1795 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1796 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1800 define i8 @umin_smin_umax(i8 %x, i8 %y) {
1801 ; CHECK-LABEL: @umin_smin_umax(
1802 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1803 ; CHECK-NEXT: ret i8 [[M1]]
1805 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1806 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1807 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1811 define i8 @umin_smin_umin(i8 %x, i8 %y) {
1812 ; CHECK-LABEL: @umin_smin_umin(
1813 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1814 ; CHECK-NEXT: ret i8 [[M2]]
1816 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1817 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1818 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1822 define i8 @umin_umax_smax(i8 %x, i8 %y) {
1823 ; CHECK-LABEL: @umin_umax_smax(
1824 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1825 ; CHECK-NEXT: ret i8 [[M2]]
1827 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1828 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1829 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1833 define i8 @umin_umax_smin(i8 %x, i8 %y) {
1834 ; CHECK-LABEL: @umin_umax_smin(
1835 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1836 ; CHECK-NEXT: ret i8 [[M2]]
1838 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1839 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1840 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1844 define i8 @umin_umax_umax(i8 %x, i8 %y) {
1845 ; CHECK-LABEL: @umin_umax_umax(
1846 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1847 ; CHECK-NEXT: ret i8 [[M2]]
1849 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1850 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1851 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1855 define i8 @umin_umax_umin(i8 %x, i8 %y) {
1856 ; CHECK-LABEL: @umin_umax_umin(
1857 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1858 ; CHECK-NEXT: ret i8 [[M2]]
1860 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1861 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1862 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1866 define i8 @umin_umin_smax(i8 %x, i8 %y) {
1867 ; CHECK-LABEL: @umin_umin_smax(
1868 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1869 ; CHECK-NEXT: ret i8 [[M1]]
1871 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1872 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1873 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1877 define i8 @umin_umin_smin(i8 %x, i8 %y) {
1878 ; CHECK-LABEL: @umin_umin_smin(
1879 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1880 ; CHECK-NEXT: ret i8 [[M1]]
1882 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1883 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1884 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1888 define i8 @umin_umin_umax(i8 %x, i8 %y) {
1889 ; CHECK-LABEL: @umin_umin_umax(
1890 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1891 ; CHECK-NEXT: ret i8 [[M1]]
1893 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1894 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1895 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1899 define i8 @umin_umin_umin(i8 %x, i8 %y) {
1900 ; CHECK-LABEL: @umin_umin_umin(
1901 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1902 ; CHECK-NEXT: ret i8 [[M1]]
1904 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1905 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1906 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1910 define i1 @umin_ult_diff_const(i8 %x) {
1911 ; CHECK-LABEL: @umin_ult_diff_const(
1912 ; CHECK-NEXT: ret i1 true
1914 %m = call i8 @llvm.umin.i8(i8 %x, i8 10)
1915 %c = icmp ult i8 %m, 20
1919 define i1 @umax_ugt_diff_const(i8 %x) {
1920 ; CHECK-LABEL: @umax_ugt_diff_const(
1921 ; CHECK-NEXT: ret i1 true
1923 %m = call i8 @llvm.umax.i8(i8 %x, i8 10)
1924 %c = icmp ugt i8 %m, 5
1928 define i1 @smin_slt_diff_const(i8 %x) {
1929 ; CHECK-LABEL: @smin_slt_diff_const(
1930 ; CHECK-NEXT: ret i1 true
1932 %m = call i8 @llvm.smin.i8(i8 %x, i8 10)
1933 %c = icmp slt i8 %m, 20
1937 define i1 @smax_sgt_diff_const(i8 %x) {
1938 ; CHECK-LABEL: @smax_sgt_diff_const(
1939 ; CHECK-NEXT: ret i1 true
1941 %m = call i8 @llvm.smax.i8(i8 %x, i8 10)
1942 %c = icmp sgt i8 %m, 5
1946 define i8 @umin_assume_uge(i8 %x, i8 %y) {
1947 ; CHECK-LABEL: @umin_assume_uge(
1948 ; CHECK-NEXT: [[C:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
1949 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
1950 ; CHECK-NEXT: ret i8 [[Y]]
1952 %c = icmp uge i8 %x, %y
1953 call void @llvm.assume(i1 %c)
1954 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1958 define i8 @umin_assume_ugt(i8 %x, i8 %y) {
1959 ; CHECK-LABEL: @umin_assume_ugt(
1960 ; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]
1961 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
1962 ; CHECK-NEXT: ret i8 [[Y]]
1964 %c = icmp ugt i8 %x, %y
1965 call void @llvm.assume(i1 %c)
1966 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1970 define i8 @umin_assume_ule(i8 %x, i8 %y) {
1971 ; CHECK-LABEL: @umin_assume_ule(
1972 ; CHECK-NEXT: [[C:%.*]] = icmp ule i8 [[X:%.*]], [[Y:%.*]]
1973 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
1974 ; CHECK-NEXT: ret i8 [[X]]
1976 %c = icmp ule i8 %x, %y
1977 call void @llvm.assume(i1 %c)
1978 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1982 define i8 @umin_assume_ult(i8 %x, i8 %y) {
1983 ; CHECK-LABEL: @umin_assume_ult(
1984 ; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
1985 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
1986 ; CHECK-NEXT: ret i8 [[X]]
1988 %c = icmp ult i8 %x, %y
1989 call void @llvm.assume(i1 %c)
1990 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1994 define i8 @umax_assume_uge(i8 %x, i8 %y) {
1995 ; CHECK-LABEL: @umax_assume_uge(
1996 ; CHECK-NEXT: [[C:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
1997 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
1998 ; CHECK-NEXT: ret i8 [[X]]
2000 %c = icmp uge i8 %x, %y
2001 call void @llvm.assume(i1 %c)
2002 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2006 define i8 @umax_assume_ugt(i8 %x, i8 %y) {
2007 ; CHECK-LABEL: @umax_assume_ugt(
2008 ; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]
2009 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2010 ; CHECK-NEXT: ret i8 [[X]]
2012 %c = icmp ugt i8 %x, %y
2013 call void @llvm.assume(i1 %c)
2014 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2018 define i8 @umax_assume_ule(i8 %x, i8 %y) {
2019 ; CHECK-LABEL: @umax_assume_ule(
2020 ; CHECK-NEXT: [[C:%.*]] = icmp ule i8 [[X:%.*]], [[Y:%.*]]
2021 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2022 ; CHECK-NEXT: ret i8 [[Y]]
2024 %c = icmp ule i8 %x, %y
2025 call void @llvm.assume(i1 %c)
2026 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2030 define i8 @umax_assume_ult(i8 %x, i8 %y) {
2031 ; CHECK-LABEL: @umax_assume_ult(
2032 ; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
2033 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2034 ; CHECK-NEXT: ret i8 [[Y]]
2036 %c = icmp ult i8 %x, %y
2037 call void @llvm.assume(i1 %c)
2038 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2042 define i8 @smin_assume_sge(i8 %x, i8 %y) {
2043 ; CHECK-LABEL: @smin_assume_sge(
2044 ; CHECK-NEXT: [[C:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
2045 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2046 ; CHECK-NEXT: ret i8 [[Y]]
2048 %c = icmp sge i8 %x, %y
2049 call void @llvm.assume(i1 %c)
2050 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
2054 define i8 @smin_assume_sgt(i8 %x, i8 %y) {
2055 ; CHECK-LABEL: @smin_assume_sgt(
2056 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]]
2057 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2058 ; CHECK-NEXT: ret i8 [[Y]]
2060 %c = icmp sgt i8 %x, %y
2061 call void @llvm.assume(i1 %c)
2062 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
2066 define i8 @smin_assume_sle(i8 %x, i8 %y) {
2067 ; CHECK-LABEL: @smin_assume_sle(
2068 ; CHECK-NEXT: [[C:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
2069 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2070 ; CHECK-NEXT: ret i8 [[X]]
2072 %c = icmp sle i8 %x, %y
2073 call void @llvm.assume(i1 %c)
2074 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
2078 define i8 @smin_assume_slt(i8 %x, i8 %y) {
2079 ; CHECK-LABEL: @smin_assume_slt(
2080 ; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X:%.*]], [[Y:%.*]]
2081 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2082 ; CHECK-NEXT: ret i8 [[X]]
2084 %c = icmp slt i8 %x, %y
2085 call void @llvm.assume(i1 %c)
2086 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
2090 define i8 @smax_assume_sge(i8 %x, i8 %y) {
2091 ; CHECK-LABEL: @smax_assume_sge(
2092 ; CHECK-NEXT: [[C:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
2093 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2094 ; CHECK-NEXT: ret i8 [[X]]
2096 %c = icmp sge i8 %x, %y
2097 call void @llvm.assume(i1 %c)
2098 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
2102 define i8 @smax_assume_sgt(i8 %x, i8 %y) {
2103 ; CHECK-LABEL: @smax_assume_sgt(
2104 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]]
2105 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2106 ; CHECK-NEXT: ret i8 [[X]]
2108 %c = icmp sgt i8 %x, %y
2109 call void @llvm.assume(i1 %c)
2110 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
2114 define i8 @smax_assume_sle(i8 %x, i8 %y) {
2115 ; CHECK-LABEL: @smax_assume_sle(
2116 ; CHECK-NEXT: [[C:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
2117 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2118 ; CHECK-NEXT: ret i8 [[Y]]
2120 %c = icmp sle i8 %x, %y
2121 call void @llvm.assume(i1 %c)
2122 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
2126 define i8 @smax_assume_slt(i8 %x, i8 %y) {
2127 ; CHECK-LABEL: @smax_assume_slt(
2128 ; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X:%.*]], [[Y:%.*]]
2129 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2130 ; CHECK-NEXT: ret i8 [[Y]]
2132 %c = icmp slt i8 %x, %y
2133 call void @llvm.assume(i1 %c)
2134 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
2138 define i8 @umax_add_nuw_1(i8 %x) {
2139 ; CHECK-LABEL: @umax_add_nuw_1(
2140 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i8 [[X:%.*]], 1
2141 ; CHECK-NEXT: ret i8 [[ADD]]
2143 %add = add nuw i8 %x, 1
2144 %max = call i8 @llvm.umax.i8(i8 %add, i8 %x)
2148 define i8 @umax_add_nuw_2(i8 %x) {
2149 ; CHECK-LABEL: @umax_add_nuw_2(
2150 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i8 [[X:%.*]], 42
2151 ; CHECK-NEXT: ret i8 [[ADD]]
2153 %add = add nuw i8 %x, 42
2154 %max = call i8 @llvm.umax.i8(i8 %add, i8 42)
2158 define i8 @umax_range_metadata(ptr %p1, ptr %p2) {
2159 ; CHECK-LABEL: @umax_range_metadata(
2160 ; CHECK-NEXT: [[Y:%.*]] = load i8, ptr [[P2:%.*]], align 1, !range [[RNG0:![0-9]+]]
2161 ; CHECK-NEXT: ret i8 [[Y]]
2163 %x = load i8, ptr %p1, !range !{i8 0, i8 10}
2164 %y = load i8, ptr %p2, !range !{i8 20, i8 30}
2165 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2169 define i8 @umax_zext_sext(i4 %x) {
2170 ; CHECK-LABEL: @umax_zext_sext(
2171 ; CHECK-NEXT: [[SEXT:%.*]] = sext i4 [[X:%.*]] to i8
2172 ; CHECK-NEXT: ret i8 [[SEXT]]
2174 %zext = zext i4 %x to i8
2175 %sext = sext i4 %x to i8
2176 %max = call i8 @llvm.umax.i8(i8 %zext, i8 %sext)
2180 define i8 @umax_lshr(i8 %x, i8 %y) {
2181 ; CHECK-LABEL: @umax_lshr(
2182 ; CHECK-NEXT: ret i8 [[X:%.*]]
2184 %shr = lshr i8 %x, %y
2185 %max = call i8 @llvm.umax.i8(i8 %x, i8 %shr)
2189 define i8 @umax_dom_cond_uge(i8 %x, i8 %y) {
2190 ; CHECK-LABEL: @umax_dom_cond_uge(
2191 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
2192 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2194 ; CHECK-NEXT: ret i8 [[X]]
2196 ; CHECK-NEXT: ret i8 [[Y]]
2198 %cmp = icmp uge i8 %x, %y
2199 br i1 %cmp, label %true, label %false
2202 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2206 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2210 define i8 @umax_dom_cond_ugt(i8 %x, i8 %y) {
2211 ; CHECK-LABEL: @umax_dom_cond_ugt(
2212 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]
2213 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2215 ; CHECK-NEXT: ret i8 [[X]]
2217 ; CHECK-NEXT: ret i8 [[Y]]
2219 %cmp = icmp ugt i8 %x, %y
2220 br i1 %cmp, label %true, label %false
2223 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2227 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2231 define i8 @umax_dom_cond_ule(i8 %x, i8 %y) {
2232 ; CHECK-LABEL: @umax_dom_cond_ule(
2233 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[X:%.*]], [[Y:%.*]]
2234 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2236 ; CHECK-NEXT: ret i8 [[Y]]
2238 ; CHECK-NEXT: ret i8 [[X]]
2240 %cmp = icmp ule i8 %x, %y
2241 br i1 %cmp, label %true, label %false
2244 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2248 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2252 define i8 @umax_dom_cond_ult(i8 %x, i8 %y) {
2253 ; CHECK-LABEL: @umax_dom_cond_ult(
2254 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
2255 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2257 ; CHECK-NEXT: ret i8 [[Y]]
2259 ; CHECK-NEXT: ret i8 [[X]]
2261 %cmp = icmp ult i8 %x, %y
2262 br i1 %cmp, label %true, label %false
2265 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2269 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2273 define i8 @umin_dom_cond_uge(i8 %x, i8 %y) {
2274 ; CHECK-LABEL: @umin_dom_cond_uge(
2275 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
2276 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2278 ; CHECK-NEXT: ret i8 [[Y]]
2280 ; CHECK-NEXT: ret i8 [[X]]
2282 %cmp = icmp uge i8 %x, %y
2283 br i1 %cmp, label %true, label %false
2286 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
2290 %m2 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
2294 define i8 @smax_dom_cond_sge(i8 %x, i8 %y) {
2295 ; CHECK-LABEL: @smax_dom_cond_sge(
2296 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
2297 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2299 ; CHECK-NEXT: ret i8 [[X]]
2301 ; CHECK-NEXT: ret i8 [[Y]]
2303 %cmp = icmp sge i8 %x, %y
2304 br i1 %cmp, label %true, label %false
2307 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
2311 %m2 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
2315 define i8 @smin_dom_cond_sge(i8 %x, i8 %y) {
2316 ; CHECK-LABEL: @smin_dom_cond_sge(
2317 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
2318 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2320 ; CHECK-NEXT: ret i8 [[Y]]
2322 ; CHECK-NEXT: ret i8 [[X]]
2324 %cmp = icmp sge i8 %x, %y
2325 br i1 %cmp, label %true, label %false
2328 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
2332 %m2 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
2336 ; Tests from PR65833
2337 define i8 @umin_and_mask(i8 %x) {
2338 ; CHECK-LABEL: @umin_and_mask(
2339 ; CHECK-NEXT: [[AND1:%.*]] = and i8 [[X:%.*]], 1
2340 ; CHECK-NEXT: ret i8 [[AND1]]
2342 %and1 = and i8 %x, 1
2343 %and2 = and i8 %x, 3
2344 %val = call i8 @llvm.umin.i8(i8 %and1, i8 %and2)
2348 define i8 @umax_and_mask(i8 %x) {
2349 ; CHECK-LABEL: @umax_and_mask(
2350 ; CHECK-NEXT: [[AND2:%.*]] = and i8 [[X:%.*]], 3
2351 ; CHECK-NEXT: ret i8 [[AND2]]
2353 %and1 = and i8 %x, 1
2354 %and2 = and i8 %x, 3
2355 %val = call i8 @llvm.umax.i8(i8 %and1, i8 %and2)
2359 define i8 @umin_or_mask(i8 %x) {
2360 ; CHECK-LABEL: @umin_or_mask(
2361 ; CHECK-NEXT: [[AND1:%.*]] = or i8 [[X:%.*]], 1
2362 ; CHECK-NEXT: ret i8 [[AND1]]
2366 %val = call i8 @llvm.umin.i8(i8 %and1, i8 %and2)
2370 define i8 @umax_or_mask(i8 %x) {
2371 ; CHECK-LABEL: @umax_or_mask(
2372 ; CHECK-NEXT: [[AND2:%.*]] = or i8 [[X:%.*]], 3
2373 ; CHECK-NEXT: ret i8 [[AND2]]
2377 %val = call i8 @llvm.umax.i8(i8 %and1, i8 %and2)
2381 define i8 @umin_and_mask_negative(i8 %x) {
2382 ; CHECK-LABEL: @umin_and_mask_negative(
2383 ; CHECK-NEXT: [[AND1:%.*]] = and i8 [[X:%.*]], 1
2384 ; CHECK-NEXT: [[AND2:%.*]] = and i8 [[X]], 2
2385 ; CHECK-NEXT: [[VAL:%.*]] = call i8 @llvm.umin.i8(i8 [[AND1]], i8 [[AND2]])
2386 ; CHECK-NEXT: ret i8 [[VAL]]
2388 %and1 = and i8 %x, 1
2389 %and2 = and i8 %x, 2
2390 %val = call i8 @llvm.umin.i8(i8 %and1, i8 %and2)
2394 define i8 @umax_and_mask_negative(i8 %x) {
2395 ; CHECK-LABEL: @umax_and_mask_negative(
2396 ; CHECK-NEXT: [[AND1:%.*]] = and i8 [[X:%.*]], 1
2397 ; CHECK-NEXT: [[AND2:%.*]] = and i8 [[X]], 2
2398 ; CHECK-NEXT: [[VAL:%.*]] = call i8 @llvm.umax.i8(i8 [[AND1]], i8 [[AND2]])
2399 ; CHECK-NEXT: ret i8 [[VAL]]
2401 %and1 = and i8 %x, 1
2402 %and2 = and i8 %x, 2
2403 %val = call i8 @llvm.umax.i8(i8 %and1, i8 %and2)
2407 define i8 @umin_or_mask_negative(i8 %x) {
2408 ; CHECK-LABEL: @umin_or_mask_negative(
2409 ; CHECK-NEXT: [[AND1:%.*]] = or i8 [[X:%.*]], 1
2410 ; CHECK-NEXT: [[AND2:%.*]] = or i8 [[X]], 2
2411 ; CHECK-NEXT: [[VAL:%.*]] = call i8 @llvm.umin.i8(i8 [[AND1]], i8 [[AND2]])
2412 ; CHECK-NEXT: ret i8 [[VAL]]
2416 %val = call i8 @llvm.umin.i8(i8 %and1, i8 %and2)
2420 define i8 @umax_or_mask_negative(i8 %x) {
2421 ; CHECK-LABEL: @umax_or_mask_negative(
2422 ; CHECK-NEXT: [[AND1:%.*]] = or i8 [[X:%.*]], 1
2423 ; CHECK-NEXT: [[AND2:%.*]] = or i8 [[X]], 2
2424 ; CHECK-NEXT: [[VAL:%.*]] = call i8 @llvm.umax.i8(i8 [[AND1]], i8 [[AND2]])
2425 ; CHECK-NEXT: ret i8 [[VAL]]
2429 %val = call i8 @llvm.umax.i8(i8 %and1, i8 %and2)
2433 define i8 @smin_and_mask_subset1(i8 %x) {
2434 ; CHECK-LABEL: @smin_and_mask_subset1(
2435 ; CHECK-NEXT: [[AND1:%.*]] = and i8 [[X:%.*]], 1
2436 ; CHECK-NEXT: ret i8 [[AND1]]
2438 %and1 = and i8 %x, 1
2439 %and2 = and i8 %x, 3
2440 %val = call i8 @llvm.smin.i8(i8 %and1, i8 %and2)
2444 define i8 @smax_and_mask_subset1(i8 %x) {
2445 ; CHECK-LABEL: @smax_and_mask_subset1(
2446 ; CHECK-NEXT: [[AND2:%.*]] = and i8 [[X:%.*]], 3
2447 ; CHECK-NEXT: ret i8 [[AND2]]
2449 %and1 = and i8 %x, 1
2450 %and2 = and i8 %x, 3
2451 %val = call i8 @llvm.smax.i8(i8 %and1, i8 %and2)
2455 define i8 @smin_or_mask_subset1(i8 %x) {
2456 ; CHECK-LABEL: @smin_or_mask_subset1(
2457 ; CHECK-NEXT: [[AND1:%.*]] = or i8 [[X:%.*]], 1
2458 ; CHECK-NEXT: ret i8 [[AND1]]
2462 %val = call i8 @llvm.smin.i8(i8 %and1, i8 %and2)
2466 define i8 @smax_or_mask_subset1(i8 %x) {
2467 ; CHECK-LABEL: @smax_or_mask_subset1(
2468 ; CHECK-NEXT: [[AND2:%.*]] = or i8 [[X:%.*]], 3
2469 ; CHECK-NEXT: ret i8 [[AND2]]
2473 %val = call i8 @llvm.smax.i8(i8 %and1, i8 %and2)
2477 define i8 @smin_and_mask_subset2(i8 %x) {
2478 ; CHECK-LABEL: @smin_and_mask_subset2(
2479 ; CHECK-NEXT: [[AND1:%.*]] = and i8 [[X:%.*]], -4
2480 ; CHECK-NEXT: ret i8 [[AND1]]
2482 %and1 = and i8 %x, -4
2483 %and2 = and i8 %x, -3
2484 %val = call i8 @llvm.smin.i8(i8 %and1, i8 %and2)
2488 define i8 @smax_and_mask_subset2(i8 %x) {
2489 ; CHECK-LABEL: @smax_and_mask_subset2(
2490 ; CHECK-NEXT: [[AND2:%.*]] = and i8 [[X:%.*]], -3
2491 ; CHECK-NEXT: ret i8 [[AND2]]
2493 %and1 = and i8 %x, -4
2494 %and2 = and i8 %x, -3
2495 %val = call i8 @llvm.smax.i8(i8 %and1, i8 %and2)
2499 define i8 @smin_or_mask_subset2(i8 %x) {
2500 ; CHECK-LABEL: @smin_or_mask_subset2(
2501 ; CHECK-NEXT: [[AND1:%.*]] = or i8 [[X:%.*]], -4
2502 ; CHECK-NEXT: ret i8 [[AND1]]
2504 %and1 = or i8 %x, -4
2505 %and2 = or i8 %x, -3
2506 %val = call i8 @llvm.smin.i8(i8 %and1, i8 %and2)
2510 define i8 @smax_or_mask_subset2(i8 %x) {
2511 ; CHECK-LABEL: @smax_or_mask_subset2(
2512 ; CHECK-NEXT: [[AND2:%.*]] = or i8 [[X:%.*]], -3
2513 ; CHECK-NEXT: ret i8 [[AND2]]
2515 %and1 = or i8 %x, -4
2516 %and2 = or i8 %x, -3
2517 %val = call i8 @llvm.smax.i8(i8 %and1, i8 %and2)
2521 define i8 @smin_and_mask_negative(i8 %x) {
2522 ; CHECK-LABEL: @smin_and_mask_negative(
2523 ; CHECK-NEXT: [[AND1:%.*]] = and i8 [[X:%.*]], 1
2524 ; CHECK-NEXT: [[AND2:%.*]] = and i8 [[X]], -3
2525 ; CHECK-NEXT: [[VAL:%.*]] = call i8 @llvm.smin.i8(i8 [[AND1]], i8 [[AND2]])
2526 ; CHECK-NEXT: ret i8 [[VAL]]
2528 %and1 = and i8 %x, 1
2529 %and2 = and i8 %x, -3
2530 %val = call i8 @llvm.smin.i8(i8 %and1, i8 %and2)
2534 define i8 @smax_and_mask_negative(i8 %x) {
2535 ; CHECK-LABEL: @smax_and_mask_negative(
2536 ; CHECK-NEXT: [[AND1:%.*]] = and i8 [[X:%.*]], 1
2537 ; CHECK-NEXT: [[AND2:%.*]] = and i8 [[X]], -3
2538 ; CHECK-NEXT: [[VAL:%.*]] = call i8 @llvm.smax.i8(i8 [[AND1]], i8 [[AND2]])
2539 ; CHECK-NEXT: ret i8 [[VAL]]
2541 %and1 = and i8 %x, 1
2542 %and2 = and i8 %x, -3
2543 %val = call i8 @llvm.smax.i8(i8 %and1, i8 %and2)
2547 define i8 @smin_or_mask_negative(i8 %x) {
2548 ; CHECK-LABEL: @smin_or_mask_negative(
2549 ; CHECK-NEXT: [[AND1:%.*]] = or i8 [[X:%.*]], 1
2550 ; CHECK-NEXT: [[AND2:%.*]] = or i8 [[X]], -3
2551 ; CHECK-NEXT: [[VAL:%.*]] = call i8 @llvm.smin.i8(i8 [[AND1]], i8 [[AND2]])
2552 ; CHECK-NEXT: ret i8 [[VAL]]
2555 %and2 = or i8 %x, -3
2556 %val = call i8 @llvm.smin.i8(i8 %and1, i8 %and2)
2560 define i8 @smax_or_mask_negative(i8 %x) {
2561 ; CHECK-LABEL: @smax_or_mask_negative(
2562 ; CHECK-NEXT: [[AND1:%.*]] = or i8 [[X:%.*]], 1
2563 ; CHECK-NEXT: [[AND2:%.*]] = or i8 [[X]], -3
2564 ; CHECK-NEXT: [[VAL:%.*]] = call i8 @llvm.smax.i8(i8 [[AND1]], i8 [[AND2]])
2565 ; CHECK-NEXT: ret i8 [[VAL]]
2568 %and2 = or i8 %x, -3
2569 %val = call i8 @llvm.smax.i8(i8 %and1, i8 %and2)