1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
4 declare half @llvm.minimum.f16(half, half)
5 declare half @llvm.maximum.f16(half, half)
7 declare float @llvm.minnum.f32(float, float)
8 declare float @llvm.maxnum.f32(float, float)
9 declare float @llvm.minimum.f32(float, float)
10 declare float @llvm.maximum.f32(float, float)
11 declare <2 x float> @llvm.minnum.v2f32(<2 x float>, <2 x float>)
12 declare <2 x float> @llvm.maxnum.v2f32(<2 x float>, <2 x float>)
13 declare <2 x float> @llvm.minimum.v2f32(<2 x float>, <2 x float>)
14 declare <2 x float> @llvm.maximum.v2f32(<2 x float>, <2 x float>)
16 declare double @llvm.minnum.f64(double, double)
17 declare double @llvm.maxnum.f64(double, double)
18 declare <2 x double> @llvm.minnum.v2f64(<2 x double>, <2 x double>)
19 declare <2 x double> @llvm.maxnum.v2f64(<2 x double>, <2 x double>)
20 declare double @llvm.minimum.f64(double, double)
21 declare double @llvm.maximum.f64(double, double)
22 declare <2 x double> @llvm.minimum.v2f64(<2 x double>, <2 x double>)
23 declare <2 x double> @llvm.maximum.v2f64(<2 x double>, <2 x double>)
25 define float @test_minnum_const_nan(float %x) {
26 ; CHECK-LABEL: @test_minnum_const_nan(
27 ; CHECK-NEXT: ret float [[X:%.*]]
29 %r = call float @llvm.minnum.f32(float %x, float 0x7fff000000000000)
33 define float @test_maxnum_const_nan(float %x) {
34 ; CHECK-LABEL: @test_maxnum_const_nan(
35 ; CHECK-NEXT: ret float [[X:%.*]]
37 %r = call float @llvm.maxnum.f32(float %x, float 0x7fff000000000000)
41 define float @test_maximum_const_nan(float %x) {
42 ; CHECK-LABEL: @test_maximum_const_nan(
43 ; CHECK-NEXT: ret float 0x7FFF000000000000
45 %r = call float @llvm.maximum.f32(float %x, float 0x7fff000000000000)
49 define float @test_minimum_const_nan(float %x) {
50 ; CHECK-LABEL: @test_minimum_const_nan(
51 ; CHECK-NEXT: ret float 0x7FFF000000000000
53 %r = call float @llvm.minimum.f32(float %x, float 0x7fff000000000000)
57 define float @test_minnum_const_inf(float %x) {
58 ; CHECK-LABEL: @test_minnum_const_inf(
59 ; CHECK-NEXT: [[R:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 0x7FF0000000000000)
60 ; CHECK-NEXT: ret float [[R]]
62 %r = call float @llvm.minnum.f32(float %x, float 0x7ff0000000000000)
66 define float @test_maxnum_const_inf(float %x) {
67 ; CHECK-LABEL: @test_maxnum_const_inf(
68 ; CHECK-NEXT: ret float 0x7FF0000000000000
70 %r = call float @llvm.maxnum.f32(float %x, float 0x7ff0000000000000)
74 define float @test_maximum_const_inf(float %x) {
75 ; CHECK-LABEL: @test_maximum_const_inf(
76 ; CHECK-NEXT: [[R:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float 0x7FF0000000000000)
77 ; CHECK-NEXT: ret float [[R]]
79 %r = call float @llvm.maximum.f32(float %x, float 0x7ff0000000000000)
83 define float @test_minimum_const_inf(float %x) {
84 ; CHECK-LABEL: @test_minimum_const_inf(
85 ; CHECK-NEXT: ret float [[X:%.*]]
87 %r = call float @llvm.minimum.f32(float %x, float 0x7ff0000000000000)
91 define float @test_minnum_const_neg_inf(float %x) {
92 ; CHECK-LABEL: @test_minnum_const_neg_inf(
93 ; CHECK-NEXT: ret float 0xFFF0000000000000
95 %r = call float @llvm.minnum.f32(float %x, float 0xfff0000000000000)
99 define float @test_maxnum_const_neg_inf(float %x) {
100 ; CHECK-LABEL: @test_maxnum_const_neg_inf(
101 ; CHECK-NEXT: [[R:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float 0xFFF0000000000000)
102 ; CHECK-NEXT: ret float [[R]]
104 %r = call float @llvm.maxnum.f32(float %x, float 0xfff0000000000000)
108 define float @test_maximum_const_neg_inf(float %x) {
109 ; CHECK-LABEL: @test_maximum_const_neg_inf(
110 ; CHECK-NEXT: ret float [[X:%.*]]
112 %r = call float @llvm.maximum.f32(float %x, float 0xfff0000000000000)
116 define float @test_minimum_const_neg_inf(float %x) {
117 ; CHECK-LABEL: @test_minimum_const_neg_inf(
118 ; CHECK-NEXT: [[R:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float 0xFFF0000000000000)
119 ; CHECK-NEXT: ret float [[R]]
121 %r = call float @llvm.minimum.f32(float %x, float 0xfff0000000000000)
125 define float @test_minnum_const_inf_nnan(float %x) {
126 ; CHECK-LABEL: @test_minnum_const_inf_nnan(
127 ; CHECK-NEXT: ret float [[X:%.*]]
129 %r = call nnan float @llvm.minnum.f32(float %x, float 0x7ff0000000000000)
133 define float @test_maxnum_const_inf_nnan(float %x) {
134 ; CHECK-LABEL: @test_maxnum_const_inf_nnan(
135 ; CHECK-NEXT: ret float 0x7FF0000000000000
137 %r = call nnan float @llvm.maxnum.f32(float %x, float 0x7ff0000000000000)
141 define float @test_maximum_const_inf_nnan(float %x) {
142 ; CHECK-LABEL: @test_maximum_const_inf_nnan(
143 ; CHECK-NEXT: ret float 0x7FF0000000000000
145 %r = call nnan float @llvm.maximum.f32(float %x, float 0x7ff0000000000000)
149 define float @test_minimum_const_inf_nnan(float %x) {
150 ; CHECK-LABEL: @test_minimum_const_inf_nnan(
151 ; CHECK-NEXT: ret float [[X:%.*]]
153 %r = call nnan float @llvm.minimum.f32(float %x, float 0x7ff0000000000000)
157 define float @test_minnum_const_inf_nnan_comm(float %x) {
158 ; CHECK-LABEL: @test_minnum_const_inf_nnan_comm(
159 ; CHECK-NEXT: ret float [[X:%.*]]
161 %r = call nnan float @llvm.minnum.f32(float 0x7ff0000000000000, float %x)
165 define float @test_maxnum_const_inf_nnan_comm(float %x) {
166 ; CHECK-LABEL: @test_maxnum_const_inf_nnan_comm(
167 ; CHECK-NEXT: ret float 0x7FF0000000000000
169 %r = call nnan float @llvm.maxnum.f32(float 0x7ff0000000000000, float %x)
173 define float @test_maximum_const_inf_nnan_comm(float %x) {
174 ; CHECK-LABEL: @test_maximum_const_inf_nnan_comm(
175 ; CHECK-NEXT: ret float 0x7FF0000000000000
177 %r = call nnan float @llvm.maximum.f32(float 0x7ff0000000000000, float %x)
181 define float @test_minimum_const_inf_nnan_comm(float %x) {
182 ; CHECK-LABEL: @test_minimum_const_inf_nnan_comm(
183 ; CHECK-NEXT: ret float [[X:%.*]]
185 %r = call nnan float @llvm.minimum.f32(float 0x7ff0000000000000, float %x)
189 define <2 x float> @test_minnum_const_inf_nnan_comm_vec(<2 x float> %x) {
190 ; CHECK-LABEL: @test_minnum_const_inf_nnan_comm_vec(
191 ; CHECK-NEXT: ret <2 x float> [[X:%.*]]
193 %r = call nnan <2 x float> @llvm.minnum.v2f32(<2 x float> <float 0x7ff0000000000000, float 0x7ff0000000000000>, <2 x float> %x)
197 define <2 x float> @test_maxnum_const_inf_nnan_comm_vec(<2 x float> %x) {
198 ; CHECK-LABEL: @test_maxnum_const_inf_nnan_comm_vec(
199 ; CHECK-NEXT: ret <2 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000>
201 %r = call nnan <2 x float> @llvm.maxnum.v2f32(<2 x float> <float 0x7ff0000000000000, float 0x7ff0000000000000>, <2 x float> %x)
205 define <2 x float> @test_maximum_const_inf_nnan_comm_vec(<2 x float> %x) {
206 ; CHECK-LABEL: @test_maximum_const_inf_nnan_comm_vec(
207 ; CHECK-NEXT: ret <2 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000>
209 %r = call nnan <2 x float> @llvm.maximum.v2f32(<2 x float> <float 0x7ff0000000000000, float 0x7ff0000000000000>, <2 x float> %x)
213 define <2 x float> @test_minimum_const_inf_nnan_comm_vec(<2 x float> %x) {
214 ; CHECK-LABEL: @test_minimum_const_inf_nnan_comm_vec(
215 ; CHECK-NEXT: ret <2 x float> [[X:%.*]]
217 %r = call nnan <2 x float> @llvm.minimum.v2f32(<2 x float> <float 0x7ff0000000000000, float 0x7ff0000000000000>, <2 x float> %x)
221 define float @test_minnum_const_neg_inf_nnan(float %x) {
222 ; CHECK-LABEL: @test_minnum_const_neg_inf_nnan(
223 ; CHECK-NEXT: ret float 0xFFF0000000000000
225 %r = call nnan float @llvm.minnum.f32(float %x, float 0xfff0000000000000)
229 define float @test_maxnum_const_neg_inf_nnan(float %x) {
230 ; CHECK-LABEL: @test_maxnum_const_neg_inf_nnan(
231 ; CHECK-NEXT: ret float [[X:%.*]]
233 %r = call nnan float @llvm.maxnum.f32(float %x, float 0xfff0000000000000)
237 define float @test_maximum_const_neg_inf_nnan(float %x) {
238 ; CHECK-LABEL: @test_maximum_const_neg_inf_nnan(
239 ; CHECK-NEXT: ret float [[X:%.*]]
241 %r = call nnan float @llvm.maximum.f32(float %x, float 0xfff0000000000000)
245 define float @test_minimum_const_neg_inf_nnan(float %x) {
246 ; CHECK-LABEL: @test_minimum_const_neg_inf_nnan(
247 ; CHECK-NEXT: ret float 0xFFF0000000000000
249 %r = call nnan float @llvm.minimum.f32(float %x, float 0xfff0000000000000)
253 define float @test_minnum_const_max(float %x) {
254 ; CHECK-LABEL: @test_minnum_const_max(
255 ; CHECK-NEXT: [[R:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 0x47EFFFFFE0000000)
256 ; CHECK-NEXT: ret float [[R]]
258 %r = call float @llvm.minnum.f32(float %x, float 0x47efffffe0000000)
262 define float @test_maxnum_const_max(float %x) {
263 ; CHECK-LABEL: @test_maxnum_const_max(
264 ; CHECK-NEXT: [[R:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float 0x47EFFFFFE0000000)
265 ; CHECK-NEXT: ret float [[R]]
267 %r = call float @llvm.maxnum.f32(float %x, float 0x47efffffe0000000)
271 define float @test_maximum_const_max(float %x) {
272 ; CHECK-LABEL: @test_maximum_const_max(
273 ; CHECK-NEXT: [[R:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float 0x47EFFFFFE0000000)
274 ; CHECK-NEXT: ret float [[R]]
276 %r = call float @llvm.maximum.f32(float %x, float 0x47efffffe0000000)
280 define float @test_minimum_const_max(float %x) {
281 ; CHECK-LABEL: @test_minimum_const_max(
282 ; CHECK-NEXT: [[R:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float 0x47EFFFFFE0000000)
283 ; CHECK-NEXT: ret float [[R]]
285 %r = call float @llvm.minimum.f32(float %x, float 0x47efffffe0000000)
289 define float @test_minnum_const_neg_max(float %x) {
290 ; CHECK-LABEL: @test_minnum_const_neg_max(
291 ; CHECK-NEXT: [[R:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float 0xC7EFFFFFE0000000)
292 ; CHECK-NEXT: ret float [[R]]
294 %r = call float @llvm.minnum.f32(float %x, float 0xc7efffffe0000000)
298 define float @test_maxnum_const_neg_max(float %x) {
299 ; CHECK-LABEL: @test_maxnum_const_neg_max(
300 ; CHECK-NEXT: [[R:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float 0xC7EFFFFFE0000000)
301 ; CHECK-NEXT: ret float [[R]]
303 %r = call float @llvm.maxnum.f32(float %x, float 0xc7efffffe0000000)
307 define float @test_maximum_const_neg_max(float %x) {
308 ; CHECK-LABEL: @test_maximum_const_neg_max(
309 ; CHECK-NEXT: [[R:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float 0xC7EFFFFFE0000000)
310 ; CHECK-NEXT: ret float [[R]]
312 %r = call float @llvm.maximum.f32(float %x, float 0xc7efffffe0000000)
316 define float @test_minimum_const_neg_max(float %x) {
317 ; CHECK-LABEL: @test_minimum_const_neg_max(
318 ; CHECK-NEXT: [[R:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float 0xC7EFFFFFE0000000)
319 ; CHECK-NEXT: ret float [[R]]
321 %r = call float @llvm.minimum.f32(float %x, float 0xc7efffffe0000000)
325 define float @test_minnum_const_max_ninf(float %x) {
326 ; CHECK-LABEL: @test_minnum_const_max_ninf(
327 ; CHECK-NEXT: [[R:%.*]] = call ninf float @llvm.minnum.f32(float [[X:%.*]], float 0x47EFFFFFE0000000)
328 ; CHECK-NEXT: ret float [[R]]
330 %r = call ninf float @llvm.minnum.f32(float %x, float 0x47efffffe0000000)
334 define float @test_maxnum_const_max_ninf(float %x) {
335 ; CHECK-LABEL: @test_maxnum_const_max_ninf(
336 ; CHECK-NEXT: ret float 0x47EFFFFFE0000000
338 %r = call ninf float @llvm.maxnum.f32(float %x, float 0x47efffffe0000000)
342 define float @test_maximum_const_max_ninf(float %x) {
343 ; CHECK-LABEL: @test_maximum_const_max_ninf(
344 ; CHECK-NEXT: [[R:%.*]] = call ninf float @llvm.maximum.f32(float [[X:%.*]], float 0x47EFFFFFE0000000)
345 ; CHECK-NEXT: ret float [[R]]
347 %r = call ninf float @llvm.maximum.f32(float %x, float 0x47efffffe0000000)
351 define float @test_minimum_const_max_ninf(float %x) {
352 ; CHECK-LABEL: @test_minimum_const_max_ninf(
353 ; CHECK-NEXT: ret float [[X:%.*]]
355 %r = call ninf float @llvm.minimum.f32(float %x, float 0x47efffffe0000000)
359 define float @test_minnum_const_neg_max_ninf(float %x) {
360 ; CHECK-LABEL: @test_minnum_const_neg_max_ninf(
361 ; CHECK-NEXT: ret float 0xC7EFFFFFE0000000
363 %r = call ninf float @llvm.minnum.f32(float %x, float 0xc7efffffe0000000)
367 define float @test_maxnum_const_neg_max_ninf(float %x) {
368 ; CHECK-LABEL: @test_maxnum_const_neg_max_ninf(
369 ; CHECK-NEXT: [[R:%.*]] = call ninf float @llvm.maxnum.f32(float [[X:%.*]], float 0xC7EFFFFFE0000000)
370 ; CHECK-NEXT: ret float [[R]]
372 %r = call ninf float @llvm.maxnum.f32(float %x, float 0xc7efffffe0000000)
376 define float @test_maximum_const_neg_max_ninf(float %x) {
377 ; CHECK-LABEL: @test_maximum_const_neg_max_ninf(
378 ; CHECK-NEXT: ret float [[X:%.*]]
380 %r = call ninf float @llvm.maximum.f32(float %x, float 0xc7efffffe0000000)
384 define float @test_minimum_const_neg_max_ninf(float %x) {
385 ; CHECK-LABEL: @test_minimum_const_neg_max_ninf(
386 ; CHECK-NEXT: [[R:%.*]] = call ninf float @llvm.minimum.f32(float [[X:%.*]], float 0xC7EFFFFFE0000000)
387 ; CHECK-NEXT: ret float [[R]]
389 %r = call ninf float @llvm.minimum.f32(float %x, float 0xc7efffffe0000000)
393 define float @test_minnum_const_max_nnan_ninf(float %x) {
394 ; CHECK-LABEL: @test_minnum_const_max_nnan_ninf(
395 ; CHECK-NEXT: ret float [[X:%.*]]
397 %r = call nnan ninf float @llvm.minnum.f32(float %x, float 0x47efffffe0000000)
401 define float @test_maxnum_const_max_nnan_ninf(float %x) {
402 ; CHECK-LABEL: @test_maxnum_const_max_nnan_ninf(
403 ; CHECK-NEXT: ret float 0x47EFFFFFE0000000
405 %r = call nnan ninf float @llvm.maxnum.f32(float %x, float 0x47efffffe0000000)
409 define float @test_maximum_const_max_nnan_ninf(float %x) {
410 ; CHECK-LABEL: @test_maximum_const_max_nnan_ninf(
411 ; CHECK-NEXT: ret float 0x47EFFFFFE0000000
413 %r = call nnan ninf float @llvm.maximum.f32(float %x, float 0x47efffffe0000000)
417 define float @test_minimum_const_max_nnan_ninf(float %x) {
418 ; CHECK-LABEL: @test_minimum_const_max_nnan_ninf(
419 ; CHECK-NEXT: ret float [[X:%.*]]
421 %r = call nnan ninf float @llvm.minimum.f32(float %x, float 0x47efffffe0000000)
425 define float @test_minnum_const_neg_max_nnan_ninf(float %x) {
426 ; CHECK-LABEL: @test_minnum_const_neg_max_nnan_ninf(
427 ; CHECK-NEXT: ret float 0xC7EFFFFFE0000000
429 %r = call nnan ninf float @llvm.minnum.f32(float %x, float 0xc7efffffe0000000)
433 define float @test_maxnum_const_neg_max_nnan_ninf(float %x) {
434 ; CHECK-LABEL: @test_maxnum_const_neg_max_nnan_ninf(
435 ; CHECK-NEXT: ret float [[X:%.*]]
437 %r = call nnan ninf float @llvm.maxnum.f32(float %x, float 0xc7efffffe0000000)
441 define float @test_maximum_const_neg_max_nnan_ninf(float %x) {
442 ; CHECK-LABEL: @test_maximum_const_neg_max_nnan_ninf(
443 ; CHECK-NEXT: ret float [[X:%.*]]
445 %r = call nnan ninf float @llvm.maximum.f32(float %x, float 0xc7efffffe0000000)
449 define float @test_minimum_const_neg_max_nnan_ninf(float %x) {
450 ; CHECK-LABEL: @test_minimum_const_neg_max_nnan_ninf(
451 ; CHECK-NEXT: ret float 0xC7EFFFFFE0000000
453 %r = call nnan ninf float @llvm.minimum.f32(float %x, float 0xc7efffffe0000000)
457 ; From the LangRef for minnum/maxnum:
458 ; "If either operand is a NaN, returns the other non-NaN operand."
460 define double @maxnum_nan_op0(double %x) {
461 ; CHECK-LABEL: @maxnum_nan_op0(
462 ; CHECK-NEXT: ret double [[X:%.*]]
464 %r = call double @llvm.maxnum.f64(double 0x7ff8000000000000, double %x)
468 define double @maxnum_nan_op1(double %x) {
469 ; CHECK-LABEL: @maxnum_nan_op1(
470 ; CHECK-NEXT: ret double [[X:%.*]]
472 %r = call double @llvm.maxnum.f64(double %x, double 0x7ff800000000dead)
476 define double @minnum_nan_op0(double %x) {
477 ; CHECK-LABEL: @minnum_nan_op0(
478 ; CHECK-NEXT: ret double [[X:%.*]]
480 %r = call double @llvm.minnum.f64(double 0x7ff8000dead00000, double %x)
484 define double @minnum_nan_op1(double %x) {
485 ; CHECK-LABEL: @minnum_nan_op1(
486 ; CHECK-NEXT: ret double [[X:%.*]]
488 %r = call double @llvm.minnum.f64(double %x, double 0x7ff800dead00dead)
492 define <2 x double> @maxnum_nan_op0_vec(<2 x double> %x) {
493 ; CHECK-LABEL: @maxnum_nan_op0_vec(
494 ; CHECK-NEXT: ret <2 x double> [[X:%.*]]
496 %r = call <2 x double> @llvm.maxnum.v2f64(<2 x double> <double 0x7ff8000000000000, double poison>, <2 x double> %x)
500 define <2 x double> @maxnum_nan_op1_vec(<2 x double> %x) {
501 ; CHECK-LABEL: @maxnum_nan_op1_vec(
502 ; CHECK-NEXT: ret <2 x double> [[X:%.*]]
504 %r = call <2 x double> @llvm.maxnum.v2f64(<2 x double> %x, <2 x double> <double 0x7ff800000000dead, double 0x7ff8ffffffffffff>)
508 define <2 x double> @minnum_nan_op0_vec(<2 x double> %x) {
509 ; CHECK-LABEL: @minnum_nan_op0_vec(
510 ; CHECK-NEXT: ret <2 x double> [[X:%.*]]
512 %r = call <2 x double> @llvm.minnum.v2f64(<2 x double> <double poison, double 0x7ff8000dead00000>, <2 x double> %x)
516 define <2 x double> @minnum_nan_op1_vec(<2 x double> %x) {
517 ; CHECK-LABEL: @minnum_nan_op1_vec(
518 ; CHECK-NEXT: ret <2 x double> [[X:%.*]]
520 %r = call <2 x double> @llvm.minnum.v2f64(<2 x double> %x, <2 x double> <double 0x7ff800dead00dead, double 0x7ff800dead00dead>)
524 define float @maxnum_undef_op1(float %x) {
525 ; CHECK-LABEL: @maxnum_undef_op1(
526 ; CHECK-NEXT: ret float [[X:%.*]]
528 %val = call float @llvm.maxnum.f32(float %x, float undef)
532 define float @maxnum_poison_op1(float %x) {
533 ; CHECK-LABEL: @maxnum_poison_op1(
534 ; CHECK-NEXT: ret float [[X:%.*]]
536 %val = call float @llvm.maxnum.f32(float %x, float poison)
540 define float @maxnum_undef_op0(float %x) {
541 ; CHECK-LABEL: @maxnum_undef_op0(
542 ; CHECK-NEXT: ret float [[X:%.*]]
544 %val = call float @llvm.maxnum.f32(float undef, float %x)
548 define float @maxnum_poison_op0(float %x) {
549 ; CHECK-LABEL: @maxnum_poison_op0(
550 ; CHECK-NEXT: ret float [[X:%.*]]
552 %val = call float @llvm.maxnum.f32(float poison, float %x)
556 define float @minnum_undef_op1(float %x) {
557 ; CHECK-LABEL: @minnum_undef_op1(
558 ; CHECK-NEXT: ret float [[X:%.*]]
560 %val = call float @llvm.minnum.f32(float %x, float undef)
564 define float @minnum_poison_op1(float %x) {
565 ; CHECK-LABEL: @minnum_poison_op1(
566 ; CHECK-NEXT: ret float [[X:%.*]]
568 %val = call float @llvm.minnum.f32(float %x, float poison)
572 define float @minnum_undef_op0(float %x) {
573 ; CHECK-LABEL: @minnum_undef_op0(
574 ; CHECK-NEXT: ret float [[X:%.*]]
576 %val = call float @llvm.minnum.f32(float undef, float %x)
580 define float @minnum_poison_op0(float %x) {
581 ; CHECK-LABEL: @minnum_poison_op0(
582 ; CHECK-NEXT: ret float [[X:%.*]]
584 %val = call float @llvm.minnum.f32(float poison, float %x)
588 define float @minnum_undef_undef(float %x) {
589 ; CHECK-LABEL: @minnum_undef_undef(
590 ; CHECK-NEXT: ret float undef
592 %val = call float @llvm.minnum.f32(float undef, float undef)
596 define float @minnum_poison_undef(float %x) {
597 ; CHECK-LABEL: @minnum_poison_undef(
598 ; CHECK-NEXT: ret float undef
600 %val = call float @llvm.minnum.f32(float poison, float undef)
604 define float @minnum_undef_poison(float %x) {
605 ; CHECK-LABEL: @minnum_undef_poison(
606 ; CHECK-NEXT: ret float poison
608 %val = call float @llvm.minnum.f32(float undef, float poison)
612 define float @maxnum_undef_undef(float %x) {
613 ; CHECK-LABEL: @maxnum_undef_undef(
614 ; CHECK-NEXT: ret float undef
616 %val = call float @llvm.maxnum.f32(float undef, float undef)
620 define float @maxnum_poison_undef(float %x) {
621 ; CHECK-LABEL: @maxnum_poison_undef(
622 ; CHECK-NEXT: ret float undef
624 %val = call float @llvm.maxnum.f32(float poison, float undef)
628 define float @maxnum_undef_poison(float %x) {
629 ; CHECK-LABEL: @maxnum_undef_poison(
630 ; CHECK-NEXT: ret float poison
632 %val = call float @llvm.maxnum.f32(float undef, float poison)
636 define float @minnum_same_args(float %x) {
637 ; CHECK-LABEL: @minnum_same_args(
638 ; CHECK-NEXT: ret float [[X:%.*]]
640 %y = call float @llvm.minnum.f32(float %x, float %x)
644 define float @maxnum_same_args(float %x) {
645 ; CHECK-LABEL: @maxnum_same_args(
646 ; CHECK-NEXT: ret float [[X:%.*]]
648 %y = call float @llvm.maxnum.f32(float %x, float %x)
652 define float @minnum_x_minnum_x_y(float %x, float %y) {
653 ; CHECK-LABEL: @minnum_x_minnum_x_y(
654 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
655 ; CHECK-NEXT: ret float [[A]]
657 %a = call float @llvm.minnum.f32(float %x, float %y)
658 %b = call float @llvm.minnum.f32(float %x, float %a)
662 define float @minnum_y_minnum_x_y(float %x, float %y) {
663 ; CHECK-LABEL: @minnum_y_minnum_x_y(
664 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
665 ; CHECK-NEXT: ret float [[A]]
667 %a = call float @llvm.minnum.f32(float %x, float %y)
668 %b = call float @llvm.minnum.f32(float %y, float %a)
672 define float @minnum_x_y_minnum_x(float %x, float %y) {
673 ; CHECK-LABEL: @minnum_x_y_minnum_x(
674 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
675 ; CHECK-NEXT: ret float [[A]]
677 %a = call float @llvm.minnum.f32(float %x, float %y)
678 %b = call float @llvm.minnum.f32(float %a, float %x)
682 define float @minnum_x_y_minnum_y(float %x, float %y) {
683 ; CHECK-LABEL: @minnum_x_y_minnum_y(
684 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
685 ; CHECK-NEXT: ret float [[A]]
687 %a = call float @llvm.minnum.f32(float %x, float %y)
688 %b = call float @llvm.minnum.f32(float %a, float %y)
694 define float @minnum_z_minnum_x_y(float %x, float %y, float %z) {
695 ; CHECK-LABEL: @minnum_z_minnum_x_y(
696 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
697 ; CHECK-NEXT: [[B:%.*]] = call float @llvm.minnum.f32(float [[Z:%.*]], float [[A]])
698 ; CHECK-NEXT: ret float [[B]]
700 %a = call float @llvm.minnum.f32(float %x, float %y)
701 %b = call float @llvm.minnum.f32(float %z, float %a)
707 define float @minnum_x_y_minnum_z(float %x, float %y, float %z) {
708 ; CHECK-LABEL: @minnum_x_y_minnum_z(
709 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
710 ; CHECK-NEXT: [[B:%.*]] = call float @llvm.minnum.f32(float [[A]], float [[Z:%.*]])
711 ; CHECK-NEXT: ret float [[B]]
713 %a = call float @llvm.minnum.f32(float %x, float %y)
714 %b = call float @llvm.minnum.f32(float %a, float %z)
718 ; minnum(X, -INF) --> -INF
720 define float @minnum_neginf(float %x) {
721 ; CHECK-LABEL: @minnum_neginf(
722 ; CHECK-NEXT: ret float 0xFFF0000000000000
724 %val = call float @llvm.minnum.f32(float %x, float 0xFFF0000000000000)
728 define <2 x double> @minnum_neginf_commute_vec(<2 x double> %x) {
729 ; CHECK-LABEL: @minnum_neginf_commute_vec(
730 ; CHECK-NEXT: ret <2 x double> <double 0xFFF0000000000000, double 0xFFF0000000000000>
732 %r = call <2 x double> @llvm.minnum.v2f64(<2 x double> <double 0xFFF0000000000000, double 0xFFF0000000000000>, <2 x double> %x)
738 define float @minnum_inf(float %x) {
739 ; CHECK-LABEL: @minnum_inf(
740 ; CHECK-NEXT: [[VAL:%.*]] = call float @llvm.minnum.f32(float 0x7FF0000000000000, float [[X:%.*]])
741 ; CHECK-NEXT: ret float [[VAL]]
743 %val = call float @llvm.minnum.f32(float 0x7FF0000000000000, float %x)
746 define float @maxnum_x_maxnum_x_y(float %x, float %y) {
747 ; CHECK-LABEL: @maxnum_x_maxnum_x_y(
748 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float [[Y:%.*]])
749 ; CHECK-NEXT: ret float [[A]]
751 %a = call float @llvm.maxnum.f32(float %x, float %y)
752 %b = call float @llvm.maxnum.f32(float %x, float %a)
756 define float @maxnum_y_maxnum_x_y(float %x, float %y) {
757 ; CHECK-LABEL: @maxnum_y_maxnum_x_y(
758 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float [[Y:%.*]])
759 ; CHECK-NEXT: ret float [[A]]
761 %a = call float @llvm.maxnum.f32(float %x, float %y)
762 %b = call float @llvm.maxnum.f32(float %y, float %a)
766 define float @maxnum_x_y_maxnum_x(float %x, float %y) {
767 ; CHECK-LABEL: @maxnum_x_y_maxnum_x(
768 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float [[Y:%.*]])
769 ; CHECK-NEXT: ret float [[A]]
771 %a = call float @llvm.maxnum.f32(float %x, float %y)
772 %b = call float @llvm.maxnum.f32(float %a, float %x)
776 define float @maxnum_x_y_maxnum_y(float %x, float %y) {
777 ; CHECK-LABEL: @maxnum_x_y_maxnum_y(
778 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float [[Y:%.*]])
779 ; CHECK-NEXT: ret float [[A]]
781 %a = call float @llvm.maxnum.f32(float %x, float %y)
782 %b = call float @llvm.maxnum.f32(float %a, float %y)
788 define float @maxnum_z_maxnum_x_y(float %x, float %y, float %z) {
789 ; CHECK-LABEL: @maxnum_z_maxnum_x_y(
790 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float [[Y:%.*]])
791 ; CHECK-NEXT: [[B:%.*]] = call float @llvm.maxnum.f32(float [[Z:%.*]], float [[A]])
792 ; CHECK-NEXT: ret float [[B]]
794 %a = call float @llvm.maxnum.f32(float %x, float %y)
795 %b = call float @llvm.maxnum.f32(float %z, float %a)
801 define float @maxnum_x_y_maxnum_z(float %x, float %y, float %z) {
802 ; CHECK-LABEL: @maxnum_x_y_maxnum_z(
803 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float [[Y:%.*]])
804 ; CHECK-NEXT: [[B:%.*]] = call float @llvm.maxnum.f32(float [[A]], float [[Z:%.*]])
805 ; CHECK-NEXT: ret float [[B]]
807 %a = call float @llvm.maxnum.f32(float %x, float %y)
808 %b = call float @llvm.maxnum.f32(float %a, float %z)
812 ; maxnum(X, INF) --> INF
814 define <2 x double> @maxnum_inf(<2 x double> %x) {
815 ; CHECK-LABEL: @maxnum_inf(
816 ; CHECK-NEXT: ret <2 x double> <double 0x7FF0000000000000, double 0x7FF0000000000000>
818 %val = call <2 x double> @llvm.maxnum.v2f64(<2 x double> %x, <2 x double><double 0x7FF0000000000000, double 0x7FF0000000000000>)
819 ret <2 x double> %val
822 define float @maxnum_inf_commute(float %x) {
823 ; CHECK-LABEL: @maxnum_inf_commute(
824 ; CHECK-NEXT: ret float 0x7FF0000000000000
826 %val = call float @llvm.maxnum.f32(float 0x7FF0000000000000, float %x)
832 define float @maxnum_neginf(float %x) {
833 ; CHECK-LABEL: @maxnum_neginf(
834 ; CHECK-NEXT: [[VAL:%.*]] = call float @llvm.maxnum.f32(float 0xFFF0000000000000, float [[X:%.*]])
835 ; CHECK-NEXT: ret float [[VAL]]
837 %val = call float @llvm.maxnum.f32(float 0xFFF0000000000000, float %x)
841 ; From the LangRef for minimum/maximum:
842 ; "If either operand is a NaN, returns NaN."
844 define double @maximum_nan_op0(double %x) {
845 ; CHECK-LABEL: @maximum_nan_op0(
846 ; CHECK-NEXT: ret double 0x7FF8000000000000
848 %r = call double @llvm.maximum.f64(double 0x7ff8000000000000, double %x)
852 define double @maximum_nan_op1(double %x) {
853 ; CHECK-LABEL: @maximum_nan_op1(
854 ; CHECK-NEXT: ret double 0x7FF800000000DEAD
856 %r = call double @llvm.maximum.f64(double %x, double 0x7ff800000000dead)
860 define double @minimum_nan_op0(double %x) {
861 ; CHECK-LABEL: @minimum_nan_op0(
862 ; CHECK-NEXT: ret double 0x7FF8000DEAD00000
864 %r = call double @llvm.minimum.f64(double 0x7ff8000dead00000, double %x)
868 define double @minimum_nan_op1(double %x) {
869 ; CHECK-LABEL: @minimum_nan_op1(
870 ; CHECK-NEXT: ret double 0x7FF800DEAD00DEAD
872 %r = call double @llvm.minimum.f64(double %x, double 0x7ff800dead00dead)
876 define <2 x double> @maximum_nan_op0_vec_partial_poison(<2 x double> %x) {
877 ; CHECK-LABEL: @maximum_nan_op0_vec_partial_poison(
878 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double poison>
880 %r = call <2 x double> @llvm.maximum.v2f64(<2 x double> <double 0x7ff8000000000000, double poison>, <2 x double> %x)
884 define <2 x double> @maximum_nan_op1_vec_partial_poison(<2 x double> %x) {
885 ; CHECK-LABEL: @maximum_nan_op1_vec_partial_poison(
886 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double poison>
888 %r = call <2 x double> @llvm.maximum.v2f64(<2 x double> %x, <2 x double> <double 0x7ff8000000000000, double poison>)
892 define <2 x double> @maximum_nan_op1_vec(<2 x double> %x) {
893 ; CHECK-LABEL: @maximum_nan_op1_vec(
894 ; CHECK-NEXT: ret <2 x double> <double 0x7FF800000000DEAD, double 0x7FF8FFFFFFFFFFFF>
896 %r = call <2 x double> @llvm.maximum.v2f64(<2 x double> %x, <2 x double> <double 0x7ff800000000dead, double 0x7ff8ffffffffffff>)
900 define <2 x double> @minimum_nan_op0_vec_partial_poison(<2 x double> %x) {
901 ; CHECK-LABEL: @minimum_nan_op0_vec_partial_poison(
902 ; CHECK-NEXT: ret <2 x double> <double poison, double 0x7FF8000DEAD00000>
904 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> <double poison, double 0x7ff8000dead00000>, <2 x double> %x)
908 define <2 x double> @minimum_nan_op1_vec_partial_poison(<2 x double> %x) {
909 ; CHECK-LABEL: @minimum_nan_op1_vec_partial_poison(
910 ; CHECK-NEXT: ret <2 x double> <double poison, double 0x7FF8000DEAD00000>
912 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> %x, <2 x double> <double poison, double 0x7ff8000dead00000>)
916 define <2 x double> @minimum_nan_op1_vec(<2 x double> %x) {
917 ; CHECK-LABEL: @minimum_nan_op1_vec(
918 ; CHECK-NEXT: ret <2 x double> <double 0x7FF800DEAD00DEAD, double 0x7FF800DEAD00DEAD>
920 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> %x, <2 x double> <double 0x7ff800dead00dead, double 0x7ff800dead00dead>)
924 define float @maximum_undef_op1(float %x) {
925 ; CHECK-LABEL: @maximum_undef_op1(
926 ; CHECK-NEXT: ret float [[X:%.*]]
928 %val = call float @llvm.maximum.f32(float %x, float undef)
932 define float @maximum_poison_op1(float %x) {
933 ; CHECK-LABEL: @maximum_poison_op1(
934 ; CHECK-NEXT: ret float [[X:%.*]]
936 %val = call float @llvm.maximum.f32(float %x, float poison)
940 define float @maximum_undef_op0(float %x) {
941 ; CHECK-LABEL: @maximum_undef_op0(
942 ; CHECK-NEXT: ret float [[X:%.*]]
944 %val = call float @llvm.maximum.f32(float undef, float %x)
948 define float @maximum_poison_op0(float %x) {
949 ; CHECK-LABEL: @maximum_poison_op0(
950 ; CHECK-NEXT: ret float [[X:%.*]]
952 %val = call float @llvm.maximum.f32(float poison, float %x)
956 define float @minimum_undef_op1(float %x) {
957 ; CHECK-LABEL: @minimum_undef_op1(
958 ; CHECK-NEXT: ret float [[X:%.*]]
960 %val = call float @llvm.minimum.f32(float %x, float undef)
964 define float @minimum_poison_op1(float %x) {
965 ; CHECK-LABEL: @minimum_poison_op1(
966 ; CHECK-NEXT: ret float [[X:%.*]]
968 %val = call float @llvm.minimum.f32(float %x, float poison)
972 define float @minimum_undef_op0(float %x) {
973 ; CHECK-LABEL: @minimum_undef_op0(
974 ; CHECK-NEXT: ret float [[X:%.*]]
976 %val = call float @llvm.minimum.f32(float undef, float %x)
980 define float @minimum_poison_op0(float %x) {
981 ; CHECK-LABEL: @minimum_poison_op0(
982 ; CHECK-NEXT: ret float [[X:%.*]]
984 %val = call float @llvm.minimum.f32(float poison, float %x)
988 define float @minimum_undef_undef(float %x) {
989 ; CHECK-LABEL: @minimum_undef_undef(
990 ; CHECK-NEXT: ret float undef
992 %val = call float @llvm.minimum.f32(float undef, float undef)
996 define float @maximum_undef_undef(float %x) {
997 ; CHECK-LABEL: @maximum_undef_undef(
998 ; CHECK-NEXT: ret float undef
1000 %val = call float @llvm.maximum.f32(float undef, float undef)
1004 define float @minimum_same_args(float %x) {
1005 ; CHECK-LABEL: @minimum_same_args(
1006 ; CHECK-NEXT: ret float [[X:%.*]]
1008 %y = call float @llvm.minimum.f32(float %x, float %x)
1012 define float @maximum_same_args(float %x) {
1013 ; CHECK-LABEL: @maximum_same_args(
1014 ; CHECK-NEXT: ret float [[X:%.*]]
1016 %y = call float @llvm.maximum.f32(float %x, float %x)
1020 define float @minimum_x_minimum_x_y(float %x, float %y) {
1021 ; CHECK-LABEL: @minimum_x_minimum_x_y(
1022 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float [[Y:%.*]])
1023 ; CHECK-NEXT: ret float [[A]]
1025 %a = call float @llvm.minimum.f32(float %x, float %y)
1026 %b = call float @llvm.minimum.f32(float %x, float %a)
1030 define float @minimum_y_minimum_x_y(float %x, float %y) {
1031 ; CHECK-LABEL: @minimum_y_minimum_x_y(
1032 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float [[Y:%.*]])
1033 ; CHECK-NEXT: ret float [[A]]
1035 %a = call float @llvm.minimum.f32(float %x, float %y)
1036 %b = call float @llvm.minimum.f32(float %y, float %a)
1040 define float @minimum_x_y_minimum_x(float %x, float %y) {
1041 ; CHECK-LABEL: @minimum_x_y_minimum_x(
1042 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float [[Y:%.*]])
1043 ; CHECK-NEXT: ret float [[A]]
1045 %a = call float @llvm.minimum.f32(float %x, float %y)
1046 %b = call float @llvm.minimum.f32(float %a, float %x)
1050 define float @minimum_x_y_minimum_y(float %x, float %y) {
1051 ; CHECK-LABEL: @minimum_x_y_minimum_y(
1052 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float [[Y:%.*]])
1053 ; CHECK-NEXT: ret float [[A]]
1055 %a = call float @llvm.minimum.f32(float %x, float %y)
1056 %b = call float @llvm.minimum.f32(float %a, float %y)
1062 define float @minimum_z_minimum_x_y(float %x, float %y, float %z) {
1063 ; CHECK-LABEL: @minimum_z_minimum_x_y(
1064 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float [[Y:%.*]])
1065 ; CHECK-NEXT: [[B:%.*]] = call float @llvm.minimum.f32(float [[Z:%.*]], float [[A]])
1066 ; CHECK-NEXT: ret float [[B]]
1068 %a = call float @llvm.minimum.f32(float %x, float %y)
1069 %b = call float @llvm.minimum.f32(float %z, float %a)
1075 define float @minimum_x_y_minimum_z(float %x, float %y, float %z) {
1076 ; CHECK-LABEL: @minimum_x_y_minimum_z(
1077 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float [[Y:%.*]])
1078 ; CHECK-NEXT: [[B:%.*]] = call float @llvm.minimum.f32(float [[A]], float [[Z:%.*]])
1079 ; CHECK-NEXT: ret float [[B]]
1081 %a = call float @llvm.minimum.f32(float %x, float %y)
1082 %b = call float @llvm.minimum.f32(float %a, float %z)
1086 define float @maximum_x_maximum_x_y(float %x, float %y) {
1087 ; CHECK-LABEL: @maximum_x_maximum_x_y(
1088 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float [[Y:%.*]])
1089 ; CHECK-NEXT: ret float [[A]]
1091 %a = call float @llvm.maximum.f32(float %x, float %y)
1092 %b = call float @llvm.maximum.f32(float %x, float %a)
1096 define float @maximum_y_maximum_x_y(float %x, float %y) {
1097 ; CHECK-LABEL: @maximum_y_maximum_x_y(
1098 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float [[Y:%.*]])
1099 ; CHECK-NEXT: ret float [[A]]
1101 %a = call float @llvm.maximum.f32(float %x, float %y)
1102 %b = call float @llvm.maximum.f32(float %y, float %a)
1106 define float @maximum_x_y_maximum_x(float %x, float %y) {
1107 ; CHECK-LABEL: @maximum_x_y_maximum_x(
1108 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float [[Y:%.*]])
1109 ; CHECK-NEXT: ret float [[A]]
1111 %a = call float @llvm.maximum.f32(float %x, float %y)
1112 %b = call float @llvm.maximum.f32(float %a, float %x)
1116 define float @maximum_x_y_maximum_y(float %x, float %y) {
1117 ; CHECK-LABEL: @maximum_x_y_maximum_y(
1118 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float [[Y:%.*]])
1119 ; CHECK-NEXT: ret float [[A]]
1121 %a = call float @llvm.maximum.f32(float %x, float %y)
1122 %b = call float @llvm.maximum.f32(float %a, float %y)
1128 define float @maximum_z_maximum_x_y(float %x, float %y, float %z) {
1129 ; CHECK-LABEL: @maximum_z_maximum_x_y(
1130 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float [[Y:%.*]])
1131 ; CHECK-NEXT: [[B:%.*]] = call float @llvm.maximum.f32(float [[Z:%.*]], float [[A]])
1132 ; CHECK-NEXT: ret float [[B]]
1134 %a = call float @llvm.maximum.f32(float %x, float %y)
1135 %b = call float @llvm.maximum.f32(float %z, float %a)
1141 define float @maximum_x_y_maximum_z(float %x, float %y, float %z) {
1142 ; CHECK-LABEL: @maximum_x_y_maximum_z(
1143 ; CHECK-NEXT: [[A:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float [[Y:%.*]])
1144 ; CHECK-NEXT: [[B:%.*]] = call float @llvm.maximum.f32(float [[A]], float [[Z:%.*]])
1145 ; CHECK-NEXT: ret float [[B]]
1147 %a = call float @llvm.maximum.f32(float %x, float %y)
1148 %b = call float @llvm.maximum.f32(float %a, float %z)
1152 ; negative test - minimum(X, -INF) != -INF because X could be NaN
1154 define float @minimum_neginf(float %x) {
1155 ; CHECK-LABEL: @minimum_neginf(
1156 ; CHECK-NEXT: [[VAL:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float 0xFFF0000000000000)
1157 ; CHECK-NEXT: ret float [[VAL]]
1159 %val = call float @llvm.minimum.f32(float %x, float 0xFFF0000000000000)
1163 ; negative test - minimum(-INF, X) != -INF because X could be NaN
1165 define <2 x double> @minimum_neginf_commute_vec(<2 x double> %x) {
1166 ; CHECK-LABEL: @minimum_neginf_commute_vec(
1167 ; CHECK-NEXT: [[R:%.*]] = call <2 x double> @llvm.minimum.v2f64(<2 x double> <double 0xFFF0000000000000, double 0xFFF0000000000000>, <2 x double> [[X:%.*]])
1168 ; CHECK-NEXT: ret <2 x double> [[R]]
1170 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> <double 0xFFF0000000000000, double 0xFFF0000000000000>, <2 x double> %x)
1174 ; TODO: minimum(INF, X) --> X
1176 define float @minimum_inf(float %x) {
1177 ; CHECK-LABEL: @minimum_inf(
1178 ; CHECK-NEXT: ret float [[X:%.*]]
1180 %val = call float @llvm.minimum.f32(float 0x7FF0000000000000, float %x)
1184 ; negative test - maximum(X, INF) != INF because X could be NaN
1186 define <2 x double> @maximum_inf(<2 x double> %x) {
1187 ; CHECK-LABEL: @maximum_inf(
1188 ; CHECK-NEXT: [[VAL:%.*]] = call <2 x double> @llvm.maximum.v2f64(<2 x double> [[X:%.*]], <2 x double> <double 0x7FF0000000000000, double 0x7FF0000000000000>)
1189 ; CHECK-NEXT: ret <2 x double> [[VAL]]
1191 %val = call <2 x double> @llvm.maximum.v2f64(<2 x double> %x, <2 x double><double 0x7FF0000000000000, double 0x7FF0000000000000>)
1192 ret <2 x double> %val
1195 ; negative test - maximum(INF, X) != INF because X could be NaN
1197 define float @maximum_inf_commute(float %x) {
1198 ; CHECK-LABEL: @maximum_inf_commute(
1199 ; CHECK-NEXT: [[VAL:%.*]] = call float @llvm.maximum.f32(float 0x7FF0000000000000, float [[X:%.*]])
1200 ; CHECK-NEXT: ret float [[VAL]]
1202 %val = call float @llvm.maximum.f32(float 0x7FF0000000000000, float %x)
1206 define float @maximum_maximum_minimum(float %x, float %y) {
1207 ; CHECK-LABEL: @maximum_maximum_minimum(
1208 ; CHECK-NEXT: [[MAX:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float [[Y:%.*]])
1209 ; CHECK-NEXT: ret float [[MAX]]
1211 %max = call float @llvm.maximum.f32(float %x, float %y)
1212 %min = call float @llvm.minimum.f32(float %x, float %y)
1213 %val = call float @llvm.maximum.f32(float %max, float %min)
1217 define double @maximum_minimum_maximum(double %x, double %y) {
1218 ; CHECK-LABEL: @maximum_minimum_maximum(
1219 ; CHECK-NEXT: [[MAX:%.*]] = call double @llvm.maximum.f64(double [[X:%.*]], double [[Y:%.*]])
1220 ; CHECK-NEXT: ret double [[MAX]]
1222 %max = call double @llvm.maximum.f64(double %x, double %y)
1223 %min = call double @llvm.minimum.f64(double %x, double %y)
1224 %val = call double @llvm.maximum.f64(double %min, double %max)
1228 define float @maximum_minimum_minimum(float %x, float %y) {
1229 ; CHECK-LABEL: @maximum_minimum_minimum(
1230 ; CHECK-NEXT: [[MIN1:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float [[Y:%.*]])
1231 ; CHECK-NEXT: [[MIN2:%.*]] = call float @llvm.minimum.f32(float [[X]], float [[Y]])
1232 ; CHECK-NEXT: [[VAL:%.*]] = call float @llvm.maximum.f32(float [[MIN1]], float [[MIN2]])
1233 ; CHECK-NEXT: ret float [[VAL]]
1235 %min1 = call float @llvm.minimum.f32(float %x, float %y)
1236 %min2 = call float @llvm.minimum.f32(float %x, float %y)
1237 %val = call float @llvm.maximum.f32(float %min1, float %min2)
1241 define half @maximum_maximum_maximum(half %x, half %y) {
1242 ; CHECK-LABEL: @maximum_maximum_maximum(
1243 ; CHECK-NEXT: [[MAX1:%.*]] = call half @llvm.maximum.f16(half [[X:%.*]], half [[Y:%.*]])
1244 ; CHECK-NEXT: ret half [[MAX1]]
1246 %max1 = call half @llvm.maximum.f16(half %x, half %y)
1247 %max2 = call half @llvm.maximum.f16(half %x, half %y)
1248 %val = call half @llvm.maximum.f16(half %max1, half %max2)
1252 define <2 x float> @minimum_maximum_minimum(<2 x float> %x, <2 x float> %y) {
1253 ; CHECK-LABEL: @minimum_maximum_minimum(
1254 ; CHECK-NEXT: [[MIN:%.*]] = call <2 x float> @llvm.minimum.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]])
1255 ; CHECK-NEXT: ret <2 x float> [[MIN]]
1257 %max = call <2 x float> @llvm.maximum.v2f32(<2 x float> %x, <2 x float> %y)
1258 %min = call <2 x float> @llvm.minimum.v2f32(<2 x float> %x, <2 x float> %y)
1259 %val = call <2 x float> @llvm.minimum.v2f32(<2 x float> %max, <2 x float> %min)
1260 ret <2 x float> %val
1263 define <2 x double> @minimum_minimum_maximum(<2 x double> %x, <2 x double> %y) {
1264 ; CHECK-LABEL: @minimum_minimum_maximum(
1265 ; CHECK-NEXT: [[MIN:%.*]] = call <2 x double> @llvm.minimum.v2f64(<2 x double> [[X:%.*]], <2 x double> [[Y:%.*]])
1266 ; CHECK-NEXT: ret <2 x double> [[MIN]]
1268 %max = call <2 x double> @llvm.maximum.v2f64(<2 x double> %x, <2 x double> %y)
1269 %min = call <2 x double> @llvm.minimum.v2f64(<2 x double> %x, <2 x double> %y)
1270 %val = call <2 x double> @llvm.minimum.v2f64(<2 x double> %min, <2 x double> %max)
1271 ret <2 x double> %val
1274 define float @minimum_maximum_maximum(float %x, float %y) {
1275 ; CHECK-LABEL: @minimum_maximum_maximum(
1276 ; CHECK-NEXT: [[MAX1:%.*]] = call float @llvm.maximum.f32(float [[X:%.*]], float [[Y:%.*]])
1277 ; CHECK-NEXT: [[MAX2:%.*]] = call float @llvm.maximum.f32(float [[X]], float [[Y]])
1278 ; CHECK-NEXT: [[VAL:%.*]] = call float @llvm.minimum.f32(float [[MAX1]], float [[MAX2]])
1279 ; CHECK-NEXT: ret float [[VAL]]
1281 %max1 = call float @llvm.maximum.f32(float %x, float %y)
1282 %max2 = call float @llvm.maximum.f32(float %x, float %y)
1283 %val = call float @llvm.minimum.f32(float %max1, float %max2)
1287 define float @minimum_minimum_minimum(float %x, float %y) {
1288 ; CHECK-LABEL: @minimum_minimum_minimum(
1289 ; CHECK-NEXT: [[MIN1:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float [[Y:%.*]])
1290 ; CHECK-NEXT: ret float [[MIN1]]
1292 %min1 = call float @llvm.minimum.f32(float %x, float %y)
1293 %min2 = call float @llvm.minimum.f32(float %x, float %y)
1294 %val = call float @llvm.minimum.f32(float %min1, float %min2)
1298 define double @maxnum_maxnum_minnum(double %x, double %y) {
1299 ; CHECK-LABEL: @maxnum_maxnum_minnum(
1300 ; CHECK-NEXT: [[MAX:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y:%.*]])
1301 ; CHECK-NEXT: ret double [[MAX]]
1303 %max = call double @llvm.maxnum.f64(double %x, double %y)
1304 %min = call double @llvm.minnum.f64(double %x, double %y)
1305 %val = call double @llvm.maxnum.f64(double %max, double %min)
1309 define <2 x float> @maxnum_minnum_maxnum(<2 x float> %x, <2 x float> %y) {
1310 ; CHECK-LABEL: @maxnum_minnum_maxnum(
1311 ; CHECK-NEXT: [[MAX:%.*]] = call <2 x float> @llvm.maxnum.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]])
1312 ; CHECK-NEXT: ret <2 x float> [[MAX]]
1314 %max = call <2 x float> @llvm.maxnum.v2f32(<2 x float> %x, <2 x float> %y)
1315 %min = call <2 x float> @llvm.minnum.v2f32(<2 x float> %x, <2 x float> %y)
1316 %val = call <2 x float> @llvm.maxnum.v2f32(<2 x float> %min, <2 x float> %max)
1317 ret <2 x float> %val
1320 define <2 x double> @maxnum_minnum_minmum(<2 x double> %x, <2 x double> %y) {
1321 ; CHECK-LABEL: @maxnum_minnum_minmum(
1322 ; CHECK-NEXT: [[MIN1:%.*]] = call <2 x double> @llvm.minnum.v2f64(<2 x double> [[X:%.*]], <2 x double> [[Y:%.*]])
1323 ; CHECK-NEXT: [[MIN2:%.*]] = call <2 x double> @llvm.minnum.v2f64(<2 x double> [[X]], <2 x double> [[Y]])
1324 ; CHECK-NEXT: [[VAL:%.*]] = call <2 x double> @llvm.maxnum.v2f64(<2 x double> [[MIN1]], <2 x double> [[MIN2]])
1325 ; CHECK-NEXT: ret <2 x double> [[VAL]]
1327 %min1 = call <2 x double> @llvm.minnum.v2f64(<2 x double> %x, <2 x double> %y)
1328 %min2 = call <2 x double> @llvm.minnum.v2f64(<2 x double> %x, <2 x double> %y)
1329 %val = call <2 x double> @llvm.maxnum.v2f64(<2 x double> %min1, <2 x double> %min2)
1330 ret <2 x double> %val
1333 define float @maxnum_maxnum_maxnum(float %x, float %y) {
1334 ; CHECK-LABEL: @maxnum_maxnum_maxnum(
1335 ; CHECK-NEXT: [[MAX1:%.*]] = call float @llvm.maxnum.f32(float [[X:%.*]], float [[Y:%.*]])
1336 ; CHECK-NEXT: ret float [[MAX1]]
1338 %max1 = call float @llvm.maxnum.f32(float %x, float %y)
1339 %max2 = call float @llvm.maxnum.f32(float %x, float %y)
1340 %val = call float @llvm.maxnum.f32(float %max1, float %max2)
1344 define double @minnum_maxnum_minnum(double %x, double %y) {
1345 ; CHECK-LABEL: @minnum_maxnum_minnum(
1346 ; CHECK-NEXT: [[MIN:%.*]] = call double @llvm.minnum.f64(double [[X:%.*]], double [[Y:%.*]])
1347 ; CHECK-NEXT: ret double [[MIN]]
1349 %max = call double @llvm.maxnum.f64(double %x, double %y)
1350 %min = call double @llvm.minnum.f64(double %x, double %y)
1351 %val = call double @llvm.minnum.f64(double %max, double %min)
1355 define float @minnum_minnum_maxnum(float %x, float %y) {
1356 ; CHECK-LABEL: @minnum_minnum_maxnum(
1357 ; CHECK-NEXT: [[MIN:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]])
1358 ; CHECK-NEXT: ret float [[MIN]]
1360 %max = call float @llvm.maxnum.f32(float %x, float %y)
1361 %min = call float @llvm.minnum.f32(float %x, float %y)
1362 %val = call float @llvm.minnum.f32(float %min, float %max)
1366 define <2 x float> @minnum_maxnum_maxnum(<2 x float> %x, <2 x float> %y) {
1367 ; CHECK-LABEL: @minnum_maxnum_maxnum(
1368 ; CHECK-NEXT: [[MAX1:%.*]] = call <2 x float> @llvm.maxnum.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]])
1369 ; CHECK-NEXT: [[MAX2:%.*]] = call <2 x float> @llvm.maxnum.v2f32(<2 x float> [[X]], <2 x float> [[Y]])
1370 ; CHECK-NEXT: [[VAL:%.*]] = call <2 x float> @llvm.minnum.v2f32(<2 x float> [[MAX1]], <2 x float> [[MAX2]])
1371 ; CHECK-NEXT: ret <2 x float> [[VAL]]
1373 %max1 = call <2 x float> @llvm.maxnum.v2f32(<2 x float> %x, <2 x float> %y)
1374 %max2 = call <2 x float> @llvm.maxnum.v2f32(<2 x float> %x, <2 x float> %y)
1375 %val = call <2 x float> @llvm.minnum.v2f32(<2 x float> %max1, <2 x float> %max2)
1376 ret <2 x float> %val
1379 define <2 x double> @minnum_minnum_minmum(<2 x double> %x, <2 x double> %y) {
1380 ; CHECK-LABEL: @minnum_minnum_minmum(
1381 ; CHECK-NEXT: [[MIN1:%.*]] = call <2 x double> @llvm.minnum.v2f64(<2 x double> [[X:%.*]], <2 x double> [[Y:%.*]])
1382 ; CHECK-NEXT: ret <2 x double> [[MIN1]]
1384 %min1 = call <2 x double> @llvm.minnum.v2f64(<2 x double> %x, <2 x double> %y)
1385 %min2 = call <2 x double> @llvm.minnum.v2f64(<2 x double> %x, <2 x double> %y)
1386 %val = call <2 x double> @llvm.minnum.v2f64(<2 x double> %min1, <2 x double> %min2)
1387 ret <2 x double> %val