1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=instsimplify < %s | FileCheck %s
4 ; Test cases for denormal handling mode when constant folding floating point
5 ; operations. Input and output modes are checked seperately.
7 ; ============================================================================ ;
9 ; Denormal operand added to normal operand produces denormal result.
10 ; If denormal outputs should be flushed to zero, the result should be zero.
11 ; If denormal inputs should be treated as zero, the result should be the
12 ; normal operand (a number plus zero is the same number).
13 ; ============================================================================ ;
15 define float @test_float_fadd_ieee() #0 {
16 ; CHECK-LABEL: @test_float_fadd_ieee(
17 ; CHECK-NEXT: ret float 0xB800000000000000
19 ; default ieee mode leaves result as a denormal
20 %result = fadd float 0xB810000000000000, 0x3800000000000000
24 define float @test_float_fadd_pzero_out() #1 {
25 ; CHECK-LABEL: @test_float_fadd_pzero_out(
26 ; CHECK-NEXT: ret float 0.000000e+00
28 ; denormal result is flushed to positive zero
29 %result = fadd float 0xB810000000000000, 0x3800000000000000
33 define float @test_float_fadd_psign_out() #2 {
34 ; CHECK-LABEL: @test_float_fadd_psign_out(
35 ; CHECK-NEXT: ret float -0.000000e+00
37 ; denormal result is flushed to sign preserved zero
38 %result = fadd float 0xB810000000000000, 0x3800000000000000
42 define float @test_float_fadd_pzero_in() #3 {
43 ; CHECK-LABEL: @test_float_fadd_pzero_in(
44 ; CHECK-NEXT: ret float 0xB810000000000000
46 ; denormal operand is treated as zero
47 ; normal operand added to zero results in the same operand as a result
48 %result = fadd float 0xB810000000000000, 0x3800000000000000
52 define float @test_float_fadd_psign_in() #4 {
53 ; CHECK-LABEL: @test_float_fadd_psign_in(
54 ; CHECK-NEXT: ret float 0xB810000000000000
56 ; denormal operand is treated as zero
57 ; normal operand added to zero results in the same operand as a result
58 %result = fadd float 0xB810000000000000, 0x3800000000000000
62 define float @test_float_fadd_pzero_f32_out() #5 {
63 ; CHECK-LABEL: @test_float_fadd_pzero_f32_out(
64 ; CHECK-NEXT: ret float 0.000000e+00
66 ; f32 only attribute should flush float output
67 ; default ieee mode leaves result as a denormal
68 %result = fadd float 0xB810000000000000, 0x3800000000000000
72 define double @test_double_fadd_ieee() #0 {
73 ; CHECK-LABEL: @test_double_fadd_ieee(
74 ; CHECK-NEXT: ret double 0x8008000000000000
76 ; default ieee mode leaves result as a denormal
77 %result = fadd double 0x8010000000000000, 0x0008000000000000
81 define double @test_double_fadd_pzero_out() #1 {
82 ; CHECK-LABEL: @test_double_fadd_pzero_out(
83 ; CHECK-NEXT: ret double 0.000000e+00
85 ; denormal result is flushed to positive zero
86 %result = fadd double 0x8010000000000000, 0x0008000000000000
90 define double @test_double_fadd_psign_out() #2 {
91 ; CHECK-LABEL: @test_double_fadd_psign_out(
92 ; CHECK-NEXT: ret double -0.000000e+00
94 ; denormal result is flushed to sign preserved zero
95 %result = fadd double 0x8010000000000000, 0x0008000000000000
99 define double @test_double_fadd_pzero_in() #3 {
100 ; CHECK-LABEL: @test_double_fadd_pzero_in(
101 ; CHECK-NEXT: ret double 0x8010000000000000
103 ; denormal operand is treated as zero
104 ; normal operand added to zero results in the same operand as a result
105 %result = fadd double 0x8010000000000000, 0x0008000000000000
109 define double @test_double_fadd_psign_in() #4 {
110 ; CHECK-LABEL: @test_double_fadd_psign_in(
111 ; CHECK-NEXT: ret double 0x8010000000000000
113 ; denormal operand is treated as zero
114 ; normal operand added to zero results in the same operand as a result
115 %result = fadd double 0x8010000000000000, 0x0008000000000000
119 define double @test_double_fadd_f32_ieee() #5 {
120 ; CHECK-LABEL: @test_double_fadd_f32_ieee(
121 ; CHECK-NEXT: ret double 0x8008000000000000
123 ; f32 only attribute should not flush doubles
124 ; default ieee mode leaves result as a denormal
125 %result = fadd double 0x8010000000000000, 0x0008000000000000
129 ; ============================================================================ ;
131 ; Normal operand subtracted from denormal operand produces denormal result
132 ; If denormal outputs should be flushed to zero, the result should be zero.
133 ; If denormal inputs should be treated as zero, the result should be the
134 ; negated normal operand (zero minus the original operand).
135 ; ============================================================================ ;
137 define float @test_float_fsub_ieee() #0 {
138 ; CHECK-LABEL: @test_float_fsub_ieee(
139 ; CHECK-NEXT: ret float 0xB800000000000000
141 ; default ieee mode leaves result as a denormal
142 %result = fsub float 0x3800000000000000, 0x3810000000000000
146 define float @test_float_fsub_pzero_out() #1 {
147 ; CHECK-LABEL: @test_float_fsub_pzero_out(
148 ; CHECK-NEXT: ret float 0.000000e+00
150 ; denormal result is flushed to positive zero
151 %result = fsub float 0x3800000000000000, 0x3810000000000000
155 define float @test_float_fsub_psign_out() #2 {
156 ; CHECK-LABEL: @test_float_fsub_psign_out(
157 ; CHECK-NEXT: ret float -0.000000e+00
159 ; denormal result is flushed to sign preserved zero
160 %result = fsub float 0x3800000000000000, 0x3810000000000000
164 define float @test_float_fsub_pzero_in() #3 {
165 ; CHECK-LABEL: @test_float_fsub_pzero_in(
166 ; CHECK-NEXT: ret float 0xB810000000000000
168 ; denormal operand is treated as zero
169 ; normal operand subtracted from zero produces the same operand, negated
170 %result = fsub float 0x3800000000000000, 0x3810000000000000
174 define float @test_float_fsub_psign_in() #4 {
175 ; CHECK-LABEL: @test_float_fsub_psign_in(
176 ; CHECK-NEXT: ret float 0xB810000000000000
178 ; denormal operand is treated as zero
179 ; normal operand subtracted from zero produces the same operand, negated
180 %result = fsub float 0x3800000000000000, 0x3810000000000000
184 define float @test_float_fsub_pzero_f32_out() #5 {
185 ; CHECK-LABEL: @test_float_fsub_pzero_f32_out(
186 ; CHECK-NEXT: ret float 0.000000e+00
188 ; f32 only attribute should flush float output
189 ; same as pzero_out above
190 %result = fsub float 0x3800000000000000, 0x3810000000000000
194 define double @test_double_fsub_ieee() #0 {
195 ; CHECK-LABEL: @test_double_fsub_ieee(
196 ; CHECK-NEXT: ret double 0x8008000000000000
198 ; default ieee mode leaves result as a denormal
199 %result = fsub double 0x0008000000000000, 0x0010000000000000
203 define double @test_double_fsub_pzero_out() #1 {
204 ; CHECK-LABEL: @test_double_fsub_pzero_out(
205 ; CHECK-NEXT: ret double 0.000000e+00
207 ; denormal result is flushed to positive zero
208 %result = fsub double 0x0008000000000000, 0x0010000000000000
212 define double @test_double_fsub_psign_out() #2 {
213 ; CHECK-LABEL: @test_double_fsub_psign_out(
214 ; CHECK-NEXT: ret double -0.000000e+00
216 ; denormal result is flushed to sign preserved zero
217 %result = fsub double 0x0008000000000000, 0x0010000000000000
221 define double @test_double_fsub_pzero_in() #3 {
222 ; CHECK-LABEL: @test_double_fsub_pzero_in(
223 ; CHECK-NEXT: ret double 0x8010000000000000
225 ; denormal operand is treated as zero
226 ; normal operand subtracted from zero produces the same operand, negated
227 %result = fsub double 0x0008000000000000, 0x0010000000000000
231 define double @test_double_fsub_psign_in() #4 {
232 ; CHECK-LABEL: @test_double_fsub_psign_in(
233 ; CHECK-NEXT: ret double 0x8010000000000000
235 ; denormal operand is treated as zero
236 ; normal operand subtracted from zero produces the same operand, negated
237 %result = fsub double 0x0008000000000000, 0x0010000000000000
241 define double @test_double_fsub_f32_ieee() #5 {
242 ; CHECK-LABEL: @test_double_fsub_f32_ieee(
243 ; CHECK-NEXT: ret double 0x8008000000000000
245 ; f32 only attribute should not flush doubles
246 ; default ieee mode leaves result as a denormal
247 %result = fsub double 0x0008000000000000, 0x0010000000000000
251 ; ============================================================================ ;
253 ; Output modes are tested by multiplying the smallest normal number by 0.5,
254 ; producing a denormal result. If denormal outputs should be flushed to zero,
255 ; the result should be zero.
256 ; Input modes are tested by the reverse operation: taking the denormal and
257 ; multiplying by 2 to produce a normal number. If denormal inputs should be
258 ; treated as zero, the result should also be zero.
259 ; ============================================================================ ;
261 define float @test_float_fmul_ieee() #0 {
262 ; CHECK-LABEL: @test_float_fmul_ieee(
263 ; CHECK-NEXT: ret float 0xB800000000000000
265 ; default ieee mode leaves result as a denormal
266 %result = fmul float 0x3810000000000000, -5.000000e-01
270 define float @test_float_fmul_pzero_out() #1 {
271 ; CHECK-LABEL: @test_float_fmul_pzero_out(
272 ; CHECK-NEXT: ret float 0.000000e+00
274 ; denormal result is flushed to positive zero
275 %result = fmul float 0x3810000000000000, -5.000000e-01
279 define float @test_float_fmul_psign_out() #2 {
280 ; CHECK-LABEL: @test_float_fmul_psign_out(
281 ; CHECK-NEXT: ret float -0.000000e+00
283 ; denormal result is flushed to sign preserved zero
284 %result = fmul float 0x3810000000000000, -5.000000e-01
288 define float @test_float_fmul_pzero_in() #3 {
289 ; CHECK-LABEL: @test_float_fmul_pzero_in(
290 ; CHECK-NEXT: ret float 0.000000e+00
292 ; denormal operand is treated as positive zero
293 ; anything multiplied by zero gives a zero result
294 %result = fmul float 0xB800000000000000, 2.000000e-00
298 define float @test_float_fmul_psign_in() #4 {
299 ; CHECK-LABEL: @test_float_fmul_psign_in(
300 ; CHECK-NEXT: ret float -0.000000e+00
302 ; denormal operand is treated as signed zero
303 ; anything multiplied by zero gives a zero result
304 %result = fmul float 0xB800000000000000, 2.000000e-00
308 define float @test_float_fmul_pzero_f32_out() #1 {
309 ; CHECK-LABEL: @test_float_fmul_pzero_f32_out(
310 ; CHECK-NEXT: ret float 0.000000e+00
312 ; f32 only attribute should flush float output
313 ; same as pzero_out above
314 %result = fmul float 0x3810000000000000, -5.000000e-01
318 define double @test_double_fmul_ieee() #0 {
319 ; CHECK-LABEL: @test_double_fmul_ieee(
320 ; CHECK-NEXT: ret double 0x8008000000000000
322 ; default ieee mode leaves result as a denormal
323 %result = fmul double 0x00010000000000000, -5.000000e-01
327 define double @test_double_fmul_pzero_out() #1 {
328 ; CHECK-LABEL: @test_double_fmul_pzero_out(
329 ; CHECK-NEXT: ret double 0.000000e+00
331 ; denormal result is flushed to positive zero
332 %result = fmul double 0x00010000000000000, -5.000000e-01
336 define double @test_double_fmul_psign_out() #2 {
337 ; CHECK-LABEL: @test_double_fmul_psign_out(
338 ; CHECK-NEXT: ret double -0.000000e+00
340 ; denormal result is flushed to sign preserved zero
341 %result = fmul double 0x0010000000000000, -5.000000e-01
345 define double @test_double_fmul_pzero_in() #3 {
346 ; CHECK-LABEL: @test_double_fmul_pzero_in(
347 ; CHECK-NEXT: ret double 0.000000e+00
349 ; denormal operand is treated as positive zero
350 ; anything multiplied by zero gives a zero result
351 %result = fmul double 0x8008000000000000, 2.000000e-00
355 define double @test_double_fmul_psign_in() #4 {
356 ; CHECK-LABEL: @test_double_fmul_psign_in(
357 ; CHECK-NEXT: ret double -0.000000e+00
359 ; denormal operand is treated as signed zero
360 ; anything multiplied by zero gives a zero result
361 %result = fmul double 0x8008000000000000, 2.000000e-00
365 define double @test_double_fmul_f32_ieee() #5 {
366 ; CHECK-LABEL: @test_double_fmul_f32_ieee(
367 ; CHECK-NEXT: ret double 0x8008000000000000
369 ; f32 only attribute should not flush doubles
370 ; default ieee mode leaves result as a denormal
371 %result = fmul double 0x0010000000000000, -5.000000e-01
375 ; ============================================================================ ;
377 ; Output modes are tested by dividing the smallest normal number by 2,
378 ; producing a denormal result. If denormal outputs should be flushed to zero,
379 ; the result should be zero.
380 ; Input modes are tested by the reverse operation: taking the denormal and
381 ; dividing by 0.5 to produce a normal number. If denormal inputs should be
382 ; treated as zero, the result should also be zero.
383 ; ============================================================================ ;
385 define float @test_float_fdiv_ieee() #0 {
386 ; CHECK-LABEL: @test_float_fdiv_ieee(
387 ; CHECK-NEXT: ret float 0xB800000000000000
389 ; default ieee mode leaves result as a denormal
390 %result = fdiv float 0x3810000000000000, -2.000000e-00
394 define float @test_float_fdiv_pzero_out() #1 {
395 ; CHECK-LABEL: @test_float_fdiv_pzero_out(
396 ; CHECK-NEXT: ret float 0.000000e+00
398 ; denormal result is flushed to positive zero
399 %result = fdiv float 0x3810000000000000, -2.000000e-00
403 define float @test_float_fdiv_psign_out() #2 {
404 ; CHECK-LABEL: @test_float_fdiv_psign_out(
405 ; CHECK-NEXT: ret float -0.000000e+00
407 ; denormal result is flushed to sign preserved zero
408 %result = fdiv float 0x3810000000000000, -2.000000e-00
412 define float @test_float_fdiv_pzero_in() #3 {
413 ; CHECK-LABEL: @test_float_fdiv_pzero_in(
414 ; CHECK-NEXT: ret float 0.000000e+00
416 ; denormal operand is treated as zero
417 ; zero divided by anything gives a zero result
418 %result = fdiv float 0xB800000000000000, 5.000000e-01
422 define float @test_float_fdiv_psign_in() #4 {
423 ; CHECK-LABEL: @test_float_fdiv_psign_in(
424 ; CHECK-NEXT: ret float -0.000000e+00
426 ; denormal operand is treated as zero
427 ; zero divided by anything gives a zero result
428 %result = fmul float 0xB800000000000000, 5.000000e-01
432 define float @test_float_fdiv_pzero_f32_out() #1 {
433 ; CHECK-LABEL: @test_float_fdiv_pzero_f32_out(
434 ; CHECK-NEXT: ret float 0.000000e+00
436 ; f32 only attribute should flush float output
437 ; same as pzero_out above
438 %result = fdiv float 0x3810000000000000, -2.000000e-00
442 define double @test_double_fdiv_ieee() #0 {
443 ; CHECK-LABEL: @test_double_fdiv_ieee(
444 ; CHECK-NEXT: ret double 0x8008000000000000
446 ; default ieee mode leaves result as a denormal
447 %result = fdiv double 0x0010000000000000, -2.000000e-00
451 define double @test_double_fdiv_pzero_out() #1 {
452 ; CHECK-LABEL: @test_double_fdiv_pzero_out(
453 ; CHECK-NEXT: ret double 0.000000e+00
455 ; denormal result is flushed to positive zero
456 %result = fdiv double 0x0010000000000000, -2.000000e-00
460 define double @test_double_fdiv_psign_out() #2 {
461 ; CHECK-LABEL: @test_double_fdiv_psign_out(
462 ; CHECK-NEXT: ret double -0.000000e+00
464 ; denormal result is flushed to sign preserved zero
465 %result = fdiv double 0x0010000000000000, -2.000000e-00
469 define double @test_double_fdiv_pzero_in() #3 {
470 ; CHECK-LABEL: @test_double_fdiv_pzero_in(
471 ; CHECK-NEXT: ret double 0.000000e+00
473 ; denormal operand is treated as zero
474 ; zero divided by anything gives a zero result
475 %result = fdiv double 0x8008000000000000, 5.000000e-01
479 define double @test_double_fdiv_psign_in() #4 {
480 ; CHECK-LABEL: @test_double_fdiv_psign_in(
481 ; CHECK-NEXT: ret double -0.000000e+00
483 ; denormal operand is treated as zero
484 ; zero divided by anything gives a zero result
485 %result = fdiv double 0x8008000000000000, 5.000000e-01
489 define double @test_double_fdiv_f32_ieee() #5 {
490 ; CHECK-LABEL: @test_double_fdiv_f32_ieee(
491 ; CHECK-NEXT: ret double 0x8008000000000000
493 ; f32 only attribute should not flush doubles
494 ; default ieee mode leaves result as a denormal
495 %result = fdiv double 0x0010000000000000, -2.000000e-00
499 ; ============================================================================ ;
501 ; Output modes are tested by using two small normal numbers to produce a
502 ; denormal result. If denormal outputs should be flushed to zero, the result
504 ; Input modes are tested by calculating the remainder of a denormal number
505 ; and a larger normal number. If denormal inputs should be treated as zero
506 ; the result also becomes zero.
507 ; ============================================================================ ;
509 define float @test_float_frem_ieee_out() #0 {
510 ; CHECK-LABEL: @test_float_frem_ieee_out(
511 ; CHECK-NEXT: ret float 0xB800000000000000
513 ; default ieee mode leaves result as a denormal
514 %result = frem float 0xB818000000000000, 0x3810000000000000
518 define float @test_float_frem_pzero_out() #1 {
519 ; CHECK-LABEL: @test_float_frem_pzero_out(
520 ; CHECK-NEXT: ret float 0.000000e+00
522 ; denormal result is flushed to positive zero
523 %result = frem float 0xB818000000000000, 0x3810000000000000
527 define float @test_float_frem_psign_out() #2 {
528 ; CHECK-LABEL: @test_float_frem_psign_out(
529 ; CHECK-NEXT: ret float -0.000000e+00
531 ; denormal result is flushed to sign preserved zero
532 %result = frem float 0xB818000000000000, 0x3810000000000000
536 define float @test_float_frem_ieee_in() #0 {
537 ; CHECK-LABEL: @test_float_frem_ieee_in(
538 ; CHECK-NEXT: ret float 0x3800000000000000
540 ; default ieee mode leaves result same as input
541 %result = frem float 0x3800000000000000, 2.000000e+00
545 define float @test_float_frem_pzero_in() #3 {
546 ; CHECK-LABEL: @test_float_frem_pzero_in(
547 ; CHECK-NEXT: ret float 0.000000e+00
549 ; denormal operand is treated as zero
550 ; remainder is now zero
551 %result = frem float 0x3800000000000000, 2.000000e+00
555 define float @test_float_frem_psign_in() #4 {
556 ; CHECK-LABEL: @test_float_frem_psign_in(
557 ; CHECK-NEXT: ret float 0.000000e+00
559 ; denormal operand is treated as zero
560 ; remainder is now zero
561 %result = frem float 0x3800000000000000, 2.000000e+00
565 define float @test_float_frem_pzero_f32_out() #1 {
566 ; CHECK-LABEL: @test_float_frem_pzero_f32_out(
567 ; CHECK-NEXT: ret float 0.000000e+00
569 ; f32 only attribute should flush float output
570 ; same as pzero_out above
571 %result = frem float 0xB818000000000000, 0x3810000000000000
575 define double @test_double_frem_ieee_out() #0 {
576 ; CHECK-LABEL: @test_double_frem_ieee_out(
577 ; CHECK-NEXT: ret double 0x8008000000000000
579 ; default ieee mode leaves result as a denormal
580 %result = frem double 0x8018000000000000, 0x0010000000000000
584 define double @test_double_frem_pzero_out() #1 {
585 ; CHECK-LABEL: @test_double_frem_pzero_out(
586 ; CHECK-NEXT: ret double 0.000000e+00
588 ; denormal result is flushed to positive zero
589 %result = frem double 0x8018000000000000, 0x0010000000000000
593 define double @test_double_frem_psign_out() #2 {
594 ; CHECK-LABEL: @test_double_frem_psign_out(
595 ; CHECK-NEXT: ret double -0.000000e+00
597 ; denormal result is flushed to sign preserved zero
598 %result = frem double 0x8018000000000000, 0x0010000000000000
602 define double @test_double_frem_ieee_in() #0 {
603 ; CHECK-LABEL: @test_double_frem_ieee_in(
604 ; CHECK-NEXT: ret double 0x8000000000000
606 ; default ieee mode leaves result same as input
607 %result = frem double 0x0008000000000000, 2.000000e+00
611 define double @test_double_frem_pzero_in() #3 {
612 ; CHECK-LABEL: @test_double_frem_pzero_in(
613 ; CHECK-NEXT: ret double 0.000000e+00
615 ; denormal operand is treated as zero
616 ; remainder is now zero
617 %result = frem double 0x0008000000000000, 2.000000e+00
621 define double @test_double_frem_psign_in() #4 {
622 ; CHECK-LABEL: @test_double_frem_psign_in(
623 ; CHECK-NEXT: ret double 0.000000e+00
625 ; denormal operand is treated as zero
626 ; remainder is now zero
627 %result = frem double 0x0008000000000000, 2.000000e+00
631 define double @test_double_frem_f32_ieee() #5 {
632 ; CHECK-LABEL: @test_double_frem_f32_ieee(
633 ; CHECK-NEXT: ret double 0x8008000000000000
635 ; f32 only attribute should not flush doubles
636 ; default ieee mode leaves result as a denormal
637 %result = frem double 0x8018000000000000, 0x0010000000000000
641 ; ============================================================================ ;
643 ; fneg should NOT be affected by denormal handling mode
644 ; these tests confirm fneg results are unchanged
645 ; ============================================================================ ;
647 define float @test_float_fneg_ieee() #0 {
648 ; CHECK-LABEL: @test_float_fneg_ieee(
649 ; CHECK-NEXT: ret float 0xB800000000000000
651 %result = fneg float 0x3800000000000000
655 define float @test_float_fneg_pzero_out() #0 {
656 ; CHECK-LABEL: @test_float_fneg_pzero_out(
657 ; CHECK-NEXT: ret float 0xB800000000000000
659 %result = fneg float 0x3800000000000000
663 define float @test_float_fneg_psign_out() #0 {
664 ; CHECK-LABEL: @test_float_fneg_psign_out(
665 ; CHECK-NEXT: ret float 0xB800000000000000
667 %result = fneg float 0x3800000000000000
671 define float @test_float_fneg_pzero_in() #0 {
672 ; CHECK-LABEL: @test_float_fneg_pzero_in(
673 ; CHECK-NEXT: ret float 0xB800000000000000
675 %result = fneg float 0x3800000000000000
679 define float @test_float_fneg_psign_in() #0 {
680 ; CHECK-LABEL: @test_float_fneg_psign_in(
681 ; CHECK-NEXT: ret float 0xB800000000000000
683 %result = fneg float 0x3800000000000000
687 define float @test_float_fneg_pzero_f32_out() #5 {
688 ; CHECK-LABEL: @test_float_fneg_pzero_f32_out(
689 ; CHECK-NEXT: ret float 0xB800000000000000
691 %result = fneg float 0x3800000000000000
695 define double @test_double_fneg_ieee() #0 {
696 ; CHECK-LABEL: @test_double_fneg_ieee(
697 ; CHECK-NEXT: ret double 0x8008000000000000
699 %result = fneg double 0x0008000000000000
703 define double @test_double_fneg_pzero_out() #1 {
704 ; CHECK-LABEL: @test_double_fneg_pzero_out(
705 ; CHECK-NEXT: ret double 0x8008000000000000
707 %result = fneg double 0x0008000000000000
711 define double @test_double_fneg_psign_out() #2 {
712 ; CHECK-LABEL: @test_double_fneg_psign_out(
713 ; CHECK-NEXT: ret double 0x8008000000000000
715 %result = fneg double 0x0008000000000000
719 define double @test_double_fneg_pzero_in() #3 {
720 ; CHECK-LABEL: @test_double_fneg_pzero_in(
721 ; CHECK-NEXT: ret double 0x8008000000000000
723 %result = fneg double 0x0008000000000000
727 define double @test_double_fneg_psign_in() #4 {
728 ; CHECK-LABEL: @test_double_fneg_psign_in(
729 ; CHECK-NEXT: ret double 0x8008000000000000
731 %result = fneg double 0x0008000000000000
735 define double @test_double_fneg_f32_ieee() #5 {
736 ; CHECK-LABEL: @test_double_fneg_f32_ieee(
737 ; CHECK-NEXT: ret double 0x8008000000000000
739 %result = fneg double 0x0008000000000000
743 define i1 @fcmp_double_ieee_in_ieee_out() #0 {
744 ; CHECK-LABEL: @fcmp_double_ieee_in_ieee_out(
746 ; CHECK-NEXT: ret i1 true
749 %cmp = fcmp une double 0x0008000000000000, 0x0
753 define i1 @fcmp_float_ieee_in_ieee_out() #0 {
754 ; CHECK-LABEL: @fcmp_float_ieee_in_ieee_out(
756 ; CHECK-NEXT: ret i1 true
759 %cmp = fcmp une float 0x3800000000000000, 0x0
763 define i1 @fcmp_double_pz_in_pz_out() #6 {
764 ; CHECK-LABEL: @fcmp_double_pz_in_pz_out(
766 ; CHECK-NEXT: ret i1 false
769 %cmp = fcmp une double 0x0008000000000000, 0x0
773 define i1 @fcmp_float_pz_in_pz_out() #6 {
774 ; CHECK-LABEL: @fcmp_float_pz_in_pz_out(
776 ; CHECK-NEXT: ret i1 false
779 %cmp = fcmp une float 0x3800000000000000, 0x0
783 define i1 @fcmp_double_ps_in_ps_out() #7 {
784 ; CHECK-LABEL: @fcmp_double_ps_in_ps_out(
786 ; CHECK-NEXT: ret i1 false
789 %cmp = fcmp une double 0x0008000000000000, 0x0
793 define i1 @fcmp_float_ps_in_ps_out() #7 {
794 ; CHECK-LABEL: @fcmp_float_ps_in_ps_out(
796 ; CHECK-NEXT: ret i1 false
799 %cmp = fcmp une float 0x3800000000000000, 0x0
803 define i1 @fcmp_double_pz_out_ieee_in() #1 {
804 ; CHECK-LABEL: @fcmp_double_pz_out_ieee_in(
806 ; CHECK-NEXT: ret i1 true
809 %cmp = fcmp une double 0x0008000000000000, 0x0
813 define i1 @fcmp_double_ps_out_ieee_in() #2 {
814 ; CHECK-LABEL: @fcmp_double_ps_out_ieee_in(
816 ; CHECK-NEXT: ret i1 true
819 %cmp = fcmp une double 0x0008000000000000, 0x0
823 define i1 @fcmp_double_ieee_out_pz_in() #3 {
824 ; CHECK-LABEL: @fcmp_double_ieee_out_pz_in(
826 ; CHECK-NEXT: ret i1 false
829 %cmp = fcmp une double 0x0008000000000000, 0x0
833 define i1 @fcmp_double_ieee_out_ps_in() #4 {
834 ; CHECK-LABEL: @fcmp_double_ieee_out_ps_in(
836 ; CHECK-NEXT: ret i1 false
839 %cmp = fcmp une double 0x0008000000000000, 0x0
843 define i1 @fcmp_double_f32_pz_in() #8 {
844 ; CHECK-LABEL: @fcmp_double_f32_pz_in(
846 ; CHECK-NEXT: ret i1 true
849 %cmp = fcmp une double 0x0008000000000000, 0x0
853 define i1 @fcmp_double_two_denormal_ins() #6 {
854 ; CHECK-LABEL: @fcmp_double_two_denormal_ins(
856 ; CHECK-NEXT: ret i1 false
859 %cmp = fcmp une double 0x0008100000000000, 0x0008000000000000
863 define i1 @fcmp_double_ps_in_ps_out_false() #6 {
864 ; CHECK-LABEL: @fcmp_double_ps_in_ps_out_false(
866 ; CHECK-NEXT: ret i1 false
869 %cmp = fcmp false double 0x0008100000000000, 0x0008000000000000
873 define i1 @fcmp_double_ieee_in_ieee_out_false() #0 {
874 ; CHECK-LABEL: @fcmp_double_ieee_in_ieee_out_false(
876 ; CHECK-NEXT: ret i1 false
879 %cmp = fcmp false double 0x0008100000000000, 0x0008000000000000
883 define i1 @fcmp_double_ps_in_ps_out_true() #6 {
884 ; CHECK-LABEL: @fcmp_double_ps_in_ps_out_true(
886 ; CHECK-NEXT: ret i1 true
889 %cmp = fcmp true double 0x0008100000000000, 0x0008000000000000
893 define i1 @fcmp_double_ieee_in_ieee_out_true() #0 {
894 ; CHECK-LABEL: @fcmp_double_ieee_in_ieee_out_true(
896 ; CHECK-NEXT: ret i1 true
899 %cmp = fcmp true double 0x0008100000000000, 0x0008000000000000
903 define i1 @fcmp_double_ps_in_ps_out_oeq() #6 {
904 ; CHECK-LABEL: @fcmp_double_ps_in_ps_out_oeq(
906 ; CHECK-NEXT: ret i1 true
909 %cmp = fcmp oeq double 0x0008100000000000, 0x0008000000000000
913 define i1 @fcmp_double_ieee_in_ieee_out_oeq() #0 {
914 ; CHECK-LABEL: @fcmp_double_ieee_in_ieee_out_oeq(
916 ; CHECK-NEXT: ret i1 false
919 %cmp = fcmp oeq double 0x0008100000000000, 0x0008000000000000
923 define i1 @fcmp_double_ps_in_ps_out_one() #6 {
924 ; CHECK-LABEL: @fcmp_double_ps_in_ps_out_one(
926 ; CHECK-NEXT: ret i1 false
929 %cmp = fcmp one double 0x0008100000000000, 0x0008000000000000
933 define i1 @fcmp_double_ieee_in_ieee_out_one() #0 {
934 ; CHECK-LABEL: @fcmp_double_ieee_in_ieee_out_one(
936 ; CHECK-NEXT: ret i1 true
939 %cmp = fcmp one double 0x0008100000000000, 0x0008000000000000
943 define i1 @fcmp_double_ps_in_ps_out_ord1() #6 {
944 ; CHECK-LABEL: @fcmp_double_ps_in_ps_out_ord1(
946 ; CHECK-NEXT: ret i1 false
949 %cmp = fcmp ord double 0x0008000000000000, 0x7ff1000000000000
953 define i1 @fcmp_double_ieee_in_ieee_out_ord1() #0 {
954 ; CHECK-LABEL: @fcmp_double_ieee_in_ieee_out_ord1(
956 ; CHECK-NEXT: ret i1 false
959 %cmp = fcmp ord double 0x0008000000000000, 0x7ff1000000000000
963 define i1 @fcmp_double_ps_in_ps_out_ord2() #6 {
964 ; CHECK-LABEL: @fcmp_double_ps_in_ps_out_ord2(
966 ; CHECK-NEXT: ret i1 true
969 %cmp = fcmp ord double 0x0008000000000000, 0x1ff1000000000000
973 define i1 @fcmp_double_ieee_in_ieee_out_ord2() #0 {
974 ; CHECK-LABEL: @fcmp_double_ieee_in_ieee_out_ord2(
976 ; CHECK-NEXT: ret i1 true
979 %cmp = fcmp ord double 0x0008000000000000, 0x1ff1000000000000
983 define i1 @fcmp_double_pz_in_pz_out_ugt() #7 {
984 ; CHECK-LABEL: @fcmp_double_pz_in_pz_out_ugt(
986 ; CHECK-NEXT: ret i1 false
989 %cmp = fcmp ugt double 0x0008000000000000, 0x0
993 define i1 @fcmp_double_ieee_in_ieee_out_ugt() #0 {
994 ; CHECK-LABEL: @fcmp_double_ieee_in_ieee_out_ugt(
996 ; CHECK-NEXT: ret i1 true
999 %cmp = fcmp ugt double 0x0008000000000000, 0x0
1003 define i1 @fcmp_double_pz_in_pz_out_ult() #7 {
1004 ; CHECK-LABEL: @fcmp_double_pz_in_pz_out_ult(
1005 ; CHECK-NEXT: entry:
1006 ; CHECK-NEXT: ret i1 false
1009 %cmp = fcmp ult double 0x0008000000000000, 0x0
1013 define i1 @fcmp_double_ieee_in_ieee_out_ult() #0 {
1014 ; CHECK-LABEL: @fcmp_double_ieee_in_ieee_out_ult(
1015 ; CHECK-NEXT: entry:
1016 ; CHECK-NEXT: ret i1 false
1019 %cmp = fcmp ult double 0x0008000000000000, 0x0
1023 define i1 @fcmp_double_pz_in_pz_out_uge() #7 {
1024 ; CHECK-LABEL: @fcmp_double_pz_in_pz_out_uge(
1025 ; CHECK-NEXT: entry:
1026 ; CHECK-NEXT: ret i1 true
1029 %cmp = fcmp uge double 0x0008000000000000, 0x0
1033 define i1 @fcmp_double_ieee_in_ieee_out_uge() #0 {
1034 ; CHECK-LABEL: @fcmp_double_ieee_in_ieee_out_uge(
1035 ; CHECK-NEXT: entry:
1036 ; CHECK-NEXT: ret i1 true
1039 %cmp = fcmp uge double 0x0008000000000000, 0x0
1043 define i1 @fcmp_double_pz_in_pz_out_ule() #7 {
1044 ; CHECK-LABEL: @fcmp_double_pz_in_pz_out_ule(
1045 ; CHECK-NEXT: entry:
1046 ; CHECK-NEXT: ret i1 true
1049 %cmp = fcmp ule double 0x0008000000000000, 0x0
1053 define i1 @fcmp_double_ieee_in_ieee_out_ule() #0 {
1054 ; CHECK-LABEL: @fcmp_double_ieee_in_ieee_out_ule(
1055 ; CHECK-NEXT: entry:
1056 ; CHECK-NEXT: ret i1 false
1059 %cmp = fcmp ule double 0x0008000000000000, 0x0
1063 define i1 @fcmp_double_pz_in_pz_out_uno() #7 {
1064 ; CHECK-LABEL: @fcmp_double_pz_in_pz_out_uno(
1065 ; CHECK-NEXT: entry:
1066 ; CHECK-NEXT: ret i1 true
1069 %cmp = fcmp uno double 0x0008000000000000, 0x7ff1000000000000
1073 define i1 @fcmp_double_ieee_in_ieee_out_uno() #0 {
1074 ; CHECK-LABEL: @fcmp_double_ieee_in_ieee_out_uno(
1075 ; CHECK-NEXT: entry:
1076 ; CHECK-NEXT: ret i1 true
1079 %cmp = fcmp uno double 0x0008000000000000, 0x7ff1000000000000
1083 define i1 @fcmp_double_pz_in_pz_out_uno2() #7 {
1084 ; CHECK-LABEL: @fcmp_double_pz_in_pz_out_uno2(
1085 ; CHECK-NEXT: entry:
1086 ; CHECK-NEXT: ret i1 false
1089 %cmp = fcmp uno double 0x0008000000000000, 0x1ff1000000000000
1093 define i1 @fcmp_double_ieee_in_ieee_out_uno2() #0 {
1094 ; CHECK-LABEL: @fcmp_double_ieee_in_ieee_out_uno2(
1095 ; CHECK-NEXT: entry:
1096 ; CHECK-NEXT: ret i1 false
1099 %cmp = fcmp uno double 0x0008000000000000, 0x1ff1000000000000
1103 ; ============================================================================ ;
1104 ; dynamic mode tests
1105 ; ============================================================================ ;
1107 define float @test_float_fadd_dynamic_ieee() #9 {
1108 ; CHECK-LABEL: @test_float_fadd_dynamic_ieee(
1109 ; CHECK-NEXT: [[RESULT:%.*]] = fadd float 0xB810000000000000, 0x3800000000000000
1110 ; CHECK-NEXT: ret float [[RESULT]]
1112 %result = fadd float 0xB810000000000000, 0x3800000000000000
1116 define float @test_float_fadd_ieee_dynamic() #10 {
1117 ; CHECK-LABEL: @test_float_fadd_ieee_dynamic(
1118 ; CHECK-NEXT: [[RESULT:%.*]] = fadd float 0xB810000000000000, 0x3800000000000000
1119 ; CHECK-NEXT: ret float [[RESULT]]
1121 %result = fadd float 0xB810000000000000, 0x3800000000000000
1125 define float @test_float_fadd_dynamic_dynamic() #11 {
1126 ; CHECK-LABEL: @test_float_fadd_dynamic_dynamic(
1127 ; CHECK-NEXT: [[RESULT:%.*]] = fadd float 0xB810000000000000, 0x3800000000000000
1128 ; CHECK-NEXT: ret float [[RESULT]]
1130 %result = fadd float 0xB810000000000000, 0x3800000000000000
1134 ; Check for failed to fold on each operand
1135 define float @test_float_fadd_dynamic_dynamic_commute() #11 {
1136 ; CHECK-LABEL: @test_float_fadd_dynamic_dynamic_commute(
1137 ; CHECK-NEXT: [[RESULT:%.*]] = fadd float 0x3800000000000000, 0xB810000000000000
1138 ; CHECK-NEXT: ret float [[RESULT]]
1140 %result = fadd float 0x3800000000000000, 0xB810000000000000
1144 define i1 @fcmp_double_dynamic_ieee() #9 {
1145 ; CHECK-LABEL: @fcmp_double_dynamic_ieee(
1146 ; CHECK-NEXT: ret i1 true
1148 %cmp = fcmp une double 0x0008000000000000, 0x0
1152 define i1 @fcmp_double_ieee_dynamic() #10 {
1153 ; CHECK-LABEL: @fcmp_double_ieee_dynamic(
1154 ; CHECK-NEXT: [[CMP:%.*]] = fcmp une double 0x8000000000000, 0.000000e+00
1155 ; CHECK-NEXT: ret i1 [[CMP]]
1157 %cmp = fcmp une double 0x0008000000000000, 0x0
1161 define i1 @fcmp_double_dynamic_dynamic() #11 {
1162 ; CHECK-LABEL: @fcmp_double_dynamic_dynamic(
1163 ; CHECK-NEXT: [[CMP:%.*]] = fcmp une double 0x8000000000000, 0.000000e+00
1164 ; CHECK-NEXT: ret i1 [[CMP]]
1166 %cmp = fcmp une double 0x0008000000000000, 0x0
1170 define i1 @fcmp_double_dynamic_dynamic_commute() #11 {
1171 ; CHECK-LABEL: @fcmp_double_dynamic_dynamic_commute(
1172 ; CHECK-NEXT: [[CMP:%.*]] = fcmp une double 0.000000e+00, 0x8000000000000
1173 ; CHECK-NEXT: ret i1 [[CMP]]
1175 %cmp = fcmp une double 0x0, 0x0008000000000000
1179 ; Output doesn't matter.
1180 define i1 @fcmp_double_dynamic_psz() #12 {
1181 ; CHECK-LABEL: @fcmp_double_dynamic_psz(
1182 ; CHECK-NEXT: ret i1 false
1184 %cmp = fcmp une double 0x0008000000000000, 0x0
1188 ; Non-denormal values should fold
1189 define float @test_float_fadd_dynamic_dynamic_normals() #11 {
1190 ; CHECK-LABEL: @test_float_fadd_dynamic_dynamic_normals(
1191 ; CHECK-NEXT: ret float 3.000000e+00
1193 %result = fadd float 1.0, 2.0
1197 ; Non-denormal values should fold
1198 define i1 @fcmp_double_dynamic_dynamic_normals() #11 {
1199 ; CHECK-LABEL: @fcmp_double_dynamic_dynamic_normals(
1200 ; CHECK-NEXT: ret i1 true
1202 %cmp = fcmp une double 1.0, 2.0
1206 attributes #0 = { nounwind "denormal-fp-math"="ieee,ieee" }
1207 attributes #1 = { nounwind "denormal-fp-math"="positive-zero,ieee" }
1208 attributes #2 = { nounwind "denormal-fp-math"="preserve-sign,ieee" }
1209 attributes #3 = { nounwind "denormal-fp-math"="ieee,positive-zero" }
1210 attributes #4 = { nounwind "denormal-fp-math"="ieee,preserve-sign" }
1211 attributes #5 = { nounwind "denormal-fp-math"="ieee,ieee" "denormal-fp-math-f32"="positive-zero,ieee" }
1212 attributes #6 = { nounwind "denormal-fp-math"="positive-zero,positive-zero" }
1213 attributes #7 = { nounwind "denormal-fp-math"="preserve-sign,preserve-sign" }
1214 attributes #8 = { nounwind "denormal-fp-math"="ieee,ieee" "denormal-fp-math-f32"="positive-zero,positive-zero" }
1215 attributes #9 = { nounwind "denormal-fp-math"="dynamic,ieee" }
1216 attributes #10 = { nounwind "denormal-fp-math"="ieee,dynamic" }
1217 attributes #11 = { nounwind "denormal-fp-math"="dynamic,dynamic" }
1218 attributes #12 = { nounwind "denormal-fp-math"="dynamic,preserve-sign" }