[x86] enable machine combiner reassociations for 256-bit vector FP mul/add
[oota-llvm.git] / test / CodeGen / X86 / avx512-trunc.ll
1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=knl | FileCheck %s --check-prefix=KNL
2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=skx | FileCheck %s --check-prefix=SKX 
3  
4  attributes #0 = { nounwind }
5  
6 ; KNL-LABEL: trunc_16x32_to_16x8
7 ; KNL: vpmovdb
8 ; KNL: ret
9 define <16 x i8> @trunc_16x32_to_16x8(<16 x i32> %i) #0 {
10   %x = trunc <16 x i32> %i to <16 x i8>
11   ret <16 x i8> %x
12 }
13
14 ; KNL-LABEL: trunc_8x64_to_8x16
15 ; KNL: vpmovqw
16 ; KNL: ret
17 define <8 x i16> @trunc_8x64_to_8x16(<8 x i64> %i) #0 {
18   %x = trunc <8 x i64> %i to <8 x i16>
19   ret <8 x i16> %x
20 }
21
22 ; KNL-LABEL: trunc_v16i32_to_v16i16
23 ; KNL: vpmovdw
24 ; KNL: ret
25 define <16 x i16> @trunc_v16i32_to_v16i16(<16 x i32> %x) #0 {
26   %1 = trunc <16 x i32> %x to <16 x i16>
27   ret <16 x i16> %1
28 }
29
30 define <8 x i8> @trunc_qb_512(<8 x i64> %i) #0 {
31 ; SKX-LABEL: trunc_qb_512:
32 ; SKX:       ## BB#0:
33 ; SKX-NEXT:    vpmovqw %zmm0, %xmm0
34 ; SKX-NEXT:    retq
35   %x = trunc <8 x i64> %i to <8 x i8>
36   ret <8 x i8> %x
37 }
38
39 define void @trunc_qb_512_mem(<8 x i64> %i, <8 x i8>* %res) #0 {
40 ; SKX-LABEL: trunc_qb_512_mem:
41 ; SKX:       ## BB#0:
42 ; SKX-NEXT:    vpmovqb %zmm0, (%rdi)
43 ; SKX-NEXT:    retq
44     %x = trunc <8 x i64> %i to <8 x i8>
45     store <8 x i8> %x, <8 x i8>* %res
46     ret void
47 }
48
49 define <4 x i8> @trunc_qb_256(<4 x i64> %i) #0 {
50 ; SKX-LABEL: trunc_qb_256:
51 ; SKX:       ## BB#0:
52 ; SKX-NEXT:    vpmovqd %ymm0, %xmm0
53 ; SKX-NEXT:    retq
54   %x = trunc <4 x i64> %i to <4 x i8>
55   ret <4 x i8> %x
56 }
57
58 define void @trunc_qb_256_mem(<4 x i64> %i, <4 x i8>* %res) #0 {
59 ; SKX-LABEL: trunc_qb_256_mem:
60 ; SKX:       ## BB#0:
61 ; SKX-NEXT:    vpmovqb %ymm0, (%rdi)
62 ; SKX-NEXT:    retq
63     %x = trunc <4 x i64> %i to <4 x i8>
64     store <4 x i8> %x, <4 x i8>* %res
65     ret void
66 }
67
68 define <2 x i8> @trunc_qb_128(<2 x i64> %i) #0 {
69 ; SKX-LABEL: trunc_qb_128:
70 ; SKX:       ## BB#0:
71 ; SKX-NEXT:    retq
72   %x = trunc <2 x i64> %i to <2 x i8>
73   ret <2 x i8> %x
74 }
75
76 define void @trunc_qb_128_mem(<2 x i64> %i, <2 x i8>* %res) #0 {
77 ; SKX-LABEL: trunc_qb_128_mem:
78 ; SKX:       ## BB#0:
79 ; SKX-NEXT:    vpmovqb %xmm0, (%rdi)
80 ; SKX-NEXT:    retq
81     %x = trunc <2 x i64> %i to <2 x i8>
82     store <2 x i8> %x, <2 x i8>* %res
83     ret void
84 }
85
86 define <8 x i16> @trunc_qw_512(<8 x i64> %i) #0 {
87 ; SKX-LABEL: trunc_qw_512:
88 ; SKX:       ## BB#0:
89 ; SKX-NEXT:    vpmovqw %zmm0, %xmm0
90 ; SKX-NEXT:    retq
91   %x = trunc <8 x i64> %i to <8 x i16>
92   ret <8 x i16> %x
93 }
94
95 define void @trunc_qw_512_mem(<8 x i64> %i, <8 x i16>* %res) #0 {
96 ; SKX-LABEL: trunc_qw_512_mem:
97 ; SKX:       ## BB#0:
98 ; SKX-NEXT:    vpmovqw %zmm0, (%rdi)
99 ; SKX-NEXT:    retq
100     %x = trunc <8 x i64> %i to <8 x i16>
101     store <8 x i16> %x, <8 x i16>* %res
102     ret void
103 }
104
105 define <4 x i16> @trunc_qw_256(<4 x i64> %i) #0 {
106 ; SKX-LABEL: trunc_qw_256:
107 ; SKX:       ## BB#0:
108 ; SKX-NEXT:    vpmovqd %ymm0, %xmm0
109 ; SKX-NEXT:    retq
110   %x = trunc <4 x i64> %i to <4 x i16>
111   ret <4 x i16> %x
112 }
113
114 define void @trunc_qw_256_mem(<4 x i64> %i, <4 x i16>* %res) #0 {
115 ; SKX-LABEL: trunc_qw_256_mem:
116 ; SKX:       ## BB#0:
117 ; SKX-NEXT:    vpmovqw %ymm0, (%rdi)
118 ; SKX-NEXT:    retq
119     %x = trunc <4 x i64> %i to <4 x i16>
120     store <4 x i16> %x, <4 x i16>* %res
121     ret void
122 }
123
124 define <2 x i16> @trunc_qw_128(<2 x i64> %i) #0 {
125 ; SKX-LABEL: trunc_qw_128:
126 ; SKX:       ## BB#0:
127 ; SKX-NEXT:    retq
128   %x = trunc <2 x i64> %i to <2 x i16>
129   ret <2 x i16> %x
130 }
131
132 define void @trunc_qw_128_mem(<2 x i64> %i, <2 x i16>* %res) #0 {
133 ; SKX-LABEL: trunc_qw_128_mem:
134 ; SKX:       ## BB#0:
135 ; SKX-NEXT:    vpmovqw %xmm0, (%rdi)
136 ; SKX-NEXT:    retq
137     %x = trunc <2 x i64> %i to <2 x i16>
138     store <2 x i16> %x, <2 x i16>* %res
139     ret void
140 }
141
142 define <8 x i32> @trunc_qd_512(<8 x i64> %i) #0 {
143 ; SKX-LABEL: trunc_qd_512:
144 ; SKX:       ## BB#0:
145 ; SKX-NEXT:    vpmovqd %zmm0, %ymm0
146 ; SKX-NEXT:    retq
147   %x = trunc <8 x i64> %i to <8 x i32>
148   ret <8 x i32> %x
149 }
150
151 define void @trunc_qd_512_mem(<8 x i64> %i, <8 x i32>* %res) #0 {
152 ; SKX-LABEL: trunc_qd_512_mem:
153 ; SKX:       ## BB#0:
154 ; SKX-NEXT:    vpmovqd %zmm0, (%rdi)
155 ; SKX-NEXT:    retq
156     %x = trunc <8 x i64> %i to <8 x i32>
157     store <8 x i32> %x, <8 x i32>* %res
158     ret void
159 }
160
161 define <4 x i32> @trunc_qd_256(<4 x i64> %i) #0 {
162 ; SKX-LABEL: trunc_qd_256:
163 ; SKX:       ## BB#0:
164 ; SKX-NEXT:    vpmovqd %ymm0, %xmm0
165 ; SKX-NEXT:    retq
166   %x = trunc <4 x i64> %i to <4 x i32>
167   ret <4 x i32> %x
168 }
169
170 define void @trunc_qd_256_mem(<4 x i64> %i, <4 x i32>* %res) #0 {
171 ; SKX-LABEL: trunc_qd_256_mem:
172 ; SKX:       ## BB#0:
173 ; SKX-NEXT:    vpmovqd %ymm0, (%rdi)
174 ; SKX-NEXT:    retq
175     %x = trunc <4 x i64> %i to <4 x i32>
176     store <4 x i32> %x, <4 x i32>* %res
177     ret void
178 }
179
180 define <2 x i32> @trunc_qd_128(<2 x i64> %i) #0 {
181 ; SKX-LABEL: trunc_qd_128:
182 ; SKX:       ## BB#0:
183 ; SKX-NEXT:    retq
184   %x = trunc <2 x i64> %i to <2 x i32>
185   ret <2 x i32> %x
186 }
187
188 define void @trunc_qd_128_mem(<2 x i64> %i, <2 x i32>* %res) #0 {
189 ; SKX-LABEL: trunc_qd_128_mem:
190 ; SKX:       ## BB#0:
191 ; SKX-NEXT:    vpmovqd %xmm0, (%rdi)
192 ; SKX-NEXT:    retq
193     %x = trunc <2 x i64> %i to <2 x i32>
194     store <2 x i32> %x, <2 x i32>* %res
195     ret void
196 }
197
198 define <16 x i8> @trunc_db_512(<16 x i32> %i) #0 {
199 ; SKX-LABEL: trunc_db_512:
200 ; SKX:       ## BB#0:
201 ; SKX-NEXT:    vpmovdb %zmm0, %xmm0
202 ; SKX-NEXT:    retq
203   %x = trunc <16 x i32> %i to <16 x i8>
204   ret <16 x i8> %x
205 }
206
207 define void @trunc_db_512_mem(<16 x i32> %i, <16 x i8>* %res) #0 {
208 ; SKX-LABEL: trunc_db_512_mem:
209 ; SKX:       ## BB#0:
210 ; SKX-NEXT:    vpmovdb %zmm0, (%rdi)
211 ; SKX-NEXT:    retq
212     %x = trunc <16 x i32> %i to <16 x i8>
213     store <16 x i8> %x, <16 x i8>* %res
214     ret void
215 }
216
217 define <8 x i8> @trunc_db_256(<8 x i32> %i) #0 {
218 ; SKX-LABEL: trunc_db_256:
219 ; SKX:       ## BB#0:
220 ; SKX-NEXT:    vpmovdw %ymm0, %xmm0
221 ; SKX-NEXT:    retq
222   %x = trunc <8 x i32> %i to <8 x i8>
223   ret <8 x i8> %x
224 }
225
226 define void @trunc_db_256_mem(<8 x i32> %i, <8 x i8>* %res) #0 {
227 ; SKX-LABEL: trunc_db_256_mem:
228 ; SKX:       ## BB#0:
229 ; SKX-NEXT:    vpmovdb %ymm0, (%rdi)
230 ; SKX-NEXT:    retq
231     %x = trunc <8 x i32> %i to <8 x i8>
232     store <8 x i8> %x, <8 x i8>* %res
233     ret void
234 }
235
236 define <4 x i8> @trunc_db_128(<4 x i32> %i) #0 {
237 ; SKX-LABEL: trunc_db_128:
238 ; SKX:       ## BB#0:
239 ; SKX-NEXT:    retq
240   %x = trunc <4 x i32> %i to <4 x i8>
241   ret <4 x i8> %x
242 }
243
244 define void @trunc_db_128_mem(<4 x i32> %i, <4 x i8>* %res) #0 {
245 ; SKX-LABEL: trunc_db_128_mem:
246 ; SKX:       ## BB#0:
247 ; SKX-NEXT:    vpmovdb %xmm0, (%rdi)
248 ; SKX-NEXT:    retq
249     %x = trunc <4 x i32> %i to <4 x i8>
250     store <4 x i8> %x, <4 x i8>* %res
251     ret void
252 }
253
254 define <16 x i16> @trunc_dw_512(<16 x i32> %i) #0 {
255 ; SKX-LABEL: trunc_dw_512:
256 ; SKX:       ## BB#0:
257 ; SKX-NEXT:    vpmovdw %zmm0, %ymm0
258 ; SKX-NEXT:    retq
259   %x = trunc <16 x i32> %i to <16 x i16>
260   ret <16 x i16> %x
261 }
262
263 define void @trunc_dw_512_mem(<16 x i32> %i, <16 x i16>* %res) #0 {
264 ; SKX-LABEL: trunc_dw_512_mem:
265 ; SKX:       ## BB#0:
266 ; SKX-NEXT:    vpmovdw %zmm0, (%rdi)
267 ; SKX-NEXT:    retq
268     %x = trunc <16 x i32> %i to <16 x i16>
269     store <16 x i16> %x, <16 x i16>* %res
270     ret void
271 }
272
273 define <8 x i16> @trunc_dw_256(<8 x i32> %i) #0 {
274 ; SKX-LABEL: trunc_dw_256:
275 ; SKX:       ## BB#0:
276 ; SKX-NEXT:    vpmovdw %ymm0, %xmm0
277 ; SKX-NEXT:    retq
278   %x = trunc <8 x i32> %i to <8 x i16>
279   ret <8 x i16> %x
280 }
281
282 define void @trunc_dw_256_mem(<8 x i32> %i, <8 x i16>* %res) #0 {
283 ; SKX-LABEL: trunc_dw_256_mem:
284 ; SKX:       ## BB#0:
285 ; SKX-NEXT:    vpmovdw %ymm0, (%rdi)
286 ; SKX-NEXT:    retq
287     %x = trunc <8 x i32> %i to <8 x i16>
288     store <8 x i16> %x, <8 x i16>* %res
289     ret void
290 }
291
292 define <4 x i16> @trunc_dw_128(<4 x i32> %i) #0 {
293 ; SKX-LABEL: trunc_dw_128:
294 ; SKX:       ## BB#0:
295 ; SKX-NEXT:    retq
296   %x = trunc <4 x i32> %i to <4 x i16>
297   ret <4 x i16> %x
298 }
299
300 define void @trunc_dw_128_mem(<4 x i32> %i, <4 x i16>* %res) #0 {
301 ; SKX-LABEL: trunc_dw_128_mem:
302 ; SKX:       ## BB#0:
303 ; SKX-NEXT:    vpmovdw %xmm0, (%rdi)
304 ; SKX-NEXT:    retq
305     %x = trunc <4 x i32> %i to <4 x i16>
306     store <4 x i16> %x, <4 x i16>* %res
307     ret void
308 }
309
310 define <32 x i8> @trunc_wb_512(<32 x i16> %i) #0 {
311 ; SKX-LABEL: trunc_wb_512:
312 ; SKX:       ## BB#0:
313 ; SKX-NEXT:    vpmovwb %zmm0, %ymm0
314 ; SKX-NEXT:    retq
315   %x = trunc <32 x i16> %i to <32 x i8>
316   ret <32 x i8> %x
317 }
318
319 define void @trunc_wb_512_mem(<32 x i16> %i, <32 x i8>* %res) #0 {
320 ; SKX-LABEL: trunc_wb_512_mem:
321 ; SKX:       ## BB#0:
322 ; SKX-NEXT:    vpmovwb %zmm0, (%rdi)
323 ; SKX-NEXT:    retq
324     %x = trunc <32 x i16> %i to <32 x i8>
325     store <32 x i8> %x, <32 x i8>* %res
326     ret void
327 }
328
329 define <16 x i8> @trunc_wb_256(<16 x i16> %i) #0 {
330 ; SKX-LABEL: trunc_wb_256:
331 ; SKX:       ## BB#0:
332 ; SKX-NEXT:    vpmovwb %ymm0, %xmm0
333 ; SKX-NEXT:    retq
334   %x = trunc <16 x i16> %i to <16 x i8>
335   ret <16 x i8> %x
336 }
337
338 define void @trunc_wb_256_mem(<16 x i16> %i, <16 x i8>* %res) #0 {
339 ; SKX-LABEL: trunc_wb_256_mem:
340 ; SKX:       ## BB#0:
341 ; SKX-NEXT:    vpmovwb %ymm0, (%rdi)
342 ; SKX-NEXT:    retq
343     %x = trunc <16 x i16> %i to <16 x i8>
344     store <16 x i8> %x, <16 x i8>* %res
345     ret void
346 }
347
348 define <8 x i8> @trunc_wb_128(<8 x i16> %i) #0 {
349 ; SKX-LABEL: trunc_wb_128:
350 ; SKX:       ## BB#0:
351 ; SKX-NEXT:    retq
352   %x = trunc <8 x i16> %i to <8 x i8>
353   ret <8 x i8> %x
354 }
355
356 define void @trunc_wb_128_mem(<8 x i16> %i, <8 x i8>* %res) #0 {
357 ; SKX-LABEL: trunc_wb_128_mem:
358 ; SKX:       ## BB#0:
359 ; SKX-NEXT:    vpmovwb %xmm0, (%rdi)
360 ; SKX-NEXT:    retq
361     %x = trunc <8 x i16> %i to <8 x i8>
362     store <8 x i8> %x, <8 x i8>* %res
363     ret void
364 }