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 define i81 @smax_sameval(i81 %x) {
19 ; CHECK-LABEL: @smax_sameval(
20 ; CHECK-NEXT: ret i81 [[X:%.*]]
22 %r = call i81 @llvm.smax.i81(i81 %x, i81 %x)
26 define i3 @smin_sameval(i3 %x) {
27 ; CHECK-LABEL: @smin_sameval(
28 ; CHECK-NEXT: ret i3 [[X:%.*]]
30 %r = call i3 @llvm.smin.i3(i3 %x, i3 %x)
34 define <2 x i8> @umax_sameval(<2 x i8> %x) {
35 ; CHECK-LABEL: @umax_sameval(
36 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
38 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> %x, <2 x i8> %x)
42 define <2 x i8> @umin_sameval(<2 x i8> %x) {
43 ; CHECK-LABEL: @umin_sameval(
44 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
46 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> %x)
50 define i81 @smax_undef(i81 %x) {
51 ; CHECK-LABEL: @smax_undef(
52 ; CHECK-NEXT: ret i81 1208925819614629174706175
54 %r = call i81 @llvm.smax.i81(i81 undef, i81 %x)
58 define i81 @smax_poison(i81 %x) {
59 ; CHECK-LABEL: @smax_poison(
60 ; CHECK-NEXT: ret i81 1208925819614629174706175
62 %r = call i81 @llvm.smax.i81(i81 poison, i81 %x)
66 define i3 @smin_undef(i3 %x) {
67 ; CHECK-LABEL: @smin_undef(
68 ; CHECK-NEXT: ret i3 -4
70 %r = call i3 @llvm.smin.i3(i3 %x, i3 undef)
74 define i3 @smin_poison(i3 %x) {
75 ; CHECK-LABEL: @smin_poison(
76 ; CHECK-NEXT: ret i3 -4
78 %r = call i3 @llvm.smin.i3(i3 %x, i3 poison)
82 define <2 x i8> @umax_undef(<2 x i8> %x) {
83 ; CHECK-LABEL: @umax_undef(
84 ; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
86 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> undef, <2 x i8> %x)
90 define <2 x i8> @umax_poison(<2 x i8> %x) {
91 ; CHECK-LABEL: @umax_poison(
92 ; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
94 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> poison, <2 x i8> %x)
98 define <2 x i8> @umin_undef(<2 x i8> %x) {
99 ; CHECK-LABEL: @umin_undef(
100 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
102 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> undef)
106 define <2 x i8> @umin_poison(<2 x i8> %x) {
107 ; CHECK-LABEL: @umin_poison(
108 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
110 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> poison)
114 define i8 @smax_maxval(i8 %x) {
115 ; CHECK-LABEL: @smax_maxval(
116 ; CHECK-NEXT: ret i8 127
118 %r = call i8 @llvm.smax.i8(i8 %x, i8 127)
122 define <2 x i8> @smax_maxval_commute(<2 x i8> %x) {
123 ; CHECK-LABEL: @smax_maxval_commute(
124 ; CHECK-NEXT: ret <2 x i8> <i8 127, i8 127>
126 %r = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 127, i8 127>, <2 x i8> %x)
130 define i8 @smin_minval(i8 %x) {
131 ; CHECK-LABEL: @smin_minval(
132 ; CHECK-NEXT: ret i8 -128
134 %r = call i8 @llvm.smin.i8(i8 -128, i8 %x)
138 define <2 x i8> @smin_minval_commute(<2 x i8> %x) {
139 ; CHECK-LABEL: @smin_minval_commute(
140 ; CHECK-NEXT: ret <2 x i8> <i8 -128, i8 -128>
142 %r = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> <i8 -128, i8 -128>)
146 define i8 @umax_maxval(i8 %x) {
147 ; CHECK-LABEL: @umax_maxval(
148 ; CHECK-NEXT: ret i8 -1
150 %r = call i8 @llvm.umax.i8(i8 %x, i8 255)
154 define <2 x i8> @umax_maxval_commute(<2 x i8> %x) {
155 ; CHECK-LABEL: @umax_maxval_commute(
156 ; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
158 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 255, i8 255>, <2 x i8> %x)
162 define i8 @umin_minval(i8 %x) {
163 ; CHECK-LABEL: @umin_minval(
164 ; CHECK-NEXT: ret i8 0
166 %r = call i8 @llvm.umin.i8(i8 0, i8 %x)
170 define <2 x i8> @umin_minval_commute(<2 x i8> %x) {
171 ; CHECK-LABEL: @umin_minval_commute(
172 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
174 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> zeroinitializer)
178 define i8 @smax_minval(i8 %x) {
179 ; CHECK-LABEL: @smax_minval(
180 ; CHECK-NEXT: ret i8 [[X:%.*]]
182 %r = call i8 @llvm.smax.i8(i8 %x, i8 -128)
186 define <2 x i8> @smax_minval_commute(<2 x i8> %x) {
187 ; CHECK-LABEL: @smax_minval_commute(
188 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
190 %r = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 -128, i8 -128>, <2 x i8> %x)
194 define i8 @smin_maxval(i8 %x) {
195 ; CHECK-LABEL: @smin_maxval(
196 ; CHECK-NEXT: ret i8 [[X:%.*]]
198 %r = call i8 @llvm.smin.i8(i8 127, i8 %x)
202 define <2 x i8> @smin_maxval_commute(<2 x i8> %x) {
203 ; CHECK-LABEL: @smin_maxval_commute(
204 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
206 %r = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> <i8 127, i8 127>)
210 define i8 @umax_minval(i8 %x) {
211 ; CHECK-LABEL: @umax_minval(
212 ; CHECK-NEXT: ret i8 [[X:%.*]]
214 %r = call i8 @llvm.umax.i8(i8 %x, i8 0)
218 define <2 x i8> @umax_minval_commute(<2 x i8> %x) {
219 ; CHECK-LABEL: @umax_minval_commute(
220 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
222 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> zeroinitializer, <2 x i8> %x)
226 define i8 @umin_maxval(i8 %x) {
227 ; CHECK-LABEL: @umin_maxval(
228 ; CHECK-NEXT: ret i8 [[X:%.*]]
230 %r = call i8 @llvm.umin.i8(i8 255, i8 %x)
234 define <2 x i8> @umin_maxval_commute(<2 x i8> %x) {
235 ; CHECK-LABEL: @umin_maxval_commute(
236 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
238 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> <i8 255, i8 255>)
242 define <2 x i8> @smax_maxval_partial_undef(<2 x i8> %x) {
243 ; CHECK-LABEL: @smax_maxval_partial_undef(
244 ; CHECK-NEXT: ret <2 x i8> <i8 127, i8 127>
246 %r = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 undef, i8 127>, <2 x i8> %x)
250 define <2 x i8> @smin_minval_partial_undef(<2 x i8> %x) {
251 ; CHECK-LABEL: @smin_minval_partial_undef(
252 ; CHECK-NEXT: ret <2 x i8> <i8 -128, i8 -128>
254 %r = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> <i8 -128, i8 undef>)
258 define <2 x i8> @umax_maxval_partial_undef(<2 x i8> %x) {
259 ; CHECK-LABEL: @umax_maxval_partial_undef(
260 ; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
262 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 255, i8 undef>, <2 x i8> %x)
266 define <2 x i8> @umin_minval_partial_undef(<2 x i8> %x) {
267 ; CHECK-LABEL: @umin_minval_partial_undef(
268 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
270 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> <i8 undef, i8 0>)
274 define <2 x i8> @smax_minval_partial_undef(<2 x i8> %x) {
275 ; CHECK-LABEL: @smax_minval_partial_undef(
276 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
278 %r = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 undef, i8 -128>, <2 x i8> %x)
282 define <2 x i8> @smin_maxval_partial_undef(<2 x i8> %x) {
283 ; CHECK-LABEL: @smin_maxval_partial_undef(
284 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
286 %r = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> <i8 undef, i8 127>)
290 define <2 x i8> @umax_minval_partial_undef(<2 x i8> %x) {
291 ; CHECK-LABEL: @umax_minval_partial_undef(
292 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
294 %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 0, i8 undef>, <2 x i8> %x)
298 define <2 x i8> @umin_maxval_partial_undef(<2 x i8> %x) {
299 ; CHECK-LABEL: @umin_maxval_partial_undef(
300 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
302 %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> <i8 255, i8 undef>)
306 define i8 @umax_umax(i8 %x, i8 %y) {
307 ; CHECK-LABEL: @umax_umax(
308 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
309 ; CHECK-NEXT: ret i8 [[M]]
311 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
312 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %m)
316 define i8 @umax_umax_commute1(i8 %x, i8 %y) {
317 ; CHECK-LABEL: @umax_umax_commute1(
318 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
319 ; CHECK-NEXT: ret i8 [[M]]
321 %m = call i8 @llvm.umax.i8(i8 %y, i8 %x)
322 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %m)
326 define i8 @umax_umax_commute2(i8 %x, i8 %y) {
327 ; CHECK-LABEL: @umax_umax_commute2(
328 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
329 ; CHECK-NEXT: ret i8 [[M]]
331 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
332 %m2 = call i8 @llvm.umax.i8(i8 %m, i8 %x)
336 define <2 x i8> @umax_umax_commute3(<2 x i8> %x, <2 x i8> %y) {
337 ; CHECK-LABEL: @umax_umax_commute3(
338 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.umax.v2i8(<2 x i8> [[Y:%.*]], <2 x i8> [[X:%.*]])
339 ; CHECK-NEXT: ret <2 x i8> [[M]]
341 %m = call <2 x i8> @llvm.umax.v2i8(<2 x i8> %y, <2 x i8> %x)
342 %m2 = call <2 x i8> @llvm.umax.v2i8(<2 x i8> %m, <2 x i8> %x)
346 define i8 @umin_umin(i8 %x, i8 %y) {
347 ; CHECK-LABEL: @umin_umin(
348 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
349 ; CHECK-NEXT: ret i8 [[M]]
351 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
352 %m2 = call i8 @llvm.umin.i8(i8 %x, i8 %m)
356 define i8 @umin_umin_commute1(i8 %x, i8 %y) {
357 ; CHECK-LABEL: @umin_umin_commute1(
358 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
359 ; CHECK-NEXT: ret i8 [[M]]
361 %m = call i8 @llvm.umin.i8(i8 %y, i8 %x)
362 %m2 = call i8 @llvm.umin.i8(i8 %x, i8 %m)
366 define <2 x i8> @umin_umin_commute2(<2 x i8> %x, <2 x i8> %y) {
367 ; CHECK-LABEL: @umin_umin_commute2(
368 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.umin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]])
369 ; CHECK-NEXT: ret <2 x i8> [[M]]
371 %m = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> %y)
372 %m2 = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %m, <2 x i8> %x)
376 define i8 @umin_umin_commute3(i8 %x, i8 %y) {
377 ; CHECK-LABEL: @umin_umin_commute3(
378 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
379 ; CHECK-NEXT: ret i8 [[M]]
381 %m = call i8 @llvm.umin.i8(i8 %y, i8 %x)
382 %m2 = call i8 @llvm.umin.i8(i8 %m, i8 %x)
386 define i8 @smax_smax(i8 %x, i8 %y) {
387 ; CHECK-LABEL: @smax_smax(
388 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
389 ; CHECK-NEXT: ret i8 [[M]]
391 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
392 %m2 = call i8 @llvm.smax.i8(i8 %x, i8 %m)
396 define <2 x i8> @smax_smax_commute1(<2 x i8> %x, <2 x i8> %y) {
397 ; CHECK-LABEL: @smax_smax_commute1(
398 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.smax.v2i8(<2 x i8> [[Y:%.*]], <2 x i8> [[X:%.*]])
399 ; CHECK-NEXT: ret <2 x i8> [[M]]
401 %m = call <2 x i8> @llvm.smax.v2i8(<2 x i8> %y, <2 x i8> %x)
402 %m2 = call <2 x i8> @llvm.smax.v2i8(<2 x i8> %x, <2 x i8> %m)
406 define i8 @smax_smax_commute2(i8 %x, i8 %y) {
407 ; CHECK-LABEL: @smax_smax_commute2(
408 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
409 ; CHECK-NEXT: ret i8 [[M]]
411 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
412 %m2 = call i8 @llvm.smax.i8(i8 %m, i8 %x)
416 define i8 @smax_smax_commute3(i8 %x, i8 %y) {
417 ; CHECK-LABEL: @smax_smax_commute3(
418 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
419 ; CHECK-NEXT: ret i8 [[M]]
421 %m = call i8 @llvm.smax.i8(i8 %y, i8 %x)
422 %m2 = call i8 @llvm.smax.i8(i8 %m, i8 %x)
426 define <2 x i8> @smin_smin(<2 x i8> %x, <2 x i8> %y) {
427 ; CHECK-LABEL: @smin_smin(
428 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.smin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]])
429 ; CHECK-NEXT: ret <2 x i8> [[M]]
431 %m = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> %y)
432 %m2 = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> %m)
436 define i8 @smin_smin_commute1(i8 %x, i8 %y) {
437 ; CHECK-LABEL: @smin_smin_commute1(
438 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
439 ; CHECK-NEXT: ret i8 [[M]]
441 %m = call i8 @llvm.smin.i8(i8 %y, i8 %x)
442 %m2 = call i8 @llvm.smin.i8(i8 %x, i8 %m)
446 define i8 @smin_smin_commute2(i8 %x, i8 %y) {
447 ; CHECK-LABEL: @smin_smin_commute2(
448 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
449 ; CHECK-NEXT: ret i8 [[M]]
451 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
452 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 %x)
456 define i8 @smin_smin_commute3(i8 %x, i8 %y) {
457 ; CHECK-LABEL: @smin_smin_commute3(
458 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
459 ; CHECK-NEXT: ret i8 [[M]]
461 %m = call i8 @llvm.smin.i8(i8 %y, i8 %x)
462 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 %x)
466 define i8 @umax_umin(i8 %x, i8 %y) {
467 ; CHECK-LABEL: @umax_umin(
468 ; CHECK-NEXT: ret i8 [[X:%.*]]
470 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
471 %m2 = call i8 @llvm.umin.i8(i8 %x, i8 %m)
475 define i8 @umax_umin_commute1(i8 %x, i8 %y) {
476 ; CHECK-LABEL: @umax_umin_commute1(
477 ; CHECK-NEXT: ret i8 [[X:%.*]]
479 %m = call i8 @llvm.umax.i8(i8 %y, i8 %x)
480 %m2 = call i8 @llvm.umin.i8(i8 %x, i8 %m)
484 define i8 @umax_umin_commute2(i8 %x, i8 %y) {
485 ; CHECK-LABEL: @umax_umin_commute2(
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 %m, i8 %x)
493 define <2 x i8> @umax_umin_commute3(<2 x i8> %x, <2 x i8> %y) {
494 ; CHECK-LABEL: @umax_umin_commute3(
495 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
497 %m = call <2 x i8> @llvm.umax.v2i8(<2 x i8> %y, <2 x i8> %x)
498 %m2 = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %m, <2 x i8> %x)
502 define i8 @umin_umax(i8 %x, i8 %y) {
503 ; CHECK-LABEL: @umin_umax(
504 ; CHECK-NEXT: ret i8 [[X:%.*]]
506 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
507 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %m)
511 define i8 @umin_umax_commute1(i8 %x, i8 %y) {
512 ; CHECK-LABEL: @umin_umax_commute1(
513 ; CHECK-NEXT: ret i8 [[X:%.*]]
515 %m = call i8 @llvm.umin.i8(i8 %y, i8 %x)
516 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %m)
520 define <2 x i8> @umin_umax_commute2(<2 x i8> %x, <2 x i8> %y) {
521 ; CHECK-LABEL: @umin_umax_commute2(
522 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
524 %m = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> %y)
525 %m2 = call <2 x i8> @llvm.umax.v2i8(<2 x i8> %m, <2 x i8> %x)
529 define i8 @umin_umax_commute3(i8 %x, i8 %y) {
530 ; CHECK-LABEL: @umin_umax_commute3(
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 %m, i8 %x)
538 define i8 @smax_smin(i8 %x, i8 %y) {
539 ; CHECK-LABEL: @smax_smin(
540 ; CHECK-NEXT: ret i8 [[X:%.*]]
542 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
543 %m2 = call i8 @llvm.smin.i8(i8 %x, i8 %m)
547 define <2 x i8> @smax_smin_commute1(<2 x i8> %x, <2 x i8> %y) {
548 ; CHECK-LABEL: @smax_smin_commute1(
549 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
551 %m = call <2 x i8> @llvm.smax.v2i8(<2 x i8> %y, <2 x i8> %x)
552 %m2 = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> %m)
556 define i8 @smax_smin_commute2(i8 %x, i8 %y) {
557 ; CHECK-LABEL: @smax_smin_commute2(
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 %m, i8 %x)
565 define i8 @smax_smin_commute3(i8 %x, i8 %y) {
566 ; CHECK-LABEL: @smax_smin_commute3(
567 ; CHECK-NEXT: ret i8 [[X:%.*]]
569 %m = call i8 @llvm.smax.i8(i8 %y, i8 %x)
570 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 %x)
574 define <2 x i8> @smin_smax(<2 x i8> %x, <2 x i8> %y) {
575 ; CHECK-LABEL: @smin_smax(
576 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
578 %m = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> %y)
579 %m2 = call <2 x i8> @llvm.smax.v2i8(<2 x i8> %x, <2 x i8> %m)
583 define i8 @smin_smax_commute1(i8 %x, i8 %y) {
584 ; CHECK-LABEL: @smin_smax_commute1(
585 ; CHECK-NEXT: ret i8 [[X:%.*]]
587 %m = call i8 @llvm.smin.i8(i8 %y, i8 %x)
588 %m2 = call i8 @llvm.smax.i8(i8 %x, i8 %m)
592 define i8 @smin_smax_commute2(i8 %x, i8 %y) {
593 ; CHECK-LABEL: @smin_smax_commute2(
594 ; CHECK-NEXT: ret i8 [[X:%.*]]
596 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
597 %m2 = call i8 @llvm.smax.i8(i8 %m, i8 %x)
601 define i8 @smin_smax_commute3(i8 %x, i8 %y) {
602 ; CHECK-LABEL: @smin_smax_commute3(
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 %m, i8 %x)
610 ; Negative test - mismatched intrinsics.
612 define i8 @smax_umin(i8 %x, i8 %y) {
613 ; CHECK-LABEL: @smax_umin(
614 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
615 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[M]], i8 [[X]])
616 ; CHECK-NEXT: ret i8 [[M2]]
618 %m = call i8 @llvm.smax.i8(i8 %y, i8 %x)
619 %m2 = call i8 @llvm.umin.i8(i8 %m, i8 %x)
623 ; Negative test - mismatched intrinsics.
625 define i8 @smax_umax(i8 %x, i8 %y) {
626 ; CHECK-LABEL: @smax_umax(
627 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
628 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[M]], i8 [[X]])
629 ; CHECK-NEXT: ret i8 [[M2]]
631 %m = call i8 @llvm.smax.i8(i8 %y, i8 %x)
632 %m2 = call i8 @llvm.umax.i8(i8 %m, i8 %x)
636 ; Negative test - mismatched intrinsics.
638 define i8 @umax_smin(i8 %x, i8 %y) {
639 ; CHECK-LABEL: @umax_smin(
640 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
641 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[M]], i8 [[X]])
642 ; CHECK-NEXT: ret i8 [[M2]]
644 %m = call i8 @llvm.umax.i8(i8 %y, i8 %x)
645 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 %x)
649 ; Negative test - mismatched intrinsics.
651 define i8 @umin_smin(i8 %x, i8 %y) {
652 ; CHECK-LABEL: @umin_smin(
653 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
654 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[M]], i8 [[X]])
655 ; CHECK-NEXT: ret i8 [[M2]]
657 %m = call i8 @llvm.umin.i8(i8 %y, i8 %x)
658 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 %x)
662 define i8 @umax_umax_constants(i8 %x) {
663 ; CHECK-LABEL: @umax_umax_constants(
664 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 9)
665 ; CHECK-NEXT: ret i8 [[M]]
667 %m = call i8 @llvm.umax.i8(i8 %x, i8 9)
668 %m2 = call i8 @llvm.umax.i8(i8 7, i8 %m)
672 define i8 @umax_umax_constants_commute1(i8 %x) {
673 ; CHECK-LABEL: @umax_umax_constants_commute1(
674 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 -128, i8 [[X:%.*]])
675 ; CHECK-NEXT: ret i8 [[M]]
677 %m = call i8 @llvm.umax.i8(i8 128, i8 %x)
678 %m2 = call i8 @llvm.umax.i8(i8 7, i8 %m)
682 define i8 @umax_umax_constants_commute2(i8 %x) {
683 ; CHECK-LABEL: @umax_umax_constants_commute2(
684 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 -56)
685 ; CHECK-NEXT: ret i8 [[M]]
687 %m = call i8 @llvm.umax.i8(i8 %x, i8 200)
688 %m2 = call i8 @llvm.umax.i8(i8 %m, i8 127)
692 define <2 x i8> @umax_umax_constants_commute3(<2 x i8> %x) {
693 ; CHECK-LABEL: @umax_umax_constants_commute3(
694 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 -2, i8 -2>, <2 x i8> [[X:%.*]])
695 ; CHECK-NEXT: ret <2 x i8> [[M]]
697 %m = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 254, i8 254>, <2 x i8> %x)
698 %m2 = call <2 x i8> @llvm.umax.v2i8(<2 x i8> %m, <2 x i8> <i8 128, i8 128>)
702 define i8 @umin_umin_constants(i8 %x) {
703 ; CHECK-LABEL: @umin_umin_constants(
704 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 7)
705 ; CHECK-NEXT: ret i8 [[M]]
707 %m = call i8 @llvm.umin.i8(i8 %x, i8 7)
708 %m2 = call i8 @llvm.umin.i8(i8 9, i8 %m)
712 define i8 @umin_umin_constants_commute1(i8 %x) {
713 ; CHECK-LABEL: @umin_umin_constants_commute1(
714 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 7, i8 [[X:%.*]])
715 ; CHECK-NEXT: ret i8 [[M]]
717 %m = call i8 @llvm.umin.i8(i8 7, i8 %x)
718 %m2 = call i8 @llvm.umin.i8(i8 128, i8 %m)
722 define <2 x i8> @umin_umin_constants_commute2(<2 x i8> %x) {
723 ; CHECK-LABEL: @umin_umin_constants_commute2(
724 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.umin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> <i8 127, i8 127>)
725 ; CHECK-NEXT: ret <2 x i8> [[M]]
727 %m = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> <i8 127, i8 127>)
728 %m2 = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %m, <2 x i8> <i8 200, i8 undef>)
732 define i8 @umin_umin_constants_commute3(i8 %x) {
733 ; CHECK-LABEL: @umin_umin_constants_commute3(
734 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 -128, i8 [[X:%.*]])
735 ; CHECK-NEXT: ret i8 [[M]]
737 %m = call i8 @llvm.umin.i8(i8 128, i8 %x)
738 %m2 = call i8 @llvm.umin.i8(i8 %m, i8 254)
742 define i8 @smax_smax_constants(i8 %x) {
743 ; CHECK-LABEL: @smax_smax_constants(
744 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 9)
745 ; CHECK-NEXT: ret i8 [[M]]
747 %m = call i8 @llvm.smax.i8(i8 %x, i8 9)
748 %m2 = call i8 @llvm.smax.i8(i8 7, i8 %m)
752 define <2 x i8> @smax_smax_constants_commute1(<2 x i8> %x) {
753 ; CHECK-LABEL: @smax_smax_constants_commute1(
754 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 7, i8 7>, <2 x i8> [[X:%.*]])
755 ; CHECK-NEXT: ret <2 x i8> [[M]]
757 %m = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 7, i8 7>, <2 x i8> %x)
758 %m2 = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 -127, i8 -127>, <2 x i8> %m)
762 define i8 @smax_smax_constants_commute2(i8 %x) {
763 ; CHECK-LABEL: @smax_smax_constants_commute2(
764 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 0)
765 ; CHECK-NEXT: ret i8 [[M]]
767 %m = call i8 @llvm.smax.i8(i8 %x, i8 0)
768 %m2 = call i8 @llvm.smax.i8(i8 %m, i8 -1)
772 define i8 @smax_smax_constants_commute3(i8 %x) {
773 ; CHECK-LABEL: @smax_smax_constants_commute3(
774 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 -1, i8 [[X:%.*]])
775 ; CHECK-NEXT: ret i8 [[M]]
777 %m = call i8 @llvm.smax.i8(i8 -1, i8 %x)
778 %m2 = call i8 @llvm.smax.i8(i8 %m, i8 -127)
782 define <2 x i8> @smin_smin_constants(<2 x i8> %x) {
783 ; CHECK-LABEL: @smin_smin_constants(
784 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.smin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> <i8 7, i8 7>)
785 ; CHECK-NEXT: ret <2 x i8> [[M]]
787 %m = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> <i8 7, i8 7>)
788 %m2 = call <2 x i8> @llvm.smin.v2i8(<2 x i8> <i8 undef, i8 9>, <2 x i8> %m)
792 define i8 @smin_smin_constants_commute1(i8 %x) {
793 ; CHECK-LABEL: @smin_smin_constants_commute1(
794 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 -127, i8 [[X:%.*]])
795 ; CHECK-NEXT: ret i8 [[M]]
797 %m = call i8 @llvm.smin.i8(i8 -127, i8 %x)
798 %m2 = call i8 @llvm.smin.i8(i8 7, i8 %m)
802 define i8 @smin_smin_constants_commute2(i8 %x) {
803 ; CHECK-LABEL: @smin_smin_constants_commute2(
804 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 -1)
805 ; CHECK-NEXT: ret i8 [[M]]
807 %m = call i8 @llvm.smin.i8(i8 %x, i8 -1)
808 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 0)
812 define i8 @smin_smin_constants_commute3(i8 %x) {
813 ; CHECK-LABEL: @smin_smin_constants_commute3(
814 ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 -127, i8 [[X:%.*]])
815 ; CHECK-NEXT: ret i8 [[M]]
817 %m = call i8 @llvm.smin.i8(i8 -127, i8 %x)
818 %m2 = call i8 @llvm.smin.i8(i8 %m, i8 -1)
822 ; Negative test - undef in inner constant must not propagate.
824 define <2 x i8> @umin_umin_constants_partial_undef(<2 x i8> %x) {
825 ; CHECK-LABEL: @umin_umin_constants_partial_undef(
826 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.umin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> <i8 7, i8 undef>)
827 ; CHECK-NEXT: [[M2:%.*]] = call <2 x i8> @llvm.umin.v2i8(<2 x i8> <i8 9, i8 9>, <2 x i8> [[M]])
828 ; CHECK-NEXT: ret <2 x i8> [[M2]]
830 %m = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> <i8 7, i8 undef> )
831 %m2 = call <2 x i8> @llvm.umin.v2i8(<2 x i8> <i8 9, i8 9>, <2 x i8> %m)
835 ; Negative test - undef in inner constant must not propagate.
837 define <2 x i8> @smax_smax_constants_partial_undef(<2 x i8> %x) {
838 ; CHECK-LABEL: @smax_smax_constants_partial_undef(
839 ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.smax.v2i8(<2 x i8> [[X:%.*]], <2 x i8> <i8 undef, i8 10>)
840 ; CHECK-NEXT: [[M2:%.*]] = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 9, i8 9>, <2 x i8> [[M]])
841 ; CHECK-NEXT: ret <2 x i8> [[M2]]
843 %m = call <2 x i8> @llvm.smax.v2i8(<2 x i8> %x, <2 x i8> <i8 undef, i8 10> )
844 %m2 = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 9, i8 9>, <2 x i8> %m)
848 define i1 @smax_slt(i8 %x, i8 %y) {
849 ; CHECK-LABEL: @smax_slt(
850 ; CHECK-NEXT: ret i1 false
852 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
853 %r = icmp slt i8 %m, %x
857 define i1 @smax_sge(i8 %x, i8 %y) {
858 ; CHECK-LABEL: @smax_sge(
859 ; CHECK-NEXT: ret i1 true
861 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
862 %r = icmp sge i8 %m, %x
866 define i1 @umax_ult(i8 %x, i8 %y) {
867 ; CHECK-LABEL: @umax_ult(
868 ; CHECK-NEXT: ret i1 false
870 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
871 %r = icmp ult i8 %m, %x
875 define i1 @umax_uge(i8 %x, i8 %y) {
876 ; CHECK-LABEL: @umax_uge(
877 ; CHECK-NEXT: ret i1 true
879 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
880 %r = icmp uge i8 %m, %x
884 define i1 @smax_sgt(i8 %x, i8 %y) {
885 ; CHECK-LABEL: @smax_sgt(
886 ; CHECK-NEXT: ret i1 false
888 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
889 %r = icmp sgt i8 %x, %m
893 define i1 @smax_sle(i8 %x, i8 %y) {
894 ; CHECK-LABEL: @smax_sle(
895 ; CHECK-NEXT: ret i1 true
897 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
898 %r = icmp sle i8 %x, %m
902 define i1 @umax_ugt(i8 %x, i8 %y) {
903 ; CHECK-LABEL: @umax_ugt(
904 ; CHECK-NEXT: ret i1 false
906 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
907 %r = icmp ugt i8 %x, %m
911 define i1 @umax_ule(i8 %x, i8 %y) {
912 ; CHECK-LABEL: @umax_ule(
913 ; CHECK-NEXT: ret i1 true
915 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
916 %r = icmp ule i8 %x, %m
920 define i1 @smin_sgt(i8 %x, i8 %y) {
921 ; CHECK-LABEL: @smin_sgt(
922 ; CHECK-NEXT: ret i1 false
924 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
925 %r = icmp sgt i8 %m, %x
929 define i1 @smin_sle(i8 %x, i8 %y) {
930 ; CHECK-LABEL: @smin_sle(
931 ; CHECK-NEXT: ret i1 true
933 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
934 %r = icmp sle i8 %m, %x
938 define i1 @umin_ugt(i8 %x, i8 %y) {
939 ; CHECK-LABEL: @umin_ugt(
940 ; CHECK-NEXT: ret i1 false
942 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
943 %r = icmp ugt i8 %m, %x
947 define i1 @umin_ule(i8 %x, i8 %y) {
948 ; CHECK-LABEL: @umin_ule(
949 ; CHECK-NEXT: ret i1 true
951 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
952 %r = icmp ule i8 %m, %x
956 define i1 @smin_slt(i8 %x, i8 %y) {
957 ; CHECK-LABEL: @smin_slt(
958 ; CHECK-NEXT: ret i1 false
960 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
961 %r = icmp slt i8 %x, %m
965 define i1 @smin_sge(i8 %x, i8 %y) {
966 ; CHECK-LABEL: @smin_sge(
967 ; CHECK-NEXT: ret i1 true
969 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
970 %r = icmp sge i8 %x, %m
974 define i1 @umin_ult(i8 %x, i8 %y) {
975 ; CHECK-LABEL: @umin_ult(
976 ; CHECK-NEXT: ret i1 false
978 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
979 %r = icmp ult i8 %x, %m
983 define i1 @umin_uge(i8 %x, i8 %y) {
984 ; CHECK-LABEL: @umin_uge(
985 ; CHECK-NEXT: ret i1 true
987 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
988 %r = icmp uge i8 %x, %m
992 define i1 @smaxmin_sge(i8 %x, i8 %y, i8 %z) {
993 ; CHECK-LABEL: @smaxmin_sge(
994 ; CHECK-NEXT: ret i1 true
996 %max = call i8 @llvm.smax.i8(i8 %x, i8 %y)
997 %min = call i8 @llvm.smin.i8(i8 %z, i8 %x)
998 %c = icmp sge i8 %max, %min
1002 define i1 @smaxmin_sgt(i8 %x, i8 %y, i8 %z) {
1003 ; CHECK-LABEL: @smaxmin_sgt(
1004 ; CHECK-NEXT: ret i1 false
1006 %max = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1007 %min = call i8 @llvm.smin.i8(i8 %z, i8 %x)
1008 %c = icmp sgt i8 %min, %max
1012 define i1 @smaxmin_sle(i8 %x, i8 %y, i8 %z) {
1013 ; CHECK-LABEL: @smaxmin_sle(
1014 ; CHECK-NEXT: ret i1 true
1016 %max = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1017 %min = call i8 @llvm.smin.i8(i8 %z, i8 %x)
1018 %c = icmp sle i8 %min, %max
1022 define i1 @smaxmin_slt(i8 %x, i8 %y, i8 %z) {
1023 ; CHECK-LABEL: @smaxmin_slt(
1024 ; CHECK-NEXT: ret i1 false
1026 %max = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1027 %min = call i8 @llvm.smin.i8(i8 %z, i8 %x)
1028 %c = icmp slt i8 %max, %min
1032 define i1 @umaxmin_uge(i8 %x, i8 %y, i8 %z) {
1033 ; CHECK-LABEL: @umaxmin_uge(
1034 ; CHECK-NEXT: ret i1 true
1036 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1037 %min = call i8 @llvm.umin.i8(i8 %z, i8 %x)
1038 %c = icmp uge i8 %max, %min
1042 define i1 @umaxmin_ugt(i8 %x, i8 %y, i8 %z) {
1043 ; CHECK-LABEL: @umaxmin_ugt(
1044 ; CHECK-NEXT: ret i1 false
1046 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1047 %min = call i8 @llvm.umin.i8(i8 %z, i8 %x)
1048 %c = icmp ugt i8 %min, %max
1052 define i1 @umaxmin_ule(i8 %x, i8 %y, i8 %z) {
1053 ; CHECK-LABEL: @umaxmin_ule(
1054 ; CHECK-NEXT: ret i1 true
1056 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1057 %min = call i8 @llvm.umin.i8(i8 %z, i8 %x)
1058 %c = icmp ule i8 %min, %max
1062 define i1 @umaxmin_ult(i8 %x, i8 %y, i8 %z) {
1063 ; CHECK-LABEL: @umaxmin_ult(
1064 ; CHECK-NEXT: ret i1 false
1066 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1067 %min = call i8 @llvm.umin.i8(i8 %z, i8 %x)
1068 %c = icmp ult i8 %max, %min
1072 ; Negative test - should reduce via instcombine, but not here.
1074 define i1 @smax_eq(i8 %x, i8 %y) {
1075 ; CHECK-LABEL: @smax_eq(
1076 ; CHECK-NEXT: [[MAX:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1077 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[MAX]], [[X]]
1078 ; CHECK-NEXT: ret i1 [[R]]
1080 %max = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1081 %r = icmp eq i8 %max, %x
1085 ; Negative test - should reduce via instcombine, but not here.
1087 define i1 @smax_eq_commute(i8 %x, i8 %y) {
1088 ; CHECK-LABEL: @smax_eq_commute(
1089 ; CHECK-NEXT: [[MAX:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1090 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[X]], [[MAX]]
1091 ; CHECK-NEXT: ret i1 [[R]]
1093 %max = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1094 %r = icmp eq i8 %x, %max
1098 ; Negative test - should reduce via instcombine, but not here.
1100 define i1 @umax_eq(i8 %x, i8 %y) {
1101 ; CHECK-LABEL: @umax_eq(
1102 ; CHECK-NEXT: [[MAX:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1103 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[MAX]], [[X]]
1104 ; CHECK-NEXT: ret i1 [[R]]
1106 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1107 %r = icmp eq i8 %max, %x
1111 ; Negative test - should reduce via instcombine, but not here.
1113 define i1 @umax_eq_commute(i8 %x, i8 %y) {
1114 ; CHECK-LABEL: @umax_eq_commute(
1115 ; CHECK-NEXT: [[MAX:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1116 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[X]], [[MAX]]
1117 ; CHECK-NEXT: ret i1 [[R]]
1119 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1120 %r = icmp eq i8 %x, %max
1124 define i8 @smax_smax_smax(i8 %x, i8 %y) {
1125 ; CHECK-LABEL: @smax_smax_smax(
1126 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1127 ; CHECK-NEXT: ret i8 [[M1]]
1129 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1130 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1131 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1135 define i8 @smax_smax_smin(i8 %x, i8 %y) {
1136 ; CHECK-LABEL: @smax_smax_smin(
1137 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1138 ; CHECK-NEXT: ret i8 [[M1]]
1140 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1141 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1142 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1146 define i8 @smax_smax_umax(i8 %x, i8 %y) {
1147 ; CHECK-LABEL: @smax_smax_umax(
1148 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1149 ; CHECK-NEXT: ret i8 [[M1]]
1151 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1152 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1153 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1157 define i8 @smax_smax_umin(i8 %x, i8 %y) {
1158 ; CHECK-LABEL: @smax_smax_umin(
1159 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1160 ; CHECK-NEXT: ret i8 [[M1]]
1162 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1163 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1164 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1168 define i8 @smax_smin_smax(i8 %x, i8 %y) {
1169 ; CHECK-LABEL: @smax_smin_smax(
1170 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1171 ; CHECK-NEXT: ret i8 [[M2]]
1173 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1174 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1175 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1179 define i8 @smax_smin_smin(i8 %x, i8 %y) {
1180 ; CHECK-LABEL: @smax_smin_smin(
1181 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1182 ; CHECK-NEXT: ret i8 [[M2]]
1184 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1185 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1186 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1190 define i8 @smax_smin_umax(i8 %x, i8 %y) {
1191 ; CHECK-LABEL: @smax_smin_umax(
1192 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1193 ; CHECK-NEXT: ret i8 [[M2]]
1195 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1196 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1197 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1201 define i8 @smax_smin_umin(i8 %x, i8 %y) {
1202 ; CHECK-LABEL: @smax_smin_umin(
1203 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1204 ; CHECK-NEXT: ret i8 [[M2]]
1206 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1207 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1208 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1212 define i8 @smax_umax_smax(i8 %x, i8 %y) {
1213 ; CHECK-LABEL: @smax_umax_smax(
1214 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1215 ; CHECK-NEXT: ret i8 [[M2]]
1217 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1218 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1219 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1223 define i8 @smax_umax_smin(i8 %x, i8 %y) {
1224 ; CHECK-LABEL: @smax_umax_smin(
1225 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1226 ; CHECK-NEXT: ret i8 [[M1]]
1228 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1229 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1230 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1234 ; This could simplify (commuted min/max op).
1236 define i8 @smax_umax_umax(i8 %x, i8 %y) {
1237 ; CHECK-LABEL: @smax_umax_umax(
1238 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1239 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y]], i8 [[X]])
1240 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smax.i8(i8 [[M1]], i8 [[M2]])
1241 ; CHECK-NEXT: ret i8 [[R]]
1243 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1244 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1245 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1249 ; This could combine - smax(x,y) - but does not simplify.
1251 define i8 @smax_umax_umin(i8 %x, i8 %y) {
1252 ; CHECK-LABEL: @smax_umax_umin(
1253 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1254 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y]], i8 [[X]])
1255 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smax.i8(i8 [[M1]], i8 [[M2]])
1256 ; CHECK-NEXT: ret i8 [[R]]
1258 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1259 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1260 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1264 define i8 @smax_umin_smax(i8 %x, i8 %y) {
1265 ; CHECK-LABEL: @smax_umin_smax(
1266 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1267 ; CHECK-NEXT: ret i8 [[M2]]
1269 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1270 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1271 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1275 define i8 @smax_umin_smin(i8 %x, i8 %y) {
1276 ; CHECK-LABEL: @smax_umin_smin(
1277 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1278 ; CHECK-NEXT: ret i8 [[M1]]
1280 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1281 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1282 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1286 ; This could combine - smax(x,y) - but does not simplify.
1288 define i8 @smax_umin_umax(i8 %x, i8 %y) {
1289 ; CHECK-LABEL: @smax_umin_umax(
1290 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1291 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y]], i8 [[X]])
1292 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smax.i8(i8 [[M1]], i8 [[M2]])
1293 ; CHECK-NEXT: ret i8 [[R]]
1295 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1296 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1297 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1301 ; This could simplify (commuted min/max op).
1303 define i8 @smax_umin_umin(i8 %x, i8 %y) {
1304 ; CHECK-LABEL: @smax_umin_umin(
1305 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1306 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y]], i8 [[X]])
1307 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smax.i8(i8 [[M1]], i8 [[M2]])
1308 ; CHECK-NEXT: ret i8 [[R]]
1310 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1311 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1312 %r = call i8 @llvm.smax.i8(i8 %m1, i8 %m2)
1316 define i8 @smin_smax_smax(i8 %x, i8 %y) {
1317 ; CHECK-LABEL: @smin_smax_smax(
1318 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1319 ; CHECK-NEXT: ret i8 [[M2]]
1321 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1322 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1323 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1327 define i8 @smin_smax_smin(i8 %x, i8 %y) {
1328 ; CHECK-LABEL: @smin_smax_smin(
1329 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1330 ; CHECK-NEXT: ret i8 [[M2]]
1332 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1333 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1334 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1338 define i8 @smin_smax_umax(i8 %x, i8 %y) {
1339 ; CHECK-LABEL: @smin_smax_umax(
1340 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1341 ; CHECK-NEXT: ret i8 [[M2]]
1343 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1344 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1345 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1349 define i8 @smin_smax_umin(i8 %x, i8 %y) {
1350 ; CHECK-LABEL: @smin_smax_umin(
1351 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1352 ; CHECK-NEXT: ret i8 [[M2]]
1354 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1355 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1356 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1360 define i8 @smin_smin_smax(i8 %x, i8 %y) {
1361 ; CHECK-LABEL: @smin_smin_smax(
1362 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1363 ; CHECK-NEXT: ret i8 [[M1]]
1365 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1366 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1367 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1371 define i8 @smin_smin_smin(i8 %x, i8 %y) {
1372 ; CHECK-LABEL: @smin_smin_smin(
1373 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1374 ; CHECK-NEXT: ret i8 [[M1]]
1376 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1377 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1378 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1382 define i8 @smin_smin_umax(i8 %x, i8 %y) {
1383 ; CHECK-LABEL: @smin_smin_umax(
1384 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1385 ; CHECK-NEXT: ret i8 [[M1]]
1387 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1388 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1389 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1393 define i8 @smin_smin_umin(i8 %x, i8 %y) {
1394 ; CHECK-LABEL: @smin_smin_umin(
1395 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1396 ; CHECK-NEXT: ret i8 [[M1]]
1398 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1399 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1400 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1404 define i8 @smin_umax_smax(i8 %x, i8 %y) {
1405 ; CHECK-LABEL: @smin_umax_smax(
1406 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1407 ; CHECK-NEXT: ret i8 [[M1]]
1409 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1410 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1411 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1415 define i8 @smin_umax_smin(i8 %x, i8 %y) {
1416 ; CHECK-LABEL: @smin_umax_smin(
1417 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1418 ; CHECK-NEXT: ret i8 [[M2]]
1420 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1421 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1422 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1426 ; This could simplify (commuted min/max op).
1428 define i8 @smin_umax_umax(i8 %x, i8 %y) {
1429 ; CHECK-LABEL: @smin_umax_umax(
1430 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1431 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y]], i8 [[X]])
1432 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smin.i8(i8 [[M1]], i8 [[M2]])
1433 ; CHECK-NEXT: ret i8 [[R]]
1435 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1436 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1437 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1441 ; This could combine - smin(x,y) - but does not simplify.
1443 define i8 @smin_umax_umin(i8 %x, i8 %y) {
1444 ; CHECK-LABEL: @smin_umax_umin(
1445 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1446 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y]], i8 [[X]])
1447 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smin.i8(i8 [[M1]], i8 [[M2]])
1448 ; CHECK-NEXT: ret i8 [[R]]
1450 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1451 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1452 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1456 define i8 @smin_umin_smax(i8 %x, i8 %y) {
1457 ; CHECK-LABEL: @smin_umin_smax(
1458 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1459 ; CHECK-NEXT: ret i8 [[M1]]
1461 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1462 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1463 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1467 define i8 @smin_umin_smin(i8 %x, i8 %y) {
1468 ; CHECK-LABEL: @smin_umin_smin(
1469 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1470 ; CHECK-NEXT: ret i8 [[M2]]
1472 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1473 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1474 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1478 ; This could combine - smin(x,y) - but does not simplify.
1480 define i8 @smin_umin_umax(i8 %x, i8 %y) {
1481 ; CHECK-LABEL: @smin_umin_umax(
1482 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1483 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y]], i8 [[X]])
1484 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smin.i8(i8 [[M1]], i8 [[M2]])
1485 ; CHECK-NEXT: ret i8 [[R]]
1487 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1488 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1489 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1493 ; This could simplify (commuted min/max op).
1495 define i8 @smin_umin_umin(i8 %x, i8 %y) {
1496 ; CHECK-LABEL: @smin_umin_umin(
1497 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1498 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y]], i8 [[X]])
1499 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smin.i8(i8 [[M1]], i8 [[M2]])
1500 ; CHECK-NEXT: ret i8 [[R]]
1502 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1503 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1504 %r = call i8 @llvm.smin.i8(i8 %m1, i8 %m2)
1508 ; This could simplify (commuted min/max op).
1510 define i8 @umax_smax_smax(i8 %x, i8 %y) {
1511 ; CHECK-LABEL: @umax_smax_smax(
1512 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1513 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y]], i8 [[X]])
1514 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umax.i8(i8 [[M1]], i8 [[M2]])
1515 ; CHECK-NEXT: ret i8 [[R]]
1517 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1518 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1519 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1523 ; This could combine - umax(x,y) - but does not simplify.
1525 define i8 @umax_smax_smin(i8 %x, i8 %y) {
1526 ; CHECK-LABEL: @umax_smax_smin(
1527 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1528 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y]], i8 [[X]])
1529 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umax.i8(i8 [[M1]], i8 [[M2]])
1530 ; CHECK-NEXT: ret i8 [[R]]
1532 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1533 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1534 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1538 define i8 @umax_smax_umax(i8 %x, i8 %y) {
1539 ; CHECK-LABEL: @umax_smax_umax(
1540 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1541 ; CHECK-NEXT: ret i8 [[M2]]
1543 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1544 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1545 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1549 define i8 @umax_smax_umin(i8 %x, i8 %y) {
1550 ; CHECK-LABEL: @umax_smax_umin(
1551 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1552 ; CHECK-NEXT: ret i8 [[M1]]
1554 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1555 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1556 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1560 ; This could combine - umax(x,y) - but does not simplify.
1562 define i8 @umax_smin_smax(i8 %x, i8 %y) {
1563 ; CHECK-LABEL: @umax_smin_smax(
1564 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1565 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y]], i8 [[X]])
1566 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umax.i8(i8 [[M1]], i8 [[M2]])
1567 ; CHECK-NEXT: ret i8 [[R]]
1569 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1570 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1571 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1575 ; This could simplify (commuted min/max op).
1577 define i8 @umax_smin_smin(i8 %x, i8 %y) {
1578 ; CHECK-LABEL: @umax_smin_smin(
1579 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1580 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y]], i8 [[X]])
1581 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umax.i8(i8 [[M1]], i8 [[M2]])
1582 ; CHECK-NEXT: ret i8 [[R]]
1584 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1585 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1586 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1590 define i8 @umax_smin_umax(i8 %x, i8 %y) {
1591 ; CHECK-LABEL: @umax_smin_umax(
1592 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1593 ; CHECK-NEXT: ret i8 [[M2]]
1595 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1596 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1597 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1601 define i8 @umax_smin_umin(i8 %x, i8 %y) {
1602 ; CHECK-LABEL: @umax_smin_umin(
1603 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1604 ; CHECK-NEXT: ret i8 [[M1]]
1606 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1607 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1608 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1612 define i8 @umax_umax_smax(i8 %x, i8 %y) {
1613 ; CHECK-LABEL: @umax_umax_smax(
1614 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1615 ; CHECK-NEXT: ret i8 [[M1]]
1617 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1618 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1619 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1623 define i8 @umax_umax_smin(i8 %x, i8 %y) {
1624 ; CHECK-LABEL: @umax_umax_smin(
1625 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1626 ; CHECK-NEXT: ret i8 [[M1]]
1628 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1629 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1630 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1634 define i8 @umax_umax_umax(i8 %x, i8 %y) {
1635 ; CHECK-LABEL: @umax_umax_umax(
1636 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1637 ; CHECK-NEXT: ret i8 [[M1]]
1639 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1640 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1641 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1645 define i8 @umax_umax_umin(i8 %x, i8 %y) {
1646 ; CHECK-LABEL: @umax_umax_umin(
1647 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1648 ; CHECK-NEXT: ret i8 [[M1]]
1650 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1651 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1652 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1656 define i8 @umax_umin_smax(i8 %x, i8 %y) {
1657 ; CHECK-LABEL: @umax_umin_smax(
1658 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1659 ; CHECK-NEXT: ret i8 [[M2]]
1661 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1662 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1663 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1667 define i8 @umax_umin_smin(i8 %x, i8 %y) {
1668 ; CHECK-LABEL: @umax_umin_smin(
1669 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1670 ; CHECK-NEXT: ret i8 [[M2]]
1672 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1673 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1674 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1678 define i8 @umax_umin_umax(i8 %x, i8 %y) {
1679 ; CHECK-LABEL: @umax_umin_umax(
1680 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1681 ; CHECK-NEXT: ret i8 [[M2]]
1683 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1684 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1685 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1689 define i8 @umax_umin_umin(i8 %x, i8 %y) {
1690 ; CHECK-LABEL: @umax_umin_umin(
1691 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1692 ; CHECK-NEXT: ret i8 [[M2]]
1694 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1695 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1696 %r = call i8 @llvm.umax.i8(i8 %m1, i8 %m2)
1700 ; This could simplify (commuted min/max op).
1702 define i8 @umin_smax_smax(i8 %x, i8 %y) {
1703 ; CHECK-LABEL: @umin_smax_smax(
1704 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1705 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y]], i8 [[X]])
1706 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umin.i8(i8 [[M1]], i8 [[M2]])
1707 ; CHECK-NEXT: ret i8 [[R]]
1709 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1710 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1711 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1715 ; This could combine - umin(x,y) - but does not simplify.
1717 define i8 @umin_smax_smin(i8 %x, i8 %y) {
1718 ; CHECK-LABEL: @umin_smax_smin(
1719 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1720 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y]], i8 [[X]])
1721 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umin.i8(i8 [[M1]], i8 [[M2]])
1722 ; CHECK-NEXT: ret i8 [[R]]
1724 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1725 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1726 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1730 define i8 @umin_smax_umax(i8 %x, i8 %y) {
1731 ; CHECK-LABEL: @umin_smax_umax(
1732 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1733 ; CHECK-NEXT: ret i8 [[M1]]
1735 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1736 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1737 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1741 define i8 @umin_smax_umin(i8 %x, i8 %y) {
1742 ; CHECK-LABEL: @umin_smax_umin(
1743 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1744 ; CHECK-NEXT: ret i8 [[M2]]
1746 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
1747 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1748 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1752 ; This could combine - umin(x,y) - but does not simplify.
1754 define i8 @umin_smin_smax(i8 %x, i8 %y) {
1755 ; CHECK-LABEL: @umin_smin_smax(
1756 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1757 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y]], i8 [[X]])
1758 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umin.i8(i8 [[M1]], i8 [[M2]])
1759 ; CHECK-NEXT: ret i8 [[R]]
1761 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1762 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1763 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1767 ; This could simplify (commuted min/max op).
1769 define i8 @umin_smin_smin(i8 %x, i8 %y) {
1770 ; CHECK-LABEL: @umin_smin_smin(
1771 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1772 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y]], i8 [[X]])
1773 ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umin.i8(i8 [[M1]], i8 [[M2]])
1774 ; CHECK-NEXT: ret i8 [[R]]
1776 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1777 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1778 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1782 define i8 @umin_smin_umax(i8 %x, i8 %y) {
1783 ; CHECK-LABEL: @umin_smin_umax(
1784 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1785 ; CHECK-NEXT: ret i8 [[M1]]
1787 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1788 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1789 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1793 define i8 @umin_smin_umin(i8 %x, i8 %y) {
1794 ; CHECK-LABEL: @umin_smin_umin(
1795 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1796 ; CHECK-NEXT: ret i8 [[M2]]
1798 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
1799 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1800 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1804 define i8 @umin_umax_smax(i8 %x, i8 %y) {
1805 ; CHECK-LABEL: @umin_umax_smax(
1806 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1807 ; CHECK-NEXT: ret i8 [[M2]]
1809 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1810 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1811 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1815 define i8 @umin_umax_smin(i8 %x, i8 %y) {
1816 ; CHECK-LABEL: @umin_umax_smin(
1817 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1818 ; CHECK-NEXT: ret i8 [[M2]]
1820 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1821 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1822 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1826 define i8 @umin_umax_umax(i8 %x, i8 %y) {
1827 ; CHECK-LABEL: @umin_umax_umax(
1828 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1829 ; CHECK-NEXT: ret i8 [[M2]]
1831 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1832 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1833 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1837 define i8 @umin_umax_umin(i8 %x, i8 %y) {
1838 ; CHECK-LABEL: @umin_umax_umin(
1839 ; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[Y:%.*]], i8 [[X:%.*]])
1840 ; CHECK-NEXT: ret i8 [[M2]]
1842 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1843 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1844 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1848 define i8 @umin_umin_smax(i8 %x, i8 %y) {
1849 ; CHECK-LABEL: @umin_umin_smax(
1850 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1851 ; CHECK-NEXT: ret i8 [[M1]]
1853 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1854 %m2 = call i8 @llvm.smax.i8(i8 %y, i8 %x)
1855 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1859 define i8 @umin_umin_smin(i8 %x, i8 %y) {
1860 ; CHECK-LABEL: @umin_umin_smin(
1861 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1862 ; CHECK-NEXT: ret i8 [[M1]]
1864 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1865 %m2 = call i8 @llvm.smin.i8(i8 %y, i8 %x)
1866 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1870 define i8 @umin_umin_umax(i8 %x, i8 %y) {
1871 ; CHECK-LABEL: @umin_umin_umax(
1872 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1873 ; CHECK-NEXT: ret i8 [[M1]]
1875 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1876 %m2 = call i8 @llvm.umax.i8(i8 %y, i8 %x)
1877 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1881 define i8 @umin_umin_umin(i8 %x, i8 %y) {
1882 ; CHECK-LABEL: @umin_umin_umin(
1883 ; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
1884 ; CHECK-NEXT: ret i8 [[M1]]
1886 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1887 %m2 = call i8 @llvm.umin.i8(i8 %y, i8 %x)
1888 %r = call i8 @llvm.umin.i8(i8 %m1, i8 %m2)
1892 define i1 @umin_ult_diff_const(i8 %x) {
1893 ; CHECK-LABEL: @umin_ult_diff_const(
1894 ; CHECK-NEXT: ret i1 true
1896 %m = call i8 @llvm.umin.i8(i8 %x, i8 10)
1897 %c = icmp ult i8 %m, 20
1901 define i1 @umax_ugt_diff_const(i8 %x) {
1902 ; CHECK-LABEL: @umax_ugt_diff_const(
1903 ; CHECK-NEXT: ret i1 true
1905 %m = call i8 @llvm.umax.i8(i8 %x, i8 10)
1906 %c = icmp ugt i8 %m, 5
1910 define i1 @smin_slt_diff_const(i8 %x) {
1911 ; CHECK-LABEL: @smin_slt_diff_const(
1912 ; CHECK-NEXT: ret i1 true
1914 %m = call i8 @llvm.smin.i8(i8 %x, i8 10)
1915 %c = icmp slt i8 %m, 20
1919 define i1 @smax_sgt_diff_const(i8 %x) {
1920 ; CHECK-LABEL: @smax_sgt_diff_const(
1921 ; CHECK-NEXT: ret i1 true
1923 %m = call i8 @llvm.smax.i8(i8 %x, i8 10)
1924 %c = icmp sgt i8 %m, 5
1928 define i8 @umin_assume_uge(i8 %x, i8 %y) {
1929 ; CHECK-LABEL: @umin_assume_uge(
1930 ; CHECK-NEXT: [[C:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
1931 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
1932 ; CHECK-NEXT: ret i8 [[Y]]
1934 %c = icmp uge i8 %x, %y
1935 call void @llvm.assume(i1 %c)
1936 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1940 define i8 @umin_assume_ugt(i8 %x, i8 %y) {
1941 ; CHECK-LABEL: @umin_assume_ugt(
1942 ; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]
1943 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
1944 ; CHECK-NEXT: ret i8 [[Y]]
1946 %c = icmp ugt i8 %x, %y
1947 call void @llvm.assume(i1 %c)
1948 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1952 define i8 @umin_assume_ule(i8 %x, i8 %y) {
1953 ; CHECK-LABEL: @umin_assume_ule(
1954 ; CHECK-NEXT: [[C:%.*]] = icmp ule i8 [[X:%.*]], [[Y:%.*]]
1955 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
1956 ; CHECK-NEXT: ret i8 [[X]]
1958 %c = icmp ule i8 %x, %y
1959 call void @llvm.assume(i1 %c)
1960 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1964 define i8 @umin_assume_ult(i8 %x, i8 %y) {
1965 ; CHECK-LABEL: @umin_assume_ult(
1966 ; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
1967 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
1968 ; CHECK-NEXT: ret i8 [[X]]
1970 %c = icmp ult i8 %x, %y
1971 call void @llvm.assume(i1 %c)
1972 %m = call i8 @llvm.umin.i8(i8 %x, i8 %y)
1976 define i8 @umax_assume_uge(i8 %x, i8 %y) {
1977 ; CHECK-LABEL: @umax_assume_uge(
1978 ; CHECK-NEXT: [[C:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
1979 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
1980 ; CHECK-NEXT: ret i8 [[X]]
1982 %c = icmp uge i8 %x, %y
1983 call void @llvm.assume(i1 %c)
1984 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
1988 define i8 @umax_assume_ugt(i8 %x, i8 %y) {
1989 ; CHECK-LABEL: @umax_assume_ugt(
1990 ; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]
1991 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
1992 ; CHECK-NEXT: ret i8 [[X]]
1994 %c = icmp ugt i8 %x, %y
1995 call void @llvm.assume(i1 %c)
1996 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2000 define i8 @umax_assume_ule(i8 %x, i8 %y) {
2001 ; CHECK-LABEL: @umax_assume_ule(
2002 ; CHECK-NEXT: [[C:%.*]] = icmp ule i8 [[X:%.*]], [[Y:%.*]]
2003 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2004 ; CHECK-NEXT: ret i8 [[Y]]
2006 %c = icmp ule i8 %x, %y
2007 call void @llvm.assume(i1 %c)
2008 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2012 define i8 @umax_assume_ult(i8 %x, i8 %y) {
2013 ; CHECK-LABEL: @umax_assume_ult(
2014 ; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
2015 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2016 ; CHECK-NEXT: ret i8 [[Y]]
2018 %c = icmp ult i8 %x, %y
2019 call void @llvm.assume(i1 %c)
2020 %m = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2024 define i8 @smin_assume_sge(i8 %x, i8 %y) {
2025 ; CHECK-LABEL: @smin_assume_sge(
2026 ; CHECK-NEXT: [[C:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
2027 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2028 ; CHECK-NEXT: ret i8 [[Y]]
2030 %c = icmp sge i8 %x, %y
2031 call void @llvm.assume(i1 %c)
2032 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
2036 define i8 @smin_assume_sgt(i8 %x, i8 %y) {
2037 ; CHECK-LABEL: @smin_assume_sgt(
2038 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]]
2039 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2040 ; CHECK-NEXT: ret i8 [[Y]]
2042 %c = icmp sgt i8 %x, %y
2043 call void @llvm.assume(i1 %c)
2044 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
2048 define i8 @smin_assume_sle(i8 %x, i8 %y) {
2049 ; CHECK-LABEL: @smin_assume_sle(
2050 ; CHECK-NEXT: [[C:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
2051 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2052 ; CHECK-NEXT: ret i8 [[X]]
2054 %c = icmp sle i8 %x, %y
2055 call void @llvm.assume(i1 %c)
2056 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
2060 define i8 @smin_assume_slt(i8 %x, i8 %y) {
2061 ; CHECK-LABEL: @smin_assume_slt(
2062 ; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X:%.*]], [[Y:%.*]]
2063 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2064 ; CHECK-NEXT: ret i8 [[X]]
2066 %c = icmp slt i8 %x, %y
2067 call void @llvm.assume(i1 %c)
2068 %m = call i8 @llvm.smin.i8(i8 %x, i8 %y)
2072 define i8 @smax_assume_sge(i8 %x, i8 %y) {
2073 ; CHECK-LABEL: @smax_assume_sge(
2074 ; CHECK-NEXT: [[C:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
2075 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2076 ; CHECK-NEXT: ret i8 [[X]]
2078 %c = icmp sge i8 %x, %y
2079 call void @llvm.assume(i1 %c)
2080 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
2084 define i8 @smax_assume_sgt(i8 %x, i8 %y) {
2085 ; CHECK-LABEL: @smax_assume_sgt(
2086 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]]
2087 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2088 ; CHECK-NEXT: ret i8 [[X]]
2090 %c = icmp sgt i8 %x, %y
2091 call void @llvm.assume(i1 %c)
2092 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
2096 define i8 @smax_assume_sle(i8 %x, i8 %y) {
2097 ; CHECK-LABEL: @smax_assume_sle(
2098 ; CHECK-NEXT: [[C:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
2099 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2100 ; CHECK-NEXT: ret i8 [[Y]]
2102 %c = icmp sle i8 %x, %y
2103 call void @llvm.assume(i1 %c)
2104 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
2108 define i8 @smax_assume_slt(i8 %x, i8 %y) {
2109 ; CHECK-LABEL: @smax_assume_slt(
2110 ; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X:%.*]], [[Y:%.*]]
2111 ; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
2112 ; CHECK-NEXT: ret i8 [[Y]]
2114 %c = icmp slt i8 %x, %y
2115 call void @llvm.assume(i1 %c)
2116 %m = call i8 @llvm.smax.i8(i8 %x, i8 %y)
2120 define i8 @umax_add_nuw_1(i8 %x) {
2121 ; CHECK-LABEL: @umax_add_nuw_1(
2122 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i8 [[X:%.*]], 1
2123 ; CHECK-NEXT: ret i8 [[ADD]]
2125 %add = add nuw i8 %x, 1
2126 %max = call i8 @llvm.umax.i8(i8 %add, i8 %x)
2130 define i8 @umax_add_nuw_2(i8 %x) {
2131 ; CHECK-LABEL: @umax_add_nuw_2(
2132 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i8 [[X:%.*]], 42
2133 ; CHECK-NEXT: ret i8 [[ADD]]
2135 %add = add nuw i8 %x, 42
2136 %max = call i8 @llvm.umax.i8(i8 %add, i8 42)
2140 define i8 @umax_range_metadata(ptr %p1, ptr %p2) {
2141 ; CHECK-LABEL: @umax_range_metadata(
2142 ; CHECK-NEXT: [[Y:%.*]] = load i8, ptr [[P2:%.*]], align 1, !range [[RNG0:![0-9]+]]
2143 ; CHECK-NEXT: ret i8 [[Y]]
2145 %x = load i8, ptr %p1, !range !{i8 0, i8 10}
2146 %y = load i8, ptr %p2, !range !{i8 20, i8 30}
2147 %max = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2151 define i8 @umax_zext_sext(i4 %x) {
2152 ; CHECK-LABEL: @umax_zext_sext(
2153 ; CHECK-NEXT: [[SEXT:%.*]] = sext i4 [[X:%.*]] to i8
2154 ; CHECK-NEXT: ret i8 [[SEXT]]
2156 %zext = zext i4 %x to i8
2157 %sext = sext i4 %x to i8
2158 %max = call i8 @llvm.umax.i8(i8 %zext, i8 %sext)
2162 define i8 @umax_lshr(i8 %x, i8 %y) {
2163 ; CHECK-LABEL: @umax_lshr(
2164 ; CHECK-NEXT: ret i8 [[X:%.*]]
2166 %shr = lshr i8 %x, %y
2167 %max = call i8 @llvm.umax.i8(i8 %x, i8 %shr)
2171 define i8 @umax_dom_cond_uge(i8 %x, i8 %y) {
2172 ; CHECK-LABEL: @umax_dom_cond_uge(
2173 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
2174 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2176 ; CHECK-NEXT: ret i8 [[X]]
2178 ; CHECK-NEXT: ret i8 [[Y]]
2180 %cmp = icmp uge i8 %x, %y
2181 br i1 %cmp, label %true, label %false
2184 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2188 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2192 define i8 @umax_dom_cond_ugt(i8 %x, i8 %y) {
2193 ; CHECK-LABEL: @umax_dom_cond_ugt(
2194 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]
2195 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2197 ; CHECK-NEXT: ret i8 [[X]]
2199 ; CHECK-NEXT: ret i8 [[Y]]
2201 %cmp = icmp ugt i8 %x, %y
2202 br i1 %cmp, label %true, label %false
2205 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2209 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2213 define i8 @umax_dom_cond_ule(i8 %x, i8 %y) {
2214 ; CHECK-LABEL: @umax_dom_cond_ule(
2215 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[X:%.*]], [[Y:%.*]]
2216 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2218 ; CHECK-NEXT: ret i8 [[Y]]
2220 ; CHECK-NEXT: ret i8 [[X]]
2222 %cmp = icmp ule i8 %x, %y
2223 br i1 %cmp, label %true, label %false
2226 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2230 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2234 define i8 @umax_dom_cond_ult(i8 %x, i8 %y) {
2235 ; CHECK-LABEL: @umax_dom_cond_ult(
2236 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
2237 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2239 ; CHECK-NEXT: ret i8 [[Y]]
2241 ; CHECK-NEXT: ret i8 [[X]]
2243 %cmp = icmp ult i8 %x, %y
2244 br i1 %cmp, label %true, label %false
2247 %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2251 %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
2255 define i8 @umin_dom_cond_uge(i8 %x, i8 %y) {
2256 ; CHECK-LABEL: @umin_dom_cond_uge(
2257 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
2258 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2260 ; CHECK-NEXT: ret i8 [[Y]]
2262 ; CHECK-NEXT: ret i8 [[X]]
2264 %cmp = icmp uge i8 %x, %y
2265 br i1 %cmp, label %true, label %false
2268 %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
2272 %m2 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
2276 define i8 @smax_dom_cond_sge(i8 %x, i8 %y) {
2277 ; CHECK-LABEL: @smax_dom_cond_sge(
2278 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
2279 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2281 ; CHECK-NEXT: ret i8 [[X]]
2283 ; CHECK-NEXT: ret i8 [[Y]]
2285 %cmp = icmp sge i8 %x, %y
2286 br i1 %cmp, label %true, label %false
2289 %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
2293 %m2 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
2297 define i8 @smin_dom_cond_sge(i8 %x, i8 %y) {
2298 ; CHECK-LABEL: @smin_dom_cond_sge(
2299 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
2300 ; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
2302 ; CHECK-NEXT: ret i8 [[Y]]
2304 ; CHECK-NEXT: ret i8 [[X]]
2306 %cmp = icmp sge i8 %x, %y
2307 br i1 %cmp, label %true, label %false
2310 %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
2314 %m2 = call i8 @llvm.smin.i8(i8 %x, i8 %y)