1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefixes=ANY,STRICT
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -enable-unsafe-fp-math | FileCheck %s --check-prefixes=ANY,UNSAFE
5 ; This is duplicated from tests for InstSimplify. If you're
6 ; adding something here, you should probably add it there too.
8 define float @fadd_undef_op0(float %x) {
9 ; ANY-LABEL: fadd_undef_op0:
11 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
13 %r = fadd float undef, %x
17 define float @fadd_undef_op1(float %x) {
18 ; ANY-LABEL: fadd_undef_op1:
20 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
22 %r = fadd float %x, undef
26 define float @fsub_undef_op0(float %x) {
27 ; ANY-LABEL: fsub_undef_op0:
29 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
31 %r = fsub float undef, %x
35 define float @fsub_undef_op1(float %x) {
36 ; ANY-LABEL: fsub_undef_op1:
38 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
40 %r = fsub float %x, undef
44 define float @fmul_undef_op0(float %x) {
45 ; ANY-LABEL: fmul_undef_op0:
47 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
49 %r = fmul float undef, %x
53 define float @fmul_undef_op1(float %x) {
54 ; ANY-LABEL: fmul_undef_op1:
56 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
58 %r = fmul float %x, undef
62 define float @fdiv_undef_op0(float %x) {
63 ; ANY-LABEL: fdiv_undef_op0:
65 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
67 %r = fdiv float undef, %x
71 define float @fdiv_undef_op1(float %x) {
72 ; ANY-LABEL: fdiv_undef_op1:
74 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
76 %r = fdiv float %x, undef
80 define float @frem_undef_op0(float %x) {
81 ; ANY-LABEL: frem_undef_op0:
83 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
85 %r = frem float undef, %x
89 define float @frem_undef_op1(float %x) {
90 ; ANY-LABEL: frem_undef_op1:
92 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
94 %r = frem float %x, undef
98 ; Repeat all tests with fast-math-flags. Alternate 'nnan' and 'fast' for more coverage.
100 define float @fadd_undef_op0_nnan(float %x) {
101 ; ANY-LABEL: fadd_undef_op0_nnan:
103 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
105 %r = fadd nnan float undef, %x
109 define float @fadd_undef_op1_fast(float %x) {
110 ; ANY-LABEL: fadd_undef_op1_fast:
112 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
114 %r = fadd fast float %x, undef
118 define float @fsub_undef_op0_fast(float %x) {
119 ; ANY-LABEL: fsub_undef_op0_fast:
121 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
123 %r = fsub fast float undef, %x
127 define float @fsub_undef_op1_nnan(float %x) {
128 ; ANY-LABEL: fsub_undef_op1_nnan:
130 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
132 %r = fsub nnan float %x, undef
136 define float @fmul_undef_op0_nnan(float %x) {
137 ; ANY-LABEL: fmul_undef_op0_nnan:
139 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
141 %r = fmul nnan float undef, %x
145 define float @fmul_undef_op1_fast(float %x) {
146 ; ANY-LABEL: fmul_undef_op1_fast:
148 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
150 %r = fmul fast float %x, undef
154 define float @fdiv_undef_op0_fast(float %x) {
155 ; ANY-LABEL: fdiv_undef_op0_fast:
157 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
159 %r = fdiv fast float undef, %x
163 define float @fdiv_undef_op1_nnan(float %x) {
164 ; ANY-LABEL: fdiv_undef_op1_nnan:
166 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
168 %r = fdiv nnan float %x, undef
172 define float @frem_undef_op0_nnan(float %x) {
173 ; ANY-LABEL: frem_undef_op0_nnan:
175 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
177 %r = frem nnan float undef, %x
181 define float @frem_undef_op1_fast(float %x) {
182 ; ANY-LABEL: frem_undef_op1_fast:
184 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
186 %r = frem fast float %x, undef
190 ; Constant folding - undef undef.
192 define double @fadd_undef_undef(double %x) {
193 ; ANY-LABEL: fadd_undef_undef:
196 %r = fadd double undef, undef
200 define double @fsub_undef_undef(double %x) {
201 ; ANY-LABEL: fsub_undef_undef:
204 %r = fsub double undef, undef
208 define double @fmul_undef_undef(double %x) {
209 ; ANY-LABEL: fmul_undef_undef:
212 %r = fmul double undef, undef
216 define double @fdiv_undef_undef(double %x) {
217 ; ANY-LABEL: fdiv_undef_undef:
220 %r = fdiv double undef, undef
224 define double @frem_undef_undef(double %x) {
225 ; ANY-LABEL: frem_undef_undef:
228 %r = frem double undef, undef
234 define float @fadd_undef_op0_nnan_constant(float %x) {
235 ; ANY-LABEL: fadd_undef_op0_nnan_constant:
237 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
239 %r = fadd nnan float undef, 1.0
243 define float @fadd_undef_op1_constant(float %x) {
244 ; ANY-LABEL: fadd_undef_op1_constant:
246 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
248 %r = fadd float 2.0, undef
252 define float @fsub_undef_op0_fast_constant(float %x) {
253 ; ANY-LABEL: fsub_undef_op0_fast_constant:
255 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
257 %r = fsub fast float undef, 3.0
261 define float @fsub_undef_op1_constant(float %x) {
262 ; ANY-LABEL: fsub_undef_op1_constant:
264 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
266 %r = fsub float 4.0, undef
270 define float @fmul_undef_op0_nnan_constant(float %x) {
271 ; ANY-LABEL: fmul_undef_op0_nnan_constant:
273 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
275 %r = fmul nnan float undef, 5.0
279 define float @fmul_undef_op1_constant(float %x) {
280 ; ANY-LABEL: fmul_undef_op1_constant:
282 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
284 %r = fmul float 6.0, undef
288 define float @fdiv_undef_op0_fast_constant(float %x) {
289 ; ANY-LABEL: fdiv_undef_op0_fast_constant:
291 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
293 %r = fdiv fast float undef, 7.0
297 define float @fdiv_undef_op1_constant(float %x) {
298 ; ANY-LABEL: fdiv_undef_op1_constant:
300 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
302 %r = fdiv float 8.0, undef
306 define float @frem_undef_op0_nnan_constant(float %x) {
307 ; ANY-LABEL: frem_undef_op0_nnan_constant:
309 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
311 %r = frem nnan float undef, 9.0
315 define float @frem_undef_op1_constant(float %x) {
316 ; ANY-LABEL: frem_undef_op1_constant:
318 ; ANY-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
320 %r = frem float 10.0, undef
324 ; Constant folding - special constants: NaN.
326 define double @fadd_undef_op0_constant_nan(double %x) {
327 ; ANY-LABEL: fadd_undef_op0_constant_nan:
329 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
331 %r = fadd double undef, 0x7FF8000000000000
335 define double @fadd_undef_op1_fast_constant_nan(double %x) {
336 ; ANY-LABEL: fadd_undef_op1_fast_constant_nan:
338 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
340 %r = fadd fast double 0xFFF0000000000001, undef
344 define double @fsub_undef_op0_constant_nan(double %x) {
345 ; ANY-LABEL: fsub_undef_op0_constant_nan:
347 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
349 %r = fsub double undef, 0xFFF8000000000010
353 define double @fsub_undef_op1_nnan_constant_nan(double %x) {
354 ; ANY-LABEL: fsub_undef_op1_nnan_constant_nan:
356 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
358 %r = fsub nnan double 0x7FF0000000000011, undef
362 define double @fmul_undef_op0_constant_nan(double %x) {
363 ; ANY-LABEL: fmul_undef_op0_constant_nan:
365 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
367 %r = fmul double undef, 0x7FF8000000000100
371 define double @fmul_undef_op1_fast_constant_nan(double %x) {
372 ; ANY-LABEL: fmul_undef_op1_fast_constant_nan:
374 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
376 %r = fmul fast double 0xFFF0000000000101, undef
380 define double @fdiv_undef_op0_constant_nan(double %x) {
381 ; ANY-LABEL: fdiv_undef_op0_constant_nan:
383 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
385 %r = fdiv double undef, 0xFFF8000000000110
389 define double @fdiv_undef_op1_nnan_constant_nan(double %x) {
390 ; ANY-LABEL: fdiv_undef_op1_nnan_constant_nan:
392 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
394 %r = fdiv nnan double 0x7FF0000000000111, undef
398 define double @frem_undef_op0_constant_nan(double %x) {
399 ; ANY-LABEL: frem_undef_op0_constant_nan:
401 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
403 %r = frem double undef, 0x7FF8000000001000
407 define double @frem_undef_op1_fast_constant_nan(double %x) {
408 ; ANY-LABEL: frem_undef_op1_fast_constant_nan:
410 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
412 %r = frem fast double 0xFFF0000000001001, undef
416 ; Constant folding - special constants: Inf.
418 define double @fadd_undef_op0_constant_inf(double %x) {
419 ; ANY-LABEL: fadd_undef_op0_constant_inf:
421 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
423 %r = fadd double undef, 0x7FF0000000000000
427 define double @fadd_undef_op1_fast_constant_inf(double %x) {
428 ; ANY-LABEL: fadd_undef_op1_fast_constant_inf:
430 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
432 %r = fadd fast double 0xFFF0000000000000, undef
436 define double @fsub_undef_op0_constant_inf(double %x) {
437 ; ANY-LABEL: fsub_undef_op0_constant_inf:
439 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
441 %r = fsub double undef, 0xFFF0000000000000
445 define double @fsub_undef_op1_ninf_constant_inf(double %x) {
446 ; ANY-LABEL: fsub_undef_op1_ninf_constant_inf:
448 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
450 %r = fsub ninf double 0x7FF0000000000000, undef
454 define double @fmul_undef_op0_constant_inf(double %x) {
455 ; ANY-LABEL: fmul_undef_op0_constant_inf:
457 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
459 %r = fmul double undef, 0x7FF0000000000000
463 define double @fmul_undef_op1_fast_constant_inf(double %x) {
464 ; ANY-LABEL: fmul_undef_op1_fast_constant_inf:
466 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
468 %r = fmul fast double 0xFFF0000000000000, undef
472 define double @fdiv_undef_op0_constant_inf(double %x) {
473 ; ANY-LABEL: fdiv_undef_op0_constant_inf:
475 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
477 %r = fdiv double undef, 0xFFF0000000000000
481 define double @fdiv_undef_op1_ninf_constant_inf(double %x) {
482 ; ANY-LABEL: fdiv_undef_op1_ninf_constant_inf:
484 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
486 %r = fdiv ninf double 0x7FF0000000000000, undef
490 define double @frem_undef_op0_constant_inf(double %x) {
491 ; ANY-LABEL: frem_undef_op0_constant_inf:
493 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
495 %r = frem double undef, 0x7FF0000000000000
499 define double @frem_undef_op1_fast_constant_inf(double %x) {
500 ; ANY-LABEL: frem_undef_op1_fast_constant_inf:
502 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
504 %r = frem fast double 0xFFF0000000000000, undef
508 define <2 x double> @fadd_undef_op1_constant_vec(<2 x double> %x) {
509 ; ANY-LABEL: fadd_undef_op1_constant_vec:
511 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
513 %r = fadd <2 x double> <double 42.0, double undef>, undef
517 define <2 x double> @fadd_undef_op0_constant_vec(<2 x double> %x) {
518 ; ANY-LABEL: fadd_undef_op0_constant_vec:
520 ; ANY-NEXT: movaps {{.*#+}} xmm0 = <u,NaN>
522 %r = fadd <2 x double> undef, <double undef, double 42.0>
526 define <2 x double> @fsub_undef_op1_constant_vec(<2 x double> %x) {
527 ; ANY-LABEL: fsub_undef_op1_constant_vec:
529 ; ANY-NEXT: movaps {{.*#+}} xmm0 = <u,NaN>
531 %r = fsub <2 x double> <double undef, double 42.0>, undef
535 define <2 x double> @fsub_undef_op0_constant_vec(<2 x double> %x) {
536 ; ANY-LABEL: fsub_undef_op0_constant_vec:
538 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
540 %r = fsub <2 x double> undef, <double 42.0, double undef>
544 define <2 x double> @fmul_undef_op1_constant_vec(<2 x double> %x) {
545 ; ANY-LABEL: fmul_undef_op1_constant_vec:
547 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
549 %r = fmul <2 x double> <double 42.0, double undef>, undef
553 define <2 x double> @fmul_undef_op0_constant_vec(<2 x double> %x) {
554 ; ANY-LABEL: fmul_undef_op0_constant_vec:
556 ; ANY-NEXT: movaps {{.*#+}} xmm0 = <u,NaN>
558 %r = fmul <2 x double> undef, <double undef, double 42.0>
562 define <2 x double> @fdiv_undef_op1_constant_vec(<2 x double> %x) {
563 ; ANY-LABEL: fdiv_undef_op1_constant_vec:
565 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
567 %r = fdiv <2 x double> <double 42.0, double undef>, undef
571 define <2 x double> @fdiv_undef_op0_constant_vec(<2 x double> %x) {
572 ; ANY-LABEL: fdiv_undef_op0_constant_vec:
574 ; ANY-NEXT: movaps {{.*#+}} xmm0 = <u,NaN>
576 %r = fdiv <2 x double> undef, <double undef, double 42.0>
580 define <2 x double> @frem_undef_op1_constant_vec(<2 x double> %x) {
581 ; ANY-LABEL: frem_undef_op1_constant_vec:
583 ; ANY-NEXT: movaps {{.*#+}} xmm0 = <u,NaN>
585 %r = frem <2 x double> <double undef, double 42.0>, undef
589 define <2 x double> @frem_undef_op0_constant_vec(<2 x double> %x) {
590 ; ANY-LABEL: frem_undef_op0_constant_vec:
592 ; ANY-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
594 %r = frem <2 x double> undef, <double 42.0, double undef>