AVX512: Change VPMOVB2M DAG lowering , use CVT2MASK node instead TRUNCATE.
[oota-llvm.git] / test / CodeGen / X86 / avx512-fma.ll
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=+avx512f -fp-contract=fast | FileCheck %s --check-prefix=ALL --check-prefix=KNL
3 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=skx -fp-contract=fast | FileCheck %s --check-prefix=ALL --check-prefix=SKX
4
5 define <16 x float> @test_x86_fmadd_ps_z(<16 x float> %a0, <16 x float> %a1, <16 x float> %a2) {
6 ; ALL-LABEL: test_x86_fmadd_ps_z:
7 ; ALL:       ## BB#0:
8 ; ALL-NEXT:    vfmadd213ps %zmm2, %zmm1, %zmm0
9 ; ALL-NEXT:    retq
10   %x = fmul <16 x float> %a0, %a1
11   %res = fadd <16 x float> %x, %a2
12   ret <16 x float> %res
13 }
14
15 define <16 x float> @test_x86_fmsub_ps_z(<16 x float> %a0, <16 x float> %a1, <16 x float> %a2) {
16 ; ALL-LABEL: test_x86_fmsub_ps_z:
17 ; ALL:       ## BB#0:
18 ; ALL-NEXT:    vfmsub213ps %zmm2, %zmm1, %zmm0
19 ; ALL-NEXT:    retq
20   %x = fmul <16 x float> %a0, %a1
21   %res = fsub <16 x float> %x, %a2
22   ret <16 x float> %res
23 }
24
25 define <16 x float> @test_x86_fnmadd_ps_z(<16 x float> %a0, <16 x float> %a1, <16 x float> %a2) {
26 ; ALL-LABEL: test_x86_fnmadd_ps_z:
27 ; ALL:       ## BB#0:
28 ; ALL-NEXT:    vfnmadd213ps %zmm2, %zmm1, %zmm0
29 ; ALL-NEXT:    retq
30   %x = fmul <16 x float> %a0, %a1
31   %res = fsub <16 x float> %a2, %x
32   ret <16 x float> %res
33 }
34
35 define <16 x float> @test_x86_fnmsub_ps_z(<16 x float> %a0, <16 x float> %a1, <16 x float> %a2) {
36 ; ALL-LABEL: test_x86_fnmsub_ps_z:
37 ; ALL:       ## BB#0:
38 ; ALL-NEXT:    vfnmsub213ps %zmm2, %zmm1, %zmm0
39 ; ALL-NEXT:    retq
40   %x = fmul <16 x float> %a0, %a1
41   %y = fsub <16 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00,
42                           float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00,
43                           float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00,
44                           float -0.000000e+00>, %x
45   %res = fsub <16 x float> %y, %a2
46   ret <16 x float> %res
47 }
48
49 define <8 x double> @test_x86_fmadd_pd_z(<8 x double> %a0, <8 x double> %a1, <8 x double> %a2) {
50 ; ALL-LABEL: test_x86_fmadd_pd_z:
51 ; ALL:       ## BB#0:
52 ; ALL-NEXT:    vfmadd213pd %zmm2, %zmm1, %zmm0
53 ; ALL-NEXT:    retq
54   %x = fmul <8 x double> %a0, %a1
55   %res = fadd <8 x double> %x, %a2
56   ret <8 x double> %res
57 }
58
59 define <8 x double> @test_x86_fmsub_pd_z(<8 x double> %a0, <8 x double> %a1, <8 x double> %a2) {
60 ; ALL-LABEL: test_x86_fmsub_pd_z:
61 ; ALL:       ## BB#0:
62 ; ALL-NEXT:    vfmsub213pd %zmm2, %zmm1, %zmm0
63 ; ALL-NEXT:    retq
64   %x = fmul <8 x double> %a0, %a1
65   %res = fsub <8 x double> %x, %a2
66   ret <8 x double> %res
67 }
68
69 define double @test_x86_fmsub_213(double %a0, double %a1, double %a2) {
70 ; ALL-LABEL: test_x86_fmsub_213:
71 ; ALL:       ## BB#0:
72 ; ALL-NEXT:    vfmsub213sd %xmm2, %xmm0, %xmm1
73 ; ALL-NEXT:    vmovaps %zmm1, %zmm0
74 ; ALL-NEXT:    retq
75   %x = fmul double %a0, %a1
76   %res = fsub double %x, %a2
77   ret double %res
78 }
79
80 define double @test_x86_fmsub_213_m(double %a0, double %a1, double * %a2_ptr) {
81 ; KNL-LABEL: test_x86_fmsub_213_m:
82 ; KNL:       ## BB#0:
83 ; KNL-NEXT:    vfmsub213sd (%rdi), %xmm0, %xmm1
84 ; KNL-NEXT:    vmovaps %zmm1, %zmm0
85 ; KNL-NEXT:    retq
86 ;
87 ; SKX-LABEL: test_x86_fmsub_213_m:
88 ; SKX:       ## BB#0:
89 ; SKX-NEXT:    vfmsub213sd (%rdi), %xmm1, %xmm0
90 ; SKX-NEXT:    retq
91   %a2 = load double , double *%a2_ptr
92   %x = fmul double %a0, %a1
93   %res = fsub double %x, %a2
94   ret double %res
95 }
96
97 define double @test_x86_fmsub_231_m(double %a0, double %a1, double * %a2_ptr) {
98 ; ALL-LABEL: test_x86_fmsub_231_m:
99 ; ALL:       ## BB#0:
100 ; ALL-NEXT:    vfmsub231sd (%rdi), %xmm0, %xmm1
101 ; ALL-NEXT:    vmovaps %zmm1, %zmm0
102 ; ALL-NEXT:    retq
103   %a2 = load double , double *%a2_ptr
104   %x = fmul double %a0, %a2
105   %res = fsub double %x, %a1
106   ret double %res
107 }
108
109 define <16 x float> @test231_br(<16 x float> %a1, <16 x float> %a2) nounwind {
110 ; ALL-LABEL: test231_br:
111 ; ALL:       ## BB#0:
112 ; ALL-NEXT:    vfmadd231ps {{.*}}(%rip){1to16}, %zmm0, %zmm1
113 ; ALL-NEXT:    vmovaps %zmm1, %zmm0
114 ; ALL-NEXT:    retq
115   %b1 = fmul <16 x float> %a1, <float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000>
116   %b2 = fadd <16 x float> %b1, %a2
117   ret <16 x float> %b2
118 }
119
120 define <16 x float> @test213_br(<16 x float> %a1, <16 x float> %a2) nounwind {
121 ; ALL-LABEL: test213_br:
122 ; ALL:       ## BB#0:
123 ; ALL-NEXT:    vfmadd213ps {{.*}}(%rip){1to16}, %zmm1, %zmm0
124 ; ALL-NEXT:    retq
125   %b1 = fmul <16 x float> %a1, %a2
126   %b2 = fadd <16 x float> %b1, <float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000, float 0x3FB99999A0000000>
127   ret <16 x float> %b2
128 }
129
130 ;mask (a*c+b , a)
131 define <16 x float> @test_x86_fmadd132_ps(<16 x float> %a0, <16 x float> %a1, <16 x float> *%a2_ptrt, <16 x i1> %mask) {
132 ; KNL-LABEL: test_x86_fmadd132_ps:
133 ; KNL:       ## BB#0:
134 ; KNL-NEXT:    vpmovsxbd %xmm2, %zmm2
135 ; KNL-NEXT:    vpslld $31, %zmm2, %zmm2
136 ; KNL-NEXT:    vptestmd %zmm2, %zmm2, %k1
137 ; KNL-NEXT:    vfmadd132ps (%rdi), %zmm1, %zmm0 {%k1}
138 ; KNL-NEXT:    retq
139 ;
140 ; SKX-LABEL: test_x86_fmadd132_ps:
141 ; SKX:       ## BB#0:
142 ; SKX-NEXT:    vpsllw $7, %xmm2, %xmm2
143 ; SKX-NEXT:    vpmovb2m %xmm2, %k1
144 ; SKX-NEXT:    vfmadd132ps (%rdi), %zmm1, %zmm0 {%k1}
145 ; SKX-NEXT:    retq
146   %a2   = load <16 x float>,<16 x float> *%a2_ptrt,align 1
147   %x = fmul <16 x float> %a0, %a2
148   %y = fadd <16 x float> %x, %a1
149   %res = select <16 x i1> %mask, <16 x float> %y, <16 x float> %a0
150   ret <16 x float> %res
151 }
152
153 ;mask (a*c+b , b)
154 define <16 x float> @test_x86_fmadd231_ps(<16 x float> %a0, <16 x float> %a1, <16 x float> *%a2_ptrt, <16 x i1> %mask) {
155 ; KNL-LABEL: test_x86_fmadd231_ps:
156 ; KNL:       ## BB#0:
157 ; KNL-NEXT:    vpmovsxbd %xmm2, %zmm2
158 ; KNL-NEXT:    vpslld $31, %zmm2, %zmm2
159 ; KNL-NEXT:    vptestmd %zmm2, %zmm2, %k1
160 ; KNL-NEXT:    vfmadd231ps (%rdi), %zmm0, %zmm1 {%k1}
161 ; KNL-NEXT:    vmovaps %zmm1, %zmm0
162 ; KNL-NEXT:    retq
163 ;
164 ; SKX-LABEL: test_x86_fmadd231_ps:
165 ; SKX:       ## BB#0:
166 ; SKX-NEXT:    vpsllw $7, %xmm2, %xmm2
167 ; SKX-NEXT:    vpmovb2m %xmm2, %k1
168 ; SKX-NEXT:    vfmadd231ps (%rdi), %zmm0, %zmm1 {%k1}
169 ; SKX-NEXT:    vmovaps %zmm1, %zmm0
170 ; SKX-NEXT:    retq
171   %a2   = load <16 x float>,<16 x float> *%a2_ptrt,align 1
172   %x = fmul <16 x float> %a0, %a2
173   %y = fadd <16 x float> %x, %a1
174   %res = select <16 x i1> %mask, <16 x float> %y, <16 x float> %a1
175   ret <16 x float> %res
176 }
177
178 ;mask (b*a+c , b)
179 define <16 x float> @test_x86_fmadd213_ps(<16 x float> %a0, <16 x float> %a1, <16 x float> *%a2_ptrt, <16 x i1> %mask) {
180 ; KNL-LABEL: test_x86_fmadd213_ps:
181 ; KNL:       ## BB#0:
182 ; KNL-NEXT:    vpmovsxbd %xmm2, %zmm2
183 ; KNL-NEXT:    vpslld $31, %zmm2, %zmm2
184 ; KNL-NEXT:    vptestmd %zmm2, %zmm2, %k1
185 ; KNL-NEXT:    vfmadd213ps (%rdi), %zmm0, %zmm1 {%k1}
186 ; KNL-NEXT:    vmovaps %zmm1, %zmm0
187 ; KNL-NEXT:    retq
188 ;
189 ; SKX-LABEL: test_x86_fmadd213_ps:
190 ; SKX:       ## BB#0:
191 ; SKX-NEXT:    vpsllw $7, %xmm2, %xmm2
192 ; SKX-NEXT:    vpmovb2m %xmm2, %k1
193 ; SKX-NEXT:    vfmadd213ps (%rdi), %zmm0, %zmm1 {%k1}
194 ; SKX-NEXT:    vmovaps %zmm1, %zmm0
195 ; SKX-NEXT:    retq
196   %a2   = load <16 x float>,<16 x float> *%a2_ptrt,align 1
197   %x = fmul <16 x float> %a1, %a0
198   %y = fadd <16 x float> %x, %a2
199   %res = select <16 x i1> %mask, <16 x float> %y, <16 x float> %a1
200   ret <16 x float> %res
201 }
202