• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-prefix=ANY
3; RUN: llc < %s -mtriple=x86_64-unknown-unknown -enable-unsafe-fp-math | FileCheck %s --check-prefix=ANY
4
5; This is duplicated from tests for InstSimplify. If you're
6; adding something here, you should probably add it there too.
7
8define float @fadd_undef_op0(float %x) {
9; ANY-LABEL: fadd_undef_op0:
10; ANY:       # %bb.0:
11; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
12; ANY-NEXT:    retq
13  %r = fadd float undef, %x
14  ret float %r
15}
16
17define float @fadd_undef_op1(float %x) {
18; ANY-LABEL: fadd_undef_op1:
19; ANY:       # %bb.0:
20; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
21; ANY-NEXT:    retq
22  %r = fadd float %x, undef
23  ret float %r
24}
25
26define float @fsub_undef_op0(float %x) {
27; ANY-LABEL: fsub_undef_op0:
28; ANY:       # %bb.0:
29; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
30; ANY-NEXT:    retq
31  %r = fsub float undef, %x
32  ret float %r
33}
34
35define float @fsub_undef_op1(float %x) {
36; ANY-LABEL: fsub_undef_op1:
37; ANY:       # %bb.0:
38; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
39; ANY-NEXT:    retq
40  %r = fsub float %x, undef
41  ret float %r
42}
43
44define float @fmul_undef_op0(float %x) {
45; ANY-LABEL: fmul_undef_op0:
46; ANY:       # %bb.0:
47; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
48; ANY-NEXT:    retq
49  %r = fmul float undef, %x
50  ret float %r
51}
52
53define float @fmul_undef_op1(float %x) {
54; ANY-LABEL: fmul_undef_op1:
55; ANY:       # %bb.0:
56; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
57; ANY-NEXT:    retq
58  %r = fmul float %x, undef
59  ret float %r
60}
61
62define float @fdiv_undef_op0(float %x) {
63; ANY-LABEL: fdiv_undef_op0:
64; ANY:       # %bb.0:
65; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
66; ANY-NEXT:    retq
67  %r = fdiv float undef, %x
68  ret float %r
69}
70
71define float @fdiv_undef_op1(float %x) {
72; ANY-LABEL: fdiv_undef_op1:
73; ANY:       # %bb.0:
74; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
75; ANY-NEXT:    retq
76  %r = fdiv float %x, undef
77  ret float %r
78}
79
80define float @frem_undef_op0(float %x) {
81; ANY-LABEL: frem_undef_op0:
82; ANY:       # %bb.0:
83; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
84; ANY-NEXT:    retq
85  %r = frem float undef, %x
86  ret float %r
87}
88
89define float @frem_undef_op1(float %x) {
90; ANY-LABEL: frem_undef_op1:
91; ANY:       # %bb.0:
92; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
93; ANY-NEXT:    retq
94  %r = frem float %x, undef
95  ret float %r
96}
97
98; Repeat all tests with fast-math-flags. Alternate 'nnan' and 'fast' for more coverage.
99
100define float @fadd_undef_op0_nnan(float %x) {
101; ANY-LABEL: fadd_undef_op0_nnan:
102; ANY:       # %bb.0:
103; ANY-NEXT:    retq
104  %r = fadd nnan float undef, %x
105  ret float %r
106}
107
108define float @fadd_undef_op1_fast(float %x) {
109; ANY-LABEL: fadd_undef_op1_fast:
110; ANY:       # %bb.0:
111; ANY-NEXT:    retq
112  %r = fadd fast float %x, undef
113  ret float %r
114}
115
116define float @fsub_undef_op0_fast(float %x) {
117; ANY-LABEL: fsub_undef_op0_fast:
118; ANY:       # %bb.0:
119; ANY-NEXT:    retq
120  %r = fsub fast float undef, %x
121  ret float %r
122}
123
124define float @fsub_undef_op1_nnan(float %x) {
125; ANY-LABEL: fsub_undef_op1_nnan:
126; ANY:       # %bb.0:
127; ANY-NEXT:    retq
128  %r = fsub nnan float %x, undef
129  ret float %r
130}
131
132define float @fmul_undef_op0_nnan(float %x) {
133; ANY-LABEL: fmul_undef_op0_nnan:
134; ANY:       # %bb.0:
135; ANY-NEXT:    retq
136  %r = fmul nnan float undef, %x
137  ret float %r
138}
139
140define float @fmul_undef_op1_fast(float %x) {
141; ANY-LABEL: fmul_undef_op1_fast:
142; ANY:       # %bb.0:
143; ANY-NEXT:    retq
144  %r = fmul fast float %x, undef
145  ret float %r
146}
147
148define float @fdiv_undef_op0_fast(float %x) {
149; ANY-LABEL: fdiv_undef_op0_fast:
150; ANY:       # %bb.0:
151; ANY-NEXT:    retq
152  %r = fdiv fast float undef, %x
153  ret float %r
154}
155
156define float @fdiv_undef_op1_nnan(float %x) {
157; ANY-LABEL: fdiv_undef_op1_nnan:
158; ANY:       # %bb.0:
159; ANY-NEXT:    retq
160  %r = fdiv nnan float %x, undef
161  ret float %r
162}
163
164define float @frem_undef_op0_nnan(float %x) {
165; ANY-LABEL: frem_undef_op0_nnan:
166; ANY:       # %bb.0:
167; ANY-NEXT:    retq
168  %r = frem nnan float undef, %x
169  ret float %r
170}
171
172define float @frem_undef_op1_fast(float %x) {
173; ANY-LABEL: frem_undef_op1_fast:
174; ANY:       # %bb.0:
175; ANY-NEXT:    retq
176  %r = frem fast float %x, undef
177  ret float %r
178}
179
180; Constant folding - undef undef.
181
182define double @fadd_undef_undef(double %x) {
183; ANY-LABEL: fadd_undef_undef:
184; ANY:       # %bb.0:
185; ANY-NEXT:    retq
186  %r = fadd double undef, undef
187  ret double %r
188}
189
190define double @fsub_undef_undef(double %x) {
191; ANY-LABEL: fsub_undef_undef:
192; ANY:       # %bb.0:
193; ANY-NEXT:    retq
194  %r = fsub double undef, undef
195  ret double %r
196}
197
198define double @fmul_undef_undef(double %x) {
199; ANY-LABEL: fmul_undef_undef:
200; ANY:       # %bb.0:
201; ANY-NEXT:    retq
202  %r = fmul double undef, undef
203  ret double %r
204}
205
206define double @fdiv_undef_undef(double %x) {
207; ANY-LABEL: fdiv_undef_undef:
208; ANY:       # %bb.0:
209; ANY-NEXT:    retq
210  %r = fdiv double undef, undef
211  ret double %r
212}
213
214define double @frem_undef_undef(double %x) {
215; ANY-LABEL: frem_undef_undef:
216; ANY:       # %bb.0:
217; ANY-NEXT:    retq
218  %r = frem double undef, undef
219  ret double %r
220}
221
222; Constant folding.
223
224define float @fadd_undef_op0_nnan_constant(float %x) {
225; ANY-LABEL: fadd_undef_op0_nnan_constant:
226; ANY:       # %bb.0:
227; ANY-NEXT:    retq
228  %r = fadd nnan float undef, 1.0
229  ret float %r
230}
231
232define float @fadd_undef_op1_constant(float %x) {
233; ANY-LABEL: fadd_undef_op1_constant:
234; ANY:       # %bb.0:
235; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
236; ANY-NEXT:    retq
237  %r = fadd float 2.0, undef
238  ret float %r
239}
240
241define float @fsub_undef_op0_fast_constant(float %x) {
242; ANY-LABEL: fsub_undef_op0_fast_constant:
243; ANY:       # %bb.0:
244; ANY-NEXT:    retq
245  %r = fsub fast float undef, 3.0
246  ret float %r
247}
248
249define float @fsub_undef_op1_constant(float %x) {
250; ANY-LABEL: fsub_undef_op1_constant:
251; ANY:       # %bb.0:
252; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
253; ANY-NEXT:    retq
254  %r = fsub float 4.0, undef
255  ret float %r
256}
257
258define float @fmul_undef_op0_nnan_constant(float %x) {
259; ANY-LABEL: fmul_undef_op0_nnan_constant:
260; ANY:       # %bb.0:
261; ANY-NEXT:    retq
262  %r = fmul nnan float undef, 5.0
263  ret float %r
264}
265
266define float @fmul_undef_op1_constant(float %x) {
267; ANY-LABEL: fmul_undef_op1_constant:
268; ANY:       # %bb.0:
269; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
270; ANY-NEXT:    retq
271  %r = fmul float 6.0, undef
272  ret float %r
273}
274
275define float @fdiv_undef_op0_fast_constant(float %x) {
276; ANY-LABEL: fdiv_undef_op0_fast_constant:
277; ANY:       # %bb.0:
278; ANY-NEXT:    retq
279  %r = fdiv fast float undef, 7.0
280  ret float %r
281}
282
283define float @fdiv_undef_op1_constant(float %x) {
284; ANY-LABEL: fdiv_undef_op1_constant:
285; ANY:       # %bb.0:
286; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
287; ANY-NEXT:    retq
288  %r = fdiv float 8.0, undef
289  ret float %r
290}
291
292define float @frem_undef_op0_nnan_constant(float %x) {
293; ANY-LABEL: frem_undef_op0_nnan_constant:
294; ANY:       # %bb.0:
295; ANY-NEXT:    retq
296  %r = frem nnan float undef, 9.0
297  ret float %r
298}
299
300define float @frem_undef_op1_constant(float %x) {
301; ANY-LABEL: frem_undef_op1_constant:
302; ANY:       # %bb.0:
303; ANY-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
304; ANY-NEXT:    retq
305  %r = frem float 10.0, undef
306  ret float %r
307}
308
309; Constant folding - special constants: NaN.
310
311define double @fadd_undef_op0_constant_nan(double %x) {
312; ANY-LABEL: fadd_undef_op0_constant_nan:
313; ANY:       # %bb.0:
314; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
315; ANY-NEXT:    retq
316  %r = fadd double undef, 0x7FF8000000000000
317  ret double %r
318}
319
320define double @fadd_undef_op1_fast_constant_nan(double %x) {
321; ANY-LABEL: fadd_undef_op1_fast_constant_nan:
322; ANY:       # %bb.0:
323; ANY-NEXT:    retq
324  %r = fadd fast double 0xFFF0000000000001, undef
325  ret double %r
326}
327
328define double @fsub_undef_op0_constant_nan(double %x) {
329; ANY-LABEL: fsub_undef_op0_constant_nan:
330; ANY:       # %bb.0:
331; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
332; ANY-NEXT:    retq
333  %r = fsub double undef, 0xFFF8000000000010
334  ret double %r
335}
336
337define double @fsub_undef_op1_nnan_constant_nan(double %x) {
338; ANY-LABEL: fsub_undef_op1_nnan_constant_nan:
339; ANY:       # %bb.0:
340; ANY-NEXT:    retq
341  %r = fsub nnan double 0x7FF0000000000011, undef
342  ret double %r
343}
344
345define double @fmul_undef_op0_constant_nan(double %x) {
346; ANY-LABEL: fmul_undef_op0_constant_nan:
347; ANY:       # %bb.0:
348; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
349; ANY-NEXT:    retq
350  %r = fmul double undef, 0x7FF8000000000100
351  ret double %r
352}
353
354define double @fmul_undef_op1_fast_constant_nan(double %x) {
355; ANY-LABEL: fmul_undef_op1_fast_constant_nan:
356; ANY:       # %bb.0:
357; ANY-NEXT:    retq
358  %r = fmul fast double 0xFFF0000000000101, undef
359  ret double %r
360}
361
362define double @fdiv_undef_op0_constant_nan(double %x) {
363; ANY-LABEL: fdiv_undef_op0_constant_nan:
364; ANY:       # %bb.0:
365; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
366; ANY-NEXT:    retq
367  %r = fdiv double undef, 0xFFF8000000000110
368  ret double %r
369}
370
371define double @fdiv_undef_op1_nnan_constant_nan(double %x) {
372; ANY-LABEL: fdiv_undef_op1_nnan_constant_nan:
373; ANY:       # %bb.0:
374; ANY-NEXT:    retq
375  %r = fdiv nnan double 0x7FF0000000000111, undef
376  ret double %r
377}
378
379define double @frem_undef_op0_constant_nan(double %x) {
380; ANY-LABEL: frem_undef_op0_constant_nan:
381; ANY:       # %bb.0:
382; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
383; ANY-NEXT:    retq
384  %r = frem double undef, 0x7FF8000000001000
385  ret double %r
386}
387
388define double @frem_undef_op1_fast_constant_nan(double %x) {
389; ANY-LABEL: frem_undef_op1_fast_constant_nan:
390; ANY:       # %bb.0:
391; ANY-NEXT:    retq
392  %r = frem fast double 0xFFF0000000001001, undef
393  ret double %r
394}
395
396; Constant folding - special constants: Inf.
397
398define double @fadd_undef_op0_constant_inf(double %x) {
399; ANY-LABEL: fadd_undef_op0_constant_inf:
400; ANY:       # %bb.0:
401; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
402; ANY-NEXT:    retq
403  %r = fadd double undef, 0x7FF0000000000000
404  ret double %r
405}
406
407define double @fadd_undef_op1_fast_constant_inf(double %x) {
408; ANY-LABEL: fadd_undef_op1_fast_constant_inf:
409; ANY:       # %bb.0:
410; ANY-NEXT:    retq
411  %r = fadd fast double 0xFFF0000000000000, undef
412  ret double %r
413}
414
415define double @fsub_undef_op0_constant_inf(double %x) {
416; ANY-LABEL: fsub_undef_op0_constant_inf:
417; ANY:       # %bb.0:
418; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
419; ANY-NEXT:    retq
420  %r = fsub double undef, 0xFFF0000000000000
421  ret double %r
422}
423
424define double @fsub_undef_op1_ninf_constant_inf(double %x) {
425; ANY-LABEL: fsub_undef_op1_ninf_constant_inf:
426; ANY:       # %bb.0:
427; ANY-NEXT:    retq
428  %r = fsub ninf double 0x7FF0000000000000, undef
429  ret double %r
430}
431
432define double @fmul_undef_op0_constant_inf(double %x) {
433; ANY-LABEL: fmul_undef_op0_constant_inf:
434; ANY:       # %bb.0:
435; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
436; ANY-NEXT:    retq
437  %r = fmul double undef, 0x7FF0000000000000
438  ret double %r
439}
440
441define double @fmul_undef_op1_fast_constant_inf(double %x) {
442; ANY-LABEL: fmul_undef_op1_fast_constant_inf:
443; ANY:       # %bb.0:
444; ANY-NEXT:    retq
445  %r = fmul fast double 0xFFF0000000000000, undef
446  ret double %r
447}
448
449define double @fdiv_undef_op0_constant_inf(double %x) {
450; ANY-LABEL: fdiv_undef_op0_constant_inf:
451; ANY:       # %bb.0:
452; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
453; ANY-NEXT:    retq
454  %r = fdiv double undef, 0xFFF0000000000000
455  ret double %r
456}
457
458define double @fdiv_undef_op1_ninf_constant_inf(double %x) {
459; ANY-LABEL: fdiv_undef_op1_ninf_constant_inf:
460; ANY:       # %bb.0:
461; ANY-NEXT:    retq
462  %r = fdiv ninf double 0x7FF0000000000000, undef
463  ret double %r
464}
465
466define double @frem_undef_op0_constant_inf(double %x) {
467; ANY-LABEL: frem_undef_op0_constant_inf:
468; ANY:       # %bb.0:
469; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
470; ANY-NEXT:    retq
471  %r = frem double undef, 0x7FF0000000000000
472  ret double %r
473}
474
475define double @frem_undef_op1_fast_constant_inf(double %x) {
476; ANY-LABEL: frem_undef_op1_fast_constant_inf:
477; ANY:       # %bb.0:
478; ANY-NEXT:    retq
479  %r = frem fast double 0xFFF0000000000000, undef
480  ret double %r
481}
482
483define <2 x double> @fadd_undef_op1_constant_vec(<2 x double> %x) {
484; ANY-LABEL: fadd_undef_op1_constant_vec:
485; ANY:       # %bb.0:
486; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
487; ANY-NEXT:    retq
488  %r = fadd <2 x double> <double 42.0, double undef>, undef
489  ret <2 x double> %r
490}
491
492define <2 x double> @fadd_undef_op0_constant_vec(<2 x double> %x) {
493; ANY-LABEL: fadd_undef_op0_constant_vec:
494; ANY:       # %bb.0:
495; ANY-NEXT:    movaps {{.*#+}} xmm0 = <u,NaN>
496; ANY-NEXT:    retq
497  %r = fadd <2 x double> undef, <double undef, double 42.0>
498  ret <2 x double> %r
499}
500
501define <2 x double> @fsub_undef_op1_constant_vec(<2 x double> %x) {
502; ANY-LABEL: fsub_undef_op1_constant_vec:
503; ANY:       # %bb.0:
504; ANY-NEXT:    movaps {{.*#+}} xmm0 = <u,NaN>
505; ANY-NEXT:    retq
506  %r = fsub <2 x double> <double undef, double 42.0>, undef
507  ret <2 x double> %r
508}
509
510define <2 x double> @fsub_undef_op0_constant_vec(<2 x double> %x) {
511; ANY-LABEL: fsub_undef_op0_constant_vec:
512; ANY:       # %bb.0:
513; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
514; ANY-NEXT:    retq
515  %r = fsub <2 x double> undef, <double 42.0, double undef>
516  ret <2 x double> %r
517}
518
519define <2 x double> @fmul_undef_op1_constant_vec(<2 x double> %x) {
520; ANY-LABEL: fmul_undef_op1_constant_vec:
521; ANY:       # %bb.0:
522; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
523; ANY-NEXT:    retq
524  %r = fmul <2 x double> <double 42.0, double undef>, undef
525  ret <2 x double> %r
526}
527
528define <2 x double> @fmul_undef_op0_constant_vec(<2 x double> %x) {
529; ANY-LABEL: fmul_undef_op0_constant_vec:
530; ANY:       # %bb.0:
531; ANY-NEXT:    movaps {{.*#+}} xmm0 = <u,NaN>
532; ANY-NEXT:    retq
533  %r = fmul <2 x double> undef, <double undef, double 42.0>
534  ret <2 x double> %r
535}
536
537define <2 x double> @fdiv_undef_op1_constant_vec(<2 x double> %x) {
538; ANY-LABEL: fdiv_undef_op1_constant_vec:
539; ANY:       # %bb.0:
540; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
541; ANY-NEXT:    retq
542  %r = fdiv <2 x double> <double 42.0, double undef>, undef
543  ret <2 x double> %r
544}
545
546define <2 x double> @fdiv_undef_op0_constant_vec(<2 x double> %x) {
547; ANY-LABEL: fdiv_undef_op0_constant_vec:
548; ANY:       # %bb.0:
549; ANY-NEXT:    movaps {{.*#+}} xmm0 = <u,NaN>
550; ANY-NEXT:    retq
551  %r = fdiv <2 x double> undef, <double undef, double 42.0>
552  ret <2 x double> %r
553}
554
555define <2 x double> @frem_undef_op1_constant_vec(<2 x double> %x) {
556; ANY-LABEL: frem_undef_op1_constant_vec:
557; ANY:       # %bb.0:
558; ANY-NEXT:    movaps {{.*#+}} xmm0 = <u,NaN>
559; ANY-NEXT:    retq
560  %r = frem <2 x double> <double undef, double 42.0>, undef
561  ret <2 x double> %r
562}
563
564define <2 x double> @frem_undef_op0_constant_vec(<2 x double> %x) {
565; ANY-LABEL: frem_undef_op0_constant_vec:
566; ANY:       # %bb.0:
567; ANY-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
568; ANY-NEXT:    retq
569  %r = frem <2 x double> undef, <double 42.0, double undef>
570  ret <2 x double> %r
571}
572
573