Debian Codegraph @

gcc/config/i386/sse.md

raw
1 ;; GCC machine description for SSE instructions
2 ;; Copyright (C) 2005-2025 Free Software Foundation, Inc.
3 ;;
4 ;; This file is part of GCC.
5 ;;
6 ;; GCC is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 3, or (at your option)
9 ;; any later version.
10 ;;
11 ;; GCC is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
15 ;;
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING3. If not see
18 ;; <http://www.gnu.org/licenses/>.
19
20 (define_c_enum "unspec" [
21 ;; SSE
22 UNSPEC_MOVNT
23
24 ;; SSE2
25 UNSPEC_MOVDI_TO_SSE
26
27 ;; SSE3
28 UNSPEC_LDDQU
29
30 ;; SSSE3
31 UNSPEC_PSIGN
32 UNSPEC_PALIGNR
33
34 ;; For SSE4A support
35 UNSPEC_EXTRQI
36 UNSPEC_EXTRQ
37 UNSPEC_INSERTQI
38 UNSPEC_INSERTQ
39
40 ;; For SSE4.1 support
41 UNSPEC_DP
42 UNSPEC_MOVNTDQA
43 UNSPEC_MPSADBW
44 UNSPEC_PHMINPOSUW
45 UNSPEC_PTEST
46
47 ;; For SSE4.2 support
48 UNSPEC_PCMPESTR
49 UNSPEC_PCMPISTR
50
51 ;; For FMA4 support
52 UNSPEC_FMADDSUB
53 UNSPEC_XOP_UNSIGNED_CMP
54 UNSPEC_XOP_TRUEFALSE
55 UNSPEC_FRCZ
56
57 ;; For AES support
58 UNSPEC_AESENC
59 UNSPEC_AESENCLAST
60 UNSPEC_AESDEC
61 UNSPEC_AESDECLAST
62 UNSPEC_AESIMC
63 UNSPEC_AESKEYGENASSIST
64
65 ;; For PCLMUL support
66 UNSPEC_PCLMUL
67
68 ;; For AVX support
69 UNSPEC_VPERMIL
70 UNSPEC_VPERMIL2
71 UNSPEC_VPERMIL2F128
72 UNSPEC_CAST
73 UNSPEC_VTESTP
74 UNSPEC_VCVTPH2PS
75 UNSPEC_VCVTPS2PH
76
77 ;; For AVX2 support
78 UNSPEC_VPERMVAR
79 UNSPEC_VPERMTI
80 UNSPEC_GATHER
81 UNSPEC_VSIBADDR
82
83 ;; For AVX512F support
84 UNSPEC_VPERMT2
85 UNSPEC_UNSIGNED_FIX_NOTRUNC
86 UNSPEC_UNSIGNED_PCMP
87 UNSPEC_TESTM
88 UNSPEC_TESTNM
89 UNSPEC_SCATTER
90 UNSPEC_RCP14
91 UNSPEC_RSQRT14
92 UNSPEC_FIXUPIMM
93 UNSPEC_VTERNLOG
94 UNSPEC_GETEXP
95 UNSPEC_GETMANT
96 UNSPEC_ALIGN
97 UNSPEC_CONFLICT
98 UNSPEC_COMPRESS
99 UNSPEC_COMPRESS_STORE
100 UNSPEC_EXPAND
101 UNSPEC_VCVTT
102 UNSPEC_VCVTTU
103
104 ;; Mask operations
105 UNSPEC_MASKOP
106 UNSPEC_KORTEST
107 UNSPEC_KTEST
108 ;; Mask load
109 UNSPEC_MASKLOAD
110
111 ;; For embed. rounding feature
112 UNSPEC_EMBEDDED_ROUNDING
113
114 ;; For SHA support
115 UNSPEC_SHA1MSG1
116 UNSPEC_SHA1MSG2
117 UNSPEC_SHA1NEXTE
118 UNSPEC_SHA1RNDS4
119 UNSPEC_SHA256MSG1
120 UNSPEC_SHA256MSG2
121 UNSPEC_SHA256RNDS2
122
123 ;; For AVX512BW support
124 UNSPEC_DBPSADBW
125 UNSPEC_PMADDUBSW512
126 UNSPEC_PMADDWD512
127 UNSPEC_PSHUFHW
128 UNSPEC_PSHUFLW
129 UNSPEC_CVTINT2MASK
130
131 ;; For AVX512DQ support
132 UNSPEC_REDUCE
133 UNSPEC_FPCLASS
134 UNSPEC_RANGE
135
136 ;; For AVX512IFMA support
137 UNSPEC_VPMADD52LUQ
138 UNSPEC_VPMADD52HUQ
139
140 ;; For AVX512VBMI support
141 UNSPEC_VPMULTISHIFT
142
143 ;; For GFNI support
144 UNSPEC_GF2P8AFFINEINV
145 UNSPEC_GF2P8AFFINE
146 UNSPEC_GF2P8MUL
147
148 ;; For AVX512VBMI2 support
149 UNSPEC_VPSHLD
150 UNSPEC_VPSHRD
151 UNSPEC_VPSHRDV
152 UNSPEC_VPSHLDV
153
154 ;; For AVX512VNNI support
155 UNSPEC_VPDPBUSD
156 UNSPEC_VPDPBUSDS
157 UNSPEC_VPDPWSSD
158 UNSPEC_VPDPWSSDS
159
160 ;; For VAES support
161 UNSPEC_VAESDEC
162 UNSPEC_VAESDECLAST
163 UNSPEC_VAESENC
164 UNSPEC_VAESENCLAST
165
166 ;; For VPCLMULQDQ support
167 UNSPEC_VPCLMULQDQ
168
169 ;; For AVX512BITALG support
170 UNSPEC_VPSHUFBIT
171
172 ;; For VP2INTERSECT support
173 UNSPEC_VP2INTERSECT
174
175 ;; For AVX512BF16 support
176 UNSPEC_VDPBF16PS
177
178 ;; For AVX512FP16 suppport
179 UNSPEC_COMPLEX_FMA
180 UNSPEC_COMPLEX_FMA_PAIR
181 UNSPEC_COMPLEX_FCMA
182 UNSPEC_COMPLEX_FCMA_PAIR
183 UNSPEC_COMPLEX_FMUL
184 UNSPEC_COMPLEX_FCMUL
185 UNSPEC_COMPLEX_MASK
186
187 ;; For SM3 support
188 UNSPEC_SM3MSG1
189 UNSPEC_SM3MSG2
190 UNSPEC_SM3RNDS2
191
192 ;; For AVX-VNNI-INT8 support
193 UNSPEC_VPDPBSSD
194 UNSPEC_VPDPBSSDS
195 UNSPEC_VPDPBSUD
196 UNSPEC_VPDPBSUDS
197 UNSPEC_VPDPBUUD
198 UNSPEC_VPDPBUUDS
199
200 ;; For AVX-VNNI-INT16 support
201 UNSPEC_VPDPWUSD
202 UNSPEC_VPDPWUSDS
203 UNSPEC_VPDPWSUD
204 UNSPEC_VPDPWSUDS
205 UNSPEC_VPDPWUUD
206 UNSPEC_VPDPWUUDS
207
208 ;; For SHA512 support
209 UNSPEC_SHA512MSG1
210 UNSPEC_SHA512MSG2
211 UNSPEC_SHA512RNDS2
212
213 ;; For SM4 support
214 UNSPEC_SM4KEY4
215 UNSPEC_SM4RNDS4
216
217 ;; For AVX10.2 suppport
218 UNSPEC_VDPPHPS
219 UNSPEC_VCVTBIASPH2BF8
220 UNSPEC_VCVTBIASPH2BF8S
221 UNSPEC_VCVTBIASPH2HF8
222 UNSPEC_VCVTBIASPH2HF8S
223 UNSPEC_VCVT2PH2BF8
224 UNSPEC_VCVT2PH2BF8S
225 UNSPEC_VCVT2PH2HF8
226 UNSPEC_VCVT2PH2HF8S
227 UNSPEC_VCVTPH2BF8
228 UNSPEC_VCVTPH2BF8S
229 UNSPEC_VCVTPH2HF8
230 UNSPEC_VCVTPH2HF8S
231 UNSPEC_VCVTHF82PH
232 UNSPEC_VSCALEFBF16
233 UNSPEC_VRNDSCALEBF16
234 UNSPEC_VREDUCEBF16
235 UNSPEC_VGETMANTBF16
236 UNSPEC_VFPCLASSBF16
237 UNSPEC_VCVTBF162IBS
238 UNSPEC_VCVTBF162IUBS
239 UNSPEC_VCVTPH2IBS
240 UNSPEC_VCVTPH2IUBS
241 UNSPEC_VCVTPS2IBS
242 UNSPEC_VCVTPS2IUBS
243 UNSPEC_VCVTTBF162IBS
244 UNSPEC_VCVTTBF162IUBS
245 UNSPEC_VCVTTPH2IBS
246 UNSPEC_VCVTTPH2IUBS
247 UNSPEC_VCVTTPS2IBS
248 UNSPEC_VCVTTPS2IUBS
249 UNSPEC_SFIX_SATURATION
250 UNSPEC_UFIX_SATURATION
251 UNSPEC_MINMAXBF16
252 UNSPEC_MINMAX
253
254 ;; For MOVRS suppport
255 UNSPEC_VMOVRS
256 ])
257
258 (define_c_enum "unspecv" [
259 UNSPECV_LDMXCSR
260 UNSPECV_STMXCSR
261 UNSPECV_CLFLUSH
262 UNSPECV_MONITOR
263 UNSPECV_MWAIT
264 UNSPECV_VZEROALL
265
266 ;; For KEYLOCKER
267 UNSPECV_LOADIWKEY
268 UNSPECV_AESDEC128KLU8
269 UNSPECV_AESENC128KLU8
270 UNSPECV_AESDEC256KLU8
271 UNSPECV_AESENC256KLU8
272 UNSPECV_AESDECWIDE128KLU8
273 UNSPECV_AESENCWIDE128KLU8
274 UNSPECV_AESDECWIDE256KLU8
275 UNSPECV_AESENCWIDE256KLU8
276 UNSPECV_ENCODEKEY128U32
277 UNSPECV_ENCODEKEY256U32
278 ])
279
280 ;; All vector modes including V?TImode, used in move patterns.
281 (define_mode_iterator VMOVE
282 [(V64QI "TARGET_AVX512F && TARGET_EVEX512") (V32QI "TARGET_AVX") V16QI
283 (V32HI "TARGET_AVX512F && TARGET_EVEX512") (V16HI "TARGET_AVX") V8HI
284 (V16SI "TARGET_AVX512F && TARGET_EVEX512") (V8SI "TARGET_AVX") V4SI
285 (V8DI "TARGET_AVX512F && TARGET_EVEX512") (V4DI "TARGET_AVX") V2DI
286 (V4TI "TARGET_AVX512F && TARGET_EVEX512") (V2TI "TARGET_AVX") V1TI
287 (V32HF "TARGET_AVX512F && TARGET_EVEX512") (V16HF "TARGET_AVX") V8HF
288 (V32BF "TARGET_AVX512F && TARGET_EVEX512") (V16BF "TARGET_AVX") V8BF
289 (V16SF "TARGET_AVX512F && TARGET_EVEX512") (V8SF "TARGET_AVX") V4SF
290 (V8DF "TARGET_AVX512F && TARGET_EVEX512") (V4DF "TARGET_AVX") V2DF])
291
292 ;; All AVX-512{F,VL} vector modes without HF. Supposed TARGET_AVX512F baseline.
293 (define_mode_iterator V48_AVX512VL
294 [(V16SI "TARGET_EVEX512") (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
295 (V8DI "TARGET_EVEX512") (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")
296 (V16SF "TARGET_EVEX512") (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
297 (V8DF "TARGET_EVEX512") (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
298
299 (define_mode_iterator V48_256_512_AVX512VL
300 [(V16SI "TARGET_EVEX512") (V8SI "TARGET_AVX512VL")
301 (V8DI "TARGET_EVEX512") (V4DI "TARGET_AVX512VL")
302 (V16SF "TARGET_EVEX512") (V8SF "TARGET_AVX512VL")
303 (V8DF "TARGET_EVEX512") (V4DF "TARGET_AVX512VL")])
304
305 ;; All AVX-512{F,VL} vector modes. Supposed TARGET_AVX512F baseline.
306 (define_mode_iterator V48H_AVX512VL
307 [(V16SI "TARGET_EVEX512") (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
308 (V8DI "TARGET_EVEX512") (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")
309 (V32HF "TARGET_AVX512FP16 && TARGET_EVEX512")
310 (V16HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
311 (V8HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
312 (V16SF "TARGET_EVEX512") (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
313 (V8DF "TARGET_EVEX512") (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
314
315 ;; 1,2 byte AVX-512{BW,VL} vector modes. Supposed TARGET_AVX512BW baseline.
316 (define_mode_iterator VI12_AVX512VL
317 [(V64QI "TARGET_EVEX512") (V16QI "TARGET_AVX512VL") (V32QI "TARGET_AVX512VL")
318 (V32HI "TARGET_EVEX512") (V16HI "TARGET_AVX512VL") (V8HI "TARGET_AVX512VL")])
319
320 (define_mode_iterator VI12HFBF_AVX512VL
321 [(V64QI "TARGET_EVEX512") (V16QI "TARGET_AVX512VL") (V32QI "TARGET_AVX512VL")
322 (V32HI "TARGET_EVEX512") (V16HI "TARGET_AVX512VL") (V8HI "TARGET_AVX512VL")
323 (V32HF "TARGET_EVEX512") (V16HF "TARGET_AVX512VL") (V8HF "TARGET_AVX512VL")
324 (V32BF "TARGET_EVEX512") (V16BF "TARGET_AVX512VL") (V8BF "TARGET_AVX512VL")])
325
326 (define_mode_iterator VI1_AVX512VL
327 [(V64QI "TARGET_EVEX512") (V16QI "TARGET_AVX512VL") (V32QI "TARGET_AVX512VL")])
328
329 ;; All vector modes
330 (define_mode_iterator V
331 [(V64QI "TARGET_AVX512F && TARGET_EVEX512") (V32QI "TARGET_AVX") V16QI
332 (V32HI "TARGET_AVX512F && TARGET_EVEX512") (V16HI "TARGET_AVX") V8HI
333 (V16SI "TARGET_AVX512F && TARGET_EVEX512") (V8SI "TARGET_AVX") V4SI
334 (V8DI "TARGET_AVX512F && TARGET_EVEX512") (V4DI "TARGET_AVX") V2DI
335 (V32HF "TARGET_AVX512F && TARGET_EVEX512") (V16HF "TARGET_AVX") V8HF
336 (V32BF "TARGET_AVX512F && TARGET_EVEX512") (V16BF "TARGET_AVX") V8BF
337 (V16SF "TARGET_AVX512F && TARGET_EVEX512") (V8SF "TARGET_AVX") V4SF
338 (V8DF "TARGET_AVX512F && TARGET_EVEX512") (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
339
340 ;; All 128bit vector modes
341 (define_mode_iterator V_128
342 [V16QI V8HI V8HF V8BF V4SI V2DI V4SF (V2DF "TARGET_SSE2")])
343
344 ;; All 256bit vector modes
345 (define_mode_iterator V_256
346 [V32QI V16HI V8SI V4DI V8SF V4DF V16HF V16BF])
347
348 ;; All 128bit and 256bit vector modes
349 (define_mode_iterator V_128_256
350 [V32QI V16QI V16HI V8HI V8SI V4SI V4DI V2DI V2TI V1TI
351 V16HF V8HF V8SF V4SF V4DF V2DF])
352
353 ;; All 512bit vector modes
354 (define_mode_iterator V_512
355 [(V64QI "TARGET_EVEX512") (V32HI "TARGET_EVEX512")
356 (V16SI "TARGET_EVEX512") (V8DI "TARGET_EVEX512")
357 (V16SF "TARGET_EVEX512") (V8DF "TARGET_EVEX512")
358 (V32HF "TARGET_EVEX512") (V32BF "TARGET_EVEX512")])
359
360 ;; All 256bit and 512bit vector modes
361 (define_mode_iterator V_256_512
362 [V32QI V16HI V16HF V16BF V8SI V4DI V8SF V4DF
363 (V64QI "TARGET_AVX512F && TARGET_EVEX512")
364 (V32HI "TARGET_AVX512F && TARGET_EVEX512")
365 (V32HF "TARGET_AVX512F && TARGET_EVEX512")
366 (V32BF "TARGET_AVX512F && TARGET_EVEX512")
367 (V16SI "TARGET_AVX512F && TARGET_EVEX512")
368 (V8DI "TARGET_AVX512F && TARGET_EVEX512")
369 (V16SF "TARGET_AVX512F && TARGET_EVEX512")
370 (V8DF "TARGET_AVX512F && TARGET_EVEX512")])
371
372 ;; All vector float modes
373 (define_mode_iterator VF
374 [(V16SF "TARGET_AVX512F && TARGET_EVEX512") (V8SF "TARGET_AVX") V4SF
375 (V8DF "TARGET_AVX512F && TARGET_EVEX512") (V4DF "TARGET_AVX")
376 (V2DF "TARGET_SSE2")])
377
378 (define_mode_iterator VF1_VF2_AVX512DQ
379 [(V16SF "TARGET_AVX512F && TARGET_EVEX512") (V8SF "TARGET_AVX") V4SF
380 (V8DF "TARGET_AVX512DQ && TARGET_EVEX512")
381 (V4DF "TARGET_AVX512DQ && TARGET_AVX512VL")
382 (V2DF "TARGET_AVX512DQ && TARGET_AVX512VL")])
383
384 (define_mode_iterator VF1_VF2_AVX10_2
385 [(V16SF "TARGET_AVX10_2") V8SF V4SF
386 (V8DF "TARGET_AVX10_2") V4DF V2DF])
387
388 (define_mode_iterator VFH
389 [(V32HF "TARGET_AVX512FP16 && TARGET_EVEX512")
390 (V16HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
391 (V8HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
392 (V16SF "TARGET_AVX512F && TARGET_EVEX512") (V8SF "TARGET_AVX") V4SF
393 (V8DF "TARGET_AVX512F && TARGET_EVEX512") (V4DF "TARGET_AVX")
394 (V2DF "TARGET_SSE2")])
395
396 (define_mode_iterator VF_BHSD
397 [(V32HF "TARGET_AVX512FP16 && TARGET_EVEX512")
398 (V16HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
399 (V8HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
400 (V16SF "TARGET_AVX512F && TARGET_EVEX512")
401 (V8SF "TARGET_AVX") V4SF
402 (V8DF "TARGET_AVX512F && TARGET_EVEX512")
403 (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")
404 (V32BF "TARGET_AVX10_2")
405 (V16BF "TARGET_AVX10_2")
406 (V8BF "TARGET_AVX10_2")
407 ])
408
409 ;; 128-, 256- and 512-bit float vector modes for bitwise operations
410 (define_mode_iterator VFB
411 [(V32BF "TARGET_AVX512F && TARGET_EVEX512")
412 (V16BF "TARGET_AVX") (V8BF "TARGET_SSE2")
413 (V32HF "TARGET_AVX512F && TARGET_EVEX512")
414 (V16HF "TARGET_AVX") (V8HF "TARGET_SSE2")
415 (V16SF "TARGET_AVX512F && TARGET_EVEX512") (V8SF "TARGET_AVX") V4SF
416 (V8DF "TARGET_AVX512F && TARGET_EVEX512")
417 (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
418
419 ;; 128- and 256-bit float vector modes
420 (define_mode_iterator VF_128_256
421 [(V8SF "TARGET_AVX") V4SF
422 (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
423
424 ;; 128- and 256-bit float vector modes for bitwise operations
425 (define_mode_iterator VFB_128_256
426 [(V16BF "TARGET_AVX") (V8BF "TARGET_SSE2")
427 (V16HF "TARGET_AVX") (V8HF "TARGET_SSE2")
428 (V8SF "TARGET_AVX") V4SF
429 (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
430
431 ;; All SFmode vector float modes
432 (define_mode_iterator VF1
433 [(V16SF "TARGET_AVX512F && TARGET_EVEX512") (V8SF "TARGET_AVX") V4SF])
434
435 (define_mode_iterator VF1_AVX2
436 [(V16SF "TARGET_AVX512F && TARGET_EVEX512") (V8SF "TARGET_AVX2") V4SF])
437
438 ;; 128- and 256-bit SF vector modes
439 (define_mode_iterator VF1_128_256
440 [(V8SF "TARGET_AVX") V4SF])
441
442 (define_mode_iterator VF1_128_256VL
443 [(V8SF "TARGET_EVEX512") (V4SF "TARGET_AVX512VL")])
444
445 ;; All DFmode vector float modes
446 (define_mode_iterator VF2
447 [(V8DF "TARGET_AVX512F && TARGET_EVEX512") (V4DF "TARGET_AVX") V2DF])
448
449 (define_mode_iterator VF2_AVX10_2
450 [(V8DF "TARGET_AVX10_2") V4DF V2DF])
451
452 ;; All DFmode & HFmode & BFmode vector float modes
453 (define_mode_iterator VF2HB
454 [(V32BF "TARGET_AVX10_2")
455 (V16BF "TARGET_AVX10_2")
456 (V8BF "TARGET_AVX10_2")
457 (V32HF "TARGET_AVX512FP16 && TARGET_EVEX512")
458 (V16HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
459 (V8HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
460 (V8DF "TARGET_AVX512F && TARGET_EVEX512") (V4DF "TARGET_AVX") V2DF])
461
462 ;; 128- and 256-bit DF vector modes
463 (define_mode_iterator VF2_128_256
464 [(V4DF "TARGET_AVX") V2DF])
465
466 (define_mode_iterator VF2_512_256
467 [(V8DF "TARGET_AVX512F && TARGET_EVEX512") V4DF])
468
469 (define_mode_iterator VF2_512_256VL
470 [(V8DF "TARGET_EVEX512") (V4DF "TARGET_AVX512VL")])
471
472 ;; All 128bit vector SF/DF modes
473 (define_mode_iterator VF_128
474 [V4SF (V2DF "TARGET_SSE2")])
475
476 ;; All 128bit vector HF/SF/DF modes
477 (define_mode_iterator VFH_128
478 [(V8HF "TARGET_AVX512FP16")
479 V4SF (V2DF "TARGET_SSE2")])
480
481 ;; All 256bit vector float modes
482 (define_mode_iterator VF_256
483 [V8SF V4DF])
484
485 ;; All 512bit vector float modes
486 (define_mode_iterator VF_512
487 [(V16SF "TARGET_EVEX512") (V8DF "TARGET_EVEX512")])
488
489 ;; All 512bit vector float modes for bitwise operations
490 (define_mode_iterator VFB_512
491 [(V32BF "TARGET_EVEX512")
492 (V32HF "TARGET_EVEX512")
493 (V16SF "TARGET_EVEX512")
494 (V8DF "TARGET_EVEX512")])
495
496 (define_mode_iterator V24F_128
497 [V4SF V8HF V8BF])
498
499 (define_mode_iterator VI48_AVX512VL
500 [(V16SI "TARGET_EVEX512") (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
501 (V8DI "TARGET_EVEX512") (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
502
503 (define_mode_iterator VI1248_AVX512VLBW
504 [(V64QI "TARGET_AVX512BW && TARGET_EVEX512")
505 (V32QI "TARGET_AVX512VL && TARGET_AVX512BW")
506 (V16QI "TARGET_AVX512VL && TARGET_AVX512BW")
507 (V32HI "TARGET_AVX512BW && TARGET_EVEX512")
508 (V16HI "TARGET_AVX512VL && TARGET_AVX512BW")
509 (V8HI "TARGET_AVX512VL && TARGET_AVX512BW")
510 (V16SI "TARGET_EVEX512") (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
511 (V8DI "TARGET_EVEX512") (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
512
513 (define_mode_iterator VI1248_AVX10_2
514 [(V64QI "TARGET_AVX10_2") V32QI V16QI
515 (V32HI "TARGET_AVX10_2") V16HI V8HI
516 (V16SI "TARGET_AVX10_2") V8SI V4SI
517 (V8DI "TARGET_AVX10_2") V4DI V2DI])
518
519 (define_mode_iterator VF_AVX512VL
520 [(V16SF "TARGET_EVEX512") (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
521 (V8DF "TARGET_EVEX512") (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
522
523 (define_mode_iterator VFH_AVX512VL
524 [(V32HF "TARGET_AVX512FP16 && TARGET_EVEX512")
525 (V16HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
526 (V8HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
527 (V16SF "TARGET_EVEX512") (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
528 (V8DF "TARGET_EVEX512") (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
529
530 (define_mode_iterator VFH_AVX10_2
531 [(V32HF "TARGET_AVX10_2") V16HF V8HF
532 (V16SF "TARGET_AVX10_2") V8SF V4SF
533 (V8DF "TARGET_AVX10_2") V4DF V2DF])
534
535 (define_mode_iterator VF2_AVX512VL
536 [(V8DF "TARGET_EVEX512") (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
537
538 (define_mode_iterator VF1_AVX512VL
539 [(V16SF "TARGET_EVEX512") (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")])
540
541 (define_mode_iterator VF1_AVX512BW
542 [(V16SF "TARGET_AVX512BW && TARGET_EVEX512") (V8SF "TARGET_AVX2") V4SF])
543
544 (define_mode_iterator VF1_AVX10_2
545 [(V16SF "TARGET_AVX10_2") V8SF V4SF])
546
547 (define_mode_iterator VHFBF
548 [(V32HF "TARGET_EVEX512") V16HF V8HF
549 (V32BF "TARGET_EVEX512") V16BF V8BF])
550 (define_mode_iterator VHFBF_256 [V16HF V16BF])
551 (define_mode_iterator VHFBF_128 [V8HF V8BF])
552
553 (define_mode_iterator VHF_AVX512VL
554 [(V32HF "TARGET_EVEX512") (V16HF "TARGET_AVX512VL") (V8HF "TARGET_AVX512VL")])
555
556 (define_mode_iterator VHFBF_AVX512VL
557 [(V32HF "TARGET_EVEX512") (V16HF "TARGET_AVX512VL") (V8HF "TARGET_AVX512VL")
558 (V32BF "TARGET_EVEX512") (V16BF "TARGET_AVX512VL") (V8BF "TARGET_AVX512VL")])
559
560 (define_mode_iterator VHF_AVX10_2
561 [(V32HF "TARGET_AVX10_2") V16HF V8HF])
562
563 (define_mode_iterator VBF_AVX10_2
564 [(V32BF "TARGET_AVX10_2") V16BF V8BF])
565
566 ;; All vector integer modes
567 (define_mode_iterator VI
568 [(V16SI "TARGET_AVX512F && TARGET_EVEX512")
569 (V8DI "TARGET_AVX512F && TARGET_EVEX512")
570 (V64QI "TARGET_AVX512BW && TARGET_EVEX512") (V32QI "TARGET_AVX") V16QI
571 (V32HI "TARGET_AVX512BW && TARGET_EVEX512") (V16HI "TARGET_AVX") V8HI
572 (V8SI "TARGET_AVX") V4SI
573 (V4DI "TARGET_AVX") V2DI])
574
575 ;; All vector integer and HF modes
576 (define_mode_iterator VIHFBF
577 [(V16SI "TARGET_AVX512F && TARGET_EVEX512")
578 (V8DI "TARGET_AVX512F && TARGET_EVEX512")
579 (V64QI "TARGET_AVX512BW && TARGET_EVEX512") (V32QI "TARGET_AVX") V16QI
580 (V32HI "TARGET_AVX512BW && TARGET_EVEX512") (V16HI "TARGET_AVX") V8HI
581 (V8SI "TARGET_AVX") V4SI
582 (V4DI "TARGET_AVX") V2DI
583 (V32HF "TARGET_AVX512BW && TARGET_EVEX512") (V16HF "TARGET_AVX") V8HF
584 (V32BF "TARGET_AVX512BW && TARGET_EVEX512") (V16BF "TARGET_AVX") V8BF])
585
586 (define_mode_iterator VI_AVX2
587 [(V64QI "TARGET_AVX512BW && TARGET_EVEX512") (V32QI "TARGET_AVX2") V16QI
588 (V32HI "TARGET_AVX512BW && TARGET_EVEX512") (V16HI "TARGET_AVX2") V8HI
589 (V16SI "TARGET_AVX512F && TARGET_EVEX512") (V8SI "TARGET_AVX2") V4SI
590 (V8DI "TARGET_AVX512F && TARGET_EVEX512") (V4DI "TARGET_AVX2") V2DI])
591
592 (define_mode_iterator VI_AVX_AVX512F
593 [(V64QI "TARGET_AVX512F && TARGET_EVEX512") (V32QI "TARGET_AVX") V16QI
594 (V32HI "TARGET_AVX512F && TARGET_EVEX512") (V16HI "TARGET_AVX") V8HI
595 (V16SI "TARGET_AVX512F && TARGET_EVEX512") (V8SI "TARGET_AVX") V4SI
596 (V8DI "TARGET_AVX512F && TARGET_EVEX512") (V4DI "TARGET_AVX") V2DI])
597
598 ;; All QImode vector integer modes
599 (define_mode_iterator VI1
600 [(V32QI "TARGET_AVX") V16QI])
601
602 ;; All DImode vector integer modes
603 (define_mode_iterator V_AVX
604 [V16QI V8HI V4SI V2DI V1TI V4SF V2DF
605 (V32QI "TARGET_AVX") (V16HI "TARGET_AVX")
606 (V8SI "TARGET_AVX") (V4DI "TARGET_AVX") (V2TI "TARGET_AVX")
607 (V8SF "TARGET_AVX") (V4DF"TARGET_AVX")])
608
609 (define_mode_iterator VI48_AVX
610 [V4SI V2DI
611 (V8SI "TARGET_AVX") (V4DI "TARGET_AVX")])
612
613 (define_mode_iterator VI8
614 [(V8DI "TARGET_AVX512F && TARGET_EVEX512") (V4DI "TARGET_AVX") V2DI])
615
616 (define_mode_iterator VI8_AVX10_2
617 [(V8DI "TARGET_AVX10_2") V4DI V2DI])
618
619 (define_mode_iterator VI8_FVL
620 [(V8DI "TARGET_AVX512F && TARGET_EVEX512") V4DI (V2DI "TARGET_AVX512VL")])
621
622 (define_mode_iterator VI8_AVX512VL
623 [(V8DI "TARGET_EVEX512") (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
624
625 (define_mode_iterator VI8_256_512
626 [(V8DI "TARGET_EVEX512") (V4DI "TARGET_AVX512VL")])
627
628 (define_mode_iterator VI1_AVX2
629 [(V32QI "TARGET_AVX2") V16QI])
630
631 (define_mode_iterator VI1_AVX512
632 [(V64QI "TARGET_AVX512BW && TARGET_EVEX512") (V32QI "TARGET_AVX2") V16QI])
633
634 (define_mode_iterator VI1_AVX512F
635 [(V64QI "TARGET_AVX512F && TARGET_EVEX512") (V32QI "TARGET_AVX") V16QI])
636
637 (define_mode_iterator VI1_AVX512VNNI
638 [(V64QI "TARGET_AVX512VNNI && TARGET_EVEX512") (V32QI "TARGET_AVX2") V16QI])
639
640 (define_mode_iterator VI1_AVX512VNNIBW
641 [(V64QI "(TARGET_AVX512BW || TARGET_AVX512VNNI) && TARGET_EVEX512")
642 (V32QI "TARGET_AVX2") V16QI])
643
644 (define_mode_iterator VI12_256_512_AVX512VL
645 [(V64QI "TARGET_EVEX512") (V32QI "TARGET_AVX512VL")
646 (V32HI "TARGET_EVEX512") (V16HI "TARGET_AVX512VL")])
647
648 (define_mode_iterator VI2_AVX2
649 [(V16HI "TARGET_AVX2") V8HI])
650
651 (define_mode_iterator VI2_AVX2_AVX512BW
652 [(V32HI "TARGET_AVX512BW && TARGET_EVEX512") (V16HI "TARGET_AVX2") V8HI])
653
654 (define_mode_iterator VI2_AVX512F
655 [(V32HI "TARGET_AVX512F && TARGET_EVEX512") (V16HI "TARGET_AVX2") V8HI])
656
657 (define_mode_iterator VI2_AVX512VNNIBW
658 [(V32HI "(TARGET_AVX512BW || TARGET_AVX512VNNI) && TARGET_EVEX512")
659 (V16HI "TARGET_AVX2") V8HI])
660
661 (define_mode_iterator VI2_AVX10_2
662 [(V32HI "TARGET_AVX10_2") V16HI V8HI])
663
664 (define_mode_iterator VI4_AVX
665 [(V8SI "TARGET_AVX") V4SI])
666
667 (define_mode_iterator VI4_AVX2
668 [(V8SI "TARGET_AVX2") V4SI])
669
670 (define_mode_iterator VI4_AVX512F
671 [(V16SI "TARGET_AVX512F && TARGET_EVEX512") (V8SI "TARGET_AVX2") V4SI])
672
673 (define_mode_iterator VI4_AVX512VL
674 [(V16SI "TARGET_EVEX512") (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")])
675
676 (define_mode_iterator VI4_AVX10_2
677 [(V16SI "TARGET_AVX10_2") V8SI V4SI])
678
679 (define_mode_iterator VI48_AVX512F_AVX512VL
680 [V4SI V8SI (V16SI "TARGET_AVX512F && TARGET_EVEX512")
681 (V2DI "TARGET_AVX512VL") (V4DI "TARGET_AVX512VL")
682 (V8DI "TARGET_AVX512F && TARGET_EVEX512")])
683
684 (define_mode_iterator VI2_AVX512VL
685 [(V8HI "TARGET_AVX512VL") (V16HI "TARGET_AVX512VL") (V32HI "TARGET_EVEX512")])
686
687 (define_mode_iterator VI2HFBF_AVX512VL
688 [(V8HI "TARGET_AVX512VL") (V16HI "TARGET_AVX512VL") (V32HI "TARGET_EVEX512")
689 (V8HF "TARGET_AVX512VL") (V16HF "TARGET_AVX512VL") (V32HF "TARGET_EVEX512")
690 (V8BF "TARGET_AVX512VL") (V16BF "TARGET_AVX512VL") (V32BF "TARGET_EVEX512")])
691
692 (define_mode_iterator VI2H_AVX512VL
693 [(V8HI "TARGET_AVX512VL") (V16HI "TARGET_AVX512VL") (V32HI "TARGET_EVEX512")
694 (V8SI "TARGET_AVX512VL") (V16SI "TARGET_EVEX512")
695 (V8DI "TARGET_EVEX512")])
696
697 (define_mode_iterator VI1_AVX512VL_F
698 [V32QI (V16QI "TARGET_AVX512VL") (V64QI "TARGET_AVX512F && TARGET_EVEX512")])
699
700 (define_mode_iterator VI8_AVX2_AVX512BW
701 [(V8DI "TARGET_AVX512BW && TARGET_EVEX512") (V4DI "TARGET_AVX2") V2DI])
702
703 (define_mode_iterator VI8_AVX2
704 [(V4DI "TARGET_AVX2") V2DI])
705
706 (define_mode_iterator VI8_AVX2_AVX512F
707 [(V8DI "TARGET_AVX512F && TARGET_EVEX512") (V4DI "TARGET_AVX2") V2DI])
708
709 (define_mode_iterator VI8_AVX_AVX512F
710 [(V8DI "TARGET_AVX512F && TARGET_EVEX512") (V4DI "TARGET_AVX")])
711
712 (define_mode_iterator VI4_128_8_256
713 [V4SI V4DI])
714
715 ;; All V8D* modes
716 (define_mode_iterator V8FI
717 [(V8DF "TARGET_EVEX512") (V8DI "TARGET_EVEX512")])
718
719 ;; All V16S* modes
720 (define_mode_iterator V16FI
721 [(V16SF "TARGET_EVEX512") (V16SI "TARGET_EVEX512")])
722
723 ;; ??? We should probably use TImode instead.
724 (define_mode_iterator VIMAX_AVX2_AVX512BW
725 [(V4TI "TARGET_AVX512BW && TARGET_EVEX512") (V2TI "TARGET_AVX2") V1TI])
726
727 ;; Suppose TARGET_AVX512BW as baseline
728 (define_mode_iterator VIMAX_AVX512VL
729 [(V4TI "TARGET_EVEX512") (V2TI "TARGET_AVX512VL") (V1TI "TARGET_AVX512VL")])
730
731 (define_mode_iterator VIMAX_AVX2
732 [(V2TI "TARGET_AVX2") V1TI])
733
734 (define_mode_iterator VI12_AVX2
735 [(V32QI "TARGET_AVX2") V16QI
736 (V16HI "TARGET_AVX2") V8HI])
737
738 (define_mode_iterator VI12_AVX2_AVX512BW
739 [(V64QI "TARGET_AVX512BW && TARGET_EVEX512") (V32QI "TARGET_AVX2") V16QI
740 (V32HI "TARGET_AVX512BW && TARGET_EVEX512") (V16HI "TARGET_AVX2") V8HI])
741
742 (define_mode_iterator VI24_AVX2
743 [(V16HI "TARGET_AVX2") V8HI
744 (V8SI "TARGET_AVX2") V4SI])
745
746 (define_mode_iterator VI124_AVX2_24_AVX512F_1_AVX512BW
747 [(V64QI "TARGET_AVX512BW && TARGET_EVEX512") (V32QI "TARGET_AVX2") V16QI
748 (V32HI "TARGET_AVX512F && TARGET_EVEX512") (V16HI "TARGET_AVX2") V8HI
749 (V16SI "TARGET_AVX512F && TARGET_EVEX512") (V8SI "TARGET_AVX2") V4SI])
750
751 (define_mode_iterator VI124_AVX2
752 [(V32QI "TARGET_AVX2") V16QI
753 (V16HI "TARGET_AVX2") V8HI
754 (V8SI "TARGET_AVX2") V4SI])
755
756 (define_mode_iterator VI248_AVX512VL
757 [(V32HI "TARGET_EVEX512") (V16SI "TARGET_EVEX512") (V8DI "TARGET_EVEX512")
758 (V16HI "TARGET_AVX512VL") (V8SI "TARGET_AVX512VL")
759 (V4DI "TARGET_AVX512VL") (V8HI "TARGET_AVX512VL")
760 (V4SI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
761
762 (define_mode_iterator VI248_AVX512VLBW
763 [(V32HI "TARGET_AVX512BW && TARGET_EVEX512")
764 (V16HI "TARGET_AVX512VL && TARGET_AVX512BW")
765 (V8HI "TARGET_AVX512VL && TARGET_AVX512BW")
766 (V16SI "TARGET_EVEX512") (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
767 (V8DI "TARGET_EVEX512") (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
768
769 (define_mode_iterator VI48_AVX2
770 [(V8SI "TARGET_AVX2") V4SI
771 (V4DI "TARGET_AVX2") V2DI])
772
773 (define_mode_iterator VI248_AVX2
774 [(V16HI "TARGET_AVX2") V8HI
775 (V8SI "TARGET_AVX2") V4SI
776 (V4DI "TARGET_AVX2") V2DI])
777
778 (define_mode_iterator VI248_AVX2_8_AVX512F_24_AVX512BW
779 [(V32HI "TARGET_AVX512BW && TARGET_EVEX512") (V16HI "TARGET_AVX2") V8HI
780 (V16SI "TARGET_AVX512BW && TARGET_EVEX512") (V8SI "TARGET_AVX2") V4SI
781 (V8DI "TARGET_AVX512F && TARGET_EVEX512") (V4DI "TARGET_AVX2") V2DI])
782
783 (define_mode_iterator VI248_AVX512BW
784 [(V32HI "TARGET_AVX512BW && TARGET_EVEX512") (V16SI "TARGET_EVEX512")
785 (V8DI "TARGET_EVEX512")])
786
787 (define_mode_iterator VI248_AVX512BW_AVX512VL
788 [(V32HI "TARGET_AVX512BW && TARGET_EVEX512")
789 (V4DI "TARGET_AVX512VL") (V16SI "TARGET_EVEX512") (V8DI "TARGET_EVEX512")])
790
791 ;; Suppose TARGET_AVX512VL as baseline
792 (define_mode_iterator VI248_AVX512BW_1
793 [(V16HI "TARGET_AVX512BW") (V8HI "TARGET_AVX512BW")
794 V8SI V4SI
795 V2DI])
796
797 (define_mode_iterator VI248_AVX512BW_2
798 [(V16HI "TARGET_AVX512BW") (V8HI "TARGET_AVX512BW")
799 V8SI V4SI
800 V4DI V2DI])
801
802 (define_mode_iterator VI48_AVX512F
803 [(V16SI "TARGET_AVX512F && TARGET_EVEX512") V8SI V4SI
804 (V8DI "TARGET_AVX512F && TARGET_EVEX512") V4DI V2DI])
805
806 (define_mode_iterator VI48_AVX_AVX512F
807 [(V16SI "TARGET_AVX512F && TARGET_EVEX512") (V8SI "TARGET_AVX") V4SI
808 (V8DI "TARGET_AVX512F && TARGET_EVEX512") (V4DI "TARGET_AVX") V2DI])
809
810 (define_mode_iterator VI12_AVX_AVX512F
811 [(V64QI "TARGET_AVX512F && TARGET_EVEX512") (V32QI "TARGET_AVX") V16QI
812 (V32HI "TARGET_AVX512F && TARGET_EVEX512") (V16HI "TARGET_AVX") V8HI])
813
814 (define_mode_iterator V48_128_256
815 [V4SF V2DF
816 V4DI V2DI
817 V8SF V4DF
818 V8SI V4SI])
819
820
821 (define_mode_iterator VF4_128_8_256
822 [V4DF V4SF])
823
824 (define_mode_attr avx512
825 [(V16QI "avx512vl") (V32QI "avx512vl") (V64QI "avx512bw")
826 (V8HI "avx512vl") (V16HI "avx512vl") (V32HI "avx512bw")
827 (V4SI "avx512vl") (V8SI "avx512vl") (V16SI "avx512f")
828 (V2DI "avx512vl") (V4DI "avx512vl") (V8DI "avx512f")
829 (V8HF "avx512fp16") (V16HF "avx512vl") (V32HF "avx512bw")
830 (V8BF "avx512vl") (V16BF "avx512vl") (V32BF "avx512bw")
831 (V4SF "avx512vl") (V8SF "avx512vl") (V16SF "avx512f")
832 (V2DF "avx512vl") (V4DF "avx512vl") (V8DF "avx512f")])
833
834 (define_mode_attr v_Yw
835 [(V16QI "Yw") (V32QI "Yw") (V64QI "v")
836 (V8HI "Yw") (V16HI "Yw") (V32HI "v")
837 (V4SI "v") (V8SI "v") (V16SI "v")
838 (V2DI "v") (V4DI "v") (V8DI "v")
839 (V4SF "v") (V8SF "v") (V16SF "v")
840 (V2DF "v") (V4DF "v") (V8DF "v")
841 (TI "Yw") (V1TI "Yw") (V2TI "Yw") (V4TI "v")])
842
843 (define_mode_attr sse2_avx_avx512f
844 [(V16QI "sse2") (V32QI "avx") (V64QI "avx512f")
845 (V8HI "avx512vl") (V16HI "avx512vl") (V32HI "avx512bw")
846 (V4SI "sse2") (V8SI "avx") (V16SI "avx512f")
847 (V2DI "avx512vl") (V4DI "avx512vl") (V8DI "avx512f")
848 (V16SF "avx512f") (V8SF "avx") (V4SF "avx")
849 (V8DF "avx512f") (V4DF "avx") (V2DF "avx")])
850
851 (define_mode_attr sse2_avx2
852 [(V16QI "sse2") (V32QI "avx2") (V64QI "avx512bw")
853 (V8HI "sse2") (V16HI "avx2") (V32HI "avx512bw")
854 (V4SI "sse2") (V8SI "avx2") (V16SI "avx512f")
855 (V2DI "sse2") (V4DI "avx2") (V8DI "avx512f")
856 (V1TI "sse2") (V2TI "avx2") (V4TI "avx512bw")])
857
858 (define_mode_attr ssse3_avx2
859 [(V16QI "ssse3") (V32QI "avx2") (V64QI "avx512bw")
860 (V4HI "ssse3") (V8HI "ssse3") (V16HI "avx2") (V32HI "avx512bw")
861 (V4SI "ssse3") (V8SI "avx2")
862 (V2DI "ssse3") (V4DI "avx2")
863 (V1TI "ssse3") (V2TI "avx2") (V4TI "avx512bw")])
864
865 (define_mode_attr sse4_1_avx2
866 [(V16QI "sse4_1") (V32QI "avx2") (V64QI "avx512bw")
867 (V8HI "sse4_1") (V16HI "avx2") (V32HI "avx512bw")
868 (V4SI "sse4_1") (V8SI "avx2") (V16SI "avx512f")
869 (V2DI "sse4_1") (V4DI "avx2") (V8DI "avx512dq")])
870
871 (define_mode_attr avx_avx2
872 [(V4SF "avx") (V2DF "avx")
873 (V8SF "avx") (V4DF "avx")
874 (V4SI "avx2") (V2DI "avx2")
875 (V8SI "avx2") (V4DI "avx2")])
876
877 (define_mode_attr vec_avx2
878 [(V16QI "vec") (V32QI "avx2")
879 (V8HI "vec") (V16HI "avx2")
880 (V4SI "vec") (V8SI "avx2")
881 (V2DI "vec") (V4DI "avx2")])
882
883 (define_mode_attr avx2_avx512
884 [(V4SI "avx2") (V8SI "avx2") (V16SI "avx512f")
885 (V2DI "avx2") (V4DI "avx2") (V8DI "avx512f")
886 (V4SF "avx2") (V8SF "avx2") (V16SF "avx512f")
887 (V2DF "avx2") (V4DF "avx2") (V8DF "avx512f")
888 (V8HI "avx512vl") (V16HI "avx512vl") (V32HI "avx512bw")])
889
890 (define_mode_attr shuffletype
891 [(V32HF "i") (V16HF "i") (V8HF "i")
892 (V32BF "i") (V16BF "i") (V8BF "i")
893 (V16SF "f") (V16SI "i") (V8DF "f") (V8DI "i")
894 (V8SF "f") (V8SI "i") (V4DF "f") (V4DI "i")
895 (V4SF "f") (V4SI "i") (V2DF "f") (V2DI "i")
896 (V32HI "i") (V16HI "i") (V8HI "i")
897 (V64QI "i") (V32QI "i") (V16QI "i")
898 (V4TI "i") (V2TI "i") (V1TI "i")])
899
900 (define_mode_attr ssequartermode
901 [(V16SF "V4SF") (V8DF "V2DF") (V16SI "V4SI") (V8DI "V2DI")])
902
903 (define_mode_attr ssequarterinsnmode
904 [(V16SF "V4SF") (V8DF "V2DF") (V16SI "TI") (V8DI "TI")])
905
906 (define_mode_attr vecmemsuffix
907 [(V32HF "{z}") (V16HF "{y}") (V8HF "{x}")
908 (V32BF "{z}") (V16BF "{y}") (V8BF "{x}")
909 (V16SF "{z}") (V8SF "{y}") (V4SF "{x}")
910 (V8DF "{z}") (V4DF "{y}") (V2DF "{x}")])
911
912 (define_mode_attr ssedoublemodelower
913 [(V16QI "v16hi") (V32QI "v32hi") (V64QI "v64hi")
914 (V8HI "v8si") (V16HI "v16si") (V32HI "v32si")
915 (V4SI "v4di") (V8SI "v8di") (V16SI "v16di")])
916
917 ;; Map vector mode to the same number of double sized elements.
918 (define_mode_attr ssedoublemode
919 [(V4SF "V4DF") (V8SF "V8DF") (V16SF "V16DF")
920 (V16QI "V16HI") (V32QI "V32HI") (V64QI "V64HI")
921 (V8HI "V8SI") (V16HI "V16SI") (V32HI "V32SI")
922 (V4SI "V4DI") (V8SI "V8DI") (V16SI "V16DI")])
923
924 (define_mode_attr ssebytemode
925 [(V8DI "V64QI") (V4DI "V32QI") (V2DI "V16QI")
926 (V16SI "V64QI") (V8SI "V32QI") (V4SI "V16QI")
927 (V8HI "V16QI")])
928
929 (define_mode_attr sseintconvert
930 [(V32HI "w") (V16HI "w") (V8HI "w")
931 (V16SI "dq") (V8SI "dq") (V4SI "dq")
932 (V8DI "qq") (V4DI "qq") (V2DI "qq")])
933
934 ;; All 128bit vector integer modes
935 (define_mode_iterator VI_128 [V16QI V8HI V4SI V2DI])
936
937 ;; All 256bit vector integer modes
938 (define_mode_iterator VI_256 [V32QI V16HI V8SI V4DI])
939
940 ;; All 128 and 256bit vector integer modes
941 (define_mode_iterator VI_128_256 [V16QI V8HI V4SI V2DI V32QI V16HI V8SI V4DI])
942 ;; All 256bit vector integer and HF modes
943 (define_mode_iterator VIHFBF_256 [V32QI V16HI V8SI V4DI V16HF V16BF])
944
945 ;; Various 128bit vector integer mode combinations
946 (define_mode_iterator VI12_128 [V16QI V8HI])
947 (define_mode_iterator VI14_128 [V16QI V4SI])
948 (define_mode_iterator VI124_128 [V16QI V8HI V4SI])
949 (define_mode_iterator VI24_128 [V8HI V4SI])
950 (define_mode_iterator VI248_128 [V8HI V4SI V2DI])
951 (define_mode_iterator VI248_256 [V16HI V8SI V4DI])
952 (define_mode_iterator VI248_512
953 [(V32HI "TARGET_EVEX512") (V16SI "TARGET_EVEX512") (V8DI "TARGET_EVEX512")])
954 (define_mode_iterator VI48_128 [V4SI V2DI])
955 (define_mode_iterator VI148_512
956 [(V64QI "TARGET_EVEX512") (V16SI "TARGET_EVEX512") (V8DI "TARGET_EVEX512")])
957 (define_mode_iterator VI148_256 [V32QI V8SI V4DI])
958 (define_mode_iterator VI148_128 [V16QI V4SI V2DI])
959
960 ;; Various 256bit and 512 vector integer mode combinations
961 (define_mode_iterator VI124_256 [V32QI V16HI V8SI])
962 (define_mode_iterator VI124_256_AVX512F_AVX512BW
963 [V32QI V16HI V8SI
964 (V64QI "TARGET_AVX512BW && TARGET_EVEX512")
965 (V32HI "TARGET_AVX512BW && TARGET_EVEX512")
966 (V16SI "TARGET_AVX512F && TARGET_EVEX512")])
967 (define_mode_iterator VI48_256 [V8SI V4DI])
968 (define_mode_iterator VI48_512
969 [(V16SI "TARGET_EVEX512") (V8DI "TARGET_EVEX512")])
970 (define_mode_iterator VI4_256_8_512 [V8SI V8DI])
971 (define_mode_iterator VI_AVX512BW
972 [(V16SI "TARGET_EVEX512") (V8DI "TARGET_EVEX512")
973 (V32HI "TARGET_AVX512BW && TARGET_EVEX512")
974 (V64QI "TARGET_AVX512BW && TARGET_EVEX512")])
975 (define_mode_iterator VIHFBF_AVX512BW
976 [(V16SI "TARGET_EVEX512") (V8DI "TARGET_EVEX512")
977 (V32HI "TARGET_AVX512BW && TARGET_EVEX512")
978 (V64QI "TARGET_AVX512BW && TARGET_EVEX512")
979 (V32HF "TARGET_AVX512BW && TARGET_EVEX512")
980 (V32BF "TARGET_AVX512BW && TARGET_EVEX512")])
981
982 ;; Int-float size matches
983 (define_mode_iterator VI2F_256_512
984 [V16HI (V32HI "TARGET_EVEX512")
985 V16HF (V32HF "TARGET_EVEX512")
986 V16BF (V32BF "TARGET_EVEX512")])
987 (define_mode_iterator VI4F_128 [V4SI V4SF])
988 (define_mode_iterator VI8F_128 [V2DI V2DF])
989 (define_mode_iterator VI4F_256 [V8SI V8SF])
990 (define_mode_iterator VI8F_256 [V4DI V4DF])
991 (define_mode_iterator VI4F_256_512
992 [V8SI V8SF
993 (V16SI "TARGET_AVX512F && TARGET_EVEX512")
994 (V16SF "TARGET_AVX512F && TARGET_EVEX512")])
995 (define_mode_iterator VI48F_256_512
996 [V8SI V8SF
997 (V16SI "TARGET_AVX512F && TARGET_EVEX512")
998 (V16SF "TARGET_AVX512F && TARGET_EVEX512")
999 (V8DI "TARGET_AVX512F && TARGET_EVEX512")
1000 (V8DF "TARGET_AVX512F && TARGET_EVEX512")
1001 (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")])
1002 (define_mode_iterator VF48H_AVX512VL
1003 [(V8DF "TARGET_EVEX512") (V16SF "TARGET_EVEX512") (V8SF "TARGET_AVX512VL")])
1004
1005 (define_mode_iterator VF48_128
1006 [V2DF V4SF])
1007
1008 (define_mode_iterator VI48F
1009 [(V16SI "TARGET_EVEX512") (V16SF "TARGET_EVEX512")
1010 (V8DI "TARGET_EVEX512") (V8DF "TARGET_EVEX512")
1011 (V8SI "TARGET_AVX512VL") (V8SF "TARGET_AVX512VL")
1012 (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")
1013 (V4SI "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
1014 (V2DI "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
1015 (define_mode_iterator VI12_VI48F_AVX512VL
1016 [(V16SI "TARGET_AVX512F && TARGET_EVEX512")
1017 (V16SF "TARGET_AVX512F && TARGET_EVEX512")
1018 (V8DI "TARGET_AVX512F && TARGET_EVEX512")
1019 (V8DF "TARGET_AVX512F && TARGET_EVEX512")
1020 (V8SI "TARGET_AVX512VL") (V8SF "TARGET_AVX512VL")
1021 (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")
1022 (V4SI "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
1023 (V2DI "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")
1024 (V64QI "TARGET_EVEX512") (V16QI "TARGET_AVX512VL") (V32QI "TARGET_AVX512VL")
1025 (V32HI "TARGET_EVEX512") (V16HI "TARGET_AVX512VL") (V8HI "TARGET_AVX512VL")])
1026
1027 (define_mode_iterator VI48F_256 [V8SI V8SF V4DI V4DF])
1028
1029 (define_mode_iterator V8_128 [V8HI V8HF V8BF])
1030 (define_mode_iterator V16_256 [V16HI V16HF V16BF])
1031 (define_mode_iterator V32_512
1032 [(V32HI "TARGET_EVEX512") (V32HF "TARGET_EVEX512") (V32BF "TARGET_EVEX512")])
1033
1034 ;; Mapping from float mode to required SSE level
1035 (define_mode_attr sse
1036 [(SF "sse") (DF "sse2") (HF "avx512fp16")
1037 (V4SF "sse") (V2DF "sse2")
1038 (V32BF "avx512bf16") (V16BF "avx512bf16")
1039 (V8BF "avx512bf16")
1040 (V32HF "avx512fp16") (V16HF "avx512fp16")
1041 (V8HF "avx512fp16")
1042 (V16SF "avx512f") (V8SF "avx")
1043 (V8DF "avx512f") (V4DF "avx")])
1044
1045 (define_mode_attr sse2
1046 [(V16QI "sse2") (V32QI "avx") (V64QI "avx512f")
1047 (V2DI "sse2") (V4DI "avx") (V8DI "avx512f")])
1048
1049 (define_mode_attr sse3
1050 [(V16QI "sse3") (V32QI "avx")])
1051
1052 (define_mode_attr sse4_1
1053 [(V4SF "sse4_1") (V2DF "sse4_1")
1054 (V8SF "avx") (V4DF "avx")
1055 (V8DF "avx512f")
1056 (V2TI "avx") (V1TI "sse4_1")
1057 (V4DI "avx") (V2DI "sse4_1")
1058 (V8SI "avx") (V4SI "sse4_1")
1059 (V16QI "sse4_1") (V32QI "avx")
1060 (V8HI "sse4_1") (V16HI "avx")])
1061
1062 (define_mode_attr avxsizesuffix
1063 [(V64QI "512") (V32HI "512") (V16SI "512") (V8DI "512") (V4TI "512")
1064 (V32QI "256") (V16HI "256") (V8SI "256") (V4DI "256") (V2TI "256")
1065 (V16QI "") (V8HI "") (V4SI "") (V2DI "") (V1TI "")
1066 (V32HF "512") (V16SF "512") (V8DF "512")
1067 (V16HF "256") (V8SF "256") (V4DF "256")
1068 (V8HF "") (V4SF "") (V2DF "")])
1069
1070 ;; SSE instruction mode
1071 (define_mode_attr sseinsnmode
1072 [(V64QI "XI") (V32HI "XI") (V16SI "XI") (V8DI "XI") (V4TI "XI")
1073 (V32QI "OI") (V16HI "OI") (V8SI "OI") (V4DI "OI") (V2TI "OI")
1074 (V16QI "TI") (V8HI "TI") (V4SI "TI") (V2DI "TI") (V1TI "TI")
1075 (V16SF "V16SF") (V8DF "V8DF")
1076 (V8SF "V8SF") (V4DF "V4DF")
1077 (V4SF "V4SF") (V2DF "V2DF")
1078 (V8HF "TI") (V16HF "OI") (V32HF "XI")
1079 (V8BF "TI") (V16BF "OI") (V32BF "XI")
1080 (TI "TI")])
1081
1082 (define_mode_attr sseintvecinsnmode
1083 [(V64QI "XI") (V32HI "XI") (V16SI "XI") (V8DI "XI") (V4TI "XI")
1084 (V32QI "OI") (V16HI "OI") (V8SI "OI") (V4DI "OI") (V2TI "OI")
1085 (V16QI "TI") (V8HI "TI") (V4SI "TI") (V2DI "TI") (V1TI "TI")
1086 (V16SF "XI") (V8DF "XI")
1087 (V8SF "OI") (V4DF "OI")
1088 (V4SF "TI") (V2DF "TI")
1089 (TI "TI")])
1090
1091 ;; SSE constant -1 constraint
1092 (define_mode_attr sseconstm1
1093 [(V64QI "BC") (V32HI "BC") (V16SI "BC") (V8DI "BC") (V4TI "BC")
1094 (V32QI "BC") (V16HI "BC") (V8SI "BC") (V4DI "BC") (V2TI "BC")
1095 (V16QI "BC") (V8HI "BC") (V4SI "BC") (V2DI "BC") (V1TI "BC")
1096 (V32HF "BF") (V32BF "BF") (V16SF "BF") (V8DF "BF")
1097 (V16HF "BF") (V16BF "BF") (V8SF "BF") (V4DF "BF")
1098 (V8HF "BF") (V8BF "BF") (V4SF "BF") (V2DF "BF")])
1099
1100 ;; SSE integer instruction suffix for various modes
1101 (define_mode_attr sseintmodesuffix
1102 [(V16QI "b") (V8HI "w") (V4SI "d") (V2DI "q")
1103 (V32QI "b") (V16HI "w") (V8SI "d") (V4DI "q")
1104 (V64QI "b") (V32HI "w") (V16SI "d") (V8DI "q")
1105 (V8HF "w") (V16HF "w") (V32HF "w")
1106 (V8BF "w") (V16BF "w") (V32BF "w")])
1107
1108 ;; Mapping of vector modes to corresponding mask size
1109 (define_mode_attr avx512fmaskmode
1110 [(V64QI "DI") (V32QI "SI") (V16QI "HI")
1111 (V32HI "SI") (V16HI "HI") (V8HI "QI") (V4HI "QI")
1112 (V16SI "HI") (V8SI "QI") (V4SI "QI")
1113 (V8DI "QI") (V4DI "QI") (V2DI "QI")
1114 (V32HF "SI") (V16HF "HI") (V8HF "QI")
1115 (V32BF "SI") (V16BF "HI") (V8BF "QI")
1116 (V16SF "HI") (V8SF "QI") (V4SF "QI")
1117 (V8DF "QI") (V4DF "QI") (V2DF "QI")])
1118
1119 ;; Mapping of vector modes to corresponding complex mask size
1120 (define_mode_attr avx512fmaskcmode
1121 [(V32HF "HI") (V16HF "QI") (V8HF "QI")])
1122
1123 ;; Mapping of vector modes to corresponding mask size
1124 (define_mode_attr avx512fmaskmodelower
1125 [(V64QI "di") (V32QI "si") (V16QI "hi")
1126 (V32HI "si") (V16HI "hi") (V8HI "qi") (V4HI "qi")
1127 (V16SI "hi") (V8SI "qi") (V4SI "qi")
1128 (V8DI "qi") (V4DI "qi") (V2DI "qi")
1129 (V32HF "si") (V16HF "hi") (V8HF "qi")
1130 (V32BF "si") (V16BF "hi") (V8BF "qi")
1131 (V16SF "hi") (V8SF "qi") (V4SF "qi")
1132 (V8DF "qi") (V4DF "qi") (V2DF "qi")])
1133
1134 ;; Mapping of vector modes to corresponding mask half size
1135 (define_mode_attr avx512fmaskhalfmode
1136 [(V64QI "SI") (V32QI "HI") (V16QI "QI")
1137 (V32HI "HI") (V16HI "QI") (V8HI "QI") (V4HI "QI")
1138 (V16SI "QI") (V8SI "QI") (V4SI "QI")
1139 (V8DI "QI") (V4DI "QI") (V2DI "QI")
1140 (V32HF "HI") (V16HF "QI") (V8HF "QI")
1141 (V32BF "HI") (V16BF "QI") (V8BF "QI")
1142 (V16SF "QI") (V8SF "QI") (V4SF "QI")
1143 (V8DF "QI") (V4DF "QI") (V2DF "QI")])
1144
1145 ;; Mapping of vector float modes to an integer mode of the same size
1146 (define_mode_attr sseintvecmode
1147 [(V32HF "V32HI") (V32BF "V32HI") (V16SF "V16SI") (V8DF "V8DI")
1148 (V16HF "V16HI") (V16BF "V16HI") (V8SF "V8SI") (V4DF "V4DI")
1149 (V8HF "V8HI") (V8BF "V8HI") (V4SF "V4SI") (V2DF "V2DI")
1150 (V16SI "V16SI") (V8DI "V8DI")
1151 (V8SI "V8SI") (V4DI "V4DI")
1152 (V4SI "V4SI") (V2DI "V2DI")
1153 (V16HI "V16HI") (V8HI "V8HI")
1154 (V32HI "V32HI") (V64QI "V64QI")
1155 (V32QI "V32QI") (V16QI "V16QI")])
1156
1157 ;; Mapping of vector modes to an V*HImode of the same size
1158 (define_mode_attr ssewvecmode
1159 [(V8DI "V32HI") (V4DI "V16HI") (V2DI "V8HI")
1160 (V16SI "V32HI") (V8SI "V16HI") (V4SI "V8HI")])
1161
1162 (define_mode_attr ssewvecmodelower
1163 [(V8DI "v32hi") (V4DI "v16hi") (V2DI "v8hi")
1164 (V16SI "v32hi") (V8SI "v16hi") (V4SI "v8hi")])
1165
1166 (define_mode_attr sseintvecmode2
1167 [(V8DF "XI") (V4DF "OI") (V2DF "TI")
1168 (V8SF "OI") (V4SF "TI")
1169 (V16HF "OI") (V8HF "TI")
1170 (V16BF "OI") (V8BF "TI")])
1171
1172 (define_mode_attr sseintvecmodelower
1173 [(V32HF "v32hi") (V32BF "v32hi") (V16SF "v16si") (V8DF "v8di")
1174 (V16HF "v16hi") (V16BF "v16hi") (V8SF "v8si") (V4DF "v4di")
1175 (V8HF "v8hi") (V8BF "v8hi") (V4SF "v4si") (V2DF "v2di")
1176 (V8SI "v8si") (V4DI "v4di")
1177 (V4SI "v4si") (V2DI "v2di")
1178 (V16HI "v16hi") (V8HI "v8hi")
1179 (V32QI "v32qi") (V16QI "v16qi")])
1180
1181 ;; Mapping of vector modes to an V*SImode of the same size
1182 (define_mode_attr ssedvecmode
1183 [(V64QI "V16SI") (V32QI "V8SI") (V16QI "V4SI")])
1184
1185 (define_mode_attr ssedvecmodelower
1186 [(V64QI "v16si") (V32QI "v8si") (V16QI "v4si")])
1187
1188 ;; Mapping of vector modes to a vector mode of double size
1189 (define_mode_attr ssedoublevecmode
1190 [(V64QI "V128QI") (V32HI "V64HI") (V16SI "V32SI") (V8DI "V16DI")
1191 (V32QI "V64QI") (V16HI "V32HI") (V8SI "V16SI") (V4DI "V8DI")
1192 (V16QI "V32QI") (V8HI "V16HI") (V4SI "V8SI") (V2DI "V4DI")
1193 (V16SF "V32SF") (V8DF "V16DF")
1194 (V8SF "V16SF") (V4DF "V8DF")
1195 (V4SF "V8SF") (V2DF "V4DF")
1196 (V32HF "V64HF") (V16HF "V32HF") (V8HF "V16HF")
1197 (V32BF "V64BF") (V16BF "V32BF") (V8BF "V16BF")])
1198
1199 ;; Mapping of vector modes to a vector mode of half size
1200 ;; instead of V1DI/V1DF, DI/DF are used for V2DI/V2DF although they are scalar.
1201 (define_mode_attr ssehalfvecmode
1202 [(V64QI "V32QI") (V32HI "V16HI") (V16SI "V8SI") (V8DI "V4DI") (V4TI "V2TI")
1203 (V32QI "V16QI") (V16HI "V8HI") (V8SI "V4SI") (V4DI "V2DI")
1204 (V16QI "V8QI") (V8HI "V4HI") (V4SI "V2SI") (V2DI "DI")
1205 (V16SF "V8SF") (V8DF "V4DF")
1206 (V8SF "V4SF") (V4DF "V2DF")
1207 (V4SF "V2SF") (V2DF "DF")
1208 (V32HF "V16HF") (V16HF "V8HF") (V8HF "V4HF")
1209 (V32BF "V16BF") (V16BF "V8BF") (V8BF "V4BF")])
1210
1211 (define_mode_attr ssehalfvecmodelower
1212 [(V64QI "v32qi") (V32HI "v16hi") (V16SI "v8si") (V8DI "v4di") (V4TI "v2ti")
1213 (V32QI "v16qi") (V16HI "v8hi") (V8SI "v4si") (V4DI "v2di")
1214 (V16QI "v8qi") (V8HI "v4hi") (V4SI "v2si")
1215 (V16SF "v8sf") (V8DF "v4df")
1216 (V8SF "v4sf") (V4DF "v2df")
1217 (V4SF "v2sf")
1218 (V32HF "v16hf") (V16HF "v8hf") (V8HF "v4hf")
1219 (V32BF "v16bf") (V16BF "v8bf") (V8BF "v4bf")])
1220
1221 ;; Mapping of vector modes to vector hf modes of conversion.
1222 (define_mode_attr ssePHmode
1223 [(V32HI "V32HF") (V16HI "V16HF") (V8HI "V8HF")
1224 (V16SI "V16HF") (V8SI "V8HF") (V4SI "V8HF")
1225 (V8DI "V8HF") (V4DI "V8HF") (V2DI "V8HF")
1226 (V8DF "V8HF") (V16SF "V16HF") (V8SF "V8HF")])
1227
1228 ;; Mapping of vector modes to vector hf modes of same element.
1229 (define_mode_attr ssePHmodelower
1230 [(V32HI "v32hf") (V16HI "v16hf") (V8HI "v8hf")
1231 (V16SI "v16hf") (V8SI "v8hf") (V4SI "v4hf")
1232 (V8DI "v8hf") (V4DI "v4hf") (V2DI "v2hf")
1233 (V8DF "v8hf") (V16SF "v16hf") (V8SF "v8hf")])
1234
1235
1236 ;; Mapping of vector modes to packed vector hf modes of same sized.
1237 (define_mode_attr ssepackPHmode
1238 [(V16SI "V32HF") (V8SI "V16HF") (V4SI "V8HF")
1239 (V16SF "V32HF") (V8SF "V16HF") (V4SF "V8HF")])
1240
1241 ;; Mapping of vector modes to packed single mode of the same size
1242 (define_mode_attr ssePSmode
1243 [(V16SI "V16SF") (V8DF "V16SF")
1244 (V16SF "V16SF") (V8DI "V16SF")
1245 (V64QI "V16SF") (V32QI "V8SF") (V16QI "V4SF")
1246 (V32HI "V16SF") (V16HI "V8SF") (V8HI "V4SF")
1247 (V8SI "V8SF") (V4SI "V4SF")
1248 (V4DI "V8SF") (V2DI "V4SF")
1249 (V4TI "V16SF") (V2TI "V8SF") (V1TI "V4SF")
1250 (V8SF "V8SF") (V4SF "V4SF")
1251 (V4DF "V8SF") (V2DF "V4SF")
1252 (V32HF "V16SF") (V16HF "V8SF") (V8HF "V4SF")])
1253
1254 (define_mode_attr ssePSmodelower
1255 [(V16SI "v16sf") (V8DF "v16sf")
1256 (V16SF "v16sf") (V8DI "v16sf")
1257 (V64QI "v16sf") (V32QI "v8sf") (V16QI "v4sf")
1258 (V32HI "v16sf") (V16HI "v8sf") (V8HI "v4sf")
1259 (V8SI "v8sf") (V4SI "v4sf")
1260 (V4DI "v8sf") (V2DI "v4sf")
1261 (V4TI "v16sf") (V2TI "v8sf") (V1TI "v4sf")
1262 (V8SF "v8sf") (V4SF "v4sf")
1263 (V4DF "v8sf") (V2DF "v4sf")
1264 (V32HF "v16sf") (V16HF "v8sf") (V8HF "v4sf")])
1265
1266 (define_mode_attr ssePSmode2
1267 [(V8DI "V8SF") (V4DI "V4SF")])
1268
1269 (define_mode_attr ssePSmode2lower
1270 [(V8DI "v8sf") (V4DI "v4sf")])
1271
1272 ;; Mapping of vector modes back to the scalar modes
1273 (define_mode_attr ssescalarmode
1274 [(V64QI "QI") (V32QI "QI") (V16QI "QI")
1275 (V32HI "HI") (V16HI "HI") (V8HI "HI")
1276 (V16SI "SI") (V8SI "SI") (V4SI "SI")
1277 (V8DI "DI") (V4DI "DI") (V2DI "DI")
1278 (V32HF "HF") (V16HF "HF") (V8HF "HF")
1279 (V32BF "BF") (V16BF "BF") (V8BF "BF")
1280 (V16SF "SF") (V8SF "SF") (V4SF "SF")
1281 (V8DF "DF") (V4DF "DF") (V2DF "DF")
1282 (V4TI "TI") (V2TI "TI")])
1283
1284 ;; Mapping of vector modes back to the scalar modes
1285 (define_mode_attr ssescalarmodelower
1286 [(V64QI "qi") (V32QI "qi") (V16QI "qi")
1287 (V32HI "hi") (V16HI "hi") (V8HI "hi")
1288 (V16SI "si") (V8SI "si") (V4SI "si")
1289 (V8DI "di") (V4DI "di") (V2DI "di")
1290 (V32HF "hf") (V16HF "hf") (V8HF "hf")
1291 (V32BF "bf") (V16BF "bf") (V8BF "bf")
1292 (V16SF "sf") (V8SF "sf") (V4SF "sf")
1293 (V8DF "df") (V4DF "df") (V2DF "df")
1294 (V4TI "ti") (V2TI "ti")])
1295
1296 ;; Mapping of vector modes to the 128bit modes
1297 (define_mode_attr ssexmmmode
1298 [(V64QI "V16QI") (V32QI "V16QI") (V16QI "V16QI")
1299 (V32HI "V8HI") (V16HI "V8HI") (V8HI "V8HI")
1300 (V16SI "V4SI") (V8SI "V4SI") (V4SI "V4SI")
1301 (V8DI "V2DI") (V4DI "V2DI") (V2DI "V2DI")
1302 (V32HF "V8HF") (V16HF "V8HF") (V8HF "V8HF")
1303 (V32BF "V8BF") (V16BF "V8BF") (V8BF "V8BF")
1304 (V16SF "V4SF") (V8SF "V4SF") (V4SF "V4SF")
1305 (V8DF "V2DF") (V4DF "V2DF") (V2DF "V2DF")])
1306
1307 ;; Pointer size override for scalar modes (Intel asm dialect)
1308 (define_mode_attr iptr
1309 [(V64QI "b") (V32HI "w") (V16SI "k") (V8DI "q")
1310 (V32QI "b") (V16HI "w") (V8SI "k") (V4DI "q")
1311 (V16QI "b") (V8HI "w") (V4SI "k") (V2DI "q")
1312 (V32HF "w") (V32BF "w") (V16SF "k") (V8DF "q")
1313 (V16HF "w") (V16BF "w") (V8SF "k") (V4DF "q")
1314 (V8HF "w") (V8BF "w") (V4SF "k") (V2DF "q")
1315 (HF "w") (BF "w") (SF "k") (DF "q")])
1316
1317 ;; Pointer size override for 16-bit upper-convert modes (Intel asm dialect)
1318 (define_mode_attr iptrh
1319 [(V32HI "") (V16SI "") (V8DI "")
1320 (V16HI "") (V8SI "") (V4DI "q")
1321 (V8HI "") (V4SI "q") (V2DI "k")])
1322
1323 ;; Mapping of vector modes to VPTERNLOG suffix
1324 (define_mode_attr ternlogsuffix
1325 [(V8DI "q") (V4DI "q") (V2DI "q")
1326 (V8DF "q") (V4DF "q") (V2DF "q")
1327 (V16SI "d") (V8SI "d") (V4SI "d")
1328 (V16SF "d") (V8SF "d") (V4SF "d")
1329 (V32HI "d") (V16HI "d") (V8HI "d")
1330 (V32HF "d") (V16HF "d") (V8HF "d")
1331 (V32BF "d") (V16BF "d") (V8BF "d")
1332 (V64QI "d") (V32QI "d") (V16QI "d")])
1333
1334 ;; Number of scalar elements in each vector type
1335 (define_mode_attr ssescalarnum
1336 [(V64QI "64") (V16SI "16") (V8DI "8")
1337 (V32QI "32") (V16HI "16") (V8SI "8") (V4DI "4")
1338 (V16QI "16") (V8HI "8") (V4SI "4") (V2DI "2")
1339 (V16SF "16") (V8DF "8")
1340 (V8SF "8") (V4DF "4")
1341 (V4SF "4") (V2DF "2")])
1342
1343 ;; Mask of scalar elements in each vector type
1344 (define_mode_attr ssescalarnummask
1345 [(V32QI "31") (V16HI "15") (V8SI "7") (V4DI "3")
1346 (V16QI "15") (V8HI "7") (V4SI "3") (V2DI "1")
1347 (V8SF "7") (V4DF "3")
1348 (V4SF "3") (V2DF "1")])
1349
1350 (define_mode_attr ssescalarsize
1351 [(V4TI "64") (V2TI "64") (V1TI "64")
1352 (V8DI "64") (V4DI "64") (V2DI "64")
1353 (V64QI "8") (V32QI "8") (V16QI "8")
1354 (V32HI "16") (V16HI "16") (V8HI "16")
1355 (V16SI "32") (V8SI "32") (V4SI "32")
1356 (V32HF "16") (V16HF "16") (V8HF "16")
1357 (V32BF "16") (V16BF "16") (V8BF "16")
1358 (V16SF "32") (V8SF "32") (V4SF "32")
1359 (V8DF "64") (V4DF "64") (V2DF "64")])
1360
1361 ;; SSE prefix for integer and HF vector modes
1362 (define_mode_attr sseintprefix
1363 [(V2DI "p") (V2DF "")
1364 (V4DI "p") (V4DF "")
1365 (V8DI "p") (V8DF "")
1366 (V4SI "p") (V4SF "")
1367 (V8SI "p") (V8SF "")
1368 (V16SI "p") (V16SF "")
1369 (V16QI "p") (V8HI "p") (V8HF "p") (V8BF "p")
1370 (V32QI "p") (V16HI "p") (V16HF "p") (V16BF "p")
1371 (V64QI "p") (V32HI "p") (V32HF "p") (V32BF "p")])
1372
1373 ;; SSE prefix for integer and HF vector comparison.
1374 (define_mode_attr ssecmpintprefix
1375 [(V2DI "p") (V2DF "")
1376 (V4DI "p") (V4DF "")
1377 (V8DI "p") (V8DF "")
1378 (V4SI "p") (V4SF "")
1379 (V8SI "p") (V8SF "")
1380 (V16SI "p") (V16SF "")
1381 (V16QI "p") (V8HI "p") (V8HF "")
1382 (V32QI "p") (V16HI "p") (V16HF "")
1383 (V64QI "p") (V32HI "p") (V32HF "")])
1384
1385 ;; SSE scalar suffix for vector modes
1386 (define_mode_attr ssescalarmodesuffix
1387 [(HF "sh") (SF "ss") (DF "sd")
1388 (V32HF "sh") (V16SF "ss") (V8DF "sd")
1389 (V16HF "sh") (V8SF "ss") (V4DF "sd")
1390 (V8HF "sh") (V4SF "ss") (V2DF "sd")
1391 (V16SI "d") (V8DI "q")
1392 (V8SI "d") (V4DI "q")
1393 (V4SI "d") (V2DI "q")])
1394
1395 ;; Pack/unpack vector modes
1396 (define_mode_attr sseunpackmode
1397 [(V16QI "V8HI") (V8HI "V4SI") (V4SI "V2DI")
1398 (V32QI "V16HI") (V16HI "V8SI") (V8SI "V4DI")
1399 (V32HI "V16SI") (V64QI "V32HI") (V16SI "V8DI")])
1400
1401 (define_mode_attr sseunpackmodelower
1402 [(V16QI "v8hi") (V8HI "v4si") (V4SI "v2di")
1403 (V32QI "v16hi") (V16HI "v8si") (V8SI "v4di")
1404 (V32HI "v16si") (V64QI "v32hi") (V16SI "v8di")])
1405
1406 (define_mode_attr ssepackmode
1407 [(V8HI "V16QI") (V4SI "V8HI") (V2DI "V4SI")
1408 (V16HI "V32QI") (V8SI "V16HI") (V4DI "V8SI")
1409 (V32HI "V64QI") (V16SI "V32HI") (V8DI "V16SI")])
1410
1411 (define_mode_attr ssepackmodelower
1412 [(V8HI "v16qi") (V4SI "v8hi") (V2DI "v4si")
1413 (V16HI "v32qi") (V8SI "v16hi") (V4DI "v8si")
1414 (V32HI "v64qi") (V16SI "v32hi") (V8DI "v16si")])
1415
1416 ;; Mapping of the max integer size for xop rotate immediate constraint
1417 (define_mode_attr sserotatemax
1418 [(V16QI "7") (V8HI "15") (V4SI "31") (V2DI "63")])
1419
1420 ;; Mapping of mode to cast intrinsic name
1421 (define_mode_attr castmode
1422 [(V4SF "ps") (V2DF "pd")
1423 (V8SI "si") (V8SF "ps") (V4DF "pd")
1424 (V16SI "si") (V16SF "ps") (V8DF "pd")])
1425
1426 ;; i128 for integer vectors and TARGET_AVX2, f128 otherwise.
1427 ;; i64x4 or f64x4 for 512bit modes.
1428 (define_mode_attr i128
1429 [(V16HF "%~128") (V32HF "i64x4") (V16BF "%~128") (V32BF "i64x4")
1430 (V16SF "f64x4") (V8SF "f128")
1431 (V8DF "f64x4") (V4DF "f128")
1432 (V64QI "i64x4") (V32QI "%~128") (V32HI "i64x4") (V16HI "%~128")
1433 (V16SI "i64x4") (V8SI "%~128") (V8DI "i64x4") (V4DI "%~128")])
1434
1435 ;; For 256-bit modes for TARGET_AVX512VL && TARGET_AVX512DQ
1436 ;; i32x4, f32x4, i64x2 or f64x2 suffixes.
1437 (define_mode_attr i128vldq
1438 [(V16HF "i32x4") (V16BF "i32x4") (V8SF "f32x4") (V4DF "f64x2")
1439 (V32QI "i32x4") (V16HI "i32x4") (V8SI "i32x4") (V4DI "i64x2")])
1440
1441 ;; Mix-n-match
1442 (define_mode_iterator AVX256MODE2P [V8SI V8SF V4DF])
1443 (define_mode_iterator AVX512MODE2P
1444 [(V16SI "TARGET_EVEX512") (V16SF "TARGET_EVEX512") (V8DF "TARGET_EVEX512")])
1445
1446 ;; Mapping for dbpsabbw modes
1447 (define_mode_attr dbpsadbwmode
1448 [(V32HI "V64QI") (V16HI "V32QI") (V8HI "V16QI")])
1449
1450 ;; Mapping suffixes for broadcast
1451 (define_mode_attr bcstscalarsuff
1452 [(V64QI "b") (V32QI "b") (V16QI "b")
1453 (V32HI "w") (V16HI "w") (V8HI "w")
1454 (V16SI "d") (V8SI "d") (V4SI "d")
1455 (V8DI "q") (V4DI "q") (V2DI "q")
1456 (V32HF "w") (V16HF "w") (V8HF "w")
1457 (V32BF "w") (V16BF "w") (V8BF "w")
1458 (V16SF "ss") (V8SF "ss") (V4SF "ss")
1459 (V8DF "sd") (V4DF "sd") (V2DF "sd")])
1460
1461 ;; Tie mode of assembler operand to mode iterator
1462 (define_mode_attr xtg_mode
1463 [(V16QI "x") (V8HI "x") (V4SI "x") (V2DI "x")
1464 (V8HF "x") (V8BF "x") (V4SF "x") (V2DF "x")
1465 (V32QI "t") (V16HI "t") (V8SI "t") (V4DI "t")
1466 (V16HF "t") (V16BF "t") (V8SF "t") (V4DF "t")
1467 (V64QI "g") (V32HI "g") (V16SI "g") (V8DI "g")
1468 (V32HF "g") (V32BF "g") (V16SF "g") (V8DF "g")])
1469
1470 ;; Half mask mode for unpacks
1471 (define_mode_attr HALFMASKMODE
1472 [(DI "SI") (SI "HI")])
1473
1474 ;; Double mask mode for packs
1475 (define_mode_attr DOUBLEMASKMODE
1476 [(HI "SI") (SI "DI")])
1477
1478
1479 ;; Include define_subst patterns for instructions with mask
1480 (include "subst.md")
1481
1482 ;; Patterns whose name begins with "sse{,2,3}_" are invoked by intrinsics.
1483
1484 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1485 ;;
1486 ;; Move patterns
1487 ;;
1488 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1489
1490 ;; All of these patterns are enabled for SSE1 as well as SSE2.
1491 ;; This is essential for maintaining stable calling conventions.
1492
1493 (define_expand "mov<mode>"
1494 [(set (match_operand:VMOVE 0 "nonimmediate_operand")
1495 (match_operand:VMOVE 1 "nonimmediate_or_sse_const_operand"))]
1496 "TARGET_SSE"
1497 {
1498 ix86_expand_vector_move (<MODE>mode, operands);
1499 DONE;
1500 })
1501
1502 (define_insn "mov<mode>_internal"
1503 [(set (match_operand:VMOVE 0 "nonimmediate_operand"
1504 "=v,v ,x,v ,m")
1505 (match_operand:VMOVE 1 "nonimmediate_or_sse_const_operand"
1506 " C,<sseconstm1>,BH,vm,v"))]
1507 "TARGET_SSE
1508 && (register_operand (operands[0], <MODE>mode)
1509 || register_operand (operands[1], <MODE>mode))
1510 && ix86_hardreg_mov_ok (operands[0], operands[1])"
1511 {
1512 switch (get_attr_type (insn))
1513 {
1514 case TYPE_SSELOG1:
1515 return standard_sse_constant_opcode (insn, operands);
1516
1517 case TYPE_SSEMOV:
1518 return ix86_output_ssemov (insn, operands);
1519
1520 default:
1521 gcc_unreachable ();
1522 }
1523 }
1524 [(set_attr "type" "sselog1,sselog1,sselog1,ssemov,ssemov")
1525 (set_attr "prefix" "maybe_vex")
1526 (set (attr "mode")
1527 (cond [(match_test "TARGET_AVX")
1528 (const_string "<sseinsnmode>")
1529 (ior (not (match_test "TARGET_SSE2"))
1530 (match_test "optimize_function_for_size_p (cfun)"))
1531 (const_string "V4SF")
1532 (and (match_test "<MODE>mode == V2DFmode")
1533 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
1534 (const_string "V4SF")
1535 (and (eq_attr "alternative" "4")
1536 (match_test "TARGET_SSE_TYPELESS_STORES"))
1537 (const_string "V4SF")
1538 (and (eq_attr "alternative" "0")
1539 (match_test "TARGET_SSE_LOAD0_BY_PXOR"))
1540 (const_string "TI")
1541 ]
1542 (const_string "<sseinsnmode>")))
1543 (set (attr "enabled")
1544 (cond [(and (match_test "<MODE_SIZE> == 16")
1545 (eq_attr "alternative" "1"))
1546 (symbol_ref "TARGET_SSE2")
1547 (and (match_test "<MODE_SIZE> == 32")
1548 (eq_attr "alternative" "1"))
1549 (symbol_ref "TARGET_AVX2")
1550 ]
1551 (symbol_ref "true")))])
1552
1553 ; False dependency happens on destination register which is not really
1554 ; used when moving all ones to vector register
1555 (define_split
1556 [(set (match_operand:VMOVE 0 "register_operand")
1557 (match_operand:VMOVE 1 "int_float_vector_all_ones_operand"))]
1558 "TARGET_AVX512F && reload_completed
1559 && (<MODE_SIZE> == 64 || EXT_REX_SSE_REG_P (operands[0]))
1560 && optimize_insn_for_speed_p ()"
1561 [(set (match_dup 0) (match_dup 2))
1562 (parallel
1563 [(set (match_dup 0) (match_dup 1))
1564 (unspec [(match_dup 0)] UNSPEC_INSN_FALSE_DEP)])]
1565 "operands[2] = CONST0_RTX (<MODE>mode);")
1566
1567 (define_insn "*vmov<mode>_constm1_pternlog_false_dep"
1568 [(set (match_operand:VMOVE 0 "register_operand" "=v")
1569 (match_operand:VMOVE 1 "int_float_vector_all_ones_operand" "<sseconstm1>"))
1570 (unspec [(match_operand:VMOVE 2 "register_operand" "0")] UNSPEC_INSN_FALSE_DEP)]
1571 "TARGET_AVX512VL || <MODE_SIZE> == 64"
1572 "vpternlogd\t{$0xFF, %0, %0, %0|%0, %0, %0, 0xFF}"
1573 [(set_attr "type" "sselog1")
1574 (set_attr "prefix" "evex")
1575 (set (attr "mode")
1576 (if_then_else (match_test "TARGET_AVX512VL")
1577 (const_string "<sseinsnmode>")
1578 (const_string "XI")))])
1579
1580 ;; If mem_addr points to a memory region with less than whole vector size bytes
1581 ;; of accessible memory and k is a mask that would prevent reading the inaccessible
1582 ;; bytes from mem_addr, add UNSPEC_MASKLOAD to prevent it to be transformed to vpblendd
1583 ;; See pr97642.
1584 (define_expand "<avx512>_load<mode>_mask"
1585 [(set (match_operand:V48_AVX512VL 0 "register_operand")
1586 (vec_merge:V48_AVX512VL
1587 (match_operand:V48_AVX512VL 1 "nonimmediate_operand")
1588 (match_operand:V48_AVX512VL 2 "nonimm_or_0_operand")
1589 (match_operand:<avx512fmaskmode> 3 "register_or_constm1_operand")))]
1590 "TARGET_AVX512F"
1591 {
1592 if (CONST_INT_P (operands[3]))
1593 {
1594 emit_insn (gen_rtx_SET (operands[0], operands[1]));
1595 DONE;
1596 }
1597 else if (MEM_P (operands[1]))
1598 operands[1] = gen_rtx_UNSPEC (<MODE>mode,
1599 gen_rtvec(1, operands[1]),
1600 UNSPEC_MASKLOAD);
1601 })
1602
1603 (define_insn "*<avx512>_load<mode>_mask"
1604 [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v")
1605 (vec_merge:V48_AVX512VL
1606 (unspec:V48_AVX512VL
1607 [(match_operand:V48_AVX512VL 1 "memory_operand" "m")]
1608 UNSPEC_MASKLOAD)
1609 (match_operand:V48_AVX512VL 2 "nonimm_or_0_operand" "0C")
1610 (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
1611 "TARGET_AVX512F"
1612 {
1613 if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
1614 {
1615 if (misaligned_operand (operands[1], <MODE>mode))
1616 return "vmovu<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1617 else
1618 return "vmova<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1619 }
1620 else
1621 {
1622 if (misaligned_operand (operands[1], <MODE>mode))
1623 return "vmovdqu<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1624 else
1625 return "vmovdqa<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1626 }
1627 }
1628 [(set_attr "type" "ssemov")
1629 (set_attr "prefix" "evex")
1630 (set_attr "mode" "<sseinsnmode>")])
1631
1632 (define_insn_and_split "*<avx512>_load<mode>"
1633 [(set (match_operand:V48_AVX512VL 0 "register_operand")
1634 (unspec:V48_AVX512VL
1635 [(match_operand:V48_AVX512VL 1 "memory_operand")]
1636 UNSPEC_MASKLOAD))]
1637 "TARGET_AVX512F"
1638 "#"
1639 "&& 1"
1640 [(set (match_dup 0) (match_dup 1))])
1641
1642 (define_expand "<avx512>_load<mode>_mask"
1643 [(set (match_operand:VI12_AVX512VL 0 "register_operand")
1644 (vec_merge:VI12_AVX512VL
1645 (match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
1646 (match_operand:VI12_AVX512VL 2 "nonimm_or_0_operand")
1647 (match_operand:<avx512fmaskmode> 3 "register_or_constm1_operand")))]
1648 "TARGET_AVX512BW"
1649 {
1650 if (CONST_INT_P (operands[3]))
1651 {
1652 emit_insn (gen_rtx_SET (operands[0], operands[1]));
1653 DONE;
1654 }
1655 else if (MEM_P (operands[1]))
1656 operands[1] = gen_rtx_UNSPEC (<MODE>mode,
1657 gen_rtvec(1, operands[1]),
1658 UNSPEC_MASKLOAD);
1659
1660 })
1661
1662 (define_insn "*<avx512>_load<mode>_mask"
1663 [(set (match_operand:VI12HFBF_AVX512VL 0 "register_operand" "=v")
1664 (vec_merge:VI12HFBF_AVX512VL
1665 (unspec:VI12HFBF_AVX512VL
1666 [(match_operand:VI12HFBF_AVX512VL 1 "memory_operand" "m")]
1667 UNSPEC_MASKLOAD)
1668 (match_operand:VI12HFBF_AVX512VL 2 "nonimm_or_0_operand" "0C")
1669 (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
1670 "TARGET_AVX512BW"
1671 "vmovdqu<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
1672 [(set_attr "type" "ssemov")
1673 (set_attr "prefix" "evex")
1674 (set_attr "mode" "<sseinsnmode>")])
1675
1676 (define_insn_and_split "*<avx512>_load<mode>"
1677 [(set (match_operand:VI12HFBF_AVX512VL 0 "register_operand" "=v")
1678 (unspec:VI12HFBF_AVX512VL
1679 [(match_operand:VI12HFBF_AVX512VL 1 "memory_operand" "m")]
1680 UNSPEC_MASKLOAD))]
1681 "TARGET_AVX512BW"
1682 "#"
1683 "&& 1"
1684 [(set (match_dup 0) (match_dup 1))])
1685
1686 (define_insn "avx512f_mov<ssescalarmodelower>_mask"
1687 [(set (match_operand:VFH_128 0 "register_operand" "=v")
1688 (vec_merge:VFH_128
1689 (vec_merge:VFH_128
1690 (match_operand:VFH_128 2 "register_operand" "v")
1691 (match_operand:VFH_128 3 "nonimm_or_0_operand" "0C")
1692 (match_operand:QI 4 "register_operand" "Yk"))
1693 (match_operand:VFH_128 1 "register_operand" "v")
1694 (const_int 1)))]
1695 "TARGET_AVX512F"
1696 "vmov<ssescalarmodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
1697 [(set_attr "type" "ssemov")
1698 (set_attr "prefix" "evex")
1699 (set_attr "mode" "<ssescalarmode>")])
1700
1701 (define_expand "avx512f_load<mode>_mask"
1702 [(set (match_operand:<ssevecmode> 0 "register_operand")
1703 (vec_merge:<ssevecmode>
1704 (vec_merge:<ssevecmode>
1705 (vec_duplicate:<ssevecmode>
1706 (match_operand:MODEFH 1 "memory_operand"))
1707 (match_operand:<ssevecmode> 2 "nonimm_or_0_operand")
1708 (match_operand:QI 3 "register_operand"))
1709 (match_dup 4)
1710 (const_int 1)))]
1711 "TARGET_AVX512F"
1712 "operands[4] = CONST0_RTX (<ssevecmode>mode);")
1713
1714 (define_insn "*avx512f_load<mode>_mask"
1715 [(set (match_operand:<ssevecmode> 0 "register_operand" "=v")
1716 (vec_merge:<ssevecmode>
1717 (vec_merge:<ssevecmode>
1718 (vec_duplicate:<ssevecmode>
1719 (match_operand:MODEFH 1 "memory_operand" "m"))
1720 (match_operand:<ssevecmode> 2 "nonimm_or_0_operand" "0C")
1721 (match_operand:QI 3 "register_operand" "Yk"))
1722 (match_operand:<ssevecmode> 4 "const0_operand")
1723 (const_int 1)))]
1724 "TARGET_AVX512F"
1725 "vmov<ssescalarmodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
1726 [(set_attr "type" "ssemov")
1727 (set_attr "prefix" "evex")
1728 (set_attr "memory" "load")
1729 (set_attr "mode" "<MODE>")])
1730
1731 (define_insn "avx512f_store<mode>_mask"
1732 [(set (match_operand:MODEFH 0 "memory_operand" "=m")
1733 (if_then_else:MODEFH
1734 (and:QI (match_operand:QI 2 "register_operand" "Yk")
1735 (const_int 1))
1736 (vec_select:MODEFH
1737 (match_operand:<ssevecmode> 1 "register_operand" "v")
1738 (parallel [(const_int 0)]))
1739 (match_dup 0)))]
1740 "TARGET_AVX512F"
1741 "vmov<ssescalarmodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
1742 [(set_attr "type" "ssemov")
1743 (set_attr "prefix" "evex")
1744 (set_attr "memory" "store")
1745 (set_attr "mode" "<MODE>")])
1746
1747 (define_insn "<avx512>_blendm<mode>"
1748 [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v,v")
1749 (vec_merge:V48_AVX512VL
1750 (match_operand:V48_AVX512VL 2 "nonimmediate_operand" "vm,vm")
1751 (match_operand:V48_AVX512VL 1 "nonimm_or_0_operand" "0C,v")
1752 (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
1753 "TARGET_AVX512F"
1754 {
1755 if (REG_P (operands[1])
1756 && REGNO (operands[1]) != REGNO (operands[0]))
1757 return "v<sseintprefix>blendm<ssemodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}";
1758
1759 if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
1760 {
1761 if (misaligned_operand (operands[2], <MODE>mode))
1762 return "vmovu<ssemodesuffix>\t{%2, %0%{%3%}%N1|%0%{%3%}%N1, %2}";
1763 else
1764 return "vmova<ssemodesuffix>\t{%2, %0%{%3%}%N1|%0%{%3%}%N1, %2}";
1765 }
1766 else
1767 {
1768 if (misaligned_operand (operands[2], <MODE>mode))
1769 return "vmovdqu<ssescalarsize>\t{%2, %0%{%3%}%N1|%0%{%3%}%N1, %2}";
1770 else
1771 return "vmovdqa<ssescalarsize>\t{%2, %0%{%3%}%N1|%0%{%3%}%N1, %2}";
1772 }
1773 }
1774 [(set_attr "type" "ssemov")
1775 (set (attr "c86_attr")
1776 (if_then_else (and (match_test "REG_P (operands[1])")
1777 (match_test "REGNO (operands[1]) != REGNO (operands[0])"))
1778 (const_string "blend")
1779 (const_string "*")))
1780 (set_attr "prefix" "evex")
1781 (set_attr "mode" "<sseinsnmode>")])
1782
1783 (define_insn "<avx512>_blendm<mode>"
1784 [(set (match_operand:VI12HFBF_AVX512VL 0 "register_operand" "=v,v")
1785 (vec_merge:VI12HFBF_AVX512VL
1786 (match_operand:VI12HFBF_AVX512VL 2 "nonimmediate_operand" "vm,vm")
1787 (match_operand:VI12HFBF_AVX512VL 1 "nonimm_or_0_operand" "0C,v")
1788 (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
1789 "TARGET_AVX512BW"
1790 "@
1791 vmovdqu<ssescalarsize>\t{%2, %0%{%3%}%N1|%0%{%3%}%N1, %2}
1792 vpblendm<sseintmodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}"
1793 [(set_attr "type" "ssemov")
1794 (set_attr "c86_attr" "*,blend")
1795 (set_attr "prefix" "evex")
1796 (set_attr "mode" "<sseinsnmode>")])
1797
1798 (define_insn "*<avx512>_store<mode>_mask"
1799 [(set (match_operand:V48_AVX512VL 0 "memory_operand" "=m")
1800 (vec_merge:V48_AVX512VL
1801 (match_operand:V48_AVX512VL 1 "register_operand" "v")
1802 (match_dup 0)
1803 (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1804 "TARGET_AVX512F"
1805 {
1806 if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
1807 {
1808 if (misaligned_operand (operands[0], <MODE>mode))
1809 return "vmovu<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1810 else
1811 return "vmova<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1812 }
1813 else
1814 {
1815 if (misaligned_operand (operands[0], <MODE>mode))
1816 return "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1817 else
1818 return "vmovdqa<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1819 }
1820 }
1821 [(set_attr "type" "ssemov")
1822 (set_attr "prefix" "evex")
1823 (set_attr "memory" "store")
1824 (set_attr "mode" "<sseinsnmode>")])
1825
1826 (define_insn "*<avx512>_store<mode>_mask"
1827 [(set (match_operand:VI12HFBF_AVX512VL 0 "memory_operand" "=m")
1828 (vec_merge:VI12HFBF_AVX512VL
1829 (match_operand:VI12HFBF_AVX512VL 1 "register_operand" "v")
1830 (match_dup 0)
1831 (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1832 "TARGET_AVX512BW"
1833 "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
1834 [(set_attr "type" "ssemov")
1835 (set_attr "prefix" "evex")
1836 (set_attr "memory" "store")
1837 (set_attr "mode" "<sseinsnmode>")])
1838
1839 (define_expand "sse2_movq128"
1840 [(set (match_operand:V2DI 0 "register_operand")
1841 (vec_concat:V2DI
1842 (vec_select:DI
1843 (match_operand:V2DI 1 "nonimmediate_operand")
1844 (parallel [(const_int 0)]))
1845 (const_int 0)))]
1846 "TARGET_SSE2")
1847
1848 (define_insn "*sse2_movq128_<mode>"
1849 [(set (match_operand:VI8F_128 0 "register_operand" "=v")
1850 (vec_concat:VI8F_128
1851 (vec_select:<ssescalarmode>
1852 (match_operand:VI8F_128 1 "nonimmediate_operand" "vm")
1853 (parallel [(const_int 0)]))
1854 (match_operand:<ssescalarmode> 2 "const0_operand")))]
1855 "TARGET_SSE2"
1856 "%vmovq\t{%1, %0|%0, %q1}"
1857 [(set_attr "type" "ssemov")
1858 (set_attr "prefix" "maybe_vex")
1859 (set_attr "mode" "TI")])
1860
1861 (define_insn "*sse2_movq128_<mode>_1"
1862 [(set (match_operand:VI8F_128 0 "register_operand" "=v")
1863 (vec_merge:VI8F_128
1864 (match_operand:VI8F_128 1 "nonimmediate_operand" "vm")
1865 (match_operand:VI8F_128 2 "const0_operand")
1866 (const_int 1)))]
1867 "TARGET_SSE2"
1868 "%vmovq\t{%1, %0|%0, %q1}"
1869 [(set_attr "type" "ssemov")
1870 (set_attr "prefix" "maybe_vex")
1871 (set_attr "mode" "TI")])
1872
1873 ;; Move a DI from a 32-bit register pair (e.g. %edx:%eax) to an xmm.
1874 ;; We'd rather avoid this entirely; if the 32-bit reg pair was loaded
1875 ;; from memory, we'd prefer to load the memory directly into the %xmm
1876 ;; register. To facilitate this happy circumstance, this pattern won't
1877 ;; split until after register allocation. If the 64-bit value didn't
1878 ;; come from memory, this is the best we can do. This is much better
1879 ;; than storing %edx:%eax into a stack temporary and loading an %xmm
1880 ;; from there.
1881
1882 (define_insn_and_split "movdi_to_sse"
1883 [(set (match_operand:V4SI 0 "register_operand" "=x,x,?x")
1884 (unspec:V4SI [(match_operand:DI 1 "nonimmediate_operand" "r,m,r")]
1885 UNSPEC_MOVDI_TO_SSE))
1886 (clobber (match_scratch:V4SI 2 "=X,X,&x"))]
1887 "!TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_TO_VEC"
1888 "#"
1889 "&& reload_completed"
1890 [(const_int 0)]
1891 {
1892 if (register_operand (operands[1], DImode))
1893 {
1894 /* The DImode arrived in a pair of integral registers (e.g. %edx:%eax).
1895 Assemble the 64-bit DImode value in an xmm register. */
1896 emit_insn (gen_sse2_loadld (operands[0], CONST0_RTX (V4SImode),
1897 gen_lowpart (SImode, operands[1])));
1898 if (TARGET_SSE4_1)
1899 emit_insn (gen_sse4_1_pinsrd (operands[0], operands[0],
1900 gen_highpart (SImode, operands[1]),
1901 GEN_INT (2)));
1902 else
1903 {
1904 emit_insn (gen_sse2_loadld (operands[2], CONST0_RTX (V4SImode),
1905 gen_highpart (SImode, operands[1])));
1906 emit_insn (gen_vec_interleave_lowv4si (operands[0], operands[0],
1907 operands[2]));
1908 }
1909 }
1910 else if (memory_operand (operands[1], DImode))
1911 emit_insn (gen_vec_concatv2di (gen_lowpart (V2DImode, operands[0]),
1912 operands[1], const0_rtx));
1913 else
1914 gcc_unreachable ();
1915 DONE;
1916 }
1917 [(set_attr "isa" "sse4,*,*")])
1918
1919 (define_split
1920 [(set (match_operand:V4SF 0 "register_operand")
1921 (match_operand:V4SF 1 "zero_extended_scalar_load_operand"))]
1922 "TARGET_SSE && reload_completed"
1923 [(set (match_dup 0)
1924 (vec_merge:V4SF
1925 (vec_duplicate:V4SF (match_dup 1))
1926 (match_dup 2)
1927 (const_int 1)))]
1928 {
1929 operands[1] = gen_lowpart (SFmode, operands[1]);
1930 operands[2] = CONST0_RTX (V4SFmode);
1931 })
1932
1933 (define_split
1934 [(set (match_operand:V2DF 0 "register_operand")
1935 (match_operand:V2DF 1 "zero_extended_scalar_load_operand"))]
1936 "TARGET_SSE2 && reload_completed"
1937 [(set (match_dup 0) (vec_concat:V2DF (match_dup 1) (match_dup 2)))]
1938 {
1939 operands[1] = gen_lowpart (DFmode, operands[1]);
1940 operands[2] = CONST0_RTX (DFmode);
1941 })
1942
1943 (define_expand "movmisalign<mode>"
1944 [(set (match_operand:VMOVE 0 "nonimmediate_operand")
1945 (match_operand:VMOVE 1 "nonimmediate_operand"))]
1946 "TARGET_SSE"
1947 {
1948 ix86_expand_vector_move_misalign (<MODE>mode, operands);
1949 DONE;
1950 })
1951
1952 ;; Merge movsd/movhpd to movupd for TARGET_SSE_UNALIGNED_LOAD_OPTIMAL targets.
1953 (define_peephole2
1954 [(set (match_operand:V2DF 0 "sse_reg_operand")
1955 (vec_concat:V2DF (match_operand:DF 1 "memory_operand")
1956 (match_operand:DF 4 "const0_operand")))
1957 (set (match_operand:V2DF 2 "sse_reg_operand")
1958 (vec_concat:V2DF (vec_select:DF (match_dup 2)
1959 (parallel [(const_int 0)]))
1960 (match_operand:DF 3 "memory_operand")))]
1961 "TARGET_SSE2 && TARGET_SSE_UNALIGNED_LOAD_OPTIMAL
1962 && ix86_operands_ok_for_move_multiple (operands, true, DFmode)"
1963 [(set (match_dup 2) (match_dup 5))]
1964 "operands[5] = adjust_address (operands[1], V2DFmode, 0);")
1965
1966 (define_peephole2
1967 [(set (match_operand:DF 0 "sse_reg_operand")
1968 (match_operand:DF 1 "memory_operand"))
1969 (set (match_operand:V2DF 2 "sse_reg_operand")
1970 (vec_concat:V2DF (match_operand:DF 4 "sse_reg_operand")
1971 (match_operand:DF 3 "memory_operand")))]
1972 "TARGET_SSE2 && TARGET_SSE_UNALIGNED_LOAD_OPTIMAL
1973 && REGNO (operands[4]) == REGNO (operands[2])
1974 && ix86_operands_ok_for_move_multiple (operands, true, DFmode)"
1975 [(set (match_dup 2) (match_dup 5))]
1976 "operands[5] = adjust_address (operands[1], V2DFmode, 0);")
1977
1978 ;; Merge movlpd/movhpd to movupd for TARGET_SSE_UNALIGNED_STORE_OPTIMAL targets.
1979 (define_peephole2
1980 [(set (match_operand:DF 0 "memory_operand")
1981 (vec_select:DF (match_operand:V2DF 1 "sse_reg_operand")
1982 (parallel [(const_int 0)])))
1983 (set (match_operand:DF 2 "memory_operand")
1984 (vec_select:DF (match_operand:V2DF 3 "sse_reg_operand")
1985 (parallel [(const_int 1)])))]
1986 "TARGET_SSE2 && TARGET_SSE_UNALIGNED_STORE_OPTIMAL
1987 && ix86_operands_ok_for_move_multiple (operands, false, DFmode)"
1988 [(set (match_dup 4) (match_dup 1))]
1989 "operands[4] = adjust_address (operands[0], V2DFmode, 0);")
1990
1991 (define_insn "<sse3>_lddqu<avxsizesuffix>"
1992 [(set (match_operand:VI1 0 "register_operand" "=x,x")
1993 (unspec:VI1 [(match_operand:VI1 1 "memory_operand" "m,jm")]
1994 UNSPEC_LDDQU))]
1995 "TARGET_SSE3"
1996 "%vlddqu\t{%1, %0|%0, %1}"
1997 [(set_attr "isa" "noavx,avx")
1998 (set_attr "type" "ssemov")
1999 (set_attr "addr" "*,gpr16")
2000 (set_attr "movu" "1")
2001 (set (attr "prefix_data16")
2002 (if_then_else
2003 (match_test "TARGET_AVX")
2004 (const_string "*")
2005 (const_string "0")))
2006 (set (attr "prefix_rep")
2007 (if_then_else
2008 (match_test "TARGET_AVX")
2009 (const_string "*")
2010 (const_string "1")))
2011 (set_attr "prefix" "maybe_vex")
2012 (set_attr "mode" "<sseinsnmode>")])
2013
2014 (define_insn "sse2_movnti<mode>"
2015 [(set (match_operand:SWI48 0 "memory_operand" "=m")
2016 (unspec:SWI48 [(match_operand:SWI48 1 "register_operand" "r")]
2017 UNSPEC_MOVNT))]
2018 "TARGET_SSE2"
2019 "movnti\t{%1, %0|%0, %1}"
2020 [(set_attr "type" "ssemov")
2021 (set_attr "c86_attr" "movnt")
2022 (set_attr "prefix_data16" "0")
2023 (set_attr "mode" "<MODE>")])
2024
2025 (define_insn "<sse>_movnt<mode>"
2026 [(set (match_operand:VF 0 "memory_operand" "=m")
2027 (unspec:VF
2028 [(match_operand:VF 1 "register_operand" "v")]
2029 UNSPEC_MOVNT))]
2030 "TARGET_SSE"
2031 "%vmovnt<ssemodesuffix>\t{%1, %0|%0, %1}"
2032 [(set_attr "type" "ssemov")
2033 (set_attr "c86_attr" "movnt")
2034 (set_attr "prefix" "maybe_vex")
2035 (set_attr "mode" "<MODE>")])
2036
2037 (define_insn "<sse2>_movnt<mode>"
2038 [(set (match_operand:VI8 0 "memory_operand" "=m")
2039 (unspec:VI8 [(match_operand:VI8 1 "register_operand" "v")]
2040 UNSPEC_MOVNT))]
2041 "TARGET_SSE2"
2042 "%vmovntdq\t{%1, %0|%0, %1}"
2043 [(set_attr "type" "ssecvt")
2044 (set (attr "prefix_data16")
2045 (if_then_else
2046 (match_test "TARGET_AVX")
2047 (const_string "*")
2048 (const_string "1")))
2049 (set_attr "c86_attr" "movnt")
2050 (set_attr "prefix" "maybe_vex")
2051 (set_attr "mode" "<sseinsnmode>")])
2052
2053 ; Expand patterns for non-temporal stores. At the moment, only those
2054 ; that directly map to insns are defined; it would be possible to
2055 ; define patterns for other modes that would expand to several insns.
2056
2057 ;; Modes handled by storent patterns.
2058 (define_mode_iterator STORENT_MODE
2059 [(DI "TARGET_SSE2 && TARGET_64BIT") (SI "TARGET_SSE2")
2060 (SF "TARGET_SSE4A") (DF "TARGET_SSE4A")
2061 (V8DI "TARGET_AVX512F && TARGET_EVEX512")
2062 (V4DI "TARGET_AVX") (V2DI "TARGET_SSE2")
2063 (V16SF "TARGET_AVX512F && TARGET_EVEX512") (V8SF "TARGET_AVX") V4SF
2064 (V8DF "TARGET_AVX512F && TARGET_EVEX512")
2065 (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
2066
2067 (define_expand "storent<mode>"
2068 [(set (match_operand:STORENT_MODE 0 "memory_operand")
2069 (unspec:STORENT_MODE
2070 [(match_operand:STORENT_MODE 1 "register_operand")]
2071 UNSPEC_MOVNT))]
2072 "TARGET_SSE")
2073
2074 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2075 ;;
2076 ;; Mask operations
2077 ;;
2078 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2079
2080 ;; All integer modes with AVX512BW/DQ.
2081 (define_mode_iterator SWI1248_AVX512BWDQ
2082 [(QI "TARGET_AVX512DQ") HI (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW")])
2083
2084 ;; All integer modes with AVX512BW, where HImode operation
2085 ;; can be used instead of QImode.
2086 (define_mode_iterator SWI1248_AVX512BW
2087 [QI HI (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW")])
2088
2089 ;; All integer modes with AVX512BW/DQ, even HImode requires DQ.
2090 (define_mode_iterator SWI1248_AVX512BWDQ2
2091 [(QI "TARGET_AVX512DQ") (HI "TARGET_AVX512DQ")
2092 (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW")])
2093
2094 (define_expand "kmov<mskmodesuffix>"
2095 [(set (match_operand:SWI1248_AVX512BWDQ 0 "nonimmediate_operand")
2096 (match_operand:SWI1248_AVX512BWDQ 1 "nonimmediate_operand"))]
2097 "TARGET_AVX512F
2098 && !(MEM_P (operands[0]) && MEM_P (operands[1]))")
2099
2100 (define_insn "k<code><mode>"
2101 [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
2102 (any_logic:SWI1248_AVX512BW
2103 (match_operand:SWI1248_AVX512BW 1 "register_operand" "k")
2104 (match_operand:SWI1248_AVX512BW 2 "register_operand" "k")))
2105 (unspec [(const_int 0)] UNSPEC_MASKOP)]
2106 "TARGET_AVX512F"
2107 {
2108 if (get_attr_mode (insn) == MODE_HI)
2109 return "k<logic>w\t{%2, %1, %0|%0, %1, %2}";
2110 else
2111 return "k<logic><mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
2112 }
2113 [(set_attr "type" "msklog")
2114 (set_attr "prefix" "vex")
2115 (set (attr "mode")
2116 (cond [(and (match_test "<MODE>mode == QImode")
2117 (not (match_test "TARGET_AVX512DQ")))
2118 (const_string "HI")
2119 ]
2120 (const_string "<MODE>")))])
2121
2122 (define_split
2123 [(set (match_operand:SWI1248_AVX512BW 0 "mask_reg_operand")
2124 (any_logic:SWI1248_AVX512BW
2125 (match_operand:SWI1248_AVX512BW 1 "mask_reg_operand")
2126 (match_operand:SWI1248_AVX512BW 2 "mask_reg_operand")))]
2127 "TARGET_AVX512F && reload_completed"
2128 [(parallel
2129 [(set (match_dup 0)
2130 (any_logic:SWI1248_AVX512BW (match_dup 1) (match_dup 2)))
2131 (unspec [(const_int 0)] UNSPEC_MASKOP)])])
2132
2133 (define_split
2134 [(set (match_operand:SWI1248_AVX512BW 0 "mask_reg_operand")
2135 (any_logic:SWI1248_AVX512BW
2136 (match_operand:SWI1248_AVX512BW 1 "mask_reg_operand")
2137 (match_operand:SWI1248_AVX512BW 2 "mask_reg_operand")))
2138 (clobber (reg:CC FLAGS_REG))]
2139 "TARGET_AVX512F && reload_completed"
2140 [(parallel
2141 [(set (match_dup 0)
2142 (any_logic:SWI1248_AVX512BW (match_dup 1) (match_dup 2)))
2143 (unspec [(const_int 0)] UNSPEC_MASKOP)])])
2144
2145 (define_insn "kandn<mode>"
2146 [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
2147 (and:SWI1248_AVX512BW
2148 (not:SWI1248_AVX512BW
2149 (match_operand:SWI1248_AVX512BW 1 "register_operand" "k"))
2150 (match_operand:SWI1248_AVX512BW 2 "register_operand" "k")))
2151 (unspec [(const_int 0)] UNSPEC_MASKOP)]
2152 "TARGET_AVX512F"
2153 {
2154 if (get_attr_mode (insn) == MODE_HI)
2155 return "kandnw\t{%2, %1, %0|%0, %1, %2}";
2156 else
2157 return "kandn<mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
2158 }
2159 [(set_attr "type" "msklog")
2160 (set_attr "prefix" "vex")
2161 (set (attr "mode")
2162 (cond [(and (match_test "<MODE>mode == QImode")
2163 (not (match_test "TARGET_AVX512DQ")))
2164 (const_string "HI")
2165 ]
2166 (const_string "<MODE>")))])
2167
2168 (define_split
2169 [(set (match_operand:SWI1248_AVX512BW 0 "mask_reg_operand")
2170 (and:SWI1248_AVX512BW
2171 (not:SWI1248_AVX512BW
2172 (match_operand:SWI1248_AVX512BW 1 "mask_reg_operand"))
2173 (match_operand:SWI1248_AVX512BW 2 "mask_reg_operand")))
2174 (clobber (reg:CC FLAGS_REG))]
2175 "TARGET_AVX512F && reload_completed"
2176 [(parallel
2177 [(set (match_dup 0)
2178 (and:SWI1248_AVX512BW
2179 (not:SWI1248_AVX512BW (match_dup 1))
2180 (match_dup 2)))
2181 (unspec [(const_int 0)] UNSPEC_MASKOP)])])
2182
2183 (define_insn "kxnor<mode>"
2184 [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
2185 (not:SWI1248_AVX512BW
2186 (xor:SWI1248_AVX512BW
2187 (match_operand:SWI1248_AVX512BW 1 "register_operand" "k")
2188 (match_operand:SWI1248_AVX512BW 2 "register_operand" "k"))))
2189 (unspec [(const_int 0)] UNSPEC_MASKOP)]
2190 "TARGET_AVX512F"
2191 {
2192 if (get_attr_mode (insn) == MODE_HI)
2193 return "kxnorw\t{%2, %1, %0|%0, %1, %2}";
2194 else
2195 return "kxnor<mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
2196 }
2197 [(set_attr "type" "msklog")
2198 (set_attr "prefix" "vex")
2199 (set (attr "mode")
2200 (cond [(and (match_test "<MODE>mode == QImode")
2201 (not (match_test "TARGET_AVX512DQ")))
2202 (const_string "HI")
2203 ]
2204 (const_string "<MODE>")))])
2205
2206 (define_insn "knot<mode>"
2207 [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
2208 (not:SWI1248_AVX512BW
2209 (match_operand:SWI1248_AVX512BW 1 "register_operand" "k")))
2210 (unspec [(const_int 0)] UNSPEC_MASKOP)]
2211 "TARGET_AVX512F"
2212 {
2213 if (get_attr_mode (insn) == MODE_HI)
2214 return "knotw\t{%1, %0|%0, %1}";
2215 else
2216 return "knot<mskmodesuffix>\t{%1, %0|%0, %1}";
2217 }
2218 [(set_attr "type" "msklog")
2219 (set_attr "prefix" "vex")
2220 (set (attr "mode")
2221 (cond [(and (match_test "<MODE>mode == QImode")
2222 (not (match_test "TARGET_AVX512DQ")))
2223 (const_string "HI")
2224 ]
2225 (const_string "<MODE>")))])
2226
2227 (define_split
2228 [(set (match_operand:SWI1248_AVX512BW 0 "mask_reg_operand")
2229 (not:SWI1248_AVX512BW
2230 (match_operand:SWI1248_AVX512BW 1 "mask_reg_operand")))]
2231 "TARGET_AVX512F && reload_completed"
2232 [(parallel
2233 [(set (match_dup 0)
2234 (not:SWI1248_AVX512BW (match_dup 1)))
2235 (unspec [(const_int 0)] UNSPEC_MASKOP)])])
2236
2237 (define_insn "*knotsi_1_zext"
2238 [(set (match_operand:DI 0 "register_operand" "=k")
2239 (zero_extend:DI
2240 (not:SI (match_operand:SI 1 "register_operand" "k"))))
2241 (unspec [(const_int 0)] UNSPEC_MASKOP)]
2242 "TARGET_AVX512BW"
2243 "knotd\t{%1, %0|%0, %1}";
2244 [(set_attr "type" "msklog")
2245 (set_attr "prefix" "vex")
2246 (set_attr "mode" "SI")])
2247
2248 (define_split
2249 [(set (match_operand:DI 0 "mask_reg_operand")
2250 (zero_extend:DI
2251 (not:SI (match_operand:SI 1 "mask_reg_operand"))))]
2252 "TARGET_AVX512BW && reload_completed"
2253 [(parallel
2254 [(set (match_dup 0)
2255 (zero_extend:DI
2256 (not:SI (match_dup 1))))
2257 (unspec [(const_int 0)] UNSPEC_MASKOP)])])
2258
2259 (define_insn "kadd<mode>"
2260 [(set (match_operand:SWI1248_AVX512BWDQ2 0 "register_operand" "=k")
2261 (plus:SWI1248_AVX512BWDQ2
2262 (match_operand:SWI1248_AVX512BWDQ2 1 "register_operand" "k")
2263 (match_operand:SWI1248_AVX512BWDQ2 2 "register_operand" "k")))
2264 (unspec [(const_int 0)] UNSPEC_MASKOP)]
2265 "TARGET_AVX512F"
2266 "kadd<mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2267 [(set_attr "type" "msklog")
2268 (set_attr "prefix" "vex")
2269 (set_attr "mode" "<MODE>")])
2270
2271 ;; Mask variant shift mnemonics
2272 (define_code_attr mshift [(ashift "shiftl") (lshiftrt "shiftr")])
2273
2274 (define_insn "k<code><mode>"
2275 [(set (match_operand:SWI1248_AVX512BWDQ 0 "register_operand" "=k")
2276 (any_lshift:SWI1248_AVX512BWDQ
2277 (match_operand:SWI1248_AVX512BWDQ 1 "register_operand" "k")
2278 (match_operand 2 "const_0_to_255_operand")))
2279 (unspec [(const_int 0)] UNSPEC_MASKOP)]
2280 "TARGET_AVX512F"
2281 "k<mshift><mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2282 [(set_attr "type" "msklog")
2283 (set_attr "prefix" "vex")
2284 (set_attr "mode" "<MODE>")])
2285
2286 (define_split
2287 [(set (match_operand:SWI1248_AVX512BW 0 "mask_reg_operand")
2288 (any_lshift:SWI1248_AVX512BW
2289 (match_operand:SWI1248_AVX512BW 1 "mask_reg_operand")
2290 (match_operand 2 "const_int_operand")))]
2291 "TARGET_AVX512F && reload_completed"
2292 [(parallel
2293 [(set (match_dup 0)
2294 (any_lshift:SWI1248_AVX512BW
2295 (match_dup 1)
2296 (match_dup 2)))
2297 (unspec [(const_int 0)] UNSPEC_MASKOP)])])
2298
2299 (define_split
2300 [(set (match_operand:SWI1248_AVX512BW 0 "mask_reg_operand")
2301 (any_lshift:SWI1248_AVX512BW
2302 (match_operand:SWI1248_AVX512BW 1 "mask_reg_operand")
2303 (match_operand 2 "const_int_operand")))
2304 (clobber (reg:CC FLAGS_REG))]
2305 "TARGET_AVX512F && reload_completed"
2306 [(parallel
2307 [(set (match_dup 0)
2308 (any_lshift:SWI1248_AVX512BW
2309 (match_dup 1)
2310 (match_dup 2)))
2311 (unspec [(const_int 0)] UNSPEC_MASKOP)])])
2312
2313 (define_insn "*klshrsi3_1_zext"
2314 [(set (match_operand:DI 0 "register_operand" "=k")
2315 (zero_extend:DI
2316 (lshiftrt:SI (match_operand:SI 1 "register_operand" "k")
2317 (match_operand 2 "const_0_to_31_operand" "I"))))
2318 (unspec [(const_int 0)] UNSPEC_MASKOP)]
2319 "TARGET_AVX512BW"
2320 "kshiftrd\t{%2, %1, %0|%0, %1, %2}"
2321 [(set_attr "type" "msklog")
2322 (set_attr "prefix" "vex")
2323 (set_attr "mode" "SI")])
2324
2325 (define_split
2326 [(set (match_operand:DI 0 "mask_reg_operand")
2327 (zero_extend:DI
2328 (lshiftrt:SI
2329 (match_operand:SI 1 "mask_reg_operand")
2330 (match_operand 2 "const_0_to_31_operand"))))
2331 (clobber (reg:CC FLAGS_REG))]
2332 "TARGET_AVX512BW && reload_completed"
2333 [(parallel
2334 [(set (match_dup 0)
2335 (zero_extend:DI
2336 (lshiftrt:SI
2337 (match_dup 1)
2338 (match_dup 2))))
2339 (unspec [(const_int 0)] UNSPEC_MASKOP)])])
2340
2341 (define_insn "ktest<mode>"
2342 [(set (reg:CC FLAGS_REG)
2343 (unspec:CC
2344 [(match_operand:SWI1248_AVX512BWDQ2 0 "register_operand" "k")
2345 (match_operand:SWI1248_AVX512BWDQ2 1 "register_operand" "k")]
2346 UNSPEC_KTEST))]
2347 "TARGET_AVX512F"
2348 "ktest<mskmodesuffix>\t{%1, %0|%0, %1}"
2349 [(set_attr "mode" "<MODE>")
2350 (set_attr "type" "msklog")
2351 (set_attr "c86_decode" "vector")
2352 (set_attr "prefix" "vex")])
2353
2354 (define_insn "*kortest<mode>"
2355 [(set (reg FLAGS_REG)
2356 (unspec
2357 [(match_operand:SWI1248_AVX512BWDQ 0 "register_operand" "k")
2358 (match_operand:SWI1248_AVX512BWDQ 1 "register_operand" "k")]
2359 UNSPEC_KORTEST))]
2360 "TARGET_AVX512F"
2361 "kortest<mskmodesuffix>\t{%1, %0|%0, %1}"
2362 [(set_attr "mode" "<MODE>")
2363 (set_attr "type" "msklog")
2364 (set_attr "c86_decode" "vector")
2365 (set_attr "prefix" "vex")])
2366
2367 (define_insn "kortest<mode>_ccc"
2368 [(set (reg:CCC FLAGS_REG)
2369 (unspec:CCC
2370 [(match_operand:SWI1248_AVX512BWDQ 0 "register_operand")
2371 (match_operand:SWI1248_AVX512BWDQ 1 "register_operand")]
2372 UNSPEC_KORTEST))]
2373 "TARGET_AVX512F")
2374
2375 (define_insn "kortest<mode>_ccz"
2376 [(set (reg:CCZ FLAGS_REG)
2377 (unspec:CCZ
2378 [(match_operand:SWI1248_AVX512BWDQ 0 "register_operand")
2379 (match_operand:SWI1248_AVX512BWDQ 1 "register_operand")]
2380 UNSPEC_KORTEST))]
2381 "TARGET_AVX512F")
2382
2383 (define_expand "kortest<mode>"
2384 [(set (reg:CC FLAGS_REG)
2385 (unspec:CC
2386 [(match_operand:SWI1248_AVX512BWDQ 0 "register_operand")
2387 (match_operand:SWI1248_AVX512BWDQ 1 "register_operand")]
2388 UNSPEC_KORTEST))]
2389 "TARGET_AVX512F")
2390
2391 ;; Optimize cmp + setcc with mask register by kortest + setcc.
2392 (define_insn_and_split "*kortest_cmp<mode>_setcc"
2393 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm, qm")
2394 (match_operator:QI 1 "bt_comparison_operator"
2395 [(match_operand:SWI1248_AVX512BWDQ_64 2 "register_operand" "?k, <r>")
2396 (const_int -1)]))
2397 (clobber (reg:CC FLAGS_REG))]
2398 "TARGET_AVX512BW"
2399 "#"
2400 "&& reload_completed"
2401 [(const_int 0)]
2402 {
2403 if (MASK_REGNO_P (REGNO (operands[2])))
2404 {
2405 emit_insn (gen_kortest<mode>_ccc (operands[2], operands[2]));
2406 operands[4] = gen_rtx_REG (CCCmode, FLAGS_REG);
2407 }
2408 else
2409 {
2410 operands[4] = gen_rtx_REG (CCZmode, FLAGS_REG);
2411 emit_insn (gen_rtx_SET (operands[4],
2412 gen_rtx_COMPARE (CCZmode,
2413 operands[2],
2414 constm1_rtx)));
2415 }
2416 ix86_expand_setcc (operands[0],
2417 GET_CODE (operands[1]),
2418 operands[4],
2419 const0_rtx);
2420 DONE;
2421 })
2422
2423 ;; Optimize cmp + jcc with mask register by kortest + jcc.
2424 (define_insn_and_split "*kortest_cmp<mode>_jcc"
2425 [(set (pc)
2426 (if_then_else
2427 (match_operator 0 "bt_comparison_operator"
2428 [(match_operand:SWI1248_AVX512BWDQ_64 1 "register_operand" "?k, <r>")
2429 (const_int -1)])
2430 (label_ref (match_operand 2))
2431 (pc)))
2432 (clobber (reg:CC FLAGS_REG))]
2433 "TARGET_AVX512BW"
2434 "#"
2435 "&& reload_completed"
2436 [(const_int 0)]
2437 {
2438 if (MASK_REGNO_P (REGNO (operands[1])))
2439 {
2440 emit_insn (gen_kortest<mode>_ccc (operands[1], operands[1]));
2441 operands[4] = gen_rtx_REG (CCCmode, FLAGS_REG);
2442 }
2443 else
2444 {
2445 operands[4] = gen_rtx_REG (CCZmode, FLAGS_REG);
2446 emit_insn (gen_rtx_SET (operands[4],
2447 gen_rtx_COMPARE (CCZmode,
2448 operands[1],
2449 constm1_rtx)));
2450 }
2451 ix86_expand_branch (GET_CODE (operands[0]),
2452 operands[4],
2453 const0_rtx,
2454 operands[2]);
2455 DONE;
2456 })
2457
2458 ;; Optimize cmp + movcc with mask register by kortest + movcc.
2459 (define_insn_and_split "*kortest_cmp<SWI1248_AVX512BWDQ_64:mode>_movqicc"
2460 [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r,r")
2461 (if_then_else:QI
2462 (match_operator 1 "bt_comparison_operator"
2463 [(match_operand:SWI1248_AVX512BWDQ_64 4 "register_operand"
2464 "?k,<SWI1248_AVX512BWDQ_64:r>,?k, <SWI1248_AVX512BWDQ_64:r>,?k,r")
2465 (const_int -1)])
2466 (match_operand:QI 2 "register_operand" "r,r,0,0,r,r")
2467 (match_operand:QI 3 "register_operand" " 0,0,r,r,r,r")))
2468 (clobber (reg:CC FLAGS_REG))]
2469 "TARGET_AVX512BW && TARGET_CMOVE && !TARGET_PARTIAL_REG_STALL"
2470 "#"
2471 "&& reload_completed"
2472 [(set (match_dup 0)
2473 (if_then_else:SI
2474 (match_dup 5)
2475 (match_dup 2)
2476 (match_dup 3)))]
2477 {
2478 rtx flag_reg;
2479 if (MASK_REGNO_P (REGNO (operands[4])))
2480 {
2481 emit_insn (gen_kortest<SWI1248_AVX512BWDQ_64:mode>_ccc (operands[4], operands[4]));
2482 flag_reg = gen_rtx_REG (CCCmode, FLAGS_REG);
2483 }
2484 else
2485 {
2486 flag_reg = gen_rtx_REG (CCZmode, FLAGS_REG);
2487 emit_insn (gen_rtx_SET (flag_reg,
2488 gen_rtx_COMPARE (CCZmode,
2489 operands[4],
2490 constm1_rtx)));
2491 }
2492 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[1]), VOIDmode,
2493 flag_reg,const0_rtx);
2494 operands[0] = gen_lowpart (SImode, operands[0]);
2495 operands[2] = gen_lowpart (SImode, operands[2]);
2496 operands[3] = gen_lowpart (SImode, operands[3]);
2497 }
2498 [(set_attr "isa" "*,*,*,*,apx_ndd,apx_ndd")
2499 (set_attr "type" "icmov")
2500 (set_attr "mode" "QI")])
2501
2502 (define_insn_and_split "*kortest_cmp<SWI1248_AVX512BWDQ_64:mode>_mov<SWI248:mode>cc"
2503 [(set (match_operand:SWI248 0 "register_operand" "=r,r,r,r,r,r,r,r")
2504 (if_then_else:SWI248
2505 (match_operator 1 "bt_comparison_operator"
2506 [(match_operand:SWI1248_AVX512BWDQ_64 4 "register_operand"
2507 "?k,<SWI1248_AVX512BWDQ_64:r>,?k, <SWI1248_AVX512BWDQ_64:r>,?k,r,?k, r")
2508 (const_int -1)])
2509 (match_operand:SWI248 2 "nonimmediate_operand" "rm,rm, 0, 0,rm,rm, r, r")
2510 (match_operand:SWI248 3 "nonimmediate_operand" " 0, 0,rm,rm, r, r,rm,rm")))
2511 (clobber (reg:CC FLAGS_REG))]
2512 "TARGET_AVX512BW && TARGET_CMOVE
2513 && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
2514 "#"
2515 "&& reload_completed"
2516 [(set (match_dup 0)
2517 (if_then_else:SWI248
2518 (match_dup 5)
2519 (match_dup 2)
2520 (match_dup 3)))]
2521 {
2522 rtx flag_reg;
2523 if (MASK_REGNO_P (REGNO (operands[4])))
2524 {
2525 emit_insn (gen_kortest<SWI1248_AVX512BWDQ_64:mode>_ccc (operands[4], operands[4]));
2526 flag_reg = gen_rtx_REG (CCCmode, FLAGS_REG);
2527 }
2528 else
2529 {
2530 flag_reg = gen_rtx_REG (CCZmode, FLAGS_REG);
2531 emit_insn (gen_rtx_SET (flag_reg,
2532 gen_rtx_COMPARE (CCZmode,
2533 operands[4],
2534 constm1_rtx)));
2535 }
2536 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[1]), VOIDmode,
2537 flag_reg,const0_rtx);
2538 }
2539 [(set_attr "isa" "*,*,*,*,apx_ndd,apx_ndd,apx_ndd,apx_ndd")
2540 (set_attr "type" "icmov")
2541 (set_attr "mode" "<SWI248:MODE>")])
2542
2543 (define_insn "kunpckhi"
2544 [(set (match_operand:HI 0 "register_operand" "=k")
2545 (ior:HI
2546 (ashift:HI
2547 (zero_extend:HI (match_operand:QI 1 "register_operand" "k"))
2548 (const_int 8))
2549 (zero_extend:HI (match_operand:QI 2 "register_operand" "k"))))
2550 (unspec [(const_int 0)] UNSPEC_MASKOP)]
2551 "TARGET_AVX512F"
2552 "kunpckbw\t{%2, %1, %0|%0, %1, %2}"
2553 [(set_attr "mode" "HI")
2554 (set_attr "type" "msklog")
2555 (set_attr "prefix" "vex")])
2556
2557 (define_insn "kunpcksi"
2558 [(set (match_operand:SI 0 "register_operand" "=k")
2559 (ior:SI
2560 (ashift:SI
2561 (zero_extend:SI (match_operand:HI 1 "register_operand" "k"))
2562 (const_int 16))
2563 (zero_extend:SI (match_operand:HI 2 "register_operand" "k"))))
2564 (unspec [(const_int 0)] UNSPEC_MASKOP)]
2565 "TARGET_AVX512BW"
2566 "kunpckwd\t{%2, %1, %0|%0, %1, %2}"
2567 [(set_attr "mode" "SI")])
2568
2569 (define_insn "kunpckdi"
2570 [(set (match_operand:DI 0 "register_operand" "=k")
2571 (ior:DI
2572 (ashift:DI
2573 (zero_extend:DI (match_operand:SI 1 "register_operand" "k"))
2574 (const_int 32))
2575 (zero_extend:DI (match_operand:SI 2 "register_operand" "k"))))
2576 (unspec [(const_int 0)] UNSPEC_MASKOP)]
2577 "TARGET_AVX512BW"
2578 "kunpckdq\t{%2, %1, %0|%0, %1, %2}"
2579 [(set_attr "mode" "DI")])
2580
2581
2582 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2583 ;;
2584 ;; Parallel floating point arithmetic
2585 ;;
2586 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2587
2588 (define_expand "<code><mode>2"
2589 [(set (match_operand:VFB 0 "register_operand")
2590 (absneg:VFB
2591 (match_operand:VFB 1 "register_operand")))]
2592 "TARGET_SSE"
2593 "ix86_expand_fp_absneg_operator (<CODE>, <MODE>mode, operands); DONE;")
2594
2595 (define_insn_and_split "*<code><mode>2"
2596 [(set (match_operand:VFB 0 "register_operand" "=x,x,v,v")
2597 (absneg:VFB
2598 (match_operand:VFB 1 "vector_operand" "0,xBm,v,m")))
2599 (use (match_operand:VFB 2 "vector_operand" "xBm,0,vm,v"))]
2600 "TARGET_SSE"
2601 "#"
2602 "&& reload_completed"
2603 [(set (match_dup 0)
2604 (<absneg_op>:VFB (match_dup 1) (match_dup 2)))]
2605 {
2606 if (TARGET_AVX)
2607 {
2608 if (MEM_P (operands[1]))
2609 std::swap (operands[1], operands[2]);
2610 }
2611 else
2612 {
2613 if (operands_match_p (operands[0], operands[2]))
2614 std::swap (operands[1], operands[2]);
2615 }
2616 }
2617 [(set_attr "isa" "noavx,noavx,avx,avx")])
2618
2619 (define_insn_and_split "*nabs<mode>2"
2620 [(set (match_operand:VF 0 "register_operand" "=x,x,v,v")
2621 (neg:VF
2622 (abs:VF
2623 (match_operand:VF 1 "vector_operand" "0,xBm,v,m"))))
2624 (use (match_operand:VF 2 "vector_operand" "xBm,0,vm,v"))]
2625 "TARGET_SSE"
2626 "#"
2627 "&& reload_completed"
2628 [(set (match_dup 0)
2629 (ior:VF (match_dup 1) (match_dup 2)))]
2630 {
2631 if (TARGET_AVX)
2632 {
2633 if (MEM_P (operands[1]))
2634 std::swap (operands[1], operands[2]);
2635 }
2636 else
2637 {
2638 if (operands_match_p (operands[0], operands[2]))
2639 std::swap (operands[1], operands[2]);
2640 }
2641 }
2642 [(set_attr "isa" "noavx,noavx,avx,avx")])
2643
2644 (define_expand "cond_<insn><mode>"
2645 [(set (match_operand:VFH 0 "register_operand")
2646 (vec_merge:VFH
2647 (plusminus:VFH
2648 (match_operand:VFH 2 "vector_operand")
2649 (match_operand:VFH 3 "vector_operand"))
2650 (match_operand:VFH 4 "nonimm_or_0_operand")
2651 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
2652 "<MODE_SIZE> == 64 || TARGET_AVX512VL"
2653 {
2654 emit_insn (gen_<insn><mode>3_mask (operands[0],
2655 operands[2],
2656 operands[3],
2657 operands[4],
2658 operands[1]));
2659 DONE;
2660 })
2661
2662 (define_expand "<insn><mode>3<mask_name><round_name>"
2663 [(set (match_operand:VF_BHSD 0 "register_operand")
2664 (plusminus:VF_BHSD
2665 (match_operand:VF_BHSD 1 "<round_nimm_predicate>")
2666 (match_operand:VF_BHSD 2 "<round_nimm_predicate>")))]
2667 "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
2668 "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
2669
2670 (define_insn "*<insn><mode>3<mask_name><round_name>"
2671 [(set (match_operand:VFH 0 "register_operand" "=x,v")
2672 (plusminus:VFH
2673 (match_operand:VFH 1 "<bcst_round_nimm_predicate>" "<comm>0,v")
2674 (match_operand:VFH 2 "<bcst_round_nimm_predicate>" "xBm,<bcst_round_constraint>")))]
2675 "TARGET_SSE && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)
2676 && <mask_mode512bit_condition> && <round_mode512bit_condition>"
2677 "@
2678 <plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
2679 v<plusminus_mnemonic><ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
2680 [(set_attr "isa" "noavx,avx")
2681 (set_attr "type" "sseadd")
2682 (set_attr "prefix" "<bcst_mask_prefix3>")
2683 (set_attr "mode" "<MODE>")])
2684
2685 ;; Standard scalar operation patterns which preserve the rest of the
2686 ;; vector for combiner.
2687 (define_insn "*<sse>_vm<insn><mode>3"
2688 [(set (match_operand:VFH_128 0 "register_operand" "=x,v")
2689 (vec_merge:VFH_128
2690 (vec_duplicate:VFH_128
2691 (plusminus:<ssescalarmode>
2692 (vec_select:<ssescalarmode>
2693 (match_operand:VFH_128 1 "register_operand" "0,v")
2694 (parallel [(const_int 0)]))
2695 (match_operand:<ssescalarmode> 2 "nonimmediate_operand" "xm,vm")))
2696 (match_dup 1)
2697 (const_int 1)))]
2698 "TARGET_SSE"
2699 "@
2700 <plusminus_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %2}
2701 v<plusminus_mnemonic><ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2702 [(set_attr "isa" "noavx,avx")
2703 (set_attr "type" "sseadd")
2704 (set (attr "prefix")
2705 (cond [(eq_attr "alternative" "0")
2706 (const_string "orig")
2707 (eq_attr "alternative" "1")
2708 (if_then_else
2709 (match_test "<MODE>mode == V8HFmode")
2710 (const_string "evex")
2711 (const_string "vex"))
2712 ]
2713 (const_string "*")))
2714 (set_attr "mode" "<ssescalarmode>")])
2715
2716 (define_insn "<sse>_vm<insn><mode>3<mask_scalar_name><round_scalar_name>"
2717 [(set (match_operand:VFH_128 0 "register_operand" "=x,v")
2718 (vec_merge:VFH_128
2719 (plusminus:VFH_128
2720 (match_operand:VFH_128 1 "register_operand" "0,v")
2721 (match_operand:VFH_128 2 "nonimmediate_operand" "xm,<round_scalar_constraint>"))
2722 (match_dup 1)
2723 (const_int 1)))]
2724 "TARGET_SSE"
2725 "@
2726 <plusminus_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
2727 v<plusminus_mnemonic><ssescalarmodesuffix>\t{<round_scalar_mask_op3>%2, %1, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %1, %<iptr>2<round_scalar_mask_op3>}"
2728 [(set_attr "isa" "noavx,avx")
2729 (set_attr "type" "sseadd")
2730 (set_attr "prefix" "<round_scalar_prefix>")
2731 (set_attr "mode" "<ssescalarmode>")])
2732
2733 (define_expand "cond_mul<mode>"
2734 [(set (match_operand:VFH 0 "register_operand")
2735 (vec_merge:VFH
2736 (mult:VFH
2737 (match_operand:VFH 2 "vector_operand")
2738 (match_operand:VFH 3 "vector_operand"))
2739 (match_operand:VFH 4 "nonimm_or_0_operand")
2740 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
2741 "<MODE_SIZE> == 64 || TARGET_AVX512VL"
2742 {
2743 emit_insn (gen_mul<mode>3_mask (operands[0],
2744 operands[2],
2745 operands[3],
2746 operands[4],
2747 operands[1]));
2748 DONE;
2749 })
2750
2751 (define_expand "mul<mode>3<mask_name><round_name>"
2752 [(set (match_operand:VF_BHSD 0 "register_operand")
2753 (mult:VF_BHSD
2754 (match_operand:VF_BHSD 1 "<round_nimm_predicate>")
2755 (match_operand:VF_BHSD 2 "<round_nimm_predicate>")))]
2756 "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
2757 "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
2758
2759 (define_insn "*mul<mode>3<mask_name><round_name>"
2760 [(set (match_operand:VFH 0 "register_operand" "=x,v")
2761 (mult:VFH
2762 (match_operand:VFH 1 "<bcst_round_nimm_predicate>" "%0,v")
2763 (match_operand:VFH 2 "<bcst_round_nimm_predicate>" "xBm,<bcst_round_constraint>")))]
2764 "TARGET_SSE && ix86_binary_operator_ok (MULT, <MODE>mode, operands)
2765 && <mask_mode512bit_condition> && <round_mode512bit_condition>"
2766 "@
2767 mul<ssemodesuffix>\t{%2, %0|%0, %2}
2768 vmul<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
2769 [(set_attr "isa" "noavx,avx")
2770 (set_attr "type" "ssemul")
2771 (set_attr "prefix" "<bcst_mask_prefix3>")
2772 (set_attr "btver2_decode" "direct,double")
2773 (set_attr "mode" "<MODE>")])
2774
2775 ;; Standard scalar operation patterns which preserve the rest of the
2776 ;; vector for combiner.
2777 (define_insn "*<sse>_vm<multdiv_mnemonic><mode>3"
2778 [(set (match_operand:VFH_128 0 "register_operand" "=x,v")
2779 (vec_merge:VFH_128
2780 (vec_duplicate:VFH_128
2781 (multdiv:<ssescalarmode>
2782 (vec_select:<ssescalarmode>
2783 (match_operand:VFH_128 1 "register_operand" "0,v")
2784 (parallel [(const_int 0)]))
2785 (match_operand:<ssescalarmode> 2 "nonimmediate_operand" "xm,vm")))
2786 (match_dup 1)
2787 (const_int 1)))]
2788 "TARGET_SSE"
2789 "@
2790 <multdiv_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %2}
2791 v<multdiv_mnemonic><ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2792 [(set_attr "isa" "noavx,avx")
2793 (set_attr "type" "sse<multdiv_mnemonic>")
2794 (set (attr "prefix")
2795 (cond [(eq_attr "alternative" "0")
2796 (const_string "orig")
2797 (eq_attr "alternative" "1")
2798 (if_then_else
2799 (match_test "<MODE>mode == V8HFmode")
2800 (const_string "evex")
2801 (const_string "vex"))
2802 ]
2803 (const_string "*")))
2804 (set_attr "btver2_decode" "direct,double")
2805 (set_attr "mode" "<ssescalarmode>")])
2806
2807 (define_insn "<sse>_vm<multdiv_mnemonic><mode>3<mask_scalar_name><round_scalar_name>"
2808 [(set (match_operand:VFH_128 0 "register_operand" "=x,v")
2809 (vec_merge:VFH_128
2810 (multdiv:VFH_128
2811 (match_operand:VFH_128 1 "register_operand" "0,v")
2812 (match_operand:VFH_128 2 "nonimmediate_operand" "xm,<round_scalar_constraint>"))
2813 (match_dup 1)
2814 (const_int 1)))]
2815 "TARGET_SSE"
2816 "@
2817 <multdiv_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
2818 v<multdiv_mnemonic><ssescalarmodesuffix>\t{<round_scalar_mask_op3>%2, %1, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %1, %<iptr>2<round_scalar_mask_op3>}"
2819 [(set_attr "isa" "noavx,avx")
2820 (set_attr "type" "sse<multdiv_mnemonic>")
2821 (set_attr "prefix" "<round_scalar_prefix>")
2822 (set_attr "btver2_decode" "direct,double")
2823 (set_attr "mode" "<ssescalarmode>")])
2824
2825 (define_expand "div<mode>3"
2826 [(set (match_operand:VF2 0 "register_operand")
2827 (div:VF2 (match_operand:VF2 1 "register_operand")
2828 (match_operand:VF2 2 "vector_operand")))]
2829 "TARGET_SSE2")
2830
2831 (define_expand "div<mode>3"
2832 [(set (match_operand:VHF_AVX512VL 0 "register_operand")
2833 (div:VHF_AVX512VL
2834 (match_operand:VHF_AVX512VL 1 "register_operand")
2835 (match_operand:VHF_AVX512VL 2 "vector_operand")))]
2836 "TARGET_AVX512FP16"
2837 {
2838 /* Transform HF vector div to vector mul/rcp. */
2839 if (GET_MODE_INNER (<MODE>mode) == HFmode
2840 && TARGET_RECIP_VEC_DIV
2841 && optimize_insn_for_speed_p ()
2842 && flag_finite_math_only && !flag_trapping_math
2843 && flag_unsafe_math_optimizations)
2844 {
2845 rtx op = gen_reg_rtx (<MODE>mode);
2846 operands[2] = force_reg (<MODE>mode, operands[2]);
2847 emit_insn (gen_avx512fp16_rcp<mode>2 (op, operands[2]));
2848 emit_insn (gen_mul<mode>3 (operands[0], operands[1], op));
2849 DONE;
2850 }
2851 })
2852
2853 (define_expand "div<mode>3"
2854 [(set (match_operand:VF1 0 "register_operand")
2855 (div:VF1 (match_operand:VF1 1 "register_operand")
2856 (match_operand:VF1 2 "vector_operand")))]
2857 "TARGET_SSE"
2858 {
2859 if (TARGET_SSE_MATH
2860 && TARGET_RECIP_VEC_DIV
2861 && !optimize_insn_for_size_p ()
2862 && flag_finite_math_only && !flag_trapping_math
2863 && flag_unsafe_math_optimizations)
2864 {
2865 ix86_emit_swdivsf (operands[0], operands[1], operands[2], <MODE>mode);
2866 DONE;
2867 }
2868 })
2869
2870 (define_expand "div<mode>3"
2871 [(set (match_operand:VBF_AVX10_2 0 "register_operand")
2872 (div:VBF_AVX10_2
2873 (match_operand:VBF_AVX10_2 1 "register_operand")
2874 (match_operand:VBF_AVX10_2 2 "vector_operand")))]
2875 "TARGET_AVX10_2"
2876 {
2877 if (TARGET_RECIP_VEC_DIV
2878 && optimize_insn_for_speed_p ()
2879 && flag_finite_math_only
2880 && flag_unsafe_math_optimizations)
2881 {
2882 rtx op = gen_reg_rtx (<MODE>mode);
2883 operands[2] = force_reg (<MODE>mode, operands[2]);
2884 emit_insn (gen_avx10_2_rcpbf16_<mode> (op, operands[2]));
2885 emit_insn (gen_avx10_2_mulbf16_<mode> (operands[0], operands[1], op));
2886 DONE;
2887 }
2888 })
2889
2890 (define_expand "cond_div<mode>"
2891 [(set (match_operand:VFH 0 "register_operand")
2892 (vec_merge:VFH
2893 (div:VFH
2894 (match_operand:VFH 2 "register_operand")
2895 (match_operand:VFH 3 "vector_operand"))
2896 (match_operand:VFH 4 "nonimm_or_0_operand")
2897 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
2898 "<MODE_SIZE> == 64 || TARGET_AVX512VL"
2899 {
2900 emit_insn (gen_<sse>_div<mode>3_mask (operands[0],
2901 operands[2],
2902 operands[3],
2903 operands[4],
2904 operands[1]));
2905 DONE;
2906 })
2907
2908 (define_insn "<sse>_div<mode>3<mask_name><round_name>"
2909 [(set (match_operand:VFH 0 "register_operand" "=x,v")
2910 (div:VFH
2911 (match_operand:VFH 1 "register_operand" "0,v")
2912 (match_operand:VFH 2 "<bcst_round_nimm_predicate>" "xBm,<bcst_round_constraint>")))]
2913 "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
2914 "@
2915 div<ssemodesuffix>\t{%2, %0|%0, %2}
2916 vdiv<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
2917 [(set_attr "isa" "noavx,avx")
2918 (set_attr "type" "ssediv")
2919 (set_attr "prefix" "<bcst_mask_prefix3>")
2920 (set_attr "mode" "<MODE>")])
2921
2922 (define_insn "<sse>_rcp<mode>2"
2923 [(set (match_operand:VF1_128_256 0 "register_operand" "=x,x")
2924 (unspec:VF1_128_256
2925 [(match_operand:VF1_128_256 1 "vector_operand" "xBm,xja")] UNSPEC_RCP))]
2926 "TARGET_SSE"
2927 "%vrcpps\t{%1, %0|%0, %1}"
2928 [(set_attr "isa" "noavx,avx")
2929 (set_attr "type" "sse")
2930 (set_attr "addr" "*,gpr16")
2931 (set_attr "atom_sse_attr" "rcp")
2932 (set_attr "btver2_sse_attr" "rcp")
2933 (set_attr "c86_attr" "rcp")
2934 (set_attr "prefix" "maybe_vex")
2935 (set_attr "mode" "<MODE>")])
2936
2937 (define_insn "sse_vmrcpv4sf2"
2938 [(set (match_operand:V4SF 0 "register_operand" "=x,x")
2939 (vec_merge:V4SF
2940 (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,xjm")]
2941 UNSPEC_RCP)
2942 (match_operand:V4SF 2 "register_operand" "0,x")
2943 (const_int 1)))]
2944 "TARGET_SSE"
2945 "@
2946 rcpss\t{%1, %0|%0, %k1}
2947 vrcpss\t{%1, %2, %0|%0, %2, %k1}"
2948 [(set_attr "isa" "noavx,avx")
2949 (set_attr "type" "sse")
2950 (set_attr "addr" "*,gpr16")
2951 (set_attr "atom_sse_attr" "rcp")
2952 (set_attr "btver2_sse_attr" "rcp")
2953 (set_attr "c86_attr" "rcp")
2954 (set_attr "prefix" "orig,vex")
2955 (set_attr "mode" "SF")])
2956
2957 (define_insn "*sse_vmrcpv4sf2"
2958 [(set (match_operand:V4SF 0 "register_operand" "=x,x")
2959 (vec_merge:V4SF
2960 (vec_duplicate:V4SF
2961 (unspec:SF [(match_operand:SF 1 "nonimmediate_operand" "xm,xjm")]
2962 UNSPEC_RCP))
2963 (match_operand:V4SF 2 "register_operand" "0,x")
2964 (const_int 1)))]
2965 "TARGET_SSE"
2966 "@
2967 rcpss\t{%1, %0|%0, %1}
2968 vrcpss\t{%1, %2, %0|%0, %2, %1}"
2969 [(set_attr "isa" "noavx,avx")
2970 (set_attr "type" "sse")
2971 (set_attr "addr" "*,gpr16")
2972 (set_attr "atom_sse_attr" "rcp")
2973 (set_attr "btver2_sse_attr" "rcp")
2974 (set_attr "c86_attr" "rcp")
2975 (set_attr "prefix" "orig,vex")
2976 (set_attr "mode" "SF")])
2977
2978 (define_insn "avx512fp16_rcp<mode>2<mask_name>"
2979 [(set (match_operand:VHF_AVX512VL 0 "register_operand" "=v")
2980 (unspec:VHF_AVX512VL
2981 [(match_operand:VHF_AVX512VL 1 "nonimmediate_operand" "vm")]
2982 UNSPEC_RCP))]
2983 "TARGET_AVX512FP16"
2984 "vrcpph\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
2985 [(set_attr "type" "sse")
2986 (set_attr "prefix" "evex")
2987 (set_attr "mode" "<MODE>")])
2988
2989 (define_insn "avx512fp16_vmrcpv8hf2<mask_scalar_name>"
2990 [(set (match_operand:V8HF 0 "register_operand" "=v")
2991 (vec_merge:V8HF
2992 (unspec:V8HF [(match_operand:V8HF 1 "nonimmediate_operand" "vm")]
2993 UNSPEC_RCP)
2994 (match_operand:V8HF 2 "register_operand" "v")
2995 (const_int 1)))]
2996 "TARGET_AVX512FP16"
2997 "vrcpsh\t{%1, %2, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %2, %w1}"
2998 [(set_attr "type" "sse")
2999 (set_attr "prefix" "evex")
3000 (set_attr "mode" "HF")])
3001
3002 (define_insn "*avx512fp16_vmrcpv8hf2"
3003 [(set (match_operand:V8HF 0 "register_operand" "=v")
3004 (vec_merge:V8HF
3005 (vec_duplicate:V8HF
3006 (unspec:HF [(match_operand:HF 1 "nonimmediate_operand" "vm")]
3007 UNSPEC_RCP))
3008 (match_operand:V8HF 2 "register_operand" "v")
3009 (const_int 1)))]
3010 "TARGET_AVX512FP16"
3011 "vrcpsh\t{%1, %2, %0|%0, %2, %w1}"
3012 [(set_attr "type" "sse")
3013 (set_attr "prefix" "evex")
3014 (set_attr "mode" "HF")])
3015
3016 (define_insn "<mask_codefor>rcp14<mode><mask_name>"
3017 [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3018 (unspec:VF_AVX512VL
3019 [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")]
3020 UNSPEC_RCP14))]
3021 "TARGET_AVX512F"
3022 "vrcp14<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
3023 [(set_attr "type" "sse")
3024 (set_attr "c86_attr" "rcp")
3025 (set_attr "prefix" "evex")
3026 (set_attr "mode" "<MODE>")])
3027
3028 (define_insn "srcp14<mode>"
3029 [(set (match_operand:VF_128 0 "register_operand" "=v")
3030 (vec_merge:VF_128
3031 (unspec:VF_128
3032 [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
3033 UNSPEC_RCP14)
3034 (match_operand:VF_128 2 "register_operand" "v")
3035 (const_int 1)))]
3036 "TARGET_AVX512F"
3037 "vrcp14<ssescalarmodesuffix>\t{%1, %2, %0|%0, %2, %<iptr>1}"
3038 [(set_attr "type" "sse")
3039 (set_attr "c86_attr" "rcp")
3040 (set_attr "prefix" "evex")
3041 (set_attr "mode" "<MODE>")])
3042
3043 (define_insn "srcp14<mode>_mask"
3044 [(set (match_operand:VF_128 0 "register_operand" "=v")
3045 (vec_merge:VF_128
3046 (vec_merge:VF_128
3047 (unspec:VF_128
3048 [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
3049 UNSPEC_RCP14)
3050 (match_operand:VF_128 3 "nonimm_or_0_operand" "0C")
3051 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk"))
3052 (match_operand:VF_128 2 "register_operand" "v")
3053 (const_int 1)))]
3054 "TARGET_AVX512F"
3055 "vrcp14<ssescalarmodesuffix>\t{%1, %2, %0%{%4%}%N3|%0%{%4%}%N3, %2, %<iptr>1}"
3056 [(set_attr "type" "sse")
3057 (set_attr "c86_attr" "rcp")
3058 (set_attr "prefix" "evex")
3059 (set_attr "mode" "<MODE>")])
3060
3061 (define_expand "sqrt<mode>2"
3062 [(set (match_operand:VF2HB 0 "register_operand")
3063 (sqrt:VF2HB (match_operand:VF2HB 1 "vector_operand")))]
3064 "TARGET_SSE2")
3065
3066 (define_expand "sqrt<mode>2"
3067 [(set (match_operand:VF1 0 "register_operand")
3068 (sqrt:VF1 (match_operand:VF1 1 "vector_operand")))]
3069 "TARGET_SSE"
3070 {
3071 if (TARGET_SSE_MATH
3072 && TARGET_RECIP_VEC_SQRT
3073 && !optimize_insn_for_size_p ()
3074 && flag_finite_math_only && !flag_trapping_math
3075 && flag_unsafe_math_optimizations)
3076 {
3077 ix86_emit_swsqrtsf (operands[0], operands[1], <MODE>mode, false);
3078 DONE;
3079 }
3080 })
3081
3082 (define_insn "<sse>_sqrt<mode>2<mask_name><round_name>"
3083 [(set (match_operand:VFH 0 "register_operand" "=x,v")
3084 (sqrt:VFH (match_operand:VFH 1 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
3085 "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
3086 "@
3087 sqrt<ssemodesuffix>\t{%1, %0|%0, %1}
3088 vsqrt<ssemodesuffix>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
3089 [(set_attr "isa" "noavx,avx")
3090 (set_attr "type" "sse")
3091 (set_attr "atom_sse_attr" "sqrt")
3092 (set_attr "btver2_sse_attr" "sqrt")
3093 (set_attr "c86_attr" "sqrt")
3094 (set_attr "prefix" "maybe_vex")
3095 (set_attr "mode" "<MODE>")])
3096
3097 (define_insn "<sse>_vmsqrt<mode>2<mask_scalar_name><round_scalar_name>"
3098 [(set (match_operand:VFH_128 0 "register_operand" "=x,v")
3099 (vec_merge:VFH_128
3100 (sqrt:VFH_128
3101 (match_operand:VFH_128 1 "nonimmediate_operand" "xm,<round_scalar_constraint>"))
3102 (match_operand:VFH_128 2 "register_operand" "0,v")
3103 (const_int 1)))]
3104 "TARGET_SSE"
3105 "@
3106 sqrt<ssescalarmodesuffix>\t{%1, %0|%0, %<iptr>1}
3107 vsqrt<ssescalarmodesuffix>\t{<round_scalar_mask_op3>%1, %2, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %2, %<iptr>1<round_scalar_mask_op3>}"
3108 [(set_attr "isa" "noavx,avx")
3109 (set_attr "type" "sse")
3110 (set_attr "atom_sse_attr" "sqrt")
3111 (set_attr "prefix" "<round_scalar_prefix>")
3112 (set_attr "btver2_sse_attr" "sqrt")
3113 (set_attr "c86_attr" "sqrt")
3114 (set_attr "mode" "<ssescalarmode>")])
3115
3116 (define_insn "*<sse>_vmsqrt<mode>2<mask_scalar_name><round_scalar_name>"
3117 [(set (match_operand:VFH_128 0 "register_operand" "=x,v")
3118 (vec_merge:VFH_128
3119 (vec_duplicate:VFH_128
3120 (sqrt:<ssescalarmode>
3121 (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "xm,<round_scalar_constraint>")))
3122 (match_operand:VFH_128 2 "register_operand" "0,v")
3123 (const_int 1)))]
3124 "TARGET_SSE"
3125 "@
3126 sqrt<ssescalarmodesuffix>\t{%1, %0|%0, %1}
3127 vsqrt<ssescalarmodesuffix>\t{<round_scalar_mask_op3>%1, %2, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %2, %1<round_scalar_mask_op3>}"
3128 [(set_attr "isa" "noavx,avx")
3129 (set_attr "type" "sse")
3130 (set_attr "atom_sse_attr" "sqrt")
3131 (set_attr "prefix" "<round_scalar_prefix>")
3132 (set_attr "btver2_sse_attr" "sqrt")
3133 (set_attr "c86_attr" "sqrt")
3134 (set_attr "mode" "<ssescalarmode>")])
3135
3136 (define_expand "rsqrt<mode>2"
3137 [(set (match_operand:VF1_128_256 0 "register_operand")
3138 (unspec:VF1_128_256
3139 [(match_operand:VF1_128_256 1 "vector_operand")]
3140 UNSPEC_RSQRT))]
3141 "TARGET_SSE && TARGET_SSE_MATH"
3142 {
3143 ix86_emit_swsqrtsf (operands[0], operands[1], <MODE>mode, true);
3144 DONE;
3145 })
3146
3147 (define_expand "rsqrt<mode>2"
3148 [(set (match_operand:VHF_AVX512VL 0 "register_operand")
3149 (unspec:VHF_AVX512VL
3150 [(match_operand:VHF_AVX512VL 1 "vector_operand")]
3151 UNSPEC_RSQRT))]
3152 "TARGET_AVX512FP16")
3153
3154 (define_insn "<sse>_rsqrt<mode>2"
3155 [(set (match_operand:VF1_128_256 0 "register_operand" "=x,x")
3156 (unspec:VF1_128_256
3157 [(match_operand:VF1_128_256 1 "vector_operand" "xBm,xja")] UNSPEC_RSQRT))]
3158 "TARGET_SSE"
3159 "%vrsqrtps\t{%1, %0|%0, %1}"
3160 [(set_attr "isa" "noavx,avx")
3161 (set_attr "type" "sse")
3162 (set_attr "addr" "*,gpr16")
3163 (set_attr "prefix" "maybe_vex")
3164 (set_attr "mode" "<MODE>")])
3165
3166 (define_insn "<sse>_rsqrt<mode>2<mask_name>"
3167 [(set (match_operand:VHF_AVX512VL 0 "register_operand" "=v")
3168 (unspec:VHF_AVX512VL
3169 [(match_operand:VHF_AVX512VL 1 "vector_operand" "vBm")] UNSPEC_RSQRT))]
3170 "TARGET_AVX512FP16"
3171 "vrsqrtph\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
3172 [(set_attr "type" "sse")
3173 (set_attr "prefix" "evex")
3174 (set_attr "mode" "<MODE>")])
3175
3176 (define_insn "<mask_codefor>rsqrt14<mode><mask_name>"
3177 [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3178 (unspec:VF_AVX512VL
3179 [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")]
3180 UNSPEC_RSQRT14))]
3181 "TARGET_AVX512F"
3182 "vrsqrt14<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
3183 [(set_attr "type" "sse")
3184 (set_attr "c86_attr" "rcp")
3185 (set_attr "prefix" "evex")
3186 (set_attr "mode" "<MODE>")])
3187
3188 (define_insn "rsqrt14<mode>"
3189 [(set (match_operand:VF_128 0 "register_operand" "=v")
3190 (vec_merge:VF_128
3191 (unspec:VF_128
3192 [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
3193 UNSPEC_RSQRT14)
3194 (match_operand:VF_128 2 "register_operand" "v")
3195 (const_int 1)))]
3196 "TARGET_AVX512F"
3197 "vrsqrt14<ssescalarmodesuffix>\t{%1, %2, %0|%0, %2, %<iptr>1}"
3198 [(set_attr "type" "sse")
3199 (set_attr "c86_attr" "rcp")
3200 (set_attr "prefix" "evex")
3201 (set_attr "mode" "<MODE>")])
3202
3203 (define_insn "rsqrt14_<mode>_mask"
3204 [(set (match_operand:VF_128 0 "register_operand" "=v")
3205 (vec_merge:VF_128
3206 (vec_merge:VF_128
3207 (unspec:VF_128
3208 [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
3209 UNSPEC_RSQRT14)
3210 (match_operand:VF_128 3 "nonimm_or_0_operand" "0C")
3211 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk"))
3212 (match_operand:VF_128 2 "register_operand" "v")
3213 (const_int 1)))]
3214 "TARGET_AVX512F"
3215 "vrsqrt14<ssescalarmodesuffix>\t{%1, %2, %0%{%4%}%N3|%0%{%4%}%N3, %2, %<iptr>1}"
3216 [(set_attr "type" "sse")
3217 (set_attr "c86_attr" "rcp")
3218 (set_attr "prefix" "evex")
3219 (set_attr "mode" "<MODE>")])
3220
3221 (define_insn "sse_vmrsqrtv4sf2"
3222 [(set (match_operand:V4SF 0 "register_operand" "=x,x")
3223 (vec_merge:V4SF
3224 (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,xjm")]
3225 UNSPEC_RSQRT)
3226 (match_operand:V4SF 2 "register_operand" "0,x")
3227 (const_int 1)))]
3228 "TARGET_SSE"
3229 "@
3230 rsqrtss\t{%1, %0|%0, %k1}
3231 vrsqrtss\t{%1, %2, %0|%0, %2, %k1}"
3232 [(set_attr "isa" "noavx,avx")
3233 (set_attr "type" "sse")
3234 (set_attr "addr" "*,gpr16")
3235 (set_attr "prefix" "orig,vex")
3236 (set_attr "mode" "SF")])
3237
3238 (define_insn "*sse_vmrsqrtv4sf2"
3239 [(set (match_operand:V4SF 0 "register_operand" "=x,x")
3240 (vec_merge:V4SF
3241 (vec_duplicate:V4SF
3242 (unspec:SF [(match_operand:SF 1 "nonimmediate_operand" "xm,xjm")]
3243 UNSPEC_RSQRT))
3244 (match_operand:V4SF 2 "register_operand" "0,x")
3245 (const_int 1)))]
3246 "TARGET_SSE"
3247 "@
3248 rsqrtss\t{%1, %0|%0, %1}
3249 vrsqrtss\t{%1, %2, %0|%0, %2, %1}"
3250 [(set_attr "isa" "noavx,avx")
3251 (set_attr "type" "sse")
3252 (set_attr "addr" "*,gpr16")
3253 (set_attr "prefix" "orig,vex")
3254 (set_attr "mode" "SF")])
3255
3256 (define_insn "avx512fp16_vmrsqrtv8hf2<mask_scalar_name>"
3257 [(set (match_operand:V8HF 0 "register_operand" "=v")
3258 (vec_merge:V8HF
3259 (unspec:V8HF [(match_operand:V8HF 1 "nonimmediate_operand" "vm")]
3260 UNSPEC_RSQRT)
3261 (match_operand:V8HF 2 "register_operand" "v")
3262 (const_int 1)))]
3263 "TARGET_AVX512FP16"
3264 "vrsqrtsh\t{%1, %2, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %2, %w1}"
3265 [(set_attr "type" "sse")
3266 (set_attr "prefix" "evex")
3267 (set_attr "mode" "HF")])
3268
3269 (define_insn "*avx512fp16_vmrsqrtv8hf2"
3270 [(set (match_operand:V8HF 0 "register_operand" "=v")
3271 (vec_merge:V8HF
3272 (vec_duplicate:V8HF
3273 (unspec:HF [(match_operand:HF 1 "nonimmediate_operand" "vm")]
3274 UNSPEC_RSQRT))
3275 (match_operand:V8HF 2 "register_operand" "v")
3276 (const_int 1)))]
3277 "TARGET_AVX512FP16"
3278 "vrsqrtsh\t{%1, %2, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %2, %w1}"
3279 [(set_attr "type" "sse")
3280 (set_attr "prefix" "evex")
3281 (set_attr "mode" "HF")])
3282
3283 (define_expand "cond_<code><mode>"
3284 [(set (match_operand:VFH 0 "register_operand")
3285 (vec_merge:VFH
3286 (smaxmin:VFH
3287 (match_operand:VFH 2 "vector_operand")
3288 (match_operand:VFH 3 "vector_operand"))
3289 (match_operand:VFH 4 "nonimm_or_0_operand")
3290 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
3291 "<MODE_SIZE> == 64 || TARGET_AVX512VL"
3292 {
3293 emit_insn (gen_<code><mode>3_mask (operands[0],
3294 operands[2],
3295 operands[3],
3296 operands[4],
3297 operands[1]));
3298 DONE;
3299 })
3300
3301 (define_expand "<code><mode>3<mask_name><round_saeonly_name>"
3302 [(set (match_operand:VFH 0 "register_operand")
3303 (smaxmin:VFH
3304 (match_operand:VFH 1 "<round_saeonly_nimm_predicate>")
3305 (match_operand:VFH 2 "<round_saeonly_nimm_predicate>")))]
3306 "TARGET_SSE && <mask_mode512bit_condition>
3307 && <round_saeonly_mode512bit_condition>"
3308 {
3309 if (!flag_finite_math_only || flag_signed_zeros)
3310 {
3311 operands[1] = force_reg (<MODE>mode, operands[1]);
3312 emit_insn (gen_ieee_<maxmin_float><mode>3<mask_name><round_saeonly_name>
3313 (operands[0], operands[1], operands[2]
3314 <mask_operand_arg34>
3315 <round_saeonly_mask_arg3>));
3316 DONE;
3317 }
3318 else
3319 ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
3320 })
3321
3322 ;; These versions of the min/max patterns are intentionally ignorant of
3323 ;; their behavior wrt -0.0 and NaN (via the commutative operand mark).
3324 ;; Since both the tree-level MAX_EXPR and the rtl-level SMAX operator
3325 ;; are undefined in this condition, we're certain this is correct.
3326
3327 (define_insn "*<code><mode>3<mask_name><round_saeonly_name>"
3328 [(set (match_operand:VFH 0 "register_operand" "=x,v")
3329 (smaxmin:VFH
3330 (match_operand:VFH 1 "<round_saeonly_nimm_predicate>" "%0,v")
3331 (match_operand:VFH 2 "<round_saeonly_nimm_predicate>" "xBm,<round_saeonly_constraint>")))]
3332 "TARGET_SSE
3333 && !(MEM_P (operands[1]) && MEM_P (operands[2]))
3334 && <mask_mode512bit_condition>
3335 && <round_saeonly_mode512bit_condition>"
3336 "@
3337 <maxmin_float><ssemodesuffix>\t{%2, %0|%0, %2}
3338 v<maxmin_float><ssemodesuffix>\t{<round_saeonly_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_saeonly_mask_op3>}"
3339 [(set_attr "isa" "noavx,avx")
3340 (set_attr "type" "sseadd")
3341 (set_attr "btver2_sse_attr" "maxmin")
3342 (set_attr "c86_attr" "maxmin")
3343 (set_attr "prefix" "<mask_prefix3>")
3344 (set_attr "mode" "<MODE>")])
3345
3346 (define_insn_and_split "*minmax<mode>3_1"
3347 [(set (match_operand:VFH 0 "register_operand")
3348 (vec_merge:VFH
3349 (match_operand:VFH 1 "nonimmediate_operand")
3350 (match_operand:VFH 2 "nonimmediate_operand")
3351 (unspec:<avx512fmaskmode>
3352 [(match_operand:VFH 3 "nonimmediate_operand")
3353 (match_operand:VFH 4 "nonimmediate_operand")
3354 (match_operand:SI 5 "const_0_to_31_operand")]
3355 UNSPEC_PCMP)))]
3356 "TARGET_SSE && ix86_pre_reload_split ()
3357 && ((rtx_equal_p (operands[1], operands[3])
3358 && rtx_equal_p (operands[2], operands[4]))
3359 || (rtx_equal_p (operands[1], operands[4])
3360 && rtx_equal_p (operands[2], operands[3])))
3361 && (INTVAL (operands[5]) == 1 || INTVAL (operands[5]) == 14)"
3362 "#"
3363 "&& 1"
3364 [(const_int 0)]
3365 {
3366 int u = UNSPEC_IEEE_MIN;
3367 if ((INTVAL (operands[5]) == 1 && rtx_equal_p (operands[1], operands[4]))
3368 || (INTVAL (operands[5]) == 14 && rtx_equal_p (operands[1], operands[3])))
3369 u = UNSPEC_IEEE_MAX;
3370
3371 if (MEM_P (operands[1]))
3372 operands[1] = force_reg (<MODE>mode, operands[1]);
3373 rtvec v = gen_rtvec (2, operands[1], operands[2]);
3374 rtx tmp = gen_rtx_UNSPEC (<MODE>mode, v, u);
3375 emit_move_insn (operands[0], tmp);
3376 DONE;
3377 })
3378
3379 (define_insn_and_split "*minmax<mode>3_2"
3380 [(set (match_operand:VF_128_256 0 "register_operand")
3381 (unspec:VF_128_256
3382 [(match_operand:VF_128_256 1 "nonimmediate_operand")
3383 (match_operand:VF_128_256 2 "nonimmediate_operand")
3384 (lt:VF_128_256
3385 (match_operand:VF_128_256 3 "nonimmediate_operand")
3386 (match_operand:VF_128_256 4 "nonimmediate_operand"))]
3387 UNSPEC_BLENDV))]
3388 "TARGET_SSE && ix86_pre_reload_split ()
3389 && ((rtx_equal_p (operands[1], operands[3])
3390 && rtx_equal_p (operands[2], operands[4]))
3391 || (rtx_equal_p (operands[1], operands[4])
3392 && rtx_equal_p (operands[2], operands[3])))"
3393 "#"
3394 "&& 1"
3395 [(const_int 0)]
3396 {
3397 int u = UNSPEC_IEEE_MIN;
3398 if (rtx_equal_p (operands[1], operands[3]))
3399 u = UNSPEC_IEEE_MAX;
3400
3401 if (MEM_P (operands[2]))
3402 operands[2] = force_reg (<MODE>mode, operands[2]);
3403 rtvec v = gen_rtvec (2, operands[2], operands[1]);
3404 rtx tmp = gen_rtx_UNSPEC (<MODE>mode, v, u);
3405 emit_move_insn (operands[0], tmp);
3406 DONE;
3407 })
3408
3409 ;; These versions of the min/max patterns implement exactly the operations
3410 ;; min = (op1 < op2 ? op1 : op2)
3411 ;; max = (!(op1 < op2) ? op1 : op2)
3412 ;; Their operands are not commutative, and thus they may be used in the
3413 ;; presence of -0.0 and NaN.
3414
3415 (define_insn "ieee_<ieee_maxmin><mode>3<mask_name><round_saeonly_name>"
3416 [(set (match_operand:VFH 0 "register_operand" "=x,v")
3417 (unspec:VFH
3418 [(match_operand:VFH 1 "register_operand" "0,v")
3419 (match_operand:VFH 2 "<round_saeonly_nimm_predicate>" "xBm,<round_saeonly_constraint>")]
3420 IEEE_MAXMIN))]
3421 "TARGET_SSE
3422 && <mask_mode512bit_condition>
3423 && <round_saeonly_mode512bit_condition>"
3424 "@
3425 <ieee_maxmin><ssemodesuffix>\t{%2, %0|%0, %2}
3426 v<ieee_maxmin><ssemodesuffix>\t{<round_saeonly_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_saeonly_mask_op3>}"
3427 [(set_attr "isa" "noavx,avx")
3428 (set_attr "type" "sseadd")
3429 (set_attr "btver2_sse_attr" "maxmin")
3430 (set_attr "c86_attr" "maxmin")
3431 (set_attr "prefix" "<mask_prefix3>")
3432 (set_attr "mode" "<MODE>")])
3433
3434 ;; Standard scalar operation patterns which preserve the rest of the
3435 ;; vector for combiner.
3436 (define_insn "*ieee_<ieee_maxmin><mode>3"
3437 [(set (match_operand:VFH_128 0 "register_operand" "=x,v")
3438 (vec_merge:VFH_128
3439 (vec_duplicate:VFH_128
3440 (unspec:<ssescalarmode>
3441 [(vec_select:<ssescalarmode>
3442 (match_operand:VFH_128 1 "register_operand" "0,v")
3443 (parallel [(const_int 0)]))
3444 (match_operand:<ssescalarmode> 2 "nonimmediate_operand" "xm,vm")]
3445 IEEE_MAXMIN))
3446 (match_dup 1)
3447 (const_int 1)))]
3448 "TARGET_SSE"
3449 "@
3450 <ieee_maxmin><ssescalarmodesuffix>\t{%2, %0|%0, %2}
3451 v<ieee_maxmin><ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %2}"
3452 [(set_attr "isa" "noavx,avx")
3453 (set_attr "type" "sseadd")
3454 (set_attr "btver2_sse_attr" "maxmin")
3455 (set_attr "c86_attr" "maxmin")
3456 (set (attr "prefix")
3457 (cond [(eq_attr "alternative" "0")
3458 (const_string "orig")
3459 (eq_attr "alternative" "1")
3460 (if_then_else
3461 (match_test "<MODE>mode == V8HFmode")
3462 (const_string "evex")
3463 (const_string "vex"))
3464 ]
3465 (const_string "*")))
3466 (set_attr "mode" "<ssescalarmode>")])
3467
3468 (define_expand "<sse>_vm<code><mode>3<mask_scalar_name><round_saeonly_scalar_name>"
3469 [(set (match_operand:VFH_128 0 "register_operand")
3470 (vec_merge:VFH_128
3471 (smaxmin:VFH_128
3472 (match_operand:VFH_128 1 "register_operand")
3473 (match_operand:VFH_128 2 "nonimmediate_operand"))
3474 (match_dup 1)
3475 (const_int 1)))]
3476 "TARGET_SSE"
3477 {
3478 if (!flag_finite_math_only || flag_signed_zeros)
3479 {
3480 emit_insn (gen_<sse>_ieee_vm<maxmin_float><mode>3<mask_scalar_name><round_saeonly_scalar_name>
3481 (operands[0], operands[1], operands[2]
3482 <mask_scalar_operand_arg34>
3483 <round_saeonly_scalar_mask_arg3>));
3484 DONE;
3485 }
3486 })
3487
3488 (define_insn "*<sse>_vm<code><mode>3<mask_scalar_name><round_saeonly_scalar_name>"
3489 [(set (match_operand:VFH_128 0 "register_operand" "=x,v")
3490 (vec_merge:VFH_128
3491 (smaxmin:VFH_128
3492 (match_operand:VFH_128 1 "register_operand" "0,v")
3493 (match_operand:VFH_128 2 "nonimmediate_operand" "xm,<round_saeonly_scalar_constraint>"))
3494 (match_dup 1)
3495 (const_int 1)))]
3496 "TARGET_SSE"
3497 "@
3498 <maxmin_float><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
3499 v<maxmin_float><ssescalarmodesuffix>\t{<round_saeonly_scalar_mask_op3>%2, %1, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %1, %<iptr>2<round_saeonly_scalar_mask_op3>}"
3500 [(set_attr "isa" "noavx,avx")
3501 (set_attr "type" "sse")
3502 (set_attr "btver2_sse_attr" "maxmin")
3503 (set_attr "c86_attr" "maxmin")
3504 (set_attr "prefix" "<round_saeonly_scalar_prefix>")
3505 (set_attr "mode" "<ssescalarmode>")])
3506
3507 (define_insn "<sse>_ieee_vm<ieee_maxmin><mode>3<mask_scalar_name><round_saeonly_scalar_name>"
3508 [(set (match_operand:VFH_128 0 "register_operand" "=x,v")
3509 (vec_merge:VFH_128
3510 (unspec:VFH_128
3511 [(match_operand:VFH_128 1 "register_operand" "0,v")
3512 (match_operand:VFH_128 2 "nonimmediate_operand" "xm,<round_saeonly_scalar_constraint>")]
3513 IEEE_MAXMIN)
3514 (match_dup 1)
3515 (const_int 1)))]
3516 "TARGET_SSE"
3517 "@
3518 <ieee_maxmin><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
3519 v<ieee_maxmin><ssescalarmodesuffix>\t{<round_saeonly_scalar_mask_op3>%2, %1, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %1, %<iptr>2<round_saeonly_scalar_mask_op3>}"
3520 [(set_attr "isa" "noavx,avx")
3521 (set_attr "type" "sse")
3522 (set_attr "btver2_sse_attr" "maxmin")
3523 (set_attr "prefix" "<round_saeonly_scalar_prefix>")
3524 (set_attr "mode" "<ssescalarmode>")])
3525
3526 (define_mode_attr addsub_cst [(V4DF "5") (V2DF "1")
3527 (V4SF "5") (V8SF "85")])
3528
3529 (define_insn "vec_addsub<mode>3"
3530 [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
3531 (vec_merge:VF_128_256
3532 (minus:VF_128_256
3533 (match_operand:VF_128_256 1 "register_operand" "0,x")
3534 (match_operand:VF_128_256 2 "vector_operand" "xBm, xjm"))
3535 (plus:VF_128_256 (match_dup 1) (match_dup 2))
3536 (const_int <addsub_cst>)))]
3537 "TARGET_SSE3"
3538 "@
3539 addsub<ssemodesuffix>\t{%2, %0|%0, %2}
3540 vaddsub<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
3541 [(set_attr "isa" "noavx,avx")
3542 (set_attr "type" "sseadd")
3543 (set_attr "addr" "*,gpr16")
3544 (set (attr "atom_unit")
3545 (if_then_else
3546 (match_test "<MODE>mode == V2DFmode")
3547 (const_string "complex")
3548 (const_string "*")))
3549 (set_attr "prefix" "orig,vex")
3550 (set (attr "prefix_rep")
3551 (if_then_else
3552 (and (match_test "<MODE>mode == V4SFmode")
3553 (eq_attr "alternative" "0"))
3554 (const_string "1")
3555 (const_string "*")))
3556 (set_attr "mode" "<MODE>")])
3557
3558 (define_split
3559 [(set (match_operand:VF_128_256 0 "register_operand")
3560 (match_operator:VF_128_256 6 "addsub_vm_operator"
3561 [(minus:VF_128_256
3562 (match_operand:VF_128_256 1 "register_operand")
3563 (match_operand:VF_128_256 2 "vector_operand"))
3564 (plus:VF_128_256
3565 (match_operand:VF_128_256 3 "vector_operand")
3566 (match_operand:VF_128_256 4 "vector_operand"))
3567 (match_operand 5 "const_int_operand")]))]
3568 "TARGET_SSE3
3569 && can_create_pseudo_p ()
3570 && ((rtx_equal_p (operands[1], operands[3])
3571 && rtx_equal_p (operands[2], operands[4]))
3572 || (rtx_equal_p (operands[1], operands[4])
3573 && rtx_equal_p (operands[2], operands[3])))"
3574 [(set (match_dup 0)
3575 (vec_merge:VF_128_256
3576 (minus:VF_128_256 (match_dup 1) (match_dup 2))
3577 (plus:VF_128_256 (match_dup 1) (match_dup 2))
3578 (match_dup 5)))])
3579
3580 (define_split
3581 [(set (match_operand:VF_128_256 0 "register_operand")
3582 (match_operator:VF_128_256 6 "addsub_vm_operator"
3583 [(plus:VF_128_256
3584 (match_operand:VF_128_256 1 "vector_operand")
3585 (match_operand:VF_128_256 2 "vector_operand"))
3586 (minus:VF_128_256
3587 (match_operand:VF_128_256 3 "register_operand")
3588 (match_operand:VF_128_256 4 "vector_operand"))
3589 (match_operand 5 "const_int_operand")]))]
3590 "TARGET_SSE3
3591 && can_create_pseudo_p ()
3592 && ((rtx_equal_p (operands[1], operands[3])
3593 && rtx_equal_p (operands[2], operands[4]))
3594 || (rtx_equal_p (operands[1], operands[4])
3595 && rtx_equal_p (operands[2], operands[3])))"
3596 [(set (match_dup 0)
3597 (vec_merge:VF_128_256
3598 (minus:VF_128_256 (match_dup 3) (match_dup 4))
3599 (plus:VF_128_256 (match_dup 3) (match_dup 4))
3600 (match_dup 5)))]
3601 {
3602 /* Negate mask bits to compensate for swapped PLUS and MINUS RTXes. */
3603 operands[5]
3604 = GEN_INT (~INTVAL (operands[5])
3605 & ((HOST_WIDE_INT_1U << GET_MODE_NUNITS (<MODE>mode)) - 1));
3606 })
3607
3608 (define_split
3609 [(set (match_operand:VF_128_256 0 "register_operand")
3610 (match_operator:VF_128_256 7 "addsub_vs_operator"
3611 [(vec_concat:<ssedoublevecmode>
3612 (minus:VF_128_256
3613 (match_operand:VF_128_256 1 "register_operand")
3614 (match_operand:VF_128_256 2 "vector_operand"))
3615 (plus:VF_128_256
3616 (match_operand:VF_128_256 3 "vector_operand")
3617 (match_operand:VF_128_256 4 "vector_operand")))
3618 (match_parallel 5 "addsub_vs_parallel"
3619 [(match_operand 6 "const_int_operand")])]))]
3620 "TARGET_SSE3
3621 && can_create_pseudo_p ()
3622 && ((rtx_equal_p (operands[1], operands[3])
3623 && rtx_equal_p (operands[2], operands[4]))
3624 || (rtx_equal_p (operands[1], operands[4])
3625 && rtx_equal_p (operands[2], operands[3])))"
3626 [(set (match_dup 0)
3627 (vec_merge:VF_128_256
3628 (minus:VF_128_256 (match_dup 1) (match_dup 2))
3629 (plus:VF_128_256 (match_dup 1) (match_dup 2))
3630 (match_dup 5)))]
3631 {
3632 int i, nelt = XVECLEN (operands[5], 0);
3633 HOST_WIDE_INT ival = 0;
3634
3635 for (i = 0; i < nelt; i++)
3636 if (INTVAL (XVECEXP (operands[5], 0, i)) < GET_MODE_NUNITS (<MODE>mode))
3637 ival |= HOST_WIDE_INT_1 << i;
3638
3639 operands[5] = GEN_INT (ival);
3640 })
3641
3642 (define_split
3643 [(set (match_operand:VF_128_256 0 "register_operand")
3644 (match_operator:VF_128_256 7 "addsub_vs_operator"
3645 [(vec_concat:<ssedoublevecmode>
3646 (plus:VF_128_256
3647 (match_operand:VF_128_256 1 "vector_operand")
3648 (match_operand:VF_128_256 2 "vector_operand"))
3649 (minus:VF_128_256
3650 (match_operand:VF_128_256 3 "register_operand")
3651 (match_operand:VF_128_256 4 "vector_operand")))
3652 (match_parallel 5 "addsub_vs_parallel"
3653 [(match_operand 6 "const_int_operand")])]))]
3654 "TARGET_SSE3
3655 && can_create_pseudo_p ()
3656 && ((rtx_equal_p (operands[1], operands[3])
3657 && rtx_equal_p (operands[2], operands[4]))
3658 || (rtx_equal_p (operands[1], operands[4])
3659 && rtx_equal_p (operands[2], operands[3])))"
3660 [(set (match_dup 0)
3661 (vec_merge:VF_128_256
3662 (minus:VF_128_256 (match_dup 3) (match_dup 4))
3663 (plus:VF_128_256 (match_dup 3) (match_dup 4))
3664 (match_dup 5)))]
3665 {
3666 int i, nelt = XVECLEN (operands[5], 0);
3667 HOST_WIDE_INT ival = 0;
3668
3669 for (i = 0; i < nelt; i++)
3670 if (INTVAL (XVECEXP (operands[5], 0, i)) >= GET_MODE_NUNITS (<MODE>mode))
3671 ival |= HOST_WIDE_INT_1 << i;
3672
3673 operands[5] = GEN_INT (ival);
3674 })
3675
3676 (define_insn "avx_h<insn>v4df3"
3677 [(set (match_operand:V4DF 0 "register_operand" "=x")
3678 (vec_concat:V4DF
3679 (vec_concat:V2DF
3680 (plusminus:DF
3681 (vec_select:DF
3682 (match_operand:V4DF 1 "register_operand" "x")
3683 (parallel [(const_int 0)]))
3684 (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
3685 (plusminus:DF
3686 (vec_select:DF
3687 (match_operand:V4DF 2 "nonimmediate_operand" "xjm")
3688 (parallel [(const_int 0)]))
3689 (vec_select:DF (match_dup 2) (parallel [(const_int 1)]))))
3690 (vec_concat:V2DF
3691 (plusminus:DF
3692 (vec_select:DF (match_dup 1) (parallel [(const_int 2)]))
3693 (vec_select:DF (match_dup 1) (parallel [(const_int 3)])))
3694 (plusminus:DF
3695 (vec_select:DF (match_dup 2) (parallel [(const_int 2)]))
3696 (vec_select:DF (match_dup 2) (parallel [(const_int 3)]))))))]
3697 "TARGET_AVX"
3698 "vh<plusminus_mnemonic>pd\t{%2, %1, %0|%0, %1, %2}"
3699 [(set_attr "type" "sseadd")
3700 (set_attr "c86_attr" "hplus")
3701 (set_attr "addr" "gpr16")
3702 (set_attr "prefix" "vex")
3703 (set_attr "mode" "V4DF")])
3704
3705 (define_expand "sse3_haddv2df3"
3706 [(set (match_operand:V2DF 0 "register_operand")
3707 (vec_concat:V2DF
3708 (plus:DF
3709 (vec_select:DF
3710 (match_operand:V2DF 1 "register_operand")
3711 (parallel [(const_int 0)]))
3712 (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
3713 (plus:DF
3714 (vec_select:DF
3715 (match_operand:V2DF 2 "vector_operand")
3716 (parallel [(const_int 0)]))
3717 (vec_select:DF (match_dup 2) (parallel [(const_int 1)])))))]
3718 "TARGET_SSE3")
3719
3720 (define_insn "*sse3_haddv2df3"
3721 [(set (match_operand:V2DF 0 "register_operand" "=x,x")
3722 (vec_concat:V2DF
3723 (plus:DF
3724 (vec_select:DF
3725 (match_operand:V2DF 1 "register_operand" "0,x")
3726 (parallel [(match_operand:SI 3 "const_0_to_1_operand")]))
3727 (vec_select:DF
3728 (match_dup 1)
3729 (parallel [(match_operand:SI 4 "const_0_to_1_operand")])))
3730 (plus:DF
3731 (vec_select:DF
3732 (match_operand:V2DF 2 "vector_operand" "xBm,xjm")
3733 (parallel [(match_operand:SI 5 "const_0_to_1_operand")]))
3734 (vec_select:DF
3735 (match_dup 2)
3736 (parallel [(match_operand:SI 6 "const_0_to_1_operand")])))))]
3737 "TARGET_SSE3
3738 && INTVAL (operands[3]) != INTVAL (operands[4])
3739 && INTVAL (operands[5]) != INTVAL (operands[6])"
3740 "@
3741 haddpd\t{%2, %0|%0, %2}
3742 vhaddpd\t{%2, %1, %0|%0, %1, %2}"
3743 [(set_attr "isa" "noavx,avx")
3744 (set_attr "addr" "*,gpr16")
3745 (set_attr "type" "sseadd")
3746 (set_attr "c86_attr" "hplus")
3747 (set_attr "prefix" "orig,vex")
3748 (set_attr "mode" "V2DF")])
3749
3750 (define_insn "sse3_hsubv2df3"
3751 [(set (match_operand:V2DF 0 "register_operand" "=x,x")
3752 (vec_concat:V2DF
3753 (minus:DF
3754 (vec_select:DF
3755 (match_operand:V2DF 1 "register_operand" "0,x")
3756 (parallel [(const_int 0)]))
3757 (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
3758 (minus:DF
3759 (vec_select:DF
3760 (match_operand:V2DF 2 "vector_operand" "xBm,xjm")
3761 (parallel [(const_int 0)]))
3762 (vec_select:DF (match_dup 2) (parallel [(const_int 1)])))))]
3763 "TARGET_SSE3"
3764 "@
3765 hsubpd\t{%2, %0|%0, %2}
3766 vhsubpd\t{%2, %1, %0|%0, %1, %2}"
3767 [(set_attr "isa" "noavx,avx")
3768 (set_attr "type" "sseadd")
3769 (set_attr "c86_attr" "hplus")
3770 (set_attr "addr" "*,gpr16")
3771 (set_attr "prefix" "orig,vex")
3772 (set_attr "mode" "V2DF")])
3773
3774 (define_insn "*sse3_haddv2df3_low"
3775 [(set (match_operand:DF 0 "register_operand" "=x,x")
3776 (plus:DF
3777 (vec_select:DF
3778 (match_operand:V2DF 1 "register_operand" "0,x")
3779 (parallel [(match_operand:SI 2 "const_0_to_1_operand")]))
3780 (vec_select:DF
3781 (match_dup 1)
3782 (parallel [(match_operand:SI 3 "const_0_to_1_operand")]))))]
3783 "TARGET_SSE3 && TARGET_V2DF_REDUCTION_PREFER_HADDPD
3784 && INTVAL (operands[2]) != INTVAL (operands[3])"
3785 "@
3786 haddpd\t{%0, %0|%0, %0}
3787 vhaddpd\t{%1, %1, %0|%0, %1, %1}"
3788 [(set_attr "isa" "noavx,avx")
3789 (set_attr "type" "sseadd1")
3790 (set_attr "c86_attr" "hplus")
3791 (set_attr "prefix" "orig,vex")
3792 (set_attr "mode" "V2DF")])
3793
3794 (define_insn "*sse3_hsubv2df3_low"
3795 [(set (match_operand:DF 0 "register_operand" "=x,x")
3796 (minus:DF
3797 (vec_select:DF
3798 (match_operand:V2DF 1 "register_operand" "0,x")
3799 (parallel [(const_int 0)]))
3800 (vec_select:DF
3801 (match_dup 1)
3802 (parallel [(const_int 1)]))))]
3803 "TARGET_SSE3 && TARGET_V2DF_REDUCTION_PREFER_HADDPD"
3804 "@
3805 hsubpd\t{%0, %0|%0, %0}
3806 vhsubpd\t{%1, %1, %0|%0, %1, %1}"
3807 [(set_attr "isa" "noavx,avx")
3808 (set_attr "type" "sseadd1")
3809 (set_attr "c86_attr" "hplus")
3810 (set_attr "prefix" "orig,vex")
3811 (set_attr "mode" "V2DF")])
3812
3813 (define_insn "avx_h<insn>v8sf3"
3814 [(set (match_operand:V8SF 0 "register_operand" "=x")
3815 (vec_concat:V8SF
3816 (vec_concat:V4SF
3817 (vec_concat:V2SF
3818 (plusminus:SF
3819 (vec_select:SF
3820 (match_operand:V8SF 1 "register_operand" "x")
3821 (parallel [(const_int 0)]))
3822 (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
3823 (plusminus:SF
3824 (vec_select:SF (match_dup 1) (parallel [(const_int 2)]))
3825 (vec_select:SF (match_dup 1) (parallel [(const_int 3)]))))
3826 (vec_concat:V2SF
3827 (plusminus:SF
3828 (vec_select:SF
3829 (match_operand:V8SF 2 "nonimmediate_operand" "xjm")
3830 (parallel [(const_int 0)]))
3831 (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))
3832 (plusminus:SF
3833 (vec_select:SF (match_dup 2) (parallel [(const_int 2)]))
3834 (vec_select:SF (match_dup 2) (parallel [(const_int 3)])))))
3835 (vec_concat:V4SF
3836 (vec_concat:V2SF
3837 (plusminus:SF
3838 (vec_select:SF (match_dup 1) (parallel [(const_int 4)]))
3839 (vec_select:SF (match_dup 1) (parallel [(const_int 5)])))
3840 (plusminus:SF
3841 (vec_select:SF (match_dup 1) (parallel [(const_int 6)]))
3842 (vec_select:SF (match_dup 1) (parallel [(const_int 7)]))))
3843 (vec_concat:V2SF
3844 (plusminus:SF
3845 (vec_select:SF (match_dup 2) (parallel [(const_int 4)]))
3846 (vec_select:SF (match_dup 2) (parallel [(const_int 5)])))
3847 (plusminus:SF
3848 (vec_select:SF (match_dup 2) (parallel [(const_int 6)]))
3849 (vec_select:SF (match_dup 2) (parallel [(const_int 7)])))))))]
3850 "TARGET_AVX"
3851 "vh<plusminus_mnemonic>ps\t{%2, %1, %0|%0, %1, %2}"
3852 [(set_attr "type" "sseadd")
3853 (set_attr "c86_attr" "hplus")
3854 (set_attr "addr" "gpr16")
3855 (set_attr "prefix" "vex")
3856 (set_attr "mode" "V8SF")])
3857
3858 (define_insn "sse3_h<insn>v4sf3"
3859 [(set (match_operand:V4SF 0 "register_operand" "=x,x")
3860 (vec_concat:V4SF
3861 (vec_concat:V2SF
3862 (plusminus:SF
3863 (vec_select:SF
3864 (match_operand:V4SF 1 "register_operand" "0,x")
3865 (parallel [(const_int 0)]))
3866 (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
3867 (plusminus:SF
3868 (vec_select:SF (match_dup 1) (parallel [(const_int 2)]))
3869 (vec_select:SF (match_dup 1) (parallel [(const_int 3)]))))
3870 (vec_concat:V2SF
3871 (plusminus:SF
3872 (vec_select:SF
3873 (match_operand:V4SF 2 "vector_operand" "xBm,xjm")
3874 (parallel [(const_int 0)]))
3875 (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))
3876 (plusminus:SF
3877 (vec_select:SF (match_dup 2) (parallel [(const_int 2)]))
3878 (vec_select:SF (match_dup 2) (parallel [(const_int 3)]))))))]
3879 "TARGET_SSE3"
3880 "@
3881 h<plusminus_mnemonic>ps\t{%2, %0|%0, %2}
3882 vh<plusminus_mnemonic>ps\t{%2, %1, %0|%0, %1, %2}"
3883 [(set_attr "isa" "noavx,avx")
3884 (set_attr "type" "sseadd")
3885 (set_attr "c86_attr" "hplus")
3886 (set_attr "addr" "*,gpr16")
3887 (set_attr "atom_unit" "complex")
3888 (set_attr "prefix" "orig,vex")
3889 (set_attr "prefix_rep" "1,*")
3890 (set_attr "mode" "V4SF")])
3891
3892 (define_mode_iterator REDUC_SSE_PLUS_MODE
3893 [(V2DF "TARGET_SSE") (V4SF "TARGET_SSE")
3894 (V8HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
3895 (V8HI "TARGET_SSE2") (V4SI "TARGET_SSE2")
3896 (V2DI "TARGET_SSE2")])
3897
3898 (define_expand "reduc_plus_scal_<mode>"
3899 [(plus:REDUC_SSE_PLUS_MODE
3900 (match_operand:<ssescalarmode> 0 "register_operand")
3901 (match_operand:REDUC_SSE_PLUS_MODE 1 "register_operand"))]
3902 ""
3903 {
3904 rtx tmp = gen_reg_rtx (<MODE>mode);
3905 ix86_expand_reduc (gen_add<mode>3, tmp, operands[1]);
3906 emit_insn (gen_vec_extract<mode><ssescalarmodelower> (operands[0], tmp,
3907 const0_rtx));
3908 DONE;
3909 })
3910
3911 (define_expand "reduc_plus_scal_v16qi"
3912 [(plus:V16QI
3913 (match_operand:QI 0 "register_operand")
3914 (match_operand:V16QI 1 "register_operand"))]
3915 "TARGET_SSE2"
3916 {
3917 rtx tmp = gen_reg_rtx (V1TImode);
3918 emit_insn (gen_sse2_lshrv1ti3 (tmp, gen_lowpart (V1TImode, operands[1]),
3919 GEN_INT (64)));
3920 rtx tmp2 = gen_reg_rtx (V16QImode);
3921 emit_insn (gen_addv16qi3 (tmp2, operands[1], gen_lowpart (V16QImode, tmp)));
3922 rtx tmp3 = gen_reg_rtx (V16QImode);
3923 emit_move_insn (tmp3, CONST0_RTX (V16QImode));
3924 rtx tmp4 = gen_reg_rtx (V2DImode);
3925 emit_insn (gen_sse2_psadbw (tmp4, tmp2, tmp3));
3926 tmp4 = gen_lowpart (V16QImode, tmp4);
3927 emit_insn (gen_vec_extractv16qiqi (operands[0], tmp4, const0_rtx));
3928 DONE;
3929 })
3930
3931 (define_mode_iterator REDUC_PLUS_MODE
3932 [(V4DF "TARGET_AVX") (V8SF "TARGET_AVX")
3933 (V16HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
3934 (V8DF "TARGET_AVX512F && TARGET_EVEX512")
3935 (V16SF "TARGET_AVX512F && TARGET_EVEX512")
3936 (V32HF "TARGET_AVX512FP16 && TARGET_AVX512VL && TARGET_EVEX512")
3937 (V32QI "TARGET_AVX") (V16HI "TARGET_AVX")
3938 (V8SI "TARGET_AVX") (V4DI "TARGET_AVX")
3939 (V64QI "TARGET_AVX512F && TARGET_EVEX512")
3940 (V32HI "TARGET_AVX512F && TARGET_EVEX512")
3941 (V16SI "TARGET_AVX512F && TARGET_EVEX512")
3942 (V8DI "TARGET_AVX512F && TARGET_EVEX512")])
3943
3944 (define_expand "reduc_plus_scal_<mode>"
3945 [(plus:REDUC_PLUS_MODE
3946 (match_operand:<ssescalarmode> 0 "register_operand")
3947 (match_operand:REDUC_PLUS_MODE 1 "register_operand"))]
3948 ""
3949 {
3950 rtx tmp = gen_reg_rtx (<ssehalfvecmode>mode);
3951 rtx tmp2 = gen_reg_rtx (<ssehalfvecmode>mode);
3952 rtx tmp3 = gen_reg_rtx (<ssehalfvecmode>mode);
3953 emit_insn (gen_vec_extract_hi_<mode> (tmp, operands[1]));
3954 emit_insn (gen_vec_extract_lo_<mode> (tmp2, operands[1]));
3955 emit_insn (gen_add<ssehalfvecmodelower>3 (tmp3, tmp, tmp2));
3956 emit_insn (gen_reduc_plus_scal_<ssehalfvecmodelower> (operands[0], tmp3));
3957 DONE;
3958 })
3959
3960 ;; Modes handled by reduc_sm{in,ax}* patterns.
3961 (define_mode_iterator REDUC_SSE_SMINMAX_MODE
3962 [(V8HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
3963 (V4SF "TARGET_SSE") (V2DF "TARGET_SSE")
3964 (V4SI "TARGET_SSE2") (V8HI "TARGET_SSE2") (V16QI "TARGET_SSE2")
3965 (V2DI "TARGET_SSE4_2")])
3966
3967 (define_expand "reduc_<code>_scal_<mode>"
3968 [(smaxmin:REDUC_SSE_SMINMAX_MODE
3969 (match_operand:<ssescalarmode> 0 "register_operand")
3970 (match_operand:REDUC_SSE_SMINMAX_MODE 1 "register_operand"))]
3971 ""
3972 {
3973 rtx tmp = gen_reg_rtx (<MODE>mode);
3974 ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
3975 emit_insn (gen_vec_extract<mode><ssescalarmodelower> (operands[0], tmp,
3976 const0_rtx));
3977 DONE;
3978 })
3979
3980 (define_mode_iterator REDUC_SMINMAX_MODE
3981 [(V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
3982 (V16HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
3983 (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")
3984 (V8SF "TARGET_AVX") (V4DF "TARGET_AVX")
3985 (V64QI "TARGET_AVX512BW && TARGET_EVEX512")
3986 (V32HF "TARGET_AVX512FP16 && TARGET_AVX512VL && TARGET_EVEX512")
3987 (V32HI "TARGET_AVX512BW && TARGET_EVEX512")
3988 (V16SI "TARGET_AVX512F && TARGET_EVEX512")
3989 (V8DI "TARGET_AVX512F && TARGET_EVEX512")
3990 (V16SF "TARGET_AVX512F && TARGET_EVEX512")
3991 (V8DF "TARGET_AVX512F && TARGET_EVEX512")])
3992
3993 (define_expand "reduc_<code>_scal_<mode>"
3994 [(smaxmin:REDUC_SMINMAX_MODE
3995 (match_operand:<ssescalarmode> 0 "register_operand")
3996 (match_operand:REDUC_SMINMAX_MODE 1 "register_operand"))]
3997 ""
3998 {
3999 rtx tmp = gen_reg_rtx (<ssehalfvecmode>mode);
4000 rtx tmp2 = gen_reg_rtx (<ssehalfvecmode>mode);
4001 rtx tmp3 = gen_reg_rtx (<ssehalfvecmode>mode);
4002 emit_insn (gen_vec_extract_hi_<mode> (tmp, operands[1]));
4003 emit_insn (gen_vec_extract_lo_<mode> (tmp2, operands[1]));
4004 emit_insn (gen_<code><ssehalfvecmodelower>3 (tmp3, tmp, tmp2));
4005 emit_insn (gen_reduc_<code>_scal_<ssehalfvecmodelower> (operands[0], tmp3));
4006 DONE;
4007 })
4008
4009 (define_expand "reduc_<code>_scal_<mode>"
4010 [(umaxmin:VI_AVX512BW
4011 (match_operand:<ssescalarmode> 0 "register_operand")
4012 (match_operand:VI_AVX512BW 1 "register_operand"))]
4013 "TARGET_AVX512F"
4014 {
4015 rtx tmp = gen_reg_rtx (<ssehalfvecmode>mode);
4016 rtx tmp2 = gen_reg_rtx (<ssehalfvecmode>mode);
4017 rtx tmp3 = gen_reg_rtx (<ssehalfvecmode>mode);
4018 emit_insn (gen_vec_extract_hi_<mode> (tmp, operands[1]));
4019 emit_insn (gen_vec_extract_lo_<mode> (tmp2, operands[1]));
4020 emit_insn (gen_<code><ssehalfvecmodelower>3 (tmp3, tmp, tmp2));
4021 emit_insn (gen_reduc_<code>_scal_<ssehalfvecmodelower> (operands[0], tmp3));
4022 DONE;
4023 })
4024
4025 (define_expand "reduc_<code>_scal_<mode>"
4026 [(umaxmin:VI_256
4027 (match_operand:<ssescalarmode> 0 "register_operand")
4028 (match_operand:VI_256 1 "register_operand"))]
4029 "TARGET_AVX2"
4030 {
4031 rtx tmp = gen_reg_rtx (<ssehalfvecmode>mode);
4032 rtx tmp2 = gen_reg_rtx (<ssehalfvecmode>mode);
4033 rtx tmp3 = gen_reg_rtx (<ssehalfvecmode>mode);
4034 emit_insn (gen_vec_extract_hi_<mode> (tmp, operands[1]));
4035 emit_insn (gen_vec_extract_lo_<mode> (tmp2, operands[1]));
4036 emit_insn (gen_<code><ssehalfvecmodelower>3 (tmp3, tmp, tmp2));
4037 rtx tmp4 = gen_reg_rtx (<ssehalfvecmode>mode);
4038 ix86_expand_reduc (gen_<code><ssehalfvecmodelower>3, tmp4, tmp3);
4039 emit_insn (gen_vec_extract<ssehalfvecmodelower><ssescalarmodelower>
4040 (operands[0], tmp4, const0_rtx));
4041 DONE;
4042 })
4043
4044 (define_expand "reduc_umin_scal_v8hi"
4045 [(umin:V8HI
4046 (match_operand:HI 0 "register_operand")
4047 (match_operand:V8HI 1 "register_operand"))]
4048 "TARGET_SSE4_1"
4049 {
4050 rtx tmp = gen_reg_rtx (V8HImode);
4051 ix86_expand_reduc (gen_uminv8hi3, tmp, operands[1]);
4052 emit_insn (gen_vec_extractv8hihi (operands[0], tmp, const0_rtx));
4053 DONE;
4054 })
4055
4056 (define_insn "<mask_codefor>reducep<mode><mask_name><round_saeonly_name>"
4057 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v")
4058 (unspec:VFH_AVX512VL
4059 [(match_operand:VFH_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
4060 (match_operand:SI 2 "const_0_to_255_operand")]
4061 UNSPEC_REDUCE))]
4062 "TARGET_AVX512DQ || (VALID_AVX512FP16_REG_MODE (<MODE>mode))"
4063 "vreduce<ssemodesuffix>\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}"
4064 [(set_attr "type" "sse")
4065 (set_attr "c86_attr" "aes")
4066 (set_attr "prefix" "evex")
4067 (set_attr "mode" "<MODE>")])
4068
4069 (define_insn "reduces<mode><mask_scalar_name><round_saeonly_scalar_name>"
4070 [(set (match_operand:VFH_128 0 "register_operand" "=v")
4071 (vec_merge:VFH_128
4072 (unspec:VFH_128
4073 [(match_operand:VFH_128 1 "register_operand" "v")
4074 (match_operand:VFH_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")
4075 (match_operand:SI 3 "const_0_to_255_operand")]
4076 UNSPEC_REDUCE)
4077 (match_dup 1)
4078 (const_int 1)))]
4079 "TARGET_AVX512DQ || (VALID_AVX512FP16_REG_MODE (<MODE>mode))"
4080 "vreduce<ssescalarmodesuffix>\t{%3, <round_saeonly_scalar_mask_op4>%2, %1, %0<mask_scalar_operand4>|%0<mask_scalar_operand4>, %1, %<iptr>2<round_saeonly_scalar_mask_op4>, %3}"
4081 [(set_attr "type" "sse")
4082 (set_attr "c86_attr" "aes")
4083 (set_attr "prefix" "evex")
4084 (set_attr "mode" "<MODE>")])
4085
4086 (define_expand "reduc_<code>_scal_<mode>"
4087 [(any_logic:VI_128
4088 (match_operand:<ssescalarmode> 0 "register_operand")
4089 (match_operand:VI_128 1 "register_operand"))]
4090 "TARGET_SSE2"
4091 {
4092 rtx tmp = gen_reg_rtx (<MODE>mode);
4093 ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
4094 emit_insn (gen_vec_extract<mode><ssescalarmodelower> (operands[0],
4095 tmp, const0_rtx));
4096 DONE;
4097 })
4098
4099 (define_mode_iterator REDUC_ANY_LOGIC_MODE
4100 [(V32QI "TARGET_AVX") (V16HI "TARGET_AVX")
4101 (V8SI "TARGET_AVX") (V4DI "TARGET_AVX")
4102 (V64QI "TARGET_AVX512F && TARGET_EVEX512")
4103 (V32HI "TARGET_AVX512F && TARGET_EVEX512")
4104 (V16SI "TARGET_AVX512F && TARGET_EVEX512")
4105 (V8DI "TARGET_AVX512F && TARGET_EVEX512")])
4106
4107 (define_expand "reduc_<code>_scal_<mode>"
4108 [(any_logic:REDUC_ANY_LOGIC_MODE
4109 (match_operand:<ssescalarmode> 0 "register_operand")
4110 (match_operand:REDUC_ANY_LOGIC_MODE 1 "register_operand"))]
4111 ""
4112 {
4113 rtx tmp = gen_reg_rtx (<ssehalfvecmode>mode);
4114 rtx tmp2 = gen_reg_rtx (<ssehalfvecmode>mode);
4115 rtx tmp3 = gen_reg_rtx (<ssehalfvecmode>mode);
4116 emit_insn (gen_vec_extract_hi_<mode> (tmp, operands[1]));
4117 emit_insn (gen_vec_extract_lo_<mode> (tmp2, operands[1]));
4118 emit_insn (gen_<code><ssehalfvecmodelower>3 (tmp3, tmp, tmp2));
4119 emit_insn (gen_reduc_<code>_scal_<ssehalfvecmodelower> (operands[0], tmp3));
4120 DONE;
4121 })
4122
4123 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4124 ;;
4125 ;; Parallel floating point comparisons
4126 ;;
4127 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4128
4129 (define_insn "avx_cmp<mode>3"
4130 [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
4131 (unspec:VF_128_256
4132 [(match_operand:VF_128_256 1 "register_operand" "0,x")
4133 (match_operand:VF_128_256 2 "nonimmediate_operand" "xm,xjm")
4134 (match_operand:SI 3 "cmpps_imm_operand")]
4135 UNSPEC_PCMP))]
4136 "TARGET_SSE"
4137 "@
4138 cmp<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
4139 vcmp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4140 [(set_attr "isa" "noavx,avx")
4141 (set_attr "type" "ssecmp")
4142 (set_attr "addr" "*,gpr16")
4143 (set_attr "length_immediate" "1")
4144 (set_attr "prefix" "orig,vex")
4145 (set_attr "mode" "<MODE>")])
4146
4147 (define_insn_and_split "*avx_cmp<mode>3_1"
4148 [(set (match_operand:<sseintvecmode> 0 "register_operand")
4149 (vec_merge:<sseintvecmode>
4150 (match_operand:<sseintvecmode> 1 "vector_all_ones_operand")
4151 (match_operand:<sseintvecmode> 2 "const0_operand")
4152 (unspec:<avx512fmaskmode>
4153 [(match_operand:VF_128_256 3 "register_operand")
4154 (match_operand:VF_128_256 4 "nonimmediate_operand")
4155 (match_operand:SI 5 "const_0_to_31_operand")]
4156 UNSPEC_PCMP)))]
4157 "TARGET_AVX512VL && ix86_pre_reload_split ()"
4158 "#"
4159 "&& 1"
4160 [(set (match_dup 6)
4161 (unspec:VF_128_256
4162 [(match_dup 3)
4163 (match_dup 4)
4164 (match_dup 5)]
4165 UNSPEC_PCMP))
4166 (set (match_dup 0) (match_dup 7))]
4167 {
4168 operands[6] = gen_reg_rtx (<MODE>mode);
4169 operands[7]
4170 = lowpart_subreg (GET_MODE (operands[0]), operands[6], <MODE>mode);
4171 })
4172
4173 (define_insn_and_split "*avx_cmp<mode>3_2"
4174 [(set (match_operand:<sseintvecmode> 0 "register_operand")
4175 (vec_merge:<sseintvecmode>
4176 (match_operand:<sseintvecmode> 1 "vector_all_ones_operand")
4177 (match_operand:<sseintvecmode> 2 "const0_operand")
4178 (not:<avx512fmaskmode>
4179 (unspec:<avx512fmaskmode>
4180 [(match_operand:VF_128_256 3 "register_operand")
4181 (match_operand:VF_128_256 4 "nonimmediate_operand")
4182 (match_operand:SI 5 "const_0_to_31_operand")]
4183 UNSPEC_PCMP))))]
4184 "TARGET_AVX512VL && ix86_pre_reload_split ()"
4185 "#"
4186 "&& 1"
4187 [(set (match_dup 6)
4188 (unspec:VF_128_256
4189 [(match_dup 3)
4190 (match_dup 4)
4191 (match_dup 5)]
4192 UNSPEC_PCMP))
4193 (set (match_dup 0) (match_dup 7))]
4194 {
4195 operands[5] = GEN_INT (INTVAL (operands[5]) ^ 4);
4196 operands[6] = gen_reg_rtx (<MODE>mode);
4197 operands[7]
4198 = lowpart_subreg (GET_MODE (operands[0]), operands[6], <MODE>mode);
4199 })
4200
4201 (define_insn_and_split "*avx_cmp<mode>3_3"
4202 [(set (match_operand:VF_128_256 0 "register_operand")
4203 (vec_merge:VF_128_256
4204 (match_operand:VF_128_256 1 "float_vector_all_ones_operand")
4205 (match_operand:VF_128_256 2 "const0_operand")
4206 (unspec:<avx512fmaskmode>
4207 [(match_operand:VF_128_256 3 "register_operand")
4208 (match_operand:VF_128_256 4 "nonimmediate_operand")
4209 (match_operand:SI 5 "const_0_to_31_operand")]
4210 UNSPEC_PCMP)))]
4211 "TARGET_AVX512VL && ix86_pre_reload_split ()"
4212 "#"
4213 "&& 1"
4214 [(set (match_dup 0)
4215 (unspec:VF_128_256
4216 [(match_dup 3)
4217 (match_dup 4)
4218 (match_dup 5)]
4219 UNSPEC_PCMP))])
4220
4221 (define_insn_and_split "*avx_cmp<mode>3_4"
4222 [(set (match_operand:VF_128_256 0 "register_operand")
4223 (vec_merge:VF_128_256
4224 (match_operand:VF_128_256 1 "float_vector_all_ones_operand")
4225 (match_operand:VF_128_256 2 "const0_operand")
4226 (not:<avx512fmaskmode>
4227 (unspec:<avx512fmaskmode>
4228 [(match_operand:VF_128_256 3 "register_operand")
4229 (match_operand:VF_128_256 4 "nonimmediate_operand")
4230 (match_operand:SI 5 "const_0_to_31_operand")]
4231 UNSPEC_PCMP))))]
4232 "TARGET_AVX512VL && ix86_pre_reload_split ()"
4233 "#"
4234 "&& 1"
4235 [(set (match_dup 0)
4236 (unspec:VF_128_256
4237 [(match_dup 3)
4238 (match_dup 4)
4239 (match_dup 5)]
4240 UNSPEC_PCMP))]
4241 "operands[5] = GEN_INT (INTVAL (operands[5]) ^ 4);")
4242
4243 (define_insn_and_split "*avx_cmp<mode>3_lt"
4244 [(set (match_operand:VF_128_256 0 "register_operand")
4245 (vec_merge:VF_128_256
4246 (match_operand:VF_128_256 1 "vector_operand")
4247 (match_operand:VF_128_256 2 "vector_operand")
4248 (unspec:<avx512fmaskmode>
4249 [(match_operand:<sseintvecmode> 3 "register_operand")
4250 (match_operand:<sseintvecmode> 4 "const0_operand")
4251 (match_operand:SI 5 "const_0_to_7_operand")]
4252 UNSPEC_PCMP)))]
4253 "TARGET_AVX512VL && ix86_pre_reload_split ()
4254 /* LT or GE 0 */
4255 && ((INTVAL (operands[5]) == 1) || (INTVAL (operands[5]) == 5))"
4256 "#"
4257 "&& 1"
4258 [(set (match_dup 0)
4259 (unspec:VF_128_256
4260 [(match_dup 2)
4261 (match_dup 1)
4262 (lt:VF_128_256
4263 (match_dup 3)
4264 (match_dup 4))]
4265 UNSPEC_BLENDV))]
4266 {
4267 if (INTVAL (operands[5]) == 5)
4268 std::swap (operands[1], operands[2]);
4269 operands[2] = force_reg (<MODE>mode, operands[2]);
4270 })
4271
4272 (define_insn_and_split "*avx_cmp<mode>3_ltint"
4273 [(set (match_operand:VI48_AVX 0 "register_operand")
4274 (vec_merge:VI48_AVX
4275 (match_operand:VI48_AVX 1 "vector_operand")
4276 (match_operand:VI48_AVX 2 "vector_operand")
4277 (unspec:<avx512fmaskmode>
4278 [(match_operand:VI48_AVX 3 "register_operand")
4279 (match_operand:VI48_AVX 4 "const0_operand")
4280 (match_operand:SI 5 "const_0_to_7_operand")]
4281 UNSPEC_PCMP)))]
4282 "TARGET_AVX512VL && ix86_pre_reload_split ()
4283 /* LT or GE 0 */
4284 && ((INTVAL (operands[5]) == 1) || (INTVAL (operands[5]) == 5))"
4285 "#"
4286 "&& 1"
4287 [(set (match_dup 0)
4288 (unspec:<ssebytemode>
4289 [(match_dup 2)
4290 (match_dup 1)
4291 (subreg:<ssebytemode>
4292 (lt:VI48_AVX
4293 (match_dup 3)
4294 (match_dup 4)) 0)]
4295 UNSPEC_BLENDV))]
4296 {
4297 if (INTVAL (operands[5]) == 5)
4298 std::swap (operands[1], operands[2]);
4299 operands[0] = gen_lowpart (<ssebytemode>mode, operands[0]);
4300 operands[1] = gen_lowpart (<ssebytemode>mode, operands[1]);
4301 operands[2] = force_reg (<ssebytemode>mode,
4302 gen_lowpart (<ssebytemode>mode, operands[2]));
4303 })
4304
4305 (define_insn_and_split "*avx_cmp<mode>3_ltint_not"
4306 [(set (match_operand:VI48_AVX 0 "register_operand")
4307 (vec_merge:VI48_AVX
4308 (match_operand:VI48_AVX 1 "vector_operand")
4309 (match_operand:VI48_AVX 2 "vector_operand")
4310 (unspec:<avx512fmaskmode>
4311 [(subreg:VI48_AVX
4312 (not:<ssebytemode>
4313 (match_operand:<ssebytemode> 3 "vector_operand")) 0)
4314 (match_operand:VI48_AVX 4 "const0_operand")
4315 (match_operand:SI 5 "const_0_to_7_operand")]
4316 UNSPEC_PCMP)))]
4317 "TARGET_AVX512VL && ix86_pre_reload_split ()
4318 /* not LT or GE 0 */
4319 && ((INTVAL (operands[5]) == 1) || (INTVAL (operands[5]) == 5))"
4320 "#"
4321 "&& 1"
4322 [(set (match_dup 0)
4323 (unspec:<ssebytemode>
4324 [(match_dup 1)
4325 (match_dup 2)
4326 (subreg:<ssebytemode>
4327 (lt:VI48_AVX
4328 (match_dup 3)
4329 (match_dup 4)) 0)]
4330 UNSPEC_BLENDV))]
4331 {
4332 if (INTVAL (operands[5]) == 5)
4333 std::swap (operands[1], operands[2]);
4334 operands[0] = gen_lowpart (<ssebytemode>mode, operands[0]);
4335 operands[1] = force_reg (<ssebytemode>mode,
4336 gen_lowpart (<ssebytemode>mode, operands[1]));
4337 operands[2] = gen_lowpart (<ssebytemode>mode, operands[2]);
4338
4339 operands[3] = force_reg (<ssebytemode>mode, operands[3]);
4340 operands[3] = lowpart_subreg (<MODE>mode, operands[3], <ssebytemode>mode);
4341 })
4342
4343 (define_insn "avx_vmcmp<mode>3"
4344 [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4345 (vec_merge:VF_128
4346 (unspec:VF_128
4347 [(match_operand:VF_128 1 "register_operand" "0,x")
4348 (match_operand:VF_128 2 "nonimmediate_operand" "xm,xjm")
4349 (match_operand:SI 3 "cmpps_imm_operand")]
4350 UNSPEC_PCMP)
4351 (match_dup 1)
4352 (const_int 1)))]
4353 "TARGET_SSE"
4354 "@
4355 cmp<ssescalarmodesuffix>\t{%3, %2, %0|%0, %<iptr>2, %3}
4356 vcmp<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %3}"
4357 [(set_attr "isa" "noavx,avx")
4358 (set_attr "type" "ssecmp")
4359 (set_attr "addr" "*,gpr16")
4360 (set_attr "length_immediate" "1")
4361 (set_attr "prefix" "orig,vex")
4362 (set_attr "mode" "<ssescalarmode>")])
4363
4364 (define_insn "*<sse>_maskcmp<mode>3_comm"
4365 [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
4366 (match_operator:VF_128_256 3 "sse_comparison_operator"
4367 [(match_operand:VF_128_256 1 "register_operand" "%0,x")
4368 (match_operand:VF_128_256 2 "vector_operand" "xBm,xjm")]))]
4369 "TARGET_SSE
4370 && GET_RTX_CLASS (GET_CODE (operands[3])) == RTX_COMM_COMPARE"
4371 "@
4372 cmp%D3<ssemodesuffix>\t{%2, %0|%0, %2}
4373 vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
4374 [(set_attr "isa" "noavx,avx")
4375 (set_attr "addr" "*,gpr16")
4376 (set_attr "type" "ssecmp")
4377 (set_attr "length_immediate" "1")
4378 (set_attr "prefix" "orig,vex")
4379 (set_attr "mode" "<MODE>")])
4380
4381 (define_insn "<sse>_maskcmp<mode>3"
4382 [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
4383 (match_operator:VF_128_256 3 "sse_comparison_operator"
4384 [(match_operand:VF_128_256 1 "register_operand" "0,x")
4385 (match_operand:VF_128_256 2 "vector_operand" "xBm,xjm")]))]
4386 "TARGET_SSE"
4387 "@
4388 cmp%D3<ssemodesuffix>\t{%2, %0|%0, %2}
4389 vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
4390 [(set_attr "isa" "noavx,avx")
4391 (set_attr "addr" "*,gpr16")
4392 (set_attr "type" "ssecmp")
4393 (set_attr "length_immediate" "1")
4394 (set_attr "prefix" "orig,vex")
4395 (set_attr "mode" "<MODE>")])
4396
4397 (define_insn "<sse>_vmmaskcmp<mode>3"
4398 [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4399 (vec_merge:VF_128
4400 (match_operator:VF_128 3 "sse_comparison_operator"
4401 [(match_operand:VF_128 1 "register_operand" "0,x")
4402 (match_operand:VF_128 2 "nonimmediate_operand" "xm,xjm")])
4403 (match_dup 1)
4404 (const_int 1)))]
4405 "TARGET_SSE"
4406 "@
4407 cmp%D3<ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
4408 vcmp%D3<ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %<iptr>2}"
4409 [(set_attr "isa" "noavx,avx")
4410 (set_attr "addr" "*,gpr16")
4411 (set_attr "type" "ssecmp")
4412 (set_attr "length_immediate" "1,*")
4413 (set_attr "prefix" "orig,vex")
4414 (set_attr "mode" "<ssescalarmode>")])
4415
4416 (define_mode_attr cmp_imm_predicate
4417 [(V32HF "const_0_to_31_operand") (V16SF "const_0_to_31_operand") (V8DF "const_0_to_31_operand")
4418 (V16SI "const_0_to_7_operand") (V8DI "const_0_to_7_operand")
4419 (V16HF "const_0_to_31_operand") (V8SF "const_0_to_31_operand") (V4DF "const_0_to_31_operand")
4420 (V8SI "const_0_to_7_operand") (V4DI "const_0_to_7_operand")
4421 (V8HF "const_0_to_31_operand") (V4SF "const_0_to_31_operand") (V2DF "const_0_to_31_operand")
4422 (V4SI "const_0_to_7_operand") (V2DI "const_0_to_7_operand")
4423 (V32HI "const_0_to_7_operand") (V64QI "const_0_to_7_operand")
4424 (V16HI "const_0_to_7_operand") (V32QI "const_0_to_7_operand")
4425 (V8HI "const_0_to_7_operand") (V16QI "const_0_to_7_operand")])
4426
4427 (define_insn "<avx512>_cmp<mode>3<mask_scalar_merge_name><round_saeonly_name>"
4428 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
4429 (unspec:<avx512fmaskmode>
4430 [(match_operand:V48H_AVX512VL 1 "register_operand" "v")
4431 (match_operand:V48H_AVX512VL 2 "nonimmediate_operand" "<round_saeonly_constraint>")
4432 (match_operand:SI 3 "<cmp_imm_predicate>" "n")]
4433 UNSPEC_PCMP))]
4434 "TARGET_AVX512F && <round_saeonly_mode512bit_condition>"
4435 "v<ssecmpintprefix>cmp<ssemodesuffix>\t{%3, <round_saeonly_mask_scalar_merge_op4>%2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2<round_saeonly_mask_scalar_merge_op4>, %3}"
4436 [(set_attr "type" "ssecmp")
4437 (set_attr "length_immediate" "1")
4438 (set_attr "prefix" "evex")
4439 (set_attr "mode" "<sseinsnmode>")])
4440
4441 ;; Since vpcmpd implicitly clear the upper bits of dest, transform
4442 ;; vpcmpd + zero_extend to vpcmpd since the instruction
4443 (define_insn "*<avx512>_cmp<V48H_AVX512VL:mode>3_zero_extend<SWI248x:mode>"
4444 [(set (match_operand:SWI248x 0 "register_operand" "=k")
4445 (zero_extend:SWI248x
4446 (unspec:<V48H_AVX512VL:avx512fmaskmode>
4447 [(match_operand:V48H_AVX512VL 1 "nonimmediate_operand" "v")
4448 (match_operand:V48H_AVX512VL 2 "nonimmediate_operand" "vm")
4449 (match_operand:SI 3 "const_0_to_7_operand" "n")]
4450 UNSPEC_PCMP)))]
4451 "TARGET_AVX512F
4452 && (!VALID_MASK_AVX512BW_MODE (<SWI248x:MODE>mode) || TARGET_AVX512BW)
4453 && (GET_MODE_NUNITS (<V48H_AVX512VL:MODE>mode)
4454 < GET_MODE_PRECISION (<SWI248x:MODE>mode))"
4455 "v<ssecmpintprefix>cmp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4456 [(set_attr "type" "ssecmp")
4457 (set_attr "length_immediate" "1")
4458 (set_attr "prefix" "evex")
4459 (set_attr "mode" "<V48H_AVX512VL:sseinsnmode>")])
4460
4461 (define_insn_and_split "*<avx512>_cmp<V48H_AVX512VL:mode>3_zero_extend<SWI248x:mode>_2"
4462 [(set (match_operand:SWI248x 0 "register_operand")
4463 (zero_extend:SWI248x
4464 (unspec:<V48H_AVX512VL:avx512fmaskmode>
4465 [(match_operand:V48H_AVX512VL 1 "nonimmediate_operand")
4466 (match_operand:V48H_AVX512VL 2 "nonimmediate_operand")
4467 (match_operand:SI 3 "const_0_to_7_operand")]
4468 UNSPEC_PCMP)))
4469 (set (match_operand:<V48H_AVX512VL:avx512fmaskmode> 4 "register_operand")
4470 (unspec:<V48H_AVX512VL:avx512fmaskmode>
4471 [(match_dup 1)
4472 (match_dup 2)
4473 (match_dup 3)]
4474 UNSPEC_PCMP))]
4475 "TARGET_AVX512F
4476 && (!VALID_MASK_AVX512BW_MODE (<SWI248x:MODE>mode) || TARGET_AVX512BW)
4477 && (GET_MODE_NUNITS (<V48H_AVX512VL:MODE>mode)
4478 < GET_MODE_PRECISION (<SWI248x:MODE>mode))
4479 && ix86_pre_reload_split ()"
4480 "#"
4481 "&& 1"
4482 [(set (match_dup 0)
4483 (zero_extend:SWI248x
4484 (unspec:<V48H_AVX512VL:avx512fmaskmode>
4485 [(match_dup 1)
4486 (match_dup 2)
4487 (match_dup 3)]
4488 UNSPEC_PCMP)))
4489 (set (match_dup 4) (match_dup 5))]
4490 {
4491 operands[5] = lowpart_subreg (<V48H_AVX512VL:avx512fmaskmode>mode,
4492 operands[0], <SWI248x:MODE>mode);
4493 if (SUBREG_P (operands[5]))
4494 {
4495 SUBREG_PROMOTED_VAR_P (operands[5]) = 1;
4496 SUBREG_PROMOTED_SET (operands[5], 1);
4497 }
4498 })
4499
4500 (define_insn_and_split "*<avx512>_cmp<mode>3"
4501 [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
4502 (not:<avx512fmaskmode>
4503 (unspec:<avx512fmaskmode>
4504 [(match_operand:V48H_AVX512VL 1 "register_operand")
4505 (match_operand:V48H_AVX512VL 2 "nonimmediate_operand")
4506 (match_operand:SI 3 "<cmp_imm_predicate>" "n")]
4507 UNSPEC_PCMP)))]
4508 "TARGET_AVX512F && ix86_pre_reload_split ()"
4509 "#"
4510 "&& 1"
4511 [(set (match_dup 0)
4512 (unspec:<avx512fmaskmode>
4513 [(match_dup 1)
4514 (match_dup 2)
4515 (match_dup 4)]
4516 UNSPEC_PCMP))]
4517 "operands[4] = GEN_INT (INTVAL (operands[3]) ^ 4);")
4518
4519 (define_insn "<avx512>_cmp<mode>3<mask_scalar_merge_name>"
4520 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
4521 (unspec:<avx512fmaskmode>
4522 [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
4523 (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
4524 (match_operand:SI 3 "<cmp_imm_predicate>" "n")]
4525 UNSPEC_PCMP))]
4526 "TARGET_AVX512BW"
4527 "vpcmp<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
4528 [(set_attr "type" "ssecmp")
4529 (set_attr "length_immediate" "1")
4530 (set_attr "prefix" "evex")
4531 (set_attr "mode" "<sseinsnmode>")])
4532
4533 (define_insn "*<avx512>_cmp<VI12_AVX512VL:mode>3_zero_extend<SWI248x:mode>"
4534 [(set (match_operand:SWI248x 0 "register_operand" "=k")
4535 (zero_extend:SWI248x
4536 (unspec:<VI12_AVX512VL:avx512fmaskmode>
4537 [(match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "v")
4538 (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
4539 (match_operand:SI 3 "const_0_to_7_operand" "n")]
4540 UNSPEC_PCMP)))]
4541 "TARGET_AVX512BW
4542 && (GET_MODE_NUNITS (<VI12_AVX512VL:MODE>mode)
4543 < GET_MODE_PRECISION (<SWI248x:MODE>mode))"
4544 "vpcmp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4545 [(set_attr "type" "ssecmp")
4546 (set_attr "length_immediate" "1")
4547 (set_attr "prefix" "evex")
4548 (set_attr "mode" "<VI12_AVX512VL:sseinsnmode>")])
4549
4550 (define_insn_and_split "*<avx512>_cmp<VI12_AVX512VL:mode>3_zero_extend<SWI248x:mode>_2"
4551 [(set (match_operand:SWI248x 0 "register_operand")
4552 (zero_extend:SWI248x
4553 (unspec:<VI12_AVX512VL:avx512fmaskmode>
4554 [(match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
4555 (match_operand:VI12_AVX512VL 2 "nonimmediate_operand")
4556 (match_operand:SI 3 "const_0_to_7_operand")]
4557 UNSPEC_PCMP)))
4558 (set (match_operand:<VI12_AVX512VL:avx512fmaskmode> 4 "register_operand")
4559 (unspec:<VI12_AVX512VL:avx512fmaskmode>
4560 [(match_dup 1)
4561 (match_dup 2)
4562 (match_dup 3)]
4563 UNSPEC_PCMP))]
4564 "TARGET_AVX512BW
4565 && (GET_MODE_NUNITS (<VI12_AVX512VL:MODE>mode)
4566 < GET_MODE_PRECISION (<SWI248x:MODE>mode))
4567 && ix86_pre_reload_split ()"
4568 "#"
4569 "&& 1"
4570 [(set (match_dup 0)
4571 (zero_extend:SWI248x
4572 (unspec:<VI12_AVX512VL:avx512fmaskmode>
4573 [(match_dup 1)
4574 (match_dup 2)
4575 (match_dup 3)]
4576 UNSPEC_PCMP)))
4577 (set (match_dup 4) (match_dup 5))]
4578 {
4579 operands[5] = lowpart_subreg (<VI12_AVX512VL:avx512fmaskmode>mode,
4580 operands[0], <SWI248x:MODE>mode);
4581 if (SUBREG_P (operands[5]))
4582 {
4583 SUBREG_PROMOTED_VAR_P (operands[5]) = 1;
4584 SUBREG_PROMOTED_SET (operands[5], 1);
4585 }
4586 }
4587 [(set_attr "type" "ssecmp")
4588 (set_attr "length_immediate" "1")
4589 (set_attr "prefix" "evex")
4590 (set_attr "mode" "<VI12_AVX512VL:sseinsnmode>")])
4591
4592 (define_int_iterator UNSPEC_PCMP_ITER
4593 [UNSPEC_PCMP UNSPEC_UNSIGNED_PCMP])
4594
4595 (define_insn_and_split "*<avx512>_cmp<mode>3"
4596 [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
4597 (not:<avx512fmaskmode>
4598 (unspec:<avx512fmaskmode>
4599 [(match_operand:VI12_AVX512VL 1 "register_operand")
4600 (match_operand:VI12_AVX512VL 2 "nonimmediate_operand")
4601 (match_operand:SI 3 "<cmp_imm_predicate>")]
4602 UNSPEC_PCMP_ITER)))]
4603 "TARGET_AVX512BW && ix86_pre_reload_split ()"
4604 "#"
4605 "&& 1"
4606 [(set (match_dup 0)
4607 (unspec:<avx512fmaskmode>
4608 [(match_dup 1)
4609 (match_dup 2)
4610 (match_dup 4)]
4611 UNSPEC_PCMP_ITER))]
4612 "operands[4] = GEN_INT (INTVAL (operands[3]) ^ 4);")
4613
4614 (define_insn "*<avx512>_eq<mode>3<mask_scalar_merge_name>_1"
4615 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k,k")
4616 (unspec:<avx512fmaskmode>
4617 [(match_operand:VI12_AVX512VL 1 "nonimm_or_0_operand" "%v,v")
4618 (match_operand:VI12_AVX512VL 2 "nonimm_or_0_operand" "vm,C")
4619 (const_int 0)]
4620 UNSPEC_PCMP_ITER))]
4621 "TARGET_AVX512BW && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
4622 "@
4623 vpcmpeq<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}
4624 vptestnm<ssemodesuffix>\t{%1, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %1}"
4625 [(set_attr "type" "ssecmp")
4626 (set_attr "c86_attr" "*,ptest")
4627 (set_attr "prefix" "evex")
4628 (set_attr "mode" "<sseinsnmode>")])
4629
4630 (define_insn "<avx512>_ucmp<mode>3<mask_scalar_merge_name>"
4631 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
4632 (unspec:<avx512fmaskmode>
4633 [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
4634 (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
4635 (match_operand:SI 3 "const_0_to_7_operand")]
4636 UNSPEC_UNSIGNED_PCMP))]
4637 "TARGET_AVX512BW"
4638 "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
4639 [(set_attr "type" "ssecmp")
4640 (set_attr "length_immediate" "1")
4641 (set_attr "prefix" "evex")
4642 (set_attr "mode" "<sseinsnmode>")])
4643
4644 (define_insn "*<avx512>_ucmp<VI12_AVX512VL:mode>3_zero_extend<SWI248x:mode>"
4645 [(set (match_operand:SWI248x 0 "register_operand" "=k")
4646 (zero_extend:SWI248x
4647 (unspec:<VI12_AVX512VL:avx512fmaskmode>
4648 [(match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "v")
4649 (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
4650 (match_operand:SI 3 "const_0_to_7_operand" "n")]
4651 UNSPEC_UNSIGNED_PCMP)))]
4652 "TARGET_AVX512BW
4653 && (GET_MODE_NUNITS (<VI12_AVX512VL:MODE>mode)
4654 < GET_MODE_PRECISION (<SWI248x:MODE>mode))"
4655 "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4656 [(set_attr "type" "ssecmp")
4657 (set_attr "length_immediate" "1")
4658 (set_attr "prefix" "evex")
4659 (set_attr "mode" "<VI12_AVX512VL:sseinsnmode>")])
4660
4661 (define_insn_and_split "*<avx512>_ucmp<VI12_AVX512VL:mode>3_zero_extend<SWI248x:mode>_2"
4662 [(set (match_operand:SWI248x 0 "register_operand")
4663 (zero_extend:SWI248x
4664 (unspec:<VI12_AVX512VL:avx512fmaskmode>
4665 [(match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
4666 (match_operand:VI12_AVX512VL 2 "nonimmediate_operand")
4667 (match_operand:SI 3 "const_0_to_7_operand")]
4668 UNSPEC_UNSIGNED_PCMP)))
4669 (set (match_operand:<VI12_AVX512VL:avx512fmaskmode> 4 "register_operand")
4670 (unspec:<VI12_AVX512VL:avx512fmaskmode>
4671 [(match_dup 1)
4672 (match_dup 2)
4673 (match_dup 3)]
4674 UNSPEC_UNSIGNED_PCMP))]
4675 "TARGET_AVX512BW
4676 && ix86_pre_reload_split ()
4677 && (GET_MODE_NUNITS (<VI12_AVX512VL:MODE>mode)
4678 < GET_MODE_PRECISION (<SWI248x:MODE>mode))
4679 && ix86_pre_reload_split ()"
4680 "#"
4681 "&& 1"
4682 [(set (match_dup 0)
4683 (zero_extend:SWI248x
4684 (unspec:<VI12_AVX512VL:avx512fmaskmode>
4685 [(match_dup 1)
4686 (match_dup 2)
4687 (match_dup 3)]
4688 UNSPEC_UNSIGNED_PCMP)))
4689 (set (match_dup 4) (match_dup 5))]
4690 {
4691 operands[5] = lowpart_subreg (<VI12_AVX512VL:avx512fmaskmode>mode,
4692 operands[0], <SWI248x:MODE>mode);
4693 if (SUBREG_P (operands[5]))
4694 {
4695 SUBREG_PROMOTED_VAR_P (operands[5]) = 1;
4696 SUBREG_PROMOTED_SET (operands[5], 1);
4697 }
4698 }
4699 [(set_attr "type" "ssecmp")
4700 (set_attr "length_immediate" "1")
4701 (set_attr "prefix" "evex")
4702 (set_attr "mode" "<VI12_AVX512VL:sseinsnmode>")])
4703
4704 (define_insn "*<avx512>_eq<mode>3<mask_scalar_merge_name>_1"
4705 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k,k")
4706 (unspec:<avx512fmaskmode>
4707 [(match_operand:VI48_AVX512VL 1 "nonimm_or_0_operand" "%v,v")
4708 (match_operand:VI48_AVX512VL 2 "nonimm_or_0_operand" "vm,C")
4709 (const_int 0)]
4710 UNSPEC_PCMP_ITER))]
4711 "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
4712 "@
4713 vpcmpeq<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}
4714 vptestnm<ssemodesuffix>\t{%1, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %1}"
4715 [(set_attr "type" "ssecmp")
4716 (set_attr "c86_attr" "*,ptest")
4717 (set_attr "prefix" "evex")
4718 (set_attr "mode" "<sseinsnmode>")])
4719
4720 (define_insn "<avx512>_ucmp<mode>3<mask_scalar_merge_name>"
4721 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
4722 (unspec:<avx512fmaskmode>
4723 [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
4724 (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")
4725 (match_operand:SI 3 "const_0_to_7_operand")]
4726 UNSPEC_UNSIGNED_PCMP))]
4727 "TARGET_AVX512F"
4728 "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
4729 [(set_attr "type" "ssecmp")
4730 (set_attr "length_immediate" "1")
4731 (set_attr "prefix" "evex")
4732 (set_attr "mode" "<sseinsnmode>")])
4733
4734 (define_insn "*<avx512>_ucmp<VI48_AVX512VL:mode>3_zero_extend<SWI248x:mode>"
4735 [(set (match_operand:SWI248x 0 "register_operand" "=k")
4736 (zero_extend:SWI248x
4737 (unspec:<VI48_AVX512VL:avx512fmaskmode>
4738 [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "v")
4739 (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")
4740 (match_operand:SI 3 "const_0_to_7_operand" "n")]
4741 UNSPEC_UNSIGNED_PCMP)))]
4742 "TARGET_AVX512F
4743 && (!VALID_MASK_AVX512BW_MODE (<SWI248x:MODE>mode) || TARGET_AVX512BW)
4744 && (GET_MODE_NUNITS (<VI48_AVX512VL:MODE>mode)
4745 < GET_MODE_PRECISION (<SWI248x:MODE>mode))"
4746 "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4747 [(set_attr "type" "ssecmp")
4748 (set_attr "length_immediate" "1")
4749 (set_attr "prefix" "evex")
4750 (set_attr "mode" "<VI48_AVX512VL:sseinsnmode>")])
4751
4752 (define_insn_and_split "*<avx512>_ucmp<VI48_AVX512VL:mode>3_zero_extend<SWI248x:mode>_2"
4753 [(set (match_operand:SWI248x 0 "register_operand")
4754 (zero_extend:SWI248x
4755 (unspec:<VI48_AVX512VL:avx512fmaskmode>
4756 [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
4757 (match_operand:VI48_AVX512VL 2 "nonimmediate_operand")
4758 (match_operand:SI 3 "const_0_to_7_operand")]
4759 UNSPEC_UNSIGNED_PCMP)))
4760 (set (match_operand:<VI48_AVX512VL:avx512fmaskmode> 4 "register_operand")
4761 (unspec:<VI48_AVX512VL:avx512fmaskmode>
4762 [(match_dup 1)
4763 (match_dup 2)
4764 (match_dup 3)]
4765 UNSPEC_UNSIGNED_PCMP))]
4766 "TARGET_AVX512F
4767 && (!VALID_MASK_AVX512BW_MODE (<SWI248x:MODE>mode) || TARGET_AVX512BW)
4768 && (GET_MODE_NUNITS (<VI48_AVX512VL:MODE>mode)
4769 < GET_MODE_PRECISION (<SWI248x:MODE>mode))
4770 && ix86_pre_reload_split ()"
4771 "#"
4772 "&& 1"
4773 [(set (match_dup 0)
4774 (zero_extend:SWI248x
4775 (unspec:<VI48_AVX512VL:avx512fmaskmode>
4776 [(match_dup 1)
4777 (match_dup 2)
4778 (match_dup 3)]
4779 UNSPEC_UNSIGNED_PCMP)))
4780 (set (match_dup 4) (match_dup 5))]
4781 {
4782 operands[5] = lowpart_subreg (<VI48_AVX512VL:avx512fmaskmode>mode,
4783 operands[0], <SWI248x:MODE>mode);
4784 if (SUBREG_P (operands[5]))
4785 {
4786 SUBREG_PROMOTED_VAR_P (operands[5]) = 1;
4787 SUBREG_PROMOTED_SET (operands[5], 1);
4788 }
4789 }
4790 [(set_attr "type" "ssecmp")
4791 (set_attr "length_immediate" "1")
4792 (set_attr "prefix" "evex")
4793 (set_attr "mode" "<VI48_AVX512VL:sseinsnmode>")])
4794
4795 (define_insn_and_split "*<avx512>_ucmp<mode>3"
4796 [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
4797 (not:<avx512fmaskmode>
4798 (unspec:<avx512fmaskmode>
4799 [(match_operand:VI48_AVX512VL 1 "register_operand")
4800 (match_operand:VI48_AVX512VL 2 "nonimmediate_operand")
4801 (match_operand:SI 3 "const_0_to_7_operand")]
4802 UNSPEC_UNSIGNED_PCMP)))]
4803 "TARGET_AVX512F && ix86_pre_reload_split ()"
4804 "#"
4805 "&& 1"
4806 [(set (match_dup 0)
4807 (unspec:<avx512fmaskmode>
4808 [(match_dup 1)
4809 (match_dup 2)
4810 (match_dup 4)]
4811 UNSPEC_UNSIGNED_PCMP))]
4812 "operands[4] = GEN_INT (INTVAL (operands[3]) ^ 4);")
4813
4814 (define_int_attr pcmp_signed_mask
4815 [(UNSPEC_PCMP "3") (UNSPEC_UNSIGNED_PCMP "1")])
4816
4817 ;; PR96906 - optimize vpsubusw compared to 0 into vpcmpleuw or vpcmpnltuw.
4818 ;; For signed comparison, handle EQ 0: NEQ 4,
4819 ;; for unsigned comparison extra handle LE:2, NLE:6, equivalent to EQ and NEQ.
4820
4821 (define_insn_and_split "*<avx512>_ucmp<mode>3_1"
4822 [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
4823 (unspec:<avx512fmaskmode>
4824 [(us_minus:VI12_AVX512VL
4825 (match_operand:VI12_AVX512VL 1 "vector_operand")
4826 (match_operand:VI12_AVX512VL 2 "vector_operand"))
4827 (match_operand:VI12_AVX512VL 3 "const0_operand")
4828 (match_operand:SI 4 "const_0_to_7_operand")]
4829 UNSPEC_PCMP_ITER))]
4830 "TARGET_AVX512BW && ix86_pre_reload_split ()
4831 && ix86_binary_operator_ok (US_MINUS, <MODE>mode, operands)
4832 && (INTVAL (operands[4]) & <pcmp_signed_mask>) == 0"
4833 "#"
4834 "&& 1"
4835 [(const_int 0)]
4836 {
4837 /* LE: 2, NLT: 5, NLE: 6, LT: 1 */
4838 int cmp_predicate = 2; /* LE */
4839 if (MEM_P (operands[1]))
4840 {
4841 std::swap (operands[1], operands[2]);
4842 cmp_predicate = 5; /* NLT (GE) */
4843 }
4844 if ((INTVAL (operands[4]) & 4) != 0)
4845 cmp_predicate ^= 4; /* Invert the comparison to NLE (GT) or LT. */
4846 emit_insn (gen_<avx512>_ucmp<mode>3 (operands[0], operands[1],operands[2],
4847 GEN_INT (cmp_predicate)));
4848 DONE;
4849 })
4850
4851 (define_insn "avx512f_vmcmp<mode>3<round_saeonly_name>"
4852 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
4853 (and:<avx512fmaskmode>
4854 (unspec:<avx512fmaskmode>
4855 [(match_operand:VFH_128 1 "register_operand" "v")
4856 (match_operand:VFH_128 2 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4857 (match_operand:SI 3 "const_0_to_31_operand")]
4858 UNSPEC_PCMP)
4859 (const_int 1)))]
4860 "TARGET_AVX512F"
4861 "vcmp<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %<iptr>2<round_saeonly_op4>, %3}"
4862 [(set_attr "type" "ssecmp")
4863 (set_attr "length_immediate" "1")
4864 (set_attr "prefix" "evex")
4865 (set_attr "mode" "<ssescalarmode>")])
4866
4867 (define_insn "avx512f_vmcmp<mode>3_mask<round_saeonly_name>"
4868 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
4869 (and:<avx512fmaskmode>
4870 (unspec:<avx512fmaskmode>
4871 [(match_operand:VFH_128 1 "register_operand" "v")
4872 (match_operand:VFH_128 2 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4873 (match_operand:SI 3 "const_0_to_31_operand")]
4874 UNSPEC_PCMP)
4875 (and:<avx512fmaskmode>
4876 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")
4877 (const_int 1))))]
4878 "TARGET_AVX512F"
4879 "vcmp<ssescalarmodesuffix>\t{%3, <round_saeonly_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %<iptr>2<round_saeonly_op5>, %3}"
4880 [(set_attr "type" "ssecmp")
4881 (set_attr "length_immediate" "1")
4882 (set_attr "prefix" "evex")
4883 (set_attr "mode" "<ssescalarmode>")])
4884
4885 (define_insn "avx10_2_<unord>comx<mode><round_saeonly_name>"
4886 [(set (reg:CCFP FLAGS_REG)
4887 (unspec:CCFP
4888 [(vec_select:MODEFH
4889 (match_operand:<ssevecmode> 0 "register_operand" "v")
4890 (parallel [(const_int 0)]))
4891 (vec_select:MODEFH
4892 (match_operand:<ssevecmode> 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4893 (parallel [(const_int 0)]))]
4894 UNSPEC_COMX))]
4895 "TARGET_AVX10_2"
4896 "v<unord>comx<ssemodesuffix>\t{<round_saeonly_op2>%1, %0|%0, %<iptr>1<round_saeonly_op2>}"
4897 [(set_attr "type" "ssecomi")
4898 (set_attr "prefix" "evex")
4899 (set_attr "mode" "<MODE>")])
4900
4901 (define_insn "<sse>_<unord>comi<round_saeonly_name>"
4902 [(set (reg:CCFP FLAGS_REG)
4903 (compare:CCFP
4904 (vec_select:MODEFH
4905 (match_operand:<ssevecmode> 0 "register_operand" "v")
4906 (parallel [(const_int 0)]))
4907 (vec_select:MODEFH
4908 (match_operand:<ssevecmode> 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4909 (parallel [(const_int 0)]))))]
4910 "SSE_FLOAT_MODE_P (<MODE>mode) || <MODE>mode == E_HFmode"
4911 "%v<unord>comi<ssemodesuffix>\t{<round_saeonly_op2>%1, %0|%0, %<iptr>1<round_saeonly_op2>}"
4912 [(set_attr "type" "ssecomi")
4913 (set_attr "prefix" "maybe_vex")
4914 (set_attr "prefix_rep" "0")
4915 (set (attr "prefix_data16")
4916 (if_then_else (eq_attr "mode" "DF")
4917 (const_string "1")
4918 (const_string "0")))
4919 (set_attr "mode" "<MODE>")])
4920
4921 (define_insn "avx10_2_comisbf16_v8bf"
4922 [(set (reg:CCFP FLAGS_REG)
4923 (compare:CCFP
4924 (vec_select:BF
4925 (match_operand:V8BF 0 "register_operand" "v")
4926 (parallel [(const_int 0)]))
4927 (vec_select:BF
4928 (match_operand:V8BF 1 "nonimmediate_operand" "vm")
4929 (parallel [(const_int 0)]))))]
4930 "TARGET_AVX10_2"
4931 "vcomisbf16\t{%1, %0|%0, %w1}"
4932 [(set_attr "prefix" "evex")
4933 (set_attr "type" "ssecomi")])
4934
4935 (define_expand "vec_cmp<mode><avx512fmaskmodelower>"
4936 [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
4937 (match_operator:<avx512fmaskmode> 1 ""
4938 [(match_operand:V48H_AVX512VL 2 "register_operand")
4939 (match_operand:V48H_AVX512VL 3 "nonimmediate_operand")]))]
4940 "TARGET_AVX512F"
4941 {
4942 bool ok = ix86_expand_mask_vec_cmp (operands[0], GET_CODE (operands[1]),
4943 operands[2], operands[3]);
4944 gcc_assert (ok);
4945 DONE;
4946 })
4947
4948 (define_expand "vec_cmp<mode><avx512fmaskmodelower>"
4949 [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
4950 (match_operator:<avx512fmaskmode> 1 ""
4951 [(match_operand:VI12_AVX512VL 2 "register_operand")
4952 (match_operand:VI12_AVX512VL 3 "nonimmediate_operand")]))]
4953 "TARGET_AVX512BW"
4954 {
4955 bool ok = ix86_expand_mask_vec_cmp (operands[0], GET_CODE (operands[1]),
4956 operands[2], operands[3]);
4957 gcc_assert (ok);
4958 DONE;
4959 })
4960
4961 (define_expand "vec_cmp<mode><avx512fmaskmodelower>"
4962 [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
4963 (match_operator:<avx512fmaskmode> 1 ""
4964 [(match_operand:VBF_AVX10_2 2 "register_operand")
4965 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand")]))]
4966 "TARGET_AVX10_2"
4967 {
4968 bool ok = ix86_expand_mask_vec_cmp (operands[0], GET_CODE (operands[1]),
4969 operands[2], operands[3]);
4970 gcc_assert (ok);
4971 DONE;
4972 })
4973
4974 (define_expand "vec_cmp<mode><sseintvecmodelower>"
4975 [(set (match_operand:<sseintvecmode> 0 "register_operand")
4976 (match_operator:<sseintvecmode> 1 ""
4977 [(match_operand:VI_256 2 "register_operand")
4978 (match_operand:VI_256 3 "nonimmediate_or_const_vector_operand")]))]
4979 "TARGET_AVX2"
4980 {
4981 bool ok = ix86_expand_int_vec_cmp (operands);
4982 gcc_assert (ok);
4983 DONE;
4984 })
4985
4986 (define_expand "vec_cmp<mode><sseintvecmodelower>"
4987 [(set (match_operand:<sseintvecmode> 0 "register_operand")
4988 (match_operator:<sseintvecmode> 1 ""
4989 [(match_operand:VI124_128 2 "register_operand")
4990 (match_operand:VI124_128 3 "vector_or_const_vector_operand")]))]
4991 "TARGET_SSE2"
4992 {
4993 bool ok = ix86_expand_int_vec_cmp (operands);
4994 gcc_assert (ok);
4995 DONE;
4996 })
4997
4998 (define_expand "vec_cmpv2div2di"
4999 [(set (match_operand:V2DI 0 "register_operand")
5000 (match_operator:V2DI 1 ""
5001 [(match_operand:V2DI 2 "register_operand")
5002 (match_operand:V2DI 3 "vector_or_const_vector_operand")]))]
5003 "TARGET_SSE4_2"
5004 {
5005 bool ok = ix86_expand_int_vec_cmp (operands);
5006 gcc_assert (ok);
5007 DONE;
5008 })
5009
5010 (define_expand "vec_cmp<mode><sseintvecmodelower>"
5011 [(set (match_operand:<sseintvecmode> 0 "register_operand")
5012 (match_operator:<sseintvecmode> 1 ""
5013 [(match_operand:VF_256 2 "register_operand")
5014 (match_operand:VF_256 3 "nonimmediate_operand")]))]
5015 "TARGET_AVX"
5016 {
5017 bool ok = ix86_expand_fp_vec_cmp (operands);
5018 gcc_assert (ok);
5019 DONE;
5020 })
5021
5022 (define_expand "vec_cmp<mode><sseintvecmodelower>"
5023 [(set (match_operand:<sseintvecmode> 0 "register_operand")
5024 (match_operator:<sseintvecmode> 1 ""
5025 [(match_operand:VF_128 2 "register_operand")
5026 (match_operand:VF_128 3 "vector_operand")]))]
5027 "TARGET_SSE"
5028 {
5029 bool ok = ix86_expand_fp_vec_cmp (operands);
5030 gcc_assert (ok);
5031 DONE;
5032 })
5033
5034 (define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
5035 [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
5036 (match_operator:<avx512fmaskmode> 1 ""
5037 [(match_operand:VI48_AVX512VL 2 "register_operand")
5038 (match_operand:VI48_AVX512VL 3 "nonimmediate_operand")]))]
5039 "TARGET_AVX512F"
5040 {
5041 bool ok = ix86_expand_mask_vec_cmp (operands[0], GET_CODE (operands[1]),
5042 operands[2], operands[3]);
5043 gcc_assert (ok);
5044 DONE;
5045 })
5046
5047 (define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
5048 [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
5049 (match_operator:<avx512fmaskmode> 1 ""
5050 [(match_operand:VI12_AVX512VL 2 "register_operand")
5051 (match_operand:VI12_AVX512VL 3 "nonimmediate_operand")]))]
5052 "TARGET_AVX512BW"
5053 {
5054 bool ok = ix86_expand_mask_vec_cmp (operands[0], GET_CODE (operands[1]),
5055 operands[2], operands[3]);
5056 gcc_assert (ok);
5057 DONE;
5058 })
5059
5060 (define_expand "vec_cmpu<mode><sseintvecmodelower>"
5061 [(set (match_operand:<sseintvecmode> 0 "register_operand")
5062 (match_operator:<sseintvecmode> 1 ""
5063 [(match_operand:VI_256 2 "register_operand")
5064 (match_operand:VI_256 3 "nonimmediate_or_const_vector_operand")]))]
5065 "TARGET_AVX2"
5066 {
5067 bool ok = ix86_expand_int_vec_cmp (operands);
5068 gcc_assert (ok);
5069 DONE;
5070 })
5071
5072 (define_expand "vec_cmpu<mode><sseintvecmodelower>"
5073 [(set (match_operand:<sseintvecmode> 0 "register_operand")
5074 (match_operator:<sseintvecmode> 1 ""
5075 [(match_operand:VI124_128 2 "register_operand")
5076 (match_operand:VI124_128 3 "vector_or_const_vector_operand")]))]
5077 "TARGET_SSE2"
5078 {
5079 bool ok = ix86_expand_int_vec_cmp (operands);
5080 gcc_assert (ok);
5081 DONE;
5082 })
5083
5084 (define_expand "vec_cmpuv2div2di"
5085 [(set (match_operand:V2DI 0 "register_operand")
5086 (match_operator:V2DI 1 ""
5087 [(match_operand:V2DI 2 "register_operand")
5088 (match_operand:V2DI 3 "vector_or_const_vector_operand")]))]
5089 "TARGET_SSE4_2"
5090 {
5091 bool ok = ix86_expand_int_vec_cmp (operands);
5092 gcc_assert (ok);
5093 DONE;
5094 })
5095
5096 (define_expand "vec_cmpeqv2div2di"
5097 [(set (match_operand:V2DI 0 "register_operand")
5098 (match_operator:V2DI 1 ""
5099 [(match_operand:V2DI 2 "register_operand")
5100 (match_operand:V2DI 3 "vector_operand")]))]
5101 "TARGET_SSE2"
5102 {
5103 bool ok;
5104 if (!TARGET_SSE4_1)
5105 {
5106 rtx ops[4];
5107 ops[0] = gen_reg_rtx (V4SImode);
5108 ops[2] = gen_lowpart (V4SImode, force_reg (V2DImode, operands[2]));
5109 ops[3] = gen_lowpart (V4SImode, force_reg (V2DImode, operands[3]));
5110 ops[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), V4SImode,
5111 ops[2], ops[3]);
5112 ok = ix86_expand_int_vec_cmp (ops);
5113
5114 rtx tmp1 = gen_reg_rtx (V4SImode);
5115 emit_insn (gen_sse2_pshufd (tmp1, ops[0], GEN_INT (0xb1)));
5116
5117 rtx tmp2 = gen_reg_rtx (V4SImode);
5118 if (GET_CODE (operands[1]) == EQ)
5119 emit_insn (gen_andv4si3 (tmp2, tmp1, ops[0]));
5120 else
5121 emit_insn (gen_iorv4si3 (tmp2, tmp1, ops[0]));
5122
5123 emit_move_insn (operands[0], gen_lowpart (V2DImode, tmp2));
5124 }
5125 else
5126 ok = ix86_expand_int_vec_cmp (operands);
5127 gcc_assert (ok);
5128 DONE;
5129 })
5130
5131 (define_expand "vec_cmpeqv1tiv1ti"
5132 [(set (match_operand:V1TI 0 "register_operand")
5133 (match_operator:V1TI 1 ""
5134 [(match_operand:V1TI 2 "register_operand")
5135 (match_operand:V1TI 3 "vector_operand")]))]
5136 "TARGET_SSE2"
5137 {
5138 rtx dst = gen_reg_rtx (V2DImode);
5139 rtx op1 = gen_lowpart (V2DImode, force_reg (V1TImode, operands[2]));
5140 rtx op2 = gen_lowpart (V2DImode, force_reg (V1TImode, operands[3]));
5141 rtx cmp = gen_rtx_fmt_ee (GET_CODE (operands[1]), V2DImode, op1, op2);
5142 emit_insn (gen_vec_cmpeqv2div2di (dst, cmp, op1, op2));
5143
5144 rtx tmp1 = gen_reg_rtx (V4SImode);
5145 rtx tmp2 = gen_lowpart (V4SImode, dst);
5146 emit_insn (gen_sse2_pshufd (tmp1, tmp2, GEN_INT (0x4e)));
5147
5148 rtx tmp3 = gen_reg_rtx (V4SImode);
5149 if (GET_CODE (operands[1]) == EQ)
5150 emit_insn (gen_andv4si3 (tmp3, tmp2, tmp1));
5151 else
5152 emit_insn (gen_iorv4si3 (tmp3, tmp2, tmp1));
5153
5154 emit_move_insn (operands[0], gen_lowpart (V1TImode, tmp3));
5155 DONE;
5156 })
5157
5158 (define_expand "vcond_mask_<mode><avx512fmaskmodelower>"
5159 [(set (match_operand:V48_AVX512VL 0 "register_operand")
5160 (vec_merge:V48_AVX512VL
5161 (match_operand:V48_AVX512VL 1 "nonimmediate_operand")
5162 (match_operand:V48_AVX512VL 2 "nonimm_or_0_operand")
5163 (match_operand:<avx512fmaskmode> 3 "register_operand")))]
5164 "TARGET_AVX512F")
5165
5166 (define_expand "vcond_mask_<mode><avx512fmaskmodelower>"
5167 [(set (match_operand:VI12HFBF_AVX512VL 0 "register_operand")
5168 (vec_merge:VI12HFBF_AVX512VL
5169 (match_operand:VI12HFBF_AVX512VL 1 "nonimmediate_operand")
5170 (match_operand:VI12HFBF_AVX512VL 2 "nonimm_or_0_operand")
5171 (match_operand:<avx512fmaskmode> 3 "register_operand")))]
5172 "TARGET_AVX512BW")
5173
5174 ;; As vcondv4div4df and vcondv8siv8sf are enabled already with TARGET_AVX,
5175 ;; and their condition can be folded late into a constant, we need to
5176 ;; support vcond_mask_v4div4di and vcond_mask_v8siv8si for TARGET_AVX.
5177 (define_mode_iterator VI_256_AVX2 [(V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
5178 V8SI V4DI])
5179
5180 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
5181 [(set (match_operand:VI_256_AVX2 0 "register_operand")
5182 (vec_merge:VI_256_AVX2
5183 (match_operand:VI_256_AVX2 1 "nonimmediate_operand")
5184 (match_operand:VI_256_AVX2 2 "nonimm_or_0_operand")
5185 (match_operand:<sseintvecmode> 3 "register_operand")))]
5186 "TARGET_AVX"
5187 {
5188 ix86_expand_sse_movcc (operands[0], operands[3],
5189 operands[1], operands[2]);
5190 DONE;
5191 })
5192
5193 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
5194 [(set (match_operand:VI_128 0 "register_operand")
5195 (vec_merge:VI_128
5196 (match_operand:VI_128 1 "vector_operand")
5197 (match_operand:VI_128 2 "nonimm_or_0_operand")
5198 (match_operand:<sseintvecmode> 3 "register_operand")))]
5199 "TARGET_SSE2"
5200 {
5201 ix86_expand_sse_movcc (operands[0], operands[3],
5202 operands[1], operands[2]);
5203 DONE;
5204 })
5205
5206 (define_expand "vcond_mask_v1tiv1ti"
5207 [(set (match_operand:V1TI 0 "register_operand")
5208 (vec_merge:V1TI
5209 (match_operand:V1TI 1 "vector_operand")
5210 (match_operand:V1TI 2 "nonimm_or_0_operand")
5211 (match_operand:V1TI 3 "register_operand")))]
5212 "TARGET_SSE2"
5213 {
5214 ix86_expand_sse_movcc (operands[0], operands[3],
5215 operands[1], operands[2]);
5216 DONE;
5217 })
5218
5219 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
5220 [(set (match_operand:VF_256 0 "register_operand")
5221 (vec_merge:VF_256
5222 (match_operand:VF_256 1 "nonimmediate_operand")
5223 (match_operand:VF_256 2 "nonimm_or_0_operand")
5224 (match_operand:<sseintvecmode> 3 "register_operand")))]
5225 "TARGET_AVX"
5226 {
5227 ix86_expand_sse_movcc (operands[0], operands[3],
5228 operands[1], operands[2]);
5229 DONE;
5230 })
5231
5232 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
5233 [(set (match_operand:VF_128 0 "register_operand")
5234 (vec_merge:VF_128
5235 (match_operand:VF_128 1 "vector_operand")
5236 (match_operand:VF_128 2 "nonimm_or_0_operand")
5237 (match_operand:<sseintvecmode> 3 "register_operand")))]
5238 "TARGET_SSE"
5239 {
5240 ix86_expand_sse_movcc (operands[0], operands[3],
5241 operands[1], operands[2]);
5242 DONE;
5243 })
5244
5245 (define_expand "vcond_mask_<mode><mode>"
5246 [(match_operand:SWI1248_AVX512BW 0 "register_operand")
5247 (match_operand:SWI1248_AVX512BW 1 "register_operand")
5248 (match_operand:SWI1248_AVX512BW 2 "register_operand")
5249 (match_operand:SWI1248_AVX512BW 3 "register_operand")]
5250 "TARGET_AVX512F"
5251 {
5252 /* (operand[1] & operand[3]) | (operand[2] & ~operand[3]) */
5253 rtx op1 = gen_reg_rtx (<MODE>mode);
5254 rtx op2 = gen_reg_rtx (<MODE>mode);
5255 rtx op3 = gen_reg_rtx (<MODE>mode);
5256
5257 emit_insn (gen_and<mode>3 (op1, operands[1], operands[3]));
5258 emit_insn (gen_one_cmpl<mode>2 (op3, operands[3]));
5259 emit_insn (gen_and<mode>3 (op2, operands[2], op3));
5260 emit_insn (gen_ior<mode>3 (operands[0], op1, op2));
5261
5262 DONE;
5263 })
5264
5265 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5266 ;;
5267 ;; Parallel floating point logical operations
5268 ;;
5269 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5270
5271 (define_insn "<sse>_andnot<mode>3<mask_name>"
5272 [(set (match_operand:VFB_128_256 0 "register_operand" "=x,x,v,v")
5273 (and:VFB_128_256
5274 (not:VFB_128_256
5275 (match_operand:VFB_128_256 1 "register_operand" "0,x,v,v"))
5276 (match_operand:VFB_128_256 2 "vector_operand" "xBm,xjm,vm,vm")))]
5277 "TARGET_SSE && <mask_avx512vl_condition>
5278 && (!<mask_applied> || <ssescalarsize> != 16)"
5279 {
5280 char buf[128];
5281 const char *ops;
5282 const char *suffix;
5283
5284 switch (which_alternative)
5285 {
5286 case 0:
5287 ops = "andn%s\t{%%2, %%0|%%0, %%2}";
5288 break;
5289 case 1:
5290 case 2:
5291 case 3:
5292 ops = "vandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
5293 break;
5294 default:
5295 gcc_unreachable ();
5296 }
5297
5298 switch (get_attr_mode (insn))
5299 {
5300 case MODE_V16BF:
5301 case MODE_V8BF:
5302 case MODE_V16HF:
5303 case MODE_V8HF:
5304 case MODE_V8SF:
5305 case MODE_V4SF:
5306 suffix = "ps";
5307 break;
5308 case MODE_OI:
5309 case MODE_TI:
5310 /* There is no vandnp[sd] in avx512f. Use vpandn[qd]. */
5311 suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
5312 ops = "vpandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
5313 break;
5314 default:
5315 suffix = "<ssemodesuffix>";
5316 }
5317
5318 snprintf (buf, sizeof (buf), ops, suffix);
5319 output_asm_insn (buf, operands);
5320 return "";
5321 }
5322 [(set_attr "isa" "noavx,avx_noavx512f,avx512dq,avx512f")
5323 (set_attr "addr" "*,gpr16,*,*")
5324 (set_attr "type" "sselog")
5325 (set_attr "c86_attr" "sselogic")
5326 (set_attr "prefix" "orig,maybe_vex,evex,evex")
5327 (set (attr "mode")
5328 (cond [(and (match_test "<mask_applied>")
5329 (and (eq_attr "alternative" "1")
5330 (match_test "!TARGET_AVX512DQ")))
5331 (const_string "<sseintvecmode2>")
5332 (and (not (match_test "<mask_applied>"))
5333 (eq_attr "alternative" "3")
5334 (match_test "!x86_evex_reg_mentioned_p (operands, 3)"))
5335 (const_string "<MODE>")
5336 (eq_attr "alternative" "3")
5337 (const_string "<sseintvecmode2>")
5338 (match_test "TARGET_AVX")
5339 (const_string "<MODE>")
5340 (match_test "optimize_function_for_size_p (cfun)")
5341 (const_string "V4SF")
5342 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
5343 (const_string "V4SF")
5344 ]
5345 (const_string "<MODE>")))])
5346
5347 (define_insn "<sse>_andnot<mode>3<mask_name>"
5348 [(set (match_operand:VFB_512 0 "register_operand" "=v")
5349 (and:VFB_512
5350 (not:VFB_512
5351 (match_operand:VFB_512 1 "register_operand" "v"))
5352 (match_operand:VFB_512 2 "nonimmediate_operand" "vm")))]
5353 "TARGET_AVX512F && (!<mask_applied> || <ssescalarsize> != 16)"
5354 {
5355 char buf[128];
5356 const char *ops;
5357 const char *suffix;
5358
5359 suffix = "<ssemodesuffix>";
5360 ops = "";
5361
5362 /* Since there are no vandnp[sd] without AVX512DQ nor vandnph,
5363 use vp<logic>[dq]. */
5364 if (!TARGET_AVX512DQ || <MODE>mode == V32HFmode || <MODE>mode == V32BFmode)
5365 {
5366 suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
5367 ops = "p";
5368 }
5369
5370 snprintf (buf, sizeof (buf),
5371 "v%sandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}",
5372 ops, suffix);
5373 output_asm_insn (buf, operands);
5374 return "";
5375 }
5376 [(set_attr "type" "sselog")
5377 (set_attr "c86_attr" "sselogic")
5378 (set_attr "prefix" "evex")
5379 (set (attr "mode")
5380 (if_then_else (match_test "TARGET_AVX512DQ")
5381 (const_string "<sseinsnmode>")
5382 (const_string "XI")))])
5383
5384 (define_expand "<code><mode>3<mask_name>"
5385 [(set (match_operand:VFB_128_256 0 "register_operand")
5386 (any_logic:VFB_128_256
5387 (match_operand:VFB_128_256 1 "vector_operand")
5388 (match_operand:VFB_128_256 2 "vector_operand")))]
5389 "TARGET_SSE && <mask_avx512vl_condition>
5390 && (!<mask_applied> || <ssescalarsize> != 16)"
5391 "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
5392
5393 (define_expand "<code><mode>3<mask_name>"
5394 [(set (match_operand:VFB_512 0 "register_operand")
5395 (any_logic:VFB_512
5396 (match_operand:VFB_512 1 "nonimmediate_operand")
5397 (match_operand:VFB_512 2 "nonimmediate_operand")))]
5398 "TARGET_AVX512F && (!<mask_applied> || <ssescalarsize> != 16)"
5399 "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
5400
5401 (define_insn "*<code><mode>3<mask_name>"
5402 [(set (match_operand:VFB_128_256 0 "register_operand" "=x,x,v,v")
5403 (any_logic:VFB_128_256
5404 (match_operand:VFB_128_256 1 "vector_operand" "%0,x,v,v")
5405 (match_operand:VFB_128_256 2 "vector_operand" "xBm,xm,vm,vm")))]
5406 "TARGET_SSE && <mask_avx512vl_condition>
5407 && (!<mask_applied> || <ssescalarsize> != 16)
5408 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
5409 {
5410 char buf[128];
5411 const char *ops;
5412 const char *suffix;
5413
5414 switch (which_alternative)
5415 {
5416 case 0:
5417 ops = "<logic>%s\t{%%2, %%0|%%0, %%2}";
5418 break;
5419 case 1:
5420 case 2:
5421 case 3:
5422 ops = "v<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
5423 break;
5424 default:
5425 gcc_unreachable ();
5426 }
5427
5428 switch (get_attr_mode (insn))
5429 {
5430 case MODE_V16BF:
5431 case MODE_V8BF:
5432 case MODE_V16HF:
5433 case MODE_V8HF:
5434 case MODE_V8SF:
5435 case MODE_V4SF:
5436 suffix = "ps";
5437 break;
5438 case MODE_OI:
5439 case MODE_TI:
5440 /* There is no v<logic>p[sd] in avx512f. Use vp<logic>[qd]. */
5441 suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
5442 ops = "vp<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
5443 break;
5444 default:
5445 suffix = "<ssemodesuffix>";
5446 }
5447
5448 snprintf (buf, sizeof (buf), ops, suffix);
5449 output_asm_insn (buf, operands);
5450 return "";
5451 }
5452 [(set_attr "isa" "noavx,avx,avx512dq,avx512f")
5453 (set_attr "type" "sselog")
5454 (set_attr "c86_attr" "sselogic")
5455 (set_attr "prefix" "orig,maybe_evex,evex,evex")
5456 (set (attr "mode")
5457 (cond [(and (match_test "<mask_applied>")
5458 (and (eq_attr "alternative" "1")
5459 (match_test "!TARGET_AVX512DQ")))
5460 (const_string "<sseintvecmode2>")
5461 (eq_attr "alternative" "3")
5462 (const_string "<sseintvecmode2>")
5463 (match_test "TARGET_AVX")
5464 (const_string "<MODE>")
5465 (match_test "optimize_function_for_size_p (cfun)")
5466 (const_string "V4SF")
5467 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
5468 (const_string "V4SF")
5469 ]
5470 (const_string "<MODE>")))])
5471
5472 (define_insn "*<code><mode>3<mask_name>"
5473 [(set (match_operand:VFB_512 0 "register_operand" "=v")
5474 (any_logic:VFB_512
5475 (match_operand:VFB_512 1 "nonimmediate_operand" "%v")
5476 (match_operand:VFB_512 2 "nonimmediate_operand" "vm")))]
5477 "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))
5478 && (!<mask_applied> || <ssescalarsize> != 16)"
5479 {
5480 char buf[128];
5481 const char *ops;
5482 const char *suffix;
5483
5484 suffix = "<ssemodesuffix>";
5485 ops = "";
5486
5487 /* Since there are no v<logic>p[sd] without AVX512DQ nor v<logic>ph,
5488 use vp<logic>[dq]. */
5489 if (!TARGET_AVX512DQ || <MODE>mode == V32HFmode || <MODE>mode == V32BFmode)
5490 {
5491 suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
5492 ops = "p";
5493 }
5494
5495 snprintf (buf, sizeof (buf),
5496 "v%s<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}",
5497 ops, suffix);
5498 output_asm_insn (buf, operands);
5499 return "";
5500 }
5501 [(set_attr "type" "sselog")
5502 (set_attr "c86_attr" "sselogic")
5503 (set_attr "prefix" "evex")
5504 (set (attr "mode")
5505 (if_then_else (match_test "TARGET_AVX512DQ")
5506 (const_string "<sseinsnmode>")
5507 (const_string "XI")))])
5508
5509 ;; Generic part doesn't support the simpliciation of logic operation with
5510 ;; float_vector_all_ones_operand since it's not valid rtl. Add combine spiltter
5511 ;; for them, it should be safe since there's no SIMD Floating-Point Exceptions.
5512 (define_insn_and_split "*bit_and_float_vector_all_ones"
5513 [(set (match_operand:VFB 0 "nonimmediate_operand")
5514 (and:VFB (match_operand:VFB 1 "nonimmediate_operand")
5515 (match_operand:VFB 2 "float_vector_all_ones_operand")))]
5516 "TARGET_SSE && ix86_pre_reload_split ()"
5517 "#"
5518 "&& 1"
5519 [(set (match_dup 0) (match_dup 1))]
5520 "operands[1] = force_reg (<MODE>mode, operands[1]);")
5521
5522 (define_expand "copysign<mode>3"
5523 [(set (match_dup 4)
5524 (and:VFB
5525 (not:VFB (match_dup 3))
5526 (match_operand:VFB 1 "vector_operand")))
5527 (set (match_dup 5)
5528 (and:VFB (match_dup 3)
5529 (match_operand:VFB 2 "vector_operand")))
5530 (set (match_operand:VFB 0 "register_operand")
5531 (ior:VFB (match_dup 4) (match_dup 5)))]
5532 "TARGET_SSE"
5533 {
5534 operands[3] = ix86_build_signbit_mask (<MODE>mode, 1, 0);
5535
5536 operands[4] = gen_reg_rtx (<MODE>mode);
5537 operands[5] = gen_reg_rtx (<MODE>mode);
5538 })
5539
5540 (define_expand "xorsign<mode>3"
5541 [(set (match_dup 4)
5542 (and:VFB (match_dup 3)
5543 (match_operand:VFB 2 "vector_operand")))
5544 (set (match_operand:VFB 0 "register_operand")
5545 (xor:VFB (match_dup 4)
5546 (match_operand:VFB 1 "vector_operand")))]
5547 "TARGET_SSE"
5548 {
5549 operands[3] = ix86_build_signbit_mask (<MODE>mode, 1, 0);
5550
5551 operands[4] = gen_reg_rtx (<MODE>mode);
5552 })
5553
5554 (define_expand "signbit<mode>2"
5555 [(set (match_operand:<sseintvecmode> 0 "register_operand")
5556 (lshiftrt:<sseintvecmode>
5557 (subreg:<sseintvecmode>
5558 (match_operand:VF1_AVX2 1 "register_operand") 0)
5559 (match_dup 2)))]
5560 "TARGET_SSE2"
5561 {
5562 operands[1] = force_reg (<MODE>mode, operands[1]);
5563 operands[2] = GEN_INT (GET_MODE_UNIT_BITSIZE (<MODE>mode)-1);
5564 })
5565
5566 ;; Also define scalar versions. These are used for abs, neg, and
5567 ;; conditional move. Using subregs into vector modes causes register
5568 ;; allocation lossage. These patterns do not allow memory operands
5569 ;; because the native instructions read the full 128-bits.
5570
5571 (define_insn "*andnot<mode>3"
5572 [(set (match_operand:MODEF248 0 "register_operand" "=x,x,v,v")
5573 (and:MODEF248
5574 (not:MODEF248
5575 (match_operand:MODEF248 1 "register_operand" "0,x,v,v"))
5576 (match_operand:MODEF248 2 "register_operand" "x,x,v,v")))]
5577 "TARGET_SSE"
5578 {
5579 char buf[128];
5580 const char *ops;
5581 const char *suffix
5582 = (get_attr_mode (insn) == MODE_V4SF) ? "ps" : "<ssevecmodesuffix>";
5583
5584 switch (which_alternative)
5585 {
5586 case 0:
5587 ops = "andn%s\t{%%2, %%0|%%0, %%2}";
5588 break;
5589 case 1:
5590 ops = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
5591 break;
5592 case 2:
5593 if (TARGET_AVX512DQ)
5594 ops = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
5595 else
5596 {
5597 suffix = <MODE>mode == DFmode ? "q" : "d";
5598 ops = "vpandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
5599 }
5600 break;
5601 case 3:
5602 if (TARGET_AVX512DQ)
5603 ops = "vandn%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
5604 else
5605 {
5606 suffix = <MODE>mode == DFmode ? "q" : "d";
5607 ops = "vpandn%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
5608 }
5609 break;
5610 default:
5611 gcc_unreachable ();
5612 }
5613
5614 snprintf (buf, sizeof (buf), ops, suffix);
5615 output_asm_insn (buf, operands);
5616 return "";
5617 }
5618 [(set_attr "isa" "noavx,avx,avx512vl,avx512f_512")
5619 (set_attr "type" "sselog")
5620 (set_attr "c86_attr" "sselogic")
5621 (set_attr "prefix" "orig,vex,evex,evex")
5622 (set (attr "mode")
5623 (cond [(eq_attr "alternative" "2")
5624 (if_then_else (match_test "TARGET_AVX512DQ")
5625 (const_string "<ssevecmode>")
5626 (const_string "TI"))
5627 (eq_attr "alternative" "3")
5628 (if_then_else (match_test "TARGET_AVX512DQ")
5629 (const_string "<avx512fvecmode>")
5630 (const_string "XI"))
5631 (match_test "TARGET_AVX")
5632 (const_string "<ssevecmode>")
5633 (match_test "optimize_function_for_size_p (cfun)")
5634 (const_string "V4SF")
5635 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
5636 (const_string "V4SF")
5637 ]
5638 (const_string "<ssevecmode>")))])
5639
5640 ;; Modes for andnot3 not covered by VI and MODEF.
5641 (define_mode_iterator ANDNOT_MODE [TF V1TI])
5642
5643 (define_insn "*andnot<mode>3"
5644 [(set (match_operand:ANDNOT_MODE 0 "register_operand" "=x,x,v,v")
5645 (and:ANDNOT_MODE
5646 (not:ANDNOT_MODE (match_operand:ANDNOT_MODE 1 "register_operand" "0,x,v,v"))
5647 (match_operand:ANDNOT_MODE 2 "vector_operand" "xBm,xjm,vm,v")))]
5648 "TARGET_SSE"
5649 {
5650 char buf[128];
5651 const char *ops;
5652 const char *tmp
5653 = (which_alternative >= 2 ? "pandnq"
5654 : get_attr_mode (insn) == MODE_V4SF ? "andnps" : "pandn");
5655
5656 switch (which_alternative)
5657 {
5658 case 0:
5659 ops = "%s\t{%%2, %%0|%%0, %%2}";
5660 break;
5661 case 1:
5662 case 2:
5663 ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
5664 break;
5665 case 3:
5666 ops = "v%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
5667 break;
5668 default:
5669 gcc_unreachable ();
5670 }
5671
5672 snprintf (buf, sizeof (buf), ops, tmp);
5673 output_asm_insn (buf, operands);
5674 return "";
5675 }
5676 [(set_attr "isa" "noavx,avx_noavx512vl,avx512vl,avx512f_512")
5677 (set_attr "addr" "*,gpr16,*,*")
5678 (set_attr "type" "sselog")
5679 (set (attr "prefix_data16")
5680 (if_then_else
5681 (and (eq_attr "alternative" "0")
5682 (eq_attr "mode" "TI"))
5683 (const_string "1")
5684 (const_string "*")))
5685 (set_attr "prefix" "orig,vex,evex,evex")
5686 (set (attr "mode")
5687 (cond [(and (eq_attr "alternative" "3")
5688 (match_test "!x86_evex_reg_mentioned_p (operands, 3)"))
5689 (const_string "TI")
5690 (eq_attr "alternative" "2")
5691 (const_string "TI")
5692 (eq_attr "alternative" "3")
5693 (const_string "XI")
5694 (match_test "TARGET_AVX")
5695 (const_string "TI")
5696 (ior (not (match_test "TARGET_SSE2"))
5697 (match_test "optimize_function_for_size_p (cfun)"))
5698 (const_string "V4SF")
5699 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
5700 (const_string "V4SF")
5701 ]
5702 (const_string "TI")))])
5703
5704 (define_insn "<code><mode>3"
5705 [(set (match_operand:MODEF248 0 "register_operand" "=x,x,v,v")
5706 (any_logic:MODEF248
5707 (match_operand:MODEF248 1 "register_operand" "%0,x,v,v")
5708 (match_operand:MODEF248 2 "register_operand" "x,x,v,v")))]
5709 "TARGET_SSE"
5710 {
5711 char buf[128];
5712 const char *ops;
5713 const char *suffix
5714 = (get_attr_mode (insn) == MODE_V4SF) ? "ps" : "<ssevecmodesuffix>";
5715
5716 switch (which_alternative)
5717 {
5718 case 0:
5719 ops = "<logic>%s\t{%%2, %%0|%%0, %%2}";
5720 break;
5721 case 2:
5722 if (!TARGET_AVX512DQ)
5723 {
5724 suffix = <MODE>mode == DFmode ? "q" : "d";
5725 ops = "vp<logic>%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
5726 break;
5727 }
5728 /* FALLTHRU */
5729 case 1:
5730 ops = "v<logic>%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
5731 break;
5732 case 3:
5733 if (TARGET_AVX512DQ)
5734 ops = "v<logic>%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
5735 else
5736 {
5737 suffix = <MODE>mode == DFmode ? "q" : "d";
5738 ops = "vp<logic>%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
5739 }
5740 break;
5741 default:
5742 gcc_unreachable ();
5743 }
5744
5745 snprintf (buf, sizeof (buf), ops, suffix);
5746 output_asm_insn (buf, operands);
5747 return "";
5748 }
5749 [(set_attr "isa" "noavx,avx,avx512vl,avx512f_512")
5750 (set_attr "type" "sselog")
5751 (set_attr "c86_attr" "sselogic")
5752 (set_attr "prefix" "orig,vex,evex,evex")
5753 (set (attr "mode")
5754 (cond [(eq_attr "alternative" "2")
5755 (if_then_else (match_test "TARGET_AVX512DQ")
5756 (const_string "<ssevecmode>")
5757 (const_string "TI"))
5758 (eq_attr "alternative" "3")
5759 (if_then_else (match_test "TARGET_AVX512DQ")
5760 (const_string "<avx512fvecmode>")
5761 (const_string "XI"))
5762 (match_test "TARGET_AVX")
5763 (const_string "<ssevecmode>")
5764 (match_test "optimize_function_for_size_p (cfun)")
5765 (const_string "V4SF")
5766 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
5767 (const_string "V4SF")
5768 ]
5769 (const_string "<ssevecmode>")))])
5770
5771 (define_expand "<code>tf3"
5772 [(set (match_operand:TF 0 "register_operand")
5773 (any_logic:TF
5774 (match_operand:TF 1 "vector_operand")
5775 (match_operand:TF 2 "vector_operand")))]
5776 "TARGET_SSE"
5777 "ix86_fixup_binary_operands_no_copy (<CODE>, TFmode, operands);")
5778
5779 (define_insn "*<code>tf3"
5780 [(set (match_operand:TF 0 "register_operand" "=x,x,v,v")
5781 (any_logic:TF
5782 (match_operand:TF 1 "vector_operand" "%0,x,v,v")
5783 (match_operand:TF 2 "vector_operand" "xBm,xm,vm,v")))]
5784 "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
5785 {
5786 char buf[128];
5787 const char *ops;
5788 const char *tmp
5789 = (which_alternative >= 2 ? "p<logic>q"
5790 : get_attr_mode (insn) == MODE_V4SF ? "<logic>ps" : "p<logic>");
5791
5792 switch (which_alternative)
5793 {
5794 case 0:
5795 ops = "%s\t{%%2, %%0|%%0, %%2}";
5796 break;
5797 case 1:
5798 case 2:
5799 ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
5800 break;
5801 case 3:
5802 ops = "v%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
5803 break;
5804 default:
5805 gcc_unreachable ();
5806 }
5807
5808 snprintf (buf, sizeof (buf), ops, tmp);
5809 output_asm_insn (buf, operands);
5810 return "";
5811 }
5812 [(set_attr "isa" "noavx,avx,avx512vl,avx512f_512")
5813 (set_attr "type" "sselog")
5814 (set_attr "c86_attr" "sselogic")
5815 (set (attr "prefix_data16")
5816 (if_then_else
5817 (and (eq_attr "alternative" "0")
5818 (eq_attr "mode" "TI"))
5819 (const_string "1")
5820 (const_string "*")))
5821 (set_attr "prefix" "orig,vex,evex,evex")
5822 (set (attr "mode")
5823 (cond [(eq_attr "alternative" "2")
5824 (const_string "TI")
5825 (eq_attr "alternative" "3")
5826 (const_string "QI")
5827 (match_test "TARGET_AVX")
5828 (const_string "TI")
5829 (ior (not (match_test "TARGET_SSE2"))
5830 (match_test "optimize_function_for_size_p (cfun)"))
5831 (const_string "V4SF")
5832 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
5833 (const_string "V4SF")
5834 ]
5835 (const_string "TI")))])
5836
5837 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5838 ;;
5839 ;; FMA floating point multiply/accumulate instructions. These include
5840 ;; scalar versions of the instructions as well as vector versions.
5841 ;;
5842 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5843
5844 ;; The standard names for scalar FMA are only available with SSE math enabled.
5845 ;; CPUID bit AVX512F enables evex encoded scalar and 512-bit fma. It doesn't
5846 ;; care about FMA bit, so we enable fma for TARGET_AVX512F even when TARGET_FMA
5847 ;; and TARGET_FMA4 are both false.
5848 ;; TODO: In theory AVX512F does not automatically imply FMA, and without FMA
5849 ;; one must force the EVEX encoding of the fma insns. Ideally we'd improve
5850 ;; GAS to allow proper prefix selection. However, for the moment all hardware
5851 ;; that supports AVX512F also supports FMA so we can ignore this for now.
5852 (define_mode_iterator FMAMODEM
5853 [(SF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
5854 (DF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
5855 (V4SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
5856 (V2DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
5857 (V8SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
5858 (V4DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
5859 (V16SF "TARGET_AVX512F && TARGET_EVEX512")
5860 (V8DF "TARGET_AVX512F && TARGET_EVEX512")
5861 (HF "TARGET_AVX512FP16")
5862 (V8HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
5863 (V16HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
5864 (V32HF "TARGET_AVX512FP16 && TARGET_EVEX512")
5865 (V8BF "TARGET_AVX10_2")
5866 (V16BF "TARGET_AVX10_2")
5867 (V32BF "TARGET_AVX10_2")])
5868
5869 (define_expand "fma<mode>4"
5870 [(set (match_operand:FMAMODEM 0 "register_operand")
5871 (fma:FMAMODEM
5872 (match_operand:FMAMODEM 1 "nonimmediate_operand")
5873 (match_operand:FMAMODEM 2 "nonimmediate_operand")
5874 (match_operand:FMAMODEM 3 "nonimmediate_operand")))])
5875
5876 (define_expand "fms<mode>4"
5877 [(set (match_operand:FMAMODEM 0 "register_operand")
5878 (fma:FMAMODEM
5879 (match_operand:FMAMODEM 1 "nonimmediate_operand")
5880 (match_operand:FMAMODEM 2 "nonimmediate_operand")
5881 (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))])
5882
5883 (define_expand "fnma<mode>4"
5884 [(set (match_operand:FMAMODEM 0 "register_operand")
5885 (fma:FMAMODEM
5886 (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
5887 (match_operand:FMAMODEM 2 "nonimmediate_operand")
5888 (match_operand:FMAMODEM 3 "nonimmediate_operand")))])
5889
5890 (define_expand "fnms<mode>4"
5891 [(set (match_operand:FMAMODEM 0 "register_operand")
5892 (fma:FMAMODEM
5893 (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
5894 (match_operand:FMAMODEM 2 "nonimmediate_operand")
5895 (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))])
5896
5897 ;; The builtins for intrinsics are not constrained by SSE math enabled.
5898 (define_mode_iterator FMAMODE_AVX512
5899 [(SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
5900 (DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
5901 (V4SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
5902 (V2DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
5903 (V8SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
5904 (V4DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
5905 (V16SF "TARGET_AVX512F && TARGET_EVEX512")
5906 (V8DF "TARGET_AVX512F && TARGET_EVEX512")])
5907
5908 (define_mode_iterator FMAMODE
5909 [SF DF V4SF V2DF V8SF V4DF])
5910
5911 (define_expand "fma4i_fmadd_<mode>"
5912 [(set (match_operand:FMAMODE_AVX512 0 "register_operand")
5913 (fma:FMAMODE_AVX512
5914 (match_operand:FMAMODE_AVX512 1 "nonimmediate_operand")
5915 (match_operand:FMAMODE_AVX512 2 "nonimmediate_operand")
5916 (match_operand:FMAMODE_AVX512 3 "nonimmediate_operand")))])
5917
5918 (define_expand "fma4i_fmsub_<mode>"
5919 [(set (match_operand:FMAMODE_AVX512 0 "register_operand")
5920 (fma:FMAMODE_AVX512
5921 (match_operand:FMAMODE_AVX512 1 "nonimmediate_operand")
5922 (match_operand:FMAMODE_AVX512 2 "nonimmediate_operand")
5923 (neg:FMAMODE_AVX512
5924 (match_operand:FMAMODE_AVX512 3 "nonimmediate_operand"))))])
5925
5926 (define_expand "fma4i_fnmadd_<mode>"
5927 [(set (match_operand:FMAMODE_AVX512 0 "register_operand")
5928 (fma:FMAMODE_AVX512
5929 (neg:FMAMODE_AVX512
5930 (match_operand:FMAMODE_AVX512 1 "nonimmediate_operand"))
5931 (match_operand:FMAMODE_AVX512 2 "nonimmediate_operand")
5932 (match_operand:FMAMODE_AVX512 3 "nonimmediate_operand")))])
5933
5934 (define_expand "fma4i_fnmsub_<mode>"
5935 [(set (match_operand:FMAMODE_AVX512 0 "register_operand")
5936 (fma:FMAMODE_AVX512
5937 (neg:FMAMODE_AVX512
5938 (match_operand:FMAMODE_AVX512 1 "nonimmediate_operand"))
5939 (match_operand:FMAMODE_AVX512 2 "nonimmediate_operand")
5940 (neg:FMAMODE_AVX512
5941 (match_operand:FMAMODE_AVX512 3 "nonimmediate_operand"))))])
5942
5943 (define_expand "<avx512>_fmadd_<mode>_maskz<round_expand_name>"
5944 [(match_operand:VFH_AVX512VL 0 "register_operand")
5945 (match_operand:VFH_AVX512VL 1 "<round_expand_nimm_predicate>")
5946 (match_operand:VFH_AVX512VL 2 "<round_expand_nimm_predicate>")
5947 (match_operand:VFH_AVX512VL 3 "<round_expand_nimm_predicate>")
5948 (match_operand:<avx512fmaskmode> 4 "register_operand")]
5949 "TARGET_AVX512F && <round_mode512bit_condition>"
5950 {
5951 emit_insn (gen_fma_fmadd_<mode>_maskz_1<round_expand_name> (
5952 operands[0], operands[1], operands[2], operands[3],
5953 CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
5954 DONE;
5955 })
5956
5957 (define_insn "*fma_fmadd_<mode>"
5958 [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
5959 (fma:FMAMODE
5960 (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x")
5961 (match_operand:FMAMODE 2 "nonimmediate_operand" "vm,v,vm,x,m")
5962 (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x")))]
5963 "TARGET_FMA || TARGET_FMA4"
5964 "@
5965 vfmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
5966 vfmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
5967 vfmadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
5968 vfmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
5969 vfmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
5970 [(set_attr "isa" "fma,fma,fma,fma4,fma4")
5971 (set_attr "type" "ssemuladd")
5972 (set_attr "mode" "<MODE>")])
5973
5974 ;; Suppose AVX-512F as baseline
5975 (define_mode_iterator VFH_SF_AVX512VL
5976 [(V32HF "TARGET_AVX512FP16 && TARGET_EVEX512")
5977 (V16HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
5978 (V8HF "TARGET_AVX512FP16 && TARGET_AVX512VL")
5979 (HF "TARGET_AVX512FP16")
5980 SF (V16SF "TARGET_EVEX512")
5981 (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
5982 DF (V8DF "TARGET_EVEX512")
5983 (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
5984
5985 (define_insn "<sd_mask_codefor>fma_fmadd_<mode><sd_maskz_name><round_name>"
5986 [(set (match_operand:VFH_SF_AVX512VL 0 "register_operand" "=v,v,v")
5987 (fma:VFH_SF_AVX512VL
5988 (match_operand:VFH_SF_AVX512VL 1 "<bcst_round_nimm_predicate>" "%0,0,v")
5989 (match_operand:VFH_SF_AVX512VL 2 "<bcst_round_nimm_predicate>" "<bcst_round_constraint>,v,<bcst_round_constraint>")
5990 (match_operand:VFH_SF_AVX512VL 3 "<bcst_round_nimm_predicate>" "v,<bcst_round_constraint>,0")))]
5991 "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
5992 "@
5993 vfmadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
5994 vfmadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
5995 vfmadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
5996 [(set_attr "type" "ssemuladd")
5997 (set_attr "prefix" "evex")
5998 (set_attr "mode" "<MODE>")])
5999
6000 (define_expand "cond_fma<mode>"
6001 [(set (match_operand:VFH_AVX512VL 0 "register_operand")
6002 (vec_merge:VFH_AVX512VL
6003 (fma:VFH_AVX512VL
6004 (match_operand:VFH_AVX512VL 2 "vector_operand")
6005 (match_operand:VFH_AVX512VL 3 "vector_operand")
6006 (match_operand:VFH_AVX512VL 4 "vector_operand"))
6007 (match_operand:VFH_AVX512VL 5 "nonimm_or_0_operand")
6008 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
6009 "TARGET_AVX512F"
6010 {
6011 rtx tmp = gen_reg_rtx (<MODE>mode);
6012 emit_insn (gen_fma<mode>4 (tmp,
6013 operands[2],
6014 operands[3],
6015 operands[4]));
6016 emit_move_insn (operands[0], gen_rtx_VEC_MERGE (<MODE>mode,
6017 tmp,
6018 operands[5],
6019 operands[1]));
6020 DONE;
6021 })
6022
6023 (define_insn "<avx512>_fmadd_<mode>_mask<round_name>"
6024 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v,v")
6025 (vec_merge:VFH_AVX512VL
6026 (fma:VFH_AVX512VL
6027 (match_operand:VFH_AVX512VL 1 "nonimmediate_operand" "0,0")
6028 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v")
6029 (match_operand:VFH_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>"))
6030 (match_dup 1)
6031 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
6032 "TARGET_AVX512F && <round_mode512bit_condition>"
6033 "@
6034 vfmadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
6035 vfmadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
6036 [(set_attr "type" "ssemuladd")
6037 (set_attr "prefix" "evex")
6038 (set_attr "mode" "<MODE>")])
6039
6040 (define_insn "<avx512>_fmadd_<mode>_mask3<round_name>"
6041 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v")
6042 (vec_merge:VFH_AVX512VL
6043 (fma:VFH_AVX512VL
6044 (match_operand:VFH_AVX512VL 1 "<round_nimm_predicate>" "%v")
6045 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>")
6046 (match_operand:VFH_AVX512VL 3 "nonimmediate_operand" "0"))
6047 (match_dup 3)
6048 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
6049 "TARGET_AVX512F"
6050 "vfmadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
6051 [(set_attr "type" "ssemuladd")
6052 (set_attr "prefix" "evex")
6053 (set_attr "mode" "<MODE>")])
6054
6055 (define_insn "*fma_fmsub_<mode>"
6056 [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
6057 (fma:FMAMODE
6058 (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x")
6059 (match_operand:FMAMODE 2 "nonimmediate_operand" "vm,v,vm,x,m")
6060 (neg:FMAMODE
6061 (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x"))))]
6062 "TARGET_FMA || TARGET_FMA4"
6063 "@
6064 vfmsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
6065 vfmsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
6066 vfmsub231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
6067 vfmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
6068 vfmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
6069 [(set_attr "isa" "fma,fma,fma,fma4,fma4")
6070 (set_attr "type" "ssemuladd")
6071 (set_attr "mode" "<MODE>")])
6072
6073 (define_expand "<avx512>_fmsub_<mode>_maskz<round_expand_name>"
6074 [(match_operand:VFH_AVX512VL 0 "register_operand")
6075 (match_operand:VFH_AVX512VL 1 "<round_expand_nimm_predicate>")
6076 (match_operand:VFH_AVX512VL 2 "<round_expand_nimm_predicate>")
6077 (match_operand:VFH_AVX512VL 3 "<round_expand_nimm_predicate>")
6078 (match_operand:<avx512fmaskmode> 4 "register_operand")]
6079 "TARGET_AVX512F && <round_mode512bit_condition>"
6080 {
6081 emit_insn (gen_fma_fmsub_<mode>_maskz_1<round_expand_name> (
6082 operands[0], operands[1], operands[2], operands[3],
6083 CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
6084 DONE;
6085 })
6086
6087 (define_insn "<sd_mask_codefor>fma_fmsub_<mode><sd_maskz_name><round_name>"
6088 [(set (match_operand:VFH_SF_AVX512VL 0 "register_operand" "=v,v,v")
6089 (fma:VFH_SF_AVX512VL
6090 (match_operand:VFH_SF_AVX512VL 1 "<bcst_round_nimm_predicate>" "%0,0,v")
6091 (match_operand:VFH_SF_AVX512VL 2 "<bcst_round_nimm_predicate>" "<bcst_round_constraint>,v,<bcst_round_constraint>")
6092 (neg:VFH_SF_AVX512VL
6093 (match_operand:VFH_SF_AVX512VL 3 "<bcst_round_nimm_predicate>" "v,<bcst_round_constraint>,0"))))]
6094 "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
6095 "@
6096 vfmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
6097 vfmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
6098 vfmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
6099 [(set_attr "type" "ssemuladd")
6100 (set_attr "prefix" "evex")
6101 (set_attr "mode" "<MODE>")])
6102
6103 (define_expand "cond_fms<mode>"
6104 [(set (match_operand:VFH_AVX512VL 0 "register_operand")
6105 (vec_merge:VFH_AVX512VL
6106 (fma:VFH_AVX512VL
6107 (match_operand:VFH_AVX512VL 2 "vector_operand")
6108 (match_operand:VFH_AVX512VL 3 "vector_operand")
6109 (neg:VFH_AVX512VL
6110 (match_operand:VFH_AVX512VL 4 "vector_operand")))
6111 (match_operand:VFH_AVX512VL 5 "nonimm_or_0_operand")
6112 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
6113 "TARGET_AVX512F"
6114 {
6115 rtx tmp = gen_reg_rtx (<MODE>mode);
6116 emit_insn (gen_fms<mode>4 (tmp,
6117 operands[2],
6118 operands[3],
6119 operands[4]));
6120 emit_move_insn (operands[0], gen_rtx_VEC_MERGE (<MODE>mode,
6121 tmp,
6122 operands[5],
6123 operands[1]));
6124 DONE;
6125 })
6126
6127 (define_insn "<avx512>_fmsub_<mode>_mask<round_name>"
6128 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v,v")
6129 (vec_merge:VFH_AVX512VL
6130 (fma:VFH_AVX512VL
6131 (match_operand:VFH_AVX512VL 1 "nonimmediate_operand" "0,0")
6132 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v")
6133 (neg:VFH_AVX512VL
6134 (match_operand:VFH_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>")))
6135 (match_dup 1)
6136 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
6137 "TARGET_AVX512F"
6138 "@
6139 vfmsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
6140 vfmsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
6141 [(set_attr "type" "ssemuladd")
6142 (set_attr "prefix" "evex")
6143 (set_attr "mode" "<MODE>")])
6144
6145 (define_insn "<avx512>_fmsub_<mode>_mask3<round_name>"
6146 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v")
6147 (vec_merge:VFH_AVX512VL
6148 (fma:VFH_AVX512VL
6149 (match_operand:VFH_AVX512VL 1 "<round_nimm_predicate>" "%v")
6150 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>")
6151 (neg:VFH_AVX512VL
6152 (match_operand:VFH_AVX512VL 3 "nonimmediate_operand" "0")))
6153 (match_dup 3)
6154 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
6155 "TARGET_AVX512F && <round_mode512bit_condition>"
6156 "vfmsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
6157 [(set_attr "type" "ssemuladd")
6158 (set_attr "prefix" "evex")
6159 (set_attr "mode" "<MODE>")])
6160
6161 (define_insn "*fma_fnmadd_<mode>"
6162 [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
6163 (fma:FMAMODE
6164 (neg:FMAMODE
6165 (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x"))
6166 (match_operand:FMAMODE 2 "nonimmediate_operand" "vm,v,vm,x,m")
6167 (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x")))]
6168 "TARGET_FMA || TARGET_FMA4"
6169 "@
6170 vfnmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
6171 vfnmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
6172 vfnmadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
6173 vfnmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
6174 vfnmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
6175 [(set_attr "isa" "fma,fma,fma,fma4,fma4")
6176 (set_attr "type" "ssemuladd")
6177 (set_attr "mode" "<MODE>")])
6178
6179 (define_expand "<avx512>_fnmadd_<mode>_maskz<round_expand_name>"
6180 [(match_operand:VFH_AVX512VL 0 "register_operand")
6181 (match_operand:VFH_AVX512VL 1 "<round_expand_nimm_predicate>")
6182 (match_operand:VFH_AVX512VL 2 "<round_expand_nimm_predicate>")
6183 (match_operand:VFH_AVX512VL 3 "<round_expand_nimm_predicate>")
6184 (match_operand:<avx512fmaskmode> 4 "register_operand")]
6185 "TARGET_AVX512F && <round_mode512bit_condition>"
6186 {
6187 emit_insn (gen_fma_fnmadd_<mode>_maskz_1<round_expand_name> (
6188 operands[0], operands[1], operands[2], operands[3],
6189 CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
6190 DONE;
6191 })
6192
6193 (define_insn "<sd_mask_codefor>fma_fnmadd_<mode><sd_maskz_name><round_name>"
6194 [(set (match_operand:VFH_SF_AVX512VL 0 "register_operand" "=v,v,v")
6195 (fma:VFH_SF_AVX512VL
6196 (neg:VFH_SF_AVX512VL
6197 (match_operand:VFH_SF_AVX512VL 1 "<bcst_round_nimm_predicate>" "%0,0,v"))
6198 (match_operand:VFH_SF_AVX512VL 2 "<bcst_round_nimm_predicate>" "<bcst_round_constraint>,v,<bcst_round_constraint>")
6199 (match_operand:VFH_SF_AVX512VL 3 "<bcst_round_nimm_predicate>" "v,<bcst_round_constraint>,0")))]
6200 "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
6201 "@
6202 vfnmadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
6203 vfnmadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
6204 vfnmadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
6205 [(set_attr "type" "ssemuladd")
6206 (set_attr "prefix" "evex")
6207 (set_attr "mode" "<MODE>")])
6208
6209 (define_expand "cond_fnma<mode>"
6210 [(set (match_operand:VFH_AVX512VL 0 "register_operand")
6211 (vec_merge:VFH_AVX512VL
6212 (fma:VFH_AVX512VL
6213 (neg:VFH_AVX512VL
6214 (match_operand:VFH_AVX512VL 2 "vector_operand"))
6215 (match_operand:VFH_AVX512VL 3 "vector_operand")
6216 (match_operand:VFH_AVX512VL 4 "vector_operand"))
6217 (match_operand:VFH_AVX512VL 5 "nonimm_or_0_operand")
6218 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
6219 "TARGET_AVX512F"
6220 {
6221 rtx tmp = gen_reg_rtx (<MODE>mode);
6222 emit_insn (gen_fnma<mode>4 (tmp,
6223 operands[2],
6224 operands[3],
6225 operands[4]));
6226 emit_move_insn (operands[0], gen_rtx_VEC_MERGE (<MODE>mode,
6227 tmp,
6228 operands[5],
6229 operands[1]));
6230 DONE;
6231 })
6232
6233 (define_insn "<avx512>_fnmadd_<mode>_mask<round_name>"
6234 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v,v")
6235 (vec_merge:VFH_AVX512VL
6236 (fma:VFH_AVX512VL
6237 (neg:VFH_AVX512VL
6238 (match_operand:VFH_AVX512VL 1 "nonimmediate_operand" "0,0"))
6239 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v")
6240 (match_operand:VFH_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>"))
6241 (match_dup 1)
6242 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
6243 "TARGET_AVX512F && <round_mode512bit_condition>"
6244 "@
6245 vfnmadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
6246 vfnmadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
6247 [(set_attr "type" "ssemuladd")
6248 (set_attr "prefix" "evex")
6249 (set_attr "mode" "<MODE>")])
6250
6251 (define_insn "<avx512>_fnmadd_<mode>_mask3<round_name>"
6252 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v")
6253 (vec_merge:VFH_AVX512VL
6254 (fma:VFH_AVX512VL
6255 (neg:VFH_AVX512VL
6256 (match_operand:VFH_AVX512VL 1 "<round_nimm_predicate>" "%v"))
6257 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>")
6258 (match_operand:VFH_AVX512VL 3 "nonimmediate_operand" "0"))
6259 (match_dup 3)
6260 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
6261 "TARGET_AVX512F && <round_mode512bit_condition>"
6262 "vfnmadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
6263 [(set_attr "type" "ssemuladd")
6264 (set_attr "prefix" "evex")
6265 (set_attr "mode" "<MODE>")])
6266
6267 (define_insn "*fma_fnmsub_<mode>"
6268 [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
6269 (fma:FMAMODE
6270 (neg:FMAMODE
6271 (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x"))
6272 (match_operand:FMAMODE 2 "nonimmediate_operand" "vm,v,vm,x,m")
6273 (neg:FMAMODE
6274 (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x"))))]
6275 "TARGET_FMA || TARGET_FMA4"
6276 "@
6277 vfnmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
6278 vfnmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
6279 vfnmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}
6280 vfnmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
6281 vfnmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
6282 [(set_attr "isa" "fma,fma,fma,fma4,fma4")
6283 (set_attr "type" "ssemuladd")
6284 (set_attr "mode" "<MODE>")])
6285
6286 (define_expand "<avx512>_fnmsub_<mode>_maskz<round_expand_name>"
6287 [(match_operand:VFH_AVX512VL 0 "register_operand")
6288 (match_operand:VFH_AVX512VL 1 "<round_expand_nimm_predicate>")
6289 (match_operand:VFH_AVX512VL 2 "<round_expand_nimm_predicate>")
6290 (match_operand:VFH_AVX512VL 3 "<round_expand_nimm_predicate>")
6291 (match_operand:<avx512fmaskmode> 4 "register_operand")]
6292 "TARGET_AVX512F && <round_mode512bit_condition>"
6293 {
6294 emit_insn (gen_fma_fnmsub_<mode>_maskz_1<round_expand_name> (
6295 operands[0], operands[1], operands[2], operands[3],
6296 CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
6297 DONE;
6298 })
6299
6300 (define_insn "<sd_mask_codefor>fma_fnmsub_<mode><sd_maskz_name><round_name>"
6301 [(set (match_operand:VFH_SF_AVX512VL 0 "register_operand" "=v,v,v")
6302 (fma:VFH_SF_AVX512VL
6303 (neg:VFH_SF_AVX512VL
6304 (match_operand:VFH_SF_AVX512VL 1 "<bcst_round_nimm_predicate>" "%0,0,v"))
6305 (match_operand:VFH_SF_AVX512VL 2 "<bcst_round_nimm_predicate>" "<bcst_round_constraint>,v,<bcst_round_constraint>")
6306 (neg:VFH_SF_AVX512VL
6307 (match_operand:VFH_SF_AVX512VL 3 "<bcst_round_nimm_predicate>" "v,<bcst_round_constraint>,0"))))]
6308 "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
6309 "@
6310 vfnmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
6311 vfnmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
6312 vfnmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
6313 [(set_attr "type" "ssemuladd")
6314 (set_attr "prefix" "evex")
6315 (set_attr "mode" "<MODE>")])
6316
6317 (define_expand "cond_fnms<mode>"
6318 [(set (match_operand:VFH_AVX512VL 0 "register_operand")
6319 (vec_merge:VFH_AVX512VL
6320 (fma:VFH_AVX512VL
6321 (neg:VFH_AVX512VL
6322 (match_operand:VFH_AVX512VL 2 "vector_operand"))
6323 (match_operand:VFH_AVX512VL 3 "vector_operand")
6324 (neg:VFH_AVX512VL
6325 (match_operand:VFH_AVX512VL 4 "vector_operand")))
6326 (match_operand:VFH_AVX512VL 5 "nonimm_or_0_operand")
6327 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
6328 "TARGET_AVX512F"
6329 {
6330 rtx tmp = gen_reg_rtx (<MODE>mode);
6331 emit_insn (gen_fnms<mode>4 (tmp,
6332 operands[2],
6333 operands[3],
6334 operands[4]));
6335 emit_move_insn (operands[0], gen_rtx_VEC_MERGE (<MODE>mode,
6336 tmp,
6337 operands[5],
6338 operands[1]));
6339 DONE;
6340 })
6341
6342 (define_insn "<avx512>_fnmsub_<mode>_mask<round_name>"
6343 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v,v")
6344 (vec_merge:VFH_AVX512VL
6345 (fma:VFH_AVX512VL
6346 (neg:VFH_AVX512VL
6347 (match_operand:VFH_AVX512VL 1 "nonimmediate_operand" "0,0"))
6348 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v")
6349 (neg:VFH_AVX512VL
6350 (match_operand:VFH_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>")))
6351 (match_dup 1)
6352 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
6353 "TARGET_AVX512F && <round_mode512bit_condition>"
6354 "@
6355 vfnmsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
6356 vfnmsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
6357 [(set_attr "type" "ssemuladd")
6358 (set_attr "prefix" "evex")
6359 (set_attr "mode" "<MODE>")])
6360
6361 (define_insn "<avx512>_fnmsub_<mode>_mask3<round_name>"
6362 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v")
6363 (vec_merge:VFH_AVX512VL
6364 (fma:VFH_AVX512VL
6365 (neg:VFH_AVX512VL
6366 (match_operand:VFH_AVX512VL 1 "<round_nimm_predicate>" "%v"))
6367 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>")
6368 (neg:VFH_AVX512VL
6369 (match_operand:VFH_AVX512VL 3 "nonimmediate_operand" "0")))
6370 (match_dup 3)
6371 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
6372 "TARGET_AVX512F"
6373 "vfnmsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
6374 [(set_attr "type" "ssemuladd")
6375 (set_attr "prefix" "evex")
6376 (set_attr "mode" "<MODE>")])
6377
6378 ;; FMA parallel floating point multiply addsub and subadd operations.
6379
6380 ;; It would be possible to represent these without the UNSPEC as
6381 ;;
6382 ;; (vec_merge
6383 ;; (fma op1 op2 op3)
6384 ;; (fma op1 op2 (neg op3))
6385 ;; (merge-const))
6386 ;;
6387 ;; But this doesn't seem useful in practice.
6388
6389 (define_expand "vec_fmaddsub<mode>4"
6390 [(set (match_operand:VFH 0 "register_operand")
6391 (unspec:VFH
6392 [(match_operand:VFH 1 "nonimmediate_operand")
6393 (match_operand:VFH 2 "nonimmediate_operand")
6394 (match_operand:VFH 3 "nonimmediate_operand")]
6395 UNSPEC_FMADDSUB))]
6396 "TARGET_FMA || TARGET_FMA4 || (<MODE_SIZE> == 64 || TARGET_AVX512VL)")
6397
6398 (define_expand "vec_fmsubadd<mode>4"
6399 [(set (match_operand:VFH 0 "register_operand")
6400 (unspec:VFH
6401 [(match_operand:VFH 1 "nonimmediate_operand")
6402 (match_operand:VFH 2 "nonimmediate_operand")
6403 (neg:VFH
6404 (match_operand:VFH 3 "nonimmediate_operand"))]
6405 UNSPEC_FMADDSUB))]
6406 "TARGET_FMA || TARGET_FMA4 || (<MODE_SIZE> == 64 || TARGET_AVX512VL)")
6407
6408 (define_expand "fmaddsub_<mode>"
6409 [(set (match_operand:VF 0 "register_operand")
6410 (unspec:VF
6411 [(match_operand:VF 1 "nonimmediate_operand")
6412 (match_operand:VF 2 "nonimmediate_operand")
6413 (match_operand:VF 3 "nonimmediate_operand")]
6414 UNSPEC_FMADDSUB))]
6415 "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
6416
6417 (define_expand "<avx512>_fmaddsub_<mode>_maskz<round_expand_name>"
6418 [(match_operand:VFH_AVX512VL 0 "register_operand")
6419 (match_operand:VFH_AVX512VL 1 "<round_expand_nimm_predicate>")
6420 (match_operand:VFH_AVX512VL 2 "<round_expand_nimm_predicate>")
6421 (match_operand:VFH_AVX512VL 3 "<round_expand_nimm_predicate>")
6422 (match_operand:<avx512fmaskmode> 4 "register_operand")]
6423 "TARGET_AVX512F"
6424 {
6425 emit_insn (gen_fma_fmaddsub_<mode>_maskz_1<round_expand_name> (
6426 operands[0], operands[1], operands[2], operands[3],
6427 CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
6428 DONE;
6429 })
6430
6431 (define_expand "<avx512>_fmsubadd_<mode>_maskz<round_expand_name>"
6432 [(match_operand:VFH_AVX512VL 0 "register_operand")
6433 (match_operand:VFH_AVX512VL 1 "<round_expand_nimm_predicate>")
6434 (match_operand:VFH_AVX512VL 2 "<round_expand_nimm_predicate>")
6435 (match_operand:VFH_AVX512VL 3 "<round_expand_nimm_predicate>")
6436 (match_operand:<avx512fmaskmode> 4 "register_operand")]
6437 "TARGET_AVX512F"
6438 {
6439 emit_insn (gen_fma_fmsubadd_<mode>_maskz_1<round_expand_name> (
6440 operands[0], operands[1], operands[2], operands[3],
6441 CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
6442 DONE;
6443 })
6444
6445 (define_insn "*fma_fmaddsub_<mode>"
6446 [(set (match_operand:VF_128_256 0 "register_operand" "=v,v,v,x,x")
6447 (unspec:VF_128_256
6448 [(match_operand:VF_128_256 1 "nonimmediate_operand" "%0,0,v,x,x")
6449 (match_operand:VF_128_256 2 "nonimmediate_operand" "vm,v,vm,x,m")
6450 (match_operand:VF_128_256 3 "nonimmediate_operand" "v,vm,0,xm,x")]
6451 UNSPEC_FMADDSUB))]
6452 "TARGET_FMA || TARGET_FMA4"
6453 "@
6454 vfmaddsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
6455 vfmaddsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
6456 vfmaddsub231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
6457 vfmaddsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
6458 vfmaddsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
6459 [(set_attr "isa" "fma,fma,fma,fma4,fma4")
6460 (set_attr "type" "ssemuladd")
6461 (set_attr "mode" "<MODE>")])
6462
6463 (define_insn "<sd_mask_codefor>fma_fmaddsub_<mode><sd_maskz_name><round_name>"
6464 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v,v,v")
6465 (unspec:VFH_AVX512VL
6466 [(match_operand:VFH_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v")
6467 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
6468 (match_operand:VFH_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0")]
6469 UNSPEC_FMADDSUB))]
6470 "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
6471 "@
6472 vfmaddsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
6473 vfmaddsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
6474 vfmaddsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
6475 [(set_attr "type" "ssemuladd")
6476 (set_attr "prefix" "evex")
6477 (set_attr "mode" "<MODE>")])
6478
6479 (define_insn "<avx512>_fmaddsub_<mode>_mask<round_name>"
6480 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v,v")
6481 (vec_merge:VFH_AVX512VL
6482 (unspec:VFH_AVX512VL
6483 [(match_operand:VFH_AVX512VL 1 "register_operand" "0,0")
6484 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v")
6485 (match_operand:VFH_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>")]
6486 UNSPEC_FMADDSUB)
6487 (match_dup 1)
6488 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
6489 "TARGET_AVX512F"
6490 "@
6491 vfmaddsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
6492 vfmaddsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
6493 [(set_attr "type" "ssemuladd")
6494 (set_attr "prefix" "evex")
6495 (set_attr "mode" "<MODE>")])
6496
6497 (define_insn "<avx512>_fmaddsub_<mode>_mask3<round_name>"
6498 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v")
6499 (vec_merge:VFH_AVX512VL
6500 (unspec:VFH_AVX512VL
6501 [(match_operand:VFH_AVX512VL 1 "nonimmediate_operand" "v")
6502 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>")
6503 (match_operand:VFH_AVX512VL 3 "nonimmediate_operand" "0")]
6504 UNSPEC_FMADDSUB)
6505 (match_dup 3)
6506 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
6507 "TARGET_AVX512F"
6508 "vfmaddsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
6509 [(set_attr "type" "ssemuladd")
6510 (set_attr "prefix" "evex")
6511 (set_attr "mode" "<MODE>")])
6512
6513 (define_insn "*fma_fmsubadd_<mode>"
6514 [(set (match_operand:VF_128_256 0 "register_operand" "=v,v,v,x,x")
6515 (unspec:VF_128_256
6516 [(match_operand:VF_128_256 1 "nonimmediate_operand" "%0,0,v,x,x")
6517 (match_operand:VF_128_256 2 "nonimmediate_operand" "vm,v,vm,x,m")
6518 (neg:VF_128_256
6519 (match_operand:VF_128_256 3 "nonimmediate_operand" "v,vm,0,xm,x"))]
6520 UNSPEC_FMADDSUB))]
6521 "TARGET_FMA || TARGET_FMA4"
6522 "@
6523 vfmsubadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
6524 vfmsubadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
6525 vfmsubadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
6526 vfmsubadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
6527 vfmsubadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
6528 [(set_attr "isa" "fma,fma,fma,fma4,fma4")
6529 (set_attr "type" "ssemuladd")
6530 (set_attr "mode" "<MODE>")])
6531
6532 (define_insn "<sd_mask_codefor>fma_fmsubadd_<mode><sd_maskz_name><round_name>"
6533 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v,v,v")
6534 (unspec:VFH_AVX512VL
6535 [(match_operand:VFH_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v")
6536 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
6537 (neg:VFH_AVX512VL
6538 (match_operand:VFH_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))]
6539 UNSPEC_FMADDSUB))]
6540 "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
6541 "@
6542 vfmsubadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
6543 vfmsubadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
6544 vfmsubadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
6545 [(set_attr "type" "ssemuladd")
6546 (set_attr "prefix" "evex")
6547 (set_attr "mode" "<MODE>")])
6548
6549 (define_insn "<avx512>_fmsubadd_<mode>_mask<round_name>"
6550 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v,v")
6551 (vec_merge:VFH_AVX512VL
6552 (unspec:VFH_AVX512VL
6553 [(match_operand:VFH_AVX512VL 1 "nonimmediate_operand" "0,0")
6554 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v")
6555 (neg:VFH_AVX512VL
6556 (match_operand:VFH_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>"))]
6557 UNSPEC_FMADDSUB)
6558 (match_dup 1)
6559 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
6560 "TARGET_AVX512F"
6561 "@
6562 vfmsubadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
6563 vfmsubadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
6564 [(set_attr "type" "ssemuladd")
6565 (set_attr "prefix" "evex")
6566 (set_attr "mode" "<MODE>")])
6567
6568 (define_insn "<avx512>_fmsubadd_<mode>_mask3<round_name>"
6569 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v")
6570 (vec_merge:VFH_AVX512VL
6571 (unspec:VFH_AVX512VL
6572 [(match_operand:VFH_AVX512VL 1 "nonimmediate_operand" "v")
6573 (match_operand:VFH_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>")
6574 (neg:VFH_AVX512VL
6575 (match_operand:VFH_AVX512VL 3 "nonimmediate_operand" "0"))]
6576 UNSPEC_FMADDSUB)
6577 (match_dup 3)
6578 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
6579 "TARGET_AVX512F"
6580 "vfmsubadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
6581 [(set_attr "type" "ssemuladd")
6582 (set_attr "prefix" "evex")
6583 (set_attr "mode" "<MODE>")])
6584
6585 ;; FMA3 floating point scalar intrinsics. These merge result with
6586 ;; high-order elements from the destination register.
6587
6588 (define_expand "fmai_vmfmadd_<mode><round_name>"
6589 [(set (match_operand:VFH_128 0 "register_operand")
6590 (vec_merge:VFH_128
6591 (fma:VFH_128
6592 (match_operand:VFH_128 1 "nonimmediate_operand")
6593 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>")
6594 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>"))
6595 (match_dup 1)
6596 (const_int 1)))]
6597 "TARGET_FMA")
6598
6599 (define_expand "fmai_vmfmsub_<mode><round_name>"
6600 [(set (match_operand:VFH_128 0 "register_operand")
6601 (vec_merge:VFH_128
6602 (fma:VFH_128
6603 (match_operand:VFH_128 1 "nonimmediate_operand")
6604 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>")
6605 (neg:VFH_128
6606 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>")))
6607 (match_dup 1)
6608 (const_int 1)))]
6609 "TARGET_FMA")
6610
6611 (define_expand "fmai_vmfnmadd_<mode><round_name>"
6612 [(set (match_operand:VFH_128 0 "register_operand")
6613 (vec_merge:VFH_128
6614 (fma:VFH_128
6615 (neg:VFH_128
6616 (match_operand:VFH_128 1 "nonimmediate_operand"))
6617 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>")
6618 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>"))
6619 (match_dup 1)
6620 (const_int 1)))]
6621 "TARGET_FMA")
6622
6623 (define_expand "fmai_vmfnmsub_<mode><round_name>"
6624 [(set (match_operand:VFH_128 0 "register_operand")
6625 (vec_merge:VFH_128
6626 (fma:VFH_128
6627 (neg:VFH_128
6628 (match_operand:VFH_128 1 "nonimmediate_operand"))
6629 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>")
6630 (neg:VFH_128
6631 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>")))
6632 (match_dup 1)
6633 (const_int 1)))]
6634 "TARGET_FMA")
6635
6636 (define_insn "*fmai_fmadd_<mode>"
6637 [(set (match_operand:VFH_128 0 "register_operand" "=v,v")
6638 (vec_merge:VFH_128
6639 (fma:VFH_128
6640 (match_operand:VFH_128 1 "nonimmediate_operand" "0,0")
6641 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>, v")
6642 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>" "v,<round_constraint>"))
6643 (match_dup 1)
6644 (const_int 1)))]
6645 "TARGET_FMA || TARGET_AVX512F"
6646 "@
6647 vfmadd132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
6648 vfmadd213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
6649 [(set_attr "type" "ssemuladd")
6650 (set_attr "prefix" "maybe_evex")
6651 (set_attr "mode" "<MODE>")])
6652
6653 (define_insn "*fmai_fmsub_<mode>"
6654 [(set (match_operand:VFH_128 0 "register_operand" "=v,v")
6655 (vec_merge:VFH_128
6656 (fma:VFH_128
6657 (match_operand:VFH_128 1 "nonimmediate_operand" "0,0")
6658 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>,v")
6659 (neg:VFH_128
6660 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>" "v,<round_constraint>")))
6661 (match_dup 1)
6662 (const_int 1)))]
6663 "TARGET_FMA || TARGET_AVX512F"
6664 "@
6665 vfmsub132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
6666 vfmsub213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
6667 [(set_attr "type" "ssemuladd")
6668 (set_attr "prefix" "maybe_evex")
6669 (set_attr "mode" "<MODE>")])
6670
6671 (define_insn "*fmai_fnmadd_<mode><round_name>"
6672 [(set (match_operand:VFH_128 0 "register_operand" "=v,v")
6673 (vec_merge:VFH_128
6674 (fma:VFH_128
6675 (neg:VFH_128
6676 (match_operand:VFH_128 1 "nonimmediate_operand" "0,0"))
6677 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>,v")
6678 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>" "v,<round_constraint>"))
6679 (match_dup 1)
6680 (const_int 1)))]
6681 "TARGET_FMA || TARGET_AVX512F"
6682 "@
6683 vfnmadd132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
6684 vfnmadd213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
6685 [(set_attr "type" "ssemuladd")
6686 (set_attr "prefix" "maybe_evex")
6687 (set_attr "mode" "<MODE>")])
6688
6689 (define_insn "*fmai_fnmsub_<mode><round_name>"
6690 [(set (match_operand:VFH_128 0 "register_operand" "=v,v")
6691 (vec_merge:VFH_128
6692 (fma:VFH_128
6693 (neg:VFH_128
6694 (match_operand:VFH_128 1 "nonimmediate_operand" "0,0"))
6695 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>,v")
6696 (neg:VFH_128
6697 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>" "v,<round_constraint>")))
6698 (match_dup 1)
6699 (const_int 1)))]
6700 "TARGET_FMA || TARGET_AVX512F"
6701 "@
6702 vfnmsub132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
6703 vfnmsub213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
6704 [(set_attr "type" "ssemuladd")
6705 (set_attr "prefix" "maybe_evex")
6706 (set_attr "mode" "<MODE>")])
6707
6708 (define_insn "avx512f_vmfmadd_<mode>_mask<round_name>"
6709 [(set (match_operand:VFH_128 0 "register_operand" "=v,v")
6710 (vec_merge:VFH_128
6711 (vec_merge:VFH_128
6712 (fma:VFH_128
6713 (match_operand:VFH_128 1 "nonimmediate_operand" "0,0")
6714 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>,v")
6715 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>" "v,<round_constraint>"))
6716 (match_dup 1)
6717 (match_operand:QI 4 "register_operand" "Yk,Yk"))
6718 (match_dup 1)
6719 (const_int 1)))]
6720 "TARGET_AVX512F"
6721 "@
6722 vfmadd132<ssescalarmodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %<iptr>3, %<iptr>2<round_op5>}
6723 vfmadd213<ssescalarmodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %<iptr>2, %<iptr>3<round_op5>}"
6724 [(set_attr "type" "ssemuladd")
6725 (set_attr "prefix" "evex")
6726 (set_attr "mode" "<MODE>")])
6727
6728 (define_insn "avx512f_vmfmadd_<mode>_mask3<round_name>"
6729 [(set (match_operand:VFH_128 0 "register_operand" "=v")
6730 (vec_merge:VFH_128
6731 (vec_merge:VFH_128
6732 (fma:VFH_128
6733 (match_operand:VFH_128 1 "<round_nimm_scalar_predicate>" "%v")
6734 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>")
6735 (match_operand:VFH_128 3 "nonimmediate_operand" "0"))
6736 (match_dup 3)
6737 (match_operand:QI 4 "register_operand" "Yk"))
6738 (match_dup 3)
6739 (const_int 1)))]
6740 "TARGET_AVX512F"
6741 "vfmadd231<ssescalarmodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %<iptr>1, %<iptr>2<round_op5>}"
6742 [(set_attr "type" "ssemuladd")
6743 (set_attr "prefix" "evex")
6744 (set_attr "mode" "<MODE>")])
6745
6746 (define_expand "avx512f_vmfmadd_<mode>_maskz<round_expand_name>"
6747 [(match_operand:VFH_128 0 "register_operand")
6748 (match_operand:VFH_128 1 "<round_expand_nimm_predicate>")
6749 (match_operand:VFH_128 2 "<round_expand_nimm_predicate>")
6750 (match_operand:VFH_128 3 "<round_expand_nimm_predicate>")
6751 (match_operand:QI 4 "register_operand")]
6752 "TARGET_AVX512F"
6753 {
6754 emit_insn (gen_avx512f_vmfmadd_<mode>_maskz_1<round_expand_name> (
6755 operands[0], operands[1], operands[2], operands[3],
6756 CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
6757 DONE;
6758 })
6759
6760 (define_insn "avx512f_vmfmadd_<mode>_maskz_1<round_name>"
6761 [(set (match_operand:VFH_128 0 "register_operand" "=v,v")
6762 (vec_merge:VFH_128
6763 (vec_merge:VFH_128
6764 (fma:VFH_128
6765 (match_operand:VFH_128 1 "nonimmediate_operand" "0,0")
6766 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>,v")
6767 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>" "v,<round_constraint>"))
6768 (match_operand:VFH_128 4 "const0_operand")
6769 (match_operand:QI 5 "register_operand" "Yk,Yk"))
6770 (match_dup 1)
6771 (const_int 1)))]
6772 "TARGET_AVX512F"
6773 "@
6774 vfmadd132<ssescalarmodesuffix>\t{<round_op6>%2, %3, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %<iptr>3, %<iptr>2<round_op6>}
6775 vfmadd213<ssescalarmodesuffix>\t{<round_op6>%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %<iptr>2, %<iptr>3<round_op6>}"
6776 [(set_attr "type" "ssemuladd")
6777 (set_attr "prefix" "evex")
6778 (set_attr "mode" "<MODE>")])
6779
6780 (define_insn "*avx512f_vmfmsub_<mode>_mask<round_name>"
6781 [(set (match_operand:VFH_128 0 "register_operand" "=v,v")
6782 (vec_merge:VFH_128
6783 (vec_merge:VFH_128
6784 (fma:VFH_128
6785 (match_operand:VFH_128 1 "nonimmediate_operand" "0,0")
6786 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>,v")
6787 (neg:VFH_128
6788 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>" "v,<round_constraint>")))
6789 (match_dup 1)
6790 (match_operand:QI 4 "register_operand" "Yk,Yk"))
6791 (match_dup 1)
6792 (const_int 1)))]
6793 "TARGET_AVX512F"
6794 "@
6795 vfmsub132<ssescalarmodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %<iptr>3, %<iptr>2<round_op5>}
6796 vfmsub213<ssescalarmodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %<iptr>2, %<iptr>3<round_op5>}"
6797 [(set_attr "type" "ssemuladd")
6798 (set_attr "prefix" "evex")
6799 (set_attr "mode" "<MODE>")])
6800
6801 (define_insn "avx512f_vmfmsub_<mode>_mask3<round_name>"
6802 [(set (match_operand:VFH_128 0 "register_operand" "=v")
6803 (vec_merge:VFH_128
6804 (vec_merge:VFH_128
6805 (fma:VFH_128
6806 (match_operand:VFH_128 1 "<round_nimm_scalar_predicate>" "%v")
6807 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>")
6808 (neg:VFH_128
6809 (match_operand:VFH_128 3 "nonimmediate_operand" "0")))
6810 (match_dup 3)
6811 (match_operand:QI 4 "register_operand" "Yk"))
6812 (match_dup 3)
6813 (const_int 1)))]
6814 "TARGET_AVX512F"
6815 "vfmsub231<ssescalarmodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %<iptr>1, %<iptr>2<round_op5>}"
6816 [(set_attr "type" "ssemuladd")
6817 (set_attr "prefix" "evex")
6818 (set_attr "mode" "<MODE>")])
6819
6820 (define_insn "*avx512f_vmfmsub_<mode>_maskz_1<round_name>"
6821 [(set (match_operand:VFH_128 0 "register_operand" "=v,v")
6822 (vec_merge:VFH_128
6823 (vec_merge:VFH_128
6824 (fma:VFH_128
6825 (match_operand:VFH_128 1 "nonimmediate_operand" "0,0")
6826 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>,v")
6827 (neg:VFH_128
6828 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>" "v,<round_constraint>")))
6829 (match_operand:VFH_128 4 "const0_operand")
6830 (match_operand:QI 5 "register_operand" "Yk,Yk"))
6831 (match_dup 1)
6832 (const_int 1)))]
6833 "TARGET_AVX512F"
6834 "@
6835 vfmsub132<ssescalarmodesuffix>\t{<round_op6>%2, %3, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %<iptr>3, %<iptr>2<round_op6>}
6836 vfmsub213<ssescalarmodesuffix>\t{<round_op6>%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %<iptr>2, %<iptr>3<round_op6>}"
6837 [(set_attr "type" "ssemuladd")
6838 (set_attr "prefix" "evex")
6839 (set_attr "mode" "<MODE>")])
6840
6841 (define_insn "avx512f_vmfnmadd_<mode>_mask<round_name>"
6842 [(set (match_operand:VFH_128 0 "register_operand" "=v,v")
6843 (vec_merge:VFH_128
6844 (vec_merge:VFH_128
6845 (fma:VFH_128
6846 (neg:VFH_128
6847 (match_operand:VFH_128 1 "nonimmediate_operand" "0,0"))
6848 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>,v")
6849 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>" "v,<round_constraint>"))
6850 (match_dup 1)
6851 (match_operand:QI 4 "register_operand" "Yk,Yk"))
6852 (match_dup 1)
6853 (const_int 1)))]
6854 "TARGET_AVX512F"
6855 "@
6856 vfnmadd132<ssescalarmodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %<iptr>3, %<iptr>2<round_op5>}
6857 vfnmadd213<ssescalarmodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %<iptr>2, %<iptr>3<round_op5>}"
6858 [(set_attr "type" "ssemuladd")
6859 (set_attr "prefix" "evex")
6860 (set_attr "mode" "<MODE>")])
6861
6862 (define_insn "avx512f_vmfnmadd_<mode>_mask3<round_name>"
6863 [(set (match_operand:VFH_128 0 "register_operand" "=v")
6864 (vec_merge:VFH_128
6865 (vec_merge:VFH_128
6866 (fma:VFH_128
6867 (neg:VFH_128
6868 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>"))
6869 (match_operand:VFH_128 1 "<round_nimm_scalar_predicate>" "%v")
6870 (match_operand:VFH_128 3 "nonimmediate_operand" "0"))
6871 (match_dup 3)
6872 (match_operand:QI 4 "register_operand" "Yk"))
6873 (match_dup 3)
6874 (const_int 1)))]
6875 "TARGET_AVX512F"
6876 "vfnmadd231<ssescalarmodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %<iptr>1, %<iptr>2<round_op5>}"
6877 [(set_attr "type" "ssemuladd")
6878 (set_attr "prefix" "evex")
6879 (set_attr "mode" "<MODE>")])
6880
6881 (define_expand "avx512f_vmfnmadd_<mode>_maskz<round_expand_name>"
6882 [(match_operand:VFH_128 0 "register_operand")
6883 (match_operand:VFH_128 1 "<round_expand_nimm_predicate>")
6884 (match_operand:VFH_128 2 "<round_expand_nimm_predicate>")
6885 (match_operand:VFH_128 3 "<round_expand_nimm_predicate>")
6886 (match_operand:QI 4 "register_operand")]
6887 "TARGET_AVX512F"
6888 {
6889 emit_insn (gen_avx512f_vmfnmadd_<mode>_maskz_1<round_expand_name> (
6890 operands[0], operands[1], operands[2], operands[3],
6891 CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
6892 DONE;
6893 })
6894
6895 (define_insn "avx512f_vmfnmadd_<mode>_maskz_1<round_name>"
6896 [(set (match_operand:VFH_128 0 "register_operand" "=v,v")
6897 (vec_merge:VFH_128
6898 (vec_merge:VFH_128
6899 (fma:VFH_128
6900 (neg:VFH_128
6901 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>,v"))
6902 (match_operand:VFH_128 1 "nonimmediate_operand" "0,0")
6903 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>" "v,<round_constraint>"))
6904 (match_operand:VFH_128 4 "const0_operand")
6905 (match_operand:QI 5 "register_operand" "Yk,Yk"))
6906 (match_dup 1)
6907 (const_int 1)))]
6908 "TARGET_AVX512F"
6909 "@
6910 vfnmadd132<ssescalarmodesuffix>\t{<round_op6>%2, %3, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %<iptr>3, %<iptr>2<round_op6>}
6911 vfnmadd213<ssescalarmodesuffix>\t{<round_op6>%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %<iptr>2, %<iptr>3<round_op6>}"
6912 [(set_attr "type" "ssemuladd")
6913 (set_attr "prefix" "evex")
6914 (set_attr "mode" "<MODE>")])
6915
6916 (define_insn "*avx512f_vmfnmsub_<mode>_mask<round_name>"
6917 [(set (match_operand:VFH_128 0 "register_operand" "=v,v")
6918 (vec_merge:VFH_128
6919 (vec_merge:VFH_128
6920 (fma:VFH_128
6921 (neg:VFH_128
6922 (match_operand:VFH_128 1 "nonimmediate_operand" "0,0"))
6923 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>,v")
6924 (neg:VFH_128
6925 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>" "v,<round_constraint>")))
6926 (match_dup 1)
6927 (match_operand:QI 4 "register_operand" "Yk,Yk"))
6928 (match_dup 1)
6929 (const_int 1)))]
6930 "TARGET_AVX512F"
6931 "@
6932 vfnmsub132<ssescalarmodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %<iptr>3, %<iptr>2<round_op5>}
6933 vfnmsub213<ssescalarmodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %<iptr>2, %<iptr>3<round_op5>}"
6934 [(set_attr "type" "ssemuladd")
6935 (set_attr "prefix" "evex")
6936 (set_attr "mode" "<MODE>")])
6937
6938 (define_insn "*avx512f_vmfnmsub_<mode>_mask3<round_name>"
6939 [(set (match_operand:VFH_128 0 "register_operand" "=v")
6940 (vec_merge:VFH_128
6941 (vec_merge:VFH_128
6942 (fma:VFH_128
6943 (neg:VFH_128
6944 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>"))
6945 (match_operand:VFH_128 1 "<round_nimm_scalar_predicate>" "%v")
6946 (neg:VFH_128
6947 (match_operand:VFH_128 3 "nonimmediate_operand" "0")))
6948 (match_dup 3)
6949 (match_operand:QI 4 "register_operand" "Yk"))
6950 (match_dup 3)
6951 (const_int 1)))]
6952 "TARGET_AVX512F"
6953 "vfnmsub231<ssescalarmodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %<iptr>1, %<iptr>2<round_op5>}"
6954 [(set_attr "type" "ssemuladd")
6955 (set_attr "prefix" "evex")
6956 (set_attr "mode" "<MODE>")])
6957
6958 (define_insn "*avx512f_vmfnmsub_<mode>_maskz_1<round_name>"
6959 [(set (match_operand:VFH_128 0 "register_operand" "=v,v")
6960 (vec_merge:VFH_128
6961 (vec_merge:VFH_128
6962 (fma:VFH_128
6963 (neg:VFH_128
6964 (match_operand:VFH_128 2 "<round_nimm_scalar_predicate>" "<round_constraint>,v"))
6965 (match_operand:VFH_128 1 "nonimmediate_operand" "0,0")
6966 (neg:VFH_128
6967 (match_operand:VFH_128 3 "<round_nimm_scalar_predicate>" "v,<round_constraint>")))
6968 (match_operand:VFH_128 4 "const0_operand")
6969 (match_operand:QI 5 "register_operand" "Yk,Yk"))
6970 (match_dup 1)
6971 (const_int 1)))]
6972 "TARGET_AVX512F"
6973 "@
6974 vfnmsub132<ssescalarmodesuffix>\t{<round_op6>%2, %3, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %<iptr>3, %<iptr>2<round_op6>}
6975 vfnmsub213<ssescalarmodesuffix>\t{<round_op6>%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %<iptr>2, %<iptr>3<round_op6>}"
6976 [(set_attr "type" "ssemuladd")
6977 (set_attr "prefix" "evex")
6978 (set_attr "mode" "<MODE>")])
6979
6980 ;; FMA4 floating point scalar intrinsics. These write the
6981 ;; entire destination register, with the high-order elements zeroed.
6982
6983 (define_expand "fma4i_vmfmadd_<mode>"
6984 [(set (match_operand:VF_128 0 "register_operand")
6985 (vec_merge:VF_128
6986 (fma:VF_128
6987 (match_operand:VF_128 1 "nonimmediate_operand")
6988 (match_operand:VF_128 2 "nonimmediate_operand")
6989 (match_operand:VF_128 3 "nonimmediate_operand"))
6990 (match_dup 4)
6991 (const_int 1)))]
6992 "TARGET_FMA4"
6993 "operands[4] = CONST0_RTX (<MODE>mode);")
6994
6995 (define_insn "*fma4i_vmfmadd_<mode>"
6996 [(set (match_operand:VF_128 0 "register_operand" "=x,x")
6997 (vec_merge:VF_128
6998 (fma:VF_128
6999 (match_operand:VF_128 1 "nonimmediate_operand" "%x,x")
7000 (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
7001 (match_operand:VF_128 3 "nonimmediate_operand" "xm,x"))
7002 (match_operand:VF_128 4 "const0_operand")
7003 (const_int 1)))]
7004 "TARGET_FMA4"
7005 "vfmadd<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
7006 [(set_attr "type" "ssemuladd")
7007 (set_attr "prefix" "vex")
7008 (set_attr "mode" "<MODE>")])
7009
7010 (define_insn "*fma4i_vmfmsub_<mode>"
7011 [(set (match_operand:VF_128 0 "register_operand" "=x,x")
7012 (vec_merge:VF_128
7013 (fma:VF_128
7014 (match_operand:VF_128 1 "nonimmediate_operand" "%x,x")
7015 (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
7016 (neg:VF_128
7017 (match_operand:VF_128 3 "nonimmediate_operand" "xm,x")))
7018 (match_operand:VF_128 4 "const0_operand")
7019 (const_int 1)))]
7020 "TARGET_FMA4"
7021 "vfmsub<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
7022 [(set_attr "type" "ssemuladd")
7023 (set_attr "prefix" "vex")
7024 (set_attr "mode" "<MODE>")])
7025
7026 (define_insn "*fma4i_vmfnmadd_<mode>"
7027 [(set (match_operand:VF_128 0 "register_operand" "=x,x")
7028 (vec_merge:VF_128
7029 (fma:VF_128
7030 (neg:VF_128
7031 (match_operand:VF_128 1 "nonimmediate_operand" "%x,x"))
7032 (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
7033 (match_operand:VF_128 3 "nonimmediate_operand" "xm,x"))
7034 (match_operand:VF_128 4 "const0_operand")
7035 (const_int 1)))]
7036 "TARGET_FMA4"
7037 "vfnmadd<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
7038 [(set_attr "type" "ssemuladd")
7039 (set_attr "prefix" "vex")
7040 (set_attr "mode" "<MODE>")])
7041
7042 (define_insn "*fma4i_vmfnmsub_<mode>"
7043 [(set (match_operand:VF_128 0 "register_operand" "=x,x")
7044 (vec_merge:VF_128
7045 (fma:VF_128
7046 (neg:VF_128
7047 (match_operand:VF_128 1 "nonimmediate_operand" "%x,x"))
7048 (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
7049 (neg:VF_128
7050 (match_operand:VF_128 3 "nonimmediate_operand" "xm,x")))
7051 (match_operand:VF_128 4 "const0_operand")
7052 (const_int 1)))]
7053 "TARGET_FMA4"
7054 "vfnmsub<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
7055 [(set_attr "type" "ssemuladd")
7056 (set_attr "prefix" "vex")
7057 (set_attr "mode" "<MODE>")])
7058
7059 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7060 ;;
7061 ;; Complex type operations
7062 ;;
7063 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7064
7065 (define_int_iterator UNSPEC_COMPLEX_F_C_MA
7066 [UNSPEC_COMPLEX_FMA UNSPEC_COMPLEX_FCMA])
7067
7068 (define_int_iterator UNSPEC_COMPLEX_F_C_MA_PAIR
7069 [UNSPEC_COMPLEX_FMA_PAIR UNSPEC_COMPLEX_FCMA_PAIR])
7070
7071 (define_int_iterator UNSPEC_COMPLEX_F_C_MUL
7072 [UNSPEC_COMPLEX_FMUL UNSPEC_COMPLEX_FCMUL])
7073
7074 (define_int_attr complexopname
7075 [(UNSPEC_COMPLEX_FMA "fmaddc")
7076 (UNSPEC_COMPLEX_FCMA "fcmaddc")
7077 (UNSPEC_COMPLEX_FMUL "fmulc")
7078 (UNSPEC_COMPLEX_FCMUL "fcmulc")])
7079
7080 (define_int_attr complexpairopname
7081 [(UNSPEC_COMPLEX_FMA_PAIR "fmaddc")
7082 (UNSPEC_COMPLEX_FCMA_PAIR "fcmaddc")])
7083
7084 (define_int_attr int_comm
7085 [(UNSPEC_COMPLEX_FMA "")
7086 (UNSPEC_COMPLEX_FMA_PAIR "")
7087 (UNSPEC_COMPLEX_FCMA "")
7088 (UNSPEC_COMPLEX_FCMA_PAIR "")
7089 (UNSPEC_COMPLEX_FMUL "%")
7090 (UNSPEC_COMPLEX_FCMUL "")])
7091
7092 (define_int_attr conj_op
7093 [(UNSPEC_COMPLEX_FMA "")
7094 (UNSPEC_COMPLEX_FCMA "_conj")
7095 (UNSPEC_COMPLEX_FMUL "")
7096 (UNSPEC_COMPLEX_FCMUL "_conj")])
7097
7098 (define_mode_attr complexmove
7099 [(V32HF "avx512f_loadv16sf")
7100 (V16HF "avx512vl_loadv8sf")
7101 (V8HF "avx512vl_loadv4sf")])
7102
7103 (define_expand "<avx512>_fmaddc_<mode>_mask1<round_expand_name>"
7104 [(match_operand:VHF_AVX512VL 0 "register_operand")
7105 (match_operand:VHF_AVX512VL 1 "<round_expand_nimm_predicate>")
7106 (match_operand:VHF_AVX512VL 2 "<round_expand_nimm_predicate>")
7107 (match_operand:VHF_AVX512VL 3 "<round_expand_nimm_predicate>")
7108 (match_operand:<avx512fmaskcmode> 4 "register_operand")]
7109 "TARGET_AVX512FP16 && <round_mode512bit_condition>"
7110 {
7111 rtx op0, op1, dest;
7112 if (<round_embedded_complex>)
7113 emit_insn (gen_<avx512>_fmaddc_<mode>_mask<round_expand_name> (
7114 operands[0], operands[1], operands[2], operands[3],
7115 operands[4]<round_expand_operand>));
7116 else
7117 emit_insn (gen_<avx512>_fmaddc_<mode>_mask (operands[0],
7118 operands[1], operands[2], operands[3], operands[4]));
7119
7120 op0 = lowpart_subreg (<ssePSmode>mode,
7121 force_reg (<MODE>mode, operands[0]),
7122 <MODE>mode);
7123 dest = gen_reg_rtx (<ssePSmode>mode);
7124 if (!MEM_P (operands[1]))
7125 operands[1] = force_reg (<MODE>mode, operands[1]);
7126 op1 = lowpart_subreg (<ssePSmode>mode, operands[1], <MODE>mode);
7127 emit_insn (gen_<complexmove>_mask (dest, op0, op1, operands[4]));
7128 emit_move_insn (operands[0],
7129 lowpart_subreg (<MODE>mode, dest, <ssePSmode>mode));
7130 DONE;
7131 })
7132
7133 (define_expand "<avx512>_fmaddc_<mode>_maskz<round_expand_name>"
7134 [(match_operand:VHF_AVX512VL 0 "register_operand")
7135 (match_operand:VHF_AVX512VL 1 "<round_expand_nimm_predicate>")
7136 (match_operand:VHF_AVX512VL 2 "<round_expand_nimm_predicate>")
7137 (match_operand:VHF_AVX512VL 3 "<round_expand_nimm_predicate>")
7138 (match_operand:<avx512fmaskcmode> 4 "register_operand")]
7139 "TARGET_AVX512FP16 && <round_mode512bit_condition>"
7140 {
7141 emit_insn (gen_fma_fmaddc_<mode>_maskz_1<round_expand_name> (
7142 operands[0], operands[1], operands[2], operands[3],
7143 CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
7144 DONE;
7145 })
7146
7147 (define_expand "<avx512>_fcmaddc_<mode>_mask1<round_expand_name>"
7148 [(match_operand:VHF_AVX512VL 0 "register_operand")
7149 (match_operand:VHF_AVX512VL 1 "<round_expand_nimm_predicate>")
7150 (match_operand:VHF_AVX512VL 2 "<round_expand_nimm_predicate>")
7151 (match_operand:VHF_AVX512VL 3 "<round_expand_nimm_predicate>")
7152 (match_operand:<avx512fmaskcmode> 4 "register_operand")]
7153 "TARGET_AVX512FP16 && <round_mode512bit_condition>"
7154 {
7155 rtx op0, op1, dest;
7156 if (<round_embedded_complex>)
7157 emit_insn (gen_<avx512>_fcmaddc_<mode>_mask<round_expand_name> (
7158 operands[0], operands[1], operands[2], operands[3],
7159 operands[4]<round_expand_operand>));
7160 else
7161 {
7162 emit_insn (gen_<avx512>_fcmaddc_<mode>_mask (operands[0],
7163 operands[1], operands[2], operands[3], operands[4]));
7164 }
7165
7166 op0 = lowpart_subreg (<ssePSmode>mode,
7167 force_reg (<MODE>mode, operands[0]),
7168 <MODE>mode);
7169 dest = gen_reg_rtx (<ssePSmode>mode);
7170 if (!MEM_P (operands[1]))
7171 operands[1] = force_reg (<MODE>mode, operands[1]);
7172 op1 = lowpart_subreg (<ssePSmode>mode, operands[1], <MODE>mode);
7173 emit_insn (gen_<complexmove>_mask (dest, op0, op1, operands[4]));
7174 emit_move_insn (operands[0],
7175 lowpart_subreg (<MODE>mode, dest, <ssePSmode>mode));
7176 DONE;
7177 })
7178
7179 (define_expand "<avx512>_fcmaddc_<mode>_maskz<round_expand_name>"
7180 [(match_operand:VHF_AVX512VL 0 "register_operand")
7181 (match_operand:VHF_AVX512VL 1 "<round_expand_nimm_predicate>")
7182 (match_operand:VHF_AVX512VL 2 "<round_expand_nimm_predicate>")
7183 (match_operand:VHF_AVX512VL 3 "<round_expand_nimm_predicate>")
7184 (match_operand:<avx512fmaskcmode> 4 "register_operand")]
7185 "TARGET_AVX512FP16 && <round_mode512bit_condition>"
7186 {
7187 emit_insn (gen_fma_fcmaddc_<mode>_maskz_1<round_expand_name> (
7188 operands[0], operands[1], operands[2], operands[3],
7189 CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
7190 DONE;
7191 })
7192
7193 (define_expand "cmla<conj_op><mode>4"
7194 [(set (match_operand:VHF_AVX512VL 0 "register_operand")
7195 (unspec:VHF_AVX512VL
7196 [(match_operand:VHF_AVX512VL 1 "vector_operand")
7197 (match_operand:VHF_AVX512VL 2 "vector_operand")
7198 (match_operand:VHF_AVX512VL 3 "vector_operand")]
7199 UNSPEC_COMPLEX_F_C_MA))]
7200 "TARGET_AVX512FP16")
7201
7202 (define_insn "fma_<complexopname>_<mode><sdc_maskz_name><round_name>"
7203 [(set (match_operand:VHF_AVX512VL 0 "register_operand" "=&v")
7204 (unspec:VHF_AVX512VL
7205 [(match_operand:VHF_AVX512VL 1 "<round_nimm_predicate>" "<int_comm>v")
7206 (match_operand:VHF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>")
7207 (match_operand:VHF_AVX512VL 3 "<round_nimm_predicate>" "0")]
7208 UNSPEC_COMPLEX_F_C_MA))]
7209 "TARGET_AVX512FP16 && <sdc_mask_mode512bit_condition> && <round_mode512bit_condition>"
7210 "v<complexopname><ssemodesuffix>\t{<round_sdc_mask_op4>%2, %1, %0<sdc_mask_op4>|%0<sdc_mask_op4>, %1, %2<round_sdc_mask_op4>}"
7211 [(set_attr "type" "ssemuladd")
7212 (set_attr "prefix" "evex")
7213 (set_attr "mode" "<MODE>")])
7214
7215 (define_insn_and_split "fma_<mode>_fadd_fmul"
7216 [(set (match_operand:VHF_AVX512VL 0 "register_operand")
7217 (plus:VHF_AVX512VL
7218 (unspec:VHF_AVX512VL
7219 [(match_operand:VHF_AVX512VL 1 "vector_operand")
7220 (match_operand:VHF_AVX512VL 2 "vector_operand")]
7221 UNSPEC_COMPLEX_FMUL)
7222 (match_operand:VHF_AVX512VL 3 "vector_operand")))]
7223 "TARGET_AVX512FP16 && flag_unsafe_math_optimizations
7224 && ix86_pre_reload_split ()"
7225 "#"
7226 "&& 1"
7227 [(set (match_dup 0)
7228 (unspec:VHF_AVX512VL
7229 [(match_dup 1) (match_dup 2) (match_dup 3)]
7230 UNSPEC_COMPLEX_FMA))])
7231
7232 (define_insn_and_split "fma_<mode>_fadd_fcmul"
7233 [(set (match_operand:VHF_AVX512VL 0 "register_operand")
7234 (plus:VHF_AVX512VL
7235 (unspec:VHF_AVX512VL
7236 [(match_operand:VHF_AVX512VL 1 "vector_operand")
7237 (match_operand:VHF_AVX512VL 2 "vector_operand")]
7238 UNSPEC_COMPLEX_FCMUL)
7239 (match_operand:VHF_AVX512VL 3 "vector_operand")))]
7240 "TARGET_AVX512FP16 && flag_unsafe_math_optimizations
7241 && ix86_pre_reload_split ()"
7242 "#"
7243 "&& 1"
7244 [(set (match_dup 0)
7245 (unspec:VHF_AVX512VL
7246 [(match_dup 1) (match_dup 2) (match_dup 3)]
7247 UNSPEC_COMPLEX_FCMA))])
7248
7249 (define_insn_and_split "fma_<complexopname>_<mode>_fma_zero"
7250 [(set (match_operand:VHF_AVX512VL 0 "register_operand")
7251 (plus:VHF_AVX512VL
7252 (unspec:VHF_AVX512VL
7253 [(match_operand:VHF_AVX512VL 1 "vector_operand")
7254 (match_operand:VHF_AVX512VL 2 "vector_operand")
7255 (match_operand:VHF_AVX512VL 3 "const0_operand")]
7256 UNSPEC_COMPLEX_F_C_MA)
7257 (match_operand:VHF_AVX512VL 4 "vector_operand")))]
7258 "TARGET_AVX512FP16 && flag_unsafe_math_optimizations
7259 && ix86_pre_reload_split ()"
7260 "#"
7261 "&& 1"
7262 [(set (match_dup 0)
7263 (unspec:VHF_AVX512VL
7264 [(match_dup 1) (match_dup 2) (match_dup 4)]
7265 UNSPEC_COMPLEX_F_C_MA))])
7266
7267 (define_insn "fma_<complexpairopname>_<mode>_pair"
7268 [(set (match_operand:VF1_AVX512VL 0 "register_operand" "=&v")
7269 (unspec:VF1_AVX512VL
7270 [(match_operand:VF1_AVX512VL 1 "vector_operand" "<int_comm>v")
7271 (match_operand:VF1_AVX512VL 2 "bcst_vector_operand" "vmBr")
7272 (match_operand:VF1_AVX512VL 3 "vector_operand" "0")]
7273 UNSPEC_COMPLEX_F_C_MA_PAIR))]
7274 "TARGET_AVX512FP16"
7275 "v<complexpairopname>ph\t{%2, %1, %0|%0, %1, %2}"
7276 [(set_attr "type" "ssemuladd")
7277 (set_attr "prefix" "evex")
7278 (set_attr "mode" "<MODE>")])
7279
7280 (define_insn_and_split "fma_<mode>_fmaddc_bcst"
7281 [(set (match_operand:VHF_AVX512VL 0 "register_operand")
7282 (unspec:VHF_AVX512VL
7283 [(match_operand:VHF_AVX512VL 1 "vector_operand")
7284 (subreg:VHF_AVX512VL
7285 (match_operand:<ssePSmode> 2 "bcst_vector_operand") 0)
7286 (match_operand:VHF_AVX512VL 3 "vector_operand")]
7287 UNSPEC_COMPLEX_FMA))]
7288 "TARGET_AVX512FP16 && ix86_pre_reload_split ()"
7289 "#"
7290 "&& 1"
7291 [(const_int 0)]
7292 {
7293 if (!MEM_P (operands[1]))
7294 operands[1] = force_reg (<MODE>mode, operands[1]);
7295 if (!MEM_P (operands[3]))
7296 operands[3] = force_reg (<MODE>mode, operands[3]);
7297 operands[1] = lowpart_subreg (<ssePSmode>mode, operands[1], <MODE>mode);
7298 operands[3] = lowpart_subreg (<ssePSmode>mode, operands[3], <MODE>mode);
7299 rtx dest = gen_reg_rtx (<ssePSmode>mode);
7300 emit_insn (gen_fma_fmaddc_<ssePSmodelower>_pair (dest, operands[1],
7301 operands[2], operands[3]));
7302 emit_move_insn (operands[0],
7303 lowpart_subreg (<MODE>mode, dest, <ssePSmode>mode));
7304 DONE;
7305 })
7306
7307 (define_insn_and_split "fma_<mode>_fcmaddc_bcst"
7308 [(set (match_operand:VHF_AVX512VL 0 "register_operand")
7309 (unspec:VHF_AVX512VL
7310 [(match_operand:VHF_AVX512VL 1 "vector_operand")
7311 (subreg:VHF_AVX512VL
7312 (match_operand:<ssePSmode> 2 "bcst_vector_operand") 0)
7313 (match_operand:VHF_AVX512VL 3 "vector_operand")]
7314 UNSPEC_COMPLEX_FCMA))]
7315 "TARGET_AVX512FP16 && ix86_pre_reload_split ()"
7316 "#"
7317 "&& 1"
7318 [(const_int 0)]
7319 {
7320 if (!MEM_P (operands[1]))
7321 operands[1] = force_reg (<MODE>mode, operands[1]);
7322 if (!MEM_P (operands[3]))
7323 operands[3] = force_reg (<MODE>mode, operands[3]);
7324 operands[1] = lowpart_subreg (<ssePSmode>mode, operands[1], <MODE>mode);
7325 operands[3] = lowpart_subreg (<ssePSmode>mode, operands[3], <MODE>mode);
7326 rtx dest = gen_reg_rtx (<ssePSmode>mode);
7327 emit_insn (gen_fma_fcmaddc_<ssePSmodelower>_pair (dest, operands[1],
7328 operands[2],
7329 operands[3]));
7330 emit_move_insn (operands[0],
7331 lowpart_subreg (<MODE>mode, dest, <ssePSmode>mode));
7332 DONE;
7333 })
7334
7335 (define_insn "<avx512>_<complexopname>_<mode>_mask<round_name>"
7336 [(set (match_operand:VHF_AVX512VL 0 "register_operand" "=&v")
7337 (vec_merge:VHF_AVX512VL
7338 (unspec:VHF_AVX512VL
7339 [(match_operand:VHF_AVX512VL 1 "<round_nimm_predicate>" "<int_comm>v")
7340 (match_operand:VHF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>")
7341 (match_operand:VHF_AVX512VL 3 "<round_nimm_predicate>" "0")]
7342 UNSPEC_COMPLEX_F_C_MA)
7343 (match_dup 1)
7344 (unspec:<avx512fmaskmode>
7345 [(match_operand:<avx512fmaskcmode> 4 "register_operand" "Yk")]
7346 UNSPEC_COMPLEX_MASK)))]
7347 "TARGET_AVX512FP16 && <round_mode512bit_condition>"
7348 "v<complexopname><ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
7349 [(set_attr "type" "ssemuladd")
7350 (set_attr "prefix" "evex")
7351 (set_attr "mode" "<MODE>")])
7352
7353 (define_expand "cmul<conj_op><mode>3"
7354 [(set (match_operand:VHF_AVX512VL 0 "register_operand")
7355 (unspec:VHF_AVX512VL
7356 [(match_operand:VHF_AVX512VL 1 "vector_operand")
7357 (match_operand:VHF_AVX512VL 2 "vector_operand")]
7358 UNSPEC_COMPLEX_F_C_MUL))]
7359 "TARGET_AVX512FP16")
7360
7361 (define_insn "<avx512>_<complexopname>_<mode><maskc_name><round_name>"
7362 [(set (match_operand:VHF_AVX512VL 0 "register_operand" "=&v")
7363 (unspec:VHF_AVX512VL
7364 [(match_operand:VHF_AVX512VL 1 "<round_nimm_predicate>" "<int_comm>v")
7365 (match_operand:VHF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>")]
7366 UNSPEC_COMPLEX_F_C_MUL))]
7367 "TARGET_AVX512FP16 && <round_mode512bit_condition>"
7368 {
7369 if (TARGET_DEST_FALSE_DEP_FOR_GLC
7370 && <maskc_dest_false_dep_for_glc_cond>)
7371 output_asm_insn ("vxorps\t%x0, %x0, %x0", operands);
7372 return "v<complexopname><ssemodesuffix>\t{<round_maskc_op3>%2, %1, %0<maskc_operand3>|%0<maskc_operand3>, %1, %2<round_maskc_op3>}";
7373 }
7374 [(set_attr "type" "ssemul")
7375 (set_attr "prefix" "evex")
7376 (set_attr "mode" "<MODE>")])
7377
7378 (define_expand "avx512fp16_fmaddcsh_v8hf_maskz<round_expand_name>"
7379 [(match_operand:V8HF 0 "register_operand")
7380 (match_operand:V8HF 1 "<round_expand_nimm_predicate>")
7381 (match_operand:V8HF 2 "<round_expand_nimm_predicate>")
7382 (match_operand:V8HF 3 "<round_expand_nimm_predicate>")
7383 (match_operand:QI 4 "register_operand")]
7384 "TARGET_AVX512FP16 && <round_mode512bit_condition>"
7385 {
7386 emit_insn (gen_avx512fp16_fma_fmaddcsh_v8hf_maskz<round_expand_name> (
7387 operands[0], operands[1], operands[2], operands[3],
7388 CONST0_RTX (V8HFmode), operands[4]<round_expand_operand>));
7389 DONE;
7390 })
7391
7392 (define_expand "avx512fp16_fmaddcsh_v8hf_mask1<round_expand_name>"
7393 [(match_operand:V8HF 0 "register_operand")
7394 (match_operand:V8HF 1 "<round_expand_nimm_predicate>")
7395 (match_operand:V8HF 2 "<round_expand_nimm_predicate>")
7396 (match_operand:V8HF 3 "<round_expand_nimm_predicate>")
7397 (match_operand:QI 4 "register_operand")]
7398 "TARGET_AVX512FP16 && <round_mode512bit_condition>"
7399 {
7400 rtx op0, op1, dest;
7401
7402 if (<round_embedded_complex>)
7403 emit_insn (gen_avx512fp16_fmaddcsh_v8hf_mask<round_expand_name> (
7404 operands[0], operands[1], operands[2], operands[3],
7405 operands[4]<round_expand_operand>));
7406 else
7407 emit_insn (gen_avx512fp16_fmaddcsh_v8hf_mask (operands[0],
7408 operands[1], operands[2], operands[3], operands[4]));
7409
7410 op0 = lowpart_subreg (V4SFmode, force_reg (V8HFmode, operands[0]),
7411 V8HFmode);
7412 if (!MEM_P (operands[1]))
7413 operands[1] = force_reg (V8HFmode, operands[1]);
7414 op1 = lowpart_subreg (V4SFmode, operands[1], V8HFmode);
7415 dest = gen_reg_rtx (V4SFmode);
7416 emit_insn (gen_avx512f_movsf_mask (dest, op1, op0, op1, operands[4]));
7417 emit_move_insn (operands[0], lowpart_subreg (V8HFmode, dest,
7418 V4SFmode));
7419 DONE;
7420 })
7421
7422 (define_expand "avx512fp16_fcmaddcsh_v8hf_maskz<round_expand_name>"
7423 [(match_operand:V8HF 0 "register_operand")
7424 (match_operand:V8HF 1 "<round_expand_nimm_predicate>")
7425 (match_operand:V8HF 2 "<round_expand_nimm_predicate>")
7426 (match_operand:V8HF 3 "<round_expand_nimm_predicate>")
7427 (match_operand:QI 4 "register_operand")]
7428 "TARGET_AVX512FP16 && <round_mode512bit_condition>"
7429 {
7430 emit_insn (gen_avx512fp16_fma_fcmaddcsh_v8hf_maskz<round_expand_name> (
7431 operands[0], operands[1], operands[2], operands[3],
7432 CONST0_RTX (V8HFmode), operands[4]<round_expand_operand>));
7433 DONE;
7434 })
7435
7436 (define_expand "avx512fp16_fcmaddcsh_v8hf_mask1<round_expand_name>"
7437 [(match_operand:V8HF 0 "register_operand")
7438 (match_operand:V8HF 1 "<round_expand_nimm_predicate>")
7439 (match_operand:V8HF 2 "<round_expand_nimm_predicate>")
7440 (match_operand:V8HF 3 "<round_expand_nimm_predicate>")
7441 (match_operand:QI 4 "register_operand")]
7442 "TARGET_AVX512FP16 && <round_mode512bit_condition>"
7443 {
7444 rtx op0, op1, dest;
7445
7446 if (<round_embedded_complex>)
7447 emit_insn (gen_avx512fp16_fcmaddcsh_v8hf_mask<round_expand_name> (
7448 operands[0], operands[1], operands[2], operands[3],
7449 operands[4]<round_expand_operand>));
7450 else
7451 emit_insn (gen_avx512fp16_fcmaddcsh_v8hf_mask (operands[0],
7452 operands[1], operands[2], operands[3], operands[4]));
7453
7454 op0 = lowpart_subreg (V4SFmode, force_reg (V8HFmode, operands[0]),
7455 V8HFmode);
7456 if (!MEM_P (operands[1]))
7457 operands[1] = force_reg (V8HFmode, operands[1]);
7458 op1 = lowpart_subreg (V4SFmode, operands[1], V8HFmode);
7459 dest = gen_reg_rtx (V4SFmode);
7460 emit_insn (gen_avx512f_movsf_mask (dest, op1, op0, op1, operands[4]));
7461 emit_move_insn (operands[0], lowpart_subreg (V8HFmode, dest,
7462 V4SFmode));
7463 DONE;
7464 })
7465
7466 (define_expand "avx512fp16_fcmaddcsh_v8hf_mask3<round_expand_name>"
7467 [(match_operand:V8HF 0 "register_operand")
7468 (match_operand:V8HF 1 "<round_expand_nimm_predicate>")
7469 (match_operand:V8HF 2 "<round_expand_nimm_predicate>")
7470 (match_operand:V8HF 3 "<round_expand_nimm_predicate>")
7471 (match_operand:QI 4 "register_operand")]
7472 "TARGET_AVX512FP16 && <round_mode512bit_condition>"
7473 {
7474 rtx dest, op0, op1;
7475
7476 if (<round_embedded_complex>)
7477 emit_insn (gen_avx512fp16_fcmaddcsh_v8hf_mask<round_expand_name> (
7478 operands[0], operands[1], operands[2], operands[3],
7479 operands[4]<round_expand_operand>));
7480 else
7481 emit_insn (gen_avx512fp16_fcmaddcsh_v8hf_mask (operands[0],
7482 operands[1], operands[2], operands[3], operands[4]));
7483
7484 dest = gen_reg_rtx (V4SFmode);
7485 op0 = lowpart_subreg (V4SFmode,
7486 force_reg (V8HFmode, operands[0]),
7487 V8HFmode);
7488 if (!MEM_P (operands[3]))
7489 operands[3] = force_reg (V8HFmode, operands[3]);
7490 op1 = lowpart_subreg (V4SFmode, operands[3], V8HFmode);
7491 emit_insn (gen_sse_movss_v4sf (dest, op1, op0));
7492 emit_move_insn (operands[0], lowpart_subreg (V8HFmode, dest, V4SFmode));
7493 DONE;
7494 })
7495
7496 (define_expand "avx512fp16_fmaddcsh_v8hf_mask3<round_expand_name>"
7497 [(match_operand:V8HF 0 "register_operand")
7498 (match_operand:V8HF 1 "<round_expand_nimm_predicate>")
7499 (match_operand:V8HF 2 "<round_expand_nimm_predicate>")
7500 (match_operand:V8HF 3 "<round_expand_nimm_predicate>")
7501 (match_operand:QI 4 "register_operand")]
7502 "TARGET_AVX512FP16 && <round_mode512bit_condition>"
7503 {
7504 rtx dest, op0, op1;
7505
7506 if (<round_embedded_complex>)
7507 emit_insn (gen_avx512fp16_fmaddcsh_v8hf_mask<round_expand_name> (
7508 operands[0], operands[1], operands[2], operands[3],
7509 operands[4]<round_expand_operand>));
7510 else
7511 emit_insn (gen_avx512fp16_fmaddcsh_v8hf_mask (operands[0],
7512 operands[1], operands[2], operands[3], operands[4]));
7513
7514 dest = gen_reg_rtx (V4SFmode);
7515 op0 = lowpart_subreg (V4SFmode,
7516 force_reg (V8HFmode, operands[0]),
7517 V8HFmode);
7518 if (!MEM_P (operands[3]))
7519 operands[3] = force_reg (V8HFmode, operands[3]);
7520 op1 = lowpart_subreg (V4SFmode, operands[3], V8HFmode);
7521 emit_insn (gen_sse_movss_v4sf (dest, op1, op0));
7522 emit_move_insn (operands[0], lowpart_subreg (V8HFmode, dest, V4SFmode));
7523 DONE;
7524 })
7525
7526 (define_insn "avx512fp16_fma_<complexopname>sh_v8hf<mask_scalarcz_name><round_scalarcz_name>"
7527 [(set (match_operand:V8HF 0 "register_operand" "=&v")
7528 (vec_merge:V8HF
7529 (unspec:V8HF
7530 [(match_operand:V8HF 1 "<round_scalarcz_nimm_predicate>" "v")
7531 (match_operand:V8HF 2 "<round_scalarcz_nimm_predicate>" "<round_scalarcz_constraint>")
7532 (match_operand:V8HF 3 "<round_scalarcz_nimm_predicate>" "0")]
7533 UNSPEC_COMPLEX_F_C_MA)
7534 (match_dup 2)
7535 (const_int 3)))]
7536 "TARGET_AVX512FP16"
7537 "v<complexopname>sh\t{<round_scalarcz_mask_op4>%2, %1, %0<mask_scalarcz_operand4>|%0<mask_scalarcz_operand4>, %1, %2<round_scalarcz_mask_op4>}"
7538 [(set_attr "type" "ssemuladd")
7539 (set_attr "prefix" "evex")
7540 (set_attr "mode" "V8HF")])
7541
7542 (define_insn "avx512fp16_<complexopname>sh_v8hf_mask<round_name>"
7543 [(set (match_operand:V8HF 0 "register_operand" "=&v")
7544 (vec_merge:V8HF
7545 (vec_merge:V8HF
7546 (unspec:V8HF
7547 [(match_operand:V8HF 1 "<round_nimm_predicate>" "v")
7548 (match_operand:V8HF 2 "<round_nimm_predicate>" "<round_constraint>")
7549 (match_operand:V8HF 3 "<round_nimm_predicate>" "0")]
7550 UNSPEC_COMPLEX_F_C_MA)
7551 (match_dup 1)
7552 (unspec:QI [(match_operand:QI 4 "register_operand" "Yk")]
7553 UNSPEC_COMPLEX_MASK))
7554 (match_dup 2)
7555 (const_int 3)))]
7556 "TARGET_AVX512FP16"
7557 "v<complexopname>sh\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
7558 [(set_attr "type" "ssemuladd")
7559 (set_attr "prefix" "evex")
7560 (set_attr "mode" "V8HF")])
7561
7562 (define_insn "avx512fp16_<complexopname>sh_v8hf<mask_scalarc_name><round_scalarcz_name>"
7563 [(set (match_operand:V8HF 0 "register_operand" "=&v")
7564 (vec_merge:V8HF
7565 (unspec:V8HF
7566 [(match_operand:V8HF 1 "nonimmediate_operand" "v")
7567 (match_operand:V8HF 2 "<round_scalarcz_nimm_predicate>" "<round_scalarcz_constraint>")]
7568 UNSPEC_COMPLEX_F_C_MUL)
7569 (match_dup 1)
7570 (const_int 3)))]
7571 "TARGET_AVX512FP16"
7572 {
7573 if (TARGET_DEST_FALSE_DEP_FOR_GLC
7574 && <mask_scalarc_dest_false_dep_for_glc_cond>)
7575 output_asm_insn ("vxorps\t%x0, %x0, %x0", operands);
7576 return "v<complexopname>sh\t{<round_scalarc_mask_op3>%2, %1, %0<mask_scalarc_operand3>|%0<mask_scalarc_operand3>, %1, %2<round_scalarc_mask_op3>}";
7577 }
7578 [(set_attr "type" "ssemul")
7579 (set_attr "prefix" "evex")
7580 (set_attr "mode" "V8HF")])
7581
7582 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7583 ;;
7584 ;; Parallel half-precision floating point conversion operations
7585 ;;
7586 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7587
7588 (define_int_iterator UNSPEC_US_FIX_NOTRUNC
7589 [UNSPEC_UNSIGNED_FIX_NOTRUNC UNSPEC_FIX_NOTRUNC])
7590
7591 (define_int_attr sseintconvertsignprefix
7592 [(UNSPEC_UNSIGNED_FIX_NOTRUNC "u")
7593 (UNSPEC_FIX_NOTRUNC "")])
7594
7595 (define_mode_attr qq2phsuff
7596 [(V32HI "") (V16HI "") (V8HI "")
7597 (V16SI "") (V8SI "{y}") (V4SI "{x}")
7598 (V8DI "{z}") (V4DI "{y}") (V2DI "{x}")
7599 (V16SF "") (V8SF "{y}") (V4SF "{x}")
7600 (V8DF "{z}") (V4DF "{y}") (V2DF "{x}")])
7601
7602 (define_mode_attr vunpck_extract_mode
7603 [(V32HF "v32hf") (V16HF "v16hf") (V8HF "v16hf")])
7604
7605 (define_expand "vec_unpacks_lo_<mode>"
7606 [(match_operand:<ssePSmode> 0 "register_operand")
7607 (match_operand:VHF_AVX512VL 1 "register_operand")]
7608 "TARGET_AVX512FP16"
7609 {
7610 rtx tem = operands[1];
7611 rtx (*gen) (rtx, rtx);
7612 if (<MODE>mode != V8HFmode)
7613 {
7614 tem = gen_reg_rtx (<ssehalfvecmode>mode);
7615 emit_insn (gen_vec_extract_lo_<vunpck_extract_mode> (tem,
7616 operands[1]));
7617 gen = gen_extend<ssehalfvecmodelower><ssePSmodelower>2;
7618 }
7619 else
7620 gen = gen_avx512fp16_float_extend_phv4sf2;
7621
7622 emit_insn (gen (operands[0], tem));
7623 DONE;
7624 })
7625
7626 (define_expand "vec_unpacks_hi_<mode>"
7627 [(match_operand:<ssePSmode> 0 "register_operand")
7628 (match_operand:VHF_AVX512VL 1 "register_operand")]
7629 "TARGET_AVX512FP16"
7630 {
7631 rtx tem = operands[1];
7632 rtx (*gen) (rtx, rtx);
7633 if (<MODE>mode != V8HFmode)
7634 {
7635 tem = gen_reg_rtx (<ssehalfvecmode>mode);
7636 emit_insn (gen_vec_extract_hi_<vunpck_extract_mode> (tem,
7637 operands[1]));
7638 gen = gen_extend<ssehalfvecmodelower><ssePSmodelower>2;
7639 }
7640 else
7641 {
7642 tem = gen_reg_rtx (V8HFmode);
7643 rtvec tmp = rtvec_alloc (8);
7644 for (int i = 0; i != 8; i++)
7645 RTVEC_ELT (tmp, i) = GEN_INT ((i + 4) % 8);
7646
7647 rtx selector = gen_rtx_PARALLEL (VOIDmode, tmp);
7648 emit_move_insn (tem,
7649 gen_rtx_VEC_SELECT (V8HFmode, operands[1], selector));
7650 gen = gen_avx512fp16_float_extend_phv4sf2;
7651 }
7652
7653 emit_insn (gen (operands[0], tem));
7654 DONE;
7655 })
7656
7657 (define_expand "lrint<mode><sseintvecmodelower>2"
7658 [(set (match_operand:<sseintvecmode> 0 "register_operand")
7659 (unspec:<sseintvecmode>
7660 [(match_operand:VHF_AVX512VL 1 "register_operand")]
7661 UNSPEC_FIX_NOTRUNC))]
7662 "TARGET_AVX512FP16")
7663
7664 (define_int_iterator UNSPEC_VCVTT_U
7665 [UNSPEC_VCVTT
7666 UNSPEC_VCVTTU])
7667
7668 (define_int_attr vcvtt_suffix
7669 [(UNSPEC_VCVTT "") (UNSPEC_VCVTTU "u")])
7670
7671 (define_int_attr vcvtt_uns_suffix
7672 [(UNSPEC_VCVTT "") (UNSPEC_VCVTTU "uns")])
7673
7674 (define_insn "avx512fp16_vcvtph2<sseintconvertsignprefix><sseintconvert>_<mode><mask_name><round_name>"
7675 [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
7676 (unspec:VI248_AVX512VL
7677 [(match_operand:<ssePHmode> 1 "<round_nimm_predicate>" "<round_constraint>")]
7678 UNSPEC_US_FIX_NOTRUNC))]
7679 "TARGET_AVX512FP16"
7680 "vcvtph2<sseintconvertsignprefix><sseintconvert>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %<iptrh>1<round_mask_op2>}"
7681 [(set_attr "type" "ssecvt")
7682 (set_attr "prefix" "evex")
7683 (set_attr "mode" "<sseinsnmode>")])
7684
7685 (define_expand "float<floatunssuffix><mode><ssePHmodelower>2"
7686 [(set (match_operand:<ssePHmode> 0 "register_operand")
7687 (any_float:<ssePHmode>
7688 (match_operand:VI2H_AVX512VL 1 "nonimmediate_operand")))]
7689 "TARGET_AVX512FP16")
7690
7691 (define_insn "avx512fp16_vcvt<floatsuffix><sseintconvert>2ph_<mode><mask_name><round_name>"
7692 [(set (match_operand:<ssePHmode> 0 "register_operand" "=v")
7693 (any_float:<ssePHmode>
7694 (match_operand:VI2H_AVX512VL 1 "<round_nimm_predicate>" "<round_constraint>")))]
7695 "TARGET_AVX512FP16"
7696 "vcvt<floatsuffix><sseintconvert>2ph<round_qq2phsuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
7697 [(set_attr "type" "ssecvt")
7698 (set_attr "prefix" "evex")
7699 (set_attr "mode" "<sseinsnmode>")])
7700
7701 (define_expand "float<floatunssuffix><mode>v4hf2"
7702 [(set (match_operand:V4HF 0 "register_operand")
7703 (any_float:V4HF
7704 (match_operand:VI4_128_8_256 1 "vector_operand")))]
7705 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7706 {
7707 rtx dest = gen_reg_rtx (V8HFmode);
7708 emit_insn (gen_avx512fp16_float<floatunssuffix><mode>v4hf2 (dest,
7709 operands[1]));
7710 emit_move_insn (operands[0], lowpart_subreg (V4HFmode, dest, V8HFmode));
7711 DONE;
7712 })
7713
7714 (define_expand "avx512fp16_float<floatunssuffix><mode>v4hf2"
7715 [(set (match_operand:V8HF 0 "register_operand")
7716 (vec_concat:V8HF
7717 (any_float:V4HF (match_operand:VI4_128_8_256 1 "vector_operand"))
7718 (match_dup 2)))]
7719 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7720 "operands[2] = CONST0_RTX (V4HFmode);")
7721
7722 (define_insn "*avx512fp16_vcvt<floatsuffix><sseintconvert>2ph_<mode>"
7723 [(set (match_operand:V8HF 0 "register_operand" "=v")
7724 (vec_concat:V8HF
7725 (any_float:V4HF (match_operand:VI4_128_8_256 1 "vector_operand" "vm"))
7726 (match_operand:V4HF 2 "const0_operand")))]
7727 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7728 "vcvt<floatsuffix><sseintconvert>2ph<qq2phsuff>\t{%1, %0|%0, %1}"
7729 [(set_attr "type" "ssecvt")
7730 (set_attr "prefix" "evex")
7731 (set_attr "mode" "<sseinsnmode>")])
7732
7733 (define_expand "avx512fp16_vcvt<floatsuffix><sseintconvert>2ph_<mode>_mask"
7734 [(set (match_operand:V8HF 0 "register_operand" "=v")
7735 (vec_concat:V8HF
7736 (vec_merge:V4HF
7737 (any_float:V4HF (match_operand:VI4_128_8_256 1 "vector_operand" "vm"))
7738 (vec_select:V4HF
7739 (match_operand:V8HF 2 "nonimm_or_0_operand" "0C")
7740 (parallel [(const_int 0) (const_int 1) (const_int 2) (const_int 3)]))
7741 (match_operand:QI 3 "register_operand" "Yk"))
7742 (match_dup 4)))]
7743 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7744 "operands[4] = CONST0_RTX (V4HFmode);")
7745
7746 (define_insn "*avx512fp16_vcvt<floatsuffix><sseintconvert>2ph_<mode>_mask"
7747 [(set (match_operand:V8HF 0 "register_operand" "=v")
7748 (vec_concat:V8HF
7749 (vec_merge:V4HF
7750 (any_float:V4HF (match_operand:VI4_128_8_256 1 "vector_operand" "vm"))
7751 (vec_select:V4HF
7752 (match_operand:V8HF 2 "nonimm_or_0_operand" "0C")
7753 (parallel [(const_int 0) (const_int 1) (const_int 2) (const_int 3)]))
7754 (match_operand:QI 3 "register_operand" "Yk"))
7755 (match_operand:V4HF 4 "const0_operand")))]
7756 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7757 "vcvt<floatsuffix><sseintconvert>2ph<qq2phsuff>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
7758 [(set_attr "type" "ssecvt")
7759 (set_attr "prefix" "evex")
7760 (set_attr "mode" "<sseinsnmode>")])
7761
7762 (define_insn "*avx512fp16_vcvt<floatsuffix><sseintconvert>2ph_<mode>_mask_1"
7763 [(set (match_operand:V8HF 0 "register_operand" "=v")
7764 (vec_concat:V8HF
7765 (vec_merge:V4HF
7766 (any_float:V4HF (match_operand:VI4_128_8_256 1
7767 "vector_operand" "vm"))
7768 (match_operand:V4HF 3 "const0_operand")
7769 (match_operand:QI 2 "register_operand" "Yk"))
7770 (match_operand:V4HF 4 "const0_operand")))]
7771 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7772 "vcvt<floatsuffix><sseintconvert>2ph<qq2phsuff>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
7773 [(set_attr "type" "ssecvt")
7774 (set_attr "prefix" "evex")
7775 (set_attr "mode" "<sseinsnmode>")])
7776
7777 (define_expand "float<floatunssuffix>v2div2hf2"
7778 [(set (match_operand:V2HF 0 "register_operand")
7779 (any_float:V2HF
7780 (match_operand:V2DI 1 "vector_operand")))]
7781 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7782 {
7783 rtx dest = gen_reg_rtx (V8HFmode);
7784 emit_insn (gen_avx512fp16_float<floatunssuffix>v2div2hf2 (dest,
7785 operands[1]));
7786 emit_move_insn (operands[0], lowpart_subreg (V2HFmode, dest, V8HFmode));
7787 DONE;
7788 })
7789
7790 (define_expand "avx512fp16_float<floatunssuffix>v2div2hf2"
7791 [(set (match_operand:V8HF 0 "register_operand")
7792 (vec_concat:V8HF
7793 (any_float:V2HF (match_operand:V2DI 1 "vector_operand"))
7794 (match_dup 2)))]
7795 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7796 "operands[2] = CONST0_RTX (V6HFmode);")
7797
7798 (define_insn "*avx512fp16_vcvt<floatsuffix>qq2ph_v2di"
7799 [(set (match_operand:V8HF 0 "register_operand" "=v")
7800 (vec_concat:V8HF
7801 (any_float:V2HF (match_operand:V2DI 1 "vector_operand" "vm"))
7802 (match_operand:V6HF 2 "const0_operand")))]
7803 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7804 "vcvt<floatsuffix>qq2ph{x}\t{%1, %0|%0, %1}"
7805 [(set_attr "type" "ssecvt")
7806 (set_attr "prefix" "evex")
7807 (set_attr "mode" "TI")])
7808
7809 (define_expand "avx512fp16_vcvt<floatsuffix>qq2ph_v2di_mask"
7810 [(set (match_operand:V8HF 0 "register_operand" "=v")
7811 (vec_concat:V8HF
7812 (vec_merge:V2HF
7813 (any_float:V2HF (match_operand:V2DI 1 "vector_operand" "vm"))
7814 (vec_select:V2HF
7815 (match_operand:V8HF 2 "nonimm_or_0_operand" "0C")
7816 (parallel [(const_int 0) (const_int 1)]))
7817 (match_operand:QI 3 "register_operand" "Yk"))
7818 (match_dup 4)))]
7819 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7820 "operands[4] = CONST0_RTX (V6HFmode);")
7821
7822 (define_insn "*avx512fp16_vcvt<floatsuffix>qq2ph_v2di_mask"
7823 [(set (match_operand:V8HF 0 "register_operand" "=v")
7824 (vec_concat:V8HF
7825 (vec_merge:V2HF
7826 (any_float:V2HF (match_operand:V2DI 1 "vector_operand" "vm"))
7827 (vec_select:V2HF
7828 (match_operand:V8HF 2 "nonimm_or_0_operand" "0C")
7829 (parallel [(const_int 0) (const_int 1)]))
7830 (match_operand:QI 3 "register_operand" "Yk"))
7831 (match_operand:V6HF 4 "const0_operand")))]
7832 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7833 "vcvt<floatsuffix>qq2ph{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
7834 [(set_attr "type" "ssecvt")
7835 (set_attr "prefix" "evex")
7836 (set_attr "mode" "TI")])
7837
7838 (define_insn "*avx512fp16_vcvt<floatsuffix>qq2ph_v2di_mask_1"
7839 [(set (match_operand:V8HF 0 "register_operand" "=v")
7840 (vec_concat:V8HF
7841 (vec_merge:V2HF
7842 (any_float:V2HF (match_operand:V2DI 1
7843 "vector_operand" "vm"))
7844 (match_operand:V2HF 3 "const0_operand")
7845 (match_operand:QI 2 "register_operand" "Yk"))
7846 (match_operand:V6HF 4 "const0_operand")))]
7847 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7848 "vcvt<floatsuffix>qq2ph{x}\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
7849 [(set_attr "type" "ssecvt")
7850 (set_attr "prefix" "evex")
7851 (set_attr "mode" "TI")])
7852
7853 (define_insn "avx512fp16_vcvtsh2<sseintconvertsignprefix>si<rex64namesuffix><round_name>"
7854 [(set (match_operand:SWI48 0 "register_operand" "=r")
7855 (unspec:SWI48
7856 [(vec_select:HF
7857 (match_operand:V8HF 1 "register_operand" "v")
7858 (parallel [(const_int 0)]))]
7859 UNSPEC_US_FIX_NOTRUNC))]
7860 "TARGET_AVX512FP16"
7861 "vcvtsh2<sseintconvertsignprefix>si\t{<round_op2>%1, %0|%0, %1<round_op2>}"
7862 [(set_attr "type" "sseicvt")
7863 (set_attr "prefix" "evex")
7864 (set_attr "mode" "<MODE>")])
7865
7866 (define_insn "avx512fp16_vcvtsh2<sseintconvertsignprefix>si<rex64namesuffix>_2"
7867 [(set (match_operand:SWI48 0 "register_operand" "=r,r")
7868 (unspec:SWI48
7869 [(match_operand:HF 1 "nonimmediate_operand" "v,m")]
7870 UNSPEC_US_FIX_NOTRUNC))]
7871 "TARGET_AVX512FP16"
7872 "vcvtsh2<sseintconvertsignprefix>si\t{%1, %0|%0, %1}"
7873 [(set_attr "type" "sseicvt")
7874 (set_attr "prefix" "evex")
7875 (set_attr "mode" "<MODE>")])
7876
7877 (define_mode_attr sseicvtsuffix
7878 [(SI "l") (DI "q")])
7879 (define_insn "avx512fp16_vcvt<floatsuffix>si2sh<rex64namesuffix><round_name>"
7880 [(set (match_operand:V8HF 0 "register_operand" "=v")
7881 (vec_merge:V8HF
7882 (vec_duplicate:V8HF
7883 (any_float:HF
7884 (match_operand:SWI48 2 "<round_nimm_scalar_predicate>" "<round_constraint3>")))
7885 (match_operand:V8HF 1 "register_operand" "v")
7886 (const_int 1)))]
7887 "TARGET_AVX512FP16"
7888 "vcvt<floatsuffix>si2sh{<sseicvtsuffix>}\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
7889 [(set_attr "type" "sseicvt")
7890 (set_attr "prefix" "evex")
7891 (set_attr "mode" "HF")])
7892
7893 (define_expand "fix<fixunssuffix>_trunc<ssePHmodelower><mode>2"
7894 [(set (match_operand:VI2H_AVX512VL 0 "register_operand")
7895 (any_fix:VI2H_AVX512VL
7896 (match_operand:<ssePHmode> 1 "nonimmediate_operand")))]
7897 "TARGET_AVX512FP16")
7898
7899 (define_insn "unspec_avx512fp16_fix<vcvtt_uns_suffix>_trunc<mode>2<mask_name><round_saeonly_name>"
7900 [(set (match_operand:VI2H_AVX512VL 0 "register_operand" "=v")
7901 (unspec:VI2H_AVX512VL
7902 [(match_operand:<ssePHmode> 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
7903 UNSPEC_VCVTT_U))]
7904 "TARGET_AVX512FP16"
7905 "vcvttph2<vcvtt_suffix><sseintconvert>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
7906 [(set_attr "type" "ssecvt")
7907 (set_attr "prefix" "evex")
7908 (set_attr "mode" "<sseinsnmode>")])
7909
7910 (define_insn "avx512fp16_fix<fixunssuffix>_trunc<mode>2<mask_name><round_saeonly_name>"
7911 [(set (match_operand:VI2H_AVX512VL 0 "register_operand" "=v")
7912 (any_fix:VI2H_AVX512VL
7913 (match_operand:<ssePHmode> 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
7914 "TARGET_AVX512FP16"
7915 "vcvttph2<fixsuffix><sseintconvert>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
7916 [(set_attr "type" "ssecvt")
7917 (set_attr "prefix" "evex")
7918 (set_attr "mode" "<sseinsnmode>")])
7919
7920 (define_expand "fix<fixunssuffix>_truncv4hf<mode>2"
7921 [(set (match_operand:VI4_128_8_256 0 "register_operand")
7922 (any_fix:VI4_128_8_256
7923 (match_operand:V4HF 1 "nonimmediate_operand")))]
7924 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7925 {
7926 if (!MEM_P (operands[1]))
7927 {
7928 operands[1] = lowpart_subreg (V8HFmode,
7929 force_reg (V4HFmode, operands[1]),
7930 V4HFmode);
7931 emit_insn (gen_avx512fp16_fix<fixunssuffix>_trunc<mode>2 (operands[0],
7932 operands[1]));
7933 DONE;
7934 }
7935 })
7936
7937 (define_insn "unspec_avx512fp16_fix<vcvtt_uns_suffix>_trunc<mode>2<mask_name>"
7938 [(set (match_operand:VI4_128_8_256 0 "register_operand" "=v")
7939 (unspec:VI4_128_8_256
7940 [(match_operand:V8HF 1 "register_operand" "v")]
7941 UNSPEC_VCVTT_U))]
7942 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7943 "vcvttph2<vcvtt_suffix><sseintconvert>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
7944 [(set_attr "type" "ssecvt")
7945 (set_attr "prefix" "evex")
7946 (set_attr "mode" "<sseinsnmode>")])
7947
7948 (define_insn "avx512fp16_fix<fixunssuffix>_trunc<mode>2<mask_name>"
7949 [(set (match_operand:VI4_128_8_256 0 "register_operand" "=v")
7950 (any_fix:VI4_128_8_256
7951 (vec_select:V4HF
7952 (match_operand:V8HF 1 "register_operand" "v")
7953 (parallel [(const_int 0) (const_int 1) (const_int 2) (const_int 3)]))))]
7954 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7955 "vcvttph2<fixsuffix><sseintconvert>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
7956 [(set_attr "type" "ssecvt")
7957 (set_attr "prefix" "evex")
7958 (set_attr "mode" "<sseinsnmode>")])
7959
7960 (define_insn "*avx512fp16_fix<fixunssuffix>_trunc<mode>2_load<mask_name>"
7961 [(set (match_operand:VI4_128_8_256 0 "register_operand" "=v")
7962 (any_fix:VI4_128_8_256
7963 (match_operand:V4HF 1 "memory_operand" "m")))]
7964 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7965 "vcvttph2<fixsuffix><sseintconvert>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
7966 [(set_attr "type" "ssecvt")
7967 (set_attr "prefix" "evex")
7968 (set_attr "mode" "<sseinsnmode>")])
7969
7970 (define_expand "fix<fixunssuffix>_truncv2hfv2di2"
7971 [(set (match_operand:V2DI 0 "register_operand")
7972 (any_fix:V2DI
7973 (match_operand:V2HF 1 "nonimmediate_operand")))]
7974 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7975 {
7976 if (!MEM_P (operands[1]))
7977 {
7978 operands[1] = lowpart_subreg (V8HFmode,
7979 force_reg (V2HFmode, operands[1]),
7980 V2HFmode);
7981 emit_insn (gen_avx512fp16_fix<fixunssuffix>_truncv2di2 (operands[0],
7982 operands[1]));
7983 DONE;
7984 }
7985 })
7986
7987 (define_insn "unspec_avx512fp16_fix<vcvtt_uns_suffix>_truncv2di2<mask_name>"
7988 [(set (match_operand:V2DI 0 "register_operand" "=v")
7989 (unspec:V2DI
7990 [(match_operand:V8HF 1 "nonimmediate_operand" "v")]
7991 UNSPEC_VCVTT_U))]
7992 "TARGET_AVX512FP16 && TARGET_AVX512VL"
7993 "vcvttph2<vcvtt_suffix>qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
7994 [(set_attr "type" "ssecvt")
7995 (set_attr "prefix" "evex")
7996 (set_attr "mode" "TI")])
7997
7998 (define_insn "avx512fp16_fix<fixunssuffix>_truncv2di2<mask_name>"
7999 [(set (match_operand:V2DI 0 "register_operand" "=v")
8000 (any_fix:V2DI
8001 (vec_select:V2HF
8002 (match_operand:V8HF 1 "nonimmediate_operand" "v")
8003 (parallel [(const_int 0) (const_int 1)]))))]
8004 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8005 "vcvttph2<fixsuffix>qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
8006 [(set_attr "type" "ssecvt")
8007 (set_attr "prefix" "evex")
8008 (set_attr "mode" "TI")])
8009
8010 (define_insn "*avx512fp16_fix<fixunssuffix>_truncv2di2_load<mask_name>"
8011 [(set (match_operand:V2DI 0 "register_operand" "=v")
8012 (any_fix:V2DI
8013 (match_operand:V2HF 1 "memory_operand" "m")))]
8014 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8015 "vcvttph2<fixsuffix>qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
8016 [(set_attr "type" "ssecvt")
8017 (set_attr "prefix" "evex")
8018 (set_attr "mode" "TI")])
8019
8020 (define_insn "unspec_avx512fp16_fix<vcvtt_uns_suffix>_trunc<mode>2<round_saeonly_name>"
8021 [(set (match_operand:SWI48 0 "register_operand" "=r")
8022 (unspec:SWI48
8023 [(match_operand:V8HF 1 "register_operand" "v")]
8024 UNSPEC_VCVTT_U))]
8025 "TARGET_AVX512FP16"
8026 "%vcvttsh2<vcvtt_suffix>si\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
8027 [(set_attr "type" "sseicvt")
8028 (set_attr "prefix" "evex")
8029 (set_attr "mode" "<MODE>")])
8030
8031 (define_insn "avx512fp16_fix<fixunssuffix>_trunc<mode>2<round_saeonly_name>"
8032 [(set (match_operand:SWI48 0 "register_operand" "=r")
8033 (any_fix:SWI48
8034 (vec_select:HF
8035 (match_operand:V8HF 1 "register_operand" "v")
8036 (parallel [(const_int 0)]))))]
8037 "TARGET_AVX512FP16"
8038 "%vcvttsh2<fixsuffix>si\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
8039 [(set_attr "type" "sseicvt")
8040 (set_attr "prefix" "evex")
8041 (set_attr "mode" "<MODE>")])
8042
8043 (define_insn "avx512fp16_fix<fixunssuffix>_trunc<mode>2_mem"
8044 [(set (match_operand:SWI48 0 "register_operand" "=r")
8045 (any_fix:SWI48
8046 (match_operand:HF 1 "memory_operand" "vm")))]
8047 "TARGET_AVX512FP16"
8048 "%vcvttsh2<fixsuffix>si\t{%1, %0|%0, %1}"
8049 [(set_attr "type" "sseicvt")
8050 (set_attr "prefix" "evex")
8051 (set_attr "mode" "<MODE>")])
8052
8053 (define_mode_attr ph2pssuffix
8054 [(V16SF "x") (V8SF "x") (V4SF "x")
8055 (V8DF "") (V4DF "") (V2DF "")])
8056
8057 (define_expand "extend<ssePHmodelower><mode>2"
8058 [(set (match_operand:VF48H_AVX512VL 0 "register_operand")
8059 (float_extend:VF48H_AVX512VL
8060 (match_operand:<ssePHmode> 1 "nonimmediate_operand")))]
8061 "TARGET_AVX512FP16")
8062
8063 (define_insn "avx512fp16_float_extend_ph<mode>2<mask_name><round_saeonly_name>"
8064 [(set (match_operand:VF48H_AVX512VL 0 "register_operand" "=v")
8065 (float_extend:VF48H_AVX512VL
8066 (match_operand:<ssePHmode> 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
8067 "TARGET_AVX512FP16"
8068 "vcvtph2<castmode><ph2pssuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
8069 [(set_attr "type" "ssecvt")
8070 (set_attr "prefix" "evex")
8071 (set_attr "mode" "<sseinsnmode>")])
8072
8073 (define_expand "extendv4hf<mode>2"
8074 [(set (match_operand:VF4_128_8_256 0 "register_operand")
8075 (float_extend:VF4_128_8_256
8076 (match_operand:V4HF 1 "nonimmediate_operand")))]
8077 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8078 {
8079 if (!MEM_P (operands[1]))
8080 {
8081 operands[1] = lowpart_subreg (V8HFmode,
8082 force_reg (V4HFmode, operands[1]),
8083 V4HFmode);
8084 emit_insn (gen_avx512fp16_float_extend_ph<mode>2
8085 (operands[0], operands[1]));
8086 DONE;
8087 }
8088 })
8089
8090 (define_insn "avx512fp16_float_extend_ph<mode>2<mask_name>"
8091 [(set (match_operand:VF4_128_8_256 0 "register_operand" "=v")
8092 (float_extend:VF4_128_8_256
8093 (vec_select:V4HF
8094 (match_operand:V8HF 1 "register_operand" "v")
8095 (parallel [(const_int 0) (const_int 1) (const_int 2) (const_int 3)]))))]
8096 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8097 "vcvtph2<castmode><ph2pssuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
8098 [(set_attr "type" "ssecvt")
8099 (set_attr "prefix" "evex")
8100 (set_attr "mode" "<sseinsnmode>")])
8101
8102 (define_insn "*avx512fp16_float_extend_ph<mode>2_load<mask_name>"
8103 [(set (match_operand:VF4_128_8_256 0 "register_operand" "=v")
8104 (float_extend:VF4_128_8_256
8105 (match_operand:V4HF 1 "memory_operand" "m")))]
8106 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8107 "vcvtph2<castmode><ph2pssuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
8108 [(set_attr "type" "ssecvt")
8109 (set_attr "prefix" "evex")
8110 (set_attr "mode" "<sseinsnmode>")])
8111
8112 (define_expand "extendv2hfv2df2"
8113 [(set (match_operand:V2DF 0 "register_operand")
8114 (float_extend:V2DF
8115 (match_operand:V2HF 1 "nonimmediate_operand")))]
8116 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8117 {
8118 if (!MEM_P (operands[1]))
8119 {
8120 operands[1] = lowpart_subreg (V8HFmode,
8121 force_reg (V2HFmode, operands[1]),
8122 V2HFmode);
8123 emit_insn (gen_avx512fp16_float_extend_phv2df2
8124 (operands[0], operands[1]));
8125 DONE;
8126 }
8127 })
8128
8129 (define_insn "avx512fp16_float_extend_phv2df2<mask_name>"
8130 [(set (match_operand:V2DF 0 "register_operand" "=v")
8131 (float_extend:V2DF
8132 (vec_select:V2HF
8133 (match_operand:V8HF 1 "register_operand" "v")
8134 (parallel [(const_int 0) (const_int 1)]))))]
8135 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8136 "vcvtph2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
8137 [(set_attr "type" "ssecvt")
8138 (set_attr "prefix" "evex")
8139 (set_attr "mode" "TI")])
8140
8141 (define_insn "*avx512fp16_float_extend_phv2df2_load<mask_name>"
8142 [(set (match_operand:V2DF 0 "register_operand" "=v")
8143 (float_extend:V2DF
8144 (match_operand:V2HF 1 "memory_operand" "m")))]
8145 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8146 "vcvtph2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
8147 [(set_attr "type" "ssecvt")
8148 (set_attr "prefix" "evex")
8149 (set_attr "mode" "TI")])
8150
8151 (define_expand "trunc<mode><ssePHmodelower>2"
8152 [(set (match_operand:<ssePHmode> 0 "register_operand")
8153 (float_truncate:<ssePHmode>
8154 (match_operand:VF48H_AVX512VL 1 "nonimmediate_operand")))]
8155 "TARGET_AVX512FP16")
8156
8157 (define_insn "avx512fp16_vcvt<castmode>2ph_<mode><mask_name><round_name>"
8158 [(set (match_operand:<ssePHmode> 0 "register_operand" "=v")
8159 (float_truncate:<ssePHmode>
8160 (match_operand:VF48H_AVX512VL 1 "<round_nimm_predicate>" "<round_constraint>")))]
8161 "TARGET_AVX512FP16"
8162 "vcvt<castmode>2ph<ph2pssuffix><round_qq2phsuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
8163 [(set_attr "type" "ssecvt")
8164 (set_attr "prefix" "evex")
8165 (set_attr "mode" "<sseinsnmode>")])
8166
8167 (define_expand "trunc<mode>v4hf2"
8168 [(set (match_operand:V4HF 0 "register_operand")
8169 (float_truncate:V4HF (match_operand:VF4_128_8_256 1 "vector_operand")))]
8170 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8171 {
8172 rtx dest = gen_reg_rtx (V8HFmode);
8173
8174 emit_insn (gen_avx512fp16_trunc<mode>v4hf2 (dest, operands[1]));
8175 emit_move_insn (operands[0], lowpart_subreg (V4HFmode, dest, V8HFmode));
8176 DONE;
8177 })
8178
8179 (define_expand "avx512fp16_trunc<mode>v4hf2"
8180 [(set (match_operand:V8HF 0 "register_operand")
8181 (vec_concat:V8HF
8182 (float_truncate:V4HF
8183 (match_operand:VF4_128_8_256 1 "vector_operand"))
8184 (match_dup 2)))]
8185 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8186 "operands[2] = CONST0_RTX (V4HFmode);")
8187
8188 (define_insn "*avx512fp16_vcvt<castmode>2ph_<mode>"
8189 [(set (match_operand:V8HF 0 "register_operand" "=v")
8190 (vec_concat:V8HF
8191 (float_truncate:V4HF
8192 (match_operand:VF4_128_8_256 1 "vector_operand" "vm"))
8193 (match_operand:V4HF 2 "const0_operand")))]
8194 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8195 "vcvt<castmode>2ph<ph2pssuffix><qq2phsuff>\t{%1, %0|%0, %1}"
8196 [(set_attr "type" "ssecvt")
8197 (set_attr "prefix" "evex")
8198 (set_attr "mode" "<sseinsnmode>")])
8199
8200 (define_expand "avx512fp16_vcvt<castmode>2ph_<mode>_mask"
8201 [(set (match_operand:V8HF 0 "register_operand" "=v")
8202 (vec_concat:V8HF
8203 (vec_merge:V4HF
8204 (float_truncate:V4HF
8205 (match_operand:VF4_128_8_256 1 "vector_operand" "vm"))
8206 (vec_select:V4HF
8207 (match_operand:V8HF 2 "nonimm_or_0_operand" "0C")
8208 (parallel [(const_int 0) (const_int 1)
8209 (const_int 2) (const_int 3)]))
8210 (match_operand:QI 3 "register_operand" "Yk"))
8211 (match_dup 4)))]
8212 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8213 "operands[4] = CONST0_RTX (V4HFmode);")
8214
8215 (define_insn "*avx512fp16_vcvt<castmode>2ph_<mode>_mask"
8216 [(set (match_operand:V8HF 0 "register_operand" "=v")
8217 (vec_concat:V8HF
8218 (vec_merge:V4HF
8219 (float_truncate:V4HF
8220 (match_operand:VF4_128_8_256 1 "vector_operand" "vm"))
8221 (vec_select:V4HF
8222 (match_operand:V8HF 2 "nonimm_or_0_operand" "0C")
8223 (parallel [(const_int 0) (const_int 1)
8224 (const_int 2) (const_int 3)]))
8225 (match_operand:QI 3 "register_operand" "Yk"))
8226 (match_operand:V4HF 4 "const0_operand")))]
8227 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8228 "vcvt<castmode>2ph<ph2pssuffix><qq2phsuff>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
8229 [(set_attr "type" "ssecvt")
8230 (set_attr "prefix" "evex")
8231 (set_attr "mode" "<sseinsnmode>")])
8232
8233 (define_insn "*avx512fp16_vcvt<castmode>2ph_<mode>_mask_1"
8234 [(set (match_operand:V8HF 0 "register_operand" "=v")
8235 (vec_concat:V8HF
8236 (vec_merge:V4HF
8237 (float_truncate:V4HF
8238 (match_operand:VF4_128_8_256 1 "vector_operand" "vm"))
8239 (match_operand:V4HF 3 "const0_operand")
8240 (match_operand:QI 2 "register_operand" "Yk"))
8241 (match_operand:V4HF 4 "const0_operand")))]
8242 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8243 "vcvt<castmode>2ph<ph2pssuffix><qq2phsuff>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
8244 [(set_attr "type" "ssecvt")
8245 (set_attr "prefix" "evex")
8246 (set_attr "mode" "<sseinsnmode>")])
8247
8248 (define_expand "truncv2dfv2hf2"
8249 [(set (match_operand:V2HF 0 "register_operand")
8250 (float_truncate:V2HF (match_operand:V2DF 1 "vector_operand")))]
8251 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8252 {
8253 rtx dest = gen_reg_rtx (V8HFmode);
8254 emit_insn (gen_avx512fp16_truncv2dfv2hf2 (dest, operands[1]));
8255 emit_move_insn (operands[0], lowpart_subreg (V2HFmode, dest, V8HFmode));
8256 DONE;
8257 })
8258
8259 (define_expand "avx512fp16_truncv2dfv2hf2"
8260 [(set (match_operand:V8HF 0 "register_operand")
8261 (vec_concat:V8HF
8262 (float_truncate:V2HF (match_operand:V2DF 1 "vector_operand"))
8263 (match_dup 2)))]
8264 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8265 "operands[2] = CONST0_RTX (V6HFmode);")
8266
8267 (define_insn "*avx512fp16_vcvtpd2ph_v2df"
8268 [(set (match_operand:V8HF 0 "register_operand" "=v")
8269 (vec_concat:V8HF
8270 (float_truncate:V2HF
8271 (match_operand:V2DF 1 "vector_operand" "vm"))
8272 (match_operand:V6HF 2 "const0_operand")))]
8273 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8274 "vcvtpd2ph{x}\t{%1, %0|%0, %1}"
8275 [(set_attr "type" "ssecvt")
8276 (set_attr "prefix" "evex")
8277 (set_attr "mode" "TI")])
8278
8279 (define_expand "avx512fp16_vcvtpd2ph_v2df_mask"
8280 [(set (match_operand:V8HF 0 "register_operand" "=v")
8281 (vec_concat:V8HF
8282 (vec_merge:V2HF
8283 (float_truncate:V2HF
8284 (match_operand:V2DF 1 "vector_operand" "vm"))
8285 (vec_select:V2HF
8286 (match_operand:V8HF 2 "nonimm_or_0_operand" "0C")
8287 (parallel [(const_int 0) (const_int 1)]))
8288 (match_operand:QI 3 "register_operand" "Yk"))
8289 (match_dup 4)))]
8290 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8291 "operands[4] = CONST0_RTX (V6HFmode);")
8292
8293 (define_insn "*avx512fp16_vcvtpd2ph_v2df_mask"
8294 [(set (match_operand:V8HF 0 "register_operand" "=v")
8295 (vec_concat:V8HF
8296 (vec_merge:V2HF
8297 (float_truncate:V2HF (match_operand:V2DF 1 "vector_operand" "vm"))
8298 (vec_select:V2HF
8299 (match_operand:V8HF 2 "nonimm_or_0_operand" "0C")
8300 (parallel [(const_int 0) (const_int 1)]))
8301 (match_operand:QI 3 "register_operand" "Yk"))
8302 (match_operand:V6HF 4 "const0_operand")))]
8303 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8304 "vcvtpd2ph{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
8305 [(set_attr "type" "ssecvt")
8306 (set_attr "prefix" "evex")
8307 (set_attr "mode" "TI")])
8308
8309 (define_insn "*avx512fp16_vcvtpd2ph_v2df_mask_1"
8310 [(set (match_operand:V8HF 0 "register_operand" "=v")
8311 (vec_concat:V8HF
8312 (vec_merge:V2HF
8313 (float_truncate:V2HF
8314 (match_operand:V2DF 1 "vector_operand" "vm"))
8315 (match_operand:V2HF 3 "const0_operand")
8316 (match_operand:QI 2 "register_operand" "Yk"))
8317 (match_operand:V6HF 4 "const0_operand")))]
8318 "TARGET_AVX512FP16 && TARGET_AVX512VL"
8319 "vcvtpd2ph{x}\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
8320 [(set_attr "type" "ssecvt")
8321 (set_attr "prefix" "evex")
8322 (set_attr "mode" "TI")])
8323
8324 (define_insn "avx512fp16_vcvtsh2<ssescalarmodesuffix><mask_scalar_name><round_saeonly_scalar_name>"
8325 [(set (match_operand:VF48_128 0 "register_operand" "=v")
8326 (vec_merge:VF48_128
8327 (vec_duplicate:VF48_128
8328 (float_extend:<ssescalarmode>
8329 (vec_select:HF
8330 (match_operand:V8HF 1 "register_operand" "v")
8331 (parallel [(const_int 0)]))))
8332 (match_operand:VF48_128 2 "register_operand" "v")
8333 (const_int 1)))]
8334 "TARGET_AVX512FP16"
8335 "vcvtsh2<ssescalarmodesuffix>\t{<round_saeonly_scalar_mask_op3>%1, %2, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %2, %1<round_saeonly_scalar_mask_op3>}"
8336 [(set_attr "type" "ssecvt")
8337 (set_attr "prefix" "evex")
8338 (set_attr "mode" "TI")])
8339
8340 (define_insn "avx512fp16_vcvtsh2<ssescalarmodesuffix><mask_scalar_name>_mem"
8341 [(set (match_operand:VF48_128 0 "register_operand" "=v")
8342 (vec_merge:VF48_128
8343 (vec_duplicate:VF48_128
8344 (float_extend:<ssescalarmode>
8345 (match_operand:HF 1 "memory_operand" "m")))
8346 (match_operand:VF48_128 2 "register_operand" "v")
8347 (const_int 1)))]
8348 "TARGET_AVX512FP16"
8349 "vcvtsh2<ssescalarmodesuffix>\t{%1, %2, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %2, %1}"
8350 [(set_attr "type" "ssecvt")
8351 (set_attr "prefix" "evex")
8352 (set_attr "mode" "TI")])
8353
8354 (define_insn "avx512fp16_vcvt<ssescalarmodesuffix>2sh<mask_scalar_name><round_scalar_name>"
8355 [(set (match_operand:V8HF 0 "register_operand" "=v")
8356 (vec_merge:V8HF
8357 (vec_duplicate:V8HF
8358 (float_truncate:HF
8359 (vec_select:<ssescalarmode>
8360 (match_operand:VF48_128 1 "register_operand" "v")
8361 (parallel [(const_int 0)]))))
8362 (match_operand:V8HF 2 "register_operand" "v")
8363 (const_int 1)))]
8364 "TARGET_AVX512FP16"
8365 "vcvt<ssescalarmodesuffix>2sh\t{<round_scalar_mask_op3>%1, %2, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %2, %1<round_scalar_mask_op3>}"
8366 [(set_attr "type" "ssecvt")
8367 (set_attr "prefix" "evex")
8368 (set_attr "mode" "TI")])
8369
8370 (define_insn "avx512fp16_vcvt<ssescalarmodesuffix>2sh<mask_scalar_name>_mem"
8371 [(set (match_operand:V8HF 0 "register_operand" "=v")
8372 (vec_merge:V8HF
8373 (vec_duplicate:V8HF
8374 (float_truncate:HF
8375 (match_operand:MODEF 1 "memory_operand" "m")))
8376 (match_operand:V8HF 2 "register_operand" "v")
8377 (const_int 1)))]
8378 "TARGET_AVX512FP16"
8379 "vcvt<ssescalarmodesuffix>2sh\t{%1, %2, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %2, %1}"
8380 [(set_attr "type" "ssecvt")
8381 (set_attr "prefix" "evex")
8382 (set_attr "mode" "TI")])
8383
8384 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8385 ;;
8386 ;; Parallel single-precision floating point conversion operations
8387 ;;
8388 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8389
8390 (define_insn_and_split "sse_cvtpi2ps"
8391 [(set (match_operand:V4SF 0 "register_operand" "=x,x,Yv")
8392 (vec_merge:V4SF
8393 (vec_duplicate:V4SF
8394 (float:V2SF (match_operand:V2SI 2 "register_mmxmem_operand" "ym,x,Yv")))
8395 (match_operand:V4SF 1 "register_operand" "0,0,Yv")
8396 (const_int 3)))
8397 (clobber (match_scratch:V4SF 3 "=X,x,Yv"))]
8398 "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSE"
8399 "@
8400 cvtpi2ps\t{%2, %0|%0, %2}
8401 #
8402 #"
8403 "TARGET_SSE2 && reload_completed
8404 && SSE_REG_P (operands[2])"
8405 [(const_int 0)]
8406 {
8407 rtx op2 = lowpart_subreg (V4SImode, operands[2],
8408 GET_MODE (operands[2]));
8409 /* Generate SSE2 cvtdq2ps. */
8410 emit_insn (gen_floatv4siv4sf2 (operands[3], op2));
8411
8412 /* Merge operands[3] with operands[0]. */
8413 rtx mask, op1;
8414 if (TARGET_AVX)
8415 {
8416 mask = gen_rtx_PARALLEL (VOIDmode,
8417 gen_rtvec (4, GEN_INT (0), GEN_INT (1),
8418 GEN_INT (6), GEN_INT (7)));
8419 op1 = gen_rtx_VEC_CONCAT (V8SFmode, operands[3], operands[1]);
8420 op2 = gen_rtx_VEC_SELECT (V4SFmode, op1, mask);
8421 emit_insn (gen_rtx_SET (operands[0], op2));
8422 }
8423 else
8424 {
8425 /* NB: SSE can only concatenate OP0 and OP3 to OP0. */
8426 mask = gen_rtx_PARALLEL (VOIDmode,
8427 gen_rtvec (4, GEN_INT (2), GEN_INT (3),
8428 GEN_INT (4), GEN_INT (5)));
8429 op1 = gen_rtx_VEC_CONCAT (V8SFmode, operands[0], operands[3]);
8430 op2 = gen_rtx_VEC_SELECT (V4SFmode, op1, mask);
8431 emit_insn (gen_rtx_SET (operands[0], op2));
8432
8433 /* Swap bits 0:63 with bits 64:127. */
8434 mask = gen_rtx_PARALLEL (VOIDmode,
8435 gen_rtvec (4, GEN_INT (2), GEN_INT (3),
8436 GEN_INT (0), GEN_INT (1)));
8437 rtx dest = lowpart_subreg (V4SImode, operands[0],
8438 GET_MODE (operands[0]));
8439 op1 = gen_rtx_VEC_SELECT (V4SImode, dest, mask);
8440 emit_insn (gen_rtx_SET (dest, op1));
8441 }
8442 DONE;
8443 }
8444 [(set_attr "mmx_isa" "native,sse_noavx,avx")
8445 (set_attr "type" "ssecvt")
8446 (set_attr "mode" "V4SF")])
8447
8448 (define_insn_and_split "sse_cvtps2pi"
8449 [(set (match_operand:V2SI 0 "register_operand" "=y,Yv")
8450 (vec_select:V2SI
8451 (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm,YvBm")]
8452 UNSPEC_FIX_NOTRUNC)
8453 (parallel [(const_int 0) (const_int 1)])))]
8454 "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSE"
8455 "@
8456 cvtps2pi\t{%1, %0|%0, %q1}
8457 #"
8458 "TARGET_SSE2 && reload_completed
8459 && SSE_REG_P (operands[0])"
8460 [(const_int 0)]
8461 {
8462 rtx op1 = lowpart_subreg (V2SFmode, operands[1],
8463 GET_MODE (operands[1]));
8464 rtx tmp = lowpart_subreg (V4SFmode, operands[0],
8465 GET_MODE (operands[0]));
8466
8467 op1 = gen_rtx_VEC_CONCAT (V4SFmode, op1, CONST0_RTX (V2SFmode));
8468 emit_insn (gen_rtx_SET (tmp, op1));
8469
8470 rtx dest = lowpart_subreg (V4SImode, operands[0],
8471 GET_MODE (operands[0]));
8472 emit_insn (gen_sse2_fix_notruncv4sfv4si (dest, tmp));
8473 DONE;
8474 }
8475 [(set_attr "isa" "*,sse2")
8476 (set_attr "mmx_isa" "native,*")
8477 (set_attr "type" "ssecvt")
8478 (set_attr "unit" "mmx,*")
8479 (set_attr "mode" "DI")])
8480
8481 (define_insn_and_split "unspec_sse_cvttps2pi"
8482 [(set (match_operand:V2SI 0 "register_operand" "=y,Yv")
8483 (unspec:V2SI
8484 [(match_operand:V4SF 1 "nonimmediate_operand" "xm,YvBm")]
8485 UNSPEC_VCVTT))]
8486 "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSE"
8487 "@
8488 cvttps2pi\t{%1, %0|%0, %q1}
8489 #"
8490 "TARGET_SSE2 && reload_completed
8491 && SSE_REG_P (operands[0])"
8492 [(const_int 0)]
8493 {
8494 rtx op1 = lowpart_subreg (V2SFmode, operands[1],
8495 GET_MODE (operands[1]));
8496 rtx tmp = lowpart_subreg (V4SFmode, operands[0],
8497 GET_MODE (operands[0]));
8498
8499 op1 = gen_rtx_VEC_CONCAT (V4SFmode, op1, CONST0_RTX (V2SFmode));
8500 emit_insn (gen_rtx_SET (tmp, op1));
8501 rtx dest = lowpart_subreg (V4SImode, operands[0],
8502 GET_MODE (operands[0]));
8503 emit_insn (gen_unspec_fix_truncv4sfv4si2 (dest, tmp));
8504 DONE;
8505 }
8506 [(set_attr "isa" "*,sse2")
8507 (set_attr "mmx_isa" "native,*")
8508 (set_attr "type" "ssecvt")
8509 (set_attr "unit" "mmx,*")
8510 (set_attr "prefix_rep" "0")
8511 (set_attr "mode" "SF")])
8512
8513 (define_insn_and_split "sse_cvttps2pi"
8514 [(set (match_operand:V2SI 0 "register_operand" "=y,Yv")
8515 (vec_select:V2SI
8516 (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm,YvBm"))
8517 (parallel [(const_int 0) (const_int 1)])))]
8518 "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSE"
8519 "@
8520 cvttps2pi\t{%1, %0|%0, %q1}
8521 #"
8522 "TARGET_SSE2 && reload_completed
8523 && SSE_REG_P (operands[0])"
8524 [(const_int 0)]
8525 {
8526 rtx op1 = lowpart_subreg (V2SFmode, operands[1],
8527 GET_MODE (operands[1]));
8528 rtx tmp = lowpart_subreg (V4SFmode, operands[0],
8529 GET_MODE (operands[0]));
8530
8531 op1 = gen_rtx_VEC_CONCAT (V4SFmode, op1, CONST0_RTX (V2SFmode));
8532 emit_insn (gen_rtx_SET (tmp, op1));
8533
8534 rtx dest = lowpart_subreg (V4SImode, operands[0],
8535 GET_MODE (operands[0]));
8536 emit_insn (gen_fix_truncv4sfv4si2 (dest, tmp));
8537 DONE;
8538 }
8539 [(set_attr "isa" "*,sse2")
8540 (set_attr "mmx_isa" "native,*")
8541 (set_attr "type" "ssecvt")
8542 (set_attr "unit" "mmx,*")
8543 (set_attr "prefix_rep" "0")
8544 (set_attr "mode" "SF")])
8545
8546 (define_insn "sse_cvtsi2ss<rex64namesuffix><round_name>"
8547 [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
8548 (vec_merge:V4SF
8549 (vec_duplicate:V4SF
8550 (float:SF (match_operand:SWI48 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
8551 (match_operand:V4SF 1 "register_operand" "0,0,v")
8552 (const_int 1)))]
8553 "TARGET_SSE"
8554 "@
8555 cvtsi2ss<rex64suffix>\t{%2, %0|%0, %2}
8556 cvtsi2ss<rex64suffix>\t{%2, %0|%0, %2}
8557 vcvtsi2ss<rex64suffix>\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
8558 [(set_attr "isa" "noavx,noavx,avx")
8559 (set_attr "type" "sseicvt")
8560 (set_attr "athlon_decode" "vector,double,*")
8561 (set_attr "amdfam10_decode" "vector,double,*")
8562 (set_attr "bdver1_decode" "double,direct,*")
8563 (set_attr "btver2_decode" "double,double,double")
8564 (set_attr "znver1_decode" "double,double,double")
8565 (set_attr "c86_decode" "double,double,double")
8566 (set (attr "length_vex")
8567 (if_then_else
8568 (and (match_test "<MODE>mode == DImode")
8569 (eq_attr "alternative" "2"))
8570 (const_string "4")
8571 (const_string "*")))
8572 (set (attr "prefix_rex")
8573 (if_then_else
8574 (and (match_test "<MODE>mode == DImode")
8575 (eq_attr "alternative" "0,1"))
8576 (const_string "1")
8577 (const_string "*")))
8578 (set_attr "prefix" "orig,orig,maybe_evex")
8579 (set_attr "mode" "SF")])
8580
8581 (define_insn "sse_cvtss2si<rex64namesuffix><round_name>"
8582 [(set (match_operand:SWI48 0 "register_operand" "=r,r")
8583 (unspec:SWI48
8584 [(vec_select:SF
8585 (match_operand:V4SF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
8586 (parallel [(const_int 0)]))]
8587 UNSPEC_FIX_NOTRUNC))]
8588 "TARGET_SSE"
8589 "%vcvtss2si<rex64suffix>\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
8590 [(set_attr "type" "sseicvt")
8591 (set_attr "athlon_decode" "double,vector")
8592 (set_attr "bdver1_decode" "double,double")
8593 (set_attr "prefix_rep" "1")
8594 (set_attr "prefix" "maybe_vex")
8595 (set_attr "mode" "<MODE>")])
8596
8597 (define_insn "sse_cvtss2si<rex64namesuffix>_2"
8598 [(set (match_operand:SWI48 0 "register_operand" "=r,r")
8599 (unspec:SWI48 [(match_operand:SF 1 "nonimmediate_operand" "v,m")]
8600 UNSPEC_FIX_NOTRUNC))]
8601 "TARGET_SSE"
8602 "%vcvtss2si<rex64suffix>\t{%1, %0|%0, %1}"
8603 [(set_attr "type" "sseicvt")
8604 (set_attr "athlon_decode" "double,vector")
8605 (set_attr "amdfam10_decode" "double,double")
8606 (set_attr "bdver1_decode" "double,double")
8607 (set_attr "prefix_rep" "1")
8608 (set_attr "prefix" "maybe_vex")
8609 (set_attr "mode" "<MODE>")])
8610
8611 (define_insn "unspec_sse_cvttss2si<rex64namesuffix><round_saeonly_name>"
8612 [(set (match_operand:SWI48 0 "register_operand" "=r,r")
8613 (unspec:SWI48
8614 [(match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint>")]
8615 UNSPEC_VCVTT))]
8616 "TARGET_SSE"
8617 "%vcvttss2si<rex64suffix>\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
8618 [(set_attr "type" "sseicvt")
8619 (set_attr "athlon_decode" "double,vector")
8620 (set_attr "amdfam10_decode" "double,double")
8621 (set_attr "bdver1_decode" "double,double")
8622 (set_attr "prefix_rep" "1")
8623 (set_attr "prefix" "maybe_vex")
8624 (set_attr "mode" "<MODE>")])
8625
8626 (define_insn "sse_cvttss2si<rex64namesuffix><round_saeonly_name>"
8627 [(set (match_operand:SWI48 0 "register_operand" "=r,r")
8628 (fix:SWI48
8629 (vec_select:SF
8630 (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint>")
8631 (parallel [(const_int 0)]))))]
8632 "TARGET_SSE"
8633 "%vcvttss2si<rex64suffix>\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
8634 [(set_attr "type" "sseicvt")
8635 (set_attr "athlon_decode" "double,vector")
8636 (set_attr "amdfam10_decode" "double,double")
8637 (set_attr "bdver1_decode" "double,double")
8638 (set_attr "prefix_rep" "1")
8639 (set_attr "prefix" "maybe_vex")
8640 (set_attr "mode" "<MODE>")])
8641
8642 (define_insn "cvtusi2<ssescalarmodesuffix>32<round_name>"
8643 [(set (match_operand:VF_128 0 "register_operand" "=v")
8644 (vec_merge:VF_128
8645 (vec_duplicate:VF_128
8646 (unsigned_float:<ssescalarmode>
8647 (match_operand:SI 2 "<round_nimm_scalar_predicate>" "<round_constraint3>")))
8648 (match_operand:VF_128 1 "register_operand" "v")
8649 (const_int 1)))]
8650 "TARGET_AVX512F && <round_modev4sf_condition>"
8651 "vcvtusi2<ssescalarmodesuffix>{l}\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
8652 [(set_attr "type" "sseicvt")
8653 (set_attr "prefix" "evex")
8654 (set_attr "mode" "<ssescalarmode>")])
8655
8656 (define_insn "cvtusi2<ssescalarmodesuffix>64<round_name>"
8657 [(set (match_operand:VF_128 0 "register_operand" "=v")
8658 (vec_merge:VF_128
8659 (vec_duplicate:VF_128
8660 (unsigned_float:<ssescalarmode>
8661 (match_operand:DI 2 "<round_nimm_scalar_predicate>" "<round_constraint3>")))
8662 (match_operand:VF_128 1 "register_operand" "v")
8663 (const_int 1)))]
8664 "TARGET_AVX512F && TARGET_64BIT"
8665 "vcvtusi2<ssescalarmodesuffix>{q}\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
8666 [(set_attr "type" "sseicvt")
8667 (set_attr "prefix" "evex")
8668 (set_attr "mode" "<ssescalarmode>")])
8669
8670 (define_insn "float<sseintvecmodelower><mode>2<mask_name><round_name>"
8671 [(set (match_operand:VF1 0 "register_operand" "=x,v")
8672 (float:VF1
8673 (match_operand:<sseintvecmode> 1 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
8674 "TARGET_SSE2 && <mask_mode512bit_condition> && <round_mode512bit_condition>"
8675 "@
8676 cvtdq2ps\t{%1, %0|%0, %1}
8677 vcvtdq2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
8678 [(set_attr "isa" "noavx,avx")
8679 (set_attr "type" "ssecvt")
8680 (set_attr "prefix" "maybe_vex")
8681 (set_attr "mode" "<sseinsnmode>")])
8682
8683 (define_insn "<mask_codefor>floatuns<sseintvecmodelower><mode>2<mask_name><round_name>"
8684 [(set (match_operand:VF1_AVX512VL 0 "register_operand" "=v")
8685 (unsigned_float:VF1_AVX512VL
8686 (match_operand:<sseintvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
8687 "TARGET_AVX512F"
8688 "vcvtudq2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
8689 [(set_attr "type" "ssecvt")
8690 (set_attr "prefix" "evex")
8691 (set_attr "mode" "<MODE>")])
8692
8693 (define_expand "floatuns<sseintvecmodelower><mode>2"
8694 [(set (match_operand:VF1 0 "register_operand")
8695 (unsigned_float:VF1
8696 (match_operand:<sseintvecmode> 1 "register_operand")))]
8697 "TARGET_SSE2 && (<MODE>mode == V4SFmode || TARGET_AVX2)"
8698 {
8699 if (<MODE>mode != V16SFmode && !TARGET_AVX512VL)
8700 {
8701 ix86_expand_vector_convert_uns_vsivsf (operands[0], operands[1]);
8702 DONE;
8703 }
8704 })
8705
8706
8707 ;; For <sse2_avx_avx512f>_fix_notrunc<sf2simodelower><mode> insn pattern
8708 (define_mode_attr sf2simodelower
8709 [(V16SI "v16sf") (V8SI "v8sf") (V4SI "v4sf")])
8710
8711 (define_insn "<sse2_avx_avx512f>_fix_notrunc<sf2simodelower><mode><mask_name>"
8712 [(set (match_operand:VI4_AVX 0 "register_operand" "=v")
8713 (unspec:VI4_AVX
8714 [(match_operand:<ssePSmode> 1 "vector_operand" "vBm")]
8715 UNSPEC_FIX_NOTRUNC))]
8716 "TARGET_SSE2 && <mask_mode512bit_condition>"
8717 "%vcvtps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
8718 [(set_attr "type" "ssecvt")
8719 (set (attr "prefix_data16")
8720 (if_then_else
8721 (match_test "TARGET_AVX")
8722 (const_string "*")
8723 (const_string "1")))
8724 (set_attr "prefix" "maybe_vex")
8725 (set_attr "mode" "<sseinsnmode>")])
8726
8727 (define_insn "avx512f_fix_notruncv16sfv16si<mask_name><round_name>"
8728 [(set (match_operand:V16SI 0 "register_operand" "=v")
8729 (unspec:V16SI
8730 [(match_operand:V16SF 1 "<round_nimm_predicate>" "<round_constraint>")]
8731 UNSPEC_FIX_NOTRUNC))]
8732 "TARGET_AVX512F && TARGET_EVEX512"
8733 "vcvtps2dq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
8734 [(set_attr "type" "ssecvt")
8735 (set_attr "prefix" "evex")
8736 (set_attr "mode" "XI")])
8737
8738 (define_insn "<mask_codefor><avx512>_fixuns_notrunc<sf2simodelower><mode><mask_name><round_name>"
8739 [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
8740 (unspec:VI4_AVX512VL
8741 [(match_operand:<ssePSmode> 1 "nonimmediate_operand" "<round_constraint>")]
8742 UNSPEC_UNSIGNED_FIX_NOTRUNC))]
8743 "TARGET_AVX512F"
8744 "vcvtps2udq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
8745 [(set_attr "type" "ssecvt")
8746 (set_attr "prefix" "evex")
8747 (set_attr "mode" "<sseinsnmode>")])
8748
8749 (define_insn "<mask_codefor>avx512dq_cvtps2qq<mode><mask_name><round_name>"
8750 [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
8751 (unspec:VI8_256_512 [(match_operand:<ssePSmode2> 1 "nonimmediate_operand" "<round_constraint>")]
8752 UNSPEC_FIX_NOTRUNC))]
8753 "TARGET_AVX512DQ && <round_mode512bit_condition>"
8754 "vcvtps2qq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
8755 [(set_attr "type" "ssecvt")
8756 (set_attr "prefix" "evex")
8757 (set_attr "mode" "<sseinsnmode>")])
8758
8759 (define_insn "<mask_codefor>avx512dq_cvtps2qqv2di<mask_name>"
8760 [(set (match_operand:V2DI 0 "register_operand" "=v")
8761 (unspec:V2DI
8762 [(vec_select:V2SF
8763 (match_operand:V4SF 1 "nonimmediate_operand" "vm")
8764 (parallel [(const_int 0) (const_int 1)]))]
8765 UNSPEC_FIX_NOTRUNC))]
8766 "TARGET_AVX512DQ && TARGET_AVX512VL"
8767 "vcvtps2qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
8768 [(set_attr "type" "ssecvt")
8769 (set_attr "prefix" "evex")
8770 (set_attr "mode" "TI")])
8771
8772 (define_insn "<mask_codefor>avx512dq_cvtps2uqq<mode><mask_name><round_name>"
8773 [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
8774 (unspec:VI8_256_512 [(match_operand:<ssePSmode2> 1 "nonimmediate_operand" "<round_constraint>")]
8775 UNSPEC_UNSIGNED_FIX_NOTRUNC))]
8776 "TARGET_AVX512DQ && <round_mode512bit_condition>"
8777 "vcvtps2uqq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
8778 [(set_attr "type" "ssecvt")
8779 (set_attr "prefix" "evex")
8780 (set_attr "mode" "<sseinsnmode>")])
8781
8782 (define_insn "<mask_codefor>avx512dq_cvtps2uqqv2di<mask_name>"
8783 [(set (match_operand:V2DI 0 "register_operand" "=v")
8784 (unspec:V2DI
8785 [(vec_select:V2SF
8786 (match_operand:V4SF 1 "nonimmediate_operand" "vm")
8787 (parallel [(const_int 0) (const_int 1)]))]
8788 UNSPEC_UNSIGNED_FIX_NOTRUNC))]
8789 "TARGET_AVX512DQ && TARGET_AVX512VL"
8790 "vcvtps2uqq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
8791 [(set_attr "type" "ssecvt")
8792 (set_attr "prefix" "evex")
8793 (set_attr "mode" "TI")])
8794
8795 (define_insn "unspec_fix<vcvtt_uns_suffix>_truncv16sfv16si2<mask_name><round_saeonly_name>"
8796 [(set (match_operand:V16SI 0 "register_operand" "=v")
8797 (unspec:V16SI
8798 [(match_operand:V16SF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
8799 UNSPEC_VCVTT_U))]
8800 "TARGET_AVX512F && TARGET_EVEX512"
8801 "vcvttps2<vcvtt_suffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
8802 [(set_attr "type" "ssecvt")
8803 (set_attr "prefix" "evex")
8804 (set_attr "mode" "XI")])
8805
8806 (define_insn "fix<fixunssuffix>_truncv16sfv16si2<mask_name><round_saeonly_name>"
8807 [(set (match_operand:V16SI 0 "register_operand" "=v")
8808 (any_fix:V16SI
8809 (match_operand:V16SF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
8810 "TARGET_AVX512F && TARGET_EVEX512"
8811 "vcvttps2<fixsuffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
8812 [(set_attr "type" "ssecvt")
8813 (set_attr "prefix" "evex")
8814 (set_attr "mode" "XI")])
8815
8816 (define_insn "unspec_fix_truncv8sfv8si2<mask_name>"
8817 [(set (match_operand:V8SI 0 "register_operand" "=v")
8818 (unspec:V8SI [(match_operand:V8SF 1 "nonimmediate_operand" "vm")]
8819 UNSPEC_VCVTT))]
8820 "TARGET_AVX && <mask_avx512vl_condition>"
8821 "vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
8822 [(set_attr "type" "ssecvt")
8823 (set_attr "prefix" "<mask_prefix>")
8824 (set_attr "mode" "OI")])
8825
8826 (define_insn "fix_truncv8sfv8si2<mask_name>"
8827 [(set (match_operand:V8SI 0 "register_operand" "=v")
8828 (fix:V8SI (match_operand:V8SF 1 "nonimmediate_operand" "vm")))]
8829 "TARGET_AVX && <mask_avx512vl_condition>"
8830 "vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
8831 [(set_attr "type" "ssecvt")
8832 (set_attr "prefix" "<mask_prefix>")
8833 (set_attr "mode" "OI")])
8834
8835 (define_insn "unspec_fix_truncv4sfv4si2<mask_name>"
8836 [(set (match_operand:V4SI 0 "register_operand" "=v")
8837 (unspec:V4SI [(match_operand:V4SF 1 "vector_operand" "vBm")]
8838 UNSPEC_VCVTT))]
8839 "TARGET_SSE2 && <mask_avx512vl_condition>"
8840 "%vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
8841 [(set_attr "type" "ssecvt")
8842 (set (attr "prefix_rep")
8843 (if_then_else
8844 (match_test "TARGET_AVX")
8845 (const_string "*")
8846 (const_string "1")))
8847 (set (attr "prefix_data16")
8848 (if_then_else
8849 (match_test "TARGET_AVX")
8850 (const_string "*")
8851 (const_string "0")))
8852 (set_attr "prefix_data16" "0")
8853 (set_attr "prefix" "<mask_prefix2>")
8854 (set_attr "mode" "TI")])
8855
8856 (define_insn "fix_truncv4sfv4si2<mask_name>"
8857 [(set (match_operand:V4SI 0 "register_operand" "=v")
8858 (fix:V4SI (match_operand:V4SF 1 "vector_operand" "vBm")))]
8859 "TARGET_SSE2 && <mask_avx512vl_condition>"
8860 "%vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
8861 [(set_attr "type" "ssecvt")
8862 (set (attr "prefix_rep")
8863 (if_then_else
8864 (match_test "TARGET_AVX")
8865 (const_string "*")
8866 (const_string "1")))
8867 (set (attr "prefix_data16")
8868 (if_then_else
8869 (match_test "TARGET_AVX")
8870 (const_string "*")
8871 (const_string "0")))
8872 (set_attr "prefix_data16" "0")
8873 (set_attr "prefix" "<mask_prefix2>")
8874 (set_attr "mode" "TI")])
8875
8876 (define_expand "fixuns_trunc<mode><sseintvecmodelower>2"
8877 [(set (match_operand:<sseintvecmode> 0 "register_operand")
8878 (unsigned_fix:<sseintvecmode>
8879 (match_operand:VF1_128_256 1 "register_operand")))]
8880 "TARGET_SSE2"
8881 {
8882 /* AVX512 support vcvttps2udq for all 128/256/512-bit vectors. */
8883 if (!TARGET_AVX512VL)
8884 {
8885 rtx tmp[3];
8886 tmp[0] = ix86_expand_adjust_ufix_to_sfix_si (operands[1], &tmp[2]);
8887 tmp[1] = gen_reg_rtx (<sseintvecmode>mode);
8888 emit_insn (gen_fix_trunc<mode><sseintvecmodelower>2 (tmp[1], tmp[0]));
8889 emit_insn (gen_xor<sseintvecmodelower>3 (operands[0], tmp[1], tmp[2]));
8890 DONE;
8891 }
8892 })
8893
8894 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8895 ;;
8896 ;; Parallel double-precision floating point conversion operations
8897 ;;
8898 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8899
8900 (define_insn "sse2_cvtpi2pd"
8901 [(set (match_operand:V2DF 0 "register_operand" "=v,?!x")
8902 (float:V2DF (match_operand:V2SI 1 "nonimmediate_operand" "vBm,yBm")))]
8903 "TARGET_SSE2"
8904 "@
8905 %vcvtdq2pd\t{%1, %0|%0, %1}
8906 cvtpi2pd\t{%1, %0|%0, %1}"
8907 [(set_attr "mmx_isa" "*,native")
8908 (set_attr "type" "ssecvt")
8909 (set_attr "unit" "*,mmx")
8910 (set_attr "prefix_data16" "*,1")
8911 (set_attr "prefix" "maybe_vex,*")
8912 (set_attr "mode" "V2DF")])
8913
8914 (define_expand "floatv2siv2df2"
8915 [(set (match_operand:V2DF 0 "register_operand")
8916 (float:V2DF (match_operand:V2SI 1 "nonimmediate_operand")))]
8917 "TARGET_MMX_WITH_SSE")
8918
8919 (define_insn "floatunsv2siv2df2"
8920 [(set (match_operand:V2DF 0 "register_operand" "=v")
8921 (unsigned_float:V2DF
8922 (match_operand:V2SI 1 "nonimmediate_operand" "vm")))]
8923 "TARGET_MMX_WITH_SSE && TARGET_AVX512VL"
8924 "vcvtudq2pd\t{%1, %0|%0, %1}"
8925 [(set_attr "type" "ssecvt")
8926 (set_attr "prefix" "evex")
8927 (set_attr "mode" "V2DF")])
8928
8929 (define_insn "sse2_cvtpd2pi"
8930 [(set (match_operand:V2SI 0 "register_operand" "=v,?!y")
8931 (unspec:V2SI [(match_operand:V2DF 1 "vector_operand" "vBm,xBm")]
8932 UNSPEC_FIX_NOTRUNC))]
8933 "TARGET_SSE2"
8934 "@
8935 * return TARGET_AVX ? \"vcvtpd2dq{x}\t{%1, %0|%0, %1}\" : \"cvtpd2dq\t{%1, %0|%0, %1}\";
8936 cvtpd2pi\t{%1, %0|%0, %1}"
8937 [(set_attr "mmx_isa" "*,native")
8938 (set_attr "type" "ssecvt")
8939 (set_attr "unit" "*,mmx")
8940 (set_attr "amdfam10_decode" "double")
8941 (set_attr "athlon_decode" "vector")
8942 (set_attr "bdver1_decode" "double")
8943 (set_attr "prefix_data16" "*,1")
8944 (set_attr "prefix" "maybe_vex,*")
8945 (set_attr "mode" "TI")])
8946
8947 (define_insn "unspec_sse2_cvttpd2pi"
8948 [(set (match_operand:V2SI 0 "register_operand" "=v,?!y")
8949 (unspec:V2SI [(match_operand:V2DF 1 "vector_operand" "vBm,xBm")]
8950 UNSPEC_VCVTT))]
8951 "TARGET_SSE2"
8952 "@
8953 * return TARGET_AVX ? \"vcvttpd2dq{x}\t{%1, %0|%0, %1}\" : \"cvttpd2dq\t{%1, %0|%0, %1}\";
8954 cvttpd2pi\t{%1, %0|%0, %1}"
8955 [(set_attr "mmx_isa" "*,native")
8956 (set_attr "type" "ssecvt")
8957 (set_attr "unit" "*,mmx")
8958 (set_attr "amdfam10_decode" "double")
8959 (set_attr "athlon_decode" "vector")
8960 (set_attr "bdver1_decode" "double")
8961 (set_attr "prefix_data16" "*,1")
8962 (set_attr "prefix" "maybe_vex,*")
8963 (set_attr "mode" "TI")])
8964
8965 (define_insn "sse2_cvttpd2pi"
8966 [(set (match_operand:V2SI 0 "register_operand" "=v,?!y")
8967 (fix:V2SI (match_operand:V2DF 1 "vector_operand" "vBm,xBm")))]
8968 "TARGET_SSE2"
8969 "@
8970 * return TARGET_AVX ? \"vcvttpd2dq{x}\t{%1, %0|%0, %1}\" : \"cvttpd2dq\t{%1, %0|%0, %1}\";
8971 cvttpd2pi\t{%1, %0|%0, %1}"
8972 [(set_attr "mmx_isa" "*,native")
8973 (set_attr "type" "ssecvt")
8974 (set_attr "unit" "*,mmx")
8975 (set_attr "amdfam10_decode" "double")
8976 (set_attr "athlon_decode" "vector")
8977 (set_attr "bdver1_decode" "double")
8978 (set_attr "prefix_data16" "*,1")
8979 (set_attr "prefix" "maybe_vex,*")
8980 (set_attr "mode" "TI")])
8981
8982 (define_expand "fix_truncv2dfv2si2"
8983 [(set (match_operand:V2SI 0 "register_operand")
8984 (fix:V2SI (match_operand:V2DF 1 "vector_operand")))]
8985 "TARGET_MMX_WITH_SSE")
8986
8987 (define_insn "unspec_fixuns_truncv2dfv2si2"
8988 [(set (match_operand:V2SI 0 "register_operand" "=v")
8989 (unspec:V2SI
8990 [(match_operand:V2DF 1 "nonimmediate_operand" "vm")]
8991 UNSPEC_VCVTTU))]
8992 "TARGET_MMX_WITH_SSE && TARGET_AVX512VL"
8993 "vcvttpd2udq{x}\t{%1, %0|%0, %1}"
8994 [(set_attr "type" "ssecvt")
8995 (set_attr "prefix" "evex")
8996 (set_attr "mode" "TI")])
8997
8998 (define_insn "fixuns_truncv2dfv2si2"
8999 [(set (match_operand:V2SI 0 "register_operand" "=v")
9000 (unsigned_fix:V2SI
9001 (match_operand:V2DF 1 "nonimmediate_operand" "vm")))]
9002 "TARGET_MMX_WITH_SSE && TARGET_AVX512VL"
9003 "vcvttpd2udq{x}\t{%1, %0|%0, %1}"
9004 [(set_attr "type" "ssecvt")
9005 (set_attr "prefix" "evex")
9006 (set_attr "mode" "TI")])
9007
9008 (define_insn "sse2_cvtsi2sd"
9009 [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
9010 (vec_merge:V2DF
9011 (vec_duplicate:V2DF
9012 (float:DF (match_operand:SI 2 "nonimmediate_operand" "r,m,rm")))
9013 (match_operand:V2DF 1 "register_operand" "0,0,v")
9014 (const_int 1)))]
9015 "TARGET_SSE2"
9016 "@
9017 cvtsi2sd{l}\t{%2, %0|%0, %2}
9018 cvtsi2sd{l}\t{%2, %0|%0, %2}
9019 vcvtsi2sd{l}\t{%2, %1, %0|%0, %1, %2}"
9020 [(set_attr "isa" "noavx,noavx,avx")
9021 (set_attr "type" "sseicvt2")
9022 (set_attr "athlon_decode" "double,direct,*")
9023 (set_attr "amdfam10_decode" "vector,double,*")
9024 (set_attr "bdver1_decode" "double,direct,*")
9025 (set_attr "btver2_decode" "double,double,double")
9026 (set_attr "znver1_decode" "double,double,double")
9027 (set_attr "c86_decode" "double,double,double")
9028 (set_attr "prefix" "orig,orig,maybe_evex")
9029 (set_attr "mode" "DF")])
9030
9031 (define_insn "sse2_cvtsi2sdq<round_name>"
9032 [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
9033 (vec_merge:V2DF
9034 (vec_duplicate:V2DF
9035 (float:DF (match_operand:DI 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
9036 (match_operand:V2DF 1 "register_operand" "0,0,v")
9037 (const_int 1)))]
9038 "TARGET_SSE2 && TARGET_64BIT"
9039 "@
9040 cvtsi2sd{q}\t{%2, %0|%0, %2}
9041 cvtsi2sd{q}\t{%2, %0|%0, %2}
9042 vcvtsi2sd{q}\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
9043 [(set_attr "isa" "noavx,noavx,avx")
9044 (set_attr "type" "sseicvt2")
9045 (set_attr "athlon_decode" "double,direct,*")
9046 (set_attr "amdfam10_decode" "vector,double,*")
9047 (set_attr "bdver1_decode" "double,direct,*")
9048 (set_attr "length_vex" "*,*,4")
9049 (set_attr "prefix_rex" "1,1,*")
9050 (set_attr "prefix" "orig,orig,maybe_evex")
9051 (set_attr "mode" "DF")])
9052
9053 (define_insn "avx512f_vcvtss2usi<rex64namesuffix><round_name>"
9054 [(set (match_operand:SWI48 0 "register_operand" "=r")
9055 (unspec:SWI48
9056 [(vec_select:SF
9057 (match_operand:V4SF 1 "<round_nimm_predicate>" "<round_constraint>")
9058 (parallel [(const_int 0)]))]
9059 UNSPEC_UNSIGNED_FIX_NOTRUNC))]
9060 "TARGET_AVX512F"
9061 "vcvtss2usi\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
9062 [(set_attr "type" "sseicvt")
9063 (set_attr "prefix" "evex")
9064 (set_attr "mode" "<MODE>")])
9065
9066 (define_insn "unspec_avx512f_vcvttss2usi<rex64namesuffix><round_saeonly_name>"
9067 [(set (match_operand:SWI48 0 "register_operand" "=r")
9068 (unspec:SWI48
9069 [(match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")]
9070 UNSPEC_VCVTTU))]
9071 "TARGET_AVX512F"
9072 "vcvttss2usi\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
9073 [(set_attr "type" "sseicvt")
9074 (set_attr "prefix" "evex")
9075 (set_attr "mode" "<MODE>")])
9076
9077 (define_insn "avx512f_vcvttss2usi<rex64namesuffix><round_saeonly_name>"
9078 [(set (match_operand:SWI48 0 "register_operand" "=r")
9079 (unsigned_fix:SWI48
9080 (vec_select:SF
9081 (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
9082 (parallel [(const_int 0)]))))]
9083 "TARGET_AVX512F"
9084 "vcvttss2usi\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
9085 [(set_attr "type" "sseicvt")
9086 (set_attr "prefix" "evex")
9087 (set_attr "mode" "<MODE>")])
9088
9089 (define_insn "avx512f_vcvtsd2usi<rex64namesuffix><round_name>"
9090 [(set (match_operand:SWI48 0 "register_operand" "=r")
9091 (unspec:SWI48
9092 [(vec_select:DF
9093 (match_operand:V2DF 1 "<round_nimm_predicate>" "<round_constraint>")
9094 (parallel [(const_int 0)]))]
9095 UNSPEC_UNSIGNED_FIX_NOTRUNC))]
9096 "TARGET_AVX512F"
9097 "vcvtsd2usi\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
9098 [(set_attr "type" "sseicvt")
9099 (set_attr "prefix" "evex")
9100 (set_attr "mode" "<MODE>")])
9101
9102 (define_insn "unspec_avx512f_vcvttsd2usi<rex64namesuffix><round_saeonly_name>"
9103 [(set (match_operand:SWI48 0 "register_operand" "=r")
9104 (unspec:SWI48
9105 [(match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")]
9106 UNSPEC_VCVTTU))]
9107 "TARGET_AVX512F"
9108 "vcvttsd2usi\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
9109 [(set_attr "type" "sseicvt")
9110 (set_attr "prefix" "evex")
9111 (set_attr "mode" "<MODE>")])
9112
9113 (define_insn "avx512f_vcvttsd2usi<rex64namesuffix><round_saeonly_name>"
9114 [(set (match_operand:SWI48 0 "register_operand" "=r")
9115 (unsigned_fix:SWI48
9116 (vec_select:DF
9117 (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
9118 (parallel [(const_int 0)]))))]
9119 "TARGET_AVX512F"
9120 "vcvttsd2usi\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
9121 [(set_attr "type" "sseicvt")
9122 (set_attr "prefix" "evex")
9123 (set_attr "mode" "<MODE>")])
9124
9125 (define_insn "sse2_cvtsd2si<rex64namesuffix><round_name>"
9126 [(set (match_operand:SWI48 0 "register_operand" "=r,r")
9127 (unspec:SWI48
9128 [(vec_select:DF
9129 (match_operand:V2DF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
9130 (parallel [(const_int 0)]))]
9131 UNSPEC_FIX_NOTRUNC))]
9132 "TARGET_SSE2"
9133 "%vcvtsd2si<rex64suffix>\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
9134 [(set_attr "type" "sseicvt")
9135 (set_attr "athlon_decode" "double,vector")
9136 (set_attr "bdver1_decode" "double,double")
9137 (set_attr "btver2_decode" "double,double")
9138 (set_attr "prefix_rep" "1")
9139 (set_attr "prefix" "maybe_vex")
9140 (set_attr "mode" "<MODE>")])
9141
9142 (define_insn "sse2_cvtsd2si<rex64namesuffix>_2"
9143 [(set (match_operand:SWI48 0 "register_operand" "=r,r")
9144 (unspec:SWI48 [(match_operand:DF 1 "nonimmediate_operand" "v,m")]
9145 UNSPEC_FIX_NOTRUNC))]
9146 "TARGET_SSE2"
9147 "%vcvtsd2si<rex64suffix>\t{%1, %0|%0, %q1}"
9148 [(set_attr "type" "sseicvt")
9149 (set_attr "athlon_decode" "double,vector")
9150 (set_attr "amdfam10_decode" "double,double")
9151 (set_attr "bdver1_decode" "double,double")
9152 (set_attr "prefix_rep" "1")
9153 (set_attr "prefix" "maybe_vex")
9154 (set_attr "mode" "<MODE>")])
9155
9156 (define_insn "unspec_sse2_cvttsd2si<rex64namesuffix><round_saeonly_name>"
9157 [(set (match_operand:SWI48 0 "register_operand" "=r,r")
9158 (unspec:SWI48
9159 [(match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint2>")]
9160 UNSPEC_VCVTT))]
9161 "TARGET_SSE2"
9162 "%vcvttsd2si<rex64suffix>\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
9163 [(set_attr "type" "sseicvt")
9164 (set_attr "athlon_decode" "double,vector")
9165 (set_attr "amdfam10_decode" "double,double")
9166 (set_attr "bdver1_decode" "double,double")
9167 (set_attr "btver2_decode" "double,double")
9168 (set_attr "prefix_rep" "1")
9169 (set_attr "prefix" "maybe_vex")
9170 (set_attr "mode" "<MODE>")])
9171
9172 (define_insn "sse2_cvttsd2si<rex64namesuffix><round_saeonly_name>"
9173 [(set (match_operand:SWI48 0 "register_operand" "=r,r")
9174 (fix:SWI48
9175 (vec_select:DF
9176 (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint2>")
9177 (parallel [(const_int 0)]))))]
9178 "TARGET_SSE2"
9179 "%vcvttsd2si<rex64suffix>\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
9180 [(set_attr "type" "sseicvt")
9181 (set_attr "athlon_decode" "double,vector")
9182 (set_attr "amdfam10_decode" "double,double")
9183 (set_attr "bdver1_decode" "double,double")
9184 (set_attr "btver2_decode" "double,double")
9185 (set_attr "prefix_rep" "1")
9186 (set_attr "prefix" "maybe_vex")
9187 (set_attr "mode" "<MODE>")])
9188
9189 ;; For float<si2dfmode><mode>2 insn pattern
9190 (define_mode_attr si2dfmode
9191 [(V8DF "V8SI") (V4DF "V4SI")])
9192 (define_mode_attr si2dfmodelower
9193 [(V8DF "v8si") (V4DF "v4si")])
9194
9195 (define_insn "float<si2dfmodelower><mode>2<mask_name>"
9196 [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
9197 (float:VF2_512_256 (match_operand:<si2dfmode> 1 "nonimmediate_operand" "vm")))]
9198 "TARGET_AVX && <mask_mode512bit_condition>"
9199 "vcvtdq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
9200 [(set_attr "type" "ssecvt")
9201 (set_attr "prefix" "maybe_vex")
9202 (set_attr "mode" "<MODE>")])
9203
9204 (define_insn "float<floatunssuffix><sseintvecmodelower><mode>2<mask_name><round_name>"
9205 [(set (match_operand:VF2_AVX512VL 0 "register_operand" "=v")
9206 (any_float:VF2_AVX512VL
9207 (match_operand:<sseintvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
9208 "TARGET_AVX512DQ"
9209 "vcvt<floatsuffix>qq2pd\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
9210 [(set_attr "type" "ssecvt")
9211 (set_attr "prefix" "evex")
9212 (set_attr "mode" "<MODE>")])
9213
9214 ;; For float<floatunssuffix><sselondveclower><mode> insn patterns
9215 (define_mode_attr qq2pssuff
9216 [(V8DI "") (V4DI "{y}")])
9217
9218 (define_insn "float<floatunssuffix><mode><ssePSmode2lower>2<mask_name><round_name>"
9219 [(set (match_operand:<ssePSmode2> 0 "register_operand" "=v")
9220 (any_float:<ssePSmode2>
9221 (match_operand:VI8_256_512 1 "nonimmediate_operand" "<round_constraint>")))]
9222 "TARGET_AVX512DQ && <round_mode512bit_condition>"
9223 "vcvt<floatsuffix>qq2ps<qq2pssuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
9224 [(set_attr "type" "ssecvt")
9225 (set_attr "prefix" "evex")
9226 (set_attr "mode" "<sseinsnmode>")])
9227
9228 (define_expand "avx512dq_float<floatunssuffix>v2div2sf2"
9229 [(set (match_operand:V4SF 0 "register_operand" "=v")
9230 (vec_concat:V4SF
9231 (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
9232 (match_dup 2)))]
9233 "TARGET_AVX512DQ && TARGET_AVX512VL"
9234 "operands[2] = CONST0_RTX (V2SFmode);")
9235
9236 (define_insn "*avx512dq_float<floatunssuffix>v2div2sf2"
9237 [(set (match_operand:V4SF 0 "register_operand" "=v")
9238 (vec_concat:V4SF
9239 (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
9240 (match_operand:V2SF 2 "const0_operand")))]
9241 "TARGET_AVX512DQ && TARGET_AVX512VL"
9242 "vcvt<floatsuffix>qq2ps{x}\t{%1, %0|%0, %1}"
9243 [(set_attr "type" "ssecvt")
9244 (set_attr "prefix" "evex")
9245 (set_attr "mode" "V4SF")])
9246
9247 (define_expand "float<floatunssuffix>v2div2sf2"
9248 [(set (match_operand:V2SF 0 "register_operand")
9249 (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand")))]
9250 "TARGET_AVX512DQ && TARGET_AVX512VL"
9251 {
9252 rtx op0 = gen_reg_rtx (V4SFmode);
9253
9254 emit_insn (gen_avx512dq_float<floatunssuffix>v2div2sf2
9255 (op0, operands[1]));
9256
9257 emit_move_insn (operands[0], lowpart_subreg (V2SFmode, op0, V4SFmode));
9258 DONE;
9259 })
9260
9261 (define_mode_attr vpckfloat_concat_mode
9262 [(V8DI "v16sf") (V4DI "v8sf") (V2DI "v8sf")
9263 (V16SI "v32hf") (V8SI "v16hf") (V4SI "v16hf")
9264 (V16SF "v32hf") (V8SF "v16hf") (V4SF "v16hf")])
9265 (define_mode_attr vpckfloat_temp_mode
9266 [(V8DI "V8SF") (V4DI "V4SF") (V2DI "V4SF")
9267 (V16SI "V16HF") (V8SI "V8HF") (V4SI "V8HF")
9268 (V16SF "V16HF") (V8SF "V8HF") (V4SF "V8HF")])
9269 (define_mode_attr vpckfloat_op_mode
9270 [(V8DI "v8sf") (V4DI "v4sf") (V2DI "v2sf")
9271 (V16SI "v16hf") (V8SI "v8hf") (V4SI "v4hf")
9272 (V16SF "v16hf") (V8SF "v8hf") (V4SF "v4hf")])
9273
9274 (define_expand "vec_pack<floatprefix>_float_<mode>"
9275 [(match_operand:<ssePSmode> 0 "register_operand")
9276 (any_float:<ssePSmode>
9277 (match_operand:VI8_AVX512VL 1 "register_operand"))
9278 (match_operand:VI8_AVX512VL 2 "register_operand")]
9279 "TARGET_AVX512DQ"
9280 {
9281 rtx r1 = gen_reg_rtx (<vpckfloat_temp_mode>mode);
9282 rtx r2 = gen_reg_rtx (<vpckfloat_temp_mode>mode);
9283 rtx (*gen) (rtx, rtx);
9284
9285 if (<MODE>mode == V2DImode)
9286 gen = gen_avx512dq_float<floatunssuffix>v2div2sf2;
9287 else
9288 gen = gen_float<floatunssuffix><mode><vpckfloat_op_mode>2;
9289 emit_insn (gen (r1, operands[1]));
9290 emit_insn (gen (r2, operands[2]));
9291 if (<MODE>mode == V2DImode)
9292 emit_insn (gen_sse_movlhps (operands[0], r1, r2));
9293 else
9294 emit_insn (gen_avx_vec_concat<vpckfloat_concat_mode> (operands[0],
9295 r1, r2));
9296 DONE;
9297 })
9298
9299 (define_expand "vec_pack<floatprefix>_float_<mode>"
9300 [(match_operand:<ssepackPHmode> 0 "register_operand")
9301 (any_float:<ssepackPHmode>
9302 (match_operand:VI4_AVX512VL 1 "register_operand"))
9303 (match_operand:VI4_AVX512VL 2 "register_operand")]
9304 "TARGET_AVX512FP16"
9305 {
9306 rtx r1 = gen_reg_rtx (<vpckfloat_temp_mode>mode);
9307 rtx r2 = gen_reg_rtx (<vpckfloat_temp_mode>mode);
9308 rtx (*gen) (rtx, rtx);
9309
9310 if (<MODE>mode == V4SImode)
9311 gen = gen_avx512fp16_float<floatunssuffix>v4siv4hf2;
9312 else
9313 gen = gen_float<floatunssuffix><mode><vpckfloat_op_mode>2;
9314 emit_insn (gen (r1, operands[1]));
9315 emit_insn (gen (r2, operands[2]));
9316 if (<MODE>mode == V4SImode)
9317 emit_insn (gen_sse_movlhps_v8hf (operands[0], r1, r2));
9318 else
9319 emit_insn (gen_avx_vec_concat<vpckfloat_concat_mode> (operands[0],
9320 r1, r2));
9321 DONE;
9322 })
9323
9324 (define_expand "float<floatunssuffix>v2div2sf2_mask"
9325 [(set (match_operand:V4SF 0 "register_operand" "=v")
9326 (vec_concat:V4SF
9327 (vec_merge:V2SF
9328 (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
9329 (vec_select:V2SF
9330 (match_operand:V4SF 2 "nonimm_or_0_operand" "0C")
9331 (parallel [(const_int 0) (const_int 1)]))
9332 (match_operand:QI 3 "register_operand" "Yk"))
9333 (match_dup 4)))]
9334 "TARGET_AVX512DQ && TARGET_AVX512VL"
9335 "operands[4] = CONST0_RTX (V2SFmode);")
9336
9337 (define_insn "*float<floatunssuffix>v2div2sf2_mask"
9338 [(set (match_operand:V4SF 0 "register_operand" "=v")
9339 (vec_concat:V4SF
9340 (vec_merge:V2SF
9341 (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
9342 (vec_select:V2SF
9343 (match_operand:V4SF 2 "nonimm_or_0_operand" "0C")
9344 (parallel [(const_int 0) (const_int 1)]))
9345 (match_operand:QI 3 "register_operand" "Yk"))
9346 (match_operand:V2SF 4 "const0_operand")))]
9347 "TARGET_AVX512DQ && TARGET_AVX512VL"
9348 "vcvt<floatsuffix>qq2ps{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9349 [(set_attr "type" "ssecvt")
9350 (set_attr "prefix" "evex")
9351 (set_attr "mode" "V4SF")])
9352
9353 (define_insn "*float<floatunssuffix>v2div2sf2_mask_1"
9354 [(set (match_operand:V4SF 0 "register_operand" "=v")
9355 (vec_concat:V4SF
9356 (vec_merge:V2SF
9357 (any_float:V2SF (match_operand:V2DI 1
9358 "nonimmediate_operand" "vm"))
9359 (match_operand:V2SF 3 "const0_operand")
9360 (match_operand:QI 2 "register_operand" "Yk"))
9361 (match_operand:V2SF 4 "const0_operand")))]
9362 "TARGET_AVX512DQ && TARGET_AVX512VL"
9363 "vcvt<floatsuffix>qq2ps{x}\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9364 [(set_attr "type" "ssecvt")
9365 (set_attr "prefix" "evex")
9366 (set_attr "mode" "V4SF")])
9367
9368 (define_insn "floatuns<si2dfmodelower><mode>2<mask_name>"
9369 [(set (match_operand:VF2_512_256VL 0 "register_operand" "=v")
9370 (unsigned_float:VF2_512_256VL
9371 (match_operand:<si2dfmode> 1 "nonimmediate_operand" "vm")))]
9372 "TARGET_AVX512F"
9373 "vcvtudq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
9374 [(set_attr "type" "ssecvt")
9375 (set_attr "prefix" "evex")
9376 (set_attr "mode" "<MODE>")])
9377
9378 (define_insn "<mask_codefor>floatunsv2siv2df2<mask_name>"
9379 [(set (match_operand:V2DF 0 "register_operand" "=v")
9380 (unsigned_float:V2DF
9381 (vec_select:V2SI
9382 (match_operand:V4SI 1 "nonimmediate_operand" "vm")
9383 (parallel [(const_int 0) (const_int 1)]))))]
9384 "TARGET_AVX512VL"
9385 "vcvtudq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
9386 [(set_attr "type" "ssecvt")
9387 (set_attr "prefix" "evex")
9388 (set_attr "mode" "V2DF")])
9389
9390 (define_insn "avx512f_cvtdq2pd512_2"
9391 [(set (match_operand:V8DF 0 "register_operand" "=v")
9392 (float:V8DF
9393 (vec_select:V8SI
9394 (match_operand:V16SI 1 "nonimmediate_operand" "vm")
9395 (parallel [(const_int 0) (const_int 1)
9396 (const_int 2) (const_int 3)
9397 (const_int 4) (const_int 5)
9398 (const_int 6) (const_int 7)]))))]
9399 "TARGET_AVX512F && TARGET_EVEX512"
9400 "vcvtdq2pd\t{%t1, %0|%0, %t1}"
9401 [(set_attr "type" "ssecvt")
9402 (set_attr "prefix" "evex")
9403 (set_attr "mode" "V8DF")])
9404
9405 (define_insn "avx_cvtdq2pd256_2"
9406 [(set (match_operand:V4DF 0 "register_operand" "=v")
9407 (float:V4DF
9408 (vec_select:V4SI
9409 (match_operand:V8SI 1 "nonimmediate_operand" "vm")
9410 (parallel [(const_int 0) (const_int 1)
9411 (const_int 2) (const_int 3)]))))]
9412 "TARGET_AVX"
9413 "vcvtdq2pd\t{%x1, %0|%0, %x1}"
9414 [(set_attr "type" "ssecvt")
9415 (set_attr "prefix" "maybe_evex")
9416 (set_attr "mode" "V4DF")])
9417
9418 (define_insn "sse2_cvtdq2pd<mask_name>"
9419 [(set (match_operand:V2DF 0 "register_operand" "=v")
9420 (float:V2DF
9421 (vec_select:V2SI
9422 (match_operand:V4SI 1 "nonimmediate_operand" "vm")
9423 (parallel [(const_int 0) (const_int 1)]))))]
9424 "TARGET_SSE2 && <mask_avx512vl_condition>"
9425 "%vcvtdq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
9426 [(set_attr "type" "ssecvt")
9427 (set_attr "prefix" "maybe_vex")
9428 (set_attr "mode" "V2DF")])
9429
9430 (define_insn "avx512f_cvtpd2dq512<mask_name><round_name>"
9431 [(set (match_operand:V8SI 0 "register_operand" "=v")
9432 (unspec:V8SI
9433 [(match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")]
9434 UNSPEC_FIX_NOTRUNC))]
9435 "TARGET_AVX512F && TARGET_EVEX512"
9436 "vcvtpd2dq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
9437 [(set_attr "type" "ssecvt")
9438 (set_attr "prefix" "evex")
9439 (set_attr "mode" "OI")])
9440
9441 (define_insn "avx_cvtpd2dq256<mask_name>"
9442 [(set (match_operand:V4SI 0 "register_operand" "=v")
9443 (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")]
9444 UNSPEC_FIX_NOTRUNC))]
9445 "TARGET_AVX && <mask_avx512vl_condition>"
9446 "vcvtpd2dq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
9447 [(set_attr "type" "ssecvt")
9448 (set_attr "prefix" "<mask_prefix>")
9449 (set_attr "mode" "OI")])
9450
9451 (define_expand "avx_cvtpd2dq256_2"
9452 [(set (match_operand:V8SI 0 "register_operand")
9453 (vec_concat:V8SI
9454 (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand")]
9455 UNSPEC_FIX_NOTRUNC)
9456 (match_dup 2)))]
9457 "TARGET_AVX"
9458 "operands[2] = CONST0_RTX (V4SImode);")
9459
9460 (define_insn "*avx_cvtpd2dq256_2"
9461 [(set (match_operand:V8SI 0 "register_operand" "=v")
9462 (vec_concat:V8SI
9463 (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")]
9464 UNSPEC_FIX_NOTRUNC)
9465 (match_operand:V4SI 2 "const0_operand")))]
9466 "TARGET_AVX"
9467 "vcvtpd2dq{y}\t{%1, %x0|%x0, %1}"
9468 [(set_attr "type" "ssecvt")
9469 (set_attr "prefix" "vex")
9470 (set_attr "btver2_decode" "vector")
9471 (set_attr "mode" "OI")])
9472
9473 (define_insn "sse2_cvtpd2dq"
9474 [(set (match_operand:V4SI 0 "register_operand" "=v")
9475 (vec_concat:V4SI
9476 (unspec:V2SI [(match_operand:V2DF 1 "vector_operand" "vBm")]
9477 UNSPEC_FIX_NOTRUNC)
9478 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9479 "TARGET_SSE2"
9480 {
9481 if (TARGET_AVX)
9482 return "vcvtpd2dq{x}\t{%1, %0|%0, %1}";
9483 else
9484 return "cvtpd2dq\t{%1, %0|%0, %1}";
9485 }
9486 [(set_attr "type" "ssecvt")
9487 (set_attr "prefix_rep" "1")
9488 (set_attr "prefix_data16" "0")
9489 (set_attr "prefix" "maybe_vex")
9490 (set_attr "mode" "TI")
9491 (set_attr "amdfam10_decode" "double")
9492 (set_attr "athlon_decode" "vector")
9493 (set_attr "bdver1_decode" "double")])
9494
9495 (define_insn "sse2_cvtpd2dq_mask"
9496 [(set (match_operand:V4SI 0 "register_operand" "=v")
9497 (vec_concat:V4SI
9498 (vec_merge:V2SI
9499 (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "vm")]
9500 UNSPEC_FIX_NOTRUNC)
9501 (vec_select:V2SI
9502 (match_operand:V4SI 2 "nonimm_or_0_operand" "0C")
9503 (parallel [(const_int 0) (const_int 1)]))
9504 (match_operand:QI 3 "register_operand" "Yk"))
9505 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9506 "TARGET_AVX512VL"
9507 "vcvtpd2dq{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9508 [(set_attr "type" "ssecvt")
9509 (set_attr "prefix" "evex")
9510 (set_attr "mode" "TI")])
9511
9512 (define_insn "*sse2_cvtpd2dq_mask_1"
9513 [(set (match_operand:V4SI 0 "register_operand" "=v")
9514 (vec_concat:V4SI
9515 (vec_merge:V2SI
9516 (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "vm")]
9517 UNSPEC_FIX_NOTRUNC)
9518 (const_vector:V2SI [(const_int 0) (const_int 0)])
9519 (match_operand:QI 2 "register_operand" "Yk"))
9520 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9521 "TARGET_AVX512VL"
9522 "vcvtpd2dq{x}\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9523 [(set_attr "type" "ssecvt")
9524 (set_attr "prefix" "evex")
9525 (set_attr "mode" "TI")])
9526
9527 ;; For fixuns_notrunc* insn patterns
9528 (define_mode_attr pd2udqsuff
9529 [(V8DF "") (V4DF "{y}")])
9530
9531 (define_insn "fixuns_notrunc<mode><si2dfmodelower>2<mask_name><round_name>"
9532 [(set (match_operand:<si2dfmode> 0 "register_operand" "=v")
9533 (unspec:<si2dfmode>
9534 [(match_operand:VF2_512_256VL 1 "nonimmediate_operand" "<round_constraint>")]
9535 UNSPEC_UNSIGNED_FIX_NOTRUNC))]
9536 "TARGET_AVX512F"
9537 "vcvtpd2udq<pd2udqsuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
9538 [(set_attr "type" "ssecvt")
9539 (set_attr "prefix" "evex")
9540 (set_attr "mode" "<sseinsnmode>")])
9541
9542 (define_insn "fixuns_notruncv2dfv2si2"
9543 [(set (match_operand:V4SI 0 "register_operand" "=v")
9544 (vec_concat:V4SI
9545 (unspec:V2SI
9546 [(match_operand:V2DF 1 "nonimmediate_operand" "vm")]
9547 UNSPEC_UNSIGNED_FIX_NOTRUNC)
9548 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9549 "TARGET_AVX512VL"
9550 "vcvtpd2udq{x}\t{%1, %0|%0, %1}"
9551 [(set_attr "type" "ssecvt")
9552 (set_attr "prefix" "evex")
9553 (set_attr "mode" "TI")])
9554
9555 (define_insn "fixuns_notruncv2dfv2si2_mask"
9556 [(set (match_operand:V4SI 0 "register_operand" "=v")
9557 (vec_concat:V4SI
9558 (vec_merge:V2SI
9559 (unspec:V2SI
9560 [(match_operand:V2DF 1 "nonimmediate_operand" "vm")]
9561 UNSPEC_UNSIGNED_FIX_NOTRUNC)
9562 (vec_select:V2SI
9563 (match_operand:V4SI 2 "nonimm_or_0_operand" "0C")
9564 (parallel [(const_int 0) (const_int 1)]))
9565 (match_operand:QI 3 "register_operand" "Yk"))
9566 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9567 "TARGET_AVX512VL"
9568 "vcvtpd2udq{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9569 [(set_attr "type" "ssecvt")
9570 (set_attr "prefix" "evex")
9571 (set_attr "mode" "TI")])
9572
9573 (define_insn "*fixuns_notruncv2dfv2si2_mask_1"
9574 [(set (match_operand:V4SI 0 "register_operand" "=v")
9575 (vec_concat:V4SI
9576 (vec_merge:V2SI
9577 (unspec:V2SI
9578 [(match_operand:V2DF 1 "nonimmediate_operand" "vm")]
9579 UNSPEC_UNSIGNED_FIX_NOTRUNC)
9580 (const_vector:V2SI [(const_int 0) (const_int 0)])
9581 (match_operand:QI 2 "register_operand" "Yk"))
9582 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9583 "TARGET_AVX512VL"
9584 "vcvtpd2udq{x}\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9585 [(set_attr "type" "ssecvt")
9586 (set_attr "prefix" "evex")
9587 (set_attr "mode" "TI")])
9588
9589 (define_insn "unspec_fix<vcvtt_uns_suffix>_truncv8dfv8si2<mask_name><round_saeonly_name>"
9590 [(set (match_operand:V8SI 0 "register_operand" "=v")
9591 (unspec:V8SI
9592 [(match_operand:V8DF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
9593 UNSPEC_VCVTT_U))]
9594 "TARGET_AVX512F && TARGET_EVEX512"
9595 "vcvttpd2<vcvtt_suffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
9596 [(set_attr "type" "ssecvt")
9597 (set_attr "prefix" "evex")
9598 (set_attr "mode" "OI")])
9599
9600 (define_insn "fix<fixunssuffix>_truncv8dfv8si2<mask_name><round_saeonly_name>"
9601 [(set (match_operand:V8SI 0 "register_operand" "=v")
9602 (any_fix:V8SI
9603 (match_operand:V8DF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
9604 "TARGET_AVX512F && TARGET_EVEX512"
9605 "vcvttpd2<fixsuffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
9606 [(set_attr "type" "ssecvt")
9607 (set_attr "prefix" "evex")
9608 (set_attr "mode" "OI")])
9609
9610 (define_insn "*unspec_fixuns_truncv2dfv2si2"
9611 [(set (match_operand:V4SI 0 "register_operand" "=v")
9612 (vec_concat:V4SI
9613 (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "vm")]
9614 UNSPEC_VCVTTU)
9615 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9616 "TARGET_AVX512VL"
9617 "vcvttpd2udq{x}\t{%1, %0|%0, %1}"
9618 [(set_attr "type" "ssecvt")
9619 (set_attr "prefix" "evex")
9620 (set_attr "mode" "TI")])
9621
9622 (define_insn "*fixuns_truncv2dfv2si2"
9623 [(set (match_operand:V4SI 0 "register_operand" "=v")
9624 (vec_concat:V4SI
9625 (unsigned_fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "vm"))
9626 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9627 "TARGET_AVX512VL"
9628 "vcvttpd2udq{x}\t{%1, %0|%0, %1}"
9629 [(set_attr "type" "ssecvt")
9630 (set_attr "prefix" "evex")
9631 (set_attr "mode" "TI")])
9632
9633 (define_insn "unspec_fixuns_truncv2dfv2si2_mask"
9634 [(set (match_operand:V4SI 0 "register_operand" "=v")
9635 (vec_concat:V4SI
9636 (vec_merge:V2SI
9637 (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "vm")]
9638 UNSPEC_VCVTTU)
9639 (vec_select:V2SI
9640 (match_operand:V4SI 2 "nonimm_or_0_operand" "0C")
9641 (parallel [(const_int 0) (const_int 1)]))
9642 (match_operand:QI 3 "register_operand" "Yk"))
9643 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9644 "TARGET_AVX512VL"
9645 "vcvttpd2udq{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9646 [(set_attr "type" "ssecvt")
9647 (set_attr "prefix" "evex")
9648 (set_attr "mode" "TI")])
9649
9650 (define_insn "fixuns_truncv2dfv2si2_mask"
9651 [(set (match_operand:V4SI 0 "register_operand" "=v")
9652 (vec_concat:V4SI
9653 (vec_merge:V2SI
9654 (unsigned_fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "vm"))
9655 (vec_select:V2SI
9656 (match_operand:V4SI 2 "nonimm_or_0_operand" "0C")
9657 (parallel [(const_int 0) (const_int 1)]))
9658 (match_operand:QI 3 "register_operand" "Yk"))
9659 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9660 "TARGET_AVX512VL"
9661 "vcvttpd2udq{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9662 [(set_attr "type" "ssecvt")
9663 (set_attr "prefix" "evex")
9664 (set_attr "mode" "TI")])
9665
9666 (define_insn "*fixuns_truncv2dfv2si2_mask_1"
9667 [(set (match_operand:V4SI 0 "register_operand" "=v")
9668 (vec_concat:V4SI
9669 (vec_merge:V2SI
9670 (unsigned_fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "vm"))
9671 (const_vector:V2SI [(const_int 0) (const_int 0)])
9672 (match_operand:QI 2 "register_operand" "Yk"))
9673 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9674 "TARGET_AVX512VL"
9675 "vcvttpd2udq{x}\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9676 [(set_attr "type" "ssecvt")
9677 (set_attr "prefix" "evex")
9678 (set_attr "mode" "TI")])
9679
9680 (define_insn "unspec_fix_truncv4dfv4si2<mask_name>"
9681 [(set (match_operand:V4SI 0 "register_operand" "=v")
9682 (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")]
9683 UNSPEC_VCVTT))]
9684 "TARGET_AVX || (TARGET_AVX512VL && TARGET_AVX512F)"
9685 "vcvttpd2dq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
9686 [(set_attr "type" "ssecvt")
9687 (set_attr "prefix" "maybe_evex")
9688 (set_attr "mode" "OI")])
9689
9690 (define_insn "fix_truncv4dfv4si2<mask_name>"
9691 [(set (match_operand:V4SI 0 "register_operand" "=v")
9692 (fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
9693 "TARGET_AVX || (TARGET_AVX512VL && TARGET_AVX512F)"
9694 "vcvttpd2dq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
9695 [(set_attr "type" "ssecvt")
9696 (set_attr "prefix" "maybe_evex")
9697 (set_attr "mode" "OI")])
9698
9699 (define_insn "unspec_fixuns_truncv4dfv4si2<mask_name>"
9700 [(set (match_operand:V4SI 0 "register_operand" "=v")
9701 (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")]
9702 UNSPEC_VCVTTU))]
9703 "TARGET_AVX512VL && TARGET_AVX512F"
9704 "vcvttpd2udq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
9705 [(set_attr "type" "ssecvt")
9706 (set_attr "prefix" "maybe_evex")
9707 (set_attr "mode" "OI")])
9708
9709 (define_insn "fixuns_truncv4dfv4si2<mask_name>"
9710 [(set (match_operand:V4SI 0 "register_operand" "=v")
9711 (unsigned_fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
9712 "TARGET_AVX512VL && TARGET_AVX512F"
9713 "vcvttpd2udq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
9714 [(set_attr "type" "ssecvt")
9715 (set_attr "prefix" "maybe_evex")
9716 (set_attr "mode" "OI")])
9717
9718 (define_insn "unspec_fix<vcvtt_uns_suffix>_trunc<mode><sseintvecmodelower>2<mask_name><round_saeonly_name>"
9719 [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
9720 (unspec:<sseintvecmode>
9721 [(match_operand:VF2_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
9722 UNSPEC_VCVTT_U))]
9723 "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
9724 "vcvttpd2<vcvtt_suffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
9725 [(set_attr "type" "ssecvt")
9726 (set_attr "prefix" "evex")
9727 (set_attr "mode" "<sseintvecmode2>")])
9728
9729 (define_insn "fix<fixunssuffix>_trunc<mode><sseintvecmodelower>2<mask_name><round_saeonly_name>"
9730 [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
9731 (any_fix:<sseintvecmode>
9732 (match_operand:VF2_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
9733 "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
9734 "vcvttpd2<fixsuffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
9735 [(set_attr "type" "ssecvt")
9736 (set_attr "prefix" "evex")
9737 (set_attr "mode" "<sseintvecmode2>")])
9738
9739 (define_insn "fix_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>"
9740 [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
9741 (unspec:<sseintvecmode>
9742 [(match_operand:VF2_AVX512VL 1 "<round_nimm_predicate>" "<round_constraint>")]
9743 UNSPEC_FIX_NOTRUNC))]
9744 "TARGET_AVX512DQ && <round_mode512bit_condition>"
9745 "vcvtpd2qq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
9746 [(set_attr "type" "ssecvt")
9747 (set_attr "prefix" "evex")
9748 (set_attr "mode" "<sseintvecmode2>")])
9749
9750 (define_insn "fixuns_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>"
9751 [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
9752 (unspec:<sseintvecmode>
9753 [(match_operand:VF2_AVX512VL 1 "nonimmediate_operand" "<round_constraint>")]
9754 UNSPEC_UNSIGNED_FIX_NOTRUNC))]
9755 "TARGET_AVX512DQ && <round_mode512bit_condition>"
9756 "vcvtpd2uqq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
9757 [(set_attr "type" "ssecvt")
9758 (set_attr "prefix" "evex")
9759 (set_attr "mode" "<sseintvecmode2>")])
9760
9761 (define_insn "unspec_fix<vcvtt_uns_suffix>_trunc<ssePSmode2lower><mode>2<mask_name><round_saeonly_name>"
9762 [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
9763 (unspec:VI8_256_512
9764 [(match_operand:<ssePSmode2> 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
9765 UNSPEC_VCVTT_U))]
9766 "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
9767 "vcvttps2<vcvtt_suffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
9768 [(set_attr "type" "ssecvt")
9769 (set_attr "prefix" "evex")
9770 (set_attr "mode" "<sseinsnmode>")])
9771
9772 (define_insn "fix<fixunssuffix>_trunc<ssePSmode2lower><mode>2<mask_name><round_saeonly_name>"
9773 [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
9774 (any_fix:VI8_256_512
9775 (match_operand:<ssePSmode2> 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
9776 "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
9777 "vcvttps2<fixsuffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
9778 [(set_attr "type" "ssecvt")
9779 (set_attr "prefix" "evex")
9780 (set_attr "mode" "<sseinsnmode>")])
9781
9782 (define_insn "unspec_avx512dq_fix<vcvtt_uns_suffix>_truncv2sfv2di2<mask_name>"
9783 [(set (match_operand:V2DI 0 "register_operand" "=v")
9784 (unspec:V2DI
9785 [(match_operand:V4SF 1 "nonimmediate_operand" "vm")]
9786 UNSPEC_VCVTT_U))]
9787 "TARGET_AVX512DQ && TARGET_AVX512VL"
9788 "vcvttps2<vcvtt_suffix>qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
9789 [(set_attr "type" "ssecvt")
9790 (set_attr "prefix" "evex")
9791 (set_attr "mode" "TI")])
9792
9793 (define_insn "avx512dq_fix<fixunssuffix>_truncv2sfv2di2<mask_name>"
9794 [(set (match_operand:V2DI 0 "register_operand" "=v")
9795 (any_fix:V2DI
9796 (vec_select:V2SF
9797 (match_operand:V4SF 1 "nonimmediate_operand" "vm")
9798 (parallel [(const_int 0) (const_int 1)]))))]
9799 "TARGET_AVX512DQ && TARGET_AVX512VL"
9800 "vcvttps2<fixsuffix>qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
9801 [(set_attr "type" "ssecvt")
9802 (set_attr "prefix" "evex")
9803 (set_attr "mode" "TI")])
9804
9805 (define_expand "fix<fixunssuffix>_truncv2sfv2di2"
9806 [(set (match_operand:V2DI 0 "register_operand")
9807 (any_fix:V2DI
9808 (match_operand:V2SF 1 "register_operand")))]
9809 "TARGET_AVX512DQ && TARGET_AVX512VL"
9810 {
9811 rtx op1 = force_reg (V2SFmode, operands[1]);
9812 op1 = lowpart_subreg (V4SFmode, op1, V2SFmode);
9813 emit_insn (gen_avx512dq_fix<fixunssuffix>_truncv2sfv2di2
9814 (operands[0], op1));
9815 DONE;
9816 })
9817
9818 (define_mode_attr vunpckfixt_mode
9819 [(V16SF "V8DI") (V8SF "V4DI") (V4SF "V2DI")
9820 (V32HF "V16SI") (V16HF "V8SI") (V8HF "V4SI")])
9821 (define_mode_attr vunpckfixt_model
9822 [(V16SF "v8di") (V8SF "v4di") (V4SF "v2di")
9823 (V32HF "v16si") (V16HF "v8si") (V8HF "v4si")])
9824 (define_mode_attr vunpckfixt_extract_mode
9825 [(V16SF "v16sf") (V8SF "v8sf") (V4SF "v8sf")
9826 (V32HF "v32hf") (V16HF "v16hf") (V8HF "v16hf")])
9827
9828 (define_expand "vec_unpack_<fixprefix>fix_trunc_lo_<mode>"
9829 [(match_operand:<vunpckfixt_mode> 0 "register_operand")
9830 (any_fix:<vunpckfixt_mode>
9831 (match_operand:VF1_AVX512VL 1 "register_operand"))]
9832 "TARGET_AVX512DQ"
9833 {
9834 rtx tem = operands[1];
9835 rtx (*gen) (rtx, rtx);
9836
9837 if (<MODE>mode != V4SFmode)
9838 {
9839 tem = gen_reg_rtx (<ssehalfvecmode>mode);
9840 emit_insn (gen_vec_extract_lo_<vunpckfixt_extract_mode> (tem,
9841 operands[1]));
9842 gen = gen_fix<fixunssuffix>_trunc<ssehalfvecmodelower><vunpckfixt_model>2;
9843 }
9844 else
9845 gen = gen_avx512dq_fix<fixunssuffix>_truncv2sfv2di2;
9846
9847 emit_insn (gen (operands[0], tem));
9848 DONE;
9849 })
9850
9851 (define_expand "vec_unpack_<fixprefix>fix_trunc_hi_<mode>"
9852 [(match_operand:<vunpckfixt_mode> 0 "register_operand")
9853 (any_fix:<vunpckfixt_mode>
9854 (match_operand:VF1_AVX512VL 1 "register_operand"))]
9855 "TARGET_AVX512DQ"
9856 {
9857 rtx tem;
9858 rtx (*gen) (rtx, rtx);
9859
9860 if (<MODE>mode != V4SFmode)
9861 {
9862 tem = gen_reg_rtx (<ssehalfvecmode>mode);
9863 emit_insn (gen_vec_extract_hi_<vunpckfixt_extract_mode> (tem,
9864 operands[1]));
9865 gen = gen_fix<fixunssuffix>_trunc<ssehalfvecmodelower><vunpckfixt_model>2;
9866 }
9867 else
9868 {
9869 tem = gen_reg_rtx (V4SFmode);
9870 emit_insn (gen_avx_vpermilv4sf (tem, operands[1], GEN_INT (0x4e)));
9871 gen = gen_avx512dq_fix<fixunssuffix>_truncv2sfv2di2;
9872 }
9873
9874 emit_insn (gen (operands[0], tem));
9875 DONE;
9876 })
9877
9878 (define_expand "vec_unpack_<fixprefix>fix_trunc_lo_<mode>"
9879 [(match_operand:<vunpckfixt_mode> 0 "register_operand")
9880 (any_fix:<vunpckfixt_mode>
9881 (match_operand:VHF_AVX512VL 1 "register_operand"))]
9882 "TARGET_AVX512FP16"
9883 {
9884 rtx tem = operands[1];
9885 rtx (*gen) (rtx, rtx);
9886 if (<MODE>mode != V8HFmode)
9887 {
9888 tem = gen_reg_rtx (<ssehalfvecmode>mode);
9889 emit_insn (gen_vec_extract_lo_<vunpckfixt_extract_mode> (tem,
9890 operands[1]));
9891 gen = gen_fix<fixunssuffix>_trunc<ssehalfvecmodelower><vunpckfixt_model>2;
9892 }
9893 else
9894 gen = gen_avx512fp16_fix<fixunssuffix>_trunc<vunpckfixt_model>2;
9895
9896 emit_insn (gen (operands[0], tem));
9897 DONE;
9898 })
9899
9900 (define_expand "vec_unpack_<fixprefix>fix_trunc_hi_<mode>"
9901 [(match_operand:<vunpckfixt_mode> 0 "register_operand")
9902 (any_fix:<vunpckfixt_mode>
9903 (match_operand:VHF_AVX512VL 1 "register_operand"))]
9904 "TARGET_AVX512FP16"
9905 {
9906 rtx tem = operands[1];
9907 rtx (*gen) (rtx, rtx);
9908 if (<MODE>mode != V8HFmode)
9909 {
9910 tem = gen_reg_rtx (<ssehalfvecmode>mode);
9911 emit_insn (gen_vec_extract_hi_<vunpckfixt_extract_mode> (tem,
9912 operands[1]));
9913 gen = gen_fix<fixunssuffix>_trunc<ssehalfvecmodelower><vunpckfixt_model>2;
9914 }
9915 else
9916 {
9917 tem = gen_reg_rtx (V8HFmode);
9918 rtvec tmp = rtvec_alloc (8);
9919 for (int i = 0; i != 8; i++)
9920 RTVEC_ELT (tmp, i) = GEN_INT ((i + 4) % 8);
9921
9922 rtx selector = gen_rtx_PARALLEL (VOIDmode, tmp);
9923 emit_move_insn (tem,
9924 gen_rtx_VEC_SELECT (V8HFmode, operands[1], selector));
9925 gen = gen_avx512fp16_fix<fixunssuffix>_trunc<vunpckfixt_model>2;
9926 }
9927
9928 emit_insn (gen (operands[0], tem));
9929 DONE;
9930 })
9931
9932 (define_insn "<mask_codefor>unspec_fixuns_trunc<mode><sseintvecmodelower>2<mask_name>"
9933 [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
9934 (unspec:<sseintvecmode>
9935 [(match_operand:VF1_128_256 1 "nonimmediate_operand" "vm")]
9936 UNSPEC_VCVTTU))]
9937 "TARGET_AVX512VL"
9938 "vcvttps2udq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
9939 [(set_attr "type" "ssecvt")
9940 (set_attr "prefix" "evex")
9941 (set_attr "mode" "<sseintvecmode2>")])
9942
9943 (define_insn "<mask_codefor>fixuns_trunc<mode><sseintvecmodelower>2<mask_name>"
9944 [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
9945 (unsigned_fix:<sseintvecmode>
9946 (match_operand:VF1_128_256 1 "nonimmediate_operand" "vm")))]
9947 "TARGET_AVX512VL"
9948 "vcvttps2udq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
9949 [(set_attr "type" "ssecvt")
9950 (set_attr "prefix" "evex")
9951 (set_attr "mode" "<sseintvecmode2>")])
9952
9953 (define_expand "avx_cvttpd2dq256_2"
9954 [(set (match_operand:V8SI 0 "register_operand")
9955 (vec_concat:V8SI
9956 (fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand"))
9957 (match_dup 2)))]
9958 "TARGET_AVX"
9959 "operands[2] = CONST0_RTX (V4SImode);")
9960
9961 (define_insn "unspec_sse2_cvttpd2dq<mask_name>"
9962 [(set (match_operand:V4SI 0 "register_operand" "=v")
9963 (unspec:V4SI
9964 [(match_operand:V2DF 1 "vector_operand" "vBm")]
9965 UNSPEC_VCVTT))]
9966 "TARGET_SSE2 && <mask_avx512vl_condition>"
9967 {
9968 if (TARGET_AVX)
9969 return "vcvttpd2dq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
9970 else
9971 return "cvttpd2dq\t{%1, %0|%0, %1}";
9972 }
9973 [(set_attr "type" "ssecvt")
9974 (set_attr "amdfam10_decode" "double")
9975 (set_attr "athlon_decode" "vector")
9976 (set_attr "bdver1_decode" "double")
9977 (set_attr "prefix" "maybe_vex")
9978 (set_attr "mode" "TI")])
9979
9980 (define_insn "sse2_cvttpd2dq"
9981 [(set (match_operand:V4SI 0 "register_operand" "=v")
9982 (vec_concat:V4SI
9983 (fix:V2SI (match_operand:V2DF 1 "vector_operand" "vBm"))
9984 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9985 "TARGET_SSE2"
9986 {
9987 if (TARGET_AVX)
9988 return "vcvttpd2dq{x}\t{%1, %0|%0, %1}";
9989 else
9990 return "cvttpd2dq\t{%1, %0|%0, %1}";
9991 }
9992 [(set_attr "type" "ssecvt")
9993 (set_attr "amdfam10_decode" "double")
9994 (set_attr "athlon_decode" "vector")
9995 (set_attr "bdver1_decode" "double")
9996 (set_attr "prefix" "maybe_vex")
9997 (set_attr "mode" "TI")])
9998
9999 (define_insn "sse2_cvttpd2dq_mask"
10000 [(set (match_operand:V4SI 0 "register_operand" "=v")
10001 (vec_concat:V4SI
10002 (vec_merge:V2SI
10003 (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "vm"))
10004 (vec_select:V2SI
10005 (match_operand:V4SI 2 "nonimm_or_0_operand" "0C")
10006 (parallel [(const_int 0) (const_int 1)]))
10007 (match_operand:QI 3 "register_operand" "Yk"))
10008 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
10009 "TARGET_AVX512VL"
10010 "vcvttpd2dq{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
10011 [(set_attr "type" "ssecvt")
10012 (set_attr "prefix" "evex")
10013 (set_attr "mode" "TI")])
10014
10015 (define_insn "*sse2_cvttpd2dq_mask_1"
10016 [(set (match_operand:V4SI 0 "register_operand" "=v")
10017 (vec_concat:V4SI
10018 (vec_merge:V2SI
10019 (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "vm"))
10020 (const_vector:V2SI [(const_int 0) (const_int 0)])
10021 (match_operand:QI 2 "register_operand" "Yk"))
10022 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
10023 "TARGET_AVX512VL"
10024 "vcvttpd2dq{x}\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
10025 [(set_attr "type" "ssecvt")
10026 (set_attr "prefix" "evex")
10027 (set_attr "mode" "TI")])
10028
10029 (define_insn "sse2_cvtsd2ss<mask_name><round_name>"
10030 [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
10031 (vec_merge:V4SF
10032 (vec_duplicate:V4SF
10033 (float_truncate:V2SF
10034 (match_operand:V2DF 2 "nonimmediate_operand" "x,m,<round_constraint>")))
10035 (match_operand:V4SF 1 "register_operand" "0,0,v")
10036 (const_int 1)))]
10037 "TARGET_SSE2"
10038 "@
10039 cvtsd2ss\t{%2, %0|%0, %2}
10040 cvtsd2ss\t{%2, %0|%0, %q2}
10041 vcvtsd2ss\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %q2<round_mask_op3>}"
10042 [(set_attr "isa" "noavx,noavx,avx")
10043 (set_attr "type" "ssecvt")
10044 (set_attr "athlon_decode" "vector,double,*")
10045 (set_attr "amdfam10_decode" "vector,double,*")
10046 (set_attr "bdver1_decode" "direct,direct,*")
10047 (set_attr "btver2_decode" "double,double,double")
10048 (set_attr "prefix" "orig,orig,<round_prefix>")
10049 (set_attr "mode" "SF")])
10050
10051 (define_insn "*sse2_vd_cvtsd2ss"
10052 [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
10053 (vec_merge:V4SF
10054 (vec_duplicate:V4SF
10055 (float_truncate:SF (match_operand:DF 2 "nonimmediate_operand" "x,m,vm")))
10056 (match_operand:V4SF 1 "register_operand" "0,0,v")
10057 (const_int 1)))]
10058 "TARGET_SSE2"
10059 "@
10060 cvtsd2ss\t{%2, %0|%0, %2}
10061 cvtsd2ss\t{%2, %0|%0, %2}
10062 vcvtsd2ss\t{%2, %1, %0|%0, %1, %2}"
10063 [(set_attr "isa" "noavx,noavx,avx")
10064 (set_attr "type" "ssecvt")
10065 (set_attr "athlon_decode" "vector,double,*")
10066 (set_attr "amdfam10_decode" "vector,double,*")
10067 (set_attr "bdver1_decode" "direct,direct,*")
10068 (set_attr "btver2_decode" "double,double,double")
10069 (set_attr "prefix" "orig,orig,vex")
10070 (set_attr "mode" "SF")])
10071
10072 (define_insn "sse2_cvtss2sd<mask_name><round_saeonly_name>"
10073 [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
10074 (vec_merge:V2DF
10075 (float_extend:V2DF
10076 (vec_select:V2SF
10077 (match_operand:V4SF 2 "<round_saeonly_nimm_scalar_predicate>" "x,m,<round_saeonly_constraint>")
10078 (parallel [(const_int 0) (const_int 1)])))
10079 (match_operand:V2DF 1 "register_operand" "0,0,v")
10080 (const_int 1)))]
10081 "TARGET_SSE2"
10082 "@
10083 cvtss2sd\t{%2, %0|%0, %2}
10084 cvtss2sd\t{%2, %0|%0, %k2}
10085 vcvtss2sd\t{<round_saeonly_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %k2<round_saeonly_mask_op3>}"
10086 [(set_attr "isa" "noavx,noavx,avx")
10087 (set_attr "type" "ssecvt")
10088 (set_attr "amdfam10_decode" "vector,double,*")
10089 (set_attr "athlon_decode" "direct,direct,*")
10090 (set_attr "bdver1_decode" "direct,direct,*")
10091 (set_attr "btver2_decode" "double,double,double")
10092 (set_attr "prefix" "orig,orig,<round_saeonly_prefix>")
10093 (set_attr "mode" "DF")])
10094
10095 (define_insn "*sse2_vd_cvtss2sd"
10096 [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
10097 (vec_merge:V2DF
10098 (vec_duplicate:V2DF
10099 (float_extend:DF (match_operand:SF 2 "nonimmediate_operand" "x,m,vm")))
10100 (match_operand:V2DF 1 "register_operand" "0,0,v")
10101 (const_int 1)))]
10102 "TARGET_SSE2"
10103 "@
10104 cvtss2sd\t{%2, %0|%0, %2}
10105 cvtss2sd\t{%2, %0|%0, %2}
10106 vcvtss2sd\t{%2, %1, %0|%0, %1, %2}"
10107 [(set_attr "isa" "noavx,noavx,avx")
10108 (set_attr "type" "ssecvt")
10109 (set_attr "amdfam10_decode" "vector,double,*")
10110 (set_attr "athlon_decode" "direct,direct,*")
10111 (set_attr "bdver1_decode" "direct,direct,*")
10112 (set_attr "btver2_decode" "double,double,double")
10113 (set_attr "prefix" "orig,orig,vex")
10114 (set_attr "mode" "DF")])
10115
10116 (define_insn "<mask_codefor>avx512f_cvtpd2ps512<mask_name><round_name>"
10117 [(set (match_operand:V8SF 0 "register_operand" "=v")
10118 (float_truncate:V8SF
10119 (match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")))]
10120 "TARGET_AVX512F && TARGET_EVEX512"
10121 "vcvtpd2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
10122 [(set_attr "type" "ssecvt")
10123 (set_attr "prefix" "evex")
10124 (set_attr "mode" "V8SF")])
10125
10126 (define_insn "avx_cvtpd2ps256<mask_name>"
10127 [(set (match_operand:V4SF 0 "register_operand" "=v")
10128 (float_truncate:V4SF
10129 (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
10130 "TARGET_AVX && <mask_avx512vl_condition>"
10131 "vcvtpd2ps{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
10132 [(set_attr "type" "ssecvt")
10133 (set_attr "prefix" "maybe_evex")
10134 (set_attr "btver2_decode" "vector")
10135 (set_attr "mode" "V4SF")])
10136
10137 (define_expand "sse2_cvtpd2ps"
10138 [(set (match_operand:V4SF 0 "register_operand")
10139 (vec_concat:V4SF
10140 (float_truncate:V2SF
10141 (match_operand:V2DF 1 "vector_operand"))
10142 (match_dup 2)))]
10143 "TARGET_SSE2"
10144 "operands[2] = CONST0_RTX (V2SFmode);")
10145
10146 (define_expand "sse2_cvtpd2ps_mask"
10147 [(set (match_operand:V4SF 0 "register_operand")
10148 (vec_concat:V4SF
10149 (vec_merge:V2SF
10150 (float_truncate:V2SF
10151 (match_operand:V2DF 1 "vector_operand"))
10152 (vec_select:V2SF
10153 (match_operand:V4SF 2 "nonimm_or_0_operand")
10154 (parallel [(const_int 0) (const_int 1)]))
10155 (match_operand:QI 3 "register_operand"))
10156 (match_dup 4)))]
10157 "TARGET_SSE2"
10158 "operands[4] = CONST0_RTX (V2SFmode);")
10159
10160 (define_insn "*sse2_cvtpd2ps"
10161 [(set (match_operand:V4SF 0 "register_operand" "=v")
10162 (vec_concat:V4SF
10163 (float_truncate:V2SF
10164 (match_operand:V2DF 1 "vector_operand" "vBm"))
10165 (match_operand:V2SF 2 "const0_operand")))]
10166 "TARGET_SSE2"
10167 {
10168 if (TARGET_AVX)
10169 return "vcvtpd2ps{x}\t{%1, %0|%0, %1}";
10170 else
10171 return "cvtpd2ps\t{%1, %0|%0, %1}";
10172 }
10173 [(set_attr "type" "ssecvt")
10174 (set_attr "amdfam10_decode" "double")
10175 (set_attr "athlon_decode" "vector")
10176 (set_attr "bdver1_decode" "double")
10177 (set_attr "prefix_data16" "1")
10178 (set_attr "prefix" "maybe_vex")
10179 (set_attr "mode" "V4SF")])
10180
10181 (define_insn "truncv2dfv2sf2"
10182 [(set (match_operand:V2SF 0 "register_operand" "=v")
10183 (float_truncate:V2SF
10184 (match_operand:V2DF 1 "vector_operand" "vBm")))]
10185 "TARGET_MMX_WITH_SSE"
10186 {
10187 if (TARGET_AVX)
10188 return "vcvtpd2ps{x}\t{%1, %0|%0, %1}";
10189 else
10190 return "cvtpd2ps\t{%1, %0|%0, %1}";
10191 }
10192 [(set_attr "type" "ssecvt")
10193 (set_attr "amdfam10_decode" "double")
10194 (set_attr "athlon_decode" "vector")
10195 (set_attr "bdver1_decode" "double")
10196 (set_attr "prefix_data16" "1")
10197 (set_attr "prefix" "maybe_vex")
10198 (set_attr "mode" "V4SF")])
10199
10200 (define_insn "*sse2_cvtpd2ps_mask"
10201 [(set (match_operand:V4SF 0 "register_operand" "=v")
10202 (vec_concat:V4SF
10203 (vec_merge:V2SF
10204 (float_truncate:V2SF
10205 (match_operand:V2DF 1 "nonimmediate_operand" "vm"))
10206 (vec_select:V2SF
10207 (match_operand:V4SF 2 "nonimm_or_0_operand" "0C")
10208 (parallel [(const_int 0) (const_int 1)]))
10209 (match_operand:QI 3 "register_operand" "Yk"))
10210 (match_operand:V2SF 4 "const0_operand")))]
10211 "TARGET_AVX512VL"
10212 "vcvtpd2ps{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
10213 [(set_attr "type" "ssecvt")
10214 (set_attr "prefix" "evex")
10215 (set_attr "mode" "V4SF")])
10216
10217 (define_insn "*sse2_cvtpd2ps_mask_1"
10218 [(set (match_operand:V4SF 0 "register_operand" "=v")
10219 (vec_concat:V4SF
10220 (vec_merge:V2SF
10221 (float_truncate:V2SF
10222 (match_operand:V2DF 1 "nonimmediate_operand" "vm"))
10223 (match_operand:V2SF 3 "const0_operand")
10224 (match_operand:QI 2 "register_operand" "Yk"))
10225 (match_operand:V2SF 4 "const0_operand")))]
10226 "TARGET_AVX512VL"
10227 "vcvtpd2ps{x}\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
10228 [(set_attr "type" "ssecvt")
10229 (set_attr "prefix" "evex")
10230 (set_attr "mode" "V4SF")])
10231
10232 ;; For <sse2_avx_avx512f>_cvtps2pd<avxsizesuffix> insn pattern
10233 (define_mode_attr sf2dfmode
10234 [(V8DF "V8SF") (V4DF "V4SF")])
10235 (define_mode_attr sf2dfmode_lower
10236 [(V8DF "v8sf") (V4DF "v4sf")])
10237
10238 (define_expand "trunc<mode><sf2dfmode_lower>2"
10239 [(set (match_operand:<sf2dfmode> 0 "register_operand")
10240 (float_truncate:<sf2dfmode>
10241 (match_operand:VF2_512_256 1 "vector_operand")))]
10242 "TARGET_AVX")
10243
10244 (define_expand "extend<sf2dfmode_lower><mode>2"
10245 [(set (match_operand:VF2_512_256 0 "register_operand")
10246 (float_extend:VF2_512_256
10247 (match_operand:<sf2dfmode> 1 "vector_operand")))]
10248 "TARGET_AVX")
10249
10250 (define_insn "<sse2_avx_avx512f>_cvtps2pd<avxsizesuffix><mask_name><round_saeonly_name>"
10251 [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
10252 (float_extend:VF2_512_256
10253 (match_operand:<sf2dfmode> 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
10254 "TARGET_AVX && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
10255 "vcvtps2pd\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
10256 [(set_attr "type" "ssecvt")
10257 (set_attr "prefix" "maybe_vex")
10258 (set_attr "mode" "<MODE>")])
10259
10260 (define_insn "*avx_cvtps2pd256_2"
10261 [(set (match_operand:V4DF 0 "register_operand" "=v")
10262 (float_extend:V4DF
10263 (vec_select:V4SF
10264 (match_operand:V8SF 1 "nonimmediate_operand" "vm")
10265 (parallel [(const_int 0) (const_int 1)
10266 (const_int 2) (const_int 3)]))))]
10267 "TARGET_AVX"
10268 "vcvtps2pd\t{%x1, %0|%0, %x1}"
10269 [(set_attr "type" "ssecvt")
10270 (set_attr "prefix" "vex")
10271 (set_attr "mode" "V4DF")])
10272
10273 (define_insn "vec_unpacks_lo_v16sf"
10274 [(set (match_operand:V8DF 0 "register_operand" "=v")
10275 (float_extend:V8DF
10276 (vec_select:V8SF
10277 (match_operand:V16SF 1 "nonimmediate_operand" "vm")
10278 (parallel [(const_int 0) (const_int 1)
10279 (const_int 2) (const_int 3)
10280 (const_int 4) (const_int 5)
10281 (const_int 6) (const_int 7)]))))]
10282 "TARGET_AVX512F && TARGET_EVEX512"
10283 "vcvtps2pd\t{%t1, %0|%0, %t1}"
10284 [(set_attr "type" "ssecvt")
10285 (set_attr "prefix" "evex")
10286 (set_attr "mode" "V8DF")])
10287
10288 (define_insn "<avx512>_cvt<ssemodesuffix>2mask<mode>"
10289 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
10290 (unspec:<avx512fmaskmode>
10291 [(match_operand:VI12_AVX512VL 1 "register_operand" "v")]
10292 UNSPEC_CVTINT2MASK))]
10293 "TARGET_AVX512BW"
10294 "vpmov<ssemodesuffix>2m\t{%1, %0|%0, %1}"
10295 [(set_attr "prefix" "evex")
10296 (set_attr "mode" "<sseinsnmode>")])
10297
10298 (define_insn "<avx512>_cvt<ssemodesuffix>2mask<mode>"
10299 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
10300 (unspec:<avx512fmaskmode>
10301 [(match_operand:VI48_AVX512VL 1 "register_operand" "v")]
10302 UNSPEC_CVTINT2MASK))]
10303 "TARGET_AVX512DQ"
10304 "vpmov<ssemodesuffix>2m\t{%1, %0|%0, %1}"
10305 [(set_attr "prefix" "evex")
10306 (set_attr "mode" "<sseinsnmode>")])
10307
10308 (define_expand "<avx512>_cvtmask2<ssemodesuffix><mode>"
10309 [(set (match_operand:VI12_AVX512VL 0 "register_operand")
10310 (vec_merge:VI12_AVX512VL
10311 (match_dup 2)
10312 (match_dup 3)
10313 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
10314 "TARGET_AVX512BW"
10315 {
10316 operands[2] = CONSTM1_RTX (<MODE>mode);
10317 operands[3] = CONST0_RTX (<MODE>mode);
10318 })
10319
10320 (define_insn "*<avx512>_cvtmask2<ssemodesuffix><mode>"
10321 [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
10322 (vec_merge:VI12_AVX512VL
10323 (match_operand:VI12_AVX512VL 2 "vector_all_ones_operand")
10324 (match_operand:VI12_AVX512VL 3 "const0_operand")
10325 (match_operand:<avx512fmaskmode> 1 "register_operand" "k")))]
10326 "TARGET_AVX512BW"
10327 "vpmovm2<ssemodesuffix>\t{%1, %0|%0, %1}"
10328 [(set_attr "prefix" "evex")
10329 (set_attr "mode" "<sseinsnmode>")])
10330
10331 (define_expand "<avx512>_cvtmask2<ssemodesuffix><mode>"
10332 [(set (match_operand:VI48_AVX512VL 0 "register_operand")
10333 (vec_merge:VI48_AVX512VL
10334 (match_dup 2)
10335 (match_dup 3)
10336 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
10337 "TARGET_AVX512F"
10338 "{
10339 operands[2] = CONSTM1_RTX (<MODE>mode);
10340 operands[3] = CONST0_RTX (<MODE>mode);
10341 }")
10342
10343 (define_insn_and_split "*<avx512>_cvtmask2<ssemodesuffix><mode>"
10344 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v,v")
10345 (vec_merge:VI48_AVX512VL
10346 (match_operand:VI48_AVX512VL 2 "vector_all_ones_operand")
10347 (match_operand:VI48_AVX512VL 3 "const0_operand")
10348 (match_operand:<avx512fmaskmode> 1 "register_operand" "k,Yk")))]
10349 "TARGET_AVX512F"
10350 "@
10351 vpmovm2<ssemodesuffix>\t{%1, %0|%0, %1}
10352 vpternlog<ssemodesuffix>\t{$0x81, %0, %0, %0%{%1%}%{z%}|%0%{%1%}%{z%}, %0, %0, 0x81}"
10353 "&& !TARGET_AVX512DQ && reload_completed
10354 && optimize_function_for_speed_p (cfun)"
10355 [(set (match_dup 0) (match_dup 4))
10356 (parallel
10357 [(set (match_dup 0)
10358 (vec_merge:VI48_AVX512VL
10359 (match_dup 2)
10360 (match_dup 3)
10361 (match_dup 1)))
10362 (unspec [(match_dup 0)] UNSPEC_INSN_FALSE_DEP)])]
10363 "operands[4] = CONST0_RTX (<MODE>mode);"
10364 [(set_attr "isa" "avx512dq,*")
10365 (set_attr "length_immediate" "0,1")
10366 (set_attr "prefix" "evex")
10367 (set_attr "mode" "<sseinsnmode>")])
10368
10369 (define_insn_and_split "*<avx512>_cvtmask2<ssemodesuffix><mode>_not"
10370 [(set (match_operand:VI1248_AVX512VLBW 0 "register_operand")
10371 (vec_merge:VI1248_AVX512VLBW
10372 (match_operand:VI1248_AVX512VLBW 2 "const0_operand")
10373 (match_operand:VI1248_AVX512VLBW 3 "vector_all_ones_operand")
10374 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
10375 "TARGET_AVX512F && ix86_pre_reload_split ()"
10376 "#"
10377 "&& 1"
10378 [(set (match_dup 4)
10379 (not:<avx512fmaskmode> (match_dup 1)))
10380 (set (match_dup 0)
10381 (vec_merge:VI1248_AVX512VLBW
10382 (match_dup 3)
10383 (match_dup 2)
10384 (match_dup 4)))]
10385 "operands[4] = gen_reg_rtx (<avx512fmaskmode>mode);")
10386
10387 (define_insn "*<avx512>_cvtmask2<ssemodesuffix><mode>_pternlog_false_dep"
10388 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10389 (vec_merge:VI48_AVX512VL
10390 (match_operand:VI48_AVX512VL 2 "vector_all_ones_operand")
10391 (match_operand:VI48_AVX512VL 3 "const0_operand")
10392 (match_operand:<avx512fmaskmode> 1 "register_operand" "Yk")))
10393 (unspec [(match_operand:VI48_AVX512VL 4 "register_operand" "0")] UNSPEC_INSN_FALSE_DEP)]
10394 "TARGET_AVX512F && !TARGET_AVX512DQ"
10395 "vpternlog<ssemodesuffix>\t{$0x81, %0, %0, %0%{%1%}%{z%}|%0%{%1%}%{z%}, %0, %0, 0x81}"
10396 [(set_attr "length_immediate" "1")
10397 (set_attr "prefix" "evex")
10398 (set_attr "mode" "<sseinsnmode>")])
10399
10400 (define_expand "extendv2sfv2df2"
10401 [(set (match_operand:V2DF 0 "register_operand")
10402 (float_extend:V2DF
10403 (match_operand:V2SF 1 "nonimmediate_operand")))]
10404 "TARGET_MMX_WITH_SSE"
10405 {
10406 if (!MEM_P (operands[1]))
10407 {
10408 operands[1] = lowpart_subreg (V4SFmode,
10409 force_reg (V2SFmode, operands[1]),
10410 V2SFmode);
10411 emit_insn (gen_sse2_cvtps2pd (operands[0], operands[1]));
10412 DONE;
10413 }
10414 })
10415
10416 (define_insn "sse2_cvtps2pd<mask_name>"
10417 [(set (match_operand:V2DF 0 "register_operand" "=v")
10418 (float_extend:V2DF
10419 (vec_select:V2SF
10420 (match_operand:V4SF 1 "register_operand" "v")
10421 (parallel [(const_int 0) (const_int 1)]))))]
10422 "TARGET_SSE2 && <mask_avx512vl_condition>"
10423 "%vcvtps2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
10424 [(set_attr "type" "ssecvt")
10425 (set_attr "amdfam10_decode" "direct")
10426 (set_attr "athlon_decode" "double")
10427 (set_attr "bdver1_decode" "double")
10428 (set_attr "prefix_data16" "0")
10429 (set_attr "prefix" "maybe_vex")
10430 (set_attr "mode" "V2DF")])
10431
10432 (define_insn "sse2_cvtps2pd<mask_name>_1"
10433 [(set (match_operand:V2DF 0 "register_operand" "=v")
10434 (float_extend:V2DF
10435 (match_operand:V2SF 1 "memory_operand" "m")))]
10436 "TARGET_SSE2 && <mask_avx512vl_condition>"
10437 "%vcvtps2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
10438 [(set_attr "type" "ssecvt")
10439 (set_attr "amdfam10_decode" "direct")
10440 (set_attr "athlon_decode" "double")
10441 (set_attr "bdver1_decode" "double")
10442 (set_attr "prefix_data16" "0")
10443 (set_attr "prefix" "maybe_vex")
10444 (set_attr "mode" "V2DF")])
10445
10446 (define_expand "vec_unpacks_hi_v4sf"
10447 [(set (match_dup 2)
10448 (vec_select:V4SF
10449 (vec_concat:V8SF
10450 (match_dup 2)
10451 (match_operand:V4SF 1 "vector_operand"))
10452 (parallel [(const_int 6) (const_int 7)
10453 (const_int 2) (const_int 3)])))
10454 (set (match_operand:V2DF 0 "register_operand")
10455 (float_extend:V2DF
10456 (vec_select:V2SF
10457 (match_dup 2)
10458 (parallel [(const_int 0) (const_int 1)]))))]
10459 "TARGET_SSE2"
10460 {
10461 operands[2] = gen_reg_rtx (V4SFmode);
10462 emit_move_insn (operands[2], CONST0_RTX (V4SFmode));
10463 })
10464
10465 (define_expand "vec_unpacks_hi_v8sf"
10466 [(set (match_dup 2)
10467 (vec_select:V4SF
10468 (match_operand:V8SF 1 "register_operand")
10469 (parallel [(const_int 4) (const_int 5)
10470 (const_int 6) (const_int 7)])))
10471 (set (match_operand:V4DF 0 "register_operand")
10472 (float_extend:V4DF
10473 (match_dup 2)))]
10474 "TARGET_AVX"
10475 "operands[2] = gen_reg_rtx (V4SFmode);")
10476
10477 (define_expand "vec_unpacks_hi_v16sf"
10478 [(set (match_dup 2)
10479 (vec_select:V8SF
10480 (match_operand:V16SF 1 "register_operand")
10481 (parallel [(const_int 8) (const_int 9)
10482 (const_int 10) (const_int 11)
10483 (const_int 12) (const_int 13)
10484 (const_int 14) (const_int 15)])))
10485 (set (match_operand:V8DF 0 "register_operand")
10486 (float_extend:V8DF
10487 (match_dup 2)))]
10488 "TARGET_AVX512F && TARGET_EVEX512"
10489 "operands[2] = gen_reg_rtx (V8SFmode);")
10490
10491 (define_expand "vec_unpacks_lo_v4sf"
10492 [(set (match_operand:V2DF 0 "register_operand")
10493 (float_extend:V2DF
10494 (vec_select:V2SF
10495 (match_operand:V4SF 1 "vector_operand")
10496 (parallel [(const_int 0) (const_int 1)]))))]
10497 "TARGET_SSE2"
10498 {
10499 if (MEM_P (operands[1]))
10500 {
10501 operands[1] = adjust_address_nv (operands[1], V2SFmode, 0);
10502 emit_insn (gen_sse2_cvtps2pd_1 (operands[0], operands[1]));
10503 DONE;
10504 }
10505 })
10506
10507 (define_expand "vec_unpacks_lo_v8sf"
10508 [(set (match_operand:V4DF 0 "register_operand")
10509 (float_extend:V4DF
10510 (vec_select:V4SF
10511 (match_operand:V8SF 1 "nonimmediate_operand")
10512 (parallel [(const_int 0) (const_int 1)
10513 (const_int 2) (const_int 3)]))))]
10514 "TARGET_AVX")
10515
10516 (define_mode_attr sseunpackfltmode
10517 [(V8HI "V4SF") (V4SI "V2DF") (V16HI "V8SF")
10518 (V8SI "V4DF") (V32HI "V16SF") (V16SI "V8DF")])
10519
10520 (define_expand "vec_unpacks_float_hi_<mode>"
10521 [(match_operand:<sseunpackfltmode> 0 "register_operand")
10522 (match_operand:VI2_AVX512F 1 "register_operand")]
10523 "TARGET_SSE2"
10524 {
10525 rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
10526
10527 emit_insn (gen_vec_unpacks_hi_<mode> (tmp, operands[1]));
10528 emit_insn (gen_rtx_SET (operands[0],
10529 gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
10530 DONE;
10531 })
10532
10533 (define_expand "vec_unpacks_float_lo_<mode>"
10534 [(match_operand:<sseunpackfltmode> 0 "register_operand")
10535 (match_operand:VI2_AVX512F 1 "register_operand")]
10536 "TARGET_SSE2"
10537 {
10538 rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
10539
10540 emit_insn (gen_vec_unpacks_lo_<mode> (tmp, operands[1]));
10541 emit_insn (gen_rtx_SET (operands[0],
10542 gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
10543 DONE;
10544 })
10545
10546 (define_expand "vec_unpacku_float_hi_<mode>"
10547 [(match_operand:<sseunpackfltmode> 0 "register_operand")
10548 (match_operand:VI2_AVX512F 1 "register_operand")]
10549 "TARGET_SSE2"
10550 {
10551 rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
10552
10553 emit_insn (gen_vec_unpacku_hi_<mode> (tmp, operands[1]));
10554 emit_insn (gen_rtx_SET (operands[0],
10555 gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
10556 DONE;
10557 })
10558
10559 (define_expand "vec_unpacku_float_lo_<mode>"
10560 [(match_operand:<sseunpackfltmode> 0 "register_operand")
10561 (match_operand:VI2_AVX512F 1 "register_operand")]
10562 "TARGET_SSE2"
10563 {
10564 rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
10565
10566 emit_insn (gen_vec_unpacku_lo_<mode> (tmp, operands[1]));
10567 emit_insn (gen_rtx_SET (operands[0],
10568 gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
10569 DONE;
10570 })
10571
10572 (define_expand "vec_unpacks_float_hi_v4si"
10573 [(set (match_dup 2)
10574 (vec_select:V4SI
10575 (match_operand:V4SI 1 "vector_operand")
10576 (parallel [(const_int 2) (const_int 3)
10577 (const_int 2) (const_int 3)])))
10578 (set (match_operand:V2DF 0 "register_operand")
10579 (float:V2DF
10580 (vec_select:V2SI
10581 (match_dup 2)
10582 (parallel [(const_int 0) (const_int 1)]))))]
10583 "TARGET_SSE2"
10584 "operands[2] = gen_reg_rtx (V4SImode);")
10585
10586 (define_expand "vec_unpacks_float_lo_v4si"
10587 [(set (match_operand:V2DF 0 "register_operand")
10588 (float:V2DF
10589 (vec_select:V2SI
10590 (match_operand:V4SI 1 "vector_operand")
10591 (parallel [(const_int 0) (const_int 1)]))))]
10592 "TARGET_SSE2")
10593
10594 (define_expand "vec_unpacks_float_hi_v8si"
10595 [(set (match_dup 2)
10596 (vec_select:V4SI
10597 (match_operand:V8SI 1 "register_operand")
10598 (parallel [(const_int 4) (const_int 5)
10599 (const_int 6) (const_int 7)])))
10600 (set (match_operand:V4DF 0 "register_operand")
10601 (float:V4DF
10602 (match_dup 2)))]
10603 "TARGET_AVX"
10604 "operands[2] = gen_reg_rtx (V4SImode);")
10605
10606 (define_expand "vec_unpacks_float_lo_v8si"
10607 [(set (match_operand:V4DF 0 "register_operand")
10608 (float:V4DF
10609 (vec_select:V4SI
10610 (match_operand:V8SI 1 "nonimmediate_operand")
10611 (parallel [(const_int 0) (const_int 1)
10612 (const_int 2) (const_int 3)]))))]
10613 "TARGET_AVX")
10614
10615 (define_expand "vec_unpacks_float_hi_v16si"
10616 [(set (match_dup 2)
10617 (vec_select:V8SI
10618 (match_operand:V16SI 1 "nonimmediate_operand")
10619 (parallel [(const_int 8) (const_int 9)
10620 (const_int 10) (const_int 11)
10621 (const_int 12) (const_int 13)
10622 (const_int 14) (const_int 15)])))
10623 (set (match_operand:V8DF 0 "register_operand")
10624 (float:V8DF
10625 (match_dup 2)))]
10626 "TARGET_AVX512F && TARGET_EVEX512"
10627 "operands[2] = gen_reg_rtx (V8SImode);")
10628
10629 (define_expand "vec_unpacks_float_lo_v16si"
10630 [(set (match_operand:V8DF 0 "register_operand")
10631 (float:V8DF
10632 (vec_select:V8SI
10633 (match_operand:V16SI 1 "nonimmediate_operand")
10634 (parallel [(const_int 0) (const_int 1)
10635 (const_int 2) (const_int 3)
10636 (const_int 4) (const_int 5)
10637 (const_int 6) (const_int 7)]))))]
10638 "TARGET_AVX512F && TARGET_EVEX512")
10639
10640 (define_expand "vec_unpacku_float_hi_v4si"
10641 [(set (match_dup 5)
10642 (vec_select:V4SI
10643 (match_operand:V4SI 1 "vector_operand")
10644 (parallel [(const_int 2) (const_int 3)
10645 (const_int 2) (const_int 3)])))
10646 (set (match_dup 6)
10647 (float:V2DF
10648 (vec_select:V2SI
10649 (match_dup 5)
10650 (parallel [(const_int 0) (const_int 1)]))))
10651 (set (match_dup 7)
10652 (lt:V2DF (match_dup 6) (match_dup 3)))
10653 (set (match_dup 8)
10654 (and:V2DF (match_dup 7) (match_dup 4)))
10655 (set (match_operand:V2DF 0 "register_operand")
10656 (plus:V2DF (match_dup 6) (match_dup 8)))]
10657 "TARGET_SSE2"
10658 {
10659 REAL_VALUE_TYPE TWO32r;
10660 rtx x;
10661 int i;
10662
10663 real_ldexp (&TWO32r, &dconst1, 32);
10664 x = const_double_from_real_value (TWO32r, DFmode);
10665
10666 operands[3] = force_reg (V2DFmode, CONST0_RTX (V2DFmode));
10667 operands[4] = force_reg (V2DFmode,
10668 ix86_build_const_vector (V2DFmode, 1, x));
10669
10670 operands[5] = gen_reg_rtx (V4SImode);
10671
10672 for (i = 6; i < 9; i++)
10673 operands[i] = gen_reg_rtx (V2DFmode);
10674 })
10675
10676 (define_expand "vec_unpacku_float_lo_v4si"
10677 [(set (match_dup 5)
10678 (float:V2DF
10679 (vec_select:V2SI
10680 (match_operand:V4SI 1 "vector_operand")
10681 (parallel [(const_int 0) (const_int 1)]))))
10682 (set (match_dup 6)
10683 (lt:V2DF (match_dup 5) (match_dup 3)))
10684 (set (match_dup 7)
10685 (and:V2DF (match_dup 6) (match_dup 4)))
10686 (set (match_operand:V2DF 0 "register_operand")
10687 (plus:V2DF (match_dup 5) (match_dup 7)))]
10688 "TARGET_SSE2"
10689 {
10690 REAL_VALUE_TYPE TWO32r;
10691 rtx x;
10692 int i;
10693
10694 real_ldexp (&TWO32r, &dconst1, 32);
10695 x = const_double_from_real_value (TWO32r, DFmode);
10696
10697 operands[3] = force_reg (V2DFmode, CONST0_RTX (V2DFmode));
10698 operands[4] = force_reg (V2DFmode,
10699 ix86_build_const_vector (V2DFmode, 1, x));
10700
10701 for (i = 5; i < 8; i++)
10702 operands[i] = gen_reg_rtx (V2DFmode);
10703 })
10704
10705 (define_expand "vec_unpacku_float_hi_v8si"
10706 [(match_operand:V4DF 0 "register_operand")
10707 (match_operand:V8SI 1 "register_operand")]
10708 "TARGET_AVX"
10709 {
10710 REAL_VALUE_TYPE TWO32r;
10711 rtx x, tmp[6];
10712 int i;
10713
10714 real_ldexp (&TWO32r, &dconst1, 32);
10715 x = const_double_from_real_value (TWO32r, DFmode);
10716
10717 tmp[0] = force_reg (V4DFmode, CONST0_RTX (V4DFmode));
10718 tmp[1] = force_reg (V4DFmode, ix86_build_const_vector (V4DFmode, 1, x));
10719 tmp[5] = gen_reg_rtx (V4SImode);
10720
10721 for (i = 2; i < 5; i++)
10722 tmp[i] = gen_reg_rtx (V4DFmode);
10723 emit_insn (gen_vec_extract_hi_v8si (tmp[5], operands[1]));
10724 emit_insn (gen_floatv4siv4df2 (tmp[2], tmp[5]));
10725 emit_insn (gen_rtx_SET (tmp[3], gen_rtx_LT (V4DFmode, tmp[2], tmp[0])));
10726 emit_insn (gen_andv4df3 (tmp[4], tmp[3], tmp[1]));
10727 emit_insn (gen_addv4df3 (operands[0], tmp[2], tmp[4]));
10728 DONE;
10729 })
10730
10731 (define_expand "vec_unpacku_float_hi_v16si"
10732 [(match_operand:V8DF 0 "register_operand")
10733 (match_operand:V16SI 1 "register_operand")]
10734 "TARGET_AVX512F && TARGET_EVEX512"
10735 {
10736 REAL_VALUE_TYPE TWO32r;
10737 rtx k, x, tmp[4];
10738
10739 real_ldexp (&TWO32r, &dconst1, 32);
10740 x = const_double_from_real_value (TWO32r, DFmode);
10741
10742 tmp[0] = force_reg (V8DFmode, CONST0_RTX (V8DFmode));
10743 tmp[1] = force_reg (V8DFmode, ix86_build_const_vector (V8DFmode, 1, x));
10744 tmp[2] = gen_reg_rtx (V8DFmode);
10745 tmp[3] = gen_reg_rtx (V8SImode);
10746 k = gen_reg_rtx (QImode);
10747
10748 emit_insn (gen_vec_extract_hi_v16si (tmp[3], operands[1]));
10749 emit_insn (gen_floatv8siv8df2 (tmp[2], tmp[3]));
10750 ix86_expand_mask_vec_cmp (k, LT, tmp[2], tmp[0]);
10751 emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k));
10752 emit_move_insn (operands[0], tmp[2]);
10753 DONE;
10754 })
10755
10756 (define_expand "vec_unpacku_float_lo_v8si"
10757 [(match_operand:V4DF 0 "register_operand")
10758 (match_operand:V8SI 1 "nonimmediate_operand")]
10759 "TARGET_AVX"
10760 {
10761 REAL_VALUE_TYPE TWO32r;
10762 rtx x, tmp[5];
10763 int i;
10764
10765 real_ldexp (&TWO32r, &dconst1, 32);
10766 x = const_double_from_real_value (TWO32r, DFmode);
10767
10768 tmp[0] = force_reg (V4DFmode, CONST0_RTX (V4DFmode));
10769 tmp[1] = force_reg (V4DFmode, ix86_build_const_vector (V4DFmode, 1, x));
10770
10771 for (i = 2; i < 5; i++)
10772 tmp[i] = gen_reg_rtx (V4DFmode);
10773 emit_insn (gen_avx_cvtdq2pd256_2 (tmp[2], operands[1]));
10774 emit_insn (gen_rtx_SET (tmp[3], gen_rtx_LT (V4DFmode, tmp[2], tmp[0])));
10775 emit_insn (gen_andv4df3 (tmp[4], tmp[3], tmp[1]));
10776 emit_insn (gen_addv4df3 (operands[0], tmp[2], tmp[4]));
10777 DONE;
10778 })
10779
10780 (define_expand "vec_unpacku_float_lo_v16si"
10781 [(match_operand:V8DF 0 "register_operand")
10782 (match_operand:V16SI 1 "nonimmediate_operand")]
10783 "TARGET_AVX512F && TARGET_EVEX512"
10784 {
10785 REAL_VALUE_TYPE TWO32r;
10786 rtx k, x, tmp[3];
10787
10788 real_ldexp (&TWO32r, &dconst1, 32);
10789 x = const_double_from_real_value (TWO32r, DFmode);
10790
10791 tmp[0] = force_reg (V8DFmode, CONST0_RTX (V8DFmode));
10792 tmp[1] = force_reg (V8DFmode, ix86_build_const_vector (V8DFmode, 1, x));
10793 tmp[2] = gen_reg_rtx (V8DFmode);
10794 k = gen_reg_rtx (QImode);
10795
10796 emit_insn (gen_avx512f_cvtdq2pd512_2 (tmp[2], operands[1]));
10797 ix86_expand_mask_vec_cmp (k, LT, tmp[2], tmp[0]);
10798 emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k));
10799 emit_move_insn (operands[0], tmp[2]);
10800 DONE;
10801 })
10802
10803 (define_expand "vec_pack_trunc_<mode>"
10804 [(set (match_dup 3)
10805 (float_truncate:<sf2dfmode>
10806 (match_operand:VF2_512_256 1 "nonimmediate_operand")))
10807 (set (match_dup 4)
10808 (float_truncate:<sf2dfmode>
10809 (match_operand:VF2_512_256 2 "nonimmediate_operand")))
10810 (set (match_operand:<ssePSmode> 0 "register_operand")
10811 (vec_concat:<ssePSmode>
10812 (match_dup 3)
10813 (match_dup 4)))]
10814 "TARGET_AVX"
10815 {
10816 operands[3] = gen_reg_rtx (<sf2dfmode>mode);
10817 operands[4] = gen_reg_rtx (<sf2dfmode>mode);
10818 })
10819
10820 (define_expand "vec_pack_trunc_<mode>"
10821 [(match_operand:<ssepackPHmode> 0 "register_operand")
10822 (match_operand:VF1_AVX512VL 1 "register_operand")
10823 (match_operand:VF1_AVX512VL 2 "register_operand")]
10824 "TARGET_AVX512FP16"
10825 {
10826 rtx r1 = gen_reg_rtx (<vpckfloat_temp_mode>mode);
10827 rtx r2 = gen_reg_rtx (<vpckfloat_temp_mode>mode);
10828 rtx (*gen) (rtx, rtx);
10829
10830 if (<MODE>mode == V4SFmode)
10831 gen = gen_avx512fp16_truncv4sfv4hf2;
10832 else
10833 gen = gen_trunc<mode><vpckfloat_op_mode>2;
10834 emit_insn (gen (r1, operands[1]));
10835 emit_insn (gen (r2, operands[2]));
10836 if (<MODE>mode == V4SFmode)
10837 emit_insn (gen_sse_movlhps_v8hf (operands[0], r1, r2));
10838 else
10839 emit_insn (gen_avx_vec_concat<vpckfloat_concat_mode> (operands[0],
10840 r1, r2));
10841 DONE;
10842
10843 })
10844
10845 (define_expand "vec_pack_trunc_v2df"
10846 [(match_operand:V4SF 0 "register_operand")
10847 (match_operand:V2DF 1 "vector_operand")
10848 (match_operand:V2DF 2 "vector_operand")]
10849 "TARGET_SSE2"
10850 {
10851 rtx tmp0, tmp1;
10852
10853 if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
10854 {
10855 tmp0 = gen_reg_rtx (V4DFmode);
10856 tmp1 = force_reg (V2DFmode, operands[1]);
10857
10858 emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
10859 emit_insn (gen_avx_cvtpd2ps256 (operands[0], tmp0));
10860 }
10861 else
10862 {
10863 tmp0 = gen_reg_rtx (V4SFmode);
10864 tmp1 = gen_reg_rtx (V4SFmode);
10865
10866 emit_insn (gen_sse2_cvtpd2ps (tmp0, operands[1]));
10867 emit_insn (gen_sse2_cvtpd2ps (tmp1, operands[2]));
10868 emit_insn (gen_sse_movlhps (operands[0], tmp0, tmp1));
10869 }
10870 DONE;
10871 })
10872
10873 (define_expand "vec_pack_sfix_trunc_v8df"
10874 [(match_operand:V16SI 0 "register_operand")
10875 (match_operand:V8DF 1 "nonimmediate_operand")
10876 (match_operand:V8DF 2 "nonimmediate_operand")]
10877 "TARGET_AVX512F && TARGET_EVEX512"
10878 {
10879 rtx r1, r2;
10880
10881 r1 = gen_reg_rtx (V8SImode);
10882 r2 = gen_reg_rtx (V8SImode);
10883
10884 emit_insn (gen_fix_truncv8dfv8si2 (r1, operands[1]));
10885 emit_insn (gen_fix_truncv8dfv8si2 (r2, operands[2]));
10886 emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
10887 DONE;
10888 })
10889
10890 (define_expand "vec_pack_sfix_trunc_v4df"
10891 [(match_operand:V8SI 0 "register_operand")
10892 (match_operand:V4DF 1 "nonimmediate_operand")
10893 (match_operand:V4DF 2 "nonimmediate_operand")]
10894 "TARGET_AVX"
10895 {
10896 rtx r1, r2;
10897
10898 r1 = gen_reg_rtx (V4SImode);
10899 r2 = gen_reg_rtx (V4SImode);
10900
10901 emit_insn (gen_fix_truncv4dfv4si2 (r1, operands[1]));
10902 emit_insn (gen_fix_truncv4dfv4si2 (r2, operands[2]));
10903 emit_insn (gen_avx_vec_concatv8si (operands[0], r1, r2));
10904 DONE;
10905 })
10906
10907 (define_expand "vec_pack_sfix_trunc_v2df"
10908 [(match_operand:V4SI 0 "register_operand")
10909 (match_operand:V2DF 1 "vector_operand")
10910 (match_operand:V2DF 2 "vector_operand")]
10911 "TARGET_SSE2"
10912 {
10913 rtx tmp0, tmp1, tmp2;
10914
10915 if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
10916 {
10917 tmp0 = gen_reg_rtx (V4DFmode);
10918 tmp1 = force_reg (V2DFmode, operands[1]);
10919
10920 emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
10921 emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp0));
10922 }
10923 else
10924 {
10925 tmp0 = gen_reg_rtx (V4SImode);
10926 tmp1 = gen_reg_rtx (V4SImode);
10927 tmp2 = gen_reg_rtx (V2DImode);
10928
10929 emit_insn (gen_sse2_cvttpd2dq (tmp0, operands[1]));
10930 emit_insn (gen_sse2_cvttpd2dq (tmp1, operands[2]));
10931 emit_insn (gen_vec_interleave_lowv2di (tmp2,
10932 gen_lowpart (V2DImode, tmp0),
10933 gen_lowpart (V2DImode, tmp1)));
10934 emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp2));
10935 }
10936 DONE;
10937 })
10938
10939 (define_mode_attr ssepackfltmode
10940 [(V8DF "V16SI") (V4DF "V8SI") (V2DF "V4SI")])
10941
10942 (define_expand "vec_pack_ufix_trunc_<mode>"
10943 [(match_operand:<ssepackfltmode> 0 "register_operand")
10944 (match_operand:VF2 1 "register_operand")
10945 (match_operand:VF2 2 "register_operand")]
10946 "TARGET_SSE2"
10947 {
10948 if (<MODE>mode == V8DFmode)
10949 {
10950 rtx r1, r2;
10951
10952 r1 = gen_reg_rtx (V8SImode);
10953 r2 = gen_reg_rtx (V8SImode);
10954
10955 emit_insn (gen_fixuns_truncv8dfv8si2 (r1, operands[1]));
10956 emit_insn (gen_fixuns_truncv8dfv8si2 (r2, operands[2]));
10957 emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
10958 }
10959 else
10960 {
10961 rtx tmp[7];
10962 tmp[0] = ix86_expand_adjust_ufix_to_sfix_si (operands[1], &tmp[2]);
10963 tmp[1] = ix86_expand_adjust_ufix_to_sfix_si (operands[2], &tmp[3]);
10964 tmp[4] = gen_reg_rtx (<ssepackfltmode>mode);
10965 emit_insn (gen_vec_pack_sfix_trunc_<mode> (tmp[4], tmp[0], tmp[1]));
10966 if (<ssepackfltmode>mode == V4SImode || TARGET_AVX2)
10967 {
10968 tmp[5] = gen_reg_rtx (<ssepackfltmode>mode);
10969 ix86_expand_vec_extract_even_odd (tmp[5], tmp[2], tmp[3], 0);
10970 }
10971 else
10972 {
10973 tmp[5] = gen_reg_rtx (V8SFmode);
10974 ix86_expand_vec_extract_even_odd (tmp[5],
10975 gen_lowpart (V8SFmode, tmp[2]),
10976 gen_lowpart (V8SFmode, tmp[3]), 0);
10977 tmp[5] = gen_lowpart (V8SImode, tmp[5]);
10978 }
10979 tmp[6] = expand_simple_binop (<ssepackfltmode>mode, XOR, tmp[4], tmp[5],
10980 operands[0], 0, OPTAB_DIRECT);
10981 if (tmp[6] != operands[0])
10982 emit_move_insn (operands[0], tmp[6]);
10983 }
10984
10985 DONE;
10986 })
10987
10988 (define_expand "avx512f_vec_pack_sfix_v8df"
10989 [(match_operand:V16SI 0 "register_operand")
10990 (match_operand:V8DF 1 "nonimmediate_operand")
10991 (match_operand:V8DF 2 "nonimmediate_operand")]
10992 "TARGET_AVX512F && TARGET_EVEX512"
10993 {
10994 rtx r1, r2;
10995
10996 r1 = gen_reg_rtx (V8SImode);
10997 r2 = gen_reg_rtx (V8SImode);
10998
10999 emit_insn (gen_avx512f_cvtpd2dq512 (r1, operands[1]));
11000 emit_insn (gen_avx512f_cvtpd2dq512 (r2, operands[2]));
11001 emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
11002 DONE;
11003 })
11004
11005 (define_expand "vec_pack_sfix_v4df"
11006 [(match_operand:V8SI 0 "register_operand")
11007 (match_operand:V4DF 1 "nonimmediate_operand")
11008 (match_operand:V4DF 2 "nonimmediate_operand")]
11009 "TARGET_AVX"
11010 {
11011 rtx r1, r2;
11012
11013 r1 = gen_reg_rtx (V4SImode);
11014 r2 = gen_reg_rtx (V4SImode);
11015
11016 emit_insn (gen_avx_cvtpd2dq256 (r1, operands[1]));
11017 emit_insn (gen_avx_cvtpd2dq256 (r2, operands[2]));
11018 emit_insn (gen_avx_vec_concatv8si (operands[0], r1, r2));
11019 DONE;
11020 })
11021
11022 (define_expand "vec_pack_sfix_v2df"
11023 [(match_operand:V4SI 0 "register_operand")
11024 (match_operand:V2DF 1 "vector_operand")
11025 (match_operand:V2DF 2 "vector_operand")]
11026 "TARGET_SSE2"
11027 {
11028 rtx tmp0, tmp1, tmp2;
11029
11030 if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
11031 {
11032 tmp0 = gen_reg_rtx (V4DFmode);
11033 tmp1 = force_reg (V2DFmode, operands[1]);
11034
11035 emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
11036 emit_insn (gen_avx_cvtpd2dq256 (operands[0], tmp0));
11037 }
11038 else
11039 {
11040 tmp0 = gen_reg_rtx (V4SImode);
11041 tmp1 = gen_reg_rtx (V4SImode);
11042 tmp2 = gen_reg_rtx (V2DImode);
11043
11044 emit_insn (gen_sse2_cvtpd2dq (tmp0, operands[1]));
11045 emit_insn (gen_sse2_cvtpd2dq (tmp1, operands[2]));
11046 emit_insn (gen_vec_interleave_lowv2di (tmp2,
11047 gen_lowpart (V2DImode, tmp0),
11048 gen_lowpart (V2DImode, tmp1)));
11049 emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp2));
11050 }
11051 DONE;
11052 })
11053
11054 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11055 ;;
11056 ;; Parallel single-precision floating point element swizzling
11057 ;;
11058 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11059
11060 (define_expand "sse_movhlps_exp"
11061 [(set (match_operand:V4SF 0 "nonimmediate_operand")
11062 (vec_select:V4SF
11063 (vec_concat:V8SF
11064 (match_operand:V4SF 1 "nonimmediate_operand")
11065 (match_operand:V4SF 2 "nonimmediate_operand"))
11066 (parallel [(const_int 6)
11067 (const_int 7)
11068 (const_int 2)
11069 (const_int 3)])))]
11070 "TARGET_SSE"
11071 {
11072 rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
11073
11074 emit_insn (gen_sse_movhlps (dst, operands[1], operands[2]));
11075
11076 /* Fix up the destination if needed. */
11077 if (dst != operands[0])
11078 emit_move_insn (operands[0], dst);
11079
11080 DONE;
11081 })
11082
11083 (define_insn "sse_movhlps"
11084 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,v,x,v,m")
11085 (vec_select:V4SF
11086 (vec_concat:V8SF
11087 (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
11088 (match_operand:V4SF 2 "nonimmediate_operand" " x,v,o,o,v"))
11089 (parallel [(const_int 6)
11090 (const_int 7)
11091 (const_int 2)
11092 (const_int 3)])))]
11093 "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11094 "@
11095 movhlps\t{%2, %0|%0, %2}
11096 vmovhlps\t{%2, %1, %0|%0, %1, %2}
11097 movlps\t{%H2, %0|%0, %H2}
11098 vmovlps\t{%H2, %1, %0|%0, %1, %H2}
11099 %vmovhps\t{%2, %0|%q0, %2}"
11100 [(set_attr "isa" "noavx,avx,noavx,avx,*")
11101 (set_attr "type" "ssemov2")
11102 (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
11103 (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
11104
11105 (define_expand "sse_movlhps_exp"
11106 [(set (match_operand:V4SF 0 "nonimmediate_operand")
11107 (vec_select:V4SF
11108 (vec_concat:V8SF
11109 (match_operand:V4SF 1 "nonimmediate_operand")
11110 (match_operand:V4SF 2 "nonimmediate_operand"))
11111 (parallel [(const_int 0)
11112 (const_int 1)
11113 (const_int 4)
11114 (const_int 5)])))]
11115 "TARGET_SSE"
11116 {
11117 rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
11118
11119 emit_insn (gen_sse_movlhps (dst, operands[1], operands[2]));
11120
11121 /* Fix up the destination if needed. */
11122 if (dst != operands[0])
11123 emit_move_insn (operands[0], dst);
11124
11125 DONE;
11126 })
11127
11128 (define_insn "sse_movlhps"
11129 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,v,x,v,o")
11130 (vec_select:V4SF
11131 (vec_concat:V8SF
11132 (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
11133 (match_operand:V4SF 2 "nonimmediate_operand" " x,v,m,v,v"))
11134 (parallel [(const_int 0)
11135 (const_int 1)
11136 (const_int 4)
11137 (const_int 5)])))]
11138 "TARGET_SSE && ix86_binary_operator_ok (UNKNOWN, V4SFmode, operands)"
11139 "@
11140 movlhps\t{%2, %0|%0, %2}
11141 vmovlhps\t{%2, %1, %0|%0, %1, %2}
11142 movhps\t{%2, %0|%0, %q2}
11143 vmovhps\t{%2, %1, %0|%0, %1, %q2}
11144 %vmovlps\t{%2, %H0|%H0, %2}"
11145 [(set_attr "isa" "noavx,avx,noavx,avx,*")
11146 (set_attr "type" "ssemov")
11147 (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
11148 (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
11149
11150 (define_insn "sse_movlhps_<mode>"
11151 [(set (match_operand:V8_128 0 "nonimmediate_operand" "=x,v,x,o")
11152 (vec_select:V8_128
11153 (vec_concat:<ssedoublevecmode>
11154 (match_operand:V8_128 1 "nonimmediate_operand" " 0,v,0,0")
11155 (match_operand:V8_128 2 "nonimmediate_operand" " x,v,m,v"))
11156 (parallel [(const_int 0) (const_int 1)
11157 (const_int 2) (const_int 3)
11158 (const_int 8) (const_int 9)
11159 (const_int 10) (const_int 11)])))]
11160 "TARGET_SSE && ix86_binary_operator_ok (UNKNOWN, <MODE>mode, operands)"
11161 "@
11162 movlhps\t{%2, %0|%0, %2}
11163 vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
11164 movhps\t{%2, %0|%0, %q2}
11165 %vmovlps\t{%2, %H0|%H0, %2}"
11166 [(set_attr "isa" "noavx,avx,noavx,*")
11167 (set_attr "type" "ssemov")
11168 (set_attr "prefix" "orig,maybe_evex,orig,maybe_vex")
11169 (set_attr "mode" "V4SF,TI,V2SF,V2SF")])
11170
11171 (define_insn "<mask_codefor>avx512f_unpckhps512<mask_name>"
11172 [(set (match_operand:V16SF 0 "register_operand" "=v")
11173 (vec_select:V16SF
11174 (vec_concat:V32SF
11175 (match_operand:V16SF 1 "register_operand" "v")
11176 (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
11177 (parallel [(const_int 2) (const_int 18)
11178 (const_int 3) (const_int 19)
11179 (const_int 6) (const_int 22)
11180 (const_int 7) (const_int 23)
11181 (const_int 10) (const_int 26)
11182 (const_int 11) (const_int 27)
11183 (const_int 14) (const_int 30)
11184 (const_int 15) (const_int 31)])))]
11185 "TARGET_AVX512F && TARGET_EVEX512"
11186 "vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11187 [(set_attr "type" "sselog")
11188 (set_attr "prefix" "evex")
11189 (set_attr "mode" "V16SF")])
11190
11191 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
11192 (define_insn "avx_unpckhps256<mask_name>"
11193 [(set (match_operand:V8SF 0 "register_operand" "=v")
11194 (vec_select:V8SF
11195 (vec_concat:V16SF
11196 (match_operand:V8SF 1 "register_operand" "v")
11197 (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
11198 (parallel [(const_int 2) (const_int 10)
11199 (const_int 3) (const_int 11)
11200 (const_int 6) (const_int 14)
11201 (const_int 7) (const_int 15)])))]
11202 "TARGET_AVX && <mask_avx512vl_condition>"
11203 "vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11204 [(set_attr "type" "sselog")
11205 (set_attr "prefix" "vex")
11206 (set_attr "mode" "V8SF")])
11207
11208 (define_expand "vec_interleave_highv8sf"
11209 [(set (match_dup 3)
11210 (vec_select:V8SF
11211 (vec_concat:V16SF
11212 (match_operand:V8SF 1 "register_operand")
11213 (match_operand:V8SF 2 "nonimmediate_operand"))
11214 (parallel [(const_int 0) (const_int 8)
11215 (const_int 1) (const_int 9)
11216 (const_int 4) (const_int 12)
11217 (const_int 5) (const_int 13)])))
11218 (set (match_dup 4)
11219 (vec_select:V8SF
11220 (vec_concat:V16SF
11221 (match_dup 1)
11222 (match_dup 2))
11223 (parallel [(const_int 2) (const_int 10)
11224 (const_int 3) (const_int 11)
11225 (const_int 6) (const_int 14)
11226 (const_int 7) (const_int 15)])))
11227 (set (match_operand:V8SF 0 "register_operand")
11228 (vec_select:V8SF
11229 (vec_concat:V16SF
11230 (match_dup 3)
11231 (match_dup 4))
11232 (parallel [(const_int 4) (const_int 5)
11233 (const_int 6) (const_int 7)
11234 (const_int 12) (const_int 13)
11235 (const_int 14) (const_int 15)])))]
11236 "TARGET_AVX"
11237 {
11238 operands[3] = gen_reg_rtx (V8SFmode);
11239 operands[4] = gen_reg_rtx (V8SFmode);
11240 })
11241
11242 (define_insn "vec_interleave_highv4sf<mask_name>"
11243 [(set (match_operand:V4SF 0 "register_operand" "=x,v")
11244 (vec_select:V4SF
11245 (vec_concat:V8SF
11246 (match_operand:V4SF 1 "register_operand" "0,v")
11247 (match_operand:V4SF 2 "vector_operand" "xBm,vm"))
11248 (parallel [(const_int 2) (const_int 6)
11249 (const_int 3) (const_int 7)])))]
11250 "TARGET_SSE && <mask_avx512vl_condition>"
11251 "@
11252 unpckhps\t{%2, %0|%0, %2}
11253 vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11254 [(set_attr "isa" "noavx,avx")
11255 (set_attr "type" "sselog")
11256 (set_attr "prefix" "orig,vex")
11257 (set_attr "mode" "V4SF")])
11258
11259 (define_insn "<mask_codefor>avx512f_unpcklps512<mask_name>"
11260 [(set (match_operand:V16SF 0 "register_operand" "=v")
11261 (vec_select:V16SF
11262 (vec_concat:V32SF
11263 (match_operand:V16SF 1 "register_operand" "v")
11264 (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
11265 (parallel [(const_int 0) (const_int 16)
11266 (const_int 1) (const_int 17)
11267 (const_int 4) (const_int 20)
11268 (const_int 5) (const_int 21)
11269 (const_int 8) (const_int 24)
11270 (const_int 9) (const_int 25)
11271 (const_int 12) (const_int 28)
11272 (const_int 13) (const_int 29)])))]
11273 "TARGET_AVX512F && TARGET_EVEX512"
11274 "vunpcklps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11275 [(set_attr "type" "sselog")
11276 (set_attr "prefix" "evex")
11277 (set_attr "mode" "V16SF")])
11278
11279 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
11280 (define_insn "avx_unpcklps256<mask_name>"
11281 [(set (match_operand:V8SF 0 "register_operand" "=v")
11282 (vec_select:V8SF
11283 (vec_concat:V16SF
11284 (match_operand:V8SF 1 "register_operand" "v")
11285 (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
11286 (parallel [(const_int 0) (const_int 8)
11287 (const_int 1) (const_int 9)
11288 (const_int 4) (const_int 12)
11289 (const_int 5) (const_int 13)])))]
11290 "TARGET_AVX && <mask_avx512vl_condition>"
11291 "vunpcklps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11292 [(set_attr "type" "sselog")
11293 (set_attr "prefix" "vex")
11294 (set_attr "mode" "V8SF")])
11295
11296 (define_insn "unpcklps128_mask"
11297 [(set (match_operand:V4SF 0 "register_operand" "=v")
11298 (vec_merge:V4SF
11299 (vec_select:V4SF
11300 (vec_concat:V8SF
11301 (match_operand:V4SF 1 "register_operand" "v")
11302 (match_operand:V4SF 2 "nonimmediate_operand" "vm"))
11303 (parallel [(const_int 0) (const_int 4)
11304 (const_int 1) (const_int 5)]))
11305 (match_operand:V4SF 3 "nonimm_or_0_operand" "0C")
11306 (match_operand:QI 4 "register_operand" "Yk")))]
11307 "TARGET_AVX512VL"
11308 "vunpcklps\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
11309 [(set_attr "type" "sselog")
11310 (set_attr "prefix" "evex")
11311 (set_attr "mode" "V4SF")])
11312
11313 (define_expand "vec_interleave_lowv8sf"
11314 [(set (match_dup 3)
11315 (vec_select:V8SF
11316 (vec_concat:V16SF
11317 (match_operand:V8SF 1 "register_operand")
11318 (match_operand:V8SF 2 "nonimmediate_operand"))
11319 (parallel [(const_int 0) (const_int 8)
11320 (const_int 1) (const_int 9)
11321 (const_int 4) (const_int 12)
11322 (const_int 5) (const_int 13)])))
11323 (set (match_dup 4)
11324 (vec_select:V8SF
11325 (vec_concat:V16SF
11326 (match_dup 1)
11327 (match_dup 2))
11328 (parallel [(const_int 2) (const_int 10)
11329 (const_int 3) (const_int 11)
11330 (const_int 6) (const_int 14)
11331 (const_int 7) (const_int 15)])))
11332 (set (match_operand:V8SF 0 "register_operand")
11333 (vec_select:V8SF
11334 (vec_concat:V16SF
11335 (match_dup 3)
11336 (match_dup 4))
11337 (parallel [(const_int 0) (const_int 1)
11338 (const_int 2) (const_int 3)
11339 (const_int 8) (const_int 9)
11340 (const_int 10) (const_int 11)])))]
11341 "TARGET_AVX"
11342 {
11343 operands[3] = gen_reg_rtx (V8SFmode);
11344 operands[4] = gen_reg_rtx (V8SFmode);
11345 })
11346
11347 (define_insn "vec_interleave_lowv4sf"
11348 [(set (match_operand:V4SF 0 "register_operand" "=x,v")
11349 (vec_select:V4SF
11350 (vec_concat:V8SF
11351 (match_operand:V4SF 1 "register_operand" "0,v")
11352 (match_operand:V4SF 2 "vector_operand" "xBm,vm"))
11353 (parallel [(const_int 0) (const_int 4)
11354 (const_int 1) (const_int 5)])))]
11355 "TARGET_SSE"
11356 "@
11357 unpcklps\t{%2, %0|%0, %2}
11358 vunpcklps\t{%2, %1, %0|%0, %1, %2}"
11359 [(set_attr "isa" "noavx,avx")
11360 (set_attr "type" "sselog")
11361 (set_attr "prefix" "orig,maybe_evex")
11362 (set_attr "mode" "V4SF")])
11363
11364 ;; These are modeled with the same vec_concat as the others so that we
11365 ;; capture users of shufps that can use the new instructions
11366 (define_insn "avx_movshdup256<mask_name>"
11367 [(set (match_operand:V8SF 0 "register_operand" "=v")
11368 (vec_select:V8SF
11369 (vec_concat:V16SF
11370 (match_operand:V8SF 1 "nonimmediate_operand" "vm")
11371 (match_dup 1))
11372 (parallel [(const_int 1) (const_int 1)
11373 (const_int 3) (const_int 3)
11374 (const_int 5) (const_int 5)
11375 (const_int 7) (const_int 7)])))]
11376 "TARGET_AVX && <mask_avx512vl_condition>"
11377 "vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
11378 [(set_attr "type" "sse")
11379 (set_attr "prefix" "vex")
11380 (set_attr "mode" "V8SF")])
11381
11382 (define_insn "sse3_movshdup<mask_name>"
11383 [(set (match_operand:V4SF 0 "register_operand" "=v")
11384 (vec_select:V4SF
11385 (vec_concat:V8SF
11386 (match_operand:V4SF 1 "vector_operand" "vBm")
11387 (match_dup 1))
11388 (parallel [(const_int 1)
11389 (const_int 1)
11390 (const_int 7)
11391 (const_int 7)])))]
11392 "TARGET_SSE3 && <mask_avx512vl_condition>"
11393 "%vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
11394 [(set_attr "type" "sse")
11395 (set_attr "prefix_rep" "1")
11396 (set_attr "prefix" "maybe_vex")
11397 (set_attr "mode" "V4SF")])
11398
11399 (define_insn "<mask_codefor>avx512f_movshdup512<mask_name>"
11400 [(set (match_operand:V16SF 0 "register_operand" "=v")
11401 (vec_select:V16SF
11402 (vec_concat:V32SF
11403 (match_operand:V16SF 1 "nonimmediate_operand" "vm")
11404 (match_dup 1))
11405 (parallel [(const_int 1) (const_int 1)
11406 (const_int 3) (const_int 3)
11407 (const_int 5) (const_int 5)
11408 (const_int 7) (const_int 7)
11409 (const_int 9) (const_int 9)
11410 (const_int 11) (const_int 11)
11411 (const_int 13) (const_int 13)
11412 (const_int 15) (const_int 15)])))]
11413 "TARGET_AVX512F && TARGET_EVEX512"
11414 "vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
11415 [(set_attr "type" "sse")
11416 (set_attr "prefix" "evex")
11417 (set_attr "mode" "V16SF")])
11418
11419 (define_insn "avx_movsldup256<mask_name>"
11420 [(set (match_operand:V8SF 0 "register_operand" "=v")
11421 (vec_select:V8SF
11422 (vec_concat:V16SF
11423 (match_operand:V8SF 1 "nonimmediate_operand" "vm")
11424 (match_dup 1))
11425 (parallel [(const_int 0) (const_int 0)
11426 (const_int 2) (const_int 2)
11427 (const_int 4) (const_int 4)
11428 (const_int 6) (const_int 6)])))]
11429 "TARGET_AVX && <mask_avx512vl_condition>"
11430 "vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
11431 [(set_attr "type" "sse")
11432 (set_attr "prefix" "vex")
11433 (set_attr "mode" "V8SF")])
11434
11435 (define_insn "sse3_movsldup<mask_name>"
11436 [(set (match_operand:V4SF 0 "register_operand" "=v")
11437 (vec_select:V4SF
11438 (vec_concat:V8SF
11439 (match_operand:V4SF 1 "vector_operand" "vBm")
11440 (match_dup 1))
11441 (parallel [(const_int 0)
11442 (const_int 0)
11443 (const_int 6)
11444 (const_int 6)])))]
11445 "TARGET_SSE3 && <mask_avx512vl_condition>"
11446 "%vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
11447 [(set_attr "type" "sse")
11448 (set_attr "prefix_rep" "1")
11449 (set_attr "prefix" "maybe_vex")
11450 (set_attr "mode" "V4SF")])
11451
11452 (define_insn "<mask_codefor>avx512f_movsldup512<mask_name>"
11453 [(set (match_operand:V16SF 0 "register_operand" "=v")
11454 (vec_select:V16SF
11455 (vec_concat:V32SF
11456 (match_operand:V16SF 1 "nonimmediate_operand" "vm")
11457 (match_dup 1))
11458 (parallel [(const_int 0) (const_int 0)
11459 (const_int 2) (const_int 2)
11460 (const_int 4) (const_int 4)
11461 (const_int 6) (const_int 6)
11462 (const_int 8) (const_int 8)
11463 (const_int 10) (const_int 10)
11464 (const_int 12) (const_int 12)
11465 (const_int 14) (const_int 14)])))]
11466 "TARGET_AVX512F && TARGET_EVEX512"
11467 "vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
11468 [(set_attr "type" "sse")
11469 (set_attr "prefix" "evex")
11470 (set_attr "mode" "V16SF")])
11471
11472 (define_expand "avx_shufps256<mask_expand4_name>"
11473 [(match_operand:V8SF 0 "register_operand")
11474 (match_operand:V8SF 1 "register_operand")
11475 (match_operand:V8SF 2 "nonimmediate_operand")
11476 (match_operand:SI 3 "const_int_operand")]
11477 "TARGET_AVX"
11478 {
11479 int mask = INTVAL (operands[3]);
11480 emit_insn (gen_avx_shufps256_1<mask_expand4_name> (operands[0],
11481 operands[1],
11482 operands[2],
11483 GEN_INT ((mask >> 0) & 3),
11484 GEN_INT ((mask >> 2) & 3),
11485 GEN_INT (((mask >> 4) & 3) + 8),
11486 GEN_INT (((mask >> 6) & 3) + 8),
11487 GEN_INT (((mask >> 0) & 3) + 4),
11488 GEN_INT (((mask >> 2) & 3) + 4),
11489 GEN_INT (((mask >> 4) & 3) + 12),
11490 GEN_INT (((mask >> 6) & 3) + 12)
11491 <mask_expand4_args>));
11492 DONE;
11493 })
11494
11495 ;; One bit in mask selects 2 elements.
11496 (define_insn "avx_shufps256_1<mask_name>"
11497 [(set (match_operand:V8SF 0 "register_operand" "=v")
11498 (vec_select:V8SF
11499 (vec_concat:V16SF
11500 (match_operand:V8SF 1 "register_operand" "v")
11501 (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
11502 (parallel [(match_operand 3 "const_0_to_3_operand" )
11503 (match_operand 4 "const_0_to_3_operand" )
11504 (match_operand 5 "const_8_to_11_operand" )
11505 (match_operand 6 "const_8_to_11_operand" )
11506 (match_operand 7 "const_4_to_7_operand" )
11507 (match_operand 8 "const_4_to_7_operand" )
11508 (match_operand 9 "const_12_to_15_operand")
11509 (match_operand 10 "const_12_to_15_operand")])))]
11510 "TARGET_AVX
11511 && <mask_avx512vl_condition>
11512 && (INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
11513 && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
11514 && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4)
11515 && INTVAL (operands[6]) == (INTVAL (operands[10]) - 4))"
11516 {
11517 int mask;
11518 mask = INTVAL (operands[3]);
11519 mask |= INTVAL (operands[4]) << 2;
11520 mask |= (INTVAL (operands[5]) - 8) << 4;
11521 mask |= (INTVAL (operands[6]) - 8) << 6;
11522 operands[3] = GEN_INT (mask);
11523
11524 return "vshufps\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
11525 }
11526 [(set_attr "type" "sseshuf")
11527 (set_attr "length_immediate" "1")
11528 (set_attr "prefix" "<mask_prefix>")
11529 (set_attr "mode" "V8SF")])
11530
11531 (define_expand "sse_shufps<mask_expand4_name>"
11532 [(match_operand:V4SF 0 "register_operand")
11533 (match_operand:V4SF 1 "register_operand")
11534 (match_operand:V4SF 2 "vector_operand")
11535 (match_operand:SI 3 "const_int_operand")]
11536 "TARGET_SSE"
11537 {
11538 int mask = INTVAL (operands[3]);
11539 emit_insn (gen_sse_shufps_v4sf<mask_expand4_name> (operands[0],
11540 operands[1],
11541 operands[2],
11542 GEN_INT ((mask >> 0) & 3),
11543 GEN_INT ((mask >> 2) & 3),
11544 GEN_INT (((mask >> 4) & 3) + 4),
11545 GEN_INT (((mask >> 6) & 3) + 4)
11546 <mask_expand4_args>));
11547 DONE;
11548 })
11549
11550 (define_insn "sse_shufps_v4sf_mask"
11551 [(set (match_operand:V4SF 0 "register_operand" "=v")
11552 (vec_merge:V4SF
11553 (vec_select:V4SF
11554 (vec_concat:V8SF
11555 (match_operand:V4SF 1 "register_operand" "v")
11556 (match_operand:V4SF 2 "nonimmediate_operand" "vm"))
11557 (parallel [(match_operand 3 "const_0_to_3_operand")
11558 (match_operand 4 "const_0_to_3_operand")
11559 (match_operand 5 "const_4_to_7_operand")
11560 (match_operand 6 "const_4_to_7_operand")]))
11561 (match_operand:V4SF 7 "nonimm_or_0_operand" "0C")
11562 (match_operand:QI 8 "register_operand" "Yk")))]
11563 "TARGET_AVX512VL"
11564 {
11565 int mask = 0;
11566 mask |= INTVAL (operands[3]) << 0;
11567 mask |= INTVAL (operands[4]) << 2;
11568 mask |= (INTVAL (operands[5]) - 4) << 4;
11569 mask |= (INTVAL (operands[6]) - 4) << 6;
11570 operands[3] = GEN_INT (mask);
11571
11572 return "vshufps\t{%3, %2, %1, %0%{%8%}%N7|%0%{%8%}%N7, %1, %2, %3}";
11573 }
11574 [(set_attr "type" "sseshuf")
11575 (set_attr "length_immediate" "1")
11576 (set_attr "prefix" "evex")
11577 (set_attr "mode" "V4SF")])
11578
11579 (define_insn "sse_shufps_<mode>"
11580 [(set (match_operand:VI4F_128 0 "register_operand" "=x,v")
11581 (vec_select:VI4F_128
11582 (vec_concat:<ssedoublevecmode>
11583 (match_operand:VI4F_128 1 "register_operand" "0,v")
11584 (match_operand:VI4F_128 2 "vector_operand" "xBm,vm"))
11585 (parallel [(match_operand 3 "const_0_to_3_operand")
11586 (match_operand 4 "const_0_to_3_operand")
11587 (match_operand 5 "const_4_to_7_operand")
11588 (match_operand 6 "const_4_to_7_operand")])))]
11589 "TARGET_SSE"
11590 {
11591 int mask = 0;
11592 mask |= INTVAL (operands[3]) << 0;
11593 mask |= INTVAL (operands[4]) << 2;
11594 mask |= (INTVAL (operands[5]) - 4) << 4;
11595 mask |= (INTVAL (operands[6]) - 4) << 6;
11596 operands[3] = GEN_INT (mask);
11597
11598 switch (which_alternative)
11599 {
11600 case 0:
11601 return "shufps\t{%3, %2, %0|%0, %2, %3}";
11602 case 1:
11603 return "vshufps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
11604 default:
11605 gcc_unreachable ();
11606 }
11607 }
11608 [(set_attr "isa" "noavx,avx")
11609 (set_attr "type" "sseshuf")
11610 (set_attr "length_immediate" "1")
11611 (set_attr "prefix" "orig,maybe_evex")
11612 (set_attr "mode" "V4SF")])
11613
11614 (define_insn "sse_storehps"
11615 [(set (match_operand:V2SF 0 "nonimmediate_operand" "=m,v,v")
11616 (vec_select:V2SF
11617 (match_operand:V4SF 1 "nonimmediate_operand" "v,v,o")
11618 (parallel [(const_int 2) (const_int 3)])))]
11619 "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
11620 "@
11621 %vmovhps\t{%1, %0|%q0, %1}
11622 %vmovhlps\t{%1, %d0|%d0, %1}
11623 %vmovlps\t{%H1, %d0|%d0, %H1}"
11624 [(set_attr "type" "ssemov")
11625 (set_attr "prefix" "maybe_vex")
11626 (set_attr "mode" "V2SF,V4SF,V2SF")])
11627
11628 (define_expand "sse_loadhps_exp"
11629 [(set (match_operand:V4SF 0 "nonimmediate_operand")
11630 (vec_concat:V4SF
11631 (vec_select:V2SF
11632 (match_operand:V4SF 1 "nonimmediate_operand")
11633 (parallel [(const_int 0) (const_int 1)]))
11634 (match_operand:V2SF 2 "nonimmediate_operand")))]
11635 "TARGET_SSE"
11636 {
11637 rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
11638
11639 emit_insn (gen_sse_loadhps (dst, operands[1], operands[2]));
11640
11641 /* Fix up the destination if needed. */
11642 if (dst != operands[0])
11643 emit_move_insn (operands[0], dst);
11644
11645 DONE;
11646 })
11647
11648 (define_insn "sse_loadhps"
11649 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,v,x,v,o")
11650 (vec_concat:V4SF
11651 (vec_select:V2SF
11652 (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
11653 (parallel [(const_int 0) (const_int 1)]))
11654 (match_operand:V2SF 2 "nonimmediate_operand" " m,m,x,v,v")))]
11655 "TARGET_SSE"
11656 "@
11657 movhps\t{%2, %0|%0, %q2}
11658 vmovhps\t{%2, %1, %0|%0, %1, %q2}
11659 movlhps\t{%2, %0|%0, %2}
11660 vmovlhps\t{%2, %1, %0|%0, %1, %2}
11661 %vmovlps\t{%2, %H0|%H0, %2}"
11662 [(set_attr "isa" "noavx,avx,noavx,avx,*")
11663 (set_attr "type" "ssemov2")
11664 (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
11665 (set_attr "mode" "V2SF,V2SF,V4SF,V4SF,V2SF")])
11666
11667 (define_insn "sse_storelps"
11668 [(set (match_operand:V2SF 0 "nonimmediate_operand" "=m,v,v")
11669 (vec_select:V2SF
11670 (match_operand:V4SF 1 "nonimmediate_operand" " v,v,m")
11671 (parallel [(const_int 0) (const_int 1)])))]
11672 "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
11673 "@
11674 %vmovlps\t{%1, %0|%q0, %1}
11675 %vmovaps\t{%1, %0|%0, %1}
11676 %vmovlps\t{%1, %d0|%d0, %q1}"
11677 [(set_attr "type" "ssemov")
11678 (set_attr "prefix" "maybe_vex")
11679 (set_attr "mode" "V2SF,V4SF,V2SF")])
11680
11681 (define_expand "sse_loadlps_exp"
11682 [(set (match_operand:V4SF 0 "nonimmediate_operand")
11683 (vec_concat:V4SF
11684 (match_operand:V2SF 2 "nonimmediate_operand")
11685 (vec_select:V2SF
11686 (match_operand:V4SF 1 "nonimmediate_operand")
11687 (parallel [(const_int 2) (const_int 3)]))))]
11688 "TARGET_SSE"
11689 {
11690 rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
11691
11692 emit_insn (gen_sse_loadlps (dst, operands[1], operands[2]));
11693
11694 /* Fix up the destination if needed. */
11695 if (dst != operands[0])
11696 emit_move_insn (operands[0], dst);
11697
11698 DONE;
11699 })
11700
11701 (define_insn "sse_loadlps"
11702 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,v,x,v,m")
11703 (vec_concat:V4SF
11704 (match_operand:V2SF 2 "nonimmediate_operand" " 0,v,m,m,v")
11705 (vec_select:V2SF
11706 (match_operand:V4SF 1 "nonimmediate_operand" " x,v,0,v,0")
11707 (parallel [(const_int 2) (const_int 3)]))))]
11708 "TARGET_SSE"
11709 "@
11710 shufps\t{$0xe4, %1, %0|%0, %1, 0xe4}
11711 vshufps\t{$0xe4, %1, %2, %0|%0, %2, %1, 0xe4}
11712 movlps\t{%2, %0|%0, %q2}
11713 vmovlps\t{%2, %1, %0|%0, %1, %q2}
11714 %vmovlps\t{%2, %0|%q0, %2}"
11715 [(set_attr "isa" "noavx,avx,noavx,avx,*")
11716 (set_attr "type" "sseshuf,sseshuf,ssemov2,ssemov2,ssemov")
11717 (set (attr "length_immediate")
11718 (if_then_else (eq_attr "alternative" "0,1")
11719 (const_string "1")
11720 (const_string "*")))
11721 (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
11722 (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
11723
11724 (define_insn "sse_movss_<mode>"
11725 [(set (match_operand:VI4F_128 0 "register_operand" "=x,v,v")
11726 (vec_merge:VI4F_128
11727 (match_operand:VI4F_128 2 "register_operand" " x,v,v")
11728 (match_operand:VI4F_128 1 "reg_or_0_operand" " 0,v,C")
11729 (const_int 1)))]
11730 "TARGET_SSE"
11731 "@
11732 movss\t{%2, %0|%0, %2}
11733 vmovss\t{%2, %1, %0|%0, %1, %2}
11734 vmovd\t{%2, %0|%0, %2}"
11735 [(set_attr "isa" "noavx,avx,avx10_2")
11736 (set_attr "type" "ssemov")
11737 (set_attr "prefix" "orig,maybe_evex,evex")
11738 (set_attr "mode" "SF,SF,SI")])
11739
11740 (define_insn "avx2_vec_dup<mode>"
11741 [(set (match_operand:VF1_128_256 0 "register_operand" "=v")
11742 (vec_duplicate:VF1_128_256
11743 (vec_select:SF
11744 (match_operand:V4SF 1 "register_operand" "v")
11745 (parallel [(const_int 0)]))))]
11746 "TARGET_AVX2"
11747 "vbroadcastss\t{%1, %0|%0, %1}"
11748 [(set_attr "type" "sselog1")
11749 (set_attr "prefix" "maybe_evex")
11750 (set_attr "mode" "<MODE>")])
11751
11752 (define_insn "avx2_vec_dupv8sf_1"
11753 [(set (match_operand:V8SF 0 "register_operand" "=v")
11754 (vec_duplicate:V8SF
11755 (vec_select:SF
11756 (match_operand:V8SF 1 "register_operand" "v")
11757 (parallel [(const_int 0)]))))]
11758 "TARGET_AVX2"
11759 "vbroadcastss\t{%x1, %0|%0, %x1}"
11760 [(set_attr "type" "sselog1")
11761 (set_attr "prefix" "maybe_evex")
11762 (set_attr "mode" "V8SF")])
11763
11764 (define_insn "avx512f_vec_dup<mode>_1"
11765 [(set (match_operand:VF_512 0 "register_operand" "=v")
11766 (vec_duplicate:VF_512
11767 (vec_select:<ssescalarmode>
11768 (match_operand:VF_512 1 "register_operand" "v")
11769 (parallel [(const_int 0)]))))]
11770 "TARGET_AVX512F"
11771 "vbroadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}"
11772 [(set_attr "type" "sselog1")
11773 (set_attr "prefix" "evex")
11774 (set_attr "mode" "<MODE>")])
11775
11776 ;; Although insertps takes register source, we prefer
11777 ;; unpcklps with register source since it is shorter.
11778 (define_insn "*vec_concatv2sf_sse4_1"
11779 [(set (match_operand:V2SF 0 "register_operand"
11780 "=Yr,*x, v,Yr,*x,v,v,*y ,*y")
11781 (vec_concat:V2SF
11782 (match_operand:SF 1 "nonimmediate_operand"
11783 " 0, 0,Yv, 0,0, v,m, 0 , m")
11784 (match_operand:SF 2 "nonimm_or_0_operand"
11785 " Yr,*x,Yv, jm,jm, m,C,*ym, C")))]
11786 "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11787 "@
11788 unpcklps\t{%2, %0|%0, %2}
11789 unpcklps\t{%2, %0|%0, %2}
11790 vunpcklps\t{%2, %1, %0|%0, %1, %2}
11791 insertps\t{$0x10, %2, %0|%0, %2, 0x10}
11792 insertps\t{$0x10, %2, %0|%0, %2, 0x10}
11793 vinsertps\t{$0x10, %2, %1, %0|%0, %1, %2, 0x10}
11794 %vmovss\t{%1, %0|%0, %1}
11795 punpckldq\t{%2, %0|%0, %2}
11796 movd\t{%1, %0|%0, %1}"
11797 [(set (attr "isa")
11798 (cond [(eq_attr "alternative" "0,1,3,4")
11799 (const_string "noavx")
11800 (eq_attr "alternative" "2,5")
11801 (const_string "avx")
11802 ]
11803 (const_string "*")))
11804 (set (attr "type")
11805 (cond [(eq_attr "alternative" "6")
11806 (const_string "ssemov")
11807 (eq_attr "alternative" "7")
11808 (const_string "mmxcvt")
11809 (eq_attr "alternative" "8")
11810 (const_string "mmxmov")
11811 ]
11812 (const_string "sselog")))
11813 (set (attr "mmx_isa")
11814 (if_then_else (eq_attr "alternative" "7,8")
11815 (const_string "native")
11816 (const_string "*")))
11817 (set (attr "addr")
11818 (if_then_else (eq_attr "alternative" "3,4")
11819 (const_string "gpr16")
11820 (const_string "*")))
11821 (set (attr "prefix_data16")
11822 (if_then_else (eq_attr "alternative" "3,4")
11823 (const_string "1")
11824 (const_string "*")))
11825 (set (attr "prefix_extra")
11826 (if_then_else (eq_attr "alternative" "3,4,5")
11827 (const_string "1")
11828 (const_string "*")))
11829 (set (attr "length_immediate")
11830 (if_then_else (eq_attr "alternative" "3,4,5")
11831 (const_string "1")
11832 (const_string "*")))
11833 (set (attr "prefix")
11834 (cond [(eq_attr "alternative" "2,5")
11835 (const_string "maybe_evex")
11836 (eq_attr "alternative" "6")
11837 (const_string "maybe_vex")
11838 ]
11839 (const_string "orig")))
11840 (set_attr "mode" "V4SF,V4SF,V4SF,V4SF,V4SF,V4SF,SF,DI,DI")])
11841
11842 ;; ??? In theory we can match memory for the MMX alternative, but allowing
11843 ;; vector_operand for operand 2 and *not* allowing memory for the SSE
11844 ;; alternatives pretty much forces the MMX alternative to be chosen.
11845 (define_insn "*vec_concatv2sf_sse"
11846 [(set (match_operand:V2SF 0 "register_operand" "=x,x,*y,*y")
11847 (vec_concat:V2SF
11848 (match_operand:SF 1 "nonimmediate_operand" " 0,m, 0, m")
11849 (match_operand:SF 2 "reg_or_0_operand" " x,C,*y, C")))]
11850 "TARGET_SSE"
11851 "@
11852 unpcklps\t{%2, %0|%0, %2}
11853 movss\t{%1, %0|%0, %1}
11854 punpckldq\t{%2, %0|%0, %2}
11855 movd\t{%1, %0|%0, %1}"
11856 [(set_attr "mmx_isa" "*,*,native,native")
11857 (set_attr "type" "sselog,ssemov,mmxcvt,mmxmov")
11858 (set_attr "mode" "V4SF,SF,DI,DI")])
11859
11860 (define_insn "*vec_concat<mode>"
11861 [(set (match_operand:V24F_128 0 "register_operand" "=x,v,x,v")
11862 (vec_concat:V24F_128
11863 (match_operand:<ssehalfvecmode> 1 "register_operand" " 0,v,0,v")
11864 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" " x,v,m,m")))]
11865 "TARGET_SSE"
11866 "@
11867 movlhps\t{%2, %0|%0, %2}
11868 vmovlhps\t{%2, %1, %0|%0, %1, %2}
11869 movhps\t{%2, %0|%0, %q2}
11870 vmovhps\t{%2, %1, %0|%0, %1, %q2}"
11871 [(set_attr "isa" "noavx,avx,noavx,avx")
11872 (set_attr "type" "ssemov2")
11873 (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex")
11874 (set_attr "mode" "V4SF,V4SF,V2SF,V2SF")])
11875
11876 (define_insn "*vec_concat<mode>_0"
11877 [(set (match_operand:V24F_128 0 "register_operand" "=v")
11878 (vec_concat:V24F_128
11879 (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "vm")
11880 (match_operand:<ssehalfvecmode> 2 "const0_operand")))]
11881 "TARGET_SSE2"
11882 "%vmovq\t{%1, %0|%0, %1}"
11883 [(set_attr "type" "ssemov")
11884 (set_attr "prefix" "maybe_vex")
11885 (set_attr "mode" "DF")])
11886
11887 (define_insn "*vec_concat<mmxxmmmodelower>_movss"
11888 [(set (match_operand:<mmxxmmmode> 0 "register_operand" "=x,v,v")
11889 (vec_merge:<mmxxmmmode>
11890 (vec_duplicate:<mmxxmmmode>
11891 (match_operand:V2FI_32 2 "nonimmediate_operand" "x,m,v"))
11892 (match_operand:<mmxxmmmode> 1 "reg_or_0_operand" "0,C,v" )
11893 (const_int 3)))]
11894 "TARGET_SSE"
11895 "@
11896 movss\t{%2, %0|%0, %2}
11897 %vmovss\t{%2, %0|%0, %2}
11898 vmovss\t{%2, %1, %0|%0, %1, %2}"
11899 [(set_attr "isa" "noavx,*,avx")
11900 (set_attr "type" "ssemov")
11901 (set_attr "prefix" "orig,maybe_vex,maybe_vex")
11902 (set_attr "mode" "SF")])
11903
11904 ;; Avoid combining registers from different units in a single alternative,
11905 ;; see comment above inline_secondary_memory_needed function in i386.cc
11906 (define_insn "vec_set<mode>_0"
11907 [(set (match_operand:VI4F_128 0 "nonimmediate_operand"
11908 "=Yr,*x,v,v,v,v,x,x,v,Yr ,?x ,x ,m ,m ,m")
11909 (vec_merge:VI4F_128
11910 (vec_duplicate:VI4F_128
11911 (match_operand:<ssescalarmode> 2 "general_operand"
11912 " Yr,*x,v,v,m,r ,m,x,v,?jrjm,?jrjm,?rm,!x,?re,!*fF"))
11913 (match_operand:VI4F_128 1 "nonimm_or_0_operand"
11914 " C , C,C,C,C,C ,C,0,v,0 ,0 ,x ,0 ,0 ,0")
11915 (const_int 1)))]
11916 "TARGET_SSE"
11917 "@
11918 insertps\t{$0xe, %2, %0|%0, %2, 0xe}
11919 insertps\t{$0xe, %2, %0|%0, %2, 0xe}
11920 vmovd\t{%2, %0|%0, %2}
11921 vinsertps\t{$0xe, %2, %2, %0|%0, %2, %2, 0xe}
11922 %vmov<ssescalarmodesuffix>\t{%2, %0|%0, %2}
11923 %vmovd\t{%2, %0|%0, %2}
11924 movss\t{%2, %0|%0, %2}
11925 movss\t{%2, %0|%0, %2}
11926 vmovss\t{%2, %1, %0|%0, %1, %2}
11927 pinsrd\t{$0, %2, %0|%0, %2, 0}
11928 pinsrd\t{$0, %2, %0|%0, %2, 0}
11929 vpinsrd\t{$0, %2, %1, %0|%0, %1, %2, 0}
11930 #
11931 #
11932 #"
11933 [(set (attr "isa")
11934 (cond [(eq_attr "alternative" "0,1,9,10")
11935 (const_string "sse4_noavx")
11936 (eq_attr "alternative" "2")
11937 (const_string "avx10_2")
11938 (eq_attr "alternative" "3,8,11")
11939 (const_string "avx")
11940 (eq_attr "alternative" "4,5")
11941 (const_string "sse2")
11942 (eq_attr "alternative" "6,7")
11943 (const_string "noavx")
11944 ]
11945 (const_string "*")))
11946 (set (attr "type")
11947 (cond [(eq_attr "alternative" "0,1,3,9,10,11")
11948 (const_string "sselog")
11949 (eq_attr "alternative" "13")
11950 (const_string "imov")
11951 (eq_attr "alternative" "14")
11952 (const_string "fmov")
11953 (eq_attr "alternative" "4,6")
11954 (const_string "ssemov2")
11955 ]
11956 (const_string "ssemov")))
11957 (set (attr "c86_attr")
11958 (if_then_else (eq_attr "alternative" "9,10,11")
11959 (const_string "insr")
11960 (const_string "*")))
11961 (set (attr "addr")
11962 (if_then_else (eq_attr "alternative" "9,10")
11963 (const_string "gpr16")
11964 (const_string "*")))
11965 (set (attr "prefix_extra")
11966 (if_then_else (eq_attr "alternative" "9,10,11")
11967 (const_string "1")
11968 (const_string "*")))
11969 (set (attr "length_immediate")
11970 (if_then_else (eq_attr "alternative" "9,10,11")
11971 (const_string "1")
11972 (const_string "*")))
11973 (set (attr "prefix")
11974 (cond [(eq_attr "alternative" "0,1,6,7,9,10")
11975 (const_string "orig")
11976 (eq_attr "alternative" "2,3")
11977 (const_string "maybe_evex")
11978 (eq_attr "alternative" "4,5")
11979 (const_string "maybe_vex")
11980 (eq_attr "alternative" "8,11")
11981 (const_string "vex")
11982 ]
11983 (const_string "*")))
11984 (set_attr "mode" "SF,SF,SI,SF,<ssescalarmode>,SI,SF,SF,SF,TI,TI,TI,*,*,*")
11985 (set (attr "preferred_for_speed")
11986 (cond [(eq_attr "alternative" "5")
11987 (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
11988 ]
11989 (symbol_ref "true")))])
11990
11991 (define_insn "@vec_set<mode>_0"
11992 [(set (match_operand:V8_128 0 "register_operand"
11993 "=v,v,v,v,x,x,Yr,*x,x,x,x,v,v")
11994 (vec_merge:V8_128
11995 (vec_duplicate:V8_128
11996 (match_operand:<ssescalarmode> 2 "nonimmediate_operand"
11997 " r,m,v,v,r,m,Yr,*x,r,m,x,r,m"))
11998 (match_operand:V8_128 1 "reg_or_0_operand"
11999 " C,C,C,v,0,0,0 ,0 ,x,x,x,v,v")
12000 (const_int 1)))]
12001 "TARGET_SSE2"
12002 "@
12003 vmovw\t{%k2, %0|%0, %k2}
12004 vmovw\t{%2, %0|%0, %2}
12005 vmovw\t{%2, %0|%0, %2}
12006 vmovsh\t{%2, %1, %0|%0, %1, %2}
12007 pinsrw\t{$0, %k2, %0|%0, %k2, 0}
12008 pinsrw\t{$0, %2, %0|%0, %2, 0}
12009 pblendw\t{$1, %2, %0|%0, %2, 1}
12010 pblendw\t{$1, %2, %0|%0, %2, 1}
12011 vpinsrw\t{$0, %k2, %1, %0|%0, %1, %k2, 0}
12012 vpinsrw\t{$0, %2, %1, %0|%0, %1, %2, 0}
12013 vpblendw\t{$1, %2, %1, %0|%0, %1, %2, 1}
12014 vpinsrw\t{$0, %k2, %1, %0|%0, %1, %k2, 0}
12015 vpinsrw\t{$0, %2, %1, %0|%0, %1, %2, 0}"
12016 [(set (attr "isa")
12017 (cond [(eq_attr "alternative" "0,1,3")
12018 (const_string "avx512fp16")
12019 (eq_attr "alternative" "2")
12020 (const_string "avx10_2")
12021 (eq_attr "alternative" "4,5")
12022 (const_string "noavx")
12023 (eq_attr "alternative" "6,7")
12024 (const_string "sse4_noavx")
12025 (eq_attr "alternative" "8,9,10")
12026 (const_string "avx")
12027 (eq_attr "alternative" "11,12")
12028 (const_string "avx512bw")
12029 ]
12030 (const_string "*")))
12031 (set (attr "type")
12032 (if_then_else (eq_attr "alternative" "0,1,2,3,6,7,10")
12033 (const_string "ssemov")
12034 (const_string "sselog")))
12035 (set (attr "c86_attr")
12036 (cond [(eq_attr "alternative" "6,7,10")
12037 (const_string "blend")
12038 (eq_attr "alternative" "4,5,8,9,11,12")
12039 (const_string "insr")
12040 ]
12041 (const_string "*")))
12042 (set (attr "prefix_data16")
12043 (if_then_else (eq_attr "alternative" "4,5")
12044 (const_string "1")
12045 (const_string "*")))
12046 (set (attr "prefix_extra")
12047 (if_then_else (eq_attr "alternative" "6,7,10")
12048 (const_string "1")
12049 (const_string "*")))
12050 (set (attr "length_immediate")
12051 (if_then_else (eq_attr "alternative" "0,1,2,3")
12052 (const_string "*")
12053 (const_string "1")))
12054 (set (attr "prefix")
12055 (cond [(eq_attr "alternative" "0,1,2,3,11,12")
12056 (const_string "evex")
12057 (eq_attr "alternative" "8,9,10")
12058 (const_string "vex")
12059 ]
12060 (const_string "orig")))
12061 (set (attr "mode")
12062 (if_then_else (eq_attr "alternative" "0,1,2,3")
12063 (const_string "HF")
12064 (const_string "TI")))
12065 (set (attr "enabled")
12066 (cond [(and (not (match_test "<MODE>mode == V8HFmode || <MODE>mode == V8BFmode"))
12067 (eq_attr "alternative" "3"))
12068 (symbol_ref "false")
12069 ]
12070 (const_string "*")))])
12071
12072 (define_insn_and_split "*vec_set<mode>_0_1"
12073 [(set (match_operand:V8_128 0 "register_operand")
12074 (vec_merge:V8_128
12075 (vec_duplicate:V8_128
12076 (vec_select:<ssescalarmode>
12077 (match_operand:V8_128 2 "nonimmediate_operand")
12078 (parallel [(const_int 0)])))
12079 (match_operand:V8_128 1 "reg_or_0_operand")
12080 (const_int 1)))]
12081 "TARGET_SSE2 && ix86_pre_reload_split ()"
12082 "#"
12083 "&& 1"
12084 [(set (match_dup 0)
12085 (vec_merge:V8_128
12086 (vec_duplicate:V8_128 (match_dup 2))
12087 (match_dup 1)
12088 (const_int 1)))]
12089 {
12090 if (register_operand (operands[2], <MODE>mode))
12091 operands[2] = force_reg (<MODE>mode, operands[2]);
12092 operands[2] = gen_lowpart (<ssescalarmode>mode, operands[2]);
12093 })
12094
12095 ;; vmovw clears also the higher bits
12096 (define_insn "vec_set<mode>_0"
12097 [(set (match_operand:VI2F_256_512 0 "register_operand" "=v,v,v")
12098 (vec_merge:VI2F_256_512
12099 (vec_duplicate:VI2F_256_512
12100 (match_operand:<ssescalarmode> 2 "nonimmediate_operand" "r,m,v"))
12101 (match_operand:VI2F_256_512 1 "const0_operand")
12102 (const_int 1)))]
12103 "TARGET_AVX512FP16"
12104 "@
12105 vmovw\t{%k2, %x0|%x0, %k2}
12106 vmovw\t{%2, %x0|%x0, %2}
12107 vmovw\t{%2, %x0|%x0, %2}"
12108 [(set_attr "isa" "*,*,avx10_2")
12109 (set_attr "type" "ssemov")
12110 (set_attr "prefix" "evex")
12111 (set_attr "mode" "HF")])
12112
12113 (define_insn_and_split "*vec_set<mode>_0_zero_extendhi"
12114 [(set (match_operand:VI48_AVX512F 0 "register_operand")
12115 (vec_merge:VI48_AVX512F
12116 (vec_duplicate:VI48_AVX512F
12117 (zero_extend:<ssescalarmode>
12118 (match_operand:HI 1 "nonimmediate_operand")))
12119 (match_operand:VI48_AVX512F 2 "const0_operand")
12120 (const_int 1)))]
12121 "TARGET_AVX512FP16 && ix86_pre_reload_split ()"
12122 "#"
12123 "&& 1"
12124 [(const_int 0)]
12125 {
12126 rtx dest = gen_reg_rtx (<ssewvecmode>mode);
12127 emit_insn (gen_vec_set<ssewvecmodelower>_0 (dest,
12128 CONST0_RTX (<ssewvecmode>mode),
12129 operands[1]));
12130 emit_move_insn (operands[0],
12131 lowpart_subreg (<MODE>mode, dest, <ssewvecmode>mode));
12132 DONE;
12133 })
12134
12135 (define_insn_and_split "*vec_setv2di_0_zero_extendhi_1"
12136 [(set (match_operand:V2DI 0 "register_operand")
12137 (vec_concat:V2DI
12138 (zero_extend:DI
12139 (match_operand:HI 1 "nonimmediate_operand"))
12140 (const_int 0)))]
12141 "TARGET_AVX512FP16 && ix86_pre_reload_split ()"
12142 "#"
12143 "&& 1"
12144 [(const_int 0)]
12145 {
12146 rtx dest = gen_reg_rtx (V8HImode);
12147 emit_insn (gen_vec_setv8hi_0 (dest, CONST0_RTX (V8HImode), operands[1]));
12148 emit_move_insn (operands[0],
12149 lowpart_subreg (V2DImode, dest, V8HImode));
12150 DONE;
12151 })
12152
12153 (define_insn "avx512fp16_mov<mode>"
12154 [(set (match_operand:V8_128 0 "register_operand" "=v,v")
12155 (vec_merge:V8_128
12156 (match_operand:V8_128 2 "register_operand" "v,v")
12157 (match_operand:V8_128 1 "reg_or_0_operand" "v,C")
12158 (const_int 1)))]
12159 "TARGET_AVX512FP16
12160 || (TARGET_AVX10_2 && const0_operand (operands[1], <MODE>mode))"
12161 "@
12162 vmovsh\t{%2, %1, %0|%0, %1, %2}
12163 vmovw\t{%2, %0|%0, %2}"
12164 [(set_attr "isa" "*,avx10_2")
12165 (set_attr "type" "ssemov")
12166 (set_attr "prefix" "evex")
12167 (set_attr "mode" "HF,HI")])
12168
12169 ;; A subset is vec_setv4sf.
12170 (define_insn "*vec_setv4sf_sse4_1"
12171 [(set (match_operand:V4SF 0 "register_operand" "=Yr,*x,v")
12172 (vec_merge:V4SF
12173 (vec_duplicate:V4SF
12174 (match_operand:SF 2 "nonimmediate_operand" "Yrjm,*xjm,vm"))
12175 (match_operand:V4SF 1 "register_operand" "0,0,v")
12176 (match_operand:SI 3 "const_int_operand")))]
12177 "TARGET_SSE4_1
12178 && ((unsigned) exact_log2 (INTVAL (operands[3]))
12179 < GET_MODE_NUNITS (V4SFmode))"
12180 {
12181 operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])) << 4);
12182 switch (which_alternative)
12183 {
12184 case 0:
12185 case 1:
12186 return "insertps\t{%3, %2, %0|%0, %2, %3}";
12187 case 2:
12188 return "vinsertps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
12189 default:
12190 gcc_unreachable ();
12191 }
12192 }
12193 [(set_attr "isa" "noavx,noavx,avx")
12194 (set_attr "type" "sselog")
12195 (set_attr "addr" "gpr16,gpr16,*")
12196 (set_attr "prefix_data16" "1,1,*")
12197 (set_attr "prefix_extra" "1")
12198 (set_attr "length_immediate" "1")
12199 (set_attr "prefix" "orig,orig,maybe_evex")
12200 (set_attr "mode" "V4SF")])
12201
12202 ;; All of vinsertps, vmovss, vmovd clear also the higher bits.
12203 (define_insn "vec_set<mode>_0"
12204 [(set (match_operand:VI4F_256_512 0 "register_operand" "=v,v,v")
12205 (vec_merge:VI4F_256_512
12206 (vec_duplicate:VI4F_256_512
12207 (match_operand:<ssescalarmode> 2 "nonimmediate_operand" "v,m,r"))
12208 (match_operand:VI4F_256_512 1 "const0_operand")
12209 (const_int 1)))]
12210 "TARGET_AVX"
12211 "@
12212 vinsertps\t{$0xe, %2, %2, %x0|%x0, %2, %2, 0xe}
12213 vmov<ssescalarmodesuffix>\t{%x2, %x0|%x0, %2}
12214 vmovd\t{%2, %x0|%x0, %2}"
12215 [(set (attr "type")
12216 (if_then_else (eq_attr "alternative" "0")
12217 (const_string "sselog")
12218 (const_string "ssemov")))
12219 (set_attr "prefix" "maybe_evex")
12220 (set_attr "mode" "SF,<ssescalarmode>,SI")
12221 (set (attr "preferred_for_speed")
12222 (cond [(eq_attr "alternative" "2")
12223 (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
12224 ]
12225 (symbol_ref "true")))])
12226
12227 (define_insn_and_split "*vec_set<mode>_0_zero_extendsi"
12228 [(set (match_operand:VI8 0 "register_operand")
12229 (vec_merge:VI8
12230 (vec_duplicate:VI8
12231 (zero_extend:DI
12232 (match_operand:SI 1 "nonimmediate_operand")))
12233 (match_operand:VI8 2 "const0_operand")
12234 (const_int 1)))]
12235 "TARGET_SSE2 && ix86_pre_reload_split ()"
12236 "#"
12237 "&& 1"
12238 [(const_int 0)]
12239 {
12240 rtx dest = gen_reg_rtx (<ssepackmode>mode);
12241 emit_insn (gen_vec_set<ssepackmodelower>_0 (dest,
12242 CONST0_RTX (<ssepackmode>mode),
12243 operands[1]));
12244 emit_move_insn (operands[0],
12245 lowpart_subreg (<MODE>mode, dest, <ssepackmode>mode));
12246 DONE;
12247 })
12248
12249 (define_insn_and_split "*vec_setv2di_0_zero_extendsi_1"
12250 [(set (match_operand:V2DI 0 "register_operand")
12251 (vec_concat:V2DI
12252 (zero_extend:DI
12253 (match_operand:SI 1 "nonimmediate_operand"))
12254 (const_int 0)))]
12255 "TARGET_SSE2 && ix86_pre_reload_split ()"
12256 "#"
12257 "&& 1"
12258 [(const_int 0)]
12259 {
12260 rtx dest = gen_reg_rtx (V4SImode);
12261 emit_insn (gen_vec_setv4si_0 (dest, CONST0_RTX (V4SImode), operands[1]));
12262 emit_move_insn (operands[0],
12263 lowpart_subreg (V2DImode, dest, V4SImode));
12264 DONE;
12265 })
12266
12267 (define_insn "@sse4_1_insertps_<mode>"
12268 [(set (match_operand:VI4F_128 0 "register_operand" "=Yr,*x,v")
12269 (unspec:VI4F_128
12270 [(match_operand:VI4F_128 2 "nonimmediate_operand" "Yrjm,*xjm,vm")
12271 (match_operand:VI4F_128 1 "register_operand" "0,0,v")
12272 (match_operand:SI 3 "const_0_to_255_operand")]
12273 UNSPEC_INSERTPS))]
12274 "TARGET_SSE4_1"
12275 {
12276 if (MEM_P (operands[2]))
12277 {
12278 unsigned count_s = INTVAL (operands[3]) >> 6;
12279 if (count_s)
12280 operands[3] = GEN_INT (INTVAL (operands[3]) & 0x3f);
12281 operands[2] = adjust_address_nv (operands[2],
12282 <ssescalarmode>mode, count_s * 4);
12283 }
12284 switch (which_alternative)
12285 {
12286 case 0:
12287 case 1:
12288 return "insertps\t{%3, %2, %0|%0, %2, %3}";
12289 case 2:
12290 return "vinsertps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
12291 default:
12292 gcc_unreachable ();
12293 }
12294 }
12295 [(set_attr "isa" "noavx,noavx,avx")
12296 (set_attr "addr" "gpr16,gpr16,*")
12297 (set_attr "type" "sselog")
12298 (set_attr "prefix_data16" "1,1,*")
12299 (set_attr "prefix_extra" "1")
12300 (set_attr "length_immediate" "1")
12301 (set_attr "prefix" "orig,orig,maybe_evex")
12302 (set_attr "mode" "V4SF")])
12303
12304 (define_split
12305 [(set (match_operand:VI4F_128 0 "memory_operand")
12306 (vec_merge:VI4F_128
12307 (vec_duplicate:VI4F_128
12308 (match_operand:<ssescalarmode> 1 "nonmemory_operand"))
12309 (match_dup 0)
12310 (const_int 1)))]
12311 "TARGET_SSE && reload_completed"
12312 [(set (match_dup 0) (match_dup 1))]
12313 "operands[0] = adjust_address (operands[0], <ssescalarmode>mode, 0);")
12314
12315 ;; Standard scalar operation patterns which preserve the rest of the
12316 ;; vector for combiner.
12317 (define_insn "vec_setv2df_0"
12318 [(set (match_operand:V2DF 0 "register_operand" "=x,v,x,v")
12319 (vec_merge:V2DF
12320 (vec_duplicate:V2DF
12321 (match_operand:DF 2 "nonimmediate_operand" " x,v,m,m"))
12322 (match_operand:V2DF 1 "register_operand" " 0,v,0,v")
12323 (const_int 1)))]
12324 "TARGET_SSE2"
12325 "@
12326 movsd\t{%2, %0|%0, %2}
12327 vmovsd\t{%2, %1, %0|%0, %1, %2}
12328 movlpd\t{%2, %0|%0, %2}
12329 vmovlpd\t{%2, %1, %0|%0, %1, %2}"
12330 [(set_attr "isa" "noavx,avx,noavx,avx")
12331 (set_attr "type" "ssemov2")
12332 (set_attr "mode" "DF")])
12333
12334 (define_expand "vec_set<mode>"
12335 [(match_operand:V_128 0 "register_operand")
12336 (match_operand:<ssescalarmode> 1 "register_operand")
12337 (match_operand 2 "vec_setm_sse41_operand")]
12338 "TARGET_SSE"
12339 {
12340 if (CONST_INT_P (operands[2]))
12341 ix86_expand_vector_set (false, operands[0], operands[1],
12342 INTVAL (operands[2]));
12343 else
12344 ix86_expand_vector_set_var (operands[0], operands[1], operands[2]);
12345 DONE;
12346 })
12347
12348 (define_expand "vec_set<mode>"
12349 [(match_operand:V_256_512 0 "register_operand")
12350 (match_operand:<ssescalarmode> 1 "register_operand")
12351 (match_operand 2 "vec_setm_avx2_operand")]
12352 "TARGET_AVX"
12353 {
12354 if (CONST_INT_P (operands[2]))
12355 ix86_expand_vector_set (false, operands[0], operands[1],
12356 INTVAL (operands[2]));
12357 else
12358 ix86_expand_vector_set_var (operands[0], operands[1], operands[2]);
12359 DONE;
12360 })
12361
12362 (define_insn_and_split "*vec_extractv4sf_0"
12363 [(set (match_operand:SF 0 "nonimmediate_operand" "=v,m,f,r")
12364 (vec_select:SF
12365 (match_operand:V4SF 1 "nonimmediate_operand" "vm,v,m,m")
12366 (parallel [(const_int 0)])))]
12367 "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
12368 "#"
12369 "&& reload_completed"
12370 [(set (match_dup 0) (match_dup 1))]
12371 "operands[1] = gen_lowpart (SFmode, operands[1]);")
12372
12373 (define_insn_and_split "*sse4_1_extractps"
12374 [(set (match_operand:SF 0 "nonimmediate_operand" "=jrjm,jrjm,rm,Yv,Yv")
12375 (vec_select:SF
12376 (match_operand:V4SF 1 "register_operand" "Yr,*x,v,0,v")
12377 (parallel [(match_operand:SI 2 "const_0_to_3_operand")])))]
12378 "TARGET_SSE4_1"
12379 "@
12380 extractps\t{%2, %1, %0|%0, %1, %2}
12381 extractps\t{%2, %1, %0|%0, %1, %2}
12382 vextractps\t{%2, %1, %0|%0, %1, %2}
12383 #
12384 #"
12385 "&& reload_completed && SSE_REG_P (operands[0])"
12386 [(const_int 0)]
12387 {
12388 rtx dest = lowpart_subreg (V4SFmode, operands[0], SFmode);
12389 switch (INTVAL (operands[2]))
12390 {
12391 case 1:
12392 case 3:
12393 emit_insn (gen_sse_shufps_v4sf (dest, operands[1], operands[1],
12394 operands[2], operands[2],
12395 GEN_INT (INTVAL (operands[2]) + 4),
12396 GEN_INT (INTVAL (operands[2]) + 4)));
12397 break;
12398 case 2:
12399 emit_insn (gen_vec_interleave_highv4sf (dest, operands[1], operands[1]));
12400 break;
12401 default:
12402 /* 0 should be handled by the *vec_extractv4sf_0 pattern above. */
12403 gcc_unreachable ();
12404 }
12405 DONE;
12406 }
12407 [(set_attr "isa" "noavx,noavx,avx,noavx,avx")
12408 (set_attr "addr" "gpr16,gpr16,*,*,*")
12409 (set_attr "type" "sselog,sselog,sselog,*,*")
12410 (set_attr "c86_attr" "extr,extr,extr,*,*")
12411 (set_attr "prefix_data16" "1,1,1,*,*")
12412 (set_attr "prefix_extra" "1,1,1,*,*")
12413 (set_attr "length_immediate" "1,1,1,*,*")
12414 (set_attr "prefix" "orig,orig,maybe_evex,*,*")
12415 (set_attr "mode" "V4SF,V4SF,V4SF,*,*")])
12416
12417 (define_insn_and_split "*vec_extractv4sf_mem"
12418 [(set (match_operand:SF 0 "register_operand" "=v,?r,f")
12419 (vec_select:SF
12420 (match_operand:V4SF 1 "memory_operand" "o,o,o")
12421 (parallel [(match_operand 2 "const_0_to_3_operand")])))]
12422 "TARGET_SSE"
12423 "#"
12424 "&& reload_completed"
12425 [(set (match_dup 0) (match_dup 1))]
12426 {
12427 operands[1] = adjust_address (operands[1], SFmode, INTVAL (operands[2]) * 4);
12428 })
12429
12430 (define_mode_attr extract_type
12431 [(V16SF "avx512f") (V16SI "avx512f") (V8DF "avx512dq") (V8DI "avx512dq")])
12432
12433 (define_mode_attr extract_suf
12434 [(V16SF "32x4") (V16SI "32x4") (V8DF "64x2") (V8DI "64x2")
12435 (V8SF "32x4") (V8SI "32x4") (V4DF "64x2") (V4DI "64x2")])
12436
12437 (define_mode_iterator AVX512_VEC
12438 [(V8DF "TARGET_AVX512DQ && TARGET_EVEX512")
12439 (V8DI "TARGET_AVX512DQ && TARGET_EVEX512")
12440 (V16SF "TARGET_EVEX512") (V16SI "TARGET_EVEX512")])
12441
12442 (define_expand "<extract_type>_vextract<shuffletype><extract_suf>_mask"
12443 [(match_operand:<ssequartermode> 0 "nonimmediate_operand")
12444 (match_operand:AVX512_VEC 1 "register_operand")
12445 (match_operand:SI 2 "const_0_to_3_operand")
12446 (match_operand:<ssequartermode> 3 "nonimmediate_operand")
12447 (match_operand:QI 4 "register_operand")]
12448 "TARGET_AVX512F"
12449 {
12450 int mask;
12451 mask = INTVAL (operands[2]);
12452 rtx dest = operands[0];
12453
12454 if (MEM_P (operands[0]) && !rtx_equal_p (operands[0], operands[3]))
12455 dest = gen_reg_rtx (<ssequartermode>mode);
12456
12457 if (<MODE>mode == V16SImode || <MODE>mode == V16SFmode)
12458 emit_insn (gen_avx512f_vextract<shuffletype>32x4_1_mask (dest,
12459 operands[1], GEN_INT (mask * 4), GEN_INT (mask * 4 + 1),
12460 GEN_INT (mask * 4 + 2), GEN_INT (mask * 4 + 3), operands[3],
12461 operands[4]));
12462 else
12463 emit_insn (gen_avx512dq_vextract<shuffletype>64x2_1_mask (dest,
12464 operands[1], GEN_INT (mask * 2), GEN_INT (mask * 2 + 1), operands[3],
12465 operands[4]));
12466 if (dest != operands[0])
12467 emit_move_insn (operands[0], dest);
12468 DONE;
12469 })
12470
12471 (define_insn "avx512dq_vextract<shuffletype>64x2_1_mask"
12472 [(set (match_operand:<ssequartermode> 0 "nonimmediate_operand" "=v,m")
12473 (vec_merge:<ssequartermode>
12474 (vec_select:<ssequartermode>
12475 (match_operand:V8FI 1 "register_operand" "v,v")
12476 (parallel [(match_operand 2 "const_0_to_7_operand")
12477 (match_operand 3 "const_0_to_7_operand")]))
12478 (match_operand:<ssequartermode> 4 "nonimm_or_0_operand" "0C,0")
12479 (match_operand:QI 5 "register_operand" "Yk,Yk")))]
12480 "TARGET_AVX512DQ
12481 && INTVAL (operands[2]) % 2 == 0
12482 && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
12483 && (!MEM_P (operands[0]) || rtx_equal_p (operands[0], operands[4]))"
12484 {
12485 operands[2] = GEN_INT (INTVAL (operands[2]) >> 1);
12486 return "vextract<shuffletype>64x2\t{%2, %1, %0%{%5%}%N4|%0%{%5%}%N4, %1, %2}";
12487 }
12488 [(set_attr "type" "sselog1")
12489 (set_attr "length_immediate" "1")
12490 (set_attr "prefix" "evex")
12491 (set_attr "mode" "<sseinsnmode>")])
12492
12493 (define_insn "*avx512dq_vextract<shuffletype>64x2_1"
12494 [(set (match_operand:<ssequartermode> 0 "nonimmediate_operand" "=vm")
12495 (vec_select:<ssequartermode>
12496 (match_operand:V8FI 1 "register_operand" "v")
12497 (parallel [(match_operand 2 "const_0_to_7_operand")
12498 (match_operand 3 "const_0_to_7_operand")])))]
12499 "TARGET_AVX512DQ
12500 && INTVAL (operands[2]) % 2 == 0
12501 && INTVAL (operands[2]) == INTVAL (operands[3]) - 1"
12502 {
12503 operands[2] = GEN_INT (INTVAL (operands[2]) >> 1);
12504 return "vextract<shuffletype>64x2\t{%2, %1, %0|%0, %1, %2}";
12505 }
12506 [(set_attr "type" "sselog1")
12507 (set_attr "length_immediate" "1")
12508 (set_attr "prefix" "evex")
12509 (set_attr "mode" "<sseinsnmode>")])
12510
12511 (define_split
12512 [(set (match_operand:<ssequartermode> 0 "nonimmediate_operand")
12513 (vec_select:<ssequartermode>
12514 (match_operand:V8FI 1 "register_operand")
12515 (parallel [(const_int 0) (const_int 1)])))]
12516 "TARGET_AVX512DQ
12517 && reload_completed
12518 && (TARGET_AVX512VL
12519 || REG_P (operands[0])
12520 || !EXT_REX_SSE_REG_P (operands[1]))"
12521 [(set (match_dup 0) (match_dup 1))]
12522 {
12523 if (!TARGET_AVX512VL
12524 && REG_P (operands[0])
12525 && EXT_REX_SSE_REG_P (operands[1]))
12526 operands[0]
12527 = lowpart_subreg (<MODE>mode, operands[0], <ssequartermode>mode);
12528 else
12529 operands[1] = gen_lowpart (<ssequartermode>mode, operands[1]);
12530 })
12531
12532 (define_insn "avx512f_vextract<shuffletype>32x4_1_mask"
12533 [(set (match_operand:<ssequartermode> 0 "nonimmediate_operand" "=v,m")
12534 (vec_merge:<ssequartermode>
12535 (vec_select:<ssequartermode>
12536 (match_operand:V16FI 1 "register_operand" "v,v")
12537 (parallel [(match_operand 2 "const_0_to_15_operand")
12538 (match_operand 3 "const_0_to_15_operand")
12539 (match_operand 4 "const_0_to_15_operand")
12540 (match_operand 5 "const_0_to_15_operand")]))
12541 (match_operand:<ssequartermode> 6 "nonimm_or_0_operand" "0C,0")
12542 (match_operand:QI 7 "register_operand" "Yk,Yk")))]
12543 "TARGET_AVX512F
12544 && INTVAL (operands[2]) % 4 == 0
12545 && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
12546 && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
12547 && INTVAL (operands[4]) == INTVAL (operands[5]) - 1
12548 && (!MEM_P (operands[0]) || rtx_equal_p (operands[0], operands[6]))"
12549 {
12550 operands[2] = GEN_INT (INTVAL (operands[2]) >> 2);
12551 return "vextract<shuffletype>32x4\t{%2, %1, %0%{%7%}%N6|%0%{%7%}%N6, %1, %2}";
12552 }
12553 [(set_attr "type" "sselog1")
12554 (set_attr "length_immediate" "1")
12555 (set_attr "prefix" "evex")
12556 (set_attr "mode" "<sseinsnmode>")])
12557
12558 (define_insn "*avx512f_vextract<shuffletype>32x4_1"
12559 [(set (match_operand:<ssequartermode> 0 "nonimmediate_operand" "=vm")
12560 (vec_select:<ssequartermode>
12561 (match_operand:V16FI 1 "register_operand" "v")
12562 (parallel [(match_operand 2 "const_0_to_15_operand")
12563 (match_operand 3 "const_0_to_15_operand")
12564 (match_operand 4 "const_0_to_15_operand")
12565 (match_operand 5 "const_0_to_15_operand")])))]
12566 "TARGET_AVX512F
12567 && INTVAL (operands[2]) % 4 == 0
12568 && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
12569 && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
12570 && INTVAL (operands[4]) == INTVAL (operands[5]) - 1"
12571 {
12572 operands[2] = GEN_INT (INTVAL (operands[2]) >> 2);
12573 return "vextract<shuffletype>32x4\t{%2, %1, %0|%0, %1, %2}";
12574 }
12575 [(set_attr "type" "sselog1")
12576 (set_attr "length_immediate" "1")
12577 (set_attr "prefix" "evex")
12578 (set_attr "mode" "<sseinsnmode>")])
12579
12580 (define_split
12581 [(set (match_operand:<ssequartermode> 0 "nonimmediate_operand")
12582 (vec_select:<ssequartermode>
12583 (match_operand:V16FI 1 "register_operand")
12584 (parallel [(const_int 0) (const_int 1)
12585 (const_int 2) (const_int 3)])))]
12586 "TARGET_AVX512F
12587 && reload_completed
12588 && (TARGET_AVX512VL
12589 || REG_P (operands[0])
12590 || !EXT_REX_SSE_REG_P (operands[1]))"
12591 [(set (match_dup 0) (match_dup 1))]
12592 {
12593 if (!TARGET_AVX512VL
12594 && REG_P (operands[0])
12595 && EXT_REX_SSE_REG_P (operands[1]))
12596 operands[0]
12597 = lowpart_subreg (<MODE>mode, operands[0], <ssequartermode>mode);
12598 else
12599 operands[1] = gen_lowpart (<ssequartermode>mode, operands[1]);
12600 })
12601
12602 (define_mode_attr extract_type_2
12603 [(V16SF "avx512dq") (V16SI "avx512dq") (V8DF "avx512f") (V8DI "avx512f")])
12604
12605 (define_mode_attr extract_suf_2
12606 [(V16SF "32x8") (V16SI "32x8") (V8DF "64x4") (V8DI "64x4")])
12607
12608 (define_mode_iterator AVX512_VEC_2
12609 [(V16SF "TARGET_AVX512DQ && TARGET_EVEX512")
12610 (V16SI "TARGET_AVX512DQ && TARGET_EVEX512")
12611 (V8DF "TARGET_EVEX512") (V8DI "TARGET_EVEX512")])
12612
12613 (define_expand "<extract_type_2>_vextract<shuffletype><extract_suf_2>_mask"
12614 [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
12615 (match_operand:AVX512_VEC_2 1 "register_operand")
12616 (match_operand:SI 2 "const_0_to_1_operand")
12617 (match_operand:<ssehalfvecmode> 3 "nonimmediate_operand")
12618 (match_operand:QI 4 "register_operand")]
12619 "TARGET_AVX512F"
12620 {
12621 rtx (*insn)(rtx, rtx, rtx, rtx);
12622 rtx dest = operands[0];
12623
12624 if (MEM_P (dest) && !rtx_equal_p (dest, operands[3]))
12625 dest = gen_reg_rtx (<ssehalfvecmode>mode);
12626
12627 switch (INTVAL (operands[2]))
12628 {
12629 case 0:
12630 insn = gen_vec_extract_lo_<mode>_mask;
12631 break;
12632 case 1:
12633 insn = gen_vec_extract_hi_<mode>_mask;
12634 break;
12635 default:
12636 gcc_unreachable ();
12637 }
12638
12639 emit_insn (insn (dest, operands[1], operands[3], operands[4]));
12640 if (dest != operands[0])
12641 emit_move_insn (operands[0], dest);
12642 DONE;
12643 })
12644
12645 (define_split
12646 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
12647 (vec_select:<ssehalfvecmode>
12648 (match_operand:V8FI 1 "nonimmediate_operand")
12649 (parallel [(const_int 0) (const_int 1)
12650 (const_int 2) (const_int 3)])))]
12651 "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))
12652 && reload_completed
12653 && (TARGET_AVX512VL
12654 || (REG_P (operands[0]) && !EXT_REX_SSE_REG_P (operands[1])))"
12655 [(set (match_dup 0) (match_dup 1))]
12656 "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
12657
12658 (define_insn "vec_extract_lo_<mode>_mask"
12659 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,m")
12660 (vec_merge:<ssehalfvecmode>
12661 (vec_select:<ssehalfvecmode>
12662 (match_operand:V8FI 1 "register_operand" "v,v")
12663 (parallel [(const_int 0) (const_int 1)
12664 (const_int 2) (const_int 3)]))
12665 (match_operand:<ssehalfvecmode> 2 "nonimm_or_0_operand" "0C,0")
12666 (match_operand:QI 3 "register_operand" "Yk,Yk")))]
12667 "TARGET_AVX512F
12668 && (!MEM_P (operands[0]) || rtx_equal_p (operands[0], operands[2]))"
12669 "vextract<shuffletype>64x4\t{$0x0, %1, %0%{%3%}%N2|%0%{%3%}%N2, %1, 0x0}"
12670 [(set_attr "type" "sselog1")
12671 (set_attr "length_immediate" "1")
12672 (set_attr "memory" "none,store")
12673 (set_attr "prefix" "evex")
12674 (set_attr "mode" "<sseinsnmode>")])
12675
12676 (define_insn "vec_extract_lo_<mode>"
12677 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,vm,v")
12678 (vec_select:<ssehalfvecmode>
12679 (match_operand:V8FI 1 "nonimmediate_operand" "v,v,vm")
12680 (parallel [(const_int 0) (const_int 1)
12681 (const_int 2) (const_int 3)])))]
12682 "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
12683 {
12684 if (!TARGET_AVX512VL && !MEM_P (operands[1]))
12685 return "vextract<shuffletype>64x4\t{$0x0, %1, %0|%0, %1, 0x0}";
12686 else
12687 return "#";
12688 }
12689 [(set_attr "type" "sselog1")
12690 (set_attr "length_immediate" "1")
12691 (set_attr "memory" "none,store,load")
12692 (set_attr "prefix" "evex")
12693 (set_attr "mode" "<sseinsnmode>")])
12694
12695 (define_insn "vec_extract_hi_<mode>_mask"
12696 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,m")
12697 (vec_merge:<ssehalfvecmode>
12698 (vec_select:<ssehalfvecmode>
12699 (match_operand:V8FI 1 "register_operand" "v,v")
12700 (parallel [(const_int 4) (const_int 5)
12701 (const_int 6) (const_int 7)]))
12702 (match_operand:<ssehalfvecmode> 2 "nonimm_or_0_operand" "0C,0")
12703 (match_operand:QI 3 "register_operand" "Yk,Yk")))]
12704 "TARGET_AVX512F
12705 && (!MEM_P (operands[0]) || rtx_equal_p (operands[0], operands[2]))"
12706 "vextract<shuffletype>64x4\t{$0x1, %1, %0%{%3%}%N2|%0%{%3%}%N2, %1, 0x1}"
12707 [(set_attr "type" "sselog1")
12708 (set_attr "length_immediate" "1")
12709 (set_attr "prefix" "evex")
12710 (set_attr "mode" "<sseinsnmode>")])
12711
12712 (define_insn "vec_extract_hi_<mode>"
12713 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=vm")
12714 (vec_select:<ssehalfvecmode>
12715 (match_operand:V8FI 1 "register_operand" "v")
12716 (parallel [(const_int 4) (const_int 5)
12717 (const_int 6) (const_int 7)])))]
12718 "TARGET_AVX512F"
12719 "vextract<shuffletype>64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
12720 [(set_attr "type" "sselog1")
12721 (set_attr "length_immediate" "1")
12722 (set_attr "prefix" "evex")
12723 (set_attr "mode" "<sseinsnmode>")])
12724
12725 (define_insn "vec_extract_hi_<mode>_mask"
12726 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,m")
12727 (vec_merge:<ssehalfvecmode>
12728 (vec_select:<ssehalfvecmode>
12729 (match_operand:V16FI 1 "register_operand" "v,v")
12730 (parallel [(const_int 8) (const_int 9)
12731 (const_int 10) (const_int 11)
12732 (const_int 12) (const_int 13)
12733 (const_int 14) (const_int 15)]))
12734 (match_operand:<ssehalfvecmode> 2 "nonimm_or_0_operand" "0C,0")
12735 (match_operand:QI 3 "register_operand" "Yk,Yk")))]
12736 "TARGET_AVX512DQ
12737 && (!MEM_P (operands[0]) || rtx_equal_p (operands[0], operands[2]))"
12738 "vextract<shuffletype>32x8\t{$0x1, %1, %0%{%3%}%N2|%0%{%3%}%N2, %1, 0x1}"
12739 [(set_attr "type" "sselog1")
12740 (set_attr "length_immediate" "1")
12741 (set_attr "prefix" "evex")
12742 (set_attr "mode" "<sseinsnmode>")])
12743
12744 (define_insn "vec_extract_hi_<mode>"
12745 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=vm,vm")
12746 (vec_select:<ssehalfvecmode>
12747 (match_operand:V16FI 1 "register_operand" "v,v")
12748 (parallel [(const_int 8) (const_int 9)
12749 (const_int 10) (const_int 11)
12750 (const_int 12) (const_int 13)
12751 (const_int 14) (const_int 15)])))]
12752 "TARGET_AVX512F"
12753 "@
12754 vextract<shuffletype>32x8\t{$0x1, %1, %0|%0, %1, 0x1}
12755 vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
12756 [(set_attr "type" "sselog1")
12757 (set_attr "isa" "avx512dq,noavx512dq")
12758 (set_attr "length_immediate" "1")
12759 (set_attr "prefix" "evex")
12760 (set_attr "mode" "<sseinsnmode>")])
12761
12762 (define_mode_iterator VI48F_256_DQ
12763 [V8SI V8SF (V4DI "TARGET_AVX512DQ") (V4DF "TARGET_AVX512DQ")])
12764
12765 (define_expand "avx512vl_vextractf128<mode>"
12766 [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
12767 (match_operand:VI48F_256_DQ 1 "register_operand")
12768 (match_operand:SI 2 "const_0_to_1_operand")
12769 (match_operand:<ssehalfvecmode> 3 "nonimm_or_0_operand")
12770 (match_operand:QI 4 "register_operand")]
12771 "TARGET_AVX512VL"
12772 {
12773 rtx (*insn)(rtx, rtx, rtx, rtx);
12774 rtx dest = operands[0];
12775
12776 if (MEM_P (dest)
12777 && (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 4
12778 /* For V8S[IF]mode there are maskm insns with =m and 0
12779 constraints. */
12780 ? !rtx_equal_p (dest, operands[3])
12781 /* For V4D[IF]mode, hi insns don't allow memory, and
12782 lo insns have =m and 0C constraints. */
12783 : (operands[2] != const0_rtx
12784 || (!rtx_equal_p (dest, operands[3])
12785 && GET_CODE (operands[3]) != CONST_VECTOR))))
12786 dest = gen_reg_rtx (<ssehalfvecmode>mode);
12787 switch (INTVAL (operands[2]))
12788 {
12789 case 0:
12790 insn = gen_vec_extract_lo_<mode>_mask;
12791 break;
12792 case 1:
12793 insn = gen_vec_extract_hi_<mode>_mask;
12794 break;
12795 default:
12796 gcc_unreachable ();
12797 }
12798
12799 emit_insn (insn (dest, operands[1], operands[3], operands[4]));
12800 if (dest != operands[0])
12801 emit_move_insn (operands[0], dest);
12802 DONE;
12803 })
12804
12805 (define_expand "avx_vextractf128<mode>"
12806 [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
12807 (match_operand:V_256 1 "register_operand")
12808 (match_operand:SI 2 "const_0_to_1_operand")]
12809 "TARGET_AVX"
12810 {
12811 rtx (*insn)(rtx, rtx);
12812
12813 switch (INTVAL (operands[2]))
12814 {
12815 case 0:
12816 insn = gen_vec_extract_lo_<mode>;
12817 break;
12818 case 1:
12819 insn = gen_vec_extract_hi_<mode>;
12820 break;
12821 default:
12822 gcc_unreachable ();
12823 }
12824
12825 emit_insn (insn (operands[0], operands[1]));
12826 DONE;
12827 })
12828
12829 (define_insn "vec_extract_lo_<mode>_mask"
12830 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,m")
12831 (vec_merge:<ssehalfvecmode>
12832 (vec_select:<ssehalfvecmode>
12833 (match_operand:V16FI 1 "register_operand" "v,v")
12834 (parallel [(const_int 0) (const_int 1)
12835 (const_int 2) (const_int 3)
12836 (const_int 4) (const_int 5)
12837 (const_int 6) (const_int 7)]))
12838 (match_operand:<ssehalfvecmode> 2 "nonimm_or_0_operand" "0C,0")
12839 (match_operand:QI 3 "register_operand" "Yk,Yk")))]
12840 "TARGET_AVX512DQ
12841 && (!MEM_P (operands[0]) || rtx_equal_p (operands[0], operands[2]))"
12842 "vextract<shuffletype>32x8\t{$0x0, %1, %0%{%3%}%N2|%0%{%3%}%N2, %1, 0x0}"
12843 [(set_attr "type" "sselog1")
12844 (set_attr "length_immediate" "1")
12845 (set_attr "memory" "none,store")
12846 (set_attr "prefix" "evex")
12847 (set_attr "mode" "<sseinsnmode>")])
12848
12849 (define_insn "vec_extract_lo_<mode>"
12850 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,v,m")
12851 (vec_select:<ssehalfvecmode>
12852 (match_operand:V16FI 1 "nonimmediate_operand" "v,m,v")
12853 (parallel [(const_int 0) (const_int 1)
12854 (const_int 2) (const_int 3)
12855 (const_int 4) (const_int 5)
12856 (const_int 6) (const_int 7)])))]
12857 "TARGET_AVX512F
12858 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
12859 {
12860 if (!TARGET_AVX512VL
12861 && !REG_P (operands[0])
12862 && EXT_REX_SSE_REG_P (operands[1]))
12863 {
12864 if (TARGET_AVX512DQ)
12865 return "vextract<shuffletype>32x8\t{$0x0, %1, %0|%0, %1, 0x0}";
12866 else
12867 return "vextract<shuffletype>64x4\t{$0x0, %1, %0|%0, %1, 0x0}";
12868 }
12869 else
12870 return "#";
12871 }
12872 [(set_attr "type" "sselog1")
12873 (set_attr "length_immediate" "1")
12874 (set_attr "memory" "none,load,store")
12875 (set_attr "prefix" "evex")
12876 (set_attr "mode" "<sseinsnmode>")])
12877
12878 (define_split
12879 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
12880 (vec_select:<ssehalfvecmode>
12881 (match_operand:V16FI 1 "nonimmediate_operand")
12882 (parallel [(const_int 0) (const_int 1)
12883 (const_int 2) (const_int 3)
12884 (const_int 4) (const_int 5)
12885 (const_int 6) (const_int 7)])))]
12886 "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))
12887 && reload_completed
12888 && (TARGET_AVX512VL
12889 || REG_P (operands[0])
12890 || !EXT_REX_SSE_REG_P (operands[1]))"
12891 [(set (match_dup 0) (match_dup 1))]
12892 {
12893 if (!TARGET_AVX512VL
12894 && REG_P (operands[0])
12895 && EXT_REX_SSE_REG_P (operands[1]))
12896 operands[0]
12897 = lowpart_subreg (<MODE>mode, operands[0], <ssehalfvecmode>mode);
12898 else
12899 operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);
12900 })
12901
12902 (define_insn "vec_extract_lo_<mode>_mask"
12903 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,m")
12904 (vec_merge:<ssehalfvecmode>
12905 (vec_select:<ssehalfvecmode>
12906 (match_operand:VI8F_256 1 "register_operand" "v,v")
12907 (parallel [(const_int 0) (const_int 1)]))
12908 (match_operand:<ssehalfvecmode> 2 "nonimm_or_0_operand" "0C,0")
12909 (match_operand:QI 3 "register_operand" "Yk,Yk")))]
12910 "TARGET_AVX512DQ
12911 && TARGET_AVX512VL
12912 && (!MEM_P (operands[0]) || rtx_equal_p (operands[0], operands[2]))"
12913 "vextract<shuffletype>64x2\t{$0x0, %1, %0%{%3%}%N2|%0%{%3%}%N2, %1, 0x0}"
12914 [(set_attr "type" "sselog1")
12915 (set_attr "length_immediate" "1")
12916 (set_attr "memory" "none,store")
12917 (set_attr "prefix" "evex")
12918 (set_attr "mode" "XI")])
12919
12920 (define_insn "vec_extract_lo_<mode>"
12921 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=vm,v")
12922 (vec_select:<ssehalfvecmode>
12923 (match_operand:VI8F_256 1 "nonimmediate_operand" "v,vm")
12924 (parallel [(const_int 0) (const_int 1)])))]
12925 "TARGET_AVX
12926 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
12927 "#")
12928
12929 (define_split
12930 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
12931 (vec_select:<ssehalfvecmode>
12932 (match_operand:VI8F_256 1 "nonimmediate_operand")
12933 (parallel [(const_int 0) (const_int 1)])))]
12934 "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))
12935 && reload_completed"
12936 [(set (match_dup 0) (match_dup 1))]
12937 "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
12938
12939 (define_insn "vec_extract_hi_<mode>_mask"
12940 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,m")
12941 (vec_merge:<ssehalfvecmode>
12942 (vec_select:<ssehalfvecmode>
12943 (match_operand:VI8F_256 1 "register_operand" "v,v")
12944 (parallel [(const_int 2) (const_int 3)]))
12945 (match_operand:<ssehalfvecmode> 2 "nonimm_or_0_operand" "0C,0")
12946 (match_operand:QI 3 "register_operand" "Yk,Yk")))]
12947 "TARGET_AVX512DQ
12948 && TARGET_AVX512VL
12949 && (!MEM_P (operands[0]) || rtx_equal_p (operands[0], operands[2]))"
12950 "vextract<shuffletype>64x2\t{$0x1, %1, %0%{%3%}%N2|%0%{%3%}%N2, %1, 0x1}"
12951 [(set_attr "type" "sselog1")
12952 (set_attr "length_immediate" "1")
12953 (set_attr "prefix" "vex")
12954 (set_attr "mode" "<sseinsnmode>")])
12955
12956 (define_insn "vec_extract_hi_<mode>"
12957 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=xjm,vm")
12958 (vec_select:<ssehalfvecmode>
12959 (match_operand:VI8F_256 1 "register_operand" "x,v")
12960 (parallel [(const_int 2) (const_int 3)])))]
12961 "TARGET_AVX"
12962 {
12963 if (TARGET_AVX512VL)
12964 {
12965 if (TARGET_AVX512DQ)
12966 return "vextract<shuffletype>64x2\t{$0x1, %1, %0|%0, %1, 0x1}";
12967 else
12968 return "vextract<shuffletype>32x4\t{$0x1, %1, %0|%0, %1, 0x1}";
12969 }
12970 else
12971 return "vextract<i128>\t{$0x1, %1, %0|%0, %1, 0x1}";
12972 }
12973 [(set_attr "isa" "noavx512vl,avx512vl")
12974 (set_attr "addr" "gpr16,*")
12975 (set_attr "type" "sselog1")
12976 (set_attr "prefix_extra" "1")
12977 (set_attr "length_immediate" "1")
12978 (set_attr "prefix" "vex")
12979 (set_attr "mode" "<sseinsnmode>")])
12980
12981 (define_split
12982 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
12983 (vec_select:<ssehalfvecmode>
12984 (match_operand:VI4F_256 1 "nonimmediate_operand")
12985 (parallel [(const_int 0) (const_int 1)
12986 (const_int 2) (const_int 3)])))]
12987 "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))
12988 && reload_completed"
12989 [(set (match_dup 0) (match_dup 1))]
12990 "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
12991
12992 (define_insn "vec_extract_lo_<mode>_mask"
12993 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,m")
12994 (vec_merge:<ssehalfvecmode>
12995 (vec_select:<ssehalfvecmode>
12996 (match_operand:VI4F_256 1 "register_operand" "v,v")
12997 (parallel [(const_int 0) (const_int 1)
12998 (const_int 2) (const_int 3)]))
12999 (match_operand:<ssehalfvecmode> 2 "nonimm_or_0_operand" "0C,0")
13000 (match_operand:QI 3 "register_operand" "Yk,Yk")))]
13001 "TARGET_AVX512VL
13002 && (!MEM_P (operands[0]) || rtx_equal_p (operands[0], operands[2]))"
13003 "vextract<shuffletype>32x4\t{$0x0, %1, %0%{%3%}%N2|%0%{%3%}%N2, %1, 0x0}"
13004 [(set_attr "type" "sselog1")
13005 (set_attr "length_immediate" "1")
13006 (set_attr "prefix" "evex")
13007 (set_attr "mode" "<sseinsnmode>")])
13008
13009 (define_insn "vec_extract_lo_<mode>"
13010 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=vm,v")
13011 (vec_select:<ssehalfvecmode>
13012 (match_operand:VI4F_256 1 "nonimmediate_operand" "v,vm")
13013 (parallel [(const_int 0) (const_int 1)
13014 (const_int 2) (const_int 3)])))]
13015 "TARGET_AVX
13016 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13017 "#"
13018 [(set_attr "type" "sselog1")
13019 (set_attr "prefix_extra" "1")
13020 (set_attr "length_immediate" "1")
13021 (set_attr "prefix" "evex")
13022 (set_attr "mode" "<sseinsnmode>")])
13023
13024 (define_insn "vec_extract_hi_<mode>_mask"
13025 [(set (match_operand:<ssehalfvecmode> 0 "register_operand" "=v,m")
13026 (vec_merge:<ssehalfvecmode>
13027 (vec_select:<ssehalfvecmode>
13028 (match_operand:VI4F_256 1 "register_operand" "v,v")
13029 (parallel [(const_int 4) (const_int 5)
13030 (const_int 6) (const_int 7)]))
13031 (match_operand:<ssehalfvecmode> 2 "nonimm_or_0_operand" "0C,0")
13032 (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
13033 "TARGET_AVX512VL
13034 && (!MEM_P (operands[0]) || rtx_equal_p (operands[0], operands[2]))"
13035 "vextract<shuffletype>32x4\t{$0x1, %1, %0%{%3%}%N2|%0%{%3%}%N2, %1, 0x1}"
13036 [(set_attr "type" "sselog1")
13037 (set_attr "length_immediate" "1")
13038 (set_attr "prefix" "evex")
13039 (set_attr "mode" "<sseinsnmode>")])
13040
13041 (define_insn "vec_extract_hi_<mode>"
13042 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=xjm, vm")
13043 (vec_select:<ssehalfvecmode>
13044 (match_operand:VI4F_256 1 "register_operand" "x, v")
13045 (parallel [(const_int 4) (const_int 5)
13046 (const_int 6) (const_int 7)])))]
13047 "TARGET_AVX"
13048 "@
13049 vextract<i128>\t{$0x1, %1, %0|%0, %1, 0x1}
13050 vextract<shuffletype>32x4\t{$0x1, %1, %0|%0, %1, 0x1}"
13051 [(set_attr "isa" "noavx512vl, avx512vl")
13052 (set_attr "addr" "gpr16,*")
13053 (set_attr "prefix" "vex, evex")
13054 (set_attr "type" "sselog1")
13055 (set_attr "length_immediate" "1")
13056 (set_attr "mode" "<sseinsnmode>")])
13057
13058 (define_insn_and_split "@vec_extract_lo_<mode>"
13059 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,v,m")
13060 (vec_select:<ssehalfvecmode>
13061 (match_operand:V32_512 1 "nonimmediate_operand" "v,m,v")
13062 (parallel [(const_int 0) (const_int 1)
13063 (const_int 2) (const_int 3)
13064 (const_int 4) (const_int 5)
13065 (const_int 6) (const_int 7)
13066 (const_int 8) (const_int 9)
13067 (const_int 10) (const_int 11)
13068 (const_int 12) (const_int 13)
13069 (const_int 14) (const_int 15)])))]
13070 "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13071 {
13072 if (TARGET_AVX512VL
13073 || REG_P (operands[0])
13074 || !EXT_REX_SSE_REG_P (operands[1]))
13075 return "#";
13076 else
13077 return "vextracti64x4\t{$0x0, %1, %0|%0, %1, 0x0}";
13078 }
13079 "&& reload_completed
13080 && (TARGET_AVX512VL
13081 || REG_P (operands[0])
13082 || !EXT_REX_SSE_REG_P (operands[1]))"
13083 [(set (match_dup 0) (match_dup 1))]
13084 {
13085 if (!TARGET_AVX512VL
13086 && REG_P (operands[0])
13087 && EXT_REX_SSE_REG_P (operands[1]))
13088 operands[0] = lowpart_subreg (<MODE>mode, operands[0],
13089 <ssehalfvecmode>mode);
13090 else
13091 operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);
13092 }
13093 [(set_attr "type" "sselog1")
13094 (set_attr "length_immediate" "1")
13095 (set_attr "memory" "none,load,store")
13096 (set_attr "prefix" "evex")
13097 (set_attr "mode" "XI")])
13098
13099 (define_insn "@vec_extract_hi_<mode>"
13100 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=vm")
13101 (vec_select:<ssehalfvecmode>
13102 (match_operand:V32_512 1 "register_operand" "v")
13103 (parallel [(const_int 16) (const_int 17)
13104 (const_int 18) (const_int 19)
13105 (const_int 20) (const_int 21)
13106 (const_int 22) (const_int 23)
13107 (const_int 24) (const_int 25)
13108 (const_int 26) (const_int 27)
13109 (const_int 28) (const_int 29)
13110 (const_int 30) (const_int 31)])))]
13111 "TARGET_AVX512F"
13112 "vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
13113 [(set_attr "type" "sselog1")
13114 (set_attr "length_immediate" "1")
13115 (set_attr "prefix" "evex")
13116 (set_attr "mode" "XI")])
13117
13118 (define_insn_and_split "@vec_extract_lo_<mode>"
13119 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,m")
13120 (vec_select:<ssehalfvecmode>
13121 (match_operand:V16_256 1 "nonimmediate_operand" "vm,v")
13122 (parallel [(const_int 0) (const_int 1)
13123 (const_int 2) (const_int 3)
13124 (const_int 4) (const_int 5)
13125 (const_int 6) (const_int 7)])))]
13126 "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13127 "#"
13128 "&& reload_completed"
13129 [(set (match_dup 0) (match_dup 1))]
13130 "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
13131
13132 (define_insn "@vec_extract_hi_<mode>"
13133 [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=xjm,vm")
13134 (vec_select:<ssehalfvecmode>
13135 (match_operand:V16_256 1 "register_operand" "x,v")
13136 (parallel [(const_int 8) (const_int 9)
13137 (const_int 10) (const_int 11)
13138 (const_int 12) (const_int 13)
13139 (const_int 14) (const_int 15)])))]
13140 "TARGET_AVX"
13141 "@
13142 vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}
13143 vextracti32x4\t{$0x1, %1, %0|%0, %1, 0x1}"
13144 [(set_attr "type" "sselog1")
13145 (set_attr "prefix_extra" "1")
13146 (set_attr "length_immediate" "1")
13147 (set_attr "isa" "noavx512vl,avx512vl")
13148 (set_attr "addr" "gpr16,*")
13149 (set_attr "prefix" "vex,evex")
13150 (set_attr "mode" "OI")])
13151
13152 (define_insn_and_split "vec_extract_lo_v64qi"
13153 [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,v,m")
13154 (vec_select:V32QI
13155 (match_operand:V64QI 1 "nonimmediate_operand" "v,m,v")
13156 (parallel [(const_int 0) (const_int 1)
13157 (const_int 2) (const_int 3)
13158 (const_int 4) (const_int 5)
13159 (const_int 6) (const_int 7)
13160 (const_int 8) (const_int 9)
13161 (const_int 10) (const_int 11)
13162 (const_int 12) (const_int 13)
13163 (const_int 14) (const_int 15)
13164 (const_int 16) (const_int 17)
13165 (const_int 18) (const_int 19)
13166 (const_int 20) (const_int 21)
13167 (const_int 22) (const_int 23)
13168 (const_int 24) (const_int 25)
13169 (const_int 26) (const_int 27)
13170 (const_int 28) (const_int 29)
13171 (const_int 30) (const_int 31)])))]
13172 "TARGET_AVX512F && TARGET_EVEX512
13173 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13174 {
13175 if (TARGET_AVX512VL
13176 || REG_P (operands[0])
13177 || !EXT_REX_SSE_REG_P (operands[1]))
13178 return "#";
13179 else
13180 return "vextracti64x4\t{$0x0, %1, %0|%0, %1, 0x0}";
13181 }
13182 "&& reload_completed
13183 && (TARGET_AVX512VL
13184 || REG_P (operands[0])
13185 || !EXT_REX_SSE_REG_P (operands[1]))"
13186 [(set (match_dup 0) (match_dup 1))]
13187 {
13188 if (!TARGET_AVX512VL
13189 && REG_P (operands[0])
13190 && EXT_REX_SSE_REG_P (operands[1]))
13191 operands[0] = lowpart_subreg (V64QImode, operands[0], V32QImode);
13192 else
13193 operands[1] = gen_lowpart (V32QImode, operands[1]);
13194 }
13195 [(set_attr "type" "sselog1")
13196 (set_attr "length_immediate" "1")
13197 (set_attr "memory" "none,load,store")
13198 (set_attr "prefix" "evex")
13199 (set_attr "mode" "XI")])
13200
13201 (define_insn "vec_extract_hi_v64qi"
13202 [(set (match_operand:V32QI 0 "nonimmediate_operand" "=vm")
13203 (vec_select:V32QI
13204 (match_operand:V64QI 1 "register_operand" "v")
13205 (parallel [(const_int 32) (const_int 33)
13206 (const_int 34) (const_int 35)
13207 (const_int 36) (const_int 37)
13208 (const_int 38) (const_int 39)
13209 (const_int 40) (const_int 41)
13210 (const_int 42) (const_int 43)
13211 (const_int 44) (const_int 45)
13212 (const_int 46) (const_int 47)
13213 (const_int 48) (const_int 49)
13214 (const_int 50) (const_int 51)
13215 (const_int 52) (const_int 53)
13216 (const_int 54) (const_int 55)
13217 (const_int 56) (const_int 57)
13218 (const_int 58) (const_int 59)
13219 (const_int 60) (const_int 61)
13220 (const_int 62) (const_int 63)])))]
13221 "TARGET_AVX512F && TARGET_EVEX512"
13222 "vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
13223 [(set_attr "type" "sselog1")
13224 (set_attr "length_immediate" "1")
13225 (set_attr "prefix" "evex")
13226 (set_attr "mode" "XI")])
13227
13228 (define_insn_and_split "vec_extract_lo_v32qi"
13229 [(set (match_operand:V16QI 0 "nonimmediate_operand" "=v,m")
13230 (vec_select:V16QI
13231 (match_operand:V32QI 1 "nonimmediate_operand" "vm,v")
13232 (parallel [(const_int 0) (const_int 1)
13233 (const_int 2) (const_int 3)
13234 (const_int 4) (const_int 5)
13235 (const_int 6) (const_int 7)
13236 (const_int 8) (const_int 9)
13237 (const_int 10) (const_int 11)
13238 (const_int 12) (const_int 13)
13239 (const_int 14) (const_int 15)])))]
13240 "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13241 "#"
13242 "&& reload_completed"
13243 [(set (match_dup 0) (match_dup 1))]
13244 "operands[1] = gen_lowpart (V16QImode, operands[1]);")
13245
13246 (define_insn "vec_extract_hi_v32qi"
13247 [(set (match_operand:V16QI 0 "nonimmediate_operand" "=xjm,vm")
13248 (vec_select:V16QI
13249 (match_operand:V32QI 1 "register_operand" "x,v")
13250 (parallel [(const_int 16) (const_int 17)
13251 (const_int 18) (const_int 19)
13252 (const_int 20) (const_int 21)
13253 (const_int 22) (const_int 23)
13254 (const_int 24) (const_int 25)
13255 (const_int 26) (const_int 27)
13256 (const_int 28) (const_int 29)
13257 (const_int 30) (const_int 31)])))]
13258 "TARGET_AVX"
13259 "@
13260 vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}
13261 vextracti32x4\t{$0x1, %1, %0|%0, %1, 0x1}"
13262 [(set_attr "type" "sselog1")
13263 (set_attr "prefix_extra" "1")
13264 (set_attr "length_immediate" "1")
13265 (set_attr "isa" "noavx512vl,avx512vl")
13266 (set_attr "addr" "gpr16,*")
13267 (set_attr "prefix" "vex,evex")
13268 (set_attr "mode" "OI")])
13269
13270 ;; NB: *vec_extract<mode>_0 must be placed before *vec_extracthf.
13271 ;; Otherwise, it will be ignored.
13272 (define_insn_and_split "*vec_extract<mode>_0"
13273 [(set (match_operand:<ssescalarmode> 0 "nonimmediate_operand" "=v,m,r")
13274 (vec_select:<ssescalarmode>
13275 (match_operand:VHFBF 1 "nonimmediate_operand" "vm,v,m")
13276 (parallel [(const_int 0)])))]
13277 "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13278 "#"
13279 "&& reload_completed"
13280 [(set (match_dup 0) (match_dup 1))]
13281 "operands[1] = gen_lowpart (<ssescalarmode>mode, operands[1]);")
13282
13283 (define_insn "*vec_extract<mode>"
13284 [(set (match_operand:HFBF 0 "register_sse4nonimm_operand" "=?r,jm,m,x,Yw")
13285 (vec_select:HFBF
13286 (match_operand:<ssevecmode> 1 "register_operand" "v,x,v,0,YW")
13287 (parallel
13288 [(match_operand:SI 2 "const_0_to_7_operand")])))]
13289 "TARGET_SSE2"
13290 {
13291 switch (which_alternative)
13292 {
13293 case 0:
13294 return "%vpextrw\t{%2, %1, %k0|%k0, %1, %2}";
13295 case 1:
13296 return "pextrw\t{%2, %1, %0|%0, %1, %2}";
13297 case 2:
13298 return "vpextrw\t{%2, %1, %0|%0, %1, %2}";
13299
13300 case 3:
13301 operands[2] = GEN_INT (INTVAL (operands[2]) * 2);
13302 return "psrldq\t{%2, %0|%0, %2}";
13303 case 4:
13304 operands[2] = GEN_INT (INTVAL (operands[2]) * 2);
13305 return "vpsrldq\t{%2, %1, %0|%0, %1, %2}";
13306
13307 default:
13308 gcc_unreachable ();
13309 }
13310 }
13311 [(set_attr "isa" "*,sse4_noavx,avx,noavx,avx")
13312 (set_attr "addr" "*,gpr16,*,*,*")
13313 (set_attr "type" "sselog1,sselog1,sselog1,sseishft1,sseishft1")
13314 (set_attr "c86_attr" "extr,extr,extr,other,other")
13315 (set_attr "prefix" "maybe_evex")
13316 (set_attr "mode" "TI")])
13317
13318 ;; Modes handled by vec_extract patterns.
13319 (define_mode_iterator VEC_EXTRACT_MODE
13320 [(V64QI "TARGET_AVX512BW && TARGET_EVEX512") (V32QI "TARGET_AVX") V16QI
13321 (V32HI "TARGET_AVX512BW && TARGET_EVEX512") (V16HI "TARGET_AVX") V8HI
13322 (V16SI "TARGET_AVX512F && TARGET_EVEX512") (V8SI "TARGET_AVX") V4SI
13323 (V8DI "TARGET_AVX512F && TARGET_EVEX512") (V4DI "TARGET_AVX") V2DI
13324 (V32HF "TARGET_AVX512BW && TARGET_EVEX512") (V16HF "TARGET_AVX") V8HF
13325 (V32BF "TARGET_AVX512BW && TARGET_EVEX512") (V16BF "TARGET_AVX") V8BF
13326 (V16SF "TARGET_AVX512F && TARGET_EVEX512") (V8SF "TARGET_AVX") V4SF
13327 (V8DF "TARGET_AVX512F && TARGET_EVEX512") (V4DF "TARGET_AVX") V2DF
13328 (V4TI "TARGET_AVX512F && TARGET_EVEX512") (V2TI "TARGET_AVX")])
13329
13330 (define_expand "vec_extract<mode><ssescalarmodelower>"
13331 [(match_operand:<ssescalarmode> 0 "register_operand")
13332 (match_operand:VEC_EXTRACT_MODE 1 "register_operand")
13333 (match_operand 2 "const_int_operand")]
13334 "TARGET_SSE"
13335 {
13336 ix86_expand_vector_extract (false, operands[0], operands[1],
13337 INTVAL (operands[2]));
13338 DONE;
13339 })
13340
13341 (define_expand "vec_extract<mode><ssehalfvecmodelower>"
13342 [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
13343 (match_operand:V_256_512 1 "register_operand")
13344 (match_operand 2 "const_0_to_1_operand")]
13345 "TARGET_AVX"
13346 {
13347 if (INTVAL (operands[2]))
13348 emit_insn (gen_vec_extract_hi_<mode> (operands[0], operands[1]));
13349 else
13350 emit_insn (gen_vec_extract_lo_<mode> (operands[0], operands[1]));
13351 DONE;
13352 })
13353
13354 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13355 ;;
13356 ;; Parallel double-precision floating point element swizzling
13357 ;;
13358 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13359
13360 (define_insn "<mask_codefor>avx512f_unpckhpd512<mask_name>"
13361 [(set (match_operand:V8DF 0 "register_operand" "=v")
13362 (vec_select:V8DF
13363 (vec_concat:V16DF
13364 (match_operand:V8DF 1 "register_operand" "v")
13365 (match_operand:V8DF 2 "nonimmediate_operand" "vm"))
13366 (parallel [(const_int 1) (const_int 9)
13367 (const_int 3) (const_int 11)
13368 (const_int 5) (const_int 13)
13369 (const_int 7) (const_int 15)])))]
13370 "TARGET_AVX512F && TARGET_EVEX512"
13371 "vunpckhpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
13372 [(set_attr "type" "sselog")
13373 (set_attr "prefix" "evex")
13374 (set_attr "mode" "V8DF")])
13375
13376 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
13377 (define_insn "avx_unpckhpd256<mask_name>"
13378 [(set (match_operand:V4DF 0 "register_operand" "=v")
13379 (vec_select:V4DF
13380 (vec_concat:V8DF
13381 (match_operand:V4DF 1 "register_operand" "v")
13382 (match_operand:V4DF 2 "nonimmediate_operand" "vm"))
13383 (parallel [(const_int 1) (const_int 5)
13384 (const_int 3) (const_int 7)])))]
13385 "TARGET_AVX && <mask_avx512vl_condition>"
13386 "vunpckhpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
13387 [(set_attr "type" "sselog")
13388 (set_attr "prefix" "vex")
13389 (set_attr "mode" "V4DF")])
13390
13391 (define_expand "vec_interleave_highv4df"
13392 [(set (match_dup 3)
13393 (vec_select:V4DF
13394 (vec_concat:V8DF
13395 (match_operand:V4DF 1 "register_operand")
13396 (match_operand:V4DF 2 "nonimmediate_operand"))
13397 (parallel [(const_int 0) (const_int 4)
13398 (const_int 2) (const_int 6)])))
13399 (set (match_dup 4)
13400 (vec_select:V4DF
13401 (vec_concat:V8DF
13402 (match_dup 1)
13403 (match_dup 2))
13404 (parallel [(const_int 1) (const_int 5)
13405 (const_int 3) (const_int 7)])))
13406 (set (match_operand:V4DF 0 "register_operand")
13407 (vec_select:V4DF
13408 (vec_concat:V8DF
13409 (match_dup 3)
13410 (match_dup 4))
13411 (parallel [(const_int 2) (const_int 3)
13412 (const_int 6) (const_int 7)])))]
13413 "TARGET_AVX"
13414 {
13415 operands[3] = gen_reg_rtx (V4DFmode);
13416 operands[4] = gen_reg_rtx (V4DFmode);
13417 })
13418
13419
13420 (define_insn "avx512vl_unpckhpd128_mask"
13421 [(set (match_operand:V2DF 0 "register_operand" "=v")
13422 (vec_merge:V2DF
13423 (vec_select:V2DF
13424 (vec_concat:V4DF
13425 (match_operand:V2DF 1 "register_operand" "v")
13426 (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
13427 (parallel [(const_int 1) (const_int 3)]))
13428 (match_operand:V2DF 3 "nonimm_or_0_operand" "0C")
13429 (match_operand:QI 4 "register_operand" "Yk")))]
13430 "TARGET_AVX512VL"
13431 "vunpckhpd\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
13432 [(set_attr "type" "sselog")
13433 (set_attr "prefix" "evex")
13434 (set_attr "mode" "V2DF")])
13435
13436 (define_expand "vec_interleave_highv2df"
13437 [(set (match_operand:V2DF 0 "register_operand")
13438 (vec_select:V2DF
13439 (vec_concat:V4DF
13440 (match_operand:V2DF 1 "nonimmediate_operand")
13441 (match_operand:V2DF 2 "nonimmediate_operand"))
13442 (parallel [(const_int 1)
13443 (const_int 3)])))]
13444 "TARGET_SSE2"
13445 {
13446 if (!ix86_vec_interleave_v2df_operator_ok (operands, 1))
13447 operands[2] = force_reg (V2DFmode, operands[2]);
13448 })
13449
13450 (define_insn "*vec_interleave_highv2df"
13451 [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,v,x,v,m")
13452 (vec_select:V2DF
13453 (vec_concat:V4DF
13454 (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,o,o,v")
13455 (match_operand:V2DF 2 "nonimmediate_operand" " x,v,0,v,0"))
13456 (parallel [(const_int 1)
13457 (const_int 3)])))]
13458 "TARGET_SSE2 && ix86_vec_interleave_v2df_operator_ok (operands, 1)"
13459 "@
13460 unpckhpd\t{%2, %0|%0, %2}
13461 vunpckhpd\t{%2, %1, %0|%0, %1, %2}
13462 movlpd\t{%H1, %0|%0, %H1}
13463 vmovlpd\t{%H1, %2, %0|%0, %2, %H1}
13464 %vmovhpd\t{%1, %0|%q0, %1}"
13465 [(set_attr "isa" "noavx,avx,noavx,avx,*")
13466 (set_attr "type" "sselog,sselog,ssemov,ssemov,ssemov")
13467 (set (attr "prefix_data16")
13468 (if_then_else (eq_attr "alternative" "2,4")
13469 (const_string "1")
13470 (const_string "*")))
13471 (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
13472 (set_attr "mode" "V2DF,V2DF,V1DF,V1DF,V1DF")])
13473
13474 (define_insn "avx512f_movddup512<mask_name>"
13475 [(set (match_operand:V8DF 0 "register_operand" "=v")
13476 (vec_select:V8DF
13477 (vec_concat:V16DF
13478 (match_operand:V8DF 1 "nonimmediate_operand" "m")
13479 (match_dup 1))
13480 (parallel [(const_int 0) (const_int 8)
13481 (const_int 2) (const_int 10)
13482 (const_int 4) (const_int 12)
13483 (const_int 6) (const_int 14)])))]
13484 "TARGET_AVX512F && TARGET_EVEX512"
13485 "vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
13486 [(set_attr "type" "sselog1")
13487 (set_attr "prefix" "evex")
13488 (set_attr "mode" "V8DF")])
13489
13490 (define_insn "avx512f_unpcklpd512<mask_name>"
13491 [(set (match_operand:V8DF 0 "register_operand" "=v")
13492 (vec_select:V8DF
13493 (vec_concat:V16DF
13494 (match_operand:V8DF 1 "register_operand" "v")
13495 (match_operand:V8DF 2 "nonimmediate_operand" "vm"))
13496 (parallel [(const_int 0) (const_int 8)
13497 (const_int 2) (const_int 10)
13498 (const_int 4) (const_int 12)
13499 (const_int 6) (const_int 14)])))]
13500 "TARGET_AVX512F && TARGET_EVEX512"
13501 "vunpcklpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
13502 [(set_attr "type" "sselog")
13503 (set_attr "prefix" "evex")
13504 (set_attr "mode" "V8DF")])
13505
13506 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
13507 (define_insn "avx_movddup256<mask_name>"
13508 [(set (match_operand:V4DF 0 "register_operand" "=v")
13509 (vec_select:V4DF
13510 (vec_concat:V8DF
13511 (match_operand:V4DF 1 "nonimmediate_operand" "m")
13512 (match_dup 1))
13513 (parallel [(const_int 0) (const_int 4)
13514 (const_int 2) (const_int 6)])))]
13515 "TARGET_AVX && <mask_avx512vl_condition>"
13516 "vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
13517 [(set_attr "type" "sselog1")
13518 (set_attr "prefix" "<mask_prefix>")
13519 (set_attr "mode" "V4DF")])
13520
13521 (define_insn "avx_unpcklpd256<mask_name>"
13522 [(set (match_operand:V4DF 0 "register_operand" "=v")
13523 (vec_select:V4DF
13524 (vec_concat:V8DF
13525 (match_operand:V4DF 1 "register_operand" " v")
13526 (match_operand:V4DF 2 "nonimmediate_operand" "vm"))
13527 (parallel [(const_int 0) (const_int 4)
13528 (const_int 2) (const_int 6)])))]
13529 "TARGET_AVX && <mask_avx512vl_condition>"
13530 "vunpcklpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
13531 [(set_attr "type" "sselog")
13532 (set_attr "prefix" "<mask_prefix>")
13533 (set_attr "mode" "V4DF")])
13534
13535 (define_expand "vec_interleave_lowv4df"
13536 [(set (match_dup 3)
13537 (vec_select:V4DF
13538 (vec_concat:V8DF
13539 (match_operand:V4DF 1 "register_operand")
13540 (match_operand:V4DF 2 "nonimmediate_operand"))
13541 (parallel [(const_int 0) (const_int 4)
13542 (const_int 2) (const_int 6)])))
13543 (set (match_dup 4)
13544 (vec_select:V4DF
13545 (vec_concat:V8DF
13546 (match_dup 1)
13547 (match_dup 2))
13548 (parallel [(const_int 1) (const_int 5)
13549 (const_int 3) (const_int 7)])))
13550 (set (match_operand:V4DF 0 "register_operand")
13551 (vec_select:V4DF
13552 (vec_concat:V8DF
13553 (match_dup 3)
13554 (match_dup 4))
13555 (parallel [(const_int 0) (const_int 1)
13556 (const_int 4) (const_int 5)])))]
13557 "TARGET_AVX"
13558 {
13559 operands[3] = gen_reg_rtx (V4DFmode);
13560 operands[4] = gen_reg_rtx (V4DFmode);
13561 })
13562
13563 (define_insn "avx512vl_unpcklpd128_mask"
13564 [(set (match_operand:V2DF 0 "register_operand" "=v")
13565 (vec_merge:V2DF
13566 (vec_select:V2DF
13567 (vec_concat:V4DF
13568 (match_operand:V2DF 1 "register_operand" "v")
13569 (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
13570 (parallel [(const_int 0) (const_int 2)]))
13571 (match_operand:V2DF 3 "nonimm_or_0_operand" "0C")
13572 (match_operand:QI 4 "register_operand" "Yk")))]
13573 "TARGET_AVX512VL"
13574 "vunpcklpd\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
13575 [(set_attr "type" "sselog")
13576 (set_attr "prefix" "evex")
13577 (set_attr "mode" "V2DF")])
13578
13579 (define_expand "vec_interleave_lowv2df"
13580 [(set (match_operand:V2DF 0 "register_operand")
13581 (vec_select:V2DF
13582 (vec_concat:V4DF
13583 (match_operand:V2DF 1 "nonimmediate_operand")
13584 (match_operand:V2DF 2 "nonimmediate_operand"))
13585 (parallel [(const_int 0)
13586 (const_int 2)])))]
13587 "TARGET_SSE2"
13588 {
13589 if (!ix86_vec_interleave_v2df_operator_ok (operands, 0))
13590 operands[1] = force_reg (V2DFmode, operands[1]);
13591 })
13592
13593 (define_insn "*vec_interleave_lowv2df"
13594 [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,v,x,v,o")
13595 (vec_select:V2DF
13596 (vec_concat:V4DF
13597 (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,0,v,0")
13598 (match_operand:V2DF 2 "nonimmediate_operand" " x,v,m,m,v"))
13599 (parallel [(const_int 0)
13600 (const_int 2)])))]
13601 "TARGET_SSE2 && ix86_vec_interleave_v2df_operator_ok (operands, 0)"
13602 "@
13603 unpcklpd\t{%2, %0|%0, %2}
13604 vunpcklpd\t{%2, %1, %0|%0, %1, %2}
13605 movhpd\t{%2, %0|%0, %q2}
13606 vmovhpd\t{%2, %1, %0|%0, %1, %q2}
13607 %vmovlpd\t{%2, %H0|%H0, %2}"
13608 [(set_attr "isa" "noavx,avx,noavx,avx,*")
13609 (set_attr "type" "sselog,sselog,ssemov,ssemov,ssemov")
13610 (set (attr "prefix_data16")
13611 (if_then_else (eq_attr "alternative" "2,4")
13612 (const_string "1")
13613 (const_string "*")))
13614 (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
13615 (set_attr "mode" "V2DF,V2DF,V1DF,V1DF,V1DF")])
13616
13617 (define_split
13618 [(set (match_operand:V2DF 0 "memory_operand")
13619 (vec_select:V2DF
13620 (vec_concat:V4DF
13621 (match_operand:V2DF 1 "register_operand")
13622 (match_dup 1))
13623 (parallel [(const_int 0)
13624 (const_int 2)])))]
13625 "TARGET_SSE3 && reload_completed"
13626 [(const_int 0)]
13627 {
13628 rtx low = gen_lowpart (DFmode, operands[1]);
13629
13630 emit_move_insn (adjust_address (operands[0], DFmode, 0), low);
13631 emit_move_insn (adjust_address (operands[0], DFmode, 8), low);
13632 DONE;
13633 })
13634
13635 (define_split
13636 [(set (match_operand:V2DF 0 "register_operand")
13637 (vec_select:V2DF
13638 (vec_concat:V4DF
13639 (match_operand:V2DF 1 "memory_operand")
13640 (match_dup 1))
13641 (parallel [(match_operand:SI 2 "const_0_to_1_operand")
13642 (match_operand:SI 3 "const_int_operand")])))]
13643 "TARGET_SSE3 && INTVAL (operands[2]) + 2 == INTVAL (operands[3])"
13644 [(set (match_dup 0) (vec_duplicate:V2DF (match_dup 1)))]
13645 {
13646 operands[1] = adjust_address (operands[1], DFmode, INTVAL (operands[2]) * 8);
13647 })
13648
13649 (define_insn "avx512f_vmscalef<mode><mask_scalar_name><round_scalar_name>"
13650 [(set (match_operand:VFH_128 0 "register_operand" "=v")
13651 (vec_merge:VFH_128
13652 (unspec:VFH_128
13653 [(match_operand:VFH_128 1 "register_operand" "v")
13654 (match_operand:VFH_128 2 "<round_scalar_nimm_predicate>" "<round_scalar_constraint>")]
13655 UNSPEC_SCALEF)
13656 (match_dup 1)
13657 (const_int 1)))]
13658 "TARGET_AVX512F"
13659 "vscalef<ssescalarmodesuffix>\t{<round_scalar_mask_op3>%2, %1, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %1, %2<round_scalar_mask_op3>}"
13660 [(set_attr "prefix" "evex")
13661 (set_attr "mode" "<ssescalarmode>")])
13662
13663 (define_insn "<avx512>_scalef<mode><mask_name><round_name>"
13664 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v")
13665 (unspec:VFH_AVX512VL
13666 [(match_operand:VFH_AVX512VL 1 "register_operand" "v")
13667 (match_operand:VFH_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")]
13668 UNSPEC_SCALEF))]
13669 "TARGET_AVX512F"
13670 "vscalef<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
13671 [(set_attr "prefix" "evex")
13672 (set_attr "mode" "<MODE>")])
13673
13674 (define_expand "<avx512>_vternlog<mode>_maskz"
13675 [(match_operand:VI48_AVX512VL 0 "register_operand")
13676 (match_operand:VI48_AVX512VL 1 "register_operand")
13677 (match_operand:VI48_AVX512VL 2 "register_operand")
13678 (match_operand:VI48_AVX512VL 3 "nonimmediate_operand")
13679 (match_operand:SI 4 "const_0_to_255_operand")
13680 (match_operand:<avx512fmaskmode> 5 "register_operand")]
13681 "TARGET_AVX512F"
13682 {
13683 emit_insn (gen_<avx512>_vternlog<mode>_maskz_1 (
13684 operands[0], operands[1], operands[2], operands[3],
13685 operands[4], CONST0_RTX (<MODE>mode), operands[5]));
13686 DONE;
13687 })
13688
13689 (define_insn "<avx512>_vternlog<mode><sd_maskz_name>"
13690 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
13691 (unspec:VI48_AVX512VL
13692 [(match_operand:VI48_AVX512VL 1 "register_operand" "0")
13693 (match_operand:VI48_AVX512VL 2 "register_operand" "v")
13694 (match_operand:VI48_AVX512VL 3 "bcst_vector_operand" "vmBr")
13695 (match_operand:SI 4 "const_0_to_255_operand")]
13696 UNSPEC_VTERNLOG))]
13697 "TARGET_AVX512F"
13698 "vpternlog<ssemodesuffix>\t{%4, %3, %2, %0<sd_mask_op5>|%0<sd_mask_op5>, %2, %3, %4}"
13699 [(set_attr "type" "sselog")
13700 (set_attr "prefix" "evex")
13701 (set_attr "mode" "<sseinsnmode>")])
13702
13703 (define_insn "*<avx512>_vternlog<mode>_all"
13704 [(set (match_operand:V 0 "register_operand" "=v,v")
13705 (unspec:V
13706 [(match_operand:V 1 "register_operand" "0,0")
13707 (match_operand:V 2 "register_operand" "v,v")
13708 (match_operand:V 3 "bcst_vector_operand" "vBr,m")
13709 (match_operand:SI 4 "const_0_to_255_operand")]
13710 UNSPEC_VTERNLOG))]
13711 "(<MODE_SIZE> == 64 || TARGET_AVX512VL
13712 || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256))
13713 /* Disallow embeded broadcast for vector HFmode since
13714 it's not real AVX512FP16 instruction. */
13715 && (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) >= 4
13716 || GET_CODE (operands[3]) != VEC_DUPLICATE)"
13717 {
13718 if (TARGET_AVX512VL)
13719 return "vpternlog<ternlogsuffix>\t{%4, %3, %2, %0|%0, %2, %3, %4}";
13720 else
13721 return "vpternlog<ternlogsuffix>\t{%4, %g3, %g2, %g0|%g0, %g2, %g3, %4}";
13722 }
13723 [(set_attr "type" "sselog")
13724 (set_attr "prefix" "evex")
13725 (set (attr "mode")
13726 (if_then_else (match_test "TARGET_AVX512VL")
13727 (const_string "<sseinsnmode>")
13728 (const_string "XI")))
13729 (set (attr "enabled")
13730 (if_then_else (eq_attr "alternative" "1")
13731 (symbol_ref "<MODE_SIZE> == 64 || TARGET_AVX512VL")
13732 (const_string "*")))])
13733
13734 ;; When VPTERNLOG happens to be invariant w.r.t first and second operands,
13735 ;; and the third operand is memory, eliminate false dependencies by loading
13736 ;; memory into the output operand first.
13737 (define_split
13738 [(set (match_operand:V 0 "register_operand")
13739 (unspec:V
13740 [(match_operand:V 1 "register_operand")
13741 (match_operand:V 2 "register_operand")
13742 (match_operand:V 3 "memory_operand")
13743 (match_operand:SI 4 "const_0_to_255_operand")]
13744 UNSPEC_VTERNLOG))]
13745 "!reload_completed && vpternlog_redundant_operand_mask (operands[4]) == 3"
13746 [(set (match_dup 0)
13747 (match_dup 3))
13748 (set (match_dup 0)
13749 (unspec:V
13750 [(match_dup 0)
13751 (match_dup 0)
13752 (match_dup 0)
13753 (match_dup 4)]
13754 UNSPEC_VTERNLOG))])
13755
13756 ;; Eliminate false dependencies when VPTERNLOG is invariant w.r.t any
13757 ;; of input operands (except the case handled in the above split).
13758 (define_split
13759 [(set (match_operand:V 0 "register_operand")
13760 (unspec:V
13761 [(match_operand:V 1 "register_operand")
13762 (match_operand:V 2 "register_operand")
13763 (match_operand:V 3 "nonimmediate_operand")
13764 (match_operand:SI 4 "const_0_to_255_operand")]
13765 UNSPEC_VTERNLOG))]
13766 "!reload_completed && vpternlog_redundant_operand_mask (operands[4]) != 0"
13767 [(set (match_dup 0)
13768 (unspec:V
13769 [(match_dup 1)
13770 (match_dup 2)
13771 (match_dup 3)
13772 (match_dup 4)]
13773 UNSPEC_VTERNLOG))]
13774 "substitute_vpternlog_operands (operands);")
13775
13776 ;; There must be lots of other combinations like
13777 ;;
13778 ;; (any_logic:V
13779 ;; (any_logic:V op1 op2)
13780 ;; (any_logic:V op1 op3))
13781 ;;
13782 ;; (any_logic:V
13783 ;; (any_logic:V
13784 ;; (any_logic:V op1, op2)
13785 ;; op3)
13786 ;; op1)
13787 ;;
13788 ;; and so on.
13789
13790 (define_insn_and_split "*<avx512>_vpternlog<mode>_0"
13791 [(set (match_operand:V 0 "register_operand")
13792 (match_operand:V 1 "ternlog_operand"))]
13793 "(<MODE_SIZE> == 64 || TARGET_AVX512VL
13794 || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256))
13795 && ix86_pre_reload_split ()"
13796 "#"
13797 "&& 1"
13798 [(const_int 0)]
13799 {
13800 rtx args[3];
13801 args[0] = NULL_RTX;
13802 args[1] = NULL_RTX;
13803 args[2] = NULL_RTX;
13804 int idx = ix86_ternlog_idx (operands[1], args);
13805 ix86_expand_ternlog (<MODE>mode, args[0], args[1], args[2], idx,
13806 operands[0]);
13807 DONE;
13808 })
13809
13810 (define_code_iterator any_logic1 [and ior xor])
13811 (define_code_iterator any_logic2 [and ior xor])
13812 (define_code_attr logic_op [(and "&") (ior "|") (xor "^")])
13813
13814 (define_insn_and_split "*<avx512>_vpternlog<mode>_1"
13815 [(set (match_operand:V 0 "register_operand")
13816 (any_logic:V
13817 (any_logic1:V
13818 (match_operand:V 1 "regmem_or_bitnot_regmem_operand")
13819 (match_operand:V 2 "regmem_or_bitnot_regmem_operand"))
13820 (any_logic2:V
13821 (match_operand:V 3 "regmem_or_bitnot_regmem_operand")
13822 (match_operand:V 4 "regmem_or_bitnot_regmem_operand"))))]
13823 "(<MODE_SIZE> == 64 || TARGET_AVX512VL
13824 || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256))
13825 && ix86_pre_reload_split ()
13826 && (rtx_equal_p (STRIP_UNARY (operands[1]),
13827 STRIP_UNARY (operands[4]))
13828 || rtx_equal_p (STRIP_UNARY (operands[2]),
13829 STRIP_UNARY (operands[4]))
13830 || rtx_equal_p (STRIP_UNARY (operands[1]),
13831 STRIP_UNARY (operands[3]))
13832 || rtx_equal_p (STRIP_UNARY (operands[2]),
13833 STRIP_UNARY (operands[3])))"
13834 "#"
13835 "&& 1"
13836 [(set (match_dup 0)
13837 (unspec:V
13838 [(match_dup 6)
13839 (match_dup 2)
13840 (match_dup 1)
13841 (match_dup 5)]
13842 UNSPEC_VTERNLOG))]
13843 {
13844 /* VPTERNLOGD reg6, reg2, reg1, imm8. */
13845 int reg6 = 0xF0;
13846 int reg2 = 0xCC;
13847 int reg1 = 0xAA;
13848 int reg3 = 0;
13849 int reg4 = 0;
13850 int reg_mask, tmp1, tmp2;
13851 if (rtx_equal_p (STRIP_UNARY (operands[1]),
13852 STRIP_UNARY (operands[4])))
13853 {
13854 reg4 = reg1;
13855 reg3 = reg6;
13856 operands[6] = operands[3];
13857 }
13858 else if (rtx_equal_p (STRIP_UNARY (operands[2]),
13859 STRIP_UNARY (operands[4])))
13860 {
13861 reg4 = reg2;
13862 reg3 = reg6;
13863 operands[6] = operands[3];
13864 }
13865 else if (rtx_equal_p (STRIP_UNARY (operands[1]),
13866 STRIP_UNARY (operands[3])))
13867 {
13868 reg4 = reg6;
13869 reg3 = reg1;
13870 operands[6] = operands[4];
13871 }
13872 else
13873 {
13874 reg4 = reg6;
13875 reg3 = reg2;
13876 operands[6] = operands[4];
13877 }
13878
13879 reg1 = UNARY_P (operands[1]) ? ~reg1 : reg1;
13880 reg2 = UNARY_P (operands[2]) ? ~reg2 : reg2;
13881 reg3 = UNARY_P (operands[3]) ? ~reg3 : reg3;
13882 reg4 = UNARY_P (operands[4]) ? ~reg4 : reg4;
13883
13884 tmp1 = reg1 <any_logic1:logic_op> reg2;
13885 tmp2 = reg3 <any_logic2:logic_op> reg4;
13886 reg_mask = tmp1 <any_logic:logic_op> tmp2;
13887 reg_mask &= 0xFF;
13888
13889 operands[1] = STRIP_UNARY (operands[1]);
13890 operands[2] = STRIP_UNARY (operands[2]);
13891 operands[6] = STRIP_UNARY (operands[6]);
13892 if (!register_operand (operands[2], <MODE>mode))
13893 operands[2] = force_reg (<MODE>mode, operands[2]);
13894 if (!register_operand (operands[6], <MODE>mode))
13895 operands[6] = force_reg (<MODE>mode, operands[6]);
13896 operands[5] = GEN_INT (reg_mask);
13897 })
13898
13899 (define_insn_and_split "*<avx512>_vpternlog<mode>_2"
13900 [(set (match_operand:V 0 "register_operand")
13901 (any_logic:V
13902 (any_logic1:V
13903 (any_logic2:V
13904 (match_operand:V 1 "regmem_or_bitnot_regmem_operand")
13905 (match_operand:V 2 "regmem_or_bitnot_regmem_operand"))
13906 (match_operand:V 3 "regmem_or_bitnot_regmem_operand"))
13907 (match_operand:V 4 "regmem_or_bitnot_regmem_operand")))]
13908 "(<MODE_SIZE> == 64 || TARGET_AVX512VL
13909 || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256))
13910 && ix86_pre_reload_split ()
13911 && (rtx_equal_p (STRIP_UNARY (operands[1]),
13912 STRIP_UNARY (operands[4]))
13913 || rtx_equal_p (STRIP_UNARY (operands[2]),
13914 STRIP_UNARY (operands[4]))
13915 || rtx_equal_p (STRIP_UNARY (operands[1]),
13916 STRIP_UNARY (operands[3]))
13917 || rtx_equal_p (STRIP_UNARY (operands[2]),
13918 STRIP_UNARY (operands[3])))"
13919 "#"
13920 "&& 1"
13921 [(set (match_dup 0)
13922 (unspec:V
13923 [(match_dup 6)
13924 (match_dup 2)
13925 (match_dup 1)
13926 (match_dup 5)]
13927 UNSPEC_VTERNLOG))]
13928 {
13929 /* VPTERNLOGD reg6, reg2, reg1, imm8. */
13930 int reg6 = 0xF0;
13931 int reg2 = 0xCC;
13932 int reg1 = 0xAA;
13933 int reg3 = 0;
13934 int reg4 = 0;
13935 int reg_mask, tmp1, tmp2;
13936 if (rtx_equal_p (STRIP_UNARY (operands[1]),
13937 STRIP_UNARY (operands[4])))
13938 {
13939 reg4 = reg1;
13940 reg3 = reg6;
13941 operands[6] = operands[3];
13942 }
13943 else if (rtx_equal_p (STRIP_UNARY (operands[2]),
13944 STRIP_UNARY (operands[4])))
13945 {
13946 reg4 = reg2;
13947 reg3 = reg6;
13948 operands[6] = operands[3];
13949 }
13950 else if (rtx_equal_p (STRIP_UNARY (operands[1]),
13951 STRIP_UNARY (operands[3])))
13952 {
13953 reg4 = reg6;
13954 reg3 = reg1;
13955 operands[6] = operands[4];
13956 }
13957 else
13958 {
13959 reg4 = reg6;
13960 reg3 = reg2;
13961 operands[6] = operands[4];
13962 }
13963
13964 reg1 = UNARY_P (operands[1]) ? ~reg1 : reg1;
13965 reg2 = UNARY_P (operands[2]) ? ~reg2 : reg2;
13966 reg3 = UNARY_P (operands[3]) ? ~reg3 : reg3;
13967 reg4 = UNARY_P (operands[4]) ? ~reg4 : reg4;
13968
13969 tmp1 = reg1 <any_logic2:logic_op> reg2;
13970 tmp2 = tmp1 <any_logic1:logic_op> reg3;
13971 reg_mask = tmp2 <any_logic:logic_op> reg4;
13972 reg_mask &= 0xFF;
13973
13974 operands[1] = STRIP_UNARY (operands[1]);
13975 operands[2] = STRIP_UNARY (operands[2]);
13976 operands[6] = STRIP_UNARY (operands[6]);
13977 operands[5] = GEN_INT (reg_mask);
13978 if (!register_operand (operands[2], <MODE>mode))
13979 operands[2] = force_reg (<MODE>mode, operands[2]);
13980 if (!register_operand (operands[6], <MODE>mode))
13981 operands[6] = force_reg (<MODE>mode, operands[6]);
13982
13983 })
13984
13985 (define_insn_and_split "*<avx512>_vpternlog<mode>_3"
13986 [(set (match_operand:V 0 "register_operand")
13987 (any_logic:V
13988 (any_logic1:V
13989 (match_operand:V 1 "regmem_or_bitnot_regmem_operand")
13990 (match_operand:V 2 "regmem_or_bitnot_regmem_operand"))
13991 (match_operand:V 3 "regmem_or_bitnot_regmem_operand")))]
13992 "(<MODE_SIZE> == 64 || TARGET_AVX512VL
13993 || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256))
13994 && ix86_pre_reload_split ()"
13995 "#"
13996 "&& 1"
13997 [(set (match_dup 0)
13998 (unspec:V
13999 [(match_dup 3)
14000 (match_dup 2)
14001 (match_dup 1)
14002 (match_dup 4)]
14003 UNSPEC_VTERNLOG))]
14004 {
14005 /* VPTERNLOGD reg3, reg2, reg1, imm8. */
14006 int reg3 = 0xF0;
14007 int reg2 = 0xCC;
14008 int reg1 = 0xAA;
14009 int reg_mask, tmp1;
14010
14011 reg1 = UNARY_P (operands[1]) ? ~reg1 : reg1;
14012 reg2 = UNARY_P (operands[2]) ? ~reg2 : reg2;
14013 reg3 = UNARY_P (operands[3]) ? ~reg3 : reg3;
14014
14015 tmp1 = reg1 <any_logic1:logic_op> reg2;
14016 reg_mask = tmp1 <any_logic:logic_op> reg3;
14017 reg_mask &= 0xFF;
14018
14019 operands[1] = STRIP_UNARY (operands[1]);
14020 operands[2] = STRIP_UNARY (operands[2]);
14021 operands[3] = STRIP_UNARY (operands[3]);
14022 operands[4] = GEN_INT (reg_mask);
14023 if (!register_operand (operands[2], <MODE>mode))
14024 operands[2] = force_reg (<MODE>mode, operands[2]);
14025 if (!register_operand (operands[3], <MODE>mode))
14026 operands[3] = force_reg (<MODE>mode, operands[3]);
14027 })
14028
14029
14030 (define_expand "<avx512>_vternlog<mode>_mask"
14031 [(set (match_operand:VI48_AVX512VL 0 "register_operand")
14032 (vec_merge:VI48_AVX512VL
14033 (unspec:VI48_AVX512VL
14034 [(match_operand:VI48_AVX512VL 1 "register_operand")
14035 (match_operand:VI48_AVX512VL 2 "register_operand")
14036 (match_operand:VI48_AVX512VL 3 "bcst_vector_operand")
14037 (match_operand:SI 4 "const_0_to_255_operand")]
14038 UNSPEC_VTERNLOG)
14039 (match_dup 1)
14040 (match_operand:<avx512fmaskmode> 5 "general_operand")))]
14041 "TARGET_AVX512F"
14042 {
14043 unsigned HOST_WIDE_INT mode_mask = GET_MODE_MASK (<avx512fmaskmode>mode);
14044 if (CONST_INT_P (operands[5])
14045 && (UINTVAL (operands[5]) & mode_mask) == mode_mask)
14046 {
14047 ix86_expand_ternlog (<MODE>mode, operands[1], operands[2],
14048 operands[3], INTVAL (operands[4]),
14049 operands[0]);
14050 DONE;
14051 }
14052 if (!register_operand (operands[5], <avx512fmaskmode>mode))
14053 operands[5] = force_reg (<avx512fmaskmode>mode, operands[5]);
14054 })
14055
14056 (define_insn "*<avx512>_vternlog<mode>_mask"
14057 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
14058 (vec_merge:VI48_AVX512VL
14059 (unspec:VI48_AVX512VL
14060 [(match_operand:VI48_AVX512VL 1 "register_operand" "0")
14061 (match_operand:VI48_AVX512VL 2 "register_operand" "v")
14062 (match_operand:VI48_AVX512VL 3 "bcst_vector_operand" "vmBr")
14063 (match_operand:SI 4 "const_0_to_255_operand")]
14064 UNSPEC_VTERNLOG)
14065 (match_dup 1)
14066 (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
14067 "TARGET_AVX512F"
14068 "vpternlog<ssemodesuffix>\t{%4, %3, %2, %0%{%5%}|%0%{%5%}, %2, %3, %4}"
14069 [(set_attr "type" "sselog")
14070 (set_attr "prefix" "evex")
14071 (set_attr "mode" "<sseinsnmode>")])
14072
14073 (define_insn "<avx512>_getexp<mode><mask_name><round_saeonly_name>"
14074 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v")
14075 (unspec:VFH_AVX512VL [(match_operand:VFH_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
14076 UNSPEC_GETEXP))]
14077 "TARGET_AVX512F"
14078 "vgetexp<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}";
14079 [(set_attr "prefix" "evex")
14080 (set_attr "mode" "<MODE>")])
14081
14082 (define_insn "avx512f_sgetexp<mode><mask_scalar_name><round_saeonly_scalar_name>"
14083 [(set (match_operand:VFH_128 0 "register_operand" "=v")
14084 (vec_merge:VFH_128
14085 (unspec:VFH_128
14086 [(match_operand:VFH_128 1 "register_operand" "v")
14087 (match_operand:VFH_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")]
14088 UNSPEC_GETEXP)
14089 (match_dup 1)
14090 (const_int 1)))]
14091 "TARGET_AVX512F"
14092 "vgetexp<ssescalarmodesuffix>\t{<round_saeonly_scalar_mask_op3>%2, %1, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %1, %<iptr>2<round_saeonly_scalar_mask_op3>}";
14093 [(set_attr "prefix" "evex")
14094 (set_attr "mode" "<ssescalarmode>")])
14095
14096 (define_insn "<mask_codefor><avx512>_align<mode><mask_name>"
14097 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
14098 (unspec:VI48_AVX512VL [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
14099 (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")
14100 (match_operand:SI 3 "const_0_to_255_operand")]
14101 UNSPEC_ALIGN))]
14102 "TARGET_AVX512F"
14103 "valign<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}";
14104 [(set_attr "prefix" "evex")
14105 (set_attr "c86_attr" "shufx")
14106 (set_attr "mode" "<sseinsnmode>")])
14107
14108 (define_mode_attr vec_extract_imm_predicate
14109 [(V16SF "const_0_to_15_operand") (V8SF "const_0_to_7_operand")
14110 (V16SI "const_0_to_15_operand") (V8SI "const_0_to_7_operand")
14111 (V8DF "const_0_to_7_operand") (V4DF "const_0_to_3_operand")
14112 (V8DI "const_0_to_7_operand") (V4DI "const_0_to_3_operand")])
14113
14114 (define_insn "*vec_extract<mode><ssescalarmodelower>_valign"
14115 [(set (match_operand:<ssescalarmode> 0 "register_operand" "=v")
14116 (vec_select:<ssescalarmode>
14117 (match_operand:V48_256_512_AVX512VL 1 "register_operand" "v")
14118 (parallel [(match_operand 2 "<vec_extract_imm_predicate>")])))]
14119 "TARGET_AVX512F
14120 && INTVAL(operands[2]) * GET_MODE_SIZE (<ssescalarmode>mode) >= 16"
14121 {
14122 int byte_offset = INTVAL (operands[2]) * GET_MODE_SIZE (<ssescalarmode>mode);
14123 if (byte_offset % 16 == 0)
14124 {
14125 operands[2] = GEN_INT (byte_offset / 16);
14126 if (byte_offset / 16 == 1)
14127 return "vextract<shuffletype><extract_suf>\t{%2, %t1, %x0|%x0, %t1, %2}";
14128 else
14129 return "vextract<shuffletype><extract_suf>\t{%2, %1, %x0|%x0, %1, %2}";
14130 }
14131 else
14132 return "valign<ternlogsuffix>\t{%2, %1, %1, %<xtg_mode>0|%<xtg_mode>0, %1, %1, %2}";
14133 }
14134 [(set_attr "prefix" "maybe_evex")
14135 (set_attr "mode" "<sseintvecinsnmode>")])
14136
14137 (define_expand "avx512f_shufps512_mask"
14138 [(match_operand:V16SF 0 "register_operand")
14139 (match_operand:V16SF 1 "register_operand")
14140 (match_operand:V16SF 2 "nonimmediate_operand")
14141 (match_operand:SI 3 "const_0_to_255_operand")
14142 (match_operand:V16SF 4 "register_operand")
14143 (match_operand:HI 5 "register_operand")]
14144 "TARGET_AVX512F && TARGET_EVEX512"
14145 {
14146 int mask = INTVAL (operands[3]);
14147 emit_insn (gen_avx512f_shufps512_1_mask (operands[0], operands[1], operands[2],
14148 GEN_INT ((mask >> 0) & 3),
14149 GEN_INT ((mask >> 2) & 3),
14150 GEN_INT (((mask >> 4) & 3) + 16),
14151 GEN_INT (((mask >> 6) & 3) + 16),
14152 GEN_INT (((mask >> 0) & 3) + 4),
14153 GEN_INT (((mask >> 2) & 3) + 4),
14154 GEN_INT (((mask >> 4) & 3) + 20),
14155 GEN_INT (((mask >> 6) & 3) + 20),
14156 GEN_INT (((mask >> 0) & 3) + 8),
14157 GEN_INT (((mask >> 2) & 3) + 8),
14158 GEN_INT (((mask >> 4) & 3) + 24),
14159 GEN_INT (((mask >> 6) & 3) + 24),
14160 GEN_INT (((mask >> 0) & 3) + 12),
14161 GEN_INT (((mask >> 2) & 3) + 12),
14162 GEN_INT (((mask >> 4) & 3) + 28),
14163 GEN_INT (((mask >> 6) & 3) + 28),
14164 operands[4], operands[5]));
14165 DONE;
14166 })
14167
14168
14169 (define_expand "<avx512>_fixupimm<mode>_maskz<round_saeonly_expand_name>"
14170 [(match_operand:VF_AVX512VL 0 "register_operand")
14171 (match_operand:VF_AVX512VL 1 "register_operand")
14172 (match_operand:VF_AVX512VL 2 "register_operand")
14173 (match_operand:<sseintvecmode> 3 "<round_saeonly_expand_nimm_predicate>")
14174 (match_operand:SI 4 "const_0_to_255_operand")
14175 (match_operand:<avx512fmaskmode> 5 "register_operand")]
14176 "TARGET_AVX512F"
14177 {
14178 emit_insn (gen_<avx512>_fixupimm<mode>_maskz_1<round_saeonly_expand_name> (
14179 operands[0], operands[1], operands[2], operands[3],
14180 operands[4], CONST0_RTX (<MODE>mode), operands[5]
14181 <round_saeonly_expand_operand6>));
14182 DONE;
14183 })
14184
14185 (define_insn "<avx512>_fixupimm<mode><sd_maskz_name><round_saeonly_name>"
14186 [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
14187 (unspec:VF_AVX512VL
14188 [(match_operand:VF_AVX512VL 1 "register_operand" "0")
14189 (match_operand:VF_AVX512VL 2 "register_operand" "v")
14190 (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "<round_saeonly_constraint>")
14191 (match_operand:SI 4 "const_0_to_255_operand")]
14192 UNSPEC_FIXUPIMM))]
14193 "TARGET_AVX512F"
14194 "vfixupimm<ssemodesuffix>\t{%4, <round_saeonly_sd_mask_op5>%3, %2, %0<sd_mask_op5>|%0<sd_mask_op5>, %2, %3<round_saeonly_sd_mask_op5>, %4}";
14195 [(set_attr "prefix" "evex")
14196 (set_attr "mode" "<MODE>")])
14197
14198 (define_insn "<avx512>_fixupimm<mode>_mask<round_saeonly_name>"
14199 [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
14200 (vec_merge:VF_AVX512VL
14201 (unspec:VF_AVX512VL
14202 [(match_operand:VF_AVX512VL 1 "register_operand" "0")
14203 (match_operand:VF_AVX512VL 2 "register_operand" "v")
14204 (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "<round_saeonly_constraint>")
14205 (match_operand:SI 4 "const_0_to_255_operand")]
14206 UNSPEC_FIXUPIMM)
14207 (match_dup 1)
14208 (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
14209 "TARGET_AVX512F"
14210 "vfixupimm<ssemodesuffix>\t{%4, <round_saeonly_op6>%3, %2, %0%{%5%}|%0%{%5%}, %2, %3<round_saeonly_op6>, %4}";
14211 [(set_attr "prefix" "evex")
14212 (set_attr "mode" "<MODE>")])
14213
14214 (define_expand "avx512f_sfixupimm<mode>_maskz<round_saeonly_expand_name>"
14215 [(match_operand:VF_128 0 "register_operand")
14216 (match_operand:VF_128 1 "register_operand")
14217 (match_operand:VF_128 2 "register_operand")
14218 (match_operand:<sseintvecmode> 3 "<round_saeonly_expand_nimm_predicate>")
14219 (match_operand:SI 4 "const_0_to_255_operand")
14220 (match_operand:<avx512fmaskmode> 5 "register_operand")]
14221 "TARGET_AVX512F"
14222 {
14223 emit_insn (gen_avx512f_sfixupimm<mode>_maskz_1<round_saeonly_expand_name> (
14224 operands[0], operands[1], operands[2], operands[3],
14225 operands[4], CONST0_RTX (<MODE>mode), operands[5]
14226 <round_saeonly_expand_operand6>));
14227 DONE;
14228 })
14229
14230 (define_insn "avx512f_sfixupimm<mode><maskz_scalar_name><round_saeonly_name>"
14231 [(set (match_operand:VF_128 0 "register_operand" "=v")
14232 (vec_merge:VF_128
14233 (unspec:VF_128
14234 [(match_operand:VF_128 1 "register_operand" "0")
14235 (match_operand:VF_128 2 "register_operand" "v")
14236 (match_operand:<sseintvecmode> 3 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
14237 (match_operand:SI 4 "const_0_to_255_operand")]
14238 UNSPEC_FIXUPIMM)
14239 (match_dup 2)
14240 (const_int 1)))]
14241 "TARGET_AVX512F"
14242 "vfixupimm<ssescalarmodesuffix>\t{%4, <round_saeonly_maskz_scalar_op5>%3, %2, %0<maskz_scalar_op5>|%0<maskz_scalar_op5>, %2, %<iptr>3<round_saeonly_maskz_scalar_op5>, %4}";
14243 [(set_attr "prefix" "evex")
14244 (set_attr "mode" "<ssescalarmode>")])
14245
14246 (define_insn "avx512f_sfixupimm<mode>_mask<round_saeonly_name>"
14247 [(set (match_operand:VF_128 0 "register_operand" "=v")
14248 (vec_merge:VF_128
14249 (vec_merge:VF_128
14250 (unspec:VF_128
14251 [(match_operand:VF_128 1 "register_operand" "0")
14252 (match_operand:VF_128 2 "register_operand" "v")
14253 (match_operand:<sseintvecmode> 3 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
14254 (match_operand:SI 4 "const_0_to_255_operand")]
14255 UNSPEC_FIXUPIMM)
14256 (match_dup 2)
14257 (const_int 1))
14258 (match_dup 1)
14259 (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
14260 "TARGET_AVX512F"
14261 "vfixupimm<ssescalarmodesuffix>\t{%4, <round_saeonly_op6>%3, %2, %0%{%5%}|%0%{%5%}, %2, %<iptr>3<round_saeonly_op6>, %4}";
14262 [(set_attr "prefix" "evex")
14263 (set_attr "mode" "<ssescalarmode>")])
14264
14265 (define_insn "<avx512>_rndscale<mode><mask_name><round_saeonly_name>"
14266 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v")
14267 (unspec:VFH_AVX512VL
14268 [(match_operand:VFH_AVX512VL 1 "nonimmediate_operand" "<round_saeonly_constraint>")
14269 (match_operand:SI 2 "const_0_to_255_operand")]
14270 UNSPEC_ROUND))]
14271 "TARGET_AVX512F"
14272 "vrndscale<ssemodesuffix>\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}"
14273 [(set_attr "length_immediate" "1")
14274 (set_attr "prefix" "evex")
14275 (set_attr "mode" "<MODE>")])
14276
14277 (define_insn "avx512f_rndscale<mode><mask_scalar_name><round_saeonly_scalar_name>"
14278 [(set (match_operand:VFH_128 0 "register_operand" "=v")
14279 (vec_merge:VFH_128
14280 (unspec:VFH_128
14281 [(match_operand:VFH_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")
14282 (match_operand:SI 3 "const_0_to_255_operand")]
14283 UNSPEC_ROUND)
14284 (match_operand:VFH_128 1 "register_operand" "v")
14285 (const_int 1)))]
14286 "TARGET_AVX512F"
14287 "vrndscale<ssescalarmodesuffix>\t{%3, <round_saeonly_scalar_mask_op4>%2, %1, %0<mask_scalar_operand4>|%0<mask_scalar_operand4>, %1, %<iptr>2<round_saeonly_scalar_mask_op4>, %3}"
14288 [(set_attr "length_immediate" "1")
14289 (set_attr "prefix" "evex")
14290 (set_attr "mode" "<MODE>")])
14291
14292 (define_insn "*avx512f_rndscale<mode><round_saeonly_name>"
14293 [(set (match_operand:VFH_128 0 "register_operand" "=v")
14294 (vec_merge:VFH_128
14295 (vec_duplicate:VFH_128
14296 (unspec:<ssescalarmode>
14297 [(match_operand:<ssescalarmode> 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
14298 (match_operand:SI 3 "const_0_to_255_operand")]
14299 UNSPEC_ROUND))
14300 (match_operand:VFH_128 1 "register_operand" "v")
14301 (const_int 1)))]
14302 "TARGET_AVX512F"
14303 "vrndscale<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %2<round_saeonly_op4>, %3}"
14304 [(set_attr "length_immediate" "1")
14305 (set_attr "prefix" "evex")
14306 (set_attr "mode" "<MODE>")])
14307
14308 ;; One bit in mask selects 2 elements.
14309 (define_insn "avx512f_shufps512_1<mask_name>"
14310 [(set (match_operand:V16SF 0 "register_operand" "=v")
14311 (vec_select:V16SF
14312 (vec_concat:V32SF
14313 (match_operand:V16SF 1 "register_operand" "v")
14314 (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
14315 (parallel [(match_operand 3 "const_0_to_3_operand")
14316 (match_operand 4 "const_0_to_3_operand")
14317 (match_operand 5 "const_16_to_19_operand")
14318 (match_operand 6 "const_16_to_19_operand")
14319 (match_operand 7 "const_4_to_7_operand")
14320 (match_operand 8 "const_4_to_7_operand")
14321 (match_operand 9 "const_20_to_23_operand")
14322 (match_operand 10 "const_20_to_23_operand")
14323 (match_operand 11 "const_8_to_11_operand")
14324 (match_operand 12 "const_8_to_11_operand")
14325 (match_operand 13 "const_24_to_27_operand")
14326 (match_operand 14 "const_24_to_27_operand")
14327 (match_operand 15 "const_12_to_15_operand")
14328 (match_operand 16 "const_12_to_15_operand")
14329 (match_operand 17 "const_28_to_31_operand")
14330 (match_operand 18 "const_28_to_31_operand")])))]
14331 "TARGET_AVX512F && TARGET_EVEX512
14332 && (INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
14333 && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
14334 && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4)
14335 && INTVAL (operands[6]) == (INTVAL (operands[10]) - 4)
14336 && INTVAL (operands[3]) == (INTVAL (operands[11]) - 8)
14337 && INTVAL (operands[4]) == (INTVAL (operands[12]) - 8)
14338 && INTVAL (operands[5]) == (INTVAL (operands[13]) - 8)
14339 && INTVAL (operands[6]) == (INTVAL (operands[14]) - 8)
14340 && INTVAL (operands[3]) == (INTVAL (operands[15]) - 12)
14341 && INTVAL (operands[4]) == (INTVAL (operands[16]) - 12)
14342 && INTVAL (operands[5]) == (INTVAL (operands[17]) - 12)
14343 && INTVAL (operands[6]) == (INTVAL (operands[18]) - 12))"
14344 {
14345 int mask;
14346 mask = INTVAL (operands[3]);
14347 mask |= INTVAL (operands[4]) << 2;
14348 mask |= (INTVAL (operands[5]) - 16) << 4;
14349 mask |= (INTVAL (operands[6]) - 16) << 6;
14350 operands[3] = GEN_INT (mask);
14351
14352 return "vshufps\t{%3, %2, %1, %0<mask_operand19>|%0<mask_operand19>, %1, %2, %3}";
14353 }
14354 [(set_attr "type" "sselog")
14355 (set_attr "length_immediate" "1")
14356 (set_attr "prefix" "evex")
14357 (set_attr "mode" "V16SF")])
14358
14359 (define_expand "avx512f_shufpd512_mask"
14360 [(match_operand:V8DF 0 "register_operand")
14361 (match_operand:V8DF 1 "register_operand")
14362 (match_operand:V8DF 2 "nonimmediate_operand")
14363 (match_operand:SI 3 "const_0_to_255_operand")
14364 (match_operand:V8DF 4 "register_operand")
14365 (match_operand:QI 5 "register_operand")]
14366 "TARGET_AVX512F && TARGET_EVEX512"
14367 {
14368 int mask = INTVAL (operands[3]);
14369 emit_insn (gen_avx512f_shufpd512_1_mask (operands[0], operands[1], operands[2],
14370 GEN_INT (mask & 1),
14371 GEN_INT (mask & 2 ? 9 : 8),
14372 GEN_INT (mask & 4 ? 3 : 2),
14373 GEN_INT (mask & 8 ? 11 : 10),
14374 GEN_INT (mask & 16 ? 5 : 4),
14375 GEN_INT (mask & 32 ? 13 : 12),
14376 GEN_INT (mask & 64 ? 7 : 6),
14377 GEN_INT (mask & 128 ? 15 : 14),
14378 operands[4], operands[5]));
14379 DONE;
14380 })
14381
14382 (define_insn "avx512f_shufpd512_1<mask_name>"
14383 [(set (match_operand:V8DF 0 "register_operand" "=v")
14384 (vec_select:V8DF
14385 (vec_concat:V16DF
14386 (match_operand:V8DF 1 "register_operand" "v")
14387 (match_operand:V8DF 2 "nonimmediate_operand" "vm"))
14388 (parallel [(match_operand 3 "const_0_to_1_operand")
14389 (match_operand 4 "const_8_to_9_operand")
14390 (match_operand 5 "const_2_to_3_operand")
14391 (match_operand 6 "const_10_to_11_operand")
14392 (match_operand 7 "const_4_to_5_operand")
14393 (match_operand 8 "const_12_to_13_operand")
14394 (match_operand 9 "const_6_to_7_operand")
14395 (match_operand 10 "const_14_to_15_operand")])))]
14396 "TARGET_AVX512F && TARGET_EVEX512"
14397 {
14398 int mask;
14399 mask = INTVAL (operands[3]);
14400 mask |= (INTVAL (operands[4]) - 8) << 1;
14401 mask |= (INTVAL (operands[5]) - 2) << 2;
14402 mask |= (INTVAL (operands[6]) - 10) << 3;
14403 mask |= (INTVAL (operands[7]) - 4) << 4;
14404 mask |= (INTVAL (operands[8]) - 12) << 5;
14405 mask |= (INTVAL (operands[9]) - 6) << 6;
14406 mask |= (INTVAL (operands[10]) - 14) << 7;
14407 operands[3] = GEN_INT (mask);
14408
14409 return "vshufpd\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
14410 }
14411 [(set_attr "type" "sselog")
14412 (set_attr "length_immediate" "1")
14413 (set_attr "prefix" "evex")
14414 (set_attr "mode" "V8DF")])
14415
14416 (define_expand "avx_shufpd256<mask_expand4_name>"
14417 [(match_operand:V4DF 0 "register_operand")
14418 (match_operand:V4DF 1 "register_operand")
14419 (match_operand:V4DF 2 "nonimmediate_operand")
14420 (match_operand:SI 3 "const_int_operand")]
14421 "TARGET_AVX"
14422 {
14423 int mask = INTVAL (operands[3]);
14424 emit_insn (gen_avx_shufpd256_1<mask_expand4_name> (operands[0],
14425 operands[1],
14426 operands[2],
14427 GEN_INT (mask & 1),
14428 GEN_INT (mask & 2 ? 5 : 4),
14429 GEN_INT (mask & 4 ? 3 : 2),
14430 GEN_INT (mask & 8 ? 7 : 6)
14431 <mask_expand4_args>));
14432 DONE;
14433 })
14434
14435 (define_insn "avx_shufpd256_1<mask_name>"
14436 [(set (match_operand:V4DF 0 "register_operand" "=v")
14437 (vec_select:V4DF
14438 (vec_concat:V8DF
14439 (match_operand:V4DF 1 "register_operand" "v")
14440 (match_operand:V4DF 2 "nonimmediate_operand" "vm"))
14441 (parallel [(match_operand 3 "const_0_to_1_operand")
14442 (match_operand 4 "const_4_to_5_operand")
14443 (match_operand 5 "const_2_to_3_operand")
14444 (match_operand 6 "const_6_to_7_operand")])))]
14445 "TARGET_AVX && <mask_avx512vl_condition>"
14446 {
14447 int mask;
14448 mask = INTVAL (operands[3]);
14449 mask |= (INTVAL (operands[4]) - 4) << 1;
14450 mask |= (INTVAL (operands[5]) - 2) << 2;
14451 mask |= (INTVAL (operands[6]) - 6) << 3;
14452 operands[3] = GEN_INT (mask);
14453
14454 return "vshufpd\t{%3, %2, %1, %0<mask_operand7>|%0<mask_operand7>, %1, %2, %3}";
14455 }
14456 [(set_attr "type" "sseshuf")
14457 (set_attr "length_immediate" "1")
14458 (set_attr "prefix" "vex")
14459 (set_attr "mode" "V4DF")])
14460
14461 (define_expand "sse2_shufpd<mask_expand4_name>"
14462 [(match_operand:V2DF 0 "register_operand")
14463 (match_operand:V2DF 1 "register_operand")
14464 (match_operand:V2DF 2 "vector_operand")
14465 (match_operand:SI 3 "const_int_operand")]
14466 "TARGET_SSE2"
14467 {
14468 int mask = INTVAL (operands[3]);
14469 emit_insn (gen_sse2_shufpd_v2df<mask_expand4_name> (operands[0], operands[1],
14470 operands[2], GEN_INT (mask & 1),
14471 GEN_INT (mask & 2 ? 3 : 2)
14472 <mask_expand4_args>));
14473 DONE;
14474 })
14475
14476 (define_insn "sse2_shufpd_v2df_mask"
14477 [(set (match_operand:V2DF 0 "register_operand" "=v")
14478 (vec_merge:V2DF
14479 (vec_select:V2DF
14480 (vec_concat:V4DF
14481 (match_operand:V2DF 1 "register_operand" "v")
14482 (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
14483 (parallel [(match_operand 3 "const_0_to_1_operand")
14484 (match_operand 4 "const_2_to_3_operand")]))
14485 (match_operand:V2DF 5 "nonimm_or_0_operand" "0C")
14486 (match_operand:QI 6 "register_operand" "Yk")))]
14487 "TARGET_AVX512VL"
14488 {
14489 int mask;
14490 mask = INTVAL (operands[3]);
14491 mask |= (INTVAL (operands[4]) - 2) << 1;
14492 operands[3] = GEN_INT (mask);
14493
14494 return "vshufpd\t{%3, %2, %1, %0%{%6%}%N5|%0%{%6%}%N5, %1, %2, %3}";
14495 }
14496 [(set_attr "type" "sseshuf")
14497 (set_attr "length_immediate" "1")
14498 (set_attr "prefix" "evex")
14499 (set_attr "mode" "V2DF")])
14500
14501 ;; punpcklqdq and punpckhqdq are shorter than shufpd.
14502 (define_insn "avx2_interleave_highv4di<mask_name>"
14503 [(set (match_operand:V4DI 0 "register_operand" "=v")
14504 (vec_select:V4DI
14505 (vec_concat:V8DI
14506 (match_operand:V4DI 1 "register_operand" "v")
14507 (match_operand:V4DI 2 "nonimmediate_operand" "vm"))
14508 (parallel [(const_int 1)
14509 (const_int 5)
14510 (const_int 3)
14511 (const_int 7)])))]
14512 "TARGET_AVX2 && <mask_avx512vl_condition>"
14513 "vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14514 [(set_attr "type" "sselog")
14515 (set_attr "prefix" "vex")
14516 (set_attr "mode" "OI")])
14517
14518 (define_insn "<mask_codefor>avx512f_interleave_highv8di<mask_name>"
14519 [(set (match_operand:V8DI 0 "register_operand" "=v")
14520 (vec_select:V8DI
14521 (vec_concat:V16DI
14522 (match_operand:V8DI 1 "register_operand" "v")
14523 (match_operand:V8DI 2 "nonimmediate_operand" "vm"))
14524 (parallel [(const_int 1) (const_int 9)
14525 (const_int 3) (const_int 11)
14526 (const_int 5) (const_int 13)
14527 (const_int 7) (const_int 15)])))]
14528 "TARGET_AVX512F && TARGET_EVEX512"
14529 "vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14530 [(set_attr "type" "sselog")
14531 (set_attr "prefix" "evex")
14532 (set_attr "mode" "XI")])
14533
14534 (define_insn "vec_interleave_highv2di<mask_name>"
14535 [(set (match_operand:V2DI 0 "register_operand" "=x,v")
14536 (vec_select:V2DI
14537 (vec_concat:V4DI
14538 (match_operand:V2DI 1 "register_operand" "0,v")
14539 (match_operand:V2DI 2 "vector_operand" "xBm,vm"))
14540 (parallel [(const_int 1)
14541 (const_int 3)])))]
14542 "TARGET_SSE2 && <mask_avx512vl_condition>"
14543 "@
14544 punpckhqdq\t{%2, %0|%0, %2}
14545 vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14546 [(set_attr "isa" "noavx,avx")
14547 (set_attr "type" "sselog")
14548 (set_attr "prefix_data16" "1,*")
14549 (set_attr "prefix" "orig,<mask_prefix>")
14550 (set_attr "mode" "TI")])
14551
14552 (define_insn "avx2_interleave_lowv4di<mask_name>"
14553 [(set (match_operand:V4DI 0 "register_operand" "=v")
14554 (vec_select:V4DI
14555 (vec_concat:V8DI
14556 (match_operand:V4DI 1 "register_operand" "v")
14557 (match_operand:V4DI 2 "nonimmediate_operand" "vm"))
14558 (parallel [(const_int 0)
14559 (const_int 4)
14560 (const_int 2)
14561 (const_int 6)])))]
14562 "TARGET_AVX2 && <mask_avx512vl_condition>"
14563 "vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14564 [(set_attr "type" "sselog")
14565 (set_attr "prefix" "vex")
14566 (set_attr "mode" "OI")])
14567
14568 (define_insn "<mask_codefor>avx512f_interleave_lowv8di<mask_name>"
14569 [(set (match_operand:V8DI 0 "register_operand" "=v")
14570 (vec_select:V8DI
14571 (vec_concat:V16DI
14572 (match_operand:V8DI 1 "register_operand" "v")
14573 (match_operand:V8DI 2 "nonimmediate_operand" "vm"))
14574 (parallel [(const_int 0) (const_int 8)
14575 (const_int 2) (const_int 10)
14576 (const_int 4) (const_int 12)
14577 (const_int 6) (const_int 14)])))]
14578 "TARGET_AVX512F && TARGET_EVEX512"
14579 "vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14580 [(set_attr "type" "sselog")
14581 (set_attr "prefix" "evex")
14582 (set_attr "mode" "XI")])
14583
14584 (define_insn "vec_interleave_lowv2di<mask_name>"
14585 [(set (match_operand:V2DI 0 "register_operand" "=x,v")
14586 (vec_select:V2DI
14587 (vec_concat:V4DI
14588 (match_operand:V2DI 1 "register_operand" "0,v")
14589 (match_operand:V2DI 2 "vector_operand" "xBm,vm"))
14590 (parallel [(const_int 0)
14591 (const_int 2)])))]
14592 "TARGET_SSE2 && <mask_avx512vl_condition>"
14593 "@
14594 punpcklqdq\t{%2, %0|%0, %2}
14595 vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14596 [(set_attr "isa" "noavx,avx")
14597 (set_attr "type" "sselog")
14598 (set_attr "prefix_data16" "1,*")
14599 (set_attr "prefix" "orig,vex")
14600 (set_attr "mode" "TI")])
14601
14602 (define_insn "sse2_shufpd_<mode>"
14603 [(set (match_operand:VI8F_128 0 "register_operand" "=x,v")
14604 (vec_select:VI8F_128
14605 (vec_concat:<ssedoublevecmode>
14606 (match_operand:VI8F_128 1 "register_operand" "0,v")
14607 (match_operand:VI8F_128 2 "vector_operand" "xBm,vm"))
14608 (parallel [(match_operand 3 "const_0_to_1_operand")
14609 (match_operand 4 "const_2_to_3_operand")])))]
14610 "TARGET_SSE2"
14611 {
14612 int mask;
14613 mask = INTVAL (operands[3]);
14614 mask |= (INTVAL (operands[4]) - 2) << 1;
14615 operands[3] = GEN_INT (mask);
14616
14617 switch (which_alternative)
14618 {
14619 case 0:
14620 return "shufpd\t{%3, %2, %0|%0, %2, %3}";
14621 case 1:
14622 return "vshufpd\t{%3, %2, %1, %0|%0, %1, %2, %3}";
14623 default:
14624 gcc_unreachable ();
14625 }
14626 }
14627 [(set_attr "isa" "noavx,avx")
14628 (set_attr "type" "sseshuf")
14629 (set_attr "length_immediate" "1")
14630 (set_attr "prefix" "orig,maybe_evex")
14631 (set_attr "mode" "V2DF")])
14632
14633 ;; Avoid combining registers from different units in a single alternative,
14634 ;; see comment above inline_secondary_memory_needed function in i386.cc
14635 (define_insn "sse2_storehpd"
14636 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,Yv,x,*f,r")
14637 (vec_select:DF
14638 (match_operand:V2DF 1 "nonimmediate_operand" " v,0, v,o,o,o")
14639 (parallel [(const_int 1)])))]
14640 "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
14641 "@
14642 %vmovhpd\t{%1, %0|%0, %1}
14643 unpckhpd\t%0, %0
14644 vunpckhpd\t{%d1, %0|%0, %d1}
14645 #
14646 #
14647 #"
14648 [(set_attr "isa" "*,noavx,avx,*,*,*")
14649 (set_attr "type" "ssemov,sselog1,sselog1,ssemov,fmov,imov")
14650 (set (attr "prefix_data16")
14651 (if_then_else
14652 (and (eq_attr "alternative" "0")
14653 (not (match_test "TARGET_AVX")))
14654 (const_string "1")
14655 (const_string "*")))
14656 (set_attr "prefix" "maybe_vex,orig,maybe_evex,*,*,*")
14657 (set_attr "mode" "V1DF,V1DF,V2DF,DF,DF,DF")])
14658
14659 (define_split
14660 [(set (match_operand:DF 0 "register_operand")
14661 (vec_select:DF
14662 (match_operand:V2DF 1 "memory_operand")
14663 (parallel [(const_int 1)])))]
14664 "TARGET_SSE2 && reload_completed"
14665 [(set (match_dup 0) (match_dup 1))]
14666 "operands[1] = adjust_address (operands[1], DFmode, 8);")
14667
14668 (define_insn "*vec_extractv2df_1_sse"
14669 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x")
14670 (vec_select:DF
14671 (match_operand:V2DF 1 "nonimmediate_operand" "x,x,o")
14672 (parallel [(const_int 1)])))]
14673 "!TARGET_SSE2 && TARGET_SSE
14674 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
14675 "@
14676 movhps\t{%1, %0|%0, %1}
14677 movhlps\t{%1, %0|%0, %1}
14678 movlps\t{%H1, %0|%0, %H1}"
14679 [(set_attr "type" "ssemov")
14680 (set_attr "mode" "V2SF,V4SF,V2SF")])
14681
14682 ;; Convert highpart SUBREG in sse2_storehpd or *vec_extractv2df_1_sse.
14683 (define_split
14684 [(set (match_operand:DF 0 "register_operand")
14685 (subreg:DF (match_operand:V2DF 1 "register_operand") 8))]
14686 "TARGET_SSE"
14687 [(set (match_dup 0)
14688 (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))])
14689
14690 ;; Avoid combining registers from different units in a single alternative,
14691 ;; see comment above inline_secondary_memory_needed function in i386.cc
14692 (define_insn "sse2_storelpd"
14693 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x,*f,r")
14694 (vec_select:DF
14695 (match_operand:V2DF 1 "nonimmediate_operand" " v,x,m,m,m")
14696 (parallel [(const_int 0)])))]
14697 "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
14698 "@
14699 %vmovlpd\t{%1, %0|%0, %1}
14700 #
14701 #
14702 #
14703 #"
14704 [(set_attr "type" "ssemov,ssemov,ssemov,fmov,imov")
14705 (set (attr "prefix_data16")
14706 (if_then_else (eq_attr "alternative" "0")
14707 (const_string "1")
14708 (const_string "*")))
14709 (set_attr "prefix" "maybe_vex")
14710 (set_attr "mode" "V1DF,DF,DF,DF,DF")])
14711
14712 (define_split
14713 [(set (match_operand:DF 0 "register_operand")
14714 (vec_select:DF
14715 (match_operand:V2DF 1 "nonimmediate_operand")
14716 (parallel [(const_int 0)])))]
14717 "TARGET_SSE2 && reload_completed"
14718 [(set (match_dup 0) (match_dup 1))]
14719 "operands[1] = gen_lowpart (DFmode, operands[1]);")
14720
14721 (define_insn "*vec_extractv2df_0_sse"
14722 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x")
14723 (vec_select:DF
14724 (match_operand:V2DF 1 "nonimmediate_operand" "x,x,m")
14725 (parallel [(const_int 0)])))]
14726 "!TARGET_SSE2 && TARGET_SSE
14727 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
14728 "@
14729 movlps\t{%1, %0|%0, %1}
14730 movaps\t{%1, %0|%0, %1}
14731 movlps\t{%1, %0|%0, %q1}"
14732 [(set_attr "type" "ssemov")
14733 (set_attr "mode" "V2SF,V4SF,V2SF")])
14734
14735 ;; Convert lowpart SUBREG into sse2_storelpd or *vec_extractv2df_0_sse.
14736 (define_split
14737 [(set (match_operand:DF 0 "register_operand")
14738 (subreg:DF (match_operand:V2DF 1 "register_operand") 0))]
14739 "TARGET_SSE"
14740 [(set (match_dup 0)
14741 (vec_select:DF (match_dup 1) (parallel [(const_int 0)])))])
14742
14743 (define_expand "sse2_loadhpd_exp"
14744 [(set (match_operand:V2DF 0 "nonimmediate_operand")
14745 (vec_concat:V2DF
14746 (vec_select:DF
14747 (match_operand:V2DF 1 "nonimmediate_operand")
14748 (parallel [(const_int 0)]))
14749 (match_operand:DF 2 "nonimmediate_operand")))]
14750 "TARGET_SSE2"
14751 {
14752 rtx dst = ix86_fixup_binary_operands (UNKNOWN, V2DFmode, operands);
14753
14754 emit_insn (gen_sse2_loadhpd (dst, operands[1], operands[2]));
14755
14756 /* Fix up the destination if needed. */
14757 if (dst != operands[0])
14758 emit_move_insn (operands[0], dst);
14759
14760 DONE;
14761 })
14762
14763 ;; Avoid combining registers from different units in a single alternative,
14764 ;; see comment above inline_secondary_memory_needed function in i386.cc
14765 (define_insn "sse2_loadhpd"
14766 [(set (match_operand:V2DF 0 "nonimmediate_operand"
14767 "=x,v,x,v ,o,o ,o")
14768 (vec_concat:V2DF
14769 (vec_select:DF
14770 (match_operand:V2DF 1 "nonimmediate_operand"
14771 " 0,v,0,v ,0,0 ,0")
14772 (parallel [(const_int 0)]))
14773 (match_operand:DF 2 "nonimmediate_operand"
14774 " m,m,x,Yv,x,*f,r")))]
14775 "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
14776 "@
14777 movhpd\t{%2, %0|%0, %2}
14778 vmovhpd\t{%2, %1, %0|%0, %1, %2}
14779 unpcklpd\t{%2, %0|%0, %2}
14780 vunpcklpd\t{%2, %1, %0|%0, %1, %2}
14781 #
14782 #
14783 #"
14784 [(set_attr "isa" "noavx,avx,noavx,avx,*,*,*")
14785 (set_attr "type" "ssemov2,ssemov2,sselog,sselog,ssemov,fmov,imov")
14786 (set (attr "prefix_data16")
14787 (if_then_else (eq_attr "alternative" "0")
14788 (const_string "1")
14789 (const_string "*")))
14790 (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,*,*,*")
14791 (set_attr "mode" "V1DF,V1DF,V2DF,V2DF,DF,DF,DF")])
14792
14793 (define_split
14794 [(set (match_operand:V2DF 0 "memory_operand")
14795 (vec_concat:V2DF
14796 (vec_select:DF (match_dup 0) (parallel [(const_int 0)]))
14797 (match_operand:DF 1 "register_operand")))]
14798 "TARGET_SSE2 && reload_completed"
14799 [(set (match_dup 0) (match_dup 1))]
14800 "operands[0] = adjust_address (operands[0], DFmode, 8);")
14801
14802 (define_expand "sse2_loadlpd_exp"
14803 [(set (match_operand:V2DF 0 "nonimmediate_operand")
14804 (vec_concat:V2DF
14805 (match_operand:DF 2 "nonimmediate_operand")
14806 (vec_select:DF
14807 (match_operand:V2DF 1 "nonimmediate_operand")
14808 (parallel [(const_int 1)]))))]
14809 "TARGET_SSE2"
14810 {
14811 rtx dst = ix86_fixup_binary_operands (UNKNOWN, V2DFmode, operands);
14812
14813 emit_insn (gen_sse2_loadlpd (dst, operands[1], operands[2]));
14814
14815 /* Fix up the destination if needed. */
14816 if (dst != operands[0])
14817 emit_move_insn (operands[0], dst);
14818
14819 DONE;
14820 })
14821
14822 ;; Avoid combining registers from different units in a single alternative,
14823 ;; see comment above inline_secondary_memory_needed function in i386.cc
14824 (define_insn "sse2_loadlpd"
14825 [(set (match_operand:V2DF 0 "nonimmediate_operand"
14826 "=v,x,v,x,v,x,x,v,m,m ,m")
14827 (vec_concat:V2DF
14828 (match_operand:DF 2 "nonimmediate_operand"
14829 "vm,m,m,x,v,0,0,v,x,*f,r")
14830 (vec_select:DF
14831 (match_operand:V2DF 1 "nonimm_or_0_operand"
14832 " C,0,v,0,v,x,o,o,0,0 ,0")
14833 (parallel [(const_int 1)]))))]
14834 "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
14835 "@
14836 %vmovq\t{%2, %0|%0, %2}
14837 movlpd\t{%2, %0|%0, %2}
14838 vmovlpd\t{%2, %1, %0|%0, %1, %2}
14839 movsd\t{%2, %0|%0, %2}
14840 vmovsd\t{%2, %1, %0|%0, %1, %2}
14841 shufpd\t{$2, %1, %0|%0, %1, 2}
14842 movhpd\t{%H1, %0|%0, %H1}
14843 vmovhpd\t{%H1, %2, %0|%0, %2, %H1}
14844 #
14845 #
14846 #"
14847 [(set_attr "isa" "*,noavx,avx,noavx,avx,noavx,noavx,avx,*,*,*")
14848 (set (attr "type")
14849 (cond [(eq_attr "alternative" "5")
14850 (const_string "sselog")
14851 (eq_attr "alternative" "9")
14852 (const_string "fmov")
14853 (eq_attr "alternative" "10")
14854 (const_string "imov")
14855 (eq_attr "alternative" "0,1,2")
14856 (const_string "ssemov2")
14857 ]
14858 (const_string "ssemov")))
14859 (set (attr "prefix_data16")
14860 (if_then_else (eq_attr "alternative" "1,6")
14861 (const_string "1")
14862 (const_string "*")))
14863 (set (attr "length_immediate")
14864 (if_then_else (eq_attr "alternative" "5")
14865 (const_string "1")
14866 (const_string "*")))
14867 (set (attr "prefix")
14868 (cond [(eq_attr "alternative" "0")
14869 (const_string "maybe_vex")
14870 (eq_attr "alternative" "1,3,5,6")
14871 (const_string "orig")
14872 (eq_attr "alternative" "2,4,7")
14873 (const_string "maybe_evex")
14874 ]
14875 (const_string "*")))
14876 (set_attr "mode" "DF,V1DF,V1DF,V1DF,V1DF,V2DF,V1DF,V1DF,DF,DF,DF")])
14877
14878 (define_split
14879 [(set (match_operand:V2DF 0 "memory_operand")
14880 (vec_concat:V2DF
14881 (match_operand:DF 1 "register_operand")
14882 (vec_select:DF (match_dup 0) (parallel [(const_int 1)]))))]
14883 "TARGET_SSE2 && reload_completed"
14884 [(set (match_dup 0) (match_dup 1))]
14885 "operands[0] = adjust_address (operands[0], DFmode, 0);")
14886
14887 (define_insn "sse2_movsd_<mode>"
14888 [(set (match_operand:VI8F_128 0 "nonimmediate_operand" "=x,v,x,v,m,x,x,v,o")
14889 (vec_merge:VI8F_128
14890 (match_operand:VI8F_128 2 "nonimmediate_operand" " x,v,m,m,v,0,0,v,0")
14891 (match_operand:VI8F_128 1 "nonimmediate_operand" " 0,v,0,v,0,x,o,o,v")
14892 (const_int 1)))]
14893 "TARGET_SSE2"
14894 "@
14895 movsd\t{%2, %0|%0, %2}
14896 vmovsd\t{%2, %1, %0|%0, %1, %2}
14897 movlpd\t{%2, %0|%0, %q2}
14898 vmovlpd\t{%2, %1, %0|%0, %1, %q2}
14899 %vmovlpd\t{%2, %0|%q0, %2}
14900 shufpd\t{$2, %1, %0|%0, %1, 2}
14901 movhps\t{%H1, %0|%0, %H1}
14902 vmovhps\t{%H1, %2, %0|%0, %2, %H1}
14903 %vmovhps\t{%1, %H0|%H0, %1}"
14904 [(set_attr "isa" "noavx,avx,noavx,avx,*,noavx,noavx,avx,*")
14905 (set (attr "type")
14906 (if_then_else
14907 (eq_attr "alternative" "5")
14908 (const_string "sselog")
14909 (const_string "ssemov2")))
14910 (set (attr "prefix_data16")
14911 (if_then_else
14912 (and (eq_attr "alternative" "2,4")
14913 (not (match_test "TARGET_AVX")))
14914 (const_string "1")
14915 (const_string "*")))
14916 (set (attr "length_immediate")
14917 (if_then_else (eq_attr "alternative" "5")
14918 (const_string "1")
14919 (const_string "*")))
14920 (set (attr "prefix")
14921 (cond [(eq_attr "alternative" "1,3,7")
14922 (const_string "maybe_evex")
14923 (eq_attr "alternative" "4,8")
14924 (const_string "maybe_vex")
14925 ]
14926 (const_string "orig")))
14927 (set_attr "mode" "DF,DF,V1DF,V1DF,V1DF,V2DF,V1DF,V1DF,V1DF")])
14928
14929 (define_insn "vec_dupv2df<mask_name>"
14930 [(set (match_operand:V2DF 0 "register_operand" "=x,v,v")
14931 (vec_duplicate:V2DF
14932 (match_operand:DF 1 "nonimmediate_operand" "0,Yvm,vm")))]
14933 "TARGET_SSE2"
14934 "@
14935 unpcklpd\t%0, %0
14936 %vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}
14937 vbroadcastsd\t{%1, }%g0<mask_operand2>{|, %1}"
14938 [(set_attr "isa" "noavx,sse3,*")
14939 (set_attr "type" "sselog1,ssemov,ssemov")
14940 (set_attr "prefix" "orig,maybe_evex,evex")
14941 (set_attr "mode" "V2DF,DF,V8DF")
14942 (set (attr "enabled")
14943 (cond [(eq_attr "alternative" "2")
14944 (symbol_ref "TARGET_AVX512F && TARGET_EVEX512
14945 && !TARGET_AVX512VL && !TARGET_PREFER_AVX256")
14946 (match_test "<mask_avx512vl_condition>")
14947 (const_string "*")
14948 ]
14949 (symbol_ref "false")))])
14950
14951 (define_insn "vec_concatv2df"
14952 [(set (match_operand:V2DF 0 "register_operand" "=x,x,v,x,x, v,x,x")
14953 (vec_concat:V2DF
14954 (match_operand:DF 1 "nonimmediate_operand" " 0,x,v,0,x,vm,0,0")
14955 (match_operand:DF 2 "nonimm_or_0_operand" " x,x,v,m,m, C,x,m")))]
14956 "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
14957 "@
14958 unpcklpd\t{%2, %0|%0, %2}
14959 vunpcklpd\t{%2, %1, %0|%0, %1, %2}
14960 vunpcklpd\t{%2, %1, %0|%0, %1, %2}
14961 movhpd\t{%2, %0|%0, %2}
14962 vmovhpd\t{%2, %1, %0|%0, %1, %2}
14963 %vmovq\t{%1, %0|%0, %1}
14964 movlhps\t{%2, %0|%0, %2}
14965 movhps\t{%2, %0|%0, %2}"
14966 [(set (attr "isa")
14967 (cond [(eq_attr "alternative" "0,3")
14968 (const_string "sse2_noavx")
14969 (eq_attr "alternative" "1,4")
14970 (const_string "avx")
14971 (eq_attr "alternative" "2")
14972 (const_string "avx512vl")
14973 (eq_attr "alternative" "5")
14974 (const_string "sse2")
14975 ]
14976 (const_string "noavx")))
14977 (set (attr "type")
14978 (if_then_else
14979 (eq_attr "alternative" "0,1,2")
14980 (const_string "sselog")
14981 (const_string "ssemov2")))
14982 (set (attr "prefix_data16")
14983 (if_then_else (eq_attr "alternative" "3")
14984 (const_string "1")
14985 (const_string "*")))
14986 (set (attr "prefix")
14987 (cond [(eq_attr "alternative" "1,4")
14988 (const_string "vex")
14989 (eq_attr "alternative" "2")
14990 (const_string "evex")
14991 (eq_attr "alternative" "5")
14992 (const_string "maybe_vex")
14993 ]
14994 (const_string "orig")))
14995 (set_attr "mode" "V2DF,V2DF,V2DF,V1DF,V1DF,DF,V4SF,V2SF")])
14996
14997 ;; vmovq clears also the higher bits.
14998 (define_insn "vec_set<mode>_0"
14999 [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
15000 (vec_merge:VF2_512_256
15001 (vec_duplicate:VF2_512_256
15002 (match_operand:<ssescalarmode> 2 "nonimmediate_operand" "vm"))
15003 (match_operand:VF2_512_256 1 "const0_operand")
15004 (const_int 1)))]
15005 "TARGET_AVX"
15006 "vmovq\t{%2, %x0|%x0, %2}"
15007 [(set_attr "type" "ssemov")
15008 (set_attr "prefix" "maybe_evex")
15009 (set_attr "mode" "DF")])
15010
15011 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15012 ;;
15013 ;; Parallel integer down-conversion operations
15014 ;;
15015 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15016
15017 (define_mode_iterator PMOV_DST_MODE_1 [V16QI V16HI V8SI V8HI])
15018 (define_mode_attr pmov_src_mode
15019 [(V16QI "V16SI") (V16HI "V16SI") (V8SI "V8DI") (V8HI "V8DI")])
15020 (define_mode_attr pmov_src_lower
15021 [(V16QI "v16si") (V16HI "v16si") (V8SI "v8di") (V8HI "v8di")])
15022 (define_mode_attr pmov_suff_1
15023 [(V16QI "db") (V16HI "dw") (V8SI "qd") (V8HI "qw")])
15024
15025 (define_expand "trunc<pmov_src_lower><mode>2"
15026 [(set (match_operand:PMOV_DST_MODE_1 0 "nonimmediate_operand")
15027 (truncate:PMOV_DST_MODE_1
15028 (match_operand:<pmov_src_mode> 1 "register_operand")))]
15029 "TARGET_AVX512F && TARGET_EVEX512")
15030
15031 (define_insn "*avx512f_<code><pmov_src_lower><mode>2"
15032 [(set (match_operand:PMOV_DST_MODE_1 0 "nonimmediate_operand" "=v,m")
15033 (any_truncate:PMOV_DST_MODE_1
15034 (match_operand:<pmov_src_mode> 1 "register_operand" "v,v")))]
15035 "TARGET_AVX512F && TARGET_EVEX512"
15036 "vpmov<trunsuffix><pmov_suff_1>\t{%1, %0|%0, %1}"
15037 [(set_attr "type" "ssemov")
15038 (set_attr "memory" "none,store")
15039 (set_attr "prefix" "evex")
15040 (set_attr "mode" "<sseinsnmode>")])
15041
15042 (define_insn_and_split "*avx512bw_permvar_truncv16siv16hi_1"
15043 [(set (match_operand:V16HI 0 "nonimmediate_operand")
15044 (vec_select:V16HI
15045 (unspec:V32HI
15046 [(match_operand:V32HI 1 "register_operand")
15047 (match_operand:V32HI 2 "permvar_truncate_operand")]
15048 UNSPEC_VPERMVAR)
15049 (parallel [(const_int 0) (const_int 1)
15050 (const_int 2) (const_int 3)
15051 (const_int 4) (const_int 5)
15052 (const_int 6) (const_int 7)
15053 (const_int 8) (const_int 9)
15054 (const_int 10) (const_int 11)
15055 (const_int 12) (const_int 13)
15056 (const_int 14) (const_int 15)])))]
15057 "TARGET_AVX512BW && TARGET_EVEX512 && ix86_pre_reload_split ()"
15058 "#"
15059 "&& 1"
15060 [(set (match_dup 0)
15061 (truncate:V16HI (match_dup 1)))]
15062 "operands[1] = lowpart_subreg (V16SImode,
15063 force_reg (V32HImode, operands[1]),
15064 V32HImode);")
15065
15066 (define_insn_and_split "*avx512bw_permvar_truncv16siv16hi_1_hf"
15067 [(set (match_operand:V16HF 0 "nonimmediate_operand")
15068 (vec_select:V16HF
15069 (subreg:V32HF
15070 (unspec:V32HI
15071 [(match_operand:V32HI 1 "register_operand")
15072 (match_operand:V32HI 2 "permvar_truncate_operand")]
15073 UNSPEC_VPERMVAR) 0)
15074 (parallel [(const_int 0) (const_int 1)
15075 (const_int 2) (const_int 3)
15076 (const_int 4) (const_int 5)
15077 (const_int 6) (const_int 7)
15078 (const_int 8) (const_int 9)
15079 (const_int 10) (const_int 11)
15080 (const_int 12) (const_int 13)
15081 (const_int 14) (const_int 15)])))]
15082 "TARGET_AVX512BW && TARGET_EVEX512 && ix86_pre_reload_split ()"
15083 "#"
15084 "&& 1"
15085 [(set (match_dup 0)
15086 (truncate:V16HI (match_dup 1)))]
15087 {
15088 operands[1] = lowpart_subreg (V16SImode,
15089 force_reg (V32HImode, operands[1]),
15090 V32HImode);
15091 if (MEM_P (operands[0]))
15092 operands[0] = lowpart_subreg (V16HImode, operands[0], V16HFmode);
15093 else
15094 {
15095 rtx op0 = gen_reg_rtx (V16HImode);
15096 emit_insn (gen_truncv16siv16hi2 (op0, operands[1]));
15097 emit_move_insn (operands[0], lowpart_subreg (V16HFmode, op0, V16HImode));
15098 DONE;
15099 }
15100 })
15101
15102
15103 (define_insn_and_split "*avx512f_permvar_truncv8siv8hi_1"
15104 [(set (match_operand:V8HI 0 "nonimmediate_operand")
15105 (vec_select:V8HI
15106 (unspec:V16HI
15107 [(match_operand:V16HI 1 "register_operand")
15108 (match_operand:V16HI 2 "permvar_truncate_operand")]
15109 UNSPEC_VPERMVAR)
15110 (parallel [(const_int 0) (const_int 1)
15111 (const_int 2) (const_int 3)
15112 (const_int 4) (const_int 5)
15113 (const_int 6) (const_int 7)])))]
15114 "TARGET_AVX512VL && TARGET_AVX512BW && ix86_pre_reload_split ()"
15115 "#"
15116 "&& 1"
15117 [(set (match_dup 0)
15118 (truncate:V8HI (match_dup 1)))]
15119 "operands[1] = lowpart_subreg (V8SImode,
15120 force_reg (V16HImode, operands[1]),
15121 V16HImode);")
15122
15123 (define_insn_and_split "*avx512f_permvar_truncv8siv8hi_1_hf"
15124 [(set (match_operand:V8HF 0 "nonimmediate_operand")
15125 (vec_select:V8HF
15126 (subreg:V16HF
15127 (unspec:V16HI
15128 [(match_operand:V16HI 1 "register_operand")
15129 (match_operand:V16HI 2 "permvar_truncate_operand")]
15130 UNSPEC_VPERMVAR) 0)
15131 (parallel [(const_int 0) (const_int 1)
15132 (const_int 2) (const_int 3)
15133 (const_int 4) (const_int 5)
15134 (const_int 6) (const_int 7)])))]
15135 "TARGET_AVX512VL && TARGET_AVX512BW && ix86_pre_reload_split ()"
15136 "#"
15137 "&& 1"
15138 [(set (match_dup 0)
15139 (truncate:V8HI (match_dup 1)))]
15140 {
15141 operands[1] = lowpart_subreg (V8SImode,
15142 force_reg (V16HImode, operands[1]),
15143 V16HImode);
15144 if (MEM_P (operands[0]))
15145 operands[0] = lowpart_subreg (V8HImode, operands[0], V8HFmode);
15146 else
15147 {
15148 rtx op0 = gen_reg_rtx (V8HImode);
15149 emit_insn (gen_truncv8siv8hi2 (op0, operands[1]));
15150 emit_move_insn (operands[0], lowpart_subreg (V8HFmode, op0, V8HImode));
15151 DONE;
15152 }
15153 })
15154
15155 (define_insn_and_split "*avx512f_vpermvar_truncv8div8si_1"
15156 [(set (match_operand:V8SI 0 "nonimmediate_operand")
15157 (vec_select:V8SI
15158 (unspec:V16SI
15159 [(match_operand:V16SI 1 "register_operand")
15160 (match_operand:V16SI 2 "permvar_truncate_operand")]
15161 UNSPEC_VPERMVAR)
15162 (parallel [(const_int 0) (const_int 1)
15163 (const_int 2) (const_int 3)
15164 (const_int 4) (const_int 5)
15165 (const_int 6) (const_int 7)])))]
15166 "TARGET_AVX512F && TARGET_EVEX512 && ix86_pre_reload_split ()"
15167 "#"
15168 "&& 1"
15169 [(set (match_dup 0)
15170 (truncate:V8SI (match_dup 1)))]
15171 "operands[1] = lowpart_subreg (V8DImode,
15172 force_reg (V16SImode, operands[1]),
15173 V16SImode);")
15174
15175 (define_insn "avx512f_<code><pmov_src_lower><mode>2_mask"
15176 [(set (match_operand:PMOV_DST_MODE_1 0 "nonimmediate_operand" "=v,m")
15177 (vec_merge:PMOV_DST_MODE_1
15178 (any_truncate:PMOV_DST_MODE_1
15179 (match_operand:<pmov_src_mode> 1 "register_operand" "v,v"))
15180 (match_operand:PMOV_DST_MODE_1 2 "nonimm_or_0_operand" "0C,0")
15181 (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
15182 "TARGET_AVX512F && TARGET_EVEX512"
15183 "vpmov<trunsuffix><pmov_suff_1>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15184 [(set_attr "type" "ssemov")
15185 (set_attr "memory" "none,store")
15186 (set_attr "prefix" "evex")
15187 (set_attr "mode" "<sseinsnmode>")])
15188
15189 (define_expand "avx512f_<code><pmov_src_lower><mode>2_mask_store"
15190 [(set (match_operand:PMOV_DST_MODE_1 0 "memory_operand")
15191 (vec_merge:PMOV_DST_MODE_1
15192 (any_truncate:PMOV_DST_MODE_1
15193 (match_operand:<pmov_src_mode> 1 "register_operand"))
15194 (match_dup 0)
15195 (match_operand:<avx512fmaskmode> 2 "register_operand")))]
15196 "TARGET_AVX512F && TARGET_EVEX512")
15197
15198 (define_expand "truncv32hiv32qi2"
15199 [(set (match_operand:V32QI 0 "nonimmediate_operand")
15200 (truncate:V32QI
15201 (match_operand:V32HI 1 "register_operand")))]
15202 "TARGET_AVX512BW && TARGET_EVEX512")
15203
15204 (define_insn "avx512bw_<code>v32hiv32qi2"
15205 [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
15206 (any_truncate:V32QI
15207 (match_operand:V32HI 1 "register_operand" "v,v")))]
15208 "TARGET_AVX512BW && TARGET_EVEX512"
15209 "vpmov<trunsuffix>wb\t{%1, %0|%0, %1}"
15210 [(set_attr "type" "ssemov")
15211 (set_attr "memory" "none,store")
15212 (set_attr "prefix" "evex")
15213 (set_attr "mode" "XI")])
15214
15215 (define_insn_and_split "*avx512f_permvar_truncv32hiv32qi_1"
15216 [(set (match_operand:V32QI 0 "nonimmediate_operand")
15217 (vec_select:V32QI
15218 (unspec:V64QI
15219 [(match_operand:V64QI 1 "register_operand")
15220 (match_operand:V64QI 2 "permvar_truncate_operand")]
15221 UNSPEC_VPERMVAR)
15222 (parallel [(const_int 0) (const_int 1)
15223 (const_int 2) (const_int 3)
15224 (const_int 4) (const_int 5)
15225 (const_int 6) (const_int 7)
15226 (const_int 8) (const_int 9)
15227 (const_int 10) (const_int 11)
15228 (const_int 12) (const_int 13)
15229 (const_int 14) (const_int 15)
15230 (const_int 16) (const_int 17)
15231 (const_int 18) (const_int 19)
15232 (const_int 20) (const_int 21)
15233 (const_int 22) (const_int 23)
15234 (const_int 24) (const_int 25)
15235 (const_int 26) (const_int 27)
15236 (const_int 28) (const_int 29)
15237 (const_int 30) (const_int 31)])))]
15238 "TARGET_AVX512VBMI && TARGET_EVEX512 && ix86_pre_reload_split ()"
15239 "#"
15240 "&& 1"
15241 [(set (match_dup 0)
15242 (truncate:V32QI (match_dup 1)))]
15243 "operands[1] = lowpart_subreg (V32HImode,
15244 force_reg (V64QImode, operands[1]),
15245 V64QImode);")
15246
15247 (define_insn "avx512bw_<code>v32hiv32qi2_mask"
15248 [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
15249 (vec_merge:V32QI
15250 (any_truncate:V32QI
15251 (match_operand:V32HI 1 "register_operand" "v,v"))
15252 (match_operand:V32QI 2 "nonimm_or_0_operand" "0C,0")
15253 (match_operand:SI 3 "register_operand" "Yk,Yk")))]
15254 "TARGET_AVX512BW && TARGET_EVEX512"
15255 "vpmov<trunsuffix>wb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15256 [(set_attr "type" "ssemov")
15257 (set_attr "memory" "none,store")
15258 (set_attr "prefix" "evex")
15259 (set_attr "mode" "XI")])
15260
15261 (define_expand "avx512bw_<code>v32hiv32qi2_mask_store"
15262 [(set (match_operand:V32QI 0 "nonimmediate_operand")
15263 (vec_merge:V32QI
15264 (any_truncate:V32QI
15265 (match_operand:V32HI 1 "register_operand"))
15266 (match_dup 0)
15267 (match_operand:SI 2 "register_operand")))]
15268 "TARGET_AVX512BW && TARGET_EVEX512")
15269
15270 (define_mode_iterator PMOV_DST_MODE_2
15271 [V4SI V8HI (V16QI "TARGET_AVX512BW")])
15272 (define_mode_iterator PMOV_DST_MODE_2_AVX2
15273 [V4SI V8HI V16QI])
15274 (define_mode_attr pmov_suff_2
15275 [(V16QI "wb") (V8HI "dw") (V4SI "qd")])
15276
15277 (define_expand "trunc<ssedoublemodelower><mode>2"
15278 [(set (match_operand:PMOV_DST_MODE_2_AVX2 0 "nonimmediate_operand")
15279 (truncate:PMOV_DST_MODE_2_AVX2
15280 (match_operand:<ssedoublemode> 1 "register_operand")))]
15281 "TARGET_AVX2"
15282 {
15283 if (!TARGET_AVX512VL
15284 || (<MODE>mode == V16QImode && !TARGET_AVX512BW))
15285 {
15286 ix86_expand_trunc_with_avx2_noavx512f (operands[0],
15287 operands[1],
15288 <ssedoublevecmode>mode);
15289 DONE;
15290 }
15291 })
15292
15293 (define_insn "*avx512vl_<code><ssedoublemodelower><mode>2"
15294 [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand" "=v,m")
15295 (any_truncate:PMOV_DST_MODE_2
15296 (match_operand:<ssedoublemode> 1 "register_operand" "v,v")))]
15297 "TARGET_AVX512VL"
15298 "vpmov<trunsuffix><pmov_suff_2>\t{%1, %0|%0, %1}"
15299 [(set_attr "type" "ssemov")
15300 (set_attr "memory" "none,store")
15301 (set_attr "prefix" "evex")
15302 (set_attr "mode" "<sseinsnmode>")])
15303
15304 (define_insn_and_split "*avx512f_permvar_truncv16hiv16qi_1"
15305 [(set (match_operand:V16QI 0 "nonimmediate_operand")
15306 (vec_select:V16QI
15307 (unspec:V32QI
15308 [(match_operand:V32QI 1 "register_operand")
15309 (match_operand:V32QI 2 "permvar_truncate_operand")]
15310 UNSPEC_VPERMVAR)
15311 (parallel [(const_int 0) (const_int 1)
15312 (const_int 2) (const_int 3)
15313 (const_int 4) (const_int 5)
15314 (const_int 6) (const_int 7)
15315 (const_int 8) (const_int 9)
15316 (const_int 10) (const_int 11)
15317 (const_int 12) (const_int 13)
15318 (const_int 14) (const_int 15)])))]
15319 "TARGET_AVX512VL && TARGET_AVX512VBMI
15320 && ix86_pre_reload_split ()"
15321 "#"
15322 "&& 1"
15323 [(set (match_dup 0)
15324 (truncate:V16QI (match_dup 1)))]
15325 "operands[1] = lowpart_subreg (V16HImode,
15326 force_reg (V32QImode, operands[1]),
15327 V32QImode);")
15328
15329 (define_insn_and_split "*avx512f_permvar_truncv4div4si_1"
15330 [(set (match_operand:V4SI 0 "nonimmediate_operand")
15331 (vec_select:V4SI
15332 (unspec:V8SI
15333 [(match_operand:V8SI 1 "register_operand")
15334 (match_operand:V8SI 2 "permvar_truncate_operand")]
15335 UNSPEC_VPERMVAR)
15336 (parallel [(const_int 0) (const_int 1)
15337 (const_int 2) (const_int 3)])))]
15338 "TARGET_AVX512VL && ix86_pre_reload_split ()"
15339 "#"
15340 "&& 1"
15341 [(set (match_dup 0)
15342 (truncate:V4SI (match_dup 1)))]
15343 "operands[1] = lowpart_subreg (V4DImode,
15344 force_reg (V8SImode, operands[1]),
15345 V8SImode);")
15346
15347 (define_insn "<avx512>_<code><ssedoublemodelower><mode>2_mask"
15348 [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand" "=v,m")
15349 (vec_merge:PMOV_DST_MODE_2
15350 (any_truncate:PMOV_DST_MODE_2
15351 (match_operand:<ssedoublemode> 1 "register_operand" "v,v"))
15352 (match_operand:PMOV_DST_MODE_2 2 "nonimm_or_0_operand" "0C,0")
15353 (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
15354 "TARGET_AVX512VL"
15355 "vpmov<trunsuffix><pmov_suff_2>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15356 [(set_attr "type" "ssemov")
15357 (set_attr "memory" "none,store")
15358 (set_attr "prefix" "evex")
15359 (set_attr "mode" "<sseinsnmode>")])
15360
15361 (define_expand "<avx512>_<code><ssedoublemodelower><mode>2_mask_store"
15362 [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand")
15363 (vec_merge:PMOV_DST_MODE_2
15364 (any_truncate:PMOV_DST_MODE_2
15365 (match_operand:<ssedoublemode> 1 "register_operand"))
15366 (match_dup 0)
15367 (match_operand:<avx512fmaskmode> 2 "register_operand")))]
15368 "TARGET_AVX512VL")
15369
15370 (define_mode_iterator PMOV_SRC_MODE_3 [V4DI V2DI V8SI V4SI (V8HI "TARGET_AVX512BW")])
15371 (define_mode_iterator PMOV_SRC_MODE_3_AVX2
15372 [(V4DI "TARGET_AVX2") V2DI (V8SI "TARGET_AVX2") V4SI V8HI])
15373 (define_mode_attr pmov_dst_3_lower
15374 [(V4DI "v4qi") (V2DI "v2qi") (V8SI "v8qi") (V4SI "v4qi") (V8HI "v8qi")])
15375 (define_mode_attr pmov_dst_3
15376 [(V4DI "V4QI") (V2DI "V2QI") (V8SI "V8QI") (V4SI "V4QI") (V8HI "V8QI")])
15377 (define_mode_attr pmov_dst_zeroed_3
15378 [(V4DI "V12QI") (V2DI "V14QI") (V8SI "V8QI") (V4SI "V12QI") (V8HI "V8QI")])
15379 (define_mode_attr pmov_suff_3
15380 [(V4DI "qb") (V2DI "qb") (V8SI "db") (V4SI "db") (V8HI "wb")])
15381
15382 (define_expand "trunc<mode><pmov_dst_3_lower>2"
15383 [(set (match_operand:<pmov_dst_3> 0 "register_operand")
15384 (truncate:<pmov_dst_3>
15385 (match_operand:PMOV_SRC_MODE_3_AVX2 1 "register_operand")))]
15386 "TARGET_SSSE3"
15387 {
15388 if (TARGET_AVX512VL
15389 && (<MODE>mode != V8HImode || TARGET_AVX512BW))
15390 {
15391 rtx op0 = gen_reg_rtx (V16QImode);
15392
15393 emit_insn (gen_avx512vl_truncate<mode>v<ssescalarnum>qi2
15394 (op0, operands[1], CONST0_RTX (<pmov_dst_zeroed_3>mode)));
15395
15396 emit_move_insn (operands[0],
15397 lowpart_subreg (<pmov_dst_3>mode, op0, V16QImode));
15398 }
15399 else
15400 {
15401 ix86_expand_trunc_with_avx2_noavx512f (operands[0],
15402 operands[1],
15403 <ssebytemode>mode);
15404 }
15405 DONE;
15406 })
15407
15408 (define_insn "avx512vl_<code><mode>v<ssescalarnum>qi2"
15409 [(set (match_operand:V16QI 0 "register_operand" "=v")
15410 (vec_concat:V16QI
15411 (any_truncate:<pmov_dst_3>
15412 (match_operand:PMOV_SRC_MODE_3 1 "register_operand" "v"))
15413 (match_operand:<pmov_dst_zeroed_3> 2 "const0_operand")))]
15414 "TARGET_AVX512VL"
15415 "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%0, %1}"
15416 [(set_attr "type" "ssemov")
15417 (set_attr "prefix" "evex")
15418 (set_attr "mode" "TI")])
15419
15420 (define_insn_and_split "*avx512f_pshufb_truncv8hiv8qi_1"
15421 [(set (match_operand:DI 0 "register_operand")
15422 (vec_select:DI
15423 (subreg:V2DI
15424 (unspec:V16QI
15425 [(match_operand:V16QI 1 "register_operand")
15426 (match_operand:V16QI 2 "pshufb_truncv8hiv8qi_operand")]
15427 UNSPEC_PSHUFB) 0)
15428 (parallel [(const_int 0)])))]
15429 "TARGET_AVX512VL && TARGET_AVX512BW && ix86_pre_reload_split ()"
15430 "#"
15431 "&& 1"
15432 [(const_int 0)]
15433 {
15434 rtx op1 = gen_reg_rtx (V8QImode);
15435 operands[1] = lowpart_subreg (V8HImode,
15436 force_reg (V16QImode, operands[1]),
15437 V16QImode);
15438 emit_insn (gen_truncv8hiv8qi2 (op1, operands[1]));
15439 emit_move_insn (operands[0], lowpart_subreg (DImode, op1, V8QImode));
15440 DONE;
15441 })
15442
15443 (define_insn "*avx512vl_<code>v2div2qi2_store_1"
15444 [(set (match_operand:V2QI 0 "memory_operand" "=m")
15445 (any_truncate:V2QI
15446 (match_operand:V2DI 1 "register_operand" "v")))]
15447 "TARGET_AVX512VL"
15448 "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
15449 [(set_attr "type" "ssemov")
15450 (set_attr "memory" "store")
15451 (set_attr "prefix" "evex")
15452 (set_attr "mode" "TI")])
15453
15454 (define_insn_and_split "*avx512vl_<code>v2div2qi2_store_2"
15455 [(set (match_operand:HI 0 "memory_operand")
15456 (subreg:HI
15457 (any_truncate:V2QI
15458 (match_operand:V2DI 1 "register_operand")) 0))]
15459 "TARGET_AVX512VL && ix86_pre_reload_split ()"
15460 "#"
15461 "&& 1"
15462 [(set (match_dup 0)
15463 (any_truncate:V2QI (match_dup 1)))]
15464 "operands[0] = adjust_address_nv (operands[0], V2QImode, 0);")
15465
15466 (define_insn "avx512vl_<code>v2div2qi2_mask"
15467 [(set (match_operand:V16QI 0 "register_operand" "=v")
15468 (vec_concat:V16QI
15469 (vec_merge:V2QI
15470 (any_truncate:V2QI
15471 (match_operand:V2DI 1 "register_operand" "v"))
15472 (vec_select:V2QI
15473 (match_operand:V16QI 2 "nonimm_or_0_operand" "0C")
15474 (parallel [(const_int 0) (const_int 1)]))
15475 (match_operand:QI 3 "register_operand" "Yk"))
15476 (const_vector:V14QI [(const_int 0) (const_int 0)
15477 (const_int 0) (const_int 0)
15478 (const_int 0) (const_int 0)
15479 (const_int 0) (const_int 0)
15480 (const_int 0) (const_int 0)
15481 (const_int 0) (const_int 0)
15482 (const_int 0) (const_int 0)])))]
15483 "TARGET_AVX512VL"
15484 "vpmov<trunsuffix>qb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15485 [(set_attr "type" "ssemov")
15486 (set_attr "prefix" "evex")
15487 (set_attr "mode" "TI")])
15488
15489 (define_insn "*avx512vl_<code>v2div2qi2_mask_1"
15490 [(set (match_operand:V16QI 0 "register_operand" "=v")
15491 (vec_concat:V16QI
15492 (vec_merge:V2QI
15493 (any_truncate:V2QI
15494 (match_operand:V2DI 1 "register_operand" "v"))
15495 (const_vector:V2QI [(const_int 0) (const_int 0)])
15496 (match_operand:QI 2 "register_operand" "Yk"))
15497 (const_vector:V14QI [(const_int 0) (const_int 0)
15498 (const_int 0) (const_int 0)
15499 (const_int 0) (const_int 0)
15500 (const_int 0) (const_int 0)
15501 (const_int 0) (const_int 0)
15502 (const_int 0) (const_int 0)
15503 (const_int 0) (const_int 0)])))]
15504 "TARGET_AVX512VL"
15505 "vpmov<trunsuffix>qb\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
15506 [(set_attr "type" "ssemov")
15507 (set_attr "prefix" "evex")
15508 (set_attr "mode" "TI")])
15509
15510 (define_insn "avx512vl_<code>v2div2qi2_mask_store_1"
15511 [(set (match_operand:V2QI 0 "memory_operand" "=m")
15512 (vec_merge:V2QI
15513 (any_truncate:V2QI
15514 (match_operand:V2DI 1 "register_operand" "v"))
15515 (match_dup 0)
15516 (match_operand:QI 2 "register_operand" "Yk")))]
15517 "TARGET_AVX512VL"
15518 "vpmov<trunsuffix>qb\t{%1, %0%{%2%}|%0%{%2%}, %1}"
15519 [(set_attr "type" "ssemov")
15520 (set_attr "memory" "store")
15521 (set_attr "prefix" "evex")
15522 (set_attr "mode" "TI")])
15523
15524 (define_expand "avx512vl_<code>v2div2qi2_mask_store_2"
15525 [(match_operand:HI 0 "memory_operand")
15526 (any_truncate:V2QI
15527 (match_operand:V2DI 1 "register_operand"))
15528 (match_operand:QI 2 "register_operand")]
15529 "TARGET_AVX512VL"
15530 {
15531 operands[0] = adjust_address_nv (operands[0], V2QImode, 0);
15532 emit_insn (gen_avx512vl_<code>v2div2qi2_mask_store_1 (operands[0],
15533 operands[1],
15534 operands[2]));
15535 DONE;
15536 })
15537
15538 (define_insn "*avx512vl_<code><mode>v4qi2_store_1"
15539 [(set (match_operand:V4QI 0 "memory_operand" "=m")
15540 (any_truncate:V4QI
15541 (match_operand:VI4_128_8_256 1 "register_operand" "v")))]
15542 "TARGET_AVX512VL"
15543 "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%0, %1}"
15544 [(set_attr "type" "ssemov")
15545 (set_attr "memory" "store")
15546 (set_attr "prefix" "evex")
15547 (set_attr "mode" "TI")])
15548
15549 (define_insn_and_split "*avx512vl_<code><mode>v4qi2_store_2"
15550 [(set (match_operand:SI 0 "memory_operand")
15551 (subreg:SI
15552 (any_truncate:V4QI
15553 (match_operand:VI4_128_8_256 1 "register_operand")) 0))]
15554 "TARGET_AVX512VL && ix86_pre_reload_split ()"
15555 "#"
15556 "&& 1"
15557 [(set (match_dup 0)
15558 (any_truncate:V4QI (match_dup 1)))]
15559 "operands[0] = adjust_address_nv (operands[0], V4QImode, 0);")
15560
15561 (define_insn "avx512vl_<code><mode>v4qi2_mask"
15562 [(set (match_operand:V16QI 0 "register_operand" "=v")
15563 (vec_concat:V16QI
15564 (vec_merge:V4QI
15565 (any_truncate:V4QI
15566 (match_operand:VI4_128_8_256 1 "register_operand" "v"))
15567 (vec_select:V4QI
15568 (match_operand:V16QI 2 "nonimm_or_0_operand" "0C")
15569 (parallel [(const_int 0) (const_int 1)
15570 (const_int 2) (const_int 3)]))
15571 (match_operand:QI 3 "register_operand" "Yk"))
15572 (const_vector:V12QI [(const_int 0) (const_int 0)
15573 (const_int 0) (const_int 0)
15574 (const_int 0) (const_int 0)
15575 (const_int 0) (const_int 0)
15576 (const_int 0) (const_int 0)
15577 (const_int 0) (const_int 0)])))]
15578 "TARGET_AVX512VL"
15579 "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15580 [(set_attr "type" "ssemov")
15581 (set_attr "prefix" "evex")
15582 (set_attr "mode" "TI")])
15583
15584 (define_insn "*avx512vl_<code><mode>v4qi2_mask_1"
15585 [(set (match_operand:V16QI 0 "register_operand" "=v")
15586 (vec_concat:V16QI
15587 (vec_merge:V4QI
15588 (any_truncate:V4QI
15589 (match_operand:VI4_128_8_256 1 "register_operand" "v"))
15590 (const_vector:V4QI [(const_int 0) (const_int 0)
15591 (const_int 0) (const_int 0)])
15592 (match_operand:QI 2 "register_operand" "Yk"))
15593 (const_vector:V12QI [(const_int 0) (const_int 0)
15594 (const_int 0) (const_int 0)
15595 (const_int 0) (const_int 0)
15596 (const_int 0) (const_int 0)
15597 (const_int 0) (const_int 0)
15598 (const_int 0) (const_int 0)])))]
15599 "TARGET_AVX512VL"
15600 "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
15601 [(set_attr "type" "ssemov")
15602 (set_attr "prefix" "evex")
15603 (set_attr "mode" "TI")])
15604
15605 (define_insn "avx512vl_<code><mode>v4qi2_mask_store_1"
15606 [(set (match_operand:V4QI 0 "memory_operand" "=m")
15607 (vec_merge:V4QI
15608 (any_truncate:V4QI
15609 (match_operand:VI4_128_8_256 1 "register_operand" "v"))
15610 (match_dup 0)
15611 (match_operand:QI 2 "register_operand" "Yk")))]
15612 "TARGET_AVX512VL"
15613 "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
15614 [(set_attr "type" "ssemov")
15615 (set_attr "memory" "store")
15616 (set_attr "prefix" "evex")
15617 (set_attr "mode" "TI")])
15618
15619 (define_expand "avx512vl_<code><mode>v4qi2_mask_store_2"
15620 [(match_operand:SI 0 "memory_operand")
15621 (any_truncate:V4QI
15622 (match_operand:VI4_128_8_256 1 "register_operand"))
15623 (match_operand:QI 2 "register_operand")]
15624 "TARGET_AVX512VL"
15625 {
15626 operands[0] = adjust_address_nv (operands[0], V4QImode, 0);
15627 emit_insn (gen_avx512vl_<code><mode>v4qi2_mask_store_1 (operands[0],
15628 operands[1],
15629 operands[2]));
15630 DONE;
15631 })
15632
15633 (define_mode_iterator VI2_128_BW_4_256
15634 [(V8HI "TARGET_AVX512BW") V8SI])
15635
15636 (define_insn "*avx512vl_<code><mode>v8qi2_store_1"
15637 [(set (match_operand:V8QI 0 "memory_operand" "=m")
15638 (any_truncate:V8QI
15639 (match_operand:VI2_128_BW_4_256 1 "register_operand" "v")))]
15640 "TARGET_AVX512VL"
15641 "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%0, %1}"
15642 [(set_attr "type" "ssemov")
15643 (set_attr "memory" "store")
15644 (set_attr "prefix" "evex")
15645 (set_attr "mode" "TI")])
15646
15647 (define_insn_and_split "*avx512vl_<code><mode>v8qi2_store_2"
15648 [(set (match_operand:DI 0 "memory_operand" "=m")
15649 (subreg:DI
15650 (any_truncate:V8QI
15651 (match_operand:VI2_128_BW_4_256 1 "register_operand" "v")) 0))]
15652 "TARGET_AVX512VL && ix86_pre_reload_split ()"
15653 "#"
15654 "&& 1"
15655 [(set (match_dup 0)
15656 (any_truncate:V8QI (match_dup 1)))]
15657 "operands[0] = adjust_address_nv (operands[0], V8QImode, 0);")
15658
15659 (define_insn "avx512vl_<code><mode>v8qi2_mask"
15660 [(set (match_operand:V16QI 0 "register_operand" "=v")
15661 (vec_concat:V16QI
15662 (vec_merge:V8QI
15663 (any_truncate:V8QI
15664 (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
15665 (vec_select:V8QI
15666 (match_operand:V16QI 2 "nonimm_or_0_operand" "0C")
15667 (parallel [(const_int 0) (const_int 1)
15668 (const_int 2) (const_int 3)
15669 (const_int 4) (const_int 5)
15670 (const_int 6) (const_int 7)]))
15671 (match_operand:QI 3 "register_operand" "Yk"))
15672 (const_vector:V8QI [(const_int 0) (const_int 0)
15673 (const_int 0) (const_int 0)
15674 (const_int 0) (const_int 0)
15675 (const_int 0) (const_int 0)])))]
15676 "TARGET_AVX512VL"
15677 "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15678 [(set_attr "type" "ssemov")
15679 (set_attr "prefix" "evex")
15680 (set_attr "mode" "TI")])
15681
15682 (define_insn "*avx512vl_<code><mode>v8qi2_mask_1"
15683 [(set (match_operand:V16QI 0 "register_operand" "=v")
15684 (vec_concat:V16QI
15685 (vec_merge:V8QI
15686 (any_truncate:V8QI
15687 (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
15688 (const_vector:V8QI [(const_int 0) (const_int 0)
15689 (const_int 0) (const_int 0)
15690 (const_int 0) (const_int 0)
15691 (const_int 0) (const_int 0)])
15692 (match_operand:QI 2 "register_operand" "Yk"))
15693 (const_vector:V8QI [(const_int 0) (const_int 0)
15694 (const_int 0) (const_int 0)
15695 (const_int 0) (const_int 0)
15696 (const_int 0) (const_int 0)])))]
15697 "TARGET_AVX512VL"
15698 "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
15699 [(set_attr "type" "ssemov")
15700 (set_attr "prefix" "evex")
15701 (set_attr "mode" "TI")])
15702
15703 (define_insn "avx512vl_<code><mode>v8qi2_mask_store_1"
15704 [(set (match_operand:V8QI 0 "memory_operand" "=m")
15705 (vec_merge:V8QI
15706 (any_truncate:V8QI
15707 (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
15708 (match_dup 0)
15709 (match_operand:QI 2 "register_operand" "Yk")))]
15710 "TARGET_AVX512VL"
15711 "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
15712 [(set_attr "type" "ssemov")
15713 (set_attr "memory" "store")
15714 (set_attr "prefix" "evex")
15715 (set_attr "mode" "TI")])
15716
15717 (define_expand "avx512vl_<code><mode>v8qi2_mask_store_2"
15718 [(match_operand:DI 0 "memory_operand")
15719 (any_truncate:V8QI
15720 (match_operand:VI2_128_BW_4_256 1 "register_operand"))
15721 (match_operand:QI 2 "register_operand")]
15722 "TARGET_AVX512VL"
15723 {
15724 operands[0] = adjust_address_nv (operands[0], V8QImode, 0);
15725 emit_insn (gen_avx512vl_<code><mode>v8qi2_mask_store_1 (operands[0],
15726 operands[1],
15727 operands[2]));
15728 DONE;
15729 })
15730
15731 (define_mode_iterator PMOV_SRC_MODE_4 [(V4DI "TARGET_AVX2") V2DI V4SI])
15732 (define_mode_attr pmov_dst_4
15733 [(V4DI "V4HI") (V2DI "V2HI") (V4SI "V4HI")])
15734 (define_mode_attr pmov_dst_4_lower
15735 [(V4DI "v4hi") (V2DI "v2hi") (V4SI "v4hi")])
15736 (define_mode_attr pmov_dst_zeroed_4
15737 [(V4DI "V4HI") (V2DI "V6HI") (V4SI "V4HI")])
15738 (define_mode_attr pmov_suff_4
15739 [(V4DI "qw") (V2DI "qw") (V4SI "dw")])
15740
15741 (define_expand "trunc<mode><pmov_dst_4_lower>2"
15742 [(set (match_operand:<pmov_dst_4> 0 "register_operand")
15743 (truncate:<pmov_dst_4>
15744 (match_operand:PMOV_SRC_MODE_4 1 "register_operand")))]
15745 "TARGET_SSSE3"
15746 {
15747 if (TARGET_AVX512VL)
15748 {
15749 rtx op0 = gen_reg_rtx (V8HImode);
15750
15751 emit_insn (gen_avx512vl_truncate<mode>v<ssescalarnum>hi2
15752 (op0, operands[1], CONST0_RTX (<pmov_dst_zeroed_4>mode)));
15753
15754 emit_move_insn (operands[0],
15755 lowpart_subreg (<pmov_dst_4>mode, op0, V8HImode));
15756 DONE;
15757 }
15758 else
15759 ix86_expand_trunc_with_avx2_noavx512f (operands[0], operands[1], <ssewvecmode>mode);
15760 DONE;
15761 })
15762
15763 (define_insn "avx512vl_<code><mode>v<ssescalarnum>hi2"
15764 [(set (match_operand:V8HI 0 "register_operand" "=v")
15765 (vec_concat:V8HI
15766 (any_truncate:<pmov_dst_4>
15767 (match_operand:PMOV_SRC_MODE_4 1 "register_operand" "v"))
15768 (match_operand:<pmov_dst_zeroed_4> 2 "const0_operand")))]
15769 "TARGET_AVX512VL"
15770 "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0|%0, %1}"
15771 [(set_attr "type" "ssemov")
15772 (set_attr "prefix" "evex")
15773 (set_attr "mode" "TI")])
15774
15775 (define_insn_and_split "*avx512f_pshufb_truncv4siv4hi_1"
15776 [(set (match_operand:DI 0 "register_operand")
15777 (vec_select:DI
15778 (subreg:V2DI
15779 (unspec:V16QI
15780 [(match_operand:V16QI 1 "register_operand")
15781 (match_operand:V16QI 2 "pshufb_truncv4siv4hi_operand")]
15782 UNSPEC_PSHUFB) 0)
15783 (parallel [(const_int 0)])))]
15784 "TARGET_AVX512VL && ix86_pre_reload_split ()"
15785 "#"
15786 "&& 1"
15787 [(const_int 0)]
15788 {
15789 rtx op1 = gen_reg_rtx (V4HImode);
15790 operands[1] = lowpart_subreg (V4SImode,
15791 force_reg (V16QImode, operands[1]),
15792 V16QImode);
15793 emit_insn (gen_truncv4siv4hi2 (op1, operands[1]));
15794 emit_move_insn (operands[0], lowpart_subreg (DImode, op1, V4HImode));
15795 DONE;
15796 })
15797
15798 (define_insn "*avx512vl_<code><mode>v4hi2_store_1"
15799 [(set (match_operand:V4HI 0 "memory_operand" "=m")
15800 (any_truncate:V4HI
15801 (match_operand:VI4_128_8_256 1 "register_operand" "v")))]
15802 "TARGET_AVX512VL"
15803 "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0|%0, %1}"
15804 [(set_attr "type" "ssemov")
15805 (set_attr "memory" "store")
15806 (set_attr "prefix" "evex")
15807 (set_attr "mode" "TI")])
15808
15809 (define_insn_and_split "*avx512vl_<code><mode>v4hi2_store_2"
15810 [(set (match_operand:DI 0 "memory_operand")
15811 (subreg:DI
15812 (any_truncate:V4HI
15813 (match_operand:VI4_128_8_256 1 "register_operand")) 0))]
15814 "TARGET_AVX512VL && ix86_pre_reload_split ()"
15815 "#"
15816 "&& 1"
15817 [(set (match_dup 0)
15818 (any_truncate:V4HI (match_dup 1)))]
15819 "operands[0] = adjust_address_nv (operands[0], V4HImode, 0);")
15820
15821 (define_insn "avx512vl_<code><mode>v4hi2_mask"
15822 [(set (match_operand:V8HI 0 "register_operand" "=v")
15823 (vec_concat:V8HI
15824 (vec_merge:V4HI
15825 (any_truncate:V4HI
15826 (match_operand:VI4_128_8_256 1 "register_operand" "v"))
15827 (vec_select:V4HI
15828 (match_operand:V8HI 2 "nonimm_or_0_operand" "0C")
15829 (parallel [(const_int 0) (const_int 1)
15830 (const_int 2) (const_int 3)]))
15831 (match_operand:QI 3 "register_operand" "Yk"))
15832 (const_vector:V4HI [(const_int 0) (const_int 0)
15833 (const_int 0) (const_int 0)])))]
15834 "TARGET_AVX512VL"
15835 "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15836 [(set_attr "type" "ssemov")
15837 (set_attr "prefix" "evex")
15838 (set_attr "mode" "TI")])
15839
15840 (define_insn "*avx512vl_<code><mode>v4hi2_mask_1"
15841 [(set (match_operand:V8HI 0 "register_operand" "=v")
15842 (vec_concat:V8HI
15843 (vec_merge:V4HI
15844 (any_truncate:V4HI
15845 (match_operand:VI4_128_8_256 1 "register_operand" "v"))
15846 (const_vector:V4HI [(const_int 0) (const_int 0)
15847 (const_int 0) (const_int 0)])
15848 (match_operand:QI 2 "register_operand" "Yk"))
15849 (const_vector:V4HI [(const_int 0) (const_int 0)
15850 (const_int 0) (const_int 0)])))]
15851 "TARGET_AVX512VL"
15852 "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
15853 [(set_attr "type" "ssemov")
15854 (set_attr "prefix" "evex")
15855 (set_attr "mode" "TI")])
15856
15857 (define_insn "avx512vl_<code><mode>v4hi2_mask_store_1"
15858 [(set (match_operand:V4HI 0 "memory_operand" "=m")
15859 (vec_merge:V4HI
15860 (any_truncate:V4HI
15861 (match_operand:VI4_128_8_256 1 "register_operand" "v"))
15862 (match_dup 0)
15863 (match_operand:QI 2 "register_operand" "Yk")))]
15864 "TARGET_AVX512VL"
15865 {
15866 if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 4)
15867 return "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
15868 return "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
15869 }
15870 [(set_attr "type" "ssemov")
15871 (set_attr "memory" "store")
15872 (set_attr "prefix" "evex")
15873 (set_attr "mode" "TI")])
15874
15875 (define_expand "avx512vl_<code><mode>v4hi2_mask_store_2"
15876 [(match_operand:DI 0 "memory_operand")
15877 (any_truncate:V4HI
15878 (match_operand:VI4_128_8_256 1 "register_operand"))
15879 (match_operand:QI 2 "register_operand")]
15880 "TARGET_AVX512VL"
15881 {
15882 operands[0] = adjust_address_nv (operands[0], V4HImode, 0);
15883 emit_insn (gen_avx512vl_<code><mode>v4hi2_mask_store_1 (operands[0],
15884 operands[1],
15885 operands[2]));
15886 DONE;
15887 })
15888
15889 (define_insn "*avx512vl_<code>v2div2hi2_store_1"
15890 [(set (match_operand:V2HI 0 "memory_operand" "=m")
15891 (any_truncate:V2HI
15892 (match_operand:V2DI 1 "register_operand" "v")))]
15893 "TARGET_AVX512VL"
15894 "vpmov<trunsuffix>qw\t{%1, %0|%0, %1}"
15895 [(set_attr "type" "ssemov")
15896 (set_attr "memory" "store")
15897 (set_attr "prefix" "evex")
15898 (set_attr "mode" "TI")])
15899
15900 (define_insn_and_split "*avx512vl_<code>v2div2hi2_store_2"
15901 [(set (match_operand:SI 0 "memory_operand")
15902 (subreg:SI
15903 (any_truncate:V2HI
15904 (match_operand:V2DI 1 "register_operand")) 0))]
15905 "TARGET_AVX512VL && ix86_pre_reload_split ()"
15906 "#"
15907 "&& 1"
15908 [(set (match_dup 0)
15909 (any_truncate:V2HI (match_dup 1)))]
15910 "operands[0] = adjust_address_nv (operands[0], V2HImode, 0);")
15911
15912 (define_insn "avx512vl_<code>v2div2hi2_mask"
15913 [(set (match_operand:V8HI 0 "register_operand" "=v")
15914 (vec_concat:V8HI
15915 (vec_merge:V2HI
15916 (any_truncate:V2HI
15917 (match_operand:V2DI 1 "register_operand" "v"))
15918 (vec_select:V2HI
15919 (match_operand:V8HI 2 "nonimm_or_0_operand" "0C")
15920 (parallel [(const_int 0) (const_int 1)]))
15921 (match_operand:QI 3 "register_operand" "Yk"))
15922 (const_vector:V6HI [(const_int 0) (const_int 0)
15923 (const_int 0) (const_int 0)
15924 (const_int 0) (const_int 0)])))]
15925 "TARGET_AVX512VL"
15926 "vpmov<trunsuffix>qw\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15927 [(set_attr "type" "ssemov")
15928 (set_attr "prefix" "evex")
15929 (set_attr "mode" "TI")])
15930
15931 (define_insn "*avx512vl_<code>v2div2hi2_mask_1"
15932 [(set (match_operand:V8HI 0 "register_operand" "=v")
15933 (vec_concat:V8HI
15934 (vec_merge:V2HI
15935 (any_truncate:V2HI
15936 (match_operand:V2DI 1 "register_operand" "v"))
15937 (const_vector:V2HI [(const_int 0) (const_int 0)])
15938 (match_operand:QI 2 "register_operand" "Yk"))
15939 (const_vector:V6HI [(const_int 0) (const_int 0)
15940 (const_int 0) (const_int 0)
15941 (const_int 0) (const_int 0)])))]
15942 "TARGET_AVX512VL"
15943 "vpmov<trunsuffix>qw\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
15944 [(set_attr "type" "ssemov")
15945 (set_attr "prefix" "evex")
15946 (set_attr "mode" "TI")])
15947
15948 (define_insn "avx512vl_<code>v2div2hi2_mask_store_1"
15949 [(set (match_operand:V2HI 0 "memory_operand" "=m")
15950 (vec_merge:V2HI
15951 (any_truncate:V2HI
15952 (match_operand:V2DI 1 "register_operand" "v"))
15953 (match_dup 0)
15954 (match_operand:QI 2 "register_operand" "Yk")))]
15955 "TARGET_AVX512VL"
15956 "vpmov<trunsuffix>qw\t{%1, %0%{%2%}|%0%{%2%}, %1}"
15957 [(set_attr "type" "ssemov")
15958 (set_attr "memory" "store")
15959 (set_attr "prefix" "evex")
15960 (set_attr "mode" "TI")])
15961
15962 (define_expand "avx512vl_<code>v2div2hi2_mask_store_2"
15963 [(match_operand:SI 0 "memory_operand")
15964 (any_truncate:V2HI
15965 (match_operand:V2DI 1 "register_operand"))
15966 (match_operand:QI 2 "register_operand")]
15967 "TARGET_AVX512VL"
15968 {
15969 operands[0] = adjust_address_nv (operands[0], V2HImode, 0);
15970 emit_insn (gen_avx512vl_<code>v2div2hi2_mask_store_1 (operands[0],
15971 operands[1],
15972 operands[2]));
15973 DONE;
15974 })
15975
15976 (define_expand "truncv2div2si2"
15977 [(set (match_operand:V2SI 0 "register_operand")
15978 (truncate:V2SI
15979 (match_operand:V2DI 1 "register_operand")))]
15980 "TARGET_SSE"
15981 {
15982 if (TARGET_AVX512VL)
15983 {
15984 rtx op0 = gen_reg_rtx (V4SImode);
15985
15986 emit_insn (gen_avx512vl_truncatev2div2si2
15987 (op0, operands[1], CONST0_RTX (V2SImode)));
15988
15989 emit_move_insn (operands[0],
15990 lowpart_subreg (V2SImode, op0, V4SImode));
15991 }
15992 else
15993 {
15994 rtx tmp = lowpart_subreg (V4SImode,
15995 force_reg (V2DImode, operands[1]), V2DImode);
15996 rtx op0 = gen_reg_rtx (V4SImode);
15997 emit_insn (gen_sse_shufps_v4si (op0, tmp, tmp, const0_rtx, GEN_INT (2),
15998 GEN_INT (6), GEN_INT (7)));
15999 emit_move_insn (operands[0], lowpart_subreg (V2SImode, op0, V4SImode));
16000 }
16001 DONE;
16002 })
16003
16004 (define_insn "avx512vl_<code>v2div2si2"
16005 [(set (match_operand:V4SI 0 "register_operand" "=v")
16006 (vec_concat:V4SI
16007 (any_truncate:V2SI
16008 (match_operand:V2DI 1 "register_operand" "v"))
16009 (match_operand:V2SI 2 "const0_operand")))]
16010 "TARGET_AVX512VL"
16011 "vpmov<trunsuffix>qd\t{%1, %0|%0, %1}"
16012 [(set_attr "type" "ssemov")
16013 (set_attr "prefix" "evex")
16014 (set_attr "mode" "TI")])
16015
16016 (define_insn_and_split "*avx512f_pshufd_truncv2div2si_1"
16017 [(set (match_operand:DI 0 "register_operand")
16018 (vec_select:DI
16019 (subreg:V2DI
16020 (vec_select:V4SI
16021 (match_operand:V4SI 1 "register_operand")
16022 (parallel [(const_int 0) (const_int 2)
16023 (const_int 2) (const_int 3)])) 0)
16024 (parallel [(const_int 0)])))]
16025 "TARGET_AVX512VL && ix86_pre_reload_split ()"
16026 "#"
16027 "&& 1"
16028 [(const_int 0)]
16029 {
16030 rtx op1 = gen_reg_rtx (V2SImode);
16031 operands[1] = lowpart_subreg (V2DImode,
16032 force_reg (V4SImode, operands[1]),
16033 V4SImode);
16034 emit_insn (gen_truncv2div2si2 (op1, operands[1]));
16035 emit_move_insn (operands[0], lowpart_subreg (DImode, op1, V2SImode));
16036 DONE;
16037 })
16038
16039 (define_insn "*avx512vl_<code>v2div2si2_store_1"
16040 [(set (match_operand:V2SI 0 "memory_operand" "=m")
16041 (any_truncate:V2SI
16042 (match_operand:V2DI 1 "register_operand" "v")))]
16043 "TARGET_AVX512VL"
16044 "vpmov<trunsuffix>qd\t{%1, %0|%0, %1}"
16045 [(set_attr "type" "ssemov")
16046 (set_attr "memory" "store")
16047 (set_attr "prefix" "evex")
16048 (set_attr "mode" "TI")])
16049
16050 (define_insn_and_split "*avx512vl_<code>v2div2si2_store_2"
16051 [(set (match_operand:DI 0 "memory_operand")
16052 (subreg:DI
16053 (any_truncate:V2SI
16054 (match_operand:V2DI 1 "register_operand")) 0))]
16055 "TARGET_AVX512VL && ix86_pre_reload_split ()"
16056 "#"
16057 "&& 1"
16058 [(set (match_dup 0)
16059 (any_truncate:V2SI (match_dup 1)))]
16060 "operands[0] = adjust_address_nv (operands[0], V2SImode, 0);")
16061
16062 (define_insn "avx512vl_<code>v2div2si2_mask"
16063 [(set (match_operand:V4SI 0 "register_operand" "=v")
16064 (vec_concat:V4SI
16065 (vec_merge:V2SI
16066 (any_truncate:V2SI
16067 (match_operand:V2DI 1 "register_operand" "v"))
16068 (vec_select:V2SI
16069 (match_operand:V4SI 2 "nonimm_or_0_operand" "0C")
16070 (parallel [(const_int 0) (const_int 1)]))
16071 (match_operand:QI 3 "register_operand" "Yk"))
16072 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
16073 "TARGET_AVX512VL"
16074 "vpmov<trunsuffix>qd\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
16075 [(set_attr "type" "ssemov")
16076 (set_attr "prefix" "evex")
16077 (set_attr "mode" "TI")])
16078
16079 (define_insn "*avx512vl_<code>v2div2si2_mask_1"
16080 [(set (match_operand:V4SI 0 "register_operand" "=v")
16081 (vec_concat:V4SI
16082 (vec_merge:V2SI
16083 (any_truncate:V2SI
16084 (match_operand:V2DI 1 "register_operand" "v"))
16085 (const_vector:V2SI [(const_int 0) (const_int 0)])
16086 (match_operand:QI 2 "register_operand" "Yk"))
16087 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
16088 "TARGET_AVX512VL"
16089 "vpmov<trunsuffix>qd\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
16090 [(set_attr "type" "ssemov")
16091 (set_attr "prefix" "evex")
16092 (set_attr "mode" "TI")])
16093
16094 (define_insn "avx512vl_<code>v2div2si2_mask_store_1"
16095 [(set (match_operand:V2SI 0 "memory_operand" "=m")
16096 (vec_merge:V2SI
16097 (any_truncate:V2SI
16098 (match_operand:V2DI 1 "register_operand" "v"))
16099 (match_dup 0)
16100 (match_operand:QI 2 "register_operand" "Yk")))]
16101 "TARGET_AVX512VL"
16102 "vpmov<trunsuffix>qd\t{%1, %0%{%2%}|%0%{%2%}, %1}"
16103 [(set_attr "type" "ssemov")
16104 (set_attr "memory" "store")
16105 (set_attr "prefix" "evex")
16106 (set_attr "mode" "TI")])
16107
16108 (define_expand "avx512vl_<code>v2div2si2_mask_store_2"
16109 [(match_operand:DI 0 "memory_operand")
16110 (any_truncate:V2SI
16111 (match_operand:V2DI 1 "register_operand"))
16112 (match_operand:QI 2 "register_operand")]
16113 "TARGET_AVX512VL"
16114 {
16115 operands[0] = adjust_address_nv (operands[0], V2SImode, 0);
16116 emit_insn (gen_avx512vl_<code>v2div2si2_mask_store_1 (operands[0],
16117 operands[1],
16118 operands[2]));
16119 DONE;
16120 })
16121
16122 (define_expand "truncv8div8qi2"
16123 [(set (match_operand:V8QI 0 "register_operand")
16124 (truncate:V8QI
16125 (match_operand:V8DI 1 "register_operand")))]
16126 "TARGET_AVX512F && TARGET_EVEX512"
16127 {
16128 rtx op0 = gen_reg_rtx (V16QImode);
16129
16130 emit_insn (gen_avx512f_truncatev8div16qi2 (op0, operands[1]));
16131
16132 emit_move_insn (operands[0],
16133 lowpart_subreg (V8QImode, op0, V16QImode));
16134 DONE;
16135 })
16136
16137 (define_insn "avx512f_<code>v8div16qi2"
16138 [(set (match_operand:V16QI 0 "register_operand" "=v")
16139 (vec_concat:V16QI
16140 (any_truncate:V8QI
16141 (match_operand:V8DI 1 "register_operand" "v"))
16142 (const_vector:V8QI [(const_int 0) (const_int 0)
16143 (const_int 0) (const_int 0)
16144 (const_int 0) (const_int 0)
16145 (const_int 0) (const_int 0)])))]
16146 "TARGET_AVX512F && TARGET_EVEX512"
16147 "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
16148 [(set_attr "type" "ssemov")
16149 (set_attr "prefix" "evex")
16150 (set_attr "mode" "TI")])
16151
16152 (define_insn "*avx512f_<code>v8div16qi2_store_1"
16153 [(set (match_operand:V8QI 0 "memory_operand" "=m")
16154 (any_truncate:V8QI
16155 (match_operand:V8DI 1 "register_operand" "v")))]
16156 "TARGET_AVX512F && TARGET_EVEX512"
16157 "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
16158 [(set_attr "type" "ssemov")
16159 (set_attr "memory" "store")
16160 (set_attr "prefix" "evex")
16161 (set_attr "mode" "TI")])
16162
16163 (define_insn_and_split "*avx512f_<code>v8div16qi2_store_2"
16164 [(set (match_operand:DI 0 "memory_operand")
16165 (subreg:DI
16166 (any_truncate:V8QI
16167 (match_operand:V8DI 1 "register_operand")) 0))]
16168 "TARGET_AVX512F && TARGET_EVEX512 && ix86_pre_reload_split ()"
16169 "#"
16170 "&& 1"
16171 [(set (match_dup 0)
16172 (any_truncate:V8QI (match_dup 1)))]
16173 "operands[0] = adjust_address_nv (operands[0], V8QImode, 0);")
16174
16175 (define_insn "avx512f_<code>v8div16qi2_mask"
16176 [(set (match_operand:V16QI 0 "register_operand" "=v")
16177 (vec_concat:V16QI
16178 (vec_merge:V8QI
16179 (any_truncate:V8QI
16180 (match_operand:V8DI 1 "register_operand" "v"))
16181 (vec_select:V8QI
16182 (match_operand:V16QI 2 "nonimm_or_0_operand" "0C")
16183 (parallel [(const_int 0) (const_int 1)
16184 (const_int 2) (const_int 3)
16185 (const_int 4) (const_int 5)
16186 (const_int 6) (const_int 7)]))
16187 (match_operand:QI 3 "register_operand" "Yk"))
16188 (const_vector:V8QI [(const_int 0) (const_int 0)
16189 (const_int 0) (const_int 0)
16190 (const_int 0) (const_int 0)
16191 (const_int 0) (const_int 0)])))]
16192 "TARGET_AVX512F && TARGET_EVEX512"
16193 "vpmov<trunsuffix>qb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
16194 [(set_attr "type" "ssemov")
16195 (set_attr "prefix" "evex")
16196 (set_attr "mode" "TI")])
16197
16198 (define_insn "*avx512f_<code>v8div16qi2_mask_1"
16199 [(set (match_operand:V16QI 0 "register_operand" "=v")
16200 (vec_concat:V16QI
16201 (vec_merge:V8QI
16202 (any_truncate:V8QI
16203 (match_operand:V8DI 1 "register_operand" "v"))
16204 (const_vector:V8QI [(const_int 0) (const_int 0)
16205 (const_int 0) (const_int 0)
16206 (const_int 0) (const_int 0)
16207 (const_int 0) (const_int 0)])
16208 (match_operand:QI 2 "register_operand" "Yk"))
16209 (const_vector:V8QI [(const_int 0) (const_int 0)
16210 (const_int 0) (const_int 0)
16211 (const_int 0) (const_int 0)
16212 (const_int 0) (const_int 0)])))]
16213 "TARGET_AVX512F && TARGET_EVEX512"
16214 "vpmov<trunsuffix>qb\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
16215 [(set_attr "type" "ssemov")
16216 (set_attr "prefix" "evex")
16217 (set_attr "mode" "TI")])
16218
16219 (define_insn "avx512f_<code>v8div16qi2_mask_store_1"
16220 [(set (match_operand:V8QI 0 "memory_operand" "=m")
16221 (vec_merge:V8QI
16222 (any_truncate:V8QI
16223 (match_operand:V8DI 1 "register_operand" "v"))
16224 (match_dup 0)
16225 (match_operand:QI 2 "register_operand" "Yk")))]
16226 "TARGET_AVX512F && TARGET_EVEX512"
16227 "vpmov<trunsuffix>qb\t{%1, %0%{%2%}|%0%{%2%}, %1}"
16228 [(set_attr "type" "ssemov")
16229 (set_attr "memory" "store")
16230 (set_attr "prefix" "evex")
16231 (set_attr "mode" "TI")])
16232
16233 (define_expand "avx512f_<code>v8div16qi2_mask_store_2"
16234 [(match_operand:DI 0 "memory_operand")
16235 (any_truncate:V8QI
16236 (match_operand:V8DI 1 "register_operand"))
16237 (match_operand:QI 2 "register_operand")]
16238 "TARGET_AVX512F && TARGET_EVEX512"
16239 {
16240 operands[0] = adjust_address_nv (operands[0], V8QImode, 0);
16241 emit_insn (gen_avx512f_<code>v8div16qi2_mask_store_1 (operands[0],
16242 operands[1],
16243 operands[2]));
16244 DONE;
16245 })
16246
16247 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16248 ;;
16249 ;; Parallel integral arithmetic
16250 ;;
16251 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16252
16253 (define_expand "neg<mode>2"
16254 [(set (match_operand:VI_AVX2 0 "register_operand")
16255 (minus:VI_AVX2
16256 (match_dup 2)
16257 (match_operand:VI_AVX2 1 "vector_operand")))]
16258 "TARGET_SSE2"
16259 "operands[2] = force_reg (<MODE>mode, CONST0_RTX (<MODE>mode));")
16260
16261 (define_expand "<insn><mode>3"
16262 [(set (match_operand:VI_AVX2 0 "register_operand")
16263 (plusminus:VI_AVX2
16264 (match_operand:VI_AVX2 1 "vector_operand")
16265 (match_operand:VI_AVX2 2 "vector_operand")))]
16266 "TARGET_SSE2"
16267 "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
16268
16269 (define_expand "cond_<insn><mode>"
16270 [(set (match_operand:VI1248_AVX512VLBW 0 "register_operand")
16271 (vec_merge:VI1248_AVX512VLBW
16272 (plusminus:VI1248_AVX512VLBW
16273 (match_operand:VI1248_AVX512VLBW 2 "nonimmediate_operand")
16274 (match_operand:VI1248_AVX512VLBW 3 "nonimmediate_operand"))
16275 (match_operand:VI1248_AVX512VLBW 4 "nonimm_or_0_operand")
16276 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
16277 "TARGET_AVX512F"
16278 {
16279 emit_insn (gen_<insn><mode>3_mask (operands[0],
16280 operands[2],
16281 operands[3],
16282 operands[4],
16283 operands[1]));
16284 DONE;
16285 })
16286
16287 (define_expand "<insn><mode>3_mask"
16288 [(set (match_operand:VI48_AVX512VL 0 "register_operand")
16289 (vec_merge:VI48_AVX512VL
16290 (plusminus:VI48_AVX512VL
16291 (match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
16292 (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
16293 (match_operand:VI48_AVX512VL 3 "nonimm_or_0_operand")
16294 (match_operand:<avx512fmaskmode> 4 "register_operand")))]
16295 "TARGET_AVX512F"
16296 "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
16297
16298 (define_expand "<insn><mode>3_mask"
16299 [(set (match_operand:VI12_AVX512VL 0 "register_operand")
16300 (vec_merge:VI12_AVX512VL
16301 (plusminus:VI12_AVX512VL
16302 (match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
16303 (match_operand:VI12_AVX512VL 2 "nonimmediate_operand"))
16304 (match_operand:VI12_AVX512VL 3 "nonimm_or_0_operand")
16305 (match_operand:<avx512fmaskmode> 4 "register_operand")))]
16306 "TARGET_AVX512BW"
16307 "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
16308
16309 (define_insn "*<insn><mode>3"
16310 [(set (match_operand:VI_AVX2 0 "register_operand" "=x,<v_Yw>")
16311 (plusminus:VI_AVX2
16312 (match_operand:VI_AVX2 1 "bcst_vector_operand" "<comm>0,<v_Yw>")
16313 (match_operand:VI_AVX2 2 "bcst_vector_operand" "xBm,<v_Yw>mBr")))]
16314 "TARGET_SSE2 && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
16315 "@
16316 p<plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
16317 vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16318 [(set_attr "isa" "noavx,avx")
16319 (set_attr "type" "sseiadd")
16320 (set_attr "prefix_data16" "1,*")
16321 (set_attr "prefix" "orig,maybe_evex")
16322 (set_attr "mode" "<sseinsnmode>")])
16323
16324 (define_insn "*<insn><mode>3_mask"
16325 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
16326 (vec_merge:VI48_AVX512VL
16327 (plusminus:VI48_AVX512VL
16328 (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "<comm>v")
16329 (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm"))
16330 (match_operand:VI48_AVX512VL 3 "nonimm_or_0_operand" "0C")
16331 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
16332 "TARGET_AVX512F && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
16333 "vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
16334 [(set_attr "type" "sseiadd")
16335 (set_attr "prefix" "evex")
16336 (set_attr "mode" "<sseinsnmode>")])
16337
16338 (define_insn "*<insn><mode>3_mask"
16339 [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
16340 (vec_merge:VI12_AVX512VL
16341 (plusminus:VI12_AVX512VL
16342 (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "<comm>v")
16343 (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm"))
16344 (match_operand:VI12_AVX512VL 3 "nonimm_or_0_operand" "0C")
16345 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
16346 "TARGET_AVX512BW && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
16347 "vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
16348 [(set_attr "type" "sseiadd")
16349 (set_attr "prefix" "evex")
16350 (set_attr "mode" "<sseinsnmode>")])
16351
16352 (define_expand "<insn><mode>3<mask_name>"
16353 [(set (match_operand:VI12_AVX2_AVX512BW 0 "register_operand")
16354 (sat_plusminus:VI12_AVX2_AVX512BW
16355 (match_operand:VI12_AVX2_AVX512BW 1 "vector_operand")
16356 (match_operand:VI12_AVX2_AVX512BW 2 "vector_operand")))]
16357 "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
16358 "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
16359
16360 (define_insn "*<sse2_avx2>_<insn><mode>3<mask_name>"
16361 [(set (match_operand:VI12_AVX2_AVX512BW 0 "register_operand" "=x,<v_Yw>")
16362 (sat_plusminus:VI12_AVX2_AVX512BW
16363 (match_operand:VI12_AVX2_AVX512BW 1 "vector_operand" "<comm>0,<v_Yw>")
16364 (match_operand:VI12_AVX2_AVX512BW 2 "vector_operand" "xBm,<v_Yw>m")))]
16365 "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
16366 && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
16367 "@
16368 p<plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
16369 vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
16370 [(set_attr "isa" "noavx,avx")
16371 (set_attr "type" "sseiadd")
16372 (set_attr "prefix_data16" "1,*")
16373 (set_attr "prefix" "orig,maybe_evex")
16374 (set_attr "mode" "TI")])
16375
16376 ;; PR96906 - optimize psubusw compared to 0 into pminuw compared to op0.
16377 (define_split
16378 [(set (match_operand:VI12_AVX2 0 "register_operand")
16379 (eq:VI12_AVX2
16380 (us_minus:VI12_AVX2
16381 (match_operand:VI12_AVX2 1 "vector_operand")
16382 (match_operand:VI12_AVX2 2 "vector_operand"))
16383 (match_operand:VI12_AVX2 3 "const0_operand")))]
16384 "TARGET_SSE2
16385 && (<MODE>mode != V8HImode || TARGET_SSE4_1)
16386 && ix86_binary_operator_ok (US_MINUS, <MODE>mode, operands)"
16387 [(set (match_dup 4)
16388 (umin:VI12_AVX2 (match_dup 1) (match_dup 2)))
16389 (set (match_dup 0)
16390 (eq:VI12_AVX2 (match_dup 4) (match_dup 1)))]
16391 "operands[4] = gen_reg_rtx (<MODE>mode);")
16392
16393 (define_expand "mul<mode>3"
16394 [(set (match_operand:VI1_AVX512 0 "register_operand")
16395 (mult:VI1_AVX512 (match_operand:VI1_AVX512 1 "register_operand")
16396 (match_operand:VI1_AVX512 2 "register_operand")))]
16397 "TARGET_SSE2"
16398 {
16399 ix86_expand_vecop_qihi (MULT, operands[0], operands[1], operands[2]);
16400 DONE;
16401 })
16402
16403 (define_expand "cond_mul<mode>"
16404 [(set (match_operand:VI2_AVX512VL 0 "register_operand")
16405 (vec_merge:VI2_AVX512VL
16406 (mult:VI2_AVX512VL
16407 (match_operand:VI2_AVX512VL 2 "vector_operand")
16408 (match_operand:VI2_AVX512VL 3 "vector_operand"))
16409 (match_operand:VI2_AVX512VL 4 "nonimm_or_0_operand")
16410 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
16411 "TARGET_AVX512BW"
16412 {
16413 emit_insn (gen_mul<mode>3_mask (operands[0],
16414 operands[2],
16415 operands[3],
16416 operands[4],
16417 operands[1]));
16418 DONE;
16419 })
16420
16421 (define_expand "mul<mode>3<mask_name>"
16422 [(set (match_operand:VI2_AVX2_AVX512BW 0 "register_operand")
16423 (mult:VI2_AVX2_AVX512BW (match_operand:VI2_AVX2_AVX512BW 1 "vector_operand")
16424 (match_operand:VI2_AVX2_AVX512BW 2 "vector_operand")))]
16425 "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
16426 "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
16427
16428 (define_insn "*mul<mode>3<mask_name>"
16429 [(set (match_operand:VI2_AVX2_AVX512BW 0 "register_operand" "=x,<v_Yw>")
16430 (mult:VI2_AVX2_AVX512BW (match_operand:VI2_AVX2_AVX512BW 1 "vector_operand" "%0,<v_Yw>")
16431 (match_operand:VI2_AVX2_AVX512BW 2 "vector_operand" "xBm,<v_Yw>m")))]
16432 "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))
16433 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
16434 "@
16435 pmullw\t{%2, %0|%0, %2}
16436 vpmullw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
16437 [(set_attr "isa" "noavx,avx")
16438 (set_attr "type" "sseimul")
16439 (set_attr "prefix_data16" "1,*")
16440 (set_attr "prefix" "orig,vex")
16441 (set_attr "mode" "<sseinsnmode>")])
16442
16443 (define_expand "<s>mul<mode>3_highpart<mask_name>"
16444 [(set (match_operand:VI2_AVX2_AVX512BW 0 "register_operand")
16445 (truncate:VI2_AVX2_AVX512BW
16446 (lshiftrt:<ssedoublemode>
16447 (mult:<ssedoublemode>
16448 (any_extend:<ssedoublemode>
16449 (match_operand:VI2_AVX2_AVX512BW 1 "vector_operand"))
16450 (any_extend:<ssedoublemode>
16451 (match_operand:VI2_AVX2_AVX512BW 2 "vector_operand")))
16452 (const_int 16))))]
16453 "TARGET_SSE2
16454 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
16455 "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
16456
16457 (define_insn "*<s>mul<mode>3_highpart<mask_name>"
16458 [(set (match_operand:VI2_AVX2_AVX512BW 0 "register_operand" "=x,<v_Yw>")
16459 (truncate:VI2_AVX2_AVX512BW
16460 (lshiftrt:<ssedoublemode>
16461 (mult:<ssedoublemode>
16462 (any_extend:<ssedoublemode>
16463 (match_operand:VI2_AVX2_AVX512BW 1 "vector_operand" "%0,<v_Yw>"))
16464 (any_extend:<ssedoublemode>
16465 (match_operand:VI2_AVX2_AVX512BW 2 "vector_operand" "xBm,<v_Yw>m")))
16466 (const_int 16))))]
16467 "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))
16468 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
16469 "@
16470 pmulh<u>w\t{%2, %0|%0, %2}
16471 vpmulh<u>w\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
16472 [(set_attr "isa" "noavx,avx")
16473 (set_attr "type" "sseimul")
16474 (set_attr "prefix_data16" "1,*")
16475 (set_attr "prefix" "orig,vex")
16476 (set_attr "mode" "<sseinsnmode>")])
16477
16478 (define_expand "vec_widen_umult_even_v16si<mask_name>"
16479 [(set (match_operand:V8DI 0 "register_operand")
16480 (mult:V8DI
16481 (zero_extend:V8DI
16482 (vec_select:V8SI
16483 (match_operand:V16SI 1 "nonimmediate_operand")
16484 (parallel [(const_int 0) (const_int 2)
16485 (const_int 4) (const_int 6)
16486 (const_int 8) (const_int 10)
16487 (const_int 12) (const_int 14)])))
16488 (zero_extend:V8DI
16489 (vec_select:V8SI
16490 (match_operand:V16SI 2 "nonimmediate_operand")
16491 (parallel [(const_int 0) (const_int 2)
16492 (const_int 4) (const_int 6)
16493 (const_int 8) (const_int 10)
16494 (const_int 12) (const_int 14)])))))]
16495 "TARGET_AVX512F && TARGET_EVEX512"
16496 "ix86_fixup_binary_operands_no_copy (MULT, V16SImode, operands);")
16497
16498 (define_insn "*vec_widen_umult_even_v16si<mask_name>"
16499 [(set (match_operand:V8DI 0 "register_operand" "=v")
16500 (mult:V8DI
16501 (zero_extend:V8DI
16502 (vec_select:V8SI
16503 (match_operand:V16SI 1 "nonimmediate_operand" "%v")
16504 (parallel [(const_int 0) (const_int 2)
16505 (const_int 4) (const_int 6)
16506 (const_int 8) (const_int 10)
16507 (const_int 12) (const_int 14)])))
16508 (zero_extend:V8DI
16509 (vec_select:V8SI
16510 (match_operand:V16SI 2 "nonimmediate_operand" "vm")
16511 (parallel [(const_int 0) (const_int 2)
16512 (const_int 4) (const_int 6)
16513 (const_int 8) (const_int 10)
16514 (const_int 12) (const_int 14)])))))]
16515 "TARGET_AVX512F && TARGET_EVEX512
16516 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16517 "vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
16518 [(set_attr "type" "sseimul")
16519 (set_attr "prefix" "evex")
16520 (set_attr "mode" "XI")])
16521
16522 (define_expand "vec_widen_umult_even_v8si<mask_name>"
16523 [(set (match_operand:V4DI 0 "register_operand")
16524 (mult:V4DI
16525 (zero_extend:V4DI
16526 (vec_select:V4SI
16527 (match_operand:V8SI 1 "nonimmediate_operand")
16528 (parallel [(const_int 0) (const_int 2)
16529 (const_int 4) (const_int 6)])))
16530 (zero_extend:V4DI
16531 (vec_select:V4SI
16532 (match_operand:V8SI 2 "nonimmediate_operand")
16533 (parallel [(const_int 0) (const_int 2)
16534 (const_int 4) (const_int 6)])))))]
16535 "TARGET_AVX2 && <mask_avx512vl_condition>"
16536 "ix86_fixup_binary_operands_no_copy (MULT, V8SImode, operands);")
16537
16538 (define_insn "*vec_widen_umult_even_v8si<mask_name>"
16539 [(set (match_operand:V4DI 0 "register_operand" "=v")
16540 (mult:V4DI
16541 (zero_extend:V4DI
16542 (vec_select:V4SI
16543 (match_operand:V8SI 1 "nonimmediate_operand" "%v")
16544 (parallel [(const_int 0) (const_int 2)
16545 (const_int 4) (const_int 6)])))
16546 (zero_extend:V4DI
16547 (vec_select:V4SI
16548 (match_operand:V8SI 2 "nonimmediate_operand" "vm")
16549 (parallel [(const_int 0) (const_int 2)
16550 (const_int 4) (const_int 6)])))))]
16551 "TARGET_AVX2 && <mask_avx512vl_condition>
16552 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16553 "vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
16554 [(set_attr "type" "sseimul")
16555 (set_attr "prefix" "maybe_evex")
16556 (set_attr "mode" "OI")])
16557
16558 (define_expand "vec_widen_umult_even_v4si<mask_name>"
16559 [(set (match_operand:V2DI 0 "register_operand")
16560 (mult:V2DI
16561 (zero_extend:V2DI
16562 (vec_select:V2SI
16563 (match_operand:V4SI 1 "vector_operand")
16564 (parallel [(const_int 0) (const_int 2)])))
16565 (zero_extend:V2DI
16566 (vec_select:V2SI
16567 (match_operand:V4SI 2 "vector_operand")
16568 (parallel [(const_int 0) (const_int 2)])))))]
16569 "TARGET_SSE2 && <mask_avx512vl_condition>"
16570 "ix86_fixup_binary_operands_no_copy (MULT, V4SImode, operands);")
16571
16572 (define_insn "*vec_widen_umult_even_v4si<mask_name>"
16573 [(set (match_operand:V2DI 0 "register_operand" "=x,v")
16574 (mult:V2DI
16575 (zero_extend:V2DI
16576 (vec_select:V2SI
16577 (match_operand:V4SI 1 "vector_operand" "%0,v")
16578 (parallel [(const_int 0) (const_int 2)])))
16579 (zero_extend:V2DI
16580 (vec_select:V2SI
16581 (match_operand:V4SI 2 "vector_operand" "xBm,vm")
16582 (parallel [(const_int 0) (const_int 2)])))))]
16583 "TARGET_SSE2 && <mask_avx512vl_condition>
16584 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16585 "@
16586 pmuludq\t{%2, %0|%0, %2}
16587 vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
16588 [(set_attr "isa" "noavx,avx")
16589 (set_attr "type" "sseimul")
16590 (set_attr "prefix_data16" "1,*")
16591 (set_attr "prefix" "orig,maybe_evex")
16592 (set_attr "mode" "TI")])
16593
16594 (define_expand "vec_widen_smult_even_v16si<mask_name>"
16595 [(set (match_operand:V8DI 0 "register_operand")
16596 (mult:V8DI
16597 (sign_extend:V8DI
16598 (vec_select:V8SI
16599 (match_operand:V16SI 1 "nonimmediate_operand")
16600 (parallel [(const_int 0) (const_int 2)
16601 (const_int 4) (const_int 6)
16602 (const_int 8) (const_int 10)
16603 (const_int 12) (const_int 14)])))
16604 (sign_extend:V8DI
16605 (vec_select:V8SI
16606 (match_operand:V16SI 2 "nonimmediate_operand")
16607 (parallel [(const_int 0) (const_int 2)
16608 (const_int 4) (const_int 6)
16609 (const_int 8) (const_int 10)
16610 (const_int 12) (const_int 14)])))))]
16611 "TARGET_AVX512F && TARGET_EVEX512"
16612 "ix86_fixup_binary_operands_no_copy (MULT, V16SImode, operands);")
16613
16614 (define_insn "*vec_widen_smult_even_v16si<mask_name>"
16615 [(set (match_operand:V8DI 0 "register_operand" "=v")
16616 (mult:V8DI
16617 (sign_extend:V8DI
16618 (vec_select:V8SI
16619 (match_operand:V16SI 1 "nonimmediate_operand" "%v")
16620 (parallel [(const_int 0) (const_int 2)
16621 (const_int 4) (const_int 6)
16622 (const_int 8) (const_int 10)
16623 (const_int 12) (const_int 14)])))
16624 (sign_extend:V8DI
16625 (vec_select:V8SI
16626 (match_operand:V16SI 2 "nonimmediate_operand" "vm")
16627 (parallel [(const_int 0) (const_int 2)
16628 (const_int 4) (const_int 6)
16629 (const_int 8) (const_int 10)
16630 (const_int 12) (const_int 14)])))))]
16631 "TARGET_AVX512F && TARGET_EVEX512
16632 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16633 "vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
16634 [(set_attr "type" "sseimul")
16635 (set_attr "prefix" "evex")
16636 (set_attr "mode" "XI")])
16637
16638 (define_expand "vec_widen_smult_even_v8si<mask_name>"
16639 [(set (match_operand:V4DI 0 "register_operand")
16640 (mult:V4DI
16641 (sign_extend:V4DI
16642 (vec_select:V4SI
16643 (match_operand:V8SI 1 "nonimmediate_operand")
16644 (parallel [(const_int 0) (const_int 2)
16645 (const_int 4) (const_int 6)])))
16646 (sign_extend:V4DI
16647 (vec_select:V4SI
16648 (match_operand:V8SI 2 "nonimmediate_operand")
16649 (parallel [(const_int 0) (const_int 2)
16650 (const_int 4) (const_int 6)])))))]
16651 "TARGET_AVX2 && <mask_avx512vl_condition>"
16652 "ix86_fixup_binary_operands_no_copy (MULT, V8SImode, operands);")
16653
16654 (define_insn "*vec_widen_smult_even_v8si<mask_name>"
16655 [(set (match_operand:V4DI 0 "register_operand" "=v")
16656 (mult:V4DI
16657 (sign_extend:V4DI
16658 (vec_select:V4SI
16659 (match_operand:V8SI 1 "nonimmediate_operand" "%v")
16660 (parallel [(const_int 0) (const_int 2)
16661 (const_int 4) (const_int 6)])))
16662 (sign_extend:V4DI
16663 (vec_select:V4SI
16664 (match_operand:V8SI 2 "nonimmediate_operand" "vm")
16665 (parallel [(const_int 0) (const_int 2)
16666 (const_int 4) (const_int 6)])))))]
16667 "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16668 "vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
16669 [(set_attr "type" "sseimul")
16670 (set_attr "prefix_extra" "1")
16671 (set_attr "prefix" "vex")
16672 (set_attr "mode" "OI")])
16673
16674 (define_expand "sse4_1_mulv2siv2di3<mask_name>"
16675 [(set (match_operand:V2DI 0 "register_operand")
16676 (mult:V2DI
16677 (sign_extend:V2DI
16678 (vec_select:V2SI
16679 (match_operand:V4SI 1 "vector_operand")
16680 (parallel [(const_int 0) (const_int 2)])))
16681 (sign_extend:V2DI
16682 (vec_select:V2SI
16683 (match_operand:V4SI 2 "vector_operand")
16684 (parallel [(const_int 0) (const_int 2)])))))]
16685 "TARGET_SSE4_1 && <mask_avx512vl_condition>"
16686 "ix86_fixup_binary_operands_no_copy (MULT, V4SImode, operands);")
16687
16688 (define_insn "*sse4_1_mulv2siv2di3<mask_name>"
16689 [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
16690 (mult:V2DI
16691 (sign_extend:V2DI
16692 (vec_select:V2SI
16693 (match_operand:V4SI 1 "vector_operand" "%0,0,v")
16694 (parallel [(const_int 0) (const_int 2)])))
16695 (sign_extend:V2DI
16696 (vec_select:V2SI
16697 (match_operand:V4SI 2 "vector_operand" "Yrja,*xja,vm")
16698 (parallel [(const_int 0) (const_int 2)])))))]
16699 "TARGET_SSE4_1 && <mask_avx512vl_condition>
16700 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16701 "@
16702 pmuldq\t{%2, %0|%0, %2}
16703 pmuldq\t{%2, %0|%0, %2}
16704 vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
16705 [(set_attr "isa" "noavx,noavx,avx")
16706 (set_attr "addr" "gpr16,gpr16,*")
16707 (set_attr "type" "sseimul")
16708 (set_attr "prefix_extra" "1")
16709 (set_attr "prefix" "orig,orig,vex")
16710 (set_attr "mode" "TI")])
16711
16712 (define_insn "avx512bw_pmaddwd512<mode><mask_name>"
16713 [(set (match_operand:<sseunpackmode> 0 "register_operand" "=v")
16714 (unspec:<sseunpackmode>
16715 [(match_operand:VI2_AVX2_AVX512BW 1 "register_operand" "v")
16716 (match_operand:VI2_AVX2_AVX512BW 2 "nonimmediate_operand" "vm")]
16717 UNSPEC_PMADDWD512))]
16718 "TARGET_AVX512BW && <mask_mode512bit_condition>"
16719 "vpmaddwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}";
16720 [(set_attr "type" "sseiadd")
16721 (set_attr "c86_attr" "madd")
16722 (set_attr "prefix" "evex")
16723 (set_attr "mode" "XI")])
16724
16725 (define_expand "avx2_pmaddwd"
16726 [(set (match_operand:V8SI 0 "register_operand")
16727 (plus:V8SI
16728 (mult:V8SI
16729 (sign_extend:V8SI
16730 (vec_select:V8HI
16731 (match_operand:V16HI 1 "nonimmediate_operand")
16732 (parallel [(const_int 0) (const_int 2)
16733 (const_int 4) (const_int 6)
16734 (const_int 8) (const_int 10)
16735 (const_int 12) (const_int 14)])))
16736 (sign_extend:V8SI
16737 (vec_select:V8HI
16738 (match_operand:V16HI 2 "nonimmediate_operand")
16739 (parallel [(const_int 0) (const_int 2)
16740 (const_int 4) (const_int 6)
16741 (const_int 8) (const_int 10)
16742 (const_int 12) (const_int 14)]))))
16743 (mult:V8SI
16744 (sign_extend:V8SI
16745 (vec_select:V8HI (match_dup 1)
16746 (parallel [(const_int 1) (const_int 3)
16747 (const_int 5) (const_int 7)
16748 (const_int 9) (const_int 11)
16749 (const_int 13) (const_int 15)])))
16750 (sign_extend:V8SI
16751 (vec_select:V8HI (match_dup 2)
16752 (parallel [(const_int 1) (const_int 3)
16753 (const_int 5) (const_int 7)
16754 (const_int 9) (const_int 11)
16755 (const_int 13) (const_int 15)]))))))]
16756 "TARGET_AVX2"
16757 "ix86_fixup_binary_operands_no_copy (MULT, V16HImode, operands);")
16758
16759 (define_insn "*avx2_pmaddwd"
16760 [(set (match_operand:V8SI 0 "register_operand" "=Yw")
16761 (plus:V8SI
16762 (mult:V8SI
16763 (sign_extend:V8SI
16764 (vec_select:V8HI
16765 (match_operand:V16HI 1 "nonimmediate_operand" "%Yw")
16766 (parallel [(const_int 0) (const_int 2)
16767 (const_int 4) (const_int 6)
16768 (const_int 8) (const_int 10)
16769 (const_int 12) (const_int 14)])))
16770 (sign_extend:V8SI
16771 (vec_select:V8HI
16772 (match_operand:V16HI 2 "nonimmediate_operand" "Ywm")
16773 (parallel [(const_int 0) (const_int 2)
16774 (const_int 4) (const_int 6)
16775 (const_int 8) (const_int 10)
16776 (const_int 12) (const_int 14)]))))
16777 (mult:V8SI
16778 (sign_extend:V8SI
16779 (vec_select:V8HI (match_dup 1)
16780 (parallel [(const_int 1) (const_int 3)
16781 (const_int 5) (const_int 7)
16782 (const_int 9) (const_int 11)
16783 (const_int 13) (const_int 15)])))
16784 (sign_extend:V8SI
16785 (vec_select:V8HI (match_dup 2)
16786 (parallel [(const_int 1) (const_int 3)
16787 (const_int 5) (const_int 7)
16788 (const_int 9) (const_int 11)
16789 (const_int 13) (const_int 15)]))))))]
16790 "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16791 "vpmaddwd\t{%2, %1, %0|%0, %1, %2}"
16792 [(set_attr "type" "sseiadd")
16793 (set_attr "c86_attr" "madd")
16794 (set_attr "prefix" "vex")
16795 (set_attr "mode" "OI")])
16796
16797 (define_expand "sse2_pmaddwd"
16798 [(set (match_operand:V4SI 0 "register_operand")
16799 (plus:V4SI
16800 (mult:V4SI
16801 (sign_extend:V4SI
16802 (vec_select:V4HI
16803 (match_operand:V8HI 1 "vector_operand")
16804 (parallel [(const_int 0) (const_int 2)
16805 (const_int 4) (const_int 6)])))
16806 (sign_extend:V4SI
16807 (vec_select:V4HI
16808 (match_operand:V8HI 2 "vector_operand")
16809 (parallel [(const_int 0) (const_int 2)
16810 (const_int 4) (const_int 6)]))))
16811 (mult:V4SI
16812 (sign_extend:V4SI
16813 (vec_select:V4HI (match_dup 1)
16814 (parallel [(const_int 1) (const_int 3)
16815 (const_int 5) (const_int 7)])))
16816 (sign_extend:V4SI
16817 (vec_select:V4HI (match_dup 2)
16818 (parallel [(const_int 1) (const_int 3)
16819 (const_int 5) (const_int 7)]))))))]
16820 "TARGET_SSE2"
16821 "ix86_fixup_binary_operands_no_copy (MULT, V8HImode, operands);")
16822
16823 (define_insn "*sse2_pmaddwd"
16824 [(set (match_operand:V4SI 0 "register_operand" "=x,Yw")
16825 (plus:V4SI
16826 (mult:V4SI
16827 (sign_extend:V4SI
16828 (vec_select:V4HI
16829 (match_operand:V8HI 1 "vector_operand" "%0,Yw")
16830 (parallel [(const_int 0) (const_int 2)
16831 (const_int 4) (const_int 6)])))
16832 (sign_extend:V4SI
16833 (vec_select:V4HI
16834 (match_operand:V8HI 2 "vector_operand" "xBm,Ywm")
16835 (parallel [(const_int 0) (const_int 2)
16836 (const_int 4) (const_int 6)]))))
16837 (mult:V4SI
16838 (sign_extend:V4SI
16839 (vec_select:V4HI (match_dup 1)
16840 (parallel [(const_int 1) (const_int 3)
16841 (const_int 5) (const_int 7)])))
16842 (sign_extend:V4SI
16843 (vec_select:V4HI (match_dup 2)
16844 (parallel [(const_int 1) (const_int 3)
16845 (const_int 5) (const_int 7)]))))))]
16846 "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16847 "@
16848 pmaddwd\t{%2, %0|%0, %2}
16849 vpmaddwd\t{%2, %1, %0|%0, %1, %2}"
16850 [(set_attr "isa" "noavx,avx")
16851 (set_attr "type" "sseiadd")
16852 (set_attr "c86_attr" "madd")
16853 (set_attr "atom_unit" "simul")
16854 (set_attr "prefix_data16" "1,*")
16855 (set_attr "prefix" "orig,vex")
16856 (set_attr "mode" "TI")])
16857
16858 (define_expand "cond_mul<mode>"
16859 [(set (match_operand:VI8_AVX512VL 0 "register_operand")
16860 (vec_merge:VI8_AVX512VL
16861 (mult:VI8_AVX512VL
16862 (match_operand:VI8_AVX512VL 2 "vector_operand")
16863 (match_operand:VI8_AVX512VL 3 "vector_operand"))
16864 (match_operand:VI8_AVX512VL 4 "nonimm_or_0_operand")
16865 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
16866 "TARGET_AVX512DQ"
16867 {
16868 emit_insn (gen_avx512dq_mul<mode>3_mask (operands[0],
16869 operands[2],
16870 operands[3],
16871 operands[4],
16872 operands[1]));
16873 DONE;
16874 })
16875
16876 (define_expand "avx512dq_mul<mode>3<mask_name>"
16877 [(set (match_operand:VI8_AVX512VL 0 "register_operand")
16878 (mult:VI8_AVX512VL
16879 (match_operand:VI8_AVX512VL 1 "bcst_vector_operand")
16880 (match_operand:VI8_AVX512VL 2 "bcst_vector_operand")))]
16881 "TARGET_AVX512DQ && <mask_mode512bit_condition>"
16882 "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
16883
16884 (define_insn "*avx512dq_mul<mode>3<mask_name>"
16885 [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
16886 (mult:VI8_AVX512VL
16887 (match_operand:VI8_AVX512VL 1 "bcst_vector_operand" "%v")
16888 (match_operand:VI8_AVX512VL 2 "bcst_vector_operand" "vmBr")))]
16889 "TARGET_AVX512DQ && <mask_mode512bit_condition>
16890 && ix86_binary_operator_ok (MULT, <MODE>mode, operands)"
16891 {
16892 if (TARGET_DEST_FALSE_DEP_FOR_GLC
16893 && <mask3_dest_false_dep_for_glc_cond>
16894 && !reg_mentioned_p (operands[0], operands[1])
16895 && !reg_mentioned_p (operands[0], operands[2]))
16896 output_asm_insn ("vxorps\t%x0, %x0, %x0", operands);
16897 return "vpmullq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}";
16898 }
16899 [(set_attr "type" "sseimul")
16900 (set_attr "prefix" "evex")
16901 (set_attr "mode" "<sseinsnmode>")])
16902
16903 (define_expand "cond_mul<mode>"
16904 [(set (match_operand:VI4_AVX512VL 0 "register_operand")
16905 (vec_merge:VI4_AVX512VL
16906 (mult:VI4_AVX512VL
16907 (match_operand:VI4_AVX512VL 2 "vector_operand")
16908 (match_operand:VI4_AVX512VL 3 "vector_operand"))
16909 (match_operand:VI4_AVX512VL 4 "nonimm_or_0_operand")
16910 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
16911 "TARGET_AVX512F"
16912 {
16913 emit_insn (gen_mul<mode>3_mask (operands[0],
16914 operands[2],
16915 operands[3],
16916 operands[4],
16917 operands[1]));
16918 DONE;
16919 })
16920
16921 (define_expand "mul<mode>3<mask_name>"
16922 [(set (match_operand:VI4_AVX512F 0 "register_operand")
16923 (mult:VI4_AVX512F
16924 (match_operand:VI4_AVX512F 1 "general_vector_operand")
16925 (match_operand:VI4_AVX512F 2 "general_vector_operand")))]
16926 "TARGET_SSE2 && <mask_mode512bit_condition>"
16927 {
16928 if (TARGET_SSE4_1)
16929 {
16930 if (!vector_operand (operands[1], <MODE>mode))
16931 operands[1] = force_reg (<MODE>mode, operands[1]);
16932 if (!vector_operand (operands[2], <MODE>mode))
16933 operands[2] = force_reg (<MODE>mode, operands[2]);
16934 ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
16935 }
16936 else
16937 {
16938 ix86_expand_sse2_mulv4si3 (operands[0], operands[1], operands[2]);
16939 DONE;
16940 }
16941 })
16942
16943 (define_insn "*<sse4_1_avx2>_mul<mode>3<mask_name>"
16944 [(set (match_operand:VI4_AVX512F 0 "register_operand" "=Yr,*x,v")
16945 (mult:VI4_AVX512F
16946 (match_operand:VI4_AVX512F 1 "bcst_vector_operand" "%0,0,v")
16947 (match_operand:VI4_AVX512F 2 "bcst_vector_operand" "Yrja,*xja,vmBr")))]
16948 "TARGET_SSE4_1 && ix86_binary_operator_ok (MULT, <MODE>mode, operands)
16949 && <mask_mode512bit_condition>"
16950 "@
16951 pmulld\t{%2, %0|%0, %2}
16952 pmulld\t{%2, %0|%0, %2}
16953 vpmulld\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
16954 [(set_attr "isa" "noavx,noavx,avx")
16955 (set_attr "addr" "gpr16,gpr16,*")
16956 (set_attr "type" "sseimul")
16957 (set_attr "prefix_extra" "1")
16958 (set_attr "prefix" "<bcst_mask_prefix4>")
16959 (set_attr "btver2_decode" "vector,vector,vector")
16960 (set_attr "mode" "<sseinsnmode>")])
16961
16962 (define_expand "mul<mode>3"
16963 [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand")
16964 (mult:VI8_AVX2_AVX512F
16965 (match_operand:VI8_AVX2_AVX512F 1 "register_operand")
16966 (match_operand:VI8_AVX2_AVX512F 2 "register_operand")))]
16967 "TARGET_SSE2"
16968 {
16969 ix86_expand_sse2_mulvxdi3 (operands[0], operands[1], operands[2]);
16970 DONE;
16971 })
16972
16973 (define_expand "vec_widen_<s>mult_hi_<mode>"
16974 [(match_operand:<sseunpackmode> 0 "register_operand")
16975 (any_extend:<sseunpackmode>
16976 (match_operand:VI124_AVX2 1 "register_operand"))
16977 (match_operand:VI124_AVX2 2 "register_operand")]
16978 "TARGET_SSE2"
16979 {
16980 ix86_expand_mul_widen_hilo (operands[0], operands[1], operands[2],
16981 <u_bool>, true);
16982 DONE;
16983 })
16984
16985 (define_expand "vec_widen_<s>mult_lo_<mode>"
16986 [(match_operand:<sseunpackmode> 0 "register_operand")
16987 (any_extend:<sseunpackmode>
16988 (match_operand:VI124_AVX2 1 "register_operand"))
16989 (match_operand:VI124_AVX2 2 "register_operand")]
16990 "TARGET_SSE2"
16991 {
16992 ix86_expand_mul_widen_hilo (operands[0], operands[1], operands[2],
16993 <u_bool>, false);
16994 DONE;
16995 })
16996
16997 ;; Most widen_<s>mult_even_<mode> can be handled directly from other
16998 ;; named patterns, but signed V4SI needs special help for plain SSE2.
16999 (define_expand "vec_widen_smult_even_v4si"
17000 [(match_operand:V2DI 0 "register_operand")
17001 (match_operand:V4SI 1 "vector_operand")
17002 (match_operand:V4SI 2 "vector_operand")]
17003 "TARGET_SSE2"
17004 {
17005 ix86_expand_mul_widen_evenodd (operands[0], operands[1], operands[2],
17006 false, false);
17007 DONE;
17008 })
17009
17010 (define_expand "vec_widen_<s>mult_odd_<mode>"
17011 [(match_operand:<sseunpackmode> 0 "register_operand")
17012 (any_extend:<sseunpackmode>
17013 (match_operand:VI4_AVX512F 1 "general_vector_operand"))
17014 (match_operand:VI4_AVX512F 2 "general_vector_operand")]
17015 "TARGET_SSE2"
17016 {
17017 ix86_expand_mul_widen_evenodd (operands[0], operands[1], operands[2],
17018 <u_bool>, true);
17019 DONE;
17020 })
17021
17022 (define_mode_attr SDOT_PMADD_SUF
17023 [(V32HI "512v32hi") (V16HI "") (V8HI "")])
17024
17025 (define_mode_attr SDOT_VPDP_SUF
17026 [(V32HI "v16si") (V16HI "v8si") (V8HI "v4si")])
17027
17028 (define_expand "sdot_prod<sseunpackmodelower><mode>"
17029 [(match_operand:<sseunpackmode> 0 "register_operand")
17030 (match_operand:VI2_AVX512VNNIBW 1 "register_operand")
17031 (match_operand:VI2_AVX512VNNIBW 2 "register_operand")
17032 (match_operand:<sseunpackmode> 3 "register_operand")]
17033 "TARGET_SSE2"
17034 {
17035 /* Try with vnni instructions. */
17036 if ((<MODE_SIZE> == 64 && TARGET_AVX512VNNI && TARGET_EVEX512)
17037 || (<MODE_SIZE> < 64
17038 && ((TARGET_AVX512VNNI && TARGET_AVX512VL) || TARGET_AVXVNNI)))
17039 {
17040 operands[1] = lowpart_subreg (<sseunpackmode>mode,
17041 force_reg (<MODE>mode, operands[1]),
17042 <MODE>mode);
17043 operands[2] = lowpart_subreg (<sseunpackmode>mode,
17044 force_reg (<MODE>mode, operands[2]),
17045 <MODE>mode);
17046 emit_insn (gen_vpdpwssd_<SDOT_VPDP_SUF> (operands[0], operands[3],
17047 operands[1], operands[2]));
17048 }
17049 /* Otherwise use pmaddwd + paddd. */
17050 else
17051 {
17052 rtx t = gen_reg_rtx (<sseunpackmode>mode);
17053 emit_insn (gen_<sse2_avx2>_pmaddwd<SDOT_PMADD_SUF> (t, operands[1], operands[2]));
17054 emit_insn (gen_rtx_SET (operands[0],
17055 gen_rtx_PLUS (<sseunpackmode>mode,
17056 operands[3], t)));
17057 }
17058 DONE;
17059 })
17060
17061 ;; Normally we use widen_mul_even/odd, but combine can't quite get it all
17062 ;; back together when madd is available.
17063 (define_expand "sdot_prodv2div4si"
17064 [(match_operand:V2DI 0 "register_operand")
17065 (match_operand:V4SI 1 "register_operand")
17066 (match_operand:V4SI 2 "register_operand")
17067 (match_operand:V2DI 3 "register_operand")]
17068 "TARGET_XOP"
17069 {
17070 rtx t = gen_reg_rtx (V2DImode);
17071 emit_insn (gen_xop_pmacsdqh (t, operands[1], operands[2], operands[3]));
17072 emit_insn (gen_xop_pmacsdql (operands[0], operands[1], operands[2], t));
17073 DONE;
17074 })
17075
17076 (define_expand "uavg<mode>3_ceil"
17077 [(set (match_operand:VI12_AVX2_AVX512BW 0 "register_operand")
17078 (truncate:VI12_AVX2_AVX512BW
17079 (lshiftrt:<ssedoublemode>
17080 (plus:<ssedoublemode>
17081 (plus:<ssedoublemode>
17082 (zero_extend:<ssedoublemode>
17083 (match_operand:VI12_AVX2_AVX512BW 1 "vector_operand"))
17084 (zero_extend:<ssedoublemode>
17085 (match_operand:VI12_AVX2_AVX512BW 2 "vector_operand")))
17086 (match_dup 3))
17087 (const_int 1))))]
17088 "TARGET_SSE2"
17089 {
17090 operands[3] = CONST1_RTX(<ssedoublemode>mode);
17091 ix86_fixup_binary_operands_no_copy (PLUS, <MODE>mode, operands);
17092 })
17093
17094 (define_expand "usadv16qi"
17095 [(match_operand:V4SI 0 "register_operand")
17096 (match_operand:V16QI 1 "register_operand")
17097 (match_operand:V16QI 2 "vector_operand")
17098 (match_operand:V4SI 3 "vector_operand")]
17099 "TARGET_SSE2"
17100 {
17101 rtx t1 = gen_reg_rtx (V2DImode);
17102 rtx t2 = gen_reg_rtx (V4SImode);
17103 emit_insn (gen_sse2_psadbw (t1, operands[1], operands[2]));
17104 convert_move (t2, t1, 0);
17105 emit_insn (gen_addv4si3 (operands[0], t2, operands[3]));
17106 DONE;
17107 })
17108
17109 (define_expand "usadv32qi"
17110 [(match_operand:V8SI 0 "register_operand")
17111 (match_operand:V32QI 1 "register_operand")
17112 (match_operand:V32QI 2 "nonimmediate_operand")
17113 (match_operand:V8SI 3 "nonimmediate_operand")]
17114 "TARGET_AVX2"
17115 {
17116 rtx t1 = gen_reg_rtx (V4DImode);
17117 rtx t2 = gen_reg_rtx (V8SImode);
17118 emit_insn (gen_avx2_psadbw (t1, operands[1], operands[2]));
17119 convert_move (t2, t1, 0);
17120 emit_insn (gen_addv8si3 (operands[0], t2, operands[3]));
17121 DONE;
17122 })
17123
17124 (define_expand "usadv64qi"
17125 [(match_operand:V16SI 0 "register_operand")
17126 (match_operand:V64QI 1 "register_operand")
17127 (match_operand:V64QI 2 "nonimmediate_operand")
17128 (match_operand:V16SI 3 "nonimmediate_operand")]
17129 "TARGET_AVX512BW && TARGET_EVEX512"
17130 {
17131 rtx t1 = gen_reg_rtx (V8DImode);
17132 rtx t2 = gen_reg_rtx (V16SImode);
17133 emit_insn (gen_avx512f_psadbw (t1, operands[1], operands[2]));
17134 convert_move (t2, t1, 0);
17135 emit_insn (gen_addv16si3 (operands[0], t2, operands[3]));
17136 DONE;
17137 })
17138
17139 (define_insn "<mask_codefor>ashr<mode>3<mask_name>"
17140 [(set (match_operand:VI248_AVX512BW_1 0 "register_operand" "=v,v")
17141 (ashiftrt:VI248_AVX512BW_1
17142 (match_operand:VI248_AVX512BW_1 1 "nonimmediate_operand" "v,vm")
17143 (match_operand:DI 2 "nonmemory_operand" "v,N")))]
17144 "TARGET_AVX512VL"
17145 "vpsra<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
17146 [(set_attr "type" "sseishft")
17147 (set (attr "length_immediate")
17148 (if_then_else (match_operand 2 "const_int_operand")
17149 (const_string "1")
17150 (const_string "0")))
17151 (set_attr "mode" "<sseinsnmode>")])
17152
17153 (define_insn "ashr<mode>3"
17154 [(set (match_operand:VI24_AVX2 0 "register_operand" "=x,<v_Yw>")
17155 (ashiftrt:VI24_AVX2
17156 (match_operand:VI24_AVX2 1 "register_operand" "0,<v_Yw>")
17157 (match_operand:DI 2 "nonmemory_operand" "xN,YwN")))]
17158 "TARGET_SSE2"
17159 "@
17160 psra<ssemodesuffix>\t{%2, %0|%0, %2}
17161 vpsra<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17162 [(set_attr "isa" "noavx,avx")
17163 (set_attr "type" "sseishft")
17164 (set (attr "length_immediate")
17165 (if_then_else (match_operand 2 "const_int_operand")
17166 (const_string "1")
17167 (const_string "0")))
17168 (set_attr "prefix_data16" "1,*")
17169 (set_attr "prefix" "orig,vex")
17170 (set_attr "mode" "<sseinsnmode>")])
17171
17172 (define_insn_and_split "*ashr<mode>3_1"
17173 [(set (match_operand:VI24_AVX2 0 "register_operand")
17174 (lt:VI24_AVX2
17175 (match_operand:VI24_AVX2 1 "register_operand")
17176 (match_operand:VI24_AVX2 2 "const0_operand")))]
17177 "TARGET_SSE2 && ix86_pre_reload_split ()"
17178 "#"
17179 "&& 1"
17180 [(set (match_dup 0) (ashiftrt:VI24_AVX2 (match_dup 1) (match_dup 3)))]
17181 "operands[3] = gen_int_mode (<ssescalarsize> - 1, DImode);")
17182
17183 (define_insn "<mask_codefor>ashr<mode>3<mask_name>"
17184 [(set (match_operand:VI248_AVX512BW_AVX512VL 0 "register_operand" "=v,v")
17185 (ashiftrt:VI248_AVX512BW_AVX512VL
17186 (match_operand:VI248_AVX512BW_AVX512VL 1 "nonimmediate_operand" "v,vm")
17187 (match_operand:DI 2 "nonmemory_operand" "v,N")))]
17188 "TARGET_AVX512F"
17189 "vpsra<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
17190 [(set_attr "type" "sseishft")
17191 (set (attr "length_immediate")
17192 (if_then_else (match_operand 2 "const_int_operand")
17193 (const_string "1")
17194 (const_string "0")))
17195 (set_attr "mode" "<sseinsnmode>")])
17196
17197 (define_insn_and_split "*avx512_ashr<mode>3_1"
17198 [(set (match_operand:VI248_AVX512VLBW 0 "register_operand")
17199 (vec_merge:VI248_AVX512VLBW
17200 (match_operand:VI248_AVX512VLBW 1 "vector_all_ones_operand")
17201 (match_operand:VI248_AVX512VLBW 2 "const0_operand")
17202 (unspec:<avx512fmaskmode>
17203 [(match_operand:VI248_AVX512VLBW 3 "nonimmediate_operand")
17204 (match_operand:VI248_AVX512VLBW 4 "const0_operand")
17205 (const_int 1)]
17206 UNSPEC_PCMP)))]
17207 "TARGET_AVX512F && ix86_pre_reload_split ()"
17208 "#"
17209 "&& 1"
17210 [(set (match_dup 0)
17211 (ashiftrt:VI248_AVX512VLBW (match_dup 3) (match_dup 5)))]
17212 "operands[5] = gen_int_mode (<ssescalarsize> - 1, DImode);")
17213
17214 (define_expand "ashr<mode>3"
17215 [(set (match_operand:VI248_AVX512BW 0 "register_operand")
17216 (ashiftrt:VI248_AVX512BW
17217 (match_operand:VI248_AVX512BW 1 "nonimmediate_operand")
17218 (match_operand:DI 2 "nonmemory_operand")))]
17219 "TARGET_AVX512F")
17220
17221 (define_expand "ashrv4di3"
17222 [(set (match_operand:V4DI 0 "register_operand")
17223 (ashiftrt:V4DI
17224 (match_operand:V4DI 1 "nonimmediate_operand")
17225 (match_operand:DI 2 "nonmemory_operand")))]
17226 "TARGET_AVX2"
17227 {
17228 if (!TARGET_AVX512VL)
17229 {
17230 if (CONST_INT_P (operands[2]) && UINTVAL (operands[2]) >= 63)
17231 {
17232 rtx zero = force_reg (V4DImode, CONST0_RTX (V4DImode));
17233 emit_insn (gen_avx2_gtv4di3 (operands[0], zero, operands[1]));
17234 DONE;
17235 }
17236 if (operands[2] == const0_rtx)
17237 {
17238 emit_move_insn (operands[0], operands[1]);
17239 DONE;
17240 }
17241 operands[1] = force_reg (V4DImode, operands[1]);
17242 if (CONST_INT_P (operands[2]))
17243 {
17244 vec_perm_builder sel (8, 8, 1);
17245 sel.quick_grow (8);
17246 rtx arg0, arg1;
17247 rtx op1 = lowpart_subreg (V8SImode, operands[1], V4DImode);
17248 rtx target = gen_reg_rtx (V8SImode);
17249 if (INTVAL (operands[2]) > 32)
17250 {
17251 arg0 = gen_reg_rtx (V8SImode);
17252 arg1 = gen_reg_rtx (V8SImode);
17253 emit_insn (gen_ashrv8si3 (arg1, op1, GEN_INT (31)));
17254 emit_insn (gen_ashrv8si3 (arg0, op1,
17255 GEN_INT (INTVAL (operands[2]) - 32)));
17256 sel[0] = 1;
17257 sel[1] = 9;
17258 sel[2] = 3;
17259 sel[3] = 11;
17260 sel[4] = 5;
17261 sel[5] = 13;
17262 sel[6] = 7;
17263 sel[7] = 15;
17264 }
17265 else if (INTVAL (operands[2]) == 32)
17266 {
17267 arg0 = op1;
17268 arg1 = gen_reg_rtx (V8SImode);
17269 emit_insn (gen_ashrv8si3 (arg1, op1, GEN_INT (31)));
17270 sel[0] = 1;
17271 sel[1] = 9;
17272 sel[2] = 3;
17273 sel[3] = 11;
17274 sel[4] = 5;
17275 sel[5] = 13;
17276 sel[6] = 7;
17277 sel[7] = 15;
17278 }
17279 else
17280 {
17281 arg0 = gen_reg_rtx (V4DImode);
17282 arg1 = gen_reg_rtx (V8SImode);
17283 emit_insn (gen_lshrv4di3 (arg0, operands[1], operands[2]));
17284 emit_insn (gen_ashrv8si3 (arg1, op1, operands[2]));
17285 arg0 = lowpart_subreg (V8SImode, arg0, V4DImode);
17286 sel[0] = 0;
17287 sel[1] = 9;
17288 sel[2] = 2;
17289 sel[3] = 11;
17290 sel[4] = 4;
17291 sel[5] = 13;
17292 sel[6] = 6;
17293 sel[7] = 15;
17294 }
17295 vec_perm_indices indices (sel, 2, 8);
17296 bool ok = targetm.vectorize.vec_perm_const (V8SImode, V8SImode,
17297 target, arg0, arg1,
17298 indices);
17299 gcc_assert (ok);
17300 emit_move_insn (operands[0],
17301 lowpart_subreg (V4DImode, target, V8SImode));
17302 DONE;
17303 }
17304
17305 rtx zero = force_reg (V4DImode, CONST0_RTX (V4DImode));
17306 rtx zero_or_all_ones = gen_reg_rtx (V4DImode);
17307 emit_insn (gen_avx2_gtv4di3 (zero_or_all_ones, zero, operands[1]));
17308 rtx lshr_res = gen_reg_rtx (V4DImode);
17309 emit_insn (gen_lshrv4di3 (lshr_res, operands[1], operands[2]));
17310 rtx ashl_res = gen_reg_rtx (V4DImode);
17311 rtx amount;
17312 if (TARGET_64BIT)
17313 {
17314 amount = gen_reg_rtx (DImode);
17315 emit_insn (gen_subdi3 (amount, force_reg (DImode, GEN_INT (64)),
17316 operands[2]));
17317 }
17318 else
17319 {
17320 rtx temp = gen_reg_rtx (SImode);
17321 emit_insn (gen_subsi3 (temp, force_reg (SImode, GEN_INT (64)),
17322 lowpart_subreg (SImode, operands[2],
17323 DImode)));
17324 amount = gen_reg_rtx (V4SImode);
17325 emit_insn (gen_vec_setv4si_0 (amount, CONST0_RTX (V4SImode),
17326 temp));
17327 }
17328 amount = lowpart_subreg (DImode, amount, GET_MODE (amount));
17329 emit_insn (gen_ashlv4di3 (ashl_res, zero_or_all_ones, amount));
17330 emit_insn (gen_iorv4di3 (operands[0], lshr_res, ashl_res));
17331 DONE;
17332 }
17333 })
17334
17335 (define_insn "<mask_codefor><insn><mode>3<mask_name>"
17336 [(set (match_operand:VI248_AVX512BW_2 0 "register_operand" "=v,v")
17337 (any_lshift:VI248_AVX512BW_2
17338 (match_operand:VI248_AVX512BW_2 1 "nonimmediate_operand" "v,vm")
17339 (match_operand:DI 2 "nonmemory_operand" "v,N")))]
17340 "TARGET_AVX512VL"
17341 "vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
17342 [(set_attr "type" "sseishft")
17343 (set (attr "length_immediate")
17344 (if_then_else (match_operand 2 "const_int_operand")
17345 (const_string "1")
17346 (const_string "0")))
17347 (set_attr "mode" "<sseinsnmode>")])
17348
17349 (define_insn "<insn><mode>3"
17350 [(set (match_operand:VI248_AVX2 0 "register_operand" "=x,<v_Yw>")
17351 (any_lshift:VI248_AVX2
17352 (match_operand:VI248_AVX2 1 "register_operand" "0,<v_Yw>")
17353 (match_operand:DI 2 "nonmemory_operand" "xN,YwN")))]
17354 "TARGET_SSE2"
17355 "@
17356 p<vshift><ssemodesuffix>\t{%2, %0|%0, %2}
17357 vp<vshift><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17358 [(set_attr "isa" "noavx,avx")
17359 (set_attr "type" "sseishft")
17360 (set (attr "length_immediate")
17361 (if_then_else (match_operand 2 "const_int_operand")
17362 (const_string "1")
17363 (const_string "0")))
17364 (set_attr "prefix_data16" "1,*")
17365 (set_attr "prefix" "orig,vex")
17366 (set_attr "mode" "<sseinsnmode>")])
17367
17368 (define_insn_and_split "*avx2_lshr<mode>3_1"
17369 [(set (match_operand:VI8_AVX2 0 "register_operand")
17370 (and:VI8_AVX2
17371 (gt:VI8_AVX2
17372 (match_operand:VI8_AVX2 1 "register_operand")
17373 (match_operand:VI8_AVX2 2 "register_operand"))
17374 (match_operand:VI8_AVX2 3 "const1_operand")))]
17375 "TARGET_SSE4_2 && ix86_pre_reload_split ()"
17376 "#"
17377 "&& 1"
17378 [(set (match_dup 5) (gt:VI8_AVX2 (match_dup 1) (match_dup 2)))
17379 (set (match_dup 0) (lshiftrt:VI8_AVX2 (match_dup 5) (match_dup 4)))]
17380 {
17381 operands[4] = gen_int_mode (<ssescalarsize> - 1, DImode);
17382 operands[5] = gen_reg_rtx (<MODE>mode);
17383 })
17384
17385 (define_insn_and_split "*avx2_lshr<mode>3_2"
17386 [(set (match_operand:VI8_AVX2 0 "register_operand")
17387 (and:VI8_AVX2
17388 (lt:VI8_AVX2
17389 (match_operand:VI8_AVX2 1 "register_operand")
17390 (match_operand:VI8_AVX2 2 "const0_operand"))
17391 (match_operand:VI8_AVX2 3 "const1_operand")))]
17392 "TARGET_SSE2 && ix86_pre_reload_split ()"
17393 "#"
17394 "&& 1"
17395 [(set (match_dup 0) (lshiftrt:VI8_AVX2 (match_dup 1) (const_int 63)))])
17396
17397 (define_split
17398 [(set (match_operand:VI248_AVX2 0 "register_operand")
17399 (and:VI248_AVX2
17400 (lt:VI248_AVX2
17401 (match_operand:VI248_AVX2 1 "register_operand")
17402 (match_operand:VI248_AVX2 2 "const0_operand"))
17403 (match_operand:VI248_AVX2 3 "const1_operand")))]
17404 "TARGET_SSE2 && ix86_pre_reload_split ()"
17405 [(set (match_dup 0) (lshiftrt:VI248_AVX2 (match_dup 1) (match_dup 4)))]
17406 "operands[4] = gen_int_mode (<ssescalarsize> - 1, DImode);")
17407
17408 (define_split
17409 [(set (match_operand:VI248_AVX512VLBW 0 "register_operand")
17410 (vec_merge:VI248_AVX512VLBW
17411 (match_operand:VI248_AVX512VLBW 1 "const1_operand")
17412 (match_operand:VI248_AVX512VLBW 2 "const0_operand")
17413 (unspec:<avx512fmaskmode>
17414 [(match_operand:VI248_AVX512VLBW 3 "nonimmediate_operand")
17415 (match_operand:VI248_AVX512VLBW 4 "const0_operand")
17416 (const_int 1)]
17417 UNSPEC_PCMP)))]
17418 "TARGET_AVX512F && ix86_pre_reload_split ()"
17419 [(set (match_dup 0)
17420 (lshiftrt:VI248_AVX512VLBW (match_dup 3) (match_dup 5)))]
17421 "operands[5] = gen_int_mode (<ssescalarsize> - 1, DImode);")
17422
17423 (define_insn "<insn><mode>3<mask_name>"
17424 [(set (match_operand:VI248_AVX512BW 0 "register_operand" "=v,v")
17425 (any_lshift:VI248_AVX512BW
17426 (match_operand:VI248_AVX512BW 1 "nonimmediate_operand" "v,m")
17427 (match_operand:DI 2 "nonmemory_operand" "vN,N")))]
17428 "TARGET_AVX512F"
17429 "vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
17430 [(set_attr "type" "sseishft")
17431 (set (attr "length_immediate")
17432 (if_then_else (match_operand 2 "const_int_operand")
17433 (const_string "1")
17434 (const_string "0")))
17435 (set_attr "mode" "<sseinsnmode>")])
17436
17437 ;; PR target/101796: Transfrom movl+vpbranchcastw+vpsravw to vpsraw
17438 ;; when COUNT is immediate.
17439 (define_split
17440 [(set (match_operand:VI248_AVX512BW 0 "register_operand")
17441 (any_shift:VI248_AVX512BW
17442 (match_operand:VI248_AVX512BW 1 "nonimmediate_operand")
17443 (match_operand:VI248_AVX512BW 2 "const_vector_duplicate_operand")))]
17444 "TARGET_AVX512F && GET_MODE_UNIT_BITSIZE (<MODE>mode)
17445 > INTVAL (XVECEXP (operands[2], 0, 0))"
17446 [(set (match_dup 0)
17447 (any_shift:VI248_AVX512BW
17448 (match_dup 1)
17449 (match_dup 3)))]
17450 "operands[3] = XVECEXP (operands[2], 0, 0);")
17451
17452 (define_expand "vec_shl_<mode>"
17453 [(set (match_operand:V_128 0 "register_operand")
17454 (ashift:V1TI
17455 (match_operand:V_128 1 "nonimmediate_operand")
17456 (match_operand:SI 2 "const_0_to_255_mul_8_operand")))]
17457 "TARGET_SSE2"
17458 {
17459 rtx op0 = gen_reg_rtx (V1TImode);
17460 rtx op1 = force_reg (<MODE>mode, operands[1]);
17461
17462 emit_insn (gen_sse2_ashlv1ti3
17463 (op0, gen_lowpart (V1TImode, op1), operands[2]));
17464 emit_move_insn (operands[0], gen_lowpart (<MODE>mode, op0));
17465 DONE;
17466 })
17467
17468 (define_expand "vec_shr_<mode>"
17469 [(set (match_operand:V_128 0 "register_operand")
17470 (lshiftrt:V1TI
17471 (match_operand:V_128 1 "nonimmediate_operand")
17472 (match_operand:SI 2 "const_0_to_255_mul_8_operand")))]
17473 "TARGET_SSE2"
17474 {
17475 rtx op0 = gen_reg_rtx (V1TImode);
17476 rtx op1 = force_reg (<MODE>mode, operands[1]);
17477
17478 emit_insn (gen_sse2_lshrv1ti3
17479 (op0, gen_lowpart (V1TImode, op1), operands[2]));
17480 emit_move_insn (operands[0], gen_lowpart (<MODE>mode, op0));
17481 DONE;
17482 })
17483
17484 (define_expand "ashlv1ti3"
17485 [(set (match_operand:V1TI 0 "register_operand")
17486 (ashift:V1TI
17487 (match_operand:V1TI 1 "register_operand")
17488 (match_operand:QI 2 "general_operand")))]
17489 "TARGET_SSE2 && TARGET_64BIT"
17490 {
17491 if (!CONST_INT_P (operands[2]))
17492 {
17493 ix86_expand_v1ti_shift (ASHIFT, operands);
17494 DONE;
17495 }
17496 })
17497
17498 (define_insn_and_split "*ashlv1ti3_internal"
17499 [(set (match_operand:V1TI 0 "register_operand")
17500 (ashift:V1TI
17501 (match_operand:V1TI 1 "register_operand")
17502 (match_operand:SI 2 "const_0_to_255_not_mul_8_operand")))]
17503 "TARGET_SSE2 && TARGET_64BIT
17504 && ix86_pre_reload_split ()"
17505 "#"
17506 "&& 1"
17507 [(const_int 0)]
17508 {
17509 ix86_expand_v1ti_shift (ASHIFT, operands);
17510 DONE;
17511 })
17512
17513 (define_expand "lshrv1ti3"
17514 [(set (match_operand:V1TI 0 "register_operand")
17515 (lshiftrt:V1TI
17516 (match_operand:V1TI 1 "register_operand")
17517 (match_operand:QI 2 "general_operand")))]
17518 "TARGET_SSE2 && TARGET_64BIT"
17519 {
17520 if (!CONST_INT_P (operands[2]))
17521 {
17522 ix86_expand_v1ti_shift (LSHIFTRT, operands);
17523 DONE;
17524 }
17525 })
17526
17527 (define_insn_and_split "*lshrv1ti3_internal"
17528 [(set (match_operand:V1TI 0 "register_operand")
17529 (lshiftrt:V1TI
17530 (match_operand:V1TI 1 "register_operand")
17531 (match_operand:SI 2 "const_0_to_255_not_mul_8_operand")))]
17532 "TARGET_SSE2 && TARGET_64BIT
17533 && ix86_pre_reload_split ()"
17534 "#"
17535 "&& 1"
17536 [(const_int 0)]
17537 {
17538 ix86_expand_v1ti_shift (LSHIFTRT, operands);
17539 DONE;
17540 })
17541
17542 (define_expand "ashrv1ti3"
17543 [(set (match_operand:V1TI 0 "register_operand")
17544 (ashiftrt:V1TI
17545 (match_operand:V1TI 1 "register_operand")
17546 (match_operand:QI 2 "general_operand")))]
17547 "TARGET_SSE2 && TARGET_64BIT"
17548 {
17549 if (!CONST_INT_P (operands[2]))
17550 {
17551 ix86_expand_v1ti_ashiftrt (operands);
17552 DONE;
17553 }
17554 })
17555
17556
17557 (define_insn_and_split "*ashrv1ti3_internal"
17558 [(set (match_operand:V1TI 0 "register_operand")
17559 (ashiftrt:V1TI
17560 (match_operand:V1TI 1 "register_operand")
17561 (match_operand:SI 2 "const_0_to_255_operand")))]
17562 "TARGET_SSE2 && TARGET_64BIT
17563 && ix86_pre_reload_split ()"
17564 "#"
17565 "&& 1"
17566 [(const_int 0)]
17567 {
17568 ix86_expand_v1ti_ashiftrt (operands);
17569 DONE;
17570 })
17571
17572 (define_split
17573 [(set (match_operand:VI248_AVX2 0 "register_operand")
17574 (eq:VI248_AVX2
17575 (eq:VI248_AVX2
17576 (lshiftrt:VI248_AVX2
17577 (match_operand:VI248_AVX2 1 "register_operand")
17578 (match_operand:SI 2 "const_int_operand"))
17579 (match_operand:VI248_AVX2 3 "const0_operand"))
17580 (match_operand:VI248_AVX2 4 "const0_operand")))]
17581 "INTVAL (operands[2]) == GET_MODE_PRECISION (<ssescalarmode>mode) - 1"
17582 [(set (match_dup 0) (ashiftrt:VI248_AVX2 (match_dup 1) (match_dup 2)))])
17583
17584 (define_expand "rotlv1ti3"
17585 [(set (match_operand:V1TI 0 "register_operand")
17586 (rotate:V1TI
17587 (match_operand:V1TI 1 "register_operand")
17588 (match_operand:QI 2 "general_operand")))]
17589 "TARGET_SSE2 && TARGET_64BIT"
17590 {
17591 if (!CONST_INT_P (operands[2]))
17592 {
17593 ix86_expand_v1ti_rotate (ROTATE, operands);
17594 DONE;
17595 }
17596 })
17597
17598 (define_insn_and_split "*rotlv1ti3_internal"
17599 [(set (match_operand:V1TI 0 "register_operand")
17600 (rotate:V1TI
17601 (match_operand:V1TI 1 "register_operand")
17602 (match_operand:SI 2 "const_0_to_255_operand")))]
17603 "TARGET_SSE2 && TARGET_64BIT
17604 && ix86_pre_reload_split ()"
17605 "#"
17606 "&& 1"
17607 [(const_int 0)]
17608 {
17609 ix86_expand_v1ti_rotate (ROTATE, operands);
17610 DONE;
17611 })
17612
17613 (define_expand "rotrv1ti3"
17614 [(set (match_operand:V1TI 0 "register_operand")
17615 (rotatert:V1TI
17616 (match_operand:V1TI 1 "register_operand")
17617 (match_operand:QI 2 "general_operand")))]
17618 "TARGET_SSE2 && TARGET_64BIT"
17619 {
17620 if (!CONST_INT_P (operands[2]))
17621 {
17622 ix86_expand_v1ti_rotate (ROTATERT, operands);
17623 DONE;
17624 }
17625 })
17626
17627 (define_insn_and_split "*rotrv1ti3_internal"
17628 [(set (match_operand:V1TI 0 "register_operand")
17629 (rotatert:V1TI
17630 (match_operand:V1TI 1 "register_operand")
17631 (match_operand:SI 2 "const_0_to_255_operand")))]
17632 "TARGET_SSE2 && TARGET_64BIT
17633 && ix86_pre_reload_split ()"
17634 "#"
17635 "&& 1"
17636 [(const_int 0)]
17637 {
17638 ix86_expand_v1ti_rotate (ROTATERT, operands);
17639 DONE;
17640 })
17641
17642 (define_insn "avx512bw_<insn><mode>3"
17643 [(set (match_operand:VIMAX_AVX512VL 0 "register_operand" "=v")
17644 (any_lshift:VIMAX_AVX512VL
17645 (match_operand:VIMAX_AVX512VL 1 "nonimmediate_operand" "vm")
17646 (match_operand:SI 2 "const_0_to_255_mul_8_operand")))]
17647 "TARGET_AVX512BW"
17648 {
17649 operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
17650 return "vp<vshift>dq\t{%2, %1, %0|%0, %1, %2}";
17651 }
17652 [(set_attr "type" "sseishft")
17653 (set_attr "length_immediate" "1")
17654 (set_attr "prefix" "maybe_evex")
17655 (set_attr "mode" "<sseinsnmode>")])
17656
17657 (define_insn "<sse2_avx2>_<insn><mode>3"
17658 [(set (match_operand:VIMAX_AVX2 0 "register_operand" "=x,Yw")
17659 (any_lshift:VIMAX_AVX2
17660 (match_operand:VIMAX_AVX2 1 "register_operand" "0,Yw")
17661 (match_operand:SI 2 "const_0_to_255_mul_8_operand")))]
17662 "TARGET_SSE2"
17663 {
17664 operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
17665
17666 switch (which_alternative)
17667 {
17668 case 0:
17669 return "p<vshift>dq\t{%2, %0|%0, %2}";
17670 case 1:
17671 return "vp<vshift>dq\t{%2, %1, %0|%0, %1, %2}";
17672 default:
17673 gcc_unreachable ();
17674 }
17675 }
17676 [(set_attr "isa" "noavx,avx")
17677 (set_attr "type" "sseishft")
17678 (set_attr "length_immediate" "1")
17679 (set_attr "atom_unit" "sishuf")
17680 (set_attr "prefix_data16" "1,*")
17681 (set_attr "prefix" "orig,vex")
17682 (set_attr "mode" "<sseinsnmode>")])
17683
17684 (define_insn "<avx512>_<rotate>v<mode><mask_name>"
17685 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
17686 (any_rotate:VI48_AVX512VL
17687 (match_operand:VI48_AVX512VL 1 "register_operand" "v")
17688 (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")))]
17689 "TARGET_AVX512F"
17690 "vp<rotate>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
17691 [(set_attr "prefix" "evex")
17692 (set_attr "mode" "<sseinsnmode>")])
17693
17694 (define_insn "<avx512>_<rotate><mode><mask_name>"
17695 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
17696 (any_rotate:VI48_AVX512VL
17697 (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")
17698 (match_operand:SI 2 "const_0_to_255_operand")))]
17699 "TARGET_AVX512F"
17700 "vp<rotate><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
17701 [(set_attr "prefix" "evex")
17702 (set_attr "mode" "<sseinsnmode>")])
17703
17704 (define_expand "<code><mode>3"
17705 [(set (match_operand:VI124_256_AVX512F_AVX512BW 0 "register_operand")
17706 (maxmin:VI124_256_AVX512F_AVX512BW
17707 (match_operand:VI124_256_AVX512F_AVX512BW 1 "nonimmediate_operand")
17708 (match_operand:VI124_256_AVX512F_AVX512BW 2 "nonimmediate_operand")))]
17709 "TARGET_AVX2"
17710 "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
17711
17712 (define_insn "*avx2_<code><mode>3"
17713 [(set (match_operand:VI124_256 0 "register_operand" "=<v_Yw>")
17714 (maxmin:VI124_256
17715 (match_operand:VI124_256 1 "nonimmediate_operand" "%<v_Yw>")
17716 (match_operand:VI124_256 2 "nonimmediate_operand" "<v_Yw>m")))]
17717 "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17718 "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17719 [(set_attr "type" "sseiadd")
17720 (set_attr "c86_attr" "maxmin")
17721 (set_attr "prefix_extra" "1")
17722 (set_attr "prefix" "vex")
17723 (set_attr "mode" "OI")])
17724
17725 (define_expand "cond_<code><mode>"
17726 [(set (match_operand:VI1248_AVX512VLBW 0 "register_operand")
17727 (vec_merge:VI1248_AVX512VLBW
17728 (maxmin:VI1248_AVX512VLBW
17729 (match_operand:VI1248_AVX512VLBW 2 "nonimmediate_operand")
17730 (match_operand:VI1248_AVX512VLBW 3 "nonimmediate_operand"))
17731 (match_operand:VI1248_AVX512VLBW 4 "nonimm_or_0_operand")
17732 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
17733 "TARGET_AVX512F"
17734 {
17735 emit_insn (gen_<code><mode>3_mask (operands[0],
17736 operands[2],
17737 operands[3],
17738 operands[4],
17739 operands[1]));
17740 DONE;
17741 })
17742
17743 (define_expand "<code><mode>3_mask"
17744 [(set (match_operand:VI1248_AVX512VLBW 0 "register_operand")
17745 (vec_merge:VI1248_AVX512VLBW
17746 (maxmin:VI1248_AVX512VLBW
17747 (match_operand:VI1248_AVX512VLBW 1 "nonimmediate_operand")
17748 (match_operand:VI1248_AVX512VLBW 2 "nonimmediate_operand"))
17749 (match_operand:VI1248_AVX512VLBW 3 "nonimm_or_0_operand")
17750 (match_operand:<avx512fmaskmode> 4 "register_operand")))]
17751 "TARGET_AVX512F"
17752 "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
17753
17754 (define_insn "*avx512f_<code><mode>3<mask_name>"
17755 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
17756 (maxmin:VI48_AVX512VL
17757 (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "%v")
17758 (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")))]
17759 "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17760 "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
17761 [(set_attr "type" "sseiadd")
17762 (set_attr "c86_attr" "maxmin")
17763 (set_attr "prefix" "maybe_evex")
17764 (set_attr "mode" "<sseinsnmode>")])
17765
17766 (define_insn "*avx512bw_<code><mode>3<mask_name>"
17767 [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
17768 (maxmin:VI12_AVX512VL
17769 (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "%v")
17770 (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")))]
17771 "TARGET_AVX512BW && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17772 "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
17773 [(set_attr "type" "sseiadd")
17774 (set_attr "c86_attr" "maxmin")
17775 (set_attr "prefix" "evex")
17776 (set_attr "mode" "<sseinsnmode>")])
17777
17778 (define_expand "<code><mode>3"
17779 [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand")
17780 (maxmin:VI8_AVX2_AVX512F
17781 (match_operand:VI8_AVX2_AVX512F 1 "register_operand")
17782 (match_operand:VI8_AVX2_AVX512F 2 "register_operand")))]
17783 "TARGET_SSE4_2"
17784 {
17785 if (TARGET_AVX512F
17786 && (<MODE>mode == V8DImode || TARGET_AVX512VL))
17787 ;
17788 else
17789 {
17790 enum rtx_code code;
17791 rtx xops[6];
17792 bool ok;
17793
17794
17795 xops[0] = operands[0];
17796
17797 if (<CODE> == SMAX || <CODE> == UMAX)
17798 {
17799 xops[1] = operands[1];
17800 xops[2] = operands[2];
17801 }
17802 else
17803 {
17804 xops[1] = operands[2];
17805 xops[2] = operands[1];
17806 }
17807
17808 code = (<CODE> == UMAX || <CODE> == UMIN) ? GTU : GT;
17809
17810 xops[3] = gen_rtx_fmt_ee (code, VOIDmode, operands[1], operands[2]);
17811 xops[4] = operands[1];
17812 xops[5] = operands[2];
17813
17814 ok = ix86_expand_int_vcond (xops);
17815 gcc_assert (ok);
17816 DONE;
17817 }
17818 })
17819
17820 (define_expand "<code><mode>3"
17821 [(set (match_operand:VI124_128 0 "register_operand")
17822 (smaxmin:VI124_128
17823 (match_operand:VI124_128 1 "vector_operand")
17824 (match_operand:VI124_128 2 "vector_operand")))]
17825 "TARGET_SSE2"
17826 {
17827 if (TARGET_SSE4_1 || <MODE>mode == V8HImode)
17828 ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
17829 else
17830 {
17831 rtx xops[6];
17832 bool ok;
17833
17834 xops[0] = operands[0];
17835 operands[1] = force_reg (<MODE>mode, operands[1]);
17836 operands[2] = force_reg (<MODE>mode, operands[2]);
17837
17838 if (<CODE> == SMAX)
17839 {
17840 xops[1] = operands[1];
17841 xops[2] = operands[2];
17842 }
17843 else
17844 {
17845 xops[1] = operands[2];
17846 xops[2] = operands[1];
17847 }
17848
17849 xops[3] = gen_rtx_GT (VOIDmode, operands[1], operands[2]);
17850 xops[4] = operands[1];
17851 xops[5] = operands[2];
17852
17853 ok = ix86_expand_int_vcond (xops);
17854 gcc_assert (ok);
17855 DONE;
17856 }
17857 })
17858
17859 (define_insn "*sse4_1_<code><mode>3<mask_name>"
17860 [(set (match_operand:VI14_128 0 "register_operand" "=Yr,*x,<v_Yw>")
17861 (smaxmin:VI14_128
17862 (match_operand:VI14_128 1 "vector_operand" "%0,0,<v_Yw>")
17863 (match_operand:VI14_128 2 "vector_operand" "Yrja,*xja,<v_Yw>m")))]
17864 "TARGET_SSE4_1
17865 && <mask_mode512bit_condition>
17866 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17867 "@
17868 p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
17869 p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
17870 vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
17871 [(set_attr "isa" "noavx,noavx,avx")
17872 (set_attr "type" "sseiadd")
17873 (set_attr "c86_attr" "maxmin")
17874 (set_attr "prefix_extra" "1")
17875 (set_attr "addr" "gpr16,gpr16,*")
17876 (set_attr "prefix" "orig,orig,vex")
17877 (set_attr "mode" "TI")])
17878
17879 (define_insn "*<code>v8hi3"
17880 [(set (match_operand:V8HI 0 "register_operand" "=x,Yw")
17881 (smaxmin:V8HI
17882 (match_operand:V8HI 1 "vector_operand" "%0,Yw")
17883 (match_operand:V8HI 2 "vector_operand" "xja,Ywm")))]
17884 "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17885 "@
17886 p<maxmin_int>w\t{%2, %0|%0, %2}
17887 vp<maxmin_int>w\t{%2, %1, %0|%0, %1, %2}"
17888 [(set_attr "isa" "noavx,avx")
17889 (set_attr "type" "sseiadd")
17890 (set_attr "c86_attr" "maxmin")
17891 (set_attr "addr" "gpr16,*")
17892 (set_attr "prefix" "orig,vex")
17893 (set_attr "mode" "TI")])
17894
17895 (define_expand "<code><mode>3"
17896 [(set (match_operand:VI124_128 0 "register_operand")
17897 (umaxmin:VI124_128
17898 (match_operand:VI124_128 1 "vector_operand")
17899 (match_operand:VI124_128 2 "vector_operand")))]
17900 "TARGET_SSE2"
17901 {
17902 if (TARGET_SSE4_1 || <MODE>mode == V16QImode)
17903 ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
17904 else if (<CODE> == UMAX && <MODE>mode == V8HImode)
17905 {
17906 rtx op0 = operands[0], op2 = operands[2], op3 = op0;
17907 operands[1] = force_reg (<MODE>mode, operands[1]);
17908 if (rtx_equal_p (op3, op2))
17909 op3 = gen_reg_rtx (V8HImode);
17910 emit_insn (gen_ussubv8hi3 (op3, operands[1], op2));
17911 emit_insn (gen_addv8hi3 (op0, op3, op2));
17912 DONE;
17913 }
17914 else
17915 {
17916 rtx xops[6];
17917 bool ok;
17918
17919 operands[1] = force_reg (<MODE>mode, operands[1]);
17920 operands[2] = force_reg (<MODE>mode, operands[2]);
17921
17922 xops[0] = operands[0];
17923
17924 if (<CODE> == UMAX)
17925 {
17926 xops[1] = operands[1];
17927 xops[2] = operands[2];
17928 }
17929 else
17930 {
17931 xops[1] = operands[2];
17932 xops[2] = operands[1];
17933 }
17934
17935 xops[3] = gen_rtx_GTU (VOIDmode, operands[1], operands[2]);
17936 xops[4] = operands[1];
17937 xops[5] = operands[2];
17938
17939 ok = ix86_expand_int_vcond (xops);
17940 gcc_assert (ok);
17941 DONE;
17942 }
17943 })
17944
17945 (define_insn "*sse4_1_<code><mode>3<mask_name>"
17946 [(set (match_operand:VI24_128 0 "register_operand" "=Yr,*x,<v_Yw>")
17947 (umaxmin:VI24_128
17948 (match_operand:VI24_128 1 "vector_operand" "%0,0,<v_Yw>")
17949 (match_operand:VI24_128 2 "vector_operand" "Yrja,*xja,<v_Yw>m")))]
17950 "TARGET_SSE4_1
17951 && <mask_mode512bit_condition>
17952 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17953 "@
17954 p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
17955 p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
17956 vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
17957 [(set_attr "isa" "noavx,noavx,avx")
17958 (set_attr "type" "sseiadd")
17959 (set_attr "c86_attr" "maxmin")
17960 (set_attr "addr" "gpr16,gpr16,*")
17961 (set_attr "prefix_extra" "1,1,*")
17962 (set_attr "prefix" "orig,orig,vex")
17963 (set_attr "mode" "TI")])
17964
17965 (define_insn "*<code>v16qi3"
17966 [(set (match_operand:V16QI 0 "register_operand" "=x,Yw")
17967 (umaxmin:V16QI
17968 (match_operand:V16QI 1 "vector_operand" "%0,Yw")
17969 (match_operand:V16QI 2 "vector_operand" "xja,Ywm")))]
17970 "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17971 "@
17972 p<maxmin_int>b\t{%2, %0|%0, %2}
17973 vp<maxmin_int>b\t{%2, %1, %0|%0, %1, %2}"
17974 [(set_attr "isa" "noavx,avx")
17975 (set_attr "addr" "gpr16,*")
17976 (set_attr "type" "sseiadd")
17977 (set_attr "c86_attr" "maxmin")
17978 (set_attr "prefix" "orig,vex")
17979 (set_attr "mode" "TI")])
17980
17981 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17982 ;;
17983 ;; Parallel integral comparisons
17984 ;;
17985 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17986
17987 (define_insn "*avx2_eq<mode>3"
17988 [(set (match_operand:VI_256 0 "register_operand" "=x")
17989 (eq:VI_256
17990 (match_operand:VI_256 1 "nonimmediate_operand" "%x")
17991 (match_operand:VI_256 2 "nonimmediate_operand" "xjm")))]
17992 "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17993 "vpcmpeq<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17994 [(set_attr "type" "ssecmp")
17995 (set (attr "prefix_extra")
17996 (if_then_else (eq (const_string "<MODE>mode") (const_string "V4DImode"))
17997 (const_string "1")
17998 (const_string "*")))
17999 (set_attr "addr" "gpr16")
18000 (set_attr "prefix" "vex")
18001 (set_attr "mode" "OI")])
18002
18003 (define_insn_and_split "*avx2_pcmp<mode>3_1"
18004 [(set (match_operand:VI_128_256 0 "register_operand")
18005 (vec_merge:VI_128_256
18006 (match_operand:VI_128_256 1 "vector_all_ones_operand")
18007 (match_operand:VI_128_256 2 "const0_operand")
18008 (unspec:<avx512fmaskmode>
18009 [(match_operand:VI_128_256 3 "nonimm_or_0_operand")
18010 (match_operand:VI_128_256 4 "nonimm_or_0_operand")
18011 (match_operand:SI 5 "const_0_to_7_operand")]
18012 UNSPEC_PCMP)))]
18013 "TARGET_AVX512VL && ix86_pre_reload_split ()
18014 /* EQ is commutative. */
18015 && ((INTVAL (operands[5]) == 0
18016 && !(MEM_P (operands[3]) && MEM_P (operands[4])))
18017 /* NLE aka GT, 3 must be register. */
18018 || (INTVAL (operands[5]) == 6
18019 && !MEM_P (operands[3]))
18020 /* LT, 4 must be register and we swap operands. */
18021 || (INTVAL (operands[5]) == 1
18022 && !MEM_P (operands[4])))"
18023 "#"
18024 "&& 1"
18025 [(const_int 0)]
18026 {
18027 if (INTVAL (operands[5]) == 1)
18028 std::swap (operands[3], operands[4]);
18029
18030 if (operands[3] == CONST0_RTX (<MODE>mode))
18031 operands[3] = force_reg (<MODE>mode, operands[3]);
18032 if (operands[4] == CONST0_RTX (<MODE>mode))
18033 operands[4] = force_reg (<MODE>mode, operands[4]);
18034
18035 enum rtx_code code = INTVAL (operands[5]) ? GT : EQ;
18036 emit_move_insn (operands[0], gen_rtx_fmt_ee (code, <MODE>mode,
18037 operands[3], operands[4]));
18038 DONE;
18039 })
18040
18041 (define_insn_and_split "*avx2_pcmp<mode>3_2"
18042 [(set (match_operand:VI_128_256 0 "register_operand")
18043 (vec_merge:VI_128_256
18044 (match_operand:VI_128_256 1 "vector_all_ones_operand")
18045 (match_operand:VI_128_256 2 "const0_operand")
18046 (not:<avx512fmaskmode>
18047 (unspec:<avx512fmaskmode>
18048 [(match_operand:VI_128_256 3 "nonimmediate_operand")
18049 (match_operand:VI_128_256 4 "nonimmediate_operand")
18050 (match_operand:SI 5 "const_0_to_7_operand")]
18051 UNSPEC_PCMP))))]
18052 "TARGET_AVX512VL && ix86_pre_reload_split ()
18053 /* NE is commutative. */
18054 && ((INTVAL (operands[5]) == 4
18055 && !(MEM_P (operands[3]) && MEM_P (operands[4])))
18056 /* LE, 3 must be register. */
18057 || (INTVAL (operands[5]) == 2
18058 && !MEM_P (operands[3]))
18059 /* NLT aka GE, 4 must be register and we swap operands. */
18060 || (INTVAL (operands[5]) == 5
18061 && !MEM_P (operands[4])))"
18062 "#"
18063 "&& 1"
18064 [(const_int 0)]
18065 {
18066 if (INTVAL (operands[5]) == 5)
18067 std::swap (operands[3], operands[4]);
18068 enum rtx_code code = INTVAL (operands[5]) != 4 ? GT : EQ;
18069 emit_move_insn (operands[0], gen_rtx_fmt_ee (code, <MODE>mode,
18070 operands[3], operands[4]));
18071 DONE;
18072 })
18073
18074 (define_insn_and_split "*avx2_pcmp<mode>3_3"
18075 [(set (match_operand:VI1_AVX2 0 "register_operand")
18076 (vec_merge:VI1_AVX2
18077 (match_operand:VI1_AVX2 1 "vector_operand")
18078 (match_operand:VI1_AVX2 2 "vector_operand")
18079 (unspec:<avx512fmaskmode>
18080 [(match_operand:VI1_AVX2 3 "register_operand")
18081 (match_operand:VI1_AVX2 4 "const0_operand")
18082 (match_operand:SI 5 "const_0_to_7_operand")]
18083 UNSPEC_PCMP)))]
18084 "TARGET_AVX512VL && ix86_pre_reload_split ()
18085 /* LT or GE 0 */
18086 && ((INTVAL (operands[5]) == 1 && !MEM_P (operands[2]))
18087 || (INTVAL (operands[5]) == 5 && !MEM_P (operands[1])))"
18088 "#"
18089 "&& 1"
18090 [(set (match_dup 0)
18091 (unspec:VI1_AVX2
18092 [(match_dup 2)
18093 (match_dup 1)
18094 (lt:VI1_AVX2
18095 (match_dup 3)
18096 (match_dup 4))]
18097 UNSPEC_BLENDV))]
18098 {
18099 if (INTVAL (operands[5]) == 5)
18100 std::swap (operands[1], operands[2]);
18101 })
18102
18103 (define_insn_and_split "*avx2_pcmp<mode>3_4"
18104 [(set (match_operand:VI1_AVX2 0 "register_operand")
18105 (vec_merge:VI1_AVX2
18106 (match_operand:VI1_AVX2 1 "vector_operand")
18107 (match_operand:VI1_AVX2 2 "vector_operand")
18108 (unspec:<avx512fmaskmode>
18109 [(subreg:VI1_AVX2 (not (match_operand 3 "register_operand")) 0)
18110 (match_operand:VI1_AVX2 4 "const0_operand")
18111 (match_operand:SI 5 "const_0_to_7_operand")]
18112 UNSPEC_PCMP)))]
18113 "TARGET_AVX512VL && ix86_pre_reload_split ()
18114 && GET_MODE_CLASS (GET_MODE (operands[3])) == MODE_VECTOR_INT
18115 && GET_MODE_SIZE (GET_MODE (operands[3])) == <MODE_SIZE>
18116 /* LT or GE 0 */
18117 && ((INTVAL (operands[5]) == 1 && !MEM_P (operands[1]))
18118 || (INTVAL (operands[5]) == 5 && !MEM_P (operands[2])))"
18119 "#"
18120 "&& 1"
18121 [(set (match_dup 0)
18122 (unspec:VI1_AVX2
18123 [(match_dup 1)
18124 (match_dup 2)
18125 (lt:VI1_AVX2
18126 (match_dup 3)
18127 (match_dup 4))]
18128 UNSPEC_BLENDV))]
18129 {
18130 if (INTVAL (operands[5]) == 5)
18131 std::swap (operands[1], operands[2]);
18132 operands[3] = gen_lowpart (<MODE>mode, operands[3]);
18133 })
18134
18135 (define_insn_and_split "*avx2_pcmp<mode>3_5"
18136 [(set (match_operand:VI1_AVX2 0 "register_operand")
18137 (vec_merge:VI1_AVX2
18138 (match_operand:VI1_AVX2 1 "vector_operand")
18139 (match_operand:VI1_AVX2 2 "vector_operand")
18140 (unspec:<avx512fmaskmode>
18141 [(not:VI1_AVX2 (match_operand:VI1_AVX2 3 "register_operand"))
18142 (match_operand:VI1_AVX2 4 "const0_operand")
18143 (match_operand:SI 5 "const_0_to_7_operand")]
18144 UNSPEC_PCMP)))]
18145 "TARGET_AVX512VL && ix86_pre_reload_split ()
18146 /* LT or GE 0 */
18147 && ((INTVAL (operands[5]) == 1 && !MEM_P (operands[1]))
18148 || (INTVAL (operands[5]) == 5 && !MEM_P (operands[2])))"
18149 "#"
18150 "&& 1"
18151 [(set (match_dup 0)
18152 (unspec:VI1_AVX2
18153 [(match_dup 1)
18154 (match_dup 2)
18155 (lt:VI1_AVX2
18156 (match_dup 3)
18157 (match_dup 4))]
18158 UNSPEC_BLENDV))]
18159 {
18160 if (INTVAL (operands[5]) == 5)
18161 std::swap (operands[1], operands[2]);
18162 })
18163
18164 (define_int_attr pcmp_usmin
18165 [(UNSPEC_PCMP "smin") (UNSPEC_UNSIGNED_PCMP "umin")])
18166
18167 (define_insn_and_split "*avx2_pcmp<mode>3_6"
18168 [(set (match_operand:VI_128_256 0 "register_operand")
18169 (vec_merge:VI_128_256
18170 (match_operand:VI_128_256 1 "vector_all_ones_operand")
18171 (match_operand:VI_128_256 2 "const0_operand")
18172 (unspec:<avx512fmaskmode>
18173 [(match_operand:VI_128_256 3 "nonimmediate_operand")
18174 (match_operand:VI_128_256 4 "nonimmediate_operand")
18175 (match_operand:SI 5 "const_0_to_7_operand")]
18176 UNSPEC_PCMP_ITER)))]
18177 "TARGET_AVX512VL && ix86_pre_reload_split ()
18178 && (INTVAL (operands[5]) == 2 || INTVAL (operands[5]) == 5)"
18179 "#"
18180 "&& 1"
18181 [(const_int 0)]
18182 {
18183 rtx dst_min = gen_reg_rtx (<MODE>mode);
18184
18185 if (MEM_P (operands[3]) && MEM_P (operands[4]))
18186 operands[3] = force_reg (<MODE>mode, operands[3]);
18187 emit_insn (gen_<pcmp_usmin><mode>3 (dst_min, operands[3], operands[4]));
18188 rtx eq_op = INTVAL (operands[5]) == 2 ? operands[3] : operands[4];
18189 emit_move_insn (operands[0], gen_rtx_EQ (<MODE>mode, eq_op, dst_min));
18190 DONE;
18191 })
18192
18193 (define_insn_and_split "*avx2_pcmp<mode>3_7"
18194 [(set (match_operand:VI_128_256 0 "register_operand")
18195 (vec_merge:VI_128_256
18196 (match_operand:VI_128_256 1 "const0_operand")
18197 (match_operand:VI_128_256 2 "vector_all_ones_operand")
18198 (unspec:<avx512fmaskmode>
18199 [(match_operand:VI_128_256 3 "nonimmediate_operand")
18200 (match_operand:VI_128_256 4 "nonimmediate_operand")
18201 (match_operand:SI 5 "const_0_to_7_operand")]
18202 UNSPEC_PCMP)))]
18203 "TARGET_AVX512VL && ix86_pre_reload_split ()
18204 /* NE is commutative. */
18205 && (INTVAL (operands[5]) == 4
18206 /* LE, 3 must be register. */
18207 || INTVAL (operands[5]) == 2
18208 /* NLT aka GE, 4 must be register and we swap operands. */
18209 || INTVAL (operands[5]) == 5)"
18210 "#"
18211 "&& 1"
18212 [(const_int 0)]
18213 {
18214 if (INTVAL (operands[5]) == 5)
18215 std::swap (operands[3], operands[4]);
18216
18217 if (MEM_P (operands[3]))
18218 operands[3] = force_reg (<MODE>mode, operands[3]);
18219 enum rtx_code code = INTVAL (operands[5]) != 4 ? GT : EQ;
18220 emit_move_insn (operands[0], gen_rtx_fmt_ee (code, <MODE>mode,
18221 operands[3], operands[4]));
18222 DONE;
18223 })
18224
18225 (define_insn_and_split "*avx2_pcmp<mode>3_8"
18226 [(set (match_operand:VI_128_256 0 "register_operand")
18227 (vec_merge:VI_128_256
18228 (match_operand:VI_128_256 1 "const0_operand")
18229 (match_operand:VI_128_256 2 "vector_all_ones_operand")
18230 (unspec:<avx512fmaskmode>
18231 [(match_operand:VI_128_256 3 "nonimmediate_operand")
18232 (match_operand:VI_128_256 4 "nonimmediate_operand")
18233 (match_operand:SI 5 "const_0_to_7_operand")]
18234 UNSPEC_UNSIGNED_PCMP)))]
18235 "TARGET_AVX512VL && ix86_pre_reload_split ()
18236 /* NE is commutative. */
18237 && INTVAL (operands[5]) == 4"
18238
18239 "#"
18240 "&& 1"
18241 [(const_int 0)]
18242 {
18243 if (MEM_P (operands[3]))
18244 operands[3] = force_reg (<MODE>mode, operands[3]);
18245 emit_move_insn (operands[0], gen_rtx_fmt_ee (EQ, <MODE>mode,
18246 operands[3], operands[4]));
18247 DONE;
18248 })
18249
18250 (define_expand "<avx512>_eq<mode>3<mask_scalar_merge_name>"
18251 [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
18252 (unspec:<avx512fmaskmode>
18253 [(match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
18254 (match_operand:VI12_AVX512VL 2 "nonimmediate_operand")
18255 (const_int 0)]
18256 UNSPEC_PCMP))]
18257 "TARGET_AVX512BW"
18258 "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
18259
18260 (define_expand "<avx512>_eq<mode>3<mask_scalar_merge_name>"
18261 [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
18262 (unspec:<avx512fmaskmode>
18263 [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
18264 (match_operand:VI48_AVX512VL 2 "nonimmediate_operand")
18265 (const_int 0)]
18266 UNSPEC_PCMP))]
18267 "TARGET_AVX512F"
18268 "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
18269
18270 (define_insn "*sse4_1_eqv2di3"
18271 [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,x")
18272 (eq:V2DI
18273 (match_operand:V2DI 1 "vector_operand" "%0,0,x")
18274 (match_operand:V2DI 2 "vector_operand" "Yrja,*xja,xjm")))]
18275 "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
18276 "@
18277 pcmpeqq\t{%2, %0|%0, %2}
18278 pcmpeqq\t{%2, %0|%0, %2}
18279 vpcmpeqq\t{%2, %1, %0|%0, %1, %2}"
18280 [(set_attr "isa" "noavx,noavx,avx")
18281 (set_attr "type" "ssecmp")
18282 (set_attr "addr" "gpr16")
18283 (set_attr "prefix_extra" "1")
18284 (set_attr "prefix" "orig,orig,vex")
18285 (set_attr "mode" "TI")])
18286
18287 (define_insn "*sse2_eq<mode>3"
18288 [(set (match_operand:VI124_128 0 "register_operand" "=x,x")
18289 (eq:VI124_128
18290 (match_operand:VI124_128 1 "vector_operand" "%0,x")
18291 (match_operand:VI124_128 2 "vector_operand" "xBm,xjm")))]
18292 "TARGET_SSE2
18293 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
18294 "@
18295 pcmpeq<ssemodesuffix>\t{%2, %0|%0, %2}
18296 vpcmpeq<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
18297 [(set_attr "isa" "noavx,avx")
18298 (set_attr "addr" "*,gpr16")
18299 (set_attr "type" "ssecmp")
18300 (set_attr "prefix" "orig,vex")
18301 (set_attr "mode" "TI")])
18302
18303 (define_insn "sse4_2_gtv2di3"
18304 [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,x")
18305 (gt:V2DI
18306 (match_operand:V2DI 1 "register_operand" "0,0,x")
18307 (match_operand:V2DI 2 "vector_operand" "Yrja,*xja,xjm")))]
18308 "TARGET_SSE4_2"
18309 "@
18310 pcmpgtq\t{%2, %0|%0, %2}
18311 pcmpgtq\t{%2, %0|%0, %2}
18312 vpcmpgtq\t{%2, %1, %0|%0, %1, %2}"
18313 [(set_attr "isa" "noavx,noavx,avx")
18314 (set_attr "type" "ssecmp")
18315 (set_attr "addr" "gpr16")
18316 (set_attr "prefix_extra" "1")
18317 (set_attr "prefix" "orig,orig,vex")
18318 (set_attr "mode" "TI")])
18319
18320 (define_insn "avx2_gt<mode>3"
18321 [(set (match_operand:VI_256 0 "register_operand" "=x")
18322 (gt:VI_256
18323 (match_operand:VI_256 1 "register_operand" "x")
18324 (match_operand:VI_256 2 "nonimmediate_operand" "xjm")))]
18325 "TARGET_AVX2"
18326 "vpcmpgt<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
18327 [(set_attr "type" "ssecmp")
18328 (set (attr "prefix_extra")
18329 (if_then_else (eq (const_string "<MODE>mode") (const_string "V4DImode"))
18330 (const_string "1")
18331 (const_string "*")))
18332 (set_attr "addr" "gpr16")
18333 (set_attr "prefix" "vex")
18334 (set_attr "mode" "OI")])
18335
18336 (define_expand "<avx512>_gt<mode>3<mask_scalar_merge_name>"
18337 [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
18338 (unspec:<avx512fmaskmode>
18339 [(match_operand:VI48_AVX512VL 1 "register_operand")
18340 (match_operand:VI48_AVX512VL 2 "nonimmediate_operand")
18341 (const_int 6)] UNSPEC_PCMP))]
18342 "TARGET_AVX512F")
18343
18344 (define_expand "<avx512>_gt<mode>3<mask_scalar_merge_name>"
18345 [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
18346 (unspec:<avx512fmaskmode>
18347 [(match_operand:VI12_AVX512VL 1 "register_operand")
18348 (match_operand:VI12_AVX512VL 2 "nonimmediate_operand")
18349 (const_int 6)] UNSPEC_PCMP))]
18350 "TARGET_AVX512BW")
18351
18352 (define_insn "*sse2_gt<mode>3"
18353 [(set (match_operand:VI124_128 0 "register_operand" "=x,x")
18354 (gt:VI124_128
18355 (match_operand:VI124_128 1 "register_operand" "0,x")
18356 (match_operand:VI124_128 2 "vector_operand" "xBm,xjm")))]
18357 "TARGET_SSE2"
18358 "@
18359 pcmpgt<ssemodesuffix>\t{%2, %0|%0, %2}
18360 vpcmpgt<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
18361 [(set_attr "isa" "noavx,avx")
18362 (set_attr "addr" "*,gpr16")
18363 (set_attr "type" "ssecmp")
18364 (set_attr "prefix" "orig,vex")
18365 (set_attr "mode" "TI")])
18366
18367 (define_mode_iterator VEC_PERM_AVX2
18368 [V16QI V8HI V4SI V2DI V4SF V2DF
18369 (V8HF "TARGET_AVX512FP16")
18370 (V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
18371 (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")
18372 (V8SF "TARGET_AVX2") (V4DF "TARGET_AVX2")
18373 (V16HF "TARGET_AVX512FP16")
18374 (V16SF "TARGET_AVX512F && TARGET_EVEX512")
18375 (V8DF "TARGET_AVX512F && TARGET_EVEX512")
18376 (V16SI "TARGET_AVX512F && TARGET_EVEX512")
18377 (V8DI "TARGET_AVX512F && TARGET_EVEX512")
18378 (V32HI "TARGET_AVX512BW && TARGET_EVEX512")
18379 (V64QI "TARGET_AVX512VBMI && TARGET_EVEX512")
18380 (V32HF "TARGET_AVX512FP16 && TARGET_EVEX512")])
18381
18382 (define_expand "vec_perm<mode>"
18383 [(match_operand:VEC_PERM_AVX2 0 "register_operand")
18384 (match_operand:VEC_PERM_AVX2 1 "register_operand")
18385 (match_operand:VEC_PERM_AVX2 2 "register_operand")
18386 (match_operand:<sseintvecmode> 3 "register_operand")]
18387 "TARGET_SSSE3 || TARGET_AVX || TARGET_XOP"
18388 {
18389 ix86_expand_vec_perm (operands);
18390 DONE;
18391 })
18392
18393 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
18394 ;;
18395 ;; Parallel bitwise logical operations
18396 ;;
18397 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
18398
18399 (define_expand "one_cmpl<mode>2"
18400 [(set (match_operand:VI 0 "register_operand")
18401 (xor:VI (match_operand:VI 1 "bcst_vector_operand")
18402 (match_dup 2)))]
18403 "TARGET_SSE"
18404 {
18405 operands[2] = CONSTM1_RTX (<MODE>mode);
18406
18407 if (!TARGET_AVX512F || (!TARGET_AVX512VL && !TARGET_EVEX512))
18408 operands[2] = force_reg (<MODE>mode, operands[2]);
18409 })
18410
18411 (define_insn_and_split "<mask_codefor>one_cmpl<mode>2<mask_name>"
18412 [(set (match_operand:VI 0 "register_operand" "=v,v,v")
18413 (xor:VI (match_operand:VI 1 "bcst_vector_operand" " 0, m,Br")
18414 (match_operand:VI 2 "vector_all_ones_operand" "BC,BC,BC")))]
18415 "TARGET_AVX512F
18416 && (<MODE_SIZE> == 64 || TARGET_AVX512VL || TARGET_EVEX512)
18417 && (!<mask_applied>
18418 || <ssescalarmode>mode == SImode
18419 || <ssescalarmode>mode == DImode)"
18420 {
18421 if (TARGET_AVX512VL)
18422 return "vpternlog<ternlogsuffix>\t{$0x55, %1, %0, %0<mask_operand3>|%0<mask_operand3>, %0, %1, 0x55}";
18423 else
18424 return "vpternlog<ternlogsuffix>\t{$0x55, %g1, %g0, %g0<mask_operand3>|%g0<mask_operand3>, %g0, %g1, 0x55}";
18425 }
18426 "&& reload_completed && !REG_P (operands[1]) && !<mask_applied>
18427 && optimize_insn_for_speed_p ()"
18428 [(set (match_dup 0) (match_dup 3))
18429 (parallel
18430 [(set (match_dup 0)
18431 (xor:VI (match_dup 1) (match_dup 2)))
18432 (unspec [(match_dup 0)] UNSPEC_INSN_FALSE_DEP)])]
18433 {
18434 if (MEM_P (operands[1]))
18435 {
18436 operands[3] = operands[1];
18437 operands[1] = operands[0];
18438 }
18439 else
18440 {
18441 if (GET_MODE_SIZE (<ssescalarmode>mode) < 4)
18442 {
18443 if (<MODE_SIZE> == 64 ? TARGET_AVX512BW
18444 : (TARGET_AVX512BW && TARGET_AVX512VL)
18445 || !EXT_REX_SSE_REG_P (operands[0]))
18446 {
18447 operands[3] = operands[1];
18448 operands[1] = operands[0];
18449 }
18450 else
18451 operands[3] = CONST0_RTX (<MODE>mode);
18452 }
18453 else
18454 {
18455 if (<MODE_SIZE> == 64 || TARGET_AVX512VL
18456 || !EXT_REX_SSE_REG_P (operands[0]))
18457 {
18458 operands[3] = operands[1];
18459 operands[1] = operands[0];
18460 }
18461 else
18462 operands[3] = CONST0_RTX (<MODE>mode);
18463 }
18464 }
18465 }
18466 [(set_attr "type" "sselog")
18467 (set_attr "prefix" "evex")
18468 (set (attr "mode")
18469 (if_then_else (match_test "TARGET_AVX512VL")
18470 (const_string "<sseinsnmode>")
18471 (const_string "XI")))
18472 (set (attr "enabled")
18473 (if_then_else (eq_attr "alternative" "1")
18474 (symbol_ref "<MODE_SIZE> == 64 || TARGET_AVX512VL")
18475 (const_int 1)))])
18476
18477 (define_insn "*one_cmpl<mode>2_pternlog_false_dep"
18478 [(set (match_operand:VI 0 "register_operand" "=v,v,v")
18479 (xor:VI (match_operand:VI 1 "bcst_vector_operand" " 0, m,Br")
18480 (match_operand:VI 2 "vector_all_ones_operand" "BC,BC,BC")))
18481 (unspec [(match_operand:VI 3 "register_operand" "0,0,0")]
18482 UNSPEC_INSN_FALSE_DEP)]
18483 "TARGET_AVX512F && (<MODE_SIZE> == 64 || TARGET_AVX512VL || TARGET_EVEX512)"
18484 {
18485 if (TARGET_AVX512VL)
18486 return "vpternlog<ternlogsuffix>\t{$0x55, %1, %0, %0<mask_operand3>|%0<mask_operand3>, %0, %1, 0x55}";
18487 else
18488 return "vpternlog<ternlogsuffix>\t{$0x55, %g1, %g0, %g0<mask_operand3>|%g0<mask_operand3>, %g0, %g1, 0x55}";
18489 }
18490 [(set_attr "type" "sselog")
18491 (set_attr "prefix" "evex")
18492 (set (attr "mode")
18493 (if_then_else (match_test "TARGET_AVX512VL")
18494 (const_string "<sseinsnmode>")
18495 (const_string "XI")))
18496 (set (attr "enabled")
18497 (if_then_else (eq_attr "alternative" "1")
18498 (symbol_ref "<MODE_SIZE> == 64 || TARGET_AVX512VL")
18499 (const_int 1)))])
18500
18501 (define_split
18502 [(set (match_operand:VI48_AVX512F 0 "register_operand")
18503 (vec_duplicate:VI48_AVX512F
18504 (not:<ssescalarmode>
18505 (match_operand:<ssescalarmode> 1 "nonimmediate_operand"))))]
18506 "<MODE_SIZE> == 64 || TARGET_AVX512VL
18507 || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256)"
18508 [(set (match_dup 0)
18509 (xor:VI48_AVX512F
18510 (vec_duplicate:VI48_AVX512F (match_dup 1))
18511 (match_dup 2)))]
18512 "operands[2] = CONSTM1_RTX (<MODE>mode);")
18513
18514 (define_expand "<sse2_avx2>_andnot<mode>3"
18515 [(set (match_operand:VI_AVX2 0 "register_operand")
18516 (and:VI_AVX2
18517 (not:VI_AVX2 (match_operand:VI_AVX2 1 "register_operand"))
18518 (match_operand:VI_AVX2 2 "vector_operand")))]
18519 "TARGET_SSE2")
18520
18521 (define_expand "andn<mode>3"
18522 [(set (match_operand:VI 0 "register_operand")
18523 (and:VI
18524 (not:VI (match_operand:VI 2 "register_operand"))
18525 (match_operand:VI 1 "register_operand")))]
18526 "TARGET_SSE2")
18527
18528 (define_expand "<sse2_avx2>_andnot<mode>3_mask"
18529 [(set (match_operand:VI48_AVX512VL 0 "register_operand")
18530 (vec_merge:VI48_AVX512VL
18531 (and:VI48_AVX512VL
18532 (not:VI48_AVX512VL
18533 (match_operand:VI48_AVX512VL 1 "register_operand"))
18534 (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
18535 (match_operand:VI48_AVX512VL 3 "nonimm_or_0_operand")
18536 (match_operand:<avx512fmaskmode> 4 "register_operand")))]
18537 "TARGET_AVX512F")
18538
18539 (define_insn "*andnot<mode>3"
18540 [(set (match_operand:VI 0 "register_operand" "=x,x,v,v,v")
18541 (and:VI
18542 (not:VI (match_operand:VI 1 "bcst_vector_operand" "0,x,v,m,Br"))
18543 (match_operand:VI 2 "bcst_vector_operand" "xBm,xjm,vmBr,0,0")))]
18544 "TARGET_SSE
18545 && (register_operand (operands[1], <MODE>mode)
18546 || register_operand (operands[2], <MODE>mode))"
18547 {
18548 char buf[64];
18549 const char *ops;
18550 const char *tmp;
18551 const char *ssesuffix;
18552
18553 switch (get_attr_mode (insn))
18554 {
18555 case MODE_XI:
18556 gcc_assert (TARGET_AVX512F);
18557 /* FALLTHRU */
18558 case MODE_OI:
18559 gcc_assert (TARGET_AVX2);
18560 /* FALLTHRU */
18561 case MODE_TI:
18562 gcc_assert (TARGET_SSE2);
18563 tmp = "pandn";
18564 switch (<MODE>mode)
18565 {
18566 case E_V64QImode:
18567 case E_V32HImode:
18568 /* There is no vpandnb or vpandnw instruction, nor vpandn for
18569 512-bit vectors. Use vpandnq instead. */
18570 ssesuffix = "q";
18571 break;
18572 case E_V16SImode:
18573 case E_V8DImode:
18574 ssesuffix = "<ssemodesuffix>";
18575 break;
18576 case E_V8SImode:
18577 case E_V4DImode:
18578 case E_V4SImode:
18579 case E_V2DImode:
18580 ssesuffix = (TARGET_AVX512VL && which_alternative == 2
18581 ? "<ssemodesuffix>" : "");
18582 break;
18583 default:
18584 ssesuffix = TARGET_AVX512VL && which_alternative == 2 ? "q" : "";
18585 }
18586 break;
18587
18588 case MODE_V16SF:
18589 gcc_assert (TARGET_AVX512F);
18590 /* FALLTHRU */
18591 case MODE_V8SF:
18592 gcc_assert (TARGET_AVX);
18593 /* FALLTHRU */
18594 case MODE_V4SF:
18595 gcc_assert (TARGET_SSE);
18596 tmp = "andn";
18597 ssesuffix = "ps";
18598 break;
18599
18600 default:
18601 gcc_unreachable ();
18602 }
18603
18604 switch (which_alternative)
18605 {
18606 case 0:
18607 ops = "%s%s\t{%%2, %%0|%%0, %%2}";
18608 break;
18609 case 1:
18610 case 2:
18611 ops = "v%s%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
18612 break;
18613 case 3:
18614 case 4:
18615 tmp = "pternlog";
18616 ssesuffix = "<ternlogsuffix>";
18617 if (which_alternative != 4 || TARGET_AVX512VL)
18618 ops = "v%s%s\t{$0x44, %%1, %%2, %%0|%%0, %%2, %%1, 0x44}";
18619 else
18620 ops = "v%s%s\t{$0x44, %%g1, %%g2, %%g0|%%g0, %%g2, %%g1, 0x44}";
18621 break;
18622 default:
18623 gcc_unreachable ();
18624 }
18625
18626 snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
18627 output_asm_insn (buf, operands);
18628 return "";
18629 }
18630 [(set_attr "isa" "noavx,avx_noavx512f,avx512f,*,*")
18631 (set_attr "addr" "*,gpr16,*,*,*")
18632 (set_attr "type" "sselog")
18633 (set_attr "c86_attr" "sselogic")
18634 (set (attr "prefix_data16")
18635 (if_then_else
18636 (and (eq_attr "alternative" "0")
18637 (eq_attr "mode" "TI"))
18638 (const_string "1")
18639 (const_string "*")))
18640 (set_attr "prefix" "orig,vex,evex,evex,evex")
18641 (set (attr "mode")
18642 (cond [(and (eq_attr "alternative" "3,4")
18643 (match_test "<MODE_SIZE> < 64 && !TARGET_AVX512VL"))
18644 (const_string "XI")
18645 (match_test "TARGET_AVX2")
18646 (const_string "<sseinsnmode>")
18647 (match_test "TARGET_AVX")
18648 (if_then_else
18649 (match_test "<MODE_SIZE> > 16")
18650 (const_string "V8SF")
18651 (const_string "<sseinsnmode>"))
18652 (ior (not (match_test "TARGET_SSE2"))
18653 (match_test "optimize_function_for_size_p (cfun)"))
18654 (const_string "V4SF")
18655 ]
18656 (const_string "<sseinsnmode>")))
18657 (set (attr "enabled")
18658 (cond [(eq_attr "alternative" "3")
18659 (symbol_ref "<MODE_SIZE> == 64 || TARGET_AVX512VL")
18660 (eq_attr "alternative" "4")
18661 (symbol_ref "<MODE_SIZE> == 64 || TARGET_AVX512VL
18662 || (TARGET_AVX512F && TARGET_EVEX512
18663 && !TARGET_PREFER_AVX256)")
18664 ]
18665 (const_string "*")))])
18666
18667 ;; PR target/100711: Split notl; vpbroadcastd; vpand as vpbroadcastd; vpandn
18668 (define_split
18669 [(set (match_operand:VI48_128 0 "register_operand")
18670 (and:VI48_128
18671 (vec_duplicate:VI48_128
18672 (not:<ssescalarmode>
18673 (match_operand:<ssescalarmode> 1 "register_operand")))
18674 (match_operand:VI48_128 2 "vector_operand")))]
18675 "TARGET_SSE"
18676 [(set (match_dup 3)
18677 (vec_duplicate:VI48_128 (match_dup 1)))
18678 (set (match_dup 0)
18679 (and:VI48_128 (not:VI48_128 (match_dup 3))
18680 (match_dup 2)))]
18681 "operands[3] = gen_reg_rtx (<MODE>mode);")
18682
18683 ;; PR target/100711: Split notl; vpbroadcastd; vpand as vpbroadcastd; vpandn
18684 (define_split
18685 [(set (match_operand:VI_AVX2 0 "register_operand")
18686 (and:VI_AVX2
18687 (vec_duplicate:VI_AVX2
18688 (not:<ssescalarmode>
18689 (match_operand:<ssescalarmode> 1 "nonimmediate_operand")))
18690 (match_operand:VI_AVX2 2 "vector_operand")))]
18691 "TARGET_AVX2"
18692 [(set (match_dup 3)
18693 (vec_duplicate:VI_AVX2 (match_dup 1)))
18694 (set (match_dup 0)
18695 (and:VI_AVX2 (not:VI_AVX2 (match_dup 3))
18696 (match_dup 2)))]
18697 "operands[3] = gen_reg_rtx (<MODE>mode);")
18698
18699 (define_split
18700 [(set (match_operand:VI 0 "register_operand")
18701 (ior:VI
18702 (vec_duplicate:VI
18703 (not:<ssescalarmode>
18704 (match_operand:<ssescalarmode> 1 "nonimmediate_operand")))
18705 (match_operand:VI 2 "vector_operand")))]
18706 "<MODE_SIZE> == 64 || TARGET_AVX512VL
18707 || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256)"
18708 [(set (match_dup 3)
18709 (vec_duplicate:VI (match_dup 1)))
18710 (set (match_dup 0)
18711 (ior:VI (not:VI (match_dup 3)) (match_dup 2)))]
18712 "operands[3] = gen_reg_rtx (<MODE>mode);")
18713
18714 (define_split
18715 [(set (match_operand:VI 0 "register_operand")
18716 (xor:VI
18717 (vec_duplicate:VI
18718 (not:<ssescalarmode>
18719 (match_operand:<ssescalarmode> 1 "nonimmediate_operand")))
18720 (match_operand:VI 2 "vector_operand")))]
18721 "<MODE_SIZE> == 64 || TARGET_AVX512VL
18722 || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256)"
18723 [(set (match_dup 3)
18724 (vec_duplicate:VI (match_dup 1)))
18725 (set (match_dup 0)
18726 (not:VI (xor:VI (match_dup 3) (match_dup 2))))]
18727 "operands[3] = gen_reg_rtx (<MODE>mode);")
18728
18729 (define_insn "*andnot<mode>3_mask"
18730 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
18731 (vec_merge:VI48_AVX512VL
18732 (and:VI48_AVX512VL
18733 (not:VI48_AVX512VL
18734 (match_operand:VI48_AVX512VL 1 "register_operand" "v"))
18735 (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm"))
18736 (match_operand:VI48_AVX512VL 3 "nonimm_or_0_operand" "0C")
18737 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
18738 "TARGET_AVX512F"
18739 "vpandn<ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}";
18740 [(set_attr "type" "sselog")
18741 (set_attr "c86_attr" "sselogic")
18742 (set_attr "prefix" "evex")
18743 (set_attr "mode" "<sseinsnmode>")])
18744
18745 (define_expand "<code><mode>3"
18746 [(set (match_operand:VI 0 "register_operand")
18747 (any_logic:VI
18748 (match_operand:VI 1 "nonimmediate_or_const_vector_operand")
18749 (match_operand:VI 2 "nonimmediate_or_const_vector_operand")))]
18750 "TARGET_SSE"
18751 {
18752 ix86_expand_vector_logical_operator (<CODE>, <MODE>mode, operands);
18753 DONE;
18754 })
18755
18756 (define_expand "cond_<code><mode>"
18757 [(set (match_operand:VI48_AVX512VL 0 "register_operand")
18758 (vec_merge:VI48_AVX512VL
18759 (any_logic:VI48_AVX512VL
18760 (match_operand:VI48_AVX512VL 2 "vector_operand")
18761 (match_operand:VI48_AVX512VL 3 "vector_operand"))
18762 (match_operand:VI48_AVX512VL 4 "nonimm_or_0_operand")
18763 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
18764 "TARGET_AVX512F"
18765 {
18766 emit_insn (gen_<code><mode>3_mask (operands[0],
18767 operands[2],
18768 operands[3],
18769 operands[4],
18770 operands[1]));
18771 DONE;
18772 })
18773
18774 (define_expand "<code><mode>3_mask"
18775 [(set (match_operand:VI48_AVX512VL 0 "register_operand")
18776 (vec_merge:VI48_AVX512VL
18777 (any_logic:VI48_AVX512VL
18778 (match_operand:VI48_AVX512VL 1 "bcst_vector_operand")
18779 (match_operand:VI48_AVX512VL 2 "bcst_vector_operand"))
18780 (match_operand:VI48_AVX512VL 3 "nonimm_or_0_operand")
18781 (match_operand:<avx512fmaskmode> 4 "register_operand")))]
18782 "TARGET_AVX512F"
18783 "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
18784
18785 (define_insn "*<code><mode>3<mask_name>"
18786 [(set (match_operand:VI48_AVX_AVX512F 0 "register_operand" "=x,x,v")
18787 (any_logic:VI48_AVX_AVX512F
18788 (match_operand:VI48_AVX_AVX512F 1 "bcst_vector_operand" "%0,x,v")
18789 (match_operand:VI48_AVX_AVX512F 2 "bcst_vector_operand" "xBm,xjm,vmBr")))]
18790 "TARGET_SSE && <mask_mode512bit_condition>
18791 && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
18792 {
18793 char buf[64];
18794 const char *ops;
18795 const char *tmp;
18796 const char *ssesuffix;
18797
18798 switch (get_attr_mode (insn))
18799 {
18800 case MODE_XI:
18801 gcc_assert (TARGET_AVX512F);
18802 /* FALLTHRU */
18803 case MODE_OI:
18804 gcc_assert (TARGET_AVX2);
18805 /* FALLTHRU */
18806 case MODE_TI:
18807 gcc_assert (TARGET_SSE2);
18808 tmp = "p<logic>";
18809 switch (<MODE>mode)
18810 {
18811 case E_V16SImode:
18812 case E_V8DImode:
18813 ssesuffix = "<ssemodesuffix>";
18814 break;
18815 case E_V8SImode:
18816 case E_V4DImode:
18817 case E_V4SImode:
18818 case E_V2DImode:
18819 ssesuffix = ((TARGET_AVX512VL
18820 && (<mask_applied> || which_alternative == 2))
18821 || (MEM_P (operands[2]) && which_alternative == 2
18822 && x86_extended_rex2reg_mentioned_p (operands[2])))
18823 ? "<ssemodesuffix>" : "";
18824 break;
18825 default:
18826 gcc_unreachable ();
18827 }
18828 break;
18829
18830 case MODE_V8SF:
18831 gcc_assert (TARGET_AVX);
18832 /* FALLTHRU */
18833 case MODE_V4SF:
18834 gcc_assert (TARGET_SSE);
18835 tmp = "<logic>";
18836 ssesuffix = "ps";
18837 break;
18838
18839 default:
18840 gcc_unreachable ();
18841 }
18842
18843 switch (which_alternative)
18844 {
18845 case 0:
18846 if (<mask_applied>)
18847 ops = "v%s%s\t{%%2, %%0, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%0, %%2}";
18848 else
18849 ops = "%s%s\t{%%2, %%0|%%0, %%2}";
18850 break;
18851 case 1:
18852 case 2:
18853 ops = "v%s%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
18854 break;
18855 default:
18856 gcc_unreachable ();
18857 }
18858
18859 snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
18860 output_asm_insn (buf, operands);
18861 return "";
18862 }
18863 [(set_attr "isa" "noavx,avx_noavx512f,avx512f")
18864 (set_attr "addr" "*,gpr16,*")
18865 (set_attr "type" "sselog")
18866 (set_attr "c86_attr" "sselogic")
18867 (set (attr "prefix_data16")
18868 (if_then_else
18869 (and (eq_attr "alternative" "0")
18870 (eq_attr "mode" "TI"))
18871 (const_string "1")
18872 (const_string "*")))
18873 (set_attr "prefix" "<mask_prefix3>,evex")
18874 (set (attr "mode")
18875 (cond [(match_test "TARGET_AVX2")
18876 (const_string "<sseinsnmode>")
18877 (match_test "TARGET_AVX")
18878 (if_then_else
18879 (match_test "<MODE_SIZE> > 16")
18880 (const_string "V8SF")
18881 (const_string "<sseinsnmode>"))
18882 (ior (not (match_test "TARGET_SSE2"))
18883 (match_test "optimize_function_for_size_p (cfun)"))
18884 (const_string "V4SF")
18885 ]
18886 (const_string "<sseinsnmode>")))])
18887
18888 (define_insn "*<code><mode>3"
18889 [(set (match_operand:VI12_AVX_AVX512F 0 "register_operand" "=x,x,v")
18890 (any_logic:VI12_AVX_AVX512F
18891 (match_operand:VI12_AVX_AVX512F 1 "vector_operand" "%0,x,v")
18892 (match_operand:VI12_AVX_AVX512F 2 "vector_operand" "xBm,xjm,vm")))]
18893 "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
18894 {
18895 char buf[64];
18896 const char *ops;
18897 const char *tmp;
18898 const char *ssesuffix;
18899
18900 switch (get_attr_mode (insn))
18901 {
18902 case MODE_XI:
18903 gcc_assert (TARGET_AVX512F);
18904 /* FALLTHRU */
18905 case MODE_OI:
18906 gcc_assert (TARGET_AVX2);
18907 /* FALLTHRU */
18908 case MODE_TI:
18909 gcc_assert (TARGET_SSE2);
18910 tmp = "p<logic>";
18911 switch (<MODE>mode)
18912 {
18913 case E_V64QImode:
18914 case E_V32HImode:
18915 ssesuffix = "q";
18916 break;
18917 case E_V32QImode:
18918 case E_V16HImode:
18919 case E_V16QImode:
18920 case E_V8HImode:
18921 ssesuffix = (((TARGET_AVX512VL && which_alternative == 2)
18922 || (MEM_P (operands[2]) && which_alternative == 2
18923 && x86_extended_rex2reg_mentioned_p (operands[2]))))
18924 ? "q" : "";
18925 break;
18926 default:
18927 gcc_unreachable ();
18928 }
18929 break;
18930
18931 case MODE_V8SF:
18932 gcc_assert (TARGET_AVX);
18933 /* FALLTHRU */
18934 case MODE_V4SF:
18935 gcc_assert (TARGET_SSE);
18936 tmp = "<logic>";
18937 ssesuffix = "ps";
18938 break;
18939
18940 default:
18941 gcc_unreachable ();
18942 }
18943
18944 switch (which_alternative)
18945 {
18946 case 0:
18947 ops = "%s%s\t{%%2, %%0|%%0, %%2}";
18948 break;
18949 case 1:
18950 case 2:
18951 ops = "v%s%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
18952 break;
18953 default:
18954 gcc_unreachable ();
18955 }
18956
18957 snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
18958 output_asm_insn (buf, operands);
18959 return "";
18960 }
18961 [(set_attr "isa" "noavx,avx_noavx512f,avx512f")
18962 (set_attr "addr" "*,gpr16,*")
18963 (set_attr "type" "sselog")
18964 (set_attr "c86_attr" "sselogic")
18965 (set (attr "prefix_data16")
18966 (if_then_else
18967 (and (eq_attr "alternative" "0")
18968 (eq_attr "mode" "TI"))
18969 (const_string "1")
18970 (const_string "*")))
18971 (set_attr "prefix" "orig,vex,evex")
18972 (set (attr "mode")
18973 (cond [(match_test "TARGET_AVX2")
18974 (const_string "<sseinsnmode>")
18975 (match_test "TARGET_AVX")
18976 (if_then_else
18977 (match_test "<MODE_SIZE> > 16")
18978 (const_string "V8SF")
18979 (const_string "<sseinsnmode>"))
18980 (ior (not (match_test "TARGET_SSE2"))
18981 (match_test "optimize_function_for_size_p (cfun)"))
18982 (const_string "V4SF")
18983 ]
18984 (const_string "<sseinsnmode>")))])
18985
18986 (define_insn "<code>v1ti3"
18987 [(set (match_operand:V1TI 0 "register_operand" "=x,x,v")
18988 (any_logic:V1TI
18989 (match_operand:V1TI 1 "register_operand" "%0,x,v")
18990 (match_operand:V1TI 2 "vector_operand" "xBm,xjm,vm")))]
18991 "TARGET_SSE2"
18992 "@
18993 p<logic>\t{%2, %0|%0, %2}
18994 vp<logic>\t{%2, %1, %0|%0, %1, %2}
18995 vp<logic>d\t{%2, %1, %0|%0, %1, %2}"
18996 [(set_attr "isa" "noavx,avx_noavx512vl,avx512vl")
18997 (set_attr "addr" "*,gpr16,*")
18998 (set_attr "prefix" "orig,vex,evex")
18999 (set_attr "prefix_data16" "1,*,*")
19000 (set_attr "type" "sselog")
19001 (set_attr "c86_attr" "sselogic")
19002 (set_attr "mode" "TI")])
19003
19004 (define_expand "one_cmplv1ti2"
19005 [(set (match_operand:V1TI 0 "register_operand")
19006 (xor:V1TI (match_operand:V1TI 1 "register_operand")
19007 (match_dup 2)))]
19008 "TARGET_SSE2"
19009 {
19010 operands[2] = force_reg (V1TImode, CONSTM1_RTX (V1TImode));
19011 })
19012
19013 (define_insn "*iornot<mode>3"
19014 [(set (match_operand:VI 0 "register_operand" "=v,v,v,v")
19015 (ior:VI
19016 (not:VI
19017 (match_operand:VI 1 "bcst_vector_operand" "0,m, 0,vBr"))
19018 (match_operand:VI 2 "bcst_vector_operand" "m,0,vBr, 0")))]
19019 "(<MODE_SIZE> == 64 || TARGET_AVX512VL
19020 || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256))
19021 && (register_operand (operands[1], <MODE>mode)
19022 || register_operand (operands[2], <MODE>mode))"
19023 {
19024 if (!register_operand (operands[1], <MODE>mode))
19025 {
19026 if (TARGET_AVX512VL)
19027 return "vpternlog<ternlogsuffix>\t{$0xdd, %1, %2, %0|%0, %2, %1, 0xdd}";
19028 return "vpternlog<ternlogsuffix>\t{$0xdd, %g1, %g2, %g0|%g0, %g2, %g1, 0xdd}";
19029 }
19030 if (TARGET_AVX512VL)
19031 return "vpternlog<ternlogsuffix>\t{$0xbb, %2, %1, %0|%0, %1, %2, 0xbb}";
19032 return "vpternlog<ternlogsuffix>\t{$0xbb, %g2, %g1, %g0|%g0, %g1, %g2, 0xbb}";
19033 }
19034 [(set_attr "type" "sselog")
19035 (set_attr "length_immediate" "1")
19036 (set_attr "prefix" "evex")
19037 (set (attr "mode")
19038 (if_then_else (match_test "TARGET_AVX512VL")
19039 (const_string "<sseinsnmode>")
19040 (const_string "XI")))
19041 (set (attr "enabled")
19042 (if_then_else (eq_attr "alternative" "0,1")
19043 (symbol_ref "<MODE_SIZE> == 64 || TARGET_AVX512VL")
19044 (const_string "*")))])
19045
19046 (define_insn "*xnor<mode>3"
19047 [(set (match_operand:VI 0 "register_operand" "=v,v")
19048 (not:VI
19049 (xor:VI
19050 (match_operand:VI 1 "bcst_vector_operand" "%0, 0")
19051 (match_operand:VI 2 "bcst_vector_operand" " m,vBr"))))]
19052 "(<MODE_SIZE> == 64 || TARGET_AVX512VL
19053 || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256))
19054 && (register_operand (operands[1], <MODE>mode)
19055 || register_operand (operands[2], <MODE>mode))"
19056 {
19057 if (TARGET_AVX512VL)
19058 return "vpternlog<ternlogsuffix>\t{$0x99, %2, %1, %0|%0, %1, %2, 0x99}";
19059 else
19060 return "vpternlog<ternlogsuffix>\t{$0x99, %g2, %g1, %g0|%g0, %g1, %g2, 0x99}";
19061 }
19062 [(set_attr "type" "sselog")
19063 (set_attr "length_immediate" "1")
19064 (set_attr "prefix" "evex")
19065 (set (attr "mode")
19066 (if_then_else (match_test "TARGET_AVX512VL")
19067 (const_string "<sseinsnmode>")
19068 (const_string "XI")))
19069 (set (attr "enabled")
19070 (if_then_else (eq_attr "alternative" "0")
19071 (symbol_ref "<MODE_SIZE> == 64 || TARGET_AVX512VL")
19072 (const_string "*")))])
19073
19074 (define_code_iterator andor [and ior])
19075 (define_code_attr nlogic [(and "nor") (ior "nand")])
19076 (define_code_attr ternlog_nlogic [(and "0x11") (ior "0x77")])
19077
19078 (define_insn "*<nlogic><mode>3"
19079 [(set (match_operand:VI 0 "register_operand" "=v,v")
19080 (andor:VI
19081 (not:VI (match_operand:VI 1 "bcst_vector_operand" "%0, 0"))
19082 (not:VI (match_operand:VI 2 "bcst_vector_operand" "m,vBr"))))]
19083 "(<MODE_SIZE> == 64 || TARGET_AVX512VL
19084 || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256))
19085 && (register_operand (operands[1], <MODE>mode)
19086 || register_operand (operands[2], <MODE>mode))"
19087 {
19088 if (TARGET_AVX512VL)
19089 return "vpternlog<ternlogsuffix>\t{$<ternlog_nlogic>, %2, %1, %0|%0, %1, %2, <ternlog_nlogic>}";
19090 else
19091 return "vpternlog<ternlogsuffix>\t{$<ternlog_nlogic>, %g2, %g1, %g0|%g0, %g1, %g2, <ternlog_nlogic>}";
19092 }
19093 [(set_attr "type" "sselog")
19094 (set_attr "length_immediate" "1")
19095 (set_attr "prefix" "evex")
19096 (set (attr "mode")
19097 (if_then_else (match_test "TARGET_AVX512VL")
19098 (const_string "<sseinsnmode>")
19099 (const_string "XI")))
19100 (set (attr "enabled")
19101 (if_then_else (eq_attr "alternative" "0")
19102 (symbol_ref "<MODE_SIZE> == 64 || TARGET_AVX512VL")
19103 (const_string "*")))])
19104
19105 (define_mode_iterator AVX512ZEXTMASK
19106 [(DI "TARGET_AVX512BW && TARGET_EVEX512") (SI "TARGET_AVX512BW") HI])
19107
19108 (define_insn "<avx512>_testm<mode>3<mask_scalar_merge_name>"
19109 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
19110 (unspec:<avx512fmaskmode>
19111 [(match_operand:VI1248_AVX512VLBW 1 "register_operand" "v")
19112 (match_operand:VI1248_AVX512VLBW 2 "nonimmediate_operand" "vm")]
19113 UNSPEC_TESTM))]
19114 "TARGET_AVX512F"
19115 "vptestm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
19116 [(set_attr "prefix" "evex")
19117 (set_attr "mode" "<sseinsnmode>")])
19118
19119 (define_insn "<avx512>_testnm<mode>3<mask_scalar_merge_name>"
19120 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
19121 (unspec:<avx512fmaskmode>
19122 [(match_operand:VI1248_AVX512VLBW 1 "register_operand" "v")
19123 (match_operand:VI1248_AVX512VLBW 2 "nonimmediate_operand" "vm")]
19124 UNSPEC_TESTNM))]
19125 "TARGET_AVX512F"
19126 "vptestnm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
19127 [(set_attr "prefix" "evex")
19128 (set_attr "mode" "<sseinsnmode>")])
19129
19130 (define_insn "*<avx512>_testm<VI1248_AVX512VLBW:mode>3_zext"
19131 [(set (match_operand:AVX512ZEXTMASK 0 "register_operand" "=k")
19132 (zero_extend:AVX512ZEXTMASK
19133 (unspec:<VI1248_AVX512VLBW:avx512fmaskmode>
19134 [(match_operand:VI1248_AVX512VLBW 1 "register_operand" "v")
19135 (match_operand:VI1248_AVX512VLBW 2 "nonimmediate_operand" "vm")]
19136 UNSPEC_TESTM)))]
19137 "TARGET_AVX512BW
19138 && (<AVX512ZEXTMASK:MODE_SIZE>
19139 > GET_MODE_SIZE (<VI1248_AVX512VLBW:avx512fmaskmode>mode))"
19140 "vptestm<VI1248_AVX512VLBW:ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
19141 [(set_attr "prefix" "evex")
19142 (set_attr "mode" "<VI1248_AVX512VLBW:sseinsnmode>")])
19143
19144 (define_insn "*<avx512>_testm<VI1248_AVX512VLBW:mode>3_zext_mask"
19145 [(set (match_operand:AVX512ZEXTMASK 0 "register_operand" "=k")
19146 (zero_extend:AVX512ZEXTMASK
19147 (and:<VI1248_AVX512VLBW:avx512fmaskmode>
19148 (unspec:<VI1248_AVX512VLBW:avx512fmaskmode>
19149 [(match_operand:VI1248_AVX512VLBW 1 "register_operand" "v")
19150 (match_operand:VI1248_AVX512VLBW 2 "nonimmediate_operand" "vm")]
19151 UNSPEC_TESTM)
19152 (match_operand:<VI1248_AVX512VLBW:avx512fmaskmode> 3 "register_operand" "Yk"))))]
19153 "TARGET_AVX512BW
19154 && (<AVX512ZEXTMASK:MODE_SIZE>
19155 > GET_MODE_SIZE (<VI1248_AVX512VLBW:avx512fmaskmode>mode))"
19156 "vptestm<VI1248_AVX512VLBW:ssemodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}"
19157 [(set_attr "prefix" "evex")
19158 (set_attr "mode" "<VI1248_AVX512VLBW:sseinsnmode>")])
19159
19160 (define_insn "*<avx512>_testnm<VI1248_AVX512VLBW:mode>3_zext"
19161 [(set (match_operand:AVX512ZEXTMASK 0 "register_operand" "=k")
19162 (zero_extend:AVX512ZEXTMASK
19163 (unspec:<VI1248_AVX512VLBW:avx512fmaskmode>
19164 [(match_operand:VI1248_AVX512VLBW 1 "register_operand" "v")
19165 (match_operand:VI1248_AVX512VLBW 2 "nonimmediate_operand" "vm")]
19166 UNSPEC_TESTNM)))]
19167 "TARGET_AVX512BW
19168 && (<AVX512ZEXTMASK:MODE_SIZE>
19169 > GET_MODE_SIZE (<VI1248_AVX512VLBW:avx512fmaskmode>mode))"
19170 "vptestnm<VI1248_AVX512VLBW:ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
19171 [(set_attr "prefix" "evex")
19172 (set_attr "mode" "<VI1248_AVX512VLBW:sseinsnmode>")])
19173
19174 (define_insn "*<avx512>_testnm<VI1248_AVX512VLBW:mode>3_zext_mask"
19175 [(set (match_operand:AVX512ZEXTMASK 0 "register_operand" "=k")
19176 (zero_extend:AVX512ZEXTMASK
19177 (and:<VI1248_AVX512VLBW:avx512fmaskmode>
19178 (unspec:<VI1248_AVX512VLBW:avx512fmaskmode>
19179 [(match_operand:VI1248_AVX512VLBW 1 "register_operand" "v")
19180 (match_operand:VI1248_AVX512VLBW 2 "nonimmediate_operand" "vm")]
19181 UNSPEC_TESTNM)
19182 (match_operand:<VI1248_AVX512VLBW:avx512fmaskmode> 3 "register_operand" "Yk"))))]
19183 "TARGET_AVX512BW
19184 && (<AVX512ZEXTMASK:MODE_SIZE>
19185 > GET_MODE_SIZE (<VI1248_AVX512VLBW:avx512fmaskmode>mode))"
19186 "vptestnm<VI1248_AVX512VLBW:ssemodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}"
19187 [(set_attr "prefix" "evex")
19188 (set_attr "mode" "<VI1248_AVX512VLBW:sseinsnmode>")])
19189
19190 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19191 ;;
19192 ;; Parallel integral element swizzling
19193 ;;
19194 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19195
19196 (define_expand "vec_pack_trunc_<mode>"
19197 [(match_operand:<ssepackmode> 0 "register_operand")
19198 (match_operand:VI248_AVX2_8_AVX512F_24_AVX512BW 1 "register_operand")
19199 (match_operand:VI248_AVX2_8_AVX512F_24_AVX512BW 2 "register_operand")]
19200 "TARGET_SSE2"
19201 {
19202 rtx op1 = gen_lowpart (<ssepackmode>mode, operands[1]);
19203 rtx op2 = gen_lowpart (<ssepackmode>mode, operands[2]);
19204 ix86_expand_vec_extract_even_odd (operands[0], op1, op2, 0);
19205 DONE;
19206 })
19207
19208 (define_expand "vec_pack_trunc_qi"
19209 [(parallel
19210 [(set (match_operand:HI 0 "register_operand")
19211 (ior:HI
19212 (ashift:HI (zero_extend:HI (match_operand:QI 2 "register_operand"))
19213 (const_int 8))
19214 (zero_extend:HI (match_operand:QI 1 "register_operand"))))
19215 (unspec [(const_int 0)] UNSPEC_MASKOP)])]
19216 "TARGET_AVX512F")
19217
19218 (define_expand "vec_pack_trunc_<mode>"
19219 [(parallel
19220 [(set (match_operand:<DOUBLEMASKMODE> 0 "register_operand")
19221 (ior:<DOUBLEMASKMODE>
19222 (ashift:<DOUBLEMASKMODE>
19223 (zero_extend:<DOUBLEMASKMODE>
19224 (match_operand:SWI24 2 "register_operand"))
19225 (match_dup 3))
19226 (zero_extend:<DOUBLEMASKMODE>
19227 (match_operand:SWI24 1 "register_operand"))))
19228 (unspec [(const_int 0)] UNSPEC_MASKOP)])]
19229 "TARGET_AVX512BW"
19230 {
19231 operands[3] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
19232 })
19233
19234 (define_expand "vec_pack_sbool_trunc_qi"
19235 [(match_operand:QI 0 "register_operand")
19236 (match_operand:QI 1 "register_operand")
19237 (match_operand:QI 2 "register_operand")
19238 (match_operand:QI 3 "const_int_operand")]
19239 "TARGET_AVX512F"
19240 {
19241 HOST_WIDE_INT nunits = INTVAL (operands[3]);
19242 rtx mask, tem1, tem2;
19243 if (nunits != 8 && nunits != 4)
19244 FAIL;
19245 mask = gen_reg_rtx (QImode);
19246 emit_move_insn (mask, GEN_INT ((1 << (nunits / 2)) - 1));
19247 tem1 = gen_reg_rtx (QImode);
19248 emit_insn (gen_kandqi (tem1, operands[1], mask));
19249 if (TARGET_AVX512DQ)
19250 {
19251 tem2 = gen_reg_rtx (QImode);
19252 emit_insn (gen_kashiftqi (tem2, operands[2],
19253 GEN_INT (nunits / 2)));
19254 }
19255 else
19256 {
19257 tem2 = gen_reg_rtx (HImode);
19258 emit_insn (gen_kashifthi (tem2, lowpart_subreg (HImode, operands[2],
19259 QImode),
19260 GEN_INT (nunits / 2)));
19261 tem2 = lowpart_subreg (QImode, tem2, HImode);
19262 }
19263 emit_insn (gen_kiorqi (operands[0], tem1, tem2));
19264 DONE;
19265 })
19266
19267 (define_insn "sse2_packsswb<mask_name>"
19268 [(set (match_operand:V16QI 0 "register_operand" "=x,Yw")
19269 (vec_concat:V16QI
19270 (ss_truncate:V8QI
19271 (match_operand:V8HI 1 "register_operand" "0,Yw"))
19272 (ss_truncate:V8QI
19273 (match_operand:V8HI 2 "vector_operand" "xBm,Ywm"))))]
19274 "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
19275 "@
19276 packsswb\t{%2, %0|%0, %2}
19277 vpacksswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19278 [(set_attr "isa" "noavx,avx")
19279 (set_attr "type" "sselog")
19280 (set_attr "prefix_data16" "1,*")
19281 (set_attr "prefix" "orig,<mask_prefix>")
19282 (set_attr "mode" "TI")])
19283
19284 (define_insn "avx2_packsswb<mask_name>"
19285 [(set (match_operand:V32QI 0 "register_operand" "=Yw")
19286 (vec_select:V32QI
19287 (vec_concat:V32QI
19288 (ss_truncate:V16QI
19289 (match_operand:V16HI 1 "register_operand" "Yw"))
19290 (ss_truncate:V16QI
19291 (match_operand:V16HI 2 "vector_operand" "Ywm")))
19292 (parallel [(const_int 0) (const_int 1)
19293 (const_int 2) (const_int 3)
19294 (const_int 4) (const_int 5)
19295 (const_int 6) (const_int 7)
19296 (const_int 16) (const_int 17)
19297 (const_int 18) (const_int 19)
19298 (const_int 20) (const_int 21)
19299 (const_int 22) (const_int 23)
19300 (const_int 8) (const_int 9)
19301 (const_int 10) (const_int 11)
19302 (const_int 12) (const_int 13)
19303 (const_int 14) (const_int 15)
19304 (const_int 24) (const_int 25)
19305 (const_int 26) (const_int 27)
19306 (const_int 28) (const_int 29)
19307 (const_int 30) (const_int 31)])))]
19308 "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
19309 "vpacksswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19310 [(set_attr "type" "sselog")
19311 (set_attr "prefix" "<mask_prefix>")
19312 (set_attr "mode" "OI")])
19313
19314 (define_insn "avx512bw_packsswb<mask_name>"
19315 [(set (match_operand:V64QI 0 "register_operand" "=v")
19316 (vec_select:V64QI
19317 (vec_concat:V64QI
19318 (ss_truncate:V32QI
19319 (match_operand:V32HI 1 "register_operand" "v"))
19320 (ss_truncate:V32QI
19321 (match_operand:V32HI 2 "vector_operand" "vm")))
19322 (parallel [(const_int 0) (const_int 1)
19323 (const_int 2) (const_int 3)
19324 (const_int 4) (const_int 5)
19325 (const_int 6) (const_int 7)
19326 (const_int 32) (const_int 33)
19327 (const_int 34) (const_int 35)
19328 (const_int 36) (const_int 37)
19329 (const_int 38) (const_int 39)
19330 (const_int 8) (const_int 9)
19331 (const_int 10) (const_int 11)
19332 (const_int 12) (const_int 13)
19333 (const_int 14) (const_int 15)
19334 (const_int 40) (const_int 41)
19335 (const_int 42) (const_int 43)
19336 (const_int 44) (const_int 45)
19337 (const_int 46) (const_int 47)
19338 (const_int 16) (const_int 17)
19339 (const_int 18) (const_int 19)
19340 (const_int 20) (const_int 21)
19341 (const_int 22) (const_int 23)
19342 (const_int 48) (const_int 49)
19343 (const_int 50) (const_int 51)
19344 (const_int 52) (const_int 53)
19345 (const_int 54) (const_int 55)
19346 (const_int 24) (const_int 25)
19347 (const_int 26) (const_int 27)
19348 (const_int 28) (const_int 29)
19349 (const_int 30) (const_int 31)
19350 (const_int 56) (const_int 57)
19351 (const_int 58) (const_int 59)
19352 (const_int 60) (const_int 61)
19353 (const_int 62) (const_int 63)])))]
19354
19355 "TARGET_AVX512BW && TARGET_EVEX512"
19356 "vpacksswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19357 [(set_attr "type" "sselog")
19358 (set_attr "prefix" "<mask_prefix>")
19359 (set_attr "mode" "XI")])
19360
19361 (define_insn "sse2_packssdw<mask_name>"
19362 [(set (match_operand:V8HI 0 "register_operand" "=x,Yw")
19363 (vec_concat:V8HI
19364 (ss_truncate:V4HI
19365 (match_operand:V4SI 1 "register_operand" "0,Yw"))
19366 (ss_truncate:V4HI
19367 (match_operand:V4SI 2 "vector_operand" "xBm,Ywm"))))]
19368 "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
19369 "@
19370 packssdw\t{%2, %0|%0, %2}
19371 vpackssdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19372 [(set_attr "isa" "noavx,avx")
19373 (set_attr "type" "sselog")
19374 (set_attr "prefix_data16" "1,*")
19375 (set_attr "prefix" "orig,<mask_prefix>")
19376 (set_attr "mode" "TI")])
19377
19378 (define_insn "avx2_packssdw<mask_name>"
19379 [(set (match_operand:V16HI 0 "register_operand" "=Yw")
19380 (vec_select:V16HI
19381 (vec_concat:V16HI
19382 (ss_truncate:V8HI
19383 (match_operand:V8SI 1 "register_operand" "Yw"))
19384 (ss_truncate:V8HI
19385 (match_operand:V8SI 2 "vector_operand" "Ywm")))
19386 (parallel [(const_int 0) (const_int 1)
19387 (const_int 2) (const_int 3)
19388 (const_int 8) (const_int 9)
19389 (const_int 10) (const_int 11)
19390 (const_int 4) (const_int 5)
19391 (const_int 6) (const_int 7)
19392 (const_int 12) (const_int 13)
19393 (const_int 14) (const_int 15)])))]
19394 "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
19395 "vpackssdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19396 [(set_attr "type" "sselog")
19397 (set_attr "prefix" "<mask_prefix>")
19398 (set_attr "mode" "OI")])
19399
19400 (define_insn "avx512bw_packssdw<mask_name>"
19401 [(set (match_operand:V32HI 0 "register_operand" "=v")
19402 (vec_select:V32HI
19403 (vec_concat:V32HI
19404 (ss_truncate:V16HI
19405 (match_operand:V16SI 1 "register_operand" "v"))
19406 (ss_truncate:V16HI
19407 (match_operand:V16SI 2 "vector_operand" "vm")))
19408 (parallel [(const_int 0) (const_int 1)
19409 (const_int 2) (const_int 3)
19410 (const_int 16) (const_int 17)
19411 (const_int 18) (const_int 19)
19412 (const_int 4) (const_int 5)
19413 (const_int 6) (const_int 7)
19414 (const_int 20) (const_int 21)
19415 (const_int 22) (const_int 23)
19416 (const_int 8) (const_int 9)
19417 (const_int 10) (const_int 11)
19418 (const_int 24) (const_int 25)
19419 (const_int 26) (const_int 27)
19420 (const_int 12) (const_int 13)
19421 (const_int 14) (const_int 15)
19422 (const_int 28) (const_int 29)
19423 (const_int 30) (const_int 31)])))]
19424 "TARGET_AVX512BW && TARGET_EVEX512"
19425 "vpackssdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19426 [(set_attr "type" "sselog")
19427 (set_attr "prefix" "<mask_prefix>")
19428 (set_attr "mode" "XI")])
19429
19430 ;; This instruction does unsigned saturation of signed source
19431 ;; and is different from generic us_truncate RTX.
19432 (define_insn "<sse2_avx2>_packuswb<mask_name>"
19433 [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,<v_Yw>")
19434 (unspec:VI1_AVX512
19435 [(match_operand:<sseunpackmode> 1 "register_operand" "0,<v_Yw>")
19436 (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,<v_Yw>m")]
19437 UNSPEC_US_TRUNCATE))]
19438 "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
19439 "@
19440 packuswb\t{%2, %0|%0, %2}
19441 vpackuswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19442 [(set_attr "isa" "noavx,avx")
19443 (set_attr "type" "sselog")
19444 (set_attr "prefix_data16" "1,*")
19445 (set_attr "prefix" "orig,<mask_prefix>")
19446 (set_attr "mode" "<sseinsnmode>")])
19447
19448 (define_insn "avx512bw_interleave_highv64qi<mask_name>"
19449 [(set (match_operand:V64QI 0 "register_operand" "=v")
19450 (vec_select:V64QI
19451 (vec_concat:V128QI
19452 (match_operand:V64QI 1 "register_operand" "v")
19453 (match_operand:V64QI 2 "nonimmediate_operand" "vm"))
19454 (parallel [(const_int 8) (const_int 72)
19455 (const_int 9) (const_int 73)
19456 (const_int 10) (const_int 74)
19457 (const_int 11) (const_int 75)
19458 (const_int 12) (const_int 76)
19459 (const_int 13) (const_int 77)
19460 (const_int 14) (const_int 78)
19461 (const_int 15) (const_int 79)
19462 (const_int 24) (const_int 88)
19463 (const_int 25) (const_int 89)
19464 (const_int 26) (const_int 90)
19465 (const_int 27) (const_int 91)
19466 (const_int 28) (const_int 92)
19467 (const_int 29) (const_int 93)
19468 (const_int 30) (const_int 94)
19469 (const_int 31) (const_int 95)
19470 (const_int 40) (const_int 104)
19471 (const_int 41) (const_int 105)
19472 (const_int 42) (const_int 106)
19473 (const_int 43) (const_int 107)
19474 (const_int 44) (const_int 108)
19475 (const_int 45) (const_int 109)
19476 (const_int 46) (const_int 110)
19477 (const_int 47) (const_int 111)
19478 (const_int 56) (const_int 120)
19479 (const_int 57) (const_int 121)
19480 (const_int 58) (const_int 122)
19481 (const_int 59) (const_int 123)
19482 (const_int 60) (const_int 124)
19483 (const_int 61) (const_int 125)
19484 (const_int 62) (const_int 126)
19485 (const_int 63) (const_int 127)])))]
19486 "TARGET_AVX512BW && TARGET_EVEX512"
19487 "vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19488 [(set_attr "type" "sselog")
19489 (set_attr "prefix" "evex")
19490 (set_attr "mode" "XI")])
19491
19492 (define_insn "avx2_interleave_highv32qi<mask_name>"
19493 [(set (match_operand:V32QI 0 "register_operand" "=Yw")
19494 (vec_select:V32QI
19495 (vec_concat:V64QI
19496 (match_operand:V32QI 1 "register_operand" "Yw")
19497 (match_operand:V32QI 2 "nonimmediate_operand" "Ywm"))
19498 (parallel [(const_int 8) (const_int 40)
19499 (const_int 9) (const_int 41)
19500 (const_int 10) (const_int 42)
19501 (const_int 11) (const_int 43)
19502 (const_int 12) (const_int 44)
19503 (const_int 13) (const_int 45)
19504 (const_int 14) (const_int 46)
19505 (const_int 15) (const_int 47)
19506 (const_int 24) (const_int 56)
19507 (const_int 25) (const_int 57)
19508 (const_int 26) (const_int 58)
19509 (const_int 27) (const_int 59)
19510 (const_int 28) (const_int 60)
19511 (const_int 29) (const_int 61)
19512 (const_int 30) (const_int 62)
19513 (const_int 31) (const_int 63)])))]
19514 "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
19515 "vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19516 [(set_attr "type" "sselog")
19517 (set_attr "prefix" "<mask_prefix>")
19518 (set_attr "mode" "OI")])
19519
19520 (define_insn "vec_interleave_highv16qi<mask_name>"
19521 [(set (match_operand:V16QI 0 "register_operand" "=x,Yw")
19522 (vec_select:V16QI
19523 (vec_concat:V32QI
19524 (match_operand:V16QI 1 "register_operand" "0,Yw")
19525 (match_operand:V16QI 2 "vector_operand" "xBm,Ywm"))
19526 (parallel [(const_int 8) (const_int 24)
19527 (const_int 9) (const_int 25)
19528 (const_int 10) (const_int 26)
19529 (const_int 11) (const_int 27)
19530 (const_int 12) (const_int 28)
19531 (const_int 13) (const_int 29)
19532 (const_int 14) (const_int 30)
19533 (const_int 15) (const_int 31)])))]
19534 "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
19535 "@
19536 punpckhbw\t{%2, %0|%0, %2}
19537 vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19538 [(set_attr "isa" "noavx,avx")
19539 (set_attr "type" "sselog")
19540 (set_attr "prefix_data16" "1,*")
19541 (set_attr "prefix" "orig,<mask_prefix>")
19542 (set_attr "mode" "TI")])
19543
19544 (define_insn "avx512bw_interleave_lowv64qi<mask_name>"
19545 [(set (match_operand:V64QI 0 "register_operand" "=v")
19546 (vec_select:V64QI
19547 (vec_concat:V128QI
19548 (match_operand:V64QI 1 "register_operand" "v")
19549 (match_operand:V64QI 2 "nonimmediate_operand" "vm"))
19550 (parallel [(const_int 0) (const_int 64)
19551 (const_int 1) (const_int 65)
19552 (const_int 2) (const_int 66)
19553 (const_int 3) (const_int 67)
19554 (const_int 4) (const_int 68)
19555 (const_int 5) (const_int 69)
19556 (const_int 6) (const_int 70)
19557 (const_int 7) (const_int 71)
19558 (const_int 16) (const_int 80)
19559 (const_int 17) (const_int 81)
19560 (const_int 18) (const_int 82)
19561 (const_int 19) (const_int 83)
19562 (const_int 20) (const_int 84)
19563 (const_int 21) (const_int 85)
19564 (const_int 22) (const_int 86)
19565 (const_int 23) (const_int 87)
19566 (const_int 32) (const_int 96)
19567 (const_int 33) (const_int 97)
19568 (const_int 34) (const_int 98)
19569 (const_int 35) (const_int 99)
19570 (const_int 36) (const_int 100)
19571 (const_int 37) (const_int 101)
19572 (const_int 38) (const_int 102)
19573 (const_int 39) (const_int 103)
19574 (const_int 48) (const_int 112)
19575 (const_int 49) (const_int 113)
19576 (const_int 50) (const_int 114)
19577 (const_int 51) (const_int 115)
19578 (const_int 52) (const_int 116)
19579 (const_int 53) (const_int 117)
19580 (const_int 54) (const_int 118)
19581 (const_int 55) (const_int 119)])))]
19582 "TARGET_AVX512BW && TARGET_EVEX512"
19583 "vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19584 [(set_attr "type" "sselog")
19585 (set_attr "prefix" "evex")
19586 (set_attr "mode" "XI")])
19587
19588 (define_insn "avx2_interleave_lowv32qi<mask_name>"
19589 [(set (match_operand:V32QI 0 "register_operand" "=Yw")
19590 (vec_select:V32QI
19591 (vec_concat:V64QI
19592 (match_operand:V32QI 1 "register_operand" "Yw")
19593 (match_operand:V32QI 2 "nonimmediate_operand" "Ywm"))
19594 (parallel [(const_int 0) (const_int 32)
19595 (const_int 1) (const_int 33)
19596 (const_int 2) (const_int 34)
19597 (const_int 3) (const_int 35)
19598 (const_int 4) (const_int 36)
19599 (const_int 5) (const_int 37)
19600 (const_int 6) (const_int 38)
19601 (const_int 7) (const_int 39)
19602 (const_int 16) (const_int 48)
19603 (const_int 17) (const_int 49)
19604 (const_int 18) (const_int 50)
19605 (const_int 19) (const_int 51)
19606 (const_int 20) (const_int 52)
19607 (const_int 21) (const_int 53)
19608 (const_int 22) (const_int 54)
19609 (const_int 23) (const_int 55)])))]
19610 "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
19611 "vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19612 [(set_attr "type" "sselog")
19613 (set_attr "prefix" "maybe_vex")
19614 (set_attr "mode" "OI")])
19615
19616 (define_insn "vec_interleave_lowv16qi<mask_name>"
19617 [(set (match_operand:V16QI 0 "register_operand" "=x,Yw")
19618 (vec_select:V16QI
19619 (vec_concat:V32QI
19620 (match_operand:V16QI 1 "register_operand" "0,Yw")
19621 (match_operand:V16QI 2 "vector_operand" "xBm,Ywm"))
19622 (parallel [(const_int 0) (const_int 16)
19623 (const_int 1) (const_int 17)
19624 (const_int 2) (const_int 18)
19625 (const_int 3) (const_int 19)
19626 (const_int 4) (const_int 20)
19627 (const_int 5) (const_int 21)
19628 (const_int 6) (const_int 22)
19629 (const_int 7) (const_int 23)])))]
19630 "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
19631 "@
19632 punpcklbw\t{%2, %0|%0, %2}
19633 vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19634 [(set_attr "isa" "noavx,avx")
19635 (set_attr "type" "sselog")
19636 (set_attr "prefix_data16" "1,*")
19637 (set_attr "prefix" "orig,vex")
19638 (set_attr "mode" "TI")])
19639
19640 (define_insn "avx512bw_interleave_high<mode><mask_name>"
19641 [(set (match_operand:V32_512 0 "register_operand" "=v")
19642 (vec_select:V32_512
19643 (vec_concat:<ssedoublevecmode>
19644 (match_operand:V32_512 1 "register_operand" "v")
19645 (match_operand:V32_512 2 "nonimmediate_operand" "vm"))
19646 (parallel [(const_int 4) (const_int 36)
19647 (const_int 5) (const_int 37)
19648 (const_int 6) (const_int 38)
19649 (const_int 7) (const_int 39)
19650 (const_int 12) (const_int 44)
19651 (const_int 13) (const_int 45)
19652 (const_int 14) (const_int 46)
19653 (const_int 15) (const_int 47)
19654 (const_int 20) (const_int 52)
19655 (const_int 21) (const_int 53)
19656 (const_int 22) (const_int 54)
19657 (const_int 23) (const_int 55)
19658 (const_int 28) (const_int 60)
19659 (const_int 29) (const_int 61)
19660 (const_int 30) (const_int 62)
19661 (const_int 31) (const_int 63)])))]
19662 "TARGET_AVX512BW"
19663 "vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19664 [(set_attr "type" "sselog")
19665 (set_attr "prefix" "evex")
19666 (set_attr "mode" "XI")])
19667
19668 (define_insn "avx2_interleave_high<mode><mask_name>"
19669 [(set (match_operand:V16_256 0 "register_operand" "=Yw")
19670 (vec_select:V16_256
19671 (vec_concat:<ssedoublevecmode>
19672 (match_operand:V16_256 1 "register_operand" "Yw")
19673 (match_operand:V16_256 2 "nonimmediate_operand" "Ywm"))
19674 (parallel [(const_int 4) (const_int 20)
19675 (const_int 5) (const_int 21)
19676 (const_int 6) (const_int 22)
19677 (const_int 7) (const_int 23)
19678 (const_int 12) (const_int 28)
19679 (const_int 13) (const_int 29)
19680 (const_int 14) (const_int 30)
19681 (const_int 15) (const_int 31)])))]
19682 "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
19683 "vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19684 [(set_attr "type" "sselog")
19685 (set_attr "prefix" "maybe_evex")
19686 (set_attr "mode" "OI")])
19687
19688 (define_insn "@vec_interleave_high<mode><mask_name>"
19689 [(set (match_operand:V8_128 0 "register_operand" "=x,Yw")
19690 (vec_select:V8_128
19691 (vec_concat:<ssedoublevecmode>
19692 (match_operand:V8_128 1 "register_operand" "0,Yw")
19693 (match_operand:V8_128 2 "vector_operand" "xBm,Ywm"))
19694 (parallel [(const_int 4) (const_int 12)
19695 (const_int 5) (const_int 13)
19696 (const_int 6) (const_int 14)
19697 (const_int 7) (const_int 15)])))]
19698 "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
19699 "@
19700 punpckhwd\t{%2, %0|%0, %2}
19701 vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19702 [(set_attr "isa" "noavx,avx")
19703 (set_attr "type" "sselog")
19704 (set_attr "prefix_data16" "1,*")
19705 (set_attr "prefix" "orig,maybe_vex")
19706 (set_attr "mode" "TI")])
19707
19708 (define_insn "<mask_codefor>avx512bw_interleave_low<mode><mask_name>"
19709 [(set (match_operand:V32_512 0 "register_operand" "=v")
19710 (vec_select:V32_512
19711 (vec_concat:<ssedoublevecmode>
19712 (match_operand:V32_512 1 "register_operand" "v")
19713 (match_operand:V32_512 2 "nonimmediate_operand" "vm"))
19714 (parallel [(const_int 0) (const_int 32)
19715 (const_int 1) (const_int 33)
19716 (const_int 2) (const_int 34)
19717 (const_int 3) (const_int 35)
19718 (const_int 8) (const_int 40)
19719 (const_int 9) (const_int 41)
19720 (const_int 10) (const_int 42)
19721 (const_int 11) (const_int 43)
19722 (const_int 16) (const_int 48)
19723 (const_int 17) (const_int 49)
19724 (const_int 18) (const_int 50)
19725 (const_int 19) (const_int 51)
19726 (const_int 24) (const_int 56)
19727 (const_int 25) (const_int 57)
19728 (const_int 26) (const_int 58)
19729 (const_int 27) (const_int 59)])))]
19730 "TARGET_AVX512BW"
19731 "vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19732 [(set_attr "type" "sselog")
19733 (set_attr "prefix" "evex")
19734 (set_attr "mode" "XI")])
19735
19736 (define_insn "avx2_interleave_low<mode><mask_name>"
19737 [(set (match_operand:V16_256 0 "register_operand" "=Yw")
19738 (vec_select:V16_256
19739 (vec_concat:<ssedoublevecmode>
19740 (match_operand:V16_256 1 "register_operand" "Yw")
19741 (match_operand:V16_256 2 "nonimmediate_operand" "Ywm"))
19742 (parallel [(const_int 0) (const_int 16)
19743 (const_int 1) (const_int 17)
19744 (const_int 2) (const_int 18)
19745 (const_int 3) (const_int 19)
19746 (const_int 8) (const_int 24)
19747 (const_int 9) (const_int 25)
19748 (const_int 10) (const_int 26)
19749 (const_int 11) (const_int 27)])))]
19750 "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
19751 "vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19752 [(set_attr "type" "sselog")
19753 (set_attr "prefix" "maybe_evex")
19754 (set_attr "mode" "OI")])
19755
19756 (define_insn "@vec_interleave_low<mode><mask_name>"
19757 [(set (match_operand:V8_128 0 "register_operand" "=x,Yw")
19758 (vec_select:V8_128
19759 (vec_concat:<ssedoublevecmode>
19760 (match_operand:V8_128 1 "register_operand" "0,Yw")
19761 (match_operand:V8_128 2 "vector_operand" "xBm,Ywm"))
19762 (parallel [(const_int 0) (const_int 8)
19763 (const_int 1) (const_int 9)
19764 (const_int 2) (const_int 10)
19765 (const_int 3) (const_int 11)])))]
19766 "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
19767 "@
19768 punpcklwd\t{%2, %0|%0, %2}
19769 vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19770 [(set_attr "isa" "noavx,avx")
19771 (set_attr "type" "sselog")
19772 (set_attr "prefix_data16" "1,*")
19773 (set_attr "prefix" "orig,maybe_evex")
19774 (set_attr "mode" "TI")])
19775
19776 (define_insn "avx2_interleave_highv8si<mask_name>"
19777 [(set (match_operand:V8SI 0 "register_operand" "=v")
19778 (vec_select:V8SI
19779 (vec_concat:V16SI
19780 (match_operand:V8SI 1 "register_operand" "v")
19781 (match_operand:V8SI 2 "nonimmediate_operand" "vm"))
19782 (parallel [(const_int 2) (const_int 10)
19783 (const_int 3) (const_int 11)
19784 (const_int 6) (const_int 14)
19785 (const_int 7) (const_int 15)])))]
19786 "TARGET_AVX2 && <mask_avx512vl_condition>"
19787 "vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19788 [(set_attr "type" "sselog")
19789 (set_attr "prefix" "maybe_evex")
19790 (set_attr "mode" "OI")])
19791
19792 (define_insn "<mask_codefor>avx512f_interleave_highv16si<mask_name>"
19793 [(set (match_operand:V16SI 0 "register_operand" "=v")
19794 (vec_select:V16SI
19795 (vec_concat:V32SI
19796 (match_operand:V16SI 1 "register_operand" "v")
19797 (match_operand:V16SI 2 "nonimmediate_operand" "vm"))
19798 (parallel [(const_int 2) (const_int 18)
19799 (const_int 3) (const_int 19)
19800 (const_int 6) (const_int 22)
19801 (const_int 7) (const_int 23)
19802 (const_int 10) (const_int 26)
19803 (const_int 11) (const_int 27)
19804 (const_int 14) (const_int 30)
19805 (const_int 15) (const_int 31)])))]
19806 "TARGET_AVX512F && TARGET_EVEX512"
19807 "vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19808 [(set_attr "type" "sselog")
19809 (set_attr "prefix" "evex")
19810 (set_attr "mode" "XI")])
19811
19812
19813 (define_insn "vec_interleave_highv4si<mask_name>"
19814 [(set (match_operand:V4SI 0 "register_operand" "=x,v")
19815 (vec_select:V4SI
19816 (vec_concat:V8SI
19817 (match_operand:V4SI 1 "register_operand" "0,v")
19818 (match_operand:V4SI 2 "vector_operand" "xBm,vm"))
19819 (parallel [(const_int 2) (const_int 6)
19820 (const_int 3) (const_int 7)])))]
19821 "TARGET_SSE2 && <mask_avx512vl_condition>"
19822 "@
19823 punpckhdq\t{%2, %0|%0, %2}
19824 vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19825 [(set_attr "isa" "noavx,avx")
19826 (set_attr "type" "sselog")
19827 (set_attr "prefix_data16" "1,*")
19828 (set_attr "prefix" "orig,maybe_vex")
19829 (set_attr "mode" "TI")])
19830
19831 (define_insn "avx2_interleave_lowv8si<mask_name>"
19832 [(set (match_operand:V8SI 0 "register_operand" "=v")
19833 (vec_select:V8SI
19834 (vec_concat:V16SI
19835 (match_operand:V8SI 1 "register_operand" "v")
19836 (match_operand:V8SI 2 "nonimmediate_operand" "vm"))
19837 (parallel [(const_int 0) (const_int 8)
19838 (const_int 1) (const_int 9)
19839 (const_int 4) (const_int 12)
19840 (const_int 5) (const_int 13)])))]
19841 "TARGET_AVX2 && <mask_avx512vl_condition>"
19842 "vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19843 [(set_attr "type" "sselog")
19844 (set_attr "prefix" "maybe_evex")
19845 (set_attr "mode" "OI")])
19846
19847 (define_insn "<mask_codefor>avx512f_interleave_lowv16si<mask_name>"
19848 [(set (match_operand:V16SI 0 "register_operand" "=v")
19849 (vec_select:V16SI
19850 (vec_concat:V32SI
19851 (match_operand:V16SI 1 "register_operand" "v")
19852 (match_operand:V16SI 2 "nonimmediate_operand" "vm"))
19853 (parallel [(const_int 0) (const_int 16)
19854 (const_int 1) (const_int 17)
19855 (const_int 4) (const_int 20)
19856 (const_int 5) (const_int 21)
19857 (const_int 8) (const_int 24)
19858 (const_int 9) (const_int 25)
19859 (const_int 12) (const_int 28)
19860 (const_int 13) (const_int 29)])))]
19861 "TARGET_AVX512F && TARGET_EVEX512"
19862 "vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19863 [(set_attr "type" "sselog")
19864 (set_attr "prefix" "evex")
19865 (set_attr "mode" "XI")])
19866
19867 (define_insn "vec_interleave_lowv4si<mask_name>"
19868 [(set (match_operand:V4SI 0 "register_operand" "=x,v")
19869 (vec_select:V4SI
19870 (vec_concat:V8SI
19871 (match_operand:V4SI 1 "register_operand" "0,v")
19872 (match_operand:V4SI 2 "vector_operand" "xBm,vm"))
19873 (parallel [(const_int 0) (const_int 4)
19874 (const_int 1) (const_int 5)])))]
19875 "TARGET_SSE2 && <mask_avx512vl_condition>"
19876 "@
19877 punpckldq\t{%2, %0|%0, %2}
19878 vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19879 [(set_attr "isa" "noavx,avx")
19880 (set_attr "type" "sselog")
19881 (set_attr "prefix_data16" "1,*")
19882 (set_attr "prefix" "orig,vex")
19883 (set_attr "mode" "TI")])
19884
19885 (define_expand "vec_interleave_high<mode>"
19886 [(match_operand:VI_256 0 "register_operand")
19887 (match_operand:VI_256 1 "register_operand")
19888 (match_operand:VI_256 2 "nonimmediate_operand")]
19889 "TARGET_AVX2"
19890 {
19891 rtx t1 = gen_reg_rtx (<MODE>mode);
19892 rtx t2 = gen_reg_rtx (<MODE>mode);
19893 rtx t3 = gen_reg_rtx (V4DImode);
19894 emit_insn (gen_avx2_interleave_low<mode> (t1, operands[1], operands[2]));
19895 emit_insn (gen_avx2_interleave_high<mode> (t2, operands[1], operands[2]));
19896 emit_insn (gen_avx2_permv2ti (t3, gen_lowpart (V4DImode, t1),
19897 gen_lowpart (V4DImode, t2),
19898 GEN_INT (1 + (3 << 4))));
19899 emit_move_insn (operands[0], gen_lowpart (<MODE>mode, t3));
19900 DONE;
19901 })
19902
19903 (define_expand "vec_interleave_low<mode>"
19904 [(match_operand:VI_256 0 "register_operand")
19905 (match_operand:VI_256 1 "register_operand")
19906 (match_operand:VI_256 2 "nonimmediate_operand")]
19907 "TARGET_AVX2"
19908 {
19909 rtx t1 = gen_reg_rtx (<MODE>mode);
19910 rtx t2 = gen_reg_rtx (<MODE>mode);
19911 rtx t3 = gen_reg_rtx (V4DImode);
19912 emit_insn (gen_avx2_interleave_low<mode> (t1, operands[1], operands[2]));
19913 emit_insn (gen_avx2_interleave_high<mode> (t2, operands[1], operands[2]));
19914 emit_insn (gen_avx2_permv2ti (t3, gen_lowpart (V4DImode, t1),
19915 gen_lowpart (V4DImode, t2),
19916 GEN_INT (0 + (2 << 4))));
19917 emit_move_insn (operands[0], gen_lowpart (<MODE>mode, t3));
19918 DONE;
19919 })
19920
19921 ;; Modes handled by pinsr patterns.
19922 (define_mode_iterator PINSR_MODE
19923 [(V16QI "TARGET_SSE4_1") V8HI V8HF V8BF
19924 (V4SI "TARGET_SSE4_1")
19925 (V2DI "TARGET_SSE4_1 && TARGET_64BIT")])
19926
19927 (define_mode_attr sse2p4_1
19928 [(V16QI "sse4_1") (V8HI "sse2") (V8HF "sse2")
19929 (V8BF "sse2") (V4SI "sse4_1") (V2DI "sse4_1")])
19930
19931 (define_mode_attr pinsr_evex_isa
19932 [(V16QI "avx512bw") (V8HI "avx512bw") (V8HF "avx512bw")
19933 (V8BF "avx512bw") (V4SI "avx512dq") (V2DI "avx512dq")])
19934
19935 ;; sse4_1_pinsrd must come before sse2_loadld since it is preferred.
19936 (define_insn "<sse2p4_1>_pinsr<ssemodesuffix>"
19937 [(set (match_operand:PINSR_MODE 0 "register_operand" "=x,x,x,x,v,v,&x")
19938 (vec_merge:PINSR_MODE
19939 (vec_duplicate:PINSR_MODE
19940 (match_operand:<ssescalarmode> 2 "nonimmediate_operand" "jr,jm,r,m,r,m,x"))
19941 (match_operand:PINSR_MODE 1 "register_operand" "0,0,x,x,v,v,x")
19942 (match_operand:SI 3 "const_int_operand")))]
19943 "TARGET_SSE2
19944 && ((unsigned) exact_log2 (INTVAL (operands[3]))
19945 < GET_MODE_NUNITS (<MODE>mode))"
19946 {
19947 HOST_WIDE_INT items = INTVAL (operands[3]);
19948
19949 operands[3] = GEN_INT (exact_log2 (items));
19950
19951 switch (which_alternative)
19952 {
19953 case 0:
19954 if (GET_MODE_SIZE (<ssescalarmode>mode) < GET_MODE_SIZE (SImode))
19955 return "pinsr<sseintmodesuffix>\t{%3, %k2, %0|%0, %k2, %3}";
19956 /* FALLTHRU */
19957 case 1:
19958 return "pinsr<sseintmodesuffix>\t{%3, %2, %0|%0, %2, %3}";
19959 case 2:
19960 case 4:
19961 if (GET_MODE_SIZE (<ssescalarmode>mode) < GET_MODE_SIZE (SImode))
19962 return "vpinsr<sseintmodesuffix>\t{%3, %k2, %1, %0|%0, %1, %k2, %3}";
19963 /* FALLTHRU */
19964 case 3:
19965 case 5:
19966 return "vpinsr<sseintmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
19967 case 6:
19968 /* This pattern needs to be shadowed with vec_set{v8hi,v8hf}_0. */
19969 gcc_assert (items > 1);
19970 return "#";
19971 default:
19972 gcc_unreachable ();
19973 }
19974 }
19975 [(set_attr "isa" "noavx,noavx,avx,avx,<pinsr_evex_isa>,<pinsr_evex_isa>,avx2")
19976 (set_attr "type" "sselog")
19977 (set_attr "c86_attr" "insr")
19978 (set (attr "addr")
19979 (if_then_else (eq_attr "alternative" "0,1")
19980 (const_string "gpr16")
19981 (const_string "*")))
19982 (set (attr "prefix_rex")
19983 (if_then_else
19984 (and (not (match_test "TARGET_AVX"))
19985 (match_test "GET_MODE_NUNITS (<MODE>mode) == 2"))
19986 (const_string "1")
19987 (const_string "*")))
19988 (set (attr "prefix_extra")
19989 (if_then_else
19990 (ior (eq_attr "prefix" "evex")
19991 (match_test "GET_MODE_NUNITS (<MODE>mode) == 8"))
19992 (const_string "*")
19993 (const_string "1")))
19994 (set_attr "length_immediate" "1")
19995 (set_attr "prefix" "orig,orig,vex,vex,evex,evex,vex")
19996 (set_attr "mode" "TI")
19997 (set (attr "enabled")
19998 (cond [(and (not (match_test "GET_MODE_NUNITS (<MODE>mode) == 8"))
19999 (eq_attr "alternative" "6"))
20000 (symbol_ref "false")
20001 ]
20002 (const_string "*")))])
20003
20004 ;; For TARGET_AVX2, implement insert from XMM reg with PBROADCASTW + PBLENDW.
20005 (define_split
20006 [(set (match_operand:V8_128 0 "sse_reg_operand")
20007 (vec_merge:V8_128
20008 (vec_duplicate:V8_128
20009 (match_operand:<ssescalarmode> 2 "sse_reg_operand"))
20010 (match_operand:V8_128 1 "sse_reg_operand")
20011 (match_operand:SI 3 "const_int_operand")))]
20012 "TARGET_AVX2 && reload_completed
20013 && INTVAL (operands[3]) > 1
20014 && ((unsigned) exact_log2 (INTVAL (operands[3]))
20015 < GET_MODE_NUNITS (<MODE>mode))"
20016 [(set (match_dup 0)
20017 (vec_duplicate:V8_128 (match_dup 2)))
20018 (set (match_dup 0)
20019 (vec_merge:V8_128 (match_dup 0) (match_dup 1) (match_dup 3)))])
20020
20021 (define_expand "<extract_type>_vinsert<shuffletype><extract_suf>_mask"
20022 [(match_operand:AVX512_VEC 0 "register_operand")
20023 (match_operand:AVX512_VEC 1 "register_operand")
20024 (match_operand:<ssequartermode> 2 "nonimmediate_operand")
20025 (match_operand:SI 3 "const_0_to_3_operand")
20026 (match_operand:AVX512_VEC 4 "register_operand")
20027 (match_operand:<avx512fmaskmode> 5 "register_operand")]
20028 "TARGET_AVX512F"
20029 {
20030 int mask, selector;
20031 mask = INTVAL (operands[3]);
20032 selector = (GET_MODE_UNIT_SIZE (<MODE>mode) == 4
20033 ? 0xFFFF ^ (0x000F << mask * 4)
20034 : 0xFF ^ (0x03 << mask * 2));
20035 emit_insn (gen_<extract_type>_vinsert<shuffletype><extract_suf>_1_mask
20036 (operands[0], operands[1], operands[2], GEN_INT (selector),
20037 operands[4], operands[5]));
20038 DONE;
20039 })
20040
20041 (define_insn "*<extract_type>_vinsert<shuffletype><extract_suf>_0"
20042 [(set (match_operand:AVX512_VEC 0 "register_operand" "=v,x,Yv")
20043 (vec_merge:AVX512_VEC
20044 (vec_duplicate:AVX512_VEC
20045 (match_operand:<ssequartermode> 1 "nonimmediate_operand" "vm,xm,vm"))
20046 (match_operand:AVX512_VEC 2 "reg_or_0_operand" "v,C,C")
20047 (match_operand:SI 3 "const_int_operand")))]
20048 "TARGET_AVX512F
20049 && (INTVAL (operands[3])
20050 == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xF : 0x3))"
20051 {
20052 if (which_alternative == 0)
20053 return "vinsert<shuffletype><extract_suf>\t{$0, %1, %2, %0|%0, %2, %1, 0}";
20054 bool egpr_used = (TARGET_APX_EGPR
20055 && x86_extended_rex2reg_mentioned_p (operands[1]));
20056 const char *align_templ = egpr_used ? "vmovaps\t{%1, %x0|%x0, %1}"
20057 : "vmovdqa\t{%1, %x0|%x0, %1}";
20058 const char *unalign_templ = egpr_used ? "vmovups\t{%1, %x0|%x0, %1}"
20059 : "vmovdqu\t{%1, %x0|%x0, %1}";
20060 switch (<MODE>mode)
20061 {
20062 case E_V8DFmode:
20063 if (misaligned_operand (operands[1], <ssequartermode>mode))
20064 return "vmovupd\t{%1, %x0|%x0, %1}";
20065 else
20066 return "vmovapd\t{%1, %x0|%x0, %1}";
20067 case E_V16SFmode:
20068 if (misaligned_operand (operands[1], <ssequartermode>mode))
20069 return "vmovups\t{%1, %x0|%x0, %1}";
20070 else
20071 return "vmovaps\t{%1, %x0|%x0, %1}";
20072 case E_V8DImode:
20073 if (misaligned_operand (operands[1], <ssequartermode>mode))
20074 return which_alternative == 2 ? "vmovdqu64\t{%1, %x0|%x0, %1}"
20075 : unalign_templ;
20076 else
20077 return which_alternative == 2 ? "vmovdqa64\t{%1, %x0|%x0, %1}"
20078 : align_templ;
20079 case E_V16SImode:
20080 if (misaligned_operand (operands[1], <ssequartermode>mode))
20081 return which_alternative == 2 ? "vmovdqu32\t{%1, %x0|%x0, %1}"
20082 : unalign_templ;
20083 else
20084 return which_alternative == 2 ? "vmovdqa32\t{%1, %x0|%x0, %1}"
20085 : align_templ;
20086 default:
20087 gcc_unreachable ();
20088 }
20089 }
20090 [(set_attr "type" "sselog,ssemov,ssemov")
20091 (set_attr "c86_attr" "insertx,*,*")
20092 (set_attr "length_immediate" "1,0,0")
20093 (set_attr "prefix" "evex,vex,evex")
20094 (set_attr "mode" "<sseinsnmode>,<ssequarterinsnmode>,<ssequarterinsnmode>")])
20095
20096 (define_insn "<mask_codefor><extract_type>_vinsert<shuffletype><extract_suf>_1<mask_name>"
20097 [(set (match_operand:AVX512_VEC 0 "register_operand" "=v")
20098 (vec_merge:AVX512_VEC
20099 (match_operand:AVX512_VEC 1 "register_operand" "v")
20100 (vec_duplicate:AVX512_VEC
20101 (match_operand:<ssequartermode> 2 "nonimmediate_operand" "vm"))
20102 (match_operand:SI 3 "const_int_operand")))]
20103 "TARGET_AVX512F"
20104 {
20105 int mask;
20106 int selector = INTVAL (operands[3]);
20107
20108 if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xFFF0 : 0xFC))
20109 mask = 0;
20110 else if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xFF0F : 0xF3))
20111 mask = 1;
20112 else if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xF0FF : 0xCF))
20113 mask = 2;
20114 else if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0x0FFF : 0x3F))
20115 mask = 3;
20116 else
20117 gcc_unreachable ();
20118
20119 operands[3] = GEN_INT (mask);
20120
20121 return "vinsert<shuffletype><extract_suf>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}";
20122 }
20123 [(set_attr "type" "sselog")
20124 (set_attr "c86_attr" "insertx")
20125 (set_attr "length_immediate" "1")
20126 (set_attr "prefix" "evex")
20127 (set_attr "mode" "<sseinsnmode>")])
20128
20129 (define_expand "<extract_type_2>_vinsert<shuffletype><extract_suf_2>_mask"
20130 [(match_operand:AVX512_VEC_2 0 "register_operand")
20131 (match_operand:AVX512_VEC_2 1 "register_operand")
20132 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
20133 (match_operand:SI 3 "const_0_to_1_operand")
20134 (match_operand:AVX512_VEC_2 4 "register_operand")
20135 (match_operand:<avx512fmaskmode> 5 "register_operand")]
20136 "TARGET_AVX512F"
20137 {
20138 int mask = INTVAL (operands[3]);
20139 if (mask == 0)
20140 emit_insn (gen_vec_set_lo_<mode>_mask (operands[0], operands[1],
20141 operands[2], operands[4],
20142 operands[5]));
20143 else
20144 emit_insn (gen_vec_set_hi_<mode>_mask (operands[0], operands[1],
20145 operands[2], operands[4],
20146 operands[5]));
20147 DONE;
20148 })
20149
20150 (define_insn "vec_set_lo_<mode><mask_name>"
20151 [(set (match_operand:V16FI 0 "register_operand" "=v")
20152 (vec_concat:V16FI
20153 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
20154 (vec_select:<ssehalfvecmode>
20155 (match_operand:V16FI 1 "register_operand" "v")
20156 (parallel [(const_int 8) (const_int 9)
20157 (const_int 10) (const_int 11)
20158 (const_int 12) (const_int 13)
20159 (const_int 14) (const_int 15)]))))]
20160 "TARGET_AVX512DQ"
20161 "vinsert<shuffletype>32x8\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}"
20162 [(set_attr "type" "sselog")
20163 (set_attr "c86_attr" "insertx")
20164 (set_attr "length_immediate" "1")
20165 (set_attr "prefix" "evex")
20166 (set_attr "mode" "<sseinsnmode>")])
20167
20168 (define_insn "vec_set_hi_<mode><mask_name>"
20169 [(set (match_operand:V16FI 0 "register_operand" "=v")
20170 (vec_concat:V16FI
20171 (vec_select:<ssehalfvecmode>
20172 (match_operand:V16FI 1 "register_operand" "v")
20173 (parallel [(const_int 0) (const_int 1)
20174 (const_int 2) (const_int 3)
20175 (const_int 4) (const_int 5)
20176 (const_int 6) (const_int 7)]))
20177 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
20178 "TARGET_AVX512DQ"
20179 "vinsert<shuffletype>32x8\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}"
20180 [(set_attr "type" "sselog")
20181 (set_attr "c86_attr" "insertx")
20182 (set_attr "length_immediate" "1")
20183 (set_attr "prefix" "evex")
20184 (set_attr "mode" "<sseinsnmode>")])
20185
20186 (define_insn "vec_set_lo_<mode><mask_name>"
20187 [(set (match_operand:V8FI 0 "register_operand" "=v")
20188 (vec_concat:V8FI
20189 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
20190 (vec_select:<ssehalfvecmode>
20191 (match_operand:V8FI 1 "register_operand" "v")
20192 (parallel [(const_int 4) (const_int 5)
20193 (const_int 6) (const_int 7)]))))]
20194 "TARGET_AVX512F"
20195 "vinsert<shuffletype>64x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}"
20196 [(set_attr "type" "sselog")
20197 (set_attr "c86_attr" "insertx")
20198 (set_attr "length_immediate" "1")
20199 (set_attr "prefix" "evex")
20200 (set_attr "mode" "XI")])
20201
20202 (define_insn "vec_set_hi_<mode><mask_name>"
20203 [(set (match_operand:V8FI 0 "register_operand" "=v")
20204 (vec_concat:V8FI
20205 (vec_select:<ssehalfvecmode>
20206 (match_operand:V8FI 1 "register_operand" "v")
20207 (parallel [(const_int 0) (const_int 1)
20208 (const_int 2) (const_int 3)]))
20209 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
20210 "TARGET_AVX512F"
20211 "vinsert<shuffletype>64x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}"
20212 [(set_attr "type" "sselog")
20213 (set_attr "c86_attr" "insertx")
20214 (set_attr "length_immediate" "1")
20215 (set_attr "prefix" "evex")
20216 (set_attr "mode" "XI")])
20217
20218 (define_expand "avx512dq_shuf_<shuffletype>64x2_mask"
20219 [(match_operand:VI8F_256 0 "register_operand")
20220 (match_operand:VI8F_256 1 "register_operand")
20221 (match_operand:VI8F_256 2 "nonimmediate_operand")
20222 (match_operand:SI 3 "const_0_to_3_operand")
20223 (match_operand:VI8F_256 4 "register_operand")
20224 (match_operand:QI 5 "register_operand")]
20225 "TARGET_AVX512DQ"
20226 {
20227 int mask = INTVAL (operands[3]);
20228 emit_insn (gen_avx512dq_shuf_<shuffletype>64x2_1_mask
20229 (operands[0], operands[1], operands[2],
20230 GEN_INT (((mask >> 0) & 1) * 2 + 0),
20231 GEN_INT (((mask >> 0) & 1) * 2 + 1),
20232 GEN_INT (((mask >> 1) & 1) * 2 + 4),
20233 GEN_INT (((mask >> 1) & 1) * 2 + 5),
20234 operands[4], operands[5]));
20235 DONE;
20236 })
20237
20238 (define_insn "<mask_codefor>avx512dq_shuf_<shuffletype>64x2_1<mask_name>"
20239 [(set (match_operand:VI8F_256 0 "register_operand" "=x,v")
20240 (vec_select:VI8F_256
20241 (vec_concat:<ssedoublevecmode>
20242 (match_operand:VI8F_256 1 "register_operand" "x,v")
20243 (match_operand:VI8F_256 2 "nonimmediate_operand" "xjm,vm"))
20244 (parallel [(match_operand 3 "const_0_to_3_operand")
20245 (match_operand 4 "const_0_to_3_operand")
20246 (match_operand 5 "const_4_to_7_operand")
20247 (match_operand 6 "const_4_to_7_operand")])))]
20248 "TARGET_AVX512VL
20249 && (INTVAL (operands[3]) & 1) == 0
20250 && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
20251 && (INTVAL (operands[5]) & 1) == 0
20252 && INTVAL (operands[5]) == INTVAL (operands[6]) - 1"
20253 {
20254 int mask;
20255 mask = INTVAL (operands[3]) / 2;
20256 mask |= (INTVAL (operands[5]) - 4) / 2 << 1;
20257 operands[3] = GEN_INT (mask);
20258 if (INTVAL (operands[3]) == 2 && !<mask_applied> && which_alternative == 0)
20259 return "vblendps\t{$240, %2, %1, %0|%0, %1, %2, 240}";
20260 return "vshuf<shuffletype>64x2\t{%3, %2, %1, %0<mask_operand7>|%0<mask_operand7>, %1, %2, %3}";
20261 }
20262 [(set_attr "type" "sselog")
20263 (set_attr "c86_attr" "shufx")
20264 (set_attr "addr" "gpr16,*")
20265 (set_attr "length_immediate" "1")
20266 (set_attr "prefix" "evex")
20267 (set_attr "mode" "XI")])
20268
20269 (define_expand "avx512f_shuf_<shuffletype>64x2_mask"
20270 [(match_operand:V8FI 0 "register_operand")
20271 (match_operand:V8FI 1 "register_operand")
20272 (match_operand:V8FI 2 "nonimmediate_operand")
20273 (match_operand:SI 3 "const_0_to_255_operand")
20274 (match_operand:V8FI 4 "register_operand")
20275 (match_operand:QI 5 "register_operand")]
20276 "TARGET_AVX512F"
20277 {
20278 int mask = INTVAL (operands[3]);
20279 emit_insn (gen_avx512f_shuf_<shuffletype>64x2_1_mask
20280 (operands[0], operands[1], operands[2],
20281 GEN_INT (((mask >> 0) & 3) * 2),
20282 GEN_INT (((mask >> 0) & 3) * 2 + 1),
20283 GEN_INT (((mask >> 2) & 3) * 2),
20284 GEN_INT (((mask >> 2) & 3) * 2 + 1),
20285 GEN_INT (((mask >> 4) & 3) * 2 + 8),
20286 GEN_INT (((mask >> 4) & 3) * 2 + 9),
20287 GEN_INT (((mask >> 6) & 3) * 2 + 8),
20288 GEN_INT (((mask >> 6) & 3) * 2 + 9),
20289 operands[4], operands[5]));
20290 DONE;
20291 })
20292
20293 (define_insn "avx512f_shuf_<shuffletype>64x2_1<mask_name>"
20294 [(set (match_operand:V8FI 0 "register_operand" "=v")
20295 (vec_select:V8FI
20296 (vec_concat:<ssedoublevecmode>
20297 (match_operand:V8FI 1 "register_operand" "v")
20298 (match_operand:V8FI 2 "nonimmediate_operand" "vm"))
20299 (parallel [(match_operand 3 "const_0_to_7_operand")
20300 (match_operand 4 "const_0_to_7_operand")
20301 (match_operand 5 "const_0_to_7_operand")
20302 (match_operand 6 "const_0_to_7_operand")
20303 (match_operand 7 "const_8_to_15_operand")
20304 (match_operand 8 "const_8_to_15_operand")
20305 (match_operand 9 "const_8_to_15_operand")
20306 (match_operand 10 "const_8_to_15_operand")])))]
20307 "TARGET_AVX512F
20308 && (INTVAL (operands[3]) & 1) == 0
20309 && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
20310 && (INTVAL (operands[5]) & 1) == 0
20311 && INTVAL (operands[5]) == INTVAL (operands[6]) - 1
20312 && (INTVAL (operands[7]) & 1) == 0
20313 && INTVAL (operands[7]) == INTVAL (operands[8]) - 1
20314 && (INTVAL (operands[9]) & 1) == 0
20315 && INTVAL (operands[9]) == INTVAL (operands[10]) - 1"
20316 {
20317 int mask;
20318 mask = INTVAL (operands[3]) / 2;
20319 mask |= INTVAL (operands[5]) / 2 << 2;
20320 mask |= (INTVAL (operands[7]) - 8) / 2 << 4;
20321 mask |= (INTVAL (operands[9]) - 8) / 2 << 6;
20322 operands[3] = GEN_INT (mask);
20323
20324 return "vshuf<shuffletype>64x2\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
20325 }
20326 [(set_attr "type" "sselog")
20327 (set_attr "c86_attr" "shufx")
20328 (set_attr "length_immediate" "1")
20329 (set_attr "prefix" "evex")
20330 (set_attr "mode" "<sseinsnmode>")])
20331
20332 (define_insn "*avx512f_shuf_<shuffletype>64x2_1<mask_name>_1"
20333 [(set (match_operand:V8FI 0 "register_operand" "=v")
20334 (vec_select:V8FI
20335 (match_operand:V8FI 1 "register_operand" "v")
20336 (parallel [(match_operand 2 "const_0_to_7_operand")
20337 (match_operand 3 "const_0_to_7_operand")
20338 (match_operand 4 "const_0_to_7_operand")
20339 (match_operand 5 "const_0_to_7_operand")
20340 (match_operand 6 "const_0_to_7_operand")
20341 (match_operand 7 "const_0_to_7_operand")
20342 (match_operand 8 "const_0_to_7_operand")
20343 (match_operand 9 "const_0_to_7_operand")])))]
20344 "TARGET_AVX512F
20345 && (INTVAL (operands[2]) & 1) == 0
20346 && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
20347 && (INTVAL (operands[4]) & 1) == 0
20348 && INTVAL (operands[4]) == INTVAL (operands[5]) - 1
20349 && (INTVAL (operands[6]) & 1) == 0
20350 && INTVAL (operands[6]) == INTVAL (operands[7]) - 1
20351 && (INTVAL (operands[8]) & 1) == 0
20352 && INTVAL (operands[8]) == INTVAL (operands[9]) - 1"
20353 {
20354 int mask;
20355 mask = INTVAL (operands[2]) / 2;
20356 mask |= INTVAL (operands[4]) / 2 << 2;
20357 mask |= INTVAL (operands[6]) / 2 << 4;
20358 mask |= INTVAL (operands[8]) / 2 << 6;
20359 operands[2] = GEN_INT (mask);
20360
20361 return "vshuf<shuffletype>64x2\t{%2, %1, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %1, %2}";
20362 }
20363 [(set_attr "type" "sselog")
20364 (set_attr "c86_attr" "shufx")
20365 (set_attr "length_immediate" "1")
20366 (set_attr "prefix" "evex")
20367 (set_attr "mode" "<sseinsnmode>")])
20368
20369 (define_expand "avx512vl_shuf_<shuffletype>32x4_mask"
20370 [(match_operand:VI4F_256 0 "register_operand")
20371 (match_operand:VI4F_256 1 "register_operand")
20372 (match_operand:VI4F_256 2 "nonimmediate_operand")
20373 (match_operand:SI 3 "const_0_to_3_operand")
20374 (match_operand:VI4F_256 4 "register_operand")
20375 (match_operand:QI 5 "register_operand")]
20376 "TARGET_AVX512VL"
20377 {
20378 int mask = INTVAL (operands[3]);
20379 emit_insn (gen_avx512vl_shuf_<shuffletype>32x4_1_mask
20380 (operands[0], operands[1], operands[2],
20381 GEN_INT (((mask >> 0) & 1) * 4 + 0),
20382 GEN_INT (((mask >> 0) & 1) * 4 + 1),
20383 GEN_INT (((mask >> 0) & 1) * 4 + 2),
20384 GEN_INT (((mask >> 0) & 1) * 4 + 3),
20385 GEN_INT (((mask >> 1) & 1) * 4 + 8),
20386 GEN_INT (((mask >> 1) & 1) * 4 + 9),
20387 GEN_INT (((mask >> 1) & 1) * 4 + 10),
20388 GEN_INT (((mask >> 1) & 1) * 4 + 11),
20389 operands[4], operands[5]));
20390 DONE;
20391 })
20392
20393 (define_insn "avx512vl_shuf_<shuffletype>32x4_1<mask_name>"
20394 [(set (match_operand:VI4F_256 0 "register_operand" "=x,v")
20395 (vec_select:VI4F_256
20396 (vec_concat:<ssedoublevecmode>
20397 (match_operand:VI4F_256 1 "register_operand" "x,v")
20398 (match_operand:VI4F_256 2 "nonimmediate_operand" "xjm,vm"))
20399 (parallel [(match_operand 3 "const_0_to_7_operand")
20400 (match_operand 4 "const_0_to_7_operand")
20401 (match_operand 5 "const_0_to_7_operand")
20402 (match_operand 6 "const_0_to_7_operand")
20403 (match_operand 7 "const_8_to_15_operand")
20404 (match_operand 8 "const_8_to_15_operand")
20405 (match_operand 9 "const_8_to_15_operand")
20406 (match_operand 10 "const_8_to_15_operand")])))]
20407 "TARGET_AVX512VL
20408 && (INTVAL (operands[3]) & 3) == 0
20409 && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
20410 && INTVAL (operands[3]) == INTVAL (operands[5]) - 2
20411 && INTVAL (operands[3]) == INTVAL (operands[6]) - 3
20412 && (INTVAL (operands[7]) & 3) == 0
20413 && INTVAL (operands[7]) == INTVAL (operands[8]) - 1
20414 && INTVAL (operands[7]) == INTVAL (operands[9]) - 2
20415 && INTVAL (operands[7]) == INTVAL (operands[10]) - 3"
20416 {
20417 int mask;
20418 mask = INTVAL (operands[3]) / 4;
20419 mask |= (INTVAL (operands[7]) - 8) / 4 << 1;
20420 operands[3] = GEN_INT (mask);
20421
20422 if (INTVAL (operands[3]) == 2 && !<mask_applied> && which_alternative == 0)
20423 return "vblendps\t{$240, %2, %1, %0|%0, %1, %2, 240}";
20424
20425 return "vshuf<shuffletype>32x4\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
20426 }
20427 [(set_attr "type" "sselog")
20428 (set_attr "c86_attr" "shufx")
20429 (set_attr "addr" "gpr16,*")
20430 (set_attr "length_immediate" "1")
20431 (set_attr "prefix" "evex")
20432 (set_attr "mode" "<sseinsnmode>")])
20433
20434 (define_expand "avx512f_shuf_<shuffletype>32x4_mask"
20435 [(match_operand:V16FI 0 "register_operand")
20436 (match_operand:V16FI 1 "register_operand")
20437 (match_operand:V16FI 2 "nonimmediate_operand")
20438 (match_operand:SI 3 "const_0_to_255_operand")
20439 (match_operand:V16FI 4 "register_operand")
20440 (match_operand:HI 5 "register_operand")]
20441 "TARGET_AVX512F"
20442 {
20443 int mask = INTVAL (operands[3]);
20444 emit_insn (gen_avx512f_shuf_<shuffletype>32x4_1_mask
20445 (operands[0], operands[1], operands[2],
20446 GEN_INT (((mask >> 0) & 3) * 4),
20447 GEN_INT (((mask >> 0) & 3) * 4 + 1),
20448 GEN_INT (((mask >> 0) & 3) * 4 + 2),
20449 GEN_INT (((mask >> 0) & 3) * 4 + 3),
20450 GEN_INT (((mask >> 2) & 3) * 4),
20451 GEN_INT (((mask >> 2) & 3) * 4 + 1),
20452 GEN_INT (((mask >> 2) & 3) * 4 + 2),
20453 GEN_INT (((mask >> 2) & 3) * 4 + 3),
20454 GEN_INT (((mask >> 4) & 3) * 4 + 16),
20455 GEN_INT (((mask >> 4) & 3) * 4 + 17),
20456 GEN_INT (((mask >> 4) & 3) * 4 + 18),
20457 GEN_INT (((mask >> 4) & 3) * 4 + 19),
20458 GEN_INT (((mask >> 6) & 3) * 4 + 16),
20459 GEN_INT (((mask >> 6) & 3) * 4 + 17),
20460 GEN_INT (((mask >> 6) & 3) * 4 + 18),
20461 GEN_INT (((mask >> 6) & 3) * 4 + 19),
20462 operands[4], operands[5]));
20463 DONE;
20464 })
20465
20466 (define_insn "avx512f_shuf_<shuffletype>32x4_1<mask_name>"
20467 [(set (match_operand:V16FI 0 "register_operand" "=v")
20468 (vec_select:V16FI
20469 (vec_concat:<ssedoublevecmode>
20470 (match_operand:V16FI 1 "register_operand" "v")
20471 (match_operand:V16FI 2 "nonimmediate_operand" "vm"))
20472 (parallel [(match_operand 3 "const_0_to_15_operand")
20473 (match_operand 4 "const_0_to_15_operand")
20474 (match_operand 5 "const_0_to_15_operand")
20475 (match_operand 6 "const_0_to_15_operand")
20476 (match_operand 7 "const_0_to_15_operand")
20477 (match_operand 8 "const_0_to_15_operand")
20478 (match_operand 9 "const_0_to_15_operand")
20479 (match_operand 10 "const_0_to_15_operand")
20480 (match_operand 11 "const_16_to_31_operand")
20481 (match_operand 12 "const_16_to_31_operand")
20482 (match_operand 13 "const_16_to_31_operand")
20483 (match_operand 14 "const_16_to_31_operand")
20484 (match_operand 15 "const_16_to_31_operand")
20485 (match_operand 16 "const_16_to_31_operand")
20486 (match_operand 17 "const_16_to_31_operand")
20487 (match_operand 18 "const_16_to_31_operand")])))]
20488 "TARGET_AVX512F
20489 && (INTVAL (operands[3]) & 3) == 0
20490 && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
20491 && INTVAL (operands[3]) == INTVAL (operands[5]) - 2
20492 && INTVAL (operands[3]) == INTVAL (operands[6]) - 3
20493 && (INTVAL (operands[7]) & 3) == 0
20494 && INTVAL (operands[7]) == INTVAL (operands[8]) - 1
20495 && INTVAL (operands[7]) == INTVAL (operands[9]) - 2
20496 && INTVAL (operands[7]) == INTVAL (operands[10]) - 3
20497 && (INTVAL (operands[11]) & 3) == 0
20498 && INTVAL (operands[11]) == INTVAL (operands[12]) - 1
20499 && INTVAL (operands[11]) == INTVAL (operands[13]) - 2
20500 && INTVAL (operands[11]) == INTVAL (operands[14]) - 3
20501 && (INTVAL (operands[15]) & 3) == 0
20502 && INTVAL (operands[15]) == INTVAL (operands[16]) - 1
20503 && INTVAL (operands[15]) == INTVAL (operands[17]) - 2
20504 && INTVAL (operands[15]) == INTVAL (operands[18]) - 3"
20505 {
20506 int mask;
20507 mask = INTVAL (operands[3]) / 4;
20508 mask |= INTVAL (operands[7]) / 4 << 2;
20509 mask |= (INTVAL (operands[11]) - 16) / 4 << 4;
20510 mask |= (INTVAL (operands[15]) - 16) / 4 << 6;
20511 operands[3] = GEN_INT (mask);
20512
20513 return "vshuf<shuffletype>32x4\t{%3, %2, %1, %0<mask_operand19>|%0<mask_operand19>, %1, %2, %3}";
20514 }
20515 [(set_attr "type" "sselog")
20516 (set_attr "c86_attr" "shufx")
20517 (set_attr "length_immediate" "1")
20518 (set_attr "prefix" "evex")
20519 (set_attr "mode" "<sseinsnmode>")])
20520
20521 (define_insn "*avx512f_shuf_<shuffletype>32x4_1<mask_name>_1"
20522 [(set (match_operand:V16FI 0 "register_operand" "=v")
20523 (vec_select:V16FI
20524 (match_operand:V16FI 1 "register_operand" "v")
20525 (parallel [(match_operand 2 "const_0_to_15_operand")
20526 (match_operand 3 "const_0_to_15_operand")
20527 (match_operand 4 "const_0_to_15_operand")
20528 (match_operand 5 "const_0_to_15_operand")
20529 (match_operand 6 "const_0_to_15_operand")
20530 (match_operand 7 "const_0_to_15_operand")
20531 (match_operand 8 "const_0_to_15_operand")
20532 (match_operand 9 "const_0_to_15_operand")
20533 (match_operand 10 "const_0_to_15_operand")
20534 (match_operand 11 "const_0_to_15_operand")
20535 (match_operand 12 "const_0_to_15_operand")
20536 (match_operand 13 "const_0_to_15_operand")
20537 (match_operand 14 "const_0_to_15_operand")
20538 (match_operand 15 "const_0_to_15_operand")
20539 (match_operand 16 "const_0_to_15_operand")
20540 (match_operand 17 "const_0_to_15_operand")])))]
20541 "TARGET_AVX512F
20542 && (INTVAL (operands[2]) & 3) == 0
20543 && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
20544 && INTVAL (operands[2]) == INTVAL (operands[4]) - 2
20545 && INTVAL (operands[2]) == INTVAL (operands[5]) - 3
20546 && (INTVAL (operands[6]) & 3) == 0
20547 && INTVAL (operands[6]) == INTVAL (operands[7]) - 1
20548 && INTVAL (operands[6]) == INTVAL (operands[8]) - 2
20549 && INTVAL (operands[6]) == INTVAL (operands[9]) - 3
20550 && (INTVAL (operands[10]) & 3) == 0
20551 && INTVAL (operands[10]) == INTVAL (operands[11]) - 1
20552 && INTVAL (operands[10]) == INTVAL (operands[12]) - 2
20553 && INTVAL (operands[10]) == INTVAL (operands[13]) - 3
20554 && (INTVAL (operands[14]) & 3) == 0
20555 && INTVAL (operands[14]) == INTVAL (operands[15]) - 1
20556 && INTVAL (operands[14]) == INTVAL (operands[16]) - 2
20557 && INTVAL (operands[14]) == INTVAL (operands[17]) - 3"
20558 {
20559 int mask;
20560 mask = INTVAL (operands[2]) / 4;
20561 mask |= INTVAL (operands[6]) / 4 << 2;
20562 mask |= INTVAL (operands[10]) / 4 << 4;
20563 mask |= INTVAL (operands[14]) / 4 << 6;
20564 operands[2] = GEN_INT (mask);
20565
20566 return "vshuf<shuffletype>32x4\t{%2, %1, %1, %0<mask_operand18>|%0<mask_operand18>, %1, %1, %2}";
20567 }
20568 [(set_attr "type" "sselog")
20569 (set_attr "c86_attr" "shufx")
20570 (set_attr "length_immediate" "1")
20571 (set_attr "prefix" "evex")
20572 (set_attr "mode" "<sseinsnmode>")])
20573
20574 (define_expand "avx512f_pshufdv3_mask"
20575 [(match_operand:V16SI 0 "register_operand")
20576 (match_operand:V16SI 1 "nonimmediate_operand")
20577 (match_operand:SI 2 "const_0_to_255_operand")
20578 (match_operand:V16SI 3 "register_operand")
20579 (match_operand:HI 4 "register_operand")]
20580 "TARGET_AVX512F && TARGET_EVEX512"
20581 {
20582 int mask = INTVAL (operands[2]);
20583 emit_insn (gen_avx512f_pshufd_1_mask (operands[0], operands[1],
20584 GEN_INT ((mask >> 0) & 3),
20585 GEN_INT ((mask >> 2) & 3),
20586 GEN_INT ((mask >> 4) & 3),
20587 GEN_INT ((mask >> 6) & 3),
20588 GEN_INT (((mask >> 0) & 3) + 4),
20589 GEN_INT (((mask >> 2) & 3) + 4),
20590 GEN_INT (((mask >> 4) & 3) + 4),
20591 GEN_INT (((mask >> 6) & 3) + 4),
20592 GEN_INT (((mask >> 0) & 3) + 8),
20593 GEN_INT (((mask >> 2) & 3) + 8),
20594 GEN_INT (((mask >> 4) & 3) + 8),
20595 GEN_INT (((mask >> 6) & 3) + 8),
20596 GEN_INT (((mask >> 0) & 3) + 12),
20597 GEN_INT (((mask >> 2) & 3) + 12),
20598 GEN_INT (((mask >> 4) & 3) + 12),
20599 GEN_INT (((mask >> 6) & 3) + 12),
20600 operands[3], operands[4]));
20601 DONE;
20602 })
20603
20604 (define_insn "avx512f_pshufd_1<mask_name>"
20605 [(set (match_operand:V16SI 0 "register_operand" "=v")
20606 (vec_select:V16SI
20607 (match_operand:V16SI 1 "nonimmediate_operand" "vm")
20608 (parallel [(match_operand 2 "const_0_to_3_operand")
20609 (match_operand 3 "const_0_to_3_operand")
20610 (match_operand 4 "const_0_to_3_operand")
20611 (match_operand 5 "const_0_to_3_operand")
20612 (match_operand 6 "const_4_to_7_operand")
20613 (match_operand 7 "const_4_to_7_operand")
20614 (match_operand 8 "const_4_to_7_operand")
20615 (match_operand 9 "const_4_to_7_operand")
20616 (match_operand 10 "const_8_to_11_operand")
20617 (match_operand 11 "const_8_to_11_operand")
20618 (match_operand 12 "const_8_to_11_operand")
20619 (match_operand 13 "const_8_to_11_operand")
20620 (match_operand 14 "const_12_to_15_operand")
20621 (match_operand 15 "const_12_to_15_operand")
20622 (match_operand 16 "const_12_to_15_operand")
20623 (match_operand 17 "const_12_to_15_operand")])))]
20624 "TARGET_AVX512F && TARGET_EVEX512
20625 && INTVAL (operands[2]) + 4 == INTVAL (operands[6])
20626 && INTVAL (operands[3]) + 4 == INTVAL (operands[7])
20627 && INTVAL (operands[4]) + 4 == INTVAL (operands[8])
20628 && INTVAL (operands[5]) + 4 == INTVAL (operands[9])
20629 && INTVAL (operands[2]) + 8 == INTVAL (operands[10])
20630 && INTVAL (operands[3]) + 8 == INTVAL (operands[11])
20631 && INTVAL (operands[4]) + 8 == INTVAL (operands[12])
20632 && INTVAL (operands[5]) + 8 == INTVAL (operands[13])
20633 && INTVAL (operands[2]) + 12 == INTVAL (operands[14])
20634 && INTVAL (operands[3]) + 12 == INTVAL (operands[15])
20635 && INTVAL (operands[4]) + 12 == INTVAL (operands[16])
20636 && INTVAL (operands[5]) + 12 == INTVAL (operands[17])"
20637 {
20638 int mask = 0;
20639 mask |= INTVAL (operands[2]) << 0;
20640 mask |= INTVAL (operands[3]) << 2;
20641 mask |= INTVAL (operands[4]) << 4;
20642 mask |= INTVAL (operands[5]) << 6;
20643 operands[2] = GEN_INT (mask);
20644
20645 return "vpshufd\t{%2, %1, %0<mask_operand18>|%0<mask_operand18>, %1, %2}";
20646 }
20647 [(set_attr "type" "sselog1")
20648 (set_attr "prefix" "evex")
20649 (set_attr "length_immediate" "1")
20650 (set_attr "mode" "XI")])
20651
20652 (define_expand "avx512vl_pshufdv3_mask"
20653 [(match_operand:V8SI 0 "register_operand")
20654 (match_operand:V8SI 1 "nonimmediate_operand")
20655 (match_operand:SI 2 "const_0_to_255_operand")
20656 (match_operand:V8SI 3 "register_operand")
20657 (match_operand:QI 4 "register_operand")]
20658 "TARGET_AVX512VL"
20659 {
20660 int mask = INTVAL (operands[2]);
20661 emit_insn (gen_avx2_pshufd_1_mask (operands[0], operands[1],
20662 GEN_INT ((mask >> 0) & 3),
20663 GEN_INT ((mask >> 2) & 3),
20664 GEN_INT ((mask >> 4) & 3),
20665 GEN_INT ((mask >> 6) & 3),
20666 GEN_INT (((mask >> 0) & 3) + 4),
20667 GEN_INT (((mask >> 2) & 3) + 4),
20668 GEN_INT (((mask >> 4) & 3) + 4),
20669 GEN_INT (((mask >> 6) & 3) + 4),
20670 operands[3], operands[4]));
20671 DONE;
20672 })
20673
20674 (define_expand "avx2_pshufdv3"
20675 [(match_operand:V8SI 0 "register_operand")
20676 (match_operand:V8SI 1 "nonimmediate_operand")
20677 (match_operand:SI 2 "const_0_to_255_operand")]
20678 "TARGET_AVX2"
20679 {
20680 int mask = INTVAL (operands[2]);
20681 emit_insn (gen_avx2_pshufd_1 (operands[0], operands[1],
20682 GEN_INT ((mask >> 0) & 3),
20683 GEN_INT ((mask >> 2) & 3),
20684 GEN_INT ((mask >> 4) & 3),
20685 GEN_INT ((mask >> 6) & 3),
20686 GEN_INT (((mask >> 0) & 3) + 4),
20687 GEN_INT (((mask >> 2) & 3) + 4),
20688 GEN_INT (((mask >> 4) & 3) + 4),
20689 GEN_INT (((mask >> 6) & 3) + 4)));
20690 DONE;
20691 })
20692
20693 (define_insn "avx2_pshufd_1<mask_name>"
20694 [(set (match_operand:V8SI 0 "register_operand" "=v")
20695 (vec_select:V8SI
20696 (match_operand:V8SI 1 "nonimmediate_operand" "vm")
20697 (parallel [(match_operand 2 "const_0_to_3_operand")
20698 (match_operand 3 "const_0_to_3_operand")
20699 (match_operand 4 "const_0_to_3_operand")
20700 (match_operand 5 "const_0_to_3_operand")
20701 (match_operand 6 "const_4_to_7_operand")
20702 (match_operand 7 "const_4_to_7_operand")
20703 (match_operand 8 "const_4_to_7_operand")
20704 (match_operand 9 "const_4_to_7_operand")])))]
20705 "TARGET_AVX2
20706 && <mask_avx512vl_condition>
20707 && INTVAL (operands[2]) + 4 == INTVAL (operands[6])
20708 && INTVAL (operands[3]) + 4 == INTVAL (operands[7])
20709 && INTVAL (operands[4]) + 4 == INTVAL (operands[8])
20710 && INTVAL (operands[5]) + 4 == INTVAL (operands[9])"
20711 {
20712 int mask = 0;
20713 mask |= INTVAL (operands[2]) << 0;
20714 mask |= INTVAL (operands[3]) << 2;
20715 mask |= INTVAL (operands[4]) << 4;
20716 mask |= INTVAL (operands[5]) << 6;
20717 operands[2] = GEN_INT (mask);
20718
20719 return "vpshufd\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
20720 }
20721 [(set_attr "type" "sselog1")
20722 (set_attr "prefix" "maybe_evex")
20723 (set_attr "length_immediate" "1")
20724 (set_attr "mode" "OI")])
20725
20726 (define_expand "avx512vl_pshufd_mask"
20727 [(match_operand:V4SI 0 "register_operand")
20728 (match_operand:V4SI 1 "nonimmediate_operand")
20729 (match_operand:SI 2 "const_0_to_255_operand")
20730 (match_operand:V4SI 3 "register_operand")
20731 (match_operand:QI 4 "register_operand")]
20732 "TARGET_AVX512VL"
20733 {
20734 int mask = INTVAL (operands[2]);
20735 emit_insn (gen_sse2_pshufd_1_mask (operands[0], operands[1],
20736 GEN_INT ((mask >> 0) & 3),
20737 GEN_INT ((mask >> 2) & 3),
20738 GEN_INT ((mask >> 4) & 3),
20739 GEN_INT ((mask >> 6) & 3),
20740 operands[3], operands[4]));
20741 DONE;
20742 })
20743
20744 (define_expand "sse2_pshufd"
20745 [(match_operand:V4SI 0 "register_operand")
20746 (match_operand:V4SI 1 "vector_operand")
20747 (match_operand:SI 2 "const_int_operand")]
20748 "TARGET_SSE2"
20749 {
20750 int mask = INTVAL (operands[2]);
20751 emit_insn (gen_sse2_pshufd_1 (operands[0], operands[1],
20752 GEN_INT ((mask >> 0) & 3),
20753 GEN_INT ((mask >> 2) & 3),
20754 GEN_INT ((mask >> 4) & 3),
20755 GEN_INT ((mask >> 6) & 3)));
20756 DONE;
20757 })
20758
20759 (define_insn "sse2_pshufd_1<mask_name>"
20760 [(set (match_operand:V4SI 0 "register_operand" "=v")
20761 (vec_select:V4SI
20762 (match_operand:V4SI 1 "vector_operand" "vBm")
20763 (parallel [(match_operand 2 "const_0_to_3_operand")
20764 (match_operand 3 "const_0_to_3_operand")
20765 (match_operand 4 "const_0_to_3_operand")
20766 (match_operand 5 "const_0_to_3_operand")])))]
20767 "TARGET_SSE2 && <mask_avx512vl_condition>"
20768 {
20769 int mask = 0;
20770 mask |= INTVAL (operands[2]) << 0;
20771 mask |= INTVAL (operands[3]) << 2;
20772 mask |= INTVAL (operands[4]) << 4;
20773 mask |= INTVAL (operands[5]) << 6;
20774 operands[2] = GEN_INT (mask);
20775
20776 return "%vpshufd\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
20777 }
20778 [(set_attr "type" "sselog1")
20779 (set_attr "prefix_data16" "1")
20780 (set_attr "prefix" "<mask_prefix2>")
20781 (set_attr "length_immediate" "1")
20782 (set_attr "mode" "TI")])
20783
20784 (define_insn "<mask_codefor>avx512bw_pshuflwv32hi<mask_name>"
20785 [(set (match_operand:V32HI 0 "register_operand" "=v")
20786 (unspec:V32HI
20787 [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
20788 (match_operand:SI 2 "const_0_to_255_operand")]
20789 UNSPEC_PSHUFLW))]
20790 "TARGET_AVX512BW && TARGET_EVEX512"
20791 "vpshuflw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
20792 [(set_attr "type" "sselog")
20793 (set_attr "prefix" "evex")
20794 (set_attr "mode" "XI")])
20795
20796 (define_expand "avx512vl_pshuflwv3_mask"
20797 [(match_operand:V16HI 0 "register_operand")
20798 (match_operand:V16HI 1 "nonimmediate_operand")
20799 (match_operand:SI 2 "const_0_to_255_operand")
20800 (match_operand:V16HI 3 "register_operand")
20801 (match_operand:HI 4 "register_operand")]
20802 "TARGET_AVX512VL && TARGET_AVX512BW"
20803 {
20804 int mask = INTVAL (operands[2]);
20805 emit_insn (gen_avx2_pshuflw_1_mask (operands[0], operands[1],
20806 GEN_INT ((mask >> 0) & 3),
20807 GEN_INT ((mask >> 2) & 3),
20808 GEN_INT ((mask >> 4) & 3),
20809 GEN_INT ((mask >> 6) & 3),
20810 GEN_INT (((mask >> 0) & 3) + 8),
20811 GEN_INT (((mask >> 2) & 3) + 8),
20812 GEN_INT (((mask >> 4) & 3) + 8),
20813 GEN_INT (((mask >> 6) & 3) + 8),
20814 operands[3], operands[4]));
20815 DONE;
20816 })
20817
20818 (define_expand "avx2_pshuflwv3"
20819 [(match_operand:V16HI 0 "register_operand")
20820 (match_operand:V16HI 1 "nonimmediate_operand")
20821 (match_operand:SI 2 "const_0_to_255_operand")]
20822 "TARGET_AVX2"
20823 {
20824 int mask = INTVAL (operands[2]);
20825 emit_insn (gen_avx2_pshuflw_1 (operands[0], operands[1],
20826 GEN_INT ((mask >> 0) & 3),
20827 GEN_INT ((mask >> 2) & 3),
20828 GEN_INT ((mask >> 4) & 3),
20829 GEN_INT ((mask >> 6) & 3),
20830 GEN_INT (((mask >> 0) & 3) + 8),
20831 GEN_INT (((mask >> 2) & 3) + 8),
20832 GEN_INT (((mask >> 4) & 3) + 8),
20833 GEN_INT (((mask >> 6) & 3) + 8)));
20834 DONE;
20835 })
20836
20837 (define_insn "avx2_pshuflw_1<mask_name>"
20838 [(set (match_operand:V16HI 0 "register_operand" "=Yw")
20839 (vec_select:V16HI
20840 (match_operand:V16HI 1 "nonimmediate_operand" "Ywm")
20841 (parallel [(match_operand 2 "const_0_to_3_operand")
20842 (match_operand 3 "const_0_to_3_operand")
20843 (match_operand 4 "const_0_to_3_operand")
20844 (match_operand 5 "const_0_to_3_operand")
20845 (const_int 4)
20846 (const_int 5)
20847 (const_int 6)
20848 (const_int 7)
20849 (match_operand 6 "const_8_to_11_operand")
20850 (match_operand 7 "const_8_to_11_operand")
20851 (match_operand 8 "const_8_to_11_operand")
20852 (match_operand 9 "const_8_to_11_operand")
20853 (const_int 12)
20854 (const_int 13)
20855 (const_int 14)
20856 (const_int 15)])))]
20857 "TARGET_AVX2
20858 && <mask_avx512bw_condition> && <mask_avx512vl_condition>
20859 && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
20860 && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
20861 && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
20862 && INTVAL (operands[5]) + 8 == INTVAL (operands[9])"
20863 {
20864 int mask = 0;
20865 mask |= INTVAL (operands[2]) << 0;
20866 mask |= INTVAL (operands[3]) << 2;
20867 mask |= INTVAL (operands[4]) << 4;
20868 mask |= INTVAL (operands[5]) << 6;
20869 operands[2] = GEN_INT (mask);
20870
20871 return "vpshuflw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
20872 }
20873 [(set_attr "type" "sselog")
20874 (set_attr "prefix" "maybe_evex")
20875 (set_attr "length_immediate" "1")
20876 (set_attr "mode" "OI")])
20877
20878 (define_expand "avx512vl_pshuflw_mask"
20879 [(match_operand:V8HI 0 "register_operand")
20880 (match_operand:V8HI 1 "nonimmediate_operand")
20881 (match_operand:SI 2 "const_0_to_255_operand")
20882 (match_operand:V8HI 3 "register_operand")
20883 (match_operand:QI 4 "register_operand")]
20884 "TARGET_AVX512VL && TARGET_AVX512BW"
20885 {
20886 int mask = INTVAL (operands[2]);
20887 emit_insn (gen_sse2_pshuflw_1_mask (operands[0], operands[1],
20888 GEN_INT ((mask >> 0) & 3),
20889 GEN_INT ((mask >> 2) & 3),
20890 GEN_INT ((mask >> 4) & 3),
20891 GEN_INT ((mask >> 6) & 3),
20892 operands[3], operands[4]));
20893 DONE;
20894 })
20895
20896 (define_expand "sse2_pshuflw"
20897 [(match_operand:V8HI 0 "register_operand")
20898 (match_operand:V8HI 1 "vector_operand")
20899 (match_operand:SI 2 "const_int_operand")]
20900 "TARGET_SSE2"
20901 {
20902 int mask = INTVAL (operands[2]);
20903 emit_insn (gen_sse2_pshuflw_1 (operands[0], operands[1],
20904 GEN_INT ((mask >> 0) & 3),
20905 GEN_INT ((mask >> 2) & 3),
20906 GEN_INT ((mask >> 4) & 3),
20907 GEN_INT ((mask >> 6) & 3)));
20908 DONE;
20909 })
20910
20911 (define_insn "sse2_pshuflw_1<mask_name>"
20912 [(set (match_operand:V8HI 0 "register_operand" "=Yw")
20913 (vec_select:V8HI
20914 (match_operand:V8HI 1 "vector_operand" "YwBm")
20915 (parallel [(match_operand 2 "const_0_to_3_operand")
20916 (match_operand 3 "const_0_to_3_operand")
20917 (match_operand 4 "const_0_to_3_operand")
20918 (match_operand 5 "const_0_to_3_operand")
20919 (const_int 4)
20920 (const_int 5)
20921 (const_int 6)
20922 (const_int 7)])))]
20923 "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
20924 {
20925 int mask = 0;
20926 mask |= INTVAL (operands[2]) << 0;
20927 mask |= INTVAL (operands[3]) << 2;
20928 mask |= INTVAL (operands[4]) << 4;
20929 mask |= INTVAL (operands[5]) << 6;
20930 operands[2] = GEN_INT (mask);
20931
20932 return "%vpshuflw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
20933 }
20934 [(set_attr "type" "sselog")
20935 (set_attr "prefix_data16" "0")
20936 (set_attr "prefix_rep" "1")
20937 (set_attr "prefix" "maybe_vex")
20938 (set_attr "length_immediate" "1")
20939 (set_attr "mode" "TI")])
20940
20941 (define_expand "avx2_pshufhwv3"
20942 [(match_operand:V16HI 0 "register_operand")
20943 (match_operand:V16HI 1 "nonimmediate_operand")
20944 (match_operand:SI 2 "const_0_to_255_operand")]
20945 "TARGET_AVX2"
20946 {
20947 int mask = INTVAL (operands[2]);
20948 emit_insn (gen_avx2_pshufhw_1 (operands[0], operands[1],
20949 GEN_INT (((mask >> 0) & 3) + 4),
20950 GEN_INT (((mask >> 2) & 3) + 4),
20951 GEN_INT (((mask >> 4) & 3) + 4),
20952 GEN_INT (((mask >> 6) & 3) + 4),
20953 GEN_INT (((mask >> 0) & 3) + 12),
20954 GEN_INT (((mask >> 2) & 3) + 12),
20955 GEN_INT (((mask >> 4) & 3) + 12),
20956 GEN_INT (((mask >> 6) & 3) + 12)));
20957 DONE;
20958 })
20959
20960 (define_insn "<mask_codefor>avx512bw_pshufhwv32hi<mask_name>"
20961 [(set (match_operand:V32HI 0 "register_operand" "=v")
20962 (unspec:V32HI
20963 [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
20964 (match_operand:SI 2 "const_0_to_255_operand")]
20965 UNSPEC_PSHUFHW))]
20966 "TARGET_AVX512BW && TARGET_EVEX512"
20967 "vpshufhw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
20968 [(set_attr "type" "sselog")
20969 (set_attr "prefix" "evex")
20970 (set_attr "mode" "XI")])
20971
20972 (define_expand "avx512vl_pshufhwv3_mask"
20973 [(match_operand:V16HI 0 "register_operand")
20974 (match_operand:V16HI 1 "nonimmediate_operand")
20975 (match_operand:SI 2 "const_0_to_255_operand")
20976 (match_operand:V16HI 3 "register_operand")
20977 (match_operand:HI 4 "register_operand")]
20978 "TARGET_AVX512VL && TARGET_AVX512BW"
20979 {
20980 int mask = INTVAL (operands[2]);
20981 emit_insn (gen_avx2_pshufhw_1_mask (operands[0], operands[1],
20982 GEN_INT (((mask >> 0) & 3) + 4),
20983 GEN_INT (((mask >> 2) & 3) + 4),
20984 GEN_INT (((mask >> 4) & 3) + 4),
20985 GEN_INT (((mask >> 6) & 3) + 4),
20986 GEN_INT (((mask >> 0) & 3) + 12),
20987 GEN_INT (((mask >> 2) & 3) + 12),
20988 GEN_INT (((mask >> 4) & 3) + 12),
20989 GEN_INT (((mask >> 6) & 3) + 12),
20990 operands[3], operands[4]));
20991 DONE;
20992 })
20993
20994 (define_insn "avx2_pshufhw_1<mask_name>"
20995 [(set (match_operand:V16HI 0 "register_operand" "=Yw")
20996 (vec_select:V16HI
20997 (match_operand:V16HI 1 "nonimmediate_operand" "Ywm")
20998 (parallel [(const_int 0)
20999 (const_int 1)
21000 (const_int 2)
21001 (const_int 3)
21002 (match_operand 2 "const_4_to_7_operand")
21003 (match_operand 3 "const_4_to_7_operand")
21004 (match_operand 4 "const_4_to_7_operand")
21005 (match_operand 5 "const_4_to_7_operand")
21006 (const_int 8)
21007 (const_int 9)
21008 (const_int 10)
21009 (const_int 11)
21010 (match_operand 6 "const_12_to_15_operand")
21011 (match_operand 7 "const_12_to_15_operand")
21012 (match_operand 8 "const_12_to_15_operand")
21013 (match_operand 9 "const_12_to_15_operand")])))]
21014 "TARGET_AVX2
21015 && <mask_avx512bw_condition> && <mask_avx512vl_condition>
21016 && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
21017 && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
21018 && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
21019 && INTVAL (operands[5]) + 8 == INTVAL (operands[9])"
21020 {
21021 int mask = 0;
21022 mask |= (INTVAL (operands[2]) - 4) << 0;
21023 mask |= (INTVAL (operands[3]) - 4) << 2;
21024 mask |= (INTVAL (operands[4]) - 4) << 4;
21025 mask |= (INTVAL (operands[5]) - 4) << 6;
21026 operands[2] = GEN_INT (mask);
21027
21028 return "vpshufhw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
21029 }
21030 [(set_attr "type" "sselog")
21031 (set_attr "prefix" "maybe_evex")
21032 (set_attr "length_immediate" "1")
21033 (set_attr "mode" "OI")])
21034
21035 (define_expand "avx512vl_pshufhw_mask"
21036 [(match_operand:V8HI 0 "register_operand")
21037 (match_operand:V8HI 1 "nonimmediate_operand")
21038 (match_operand:SI 2 "const_0_to_255_operand")
21039 (match_operand:V8HI 3 "register_operand")
21040 (match_operand:QI 4 "register_operand")]
21041 "TARGET_AVX512VL && TARGET_AVX512BW"
21042 {
21043 int mask = INTVAL (operands[2]);
21044 emit_insn (gen_sse2_pshufhw_1_mask (operands[0], operands[1],
21045 GEN_INT (((mask >> 0) & 3) + 4),
21046 GEN_INT (((mask >> 2) & 3) + 4),
21047 GEN_INT (((mask >> 4) & 3) + 4),
21048 GEN_INT (((mask >> 6) & 3) + 4),
21049 operands[3], operands[4]));
21050 DONE;
21051 })
21052
21053 (define_expand "sse2_pshufhw"
21054 [(match_operand:V8HI 0 "register_operand")
21055 (match_operand:V8HI 1 "vector_operand")
21056 (match_operand:SI 2 "const_int_operand")]
21057 "TARGET_SSE2"
21058 {
21059 int mask = INTVAL (operands[2]);
21060 emit_insn (gen_sse2_pshufhw_1 (operands[0], operands[1],
21061 GEN_INT (((mask >> 0) & 3) + 4),
21062 GEN_INT (((mask >> 2) & 3) + 4),
21063 GEN_INT (((mask >> 4) & 3) + 4),
21064 GEN_INT (((mask >> 6) & 3) + 4)));
21065 DONE;
21066 })
21067
21068 (define_insn "sse2_pshufhw_1<mask_name>"
21069 [(set (match_operand:V8HI 0 "register_operand" "=Yw")
21070 (vec_select:V8HI
21071 (match_operand:V8HI 1 "vector_operand" "YwBm")
21072 (parallel [(const_int 0)
21073 (const_int 1)
21074 (const_int 2)
21075 (const_int 3)
21076 (match_operand 2 "const_4_to_7_operand")
21077 (match_operand 3 "const_4_to_7_operand")
21078 (match_operand 4 "const_4_to_7_operand")
21079 (match_operand 5 "const_4_to_7_operand")])))]
21080 "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
21081 {
21082 int mask = 0;
21083 mask |= (INTVAL (operands[2]) - 4) << 0;
21084 mask |= (INTVAL (operands[3]) - 4) << 2;
21085 mask |= (INTVAL (operands[4]) - 4) << 4;
21086 mask |= (INTVAL (operands[5]) - 4) << 6;
21087 operands[2] = GEN_INT (mask);
21088
21089 return "%vpshufhw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
21090 }
21091 [(set_attr "type" "sselog")
21092 (set_attr "prefix_rep" "1")
21093 (set_attr "prefix_data16" "0")
21094 (set_attr "prefix" "maybe_vex")
21095 (set_attr "length_immediate" "1")
21096 (set_attr "mode" "TI")])
21097
21098 (define_expand "sse2_loadd"
21099 [(set (match_operand:V4SI 0 "register_operand")
21100 (vec_merge:V4SI
21101 (vec_duplicate:V4SI
21102 (match_operand:SI 1 "nonimmediate_operand"))
21103 (match_dup 2)
21104 (const_int 1)))]
21105 "TARGET_SSE"
21106 "operands[2] = CONST0_RTX (V4SImode);")
21107
21108 (define_insn "sse2_loadld"
21109 [(set (match_operand:V4SI 0 "register_operand" "=v,v,x,x,v")
21110 (vec_merge:V4SI
21111 (vec_duplicate:V4SI
21112 (match_operand:SI 2 "nonimmediate_operand" "m ,r ,m,x,v"))
21113 (match_operand:V4SI 1 "reg_or_0_operand" "C ,C ,C,0,v")
21114 (const_int 1)))]
21115 "TARGET_SSE"
21116 "@
21117 %vmovd\t{%2, %0|%0, %2}
21118 %vmovd\t{%2, %0|%0, %2}
21119 movss\t{%2, %0|%0, %2}
21120 movss\t{%2, %0|%0, %2}
21121 vmovss\t{%2, %1, %0|%0, %1, %2}"
21122 [(set_attr "isa" "sse2,sse2,noavx,noavx,avx")
21123 (set_attr "type" "ssemov")
21124 (set_attr "prefix" "maybe_vex,maybe_vex,orig,orig,maybe_evex")
21125 (set_attr "mode" "TI,TI,V4SF,SF,SF")
21126 (set (attr "preferred_for_speed")
21127 (cond [(eq_attr "alternative" "1")
21128 (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
21129 ]
21130 (symbol_ref "true")))])
21131
21132 ;; QI and HI modes handled by pextr patterns.
21133 (define_mode_iterator PEXTR_MODE12
21134 [(V16QI "TARGET_SSE4_1") V8HI])
21135
21136 (define_insn_and_split "*vec_extract<mode>_0_mem"
21137 [(set (match_operand:<ssescalarmode> 0 "memory_operand")
21138 (vec_select:<ssescalarmode>
21139 (match_operand:PEXTR_MODE12 1 "register_operand")
21140 (parallel [(const_int 0)])))]
21141 "TARGET_SSE2
21142 && !TARGET_SSE4_1
21143 && (TARGET_INTER_UNIT_MOVES_FROM_VEC
21144 || optimize_function_for_speed_p (cfun))
21145 && ix86_pre_reload_split ()"
21146 "#"
21147 "&& 1"
21148 [(set (match_dup 2) (match_dup 3))
21149 (set (match_dup 0) (match_dup 4))]
21150 {
21151 operands[2] = gen_reg_rtx (SImode);
21152 operands[3] = gen_lowpart (SImode, force_reg (<MODE>mode, operands[1]));
21153 operands[4] = gen_lowpart (<ssescalarmode>mode, operands[2]);
21154 })
21155
21156 (define_mode_attr vi128_jr_r
21157 [(V16QI "jr") (V8HI "r")])
21158
21159 (define_insn "*vec_extract<mode>"
21160 [(set (match_operand:<ssescalarmode> 0 "register_sse4nonimm_operand" "=<vi128_jr_r>,r,jm,m")
21161 (vec_select:<ssescalarmode>
21162 (match_operand:PEXTR_MODE12 1 "register_operand" "YW,YW,YW,YW")
21163 (parallel
21164 [(match_operand:SI 2 "const_0_to_<ssescalarnummask>_operand")])))]
21165 "TARGET_SSE2"
21166 "@
21167 pextr<ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
21168 vpextr<ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
21169 pextr<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
21170 vpextr<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
21171 [(set_attr "isa" "sse2_noavx,avx,sse4_noavx,avx")
21172 (set_attr "addr" "*,*,gpr16,*")
21173 (set_attr "type" "sselog1")
21174 (set_attr "c86_attr" "extr")
21175 (set (attr "prefix_extra")
21176 (if_then_else
21177 (eq (const_string "<MODE>mode") (const_string "V8HImode"))
21178 (const_string "*")
21179 (const_string "1")))
21180 (set_attr "length_immediate" "1")
21181 (set_attr "prefix" "maybe_vex")
21182 (set_attr "mode" "TI")])
21183
21184 (define_insn "*vec_extract<PEXTR_MODE12:mode>_zext"
21185 [(set (match_operand:SWI48 0 "register_operand" "=<vi128_jr_r>,r")
21186 (zero_extend:SWI48
21187 (vec_select:<PEXTR_MODE12:ssescalarmode>
21188 (match_operand:PEXTR_MODE12 1 "register_operand" "YW,YW")
21189 (parallel
21190 [(match_operand:SI 2
21191 "const_0_to_<PEXTR_MODE12:ssescalarnummask>_operand")]))))]
21192 "TARGET_SSE2"
21193 "%vpextr<PEXTR_MODE12:ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}"
21194 [(set_attr "isa" "noavx,avx")
21195 (set_attr "type" "sselog1")
21196 (set_attr "c86_attr" "extr")
21197 (set (attr "prefix_extra")
21198 (if_then_else
21199 (eq (const_string "<PEXTR_MODE12:MODE>mode") (const_string "V8HImode"))
21200 (const_string "*")
21201 (const_string "1")))
21202 (set_attr "length_immediate" "1")
21203 (set_attr "prefix" "maybe_vex")
21204 (set_attr "mode" "TI")])
21205
21206 (define_insn "*vec_extractv16qi_zext"
21207 [(set (match_operand:HI 0 "register_operand" "=jr,r")
21208 (zero_extend:HI
21209 (vec_select:QI
21210 (match_operand:V16QI 1 "register_operand" "YW,YW")
21211 (parallel
21212 [(match_operand:SI 2 "const_0_to_15_operand")]))))]
21213 "TARGET_SSE4_1"
21214 "%vpextrb\t{%2, %1, %k0|%k0, %1, %2}"
21215 [(set_attr "isa" "noavx,avx")
21216 (set_attr "type" "sselog1")
21217 (set_attr "c86_attr" "extr")
21218 (set_attr "prefix_extra" "1")
21219 (set_attr "length_immediate" "1")
21220 (set_attr "prefix" "maybe_vex")
21221 (set_attr "mode" "TI")])
21222
21223 (define_insn "*vec_extract<mode>_mem"
21224 [(set (match_operand:<ssescalarmode> 0 "register_operand" "=r")
21225 (vec_select:<ssescalarmode>
21226 (match_operand:VI12_128 1 "memory_operand" "o")
21227 (parallel
21228 [(match_operand 2 "const_0_to_<ssescalarnummask>_operand")])))]
21229 "TARGET_SSE"
21230 "#")
21231
21232 (define_insn "*vec_extract<ssevecmodelower>_0"
21233 [(set (match_operand:SWI48 0 "nonimmediate_operand" "=r,r,v ,m")
21234 (vec_select:SWI48
21235 (match_operand:<ssevecmode> 1 "nonimmediate_operand" "m ,v,vm,v")
21236 (parallel [(const_int 0)])))]
21237 "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
21238 "#"
21239 [(set_attr "isa" "*,sse2,*,*")
21240 (set (attr "preferred_for_speed")
21241 (cond [(eq_attr "alternative" "1")
21242 (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
21243 ]
21244 (symbol_ref "true")))])
21245
21246 (define_insn "*vec_extractv2di_0_sse"
21247 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,x ,m")
21248 (vec_select:DI
21249 (match_operand:V2DI 1 "nonimmediate_operand" " x,xm,x")
21250 (parallel [(const_int 0)])))]
21251 "TARGET_SSE && !TARGET_64BIT
21252 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
21253 "#"
21254 [(set_attr "isa" "sse4,*,*")
21255 (set (attr "preferred_for_speed")
21256 (cond [(eq_attr "alternative" "0")
21257 (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
21258 ]
21259 (symbol_ref "true")))])
21260
21261 (define_split
21262 [(set (match_operand:DI 0 "general_reg_operand")
21263 (vec_select:DI
21264 (match_operand:V2DI 1 "register_operand")
21265 (parallel [(const_int 0)])))]
21266 "TARGET_SSE4_1 && !TARGET_64BIT
21267 && reload_completed"
21268 [(set (match_dup 2) (match_dup 4))
21269 (set (match_dup 3)
21270 (vec_select:SI
21271 (match_dup 5)
21272 (parallel [(const_int 1)])))]
21273 {
21274 operands[4] = gen_lowpart (SImode, operands[1]);
21275 operands[5] = gen_lowpart (V4SImode, operands[1]);
21276 split_double_mode (DImode, &operands[0], 1, &operands[2], &operands[3]);
21277 })
21278
21279 (define_split
21280 [(set (match_operand:SWI48x 0 "nonimmediate_operand")
21281 (vec_select:SWI48x
21282 (match_operand:<ssevecmode> 1 "register_operand")
21283 (parallel [(const_int 0)])))]
21284 "TARGET_SSE && reload_completed"
21285 [(set (match_dup 0) (match_dup 1))]
21286 "operands[1] = gen_lowpart (<MODE>mode, operands[1]);")
21287
21288 (define_insn "*vec_extractv4si_0_zext_sse4"
21289 [(set (match_operand:DI 0 "register_operand" "=r,x,v")
21290 (zero_extend:DI
21291 (vec_select:SI
21292 (match_operand:V4SI 1 "register_operand" "v,x,v")
21293 (parallel [(const_int 0)]))))]
21294 "TARGET_64BIT && TARGET_SSE4_1"
21295 "#"
21296 [(set_attr "isa" "*,*,avx512f")
21297 (set (attr "preferred_for_speed")
21298 (cond [(eq_attr "alternative" "0")
21299 (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
21300 ]
21301 (symbol_ref "true")))])
21302
21303 (define_insn "*vec_extractv4si_0_zext"
21304 [(set (match_operand:DI 0 "register_operand" "=r")
21305 (zero_extend:DI
21306 (vec_select:SI
21307 (match_operand:V4SI 1 "register_operand" "x")
21308 (parallel [(const_int 0)]))))]
21309 "TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_FROM_VEC"
21310 "#")
21311
21312 (define_split
21313 [(set (match_operand:DI 0 "register_operand")
21314 (zero_extend:DI
21315 (vec_select:SI
21316 (match_operand:V4SI 1 "register_operand")
21317 (parallel [(const_int 0)]))))]
21318 "TARGET_SSE2 && reload_completed"
21319 [(set (match_dup 0) (zero_extend:DI (match_dup 1)))]
21320 "operands[1] = gen_lowpart (SImode, operands[1]);")
21321
21322 (define_insn "*vec_extractv4si"
21323 [(set (match_operand:SI 0 "nonimmediate_operand" "=jrjm,rm,rm,Yr,*x,Yw")
21324 (vec_select:SI
21325 (match_operand:V4SI 1 "register_operand" "x, x, v, 0, 0, Yw")
21326 (parallel [(match_operand:SI 2 "const_0_to_3_operand")])))]
21327 "TARGET_SSE4_1"
21328 {
21329 switch (which_alternative)
21330 {
21331 case 0:
21332 return "pextrd\t{%2, %1, %0|%0, %1, %2}";
21333 case 1:
21334 case 2:
21335 return "vpextrd\t{%2, %1, %0|%0, %1, %2}";
21336
21337 case 3:
21338 case 4:
21339 operands[2] = GEN_INT (INTVAL (operands[2]) * 4);
21340 return "psrldq\t{%2, %0|%0, %2}";
21341
21342 case 5:
21343 operands[2] = GEN_INT (INTVAL (operands[2]) * 4);
21344 return "vpsrldq\t{%2, %1, %0|%0, %1, %2}";
21345
21346 default:
21347 gcc_unreachable ();
21348 }
21349 }
21350 [(set_attr "isa" "noavx,avx,avx512dq,noavx,noavx,avx")
21351 (set_attr "type" "sselog1,sselog1,sselog1,sseishft1,sseishft1,sseishft1")
21352 (set_attr "c86_attr" "extr,extr,*,*,*,*")
21353 (set (attr "addr")
21354 (if_then_else (eq_attr "alternative" "0")
21355 (const_string "gpr16")
21356 (const_string "*")))
21357 (set (attr "prefix_extra")
21358 (if_then_else (eq_attr "alternative" "0,1")
21359 (const_string "1")
21360 (const_string "*")))
21361 (set_attr "length_immediate" "1")
21362 (set_attr "prefix" "orig,vex,evex,orig,orig,maybe_vex")
21363 (set_attr "mode" "TI")])
21364
21365 (define_insn "*vec_extractv4si_zext"
21366 [(set (match_operand:DI 0 "register_operand" "=jr,r,r")
21367 (zero_extend:DI
21368 (vec_select:SI
21369 (match_operand:V4SI 1 "register_operand" "x,x,v")
21370 (parallel [(match_operand:SI 2 "const_0_to_3_operand")]))))]
21371 "TARGET_64BIT && TARGET_SSE4_1"
21372 "%vpextrd\t{%2, %1, %k0|%k0, %1, %2}"
21373 [(set_attr "isa" "noavx,avx,avx512dq")
21374 (set_attr "type" "sselog1")
21375 (set_attr "c86_attr" "extr")
21376 (set_attr "prefix_extra" "1")
21377 (set_attr "length_immediate" "1")
21378 (set_attr "prefix" "maybe_vex")
21379 (set_attr "mode" "TI")])
21380
21381 (define_insn "*vec_extractv4si_mem"
21382 [(set (match_operand:SI 0 "register_operand" "=x,r")
21383 (vec_select:SI
21384 (match_operand:V4SI 1 "memory_operand" "o,o")
21385 (parallel [(match_operand 2 "const_0_to_3_operand")])))]
21386 "TARGET_SSE"
21387 "#")
21388
21389 (define_insn_and_split "*vec_extractv4si_zext_mem"
21390 [(set (match_operand:DI 0 "register_operand" "=x,r")
21391 (zero_extend:DI
21392 (vec_select:SI
21393 (match_operand:V4SI 1 "memory_operand" "o,o")
21394 (parallel [(match_operand:SI 2 "const_0_to_3_operand")]))))]
21395 "TARGET_64BIT && TARGET_SSE"
21396 "#"
21397 "&& reload_completed"
21398 [(set (match_dup 0) (zero_extend:DI (match_dup 1)))]
21399 {
21400 operands[1] = adjust_address (operands[1], SImode, INTVAL (operands[2]) * 4);
21401 })
21402
21403 (define_insn "*vec_extractv2di_1"
21404 [(set (match_operand:DI 0 "nonimmediate_operand" "=jrjm,rm,rm,m,x,x,Yv,x,v,r")
21405 (vec_select:DI
21406 (match_operand:V2DI 1 "nonimmediate_operand" "x, x ,v ,v,0,x, v,x,o,o")
21407 (parallel [(const_int 1)])))]
21408 "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
21409 "@
21410 pextrq\t{$1, %1, %0|%0, %1, 1}
21411 vpextrq\t{$1, %1, %0|%0, %1, 1}
21412 vpextrq\t{$1, %1, %0|%0, %1, 1}
21413 %vmovhps\t{%1, %0|%0, %1}
21414 psrldq\t{$8, %0|%0, 8}
21415 vpsrldq\t{$8, %1, %0|%0, %1, 8}
21416 vpsrldq\t{$8, %1, %0|%0, %1, 8}
21417 movhlps\t{%1, %0|%0, %1}
21418 #
21419 #"
21420 [(set (attr "isa")
21421 (cond [(eq_attr "alternative" "0")
21422 (const_string "x64_sse4_noavx")
21423 (eq_attr "alternative" "1")
21424 (const_string "x64_avx")
21425 (eq_attr "alternative" "2")
21426 (const_string "x64_avx512dq")
21427 (eq_attr "alternative" "4")
21428 (const_string "sse2_noavx")
21429 (eq_attr "alternative" "5")
21430 (const_string "avx")
21431 (eq_attr "alternative" "6")
21432 (const_string "avx512bw")
21433 (eq_attr "alternative" "8")
21434 (const_string "noavx")
21435 (eq_attr "alternative" "9")
21436 (const_string "x64")
21437 ]
21438 (const_string "*")))
21439 (set (attr "type")
21440 (cond [(eq_attr "alternative" "3,7,8")
21441 (const_string "ssemov")
21442 (eq_attr "alternative" "4,5,6")
21443 (const_string "sseishft1")
21444 (eq_attr "alternative" "9")
21445 (const_string "imov")
21446 ]
21447 (const_string "sselog1")))
21448 (set (attr "c86_attr")
21449 (if_then_else (eq_attr "alternative" "0,1,2")
21450 (const_string "extr")
21451 (const_string "other")))
21452 (set (attr "addr")
21453 (if_then_else (eq_attr "alternative" "0")
21454 (const_string "gpr16")
21455 (const_string "*")))
21456 (set (attr "length_immediate")
21457 (if_then_else (eq_attr "alternative" "0,1,2,4,5,6")
21458 (const_string "1")
21459 (const_string "*")))
21460 (set (attr "prefix_rex")
21461 (if_then_else (eq_attr "alternative" "0")
21462 (const_string "1")
21463 (const_string "*")))
21464 (set (attr "prefix_extra")
21465 (if_then_else (eq_attr "alternative" "0")
21466 (const_string "1")
21467 (const_string "*")))
21468 (set_attr "prefix" "orig,maybe_evex,evex,maybe_vex,orig,vex,evex,orig,*,*")
21469 (set_attr "mode" "TI,TI,TI,V2SF,TI,TI,TI,V4SF,DI,DI")])
21470
21471 (define_split
21472 [(set (match_operand:<ssescalarmode> 0 "register_operand")
21473 (vec_select:<ssescalarmode>
21474 (match_operand:VI_128 1 "memory_operand")
21475 (parallel
21476 [(match_operand 2 "const_0_to_<ssescalarnummask>_operand")])))]
21477 "TARGET_SSE && reload_completed"
21478 [(set (match_dup 0) (match_dup 1))]
21479 {
21480 int offs = INTVAL (operands[2]) * GET_MODE_SIZE (<ssescalarmode>mode);
21481
21482 operands[1] = adjust_address (operands[1], <ssescalarmode>mode, offs);
21483 })
21484
21485 (define_insn "*vec_extractv2ti"
21486 [(set (match_operand:TI 0 "nonimmediate_operand" "=xjm,vm")
21487 (vec_select:TI
21488 (match_operand:V2TI 1 "register_operand" "x,v")
21489 (parallel
21490 [(match_operand:SI 2 "const_0_to_1_operand")])))]
21491 "TARGET_AVX"
21492 "@
21493 vextract%~128\t{%2, %1, %0|%0, %1, %2}
21494 vextracti32x4\t{%2, %1, %0|%0, %1, %2}"
21495 [(set_attr "type" "sselog")
21496 (set_attr "prefix_extra" "1")
21497 (set_attr "length_immediate" "1")
21498 (set_attr "isa" "noavx512vl,avx512vl")
21499 (set_attr "addr" "gpr16,*")
21500 (set_attr "prefix" "vex,evex")
21501 (set_attr "mode" "OI")])
21502
21503 (define_insn "*vec_extractv4ti"
21504 [(set (match_operand:TI 0 "nonimmediate_operand" "=vm")
21505 (vec_select:TI
21506 (match_operand:V4TI 1 "register_operand" "v")
21507 (parallel
21508 [(match_operand:SI 2 "const_0_to_3_operand")])))]
21509 "TARGET_AVX512F && TARGET_EVEX512"
21510 "vextracti32x4\t{%2, %1, %0|%0, %1, %2}"
21511 [(set_attr "type" "sselog")
21512 (set_attr "length_immediate" "1")
21513 (set_attr "prefix" "evex")
21514 (set_attr "mode" "XI")])
21515
21516 (define_mode_iterator VEXTRACTI128_MODE
21517 [(V4TI "TARGET_AVX512F && TARGET_EVEX512") V2TI])
21518
21519 (define_split
21520 [(set (match_operand:TI 0 "nonimmediate_operand")
21521 (vec_select:TI
21522 (match_operand:VEXTRACTI128_MODE 1 "register_operand")
21523 (parallel [(const_int 0)])))]
21524 "TARGET_AVX
21525 && reload_completed
21526 && (TARGET_AVX512VL || !EXT_REX_SSE_REG_P (operands[1]))"
21527 [(set (match_dup 0) (match_dup 1))]
21528 "operands[1] = gen_lowpart (TImode, operands[1]);")
21529
21530 ;; Turn SImode or DImode extraction from arbitrary SSE/AVX/AVX512F
21531 ;; vector modes into vec_extract*.
21532 (define_split
21533 [(set (match_operand:SWI48x 0 "nonimmediate_operand")
21534 (subreg:SWI48x (match_operand 1 "register_operand") 0))]
21535 "can_create_pseudo_p ()
21536 && REG_P (operands[1])
21537 && VECTOR_MODE_P (GET_MODE (operands[1]))
21538 && ((TARGET_SSE && GET_MODE_SIZE (GET_MODE (operands[1])) == 16)
21539 || (TARGET_AVX && GET_MODE_SIZE (GET_MODE (operands[1])) == 32)
21540 || (TARGET_AVX512F && TARGET_EVEX512
21541 && GET_MODE_SIZE (GET_MODE (operands[1])) == 64))
21542 && (<MODE>mode == SImode || TARGET_64BIT || MEM_P (operands[0]))"
21543 [(set (match_dup 0) (vec_select:SWI48x (match_dup 1)
21544 (parallel [(const_int 0)])))]
21545 {
21546 rtx tmp;
21547
21548 switch (GET_MODE_SIZE (GET_MODE (operands[1])))
21549 {
21550 case 64:
21551 if (<MODE>mode == SImode)
21552 {
21553 tmp = gen_reg_rtx (V8SImode);
21554 emit_insn (gen_vec_extract_lo_v16si (tmp,
21555 gen_lowpart (V16SImode,
21556 operands[1])));
21557 }
21558 else
21559 {
21560 tmp = gen_reg_rtx (V4DImode);
21561 emit_insn (gen_vec_extract_lo_v8di (tmp,
21562 gen_lowpart (V8DImode,
21563 operands[1])));
21564 }
21565 operands[1] = tmp;
21566 /* FALLTHRU */
21567 case 32:
21568 tmp = gen_reg_rtx (<ssevecmode>mode);
21569 if (<MODE>mode == SImode)
21570 emit_insn (gen_vec_extract_lo_v8si (tmp, gen_lowpart (V8SImode,
21571 operands[1])));
21572 else
21573 emit_insn (gen_vec_extract_lo_v4di (tmp, gen_lowpart (V4DImode,
21574 operands[1])));
21575 operands[1] = tmp;
21576 break;
21577 case 16:
21578 operands[1] = gen_lowpart (<ssevecmode>mode, operands[1]);
21579 break;
21580 }
21581 })
21582
21583 (define_insn "*vec_concatv2si_sse4_1"
21584 [(set (match_operand:V2SI 0 "register_operand"
21585 "=Yr,*x, x, v,Yr,*x, v, v, *y,*y")
21586 (vec_concat:V2SI
21587 (match_operand:SI 1 "nonimmediate_operand"
21588 " 0, 0, x,Yv, 0, 0,Yv,rm, 0,rm")
21589 (match_operand:SI 2 "nonimm_or_0_operand"
21590 "jrjm,jrjm,rm,rm,Yr,*x,Yv, C,*ym, C")))]
21591 "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
21592 "@
21593 pinsrd\t{$1, %2, %0|%0, %2, 1}
21594 pinsrd\t{$1, %2, %0|%0, %2, 1}
21595 vpinsrd\t{$1, %2, %1, %0|%0, %1, %2, 1}
21596 vpinsrd\t{$1, %2, %1, %0|%0, %1, %2, 1}
21597 punpckldq\t{%2, %0|%0, %2}
21598 punpckldq\t{%2, %0|%0, %2}
21599 vpunpckldq\t{%2, %1, %0|%0, %1, %2}
21600 %vmovd\t{%1, %0|%0, %1}
21601 punpckldq\t{%2, %0|%0, %2}
21602 movd\t{%1, %0|%0, %1}"
21603 [(set_attr "isa" "noavx,noavx,avx,avx512dq,noavx,noavx,avx,*,*,*")
21604 (set (attr "mmx_isa")
21605 (if_then_else (eq_attr "alternative" "8,9")
21606 (const_string "native")
21607 (const_string "*")))
21608 (set (attr "type")
21609 (cond [(eq_attr "alternative" "7")
21610 (const_string "ssemov")
21611 (eq_attr "alternative" "8")
21612 (const_string "mmxcvt")
21613 (eq_attr "alternative" "9")
21614 (const_string "mmxmov")
21615 ]
21616 (const_string "sselog")))
21617 (set (attr "c86_attr")
21618 (if_then_else (eq_attr "alternative" "0,1,2,3")
21619 (const_string "insr")
21620 (const_string "other")))
21621 (set (attr "addr")
21622 (if_then_else (eq_attr "alternative" "0,1")
21623 (const_string "gpr16")
21624 (const_string "*")))
21625 (set (attr "prefix_extra")
21626 (if_then_else (eq_attr "alternative" "0,1,2,3")
21627 (const_string "1")
21628 (const_string "*")))
21629 (set (attr "length_immediate")
21630 (if_then_else (eq_attr "alternative" "0,1,2,3")
21631 (const_string "1")
21632 (const_string "*")))
21633 (set_attr "prefix" "orig,orig,vex,evex,orig,orig,maybe_evex,maybe_vex,orig,orig")
21634 (set_attr "mode" "TI,TI,TI,TI,TI,TI,TI,TI,DI,DI")])
21635
21636 ;; ??? In theory we can match memory for the MMX alternative, but allowing
21637 ;; nonimmediate_operand for operand 2 and *not* allowing memory for the SSE
21638 ;; alternatives pretty much forces the MMX alternative to be chosen.
21639 (define_insn "*vec_concatv2si"
21640 [(set (match_operand:V2SI 0 "register_operand" "=x,x ,x,x,*y,*y")
21641 (vec_concat:V2SI
21642 (match_operand:SI 1 "nonimmediate_operand" " 0,rm,0,m, 0,rm")
21643 (match_operand:SI 2 "reg_or_0_operand" " x,C ,x,C,*y,C")))]
21644 "TARGET_SSE && !TARGET_SSE4_1"
21645 "@
21646 punpckldq\t{%2, %0|%0, %2}
21647 movd\t{%1, %0|%0, %1}
21648 unpcklps\t{%2, %0|%0, %2}
21649 movss\t{%1, %0|%0, %1}
21650 punpckldq\t{%2, %0|%0, %2}
21651 movd\t{%1, %0|%0, %1}"
21652 [(set_attr "isa" "sse2,sse2,*,*,*,*")
21653 (set_attr "mmx_isa" "*,*,*,*,native,native")
21654 (set_attr "type" "sselog,ssemov,sselog,ssemov,mmxcvt,mmxmov")
21655 (set_attr "mode" "TI,TI,V4SF,SF,DI,DI")])
21656
21657 (define_insn "*vec_concat<mode>"
21658 [(set (match_operand:VI124_128 0 "register_operand" "=x,v,x,x,v")
21659 (vec_concat:VI124_128
21660 (match_operand:<ssehalfvecmode> 1 "register_operand" " 0,v,0,0,v")
21661 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" " x,v,x,m,m")))]
21662 "TARGET_SSE"
21663 "@
21664 punpcklqdq\t{%2, %0|%0, %2}
21665 vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
21666 movlhps\t{%2, %0|%0, %2}
21667 movhps\t{%2, %0|%0, %q2}
21668 vmovhps\t{%2, %1, %0|%0, %1, %q2}"
21669 [(set_attr "isa" "sse2_noavx,avx,noavx,noavx,avx")
21670 (set_attr "type" "sselog,sselog,ssemov,ssemov2,ssemov2")
21671 (set_attr "prefix" "orig,maybe_evex,orig,orig,maybe_evex")
21672 (set_attr "mode" "TI,TI,V4SF,V2SF,V2SF")])
21673
21674 (define_insn_and_split "*vec_concatv16qi_permt2"
21675 [(set (match_operand:V16QI 0 "register_operand")
21676 (unspec:V16QI
21677 [(const_vector:V16QI [(const_int 0) (const_int 1)
21678 (const_int 2) (const_int 3)
21679 (const_int 4) (const_int 5)
21680 (const_int 6) (const_int 7)
21681 (const_int 16) (const_int 17)
21682 (const_int 18) (const_int 19)
21683 (const_int 20) (const_int 21)
21684 (const_int 22) (const_int 23)])
21685 (match_operand:V16QI 1 "register_operand")
21686 (match_operand:V16QI 2 "nonimmediate_operand")]
21687 UNSPEC_VPERMT2))]
21688 "TARGET_AVX512VL && TARGET_AVX512VBMI
21689 && ix86_pre_reload_split ()"
21690 "#"
21691 "&& 1"
21692 [(set (match_dup 0)
21693 (vec_concat:V16QI (match_dup 1) (match_dup 2)))]
21694 {
21695 operands[1] = lowpart_subreg (V8QImode,
21696 force_reg (V16QImode, operands[1]),
21697 V16QImode);
21698 if (!MEM_P (operands[2]))
21699 operands[2] = force_reg (V16QImode, operands[2]);
21700 operands[2] = lowpart_subreg (V8QImode, operands[2], V16QImode);
21701 })
21702
21703 (define_insn_and_split "*vec_concatv8hi_permt2"
21704 [(set (match_operand:V8HI 0 "register_operand")
21705 (unspec:V8HI
21706 [(const_vector:V8HI [(const_int 0) (const_int 1)
21707 (const_int 2) (const_int 3)
21708 (const_int 8) (const_int 9)
21709 (const_int 10) (const_int 11)])
21710 (match_operand:V8HI 1 "register_operand")
21711 (match_operand:V8HI 2 "nonimmediate_operand")]
21712 UNSPEC_VPERMT2))]
21713 "TARGET_AVX512VL && TARGET_AVX512BW
21714 && ix86_pre_reload_split ()"
21715 "#"
21716 "&& 1"
21717 [(set (match_dup 0)
21718 (vec_concat:V8HI (match_dup 1) (match_dup 2)))]
21719 {
21720 operands[1] = lowpart_subreg (V4HImode,
21721 force_reg (V8HImode, operands[1]),
21722 V8HImode);
21723 if (!MEM_P (operands[2]))
21724 operands[2] = force_reg (V8HImode, operands[2]);
21725 operands[2] = lowpart_subreg (V4HImode, operands[2], V8HImode);
21726 })
21727
21728 (define_insn "*vec_concat<mode>_0"
21729 [(set (match_operand:VI124_128 0 "register_operand" "=v,x")
21730 (vec_concat:VI124_128
21731 (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "vm,?!*y")
21732 (match_operand:<ssehalfvecmode> 2 "const0_operand")))]
21733 "TARGET_SSE2"
21734 "@
21735 %vmovq\t{%1, %0|%0, %1}
21736 movq2dq\t{%1, %0|%0, %1}"
21737 [(set_attr "mmx_isa" "*,native")
21738 (set_attr "type" "ssemov")
21739 (set_attr "prefix" "maybe_vex,orig")
21740 (set_attr "mode" "TI")])
21741
21742 (define_insn "vec_concatv2di"
21743 [(set (match_operand:V2DI 0 "register_operand"
21744 "=Yr,*x,x ,v ,x,v ,x,x,v")
21745 (vec_concat:V2DI
21746 (match_operand:DI 1 "register_operand"
21747 " 0, 0,x ,Yv,0,Yv,0,0,v")
21748 (match_operand:DI 2 "nonimmediate_operand"
21749 " jrjm,jrjm,rm,rm,x,Yv,x,m,m")))]
21750 "TARGET_SSE"
21751 "@
21752 pinsrq\t{$1, %2, %0|%0, %2, 1}
21753 pinsrq\t{$1, %2, %0|%0, %2, 1}
21754 vpinsrq\t{$1, %2, %1, %0|%0, %1, %2, 1}
21755 vpinsrq\t{$1, %2, %1, %0|%0, %1, %2, 1}
21756 punpcklqdq\t{%2, %0|%0, %2}
21757 vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
21758 movlhps\t{%2, %0|%0, %2}
21759 movhps\t{%2, %0|%0, %2}
21760 vmovhps\t{%2, %1, %0|%0, %1, %2}"
21761 [(set (attr "isa")
21762 (cond [(eq_attr "alternative" "0,1")
21763 (const_string "x64_sse4_noavx")
21764 (eq_attr "alternative" "2")
21765 (const_string "x64_avx")
21766 (eq_attr "alternative" "3")
21767 (const_string "x64_avx512dq")
21768 (eq_attr "alternative" "4")
21769 (const_string "sse2_noavx")
21770 (eq_attr "alternative" "5,8")
21771 (const_string "avx")
21772 ]
21773 (const_string "noavx")))
21774 (set (attr "type")
21775 (if_then_else
21776 (eq_attr "alternative" "0,1,2,3,4,5")
21777 (const_string "sselog")
21778 (const_string "ssemov2")))
21779 (set (attr "c86_attr")
21780 (if_then_else (eq_attr "alternative" "0,1,2,3")
21781 (const_string "insr")
21782 (const_string "other")))
21783 (set (attr "addr")
21784 (if_then_else (eq_attr "alternative" "0,1")
21785 (const_string "gpr16")
21786 (const_string "*")))
21787 (set (attr "prefix_rex")
21788 (if_then_else (eq_attr "alternative" "0,1,2,3")
21789 (const_string "1")
21790 (const_string "*")))
21791 (set (attr "prefix_extra")
21792 (if_then_else (eq_attr "alternative" "0,1,2,3")
21793 (const_string "1")
21794 (const_string "*")))
21795 (set (attr "length_immediate")
21796 (if_then_else (eq_attr "alternative" "0,1,2,3")
21797 (const_string "1")
21798 (const_string "*")))
21799 (set (attr "prefix")
21800 (cond [(eq_attr "alternative" "2")
21801 (const_string "vex")
21802 (eq_attr "alternative" "3")
21803 (const_string "evex")
21804 (eq_attr "alternative" "5,8")
21805 (const_string "maybe_evex")
21806 ]
21807 (const_string "orig")))
21808 (set_attr "mode" "TI,TI,TI,TI,TI,TI,V4SF,V2SF,V2SF")])
21809
21810 ;; Eliminate redundancy caused by
21811 ;; /* Special case TImode to 128-bit vector conversions via V2DI. */
21812 ;; in ix86_expand_vector_move
21813
21814 (define_split
21815 [(set (match_operand:V2DI 0 "register_operand")
21816 (vec_concat:V2DI
21817 (subreg:DI (match_operand:TI 1 "register_operand") 0)
21818 (subreg:DI (match_dup 1) 8)))]
21819 "TARGET_SSE2 && ix86_pre_reload_split ()"
21820 [(set (match_dup 0)
21821 (subreg:V2DI (match_dup 1) 0))])
21822
21823 (define_insn "*vec_concatv2di_0"
21824 [(set (match_operand:V2DI 0 "register_operand" "=v,v ,x")
21825 (vec_concat:V2DI
21826 (match_operand:DI 1 "nonimmediate_operand" " r,vm,?!*y")
21827 (match_operand:DI 2 "const0_operand")))]
21828 "TARGET_SSE2"
21829 "@
21830 * return HAVE_AS_IX86_INTERUNIT_MOVQ ? \"%vmovq\t{%1, %0|%0, %1}\" : \"%vmovd\t{%1, %0|%0, %1}\";
21831 %vmovq\t{%1, %0|%0, %1}
21832 movq2dq\t{%1, %0|%0, %1}"
21833 [(set_attr "isa" "x64,*,*")
21834 (set_attr "mmx_isa" "*,*,native")
21835 (set_attr "type" "ssemov")
21836 (set_attr "prefix_rex" "1,*,*")
21837 (set_attr "prefix" "maybe_vex,maybe_vex,orig")
21838 (set_attr "mode" "TI")
21839 (set (attr "preferred_for_speed")
21840 (cond [(eq_attr "alternative" "0")
21841 (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
21842 ]
21843 (symbol_ref "true")))])
21844
21845 ;; vmovq clears also the higher bits.
21846 (define_insn "vec_set<mode>_0"
21847 [(set (match_operand:VI8_AVX_AVX512F 0 "register_operand" "=v,v")
21848 (vec_merge:VI8_AVX_AVX512F
21849 (vec_duplicate:VI8_AVX_AVX512F
21850 (match_operand:<ssescalarmode> 2 "nonimmediate_operand" "r,vm"))
21851 (match_operand:VI8_AVX_AVX512F 1 "const0_operand")
21852 (const_int 1)))]
21853 "TARGET_AVX"
21854 "vmovq\t{%2, %x0|%x0, %2}"
21855 [(set_attr "isa" "x64,*")
21856 (set_attr "type" "ssemov")
21857 (set_attr "prefix_rex" "1,*")
21858 (set_attr "prefix" "maybe_evex")
21859 (set_attr "mode" "TI")
21860 (set (attr "preferred_for_speed")
21861 (cond [(eq_attr "alternative" "0")
21862 (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
21863 ]
21864 (symbol_ref "true")))])
21865
21866 (define_expand "vec_unpacks_lo_<mode>"
21867 [(match_operand:<sseunpackmode> 0 "register_operand")
21868 (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
21869 "TARGET_SSE2"
21870 "ix86_expand_sse_unpack (operands[0], operands[1], false, false); DONE;")
21871
21872 (define_expand "vec_unpacks_hi_<mode>"
21873 [(match_operand:<sseunpackmode> 0 "register_operand")
21874 (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
21875 "TARGET_SSE2"
21876 "ix86_expand_sse_unpack (operands[0], operands[1], false, true); DONE;")
21877
21878 (define_expand "vec_unpacku_lo_<mode>"
21879 [(match_operand:<sseunpackmode> 0 "register_operand")
21880 (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
21881 "TARGET_SSE2"
21882 "ix86_expand_sse_unpack (operands[0], operands[1], true, false); DONE;")
21883
21884 (define_expand "vec_unpacks_sbool_lo_qi"
21885 [(match_operand:QI 0 "register_operand")
21886 (match_operand:QI 1 "register_operand")
21887 (match_operand:QI 2 "const_int_operand")]
21888 "TARGET_AVX512F"
21889 {
21890 if (INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 4)
21891 FAIL;
21892 emit_move_insn (operands[0], operands[1]);
21893 DONE;
21894 })
21895
21896 (define_expand "vec_unpacks_lo_hi"
21897 [(set (subreg:HI (match_operand:QI 0 "register_operand") 0)
21898 (match_operand:HI 1 "register_operand"))]
21899 "TARGET_AVX512F")
21900
21901 (define_expand "vec_unpacks_lo_si"
21902 [(set (match_operand:HI 0 "register_operand")
21903 (subreg:HI (match_operand:SI 1 "register_operand") 0))]
21904 "TARGET_AVX512F")
21905
21906 (define_expand "vec_unpacks_lo_di"
21907 [(set (match_operand:SI 0 "register_operand")
21908 (subreg:SI (match_operand:DI 1 "register_operand") 0))]
21909 "TARGET_AVX512BW")
21910
21911 (define_expand "vec_unpacku_hi_<mode>"
21912 [(match_operand:<sseunpackmode> 0 "register_operand")
21913 (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
21914 "TARGET_SSE2"
21915 "ix86_expand_sse_unpack (operands[0], operands[1], true, true); DONE;")
21916
21917 (define_expand "vec_unpacks_sbool_hi_qi"
21918 [(match_operand:QI 0 "register_operand")
21919 (match_operand:QI 1 "register_operand")
21920 (match_operand:QI 2 "const_int_operand")]
21921 "TARGET_AVX512F"
21922 {
21923 HOST_WIDE_INT nunits = INTVAL (operands[2]);
21924 if (nunits != 8 && nunits != 4)
21925 FAIL;
21926 if (TARGET_AVX512DQ)
21927 emit_insn (gen_klshiftrtqi (operands[0], operands[1],
21928 GEN_INT (nunits / 2)));
21929 else
21930 {
21931 rtx tem = gen_reg_rtx (HImode);
21932 emit_insn (gen_klshiftrthi (tem, lowpart_subreg (HImode, operands[1],
21933 QImode),
21934 GEN_INT (nunits / 2)));
21935 emit_move_insn (operands[0], lowpart_subreg (QImode, tem, HImode));
21936 }
21937 DONE;
21938 })
21939
21940 (define_expand "vec_unpacks_hi_hi"
21941 [(parallel
21942 [(set (subreg:HI (match_operand:QI 0 "register_operand") 0)
21943 (lshiftrt:HI (match_operand:HI 1 "register_operand")
21944 (const_int 8)))
21945 (unspec [(const_int 0)] UNSPEC_MASKOP)])]
21946 "TARGET_AVX512F")
21947
21948 (define_expand "vec_unpacks_hi_<mode>"
21949 [(parallel
21950 [(set (subreg:SWI48x
21951 (match_operand:<HALFMASKMODE> 0 "register_operand") 0)
21952 (lshiftrt:SWI48x
21953 (match_operand:SWI48x 1 "register_operand")
21954 (match_dup 2)))
21955 (unspec [(const_int 0)] UNSPEC_MASKOP)])]
21956 "TARGET_AVX512BW"
21957 "operands[2] = GEN_INT (GET_MODE_BITSIZE (<HALFMASKMODE>mode));")
21958
21959 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21960 ;;
21961 ;; Miscellaneous
21962 ;;
21963 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21964
21965 (define_expand "<sse2_avx2>_uavg<mode>3<mask_name>"
21966 [(set (match_operand:VI12_AVX2_AVX512BW 0 "register_operand")
21967 (truncate:VI12_AVX2_AVX512BW
21968 (lshiftrt:<ssedoublemode>
21969 (plus:<ssedoublemode>
21970 (plus:<ssedoublemode>
21971 (zero_extend:<ssedoublemode>
21972 (match_operand:VI12_AVX2_AVX512BW 1 "vector_operand"))
21973 (zero_extend:<ssedoublemode>
21974 (match_operand:VI12_AVX2_AVX512BW 2 "vector_operand")))
21975 (match_dup <mask_expand_op3>))
21976 (const_int 1))))]
21977 "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
21978 {
21979 operands[<mask_expand_op3>] = CONST1_RTX(<ssedoublemode>mode);
21980 ix86_fixup_binary_operands_no_copy (PLUS, <MODE>mode, operands);
21981 })
21982
21983 (define_insn "*<sse2_avx2>_uavg<mode>3<mask_name>"
21984 [(set (match_operand:VI12_AVX2_AVX512BW 0 "register_operand" "=x,<v_Yw>")
21985 (truncate:VI12_AVX2_AVX512BW
21986 (lshiftrt:<ssedoublemode>
21987 (plus:<ssedoublemode>
21988 (plus:<ssedoublemode>
21989 (zero_extend:<ssedoublemode>
21990 (match_operand:VI12_AVX2_AVX512BW 1 "vector_operand" "%0,<v_Yw>"))
21991 (zero_extend:<ssedoublemode>
21992 (match_operand:VI12_AVX2_AVX512BW 2 "vector_operand" "xBm,<v_Yw>m")))
21993 (match_operand:<ssedoublemode> <mask_expand_op3> "const1_operand"))
21994 (const_int 1))))]
21995 "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
21996 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
21997 "@
21998 pavg<ssemodesuffix>\t{%2, %0|%0, %2}
21999 vpavg<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
22000 [(set_attr "isa" "noavx,avx")
22001 (set_attr "type" "sseiadd")
22002 (set_attr "c86_attr" "avg")
22003 (set_attr "prefix_data16" "1,*")
22004 (set_attr "prefix" "orig,<mask_prefix>")
22005 (set_attr "mode" "<sseinsnmode>")])
22006
22007 ;; The correct representation for this is absolutely enormous, and
22008 ;; surely not generally useful.
22009 (define_expand "<sse2_avx2>_psadbw"
22010 [(set (match_operand:VI8_AVX2_AVX512BW 0 "register_operand")
22011 (unspec:VI8_AVX2_AVX512BW
22012 [(match_operand:<ssebytemode> 1 "vector_operand")
22013 (match_operand:<ssebytemode> 2 "vector_operand")]
22014 UNSPEC_PSADBW))]
22015 "TARGET_SSE2"
22016 "ix86_fixup_binary_operands_no_copy (PLUS, <ssebytemode>mode, operands);")
22017
22018 (define_insn "*<sse2_avx2>_psadbw"
22019 [(set (match_operand:VI8_AVX2_AVX512BW 0 "register_operand" "=x,YW")
22020 (unspec:VI8_AVX2_AVX512BW
22021 [(match_operand:<ssebytemode> 1 "vector_operand" "%0,YW")
22022 (match_operand:<ssebytemode> 2 "vector_operand" "xBm,YWm")]
22023 UNSPEC_PSADBW))]
22024 "TARGET_SSE2
22025 && ix86_binary_operator_ok (PLUS, <ssebytemode>mode, operands)"
22026 "@
22027 psadbw\t{%2, %0|%0, %2}
22028 vpsadbw\t{%2, %1, %0|%0, %1, %2}"
22029 [(set_attr "isa" "noavx,avx")
22030 (set_attr "type" "sseiadd")
22031 (set_attr "c86_attr" "sadbw")
22032 (set_attr "atom_unit" "simul")
22033 (set_attr "prefix_data16" "1,*")
22034 (set_attr "prefix" "orig,maybe_evex")
22035 (set_attr "mode" "<sseinsnmode>")])
22036
22037 (define_insn "<sse>_movmsk<ssemodesuffix><avxsizesuffix>"
22038 [(set (match_operand:SI 0 "register_operand" "=r,jr")
22039 (unspec:SI
22040 [(match_operand:VF_128_256 1 "register_operand" "x,x")]
22041 UNSPEC_MOVMSK))]
22042 "TARGET_SSE"
22043 "%vmovmsk<ssemodesuffix>\t{%1, %0|%0, %1}"
22044 [(set_attr "isa" "noavx,avx")
22045 (set_attr "type" "ssemov")
22046 (set_attr "c86_attr" "movnt")
22047 (set_attr "prefix" "maybe_evex")
22048 (set_attr "mode" "<MODE>")])
22049
22050 (define_insn "*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_<u>ext"
22051 [(set (match_operand:DI 0 "register_operand" "=r,jr")
22052 (any_extend:DI
22053 (unspec:SI
22054 [(match_operand:VF_128_256 1 "register_operand" "x,x")]
22055 UNSPEC_MOVMSK)))]
22056 "TARGET_64BIT && TARGET_SSE"
22057 "%vmovmsk<ssemodesuffix>\t{%1, %0|%0, %1}"
22058 [(set_attr "isa" "noavx,avx")
22059 (set_attr "type" "ssemov")
22060 (set_attr "c86_attr" "movnt")
22061 (set_attr "prefix" "maybe_evex")
22062 (set_attr "mode" "<MODE>")])
22063
22064 (define_insn_and_split "*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_lt"
22065 [(set (match_operand:SI 0 "register_operand" "=r,jr")
22066 (unspec:SI
22067 [(lt:VF_128_256
22068 (match_operand:<sseintvecmode> 1 "register_operand" "x,x")
22069 (match_operand:<sseintvecmode> 2 "const0_operand"))]
22070 UNSPEC_MOVMSK))]
22071 "TARGET_SSE"
22072 "#"
22073 "&& reload_completed"
22074 [(set (match_dup 0)
22075 (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK))]
22076 "operands[1] = gen_lowpart (<MODE>mode, operands[1]);"
22077 [(set_attr "isa" "noavx,avx")
22078 (set_attr "type" "ssemov")
22079 (set_attr "prefix" "maybe_vex")
22080 (set_attr "mode" "<MODE>")])
22081
22082 (define_insn_and_split "*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_lt_avx512"
22083 [(set (match_operand:SI 0 "register_operand" "=r,jr")
22084 (unspec:SI
22085 [(subreg:VF_128_256
22086 (vec_merge:<sseintvecmode>
22087 (match_operand:<sseintvecmode> 3 "vector_all_ones_operand")
22088 (match_operand:<sseintvecmode> 4 "const0_operand")
22089 (unspec:<avx512fmaskmode>
22090 [(match_operand:<sseintvecmode> 1 "register_operand" "x,x")
22091 (match_operand:<sseintvecmode> 2 "const0_operand")
22092 (const_int 1)]
22093 UNSPEC_PCMP)) 0)]
22094 UNSPEC_MOVMSK))]
22095 "TARGET_SSE"
22096 "#"
22097 "&& reload_completed"
22098 [(set (match_dup 0)
22099 (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK))]
22100 "operands[1] = gen_lowpart (<MODE>mode, operands[1]);"
22101 [(set_attr "isa" "noavx,avx")
22102 (set_attr "type" "ssemov")
22103 (set_attr "prefix" "maybe_vex")
22104 (set_attr "mode" "<MODE>")])
22105
22106 (define_insn_and_split "*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_<u>ext_lt"
22107 [(set (match_operand:DI 0 "register_operand" "=r,jr")
22108 (any_extend:DI
22109 (unspec:SI
22110 [(lt:VF_128_256
22111 (match_operand:<sseintvecmode> 1 "register_operand" "x,x")
22112 (match_operand:<sseintvecmode> 2 "const0_operand"))]
22113 UNSPEC_MOVMSK)))]
22114 "TARGET_64BIT && TARGET_SSE"
22115 "#"
22116 "&& reload_completed"
22117 [(set (match_dup 0)
22118 (any_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK)))]
22119 "operands[1] = gen_lowpart (<MODE>mode, operands[1]);"
22120 [(set_attr "isa" "noavx,avx")
22121 (set_attr "type" "ssemov")
22122 (set_attr "prefix" "maybe_vex")
22123 (set_attr "mode" "<MODE>")])
22124
22125 (define_insn_and_split "*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_<u>ext_lt_avx512"
22126 [(set (match_operand:DI 0 "register_operand" "=r,jr")
22127 (any_extend:DI
22128 (unspec:SI
22129 [(subreg:VF_128_256
22130 (vec_merge:<sseintvecmode>
22131 (match_operand:<sseintvecmode> 3 "vector_all_ones_operand")
22132 (match_operand:<sseintvecmode> 4 "const0_operand")
22133 (unspec:<avx512fmaskmode>
22134 [(match_operand:<sseintvecmode> 1 "register_operand" "x,x")
22135 (match_operand:<sseintvecmode> 2 "const0_operand")
22136 (const_int 1)]
22137 UNSPEC_PCMP)) 0)]
22138 UNSPEC_MOVMSK)))]
22139 "TARGET_64BIT && TARGET_SSE"
22140 "#"
22141 "&& reload_completed"
22142 [(set (match_dup 0)
22143 (any_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK)))]
22144 "operands[1] = gen_lowpart (<MODE>mode, operands[1]);"
22145 [(set_attr "isa" "noavx,avx")
22146 (set_attr "type" "ssemov")
22147 (set_attr "prefix" "maybe_vex")
22148 (set_attr "mode" "<MODE>")])
22149
22150 (define_insn_and_split "*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_shift"
22151 [(set (match_operand:SI 0 "register_operand" "=r,jr")
22152 (unspec:SI
22153 [(subreg:VF_128_256
22154 (ashiftrt:<sseintvecmode>
22155 (match_operand:<sseintvecmode> 1 "register_operand" "x,x")
22156 (match_operand:QI 2 "const_int_operand")) 0)]
22157 UNSPEC_MOVMSK))]
22158 "TARGET_SSE"
22159 "#"
22160 "&& reload_completed"
22161 [(set (match_dup 0)
22162 (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK))]
22163 "operands[1] = gen_lowpart (<MODE>mode, operands[1]);"
22164 [(set_attr "isa" "noavx,avx")
22165 (set_attr "type" "ssemov")
22166 (set_attr "prefix" "maybe_vex")
22167 (set_attr "mode" "<MODE>")])
22168
22169 (define_insn_and_split "*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_<u>ext_shift"
22170 [(set (match_operand:DI 0 "register_operand" "=r,jr")
22171 (any_extend:DI
22172 (unspec:SI
22173 [(subreg:VF_128_256
22174 (ashiftrt:<sseintvecmode>
22175 (match_operand:<sseintvecmode> 1 "register_operand" "x,x")
22176 (match_operand:QI 2 "const_int_operand")) 0)]
22177 UNSPEC_MOVMSK)))]
22178 "TARGET_64BIT && TARGET_SSE"
22179 "#"
22180 "&& reload_completed"
22181 [(set (match_dup 0)
22182 (any_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK)))]
22183 "operands[1] = gen_lowpart (<MODE>mode, operands[1]);"
22184 [(set_attr "isa" "noavx,avx")
22185 (set_attr "type" "ssemov")
22186 (set_attr "prefix" "maybe_vex")
22187 (set_attr "mode" "<MODE>")])
22188
22189 (define_insn "<sse2_avx2>_pmovmskb"
22190 [(set (match_operand:SI 0 "register_operand" "=r,jr")
22191 (unspec:SI
22192 [(match_operand:VI1_AVX2 1 "register_operand" "x,x")]
22193 UNSPEC_MOVMSK))]
22194 "TARGET_SSE2"
22195 "%vpmovmskb\t{%1, %0|%0, %1}"
22196 [(set_attr "isa" "noavx,avx")
22197 (set_attr "type" "ssemov")
22198 (set_attr "c86_attr" "movnt")
22199 (set (attr "prefix_data16")
22200 (if_then_else
22201 (match_test "TARGET_AVX")
22202 (const_string "*")
22203 (const_string "1")))
22204 (set_attr "prefix" "maybe_vex")
22205 (set_attr "mode" "SI")])
22206
22207 (define_insn "*<sse2_avx2>_pmovmskb_zext"
22208 [(set (match_operand:DI 0 "register_operand" "=r,jr")
22209 (zero_extend:DI
22210 (unspec:SI
22211 [(match_operand:VI1_AVX2 1 "register_operand" "x,x")]
22212 UNSPEC_MOVMSK)))]
22213 "TARGET_64BIT && TARGET_SSE2"
22214 "%vpmovmskb\t{%1, %k0|%k0, %1}"
22215 [(set_attr "isa" "noavx,avx")
22216 (set_attr "type" "ssemov")
22217 (set_attr "c86_attr" "movnt")
22218 (set (attr "prefix_data16")
22219 (if_then_else
22220 (match_test "TARGET_AVX")
22221 (const_string "*")
22222 (const_string "1")))
22223 (set_attr "prefix" "maybe_vex")
22224 (set_attr "mode" "SI")])
22225
22226 (define_insn "*sse2_pmovmskb_ext"
22227 [(set (match_operand:DI 0 "register_operand" "=r,jr")
22228 (sign_extend:DI
22229 (unspec:SI
22230 [(match_operand:V16QI 1 "register_operand" "x,x")]
22231 UNSPEC_MOVMSK)))]
22232 "TARGET_64BIT && TARGET_SSE2"
22233 "%vpmovmskb\t{%1, %k0|%k0, %1}"
22234 [(set_attr "isa" "noavx,avx")
22235 (set_attr "type" "ssemov")
22236 (set_attr "c86_attr" "movnt")
22237 (set (attr "prefix_data16")
22238 (if_then_else
22239 (match_test "TARGET_AVX")
22240 (const_string "*")
22241 (const_string "1")))
22242 (set_attr "prefix" "maybe_vex")
22243 (set_attr "mode" "SI")])
22244
22245 (define_insn_and_split "*sse2_pmovskb_zexthisi"
22246 [(set (match_operand:SI 0 "register_operand")
22247 (zero_extend:SI
22248 (subreg:HI
22249 (unspec:SI
22250 [(match_operand:V16QI 1 "register_operand")]
22251 UNSPEC_MOVMSK) 0)))]
22252 "TARGET_SSE2 && ix86_pre_reload_split ()"
22253 "#"
22254 "&& 1"
22255 [(set (match_dup 0)
22256 (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK))])
22257
22258 (define_split
22259 [(set (match_operand:SI 0 "register_operand")
22260 (zero_extend:SI
22261 (not:HI
22262 (subreg:HI
22263 (unspec:SI
22264 [(match_operand:V16QI 1 "register_operand")]
22265 UNSPEC_MOVMSK) 0))))]
22266 "TARGET_SSE2"
22267 [(set (match_dup 2)
22268 (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK))
22269 (set (match_dup 0)
22270 (xor:SI (match_dup 2) (const_int 65535)))]
22271 "operands[2] = gen_reg_rtx (SImode);")
22272
22273 (define_split
22274 [(set (match_operand:SI 0 "register_operand")
22275 (unspec:SI
22276 [(not:VI1_AVX2 (match_operand:VI1_AVX2 1 "register_operand"))]
22277 UNSPEC_MOVMSK))]
22278 "TARGET_SSE2"
22279 [(set (match_dup 2)
22280 (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK))
22281 (set (match_dup 0) (match_dup 3))]
22282 {
22283 operands[2] = gen_reg_rtx (SImode);
22284 if (GET_MODE_NUNITS (<MODE>mode) == 32)
22285 operands[3] = gen_rtx_NOT (SImode, operands[2]);
22286 else
22287 {
22288 operands[3]
22289 = gen_int_mode ((HOST_WIDE_INT_1 << GET_MODE_NUNITS (<MODE>mode)) - 1,
22290 SImode);
22291 operands[3] = gen_rtx_XOR (SImode, operands[2], operands[3]);
22292 }
22293 })
22294
22295 (define_split
22296 [(set (match_operand:SI 0 "register_operand")
22297 (unspec:SI
22298 [(subreg:VI1_AVX2 (not (match_operand 1 "register_operand")) 0)]
22299 UNSPEC_MOVMSK))]
22300 "TARGET_SSE2
22301 && GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_VECTOR_INT
22302 && GET_MODE_SIZE (GET_MODE (operands[1])) == <MODE_SIZE>"
22303 [(set (match_dup 2)
22304 (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK))
22305 (set (match_dup 0) (match_dup 3))]
22306 {
22307 operands[2] = gen_reg_rtx (SImode);
22308 operands[1] = gen_lowpart (<MODE>mode, operands[1]);
22309 if (GET_MODE_NUNITS (<MODE>mode) == 32)
22310 operands[3] = gen_rtx_NOT (SImode, operands[2]);
22311 else
22312 {
22313 operands[3]
22314 = gen_int_mode ((HOST_WIDE_INT_1 << GET_MODE_NUNITS (<MODE>mode)) - 1,
22315 SImode);
22316 operands[3] = gen_rtx_XOR (SImode, operands[2], operands[3]);
22317 }
22318 })
22319
22320 (define_insn_and_split "*<sse2_avx2>_pmovmskb_lt"
22321 [(set (match_operand:SI 0 "register_operand" "=r,jr")
22322 (unspec:SI
22323 [(lt:VI1_AVX2 (match_operand:VI1_AVX2 1 "register_operand" "x,x")
22324 (match_operand:VI1_AVX2 2 "const0_operand"))]
22325 UNSPEC_MOVMSK))]
22326 "TARGET_SSE2"
22327 "#"
22328 "&& 1"
22329 [(set (match_dup 0)
22330 (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK))]
22331 ""
22332 [(set_attr "isa" "noavx,avx")
22333 (set_attr "type" "ssemov")
22334 (set (attr "prefix_data16")
22335 (if_then_else
22336 (match_test "TARGET_AVX")
22337 (const_string "*")
22338 (const_string "1")))
22339 (set_attr "prefix" "maybe_vex")
22340 (set_attr "mode" "SI")])
22341
22342 (define_insn_and_split "*<sse2_avx2>_pmovmskb_lt_avx512"
22343 [(set (match_operand:SI 0 "register_operand" "=r,jr")
22344 (unspec:SI
22345 [(vec_merge:VI1_AVX2
22346 (match_operand:VI1_AVX2 3 "vector_all_ones_operand")
22347 (match_operand:VI1_AVX2 4 "const0_operand")
22348 (unspec:<avx512fmaskmode>
22349 [(match_operand:VI1_AVX2 1 "register_operand" "x,x")
22350 (match_operand:VI1_AVX2 2 "const0_operand")
22351 (const_int 1)]
22352 UNSPEC_PCMP))]
22353 UNSPEC_MOVMSK))]
22354 "TARGET_SSE2"
22355 "#"
22356 "&& 1"
22357 [(set (match_dup 0)
22358 (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK))]
22359 ""
22360 [(set_attr "isa" "noavx,avx")
22361 (set_attr "type" "ssemov")
22362 (set (attr "prefix_data16")
22363 (if_then_else
22364 (match_test "TARGET_AVX")
22365 (const_string "*")
22366 (const_string "1")))
22367 (set_attr "prefix" "maybe_vex")
22368 (set_attr "mode" "SI")])
22369
22370 (define_insn_and_split "*<sse2_avx2>_pmovmskb_zext_lt"
22371 [(set (match_operand:DI 0 "register_operand" "=r,jr")
22372 (zero_extend:DI
22373 (unspec:SI
22374 [(lt:VI1_AVX2 (match_operand:VI1_AVX2 1 "register_operand" "x,x")
22375 (match_operand:VI1_AVX2 2 "const0_operand"))]
22376 UNSPEC_MOVMSK)))]
22377 "TARGET_64BIT && TARGET_SSE2"
22378 "#"
22379 "&& 1"
22380 [(set (match_dup 0)
22381 (zero_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK)))]
22382 ""
22383 [(set_attr "isa" "noavx,avx")
22384 (set_attr "type" "ssemov")
22385 (set (attr "prefix_data16")
22386 (if_then_else
22387 (match_test "TARGET_AVX")
22388 (const_string "*")
22389 (const_string "1")))
22390 (set_attr "prefix" "maybe_vex")
22391 (set_attr "mode" "SI")])
22392
22393 (define_insn_and_split "*<sse2_avx2>_pmovmskb_zext_lt_avx512"
22394 [(set (match_operand:DI 0 "register_operand" "=r,jr")
22395 (zero_extend:DI
22396 (unspec:SI
22397 [(vec_merge:VI1_AVX2
22398 (match_operand:VI1_AVX2 3 "vector_all_ones_operand")
22399 (match_operand:VI1_AVX2 4 "const0_operand")
22400 (unspec:<avx512fmaskmode>
22401 [(match_operand:VI1_AVX2 1 "register_operand" "x,x")
22402 (match_operand:VI1_AVX2 2 "const0_operand")
22403 (const_int 1)]
22404 UNSPEC_PCMP))]
22405 UNSPEC_MOVMSK)))]
22406 "TARGET_64BIT && TARGET_SSE2"
22407 "#"
22408 "&& 1"
22409 [(set (match_dup 0)
22410 (zero_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK)))]
22411 ""
22412 [(set_attr "isa" "noavx,avx")
22413 (set_attr "type" "ssemov")
22414 (set (attr "prefix_data16")
22415 (if_then_else
22416 (match_test "TARGET_AVX")
22417 (const_string "*")
22418 (const_string "1")))
22419 (set_attr "prefix" "maybe_vex")
22420 (set_attr "mode" "SI")])
22421
22422 (define_insn_and_split "*sse2_pmovmskb_ext_lt"
22423 [(set (match_operand:DI 0 "register_operand" "=r,jr")
22424 (sign_extend:DI
22425 (unspec:SI
22426 [(lt:V16QI (match_operand:V16QI 1 "register_operand" "x,x")
22427 (match_operand:V16QI 2 "const0_operand"))]
22428 UNSPEC_MOVMSK)))]
22429 "TARGET_64BIT && TARGET_SSE2"
22430 "#"
22431 "&& 1"
22432 [(set (match_dup 0)
22433 (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK)))]
22434 ""
22435 [(set_attr "isa" "noavx,avx")
22436 (set_attr "type" "ssemov")
22437 (set (attr "prefix_data16")
22438 (if_then_else
22439 (match_test "TARGET_AVX")
22440 (const_string "*")
22441 (const_string "1")))
22442 (set_attr "prefix" "maybe_vex")
22443 (set_attr "mode" "SI")])
22444
22445 (define_insn_and_split "*sse2_pmovmskb_ext_lt_avx512"
22446 [(set (match_operand:DI 0 "register_operand" "=r,jr")
22447 (sign_extend:DI
22448 (unspec:SI
22449 [(vec_merge:VI1_AVX2
22450 (match_operand:VI1_AVX2 3 "vector_all_ones_operand")
22451 (match_operand:VI1_AVX2 4 "const0_operand")
22452 (unspec:<avx512fmaskmode>
22453 [(match_operand:VI1_AVX2 1 "register_operand" "x,x")
22454 (match_operand:VI1_AVX2 2 "const0_operand")
22455 (const_int 1)]
22456 UNSPEC_PCMP))]
22457 UNSPEC_MOVMSK)))]
22458 "TARGET_64BIT && TARGET_SSE2"
22459 "#"
22460 "&& 1"
22461 [(set (match_dup 0)
22462 (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK)))]
22463 ""
22464 [(set_attr "isa" "noavx,avx")
22465 (set_attr "type" "ssemov")
22466 (set (attr "prefix_data16")
22467 (if_then_else
22468 (match_test "TARGET_AVX")
22469 (const_string "*")
22470 (const_string "1")))
22471 (set_attr "prefix" "maybe_vex")
22472 (set_attr "mode" "SI")])
22473
22474 (define_insn_and_split "*pmovsk_kmask_v16qi_avx512"
22475 [(set (match_operand:SI 0 "register_operand")
22476 (unspec:SI
22477 [(vec_merge:V16QI
22478 (match_operand:V16QI 2 "vector_all_ones_operand")
22479 (match_operand:V16QI 3 "const0_operand")
22480 (match_operand:HI 1 "register_operand"))]
22481 UNSPEC_MOVMSK))]
22482 "TARGET_SSE2 && ix86_pre_reload_split ()"
22483 "#"
22484 "&& 1"
22485 [(set (match_dup 0)
22486 (zero_extend:SI (match_dup 1)))])
22487
22488 (define_insn_and_split "*pmovsk_mask_v32qi_avx512"
22489 [(set (match_operand:SI 0 "register_operand")
22490 (unspec:SI
22491 [(vec_merge:V32QI
22492 (match_operand:V32QI 2 "vector_all_ones_operand")
22493 (match_operand:V32QI 3 "const0_operand")
22494 (match_operand:SI 1 "register_operand"))]
22495 UNSPEC_MOVMSK))]
22496 "TARGET_SSE2 && ix86_pre_reload_split ()"
22497 "#"
22498 "&& 1"
22499 [(set (match_dup 0)
22500 (match_dup 1))])
22501
22502 ;; Optimize pxor/pcmpeqb/pmovmskb/cmp 0xffff to ptest.
22503 (define_mode_attr vi1avx2const
22504 [(V32QI "0xffffffff") (V16QI "0xffff")])
22505
22506 (define_split
22507 [(set (reg:CCZ FLAGS_REG)
22508 (compare:CCZ (unspec:SI
22509 [(eq:VI1_AVX2
22510 (match_operand:VI1_AVX2 0 "vector_operand")
22511 (match_operand:VI1_AVX2 1 "const0_operand"))]
22512 UNSPEC_MOVMSK)
22513 (match_operand 2 "const_int_operand")))]
22514 "TARGET_SSE4_1 && (INTVAL (operands[2]) == (int) (<vi1avx2const>))"
22515 [(set (reg:CCZ FLAGS_REG)
22516 (unspec:CCZ [(match_dup 0)
22517 (match_dup 0)]
22518 UNSPEC_PTEST))]
22519 "operands[0] = force_reg (<MODE>mode, operands[0]);")
22520
22521 (define_insn_and_split "*pmovsk_mask_cmp_<mode>_avx512"
22522 [(set (reg:CCZ FLAGS_REG)
22523 (compare:CCZ
22524 (unspec:SI
22525 [(vec_merge:VI1_AVX2
22526 (match_operand:VI1_AVX2 0 "vector_all_ones_operand")
22527 (match_operand:VI1_AVX2 3 "const0_operand")
22528 (match_operand:<avx512fmaskmode> 1 "register_operand"))]
22529 UNSPEC_MOVMSK)
22530 (match_operand 2 "const_int_operand")))]
22531 "TARGET_AVX512VL && UINTVAL (operands[2]) <= <vi1avx2const>"
22532 "#"
22533 "&& 1"
22534 [(set (reg:CCZ FLAGS_REG)
22535 (compare:CCZ
22536 (match_dup 1)
22537 (match_dup 2)))]
22538 "operands[2] = gen_int_mode (UINTVAL (operands[2]), <avx512fmaskmode>mode);")
22539
22540 (define_insn_and_split "*pmovsk_ptest_<mode>_avx512"
22541 [(set (reg:CCZ FLAGS_REG)
22542 (compare:CCZ
22543 (unspec:SI
22544 [(vec_merge:VI1_AVX2
22545 (match_operand:VI1_AVX2 3 "vector_all_ones_operand")
22546 (match_operand:VI1_AVX2 4 "const0_operand")
22547 (unspec:<avx512fmaskmode>
22548 [(match_operand:VI1_AVX2 0 "vector_operand")
22549 (match_operand:VI1_AVX2 1 "const0_operand")
22550 (const_int 0)]
22551 UNSPEC_PCMP))]
22552 UNSPEC_MOVMSK)
22553 (match_operand 2 "const_int_operand")))]
22554 "TARGET_AVX512VL && (INTVAL (operands[2]) == (int) (<vi1avx2const>))"
22555 "#"
22556 "&& 1"
22557 [(set (reg:CCZ FLAGS_REG)
22558 (unspec:CCZ [(match_dup 0)
22559 (match_dup 0)]
22560 UNSPEC_PTEST))]
22561 "operands[0] = force_reg (<MODE>mode, operands[0]);")
22562
22563 (define_expand "sse2_maskmovdqu"
22564 [(set (match_operand:V16QI 0 "memory_operand")
22565 (unspec:V16QI [(match_operand:V16QI 1 "register_operand")
22566 (match_operand:V16QI 2 "register_operand")
22567 (match_dup 0)]
22568 UNSPEC_MASKMOV))]
22569 "TARGET_SSE2")
22570
22571 (define_insn "*sse2_maskmovdqu"
22572 [(set (mem:V16QI (match_operand:P 0 "register_operand" "D"))
22573 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "x")
22574 (match_operand:V16QI 2 "register_operand" "x")
22575 (mem:V16QI (match_dup 0))]
22576 UNSPEC_MASKMOV))]
22577 "TARGET_SSE2"
22578 {
22579 /* We can't use %^ here due to ASM_OUTPUT_OPCODE processing
22580 that requires %v to be at the beginning of the opcode name. */
22581 if (Pmode != word_mode)
22582 fputs ("\taddr32", asm_out_file);
22583 return "%vmaskmovdqu\t{%2, %1|%1, %2}";
22584 }
22585 [(set_attr "type" "ssemov")
22586 (set_attr "c86_attr" "blend")
22587 (set_attr "prefix_data16" "1")
22588 (set (attr "length_address")
22589 (symbol_ref ("Pmode != word_mode")))
22590 ;; The implicit %rdi operand confuses default length_vex computation.
22591 (set (attr "length_vex")
22592 (symbol_ref ("3 + REX_SSE_REGNO_P (REGNO (operands[2]))")))
22593 (set_attr "prefix" "maybe_vex")
22594 (set_attr "znver1_decode" "vector")
22595 (set_attr "c86_decode" "vector")
22596 (set_attr "mode" "TI")])
22597
22598 (define_insn "sse_ldmxcsr"
22599 [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m,jm")]
22600 UNSPECV_LDMXCSR)]
22601 "TARGET_SSE"
22602 "%vldmxcsr\t%0"
22603 [(set_attr "isa" "noavx,avx")
22604 (set_attr "type" "sse")
22605 (set_attr "addr" "*,gpr16")
22606 (set_attr "atom_sse_attr" "mxcsr")
22607 (set_attr "prefix" "maybe_vex")
22608 (set_attr "memory" "load")])
22609
22610 (define_insn "sse_stmxcsr"
22611 [(set (match_operand:SI 0 "memory_operand" "=m,jm")
22612 (unspec_volatile:SI [(const_int 0)] UNSPECV_STMXCSR))]
22613 "TARGET_SSE"
22614 "%vstmxcsr\t%0"
22615 [(set_attr "isa" "noavx,avx")
22616 (set_attr "type" "sse")
22617 (set_attr "addr" "gpr16")
22618 (set_attr "atom_sse_attr" "mxcsr")
22619 (set_attr "prefix" "maybe_vex")
22620 (set_attr "memory" "store")])
22621
22622 (define_insn "sse2_clflush"
22623 [(unspec_volatile [(match_operand 0 "address_operand" "p")]
22624 UNSPECV_CLFLUSH)]
22625 "TARGET_SSE2"
22626 "clflush\t%a0"
22627 [(set_attr "type" "sse")
22628 (set_attr "atom_sse_attr" "fence")
22629 (set_attr "memory" "unknown")])
22630
22631 ;; As per AMD and Intel ISA manuals, the first operand is extensions
22632 ;; and it goes to %ecx. The second operand received is hints and it goes
22633 ;; to %eax.
22634 (define_insn "sse3_mwait"
22635 [(unspec_volatile [(match_operand:SI 0 "register_operand" "c")
22636 (match_operand:SI 1 "register_operand" "a")]
22637 UNSPECV_MWAIT)]
22638 "TARGET_MWAIT"
22639 ;; 64bit version is "mwait %rax,%rcx". But only lower 32bits are used.
22640 ;; Since 32bit register operands are implicitly zero extended to 64bit,
22641 ;; we only need to set up 32bit registers.
22642 "mwait"
22643 [(set_attr "length" "3")])
22644
22645 (define_insn "@sse3_monitor_<mode>"
22646 [(unspec_volatile [(match_operand:P 0 "register_operand" "a")
22647 (match_operand:SI 1 "register_operand" "c")
22648 (match_operand:SI 2 "register_operand" "d")]
22649 UNSPECV_MONITOR)]
22650 "TARGET_MWAIT"
22651 ;; 64bit version is "monitor %rax,%rcx,%rdx". But only lower 32bits in
22652 ;; RCX and RDX are used. Since 32bit register operands are implicitly
22653 ;; zero extended to 64bit, we only need to set up 32bit registers.
22654 "%^monitor"
22655 [(set (attr "length")
22656 (symbol_ref ("(Pmode != word_mode) + 3")))])
22657
22658 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22659 ;;
22660 ;; SSSE3 instructions
22661 ;;
22662 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22663
22664 (define_code_iterator ssse3_plusminus [plus ss_plus minus ss_minus])
22665
22666 (define_insn "avx2_ph<plusminus_mnemonic>wv16hi3"
22667 [(set (match_operand:V16HI 0 "register_operand" "=x")
22668 (ssse3_plusminus:V16HI
22669 (vec_select:V16HI
22670 (vec_concat:V32HI
22671 (match_operand:V16HI 1 "register_operand" "x")
22672 (match_operand:V16HI 2 "nonimmediate_operand" "xjm"))
22673 (parallel
22674 [(const_int 0) (const_int 2) (const_int 4) (const_int 6)
22675 (const_int 16) (const_int 18) (const_int 20) (const_int 22)
22676 (const_int 8) (const_int 10) (const_int 12) (const_int 14)
22677 (const_int 24) (const_int 26) (const_int 28) (const_int 30)]))
22678 (vec_select:V16HI
22679 (vec_concat:V32HI (match_dup 1) (match_dup 2))
22680 (parallel
22681 [(const_int 1) (const_int 3) (const_int 5) (const_int 7)
22682 (const_int 17) (const_int 19) (const_int 21) (const_int 23)
22683 (const_int 9) (const_int 11) (const_int 13) (const_int 15)
22684 (const_int 25) (const_int 27) (const_int 29) (const_int 31)]))))]
22685 "TARGET_AVX2"
22686 "vph<plusminus_mnemonic>w\t{%2, %1, %0|%0, %1, %2}"
22687 [(set_attr "type" "sseiadd")
22688 (set_attr "c86_attr" "hplus")
22689 (set_attr "addr" "gpr16")
22690 (set_attr "prefix_extra" "1")
22691 (set_attr "prefix" "vex")
22692 (set_attr "mode" "OI")])
22693
22694 (define_insn "ssse3_ph<plusminus_mnemonic>wv8hi3"
22695 [(set (match_operand:V8HI 0 "register_operand" "=x,x")
22696 (ssse3_plusminus:V8HI
22697 (vec_select:V8HI
22698 (vec_concat:V16HI
22699 (match_operand:V8HI 1 "register_operand" "0,x")
22700 (match_operand:V8HI 2 "vector_operand" "xja,xjm"))
22701 (parallel
22702 [(const_int 0) (const_int 2) (const_int 4) (const_int 6)
22703 (const_int 8) (const_int 10) (const_int 12) (const_int 14)]))
22704 (vec_select:V8HI
22705 (vec_concat:V16HI (match_dup 1) (match_dup 2))
22706 (parallel
22707 [(const_int 1) (const_int 3) (const_int 5) (const_int 7)
22708 (const_int 9) (const_int 11) (const_int 13) (const_int 15)]))))]
22709 "TARGET_SSSE3"
22710 "@
22711 ph<plusminus_mnemonic>w\t{%2, %0|%0, %2}
22712 vph<plusminus_mnemonic>w\t{%2, %1, %0|%0, %1, %2}"
22713 [(set_attr "isa" "noavx,avx")
22714 (set_attr "type" "sseiadd")
22715 (set_attr "c86_attr" "hplus")
22716 (set_attr "addr" "gpr16")
22717 (set_attr "atom_unit" "complex")
22718 (set_attr "prefix_extra" "1")
22719 (set_attr "prefix" "orig,vex")
22720 (set_attr "mode" "TI")])
22721
22722 (define_insn_and_split "ssse3_ph<plusminus_mnemonic>wv4hi3"
22723 [(set (match_operand:V4HI 0 "register_operand" "=y,x,x")
22724 (ssse3_plusminus:V4HI
22725 (vec_select:V4HI
22726 (vec_concat:V8HI
22727 (match_operand:V4HI 1 "register_operand" "0,0,x")
22728 (match_operand:V4HI 2 "register_mmxmem_operand" "ym,x,x"))
22729 (parallel
22730 [(const_int 0) (const_int 2) (const_int 4) (const_int 6)]))
22731 (vec_select:V4HI
22732 (vec_concat:V8HI (match_dup 1) (match_dup 2))
22733 (parallel
22734 [(const_int 1) (const_int 3) (const_int 5) (const_int 7)]))))]
22735 "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSSE3"
22736 "@
22737 ph<plusminus_mnemonic>w\t{%2, %0|%0, %2}
22738 #
22739 #"
22740 "TARGET_SSSE3 && reload_completed
22741 && SSE_REGNO_P (REGNO (operands[0]))"
22742 [(const_int 0)]
22743 {
22744 /* Generate SSE version of the operation. */
22745 rtx op0 = lowpart_subreg (V8HImode, operands[0],
22746 GET_MODE (operands[0]));
22747 rtx op1 = lowpart_subreg (V8HImode, operands[1],
22748 GET_MODE (operands[1]));
22749 rtx op2 = lowpart_subreg (V8HImode, operands[2],
22750 GET_MODE (operands[2]));
22751 emit_insn (gen_ssse3_ph<plusminus_mnemonic>wv8hi3 (op0, op1, op2));
22752 ix86_move_vector_high_sse_to_mmx (op0);
22753 DONE;
22754 }
22755 [(set_attr "mmx_isa" "native,sse_noavx,avx")
22756 (set_attr "type" "sseiadd")
22757 (set_attr "c86_attr" "hplus")
22758 (set_attr "atom_unit" "complex")
22759 (set_attr "prefix_extra" "1")
22760 (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
22761 (set_attr "mode" "DI,TI,TI")])
22762
22763 (define_insn "avx2_ph<plusminus_mnemonic>dv8si3"
22764 [(set (match_operand:V8SI 0 "register_operand" "=x")
22765 (plusminus:V8SI
22766 (vec_select:V8SI
22767 (vec_concat:V16SI
22768 (match_operand:V8SI 1 "register_operand" "x")
22769 (match_operand:V8SI 2 "nonimmediate_operand" "xjm"))
22770 (parallel
22771 [(const_int 0) (const_int 2) (const_int 8) (const_int 10)
22772 (const_int 4) (const_int 6) (const_int 12) (const_int 14)]))
22773 (vec_select:V8SI
22774 (vec_concat:V16SI (match_dup 1) (match_dup 2))
22775 (parallel
22776 [(const_int 1) (const_int 3) (const_int 9) (const_int 11)
22777 (const_int 5) (const_int 7) (const_int 13) (const_int 15)]))))]
22778 "TARGET_AVX2"
22779 "vph<plusminus_mnemonic>d\t{%2, %1, %0|%0, %1, %2}"
22780 [(set_attr "type" "sseiadd")
22781 (set_attr "c86_attr" "hplus")
22782 (set_attr "addr" "gpr16")
22783 (set_attr "prefix_extra" "1")
22784 (set_attr "prefix" "vex")
22785 (set_attr "mode" "OI")])
22786
22787 (define_insn "ssse3_ph<plusminus_mnemonic>dv4si3"
22788 [(set (match_operand:V4SI 0 "register_operand" "=x,x")
22789 (plusminus:V4SI
22790 (vec_select:V4SI
22791 (vec_concat:V8SI
22792 (match_operand:V4SI 1 "register_operand" "0,x")
22793 (match_operand:V4SI 2 "vector_operand" "xja,xjm"))
22794 (parallel
22795 [(const_int 0) (const_int 2) (const_int 4) (const_int 6)]))
22796 (vec_select:V4SI
22797 (vec_concat:V8SI (match_dup 1) (match_dup 2))
22798 (parallel
22799 [(const_int 1) (const_int 3) (const_int 5) (const_int 7)]))))]
22800 "TARGET_SSSE3"
22801 "@
22802 ph<plusminus_mnemonic>d\t{%2, %0|%0, %2}
22803 vph<plusminus_mnemonic>d\t{%2, %1, %0|%0, %1, %2}"
22804 [(set_attr "isa" "noavx,avx")
22805 (set_attr "type" "sseiadd")
22806 (set_attr "c86_attr" "hplus")
22807 (set_attr "addr" "gpr16")
22808 (set_attr "atom_unit" "complex")
22809 (set_attr "prefix_data16" "1,*")
22810 (set_attr "prefix_extra" "1")
22811 (set_attr "prefix" "orig,vex")
22812 (set_attr "mode" "TI")])
22813
22814 (define_insn_and_split "ssse3_ph<plusminus_mnemonic>dv2si3"
22815 [(set (match_operand:V2SI 0 "register_operand" "=y,x,x")
22816 (plusminus:V2SI
22817 (vec_select:V2SI
22818 (vec_concat:V4SI
22819 (match_operand:V2SI 1 "register_operand" "0,0,x")
22820 (match_operand:V2SI 2 "register_mmxmem_operand" "ym,x,x"))
22821 (parallel [(const_int 0) (const_int 2)]))
22822 (vec_select:V2SI
22823 (vec_concat:V4SI (match_dup 1) (match_dup 2))
22824 (parallel [(const_int 1) (const_int 3)]))))]
22825 "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSSE3"
22826 "@
22827 ph<plusminus_mnemonic>d\t{%2, %0|%0, %2}
22828 #
22829 #"
22830 "TARGET_SSSE3 && reload_completed
22831 && SSE_REGNO_P (REGNO (operands[0]))"
22832 [(const_int 0)]
22833 {
22834 /* Generate SSE version of the operation. */
22835 rtx op0 = lowpart_subreg (V4SImode, operands[0],
22836 GET_MODE (operands[0]));
22837 rtx op1 = lowpart_subreg (V4SImode, operands[1],
22838 GET_MODE (operands[1]));
22839 rtx op2 = lowpart_subreg (V4SImode, operands[2],
22840 GET_MODE (operands[2]));
22841 emit_insn (gen_ssse3_ph<plusminus_mnemonic>dv4si3 (op0, op1, op2));
22842 ix86_move_vector_high_sse_to_mmx (op0);
22843 DONE;
22844 }
22845 [(set_attr "mmx_isa" "native,sse_noavx,avx")
22846 (set_attr "type" "sseiadd")
22847 (set_attr "c86_attr" "hplus")
22848 (set_attr "addr" "gpr16")
22849 (set_attr "atom_unit" "complex")
22850 (set_attr "prefix_extra" "1")
22851 (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
22852 (set_attr "mode" "DI,TI,TI")])
22853
22854 (define_insn "avx2_pmaddubsw256"
22855 [(set (match_operand:V16HI 0 "register_operand" "=Yw")
22856 (ss_plus:V16HI
22857 (mult:V16HI
22858 (zero_extend:V16HI
22859 (vec_select:V16QI
22860 (match_operand:V32QI 1 "register_operand" "Yw")
22861 (parallel [(const_int 0) (const_int 2)
22862 (const_int 4) (const_int 6)
22863 (const_int 8) (const_int 10)
22864 (const_int 12) (const_int 14)
22865 (const_int 16) (const_int 18)
22866 (const_int 20) (const_int 22)
22867 (const_int 24) (const_int 26)
22868 (const_int 28) (const_int 30)])))
22869 (sign_extend:V16HI
22870 (vec_select:V16QI
22871 (match_operand:V32QI 2 "nonimmediate_operand" "Ywm")
22872 (parallel [(const_int 0) (const_int 2)
22873 (const_int 4) (const_int 6)
22874 (const_int 8) (const_int 10)
22875 (const_int 12) (const_int 14)
22876 (const_int 16) (const_int 18)
22877 (const_int 20) (const_int 22)
22878 (const_int 24) (const_int 26)
22879 (const_int 28) (const_int 30)]))))
22880 (mult:V16HI
22881 (zero_extend:V16HI
22882 (vec_select:V16QI (match_dup 1)
22883 (parallel [(const_int 1) (const_int 3)
22884 (const_int 5) (const_int 7)
22885 (const_int 9) (const_int 11)
22886 (const_int 13) (const_int 15)
22887 (const_int 17) (const_int 19)
22888 (const_int 21) (const_int 23)
22889 (const_int 25) (const_int 27)
22890 (const_int 29) (const_int 31)])))
22891 (sign_extend:V16HI
22892 (vec_select:V16QI (match_dup 2)
22893 (parallel [(const_int 1) (const_int 3)
22894 (const_int 5) (const_int 7)
22895 (const_int 9) (const_int 11)
22896 (const_int 13) (const_int 15)
22897 (const_int 17) (const_int 19)
22898 (const_int 21) (const_int 23)
22899 (const_int 25) (const_int 27)
22900 (const_int 29) (const_int 31)]))))))]
22901 "TARGET_AVX2"
22902 "vpmaddubsw\t{%2, %1, %0|%0, %1, %2}"
22903 [(set_attr "type" "sseiadd")
22904 (set_attr "c86_attr" "madd")
22905 (set_attr "prefix_extra" "1")
22906 (set_attr "prefix" "vex")
22907 (set_attr "mode" "OI")])
22908
22909 ;; The correct representation for this is absolutely enormous, and
22910 ;; surely not generally useful.
22911 (define_insn "avx512bw_pmaddubsw512<mode><mask_name>"
22912 [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
22913 (unspec:VI2_AVX512VL
22914 [(match_operand:<dbpsadbwmode> 1 "register_operand" "v")
22915 (match_operand:<dbpsadbwmode> 2 "nonimmediate_operand" "vm")]
22916 UNSPEC_PMADDUBSW512))]
22917 "TARGET_AVX512BW"
22918 "vpmaddubsw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}";
22919 [(set_attr "type" "sseiadd")
22920 (set_attr "c86_attr" "madd")
22921 (set_attr "prefix" "evex")
22922 (set_attr "mode" "XI")])
22923
22924 (define_insn "avx512bw_umulhrswv32hi3<mask_name>"
22925 [(set (match_operand:V32HI 0 "register_operand" "=v")
22926 (truncate:V32HI
22927 (lshiftrt:V32SI
22928 (plus:V32SI
22929 (lshiftrt:V32SI
22930 (mult:V32SI
22931 (sign_extend:V32SI
22932 (match_operand:V32HI 1 "nonimmediate_operand" "%v"))
22933 (sign_extend:V32SI
22934 (match_operand:V32HI 2 "nonimmediate_operand" "vm")))
22935 (const_int 14))
22936 (const_vector:V32HI [(const_int 1) (const_int 1)
22937 (const_int 1) (const_int 1)
22938 (const_int 1) (const_int 1)
22939 (const_int 1) (const_int 1)
22940 (const_int 1) (const_int 1)
22941 (const_int 1) (const_int 1)
22942 (const_int 1) (const_int 1)
22943 (const_int 1) (const_int 1)
22944 (const_int 1) (const_int 1)
22945 (const_int 1) (const_int 1)
22946 (const_int 1) (const_int 1)
22947 (const_int 1) (const_int 1)
22948 (const_int 1) (const_int 1)
22949 (const_int 1) (const_int 1)
22950 (const_int 1) (const_int 1)
22951 (const_int 1) (const_int 1)]))
22952 (const_int 1))))]
22953 "TARGET_AVX512BW && TARGET_EVEX512"
22954 "vpmulhrsw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
22955 [(set_attr "type" "sseimul")
22956 (set_attr "prefix" "evex")
22957 (set_attr "mode" "XI")])
22958
22959 (define_insn "ssse3_pmaddubsw128"
22960 [(set (match_operand:V8HI 0 "register_operand" "=x,Yw")
22961 (ss_plus:V8HI
22962 (mult:V8HI
22963 (zero_extend:V8HI
22964 (vec_select:V8QI
22965 (match_operand:V16QI 1 "register_operand" "0,Yw")
22966 (parallel [(const_int 0) (const_int 2)
22967 (const_int 4) (const_int 6)
22968 (const_int 8) (const_int 10)
22969 (const_int 12) (const_int 14)])))
22970 (sign_extend:V8HI
22971 (vec_select:V8QI
22972 (match_operand:V16QI 2 "vector_operand" "xja,Ywm")
22973 (parallel [(const_int 0) (const_int 2)
22974 (const_int 4) (const_int 6)
22975 (const_int 8) (const_int 10)
22976 (const_int 12) (const_int 14)]))))
22977 (mult:V8HI
22978 (zero_extend:V8HI
22979 (vec_select:V8QI (match_dup 1)
22980 (parallel [(const_int 1) (const_int 3)
22981 (const_int 5) (const_int 7)
22982 (const_int 9) (const_int 11)
22983 (const_int 13) (const_int 15)])))
22984 (sign_extend:V8HI
22985 (vec_select:V8QI (match_dup 2)
22986 (parallel [(const_int 1) (const_int 3)
22987 (const_int 5) (const_int 7)
22988 (const_int 9) (const_int 11)
22989 (const_int 13) (const_int 15)]))))))]
22990 "TARGET_SSSE3"
22991 "@
22992 pmaddubsw\t{%2, %0|%0, %2}
22993 vpmaddubsw\t{%2, %1, %0|%0, %1, %2}"
22994 [(set_attr "isa" "noavx,avx")
22995 (set_attr "addr" "gpr16,*")
22996 (set_attr "type" "sseiadd")
22997 (set_attr "c86_attr" "madd")
22998 (set_attr "atom_unit" "simul")
22999 (set_attr "prefix_extra" "1")
23000 (set_attr "prefix" "orig,vex")
23001 (set_attr "mode" "TI")])
23002
23003 (define_insn "ssse3_pmaddubsw"
23004 [(set (match_operand:V4HI 0 "register_operand" "=y,x,Yv")
23005 (ss_plus:V4HI
23006 (mult:V4HI
23007 (zero_extend:V4HI
23008 (vec_select:V4QI
23009 (match_operand:V8QI 1 "register_operand" "0,0,Yv")
23010 (parallel [(const_int 0) (const_int 2)
23011 (const_int 4) (const_int 6)])))
23012 (sign_extend:V4HI
23013 (vec_select:V4QI
23014 (match_operand:V8QI 2 "register_mmxmem_operand" "ym,x,Yv")
23015 (parallel [(const_int 0) (const_int 2)
23016 (const_int 4) (const_int 6)]))))
23017 (mult:V4HI
23018 (zero_extend:V4HI
23019 (vec_select:V4QI (match_dup 1)
23020 (parallel [(const_int 1) (const_int 3)
23021 (const_int 5) (const_int 7)])))
23022 (sign_extend:V4HI
23023 (vec_select:V4QI (match_dup 2)
23024 (parallel [(const_int 1) (const_int 3)
23025 (const_int 5) (const_int 7)]))))))]
23026 "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSSE3"
23027 "@
23028 pmaddubsw\t{%2, %0|%0, %2}
23029 pmaddubsw\t{%2, %0|%0, %2}
23030 vpmaddubsw\t{%2, %1, %0|%0, %1, %2}"
23031 [(set_attr "isa" "*,noavx,avx")
23032 (set_attr "mmx_isa" "native,*,*")
23033 (set_attr "type" "sseiadd")
23034 (set_attr "c86_attr" "madd")
23035 (set_attr "atom_unit" "simul")
23036 (set_attr "prefix_extra" "1")
23037 (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
23038 (set_attr "mode" "DI,TI,TI")])
23039
23040 (define_mode_iterator PMULHRSW
23041 [V8HI (V16HI "TARGET_AVX2")])
23042
23043 (define_expand "<ssse3_avx2>_pmulhrsw<mode>3_mask"
23044 [(set (match_operand:PMULHRSW 0 "register_operand")
23045 (vec_merge:PMULHRSW
23046 (truncate:PMULHRSW
23047 (lshiftrt:<ssedoublemode>
23048 (plus:<ssedoublemode>
23049 (lshiftrt:<ssedoublemode>
23050 (mult:<ssedoublemode>
23051 (sign_extend:<ssedoublemode>
23052 (match_operand:PMULHRSW 1 "nonimmediate_operand"))
23053 (sign_extend:<ssedoublemode>
23054 (match_operand:PMULHRSW 2 "nonimmediate_operand")))
23055 (const_int 14))
23056 (match_dup 5))
23057 (const_int 1)))
23058 (match_operand:PMULHRSW 3 "register_operand")
23059 (match_operand:<avx512fmaskmode> 4 "register_operand")))]
23060 "TARGET_AVX512BW && TARGET_AVX512VL"
23061 {
23062 operands[5] = CONST1_RTX(<MODE>mode);
23063 ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
23064 })
23065
23066 (define_expand "<ssse3_avx2>_pmulhrsw<mode>3"
23067 [(set (match_operand:PMULHRSW 0 "register_operand")
23068 (truncate:PMULHRSW
23069 (lshiftrt:<ssedoublemode>
23070 (plus:<ssedoublemode>
23071 (lshiftrt:<ssedoublemode>
23072 (mult:<ssedoublemode>
23073 (sign_extend:<ssedoublemode>
23074 (match_operand:PMULHRSW 1 "nonimmediate_operand"))
23075 (sign_extend:<ssedoublemode>
23076 (match_operand:PMULHRSW 2 "nonimmediate_operand")))
23077 (const_int 14))
23078 (match_dup 3))
23079 (const_int 1))))]
23080 "TARGET_SSSE3"
23081 {
23082 operands[3] = CONST1_RTX(<MODE>mode);
23083 ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
23084 })
23085
23086 (define_expand "smulhrs<mode>3"
23087 [(set (match_operand:VI2_AVX2_AVX512BW 0 "register_operand")
23088 (truncate:VI2_AVX2_AVX512BW
23089 (lshiftrt:<ssedoublemode>
23090 (plus:<ssedoublemode>
23091 (lshiftrt:<ssedoublemode>
23092 (mult:<ssedoublemode>
23093 (sign_extend:<ssedoublemode>
23094 (match_operand:VI2_AVX2_AVX512BW 1 "nonimmediate_operand"))
23095 (sign_extend:<ssedoublemode>
23096 (match_operand:VI2_AVX2_AVX512BW 2 "nonimmediate_operand")))
23097 (const_int 14))
23098 (match_dup 3))
23099 (const_int 1))))]
23100 "TARGET_SSSE3"
23101 {
23102 operands[3] = CONST1_RTX(<MODE>mode);
23103 ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
23104 })
23105
23106 (define_insn "*<ssse3_avx2>_pmulhrsw<mode>3<mask_name>"
23107 [(set (match_operand:VI2_AVX2_AVX512BW 0 "register_operand" "=x,<v_Yw>")
23108 (truncate:VI2_AVX2_AVX512BW
23109 (lshiftrt:<ssedoublemode>
23110 (plus:<ssedoublemode>
23111 (lshiftrt:<ssedoublemode>
23112 (mult:<ssedoublemode>
23113 (sign_extend:<ssedoublemode>
23114 (match_operand:VI2_AVX2_AVX512BW 1 "vector_operand" "%0,<v_Yw>"))
23115 (sign_extend:<ssedoublemode>
23116 (match_operand:VI2_AVX2_AVX512BW 2 "vector_operand" "xja,<v_Yw>m")))
23117 (const_int 14))
23118 (match_operand:VI2_AVX2_AVX512BW 3 "const1_operand"))
23119 (const_int 1))))]
23120 "TARGET_SSSE3 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
23121 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
23122 "@
23123 pmulhrsw\t{%2, %0|%0, %2}
23124 vpmulhrsw\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}"
23125 [(set_attr "isa" "noavx,avx")
23126 (set_attr "addr" "gpr16,*")
23127 (set_attr "type" "sseimul")
23128 (set_attr "prefix_extra" "1")
23129 (set_attr "prefix" "orig,maybe_evex")
23130 (set_attr "mode" "<sseinsnmode>")])
23131
23132 (define_expand "smulhrsv4hi3"
23133 [(set (match_operand:V4HI 0 "register_operand")
23134 (truncate:V4HI
23135 (lshiftrt:V4SI
23136 (plus:V4SI
23137 (lshiftrt:V4SI
23138 (mult:V4SI
23139 (sign_extend:V4SI
23140 (match_operand:V4HI 1 "register_operand"))
23141 (sign_extend:V4SI
23142 (match_operand:V4HI 2 "register_operand")))
23143 (const_int 14))
23144 (match_dup 3))
23145 (const_int 1))))]
23146 "TARGET_MMX_WITH_SSE && TARGET_SSSE3"
23147 "operands[3] = CONST1_RTX(V4HImode);")
23148
23149 (define_expand "ssse3_pmulhrswv4hi3"
23150 [(set (match_operand:V4HI 0 "register_operand")
23151 (truncate:V4HI
23152 (lshiftrt:V4SI
23153 (plus:V4SI
23154 (lshiftrt:V4SI
23155 (mult:V4SI
23156 (sign_extend:V4SI
23157 (match_operand:V4HI 1 "register_mmxmem_operand"))
23158 (sign_extend:V4SI
23159 (match_operand:V4HI 2 "register_mmxmem_operand")))
23160 (const_int 14))
23161 (match_dup 3))
23162 (const_int 1))))]
23163 "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSSE3"
23164 {
23165 operands[3] = CONST1_RTX(V4HImode);
23166 ix86_fixup_binary_operands_no_copy (MULT, V4HImode, operands);
23167 })
23168
23169 (define_insn "*ssse3_pmulhrswv4hi3"
23170 [(set (match_operand:V4HI 0 "register_operand" "=y,x,Yv")
23171 (truncate:V4HI
23172 (lshiftrt:V4SI
23173 (plus:V4SI
23174 (lshiftrt:V4SI
23175 (mult:V4SI
23176 (sign_extend:V4SI
23177 (match_operand:V4HI 1 "register_mmxmem_operand" "%0,0,Yv"))
23178 (sign_extend:V4SI
23179 (match_operand:V4HI 2 "register_mmxmem_operand" "ym,x,Yv")))
23180 (const_int 14))
23181 (match_operand:V4HI 3 "const1_operand"))
23182 (const_int 1))))]
23183 "(TARGET_MMX || TARGET_MMX_WITH_SSE)
23184 && TARGET_SSSE3
23185 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
23186 "@
23187 pmulhrsw\t{%2, %0|%0, %2}
23188 pmulhrsw\t{%2, %0|%0, %2}
23189 vpmulhrsw\t{%2, %1, %0|%0, %1, %2}"
23190 [(set_attr "isa" "*,noavx,avx")
23191 (set_attr "mmx_isa" "native,*,*")
23192 (set_attr "type" "sseimul")
23193 (set_attr "prefix_extra" "1")
23194 (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
23195 (set_attr "mode" "DI,TI,TI")])
23196
23197 (define_expand "smulhrsv2hi3"
23198 [(set (match_operand:V2HI 0 "register_operand")
23199 (truncate:V2HI
23200 (lshiftrt:V2SI
23201 (plus:V2SI
23202 (lshiftrt:V2SI
23203 (mult:V2SI
23204 (sign_extend:V2SI
23205 (match_operand:V2HI 1 "register_operand"))
23206 (sign_extend:V2SI
23207 (match_operand:V2HI 2 "register_operand")))
23208 (const_int 14))
23209 (match_dup 3))
23210 (const_int 1))))]
23211 "TARGET_SSSE3"
23212 "operands[3] = CONST1_RTX(V2HImode);")
23213
23214 (define_insn "*smulhrsv2hi3"
23215 [(set (match_operand:V2HI 0 "register_operand" "=x,Yv")
23216 (truncate:V2HI
23217 (lshiftrt:V2SI
23218 (plus:V2SI
23219 (lshiftrt:V2SI
23220 (mult:V2SI
23221 (sign_extend:V2SI
23222 (match_operand:V2HI 1 "register_operand" "%0,Yv"))
23223 (sign_extend:V2SI
23224 (match_operand:V2HI 2 "register_operand" "x,Yv")))
23225 (const_int 14))
23226 (match_operand:V2HI 3 "const1_operand"))
23227 (const_int 1))))]
23228 "TARGET_SSSE3
23229 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
23230 "@
23231 pmulhrsw\t{%2, %0|%0, %2}
23232 vpmulhrsw\t{%2, %1, %0|%0, %1, %2}"
23233 [(set_attr "isa" "noavx,avx")
23234 (set_attr "type" "sseimul")
23235 (set_attr "prefix_extra" "1")
23236 (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
23237 (set_attr "mode" "TI")])
23238
23239 (define_insn "<ssse3_avx2>_pshufb<mode>3<mask_name>"
23240 [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,<v_Yw>")
23241 (unspec:VI1_AVX512
23242 [(match_operand:VI1_AVX512 1 "register_operand" "0,<v_Yw>")
23243 (match_operand:VI1_AVX512 2 "vector_operand" "xja,<v_Yw>m")]
23244 UNSPEC_PSHUFB))]
23245 "TARGET_SSSE3 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
23246 "@
23247 pshufb\t{%2, %0|%0, %2}
23248 vpshufb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
23249 [(set_attr "isa" "noavx,avx")
23250 (set_attr "addr" "gpr16,*")
23251 (set_attr "type" "sselog1")
23252 (set_attr "prefix_extra" "1")
23253 (set_attr "prefix" "orig,maybe_evex")
23254 (set_attr "btver2_decode" "vector")
23255 (set_attr "mode" "<sseinsnmode>")])
23256
23257 (define_expand "ssse3_pshufbv8qi3"
23258 [(parallel
23259 [(set (match_operand:V8QI 0 "register_operand")
23260 (unspec:V8QI [(match_operand:V8QI 1 "register_operand")
23261 (match_operand:V8QI 2 "register_mmxmem_operand")
23262 (match_dup 3)] UNSPEC_PSHUFB))
23263 (clobber (match_scratch:V4SI 4))])]
23264 "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSSE3"
23265 {
23266 operands[3] = ix86_build_const_vector (V4SImode, true,
23267 gen_int_mode (0xf7f7f7f7, SImode));
23268 })
23269
23270 (define_insn_and_split "*ssse3_pshufbv8qi3"
23271 [(set (match_operand:V8QI 0 "register_operand" "=y,x,Yw")
23272 (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "0,0,Yw")
23273 (match_operand:V8QI 2 "register_mmxmem_operand" "ym,x,Yw")
23274 (match_operand:V4SI 4 "reg_or_const_vector_operand"
23275 "i,3,3")]
23276 UNSPEC_PSHUFB))
23277 (clobber (match_scratch:V4SI 3 "=X,&x,&Yw"))]
23278 "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSSE3"
23279 "@
23280 pshufb\t{%2, %0|%0, %2}
23281 #
23282 #"
23283 "TARGET_SSSE3 && reload_completed
23284 && SSE_REGNO_P (REGNO (operands[0]))"
23285 [(set (match_dup 3)
23286 (and:V4SI (match_dup 3) (match_dup 2)))
23287 (set (match_dup 0)
23288 (unspec:V16QI [(match_dup 1) (match_dup 4)] UNSPEC_PSHUFB))]
23289 {
23290 /* Emulate MMX version of pshufb with SSE version by masking out the
23291 bit 3 of the shuffle control byte. */
23292 operands[0] = lowpart_subreg (V16QImode, operands[0],
23293 GET_MODE (operands[0]));
23294 operands[1] = lowpart_subreg (V16QImode, operands[1],
23295 GET_MODE (operands[1]));
23296 operands[2] = lowpart_subreg (V4SImode, operands[2],
23297 GET_MODE (operands[2]));
23298 operands[4] = lowpart_subreg (V16QImode, operands[3],
23299 GET_MODE (operands[3]));
23300 }
23301 [(set_attr "mmx_isa" "native,sse_noavx,avx")
23302 (set_attr "prefix_extra" "1")
23303 (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
23304 (set_attr "mode" "DI,TI,TI")])
23305
23306 (define_insn "<ssse3_avx2>_psign<mode>3"
23307 [(set (match_operand:VI124_AVX2 0 "register_operand" "=x,x")
23308 (unspec:VI124_AVX2
23309 [(match_operand:VI124_AVX2 1 "register_operand" "0,x")
23310 (match_operand:VI124_AVX2 2 "vector_operand" "xja,xjm")]
23311 UNSPEC_PSIGN))]
23312 "TARGET_SSSE3"
23313 "@
23314 psign<ssemodesuffix>\t{%2, %0|%0, %2}
23315 vpsign<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
23316 [(set_attr "isa" "noavx,avx")
23317 (set_attr "type" "sselog1")
23318 (set_attr "c86_attr" "sign")
23319 (set_attr "addr" "gpr16")
23320 (set_attr "prefix_extra" "1")
23321 (set_attr "prefix" "orig,vex")
23322 (set_attr "mode" "<sseinsnmode>")])
23323
23324 (define_insn "ssse3_psign<mode>3"
23325 [(set (match_operand:MMXMODEI 0 "register_operand" "=y,x,x")
23326 (unspec:MMXMODEI
23327 [(match_operand:MMXMODEI 1 "register_operand" "0,0,x")
23328 (match_operand:MMXMODEI 2 "register_mmxmem_operand" "ym,x,x")]
23329 UNSPEC_PSIGN))]
23330 "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSSE3"
23331 "@
23332 psign<mmxvecsize>\t{%2, %0|%0, %2}
23333 psign<mmxvecsize>\t{%2, %0|%0, %2}
23334 vpsign<mmxvecsize>\t{%2, %1, %0|%0, %1, %2}"
23335 [(set_attr "isa" "*,noavx,avx")
23336 (set_attr "mmx_isa" "native,*,*")
23337 (set_attr "type" "sselog1")
23338 (set_attr "c86_attr" "sign")
23339 (set_attr "prefix_extra" "1")
23340 (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
23341 (set_attr "mode" "DI,TI,TI")])
23342
23343 (define_insn "<ssse3_avx2>_palignr<mode>_mask"
23344 [(set (match_operand:VI1_AVX512 0 "register_operand" "=v")
23345 (vec_merge:VI1_AVX512
23346 (unspec:VI1_AVX512
23347 [(match_operand:VI1_AVX512 1 "register_operand" "v")
23348 (match_operand:VI1_AVX512 2 "nonimmediate_operand" "vm")
23349 (match_operand:SI 3 "const_0_to_255_mul_8_operand")]
23350 UNSPEC_PALIGNR)
23351 (match_operand:VI1_AVX512 4 "nonimm_or_0_operand" "0C")
23352 (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
23353 "TARGET_AVX512BW && (<MODE_SIZE> == 64 || TARGET_AVX512VL)"
23354 {
23355 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
23356 return "vpalignr\t{%3, %2, %1, %0%{%5%}%N4|%0%{%5%}%N4, %1, %2, %3}";
23357 }
23358 [(set_attr "type" "sseishft")
23359 (set_attr "atom_unit" "sishuf")
23360 (set_attr "length_immediate" "1")
23361 (set_attr "prefix" "evex")
23362 (set_attr "mode" "<sseinsnmode>")])
23363
23364 (define_insn "<ssse3_avx2>_palignr<mode>"
23365 [(set (match_operand:VIMAX_AVX2_AVX512BW 0 "register_operand" "=x,<v_Yw>")
23366 (unspec:VIMAX_AVX2_AVX512BW
23367 [(match_operand:VIMAX_AVX2_AVX512BW 1 "register_operand" "0,<v_Yw>")
23368 (match_operand:VIMAX_AVX2_AVX512BW 2 "vector_operand" "xja,<v_Yw>m")
23369 (match_operand:SI 3 "const_0_to_255_mul_8_operand")]
23370 UNSPEC_PALIGNR))]
23371 "TARGET_SSSE3"
23372 {
23373 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
23374
23375 switch (which_alternative)
23376 {
23377 case 0:
23378 return "palignr\t{%3, %2, %0|%0, %2, %3}";
23379 case 1:
23380 return "vpalignr\t{%3, %2, %1, %0|%0, %1, %2, %3}";
23381 default:
23382 gcc_unreachable ();
23383 }
23384 }
23385 [(set_attr "isa" "noavx,avx")
23386 (set_attr "addr" "gpr16,*")
23387 (set_attr "type" "sseishft")
23388 (set_attr "atom_unit" "sishuf")
23389 (set_attr "prefix_extra" "1")
23390 (set_attr "length_immediate" "1")
23391 (set_attr "prefix" "orig,vex")
23392 (set_attr "mode" "<sseinsnmode>")])
23393
23394 (define_insn_and_split "ssse3_palignrdi"
23395 [(set (match_operand:DI 0 "register_operand" "=y,x,Yw")
23396 (unspec:DI [(match_operand:DI 1 "register_operand" "0,0,Yw")
23397 (match_operand:DI 2 "register_mmxmem_operand" "ym,x,Yw")
23398 (match_operand:SI 3 "const_0_to_255_mul_8_operand")]
23399 UNSPEC_PALIGNR))]
23400 "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSSE3"
23401 {
23402 switch (which_alternative)
23403 {
23404 case 0:
23405 operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
23406 return "palignr\t{%3, %2, %0|%0, %2, %3}";
23407 case 1:
23408 case 2:
23409 return "#";
23410 default:
23411 gcc_unreachable ();
23412 }
23413 }
23414 "(TARGET_SSSE3 && reload_completed
23415 && SSE_REGNO_P (REGNO (operands[0])))
23416 || operands[3] == const0_rtx
23417 || INTVAL (operands[3]) == 64"
23418 [(set (match_dup 0)
23419 (lshiftrt:V1TI (match_dup 0) (match_dup 3)))]
23420 {
23421 if (operands[3] == const0_rtx)
23422 {
23423 if (!rtx_equal_p (operands[0], operands[2]))
23424 emit_move_insn (operands[0], operands[2]);
23425 else
23426 emit_note (NOTE_INSN_DELETED);
23427 DONE;
23428 }
23429 else if (INTVAL (operands[3]) == 64)
23430 {
23431 if (!rtx_equal_p (operands[0], operands[1]))
23432 emit_move_insn (operands[0], operands[1]);
23433 else
23434 emit_note (NOTE_INSN_DELETED);
23435 DONE;
23436 }
23437
23438 /* Emulate MMX palignrdi with SSE psrldq. */
23439 rtx op0 = lowpart_subreg (V2DImode, operands[0],
23440 GET_MODE (operands[0]));
23441 if (TARGET_AVX)
23442 emit_insn (gen_vec_concatv2di (op0, operands[2], operands[1]));
23443 else
23444 {
23445 /* NB: SSE can only concatenate OP0 and OP1 to OP0. */
23446 emit_insn (gen_vec_concatv2di (op0, operands[1], operands[2]));
23447 /* Swap bits 0:63 with bits 64:127. */
23448 rtx mask = gen_rtx_PARALLEL (VOIDmode,
23449 gen_rtvec (4, GEN_INT (2),
23450 GEN_INT (3),
23451 GEN_INT (0),
23452 GEN_INT (1)));
23453 rtx op1 = lowpart_subreg (V4SImode, op0, GET_MODE (op0));
23454 rtx op2 = gen_rtx_VEC_SELECT (V4SImode, op1, mask);
23455 emit_insn (gen_rtx_SET (op1, op2));
23456 }
23457 operands[0] = lowpart_subreg (V1TImode, op0, GET_MODE (op0));
23458 }
23459 [(set_attr "mmx_isa" "native,sse_noavx,avx")
23460 (set_attr "type" "sseishft")
23461 (set_attr "addr" "gpr16,gpr16,*")
23462 (set_attr "atom_unit" "sishuf")
23463 (set_attr "prefix_extra" "1")
23464 (set_attr "length_immediate" "1")
23465 (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
23466 (set_attr "mode" "DI,TI,TI")])
23467
23468 ;; Mode iterator to handle singularity w/ absence of V2DI and V4DI
23469 ;; modes for abs instruction on pre AVX-512 targets.
23470 (define_mode_iterator VI1248_AVX512VL_AVX512BW
23471 [(V64QI "TARGET_AVX512BW && TARGET_EVEX512") (V32QI "TARGET_AVX2") V16QI
23472 (V32HI "TARGET_AVX512BW && TARGET_EVEX512") (V16HI "TARGET_AVX2") V8HI
23473 (V16SI "TARGET_AVX512F && TARGET_EVEX512") (V8SI "TARGET_AVX2") V4SI
23474 (V8DI "TARGET_AVX512F && TARGET_EVEX512") (V4DI "TARGET_AVX512VL")
23475 (V2DI "TARGET_AVX512VL")])
23476
23477 (define_insn "*abs<mode>2"
23478 [(set (match_operand:VI1248_AVX512VL_AVX512BW 0 "register_operand" "=x,<v_Yw>")
23479 (abs:VI1248_AVX512VL_AVX512BW
23480 (match_operand:VI1248_AVX512VL_AVX512BW 1 "vector_operand" "xja,<v_Yw>Bm")))]
23481 "TARGET_SSSE3"
23482 "%vpabs<ssemodesuffix>\t{%1, %0|%0, %1}"
23483 [(set_attr "isa" "noavx,avx")
23484 (set_attr "addr" "gpr16,*")
23485 (set_attr "type" "sselog1")
23486 (set_attr "prefix_extra" "1")
23487 (set_attr "prefix" "maybe_vex")
23488 (set_attr "c86_attr" "abs")
23489 (set_attr "mode" "<sseinsnmode>")])
23490
23491 (define_insn "abs<mode>2_mask"
23492 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
23493 (vec_merge:VI48_AVX512VL
23494 (abs:VI48_AVX512VL
23495 (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm"))
23496 (match_operand:VI48_AVX512VL 2 "nonimm_or_0_operand" "0C")
23497 (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
23498 "TARGET_AVX512F"
23499 "vpabs<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
23500 [(set_attr "type" "sselog1")
23501 (set_attr "c86_attr" "abs")
23502 (set_attr "prefix" "evex")
23503 (set_attr "mode" "<sseinsnmode>")])
23504
23505 (define_insn "abs<mode>2_mask"
23506 [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
23507 (vec_merge:VI12_AVX512VL
23508 (abs:VI12_AVX512VL
23509 (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "vm"))
23510 (match_operand:VI12_AVX512VL 2 "nonimm_or_0_operand" "0C")
23511 (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
23512 "TARGET_AVX512BW"
23513 "vpabs<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
23514 [(set_attr "type" "sselog1")
23515 (set_attr "c86_attr" "abs")
23516 (set_attr "prefix" "evex")
23517 (set_attr "mode" "<sseinsnmode>")])
23518
23519 (define_expand "abs<mode>2"
23520 [(set (match_operand:VI_AVX2 0 "register_operand")
23521 (abs:VI_AVX2
23522 (match_operand:VI_AVX2 1 "vector_operand")))]
23523 "TARGET_SSE2"
23524 {
23525 if (!TARGET_SSSE3
23526 || ((<MODE>mode == V2DImode || <MODE>mode == V4DImode)
23527 && !TARGET_AVX512VL))
23528 {
23529 ix86_expand_sse2_abs (operands[0], operands[1]);
23530 DONE;
23531 }
23532 })
23533
23534 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23535 ;;
23536 ;; AMD SSE4A instructions
23537 ;;
23538 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23539
23540 (define_insn "sse4a_movnt<mode>"
23541 [(set (match_operand:MODEF 0 "memory_operand" "=m")
23542 (unspec:MODEF
23543 [(match_operand:MODEF 1 "register_operand" "x")]
23544 UNSPEC_MOVNT))]
23545 "TARGET_SSE4A"
23546 "movnt<ssemodesuffix>\t{%1, %0|%0, %1}"
23547 [(set_attr "type" "ssemov")
23548 (set_attr "c86_attr" "movnt")
23549 (set_attr "mode" "<MODE>")])
23550
23551 (define_insn "sse4a_vmmovnt<mode>"
23552 [(set (match_operand:<ssescalarmode> 0 "memory_operand" "=m")
23553 (unspec:<ssescalarmode>
23554 [(vec_select:<ssescalarmode>
23555 (match_operand:VF_128 1 "register_operand" "x")
23556 (parallel [(const_int 0)]))]
23557 UNSPEC_MOVNT))]
23558 "TARGET_SSE4A"
23559 "movnt<ssescalarmodesuffix>\t{%1, %0|%0, %1}"
23560 [(set_attr "type" "ssemov")
23561 (set_attr "c86_attr" "movnt")
23562 (set_attr "mode" "<ssescalarmode>")])
23563
23564 (define_insn "sse4a_extrqi"
23565 [(set (match_operand:V2DI 0 "register_operand" "=x")
23566 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
23567 (match_operand 2 "const_0_to_255_operand")
23568 (match_operand 3 "const_0_to_255_operand")]
23569 UNSPEC_EXTRQI))]
23570 "TARGET_SSE4A"
23571 "extrq\t{%3, %2, %0|%0, %2, %3}"
23572 [(set_attr "type" "sse")
23573 (set_attr "prefix_data16" "1")
23574 (set_attr "length_immediate" "2")
23575 (set_attr "mode" "TI")])
23576
23577 (define_insn "sse4a_extrq"
23578 [(set (match_operand:V2DI 0 "register_operand" "=x")
23579 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
23580 (match_operand:V16QI 2 "register_operand" "x")]
23581 UNSPEC_EXTRQ))]
23582 "TARGET_SSE4A"
23583 "extrq\t{%2, %0|%0, %2}"
23584 [(set_attr "type" "sse")
23585 (set_attr "prefix_data16" "1")
23586 (set_attr "mode" "TI")])
23587
23588 (define_insn "sse4a_insertqi"
23589 [(set (match_operand:V2DI 0 "register_operand" "=x")
23590 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
23591 (match_operand:V2DI 2 "register_operand" "x")
23592 (match_operand 3 "const_0_to_255_operand")
23593 (match_operand 4 "const_0_to_255_operand")]
23594 UNSPEC_INSERTQI))]
23595 "TARGET_SSE4A"
23596 "insertq\t{%4, %3, %2, %0|%0, %2, %3, %4}"
23597 [(set_attr "type" "sseins")
23598 (set_attr "prefix_data16" "0")
23599 (set_attr "prefix_rep" "1")
23600 (set_attr "length_immediate" "2")
23601 (set_attr "mode" "TI")])
23602
23603 (define_insn "sse4a_insertq"
23604 [(set (match_operand:V2DI 0 "register_operand" "=x")
23605 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
23606 (match_operand:V2DI 2 "register_operand" "x")]
23607 UNSPEC_INSERTQ))]
23608 "TARGET_SSE4A"
23609 "insertq\t{%2, %0|%0, %2}"
23610 [(set_attr "type" "sseins")
23611 (set_attr "prefix_data16" "0")
23612 (set_attr "prefix_rep" "1")
23613 (set_attr "mode" "TI")])
23614
23615 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23616 ;;
23617 ;; Intel SSE4.1 instructions
23618 ;;
23619 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23620
23621 ;; Mapping of immediate bits for blend instructions
23622 (define_mode_attr blendbits
23623 [(V8SF "255") (V4SF "15") (V4DF "15") (V2DF "3")])
23624
23625 (define_insn "<sse4_1>_blend<ssemodesuffix><avxsizesuffix>"
23626 [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
23627 (vec_merge:VF_128_256
23628 (match_operand:VF_128_256 2 "vector_operand" "Yrja,*xja,xjm")
23629 (match_operand:VF_128_256 1 "register_operand" "0,0,x")
23630 (match_operand:SI 3 "const_0_to_<blendbits>_operand")))]
23631 "TARGET_SSE4_1"
23632 "@
23633 blend<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
23634 blend<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
23635 vblend<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
23636 [(set_attr "isa" "noavx,noavx,avx")
23637 (set_attr "type" "ssemov")
23638 (set_attr "c86_attr" "blend")
23639 (set_attr "addr" "gpr16")
23640 (set_attr "length_immediate" "1")
23641 (set_attr "prefix_data16" "1,1,*")
23642 (set_attr "prefix_extra" "1")
23643 (set_attr "prefix" "orig,orig,vex")
23644 (set_attr "mode" "<MODE>")])
23645
23646 (define_insn "<sse4_1>_blendv<ssemodesuffix><avxsizesuffix>"
23647 [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
23648 (unspec:VF_128_256
23649 [(match_operand:VF_128_256 1 "register_operand" "0,0,x")
23650 (match_operand:VF_128_256 2 "vector_operand" "Yrja,*xja,xjm")
23651 (match_operand:VF_128_256 3 "register_operand" "Yz,Yz,x")]
23652 UNSPEC_BLENDV))]
23653 "TARGET_SSE4_1"
23654 "@
23655 blendv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
23656 blendv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
23657 vblendv<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
23658 [(set_attr "isa" "noavx,noavx,avx")
23659 (set_attr "type" "ssemov")
23660 (set_attr "c86_attr" "blendv")
23661 (set_attr "addr" "gpr16")
23662 (set_attr "length_immediate" "1")
23663 (set_attr "prefix_data16" "1,1,*")
23664 (set_attr "prefix_extra" "1")
23665 (set_attr "prefix" "orig,orig,vex")
23666 (set_attr "btver2_decode" "vector,vector,vector")
23667 (set_attr "mode" "<MODE>")])
23668
23669 ;; Also define scalar versions. These are used for conditional move.
23670 ;; Using subregs into vector modes causes register allocation lossage.
23671 ;; These patterns do not allow memory operands because the native
23672 ;; instructions read the full 128-bits.
23673
23674 (define_insn "sse4_1_blendv<ssemodesuffix>"
23675 [(set (match_operand:MODEF 0 "register_operand" "=Yr,*x,x")
23676 (unspec:MODEF
23677 [(match_operand:MODEF 1 "register_operand" "0,0,x")
23678 (match_operand:MODEF 2 "register_operand" "Yr,*x,x")
23679 (match_operand:MODEF 3 "register_operand" "Yz,Yz,x")]
23680 UNSPEC_BLENDV))]
23681 "TARGET_SSE4_1"
23682 {
23683 if (get_attr_mode (insn) == MODE_V4SF)
23684 return (which_alternative == 2
23685 ? "vblendvps\t{%3, %2, %1, %0|%0, %1, %2, %3}"
23686 : "blendvps\t{%3, %2, %0|%0, %2, %3}");
23687 else
23688 return (which_alternative == 2
23689 ? "vblendv<ssevecmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
23690 : "blendv<ssevecmodesuffix>\t{%3, %2, %0|%0, %2, %3}");
23691 }
23692 [(set_attr "isa" "noavx,noavx,avx")
23693 (set_attr "type" "ssemov")
23694 (set_attr "c86_attr" "blendv")
23695 (set_attr "length_immediate" "1")
23696 (set_attr "prefix_data16" "1,1,*")
23697 (set_attr "prefix_extra" "1")
23698 (set_attr "prefix" "orig,orig,vex")
23699 (set_attr "btver2_decode" "vector,vector,vector")
23700 (set (attr "mode")
23701 (cond [(match_test "TARGET_AVX")
23702 (const_string "<ssevecmode>")
23703 (match_test "optimize_function_for_size_p (cfun)")
23704 (const_string "V4SF")
23705 (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
23706 (const_string "V4SF")
23707 ]
23708 (const_string "<ssevecmode>")))])
23709
23710 (define_insn_and_split "*<sse4_1>_blendv<ssemodesuffix><avxsizesuffix>_lt"
23711 [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
23712 (unspec:VF_128_256
23713 [(match_operand:VF_128_256 1 "register_operand" "0,0,x")
23714 (match_operand:VF_128_256 2 "vector_operand" "Yrja,*xja,xjm")
23715 (lt:VF_128_256
23716 (match_operand:<sseintvecmode> 3 "register_operand" "Yz,Yz,x")
23717 (match_operand:<sseintvecmode> 4 "const0_operand"))]
23718 UNSPEC_BLENDV))]
23719 "TARGET_SSE4_1"
23720 "#"
23721 "&& reload_completed"
23722 [(set (match_dup 0)
23723 (unspec:VF_128_256
23724 [(match_dup 1) (match_dup 2) (match_dup 3)] UNSPEC_BLENDV))]
23725 "operands[3] = gen_lowpart (<MODE>mode, operands[3]);"
23726 [(set_attr "isa" "noavx,noavx,avx")
23727 (set_attr "type" "ssemov")
23728 (set_attr "addr" "gpr16")
23729 (set_attr "length_immediate" "1")
23730 (set_attr "prefix_data16" "1,1,*")
23731 (set_attr "prefix_extra" "1")
23732 (set_attr "prefix" "orig,orig,vex")
23733 (set_attr "btver2_decode" "vector,vector,vector")
23734 (set_attr "mode" "<MODE>")])
23735
23736 (define_insn_and_split "*<sse4_1>_blendv<ssemodesuffix><avxsizesuffix>_gt"
23737 [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
23738 (unspec:VF_128_256
23739 [(match_operand:VF_128_256 1 "vector_operand" "Yrja,*xja,xjm")
23740 (match_operand:VF_128_256 2 "register_operand" "0,0,x")
23741 (gt:VF_128_256
23742 (match_operand:<sseintvecmode> 3 "register_operand" "Yz,Yz,x")
23743 (match_operand:<sseintvecmode> 4 "vector_all_ones_operand"))]
23744 UNSPEC_BLENDV))]
23745 "TARGET_SSE4_1"
23746 "#"
23747 "&& reload_completed"
23748 [(set (match_dup 0)
23749 (unspec:VF_128_256
23750 [(match_dup 2) (match_dup 1) (match_dup 3)] UNSPEC_BLENDV))]
23751 "operands[3] = gen_lowpart (<MODE>mode, operands[3]);"
23752 [(set_attr "isa" "noavx,noavx,avx")
23753 (set_attr "type" "ssemov")
23754 (set_attr "addr" "gpr16")
23755 (set_attr "length_immediate" "1")
23756 (set_attr "prefix_data16" "1,1,*")
23757 (set_attr "prefix_extra" "1")
23758 (set_attr "prefix" "orig,orig,vex")
23759 (set_attr "btver2_decode" "vector,vector,vector")
23760 (set_attr "mode" "<MODE>")])
23761
23762 (define_mode_attr ssefltmodesuffix
23763 [(V2DI "pd") (V4DI "pd") (V4SI "ps") (V8SI "ps")
23764 (V2DF "pd") (V4DF "pd") (V4SF "ps") (V8SF "ps")])
23765
23766 (define_mode_attr ssefltvecmode
23767 [(V2DI "V2DF") (V4DI "V4DF") (V4SI "V4SF") (V8SI "V8SF")])
23768
23769 (define_insn_and_split "*<sse4_1>_blendv<ssefltmodesuffix><avxsizesuffix>_ltint"
23770 [(set (match_operand:<ssebytemode> 0 "register_operand" "=Yr,*x,x")
23771 (unspec:<ssebytemode>
23772 [(match_operand:<ssebytemode> 1 "register_operand" "0,0,x")
23773 (match_operand:<ssebytemode> 2 "vector_operand" "Yrja,*xja,xjm")
23774 (subreg:<ssebytemode>
23775 (lt:VI48_AVX
23776 (match_operand:VI48_AVX 3 "register_operand" "Yz,Yz,x")
23777 (match_operand:VI48_AVX 4 "const0_operand")) 0)]
23778 UNSPEC_BLENDV))]
23779 "TARGET_SSE4_1"
23780 "#"
23781 "&& reload_completed"
23782 [(set (match_dup 0)
23783 (unspec:<ssefltvecmode>
23784 [(match_dup 1) (match_dup 2) (match_dup 3)] UNSPEC_BLENDV))]
23785 {
23786 operands[0] = gen_lowpart (<ssefltvecmode>mode, operands[0]);
23787 operands[1] = gen_lowpart (<ssefltvecmode>mode, operands[1]);
23788 operands[2] = gen_lowpart (<ssefltvecmode>mode, operands[2]);
23789 operands[3] = gen_lowpart (<ssefltvecmode>mode, operands[3]);
23790 }
23791 [(set_attr "isa" "noavx,noavx,avx")
23792 (set_attr "type" "ssemov")
23793 (set_attr "addr" "gpr16")
23794 (set_attr "length_immediate" "1")
23795 (set_attr "prefix_data16" "1,1,*")
23796 (set_attr "prefix_extra" "1")
23797 (set_attr "prefix" "orig,orig,vex")
23798 (set_attr "btver2_decode" "vector,vector,vector")
23799 (set_attr "mode" "<ssefltvecmode>")])
23800
23801 (define_insn_and_split "*<sse4_1>_blendv<ssefltmodesuffix><avxsizesuffix>_gtint"
23802 [(set (match_operand:<ssebytemode> 0 "register_operand" "=Yr,*x,x")
23803 (unspec:<ssebytemode>
23804 [(match_operand:<ssebytemode> 1 "vector_operand" "Yrja,*xja,xjm")
23805 (match_operand:<ssebytemode> 2 "register_operand" "0,0,x")
23806 (subreg:<ssebytemode>
23807 (gt:VI48_AVX
23808 (match_operand:VI48_AVX 3 "register_operand" "Yz,Yz,x")
23809 (match_operand:VI48_AVX 4 "vector_all_ones_operand")) 0)]
23810 UNSPEC_BLENDV))]
23811 "TARGET_SSE4_1"
23812 "#"
23813 "&& reload_completed"
23814 [(set (match_dup 0)
23815 (unspec:<ssefltvecmode>
23816 [(match_dup 2) (match_dup 1) (match_dup 3)] UNSPEC_BLENDV))]
23817 {
23818 operands[0] = gen_lowpart (<ssefltvecmode>mode, operands[0]);
23819 operands[1] = gen_lowpart (<ssefltvecmode>mode, operands[1]);
23820 operands[2] = gen_lowpart (<ssefltvecmode>mode, operands[2]);
23821 operands[3] = gen_lowpart (<ssefltvecmode>mode, operands[3]);
23822 }
23823 [(set_attr "isa" "noavx,noavx,avx")
23824 (set_attr "type" "ssemov")
23825 (set_attr "addr" "gpr16")
23826 (set_attr "length_immediate" "1")
23827 (set_attr "prefix_data16" "1,1,*")
23828 (set_attr "prefix_extra" "1")
23829 (set_attr "prefix" "orig,orig,vex")
23830 (set_attr "btver2_decode" "vector,vector,vector")
23831 (set_attr "mode" "<ssefltvecmode>")])
23832
23833 ;; PR target/100738: Transform vpcmpeqd + vpxor + vblendvps to vblendvps for inverted mask;
23834 (define_insn_and_split "*<sse4_1>_blendv<ssefltmodesuffix><avxsizesuffix>_not_ltint"
23835 [(set (match_operand:<ssebytemode> 0 "register_operand")
23836 (unspec:<ssebytemode>
23837 [(match_operand:<ssebytemode> 1 "register_operand")
23838 (match_operand:<ssebytemode> 2 "vector_operand")
23839 (subreg:<ssebytemode>
23840 (lt:VI48_AVX
23841 (subreg:VI48_AVX
23842 (not:<ssebytemode>
23843 (match_operand:<ssebytemode> 3 "register_operand")) 0)
23844 (match_operand:VI48_AVX 4 "const0_operand")) 0)]
23845 UNSPEC_BLENDV))]
23846 "TARGET_SSE4_1 && ix86_pre_reload_split ()"
23847 "#"
23848 "&& 1"
23849 [(set (match_dup 0)
23850 (unspec:<ssefltvecmode>
23851 [(match_dup 2) (match_dup 1) (match_dup 3)] UNSPEC_BLENDV))]
23852 {
23853 operands[0] = gen_lowpart (<ssefltvecmode>mode, operands[0]);
23854 operands[1] = gen_lowpart (<ssefltvecmode>mode, operands[1]);
23855 operands[2] = force_reg (<ssefltvecmode>mode,
23856 gen_lowpart (<ssefltvecmode>mode, operands[2]));
23857 operands[3] = gen_lowpart (<ssefltvecmode>mode, operands[3]);
23858 })
23859
23860 (define_insn_and_split "*<sse4_1>_blendv<ssefltmodesuffix><avxsizesuffix>_not_gtint"
23861 [(set (match_operand:<ssebytemode> 0 "register_operand")
23862 (unspec:<ssebytemode>
23863 [(match_operand:<ssebytemode> 1 "vector_operand")
23864 (match_operand:<ssebytemode> 2 "register_operand")
23865 (subreg:<ssebytemode>
23866 (gt:VI48_AVX
23867 (subreg:VI48_AVX
23868 (not:<ssebytemode>
23869 (match_operand:<ssebytemode> 3 "register_operand")) 0)
23870 (match_operand:VI48_AVX 4 "vector_all_ones_operand")) 0)]
23871 UNSPEC_BLENDV))]
23872 "TARGET_SSE4_1 && ix86_pre_reload_split ()"
23873 "#"
23874 "&& 1"
23875 [(set (match_dup 0)
23876 (unspec:<ssefltvecmode>
23877 [(match_dup 1) (match_dup 2) (match_dup 3)] UNSPEC_BLENDV))]
23878 {
23879 operands[0] = gen_lowpart (<ssefltvecmode>mode, operands[0]);
23880 operands[2] = gen_lowpart (<ssefltvecmode>mode, operands[2]);
23881 operands[1] = force_reg (<ssefltvecmode>mode,
23882 gen_lowpart (<ssefltvecmode>mode, operands[1]));
23883 operands[3] = gen_lowpart (<ssefltvecmode>mode, operands[3]);
23884 })
23885
23886 (define_insn "<sse4_1>_dp<ssemodesuffix><avxsizesuffix>"
23887 [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
23888 (unspec:VF_128_256
23889 [(match_operand:VF_128_256 1 "vector_operand" "%0,0,x")
23890 (match_operand:VF_128_256 2 "vector_operand" "Yrja,*xja,xjm")
23891 (match_operand:SI 3 "const_0_to_255_operand")]
23892 UNSPEC_DP))]
23893 "TARGET_SSE4_1"
23894 "@
23895 dp<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
23896 dp<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
23897 vdp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
23898 [(set_attr "isa" "noavx,noavx,avx")
23899 (set_attr "type" "ssemul")
23900 (set_attr "addr" "gpr16")
23901 (set_attr "length_immediate" "1")
23902 (set_attr "prefix_data16" "1,1,*")
23903 (set_attr "prefix_extra" "1")
23904 (set_attr "prefix" "orig,orig,vex")
23905 (set_attr "btver2_decode" "vector,vector,vector")
23906 (set_attr "znver1_decode" "vector,vector,vector")
23907 (set_attr "c86_decode" "vector,vector,vector")
23908 (set_attr "mode" "<MODE>")])
23909
23910 ;; Mode attribute used by `vmovntdqa' pattern
23911 (define_mode_attr vi8_sse4_1_avx2_avx512
23912 [(V2DI "sse4_1") (V4DI "avx2") (V8DI "avx512f")])
23913
23914 (define_insn "<vi8_sse4_1_avx2_avx512>_movntdqa"
23915 [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand" "=Yr,*x,v")
23916 (unspec:VI8_AVX2_AVX512F [(match_operand:VI8_AVX2_AVX512F 1 "memory_operand" "jm,jm,m")]
23917 UNSPEC_MOVNTDQA))]
23918 "TARGET_SSE4_1"
23919 "%vmovntdqa\t{%1, %0|%0, %1}"
23920 [(set_attr "isa" "noavx,noavx,avx")
23921 (set_attr "addr" "gpr16,gpr16,*")
23922 (set_attr "type" "ssemov")
23923 (set_attr "c86_attr" "movnt")
23924 (set_attr "prefix_extra" "1")
23925 (set_attr "prefix" "orig,orig,maybe_evex")
23926 (set_attr "mode" "<sseinsnmode>")])
23927
23928 (define_insn "<sse4_1_avx2>_mpsadbw"
23929 [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
23930 (unspec:VI1_AVX2
23931 [(match_operand:VI1_AVX2 1 "register_operand" "0,0,x")
23932 (match_operand:VI1_AVX2 2 "vector_operand" "Yrja,*xja,xjm")
23933 (match_operand:SI 3 "const_0_to_255_operand")]
23934 UNSPEC_MPSADBW))]
23935 "TARGET_SSE4_1"
23936 "@
23937 mpsadbw\t{%3, %2, %0|%0, %2, %3}
23938 mpsadbw\t{%3, %2, %0|%0, %2, %3}
23939 vmpsadbw\t{%3, %2, %1, %0|%0, %1, %2, %3}"
23940 [(set_attr "isa" "noavx,noavx,avx")
23941 (set_attr "addr" "gpr16")
23942 (set_attr "type" "sselog1")
23943 (set_attr "length_immediate" "1")
23944 (set_attr "prefix_extra" "1")
23945 (set_attr "prefix" "orig,orig,vex")
23946 (set_attr "btver2_decode" "vector,vector,vector")
23947 (set_attr "znver1_decode" "vector,vector,vector")
23948 (set_attr "c86_decode" "vector,vector,vector")
23949 (set_attr "mode" "<sseinsnmode>")])
23950
23951 (define_insn "avx10_2_mpsadbw<mask_name>"
23952 [(set (match_operand:V64QI 0 "register_operand" "=v")
23953 (unspec:V64QI
23954 [(match_operand:V64QI 1 "register_operand" "v")
23955 (match_operand:V64QI 2 "vector_operand" "vm")
23956 (match_operand:SI 3 "const_0_to_255_operand" "n")]
23957 UNSPEC_MPSADBW))]
23958 "TARGET_AVX10_2"
23959 "vmpsadbw\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}"
23960 [(set_attr "length_immediate" "1")
23961 (set_attr "prefix" "evex")])
23962
23963 (define_insn "<mask_codefor><sse4_1_avx2>_mpsadbw<mask_name>"
23964 [(set (match_operand:VI1 0 "register_operand" "=v")
23965 (unspec:VI1
23966 [(match_operand:VI1 1 "register_operand" "v")
23967 (match_operand:VI1 2 "vector_operand" "vm")
23968 (match_operand:SI 3 "const_0_to_255_operand" "n")]
23969 UNSPEC_MPSADBW))]
23970 "TARGET_AVX10_2"
23971 "vmpsadbw\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}"
23972 [(set_attr "length_immediate" "1")
23973 (set_attr "prefix" "evex")
23974 (set_attr "mode" "<sseinsnmode>")])
23975
23976 (define_insn "<sse4_1_avx2>_packusdw<mask_name>"
23977 [(set (match_operand:VI2_AVX2_AVX512BW 0 "register_operand" "=Yr,*x,<v_Yw>")
23978 (unspec:VI2_AVX2_AVX512BW
23979 [(match_operand:<sseunpackmode> 1 "register_operand" "0,0,<v_Yw>")
23980 (match_operand:<sseunpackmode> 2 "vector_operand" "Yrja,*xja,<v_Yw>m")]
23981 UNSPEC_US_TRUNCATE))]
23982 "TARGET_SSE4_1 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
23983 "@
23984 packusdw\t{%2, %0|%0, %2}
23985 packusdw\t{%2, %0|%0, %2}
23986 vpackusdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
23987 [(set_attr "isa" "noavx,noavx,avx")
23988 (set_attr "addr" "gpr16,gpr16,*")
23989 (set_attr "type" "sselog")
23990 (set_attr "prefix_extra" "1")
23991 (set_attr "prefix" "orig,orig,<mask_prefix>")
23992 (set_attr "mode" "<sseinsnmode>")])
23993
23994 (define_insn "<sse4_1_avx2>_pblendvb"
23995 [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
23996 (unspec:VI1_AVX2
23997 [(match_operand:VI1_AVX2 1 "register_operand" "0,0,x")
23998 (match_operand:VI1_AVX2 2 "vector_operand" "Yrja,*xja,xjm")
23999 (match_operand:VI1_AVX2 3 "register_operand" "Yz,Yz,x")]
24000 UNSPEC_BLENDV))]
24001 "TARGET_SSE4_1"
24002 "@
24003 pblendvb\t{%3, %2, %0|%0, %2, %3}
24004 pblendvb\t{%3, %2, %0|%0, %2, %3}
24005 vpblendvb\t{%3, %2, %1, %0|%0, %1, %2, %3}"
24006 [(set_attr "isa" "noavx,noavx,avx")
24007 (set_attr "type" "ssemov")
24008 (set_attr "c86_attr" "blendv")
24009 (set_attr "addr" "gpr16")
24010 (set_attr "prefix_extra" "1")
24011 (set_attr "length_immediate" "*,*,1")
24012 (set_attr "prefix" "orig,orig,vex")
24013 (set_attr "btver2_decode" "vector,vector,vector")
24014 (set_attr "mode" "<sseinsnmode>")])
24015
24016 (define_split
24017 [(set (match_operand:VI1_AVX2 0 "register_operand")
24018 (unspec:VI1_AVX2
24019 [(match_operand:VI1_AVX2 1 "vector_operand")
24020 (match_operand:VI1_AVX2 2 "register_operand")
24021 (not:VI1_AVX2 (match_operand:VI1_AVX2 3 "register_operand"))]
24022 UNSPEC_BLENDV))]
24023 "TARGET_SSE4_1"
24024 [(set (match_dup 0)
24025 (unspec:VI1_AVX2
24026 [(match_dup 2) (match_dup 1) (match_dup 3)]
24027 UNSPEC_BLENDV))])
24028
24029 (define_split
24030 [(set (match_operand:VI1_AVX2 0 "register_operand")
24031 (unspec:VI1_AVX2
24032 [(match_operand:VI1_AVX2 1 "vector_operand")
24033 (match_operand:VI1_AVX2 2 "register_operand")
24034 (subreg:VI1_AVX2 (not (match_operand 3 "register_operand")) 0)]
24035 UNSPEC_BLENDV))]
24036 "TARGET_SSE4_1
24037 && GET_MODE_CLASS (GET_MODE (operands[3])) == MODE_VECTOR_INT
24038 && GET_MODE_SIZE (GET_MODE (operands[3])) == <MODE_SIZE>"
24039 [(set (match_dup 0)
24040 (unspec:VI1_AVX2
24041 [(match_dup 2) (match_dup 1) (match_dup 4)]
24042 UNSPEC_BLENDV))]
24043 "operands[4] = gen_lowpart (<MODE>mode, operands[3]);")
24044
24045 (define_insn_and_split "*<sse4_1_avx2>_pblendvb_lt"
24046 [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
24047 (unspec:VI1_AVX2
24048 [(match_operand:VI1_AVX2 1 "register_operand" "0,0,x")
24049 (match_operand:VI1_AVX2 2 "vector_operand" "Yrja,*xja,xjm")
24050 (lt:VI1_AVX2 (match_operand:VI1_AVX2 3 "register_operand" "Yz,Yz,x")
24051 (match_operand:VI1_AVX2 4 "const0_operand"))]
24052 UNSPEC_BLENDV))]
24053 "TARGET_SSE4_1"
24054 "#"
24055 "&& 1"
24056 [(set (match_dup 0)
24057 (unspec:VI1_AVX2
24058 [(match_dup 1) (match_dup 2) (match_dup 3)] UNSPEC_BLENDV))]
24059 ""
24060 [(set_attr "isa" "noavx,noavx,avx")
24061 (set_attr "type" "ssemov")
24062 (set_attr "addr" "gpr16")
24063 (set_attr "prefix_extra" "1")
24064 (set_attr "length_immediate" "*,*,1")
24065 (set_attr "prefix" "orig,orig,vex")
24066 (set_attr "btver2_decode" "vector,vector,vector")
24067 (set_attr "mode" "<sseinsnmode>")])
24068
24069 (define_insn_and_split "*<sse4_1_avx2>_pblendvb_gt"
24070 [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
24071 (unspec:VI1_AVX2
24072 [(match_operand:VI1_AVX2 1 "vector_operand" "Yrja,*xja,xjm")
24073 (match_operand:VI1_AVX2 2 "register_operand" "0,0,x")
24074 (gt:VI1_AVX2 (match_operand:VI1_AVX2 3 "register_operand" "Yz,Yz,x")
24075 (match_operand:VI1_AVX2 4 "vector_all_ones_operand"))]
24076 UNSPEC_BLENDV))]
24077 "TARGET_SSE4_1"
24078 "#"
24079 "&& 1"
24080 [(set (match_dup 0)
24081 (unspec:VI1_AVX2
24082 [(match_dup 2) (match_dup 1) (match_dup 3)] UNSPEC_BLENDV))]
24083 ""
24084 [(set_attr "isa" "noavx,noavx,avx")
24085 (set_attr "type" "ssemov")
24086 (set_attr "addr" "gpr16")
24087 (set_attr "prefix_extra" "1")
24088 (set_attr "length_immediate" "*,*,1")
24089 (set_attr "prefix" "orig,orig,vex")
24090 (set_attr "btver2_decode" "vector,vector,vector")
24091 (set_attr "mode" "<sseinsnmode>")])
24092
24093 (define_insn_and_split "*<sse4_1_avx2>_pblendvb_lt_subreg_not"
24094 [(set (match_operand:VI1_AVX2 0 "register_operand")
24095 (unspec:VI1_AVX2
24096 [(match_operand:VI1_AVX2 2 "vector_operand")
24097 (match_operand:VI1_AVX2 1 "register_operand")
24098 (lt:VI1_AVX2
24099 (subreg:VI1_AVX2
24100 (not (match_operand 3 "register_operand")) 0)
24101 (match_operand:VI1_AVX2 4 "const0_operand"))]
24102 UNSPEC_BLENDV))]
24103 "TARGET_SSE4_1
24104 && GET_MODE_CLASS (GET_MODE (operands[3])) == MODE_VECTOR_INT
24105 && GET_MODE_SIZE (GET_MODE (operands[3])) == <MODE_SIZE>
24106 && ix86_pre_reload_split ()"
24107 "#"
24108 "&& 1"
24109 [(set (match_dup 0)
24110 (unspec:VI1_AVX2
24111 [(match_dup 1) (match_dup 2)
24112 (lt:VI1_AVX2 (match_dup 3) (match_dup 4))] UNSPEC_BLENDV))]
24113 "operands[3] = gen_lowpart (<MODE>mode, operands[3]);")
24114
24115 (define_insn_and_split "*<sse4_1_avx2>_pblendvb_gt_subreg_not"
24116 [(set (match_operand:VI1_AVX2 0 "register_operand")
24117 (unspec:VI1_AVX2
24118 [(match_operand:VI1_AVX2 2 "register_operand")
24119 (match_operand:VI1_AVX2 1 "vector_operand")
24120 (gt:VI1_AVX2
24121 (subreg:VI1_AVX2
24122 (not (match_operand 3 "register_operand")) 0)
24123 (match_operand:VI1_AVX2 4 "vector_all_ones_operand"))]
24124 UNSPEC_BLENDV))]
24125 "TARGET_SSE4_1
24126 && GET_MODE_CLASS (GET_MODE (operands[3])) == MODE_VECTOR_INT
24127 && GET_MODE_SIZE (GET_MODE (operands[3])) == <MODE_SIZE>
24128 && ix86_pre_reload_split ()"
24129 "#"
24130 "&& 1"
24131 [(set (match_dup 0)
24132 (unspec:VI1_AVX2
24133 [(match_dup 1) (match_dup 2)
24134 (gt:VI1_AVX2 (match_dup 3) (match_dup 4))] UNSPEC_BLENDV))]
24135 "operands[3] = gen_lowpart (<MODE>mode, operands[3]);")
24136
24137 (define_insn "sse4_1_pblend<ssemodesuffix>"
24138 [(set (match_operand:V8_128 0 "register_operand" "=Yr,*x,x")
24139 (vec_merge:V8_128
24140 (match_operand:V8_128 2 "vector_operand" "Yrja,*xja,xjm")
24141 (match_operand:V8_128 1 "register_operand" "0,0,x")
24142 (match_operand:SI 3 "const_0_to_255_operand")))]
24143 "TARGET_SSE4_1"
24144 "@
24145 pblendw\t{%3, %2, %0|%0, %2, %3}
24146 pblendw\t{%3, %2, %0|%0, %2, %3}
24147 vpblendw\t{%3, %2, %1, %0|%0, %1, %2, %3}"
24148 [(set_attr "isa" "noavx,noavx,avx")
24149 (set_attr "type" "ssemov")
24150 (set_attr "c86_attr" "blend")
24151 (set_attr "addr" "gpr16")
24152 (set_attr "prefix_extra" "1")
24153 (set_attr "length_immediate" "1")
24154 (set_attr "prefix" "orig,orig,vex")
24155 (set_attr "mode" "TI")])
24156
24157 ;; The builtin uses an 8-bit immediate. Expand that.
24158 (define_expand "avx2_pblend<ssemodesuffix>"
24159 [(set (match_operand:V16_256 0 "register_operand")
24160 (vec_merge:V16_256
24161 (match_operand:V16_256 2 "nonimmediate_operand")
24162 (match_operand:V16_256 1 "register_operand")
24163 (match_operand:SI 3 "const_0_to_255_operand")))]
24164 "TARGET_AVX2"
24165 {
24166 HOST_WIDE_INT val = INTVAL (operands[3]) & 0xff;
24167 operands[3] = GEN_INT (val << 8 | val);
24168 })
24169
24170 (define_expand "avx2_pblend<ssemodesuffix>_1"
24171 [(set (match_operand:V16_256 0 "register_operand")
24172 (vec_merge:V16_256
24173 (match_operand:V16_256 2 "register_operand")
24174 (match_operand:V16_256 1 "register_operand")
24175 (match_operand:SI 3 "const_int_operand")))]
24176 "TARGET_AVX2
24177 && !((INTVAL (operands[3]) & 0xff) && (INTVAL (operands[3]) & 0xff00))"
24178 {
24179 int mask = INTVAL (operands[3]);
24180 if (mask == 0)
24181 emit_move_insn (operands[0], operands[1]);
24182 else
24183 {
24184 rtx tmp = gen_reg_rtx (<MODE>mode);
24185 rtx blendw_idx, blendd_idx;
24186
24187 if (mask & 0xff)
24188 {
24189 blendw_idx = GEN_INT (mask & 0xff);
24190 blendd_idx = GEN_INT (15);
24191 }
24192 else
24193 {
24194 blendw_idx = GEN_INT (mask >> 8 & 0xff);
24195 blendd_idx = GEN_INT (240);
24196 }
24197 emit_insn (gen_avx2_pblend<ssemodesuffix> (tmp, operands[1],
24198 operands[2], blendw_idx));
24199
24200 rtx op0 = gen_reg_rtx (V8SImode);
24201 tmp = lowpart_subreg (V8SImode, tmp, <MODE>mode);
24202 operands[1] = lowpart_subreg (V8SImode, operands[1], <MODE>mode);
24203 emit_insn (gen_avx2_pblenddv8si (op0, operands[1],
24204 tmp, blendd_idx));
24205 emit_move_insn (operands[0], lowpart_subreg (<MODE>mode, op0, V8SImode));
24206 }
24207
24208 DONE;
24209 })
24210
24211 (define_insn "*avx2_pblend<ssemodesuffix>"
24212 [(set (match_operand:V16_256 0 "register_operand" "=x")
24213 (vec_merge:V16_256
24214 (match_operand:V16_256 2 "nonimmediate_operand" "xjm")
24215 (match_operand:V16_256 1 "register_operand" "x")
24216 (match_operand:SI 3 "avx2_pblendw_operand")))]
24217 "TARGET_AVX2"
24218 {
24219 operands[3] = GEN_INT (INTVAL (operands[3]) & 0xff);
24220 return "vpblendw\t{%3, %2, %1, %0|%0, %1, %2, %3}";
24221 }
24222 [(set_attr "type" "ssemov")
24223 (set_attr "c86_attr" "blend")
24224 (set_attr "addr" "gpr16")
24225 (set_attr "prefix_extra" "1")
24226 (set_attr "length_immediate" "1")
24227 (set_attr "prefix" "vex")
24228 (set_attr "mode" "OI")])
24229
24230 (define_insn "avx2_pblendd<mode>"
24231 [(set (match_operand:VI4_AVX2 0 "register_operand" "=x")
24232 (vec_merge:VI4_AVX2
24233 (match_operand:VI4_AVX2 2 "nonimmediate_operand" "xjm")
24234 (match_operand:VI4_AVX2 1 "register_operand" "x")
24235 (match_operand:SI 3 "const_0_to_255_operand")))]
24236 "TARGET_AVX2"
24237 "vpblendd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
24238 [(set_attr "type" "ssemov")
24239 (set_attr "c86_attr" "blend")
24240 (set_attr "addr" "gpr16")
24241 (set_attr "prefix_extra" "1")
24242 (set_attr "length_immediate" "1")
24243 (set_attr "prefix" "vex")
24244 (set_attr "mode" "<sseinsnmode>")])
24245
24246 (define_insn "sse4_1_phminposuw"
24247 [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,x")
24248 (unspec:V8HI [(match_operand:V8HI 1 "vector_operand" "Yrja,*xja,xjm")]
24249 UNSPEC_PHMINPOSUW))]
24250 "TARGET_SSE4_1"
24251 "%vphminposuw\t{%1, %0|%0, %1}"
24252 [(set_attr "isa" "noavx,noavx,avx")
24253 (set_attr "addr" "gpr16")
24254 (set_attr "type" "sselog1")
24255 (set_attr "prefix_extra" "1")
24256 (set_attr "prefix" "orig,orig,vex")
24257 (set_attr "mode" "TI")])
24258
24259 (define_insn "avx2_<code>v16qiv16hi2<mask_name>"
24260 [(set (match_operand:V16HI 0 "register_operand" "=Yw")
24261 (any_extend:V16HI
24262 (match_operand:V16QI 1 "nonimmediate_operand" "Ywm")))]
24263 "TARGET_AVX2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
24264 "vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
24265 [(set_attr "type" "ssemov")
24266 (set_attr "c86_attr" "vpmovx")
24267 (set_attr "prefix_extra" "1")
24268 (set_attr "prefix" "maybe_evex")
24269 (set_attr "mode" "OI")])
24270
24271 (define_insn_and_split "*avx2_zero_extendv16qiv16hi2_1"
24272 [(set (match_operand:V32QI 0 "register_operand" "=v")
24273 (vec_select:V32QI
24274 (vec_concat:V64QI
24275 (match_operand:V32QI 1 "nonimmediate_operand" "vm")
24276 (match_operand:V32QI 2 "const0_operand"))
24277 (match_parallel 3 "pmovzx_parallel"
24278 [(match_operand 4 "const_int_operand")])))]
24279 "TARGET_AVX2"
24280 "#"
24281 "&& reload_completed"
24282 [(set (match_dup 0) (zero_extend:V16HI (match_dup 1)))]
24283 {
24284 operands[0] = lowpart_subreg (V16HImode, operands[0], V32QImode);
24285 operands[1] = lowpart_subreg (V16QImode, operands[1], V32QImode);
24286 })
24287
24288 (define_insn_and_split "*avx2_zero_extendv16qiv16hi2_2"
24289 [(set (match_operand:V32QI 0 "register_operand" "=v")
24290 (vec_select:V32QI
24291 (vec_concat:V64QI
24292 (subreg:V32QI
24293 (vec_concat:VI248_256
24294 (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "vm")
24295 (match_operand:<ssehalfvecmode> 2 "const0_operand")) 0)
24296 (match_operand:V32QI 3 "const0_operand"))
24297 (match_parallel 4 "pmovzx_parallel"
24298 [(match_operand 5 "const_int_operand")])))]
24299 "TARGET_AVX2"
24300 "#"
24301 "&& reload_completed"
24302 [(set (match_dup 0) (zero_extend:V16HI (match_dup 1)))]
24303 {
24304 operands[0] = lowpart_subreg (V16HImode, operands[0], V32QImode);
24305 operands[1] = lowpart_subreg (V16QImode, operands[1], <ssehalfvecmode>mode);
24306 })
24307
24308 (define_expand "<insn>v16qiv16hi2"
24309 [(set (match_operand:V16HI 0 "register_operand")
24310 (any_extend:V16HI
24311 (match_operand:V16QI 1 "nonimmediate_operand")))]
24312 "TARGET_AVX2")
24313
24314 (define_insn "avx512bw_<code>v32qiv32hi2<mask_name>"
24315 [(set (match_operand:V32HI 0 "register_operand" "=v")
24316 (any_extend:V32HI
24317 (match_operand:V32QI 1 "nonimmediate_operand" "vm")))]
24318 "TARGET_AVX512BW && TARGET_EVEX512"
24319 "vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
24320 [(set_attr "type" "ssemov")
24321 (set_attr "c86_attr" "vpmovx")
24322 (set_attr "prefix" "evex")
24323 (set_attr "mode" "XI")])
24324
24325 (define_insn_and_split "*avx512bw_zero_extendv32qiv32hi2_1"
24326 [(set (match_operand:V64QI 0 "register_operand" "=v")
24327 (vec_select:V64QI
24328 (vec_concat:V128QI
24329 (match_operand:V64QI 1 "nonimmediate_operand" "vm")
24330 (match_operand:V64QI 2 "const0_operand"))
24331 (match_parallel 3 "pmovzx_parallel"
24332 [(match_operand 4 "const_int_operand")])))]
24333 "TARGET_AVX512BW && TARGET_EVEX512"
24334 "#"
24335 "&& reload_completed"
24336 [(set (match_dup 0) (zero_extend:V32HI (match_dup 1)))]
24337 {
24338 operands[0] = lowpart_subreg (V32HImode, operands[0], V64QImode);
24339 operands[1] = lowpart_subreg (V32QImode, operands[1], V64QImode);
24340 })
24341
24342 (define_insn_and_split "*avx512bw_zero_extendv32qiv32hi2_2"
24343 [(set (match_operand:V64QI 0 "register_operand" "=v")
24344 (vec_select:V64QI
24345 (vec_concat:V128QI
24346 (subreg:V64QI
24347 (vec_concat:VI248_512
24348 (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "vm")
24349 (match_operand:<ssehalfvecmode> 2 "const0_operand")) 0)
24350 (match_operand:V64QI 3 "const0_operand"))
24351 (match_parallel 4 "pmovzx_parallel"
24352 [(match_operand 5 "const_int_operand")])))]
24353 "TARGET_AVX512BW && TARGET_EVEX512"
24354 "#"
24355 "&& reload_completed"
24356 [(set (match_dup 0) (zero_extend:V32HI (match_dup 1)))]
24357 {
24358 operands[0] = lowpart_subreg (V32HImode, operands[0], V64QImode);
24359 operands[1] = lowpart_subreg (V32QImode, operands[1], <ssehalfvecmode>mode);
24360 })
24361
24362 (define_expand "<insn>v32qiv32hi2"
24363 [(set (match_operand:V32HI 0 "register_operand")
24364 (any_extend:V32HI
24365 (match_operand:V32QI 1 "nonimmediate_operand")))]
24366 "TARGET_AVX512BW && TARGET_EVEX512")
24367
24368 (define_insn "sse4_1_<code>v8qiv8hi2<mask_name>"
24369 [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,Yw")
24370 (any_extend:V8HI
24371 (vec_select:V8QI
24372 (match_operand:V16QI 1 "register_operand" "Yr,*x,Yw")
24373 (parallel [(const_int 0) (const_int 1)
24374 (const_int 2) (const_int 3)
24375 (const_int 4) (const_int 5)
24376 (const_int 6) (const_int 7)]))))]
24377 "TARGET_SSE4_1 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
24378 "%vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
24379 [(set_attr "isa" "noavx,noavx,avx")
24380 (set_attr "type" "ssemov")
24381 (set_attr "c86_attr" "vpmovx")
24382 (set_attr "prefix_extra" "1")
24383 (set_attr "prefix" "orig,orig,maybe_evex")
24384 (set_attr "mode" "TI")])
24385
24386 (define_insn "*sse4_1_<code>v8qiv8hi2<mask_name>_1"
24387 [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,Yw")
24388 (any_extend:V8HI
24389 (match_operand:V8QI 1 "memory_operand" "jm,jm,m")))]
24390 "TARGET_SSE4_1 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
24391 "@
24392 pmov<extsuffix>bw\t{%1, %0|%0, %1}
24393 pmov<extsuffix>bw\t{%1, %0|%0, %1}
24394 vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
24395 [(set_attr "isa" "noavx,noavx,avx")
24396 (set_attr "addr" "gpr16,gpr16,*")
24397 (set_attr "type" "ssemov")
24398 (set_attr "c86_attr" "vpmovx")
24399 (set_attr "prefix_extra" "1")
24400 (set_attr "prefix" "orig,orig,maybe_evex")
24401 (set_attr "mode" "TI")])
24402
24403 (define_insn_and_split "*sse4_1_<code>v8qiv8hi2_2"
24404 [(set (match_operand:V8HI 0 "register_operand")
24405 (any_extend:V8HI
24406 (vec_select:V8QI
24407 (subreg:V16QI
24408 (vec_concat:V2DI
24409 (match_operand:DI 1 "memory_operand")
24410 (const_int 0)) 0)
24411 (parallel [(const_int 0) (const_int 1)
24412 (const_int 2) (const_int 3)
24413 (const_int 4) (const_int 5)
24414 (const_int 6) (const_int 7)]))))]
24415 "TARGET_SSE4_1
24416 && ix86_pre_reload_split ()"
24417 "#"
24418 "&& 1"
24419 [(set (match_dup 0)
24420 (any_extend:V8HI (match_dup 1)))]
24421 "operands[1] = adjust_address_nv (operands[1], V8QImode, 0);")
24422
24423 (define_insn_and_split "*avx512vl_<code>v8qiv8hi2_mask_2"
24424 [(set (match_operand:V8HI 0 "register_operand")
24425 (vec_merge:V8HI
24426 (any_extend:V8HI
24427 (vec_select:V8QI
24428 (subreg:V16QI
24429 (vec_concat:V2DI
24430 (match_operand:DI 1 "memory_operand")
24431 (const_int 0)) 0)
24432 (parallel [(const_int 0) (const_int 1)
24433 (const_int 2) (const_int 3)
24434 (const_int 4) (const_int 5)
24435 (const_int 6) (const_int 7)])))
24436 (match_operand:V8HI 2 "nonimm_or_0_operand")
24437 (match_operand:QI 3 "register_operand")))]
24438 "TARGET_AVX512VL && TARGET_AVX512BW
24439 && ix86_pre_reload_split ()"
24440 "#"
24441 "&& 1"
24442 [(set (match_dup 0)
24443 (vec_merge:V8HI
24444 (any_extend:V8HI (match_dup 1))
24445 (match_dup 2)
24446 (match_dup 3)))]
24447 "operands[1] = adjust_address_nv (operands[1], V8QImode, 0);")
24448
24449 (define_insn_and_split "*sse4_1_zero_extendv8qiv8hi2_3"
24450 [(set (match_operand:V16QI 0 "register_operand" "=Yr,*x,Yw")
24451 (vec_select:V16QI
24452 (vec_concat:V32QI
24453 (match_operand:V16QI 1 "vector_operand" "Yrja,*xja,Ywm")
24454 (match_operand:V16QI 2 "const0_operand"))
24455 (match_parallel 3 "pmovzx_parallel"
24456 [(match_operand 4 "const_int_operand")])))]
24457 "TARGET_SSE4_1"
24458 "#"
24459 "&& reload_completed"
24460 [(set (match_dup 0)
24461 (zero_extend:V8HI
24462 (vec_select:V8QI
24463 (match_dup 1)
24464 (parallel [(const_int 0) (const_int 1)
24465 (const_int 2) (const_int 3)
24466 (const_int 4) (const_int 5)
24467 (const_int 6) (const_int 7)]))))]
24468 {
24469 operands[0] = lowpart_subreg (V8HImode, operands[0], V16QImode);
24470 if (MEM_P (operands[1]))
24471 {
24472 operands[1] = lowpart_subreg (V8QImode, operands[1], V16QImode);
24473 operands[1] = gen_rtx_ZERO_EXTEND (V8HImode, operands[1]);
24474 emit_insn (gen_rtx_SET (operands[0], operands[1]));
24475 DONE;
24476 }
24477 }
24478 [(set_attr "isa" "noavx,noavx,avx")
24479 (set_attr "addr" "gpr16,gpr16,*")])
24480
24481 (define_insn_and_split "*sse4_1_zero_extendv8qiv8hi2_4"
24482 [(set (match_operand:V16QI 0 "register_operand" "=Yr,*x,Yw")
24483 (vec_select:V16QI
24484 (vec_concat:V32QI
24485 (subreg:V16QI
24486 (vec_concat:VI248_128
24487 (match_operand:<ssehalfvecmode> 1 "vector_operand" "Yrja,*xja,Ywm")
24488 (match_operand:<ssehalfvecmode> 2 "const0_operand")) 0)
24489 (match_operand:V16QI 3 "const0_operand"))
24490 (match_parallel 4 "pmovzx_parallel"
24491 [(match_operand 5 "const_int_operand")])))]
24492 "TARGET_SSE4_1"
24493 "#"
24494 "&& reload_completed"
24495 [(set (match_dup 0)
24496 (zero_extend:V8HI
24497 (vec_select:V8QI
24498 (match_dup 1)
24499 (parallel [(const_int 0) (const_int 1)
24500 (const_int 2) (const_int 3)
24501 (const_int 4) (const_int 5)
24502 (const_int 6) (const_int 7)]))))]
24503 {
24504 operands[0] = lowpart_subreg (V8HImode, operands[0], V16QImode);
24505 if (MEM_P (operands[1]))
24506 {
24507 operands[1] = lowpart_subreg (V8QImode, operands[1], <ssehalfvecmode>mode);
24508 operands[1] = gen_rtx_ZERO_EXTEND (V8HImode, operands[1]);
24509 emit_insn (gen_rtx_SET (operands[0], operands[1]));
24510 DONE;
24511 }
24512 operands[1] = lowpart_subreg (V16QImode, operands[1], <ssehalfvecmode>mode);
24513 }
24514 [(set_attr "isa" "noavx,noavx,avx")
24515 (set_attr "addr" "gpr16,gpr16,*")])
24516
24517 (define_expand "<insn>v8qiv8hi2"
24518 [(set (match_operand:V8HI 0 "register_operand")
24519 (any_extend:V8HI
24520 (match_operand:V8QI 1 "nonimmediate_operand")))]
24521 "TARGET_SSE4_1 || TARGET_MMX_WITH_SSE"
24522 {
24523 if (!TARGET_SSE4_1)
24524 {
24525 ix86_expand_sse_extend (operands[0], operands[1], <u_bool>);
24526 DONE;
24527 }
24528
24529 if (!MEM_P (operands[1]))
24530 {
24531 rtx op1 = force_reg (V8QImode, operands[1]);
24532 op1 = lowpart_subreg (V16QImode, op1, V8QImode);
24533 emit_insn (gen_sse4_1_<code>v8qiv8hi2 (operands[0], op1));
24534 DONE;
24535 }
24536 })
24537
24538 (define_insn "<mask_codefor>avx512f_<code>v16qiv16si2<mask_name>"
24539 [(set (match_operand:V16SI 0 "register_operand" "=v")
24540 (any_extend:V16SI
24541 (match_operand:V16QI 1 "nonimmediate_operand" "vm")))]
24542 "TARGET_AVX512F && TARGET_EVEX512"
24543 "vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
24544 [(set_attr "type" "ssemov")
24545 (set_attr "c86_attr" "vpmovx")
24546 (set_attr "prefix" "evex")
24547 (set_attr "mode" "XI")])
24548
24549 (define_expand "<insn>v16qiv16si2"
24550 [(set (match_operand:V16SI 0 "register_operand")
24551 (any_extend:V16SI
24552 (match_operand:V16QI 1 "nonimmediate_operand")))]
24553 "TARGET_AVX512F && TARGET_EVEX512")
24554
24555 (define_insn "avx2_<code>v8qiv8si2<mask_name>"
24556 [(set (match_operand:V8SI 0 "register_operand" "=v")
24557 (any_extend:V8SI
24558 (vec_select:V8QI
24559 (match_operand:V16QI 1 "register_operand" "v")
24560 (parallel [(const_int 0) (const_int 1)
24561 (const_int 2) (const_int 3)
24562 (const_int 4) (const_int 5)
24563 (const_int 6) (const_int 7)]))))]
24564 "TARGET_AVX2 && <mask_avx512vl_condition>"
24565 "vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
24566 [(set_attr "type" "ssemov")
24567 (set_attr "c86_attr" "vpmovx")
24568 (set_attr "prefix_extra" "1")
24569 (set_attr "prefix" "maybe_evex")
24570 (set_attr "mode" "OI")])
24571
24572 (define_insn "*avx2_<code>v8qiv8si2<mask_name>_1"
24573 [(set (match_operand:V8SI 0 "register_operand" "=v")
24574 (any_extend:V8SI
24575 (match_operand:V8QI 1 "memory_operand" "m")))]
24576 "TARGET_AVX2 && <mask_avx512vl_condition>"
24577 "%vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
24578 [(set_attr "type" "ssemov")
24579 (set_attr "c86_attr" "vpmovx")
24580 (set_attr "prefix_extra" "1")
24581 (set_attr "prefix" "maybe_evex")
24582 (set_attr "mode" "OI")])
24583
24584 (define_insn_and_split "*avx2_<code>v8qiv8si2_2"
24585 [(set (match_operand:V8SI 0 "register_operand")
24586 (any_extend:V8SI
24587 (vec_select:V8QI
24588 (subreg:V16QI
24589 (vec_concat:V2DI
24590 (match_operand:DI 1 "memory_operand")
24591 (const_int 0)) 0)
24592 (parallel [(const_int 0) (const_int 1)
24593 (const_int 2) (const_int 3)
24594 (const_int 4) (const_int 5)
24595 (const_int 6) (const_int 7)]))))]
24596 "TARGET_AVX2
24597 && ix86_pre_reload_split ()"
24598 "#"
24599 "&& 1"
24600 [(set (match_dup 0)
24601 (any_extend:V8SI (match_dup 1)))]
24602 "operands[1] = adjust_address_nv (operands[1], V8QImode, 0);")
24603
24604 (define_insn_and_split "*avx512vl_<code>v8qiv8si2_mask_2"
24605 [(set (match_operand:V8SI 0 "register_operand")
24606 (vec_merge:V8SI
24607 (any_extend:V8SI
24608 (vec_select:V8QI
24609 (subreg:V16QI
24610 (vec_concat:V2DI
24611 (match_operand:DI 1 "memory_operand")
24612 (const_int 0)) 0)
24613 (parallel [(const_int 0) (const_int 1)
24614 (const_int 2) (const_int 3)
24615 (const_int 4) (const_int 5)
24616 (const_int 6) (const_int 7)])))
24617 (match_operand:V8SI 2 "nonimm_or_0_operand")
24618 (match_operand:QI 3 "register_operand")))]
24619 "TARGET_AVX512VL
24620 && ix86_pre_reload_split ()"
24621 "#"
24622 "&& 1"
24623 [(set (match_dup 0)
24624 (vec_merge:V8SI
24625 (any_extend:V8SI (match_dup 1))
24626 (match_dup 2)
24627 (match_dup 3)))]
24628 "operands[1] = adjust_address_nv (operands[1], V8QImode, 0);")
24629
24630
24631 (define_expand "<insn>v8qiv8si2"
24632 [(set (match_operand:V8SI 0 "register_operand")
24633 (any_extend:V8SI
24634 (match_operand:V8QI 1 "nonimmediate_operand")))]
24635 "TARGET_AVX2"
24636 {
24637 if (!MEM_P (operands[1]))
24638 {
24639 rtx op1 = force_reg (V8QImode, operands[1]);
24640 op1 = lowpart_subreg (V16QImode, op1, V8QImode);
24641 emit_insn (gen_avx2_<code>v8qiv8si2 (operands[0], op1));
24642 DONE;
24643 }
24644 })
24645
24646 (define_insn "sse4_1_<code>v4qiv4si2<mask_name>"
24647 [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
24648 (any_extend:V4SI
24649 (vec_select:V4QI
24650 (match_operand:V16QI 1 "register_operand" "Yr,*x,v")
24651 (parallel [(const_int 0) (const_int 1)
24652 (const_int 2) (const_int 3)]))))]
24653 "TARGET_SSE4_1 && <mask_avx512vl_condition>"
24654 "%vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
24655 [(set_attr "isa" "noavx,noavx,avx")
24656 (set_attr "type" "ssemov")
24657 (set_attr "c86_attr" "vpmovx")
24658 (set_attr "prefix_extra" "1")
24659 (set_attr "prefix" "orig,orig,maybe_evex")
24660 (set_attr "mode" "TI")])
24661
24662 (define_insn "*sse4_1_<code>v4qiv4si2<mask_name>_1"
24663 [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
24664 (any_extend:V4SI
24665 (match_operand:V4QI 1 "memory_operand" "jm,jm,m")))]
24666 "TARGET_SSE4_1 && <mask_avx512vl_condition>"
24667 "%vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
24668 [(set_attr "isa" "noavx,noavx,avx")
24669 (set_attr "addr" "gpr16,gpr16,*")
24670 (set_attr "type" "ssemov")
24671 (set_attr "c86_attr" "vpmovx")
24672 (set_attr "prefix_extra" "1")
24673 (set_attr "prefix" "orig,orig,maybe_evex")
24674 (set_attr "mode" "TI")])
24675
24676 (define_insn_and_split "*sse4_1_<code>v4qiv4si2_2"
24677 [(set (match_operand:V4SI 0 "register_operand")
24678 (any_extend:V4SI
24679 (vec_select:V4QI
24680 (subreg:V16QI
24681 (vec_merge:V4SI
24682 (vec_duplicate:V4SI
24683 (match_operand:SI 1 "memory_operand"))
24684 (const_vector:V4SI
24685 [(const_int 0) (const_int 0)
24686 (const_int 0) (const_int 0)])
24687 (const_int 1)) 0)
24688 (parallel [(const_int 0) (const_int 1)
24689 (const_int 2) (const_int 3)]))))]
24690 "TARGET_SSE4_1 && <mask_avx512vl_condition>
24691 && ix86_pre_reload_split ()"
24692 "#"
24693 "&& 1"
24694 [(set (match_dup 0)
24695 (any_extend:V4SI (match_dup 1)))]
24696 "operands[1] = adjust_address_nv (operands[1], V4QImode, 0);")
24697
24698 (define_insn_and_split "*avx512vl_<code>v4qiv4si2_mask_2"
24699 [(set (match_operand:V4SI 0 "register_operand")
24700 (vec_merge:V4SI
24701 (any_extend:V4SI
24702 (vec_select:V4QI
24703 (subreg:V16QI
24704 (vec_merge:V4SI
24705 (vec_duplicate:V4SI
24706 (match_operand:SI 1 "memory_operand"))
24707 (const_vector:V4SI
24708 [(const_int 0) (const_int 0)
24709 (const_int 0) (const_int 0)])
24710 (const_int 1)) 0)
24711 (parallel [(const_int 0) (const_int 1)
24712 (const_int 2) (const_int 3)])))
24713 (match_operand:V4SI 2 "nonimm_or_0_operand")
24714 (match_operand:QI 3 "register_operand")))]
24715 "TARGET_AVX512VL
24716 && ix86_pre_reload_split ()"
24717 "#"
24718 "&& 1"
24719 [(set (match_dup 0)
24720 (vec_merge:V4SI
24721 (any_extend:V4SI (match_dup 1))
24722 (match_dup 2)
24723 (match_dup 3)))]
24724 "operands[1] = adjust_address_nv (operands[1], V4QImode, 0);")
24725
24726
24727 (define_expand "<insn>v4qiv4si2"
24728 [(set (match_operand:V4SI 0 "register_operand")
24729 (any_extend:V4SI
24730 (match_operand:V4QI 1 "nonimmediate_operand")))]
24731 "TARGET_SSE4_1"
24732 {
24733 if (!MEM_P (operands[1]))
24734 {
24735 rtx op1 = force_reg (V4QImode, operands[1]);
24736 op1 = lowpart_subreg (V16QImode, op1, V4QImode);
24737 emit_insn (gen_sse4_1_<code>v4qiv4si2 (operands[0], op1));
24738 DONE;
24739 }
24740 })
24741
24742 (define_insn "avx512f_<code>v16hiv16si2<mask_name>"
24743 [(set (match_operand:V16SI 0 "register_operand" "=v")
24744 (any_extend:V16SI
24745 (match_operand:V16HI 1 "nonimmediate_operand" "vm")))]
24746 "TARGET_AVX512F && TARGET_EVEX512"
24747 "vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
24748 [(set_attr "type" "ssemov")
24749 (set_attr "c86_attr" "vpmovx")
24750 (set_attr "prefix" "evex")
24751 (set_attr "mode" "XI")])
24752
24753 (define_expand "<insn>v16hiv16si2"
24754 [(set (match_operand:V16SI 0 "register_operand")
24755 (any_extend:V16SI
24756 (match_operand:V16HI 1 "nonimmediate_operand")))]
24757 "TARGET_AVX512F && TARGET_EVEX512")
24758
24759 (define_insn_and_split "avx512f_zero_extendv16hiv16si2_1"
24760 [(set (match_operand:V32HI 0 "register_operand" "=v")
24761 (vec_select:V32HI
24762 (vec_concat:V64HI
24763 (match_operand:V32HI 1 "nonimmediate_operand" "vm")
24764 (match_operand:V32HI 2 "const0_operand"))
24765 (match_parallel 3 "pmovzx_parallel"
24766 [(match_operand 4 "const_int_operand")])))]
24767 "TARGET_AVX512F && TARGET_EVEX512"
24768 "#"
24769 "&& reload_completed"
24770 [(set (match_dup 0) (zero_extend:V16SI (match_dup 1)))]
24771 {
24772 operands[0] = lowpart_subreg (V16SImode, operands[0], V32HImode);
24773 operands[1] = lowpart_subreg (V16HImode, operands[1], V32HImode);
24774 })
24775
24776 (define_insn_and_split "*avx512f_zero_extendv16hiv16si2_2"
24777 [(set (match_operand:V32HI 0 "register_operand" "=v")
24778 (vec_select:V32HI
24779 (vec_concat:V64HI
24780 (subreg:V32HI
24781 (vec_concat:VI148_512
24782 (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "vm")
24783 (match_operand:<ssehalfvecmode> 2 "const0_operand")) 0)
24784 (match_operand:V32HI 3 "const0_operand"))
24785 (match_parallel 4 "pmovzx_parallel"
24786 [(match_operand 5 "const_int_operand")])))]
24787 "TARGET_AVX512F"
24788 "#"
24789 "&& reload_completed"
24790 [(set (match_dup 0) (zero_extend:V16SI (match_dup 1)))]
24791 {
24792 operands[0] = lowpart_subreg (V16SImode, operands[0], V32HImode);
24793 operands[1] = lowpart_subreg (V16HImode, operands[1], <ssehalfvecmode>mode);
24794 })
24795
24796 (define_insn "avx2_<code>v8hiv8si2<mask_name>"
24797 [(set (match_operand:V8SI 0 "register_operand" "=v")
24798 (any_extend:V8SI
24799 (match_operand:V8HI 1 "nonimmediate_operand" "vm")))]
24800 "TARGET_AVX2 && <mask_avx512vl_condition>"
24801 "vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
24802 [(set_attr "type" "ssemov")
24803 (set_attr "c86_attr" "vpmovx")
24804 (set_attr "prefix_extra" "1")
24805 (set_attr "prefix" "maybe_evex")
24806 (set_attr "mode" "OI")])
24807
24808 (define_expand "<insn>v8hiv8si2"
24809 [(set (match_operand:V8SI 0 "register_operand")
24810 (any_extend:V8SI
24811 (match_operand:V8HI 1 "nonimmediate_operand")))]
24812 "TARGET_AVX2")
24813
24814 (define_insn_and_split "avx2_zero_extendv8hiv8si2_1"
24815 [(set (match_operand:V16HI 0 "register_operand" "=v")
24816 (vec_select:V16HI
24817 (vec_concat:V32HI
24818 (match_operand:V16HI 1 "nonimmediate_operand" "vm")
24819 (match_operand:V16HI 2 "const0_operand"))
24820 (match_parallel 3 "pmovzx_parallel"
24821 [(match_operand 4 "const_int_operand")])))]
24822 "TARGET_AVX2"
24823 "#"
24824 "&& reload_completed"
24825 [(set (match_dup 0) (zero_extend:V8SI (match_dup 1)))]
24826 {
24827 operands[0] = lowpart_subreg (V8SImode, operands[0], V16HImode);
24828 operands[1] = lowpart_subreg (V8HImode, operands[1], V16HImode);
24829 })
24830
24831 (define_insn_and_split "*avx2_zero_extendv8hiv8si2_2"
24832 [(set (match_operand:V16HI 0 "register_operand" "=v")
24833 (vec_select:V16HI
24834 (vec_concat:V32HI
24835 (subreg:V16HI
24836 (vec_concat:VI148_256
24837 (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "vm")
24838 (match_operand:<ssehalfvecmode> 2 "const0_operand")) 0)
24839 (match_operand:V16HI 3 "const0_operand"))
24840 (match_parallel 4 "pmovzx_parallel"
24841 [(match_operand 5 "const_int_operand")])))]
24842 "TARGET_AVX2"
24843 "#"
24844 "&& reload_completed"
24845 [(set (match_dup 0) (zero_extend:V8SI (match_dup 1)))]
24846 {
24847 operands[0] = lowpart_subreg (V8SImode, operands[0], V16HImode);
24848 operands[1] = lowpart_subreg (V8HImode, operands[1], <ssehalfvecmode>mode);
24849 })
24850
24851
24852 (define_insn "sse4_1_<code>v4hiv4si2<mask_name>"
24853 [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
24854 (any_extend:V4SI
24855 (vec_select:V4HI
24856 (match_operand:V8HI 1 "register_operand" "Yr,*x,v")
24857 (parallel [(const_int 0) (const_int 1)
24858 (const_int 2) (const_int 3)]))))]
24859 "TARGET_SSE4_1 && <mask_avx512vl_condition>"
24860 "%vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
24861 [(set_attr "isa" "noavx,noavx,avx")
24862 (set_attr "type" "ssemov")
24863 (set_attr "c86_attr" "vpmovx")
24864 (set_attr "prefix_extra" "1")
24865 (set_attr "prefix" "orig,orig,maybe_evex")
24866 (set_attr "mode" "TI")])
24867
24868 (define_insn "*sse4_1_<code>v4hiv4si2<mask_name>_1"
24869 [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
24870 (any_extend:V4SI
24871 (match_operand:V4HI 1 "memory_operand" "jm,jm,m")))]
24872 "TARGET_SSE4_1 && <mask_avx512vl_condition>"
24873 "%vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
24874 [(set_attr "isa" "noavx,noavx,avx")
24875 (set_attr "addr" "gpr16,gpr16,*")
24876 (set_attr "type" "ssemov")
24877 (set_attr "c86_attr" "vpmovx")
24878 (set_attr "prefix_extra" "1")
24879 (set_attr "prefix" "orig,orig,maybe_evex")
24880 (set_attr "mode" "TI")])
24881
24882 (define_insn_and_split "*sse4_1_<code>v4hiv4si2_2"
24883 [(set (match_operand:V4SI 0 "register_operand")
24884 (any_extend:V4SI
24885 (vec_select:V4HI
24886 (subreg:V8HI
24887 (vec_concat:V2DI
24888 (match_operand:DI 1 "memory_operand")
24889 (const_int 0)) 0)
24890 (parallel [(const_int 0) (const_int 1)
24891 (const_int 2) (const_int 3)]))))]
24892 "TARGET_SSE4_1
24893 && ix86_pre_reload_split ()"
24894 "#"
24895 "&& 1"
24896 [(set (match_dup 0)
24897 (any_extend:V4SI (match_dup 1)))]
24898 "operands[1] = adjust_address_nv (operands[1], V4HImode, 0);")
24899
24900 (define_insn_and_split "*avx512vl_<code>v4hiv4si2_mask_2"
24901 [(set (match_operand:V4SI 0 "register_operand")
24902 (vec_merge:V4SI
24903 (any_extend:V4SI
24904 (vec_select:V4HI
24905 (subreg:V8HI
24906 (vec_concat:V2DI
24907 (match_operand:DI 1 "memory_operand")
24908 (const_int 0)) 0)
24909 (parallel [(const_int 0) (const_int 1)
24910 (const_int 2) (const_int 3)])))
24911 (match_operand:V4SI 2 "nonimm_or_0_operand")
24912 (match_operand:QI 3 "register_operand")))]
24913 "TARGET_AVX512VL
24914 && ix86_pre_reload_split ()"
24915 "#"
24916 "&& 1"
24917 [(set (match_dup 0)
24918 (vec_merge:V4SI
24919 (any_extend:V4SI (match_dup 1))
24920 (match_dup 2)
24921 (match_dup 3)))]
24922 "operands[1] = adjust_address_nv (operands[1], V4HImode, 0);")
24923
24924
24925 (define_expand "<insn>v4hiv4si2"
24926 [(set (match_operand:V4SI 0 "register_operand")
24927 (any_extend:V4SI
24928 (match_operand:V4HI 1 "nonimmediate_operand")))]
24929 "TARGET_SSE4_1 || TARGET_MMX_WITH_SSE"
24930 {
24931 if (!TARGET_SSE4_1)
24932 {
24933 ix86_expand_sse_extend (operands[0], operands[1], <u_bool>);
24934 DONE;
24935 }
24936
24937 if (!MEM_P (operands[1]))
24938 {
24939 rtx op1 = force_reg (V4HImode, operands[1]);
24940 op1 = lowpart_subreg (V8HImode, op1, V4HImode);
24941 emit_insn (gen_sse4_1_<code>v4hiv4si2 (operands[0], op1));
24942 DONE;
24943 }
24944 })
24945
24946 (define_insn_and_split "*sse4_1_zero_extendv4hiv4si2_3"
24947 [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,v")
24948 (vec_select:V8HI
24949 (vec_concat:V16HI
24950 (match_operand:V8HI 1 "vector_operand" "Yrja,*xja,vm")
24951 (match_operand:V8HI 2 "const0_operand"))
24952 (match_parallel 3 "pmovzx_parallel"
24953 [(match_operand 4 "const_int_operand")])))]
24954 "TARGET_SSE4_1"
24955 "#"
24956 "&& reload_completed"
24957 [(set (match_dup 0)
24958 (zero_extend:V4SI
24959 (vec_select:V4HI
24960 (match_dup 1)
24961 (parallel [(const_int 0) (const_int 1)
24962 (const_int 2) (const_int 3)]))))]
24963 {
24964 operands[0] = lowpart_subreg (V4SImode, operands[0], V8HImode);
24965 if (MEM_P (operands[1]))
24966 {
24967 operands[1] = lowpart_subreg (V4HImode, operands[1], V8HImode);
24968 operands[1] = gen_rtx_ZERO_EXTEND (V4SImode, operands[1]);
24969 emit_insn (gen_rtx_SET (operands[0], operands[1]));
24970 DONE;
24971 }
24972 }
24973 [(set_attr "isa" "noavx,noavx,avx")
24974 (set_attr "addr" "gpr16,gpr16,*")])
24975
24976 (define_insn_and_split "*sse4_1_zero_extendv4hiv4si2_4"
24977 [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,v")
24978 (vec_select:V8HI
24979 (vec_concat:V16HI
24980 (subreg:V8HI
24981 (vec_concat:VI148_128
24982 (match_operand:<ssehalfvecmode> 1 "vector_operand" "Yrja,*xja,vm")
24983 (match_operand:<ssehalfvecmode> 2 "const0_operand")) 0)
24984 (match_operand:V8HI 3 "const0_operand"))
24985 (match_parallel 4 "pmovzx_parallel"
24986 [(match_operand 5 "const_int_operand")])))]
24987 "TARGET_SSE4_1"
24988 "#"
24989 "&& reload_completed"
24990 [(set (match_dup 0)
24991 (zero_extend:V4SI
24992 (vec_select:V4HI
24993 (match_dup 1)
24994 (parallel [(const_int 0) (const_int 1)
24995 (const_int 2) (const_int 3)]))))]
24996 {
24997 operands[0] = lowpart_subreg (V4SImode, operands[0], V8HImode);
24998 if (MEM_P (operands[1]))
24999 {
25000 operands[1] = lowpart_subreg (V4HImode, operands[1], <ssehalfvecmode>mode);
25001 operands[1] = gen_rtx_ZERO_EXTEND (V4SImode, operands[1]);
25002 emit_insn (gen_rtx_SET (operands[0], operands[1]));
25003 DONE;
25004 }
25005 operands[1] = lowpart_subreg (V8HImode, operands[1], <ssehalfvecmode>mode);
25006 }
25007 [(set_attr "isa" "noavx,noavx,avx")
25008 (set_attr "addr" "gpr16,gpr16,*")])
25009
25010 (define_insn "avx512f_<code>v8qiv8di2<mask_name>"
25011 [(set (match_operand:V8DI 0 "register_operand" "=v")
25012 (any_extend:V8DI
25013 (vec_select:V8QI
25014 (match_operand:V16QI 1 "register_operand" "v")
25015 (parallel [(const_int 0) (const_int 1)
25016 (const_int 2) (const_int 3)
25017 (const_int 4) (const_int 5)
25018 (const_int 6) (const_int 7)]))))]
25019 "TARGET_AVX512F && TARGET_EVEX512"
25020 "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25021 [(set_attr "type" "ssemov")
25022 (set_attr "c86_attr" "vpmovx")
25023 (set_attr "prefix" "evex")
25024 (set_attr "mode" "XI")])
25025
25026 (define_insn "*avx512f_<code>v8qiv8di2<mask_name>_1"
25027 [(set (match_operand:V8DI 0 "register_operand" "=v")
25028 (any_extend:V8DI
25029 (match_operand:V8QI 1 "memory_operand" "m")))]
25030 "TARGET_AVX512F && TARGET_EVEX512"
25031 "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25032 [(set_attr "type" "ssemov")
25033 (set_attr "c86_attr" "vpmovx")
25034 (set_attr "prefix" "evex")
25035 (set_attr "mode" "XI")])
25036
25037 (define_insn_and_split "*avx512f_<code>v8qiv8di2_2"
25038 [(set (match_operand:V8DI 0 "register_operand")
25039 (any_extend:V8DI
25040 (vec_select:V8QI
25041 (subreg:V16QI
25042 (vec_concat:V2DI
25043 (match_operand:DI 1 "memory_operand")
25044 (const_int 0)) 0)
25045 (parallel [(const_int 0) (const_int 1)
25046 (const_int 2) (const_int 3)
25047 (const_int 4) (const_int 5)
25048 (const_int 6) (const_int 7)]))))]
25049 "TARGET_AVX512F && TARGET_EVEX512 && ix86_pre_reload_split ()"
25050 "#"
25051 "&& 1"
25052 [(set (match_dup 0)
25053 (any_extend:V8DI (match_dup 1)))]
25054 "operands[1] = adjust_address_nv (operands[1], V8QImode, 0);")
25055
25056 (define_insn_and_split "*avx512f_<code>v8qiv8di2_mask_2"
25057 [(set (match_operand:V8DI 0 "register_operand")
25058 (vec_merge:V8DI
25059 (any_extend:V8DI
25060 (vec_select:V8QI
25061 (subreg:V16QI
25062 (vec_concat:V2DI
25063 (match_operand:DI 1 "memory_operand")
25064 (const_int 0)) 0)
25065 (parallel [(const_int 0) (const_int 1)
25066 (const_int 2) (const_int 3)
25067 (const_int 4) (const_int 5)
25068 (const_int 6) (const_int 7)])))
25069 (match_operand:V8DI 2 "nonimm_or_0_operand")
25070 (match_operand:QI 3 "register_operand")))]
25071 "TARGET_AVX512F && ix86_pre_reload_split ()"
25072 "#"
25073 "&& 1"
25074 [(set (match_dup 0)
25075 (vec_merge:V8DI
25076 (any_extend:V8DI (match_dup 1))
25077 (match_dup 2)
25078 (match_dup 3)))]
25079 "operands[1] = adjust_address_nv (operands[1], V8QImode, 0);")
25080
25081
25082 (define_expand "<insn>v8qiv8di2"
25083 [(set (match_operand:V8DI 0 "register_operand")
25084 (any_extend:V8DI
25085 (match_operand:V8QI 1 "nonimmediate_operand")))]
25086 "TARGET_AVX512F && TARGET_EVEX512"
25087 {
25088 if (!MEM_P (operands[1]))
25089 {
25090 rtx op1 = force_reg (V8QImode, operands[1]);
25091 op1 = lowpart_subreg (V16QImode, op1, V8QImode);
25092 emit_insn (gen_avx512f_<code>v8qiv8di2 (operands[0], op1));
25093 DONE;
25094 }
25095 })
25096
25097 (define_insn "avx2_<code>v4qiv4di2<mask_name>"
25098 [(set (match_operand:V4DI 0 "register_operand" "=v")
25099 (any_extend:V4DI
25100 (vec_select:V4QI
25101 (match_operand:V16QI 1 "register_operand" "v")
25102 (parallel [(const_int 0) (const_int 1)
25103 (const_int 2) (const_int 3)]))))]
25104 "TARGET_AVX2 && <mask_avx512vl_condition>"
25105 "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25106 [(set_attr "type" "ssemov")
25107 (set_attr "c86_attr" "vpmovx")
25108 (set_attr "prefix_extra" "1")
25109 (set_attr "prefix" "maybe_evex")
25110 (set_attr "mode" "OI")])
25111
25112 (define_insn "*avx2_<code>v4qiv4di2<mask_name>_1"
25113 [(set (match_operand:V4DI 0 "register_operand" "=v")
25114 (any_extend:V4DI
25115 (match_operand:V4QI 1 "memory_operand" "m")))]
25116 "TARGET_AVX2 && <mask_avx512vl_condition>"
25117 "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25118 [(set_attr "type" "ssemov")
25119 (set_attr "c86_attr" "vpmovx")
25120 (set_attr "prefix_extra" "1")
25121 (set_attr "prefix" "maybe_evex")
25122 (set_attr "mode" "OI")])
25123
25124 (define_insn_and_split "*avx2_<code>v4qiv4di2_2"
25125 [(set (match_operand:V4DI 0 "register_operand")
25126 (any_extend:V4DI
25127 (vec_select:V4QI
25128 (subreg:V16QI
25129 (vec_merge:V4SI
25130 (vec_duplicate:V4SI
25131 (match_operand:SI 1 "memory_operand"))
25132 (const_vector:V4SI
25133 [(const_int 0) (const_int 0)
25134 (const_int 0) (const_int 0)])
25135 (const_int 1)) 0)
25136 (parallel [(const_int 0) (const_int 1)
25137 (const_int 2) (const_int 3)]))))]
25138 "TARGET_AVX2
25139 && ix86_pre_reload_split ()"
25140 "#"
25141 "&& 1"
25142 [(set (match_dup 0)
25143 (any_extend:V4DI (match_dup 1)))]
25144 "operands[1] = adjust_address_nv (operands[1], V4QImode, 0);")
25145
25146 (define_insn_and_split "*avx512vl_<code>v4qiv4di2_mask_2"
25147 [(set (match_operand:V4DI 0 "register_operand")
25148 (vec_merge:V4DI
25149 (any_extend:V4DI
25150 (vec_select:V4QI
25151 (subreg:V16QI
25152 (vec_merge:V4SI
25153 (vec_duplicate:V4SI
25154 (match_operand:SI 1 "memory_operand"))
25155 (const_vector:V4SI
25156 [(const_int 0) (const_int 0)
25157 (const_int 0) (const_int 0)])
25158 (const_int 1)) 0)
25159 (parallel [(const_int 0) (const_int 1)
25160 (const_int 2) (const_int 3)])))
25161 (match_operand:V4DI 2 "nonimm_or_0_operand")
25162 (match_operand:QI 3 "register_operand")))]
25163 "TARGET_AVX512VL
25164 && ix86_pre_reload_split ()"
25165 "#"
25166 "&& 1"
25167 [(set (match_dup 0)
25168 (vec_merge:V4DI
25169 (any_extend:V4DI (match_dup 1))
25170 (match_dup 2)
25171 (match_dup 3)))]
25172 "operands[1] = adjust_address_nv (operands[1], V4QImode, 0);")
25173
25174
25175 (define_expand "<insn>v4qiv4di2"
25176 [(set (match_operand:V4DI 0 "register_operand")
25177 (any_extend:V4DI
25178 (match_operand:V4QI 1 "nonimmediate_operand")))]
25179 "TARGET_AVX2"
25180 {
25181 if (!MEM_P (operands[1]))
25182 {
25183 rtx op1 = force_reg (V4QImode, operands[1]);
25184 op1 = lowpart_subreg (V16QImode, operands[1], V4QImode);
25185 emit_insn (gen_avx2_<code>v4qiv4di2 (operands[0], op1));
25186 DONE;
25187 }
25188 })
25189
25190 (define_insn "sse4_1_<code>v2qiv2di2<mask_name>"
25191 [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
25192 (any_extend:V2DI
25193 (vec_select:V2QI
25194 (match_operand:V16QI 1 "register_operand" "Yr,*x,v")
25195 (parallel [(const_int 0) (const_int 1)]))))]
25196 "TARGET_SSE4_1 && <mask_avx512vl_condition>"
25197 "%vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25198 [(set_attr "isa" "noavx,noavx,avx")
25199 (set_attr "type" "ssemov")
25200 (set_attr "c86_attr" "vpmovx")
25201 (set_attr "prefix_extra" "1")
25202 (set_attr "prefix" "orig,orig,maybe_evex")
25203 (set_attr "mode" "TI")])
25204
25205 (define_insn "*sse4_1_<code>v2qiv2di2<mask_name>_1"
25206 [(set (match_operand:V2DI 0 "register_operand" "=x,v")
25207 (any_extend:V2DI
25208 (match_operand:V2QI 1 "memory_operand" "jm,m")))]
25209 "TARGET_SSE4_1 && <mask_avx512vl_condition>"
25210 "%vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25211 [(set_attr "isa" "noavx,avx")
25212 (set_attr "addr" "gpr16,*")
25213 (set_attr "type" "ssemov")
25214 (set_attr "c86_attr" "vpmovx")
25215 (set_attr "prefix_extra" "1")
25216 (set_attr "prefix" "maybe_evex")
25217 (set_attr "mode" "TI")])
25218
25219 (define_expand "<insn>v2qiv2di2"
25220 [(set (match_operand:V2DI 0 "register_operand")
25221 (any_extend:V2DI
25222 (match_operand:V2QI 1 "nonimmediate_operand")))]
25223 "TARGET_SSE4_1"
25224 {
25225 if (!MEM_P (operands[1]))
25226 {
25227 rtx op1 = force_reg (V2QImode, operands[1]);
25228 op1 = lowpart_subreg (V16QImode, op1, V2QImode);
25229 emit_insn (gen_sse4_1_<code>v2qiv2di2 (operands[0], op1));
25230 DONE;
25231 }
25232 })
25233
25234 (define_insn_and_split "*sse4_1_zero_extendv2qiv2di2_2"
25235 [(set (match_operand:V2DI 0 "register_operand")
25236 (zero_extend:V2DI
25237 (vec_select:V2QI
25238 (subreg:V16QI
25239 (vec_merge:V8_128
25240 (vec_duplicate:V8_128
25241 (match_operand:<ssescalarmode> 1 "nonimmediate_operand"))
25242 (match_operand:V8_128 2 "const0_operand")
25243 (const_int 1)) 0)
25244 (parallel [(const_int 0) (const_int 1)]))))]
25245 "TARGET_SSE4_1 && ix86_pre_reload_split ()"
25246 "#"
25247 "&& 1"
25248 [(const_int 0)]
25249 {
25250 if (!MEM_P (operands[1]))
25251 operands[1] = force_reg (<ssescalarmode>mode, operands[1]);
25252 operands[1] = lowpart_subreg (V2QImode, operands[1], <ssescalarmode>mode);
25253 emit_insn (gen_zero_extendv2qiv2di2 (operands[0], operands[1]));
25254 DONE;
25255 })
25256
25257 (define_insn "avx512f_<code>v8hiv8di2<mask_name>"
25258 [(set (match_operand:V8DI 0 "register_operand" "=v")
25259 (any_extend:V8DI
25260 (match_operand:V8HI 1 "nonimmediate_operand" "vm")))]
25261 "TARGET_AVX512F && TARGET_EVEX512"
25262 "vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25263 [(set_attr "type" "ssemov")
25264 (set_attr "c86_attr" "vpmovx")
25265 (set_attr "prefix" "evex")
25266 (set_attr "mode" "XI")])
25267
25268 (define_expand "<insn>v8hiv8di2"
25269 [(set (match_operand:V8DI 0 "register_operand")
25270 (any_extend:V8DI
25271 (match_operand:V8HI 1 "nonimmediate_operand")))]
25272 "TARGET_AVX512F && TARGET_EVEX512")
25273
25274 (define_insn "avx2_<code>v4hiv4di2<mask_name>"
25275 [(set (match_operand:V4DI 0 "register_operand" "=v")
25276 (any_extend:V4DI
25277 (vec_select:V4HI
25278 (match_operand:V8HI 1 "register_operand" "v")
25279 (parallel [(const_int 0) (const_int 1)
25280 (const_int 2) (const_int 3)]))))]
25281 "TARGET_AVX2 && <mask_avx512vl_condition>"
25282 "vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25283 [(set_attr "type" "ssemov")
25284 (set_attr "c86_attr" "vpmovx")
25285 (set_attr "prefix_extra" "1")
25286 (set_attr "prefix" "maybe_evex")
25287 (set_attr "mode" "OI")])
25288
25289 (define_insn "*avx2_<code>v4hiv4di2<mask_name>_1"
25290 [(set (match_operand:V4DI 0 "register_operand" "=v")
25291 (any_extend:V4DI
25292 (match_operand:V4HI 1 "memory_operand" "m")))]
25293 "TARGET_AVX2 && <mask_avx512vl_condition>"
25294 "vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25295 [(set_attr "type" "ssemov")
25296 (set_attr "c86_attr" "vpmovx")
25297 (set_attr "prefix_extra" "1")
25298 (set_attr "prefix" "maybe_evex")
25299 (set_attr "mode" "OI")])
25300
25301 (define_insn_and_split "*avx2_<code>v4hiv4di2_2"
25302 [(set (match_operand:V4DI 0 "register_operand")
25303 (any_extend:V4DI
25304 (vec_select:V4HI
25305 (subreg:V8HI
25306 (vec_concat:V2DI
25307 (match_operand:DI 1 "memory_operand")
25308 (const_int 0)) 0)
25309 (parallel [(const_int 0) (const_int 1)
25310 (const_int 2) (const_int 3)]))))]
25311 "TARGET_AVX2
25312 && ix86_pre_reload_split ()"
25313 "#"
25314 "&& 1"
25315 [(set (match_dup 0)
25316 (any_extend:V4DI (match_dup 1)))]
25317 "operands[1] = adjust_address_nv (operands[1], V4HImode, 0);")
25318
25319 (define_insn_and_split "*avx512vl_<code>v4hiv4di2_mask_2"
25320 [(set (match_operand:V4DI 0 "register_operand")
25321 (vec_merge:V4DI
25322 (any_extend:V4DI
25323 (vec_select:V4HI
25324 (subreg:V8HI
25325 (vec_concat:V2DI
25326 (match_operand:DI 1 "memory_operand")
25327 (const_int 0)) 0)
25328 (parallel [(const_int 0) (const_int 1)
25329 (const_int 2) (const_int 3)])))
25330 (match_operand:V4DI 2 "nonimm_or_0_operand")
25331 (match_operand:QI 3 "register_operand")))]
25332 "TARGET_AVX512VL
25333 && ix86_pre_reload_split ()"
25334 "#"
25335 "&& 1"
25336 [(set (match_dup 0)
25337 (vec_merge:V4DI
25338 (any_extend:V4DI (match_dup 1))
25339 (match_dup 2)
25340 (match_dup 3)))]
25341 "operands[1] = adjust_address_nv (operands[1], V4HImode, 0);")
25342
25343
25344 (define_expand "<insn>v4hiv4di2"
25345 [(set (match_operand:V4DI 0 "register_operand")
25346 (any_extend:V4DI
25347 (match_operand:V4HI 1 "nonimmediate_operand")))]
25348 "TARGET_AVX2"
25349 {
25350 if (!MEM_P (operands[1]))
25351 {
25352 rtx op1 = force_reg (V4HImode, operands[1]);
25353 op1 = lowpart_subreg (V8HImode, op1, V4HImode);
25354 emit_insn (gen_avx2_<code>v4hiv4di2 (operands[0], op1));
25355 DONE;
25356 }
25357 })
25358
25359 (define_insn "sse4_1_<code>v2hiv2di2<mask_name>"
25360 [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
25361 (any_extend:V2DI
25362 (vec_select:V2HI
25363 (match_operand:V8HI 1 "register_operand" "Yr,*x,v")
25364 (parallel [(const_int 0) (const_int 1)]))))]
25365 "TARGET_SSE4_1 && <mask_avx512vl_condition>"
25366 "%vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25367 [(set_attr "isa" "noavx,noavx,avx")
25368 (set_attr "type" "ssemov")
25369 (set_attr "c86_attr" "vpmovx")
25370 (set_attr "prefix_extra" "1")
25371 (set_attr "prefix" "orig,orig,maybe_evex")
25372 (set_attr "mode" "TI")])
25373
25374 (define_insn "*sse4_1_<code>v2hiv2di2<mask_name>_1"
25375 [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
25376 (any_extend:V2DI
25377 (match_operand:V2HI 1 "memory_operand" "jm,jm,m")))]
25378 "TARGET_SSE4_1 && <mask_avx512vl_condition>"
25379 "%vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25380 [(set_attr "isa" "noavx,noavx,avx")
25381 (set_attr "addr" "gpr16,gpr16,*")
25382 (set_attr "type" "ssemov")
25383 (set_attr "c86_attr" "vpmovx")
25384 (set_attr "prefix_extra" "1")
25385 (set_attr "prefix" "orig,orig,maybe_evex")
25386 (set_attr "mode" "TI")])
25387
25388 (define_insn_and_split "*sse4_1_<code>v2hiv2di2_2"
25389 [(set (match_operand:V2DI 0 "register_operand")
25390 (any_extend:V2DI
25391 (vec_select:V2HI
25392 (subreg:V8HI
25393 (vec_merge:V4SI
25394 (vec_duplicate:V4SI
25395 (match_operand:SI 1 "memory_operand"))
25396 (const_vector:V4SI
25397 [(const_int 0) (const_int 0)
25398 (const_int 0) (const_int 0)])
25399 (const_int 1)) 0)
25400 (parallel [(const_int 0) (const_int 1)]))))]
25401 "TARGET_SSE4_1
25402 && ix86_pre_reload_split ()"
25403 "#"
25404 "&& 1"
25405 [(set (match_dup 0)
25406 (any_extend:V2DI (match_dup 1)))]
25407 "operands[1] = adjust_address_nv (operands[1], V2HImode, 0);")
25408
25409 (define_insn_and_split "*avx512vl_<code>v2hiv2di2_mask_2"
25410 [(set (match_operand:V2DI 0 "register_operand")
25411 (vec_merge:V2DI
25412 (any_extend:V2DI
25413 (vec_select:V2HI
25414 (subreg:V8HI
25415 (vec_merge:V4SI
25416 (vec_duplicate:V4SI
25417 (match_operand:SI 1 "memory_operand"))
25418 (const_vector:V4SI
25419 [(const_int 0) (const_int 0)
25420 (const_int 0) (const_int 0)])
25421 (const_int 1)) 0)
25422 (parallel [(const_int 0) (const_int 1)])))
25423 (match_operand:V2DI 2 "nonimm_or_0_operand")
25424 (match_operand:QI 3 "register_operand")))]
25425 "TARGET_AVX512VL
25426 && ix86_pre_reload_split ()"
25427 "#"
25428 "&& 1"
25429 [(set (match_dup 0)
25430 (vec_merge:V2DI
25431 (any_extend:V2DI (match_dup 1))
25432 (match_dup 2)
25433 (match_dup 3)))]
25434 "operands[1] = adjust_address_nv (operands[1], V2HImode, 0);")
25435
25436
25437 (define_expand "<insn>v2hiv2di2"
25438 [(set (match_operand:V2DI 0 "register_operand")
25439 (any_extend:V2DI
25440 (match_operand:V2HI 1 "nonimmediate_operand")))]
25441 "TARGET_SSE4_1"
25442 {
25443 if (!MEM_P (operands[1]))
25444 {
25445 rtx op1 = force_reg (V2HImode, operands[1]);
25446 op1 = lowpart_subreg (V8HImode, op1, V2HImode);
25447 emit_insn (gen_sse4_1_<code>v2hiv2di2 (operands[0], op1));
25448 DONE;
25449 }
25450 })
25451
25452 (define_insn "avx512f_<code>v8siv8di2<mask_name>"
25453 [(set (match_operand:V8DI 0 "register_operand" "=v")
25454 (any_extend:V8DI
25455 (match_operand:V8SI 1 "nonimmediate_operand" "vm")))]
25456 "TARGET_AVX512F && TARGET_EVEX512"
25457 "vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25458 [(set_attr "type" "ssemov")
25459 (set_attr "c86_attr" "vpmovx")
25460 (set_attr "prefix" "evex")
25461 (set_attr "mode" "XI")])
25462
25463 (define_insn_and_split "*avx512f_zero_extendv8siv8di2_1"
25464 [(set (match_operand:V16SI 0 "register_operand" "=v")
25465 (vec_select:V16SI
25466 (vec_concat:V32SI
25467 (match_operand:V16SI 1 "nonimmediate_operand" "vm")
25468 (match_operand:V16SI 2 "const0_operand"))
25469 (match_parallel 3 "pmovzx_parallel"
25470 [(match_operand 4 "const_int_operand")])))]
25471 "TARGET_AVX512F && TARGET_EVEX512"
25472 "#"
25473 "&& reload_completed"
25474 [(set (match_dup 0) (zero_extend:V8DI (match_dup 1)))]
25475 {
25476 operands[0] = lowpart_subreg (V8DImode, operands[0], V16SImode);
25477 operands[1] = lowpart_subreg (V8SImode, operands[1], V16SImode);
25478 })
25479
25480 (define_insn_and_split "*avx512f_zero_extendv8siv8di2_2"
25481 [(set (match_operand:V16SI 0 "register_operand" "=v")
25482 (vec_select:V16SI
25483 (vec_concat:V32SI
25484 (vec_concat:V16SI
25485 (match_operand:V8SI 1 "nonimmediate_operand" "vm")
25486 (match_operand:V8SI 2 "const0_operand"))
25487 (match_operand:V16SI 3 "const0_operand"))
25488 (match_parallel 4 "pmovzx_parallel"
25489 [(match_operand 5 "const_int_operand")])))]
25490 "TARGET_AVX512F && TARGET_EVEX512"
25491 "#"
25492 "&& reload_completed"
25493 [(set (match_dup 0) (zero_extend:V8DI (match_dup 1)))]
25494 {
25495 operands[0] = lowpart_subreg (V8DImode, operands[0], V16SImode);
25496 })
25497
25498 (define_expand "<insn>v8siv8di2"
25499 [(set (match_operand:V8DI 0 "register_operand" "=v")
25500 (any_extend:V8DI
25501 (match_operand:V8SI 1 "nonimmediate_operand" "vm")))]
25502 "TARGET_AVX512F && TARGET_EVEX512")
25503
25504 (define_insn "avx2_<code>v4siv4di2<mask_name>"
25505 [(set (match_operand:V4DI 0 "register_operand" "=v")
25506 (any_extend:V4DI
25507 (match_operand:V4SI 1 "nonimmediate_operand" "vm")))]
25508 "TARGET_AVX2 && <mask_avx512vl_condition>"
25509 "vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25510 [(set_attr "type" "ssemov")
25511 (set_attr "c86_attr" "vpmovx")
25512 (set_attr "prefix" "maybe_evex")
25513 (set_attr "prefix_extra" "1")
25514 (set_attr "mode" "OI")])
25515
25516 (define_insn_and_split "*avx2_zero_extendv4siv4di2_1"
25517 [(set (match_operand:V8SI 0 "register_operand" "=v")
25518 (vec_select:V8SI
25519 (vec_concat:V16SI
25520 (match_operand:V8SI 1 "nonimmediate_operand" "vm")
25521 (match_operand:V8SI 2 "const0_operand"))
25522 (match_parallel 3 "pmovzx_parallel"
25523 [(match_operand 4 "const_int_operand")])))]
25524 "TARGET_AVX2"
25525 "#"
25526 "&& reload_completed"
25527 [(set (match_dup 0) (zero_extend:V4DI (match_dup 1)))]
25528 {
25529 operands[0] = lowpart_subreg (V4DImode, operands[0], V8SImode);
25530 operands[1] = lowpart_subreg (V4SImode, operands[1], V8SImode);
25531 })
25532
25533 (define_insn_and_split "*avx2_zero_extendv4siv4di2_2"
25534 [(set (match_operand:V8SI 0 "register_operand" "=v")
25535 (vec_select:V8SI
25536 (vec_concat:V16SI
25537 (vec_concat:V8SI
25538 (match_operand:V4SI 1 "nonimmediate_operand" "vm")
25539 (match_operand:V4SI 2 "const0_operand"))
25540 (match_operand:V8SI 3 "const0_operand"))
25541 (match_parallel 4 "pmovzx_parallel"
25542 [(match_operand 5 "const_int_operand")])))]
25543 "TARGET_AVX2"
25544 "#"
25545 "&& reload_completed"
25546 [(set (match_dup 0) (zero_extend:V4DI (match_dup 1)))]
25547 {
25548 operands[0] = lowpart_subreg (V4DImode, operands[0], V8SImode);
25549 })
25550
25551 (define_expand "<insn>v4siv4di2"
25552 [(set (match_operand:V4DI 0 "register_operand")
25553 (any_extend:V4DI
25554 (match_operand:V4SI 1 "nonimmediate_operand")))]
25555 "TARGET_AVX2")
25556
25557 (define_insn "sse4_1_<code>v2siv2di2<mask_name>"
25558 [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
25559 (any_extend:V2DI
25560 (vec_select:V2SI
25561 (match_operand:V4SI 1 "register_operand" "Yr,*x,v")
25562 (parallel [(const_int 0) (const_int 1)]))))]
25563 "TARGET_SSE4_1 && <mask_avx512vl_condition>"
25564 "%vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25565 [(set_attr "isa" "noavx,noavx,avx")
25566 (set_attr "type" "ssemov")
25567 (set_attr "c86_attr" "vpmovx")
25568 (set_attr "prefix_extra" "1")
25569 (set_attr "prefix" "orig,orig,maybe_evex")
25570 (set_attr "mode" "TI")])
25571
25572 (define_insn "*sse4_1_<code>v2siv2di2<mask_name>_1"
25573 [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
25574 (any_extend:V2DI
25575 (match_operand:V2SI 1 "memory_operand" "jm,jm,m")))]
25576 "TARGET_SSE4_1 && <mask_avx512vl_condition>"
25577 "%vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
25578 [(set_attr "isa" "noavx,noavx,avx")
25579 (set_attr "addr" "gpr16,gpr16,*")
25580 (set_attr "type" "ssemov")
25581 (set_attr "c86_attr" "vpmovx")
25582 (set_attr "prefix_extra" "1")
25583 (set_attr "prefix" "orig,orig,maybe_evex")
25584 (set_attr "mode" "TI")])
25585
25586 (define_insn_and_split "*sse4_1_<code>v2siv2di2_2"
25587 [(set (match_operand:V2DI 0 "register_operand")
25588 (any_extend:V2DI
25589 (vec_select:V2SI
25590 (subreg:V4SI
25591 (vec_concat:V2DI
25592 (match_operand:DI 1 "memory_operand")
25593 (const_int 0)) 0)
25594 (parallel [(const_int 0) (const_int 1)]))))]
25595 "TARGET_SSE4_1
25596 && ix86_pre_reload_split ()"
25597 "#"
25598 "&& 1"
25599 [(set (match_dup 0)
25600 (any_extend:V2DI (match_dup 1)))]
25601 "operands[1] = adjust_address_nv (operands[1], V2SImode, 0);")
25602
25603 (define_insn_and_split "*avx512vl_<code>v2siv2di2_mask_2"
25604 [(set (match_operand:V2DI 0 "register_operand")
25605 (vec_merge:V2DI
25606 (any_extend:V2DI
25607 (vec_select:V2SI
25608 (subreg:V4SI
25609 (vec_concat:V2DI
25610 (match_operand:DI 1 "memory_operand")
25611 (const_int 0)) 0)
25612 (parallel [(const_int 0) (const_int 1)])))
25613 (match_operand:V2DI 2 "nonimm_or_0_operand")
25614 (match_operand:QI 3 "register_operand")))]
25615 "TARGET_AVX512VL
25616 && ix86_pre_reload_split ()"
25617 "#"
25618 "&& 1"
25619 [(set (match_dup 0)
25620 (vec_merge:V2DI
25621 (any_extend:V2DI (match_dup 1))
25622 (match_dup 2)
25623 (match_dup 3)))]
25624 "operands[1] = adjust_address_nv (operands[1], V2SImode, 0);")
25625
25626 (define_insn_and_split "*sse4_1_zero_extendv2siv2di2_3"
25627 [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
25628 (vec_select:V4SI
25629 (vec_concat:V8SI
25630 (match_operand:V4SI 1 "vector_operand" "Yrja,*xja,vm")
25631 (match_operand:V4SI 2 "const0_operand"))
25632 (match_parallel 3 "pmovzx_parallel"
25633 [(match_operand 4 "const_int_operand")])))]
25634 "TARGET_SSE4_1"
25635 "#"
25636 "&& reload_completed"
25637 [(set (match_dup 0)
25638 (zero_extend:V2DI
25639 (vec_select:V2SI (match_dup 1)
25640 (parallel [(const_int 0) (const_int 1)]))))]
25641 {
25642 operands[0] = lowpart_subreg (V2DImode, operands[0], V4SImode);
25643 if (MEM_P (operands[1]))
25644 {
25645 operands[1] = lowpart_subreg (V2SImode, operands[1], V4SImode);
25646 operands[1] = gen_rtx_ZERO_EXTEND (V2DImode, operands[1]);
25647 emit_insn (gen_rtx_SET (operands[0], operands[1]));
25648 DONE;
25649 }
25650 }
25651 [(set_attr "isa" "noavx,noavx,avx")
25652 (set_attr "addr" "gpr16,gpr16,*")])
25653
25654 (define_insn_and_split "*sse4_1_zero_extendv2siv2di2_4"
25655 [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
25656 (vec_select:V4SI
25657 (vec_concat:V8SI
25658 (vec_concat:V4SI
25659 (match_operand:V2SI 1 "vector_operand" "Yrja, *xja, vm")
25660 (match_operand:V2SI 2 "const0_operand"))
25661 (match_operand:V4SI 3 "const0_operand"))
25662 (match_parallel 4 "pmovzx_parallel"
25663 [(match_operand 5 "const_int_operand")])))]
25664 "TARGET_SSE4_1"
25665 "#"
25666 "&& reload_completed"
25667 [(set (match_dup 0)
25668 (zero_extend:V2DI
25669 (vec_select:V2SI (match_dup 1)
25670 (parallel [(const_int 0) (const_int 1)]))))]
25671 {
25672 operands[0] = lowpart_subreg (V2DImode, operands[0], V4SImode);
25673 if (MEM_P (operands[1]))
25674 {
25675 operands[1] = gen_rtx_ZERO_EXTEND (V2DImode, operands[1]);
25676 emit_insn (gen_rtx_SET (operands[0], operands[1]));
25677 DONE;
25678 }
25679 operands[1] = lowpart_subreg (V4SImode, operands[1], V2SImode);
25680 }
25681 [(set_attr "isa" "noavx,noavx,avx")
25682 (set_attr "addr" "gpr16,gpr16,*")])
25683
25684 (define_expand "<insn>v2siv2di2"
25685 [(set (match_operand:V2DI 0 "register_operand")
25686 (any_extend:V2DI
25687 (match_operand:V2SI 1 "nonimmediate_operand")))]
25688 "TARGET_SSE4_1 || TARGET_MMX_WITH_SSE"
25689 {
25690 if (!TARGET_SSE4_1)
25691 {
25692 ix86_expand_sse_extend (operands[0], operands[1], <u_bool>);
25693 DONE;
25694 }
25695
25696 if (!MEM_P (operands[1]))
25697 {
25698 rtx op1 = force_reg (V2SImode, operands[1]);
25699 op1 = lowpart_subreg (V4SImode, op1, V2SImode);
25700 emit_insn (gen_sse4_1_<code>v2siv2di2 (operands[0], op1));
25701 DONE;
25702 }
25703 })
25704
25705 ;; ptestps/ptestpd are very similar to comiss and ucomiss when
25706 ;; setting FLAGS_REG. But it is not a really compare instruction.
25707 (define_insn "avx_vtest<ssemodesuffix><avxsizesuffix>"
25708 [(set (reg:CC FLAGS_REG)
25709 (unspec:CC [(match_operand:VF_128_256 0 "register_operand" "x")
25710 (match_operand:VF_128_256 1 "nonimmediate_operand" "xjm")]
25711 UNSPEC_VTESTP))]
25712 "TARGET_AVX"
25713 "vtest<ssemodesuffix>\t{%1, %0|%0, %1}"
25714 [(set_attr "type" "ssecomi")
25715 (set_attr "addr" "gpr16")
25716 (set_attr "prefix_extra" "1")
25717 (set_attr "prefix" "vex")
25718 (set_attr "mode" "<MODE>")])
25719
25720 ;; ptest is very similar to comiss and ucomiss when setting FLAGS_REG.
25721 ;; But it is not really a compare instruction.
25722 (define_insn "*<sse4_1>_ptest<mode>"
25723 [(set (reg FLAGS_REG)
25724 (unspec [(match_operand:V_AVX 0 "register_operand" "Yr, *x, x")
25725 (match_operand:V_AVX 1 "vector_operand" "Yrja, *xja, xjm")]
25726 UNSPEC_PTEST))]
25727 "TARGET_SSE4_1 && ix86_match_ptest_ccmode (insn)"
25728 "%vptest\t{%1, %0|%0, %1}"
25729 [(set_attr "isa" "noavx,noavx,avx")
25730 (set_attr "type" "ssecomi")
25731 (set_attr "addr" "gpr16")
25732 (set_attr "prefix_extra" "1")
25733 (set_attr "prefix" "orig,orig,vex")
25734 (set (attr "btver2_decode")
25735 (if_then_else
25736 (match_test "<sseinsnmode>mode==OImode")
25737 (const_string "vector")
25738 (const_string "*")))
25739 (set_attr "mode" "<sseinsnmode>")])
25740
25741 ;; Expand a ptest to set the Z flag.
25742 (define_expand "<sse4_1>_ptestz<mode>"
25743 [(set (reg:CCZ FLAGS_REG)
25744 (unspec:CCZ [(match_operand:V_AVX 0 "register_operand")
25745 (match_operand:V_AVX 1 "vector_operand")]
25746 UNSPEC_PTEST))]
25747 "TARGET_SSE4_1")
25748
25749 ;; Expand a ptest to set the C flag
25750 (define_expand "<sse4_1>_ptestc<mode>"
25751 [(set (reg:CCC FLAGS_REG)
25752 (unspec:CCC [(match_operand:V_AVX 0 "register_operand")
25753 (match_operand:V_AVX 1 "vector_operand")]
25754 UNSPEC_PTEST))]
25755 "TARGET_SSE4_1")
25756
25757 ;; Expand a ptest to set both the Z and C flags
25758 (define_expand "<sse4_1>_ptest<mode>"
25759 [(set (reg:CC FLAGS_REG)
25760 (unspec:CC [(match_operand:V_AVX 0 "register_operand")
25761 (match_operand:V_AVX 1 "vector_operand")]
25762 UNSPEC_PTEST))]
25763 "TARGET_SSE4_1")
25764
25765 (define_insn "ptesttf2"
25766 [(set (reg:CC FLAGS_REG)
25767 (unspec:CC [(match_operand:TF 0 "register_operand" "Yr, *x, x")
25768 (match_operand:TF 1 "vector_operand" "Yrja, *xja, xjm")]
25769 UNSPEC_PTEST))]
25770 "TARGET_SSE4_1"
25771 "%vptest\t{%1, %0|%0, %1}"
25772 [(set_attr "isa" "noavx,noavx,avx")
25773 (set_attr "type" "ssecomi")
25774 (set_attr "addr" "gpr16")
25775 (set_attr "prefix_extra" "1")
25776 (set_attr "prefix" "orig,orig,vex")
25777 (set_attr "mode" "TI")])
25778
25779 (define_insn_and_split "*ptest<mode>_and"
25780 [(set (reg:CCZ FLAGS_REG)
25781 (unspec:CCZ [(and:V_AVX (match_operand:V_AVX 0 "register_operand")
25782 (match_operand:V_AVX 1 "vector_operand"))
25783 (and:V_AVX (match_dup 0) (match_dup 1))]
25784 UNSPEC_PTEST))]
25785 "TARGET_SSE4_1
25786 && ix86_pre_reload_split ()"
25787 "#"
25788 "&& 1"
25789 [(set (reg:CCZ FLAGS_REG)
25790 (unspec:CCZ [(match_dup 0) (match_dup 1)] UNSPEC_PTEST))])
25791
25792 ;; ptest reg,reg sets the carry flag.
25793 (define_split
25794 [(set (reg:CCC FLAGS_REG)
25795 (unspec:CCC [(match_operand:V_AVX 0 "register_operand")
25796 (match_operand:V_AVX 1 "register_operand")]
25797 UNSPEC_PTEST))]
25798 "TARGET_SSE4_1
25799 && rtx_equal_p (operands[0], operands[1])"
25800 [(set (reg:CCC FLAGS_REG)
25801 (unspec:CCC [(const_int 0)] UNSPEC_STC))])
25802
25803 ;; Changing the CCmode of FLAGS_REG requires updating both def and use.
25804 ;; pandn/ptestz/set{n?}e -> ptestc/set{n?}c
25805 (define_split
25806 [(set (match_operand:SWI 0 "register_operand")
25807 (match_operator:SWI 3 "bt_comparison_operator"
25808 [(unspec:CCZ [
25809 (and:V_AVX (not:V_AVX (match_operand:V_AVX 1 "register_operand"))
25810 (match_operand:V_AVX 2 "register_operand"))
25811 (and:V_AVX (not:V_AVX (match_dup 1)) (match_dup 2))]
25812 UNSPEC_PTEST)
25813 (const_int 0)]))]
25814 "TARGET_SSE4_1"
25815 [(set (reg:CCC FLAGS_REG)
25816 (unspec:CCC [(match_dup 1) (match_dup 2)] UNSPEC_PTEST))
25817 (set (match_dup 0)
25818 (match_op_dup 3 [(reg:CCC FLAGS_REG) (const_int 0)]))])
25819
25820 (define_split
25821 [(set (strict_low_part (match_operand:QI 0 "register_operand"))
25822 (match_operator:QI 3 "bt_comparison_operator"
25823 [(unspec:CCZ [
25824 (and:V_AVX (not:V_AVX (match_operand:V_AVX 1 "register_operand"))
25825 (match_operand:V_AVX 2 "register_operand"))
25826 (and:V_AVX (not:V_AVX (match_dup 1)) (match_dup 2))]
25827 UNSPEC_PTEST)
25828 (const_int 0)]))]
25829 "TARGET_SSE4_1"
25830 [(set (reg:CCC FLAGS_REG)
25831 (unspec:CCC [(match_dup 1) (match_dup 2)] UNSPEC_PTEST))
25832 (set (strict_low_part (match_dup 0))
25833 (match_op_dup 3 [(reg:CCC FLAGS_REG) (const_int 0)]))])
25834
25835 ;; pandn/ptestz/j{n?}e -> ptestc/j{n?}c
25836 (define_split
25837 [(set (pc)
25838 (if_then_else
25839 (match_operator 3 "bt_comparison_operator"
25840 [(unspec:CCZ [
25841 (and:V_AVX
25842 (not:V_AVX (match_operand:V_AVX 1 "register_operand"))
25843 (match_operand:V_AVX 2 "register_operand"))
25844 (and:V_AVX (not:V_AVX (match_dup 1)) (match_dup 2))]
25845 UNSPEC_PTEST)
25846 (const_int 0)])
25847 (match_operand 0)
25848 (pc)))]
25849 "TARGET_SSE4_1"
25850 [(set (reg:CCC FLAGS_REG)
25851 (unspec:CCC [(match_dup 1) (match_dup 2)] UNSPEC_PTEST))
25852 (set (pc) (if_then_else (match_op_dup 3 [(reg:CCC FLAGS_REG) (const_int 0)])
25853 (match_dup 0)
25854 (pc)))])
25855
25856 (define_expand "nearbyint<mode>2"
25857 [(set (match_operand:VFH 0 "register_operand")
25858 (unspec:VFH
25859 [(match_operand:VFH 1 "vector_operand")
25860 (match_dup 2)]
25861 UNSPEC_ROUND))]
25862 "TARGET_SSE4_1"
25863 "operands[2] = GEN_INT (ROUND_MXCSR | ROUND_NO_EXC);")
25864
25865 (define_expand "rint<mode>2"
25866 [(set (match_operand:VFH 0 "register_operand")
25867 (unspec:VFH
25868 [(match_operand:VFH 1 "vector_operand")
25869 (match_dup 2)]
25870 UNSPEC_ROUND))]
25871 "TARGET_SSE4_1"
25872 "operands[2] = GEN_INT (ROUND_MXCSR);")
25873
25874 ;; Note vcvtpd2qq require avx512dq for all vector lengths.
25875 (define_expand "lrint<mode><sseintvecmodelower>2"
25876 [(set (match_operand:<sseintvecmode> 0 "register_operand")
25877 (unspec:<sseintvecmode>
25878 [(match_operand:VF1_VF2_AVX512DQ 1 "register_operand")]
25879 UNSPEC_FIX_NOTRUNC))]
25880 "TARGET_SSE2")
25881
25882 (define_insn "<sse4_1>_round<ssemodesuffix><avxsizesuffix>"
25883 [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
25884 (unspec:VF_128_256
25885 [(match_operand:VF_128_256 1 "vector_operand" "Yrja,*xja,xjm")
25886 (match_operand:SI 2 "const_0_to_15_operand")]
25887 UNSPEC_ROUND))]
25888 "TARGET_SSE4_1"
25889 "%vround<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
25890 [(set_attr "isa" "noavx,noavx,avx")
25891 (set_attr "type" "ssecvt")
25892 (set_attr "addr" "gpr16")
25893 (set_attr "prefix_data16" "1,1,*")
25894 (set_attr "prefix_extra" "1")
25895 (set_attr "length_immediate" "1")
25896 (set_attr "prefix" "orig,orig,vex")
25897 (set_attr "mode" "<MODE>")])
25898
25899 (define_expand "<sse4_1>_round<ssemodesuffix>_sfix<avxsizesuffix>"
25900 [(match_operand:<sseintvecmode> 0 "register_operand")
25901 (match_operand:VF1_128_256 1 "vector_operand")
25902 (match_operand:SI 2 "const_0_to_15_operand")]
25903 "TARGET_SSE4_1"
25904 {
25905 rtx tmp = gen_reg_rtx (<MODE>mode);
25906
25907 emit_insn
25908 (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp, operands[1],
25909 operands[2]));
25910 emit_insn
25911 (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
25912 DONE;
25913 })
25914
25915 (define_expand "avx512f_round<castmode>512"
25916 [(match_operand:VF_512 0 "register_operand")
25917 (match_operand:VF_512 1 "nonimmediate_operand")
25918 (match_operand:SI 2 "const_0_to_15_operand")]
25919 "TARGET_AVX512F"
25920 {
25921 emit_insn (gen_avx512f_rndscale<mode> (operands[0], operands[1], operands[2]));
25922 DONE;
25923 })
25924
25925 (define_expand "avx512f_roundps512_sfix"
25926 [(match_operand:V16SI 0 "register_operand")
25927 (match_operand:V16SF 1 "nonimmediate_operand")
25928 (match_operand:SI 2 "const_0_to_15_operand")]
25929 "TARGET_AVX512F && TARGET_EVEX512"
25930 {
25931 rtx tmp = gen_reg_rtx (V16SFmode);
25932 emit_insn (gen_avx512f_rndscalev16sf (tmp, operands[1], operands[2]));
25933 emit_insn (gen_fix_truncv16sfv16si2 (operands[0], tmp));
25934 DONE;
25935 })
25936
25937 (define_expand "<sse4_1>_round<ssemodesuffix>_vec_pack_sfix<avxsizesuffix>"
25938 [(match_operand:<ssepackfltmode> 0 "register_operand")
25939 (match_operand:VF2 1 "vector_operand")
25940 (match_operand:VF2 2 "vector_operand")
25941 (match_operand:SI 3 "const_0_to_15_operand")]
25942 "TARGET_SSE4_1"
25943 {
25944 rtx tmp0, tmp1;
25945
25946 if (<MODE>mode == V2DFmode
25947 && TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
25948 {
25949 rtx tmp2 = gen_reg_rtx (V4DFmode);
25950
25951 tmp0 = gen_reg_rtx (V4DFmode);
25952 tmp1 = force_reg (V2DFmode, operands[1]);
25953
25954 emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
25955 emit_insn (gen_avx_roundpd256 (tmp2, tmp0, operands[3]));
25956 emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp2));
25957 }
25958 else
25959 {
25960 tmp0 = gen_reg_rtx (<MODE>mode);
25961 tmp1 = gen_reg_rtx (<MODE>mode);
25962
25963 emit_insn
25964 (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp0, operands[1],
25965 operands[3]));
25966 emit_insn
25967 (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp1, operands[2],
25968 operands[3]));
25969 emit_insn
25970 (gen_vec_pack_sfix_trunc_<mode> (operands[0], tmp0, tmp1));
25971 }
25972 DONE;
25973 })
25974
25975 (define_insn "sse4_1_round<ssescalarmodesuffix>"
25976 [(set (match_operand:VFH_128 0 "register_operand" "=Yr,*x,x,v")
25977 (vec_merge:VFH_128
25978 (unspec:VFH_128
25979 [(match_operand:VFH_128 2 "nonimmediate_operand" "Yrjm,*xjm,xjm,vm")
25980 (match_operand:SI 3 "const_0_to_15_operand")]
25981 UNSPEC_ROUND)
25982 (match_operand:VFH_128 1 "register_operand" "0,0,x,v")
25983 (const_int 1)))]
25984 "TARGET_SSE4_1"
25985 {
25986 switch (which_alternative)
25987 {
25988 case 0:
25989 case 1:
25990 return "round<ssescalarmodesuffix>\t{%3, %2, %0|%0, %<iptr>2, %3}";
25991 case 2:
25992 return "vround<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %3}";
25993 case 3:
25994 if (x86_evex_reg_mentioned_p (operands, 3) || <MODE>mode == V8HFmode)
25995 return "vrndscale<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %3}";
25996 else
25997 return "vround<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %3}";
25998 default:
25999 gcc_unreachable ();
26000 }
26001 }
26002 [(set_attr "isa" "noavx,noavx,noavx512f,avx512f")
26003 (set_attr "type" "ssecvt")
26004 (set_attr "c86_attr" "aes")
26005 (set_attr "addr" "gpr16,gpr16,gpr16,*")
26006 (set_attr "length_immediate" "1")
26007 (set_attr "prefix_data16" "1,1,*,*")
26008 (set_attr "prefix_extra" "1")
26009 (set_attr "prefix" "orig,orig,vex,evex")
26010 (set_attr "mode" "<MODE>")])
26011
26012 (define_insn "*sse4_1_round<ssescalarmodesuffix>"
26013 [(set (match_operand:VFH_128 0 "register_operand" "=Yr,*x,x,v")
26014 (vec_merge:VFH_128
26015 (vec_duplicate:VFH_128
26016 (unspec:<ssescalarmode>
26017 [(match_operand:<ssescalarmode> 2 "nonimmediate_operand" "Yrjm,*xjm,xjm,vm")
26018 (match_operand:SI 3 "const_0_to_15_operand")]
26019 UNSPEC_ROUND))
26020 (match_operand:VFH_128 1 "register_operand" "0,0,x,v")
26021 (const_int 1)))]
26022 "TARGET_SSE4_1"
26023 {
26024 switch (which_alternative)
26025 {
26026 case 0:
26027 case 1:
26028 return "round<ssescalarmodesuffix>\t{%3, %2, %0|%0, %2, %3}";
26029 case 2:
26030 return "vround<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
26031 case 3:
26032 if (x86_evex_reg_mentioned_p (operands, 3) || <MODE>mode == V8HFmode)
26033 return "vrndscale<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
26034 else
26035 return "vround<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
26036 default:
26037 gcc_unreachable ();
26038 }
26039 }
26040 [(set_attr "isa" "noavx,noavx,noavx512f,avx512f")
26041 (set_attr "type" "ssecvt")
26042 (set_attr "c86_attr" "aes")
26043 (set_attr "addr" "gpr16,gpr16,gpr16,*")
26044 (set_attr "length_immediate" "1")
26045 (set_attr "prefix_data16" "1,1,*,*")
26046 (set_attr "prefix_extra" "1")
26047 (set_attr "prefix" "orig,orig,vex,evex")
26048 (set_attr "mode" "<MODE>")])
26049
26050 (define_expand "floor<mode>2"
26051 [(set (match_operand:VFH 0 "register_operand")
26052 (unspec:VFH
26053 [(match_operand:VFH 1 "vector_operand")
26054 (match_dup 2)]
26055 UNSPEC_ROUND))]
26056 "TARGET_SSE4_1 && !flag_trapping_math"
26057 "operands[2] = GEN_INT (ROUND_FLOOR | ROUND_NO_EXC);")
26058
26059 (define_expand "lfloor<mode><sseintvecmodelower>2"
26060 [(match_operand:<sseintvecmode> 0 "register_operand")
26061 (match_operand:VHF_AVX512VL 1 "nonimmediate_operand")]
26062 "TARGET_AVX512FP16 && !flag_trapping_math"
26063 {
26064 rtx tmp = gen_reg_rtx (<MODE>mode);
26065 emit_insn (gen_floor<mode>2 (tmp, operands[1]));
26066 emit_insn (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
26067 DONE;
26068 })
26069
26070 (define_expand "lfloor<mode><sseintvecmodelower>2"
26071 [(match_operand:<sseintvecmode> 0 "register_operand")
26072 (match_operand:VF1_VF2_AVX512DQ 1 "register_operand")]
26073 "TARGET_SSE4_1 && !flag_trapping_math"
26074 {
26075 rtx tmp = gen_reg_rtx (<MODE>mode);
26076 emit_insn (gen_floor<mode>2 (tmp, operands[1]));
26077 emit_insn (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
26078 DONE;
26079 })
26080
26081 (define_expand "ceil<mode>2"
26082 [(set (match_operand:VFH 0 "register_operand")
26083 (unspec:VFH
26084 [(match_operand:VFH 1 "vector_operand")
26085 (match_dup 2)]
26086 UNSPEC_ROUND))]
26087 "TARGET_SSE4_1 && !flag_trapping_math"
26088 "operands[2] = GEN_INT (ROUND_CEIL | ROUND_NO_EXC);")
26089
26090 (define_expand "lceil<mode><sseintvecmodelower>2"
26091 [(match_operand:<sseintvecmode> 0 "register_operand")
26092 (match_operand:VHF_AVX512VL 1 "register_operand")]
26093 "TARGET_AVX512FP16 && !flag_trapping_math"
26094 {
26095 rtx tmp = gen_reg_rtx (<MODE>mode);
26096 emit_insn (gen_ceil<mode>2 (tmp, operands[1]));
26097 emit_insn (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
26098 DONE;
26099 })
26100
26101 (define_expand "lceil<mode><sseintvecmodelower>2"
26102 [(match_operand:<sseintvecmode> 0 "register_operand")
26103 (match_operand:VF1_VF2_AVX512DQ 1 "register_operand")]
26104 "TARGET_SSE4_1 && !flag_trapping_math"
26105 {
26106 rtx tmp = gen_reg_rtx (<MODE>mode);
26107 emit_insn (gen_ceil<mode>2 (tmp, operands[1]));
26108 emit_insn (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
26109 DONE;
26110 })
26111
26112 (define_expand "btrunc<mode>2"
26113 [(set (match_operand:VFH 0 "register_operand")
26114 (unspec:VFH
26115 [(match_operand:VFH 1 "vector_operand")
26116 (match_dup 2)]
26117 UNSPEC_ROUND))]
26118 "TARGET_SSE4_1 && !flag_trapping_math"
26119 "operands[2] = GEN_INT (ROUND_TRUNC | ROUND_NO_EXC);")
26120
26121 (define_expand "round<mode>2"
26122 [(set (match_dup 3)
26123 (plus:VFH
26124 (match_operand:VFH 1 "register_operand")
26125 (match_dup 2)))
26126 (set (match_operand:VFH 0 "register_operand")
26127 (unspec:VFH
26128 [(match_dup 3) (match_dup 4)]
26129 UNSPEC_ROUND))]
26130 "TARGET_SSE4_1 && !flag_trapping_math"
26131 {
26132 machine_mode scalar_mode;
26133 const struct real_format *fmt;
26134 REAL_VALUE_TYPE pred_half, half_minus_pred_half;
26135 rtx half, vec_half;
26136
26137 scalar_mode = GET_MODE_INNER (<MODE>mode);
26138
26139 /* load nextafter (0.5, 0.0) */
26140 fmt = REAL_MODE_FORMAT (scalar_mode);
26141 real_2expN (&half_minus_pred_half, -(fmt->p) - 1, scalar_mode);
26142 real_arithmetic (&pred_half, MINUS_EXPR, &dconsthalf, &half_minus_pred_half);
26143 half = const_double_from_real_value (pred_half, scalar_mode);
26144
26145 vec_half = ix86_build_const_vector (<MODE>mode, true, half);
26146 vec_half = force_reg (<MODE>mode, vec_half);
26147
26148 operands[2] = gen_reg_rtx (<MODE>mode);
26149 emit_insn (gen_copysign<mode>3 (operands[2], vec_half, operands[1]));
26150
26151 operands[3] = gen_reg_rtx (<MODE>mode);
26152 operands[4] = GEN_INT (ROUND_TRUNC);
26153 })
26154
26155 (define_expand "lround<mode><sseintvecmodelower>2"
26156 [(match_operand:<sseintvecmode> 0 "register_operand")
26157 (match_operand:VHF_AVX512VL 1 "register_operand")]
26158 "TARGET_AVX512FP16 && !flag_trapping_math"
26159 {
26160 rtx tmp = gen_reg_rtx (<MODE>mode);
26161 emit_insn (gen_round<mode>2 (tmp, operands[1]));
26162 emit_insn (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
26163 DONE;
26164 })
26165
26166 (define_expand "lround<mode><sseintvecmodelower>2"
26167 [(match_operand:<sseintvecmode> 0 "register_operand")
26168 (match_operand:VF1_VF2_AVX512DQ 1 "register_operand")]
26169 "TARGET_SSE4_1 && !flag_trapping_math"
26170 {
26171 rtx tmp = gen_reg_rtx (<MODE>mode);
26172 emit_insn (gen_round<mode>2 (tmp, operands[1]));
26173 emit_insn (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
26174 DONE;
26175 })
26176
26177 (define_expand "round<mode>2_sfix"
26178 [(match_operand:<sseintvecmode> 0 "register_operand")
26179 (match_operand:VF1 1 "register_operand")]
26180 "TARGET_SSE4_1 && !flag_trapping_math"
26181 {
26182 rtx tmp = gen_reg_rtx (<MODE>mode);
26183
26184 emit_insn (gen_round<mode>2 (tmp, operands[1]));
26185
26186 emit_insn
26187 (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
26188 DONE;
26189 })
26190
26191 (define_expand "round<mode>2_vec_pack_sfix"
26192 [(match_operand:<ssepackfltmode> 0 "register_operand")
26193 (match_operand:VF2 1 "register_operand")
26194 (match_operand:VF2 2 "register_operand")]
26195 "TARGET_SSE4_1 && !flag_trapping_math"
26196 {
26197 rtx tmp0, tmp1;
26198
26199 if (<MODE>mode == V2DFmode
26200 && TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
26201 {
26202 rtx tmp2 = gen_reg_rtx (V4DFmode);
26203
26204 tmp0 = gen_reg_rtx (V4DFmode);
26205 tmp1 = force_reg (V2DFmode, operands[1]);
26206
26207 emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
26208 emit_insn (gen_roundv4df2 (tmp2, tmp0));
26209 emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp2));
26210 }
26211 else
26212 {
26213 tmp0 = gen_reg_rtx (<MODE>mode);
26214 tmp1 = gen_reg_rtx (<MODE>mode);
26215
26216 emit_insn (gen_round<mode>2 (tmp0, operands[1]));
26217 emit_insn (gen_round<mode>2 (tmp1, operands[2]));
26218
26219 emit_insn
26220 (gen_vec_pack_sfix_trunc_<mode> (operands[0], tmp0, tmp1));
26221 }
26222 DONE;
26223 })
26224
26225 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26226 ;;
26227 ;; Intel SSE4.2 string/text processing instructions
26228 ;;
26229 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26230
26231 (define_insn_and_split "sse4_2_pcmpestr"
26232 [(set (match_operand:SI 0 "register_operand" "=c,c")
26233 (unspec:SI
26234 [(match_operand:V16QI 2 "register_operand" "x,x")
26235 (match_operand:SI 3 "register_operand" "a,a")
26236 (match_operand:V16QI 4 "nonimmediate_operand" "x,m")
26237 (match_operand:SI 5 "register_operand" "d,d")
26238 (match_operand:SI 6 "const_0_to_255_operand")]
26239 UNSPEC_PCMPESTR))
26240 (set (match_operand:V16QI 1 "register_operand" "=Yz,Yz")
26241 (unspec:V16QI
26242 [(match_dup 2)
26243 (match_dup 3)
26244 (match_dup 4)
26245 (match_dup 5)
26246 (match_dup 6)]
26247 UNSPEC_PCMPESTR))
26248 (set (reg:CC FLAGS_REG)
26249 (unspec:CC
26250 [(match_dup 2)
26251 (match_dup 3)
26252 (match_dup 4)
26253 (match_dup 5)
26254 (match_dup 6)]
26255 UNSPEC_PCMPESTR))]
26256 "TARGET_SSE4_2
26257 && ix86_pre_reload_split ()"
26258 "#"
26259 "&& 1"
26260 [(const_int 0)]
26261 {
26262 int ecx = !find_regno_note (curr_insn, REG_UNUSED,
26263 reg_or_subregno (operands[0]));
26264 int xmm0 = !find_regno_note (curr_insn, REG_UNUSED,
26265 reg_or_subregno (operands[1]));
26266 int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
26267
26268 if (ecx)
26269 emit_insn (gen_sse4_2_pcmpestri (operands[0], operands[2],
26270 operands[3], operands[4],
26271 operands[5], operands[6]));
26272 if (xmm0)
26273 emit_insn (gen_sse4_2_pcmpestrm (operands[1], operands[2],
26274 operands[3], operands[4],
26275 operands[5], operands[6]));
26276 if (flags && !(ecx || xmm0))
26277 emit_insn (gen_sse4_2_pcmpestr_cconly (NULL, NULL,
26278 operands[2], operands[3],
26279 operands[4], operands[5],
26280 operands[6]));
26281 if (!(flags || ecx || xmm0))
26282 emit_note (NOTE_INSN_DELETED);
26283
26284 DONE;
26285 }
26286 [(set_attr "type" "sselog")
26287 (set_attr "prefix_extra" "1")
26288 (set_attr "length_immediate" "1")
26289 (set_attr "memory" "none,load")
26290 (set_attr "mode" "TI")])
26291
26292 (define_insn "sse4_2_pcmpestri"
26293 [(set (match_operand:SI 0 "register_operand" "=c,c")
26294 (unspec:SI
26295 [(match_operand:V16QI 1 "register_operand" "x,x")
26296 (match_operand:SI 2 "register_operand" "a,a")
26297 (match_operand:V16QI 3 "nonimmediate_operand" "x,jm")
26298 (match_operand:SI 4 "register_operand" "d,d")
26299 (match_operand:SI 5 "const_0_to_255_operand")]
26300 UNSPEC_PCMPESTR))
26301 (set (reg:CC FLAGS_REG)
26302 (unspec:CC
26303 [(match_dup 1)
26304 (match_dup 2)
26305 (match_dup 3)
26306 (match_dup 4)
26307 (match_dup 5)]
26308 UNSPEC_PCMPESTR))]
26309 "TARGET_SSE4_2"
26310 "%vpcmpestri\t{%5, %3, %1|%1, %3, %5}"
26311 [(set_attr "type" "sselog")
26312 (set_attr "c86_attr" "cmpestr")
26313 (set_attr "addr" "gpr16")
26314 (set_attr "prefix_extra" "1")
26315 (set_attr "prefix" "maybe_vex")
26316 (set_attr "length_immediate" "1")
26317 (set_attr "btver2_decode" "vector")
26318 (set_attr "memory" "none,load")
26319 (set_attr "mode" "TI")])
26320
26321 (define_insn "sse4_2_pcmpestrm"
26322 [(set (match_operand:V16QI 0 "register_operand" "=Yz,Yz")
26323 (unspec:V16QI
26324 [(match_operand:V16QI 1 "register_operand" "x,x")
26325 (match_operand:SI 2 "register_operand" "a,a")
26326 (match_operand:V16QI 3 "nonimmediate_operand" "x,jm")
26327 (match_operand:SI 4 "register_operand" "d,d")
26328 (match_operand:SI 5 "const_0_to_255_operand")]
26329 UNSPEC_PCMPESTR))
26330 (set (reg:CC FLAGS_REG)
26331 (unspec:CC
26332 [(match_dup 1)
26333 (match_dup 2)
26334 (match_dup 3)
26335 (match_dup 4)
26336 (match_dup 5)]
26337 UNSPEC_PCMPESTR))]
26338 "TARGET_SSE4_2"
26339 "%vpcmpestrm\t{%5, %3, %1|%1, %3, %5}"
26340 [(set_attr "type" "sselog")
26341 (set_attr "c86_attr" "cmpestr")
26342 (set_attr "addr" "gpr16")
26343 (set_attr "prefix_extra" "1")
26344 (set_attr "length_immediate" "1")
26345 (set_attr "prefix" "maybe_vex")
26346 (set_attr "btver2_decode" "vector")
26347 (set_attr "memory" "none,load")
26348 (set_attr "mode" "TI")])
26349
26350 (define_insn "sse4_2_pcmpestr_cconly"
26351 [(set (reg:CC FLAGS_REG)
26352 (unspec:CC
26353 [(match_operand:V16QI 2 "register_operand" "x,x,x,x")
26354 (match_operand:SI 3 "register_operand" "a,a,a,a")
26355 (match_operand:V16QI 4 "nonimmediate_operand" "x,jm,x,jm")
26356 (match_operand:SI 5 "register_operand" "d,d,d,d")
26357 (match_operand:SI 6 "const_0_to_255_operand")]
26358 UNSPEC_PCMPESTR))
26359 (clobber (match_scratch:V16QI 0 "=Yz,Yz,X,X"))
26360 (clobber (match_scratch:SI 1 "= X, X,c,c"))]
26361 "TARGET_SSE4_2"
26362 "@
26363 %vpcmpestrm\t{%6, %4, %2|%2, %4, %6}
26364 %vpcmpestrm\t{%6, %4, %2|%2, %4, %6}
26365 %vpcmpestri\t{%6, %4, %2|%2, %4, %6}
26366 %vpcmpestri\t{%6, %4, %2|%2, %4, %6}"
26367 [(set_attr "type" "sselog")
26368 (set_attr "c86_attr" "cmpestr")
26369 (set_attr "addr" "gpr16")
26370 (set_attr "prefix_extra" "1")
26371 (set_attr "length_immediate" "1")
26372 (set_attr "memory" "none,load,none,load")
26373 (set_attr "btver2_decode" "vector,vector,vector,vector")
26374 (set_attr "prefix" "maybe_vex")
26375 (set_attr "mode" "TI")])
26376
26377 (define_insn_and_split "sse4_2_pcmpistr"
26378 [(set (match_operand:SI 0 "register_operand" "=c,c")
26379 (unspec:SI
26380 [(match_operand:V16QI 2 "register_operand" "x,x")
26381 (match_operand:V16QI 3 "nonimmediate_operand" "x,jm")
26382 (match_operand:SI 4 "const_0_to_255_operand")]
26383 UNSPEC_PCMPISTR))
26384 (set (match_operand:V16QI 1 "register_operand" "=Yz,Yz")
26385 (unspec:V16QI
26386 [(match_dup 2)
26387 (match_dup 3)
26388 (match_dup 4)]
26389 UNSPEC_PCMPISTR))
26390 (set (reg:CC FLAGS_REG)
26391 (unspec:CC
26392 [(match_dup 2)
26393 (match_dup 3)
26394 (match_dup 4)]
26395 UNSPEC_PCMPISTR))]
26396 "TARGET_SSE4_2
26397 && ix86_pre_reload_split ()"
26398 "#"
26399 "&& 1"
26400 [(const_int 0)]
26401 {
26402 int ecx = !find_regno_note (curr_insn, REG_UNUSED,
26403 reg_or_subregno (operands[0]));
26404 int xmm0 = !find_regno_note (curr_insn, REG_UNUSED,
26405 reg_or_subregno (operands[1]));
26406 int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
26407
26408 if (ecx)
26409 emit_insn (gen_sse4_2_pcmpistri (operands[0], operands[2],
26410 operands[3], operands[4]));
26411 if (xmm0)
26412 emit_insn (gen_sse4_2_pcmpistrm (operands[1], operands[2],
26413 operands[3], operands[4]));
26414 if (flags && !(ecx || xmm0))
26415 emit_insn (gen_sse4_2_pcmpistr_cconly (NULL, NULL,
26416 operands[2], operands[3],
26417 operands[4]));
26418 if (!(flags || ecx || xmm0))
26419 emit_note (NOTE_INSN_DELETED);
26420
26421 DONE;
26422 }
26423 [(set_attr "type" "sselog")
26424 (set_attr "addr" "gpr16")
26425 (set_attr "prefix_extra" "1")
26426 (set_attr "length_immediate" "1")
26427 (set_attr "memory" "none,load")
26428 (set_attr "mode" "TI")])
26429
26430 (define_insn "sse4_2_pcmpistri"
26431 [(set (match_operand:SI 0 "register_operand" "=c,c")
26432 (unspec:SI
26433 [(match_operand:V16QI 1 "register_operand" "x,x")
26434 (match_operand:V16QI 2 "nonimmediate_operand" "x,jm")
26435 (match_operand:SI 3 "const_0_to_255_operand")]
26436 UNSPEC_PCMPISTR))
26437 (set (reg:CC FLAGS_REG)
26438 (unspec:CC
26439 [(match_dup 1)
26440 (match_dup 2)
26441 (match_dup 3)]
26442 UNSPEC_PCMPISTR))]
26443 "TARGET_SSE4_2"
26444 "%vpcmpistri\t{%3, %2, %1|%1, %2, %3}"
26445 [(set_attr "type" "sselog")
26446 (set_attr "c86_attr" "cmpestr")
26447 (set_attr "addr" "gpr16")
26448 (set_attr "prefix_extra" "1")
26449 (set_attr "length_immediate" "1")
26450 (set_attr "prefix" "maybe_vex")
26451 (set_attr "memory" "none,load")
26452 (set_attr "btver2_decode" "vector")
26453 (set_attr "mode" "TI")])
26454
26455 (define_insn "sse4_2_pcmpistrm"
26456 [(set (match_operand:V16QI 0 "register_operand" "=Yz,Yz")
26457 (unspec:V16QI
26458 [(match_operand:V16QI 1 "register_operand" "x,x")
26459 (match_operand:V16QI 2 "nonimmediate_operand" "x,jm")
26460 (match_operand:SI 3 "const_0_to_255_operand")]
26461 UNSPEC_PCMPISTR))
26462 (set (reg:CC FLAGS_REG)
26463 (unspec:CC
26464 [(match_dup 1)
26465 (match_dup 2)
26466 (match_dup 3)]
26467 UNSPEC_PCMPISTR))]
26468 "TARGET_SSE4_2"
26469 "%vpcmpistrm\t{%3, %2, %1|%1, %2, %3}"
26470 [(set_attr "type" "sselog")
26471 (set_attr "c86_attr" "cmpestr")
26472 (set_attr "addr" "gpr16")
26473 (set_attr "prefix_extra" "1")
26474 (set_attr "length_immediate" "1")
26475 (set_attr "prefix" "maybe_vex")
26476 (set_attr "memory" "none,load")
26477 (set_attr "btver2_decode" "vector")
26478 (set_attr "mode" "TI")])
26479
26480 (define_insn "sse4_2_pcmpistr_cconly"
26481 [(set (reg:CC FLAGS_REG)
26482 (unspec:CC
26483 [(match_operand:V16QI 2 "register_operand" "x,x,x,x")
26484 (match_operand:V16QI 3 "nonimmediate_operand" "x,jm,x,jm")
26485 (match_operand:SI 4 "const_0_to_255_operand")]
26486 UNSPEC_PCMPISTR))
26487 (clobber (match_scratch:V16QI 0 "=Yz,Yz,X,X"))
26488 (clobber (match_scratch:SI 1 "= X, X,c,c"))]
26489 "TARGET_SSE4_2"
26490 "@
26491 %vpcmpistrm\t{%4, %3, %2|%2, %3, %4}
26492 %vpcmpistrm\t{%4, %3, %2|%2, %3, %4}
26493 %vpcmpistri\t{%4, %3, %2|%2, %3, %4}
26494 %vpcmpistri\t{%4, %3, %2|%2, %3, %4}"
26495 [(set_attr "type" "sselog")
26496 (set_attr "c86_attr" "cmpestr")
26497 (set_attr "addr" "gpr16")
26498 (set_attr "prefix_extra" "1")
26499 (set_attr "length_immediate" "1")
26500 (set_attr "memory" "none,load,none,load")
26501 (set_attr "prefix" "maybe_vex")
26502 (set_attr "btver2_decode" "vector,vector,vector,vector")
26503 (set_attr "mode" "TI")])
26504
26505 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26506 ;;
26507 ;; XOP instructions
26508 ;;
26509 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26510
26511 (define_code_iterator xop_plus [plus ss_plus])
26512
26513 (define_code_attr macs [(plus "macs") (ss_plus "macss")])
26514 (define_code_attr madcs [(plus "madcs") (ss_plus "madcss")])
26515
26516 ;; XOP parallel integer multiply/add instructions.
26517
26518 (define_insn "xop_p<macs><ssemodesuffix><ssemodesuffix>"
26519 [(set (match_operand:VI24_128 0 "register_operand" "=x")
26520 (xop_plus:VI24_128
26521 (mult:VI24_128
26522 (match_operand:VI24_128 1 "nonimmediate_operand" "%x")
26523 (match_operand:VI24_128 2 "nonimmediate_operand" "xm"))
26524 (match_operand:VI24_128 3 "register_operand" "x")))]
26525 "TARGET_XOP"
26526 "vp<macs><ssemodesuffix><ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
26527 [(set_attr "type" "ssemuladd")
26528 (set_attr "prefix" "vex")
26529 (set_attr "mode" "TI")])
26530
26531 (define_insn "xop_p<macs>dql"
26532 [(set (match_operand:V2DI 0 "register_operand" "=x")
26533 (xop_plus:V2DI
26534 (mult:V2DI
26535 (sign_extend:V2DI
26536 (vec_select:V2SI
26537 (match_operand:V4SI 1 "nonimmediate_operand" "%x")
26538 (parallel [(const_int 0) (const_int 2)])))
26539 (sign_extend:V2DI
26540 (vec_select:V2SI
26541 (match_operand:V4SI 2 "nonimmediate_operand" "xm")
26542 (parallel [(const_int 0) (const_int 2)]))))
26543 (match_operand:V2DI 3 "register_operand" "x")))]
26544 "TARGET_XOP"
26545 "vp<macs>dql\t{%3, %2, %1, %0|%0, %1, %2, %3}"
26546 [(set_attr "type" "ssemuladd")
26547 (set_attr "prefix" "vex")
26548 (set_attr "mode" "TI")])
26549
26550 (define_insn "xop_p<macs>dqh"
26551 [(set (match_operand:V2DI 0 "register_operand" "=x")
26552 (xop_plus:V2DI
26553 (mult:V2DI
26554 (sign_extend:V2DI
26555 (vec_select:V2SI
26556 (match_operand:V4SI 1 "nonimmediate_operand" "%x")
26557 (parallel [(const_int 1) (const_int 3)])))
26558 (sign_extend:V2DI
26559 (vec_select:V2SI
26560 (match_operand:V4SI 2 "nonimmediate_operand" "xm")
26561 (parallel [(const_int 1) (const_int 3)]))))
26562 (match_operand:V2DI 3 "register_operand" "x")))]
26563 "TARGET_XOP"
26564 "vp<macs>dqh\t{%3, %2, %1, %0|%0, %1, %2, %3}"
26565 [(set_attr "type" "ssemuladd")
26566 (set_attr "prefix" "vex")
26567 (set_attr "mode" "TI")])
26568
26569 ;; XOP parallel integer multiply/add instructions for the intrinisics
26570 (define_insn "xop_p<macs>wd"
26571 [(set (match_operand:V4SI 0 "register_operand" "=x")
26572 (xop_plus:V4SI
26573 (mult:V4SI
26574 (sign_extend:V4SI
26575 (vec_select:V4HI
26576 (match_operand:V8HI 1 "nonimmediate_operand" "%x")
26577 (parallel [(const_int 1) (const_int 3)
26578 (const_int 5) (const_int 7)])))
26579 (sign_extend:V4SI
26580 (vec_select:V4HI
26581 (match_operand:V8HI 2 "nonimmediate_operand" "xm")
26582 (parallel [(const_int 1) (const_int 3)
26583 (const_int 5) (const_int 7)]))))
26584 (match_operand:V4SI 3 "register_operand" "x")))]
26585 "TARGET_XOP"
26586 "vp<macs>wd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
26587 [(set_attr "type" "ssemuladd")
26588 (set_attr "prefix" "vex")
26589 (set_attr "mode" "TI")])
26590
26591 (define_insn "xop_p<madcs>wd"
26592 [(set (match_operand:V4SI 0 "register_operand" "=x")
26593 (xop_plus:V4SI
26594 (plus:V4SI
26595 (mult:V4SI
26596 (sign_extend:V4SI
26597 (vec_select:V4HI
26598 (match_operand:V8HI 1 "nonimmediate_operand" "%x")
26599 (parallel [(const_int 0) (const_int 2)
26600 (const_int 4) (const_int 6)])))
26601 (sign_extend:V4SI
26602 (vec_select:V4HI
26603 (match_operand:V8HI 2 "nonimmediate_operand" "xm")
26604 (parallel [(const_int 0) (const_int 2)
26605 (const_int 4) (const_int 6)]))))
26606 (mult:V4SI
26607 (sign_extend:V4SI
26608 (vec_select:V4HI
26609 (match_dup 1)
26610 (parallel [(const_int 1) (const_int 3)
26611 (const_int 5) (const_int 7)])))
26612 (sign_extend:V4SI
26613 (vec_select:V4HI
26614 (match_dup 2)
26615 (parallel [(const_int 1) (const_int 3)
26616 (const_int 5) (const_int 7)])))))
26617 (match_operand:V4SI 3 "register_operand" "x")))]
26618 "TARGET_XOP"
26619 "vp<madcs>wd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
26620 [(set_attr "type" "ssemuladd")
26621 (set_attr "prefix" "vex")
26622 (set_attr "mode" "TI")])
26623
26624 ;; XOP parallel XMM conditional moves
26625 (define_insn "xop_pcmov_<mode><avxsizesuffix>"
26626 [(set (match_operand:V_128_256 0 "register_operand" "=x,x")
26627 (if_then_else:V_128_256
26628 (match_operand:V_128_256 3 "nonimmediate_operand" "x,m")
26629 (match_operand:V_128_256 1 "register_operand" "x,x")
26630 (match_operand:V_128_256 2 "nonimmediate_operand" "xm,x")))]
26631 "TARGET_XOP"
26632 "vpcmov\t{%3, %2, %1, %0|%0, %1, %2, %3}"
26633 [(set_attr "type" "sse4arg")
26634 (set_attr "mode" "<sseinsnmode>")])
26635
26636 ;; Recognize XOP's vpcmov from canonical (xor (and (xor t f) c) f)
26637 (define_split
26638 [(set (match_operand:V_128_256 0 "register_operand")
26639 (xor:V_128_256
26640 (and:V_128_256
26641 (xor:V_128_256 (match_operand:V_128_256 1 "register_operand")
26642 (match_operand:V_128_256 2 "register_operand"))
26643 (match_operand:V_128_256 3 "nonimmediate_operand"))
26644 (match_dup 1)))]
26645 "TARGET_XOP"
26646 [(set (match_dup 0) (if_then_else:V_128_256 (match_dup 3)
26647 (match_dup 2)
26648 (match_dup 1)))])
26649 (define_split
26650 [(set (match_operand:V_128_256 0 "register_operand")
26651 (xor:V_128_256
26652 (and:V_128_256
26653 (xor:V_128_256 (match_operand:V_128_256 1 "register_operand")
26654 (match_operand:V_128_256 2 "register_operand"))
26655 (match_operand:V_128_256 3 "nonimmediate_operand"))
26656 (match_dup 2)))]
26657 "TARGET_XOP"
26658 [(set (match_dup 0) (if_then_else:V_128_256 (match_dup 3)
26659 (match_dup 1)
26660 (match_dup 2)))])
26661
26662 ;; XOP horizontal add/subtract instructions
26663 (define_insn "xop_phadd<u>bw"
26664 [(set (match_operand:V8HI 0 "register_operand" "=x")
26665 (plus:V8HI
26666 (any_extend:V8HI
26667 (vec_select:V8QI
26668 (match_operand:V16QI 1 "nonimmediate_operand" "xm")
26669 (parallel [(const_int 0) (const_int 2)
26670 (const_int 4) (const_int 6)
26671 (const_int 8) (const_int 10)
26672 (const_int 12) (const_int 14)])))
26673 (any_extend:V8HI
26674 (vec_select:V8QI
26675 (match_dup 1)
26676 (parallel [(const_int 1) (const_int 3)
26677 (const_int 5) (const_int 7)
26678 (const_int 9) (const_int 11)
26679 (const_int 13) (const_int 15)])))))]
26680 "TARGET_XOP"
26681 "vphadd<u>bw\t{%1, %0|%0, %1}"
26682 [(set_attr "type" "sseiadd1")
26683 (set_attr "c86_attr" "hplus")
26684 (set_attr "prefix" "vex")
26685 (set_attr "prefix_extra" "1")
26686 (set_attr "mode" "TI")])
26687
26688 (define_insn "xop_phadd<u>bd"
26689 [(set (match_operand:V4SI 0 "register_operand" "=x")
26690 (plus:V4SI
26691 (plus:V4SI
26692 (any_extend:V4SI
26693 (vec_select:V4QI
26694 (match_operand:V16QI 1 "nonimmediate_operand" "xm")
26695 (parallel [(const_int 0) (const_int 4)
26696 (const_int 8) (const_int 12)])))
26697 (any_extend:V4SI
26698 (vec_select:V4QI
26699 (match_dup 1)
26700 (parallel [(const_int 1) (const_int 5)
26701 (const_int 9) (const_int 13)]))))
26702 (plus:V4SI
26703 (any_extend:V4SI
26704 (vec_select:V4QI
26705 (match_dup 1)
26706 (parallel [(const_int 2) (const_int 6)
26707 (const_int 10) (const_int 14)])))
26708 (any_extend:V4SI
26709 (vec_select:V4QI
26710 (match_dup 1)
26711 (parallel [(const_int 3) (const_int 7)
26712 (const_int 11) (const_int 15)]))))))]
26713 "TARGET_XOP"
26714 "vphadd<u>bd\t{%1, %0|%0, %1}"
26715 [(set_attr "type" "sseiadd1")
26716 (set_attr "c86_attr" "hplus")
26717 (set_attr "prefix" "vex")
26718 (set_attr "prefix_extra" "1")
26719 (set_attr "mode" "TI")])
26720
26721 (define_insn "xop_phadd<u>bq"
26722 [(set (match_operand:V2DI 0 "register_operand" "=x")
26723 (plus:V2DI
26724 (plus:V2DI
26725 (plus:V2DI
26726 (any_extend:V2DI
26727 (vec_select:V2QI
26728 (match_operand:V16QI 1 "nonimmediate_operand" "xm")
26729 (parallel [(const_int 0) (const_int 8)])))
26730 (any_extend:V2DI
26731 (vec_select:V2QI
26732 (match_dup 1)
26733 (parallel [(const_int 1) (const_int 9)]))))
26734 (plus:V2DI
26735 (any_extend:V2DI
26736 (vec_select:V2QI
26737 (match_dup 1)
26738 (parallel [(const_int 2) (const_int 10)])))
26739 (any_extend:V2DI
26740 (vec_select:V2QI
26741 (match_dup 1)
26742 (parallel [(const_int 3) (const_int 11)])))))
26743 (plus:V2DI
26744 (plus:V2DI
26745 (any_extend:V2DI
26746 (vec_select:V2QI
26747 (match_dup 1)
26748 (parallel [(const_int 4) (const_int 12)])))
26749 (any_extend:V2DI
26750 (vec_select:V2QI
26751 (match_dup 1)
26752 (parallel [(const_int 5) (const_int 13)]))))
26753 (plus:V2DI
26754 (any_extend:V2DI
26755 (vec_select:V2QI
26756 (match_dup 1)
26757 (parallel [(const_int 6) (const_int 14)])))
26758 (any_extend:V2DI
26759 (vec_select:V2QI
26760 (match_dup 1)
26761 (parallel [(const_int 7) (const_int 15)])))))))]
26762 "TARGET_XOP"
26763 "vphadd<u>bq\t{%1, %0|%0, %1}"
26764 [(set_attr "type" "sseiadd1")
26765 (set_attr "c86_attr" "hplus")
26766 (set_attr "prefix" "vex")
26767 (set_attr "prefix_extra" "1")
26768 (set_attr "mode" "TI")])
26769
26770 (define_insn "xop_phadd<u>wd"
26771 [(set (match_operand:V4SI 0 "register_operand" "=x")
26772 (plus:V4SI
26773 (any_extend:V4SI
26774 (vec_select:V4HI
26775 (match_operand:V8HI 1 "nonimmediate_operand" "xm")
26776 (parallel [(const_int 0) (const_int 2)
26777 (const_int 4) (const_int 6)])))
26778 (any_extend:V4SI
26779 (vec_select:V4HI
26780 (match_dup 1)
26781 (parallel [(const_int 1) (const_int 3)
26782 (const_int 5) (const_int 7)])))))]
26783 "TARGET_XOP"
26784 "vphadd<u>wd\t{%1, %0|%0, %1}"
26785 [(set_attr "type" "sseiadd1")
26786 (set_attr "c86_attr" "hplus")
26787 (set_attr "prefix" "vex")
26788 (set_attr "prefix_extra" "1")
26789 (set_attr "mode" "TI")])
26790
26791 (define_insn "xop_phadd<u>wq"
26792 [(set (match_operand:V2DI 0 "register_operand" "=x")
26793 (plus:V2DI
26794 (plus:V2DI
26795 (any_extend:V2DI
26796 (vec_select:V2HI
26797 (match_operand:V8HI 1 "nonimmediate_operand" "xm")
26798 (parallel [(const_int 0) (const_int 4)])))
26799 (any_extend:V2DI
26800 (vec_select:V2HI
26801 (match_dup 1)
26802 (parallel [(const_int 1) (const_int 5)]))))
26803 (plus:V2DI
26804 (any_extend:V2DI
26805 (vec_select:V2HI
26806 (match_dup 1)
26807 (parallel [(const_int 2) (const_int 6)])))
26808 (any_extend:V2DI
26809 (vec_select:V2HI
26810 (match_dup 1)
26811 (parallel [(const_int 3) (const_int 7)]))))))]
26812 "TARGET_XOP"
26813 "vphadd<u>wq\t{%1, %0|%0, %1}"
26814 [(set_attr "type" "sseiadd1")
26815 (set_attr "c86_attr" "hplus")
26816 (set_attr "prefix" "vex")
26817 (set_attr "prefix_extra" "1")
26818 (set_attr "mode" "TI")])
26819
26820 (define_insn "xop_phadd<u>dq"
26821 [(set (match_operand:V2DI 0 "register_operand" "=x")
26822 (plus:V2DI
26823 (any_extend:V2DI
26824 (vec_select:V2SI
26825 (match_operand:V4SI 1 "nonimmediate_operand" "xm")
26826 (parallel [(const_int 0) (const_int 2)])))
26827 (any_extend:V2DI
26828 (vec_select:V2SI
26829 (match_dup 1)
26830 (parallel [(const_int 1) (const_int 3)])))))]
26831 "TARGET_XOP"
26832 "vphadd<u>dq\t{%1, %0|%0, %1}"
26833 [(set_attr "type" "sseiadd1")
26834 (set_attr "c86_attr" "hplus")
26835 (set_attr "prefix" "vex")
26836 (set_attr "prefix_extra" "1")
26837 (set_attr "mode" "TI")])
26838
26839 (define_insn "xop_phsubbw"
26840 [(set (match_operand:V8HI 0 "register_operand" "=x")
26841 (minus:V8HI
26842 (sign_extend:V8HI
26843 (vec_select:V8QI
26844 (match_operand:V16QI 1 "nonimmediate_operand" "xm")
26845 (parallel [(const_int 0) (const_int 2)
26846 (const_int 4) (const_int 6)
26847 (const_int 8) (const_int 10)
26848 (const_int 12) (const_int 14)])))
26849 (sign_extend:V8HI
26850 (vec_select:V8QI
26851 (match_dup 1)
26852 (parallel [(const_int 1) (const_int 3)
26853 (const_int 5) (const_int 7)
26854 (const_int 9) (const_int 11)
26855 (const_int 13) (const_int 15)])))))]
26856 "TARGET_XOP"
26857 "vphsubbw\t{%1, %0|%0, %1}"
26858 [(set_attr "type" "sseiadd1")
26859 (set_attr "c86_attr" "hplus")
26860 (set_attr "prefix" "vex")
26861 (set_attr "prefix_extra" "1")
26862 (set_attr "mode" "TI")])
26863
26864 (define_insn "xop_phsubwd"
26865 [(set (match_operand:V4SI 0 "register_operand" "=x")
26866 (minus:V4SI
26867 (sign_extend:V4SI
26868 (vec_select:V4HI
26869 (match_operand:V8HI 1 "nonimmediate_operand" "xm")
26870 (parallel [(const_int 0) (const_int 2)
26871 (const_int 4) (const_int 6)])))
26872 (sign_extend:V4SI
26873 (vec_select:V4HI
26874 (match_dup 1)
26875 (parallel [(const_int 1) (const_int 3)
26876 (const_int 5) (const_int 7)])))))]
26877 "TARGET_XOP"
26878 "vphsubwd\t{%1, %0|%0, %1}"
26879 [(set_attr "type" "sseiadd1")
26880 (set_attr "c86_attr" "hplus")
26881 (set_attr "prefix" "vex")
26882 (set_attr "prefix_extra" "1")
26883 (set_attr "mode" "TI")])
26884
26885 (define_insn "xop_phsubdq"
26886 [(set (match_operand:V2DI 0 "register_operand" "=x")
26887 (minus:V2DI
26888 (sign_extend:V2DI
26889 (vec_select:V2SI
26890 (match_operand:V4SI 1 "nonimmediate_operand" "xm")
26891 (parallel [(const_int 0) (const_int 2)])))
26892 (sign_extend:V2DI
26893 (vec_select:V2SI
26894 (match_dup 1)
26895 (parallel [(const_int 1) (const_int 3)])))))]
26896 "TARGET_XOP"
26897 "vphsubdq\t{%1, %0|%0, %1}"
26898 [(set_attr "type" "sseiadd1")
26899 (set_attr "c86_attr" "hplus")
26900 (set_attr "prefix" "vex")
26901 (set_attr "prefix_extra" "1")
26902 (set_attr "mode" "TI")])
26903
26904 ;; XOP permute instructions
26905 (define_insn "xop_pperm"
26906 [(set (match_operand:V16QI 0 "register_operand" "=x,x")
26907 (unspec:V16QI
26908 [(match_operand:V16QI 1 "register_operand" "x,x")
26909 (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
26910 (match_operand:V16QI 3 "nonimmediate_operand" "xm,x")]
26911 UNSPEC_XOP_PERMUTE))]
26912 "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
26913 "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
26914 [(set_attr "type" "sse4arg")
26915 (set_attr "mode" "TI")])
26916
26917 ;; XOP pack instructions that combine two vectors into a smaller vector
26918 (define_insn "xop_pperm_pack_v2di_v4si"
26919 [(set (match_operand:V4SI 0 "register_operand" "=x,x")
26920 (vec_concat:V4SI
26921 (truncate:V2SI
26922 (match_operand:V2DI 1 "register_operand" "x,x"))
26923 (truncate:V2SI
26924 (match_operand:V2DI 2 "nonimmediate_operand" "x,m"))))
26925 (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
26926 "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
26927 "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
26928 [(set_attr "type" "sse4arg")
26929 (set_attr "mode" "TI")])
26930
26931 (define_insn "xop_pperm_pack_v4si_v8hi"
26932 [(set (match_operand:V8HI 0 "register_operand" "=x,x")
26933 (vec_concat:V8HI
26934 (truncate:V4HI
26935 (match_operand:V4SI 1 "register_operand" "x,x"))
26936 (truncate:V4HI
26937 (match_operand:V4SI 2 "nonimmediate_operand" "x,m"))))
26938 (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
26939 "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
26940 "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
26941 [(set_attr "type" "sse4arg")
26942 (set_attr "mode" "TI")])
26943
26944 (define_insn "xop_pperm_pack_v8hi_v16qi"
26945 [(set (match_operand:V16QI 0 "register_operand" "=x,x")
26946 (vec_concat:V16QI
26947 (truncate:V8QI
26948 (match_operand:V8HI 1 "register_operand" "x,x"))
26949 (truncate:V8QI
26950 (match_operand:V8HI 2 "nonimmediate_operand" "x,m"))))
26951 (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
26952 "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
26953 "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
26954 [(set_attr "type" "sse4arg")
26955 (set_attr "mode" "TI")])
26956
26957 ;; XOP packed rotate instructions
26958 (define_expand "rotl<mode>3"
26959 [(set (match_operand:VI_128 0 "register_operand")
26960 (rotate:VI_128
26961 (match_operand:VI_128 1 "nonimmediate_operand")
26962 (match_operand:SI 2 "general_operand")))]
26963 "TARGET_XOP"
26964 {
26965 /* If we were given a scalar, convert it to parallel */
26966 if (! const_0_to_<sserotatemax>_operand (operands[2], SImode))
26967 {
26968 rtvec vs = rtvec_alloc (<ssescalarnum>);
26969 rtx par = gen_rtx_PARALLEL (<MODE>mode, vs);
26970 rtx reg = gen_reg_rtx (<MODE>mode);
26971 rtx op2 = operands[2];
26972 int i;
26973
26974 if (GET_MODE (op2) != <ssescalarmode>mode)
26975 {
26976 op2 = gen_reg_rtx (<ssescalarmode>mode);
26977 convert_move (op2, operands[2], false);
26978 }
26979
26980 for (i = 0; i < <ssescalarnum>; i++)
26981 RTVEC_ELT (vs, i) = op2;
26982
26983 emit_insn (gen_vec_init<mode><ssescalarmodelower> (reg, par));
26984 emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], reg));
26985 DONE;
26986 }
26987 })
26988
26989 (define_expand "rotr<mode>3"
26990 [(set (match_operand:VI_128 0 "register_operand")
26991 (rotatert:VI_128
26992 (match_operand:VI_128 1 "nonimmediate_operand")
26993 (match_operand:SI 2 "general_operand")))]
26994 "TARGET_XOP"
26995 {
26996 /* If we were given a scalar, convert it to parallel */
26997 if (! const_0_to_<sserotatemax>_operand (operands[2], SImode))
26998 {
26999 rtvec vs = rtvec_alloc (<ssescalarnum>);
27000 rtx par = gen_rtx_PARALLEL (<MODE>mode, vs);
27001 rtx neg = gen_reg_rtx (<MODE>mode);
27002 rtx reg = gen_reg_rtx (<MODE>mode);
27003 rtx op2 = operands[2];
27004 int i;
27005
27006 if (GET_MODE (op2) != <ssescalarmode>mode)
27007 {
27008 op2 = gen_reg_rtx (<ssescalarmode>mode);
27009 convert_move (op2, operands[2], false);
27010 }
27011
27012 for (i = 0; i < <ssescalarnum>; i++)
27013 RTVEC_ELT (vs, i) = op2;
27014
27015 emit_insn (gen_vec_init<mode><ssescalarmodelower> (reg, par));
27016 emit_insn (gen_neg<mode>2 (neg, reg));
27017 emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], neg));
27018 DONE;
27019 }
27020 })
27021
27022 (define_insn "xop_rotl<mode>3"
27023 [(set (match_operand:VI_128 0 "register_operand" "=x")
27024 (rotate:VI_128
27025 (match_operand:VI_128 1 "nonimmediate_operand" "xm")
27026 (match_operand:SI 2 "const_0_to_<sserotatemax>_operand")))]
27027 "TARGET_XOP"
27028 "vprot<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
27029 [(set_attr "type" "sseishft")
27030 (set_attr "prefix" "vex")
27031 (set_attr "prefix_extra" "1")
27032 (set_attr "length_immediate" "1")
27033 (set_attr "mode" "TI")])
27034
27035 (define_insn "xop_rotr<mode>3"
27036 [(set (match_operand:VI_128 0 "register_operand" "=x")
27037 (rotatert:VI_128
27038 (match_operand:VI_128 1 "nonimmediate_operand" "xm")
27039 (match_operand:SI 2 "const_0_to_<sserotatemax>_operand")))]
27040 "TARGET_XOP"
27041 {
27042 operands[3]
27043 = GEN_INT (GET_MODE_BITSIZE (<ssescalarmode>mode) - INTVAL (operands[2]));
27044 return \"vprot<ssemodesuffix>\t{%3, %1, %0|%0, %1, %3}\";
27045 }
27046 [(set_attr "type" "sseishft")
27047 (set_attr "prefix" "vex")
27048 (set_attr "prefix_extra" "1")
27049 (set_attr "length_immediate" "1")
27050 (set_attr "mode" "TI")])
27051
27052 (define_expand "vrotr<mode>3"
27053 [(match_operand:VI_128 0 "register_operand")
27054 (match_operand:VI_128 1 "register_operand")
27055 (match_operand:VI_128 2 "register_operand")]
27056 "TARGET_XOP"
27057 {
27058 rtx reg = gen_reg_rtx (<MODE>mode);
27059 emit_insn (gen_neg<mode>2 (reg, operands[2]));
27060 emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], reg));
27061 DONE;
27062 })
27063
27064 (define_expand "vrotl<mode>3"
27065 [(match_operand:VI_128 0 "register_operand")
27066 (match_operand:VI_128 1 "register_operand")
27067 (match_operand:VI_128 2 "register_operand")]
27068 "TARGET_XOP"
27069 {
27070 emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], operands[2]));
27071 DONE;
27072 })
27073
27074 (define_insn "xop_vrotl<mode>3"
27075 [(set (match_operand:VI_128 0 "register_operand" "=x,x")
27076 (if_then_else:VI_128
27077 (ge:VI_128
27078 (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
27079 (const_int 0))
27080 (rotate:VI_128
27081 (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
27082 (match_dup 2))
27083 (rotatert:VI_128
27084 (match_dup 1)
27085 (neg:VI_128 (match_dup 2)))))]
27086 "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
27087 "vprot<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
27088 [(set_attr "type" "sseishft")
27089 (set_attr "prefix" "vex")
27090 (set_attr "prefix_extra" "1")
27091 (set_attr "mode" "TI")])
27092
27093 ;; XOP packed shift instructions.
27094 (define_expand "vlshr<mode>3"
27095 [(set (match_operand:VI12_128 0 "register_operand")
27096 (lshiftrt:VI12_128
27097 (match_operand:VI12_128 1 "register_operand")
27098 (match_operand:VI12_128 2 "nonimmediate_operand")))]
27099 "TARGET_XOP || (TARGET_AVX512BW && TARGET_AVX512VL)"
27100 {
27101 if (TARGET_XOP)
27102 {
27103 rtx neg = gen_reg_rtx (<MODE>mode);
27104 emit_insn (gen_neg<mode>2 (neg, operands[2]));
27105 emit_insn (gen_xop_shl<mode>3 (operands[0], operands[1], neg));
27106 DONE;
27107 }
27108 else if (<MODE>mode == V16QImode)
27109 {
27110 ix86_expand_vecop_qihi (LSHIFTRT, operands[0], operands[1], operands[2]);
27111 DONE;
27112 }
27113 })
27114
27115 (define_expand "vlshr<mode>3"
27116 [(set (match_operand:VI48_128 0 "register_operand")
27117 (lshiftrt:VI48_128
27118 (match_operand:VI48_128 1 "register_operand")
27119 (match_operand:VI48_128 2 "nonimmediate_operand")))]
27120 "TARGET_AVX2 || TARGET_XOP"
27121 {
27122 if (!TARGET_AVX2)
27123 {
27124 rtx neg = gen_reg_rtx (<MODE>mode);
27125 emit_insn (gen_neg<mode>2 (neg, operands[2]));
27126 emit_insn (gen_xop_shl<mode>3 (operands[0], operands[1], neg));
27127 DONE;
27128 }
27129 })
27130
27131 (define_expand "v<insn><mode>3"
27132 [(set (match_operand:VI12_256_512_AVX512VL 0 "register_operand")
27133 (any_shift:VI12_256_512_AVX512VL
27134 (match_operand:VI12_256_512_AVX512VL 1 "register_operand")
27135 (match_operand:VI12_256_512_AVX512VL 2 "nonimmediate_operand")))]
27136 "TARGET_AVX512BW"
27137 {
27138 if (<MODE>mode == V32QImode || <MODE>mode == V64QImode)
27139 {
27140 ix86_expand_vecop_qihi (<CODE>, operands[0], operands[1], operands[2]);
27141 DONE;
27142 }
27143 })
27144
27145 (define_expand "vlshr<mode>3"
27146 [(set (match_operand:VI48_512 0 "register_operand")
27147 (lshiftrt:VI48_512
27148 (match_operand:VI48_512 1 "register_operand")
27149 (match_operand:VI48_512 2 "nonimmediate_operand")))]
27150 "TARGET_AVX512F")
27151
27152 (define_expand "vlshr<mode>3"
27153 [(set (match_operand:VI48_256 0 "register_operand")
27154 (lshiftrt:VI48_256
27155 (match_operand:VI48_256 1 "register_operand")
27156 (match_operand:VI48_256 2 "nonimmediate_operand")))]
27157 "TARGET_AVX2")
27158
27159 (define_expand "vashrv8di3"
27160 [(set (match_operand:V8DI 0 "register_operand")
27161 (ashiftrt:V8DI
27162 (match_operand:V8DI 1 "register_operand")
27163 (match_operand:V8DI 2 "nonimmediate_operand")))]
27164 "TARGET_AVX512F && TARGET_EVEX512")
27165
27166 (define_expand "vashrv4di3"
27167 [(set (match_operand:V4DI 0 "register_operand")
27168 (ashiftrt:V4DI
27169 (match_operand:V4DI 1 "register_operand")
27170 (match_operand:V4DI 2 "nonimmediate_operand")))]
27171 "TARGET_AVX2"
27172 {
27173 if (!TARGET_AVX512VL)
27174 {
27175 rtx mask = ix86_build_signbit_mask (V4DImode, 1, 0);
27176 rtx t1 = gen_reg_rtx (V4DImode);
27177 rtx t2 = gen_reg_rtx (V4DImode);
27178 rtx t3 = gen_reg_rtx (V4DImode);
27179 emit_insn (gen_vlshrv4di3 (t1, operands[1], operands[2]));
27180 emit_insn (gen_vlshrv4di3 (t2, mask, operands[2]));
27181 emit_insn (gen_xorv4di3 (t3, t1, t2));
27182 emit_insn (gen_subv4di3 (operands[0], t3, t2));
27183 DONE;
27184 }
27185 })
27186
27187 (define_expand "vashr<mode>3"
27188 [(set (match_operand:VI12_128 0 "register_operand")
27189 (ashiftrt:VI12_128
27190 (match_operand:VI12_128 1 "register_operand")
27191 (match_operand:VI12_128 2 "nonimmediate_operand")))]
27192 "TARGET_XOP || (TARGET_AVX512BW && TARGET_AVX512VL)"
27193 {
27194 if (TARGET_XOP)
27195 {
27196 rtx neg = gen_reg_rtx (<MODE>mode);
27197 emit_insn (gen_neg<mode>2 (neg, operands[2]));
27198 emit_insn (gen_xop_sha<mode>3 (operands[0], operands[1], neg));
27199 DONE;
27200 }
27201 else if(<MODE>mode == V16QImode)
27202 {
27203 ix86_expand_vecop_qihi (ASHIFTRT, operands[0],operands[1], operands[2]);
27204 DONE;
27205 }
27206 })
27207
27208 (define_expand "vashrv2di3"
27209 [(set (match_operand:V2DI 0 "register_operand")
27210 (ashiftrt:V2DI
27211 (match_operand:V2DI 1 "register_operand")
27212 (match_operand:V2DI 2 "nonimmediate_operand")))]
27213 "TARGET_XOP || TARGET_AVX2"
27214 {
27215 if (TARGET_XOP)
27216 {
27217 rtx neg = gen_reg_rtx (V2DImode);
27218 emit_insn (gen_negv2di2 (neg, operands[2]));
27219 emit_insn (gen_xop_shav2di3 (operands[0], operands[1], neg));
27220 DONE;
27221 }
27222 if (!TARGET_AVX512VL)
27223 {
27224 rtx mask = ix86_build_signbit_mask (V2DImode, 1, 0);
27225 rtx t1 = gen_reg_rtx (V2DImode);
27226 rtx t2 = gen_reg_rtx (V2DImode);
27227 rtx t3 = gen_reg_rtx (V2DImode);
27228 emit_insn (gen_vlshrv2di3 (t1, operands[1], operands[2]));
27229 emit_insn (gen_vlshrv2di3 (t2, mask, operands[2]));
27230 emit_insn (gen_xorv2di3 (t3, t1, t2));
27231 emit_insn (gen_subv2di3 (operands[0], t3, t2));
27232 DONE;
27233 }
27234 })
27235
27236 (define_expand "vashrv4si3"
27237 [(set (match_operand:V4SI 0 "register_operand")
27238 (ashiftrt:V4SI (match_operand:V4SI 1 "register_operand")
27239 (match_operand:V4SI 2 "nonimmediate_operand")))]
27240 "TARGET_AVX2 || TARGET_XOP"
27241 {
27242 if (!TARGET_AVX2)
27243 {
27244 rtx neg = gen_reg_rtx (V4SImode);
27245 emit_insn (gen_negv4si2 (neg, operands[2]));
27246 emit_insn (gen_xop_shav4si3 (operands[0], operands[1], neg));
27247 DONE;
27248 }
27249 })
27250
27251 (define_expand "vashrv16si3"
27252 [(set (match_operand:V16SI 0 "register_operand")
27253 (ashiftrt:V16SI (match_operand:V16SI 1 "register_operand")
27254 (match_operand:V16SI 2 "nonimmediate_operand")))]
27255 "TARGET_AVX512F && TARGET_EVEX512")
27256
27257 (define_expand "vashrv8si3"
27258 [(set (match_operand:V8SI 0 "register_operand")
27259 (ashiftrt:V8SI (match_operand:V8SI 1 "register_operand")
27260 (match_operand:V8SI 2 "nonimmediate_operand")))]
27261 "TARGET_AVX2")
27262
27263 (define_expand "vashl<mode>3"
27264 [(set (match_operand:VI12_128 0 "register_operand")
27265 (ashift:VI12_128
27266 (match_operand:VI12_128 1 "register_operand")
27267 (match_operand:VI12_128 2 "nonimmediate_operand")))]
27268 "TARGET_XOP || (TARGET_AVX512BW && TARGET_AVX512VL)"
27269 {
27270 if (TARGET_XOP)
27271 {
27272 emit_insn (gen_xop_sha<mode>3 (operands[0], operands[1], operands[2]));
27273 DONE;
27274 }
27275 else if (<MODE>mode == V16QImode)
27276 {
27277 ix86_expand_vecop_qihi (ASHIFT, operands[0], operands[1], operands[2]);
27278 DONE;
27279 }
27280 })
27281
27282 (define_expand "vashl<mode>3"
27283 [(set (match_operand:VI48_128 0 "register_operand")
27284 (ashift:VI48_128
27285 (match_operand:VI48_128 1 "register_operand")
27286 (match_operand:VI48_128 2 "nonimmediate_operand")))]
27287 "TARGET_AVX2 || TARGET_XOP"
27288 {
27289 if (!TARGET_AVX2)
27290 {
27291 operands[2] = force_reg (<MODE>mode, operands[2]);
27292 emit_insn (gen_xop_sha<mode>3 (operands[0], operands[1], operands[2]));
27293 DONE;
27294 }
27295 })
27296
27297 (define_expand "vashl<mode>3"
27298 [(set (match_operand:VI48_512 0 "register_operand")
27299 (ashift:VI48_512
27300 (match_operand:VI48_512 1 "register_operand")
27301 (match_operand:VI48_512 2 "nonimmediate_operand")))]
27302 "TARGET_AVX512F")
27303
27304 (define_expand "vashl<mode>3"
27305 [(set (match_operand:VI48_256 0 "register_operand")
27306 (ashift:VI48_256
27307 (match_operand:VI48_256 1 "register_operand")
27308 (match_operand:VI48_256 2 "nonimmediate_operand")))]
27309 "TARGET_AVX2")
27310
27311 (define_insn "xop_sha<mode>3"
27312 [(set (match_operand:VI_128 0 "register_operand" "=x,x")
27313 (if_then_else:VI_128
27314 (ge:VI_128
27315 (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
27316 (const_int 0))
27317 (ashift:VI_128
27318 (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
27319 (match_dup 2))
27320 (ashiftrt:VI_128
27321 (match_dup 1)
27322 (neg:VI_128 (match_dup 2)))))]
27323 "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
27324 "vpsha<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
27325 [(set_attr "type" "sseishft")
27326 (set_attr "prefix" "vex")
27327 (set_attr "prefix_extra" "1")
27328 (set_attr "mode" "TI")])
27329
27330 (define_insn "xop_shl<mode>3"
27331 [(set (match_operand:VI_128 0 "register_operand" "=x,x")
27332 (if_then_else:VI_128
27333 (ge:VI_128
27334 (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
27335 (const_int 0))
27336 (ashift:VI_128
27337 (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
27338 (match_dup 2))
27339 (lshiftrt:VI_128
27340 (match_dup 1)
27341 (neg:VI_128 (match_dup 2)))))]
27342 "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
27343 "vpshl<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
27344 [(set_attr "type" "sseishft")
27345 (set_attr "prefix" "vex")
27346 (set_attr "prefix_extra" "1")
27347 (set_attr "mode" "TI")])
27348
27349 (define_expand "<insn><mode>3"
27350 [(set (match_operand:VI1_AVX512 0 "register_operand")
27351 (any_shift:VI1_AVX512
27352 (match_operand:VI1_AVX512 1 "register_operand")
27353 (match_operand:SI 2 "nonmemory_operand")))]
27354 "TARGET_SSE2"
27355 {
27356 if (TARGET_XOP && <MODE>mode == V16QImode)
27357 {
27358 bool negate = false;
27359 rtx (*gen) (rtx, rtx, rtx);
27360 rtx tmp, par;
27361 int i;
27362
27363 if (<CODE> != ASHIFT)
27364 {
27365 if (CONST_INT_P (operands[2]))
27366 operands[2] = GEN_INT (-INTVAL (operands[2]));
27367 else
27368 negate = true;
27369 }
27370 par = gen_rtx_PARALLEL (V16QImode, rtvec_alloc (16));
27371 tmp = lowpart_subreg (QImode, operands[2], SImode);
27372 for (i = 0; i < 16; i++)
27373 XVECEXP (par, 0, i) = tmp;
27374
27375 tmp = gen_reg_rtx (V16QImode);
27376 emit_insn (gen_vec_initv16qiqi (tmp, par));
27377
27378 if (negate)
27379 emit_insn (gen_negv16qi2 (tmp, tmp));
27380
27381 gen = (<CODE> == LSHIFTRT ? gen_xop_shlv16qi3 : gen_xop_shav16qi3);
27382 emit_insn (gen (operands[0], operands[1], tmp));
27383 }
27384 else
27385 ix86_expand_vecop_qihi (<CODE>, operands[0], operands[1], operands[2]);
27386 DONE;
27387 })
27388
27389 (define_expand "ashrv2di3"
27390 [(set (match_operand:V2DI 0 "register_operand")
27391 (ashiftrt:V2DI
27392 (match_operand:V2DI 1 "register_operand")
27393 (match_operand:DI 2 "nonmemory_operand")))]
27394 "TARGET_SSE2"
27395 {
27396 if (!TARGET_AVX512VL)
27397 {
27398 ix86_expand_v2di_ashiftrt (operands);
27399 DONE;
27400 }
27401 })
27402
27403 (define_insn_and_split "*ashrv2di3"
27404 [(set (match_operand:V2DI 0 "register_operand")
27405 (ashiftrt:V2DI
27406 (match_operand:V2DI 1 "register_operand")
27407 (match_operand:DI 2 "nonmemory_operand")))]
27408 "TARGET_SSE2 && !TARGET_AVX512VL && ix86_pre_reload_split ()"
27409 "#"
27410 "&& 1"
27411 [(const_int 0)]
27412 "ix86_expand_v2di_ashiftrt (operands); DONE;")
27413
27414 ;; XOP FRCZ support
27415 (define_insn "xop_frcz<mode>2"
27416 [(set (match_operand:FMAMODE 0 "register_operand" "=x")
27417 (unspec:FMAMODE
27418 [(match_operand:FMAMODE 1 "nonimmediate_operand" "xm")]
27419 UNSPEC_FRCZ))]
27420 "TARGET_XOP"
27421 "vfrcz<ssemodesuffix>\t{%1, %0|%0, %1}"
27422 [(set_attr "type" "ssecvt1")
27423 (set_attr "prefix" "vex")
27424 (set_attr "prefix_extra" "1")
27425 (set_attr "mode" "<MODE>")])
27426
27427 (define_expand "xop_vmfrcz<mode>2"
27428 [(set (match_operand:VF_128 0 "register_operand")
27429 (vec_merge:VF_128
27430 (unspec:VF_128
27431 [(match_operand:VF_128 1 "nonimmediate_operand")]
27432 UNSPEC_FRCZ)
27433 (match_dup 2)
27434 (const_int 1)))]
27435 "TARGET_XOP"
27436 "operands[2] = CONST0_RTX (<MODE>mode);")
27437
27438 (define_insn "*xop_vmfrcz<mode>2"
27439 [(set (match_operand:VF_128 0 "register_operand" "=x")
27440 (vec_merge:VF_128
27441 (unspec:VF_128
27442 [(match_operand:VF_128 1 "nonimmediate_operand" "xm")]
27443 UNSPEC_FRCZ)
27444 (match_operand:VF_128 2 "const0_operand")
27445 (const_int 1)))]
27446 "TARGET_XOP"
27447 "vfrcz<ssescalarmodesuffix>\t{%1, %0|%0, %<iptr>1}"
27448 [(set_attr "type" "ssecvt1")
27449 (set_attr "prefix" "vex")
27450 (set_attr "prefix_extra" "1")
27451 (set_attr "mode" "<MODE>")])
27452
27453 (define_insn "xop_maskcmp<mode>3"
27454 [(set (match_operand:VI_128 0 "register_operand" "=x")
27455 (match_operator:VI_128 1 "ix86_comparison_int_operator"
27456 [(match_operand:VI_128 2 "register_operand" "x")
27457 (match_operand:VI_128 3 "nonimmediate_operand" "xm")]))]
27458 "TARGET_XOP"
27459 "vpcom%Y1<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
27460 [(set_attr "type" "sse4arg")
27461 (set_attr "mode" "TI")])
27462
27463 (define_insn "xop_maskcmp_uns<mode>3"
27464 [(set (match_operand:VI_128 0 "register_operand" "=x")
27465 (match_operator:VI_128 1 "ix86_comparison_uns_operator"
27466 [(match_operand:VI_128 2 "register_operand" "x")
27467 (match_operand:VI_128 3 "nonimmediate_operand" "xm")]))]
27468 "TARGET_XOP"
27469 "vpcom%Y1u<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
27470 [(set_attr "type" "sse4arg")
27471 (set_attr "mode" "TI")])
27472
27473 ;; Version of pcom*u* that is called from the intrinsics that allows pcomequ*
27474 ;; and pcomneu* not to be converted to the signed ones in case somebody needs
27475 ;; the exact instruction generated for the intrinsic.
27476 (define_insn "xop_maskcmp_uns2<mode>3"
27477 [(set (match_operand:VI_128 0 "register_operand" "=x")
27478 (unspec:VI_128
27479 [(match_operator:VI_128 1 "ix86_comparison_uns_operator"
27480 [(match_operand:VI_128 2 "register_operand" "x")
27481 (match_operand:VI_128 3 "nonimmediate_operand" "xm")])]
27482 UNSPEC_XOP_UNSIGNED_CMP))]
27483 "TARGET_XOP"
27484 "vpcom%Y1u<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
27485 [(set_attr "type" "sse4arg")
27486 (set_attr "mode" "TI")])
27487
27488 ;; Pcomtrue and pcomfalse support. These are useless instructions, but are
27489 ;; being added here to be complete.
27490 (define_insn "xop_pcom_tf<mode>3"
27491 [(set (match_operand:VI_128 0 "register_operand" "=x")
27492 (unspec:VI_128
27493 [(match_operand:VI_128 1 "register_operand" "x")
27494 (match_operand:VI_128 2 "nonimmediate_operand" "xm")
27495 (match_operand:SI 3 "const_int_operand")]
27496 UNSPEC_XOP_TRUEFALSE))]
27497 "TARGET_XOP"
27498 {
27499 return ((INTVAL (operands[3]) != 0)
27500 ? "vpcomtrue<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
27501 : "vpcomfalse<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}");
27502 }
27503 [(set_attr "type" "sse4arg")
27504 (set_attr "mode" "TI")])
27505
27506 (define_insn "xop_vpermil2<mode>3"
27507 [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
27508 (unspec:VF_128_256
27509 [(match_operand:VF_128_256 1 "register_operand" "x,x")
27510 (match_operand:VF_128_256 2 "nonimmediate_operand" "x,m")
27511 (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "xm,x")
27512 (match_operand:SI 4 "const_0_to_3_operand")]
27513 UNSPEC_VPERMIL2))]
27514 "TARGET_XOP"
27515 "vpermil2<ssemodesuffix>\t{%4, %3, %2, %1, %0|%0, %1, %2, %3, %4}"
27516 [(set_attr "type" "sse4arg")
27517 (set_attr "mode" "<MODE>")])
27518
27519 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27520
27521 (define_insn "aesenc"
27522 [(set (match_operand:V2DI 0 "register_operand" "=x,x,v")
27523 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x,v")
27524 (match_operand:V2DI 2 "vector_operand" "xja,xjm,vm")]
27525 UNSPEC_AESENC))]
27526 "TARGET_AES || (TARGET_VAES && TARGET_AVX512VL)"
27527 "@
27528 aesenc\t{%2, %0|%0, %2}
27529 * return TARGET_AES ? \"vaesenc\t{%2, %1, %0|%0, %1, %2}\" : \"%{evex%} vaesenc\t{%2, %1, %0|%0, %1, %2}\";
27530 vaesenc\t{%2, %1, %0|%0, %1, %2}"
27531 [(set_attr "isa" "noavx,avx,vaes_avx512vl")
27532 (set_attr "type" "sselog1")
27533 (set_attr "c86_attr" "aes")
27534 (set_attr "addr" "gpr16,gpr16,*")
27535 (set_attr "prefix_extra" "1")
27536 (set_attr "prefix" "orig,maybe_evex,evex")
27537 (set_attr "btver2_decode" "double,double,double")
27538 (set_attr "mode" "TI")])
27539
27540 (define_insn "aesenclast"
27541 [(set (match_operand:V2DI 0 "register_operand" "=x,x,v")
27542 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x,v")
27543 (match_operand:V2DI 2 "vector_operand" "xja,xjm,vm")]
27544 UNSPEC_AESENCLAST))]
27545 "TARGET_AES || (TARGET_VAES && TARGET_AVX512VL)"
27546 "@
27547 aesenclast\t{%2, %0|%0, %2}
27548 * return TARGET_AES ? \"vaesenclast\t{%2, %1, %0|%0, %1, %2}\" : \"%{evex%} vaesenclast\t{%2, %1, %0|%0, %1, %2}\";
27549 vaesenclast\t{%2, %1, %0|%0, %1, %2}"
27550 [(set_attr "isa" "noavx,avx,vaes_avx512vl")
27551 (set_attr "type" "sselog1")
27552 (set_attr "c86_attr" "aes")
27553 (set_attr "addr" "gpr16,gpr16,*")
27554 (set_attr "prefix_extra" "1")
27555 (set_attr "prefix" "orig,maybe_evex,evex")
27556 (set_attr "btver2_decode" "double,double,double")
27557 (set_attr "mode" "TI")])
27558
27559 (define_insn "aesdec"
27560 [(set (match_operand:V2DI 0 "register_operand" "=x,x,v")
27561 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x,v")
27562 (match_operand:V2DI 2 "vector_operand" "xja,xjm,vm")]
27563 UNSPEC_AESDEC))]
27564 "TARGET_AES || (TARGET_VAES && TARGET_AVX512VL)"
27565 "@
27566 aesdec\t{%2, %0|%0, %2}
27567 * return TARGET_AES ? \"vaesdec\t{%2, %1, %0|%0, %1, %2}\" : \"%{evex%} vaesdec\t{%2, %1, %0|%0, %1, %2}\";
27568 vaesdec\t{%2, %1, %0|%0, %1, %2}"
27569 [(set_attr "isa" "noavx,avx,vaes_avx512vl")
27570 (set_attr "type" "sselog1")
27571 (set_attr "c86_attr" "aes")
27572 (set_attr "addr" "gpr16,gpr16,*")
27573 (set_attr "prefix_extra" "1")
27574 (set_attr "prefix" "orig,maybe_evex,evex")
27575 (set_attr "btver2_decode" "double,double,double")
27576 (set_attr "mode" "TI")])
27577
27578 (define_insn "aesdeclast"
27579 [(set (match_operand:V2DI 0 "register_operand" "=x,x,v")
27580 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x,v")
27581 (match_operand:V2DI 2 "vector_operand" "xja,xjm,vm")]
27582 UNSPEC_AESDECLAST))]
27583 "TARGET_AES || (TARGET_VAES && TARGET_AVX512VL)"
27584 "@
27585 aesdeclast\t{%2, %0|%0, %2}
27586 * return TARGET_AES ? \"vaesdeclast\t{%2, %1, %0|%0, %1, %2}\" : \"%{evex%} vaesdeclast\t{%2, %1, %0|%0, %1, %2}\";
27587 vaesdeclast\t{%2, %1, %0|%0, %1, %2}"
27588 [(set_attr "isa" "noavx,avx,vaes_avx512vl")
27589 (set_attr "addr" "gpr16,gpr16,*")
27590 (set_attr "type" "sselog1")
27591 (set_attr "c86_attr" "aes")
27592 (set_attr "prefix_extra" "1")
27593 (set_attr "prefix" "orig,maybe_evex,evex")
27594 (set_attr "btver2_decode" "double,double,double")
27595 (set_attr "mode" "TI")])
27596
27597 (define_insn "aesimc"
27598 [(set (match_operand:V2DI 0 "register_operand" "=x")
27599 (unspec:V2DI [(match_operand:V2DI 1 "vector_operand" "xja")]
27600 UNSPEC_AESIMC))]
27601 "TARGET_AES"
27602 "%vaesimc\t{%1, %0|%0, %1}"
27603 [(set_attr "type" "sselog1")
27604 (set_attr "c86_attr" "aes")
27605 (set_attr "addr" "gpr16")
27606 (set_attr "prefix_extra" "1")
27607 (set_attr "prefix" "maybe_vex")
27608 (set_attr "mode" "TI")])
27609
27610 (define_insn "aeskeygenassist"
27611 [(set (match_operand:V2DI 0 "register_operand" "=x")
27612 (unspec:V2DI [(match_operand:V2DI 1 "vector_operand" "xja")
27613 (match_operand:SI 2 "const_0_to_255_operand")]
27614 UNSPEC_AESKEYGENASSIST))]
27615 "TARGET_AES"
27616 "%vaeskeygenassist\t{%2, %1, %0|%0, %1, %2}"
27617 [(set_attr "type" "sselog1")
27618 (set_attr "c86_attr" "aes")
27619 (set_attr "addr" "gpr16")
27620 (set_attr "prefix_extra" "1")
27621 (set_attr "length_immediate" "1")
27622 (set_attr "prefix" "maybe_vex")
27623 (set_attr "mode" "TI")])
27624
27625 (define_insn "pclmulqdq"
27626 [(set (match_operand:V2DI 0 "register_operand" "=x,x,v")
27627 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x,v")
27628 (match_operand:V2DI 2 "vector_operand" "xja,xm,vm")
27629 (match_operand:SI 3 "const_0_to_255_operand")]
27630 UNSPEC_PCLMUL))]
27631 "TARGET_PCLMUL"
27632 "@
27633 pclmulqdq\t{%3, %2, %0|%0, %2, %3}
27634 vpclmulqdq\t{%3, %2, %1, %0|%0, %1, %2, %3}
27635 vpclmulqdq\t{%3, %2, %1, %0|%0, %1, %2, %3}"
27636 [(set_attr "isa" "noavx,avx,vpclmulqdqvl")
27637 (set_attr "type" "sselog1")
27638 (set_attr "addr" "gpr16,*,*")
27639 (set_attr "prefix_extra" "1")
27640 (set_attr "length_immediate" "1")
27641 (set_attr "prefix" "orig,vex,evex")
27642 (set_attr "c86_decode" "*,vector,vector")
27643 (set_attr "mode" "TI")])
27644
27645 (define_expand "avx_vzeroall"
27646 [(match_par_dup 0 [(const_int 0)])]
27647 "TARGET_AVX"
27648 {
27649 int nregs = TARGET_64BIT ? 16 : 8;
27650 int regno;
27651
27652 operands[0] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs + 1));
27653
27654 XVECEXP (operands[0], 0, 0)
27655 = gen_rtx_UNSPEC_VOLATILE (VOIDmode, gen_rtvec (1, const0_rtx),
27656 UNSPECV_VZEROALL);
27657
27658 for (regno = 0; regno < nregs; regno++)
27659 XVECEXP (operands[0], 0, regno + 1)
27660 = gen_rtx_SET (gen_rtx_REG (V8SImode, GET_SSE_REGNO (regno)),
27661 CONST0_RTX (V8SImode));
27662 })
27663
27664 (define_insn "*avx_vzeroall"
27665 [(match_parallel 0 "vzeroall_operation"
27666 [(unspec_volatile [(const_int 0)] UNSPECV_VZEROALL)])]
27667 "TARGET_AVX"
27668 "vzeroall"
27669 [(set_attr "type" "sse")
27670 (set_attr "modrm" "0")
27671 (set_attr "memory" "none")
27672 (set_attr "prefix" "vex")
27673 (set_attr "btver2_decode" "vector")
27674 (set_attr "mode" "OI")])
27675
27676 ;; Clear the upper 128bits of AVX registers, equivalent to a NOP
27677 ;; if the upper 128bits are unused. Initially we expand the instructions
27678 ;; as though they had no effect on the SSE registers, but later add SETs and
27679 ;; CLOBBERs to the PARALLEL to model the real effect.
27680
27681 (define_expand "avx_vzeroupper"
27682 [(parallel [(call (mem:QI (const_int 0))
27683 (const_int 0))
27684 (unspec [(const_int ABI_VZEROUPPER)] UNSPEC_CALLEE_ABI)])]
27685 "TARGET_AVX"
27686 {
27687 ix86_expand_avx_vzeroupper ();
27688 DONE;
27689 })
27690
27691 (define_insn "avx_vzeroupper_callee_abi"
27692 [(call (mem:QI (const_int 0))
27693 (const_int 0))
27694 (unspec [(const_int ABI_VZEROUPPER)] UNSPEC_CALLEE_ABI)]
27695 "TARGET_AVX"
27696 "vzeroupper"
27697 [(set_attr "type" "sse")
27698 (set_attr "modrm" "0")
27699 (set_attr "memory" "none")
27700 (set_attr "prefix" "vex")
27701 (set_attr "btver2_decode" "vector")
27702 (set_attr "mode" "OI")])
27703
27704 (define_mode_attr pbroadcast_evex_isa
27705 [(V64QI "avx512bw_512") (V32QI "avx512bw") (V16QI "avx512bw")
27706 (V32HI "avx512bw_512") (V16HI "avx512bw") (V8HI "avx512bw")
27707 (V16SI "avx512f_512") (V8SI "avx512f") (V4SI "avx512f")
27708 (V8DI "avx512f_512") (V4DI "avx512f") (V2DI "avx512f")
27709 (V32HF "avx512bw_512") (V16HF "avx512bw") (V8HF "avx512bw")
27710 (V32BF "avx512bw_512") (V16BF "avx512bw") (V8BF "avx512bw")])
27711
27712 (define_insn "avx2_pbroadcast<mode>"
27713 [(set (match_operand:VIHFBF 0 "register_operand" "=x,v")
27714 (vec_duplicate:VIHFBF
27715 (vec_select:<ssescalarmode>
27716 (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "xm,vm")
27717 (parallel [(const_int 0)]))))]
27718 "TARGET_AVX2"
27719 "vpbroadcast<sseintmodesuffix>\t{%1, %0|%0, %<iptr>1}"
27720 [(set_attr "isa" "*,<pbroadcast_evex_isa>")
27721 (set_attr "type" "ssemov")
27722 (set_attr "prefix_extra" "1")
27723 (set_attr "prefix" "vex,evex")
27724 (set_attr "mode" "<sseinsnmode>")])
27725
27726 (define_insn "avx2_pbroadcast<mode>_1"
27727 [(set (match_operand:VIHFBF_256 0 "register_operand" "=x,x,v,v")
27728 (vec_duplicate:VIHFBF_256
27729 (vec_select:<ssescalarmode>
27730 (match_operand:VIHFBF_256 1 "nonimmediate_operand" "m,x,m,v")
27731 (parallel [(const_int 0)]))))]
27732 "TARGET_AVX2"
27733 "@
27734 vpbroadcast<sseintmodesuffix>\t{%1, %0|%0, %<iptr>1}
27735 vpbroadcast<sseintmodesuffix>\t{%x1, %0|%0, %x1}
27736 vpbroadcast<sseintmodesuffix>\t{%1, %0|%0, %<iptr>1}
27737 vpbroadcast<sseintmodesuffix>\t{%x1, %0|%0, %x1}"
27738 [(set_attr "isa" "*,*,<pbroadcast_evex_isa>,<pbroadcast_evex_isa>")
27739 (set_attr "type" "ssemov")
27740 (set_attr "prefix_extra" "1")
27741 (set_attr "prefix" "vex")
27742 (set_attr "mode" "<sseinsnmode>")])
27743
27744 (define_insn "<avx2_avx512>_permvar<mode><mask_name>"
27745 [(set (match_operand:VI48F_256_512 0 "register_operand" "=v")
27746 (unspec:VI48F_256_512
27747 [(match_operand:VI48F_256_512 1 "nonimmediate_operand" "vm")
27748 (match_operand:<sseintvecmode> 2 "register_operand" "v")]
27749 UNSPEC_VPERMVAR))]
27750 "TARGET_AVX2 && <mask_mode512bit_condition>"
27751 {
27752 if (TARGET_DEST_FALSE_DEP_FOR_GLC
27753 && <mask3_dest_false_dep_for_glc_cond>
27754 && !reg_mentioned_p (operands[0], operands[1])
27755 && !reg_mentioned_p (operands[0], operands[2]))
27756 output_asm_insn ("vxorps\t%x0, %x0, %x0", operands);
27757 return "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}";
27758 }
27759 [(set_attr "type" "sselog")
27760 (set_attr "c86_attr" "perm")
27761 (set_attr "prefix" "<mask_prefix2>")
27762 (set_attr "mode" "<sseinsnmode>")])
27763
27764 (define_insn "<avx512>_permvar<mode><mask_name>"
27765 [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
27766 (unspec:VI1_AVX512VL
27767 [(match_operand:VI1_AVX512VL 1 "nonimmediate_operand" "vm")
27768 (match_operand:<sseintvecmode> 2 "register_operand" "v")]
27769 UNSPEC_VPERMVAR))]
27770 "TARGET_AVX512VBMI && <mask_mode512bit_condition>"
27771 "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
27772 [(set_attr "type" "sselog")
27773 (set_attr "c86_attr" "perm")
27774 (set_attr "prefix" "<mask_prefix2>")
27775 (set_attr "mode" "<sseinsnmode>")])
27776
27777 (define_insn "<avx512>_permvar<mode><mask_name>"
27778 [(set (match_operand:VI2HFBF_AVX512VL 0 "register_operand" "=v")
27779 (unspec:VI2HFBF_AVX512VL
27780 [(match_operand:VI2HFBF_AVX512VL 1 "nonimmediate_operand" "vm")
27781 (match_operand:<sseintvecmode> 2 "register_operand" "v")]
27782 UNSPEC_VPERMVAR))]
27783 "TARGET_AVX512BW && <mask_mode512bit_condition>"
27784 "vpermw\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
27785 [(set_attr "type" "sselog")
27786 (set_attr "c86_attr" "perm")
27787 (set_attr "prefix" "<mask_prefix2>")
27788 (set_attr "mode" "<sseinsnmode>")])
27789
27790 ;; Recognize broadcast as a vec_select as produced by builtin_vec_perm.
27791 ;; If it so happens that the input is in memory, use vbroadcast.
27792 ;; Otherwise use vpermilp (and in the case of 256-bit modes, vperm2f128).
27793 (define_insn "*avx_vperm_broadcast_v4sf"
27794 [(set (match_operand:V4SF 0 "register_operand" "=v,v,v")
27795 (vec_select:V4SF
27796 (match_operand:V4SF 1 "nonimmediate_operand" "m,o,v")
27797 (match_parallel 2 "avx_vbroadcast_operand"
27798 [(match_operand 3 "const_int_operand" "C,n,n")])))]
27799 "TARGET_AVX"
27800 {
27801 int elt = INTVAL (operands[3]);
27802 switch (which_alternative)
27803 {
27804 case 0:
27805 case 1:
27806 operands[1] = adjust_address_nv (operands[1], SFmode, elt * 4);
27807 return "vbroadcastss\t{%1, %0|%0, %k1}";
27808 case 2:
27809 operands[2] = GEN_INT (elt * 0x55);
27810 return "vpermilps\t{%2, %1, %0|%0, %1, %2}";
27811 default:
27812 gcc_unreachable ();
27813 }
27814 }
27815 [(set_attr "type" "ssemov,ssemov,sselog1")
27816 (set_attr "prefix_extra" "1")
27817 (set_attr "length_immediate" "0,0,1")
27818 (set_attr "prefix" "maybe_evex")
27819 (set_attr "mode" "SF,SF,V4SF")])
27820
27821 (define_insn_and_split "*avx_vperm_broadcast_<mode>"
27822 [(set (match_operand:VF_256 0 "register_operand" "=v,v,v")
27823 (vec_select:VF_256
27824 (match_operand:VF_256 1 "nonimmediate_operand" "m,o,?v")
27825 (match_parallel 2 "avx_vbroadcast_operand"
27826 [(match_operand 3 "const_int_operand" "C,n,n")])))]
27827 "TARGET_AVX
27828 && (<MODE>mode != V4DFmode || !TARGET_AVX2 || operands[3] == const0_rtx)"
27829 "#"
27830 "&& reload_completed"
27831 [(set (match_dup 0) (vec_duplicate:VF_256 (match_dup 1)))]
27832 {
27833 rtx op0 = operands[0], op1 = operands[1];
27834 int elt = INTVAL (operands[3]);
27835
27836 if (REG_P (op1))
27837 {
27838 int mask;
27839
27840 if (TARGET_AVX2 && elt == 0)
27841 {
27842 emit_insn (gen_vec_dup<mode> (op0, gen_lowpart (<ssescalarmode>mode,
27843 op1)));
27844 DONE;
27845 }
27846
27847 /* Shuffle element we care about into all elements of the 128-bit lane.
27848 The other lane gets shuffled too, but we don't care. */
27849 if (<MODE>mode == V4DFmode)
27850 mask = (elt & 1 ? 15 : 0);
27851 else
27852 mask = (elt & 3) * 0x55;
27853 emit_insn (gen_avx_vpermil<mode> (op0, op1, GEN_INT (mask)));
27854
27855 /* Shuffle the lane we care about into both lanes of the dest. */
27856 mask = (elt / (<ssescalarnum> / 2)) * 0x11;
27857 if (EXT_REX_SSE_REG_P (op0))
27858 {
27859 /* There is no EVEX VPERM2F128, but we can use either VBROADCASTSS
27860 or VSHUFF128. */
27861 gcc_assert (<MODE>mode == V8SFmode);
27862 if ((mask & 1) == 0)
27863 emit_insn (gen_avx2_vec_dupv8sf (op0,
27864 gen_lowpart (V4SFmode, op0)));
27865 else
27866 emit_insn (gen_avx512vl_shuf_f32x4_1 (op0, op0, op0,
27867 GEN_INT (4), GEN_INT (5),
27868 GEN_INT (6), GEN_INT (7),
27869 GEN_INT (12), GEN_INT (13),
27870 GEN_INT (14), GEN_INT (15)));
27871 DONE;
27872 }
27873
27874 emit_insn (gen_avx_vperm2f128<mode>3 (op0, op0, op0, GEN_INT (mask)));
27875 DONE;
27876 }
27877
27878 operands[1] = adjust_address (op1, <ssescalarmode>mode,
27879 elt * GET_MODE_SIZE (<ssescalarmode>mode));
27880 })
27881
27882 (define_expand "<sse2_avx_avx512f>_vpermil<mode><mask_name>"
27883 [(set (match_operand:VF2 0 "register_operand")
27884 (vec_select:VF2
27885 (match_operand:VF2 1 "nonimmediate_operand")
27886 (match_operand:SI 2 "const_0_to_255_operand")))]
27887 "TARGET_AVX && <mask_mode512bit_condition>"
27888 {
27889 int mask = INTVAL (operands[2]);
27890 rtx perm[<ssescalarnum>];
27891
27892 int i;
27893 for (i = 0; i < <ssescalarnum>; i = i + 2)
27894 {
27895 perm[i] = GEN_INT (((mask >> i) & 1) + i);
27896 perm[i + 1] = GEN_INT (((mask >> (i + 1)) & 1) + i);
27897 }
27898
27899 operands[2]
27900 = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (<ssescalarnum>, perm));
27901 })
27902
27903 (define_expand "<sse2_avx_avx512f>_vpermil<mode><mask_name>"
27904 [(set (match_operand:VF1 0 "register_operand")
27905 (vec_select:VF1
27906 (match_operand:VF1 1 "nonimmediate_operand")
27907 (match_operand:SI 2 "const_0_to_255_operand")))]
27908 "TARGET_AVX && <mask_mode512bit_condition>"
27909 {
27910 int mask = INTVAL (operands[2]);
27911 rtx perm[<ssescalarnum>];
27912
27913 int i;
27914 for (i = 0; i < <ssescalarnum>; i = i + 4)
27915 {
27916 perm[i] = GEN_INT (((mask >> 0) & 3) + i);
27917 perm[i + 1] = GEN_INT (((mask >> 2) & 3) + i);
27918 perm[i + 2] = GEN_INT (((mask >> 4) & 3) + i);
27919 perm[i + 3] = GEN_INT (((mask >> 6) & 3) + i);
27920 }
27921
27922 operands[2]
27923 = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (<ssescalarnum>, perm));
27924 })
27925
27926 ;; This pattern needs to come before the avx2_perm*/avx512f_perm*
27927 ;; patterns, as they have the same RTL representation (vpermilp*
27928 ;; being a subset of what vpermp* can do), but vpermilp* has shorter
27929 ;; latency as it never crosses lanes.
27930 (define_insn "*<sse2_avx_avx512f>_vpermilp<mode><mask_name>"
27931 [(set (match_operand:VF 0 "register_operand" "=v")
27932 (vec_select:VF
27933 (match_operand:VF 1 "nonimmediate_operand" "vm")
27934 (match_parallel 2 ""
27935 [(match_operand 3 "const_int_operand")])))]
27936 "TARGET_AVX && <mask_mode512bit_condition>
27937 && avx_vpermilp_parallel (operands[2], <MODE>mode)"
27938 {
27939 int mask = avx_vpermilp_parallel (operands[2], <MODE>mode) - 1;
27940 operands[2] = GEN_INT (mask);
27941 return "vpermil<ssemodesuffix>\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}";
27942 }
27943 [(set_attr "type" "sselog")
27944 (set_attr "prefix_extra" "1")
27945 (set_attr "length_immediate" "1")
27946 (set_attr "prefix" "<mask_prefix>")
27947 (set_attr "mode" "<sseinsnmode>")])
27948
27949 (define_expand "avx2_perm<mode>"
27950 [(match_operand:VI8F_256 0 "register_operand")
27951 (match_operand:VI8F_256 1 "nonimmediate_operand")
27952 (match_operand:SI 2 "const_0_to_255_operand")]
27953 "TARGET_AVX2"
27954 {
27955 int mask = INTVAL (operands[2]);
27956 emit_insn (gen_avx2_perm<mode>_1 (operands[0], operands[1],
27957 GEN_INT ((mask >> 0) & 3),
27958 GEN_INT ((mask >> 2) & 3),
27959 GEN_INT ((mask >> 4) & 3),
27960 GEN_INT ((mask >> 6) & 3)));
27961 DONE;
27962 })
27963
27964 (define_expand "avx512vl_perm<mode>_mask"
27965 [(match_operand:VI8F_256 0 "register_operand")
27966 (match_operand:VI8F_256 1 "nonimmediate_operand")
27967 (match_operand:SI 2 "const_0_to_255_operand")
27968 (match_operand:VI8F_256 3 "nonimm_or_0_operand")
27969 (match_operand:<avx512fmaskmode> 4 "register_operand")]
27970 "TARGET_AVX512VL"
27971 {
27972 int mask = INTVAL (operands[2]);
27973 emit_insn (gen_<avx2_avx512>_perm<mode>_1_mask (operands[0], operands[1],
27974 GEN_INT ((mask >> 0) & 3),
27975 GEN_INT ((mask >> 2) & 3),
27976 GEN_INT ((mask >> 4) & 3),
27977 GEN_INT ((mask >> 6) & 3),
27978 operands[3], operands[4]));
27979 DONE;
27980 })
27981
27982 (define_insn "avx2_perm<mode>_1<mask_name>"
27983 [(set (match_operand:VI8F_256 0 "register_operand" "=v")
27984 (vec_select:VI8F_256
27985 (match_operand:VI8F_256 1 "nonimmediate_operand" "vm")
27986 (parallel [(match_operand 2 "const_0_to_3_operand")
27987 (match_operand 3 "const_0_to_3_operand")
27988 (match_operand 4 "const_0_to_3_operand")
27989 (match_operand 5 "const_0_to_3_operand")])))]
27990 "TARGET_AVX2 && <mask_mode512bit_condition>"
27991 {
27992 int mask = 0;
27993 mask |= INTVAL (operands[2]) << 0;
27994 mask |= INTVAL (operands[3]) << 2;
27995 mask |= INTVAL (operands[4]) << 4;
27996 mask |= INTVAL (operands[5]) << 6;
27997 operands[2] = GEN_INT (mask);
27998 if (TARGET_DEST_FALSE_DEP_FOR_GLC
27999 && <mask6_dest_false_dep_for_glc_cond>
28000 && !reg_mentioned_p (operands[0], operands[1]))
28001 output_asm_insn ("vxorps\t%x0, %x0, %x0", operands);
28002 return "vperm<ssemodesuffix>\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
28003 }
28004 [(set_attr "type" "sselog")
28005 (set_attr "c86_attr" "perm")
28006 (set_attr "prefix" "<mask_prefix2>")
28007 (set_attr "mode" "<sseinsnmode>")])
28008
28009 (define_expand "avx512f_perm<mode>"
28010 [(match_operand:V8FI 0 "register_operand")
28011 (match_operand:V8FI 1 "nonimmediate_operand")
28012 (match_operand:SI 2 "const_0_to_255_operand")]
28013 "TARGET_AVX512F"
28014 {
28015 int mask = INTVAL (operands[2]);
28016 emit_insn (gen_avx512f_perm<mode>_1 (operands[0], operands[1],
28017 GEN_INT ((mask >> 0) & 3),
28018 GEN_INT ((mask >> 2) & 3),
28019 GEN_INT ((mask >> 4) & 3),
28020 GEN_INT ((mask >> 6) & 3),
28021 GEN_INT (((mask >> 0) & 3) + 4),
28022 GEN_INT (((mask >> 2) & 3) + 4),
28023 GEN_INT (((mask >> 4) & 3) + 4),
28024 GEN_INT (((mask >> 6) & 3) + 4)));
28025 DONE;
28026 })
28027
28028 (define_expand "avx512f_perm<mode>_mask"
28029 [(match_operand:V8FI 0 "register_operand")
28030 (match_operand:V8FI 1 "nonimmediate_operand")
28031 (match_operand:SI 2 "const_0_to_255_operand")
28032 (match_operand:V8FI 3 "nonimm_or_0_operand")
28033 (match_operand:<avx512fmaskmode> 4 "register_operand")]
28034 "TARGET_AVX512F"
28035 {
28036 int mask = INTVAL (operands[2]);
28037 emit_insn (gen_avx512f_perm<mode>_1_mask (operands[0], operands[1],
28038 GEN_INT ((mask >> 0) & 3),
28039 GEN_INT ((mask >> 2) & 3),
28040 GEN_INT ((mask >> 4) & 3),
28041 GEN_INT ((mask >> 6) & 3),
28042 GEN_INT (((mask >> 0) & 3) + 4),
28043 GEN_INT (((mask >> 2) & 3) + 4),
28044 GEN_INT (((mask >> 4) & 3) + 4),
28045 GEN_INT (((mask >> 6) & 3) + 4),
28046 operands[3], operands[4]));
28047 DONE;
28048 })
28049
28050 (define_insn "avx512f_perm<mode>_1<mask_name>"
28051 [(set (match_operand:V8FI 0 "register_operand" "=v")
28052 (vec_select:V8FI
28053 (match_operand:V8FI 1 "nonimmediate_operand" "vm")
28054 (parallel [(match_operand 2 "const_0_to_3_operand")
28055 (match_operand 3 "const_0_to_3_operand")
28056 (match_operand 4 "const_0_to_3_operand")
28057 (match_operand 5 "const_0_to_3_operand")
28058 (match_operand 6 "const_4_to_7_operand")
28059 (match_operand 7 "const_4_to_7_operand")
28060 (match_operand 8 "const_4_to_7_operand")
28061 (match_operand 9 "const_4_to_7_operand")])))]
28062 "TARGET_AVX512F && <mask_mode512bit_condition>
28063 && (INTVAL (operands[2]) == (INTVAL (operands[6]) - 4)
28064 && INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
28065 && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
28066 && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4))"
28067 {
28068 int mask = 0;
28069 mask |= INTVAL (operands[2]) << 0;
28070 mask |= INTVAL (operands[3]) << 2;
28071 mask |= INTVAL (operands[4]) << 4;
28072 mask |= INTVAL (operands[5]) << 6;
28073 operands[2] = GEN_INT (mask);
28074 if (TARGET_DEST_FALSE_DEP_FOR_GLC
28075 && <mask10_dest_false_dep_for_glc_cond>
28076 && !reg_mentioned_p (operands[0], operands[1]))
28077 output_asm_insn ("vxorps\t%x0, %x0, %x0", operands);
28078 return "vperm<ssemodesuffix>\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
28079 }
28080 [(set_attr "type" "sselog")
28081 (set_attr "c86_attr" "perm")
28082 (set_attr "prefix" "<mask_prefix2>")
28083 (set_attr "mode" "<sseinsnmode>")])
28084
28085 ;; TODO (APX): vmovaps supports EGPR but not others, could split
28086 ;; pattern to enable rex2 address for this one.
28087 (define_insn "avx2_permv2ti"
28088 [(set (match_operand:V4DI 0 "register_operand" "=x")
28089 (unspec:V4DI
28090 [(match_operand:V4DI 1 "register_operand" "x")
28091 (match_operand:V4DI 2 "nonimmediate_operand" "xjm")
28092 (match_operand:SI 3 "const_0_to_255_operand")]
28093 UNSPEC_VPERMTI))]
28094 "TARGET_AVX2"
28095 {
28096 int mask = INTVAL (operands[3]);
28097 if ((mask & 0xbb) == 16)
28098 {
28099 if (rtx_equal_p (operands[0], operands[1]))
28100 return "";
28101 else
28102 return "vmovaps\t{%1, %0|%0, %1}";
28103 }
28104 if ((mask & 0xbb) == 50)
28105 {
28106 if (rtx_equal_p (operands[0], operands[2]))
28107 return "";
28108 else
28109 return "vmovaps\t{%2, %0|%0, %2}";
28110 }
28111 if ((mask & 0xbb) == 18)
28112 return "vblendps\t{$15, %2, %1, %0|%0, %1, %2, 15}";
28113 if ((mask & 0xbb) == 48)
28114 return "vblendps\t{$240, %2, %1, %0|%0, %1, %2, 240}";
28115 return "vperm2i128\t{%3, %2, %1, %0|%0, %1, %2, %3}";
28116 }
28117 [(set_attr "type" "sselog")
28118 (set_attr "addr" "gpr16")
28119 (set_attr "prefix" "vex")
28120 (set_attr "mode" "OI")])
28121
28122 (define_insn "avx2_vec_dupv4df"
28123 [(set (match_operand:V4DF 0 "register_operand" "=v")
28124 (vec_duplicate:V4DF
28125 (vec_select:DF
28126 (match_operand:V2DF 1 "register_operand" "v")
28127 (parallel [(const_int 0)]))))]
28128 "TARGET_AVX2"
28129 "vbroadcastsd\t{%1, %0|%0, %1}"
28130 [(set_attr "type" "sselog1")
28131 (set_attr "prefix" "maybe_evex")
28132 (set_attr "mode" "V4DF")])
28133
28134 (define_insn "<avx512>_vec_dup<mode>_1"
28135 [(set (match_operand:VIHFBF_AVX512BW 0 "register_operand" "=v,v")
28136 (vec_duplicate:VIHFBF_AVX512BW
28137 (vec_select:<ssescalarmode>
28138 (match_operand:VIHFBF_AVX512BW 1 "nonimmediate_operand" "v,m")
28139 (parallel [(const_int 0)]))))]
28140 "TARGET_AVX512F"
28141 "@
28142 vpbroadcast<sseintmodesuffix>\t{%x1, %0|%0, %x1}
28143 vpbroadcast<sseintmodesuffix>\t{%x1, %0|%0, %<iptr>1}"
28144 [(set_attr "type" "ssemov")
28145 (set_attr "prefix" "evex")
28146 (set_attr "mode" "<sseinsnmode>")])
28147
28148 (define_insn "<avx512>_vec_dup<mode><mask_name>"
28149 [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v")
28150 (vec_duplicate:V48_AVX512VL
28151 (vec_select:<ssescalarmode>
28152 (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
28153 (parallel [(const_int 0)]))))]
28154 "TARGET_AVX512F"
28155 {
28156 /* There is no DF broadcast (in AVX-512*) to 128b register.
28157 Mimic it with vmovddup, just like vec_dupv2df<mask_name> does. */
28158 if (<MODE>mode == V2DFmode)
28159 return "vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}";
28160
28161 return "v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %<iptr>1}";
28162 }
28163 [(set_attr "type" "ssemov")
28164 (set_attr "prefix" "evex")
28165 (set_attr "mode" "<sseinsnmode>")])
28166
28167 (define_insn "<avx512>_vec_dup<mode><mask_name>"
28168 [(set (match_operand:VI12HFBF_AVX512VL 0 "register_operand" "=v")
28169 (vec_duplicate:VI12HFBF_AVX512VL
28170 (vec_select:<ssescalarmode>
28171 (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
28172 (parallel [(const_int 0)]))))]
28173 "TARGET_AVX512BW"
28174 "vpbroadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %<iptr>1}"
28175 [(set_attr "type" "ssemov")
28176 (set_attr "prefix" "evex")
28177 (set_attr "mode" "<sseinsnmode>")])
28178
28179 (define_insn "<mask_codefor>avx512f_broadcast<mode><mask_name>"
28180 [(set (match_operand:V16FI 0 "register_operand" "=v,v")
28181 (vec_duplicate:V16FI
28182 (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "v,m")))]
28183 "TARGET_AVX512F"
28184 "@
28185 vshuf<shuffletype>32x4\t{$0x0, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x0}
28186 vbroadcast<shuffletype>32x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
28187 [(set_attr "type" "ssemov")
28188 (set_attr "c86_attr" "shufx,*")
28189 (set_attr "prefix" "evex")
28190 (set_attr "mode" "<sseinsnmode>")])
28191
28192 (define_insn "<mask_codefor>avx512f_broadcast<mode><mask_name>"
28193 [(set (match_operand:V8FI 0 "register_operand" "=v,v")
28194 (vec_duplicate:V8FI
28195 (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "v,m")))]
28196 "TARGET_AVX512F"
28197 "@
28198 vshuf<shuffletype>64x2\t{$0x44, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x44}
28199 vbroadcast<shuffletype>64x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
28200 [(set_attr "type" "ssemov")
28201 (set_attr "c86_attr" "shufx,*")
28202 (set_attr "prefix" "evex")
28203 (set_attr "mode" "<sseinsnmode>")])
28204
28205 (define_insn "<mask_codefor><avx512>_vec_dup_gpr<mode><mask_name>"
28206 [(set (match_operand:VI12HFBF_AVX512VL 0 "register_operand" "=v,v")
28207 (vec_duplicate:VI12HFBF_AVX512VL
28208 (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "vm,r")))]
28209 "TARGET_AVX512BW"
28210 "@
28211 vpbroadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}
28212 vpbroadcast<bcstscalarsuff>\t{%k1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
28213 [(set_attr "type" "ssemov")
28214 (set_attr "prefix" "evex")
28215 (set_attr "mode" "<sseinsnmode>")])
28216
28217 (define_insn "<mask_codefor><avx512>_vec_dup_gpr<mode><mask_name>"
28218 [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v,v")
28219 (vec_duplicate:V48_AVX512VL
28220 (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "vm,r")))]
28221 "TARGET_AVX512F"
28222 "v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
28223 [(set_attr "type" "ssemov")
28224 (set_attr "prefix" "evex")
28225 (set_attr "mode" "<sseinsnmode>")
28226 (set (attr "enabled")
28227 (if_then_else (eq_attr "alternative" "1")
28228 (symbol_ref "GET_MODE_CLASS (<ssescalarmode>mode) == MODE_INT
28229 && (<ssescalarmode>mode != DImode || TARGET_64BIT)")
28230 (const_int 1)))])
28231
28232 (define_insn "vec_dupv4sf"
28233 [(set (match_operand:V4SF 0 "register_operand" "=v,v,v,x")
28234 (vec_duplicate:V4SF
28235 (match_operand:SF 1 "nonimmediate_operand" "Yv,v,m,0")))]
28236 "TARGET_SSE"
28237 "@
28238 * return TARGET_AVX2 ? \"vbroadcastss\t{%1, %0|%0, %1}\" : \"vshufps\t{$0, %d1, %0|%0, %d1, 0}\";
28239 vbroadcastss\t{%1, %g0|%g0, %1}
28240 vbroadcastss\t{%1, %0|%0, %1}
28241 shufps\t{$0, %0, %0|%0, %0, 0}"
28242 [(set_attr "isa" "avx,*,avx,noavx")
28243 (set (attr "type")
28244 (cond [(and (eq_attr "alternative" "0")
28245 (match_test "!TARGET_AVX2"))
28246 (const_string "sseshuf1")
28247 (eq_attr "alternative" "3")
28248 (const_string "sseshuf1")
28249 ]
28250 (const_string "ssemov")))
28251 (set (attr "length_immediate")
28252 (if_then_else (eq_attr "type" "sseshuf1")
28253 (const_string "1")
28254 (const_string "0")))
28255 (set_attr "prefix_extra" "0,1,1,*")
28256 (set_attr "prefix" "maybe_evex,evex,maybe_evex,orig")
28257 (set_attr "mode" "V4SF,V16SF,V4SF,V4SF")
28258 (set (attr "enabled")
28259 (if_then_else (eq_attr "alternative" "1")
28260 (symbol_ref "TARGET_AVX512F && !TARGET_AVX512VL
28261 && TARGET_EVEX512 && !TARGET_PREFER_AVX256")
28262 (const_string "*")))])
28263
28264 (define_insn "*vec_dupv4si"
28265 [(set (match_operand:V4SI 0 "register_operand" "=v,v,v,v,x")
28266 (vec_duplicate:V4SI
28267 (match_operand:SI 1 "nonimmediate_operand" "Yvm,v,Yv,m,0")))]
28268 "TARGET_SSE"
28269 "@
28270 vpbroadcastd\t{%1, %0|%0, %1}
28271 vpbroadcastd\t{%1, %g0|%g0, %1}
28272 %vpshufd\t{$0, %1, %0|%0, %1, 0}
28273 vbroadcastss\t{%1, %0|%0, %1}
28274 shufps\t{$0, %0, %0|%0, %0, 0}"
28275 [(set_attr "isa" "avx2,*,sse2,avx,noavx")
28276 (set_attr "type" "ssemov,ssemov,sseshuf1,ssemov,sseshuf1")
28277 (set_attr "length_immediate" "0,0,1,0,1")
28278 (set_attr "prefix_extra" "1,1,0,1,*")
28279 (set_attr "prefix" "maybe_evex,evex,maybe_vex,maybe_evex,orig")
28280 (set_attr "mode" "TI,XI,TI,V4SF,V4SF")
28281 (set (attr "preferred_for_speed")
28282 (cond [(eq_attr "alternative" "3")
28283 (symbol_ref "!TARGET_INTER_UNIT_MOVES_TO_VEC")
28284 ]
28285 (symbol_ref "true")))
28286 (set (attr "enabled")
28287 (if_then_else (eq_attr "alternative" "1")
28288 (symbol_ref "TARGET_AVX512F && !TARGET_AVX512VL
28289 && TARGET_EVEX512 && !TARGET_PREFER_AVX256")
28290 (const_string "*")))])
28291
28292 (define_insn "*vec_dupv2di"
28293 [(set (match_operand:V2DI 0 "register_operand" "=x,v,v,v,x")
28294 (vec_duplicate:V2DI
28295 (match_operand:DI 1 "nonimmediate_operand" " 0,Yv,vm,Yvm,0")))]
28296 "TARGET_SSE"
28297 "@
28298 punpcklqdq\t%0, %0
28299 vpunpcklqdq\t{%d1, %0|%0, %d1}
28300 * return TARGET_AVX512VL ? \"vpbroadcastq\t{%1, %0|%0, %1}\" : \"vpbroadcastq\t{%1, %g0|%g0, %1}\";
28301 %vmovddup\t{%1, %0|%0, %1}
28302 movlhps\t%0, %0"
28303 [(set_attr "isa" "sse2_noavx,avx,avx512f,sse3,noavx")
28304 (set_attr "type" "sselog1,sselog1,ssemov,sselog1,ssemov")
28305 (set_attr "prefix" "orig,maybe_evex,evex,maybe_vex,orig")
28306 (set (attr "mode")
28307 (cond [(and (eq_attr "alternative" "2")
28308 (match_test "!TARGET_AVX512VL"))
28309 (const_string "XI")
28310 (eq_attr "alternative" "3")
28311 (const_string "DF")
28312 (eq_attr "alternative" "4")
28313 (const_string "V4SF")
28314 ]
28315 (const_string "TI")))
28316 (set (attr "enabled")
28317 (if_then_else
28318 (eq_attr "alternative" "2")
28319 (symbol_ref "TARGET_AVX512VL
28320 || (TARGET_AVX512F && TARGET_EVEX512
28321 && !TARGET_PREFER_AVX256)")
28322 (const_string "*")))])
28323
28324 (define_insn "avx2_vbroadcasti128_<mode>"
28325 [(set (match_operand:VI_256 0 "register_operand" "=x,v,v")
28326 (vec_concat:VI_256
28327 (match_operand:<ssehalfvecmode> 1 "memory_operand" "jm,m,m")
28328 (match_dup 1)))]
28329 "TARGET_AVX2"
28330 "@
28331 vbroadcasti128\t{%1, %0|%0, %1}
28332 vbroadcast<i128vldq>\t{%1, %0|%0, %1}
28333 vbroadcast<shuffletype>32x4\t{%1, %0|%0, %1}"
28334 [(set_attr "isa" "noavx512vl,avx512dq,avx512vl")
28335 (set_attr "type" "ssemov")
28336 (set_attr "prefix_extra" "1")
28337 (set_attr "prefix" "vex,evex,evex")
28338 (set_attr "addr" "gpr16,*,*")
28339 (set_attr "mode" "OI")])
28340
28341 ;; optimize vlddqu + vinserti128 to vbroadcasti128, the former will use
28342 ;; extra shuffle port in addition to load port than the latter.
28343 ;; For latency perspective,vbroadcasti is no worse.
28344 (define_insn_and_split "avx2_lddqu_inserti_to_bcasti"
28345 [(set (match_operand:V4DI 0 "register_operand" "=x,v,v")
28346 (vec_concat:V4DI
28347 (subreg:V2DI
28348 (unspec:V16QI [(match_operand:V16QI 1 "memory_operand")]
28349 UNSPEC_LDDQU) 0)
28350 (subreg:V2DI (unspec:V16QI [(match_dup 1)]
28351 UNSPEC_LDDQU) 0)))]
28352 "TARGET_AVX2 && ix86_pre_reload_split ()"
28353 "#"
28354 "&& 1"
28355 [(set (match_dup 0)
28356 (vec_concat:V4DI (match_dup 1) (match_dup 1)))]
28357 "operands[1] = adjust_address_nv (operands[1], V2DImode, 0);")
28358
28359 ;; Modes handled by AVX vec_dup patterns.
28360 (define_mode_iterator AVX_VEC_DUP_MODE
28361 [V8SI V8SF V4DI V4DF])
28362 (define_mode_attr vecdupssescalarmodesuffix
28363 [(V8SF "ss") (V4DF "sd") (V8SI "ss") (V4DI "sd")])
28364 ;; Modes handled by AVX2 vec_dup patterns.
28365 (define_mode_iterator AVX2_VEC_DUP_MODE
28366 [V32QI V16QI V16HI V8HI V8SI V4SI V16HF V8HF V16BF V8BF])
28367
28368 (define_insn "*vec_dup<mode>"
28369 [(set (match_operand:AVX2_VEC_DUP_MODE 0 "register_operand" "=x,x,v")
28370 (vec_duplicate:AVX2_VEC_DUP_MODE
28371 (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,x,$r")))]
28372 "TARGET_AVX2"
28373 "@
28374 v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0|%0, %1}
28375 v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}
28376 #"
28377 [(set_attr "isa" "*,*,noavx512vl")
28378 (set_attr "type" "ssemov")
28379 (set_attr "prefix_extra" "1")
28380 (set_attr "prefix" "maybe_evex")
28381 (set_attr "mode" "<sseinsnmode>")
28382 (set (attr "preferred_for_speed")
28383 (cond [(eq_attr "alternative" "2")
28384 (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
28385 ]
28386 (symbol_ref "true")))])
28387
28388 (define_insn "vec_dup<mode>"
28389 [(set (match_operand:AVX_VEC_DUP_MODE 0 "register_operand" "=x,x,x,v,x")
28390 (vec_duplicate:AVX_VEC_DUP_MODE
28391 (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,m,x,v,?x")))]
28392 "TARGET_AVX"
28393 "@
28394 v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0|%0, %1}
28395 vbroadcast<vecdupssescalarmodesuffix>\t{%1, %0|%0, %1}
28396 v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}
28397 v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %g0|%g0, %x1}
28398 #"
28399 [(set_attr "type" "ssemov")
28400 (set_attr "prefix_extra" "1")
28401 (set_attr "prefix" "maybe_evex")
28402 (set_attr "isa" "avx2,noavx2,avx2,avx512f_512,noavx2")
28403 (set_attr "mode" "<sseinsnmode>,V8SF,<sseinsnmode>,<sseinsnmode>,V8SF")])
28404
28405 (define_split
28406 [(set (match_operand:AVX2_VEC_DUP_MODE 0 "register_operand")
28407 (vec_duplicate:AVX2_VEC_DUP_MODE
28408 (match_operand:<ssescalarmode> 1 "register_operand")))]
28409 "TARGET_AVX2
28410 /* Disable this splitter if avx512vl_vec_dup_gprv*[qhs]i insn is
28411 available, because then we can broadcast from GPRs directly.
28412 For V*[QH]I modes it requires both -mavx512vl and -mavx512bw,
28413 for V*SI mode it requires just -mavx512vl. */
28414 && !(TARGET_AVX512VL
28415 && (TARGET_AVX512BW || <ssescalarmode>mode == SImode))
28416 && reload_completed && GENERAL_REG_P (operands[1])"
28417 [(const_int 0)]
28418 {
28419 emit_insn (gen_vec_setv4si_0 (gen_lowpart (V4SImode, operands[0]),
28420 CONST0_RTX (V4SImode),
28421 gen_lowpart (SImode, operands[1])));
28422 emit_insn (gen_avx2_pbroadcast<mode> (operands[0],
28423 gen_lowpart (<ssexmmmode>mode,
28424 operands[0])));
28425 DONE;
28426 })
28427
28428 (define_split
28429 [(set (match_operand:AVX_VEC_DUP_MODE 0 "register_operand")
28430 (vec_duplicate:AVX_VEC_DUP_MODE
28431 (match_operand:<ssescalarmode> 1 "register_operand")))]
28432 "TARGET_AVX && !TARGET_AVX2 && reload_completed"
28433 [(set (match_dup 2)
28434 (vec_duplicate:<ssehalfvecmode> (match_dup 1)))
28435 (set (match_dup 0)
28436 (vec_concat:AVX_VEC_DUP_MODE (match_dup 2) (match_dup 2)))]
28437 "operands[2] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);")
28438
28439 (define_insn "avx_vbroadcastf128_<mode>"
28440 [(set (match_operand:V_256 0 "register_operand" "=x,x,x,v,v,v,v")
28441 (vec_concat:V_256
28442 (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "jm,0,?x,m,0,m,0")
28443 (match_dup 1)))]
28444 "TARGET_AVX"
28445 "@
28446 vbroadcast<i128>\t{%1, %0|%0, %1}
28447 vinsert<i128>\t{$1, %1, %0, %0|%0, %0, %1, 1}
28448 vperm2<i128>\t{$0, %t1, %t1, %0|%0, %t1, %t1, 0}
28449 vbroadcast<i128vldq>\t{%1, %0|%0, %1}
28450 vinsert<i128vldq>\t{$1, %1, %0, %0|%0, %0, %1, 1}
28451 vbroadcast<shuffletype>32x4\t{%1, %0|%0, %1}
28452 vinsert<shuffletype>32x4\t{$1, %1, %0, %0|%0, %0, %1, 1}"
28453 [(set_attr "isa" "noavx512vl,*,*,avx512dq,avx512dq,avx512vl,avx512vl")
28454 (set_attr "type" "ssemov,sselog1,sselog1,ssemov,sselog1,ssemov,sselog1")
28455 (set_attr "c86_attr" "*,insertx,*,*,insertx,*,insertx")
28456 (set (attr "addr")
28457 (if_then_else (eq_attr "alternative" "0")
28458 (const_string "gpr16")
28459 (const_string "*")))
28460 (set_attr "prefix_extra" "1")
28461 (set_attr "length_immediate" "0,1,1,0,1,0,1")
28462 (set_attr "prefix" "vex,vex,vex,evex,evex,evex,evex")
28463 (set_attr "mode" "<sseinsnmode>")])
28464
28465 ;; For broadcast[i|f]32x2. Yes there is no v4sf version, only v4si.
28466 (define_mode_iterator VI4F_BRCST32x2
28467 [(V16SI "TARGET_EVEX512") (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
28468 (V16SF "TARGET_EVEX512") (V8SF "TARGET_AVX512VL")])
28469
28470 (define_mode_attr 64x2mode
28471 [(V8DF "V2DF") (V8DI "V2DI") (V4DI "V2DI") (V4DF "V2DF")])
28472
28473 (define_mode_attr 32x2mode
28474 [(V16SF "V2SF") (V16SI "V2SI") (V8SI "V2SI")
28475 (V8SF "V2SF") (V4SI "V2SI")])
28476
28477 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>"
28478 [(set (match_operand:VI4F_BRCST32x2 0 "register_operand" "=v")
28479 (vec_duplicate:VI4F_BRCST32x2
28480 (vec_select:<32x2mode>
28481 (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
28482 (parallel [(const_int 0) (const_int 1)]))))]
28483 "TARGET_AVX512DQ"
28484 "vbroadcast<shuffletype>32x2\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
28485 [(set_attr "type" "ssemov")
28486 (set_attr "prefix_extra" "1")
28487 (set_attr "prefix" "evex")
28488 (set_attr "mode" "<sseinsnmode>")])
28489
28490 (define_insn "<mask_codefor>avx512vl_broadcast<mode><mask_name>_1"
28491 [(set (match_operand:VI4F_256 0 "register_operand" "=v,v")
28492 (vec_duplicate:VI4F_256
28493 (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "v,m")))]
28494 "TARGET_AVX512VL"
28495 "@
28496 vshuf<shuffletype>32x4\t{$0x0, %t1, %t1, %0<mask_operand2>|%0<mask_operand2>, %t1, %t1, 0x0}
28497 vbroadcast<shuffletype>32x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
28498 [(set_attr "type" "ssemov")
28499 (set_attr "c86_attr" "shufx,*")
28500 (set_attr "prefix_extra" "1")
28501 (set_attr "prefix" "evex")
28502 (set_attr "mode" "<sseinsnmode>")])
28503
28504 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>_1"
28505 [(set (match_operand:V16FI 0 "register_operand" "=v,v")
28506 (vec_duplicate:V16FI
28507 (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "v,m")))]
28508 "TARGET_AVX512DQ"
28509 "@
28510 vshuf<shuffletype>32x4\t{$0x44, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x44}
28511 vbroadcast<shuffletype>32x8\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
28512 [(set_attr "type" "ssemov")
28513 (set_attr "c86_attr" "shufx,*")
28514 (set_attr "length_immediate" "1,*")
28515 (set_attr "prefix" "evex")
28516 (set_attr "mode" "<sseinsnmode>")])
28517
28518 ;; For broadcast[i|f]64x2
28519 (define_mode_iterator VI8F_BRCST64x2
28520 [(V8DI "TARGET_EVEX512") (V8DF "TARGET_EVEX512")
28521 (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")])
28522
28523 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>_1"
28524 [(set (match_operand:VI8F_BRCST64x2 0 "register_operand" "=v,v")
28525 (vec_duplicate:VI8F_BRCST64x2
28526 (match_operand:<64x2mode> 1 "nonimmediate_operand" "v,m")))]
28527 "TARGET_AVX512DQ"
28528 "@
28529 vshuf<shuffletype>64x2\t{$0x0, %<xtg_mode>1, %<xtg_mode>1, %0<mask_operand2>|%0<mask_operand2>, %<xtg_mode>1, %<xtg_mode>1, 0x0}
28530 vbroadcast<shuffletype>64x2\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
28531 [(set_attr "type" "ssemov")
28532 (set_attr "c86_attr" "shufx,*")
28533 (set_attr "length_immediate" "1")
28534 (set_attr "prefix" "evex")
28535 (set_attr "mode" "<sseinsnmode>")])
28536
28537 ;; Use unspec to prevent rtl optimizer to optimize zero_extend + vec_duplicate
28538 ;; to pbroadcastm, there could be an extra kmov after RA.
28539 (define_insn "avx512cd_maskb_vec_dup<mode>"
28540 [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
28541 (vec_duplicate:VI8_AVX512VL
28542 (zero_extend:DI
28543 (match_operand:QI 1 "register_operand" "k"))))
28544 (unspec [(const_int 0)] UNSPEC_MASKOP)]
28545 "TARGET_AVX512CD"
28546 "vpbroadcastmb2q\t{%1, %0|%0, %1}"
28547 [(set_attr "type" "mskmov")
28548 (set_attr "prefix" "evex")
28549 (set_attr "mode" "XI")])
28550
28551 (define_insn "avx512cd_maskw_vec_dup<mode>"
28552 [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
28553 (vec_duplicate:VI4_AVX512VL
28554 (zero_extend:SI
28555 (match_operand:HI 1 "register_operand" "k"))))
28556 (unspec [(const_int 0)] UNSPEC_MASKOP)]
28557 "TARGET_AVX512CD"
28558 "vpbroadcastmw2d\t{%1, %0|%0, %1}"
28559 [(set_attr "type" "mskmov")
28560 (set_attr "prefix" "evex")
28561 (set_attr "mode" "XI")])
28562
28563 (define_insn "<sse2_avx_avx512f>_vpermilvar<mode>3<mask_name>"
28564 [(set (match_operand:VF 0 "register_operand" "=v")
28565 (unspec:VF
28566 [(match_operand:VF 1 "register_operand" "v")
28567 (match_operand:<sseintvecmode> 2 "nonimmediate_operand" "vm")]
28568 UNSPEC_VPERMIL))]
28569 "TARGET_AVX && <mask_mode512bit_condition>"
28570 "vpermil<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
28571 [(set_attr "type" "sselog")
28572 (set_attr "prefix_extra" "1")
28573 (set_attr "btver2_decode" "vector")
28574 (set_attr "prefix" "<mask_prefix>")
28575 (set_attr "mode" "<sseinsnmode>")])
28576
28577 (define_mode_iterator VPERMI2
28578 [(V16SI "TARGET_EVEX512") (V16SF "TARGET_EVEX512")
28579 (V8DI "TARGET_EVEX512") (V8DF "TARGET_EVEX512")
28580 (V8SI "TARGET_AVX512VL") (V8SF "TARGET_AVX512VL")
28581 (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")
28582 (V4SI "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
28583 (V2DI "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")
28584 (V32HI "TARGET_AVX512BW && TARGET_EVEX512")
28585 (V16HI "TARGET_AVX512BW && TARGET_AVX512VL")
28586 (V8HI "TARGET_AVX512BW && TARGET_AVX512VL")
28587 (V64QI "TARGET_AVX512VBMI && TARGET_EVEX512")
28588 (V32QI "TARGET_AVX512VBMI && TARGET_AVX512VL")
28589 (V16QI "TARGET_AVX512VBMI && TARGET_AVX512VL")])
28590
28591 (define_mode_iterator VPERMI2I
28592 [(V16SI "TARGET_EVEX512") (V8DI "TARGET_EVEX512")
28593 (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
28594 (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")
28595 (V32HI "TARGET_AVX512BW && TARGET_EVEX512")
28596 (V16HI "TARGET_AVX512BW && TARGET_AVX512VL")
28597 (V8HI "TARGET_AVX512BW && TARGET_AVX512VL")
28598 (V64QI "TARGET_AVX512VBMI && TARGET_EVEX512")
28599 (V32QI "TARGET_AVX512VBMI && TARGET_AVX512VL")
28600 (V16QI "TARGET_AVX512VBMI && TARGET_AVX512VL")])
28601
28602 (define_expand "<avx512>_vpermi2var<mode>3_mask"
28603 [(set (match_operand:VPERMI2 0 "register_operand")
28604 (vec_merge:VPERMI2
28605 (unspec:VPERMI2
28606 [(match_operand:<sseintvecmode> 2 "register_operand")
28607 (match_operand:VPERMI2 1 "register_operand")
28608 (match_operand:VPERMI2 3 "nonimmediate_operand")]
28609 UNSPEC_VPERMT2)
28610 (match_dup 5)
28611 (match_operand:<avx512fmaskmode> 4 "register_operand")))]
28612 "TARGET_AVX512F"
28613 {
28614 operands[2] = force_reg (<sseintvecmode>mode, operands[2]);
28615 operands[5] = gen_lowpart (<MODE>mode, operands[2]);
28616 })
28617
28618 (define_insn "*<avx512>_vpermi2var<mode>3_mask"
28619 [(set (match_operand:VPERMI2I 0 "register_operand" "=v")
28620 (vec_merge:VPERMI2I
28621 (unspec:VPERMI2I
28622 [(match_operand:<sseintvecmode> 2 "register_operand" "0")
28623 (match_operand:VPERMI2I 1 "register_operand" "v")
28624 (match_operand:VPERMI2I 3 "nonimmediate_operand" "vm")]
28625 UNSPEC_VPERMT2)
28626 (match_dup 2)
28627 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
28628 "TARGET_AVX512F"
28629 "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
28630 [(set_attr "type" "sselog")
28631 (set_attr "c86_attr" "perm2")
28632 (set_attr "prefix" "evex")
28633 (set_attr "mode" "<sseinsnmode>")])
28634
28635 (define_insn "*<avx512>_vpermi2var<mode>3_mask"
28636 [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
28637 (vec_merge:VF_AVX512VL
28638 (unspec:VF_AVX512VL
28639 [(match_operand:<sseintvecmode> 2 "register_operand" "0")
28640 (match_operand:VF_AVX512VL 1 "register_operand" "v")
28641 (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "vm")]
28642 UNSPEC_VPERMT2)
28643 (subreg:VF_AVX512VL (match_dup 2) 0)
28644 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
28645 "TARGET_AVX512F"
28646 "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
28647 [(set_attr "type" "sselog")
28648 (set_attr "c86_attr" "perm2")
28649 (set_attr "prefix" "evex")
28650 (set_attr "mode" "<sseinsnmode>")])
28651
28652 (define_expand "<avx512>_vpermt2var<mode>3_maskz"
28653 [(match_operand:VPERMI2 0 "register_operand")
28654 (match_operand:<sseintvecmode> 1 "register_operand")
28655 (match_operand:VPERMI2 2 "register_operand")
28656 (match_operand:VPERMI2 3 "nonimmediate_operand")
28657 (match_operand:<avx512fmaskmode> 4 "register_operand")]
28658 "TARGET_AVX512F"
28659 {
28660 emit_insn (gen_<avx512>_vpermt2var<mode>3_maskz_1 (
28661 operands[0], operands[1], operands[2], operands[3],
28662 CONST0_RTX (<MODE>mode), operands[4]));
28663 DONE;
28664 })
28665
28666 (define_insn "<avx512>_vpermt2var<mode>3<sd_maskz_name>"
28667 [(set (match_operand:VPERMI2 0 "register_operand" "=v,v")
28668 (unspec:VPERMI2
28669 [(match_operand:<sseintvecmode> 1 "register_operand" "v,0")
28670 (match_operand:VPERMI2 2 "register_operand" "0,v")
28671 (match_operand:VPERMI2 3 "nonimmediate_operand" "vm,vm")]
28672 UNSPEC_VPERMT2))]
28673 "TARGET_AVX512F"
28674 "@
28675 vpermt2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}
28676 vpermi2<ssemodesuffix>\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}"
28677 [(set_attr "type" "sselog")
28678 (set_attr "c86_attr" "perm2")
28679 (set_attr "prefix" "evex")
28680 (set_attr "mode" "<sseinsnmode>")])
28681
28682 (define_insn "<avx512>_vpermt2var<mode>3<sd_maskz_name>"
28683 [(set (match_operand:VHFBF_AVX512VL 0 "register_operand" "=v,v")
28684 (unspec:VHFBF_AVX512VL
28685 [(match_operand:<sseintvecmode> 1 "register_operand" "v,0")
28686 (match_operand:VHFBF_AVX512VL 2 "register_operand" "0,v")
28687 (match_operand:VHFBF_AVX512VL 3 "nonimmediate_operand" "vm,vm")]
28688 UNSPEC_VPERMT2))]
28689 "TARGET_AVX512BW"
28690 "@
28691 vpermt2w\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}
28692 vpermi2w\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}"
28693 [(set_attr "type" "sselog")
28694 (set_attr "prefix" "evex")
28695 (set_attr "mode" "<sseinsnmode>")])
28696
28697 (define_insn "<avx512>_vpermt2var<mode>3_mask"
28698 [(set (match_operand:VPERMI2 0 "register_operand" "=v")
28699 (vec_merge:VPERMI2
28700 (unspec:VPERMI2
28701 [(match_operand:<sseintvecmode> 1 "register_operand" "v")
28702 (match_operand:VPERMI2 2 "register_operand" "0")
28703 (match_operand:VPERMI2 3 "nonimmediate_operand" "vm")]
28704 UNSPEC_VPERMT2)
28705 (match_dup 2)
28706 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
28707 "TARGET_AVX512F"
28708 "vpermt2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
28709 [(set_attr "type" "sselog")
28710 (set_attr "c86_attr" "perm2")
28711 (set_attr "prefix" "evex")
28712 (set_attr "mode" "<sseinsnmode>")])
28713
28714 (define_expand "avx_vperm2f128<mode>3"
28715 [(set (match_operand:AVX256MODE2P 0 "register_operand")
28716 (unspec:AVX256MODE2P
28717 [(match_operand:AVX256MODE2P 1 "register_operand")
28718 (match_operand:AVX256MODE2P 2 "nonimmediate_operand")
28719 (match_operand:SI 3 "const_0_to_255_operand")]
28720 UNSPEC_VPERMIL2F128))]
28721 "TARGET_AVX"
28722 {
28723 int mask = INTVAL (operands[3]);
28724 if ((mask & 0x88) == 0)
28725 {
28726 rtx perm[<ssescalarnum>], t1, t2;
28727 int i, base, nelt = <ssescalarnum>, nelt2 = nelt / 2;
28728
28729 base = (mask & 3) * nelt2;
28730 for (i = 0; i < nelt2; ++i)
28731 perm[i] = GEN_INT (base + i);
28732
28733 base = ((mask >> 4) & 3) * nelt2;
28734 for (i = 0; i < nelt2; ++i)
28735 perm[i + nelt2] = GEN_INT (base + i);
28736
28737 t2 = gen_rtx_VEC_CONCAT (<ssedoublevecmode>mode,
28738 operands[1], operands[2]);
28739 t1 = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (nelt, perm));
28740 t2 = gen_rtx_VEC_SELECT (<MODE>mode, t2, t1);
28741 t2 = gen_rtx_SET (operands[0], t2);
28742 emit_insn (t2);
28743 DONE;
28744 }
28745 })
28746
28747 ;; Note that bits 7 and 3 of the imm8 allow lanes to be zeroed, which
28748 ;; means that in order to represent this properly in rtl we'd have to
28749 ;; nest *another* vec_concat with a zero operand and do the select from
28750 ;; a 4x wide vector. That doesn't seem very nice.
28751 (define_insn "*avx_vperm2f128<mode>_full"
28752 [(set (match_operand:AVX256MODE2P 0 "register_operand" "=x")
28753 (unspec:AVX256MODE2P
28754 [(match_operand:AVX256MODE2P 1 "register_operand" "x")
28755 (match_operand:AVX256MODE2P 2 "nonimmediate_operand" "xjm")
28756 (match_operand:SI 3 "const_0_to_255_operand")]
28757 UNSPEC_VPERMIL2F128))]
28758 "TARGET_AVX"
28759 "vperm2<i128>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
28760 [(set_attr "type" "sselog")
28761 (set_attr "addr" "gpr16")
28762 (set_attr "prefix_extra" "1")
28763 (set_attr "length_immediate" "1")
28764 (set_attr "prefix" "vex")
28765 (set_attr "mode" "<sseinsnmode>")])
28766
28767 (define_insn "*avx_vperm2f128<mode>_nozero"
28768 [(set (match_operand:AVX256MODE2P 0 "register_operand" "=x")
28769 (vec_select:AVX256MODE2P
28770 (vec_concat:<ssedoublevecmode>
28771 (match_operand:AVX256MODE2P 1 "register_operand" "x")
28772 (match_operand:AVX256MODE2P 2 "nonimmediate_operand" "xjm"))
28773 (match_parallel 3 ""
28774 [(match_operand 4 "const_int_operand")])))]
28775 "TARGET_AVX
28776 && avx_vperm2f128_parallel (operands[3], <MODE>mode)"
28777 {
28778 int mask = avx_vperm2f128_parallel (operands[3], <MODE>mode) - 1;
28779 if ((mask & 0xbb) == 0x12)
28780 return "vblendps\t{$15, %2, %1, %0|%0, %1, %2, 15}";
28781 if ((mask & 0xbb) == 0x30)
28782 return "vblendps\t{$240, %2, %1, %0|%0, %1, %2, 240}";
28783 if ((mask & 0xbb) == 0x20)
28784 return "vinsert<i128>\t{$1, %x2, %1, %0|%0, %1, %x2, 1}";
28785 operands[3] = GEN_INT (mask);
28786 return "vperm2<i128>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
28787 }
28788 [(set_attr "type" "sselog")
28789 (set_attr "c86_attr" "insertx")
28790 (set_attr "addr" "gpr16")
28791 (set_attr "prefix_extra" "1")
28792 (set_attr "length_immediate" "1")
28793 (set_attr "prefix" "vex")
28794 (set_attr "mode" "<sseinsnmode>")])
28795
28796 (define_insn "*ssse3_palignr<mode>_perm"
28797 [(set (match_operand:V_128 0 "register_operand" "=x,Yw")
28798 (vec_select:V_128
28799 (match_operand:V_128 1 "register_operand" "0,Yw")
28800 (match_parallel 2 "palignr_operand"
28801 [(match_operand 3 "const_int_operand")])))]
28802 "TARGET_SSSE3"
28803 {
28804 operands[2] = (GEN_INT (INTVAL (operands[3])
28805 * GET_MODE_UNIT_SIZE (GET_MODE (operands[0]))));
28806
28807 switch (which_alternative)
28808 {
28809 case 0:
28810 return "palignr\t{%2, %1, %0|%0, %1, %2}";
28811 case 1:
28812 return "vpalignr\t{%2, %1, %1, %0|%0, %1, %1, %2}";
28813 default:
28814 gcc_unreachable ();
28815 }
28816 }
28817 [(set_attr "isa" "noavx,avx")
28818 (set_attr "type" "sseishft")
28819 (set_attr "atom_unit" "sishuf")
28820 (set_attr "prefix_data16" "1,*")
28821 (set_attr "prefix_extra" "1")
28822 (set_attr "length_immediate" "1")
28823 (set_attr "prefix" "orig,maybe_evex")])
28824
28825 (define_expand "avx512vl_vinsert<mode>"
28826 [(match_operand:VI48F_256 0 "register_operand")
28827 (match_operand:VI48F_256 1 "register_operand")
28828 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
28829 (match_operand:SI 3 "const_0_to_1_operand")
28830 (match_operand:VI48F_256 4 "register_operand")
28831 (match_operand:<avx512fmaskmode> 5 "register_operand")]
28832 "TARGET_AVX512VL"
28833 {
28834 rtx (*insn)(rtx, rtx, rtx, rtx, rtx);
28835
28836 switch (INTVAL (operands[3]))
28837 {
28838 case 0:
28839 insn = gen_vec_set_lo_<mode>_mask;
28840 break;
28841 case 1:
28842 insn = gen_vec_set_hi_<mode>_mask;
28843 break;
28844 default:
28845 gcc_unreachable ();
28846 }
28847
28848 emit_insn (insn (operands[0], operands[1], operands[2], operands[4],
28849 operands[5]));
28850 DONE;
28851 })
28852
28853 (define_expand "avx_vinsertf128<mode>"
28854 [(match_operand:V_256 0 "register_operand")
28855 (match_operand:V_256 1 "register_operand")
28856 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
28857 (match_operand:SI 3 "const_0_to_1_operand")]
28858 "TARGET_AVX"
28859 {
28860 rtx (*insn)(rtx, rtx, rtx);
28861
28862 switch (INTVAL (operands[3]))
28863 {
28864 case 0:
28865 insn = gen_vec_set_lo_<mode>;
28866 break;
28867 case 1:
28868 insn = gen_vec_set_hi_<mode>;
28869 break;
28870 default:
28871 gcc_unreachable ();
28872 }
28873
28874 emit_insn (insn (operands[0], operands[1], operands[2]));
28875 DONE;
28876 })
28877
28878 (define_insn "vec_set_lo_<mode><mask_name>"
28879 [(set (match_operand:VI8F_256 0 "register_operand" "=x,v")
28880 (vec_concat:VI8F_256
28881 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "xjm,vm")
28882 (vec_select:<ssehalfvecmode>
28883 (match_operand:VI8F_256 1 "register_operand" "x,v")
28884 (parallel [(const_int 2) (const_int 3)]))))]
28885 "TARGET_AVX && <mask_avx512dq_condition>"
28886 {
28887 if (TARGET_AVX512DQ)
28888 return "vinsert<shuffletype>64x2\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
28889 else if (TARGET_AVX512VL)
28890 return "vinsert<shuffletype>32x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
28891 else
28892 return "vinsert<i128>\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}";
28893 }
28894 [(set_attr "isa" "noavx512vl,avx512vl")
28895 (set_attr "addr" "gpr16,*")
28896 (set_attr "type" "sselog")
28897 (set_attr "c86_attr" "insertx")
28898 (set_attr "prefix_extra" "1")
28899 (set_attr "length_immediate" "1")
28900 (set_attr "prefix" "vex")
28901 (set_attr "mode" "<sseinsnmode>")])
28902
28903 (define_insn "vec_set_hi_<mode><mask_name>"
28904 [(set (match_operand:VI8F_256 0 "register_operand" "=x,v")
28905 (vec_concat:VI8F_256
28906 (vec_select:<ssehalfvecmode>
28907 (match_operand:VI8F_256 1 "register_operand" "x,v")
28908 (parallel [(const_int 0) (const_int 1)]))
28909 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "xjm,vm")))]
28910 "TARGET_AVX && <mask_avx512dq_condition>"
28911 {
28912 if (TARGET_AVX512DQ)
28913 return "vinsert<shuffletype>64x2\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
28914 else if (TARGET_AVX512VL)
28915 return "vinsert<shuffletype>32x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
28916 else
28917 return "vinsert<i128>\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}";
28918 }
28919 [(set_attr "isa" "noavx512vl,avx512vl")
28920 (set_attr "addr" "gpr16,*")
28921 (set_attr "type" "sselog")
28922 (set_attr "c86_attr" "insertx")
28923 (set_attr "prefix_extra" "1")
28924 (set_attr "length_immediate" "1")
28925 (set_attr "prefix" "vex")
28926 (set_attr "mode" "<sseinsnmode>")])
28927
28928 (define_insn "vec_set_lo_<mode><mask_name>"
28929 [(set (match_operand:VI4F_256 0 "register_operand" "=x,v")
28930 (vec_concat:VI4F_256
28931 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "xjm,vm")
28932 (vec_select:<ssehalfvecmode>
28933 (match_operand:VI4F_256 1 "register_operand" "x,v")
28934 (parallel [(const_int 4) (const_int 5)
28935 (const_int 6) (const_int 7)]))))]
28936 "TARGET_AVX"
28937 {
28938 if (TARGET_AVX512VL)
28939 return "vinsert<shuffletype>32x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
28940 else
28941 return "vinsert<i128>\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}";
28942 }
28943 [(set_attr "isa" "noavx512vl,avx512vl")
28944 (set_attr "addr" "gpr16,*")
28945 (set_attr "type" "sselog")
28946 (set_attr "c86_attr" "insertx")
28947 (set_attr "prefix_extra" "1")
28948 (set_attr "length_immediate" "1")
28949 (set_attr "prefix" "vex")
28950 (set_attr "mode" "<sseinsnmode>")])
28951
28952 (define_insn "vec_set_hi_<mode><mask_name>"
28953 [(set (match_operand:VI4F_256 0 "register_operand" "=x,v")
28954 (vec_concat:VI4F_256
28955 (vec_select:<ssehalfvecmode>
28956 (match_operand:VI4F_256 1 "register_operand" "x,v")
28957 (parallel [(const_int 0) (const_int 1)
28958 (const_int 2) (const_int 3)]))
28959 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "xjm,vm")))]
28960 "TARGET_AVX"
28961 {
28962 if (TARGET_AVX512VL)
28963 return "vinsert<shuffletype>32x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
28964 else
28965 return "vinsert<i128>\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}";
28966 }
28967 [(set_attr "isa" "noavx512vl,avx512vl")
28968 (set_attr "addr" "gpr16,*")
28969 (set_attr "type" "sselog")
28970 (set_attr "c86_attr" "insertx")
28971 (set_attr "prefix_extra" "1")
28972 (set_attr "length_immediate" "1")
28973 (set_attr "prefix" "vex")
28974 (set_attr "mode" "<sseinsnmode>")])
28975
28976 (define_insn "vec_set_lo_<mode>"
28977 [(set (match_operand:V16_256 0 "register_operand" "=x,v")
28978 (vec_concat:V16_256
28979 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "xjm,vm")
28980 (vec_select:<ssehalfvecmode>
28981 (match_operand:V16_256 1 "register_operand" "x,v")
28982 (parallel [(const_int 8) (const_int 9)
28983 (const_int 10) (const_int 11)
28984 (const_int 12) (const_int 13)
28985 (const_int 14) (const_int 15)]))))]
28986 "TARGET_AVX"
28987 "@
28988 vinsert%~128\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}
28989 vinserti32x4\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}"
28990 [(set_attr "isa" "noavx512vl,avx512vl")
28991 (set_attr "addr" "gpr16,*")
28992 (set_attr "type" "sselog")
28993 (set_attr "c86_attr" "insertx")
28994 (set_attr "prefix_extra" "1")
28995 (set_attr "length_immediate" "1")
28996 (set_attr "prefix" "vex,evex")
28997 (set_attr "mode" "OI")])
28998
28999 (define_insn "vec_set_hi_<mode>"
29000 [(set (match_operand:V16_256 0 "register_operand" "=x,v")
29001 (vec_concat:V16_256
29002 (vec_select:<ssehalfvecmode>
29003 (match_operand:V16_256 1 "register_operand" "x,v")
29004 (parallel [(const_int 0) (const_int 1)
29005 (const_int 2) (const_int 3)
29006 (const_int 4) (const_int 5)
29007 (const_int 6) (const_int 7)]))
29008 (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "xjm,vm")))]
29009 "TARGET_AVX"
29010 "@
29011 vinsert%~128\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}
29012 vinserti32x4\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}"
29013 [(set_attr "isa" "noavx512vl,avx512vl")
29014 (set_attr "addr" "gpr16,*")
29015 (set_attr "type" "sselog")
29016 (set_attr "c86_attr" "insertx")
29017 (set_attr "prefix_extra" "1")
29018 (set_attr "length_immediate" "1")
29019 (set_attr "prefix" "vex,evex")
29020 (set_attr "mode" "OI")])
29021
29022 (define_insn "vec_set_lo_v32qi"
29023 [(set (match_operand:V32QI 0 "register_operand" "=x,v")
29024 (vec_concat:V32QI
29025 (match_operand:V16QI 2 "nonimmediate_operand" "xjm,v")
29026 (vec_select:V16QI
29027 (match_operand:V32QI 1 "register_operand" "x,v")
29028 (parallel [(const_int 16) (const_int 17)
29029 (const_int 18) (const_int 19)
29030 (const_int 20) (const_int 21)
29031 (const_int 22) (const_int 23)
29032 (const_int 24) (const_int 25)
29033 (const_int 26) (const_int 27)
29034 (const_int 28) (const_int 29)
29035 (const_int 30) (const_int 31)]))))]
29036 "TARGET_AVX"
29037 "@
29038 vinsert%~128\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}
29039 vinserti32x4\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}"
29040 [(set_attr "isa" "noavx512vl,avx512vl")
29041 (set_attr "type" "sselog")
29042 (set_attr "c86_attr" "insertx")
29043 (set_attr "addr" "gpr16,*")
29044 (set_attr "prefix_extra" "1")
29045 (set_attr "length_immediate" "1")
29046 (set_attr "prefix" "vex,evex")
29047 (set_attr "mode" "OI")])
29048
29049 (define_insn "vec_set_hi_v32qi"
29050 [(set (match_operand:V32QI 0 "register_operand" "=x,v")
29051 (vec_concat:V32QI
29052 (vec_select:V16QI
29053 (match_operand:V32QI 1 "register_operand" "x,v")
29054 (parallel [(const_int 0) (const_int 1)
29055 (const_int 2) (const_int 3)
29056 (const_int 4) (const_int 5)
29057 (const_int 6) (const_int 7)
29058 (const_int 8) (const_int 9)
29059 (const_int 10) (const_int 11)
29060 (const_int 12) (const_int 13)
29061 (const_int 14) (const_int 15)]))
29062 (match_operand:V16QI 2 "nonimmediate_operand" "xjm,vm")))]
29063 "TARGET_AVX"
29064 "@
29065 vinsert%~128\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}
29066 vinserti32x4\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}"
29067 [(set_attr "isa" "noavx512vl,avx512vl")
29068 (set_attr "addr" "gpr16")
29069 (set_attr "type" "sselog")
29070 (set_attr "c86_attr" "insertx")
29071 (set_attr "prefix_extra" "1")
29072 (set_attr "length_immediate" "1")
29073 (set_attr "prefix" "vex,evex")
29074 (set_attr "mode" "OI")])
29075
29076 (define_insn "<avx_avx2>_maskload<ssemodesuffix><avxsizesuffix>"
29077 [(set (match_operand:V48_128_256 0 "register_operand" "=x")
29078 (unspec:V48_128_256
29079 [(match_operand:<sseintvecmode> 2 "register_operand" "x")
29080 (match_operand:V48_128_256 1 "memory_operand" "jm")]
29081 UNSPEC_MASKMOV))]
29082 "TARGET_AVX"
29083 {
29084 if (TARGET_AVX2)
29085 return "v<sseintprefix>maskmov<ssemodesuffix>\t{%1, %2, %0|%0, %2, %1}";
29086 else
29087 return "vmaskmov<ssefltmodesuffix>\t{%1, %2, %0|%0, %2, %1}";
29088 }
29089 [(set_attr "type" "sselog1")
29090 (set_attr "c86_attr" "blend")
29091 (set_attr "addr" "gpr16")
29092 (set_attr "prefix_extra" "1")
29093 (set_attr "prefix" "vex")
29094 (set_attr "btver2_decode" "vector")
29095 (set_attr "mode" "<sseinsnmode>")])
29096
29097 (define_insn "<avx_avx2>_maskstore<ssemodesuffix><avxsizesuffix>"
29098 [(set (match_operand:V48_128_256 0 "memory_operand" "+jm")
29099 (unspec:V48_128_256
29100 [(match_operand:<sseintvecmode> 1 "register_operand" "x")
29101 (match_operand:V48_128_256 2 "register_operand" "x")
29102 (match_dup 0)]
29103 UNSPEC_MASKMOV))]
29104 "TARGET_AVX"
29105 {
29106 if (TARGET_AVX2)
29107 return "v<sseintprefix>maskmov<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}";
29108 else
29109 return "vmaskmov<ssefltmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
29110 }
29111 [(set_attr "type" "sselog1")
29112 (set_attr "c86_attr" "blend")
29113 (set_attr "addr" "gpr16")
29114 (set_attr "prefix_extra" "1")
29115 (set_attr "prefix" "vex")
29116 (set_attr "btver2_decode" "vector")
29117 (set_attr "mode" "<sseinsnmode>")])
29118
29119 (define_expand "maskload<mode><sseintvecmodelower>_1"
29120 [(set (match_operand:V48_128_256 0 "register_operand")
29121 (unspec:V48_128_256
29122 [(match_operand:<sseintvecmode> 2 "register_operand")
29123 (match_operand:V48_128_256 1 "memory_operand")]
29124 UNSPEC_MASKMOV))]
29125 "TARGET_AVX")
29126
29127 (define_expand "maskload<mode><sseintvecmodelower>"
29128 [(set (match_operand:V48_128_256 0 "register_operand")
29129 (unspec:V48_128_256
29130 [(match_operand:<sseintvecmode> 2 "register_operand")
29131 (match_operand:V48_128_256 1 "memory_operand")
29132 (match_operand:V48_128_256 3 "const0_operand")]
29133 UNSPEC_MASKMOV))]
29134 "TARGET_AVX"
29135 {
29136 emit_insn (gen_maskload<mode><sseintvecmodelower>_1 (operands[0],
29137 operands[1],
29138 operands[2]));
29139 DONE;
29140 })
29141
29142 (define_expand "maskload<mode><avx512fmaskmodelower>"
29143 [(set (match_operand:V48_AVX512VL 0 "register_operand")
29144 (vec_merge:V48_AVX512VL
29145 (unspec:V48_AVX512VL
29146 [(match_operand:V48_AVX512VL 1 "memory_operand")]
29147 UNSPEC_MASKLOAD)
29148 (match_operand:V48_AVX512VL 3 "const0_operand")
29149 (match_operand:<avx512fmaskmode> 2 "register_operand")))]
29150 "TARGET_AVX512F")
29151
29152 (define_expand "maskload<mode><avx512fmaskmodelower>"
29153 [(set (match_operand:VI12HFBF_AVX512VL 0 "register_operand")
29154 (vec_merge:VI12HFBF_AVX512VL
29155 (unspec:VI12HFBF_AVX512VL
29156 [(match_operand:VI12HFBF_AVX512VL 1 "memory_operand")]
29157 UNSPEC_MASKLOAD)
29158 (match_operand:VI12HFBF_AVX512VL 3 "const0_operand")
29159 (match_operand:<avx512fmaskmode> 2 "register_operand")))]
29160 "TARGET_AVX512BW")
29161
29162 (define_expand "maskstore<mode><sseintvecmodelower>"
29163 [(set (match_operand:V48_128_256 0 "memory_operand")
29164 (unspec:V48_128_256
29165 [(match_operand:<sseintvecmode> 2 "register_operand")
29166 (match_operand:V48_128_256 1 "register_operand")
29167 (match_dup 0)]
29168 UNSPEC_MASKMOV))]
29169 "TARGET_AVX")
29170
29171 (define_expand "maskstore<mode><avx512fmaskmodelower>"
29172 [(set (match_operand:V48_AVX512VL 0 "memory_operand")
29173 (unspec:V48_AVX512VL
29174 [(match_operand:V48_AVX512VL 1 "register_operand")
29175 (match_dup 0)
29176 (match_operand:<avx512fmaskmode> 2 "register_operand")]
29177 UNSPEC_MASKMOV))]
29178 "TARGET_AVX512F")
29179
29180 (define_expand "maskstore<mode><avx512fmaskmodelower>"
29181 [(set (match_operand:VI12HFBF_AVX512VL 0 "memory_operand")
29182 (unspec:VI12HFBF_AVX512VL
29183 [(match_operand:VI12HFBF_AVX512VL 1 "register_operand")
29184 (match_dup 0)
29185 (match_operand:<avx512fmaskmode> 2 "register_operand")]
29186 UNSPEC_MASKMOV))]
29187 "TARGET_AVX512BW")
29188
29189 (define_insn "<avx512>_store<mode>_mask"
29190 [(set (match_operand:V48_AVX512VL 0 "memory_operand" "=m")
29191 (unspec:V48_AVX512VL
29192 [(match_operand:V48_AVX512VL 1 "register_operand" "v")
29193 (match_dup 0)
29194 (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")]
29195 UNSPEC_MASKMOV))]
29196 "TARGET_AVX512F"
29197 {
29198 if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
29199 {
29200 if (misaligned_operand (operands[0], <MODE>mode))
29201 return "vmovu<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
29202 else
29203 return "vmova<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
29204 }
29205 else
29206 {
29207 if (misaligned_operand (operands[0], <MODE>mode))
29208 return "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
29209 else
29210 return "vmovdqa<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
29211 }
29212 }
29213 [(set_attr "type" "ssemov")
29214 (set_attr "prefix" "evex")
29215 (set_attr "memory" "store")
29216 (set_attr "mode" "<sseinsnmode>")])
29217
29218 (define_insn "<avx512>_store<mode>_mask"
29219 [(set (match_operand:VI12HFBF_AVX512VL 0 "memory_operand" "=m")
29220 (unspec:VI12HFBF_AVX512VL
29221 [(match_operand:VI12HFBF_AVX512VL 1 "register_operand" "v")
29222 (match_dup 0)
29223 (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")]
29224 UNSPEC_MASKMOV))]
29225 "TARGET_AVX512BW"
29226 "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
29227 [(set_attr "type" "ssemov")
29228 (set_attr "prefix" "evex")
29229 (set_attr "memory" "store")
29230 (set_attr "mode" "<sseinsnmode>")])
29231
29232 (define_insn_and_split "*<avx512>_store<mode>_mask_1"
29233 [(set (match_operand:V 0 "memory_operand")
29234 (unspec:V
29235 [(match_operand:V 1 "register_operand")
29236 (match_dup 0)
29237 (match_operand:<avx512fmaskmode> 2 "const0_or_m1_operand")]
29238 UNSPEC_MASKMOV))]
29239 "TARGET_AVX512F && ix86_pre_reload_split ()"
29240 "#"
29241 "&& 1"
29242 [(const_int 0)]
29243 {
29244 if (constm1_operand (operands[2], <MODE>mode))
29245 emit_move_insn (operands[0], operands[1]);
29246 else
29247 emit_note (NOTE_INSN_DELETED);
29248
29249 DONE;
29250 })
29251
29252 (define_expand "cbranch<mode>4"
29253 [(set (reg:CC FLAGS_REG)
29254 (compare:CC (match_operand:VI_AVX_AVX512F 1 "register_operand")
29255 (match_operand:VI_AVX_AVX512F 2 "nonimmediate_operand")))
29256 (set (pc) (if_then_else
29257 (match_operator 0 "bt_comparison_operator"
29258 [(reg:CC FLAGS_REG) (const_int 0)])
29259 (label_ref (match_operand 3))
29260 (pc)))]
29261 "TARGET_SSE4_1 && (<MODE_SIZE> != 64 || !TARGET_PREFER_AVX256)"
29262 {
29263 ix86_expand_branch (GET_CODE (operands[0]),
29264 operands[1], operands[2], operands[3]);
29265 DONE;
29266 })
29267
29268
29269 (define_insn_and_split "avx_<castmode><avxsizesuffix>_<castmode>"
29270 [(set (match_operand:AVX256MODE2P 0 "nonimmediate_operand" "=x,m")
29271 (vec_concat:AVX256MODE2P
29272 (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "xm,x")
29273 (unspec:<ssehalfvecmode> [(const_int 0)] UNSPEC_CAST)))]
29274 "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
29275 "#"
29276 "&& reload_completed"
29277 [(set (match_dup 0) (match_dup 1))]
29278 {
29279 if (REG_P (operands[0]))
29280 operands[0] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);
29281 else
29282 operands[1] = lowpart_subreg (<MODE>mode, operands[1],
29283 <ssehalfvecmode>mode);
29284 })
29285
29286 ;; Modes handled by vec_init expanders.
29287 (define_mode_iterator VEC_INIT_MODE
29288 [(V64QI "TARGET_AVX512F && TARGET_EVEX512") (V32QI "TARGET_AVX") V16QI
29289 (V32HI "TARGET_AVX512F && TARGET_EVEX512") (V16HI "TARGET_AVX") V8HI
29290 (V16SI "TARGET_AVX512F && TARGET_EVEX512") (V8SI "TARGET_AVX") V4SI
29291 (V8DI "TARGET_AVX512F && TARGET_EVEX512") (V4DI "TARGET_AVX") V2DI
29292 (V32HF "TARGET_AVX512F && TARGET_EVEX512") (V16HF "TARGET_AVX") V8HF
29293 (V32BF "TARGET_AVX512F && TARGET_EVEX512") (V16BF "TARGET_AVX") V8BF
29294 (V16SF "TARGET_AVX512F && TARGET_EVEX512") (V8SF "TARGET_AVX") V4SF
29295 (V8DF "TARGET_AVX512F && TARGET_EVEX512")
29296 (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")
29297 (V4TI "TARGET_AVX512F && TARGET_EVEX512") (V2TI "TARGET_AVX")])
29298
29299 ;; Likewise, but for initialization from half sized vectors.
29300 ;; Thus, these are all VEC_INIT_MODE modes except V2??.
29301 (define_mode_iterator VEC_INIT_HALF_MODE
29302 [(V64QI "TARGET_AVX512F && TARGET_EVEX512") (V32QI "TARGET_AVX") V16QI
29303 (V32HI "TARGET_AVX512F && TARGET_EVEX512") (V16HI "TARGET_AVX") V8HI
29304 (V16SI "TARGET_AVX512F && TARGET_EVEX512") (V8SI "TARGET_AVX") V4SI
29305 (V8DI "TARGET_AVX512F && TARGET_EVEX512") (V4DI "TARGET_AVX")
29306 (V32HF "TARGET_AVX512F && TARGET_EVEX512") (V16HF "TARGET_AVX") V8HF
29307 (V32BF "TARGET_AVX512F && TARGET_EVEX512") (V16BF "TARGET_AVX") V8BF
29308 (V16SF "TARGET_AVX512F && TARGET_EVEX512") (V8SF "TARGET_AVX") V4SF
29309 (V8DF "TARGET_AVX512F && TARGET_EVEX512") (V4DF "TARGET_AVX")
29310 (V4TI "TARGET_AVX512F && TARGET_EVEX512")])
29311
29312 (define_expand "vec_init<mode><ssescalarmodelower>"
29313 [(match_operand:VEC_INIT_MODE 0 "register_operand")
29314 (match_operand 1)]
29315 "TARGET_SSE"
29316 {
29317 ix86_expand_vector_init (false, operands[0], operands[1]);
29318 DONE;
29319 })
29320
29321 (define_expand "vec_init<mode><ssehalfvecmodelower>"
29322 [(match_operand:VEC_INIT_HALF_MODE 0 "register_operand")
29323 (match_operand 1)]
29324 "TARGET_SSE"
29325 {
29326 ix86_expand_vector_init (false, operands[0], operands[1]);
29327 DONE;
29328 })
29329
29330 (define_expand "cond_<insn><mode>"
29331 [(set (match_operand:VI248_AVX512VLBW 0 "register_operand")
29332 (vec_merge:VI248_AVX512VLBW
29333 (any_shift:VI248_AVX512VLBW
29334 (match_operand:VI248_AVX512VLBW 2 "register_operand")
29335 (match_operand:VI248_AVX512VLBW 3 "nonimmediate_or_const_vec_dup_operand"))
29336 (match_operand:VI248_AVX512VLBW 4 "nonimm_or_0_operand")
29337 (match_operand:<avx512fmaskmode> 1 "register_operand")))]
29338 "TARGET_AVX512F"
29339 {
29340 if (const_vec_duplicate_p (operands[3]))
29341 {
29342 operands[3] = unwrap_const_vec_duplicate (operands[3]);
29343 operands[3] = lowpart_subreg (DImode, operands[3], <ssescalarmode>mode);
29344 emit_insn (gen_<insn><mode>3_mask (operands[0],
29345 operands[2],
29346 operands[3],
29347 operands[4],
29348 operands[1]));
29349 }
29350 else
29351 emit_insn (gen_<avx2_avx512>_<insn>v<mode>_mask (operands[0],
29352 operands[2],
29353 operands[3],
29354 operands[4],
29355 operands[1]));
29356 DONE;
29357 })
29358
29359 (define_insn "<avx2_avx512>_ashrv<mode><mask_name>"
29360 [(set (match_operand:VI48_AVX512F_AVX512VL 0 "register_operand" "=v")
29361 (ashiftrt:VI48_AVX512F_AVX512VL
29362 (match_operand:VI48_AVX512F_AVX512VL 1 "register_operand" "v")
29363 (match_operand:VI48_AVX512F_AVX512VL 2 "nonimmediate_operand" "vm")))]
29364 "TARGET_AVX2 && <mask_mode512bit_condition>"
29365 "vpsrav<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
29366 [(set_attr "type" "sseishft")
29367 (set_attr "prefix" "maybe_evex")
29368 (set_attr "mode" "<sseinsnmode>")])
29369
29370 (define_insn "<avx2_avx512>_ashrv<mode><mask_name>"
29371 [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
29372 (ashiftrt:VI2_AVX512VL
29373 (match_operand:VI2_AVX512VL 1 "register_operand" "v")
29374 (match_operand:VI2_AVX512VL 2 "nonimmediate_operand" "vm")))]
29375 "TARGET_AVX512BW"
29376 "vpsravw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
29377 [(set_attr "type" "sseishft")
29378 (set_attr "prefix" "maybe_evex")
29379 (set_attr "mode" "<sseinsnmode>")])
29380
29381 (define_insn "<avx2_avx512>_<insn>v<mode><mask_name>"
29382 [(set (match_operand:VI48_AVX512F 0 "register_operand" "=v")
29383 (any_lshift:VI48_AVX512F
29384 (match_operand:VI48_AVX512F 1 "register_operand" "v")
29385 (match_operand:VI48_AVX512F 2 "nonimmediate_operand" "vm")))]
29386 "TARGET_AVX2 && <mask_mode512bit_condition>"
29387 "vp<vshift>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
29388 [(set_attr "type" "sseishft")
29389 (set_attr "prefix" "maybe_evex")
29390 (set_attr "mode" "<sseinsnmode>")])
29391
29392 (define_insn "<avx2_avx512>_<insn>v<mode><mask_name>"
29393 [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
29394 (any_lshift:VI2_AVX512VL
29395 (match_operand:VI2_AVX512VL 1 "register_operand" "v")
29396 (match_operand:VI2_AVX512VL 2 "nonimmediate_operand" "vm")))]
29397 "TARGET_AVX512BW"
29398 "vp<vshift>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
29399 [(set_attr "type" "sseishft")
29400 (set_attr "prefix" "maybe_evex")
29401 (set_attr "mode" "<sseinsnmode>")])
29402
29403 (define_insn "avx_vec_concat<mode>"
29404 [(set (match_operand:V_256_512 0 "register_operand" "=x,v,x,Yv")
29405 (vec_concat:V_256_512
29406 (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "x,v,xm,vm")
29407 (match_operand:<ssehalfvecmode> 2 "nonimm_or_0_operand" "xjm,vm,C,C")))]
29408 "TARGET_AVX
29409 && (operands[2] == CONST0_RTX (<ssehalfvecmode>mode)
29410 || !MEM_P (operands[1]))"
29411 {
29412 bool egpr_used = (TARGET_APX_EGPR
29413 && x86_extended_rex2reg_mentioned_p (operands[1]));
29414 switch (which_alternative)
29415 {
29416 case 0:
29417 return "vinsert<i128>\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
29418 case 1:
29419 if (<MODE_SIZE> == 64)
29420 {
29421 if (TARGET_AVX512DQ && GET_MODE_SIZE (<ssescalarmode>mode) == 4)
29422 return "vinsert<shuffletype>32x8\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
29423 else
29424 return "vinsert<shuffletype>64x4\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
29425 }
29426 else
29427 {
29428 if (TARGET_AVX512DQ && GET_MODE_SIZE (<ssescalarmode>mode) == 8)
29429 return "vinsert<shuffletype>64x2\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
29430 else
29431 return "vinsert<shuffletype>32x4\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
29432 }
29433 case 2:
29434 case 3:
29435 switch (get_attr_mode (insn))
29436 {
29437 case MODE_V16SF:
29438 if (misaligned_operand (operands[1], <ssehalfvecmode>mode))
29439 return "vmovups\t{%1, %t0|%t0, %1}";
29440 else
29441 return "vmovaps\t{%1, %t0|%t0, %1}";
29442 case MODE_V8DF:
29443 if (misaligned_operand (operands[1], <ssehalfvecmode>mode))
29444 return "vmovupd\t{%1, %t0|%t0, %1}";
29445 else
29446 return "vmovapd\t{%1, %t0|%t0, %1}";
29447 case MODE_V8SF:
29448 if (misaligned_operand (operands[1], <ssehalfvecmode>mode))
29449 return "vmovups\t{%1, %x0|%x0, %1}";
29450 else
29451 return "vmovaps\t{%1, %x0|%x0, %1}";
29452 case MODE_V4DF:
29453 if (misaligned_operand (operands[1], <ssehalfvecmode>mode))
29454 return "vmovupd\t{%1, %x0|%x0, %1}";
29455 else
29456 return "vmovapd\t{%1, %x0|%x0, %1}";
29457 case MODE_XI:
29458 if (misaligned_operand (operands[1], <ssehalfvecmode>mode))
29459 {
29460 if (which_alternative == 2)
29461 return egpr_used ? "vmovups\t{%1, %t0|%t0, %1}"
29462 : "vmovdqu\t{%1, %t0|%t0, %1}";
29463 else if (GET_MODE_SIZE (<ssescalarmode>mode) == 8)
29464 return "vmovdqu64\t{%1, %t0|%t0, %1}";
29465 else
29466 return "vmovdqu32\t{%1, %t0|%t0, %1}";
29467 }
29468 else
29469 {
29470 if (which_alternative == 2)
29471 return egpr_used ? "vmovaps\t{%1, %t0|%t0, %1}"
29472 : "vmovdqa\t{%1, %t0|%t0, %1}";
29473 else if (GET_MODE_SIZE (<ssescalarmode>mode) == 8)
29474 return "vmovdqa64\t{%1, %t0|%t0, %1}";
29475 else
29476 return "vmovdqa32\t{%1, %t0|%t0, %1}";
29477 }
29478 case MODE_OI:
29479 if (misaligned_operand (operands[1], <ssehalfvecmode>mode))
29480 {
29481 if (which_alternative == 2)
29482 return egpr_used ? "vmovups\t{%1, %x0|%x0, %1}"
29483 : "vmovdqu\t{%1, %x0|%x0, %1}";
29484 else if (GET_MODE_SIZE (<ssescalarmode>mode) == 8)
29485 return "vmovdqu64\t{%1, %x0|%x0, %1}";
29486 else
29487 return "vmovdqu32\t{%1, %x0|%x0, %1}";
29488 }
29489 else
29490 {
29491 if (which_alternative == 2)
29492 return egpr_used ? "vmovaps\t{%1, %x0|%x0, %1}"
29493 : "vmovdqa\t{%1, %x0|%x0, %1}";
29494 else if (GET_MODE_SIZE (<ssescalarmode>mode) == 8)
29495 return "vmovdqa64\t{%1, %x0|%x0, %1}";
29496 else
29497 return "vmovdqa32\t{%1, %x0|%x0, %1}";
29498 }
29499 default:
29500 gcc_unreachable ();
29501 }
29502 default:
29503 gcc_unreachable ();
29504 }
29505 }
29506 [(set_attr "isa" "noavx512f,avx512f,*,*")
29507 (set_attr "addr" "gpr16,*,*,*")
29508 (set_attr "type" "sselog,sselog,ssemov,ssemov")
29509 (set_attr "c86_attr" "insertx,insertx,*,*")
29510 (set_attr "prefix_extra" "1,1,*,*")
29511 (set_attr "length_immediate" "1,1,*,*")
29512 (set_attr "prefix" "maybe_evex")
29513 (set_attr "mode" "<sseinsnmode>")])
29514
29515 (define_insn_and_split "*vec_concat<mode>_0_1"
29516 [(set (match_operand:V 0 "register_operand")
29517 (vec_select:V
29518 (vec_concat:<ssedoublevecmode>
29519 (match_operand:V 1 "nonimmediate_operand")
29520 (match_operand:V 2 "const0_operand"))
29521 (match_parallel 3 "movq_parallel"
29522 [(match_operand 4 "const_int_operand")])))]
29523 "TARGET_SSE2 && ix86_pre_reload_split ()"
29524 "#"
29525 "&& 1"
29526 [(set (match_dup 0)
29527 (vec_concat:V (match_dup 1) (match_dup 5)))]
29528 {
29529 operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);
29530 operands[5] = CONST0_RTX (<ssehalfvecmode>mode);
29531 })
29532
29533 (define_insn "vcvtph2ps<mask_name>"
29534 [(set (match_operand:V4SF 0 "register_operand" "=v")
29535 (vec_select:V4SF
29536 (unspec:V8SF [(match_operand:V8HI 1 "register_operand" "v")]
29537 UNSPEC_VCVTPH2PS)
29538 (parallel [(const_int 0) (const_int 1)
29539 (const_int 2) (const_int 3)])))]
29540 "TARGET_F16C || TARGET_AVX512VL"
29541 "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
29542 [(set_attr "type" "ssecvt")
29543 (set_attr "prefix" "maybe_evex")
29544 (set_attr "mode" "V4SF")])
29545
29546 (define_insn "*vcvtph2ps_load<mask_name>"
29547 [(set (match_operand:V4SF 0 "register_operand" "=v")
29548 (unspec:V4SF [(match_operand:V4HI 1 "memory_operand" "m")]
29549 UNSPEC_VCVTPH2PS))]
29550 "TARGET_F16C || TARGET_AVX512VL"
29551 "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
29552 [(set_attr "type" "ssecvt")
29553 (set_attr "prefix" "vex")
29554 (set_attr "mode" "V8SF")])
29555
29556 (define_insn "vcvtph2ps256<mask_name>"
29557 [(set (match_operand:V8SF 0 "register_operand" "=v")
29558 (unspec:V8SF [(match_operand:V8HI 1 "nonimmediate_operand" "vm")]
29559 UNSPEC_VCVTPH2PS))]
29560 "TARGET_F16C || TARGET_AVX512VL"
29561 "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
29562 [(set_attr "type" "ssecvt")
29563 (set_attr "prefix" "vex")
29564 (set_attr "btver2_decode" "double")
29565 (set_attr "mode" "V8SF")])
29566
29567 (define_insn "<mask_codefor>avx512f_vcvtph2ps512<mask_name><round_saeonly_name>"
29568 [(set (match_operand:V16SF 0 "register_operand" "=v")
29569 (unspec:V16SF
29570 [(match_operand:V16HI 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
29571 UNSPEC_VCVTPH2PS))]
29572 "TARGET_AVX512F && TARGET_EVEX512"
29573 "vcvtph2ps\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
29574 [(set_attr "type" "ssecvt")
29575 (set_attr "prefix" "evex")
29576 (set_attr "mode" "V16SF")])
29577
29578 (define_expand "vcvtps2ph_mask"
29579 [(set (match_operand:V8HI 0 "register_operand")
29580 (vec_merge:V8HI
29581 (vec_concat:V8HI
29582 (unspec:V4HI [(match_operand:V4SF 1 "register_operand")
29583 (match_operand:SI 2 "const_0_to_255_operand")]
29584 UNSPEC_VCVTPS2PH)
29585 (match_dup 5))
29586 (match_operand:V8HI 3 "nonimm_or_0_operand")
29587 (match_operand:QI 4 "register_operand")))]
29588 "TARGET_AVX512VL"
29589 "operands[5] = CONST0_RTX (V4HImode);")
29590
29591 (define_expand "vcvtps2ph"
29592 [(set (match_operand:V8HI 0 "register_operand")
29593 (vec_concat:V8HI
29594 (unspec:V4HI [(match_operand:V4SF 1 "register_operand")
29595 (match_operand:SI 2 "const_0_to_255_operand")]
29596 UNSPEC_VCVTPS2PH)
29597 (match_dup 3)))]
29598 "TARGET_F16C"
29599 "operands[3] = CONST0_RTX (V4HImode);")
29600
29601 (define_insn "*vcvtps2ph<mask_name>"
29602 [(set (match_operand:V8HI 0 "register_operand" "=v")
29603 (vec_concat:V8HI
29604 (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "v")
29605 (match_operand:SI 2 "const_0_to_255_operand")]
29606 UNSPEC_VCVTPS2PH)
29607 (match_operand:V4HI 3 "const0_operand")))]
29608 "(TARGET_F16C || TARGET_AVX512VL) && <mask_avx512vl_condition>"
29609 "vcvtps2ph\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}"
29610 [(set_attr "type" "ssecvt")
29611 (set_attr "prefix" "maybe_evex")
29612 (set_attr "mode" "V4SF")])
29613
29614 (define_insn "*vcvtps2ph_store<merge_mask_name>"
29615 [(set (match_operand:V4HI 0 "memory_operand" "=m")
29616 (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "v")
29617 (match_operand:SI 2 "const_0_to_255_operand")]
29618 UNSPEC_VCVTPS2PH))]
29619 "TARGET_F16C || TARGET_AVX512VL"
29620 "vcvtps2ph\t{%2, %1, %0<merge_mask_operand3>|%0<merge_mask_operand3>, %1, %2}"
29621 [(set_attr "type" "ssecvt")
29622 (set_attr "prefix" "maybe_evex")
29623 (set_attr "mode" "V4SF")])
29624
29625 (define_insn "vcvtps2ph256<mask_name>"
29626 [(set (match_operand:V8HI 0 "register_operand" "=v")
29627 (unspec:V8HI [(match_operand:V8SF 1 "register_operand" "v")
29628 (match_operand:SI 2 "const_0_to_255_operand")]
29629 UNSPEC_VCVTPS2PH))]
29630 "TARGET_F16C || TARGET_AVX512VL"
29631 "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
29632 [(set_attr "type" "ssecvt")
29633 (set_attr "prefix" "maybe_evex")
29634 (set_attr "btver2_decode" "vector")
29635 (set_attr "mode" "V8SF")])
29636
29637 (define_insn "*vcvtps2ph256<merge_mask_name>"
29638 [(set (match_operand:V8HI 0 "memory_operand" "=m")
29639 (unspec:V8HI [(match_operand:V8SF 1 "register_operand" "v")
29640 (match_operand:SI 2 "const_0_to_255_operand")]
29641 UNSPEC_VCVTPS2PH))]
29642 "TARGET_F16C || TARGET_AVX512VL"
29643 "vcvtps2ph\t{%2, %1, %0<merge_mask_operand3>|%0<merge_mask_operand3>, %1, %2}"
29644 [(set_attr "type" "ssecvt")
29645 (set_attr "prefix" "maybe_evex")
29646 (set_attr "btver2_decode" "vector")
29647 (set_attr "mode" "V8SF")])
29648
29649 ;; vcvtps2ph is special, it encodes {sae} in evex, but round control in the imm
29650 ;; For intrinsic _mm512_cvt_roundps_ph (a, imm), imm contains both {sae}
29651 ;; and round control, we need to separate it in the assembly output.
29652 ;; op2 in avx512f_vcvtps2ph512_mask_sae contains both sae and round control.
29653 (define_expand "avx512f_vcvtps2ph512_mask_sae"
29654 [(set (match_operand:V16HI 0 "register_operand" "=v")
29655 (vec_merge:V16HI
29656 (unspec:V16HI
29657 [(match_operand:V16SF 1 "register_operand" "v")
29658 (match_operand:SI 2 "const_0_to_255_operand")]
29659 UNSPEC_VCVTPS2PH)
29660 (match_operand:V16HI 3 "nonimm_or_0_operand")
29661 (match_operand:HI 4 "register_operand")))]
29662 "TARGET_AVX512F && TARGET_EVEX512"
29663 {
29664 int round = INTVAL (operands[2]);
29665 /* Separate {sae} from rounding control imm,
29666 imm[3:7] will be ignored by the instruction. */
29667 if (round & 8)
29668 {
29669 emit_insn (gen_avx512f_vcvtps2ph512_mask_round (operands[0], operands[1],
29670 operands[2], operands[3], operands[4], GEN_INT (8)));
29671 DONE;
29672 }
29673 })
29674
29675 (define_insn "<mask_codefor>avx512f_vcvtps2ph512<mask_name><round_saeonly_name>"
29676 [(set (match_operand:V16HI 0 "register_operand" "=v")
29677 (unspec:V16HI
29678 [(match_operand:V16SF 1 "register_operand" "v")
29679 (match_operand:SI 2 "const_0_to_255_operand")]
29680 UNSPEC_VCVTPS2PH))]
29681 "TARGET_AVX512F && TARGET_EVEX512"
29682 "vcvtps2ph\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}"
29683 [(set_attr "type" "ssecvt")
29684 (set_attr "prefix" "evex")
29685 (set_attr "mode" "V16SF")])
29686
29687 (define_insn "*avx512f_vcvtps2ph512<merge_mask_name>"
29688 [(set (match_operand:V16HI 0 "memory_operand" "=m")
29689 (unspec:V16HI
29690 [(match_operand:V16SF 1 "register_operand" "v")
29691 (match_operand:SI 2 "const_0_to_255_operand")]
29692 UNSPEC_VCVTPS2PH))]
29693 "TARGET_AVX512F && TARGET_EVEX512"
29694 "vcvtps2ph\t{%2, %1, %0<merge_mask_operand3>|%0<merge_mask_operand3>, %1, %2}"
29695 [(set_attr "type" "ssecvt")
29696 (set_attr "prefix" "evex")
29697 (set_attr "mode" "V16SF")])
29698
29699 ;; For gather* insn patterns
29700 (define_mode_iterator VEC_GATHER_MODE
29701 [V2DI V2DF V4DI V4DF V4SI V4SF V8SI V8SF])
29702 (define_mode_attr VEC_GATHER_IDXSI
29703 [(V2DI "V4SI") (V4DI "V4SI") (V8DI "V8SI")
29704 (V2DF "V4SI") (V4DF "V4SI") (V8DF "V8SI")
29705 (V4SI "V4SI") (V8SI "V8SI") (V16SI "V16SI")
29706 (V4SF "V4SI") (V8SF "V8SI") (V16SF "V16SI")])
29707
29708 (define_mode_attr VEC_GATHER_IDXDI
29709 [(V2DI "V2DI") (V4DI "V4DI") (V8DI "V8DI")
29710 (V2DF "V2DI") (V4DF "V4DI") (V8DF "V8DI")
29711 (V4SI "V2DI") (V8SI "V4DI") (V16SI "V8DI")
29712 (V4SF "V2DI") (V8SF "V4DI") (V16SF "V8DI")])
29713
29714 (define_mode_attr VEC_GATHER_SRCDI
29715 [(V2DI "V2DI") (V4DI "V4DI") (V8DI "V8DI")
29716 (V2DF "V2DF") (V4DF "V4DF") (V8DF "V8DF")
29717 (V4SI "V4SI") (V8SI "V4SI") (V16SI "V8SI")
29718 (V4SF "V4SF") (V8SF "V4SF") (V16SF "V8SF")])
29719
29720 (define_expand "avx2_gathersi<mode>"
29721 [(parallel [(set (match_operand:VEC_GATHER_MODE 0 "register_operand")
29722 (unspec:VEC_GATHER_MODE
29723 [(match_operand:VEC_GATHER_MODE 1 "register_operand")
29724 (mem:<ssescalarmode>
29725 (match_par_dup 6
29726 [(match_operand 2 "vsib_address_operand")
29727 (match_operand:<VEC_GATHER_IDXSI>
29728 3 "register_operand")
29729 (match_operand:SI 5 "const1248_operand ")]))
29730 (mem:BLK (scratch))
29731 (match_operand:VEC_GATHER_MODE 4 "register_operand")]
29732 UNSPEC_GATHER))
29733 (clobber (match_scratch:VEC_GATHER_MODE 7))])]
29734 "TARGET_AVX2"
29735 {
29736 operands[6]
29737 = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
29738 operands[5]), UNSPEC_VSIBADDR);
29739 })
29740
29741 (define_insn "*avx2_gathersi<VEC_GATHER_MODE:mode>"
29742 [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
29743 (unspec:VEC_GATHER_MODE
29744 [(match_operand:VEC_GATHER_MODE 2 "register_operand" "0")
29745 (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
29746 [(unspec:P
29747 [(match_operand:P 3 "vsib_address_operand" "jb")
29748 (match_operand:<VEC_GATHER_IDXSI> 4 "register_operand" "x")
29749 (match_operand:SI 6 "const1248_operand")]
29750 UNSPEC_VSIBADDR)])
29751 (mem:BLK (scratch))
29752 (match_operand:VEC_GATHER_MODE 5 "register_operand" "1")]
29753 UNSPEC_GATHER))
29754 (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
29755 "TARGET_AVX2"
29756 "%M3v<sseintprefix>gatherd<ssemodesuffix>\t{%1, %7, %0|%0, %7, %1}"
29757 [(set_attr "type" "ssemov")
29758 (set_attr "addr" "gpr16")
29759 (set_attr "prefix" "vex")
29760 (set_attr "mode" "<sseinsnmode>")])
29761
29762 (define_insn "*avx2_gathersi<VEC_GATHER_MODE:mode>_2"
29763 [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
29764 (unspec:VEC_GATHER_MODE
29765 [(pc)
29766 (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
29767 [(unspec:P
29768 [(match_operand:P 2 "vsib_address_operand" "jb")
29769 (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand" "x")
29770 (match_operand:SI 5 "const1248_operand")]
29771 UNSPEC_VSIBADDR)])
29772 (mem:BLK (scratch))
29773 (match_operand:VEC_GATHER_MODE 4 "register_operand" "1")]
29774 UNSPEC_GATHER))
29775 (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
29776 "TARGET_AVX2"
29777 "%M2v<sseintprefix>gatherd<ssemodesuffix>\t{%1, %6, %0|%0, %6, %1}"
29778 [(set_attr "type" "ssemov")
29779 (set_attr "addr" "gpr16")
29780 (set_attr "prefix" "vex")
29781 (set_attr "mode" "<sseinsnmode>")])
29782
29783 (define_expand "avx2_gatherdi<mode>"
29784 [(parallel [(set (match_operand:VEC_GATHER_MODE 0 "register_operand")
29785 (unspec:VEC_GATHER_MODE
29786 [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand")
29787 (mem:<ssescalarmode>
29788 (match_par_dup 6
29789 [(match_operand 2 "vsib_address_operand")
29790 (match_operand:<VEC_GATHER_IDXDI>
29791 3 "register_operand")
29792 (match_operand:SI 5 "const1248_operand ")]))
29793 (mem:BLK (scratch))
29794 (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand")]
29795 UNSPEC_GATHER))
29796 (clobber (match_scratch:VEC_GATHER_MODE 7))])]
29797 "TARGET_AVX2"
29798 {
29799 operands[6]
29800 = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
29801 operands[5]), UNSPEC_VSIBADDR);
29802 })
29803
29804 (define_insn "*avx2_gatherdi<VEC_GATHER_MODE:mode>"
29805 [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
29806 (unspec:VEC_GATHER_MODE
29807 [(match_operand:<VEC_GATHER_SRCDI> 2 "register_operand" "0")
29808 (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
29809 [(unspec:P
29810 [(match_operand:P 3 "vsib_address_operand" "jb")
29811 (match_operand:<VEC_GATHER_IDXDI> 4 "register_operand" "x")
29812 (match_operand:SI 6 "const1248_operand")]
29813 UNSPEC_VSIBADDR)])
29814 (mem:BLK (scratch))
29815 (match_operand:<VEC_GATHER_SRCDI> 5 "register_operand" "1")]
29816 UNSPEC_GATHER))
29817 (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
29818 "TARGET_AVX2"
29819 "%M3v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %7, %2|%2, %7, %5}"
29820 [(set_attr "type" "ssemov")
29821 (set_attr "addr" "gpr16")
29822 (set_attr "prefix" "vex")
29823 (set_attr "mode" "<sseinsnmode>")])
29824
29825 (define_insn "*avx2_gatherdi<VEC_GATHER_MODE:mode>_2"
29826 [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
29827 (unspec:VEC_GATHER_MODE
29828 [(pc)
29829 (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
29830 [(unspec:P
29831 [(match_operand:P 2 "vsib_address_operand" "jb")
29832 (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "x")
29833 (match_operand:SI 5 "const1248_operand")]
29834 UNSPEC_VSIBADDR)])
29835 (mem:BLK (scratch))
29836 (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand" "1")]
29837 UNSPEC_GATHER))
29838 (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
29839 "TARGET_AVX2"
29840 {
29841 if (<VEC_GATHER_MODE:MODE>mode != <VEC_GATHER_SRCDI>mode)
29842 return "%M2v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %x0|%x0, %6, %4}";
29843 return "%M2v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %0|%0, %6, %4}";
29844 }
29845 [(set_attr "type" "ssemov")
29846 (set_attr "addr" "gpr16")
29847 (set_attr "prefix" "vex")
29848 (set_attr "mode" "<sseinsnmode>")])
29849
29850 (define_insn "*avx2_gatherdi<VI4F_256:mode>_3"
29851 [(set (match_operand:<VEC_GATHER_SRCDI> 0 "register_operand" "=&x")
29852 (vec_select:<VEC_GATHER_SRCDI>
29853 (unspec:VI4F_256
29854 [(match_operand:<VEC_GATHER_SRCDI> 2 "register_operand" "0")
29855 (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
29856 [(unspec:P
29857 [(match_operand:P 3 "vsib_address_operand" "jb")
29858 (match_operand:<VEC_GATHER_IDXDI> 4 "register_operand" "x")
29859 (match_operand:SI 6 "const1248_operand")]
29860 UNSPEC_VSIBADDR)])
29861 (mem:BLK (scratch))
29862 (match_operand:<VEC_GATHER_SRCDI> 5 "register_operand" "1")]
29863 UNSPEC_GATHER)
29864 (parallel [(const_int 0) (const_int 1)
29865 (const_int 2) (const_int 3)])))
29866 (clobber (match_scratch:VI4F_256 1 "=&x"))]
29867 "TARGET_AVX2"
29868 "%M3v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %7, %0|%0, %7, %5}"
29869 [(set_attr "type" "ssemov")
29870 (set_attr "addr" "gpr16")
29871 (set_attr "prefix" "vex")
29872 (set_attr "mode" "<sseinsnmode>")])
29873
29874 (define_insn "*avx2_gatherdi<VI4F_256:mode>_4"
29875 [(set (match_operand:<VEC_GATHER_SRCDI> 0 "register_operand" "=&x")
29876 (vec_select:<VEC_GATHER_SRCDI>
29877 (unspec:VI4F_256
29878 [(pc)
29879 (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
29880 [(unspec:P
29881 [(match_operand:P 2 "vsib_address_operand" "jb")
29882 (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "x")
29883 (match_operand:SI 5 "const1248_operand")]
29884 UNSPEC_VSIBADDR)])
29885 (mem:BLK (scratch))
29886 (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand" "1")]
29887 UNSPEC_GATHER)
29888 (parallel [(const_int 0) (const_int 1)
29889 (const_int 2) (const_int 3)])))
29890 (clobber (match_scratch:VI4F_256 1 "=&x"))]
29891 "TARGET_AVX2"
29892 "%M2v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %0|%0, %6, %4}"
29893 [(set_attr "type" "ssemov")
29894 (set_attr "addr" "gpr16")
29895 (set_attr "prefix" "vex")
29896 (set_attr "mode" "<sseinsnmode>")])
29897
29898 (define_expand "<avx512>_gathersi<mode>"
29899 [(parallel [(set (match_operand:VI48F 0 "register_operand")
29900 (unspec:VI48F
29901 [(match_operand:VI48F 1 "register_operand")
29902 (match_operand:<avx512fmaskmode> 4 "register_operand")
29903 (mem:<ssescalarmode>
29904 (match_par_dup 6
29905 [(match_operand 2 "vsib_address_operand")
29906 (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand")
29907 (match_operand:SI 5 "const1248_operand")]))]
29908 UNSPEC_GATHER))
29909 (clobber (match_scratch:<avx512fmaskmode> 7))])]
29910 "TARGET_AVX512F"
29911 {
29912 operands[6]
29913 = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
29914 operands[5]), UNSPEC_VSIBADDR);
29915 })
29916
29917 (define_insn "*avx512f_gathersi<VI48F:mode>"
29918 [(set (match_operand:VI48F 0 "register_operand" "=&v")
29919 (unspec:VI48F
29920 [(match_operand:VI48F 1 "register_operand" "0")
29921 (match_operand:<avx512fmaskmode> 7 "register_operand" "2")
29922 (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
29923 [(unspec:P
29924 [(match_operand:P 4 "vsib_address_operand" "Tv")
29925 (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand" "v")
29926 (match_operand:SI 5 "const1248_operand")]
29927 UNSPEC_VSIBADDR)])]
29928 UNSPEC_GATHER))
29929 (clobber (match_scratch:<avx512fmaskmode> 2 "=&Yk"))]
29930 "TARGET_AVX512F"
29931 ;; %X6 so that we don't emit any *WORD PTR for -masm=intel, as
29932 ;; gas changed what it requires incompatibly.
29933 "%M4v<sseintprefix>gatherd<ssemodesuffix>\t{%6, %0%{%2%}|%0%{%2%}, %X6}"
29934 [(set_attr "type" "ssemov")
29935 (set_attr "prefix" "evex")
29936 (set_attr "mode" "<sseinsnmode>")])
29937
29938 (define_insn "*avx512f_gathersi<VI48F:mode>_2"
29939 [(set (match_operand:VI48F 0 "register_operand" "=&v")
29940 (unspec:VI48F
29941 [(pc)
29942 (match_operand:<avx512fmaskmode> 6 "register_operand" "1")
29943 (match_operator:<ssescalarmode> 5 "vsib_mem_operator"
29944 [(unspec:P
29945 [(match_operand:P 3 "vsib_address_operand" "Tv")
29946 (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand" "v")
29947 (match_operand:SI 4 "const1248_operand")]
29948 UNSPEC_VSIBADDR)])]
29949 UNSPEC_GATHER))
29950 (clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
29951 "TARGET_AVX512F"
29952 ;; %X5 so that we don't emit any *WORD PTR for -masm=intel, as
29953 ;; gas changed what it requires incompatibly.
29954 "%M3v<sseintprefix>gatherd<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %X5}"
29955 [(set_attr "type" "ssemov")
29956 (set_attr "prefix" "evex")
29957 (set_attr "mode" "<sseinsnmode>")])
29958
29959
29960 (define_expand "<avx512>_gatherdi<mode>"
29961 [(parallel [(set (match_operand:VI48F 0 "register_operand")
29962 (unspec:VI48F
29963 [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand")
29964 (match_operand:QI 4 "register_operand")
29965 (mem:<ssescalarmode>
29966 (match_par_dup 6
29967 [(match_operand 2 "vsib_address_operand")
29968 (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand")
29969 (match_operand:SI 5 "const1248_operand")]))]
29970 UNSPEC_GATHER))
29971 (clobber (match_scratch:QI 7))])]
29972 "TARGET_AVX512F"
29973 {
29974 operands[6]
29975 = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
29976 operands[5]), UNSPEC_VSIBADDR);
29977 })
29978
29979 (define_insn "*avx512f_gatherdi<VI48F:mode>"
29980 [(set (match_operand:VI48F 0 "register_operand" "=&v")
29981 (unspec:VI48F
29982 [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand" "0")
29983 (match_operand:QI 7 "register_operand" "2")
29984 (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
29985 [(unspec:P
29986 [(match_operand:P 4 "vsib_address_operand" "Tv")
29987 (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "v")
29988 (match_operand:SI 5 "const1248_operand")]
29989 UNSPEC_VSIBADDR)])]
29990 UNSPEC_GATHER))
29991 (clobber (match_scratch:QI 2 "=&Yk"))]
29992 "TARGET_AVX512F"
29993 ;; %X6 so that we don't emit any *WORD PTR for -masm=intel, as
29994 ;; gas changed what it requires incompatibly.
29995 "%M4v<sseintprefix>gatherq<ssemodesuffix>\t{%6, %1%{%2%}|%1%{%2%}, %X6}"
29996 [(set_attr "type" "ssemov")
29997 (set_attr "prefix" "evex")
29998 (set_attr "mode" "<sseinsnmode>")])
29999
30000 (define_insn "*avx512f_gatherdi<VI48F:mode>_2"
30001 [(set (match_operand:VI48F 0 "register_operand" "=&v")
30002 (unspec:VI48F
30003 [(pc)
30004 (match_operand:QI 6 "register_operand" "1")
30005 (match_operator:<ssescalarmode> 5 "vsib_mem_operator"
30006 [(unspec:P
30007 [(match_operand:P 3 "vsib_address_operand" "Tv")
30008 (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand" "v")
30009 (match_operand:SI 4 "const1248_operand")]
30010 UNSPEC_VSIBADDR)])]
30011 UNSPEC_GATHER))
30012 (clobber (match_scratch:QI 1 "=&Yk"))]
30013 "TARGET_AVX512F"
30014 {
30015 /* %X5 so that we don't emit any *WORD PTR for -masm=intel, as
30016 gas changed what it requires incompatibly. */
30017 if (<VI48F:MODE>mode != <VEC_GATHER_SRCDI>mode)
30018 {
30019 if (<VI48F:MODE_SIZE> != 64)
30020 return "%M3v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %x0%{%1%}|%x0%{%1%}, %X5}";
30021 else
30022 return "%M3v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %t0%{%1%}|%t0%{%1%}, %X5}";
30023 }
30024 return "%M3v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %X5}";
30025 }
30026 [(set_attr "type" "ssemov")
30027 (set_attr "prefix" "evex")
30028 (set_attr "mode" "<sseinsnmode>")])
30029
30030 (define_expand "<avx512>_scattersi<mode>"
30031 [(parallel [(set (mem:VI48F
30032 (match_par_dup 5
30033 [(match_operand 0 "vsib_address_operand")
30034 (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand")
30035 (match_operand:SI 4 "const1248_operand")]))
30036 (unspec:VI48F
30037 [(match_operand:<avx512fmaskmode> 1 "register_operand")
30038 (match_operand:VI48F 3 "register_operand")]
30039 UNSPEC_SCATTER))
30040 (clobber (match_scratch:<avx512fmaskmode> 6))])]
30041 "TARGET_AVX512F"
30042 {
30043 operands[5]
30044 = gen_rtx_UNSPEC (Pmode, gen_rtvec (4, operands[0], operands[2],
30045 operands[4], operands[1]),
30046 UNSPEC_VSIBADDR);
30047 })
30048
30049 (define_insn "*avx512f_scattersi<VI48F:mode>"
30050 [(set (match_operator:VI48F 5 "vsib_mem_operator"
30051 [(unspec:P
30052 [(match_operand:P 0 "vsib_address_operand" "Tv")
30053 (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand" "v")
30054 (match_operand:SI 4 "const1248_operand")
30055 (match_operand:<avx512fmaskmode> 6 "register_operand" "1")]
30056 UNSPEC_VSIBADDR)])
30057 (unspec:VI48F
30058 [(match_dup 6)
30059 (match_operand:VI48F 3 "register_operand" "v")]
30060 UNSPEC_SCATTER))
30061 (clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
30062 "TARGET_AVX512F"
30063 ;; %X5 so that we don't emit any *WORD PTR for -masm=intel, as
30064 ;; gas changed what it requires incompatibly.
30065 "%M0v<sseintprefix>scatterd<ssemodesuffix>\t{%3, %5%{%1%}|%X5%{%1%}, %3}"
30066 [(set_attr "type" "ssemov")
30067 (set_attr "prefix" "evex")
30068 (set_attr "mode" "<sseinsnmode>")])
30069
30070 (define_expand "<avx512>_scatterdi<mode>"
30071 [(parallel [(set (mem:VI48F
30072 (match_par_dup 5
30073 [(match_operand 0 "vsib_address_operand")
30074 (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand")
30075 (match_operand:SI 4 "const1248_operand")]))
30076 (unspec:VI48F
30077 [(match_operand:QI 1 "register_operand")
30078 (match_operand:<VEC_GATHER_SRCDI> 3 "register_operand")]
30079 UNSPEC_SCATTER))
30080 (clobber (match_scratch:QI 6))])]
30081 "TARGET_AVX512F"
30082 {
30083 operands[5]
30084 = gen_rtx_UNSPEC (Pmode, gen_rtvec (4, operands[0], operands[2],
30085 operands[4], operands[1]),
30086 UNSPEC_VSIBADDR);
30087 })
30088
30089 (define_insn "*avx512f_scatterdi<VI48F:mode>"
30090 [(set (match_operator:VI48F 5 "vsib_mem_operator"
30091 [(unspec:P
30092 [(match_operand:P 0 "vsib_address_operand" "Tv")
30093 (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand" "v")
30094 (match_operand:SI 4 "const1248_operand")
30095 (match_operand:QI 6 "register_operand" "1")]
30096 UNSPEC_VSIBADDR)])
30097 (unspec:VI48F
30098 [(match_dup 6)
30099 (match_operand:<VEC_GATHER_SRCDI> 3 "register_operand" "v")]
30100 UNSPEC_SCATTER))
30101 (clobber (match_scratch:QI 1 "=&Yk"))]
30102 "TARGET_AVX512F"
30103 ;; %X5 so that we don't emit any *WORD PTR for -masm=intel, as
30104 ;; gas changed what it requires incompatibly.
30105 "%M0v<sseintprefix>scatterq<ssemodesuffix>\t{%3, %5%{%1%}|%X5%{%1%}, %3}"
30106 [(set_attr "type" "ssemov")
30107 (set_attr "prefix" "evex")
30108 (set_attr "mode" "<sseinsnmode>")])
30109
30110 (define_insn "<avx512>_compress<mode>_mask"
30111 [(set (match_operand:VI48F 0 "register_operand" "=v")
30112 (unspec:VI48F
30113 [(match_operand:VI48F 1 "register_operand" "v")
30114 (match_operand:VI48F 2 "nonimm_or_0_operand" "0C")
30115 (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")]
30116 UNSPEC_COMPRESS))]
30117 "TARGET_AVX512F"
30118 "v<sseintprefix>compress<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
30119 [(set_attr "type" "ssemov")
30120 (set_attr "c86_attr" "compress")
30121 (set_attr "prefix" "evex")
30122 (set_attr "mode" "<sseinsnmode>")])
30123
30124 (define_insn "compress<mode>_mask"
30125 [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
30126 (unspec:VI12_AVX512VL
30127 [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
30128 (match_operand:VI12_AVX512VL 2 "nonimm_or_0_operand" "0C")
30129 (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")]
30130 UNSPEC_COMPRESS))]
30131 "TARGET_AVX512VBMI2"
30132 "vpcompress<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
30133 [(set_attr "type" "ssemov")
30134 (set_attr "c86_attr" "compress")
30135 (set_attr "prefix" "evex")
30136 (set_attr "mode" "<sseinsnmode>")])
30137
30138 (define_insn "<avx512>_compressstore<mode>_mask"
30139 [(set (match_operand:VI48F 0 "memory_operand" "=m")
30140 (unspec:VI48F
30141 [(match_operand:VI48F 1 "register_operand" "x")
30142 (match_dup 0)
30143 (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")]
30144 UNSPEC_COMPRESS_STORE))]
30145 "TARGET_AVX512F"
30146 "v<sseintprefix>compress<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
30147 [(set_attr "type" "ssemov")
30148 (set_attr "c86_attr" "compress")
30149 (set_attr "prefix" "evex")
30150 (set_attr "memory" "store")
30151 (set_attr "mode" "<sseinsnmode>")])
30152
30153 (define_insn "compressstore<mode>_mask"
30154 [(set (match_operand:VI12_AVX512VL 0 "memory_operand" "=m")
30155 (unspec:VI12_AVX512VL
30156 [(match_operand:VI12_AVX512VL 1 "register_operand" "x")
30157 (match_dup 0)
30158 (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")]
30159 UNSPEC_COMPRESS_STORE))]
30160 "TARGET_AVX512VBMI2"
30161 "vpcompress<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
30162 [(set_attr "type" "ssemov")
30163 (set_attr "c86_attr" "compress")
30164 (set_attr "prefix" "evex")
30165 (set_attr "memory" "store")
30166 (set_attr "mode" "<sseinsnmode>")])
30167
30168 (define_expand "<avx512>_expand<mode>_maskz"
30169 [(set (match_operand:VI48F 0 "register_operand")
30170 (unspec:VI48F
30171 [(match_operand:VI48F 1 "nonimmediate_operand")
30172 (match_operand:VI48F 2 "nonimm_or_0_operand")
30173 (match_operand:<avx512fmaskmode> 3 "register_operand")]
30174 UNSPEC_EXPAND))]
30175 "TARGET_AVX512F"
30176 "operands[2] = CONST0_RTX (<MODE>mode);")
30177
30178 (define_insn "expand<mode>_mask"
30179 [(set (match_operand:VI48F 0 "register_operand" "=v,v")
30180 (unspec:VI48F
30181 [(match_operand:VI48F 1 "nonimmediate_operand" "v,m")
30182 (match_operand:VI48F 2 "nonimm_or_0_operand" "0C,0C")
30183 (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")]
30184 UNSPEC_EXPAND))]
30185 "TARGET_AVX512F"
30186 "v<sseintprefix>expand<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
30187 [(set_attr "type" "ssemov")
30188 (set_attr "c86_attr" "expand")
30189 (set_attr "prefix" "evex")
30190 (set_attr "memory" "none,load")
30191 (set_attr "mode" "<sseinsnmode>")])
30192
30193 (define_insn "expand<mode>_mask"
30194 [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v,v")
30195 (unspec:VI12_AVX512VL
30196 [(match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "v,m")
30197 (match_operand:VI12_AVX512VL 2 "nonimm_or_0_operand" "0C,0C")
30198 (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")]
30199 UNSPEC_EXPAND))]
30200 "TARGET_AVX512VBMI2"
30201 "v<sseintprefix>expand<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
30202 [(set_attr "type" "ssemov")
30203 (set_attr "c86_attr" "expand")
30204 (set_attr "prefix" "evex")
30205 (set_attr "memory" "none,load")
30206 (set_attr "mode" "<sseinsnmode>")])
30207
30208 (define_insn_and_split "*expand<mode>_mask"
30209 [(set (match_operand:VI12_VI48F_AVX512VL 0 "register_operand")
30210 (unspec:VI12_VI48F_AVX512VL
30211 [(match_operand:VI12_VI48F_AVX512VL 1 "nonimmediate_operand")
30212 (match_operand:VI12_VI48F_AVX512VL 2 "nonimm_or_0_operand")
30213 (match_operand 3 "const_int_operand")]
30214 UNSPEC_EXPAND))]
30215 "ix86_pre_reload_split ()
30216 && (TARGET_AVX512VBMI2 || GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) >= 4)"
30217 "#"
30218 "&& 1"
30219 [(const_int 0)]
30220 {
30221 unsigned HOST_WIDE_INT mask = INTVAL (operands[3]);
30222 bool has_zero = false;
30223 unsigned n = GET_MODE_NUNITS (<MODE>mode), i;
30224 unsigned ones = 0;
30225
30226 /* If all ones bits is in mask's lower part,
30227 get number of ones and assign it to ONES. */
30228 for (i = 0; i != n; i++)
30229 {
30230 if ((mask & HOST_WIDE_INT_1U << i) && has_zero)
30231 break;
30232
30233 /* Record first zero bit. */
30234 if (!(mask & HOST_WIDE_INT_1U << i) && !has_zero)
30235 {
30236 has_zero = true;
30237 ones = i;
30238 }
30239 }
30240
30241 if (!has_zero)
30242 ones = n;
30243
30244 if (i != n || (ones != 0 && ones != n))
30245 {
30246 rtx reg = gen_reg_rtx (<avx512fmaskmode>mode);
30247 emit_move_insn (reg, operands[3]);
30248 enum insn_code icode;
30249 if (i == n)
30250 /* For masks with all one bits in it's lower part,
30251 we can transform v{,p}expand* to vmovdq* with
30252 mask operand. */
30253 icode = CODE_FOR_<avx512>_load<mode>_mask;
30254 else
30255 icode = CODE_FOR_expand<mode>_mask;
30256 emit_insn (GEN_FCN (icode) (operands[0], operands[1], operands[2], reg));
30257 }
30258 else
30259 /* For ALL_MASK_ONES or CONST0_RTX mask, transform it to simple mov. */
30260 emit_move_insn (operands[0], ones ? operands[1] : operands[2]);
30261 DONE;
30262 })
30263
30264 (define_expand "expand<mode>_maskz"
30265 [(set (match_operand:VI12_AVX512VL 0 "register_operand")
30266 (unspec:VI12_AVX512VL
30267 [(match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
30268 (match_operand:VI12_AVX512VL 2 "nonimm_or_0_operand")
30269 (match_operand:<avx512fmaskmode> 3 "register_operand")]
30270 UNSPEC_EXPAND))]
30271 "TARGET_AVX512VBMI2"
30272 "operands[2] = CONST0_RTX (<MODE>mode);")
30273
30274 (define_insn "avx512dq_rangep<mode><mask_name><round_saeonly_name>"
30275 [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
30276 (unspec:VF_AVX512VL
30277 [(match_operand:VF_AVX512VL 1 "register_operand" "v")
30278 (match_operand:VF_AVX512VL 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
30279 (match_operand:SI 3 "const_0_to_15_operand")]
30280 UNSPEC_RANGE))]
30281 "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
30282 {
30283 if (TARGET_DEST_FALSE_DEP_FOR_GLC
30284 && <mask4_dest_false_dep_for_glc_cond>
30285 && !reg_mentioned_p (operands[0], operands[1])
30286 && !reg_mentioned_p (operands[0], operands[2]))
30287 output_asm_insn ("vxorps\t%x0, %x0, %x0", operands);
30288 return "vrange<ssemodesuffix>\t{%3, <round_saeonly_mask_op4>%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2<round_saeonly_mask_op4>, %3}";
30289 }
30290 [(set_attr "type" "sse")
30291 (set_attr "prefix" "evex")
30292 (set_attr "mode" "<MODE>")])
30293
30294 (define_insn "avx512dq_ranges<mode><mask_scalar_name><round_saeonly_scalar_name>"
30295 [(set (match_operand:VF_128 0 "register_operand" "=v")
30296 (vec_merge:VF_128
30297 (unspec:VF_128
30298 [(match_operand:VF_128 1 "register_operand" "v")
30299 (match_operand:VF_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")
30300 (match_operand:SI 3 "const_0_to_15_operand")]
30301 UNSPEC_RANGE)
30302 (match_dup 1)
30303 (const_int 1)))]
30304 "TARGET_AVX512DQ"
30305 {
30306 if (TARGET_DEST_FALSE_DEP_FOR_GLC
30307 && <mask_scalar4_dest_false_dep_for_glc_cond>
30308 && !reg_mentioned_p (operands[0], operands[1])
30309 && !reg_mentioned_p (operands[0], operands[2]))
30310 output_asm_insn ("vxorps\t%x0, %x0, %x0", operands);
30311 return "vrange<ssescalarmodesuffix>\t{%3, <round_saeonly_scalar_mask_op4>%2, %1, %0<mask_scalar_operand4>|%0<mask_scalar_operand4>, %1, %<iptr>2<round_saeonly_scalar_mask_op4>, %3}";
30312 }
30313 [(set_attr "type" "sse")
30314 (set_attr "prefix" "evex")
30315 (set_attr "mode" "<MODE>")])
30316
30317 (define_insn "avx512dq_fpclass<mode><mask_scalar_merge_name>"
30318 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
30319 (unspec:<avx512fmaskmode>
30320 [(match_operand:VFH_AVX512VL 1 "vector_operand" "vm")
30321 (match_operand 2 "const_0_to_255_operand")]
30322 UNSPEC_FPCLASS))]
30323 "TARGET_AVX512DQ || VALID_AVX512FP16_REG_MODE(<MODE>mode)"
30324 "vfpclass<ssemodesuffix><vecmemsuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}";
30325 [(set_attr "type" "sse")
30326 (set_attr "length_immediate" "1")
30327 (set_attr "prefix" "evex")
30328 (set_attr "mode" "<MODE>")])
30329
30330 (define_insn "avx512dq_vmfpclass<mode><mask_scalar_merge_name>"
30331 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
30332 (and:<avx512fmaskmode>
30333 (unspec:<avx512fmaskmode>
30334 [(match_operand:VFH_128 1 "nonimmediate_operand" "vm")
30335 (match_operand 2 "const_0_to_255_operand")]
30336 UNSPEC_FPCLASS)
30337 (const_int 1)))]
30338 "TARGET_AVX512DQ || VALID_AVX512FP16_REG_MODE(<MODE>mode)"
30339 "vfpclass<ssescalarmodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %<iptr>1, %2}";
30340 [(set_attr "type" "sse")
30341 (set_attr "length_immediate" "1")
30342 (set_attr "prefix" "evex")
30343 (set_attr "mode" "<MODE>")])
30344
30345 (define_insn "<avx512>_getmant<mode><mask_name><round_saeonly_name>"
30346 [(set (match_operand:VFH_AVX512VL 0 "register_operand" "=v")
30347 (unspec:VFH_AVX512VL
30348 [(match_operand:VFH_AVX512VL 1 "nonimmediate_operand" "<round_saeonly_constraint>")
30349 (match_operand:SI 2 "const_0_to_15_operand")]
30350 UNSPEC_GETMANT))]
30351 "TARGET_AVX512F"
30352 {
30353 if (TARGET_DEST_FALSE_DEP_FOR_GLC
30354 && <mask3_dest_false_dep_for_glc_cond>
30355 && MEM_P (operands[1]))
30356 output_asm_insn ("vxorps\t%x0, %x0, %x0", operands);
30357 return "vgetmant<ssemodesuffix>\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}";
30358 }
30359 [(set_attr "prefix" "evex")
30360 (set_attr "mode" "<MODE>")])
30361
30362 (define_insn "avx512f_vgetmant<mode><mask_scalar_name><round_saeonly_scalar_name>"
30363 [(set (match_operand:VFH_128 0 "register_operand" "=v")
30364 (vec_merge:VFH_128
30365 (unspec:VFH_128
30366 [(match_operand:VFH_128 1 "register_operand" "v")
30367 (match_operand:VFH_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")
30368 (match_operand:SI 3 "const_0_to_15_operand")]
30369 UNSPEC_GETMANT)
30370 (match_dup 1)
30371 (const_int 1)))]
30372 "TARGET_AVX512F"
30373 {
30374 if (TARGET_DEST_FALSE_DEP_FOR_GLC
30375 && <mask_scalar4_dest_false_dep_for_glc_cond>
30376 && !reg_mentioned_p (operands[0], operands[1])
30377 && !reg_mentioned_p (operands[0], operands[2]))
30378 output_asm_insn ("vxorps\t%x0, %x0, %x0", operands);
30379 return "vgetmant<ssescalarmodesuffix>\t{%3, <round_saeonly_scalar_mask_op4>%2, %1, %0<mask_scalar_operand4>|%0<mask_scalar_operand4>, %1, %<iptr>2<round_saeonly_scalar_mask_op4>, %3}";
30380 }
30381 [(set_attr "prefix" "evex")
30382 (set_attr "mode" "<ssescalarmode>")])
30383
30384 ;; The correct representation for this is absolutely enormous, and
30385 ;; surely not generally useful.
30386 (define_insn "<mask_codefor>avx512bw_dbpsadbw<mode><mask_name>"
30387 [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
30388 (unspec:VI2_AVX512VL
30389 [(match_operand:<dbpsadbwmode> 1 "register_operand" "v")
30390 (match_operand:<dbpsadbwmode> 2 "nonimmediate_operand" "vm")
30391 (match_operand:SI 3 "const_0_to_255_operand")]
30392 UNSPEC_DBPSADBW))]
30393 "TARGET_AVX512BW"
30394 "vdbpsadbw\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}"
30395 [(set_attr "type" "sselog1")
30396 (set_attr "c86_attr" "sadbw")
30397 (set_attr "length_immediate" "1")
30398 (set_attr "prefix" "evex")
30399 (set_attr "mode" "<sseinsnmode>")])
30400
30401 (define_insn "clz<mode>2<mask_name>"
30402 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
30403 (clz:VI48_AVX512VL
30404 (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")))]
30405 "TARGET_AVX512CD"
30406 "vplzcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
30407 [(set_attr "type" "sse")
30408 (set_attr "c86_attr" "abs")
30409 (set_attr "prefix" "evex")
30410 (set_attr "mode" "<sseinsnmode>")])
30411
30412 (define_insn "<mask_codefor>conflict<mode><mask_name>"
30413 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
30414 (unspec:VI48_AVX512VL
30415 [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")]
30416 UNSPEC_CONFLICT))]
30417 "TARGET_AVX512CD"
30418 "vpconflict<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
30419 [(set_attr "type" "sse")
30420 (set_attr "prefix" "evex")
30421 (set_attr "c86_decode" "vector")
30422 (set_attr "mode" "<sseinsnmode>")])
30423
30424 (define_insn "sha1msg1"
30425 [(set (match_operand:V4SI 0 "register_operand" "=x")
30426 (unspec:V4SI
30427 [(match_operand:V4SI 1 "register_operand" "0")
30428 (match_operand:V4SI 2 "vector_operand" "xja")]
30429 UNSPEC_SHA1MSG1))]
30430 "TARGET_SHA"
30431 "sha1msg1\t{%2, %0|%0, %2}"
30432 [(set_attr "type" "sselog1")
30433 (set_attr "mode" "TI")])
30434
30435 (define_insn "sha1msg2"
30436 [(set (match_operand:V4SI 0 "register_operand" "=x")
30437 (unspec:V4SI
30438 [(match_operand:V4SI 1 "register_operand" "0")
30439 (match_operand:V4SI 2 "vector_operand" "xja")]
30440 UNSPEC_SHA1MSG2))]
30441 "TARGET_SHA"
30442 "sha1msg2\t{%2, %0|%0, %2}"
30443 [(set_attr "type" "sselog1")
30444 (set_attr "mode" "TI")])
30445
30446 (define_insn "sha1nexte"
30447 [(set (match_operand:V4SI 0 "register_operand" "=x")
30448 (unspec:V4SI
30449 [(match_operand:V4SI 1 "register_operand" "0")
30450 (match_operand:V4SI 2 "vector_operand" "xja")]
30451 UNSPEC_SHA1NEXTE))]
30452 "TARGET_SHA"
30453 "sha1nexte\t{%2, %0|%0, %2}"
30454 [(set_attr "type" "sselog1")
30455 (set_attr "mode" "TI")])
30456
30457 (define_insn "sha1rnds4"
30458 [(set (match_operand:V4SI 0 "register_operand" "=x")
30459 (unspec:V4SI
30460 [(match_operand:V4SI 1 "register_operand" "0")
30461 (match_operand:V4SI 2 "vector_operand" "xja")
30462 (match_operand:SI 3 "const_0_to_3_operand")]
30463 UNSPEC_SHA1RNDS4))]
30464 "TARGET_SHA"
30465 "sha1rnds4\t{%3, %2, %0|%0, %2, %3}"
30466 [(set_attr "type" "sselog1")
30467 (set_attr "length_immediate" "1")
30468 (set_attr "mode" "TI")])
30469
30470 (define_insn "sha256msg1"
30471 [(set (match_operand:V4SI 0 "register_operand" "=x")
30472 (unspec:V4SI
30473 [(match_operand:V4SI 1 "register_operand" "0")
30474 (match_operand:V4SI 2 "vector_operand" "xja")]
30475 UNSPEC_SHA256MSG1))]
30476 "TARGET_SHA"
30477 "sha256msg1\t{%2, %0|%0, %2}"
30478 [(set_attr "type" "sselog1")
30479 (set_attr "mode" "TI")])
30480
30481 (define_insn "sha256msg2"
30482 [(set (match_operand:V4SI 0 "register_operand" "=x")
30483 (unspec:V4SI
30484 [(match_operand:V4SI 1 "register_operand" "0")
30485 (match_operand:V4SI 2 "vector_operand" "xja")]
30486 UNSPEC_SHA256MSG2))]
30487 "TARGET_SHA"
30488 "sha256msg2\t{%2, %0|%0, %2}"
30489 [(set_attr "type" "sselog1")
30490 (set_attr "mode" "TI")])
30491
30492 (define_insn "sha256rnds2"
30493 [(set (match_operand:V4SI 0 "register_operand" "=x")
30494 (unspec:V4SI
30495 [(match_operand:V4SI 1 "register_operand" "0")
30496 (match_operand:V4SI 2 "vector_operand" "xja")
30497 (match_operand:V4SI 3 "register_operand" "Yz")]
30498 UNSPEC_SHA256RNDS2))]
30499 "TARGET_SHA"
30500 "sha256rnds2\t{%3, %2, %0|%0, %2, %3}"
30501 [(set_attr "type" "sselog1")
30502 (set_attr "length_immediate" "1")
30503 (set_attr "mode" "TI")])
30504
30505 (define_insn "vsm3msg1"
30506 [(set (match_operand:V4SI 0 "register_operand" "=x")
30507 (unspec:V4SI
30508 [(match_operand:V4SI 1 "register_operand" "0")
30509 (match_operand:V4SI 2 "register_operand" "x")
30510 (match_operand:V4SI 3 "vector_operand" "xBm")]
30511 UNSPEC_SM3MSG1))]
30512 "TARGET_SM3"
30513 "vsm3msg1\t{%3, %2, %0|%0, %2, %3}"
30514 [(set_attr "type" "other")
30515 (set_attr "mode" "TI")])
30516
30517 (define_insn "vsm3msg2"
30518 [(set (match_operand:V4SI 0 "register_operand" "=x")
30519 (unspec:V4SI
30520 [(match_operand:V4SI 1 "register_operand" "0")
30521 (match_operand:V4SI 2 "register_operand" "x")
30522 (match_operand:V4SI 3 "vector_operand" "xBm")]
30523 UNSPEC_SM3MSG2))]
30524 "TARGET_SM3"
30525 "vsm3msg2\t{%3, %2, %0|%0, %2, %3}"
30526 [(set_attr "type" "other")
30527 (set_attr "mode" "TI")])
30528
30529 (define_insn "vsm3rnds2"
30530 [(set (match_operand:V4SI 0 "register_operand" "=x")
30531 (unspec:V4SI
30532 [(match_operand:V4SI 1 "register_operand" "0")
30533 (match_operand:V4SI 2 "register_operand" "x")
30534 (match_operand:V4SI 3 "vector_operand" "xBm")
30535 (match_operand:SI 4 "const_0_to_255_operand" "n")]
30536 UNSPEC_SM3RNDS2))]
30537 "TARGET_SM3"
30538 "vsm3rnds2\t{%4, %3, %2, %0|%0, %2, %3, %4}"
30539 [(set_attr "type" "other")
30540 (set_attr "mode" "TI")
30541 (set_attr "length_immediate" "1")])
30542
30543 (define_insn "vsha512msg1"
30544 [(set (match_operand:V4DI 0 "register_operand" "=x")
30545 (unspec:V4DI
30546 [(match_operand:V4DI 1 "register_operand" "0")
30547 (match_operand:V2DI 2 "register_operand" "x")]
30548 UNSPEC_SHA512MSG1))]
30549 "TARGET_SHA512"
30550 "vsha512msg1\t{%2, %0|%0, %2}"
30551 [(set_attr "type" "sselog1")
30552 (set_attr "mode" "OI")])
30553
30554 (define_insn "vsha512msg2"
30555 [(set (match_operand:V4DI 0 "register_operand" "=x")
30556 (unspec:V4DI
30557 [(match_operand:V4DI 1 "register_operand" "0")
30558 (match_operand:V4DI 2 "register_operand" "x")]
30559 UNSPEC_SHA512MSG2))]
30560 "TARGET_SHA512"
30561 "vsha512msg2\t{%2, %0|%0, %2}"
30562 [(set_attr "type" "sselog1")
30563 (set_attr "mode" "OI")])
30564
30565 (define_insn "vsha512rnds2"
30566 [(set (match_operand:V4DI 0 "register_operand" "=x")
30567 (unspec:V4DI
30568 [(match_operand:V4DI 1 "register_operand" "0")
30569 (match_operand:V4DI 2 "register_operand" "x")
30570 (match_operand:V2DI 3 "register_operand" "x")]
30571 UNSPEC_SHA512RNDS2))]
30572 "TARGET_SHA512"
30573 "vsha512rnds2\t{%3, %2, %0|%0, %2, %3}"
30574 [(set_attr "type" "sselog1")
30575 (set_attr "mode" "OI")])
30576
30577 (define_insn "vsm4key4_<mode>"
30578 [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=x,v")
30579 (unspec:VI4_AVX10_2
30580 [(match_operand:VI4_AVX10_2 1 "register_operand" "x,v")
30581 (match_operand:VI4_AVX10_2 2 "vector_operand" "xBm,vBm")]
30582 UNSPEC_SM4KEY4))]
30583 "TARGET_SM4"
30584 "vsm4key4\t{%2, %1, %0|%0, %1, %2}"
30585 [(set_attr "type" "other")
30586 (set_attr "prefix" "maybe_evex")
30587 (set_attr "isa" "avx,avx10_2")
30588 (set_attr "mode" "<sseinsnmode>")])
30589
30590 (define_insn "vsm4rnds4_<mode>"
30591 [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=x,v")
30592 (unspec:VI4_AVX10_2
30593 [(match_operand:VI4_AVX10_2 1 "register_operand" "x,v")
30594 (match_operand:VI4_AVX10_2 2 "vector_operand" "xBm,vBm")]
30595 UNSPEC_SM4RNDS4))]
30596 "TARGET_SM4"
30597 "vsm4rnds4\t{%2, %1, %0|%0, %1, %2}"
30598 [(set_attr "type" "other")
30599 (set_attr "prefix" "maybe_evex")
30600 (set_attr "isa" "avx,avx10_2")
30601 (set_attr "mode" "<sseinsnmode>")])
30602
30603 (define_insn_and_split "avx512f_<castmode><avxsizesuffix>_<castmode>"
30604 [(set (match_operand:AVX512MODE2P 0 "nonimmediate_operand" "=x,m")
30605 (vec_concat:AVX512MODE2P
30606 (vec_concat:<ssehalfvecmode>
30607 (match_operand:<ssequartermode> 1 "nonimmediate_operand" "xm,x")
30608 (unspec:<ssequartermode> [(const_int 0)] UNSPEC_CAST))
30609 (unspec:<ssehalfvecmode> [(const_int 0)] UNSPEC_CAST)))]
30610 "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
30611 "#"
30612 "&& reload_completed"
30613 [(set (match_dup 0) (match_dup 1))]
30614 {
30615 if (REG_P (operands[0]))
30616 operands[0] = gen_lowpart (<ssequartermode>mode, operands[0]);
30617 else
30618 operands[1] = lowpart_subreg (<MODE>mode, operands[1],
30619 <ssequartermode>mode);
30620 })
30621
30622 (define_insn_and_split "avx512f_<castmode><avxsizesuffix>_256<castmode>"
30623 [(set (match_operand:AVX512MODE2P 0 "nonimmediate_operand" "=x,m")
30624 (vec_concat:AVX512MODE2P
30625 (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "xm,x")
30626 (unspec:<ssehalfvecmode> [(const_int 0)] UNSPEC_CAST)))]
30627 "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
30628 "#"
30629 "&& reload_completed"
30630 [(set (match_dup 0) (match_dup 1))]
30631 {
30632 if (REG_P (operands[0]))
30633 operands[0] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);
30634 else
30635 operands[1] = lowpart_subreg (<MODE>mode, operands[1],
30636 <ssehalfvecmode>mode);
30637 })
30638
30639 (define_int_iterator VPMADD52
30640 [UNSPEC_VPMADD52LUQ
30641 UNSPEC_VPMADD52HUQ])
30642
30643 (define_int_attr vpmadd52type
30644 [(UNSPEC_VPMADD52LUQ "luq") (UNSPEC_VPMADD52HUQ "huq")])
30645
30646 (define_expand "vpmadd52huq<mode>_maskz"
30647 [(match_operand:VI8_AVX512VL 0 "register_operand")
30648 (match_operand:VI8_AVX512VL 1 "register_operand")
30649 (match_operand:VI8_AVX512VL 2 "register_operand")
30650 (match_operand:VI8_AVX512VL 3 "nonimmediate_operand")
30651 (match_operand:<avx512fmaskmode> 4 "register_operand")]
30652 "TARGET_AVX512IFMA"
30653 {
30654 emit_insn (gen_vpmadd52huq<mode>_maskz_1 (
30655 operands[0], operands[1], operands[2], operands[3],
30656 CONST0_RTX (<MODE>mode), operands[4]));
30657 DONE;
30658 })
30659
30660 (define_expand "vpmadd52luq<mode>_maskz"
30661 [(match_operand:VI8_AVX512VL 0 "register_operand")
30662 (match_operand:VI8_AVX512VL 1 "register_operand")
30663 (match_operand:VI8_AVX512VL 2 "register_operand")
30664 (match_operand:VI8_AVX512VL 3 "nonimmediate_operand")
30665 (match_operand:<avx512fmaskmode> 4 "register_operand")]
30666 "TARGET_AVX512IFMA"
30667 {
30668 emit_insn (gen_vpmadd52luq<mode>_maskz_1 (
30669 operands[0], operands[1], operands[2], operands[3],
30670 CONST0_RTX (<MODE>mode), operands[4]));
30671 DONE;
30672 })
30673
30674 (define_insn "vpmadd52<vpmadd52type>v8di"
30675 [(set (match_operand:V8DI 0 "register_operand" "=v")
30676 (unspec:V8DI
30677 [(match_operand:V8DI 1 "register_operand" "0")
30678 (match_operand:V8DI 2 "register_operand" "v")
30679 (match_operand:V8DI 3 "nonimmediate_operand" "vm")]
30680 VPMADD52))]
30681 "TARGET_AVX512IFMA && TARGET_EVEX512"
30682 "vpmadd52<vpmadd52type>\t{%3, %2, %0|%0, %2, %3}"
30683 [(set_attr "type" "ssemuladd")
30684 (set_attr "c86_attr" "madd")
30685 (set_attr "prefix" "evex")
30686 (set_attr "mode" "XI")])
30687
30688 (define_insn "vpmadd52<vpmadd52type><mode>"
30689 [(set (match_operand:VI8_AVX2 0 "register_operand" "=x,v")
30690 (unspec:VI8_AVX2
30691 [(match_operand:VI8_AVX2 1 "register_operand" "0,0")
30692 (match_operand:VI8_AVX2 2 "register_operand" "x,v")
30693 (match_operand:VI8_AVX2 3 "nonimmediate_operand" "xjm,vm")]
30694 VPMADD52))]
30695 "TARGET_AVXIFMA || (TARGET_AVX512IFMA && TARGET_AVX512VL)"
30696 "@
30697 %{vex%} vpmadd52<vpmadd52type>\t{%3, %2, %0|%0, %2, %3}
30698 vpmadd52<vpmadd52type>\t{%3, %2, %0|%0, %2, %3}"
30699 [(set_attr "isa" "avxifma,avx512ifmavl")
30700 (set_attr "type" "ssemuladd")
30701 (set_attr "c86_attr" "madd")
30702 (set_attr "addr" "gpr16,*")
30703 (set_attr "prefix" "vex,evex")
30704 (set_attr "mode" "<sseinsnmode>")])
30705
30706 (define_insn "vpmadd52<vpmadd52type><mode>_maskz_1"
30707 [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
30708 (vec_merge:VI8_AVX512VL
30709 (unspec:VI8_AVX512VL
30710 [(match_operand:VI8_AVX512VL 1 "register_operand" "0")
30711 (match_operand:VI8_AVX512VL 2 "register_operand" "v")
30712 (match_operand:VI8_AVX512VL 3 "nonimmediate_operand" "vm")]
30713 VPMADD52)
30714 (match_operand:VI8_AVX512VL 4 "const0_operand" "C")
30715 (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
30716 "TARGET_AVX512IFMA"
30717 "vpmadd52<vpmadd52type>\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3}"
30718 [(set_attr "type" "ssemuladd")
30719 (set_attr "c86_attr" "madd")
30720 (set_attr "prefix" "evex")
30721 (set_attr "mode" "<sseinsnmode>")])
30722
30723 (define_insn "vpmadd52<vpmadd52type><mode>_mask"
30724 [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
30725 (vec_merge:VI8_AVX512VL
30726 (unspec:VI8_AVX512VL
30727 [(match_operand:VI8_AVX512VL 1 "register_operand" "0")
30728 (match_operand:VI8_AVX512VL 2 "register_operand" "v")
30729 (match_operand:VI8_AVX512VL 3 "nonimmediate_operand" "vm")]
30730 VPMADD52)
30731 (match_dup 1)
30732 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
30733 "TARGET_AVX512IFMA"
30734 "vpmadd52<vpmadd52type>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
30735 [(set_attr "type" "ssemuladd")
30736 (set_attr "c86_attr" "madd")
30737 (set_attr "prefix" "evex")
30738 (set_attr "mode" "<sseinsnmode>")])
30739
30740 (define_insn "vpmultishiftqb<mode><mask_name>"
30741 [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
30742 (unspec:VI1_AVX512VL
30743 [(match_operand:VI1_AVX512VL 1 "register_operand" "v")
30744 (match_operand:VI1_AVX512VL 2 "nonimmediate_operand" "vm")]
30745 UNSPEC_VPMULTISHIFT))]
30746 "TARGET_AVX512VBMI"
30747 "vpmultishiftqb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
30748 [(set_attr "type" "sselog")
30749 (set_attr "prefix" "evex")
30750 (set_attr "mode" "<sseinsnmode>")])
30751
30752 (define_expand "popcount<mode>2"
30753 [(set (match_operand:VI48_AVX512VL 0 "register_operand")
30754 (popcount:VI48_AVX512VL
30755 (match_operand:VI48_AVX512VL 1 "nonimmediate_operand")))]
30756 "TARGET_AVX512VPOPCNTDQ")
30757
30758 (define_insn "vpopcount<mode><mask_name>"
30759 [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
30760 (popcount:VI48_AVX512VL
30761 (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")))]
30762 "TARGET_AVX512VPOPCNTDQ"
30763 "vpopcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}")
30764
30765 ;; Save multiple registers out-of-line.
30766 (define_insn "*save_multiple<mode>"
30767 [(match_parallel 0 "save_multiple"
30768 [(use (match_operand:P 1 "symbol_operand"))])]
30769 "TARGET_SSE && TARGET_64BIT"
30770 "call\t%P1")
30771
30772 ;; Restore multiple registers out-of-line.
30773 (define_insn "*restore_multiple<mode>"
30774 [(match_parallel 0 "restore_multiple"
30775 [(use (match_operand:P 1 "symbol_operand"))])]
30776 "TARGET_SSE && TARGET_64BIT"
30777 "call\t%P1")
30778
30779 ;; Restore multiple registers out-of-line and return.
30780 (define_insn "*restore_multiple_and_return<mode>"
30781 [(match_parallel 0 "restore_multiple"
30782 [(return)
30783 (use (match_operand:P 1 "symbol_operand"))
30784 (set (reg:DI SP_REG) (reg:DI R10_REG))
30785 ])]
30786 "TARGET_SSE && TARGET_64BIT"
30787 "jmp\t%P1")
30788
30789 ;; Restore multiple registers out-of-line when hard frame pointer is used,
30790 ;; perform the leave operation prior to returning (from the function).
30791 (define_insn "*restore_multiple_leave_return<mode>"
30792 [(match_parallel 0 "restore_multiple"
30793 [(return)
30794 (use (match_operand:P 1 "symbol_operand"))
30795 (set (reg:DI SP_REG) (plus:DI (reg:DI BP_REG) (const_int 8)))
30796 (set (reg:DI BP_REG) (mem:DI (reg:DI BP_REG)))
30797 (clobber (mem:BLK (scratch)))
30798 ])]
30799 "TARGET_SSE && TARGET_64BIT"
30800 "jmp\t%P1")
30801
30802 (define_expand "popcount<mode>2"
30803 [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
30804 (popcount:VI12_AVX512VL
30805 (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "vm")))]
30806 "TARGET_AVX512BITALG")
30807
30808 (define_insn "vpopcount<mode><mask_name>"
30809 [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
30810 (popcount:VI12_AVX512VL
30811 (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "vm")))]
30812 "TARGET_AVX512BITALG"
30813 "vpopcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}")
30814
30815 (define_insn "vgf2p8affineinvqb_<mode><mask_name>"
30816 [(set (match_operand:VI1_AVX512F 0 "register_operand" "=x,v")
30817 (unspec:VI1_AVX512F
30818 [(match_operand:VI1_AVX512F 1 "register_operand" "0,v")
30819 (match_operand:VI1_AVX512F 2 "vector_operand" "xja,vm")
30820 (match_operand 3 "const_0_to_255_operand")]
30821 UNSPEC_GF2P8AFFINEINV))]
30822 "TARGET_GFNI"
30823 "@
30824 gf2p8affineinvqb\t{%3, %2, %0| %0, %2, %3}
30825 vgf2p8affineinvqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}"
30826 [(set_attr "isa" "noavx,avx")
30827 (set_attr "addr" "gpr16,*")
30828 (set_attr "prefix_extra" "1")
30829 (set_attr "prefix" "orig,maybe_evex")
30830 (set_attr "mode" "<sseinsnmode>")])
30831
30832 (define_insn "vgf2p8affineqb_<mode><mask_name>"
30833 [(set (match_operand:VI1_AVX512F 0 "register_operand" "=x,v")
30834 (unspec:VI1_AVX512F
30835 [(match_operand:VI1_AVX512F 1 "register_operand" "0,v")
30836 (match_operand:VI1_AVX512F 2 "vector_operand" "xja,vm")
30837 (match_operand 3 "const_0_to_255_operand")]
30838 UNSPEC_GF2P8AFFINE))]
30839 "TARGET_GFNI"
30840 "@
30841 gf2p8affineqb\t{%3, %2, %0| %0, %2, %3}
30842 vgf2p8affineqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}"
30843 [(set_attr "isa" "noavx,avx")
30844 (set_attr "addr" "gpr16,*")
30845 (set_attr "prefix_extra" "1")
30846 (set_attr "prefix" "orig,maybe_evex")
30847 (set_attr "mode" "<sseinsnmode>")])
30848
30849 (define_insn "vgf2p8mulb_<mode><mask_name>"
30850 [(set (match_operand:VI1_AVX512F 0 "register_operand" "=x,v")
30851 (unspec:VI1_AVX512F
30852 [(match_operand:VI1_AVX512F 1 "register_operand" "%0,v")
30853 (match_operand:VI1_AVX512F 2 "vector_operand" "xja,vm")]
30854 UNSPEC_GF2P8MUL))]
30855 "TARGET_GFNI"
30856 "@
30857 gf2p8mulb\t{%2, %0| %0, %2}
30858 vgf2p8mulb\t{%2, %1, %0<mask_operand3>| %0<mask_operand3>, %1, %2}"
30859 [(set_attr "isa" "noavx,avx")
30860 (set_attr "addr" "gpr16,*")
30861 (set_attr "prefix_extra" "1")
30862 (set_attr "prefix" "orig,maybe_evex")
30863 (set_attr "mode" "<sseinsnmode>")])
30864
30865 (define_insn "vpshrd_<mode><mask_name>"
30866 [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
30867 (unspec:VI248_AVX512VL
30868 [(match_operand:VI248_AVX512VL 1 "register_operand" "v")
30869 (match_operand:VI248_AVX512VL 2 "nonimmediate_operand" "vm")
30870 (match_operand:SI 3 "const_0_to_255_operand")]
30871 UNSPEC_VPSHRD))]
30872 "TARGET_AVX512VBMI2"
30873 "vpshrd<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3 }"
30874 [(set_attr ("prefix") ("evex"))])
30875
30876 (define_insn "vpshld_<mode><mask_name>"
30877 [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
30878 (unspec:VI248_AVX512VL
30879 [(match_operand:VI248_AVX512VL 1 "register_operand" "v")
30880 (match_operand:VI248_AVX512VL 2 "nonimmediate_operand" "vm")
30881 (match_operand:SI 3 "const_0_to_255_operand")]
30882 UNSPEC_VPSHLD))]
30883 "TARGET_AVX512VBMI2"
30884 "vpshld<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3 }"
30885 [(set_attr ("prefix") ("evex"))])
30886
30887 (define_insn "vpshrdv_<mode>"
30888 [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
30889 (unspec:VI248_AVX512VL
30890 [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
30891 (match_operand:VI248_AVX512VL 2 "register_operand" "v")
30892 (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
30893 UNSPEC_VPSHRDV))]
30894 "TARGET_AVX512VBMI2"
30895 "vpshrdv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3 }"
30896 [(set_attr ("prefix") ("evex"))
30897 (set_attr "mode" "<sseinsnmode>")])
30898
30899 (define_insn "vpshrdv_<mode>_mask"
30900 [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
30901 (vec_merge:VI248_AVX512VL
30902 (unspec:VI248_AVX512VL
30903 [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
30904 (match_operand:VI248_AVX512VL 2 "register_operand" "v")
30905 (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
30906 UNSPEC_VPSHRDV)
30907 (match_dup 1)
30908 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
30909 "TARGET_AVX512VBMI2"
30910 "vpshrdv<ssemodesuffix>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
30911 [(set_attr ("prefix") ("evex"))
30912 (set_attr "mode" "<sseinsnmode>")])
30913
30914 (define_expand "vpshrdv_<mode>_maskz"
30915 [(match_operand:VI248_AVX512VL 0 "register_operand")
30916 (match_operand:VI248_AVX512VL 1 "register_operand")
30917 (match_operand:VI248_AVX512VL 2 "register_operand")
30918 (match_operand:VI248_AVX512VL 3 "nonimmediate_operand")
30919 (match_operand:<avx512fmaskmode> 4 "register_operand")]
30920 "TARGET_AVX512VBMI2"
30921 {
30922 emit_insn (gen_vpshrdv_<mode>_maskz_1 (operands[0], operands[1],
30923 operands[2], operands[3],
30924 CONST0_RTX (<MODE>mode),
30925 operands[4]));
30926 DONE;
30927 })
30928
30929 (define_insn "vpshrdv_<mode>_maskz_1"
30930 [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
30931 (vec_merge:VI248_AVX512VL
30932 (unspec:VI248_AVX512VL
30933 [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
30934 (match_operand:VI248_AVX512VL 2 "register_operand" "v")
30935 (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
30936 UNSPEC_VPSHRDV)
30937 (match_operand:VI248_AVX512VL 4 "const0_operand")
30938 (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
30939 "TARGET_AVX512VBMI2"
30940 "vpshrdv<ssemodesuffix>\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
30941 [(set_attr ("prefix") ("evex"))
30942 (set_attr "mode" "<sseinsnmode>")])
30943
30944 (define_insn "vpshldv_<mode>"
30945 [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
30946 (unspec:VI248_AVX512VL
30947 [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
30948 (match_operand:VI248_AVX512VL 2 "register_operand" "v")
30949 (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
30950 UNSPEC_VPSHLDV))]
30951 "TARGET_AVX512VBMI2"
30952 "vpshldv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3 }"
30953 [(set_attr ("prefix") ("evex"))
30954 (set_attr "mode" "<sseinsnmode>")])
30955
30956 (define_insn "vpshldv_<mode>_mask"
30957 [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
30958 (vec_merge:VI248_AVX512VL
30959 (unspec:VI248_AVX512VL
30960 [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
30961 (match_operand:VI248_AVX512VL 2 "register_operand" "v")
30962 (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
30963 UNSPEC_VPSHLDV)
30964 (match_dup 1)
30965 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
30966 "TARGET_AVX512VBMI2"
30967 "vpshldv<ssemodesuffix>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
30968 [(set_attr ("prefix") ("evex"))
30969 (set_attr "mode" "<sseinsnmode>")])
30970
30971 (define_expand "vpshldv_<mode>_maskz"
30972 [(match_operand:VI248_AVX512VL 0 "register_operand")
30973 (match_operand:VI248_AVX512VL 1 "register_operand")
30974 (match_operand:VI248_AVX512VL 2 "register_operand")
30975 (match_operand:VI248_AVX512VL 3 "nonimmediate_operand")
30976 (match_operand:<avx512fmaskmode> 4 "register_operand")]
30977 "TARGET_AVX512VBMI2"
30978 {
30979 emit_insn (gen_vpshldv_<mode>_maskz_1 (operands[0], operands[1],
30980 operands[2], operands[3],
30981 CONST0_RTX (<MODE>mode),
30982 operands[4]));
30983 DONE;
30984 })
30985
30986 (define_insn "vpshldv_<mode>_maskz_1"
30987 [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
30988 (vec_merge:VI248_AVX512VL
30989 (unspec:VI248_AVX512VL
30990 [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
30991 (match_operand:VI248_AVX512VL 2 "register_operand" "v")
30992 (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
30993 UNSPEC_VPSHLDV)
30994 (match_operand:VI248_AVX512VL 4 "const0_operand")
30995 (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
30996 "TARGET_AVX512VBMI2"
30997 "vpshldv<ssemodesuffix>\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
30998 [(set_attr ("prefix") ("evex"))
30999 (set_attr "mode" "<sseinsnmode>")])
31000
31001 (define_expand "usdot_prod<ssedvecmodelower><mode>"
31002 [(match_operand:<ssedvecmode> 0 "register_operand")
31003 (match_operand:VI1_AVX512 1 "register_operand")
31004 (match_operand:VI1_AVX512 2 "register_operand")
31005 (match_operand:<ssedvecmode> 3 "register_operand")]
31006 "TARGET_SSE2"
31007 {
31008 if (<MODE_SIZE> == 64
31009 ? TARGET_AVX512VNNI
31010 : ((TARGET_AVX512VNNI && TARGET_AVX512VL) || TARGET_AVXVNNI))
31011 {
31012 operands[1] = lowpart_subreg (<ssedvecmode>mode,
31013 force_reg (<MODE>mode, operands[1]),
31014 <MODE>mode);
31015 operands[2] = lowpart_subreg (<ssedvecmode>mode,
31016 force_reg (<MODE>mode, operands[2]),
31017 <MODE>mode);
31018 emit_insn (gen_vpdpbusd_<ssedvecmodelower> (operands[0], operands[3],
31019 operands[1], operands[2]));
31020 }
31021 else
31022 {
31023 /* Emulate with vpdpwssd. */
31024 rtx op1_lo = gen_reg_rtx (<sseunpackmode>mode);
31025 rtx op1_hi = gen_reg_rtx (<sseunpackmode>mode);
31026 rtx op2_lo = gen_reg_rtx (<sseunpackmode>mode);
31027 rtx op2_hi = gen_reg_rtx (<sseunpackmode>mode);
31028
31029 emit_insn (gen_vec_unpacku_lo_<mode> (op1_lo, operands[1]));
31030 emit_insn (gen_vec_unpacks_lo_<mode> (op2_lo, operands[2]));
31031 emit_insn (gen_vec_unpacku_hi_<mode> (op1_hi, operands[1]));
31032 emit_insn (gen_vec_unpacks_hi_<mode> (op2_hi, operands[2]));
31033
31034 rtx res1 = gen_reg_rtx (<ssedvecmode>mode);
31035 rtx res2 = gen_reg_rtx (<ssedvecmode>mode);
31036 rtx sum = gen_reg_rtx (<ssedvecmode>mode);
31037
31038 emit_move_insn (sum, CONST0_RTX (<ssedvecmode>mode));
31039 emit_insn (gen_sdot_prod<ssedvecmodelower><sseunpackmodelower> (res1,
31040 op1_lo, op2_lo, sum));
31041 emit_insn (gen_sdot_prod<ssedvecmodelower><sseunpackmodelower> (res2,
31042 op1_hi, op2_hi,
31043 operands[3]));
31044 emit_insn (gen_add<ssedvecmodelower>3 (operands[0], res1, res2));
31045 }
31046 DONE;
31047 })
31048
31049 (define_insn "vpdpbusd_v16si"
31050 [(set (match_operand:V16SI 0 "register_operand" "=v")
31051 (unspec:V16SI
31052 [(match_operand:V16SI 1 "register_operand" "0")
31053 (match_operand:V16SI 2 "register_operand" "v")
31054 (match_operand:V16SI 3 "nonimmediate_operand" "vm")]
31055 UNSPEC_VPDPBUSD))]
31056 "TARGET_AVX512VNNI && TARGET_EVEX512"
31057 "vpdpbusd\t{%3, %2, %0|%0, %2, %3}"
31058 [(set_attr ("prefix") ("evex"))])
31059
31060 (define_insn "vpdpbusd_<mode>"
31061 [(set (match_operand:VI4_AVX2 0 "register_operand" "=x,v")
31062 (unspec:VI4_AVX2
31063 [(match_operand:VI4_AVX2 1 "register_operand" "0,0")
31064 (match_operand:VI4_AVX2 2 "register_operand" "x,v")
31065 (match_operand:VI4_AVX2 3 "nonimmediate_operand" "xjm,vm")]
31066 UNSPEC_VPDPBUSD))]
31067 "TARGET_AVXVNNI || (TARGET_AVX512VNNI && TARGET_AVX512VL)"
31068 "@
31069 %{vex%} vpdpbusd\t{%3, %2, %0|%0, %2, %3}
31070 vpdpbusd\t{%3, %2, %0|%0, %2, %3}"
31071 [(set_attr ("prefix") ("vex,evex"))
31072 (set_attr "addr" "gpr16,*")
31073 (set_attr ("isa") ("avxvnni,avx512vnnivl"))])
31074
31075 (define_insn "vpdpbusd_<mode>_mask"
31076 [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
31077 (vec_merge:VI4_AVX512VL
31078 (unspec:VI4_AVX512VL
31079 [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
31080 (match_operand:VI4_AVX512VL 2 "register_operand" "v")
31081 (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
31082 UNSPEC_VPDPBUSD)
31083 (match_dup 1)
31084 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
31085 "TARGET_AVX512VNNI"
31086 "vpdpbusd\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
31087 [(set_attr ("prefix") ("evex"))])
31088
31089 (define_expand "vpdpbusd_<mode>_maskz"
31090 [(match_operand:VI4_AVX512VL 0 "register_operand")
31091 (match_operand:VI4_AVX512VL 1 "register_operand")
31092 (match_operand:VI4_AVX512VL 2 "register_operand")
31093 (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
31094 (match_operand:<avx512fmaskmode> 4 "register_operand")]
31095 "TARGET_AVX512VNNI"
31096 {
31097 emit_insn (gen_vpdpbusd_<mode>_maskz_1 (operands[0], operands[1],
31098 operands[2], operands[3],
31099 CONST0_RTX (<MODE>mode),
31100 operands[4]));
31101 DONE;
31102 })
31103
31104 (define_insn "vpdpbusd_<mode>_maskz_1"
31105 [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
31106 (vec_merge:VI4_AVX512VL
31107 (unspec:VI4_AVX512VL
31108 [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
31109 (match_operand:VI4_AVX512VL 2 "register_operand" "v")
31110 (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")
31111 ] UNSPEC_VPDPBUSD)
31112 (match_operand:VI4_AVX512VL 4 "const0_operand")
31113 (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
31114 "TARGET_AVX512VNNI"
31115 "vpdpbusd\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
31116 [(set_attr ("prefix") ("evex"))])
31117
31118 (define_insn "vpdpbusds_v16si"
31119 [(set (match_operand:V16SI 0 "register_operand" "=v")
31120 (unspec:V16SI
31121 [(match_operand:V16SI 1 "register_operand" "0")
31122 (match_operand:V16SI 2 "register_operand" "v")
31123 (match_operand:V16SI 3 "nonimmediate_operand" "vm")]
31124 UNSPEC_VPDPBUSDS))]
31125 "TARGET_AVX512VNNI && TARGET_EVEX512"
31126 "vpdpbusds\t{%3, %2, %0|%0, %2, %3}"
31127 [(set_attr ("prefix") ("evex"))])
31128
31129 (define_insn "vpdpbusds_<mode>"
31130 [(set (match_operand:VI4_AVX2 0 "register_operand" "=x,v")
31131 (unspec:VI4_AVX2
31132 [(match_operand:VI4_AVX2 1 "register_operand" "0,0")
31133 (match_operand:VI4_AVX2 2 "register_operand" "x,v")
31134 (match_operand:VI4_AVX2 3 "nonimmediate_operand" "xjm,vm")]
31135 UNSPEC_VPDPBUSDS))]
31136 "TARGET_AVXVNNI || (TARGET_AVX512VNNI && TARGET_AVX512VL)"
31137 "@
31138 %{vex%} vpdpbusds\t{%3, %2, %0|%0, %2, %3}
31139 vpdpbusds\t{%3, %2, %0|%0, %2, %3}"
31140 [(set_attr ("prefix") ("vex,evex"))
31141 (set_attr "addr" "gpr16,*")
31142 (set_attr ("isa") ("avxvnni,avx512vnnivl"))])
31143
31144 (define_insn "vpdpbusds_<mode>_mask"
31145 [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
31146 (vec_merge:VI4_AVX512VL
31147 (unspec:VI4_AVX512VL
31148 [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
31149 (match_operand:VI4_AVX512VL 2 "register_operand" "v")
31150 (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
31151 UNSPEC_VPDPBUSDS)
31152 (match_dup 1)
31153 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
31154 "TARGET_AVX512VNNI"
31155 "vpdpbusds\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
31156 [(set_attr ("prefix") ("evex"))])
31157
31158 (define_expand "vpdpbusds_<mode>_maskz"
31159 [(match_operand:VI4_AVX512VL 0 "register_operand")
31160 (match_operand:VI4_AVX512VL 1 "register_operand")
31161 (match_operand:VI4_AVX512VL 2 "register_operand")
31162 (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
31163 (match_operand:<avx512fmaskmode> 4 "register_operand")]
31164 "TARGET_AVX512VNNI"
31165 {
31166 emit_insn (gen_vpdpbusds_<mode>_maskz_1 (operands[0], operands[1],
31167 operands[2], operands[3],
31168 CONST0_RTX (<MODE>mode),
31169 operands[4]));
31170 DONE;
31171 })
31172
31173 (define_insn "vpdpbusds_<mode>_maskz_1"
31174 [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
31175 (vec_merge:VI4_AVX512VL
31176 (unspec:VI4_AVX512VL
31177 [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
31178 (match_operand:VI4_AVX512VL 2 "register_operand" "v")
31179 (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
31180 UNSPEC_VPDPBUSDS)
31181 (match_operand:VI4_AVX512VL 4 "const0_operand")
31182 (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
31183 "TARGET_AVX512VNNI"
31184 "vpdpbusds\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
31185 [(set_attr ("prefix") ("evex"))])
31186
31187 (define_insn "vpdpwssd_v16si"
31188 [(set (match_operand:V16SI 0 "register_operand" "=v")
31189 (unspec:V16SI
31190 [(match_operand:V16SI 1 "register_operand" "0")
31191 (match_operand:V16SI 2 "register_operand" "v")
31192 (match_operand:V16SI 3 "nonimmediate_operand" "vm")]
31193 UNSPEC_VPDPWSSD))]
31194 "TARGET_AVX512VNNI && TARGET_EVEX512"
31195 "vpdpwssd\t{%3, %2, %0|%0, %2, %3}"
31196 [(set_attr ("prefix") ("evex"))])
31197
31198 (define_insn "vpdpwssd_<mode>"
31199 [(set (match_operand:VI4_AVX2 0 "register_operand" "=x,v")
31200 (unspec:VI4_AVX2
31201 [(match_operand:VI4_AVX2 1 "register_operand" "0,0")
31202 (match_operand:VI4_AVX2 2 "register_operand" "x,v")
31203 (match_operand:VI4_AVX2 3 "nonimmediate_operand" "xjm,vm")]
31204 UNSPEC_VPDPWSSD))]
31205 "TARGET_AVXVNNI || (TARGET_AVX512VNNI && TARGET_AVX512VL)"
31206 "@
31207 %{vex%} vpdpwssd\t{%3, %2, %0|%0, %2, %3}
31208 vpdpwssd\t{%3, %2, %0|%0, %2, %3}"
31209 [(set_attr ("prefix") ("vex,evex"))
31210 (set_attr "addr" "gpr16,*")
31211 (set_attr ("isa") ("avxvnni,avx512vnnivl"))])
31212
31213 (define_insn "vpdpwssd_<mode>_mask"
31214 [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
31215 (vec_merge:VI4_AVX512VL
31216 (unspec:VI4_AVX512VL
31217 [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
31218 (match_operand:VI4_AVX512VL 2 "register_operand" "v")
31219 (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
31220 UNSPEC_VPDPWSSD)
31221 (match_dup 1)
31222 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
31223 "TARGET_AVX512VNNI"
31224 "vpdpwssd\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
31225 [(set_attr ("prefix") ("evex"))])
31226
31227 (define_expand "vpdpwssd_<mode>_maskz"
31228 [(match_operand:VI4_AVX512VL 0 "register_operand")
31229 (match_operand:VI4_AVX512VL 1 "register_operand")
31230 (match_operand:VI4_AVX512VL 2 "register_operand")
31231 (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
31232 (match_operand:<avx512fmaskmode> 4 "register_operand")]
31233 "TARGET_AVX512VNNI"
31234 {
31235 emit_insn (gen_vpdpwssd_<mode>_maskz_1 (operands[0], operands[1],
31236 operands[2], operands[3],
31237 CONST0_RTX (<MODE>mode),
31238 operands[4]));
31239 DONE;
31240 })
31241
31242 (define_insn "vpdpwssd_<mode>_maskz_1"
31243 [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
31244 (vec_merge:VI4_AVX512VL
31245 (unspec:VI4_AVX512VL
31246 [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
31247 (match_operand:VI4_AVX512VL 2 "register_operand" "v")
31248 (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
31249 UNSPEC_VPDPWSSD)
31250 (match_operand:VI4_AVX512VL 4 "const0_operand")
31251 (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
31252 "TARGET_AVX512VNNI"
31253 "vpdpwssd\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
31254 [(set_attr ("prefix") ("evex"))])
31255
31256 (define_insn "vpdpwssds_v16si"
31257 [(set (match_operand:V16SI 0 "register_operand" "=v")
31258 (unspec:V16SI
31259 [(match_operand:V16SI 1 "register_operand" "0")
31260 (match_operand:V16SI 2 "register_operand" "v")
31261 (match_operand:V16SI 3 "nonimmediate_operand" "vm")]
31262 UNSPEC_VPDPWSSDS))]
31263 "TARGET_AVX512VNNI && TARGET_EVEX512"
31264 "vpdpwssds\t{%3, %2, %0|%0, %2, %3}"
31265 [(set_attr ("prefix") ("evex"))])
31266
31267 (define_insn "vpdpwssds_<mode>"
31268 [(set (match_operand:VI4_AVX2 0 "register_operand" "=x,v")
31269 (unspec:VI4_AVX2
31270 [(match_operand:VI4_AVX2 1 "register_operand" "0,0")
31271 (match_operand:VI4_AVX2 2 "register_operand" "x,v")
31272 (match_operand:VI4_AVX2 3 "nonimmediate_operand" "xjm,vm")]
31273 UNSPEC_VPDPWSSDS))]
31274 "TARGET_AVXVNNI || (TARGET_AVX512VNNI && TARGET_AVX512VL)"
31275 "@
31276 %{vex%} vpdpwssds\t{%3, %2, %0|%0, %2, %3}
31277 vpdpwssds\t{%3, %2, %0|%0, %2, %3}"
31278 [(set_attr ("prefix") ("vex,evex"))
31279 (set_attr "addr" "gpr16,*")
31280 (set_attr ("isa") ("avxvnni,avx512vnnivl"))])
31281
31282 (define_insn "vpdpwssds_<mode>_mask"
31283 [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
31284 (vec_merge:VI4_AVX512VL
31285 (unspec:VI4_AVX512VL
31286 [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
31287 (match_operand:VI4_AVX512VL 2 "register_operand" "v")
31288 (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
31289 UNSPEC_VPDPWSSDS)
31290 (match_dup 1)
31291 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
31292 "TARGET_AVX512VNNI"
31293 "vpdpwssds\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
31294 [(set_attr ("prefix") ("evex"))])
31295
31296 (define_expand "vpdpwssds_<mode>_maskz"
31297 [(match_operand:VI4_AVX512VL 0 "register_operand")
31298 (match_operand:VI4_AVX512VL 1 "register_operand")
31299 (match_operand:VI4_AVX512VL 2 "register_operand")
31300 (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
31301 (match_operand:<avx512fmaskmode> 4 "register_operand")]
31302 "TARGET_AVX512VNNI"
31303 {
31304 emit_insn (gen_vpdpwssds_<mode>_maskz_1 (operands[0], operands[1],
31305 operands[2], operands[3],
31306 CONST0_RTX (<MODE>mode),
31307 operands[4]));
31308 DONE;
31309 })
31310
31311 (define_insn "vpdpwssds_<mode>_maskz_1"
31312 [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
31313 (vec_merge:VI4_AVX512VL
31314 (unspec:VI4_AVX512VL
31315 [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
31316 (match_operand:VI4_AVX512VL 2 "register_operand" "v")
31317 (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
31318 UNSPEC_VPDPWSSDS)
31319 (match_operand:VI4_AVX512VL 4 "const0_operand")
31320 (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
31321 "TARGET_AVX512VNNI"
31322 "vpdpwssds\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
31323 [(set_attr ("prefix") ("evex"))])
31324
31325 (define_insn "vaesdec_<mode>"
31326 [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=x,v")
31327 (unspec:VI1_AVX512VL_F
31328 [(match_operand:VI1_AVX512VL_F 1 "register_operand" "x,v")
31329 (match_operand:VI1_AVX512VL_F 2 "vector_operand" "xjm,vm")]
31330 UNSPEC_VAESDEC))]
31331 "TARGET_VAES"
31332 {
31333 if (!TARGET_AES && <MODE>mode == V16QImode)
31334 return "%{evex%} vaesdec\t{%2, %1, %0|%0, %1, %2}";
31335 else
31336 return "vaesdec\t{%2, %1, %0|%0, %1, %2}";
31337 }
31338 [(set_attr "isa" "avx,vaes_avx512vl")
31339 (set_attr "type" "sselog1")
31340 (set_attr "c86_attr" "aes")
31341 (set_attr "addr" "gpr16,*")
31342 (set_attr "mode" "TI")])
31343
31344 (define_insn "vaesdeclast_<mode>"
31345 [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=x,v")
31346 (unspec:VI1_AVX512VL_F
31347 [(match_operand:VI1_AVX512VL_F 1 "register_operand" "x,v")
31348 (match_operand:VI1_AVX512VL_F 2 "vector_operand" "xjm,vm")]
31349 UNSPEC_VAESDECLAST))]
31350 "TARGET_VAES"
31351 {
31352 if (!TARGET_AES && <MODE>mode == V16QImode)
31353 return "%{evex%} vaesdeclast\t{%2, %1, %0|%0, %1, %2}";
31354 else
31355 return "vaesdeclast\t{%2, %1, %0|%0, %1, %2}";
31356 }
31357 [(set_attr "isa" "avx,vaes_avx512vl")
31358 (set_attr "type" "sselog1")
31359 (set_attr "c86_attr" "aes")
31360 (set_attr "addr" "gpr16,*")
31361 (set_attr "mode" "TI")])
31362
31363 (define_insn "vaesenc_<mode>"
31364 [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=x,v")
31365 (unspec:VI1_AVX512VL_F
31366 [(match_operand:VI1_AVX512VL_F 1 "register_operand" "x,v")
31367 (match_operand:VI1_AVX512VL_F 2 "vector_operand" "xjm,vm")]
31368 UNSPEC_VAESENC))]
31369 "TARGET_VAES"
31370 {
31371 if (!TARGET_AES && <MODE>mode == V16QImode)
31372 return "%{evex%} vaesenc\t{%2, %1, %0|%0, %1, %2}";
31373 else
31374 return "vaesenc\t{%2, %1, %0|%0, %1, %2}";
31375 }
31376 [(set_attr "isa" "avx,vaes_avx512vl")
31377 (set_attr "type" "sselog1")
31378 (set_attr "c86_attr" "aes")
31379 (set_attr "addr" "gpr16,*")
31380 (set_attr "mode" "TI")])
31381
31382 (define_insn "vaesenclast_<mode>"
31383 [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=x,v")
31384 (unspec:VI1_AVX512VL_F
31385 [(match_operand:VI1_AVX512VL_F 1 "register_operand" "x,v")
31386 (match_operand:VI1_AVX512VL_F 2 "vector_operand" "xjm,vm")]
31387 UNSPEC_VAESENCLAST))]
31388 "TARGET_VAES"
31389 {
31390 if (!TARGET_AES && <MODE>mode == V16QImode)
31391 return "%{evex%} vaesenclast\t{%2, %1, %0|%0, %1, %2}";
31392 else
31393 return "vaesenclast\t{%2, %1, %0|%0, %1, %2}";
31394 }
31395 [(set_attr "isa" "avx,vaes_avx512vl")
31396 (set_attr "type" "sselog1")
31397 (set_attr "c86_attr" "aes")
31398 (set_attr "addr" "gpr16,*")
31399 (set_attr "mode" "TI")])
31400
31401 (define_insn "vpclmulqdq_<mode>"
31402 [(set (match_operand:VI8_FVL 0 "register_operand" "=v")
31403 (unspec:VI8_FVL [(match_operand:VI8_FVL 1 "register_operand" "v")
31404 (match_operand:VI8_FVL 2 "vector_operand" "vm")
31405 (match_operand:SI 3 "const_0_to_255_operand")]
31406 UNSPEC_VPCLMULQDQ))]
31407 "TARGET_VPCLMULQDQ"
31408 "vpclmulqdq\t{%3, %2, %1, %0|%0, %1, %2, %3}"
31409 [(set_attr "mode" "DI")])
31410
31411 (define_insn "avx512vl_vpshufbitqmb<mode><mask_scalar_merge_name>"
31412 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
31413 (unspec:<avx512fmaskmode>
31414 [(match_operand:VI1_AVX512VL 1 "register_operand" "v")
31415 (match_operand:VI1_AVX512VL 2 "nonimmediate_operand" "vm")]
31416 UNSPEC_VPSHUFBIT))]
31417 "TARGET_AVX512BITALG"
31418 "vpshufbitqmb\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
31419 [(set_attr "prefix" "evex")
31420 (set_attr "mode" "<sseinsnmode>")])
31421
31422 (define_mode_iterator VI48_AVX512VP2VL
31423 [(V8DI "TARGET_EVEX512")
31424 (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")
31425 (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")])
31426
31427 (define_mode_iterator MASK_DWI [P2QI P2HI])
31428
31429 (define_expand "mov<mode>"
31430 [(set (match_operand:MASK_DWI 0 "nonimmediate_operand")
31431 (match_operand:MASK_DWI 1 "nonimmediate_operand"))]
31432 "TARGET_AVX512VP2INTERSECT"
31433 {
31434 if (MEM_P (operands[0]) && MEM_P (operands[1]))
31435 operands[1] = force_reg (<MODE>mode, operands[1]);
31436 })
31437
31438 (define_insn_and_split "*mov<mode>_internal"
31439 [(set (match_operand:MASK_DWI 0 "nonimmediate_operand" "=k,o")
31440 (match_operand:MASK_DWI 1 "nonimmediate_operand" "ko,k"))]
31441 "TARGET_AVX512VP2INTERSECT
31442 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
31443 "#"
31444 "&& reload_completed"
31445 [(set (match_dup 0) (match_dup 1))
31446 (set (match_dup 2) (match_dup 3))]
31447 {
31448 split_double_mode (<MODE>mode, &operands[0], 2, &operands[0], &operands[2]);
31449 })
31450
31451 (define_insn "avx512vp2intersect_2intersect<mode>"
31452 [(set (match_operand:P2QI 0 "register_operand" "=k")
31453 (unspec:P2QI
31454 [(match_operand:VI48_AVX512VP2VL 1 "register_operand" "v")
31455 (match_operand:VI48_AVX512VP2VL 2 "vector_operand" "vm")]
31456 UNSPEC_VP2INTERSECT))]
31457 "TARGET_AVX512VP2INTERSECT"
31458 "vp2intersect<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
31459 [(set_attr ("prefix") ("evex"))])
31460
31461 (define_insn "avx512vp2intersect_2intersectv16si"
31462 [(set (match_operand:P2HI 0 "register_operand" "=k")
31463 (unspec:P2HI [(match_operand:V16SI 1 "register_operand" "v")
31464 (match_operand:V16SI 2 "vector_operand" "vm")]
31465 UNSPEC_VP2INTERSECT))]
31466 "TARGET_AVX512VP2INTERSECT && TARGET_EVEX512"
31467 "vp2intersectd\t{%2, %1, %0|%0, %1, %2}"
31468 [(set_attr ("prefix") ("evex"))])
31469
31470 (define_mode_iterator VF_AVX512BF16VL
31471 [(V32BF "TARGET_EVEX512") (V16BF "TARGET_AVX512VL") (V8BF "TARGET_AVX512VL")])
31472 ;; Converting from BF to SF
31473 (define_mode_attr bf16_cvt_2sf
31474 [(V32BF "V16SF") (V16BF "V8SF") (V8BF "V4SF")])
31475 ;; Converting from SF to BF
31476 (define_mode_attr sf_cvt_bf16
31477 [(V4SF "V4BF") (V8SF "V8BF") (V16SF "V16BF")])
31478
31479 (define_mode_attr sf_cvt_bf16_lower
31480 [(V4SF "v4bf") (V8SF "v8bf") (V16SF "v16bf")])
31481
31482 ;; Mapping from BF to SF
31483 (define_mode_attr sf_bf16
31484 [(V4SF "V8BF") (V8SF "V16BF") (V16SF "V32BF")])
31485
31486 (define_expand "avx512f_cvtne2ps2bf16_<mode>_maskz"
31487 [(match_operand:VF_AVX512BF16VL 0 "register_operand")
31488 (match_operand:<bf16_cvt_2sf> 1 "register_operand")
31489 (match_operand:<bf16_cvt_2sf> 2 "nonimmediate_operand")
31490 (match_operand:<avx512fmaskmode> 3 "register_operand")]
31491 "TARGET_AVX512BF16"
31492 {
31493 emit_insn (gen_avx512f_cvtne2ps2bf16_<mode>_mask(operands[0], operands[1],
31494 operands[2], CONST0_RTX(<MODE>mode), operands[3]));
31495 DONE;
31496 })
31497
31498 (define_insn "avx512f_cvtne2ps2bf16_<mode><mask_name>"
31499 [(set (match_operand:VF_AVX512BF16VL 0 "register_operand" "=v")
31500 (vec_concat:VF_AVX512BF16VL
31501 (float_truncate:<ssehalfvecmode>
31502 (match_operand:<bf16_cvt_2sf> 2 "nonimmediate_operand" "vm"))
31503 (float_truncate:<ssehalfvecmode>
31504 (match_operand:<bf16_cvt_2sf> 1 "register_operand" "v"))))]
31505 "TARGET_AVX512BF16"
31506 "vcvtne2ps2bf16\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}")
31507
31508 (define_expand "truncv4sfv4bf2"
31509 [(set (match_operand:V4BF 0 "register_operand")
31510 (float_truncate:V4BF
31511 (match_operand:V4SF 1 "nonimmediate_operand")))]
31512 "TARGET_SSSE3 && !HONOR_NANS (BFmode) && !flag_rounding_math
31513 && (flag_unsafe_math_optimizations
31514 || TARGET_AVXNECONVERT
31515 || (TARGET_AVX512BF16 && TARGET_AVX512VL))"
31516 {
31517 if (!TARGET_AVXNECONVERT
31518 && !(TARGET_AVX512BF16 && TARGET_AVX512VL))
31519 ix86_expand_vector_sf2bf_with_vec_perm (operands[0], operands[1]);
31520 else
31521 {
31522 rtx dest = gen_reg_rtx (V8BFmode);
31523 emit_insn (gen_vcvtneps2bf16_v4sf (dest, operands[1]));
31524 emit_move_insn (operands[0], lowpart_subreg (V4BFmode, dest, V8BFmode));
31525 }
31526 DONE;
31527 })
31528
31529 (define_expand "vcvtneps2bf16_v4sf"
31530 [(set (match_operand:V8BF 0 "register_operand")
31531 (vec_concat:V8BF
31532 (float_truncate:V4BF
31533 (match_operand:V4SF 1 "nonimmediate_operand"))
31534 (match_dup 2)))]
31535 "TARGET_AVXNECONVERT || (TARGET_AVX512BF16 && TARGET_AVX512VL)"
31536 "operands[2] = CONST0_RTX (V4BFmode);")
31537
31538 (define_insn "*vcvtneps2bf16_v4sf"
31539 [(set (match_operand:V8BF 0 "register_operand" "=x,v")
31540 (vec_concat:V8BF
31541 (float_truncate:V4BF
31542 (match_operand:V4SF 1 "nonimmediate_operand" "xjm,vm"))
31543 (match_operand:V4BF 2 "const0_operand")))]
31544 "TARGET_AVXNECONVERT || (TARGET_AVX512BF16 && TARGET_AVX512VL)"
31545 "@
31546 %{vex%} vcvtneps2bf16{x}\t{%1, %0|%0, %1}
31547 vcvtneps2bf16{x}\t{%1, %0|%0, %1}"
31548 [(set_attr "isa" "avxneconvert,avx512bf16vl")
31549 (set_attr "addr" "gpr16,*")
31550 (set_attr "prefix" "vex,evex")])
31551
31552 (define_expand "avx512f_cvtneps2bf16_v4sf_maskz"
31553 [(match_operand:V8BF 0 "register_operand")
31554 (match_operand:V4SF 1 "nonimmediate_operand")
31555 (match_operand:QI 2 "register_operand")]
31556 "TARGET_AVX512BF16 && TARGET_AVX512VL"
31557 {
31558 emit_insn (gen_avx512f_cvtneps2bf16_v4sf_mask_1(operands[0], operands[1],
31559 CONST0_RTX(V8BFmode), operands[2], CONST0_RTX(V4BFmode)));
31560 DONE;
31561 })
31562
31563 (define_expand "avx512f_cvtneps2bf16_v4sf_mask"
31564 [(match_operand:V8BF 0 "register_operand")
31565 (match_operand:V4SF 1 "nonimmediate_operand")
31566 (match_operand:V8BF 2 "nonimm_or_0_operand")
31567 (match_operand:QI 3 "register_operand")]
31568 "TARGET_AVX512BF16 && TARGET_AVX512VL"
31569 {
31570 emit_insn (gen_avx512f_cvtneps2bf16_v4sf_mask_1(operands[0], operands[1],
31571 operands[2], operands[3], CONST0_RTX(V4BFmode)));
31572 DONE;
31573 })
31574
31575 (define_insn "avx512f_cvtneps2bf16_v4sf_mask_1"
31576 [(set (match_operand:V8BF 0 "register_operand" "=v")
31577 (vec_concat:V8BF
31578 (vec_merge:V4BF
31579 (float_truncate:V4BF
31580 (match_operand:V4SF 1 "nonimmediate_operand" "vm"))
31581 (vec_select:V4BF
31582 (match_operand:V8BF 2 "nonimm_or_0_operand" "0C")
31583 (parallel [(const_int 0) (const_int 1)
31584 (const_int 2) (const_int 3)]))
31585 (match_operand:QI 3 "register_operand" "Yk"))
31586 (match_operand:V4BF 4 "const0_operand")))]
31587 "TARGET_AVX512BF16 && TARGET_AVX512VL"
31588 "vcvtneps2bf16{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}")
31589
31590 (define_mode_iterator VF1_AVX512_256
31591 [(V16SF "TARGET_EVEX512") (V8SF "TARGET_AVX512VL")])
31592
31593 (define_expand "avx512f_cvtneps2bf16_<mode>_maskz"
31594 [(match_operand:<sf_cvt_bf16> 0 "register_operand")
31595 (match_operand:VF1_AVX512_256 1 "nonimmediate_operand")
31596 (match_operand:<avx512fmaskmode> 2 "register_operand")]
31597 "TARGET_AVX512BF16"
31598 {
31599 emit_insn (gen_avx512f_cvtneps2bf16_<mode>_mask(operands[0], operands[1],
31600 CONST0_RTX(<sf_cvt_bf16>mode), operands[2]));
31601 DONE;
31602 })
31603
31604 (define_expand "truncv8sfv8bf2"
31605 [(set (match_operand:V8BF 0 "register_operand")
31606 (float_truncate:V8BF
31607 (match_operand:V8SF 1 "nonimmediate_operand")))]
31608 "TARGET_AVX2 && !HONOR_NANS (BFmode) && !flag_rounding_math
31609 && (flag_unsafe_math_optimizations
31610 || TARGET_AVXNECONVERT
31611 || (TARGET_AVX512BF16 && TARGET_AVX512VL))"
31612 {
31613 if (!TARGET_AVXNECONVERT
31614 && !(TARGET_AVX512BF16 && TARGET_AVX512VL))
31615 {
31616 ix86_expand_vector_sf2bf_with_vec_perm (operands[0], operands[1]);
31617 DONE;
31618 }
31619 })
31620
31621 (define_insn "vcvtneps2bf16_v8sf"
31622 [(set (match_operand:V8BF 0 "register_operand" "=x,v")
31623 (float_truncate:V8BF
31624 (match_operand:V8SF 1 "nonimmediate_operand" "xjm,vm")))]
31625 "TARGET_AVXNECONVERT || (TARGET_AVX512BF16 && TARGET_AVX512VL)"
31626 "@
31627 %{vex%} vcvtneps2bf16{y}\t{%1, %0|%0, %1}
31628 vcvtneps2bf16{y}\t{%1, %0|%0, %1}"
31629 [(set_attr "isa" "avxneconvert,avx512bf16vl")
31630 (set_attr "addr" "gpr16,*")
31631 (set_attr "prefix" "vex,evex")])
31632
31633 (define_expand "truncv16sfv16bf2"
31634 [(set (match_operand:V16BF 0 "register_operand")
31635 (float_truncate:V16BF
31636 (match_operand:V16SF 1 "nonimmediate_operand")))]
31637 "TARGET_AVX512BW && TARGET_EVEX512
31638 && !HONOR_NANS (BFmode) && !flag_rounding_math
31639 && (flag_unsafe_math_optimizations || TARGET_AVX512BF16)"
31640 {
31641 if (!TARGET_AVX512BF16)
31642 {
31643 ix86_expand_vector_sf2bf_with_vec_perm (operands[0], operands[1]);
31644 DONE;
31645 }
31646 })
31647
31648 (define_expand "extend<sf_cvt_bf16_lower><mode>2"
31649 [(set (match_operand:VF1_AVX512BW 0 "register_operand")
31650 (float_extend:VF1_AVX512BW
31651 (match_operand:<sf_cvt_bf16> 1 "nonimmediate_operand")))]
31652 "TARGET_SSE2 && !HONOR_NANS (BFmode)"
31653 {
31654 ix86_expand_vector_bf2sf_with_vec_perm (operands[0], operands[1]);
31655 DONE;
31656 })
31657
31658
31659 (define_insn "avx512f_cvtneps2bf16_<mode><mask_name>"
31660 [(set (match_operand:<sf_cvt_bf16> 0 "register_operand" "=v")
31661 (float_truncate:<sf_cvt_bf16>
31662 (match_operand:VF1_AVX512_256 1 "nonimmediate_operand" "vm")))]
31663 "TARGET_AVX512BF16"
31664 "vcvtneps2bf16<qq2phsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}")
31665
31666 (define_expand "avx512f_dpbf16ps_<mode>_maskz"
31667 [(match_operand:VF1_AVX512VL 0 "register_operand")
31668 (match_operand:VF1_AVX512VL 1 "register_operand")
31669 (match_operand:<sf_bf16> 2 "register_operand")
31670 (match_operand:<sf_bf16> 3 "register_operand")
31671 (match_operand:<avx512fmaskhalfmode> 4 "register_operand")]
31672 "TARGET_AVX512BF16"
31673 {
31674 emit_insn (gen_avx512f_dpbf16ps_<mode>_maskz_1(operands[0], operands[1],
31675 operands[2], operands[3], CONST0_RTX(<MODE>mode), operands[4]));
31676 DONE;
31677 })
31678
31679 (define_insn "avx512f_dpbf16ps_<mode><maskz_half_name>"
31680 [(set (match_operand:VF1_AVX512VL 0 "register_operand" "=v")
31681 (unspec:VF1_AVX512VL
31682 [(match_operand:VF1_AVX512VL 1 "register_operand" "0")
31683 (match_operand:<sf_bf16> 2 "register_operand" "v")
31684 (match_operand:<sf_bf16> 3 "nonimmediate_operand" "vm")]
31685 UNSPEC_VDPBF16PS))]
31686 "TARGET_AVX512BF16"
31687 "vdpbf16ps\t{%3, %2, %0<maskz_half_operand4>|%0<maskz_half_operand4>, %2, %3}")
31688
31689 (define_insn "avx512f_dpbf16ps_<mode>_mask"
31690 [(set (match_operand:VF1_AVX512VL 0 "register_operand" "=v")
31691 (vec_merge:VF1_AVX512VL
31692 (unspec:VF1_AVX512VL
31693 [(match_operand:VF1_AVX512VL 1 "register_operand" "0")
31694 (match_operand:<sf_bf16> 2 "register_operand" "v")
31695 (match_operand:<sf_bf16> 3 "nonimmediate_operand" "vm")]
31696 UNSPEC_VDPBF16PS)
31697 (match_dup 1)
31698 (match_operand:<avx512fmaskhalfmode> 4 "register_operand" "Yk")))]
31699 "TARGET_AVX512BF16"
31700 "vdpbf16ps\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}")
31701
31702 ;; KEYLOCKER
31703 (define_insn "loadiwkey"
31704 [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "x")
31705 (match_operand:V2DI 1 "register_operand" "x")
31706 (match_operand:V2DI 2 "register_operand" "Yz")
31707 (match_operand:SI 3 "register_operand" "a")]
31708 UNSPECV_LOADIWKEY)
31709 (clobber (reg:CC FLAGS_REG))]
31710 "TARGET_KL"
31711 "loadiwkey\t{%0, %1|%1, %0}"
31712 [(set_attr "type" "other")])
31713
31714 (define_expand "encodekey128u32"
31715 [(match_par_dup 2
31716 [(set (match_operand:SI 0 "register_operand")
31717 (unspec_volatile:SI
31718 [(match_operand:SI 1 "register_operand")
31719 (reg:V2DI XMM0_REG)]
31720 UNSPECV_ENCODEKEY128U32))])]
31721 "TARGET_KL"
31722 {
31723 rtx xmm_regs[7];
31724 rtx tmp_unspec;
31725 unsigned i;
31726
31727 /* parallel rtx for encodekey128 predicate */
31728 operands[2] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (8));
31729
31730 for (i = 0; i < 7; i++)
31731 xmm_regs[i] = gen_rtx_REG (V2DImode, GET_SSE_REGNO (i));
31732
31733 tmp_unspec
31734 = gen_rtx_UNSPEC_VOLATILE (SImode,
31735 gen_rtvec (2, operands[1], xmm_regs[0]),
31736 UNSPECV_ENCODEKEY128U32);
31737
31738 XVECEXP (operands[2], 0, 0)
31739 = gen_rtx_SET (operands[0], tmp_unspec);
31740
31741 tmp_unspec
31742 = gen_rtx_UNSPEC_VOLATILE (V2DImode,
31743 gen_rtvec (1, const0_rtx),
31744 UNSPECV_ENCODEKEY128U32);
31745
31746 for (i = 0; i < 3; i++)
31747 XVECEXP (operands[2], 0, i + 1)
31748 = gen_rtx_SET (xmm_regs[i], tmp_unspec);
31749
31750 for (i = 4; i < 7; i++)
31751 XVECEXP (operands[2], 0, i)
31752 = gen_rtx_CLOBBER (VOIDmode, xmm_regs[i]);
31753
31754 XVECEXP (operands[2], 0, 7)
31755 = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
31756 })
31757
31758 (define_insn "*encodekey128u32"
31759 [(match_parallel 2 "encodekey128_operation"
31760 [(set (match_operand:SI 0 "register_operand" "=jr")
31761 (unspec_volatile:SI
31762 [(match_operand:SI 1 "register_operand" "jr")
31763 (reg:V2DI XMM0_REG)]
31764 UNSPECV_ENCODEKEY128U32))])]
31765 "TARGET_KL"
31766 "encodekey128\t{%1, %0|%0, %1}"
31767 [(set_attr "type" "other")])
31768
31769 (define_expand "encodekey256u32"
31770 [(match_par_dup 2
31771 [(set (match_operand:SI 0 "register_operand")
31772 (unspec_volatile:SI
31773 [(match_operand:SI 1 "register_operand")
31774 (reg:V2DI XMM0_REG)
31775 (reg:V2DI XMM1_REG)]
31776 UNSPECV_ENCODEKEY256U32))])]
31777 "TARGET_KL"
31778 {
31779 rtx xmm_regs[7];
31780 rtx tmp_unspec;
31781 unsigned i;
31782
31783 /* parallel rtx for encodekey256 predicate */
31784 operands[2] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (9));
31785
31786 for (i = 0; i < 7; i++)
31787 xmm_regs[i] = gen_rtx_REG (V2DImode, GET_SSE_REGNO (i));
31788
31789 tmp_unspec
31790 = gen_rtx_UNSPEC_VOLATILE (SImode,
31791 gen_rtvec (3, operands[1],
31792 xmm_regs[0], xmm_regs[1]),
31793 UNSPECV_ENCODEKEY256U32);
31794
31795 XVECEXP (operands[2], 0, 0)
31796 = gen_rtx_SET (operands[0], tmp_unspec);
31797
31798 tmp_unspec
31799 = gen_rtx_UNSPEC_VOLATILE (V2DImode,
31800 gen_rtvec (1, const0_rtx),
31801 UNSPECV_ENCODEKEY256U32);
31802
31803 for (i = 0; i < 4; i++)
31804 XVECEXP (operands[2], 0, i + 1)
31805 = gen_rtx_SET (xmm_regs[i], tmp_unspec);
31806
31807 for (i = 4; i < 7; i++)
31808 XVECEXP (operands[2], 0, i + 1)
31809 = gen_rtx_CLOBBER (VOIDmode, xmm_regs[i]);
31810
31811 XVECEXP (operands[2], 0, 8)
31812 = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
31813 })
31814
31815 (define_insn "*encodekey256u32"
31816 [(match_parallel 2 "encodekey256_operation"
31817 [(set (match_operand:SI 0 "register_operand" "=jr")
31818 (unspec_volatile:SI
31819 [(match_operand:SI 1 "register_operand" "jr")
31820 (reg:V2DI XMM0_REG)
31821 (reg:V2DI XMM1_REG)]
31822 UNSPECV_ENCODEKEY256U32))])]
31823 "TARGET_KL"
31824 "encodekey256\t{%1, %0|%0, %1}"
31825 [(set_attr "type" "other")])
31826
31827 (define_int_iterator AESDECENCKL
31828 [UNSPECV_AESDEC128KLU8 UNSPECV_AESDEC256KLU8
31829 UNSPECV_AESENC128KLU8 UNSPECV_AESENC256KLU8])
31830
31831 (define_int_attr aesklvariant
31832 [(UNSPECV_AESDEC128KLU8 "dec128kl")
31833 (UNSPECV_AESDEC256KLU8 "dec256kl")
31834 (UNSPECV_AESENC128KLU8 "enc128kl")
31835 (UNSPECV_AESENC256KLU8 "enc256kl")])
31836
31837 (define_insn "aes<aesklvariant>u8"
31838 [(set (match_operand:V2DI 0 "register_operand" "=x")
31839 (unspec_volatile:V2DI [(match_operand:V2DI 1 "register_operand" "0")
31840 (match_operand:BLK 2 "memory_operand" "jm")]
31841 AESDECENCKL))
31842 (set (reg:CCZ FLAGS_REG)
31843 (unspec_volatile:CCZ [(match_dup 1) (match_dup 2)] AESDECENCKL))]
31844 "TARGET_KL"
31845 "aes<aesklvariant>\t{%2, %0|%0, %2}"
31846 [(set_attr "type" "other")
31847 (set_attr "addr" "gpr16")])
31848
31849 (define_int_iterator AESDECENCWIDEKL
31850 [UNSPECV_AESDECWIDE128KLU8 UNSPECV_AESDECWIDE256KLU8
31851 UNSPECV_AESENCWIDE128KLU8 UNSPECV_AESENCWIDE256KLU8])
31852
31853 (define_int_attr aeswideklvariant
31854 [(UNSPECV_AESDECWIDE128KLU8 "decwide128kl")
31855 (UNSPECV_AESDECWIDE256KLU8 "decwide256kl")
31856 (UNSPECV_AESENCWIDE128KLU8 "encwide128kl")
31857 (UNSPECV_AESENCWIDE256KLU8 "encwide256kl")])
31858
31859 (define_int_attr AESWIDEKLVARIANT
31860 [(UNSPECV_AESDECWIDE128KLU8 "AESDECWIDE128KLU8")
31861 (UNSPECV_AESDECWIDE256KLU8 "AESDECWIDE256KLU8")
31862 (UNSPECV_AESENCWIDE128KLU8 "AESENCWIDE128KLU8")
31863 (UNSPECV_AESENCWIDE256KLU8 "AESENCWIDE256KLU8")])
31864
31865 (define_expand "aes<aeswideklvariant>u8"
31866 [(match_par_dup 1
31867 [(set (reg:CCZ FLAGS_REG)
31868 (unspec_volatile:CCZ
31869 [(match_operand:BLK 0 "memory_operand")]
31870 AESDECENCWIDEKL))])]
31871 "TARGET_WIDEKL"
31872 {
31873 rtx tmp_unspec;
31874 unsigned i;
31875
31876 /* parallel rtx for widekl predicate */
31877 operands[1] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (9));
31878
31879 tmp_unspec
31880 = gen_rtx_UNSPEC_VOLATILE (CCZmode,
31881 gen_rtvec (1, operands[0]),
31882 UNSPECV_<AESWIDEKLVARIANT>);
31883
31884 XVECEXP (operands[1], 0, 0)
31885 = gen_rtx_SET (gen_rtx_REG (CCZmode, FLAGS_REG),
31886 tmp_unspec);
31887
31888 for (i = 0; i < 8; i++)
31889 {
31890 rtx xmm_reg = gen_rtx_REG (V2DImode, GET_SSE_REGNO (i));
31891
31892 tmp_unspec
31893 = gen_rtx_UNSPEC_VOLATILE (V2DImode,
31894 gen_rtvec (1, xmm_reg),
31895 UNSPECV_<AESWIDEKLVARIANT>);
31896 XVECEXP (operands[1], 0, i + 1)
31897 = gen_rtx_SET (xmm_reg, tmp_unspec);
31898 }
31899 })
31900
31901 (define_insn "*aes<aeswideklvariant>u8"
31902 [(match_parallel 1 "aeswidekl_operation"
31903 [(set (reg:CCZ FLAGS_REG)
31904 (unspec_volatile:CCZ
31905 [(match_operand:BLK 0 "memory_operand" "jm")]
31906 AESDECENCWIDEKL))])]
31907 "TARGET_WIDEKL"
31908 "aes<aeswideklvariant>\t%0"
31909 [(set_attr "type" "other")
31910 (set_attr "addr" "gpr16")])
31911
31912 ;; Modes handled by broadcast patterns. NB: Allow V64QI and V32HI with
31913 ;; TARGET_AVX512F since ix86_expand_vector_init_duplicate can expand
31914 ;; without TARGET_AVX512BW which is used by memset vector broadcast
31915 ;; expander to XI with:
31916 ;; vmovd %edi, %xmm15
31917 ;; vpbroadcastb %xmm15, %ymm15
31918 ;; vinserti64x4 $0x1, %ymm15, %zmm15, %zmm15
31919
31920 (define_mode_iterator INT_BROADCAST_MODE
31921 [(V64QI "TARGET_AVX512F && TARGET_EVEX512") (V32QI "TARGET_AVX") V16QI
31922 (V32HI "TARGET_AVX512F && TARGET_EVEX512") (V16HI "TARGET_AVX") V8HI
31923 (V16SI "TARGET_AVX512F && TARGET_EVEX512") (V8SI "TARGET_AVX") V4SI
31924 (V8DI "TARGET_AVX512F && TARGET_EVEX512 && TARGET_64BIT")
31925 (V4DI "TARGET_AVX && TARGET_64BIT") (V2DI "TARGET_64BIT")])
31926
31927 ;; Broadcast from an integer. NB: Enable broadcast only if we can move
31928 ;; from GPR to SSE register directly.
31929 (define_expand "vec_duplicate<mode>"
31930 [(set (match_operand:INT_BROADCAST_MODE 0 "register_operand")
31931 (vec_duplicate:INT_BROADCAST_MODE
31932 (match_operand:<ssescalarmode> 1 "nonimmediate_operand")))]
31933 "TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_TO_VEC"
31934 {
31935 if (!ix86_expand_vector_init_duplicate (false,
31936 GET_MODE (operands[0]),
31937 operands[0],
31938 operands[1]))
31939 gcc_unreachable ();
31940 DONE;
31941 })
31942
31943 (define_int_iterator VPDOTPROD
31944 [UNSPEC_VPDPBSSD
31945 UNSPEC_VPDPBSSDS
31946 UNSPEC_VPDPBSUD
31947 UNSPEC_VPDPBSUDS
31948 UNSPEC_VPDPBUUD
31949 UNSPEC_VPDPBUUDS])
31950
31951 (define_int_attr vpdotprodtype
31952 [(UNSPEC_VPDPBSSD "bssd") (UNSPEC_VPDPBSSDS "bssds")
31953 (UNSPEC_VPDPBSUD "bsud") (UNSPEC_VPDPBSUDS "bsuds")
31954 (UNSPEC_VPDPBUUD "buud") (UNSPEC_VPDPBUUDS "buuds")])
31955
31956 (define_expand "sdot_prod<ssedvecmodelower><mode>"
31957 [(match_operand:<ssedvecmode> 0 "register_operand")
31958 (match_operand:VI1_AVX512VNNIBW 1 "register_operand")
31959 (match_operand:VI1_AVX512VNNIBW 2 "register_operand")
31960 (match_operand:<ssedvecmode> 3 "register_operand")]
31961 "TARGET_SSE2"
31962 {
31963 if ((<MODE_SIZE> == 64 && TARGET_AVX10_2)
31964 || (<MODE_SIZE> < 64 && (TARGET_AVXVNNIINT8 || TARGET_AVX10_2)))
31965 {
31966 operands[1] = lowpart_subreg (<ssedvecmode>mode,
31967 force_reg (<MODE>mode, operands[1]),
31968 <MODE>mode);
31969 operands[2] = lowpart_subreg (<ssedvecmode>mode,
31970 force_reg (<MODE>mode, operands[2]),
31971 <MODE>mode);
31972 emit_insn (gen_vpdpbssd_<ssedvecmodelower> (operands[0], operands[3],
31973 operands[1], operands[2]));
31974 }
31975 else
31976 {
31977 /* Emulate with vpdpwssd. */
31978 rtx op1_lo = gen_reg_rtx (<sseunpackmode>mode);
31979 rtx op1_hi = gen_reg_rtx (<sseunpackmode>mode);
31980 rtx op2_lo = gen_reg_rtx (<sseunpackmode>mode);
31981 rtx op2_hi = gen_reg_rtx (<sseunpackmode>mode);
31982
31983 emit_insn (gen_vec_unpacks_lo_<mode> (op1_lo, operands[1]));
31984 emit_insn (gen_vec_unpacks_lo_<mode> (op2_lo, operands[2]));
31985 emit_insn (gen_vec_unpacks_hi_<mode> (op1_hi, operands[1]));
31986 emit_insn (gen_vec_unpacks_hi_<mode> (op2_hi, operands[2]));
31987
31988 rtx res1 = gen_reg_rtx (<ssedvecmode>mode);
31989 rtx res2 = gen_reg_rtx (<ssedvecmode>mode);
31990 rtx sum = gen_reg_rtx (<ssedvecmode>mode);
31991
31992 emit_move_insn (sum, CONST0_RTX (<ssedvecmode>mode));
31993 emit_insn (gen_sdot_prod<ssedvecmodelower><sseunpackmodelower> (res1,
31994 op1_lo, op2_lo, sum));
31995 emit_insn (gen_sdot_prod<ssedvecmodelower><sseunpackmodelower> (res2,
31996 op1_hi, op2_hi,
31997 operands[3]));
31998 emit_insn (gen_add<ssedvecmodelower>3 (operands[0], res1, res2));
31999 }
32000
32001 DONE;
32002 })
32003
32004 (define_expand "udot_prod<ssedvecmodelower><mode>"
32005 [(match_operand:<ssedvecmode> 0 "register_operand")
32006 (match_operand:VI1_AVX512VNNIBW 1 "register_operand")
32007 (match_operand:VI1_AVX512VNNIBW 2 "register_operand")
32008 (match_operand:<ssedvecmode> 3 "register_operand")]
32009 "TARGET_SSE2"
32010 {
32011 if ((<MODE_SIZE> == 64 && TARGET_AVX10_2)
32012 || (<MODE_SIZE> < 64 && (TARGET_AVXVNNIINT8 || TARGET_AVX10_2)))
32013 {
32014 operands[1] = lowpart_subreg (<ssedvecmode>mode,
32015 force_reg (<MODE>mode, operands[1]),
32016 <MODE>mode);
32017 operands[2] = lowpart_subreg (<ssedvecmode>mode,
32018 force_reg (<MODE>mode, operands[2]),
32019 <MODE>mode);
32020 emit_insn (gen_vpdpbuud_<ssedvecmodelower> (operands[0], operands[3],
32021 operands[1], operands[2]));
32022 }
32023 else
32024 {
32025 /* Emulate with vpdpwssd. */
32026 rtx op1_lo = gen_reg_rtx (<sseunpackmode>mode);
32027 rtx op1_hi = gen_reg_rtx (<sseunpackmode>mode);
32028 rtx op2_lo = gen_reg_rtx (<sseunpackmode>mode);
32029 rtx op2_hi = gen_reg_rtx (<sseunpackmode>mode);
32030
32031 emit_insn (gen_vec_unpacku_lo_<mode> (op1_lo, operands[1]));
32032 emit_insn (gen_vec_unpacku_lo_<mode> (op2_lo, operands[2]));
32033 emit_insn (gen_vec_unpacku_hi_<mode> (op1_hi, operands[1]));
32034 emit_insn (gen_vec_unpacku_hi_<mode> (op2_hi, operands[2]));
32035
32036 rtx res1 = gen_reg_rtx (<ssedvecmode>mode);
32037 rtx res2 = gen_reg_rtx (<ssedvecmode>mode);
32038 rtx sum = gen_reg_rtx (<ssedvecmode>mode);
32039
32040 emit_move_insn (sum, CONST0_RTX (<ssedvecmode>mode));
32041 emit_insn (gen_sdot_prod<ssedvecmodelower><sseunpackmodelower> (res1,
32042 op1_lo, op2_lo, sum));
32043 emit_insn (gen_sdot_prod<ssedvecmodelower><sseunpackmodelower> (res2,
32044 op1_hi, op2_hi,
32045 operands[3]));
32046 emit_insn (gen_add<ssedvecmodelower>3 (operands[0], res1, res2));
32047 }
32048
32049 DONE;
32050 })
32051
32052 (define_insn "vpdp<vpdotprodtype>_<mode>"
32053 [(set (match_operand:VI4_AVX 0 "register_operand" "=v")
32054 (unspec:VI4_AVX
32055 [(match_operand:VI4_AVX 1 "register_operand" "0")
32056 (match_operand:VI4_AVX 2 "register_operand" "v")
32057 (match_operand:VI4_AVX 3 "nonimmediate_operand" "vm")]
32058 VPDOTPROD))]
32059 "TARGET_AVXVNNIINT8 || TARGET_AVX10_2"
32060 "vpdp<vpdotprodtype>\t{%3, %2, %0|%0, %2, %3}"
32061 [(set_attr "prefix" "maybe_evex")])
32062
32063 (define_insn "vpdp<vpdotprodtype>_v16si"
32064 [(set (match_operand:V16SI 0 "register_operand" "=v")
32065 (unspec:V16SI
32066 [(match_operand:V16SI 1 "register_operand" "0")
32067 (match_operand:V16SI 2 "register_operand" "v")
32068 (match_operand:V16SI 3 "nonimmediate_operand" "vm")]
32069 VPDOTPROD))]
32070 "TARGET_AVX10_2"
32071 "vpdp<vpdotprodtype>\t{%3, %2, %0|%0, %2, %3}"
32072 [(set_attr "prefix" "evex")])
32073
32074 (define_insn "vpdp<vpdotprodtype>_<mode>_mask"
32075 [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=v")
32076 (vec_merge:VI4_AVX10_2
32077 (unspec:VI4_AVX10_2
32078 [(match_operand:VI4_AVX10_2 1 "register_operand" "0")
32079 (match_operand:VI4_AVX10_2 2 "register_operand" "v")
32080 (match_operand:VI4_AVX10_2 3 "nonimmediate_operand" "vm")]
32081 VPDOTPROD)
32082 (match_dup 1)
32083 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
32084 "TARGET_AVX10_2"
32085 "vpdp<vpdotprodtype>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
32086 [(set_attr "prefix" "evex")])
32087
32088 (define_expand "vpdp<vpdotprodtype>_<mode>_maskz"
32089 [(set (match_operand:VI4_AVX10_2 0 "register_operand")
32090 (vec_merge:VI4_AVX10_2
32091 (unspec:VI4_AVX10_2
32092 [(match_operand:VI4_AVX10_2 1 "register_operand")
32093 (match_operand:VI4_AVX10_2 2 "register_operand")
32094 (match_operand:VI4_AVX10_2 3 "nonimmediate_operand")]
32095 VPDOTPROD)
32096 (match_dup 5)
32097 (match_operand:<avx512fmaskmode> 4 "register_operand")))]
32098 "TARGET_AVX10_2"
32099 "operands[5] = CONST0_RTX (<MODE>mode);")
32100
32101 (define_insn "*vpdp<vpdotprodtype>_<mode>_maskz"
32102 [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=v")
32103 (vec_merge:VI4_AVX10_2
32104 (unspec:VI4_AVX10_2
32105 [(match_operand:VI4_AVX10_2 1 "register_operand" "0")
32106 (match_operand:VI4_AVX10_2 2 "register_operand" "v")
32107 (match_operand:VI4_AVX10_2 3 "nonimmediate_operand" "vm")]
32108 VPDOTPROD)
32109 (match_operand:VI4_AVX10_2 5 "const0_operand" "C")
32110 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
32111 "TARGET_AVX10_2"
32112 "vpdp<vpdotprodtype>\t{%3, %2, %0%{%4%}%N5|%0%{%4%}%N5, %2, %3}"
32113 [(set_attr "prefix" "evex")])
32114
32115 (define_insn "vbcstnebf162ps_<mode>"
32116 [(set (match_operand:VF1_128_256 0 "register_operand" "=x")
32117 (vec_duplicate:VF1_128_256
32118 (float_extend:SF
32119 (match_operand:BF 1 "memory_operand" "jm"))))]
32120 "TARGET_AVXNECONVERT"
32121 "vbcstnebf162ps\t{%1, %0|%0, %1}"
32122 [(set_attr "prefix" "vex")
32123 (set_attr "addr" "gpr16")
32124 (set_attr "mode" "<sseinsnmode>")])
32125
32126 (define_insn "vbcstnesh2ps_<mode>"
32127 [(set (match_operand:VF1_128_256 0 "register_operand" "=x")
32128 (vec_duplicate:VF1_128_256
32129 (float_extend:SF
32130 (match_operand:HF 1 "memory_operand" "jm"))))]
32131 "TARGET_AVXNECONVERT"
32132 "vbcstnesh2ps\t{%1, %0|%0, %1}"
32133 [(set_attr "prefix" "vex")
32134 (set_attr "addr" "gpr16")
32135 (set_attr "mode" "<sseinsnmode>")])
32136
32137 (define_mode_attr bf16_ph
32138 [(V8HF "ph") (V16HF "ph") (V32HF "ph")
32139 (V8BF "bf16") (V16BF "bf16") (V32BF "bf16")])
32140
32141 (define_insn "vcvtnee<bf16_ph>2ps_<mode>"
32142 [(set (match_operand:V4SF 0 "register_operand" "=x")
32143 (float_extend:V4SF
32144 (vec_select:<ssehalfvecmode>
32145 (match_operand:VHFBF_128 1 "memory_operand" "jm")
32146 (parallel [(const_int 0) (const_int 2)
32147 (const_int 4) (const_int 6)]))))]
32148 "TARGET_AVXNECONVERT"
32149 "vcvtnee<bf16_ph>2ps\t{%1, %0|%0, %1}"
32150 [(set_attr "prefix" "vex")
32151 (set_attr "addr" "gpr16")
32152 (set_attr "mode" "<sseinsnmode>")])
32153
32154 (define_insn "vcvtnee<bf16_ph>2ps_<mode>"
32155 [(set (match_operand:V8SF 0 "register_operand" "=x")
32156 (float_extend:V8SF
32157 (vec_select:<ssehalfvecmode>
32158 (match_operand:VHFBF_256 1 "memory_operand" "jm")
32159 (parallel [(const_int 0) (const_int 2)
32160 (const_int 4) (const_int 6)
32161 (const_int 8) (const_int 10)
32162 (const_int 12) (const_int 14)]))))]
32163 "TARGET_AVXNECONVERT"
32164 "vcvtnee<bf16_ph>2ps\t{%1, %0|%0, %1}"
32165 [(set_attr "prefix" "vex")
32166 (set_attr "addr" "gpr16")
32167 (set_attr "mode" "<sseinsnmode>")])
32168
32169 (define_insn "vcvtneo<bf16_ph>2ps_<mode>"
32170 [(set (match_operand:V4SF 0 "register_operand" "=x")
32171 (float_extend:V4SF
32172 (vec_select:<ssehalfvecmode>
32173 (match_operand:VHFBF_128 1 "memory_operand" "jm")
32174 (parallel [(const_int 1) (const_int 3)
32175 (const_int 5) (const_int 7)]))))]
32176 "TARGET_AVXNECONVERT"
32177 "vcvtneo<bf16_ph>2ps\t{%1, %0|%0, %1}"
32178 [(set_attr "prefix" "vex")
32179 (set_attr "addr" "gpr16")
32180 (set_attr "mode" "<sseinsnmode>")])
32181
32182 (define_insn "vcvtneo<bf16_ph>2ps_<mode>"
32183 [(set (match_operand:V8SF 0 "register_operand" "=x")
32184 (float_extend:V8SF
32185 (vec_select:<ssehalfvecmode>
32186 (match_operand:VHFBF_256 1 "memory_operand" "jm")
32187 (parallel [(const_int 1) (const_int 3)
32188 (const_int 5) (const_int 7)
32189 (const_int 9) (const_int 11)
32190 (const_int 13) (const_int 15)]))))]
32191 "TARGET_AVXNECONVERT"
32192 "vcvtneo<bf16_ph>2ps\t{%1, %0|%0, %1}"
32193 [(set_attr "prefix" "vex")
32194 (set_attr "addr" "gpr16")
32195 (set_attr "mode" "<sseinsnmode>")])
32196
32197 (define_insn "avx10_2_cvt2ps2phx_<mode><mask_name><round_name>"
32198 [(set (match_operand:VHF_AVX10_2 0 "register_operand" "=v")
32199 (vec_concat:VHF_AVX10_2
32200 (float_truncate:<ssehalfvecmode>
32201 (match_operand:<ssePSmode> 2 "<round_nimm_predicate>" "<round_constraint>"))
32202 (float_truncate:<ssehalfvecmode>
32203 (match_operand:<ssePSmode> 1 "register_operand" "v"))))]
32204 "TARGET_AVX10_2 && <round_mode512bit_condition>"
32205 "vcvt2ps2phx\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}")
32206
32207 (define_mode_attr ssebvecmode
32208 [(V8HF "V16QI") (V16HF "V32QI") (V32HF "V64QI")])
32209
32210 (define_int_iterator UNSPEC_CONVERTFP8_PACK
32211 [UNSPEC_VCVT2PH2BF8 UNSPEC_VCVT2PH2BF8S
32212 UNSPEC_VCVT2PH2HF8 UNSPEC_VCVT2PH2HF8S])
32213
32214 (define_int_attr convertfp8_pack
32215 [(UNSPEC_VCVT2PH2BF8 "2ph2bf8")
32216 (UNSPEC_VCVT2PH2BF8S "2ph2bf8s")
32217 (UNSPEC_VCVT2PH2HF8 "2ph2hf8")
32218 (UNSPEC_VCVT2PH2HF8S "2ph2hf8s")])
32219
32220 (define_insn "vcvt<convertfp8_pack><mode><mask_name>"
32221 [(set (match_operand:<ssebvecmode> 0 "register_operand" "=v")
32222 (unspec:<ssebvecmode>
32223 [(match_operand:VHF_AVX10_2 1 "register_operand" "v")
32224 (match_operand:VHF_AVX10_2 2 "nonimmediate_operand" "vm")]
32225 UNSPEC_CONVERTFP8_PACK))]
32226 "TARGET_AVX10_2"
32227 "vcvt<convertfp8_pack>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
32228 [(set_attr "prefix" "evex")])
32229
32230 (define_mode_attr ssebvecmode_2
32231 [(V8HF "V16QI") (V16HF "V16QI") (V32HF "V32QI")])
32232
32233 (define_mode_attr iptrssebvec_2
32234 [(V8HF "q") (V16HF "") (V32HF "")])
32235
32236 (define_int_iterator UNSPEC_VCVTBIASPH2FP8_PACK
32237 [UNSPEC_VCVTBIASPH2BF8 UNSPEC_VCVTBIASPH2BF8S
32238 UNSPEC_VCVTBIASPH2HF8 UNSPEC_VCVTBIASPH2HF8S])
32239
32240 (define_int_attr biasph2fp8_pack
32241 [(UNSPEC_VCVTBIASPH2BF8 "biasph2bf8")
32242 (UNSPEC_VCVTBIASPH2BF8S "biasph2bf8s")
32243 (UNSPEC_VCVTBIASPH2HF8 "biasph2hf8")
32244 (UNSPEC_VCVTBIASPH2HF8S "biasph2hf8s")])
32245
32246 (define_expand "vcvt<biasph2fp8_pack>v8hf"
32247 [(set (match_operand:V16QI 0 "register_operand")
32248 (vec_concat:V16QI
32249 (unspec:V8QI
32250 [(match_operand:V16QI 1 "register_operand")
32251 (match_operand:V8HF 2 "nonimmediate_operand")]
32252 UNSPEC_VCVTBIASPH2FP8_PACK)
32253 (match_dup 3)))]
32254 "TARGET_AVX10_2"
32255 "operands[3] = CONST0_RTX (V8QImode);")
32256
32257 (define_insn "*vcvt<biasph2fp8_pack>v8hf"
32258 [(set (match_operand:V16QI 0 "register_operand" "=v")
32259 (vec_concat:V16QI
32260 (unspec:V8QI
32261 [(match_operand:V16QI 1 "register_operand" "v")
32262 (match_operand:V8HF 2 "nonimmediate_operand" "vm")]
32263 UNSPEC_VCVTBIASPH2FP8_PACK)
32264 (match_operand:V8QI 3 "const0_operand")))]
32265 "TARGET_AVX10_2"
32266 "vcvt<biasph2fp8_pack>\t{%2, %1, %0|%0, %1, %2}"
32267 [(set_attr "prefix" "evex")
32268 (set_attr "mode" "HF")])
32269
32270 (define_expand "vcvt<biasph2fp8_pack>v8hf_mask"
32271 [(set (match_operand:V16QI 0 "register_operand")
32272 (vec_concat:V16QI
32273 (vec_merge:V8QI
32274 (unspec:V8QI
32275 [(match_operand:V16QI 1 "register_operand")
32276 (match_operand:V8HF 2 "nonimmediate_operand")]
32277 UNSPEC_VCVTBIASPH2FP8_PACK)
32278 (vec_select:V8QI
32279 (match_operand:V16QI 3 "nonimm_or_0_operand")
32280 (parallel [(const_int 0) (const_int 1)
32281 (const_int 2) (const_int 3)
32282 (const_int 4) (const_int 5)
32283 (const_int 6) (const_int 7)]))
32284 (match_operand:QI 4 "register_operand" "C"))
32285 (match_dup 5)))]
32286 "TARGET_AVX10_2"
32287 "operands[5] = CONST0_RTX (V8QImode);")
32288
32289 (define_insn "*vcvt<biasph2fp8_pack>v8hf_mask"
32290 [(set (match_operand:V16QI 0 "register_operand" "=v")
32291 (vec_concat:V16QI
32292 (vec_merge:V8QI
32293 (unspec:V8QI
32294 [(match_operand:V16QI 1 "register_operand" "v")
32295 (match_operand:V8HF 2 "nonimmediate_operand" "vm")]
32296 UNSPEC_VCVTBIASPH2FP8_PACK)
32297 (vec_select:V8QI
32298 (match_operand:V16QI 3 "nonimm_or_0_operand" "0C")
32299 (parallel [(const_int 0) (const_int 1)
32300 (const_int 2) (const_int 3)
32301 (const_int 4) (const_int 5)
32302 (const_int 6) (const_int 7)]))
32303 (match_operand:QI 4 "register_operand" "Yk"))
32304 (match_operand:V8QI 5 "const0_operand")))]
32305 "TARGET_AVX10_2"
32306 "vcvt<biasph2fp8_pack>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
32307 [(set_attr "prefix" "evex")])
32308
32309 (define_mode_iterator VHF_AVX10_2_2
32310 [(V32HF "TARGET_AVX10_2") V16HF])
32311
32312 (define_insn "vcvt<biasph2fp8_pack><mode><mask_name>"
32313 [(set (match_operand:<ssebvecmode_2> 0 "register_operand" "=v")
32314 (unspec:<ssebvecmode_2>
32315 [(match_operand:<ssebvecmode> 1 "register_operand" "v")
32316 (match_operand:VHF_AVX10_2_2 2 "nonimmediate_operand" "vm")]
32317 UNSPEC_VCVTBIASPH2FP8_PACK))]
32318 "TARGET_AVX10_2"
32319 "vcvt<biasph2fp8_pack>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
32320 [(set_attr "prefix" "evex")])
32321
32322 (define_mode_iterator VHF_256_512
32323 [V16HF (V32HF "TARGET_AVX10_2")])
32324
32325 (define_mode_attr ph2fp8suff
32326 [(V32HF "") (V16HF "{y}") (V8HF "{x}")])
32327
32328 (define_int_iterator UNSPEC_CONVERTPH2FP8
32329 [UNSPEC_VCVTPH2BF8 UNSPEC_VCVTPH2BF8S
32330 UNSPEC_VCVTPH2HF8 UNSPEC_VCVTPH2HF8S])
32331
32332 (define_int_attr convertph2fp8
32333 [(UNSPEC_VCVTPH2BF8 "ph2bf8")
32334 (UNSPEC_VCVTPH2BF8S "ph2bf8s")
32335 (UNSPEC_VCVTPH2HF8 "ph2hf8")
32336 (UNSPEC_VCVTPH2HF8S "ph2hf8s")])
32337
32338 (define_expand "vcvt<convertph2fp8>v8hf"
32339 [(set (match_operand:V16QI 0 "register_operand")
32340 (vec_concat:V16QI
32341 (unspec:V8QI
32342 [(match_operand:V8HF 1 "nonimmediate_operand")]
32343 UNSPEC_CONVERTPH2FP8)
32344 (match_dup 2)))]
32345 "TARGET_AVX10_2"
32346 "operands[2] = CONST0_RTX (V8QImode);")
32347
32348 (define_insn "*vcvt<convertph2fp8>v8hf"
32349 [(set (match_operand:V16QI 0 "register_operand" "=v")
32350 (vec_concat:V16QI
32351 (unspec:V8QI
32352 [(match_operand:V8HF 1 "nonimmediate_operand" "vm")]
32353 UNSPEC_CONVERTPH2FP8)
32354 (match_operand:V8QI 2 "const0_operand")))]
32355 "TARGET_AVX10_2"
32356 "vcvt<convertph2fp8>{x}\t{%1, %0|%0, %1}"
32357 [(set_attr "prefix" "evex")
32358 (set_attr "mode" "HF")])
32359
32360 (define_expand "vcvt<convertph2fp8>v8hf_mask"
32361 [(set (match_operand:V16QI 0 "register_operand")
32362 (vec_concat:V16QI
32363 (vec_merge:V8QI
32364 (unspec:V8QI
32365 [(match_operand:V8HF 1 "nonimmediate_operand")]
32366 UNSPEC_CONVERTPH2FP8)
32367 (vec_select:V8QI
32368 (match_operand:V16QI 2 "nonimm_or_0_operand")
32369 (parallel [(const_int 0) (const_int 1)
32370 (const_int 2) (const_int 3)
32371 (const_int 4) (const_int 5)
32372 (const_int 6) (const_int 7)]))
32373 (match_operand:QI 3 "register_operand"))
32374 (match_dup 4)))]
32375 "TARGET_AVX10_2"
32376 "operands[4] = CONST0_RTX (V8QImode);")
32377
32378 (define_insn "*vcvt<convertph2fp8>v8hf_mask"
32379 [(set (match_operand:V16QI 0 "register_operand" "=v")
32380 (vec_concat:V16QI
32381 (vec_merge:V8QI
32382 (unspec:V8QI
32383 [(match_operand:V8HF 1 "nonimmediate_operand" "vm")]
32384 UNSPEC_CONVERTPH2FP8)
32385 (vec_select:V8QI
32386 (match_operand:V16QI 2 "nonimm_or_0_operand" "0C")
32387 (parallel [(const_int 0) (const_int 1)
32388 (const_int 2) (const_int 3)
32389 (const_int 4) (const_int 5)
32390 (const_int 6) (const_int 7)]))
32391 (match_operand:QI 3 "register_operand" "Yk"))
32392 (match_operand:V8QI 4 "const0_operand")))]
32393 "TARGET_AVX10_2"
32394 "vcvt<convertph2fp8>{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
32395 [(set_attr "prefix" "evex")])
32396
32397 (define_insn "vcvt<convertph2fp8><mode><mask_name>"
32398 [(set (match_operand:<ssebvecmode_2> 0 "register_operand" "=v")
32399 (unspec:<ssebvecmode_2>
32400 [(match_operand:VHF_256_512 1 "nonimmediate_operand" "vm")]
32401 UNSPEC_CONVERTPH2FP8))]
32402 "TARGET_AVX10_2"
32403 "vcvt<convertph2fp8><ph2fp8suff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
32404 [(set_attr "prefix" "evex")])
32405
32406 (define_insn "vcvthf82ph<mode><mask_name>"
32407 [(set (match_operand:VHF_AVX10_2 0 "register_operand" "=v")
32408 (unspec:VHF_AVX10_2
32409 [(match_operand:<ssebvecmode_2> 1 "nonimmediate_operand" "vm")]
32410 UNSPEC_VCVTHF82PH))]
32411 "TARGET_AVX10_2"
32412 "vcvthf82ph\t{%1, %0<mask_operand2>|%0<mask_operand2>, %<iptrssebvec_2>1}"
32413 [(set_attr "prefix" "evex")])
32414
32415 (define_int_iterator VPDPWPROD
32416 [UNSPEC_VPDPWUSD
32417 UNSPEC_VPDPWUSDS
32418 UNSPEC_VPDPWSUD
32419 UNSPEC_VPDPWSUDS
32420 UNSPEC_VPDPWUUD
32421 UNSPEC_VPDPWUUDS])
32422
32423 (define_int_attr vpdpwprodtype
32424 [(UNSPEC_VPDPWUSD "wusd") (UNSPEC_VPDPWUSDS "wusds")
32425 (UNSPEC_VPDPWSUD "wsud") (UNSPEC_VPDPWSUDS "wsuds")
32426 (UNSPEC_VPDPWUUD "wuud") (UNSPEC_VPDPWUUDS "wuuds")])
32427
32428 (define_expand "usdot_prod<sseunpackmodelower><mode>"
32429 [(match_operand:<sseunpackmode> 0 "register_operand")
32430 (match_operand:VI2_AVX10_2 1 "register_operand")
32431 (match_operand:VI2_AVX10_2 2 "register_operand")
32432 (match_operand:<sseunpackmode> 3 "register_operand")]
32433 "TARGET_AVXVNNIINT16 || TARGET_AVX10_2"
32434 {
32435 operands[1] = lowpart_subreg (<sseunpackmode>mode,
32436 force_reg (<MODE>mode, operands[1]),
32437 <MODE>mode);
32438 operands[2] = lowpart_subreg (<sseunpackmode>mode,
32439 force_reg (<MODE>mode, operands[2]),
32440 <MODE>mode);
32441 emit_insn (gen_vpdpwusd_<SDOT_VPDP_SUF> (operands[0], operands[3],
32442 operands[1], operands[2]));
32443 DONE;
32444 })
32445
32446 (define_expand "udot_prod<sseunpackmodelower><mode>"
32447 [(match_operand:<sseunpackmode> 0 "register_operand")
32448 (match_operand:VI2_AVX10_2 1 "register_operand")
32449 (match_operand:VI2_AVX10_2 2 "register_operand")
32450 (match_operand:<sseunpackmode> 3 "register_operand")]
32451 "TARGET_AVXVNNIINT16 || TARGET_AVX10_2"
32452 {
32453 operands[1] = lowpart_subreg (<sseunpackmode>mode,
32454 force_reg (<MODE>mode, operands[1]),
32455 <MODE>mode);
32456 operands[2] = lowpart_subreg (<sseunpackmode>mode,
32457 force_reg (<MODE>mode, operands[2]),
32458 <MODE>mode);
32459 emit_insn (gen_vpdpwuud_<SDOT_VPDP_SUF> (operands[0], operands[3],
32460 operands[1], operands[2]));
32461 DONE;
32462 })
32463
32464 (define_insn "vpdp<vpdpwprodtype>_<mode>"
32465 [(set (match_operand:VI4_AVX 0 "register_operand" "=v")
32466 (unspec:VI4_AVX
32467 [(match_operand:VI4_AVX 1 "register_operand" "0")
32468 (match_operand:VI4_AVX 2 "register_operand" "v")
32469 (match_operand:VI4_AVX 3 "nonimmediate_operand" "vm")]
32470 VPDPWPROD))]
32471 "TARGET_AVXVNNIINT16 || TARGET_AVX10_2"
32472 "vpdp<vpdpwprodtype>\t{%3, %2, %0|%0, %2, %3}"
32473 [(set_attr "prefix" "maybe_evex")])
32474
32475 (define_insn "vpdp<vpdpwprodtype>_v16si"
32476 [(set (match_operand:V16SI 0 "register_operand" "=v")
32477 (unspec:V16SI
32478 [(match_operand:V16SI 1 "register_operand" "0")
32479 (match_operand:V16SI 2 "register_operand" "v")
32480 (match_operand:V16SI 3 "nonimmediate_operand" "vm")]
32481 VPDPWPROD))]
32482 "TARGET_AVX10_2"
32483 "vpdp<vpdpwprodtype>\t{%3, %2, %0|%0, %2, %3}"
32484 [(set_attr "prefix" "evex")])
32485
32486 (define_insn "vpdp<vpdpwprodtype>_<mode>_mask"
32487 [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=v")
32488 (vec_merge:VI4_AVX10_2
32489 (unspec:VI4_AVX10_2
32490 [(match_operand:VI4_AVX10_2 1 "register_operand" "0")
32491 (match_operand:VI4_AVX10_2 2 "register_operand" "v")
32492 (match_operand:VI4_AVX10_2 3 "nonimmediate_operand" "vm")]
32493 VPDPWPROD)
32494 (match_dup 1)
32495 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
32496 "TARGET_AVX10_2"
32497 "vpdp<vpdpwprodtype>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
32498 [(set_attr "prefix" "evex")])
32499
32500 (define_expand "vpdp<vpdpwprodtype>_<mode>_maskz"
32501 [(set (match_operand:VI4_AVX10_2 0 "register_operand")
32502 (vec_merge:VI4_AVX10_2
32503 (unspec:VI4_AVX10_2
32504 [(match_operand:VI4_AVX10_2 1 "register_operand")
32505 (match_operand:VI4_AVX10_2 2 "register_operand")
32506 (match_operand:VI4_AVX10_2 3 "nonimmediate_operand")]
32507 VPDPWPROD)
32508 (match_dup 5)
32509 (match_operand:<avx512fmaskmode> 4 "register_operand")))]
32510 "TARGET_AVX10_2"
32511 "operands[5] = CONST0_RTX (<MODE>mode);")
32512
32513 (define_insn "*vpdp<vpdpwprodtype>_<mode>_maskz"
32514 [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=v")
32515 (vec_merge:VI4_AVX10_2
32516 (unspec:VI4_AVX10_2
32517 [(match_operand:VI4_AVX10_2 1 "register_operand" "0")
32518 (match_operand:VI4_AVX10_2 2 "register_operand" "v")
32519 (match_operand:VI4_AVX10_2 3 "nonimmediate_operand" "vm")]
32520 VPDPWPROD)
32521 (match_operand:VI4_AVX10_2 5 "const0_operand" "C")
32522 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
32523 "TARGET_AVX10_2"
32524 "vpdp<vpdpwprodtype>\t{%3, %2, %0%{%4%}%N5|%0%{%4%}%N5, %2, %3}"
32525 [(set_attr "prefix" "evex")])
32526
32527 (define_insn "vdpphps_<mode>"
32528 [(set (match_operand:VF1_AVX10_2 0 "register_operand" "=v")
32529 (unspec:VF1_AVX10_2
32530 [(match_operand:VF1_AVX10_2 1 "register_operand" "0")
32531 (match_operand:VF1_AVX10_2 2 "register_operand" "v")
32532 (match_operand:VF1_AVX10_2 3 "nonimmediate_operand" "vm")]
32533 UNSPEC_VDPPHPS))]
32534 "TARGET_AVX10_2"
32535 "vdpphps\t{%3, %2, %0|%0, %2, %3}"
32536 [(set_attr "prefix" "evex")])
32537
32538 (define_insn "vdpphps_<mode>_mask"
32539 [(set (match_operand:VF1_AVX10_2 0 "register_operand" "=v")
32540 (vec_merge:VF1_AVX10_2
32541 (unspec:VF1_AVX10_2
32542 [(match_operand:VF1_AVX10_2 1 "register_operand" "0")
32543 (match_operand:VF1_AVX10_2 2 "register_operand" "v")
32544 (match_operand:VF1_AVX10_2 3 "nonimmediate_operand" "vm")]
32545 UNSPEC_VDPPHPS)
32546 (match_dup 1)
32547 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
32548 "TARGET_AVX10_2"
32549 "vdpphps\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
32550 [(set_attr "prefix" "evex")])
32551
32552 (define_expand "vdpphps_<mode>_maskz"
32553 [(match_operand:VF1_AVX10_2 0 "register_operand")
32554 (match_operand:VF1_AVX10_2 1 "register_operand")
32555 (match_operand:VF1_AVX10_2 2 "register_operand")
32556 (match_operand:VF1_AVX10_2 3 "nonimmediate_operand")
32557 (match_operand:<avx512fmaskmode> 4 "register_operand")]
32558 "TARGET_AVX10_2"
32559 {
32560 emit_insn (gen_vdpphps_<mode>_maskz_1 (operands[0], operands[1],
32561 operands[2], operands[3], CONST0_RTX(<MODE>mode), operands[4]));
32562 DONE;
32563 })
32564
32565 (define_insn "vdpphps_<mode>_maskz_1"
32566 [(set (match_operand:VF1_AVX10_2 0 "register_operand" "=v")
32567 (vec_merge:VF1_AVX10_2
32568 (unspec:VF1_AVX10_2
32569 [(match_operand:VF1_AVX10_2 1 "register_operand" "0")
32570 (match_operand:VF1_AVX10_2 2 "register_operand" "v")
32571 (match_operand:VF1_AVX10_2 3 "nonimmediate_operand" "vm")]
32572 UNSPEC_VDPPHPS)
32573 (match_operand:VF1_AVX10_2 4 "const0_operand" "C")
32574 (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
32575 "TARGET_AVX10_2"
32576 "vdpphps\t{%3, %2, %0%{%5%}%N4|%0%{%5%}%N4, %2, %3}"
32577 [(set_attr "prefix" "evex")])
32578
32579 (define_insn "avx10_2_scalefbf16_<mode><mask_name>"
32580 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v")
32581 (unspec:VBF_AVX10_2
32582 [(match_operand:VBF_AVX10_2 1 "register_operand" "v")
32583 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm")]
32584 UNSPEC_VSCALEFBF16))]
32585 "TARGET_AVX10_2"
32586 "vscalefbf16\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
32587 [(set_attr "prefix" "evex")])
32588
32589 (define_expand "<code><mode>3"
32590 [(set (match_operand:VBF_AVX10_2 0 "register_operand")
32591 (smaxmin:VBF_AVX10_2
32592 (match_operand:VBF_AVX10_2 1 "register_operand")
32593 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand")))]
32594 "TARGET_AVX10_2")
32595
32596 (define_insn "avx10_2_<code>bf16_<mode><mask_name>"
32597 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v")
32598 (smaxmin:VBF_AVX10_2
32599 (match_operand:VBF_AVX10_2 1 "register_operand" "v")
32600 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm")))]
32601 "TARGET_AVX10_2"
32602 "v<maxmin_float>bf16\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
32603 [(set_attr "prefix" "evex")
32604 (set_attr "mode" "<MODE>")])
32605
32606 (define_insn "avx10_2_<insn>bf16_<mode><mask_name>"
32607 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v")
32608 (plusminusmultdiv:VBF_AVX10_2
32609 (match_operand:VBF_AVX10_2 1 "register_operand" "v")
32610 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm")))]
32611 "TARGET_AVX10_2"
32612 "v<insn>bf16\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
32613 [(set_attr "prefix" "evex")])
32614
32615 (define_expand "avx10_2_fmaddbf16_<mode>_maskz"
32616 [(match_operand:VBF_AVX10_2 0 "register_operand")
32617 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand")
32618 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand")
32619 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand")
32620 (match_operand:<avx512fmaskmode> 4 "register_operand")]
32621 "TARGET_AVX10_2"
32622 {
32623 emit_insn (gen_avx10_2_fmaddbf16_<mode>_maskz_1 (operands[0], operands[1],
32624 operands[2], operands[3],
32625 CONST0_RTX (<MODE>mode),
32626 operands[4]));
32627 DONE;
32628 })
32629
32630 (define_insn "avx10_2_fmaddbf16_<mode><sd_maskz_name>"
32631 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v,v,v")
32632 (fma:VBF_AVX10_2
32633 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "%0,0,v")
32634 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm,v,vm")
32635 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand" "v,vm,0")))]
32636 "TARGET_AVX10_2"
32637 "@
32638 vfmadd132bf16\t{%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2}
32639 vfmadd213bf16\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}
32640 vfmadd231bf16\t{%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2}"
32641 [(set_attr "prefix" "evex")
32642 (set_attr "type" "ssemuladd")
32643 (set_attr "mode" "<sseinsnmode>")])
32644
32645 (define_insn "avx10_2_fmaddbf16_<mode>_mask"
32646 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v,v")
32647 (vec_merge:VBF_AVX10_2
32648 (fma:VBF_AVX10_2
32649 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "0,0")
32650 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm,v")
32651 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand" "v,vm"))
32652 (match_dup 1)
32653 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
32654 "TARGET_AVX10_2"
32655 "@
32656 vfmadd132bf16\t{%2, %3, %0%{%4%}|%0%{%4%}, %3, %2}
32657 vfmadd213bf16\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
32658 [(set_attr "prefix" "evex")
32659 (set_attr "type" "ssemuladd")
32660 (set_attr "mode" "<sseinsnmode>")])
32661
32662 (define_insn "avx10_2_fmaddbf16_<mode>_mask3"
32663 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v")
32664 (vec_merge:VBF_AVX10_2
32665 (fma:VBF_AVX10_2
32666 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "%v")
32667 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm")
32668 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand" "0"))
32669 (match_dup 3)
32670 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
32671 "TARGET_AVX10_2"
32672 "vfmadd231bf16\t{%2, %1, %0%{%4%}|%0%{%4%}, %1, %2}"
32673 [(set_attr "prefix" "evex")
32674 (set_attr "type" "ssemuladd")
32675 (set_attr "mode" "<sseinsnmode>")])
32676
32677 (define_expand "avx10_2_fnmaddbf16_<mode>_maskz"
32678 [(match_operand:VBF_AVX10_2 0 "register_operand")
32679 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand")
32680 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand")
32681 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand")
32682 (match_operand:<avx512fmaskmode> 4 "register_operand")]
32683 "TARGET_AVX10_2"
32684 {
32685 emit_insn (gen_avx10_2_fnmaddbf16_<mode>_maskz_1 (operands[0], operands[1],
32686 operands[2], operands[3],
32687 CONST0_RTX (<MODE>mode),
32688 operands[4]));
32689 DONE;
32690 })
32691
32692 (define_insn "avx10_2_fnmaddbf16_<mode><sd_maskz_name>"
32693 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v,v,v")
32694 (fma:VBF_AVX10_2
32695 (neg:VBF_AVX10_2
32696 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "%0,0,v"))
32697 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm,v,vm")
32698 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand" "v,vm,0")))]
32699 "TARGET_AVX10_2"
32700 "@
32701 vfnmadd132bf16\t{%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2}
32702 vfnmadd213bf16\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}
32703 vfnmadd231bf16\t{%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2}"
32704 [(set_attr "prefix" "evex")
32705 (set_attr "type" "ssemuladd")
32706 (set_attr "mode" "<sseinsnmode>")])
32707
32708 (define_insn "avx10_2_fnmaddbf16_<mode>_mask"
32709 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v,v")
32710 (vec_merge:VBF_AVX10_2
32711 (fma:VBF_AVX10_2
32712 (neg:VBF_AVX10_2
32713 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "0,0"))
32714 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm,v")
32715 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand" "v,vm"))
32716 (match_dup 1)
32717 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
32718 "TARGET_AVX10_2"
32719 "@
32720 vfnmadd132bf16\t{%2, %3, %0%{%4%}|%0%{%4%}, %3, %2}
32721 vfnmadd213bf16\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
32722 [(set_attr "prefix" "evex")
32723 (set_attr "type" "ssemuladd")
32724 (set_attr "mode" "<sseinsnmode>")])
32725
32726 (define_insn "avx10_2_fnmaddbf16_<mode>_mask3"
32727 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v")
32728 (vec_merge:VBF_AVX10_2
32729 (fma:VBF_AVX10_2
32730 (neg:VBF_AVX10_2
32731 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "%v"))
32732 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm")
32733 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand" "0"))
32734 (match_dup 3)
32735 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
32736 "TARGET_AVX10_2"
32737 "vfnmadd231bf16\t{%2, %1, %0%{%4%}|%0%{%4%}, %1, %2}"
32738 [(set_attr "prefix" "evex")
32739 (set_attr "type" "ssemuladd")
32740 (set_attr "mode" "<sseinsnmode>")])
32741
32742 (define_expand "avx10_2_fmsubbf16_<mode>_maskz"
32743 [(match_operand:VBF_AVX10_2 0 "register_operand")
32744 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand")
32745 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand")
32746 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand")
32747 (match_operand:<avx512fmaskmode> 4 "register_operand")]
32748 "TARGET_AVX10_2"
32749 {
32750 emit_insn (gen_avx10_2_fmsubbf16_<mode>_maskz_1 (operands[0], operands[1],
32751 operands[2], operands[3],
32752 CONST0_RTX (<MODE>mode),
32753 operands[4]));
32754 DONE;
32755 })
32756
32757 (define_insn "avx10_2_fmsubbf16_<mode><sd_maskz_name>"
32758 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v,v,v")
32759 (fma:VBF_AVX10_2
32760 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "%0,0,v")
32761 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm,v,vm")
32762 (neg:VBF_AVX10_2
32763 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand" "v,vm,0"))))]
32764 "TARGET_AVX10_2"
32765 "@
32766 vfmsub132bf16\t{%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2}
32767 vfmsub213bf16\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}
32768 vfmsub231bf16\t{%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2}"
32769 [(set_attr "prefix" "evex")
32770 (set_attr "type" "ssemuladd")
32771 (set_attr "mode" "<sseinsnmode>")])
32772
32773 (define_insn "avx10_2_fmsubbf16_<mode>_mask"
32774 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v,v")
32775 (vec_merge:VBF_AVX10_2
32776 (fma:VBF_AVX10_2
32777 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "0,0")
32778 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm,v")
32779 (neg:VBF_AVX10_2
32780 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand" "v,vm")))
32781 (match_dup 1)
32782 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
32783 "TARGET_AVX10_2"
32784 "@
32785 vfmsub132bf16\t{%2, %3, %0%{%4%}|%0%{%4%}, %3, %2}
32786 vfmsub213bf16\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
32787 [(set_attr "prefix" "evex")
32788 (set_attr "type" "ssemuladd")
32789 (set_attr "mode" "<sseinsnmode>")])
32790
32791 (define_insn "avx10_2_fmsubbf16_<mode>_mask3"
32792 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v")
32793 (vec_merge:VBF_AVX10_2
32794 (fma:VBF_AVX10_2
32795 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "%v")
32796 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm")
32797 (neg:VBF_AVX10_2
32798 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand" "0")))
32799 (match_dup 3)
32800 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
32801 "TARGET_AVX10_2"
32802 "vfmsub231bf16\t{%2, %1, %0%{%4%}|%0%{%4%}, %1, %2}"
32803 [(set_attr "prefix" "evex")
32804 (set_attr "type" "ssemuladd")
32805 (set_attr "mode" "<sseinsnmode>")])
32806
32807 (define_expand "avx10_2_fnmsubbf16_<mode>_maskz"
32808 [(match_operand:VBF_AVX10_2 0 "register_operand")
32809 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand")
32810 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand")
32811 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand")
32812 (match_operand:<avx512fmaskmode> 4 "register_operand")]
32813 "TARGET_AVX10_2"
32814 {
32815 emit_insn (gen_avx10_2_fnmsubbf16_<mode>_maskz_1 (operands[0], operands[1],
32816 operands[2], operands[3],
32817 CONST0_RTX (<MODE>mode),
32818 operands[4]));
32819 DONE;
32820 })
32821
32822 (define_insn "avx10_2_fnmsubbf16_<mode><sd_maskz_name>"
32823 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v,v,v")
32824 (fma:VBF_AVX10_2
32825 (neg:VBF_AVX10_2
32826 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "%0,0,v"))
32827 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm,v,vm")
32828 (neg:VBF_AVX10_2
32829 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand" "v,vm,0"))))]
32830 "TARGET_AVX10_2"
32831 "@
32832 vfnmsub132bf16\t{%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2}
32833 vfnmsub213bf16\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}
32834 vfnmsub231bf16\t{%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2}"
32835 [(set_attr "prefix" "evex")
32836 (set_attr "type" "ssemuladd")
32837 (set_attr "mode" "<sseinsnmode>")])
32838
32839 (define_insn "avx10_2_fnmsubbf16_<mode>_mask"
32840 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v,v")
32841 (vec_merge:VBF_AVX10_2
32842 (fma:VBF_AVX10_2
32843 (neg:VBF_AVX10_2
32844 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "0,0"))
32845 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm,v")
32846 (neg:VBF_AVX10_2
32847 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand" "v,vm")))
32848 (match_dup 1)
32849 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
32850 "TARGET_AVX10_2"
32851 "@
32852 vfnmsub132bf16\t{%2, %3, %0%{%4%}|%0%{%4%}, %3, %2}
32853 vfnmsub213bf16\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
32854 [(set_attr "prefix" "evex")
32855 (set_attr "type" "ssemuladd")
32856 (set_attr "mode" "<sseinsnmode>")])
32857
32858 (define_insn "avx10_2_fnmsubbf16_<mode>_mask3"
32859 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v")
32860 (vec_merge:VBF_AVX10_2
32861 (fma:VBF_AVX10_2
32862 (neg:VBF_AVX10_2
32863 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "%v"))
32864 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm")
32865 (neg:VBF_AVX10_2
32866 (match_operand:VBF_AVX10_2 3 "nonimmediate_operand" "0")))
32867 (match_dup 3)
32868 (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
32869 "TARGET_AVX10_2"
32870 "vfnmsub231bf16\t{%2, %1, %0%{%4%}|%0%{%4%}, %1, %2}"
32871 [(set_attr "prefix" "evex")
32872 (set_attr "type" "ssemuladd")
32873 (set_attr "mode" "<sseinsnmode>")])
32874
32875 (define_insn "avx10_2_rsqrtbf16_<mode><mask_name>"
32876 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v")
32877 (unspec:VBF_AVX10_2
32878 [(match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "vm")]
32879 UNSPEC_RSQRT))]
32880 "TARGET_AVX10_2"
32881 "vrsqrtbf16\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
32882 [(set_attr "prefix" "evex")])
32883
32884 (define_insn "avx10_2_sqrtbf16_<mode><mask_name>"
32885 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v")
32886 (sqrt:VBF_AVX10_2
32887 (match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "vm")))]
32888 "TARGET_AVX10_2"
32889 "vsqrtbf16\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
32890 [(set_attr "prefix" "evex")])
32891
32892 (define_insn "avx10_2_rcpbf16_<mode><mask_name>"
32893 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v")
32894 (unspec:VBF_AVX10_2
32895 [(match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "vm")]
32896 UNSPEC_RCP))]
32897 "TARGET_AVX10_2"
32898 "vrcpbf16\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
32899 [(set_attr "prefix" "evex")])
32900
32901 (define_insn "avx10_2_getexpbf16_<mode><mask_name>"
32902 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v")
32903 (unspec:VBF_AVX10_2
32904 [(match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "vm")]
32905 UNSPEC_GETEXP))]
32906 "TARGET_AVX10_2"
32907 "vgetexpbf16\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
32908 [(set_attr "prefix" "evex")])
32909
32910 (define_int_iterator BF16IMMOP
32911 [UNSPEC_VRNDSCALEBF16
32912 UNSPEC_VREDUCEBF16
32913 UNSPEC_VGETMANTBF16])
32914
32915 (define_int_attr bf16immop
32916 [(UNSPEC_VRNDSCALEBF16 "rndscale")
32917 (UNSPEC_VREDUCEBF16 "reduce")
32918 (UNSPEC_VGETMANTBF16 "getmant")])
32919
32920 (define_insn "avx10_2_<bf16immop>bf16_<mode><mask_name>"
32921 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v")
32922 (unspec:VBF_AVX10_2
32923 [(match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "vm")
32924 (match_operand:SI 2 "const_0_to_255_operand")]
32925 BF16IMMOP))]
32926 "TARGET_AVX10_2"
32927 "v<bf16immop>bf16\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
32928 [(set_attr "prefix" "evex")])
32929
32930 (define_insn "avx10_2_fpclassbf16_<mode><mask_scalar_merge_name>"
32931 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
32932 (unspec:<avx512fmaskmode>
32933 [(match_operand:VBF_AVX10_2 1 "nonimmediate_operand" "vm")
32934 (match_operand 2 "const_0_to_255_operand")]
32935 UNSPEC_VFPCLASSBF16))]
32936 "TARGET_AVX10_2"
32937 "vfpclassbf16<vecmemsuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
32938 [(set_attr "prefix" "evex")])
32939
32940 (define_insn "avx10_2_cmpbf16_<mode><mask_scalar_merge_name>"
32941 [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=k")
32942 (unspec:<avx512fmaskmode>
32943 [(match_operand:VBF_AVX10_2 1 "register_operand" "v")
32944 (match_operand:VBF_AVX10_2 2 "nonimmediate_operand" "vm")
32945 (match_operand 3 "const_0_to_31_operand" "n")]
32946 UNSPEC_PCMP))]
32947 "TARGET_AVX10_2"
32948 "vcmpbf16\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
32949 [(set_attr "prefix" "evex")])
32950
32951 (define_int_iterator UNSPEC_CVT_BF16_IBS_ITER
32952 [UNSPEC_VCVTBF162IBS
32953 UNSPEC_VCVTBF162IUBS
32954 UNSPEC_VCVTTBF162IBS
32955 UNSPEC_VCVTTBF162IUBS])
32956
32957 (define_int_attr sat_cvt_sign_prefix
32958 [(UNSPEC_VCVTBF162IBS "")
32959 (UNSPEC_VCVTBF162IUBS "u")
32960 (UNSPEC_VCVTTBF162IBS "")
32961 (UNSPEC_VCVTTBF162IUBS "u")
32962 (UNSPEC_VCVTPH2IBS "")
32963 (UNSPEC_VCVTPH2IUBS "u")
32964 (UNSPEC_VCVTTPH2IBS "")
32965 (UNSPEC_VCVTTPH2IUBS "u")
32966 (UNSPEC_VCVTPS2IBS "")
32967 (UNSPEC_VCVTPS2IUBS "u")
32968 (UNSPEC_VCVTTPS2IBS "")
32969 (UNSPEC_VCVTTPS2IUBS "u")
32970 (UNSPEC_SFIX_SATURATION "")
32971 (UNSPEC_UFIX_SATURATION "u")])
32972
32973 (define_int_attr sat_cvt_trunc_prefix
32974 [(UNSPEC_VCVTBF162IBS "")
32975 (UNSPEC_VCVTBF162IUBS "")
32976 (UNSPEC_VCVTTBF162IBS "t")
32977 (UNSPEC_VCVTTBF162IUBS "t")])
32978
32979 (define_insn "avx10_2_cvt<sat_cvt_trunc_prefix>bf162i<sat_cvt_sign_prefix>bs<mode><mask_name>"
32980 [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
32981 (unspec:<sseintvecmode>
32982 [(match_operand:VBF_AVX10_2 1 "vector_operand" "vm")]
32983 UNSPEC_CVT_BF16_IBS_ITER))]
32984 "TARGET_AVX10_2"
32985 "vcvt<sat_cvt_trunc_prefix>bf162i<sat_cvt_sign_prefix>bs\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
32986 [(set_attr "type" "ssecvt")
32987 (set_attr "prefix" "evex")
32988 (set_attr "mode" "<sseinsnmode>")])
32989
32990 (define_int_iterator UNSPEC_CVT_PH_IBS_ITER
32991 [UNSPEC_VCVTPH2IBS
32992 UNSPEC_VCVTPH2IUBS])
32993
32994 (define_insn "avx10_2_cvtph2i<sat_cvt_sign_prefix>bs<mode><mask_name><round_name>"
32995 [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
32996 (unspec:<sseintvecmode>
32997 [(match_operand:VHF_AVX10_2 1 "<round_nimm_predicate>" "<round_constraint>")]
32998 UNSPEC_CVT_PH_IBS_ITER))]
32999 "TARGET_AVX10_2 && <round_mode512bit_condition>"
33000 "vcvtph2i<sat_cvt_sign_prefix>bs\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
33001 [(set_attr "type" "ssecvt")
33002 (set_attr "prefix" "evex")
33003 (set_attr "mode" "<sseinsnmode>")])
33004
33005 (define_int_iterator UNSPEC_CVTT_PH_IBS_ITER
33006 [UNSPEC_VCVTTPH2IBS
33007 UNSPEC_VCVTTPH2IUBS])
33008
33009 (define_insn "avx10_2_cvttph2i<sat_cvt_sign_prefix>bs<mode><mask_name><round_saeonly_name>"
33010 [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
33011 (unspec:<sseintvecmode>
33012 [(match_operand:VHF_AVX10_2 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
33013 UNSPEC_CVTT_PH_IBS_ITER))]
33014 "TARGET_AVX10_2 && <round_saeonly_mode512bit_condition>"
33015 "vcvttph2i<sat_cvt_sign_prefix>bs\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
33016 [(set_attr "type" "ssecvt")
33017 (set_attr "prefix" "evex")
33018 (set_attr "mode" "<sseinsnmode>")])
33019
33020 (define_int_iterator UNSPEC_CVT_PS_IBS_ITER
33021 [UNSPEC_VCVTPS2IBS
33022 UNSPEC_VCVTPS2IUBS])
33023
33024 (define_insn "avx10_2_cvtps2i<sat_cvt_sign_prefix>bs<mode><mask_name><round_name>"
33025 [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
33026 (unspec:<sseintvecmode>
33027 [(match_operand:VF1_AVX10_2 1 "<round_nimm_predicate>" "<round_constraint>")]
33028 UNSPEC_CVT_PS_IBS_ITER))]
33029 "TARGET_AVX10_2 && <round_mode512bit_condition>"
33030 "vcvtps2i<sat_cvt_sign_prefix>bs\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
33031 [(set_attr "type" "ssecvt")
33032 (set_attr "prefix" "evex")
33033 (set_attr "mode" "<sseinsnmode>")])
33034
33035 (define_int_iterator UNSPEC_CVTT_PS_IBS_ITER
33036 [UNSPEC_VCVTTPS2IBS
33037 UNSPEC_VCVTTPS2IUBS])
33038
33039 (define_insn "avx10_2_cvttps2i<sat_cvt_sign_prefix>bs<mode><mask_name><round_saeonly_name>"
33040 [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
33041 (unspec:<sseintvecmode>
33042 [(match_operand:VF1_AVX10_2 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
33043 UNSPEC_CVTT_PS_IBS_ITER))]
33044 "TARGET_AVX10_2 && <round_saeonly_mode512bit_condition>"
33045 "vcvttps2i<sat_cvt_sign_prefix>bs\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
33046 [(set_attr "type" "ssecvt")
33047 (set_attr "prefix" "evex")
33048 (set_attr "mode" "<sseinsnmode>")])
33049
33050 (define_int_iterator UNSPEC_SAT_CVT_DS_SIGN_ITER
33051 [UNSPEC_SFIX_SATURATION
33052 UNSPEC_UFIX_SATURATION])
33053
33054 (define_mode_attr pd2dqssuff
33055 [(V16SF "") (V8SF "") (V4SF "")
33056 (V8DF "") (V4DF "{y}") (V2DF "{x}")])
33057
33058 ;; Pointer size override for ps2qq conversions: V2DI uses half-width (64-bit)
33059 ;; source, needing %q for Intel syntax memory operand disambiguation.
33060 (define_mode_attr iptrps2qq
33061 [(V8DI "") (V4DI "") (V2DI "q")])
33062
33063 (define_insn "avx10_2_vcvtt<castmode>2<sat_cvt_sign_prefix>dqs<mode><mask_name><round_saeonly_name>"
33064 [(set (match_operand:<VEC_GATHER_IDXSI> 0 "register_operand" "=v")
33065 (unspec:<VEC_GATHER_IDXSI>
33066 [(match_operand:VF1_VF2_AVX10_2 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
33067 UNSPEC_SAT_CVT_DS_SIGN_ITER))]
33068 "TARGET_AVX10_2 && <round_saeonly_mode512bit_condition>"
33069 "vcvtt<castmode>2<sat_cvt_sign_prefix>dqs<pd2dqssuff>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
33070 [(set_attr "type" "ssecvt")
33071 (set_attr "prefix" "evex")
33072 (set_attr "mode" "<sseinsnmode>")])
33073
33074 (define_insn "avx10_2_vcvttpd2<sat_cvt_sign_prefix>qqs<mode><mask_name><round_saeonly_name>"
33075 [(set (match_operand:<VEC_GATHER_IDXDI> 0 "register_operand" "=v")
33076 (unspec:<VEC_GATHER_IDXDI>
33077 [(match_operand:VF2_AVX10_2 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
33078 UNSPEC_SAT_CVT_DS_SIGN_ITER))]
33079 "TARGET_AVX10_2 && <round_saeonly_mode512bit_condition>"
33080 "vcvttpd2<sat_cvt_sign_prefix>qqs\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
33081 [(set_attr "type" "ssecvt")
33082 (set_attr "prefix" "evex")
33083 (set_attr "mode" "<sseinsnmode>")])
33084
33085 (define_insn "avx10_2_vcvttps2<sat_cvt_sign_prefix>qqs<mode><mask_name><round_saeonly_name>"
33086 [(set (match_operand:VI8_AVX10_2 0 "register_operand" "=v")
33087 (unspec:VI8_AVX10_2
33088 [(match_operand:<vpckfloat_temp_mode> 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
33089 UNSPEC_SAT_CVT_DS_SIGN_ITER))]
33090 "TARGET_AVX10_2 && <round_saeonly_mode512bit_condition>"
33091 "vcvttps2<sat_cvt_sign_prefix>qqs\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %<iptrps2qq>1<round_saeonly_mask_op2>}"
33092 [(set_attr "type" "ssecvt")
33093 (set_attr "prefix" "evex")
33094 (set_attr "mode" "<sseinsnmode>")])
33095
33096 (define_insn "avx10_2_vcvttsd2<sat_cvt_sign_prefix>sis<mode><round_saeonly_name>"
33097 [(set (match_operand:SWI48 0 "register_operand" "=r")
33098 (unspec:SWI48
33099 [(vec_select:DF
33100 (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
33101 (parallel [(const_int 0)]))]
33102 UNSPEC_SAT_CVT_DS_SIGN_ITER))]
33103 "TARGET_AVX10_2"
33104 "vcvttsd2<sat_cvt_sign_prefix>sis\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
33105 [(set_attr "type" "ssecvt")
33106 (set_attr "prefix" "evex")
33107 (set_attr "mode" "<MODE>")])
33108
33109 (define_insn "avx10_2_vcvttss2<sat_cvt_sign_prefix>sis<mode><round_saeonly_name>"
33110 [(set (match_operand:SWI48 0 "register_operand" "=r")
33111 (unspec:SWI48
33112 [(vec_select:SF
33113 (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
33114 (parallel [(const_int 0)]))]
33115 UNSPEC_SAT_CVT_DS_SIGN_ITER))]
33116 "TARGET_AVX10_2"
33117 "vcvttss2<sat_cvt_sign_prefix>sis\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
33118 [(set_attr "type" "ssecvt")
33119 (set_attr "prefix" "evex")
33120 (set_attr "mode" "<MODE>")])
33121
33122 (define_insn "avx10_2_minmaxbf16_<mode><mask_name>"
33123 [(set (match_operand:VBF_AVX10_2 0 "register_operand" "=v")
33124 (unspec:VBF_AVX10_2
33125 [(match_operand:VBF_AVX10_2 1 "register_operand" "v")
33126 (match_operand:VBF_AVX10_2 2 "bcst_vector_operand" "vmBr")
33127 (match_operand:SI 3 "const_0_to_255_operand")]
33128 UNSPEC_MINMAXBF16))]
33129 "TARGET_AVX10_2"
33130 "vminmaxbf16\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}"
33131 [(set_attr "prefix" "evex")
33132 (set_attr "mode" "<sseinsnmode>")])
33133
33134 (define_insn "avx10_2_minmaxp<mode><mask_name><round_saeonly_name>"
33135 [(set (match_operand:VFH_AVX10_2 0 "register_operand" "=v")
33136 (unspec:VFH_AVX10_2
33137 [(match_operand:VFH_AVX10_2 1 "register_operand" "v")
33138 (match_operand:VFH_AVX10_2 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
33139 (match_operand:SI 3 "const_0_to_255_operand")]
33140 UNSPEC_MINMAX))]
33141 "TARGET_AVX10_2"
33142 "vminmax<ssemodesuffix>\t{%3, <round_saeonly_mask_op4>%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2<round_saeonly_mask_op4>, %3}"
33143 [(set_attr "prefix" "evex")
33144 (set_attr "mode" "<MODE>")])
33145
33146 (define_insn "avx10_2_minmaxs<mode><mask_scalar_name><round_saeonly_scalar_name>"
33147 [(set (match_operand:VFH_128 0 "register_operand" "=v")
33148 (vec_merge:VFH_128
33149 (unspec:VFH_128
33150 [(match_operand:VFH_128 1 "register_operand" "v")
33151 (match_operand:VFH_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")
33152 (match_operand:SI 3 "const_0_to_255_operand")]
33153 UNSPEC_MINMAX)
33154 (match_dup 1)
33155 (const_int 1)))]
33156 "TARGET_AVX10_2"
33157 "vminmax<ssescalarmodesuffix>\t{%3, <round_saeonly_scalar_mask_op4>%2, %1, %0<mask_scalar_operand4>|%0<mask_scalar_operand4>, %1, %2<round_saeonly_scalar_mask_op4>, %3}"
33158 [(set_attr "prefix" "evex")
33159 (set_attr "mode" "<ssescalarmode>")])
33160
33161 (define_insn "avx10_2_vmovrs<ssemodesuffix><mode><mask_name>"
33162 [(set (match_operand:VI1248_AVX10_2 0 "register_operand" "=v")
33163 (unspec:VI1248_AVX10_2
33164 [(match_operand:VI1248_AVX10_2 1 "memory_operand" "m")]
33165 UNSPEC_VMOVRS))]
33166 "TARGET_AVX10_2 && TARGET_MOVRS"
33167 "vmovrs<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
33168 [(set_attr "type" "ssemov")
33169 (set_attr "prefix" "evex")
33170 (set_attr "memory" "load")
33171 (set_attr "mode" "<sseinsnmode>")])