2018-10-02 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / config / i386 / sse.md
blobce26994f61fa39cd6fa1decb5c7fb04415be4814
1 ;; GCC machine description for SSE instructions
2 ;; Copyright (C) 2005-2018 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.
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.
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/>.
20 (define_c_enum "unspec" [
21   ;; SSE
22   UNSPEC_MOVNT
24   ;; SSE3
25   UNSPEC_LDDQU
27   ;; SSSE3
28   UNSPEC_PSHUFB
29   UNSPEC_PSIGN
30   UNSPEC_PALIGNR
32   ;; For SSE4A support
33   UNSPEC_EXTRQI
34   UNSPEC_EXTRQ
35   UNSPEC_INSERTQI
36   UNSPEC_INSERTQ
38   ;; For SSE4.1 support
39   UNSPEC_BLENDV
40   UNSPEC_INSERTPS
41   UNSPEC_DP
42   UNSPEC_MOVNTDQA
43   UNSPEC_MPSADBW
44   UNSPEC_PHMINPOSUW
45   UNSPEC_PTEST
47   ;; For SSE4.2 support
48   UNSPEC_PCMPESTR
49   UNSPEC_PCMPISTR
51   ;; For FMA4 support
52   UNSPEC_FMADDSUB
53   UNSPEC_XOP_UNSIGNED_CMP
54   UNSPEC_XOP_TRUEFALSE
55   UNSPEC_XOP_PERMUTE
56   UNSPEC_FRCZ
58   ;; For AES support
59   UNSPEC_AESENC
60   UNSPEC_AESENCLAST
61   UNSPEC_AESDEC
62   UNSPEC_AESDECLAST
63   UNSPEC_AESIMC
64   UNSPEC_AESKEYGENASSIST
66   ;; For PCLMUL support
67   UNSPEC_PCLMUL
69   ;; For AVX support
70   UNSPEC_PCMP
71   UNSPEC_VPERMIL
72   UNSPEC_VPERMIL2
73   UNSPEC_VPERMIL2F128
74   UNSPEC_CAST
75   UNSPEC_VTESTP
76   UNSPEC_VCVTPH2PS
77   UNSPEC_VCVTPS2PH
79   ;; For AVX2 support
80   UNSPEC_VPERMVAR
81   UNSPEC_VPERMTI
82   UNSPEC_GATHER
83   UNSPEC_VSIBADDR
85   ;; For AVX512F support
86   UNSPEC_VPERMT2
87   UNSPEC_UNSIGNED_FIX_NOTRUNC
88   UNSPEC_UNSIGNED_PCMP
89   UNSPEC_TESTM
90   UNSPEC_TESTNM
91   UNSPEC_SCATTER
92   UNSPEC_RCP14
93   UNSPEC_RSQRT14
94   UNSPEC_FIXUPIMM
95   UNSPEC_SCALEF
96   UNSPEC_VTERNLOG
97   UNSPEC_GETEXP
98   UNSPEC_GETMANT
99   UNSPEC_ALIGN
100   UNSPEC_CONFLICT
101   UNSPEC_COMPRESS
102   UNSPEC_COMPRESS_STORE
103   UNSPEC_EXPAND
104   UNSPEC_MASKED_EQ
105   UNSPEC_MASKED_GT
107   ;; Mask operations
108   UNSPEC_MASKOP
109   UNSPEC_KORTEST
110   UNSPEC_KTEST
112   ;; For embed. rounding feature
113   UNSPEC_EMBEDDED_ROUNDING
115   ;; For AVX512PF support
116   UNSPEC_GATHER_PREFETCH
117   UNSPEC_SCATTER_PREFETCH
119   ;; For AVX512ER support
120   UNSPEC_EXP2
121   UNSPEC_RCP28
122   UNSPEC_RSQRT28
124   ;; For SHA support
125   UNSPEC_SHA1MSG1
126   UNSPEC_SHA1MSG2
127   UNSPEC_SHA1NEXTE
128   UNSPEC_SHA1RNDS4
129   UNSPEC_SHA256MSG1
130   UNSPEC_SHA256MSG2
131   UNSPEC_SHA256RNDS2
133   ;; For AVX512BW support
134   UNSPEC_DBPSADBW
135   UNSPEC_PMADDUBSW512
136   UNSPEC_PMADDWD512
137   UNSPEC_PSHUFHW
138   UNSPEC_PSHUFLW
139   UNSPEC_CVTINT2MASK
141   ;; For AVX512DQ support
142   UNSPEC_REDUCE
143   UNSPEC_FPCLASS
144   UNSPEC_RANGE
146   ;; For AVX512IFMA support
147   UNSPEC_VPMADD52LUQ
148   UNSPEC_VPMADD52HUQ
150   ;; For AVX512VBMI support
151   UNSPEC_VPMULTISHIFT
153   ;; For AVX5124FMAPS/AVX5124VNNIW support
154   UNSPEC_VP4FMADD
155   UNSPEC_VP4FNMADD
156   UNSPEC_VP4DPWSSD
157   UNSPEC_VP4DPWSSDS
159   ;; For GFNI support
160   UNSPEC_GF2P8AFFINEINV
161   UNSPEC_GF2P8AFFINE
162   UNSPEC_GF2P8MUL
164   ;; For AVX512VBMI2 support
165   UNSPEC_VPSHLD
166   UNSPEC_VPSHRD
167   UNSPEC_VPSHRDV
168   UNSPEC_VPSHLDV
170   ;; For AVX512VNNI support
171   UNSPEC_VPMADDUBSWACCD
172   UNSPEC_VPMADDUBSWACCSSD
173   UNSPEC_VPMADDWDACCD
174   UNSPEC_VPMADDWDACCSSD
176   ;; For VAES support
177   UNSPEC_VAESDEC
178   UNSPEC_VAESDECLAST
179   UNSPEC_VAESENC
180   UNSPEC_VAESENCLAST
182   ;; For VPCLMULQDQ support
183   UNSPEC_VPCLMULQDQ
185   ;; For AVX512BITALG support
186   UNSPEC_VPSHUFBIT
189 (define_c_enum "unspecv" [
190   UNSPECV_LDMXCSR
191   UNSPECV_STMXCSR
192   UNSPECV_CLFLUSH
193   UNSPECV_MONITOR
194   UNSPECV_MWAIT
195   UNSPECV_VZEROALL
196   UNSPECV_VZEROUPPER
199 ;; All vector modes including V?TImode, used in move patterns.
200 (define_mode_iterator VMOVE
201   [(V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
202    (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI
203    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
204    (V8DI "TARGET_AVX512F")  (V4DI "TARGET_AVX") V2DI
205    (V4TI "TARGET_AVX512F") (V2TI "TARGET_AVX") V1TI
206    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
207    (V8DF "TARGET_AVX512F")  (V4DF "TARGET_AVX") V2DF])
209 ;; All AVX-512{F,VL} vector modes. Supposed TARGET_AVX512F baseline.
210 (define_mode_iterator V48_AVX512VL
211   [V16SI (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
212    V8DI  (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")
213    V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
214    V8DF  (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
216 ;; 1,2 byte AVX-512{BW,VL} vector modes. Supposed TARGET_AVX512BW baseline.
217 (define_mode_iterator VI12_AVX512VL
218   [V64QI (V16QI "TARGET_AVX512VL") (V32QI "TARGET_AVX512VL")
219    V32HI (V16HI "TARGET_AVX512VL") (V8HI "TARGET_AVX512VL")])
221 ;; Same iterator, but without supposed TARGET_AVX512BW
222 (define_mode_iterator VI12_AVX512VLBW
223   [(V64QI "TARGET_AVX512BW") (V16QI "TARGET_AVX512VL")
224    (V32QI "TARGET_AVX512VL && TARGET_AVX512BW") (V32HI "TARGET_AVX512BW")
225    (V16HI "TARGET_AVX512VL") (V8HI "TARGET_AVX512VL")])
227 (define_mode_iterator VI1_AVX512VL
228   [V64QI (V16QI "TARGET_AVX512VL") (V32QI "TARGET_AVX512VL")])
230 ;; All vector modes
231 (define_mode_iterator V
232   [(V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
233    (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI
234    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
235    (V8DI "TARGET_AVX512F")  (V4DI "TARGET_AVX") V2DI
236    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
237    (V8DF "TARGET_AVX512F")  (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
239 ;; All 128bit vector modes
240 (define_mode_iterator V_128
241   [V16QI V8HI V4SI V2DI V4SF (V2DF "TARGET_SSE2")])
243 ;; All 256bit vector modes
244 (define_mode_iterator V_256
245   [V32QI V16HI V8SI V4DI V8SF V4DF])
247 ;; All 128bit and 256bit vector modes
248 (define_mode_iterator V_128_256
249   [V32QI V16QI V16HI V8HI V8SI V4SI V4DI V2DI V8SF V4SF V4DF V2DF])
251 ;; All 512bit vector modes
252 (define_mode_iterator V_512 [V64QI V32HI V16SI V8DI V16SF V8DF])
254 ;; All 256bit and 512bit vector modes
255 (define_mode_iterator V_256_512
256   [V32QI V16HI V8SI V4DI V8SF V4DF
257    (V64QI "TARGET_AVX512F") (V32HI "TARGET_AVX512F") (V16SI "TARGET_AVX512F")
258    (V8DI "TARGET_AVX512F") (V16SF "TARGET_AVX512F") (V8DF "TARGET_AVX512F")])
260 ;; All vector float modes
261 (define_mode_iterator VF
262   [(V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
263    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
265 ;; 128- and 256-bit float vector modes
266 (define_mode_iterator VF_128_256
267   [(V8SF "TARGET_AVX") V4SF
268    (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
270 ;; All SFmode vector float modes
271 (define_mode_iterator VF1
272   [(V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF])
274 ;; 128- and 256-bit SF vector modes
275 (define_mode_iterator VF1_128_256
276   [(V8SF "TARGET_AVX") V4SF])
278 (define_mode_iterator VF1_128_256VL
279   [V8SF (V4SF "TARGET_AVX512VL")])
281 ;; All DFmode vector float modes
282 (define_mode_iterator VF2
283   [(V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") V2DF])
285 ;; 128- and 256-bit DF vector modes
286 (define_mode_iterator VF2_128_256
287   [(V4DF "TARGET_AVX") V2DF])
289 (define_mode_iterator VF2_512_256
290   [(V8DF "TARGET_AVX512F") V4DF])
292 (define_mode_iterator VF2_512_256VL
293   [V8DF (V4DF "TARGET_AVX512VL")])
295 ;; All 128bit vector float modes
296 (define_mode_iterator VF_128
297   [V4SF (V2DF "TARGET_SSE2")])
299 ;; All 256bit vector float modes
300 (define_mode_iterator VF_256
301   [V8SF V4DF])
303 ;; All 512bit vector float modes
304 (define_mode_iterator VF_512
305   [V16SF V8DF])
307 (define_mode_iterator VI48_AVX512VL
308   [V16SI (V8SI  "TARGET_AVX512VL") (V4SI  "TARGET_AVX512VL")
309    V8DI  (V4DI  "TARGET_AVX512VL") (V2DI  "TARGET_AVX512VL")])
311 (define_mode_iterator VF_AVX512VL
312   [V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
313    V8DF (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
315 (define_mode_iterator VF2_AVX512VL
316   [V8DF (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
318 (define_mode_iterator VF1_AVX512VL
319   [V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")])
321 ;; All vector integer modes
322 (define_mode_iterator VI
323   [(V16SI "TARGET_AVX512F") (V8DI "TARGET_AVX512F")
324    (V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX") V16QI
325    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX") V8HI
326    (V8SI "TARGET_AVX") V4SI
327    (V4DI "TARGET_AVX") V2DI])
329 (define_mode_iterator VI_AVX2
330   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
331    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI
332    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI
333    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX2") V2DI])
335 ;; All QImode vector integer modes
336 (define_mode_iterator VI1
337   [(V32QI "TARGET_AVX") V16QI])
339 ;; All DImode vector integer modes
340 (define_mode_iterator V_AVX
341   [V16QI V8HI V4SI V2DI V4SF V2DF
342    (V32QI "TARGET_AVX") (V16HI "TARGET_AVX")
343    (V8SI "TARGET_AVX") (V4DI "TARGET_AVX")
344    (V8SF "TARGET_AVX") (V4DF"TARGET_AVX")])
346 (define_mode_iterator VI48_AVX
347  [V4SI V2DI
348   (V8SI "TARGET_AVX") (V4DI "TARGET_AVX")])
350 (define_mode_iterator VI8
351   [(V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI])
353 (define_mode_iterator VI8_FVL
354   [(V8DI "TARGET_AVX512F") V4DI (V2DI "TARGET_AVX512VL")])
356 (define_mode_iterator VI8_AVX512VL
357   [V8DI (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
359 (define_mode_iterator VI8_256_512
360   [V8DI (V4DI "TARGET_AVX512VL")])
362 (define_mode_iterator VI1_AVX2
363   [(V32QI "TARGET_AVX2") V16QI])
365 (define_mode_iterator VI1_AVX512
366   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI])
368 (define_mode_iterator VI1_AVX512F
369   [(V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI])
371 (define_mode_iterator VI2_AVX2
372   [(V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI])
374 (define_mode_iterator VI2_AVX512F
375   [(V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX2") V8HI])
377 (define_mode_iterator VI4_AVX
378   [(V8SI "TARGET_AVX") V4SI])
380 (define_mode_iterator VI4_AVX2
381   [(V8SI "TARGET_AVX2") V4SI])
383 (define_mode_iterator VI4_AVX512F
384   [(V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI])
386 (define_mode_iterator VI4_AVX512VL
387   [V16SI (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")])
389 (define_mode_iterator VI48_AVX512F_AVX512VL
390   [V4SI V8SI (V16SI "TARGET_AVX512F")
391    (V2DI "TARGET_AVX512VL") (V4DI "TARGET_AVX512VL") (V8DI "TARGET_AVX512F")])
393 (define_mode_iterator VI2_AVX512VL
394   [(V8HI "TARGET_AVX512VL") (V16HI "TARGET_AVX512VL") V32HI])
396 (define_mode_iterator VI1_AVX512VL_F
397   [V32QI (V16QI "TARGET_AVX512VL") (V64QI "TARGET_AVX512F")])
399 (define_mode_iterator VI8_AVX2_AVX512BW
400   [(V8DI "TARGET_AVX512BW") (V4DI "TARGET_AVX2") V2DI])
402 (define_mode_iterator VI8_AVX2
403   [(V4DI "TARGET_AVX2") V2DI])
405 (define_mode_iterator VI8_AVX2_AVX512F
406   [(V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX2") V2DI])
408 (define_mode_iterator VI8_AVX_AVX512F
409   [(V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX")])
411 (define_mode_iterator VI4_128_8_256
412   [V4SI V4DI])
414 ;; All V8D* modes
415 (define_mode_iterator V8FI
416   [V8DF V8DI])
418 ;; All V16S* modes
419 (define_mode_iterator V16FI
420   [V16SF V16SI])
422 ;; ??? We should probably use TImode instead.
423 (define_mode_iterator VIMAX_AVX2_AVX512BW
424   [(V4TI "TARGET_AVX512BW") (V2TI "TARGET_AVX2") V1TI])
426 ;; Suppose TARGET_AVX512BW as baseline
427 (define_mode_iterator VIMAX_AVX512VL
428   [V4TI (V2TI "TARGET_AVX512VL") (V1TI "TARGET_AVX512VL")])
430 (define_mode_iterator VIMAX_AVX2
431   [(V2TI "TARGET_AVX2") V1TI])
433 ;; ??? This should probably be dropped in favor of VIMAX_AVX2_AVX512BW.
434 (define_mode_iterator SSESCALARMODE
435   [(V4TI "TARGET_AVX512BW") (V2TI "TARGET_AVX2") TI])
437 (define_mode_iterator VI12_AVX2
438   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
439    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI])
441 (define_mode_iterator VI24_AVX2
442   [(V16HI "TARGET_AVX2") V8HI
443    (V8SI "TARGET_AVX2") V4SI])
445 (define_mode_iterator VI124_AVX2_24_AVX512F_1_AVX512BW
446   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
447    (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX2") V8HI
448    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI])
450 (define_mode_iterator VI124_AVX2
451   [(V32QI "TARGET_AVX2") V16QI
452    (V16HI "TARGET_AVX2") V8HI
453    (V8SI "TARGET_AVX2") V4SI])
455 (define_mode_iterator VI2_AVX2_AVX512BW
456   [(V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI])
458 (define_mode_iterator VI248_AVX512VL
459   [V32HI V16SI V8DI
460    (V16HI "TARGET_AVX512VL") (V8SI "TARGET_AVX512VL")
461    (V4DI "TARGET_AVX512VL") (V8HI "TARGET_AVX512VL")
462    (V4SI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
464 (define_mode_iterator VI48_AVX2
465   [(V8SI "TARGET_AVX2") V4SI
466    (V4DI "TARGET_AVX2") V2DI])
468 (define_mode_iterator VI248_AVX2
469   [(V16HI "TARGET_AVX2") V8HI
470    (V8SI "TARGET_AVX2") V4SI
471    (V4DI "TARGET_AVX2") V2DI])
473 (define_mode_iterator VI248_AVX2_8_AVX512F_24_AVX512BW
474   [(V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI
475    (V16SI "TARGET_AVX512BW") (V8SI "TARGET_AVX2") V4SI
476    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX2") V2DI])
478 (define_mode_iterator VI248_AVX512BW
479   [(V32HI "TARGET_AVX512BW") V16SI V8DI])
481 (define_mode_iterator VI248_AVX512BW_AVX512VL
482   [(V32HI "TARGET_AVX512BW") 
483    (V4DI "TARGET_AVX512VL") V16SI V8DI])
485 ;; Suppose TARGET_AVX512VL as baseline
486 (define_mode_iterator VI248_AVX512BW_1
487  [(V16HI "TARGET_AVX512BW") (V8HI "TARGET_AVX512BW")
488   V8SI V4SI
489   V2DI])
490    
491 (define_mode_iterator VI248_AVX512BW_2
492  [(V16HI "TARGET_AVX512BW") (V8HI "TARGET_AVX512BW")
493   V8SI V4SI
494   V4DI V2DI])
495    
496 (define_mode_iterator VI48_AVX512F
497   [(V16SI "TARGET_AVX512F") V8SI V4SI
498    (V8DI "TARGET_AVX512F") V4DI V2DI])
500 (define_mode_iterator VI48_AVX_AVX512F
501   [(V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
502    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI])
504 (define_mode_iterator VI12_AVX_AVX512F
505   [ (V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
506     (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI])
508 (define_mode_iterator V48_AVX2
509   [V4SF V2DF
510    V8SF V4DF
511    (V4SI "TARGET_AVX2") (V2DI "TARGET_AVX2")
512    (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")])
514 (define_mode_iterator VI1_AVX512VLBW
515   [(V64QI "TARGET_AVX512BW") (V32QI  "TARGET_AVX512VL")
516         (V16QI  "TARGET_AVX512VL")])
518 (define_mode_attr avx512
519   [(V16QI "avx512vl") (V32QI "avx512vl") (V64QI "avx512bw")
520    (V8HI  "avx512vl") (V16HI  "avx512vl") (V32HI "avx512bw")
521    (V4SI  "avx512vl") (V8SI  "avx512vl") (V16SI "avx512f")
522    (V2DI  "avx512vl") (V4DI  "avx512vl") (V8DI "avx512f")
523    (V4SF "avx512vl") (V8SF "avx512vl") (V16SF "avx512f")
524    (V2DF "avx512vl") (V4DF "avx512vl") (V8DF "avx512f")])
526 (define_mode_attr sse2_avx_avx512f
527   [(V16QI "sse2") (V32QI "avx") (V64QI "avx512f")
528    (V8HI  "avx512vl") (V16HI  "avx512vl") (V32HI "avx512bw")
529    (V4SI  "sse2") (V8SI  "avx") (V16SI "avx512f")
530    (V2DI  "avx512vl") (V4DI  "avx512vl") (V8DI "avx512f")
531    (V16SF "avx512f") (V8SF "avx") (V4SF "avx")
532    (V8DF "avx512f") (V4DF "avx") (V2DF "avx")])
534 (define_mode_attr sse2_avx2
535   [(V16QI "sse2") (V32QI "avx2") (V64QI "avx512bw")
536    (V8HI "sse2") (V16HI "avx2") (V32HI "avx512bw")
537    (V4SI "sse2") (V8SI "avx2") (V16SI "avx512f")
538    (V2DI "sse2") (V4DI "avx2") (V8DI "avx512f")
539    (V1TI "sse2") (V2TI "avx2") (V4TI "avx512bw")])
541 (define_mode_attr ssse3_avx2
542    [(V16QI "ssse3") (V32QI "avx2") (V64QI "avx512bw")
543     (V4HI "ssse3") (V8HI "ssse3") (V16HI "avx2") (V32HI "avx512bw")
544     (V4SI "ssse3") (V8SI "avx2")
545     (V2DI "ssse3") (V4DI "avx2")
546     (TI "ssse3") (V2TI "avx2") (V4TI "avx512bw")])
548 (define_mode_attr sse4_1_avx2
549    [(V16QI "sse4_1") (V32QI "avx2") (V64QI "avx512bw")
550     (V8HI "sse4_1") (V16HI "avx2") (V32HI "avx512bw")
551     (V4SI "sse4_1") (V8SI "avx2") (V16SI "avx512f")
552     (V2DI "sse4_1") (V4DI "avx2") (V8DI "avx512dq")])
554 (define_mode_attr avx_avx2
555   [(V4SF "avx") (V2DF "avx")
556    (V8SF "avx") (V4DF "avx")
557    (V4SI "avx2") (V2DI "avx2")
558    (V8SI "avx2") (V4DI "avx2")])
560 (define_mode_attr vec_avx2
561   [(V16QI "vec") (V32QI "avx2")
562    (V8HI "vec") (V16HI "avx2")
563    (V4SI "vec") (V8SI "avx2")
564    (V2DI "vec") (V4DI "avx2")])
566 (define_mode_attr avx2_avx512
567   [(V4SI "avx2") (V8SI "avx2") (V16SI "avx512f")
568    (V2DI "avx2") (V4DI "avx2") (V8DI "avx512f")
569    (V4SF "avx2") (V8SF "avx2") (V16SF "avx512f")
570    (V2DF "avx2") (V4DF "avx2") (V8DF "avx512f")
571    (V8HI "avx512vl") (V16HI "avx512vl") (V32HI "avx512bw")])
573 (define_mode_attr shuffletype
574   [(V16SF "f") (V16SI "i") (V8DF "f") (V8DI "i")
575   (V8SF "f") (V8SI "i") (V4DF "f") (V4DI "i")
576   (V4SF "f") (V4SI "i") (V2DF "f") (V2DI "i")
577   (V32HI "i") (V16HI "i") (V8HI "i")
578   (V64QI "i") (V32QI "i") (V16QI "i")
579   (V4TI "i") (V2TI "i") (V1TI "i")])
581 (define_mode_attr ssequartermode
582   [(V16SF "V4SF") (V8DF "V2DF") (V16SI "V4SI") (V8DI "V2DI")])
584 (define_mode_attr ssequarterinsnmode
585   [(V16SF "V4SF") (V8DF "V2DF") (V16SI "TI") (V8DI "TI")])
587 (define_mode_attr ssedoublemodelower
588   [(V16QI "v16hi") (V32QI "v32hi") (V64QI "v64hi")
589    (V8HI "v8si")   (V16HI "v16si") (V32HI "v32si")
590    (V4SI "v4di")   (V8SI "v8di")   (V16SI "v16di")])
592 (define_mode_attr ssedoublemode
593   [(V4SF "V8SF") (V8SF "V16SF") (V16SF "V32SF")
594    (V2DF "V4DF") (V4DF "V8DF") (V8DF "V16DF")
595    (V16QI "V16HI") (V32QI "V32HI") (V64QI "V64HI")
596    (V4HI "V4SI") (V8HI "V8SI") (V16HI "V16SI") (V32HI "V32SI")
597    (V4SI "V4DI") (V8SI "V16SI") (V16SI "V32SI")
598    (V4DI "V8DI") (V8DI "V16DI")])
600 (define_mode_attr ssebytemode
601   [(V8DI "V64QI") (V4DI "V32QI") (V2DI "V16QI")])
603 ;; All 128bit vector integer modes
604 (define_mode_iterator VI_128 [V16QI V8HI V4SI V2DI])
606 ;; All 256bit vector integer modes
607 (define_mode_iterator VI_256 [V32QI V16HI V8SI V4DI])
609 ;; Various 128bit vector integer mode combinations
610 (define_mode_iterator VI12_128 [V16QI V8HI])
611 (define_mode_iterator VI14_128 [V16QI V4SI])
612 (define_mode_iterator VI124_128 [V16QI V8HI V4SI])
613 (define_mode_iterator VI24_128 [V8HI V4SI])
614 (define_mode_iterator VI248_128 [V8HI V4SI V2DI])
615 (define_mode_iterator VI48_128 [V4SI V2DI])
617 ;; Various 256bit and 512 vector integer mode combinations
618 (define_mode_iterator VI124_256 [V32QI V16HI V8SI])
619 (define_mode_iterator VI124_256_AVX512F_AVX512BW
620   [V32QI V16HI V8SI
621    (V64QI "TARGET_AVX512BW")
622    (V32HI "TARGET_AVX512BW")
623    (V16SI "TARGET_AVX512F")])
624 (define_mode_iterator VI48_256 [V8SI V4DI])
625 (define_mode_iterator VI48_512 [V16SI V8DI])
626 (define_mode_iterator VI4_256_8_512 [V8SI V8DI])
627 (define_mode_iterator VI_AVX512BW
628   [V16SI V8DI (V32HI "TARGET_AVX512BW") (V64QI "TARGET_AVX512BW")])
630 ;; Int-float size matches
631 (define_mode_iterator VI4F_128 [V4SI V4SF])
632 (define_mode_iterator VI8F_128 [V2DI V2DF])
633 (define_mode_iterator VI4F_256 [V8SI V8SF])
634 (define_mode_iterator VI8F_256 [V4DI V4DF])
635 (define_mode_iterator VI4F_256_512
636   [V8SI V8SF
637    (V16SI "TARGET_AVX512F") (V16SF "TARGET_AVX512F")])
638 (define_mode_iterator VI48F_256_512
639   [V8SI V8SF
640   (V16SI "TARGET_AVX512F") (V16SF "TARGET_AVX512F")
641   (V8DI  "TARGET_AVX512F") (V8DF  "TARGET_AVX512F")
642   (V4DI  "TARGET_AVX512VL") (V4DF  "TARGET_AVX512VL")])
643 (define_mode_iterator VF48_I1248
644   [V16SI V16SF V8DI V8DF V32HI V64QI])
645 (define_mode_iterator VI48F
646   [V16SI V16SF V8DI V8DF
647    (V8SI "TARGET_AVX512VL") (V8SF "TARGET_AVX512VL")
648    (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")
649    (V4SI "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
650    (V2DI "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
651 (define_mode_iterator VI48F_256 [V8SI V8SF V4DI V4DF])
653 ;; Mapping from float mode to required SSE level
654 (define_mode_attr sse
655   [(SF "sse") (DF "sse2")
656    (V4SF "sse") (V2DF "sse2")
657    (V16SF "avx512f") (V8SF "avx")
658    (V8DF "avx512f") (V4DF "avx")])
660 (define_mode_attr sse2
661   [(V16QI "sse2") (V32QI "avx") (V64QI "avx512f")
662    (V2DI "sse2") (V4DI "avx") (V8DI "avx512f")])
664 (define_mode_attr sse3
665   [(V16QI "sse3") (V32QI "avx")])
667 (define_mode_attr sse4_1
668   [(V4SF "sse4_1") (V2DF "sse4_1")
669    (V8SF "avx") (V4DF "avx")
670    (V8DF "avx512f")
671    (V4DI "avx") (V2DI "sse4_1")
672    (V8SI "avx") (V4SI "sse4_1")
673    (V16QI "sse4_1") (V32QI "avx")
674    (V8HI "sse4_1") (V16HI "avx")])
676 (define_mode_attr avxsizesuffix
677   [(V64QI "512") (V32HI "512") (V16SI "512") (V8DI "512")
678    (V32QI "256") (V16HI "256") (V8SI "256") (V4DI "256")
679    (V16QI "") (V8HI "") (V4SI "") (V2DI "")
680    (V16SF "512") (V8DF "512")
681    (V8SF "256") (V4DF "256")
682    (V4SF "") (V2DF "")])
684 ;; SSE instruction mode
685 (define_mode_attr sseinsnmode
686   [(V64QI "XI") (V32HI "XI") (V16SI "XI") (V8DI "XI") (V4TI "XI")
687    (V32QI "OI") (V16HI "OI") (V8SI "OI") (V4DI "OI") (V2TI "OI")
688    (V16QI "TI") (V8HI "TI") (V4SI "TI") (V2DI "TI") (V1TI "TI")
689    (V16SF "V16SF") (V8DF "V8DF")
690    (V8SF "V8SF") (V4DF "V4DF")
691    (V4SF "V4SF") (V2DF "V2DF")
692    (TI "TI")])
694 ;; Mapping of vector modes to corresponding mask size
695 (define_mode_attr avx512fmaskmode
696   [(V64QI "DI") (V32QI "SI") (V16QI "HI")
697    (V32HI "SI") (V16HI "HI") (V8HI  "QI") (V4HI "QI")
698    (V16SI "HI") (V8SI  "QI") (V4SI  "QI")
699    (V8DI  "QI") (V4DI  "QI") (V2DI  "QI")
700    (V16SF "HI") (V8SF  "QI") (V4SF  "QI")
701    (V8DF  "QI") (V4DF  "QI") (V2DF  "QI")])
703 ;; Mapping of vector modes to corresponding mask size
704 (define_mode_attr avx512fmaskmodelower
705   [(V64QI "di") (V32QI "si") (V16QI "hi")
706    (V32HI "si") (V16HI "hi") (V8HI  "qi") (V4HI "qi")
707    (V16SI "hi") (V8SI  "qi") (V4SI  "qi")
708    (V8DI  "qi") (V4DI  "qi") (V2DI  "qi")
709    (V16SF "hi") (V8SF  "qi") (V4SF  "qi")
710    (V8DF  "qi") (V4DF  "qi") (V2DF  "qi")])
712 ;; Mapping of vector float modes to an integer mode of the same size
713 (define_mode_attr sseintvecmode
714   [(V16SF "V16SI") (V8DF  "V8DI")
715    (V8SF  "V8SI")  (V4DF  "V4DI")
716    (V4SF  "V4SI")  (V2DF  "V2DI")
717    (V16SI "V16SI") (V8DI  "V8DI")
718    (V8SI  "V8SI")  (V4DI  "V4DI")
719    (V4SI  "V4SI")  (V2DI  "V2DI")
720    (V16HI "V16HI") (V8HI  "V8HI")
721    (V32HI "V32HI") (V64QI "V64QI")
722    (V32QI "V32QI") (V16QI "V16QI")])
724 (define_mode_attr sseintvecmode2
725   [(V8DF "XI") (V4DF "OI") (V2DF "TI")
726    (V8SF "OI") (V4SF "TI")])
728 (define_mode_attr sseintvecmodelower
729   [(V16SF "v16si") (V8DF "v8di")
730    (V8SF "v8si") (V4DF "v4di")
731    (V4SF "v4si") (V2DF "v2di")
732    (V8SI "v8si") (V4DI "v4di")
733    (V4SI "v4si") (V2DI "v2di")
734    (V16HI "v16hi") (V8HI "v8hi")
735    (V32QI "v32qi") (V16QI "v16qi")])
737 ;; Mapping of vector modes to a vector mode of double size
738 (define_mode_attr ssedoublevecmode
739   [(V32QI "V64QI") (V16HI "V32HI") (V8SI "V16SI") (V4DI "V8DI")
740    (V16QI "V32QI") (V8HI "V16HI") (V4SI "V8SI") (V2DI "V4DI")
741    (V8SF "V16SF") (V4DF "V8DF")
742    (V4SF "V8SF") (V2DF "V4DF")])
744 ;; Mapping of vector modes to a vector mode of half size
745 (define_mode_attr ssehalfvecmode
746   [(V64QI "V32QI") (V32HI "V16HI") (V16SI "V8SI") (V8DI "V4DI") (V4TI "V2TI")
747    (V32QI "V16QI") (V16HI  "V8HI") (V8SI  "V4SI") (V4DI "V2DI")
748    (V16QI  "V8QI") (V8HI   "V4HI") (V4SI  "V2SI")
749    (V16SF "V8SF") (V8DF "V4DF")
750    (V8SF  "V4SF") (V4DF "V2DF")
751    (V4SF  "V2SF")])
753 (define_mode_attr ssehalfvecmodelower
754   [(V64QI "v32qi") (V32HI "v16hi") (V16SI "v8si") (V8DI "v4di") (V4TI "v2ti")
755    (V32QI "v16qi") (V16HI  "v8hi") (V8SI  "v4si") (V4DI "v2di")
756    (V16QI  "v8qi") (V8HI   "v4hi") (V4SI  "v2si")
757    (V16SF "v8sf") (V8DF "v4df")
758    (V8SF  "v4sf") (V4DF "v2df")
759    (V4SF  "v2sf")])
761 ;; Mapping of vector modes ti packed single mode of the same size
762 (define_mode_attr ssePSmode
763   [(V16SI "V16SF") (V8DF "V16SF")
764    (V16SF "V16SF") (V8DI "V16SF")
765    (V64QI "V16SF") (V32QI "V8SF") (V16QI "V4SF")
766    (V32HI "V16SF") (V16HI "V8SF") (V8HI "V4SF")
767    (V8SI "V8SF") (V4SI "V4SF")
768    (V4DI "V8SF") (V2DI "V4SF")
769    (V4TI "V16SF") (V2TI "V8SF") (V1TI "V4SF")
770    (V8SF "V8SF") (V4SF "V4SF")
771    (V4DF "V8SF") (V2DF "V4SF")])
773 (define_mode_attr ssePSmode2
774   [(V8DI "V8SF") (V4DI "V4SF")])
776 ;; Mapping of vector modes back to the scalar modes
777 (define_mode_attr ssescalarmode
778   [(V64QI "QI") (V32QI "QI") (V16QI "QI")
779    (V32HI "HI") (V16HI "HI") (V8HI "HI")
780    (V16SI "SI") (V8SI "SI")  (V4SI "SI")
781    (V8DI "DI")  (V4DI "DI")  (V2DI "DI")
782    (V16SF "SF") (V8SF "SF")  (V4SF "SF")
783    (V8DF "DF")  (V4DF "DF")  (V2DF "DF")
784    (V4TI "TI")  (V2TI "TI")])
786 ;; Mapping of vector modes back to the scalar modes
787 (define_mode_attr ssescalarmodelower
788   [(V64QI "qi") (V32QI "qi") (V16QI "qi")
789    (V32HI "hi") (V16HI "hi") (V8HI "hi")
790    (V16SI "si") (V8SI "si")  (V4SI "si")
791    (V8DI "di")  (V4DI "di")  (V2DI "di")
792    (V16SF "sf") (V8SF "sf")  (V4SF "sf")
793    (V8DF "df")  (V4DF "df")  (V2DF "df")
794    (V4TI "ti")  (V2TI "ti")])
796 ;; Mapping of vector modes to the 128bit modes
797 (define_mode_attr ssexmmmode
798   [(V64QI "V16QI") (V32QI "V16QI") (V16QI "V16QI")
799    (V32HI "V8HI")  (V16HI "V8HI") (V8HI "V8HI")
800    (V16SI "V4SI")  (V8SI "V4SI")  (V4SI "V4SI")
801    (V8DI "V2DI")   (V4DI "V2DI")  (V2DI "V2DI")
802    (V16SF "V4SF")  (V8SF "V4SF")  (V4SF "V4SF")
803    (V8DF "V2DF")   (V4DF "V2DF")  (V2DF "V2DF")])
805 ;; Pointer size override for scalar modes (Intel asm dialect)
806 (define_mode_attr iptr
807   [(V64QI "b") (V32HI "w") (V16SI "k") (V8DI "q")
808    (V32QI "b") (V16HI "w") (V8SI "k") (V4DI "q")
809    (V16QI "b") (V8HI "w") (V4SI "k") (V2DI "q")
810    (V16SF "k") (V8DF "q")
811    (V8SF "k") (V4DF "q")
812    (V4SF "k") (V2DF "q")
813    (SF "k") (DF "q")])
815 ;; Number of scalar elements in each vector type
816 (define_mode_attr ssescalarnum
817   [(V64QI "64") (V16SI "16") (V8DI "8")
818    (V32QI "32") (V16HI "16") (V8SI "8") (V4DI "4")
819    (V16QI "16") (V8HI "8") (V4SI "4") (V2DI "2")
820    (V16SF "16") (V8DF "8")
821    (V8SF "8") (V4DF "4")
822    (V4SF "4") (V2DF "2")])
824 ;; Mask of scalar elements in each vector type
825 (define_mode_attr ssescalarnummask
826   [(V32QI "31") (V16HI "15") (V8SI "7") (V4DI "3")
827    (V16QI "15") (V8HI "7") (V4SI "3") (V2DI "1")
828    (V8SF "7") (V4DF "3")
829    (V4SF "3") (V2DF "1")])
831 (define_mode_attr ssescalarsize
832   [(V4TI  "64") (V2TI  "64") (V1TI  "64")
833    (V8DI  "64") (V4DI  "64") (V2DI  "64")
834    (V64QI "8") (V32QI "8") (V16QI "8")
835    (V32HI "16") (V16HI "16") (V8HI "16")
836    (V16SI "32") (V8SI "32") (V4SI "32")
837    (V16SF "32") (V8SF "32") (V4SF "32")
838    (V8DF "64") (V4DF "64") (V2DF "64")])
840 ;; SSE prefix for integer vector modes
841 (define_mode_attr sseintprefix
842   [(V2DI  "p") (V2DF  "")
843    (V4DI  "p") (V4DF  "")
844    (V8DI  "p") (V8DF  "")
845    (V4SI  "p") (V4SF  "")
846    (V8SI  "p") (V8SF  "")
847    (V16SI "p") (V16SF "")
848    (V16QI "p") (V8HI "p")
849    (V32QI "p") (V16HI "p")
850    (V64QI "p") (V32HI "p")])
852 ;; SSE scalar suffix for vector modes
853 (define_mode_attr ssescalarmodesuffix
854   [(SF "ss") (DF "sd")
855    (V16SF "ss") (V8DF "sd")
856    (V8SF "ss") (V4DF "sd")
857    (V4SF "ss") (V2DF "sd")
858    (V16SI "d") (V8DI "q")
859    (V8SI "d") (V4DI "q")
860    (V4SI "d") (V2DI "q")])
862 ;; Pack/unpack vector modes
863 (define_mode_attr sseunpackmode
864   [(V16QI "V8HI") (V8HI "V4SI") (V4SI "V2DI")
865    (V32QI "V16HI") (V16HI "V8SI") (V8SI "V4DI")
866    (V32HI "V16SI") (V64QI "V32HI") (V16SI "V8DI")])
868 (define_mode_attr ssepackmode
869   [(V8HI "V16QI") (V4SI "V8HI") (V2DI "V4SI")
870    (V16HI "V32QI") (V8SI "V16HI") (V4DI "V8SI")
871    (V32HI "V64QI") (V16SI "V32HI") (V8DI "V16SI")])
873 ;; Mapping of the max integer size for xop rotate immediate constraint
874 (define_mode_attr sserotatemax
875   [(V16QI "7") (V8HI "15") (V4SI "31") (V2DI "63")])
877 ;; Mapping of mode to cast intrinsic name
878 (define_mode_attr castmode
879  [(V8SI "si") (V8SF "ps") (V4DF "pd")
880   (V16SI "si") (V16SF "ps") (V8DF "pd")])
882 ;; Instruction suffix for sign and zero extensions.
883 (define_code_attr extsuffix [(sign_extend "sx") (zero_extend "zx")])
885 ;; i128 for integer vectors and TARGET_AVX2, f128 otherwise.
886 ;; i64x4 or f64x4 for 512bit modes.
887 (define_mode_attr i128
888   [(V16SF "f64x4") (V8SF "f128") (V8DF "f64x4") (V4DF "f128")
889    (V64QI "i64x4") (V32QI "%~128") (V32HI "i64x4") (V16HI "%~128")
890    (V16SI "i64x4") (V8SI "%~128") (V8DI "i64x4") (V4DI "%~128")])
892 ;; For 256-bit modes for TARGET_AVX512VL && TARGET_AVX512DQ
893 ;; i32x4, f32x4, i64x2 or f64x2 suffixes.
894 (define_mode_attr i128vldq
895   [(V8SF "f32x4") (V4DF "f64x2")
896    (V32QI "i32x4") (V16HI "i32x4") (V8SI "i32x4") (V4DI "i64x2")])
898 ;; Mix-n-match
899 (define_mode_iterator AVX256MODE2P [V8SI V8SF V4DF])
900 (define_mode_iterator AVX512MODE2P [V16SI V16SF V8DF])
902 ;; Mapping for dbpsabbw modes
903 (define_mode_attr dbpsadbwmode
904   [(V32HI "V64QI") (V16HI "V32QI") (V8HI "V16QI")])
906 ;; Mapping suffixes for broadcast
907 (define_mode_attr bcstscalarsuff
908   [(V64QI "b")  (V32QI "b") (V16QI "b")
909    (V32HI "w")  (V16HI "w") (V8HI "w")
910    (V16SI "d")  (V8SI "d")  (V4SI "d")
911    (V8DI "q")   (V4DI "q")  (V2DI "q")
912    (V16SF "ss") (V8SF "ss") (V4SF "ss")
913    (V8DF "sd")  (V4DF "sd") (V2DF "sd")])
915 ;; Tie mode of assembler operand to mode iterator
916 (define_mode_attr xtg_mode
917   [(V16QI "x") (V8HI "x") (V4SI "x") (V2DI "x") (V4SF "x") (V2DF "x")
918    (V32QI "t") (V16HI "t") (V8SI "t") (V4DI "t") (V8SF "t") (V4DF "t")
919    (V64QI "g") (V32HI "g") (V16SI "g") (V8DI "g") (V16SF "g") (V8DF "g")])
921 ;; Half mask mode for unpacks
922 (define_mode_attr HALFMASKMODE
923   [(DI "SI") (SI "HI")])
925 ;; Double mask mode for packs
926 (define_mode_attr DOUBLEMASKMODE
927   [(HI "SI") (SI "DI")])
930 ;; Include define_subst patterns for instructions with mask
931 (include "subst.md")
933 ;; Patterns whose name begins with "sse{,2,3}_" are invoked by intrinsics.
935 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
937 ;; Move patterns
939 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
941 ;; All of these patterns are enabled for SSE1 as well as SSE2.
942 ;; This is essential for maintaining stable calling conventions.
944 (define_expand "mov<mode>"
945   [(set (match_operand:VMOVE 0 "nonimmediate_operand")
946         (match_operand:VMOVE 1 "nonimmediate_operand"))]
947   "TARGET_SSE"
949   ix86_expand_vector_move (<MODE>mode, operands);
950   DONE;
953 (define_insn "mov<mode>_internal"
954   [(set (match_operand:VMOVE 0 "nonimmediate_operand"
955          "=v,v ,v ,m")
956         (match_operand:VMOVE 1 "nonimmediate_or_sse_const_operand"
957          " C,BC,vm,v"))]
958   "TARGET_SSE
959    && (register_operand (operands[0], <MODE>mode)
960        || register_operand (operands[1], <MODE>mode))"
962   switch (get_attr_type (insn))
963     {
964     case TYPE_SSELOG1:
965       return standard_sse_constant_opcode (insn, operands);
967     case TYPE_SSEMOV:
968       /* There is no evex-encoded vmov* for sizes smaller than 64-bytes
969          in avx512f, so we need to use workarounds, to access sse registers
970          16-31, which are evex-only. In avx512vl we don't need workarounds.  */
971       if (TARGET_AVX512F && <MODE_SIZE> < 64 && !TARGET_AVX512VL
972           && (EXT_REX_SSE_REG_P (operands[0])
973               || EXT_REX_SSE_REG_P (operands[1])))
974         {
975           if (memory_operand (operands[0], <MODE>mode))
976             {
977               if (<MODE_SIZE> == 32)
978                 return "vextract<shuffletype>64x4\t{$0x0, %g1, %0|%0, %g1, 0x0}";
979               else if (<MODE_SIZE> == 16)
980                 return "vextract<shuffletype>32x4\t{$0x0, %g1, %0|%0, %g1, 0x0}";
981               else
982                 gcc_unreachable ();
983             }
984           else if (memory_operand (operands[1], <MODE>mode))
985             {
986               if (<MODE_SIZE> == 32)
987                 return "vbroadcast<shuffletype>64x4\t{%1, %g0|%g0, %1}";
988               else if (<MODE_SIZE> == 16)
989                 return "vbroadcast<shuffletype>32x4\t{%1, %g0|%g0, %1}";
990               else
991                 gcc_unreachable ();
992             }
993           else
994             /* Reg -> reg move is always aligned.  Just use wider move.  */
995             switch (get_attr_mode (insn))
996               {
997               case MODE_V8SF:
998               case MODE_V4SF:
999                 return "vmovaps\t{%g1, %g0|%g0, %g1}";
1000               case MODE_V4DF:
1001               case MODE_V2DF:
1002                 return "vmovapd\t{%g1, %g0|%g0, %g1}";
1003               case MODE_OI:
1004               case MODE_TI:
1005                 return "vmovdqa64\t{%g1, %g0|%g0, %g1}";
1006               default:
1007                 gcc_unreachable ();
1008               }
1009         }
1011       switch (get_attr_mode (insn))
1012         {
1013         case MODE_V16SF:
1014         case MODE_V8SF:
1015         case MODE_V4SF:
1016           if (misaligned_operand (operands[0], <MODE>mode)
1017               || misaligned_operand (operands[1], <MODE>mode))
1018             return "%vmovups\t{%1, %0|%0, %1}";
1019           else
1020             return "%vmovaps\t{%1, %0|%0, %1}";
1022         case MODE_V8DF:
1023         case MODE_V4DF:
1024         case MODE_V2DF:
1025           if (misaligned_operand (operands[0], <MODE>mode)
1026               || misaligned_operand (operands[1], <MODE>mode))
1027             return "%vmovupd\t{%1, %0|%0, %1}";
1028           else
1029             return "%vmovapd\t{%1, %0|%0, %1}";
1031         case MODE_OI:
1032         case MODE_TI:
1033           if (misaligned_operand (operands[0], <MODE>mode)
1034               || misaligned_operand (operands[1], <MODE>mode))
1035             return TARGET_AVX512VL
1036                    && (<MODE>mode == V4SImode
1037                        || <MODE>mode == V2DImode
1038                        || <MODE>mode == V8SImode
1039                        || <MODE>mode == V4DImode
1040                        || TARGET_AVX512BW)
1041                    ? "vmovdqu<ssescalarsize>\t{%1, %0|%0, %1}"
1042                    : "%vmovdqu\t{%1, %0|%0, %1}";
1043           else
1044             return TARGET_AVX512VL ? "vmovdqa64\t{%1, %0|%0, %1}"
1045                                    : "%vmovdqa\t{%1, %0|%0, %1}";
1046         case MODE_XI:
1047           if (misaligned_operand (operands[0], <MODE>mode)
1048               || misaligned_operand (operands[1], <MODE>mode))
1049             return (<MODE>mode == V16SImode
1050                     || <MODE>mode == V8DImode
1051                     || TARGET_AVX512BW)
1052                    ? "vmovdqu<ssescalarsize>\t{%1, %0|%0, %1}"
1053                    : "vmovdqu64\t{%1, %0|%0, %1}";
1054           else
1055             return "vmovdqa64\t{%1, %0|%0, %1}";
1057         default:
1058           gcc_unreachable ();
1059         }
1061     default:
1062       gcc_unreachable ();
1063     }
1065   [(set_attr "type" "sselog1,sselog1,ssemov,ssemov")
1066    (set_attr "prefix" "maybe_vex")
1067    (set (attr "mode")
1068         (cond [(and (eq_attr "alternative" "1")
1069                     (match_test "TARGET_AVX512VL"))
1070                  (const_string "<sseinsnmode>")
1071                (and (match_test "<MODE_SIZE> == 16")
1072                     (ior (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
1073                          (and (eq_attr "alternative" "3")
1074                               (match_test "TARGET_SSE_TYPELESS_STORES"))))
1075                  (const_string "<ssePSmode>")
1076                (match_test "TARGET_AVX")
1077                  (const_string "<sseinsnmode>")
1078                (ior (not (match_test "TARGET_SSE2"))
1079                     (match_test "optimize_function_for_size_p (cfun)"))
1080                  (const_string "V4SF")
1081                (and (eq_attr "alternative" "0")
1082                     (match_test "TARGET_SSE_LOAD0_BY_PXOR"))
1083                  (const_string "TI")
1084               ]
1085               (const_string "<sseinsnmode>")))
1086    (set (attr "enabled")
1087         (cond [(and (match_test "<MODE_SIZE> == 16")
1088                     (eq_attr "alternative" "1"))
1089                  (symbol_ref "TARGET_SSE2")
1090                (and (match_test "<MODE_SIZE> == 32")
1091                     (eq_attr "alternative" "1"))
1092                  (symbol_ref "TARGET_AVX2")
1093               ]
1094               (symbol_ref "true")))])
1096 (define_insn "<avx512>_load<mode>_mask"
1097   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v,v")
1098         (vec_merge:V48_AVX512VL
1099           (match_operand:V48_AVX512VL 1 "nonimmediate_operand" "v,m")
1100           (match_operand:V48_AVX512VL 2 "vector_move_operand" "0C,0C")
1101           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
1102   "TARGET_AVX512F"
1104   if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
1105     {
1106       if (misaligned_operand (operands[1], <MODE>mode))
1107         return "vmovu<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1108       else
1109         return "vmova<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1110     }
1111   else
1112     {
1113       if (misaligned_operand (operands[1], <MODE>mode))
1114         return "vmovdqu<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1115       else
1116         return "vmovdqa<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1117     }
1119   [(set_attr "type" "ssemov")
1120    (set_attr "prefix" "evex")
1121    (set_attr "memory" "none,load")
1122    (set_attr "mode" "<sseinsnmode>")])
1124 (define_insn "<avx512>_load<mode>_mask"
1125   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v,v")
1126         (vec_merge:VI12_AVX512VL
1127           (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "v,m")
1128           (match_operand:VI12_AVX512VL 2 "vector_move_operand" "0C,0C")
1129           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
1130   "TARGET_AVX512BW"
1131   "vmovdqu<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
1132   [(set_attr "type" "ssemov")
1133    (set_attr "prefix" "evex")
1134    (set_attr "memory" "none,load")
1135    (set_attr "mode" "<sseinsnmode>")])
1137 (define_insn "<avx512>_blendm<mode>"
1138   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v")
1139         (vec_merge:V48_AVX512VL
1140           (match_operand:V48_AVX512VL 2 "nonimmediate_operand" "vm")
1141           (match_operand:V48_AVX512VL 1 "register_operand" "v")
1142           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
1143   "TARGET_AVX512F"
1144   "v<sseintprefix>blendm<ssemodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}"
1145   [(set_attr "type" "ssemov")
1146    (set_attr "prefix" "evex")
1147    (set_attr "mode" "<sseinsnmode>")])
1149 (define_insn "<avx512>_blendm<mode>"
1150   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
1151         (vec_merge:VI12_AVX512VL
1152           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
1153           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
1154           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
1155   "TARGET_AVX512BW"
1156   "vpblendm<ssemodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}"
1157   [(set_attr "type" "ssemov")
1158    (set_attr "prefix" "evex")
1159    (set_attr "mode" "<sseinsnmode>")])
1161 (define_insn "<avx512>_store<mode>_mask"
1162   [(set (match_operand:V48_AVX512VL 0 "memory_operand" "=m")
1163         (vec_merge:V48_AVX512VL
1164           (match_operand:V48_AVX512VL 1 "register_operand" "v")
1165           (match_dup 0)
1166           (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1167   "TARGET_AVX512F"
1169   if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
1170     {
1171       if (misaligned_operand (operands[0], <MODE>mode))
1172         return "vmovu<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1173       else
1174         return "vmova<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1175     }
1176   else
1177     {
1178       if (misaligned_operand (operands[0], <MODE>mode))
1179         return "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1180       else
1181         return "vmovdqa<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1182     }
1184   [(set_attr "type" "ssemov")
1185    (set_attr "prefix" "evex")
1186    (set_attr "memory" "store")
1187    (set_attr "mode" "<sseinsnmode>")])
1189 (define_insn "<avx512>_store<mode>_mask"
1190   [(set (match_operand:VI12_AVX512VL 0 "memory_operand" "=m")
1191         (vec_merge:VI12_AVX512VL
1192           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
1193           (match_dup 0)
1194           (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1195   "TARGET_AVX512BW"
1196   "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
1197   [(set_attr "type" "ssemov")
1198    (set_attr "prefix" "evex")
1199    (set_attr "memory" "store")
1200    (set_attr "mode" "<sseinsnmode>")])
1202 (define_insn "sse2_movq128"
1203   [(set (match_operand:V2DI 0 "register_operand" "=v")
1204         (vec_concat:V2DI
1205           (vec_select:DI
1206             (match_operand:V2DI 1 "nonimmediate_operand" "vm")
1207             (parallel [(const_int 0)]))
1208           (const_int 0)))]
1209   "TARGET_SSE2"
1210   "%vmovq\t{%1, %0|%0, %q1}"
1211   [(set_attr "type" "ssemov")
1212    (set_attr "prefix" "maybe_vex")
1213    (set_attr "mode" "TI")])
1215 ;; Move a DI from a 32-bit register pair (e.g. %edx:%eax) to an xmm.
1216 ;; We'd rather avoid this entirely; if the 32-bit reg pair was loaded
1217 ;; from memory, we'd prefer to load the memory directly into the %xmm
1218 ;; register.  To facilitate this happy circumstance, this pattern won't
1219 ;; split until after register allocation.  If the 64-bit value didn't
1220 ;; come from memory, this is the best we can do.  This is much better
1221 ;; than storing %edx:%eax into a stack temporary and loading an %xmm
1222 ;; from there.
1224 (define_insn_and_split "movdi_to_sse"
1225   [(parallel
1226     [(set (match_operand:V4SI 0 "register_operand" "=?x,x")
1227           (subreg:V4SI (match_operand:DI 1 "nonimmediate_operand" "r,m") 0))
1228      (clobber (match_scratch:V4SI 2 "=&x,X"))])]
1229   "!TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_TO_VEC"
1230   "#"
1231   "&& reload_completed"
1232   [(const_int 0)]
1234  if (register_operand (operands[1], DImode))
1235    {
1236       /* The DImode arrived in a pair of integral registers (e.g. %edx:%eax).
1237          Assemble the 64-bit DImode value in an xmm register.  */
1238       emit_insn (gen_sse2_loadld (operands[0], CONST0_RTX (V4SImode),
1239                                   gen_lowpart (SImode, operands[1])));
1240       emit_insn (gen_sse2_loadld (operands[2], CONST0_RTX (V4SImode),
1241                                   gen_highpart (SImode, operands[1])));
1242       emit_insn (gen_vec_interleave_lowv4si (operands[0], operands[0],
1243                                              operands[2]));
1244    }
1245  else if (memory_operand (operands[1], DImode))
1246    emit_insn (gen_vec_concatv2di (gen_lowpart (V2DImode, operands[0]),
1247                                   operands[1], const0_rtx));
1248  else
1249    gcc_unreachable ();
1250  DONE;
1253 (define_split
1254   [(set (match_operand:V4SF 0 "register_operand")
1255         (match_operand:V4SF 1 "zero_extended_scalar_load_operand"))]
1256   "TARGET_SSE && reload_completed"
1257   [(set (match_dup 0)
1258         (vec_merge:V4SF
1259           (vec_duplicate:V4SF (match_dup 1))
1260           (match_dup 2)
1261           (const_int 1)))]
1263   operands[1] = gen_lowpart (SFmode, operands[1]);
1264   operands[2] = CONST0_RTX (V4SFmode);
1267 (define_split
1268   [(set (match_operand:V2DF 0 "register_operand")
1269         (match_operand:V2DF 1 "zero_extended_scalar_load_operand"))]
1270   "TARGET_SSE2 && reload_completed"
1271   [(set (match_dup 0) (vec_concat:V2DF (match_dup 1) (match_dup 2)))]
1273   operands[1] = gen_lowpart (DFmode, operands[1]);
1274   operands[2] = CONST0_RTX (DFmode);
1277 (define_expand "movmisalign<mode>"
1278   [(set (match_operand:VMOVE 0 "nonimmediate_operand")
1279         (match_operand:VMOVE 1 "nonimmediate_operand"))]
1280   "TARGET_SSE"
1282   ix86_expand_vector_move_misalign (<MODE>mode, operands);
1283   DONE;
1286 ;; Merge movsd/movhpd to movupd for TARGET_SSE_UNALIGNED_LOAD_OPTIMAL targets.
1287 (define_peephole2
1288   [(set (match_operand:V2DF 0 "sse_reg_operand")
1289         (vec_concat:V2DF (match_operand:DF 1 "memory_operand")
1290                          (match_operand:DF 4 "const0_operand")))
1291    (set (match_operand:V2DF 2 "sse_reg_operand")
1292         (vec_concat:V2DF (vec_select:DF (match_dup 2)
1293                                         (parallel [(const_int 0)]))
1294                          (match_operand:DF 3 "memory_operand")))]
1295   "TARGET_SSE2 && TARGET_SSE_UNALIGNED_LOAD_OPTIMAL
1296    && ix86_operands_ok_for_move_multiple (operands, true, DFmode)"
1297   [(set (match_dup 2) (match_dup 5))]
1298   "operands[5] = adjust_address (operands[1], V2DFmode, 0);")
1300 (define_peephole2
1301   [(set (match_operand:DF 0 "sse_reg_operand")
1302         (match_operand:DF 1 "memory_operand"))
1303    (set (match_operand:V2DF 2 "sse_reg_operand")
1304         (vec_concat:V2DF (match_operand:DF 4 "sse_reg_operand")
1305                          (match_operand:DF 3 "memory_operand")))]
1306   "TARGET_SSE2 && TARGET_SSE_UNALIGNED_LOAD_OPTIMAL
1307    && REGNO (operands[4]) == REGNO (operands[2])
1308    && ix86_operands_ok_for_move_multiple (operands, true, DFmode)"
1309   [(set (match_dup 2) (match_dup 5))]
1310   "operands[5] = adjust_address (operands[1], V2DFmode, 0);")
1312 ;; Merge movlpd/movhpd to movupd for TARGET_SSE_UNALIGNED_STORE_OPTIMAL targets.
1313 (define_peephole2
1314   [(set (match_operand:DF 0 "memory_operand")
1315         (vec_select:DF (match_operand:V2DF 1 "sse_reg_operand")
1316                        (parallel [(const_int 0)])))
1317    (set (match_operand:DF 2 "memory_operand")
1318         (vec_select:DF (match_operand:V2DF 3 "sse_reg_operand")
1319                        (parallel [(const_int 1)])))]
1320   "TARGET_SSE2 && TARGET_SSE_UNALIGNED_STORE_OPTIMAL
1321    && ix86_operands_ok_for_move_multiple (operands, false, DFmode)"
1322   [(set (match_dup 4) (match_dup 1))]
1323   "operands[4] = adjust_address (operands[0], V2DFmode, 0);")
1325 (define_insn "<sse3>_lddqu<avxsizesuffix>"
1326   [(set (match_operand:VI1 0 "register_operand" "=x")
1327         (unspec:VI1 [(match_operand:VI1 1 "memory_operand" "m")]
1328                     UNSPEC_LDDQU))]
1329   "TARGET_SSE3"
1330   "%vlddqu\t{%1, %0|%0, %1}"
1331   [(set_attr "type" "ssemov")
1332    (set_attr "movu" "1")
1333    (set (attr "prefix_data16")
1334      (if_then_else
1335        (match_test "TARGET_AVX")
1336      (const_string "*")
1337      (const_string "0")))
1338    (set (attr "prefix_rep")
1339      (if_then_else
1340        (match_test "TARGET_AVX")
1341      (const_string "*")
1342      (const_string "1")))
1343    (set_attr "prefix" "maybe_vex")
1344    (set_attr "mode" "<sseinsnmode>")])
1346 (define_insn "sse2_movnti<mode>"
1347   [(set (match_operand:SWI48 0 "memory_operand" "=m")
1348         (unspec:SWI48 [(match_operand:SWI48 1 "register_operand" "r")]
1349                       UNSPEC_MOVNT))]
1350   "TARGET_SSE2"
1351   "movnti\t{%1, %0|%0, %1}"
1352   [(set_attr "type" "ssemov")
1353    (set_attr "prefix_data16" "0")
1354    (set_attr "mode" "<MODE>")])
1356 (define_insn "<sse>_movnt<mode>"
1357   [(set (match_operand:VF 0 "memory_operand" "=m")
1358         (unspec:VF
1359           [(match_operand:VF 1 "register_operand" "v")]
1360           UNSPEC_MOVNT))]
1361   "TARGET_SSE"
1362   "%vmovnt<ssemodesuffix>\t{%1, %0|%0, %1}"
1363   [(set_attr "type" "ssemov")
1364    (set_attr "prefix" "maybe_vex")
1365    (set_attr "mode" "<MODE>")])
1367 (define_insn "<sse2>_movnt<mode>"
1368   [(set (match_operand:VI8 0 "memory_operand" "=m")
1369         (unspec:VI8 [(match_operand:VI8 1 "register_operand" "v")]
1370                     UNSPEC_MOVNT))]
1371   "TARGET_SSE2"
1372   "%vmovntdq\t{%1, %0|%0, %1}"
1373   [(set_attr "type" "ssecvt")
1374    (set (attr "prefix_data16")
1375      (if_then_else
1376        (match_test "TARGET_AVX")
1377      (const_string "*")
1378      (const_string "1")))
1379    (set_attr "prefix" "maybe_vex")
1380    (set_attr "mode" "<sseinsnmode>")])
1382 ; Expand patterns for non-temporal stores.  At the moment, only those
1383 ; that directly map to insns are defined; it would be possible to
1384 ; define patterns for other modes that would expand to several insns.
1386 ;; Modes handled by storent patterns.
1387 (define_mode_iterator STORENT_MODE
1388   [(DI "TARGET_SSE2 && TARGET_64BIT") (SI "TARGET_SSE2")
1389    (SF "TARGET_SSE4A") (DF "TARGET_SSE4A")
1390    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") (V2DI "TARGET_SSE2")
1391    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
1392    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
1394 (define_expand "storent<mode>"
1395   [(set (match_operand:STORENT_MODE 0 "memory_operand")
1396         (unspec:STORENT_MODE
1397           [(match_operand:STORENT_MODE 1 "register_operand")]
1398           UNSPEC_MOVNT))]
1399   "TARGET_SSE")
1401 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1403 ;; Mask operations
1405 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1407 ;; All integer modes with AVX512BW/DQ.
1408 (define_mode_iterator SWI1248_AVX512BWDQ
1409   [(QI "TARGET_AVX512DQ") HI (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW")])
1411 ;; All integer modes with AVX512BW, where HImode operation
1412 ;; can be used instead of QImode.
1413 (define_mode_iterator SWI1248_AVX512BW
1414   [QI HI (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW")])
1416 ;; All integer modes with AVX512BW/DQ, even HImode requires DQ.
1417 (define_mode_iterator SWI1248_AVX512BWDQ2
1418   [(QI "TARGET_AVX512DQ") (HI "TARGET_AVX512DQ")
1419    (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW")])
1421 (define_expand "kmov<mskmodesuffix>"
1422   [(set (match_operand:SWI1248_AVX512BWDQ 0 "nonimmediate_operand")
1423         (match_operand:SWI1248_AVX512BWDQ 1 "nonimmediate_operand"))]
1424   "TARGET_AVX512F
1425    && !(MEM_P (operands[0]) && MEM_P (operands[1]))")
1427 (define_insn "k<code><mode>"
1428   [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
1429         (any_logic:SWI1248_AVX512BW
1430           (match_operand:SWI1248_AVX512BW 1 "register_operand" "k")
1431           (match_operand:SWI1248_AVX512BW 2 "register_operand" "k")))
1432    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1433   "TARGET_AVX512F"
1435   if (get_attr_mode (insn) == MODE_HI)
1436     return "k<logic>w\t{%2, %1, %0|%0, %1, %2}";
1437   else
1438     return "k<logic><mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
1440   [(set_attr "type" "msklog")
1441    (set_attr "prefix" "vex")
1442    (set (attr "mode")
1443      (cond [(and (match_test "<MODE>mode == QImode")
1444                  (not (match_test "TARGET_AVX512DQ")))
1445                (const_string "HI")
1446            ]
1447            (const_string "<MODE>")))])
1449 (define_insn "kandn<mode>"
1450   [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
1451         (and:SWI1248_AVX512BW
1452           (not:SWI1248_AVX512BW
1453             (match_operand:SWI1248_AVX512BW 1 "register_operand" "k"))
1454           (match_operand:SWI1248_AVX512BW 2 "register_operand" "k")))
1455    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1456   "TARGET_AVX512F"
1458   if (get_attr_mode (insn) == MODE_HI)
1459     return "kandnw\t{%2, %1, %0|%0, %1, %2}";
1460   else
1461     return "kandn<mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
1463   [(set_attr "type" "msklog")
1464    (set_attr "prefix" "vex")
1465    (set (attr "mode")
1466      (cond [(and (match_test "<MODE>mode == QImode")
1467                  (not (match_test "TARGET_AVX512DQ")))
1468               (const_string "HI")
1469            ]
1470            (const_string "<MODE>")))])
1472 (define_insn "kxnor<mode>"
1473   [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
1474         (not:SWI1248_AVX512BW
1475           (xor:SWI1248_AVX512BW
1476             (match_operand:SWI1248_AVX512BW 1 "register_operand" "k")
1477             (match_operand:SWI1248_AVX512BW 2 "register_operand" "k"))))
1478    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1479   "TARGET_AVX512F"
1481   if (get_attr_mode (insn) == MODE_HI)
1482     return "kxnorw\t{%2, %1, %0|%0, %1, %2}";
1483   else
1484     return "kxnor<mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
1486   [(set_attr "type" "msklog")
1487    (set_attr "prefix" "vex")
1488    (set (attr "mode")
1489      (cond [(and (match_test "<MODE>mode == QImode")
1490                  (not (match_test "TARGET_AVX512DQ")))
1491               (const_string "HI")
1492            ]
1493            (const_string "<MODE>")))])
1495 (define_insn "knot<mode>"
1496   [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
1497         (not:SWI1248_AVX512BW
1498           (match_operand:SWI1248_AVX512BW 1 "register_operand" "k")))
1499    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1500   "TARGET_AVX512F"
1502   if (get_attr_mode (insn) == MODE_HI)
1503     return "knotw\t{%1, %0|%0, %1}";
1504   else
1505     return "knot<mskmodesuffix>\t{%1, %0|%0, %1}";
1507   [(set_attr "type" "msklog")
1508    (set_attr "prefix" "vex")
1509    (set (attr "mode")
1510      (cond [(and (match_test "<MODE>mode == QImode")
1511                  (not (match_test "TARGET_AVX512DQ")))
1512                (const_string "HI")
1513            ]
1514            (const_string "<MODE>")))])
1516 (define_insn "kadd<mode>"
1517   [(set (match_operand:SWI1248_AVX512BWDQ2 0 "register_operand" "=k")
1518         (plus:SWI1248_AVX512BWDQ2
1519           (match_operand:SWI1248_AVX512BWDQ2 1 "register_operand" "k")
1520           (match_operand:SWI1248_AVX512BWDQ2 2 "register_operand" "k")))
1521    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1522   "TARGET_AVX512F"
1523   "kadd<mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}"
1524   [(set_attr "type" "msklog")
1525    (set_attr "prefix" "vex")
1526    (set_attr "mode" "<MODE>")])
1528 ;; Mask variant shift mnemonics
1529 (define_code_attr mshift [(ashift "shiftl") (lshiftrt "shiftr")])
1531 (define_insn "k<code><mode>"
1532   [(set (match_operand:SWI1248_AVX512BWDQ 0 "register_operand" "=k")
1533         (any_lshift:SWI1248_AVX512BWDQ
1534           (match_operand:SWI1248_AVX512BWDQ 1 "register_operand" "k")
1535           (match_operand:QI 2 "immediate_operand" "n")))
1536    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1537   "TARGET_AVX512F"
1538   "k<mshift><mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}"
1539   [(set_attr "type" "msklog")
1540    (set_attr "prefix" "vex")
1541    (set_attr "mode" "<MODE>")])
1543 (define_insn "ktest<mode>"
1544   [(set (reg:CC FLAGS_REG)
1545         (unspec:CC
1546           [(match_operand:SWI1248_AVX512BWDQ2 0 "register_operand" "k")
1547            (match_operand:SWI1248_AVX512BWDQ2 1 "register_operand" "k")]
1548           UNSPEC_KTEST))]
1549   "TARGET_AVX512F"
1550   "ktest<mskmodesuffix>\t{%1, %0|%0, %1}"
1551   [(set_attr "mode" "<MODE>")
1552    (set_attr "type" "msklog")
1553    (set_attr "prefix" "vex")])
1555 (define_insn "kortest<mode>"
1556   [(set (reg:CC FLAGS_REG)
1557         (unspec:CC
1558           [(match_operand:SWI1248_AVX512BWDQ 0 "register_operand" "k")
1559            (match_operand:SWI1248_AVX512BWDQ 1 "register_operand" "k")]
1560           UNSPEC_KORTEST))]
1561   "TARGET_AVX512F"
1562   "kortest<mskmodesuffix>\t{%1, %0|%0, %1}"
1563   [(set_attr "mode" "<MODE>")
1564    (set_attr "type" "msklog")
1565    (set_attr "prefix" "vex")])
1567 (define_insn "kunpckhi"
1568   [(set (match_operand:HI 0 "register_operand" "=k")
1569         (ior:HI
1570           (ashift:HI
1571             (zero_extend:HI (match_operand:QI 1 "register_operand" "k"))
1572             (const_int 8))
1573           (zero_extend:HI (match_operand:QI 2 "register_operand" "k"))))]
1574   "TARGET_AVX512F"
1575   "kunpckbw\t{%2, %1, %0|%0, %1, %2}"
1576   [(set_attr "mode" "HI")
1577    (set_attr "type" "msklog")
1578    (set_attr "prefix" "vex")])
1580 (define_insn "kunpcksi"
1581   [(set (match_operand:SI 0 "register_operand" "=k")
1582         (ior:SI
1583           (ashift:SI
1584             (zero_extend:SI (match_operand:HI 1 "register_operand" "k"))
1585             (const_int 16))
1586           (zero_extend:SI (match_operand:HI 2 "register_operand" "k"))))]
1587   "TARGET_AVX512BW"
1588   "kunpckwd\t{%2, %1, %0|%0, %1, %2}"
1589   [(set_attr "mode" "SI")])
1591 (define_insn "kunpckdi"
1592   [(set (match_operand:DI 0 "register_operand" "=k")
1593         (ior:DI
1594           (ashift:DI
1595             (zero_extend:DI (match_operand:SI 1 "register_operand" "k"))
1596             (const_int 32))
1597           (zero_extend:DI (match_operand:SI 2 "register_operand" "k"))))]
1598   "TARGET_AVX512BW"
1599   "kunpckdq\t{%2, %1, %0|%0, %1, %2}"
1600   [(set_attr "mode" "DI")])
1603 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1605 ;; Parallel floating point arithmetic
1607 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1609 (define_expand "<code><mode>2"
1610   [(set (match_operand:VF 0 "register_operand")
1611         (absneg:VF
1612           (match_operand:VF 1 "register_operand")))]
1613   "TARGET_SSE"
1614   "ix86_expand_fp_absneg_operator (<CODE>, <MODE>mode, operands); DONE;")
1616 (define_insn_and_split "*absneg<mode>2"
1617   [(set (match_operand:VF 0 "register_operand" "=x,x,v,v")
1618         (match_operator:VF 3 "absneg_operator"
1619           [(match_operand:VF 1 "vector_operand" "0,  xBm,v, m")]))
1620    (use (match_operand:VF 2 "vector_operand"    "xBm,0,  vm,v"))]
1621   "TARGET_SSE"
1622   "#"
1623   "&& reload_completed"
1624   [(const_int 0)]
1626   enum rtx_code absneg_op;
1627   rtx op1, op2;
1628   rtx t;
1630   if (TARGET_AVX)
1631     {
1632       if (MEM_P (operands[1]))
1633         op1 = operands[2], op2 = operands[1];
1634       else
1635         op1 = operands[1], op2 = operands[2];
1636     }
1637   else
1638     {
1639       op1 = operands[0];
1640       if (rtx_equal_p (operands[0], operands[1]))
1641         op2 = operands[2];
1642       else
1643         op2 = operands[1];
1644     }
1646   absneg_op = GET_CODE (operands[3]) == NEG ? XOR : AND;
1647   t = gen_rtx_fmt_ee (absneg_op, <MODE>mode, op1, op2);
1648   t = gen_rtx_SET (operands[0], t);
1649   emit_insn (t);
1650   DONE;
1652   [(set_attr "isa" "noavx,noavx,avx,avx")])
1654 (define_expand "<plusminus_insn><mode>3<mask_name><round_name>"
1655   [(set (match_operand:VF 0 "register_operand")
1656         (plusminus:VF
1657           (match_operand:VF 1 "<round_nimm_predicate>")
1658           (match_operand:VF 2 "<round_nimm_predicate>")))]
1659   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1660   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
1662 (define_insn "*<plusminus_insn><mode>3<mask_name><round_name>"
1663   [(set (match_operand:VF 0 "register_operand" "=x,v")
1664         (plusminus:VF
1665           (match_operand:VF 1 "<round_nimm_predicate>" "<comm>0,v")
1666           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1667   "TARGET_SSE && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)
1668    && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1669   "@
1670    <plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
1671    v<plusminus_mnemonic><ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1672   [(set_attr "isa" "noavx,avx")
1673    (set_attr "type" "sseadd")
1674    (set_attr "prefix" "<mask_prefix3>")
1675    (set_attr "mode" "<MODE>")])
1677 (define_insn "<sse>_vm<plusminus_insn><mode>3<mask_scalar_name><round_scalar_name>"
1678   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1679         (vec_merge:VF_128
1680           (plusminus:VF_128
1681             (match_operand:VF_128 1 "register_operand" "0,v")
1682             (match_operand:VF_128 2 "vector_operand" "xBm,<round_scalar_constraint>"))
1683           (match_dup 1)
1684           (const_int 1)))]
1685   "TARGET_SSE"
1686   "@
1687    <plusminus_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
1688    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>}"
1689   [(set_attr "isa" "noavx,avx")
1690    (set_attr "type" "sseadd")
1691    (set_attr "prefix" "<round_scalar_prefix>")
1692    (set_attr "mode" "<ssescalarmode>")])
1694 (define_expand "mul<mode>3<mask_name><round_name>"
1695   [(set (match_operand:VF 0 "register_operand")
1696         (mult:VF
1697           (match_operand:VF 1 "<round_nimm_predicate>")
1698           (match_operand:VF 2 "<round_nimm_predicate>")))]
1699   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1700   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
1702 (define_insn "*mul<mode>3<mask_name><round_name>"
1703   [(set (match_operand:VF 0 "register_operand" "=x,v")
1704         (mult:VF
1705           (match_operand:VF 1 "<round_nimm_predicate>" "%0,v")
1706           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1707   "TARGET_SSE
1708    && !(MEM_P (operands[1]) && MEM_P (operands[2]))
1709    && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1710   "@
1711    mul<ssemodesuffix>\t{%2, %0|%0, %2}
1712    vmul<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1713   [(set_attr "isa" "noavx,avx")
1714    (set_attr "type" "ssemul")
1715    (set_attr "prefix" "<mask_prefix3>")
1716    (set_attr "btver2_decode" "direct,double")
1717    (set_attr "mode" "<MODE>")])
1719 (define_insn "<sse>_vm<multdiv_mnemonic><mode>3<mask_scalar_name><round_scalar_name>"
1720   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1721         (vec_merge:VF_128
1722           (multdiv:VF_128
1723             (match_operand:VF_128 1 "register_operand" "0,v")
1724             (match_operand:VF_128 2 "vector_operand" "xBm,<round_scalar_constraint>"))
1725           (match_dup 1)
1726           (const_int 1)))]
1727   "TARGET_SSE"
1728   "@
1729    <multdiv_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
1730    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>}"
1731   [(set_attr "isa" "noavx,avx")
1732    (set_attr "type" "sse<multdiv_mnemonic>")
1733    (set_attr "prefix" "<round_scalar_prefix>")
1734    (set_attr "btver2_decode" "direct,double")
1735    (set_attr "mode" "<ssescalarmode>")])
1737 (define_expand "div<mode>3"
1738   [(set (match_operand:VF2 0 "register_operand")
1739         (div:VF2 (match_operand:VF2 1 "register_operand")
1740                  (match_operand:VF2 2 "vector_operand")))]
1741   "TARGET_SSE2"
1742   "ix86_fixup_binary_operands_no_copy (DIV, <MODE>mode, operands);")
1744 (define_expand "div<mode>3"
1745   [(set (match_operand:VF1 0 "register_operand")
1746         (div:VF1 (match_operand:VF1 1 "register_operand")
1747                  (match_operand:VF1 2 "vector_operand")))]
1748   "TARGET_SSE"
1750   ix86_fixup_binary_operands_no_copy (DIV, <MODE>mode, operands);
1752   if (TARGET_SSE_MATH
1753       && TARGET_RECIP_VEC_DIV
1754       && !optimize_insn_for_size_p ()
1755       && flag_finite_math_only && !flag_trapping_math
1756       && flag_unsafe_math_optimizations)
1757     {
1758       ix86_emit_swdivsf (operands[0], operands[1], operands[2], <MODE>mode);
1759       DONE;
1760     }
1763 (define_insn "<sse>_div<mode>3<mask_name><round_name>"
1764   [(set (match_operand:VF 0 "register_operand" "=x,v")
1765         (div:VF
1766           (match_operand:VF 1 "register_operand" "0,v")
1767           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1768   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1769   "@
1770    div<ssemodesuffix>\t{%2, %0|%0, %2}
1771    vdiv<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1772   [(set_attr "isa" "noavx,avx")
1773    (set_attr "type" "ssediv")
1774    (set_attr "prefix" "<mask_prefix3>")
1775    (set_attr "mode" "<MODE>")])
1777 (define_insn "<sse>_rcp<mode>2"
1778   [(set (match_operand:VF1_128_256 0 "register_operand" "=x")
1779         (unspec:VF1_128_256
1780           [(match_operand:VF1_128_256 1 "vector_operand" "xBm")] UNSPEC_RCP))]
1781   "TARGET_SSE"
1782   "%vrcpps\t{%1, %0|%0, %1}"
1783   [(set_attr "type" "sse")
1784    (set_attr "atom_sse_attr" "rcp")
1785    (set_attr "btver2_sse_attr" "rcp")
1786    (set_attr "prefix" "maybe_vex")
1787    (set_attr "mode" "<MODE>")])
1789 (define_insn "sse_vmrcpv4sf2"
1790   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
1791         (vec_merge:V4SF
1792           (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,xm")]
1793                        UNSPEC_RCP)
1794           (match_operand:V4SF 2 "register_operand" "0,x")
1795           (const_int 1)))]
1796   "TARGET_SSE"
1797   "@
1798    rcpss\t{%1, %0|%0, %k1}
1799    vrcpss\t{%1, %2, %0|%0, %2, %k1}"
1800   [(set_attr "isa" "noavx,avx")
1801    (set_attr "type" "sse")
1802    (set_attr "atom_sse_attr" "rcp")
1803    (set_attr "btver2_sse_attr" "rcp")
1804    (set_attr "prefix" "orig,vex")
1805    (set_attr "mode" "SF")])
1807 (define_insn "<mask_codefor>rcp14<mode><mask_name>"
1808   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
1809         (unspec:VF_AVX512VL
1810           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")]
1811           UNSPEC_RCP14))]
1812   "TARGET_AVX512F"
1813   "vrcp14<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
1814   [(set_attr "type" "sse")
1815    (set_attr "prefix" "evex")
1816    (set_attr "mode" "<MODE>")])
1818 (define_insn "srcp14<mode>"
1819   [(set (match_operand:VF_128 0 "register_operand" "=v")
1820         (vec_merge:VF_128
1821           (unspec:VF_128
1822             [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1823             UNSPEC_RCP14)
1824           (match_operand:VF_128 2 "register_operand" "v")
1825           (const_int 1)))]
1826   "TARGET_AVX512F"
1827   "vrcp14<ssescalarmodesuffix>\t{%1, %2, %0|%0, %2, %<iptr>1}"
1828   [(set_attr "type" "sse")
1829    (set_attr "prefix" "evex")
1830    (set_attr "mode" "<MODE>")])
1832 (define_insn "srcp14<mode>_mask"
1833   [(set (match_operand:VF_128 0 "register_operand" "=v")
1834         (vec_merge:VF_128
1835           (vec_merge:VF_128
1836             (unspec:VF_128
1837               [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1838             UNSPEC_RCP14)
1839               (match_operand:VF_128 3 "vector_move_operand" "0C")
1840             (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk"))
1841           (match_operand:VF_128 2 "register_operand" "v")
1842           (const_int 1)))]
1843   "TARGET_AVX512F"
1844   "vrcp14<ssescalarmodesuffix>\t{%1, %2, %0%{%4%}%N3|%0%{%4%}%N3, %2, %<iptr>1}"
1845   [(set_attr "type" "sse")
1846    (set_attr "prefix" "evex")
1847    (set_attr "mode" "<MODE>")])
1849 (define_expand "sqrt<mode>2"
1850   [(set (match_operand:VF2 0 "register_operand")
1851         (sqrt:VF2 (match_operand:VF2 1 "vector_operand")))]
1852   "TARGET_SSE2")
1854 (define_expand "sqrt<mode>2"
1855   [(set (match_operand:VF1 0 "register_operand")
1856         (sqrt:VF1 (match_operand:VF1 1 "vector_operand")))]
1857   "TARGET_SSE"
1859   if (TARGET_SSE_MATH
1860       && TARGET_RECIP_VEC_SQRT
1861       && !optimize_insn_for_size_p ()
1862       && flag_finite_math_only && !flag_trapping_math
1863       && flag_unsafe_math_optimizations)
1864     {
1865       ix86_emit_swsqrtsf (operands[0], operands[1], <MODE>mode, false);
1866       DONE;
1867     }
1870 (define_insn "<sse>_sqrt<mode>2<mask_name><round_name>"
1871   [(set (match_operand:VF 0 "register_operand" "=x,v")
1872         (sqrt:VF (match_operand:VF 1 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1873   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1874   "@
1875    sqrt<ssemodesuffix>\t{%1, %0|%0, %1}
1876    vsqrt<ssemodesuffix>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
1877   [(set_attr "isa" "noavx,avx")
1878    (set_attr "type" "sse")
1879    (set_attr "atom_sse_attr" "sqrt")
1880    (set_attr "btver2_sse_attr" "sqrt")
1881    (set_attr "prefix" "maybe_vex")
1882    (set_attr "mode" "<MODE>")])
1884 (define_insn "<sse>_vmsqrt<mode>2<mask_scalar_name><round_scalar_name>"
1885   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1886         (vec_merge:VF_128
1887           (sqrt:VF_128
1888             (match_operand:VF_128 1 "vector_operand" "xBm,<round_scalar_constraint>"))
1889           (match_operand:VF_128 2 "register_operand" "0,v")
1890           (const_int 1)))]
1891   "TARGET_SSE"
1892   "@
1893    sqrt<ssescalarmodesuffix>\t{%1, %0|%0, %<iptr>1}
1894    vsqrt<ssescalarmodesuffix>\t{<round_scalar_mask_op3>%1, %2, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %2, %<iptr>1<round_scalar_mask_op3>}"
1895   [(set_attr "isa" "noavx,avx")
1896    (set_attr "type" "sse")
1897    (set_attr "atom_sse_attr" "sqrt")
1898    (set_attr "prefix" "<round_scalar_prefix>")
1899    (set_attr "btver2_sse_attr" "sqrt")
1900    (set_attr "mode" "<ssescalarmode>")])
1902 (define_expand "rsqrt<mode>2"
1903   [(set (match_operand:VF1_128_256 0 "register_operand")
1904         (unspec:VF1_128_256
1905           [(match_operand:VF1_128_256 1 "vector_operand")] UNSPEC_RSQRT))]
1906   "TARGET_SSE_MATH"
1908   ix86_emit_swsqrtsf (operands[0], operands[1], <MODE>mode, true);
1909   DONE;
1912 (define_expand "rsqrtv16sf2"
1913   [(set (match_operand:V16SF 0 "register_operand")
1914         (unspec:V16SF
1915           [(match_operand:V16SF 1 "vector_operand")]
1916           UNSPEC_RSQRT28))]
1917   "TARGET_SSE_MATH && TARGET_AVX512ER"
1919   ix86_emit_swsqrtsf (operands[0], operands[1], V16SFmode, true);
1920   DONE;
1923 (define_insn "<sse>_rsqrt<mode>2"
1924   [(set (match_operand:VF1_128_256 0 "register_operand" "=x")
1925         (unspec:VF1_128_256
1926           [(match_operand:VF1_128_256 1 "vector_operand" "xBm")] UNSPEC_RSQRT))]
1927   "TARGET_SSE"
1928   "%vrsqrtps\t{%1, %0|%0, %1}"
1929   [(set_attr "type" "sse")
1930    (set_attr "prefix" "maybe_vex")
1931    (set_attr "mode" "<MODE>")])
1933 (define_insn "<mask_codefor>rsqrt14<mode><mask_name>"
1934   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
1935         (unspec:VF_AVX512VL
1936           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")]
1937           UNSPEC_RSQRT14))]
1938   "TARGET_AVX512F"
1939   "vrsqrt14<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
1940   [(set_attr "type" "sse")
1941    (set_attr "prefix" "evex")
1942    (set_attr "mode" "<MODE>")])
1944 (define_insn "rsqrt14<mode>"
1945   [(set (match_operand:VF_128 0 "register_operand" "=v")
1946         (vec_merge:VF_128
1947           (unspec:VF_128
1948             [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1949             UNSPEC_RSQRT14)
1950           (match_operand:VF_128 2 "register_operand" "v")
1951           (const_int 1)))]
1952   "TARGET_AVX512F"
1953   "vrsqrt14<ssescalarmodesuffix>\t{%1, %2, %0|%0, %2, %<iptr>1}"
1954   [(set_attr "type" "sse")
1955    (set_attr "prefix" "evex")
1956    (set_attr "mode" "<MODE>")])
1958 (define_insn "rsqrt14_<mode>_mask"
1959   [(set (match_operand:VF_128 0 "register_operand" "=v")
1960         (vec_merge:VF_128
1961           (vec_merge:VF_128
1962             (unspec:VF_128
1963               [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1964               UNSPEC_RSQRT14)
1965               (match_operand:VF_128 3 "vector_move_operand" "0C")
1966               (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk"))
1967           (match_operand:VF_128 2 "register_operand" "v")
1968           (const_int 1)))]
1969   "TARGET_AVX512F"
1970   "vrsqrt14<ssescalarmodesuffix>\t{%1, %2, %0%{%4%}%N3|%0%{%4%}%N3, %2, %<iptr>1}"
1971   [(set_attr "type" "sse")
1972    (set_attr "prefix" "evex")
1973    (set_attr "mode" "<MODE>")])
1975 (define_insn "sse_vmrsqrtv4sf2"
1976   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
1977         (vec_merge:V4SF
1978           (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,xm")]
1979                        UNSPEC_RSQRT)
1980           (match_operand:V4SF 2 "register_operand" "0,x")
1981           (const_int 1)))]
1982   "TARGET_SSE"
1983   "@
1984    rsqrtss\t{%1, %0|%0, %k1}
1985    vrsqrtss\t{%1, %2, %0|%0, %2, %k1}"
1986   [(set_attr "isa" "noavx,avx")
1987    (set_attr "type" "sse")
1988    (set_attr "prefix" "orig,vex")
1989    (set_attr "mode" "SF")])
1991 (define_expand "<code><mode>3<mask_name><round_saeonly_name>"
1992   [(set (match_operand:VF 0 "register_operand")
1993         (smaxmin:VF
1994           (match_operand:VF 1 "<round_saeonly_nimm_predicate>")
1995           (match_operand:VF 2 "<round_saeonly_nimm_predicate>")))]
1996   "TARGET_SSE && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
1998   if (!flag_finite_math_only || flag_signed_zeros)
1999     {
2000       operands[1] = force_reg (<MODE>mode, operands[1]);
2001       emit_insn (gen_ieee_<maxmin_float><mode>3<mask_name><round_saeonly_name>
2002                  (operands[0], operands[1], operands[2]
2003                   <mask_operand_arg34>
2004                   <round_saeonly_mask_arg3>));
2005       DONE;
2006     }
2007   else
2008     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
2011 ;; These versions of the min/max patterns are intentionally ignorant of
2012 ;; their behavior wrt -0.0 and NaN (via the commutative operand mark).
2013 ;; Since both the tree-level MAX_EXPR and the rtl-level SMAX operator
2014 ;; are undefined in this condition, we're certain this is correct.
2016 (define_insn "*<code><mode>3<mask_name><round_saeonly_name>"
2017   [(set (match_operand:VF 0 "register_operand" "=x,v")
2018         (smaxmin:VF
2019           (match_operand:VF 1 "<round_saeonly_nimm_predicate>" "%0,v")
2020           (match_operand:VF 2 "<round_saeonly_nimm_predicate>" "xBm,<round_saeonly_constraint>")))]
2021   "TARGET_SSE
2022    && !(MEM_P (operands[1]) && MEM_P (operands[2]))
2023    && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
2024   "@
2025    <maxmin_float><ssemodesuffix>\t{%2, %0|%0, %2}
2026    v<maxmin_float><ssemodesuffix>\t{<round_saeonly_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_saeonly_mask_op3>}"
2027   [(set_attr "isa" "noavx,avx")
2028    (set_attr "type" "sseadd")
2029    (set_attr "btver2_sse_attr" "maxmin")
2030    (set_attr "prefix" "<mask_prefix3>")
2031    (set_attr "mode" "<MODE>")])
2033 ;; These versions of the min/max patterns implement exactly the operations
2034 ;;   min = (op1 < op2 ? op1 : op2)
2035 ;;   max = (!(op1 < op2) ? op1 : op2)
2036 ;; Their operands are not commutative, and thus they may be used in the
2037 ;; presence of -0.0 and NaN.
2039 (define_insn "ieee_<ieee_maxmin><mode>3<mask_name><round_saeonly_name>"
2040   [(set (match_operand:VF 0 "register_operand" "=x,v")
2041         (unspec:VF
2042           [(match_operand:VF 1 "register_operand" "0,v")
2043            (match_operand:VF 2 "<round_saeonly_nimm_predicate>" "xBm,<round_saeonly_constraint>")]
2044           IEEE_MAXMIN))]
2045   "TARGET_SSE
2046    && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
2047   "@
2048    <ieee_maxmin><ssemodesuffix>\t{%2, %0|%0, %2}
2049    v<ieee_maxmin><ssemodesuffix>\t{<round_saeonly_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_saeonly_mask_op3>}"
2050   [(set_attr "isa" "noavx,avx")
2051    (set_attr "type" "sseadd")
2052    (set_attr "btver2_sse_attr" "maxmin")
2053    (set_attr "prefix" "<mask_prefix3>")
2054    (set_attr "mode" "<MODE>")])
2056 (define_insn "<sse>_vm<code><mode>3<mask_scalar_name><round_saeonly_scalar_name>"
2057   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
2058         (vec_merge:VF_128
2059           (smaxmin:VF_128
2060             (match_operand:VF_128 1 "register_operand" "0,v")
2061             (match_operand:VF_128 2 "vector_operand" "xBm,<round_saeonly_scalar_constraint>"))
2062          (match_dup 1)
2063          (const_int 1)))]
2064   "TARGET_SSE"
2065   "@
2066    <maxmin_float><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
2067    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>}"
2068   [(set_attr "isa" "noavx,avx")
2069    (set_attr "type" "sse")
2070    (set_attr "btver2_sse_attr" "maxmin")
2071    (set_attr "prefix" "<round_saeonly_scalar_prefix>")
2072    (set_attr "mode" "<ssescalarmode>")])
2074 (define_insn "avx_addsubv4df3"
2075   [(set (match_operand:V4DF 0 "register_operand" "=x")
2076         (vec_merge:V4DF
2077           (minus:V4DF
2078             (match_operand:V4DF 1 "register_operand" "x")
2079             (match_operand:V4DF 2 "nonimmediate_operand" "xm"))
2080           (plus:V4DF (match_dup 1) (match_dup 2))
2081           (const_int 5)))]
2082   "TARGET_AVX"
2083   "vaddsubpd\t{%2, %1, %0|%0, %1, %2}"
2084   [(set_attr "type" "sseadd")
2085    (set_attr "prefix" "vex")
2086    (set_attr "mode" "V4DF")])
2088 (define_insn "sse3_addsubv2df3"
2089   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
2090         (vec_merge:V2DF
2091           (minus:V2DF
2092             (match_operand:V2DF 1 "register_operand" "0,x")
2093             (match_operand:V2DF 2 "vector_operand" "xBm,xm"))
2094           (plus:V2DF (match_dup 1) (match_dup 2))
2095           (const_int 1)))]
2096   "TARGET_SSE3"
2097   "@
2098    addsubpd\t{%2, %0|%0, %2}
2099    vaddsubpd\t{%2, %1, %0|%0, %1, %2}"
2100   [(set_attr "isa" "noavx,avx")
2101    (set_attr "type" "sseadd")
2102    (set_attr "atom_unit" "complex")
2103    (set_attr "prefix" "orig,vex")
2104    (set_attr "mode" "V2DF")])
2106 (define_insn "avx_addsubv8sf3"
2107   [(set (match_operand:V8SF 0 "register_operand" "=x")
2108         (vec_merge:V8SF
2109           (minus:V8SF
2110             (match_operand:V8SF 1 "register_operand" "x")
2111             (match_operand:V8SF 2 "nonimmediate_operand" "xm"))
2112           (plus:V8SF (match_dup 1) (match_dup 2))
2113           (const_int 85)))]
2114   "TARGET_AVX"
2115   "vaddsubps\t{%2, %1, %0|%0, %1, %2}"
2116   [(set_attr "type" "sseadd")
2117    (set_attr "prefix" "vex")
2118    (set_attr "mode" "V8SF")])
2120 (define_insn "sse3_addsubv4sf3"
2121   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
2122         (vec_merge:V4SF
2123           (minus:V4SF
2124             (match_operand:V4SF 1 "register_operand" "0,x")
2125             (match_operand:V4SF 2 "vector_operand" "xBm,xm"))
2126           (plus:V4SF (match_dup 1) (match_dup 2))
2127           (const_int 5)))]
2128   "TARGET_SSE3"
2129   "@
2130    addsubps\t{%2, %0|%0, %2}
2131    vaddsubps\t{%2, %1, %0|%0, %1, %2}"
2132   [(set_attr "isa" "noavx,avx")
2133    (set_attr "type" "sseadd")
2134    (set_attr "prefix" "orig,vex")
2135    (set_attr "prefix_rep" "1,*")
2136    (set_attr "mode" "V4SF")])
2138 (define_split
2139   [(set (match_operand:VF_128_256 0 "register_operand")
2140         (match_operator:VF_128_256 6 "addsub_vm_operator"
2141           [(minus:VF_128_256
2142              (match_operand:VF_128_256 1 "register_operand")
2143              (match_operand:VF_128_256 2 "vector_operand"))
2144            (plus:VF_128_256
2145              (match_operand:VF_128_256 3 "vector_operand")
2146              (match_operand:VF_128_256 4 "vector_operand"))
2147            (match_operand 5 "const_int_operand")]))]
2148   "TARGET_SSE3
2149    && can_create_pseudo_p ()
2150    && ((rtx_equal_p (operands[1], operands[3])
2151         && rtx_equal_p (operands[2], operands[4]))
2152        || (rtx_equal_p (operands[1], operands[4])
2153            && rtx_equal_p (operands[2], operands[3])))"
2154   [(set (match_dup 0)
2155         (vec_merge:VF_128_256
2156           (minus:VF_128_256 (match_dup 1) (match_dup 2))
2157           (plus:VF_128_256 (match_dup 1) (match_dup 2))
2158           (match_dup 5)))])
2160 (define_split
2161   [(set (match_operand:VF_128_256 0 "register_operand")
2162         (match_operator:VF_128_256 6 "addsub_vm_operator"
2163           [(plus:VF_128_256
2164              (match_operand:VF_128_256 1 "vector_operand")
2165              (match_operand:VF_128_256 2 "vector_operand"))
2166            (minus:VF_128_256
2167              (match_operand:VF_128_256 3 "register_operand")
2168              (match_operand:VF_128_256 4 "vector_operand"))
2169            (match_operand 5 "const_int_operand")]))]
2170   "TARGET_SSE3
2171    && can_create_pseudo_p ()
2172    && ((rtx_equal_p (operands[1], operands[3])
2173         && rtx_equal_p (operands[2], operands[4]))
2174        || (rtx_equal_p (operands[1], operands[4])
2175            && rtx_equal_p (operands[2], operands[3])))"
2176   [(set (match_dup 0)
2177         (vec_merge:VF_128_256
2178           (minus:VF_128_256 (match_dup 3) (match_dup 4))
2179           (plus:VF_128_256 (match_dup 3) (match_dup 4))
2180           (match_dup 5)))]
2182   /* Negate mask bits to compensate for swapped PLUS and MINUS RTXes.  */
2183   operands[5]
2184     = GEN_INT (~INTVAL (operands[5])
2185                & ((HOST_WIDE_INT_1U << GET_MODE_NUNITS (<MODE>mode)) - 1));
2188 (define_split
2189   [(set (match_operand:VF_128_256 0 "register_operand")
2190         (match_operator:VF_128_256 7 "addsub_vs_operator"
2191           [(vec_concat:<ssedoublemode>
2192              (minus:VF_128_256
2193                (match_operand:VF_128_256 1 "register_operand")
2194                (match_operand:VF_128_256 2 "vector_operand"))
2195              (plus:VF_128_256
2196                (match_operand:VF_128_256 3 "vector_operand")
2197                (match_operand:VF_128_256 4 "vector_operand")))
2198            (match_parallel 5 "addsub_vs_parallel"
2199              [(match_operand 6 "const_int_operand")])]))]
2200   "TARGET_SSE3
2201    && can_create_pseudo_p ()
2202    && ((rtx_equal_p (operands[1], operands[3])
2203         && rtx_equal_p (operands[2], operands[4]))
2204        || (rtx_equal_p (operands[1], operands[4])
2205            && rtx_equal_p (operands[2], operands[3])))"
2206   [(set (match_dup 0)
2207         (vec_merge:VF_128_256
2208           (minus:VF_128_256 (match_dup 1) (match_dup 2))
2209           (plus:VF_128_256 (match_dup 1) (match_dup 2))
2210           (match_dup 5)))]
2212   int i, nelt = XVECLEN (operands[5], 0);
2213   HOST_WIDE_INT ival = 0;
2215   for (i = 0; i < nelt; i++)
2216     if (INTVAL (XVECEXP (operands[5], 0, i)) < GET_MODE_NUNITS (<MODE>mode))
2217       ival |= HOST_WIDE_INT_1 << i;
2219   operands[5] = GEN_INT (ival);
2222 (define_split
2223   [(set (match_operand:VF_128_256 0 "register_operand")
2224         (match_operator:VF_128_256 7 "addsub_vs_operator"
2225           [(vec_concat:<ssedoublemode>
2226              (plus:VF_128_256
2227                (match_operand:VF_128_256 1 "vector_operand")
2228                (match_operand:VF_128_256 2 "vector_operand"))
2229              (minus:VF_128_256
2230                (match_operand:VF_128_256 3 "register_operand")
2231                (match_operand:VF_128_256 4 "vector_operand")))
2232            (match_parallel 5 "addsub_vs_parallel"
2233              [(match_operand 6 "const_int_operand")])]))]
2234   "TARGET_SSE3
2235    && can_create_pseudo_p ()
2236    && ((rtx_equal_p (operands[1], operands[3])
2237         && rtx_equal_p (operands[2], operands[4]))
2238        || (rtx_equal_p (operands[1], operands[4])
2239            && rtx_equal_p (operands[2], operands[3])))"
2240   [(set (match_dup 0)
2241         (vec_merge:VF_128_256
2242           (minus:VF_128_256 (match_dup 3) (match_dup 4))
2243           (plus:VF_128_256 (match_dup 3) (match_dup 4))
2244           (match_dup 5)))]
2246   int i, nelt = XVECLEN (operands[5], 0);
2247   HOST_WIDE_INT ival = 0;
2249   for (i = 0; i < nelt; i++)
2250     if (INTVAL (XVECEXP (operands[5], 0, i)) >= GET_MODE_NUNITS (<MODE>mode))
2251       ival |= HOST_WIDE_INT_1 << i;
2253   operands[5] = GEN_INT (ival);
2256 (define_insn "avx_h<plusminus_insn>v4df3"
2257   [(set (match_operand:V4DF 0 "register_operand" "=x")
2258         (vec_concat:V4DF
2259           (vec_concat:V2DF
2260             (plusminus:DF
2261               (vec_select:DF
2262                 (match_operand:V4DF 1 "register_operand" "x")
2263                 (parallel [(const_int 0)]))
2264               (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
2265             (plusminus:DF
2266               (vec_select:DF
2267                 (match_operand:V4DF 2 "nonimmediate_operand" "xm")
2268                 (parallel [(const_int 0)]))
2269               (vec_select:DF (match_dup 2) (parallel [(const_int 1)]))))
2270           (vec_concat:V2DF
2271             (plusminus:DF
2272               (vec_select:DF (match_dup 1) (parallel [(const_int 2)]))
2273               (vec_select:DF (match_dup 1) (parallel [(const_int 3)])))
2274             (plusminus:DF
2275               (vec_select:DF (match_dup 2) (parallel [(const_int 2)]))
2276               (vec_select:DF (match_dup 2) (parallel [(const_int 3)]))))))]
2277   "TARGET_AVX"
2278   "vh<plusminus_mnemonic>pd\t{%2, %1, %0|%0, %1, %2}"
2279   [(set_attr "type" "sseadd")
2280    (set_attr "prefix" "vex")
2281    (set_attr "mode" "V4DF")])
2283 (define_expand "sse3_haddv2df3"
2284   [(set (match_operand:V2DF 0 "register_operand")
2285         (vec_concat:V2DF
2286           (plus:DF
2287             (vec_select:DF
2288               (match_operand:V2DF 1 "register_operand")
2289               (parallel [(const_int 0)]))
2290             (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
2291           (plus:DF
2292             (vec_select:DF
2293               (match_operand:V2DF 2 "vector_operand")
2294               (parallel [(const_int 0)]))
2295             (vec_select:DF (match_dup 2) (parallel [(const_int 1)])))))]
2296   "TARGET_SSE3")
2298 (define_insn "*sse3_haddv2df3"
2299   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
2300         (vec_concat:V2DF
2301           (plus:DF
2302             (vec_select:DF
2303               (match_operand:V2DF 1 "register_operand" "0,x")
2304               (parallel [(match_operand:SI 3 "const_0_to_1_operand")]))
2305             (vec_select:DF
2306               (match_dup 1)
2307               (parallel [(match_operand:SI 4 "const_0_to_1_operand")])))
2308           (plus:DF
2309             (vec_select:DF
2310               (match_operand:V2DF 2 "vector_operand" "xBm,xm")
2311               (parallel [(match_operand:SI 5 "const_0_to_1_operand")]))
2312             (vec_select:DF
2313               (match_dup 2)
2314               (parallel [(match_operand:SI 6 "const_0_to_1_operand")])))))]
2315   "TARGET_SSE3
2316    && INTVAL (operands[3]) != INTVAL (operands[4])
2317    && INTVAL (operands[5]) != INTVAL (operands[6])"
2318   "@
2319    haddpd\t{%2, %0|%0, %2}
2320    vhaddpd\t{%2, %1, %0|%0, %1, %2}"
2321   [(set_attr "isa" "noavx,avx")
2322    (set_attr "type" "sseadd")
2323    (set_attr "prefix" "orig,vex")
2324    (set_attr "mode" "V2DF")])
2326 (define_insn "sse3_hsubv2df3"
2327   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
2328         (vec_concat:V2DF
2329           (minus:DF
2330             (vec_select:DF
2331               (match_operand:V2DF 1 "register_operand" "0,x")
2332               (parallel [(const_int 0)]))
2333             (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
2334           (minus:DF
2335             (vec_select:DF
2336               (match_operand:V2DF 2 "vector_operand" "xBm,xm")
2337               (parallel [(const_int 0)]))
2338             (vec_select:DF (match_dup 2) (parallel [(const_int 1)])))))]
2339   "TARGET_SSE3"
2340   "@
2341    hsubpd\t{%2, %0|%0, %2}
2342    vhsubpd\t{%2, %1, %0|%0, %1, %2}"
2343   [(set_attr "isa" "noavx,avx")
2344    (set_attr "type" "sseadd")
2345    (set_attr "prefix" "orig,vex")
2346    (set_attr "mode" "V2DF")])
2348 (define_insn "*sse3_haddv2df3_low"
2349   [(set (match_operand:DF 0 "register_operand" "=x,x")
2350         (plus:DF
2351           (vec_select:DF
2352             (match_operand:V2DF 1 "register_operand" "0,x")
2353             (parallel [(match_operand:SI 2 "const_0_to_1_operand")]))
2354           (vec_select:DF
2355             (match_dup 1)
2356             (parallel [(match_operand:SI 3 "const_0_to_1_operand")]))))]
2357   "TARGET_SSE3
2358    && INTVAL (operands[2]) != INTVAL (operands[3])"
2359   "@
2360    haddpd\t{%0, %0|%0, %0}
2361    vhaddpd\t{%1, %1, %0|%0, %1, %1}"
2362   [(set_attr "isa" "noavx,avx")
2363    (set_attr "type" "sseadd1")
2364    (set_attr "prefix" "orig,vex")
2365    (set_attr "mode" "V2DF")])
2367 (define_insn "*sse3_hsubv2df3_low"
2368   [(set (match_operand:DF 0 "register_operand" "=x,x")
2369         (minus:DF
2370           (vec_select:DF
2371             (match_operand:V2DF 1 "register_operand" "0,x")
2372             (parallel [(const_int 0)]))
2373           (vec_select:DF
2374             (match_dup 1)
2375             (parallel [(const_int 1)]))))]
2376   "TARGET_SSE3"
2377   "@
2378    hsubpd\t{%0, %0|%0, %0}
2379    vhsubpd\t{%1, %1, %0|%0, %1, %1}"
2380   [(set_attr "isa" "noavx,avx")
2381    (set_attr "type" "sseadd1")
2382    (set_attr "prefix" "orig,vex")
2383    (set_attr "mode" "V2DF")])
2385 (define_insn "avx_h<plusminus_insn>v8sf3"
2386   [(set (match_operand:V8SF 0 "register_operand" "=x")
2387         (vec_concat:V8SF
2388           (vec_concat:V4SF
2389             (vec_concat:V2SF
2390               (plusminus:SF
2391                 (vec_select:SF
2392                   (match_operand:V8SF 1 "register_operand" "x")
2393                   (parallel [(const_int 0)]))
2394                 (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
2395               (plusminus:SF
2396                 (vec_select:SF (match_dup 1) (parallel [(const_int 2)]))
2397                 (vec_select:SF (match_dup 1) (parallel [(const_int 3)]))))
2398             (vec_concat:V2SF
2399               (plusminus:SF
2400                 (vec_select:SF
2401                   (match_operand:V8SF 2 "nonimmediate_operand" "xm")
2402                   (parallel [(const_int 0)]))
2403                 (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))
2404               (plusminus:SF
2405                 (vec_select:SF (match_dup 2) (parallel [(const_int 2)]))
2406                 (vec_select:SF (match_dup 2) (parallel [(const_int 3)])))))
2407           (vec_concat:V4SF
2408             (vec_concat:V2SF
2409               (plusminus:SF
2410                 (vec_select:SF (match_dup 1) (parallel [(const_int 4)]))
2411                 (vec_select:SF (match_dup 1) (parallel [(const_int 5)])))
2412               (plusminus:SF
2413                 (vec_select:SF (match_dup 1) (parallel [(const_int 6)]))
2414                 (vec_select:SF (match_dup 1) (parallel [(const_int 7)]))))
2415             (vec_concat:V2SF
2416               (plusminus:SF
2417                 (vec_select:SF (match_dup 2) (parallel [(const_int 4)]))
2418                 (vec_select:SF (match_dup 2) (parallel [(const_int 5)])))
2419               (plusminus:SF
2420                 (vec_select:SF (match_dup 2) (parallel [(const_int 6)]))
2421                 (vec_select:SF (match_dup 2) (parallel [(const_int 7)])))))))]
2422   "TARGET_AVX"
2423   "vh<plusminus_mnemonic>ps\t{%2, %1, %0|%0, %1, %2}"
2424   [(set_attr "type" "sseadd")
2425    (set_attr "prefix" "vex")
2426    (set_attr "mode" "V8SF")])
2428 (define_insn "sse3_h<plusminus_insn>v4sf3"
2429   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
2430         (vec_concat:V4SF
2431           (vec_concat:V2SF
2432             (plusminus:SF
2433               (vec_select:SF
2434                 (match_operand:V4SF 1 "register_operand" "0,x")
2435                 (parallel [(const_int 0)]))
2436               (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
2437             (plusminus:SF
2438               (vec_select:SF (match_dup 1) (parallel [(const_int 2)]))
2439               (vec_select:SF (match_dup 1) (parallel [(const_int 3)]))))
2440           (vec_concat:V2SF
2441             (plusminus:SF
2442               (vec_select:SF
2443                 (match_operand:V4SF 2 "vector_operand" "xBm,xm")
2444                 (parallel [(const_int 0)]))
2445               (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))
2446             (plusminus:SF
2447               (vec_select:SF (match_dup 2) (parallel [(const_int 2)]))
2448               (vec_select:SF (match_dup 2) (parallel [(const_int 3)]))))))]
2449   "TARGET_SSE3"
2450   "@
2451    h<plusminus_mnemonic>ps\t{%2, %0|%0, %2}
2452    vh<plusminus_mnemonic>ps\t{%2, %1, %0|%0, %1, %2}"
2453   [(set_attr "isa" "noavx,avx")
2454    (set_attr "type" "sseadd")
2455    (set_attr "atom_unit" "complex")
2456    (set_attr "prefix" "orig,vex")
2457    (set_attr "prefix_rep" "1,*")
2458    (set_attr "mode" "V4SF")])
2460 (define_expand "reduc_plus_scal_v8df"
2461   [(match_operand:DF 0 "register_operand")
2462    (match_operand:V8DF 1 "register_operand")]
2463   "TARGET_AVX512F"
2465   rtx tmp = gen_reg_rtx (V8DFmode);
2466   ix86_expand_reduc (gen_addv8df3, tmp, operands[1]);
2467   emit_insn (gen_vec_extractv8dfdf (operands[0], tmp, const0_rtx));
2468   DONE;
2471 (define_expand "reduc_plus_scal_v4df"
2472   [(match_operand:DF 0 "register_operand")
2473    (match_operand:V4DF 1 "register_operand")]
2474   "TARGET_AVX"
2476   rtx tmp = gen_reg_rtx (V2DFmode);
2477   emit_insn (gen_vec_extract_hi_v4df (tmp, operands[1]));
2478   rtx tmp2 = gen_reg_rtx (V2DFmode);
2479   emit_insn (gen_addv2df3 (tmp2, tmp, gen_lowpart (V2DFmode, operands[1])));
2480   rtx tmp3 = gen_reg_rtx (V2DFmode);
2481   emit_insn (gen_vec_interleave_highv2df (tmp3, tmp2, tmp2));
2482   emit_insn (gen_adddf3 (operands[0],
2483                          gen_lowpart (DFmode, tmp2),
2484                          gen_lowpart (DFmode, tmp3)));
2485   DONE;
2488 (define_expand "reduc_plus_scal_v2df"
2489   [(match_operand:DF 0 "register_operand")
2490    (match_operand:V2DF 1 "register_operand")]
2491   "TARGET_SSE2"
2493   rtx tmp = gen_reg_rtx (V2DFmode);
2494   emit_insn (gen_vec_interleave_highv2df (tmp, operands[1], operands[1]));
2495   emit_insn (gen_adddf3 (operands[0],
2496                          gen_lowpart (DFmode, tmp),
2497                          gen_lowpart (DFmode, operands[1])));
2498   DONE;
2501 (define_expand "reduc_plus_scal_v16sf"
2502   [(match_operand:SF 0 "register_operand")
2503    (match_operand:V16SF 1 "register_operand")]
2504   "TARGET_AVX512F"
2506   rtx tmp = gen_reg_rtx (V16SFmode);
2507   ix86_expand_reduc (gen_addv16sf3, tmp, operands[1]);
2508   emit_insn (gen_vec_extractv16sfsf (operands[0], tmp, const0_rtx));
2509   DONE;
2512 (define_expand "reduc_plus_scal_v8sf"
2513   [(match_operand:SF 0 "register_operand")
2514    (match_operand:V8SF 1 "register_operand")]
2515   "TARGET_AVX"
2517   rtx tmp = gen_reg_rtx (V8SFmode);
2518   rtx tmp2 = gen_reg_rtx (V8SFmode);
2519   rtx vec_res = gen_reg_rtx (V8SFmode);
2520   emit_insn (gen_avx_haddv8sf3 (tmp, operands[1], operands[1]));
2521   emit_insn (gen_avx_haddv8sf3 (tmp2, tmp, tmp));
2522   emit_insn (gen_avx_vperm2f128v8sf3 (tmp, tmp2, tmp2, GEN_INT (1)));
2523   emit_insn (gen_addv8sf3 (vec_res, tmp, tmp2));
2524   emit_insn (gen_vec_extractv8sfsf (operands[0], vec_res, const0_rtx));
2525   DONE;
2528 (define_expand "reduc_plus_scal_v4sf"
2529   [(match_operand:SF 0 "register_operand")
2530    (match_operand:V4SF 1 "register_operand")]
2531   "TARGET_SSE"
2533   rtx vec_res = gen_reg_rtx (V4SFmode);
2534   if (TARGET_SSE3)
2535     {
2536       rtx tmp = gen_reg_rtx (V4SFmode);
2537       emit_insn (gen_sse3_haddv4sf3 (tmp, operands[1], operands[1]));
2538       emit_insn (gen_sse3_haddv4sf3 (vec_res, tmp, tmp));
2539     }
2540   else
2541     ix86_expand_reduc (gen_addv4sf3, vec_res, operands[1]);
2542   emit_insn (gen_vec_extractv4sfsf (operands[0], vec_res, const0_rtx));
2543   DONE;
2546 ;; Modes handled by reduc_sm{in,ax}* patterns.
2547 (define_mode_iterator REDUC_SMINMAX_MODE
2548   [(V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
2549    (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")
2550    (V8SF "TARGET_AVX") (V4DF "TARGET_AVX")
2551    (V4SF "TARGET_SSE") (V64QI "TARGET_AVX512BW")
2552    (V32HI "TARGET_AVX512BW") (V16SI "TARGET_AVX512F")
2553    (V8DI "TARGET_AVX512F") (V16SF "TARGET_AVX512F")
2554    (V8DF "TARGET_AVX512F")])
2556 (define_expand "reduc_<code>_scal_<mode>"
2557   [(smaxmin:REDUC_SMINMAX_MODE
2558      (match_operand:<ssescalarmode> 0 "register_operand")
2559      (match_operand:REDUC_SMINMAX_MODE 1 "register_operand"))]
2560   ""
2562   rtx tmp = gen_reg_rtx (<MODE>mode);
2563   ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
2564   emit_insn (gen_vec_extract<mode><ssescalarmodelower> (operands[0], tmp,
2565                                                         const0_rtx));
2566   DONE;
2569 (define_expand "reduc_<code>_scal_<mode>"
2570   [(umaxmin:VI_AVX512BW
2571      (match_operand:<ssescalarmode> 0 "register_operand")
2572      (match_operand:VI_AVX512BW 1 "register_operand"))]
2573   "TARGET_AVX512F"
2575   rtx tmp = gen_reg_rtx (<MODE>mode);
2576   ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
2577   emit_insn (gen_vec_extract<mode><ssescalarmodelower> (operands[0], tmp,
2578                                                         const0_rtx));
2579   DONE;
2582 (define_expand "reduc_<code>_scal_<mode>"
2583   [(umaxmin:VI_256
2584      (match_operand:<ssescalarmode> 0 "register_operand")
2585      (match_operand:VI_256 1 "register_operand"))]
2586   "TARGET_AVX2"
2588   rtx tmp = gen_reg_rtx (<MODE>mode);
2589   ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
2590   emit_insn (gen_vec_extract<mode><ssescalarmodelower> (operands[0], tmp,
2591                                                         const0_rtx));
2592   DONE;
2595 (define_expand "reduc_umin_scal_v8hi"
2596   [(umin:V8HI
2597      (match_operand:HI 0 "register_operand")
2598      (match_operand:V8HI 1 "register_operand"))]
2599   "TARGET_SSE4_1"
2601   rtx tmp = gen_reg_rtx (V8HImode);
2602   ix86_expand_reduc (gen_uminv8hi3, tmp, operands[1]);
2603   emit_insn (gen_vec_extractv8hihi (operands[0], tmp, const0_rtx));
2604   DONE;
2607 (define_insn "<mask_codefor>reducep<mode><mask_name>"
2608   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
2609         (unspec:VF_AVX512VL
2610           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")
2611            (match_operand:SI 2 "const_0_to_255_operand")]
2612           UNSPEC_REDUCE))]
2613   "TARGET_AVX512DQ"
2614   "vreduce<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
2615   [(set_attr "type" "sse")
2616    (set_attr "prefix" "evex")
2617    (set_attr "mode" "<MODE>")])
2619 (define_insn "reduces<mode><mask_scalar_name>"
2620   [(set (match_operand:VF_128 0 "register_operand" "=v")
2621         (vec_merge:VF_128
2622           (unspec:VF_128
2623             [(match_operand:VF_128 1 "register_operand" "v")
2624              (match_operand:VF_128 2 "nonimmediate_operand" "vm")
2625              (match_operand:SI 3 "const_0_to_255_operand")]
2626             UNSPEC_REDUCE)
2627           (match_dup 1)
2628           (const_int 1)))]
2629   "TARGET_AVX512DQ"
2630   "vreduce<ssescalarmodesuffix>\t{%3, %2, %1, %0<mask_scalar_operand4>|%0<mask_scalar_operand4>, %1, %<iptr>2, %3}"
2631   [(set_attr "type" "sse")
2632    (set_attr "prefix" "evex")
2633    (set_attr "mode" "<MODE>")])
2635 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2637 ;; Parallel floating point comparisons
2639 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2641 (define_insn "avx_cmp<mode>3"
2642   [(set (match_operand:VF_128_256 0 "register_operand" "=x")
2643         (unspec:VF_128_256
2644           [(match_operand:VF_128_256 1 "register_operand" "x")
2645            (match_operand:VF_128_256 2 "nonimmediate_operand" "xm")
2646            (match_operand:SI 3 "const_0_to_31_operand" "n")]
2647           UNSPEC_PCMP))]
2648   "TARGET_AVX"
2649   "vcmp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
2650   [(set_attr "type" "ssecmp")
2651    (set_attr "length_immediate" "1")
2652    (set_attr "prefix" "vex")
2653    (set_attr "mode" "<MODE>")])
2655 (define_insn "avx_vmcmp<mode>3"
2656   [(set (match_operand:VF_128 0 "register_operand" "=x")
2657         (vec_merge:VF_128
2658           (unspec:VF_128
2659             [(match_operand:VF_128 1 "register_operand" "x")
2660              (match_operand:VF_128 2 "nonimmediate_operand" "xm")
2661              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2662             UNSPEC_PCMP)
2663          (match_dup 1)
2664          (const_int 1)))]
2665   "TARGET_AVX"
2666   "vcmp<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %3}"
2667   [(set_attr "type" "ssecmp")
2668    (set_attr "length_immediate" "1")
2669    (set_attr "prefix" "vex")
2670    (set_attr "mode" "<ssescalarmode>")])
2672 (define_insn "*<sse>_maskcmp<mode>3_comm"
2673   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
2674         (match_operator:VF_128_256 3 "sse_comparison_operator"
2675           [(match_operand:VF_128_256 1 "register_operand" "%0,x")
2676            (match_operand:VF_128_256 2 "vector_operand" "xBm,xm")]))]
2677   "TARGET_SSE
2678    && GET_RTX_CLASS (GET_CODE (operands[3])) == RTX_COMM_COMPARE"
2679   "@
2680    cmp%D3<ssemodesuffix>\t{%2, %0|%0, %2}
2681    vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2682   [(set_attr "isa" "noavx,avx")
2683    (set_attr "type" "ssecmp")
2684    (set_attr "length_immediate" "1")
2685    (set_attr "prefix" "orig,vex")
2686    (set_attr "mode" "<MODE>")])
2688 (define_insn "<sse>_maskcmp<mode>3"
2689   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
2690         (match_operator:VF_128_256 3 "sse_comparison_operator"
2691           [(match_operand:VF_128_256 1 "register_operand" "0,x")
2692            (match_operand:VF_128_256 2 "vector_operand" "xBm,xm")]))]
2693   "TARGET_SSE"
2694   "@
2695    cmp%D3<ssemodesuffix>\t{%2, %0|%0, %2}
2696    vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2697   [(set_attr "isa" "noavx,avx")
2698    (set_attr "type" "ssecmp")
2699    (set_attr "length_immediate" "1")
2700    (set_attr "prefix" "orig,vex")
2701    (set_attr "mode" "<MODE>")])
2703 (define_insn "<sse>_vmmaskcmp<mode>3"
2704   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
2705         (vec_merge:VF_128
2706          (match_operator:VF_128 3 "sse_comparison_operator"
2707            [(match_operand:VF_128 1 "register_operand" "0,x")
2708             (match_operand:VF_128 2 "vector_operand" "xBm,xm")])
2709          (match_dup 1)
2710          (const_int 1)))]
2711   "TARGET_SSE"
2712   "@
2713    cmp%D3<ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
2714    vcmp%D3<ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %<iptr>2}"
2715   [(set_attr "isa" "noavx,avx")
2716    (set_attr "type" "ssecmp")
2717    (set_attr "length_immediate" "1,*")
2718    (set_attr "prefix" "orig,vex")
2719    (set_attr "mode" "<ssescalarmode>")])
2721 (define_mode_attr cmp_imm_predicate
2722   [(V16SF "const_0_to_31_operand")  (V8DF "const_0_to_31_operand")
2723    (V16SI "const_0_to_7_operand")   (V8DI "const_0_to_7_operand")
2724    (V8SF "const_0_to_31_operand")   (V4DF "const_0_to_31_operand")
2725    (V8SI "const_0_to_7_operand")    (V4DI "const_0_to_7_operand")
2726    (V4SF "const_0_to_31_operand")   (V2DF "const_0_to_31_operand")
2727    (V4SI "const_0_to_7_operand")    (V2DI "const_0_to_7_operand")
2728    (V32HI "const_0_to_7_operand")   (V64QI "const_0_to_7_operand")
2729    (V16HI "const_0_to_7_operand")   (V32QI "const_0_to_7_operand")
2730    (V8HI "const_0_to_7_operand")    (V16QI "const_0_to_7_operand")])
2732 (define_insn "<avx512>_cmp<mode>3<mask_scalar_merge_name><round_saeonly_name>"
2733   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2734         (unspec:<avx512fmaskmode>
2735           [(match_operand:V48_AVX512VL 1 "register_operand" "v")
2736            (match_operand:V48_AVX512VL 2 "nonimmediate_operand" "<round_saeonly_constraint>")
2737            (match_operand:SI 3 "<cmp_imm_predicate>" "n")]
2738           UNSPEC_PCMP))]
2739   "TARGET_AVX512F && <round_saeonly_mode512bit_condition>"
2740   "v<sseintprefix>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}"
2741   [(set_attr "type" "ssecmp")
2742    (set_attr "length_immediate" "1")
2743    (set_attr "prefix" "evex")
2744    (set_attr "mode" "<sseinsnmode>")])
2746 (define_insn "<avx512>_cmp<mode>3<mask_scalar_merge_name>"
2747   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2748         (unspec:<avx512fmaskmode>
2749           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
2750            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
2751            (match_operand:SI 3 "<cmp_imm_predicate>" "n")]
2752           UNSPEC_PCMP))]
2753   "TARGET_AVX512BW"
2754   "vpcmp<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2755   [(set_attr "type" "ssecmp")
2756    (set_attr "length_immediate" "1")
2757    (set_attr "prefix" "evex")
2758    (set_attr "mode" "<sseinsnmode>")])
2760 (define_insn "<avx512>_ucmp<mode>3<mask_scalar_merge_name>"
2761   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2762         (unspec:<avx512fmaskmode>
2763           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
2764            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
2765            (match_operand:SI 3 "const_0_to_7_operand" "n")]
2766           UNSPEC_UNSIGNED_PCMP))]
2767   "TARGET_AVX512BW"
2768   "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2769   [(set_attr "type" "ssecmp")
2770    (set_attr "length_immediate" "1")
2771    (set_attr "prefix" "evex")
2772    (set_attr "mode" "<sseinsnmode>")])
2774 (define_insn "<avx512>_ucmp<mode>3<mask_scalar_merge_name>"
2775   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2776         (unspec:<avx512fmaskmode>
2777           [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
2778            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")
2779            (match_operand:SI 3 "const_0_to_7_operand" "n")]
2780           UNSPEC_UNSIGNED_PCMP))]
2781   "TARGET_AVX512F"
2782   "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2783   [(set_attr "type" "ssecmp")
2784    (set_attr "length_immediate" "1")
2785    (set_attr "prefix" "evex")
2786    (set_attr "mode" "<sseinsnmode>")])
2788 (define_insn "avx512f_vmcmp<mode>3<round_saeonly_name>"
2789   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2790         (and:<avx512fmaskmode>
2791           (unspec:<avx512fmaskmode>
2792             [(match_operand:VF_128 1 "register_operand" "v")
2793              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
2794              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2795             UNSPEC_PCMP)
2796           (const_int 1)))]
2797   "TARGET_AVX512F"
2798   "vcmp<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %<iptr>2<round_saeonly_op4>, %3}"
2799   [(set_attr "type" "ssecmp")
2800    (set_attr "length_immediate" "1")
2801    (set_attr "prefix" "evex")
2802    (set_attr "mode" "<ssescalarmode>")])
2804 (define_insn "avx512f_vmcmp<mode>3_mask<round_saeonly_name>"
2805   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2806         (and:<avx512fmaskmode>
2807           (unspec:<avx512fmaskmode>
2808             [(match_operand:VF_128 1 "register_operand" "v")
2809              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
2810              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2811             UNSPEC_PCMP)
2812           (and:<avx512fmaskmode>
2813             (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")
2814             (const_int 1))))]
2815   "TARGET_AVX512F"
2816   "vcmp<ssescalarmodesuffix>\t{%3, <round_saeonly_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %<iptr>2<round_saeonly_op5>, %3}"
2817   [(set_attr "type" "ssecmp")
2818    (set_attr "length_immediate" "1")
2819    (set_attr "prefix" "evex")
2820    (set_attr "mode" "<ssescalarmode>")])
2822 (define_insn "avx512f_maskcmp<mode>3"
2823   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2824         (match_operator:<avx512fmaskmode> 3 "sse_comparison_operator"
2825           [(match_operand:VF 1 "register_operand" "v")
2826            (match_operand:VF 2 "nonimmediate_operand" "vm")]))]
2827   "TARGET_AVX512F"
2828   "vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2829   [(set_attr "type" "ssecmp")
2830    (set_attr "length_immediate" "1")
2831    (set_attr "prefix" "evex")
2832    (set_attr "mode" "<sseinsnmode>")])
2834 (define_insn "<sse>_<unord>comi<round_saeonly_name>"
2835   [(set (reg:CCFP FLAGS_REG)
2836         (compare:CCFP
2837           (vec_select:MODEF
2838             (match_operand:<ssevecmode> 0 "register_operand" "v")
2839             (parallel [(const_int 0)]))
2840           (vec_select:MODEF
2841             (match_operand:<ssevecmode> 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
2842             (parallel [(const_int 0)]))))]
2843   "SSE_FLOAT_MODE_P (<MODE>mode)"
2844   "%v<unord>comi<ssemodesuffix>\t{<round_saeonly_op2>%1, %0|%0, %<iptr>1<round_saeonly_op2>}"
2845   [(set_attr "type" "ssecomi")
2846    (set_attr "prefix" "maybe_vex")
2847    (set_attr "prefix_rep" "0")
2848    (set (attr "prefix_data16")
2849         (if_then_else (eq_attr "mode" "DF")
2850                       (const_string "1")
2851                       (const_string "0")))
2852    (set_attr "mode" "<MODE>")])
2854 (define_expand "vec_cmp<mode><avx512fmaskmodelower>"
2855   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2856         (match_operator:<avx512fmaskmode> 1 ""
2857           [(match_operand:V48_AVX512VL 2 "register_operand")
2858            (match_operand:V48_AVX512VL 3 "nonimmediate_operand")]))]
2859   "TARGET_AVX512F"
2861   bool ok = ix86_expand_mask_vec_cmp (operands);
2862   gcc_assert (ok);
2863   DONE;
2866 (define_expand "vec_cmp<mode><avx512fmaskmodelower>"
2867   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2868         (match_operator:<avx512fmaskmode> 1 ""
2869           [(match_operand:VI12_AVX512VL 2 "register_operand")
2870            (match_operand:VI12_AVX512VL 3 "nonimmediate_operand")]))]
2871   "TARGET_AVX512BW"
2873   bool ok = ix86_expand_mask_vec_cmp (operands);
2874   gcc_assert (ok);
2875   DONE;
2878 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2879   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2880         (match_operator:<sseintvecmode> 1 ""
2881           [(match_operand:VI_256 2 "register_operand")
2882            (match_operand:VI_256 3 "nonimmediate_operand")]))]
2883   "TARGET_AVX2"
2885   bool ok = ix86_expand_int_vec_cmp (operands);
2886   gcc_assert (ok);
2887   DONE;
2890 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2891   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2892         (match_operator:<sseintvecmode> 1 ""
2893           [(match_operand:VI124_128 2 "register_operand")
2894            (match_operand:VI124_128 3 "vector_operand")]))]
2895   "TARGET_SSE2"
2897   bool ok = ix86_expand_int_vec_cmp (operands);
2898   gcc_assert (ok);
2899   DONE;
2902 (define_expand "vec_cmpv2div2di"
2903   [(set (match_operand:V2DI 0 "register_operand")
2904         (match_operator:V2DI 1 ""
2905           [(match_operand:V2DI 2 "register_operand")
2906            (match_operand:V2DI 3 "vector_operand")]))]
2907   "TARGET_SSE4_2"
2909   bool ok = ix86_expand_int_vec_cmp (operands);
2910   gcc_assert (ok);
2911   DONE;
2914 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2915   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2916         (match_operator:<sseintvecmode> 1 ""
2917           [(match_operand:VF_256 2 "register_operand")
2918            (match_operand:VF_256 3 "nonimmediate_operand")]))]
2919   "TARGET_AVX"
2921   bool ok = ix86_expand_fp_vec_cmp (operands);
2922   gcc_assert (ok);
2923   DONE;
2926 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2927   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2928         (match_operator:<sseintvecmode> 1 ""
2929           [(match_operand:VF_128 2 "register_operand")
2930            (match_operand:VF_128 3 "vector_operand")]))]
2931   "TARGET_SSE"
2933   bool ok = ix86_expand_fp_vec_cmp (operands);
2934   gcc_assert (ok);
2935   DONE;
2938 (define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
2939   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2940         (match_operator:<avx512fmaskmode> 1 ""
2941           [(match_operand:VI48_AVX512VL 2 "register_operand")
2942            (match_operand:VI48_AVX512VL 3 "nonimmediate_operand")]))]
2943   "TARGET_AVX512F"
2945   bool ok = ix86_expand_mask_vec_cmp (operands);
2946   gcc_assert (ok);
2947   DONE;
2950 (define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
2951   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2952         (match_operator:<avx512fmaskmode> 1 ""
2953           [(match_operand:VI12_AVX512VL 2 "register_operand")
2954            (match_operand:VI12_AVX512VL 3 "nonimmediate_operand")]))]
2955   "TARGET_AVX512BW"
2957   bool ok = ix86_expand_mask_vec_cmp (operands);
2958   gcc_assert (ok);
2959   DONE;
2962 (define_expand "vec_cmpu<mode><sseintvecmodelower>"
2963   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2964         (match_operator:<sseintvecmode> 1 ""
2965           [(match_operand:VI_256 2 "register_operand")
2966            (match_operand:VI_256 3 "nonimmediate_operand")]))]
2967   "TARGET_AVX2"
2969   bool ok = ix86_expand_int_vec_cmp (operands);
2970   gcc_assert (ok);
2971   DONE;
2974 (define_expand "vec_cmpu<mode><sseintvecmodelower>"
2975   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2976         (match_operator:<sseintvecmode> 1 ""
2977           [(match_operand:VI124_128 2 "register_operand")
2978            (match_operand:VI124_128 3 "vector_operand")]))]
2979   "TARGET_SSE2"
2981   bool ok = ix86_expand_int_vec_cmp (operands);
2982   gcc_assert (ok);
2983   DONE;
2986 (define_expand "vec_cmpuv2div2di"
2987   [(set (match_operand:V2DI 0 "register_operand")
2988         (match_operator:V2DI 1 ""
2989           [(match_operand:V2DI 2 "register_operand")
2990            (match_operand:V2DI 3 "vector_operand")]))]
2991   "TARGET_SSE4_2"
2993   bool ok = ix86_expand_int_vec_cmp (operands);
2994   gcc_assert (ok);
2995   DONE;
2998 (define_expand "vec_cmpeqv2div2di"
2999   [(set (match_operand:V2DI 0 "register_operand")
3000         (match_operator:V2DI 1 ""
3001           [(match_operand:V2DI 2 "register_operand")
3002            (match_operand:V2DI 3 "vector_operand")]))]
3003   "TARGET_SSE4_1"
3005   bool ok = ix86_expand_int_vec_cmp (operands);
3006   gcc_assert (ok);
3007   DONE;
3010 (define_expand "vcond<V_512:mode><VF_512:mode>"
3011   [(set (match_operand:V_512 0 "register_operand")
3012         (if_then_else:V_512
3013           (match_operator 3 ""
3014             [(match_operand:VF_512 4 "nonimmediate_operand")
3015              (match_operand:VF_512 5 "nonimmediate_operand")])
3016           (match_operand:V_512 1 "general_operand")
3017           (match_operand:V_512 2 "general_operand")))]
3018   "TARGET_AVX512F
3019    && (GET_MODE_NUNITS (<V_512:MODE>mode)
3020        == GET_MODE_NUNITS (<VF_512:MODE>mode))"
3022   bool ok = ix86_expand_fp_vcond (operands);
3023   gcc_assert (ok);
3024   DONE;
3027 (define_expand "vcond<V_256:mode><VF_256:mode>"
3028   [(set (match_operand:V_256 0 "register_operand")
3029         (if_then_else:V_256
3030           (match_operator 3 ""
3031             [(match_operand:VF_256 4 "nonimmediate_operand")
3032              (match_operand:VF_256 5 "nonimmediate_operand")])
3033           (match_operand:V_256 1 "general_operand")
3034           (match_operand:V_256 2 "general_operand")))]
3035   "TARGET_AVX
3036    && (GET_MODE_NUNITS (<V_256:MODE>mode)
3037        == GET_MODE_NUNITS (<VF_256:MODE>mode))"
3039   bool ok = ix86_expand_fp_vcond (operands);
3040   gcc_assert (ok);
3041   DONE;
3044 (define_expand "vcond<V_128:mode><VF_128:mode>"
3045   [(set (match_operand:V_128 0 "register_operand")
3046         (if_then_else:V_128
3047           (match_operator 3 ""
3048             [(match_operand:VF_128 4 "vector_operand")
3049              (match_operand:VF_128 5 "vector_operand")])
3050           (match_operand:V_128 1 "general_operand")
3051           (match_operand:V_128 2 "general_operand")))]
3052   "TARGET_SSE
3053    && (GET_MODE_NUNITS (<V_128:MODE>mode)
3054        == GET_MODE_NUNITS (<VF_128:MODE>mode))"
3056   bool ok = ix86_expand_fp_vcond (operands);
3057   gcc_assert (ok);
3058   DONE;
3061 (define_expand "vcond_mask_<mode><avx512fmaskmodelower>"
3062   [(set (match_operand:V48_AVX512VL 0 "register_operand")
3063         (vec_merge:V48_AVX512VL
3064           (match_operand:V48_AVX512VL 1 "nonimmediate_operand")
3065           (match_operand:V48_AVX512VL 2 "vector_move_operand")
3066           (match_operand:<avx512fmaskmode> 3 "register_operand")))]
3067   "TARGET_AVX512F")
3069 (define_expand "vcond_mask_<mode><avx512fmaskmodelower>"
3070   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
3071         (vec_merge:VI12_AVX512VL
3072           (match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
3073           (match_operand:VI12_AVX512VL 2 "vector_move_operand")
3074           (match_operand:<avx512fmaskmode> 3 "register_operand")))]
3075   "TARGET_AVX512BW")
3077 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3078   [(set (match_operand:VI_256 0 "register_operand")
3079         (vec_merge:VI_256
3080           (match_operand:VI_256 1 "nonimmediate_operand")
3081           (match_operand:VI_256 2 "vector_move_operand")
3082           (match_operand:<sseintvecmode> 3 "register_operand")))]
3083   "TARGET_AVX2"
3085   ix86_expand_sse_movcc (operands[0], operands[3],
3086                          operands[1], operands[2]);
3087   DONE;
3090 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3091   [(set (match_operand:VI124_128 0 "register_operand")
3092         (vec_merge:VI124_128
3093           (match_operand:VI124_128 1 "vector_operand")
3094           (match_operand:VI124_128 2 "vector_move_operand")
3095           (match_operand:<sseintvecmode> 3 "register_operand")))]
3096   "TARGET_SSE2"
3098   ix86_expand_sse_movcc (operands[0], operands[3],
3099                          operands[1], operands[2]);
3100   DONE;
3103 (define_expand "vcond_mask_v2div2di"
3104   [(set (match_operand:V2DI 0 "register_operand")
3105         (vec_merge:V2DI
3106           (match_operand:V2DI 1 "vector_operand")
3107           (match_operand:V2DI 2 "vector_move_operand")
3108           (match_operand:V2DI 3 "register_operand")))]
3109   "TARGET_SSE4_2"
3111   ix86_expand_sse_movcc (operands[0], operands[3],
3112                          operands[1], operands[2]);
3113   DONE;
3116 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3117   [(set (match_operand:VF_256 0 "register_operand")
3118         (vec_merge:VF_256
3119           (match_operand:VF_256 1 "nonimmediate_operand")
3120           (match_operand:VF_256 2 "vector_move_operand")
3121           (match_operand:<sseintvecmode> 3 "register_operand")))]
3122   "TARGET_AVX"
3124   ix86_expand_sse_movcc (operands[0], operands[3],
3125                          operands[1], operands[2]);
3126   DONE;
3129 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3130   [(set (match_operand:VF_128 0 "register_operand")
3131         (vec_merge:VF_128
3132           (match_operand:VF_128 1 "vector_operand")
3133           (match_operand:VF_128 2 "vector_move_operand")
3134           (match_operand:<sseintvecmode> 3 "register_operand")))]
3135   "TARGET_SSE"
3137   ix86_expand_sse_movcc (operands[0], operands[3],
3138                          operands[1], operands[2]);
3139   DONE;
3142 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3144 ;; Parallel floating point logical operations
3146 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3148 (define_insn "<sse>_andnot<mode>3<mask_name>"
3149   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x,v,v")
3150         (and:VF_128_256
3151           (not:VF_128_256
3152             (match_operand:VF_128_256 1 "register_operand" "0,x,v,v"))
3153           (match_operand:VF_128_256 2 "vector_operand" "xBm,xm,vm,vm")))]
3154   "TARGET_SSE && <mask_avx512vl_condition>"
3156   static char buf[128];
3157   const char *ops;
3158   const char *suffix;
3160   switch (which_alternative)
3161     {
3162     case 0:
3163       ops = "andn%s\t{%%2, %%0|%%0, %%2}";
3164       break;
3165     case 1:
3166     case 2:
3167     case 3:
3168       ops = "vandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3169       break;
3170     default:
3171       gcc_unreachable ();
3172     }
3174   switch (get_attr_mode (insn))
3175     {
3176     case MODE_V8SF:
3177     case MODE_V4SF:
3178       suffix = "ps";
3179       break;
3180     case MODE_OI:
3181     case MODE_TI:
3182       /* There is no vandnp[sd] in avx512f.  Use vpandn[qd].  */
3183       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3184       ops = "vpandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3185       break;
3186     default:
3187       suffix = "<ssemodesuffix>";
3188     }
3190   snprintf (buf, sizeof (buf), ops, suffix);
3191   return buf;
3193   [(set_attr "isa" "noavx,avx,avx512dq,avx512f")
3194    (set_attr "type" "sselog")
3195    (set_attr "prefix" "orig,maybe_vex,evex,evex")
3196    (set (attr "mode")
3197         (cond [(and (match_test "<mask_applied>")
3198                     (and (eq_attr "alternative" "1")
3199                          (match_test "!TARGET_AVX512DQ")))
3200                  (const_string "<sseintvecmode2>")
3201                (eq_attr "alternative" "3")
3202                  (const_string "<sseintvecmode2>")
3203                (and (match_test "<MODE_SIZE> == 16")
3204                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3205                  (const_string "<ssePSmode>")
3206                (match_test "TARGET_AVX")
3207                  (const_string "<MODE>")
3208                (match_test "optimize_function_for_size_p (cfun)")
3209                  (const_string "V4SF")
3210                ]
3211                (const_string "<MODE>")))])
3214 (define_insn "<sse>_andnot<mode>3<mask_name>"
3215   [(set (match_operand:VF_512 0 "register_operand" "=v")
3216         (and:VF_512
3217           (not:VF_512
3218             (match_operand:VF_512 1 "register_operand" "v"))
3219           (match_operand:VF_512 2 "nonimmediate_operand" "vm")))]
3220   "TARGET_AVX512F"
3222   static char buf[128];
3223   const char *ops;
3224   const char *suffix;
3226   suffix = "<ssemodesuffix>";
3227   ops = "";
3229   /* There is no vandnp[sd] in avx512f.  Use vpandn[qd].  */
3230   if (!TARGET_AVX512DQ)
3231     {
3232       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3233       ops = "p";
3234     }
3236   snprintf (buf, sizeof (buf),
3237             "v%sandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}",
3238             ops, suffix);
3239   return buf;
3241   [(set_attr "type" "sselog")
3242    (set_attr "prefix" "evex")
3243    (set (attr "mode")
3244         (if_then_else (match_test "TARGET_AVX512DQ")
3245                       (const_string "<sseinsnmode>")
3246                       (const_string "XI")))])
3248 (define_expand "<code><mode>3<mask_name>"
3249   [(set (match_operand:VF_128_256 0 "register_operand")
3250        (any_logic:VF_128_256
3251          (match_operand:VF_128_256 1 "vector_operand")
3252          (match_operand:VF_128_256 2 "vector_operand")))]
3253   "TARGET_SSE && <mask_avx512vl_condition>"
3254   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
3256 (define_expand "<code><mode>3<mask_name>"
3257   [(set (match_operand:VF_512 0 "register_operand")
3258        (any_logic:VF_512
3259          (match_operand:VF_512 1 "nonimmediate_operand")
3260          (match_operand:VF_512 2 "nonimmediate_operand")))]
3261   "TARGET_AVX512F"
3262   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
3264 (define_insn "*<code><mode>3<mask_name>"
3265   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x,v,v")
3266         (any_logic:VF_128_256
3267           (match_operand:VF_128_256 1 "vector_operand" "%0,x,v,v")
3268           (match_operand:VF_128_256 2 "vector_operand" "xBm,xm,vm,vm")))]
3269   "TARGET_SSE && <mask_avx512vl_condition>
3270    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
3272   static char buf[128];
3273   const char *ops;
3274   const char *suffix;
3276   switch (which_alternative)
3277     {
3278     case 0:
3279       ops = "<logic>%s\t{%%2, %%0|%%0, %%2}";
3280       break;
3281     case 1:
3282     case 2:
3283     case 3:
3284       ops = "v<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3285       break;
3286     default:
3287       gcc_unreachable ();
3288     }
3290   switch (get_attr_mode (insn))
3291     {
3292     case MODE_V8SF:
3293     case MODE_V4SF:
3294       suffix = "ps";
3295       break;
3296     case MODE_OI:
3297     case MODE_TI:
3298       /* There is no v<logic>p[sd] in avx512f.  Use vp<logic>[qd].  */
3299       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3300       ops = "vp<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3301       break;
3302     default:
3303       suffix = "<ssemodesuffix>";
3304     }
3306   snprintf (buf, sizeof (buf), ops, suffix);
3307   return buf;
3309   [(set_attr "isa" "noavx,avx,avx512dq,avx512f")
3310    (set_attr "type" "sselog")
3311    (set_attr "prefix" "orig,maybe_evex,evex,evex")
3312    (set (attr "mode")
3313         (cond [(and (match_test "<mask_applied>")
3314                     (and (eq_attr "alternative" "1")
3315                          (match_test "!TARGET_AVX512DQ")))
3316                  (const_string "<sseintvecmode2>")
3317                (eq_attr "alternative" "3")
3318                  (const_string "<sseintvecmode2>")
3319                (and (match_test "<MODE_SIZE> == 16")
3320                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3321                  (const_string "<ssePSmode>")
3322                (match_test "TARGET_AVX")
3323                  (const_string "<MODE>")
3324                (match_test "optimize_function_for_size_p (cfun)")
3325                  (const_string "V4SF")
3326                ]
3327                (const_string "<MODE>")))])
3329 (define_insn "*<code><mode>3<mask_name>"
3330   [(set (match_operand:VF_512 0 "register_operand" "=v")
3331         (any_logic:VF_512
3332           (match_operand:VF_512 1 "nonimmediate_operand" "%v")
3333           (match_operand:VF_512 2 "nonimmediate_operand" "vm")))]
3334   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
3336   static char buf[128];
3337   const char *ops;
3338   const char *suffix;
3340   suffix = "<ssemodesuffix>";
3341   ops = "";
3343   /* There is no v<logic>p[sd] in avx512f.  Use vp<logic>[dq].  */
3344   if (!TARGET_AVX512DQ)
3345     {
3346       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3347       ops = "p";
3348     }
3350   snprintf (buf, sizeof (buf),
3351            "v%s<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}",
3352            ops, suffix);
3353   return buf;
3355   [(set_attr "type" "sselog")
3356    (set_attr "prefix" "evex")
3357    (set (attr "mode")
3358         (if_then_else (match_test "TARGET_AVX512DQ")
3359                       (const_string "<sseinsnmode>")
3360                       (const_string "XI")))])
3362 (define_expand "copysign<mode>3"
3363   [(set (match_dup 4)
3364         (and:VF
3365           (not:VF (match_dup 3))
3366           (match_operand:VF 1 "vector_operand")))
3367    (set (match_dup 5)
3368         (and:VF (match_dup 3)
3369                 (match_operand:VF 2 "vector_operand")))
3370    (set (match_operand:VF 0 "register_operand")
3371         (ior:VF (match_dup 4) (match_dup 5)))]
3372   "TARGET_SSE"
3374   operands[3] = ix86_build_signbit_mask (<MODE>mode, 1, 0);
3376   operands[4] = gen_reg_rtx (<MODE>mode);
3377   operands[5] = gen_reg_rtx (<MODE>mode);
3380 ;; Also define scalar versions.  These are used for abs, neg, and
3381 ;; conditional move.  Using subregs into vector modes causes register
3382 ;; allocation lossage.  These patterns do not allow memory operands
3383 ;; because the native instructions read the full 128-bits.
3385 (define_insn "*andnot<mode>3"
3386   [(set (match_operand:MODEF 0 "register_operand" "=x,x,v,v")
3387         (and:MODEF
3388           (not:MODEF
3389             (match_operand:MODEF 1 "register_operand" "0,x,v,v"))
3390             (match_operand:MODEF 2 "register_operand" "x,x,v,v")))]
3391   "SSE_FLOAT_MODE_P (<MODE>mode)"
3393   static char buf[128];
3394   const char *ops;
3395   const char *suffix
3396     = (get_attr_mode (insn) == MODE_V4SF) ? "ps" : "<ssevecmodesuffix>";
3398   switch (which_alternative)
3399     {
3400     case 0:
3401       ops = "andn%s\t{%%2, %%0|%%0, %%2}";
3402       break;
3403     case 1:
3404       ops = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3405       break;
3406     case 2:
3407       if (TARGET_AVX512DQ)
3408         ops = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3409       else
3410         {
3411           suffix = <MODE>mode == DFmode ? "q" : "d";
3412           ops = "vpandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3413         }
3414       break;
3415     case 3:
3416       if (TARGET_AVX512DQ)
3417         ops = "vandn%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3418       else
3419         {
3420           suffix = <MODE>mode == DFmode ? "q" : "d";
3421           ops = "vpandn%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3422         }
3423       break;
3424     default:
3425       gcc_unreachable ();
3426     }
3428   snprintf (buf, sizeof (buf), ops, suffix);
3429   return buf;
3431   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3432    (set_attr "type" "sselog")
3433    (set_attr "prefix" "orig,vex,evex,evex")
3434    (set (attr "mode")
3435         (cond [(eq_attr "alternative" "2")
3436                  (if_then_else (match_test "TARGET_AVX512DQ")
3437                                (const_string "<ssevecmode>")
3438                                (const_string "TI"))
3439                (eq_attr "alternative" "3")
3440                  (if_then_else (match_test "TARGET_AVX512DQ")
3441                                (const_string "<avx512fvecmode>")
3442                                (const_string "XI"))
3443                (and (match_test "<MODE_SIZE> == 16")
3444                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3445                  (const_string "V4SF")
3446                (match_test "TARGET_AVX")
3447                  (const_string "<ssevecmode>")
3448                (match_test "optimize_function_for_size_p (cfun)")
3449                  (const_string "V4SF")
3450                ]
3451                (const_string "<ssevecmode>")))])
3453 (define_insn "*andnottf3"
3454   [(set (match_operand:TF 0 "register_operand" "=x,x,v,v")
3455         (and:TF
3456           (not:TF (match_operand:TF 1 "register_operand" "0,x,v,v"))
3457           (match_operand:TF 2 "vector_operand" "xBm,xm,vm,v")))]
3458   "TARGET_SSE"
3460   static char buf[128];
3461   const char *ops;
3462   const char *tmp
3463     = (which_alternative >= 2 ? "pandnq"
3464        : get_attr_mode (insn) == MODE_V4SF ? "andnps" : "pandn");
3466   switch (which_alternative)
3467     {
3468     case 0:
3469       ops = "%s\t{%%2, %%0|%%0, %%2}";
3470       break;
3471     case 1:
3472     case 2:
3473       ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3474       break;
3475     case 3:
3476       ops = "v%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3477       break;
3478     default:
3479       gcc_unreachable ();
3480     }
3482   snprintf (buf, sizeof (buf), ops, tmp);
3483   return buf;
3485   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3486    (set_attr "type" "sselog")
3487    (set (attr "prefix_data16")
3488      (if_then_else
3489        (and (eq_attr "alternative" "0")
3490             (eq_attr "mode" "TI"))
3491        (const_string "1")
3492        (const_string "*")))
3493    (set_attr "prefix" "orig,vex,evex,evex")
3494    (set (attr "mode")
3495         (cond [(eq_attr "alternative" "2")
3496                  (const_string "TI")
3497                (eq_attr "alternative" "3")
3498                  (const_string "XI")
3499                (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
3500                  (const_string "V4SF")
3501                (match_test "TARGET_AVX")
3502                  (const_string "TI")
3503                (ior (not (match_test "TARGET_SSE2"))
3504                     (match_test "optimize_function_for_size_p (cfun)"))
3505                  (const_string "V4SF")
3506                ]
3507                (const_string "TI")))])
3509 (define_insn "*<code><mode>3"
3510   [(set (match_operand:MODEF 0 "register_operand" "=x,x,v,v")
3511         (any_logic:MODEF
3512           (match_operand:MODEF 1 "register_operand" "%0,x,v,v")
3513           (match_operand:MODEF 2 "register_operand" "x,x,v,v")))]
3514   "SSE_FLOAT_MODE_P (<MODE>mode)"
3516   static char buf[128];
3517   const char *ops;
3518   const char *suffix
3519     = (get_attr_mode (insn) == MODE_V4SF) ? "ps" : "<ssevecmodesuffix>";
3521   switch (which_alternative)
3522     {
3523     case 0:
3524       ops = "<logic>%s\t{%%2, %%0|%%0, %%2}";
3525       break;
3526     case 2:
3527       if (!TARGET_AVX512DQ)
3528         {
3529           suffix = <MODE>mode == DFmode ? "q" : "d";
3530           ops = "vp<logic>%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3531           break;
3532         }
3533       /* FALLTHRU */
3534     case 1:
3535       ops = "v<logic>%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3536       break;
3537     case 3:
3538       if (TARGET_AVX512DQ)
3539         ops = "v<logic>%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3540       else
3541         {
3542           suffix = <MODE>mode == DFmode ? "q" : "d";
3543           ops = "vp<logic>%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3544         }
3545       break;
3546     default:
3547       gcc_unreachable ();
3548     }
3550   snprintf (buf, sizeof (buf), ops, suffix);
3551   return buf;
3553   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3554    (set_attr "type" "sselog")
3555    (set_attr "prefix" "orig,vex,evex,evex")
3556    (set (attr "mode")
3557         (cond [(eq_attr "alternative" "2")
3558                  (if_then_else (match_test "TARGET_AVX512DQ")
3559                                (const_string "<ssevecmode>")
3560                                (const_string "TI"))
3561                (eq_attr "alternative" "3")
3562                  (if_then_else (match_test "TARGET_AVX512DQ")
3563                                (const_string "<avx512fvecmode>")
3564                                (const_string "XI"))
3565                (and (match_test "<MODE_SIZE> == 16")
3566                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3567                  (const_string "V4SF")
3568                (match_test "TARGET_AVX")
3569                  (const_string "<ssevecmode>")
3570                (match_test "optimize_function_for_size_p (cfun)")
3571                  (const_string "V4SF")
3572                ]
3573                (const_string "<ssevecmode>")))])
3575 (define_expand "<code>tf3"
3576   [(set (match_operand:TF 0 "register_operand")
3577         (any_logic:TF
3578           (match_operand:TF 1 "vector_operand")
3579           (match_operand:TF 2 "vector_operand")))]
3580   "TARGET_SSE"
3581   "ix86_fixup_binary_operands_no_copy (<CODE>, TFmode, operands);")
3583 (define_insn "*<code>tf3"
3584   [(set (match_operand:TF 0 "register_operand" "=x,x,v,v")
3585         (any_logic:TF
3586           (match_operand:TF 1 "vector_operand" "%0,x,v,v")
3587           (match_operand:TF 2 "vector_operand" "xBm,xm,vm,v")))]
3588   "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
3590   static char buf[128];
3591   const char *ops;
3592   const char *tmp
3593     = (which_alternative >= 2 ? "p<logic>q"
3594        : get_attr_mode (insn) == MODE_V4SF ? "<logic>ps" : "p<logic>");
3596   switch (which_alternative)
3597     {
3598     case 0:
3599       ops = "%s\t{%%2, %%0|%%0, %%2}";
3600       break;
3601     case 1:
3602     case 2:
3603       ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3604       break;
3605     case 3:
3606       ops = "v%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3607       break;
3608     default:
3609       gcc_unreachable ();
3610     }
3612   snprintf (buf, sizeof (buf), ops, tmp);
3613   return buf;
3615   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3616    (set_attr "type" "sselog")
3617    (set (attr "prefix_data16")
3618      (if_then_else
3619        (and (eq_attr "alternative" "0")
3620             (eq_attr "mode" "TI"))
3621        (const_string "1")
3622        (const_string "*")))
3623    (set_attr "prefix" "orig,vex,evex,evex")
3624    (set (attr "mode")
3625         (cond [(eq_attr "alternative" "2")
3626                  (const_string "TI")
3627                (eq_attr "alternative" "3")
3628                  (const_string "QI")
3629                (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
3630                  (const_string "V4SF")
3631                (match_test "TARGET_AVX")
3632                  (const_string "TI")
3633                (ior (not (match_test "TARGET_SSE2"))
3634                     (match_test "optimize_function_for_size_p (cfun)"))
3635                  (const_string "V4SF")
3636                ]
3637                (const_string "TI")))])
3639 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3641 ;; FMA floating point multiply/accumulate instructions.  These include
3642 ;; scalar versions of the instructions as well as vector versions.
3644 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3646 ;; The standard names for scalar FMA are only available with SSE math enabled.
3647 ;; CPUID bit AVX512F enables evex encoded scalar and 512-bit fma.  It doesn't
3648 ;; care about FMA bit, so we enable fma for TARGET_AVX512F even when TARGET_FMA
3649 ;; and TARGET_FMA4 are both false.
3650 ;; TODO: In theory AVX512F does not automatically imply FMA, and without FMA
3651 ;; one must force the EVEX encoding of the fma insns.  Ideally we'd improve
3652 ;; GAS to allow proper prefix selection.  However, for the moment all hardware
3653 ;; that supports AVX512F also supports FMA so we can ignore this for now.
3654 (define_mode_iterator FMAMODEM
3655   [(SF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
3656    (DF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
3657    (V4SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3658    (V2DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3659    (V8SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3660    (V4DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3661    (V16SF "TARGET_AVX512F")
3662    (V8DF "TARGET_AVX512F")])
3664 (define_expand "fma<mode>4"
3665   [(set (match_operand:FMAMODEM 0 "register_operand")
3666         (fma:FMAMODEM
3667           (match_operand:FMAMODEM 1 "nonimmediate_operand")
3668           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3669           (match_operand:FMAMODEM 3 "nonimmediate_operand")))])
3671 (define_expand "fms<mode>4"
3672   [(set (match_operand:FMAMODEM 0 "register_operand")
3673         (fma:FMAMODEM
3674           (match_operand:FMAMODEM 1 "nonimmediate_operand")
3675           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3676           (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))])
3678 (define_expand "fnma<mode>4"
3679   [(set (match_operand:FMAMODEM 0 "register_operand")
3680         (fma:FMAMODEM
3681           (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
3682           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3683           (match_operand:FMAMODEM 3 "nonimmediate_operand")))])
3685 (define_expand "fnms<mode>4"
3686   [(set (match_operand:FMAMODEM 0 "register_operand")
3687         (fma:FMAMODEM
3688           (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
3689           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3690           (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))])
3692 ;; The builtins for intrinsics are not constrained by SSE math enabled.
3693 (define_mode_iterator FMAMODE_AVX512
3694  [(SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
3695   (DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
3696   (V4SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3697   (V2DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3698   (V8SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3699   (V4DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3700   (V16SF "TARGET_AVX512F")
3701   (V8DF "TARGET_AVX512F")])
3703 (define_mode_iterator FMAMODE
3704   [SF DF V4SF V2DF V8SF V4DF])
3706 (define_expand "fma4i_fmadd_<mode>"
3707   [(set (match_operand:FMAMODE_AVX512 0 "register_operand")
3708         (fma:FMAMODE_AVX512
3709           (match_operand:FMAMODE_AVX512 1 "nonimmediate_operand")
3710           (match_operand:FMAMODE_AVX512 2 "nonimmediate_operand")
3711           (match_operand:FMAMODE_AVX512 3 "nonimmediate_operand")))])
3713 (define_expand "<avx512>_fmadd_<mode>_maskz<round_expand_name>"
3714   [(match_operand:VF_AVX512VL 0 "register_operand")
3715    (match_operand:VF_AVX512VL 1 "<round_expand_nimm_predicate>")
3716    (match_operand:VF_AVX512VL 2 "<round_expand_nimm_predicate>")
3717    (match_operand:VF_AVX512VL 3 "<round_expand_nimm_predicate>")
3718    (match_operand:<avx512fmaskmode> 4 "register_operand")]
3719   "TARGET_AVX512F && <round_mode512bit_condition>"
3721   emit_insn (gen_fma_fmadd_<mode>_maskz_1<round_expand_name> (
3722     operands[0], operands[1], operands[2], operands[3],
3723     CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
3724   DONE;
3727 (define_insn "*fma_fmadd_<mode>"
3728   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3729         (fma:FMAMODE
3730           (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x")
3731           (match_operand:FMAMODE 2 "nonimmediate_operand" "vm,v,vm,x,m")
3732           (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x")))]
3733   "TARGET_FMA || TARGET_FMA4"
3734   "@
3735    vfmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3736    vfmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3737    vfmadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3738    vfmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3739    vfmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3740   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3741    (set_attr "type" "ssemuladd")
3742    (set_attr "mode" "<MODE>")])
3744 ;; Suppose AVX-512F as baseline
3745 (define_mode_iterator VF_SF_AVX512VL
3746   [SF V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
3747    DF V8DF (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
3749 (define_insn "<sd_mask_codefor>fma_fmadd_<mode><sd_maskz_name><round_name>"
3750   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3751         (fma:VF_SF_AVX512VL
3752           (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v")
3753           (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3754           (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0")))]
3755   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3756   "@
3757    vfmadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3758    vfmadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3759    vfmadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3760   [(set_attr "type" "ssemuladd")
3761    (set_attr "mode" "<MODE>")])
3763 (define_insn "<avx512>_fmadd_<mode>_mask<round_name>"
3764   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3765         (vec_merge:VF_AVX512VL
3766           (fma:VF_AVX512VL
3767             (match_operand:VF_AVX512VL 1 "register_operand" "0,0")
3768             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3769             (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))
3770           (match_dup 1)
3771           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3772   "TARGET_AVX512F && <round_mode512bit_condition>"
3773   "@
3774    vfmadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3775    vfmadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3776   [(set_attr "type" "ssemuladd")
3777    (set_attr "mode" "<MODE>")])
3779 (define_insn "<avx512>_fmadd_<mode>_mask3<round_name>"
3780   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3781         (vec_merge:VF_AVX512VL
3782           (fma:VF_AVX512VL
3783             (match_operand:VF_AVX512VL 1 "register_operand" "v")
3784             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3785             (match_operand:VF_AVX512VL 3 "register_operand" "0"))
3786           (match_dup 3)
3787           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3788   "TARGET_AVX512F"
3789   "vfmadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3790   [(set_attr "type" "ssemuladd")
3791    (set_attr "mode" "<MODE>")])
3793 (define_insn "*fma_fmsub_<mode>"
3794   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3795         (fma:FMAMODE
3796           (match_operand:FMAMODE   1 "nonimmediate_operand" "%0,0,v,x,x")
3797           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
3798           (neg:FMAMODE
3799             (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x"))))]
3800   "TARGET_FMA || TARGET_FMA4"
3801   "@
3802    vfmsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3803    vfmsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3804    vfmsub231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3805    vfmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3806    vfmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3807   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3808    (set_attr "type" "ssemuladd")
3809    (set_attr "mode" "<MODE>")])
3811 (define_insn "<sd_mask_codefor>fma_fmsub_<mode><sd_maskz_name><round_name>"
3812   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3813         (fma:VF_SF_AVX512VL
3814           (match_operand:VF_SF_AVX512VL   1 "<round_nimm_predicate>" "%0,0,v")
3815           (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3816           (neg:VF_SF_AVX512VL
3817             (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))))]
3818   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3819   "@
3820    vfmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3821    vfmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3822    vfmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3823   [(set_attr "type" "ssemuladd")
3824    (set_attr "mode" "<MODE>")])
3826 (define_insn "<avx512>_fmsub_<mode>_mask<round_name>"
3827   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3828         (vec_merge:VF_AVX512VL
3829           (fma:VF_AVX512VL
3830             (match_operand:VF_AVX512VL 1 "register_operand" "0,0")
3831             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3832             (neg:VF_AVX512VL
3833               (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")))
3834           (match_dup 1)
3835           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3836   "TARGET_AVX512F"
3837   "@
3838    vfmsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3839    vfmsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3840   [(set_attr "type" "ssemuladd")
3841    (set_attr "mode" "<MODE>")])
3843 (define_insn "<avx512>_fmsub_<mode>_mask3<round_name>"
3844   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3845         (vec_merge:VF_AVX512VL
3846           (fma:VF_AVX512VL
3847             (match_operand:VF_AVX512VL 1 "register_operand" "v")
3848             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3849             (neg:VF_AVX512VL
3850               (match_operand:VF_AVX512VL 3 "register_operand" "0")))
3851           (match_dup 3)
3852           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3853   "TARGET_AVX512F && <round_mode512bit_condition>"
3854   "vfmsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3855   [(set_attr "type" "ssemuladd")
3856    (set_attr "mode" "<MODE>")])
3858 (define_insn "*fma_fnmadd_<mode>"
3859   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3860         (fma:FMAMODE
3861           (neg:FMAMODE
3862             (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x"))
3863           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
3864           (match_operand:FMAMODE   3 "nonimmediate_operand" "v,vm,0,xm,x")))]
3865   "TARGET_FMA || TARGET_FMA4"
3866   "@
3867    vfnmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3868    vfnmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3869    vfnmadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3870    vfnmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3871    vfnmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3872   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3873    (set_attr "type" "ssemuladd")
3874    (set_attr "mode" "<MODE>")])
3876 (define_insn "<sd_mask_codefor>fma_fnmadd_<mode><sd_maskz_name><round_name>"
3877   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3878         (fma:VF_SF_AVX512VL
3879           (neg:VF_SF_AVX512VL
3880             (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v"))
3881           (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3882           (match_operand:VF_SF_AVX512VL   3 "<round_nimm_predicate>" "v,<round_constraint>,0")))]
3883   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3884   "@
3885    vfnmadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3886    vfnmadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3887    vfnmadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3888   [(set_attr "type" "ssemuladd")
3889    (set_attr "mode" "<MODE>")])
3891 (define_insn "<avx512>_fnmadd_<mode>_mask<round_name>"
3892   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3893         (vec_merge:VF_AVX512VL
3894           (fma:VF_AVX512VL
3895             (neg:VF_AVX512VL
3896               (match_operand:VF_AVX512VL 1 "register_operand" "0,0"))
3897             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3898             (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))
3899           (match_dup 1)
3900           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3901   "TARGET_AVX512F && <round_mode512bit_condition>"
3902   "@
3903    vfnmadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3904    vfnmadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3905   [(set_attr "type" "ssemuladd")
3906    (set_attr "mode" "<MODE>")])
3908 (define_insn "<avx512>_fnmadd_<mode>_mask3<round_name>"
3909   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3910         (vec_merge:VF_AVX512VL
3911           (fma:VF_AVX512VL
3912             (neg:VF_AVX512VL
3913               (match_operand:VF_AVX512VL 1 "register_operand" "v"))
3914             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3915             (match_operand:VF_AVX512VL 3 "register_operand" "0"))
3916           (match_dup 3)
3917           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3918   "TARGET_AVX512F && <round_mode512bit_condition>"
3919   "vfnmadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3920   [(set_attr "type" "ssemuladd")
3921    (set_attr "mode" "<MODE>")])
3923 (define_insn "*fma_fnmsub_<mode>"
3924   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3925         (fma:FMAMODE
3926           (neg:FMAMODE
3927             (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x"))
3928           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
3929           (neg:FMAMODE
3930             (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x"))))]
3931   "TARGET_FMA || TARGET_FMA4"
3932   "@
3933    vfnmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3934    vfnmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3935    vfnmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}
3936    vfnmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3937    vfnmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3938   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3939    (set_attr "type" "ssemuladd")
3940    (set_attr "mode" "<MODE>")])
3942 (define_insn "<sd_mask_codefor>fma_fnmsub_<mode><sd_maskz_name><round_name>"
3943   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3944         (fma:VF_SF_AVX512VL
3945           (neg:VF_SF_AVX512VL
3946             (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v"))
3947           (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3948           (neg:VF_SF_AVX512VL
3949             (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))))]
3950   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3951   "@
3952    vfnmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3953    vfnmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3954    vfnmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3955   [(set_attr "type" "ssemuladd")
3956    (set_attr "mode" "<MODE>")])
3958 (define_insn "<avx512>_fnmsub_<mode>_mask<round_name>"
3959   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3960         (vec_merge:VF_AVX512VL
3961           (fma:VF_AVX512VL
3962             (neg:VF_AVX512VL
3963               (match_operand:VF_AVX512VL 1 "register_operand" "0,0"))
3964             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3965             (neg:VF_AVX512VL
3966               (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")))
3967           (match_dup 1)
3968           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3969   "TARGET_AVX512F && <round_mode512bit_condition>"
3970   "@
3971    vfnmsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3972    vfnmsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3973   [(set_attr "type" "ssemuladd")
3974    (set_attr "mode" "<MODE>")])
3976 (define_insn "<avx512>_fnmsub_<mode>_mask3<round_name>"
3977   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3978         (vec_merge:VF_AVX512VL
3979           (fma:VF_AVX512VL
3980             (neg:VF_AVX512VL
3981               (match_operand:VF_AVX512VL 1 "register_operand" "v"))
3982             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3983             (neg:VF_AVX512VL
3984               (match_operand:VF_AVX512VL 3 "register_operand" "0")))
3985           (match_dup 3)
3986           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3987   "TARGET_AVX512F"
3988   "vfnmsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3989   [(set_attr "type" "ssemuladd")
3990    (set_attr "mode" "<MODE>")])
3992 ;; FMA parallel floating point multiply addsub and subadd operations.
3994 ;; It would be possible to represent these without the UNSPEC as
3996 ;; (vec_merge
3997 ;;   (fma op1 op2 op3)
3998 ;;   (fma op1 op2 (neg op3))
3999 ;;   (merge-const))
4001 ;; But this doesn't seem useful in practice.
4003 (define_expand "fmaddsub_<mode>"
4004   [(set (match_operand:VF 0 "register_operand")
4005         (unspec:VF
4006           [(match_operand:VF 1 "nonimmediate_operand")
4007            (match_operand:VF 2 "nonimmediate_operand")
4008            (match_operand:VF 3 "nonimmediate_operand")]
4009           UNSPEC_FMADDSUB))]
4010   "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
4012 (define_expand "<avx512>_fmaddsub_<mode>_maskz<round_expand_name>"
4013   [(match_operand:VF_AVX512VL 0 "register_operand")
4014    (match_operand:VF_AVX512VL 1 "<round_expand_nimm_predicate>")
4015    (match_operand:VF_AVX512VL 2 "<round_expand_nimm_predicate>")
4016    (match_operand:VF_AVX512VL 3 "<round_expand_nimm_predicate>")
4017    (match_operand:<avx512fmaskmode> 4 "register_operand")]
4018   "TARGET_AVX512F"
4020   emit_insn (gen_fma_fmaddsub_<mode>_maskz_1<round_expand_name> (
4021     operands[0], operands[1], operands[2], operands[3],
4022     CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
4023   DONE;
4026 (define_insn "*fma_fmaddsub_<mode>"
4027   [(set (match_operand:VF_128_256 0 "register_operand" "=v,v,v,x,x")
4028         (unspec:VF_128_256
4029           [(match_operand:VF_128_256 1 "nonimmediate_operand" "%0,0,v,x,x")
4030            (match_operand:VF_128_256 2 "nonimmediate_operand" "vm,v,vm,x,m")
4031            (match_operand:VF_128_256 3 "nonimmediate_operand" "v,vm,0,xm,x")]
4032           UNSPEC_FMADDSUB))]
4033   "TARGET_FMA || TARGET_FMA4"
4034   "@
4035    vfmaddsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
4036    vfmaddsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
4037    vfmaddsub231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
4038    vfmaddsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
4039    vfmaddsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4040   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
4041    (set_attr "type" "ssemuladd")
4042    (set_attr "mode" "<MODE>")])
4044 (define_insn "<sd_mask_codefor>fma_fmaddsub_<mode><sd_maskz_name><round_name>"
4045   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
4046         (unspec:VF_SF_AVX512VL
4047           [(match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v")
4048            (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
4049            (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0")]
4050           UNSPEC_FMADDSUB))]
4051   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
4052   "@
4053    vfmaddsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
4054    vfmaddsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
4055    vfmaddsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
4056   [(set_attr "type" "ssemuladd")
4057    (set_attr "mode" "<MODE>")])
4059 (define_insn "<avx512>_fmaddsub_<mode>_mask<round_name>"
4060   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
4061         (vec_merge:VF_AVX512VL
4062           (unspec:VF_AVX512VL
4063             [(match_operand:VF_AVX512VL 1 "register_operand" "0,0")
4064              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
4065              (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")]
4066             UNSPEC_FMADDSUB)
4067           (match_dup 1)
4068           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
4069   "TARGET_AVX512F"
4070   "@
4071    vfmaddsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
4072    vfmaddsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
4073   [(set_attr "type" "ssemuladd")
4074    (set_attr "mode" "<MODE>")])
4076 (define_insn "<avx512>_fmaddsub_<mode>_mask3<round_name>"
4077   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
4078         (vec_merge:VF_AVX512VL
4079           (unspec:VF_AVX512VL
4080             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
4081              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
4082              (match_operand:VF_AVX512VL 3 "register_operand" "0")]
4083             UNSPEC_FMADDSUB)
4084           (match_dup 3)
4085           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
4086   "TARGET_AVX512F"
4087   "vfmaddsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
4088   [(set_attr "type" "ssemuladd")
4089    (set_attr "mode" "<MODE>")])
4091 (define_insn "*fma_fmsubadd_<mode>"
4092   [(set (match_operand:VF_128_256 0 "register_operand" "=v,v,v,x,x")
4093         (unspec:VF_128_256
4094           [(match_operand:VF_128_256   1 "nonimmediate_operand" "%0,0,v,x,x")
4095            (match_operand:VF_128_256   2 "nonimmediate_operand" "vm,v,vm,x,m")
4096            (neg:VF_128_256
4097              (match_operand:VF_128_256 3 "nonimmediate_operand" "v,vm,0,xm,x"))]
4098           UNSPEC_FMADDSUB))]
4099   "TARGET_FMA || TARGET_FMA4"
4100   "@
4101    vfmsubadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
4102    vfmsubadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
4103    vfmsubadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
4104    vfmsubadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
4105    vfmsubadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4106   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
4107    (set_attr "type" "ssemuladd")
4108    (set_attr "mode" "<MODE>")])
4110 (define_insn "<sd_mask_codefor>fma_fmsubadd_<mode><sd_maskz_name><round_name>"
4111   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
4112         (unspec:VF_SF_AVX512VL
4113           [(match_operand:VF_SF_AVX512VL   1 "<round_nimm_predicate>" "%0,0,v")
4114            (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
4115            (neg:VF_SF_AVX512VL
4116              (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))]
4117           UNSPEC_FMADDSUB))]
4118   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
4119   "@
4120    vfmsubadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
4121    vfmsubadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
4122    vfmsubadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
4123   [(set_attr "type" "ssemuladd")
4124    (set_attr "mode" "<MODE>")])
4126 (define_insn "<avx512>_fmsubadd_<mode>_mask<round_name>"
4127   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
4128         (vec_merge:VF_AVX512VL
4129           (unspec:VF_AVX512VL
4130             [(match_operand:VF_AVX512VL 1 "register_operand" "0,0")
4131              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
4132              (neg:VF_AVX512VL
4133                (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))]
4134             UNSPEC_FMADDSUB)
4135           (match_dup 1)
4136           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
4137   "TARGET_AVX512F"
4138   "@
4139    vfmsubadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
4140    vfmsubadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
4141   [(set_attr "type" "ssemuladd")
4142    (set_attr "mode" "<MODE>")])
4144 (define_insn "<avx512>_fmsubadd_<mode>_mask3<round_name>"
4145   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
4146         (vec_merge:VF_AVX512VL
4147           (unspec:VF_AVX512VL
4148             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
4149              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
4150              (neg:VF_AVX512VL
4151                (match_operand:VF_AVX512VL 3 "register_operand" "0"))]
4152             UNSPEC_FMADDSUB)
4153           (match_dup 3)
4154           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
4155   "TARGET_AVX512F"
4156   "vfmsubadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
4157   [(set_attr "type" "ssemuladd")
4158    (set_attr "mode" "<MODE>")])
4160 ;; FMA3 floating point scalar intrinsics. These merge result with
4161 ;; high-order elements from the destination register.
4163 (define_expand "fmai_vmfmadd_<mode><round_name>"
4164   [(set (match_operand:VF_128 0 "register_operand")
4165         (vec_merge:VF_128
4166           (fma:VF_128
4167             (match_operand:VF_128 1 "<round_nimm_predicate>")
4168             (match_operand:VF_128 2 "<round_nimm_predicate>")
4169             (match_operand:VF_128 3 "<round_nimm_predicate>"))
4170           (match_dup 1)
4171           (const_int 1)))]
4172   "TARGET_FMA")
4174 (define_insn "*fmai_fmadd_<mode>"
4175   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4176         (vec_merge:VF_128
4177           (fma:VF_128
4178             (match_operand:VF_128 1 "<round_nimm_predicate>" " 0, 0")
4179             (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>, v")
4180             (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>"))
4181           (match_dup 1)
4182           (const_int 1)))]
4183   "TARGET_FMA || TARGET_AVX512F"
4184   "@
4185    vfmadd132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4186    vfmadd213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4187   [(set_attr "type" "ssemuladd")
4188    (set_attr "mode" "<MODE>")])
4190 (define_insn "*fmai_fmsub_<mode>"
4191   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4192         (vec_merge:VF_128
4193           (fma:VF_128
4194             (match_operand:VF_128   1 "<round_nimm_predicate>" "0,0")
4195             (match_operand:VF_128   2 "<round_nimm_predicate>" "<round_constraint>,v")
4196             (neg:VF_128
4197               (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>")))
4198           (match_dup 1)
4199           (const_int 1)))]
4200   "TARGET_FMA || TARGET_AVX512F"
4201   "@
4202    vfmsub132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4203    vfmsub213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4204   [(set_attr "type" "ssemuladd")
4205    (set_attr "mode" "<MODE>")])
4207 (define_insn "*fmai_fnmadd_<mode><round_name>"
4208   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4209         (vec_merge:VF_128
4210           (fma:VF_128
4211             (neg:VF_128
4212               (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>,v"))
4213             (match_operand:VF_128   1 "<round_nimm_predicate>" "0,0")
4214             (match_operand:VF_128   3 "<round_nimm_predicate>" "v,<round_constraint>"))
4215           (match_dup 1)
4216           (const_int 1)))]
4217   "TARGET_FMA || TARGET_AVX512F"
4218   "@
4219    vfnmadd132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4220    vfnmadd213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4221   [(set_attr "type" "ssemuladd")
4222    (set_attr "mode" "<MODE>")])
4224 (define_insn "*fmai_fnmsub_<mode><round_name>"
4225   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4226         (vec_merge:VF_128
4227           (fma:VF_128
4228             (neg:VF_128
4229               (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>, v"))
4230             (match_operand:VF_128   1 "<round_nimm_predicate>" " 0, 0")
4231             (neg:VF_128
4232               (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>")))
4233           (match_dup 1)
4234           (const_int 1)))]
4235   "TARGET_FMA || TARGET_AVX512F"
4236   "@
4237    vfnmsub132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4238    vfnmsub213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4239   [(set_attr "type" "ssemuladd")
4240    (set_attr "mode" "<MODE>")])
4242 ;; FMA4 floating point scalar intrinsics.  These write the
4243 ;; entire destination register, with the high-order elements zeroed.
4245 (define_expand "fma4i_vmfmadd_<mode>"
4246   [(set (match_operand:VF_128 0 "register_operand")
4247         (vec_merge:VF_128
4248           (fma:VF_128
4249             (match_operand:VF_128 1 "nonimmediate_operand")
4250             (match_operand:VF_128 2 "nonimmediate_operand")
4251             (match_operand:VF_128 3 "nonimmediate_operand"))
4252           (match_dup 4)
4253           (const_int 1)))]
4254   "TARGET_FMA4"
4255   "operands[4] = CONST0_RTX (<MODE>mode);")
4257 (define_insn "*fma4i_vmfmadd_<mode>"
4258   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4259         (vec_merge:VF_128
4260           (fma:VF_128
4261             (match_operand:VF_128 1 "nonimmediate_operand" "%x,x")
4262             (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
4263             (match_operand:VF_128 3 "nonimmediate_operand" "xm,x"))
4264           (match_operand:VF_128 4 "const0_operand")
4265           (const_int 1)))]
4266   "TARGET_FMA4"
4267   "vfmadd<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4268   [(set_attr "type" "ssemuladd")
4269    (set_attr "mode" "<MODE>")])
4271 (define_insn "*fma4i_vmfmsub_<mode>"
4272   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4273         (vec_merge:VF_128
4274           (fma:VF_128
4275             (match_operand:VF_128 1 "nonimmediate_operand" "%x,x")
4276             (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
4277             (neg:VF_128
4278               (match_operand:VF_128 3 "nonimmediate_operand" "xm,x")))
4279           (match_operand:VF_128 4 "const0_operand")
4280           (const_int 1)))]
4281   "TARGET_FMA4"
4282   "vfmsub<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4283   [(set_attr "type" "ssemuladd")
4284    (set_attr "mode" "<MODE>")])
4286 (define_insn "*fma4i_vmfnmadd_<mode>"
4287   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4288         (vec_merge:VF_128
4289           (fma:VF_128
4290             (neg:VF_128
4291               (match_operand:VF_128 1 "nonimmediate_operand" "%x,x"))
4292             (match_operand:VF_128   2 "nonimmediate_operand" " x,m")
4293             (match_operand:VF_128   3 "nonimmediate_operand" "xm,x"))
4294           (match_operand:VF_128 4 "const0_operand")
4295           (const_int 1)))]
4296   "TARGET_FMA4"
4297   "vfnmadd<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4298   [(set_attr "type" "ssemuladd")
4299    (set_attr "mode" "<MODE>")])
4301 (define_insn "*fma4i_vmfnmsub_<mode>"
4302   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4303         (vec_merge:VF_128
4304           (fma:VF_128
4305             (neg:VF_128
4306               (match_operand:VF_128 1 "nonimmediate_operand" "%x,x"))
4307             (match_operand:VF_128   2 "nonimmediate_operand" " x,m")
4308             (neg:VF_128
4309               (match_operand:VF_128   3 "nonimmediate_operand" "xm,x")))
4310           (match_operand:VF_128 4 "const0_operand")
4311           (const_int 1)))]
4312   "TARGET_FMA4"
4313   "vfnmsub<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4314   [(set_attr "type" "ssemuladd")
4315    (set_attr "mode" "<MODE>")])
4317 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4319 ;; Parallel single-precision floating point conversion operations
4321 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4323 (define_insn "sse_cvtpi2ps"
4324   [(set (match_operand:V4SF 0 "register_operand" "=x")
4325         (vec_merge:V4SF
4326           (vec_duplicate:V4SF
4327             (float:V2SF (match_operand:V2SI 2 "nonimmediate_operand" "ym")))
4328           (match_operand:V4SF 1 "register_operand" "0")
4329           (const_int 3)))]
4330   "TARGET_SSE"
4331   "cvtpi2ps\t{%2, %0|%0, %2}"
4332   [(set_attr "type" "ssecvt")
4333    (set_attr "mode" "V4SF")])
4335 (define_insn "sse_cvtps2pi"
4336   [(set (match_operand:V2SI 0 "register_operand" "=y")
4337         (vec_select:V2SI
4338           (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
4339                        UNSPEC_FIX_NOTRUNC)
4340           (parallel [(const_int 0) (const_int 1)])))]
4341   "TARGET_SSE"
4342   "cvtps2pi\t{%1, %0|%0, %q1}"
4343   [(set_attr "type" "ssecvt")
4344    (set_attr "unit" "mmx")
4345    (set_attr "mode" "DI")])
4347 (define_insn "sse_cvttps2pi"
4348   [(set (match_operand:V2SI 0 "register_operand" "=y")
4349         (vec_select:V2SI
4350           (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
4351           (parallel [(const_int 0) (const_int 1)])))]
4352   "TARGET_SSE"
4353   "cvttps2pi\t{%1, %0|%0, %q1}"
4354   [(set_attr "type" "ssecvt")
4355    (set_attr "unit" "mmx")
4356    (set_attr "prefix_rep" "0")
4357    (set_attr "mode" "SF")])
4359 (define_insn "sse_cvtsi2ss<rex64namesuffix><round_name>"
4360   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
4361         (vec_merge:V4SF
4362           (vec_duplicate:V4SF
4363             (float:SF (match_operand:SWI48 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
4364           (match_operand:V4SF 1 "register_operand" "0,0,v")
4365           (const_int 1)))]
4366   "TARGET_SSE"
4367   "@
4368    cvtsi2ss<rex64suffix>\t{%2, %0|%0, %2}
4369    cvtsi2ss<rex64suffix>\t{%2, %0|%0, %2}
4370    vcvtsi2ss<rex64suffix>\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4371   [(set_attr "isa" "noavx,noavx,avx")
4372    (set_attr "type" "sseicvt")
4373    (set_attr "athlon_decode" "vector,double,*")
4374    (set_attr "amdfam10_decode" "vector,double,*")
4375    (set_attr "bdver1_decode" "double,direct,*")
4376    (set_attr "btver2_decode" "double,double,double")
4377    (set_attr "znver1_decode" "double,double,double")
4378    (set (attr "length_vex")
4379         (if_then_else
4380           (and (match_test "<MODE>mode == DImode")
4381                (eq_attr "alternative" "2"))
4382           (const_string "4")
4383           (const_string "*")))
4384    (set (attr "prefix_rex")
4385         (if_then_else
4386           (and (match_test "<MODE>mode == DImode")
4387                (eq_attr "alternative" "0,1"))
4388           (const_string "1")
4389           (const_string "*")))
4390    (set_attr "prefix" "orig,orig,maybe_evex")
4391    (set_attr "mode" "SF")])
4393 (define_insn "sse_cvtss2si<rex64namesuffix><round_name>"
4394   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
4395         (unspec:SWI48
4396           [(vec_select:SF
4397              (match_operand:V4SF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4398              (parallel [(const_int 0)]))]
4399           UNSPEC_FIX_NOTRUNC))]
4400   "TARGET_SSE"
4401   "%vcvtss2si<rex64suffix>\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
4402   [(set_attr "type" "sseicvt")
4403    (set_attr "athlon_decode" "double,vector")
4404    (set_attr "bdver1_decode" "double,double")
4405    (set_attr "prefix_rep" "1")
4406    (set_attr "prefix" "maybe_vex")
4407    (set_attr "mode" "<MODE>")])
4409 (define_insn "sse_cvtss2si<rex64namesuffix>_2"
4410   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
4411         (unspec:SWI48 [(match_operand:SF 1 "nonimmediate_operand" "v,m")]
4412                       UNSPEC_FIX_NOTRUNC))]
4413   "TARGET_SSE"
4414   "%vcvtss2si<rex64suffix>\t{%1, %0|%0, %k1}"
4415   [(set_attr "type" "sseicvt")
4416    (set_attr "athlon_decode" "double,vector")
4417    (set_attr "amdfam10_decode" "double,double")
4418    (set_attr "bdver1_decode" "double,double")
4419    (set_attr "prefix_rep" "1")
4420    (set_attr "prefix" "maybe_vex")
4421    (set_attr "mode" "<MODE>")])
4423 (define_insn "sse_cvttss2si<rex64namesuffix><round_saeonly_name>"
4424   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
4425         (fix:SWI48
4426           (vec_select:SF
4427             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint>")
4428             (parallel [(const_int 0)]))))]
4429   "TARGET_SSE"
4430   "%vcvttss2si<rex64suffix>\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
4431   [(set_attr "type" "sseicvt")
4432    (set_attr "athlon_decode" "double,vector")
4433    (set_attr "amdfam10_decode" "double,double")
4434    (set_attr "bdver1_decode" "double,double")
4435    (set_attr "prefix_rep" "1")
4436    (set_attr "prefix" "maybe_vex")
4437    (set_attr "mode" "<MODE>")])
4439 (define_insn "cvtusi2<ssescalarmodesuffix>32<round_name>"
4440   [(set (match_operand:VF_128 0 "register_operand" "=v")
4441         (vec_merge:VF_128
4442           (vec_duplicate:VF_128
4443             (unsigned_float:<ssescalarmode>
4444               (match_operand:SI 2 "<round_nimm_predicate>" "<round_constraint3>")))
4445           (match_operand:VF_128 1 "register_operand" "v")
4446           (const_int 1)))]
4447   "TARGET_AVX512F && <round_modev4sf_condition>"
4448   "vcvtusi2<ssescalarmodesuffix>\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4449   [(set_attr "type" "sseicvt")
4450    (set_attr "prefix" "evex")
4451    (set_attr "mode" "<ssescalarmode>")])
4453 (define_insn "cvtusi2<ssescalarmodesuffix>64<round_name>"
4454   [(set (match_operand:VF_128 0 "register_operand" "=v")
4455         (vec_merge:VF_128
4456           (vec_duplicate:VF_128
4457             (unsigned_float:<ssescalarmode>
4458               (match_operand:DI 2 "<round_nimm_predicate>" "<round_constraint3>")))
4459           (match_operand:VF_128 1 "register_operand" "v")
4460           (const_int 1)))]
4461   "TARGET_AVX512F && TARGET_64BIT"
4462   "vcvtusi2<ssescalarmodesuffix>{q}\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4463   [(set_attr "type" "sseicvt")
4464    (set_attr "prefix" "evex")
4465    (set_attr "mode" "<ssescalarmode>")])
4467 (define_insn "float<sseintvecmodelower><mode>2<mask_name><round_name>"
4468   [(set (match_operand:VF1 0 "register_operand" "=x,v")
4469         (float:VF1
4470           (match_operand:<sseintvecmode> 1 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
4471   "TARGET_SSE2 && <mask_mode512bit_condition> && <round_mode512bit_condition>"
4472   "@
4473    cvtdq2ps\t{%1, %0|%0, %1}
4474    vcvtdq2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4475   [(set_attr "isa" "noavx,avx")
4476    (set_attr "type" "ssecvt")
4477    (set_attr "prefix" "maybe_vex")
4478    (set_attr "mode" "<sseinsnmode>")])
4480 (define_insn "ufloat<sseintvecmodelower><mode>2<mask_name><round_name>"
4481   [(set (match_operand:VF1_AVX512VL 0 "register_operand" "=v")
4482         (unsigned_float:VF1_AVX512VL
4483           (match_operand:<sseintvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
4484   "TARGET_AVX512F"
4485   "vcvtudq2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4486   [(set_attr "type" "ssecvt")
4487    (set_attr "prefix" "evex")
4488    (set_attr "mode" "<MODE>")])
4490 (define_expand "floatuns<sseintvecmodelower><mode>2"
4491   [(match_operand:VF1 0 "register_operand")
4492    (match_operand:<sseintvecmode> 1 "register_operand")]
4493   "TARGET_SSE2 && (<MODE>mode == V4SFmode || TARGET_AVX2)"
4495   if (<MODE>mode == V16SFmode)
4496     emit_insn (gen_ufloatv16siv16sf2 (operands[0], operands[1]));
4497   else
4498     if (TARGET_AVX512VL)
4499       {
4500         if (<MODE>mode == V4SFmode)
4501           emit_insn (gen_ufloatv4siv4sf2 (operands[0], operands[1]));
4502         else
4503           emit_insn (gen_ufloatv8siv8sf2 (operands[0], operands[1]));
4504       }
4505   else
4506     ix86_expand_vector_convert_uns_vsivsf (operands[0], operands[1]);
4508   DONE;
4512 ;; For <sse2_avx_avx512f>_fix_notrunc<sf2simodelower><mode> insn pattern
4513 (define_mode_attr sf2simodelower
4514   [(V16SI "v16sf") (V8SI "v8sf") (V4SI "v4sf")])
4516 (define_insn "<sse2_avx_avx512f>_fix_notrunc<sf2simodelower><mode><mask_name>"
4517   [(set (match_operand:VI4_AVX 0 "register_operand" "=v")
4518         (unspec:VI4_AVX
4519           [(match_operand:<ssePSmode> 1 "vector_operand" "vBm")]
4520           UNSPEC_FIX_NOTRUNC))]
4521   "TARGET_SSE2 && <mask_mode512bit_condition>"
4522   "%vcvtps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4523   [(set_attr "type" "ssecvt")
4524    (set (attr "prefix_data16")
4525      (if_then_else
4526        (match_test "TARGET_AVX")
4527      (const_string "*")
4528      (const_string "1")))
4529    (set_attr "prefix" "maybe_vex")
4530    (set_attr "mode" "<sseinsnmode>")])
4532 (define_insn "avx512f_fix_notruncv16sfv16si<mask_name><round_name>"
4533   [(set (match_operand:V16SI 0 "register_operand" "=v")
4534         (unspec:V16SI
4535           [(match_operand:V16SF 1 "<round_nimm_predicate>" "<round_constraint>")]
4536           UNSPEC_FIX_NOTRUNC))]
4537   "TARGET_AVX512F"
4538   "vcvtps2dq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4539   [(set_attr "type" "ssecvt")
4540    (set_attr "prefix" "evex")
4541    (set_attr "mode" "XI")])
4543 (define_insn "<mask_codefor><avx512>_ufix_notrunc<sf2simodelower><mode><mask_name><round_name>"
4544   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
4545         (unspec:VI4_AVX512VL
4546           [(match_operand:<ssePSmode> 1 "nonimmediate_operand" "<round_constraint>")]
4547           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4548   "TARGET_AVX512F"
4549   "vcvtps2udq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4550   [(set_attr "type" "ssecvt")
4551    (set_attr "prefix" "evex")
4552    (set_attr "mode" "<sseinsnmode>")])
4554 (define_insn "<mask_codefor>avx512dq_cvtps2qq<mode><mask_name><round_name>"
4555   [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
4556         (unspec:VI8_256_512 [(match_operand:<ssePSmode2> 1 "nonimmediate_operand" "<round_constraint>")]
4557                      UNSPEC_FIX_NOTRUNC))]
4558   "TARGET_AVX512DQ && <round_mode512bit_condition>"
4559   "vcvtps2qq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4560   [(set_attr "type" "ssecvt")
4561    (set_attr "prefix" "evex")
4562    (set_attr "mode" "<sseinsnmode>")])
4564 (define_insn "<mask_codefor>avx512dq_cvtps2qqv2di<mask_name>"
4565   [(set (match_operand:V2DI 0 "register_operand" "=v")
4566         (unspec:V2DI
4567           [(vec_select:V2SF
4568              (match_operand:V4SF 1 "nonimmediate_operand" "vm")
4569              (parallel [(const_int 0) (const_int 1)]))]
4570           UNSPEC_FIX_NOTRUNC))]
4571   "TARGET_AVX512DQ && TARGET_AVX512VL"
4572   "vcvtps2qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
4573   [(set_attr "type" "ssecvt")
4574    (set_attr "prefix" "evex")
4575    (set_attr "mode" "TI")])
4577 (define_insn "<mask_codefor>avx512dq_cvtps2uqq<mode><mask_name><round_name>"
4578   [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
4579         (unspec:VI8_256_512 [(match_operand:<ssePSmode2> 1 "nonimmediate_operand" "<round_constraint>")]
4580                      UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4581   "TARGET_AVX512DQ && <round_mode512bit_condition>"
4582   "vcvtps2uqq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4583   [(set_attr "type" "ssecvt")
4584    (set_attr "prefix" "evex")
4585    (set_attr "mode" "<sseinsnmode>")])
4587 (define_insn "<mask_codefor>avx512dq_cvtps2uqqv2di<mask_name>"
4588   [(set (match_operand:V2DI 0 "register_operand" "=v")
4589         (unspec:V2DI
4590           [(vec_select:V2SF
4591              (match_operand:V4SF 1 "nonimmediate_operand" "vm")
4592              (parallel [(const_int 0) (const_int 1)]))]
4593           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4594   "TARGET_AVX512DQ && TARGET_AVX512VL"
4595   "vcvtps2uqq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
4596   [(set_attr "type" "ssecvt")
4597    (set_attr "prefix" "evex")
4598    (set_attr "mode" "TI")])
4600 (define_insn "<fixsuffix>fix_truncv16sfv16si2<mask_name><round_saeonly_name>"
4601   [(set (match_operand:V16SI 0 "register_operand" "=v")
4602         (any_fix:V16SI
4603           (match_operand:V16SF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
4604   "TARGET_AVX512F"
4605   "vcvttps2<fixsuffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
4606   [(set_attr "type" "ssecvt")
4607    (set_attr "prefix" "evex")
4608    (set_attr "mode" "XI")])
4610 (define_insn "fix_truncv8sfv8si2<mask_name>"
4611   [(set (match_operand:V8SI 0 "register_operand" "=v")
4612         (fix:V8SI (match_operand:V8SF 1 "nonimmediate_operand" "vm")))]
4613   "TARGET_AVX && <mask_avx512vl_condition>"
4614   "vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4615   [(set_attr "type" "ssecvt")
4616    (set_attr "prefix" "<mask_prefix>")
4617    (set_attr "mode" "OI")])
4619 (define_insn "fix_truncv4sfv4si2<mask_name>"
4620   [(set (match_operand:V4SI 0 "register_operand" "=v")
4621         (fix:V4SI (match_operand:V4SF 1 "vector_operand" "vBm")))]
4622   "TARGET_SSE2 && <mask_avx512vl_condition>"
4623   "%vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4624   [(set_attr "type" "ssecvt")
4625    (set (attr "prefix_rep")
4626      (if_then_else
4627        (match_test "TARGET_AVX")
4628      (const_string "*")
4629      (const_string "1")))
4630    (set (attr "prefix_data16")
4631      (if_then_else
4632        (match_test "TARGET_AVX")
4633      (const_string "*")
4634      (const_string "0")))
4635    (set_attr "prefix_data16" "0")
4636    (set_attr "prefix" "<mask_prefix2>")
4637    (set_attr "mode" "TI")])
4639 (define_expand "fixuns_trunc<mode><sseintvecmodelower>2"
4640   [(match_operand:<sseintvecmode> 0 "register_operand")
4641    (match_operand:VF1 1 "register_operand")]
4642   "TARGET_SSE2"
4644   if (<MODE>mode == V16SFmode)
4645     emit_insn (gen_ufix_truncv16sfv16si2 (operands[0],
4646                                           operands[1]));
4647   else
4648     {
4649       rtx tmp[3];
4650       tmp[0] = ix86_expand_adjust_ufix_to_sfix_si (operands[1], &tmp[2]);
4651       tmp[1] = gen_reg_rtx (<sseintvecmode>mode);
4652       emit_insn (gen_fix_trunc<mode><sseintvecmodelower>2 (tmp[1], tmp[0]));
4653       emit_insn (gen_xor<sseintvecmodelower>3 (operands[0], tmp[1], tmp[2]));
4654     }
4655   DONE;
4658 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4660 ;; Parallel double-precision floating point conversion operations
4662 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4664 (define_insn "sse2_cvtpi2pd"
4665   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
4666         (float:V2DF (match_operand:V2SI 1 "nonimmediate_operand" "y,m")))]
4667   "TARGET_SSE2"
4668   "cvtpi2pd\t{%1, %0|%0, %1}"
4669   [(set_attr "type" "ssecvt")
4670    (set_attr "unit" "mmx,*")
4671    (set_attr "prefix_data16" "1,*")
4672    (set_attr "mode" "V2DF")])
4674 (define_insn "sse2_cvtpd2pi"
4675   [(set (match_operand:V2SI 0 "register_operand" "=y")
4676         (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "xm")]
4677                      UNSPEC_FIX_NOTRUNC))]
4678   "TARGET_SSE2"
4679   "cvtpd2pi\t{%1, %0|%0, %1}"
4680   [(set_attr "type" "ssecvt")
4681    (set_attr "unit" "mmx")
4682    (set_attr "bdver1_decode" "double")
4683    (set_attr "btver2_decode" "direct")
4684    (set_attr "prefix_data16" "1")
4685    (set_attr "mode" "DI")])
4687 (define_insn "sse2_cvttpd2pi"
4688   [(set (match_operand:V2SI 0 "register_operand" "=y")
4689         (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "xm")))]
4690   "TARGET_SSE2"
4691   "cvttpd2pi\t{%1, %0|%0, %1}"
4692   [(set_attr "type" "ssecvt")
4693    (set_attr "unit" "mmx")
4694    (set_attr "bdver1_decode" "double")
4695    (set_attr "prefix_data16" "1")
4696    (set_attr "mode" "TI")])
4698 (define_insn "sse2_cvtsi2sd"
4699   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
4700         (vec_merge:V2DF
4701           (vec_duplicate:V2DF
4702             (float:DF (match_operand:SI 2 "nonimmediate_operand" "r,m,rm")))
4703           (match_operand:V2DF 1 "register_operand" "0,0,v")
4704           (const_int 1)))]
4705   "TARGET_SSE2"
4706   "@
4707    cvtsi2sd\t{%2, %0|%0, %2}
4708    cvtsi2sd\t{%2, %0|%0, %2}
4709    vcvtsi2sd\t{%2, %1, %0|%0, %1, %2}"
4710   [(set_attr "isa" "noavx,noavx,avx")
4711    (set_attr "type" "sseicvt")
4712    (set_attr "athlon_decode" "double,direct,*")
4713    (set_attr "amdfam10_decode" "vector,double,*")
4714    (set_attr "bdver1_decode" "double,direct,*")
4715    (set_attr "btver2_decode" "double,double,double")
4716    (set_attr "znver1_decode" "double,double,double")
4717    (set_attr "prefix" "orig,orig,maybe_evex")
4718    (set_attr "mode" "DF")])
4720 (define_insn "sse2_cvtsi2sdq<round_name>"
4721   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
4722         (vec_merge:V2DF
4723           (vec_duplicate:V2DF
4724             (float:DF (match_operand:DI 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
4725           (match_operand:V2DF 1 "register_operand" "0,0,v")
4726           (const_int 1)))]
4727   "TARGET_SSE2 && TARGET_64BIT"
4728   "@
4729    cvtsi2sdq\t{%2, %0|%0, %2}
4730    cvtsi2sdq\t{%2, %0|%0, %2}
4731    vcvtsi2sdq\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4732   [(set_attr "isa" "noavx,noavx,avx")
4733    (set_attr "type" "sseicvt")
4734    (set_attr "athlon_decode" "double,direct,*")
4735    (set_attr "amdfam10_decode" "vector,double,*")
4736    (set_attr "bdver1_decode" "double,direct,*")
4737    (set_attr "length_vex" "*,*,4")
4738    (set_attr "prefix_rex" "1,1,*")
4739    (set_attr "prefix" "orig,orig,maybe_evex")
4740    (set_attr "mode" "DF")])
4742 (define_insn "avx512f_vcvtss2usi<rex64namesuffix><round_name>"
4743   [(set (match_operand:SWI48 0 "register_operand" "=r")
4744         (unspec:SWI48
4745           [(vec_select:SF
4746              (match_operand:V4SF 1 "<round_nimm_predicate>" "<round_constraint>")
4747              (parallel [(const_int 0)]))]
4748           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4749   "TARGET_AVX512F"
4750   "vcvtss2usi\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
4751   [(set_attr "type" "sseicvt")
4752    (set_attr "prefix" "evex")
4753    (set_attr "mode" "<MODE>")])
4755 (define_insn "avx512f_vcvttss2usi<rex64namesuffix><round_saeonly_name>"
4756   [(set (match_operand:SWI48 0 "register_operand" "=r")
4757         (unsigned_fix:SWI48
4758           (vec_select:SF
4759             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4760             (parallel [(const_int 0)]))))]
4761   "TARGET_AVX512F"
4762   "vcvttss2usi\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
4763   [(set_attr "type" "sseicvt")
4764    (set_attr "prefix" "evex")
4765    (set_attr "mode" "<MODE>")])
4767 (define_insn "avx512f_vcvtsd2usi<rex64namesuffix><round_name>"
4768   [(set (match_operand:SWI48 0 "register_operand" "=r")
4769         (unspec:SWI48
4770           [(vec_select:DF
4771              (match_operand:V2DF 1 "<round_nimm_predicate>" "<round_constraint>")
4772              (parallel [(const_int 0)]))]
4773           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4774   "TARGET_AVX512F"
4775   "vcvtsd2usi\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
4776   [(set_attr "type" "sseicvt")
4777    (set_attr "prefix" "evex")
4778    (set_attr "mode" "<MODE>")])
4780 (define_insn "avx512f_vcvttsd2usi<rex64namesuffix><round_saeonly_name>"
4781   [(set (match_operand:SWI48 0 "register_operand" "=r")
4782         (unsigned_fix:SWI48
4783           (vec_select:DF
4784             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4785             (parallel [(const_int 0)]))))]
4786   "TARGET_AVX512F"
4787   "vcvttsd2usi\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
4788   [(set_attr "type" "sseicvt")
4789    (set_attr "prefix" "evex")
4790    (set_attr "mode" "<MODE>")])
4792 (define_insn "sse2_cvtsd2si<rex64namesuffix><round_name>"
4793   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
4794         (unspec:SWI48
4795           [(vec_select:DF
4796              (match_operand:V2DF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4797              (parallel [(const_int 0)]))]
4798           UNSPEC_FIX_NOTRUNC))]
4799   "TARGET_SSE2"
4800   "%vcvtsd2si<rex64suffix>\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
4801   [(set_attr "type" "sseicvt")
4802    (set_attr "athlon_decode" "double,vector")
4803    (set_attr "bdver1_decode" "double,double")
4804    (set_attr "btver2_decode" "double,double")
4805    (set_attr "prefix_rep" "1")
4806    (set_attr "prefix" "maybe_vex")
4807    (set_attr "mode" "<MODE>")])
4809 (define_insn "sse2_cvtsd2si<rex64namesuffix>_2"
4810   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
4811         (unspec:SWI48 [(match_operand:DF 1 "nonimmediate_operand" "v,m")]
4812                       UNSPEC_FIX_NOTRUNC))]
4813   "TARGET_SSE2"
4814   "%vcvtsd2si<rex64suffix>\t{%1, %0|%0, %q1}"
4815   [(set_attr "type" "sseicvt")
4816    (set_attr "athlon_decode" "double,vector")
4817    (set_attr "amdfam10_decode" "double,double")
4818    (set_attr "bdver1_decode" "double,double")
4819    (set_attr "prefix_rep" "1")
4820    (set_attr "prefix" "maybe_vex")
4821    (set_attr "mode" "<MODE>")])
4823 (define_insn "sse2_cvttsd2si<rex64namesuffix><round_saeonly_name>"
4824   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
4825         (fix:SWI48
4826           (vec_select:DF
4827             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint2>")
4828             (parallel [(const_int 0)]))))]
4829   "TARGET_SSE2"
4830   "%vcvttsd2si<rex64suffix>\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
4831   [(set_attr "type" "sseicvt")
4832    (set_attr "athlon_decode" "double,vector")
4833    (set_attr "amdfam10_decode" "double,double")
4834    (set_attr "bdver1_decode" "double,double")
4835    (set_attr "btver2_decode" "double,double")
4836    (set_attr "prefix_rep" "1")
4837    (set_attr "prefix" "maybe_vex")
4838    (set_attr "mode" "<MODE>")])
4840 ;; For float<si2dfmode><mode>2 insn pattern
4841 (define_mode_attr si2dfmode
4842   [(V8DF "V8SI") (V4DF "V4SI")])
4843 (define_mode_attr si2dfmodelower
4844   [(V8DF "v8si") (V4DF "v4si")])
4846 (define_insn "float<si2dfmodelower><mode>2<mask_name>"
4847   [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
4848         (float:VF2_512_256 (match_operand:<si2dfmode> 1 "nonimmediate_operand" "vm")))]
4849   "TARGET_AVX && <mask_mode512bit_condition>"
4850   "vcvtdq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4851   [(set_attr "type" "ssecvt")
4852    (set_attr "prefix" "maybe_vex")
4853    (set_attr "mode" "<MODE>")])
4855 (define_insn "float<floatunssuffix><sseintvecmodelower><mode>2<mask_name><round_name>"
4856   [(set (match_operand:VF2_AVX512VL 0 "register_operand" "=v")
4857         (any_float:VF2_AVX512VL
4858           (match_operand:<sseintvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
4859   "TARGET_AVX512DQ"
4860   "vcvt<floatsuffix>qq2pd\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4861   [(set_attr "type" "ssecvt")
4862    (set_attr "prefix" "evex")
4863    (set_attr "mode" "<MODE>")])
4865 ;; For float<floatunssuffix><sselondveclower><mode> insn patterns
4866 (define_mode_attr qq2pssuff
4867   [(V8SF "") (V4SF "{y}")])
4869 (define_mode_attr sselongvecmode
4870   [(V8SF "V8DI") (V4SF  "V4DI")])
4872 (define_mode_attr sselongvecmodelower
4873   [(V8SF "v8di") (V4SF  "v4di")])
4875 (define_mode_attr sseintvecmode3
4876   [(V8SF "XI") (V4SF "OI")
4877    (V8DF "OI") (V4DF "TI")])
4879 (define_insn "float<floatunssuffix><sselongvecmodelower><mode>2<mask_name><round_name>"
4880   [(set (match_operand:VF1_128_256VL 0 "register_operand" "=v")
4881          (any_float:VF1_128_256VL
4882            (match_operand:<sselongvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
4883   "TARGET_AVX512DQ && <round_modev8sf_condition>"
4884   "vcvt<floatsuffix>qq2ps<qq2pssuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4885   [(set_attr "type" "ssecvt")
4886    (set_attr "prefix" "evex")
4887    (set_attr "mode" "<MODE>")])
4889 (define_insn "float<floatunssuffix>v2div2sf2"
4890   [(set (match_operand:V4SF 0 "register_operand" "=v")
4891         (vec_concat:V4SF
4892             (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
4893             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
4894   "TARGET_AVX512DQ && TARGET_AVX512VL"
4895   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0|%0, %1}"
4896   [(set_attr "type" "ssecvt")
4897    (set_attr "prefix" "evex")
4898    (set_attr "mode" "V4SF")])
4900 (define_mode_attr vpckfloat_concat_mode
4901   [(V8DI "v16sf") (V4DI "v8sf") (V2DI "v8sf")])
4902 (define_mode_attr vpckfloat_temp_mode
4903   [(V8DI "V8SF") (V4DI "V4SF") (V2DI "V4SF")])
4904 (define_mode_attr vpckfloat_op_mode
4905   [(V8DI "v8sf") (V4DI "v4sf") (V2DI "v2sf")])
4907 (define_expand "vec_pack<floatprefix>_float_<mode>"
4908   [(match_operand:<ssePSmode> 0 "register_operand")
4909    (any_float:<ssePSmode>
4910      (match_operand:VI8_AVX512VL 1 "register_operand"))
4911    (match_operand:VI8_AVX512VL 2 "register_operand")]
4912   "TARGET_AVX512DQ"
4914   rtx r1 = gen_reg_rtx (<vpckfloat_temp_mode>mode);
4915   rtx r2 = gen_reg_rtx (<vpckfloat_temp_mode>mode);
4916   rtx (*gen) (rtx, rtx) = gen_float<floatunssuffix><mode><vpckfloat_op_mode>2;
4917   emit_insn (gen (r1, operands[1]));
4918   emit_insn (gen (r2, operands[2]));
4919   if (<MODE>mode == V2DImode)
4920     emit_insn (gen_sse_movlhps (operands[0], r1, r2));
4921   else
4922     emit_insn (gen_avx_vec_concat<vpckfloat_concat_mode> (operands[0],
4923                                                           r1, r2));
4924   DONE;
4927 (define_insn "float<floatunssuffix>v2div2sf2_mask"
4928   [(set (match_operand:V4SF 0 "register_operand" "=v")
4929     (vec_concat:V4SF
4930         (vec_merge:V2SF
4931                 (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
4932             (vec_select:V2SF
4933                 (match_operand:V4SF 2 "vector_move_operand" "0C")
4934                 (parallel [(const_int 0) (const_int 1)]))
4935             (match_operand:QI 3 "register_operand" "Yk"))
4936             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
4937   "TARGET_AVX512DQ && TARGET_AVX512VL"
4938   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
4939   [(set_attr "type" "ssecvt")
4940    (set_attr "prefix" "evex")
4941    (set_attr "mode" "V4SF")])
4943 (define_insn "*float<floatunssuffix>v2div2sf2_mask_1"
4944   [(set (match_operand:V4SF 0 "register_operand" "=v")
4945     (vec_concat:V4SF
4946         (vec_merge:V2SF
4947                 (any_float:V2SF (match_operand:V2DI 1
4948                                   "nonimmediate_operand" "vm"))
4949             (const_vector:V2SF [(const_int 0) (const_int 0)])
4950             (match_operand:QI 2 "register_operand" "Yk"))
4951             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
4952   "TARGET_AVX512DQ && TARGET_AVX512VL"
4953   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
4954   [(set_attr "type" "ssecvt")
4955    (set_attr "prefix" "evex")
4956    (set_attr "mode" "V4SF")])
4958 (define_insn "ufloat<si2dfmodelower><mode>2<mask_name>"
4959   [(set (match_operand:VF2_512_256VL 0 "register_operand" "=v")
4960         (unsigned_float:VF2_512_256VL
4961           (match_operand:<si2dfmode> 1 "nonimmediate_operand" "vm")))]
4962    "TARGET_AVX512F"
4963    "vcvtudq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4964    [(set_attr "type" "ssecvt")
4965     (set_attr "prefix" "evex")
4966     (set_attr "mode" "<MODE>")])
4968 (define_insn "ufloatv2siv2df2<mask_name>"
4969   [(set (match_operand:V2DF 0 "register_operand" "=v")
4970         (unsigned_float:V2DF
4971           (vec_select:V2SI
4972             (match_operand:V4SI 1 "nonimmediate_operand" "vm")
4973             (parallel [(const_int 0) (const_int 1)]))))]
4974   "TARGET_AVX512VL"
4975   "vcvtudq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
4976   [(set_attr "type" "ssecvt")
4977    (set_attr "prefix" "evex")
4978    (set_attr "mode" "V2DF")])
4980 (define_insn "avx512f_cvtdq2pd512_2"
4981   [(set (match_operand:V8DF 0 "register_operand" "=v")
4982         (float:V8DF
4983           (vec_select:V8SI
4984             (match_operand:V16SI 1 "nonimmediate_operand" "vm")
4985             (parallel [(const_int 0) (const_int 1)
4986                        (const_int 2) (const_int 3)
4987                        (const_int 4) (const_int 5)
4988                        (const_int 6) (const_int 7)]))))]
4989   "TARGET_AVX512F"
4990   "vcvtdq2pd\t{%t1, %0|%0, %t1}"
4991   [(set_attr "type" "ssecvt")
4992    (set_attr "prefix" "evex")
4993    (set_attr "mode" "V8DF")])
4995 (define_insn "avx_cvtdq2pd256_2"
4996   [(set (match_operand:V4DF 0 "register_operand" "=v")
4997         (float:V4DF
4998           (vec_select:V4SI
4999             (match_operand:V8SI 1 "nonimmediate_operand" "vm")
5000             (parallel [(const_int 0) (const_int 1)
5001                        (const_int 2) (const_int 3)]))))]
5002   "TARGET_AVX"
5003   "vcvtdq2pd\t{%x1, %0|%0, %x1}"
5004   [(set_attr "type" "ssecvt")
5005    (set_attr "prefix" "maybe_evex")
5006    (set_attr "mode" "V4DF")])
5008 (define_insn "sse2_cvtdq2pd<mask_name>"
5009   [(set (match_operand:V2DF 0 "register_operand" "=v")
5010         (float:V2DF
5011           (vec_select:V2SI
5012             (match_operand:V4SI 1 "nonimmediate_operand" "vm")
5013             (parallel [(const_int 0) (const_int 1)]))))]
5014   "TARGET_SSE2 && <mask_avx512vl_condition>"
5015   "%vcvtdq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5016   [(set_attr "type" "ssecvt")
5017    (set_attr "prefix" "maybe_vex")
5018    (set_attr "mode" "V2DF")])
5020 (define_insn "avx512f_cvtpd2dq512<mask_name><round_name>"
5021   [(set (match_operand:V8SI 0 "register_operand" "=v")
5022         (unspec:V8SI
5023           [(match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")]
5024           UNSPEC_FIX_NOTRUNC))]
5025   "TARGET_AVX512F"
5026   "vcvtpd2dq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5027   [(set_attr "type" "ssecvt")
5028    (set_attr "prefix" "evex")
5029    (set_attr "mode" "OI")])
5031 (define_insn "avx_cvtpd2dq256<mask_name>"
5032   [(set (match_operand:V4SI 0 "register_operand" "=v")
5033         (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")]
5034                      UNSPEC_FIX_NOTRUNC))]
5035   "TARGET_AVX && <mask_avx512vl_condition>"
5036   "vcvtpd2dq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5037   [(set_attr "type" "ssecvt")
5038    (set_attr "prefix" "<mask_prefix>")
5039    (set_attr "mode" "OI")])
5041 (define_expand "avx_cvtpd2dq256_2"
5042   [(set (match_operand:V8SI 0 "register_operand")
5043         (vec_concat:V8SI
5044           (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand")]
5045                        UNSPEC_FIX_NOTRUNC)
5046           (match_dup 2)))]
5047   "TARGET_AVX"
5048   "operands[2] = CONST0_RTX (V4SImode);")
5050 (define_insn "*avx_cvtpd2dq256_2"
5051   [(set (match_operand:V8SI 0 "register_operand" "=v")
5052         (vec_concat:V8SI
5053           (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")]
5054                        UNSPEC_FIX_NOTRUNC)
5055           (match_operand:V4SI 2 "const0_operand")))]
5056   "TARGET_AVX"
5057   "vcvtpd2dq{y}\t{%1, %x0|%x0, %1}"
5058   [(set_attr "type" "ssecvt")
5059    (set_attr "prefix" "vex")
5060    (set_attr "btver2_decode" "vector")
5061    (set_attr "mode" "OI")])
5063 (define_insn "sse2_cvtpd2dq<mask_name>"
5064   [(set (match_operand:V4SI 0 "register_operand" "=v")
5065         (vec_concat:V4SI
5066           (unspec:V2SI [(match_operand:V2DF 1 "vector_operand" "vBm")]
5067                        UNSPEC_FIX_NOTRUNC)
5068           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5069   "TARGET_SSE2 && <mask_avx512vl_condition>"
5071   if (TARGET_AVX)
5072     return "vcvtpd2dq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
5073   else
5074     return "cvtpd2dq\t{%1, %0|%0, %1}";
5076   [(set_attr "type" "ssecvt")
5077    (set_attr "prefix_rep" "1")
5078    (set_attr "prefix_data16" "0")
5079    (set_attr "prefix" "maybe_vex")
5080    (set_attr "mode" "TI")
5081    (set_attr "amdfam10_decode" "double")
5082    (set_attr "athlon_decode" "vector")
5083    (set_attr "bdver1_decode" "double")])
5085 ;; For ufix_notrunc* insn patterns
5086 (define_mode_attr pd2udqsuff
5087   [(V8DF "") (V4DF "{y}")])
5089 (define_insn "ufix_notrunc<mode><si2dfmodelower>2<mask_name><round_name>"
5090   [(set (match_operand:<si2dfmode> 0 "register_operand" "=v")
5091         (unspec:<si2dfmode>
5092           [(match_operand:VF2_512_256VL 1 "nonimmediate_operand" "<round_constraint>")]
5093           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
5094   "TARGET_AVX512F"
5095   "vcvtpd2udq<pd2udqsuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5096   [(set_attr "type" "ssecvt")
5097    (set_attr "prefix" "evex")
5098    (set_attr "mode" "<sseinsnmode>")])
5100 (define_insn "ufix_notruncv2dfv2si2<mask_name>"
5101   [(set (match_operand:V4SI 0 "register_operand" "=v")
5102         (vec_concat:V4SI
5103           (unspec:V2SI
5104             [(match_operand:V2DF 1 "nonimmediate_operand" "vm")]
5105             UNSPEC_UNSIGNED_FIX_NOTRUNC)
5106           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5107   "TARGET_AVX512VL"
5108   "vcvtpd2udq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5109   [(set_attr "type" "ssecvt")
5110    (set_attr "prefix" "evex")
5111    (set_attr "mode" "TI")])
5113 (define_insn "fix<fixunssuffix>_truncv8dfv8si2<mask_name><round_saeonly_name>"
5114   [(set (match_operand:V8SI 0 "register_operand" "=v")
5115         (any_fix:V8SI
5116           (match_operand:V8DF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5117   "TARGET_AVX512F"
5118   "vcvttpd2<fixsuffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5119   [(set_attr "type" "ssecvt")
5120    (set_attr "prefix" "evex")
5121    (set_attr "mode" "OI")])
5123 (define_insn "ufix_truncv2dfv2si2<mask_name>"
5124   [(set (match_operand:V4SI 0 "register_operand" "=v")
5125         (vec_concat:V4SI
5126           (unsigned_fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "vm"))
5127           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5128   "TARGET_AVX512VL"
5129   "vcvttpd2udq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5130   [(set_attr "type" "ssecvt")
5131    (set_attr "prefix" "evex")
5132    (set_attr "mode" "TI")])
5134 (define_insn "fix_truncv4dfv4si2<mask_name>"
5135   [(set (match_operand:V4SI 0 "register_operand" "=v")
5136         (fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
5137   "TARGET_AVX || (TARGET_AVX512VL && TARGET_AVX512F)"
5138   "vcvttpd2dq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5139   [(set_attr "type" "ssecvt")
5140    (set_attr "prefix" "maybe_evex")
5141    (set_attr "mode" "OI")])
5143 (define_insn "ufix_truncv4dfv4si2<mask_name>"
5144   [(set (match_operand:V4SI 0 "register_operand" "=v")
5145         (unsigned_fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
5146   "TARGET_AVX512VL && TARGET_AVX512F"
5147   "vcvttpd2udq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5148   [(set_attr "type" "ssecvt")
5149    (set_attr "prefix" "maybe_evex")
5150    (set_attr "mode" "OI")])
5152 (define_insn "fix<fixunssuffix>_trunc<mode><sseintvecmodelower>2<mask_name><round_saeonly_name>"
5153   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5154         (any_fix:<sseintvecmode>
5155           (match_operand:VF2_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5156   "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
5157   "vcvttpd2<fixsuffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5158   [(set_attr "type" "ssecvt")
5159    (set_attr "prefix" "evex")
5160    (set_attr "mode" "<sseintvecmode2>")])
5162 (define_insn "fix_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>"
5163   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5164         (unspec:<sseintvecmode>
5165           [(match_operand:VF2_AVX512VL 1 "<round_nimm_predicate>" "<round_constraint>")]
5166           UNSPEC_FIX_NOTRUNC))]
5167   "TARGET_AVX512DQ && <round_mode512bit_condition>"
5168   "vcvtpd2qq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5169   [(set_attr "type" "ssecvt")
5170    (set_attr "prefix" "evex")
5171    (set_attr "mode" "<sseintvecmode2>")])
5173 (define_insn "ufix_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>"
5174   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5175         (unspec:<sseintvecmode>
5176           [(match_operand:VF2_AVX512VL 1 "nonimmediate_operand" "<round_constraint>")]
5177           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
5178   "TARGET_AVX512DQ && <round_mode512bit_condition>"
5179   "vcvtpd2uqq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5180   [(set_attr "type" "ssecvt")
5181    (set_attr "prefix" "evex")
5182    (set_attr "mode" "<sseintvecmode2>")])
5184 (define_insn "fix<fixunssuffix>_trunc<mode><sselongvecmodelower>2<mask_name><round_saeonly_name>"
5185   [(set (match_operand:<sselongvecmode> 0 "register_operand" "=v")
5186         (any_fix:<sselongvecmode>
5187           (match_operand:VF1_128_256VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5188   "TARGET_AVX512DQ && <round_saeonly_modev8sf_condition>"
5189   "vcvttps2<fixsuffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5190   [(set_attr "type" "ssecvt")
5191    (set_attr "prefix" "evex")
5192    (set_attr "mode" "<sseintvecmode3>")])
5194 (define_insn "fix<fixunssuffix>_truncv2sfv2di2<mask_name>"
5195   [(set (match_operand:V2DI 0 "register_operand" "=v")
5196         (any_fix:V2DI
5197           (vec_select:V2SF
5198             (match_operand:V4SF 1 "nonimmediate_operand" "vm")
5199             (parallel [(const_int 0) (const_int 1)]))))]
5200   "TARGET_AVX512DQ && TARGET_AVX512VL"
5201   "vcvttps2<fixsuffix>qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5202   [(set_attr "type" "ssecvt")
5203    (set_attr "prefix" "evex")
5204    (set_attr "mode" "TI")])
5206 (define_mode_attr vunpckfixt_mode
5207   [(V16SF "V8DI") (V8SF "V4DI") (V4SF "V2DI")])
5208 (define_mode_attr vunpckfixt_model
5209   [(V16SF "v8di") (V8SF "v4di") (V4SF "v2di")])
5210 (define_mode_attr vunpckfixt_extract_mode
5211   [(V16SF "v16sf") (V8SF "v8sf") (V4SF "v8sf")])
5213 (define_expand "vec_unpack_<fixprefix>fix_trunc_lo_<mode>"
5214   [(match_operand:<vunpckfixt_mode> 0 "register_operand")
5215    (any_fix:<vunpckfixt_mode>
5216      (match_operand:VF1_AVX512VL 1 "register_operand"))]
5217   "TARGET_AVX512DQ"
5219   rtx tem = operands[1];
5220   if (<MODE>mode != V4SFmode)
5221     {
5222       tem = gen_reg_rtx (<ssehalfvecmode>mode);
5223       emit_insn (gen_vec_extract_lo_<vunpckfixt_extract_mode> (tem,
5224                                                                operands[1]));
5225     }
5226   rtx (*gen) (rtx, rtx)
5227     = gen_fix<fixunssuffix>_trunc<ssehalfvecmodelower><vunpckfixt_model>2;
5228   emit_insn (gen (operands[0], tem));
5229   DONE;
5232 (define_expand "vec_unpack_<fixprefix>fix_trunc_hi_<mode>"
5233   [(match_operand:<vunpckfixt_mode> 0 "register_operand")
5234    (any_fix:<vunpckfixt_mode>
5235      (match_operand:VF1_AVX512VL 1 "register_operand"))]
5236   "TARGET_AVX512DQ"
5238   rtx tem;
5239   if (<MODE>mode != V4SFmode)
5240     {
5241       tem = gen_reg_rtx (<ssehalfvecmode>mode);
5242       emit_insn (gen_vec_extract_hi_<vunpckfixt_extract_mode> (tem,
5243                                                                operands[1]));
5244     }
5245   else
5246     {
5247       tem = gen_reg_rtx (V4SFmode);
5248       emit_insn (gen_avx_vpermilv4sf (tem, operands[1], GEN_INT (0x4e)));
5249     }
5250   rtx (*gen) (rtx, rtx)
5251     = gen_fix<fixunssuffix>_trunc<ssehalfvecmodelower><vunpckfixt_model>2;
5252   emit_insn (gen (operands[0], tem));
5253   DONE;
5256 (define_insn "ufix_trunc<mode><sseintvecmodelower>2<mask_name>"
5257   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5258         (unsigned_fix:<sseintvecmode>
5259           (match_operand:VF1_128_256VL 1 "nonimmediate_operand" "vm")))]
5260   "TARGET_AVX512VL"
5261   "vcvttps2udq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5262   [(set_attr "type" "ssecvt")
5263    (set_attr "prefix" "evex")
5264    (set_attr "mode" "<sseintvecmode2>")])
5266 (define_expand "avx_cvttpd2dq256_2"
5267   [(set (match_operand:V8SI 0 "register_operand")
5268         (vec_concat:V8SI
5269           (fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand"))
5270           (match_dup 2)))]
5271   "TARGET_AVX"
5272   "operands[2] = CONST0_RTX (V4SImode);")
5274 (define_insn "sse2_cvttpd2dq<mask_name>"
5275   [(set (match_operand:V4SI 0 "register_operand" "=v")
5276         (vec_concat:V4SI
5277           (fix:V2SI (match_operand:V2DF 1 "vector_operand" "vBm"))
5278           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5279   "TARGET_SSE2 && <mask_avx512vl_condition>"
5281   if (TARGET_AVX)
5282     return "vcvttpd2dq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
5283   else
5284     return "cvttpd2dq\t{%1, %0|%0, %1}";
5286   [(set_attr "type" "ssecvt")
5287    (set_attr "amdfam10_decode" "double")
5288    (set_attr "athlon_decode" "vector")
5289    (set_attr "bdver1_decode" "double")
5290    (set_attr "prefix" "maybe_vex")
5291    (set_attr "mode" "TI")])
5293 (define_insn "sse2_cvtsd2ss<round_name>"
5294   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
5295         (vec_merge:V4SF
5296           (vec_duplicate:V4SF
5297             (float_truncate:V2SF
5298               (match_operand:V2DF 2 "nonimmediate_operand" "x,m,<round_constraint>")))
5299           (match_operand:V4SF 1 "register_operand" "0,0,v")
5300           (const_int 1)))]
5301   "TARGET_SSE2"
5302   "@
5303    cvtsd2ss\t{%2, %0|%0, %2}
5304    cvtsd2ss\t{%2, %0|%0, %q2}
5305    vcvtsd2ss\t{<round_op3>%2, %1, %0|%0, %1, %q2<round_op3>}"
5306   [(set_attr "isa" "noavx,noavx,avx")
5307    (set_attr "type" "ssecvt")
5308    (set_attr "athlon_decode" "vector,double,*")
5309    (set_attr "amdfam10_decode" "vector,double,*")
5310    (set_attr "bdver1_decode" "direct,direct,*")
5311    (set_attr "btver2_decode" "double,double,double")
5312    (set_attr "prefix" "orig,orig,<round_prefix>")
5313    (set_attr "mode" "SF")])
5315 (define_insn "*sse2_vd_cvtsd2ss"
5316   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
5317         (vec_merge:V4SF
5318           (vec_duplicate:V4SF
5319             (float_truncate:SF (match_operand:DF 2 "nonimmediate_operand" "x,m,vm")))
5320           (match_operand:V4SF 1 "register_operand" "0,0,v")
5321           (const_int 1)))]
5322   "TARGET_SSE2"
5323   "@
5324    cvtsd2ss\t{%2, %0|%0, %2}
5325    cvtsd2ss\t{%2, %0|%0, %2}
5326    vcvtsd2ss\t{%2, %1, %0|%0, %1, %2}"
5327   [(set_attr "isa" "noavx,noavx,avx")
5328    (set_attr "type" "ssecvt")
5329    (set_attr "athlon_decode" "vector,double,*")
5330    (set_attr "amdfam10_decode" "vector,double,*")
5331    (set_attr "bdver1_decode" "direct,direct,*")
5332    (set_attr "btver2_decode" "double,double,double")
5333    (set_attr "prefix" "orig,orig,vex")
5334    (set_attr "mode" "SF")])
5336 (define_insn "sse2_cvtss2sd<round_saeonly_name>"
5337   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
5338         (vec_merge:V2DF
5339           (float_extend:V2DF
5340             (vec_select:V2SF
5341               (match_operand:V4SF 2 "<round_saeonly_nimm_scalar_predicate>" "x,m,<round_saeonly_constraint>")
5342               (parallel [(const_int 0) (const_int 1)])))
5343           (match_operand:V2DF 1 "register_operand" "0,0,v")
5344           (const_int 1)))]
5345   "TARGET_SSE2"
5346   "@
5347    cvtss2sd\t{%2, %0|%0, %2}
5348    cvtss2sd\t{%2, %0|%0, %k2}
5349    vcvtss2sd\t{<round_saeonly_op3>%2, %1, %0|%0, %1, %k2<round_saeonly_op3>}"
5350   [(set_attr "isa" "noavx,noavx,avx")
5351    (set_attr "type" "ssecvt")
5352    (set_attr "amdfam10_decode" "vector,double,*")
5353    (set_attr "athlon_decode" "direct,direct,*")
5354    (set_attr "bdver1_decode" "direct,direct,*")
5355    (set_attr "btver2_decode" "double,double,double")
5356    (set_attr "prefix" "orig,orig,<round_saeonly_prefix>")
5357    (set_attr "mode" "DF")])
5359 (define_insn "*sse2_vd_cvtss2sd"
5360   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
5361         (vec_merge:V2DF
5362           (vec_duplicate:V2DF
5363             (float_extend:DF (match_operand:SF 2 "nonimmediate_operand" "x,m,vm")))
5364           (match_operand:V2DF 1 "register_operand" "0,0,v")
5365           (const_int 1)))]
5366   "TARGET_SSE2"
5367   "@
5368    cvtss2sd\t{%2, %0|%0, %2}
5369    cvtss2sd\t{%2, %0|%0, %2}
5370    vcvtss2sd\t{%2, %1, %0|%0, %1, %2}"
5371   [(set_attr "isa" "noavx,noavx,avx")
5372    (set_attr "type" "ssecvt")
5373    (set_attr "amdfam10_decode" "vector,double,*")
5374    (set_attr "athlon_decode" "direct,direct,*")
5375    (set_attr "bdver1_decode" "direct,direct,*")
5376    (set_attr "btver2_decode" "double,double,double")
5377    (set_attr "prefix" "orig,orig,vex")
5378    (set_attr "mode" "DF")])
5380 (define_insn "<mask_codefor>avx512f_cvtpd2ps512<mask_name><round_name>"
5381   [(set (match_operand:V8SF 0 "register_operand" "=v")
5382         (float_truncate:V8SF
5383           (match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")))]
5384   "TARGET_AVX512F"
5385   "vcvtpd2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5386   [(set_attr "type" "ssecvt")
5387    (set_attr "prefix" "evex")
5388    (set_attr "mode" "V8SF")])
5390 (define_insn "avx_cvtpd2ps256<mask_name>"
5391   [(set (match_operand:V4SF 0 "register_operand" "=v")
5392         (float_truncate:V4SF
5393           (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
5394   "TARGET_AVX && <mask_avx512vl_condition>"
5395   "vcvtpd2ps{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5396   [(set_attr "type" "ssecvt")
5397    (set_attr "prefix" "maybe_evex")
5398    (set_attr "btver2_decode" "vector")
5399    (set_attr "mode" "V4SF")])
5401 (define_expand "sse2_cvtpd2ps"
5402   [(set (match_operand:V4SF 0 "register_operand")
5403         (vec_concat:V4SF
5404           (float_truncate:V2SF
5405             (match_operand:V2DF 1 "vector_operand"))
5406           (match_dup 2)))]
5407   "TARGET_SSE2"
5408   "operands[2] = CONST0_RTX (V2SFmode);")
5410 (define_expand "sse2_cvtpd2ps_mask"
5411   [(set (match_operand:V4SF 0 "register_operand")
5412         (vec_merge:V4SF
5413           (vec_concat:V4SF
5414             (float_truncate:V2SF
5415               (match_operand:V2DF 1 "vector_operand"))
5416             (match_dup 4))
5417           (match_operand:V4SF 2 "register_operand")
5418           (match_operand:QI 3 "register_operand")))]
5419   "TARGET_SSE2"
5420   "operands[4] = CONST0_RTX (V2SFmode);")
5422 (define_insn "*sse2_cvtpd2ps<mask_name>"
5423   [(set (match_operand:V4SF 0 "register_operand" "=v")
5424         (vec_concat:V4SF
5425           (float_truncate:V2SF
5426             (match_operand:V2DF 1 "vector_operand" "vBm"))
5427           (match_operand:V2SF 2 "const0_operand")))]
5428   "TARGET_SSE2 && <mask_avx512vl_condition>"
5430   if (TARGET_AVX)
5431     return "vcvtpd2ps{x}\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}";
5432   else
5433     return "cvtpd2ps\t{%1, %0|%0, %1}";
5435   [(set_attr "type" "ssecvt")
5436    (set_attr "amdfam10_decode" "double")
5437    (set_attr "athlon_decode" "vector")
5438    (set_attr "bdver1_decode" "double")
5439    (set_attr "prefix_data16" "1")
5440    (set_attr "prefix" "maybe_vex")
5441    (set_attr "mode" "V4SF")])
5443 ;; For <sse2_avx_avx512f>_cvtps2pd<avxsizesuffix> insn pattern
5444 (define_mode_attr sf2dfmode
5445   [(V8DF "V8SF") (V4DF "V4SF")])
5447 (define_insn "<sse2_avx_avx512f>_cvtps2pd<avxsizesuffix><mask_name><round_saeonly_name>"
5448   [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
5449         (float_extend:VF2_512_256
5450           (match_operand:<sf2dfmode> 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5451   "TARGET_AVX && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
5452   "vcvtps2pd\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5453   [(set_attr "type" "ssecvt")
5454    (set_attr "prefix" "maybe_vex")
5455    (set_attr "mode" "<MODE>")])
5457 (define_insn "*avx_cvtps2pd256_2"
5458   [(set (match_operand:V4DF 0 "register_operand" "=v")
5459         (float_extend:V4DF
5460           (vec_select:V4SF
5461             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
5462             (parallel [(const_int 0) (const_int 1)
5463                        (const_int 2) (const_int 3)]))))]
5464   "TARGET_AVX"
5465   "vcvtps2pd\t{%x1, %0|%0, %x1}"
5466   [(set_attr "type" "ssecvt")
5467    (set_attr "prefix" "vex")
5468    (set_attr "mode" "V4DF")])
5470 (define_insn "vec_unpacks_lo_v16sf"
5471   [(set (match_operand:V8DF 0 "register_operand" "=v")
5472         (float_extend:V8DF
5473           (vec_select:V8SF
5474             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
5475             (parallel [(const_int 0) (const_int 1)
5476                        (const_int 2) (const_int 3)
5477                        (const_int 4) (const_int 5)
5478                        (const_int 6) (const_int 7)]))))]
5479   "TARGET_AVX512F"
5480   "vcvtps2pd\t{%t1, %0|%0, %t1}"
5481   [(set_attr "type" "ssecvt")
5482    (set_attr "prefix" "evex")
5483    (set_attr "mode" "V8DF")])
5485 (define_insn "<avx512>_cvt<ssemodesuffix>2mask<mode>"
5486   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
5487         (unspec:<avx512fmaskmode>
5488          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")]
5489          UNSPEC_CVTINT2MASK))]
5490   "TARGET_AVX512BW"
5491   "vpmov<ssemodesuffix>2m\t{%1, %0|%0, %1}"
5492   [(set_attr "prefix" "evex")
5493    (set_attr "mode" "<sseinsnmode>")])
5495 (define_insn "<avx512>_cvt<ssemodesuffix>2mask<mode>"
5496   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
5497         (unspec:<avx512fmaskmode>
5498          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")]
5499          UNSPEC_CVTINT2MASK))]
5500   "TARGET_AVX512DQ"
5501   "vpmov<ssemodesuffix>2m\t{%1, %0|%0, %1}"
5502   [(set_attr "prefix" "evex")
5503    (set_attr "mode" "<sseinsnmode>")])
5505 (define_expand "<avx512>_cvtmask2<ssemodesuffix><mode>"
5506   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
5507         (vec_merge:VI12_AVX512VL
5508           (match_dup 2)
5509           (match_dup 3)
5510           (match_operand:<avx512fmaskmode> 1 "register_operand")))]
5511   "TARGET_AVX512BW"
5512   {
5513     operands[2] = CONSTM1_RTX (<MODE>mode);
5514     operands[3] = CONST0_RTX (<MODE>mode);
5515   })
5517 (define_insn "*<avx512>_cvtmask2<ssemodesuffix><mode>"
5518   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
5519         (vec_merge:VI12_AVX512VL
5520           (match_operand:VI12_AVX512VL 2 "vector_all_ones_operand")
5521           (match_operand:VI12_AVX512VL 3 "const0_operand")
5522           (match_operand:<avx512fmaskmode> 1 "register_operand" "Yk")))]
5523   "TARGET_AVX512BW"
5524   "vpmovm2<ssemodesuffix>\t{%1, %0|%0, %1}"
5525   [(set_attr "prefix" "evex")
5526    (set_attr "mode" "<sseinsnmode>")])
5528 (define_expand "<avx512>_cvtmask2<ssemodesuffix><mode>"
5529   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
5530         (vec_merge:VI48_AVX512VL
5531           (match_dup 2)
5532           (match_dup 3)
5533           (match_operand:<avx512fmaskmode> 1 "register_operand")))]
5534   "TARGET_AVX512DQ"
5535   "{
5536     operands[2] = CONSTM1_RTX (<MODE>mode);
5537     operands[3] = CONST0_RTX (<MODE>mode);
5538   }")
5540 (define_insn "*<avx512>_cvtmask2<ssemodesuffix><mode>"
5541   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
5542         (vec_merge:VI48_AVX512VL
5543           (match_operand:VI48_AVX512VL 2 "vector_all_ones_operand")
5544           (match_operand:VI48_AVX512VL 3 "const0_operand")
5545           (match_operand:<avx512fmaskmode> 1 "register_operand" "Yk")))]
5546   "TARGET_AVX512DQ"
5547   "vpmovm2<ssemodesuffix>\t{%1, %0|%0, %1}"
5548   [(set_attr "prefix" "evex")
5549    (set_attr "mode" "<sseinsnmode>")])
5551 (define_insn "sse2_cvtps2pd<mask_name>"
5552   [(set (match_operand:V2DF 0 "register_operand" "=v")
5553         (float_extend:V2DF
5554           (vec_select:V2SF
5555             (match_operand:V4SF 1 "vector_operand" "vm")
5556             (parallel [(const_int 0) (const_int 1)]))))]
5557   "TARGET_SSE2 && <mask_avx512vl_condition>"
5558   "%vcvtps2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5559   [(set_attr "type" "ssecvt")
5560    (set_attr "amdfam10_decode" "direct")
5561    (set_attr "athlon_decode" "double")
5562    (set_attr "bdver1_decode" "double")
5563    (set_attr "prefix_data16" "0")
5564    (set_attr "prefix" "maybe_vex")
5565    (set_attr "mode" "V2DF")])
5567 (define_expand "vec_unpacks_hi_v4sf"
5568   [(set (match_dup 2)
5569    (vec_select:V4SF
5570      (vec_concat:V8SF
5571        (match_dup 2)
5572        (match_operand:V4SF 1 "vector_operand"))
5573      (parallel [(const_int 6) (const_int 7)
5574                 (const_int 2) (const_int 3)])))
5575   (set (match_operand:V2DF 0 "register_operand")
5576    (float_extend:V2DF
5577      (vec_select:V2SF
5578        (match_dup 2)
5579        (parallel [(const_int 0) (const_int 1)]))))]
5580   "TARGET_SSE2"
5581   "operands[2] = gen_reg_rtx (V4SFmode);")
5583 (define_expand "vec_unpacks_hi_v8sf"
5584   [(set (match_dup 2)
5585         (vec_select:V4SF
5586           (match_operand:V8SF 1 "register_operand")
5587           (parallel [(const_int 4) (const_int 5)
5588                      (const_int 6) (const_int 7)])))
5589    (set (match_operand:V4DF 0 "register_operand")
5590         (float_extend:V4DF
5591           (match_dup 2)))]
5592   "TARGET_AVX"
5593   "operands[2] = gen_reg_rtx (V4SFmode);")
5595 (define_expand "vec_unpacks_hi_v16sf"
5596   [(set (match_dup 2)
5597         (vec_select:V8SF
5598           (match_operand:V16SF 1 "register_operand")
5599           (parallel [(const_int 8) (const_int 9)
5600                      (const_int 10) (const_int 11)
5601                      (const_int 12) (const_int 13)
5602                      (const_int 14) (const_int 15)])))
5603    (set (match_operand:V8DF 0 "register_operand")
5604         (float_extend:V8DF
5605           (match_dup 2)))]
5606 "TARGET_AVX512F"
5607 "operands[2] = gen_reg_rtx (V8SFmode);")
5609 (define_expand "vec_unpacks_lo_v4sf"
5610   [(set (match_operand:V2DF 0 "register_operand")
5611         (float_extend:V2DF
5612           (vec_select:V2SF
5613             (match_operand:V4SF 1 "vector_operand")
5614             (parallel [(const_int 0) (const_int 1)]))))]
5615   "TARGET_SSE2")
5617 (define_expand "vec_unpacks_lo_v8sf"
5618   [(set (match_operand:V4DF 0 "register_operand")
5619         (float_extend:V4DF
5620           (vec_select:V4SF
5621             (match_operand:V8SF 1 "nonimmediate_operand")
5622             (parallel [(const_int 0) (const_int 1)
5623                        (const_int 2) (const_int 3)]))))]
5624   "TARGET_AVX")
5626 (define_mode_attr sseunpackfltmode
5627   [(V8HI "V4SF") (V4SI "V2DF") (V16HI "V8SF")
5628   (V8SI "V4DF") (V32HI "V16SF") (V16SI "V8DF")])
5630 (define_expand "vec_unpacks_float_hi_<mode>"
5631   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5632    (match_operand:VI2_AVX512F 1 "register_operand")]
5633   "TARGET_SSE2"
5635   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5637   emit_insn (gen_vec_unpacks_hi_<mode> (tmp, operands[1]));
5638   emit_insn (gen_rtx_SET (operands[0],
5639                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5640   DONE;
5643 (define_expand "vec_unpacks_float_lo_<mode>"
5644   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5645    (match_operand:VI2_AVX512F 1 "register_operand")]
5646   "TARGET_SSE2"
5648   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5650   emit_insn (gen_vec_unpacks_lo_<mode> (tmp, operands[1]));
5651   emit_insn (gen_rtx_SET (operands[0],
5652                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5653   DONE;
5656 (define_expand "vec_unpacku_float_hi_<mode>"
5657   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5658    (match_operand:VI2_AVX512F 1 "register_operand")]
5659   "TARGET_SSE2"
5661   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5663   emit_insn (gen_vec_unpacku_hi_<mode> (tmp, operands[1]));
5664   emit_insn (gen_rtx_SET (operands[0],
5665                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5666   DONE;
5669 (define_expand "vec_unpacku_float_lo_<mode>"
5670   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5671    (match_operand:VI2_AVX512F 1 "register_operand")]
5672   "TARGET_SSE2"
5674   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5676   emit_insn (gen_vec_unpacku_lo_<mode> (tmp, operands[1]));
5677   emit_insn (gen_rtx_SET (operands[0],
5678                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5679   DONE;
5682 (define_expand "vec_unpacks_float_hi_v4si"
5683   [(set (match_dup 2)
5684         (vec_select:V4SI
5685           (match_operand:V4SI 1 "vector_operand")
5686           (parallel [(const_int 2) (const_int 3)
5687                      (const_int 2) (const_int 3)])))
5688    (set (match_operand:V2DF 0 "register_operand")
5689         (float:V2DF
5690           (vec_select:V2SI
5691           (match_dup 2)
5692             (parallel [(const_int 0) (const_int 1)]))))]
5693   "TARGET_SSE2"
5694   "operands[2] = gen_reg_rtx (V4SImode);")
5696 (define_expand "vec_unpacks_float_lo_v4si"
5697   [(set (match_operand:V2DF 0 "register_operand")
5698         (float:V2DF
5699           (vec_select:V2SI
5700             (match_operand:V4SI 1 "vector_operand")
5701             (parallel [(const_int 0) (const_int 1)]))))]
5702   "TARGET_SSE2")
5704 (define_expand "vec_unpacks_float_hi_v8si"
5705   [(set (match_dup 2)
5706         (vec_select:V4SI
5707           (match_operand:V8SI 1 "vector_operand")
5708           (parallel [(const_int 4) (const_int 5)
5709                      (const_int 6) (const_int 7)])))
5710    (set (match_operand:V4DF 0 "register_operand")
5711         (float:V4DF
5712           (match_dup 2)))]
5713   "TARGET_AVX"
5714   "operands[2] = gen_reg_rtx (V4SImode);")
5716 (define_expand "vec_unpacks_float_lo_v8si"
5717   [(set (match_operand:V4DF 0 "register_operand")
5718         (float:V4DF
5719           (vec_select:V4SI
5720             (match_operand:V8SI 1 "nonimmediate_operand")
5721             (parallel [(const_int 0) (const_int 1)
5722                        (const_int 2) (const_int 3)]))))]
5723   "TARGET_AVX")
5725 (define_expand "vec_unpacks_float_hi_v16si"
5726   [(set (match_dup 2)
5727         (vec_select:V8SI
5728           (match_operand:V16SI 1 "nonimmediate_operand")
5729           (parallel [(const_int 8) (const_int 9)
5730                      (const_int 10) (const_int 11)
5731                      (const_int 12) (const_int 13)
5732                      (const_int 14) (const_int 15)])))
5733    (set (match_operand:V8DF 0 "register_operand")
5734         (float:V8DF
5735           (match_dup 2)))]
5736   "TARGET_AVX512F"
5737   "operands[2] = gen_reg_rtx (V8SImode);")
5739 (define_expand "vec_unpacks_float_lo_v16si"
5740   [(set (match_operand:V8DF 0 "register_operand")
5741         (float:V8DF
5742           (vec_select:V8SI
5743             (match_operand:V16SI 1 "nonimmediate_operand")
5744             (parallel [(const_int 0) (const_int 1)
5745                        (const_int 2) (const_int 3)
5746                        (const_int 4) (const_int 5)
5747                        (const_int 6) (const_int 7)]))))]
5748   "TARGET_AVX512F")
5750 (define_expand "vec_unpacku_float_hi_v4si"
5751   [(set (match_dup 5)
5752         (vec_select:V4SI
5753           (match_operand:V4SI 1 "vector_operand")
5754           (parallel [(const_int 2) (const_int 3)
5755                      (const_int 2) (const_int 3)])))
5756    (set (match_dup 6)
5757         (float:V2DF
5758           (vec_select:V2SI
5759           (match_dup 5)
5760             (parallel [(const_int 0) (const_int 1)]))))
5761    (set (match_dup 7)
5762         (lt:V2DF (match_dup 6) (match_dup 3)))
5763    (set (match_dup 8)
5764         (and:V2DF (match_dup 7) (match_dup 4)))
5765    (set (match_operand:V2DF 0 "register_operand")
5766         (plus:V2DF (match_dup 6) (match_dup 8)))]
5767   "TARGET_SSE2"
5769   REAL_VALUE_TYPE TWO32r;
5770   rtx x;
5771   int i;
5773   real_ldexp (&TWO32r, &dconst1, 32);
5774   x = const_double_from_real_value (TWO32r, DFmode);
5776   operands[3] = force_reg (V2DFmode, CONST0_RTX (V2DFmode));
5777   operands[4] = force_reg (V2DFmode,
5778                            ix86_build_const_vector (V2DFmode, 1, x));
5780   operands[5] = gen_reg_rtx (V4SImode);
5782   for (i = 6; i < 9; i++)
5783     operands[i] = gen_reg_rtx (V2DFmode);
5786 (define_expand "vec_unpacku_float_lo_v4si"
5787   [(set (match_dup 5)
5788         (float:V2DF
5789           (vec_select:V2SI
5790             (match_operand:V4SI 1 "vector_operand")
5791             (parallel [(const_int 0) (const_int 1)]))))
5792    (set (match_dup 6)
5793         (lt:V2DF (match_dup 5) (match_dup 3)))
5794    (set (match_dup 7)
5795         (and:V2DF (match_dup 6) (match_dup 4)))
5796    (set (match_operand:V2DF 0 "register_operand")
5797         (plus:V2DF (match_dup 5) (match_dup 7)))]
5798   "TARGET_SSE2"
5800   REAL_VALUE_TYPE TWO32r;
5801   rtx x;
5802   int i;
5804   real_ldexp (&TWO32r, &dconst1, 32);
5805   x = const_double_from_real_value (TWO32r, DFmode);
5807   operands[3] = force_reg (V2DFmode, CONST0_RTX (V2DFmode));
5808   operands[4] = force_reg (V2DFmode,
5809                            ix86_build_const_vector (V2DFmode, 1, x));
5811   for (i = 5; i < 8; i++)
5812     operands[i] = gen_reg_rtx (V2DFmode);
5815 (define_expand "vec_unpacku_float_hi_v8si"
5816   [(match_operand:V4DF 0 "register_operand")
5817    (match_operand:V8SI 1 "register_operand")]
5818   "TARGET_AVX"
5820   REAL_VALUE_TYPE TWO32r;
5821   rtx x, tmp[6];
5822   int i;
5824   real_ldexp (&TWO32r, &dconst1, 32);
5825   x = const_double_from_real_value (TWO32r, DFmode);
5827   tmp[0] = force_reg (V4DFmode, CONST0_RTX (V4DFmode));
5828   tmp[1] = force_reg (V4DFmode, ix86_build_const_vector (V4DFmode, 1, x));
5829   tmp[5] = gen_reg_rtx (V4SImode);
5831   for (i = 2; i < 5; i++)
5832     tmp[i] = gen_reg_rtx (V4DFmode);
5833   emit_insn (gen_vec_extract_hi_v8si (tmp[5], operands[1]));
5834   emit_insn (gen_floatv4siv4df2 (tmp[2], tmp[5]));
5835   emit_insn (gen_rtx_SET (tmp[3], gen_rtx_LT (V4DFmode, tmp[2], tmp[0])));
5836   emit_insn (gen_andv4df3 (tmp[4], tmp[3], tmp[1]));
5837   emit_insn (gen_addv4df3 (operands[0], tmp[2], tmp[4]));
5838   DONE;
5841 (define_expand "vec_unpacku_float_hi_v16si"
5842   [(match_operand:V8DF 0 "register_operand")
5843    (match_operand:V16SI 1 "register_operand")]
5844   "TARGET_AVX512F"
5846   REAL_VALUE_TYPE TWO32r;
5847   rtx k, x, tmp[4];
5849   real_ldexp (&TWO32r, &dconst1, 32);
5850   x = const_double_from_real_value (TWO32r, DFmode);
5852   tmp[0] = force_reg (V8DFmode, CONST0_RTX (V8DFmode));
5853   tmp[1] = force_reg (V8DFmode, ix86_build_const_vector (V8DFmode, 1, x));
5854   tmp[2] = gen_reg_rtx (V8DFmode);
5855   tmp[3] = gen_reg_rtx (V8SImode);
5856   k = gen_reg_rtx (QImode);
5858   emit_insn (gen_vec_extract_hi_v16si (tmp[3], operands[1]));
5859   emit_insn (gen_floatv8siv8df2 (tmp[2], tmp[3]));
5860   emit_insn (gen_rtx_SET (k, gen_rtx_LT (QImode, tmp[2], tmp[0])));
5861   emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k));
5862   emit_move_insn (operands[0], tmp[2]);
5863   DONE;
5866 (define_expand "vec_unpacku_float_lo_v8si"
5867   [(match_operand:V4DF 0 "register_operand")
5868    (match_operand:V8SI 1 "nonimmediate_operand")]
5869   "TARGET_AVX"
5871   REAL_VALUE_TYPE TWO32r;
5872   rtx x, tmp[5];
5873   int i;
5875   real_ldexp (&TWO32r, &dconst1, 32);
5876   x = const_double_from_real_value (TWO32r, DFmode);
5878   tmp[0] = force_reg (V4DFmode, CONST0_RTX (V4DFmode));
5879   tmp[1] = force_reg (V4DFmode, ix86_build_const_vector (V4DFmode, 1, x));
5881   for (i = 2; i < 5; i++)
5882     tmp[i] = gen_reg_rtx (V4DFmode);
5883   emit_insn (gen_avx_cvtdq2pd256_2 (tmp[2], operands[1]));
5884   emit_insn (gen_rtx_SET (tmp[3], gen_rtx_LT (V4DFmode, tmp[2], tmp[0])));
5885   emit_insn (gen_andv4df3 (tmp[4], tmp[3], tmp[1]));
5886   emit_insn (gen_addv4df3 (operands[0], tmp[2], tmp[4]));
5887   DONE;
5890 (define_expand "vec_unpacku_float_lo_v16si"
5891   [(match_operand:V8DF 0 "register_operand")
5892    (match_operand:V16SI 1 "nonimmediate_operand")]
5893   "TARGET_AVX512F"
5895   REAL_VALUE_TYPE TWO32r;
5896   rtx k, x, tmp[3];
5898   real_ldexp (&TWO32r, &dconst1, 32);
5899   x = const_double_from_real_value (TWO32r, DFmode);
5901   tmp[0] = force_reg (V8DFmode, CONST0_RTX (V8DFmode));
5902   tmp[1] = force_reg (V8DFmode, ix86_build_const_vector (V8DFmode, 1, x));
5903   tmp[2] = gen_reg_rtx (V8DFmode);
5904   k = gen_reg_rtx (QImode);
5906   emit_insn (gen_avx512f_cvtdq2pd512_2 (tmp[2], operands[1]));
5907   emit_insn (gen_rtx_SET (k, gen_rtx_LT (QImode, tmp[2], tmp[0])));
5908   emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k));
5909   emit_move_insn (operands[0], tmp[2]);
5910   DONE;
5913 (define_expand "vec_pack_trunc_<mode>"
5914   [(set (match_dup 3)
5915         (float_truncate:<sf2dfmode>
5916           (match_operand:VF2_512_256 1 "nonimmediate_operand")))
5917    (set (match_dup 4)
5918         (float_truncate:<sf2dfmode>
5919           (match_operand:VF2_512_256 2 "nonimmediate_operand")))
5920    (set (match_operand:<ssePSmode> 0 "register_operand")
5921         (vec_concat:<ssePSmode>
5922           (match_dup 3)
5923           (match_dup 4)))]
5924   "TARGET_AVX"
5926   operands[3] = gen_reg_rtx (<sf2dfmode>mode);
5927   operands[4] = gen_reg_rtx (<sf2dfmode>mode);
5930 (define_expand "vec_pack_trunc_v2df"
5931   [(match_operand:V4SF 0 "register_operand")
5932    (match_operand:V2DF 1 "vector_operand")
5933    (match_operand:V2DF 2 "vector_operand")]
5934   "TARGET_SSE2"
5936   rtx tmp0, tmp1;
5938   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
5939     {
5940       tmp0 = gen_reg_rtx (V4DFmode);
5941       tmp1 = force_reg (V2DFmode, operands[1]);
5943       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
5944       emit_insn (gen_avx_cvtpd2ps256 (operands[0], tmp0));
5945     }
5946   else
5947     {
5948       tmp0 = gen_reg_rtx (V4SFmode);
5949       tmp1 = gen_reg_rtx (V4SFmode);
5951       emit_insn (gen_sse2_cvtpd2ps (tmp0, operands[1]));
5952       emit_insn (gen_sse2_cvtpd2ps (tmp1, operands[2]));
5953       emit_insn (gen_sse_movlhps (operands[0], tmp0, tmp1));
5954     }
5955   DONE;
5958 (define_expand "vec_pack_sfix_trunc_v8df"
5959   [(match_operand:V16SI 0 "register_operand")
5960    (match_operand:V8DF 1 "nonimmediate_operand")
5961    (match_operand:V8DF 2 "nonimmediate_operand")]
5962   "TARGET_AVX512F"
5964   rtx r1, r2;
5966   r1 = gen_reg_rtx (V8SImode);
5967   r2 = gen_reg_rtx (V8SImode);
5969   emit_insn (gen_fix_truncv8dfv8si2 (r1, operands[1]));
5970   emit_insn (gen_fix_truncv8dfv8si2 (r2, operands[2]));
5971   emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
5972   DONE;
5975 (define_expand "vec_pack_sfix_trunc_v4df"
5976   [(match_operand:V8SI 0 "register_operand")
5977    (match_operand:V4DF 1 "nonimmediate_operand")
5978    (match_operand:V4DF 2 "nonimmediate_operand")]
5979   "TARGET_AVX"
5981   rtx r1, r2;
5983   r1 = gen_reg_rtx (V4SImode);
5984   r2 = gen_reg_rtx (V4SImode);
5986   emit_insn (gen_fix_truncv4dfv4si2 (r1, operands[1]));
5987   emit_insn (gen_fix_truncv4dfv4si2 (r2, operands[2]));
5988   emit_insn (gen_avx_vec_concatv8si (operands[0], r1, r2));
5989   DONE;
5992 (define_expand "vec_pack_sfix_trunc_v2df"
5993   [(match_operand:V4SI 0 "register_operand")
5994    (match_operand:V2DF 1 "vector_operand")
5995    (match_operand:V2DF 2 "vector_operand")]
5996   "TARGET_SSE2"
5998   rtx tmp0, tmp1, tmp2;
6000   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
6001     {
6002       tmp0 = gen_reg_rtx (V4DFmode);
6003       tmp1 = force_reg (V2DFmode, operands[1]);
6005       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
6006       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp0));
6007     }
6008   else
6009     {
6010       tmp0 = gen_reg_rtx (V4SImode);
6011       tmp1 = gen_reg_rtx (V4SImode);
6012       tmp2 = gen_reg_rtx (V2DImode);
6014       emit_insn (gen_sse2_cvttpd2dq (tmp0, operands[1]));
6015       emit_insn (gen_sse2_cvttpd2dq (tmp1, operands[2]));
6016       emit_insn (gen_vec_interleave_lowv2di (tmp2,
6017                                              gen_lowpart (V2DImode, tmp0),
6018                                              gen_lowpart (V2DImode, tmp1)));
6019       emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp2));
6020     }
6021   DONE;
6024 (define_mode_attr ssepackfltmode
6025   [(V8DF "V16SI") (V4DF "V8SI") (V2DF "V4SI")])
6027 (define_expand "vec_pack_ufix_trunc_<mode>"
6028   [(match_operand:<ssepackfltmode> 0 "register_operand")
6029    (match_operand:VF2 1 "register_operand")
6030    (match_operand:VF2 2 "register_operand")]
6031   "TARGET_SSE2"
6033   if (<MODE>mode == V8DFmode)
6034     {
6035       rtx r1, r2;
6037       r1 = gen_reg_rtx (V8SImode);
6038       r2 = gen_reg_rtx (V8SImode);
6040       emit_insn (gen_fixuns_truncv8dfv8si2 (r1, operands[1]));
6041       emit_insn (gen_fixuns_truncv8dfv8si2 (r2, operands[2]));
6042       emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
6043     }
6044   else
6045     {
6046       rtx tmp[7];
6047       tmp[0] = ix86_expand_adjust_ufix_to_sfix_si (operands[1], &tmp[2]);
6048       tmp[1] = ix86_expand_adjust_ufix_to_sfix_si (operands[2], &tmp[3]);
6049       tmp[4] = gen_reg_rtx (<ssepackfltmode>mode);
6050       emit_insn (gen_vec_pack_sfix_trunc_<mode> (tmp[4], tmp[0], tmp[1]));
6051       if (<ssepackfltmode>mode == V4SImode || TARGET_AVX2)
6052         {
6053           tmp[5] = gen_reg_rtx (<ssepackfltmode>mode);
6054           ix86_expand_vec_extract_even_odd (tmp[5], tmp[2], tmp[3], 0);
6055         }
6056       else
6057         {
6058           tmp[5] = gen_reg_rtx (V8SFmode);
6059           ix86_expand_vec_extract_even_odd (tmp[5],
6060                                             gen_lowpart (V8SFmode, tmp[2]),
6061                                             gen_lowpart (V8SFmode, tmp[3]), 0);
6062           tmp[5] = gen_lowpart (V8SImode, tmp[5]);
6063         }
6064       tmp[6] = expand_simple_binop (<ssepackfltmode>mode, XOR, tmp[4], tmp[5],
6065                                     operands[0], 0, OPTAB_DIRECT);
6066       if (tmp[6] != operands[0])
6067         emit_move_insn (operands[0], tmp[6]);
6068     }
6070   DONE;
6073 (define_expand "avx512f_vec_pack_sfix_v8df"
6074   [(match_operand:V16SI 0 "register_operand")
6075    (match_operand:V8DF 1 "nonimmediate_operand")
6076    (match_operand:V8DF 2 "nonimmediate_operand")]
6077   "TARGET_AVX512F"
6079   rtx r1, r2;
6081   r1 = gen_reg_rtx (V8SImode);
6082   r2 = gen_reg_rtx (V8SImode);
6084   emit_insn (gen_avx512f_cvtpd2dq512 (r1, operands[1]));
6085   emit_insn (gen_avx512f_cvtpd2dq512 (r2, operands[2]));
6086   emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
6087   DONE;
6090 (define_expand "vec_pack_sfix_v4df"
6091   [(match_operand:V8SI 0 "register_operand")
6092    (match_operand:V4DF 1 "nonimmediate_operand")
6093    (match_operand:V4DF 2 "nonimmediate_operand")]
6094   "TARGET_AVX"
6096   rtx r1, r2;
6098   r1 = gen_reg_rtx (V4SImode);
6099   r2 = gen_reg_rtx (V4SImode);
6101   emit_insn (gen_avx_cvtpd2dq256 (r1, operands[1]));
6102   emit_insn (gen_avx_cvtpd2dq256 (r2, operands[2]));
6103   emit_insn (gen_avx_vec_concatv8si (operands[0], r1, r2));
6104   DONE;
6107 (define_expand "vec_pack_sfix_v2df"
6108   [(match_operand:V4SI 0 "register_operand")
6109    (match_operand:V2DF 1 "vector_operand")
6110    (match_operand:V2DF 2 "vector_operand")]
6111   "TARGET_SSE2"
6113   rtx tmp0, tmp1, tmp2;
6115   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
6116     {
6117       tmp0 = gen_reg_rtx (V4DFmode);
6118       tmp1 = force_reg (V2DFmode, operands[1]);
6120       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
6121       emit_insn (gen_avx_cvtpd2dq256 (operands[0], tmp0));
6122     }
6123   else
6124     {
6125       tmp0 = gen_reg_rtx (V4SImode);
6126       tmp1 = gen_reg_rtx (V4SImode);
6127       tmp2 = gen_reg_rtx (V2DImode);
6129       emit_insn (gen_sse2_cvtpd2dq (tmp0, operands[1]));
6130       emit_insn (gen_sse2_cvtpd2dq (tmp1, operands[2]));
6131       emit_insn (gen_vec_interleave_lowv2di (tmp2,
6132                                              gen_lowpart (V2DImode, tmp0),
6133                                              gen_lowpart (V2DImode, tmp1)));
6134       emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp2));
6135     }
6136   DONE;
6139 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6141 ;; Parallel single-precision floating point element swizzling
6143 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6145 (define_expand "sse_movhlps_exp"
6146   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6147         (vec_select:V4SF
6148           (vec_concat:V8SF
6149             (match_operand:V4SF 1 "nonimmediate_operand")
6150             (match_operand:V4SF 2 "nonimmediate_operand"))
6151           (parallel [(const_int 6)
6152                      (const_int 7)
6153                      (const_int 2)
6154                      (const_int 3)])))]
6155   "TARGET_SSE"
6157   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6159   emit_insn (gen_sse_movhlps (dst, operands[1], operands[2]));
6161   /* Fix up the destination if needed.  */
6162   if (dst != operands[0])
6163     emit_move_insn (operands[0], dst);
6165   DONE;
6168 (define_insn "sse_movhlps"
6169   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,m")
6170         (vec_select:V4SF
6171           (vec_concat:V8SF
6172             (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
6173             (match_operand:V4SF 2 "nonimmediate_operand" " x,v,o,o,v"))
6174           (parallel [(const_int 6)
6175                      (const_int 7)
6176                      (const_int 2)
6177                      (const_int 3)])))]
6178   "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
6179   "@
6180    movhlps\t{%2, %0|%0, %2}
6181    vmovhlps\t{%2, %1, %0|%0, %1, %2}
6182    movlps\t{%H2, %0|%0, %H2}
6183    vmovlps\t{%H2, %1, %0|%0, %1, %H2}
6184    %vmovhps\t{%2, %0|%q0, %2}"
6185   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6186    (set_attr "type" "ssemov")
6187    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
6188    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
6190 (define_expand "sse_movlhps_exp"
6191   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6192         (vec_select:V4SF
6193           (vec_concat:V8SF
6194             (match_operand:V4SF 1 "nonimmediate_operand")
6195             (match_operand:V4SF 2 "nonimmediate_operand"))
6196           (parallel [(const_int 0)
6197                      (const_int 1)
6198                      (const_int 4)
6199                      (const_int 5)])))]
6200   "TARGET_SSE"
6202   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6204   emit_insn (gen_sse_movlhps (dst, operands[1], operands[2]));
6206   /* Fix up the destination if needed.  */
6207   if (dst != operands[0])
6208     emit_move_insn (operands[0], dst);
6210   DONE;
6213 (define_insn "sse_movlhps"
6214   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,o")
6215         (vec_select:V4SF
6216           (vec_concat:V8SF
6217             (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
6218             (match_operand:V4SF 2 "nonimmediate_operand" " x,v,m,v,v"))
6219           (parallel [(const_int 0)
6220                      (const_int 1)
6221                      (const_int 4)
6222                      (const_int 5)])))]
6223   "TARGET_SSE && ix86_binary_operator_ok (UNKNOWN, V4SFmode, operands)"
6224   "@
6225    movlhps\t{%2, %0|%0, %2}
6226    vmovlhps\t{%2, %1, %0|%0, %1, %2}
6227    movhps\t{%2, %0|%0, %q2}
6228    vmovhps\t{%2, %1, %0|%0, %1, %q2}
6229    %vmovlps\t{%2, %H0|%H0, %2}"
6230   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6231    (set_attr "type" "ssemov")
6232    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
6233    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
6235 (define_insn "<mask_codefor>avx512f_unpckhps512<mask_name>"
6236   [(set (match_operand:V16SF 0 "register_operand" "=v")
6237         (vec_select:V16SF
6238           (vec_concat:V32SF
6239             (match_operand:V16SF 1 "register_operand" "v")
6240             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
6241           (parallel [(const_int 2) (const_int 18)
6242                      (const_int 3) (const_int 19)
6243                      (const_int 6) (const_int 22)
6244                      (const_int 7) (const_int 23)
6245                      (const_int 10) (const_int 26)
6246                      (const_int 11) (const_int 27)
6247                      (const_int 14) (const_int 30)
6248                      (const_int 15) (const_int 31)])))]
6249   "TARGET_AVX512F"
6250   "vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6251   [(set_attr "type" "sselog")
6252    (set_attr "prefix" "evex")
6253    (set_attr "mode" "V16SF")])
6255 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
6256 (define_insn "avx_unpckhps256<mask_name>"
6257   [(set (match_operand:V8SF 0 "register_operand" "=v")
6258         (vec_select:V8SF
6259           (vec_concat:V16SF
6260             (match_operand:V8SF 1 "register_operand" "v")
6261             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6262           (parallel [(const_int 2) (const_int 10)
6263                      (const_int 3) (const_int 11)
6264                      (const_int 6) (const_int 14)
6265                      (const_int 7) (const_int 15)])))]
6266   "TARGET_AVX && <mask_avx512vl_condition>"
6267   "vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6268   [(set_attr "type" "sselog")
6269    (set_attr "prefix" "vex")
6270    (set_attr "mode" "V8SF")])
6272 (define_expand "vec_interleave_highv8sf"
6273   [(set (match_dup 3)
6274         (vec_select:V8SF
6275           (vec_concat:V16SF
6276             (match_operand:V8SF 1 "register_operand")
6277             (match_operand:V8SF 2 "nonimmediate_operand"))
6278           (parallel [(const_int 0) (const_int 8)
6279                      (const_int 1) (const_int 9)
6280                      (const_int 4) (const_int 12)
6281                      (const_int 5) (const_int 13)])))
6282    (set (match_dup 4)
6283         (vec_select:V8SF
6284           (vec_concat:V16SF
6285             (match_dup 1)
6286             (match_dup 2))
6287           (parallel [(const_int 2) (const_int 10)
6288                      (const_int 3) (const_int 11)
6289                      (const_int 6) (const_int 14)
6290                      (const_int 7) (const_int 15)])))
6291    (set (match_operand:V8SF 0 "register_operand")
6292         (vec_select:V8SF
6293           (vec_concat:V16SF
6294             (match_dup 3)
6295             (match_dup 4))
6296           (parallel [(const_int 4) (const_int 5)
6297                      (const_int 6) (const_int 7)
6298                      (const_int 12) (const_int 13)
6299                      (const_int 14) (const_int 15)])))]
6300  "TARGET_AVX"
6302   operands[3] = gen_reg_rtx (V8SFmode);
6303   operands[4] = gen_reg_rtx (V8SFmode);
6306 (define_insn "vec_interleave_highv4sf<mask_name>"
6307   [(set (match_operand:V4SF 0 "register_operand" "=x,v")
6308         (vec_select:V4SF
6309           (vec_concat:V8SF
6310             (match_operand:V4SF 1 "register_operand" "0,v")
6311             (match_operand:V4SF 2 "vector_operand" "xBm,vm"))
6312           (parallel [(const_int 2) (const_int 6)
6313                      (const_int 3) (const_int 7)])))]
6314   "TARGET_SSE && <mask_avx512vl_condition>"
6315   "@
6316    unpckhps\t{%2, %0|%0, %2}
6317    vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6318   [(set_attr "isa" "noavx,avx")
6319    (set_attr "type" "sselog")
6320    (set_attr "prefix" "orig,vex")
6321    (set_attr "mode" "V4SF")])
6323 (define_insn "<mask_codefor>avx512f_unpcklps512<mask_name>"
6324   [(set (match_operand:V16SF 0 "register_operand" "=v")
6325         (vec_select:V16SF
6326           (vec_concat:V32SF
6327             (match_operand:V16SF 1 "register_operand" "v")
6328             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
6329           (parallel [(const_int 0) (const_int 16)
6330                      (const_int 1) (const_int 17)
6331                      (const_int 4) (const_int 20)
6332                      (const_int 5) (const_int 21)
6333                      (const_int 8) (const_int 24)
6334                      (const_int 9) (const_int 25)
6335                      (const_int 12) (const_int 28)
6336                      (const_int 13) (const_int 29)])))]
6337   "TARGET_AVX512F"
6338   "vunpcklps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6339   [(set_attr "type" "sselog")
6340    (set_attr "prefix" "evex")
6341    (set_attr "mode" "V16SF")])
6343 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
6344 (define_insn "avx_unpcklps256<mask_name>"
6345   [(set (match_operand:V8SF 0 "register_operand" "=v")
6346         (vec_select:V8SF
6347           (vec_concat:V16SF
6348             (match_operand:V8SF 1 "register_operand" "v")
6349             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6350           (parallel [(const_int 0) (const_int 8)
6351                      (const_int 1) (const_int 9)
6352                      (const_int 4) (const_int 12)
6353                      (const_int 5) (const_int 13)])))]
6354   "TARGET_AVX && <mask_avx512vl_condition>"
6355   "vunpcklps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6356   [(set_attr "type" "sselog")
6357    (set_attr "prefix" "vex")
6358    (set_attr "mode" "V8SF")])
6360 (define_insn "unpcklps128_mask"
6361   [(set (match_operand:V4SF 0 "register_operand" "=v")
6362         (vec_merge:V4SF
6363           (vec_select:V4SF
6364             (vec_concat:V8SF
6365               (match_operand:V4SF 1 "register_operand" "v")
6366               (match_operand:V4SF 2 "nonimmediate_operand" "vm"))
6367             (parallel [(const_int 0) (const_int 4)
6368                       (const_int 1) (const_int 5)]))
6369           (match_operand:V4SF 3 "vector_move_operand" "0C")
6370           (match_operand:QI 4 "register_operand" "Yk")))]
6371   "TARGET_AVX512VL"
6372   "vunpcklps\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
6373   [(set_attr "type" "sselog")
6374    (set_attr "prefix" "evex")
6375    (set_attr "mode" "V4SF")])
6377 (define_expand "vec_interleave_lowv8sf"
6378   [(set (match_dup 3)
6379         (vec_select:V8SF
6380           (vec_concat:V16SF
6381             (match_operand:V8SF 1 "register_operand")
6382             (match_operand:V8SF 2 "nonimmediate_operand"))
6383           (parallel [(const_int 0) (const_int 8)
6384                      (const_int 1) (const_int 9)
6385                      (const_int 4) (const_int 12)
6386                      (const_int 5) (const_int 13)])))
6387    (set (match_dup 4)
6388         (vec_select:V8SF
6389           (vec_concat:V16SF
6390             (match_dup 1)
6391             (match_dup 2))
6392           (parallel [(const_int 2) (const_int 10)
6393                      (const_int 3) (const_int 11)
6394                      (const_int 6) (const_int 14)
6395                      (const_int 7) (const_int 15)])))
6396    (set (match_operand:V8SF 0 "register_operand")
6397         (vec_select:V8SF
6398           (vec_concat:V16SF
6399             (match_dup 3)
6400             (match_dup 4))
6401           (parallel [(const_int 0) (const_int 1)
6402                      (const_int 2) (const_int 3)
6403                      (const_int 8) (const_int 9)
6404                      (const_int 10) (const_int 11)])))]
6405  "TARGET_AVX"
6407   operands[3] = gen_reg_rtx (V8SFmode);
6408   operands[4] = gen_reg_rtx (V8SFmode);
6411 (define_insn "vec_interleave_lowv4sf"
6412   [(set (match_operand:V4SF 0 "register_operand" "=x,v")
6413         (vec_select:V4SF
6414           (vec_concat:V8SF
6415             (match_operand:V4SF 1 "register_operand" "0,v")
6416             (match_operand:V4SF 2 "vector_operand" "xBm,vm"))
6417           (parallel [(const_int 0) (const_int 4)
6418                      (const_int 1) (const_int 5)])))]
6419   "TARGET_SSE"
6420   "@
6421    unpcklps\t{%2, %0|%0, %2}
6422    vunpcklps\t{%2, %1, %0|%0, %1, %2}"
6423   [(set_attr "isa" "noavx,avx")
6424    (set_attr "type" "sselog")
6425    (set_attr "prefix" "orig,maybe_evex")
6426    (set_attr "mode" "V4SF")])
6428 ;; These are modeled with the same vec_concat as the others so that we
6429 ;; capture users of shufps that can use the new instructions
6430 (define_insn "avx_movshdup256<mask_name>"
6431   [(set (match_operand:V8SF 0 "register_operand" "=v")
6432         (vec_select:V8SF
6433           (vec_concat:V16SF
6434             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
6435             (match_dup 1))
6436           (parallel [(const_int 1) (const_int 1)
6437                      (const_int 3) (const_int 3)
6438                      (const_int 5) (const_int 5)
6439                      (const_int 7) (const_int 7)])))]
6440   "TARGET_AVX && <mask_avx512vl_condition>"
6441   "vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6442   [(set_attr "type" "sse")
6443    (set_attr "prefix" "vex")
6444    (set_attr "mode" "V8SF")])
6446 (define_insn "sse3_movshdup<mask_name>"
6447   [(set (match_operand:V4SF 0 "register_operand" "=v")
6448         (vec_select:V4SF
6449           (vec_concat:V8SF
6450             (match_operand:V4SF 1 "vector_operand" "vBm")
6451             (match_dup 1))
6452           (parallel [(const_int 1)
6453                      (const_int 1)
6454                      (const_int 7)
6455                      (const_int 7)])))]
6456   "TARGET_SSE3 && <mask_avx512vl_condition>"
6457   "%vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6458   [(set_attr "type" "sse")
6459    (set_attr "prefix_rep" "1")
6460    (set_attr "prefix" "maybe_vex")
6461    (set_attr "mode" "V4SF")])
6463 (define_insn "<mask_codefor>avx512f_movshdup512<mask_name>"
6464   [(set (match_operand:V16SF 0 "register_operand" "=v")
6465         (vec_select:V16SF
6466           (vec_concat:V32SF
6467             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
6468             (match_dup 1))
6469           (parallel [(const_int 1) (const_int 1)
6470                      (const_int 3) (const_int 3)
6471                      (const_int 5) (const_int 5)
6472                      (const_int 7) (const_int 7)
6473                      (const_int 9) (const_int 9)
6474                      (const_int 11) (const_int 11)
6475                      (const_int 13) (const_int 13)
6476                      (const_int 15) (const_int 15)])))]
6477   "TARGET_AVX512F"
6478   "vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6479   [(set_attr "type" "sse")
6480    (set_attr "prefix" "evex")
6481    (set_attr "mode" "V16SF")])
6483 (define_insn "avx_movsldup256<mask_name>"
6484   [(set (match_operand:V8SF 0 "register_operand" "=v")
6485         (vec_select:V8SF
6486           (vec_concat:V16SF
6487             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
6488             (match_dup 1))
6489           (parallel [(const_int 0) (const_int 0)
6490                      (const_int 2) (const_int 2)
6491                      (const_int 4) (const_int 4)
6492                      (const_int 6) (const_int 6)])))]
6493   "TARGET_AVX && <mask_avx512vl_condition>"
6494   "vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6495   [(set_attr "type" "sse")
6496    (set_attr "prefix" "vex")
6497    (set_attr "mode" "V8SF")])
6499 (define_insn "sse3_movsldup<mask_name>"
6500   [(set (match_operand:V4SF 0 "register_operand" "=v")
6501         (vec_select:V4SF
6502           (vec_concat:V8SF
6503             (match_operand:V4SF 1 "vector_operand" "vBm")
6504             (match_dup 1))
6505           (parallel [(const_int 0)
6506                      (const_int 0)
6507                      (const_int 6)
6508                      (const_int 6)])))]
6509   "TARGET_SSE3 && <mask_avx512vl_condition>"
6510   "%vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6511   [(set_attr "type" "sse")
6512    (set_attr "prefix_rep" "1")
6513    (set_attr "prefix" "maybe_vex")
6514    (set_attr "mode" "V4SF")])
6516 (define_insn "<mask_codefor>avx512f_movsldup512<mask_name>"
6517   [(set (match_operand:V16SF 0 "register_operand" "=v")
6518         (vec_select:V16SF
6519           (vec_concat:V32SF
6520             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
6521             (match_dup 1))
6522           (parallel [(const_int 0) (const_int 0)
6523                      (const_int 2) (const_int 2)
6524                      (const_int 4) (const_int 4)
6525                      (const_int 6) (const_int 6)
6526                      (const_int 8) (const_int 8)
6527                      (const_int 10) (const_int 10)
6528                      (const_int 12) (const_int 12)
6529                      (const_int 14) (const_int 14)])))]
6530   "TARGET_AVX512F"
6531   "vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6532   [(set_attr "type" "sse")
6533    (set_attr "prefix" "evex")
6534    (set_attr "mode" "V16SF")])
6536 (define_expand "avx_shufps256<mask_expand4_name>"
6537   [(match_operand:V8SF 0 "register_operand")
6538    (match_operand:V8SF 1 "register_operand")
6539    (match_operand:V8SF 2 "nonimmediate_operand")
6540    (match_operand:SI 3 "const_int_operand")]
6541   "TARGET_AVX"
6543   int mask = INTVAL (operands[3]);
6544   emit_insn (gen_avx_shufps256_1<mask_expand4_name> (operands[0],
6545                                                      operands[1],
6546                                                      operands[2],
6547                                                      GEN_INT ((mask >> 0) & 3),
6548                                                      GEN_INT ((mask >> 2) & 3),
6549                                                      GEN_INT (((mask >> 4) & 3) + 8),
6550                                                      GEN_INT (((mask >> 6) & 3) + 8),
6551                                                      GEN_INT (((mask >> 0) & 3) + 4),
6552                                                      GEN_INT (((mask >> 2) & 3) + 4),
6553                                                      GEN_INT (((mask >> 4) & 3) + 12),
6554                                                      GEN_INT (((mask >> 6) & 3) + 12)
6555                                                      <mask_expand4_args>));
6556   DONE;
6559 ;; One bit in mask selects 2 elements.
6560 (define_insn "avx_shufps256_1<mask_name>"
6561   [(set (match_operand:V8SF 0 "register_operand" "=v")
6562         (vec_select:V8SF
6563           (vec_concat:V16SF
6564             (match_operand:V8SF 1 "register_operand" "v")
6565             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6566           (parallel [(match_operand 3  "const_0_to_3_operand"  )
6567                      (match_operand 4  "const_0_to_3_operand"  )
6568                      (match_operand 5  "const_8_to_11_operand" )
6569                      (match_operand 6  "const_8_to_11_operand" )
6570                      (match_operand 7  "const_4_to_7_operand"  )
6571                      (match_operand 8  "const_4_to_7_operand"  )
6572                      (match_operand 9  "const_12_to_15_operand")
6573                      (match_operand 10 "const_12_to_15_operand")])))]
6574   "TARGET_AVX
6575    && <mask_avx512vl_condition>
6576    && (INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
6577        && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
6578        && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4)
6579        && INTVAL (operands[6]) == (INTVAL (operands[10]) - 4))"
6581   int mask;
6582   mask = INTVAL (operands[3]);
6583   mask |= INTVAL (operands[4]) << 2;
6584   mask |= (INTVAL (operands[5]) - 8) << 4;
6585   mask |= (INTVAL (operands[6]) - 8) << 6;
6586   operands[3] = GEN_INT (mask);
6588   return "vshufps\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
6590   [(set_attr "type" "sseshuf")
6591    (set_attr "length_immediate" "1")
6592    (set_attr "prefix" "<mask_prefix>")
6593    (set_attr "mode" "V8SF")])
6595 (define_expand "sse_shufps<mask_expand4_name>"
6596   [(match_operand:V4SF 0 "register_operand")
6597    (match_operand:V4SF 1 "register_operand")
6598    (match_operand:V4SF 2 "vector_operand")
6599    (match_operand:SI 3 "const_int_operand")]
6600   "TARGET_SSE"
6602   int mask = INTVAL (operands[3]);
6603   emit_insn (gen_sse_shufps_v4sf<mask_expand4_name> (operands[0],
6604                                                      operands[1],
6605                                                      operands[2],
6606                                                      GEN_INT ((mask >> 0) & 3),
6607                                                      GEN_INT ((mask >> 2) & 3),
6608                                                      GEN_INT (((mask >> 4) & 3) + 4),
6609                                                      GEN_INT (((mask >> 6) & 3) + 4)
6610                                                      <mask_expand4_args>));
6611   DONE;
6614 (define_insn "sse_shufps_v4sf_mask"
6615   [(set (match_operand:V4SF 0 "register_operand" "=v")
6616     (vec_merge:V4SF
6617           (vec_select:V4SF
6618             (vec_concat:V8SF
6619               (match_operand:V4SF 1 "register_operand" "v")
6620               (match_operand:V4SF 2 "nonimmediate_operand" "vm"))
6621             (parallel [(match_operand 3 "const_0_to_3_operand")
6622                        (match_operand 4 "const_0_to_3_operand")
6623                        (match_operand 5 "const_4_to_7_operand")
6624                        (match_operand 6 "const_4_to_7_operand")]))
6625       (match_operand:V4SF 7 "vector_move_operand" "0C")
6626       (match_operand:QI 8 "register_operand" "Yk")))]
6627   "TARGET_AVX512VL"
6629   int mask = 0;
6630   mask |= INTVAL (operands[3]) << 0;
6631   mask |= INTVAL (operands[4]) << 2;
6632   mask |= (INTVAL (operands[5]) - 4) << 4;
6633   mask |= (INTVAL (operands[6]) - 4) << 6;
6634   operands[3] = GEN_INT (mask);
6636   return "vshufps\t{%3, %2, %1, %0%{%8%}%N7|%0%{%8%}%N7, %1, %2, %3}";
6638   [(set_attr "type" "sseshuf")
6639    (set_attr "length_immediate" "1")
6640    (set_attr "prefix" "evex")
6641    (set_attr "mode" "V4SF")])
6643 (define_insn "sse_shufps_<mode>"
6644   [(set (match_operand:VI4F_128 0 "register_operand" "=x,v")
6645         (vec_select:VI4F_128
6646           (vec_concat:<ssedoublevecmode>
6647             (match_operand:VI4F_128 1 "register_operand" "0,v")
6648             (match_operand:VI4F_128 2 "vector_operand" "xBm,vm"))
6649           (parallel [(match_operand 3 "const_0_to_3_operand")
6650                      (match_operand 4 "const_0_to_3_operand")
6651                      (match_operand 5 "const_4_to_7_operand")
6652                      (match_operand 6 "const_4_to_7_operand")])))]
6653   "TARGET_SSE"
6655   int mask = 0;
6656   mask |= INTVAL (operands[3]) << 0;
6657   mask |= INTVAL (operands[4]) << 2;
6658   mask |= (INTVAL (operands[5]) - 4) << 4;
6659   mask |= (INTVAL (operands[6]) - 4) << 6;
6660   operands[3] = GEN_INT (mask);
6662   switch (which_alternative)
6663     {
6664     case 0:
6665       return "shufps\t{%3, %2, %0|%0, %2, %3}";
6666     case 1:
6667       return "vshufps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
6668     default:
6669       gcc_unreachable ();
6670     }
6672   [(set_attr "isa" "noavx,avx")
6673    (set_attr "type" "sseshuf")
6674    (set_attr "length_immediate" "1")
6675    (set_attr "prefix" "orig,maybe_evex")
6676    (set_attr "mode" "V4SF")])
6678 (define_insn "sse_storehps"
6679   [(set (match_operand:V2SF 0 "nonimmediate_operand" "=m,v,v")
6680         (vec_select:V2SF
6681           (match_operand:V4SF 1 "nonimmediate_operand" "v,v,o")
6682           (parallel [(const_int 2) (const_int 3)])))]
6683   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
6684   "@
6685    %vmovhps\t{%1, %0|%q0, %1}
6686    %vmovhlps\t{%1, %d0|%d0, %1}
6687    %vmovlps\t{%H1, %d0|%d0, %H1}"
6688   [(set_attr "type" "ssemov")
6689    (set_attr "prefix" "maybe_vex")
6690    (set_attr "mode" "V2SF,V4SF,V2SF")])
6692 (define_expand "sse_loadhps_exp"
6693   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6694         (vec_concat:V4SF
6695           (vec_select:V2SF
6696             (match_operand:V4SF 1 "nonimmediate_operand")
6697             (parallel [(const_int 0) (const_int 1)]))
6698           (match_operand:V2SF 2 "nonimmediate_operand")))]
6699   "TARGET_SSE"
6701   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6703   emit_insn (gen_sse_loadhps (dst, operands[1], operands[2]));
6705   /* Fix up the destination if needed.  */
6706   if (dst != operands[0])
6707     emit_move_insn (operands[0], dst);
6709   DONE;
6712 (define_insn "sse_loadhps"
6713   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,o")
6714         (vec_concat:V4SF
6715           (vec_select:V2SF
6716             (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
6717             (parallel [(const_int 0) (const_int 1)]))
6718           (match_operand:V2SF 2 "nonimmediate_operand"   " m,m,x,v,v")))]
6719   "TARGET_SSE"
6720   "@
6721    movhps\t{%2, %0|%0, %q2}
6722    vmovhps\t{%2, %1, %0|%0, %1, %q2}
6723    movlhps\t{%2, %0|%0, %2}
6724    vmovlhps\t{%2, %1, %0|%0, %1, %2}
6725    %vmovlps\t{%2, %H0|%H0, %2}"
6726   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6727    (set_attr "type" "ssemov")
6728    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
6729    (set_attr "mode" "V2SF,V2SF,V4SF,V4SF,V2SF")])
6731 (define_insn "sse_storelps"
6732   [(set (match_operand:V2SF 0 "nonimmediate_operand"   "=m,v,v")
6733         (vec_select:V2SF
6734           (match_operand:V4SF 1 "nonimmediate_operand" " v,v,m")
6735           (parallel [(const_int 0) (const_int 1)])))]
6736   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
6737   "@
6738    %vmovlps\t{%1, %0|%q0, %1}
6739    %vmovaps\t{%1, %0|%0, %1}
6740    %vmovlps\t{%1, %d0|%d0, %q1}"
6741   [(set_attr "type" "ssemov")
6742    (set_attr "prefix" "maybe_vex")
6743    (set_attr "mode" "V2SF,V4SF,V2SF")])
6745 (define_expand "sse_loadlps_exp"
6746   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6747         (vec_concat:V4SF
6748           (match_operand:V2SF 2 "nonimmediate_operand")
6749           (vec_select:V2SF
6750             (match_operand:V4SF 1 "nonimmediate_operand")
6751             (parallel [(const_int 2) (const_int 3)]))))]
6752   "TARGET_SSE"
6754   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6756   emit_insn (gen_sse_loadlps (dst, operands[1], operands[2]));
6758   /* Fix up the destination if needed.  */
6759   if (dst != operands[0])
6760     emit_move_insn (operands[0], dst);
6762   DONE;
6765 (define_insn "sse_loadlps"
6766   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,m")
6767         (vec_concat:V4SF
6768           (match_operand:V2SF 2 "nonimmediate_operand"   " 0,v,m,m,v")
6769           (vec_select:V2SF
6770             (match_operand:V4SF 1 "nonimmediate_operand" " x,v,0,v,0")
6771             (parallel [(const_int 2) (const_int 3)]))))]
6772   "TARGET_SSE"
6773   "@
6774    shufps\t{$0xe4, %1, %0|%0, %1, 0xe4}
6775    vshufps\t{$0xe4, %1, %2, %0|%0, %2, %1, 0xe4}
6776    movlps\t{%2, %0|%0, %q2}
6777    vmovlps\t{%2, %1, %0|%0, %1, %q2}
6778    %vmovlps\t{%2, %0|%q0, %2}"
6779   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6780    (set_attr "type" "sseshuf,sseshuf,ssemov,ssemov,ssemov")
6781    (set (attr "length_immediate")
6782      (if_then_else (eq_attr "alternative" "0,1")
6783                    (const_string "1")
6784                    (const_string "*")))
6785    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
6786    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
6788 (define_insn "sse_movss"
6789   [(set (match_operand:V4SF 0 "register_operand"   "=x,v")
6790         (vec_merge:V4SF
6791           (match_operand:V4SF 2 "register_operand" " x,v")
6792           (match_operand:V4SF 1 "register_operand" " 0,v")
6793           (const_int 1)))]
6794   "TARGET_SSE"
6795   "@
6796    movss\t{%2, %0|%0, %2}
6797    vmovss\t{%2, %1, %0|%0, %1, %2}"
6798   [(set_attr "isa" "noavx,avx")
6799    (set_attr "type" "ssemov")
6800    (set_attr "prefix" "orig,maybe_evex")
6801    (set_attr "mode" "SF")])
6803 (define_insn "avx2_vec_dup<mode>"
6804   [(set (match_operand:VF1_128_256 0 "register_operand" "=v")
6805         (vec_duplicate:VF1_128_256
6806           (vec_select:SF
6807             (match_operand:V4SF 1 "register_operand" "v")
6808             (parallel [(const_int 0)]))))]
6809   "TARGET_AVX2"
6810   "vbroadcastss\t{%1, %0|%0, %1}"
6811   [(set_attr "type" "sselog1")
6812     (set_attr "prefix" "maybe_evex")
6813     (set_attr "mode" "<MODE>")])
6815 (define_insn "avx2_vec_dupv8sf_1"
6816   [(set (match_operand:V8SF 0 "register_operand" "=v")
6817         (vec_duplicate:V8SF
6818           (vec_select:SF
6819             (match_operand:V8SF 1 "register_operand" "v")
6820             (parallel [(const_int 0)]))))]
6821   "TARGET_AVX2"
6822   "vbroadcastss\t{%x1, %0|%0, %x1}"
6823   [(set_attr "type" "sselog1")
6824     (set_attr "prefix" "maybe_evex")
6825     (set_attr "mode" "V8SF")])
6827 (define_insn "avx512f_vec_dup<mode>_1"
6828   [(set (match_operand:VF_512 0 "register_operand" "=v")
6829         (vec_duplicate:VF_512
6830           (vec_select:<ssescalarmode>
6831             (match_operand:VF_512 1 "register_operand" "v")
6832             (parallel [(const_int 0)]))))]
6833   "TARGET_AVX512F"
6834   "vbroadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}"
6835   [(set_attr "type" "sselog1")
6836     (set_attr "prefix" "evex")
6837     (set_attr "mode" "<MODE>")])
6839 ;; Although insertps takes register source, we prefer
6840 ;; unpcklps with register source since it is shorter.
6841 (define_insn "*vec_concatv2sf_sse4_1"
6842   [(set (match_operand:V2SF 0 "register_operand"
6843           "=Yr,*x, v,Yr,*x,v,v,*y ,*y")
6844         (vec_concat:V2SF
6845           (match_operand:SF 1 "nonimmediate_operand"
6846           "  0, 0,Yv, 0,0, v,m, 0 , m")
6847           (match_operand:SF 2 "vector_move_operand"
6848           " Yr,*x,Yv, m,m, m,C,*ym, C")))]
6849   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
6850   "@
6851    unpcklps\t{%2, %0|%0, %2}
6852    unpcklps\t{%2, %0|%0, %2}
6853    vunpcklps\t{%2, %1, %0|%0, %1, %2}
6854    insertps\t{$0x10, %2, %0|%0, %2, 0x10}
6855    insertps\t{$0x10, %2, %0|%0, %2, 0x10}
6856    vinsertps\t{$0x10, %2, %1, %0|%0, %1, %2, 0x10}
6857    %vmovss\t{%1, %0|%0, %1}
6858    punpckldq\t{%2, %0|%0, %2}
6859    movd\t{%1, %0|%0, %1}"
6860   [(set (attr "isa")
6861      (cond [(eq_attr "alternative" "0,1,3,4")
6862               (const_string "noavx")
6863             (eq_attr "alternative" "2,5")
6864               (const_string "avx")
6865            ]
6866            (const_string "*")))
6867    (set (attr "type")
6868      (cond [(eq_attr "alternative" "6")
6869               (const_string "ssemov")
6870             (eq_attr "alternative" "7")
6871               (const_string "mmxcvt")
6872             (eq_attr "alternative" "8")
6873               (const_string "mmxmov")
6874            ]
6875            (const_string "sselog")))
6876    (set (attr "prefix_data16")
6877      (if_then_else (eq_attr "alternative" "3,4")
6878                    (const_string "1")
6879                    (const_string "*")))
6880    (set (attr "prefix_extra")
6881      (if_then_else (eq_attr "alternative" "3,4,5")
6882                    (const_string "1")
6883                    (const_string "*")))
6884    (set (attr "length_immediate")
6885      (if_then_else (eq_attr "alternative" "3,4,5")
6886                    (const_string "1")
6887                    (const_string "*")))
6888    (set (attr "prefix")
6889      (cond [(eq_attr "alternative" "2,5")
6890               (const_string "maybe_evex")
6891             (eq_attr "alternative" "6")
6892               (const_string "maybe_vex")
6893            ]
6894            (const_string "orig")))
6895    (set_attr "mode" "V4SF,V4SF,V4SF,V4SF,V4SF,V4SF,SF,DI,DI")])
6897 ;; ??? In theory we can match memory for the MMX alternative, but allowing
6898 ;; vector_operand for operand 2 and *not* allowing memory for the SSE
6899 ;; alternatives pretty much forces the MMX alternative to be chosen.
6900 (define_insn "*vec_concatv2sf_sse"
6901   [(set (match_operand:V2SF 0 "register_operand"     "=x,x,*y,*y")
6902         (vec_concat:V2SF
6903           (match_operand:SF 1 "nonimmediate_operand" " 0,m, 0, m")
6904           (match_operand:SF 2 "reg_or_0_operand"     " x,C,*y, C")))]
6905   "TARGET_SSE"
6906   "@
6907    unpcklps\t{%2, %0|%0, %2}
6908    movss\t{%1, %0|%0, %1}
6909    punpckldq\t{%2, %0|%0, %2}
6910    movd\t{%1, %0|%0, %1}"
6911   [(set_attr "type" "sselog,ssemov,mmxcvt,mmxmov")
6912    (set_attr "mode" "V4SF,SF,DI,DI")])
6914 (define_insn "*vec_concatv4sf"
6915   [(set (match_operand:V4SF 0 "register_operand"       "=x,v,x,v")
6916         (vec_concat:V4SF
6917           (match_operand:V2SF 1 "register_operand"     " 0,v,0,v")
6918           (match_operand:V2SF 2 "nonimmediate_operand" " x,v,m,m")))]
6919   "TARGET_SSE"
6920   "@
6921    movlhps\t{%2, %0|%0, %2}
6922    vmovlhps\t{%2, %1, %0|%0, %1, %2}
6923    movhps\t{%2, %0|%0, %q2}
6924    vmovhps\t{%2, %1, %0|%0, %1, %q2}"
6925   [(set_attr "isa" "noavx,avx,noavx,avx")
6926    (set_attr "type" "ssemov")
6927    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex")
6928    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF")])
6930 ;; Avoid combining registers from different units in a single alternative,
6931 ;; see comment above inline_secondary_memory_needed function in i386.c
6932 (define_insn "vec_set<mode>_0"
6933   [(set (match_operand:VI4F_128 0 "nonimmediate_operand"
6934           "=Yr,*x,v,v,v,x,x,v,Yr ,*x ,x  ,m ,m   ,m")
6935         (vec_merge:VI4F_128
6936           (vec_duplicate:VI4F_128
6937             (match_operand:<ssescalarmode> 2 "general_operand"
6938           " Yr,*x,v,m,r ,m,x,v,*rm,*rm,*rm,!x,!*re,!*fF"))
6939           (match_operand:VI4F_128 1 "vector_move_operand"
6940           " C , C,C,C,C ,C,0,v,0  ,0  ,x  ,0 ,0   ,0")
6941           (const_int 1)))]
6942   "TARGET_SSE"
6943   "@
6944    insertps\t{$0xe, %2, %0|%0, %2, 0xe}
6945    insertps\t{$0xe, %2, %0|%0, %2, 0xe}
6946    vinsertps\t{$0xe, %2, %2, %0|%0, %2, %2, 0xe}
6947    %vmov<ssescalarmodesuffix>\t{%2, %0|%0, %2}
6948    %vmovd\t{%2, %0|%0, %2}
6949    movss\t{%2, %0|%0, %2}
6950    movss\t{%2, %0|%0, %2}
6951    vmovss\t{%2, %1, %0|%0, %1, %2}
6952    pinsrd\t{$0, %2, %0|%0, %2, 0}
6953    pinsrd\t{$0, %2, %0|%0, %2, 0}
6954    vpinsrd\t{$0, %2, %1, %0|%0, %1, %2, 0}
6955    #
6956    #
6957    #"
6958   [(set (attr "isa")
6959      (cond [(eq_attr "alternative" "0,1,8,9")
6960               (const_string "sse4_noavx")
6961             (eq_attr "alternative" "2,7,10")
6962               (const_string "avx")
6963             (eq_attr "alternative" "3,4")
6964               (const_string "sse2")
6965             (eq_attr "alternative" "5,6")
6966               (const_string "noavx")
6967            ]
6968            (const_string "*")))
6969    (set (attr "type")
6970      (cond [(eq_attr "alternative" "0,1,2,8,9,10")
6971               (const_string "sselog")
6972             (eq_attr "alternative" "12")
6973               (const_string "imov")
6974             (eq_attr "alternative" "13")
6975               (const_string "fmov")
6976            ]
6977            (const_string "ssemov")))
6978    (set (attr "prefix_extra")
6979      (if_then_else (eq_attr "alternative" "8,9,10")
6980                    (const_string "1")
6981                    (const_string "*")))
6982    (set (attr "length_immediate")
6983      (if_then_else (eq_attr "alternative" "8,9,10")
6984                    (const_string "1")
6985                    (const_string "*")))
6986    (set (attr "prefix")
6987      (cond [(eq_attr "alternative" "0,1,5,6,8,9")
6988               (const_string "orig")
6989             (eq_attr "alternative" "2")
6990               (const_string "maybe_evex")
6991             (eq_attr "alternative" "3,4")
6992               (const_string "maybe_vex")
6993             (eq_attr "alternative" "7,10")
6994               (const_string "vex")
6995            ]
6996            (const_string "*")))
6997    (set_attr "mode" "SF,SF,SF,<ssescalarmode>,SI,SF,SF,SF,TI,TI,TI,*,*,*")
6998    (set (attr "preferred_for_speed")
6999      (cond [(eq_attr "alternative" "4")
7000               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
7001            ]
7002            (symbol_ref "true")))])
7004 ;; A subset is vec_setv4sf.
7005 (define_insn "*vec_setv4sf_sse4_1"
7006   [(set (match_operand:V4SF 0 "register_operand" "=Yr,*x,v")
7007         (vec_merge:V4SF
7008           (vec_duplicate:V4SF
7009             (match_operand:SF 2 "nonimmediate_operand" "Yrm,*xm,vm"))
7010           (match_operand:V4SF 1 "register_operand" "0,0,v")
7011           (match_operand:SI 3 "const_int_operand")))]
7012   "TARGET_SSE4_1
7013    && ((unsigned) exact_log2 (INTVAL (operands[3]))
7014        < GET_MODE_NUNITS (V4SFmode))"
7016   operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])) << 4);
7017   switch (which_alternative)
7018     {
7019     case 0:
7020     case 1:
7021       return "insertps\t{%3, %2, %0|%0, %2, %3}";
7022     case 2:
7023       return "vinsertps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
7024     default:
7025       gcc_unreachable ();
7026     }
7028   [(set_attr "isa" "noavx,noavx,avx")
7029    (set_attr "type" "sselog")
7030    (set_attr "prefix_data16" "1,1,*")
7031    (set_attr "prefix_extra" "1")
7032    (set_attr "length_immediate" "1")
7033    (set_attr "prefix" "orig,orig,maybe_evex")
7034    (set_attr "mode" "V4SF")])
7036 ;; All of vinsertps, vmovss, vmovd clear also the higher bits.
7037 (define_insn "vec_set<mode>_0"
7038   [(set (match_operand:VI4F_256_512 0 "register_operand" "=v,v,v")
7039         (vec_merge:VI4F_256_512
7040           (vec_duplicate:VI4F_256_512
7041             (match_operand:<ssescalarmode> 2 "general_operand" "v,m,r"))
7042           (match_operand:VI4F_256_512 1 "const0_operand" "C,C,C")
7043           (const_int 1)))]
7044   "TARGET_AVX"
7045   "@
7046    vinsertps\t{$0xe, %2, %2, %x0|%x0, %2, %2, 0xe}
7047    vmov<ssescalarmodesuffix>\t{%x2, %x0|%x0, %2}
7048    vmovd\t{%2, %x0|%x0, %2}"
7049   [(set (attr "type")
7050      (if_then_else (eq_attr "alternative" "0")
7051                    (const_string "sselog")
7052                    (const_string "ssemov")))
7053    (set_attr "prefix" "maybe_evex")
7054    (set_attr "mode" "SF,<ssescalarmode>,SI")
7055    (set (attr "preferred_for_speed")
7056      (cond [(eq_attr "alternative" "2")
7057               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
7058            ]
7059            (symbol_ref "true")))])
7061 (define_insn "sse4_1_insertps"
7062   [(set (match_operand:V4SF 0 "register_operand" "=Yr,*x,v")
7063         (unspec:V4SF [(match_operand:V4SF 2 "nonimmediate_operand" "Yrm,*xm,vm")
7064                       (match_operand:V4SF 1 "register_operand" "0,0,v")
7065                       (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
7066                      UNSPEC_INSERTPS))]
7067   "TARGET_SSE4_1"
7069   if (MEM_P (operands[2]))
7070     {
7071       unsigned count_s = INTVAL (operands[3]) >> 6;
7072       if (count_s)
7073         operands[3] = GEN_INT (INTVAL (operands[3]) & 0x3f);
7074       operands[2] = adjust_address_nv (operands[2], SFmode, count_s * 4);
7075     }
7076   switch (which_alternative)
7077     {
7078     case 0:
7079     case 1:
7080       return "insertps\t{%3, %2, %0|%0, %2, %3}";
7081     case 2:
7082       return "vinsertps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
7083     default:
7084       gcc_unreachable ();
7085     }
7087   [(set_attr "isa" "noavx,noavx,avx")
7088    (set_attr "type" "sselog")
7089    (set_attr "prefix_data16" "1,1,*")
7090    (set_attr "prefix_extra" "1")
7091    (set_attr "length_immediate" "1")
7092    (set_attr "prefix" "orig,orig,maybe_evex")
7093    (set_attr "mode" "V4SF")])
7095 (define_split
7096   [(set (match_operand:VI4F_128 0 "memory_operand")
7097         (vec_merge:VI4F_128
7098           (vec_duplicate:VI4F_128
7099             (match_operand:<ssescalarmode> 1 "nonmemory_operand"))
7100           (match_dup 0)
7101           (const_int 1)))]
7102   "TARGET_SSE && reload_completed"
7103   [(set (match_dup 0) (match_dup 1))]
7104   "operands[0] = adjust_address (operands[0], <ssescalarmode>mode, 0);")
7106 (define_expand "vec_set<mode>"
7107   [(match_operand:V 0 "register_operand")
7108    (match_operand:<ssescalarmode> 1 "register_operand")
7109    (match_operand 2 "const_int_operand")]
7110   "TARGET_SSE"
7112   ix86_expand_vector_set (false, operands[0], operands[1],
7113                           INTVAL (operands[2]));
7114   DONE;
7117 (define_insn_and_split "*vec_extractv4sf_0"
7118   [(set (match_operand:SF 0 "nonimmediate_operand" "=v,m,f,r")
7119         (vec_select:SF
7120           (match_operand:V4SF 1 "nonimmediate_operand" "vm,v,m,m")
7121           (parallel [(const_int 0)])))]
7122   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7123   "#"
7124   "&& reload_completed"
7125   [(set (match_dup 0) (match_dup 1))]
7126   "operands[1] = gen_lowpart (SFmode, operands[1]);")
7128 (define_insn_and_split "*sse4_1_extractps"
7129   [(set (match_operand:SF 0 "nonimmediate_operand" "=rm,rm,rm,Yv,Yv")
7130         (vec_select:SF
7131           (match_operand:V4SF 1 "register_operand" "Yr,*x,v,0,v")
7132           (parallel [(match_operand:SI 2 "const_0_to_3_operand" "n,n,n,n,n")])))]
7133   "TARGET_SSE4_1"
7134   "@
7135    extractps\t{%2, %1, %0|%0, %1, %2}
7136    extractps\t{%2, %1, %0|%0, %1, %2}
7137    vextractps\t{%2, %1, %0|%0, %1, %2}
7138    #
7139    #"
7140   "&& reload_completed && SSE_REG_P (operands[0])"
7141   [(const_int 0)]
7143   rtx dest = lowpart_subreg (V4SFmode, operands[0], SFmode);
7144   switch (INTVAL (operands[2]))
7145     {
7146     case 1:
7147     case 3:
7148       emit_insn (gen_sse_shufps_v4sf (dest, operands[1], operands[1],
7149                                       operands[2], operands[2],
7150                                       GEN_INT (INTVAL (operands[2]) + 4),
7151                                       GEN_INT (INTVAL (operands[2]) + 4)));
7152       break;
7153     case 2:
7154       emit_insn (gen_vec_interleave_highv4sf (dest, operands[1], operands[1]));
7155       break;
7156     default:
7157       /* 0 should be handled by the *vec_extractv4sf_0 pattern above.  */
7158       gcc_unreachable ();
7159     }
7160   DONE;
7162   [(set_attr "isa" "noavx,noavx,avx,noavx,avx")
7163    (set_attr "type" "sselog,sselog,sselog,*,*")
7164    (set_attr "prefix_data16" "1,1,1,*,*")
7165    (set_attr "prefix_extra" "1,1,1,*,*")
7166    (set_attr "length_immediate" "1,1,1,*,*")
7167    (set_attr "prefix" "orig,orig,maybe_evex,*,*")
7168    (set_attr "mode" "V4SF,V4SF,V4SF,*,*")])
7170 (define_insn_and_split "*vec_extractv4sf_mem"
7171   [(set (match_operand:SF 0 "register_operand" "=v,*r,f")
7172         (vec_select:SF
7173           (match_operand:V4SF 1 "memory_operand" "o,o,o")
7174           (parallel [(match_operand 2 "const_0_to_3_operand" "n,n,n")])))]
7175   "TARGET_SSE"
7176   "#"
7177   "&& reload_completed"
7178   [(set (match_dup 0) (match_dup 1))]
7180   operands[1] = adjust_address (operands[1], SFmode, INTVAL (operands[2]) * 4);
7183 (define_mode_attr extract_type
7184   [(V16SF "avx512f") (V16SI "avx512f") (V8DF "avx512dq") (V8DI "avx512dq")])
7186 (define_mode_attr extract_suf
7187   [(V16SF "32x4") (V16SI "32x4") (V8DF "64x2") (V8DI "64x2")])
7189 (define_mode_iterator AVX512_VEC
7190   [(V8DF "TARGET_AVX512DQ") (V8DI "TARGET_AVX512DQ") V16SF V16SI])
7192 (define_expand "<extract_type>_vextract<shuffletype><extract_suf>_mask"
7193   [(match_operand:<ssequartermode> 0 "nonimmediate_operand")
7194    (match_operand:AVX512_VEC 1 "register_operand")
7195    (match_operand:SI 2 "const_0_to_3_operand")
7196    (match_operand:<ssequartermode> 3 "nonimmediate_operand")
7197    (match_operand:QI 4 "register_operand")]
7198   "TARGET_AVX512F"
7200   int mask;
7201   mask = INTVAL (operands[2]);
7202   rtx dest = operands[0];
7204   if (MEM_P (operands[0]) && !rtx_equal_p (operands[0], operands[3]))
7205     dest = gen_reg_rtx (<ssequartermode>mode);
7207   if (<MODE>mode == V16SImode || <MODE>mode == V16SFmode)
7208     emit_insn (gen_avx512f_vextract<shuffletype>32x4_1_mask (dest,
7209         operands[1], GEN_INT (mask * 4), GEN_INT (mask * 4 + 1),
7210         GEN_INT (mask * 4 + 2), GEN_INT (mask * 4 + 3), operands[3],
7211         operands[4]));
7212   else
7213     emit_insn (gen_avx512dq_vextract<shuffletype>64x2_1_mask (dest,
7214         operands[1], GEN_INT (mask * 2), GEN_INT (mask * 2 + 1), operands[3],
7215         operands[4]));
7216   if (dest != operands[0])
7217     emit_move_insn (operands[0], dest);
7218   DONE;
7221 (define_insn "avx512dq_vextract<shuffletype>64x2_1_maskm"
7222   [(set (match_operand:<ssequartermode> 0 "memory_operand" "=m")
7223         (vec_merge:<ssequartermode>
7224           (vec_select:<ssequartermode>
7225             (match_operand:V8FI 1 "register_operand" "v")
7226             (parallel [(match_operand 2  "const_0_to_7_operand")
7227               (match_operand 3  "const_0_to_7_operand")]))
7228           (match_operand:<ssequartermode> 4 "memory_operand" "0")
7229           (match_operand:QI 5 "register_operand" "Yk")))]
7230   "TARGET_AVX512DQ
7231    && INTVAL (operands[2]) % 2 == 0
7232    && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
7233    && rtx_equal_p (operands[4], operands[0])"
7235   operands[2] = GEN_INT ((INTVAL (operands[2])) >> 1);
7236   return "vextract<shuffletype>64x2\t{%2, %1, %0%{%5%}|%0%{%5%}, %1, %2}";
7238   [(set_attr "type" "sselog")
7239    (set_attr "prefix_extra" "1")
7240    (set_attr "length_immediate" "1")
7241    (set_attr "memory" "store")
7242    (set_attr "prefix" "evex")
7243    (set_attr "mode" "<sseinsnmode>")])
7245 (define_insn "avx512f_vextract<shuffletype>32x4_1_maskm"
7246   [(set (match_operand:<ssequartermode> 0 "memory_operand" "=m")
7247         (vec_merge:<ssequartermode>
7248           (vec_select:<ssequartermode>
7249             (match_operand:V16FI 1 "register_operand" "v")
7250             (parallel [(match_operand 2  "const_0_to_15_operand")
7251               (match_operand 3  "const_0_to_15_operand")
7252               (match_operand 4  "const_0_to_15_operand")
7253               (match_operand 5  "const_0_to_15_operand")]))
7254           (match_operand:<ssequartermode> 6 "memory_operand" "0")
7255           (match_operand:QI 7 "register_operand" "Yk")))]
7256   "TARGET_AVX512F
7257    && INTVAL (operands[2]) % 4 == 0
7258    && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
7259    && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
7260    && INTVAL (operands[4]) == INTVAL (operands[5]) - 1
7261    && rtx_equal_p (operands[6], operands[0])"
7263   operands[2] = GEN_INT (INTVAL (operands[2]) >> 2);
7264   return "vextract<shuffletype>32x4\t{%2, %1, %0%{%7%}|%0%{%7%}, %1, %2}";
7266   [(set_attr "type" "sselog")
7267    (set_attr "prefix_extra" "1")
7268    (set_attr "length_immediate" "1")
7269    (set_attr "memory" "store")
7270    (set_attr "prefix" "evex")
7271    (set_attr "mode" "<sseinsnmode>")])
7273 (define_insn "<mask_codefor>avx512dq_vextract<shuffletype>64x2_1<mask_name>"
7274   [(set (match_operand:<ssequartermode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7275         (vec_select:<ssequartermode>
7276           (match_operand:V8FI 1 "register_operand" "v")
7277           (parallel [(match_operand 2  "const_0_to_7_operand")
7278             (match_operand 3  "const_0_to_7_operand")])))]
7279   "TARGET_AVX512DQ
7280    && INTVAL (operands[2]) % 2 == 0
7281    && INTVAL (operands[2]) == INTVAL (operands[3]) - 1"
7283   operands[2] = GEN_INT (INTVAL (operands[2]) >> 1);
7284   return "vextract<shuffletype>64x2\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}";
7286   [(set_attr "type" "sselog1")
7287    (set_attr "prefix_extra" "1")
7288    (set_attr "length_immediate" "1")
7289    (set_attr "prefix" "evex")
7290    (set_attr "mode" "<sseinsnmode>")])
7292 (define_split
7293   [(set (match_operand:<ssequartermode> 0 "nonimmediate_operand")
7294         (vec_select:<ssequartermode>
7295           (match_operand:V8FI 1 "register_operand")
7296           (parallel [(const_int 0) (const_int 1)])))]
7297   "TARGET_AVX512DQ
7298    && reload_completed
7299    && (TARGET_AVX512VL
7300        || REG_P (operands[0])
7301        || !EXT_REX_SSE_REG_P (operands[1]))"
7302   [(set (match_dup 0) (match_dup 1))]
7304   if (!TARGET_AVX512VL
7305       && REG_P (operands[0])
7306       && EXT_REX_SSE_REG_P (operands[1]))
7307     operands[0]
7308       = lowpart_subreg (<MODE>mode, operands[0], <ssequartermode>mode);
7309   else
7310     operands[1] = gen_lowpart (<ssequartermode>mode, operands[1]);
7313 (define_insn "<mask_codefor>avx512f_vextract<shuffletype>32x4_1<mask_name>"
7314   [(set (match_operand:<ssequartermode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7315         (vec_select:<ssequartermode>
7316           (match_operand:V16FI 1 "register_operand" "v")
7317           (parallel [(match_operand 2  "const_0_to_15_operand")
7318             (match_operand 3  "const_0_to_15_operand")
7319             (match_operand 4  "const_0_to_15_operand")
7320             (match_operand 5  "const_0_to_15_operand")])))]
7321   "TARGET_AVX512F
7322    && INTVAL (operands[2]) % 4 == 0
7323    && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
7324    && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
7325    && INTVAL (operands[4]) == INTVAL (operands[5]) - 1"
7327   operands[2] = GEN_INT (INTVAL (operands[2]) >> 2);
7328   return "vextract<shuffletype>32x4\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
7330   [(set_attr "type" "sselog1")
7331    (set_attr "prefix_extra" "1")
7332    (set_attr "length_immediate" "1")
7333    (set_attr "prefix" "evex")
7334    (set_attr "mode" "<sseinsnmode>")])
7336 (define_split
7337   [(set (match_operand:<ssequartermode> 0 "nonimmediate_operand")
7338         (vec_select:<ssequartermode>
7339           (match_operand:V16FI 1 "register_operand")
7340           (parallel [(const_int 0) (const_int 1)
7341                      (const_int 2) (const_int 3)])))]
7342   "TARGET_AVX512F
7343    && reload_completed
7344    && (TARGET_AVX512VL
7345        || REG_P (operands[0])
7346        || !EXT_REX_SSE_REG_P (operands[1]))"
7347   [(set (match_dup 0) (match_dup 1))]
7349   if (!TARGET_AVX512VL
7350       && REG_P (operands[0])
7351       && EXT_REX_SSE_REG_P (operands[1]))
7352     operands[0]
7353       = lowpart_subreg (<MODE>mode, operands[0], <ssequartermode>mode);
7354   else
7355     operands[1] = gen_lowpart (<ssequartermode>mode, operands[1]);
7358 (define_mode_attr extract_type_2
7359   [(V16SF "avx512dq") (V16SI "avx512dq") (V8DF "avx512f") (V8DI "avx512f")])
7361 (define_mode_attr extract_suf_2
7362   [(V16SF "32x8") (V16SI "32x8") (V8DF "64x4") (V8DI "64x4")])
7364 (define_mode_iterator AVX512_VEC_2
7365   [(V16SF "TARGET_AVX512DQ") (V16SI "TARGET_AVX512DQ") V8DF V8DI])
7367 (define_expand "<extract_type_2>_vextract<shuffletype><extract_suf_2>_mask"
7368   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7369    (match_operand:AVX512_VEC_2 1 "register_operand")
7370    (match_operand:SI 2 "const_0_to_1_operand")
7371    (match_operand:<ssehalfvecmode> 3 "nonimmediate_operand")
7372    (match_operand:QI 4 "register_operand")]
7373   "TARGET_AVX512F"
7375   rtx (*insn)(rtx, rtx, rtx, rtx);
7376   rtx dest = operands[0];
7378   if (MEM_P (dest) && !rtx_equal_p (dest, operands[3]))
7379     dest = gen_reg_rtx (<ssehalfvecmode>mode);
7381   switch (INTVAL (operands[2]))
7382     {
7383     case 0:
7384       insn = gen_vec_extract_lo_<mode>_mask;
7385       break;
7386     case 1:
7387       insn = gen_vec_extract_hi_<mode>_mask;
7388       break;
7389     default:
7390       gcc_unreachable ();
7391     }
7393   emit_insn (insn (dest, operands[1], operands[3], operands[4]));
7394   if (dest != operands[0])
7395     emit_move_insn (operands[0], dest);
7396   DONE;
7399 (define_split
7400   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7401         (vec_select:<ssehalfvecmode>
7402           (match_operand:V8FI 1 "nonimmediate_operand")
7403           (parallel [(const_int 0) (const_int 1)
7404             (const_int 2) (const_int 3)])))]
7405   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7406    && reload_completed
7407    && (TARGET_AVX512VL
7408        || (REG_P (operands[0]) && !EXT_REX_SSE_REG_P (operands[1])))"
7409   [(set (match_dup 0) (match_dup 1))]
7410   "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
7412 (define_insn "vec_extract_lo_<mode>_maskm"
7413   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7414         (vec_merge:<ssehalfvecmode>
7415           (vec_select:<ssehalfvecmode>
7416             (match_operand:V8FI 1 "register_operand" "v")
7417             (parallel [(const_int 0) (const_int 1)
7418               (const_int 2) (const_int 3)]))
7419           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7420           (match_operand:QI 3 "register_operand" "Yk")))]
7421   "TARGET_AVX512F
7422    && rtx_equal_p (operands[2], operands[0])"
7423   "vextract<shuffletype>64x4\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}"
7424   [(set_attr "type" "sselog1")
7425    (set_attr "prefix_extra" "1")
7426    (set_attr "length_immediate" "1")
7427    (set_attr "prefix" "evex")
7428    (set_attr "mode" "<sseinsnmode>")])
7430 (define_insn "vec_extract_lo_<mode><mask_name>"
7431   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,<store_mask_constraint>,v")
7432         (vec_select:<ssehalfvecmode>
7433           (match_operand:V8FI 1 "<store_mask_predicate>" "v,v,<store_mask_constraint>")
7434           (parallel [(const_int 0) (const_int 1)
7435             (const_int 2) (const_int 3)])))]
7436   "TARGET_AVX512F
7437    && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))"
7439   if (<mask_applied> || (!TARGET_AVX512VL && !MEM_P (operands[1])))
7440     return "vextract<shuffletype>64x4\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7441   else
7442     return "#";
7444   [(set_attr "type" "sselog1")
7445    (set_attr "prefix_extra" "1")
7446    (set_attr "length_immediate" "1")
7447    (set_attr "memory" "none,store,load")
7448    (set_attr "prefix" "evex")
7449    (set_attr "mode" "<sseinsnmode>")])
7451 (define_insn "vec_extract_hi_<mode>_maskm"
7452   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7453         (vec_merge:<ssehalfvecmode>
7454           (vec_select:<ssehalfvecmode>
7455             (match_operand:V8FI 1 "register_operand" "v")
7456             (parallel [(const_int 4) (const_int 5)
7457               (const_int 6) (const_int 7)]))
7458           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7459           (match_operand:QI 3 "register_operand" "Yk")))]
7460   "TARGET_AVX512F
7461    && rtx_equal_p (operands[2], operands[0])"
7462   "vextract<shuffletype>64x4\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7463   [(set_attr "type" "sselog")
7464    (set_attr "prefix_extra" "1")
7465    (set_attr "length_immediate" "1")
7466    (set_attr "memory" "store")
7467    (set_attr "prefix" "evex")
7468    (set_attr "mode" "<sseinsnmode>")])
7470 (define_insn "vec_extract_hi_<mode><mask_name>"
7471   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7472         (vec_select:<ssehalfvecmode>
7473           (match_operand:V8FI 1 "register_operand" "v")
7474           (parallel [(const_int 4) (const_int 5)
7475             (const_int 6) (const_int 7)])))]
7476   "TARGET_AVX512F"
7477   "vextract<shuffletype>64x4\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}"
7478   [(set_attr "type" "sselog1")
7479    (set_attr "prefix_extra" "1")
7480    (set_attr "length_immediate" "1")
7481    (set_attr "prefix" "evex")
7482    (set_attr "mode" "<sseinsnmode>")])
7484 (define_insn "vec_extract_hi_<mode>_maskm"
7485    [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7486         (vec_merge:<ssehalfvecmode>
7487           (vec_select:<ssehalfvecmode>
7488             (match_operand:V16FI 1 "register_operand" "v")
7489             (parallel [(const_int 8) (const_int 9)
7490               (const_int 10) (const_int 11)
7491               (const_int 12) (const_int 13)
7492               (const_int 14) (const_int 15)]))
7493           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7494           (match_operand:QI 3 "register_operand" "Yk")))]
7495   "TARGET_AVX512DQ
7496    && rtx_equal_p (operands[2], operands[0])"
7497   "vextract<shuffletype>32x8\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7498   [(set_attr "type" "sselog1")
7499    (set_attr "prefix_extra" "1")
7500    (set_attr "length_immediate" "1")
7501    (set_attr "prefix" "evex")
7502    (set_attr "mode" "<sseinsnmode>")])
7504 (define_insn "vec_extract_hi_<mode><mask_name>"
7505   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>,vm")
7506         (vec_select:<ssehalfvecmode>
7507           (match_operand:V16FI 1 "register_operand" "v,v")
7508           (parallel [(const_int 8) (const_int 9)
7509             (const_int 10) (const_int 11)
7510             (const_int 12) (const_int 13)
7511             (const_int 14) (const_int 15)])))]
7512   "TARGET_AVX512F && <mask_avx512dq_condition>"
7513   "@
7514    vextract<shuffletype>32x8\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}
7515    vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7516   [(set_attr "type" "sselog1")
7517    (set_attr "prefix_extra" "1")
7518    (set_attr "isa" "avx512dq,noavx512dq")
7519    (set_attr "length_immediate" "1")
7520    (set_attr "prefix" "evex")
7521    (set_attr "mode" "<sseinsnmode>")])
7523 (define_expand "avx512vl_vextractf128<mode>"
7524   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7525    (match_operand:VI48F_256 1 "register_operand")
7526    (match_operand:SI 2 "const_0_to_1_operand")
7527    (match_operand:<ssehalfvecmode> 3 "vector_move_operand")
7528    (match_operand:QI 4 "register_operand")]
7529   "TARGET_AVX512DQ && TARGET_AVX512VL"
7531   rtx (*insn)(rtx, rtx, rtx, rtx);
7532   rtx dest = operands[0];
7534   if (MEM_P (dest)
7535       && (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 4
7536           /* For V8S[IF]mode there are maskm insns with =m and 0
7537              constraints.  */
7538           ? !rtx_equal_p (dest, operands[3])
7539           /* For V4D[IF]mode, hi insns don't allow memory, and
7540              lo insns have =m and 0C constraints.  */
7541           : (operands[2] != const0_rtx
7542              || (!rtx_equal_p (dest, operands[3])
7543                  && GET_CODE (operands[3]) != CONST_VECTOR))))
7544     dest = gen_reg_rtx (<ssehalfvecmode>mode);
7545   switch (INTVAL (operands[2]))
7546     {
7547     case 0:
7548       insn = gen_vec_extract_lo_<mode>_mask;
7549       break;
7550     case 1:
7551       insn = gen_vec_extract_hi_<mode>_mask;
7552       break;
7553     default:
7554       gcc_unreachable ();
7555     }
7557   emit_insn (insn (dest, operands[1], operands[3], operands[4]));
7558   if (dest != operands[0])
7559     emit_move_insn (operands[0], dest);
7560   DONE;
7563 (define_expand "avx_vextractf128<mode>"
7564   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7565    (match_operand:V_256 1 "register_operand")
7566    (match_operand:SI 2 "const_0_to_1_operand")]
7567   "TARGET_AVX"
7569   rtx (*insn)(rtx, rtx);
7571   switch (INTVAL (operands[2]))
7572     {
7573     case 0:
7574       insn = gen_vec_extract_lo_<mode>;
7575       break;
7576     case 1:
7577       insn = gen_vec_extract_hi_<mode>;
7578       break;
7579     default:
7580       gcc_unreachable ();
7581     }
7583   emit_insn (insn (operands[0], operands[1]));
7584   DONE;
7587 (define_insn "vec_extract_lo_<mode><mask_name>"
7588   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,v,m")
7589         (vec_select:<ssehalfvecmode>
7590           (match_operand:V16FI 1 "<store_mask_predicate>"
7591                                  "v,<store_mask_constraint>,v")
7592           (parallel [(const_int 0) (const_int 1)
7593                      (const_int 2) (const_int 3)
7594                      (const_int 4) (const_int 5)
7595                      (const_int 6) (const_int 7)])))]
7596   "TARGET_AVX512F
7597    && <mask_mode512bit_condition>
7598    && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))"
7600   if (<mask_applied>
7601       || (!TARGET_AVX512VL
7602           && !REG_P (operands[0])
7603           && EXT_REX_SSE_REG_P (operands[1])))
7604     return "vextract<shuffletype>32x8\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7605   else
7606     return "#";
7608   [(set_attr "type" "sselog1")
7609    (set_attr "prefix_extra" "1")
7610    (set_attr "length_immediate" "1")
7611    (set_attr "memory" "none,load,store")
7612    (set_attr "prefix" "evex")
7613    (set_attr "mode" "<sseinsnmode>")])
7615 (define_split
7616   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7617         (vec_select:<ssehalfvecmode>
7618           (match_operand:V16FI 1 "nonimmediate_operand")
7619           (parallel [(const_int 0) (const_int 1)
7620             (const_int 2) (const_int 3)
7621             (const_int 4) (const_int 5)
7622             (const_int 6) (const_int 7)])))]
7623   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7624    && reload_completed
7625    && (TARGET_AVX512VL
7626        || REG_P (operands[0])
7627        || !EXT_REX_SSE_REG_P (operands[1]))"
7628   [(set (match_dup 0) (match_dup 1))]
7630   if (!TARGET_AVX512VL
7631       && REG_P (operands[0])
7632       && EXT_REX_SSE_REG_P (operands[1]))
7633     operands[0]
7634       = lowpart_subreg (<MODE>mode, operands[0], <ssehalfvecmode>mode);
7635   else
7636     operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);
7639 (define_insn "vec_extract_lo_<mode><mask_name>"
7640   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,v,m")
7641         (vec_select:<ssehalfvecmode>
7642           (match_operand:VI8F_256 1 "<store_mask_predicate>"
7643                                     "v,<store_mask_constraint>,v")
7644           (parallel [(const_int 0) (const_int 1)])))]
7645   "TARGET_AVX
7646    && <mask_avx512vl_condition> && <mask_avx512dq_condition>
7647    && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))"
7649   if (<mask_applied>)
7650     return "vextract<shuffletype>64x2\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}";
7651   else
7652     return "#";
7654    [(set_attr "type" "sselog1")
7655     (set_attr "prefix_extra" "1")
7656     (set_attr "length_immediate" "1")
7657     (set_attr "memory" "none,load,store")
7658     (set_attr "prefix" "evex")
7659     (set_attr "mode" "XI")])
7661 (define_split
7662   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7663         (vec_select:<ssehalfvecmode>
7664           (match_operand:VI8F_256 1 "nonimmediate_operand")
7665           (parallel [(const_int 0) (const_int 1)])))]
7666   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7667    && reload_completed"
7668   [(set (match_dup 0) (match_dup 1))]
7669   "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
7671 (define_insn "vec_extract_hi_<mode><mask_name>"
7672   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,<store_mask_constraint>")
7673         (vec_select:<ssehalfvecmode>
7674           (match_operand:VI8F_256 1 "register_operand" "v,v")
7675           (parallel [(const_int 2) (const_int 3)])))]
7676   "TARGET_AVX && <mask_avx512vl_condition> && <mask_avx512dq_condition>"
7678   if (TARGET_AVX512VL)
7679   {
7680     if (TARGET_AVX512DQ)
7681       return "vextract<shuffletype>64x2\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}";
7682     else
7683       return "vextract<shuffletype>32x4\t{$0x1, %1, %0|%0, %1, 0x1}";
7684   }
7685   else
7686     return "vextract<i128>\t{$0x1, %1, %0|%0, %1, 0x1}";
7688   [(set_attr "type" "sselog1")
7689    (set_attr "prefix_extra" "1")
7690    (set_attr "length_immediate" "1")
7691    (set_attr "prefix" "vex")
7692    (set_attr "mode" "<sseinsnmode>")])
7694 (define_split
7695   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7696         (vec_select:<ssehalfvecmode>
7697           (match_operand:VI4F_256 1 "nonimmediate_operand")
7698           (parallel [(const_int 0) (const_int 1)
7699                      (const_int 2) (const_int 3)])))]
7700   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7701    && reload_completed"
7702   [(set (match_dup 0) (match_dup 1))]
7703   "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
7705 (define_insn "vec_extract_lo_<mode><mask_name>"
7706   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>"
7707                                           "=<store_mask_constraint>,v")
7708         (vec_select:<ssehalfvecmode>
7709           (match_operand:VI4F_256 1 "<store_mask_predicate>"
7710                                     "v,<store_mask_constraint>")
7711           (parallel [(const_int 0) (const_int 1)
7712                      (const_int 2) (const_int 3)])))]
7713   "TARGET_AVX
7714    && <mask_avx512vl_condition> && <mask_avx512dq_condition>
7715    && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))"
7717   if (<mask_applied>)
7718     return "vextract<shuffletype>32x4\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7719   else
7720     return "#";
7722   [(set_attr "type" "sselog1")
7723    (set_attr "prefix_extra" "1")
7724    (set_attr "length_immediate" "1")
7725    (set_attr "prefix" "evex")
7726    (set_attr "mode" "<sseinsnmode>")])
7728 (define_insn "vec_extract_lo_<mode>_maskm"
7729   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7730         (vec_merge:<ssehalfvecmode>
7731           (vec_select:<ssehalfvecmode>
7732             (match_operand:VI4F_256 1 "register_operand" "v")
7733             (parallel [(const_int 0) (const_int 1)
7734                       (const_int 2) (const_int 3)]))
7735           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7736           (match_operand:QI 3 "register_operand" "Yk")))]
7737   "TARGET_AVX512VL && TARGET_AVX512F
7738    && rtx_equal_p (operands[2], operands[0])"
7739   "vextract<shuffletype>32x4\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}"
7740   [(set_attr "type" "sselog1")
7741    (set_attr "prefix_extra" "1")
7742    (set_attr "length_immediate" "1")
7743    (set_attr "prefix" "evex")
7744    (set_attr "mode" "<sseinsnmode>")])
7746 (define_insn "vec_extract_hi_<mode>_maskm"
7747   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7748         (vec_merge:<ssehalfvecmode>
7749           (vec_select:<ssehalfvecmode>
7750             (match_operand:VI4F_256 1 "register_operand" "v")
7751             (parallel [(const_int 4) (const_int 5)
7752                       (const_int 6) (const_int 7)]))
7753           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7754           (match_operand:<ssehalfvecmode> 3 "register_operand" "Yk")))]
7755   "TARGET_AVX512F && TARGET_AVX512VL
7756    && rtx_equal_p (operands[2], operands[0])"
7757   "vextract<shuffletype>32x4\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7758   [(set_attr "type" "sselog1")
7759    (set_attr "length_immediate" "1")
7760    (set_attr "prefix" "evex")
7761    (set_attr "mode" "<sseinsnmode>")])
7763 (define_insn "vec_extract_hi_<mode>_mask"
7764   [(set (match_operand:<ssehalfvecmode> 0 "register_operand" "=v")
7765         (vec_merge:<ssehalfvecmode>
7766           (vec_select:<ssehalfvecmode>
7767             (match_operand:VI4F_256 1 "register_operand" "v")
7768             (parallel [(const_int 4) (const_int 5)
7769                        (const_int 6) (const_int 7)]))
7770           (match_operand:<ssehalfvecmode> 2 "vector_move_operand" "0C")
7771           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
7772   "TARGET_AVX512VL"
7773   "vextract<shuffletype>32x4\t{$0x1, %1, %0%{%3%}%N2|%0%{%3%}%N2, %1, 0x1}"
7774   [(set_attr "type" "sselog1")
7775    (set_attr "length_immediate" "1")
7776    (set_attr "prefix" "evex")
7777    (set_attr "mode" "<sseinsnmode>")])
7779 (define_insn "vec_extract_hi_<mode>"
7780   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=xm, vm")
7781         (vec_select:<ssehalfvecmode>
7782           (match_operand:VI4F_256 1 "register_operand" "x, v")
7783           (parallel [(const_int 4) (const_int 5)
7784                      (const_int 6) (const_int 7)])))]
7785   "TARGET_AVX"
7786   "@
7787     vextract<i128>\t{$0x1, %1, %0|%0, %1, 0x1}
7788     vextract<shuffletype>32x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7789   [(set_attr "isa" "*, avx512vl")
7790    (set_attr "prefix" "vex, evex")
7791    (set_attr "type" "sselog1")
7792    (set_attr "length_immediate" "1")
7793    (set_attr "mode" "<sseinsnmode>")])
7795 (define_insn_and_split "vec_extract_lo_v32hi"
7796   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=v,v,m")
7797         (vec_select:V16HI
7798           (match_operand:V32HI 1 "nonimmediate_operand" "v,m,v")
7799           (parallel [(const_int 0) (const_int 1)
7800                      (const_int 2) (const_int 3)
7801                      (const_int 4) (const_int 5)
7802                      (const_int 6) (const_int 7)
7803                      (const_int 8) (const_int 9)
7804                      (const_int 10) (const_int 11)
7805                      (const_int 12) (const_int 13)
7806                      (const_int 14) (const_int 15)])))]
7807   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7809   if (TARGET_AVX512VL
7810       || REG_P (operands[0])
7811       || !EXT_REX_SSE_REG_P (operands[1]))
7812     return "#";
7813   else
7814     return "vextracti64x4\t{$0x0, %1, %0|%0, %1, 0x0}";
7816   "&& reload_completed
7817    && (TARGET_AVX512VL
7818        || REG_P (operands[0])
7819        || !EXT_REX_SSE_REG_P (operands[1]))"
7820   [(set (match_dup 0) (match_dup 1))]
7822   if (!TARGET_AVX512VL
7823       && REG_P (operands[0])
7824       && EXT_REX_SSE_REG_P (operands[1]))
7825     operands[0] = lowpart_subreg (V32HImode, operands[0], V16HImode);
7826   else
7827     operands[1] = gen_lowpart (V16HImode, operands[1]);
7829   [(set_attr "type" "sselog1")
7830    (set_attr "prefix_extra" "1")
7831    (set_attr "length_immediate" "1")
7832    (set_attr "memory" "none,load,store")
7833    (set_attr "prefix" "evex")
7834    (set_attr "mode" "XI")])
7836 (define_insn "vec_extract_hi_v32hi"
7837   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=vm")
7838         (vec_select:V16HI
7839           (match_operand:V32HI 1 "register_operand" "v")
7840           (parallel [(const_int 16) (const_int 17)
7841                      (const_int 18) (const_int 19)
7842                      (const_int 20) (const_int 21)
7843                      (const_int 22) (const_int 23)
7844                      (const_int 24) (const_int 25)
7845                      (const_int 26) (const_int 27)
7846                      (const_int 28) (const_int 29)
7847                      (const_int 30) (const_int 31)])))]
7848   "TARGET_AVX512F"
7849   "vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7850   [(set_attr "type" "sselog1")
7851    (set_attr "prefix_extra" "1")
7852    (set_attr "length_immediate" "1")
7853    (set_attr "prefix" "evex")
7854    (set_attr "mode" "XI")])
7856 (define_insn_and_split "vec_extract_lo_v16hi"
7857   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=v,m")
7858         (vec_select:V8HI
7859           (match_operand:V16HI 1 "nonimmediate_operand" "vm,v")
7860           (parallel [(const_int 0) (const_int 1)
7861                      (const_int 2) (const_int 3)
7862                      (const_int 4) (const_int 5)
7863                      (const_int 6) (const_int 7)])))]
7864   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7865   "#"
7866   "&& reload_completed"
7867   [(set (match_dup 0) (match_dup 1))]
7868   "operands[1] = gen_lowpart (V8HImode, operands[1]);")
7870 (define_insn "vec_extract_hi_v16hi"
7871   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=xm,vm,vm")
7872         (vec_select:V8HI
7873           (match_operand:V16HI 1 "register_operand" "x,v,v")
7874           (parallel [(const_int 8) (const_int 9)
7875                      (const_int 10) (const_int 11)
7876                      (const_int 12) (const_int 13)
7877                      (const_int 14) (const_int 15)])))]
7878   "TARGET_AVX"
7879   "@
7880    vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}
7881    vextracti32x4\t{$0x1, %1, %0|%0, %1, 0x1}
7882    vextracti32x4\t{$0x1, %g1, %0|%0, %g1, 0x1}"
7883   [(set_attr "type" "sselog1")
7884    (set_attr "prefix_extra" "1")
7885    (set_attr "length_immediate" "1")
7886    (set_attr "isa" "*,avx512dq,avx512f")
7887    (set_attr "prefix" "vex,evex,evex")
7888    (set_attr "mode" "OI")])
7890 (define_insn_and_split "vec_extract_lo_v64qi"
7891   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,v,m")
7892         (vec_select:V32QI
7893           (match_operand:V64QI 1 "nonimmediate_operand" "v,m,v")
7894           (parallel [(const_int 0) (const_int 1)
7895                      (const_int 2) (const_int 3)
7896                      (const_int 4) (const_int 5)
7897                      (const_int 6) (const_int 7)
7898                      (const_int 8) (const_int 9)
7899                      (const_int 10) (const_int 11)
7900                      (const_int 12) (const_int 13)
7901                      (const_int 14) (const_int 15)
7902                      (const_int 16) (const_int 17)
7903                      (const_int 18) (const_int 19)
7904                      (const_int 20) (const_int 21)
7905                      (const_int 22) (const_int 23)
7906                      (const_int 24) (const_int 25)
7907                      (const_int 26) (const_int 27)
7908                      (const_int 28) (const_int 29)
7909                      (const_int 30) (const_int 31)])))]
7910   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7912   if (TARGET_AVX512VL
7913       || REG_P (operands[0])
7914       || !EXT_REX_SSE_REG_P (operands[1]))
7915     return "#";
7916   else
7917     return "vextracti64x4\t{$0x0, %1, %0|%0, %1, 0x0}";
7919   "&& reload_completed
7920    && (TARGET_AVX512VL
7921        || REG_P (operands[0])
7922        || !EXT_REX_SSE_REG_P (operands[1]))"
7923   [(set (match_dup 0) (match_dup 1))]
7925   if (!TARGET_AVX512VL
7926       && REG_P (operands[0])
7927       && EXT_REX_SSE_REG_P (operands[1]))
7928     operands[0] = lowpart_subreg (V64QImode, operands[0], V32QImode);
7929   else
7930     operands[1] = gen_lowpart (V32QImode, operands[1]);
7932   [(set_attr "type" "sselog1")
7933    (set_attr "prefix_extra" "1")
7934    (set_attr "length_immediate" "1")
7935    (set_attr "memory" "none,load,store")
7936    (set_attr "prefix" "evex")
7937    (set_attr "mode" "XI")])
7939 (define_insn "vec_extract_hi_v64qi"
7940   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=vm")
7941         (vec_select:V32QI
7942           (match_operand:V64QI 1 "register_operand" "v")
7943           (parallel [(const_int 32) (const_int 33)
7944                      (const_int 34) (const_int 35)
7945                      (const_int 36) (const_int 37)
7946                      (const_int 38) (const_int 39)
7947                      (const_int 40) (const_int 41)
7948                      (const_int 42) (const_int 43)
7949                      (const_int 44) (const_int 45)
7950                      (const_int 46) (const_int 47)
7951                      (const_int 48) (const_int 49)
7952                      (const_int 50) (const_int 51)
7953                      (const_int 52) (const_int 53)
7954                      (const_int 54) (const_int 55)
7955                      (const_int 56) (const_int 57)
7956                      (const_int 58) (const_int 59)
7957                      (const_int 60) (const_int 61)
7958                      (const_int 62) (const_int 63)])))]
7959   "TARGET_AVX512F"
7960   "vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7961   [(set_attr "type" "sselog1")
7962    (set_attr "prefix_extra" "1")
7963    (set_attr "length_immediate" "1")
7964    (set_attr "prefix" "evex")
7965    (set_attr "mode" "XI")])
7967 (define_insn_and_split "vec_extract_lo_v32qi"
7968   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=v,m")
7969         (vec_select:V16QI
7970           (match_operand:V32QI 1 "nonimmediate_operand" "vm,v")
7971           (parallel [(const_int 0) (const_int 1)
7972                      (const_int 2) (const_int 3)
7973                      (const_int 4) (const_int 5)
7974                      (const_int 6) (const_int 7)
7975                      (const_int 8) (const_int 9)
7976                      (const_int 10) (const_int 11)
7977                      (const_int 12) (const_int 13)
7978                      (const_int 14) (const_int 15)])))]
7979   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7980   "#"
7981   "&& reload_completed"
7982   [(set (match_dup 0) (match_dup 1))]
7983   "operands[1] = gen_lowpart (V16QImode, operands[1]);")
7985 (define_insn "vec_extract_hi_v32qi"
7986   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=xm,vm,vm")
7987         (vec_select:V16QI
7988           (match_operand:V32QI 1 "register_operand" "x,v,v")
7989           (parallel [(const_int 16) (const_int 17)
7990                      (const_int 18) (const_int 19)
7991                      (const_int 20) (const_int 21)
7992                      (const_int 22) (const_int 23)
7993                      (const_int 24) (const_int 25)
7994                      (const_int 26) (const_int 27)
7995                      (const_int 28) (const_int 29)
7996                      (const_int 30) (const_int 31)])))]
7997   "TARGET_AVX"
7998   "@
7999    vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}
8000    vextracti32x4\t{$0x1, %1, %0|%0, %1, 0x1}
8001    vextracti32x4\t{$0x1, %g1, %0|%0, %g1, 0x1}"
8002   [(set_attr "type" "sselog1")
8003    (set_attr "prefix_extra" "1")
8004    (set_attr "length_immediate" "1")
8005    (set_attr "isa" "*,avx512dq,avx512f")
8006    (set_attr "prefix" "vex,evex,evex")
8007    (set_attr "mode" "OI")])
8009 ;; Modes handled by vec_extract patterns.
8010 (define_mode_iterator VEC_EXTRACT_MODE
8011   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX") V16QI
8012    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX") V8HI
8013    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
8014    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI
8015    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
8016    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") V2DF
8017    (V4TI "TARGET_AVX512F") (V2TI "TARGET_AVX")])
8019 (define_expand "vec_extract<mode><ssescalarmodelower>"
8020   [(match_operand:<ssescalarmode> 0 "register_operand")
8021    (match_operand:VEC_EXTRACT_MODE 1 "register_operand")
8022    (match_operand 2 "const_int_operand")]
8023   "TARGET_SSE"
8025   ix86_expand_vector_extract (false, operands[0], operands[1],
8026                               INTVAL (operands[2]));
8027   DONE;
8030 (define_expand "vec_extract<mode><ssehalfvecmodelower>"
8031   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
8032    (match_operand:V_512 1 "register_operand")
8033    (match_operand 2 "const_0_to_1_operand")]
8034   "TARGET_AVX512F"
8036   if (INTVAL (operands[2]))
8037     emit_insn (gen_vec_extract_hi_<mode> (operands[0], operands[1]));
8038   else
8039     emit_insn (gen_vec_extract_lo_<mode> (operands[0], operands[1]));
8040   DONE;
8043 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8045 ;; Parallel double-precision floating point element swizzling
8047 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8049 (define_insn "<mask_codefor>avx512f_unpckhpd512<mask_name>"
8050   [(set (match_operand:V8DF 0 "register_operand" "=v")
8051         (vec_select:V8DF
8052           (vec_concat:V16DF
8053             (match_operand:V8DF 1 "register_operand" "v")
8054             (match_operand:V8DF 2 "nonimmediate_operand" "vm"))
8055           (parallel [(const_int 1) (const_int 9)
8056                      (const_int 3) (const_int 11)
8057                      (const_int 5) (const_int 13)
8058                      (const_int 7) (const_int 15)])))]
8059   "TARGET_AVX512F"
8060   "vunpckhpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8061   [(set_attr "type" "sselog")
8062    (set_attr "prefix" "evex")
8063    (set_attr "mode" "V8DF")])
8065 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
8066 (define_insn "avx_unpckhpd256<mask_name>"
8067   [(set (match_operand:V4DF 0 "register_operand" "=v")
8068         (vec_select:V4DF
8069           (vec_concat:V8DF
8070             (match_operand:V4DF 1 "register_operand" "v")
8071             (match_operand:V4DF 2 "nonimmediate_operand" "vm"))
8072           (parallel [(const_int 1) (const_int 5)
8073                      (const_int 3) (const_int 7)])))]
8074   "TARGET_AVX && <mask_avx512vl_condition>"
8075   "vunpckhpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8076   [(set_attr "type" "sselog")
8077    (set_attr "prefix" "vex")
8078    (set_attr "mode" "V4DF")])
8080 (define_expand "vec_interleave_highv4df"
8081   [(set (match_dup 3)
8082         (vec_select:V4DF
8083           (vec_concat:V8DF
8084             (match_operand:V4DF 1 "register_operand")
8085             (match_operand:V4DF 2 "nonimmediate_operand"))
8086           (parallel [(const_int 0) (const_int 4)
8087                      (const_int 2) (const_int 6)])))
8088    (set (match_dup 4)
8089         (vec_select:V4DF
8090           (vec_concat:V8DF
8091             (match_dup 1)
8092             (match_dup 2))
8093           (parallel [(const_int 1) (const_int 5)
8094                      (const_int 3) (const_int 7)])))
8095    (set (match_operand:V4DF 0 "register_operand")
8096         (vec_select:V4DF
8097           (vec_concat:V8DF
8098             (match_dup 3)
8099             (match_dup 4))
8100           (parallel [(const_int 2) (const_int 3)
8101                      (const_int 6) (const_int 7)])))]
8102  "TARGET_AVX"
8104   operands[3] = gen_reg_rtx (V4DFmode);
8105   operands[4] = gen_reg_rtx (V4DFmode);
8109 (define_insn "avx512vl_unpckhpd128_mask"
8110   [(set (match_operand:V2DF 0 "register_operand" "=v")
8111         (vec_merge:V2DF
8112           (vec_select:V2DF
8113             (vec_concat:V4DF
8114               (match_operand:V2DF 1 "register_operand" "v")
8115               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
8116             (parallel [(const_int 1) (const_int 3)]))
8117           (match_operand:V2DF 3 "vector_move_operand" "0C")
8118           (match_operand:QI 4 "register_operand" "Yk")))]
8119   "TARGET_AVX512VL"
8120   "vunpckhpd\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
8121   [(set_attr "type" "sselog")
8122    (set_attr "prefix" "evex")
8123    (set_attr "mode" "V2DF")])
8125 (define_expand "vec_interleave_highv2df"
8126   [(set (match_operand:V2DF 0 "register_operand")
8127         (vec_select:V2DF
8128           (vec_concat:V4DF
8129             (match_operand:V2DF 1 "nonimmediate_operand")
8130             (match_operand:V2DF 2 "nonimmediate_operand"))
8131           (parallel [(const_int 1)
8132                      (const_int 3)])))]
8133   "TARGET_SSE2"
8135   if (!ix86_vec_interleave_v2df_operator_ok (operands, 1))
8136     operands[2] = force_reg (V2DFmode, operands[2]);
8139 (define_insn "*vec_interleave_highv2df"
8140   [(set (match_operand:V2DF 0 "nonimmediate_operand"     "=x,v,v,x,v,m")
8141         (vec_select:V2DF
8142           (vec_concat:V4DF
8143             (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,o,o,o,v")
8144             (match_operand:V2DF 2 "nonimmediate_operand" " x,v,1,0,v,0"))
8145           (parallel [(const_int 1)
8146                      (const_int 3)])))]
8147   "TARGET_SSE2 && ix86_vec_interleave_v2df_operator_ok (operands, 1)"
8148   "@
8149    unpckhpd\t{%2, %0|%0, %2}
8150    vunpckhpd\t{%2, %1, %0|%0, %1, %2}
8151    %vmovddup\t{%H1, %0|%0, %H1}
8152    movlpd\t{%H1, %0|%0, %H1}
8153    vmovlpd\t{%H1, %2, %0|%0, %2, %H1}
8154    %vmovhpd\t{%1, %0|%q0, %1}"
8155   [(set_attr "isa" "noavx,avx,sse3,noavx,avx,*")
8156    (set_attr "type" "sselog,sselog,sselog,ssemov,ssemov,ssemov")
8157    (set (attr "prefix_data16")
8158      (if_then_else (eq_attr "alternative" "3,5")
8159                    (const_string "1")
8160                    (const_string "*")))
8161    (set_attr "prefix" "orig,maybe_evex,maybe_vex,orig,maybe_evex,maybe_vex")
8162    (set_attr "mode" "V2DF,V2DF,DF,V1DF,V1DF,V1DF")])
8164 (define_expand "avx512f_movddup512<mask_name>"
8165   [(set (match_operand:V8DF 0 "register_operand")
8166         (vec_select:V8DF
8167           (vec_concat:V16DF
8168             (match_operand:V8DF 1 "nonimmediate_operand")
8169             (match_dup 1))
8170           (parallel [(const_int 0) (const_int 8)
8171                      (const_int 2) (const_int 10)
8172                      (const_int 4) (const_int 12)
8173                      (const_int 6) (const_int 14)])))]
8174   "TARGET_AVX512F")
8176 (define_expand "avx512f_unpcklpd512<mask_name>"
8177   [(set (match_operand:V8DF 0 "register_operand")
8178         (vec_select:V8DF
8179           (vec_concat:V16DF
8180             (match_operand:V8DF 1 "register_operand")
8181             (match_operand:V8DF 2 "nonimmediate_operand"))
8182           (parallel [(const_int 0) (const_int 8)
8183                      (const_int 2) (const_int 10)
8184                      (const_int 4) (const_int 12)
8185                      (const_int 6) (const_int 14)])))]
8186   "TARGET_AVX512F")
8188 (define_insn "*avx512f_unpcklpd512<mask_name>"
8189   [(set (match_operand:V8DF 0 "register_operand" "=v,v")
8190         (vec_select:V8DF
8191           (vec_concat:V16DF
8192             (match_operand:V8DF 1 "nonimmediate_operand" "vm, v")
8193             (match_operand:V8DF 2 "nonimmediate_operand" "1 ,vm"))
8194           (parallel [(const_int 0) (const_int 8)
8195                      (const_int 2) (const_int 10)
8196                      (const_int 4) (const_int 12)
8197                      (const_int 6) (const_int 14)])))]
8198   "TARGET_AVX512F"
8199   "@
8200    vmovddup\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}
8201    vunpcklpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8202   [(set_attr "type" "sselog")
8203    (set_attr "prefix" "evex")
8204    (set_attr "mode" "V8DF")])
8206 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
8207 (define_expand "avx_movddup256<mask_name>"
8208   [(set (match_operand:V4DF 0 "register_operand")
8209         (vec_select:V4DF
8210           (vec_concat:V8DF
8211             (match_operand:V4DF 1 "nonimmediate_operand")
8212             (match_dup 1))
8213           (parallel [(const_int 0) (const_int 4)
8214                      (const_int 2) (const_int 6)])))]
8215   "TARGET_AVX && <mask_avx512vl_condition>")
8217 (define_expand "avx_unpcklpd256<mask_name>"
8218   [(set (match_operand:V4DF 0 "register_operand")
8219         (vec_select:V4DF
8220           (vec_concat:V8DF
8221             (match_operand:V4DF 1 "register_operand")
8222             (match_operand:V4DF 2 "nonimmediate_operand"))
8223           (parallel [(const_int 0) (const_int 4)
8224                      (const_int 2) (const_int 6)])))]
8225   "TARGET_AVX && <mask_avx512vl_condition>")
8227 (define_insn "*avx_unpcklpd256<mask_name>"
8228   [(set (match_operand:V4DF 0 "register_operand"         "=v,v")
8229         (vec_select:V4DF
8230           (vec_concat:V8DF
8231             (match_operand:V4DF 1 "nonimmediate_operand" " v,m")
8232             (match_operand:V4DF 2 "nonimmediate_operand" "vm,1"))
8233           (parallel [(const_int 0) (const_int 4)
8234                      (const_int 2) (const_int 6)])))]
8235   "TARGET_AVX && <mask_avx512vl_condition>"
8236   "@
8237    vunpcklpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
8238    vmovddup\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}"
8239   [(set_attr "type" "sselog")
8240    (set_attr "prefix" "vex")
8241    (set_attr "mode" "V4DF")])
8243 (define_expand "vec_interleave_lowv4df"
8244   [(set (match_dup 3)
8245         (vec_select:V4DF
8246           (vec_concat:V8DF
8247             (match_operand:V4DF 1 "register_operand")
8248             (match_operand:V4DF 2 "nonimmediate_operand"))
8249           (parallel [(const_int 0) (const_int 4)
8250                      (const_int 2) (const_int 6)])))
8251    (set (match_dup 4)
8252         (vec_select:V4DF
8253           (vec_concat:V8DF
8254             (match_dup 1)
8255             (match_dup 2))
8256           (parallel [(const_int 1) (const_int 5)
8257                      (const_int 3) (const_int 7)])))
8258    (set (match_operand:V4DF 0 "register_operand")
8259         (vec_select:V4DF
8260           (vec_concat:V8DF
8261             (match_dup 3)
8262             (match_dup 4))
8263           (parallel [(const_int 0) (const_int 1)
8264                      (const_int 4) (const_int 5)])))]
8265  "TARGET_AVX"
8267   operands[3] = gen_reg_rtx (V4DFmode);
8268   operands[4] = gen_reg_rtx (V4DFmode);
8271 (define_insn "avx512vl_unpcklpd128_mask"
8272   [(set (match_operand:V2DF 0 "register_operand" "=v")
8273         (vec_merge:V2DF
8274           (vec_select:V2DF
8275             (vec_concat:V4DF
8276               (match_operand:V2DF 1 "register_operand" "v")
8277               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
8278             (parallel [(const_int 0) (const_int 2)]))
8279           (match_operand:V2DF 3 "vector_move_operand" "0C")
8280           (match_operand:QI 4 "register_operand" "Yk")))]
8281   "TARGET_AVX512VL"
8282   "vunpcklpd\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
8283   [(set_attr "type" "sselog")
8284    (set_attr "prefix" "evex")
8285    (set_attr "mode" "V2DF")])
8287 (define_expand "vec_interleave_lowv2df"
8288   [(set (match_operand:V2DF 0 "register_operand")
8289         (vec_select:V2DF
8290           (vec_concat:V4DF
8291             (match_operand:V2DF 1 "nonimmediate_operand")
8292             (match_operand:V2DF 2 "nonimmediate_operand"))
8293           (parallel [(const_int 0)
8294                      (const_int 2)])))]
8295   "TARGET_SSE2"
8297   if (!ix86_vec_interleave_v2df_operator_ok (operands, 0))
8298     operands[1] = force_reg (V2DFmode, operands[1]);
8301 (define_insn "*vec_interleave_lowv2df"
8302   [(set (match_operand:V2DF 0 "nonimmediate_operand"     "=x,v,v,x,v,o")
8303         (vec_select:V2DF
8304           (vec_concat:V4DF
8305             (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,m,0,v,0")
8306             (match_operand:V2DF 2 "nonimmediate_operand" " x,v,1,m,m,v"))
8307           (parallel [(const_int 0)
8308                      (const_int 2)])))]
8309   "TARGET_SSE2 && ix86_vec_interleave_v2df_operator_ok (operands, 0)"
8310   "@
8311    unpcklpd\t{%2, %0|%0, %2}
8312    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
8313    %vmovddup\t{%1, %0|%0, %q1}
8314    movhpd\t{%2, %0|%0, %q2}
8315    vmovhpd\t{%2, %1, %0|%0, %1, %q2}
8316    %vmovlpd\t{%2, %H0|%H0, %2}"
8317   [(set_attr "isa" "noavx,avx,sse3,noavx,avx,*")
8318    (set_attr "type" "sselog,sselog,sselog,ssemov,ssemov,ssemov")
8319    (set (attr "prefix_data16")
8320      (if_then_else (eq_attr "alternative" "3,5")
8321                    (const_string "1")
8322                    (const_string "*")))
8323    (set_attr "prefix" "orig,maybe_evex,maybe_vex,orig,maybe_evex,maybe_vex")
8324    (set_attr "mode" "V2DF,V2DF,DF,V1DF,V1DF,V1DF")])
8326 (define_split
8327   [(set (match_operand:V2DF 0 "memory_operand")
8328         (vec_select:V2DF
8329           (vec_concat:V4DF
8330             (match_operand:V2DF 1 "register_operand")
8331             (match_dup 1))
8332           (parallel [(const_int 0)
8333                      (const_int 2)])))]
8334   "TARGET_SSE3 && reload_completed"
8335   [(const_int 0)]
8337   rtx low = gen_lowpart (DFmode, operands[1]);
8339   emit_move_insn (adjust_address (operands[0], DFmode, 0), low);
8340   emit_move_insn (adjust_address (operands[0], DFmode, 8), low);
8341   DONE;
8344 (define_split
8345   [(set (match_operand:V2DF 0 "register_operand")
8346         (vec_select:V2DF
8347           (vec_concat:V4DF
8348             (match_operand:V2DF 1 "memory_operand")
8349             (match_dup 1))
8350           (parallel [(match_operand:SI 2 "const_0_to_1_operand")
8351                      (match_operand:SI 3 "const_int_operand")])))]
8352   "TARGET_SSE3 && INTVAL (operands[2]) + 2 == INTVAL (operands[3])"
8353   [(set (match_dup 0) (vec_duplicate:V2DF (match_dup 1)))]
8355   operands[1] = adjust_address (operands[1], DFmode, INTVAL (operands[2]) * 8);
8358 (define_insn "avx512f_vmscalef<mode><mask_scalar_name><round_scalar_name>"
8359   [(set (match_operand:VF_128 0 "register_operand" "=v")
8360         (vec_merge:VF_128
8361           (unspec:VF_128
8362             [(match_operand:VF_128 1 "register_operand" "v")
8363              (match_operand:VF_128 2 "<round_scalar_nimm_predicate>" "<round_scalar_constraint>")]
8364             UNSPEC_SCALEF)
8365           (match_dup 1)
8366           (const_int 1)))]
8367   "TARGET_AVX512F"
8368   "vscalef<ssescalarmodesuffix>\t{<round_scalar_mask_op3>%2, %1, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %1, %2<round_scalar_mask_op3>}"
8369   [(set_attr "prefix" "evex")
8370    (set_attr "mode"  "<ssescalarmode>")])
8372 (define_insn "<avx512>_scalef<mode><mask_name><round_name>"
8373   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8374         (unspec:VF_AVX512VL
8375           [(match_operand:VF_AVX512VL 1 "register_operand" "v")
8376            (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")]
8377           UNSPEC_SCALEF))]
8378   "TARGET_AVX512F"
8379   "vscalef<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
8380   [(set_attr "prefix" "evex")
8381    (set_attr "mode"  "<MODE>")])
8383 (define_expand "<avx512>_vternlog<mode>_maskz"
8384   [(match_operand:VI48_AVX512VL 0 "register_operand")
8385    (match_operand:VI48_AVX512VL 1 "register_operand")
8386    (match_operand:VI48_AVX512VL 2 "register_operand")
8387    (match_operand:VI48_AVX512VL 3 "nonimmediate_operand")
8388    (match_operand:SI 4 "const_0_to_255_operand")
8389    (match_operand:<avx512fmaskmode> 5 "register_operand")]
8390   "TARGET_AVX512F"
8392   emit_insn (gen_<avx512>_vternlog<mode>_maskz_1 (
8393     operands[0], operands[1], operands[2], operands[3],
8394     operands[4], CONST0_RTX (<MODE>mode), operands[5]));
8395   DONE;
8398 (define_insn "<avx512>_vternlog<mode><sd_maskz_name>"
8399   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
8400         (unspec:VI48_AVX512VL
8401           [(match_operand:VI48_AVX512VL 1 "register_operand" "0")
8402            (match_operand:VI48_AVX512VL 2 "register_operand" "v")
8403            (match_operand:VI48_AVX512VL 3 "nonimmediate_operand" "vm")
8404            (match_operand:SI 4 "const_0_to_255_operand")]
8405           UNSPEC_VTERNLOG))]
8406   "TARGET_AVX512F"
8407   "vpternlog<ssemodesuffix>\t{%4, %3, %2, %0<sd_mask_op5>|%0<sd_mask_op5>, %2, %3, %4}"
8408   [(set_attr "type" "sselog")
8409    (set_attr "prefix" "evex")
8410    (set_attr "mode" "<sseinsnmode>")])
8412 (define_insn "<avx512>_vternlog<mode>_mask"
8413   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
8414         (vec_merge:VI48_AVX512VL
8415           (unspec:VI48_AVX512VL
8416             [(match_operand:VI48_AVX512VL 1 "register_operand" "0")
8417              (match_operand:VI48_AVX512VL 2 "register_operand" "v")
8418              (match_operand:VI48_AVX512VL 3 "nonimmediate_operand" "vm")
8419              (match_operand:SI 4 "const_0_to_255_operand")]
8420             UNSPEC_VTERNLOG)
8421           (match_dup 1)
8422           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
8423   "TARGET_AVX512F"
8424   "vpternlog<ssemodesuffix>\t{%4, %3, %2, %0%{%5%}|%0%{%5%}, %2, %3, %4}"
8425   [(set_attr "type" "sselog")
8426    (set_attr "prefix" "evex")
8427    (set_attr "mode" "<sseinsnmode>")])
8429 (define_insn "<avx512>_getexp<mode><mask_name><round_saeonly_name>"
8430   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8431         (unspec:VF_AVX512VL [(match_operand:VF_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
8432                         UNSPEC_GETEXP))]
8433    "TARGET_AVX512F"
8434    "vgetexp<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}";
8435     [(set_attr "prefix" "evex")
8436      (set_attr "mode" "<MODE>")])
8438 (define_insn "avx512f_sgetexp<mode><mask_scalar_name><round_saeonly_scalar_name>"
8439   [(set (match_operand:VF_128 0 "register_operand" "=v")
8440         (vec_merge:VF_128
8441           (unspec:VF_128
8442             [(match_operand:VF_128 1 "register_operand" "v")
8443              (match_operand:VF_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")]
8444             UNSPEC_GETEXP)
8445           (match_dup 1)
8446           (const_int 1)))]
8447    "TARGET_AVX512F"
8448    "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>}";
8449     [(set_attr "prefix" "evex")
8450      (set_attr "mode" "<ssescalarmode>")])
8452 (define_insn "<mask_codefor><avx512>_align<mode><mask_name>"
8453   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
8454         (unspec:VI48_AVX512VL [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
8455                                (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")
8456                                (match_operand:SI 3 "const_0_to_255_operand")]
8457                               UNSPEC_ALIGN))]
8458   "TARGET_AVX512F"
8459   "valign<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}";
8460   [(set_attr "prefix" "evex")
8461    (set_attr "mode" "<sseinsnmode>")])
8463 (define_expand "avx512f_shufps512_mask"
8464   [(match_operand:V16SF 0 "register_operand")
8465    (match_operand:V16SF 1 "register_operand")
8466    (match_operand:V16SF 2 "nonimmediate_operand")
8467    (match_operand:SI 3 "const_0_to_255_operand")
8468    (match_operand:V16SF 4 "register_operand")
8469    (match_operand:HI 5 "register_operand")]
8470   "TARGET_AVX512F"
8472   int mask = INTVAL (operands[3]);
8473   emit_insn (gen_avx512f_shufps512_1_mask (operands[0], operands[1], operands[2],
8474                                           GEN_INT ((mask >> 0) & 3),
8475                                           GEN_INT ((mask >> 2) & 3),
8476                                           GEN_INT (((mask >> 4) & 3) + 16),
8477                                           GEN_INT (((mask >> 6) & 3) + 16),
8478                                           GEN_INT (((mask >> 0) & 3) + 4),
8479                                           GEN_INT (((mask >> 2) & 3) + 4),
8480                                           GEN_INT (((mask >> 4) & 3) + 20),
8481                                           GEN_INT (((mask >> 6) & 3) + 20),
8482                                           GEN_INT (((mask >> 0) & 3) + 8),
8483                                           GEN_INT (((mask >> 2) & 3) + 8),
8484                                           GEN_INT (((mask >> 4) & 3) + 24),
8485                                           GEN_INT (((mask >> 6) & 3) + 24),
8486                                           GEN_INT (((mask >> 0) & 3) + 12),
8487                                           GEN_INT (((mask >> 2) & 3) + 12),
8488                                           GEN_INT (((mask >> 4) & 3) + 28),
8489                                           GEN_INT (((mask >> 6) & 3) + 28),
8490                                           operands[4], operands[5]));
8491   DONE;
8495 (define_expand "<avx512>_fixupimm<mode>_maskz<round_saeonly_expand_name>"
8496   [(match_operand:VF_AVX512VL 0 "register_operand")
8497    (match_operand:VF_AVX512VL 1 "register_operand")
8498    (match_operand:VF_AVX512VL 2 "register_operand")
8499    (match_operand:<sseintvecmode> 3 "<round_saeonly_expand_nimm_predicate>")
8500    (match_operand:SI 4 "const_0_to_255_operand")
8501    (match_operand:<avx512fmaskmode> 5 "register_operand")]
8502   "TARGET_AVX512F"
8504   emit_insn (gen_<avx512>_fixupimm<mode>_maskz_1<round_saeonly_expand_name> (
8505         operands[0], operands[1], operands[2], operands[3],
8506         operands[4], CONST0_RTX (<MODE>mode), operands[5]
8507         <round_saeonly_expand_operand6>));
8508   DONE;
8511 (define_insn "<avx512>_fixupimm<mode><sd_maskz_name><round_saeonly_name>"
8512   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8513         (unspec:VF_AVX512VL
8514           [(match_operand:VF_AVX512VL 1 "register_operand" "0")
8515            (match_operand:VF_AVX512VL 2 "register_operand" "v")
8516            (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "<round_saeonly_constraint>")
8517            (match_operand:SI 4 "const_0_to_255_operand")]
8518            UNSPEC_FIXUPIMM))]
8519   "TARGET_AVX512F"
8520   "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}";
8521   [(set_attr "prefix" "evex")
8522    (set_attr "mode" "<MODE>")])
8524 (define_insn "<avx512>_fixupimm<mode>_mask<round_saeonly_name>"
8525   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8526         (vec_merge:VF_AVX512VL
8527           (unspec:VF_AVX512VL
8528             [(match_operand:VF_AVX512VL 1 "register_operand" "0")
8529              (match_operand:VF_AVX512VL 2 "register_operand" "v")
8530              (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "<round_saeonly_constraint>")
8531              (match_operand:SI 4 "const_0_to_255_operand")]
8532              UNSPEC_FIXUPIMM)
8533           (match_dup 1)
8534           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
8535   "TARGET_AVX512F"
8536   "vfixupimm<ssemodesuffix>\t{%4, <round_saeonly_op6>%3, %2, %0%{%5%}|%0%{%5%}, %2, %3<round_saeonly_op6>, %4}";
8537   [(set_attr "prefix" "evex")
8538    (set_attr "mode" "<MODE>")])
8540 (define_expand "avx512f_sfixupimm<mode>_maskz<round_saeonly_expand_name>"
8541   [(match_operand:VF_128 0 "register_operand")
8542    (match_operand:VF_128 1 "register_operand")
8543    (match_operand:VF_128 2 "register_operand")
8544    (match_operand:<sseintvecmode> 3 "<round_saeonly_expand_nimm_predicate>")
8545    (match_operand:SI 4 "const_0_to_255_operand")
8546    (match_operand:<avx512fmaskmode> 5 "register_operand")]
8547   "TARGET_AVX512F"
8549   emit_insn (gen_avx512f_sfixupimm<mode>_maskz_1<round_saeonly_expand_name> (
8550         operands[0], operands[1], operands[2], operands[3],
8551         operands[4], CONST0_RTX (<MODE>mode), operands[5]
8552         <round_saeonly_expand_operand6>));
8553   DONE;
8556 (define_insn "avx512f_sfixupimm<mode><sd_maskz_name><round_saeonly_name>"
8557   [(set (match_operand:VF_128 0 "register_operand" "=v")
8558         (vec_merge:VF_128
8559           (unspec:VF_128
8560             [(match_operand:VF_128 1 "register_operand" "0")
8561              (match_operand:VF_128 2 "register_operand" "v")
8562              (match_operand:<sseintvecmode> 3 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8563              (match_operand:SI 4 "const_0_to_255_operand")]
8564             UNSPEC_FIXUPIMM)
8565           (match_dup 1)
8566           (const_int 1)))]
8567    "TARGET_AVX512F"
8568    "vfixupimm<ssescalarmodesuffix>\t{%4, <round_saeonly_sd_mask_op5>%3, %2, %0<sd_mask_op5>|%0<sd_mask_op5>, %2, %<iptr>3<round_saeonly_sd_mask_op5>, %4}";
8569    [(set_attr "prefix" "evex")
8570    (set_attr "mode" "<ssescalarmode>")])
8572 (define_insn "avx512f_sfixupimm<mode>_mask<round_saeonly_name>"
8573   [(set (match_operand:VF_128 0 "register_operand" "=v")
8574         (vec_merge:VF_128
8575           (vec_merge:VF_128
8576             (unspec:VF_128
8577                [(match_operand:VF_128 1 "register_operand" "0")
8578                 (match_operand:VF_128 2 "register_operand" "v")
8579                 (match_operand:<sseintvecmode> 3 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8580                 (match_operand:SI 4 "const_0_to_255_operand")]
8581                UNSPEC_FIXUPIMM)
8582             (match_dup 1)
8583             (const_int 1))
8584           (match_dup 1)
8585           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
8586   "TARGET_AVX512F"
8587   "vfixupimm<ssescalarmodesuffix>\t{%4, <round_saeonly_op6>%3, %2, %0%{%5%}|%0%{%5%}, %2, %<iptr>3<round_saeonly_op6>, %4}";
8588   [(set_attr "prefix" "evex")
8589    (set_attr "mode" "<ssescalarmode>")])
8591 (define_insn "<avx512>_rndscale<mode><mask_name><round_saeonly_name>"
8592   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8593         (unspec:VF_AVX512VL
8594           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "<round_saeonly_constraint>")
8595            (match_operand:SI 2 "const_0_to_255_operand")]
8596           UNSPEC_ROUND))]
8597   "TARGET_AVX512F"
8598   "vrndscale<ssemodesuffix>\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}"
8599   [(set_attr "length_immediate" "1")
8600    (set_attr "prefix" "evex")
8601    (set_attr "mode" "<MODE>")])
8603 (define_insn "avx512f_rndscale<mode><round_saeonly_name>"
8604   [(set (match_operand:VF_128 0 "register_operand" "=v")
8605         (vec_merge:VF_128
8606           (unspec:VF_128
8607             [(match_operand:VF_128 1 "register_operand" "v")
8608              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8609              (match_operand:SI 3 "const_0_to_255_operand")]
8610             UNSPEC_ROUND)
8611           (match_dup 1)
8612           (const_int 1)))]
8613   "TARGET_AVX512F"
8614   "vrndscale<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %<iptr>2<round_saeonly_op4>, %3}"
8615   [(set_attr "length_immediate" "1")
8616    (set_attr "prefix" "evex")
8617    (set_attr "mode" "<MODE>")])
8619 ;; One bit in mask selects 2 elements.
8620 (define_insn "avx512f_shufps512_1<mask_name>"
8621   [(set (match_operand:V16SF 0 "register_operand" "=v")
8622         (vec_select:V16SF
8623           (vec_concat:V32SF
8624             (match_operand:V16SF 1 "register_operand" "v")
8625             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
8626           (parallel [(match_operand 3  "const_0_to_3_operand")
8627                      (match_operand 4  "const_0_to_3_operand")
8628                      (match_operand 5  "const_16_to_19_operand")
8629                      (match_operand 6  "const_16_to_19_operand")
8630                      (match_operand 7  "const_4_to_7_operand")
8631                      (match_operand 8  "const_4_to_7_operand")
8632                      (match_operand 9  "const_20_to_23_operand")
8633                      (match_operand 10  "const_20_to_23_operand")
8634                      (match_operand 11  "const_8_to_11_operand")
8635                      (match_operand 12  "const_8_to_11_operand")
8636                      (match_operand 13  "const_24_to_27_operand")
8637                      (match_operand 14  "const_24_to_27_operand")
8638                      (match_operand 15  "const_12_to_15_operand")
8639                      (match_operand 16  "const_12_to_15_operand")
8640                      (match_operand 17  "const_28_to_31_operand")
8641                      (match_operand 18  "const_28_to_31_operand")])))]
8642   "TARGET_AVX512F
8643    && (INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
8644        && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
8645        && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4)
8646        && INTVAL (operands[6]) == (INTVAL (operands[10]) - 4)
8647        && INTVAL (operands[3]) == (INTVAL (operands[11]) - 8)
8648        && INTVAL (operands[4]) == (INTVAL (operands[12]) - 8)
8649        && INTVAL (operands[5]) == (INTVAL (operands[13]) - 8)
8650        && INTVAL (operands[6]) == (INTVAL (operands[14]) - 8)
8651        && INTVAL (operands[3]) == (INTVAL (operands[15]) - 12)
8652        && INTVAL (operands[4]) == (INTVAL (operands[16]) - 12)
8653        && INTVAL (operands[5]) == (INTVAL (operands[17]) - 12)
8654        && INTVAL (operands[6]) == (INTVAL (operands[18]) - 12))"
8656   int mask;
8657   mask = INTVAL (operands[3]);
8658   mask |= INTVAL (operands[4]) << 2;
8659   mask |= (INTVAL (operands[5]) - 16) << 4;
8660   mask |= (INTVAL (operands[6]) - 16) << 6;
8661   operands[3] = GEN_INT (mask);
8663   return "vshufps\t{%3, %2, %1, %0<mask_operand19>|%0<mask_operand19>, %1, %2, %3}";
8665   [(set_attr "type" "sselog")
8666    (set_attr "length_immediate" "1")
8667    (set_attr "prefix" "evex")
8668    (set_attr "mode" "V16SF")])
8670 (define_expand "avx512f_shufpd512_mask"
8671   [(match_operand:V8DF 0 "register_operand")
8672    (match_operand:V8DF 1 "register_operand")
8673    (match_operand:V8DF 2 "nonimmediate_operand")
8674    (match_operand:SI 3 "const_0_to_255_operand")
8675    (match_operand:V8DF 4 "register_operand")
8676    (match_operand:QI 5 "register_operand")]
8677   "TARGET_AVX512F"
8679   int mask = INTVAL (operands[3]);
8680   emit_insn (gen_avx512f_shufpd512_1_mask (operands[0], operands[1], operands[2],
8681                                         GEN_INT (mask & 1),
8682                                         GEN_INT (mask & 2 ? 9 : 8),
8683                                         GEN_INT (mask & 4 ? 3 : 2),
8684                                         GEN_INT (mask & 8 ? 11 : 10),
8685                                         GEN_INT (mask & 16 ? 5 : 4),
8686                                         GEN_INT (mask & 32 ? 13 : 12),
8687                                         GEN_INT (mask & 64 ? 7 : 6),
8688                                         GEN_INT (mask & 128 ? 15 : 14),
8689                                         operands[4], operands[5]));
8690   DONE;
8693 (define_insn "avx512f_shufpd512_1<mask_name>"
8694   [(set (match_operand:V8DF 0 "register_operand" "=v")
8695         (vec_select:V8DF
8696           (vec_concat:V16DF
8697             (match_operand:V8DF 1 "register_operand" "v")
8698             (match_operand:V8DF 2 "nonimmediate_operand" "vm"))
8699           (parallel [(match_operand 3 "const_0_to_1_operand")
8700                      (match_operand 4 "const_8_to_9_operand")
8701                      (match_operand 5 "const_2_to_3_operand")
8702                      (match_operand 6 "const_10_to_11_operand")
8703                      (match_operand 7 "const_4_to_5_operand")
8704                      (match_operand 8 "const_12_to_13_operand")
8705                      (match_operand 9 "const_6_to_7_operand")
8706                      (match_operand 10 "const_14_to_15_operand")])))]
8707   "TARGET_AVX512F"
8709   int mask;
8710   mask = INTVAL (operands[3]);
8711   mask |= (INTVAL (operands[4]) - 8) << 1;
8712   mask |= (INTVAL (operands[5]) - 2) << 2;
8713   mask |= (INTVAL (operands[6]) - 10) << 3;
8714   mask |= (INTVAL (operands[7]) - 4) << 4;
8715   mask |= (INTVAL (operands[8]) - 12) << 5;
8716   mask |= (INTVAL (operands[9]) - 6) << 6;
8717   mask |= (INTVAL (operands[10]) - 14) << 7;
8718   operands[3] = GEN_INT (mask);
8720   return "vshufpd\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
8722   [(set_attr "type" "sselog")
8723    (set_attr "length_immediate" "1")
8724    (set_attr "prefix" "evex")
8725    (set_attr "mode" "V8DF")])
8727 (define_expand "avx_shufpd256<mask_expand4_name>"
8728   [(match_operand:V4DF 0 "register_operand")
8729    (match_operand:V4DF 1 "register_operand")
8730    (match_operand:V4DF 2 "nonimmediate_operand")
8731    (match_operand:SI 3 "const_int_operand")]
8732   "TARGET_AVX"
8734   int mask = INTVAL (operands[3]);
8735   emit_insn (gen_avx_shufpd256_1<mask_expand4_name> (operands[0],
8736                                                      operands[1],
8737                                                      operands[2],
8738                                                      GEN_INT (mask & 1),
8739                                                      GEN_INT (mask & 2 ? 5 : 4),
8740                                                      GEN_INT (mask & 4 ? 3 : 2),
8741                                                      GEN_INT (mask & 8 ? 7 : 6)
8742                                                      <mask_expand4_args>));
8743   DONE;
8746 (define_insn "avx_shufpd256_1<mask_name>"
8747   [(set (match_operand:V4DF 0 "register_operand" "=v")
8748         (vec_select:V4DF
8749           (vec_concat:V8DF
8750             (match_operand:V4DF 1 "register_operand" "v")
8751             (match_operand:V4DF 2 "nonimmediate_operand" "vm"))
8752           (parallel [(match_operand 3 "const_0_to_1_operand")
8753                      (match_operand 4 "const_4_to_5_operand")
8754                      (match_operand 5 "const_2_to_3_operand")
8755                      (match_operand 6 "const_6_to_7_operand")])))]
8756   "TARGET_AVX && <mask_avx512vl_condition>"
8758   int mask;
8759   mask = INTVAL (operands[3]);
8760   mask |= (INTVAL (operands[4]) - 4) << 1;
8761   mask |= (INTVAL (operands[5]) - 2) << 2;
8762   mask |= (INTVAL (operands[6]) - 6) << 3;
8763   operands[3] = GEN_INT (mask);
8765   return "vshufpd\t{%3, %2, %1, %0<mask_operand7>|%0<mask_operand7>, %1, %2, %3}";
8767   [(set_attr "type" "sseshuf")
8768    (set_attr "length_immediate" "1")
8769    (set_attr "prefix" "vex")
8770    (set_attr "mode" "V4DF")])
8772 (define_expand "sse2_shufpd<mask_expand4_name>"
8773   [(match_operand:V2DF 0 "register_operand")
8774    (match_operand:V2DF 1 "register_operand")
8775    (match_operand:V2DF 2 "vector_operand")
8776    (match_operand:SI 3 "const_int_operand")]
8777   "TARGET_SSE2"
8779   int mask = INTVAL (operands[3]);
8780   emit_insn (gen_sse2_shufpd_v2df<mask_expand4_name> (operands[0], operands[1],
8781                                                       operands[2], GEN_INT (mask & 1),
8782                                                       GEN_INT (mask & 2 ? 3 : 2)
8783                                                       <mask_expand4_args>));
8784   DONE;
8787 (define_insn "sse2_shufpd_v2df_mask"
8788   [(set (match_operand:V2DF 0 "register_operand" "=v")
8789     (vec_merge:V2DF
8790           (vec_select:V2DF
8791             (vec_concat:V4DF
8792               (match_operand:V2DF 1 "register_operand" "v")
8793               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
8794             (parallel [(match_operand 3 "const_0_to_1_operand")
8795                            (match_operand 4 "const_2_to_3_operand")]))
8796       (match_operand:V2DF 5 "vector_move_operand" "0C")
8797       (match_operand:QI 6 "register_operand" "Yk")))]
8798   "TARGET_AVX512VL"
8800   int mask;
8801   mask = INTVAL (operands[3]);
8802   mask |= (INTVAL (operands[4]) - 2) << 1;
8803   operands[3] = GEN_INT (mask);
8805   return "vshufpd\t{%3, %2, %1, %0%{%6%}%N5|%0%{%6%}%N5, %1, %2, %3}";
8807   [(set_attr "type" "sseshuf")
8808    (set_attr "length_immediate" "1")
8809    (set_attr "prefix" "evex")
8810    (set_attr "mode" "V2DF")])
8812 ;; punpcklqdq and punpckhqdq are shorter than shufpd.
8813 (define_insn "avx2_interleave_highv4di<mask_name>"
8814   [(set (match_operand:V4DI 0 "register_operand" "=v")
8815         (vec_select:V4DI
8816           (vec_concat:V8DI
8817             (match_operand:V4DI 1 "register_operand" "v")
8818             (match_operand:V4DI 2 "nonimmediate_operand" "vm"))
8819           (parallel [(const_int 1)
8820                      (const_int 5)
8821                      (const_int 3)
8822                      (const_int 7)])))]
8823   "TARGET_AVX2 && <mask_avx512vl_condition>"
8824   "vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8825   [(set_attr "type" "sselog")
8826    (set_attr "prefix" "vex")
8827    (set_attr "mode" "OI")])
8829 (define_insn "<mask_codefor>avx512f_interleave_highv8di<mask_name>"
8830   [(set (match_operand:V8DI 0 "register_operand" "=v")
8831         (vec_select:V8DI
8832           (vec_concat:V16DI
8833             (match_operand:V8DI 1 "register_operand" "v")
8834             (match_operand:V8DI 2 "nonimmediate_operand" "vm"))
8835           (parallel [(const_int 1) (const_int 9)
8836                      (const_int 3) (const_int 11)
8837                      (const_int 5) (const_int 13)
8838                      (const_int 7) (const_int 15)])))]
8839   "TARGET_AVX512F"
8840   "vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8841   [(set_attr "type" "sselog")
8842    (set_attr "prefix" "evex")
8843    (set_attr "mode" "XI")])
8845 (define_insn "vec_interleave_highv2di<mask_name>"
8846   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
8847         (vec_select:V2DI
8848           (vec_concat:V4DI
8849             (match_operand:V2DI 1 "register_operand" "0,v")
8850             (match_operand:V2DI 2 "vector_operand" "xBm,vm"))
8851           (parallel [(const_int 1)
8852                      (const_int 3)])))]
8853   "TARGET_SSE2 && <mask_avx512vl_condition>"
8854   "@
8855    punpckhqdq\t{%2, %0|%0, %2}
8856    vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8857   [(set_attr "isa" "noavx,avx")
8858    (set_attr "type" "sselog")
8859    (set_attr "prefix_data16" "1,*")
8860    (set_attr "prefix" "orig,<mask_prefix>")
8861    (set_attr "mode" "TI")])
8863 (define_insn "avx2_interleave_lowv4di<mask_name>"
8864   [(set (match_operand:V4DI 0 "register_operand" "=v")
8865         (vec_select:V4DI
8866           (vec_concat:V8DI
8867             (match_operand:V4DI 1 "register_operand" "v")
8868             (match_operand:V4DI 2 "nonimmediate_operand" "vm"))
8869           (parallel [(const_int 0)
8870                      (const_int 4)
8871                      (const_int 2)
8872                      (const_int 6)])))]
8873   "TARGET_AVX2 && <mask_avx512vl_condition>"
8874   "vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8875   [(set_attr "type" "sselog")
8876    (set_attr "prefix" "vex")
8877    (set_attr "mode" "OI")])
8879 (define_insn "<mask_codefor>avx512f_interleave_lowv8di<mask_name>"
8880   [(set (match_operand:V8DI 0 "register_operand" "=v")
8881         (vec_select:V8DI
8882           (vec_concat:V16DI
8883             (match_operand:V8DI 1 "register_operand" "v")
8884             (match_operand:V8DI 2 "nonimmediate_operand" "vm"))
8885           (parallel [(const_int 0) (const_int 8)
8886                      (const_int 2) (const_int 10)
8887                      (const_int 4) (const_int 12)
8888                      (const_int 6) (const_int 14)])))]
8889   "TARGET_AVX512F"
8890   "vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8891   [(set_attr "type" "sselog")
8892    (set_attr "prefix" "evex")
8893    (set_attr "mode" "XI")])
8895 (define_insn "vec_interleave_lowv2di<mask_name>"
8896   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
8897         (vec_select:V2DI
8898           (vec_concat:V4DI
8899             (match_operand:V2DI 1 "register_operand" "0,v")
8900             (match_operand:V2DI 2 "vector_operand" "xBm,vm"))
8901           (parallel [(const_int 0)
8902                      (const_int 2)])))]
8903   "TARGET_SSE2 && <mask_avx512vl_condition>"
8904   "@
8905    punpcklqdq\t{%2, %0|%0, %2}
8906    vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8907   [(set_attr "isa" "noavx,avx")
8908    (set_attr "type" "sselog")
8909    (set_attr "prefix_data16" "1,*")
8910    (set_attr "prefix" "orig,vex")
8911    (set_attr "mode" "TI")])
8913 (define_insn "sse2_shufpd_<mode>"
8914   [(set (match_operand:VI8F_128 0 "register_operand" "=x,v")
8915         (vec_select:VI8F_128
8916           (vec_concat:<ssedoublevecmode>
8917             (match_operand:VI8F_128 1 "register_operand" "0,v")
8918             (match_operand:VI8F_128 2 "vector_operand" "xBm,vm"))
8919           (parallel [(match_operand 3 "const_0_to_1_operand")
8920                      (match_operand 4 "const_2_to_3_operand")])))]
8921   "TARGET_SSE2"
8923   int mask;
8924   mask = INTVAL (operands[3]);
8925   mask |= (INTVAL (operands[4]) - 2) << 1;
8926   operands[3] = GEN_INT (mask);
8928   switch (which_alternative)
8929     {
8930     case 0:
8931       return "shufpd\t{%3, %2, %0|%0, %2, %3}";
8932     case 1:
8933       return "vshufpd\t{%3, %2, %1, %0|%0, %1, %2, %3}";
8934     default:
8935       gcc_unreachable ();
8936     }
8938   [(set_attr "isa" "noavx,avx")
8939    (set_attr "type" "sseshuf")
8940    (set_attr "length_immediate" "1")
8941    (set_attr "prefix" "orig,maybe_evex")
8942    (set_attr "mode" "V2DF")])
8944 ;; Avoid combining registers from different units in a single alternative,
8945 ;; see comment above inline_secondary_memory_needed function in i386.c
8946 (define_insn "sse2_storehpd"
8947   [(set (match_operand:DF 0 "nonimmediate_operand"     "=m,x,Yv,x,*f,r")
8948         (vec_select:DF
8949           (match_operand:V2DF 1 "nonimmediate_operand" " v,0, v,o,o,o")
8950           (parallel [(const_int 1)])))]
8951   "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8952   "@
8953    %vmovhpd\t{%1, %0|%0, %1}
8954    unpckhpd\t%0, %0
8955    vunpckhpd\t{%d1, %0|%0, %d1}
8956    #
8957    #
8958    #"
8959   [(set_attr "isa" "*,noavx,avx,*,*,*")
8960    (set_attr "type" "ssemov,sselog1,sselog1,ssemov,fmov,imov")
8961    (set (attr "prefix_data16")
8962      (if_then_else
8963        (and (eq_attr "alternative" "0")
8964             (not (match_test "TARGET_AVX")))
8965        (const_string "1")
8966        (const_string "*")))
8967    (set_attr "prefix" "maybe_vex,orig,maybe_evex,*,*,*")
8968    (set_attr "mode" "V1DF,V1DF,V2DF,DF,DF,DF")])
8970 (define_split
8971   [(set (match_operand:DF 0 "register_operand")
8972         (vec_select:DF
8973           (match_operand:V2DF 1 "memory_operand")
8974           (parallel [(const_int 1)])))]
8975   "TARGET_SSE2 && reload_completed"
8976   [(set (match_dup 0) (match_dup 1))]
8977   "operands[1] = adjust_address (operands[1], DFmode, 8);")
8979 (define_insn "*vec_extractv2df_1_sse"
8980   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x")
8981         (vec_select:DF
8982           (match_operand:V2DF 1 "nonimmediate_operand" "x,x,o")
8983           (parallel [(const_int 1)])))]
8984   "!TARGET_SSE2 && TARGET_SSE
8985    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8986   "@
8987    movhps\t{%1, %0|%q0, %1}
8988    movhlps\t{%1, %0|%0, %1}
8989    movlps\t{%H1, %0|%0, %H1}"
8990   [(set_attr "type" "ssemov")
8991    (set_attr "mode" "V2SF,V4SF,V2SF")])
8993 ;; Avoid combining registers from different units in a single alternative,
8994 ;; see comment above inline_secondary_memory_needed function in i386.c
8995 (define_insn "sse2_storelpd"
8996   [(set (match_operand:DF 0 "nonimmediate_operand"     "=m,x,x,*f,r")
8997         (vec_select:DF
8998           (match_operand:V2DF 1 "nonimmediate_operand" " v,x,m,m,m")
8999           (parallel [(const_int 0)])))]
9000   "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
9001   "@
9002    %vmovlpd\t{%1, %0|%0, %1}
9003    #
9004    #
9005    #
9006    #"
9007   [(set_attr "type" "ssemov,ssemov,ssemov,fmov,imov")
9008    (set (attr "prefix_data16")
9009      (if_then_else (eq_attr "alternative" "0")
9010                    (const_string "1")
9011                    (const_string "*")))
9012    (set_attr "prefix" "maybe_vex")
9013    (set_attr "mode" "V1DF,DF,DF,DF,DF")])
9015 (define_split
9016   [(set (match_operand:DF 0 "register_operand")
9017         (vec_select:DF
9018           (match_operand:V2DF 1 "nonimmediate_operand")
9019           (parallel [(const_int 0)])))]
9020   "TARGET_SSE2 && reload_completed"
9021   [(set (match_dup 0) (match_dup 1))]
9022   "operands[1] = gen_lowpart (DFmode, operands[1]);")
9024 (define_insn "*vec_extractv2df_0_sse"
9025   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x")
9026         (vec_select:DF
9027           (match_operand:V2DF 1 "nonimmediate_operand" "x,x,m")
9028           (parallel [(const_int 0)])))]
9029   "!TARGET_SSE2 && TARGET_SSE
9030    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
9031   "@
9032    movlps\t{%1, %0|%0, %1}
9033    movaps\t{%1, %0|%0, %1}
9034    movlps\t{%1, %0|%0, %q1}"
9035   [(set_attr "type" "ssemov")
9036    (set_attr "mode" "V2SF,V4SF,V2SF")])
9038 (define_expand "sse2_loadhpd_exp"
9039   [(set (match_operand:V2DF 0 "nonimmediate_operand")
9040         (vec_concat:V2DF
9041           (vec_select:DF
9042             (match_operand:V2DF 1 "nonimmediate_operand")
9043             (parallel [(const_int 0)]))
9044           (match_operand:DF 2 "nonimmediate_operand")))]
9045   "TARGET_SSE2"
9047   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V2DFmode, operands);
9049   emit_insn (gen_sse2_loadhpd (dst, operands[1], operands[2]));
9051   /* Fix up the destination if needed.  */
9052   if (dst != operands[0])
9053     emit_move_insn (operands[0], dst);
9055   DONE;
9058 ;; Avoid combining registers from different units in a single alternative,
9059 ;; see comment above inline_secondary_memory_needed function in i386.c
9060 (define_insn "sse2_loadhpd"
9061   [(set (match_operand:V2DF 0 "nonimmediate_operand"
9062           "=x,v,x,v ,o,o ,o")
9063         (vec_concat:V2DF
9064           (vec_select:DF
9065             (match_operand:V2DF 1 "nonimmediate_operand"
9066           " 0,v,0,v ,0,0 ,0")
9067             (parallel [(const_int 0)]))
9068           (match_operand:DF 2 "nonimmediate_operand"
9069           " m,m,x,Yv,x,*f,r")))]
9070   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
9071   "@
9072    movhpd\t{%2, %0|%0, %2}
9073    vmovhpd\t{%2, %1, %0|%0, %1, %2}
9074    unpcklpd\t{%2, %0|%0, %2}
9075    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
9076    #
9077    #
9078    #"
9079   [(set_attr "isa" "noavx,avx,noavx,avx,*,*,*")
9080    (set_attr "type" "ssemov,ssemov,sselog,sselog,ssemov,fmov,imov")
9081    (set (attr "prefix_data16")
9082      (if_then_else (eq_attr "alternative" "0")
9083                    (const_string "1")
9084                    (const_string "*")))
9085    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,*,*,*")
9086    (set_attr "mode" "V1DF,V1DF,V2DF,V2DF,DF,DF,DF")])
9088 (define_split
9089   [(set (match_operand:V2DF 0 "memory_operand")
9090         (vec_concat:V2DF
9091           (vec_select:DF (match_dup 0) (parallel [(const_int 0)]))
9092           (match_operand:DF 1 "register_operand")))]
9093   "TARGET_SSE2 && reload_completed"
9094   [(set (match_dup 0) (match_dup 1))]
9095   "operands[0] = adjust_address (operands[0], DFmode, 8);")
9097 (define_expand "sse2_loadlpd_exp"
9098   [(set (match_operand:V2DF 0 "nonimmediate_operand")
9099         (vec_concat:V2DF
9100           (match_operand:DF 2 "nonimmediate_operand")
9101           (vec_select:DF
9102             (match_operand:V2DF 1 "nonimmediate_operand")
9103             (parallel [(const_int 1)]))))]
9104   "TARGET_SSE2"
9106   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V2DFmode, operands);
9108   emit_insn (gen_sse2_loadlpd (dst, operands[1], operands[2]));
9110   /* Fix up the destination if needed.  */
9111   if (dst != operands[0])
9112     emit_move_insn (operands[0], dst);
9114   DONE;
9117 ;; Avoid combining registers from different units in a single alternative,
9118 ;; see comment above inline_secondary_memory_needed function in i386.c
9119 (define_insn "sse2_loadlpd"
9120   [(set (match_operand:V2DF 0 "nonimmediate_operand"
9121           "=v,x,v,x,v,x,x,v,m,m ,m")
9122         (vec_concat:V2DF
9123           (match_operand:DF 2 "nonimmediate_operand"
9124           "vm,m,m,x,v,0,0,v,x,*f,r")
9125           (vec_select:DF
9126             (match_operand:V2DF 1 "vector_move_operand"
9127           " C,0,v,0,v,x,o,o,0,0 ,0")
9128             (parallel [(const_int 1)]))))]
9129   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
9130   "@
9131    %vmovq\t{%2, %0|%0, %2}
9132    movlpd\t{%2, %0|%0, %2}
9133    vmovlpd\t{%2, %1, %0|%0, %1, %2}
9134    movsd\t{%2, %0|%0, %2}
9135    vmovsd\t{%2, %1, %0|%0, %1, %2}
9136    shufpd\t{$2, %1, %0|%0, %1, 2}
9137    movhpd\t{%H1, %0|%0, %H1}
9138    vmovhpd\t{%H1, %2, %0|%0, %2, %H1}
9139    #
9140    #
9141    #"
9142   [(set_attr "isa" "*,noavx,avx,noavx,avx,noavx,noavx,avx,*,*,*")
9143    (set (attr "type")
9144      (cond [(eq_attr "alternative" "5")
9145               (const_string "sselog")
9146             (eq_attr "alternative" "9")
9147               (const_string "fmov")
9148             (eq_attr "alternative" "10")
9149               (const_string "imov")
9150            ]
9151            (const_string "ssemov")))
9152    (set (attr "prefix_data16")
9153      (if_then_else (eq_attr "alternative" "1,6")
9154                    (const_string "1")
9155                    (const_string "*")))
9156    (set (attr "length_immediate")
9157      (if_then_else (eq_attr "alternative" "5")
9158                    (const_string "1")
9159                    (const_string "*")))
9160    (set (attr "prefix")
9161      (cond [(eq_attr "alternative" "0")
9162               (const_string "maybe_vex")
9163             (eq_attr "alternative" "1,3,5,6")
9164               (const_string "orig")
9165             (eq_attr "alternative" "2,4,7")
9166               (const_string "maybe_evex")
9167            ]
9168            (const_string "*")))
9169    (set_attr "mode" "DF,V1DF,V1DF,V1DF,V1DF,V2DF,V1DF,V1DF,DF,DF,DF")])
9171 (define_split
9172   [(set (match_operand:V2DF 0 "memory_operand")
9173         (vec_concat:V2DF
9174           (match_operand:DF 1 "register_operand")
9175           (vec_select:DF (match_dup 0) (parallel [(const_int 1)]))))]
9176   "TARGET_SSE2 && reload_completed"
9177   [(set (match_dup 0) (match_dup 1))]
9178   "operands[0] = adjust_address (operands[0], DFmode, 0);")
9180 (define_insn "sse2_movsd"
9181   [(set (match_operand:V2DF 0 "nonimmediate_operand"   "=x,v,x,v,m,x,x,v,o")
9182         (vec_merge:V2DF
9183           (match_operand:V2DF 2 "nonimmediate_operand" " x,v,m,m,v,0,0,v,0")
9184           (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,0,v,0,x,o,o,v")
9185           (const_int 1)))]
9186   "TARGET_SSE2"
9187   "@
9188    movsd\t{%2, %0|%0, %2}
9189    vmovsd\t{%2, %1, %0|%0, %1, %2}
9190    movlpd\t{%2, %0|%0, %q2}
9191    vmovlpd\t{%2, %1, %0|%0, %1, %q2}
9192    %vmovlpd\t{%2, %0|%q0, %2}
9193    shufpd\t{$2, %1, %0|%0, %1, 2}
9194    movhps\t{%H1, %0|%0, %H1}
9195    vmovhps\t{%H1, %2, %0|%0, %2, %H1}
9196    %vmovhps\t{%1, %H0|%H0, %1}"
9197   [(set_attr "isa" "noavx,avx,noavx,avx,*,noavx,noavx,avx,*")
9198    (set (attr "type")
9199      (if_then_else
9200        (eq_attr "alternative" "5")
9201        (const_string "sselog")
9202        (const_string "ssemov")))
9203    (set (attr "prefix_data16")
9204      (if_then_else
9205        (and (eq_attr "alternative" "2,4")
9206             (not (match_test "TARGET_AVX")))
9207        (const_string "1")
9208        (const_string "*")))
9209    (set (attr "length_immediate")
9210      (if_then_else (eq_attr "alternative" "5")
9211                    (const_string "1")
9212                    (const_string "*")))
9213    (set (attr "prefix")
9214      (cond [(eq_attr "alternative" "1,3,7")
9215               (const_string "maybe_evex")
9216             (eq_attr "alternative" "4,8")
9217               (const_string "maybe_vex")
9218            ]
9219            (const_string "orig")))
9220    (set_attr "mode" "DF,DF,V1DF,V1DF,V1DF,V2DF,V1DF,V1DF,V1DF")])
9222 (define_insn "vec_dupv2df<mask_name>"
9223   [(set (match_operand:V2DF 0 "register_operand"     "=x,x,v")
9224         (vec_duplicate:V2DF
9225           (match_operand:DF 1 "nonimmediate_operand" " 0,xm,vm")))]
9226   "TARGET_SSE2 && <mask_avx512vl_condition>"
9227   "@
9228    unpcklpd\t%0, %0
9229    %vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}
9230    vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
9231   [(set_attr "isa" "noavx,sse3,avx512vl")
9232    (set_attr "type" "sselog1")
9233    (set_attr "prefix" "orig,maybe_vex,evex")
9234    (set_attr "mode" "V2DF,DF,DF")])
9236 (define_insn "vec_concatv2df"
9237   [(set (match_operand:V2DF 0 "register_operand"     "=x,x,v,x,v,x,x, v,x,x")
9238         (vec_concat:V2DF
9239           (match_operand:DF 1 "nonimmediate_operand" " 0,x,v,m,m,0,x,xm,0,0")
9240           (match_operand:DF 2 "vector_move_operand"  " x,x,v,1,1,m,m, C,x,m")))]
9241   "TARGET_SSE
9242    && (!(MEM_P (operands[1]) && MEM_P (operands[2]))
9243        || (TARGET_SSE3 && rtx_equal_p (operands[1], operands[2])))"
9244   "@
9245    unpcklpd\t{%2, %0|%0, %2}
9246    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
9247    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
9248    %vmovddup\t{%1, %0|%0, %1}
9249    vmovddup\t{%1, %0|%0, %1}
9250    movhpd\t{%2, %0|%0, %2}
9251    vmovhpd\t{%2, %1, %0|%0, %1, %2}
9252    %vmovq\t{%1, %0|%0, %1}
9253    movlhps\t{%2, %0|%0, %2}
9254    movhps\t{%2, %0|%0, %2}"
9255   [(set (attr "isa")
9256      (cond [(eq_attr "alternative" "0,5")
9257               (const_string "sse2_noavx")
9258             (eq_attr "alternative" "1,6")
9259               (const_string "avx")
9260             (eq_attr "alternative" "2,4")
9261               (const_string "avx512vl")
9262             (eq_attr "alternative" "3")
9263               (const_string "sse3")
9264             (eq_attr "alternative" "7")
9265               (const_string "sse2")
9266            ]
9267            (const_string "noavx")))
9268    (set (attr "type")
9269      (if_then_else
9270        (eq_attr "alternative" "0,1,2,3,4")
9271        (const_string "sselog")
9272        (const_string "ssemov")))
9273    (set (attr "prefix_data16")
9274         (if_then_else (eq_attr "alternative" "5")
9275                       (const_string "1")
9276                       (const_string "*")))
9277    (set (attr "prefix")
9278      (cond [(eq_attr "alternative" "1,6")
9279               (const_string "vex")
9280             (eq_attr "alternative" "2,4")
9281               (const_string "evex")
9282             (eq_attr "alternative" "3,7")
9283               (const_string "maybe_vex")
9284            ]
9285            (const_string "orig")))
9286    (set_attr "mode" "V2DF,V2DF,V2DF, DF, DF, V1DF,V1DF,DF,V4SF,V2SF")])
9288 ;; vmovq clears also the higher bits.
9289 (define_insn "vec_set<mode>_0"
9290   [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
9291         (vec_merge:VF2_512_256
9292           (vec_duplicate:VF2_512_256
9293             (match_operand:<ssescalarmode> 2 "general_operand" "xm"))
9294           (match_operand:VF2_512_256 1 "const0_operand" "C")
9295           (const_int 1)))]
9296   "TARGET_AVX"
9297   "vmovq\t{%2, %x0|%x0, %2}"
9298   [(set_attr "type" "ssemov")
9299    (set_attr "prefix" "maybe_evex")
9300    (set_attr "mode" "DF")])
9302 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9304 ;; Parallel integer down-conversion operations
9306 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9308 (define_mode_iterator PMOV_DST_MODE_1 [V16QI V16HI V8SI V8HI])
9309 (define_mode_attr pmov_src_mode
9310   [(V16QI "V16SI") (V16HI "V16SI") (V8SI "V8DI") (V8HI "V8DI")])
9311 (define_mode_attr pmov_src_lower
9312   [(V16QI "v16si") (V16HI "v16si") (V8SI "v8di") (V8HI "v8di")])
9313 (define_mode_attr pmov_suff_1
9314   [(V16QI "db") (V16HI "dw") (V8SI "qd") (V8HI "qw")])
9316 (define_insn "*avx512f_<code><pmov_src_lower><mode>2"
9317   [(set (match_operand:PMOV_DST_MODE_1 0 "nonimmediate_operand" "=v,m")
9318         (any_truncate:PMOV_DST_MODE_1
9319           (match_operand:<pmov_src_mode> 1 "register_operand" "v,v")))]
9320   "TARGET_AVX512F"
9321   "vpmov<trunsuffix><pmov_suff_1>\t{%1, %0|%0, %1}"
9322   [(set_attr "type" "ssemov")
9323    (set_attr "memory" "none,store")
9324    (set_attr "prefix" "evex")
9325    (set_attr "mode" "<sseinsnmode>")])
9327 (define_insn "avx512f_<code><pmov_src_lower><mode>2_mask"
9328   [(set (match_operand:PMOV_DST_MODE_1 0 "nonimmediate_operand" "=v,m")
9329     (vec_merge:PMOV_DST_MODE_1
9330       (any_truncate:PMOV_DST_MODE_1
9331         (match_operand:<pmov_src_mode> 1 "register_operand" "v,v"))
9332       (match_operand:PMOV_DST_MODE_1 2 "vector_move_operand" "0C,0")
9333       (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
9334   "TARGET_AVX512F"
9335   "vpmov<trunsuffix><pmov_suff_1>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9336   [(set_attr "type" "ssemov")
9337    (set_attr "memory" "none,store")
9338    (set_attr "prefix" "evex")
9339    (set_attr "mode" "<sseinsnmode>")])
9341 (define_expand "avx512f_<code><pmov_src_lower><mode>2_mask_store"
9342   [(set (match_operand:PMOV_DST_MODE_1 0 "memory_operand")
9343     (vec_merge:PMOV_DST_MODE_1
9344       (any_truncate:PMOV_DST_MODE_1
9345         (match_operand:<pmov_src_mode> 1 "register_operand"))
9346       (match_dup 0)
9347       (match_operand:<avx512fmaskmode> 2 "register_operand")))]
9348   "TARGET_AVX512F")
9350 (define_insn "avx512bw_<code>v32hiv32qi2"
9351   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
9352         (any_truncate:V32QI
9353             (match_operand:V32HI 1 "register_operand" "v,v")))]
9354   "TARGET_AVX512BW"
9355   "vpmov<trunsuffix>wb\t{%1, %0|%0, %1}"
9356   [(set_attr "type" "ssemov")
9357    (set_attr "memory" "none,store")
9358    (set_attr "prefix" "evex")
9359    (set_attr "mode" "XI")])
9361 (define_insn "avx512bw_<code>v32hiv32qi2_mask"
9362   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
9363     (vec_merge:V32QI
9364       (any_truncate:V32QI
9365         (match_operand:V32HI 1 "register_operand" "v,v"))
9366       (match_operand:V32QI 2 "vector_move_operand" "0C,0")
9367       (match_operand:SI 3 "register_operand" "Yk,Yk")))]
9368   "TARGET_AVX512BW"
9369   "vpmov<trunsuffix>wb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9370   [(set_attr "type" "ssemov")
9371    (set_attr "memory" "none,store")
9372    (set_attr "prefix" "evex")
9373    (set_attr "mode" "XI")])
9375 (define_expand "avx512bw_<code>v32hiv32qi2_mask_store"
9376   [(set (match_operand:V32QI 0 "nonimmediate_operand")
9377     (vec_merge:V32QI
9378       (any_truncate:V32QI
9379         (match_operand:V32HI 1 "register_operand"))
9380       (match_dup 0)
9381       (match_operand:SI 2 "register_operand")))]
9382   "TARGET_AVX512BW")
9384 (define_mode_iterator PMOV_DST_MODE_2
9385   [V4SI V8HI (V16QI "TARGET_AVX512BW")])
9386 (define_mode_attr pmov_suff_2
9387   [(V16QI "wb") (V8HI "dw") (V4SI "qd")])
9389 (define_insn "*avx512vl_<code><ssedoublemodelower><mode>2"
9390   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand" "=v,m")
9391         (any_truncate:PMOV_DST_MODE_2
9392             (match_operand:<ssedoublemode> 1 "register_operand" "v,v")))]
9393   "TARGET_AVX512VL"
9394   "vpmov<trunsuffix><pmov_suff_2>\t{%1, %0|%0, %1}"
9395   [(set_attr "type" "ssemov")
9396    (set_attr "memory" "none,store")
9397    (set_attr "prefix" "evex")
9398    (set_attr "mode" "<sseinsnmode>")])
9400 (define_insn "<avx512>_<code><ssedoublemodelower><mode>2_mask"
9401   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand" "=v,m")
9402     (vec_merge:PMOV_DST_MODE_2
9403       (any_truncate:PMOV_DST_MODE_2
9404         (match_operand:<ssedoublemode> 1 "register_operand" "v,v"))
9405       (match_operand:PMOV_DST_MODE_2 2 "vector_move_operand" "0C,0")
9406       (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
9407   "TARGET_AVX512VL"
9408   "vpmov<trunsuffix><pmov_suff_2>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9409   [(set_attr "type" "ssemov")
9410    (set_attr "memory" "none,store")
9411    (set_attr "prefix" "evex")
9412    (set_attr "mode" "<sseinsnmode>")])
9414 (define_expand "<avx512>_<code><ssedoublemodelower><mode>2_mask_store"
9415   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand")
9416     (vec_merge:PMOV_DST_MODE_2
9417       (any_truncate:PMOV_DST_MODE_2
9418         (match_operand:<ssedoublemode> 1 "register_operand"))
9419       (match_dup 0)
9420       (match_operand:<avx512fmaskmode> 2 "register_operand")))]
9421   "TARGET_AVX512VL")
9423 (define_mode_iterator PMOV_SRC_MODE_3 [V4DI V2DI V8SI V4SI (V8HI "TARGET_AVX512BW")])
9424 (define_mode_attr pmov_dst_3
9425   [(V4DI "V4QI") (V2DI "V2QI") (V8SI "V8QI") (V4SI "V4QI") (V8HI "V8QI")])
9426 (define_mode_attr pmov_dst_zeroed_3
9427   [(V4DI "V12QI") (V2DI "V14QI") (V8SI "V8QI") (V4SI "V12QI") (V8HI "V8QI")])
9428 (define_mode_attr pmov_suff_3
9429   [(V4DI "qb") (V2DI "qb") (V8SI "db") (V4SI "db") (V8HI "wb")])
9431 (define_insn "*avx512vl_<code><mode>v<ssescalarnum>qi2"
9432   [(set (match_operand:V16QI 0 "register_operand" "=v")
9433     (vec_concat:V16QI
9434       (any_truncate:<pmov_dst_3>
9435               (match_operand:PMOV_SRC_MODE_3 1 "register_operand" "v"))
9436       (match_operand:<pmov_dst_zeroed_3> 2 "const0_operand")))]
9437   "TARGET_AVX512VL"
9438   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%0, %1}"
9439   [(set_attr "type" "ssemov")
9440    (set_attr "prefix" "evex")
9441    (set_attr "mode" "TI")])
9443 (define_insn "*avx512vl_<code>v2div2qi2_store"
9444   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9445     (vec_concat:V16QI
9446       (any_truncate:V2QI
9447               (match_operand:V2DI 1 "register_operand" "v"))
9448       (vec_select:V14QI
9449         (match_dup 0)
9450         (parallel [(const_int 2) (const_int 3)
9451                    (const_int 4) (const_int 5)
9452                    (const_int 6) (const_int 7)
9453                    (const_int 8) (const_int 9)
9454                    (const_int 10) (const_int 11)
9455                    (const_int 12) (const_int 13)
9456                    (const_int 14) (const_int 15)]))))]
9457   "TARGET_AVX512VL"
9458   "vpmov<trunsuffix>qb\t{%1, %0|%w0, %1}"
9459   [(set_attr "type" "ssemov")
9460    (set_attr "memory" "store")
9461    (set_attr "prefix" "evex")
9462    (set_attr "mode" "TI")])
9464 (define_insn "avx512vl_<code>v2div2qi2_mask"
9465   [(set (match_operand:V16QI 0 "register_operand" "=v")
9466     (vec_concat:V16QI
9467       (vec_merge:V2QI
9468         (any_truncate:V2QI
9469           (match_operand:V2DI 1 "register_operand" "v"))
9470         (vec_select:V2QI
9471           (match_operand:V16QI 2 "vector_move_operand" "0C")
9472           (parallel [(const_int 0) (const_int 1)]))
9473         (match_operand:QI 3 "register_operand" "Yk"))
9474       (const_vector:V14QI [(const_int 0) (const_int 0)
9475                            (const_int 0) (const_int 0)
9476                            (const_int 0) (const_int 0)
9477                            (const_int 0) (const_int 0)
9478                            (const_int 0) (const_int 0)
9479                            (const_int 0) (const_int 0)
9480                            (const_int 0) (const_int 0)])))]
9481   "TARGET_AVX512VL"
9482   "vpmov<trunsuffix>qb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9483   [(set_attr "type" "ssemov")
9484    (set_attr "prefix" "evex")
9485    (set_attr "mode" "TI")])
9487 (define_insn "*avx512vl_<code>v2div2qi2_mask_1"
9488   [(set (match_operand:V16QI 0 "register_operand" "=v")
9489     (vec_concat:V16QI
9490       (vec_merge:V2QI
9491         (any_truncate:V2QI
9492           (match_operand:V2DI 1 "register_operand" "v"))
9493         (const_vector:V2QI [(const_int 0) (const_int 0)])
9494         (match_operand:QI 2 "register_operand" "Yk"))
9495       (const_vector:V14QI [(const_int 0) (const_int 0)
9496                            (const_int 0) (const_int 0)
9497                            (const_int 0) (const_int 0)
9498                            (const_int 0) (const_int 0)
9499                            (const_int 0) (const_int 0)
9500                            (const_int 0) (const_int 0)
9501                            (const_int 0) (const_int 0)])))]
9502   "TARGET_AVX512VL"
9503   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9504   [(set_attr "type" "ssemov")
9505    (set_attr "prefix" "evex")
9506    (set_attr "mode" "TI")])
9508 (define_insn "avx512vl_<code>v2div2qi2_mask_store"
9509   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9510     (vec_concat:V16QI
9511       (vec_merge:V2QI
9512         (any_truncate:V2QI
9513           (match_operand:V2DI 1 "register_operand" "v"))
9514         (vec_select:V2QI
9515           (match_dup 0)
9516           (parallel [(const_int 0) (const_int 1)]))
9517         (match_operand:QI 2 "register_operand" "Yk"))
9518       (vec_select:V14QI
9519         (match_dup 0)
9520         (parallel [(const_int 2) (const_int 3)
9521                    (const_int 4) (const_int 5)
9522                    (const_int 6) (const_int 7)
9523                    (const_int 8) (const_int 9)
9524                    (const_int 10) (const_int 11)
9525                    (const_int 12) (const_int 13)
9526                    (const_int 14) (const_int 15)]))))]
9527   "TARGET_AVX512VL"
9528   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}|%w0%{%2%}, %1}"
9529   [(set_attr "type" "ssemov")
9530    (set_attr "memory" "store")
9531    (set_attr "prefix" "evex")
9532    (set_attr "mode" "TI")])
9534 (define_insn "*avx512vl_<code><mode>v4qi2_store"
9535   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9536     (vec_concat:V16QI
9537       (any_truncate:V4QI
9538               (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9539       (vec_select:V12QI
9540         (match_dup 0)
9541         (parallel [(const_int 4) (const_int 5)
9542                    (const_int 6) (const_int 7)
9543                    (const_int 8) (const_int 9)
9544                    (const_int 10) (const_int 11)
9545                    (const_int 12) (const_int 13)
9546                    (const_int 14) (const_int 15)]))))]
9547   "TARGET_AVX512VL"
9548   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%k0, %1}"
9549   [(set_attr "type" "ssemov")
9550    (set_attr "memory" "store")
9551    (set_attr "prefix" "evex")
9552    (set_attr "mode" "TI")])
9554 (define_insn "avx512vl_<code><mode>v4qi2_mask"
9555   [(set (match_operand:V16QI 0 "register_operand" "=v")
9556     (vec_concat:V16QI
9557       (vec_merge:V4QI
9558         (any_truncate:V4QI
9559           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9560         (vec_select:V4QI
9561           (match_operand:V16QI 2 "vector_move_operand" "0C")
9562           (parallel [(const_int 0) (const_int 1)
9563                      (const_int 2) (const_int 3)]))
9564         (match_operand:QI 3 "register_operand" "Yk"))
9565       (const_vector:V12QI [(const_int 0) (const_int 0)
9566                            (const_int 0) (const_int 0)
9567                            (const_int 0) (const_int 0)
9568                            (const_int 0) (const_int 0)
9569                            (const_int 0) (const_int 0)
9570                            (const_int 0) (const_int 0)])))]
9571   "TARGET_AVX512VL"
9572   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9573   [(set_attr "type" "ssemov")
9574    (set_attr "prefix" "evex")
9575    (set_attr "mode" "TI")])
9577 (define_insn "*avx512vl_<code><mode>v4qi2_mask_1"
9578   [(set (match_operand:V16QI 0 "register_operand" "=v")
9579     (vec_concat:V16QI
9580       (vec_merge:V4QI
9581         (any_truncate:V4QI
9582           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9583         (const_vector:V4QI [(const_int 0) (const_int 0)
9584                             (const_int 0) (const_int 0)])
9585         (match_operand:QI 2 "register_operand" "Yk"))
9586       (const_vector:V12QI [(const_int 0) (const_int 0)
9587                            (const_int 0) (const_int 0)
9588                            (const_int 0) (const_int 0)
9589                            (const_int 0) (const_int 0)
9590                            (const_int 0) (const_int 0)
9591                            (const_int 0) (const_int 0)])))]
9592   "TARGET_AVX512VL"
9593   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9594   [(set_attr "type" "ssemov")
9595    (set_attr "prefix" "evex")
9596    (set_attr "mode" "TI")])
9598 (define_insn "avx512vl_<code><mode>v4qi2_mask_store"
9599   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9600     (vec_concat:V16QI
9601       (vec_merge:V4QI
9602         (any_truncate:V4QI
9603           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9604         (vec_select:V4QI
9605           (match_dup 0)
9606           (parallel [(const_int 0) (const_int 1)
9607                      (const_int 2) (const_int 3)]))
9608         (match_operand:QI 2 "register_operand" "Yk"))
9609       (vec_select:V12QI
9610         (match_dup 0)
9611         (parallel [(const_int 4) (const_int 5)
9612                    (const_int 6) (const_int 7)
9613                    (const_int 8) (const_int 9)
9614                    (const_int 10) (const_int 11)
9615                    (const_int 12) (const_int 13)
9616                    (const_int 14) (const_int 15)]))))]
9617   "TARGET_AVX512VL"
9618   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%k0%{%2%}, %1}"
9619   [(set_attr "type" "ssemov")
9620    (set_attr "memory" "store")
9621    (set_attr "prefix" "evex")
9622    (set_attr "mode" "TI")])
9624 (define_mode_iterator VI2_128_BW_4_256
9625   [(V8HI "TARGET_AVX512BW") V8SI])
9627 (define_insn "*avx512vl_<code><mode>v8qi2_store"
9628   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9629     (vec_concat:V16QI
9630       (any_truncate:V8QI
9631               (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9632       (vec_select:V8QI
9633         (match_dup 0)
9634         (parallel [(const_int 8) (const_int 9)
9635                    (const_int 10) (const_int 11)
9636                    (const_int 12) (const_int 13)
9637                    (const_int 14) (const_int 15)]))))]
9638   "TARGET_AVX512VL"
9639   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%q0, %1}"
9640   [(set_attr "type" "ssemov")
9641    (set_attr "memory" "store")
9642    (set_attr "prefix" "evex")
9643    (set_attr "mode" "TI")])
9645 (define_insn "avx512vl_<code><mode>v8qi2_mask"
9646   [(set (match_operand:V16QI 0 "register_operand" "=v")
9647     (vec_concat:V16QI
9648       (vec_merge:V8QI
9649         (any_truncate:V8QI
9650           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9651         (vec_select:V8QI
9652           (match_operand:V16QI 2 "vector_move_operand" "0C")
9653           (parallel [(const_int 0) (const_int 1)
9654                      (const_int 2) (const_int 3)
9655                      (const_int 4) (const_int 5)
9656                      (const_int 6) (const_int 7)]))
9657         (match_operand:QI 3 "register_operand" "Yk"))
9658       (const_vector:V8QI [(const_int 0) (const_int 0)
9659                           (const_int 0) (const_int 0)
9660                           (const_int 0) (const_int 0)
9661                           (const_int 0) (const_int 0)])))]
9662   "TARGET_AVX512VL"
9663   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9664   [(set_attr "type" "ssemov")
9665    (set_attr "prefix" "evex")
9666    (set_attr "mode" "TI")])
9668 (define_insn "*avx512vl_<code><mode>v8qi2_mask_1"
9669   [(set (match_operand:V16QI 0 "register_operand" "=v")
9670     (vec_concat:V16QI
9671       (vec_merge:V8QI
9672         (any_truncate:V8QI
9673           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9674         (const_vector:V8QI [(const_int 0) (const_int 0)
9675                             (const_int 0) (const_int 0)
9676                             (const_int 0) (const_int 0)
9677                             (const_int 0) (const_int 0)])
9678         (match_operand:QI 2 "register_operand" "Yk"))
9679       (const_vector:V8QI [(const_int 0) (const_int 0)
9680                           (const_int 0) (const_int 0)
9681                           (const_int 0) (const_int 0)
9682                           (const_int 0) (const_int 0)])))]
9683   "TARGET_AVX512VL"
9684   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9685   [(set_attr "type" "ssemov")
9686    (set_attr "prefix" "evex")
9687    (set_attr "mode" "TI")])
9689 (define_insn "avx512vl_<code><mode>v8qi2_mask_store"
9690   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9691     (vec_concat:V16QI
9692       (vec_merge:V8QI
9693         (any_truncate:V8QI
9694           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9695         (vec_select:V8QI
9696           (match_dup 0)
9697           (parallel [(const_int 0) (const_int 1)
9698                      (const_int 2) (const_int 3)
9699                      (const_int 4) (const_int 5)
9700                      (const_int 6) (const_int 7)]))
9701         (match_operand:QI 2 "register_operand" "Yk"))
9702       (vec_select:V8QI
9703         (match_dup 0)
9704         (parallel [(const_int 8) (const_int 9)
9705                    (const_int 10) (const_int 11)
9706                    (const_int 12) (const_int 13)
9707                    (const_int 14) (const_int 15)]))))]
9708   "TARGET_AVX512VL"
9709   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%q0%{%2%}, %1}"
9710   [(set_attr "type" "ssemov")
9711    (set_attr "memory" "store")
9712    (set_attr "prefix" "evex")
9713    (set_attr "mode" "TI")])
9715 (define_mode_iterator PMOV_SRC_MODE_4 [V4DI V2DI V4SI])
9716 (define_mode_attr pmov_dst_4
9717   [(V4DI "V4HI") (V2DI "V2HI") (V4SI "V4HI")])
9718 (define_mode_attr pmov_dst_zeroed_4
9719   [(V4DI "V4HI") (V2DI "V6HI") (V4SI "V4HI")])
9720 (define_mode_attr pmov_suff_4
9721   [(V4DI "qw") (V2DI "qw") (V4SI "dw")])
9723 (define_insn "*avx512vl_<code><mode>v<ssescalarnum>hi2"
9724   [(set (match_operand:V8HI 0 "register_operand" "=v")
9725     (vec_concat:V8HI
9726       (any_truncate:<pmov_dst_4>
9727               (match_operand:PMOV_SRC_MODE_4 1 "register_operand" "v"))
9728       (match_operand:<pmov_dst_zeroed_4> 2 "const0_operand")))]
9729   "TARGET_AVX512VL"
9730   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0|%0, %1}"
9731   [(set_attr "type" "ssemov")
9732    (set_attr "prefix" "evex")
9733    (set_attr "mode" "TI")])
9735 (define_insn "*avx512vl_<code><mode>v4hi2_store"
9736   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9737     (vec_concat:V8HI
9738       (any_truncate:V4HI
9739               (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9740       (vec_select:V4HI
9741         (match_dup 0)
9742         (parallel [(const_int 4) (const_int 5)
9743                    (const_int 6) (const_int 7)]))))]
9744   "TARGET_AVX512VL"
9745   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0|%0, %1}"
9746   [(set_attr "type" "ssemov")
9747    (set_attr "memory" "store")
9748    (set_attr "prefix" "evex")
9749    (set_attr "mode" "TI")])
9751 (define_insn "avx512vl_<code><mode>v4hi2_mask"
9752   [(set (match_operand:V8HI 0 "register_operand" "=v")
9753     (vec_concat:V8HI
9754       (vec_merge:V4HI
9755         (any_truncate:V4HI
9756           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9757         (vec_select:V4HI
9758           (match_operand:V8HI 2 "vector_move_operand" "0C")
9759           (parallel [(const_int 0) (const_int 1)
9760                      (const_int 2) (const_int 3)]))
9761         (match_operand:QI 3 "register_operand" "Yk"))
9762       (const_vector:V4HI [(const_int 0) (const_int 0)
9763                           (const_int 0) (const_int 0)])))]
9764   "TARGET_AVX512VL"
9765   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9766   [(set_attr "type" "ssemov")
9767    (set_attr "prefix" "evex")
9768    (set_attr "mode" "TI")])
9770 (define_insn "*avx512vl_<code><mode>v4hi2_mask_1"
9771   [(set (match_operand:V8HI 0 "register_operand" "=v")
9772     (vec_concat:V8HI
9773       (vec_merge:V4HI
9774         (any_truncate:V4HI
9775           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9776         (const_vector:V4HI [(const_int 0) (const_int 0)
9777                             (const_int 0) (const_int 0)])
9778         (match_operand:QI 2 "register_operand" "Yk"))
9779       (const_vector:V4HI [(const_int 0) (const_int 0)
9780                           (const_int 0) (const_int 0)])))]
9781   "TARGET_AVX512VL"
9782   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9783   [(set_attr "type" "ssemov")
9784    (set_attr "prefix" "evex")
9785    (set_attr "mode" "TI")])
9787 (define_insn "avx512vl_<code><mode>v4hi2_mask_store"
9788   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9789     (vec_concat:V8HI
9790       (vec_merge:V4HI
9791         (any_truncate:V4HI
9792           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9793         (vec_select:V4HI
9794           (match_dup 0)
9795           (parallel [(const_int 0) (const_int 1)
9796                      (const_int 2) (const_int 3)]))
9797         (match_operand:QI 2 "register_operand" "Yk"))
9798       (vec_select:V4HI
9799         (match_dup 0)
9800         (parallel [(const_int 4) (const_int 5)
9801                    (const_int 6) (const_int 7)]))))]
9802   "TARGET_AVX512VL"
9804   if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 4)
9805     return "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}|%0%{%2%}, %t1}";
9806   return "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}|%0%{%2%}, %g1}";
9808   [(set_attr "type" "ssemov")
9809    (set_attr "memory" "store")
9810    (set_attr "prefix" "evex")
9811    (set_attr "mode" "TI")])
9813 (define_insn "*avx512vl_<code>v2div2hi2_store"
9814   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9815     (vec_concat:V8HI
9816       (any_truncate:V2HI
9817               (match_operand:V2DI 1 "register_operand" "v"))
9818       (vec_select:V6HI
9819         (match_dup 0)
9820         (parallel [(const_int 2) (const_int 3)
9821                    (const_int 4) (const_int 5)
9822                    (const_int 6) (const_int 7)]))))]
9823   "TARGET_AVX512VL"
9824   "vpmov<trunsuffix>qw\t{%1, %0|%0, %1}"
9825   [(set_attr "type" "ssemov")
9826    (set_attr "memory" "store")
9827    (set_attr "prefix" "evex")
9828    (set_attr "mode" "TI")])
9830 (define_insn "avx512vl_<code>v2div2hi2_mask"
9831   [(set (match_operand:V8HI 0 "register_operand" "=v")
9832     (vec_concat:V8HI
9833       (vec_merge:V2HI
9834         (any_truncate:V2HI
9835           (match_operand:V2DI 1 "register_operand" "v"))
9836         (vec_select:V2HI
9837           (match_operand:V8HI 2 "vector_move_operand" "0C")
9838           (parallel [(const_int 0) (const_int 1)]))
9839         (match_operand:QI 3 "register_operand" "Yk"))
9840       (const_vector:V6HI [(const_int 0) (const_int 0)
9841                           (const_int 0) (const_int 0)
9842                           (const_int 0) (const_int 0)])))]
9843   "TARGET_AVX512VL"
9844   "vpmov<trunsuffix>qw\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9845   [(set_attr "type" "ssemov")
9846    (set_attr "prefix" "evex")
9847    (set_attr "mode" "TI")])
9849 (define_insn "*avx512vl_<code>v2div2hi2_mask_1"
9850   [(set (match_operand:V8HI 0 "register_operand" "=v")
9851     (vec_concat:V8HI
9852       (vec_merge:V2HI
9853         (any_truncate:V2HI
9854           (match_operand:V2DI 1 "register_operand" "v"))
9855         (const_vector:V2HI [(const_int 0) (const_int 0)])
9856         (match_operand:QI 2 "register_operand" "Yk"))
9857       (const_vector:V6HI [(const_int 0) (const_int 0)
9858                           (const_int 0) (const_int 0)
9859                           (const_int 0) (const_int 0)])))]
9860   "TARGET_AVX512VL"
9861   "vpmov<trunsuffix>qw\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9862   [(set_attr "type" "ssemov")
9863    (set_attr "prefix" "evex")
9864    (set_attr "mode" "TI")])
9866 (define_insn "avx512vl_<code>v2div2hi2_mask_store"
9867   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9868     (vec_concat:V8HI
9869       (vec_merge:V2HI
9870         (any_truncate:V2HI
9871           (match_operand:V2DI 1 "register_operand" "v"))
9872         (vec_select:V2HI
9873           (match_dup 0)
9874           (parallel [(const_int 0) (const_int 1)]))
9875         (match_operand:QI 2 "register_operand" "Yk"))
9876       (vec_select:V6HI
9877         (match_dup 0)
9878         (parallel [(const_int 2) (const_int 3)
9879                    (const_int 4) (const_int 5)
9880                    (const_int 6) (const_int 7)]))))]
9881   "TARGET_AVX512VL"
9882   "vpmov<trunsuffix>qw\t{%1, %0%{%2%}|%0%{%2%}, %g1}"
9883   [(set_attr "type" "ssemov")
9884    (set_attr "memory" "store")
9885    (set_attr "prefix" "evex")
9886    (set_attr "mode" "TI")])
9888 (define_insn "*avx512vl_<code>v2div2si2"
9889   [(set (match_operand:V4SI 0 "register_operand" "=v")
9890     (vec_concat:V4SI
9891       (any_truncate:V2SI
9892               (match_operand:V2DI 1 "register_operand" "v"))
9893       (match_operand:V2SI 2 "const0_operand")))]
9894   "TARGET_AVX512VL"
9895   "vpmov<trunsuffix>qd\t{%1, %0|%0, %1}"
9896   [(set_attr "type" "ssemov")
9897    (set_attr "prefix" "evex")
9898    (set_attr "mode" "TI")])
9900 (define_insn "*avx512vl_<code>v2div2si2_store"
9901   [(set (match_operand:V4SI 0 "memory_operand" "=m")
9902     (vec_concat:V4SI
9903       (any_truncate:V2SI
9904               (match_operand:V2DI 1 "register_operand" "v"))
9905       (vec_select:V2SI
9906         (match_dup 0)
9907         (parallel [(const_int 2) (const_int 3)]))))]
9908   "TARGET_AVX512VL"
9909   "vpmov<trunsuffix>qd\t{%1, %0|%0, %1}"
9910   [(set_attr "type" "ssemov")
9911    (set_attr "memory" "store")
9912    (set_attr "prefix" "evex")
9913    (set_attr "mode" "TI")])
9915 (define_insn "avx512vl_<code>v2div2si2_mask"
9916   [(set (match_operand:V4SI 0 "register_operand" "=v")
9917     (vec_concat:V4SI
9918       (vec_merge:V2SI
9919         (any_truncate:V2SI
9920           (match_operand:V2DI 1 "register_operand" "v"))
9921         (vec_select:V2SI
9922           (match_operand:V4SI 2 "vector_move_operand" "0C")
9923           (parallel [(const_int 0) (const_int 1)]))
9924         (match_operand:QI 3 "register_operand" "Yk"))
9925       (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9926   "TARGET_AVX512VL"
9927   "vpmov<trunsuffix>qd\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9928   [(set_attr "type" "ssemov")
9929    (set_attr "prefix" "evex")
9930    (set_attr "mode" "TI")])
9932 (define_insn "*avx512vl_<code>v2div2si2_mask_1"
9933   [(set (match_operand:V4SI 0 "register_operand" "=v")
9934     (vec_concat:V4SI
9935       (vec_merge:V2SI
9936         (any_truncate:V2SI
9937           (match_operand:V2DI 1 "register_operand" "v"))
9938         (const_vector:V2SI [(const_int 0) (const_int 0)])
9939         (match_operand:QI 2 "register_operand" "Yk"))
9940       (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9941   "TARGET_AVX512VL"
9942   "vpmov<trunsuffix>qd\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9943   [(set_attr "type" "ssemov")
9944    (set_attr "prefix" "evex")
9945    (set_attr "mode" "TI")])
9947 (define_insn "avx512vl_<code>v2div2si2_mask_store"
9948   [(set (match_operand:V4SI 0 "memory_operand" "=m")
9949     (vec_concat:V4SI
9950       (vec_merge:V2SI
9951         (any_truncate:V2SI
9952           (match_operand:V2DI 1 "register_operand" "v"))
9953         (vec_select:V2SI
9954           (match_dup 0)
9955           (parallel [(const_int 0) (const_int 1)]))
9956         (match_operand:QI 2 "register_operand" "Yk"))
9957       (vec_select:V2SI
9958         (match_dup 0)
9959         (parallel [(const_int 2) (const_int 3)]))))]
9960   "TARGET_AVX512VL"
9961   "vpmov<trunsuffix>qd\t{%1, %0%{%2%}|%0%{%2%}, %t1}"
9962   [(set_attr "type" "ssemov")
9963    (set_attr "memory" "store")
9964    (set_attr "prefix" "evex")
9965    (set_attr "mode" "TI")])
9967 (define_insn "*avx512f_<code>v8div16qi2"
9968   [(set (match_operand:V16QI 0 "register_operand" "=v")
9969         (vec_concat:V16QI
9970           (any_truncate:V8QI
9971             (match_operand:V8DI 1 "register_operand" "v"))
9972           (const_vector:V8QI [(const_int 0) (const_int 0)
9973                               (const_int 0) (const_int 0)
9974                               (const_int 0) (const_int 0)
9975                               (const_int 0) (const_int 0)])))]
9976   "TARGET_AVX512F"
9977   "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
9978   [(set_attr "type" "ssemov")
9979    (set_attr "prefix" "evex")
9980    (set_attr "mode" "TI")])
9982 (define_insn "*avx512f_<code>v8div16qi2_store"
9983   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9984         (vec_concat:V16QI
9985           (any_truncate:V8QI
9986             (match_operand:V8DI 1 "register_operand" "v"))
9987           (vec_select:V8QI
9988             (match_dup 0)
9989             (parallel [(const_int 8) (const_int 9)
9990                        (const_int 10) (const_int 11)
9991                        (const_int 12) (const_int 13)
9992                        (const_int 14) (const_int 15)]))))]
9993   "TARGET_AVX512F"
9994   "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
9995   [(set_attr "type" "ssemov")
9996    (set_attr "memory" "store")
9997    (set_attr "prefix" "evex")
9998    (set_attr "mode" "TI")])
10000 (define_insn "avx512f_<code>v8div16qi2_mask"
10001   [(set (match_operand:V16QI 0 "register_operand" "=v")
10002     (vec_concat:V16QI
10003       (vec_merge:V8QI
10004         (any_truncate:V8QI
10005           (match_operand:V8DI 1 "register_operand" "v"))
10006         (vec_select:V8QI
10007           (match_operand:V16QI 2 "vector_move_operand" "0C")
10008           (parallel [(const_int 0) (const_int 1)
10009                      (const_int 2) (const_int 3)
10010                      (const_int 4) (const_int 5)
10011                      (const_int 6) (const_int 7)]))
10012         (match_operand:QI 3 "register_operand" "Yk"))
10013       (const_vector:V8QI [(const_int 0) (const_int 0)
10014                           (const_int 0) (const_int 0)
10015                           (const_int 0) (const_int 0)
10016                           (const_int 0) (const_int 0)])))]
10017   "TARGET_AVX512F"
10018   "vpmov<trunsuffix>qb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
10019   [(set_attr "type" "ssemov")
10020    (set_attr "prefix" "evex")
10021    (set_attr "mode" "TI")])
10023 (define_insn "*avx512f_<code>v8div16qi2_mask_1"
10024   [(set (match_operand:V16QI 0 "register_operand" "=v")
10025     (vec_concat:V16QI
10026       (vec_merge:V8QI
10027         (any_truncate:V8QI
10028           (match_operand:V8DI 1 "register_operand" "v"))
10029         (const_vector:V8QI [(const_int 0) (const_int 0)
10030                             (const_int 0) (const_int 0)
10031                             (const_int 0) (const_int 0)
10032                             (const_int 0) (const_int 0)])
10033         (match_operand:QI 2 "register_operand" "Yk"))
10034       (const_vector:V8QI [(const_int 0) (const_int 0)
10035                           (const_int 0) (const_int 0)
10036                           (const_int 0) (const_int 0)
10037                           (const_int 0) (const_int 0)])))]
10038   "TARGET_AVX512F"
10039   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
10040   [(set_attr "type" "ssemov")
10041    (set_attr "prefix" "evex")
10042    (set_attr "mode" "TI")])
10044 (define_insn "avx512f_<code>v8div16qi2_mask_store"
10045   [(set (match_operand:V16QI 0 "memory_operand" "=m")
10046     (vec_concat:V16QI
10047       (vec_merge:V8QI
10048         (any_truncate:V8QI
10049           (match_operand:V8DI 1 "register_operand" "v"))
10050         (vec_select:V8QI
10051           (match_dup 0)
10052           (parallel [(const_int 0) (const_int 1)
10053                      (const_int 2) (const_int 3)
10054                      (const_int 4) (const_int 5)
10055                      (const_int 6) (const_int 7)]))
10056         (match_operand:QI 2 "register_operand" "Yk"))
10057       (vec_select:V8QI
10058         (match_dup 0)
10059         (parallel [(const_int 8) (const_int 9)
10060                    (const_int 10) (const_int 11)
10061                    (const_int 12) (const_int 13)
10062                    (const_int 14) (const_int 15)]))))]
10063   "TARGET_AVX512F"
10064   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}|%q0%{%2%}, %1}"
10065   [(set_attr "type" "ssemov")
10066    (set_attr "memory" "store")
10067    (set_attr "prefix" "evex")
10068    (set_attr "mode" "TI")])
10070 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10072 ;; Parallel integral arithmetic
10074 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10076 (define_expand "neg<mode>2"
10077   [(set (match_operand:VI_AVX2 0 "register_operand")
10078         (minus:VI_AVX2
10079           (match_dup 2)
10080           (match_operand:VI_AVX2 1 "vector_operand")))]
10081   "TARGET_SSE2"
10082   "operands[2] = force_reg (<MODE>mode, CONST0_RTX (<MODE>mode));")
10084 (define_expand "<plusminus_insn><mode>3"
10085   [(set (match_operand:VI_AVX2 0 "register_operand")
10086         (plusminus:VI_AVX2
10087           (match_operand:VI_AVX2 1 "vector_operand")
10088           (match_operand:VI_AVX2 2 "vector_operand")))]
10089   "TARGET_SSE2"
10090   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10092 (define_expand "<plusminus_insn><mode>3_mask"
10093   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
10094         (vec_merge:VI48_AVX512VL
10095           (plusminus:VI48_AVX512VL
10096             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
10097             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
10098           (match_operand:VI48_AVX512VL 3 "vector_move_operand")
10099           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
10100   "TARGET_AVX512F"
10101   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10103 (define_expand "<plusminus_insn><mode>3_mask"
10104   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
10105         (vec_merge:VI12_AVX512VL
10106           (plusminus:VI12_AVX512VL
10107             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
10108             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand"))
10109           (match_operand:VI12_AVX512VL 3 "vector_move_operand")
10110           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
10111   "TARGET_AVX512BW"
10112   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10114 (define_insn "*<plusminus_insn><mode>3"
10115   [(set (match_operand:VI_AVX2 0 "register_operand" "=x,v")
10116         (plusminus:VI_AVX2
10117           (match_operand:VI_AVX2 1 "vector_operand" "<comm>0,v")
10118           (match_operand:VI_AVX2 2 "vector_operand" "xBm,vm")))]
10119   "TARGET_SSE2 && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10120   "@
10121    p<plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
10122    vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10123   [(set_attr "isa" "noavx,avx")
10124    (set_attr "type" "sseiadd")
10125    (set_attr "prefix_data16" "1,*")
10126    (set_attr "prefix" "orig,vex")
10127    (set_attr "mode" "<sseinsnmode>")])
10129 (define_insn "*<plusminus_insn><mode>3_mask"
10130   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10131         (vec_merge:VI48_AVX512VL
10132           (plusminus:VI48_AVX512VL
10133             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "<comm>v")
10134             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm"))
10135           (match_operand:VI48_AVX512VL 3 "vector_move_operand" "0C")
10136           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
10137   "TARGET_AVX512F && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10138   "vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
10139   [(set_attr "type" "sseiadd")
10140    (set_attr "prefix" "evex")
10141    (set_attr "mode" "<sseinsnmode>")])
10143 (define_insn "*<plusminus_insn><mode>3_mask"
10144   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
10145         (vec_merge:VI12_AVX512VL
10146           (plusminus:VI12_AVX512VL
10147             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "<comm>v")
10148             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm"))
10149           (match_operand:VI12_AVX512VL 3 "vector_move_operand" "0C")
10150           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
10151   "TARGET_AVX512BW && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10152   "vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
10153   [(set_attr "type" "sseiadd")
10154    (set_attr "prefix" "evex")
10155    (set_attr "mode" "<sseinsnmode>")])
10157 (define_expand "<sse2_avx2>_<plusminus_insn><mode>3<mask_name>"
10158   [(set (match_operand:VI12_AVX2 0 "register_operand")
10159         (sat_plusminus:VI12_AVX2
10160           (match_operand:VI12_AVX2 1 "vector_operand")
10161           (match_operand:VI12_AVX2 2 "vector_operand")))]
10162   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10163   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10165 (define_insn "*<sse2_avx2>_<plusminus_insn><mode>3<mask_name>"
10166   [(set (match_operand:VI12_AVX2 0 "register_operand" "=x,v")
10167         (sat_plusminus:VI12_AVX2
10168           (match_operand:VI12_AVX2 1 "vector_operand" "<comm>0,v")
10169           (match_operand:VI12_AVX2 2 "vector_operand" "xBm,vm")))]
10170   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
10171    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10172   "@
10173    p<plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
10174    vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10175   [(set_attr "isa" "noavx,avx")
10176    (set_attr "type" "sseiadd")
10177    (set_attr "prefix_data16" "1,*")
10178    (set_attr "prefix" "orig,maybe_evex")
10179    (set_attr "mode" "TI")])
10181 (define_expand "mul<mode>3<mask_name>"
10182   [(set (match_operand:VI1_AVX512 0 "register_operand")
10183         (mult:VI1_AVX512 (match_operand:VI1_AVX512 1 "register_operand")
10184                        (match_operand:VI1_AVX512 2 "register_operand")))]
10185   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10187   ix86_expand_vecop_qihi (MULT, operands[0], operands[1], operands[2]);
10188   DONE;
10191 (define_expand "mul<mode>3<mask_name>"
10192   [(set (match_operand:VI2_AVX2 0 "register_operand")
10193         (mult:VI2_AVX2 (match_operand:VI2_AVX2 1 "vector_operand")
10194                        (match_operand:VI2_AVX2 2 "vector_operand")))]
10195   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10196   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
10198 (define_insn "*mul<mode>3<mask_name>"
10199   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,v")
10200         (mult:VI2_AVX2 (match_operand:VI2_AVX2 1 "vector_operand" "%0,v")
10201                        (match_operand:VI2_AVX2 2 "vector_operand" "xBm,vm")))]
10202   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))
10203    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10204   "@
10205    pmullw\t{%2, %0|%0, %2}
10206    vpmullw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10207   [(set_attr "isa" "noavx,avx")
10208    (set_attr "type" "sseimul")
10209    (set_attr "prefix_data16" "1,*")
10210    (set_attr "prefix" "orig,vex")
10211    (set_attr "mode" "<sseinsnmode>")])
10213 (define_expand "<s>mul<mode>3_highpart<mask_name>"
10214   [(set (match_operand:VI2_AVX2 0 "register_operand")
10215         (truncate:VI2_AVX2
10216           (lshiftrt:<ssedoublemode>
10217             (mult:<ssedoublemode>
10218               (any_extend:<ssedoublemode>
10219                 (match_operand:VI2_AVX2 1 "vector_operand"))
10220               (any_extend:<ssedoublemode>
10221                 (match_operand:VI2_AVX2 2 "vector_operand")))
10222             (const_int 16))))]
10223   "TARGET_SSE2
10224    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10225   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
10227 (define_insn "*<s>mul<mode>3_highpart<mask_name>"
10228   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,v")
10229         (truncate:VI2_AVX2
10230           (lshiftrt:<ssedoublemode>
10231             (mult:<ssedoublemode>
10232               (any_extend:<ssedoublemode>
10233                 (match_operand:VI2_AVX2 1 "vector_operand" "%0,v"))
10234               (any_extend:<ssedoublemode>
10235                 (match_operand:VI2_AVX2 2 "vector_operand" "xBm,vm")))
10236             (const_int 16))))]
10237   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))
10238    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10239   "@
10240    pmulh<u>w\t{%2, %0|%0, %2}
10241    vpmulh<u>w\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10242   [(set_attr "isa" "noavx,avx")
10243    (set_attr "type" "sseimul")
10244    (set_attr "prefix_data16" "1,*")
10245    (set_attr "prefix" "orig,vex")
10246    (set_attr "mode" "<sseinsnmode>")])
10248 (define_expand "vec_widen_umult_even_v16si<mask_name>"
10249   [(set (match_operand:V8DI 0 "register_operand")
10250         (mult:V8DI
10251           (zero_extend:V8DI
10252             (vec_select:V8SI
10253               (match_operand:V16SI 1 "nonimmediate_operand")
10254               (parallel [(const_int 0) (const_int 2)
10255                          (const_int 4) (const_int 6)
10256                          (const_int 8) (const_int 10)
10257                          (const_int 12) (const_int 14)])))
10258           (zero_extend:V8DI
10259             (vec_select:V8SI
10260               (match_operand:V16SI 2 "nonimmediate_operand")
10261               (parallel [(const_int 0) (const_int 2)
10262                          (const_int 4) (const_int 6)
10263                          (const_int 8) (const_int 10)
10264                          (const_int 12) (const_int 14)])))))]
10265   "TARGET_AVX512F"
10266   "ix86_fixup_binary_operands_no_copy (MULT, V16SImode, operands);")
10268 (define_insn "*vec_widen_umult_even_v16si<mask_name>"
10269   [(set (match_operand:V8DI 0 "register_operand" "=v")
10270         (mult:V8DI
10271           (zero_extend:V8DI
10272             (vec_select:V8SI
10273               (match_operand:V16SI 1 "nonimmediate_operand" "%v")
10274               (parallel [(const_int 0) (const_int 2)
10275                          (const_int 4) (const_int 6)
10276                          (const_int 8) (const_int 10)
10277                          (const_int 12) (const_int 14)])))
10278           (zero_extend:V8DI
10279             (vec_select:V8SI
10280               (match_operand:V16SI 2 "nonimmediate_operand" "vm")
10281               (parallel [(const_int 0) (const_int 2)
10282                          (const_int 4) (const_int 6)
10283                          (const_int 8) (const_int 10)
10284                          (const_int 12) (const_int 14)])))))]
10285   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10286   "vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10287   [(set_attr "type" "sseimul")
10288    (set_attr "prefix_extra" "1")
10289    (set_attr "prefix" "evex")
10290    (set_attr "mode" "XI")])
10292 (define_expand "vec_widen_umult_even_v8si<mask_name>"
10293   [(set (match_operand:V4DI 0 "register_operand")
10294         (mult:V4DI
10295           (zero_extend:V4DI
10296             (vec_select:V4SI
10297               (match_operand:V8SI 1 "nonimmediate_operand")
10298               (parallel [(const_int 0) (const_int 2)
10299                          (const_int 4) (const_int 6)])))
10300           (zero_extend:V4DI
10301             (vec_select:V4SI
10302               (match_operand:V8SI 2 "nonimmediate_operand")
10303               (parallel [(const_int 0) (const_int 2)
10304                          (const_int 4) (const_int 6)])))))]
10305   "TARGET_AVX2 && <mask_avx512vl_condition>"
10306   "ix86_fixup_binary_operands_no_copy (MULT, V8SImode, operands);")
10308 (define_insn "*vec_widen_umult_even_v8si<mask_name>"
10309   [(set (match_operand:V4DI 0 "register_operand" "=v")
10310         (mult:V4DI
10311           (zero_extend:V4DI
10312             (vec_select:V4SI
10313               (match_operand:V8SI 1 "nonimmediate_operand" "%v")
10314               (parallel [(const_int 0) (const_int 2)
10315                          (const_int 4) (const_int 6)])))
10316           (zero_extend:V4DI
10317             (vec_select:V4SI
10318               (match_operand:V8SI 2 "nonimmediate_operand" "vm")
10319               (parallel [(const_int 0) (const_int 2)
10320                          (const_int 4) (const_int 6)])))))]
10321   "TARGET_AVX2 && <mask_avx512vl_condition>
10322    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10323   "vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10324   [(set_attr "type" "sseimul")
10325    (set_attr "prefix" "maybe_evex")
10326    (set_attr "mode" "OI")])
10328 (define_expand "vec_widen_umult_even_v4si<mask_name>"
10329   [(set (match_operand:V2DI 0 "register_operand")
10330         (mult:V2DI
10331           (zero_extend:V2DI
10332             (vec_select:V2SI
10333               (match_operand:V4SI 1 "vector_operand")
10334               (parallel [(const_int 0) (const_int 2)])))
10335           (zero_extend:V2DI
10336             (vec_select:V2SI
10337               (match_operand:V4SI 2 "vector_operand")
10338               (parallel [(const_int 0) (const_int 2)])))))]
10339   "TARGET_SSE2 && <mask_avx512vl_condition>"
10340   "ix86_fixup_binary_operands_no_copy (MULT, V4SImode, operands);")
10342 (define_insn "*vec_widen_umult_even_v4si<mask_name>"
10343   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
10344         (mult:V2DI
10345           (zero_extend:V2DI
10346             (vec_select:V2SI
10347               (match_operand:V4SI 1 "vector_operand" "%0,v")
10348               (parallel [(const_int 0) (const_int 2)])))
10349           (zero_extend:V2DI
10350             (vec_select:V2SI
10351               (match_operand:V4SI 2 "vector_operand" "xBm,vm")
10352               (parallel [(const_int 0) (const_int 2)])))))]
10353   "TARGET_SSE2 && <mask_avx512vl_condition>
10354    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10355   "@
10356    pmuludq\t{%2, %0|%0, %2}
10357    vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10358   [(set_attr "isa" "noavx,avx")
10359    (set_attr "type" "sseimul")
10360    (set_attr "prefix_data16" "1,*")
10361    (set_attr "prefix" "orig,maybe_evex")
10362    (set_attr "mode" "TI")])
10364 (define_expand "vec_widen_smult_even_v16si<mask_name>"
10365   [(set (match_operand:V8DI 0 "register_operand")
10366         (mult:V8DI
10367           (sign_extend:V8DI
10368             (vec_select:V8SI
10369               (match_operand:V16SI 1 "nonimmediate_operand")
10370               (parallel [(const_int 0) (const_int 2)
10371                          (const_int 4) (const_int 6)
10372                          (const_int 8) (const_int 10)
10373                          (const_int 12) (const_int 14)])))
10374           (sign_extend:V8DI
10375             (vec_select:V8SI
10376               (match_operand:V16SI 2 "nonimmediate_operand")
10377               (parallel [(const_int 0) (const_int 2)
10378                          (const_int 4) (const_int 6)
10379                          (const_int 8) (const_int 10)
10380                          (const_int 12) (const_int 14)])))))]
10381   "TARGET_AVX512F"
10382   "ix86_fixup_binary_operands_no_copy (MULT, V16SImode, operands);")
10384 (define_insn "*vec_widen_smult_even_v16si<mask_name>"
10385   [(set (match_operand:V8DI 0 "register_operand" "=v")
10386         (mult:V8DI
10387           (sign_extend:V8DI
10388             (vec_select:V8SI
10389               (match_operand:V16SI 1 "nonimmediate_operand" "%v")
10390               (parallel [(const_int 0) (const_int 2)
10391                          (const_int 4) (const_int 6)
10392                          (const_int 8) (const_int 10)
10393                          (const_int 12) (const_int 14)])))
10394           (sign_extend:V8DI
10395             (vec_select:V8SI
10396               (match_operand:V16SI 2 "nonimmediate_operand" "vm")
10397               (parallel [(const_int 0) (const_int 2)
10398                          (const_int 4) (const_int 6)
10399                          (const_int 8) (const_int 10)
10400                          (const_int 12) (const_int 14)])))))]
10401   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10402   "vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10403   [(set_attr "type" "sseimul")
10404    (set_attr "prefix_extra" "1")
10405    (set_attr "prefix" "evex")
10406    (set_attr "mode" "XI")])
10408 (define_expand "vec_widen_smult_even_v8si<mask_name>"
10409   [(set (match_operand:V4DI 0 "register_operand")
10410         (mult:V4DI
10411           (sign_extend:V4DI
10412             (vec_select:V4SI
10413               (match_operand:V8SI 1 "nonimmediate_operand")
10414               (parallel [(const_int 0) (const_int 2)
10415                          (const_int 4) (const_int 6)])))
10416           (sign_extend:V4DI
10417             (vec_select:V4SI
10418               (match_operand:V8SI 2 "nonimmediate_operand")
10419               (parallel [(const_int 0) (const_int 2)
10420                          (const_int 4) (const_int 6)])))))]
10421   "TARGET_AVX2 && <mask_avx512vl_condition>"
10422   "ix86_fixup_binary_operands_no_copy (MULT, V8SImode, operands);")
10424 (define_insn "*vec_widen_smult_even_v8si<mask_name>"
10425   [(set (match_operand:V4DI 0 "register_operand" "=v")
10426         (mult:V4DI
10427           (sign_extend:V4DI
10428             (vec_select:V4SI
10429               (match_operand:V8SI 1 "nonimmediate_operand" "%v")
10430               (parallel [(const_int 0) (const_int 2)
10431                          (const_int 4) (const_int 6)])))
10432           (sign_extend:V4DI
10433             (vec_select:V4SI
10434               (match_operand:V8SI 2 "nonimmediate_operand" "vm")
10435               (parallel [(const_int 0) (const_int 2)
10436                          (const_int 4) (const_int 6)])))))]
10437   "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10438   "vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10439   [(set_attr "type" "sseimul")
10440    (set_attr "prefix_extra" "1")
10441    (set_attr "prefix" "vex")
10442    (set_attr "mode" "OI")])
10444 (define_expand "sse4_1_mulv2siv2di3<mask_name>"
10445   [(set (match_operand:V2DI 0 "register_operand")
10446         (mult:V2DI
10447           (sign_extend:V2DI
10448             (vec_select:V2SI
10449               (match_operand:V4SI 1 "vector_operand")
10450               (parallel [(const_int 0) (const_int 2)])))
10451           (sign_extend:V2DI
10452             (vec_select:V2SI
10453               (match_operand:V4SI 2 "vector_operand")
10454               (parallel [(const_int 0) (const_int 2)])))))]
10455   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
10456   "ix86_fixup_binary_operands_no_copy (MULT, V4SImode, operands);")
10458 (define_insn "*sse4_1_mulv2siv2di3<mask_name>"
10459   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
10460         (mult:V2DI
10461           (sign_extend:V2DI
10462             (vec_select:V2SI
10463               (match_operand:V4SI 1 "vector_operand" "%0,0,v")
10464               (parallel [(const_int 0) (const_int 2)])))
10465           (sign_extend:V2DI
10466             (vec_select:V2SI
10467               (match_operand:V4SI 2 "vector_operand" "YrBm,*xBm,vm")
10468               (parallel [(const_int 0) (const_int 2)])))))]
10469   "TARGET_SSE4_1 && <mask_avx512vl_condition>
10470    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10471   "@
10472    pmuldq\t{%2, %0|%0, %2}
10473    pmuldq\t{%2, %0|%0, %2}
10474    vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10475   [(set_attr "isa" "noavx,noavx,avx")
10476    (set_attr "type" "sseimul")
10477    (set_attr "prefix_data16" "1,1,*")
10478    (set_attr "prefix_extra" "1")
10479    (set_attr "prefix" "orig,orig,vex")
10480    (set_attr "mode" "TI")])
10482 (define_insn "avx512bw_pmaddwd512<mode><mask_name>"
10483   [(set (match_operand:<sseunpackmode> 0 "register_operand" "=v")
10484           (unspec:<sseunpackmode>
10485             [(match_operand:VI2_AVX2 1 "register_operand" "v")
10486              (match_operand:VI2_AVX2 2 "nonimmediate_operand" "vm")]
10487              UNSPEC_PMADDWD512))]
10488    "TARGET_AVX512BW && <mask_mode512bit_condition>"
10489    "vpmaddwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}";
10490   [(set_attr "type" "sseiadd")
10491    (set_attr "prefix" "evex")
10492    (set_attr "mode" "XI")])
10494 (define_expand "avx2_pmaddwd"
10495   [(set (match_operand:V8SI 0 "register_operand")
10496         (plus:V8SI
10497           (mult:V8SI
10498             (sign_extend:V8SI
10499               (vec_select:V8HI
10500                 (match_operand:V16HI 1 "nonimmediate_operand")
10501                 (parallel [(const_int 0) (const_int 2)
10502                            (const_int 4) (const_int 6)
10503                            (const_int 8) (const_int 10)
10504                            (const_int 12) (const_int 14)])))
10505             (sign_extend:V8SI
10506               (vec_select:V8HI
10507                 (match_operand:V16HI 2 "nonimmediate_operand")
10508                 (parallel [(const_int 0) (const_int 2)
10509                            (const_int 4) (const_int 6)
10510                            (const_int 8) (const_int 10)
10511                            (const_int 12) (const_int 14)]))))
10512           (mult:V8SI
10513             (sign_extend:V8SI
10514               (vec_select:V8HI (match_dup 1)
10515                 (parallel [(const_int 1) (const_int 3)
10516                            (const_int 5) (const_int 7)
10517                            (const_int 9) (const_int 11)
10518                            (const_int 13) (const_int 15)])))
10519             (sign_extend:V8SI
10520               (vec_select:V8HI (match_dup 2)
10521                 (parallel [(const_int 1) (const_int 3)
10522                            (const_int 5) (const_int 7)
10523                            (const_int 9) (const_int 11)
10524                            (const_int 13) (const_int 15)]))))))]
10525   "TARGET_AVX2"
10526   "ix86_fixup_binary_operands_no_copy (MULT, V16HImode, operands);")
10528 (define_insn "*avx2_pmaddwd"
10529   [(set (match_operand:V8SI 0 "register_operand" "=x,v")
10530         (plus:V8SI
10531           (mult:V8SI
10532             (sign_extend:V8SI
10533               (vec_select:V8HI
10534                 (match_operand:V16HI 1 "nonimmediate_operand" "%x,v")
10535                 (parallel [(const_int 0) (const_int 2)
10536                            (const_int 4) (const_int 6)
10537                            (const_int 8) (const_int 10)
10538                            (const_int 12) (const_int 14)])))
10539             (sign_extend:V8SI
10540               (vec_select:V8HI
10541                 (match_operand:V16HI 2 "nonimmediate_operand" "xm,vm")
10542                 (parallel [(const_int 0) (const_int 2)
10543                            (const_int 4) (const_int 6)
10544                            (const_int 8) (const_int 10)
10545                            (const_int 12) (const_int 14)]))))
10546           (mult:V8SI
10547             (sign_extend:V8SI
10548               (vec_select:V8HI (match_dup 1)
10549                 (parallel [(const_int 1) (const_int 3)
10550                            (const_int 5) (const_int 7)
10551                            (const_int 9) (const_int 11)
10552                            (const_int 13) (const_int 15)])))
10553             (sign_extend:V8SI
10554               (vec_select:V8HI (match_dup 2)
10555                 (parallel [(const_int 1) (const_int 3)
10556                            (const_int 5) (const_int 7)
10557                            (const_int 9) (const_int 11)
10558                            (const_int 13) (const_int 15)]))))))]
10559   "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10560   "vpmaddwd\t{%2, %1, %0|%0, %1, %2}"
10561   [(set_attr "type" "sseiadd")
10562    (set_attr "isa" "*,avx512bw")
10563    (set_attr "prefix" "vex,evex")
10564    (set_attr "mode" "OI")])
10566 (define_expand "sse2_pmaddwd"
10567   [(set (match_operand:V4SI 0 "register_operand")
10568         (plus:V4SI
10569           (mult:V4SI
10570             (sign_extend:V4SI
10571               (vec_select:V4HI
10572                 (match_operand:V8HI 1 "vector_operand")
10573                 (parallel [(const_int 0) (const_int 2)
10574                            (const_int 4) (const_int 6)])))
10575             (sign_extend:V4SI
10576               (vec_select:V4HI
10577                 (match_operand:V8HI 2 "vector_operand")
10578                 (parallel [(const_int 0) (const_int 2)
10579                            (const_int 4) (const_int 6)]))))
10580           (mult:V4SI
10581             (sign_extend:V4SI
10582               (vec_select:V4HI (match_dup 1)
10583                 (parallel [(const_int 1) (const_int 3)
10584                            (const_int 5) (const_int 7)])))
10585             (sign_extend:V4SI
10586               (vec_select:V4HI (match_dup 2)
10587                 (parallel [(const_int 1) (const_int 3)
10588                            (const_int 5) (const_int 7)]))))))]
10589   "TARGET_SSE2"
10590   "ix86_fixup_binary_operands_no_copy (MULT, V8HImode, operands);")
10592 (define_insn "*sse2_pmaddwd"
10593   [(set (match_operand:V4SI 0 "register_operand" "=x,x,v")
10594         (plus:V4SI
10595           (mult:V4SI
10596             (sign_extend:V4SI
10597               (vec_select:V4HI
10598                 (match_operand:V8HI 1 "vector_operand" "%0,x,v")
10599                 (parallel [(const_int 0) (const_int 2)
10600                            (const_int 4) (const_int 6)])))
10601             (sign_extend:V4SI
10602               (vec_select:V4HI
10603                 (match_operand:V8HI 2 "vector_operand" "xBm,xm,vm")
10604                 (parallel [(const_int 0) (const_int 2)
10605                            (const_int 4) (const_int 6)]))))
10606           (mult:V4SI
10607             (sign_extend:V4SI
10608               (vec_select:V4HI (match_dup 1)
10609                 (parallel [(const_int 1) (const_int 3)
10610                            (const_int 5) (const_int 7)])))
10611             (sign_extend:V4SI
10612               (vec_select:V4HI (match_dup 2)
10613                 (parallel [(const_int 1) (const_int 3)
10614                            (const_int 5) (const_int 7)]))))))]
10615   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10616   "@
10617    pmaddwd\t{%2, %0|%0, %2}
10618    vpmaddwd\t{%2, %1, %0|%0, %1, %2}
10619    vpmaddwd\t{%2, %1, %0|%0, %1, %2}"
10620   [(set_attr "isa" "noavx,avx,avx512bw")
10621    (set_attr "type" "sseiadd")
10622    (set_attr "atom_unit" "simul")
10623    (set_attr "prefix_data16" "1,*,*")
10624    (set_attr "prefix" "orig,vex,evex")
10625    (set_attr "mode" "TI")])
10627 (define_insn "avx512dq_mul<mode>3<mask_name>"
10628   [(set (match_operand:VI8 0 "register_operand" "=v")
10629         (mult:VI8
10630           (match_operand:VI8 1 "register_operand" "v")
10631           (match_operand:VI8 2 "nonimmediate_operand" "vm")))]
10632   "TARGET_AVX512DQ && <mask_mode512bit_condition>"
10633   "vpmullq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10634   [(set_attr "type" "sseimul")
10635    (set_attr "prefix" "evex")
10636    (set_attr "mode" "<sseinsnmode>")])
10638 (define_expand "mul<mode>3<mask_name>"
10639   [(set (match_operand:VI4_AVX512F 0 "register_operand")
10640         (mult:VI4_AVX512F
10641           (match_operand:VI4_AVX512F 1 "general_vector_operand")
10642           (match_operand:VI4_AVX512F 2 "general_vector_operand")))]
10643   "TARGET_SSE2 && <mask_mode512bit_condition>"
10645   if (TARGET_SSE4_1)
10646     {
10647       if (!vector_operand (operands[1], <MODE>mode))
10648         operands[1] = force_reg (<MODE>mode, operands[1]);
10649       if (!vector_operand (operands[2], <MODE>mode))
10650         operands[2] = force_reg (<MODE>mode, operands[2]);
10651       ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
10652     }
10653   else
10654     {
10655       ix86_expand_sse2_mulv4si3 (operands[0], operands[1], operands[2]);
10656       DONE;
10657     }
10660 (define_insn "*<sse4_1_avx2>_mul<mode>3<mask_name>"
10661   [(set (match_operand:VI4_AVX512F 0 "register_operand" "=Yr,*x,v")
10662         (mult:VI4_AVX512F
10663           (match_operand:VI4_AVX512F 1 "vector_operand" "%0,0,v")
10664           (match_operand:VI4_AVX512F 2 "vector_operand" "YrBm,*xBm,vm")))]
10665   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))
10666    && <mask_mode512bit_condition>"
10667   "@
10668    pmulld\t{%2, %0|%0, %2}
10669    pmulld\t{%2, %0|%0, %2}
10670    vpmulld\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10671   [(set_attr "isa" "noavx,noavx,avx")
10672    (set_attr "type" "sseimul")
10673    (set_attr "prefix_extra" "1")
10674    (set_attr "prefix" "<mask_prefix4>")
10675    (set_attr "btver2_decode" "vector,vector,vector")
10676    (set_attr "mode" "<sseinsnmode>")])
10678 (define_expand "mul<mode>3"
10679   [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand")
10680         (mult:VI8_AVX2_AVX512F
10681           (match_operand:VI8_AVX2_AVX512F 1 "register_operand")
10682           (match_operand:VI8_AVX2_AVX512F 2 "register_operand")))]
10683   "TARGET_SSE2"
10685   ix86_expand_sse2_mulvxdi3 (operands[0], operands[1], operands[2]);
10686   DONE;
10689 (define_expand "vec_widen_<s>mult_hi_<mode>"
10690   [(match_operand:<sseunpackmode> 0 "register_operand")
10691    (any_extend:<sseunpackmode>
10692      (match_operand:VI124_AVX2 1 "register_operand"))
10693    (match_operand:VI124_AVX2 2 "register_operand")]
10694   "TARGET_SSE2"
10696   ix86_expand_mul_widen_hilo (operands[0], operands[1], operands[2],
10697                               <u_bool>, true);
10698   DONE;
10701 (define_expand "vec_widen_<s>mult_lo_<mode>"
10702   [(match_operand:<sseunpackmode> 0 "register_operand")
10703    (any_extend:<sseunpackmode>
10704      (match_operand:VI124_AVX2 1 "register_operand"))
10705    (match_operand:VI124_AVX2 2 "register_operand")]
10706   "TARGET_SSE2"
10708   ix86_expand_mul_widen_hilo (operands[0], operands[1], operands[2],
10709                               <u_bool>, false);
10710   DONE;
10713 ;; Most widen_<s>mult_even_<mode> can be handled directly from other
10714 ;; named patterns, but signed V4SI needs special help for plain SSE2.
10715 (define_expand "vec_widen_smult_even_v4si"
10716   [(match_operand:V2DI 0 "register_operand")
10717    (match_operand:V4SI 1 "vector_operand")
10718    (match_operand:V4SI 2 "vector_operand")]
10719   "TARGET_SSE2"
10721   ix86_expand_mul_widen_evenodd (operands[0], operands[1], operands[2],
10722                                  false, false);
10723   DONE;
10726 (define_expand "vec_widen_<s>mult_odd_<mode>"
10727   [(match_operand:<sseunpackmode> 0 "register_operand")
10728    (any_extend:<sseunpackmode>
10729      (match_operand:VI4_AVX512F 1 "general_vector_operand"))
10730    (match_operand:VI4_AVX512F 2 "general_vector_operand")]
10731   "TARGET_SSE2"
10733   ix86_expand_mul_widen_evenodd (operands[0], operands[1], operands[2],
10734                                  <u_bool>, true);
10735   DONE;
10738 (define_mode_attr SDOT_PMADD_SUF
10739   [(V32HI "512v32hi") (V16HI "") (V8HI "")])
10741 (define_expand "sdot_prod<mode>"
10742   [(match_operand:<sseunpackmode> 0 "register_operand")
10743    (match_operand:VI2_AVX2 1 "register_operand")
10744    (match_operand:VI2_AVX2 2 "register_operand")
10745    (match_operand:<sseunpackmode> 3 "register_operand")]
10746   "TARGET_SSE2"
10748   rtx t = gen_reg_rtx (<sseunpackmode>mode);
10749   emit_insn (gen_<sse2_avx2>_pmaddwd<SDOT_PMADD_SUF> (t, operands[1], operands[2]));
10750   emit_insn (gen_rtx_SET (operands[0],
10751                           gen_rtx_PLUS (<sseunpackmode>mode,
10752                                         operands[3], t)));
10753   DONE;
10756 ;; Normally we use widen_mul_even/odd, but combine can't quite get it all
10757 ;; back together when madd is available.
10758 (define_expand "sdot_prodv4si"
10759   [(match_operand:V2DI 0 "register_operand")
10760    (match_operand:V4SI 1 "register_operand")
10761    (match_operand:V4SI 2 "register_operand")
10762    (match_operand:V2DI 3 "register_operand")]
10763   "TARGET_XOP"
10765   rtx t = gen_reg_rtx (V2DImode);
10766   emit_insn (gen_xop_pmacsdqh (t, operands[1], operands[2], operands[3]));
10767   emit_insn (gen_xop_pmacsdql (operands[0], operands[1], operands[2], t));
10768   DONE;
10771 (define_expand "uavg<mode>3_ceil"
10772   [(set (match_operand:VI12_AVX2 0 "register_operand")
10773         (truncate:VI12_AVX2
10774           (lshiftrt:<ssedoublemode>
10775             (plus:<ssedoublemode>
10776               (plus:<ssedoublemode>
10777                 (zero_extend:<ssedoublemode>
10778                   (match_operand:VI12_AVX2 1 "vector_operand"))
10779                 (zero_extend:<ssedoublemode>
10780                   (match_operand:VI12_AVX2 2 "vector_operand")))
10781               (match_dup 3))
10782             (const_int 1))))]
10783   "TARGET_SSE2"
10785   operands[3] = CONST1_RTX(<MODE>mode);
10786   ix86_fixup_binary_operands_no_copy (PLUS, <MODE>mode, operands);
10789 (define_expand "usadv16qi"
10790   [(match_operand:V4SI 0 "register_operand")
10791    (match_operand:V16QI 1 "register_operand")
10792    (match_operand:V16QI 2 "vector_operand")
10793    (match_operand:V4SI 3 "vector_operand")]
10794   "TARGET_SSE2"
10796   rtx t1 = gen_reg_rtx (V2DImode);
10797   rtx t2 = gen_reg_rtx (V4SImode);
10798   emit_insn (gen_sse2_psadbw (t1, operands[1], operands[2]));
10799   convert_move (t2, t1, 0);
10800   emit_insn (gen_addv4si3 (operands[0], t2, operands[3]));
10801   DONE;
10804 (define_expand "usadv32qi"
10805   [(match_operand:V8SI 0 "register_operand")
10806    (match_operand:V32QI 1 "register_operand")
10807    (match_operand:V32QI 2 "nonimmediate_operand")
10808    (match_operand:V8SI 3 "nonimmediate_operand")]
10809   "TARGET_AVX2"
10811   rtx t1 = gen_reg_rtx (V4DImode);
10812   rtx t2 = gen_reg_rtx (V8SImode);
10813   emit_insn (gen_avx2_psadbw (t1, operands[1], operands[2]));
10814   convert_move (t2, t1, 0);
10815   emit_insn (gen_addv8si3 (operands[0], t2, operands[3]));
10816   DONE;
10819 (define_expand "usadv64qi"
10820   [(match_operand:V16SI 0 "register_operand")
10821    (match_operand:V64QI 1 "register_operand")
10822    (match_operand:V64QI 2 "nonimmediate_operand")
10823    (match_operand:V16SI 3 "nonimmediate_operand")]
10824   "TARGET_AVX512BW"
10826   rtx t1 = gen_reg_rtx (V8DImode);
10827   rtx t2 = gen_reg_rtx (V16SImode);
10828   emit_insn (gen_avx512f_psadbw (t1, operands[1], operands[2]));
10829   convert_move (t2, t1, 0);
10830   emit_insn (gen_addv16si3 (operands[0], t2, operands[3]));
10831   DONE;
10834 (define_insn "<mask_codefor>ashr<mode>3<mask_name>"
10835   [(set (match_operand:VI248_AVX512BW_1 0 "register_operand" "=v,v")
10836         (ashiftrt:VI248_AVX512BW_1
10837           (match_operand:VI248_AVX512BW_1 1 "nonimmediate_operand" "v,vm")
10838           (match_operand:DI 2 "nonmemory_operand" "v,N")))]
10839   "TARGET_AVX512VL"
10840   "vpsra<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10841   [(set_attr "type" "sseishft")
10842    (set (attr "length_immediate")
10843      (if_then_else (match_operand 2 "const_int_operand")
10844        (const_string "1")
10845        (const_string "0")))
10846    (set_attr "mode" "<sseinsnmode>")])
10848 (define_insn "ashr<mode>3"
10849   [(set (match_operand:VI24_AVX2 0 "register_operand" "=x,x")
10850         (ashiftrt:VI24_AVX2
10851           (match_operand:VI24_AVX2 1 "register_operand" "0,x")
10852           (match_operand:DI 2 "nonmemory_operand" "xN,xN")))]
10853   "TARGET_SSE2"
10854   "@
10855    psra<ssemodesuffix>\t{%2, %0|%0, %2}
10856    vpsra<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10857   [(set_attr "isa" "noavx,avx")
10858    (set_attr "type" "sseishft")
10859    (set (attr "length_immediate")
10860      (if_then_else (match_operand 2 "const_int_operand")
10861        (const_string "1")
10862        (const_string "0")))
10863    (set_attr "prefix_data16" "1,*")
10864    (set_attr "prefix" "orig,vex")
10865    (set_attr "mode" "<sseinsnmode>")])
10867 (define_insn "ashr<mode>3<mask_name>"
10868   [(set (match_operand:VI248_AVX512BW_AVX512VL 0 "register_operand" "=v,v")
10869         (ashiftrt:VI248_AVX512BW_AVX512VL
10870           (match_operand:VI248_AVX512BW_AVX512VL 1 "nonimmediate_operand" "v,vm")
10871           (match_operand:DI 2 "nonmemory_operand" "v,N")))]
10872   "TARGET_AVX512F"
10873   "vpsra<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10874   [(set_attr "type" "sseishft")
10875    (set (attr "length_immediate")
10876      (if_then_else (match_operand 2 "const_int_operand")
10877        (const_string "1")
10878        (const_string "0")))
10879    (set_attr "mode" "<sseinsnmode>")])
10881 (define_insn "<mask_codefor><shift_insn><mode>3<mask_name>"
10882   [(set (match_operand:VI248_AVX512BW_2 0 "register_operand" "=v,v")
10883         (any_lshift:VI248_AVX512BW_2
10884           (match_operand:VI248_AVX512BW_2 1 "nonimmediate_operand" "v,vm")
10885           (match_operand:DI 2 "nonmemory_operand" "v,N")))]
10886   "TARGET_AVX512VL"
10887   "vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10888   [(set_attr "type" "sseishft")
10889    (set (attr "length_immediate")
10890      (if_then_else (match_operand 2 "const_int_operand")
10891        (const_string "1")
10892        (const_string "0")))
10893    (set_attr "mode" "<sseinsnmode>")])
10895 (define_insn "<shift_insn><mode>3"
10896   [(set (match_operand:VI248_AVX2 0 "register_operand" "=x,x")
10897         (any_lshift:VI248_AVX2
10898           (match_operand:VI248_AVX2 1 "register_operand" "0,x")
10899           (match_operand:DI 2 "nonmemory_operand" "xN,xN")))]
10900   "TARGET_SSE2"
10901   "@
10902    p<vshift><ssemodesuffix>\t{%2, %0|%0, %2}
10903    vp<vshift><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10904   [(set_attr "isa" "noavx,avx")
10905    (set_attr "type" "sseishft")
10906    (set (attr "length_immediate")
10907      (if_then_else (match_operand 2 "const_int_operand")
10908        (const_string "1")
10909        (const_string "0")))
10910    (set_attr "prefix_data16" "1,*")
10911    (set_attr "prefix" "orig,vex")
10912    (set_attr "mode" "<sseinsnmode>")])
10914 (define_insn "<shift_insn><mode>3<mask_name>"
10915   [(set (match_operand:VI248_AVX512BW 0 "register_operand" "=v,v")
10916         (any_lshift:VI248_AVX512BW
10917           (match_operand:VI248_AVX512BW 1 "nonimmediate_operand" "v,m")
10918           (match_operand:DI 2 "nonmemory_operand" "vN,N")))]
10919   "TARGET_AVX512F"
10920   "vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10921   [(set_attr "type" "sseishft")
10922    (set (attr "length_immediate")
10923      (if_then_else (match_operand 2 "const_int_operand")
10924        (const_string "1")
10925        (const_string "0")))
10926    (set_attr "mode" "<sseinsnmode>")])
10929 (define_expand "vec_shr_<mode>"
10930   [(set (match_dup 3)
10931         (lshiftrt:V1TI
10932          (match_operand:VI_128 1 "register_operand")
10933          (match_operand:SI 2 "const_0_to_255_mul_8_operand")))
10934    (set (match_operand:VI_128 0 "register_operand") (match_dup 4))]
10935   "TARGET_SSE2"
10937   operands[1] = gen_lowpart (V1TImode, operands[1]);
10938   operands[3] = gen_reg_rtx (V1TImode);
10939   operands[4] = gen_lowpart (<MODE>mode, operands[3]);
10942 (define_insn "avx512bw_<shift_insn><mode>3"
10943   [(set (match_operand:VIMAX_AVX512VL 0 "register_operand" "=v")
10944         (any_lshift:VIMAX_AVX512VL
10945          (match_operand:VIMAX_AVX512VL 1 "nonimmediate_operand" "vm")
10946          (match_operand:SI 2 "const_0_to_255_mul_8_operand" "n")))]
10947   "TARGET_AVX512BW"
10949   operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
10950   return "vp<vshift>dq\t{%2, %1, %0|%0, %1, %2}";
10952   [(set_attr "type" "sseishft")
10953    (set_attr "length_immediate" "1")
10954    (set_attr "prefix" "maybe_evex")
10955    (set_attr "mode" "<sseinsnmode>")])
10957 (define_insn "<sse2_avx2>_<shift_insn><mode>3"
10958   [(set (match_operand:VIMAX_AVX2 0 "register_operand" "=x,v")
10959         (any_lshift:VIMAX_AVX2
10960          (match_operand:VIMAX_AVX2 1 "register_operand" "0,v")
10961          (match_operand:SI 2 "const_0_to_255_mul_8_operand" "n,n")))]
10962   "TARGET_SSE2"
10964   operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
10966   switch (which_alternative)
10967     {
10968     case 0:
10969       return "p<vshift>dq\t{%2, %0|%0, %2}";
10970     case 1:
10971       return "vp<vshift>dq\t{%2, %1, %0|%0, %1, %2}";
10972     default:
10973       gcc_unreachable ();
10974     }
10976   [(set_attr "isa" "noavx,avx")
10977    (set_attr "type" "sseishft")
10978    (set_attr "length_immediate" "1")
10979    (set_attr "atom_unit" "sishuf")
10980    (set_attr "prefix_data16" "1,*")
10981    (set_attr "prefix" "orig,vex")
10982    (set_attr "mode" "<sseinsnmode>")])
10984 (define_insn "<avx512>_<rotate>v<mode><mask_name>"
10985   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10986         (any_rotate:VI48_AVX512VL
10987           (match_operand:VI48_AVX512VL 1 "register_operand" "v")
10988           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")))]
10989   "TARGET_AVX512F"
10990   "vp<rotate>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10991   [(set_attr "prefix" "evex")
10992    (set_attr "mode" "<sseinsnmode>")])
10994 (define_insn "<avx512>_<rotate><mode><mask_name>"
10995   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10996         (any_rotate:VI48_AVX512VL
10997           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")
10998           (match_operand:SI 2 "const_0_to_255_operand")))]
10999   "TARGET_AVX512F"
11000   "vp<rotate><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11001   [(set_attr "prefix" "evex")
11002    (set_attr "mode" "<sseinsnmode>")])
11004 (define_expand "<code><mode>3"
11005   [(set (match_operand:VI124_256_AVX512F_AVX512BW 0 "register_operand")
11006         (maxmin:VI124_256_AVX512F_AVX512BW
11007           (match_operand:VI124_256_AVX512F_AVX512BW 1 "nonimmediate_operand")
11008           (match_operand:VI124_256_AVX512F_AVX512BW 2 "nonimmediate_operand")))]
11009   "TARGET_AVX2"
11010   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
11012 (define_insn "*avx2_<code><mode>3"
11013   [(set (match_operand:VI124_256 0 "register_operand" "=v")
11014         (maxmin:VI124_256
11015           (match_operand:VI124_256 1 "nonimmediate_operand" "%v")
11016           (match_operand:VI124_256 2 "nonimmediate_operand" "vm")))]
11017   "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11018   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11019   [(set_attr "type" "sseiadd")
11020    (set_attr "prefix_extra" "1")
11021    (set_attr "prefix" "vex")
11022    (set_attr "mode" "OI")])
11024 (define_expand "<code><mode>3_mask"
11025   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
11026         (vec_merge:VI48_AVX512VL
11027           (maxmin:VI48_AVX512VL
11028             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
11029             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
11030           (match_operand:VI48_AVX512VL 3 "vector_move_operand")
11031           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
11032   "TARGET_AVX512F"
11033   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
11035 (define_insn "*avx512f_<code><mode>3<mask_name>"
11036   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
11037         (maxmin:VI48_AVX512VL
11038           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "%v")
11039           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")))]
11040   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11041   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11042   [(set_attr "type" "sseiadd")
11043    (set_attr "prefix_extra" "1")
11044    (set_attr "prefix" "maybe_evex")
11045    (set_attr "mode" "<sseinsnmode>")])
11047 (define_insn "<mask_codefor><code><mode>3<mask_name>"
11048   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
11049         (maxmin:VI12_AVX512VL
11050           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
11051           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")))]
11052   "TARGET_AVX512BW"
11053   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11054   [(set_attr "type" "sseiadd")
11055    (set_attr "prefix" "evex")
11056    (set_attr "mode" "<sseinsnmode>")])
11058 (define_expand "<code><mode>3"
11059   [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand")
11060         (maxmin:VI8_AVX2_AVX512F
11061           (match_operand:VI8_AVX2_AVX512F 1 "register_operand")
11062           (match_operand:VI8_AVX2_AVX512F 2 "register_operand")))]
11063   "TARGET_SSE4_2"
11065   if (TARGET_AVX512F
11066       && (<MODE>mode == V8DImode || TARGET_AVX512VL))
11067     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
11068   else 
11069     {
11070       enum rtx_code code;
11071       rtx xops[6];
11072       bool ok;
11075       xops[0] = operands[0];
11077       if (<CODE> == SMAX || <CODE> == UMAX)
11078         {
11079           xops[1] = operands[1];
11080           xops[2] = operands[2];
11081         }
11082       else
11083         {
11084           xops[1] = operands[2];
11085           xops[2] = operands[1];
11086         }
11088       code = (<CODE> == UMAX || <CODE> == UMIN) ? GTU : GT;
11090       xops[3] = gen_rtx_fmt_ee (code, VOIDmode, operands[1], operands[2]);
11091       xops[4] = operands[1];
11092       xops[5] = operands[2];
11094       ok = ix86_expand_int_vcond (xops);
11095       gcc_assert (ok);
11096       DONE;
11097     }
11100 (define_expand "<code><mode>3"
11101   [(set (match_operand:VI124_128 0 "register_operand")
11102         (smaxmin:VI124_128
11103           (match_operand:VI124_128 1 "vector_operand")
11104           (match_operand:VI124_128 2 "vector_operand")))]
11105   "TARGET_SSE2"
11107   if (TARGET_SSE4_1 || <MODE>mode == V8HImode)
11108     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
11109   else
11110     {
11111       rtx xops[6];
11112       bool ok;
11114       xops[0] = operands[0];
11115       operands[1] = force_reg (<MODE>mode, operands[1]);
11116       operands[2] = force_reg (<MODE>mode, operands[2]);
11118       if (<CODE> == SMAX)
11119         {
11120           xops[1] = operands[1];
11121           xops[2] = operands[2];
11122         }
11123       else
11124         {
11125           xops[1] = operands[2];
11126           xops[2] = operands[1];
11127         }
11129       xops[3] = gen_rtx_GT (VOIDmode, operands[1], operands[2]);
11130       xops[4] = operands[1];
11131       xops[5] = operands[2];
11133       ok = ix86_expand_int_vcond (xops);
11134       gcc_assert (ok);
11135       DONE;
11136     }
11139 (define_insn "*sse4_1_<code><mode>3<mask_name>"
11140   [(set (match_operand:VI14_128 0 "register_operand" "=Yr,*x,v")
11141         (smaxmin:VI14_128
11142           (match_operand:VI14_128 1 "vector_operand" "%0,0,v")
11143           (match_operand:VI14_128 2 "vector_operand" "YrBm,*xBm,vm")))]
11144   "TARGET_SSE4_1
11145    && <mask_mode512bit_condition>
11146    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11147   "@
11148    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
11149    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
11150    vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11151   [(set_attr "isa" "noavx,noavx,avx")
11152    (set_attr "type" "sseiadd")
11153    (set_attr "prefix_extra" "1,1,*")
11154    (set_attr "prefix" "orig,orig,vex")
11155    (set_attr "mode" "TI")])
11157 (define_insn "*<code>v8hi3"
11158   [(set (match_operand:V8HI 0 "register_operand" "=x,x,v")
11159         (smaxmin:V8HI
11160           (match_operand:V8HI 1 "vector_operand" "%0,x,v")
11161           (match_operand:V8HI 2 "vector_operand" "xBm,xm,vm")))]
11162   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11163   "@
11164    p<maxmin_int>w\t{%2, %0|%0, %2}
11165    vp<maxmin_int>w\t{%2, %1, %0|%0, %1, %2}
11166    vp<maxmin_int>w\t{%2, %1, %0|%0, %1, %2}"
11167   [(set_attr "isa" "noavx,avx,avx512bw")
11168    (set_attr "type" "sseiadd")
11169    (set_attr "prefix_data16" "1,*,*")
11170    (set_attr "prefix_extra" "*,1,1")
11171    (set_attr "prefix" "orig,vex,evex")
11172    (set_attr "mode" "TI")])
11174 (define_expand "<code><mode>3"
11175   [(set (match_operand:VI124_128 0 "register_operand")
11176         (umaxmin:VI124_128
11177           (match_operand:VI124_128 1 "vector_operand")
11178           (match_operand:VI124_128 2 "vector_operand")))]
11179   "TARGET_SSE2"
11181   if (TARGET_SSE4_1 || <MODE>mode == V16QImode)
11182     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
11183   else if (<CODE> == UMAX && <MODE>mode == V8HImode)
11184     {
11185       rtx op0 = operands[0], op2 = operands[2], op3 = op0;
11186       operands[1] = force_reg (<MODE>mode, operands[1]);
11187       if (rtx_equal_p (op3, op2))
11188         op3 = gen_reg_rtx (V8HImode);
11189       emit_insn (gen_sse2_ussubv8hi3 (op3, operands[1], op2));
11190       emit_insn (gen_addv8hi3 (op0, op3, op2));
11191       DONE;
11192     }
11193   else
11194     {
11195       rtx xops[6];
11196       bool ok;
11198       operands[1] = force_reg (<MODE>mode, operands[1]);
11199       operands[2] = force_reg (<MODE>mode, operands[2]);
11201       xops[0] = operands[0];
11203       if (<CODE> == UMAX)
11204         {
11205           xops[1] = operands[1];
11206           xops[2] = operands[2];
11207         }
11208       else
11209         {
11210           xops[1] = operands[2];
11211           xops[2] = operands[1];
11212         }
11214       xops[3] = gen_rtx_GTU (VOIDmode, operands[1], operands[2]);
11215       xops[4] = operands[1];
11216       xops[5] = operands[2];
11218       ok = ix86_expand_int_vcond (xops);
11219       gcc_assert (ok);
11220       DONE;
11221     }
11224 (define_insn "*sse4_1_<code><mode>3<mask_name>"
11225   [(set (match_operand:VI24_128 0 "register_operand" "=Yr,*x,v")
11226         (umaxmin:VI24_128
11227           (match_operand:VI24_128 1 "vector_operand" "%0,0,v")
11228           (match_operand:VI24_128 2 "vector_operand" "YrBm,*xBm,vm")))]
11229   "TARGET_SSE4_1
11230    && <mask_mode512bit_condition>
11231    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11232   "@
11233    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
11234    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
11235    vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11236   [(set_attr "isa" "noavx,noavx,avx")
11237    (set_attr "type" "sseiadd")
11238    (set_attr "prefix_extra" "1,1,*")
11239    (set_attr "prefix" "orig,orig,vex")
11240    (set_attr "mode" "TI")])
11242 (define_insn "*<code>v16qi3"
11243   [(set (match_operand:V16QI 0 "register_operand" "=x,x,v")
11244         (umaxmin:V16QI
11245           (match_operand:V16QI 1 "vector_operand" "%0,x,v")
11246           (match_operand:V16QI 2 "vector_operand" "xBm,xm,vm")))]
11247   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11248   "@
11249    p<maxmin_int>b\t{%2, %0|%0, %2}
11250    vp<maxmin_int>b\t{%2, %1, %0|%0, %1, %2}
11251    vp<maxmin_int>b\t{%2, %1, %0|%0, %1, %2}"
11252   [(set_attr "isa" "noavx,avx,avx512bw")
11253    (set_attr "type" "sseiadd")
11254    (set_attr "prefix_data16" "1,*,*")
11255    (set_attr "prefix_extra" "*,1,1")
11256    (set_attr "prefix" "orig,vex,evex")
11257    (set_attr "mode" "TI")])
11259 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11261 ;; Parallel integral comparisons
11263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11265 (define_expand "avx2_eq<mode>3"
11266   [(set (match_operand:VI_256 0 "register_operand")
11267         (eq:VI_256
11268           (match_operand:VI_256 1 "nonimmediate_operand")
11269           (match_operand:VI_256 2 "nonimmediate_operand")))]
11270   "TARGET_AVX2"
11271   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
11273 (define_insn "*avx2_eq<mode>3"
11274   [(set (match_operand:VI_256 0 "register_operand" "=x")
11275         (eq:VI_256
11276           (match_operand:VI_256 1 "nonimmediate_operand" "%x")
11277           (match_operand:VI_256 2 "nonimmediate_operand" "xm")))]
11278   "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11279   "vpcmpeq<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11280   [(set_attr "type" "ssecmp")
11281    (set_attr "prefix_extra" "1")
11282    (set_attr "prefix" "vex")
11283    (set_attr "mode" "OI")])
11285 (define_expand "<avx512>_eq<mode>3<mask_scalar_merge_name>"
11286   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
11287         (unspec:<avx512fmaskmode>
11288           [(match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
11289            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand")]
11290           UNSPEC_MASKED_EQ))]
11291   "TARGET_AVX512BW"
11292   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
11294 (define_expand "<avx512>_eq<mode>3<mask_scalar_merge_name>"
11295   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
11296         (unspec:<avx512fmaskmode>
11297           [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
11298            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand")]
11299           UNSPEC_MASKED_EQ))]
11300   "TARGET_AVX512F"
11301   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
11303 (define_insn "<avx512>_eq<mode>3<mask_scalar_merge_name>_1"
11304   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk,Yk")
11305         (unspec:<avx512fmaskmode>
11306           [(match_operand:VI12_AVX512VL 1 "vector_move_operand" "%v,v")
11307            (match_operand:VI12_AVX512VL 2 "vector_move_operand" "vm,C")]
11308           UNSPEC_MASKED_EQ))]
11309   "TARGET_AVX512BW && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11310   "@
11311    vpcmpeq<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}
11312    vptestnm<ssemodesuffix>\t{%1, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %1}"
11313   [(set_attr "type" "ssecmp")
11314    (set_attr "prefix_extra" "1")
11315    (set_attr "prefix" "evex")
11316    (set_attr "mode" "<sseinsnmode>")])
11318 (define_insn "<avx512>_eq<mode>3<mask_scalar_merge_name>_1"
11319   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk,Yk")
11320         (unspec:<avx512fmaskmode>
11321           [(match_operand:VI48_AVX512VL 1 "vector_move_operand" "%v,v")
11322            (match_operand:VI48_AVX512VL 2 "vector_move_operand" "vm,C")]
11323           UNSPEC_MASKED_EQ))]
11324   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11325   "@
11326    vpcmpeq<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}
11327    vptestnm<ssemodesuffix>\t{%1, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %1}"
11328   [(set_attr "type" "ssecmp")
11329    (set_attr "prefix_extra" "1")
11330    (set_attr "prefix" "evex")
11331    (set_attr "mode" "<sseinsnmode>")])
11333 (define_insn "*sse4_1_eqv2di3"
11334   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,x")
11335         (eq:V2DI
11336           (match_operand:V2DI 1 "vector_operand" "%0,0,x")
11337           (match_operand:V2DI 2 "vector_operand" "YrBm,*xBm,xm")))]
11338   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11339   "@
11340    pcmpeqq\t{%2, %0|%0, %2}
11341    pcmpeqq\t{%2, %0|%0, %2}
11342    vpcmpeqq\t{%2, %1, %0|%0, %1, %2}"
11343   [(set_attr "isa" "noavx,noavx,avx")
11344    (set_attr "type" "ssecmp")
11345    (set_attr "prefix_extra" "1")
11346    (set_attr "prefix" "orig,orig,vex")
11347    (set_attr "mode" "TI")])
11349 (define_insn "*sse2_eq<mode>3"
11350   [(set (match_operand:VI124_128 0 "register_operand" "=x,x")
11351         (eq:VI124_128
11352           (match_operand:VI124_128 1 "vector_operand" "%0,x")
11353           (match_operand:VI124_128 2 "vector_operand" "xBm,xm")))]
11354   "TARGET_SSE2 && !TARGET_XOP
11355    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11356   "@
11357    pcmpeq<ssemodesuffix>\t{%2, %0|%0, %2}
11358    vpcmpeq<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11359   [(set_attr "isa" "noavx,avx")
11360    (set_attr "type" "ssecmp")
11361    (set_attr "prefix_data16" "1,*")
11362    (set_attr "prefix" "orig,vex")
11363    (set_attr "mode" "TI")])
11365 (define_expand "sse2_eq<mode>3"
11366   [(set (match_operand:VI124_128 0 "register_operand")
11367         (eq:VI124_128
11368           (match_operand:VI124_128 1 "vector_operand")
11369           (match_operand:VI124_128 2 "vector_operand")))]
11370   "TARGET_SSE2 && !TARGET_XOP "
11371   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
11373 (define_expand "sse4_1_eqv2di3"
11374   [(set (match_operand:V2DI 0 "register_operand")
11375         (eq:V2DI
11376           (match_operand:V2DI 1 "vector_operand")
11377           (match_operand:V2DI 2 "vector_operand")))]
11378   "TARGET_SSE4_1"
11379   "ix86_fixup_binary_operands_no_copy (EQ, V2DImode, operands);")
11381 (define_insn "sse4_2_gtv2di3"
11382   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,x")
11383         (gt:V2DI
11384           (match_operand:V2DI 1 "register_operand" "0,0,x")
11385           (match_operand:V2DI 2 "vector_operand" "YrBm,*xBm,xm")))]
11386   "TARGET_SSE4_2"
11387   "@
11388    pcmpgtq\t{%2, %0|%0, %2}
11389    pcmpgtq\t{%2, %0|%0, %2}
11390    vpcmpgtq\t{%2, %1, %0|%0, %1, %2}"
11391   [(set_attr "isa" "noavx,noavx,avx")
11392    (set_attr "type" "ssecmp")
11393    (set_attr "prefix_extra" "1")
11394    (set_attr "prefix" "orig,orig,vex")
11395    (set_attr "mode" "TI")])
11397 (define_insn "avx2_gt<mode>3"
11398   [(set (match_operand:VI_256 0 "register_operand" "=x")
11399         (gt:VI_256
11400           (match_operand:VI_256 1 "register_operand" "x")
11401           (match_operand:VI_256 2 "nonimmediate_operand" "xm")))]
11402   "TARGET_AVX2"
11403   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11404   [(set_attr "type" "ssecmp")
11405    (set_attr "prefix_extra" "1")
11406    (set_attr "prefix" "vex")
11407    (set_attr "mode" "OI")])
11409 (define_insn "<avx512>_gt<mode>3<mask_scalar_merge_name>"
11410   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11411         (unspec:<avx512fmaskmode>
11412           [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
11413            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")] UNSPEC_MASKED_GT))]
11414   "TARGET_AVX512F"
11415   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11416   [(set_attr "type" "ssecmp")
11417    (set_attr "prefix_extra" "1")
11418    (set_attr "prefix" "evex")
11419    (set_attr "mode" "<sseinsnmode>")])
11421 (define_insn "<avx512>_gt<mode>3<mask_scalar_merge_name>"
11422   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11423         (unspec:<avx512fmaskmode>
11424           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
11425            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")] UNSPEC_MASKED_GT))]
11426   "TARGET_AVX512BW"
11427   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11428   [(set_attr "type" "ssecmp")
11429    (set_attr "prefix_extra" "1")
11430    (set_attr "prefix" "evex")
11431    (set_attr "mode" "<sseinsnmode>")])
11433 (define_insn "sse2_gt<mode>3"
11434   [(set (match_operand:VI124_128 0 "register_operand" "=x,x")
11435         (gt:VI124_128
11436           (match_operand:VI124_128 1 "register_operand" "0,x")
11437           (match_operand:VI124_128 2 "vector_operand" "xBm,xm")))]
11438   "TARGET_SSE2 && !TARGET_XOP"
11439   "@
11440    pcmpgt<ssemodesuffix>\t{%2, %0|%0, %2}
11441    vpcmpgt<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11442   [(set_attr "isa" "noavx,avx")
11443    (set_attr "type" "ssecmp")
11444    (set_attr "prefix_data16" "1,*")
11445    (set_attr "prefix" "orig,vex")
11446    (set_attr "mode" "TI")])
11448 (define_expand "vcond<V_512:mode><VI_AVX512BW:mode>"
11449   [(set (match_operand:V_512 0 "register_operand")
11450         (if_then_else:V_512
11451           (match_operator 3 ""
11452             [(match_operand:VI_AVX512BW 4 "nonimmediate_operand")
11453              (match_operand:VI_AVX512BW 5 "general_operand")])
11454           (match_operand:V_512 1)
11455           (match_operand:V_512 2)))]
11456   "TARGET_AVX512F
11457    && (GET_MODE_NUNITS (<V_512:MODE>mode)
11458        == GET_MODE_NUNITS (<VI_AVX512BW:MODE>mode))"
11460   bool ok = ix86_expand_int_vcond (operands);
11461   gcc_assert (ok);
11462   DONE;
11465 (define_expand "vcond<V_256:mode><VI_256:mode>"
11466   [(set (match_operand:V_256 0 "register_operand")
11467         (if_then_else:V_256
11468           (match_operator 3 ""
11469             [(match_operand:VI_256 4 "nonimmediate_operand")
11470              (match_operand:VI_256 5 "general_operand")])
11471           (match_operand:V_256 1)
11472           (match_operand:V_256 2)))]
11473   "TARGET_AVX2
11474    && (GET_MODE_NUNITS (<V_256:MODE>mode)
11475        == GET_MODE_NUNITS (<VI_256:MODE>mode))"
11477   bool ok = ix86_expand_int_vcond (operands);
11478   gcc_assert (ok);
11479   DONE;
11482 (define_expand "vcond<V_128:mode><VI124_128:mode>"
11483   [(set (match_operand:V_128 0 "register_operand")
11484         (if_then_else:V_128
11485           (match_operator 3 ""
11486             [(match_operand:VI124_128 4 "vector_operand")
11487              (match_operand:VI124_128 5 "general_operand")])
11488           (match_operand:V_128 1)
11489           (match_operand:V_128 2)))]
11490   "TARGET_SSE2
11491    && (GET_MODE_NUNITS (<V_128:MODE>mode)
11492        == GET_MODE_NUNITS (<VI124_128:MODE>mode))"
11494   bool ok = ix86_expand_int_vcond (operands);
11495   gcc_assert (ok);
11496   DONE;
11499 (define_expand "vcond<VI8F_128:mode>v2di"
11500   [(set (match_operand:VI8F_128 0 "register_operand")
11501         (if_then_else:VI8F_128
11502           (match_operator 3 ""
11503             [(match_operand:V2DI 4 "vector_operand")
11504              (match_operand:V2DI 5 "general_operand")])
11505           (match_operand:VI8F_128 1)
11506           (match_operand:VI8F_128 2)))]
11507   "TARGET_SSE4_2"
11509   bool ok = ix86_expand_int_vcond (operands);
11510   gcc_assert (ok);
11511   DONE;
11514 (define_expand "vcondu<V_512:mode><VI_AVX512BW:mode>"
11515   [(set (match_operand:V_512 0 "register_operand")
11516         (if_then_else:V_512
11517           (match_operator 3 ""
11518             [(match_operand:VI_AVX512BW 4 "nonimmediate_operand")
11519              (match_operand:VI_AVX512BW 5 "nonimmediate_operand")])
11520           (match_operand:V_512 1 "general_operand")
11521           (match_operand:V_512 2 "general_operand")))]
11522   "TARGET_AVX512F
11523    && (GET_MODE_NUNITS (<V_512:MODE>mode)
11524        == GET_MODE_NUNITS (<VI_AVX512BW:MODE>mode))"
11526   bool ok = ix86_expand_int_vcond (operands);
11527   gcc_assert (ok);
11528   DONE;
11531 (define_expand "vcondu<V_256:mode><VI_256:mode>"
11532   [(set (match_operand:V_256 0 "register_operand")
11533         (if_then_else:V_256
11534           (match_operator 3 ""
11535             [(match_operand:VI_256 4 "nonimmediate_operand")
11536              (match_operand:VI_256 5 "nonimmediate_operand")])
11537           (match_operand:V_256 1 "general_operand")
11538           (match_operand:V_256 2 "general_operand")))]
11539   "TARGET_AVX2
11540    && (GET_MODE_NUNITS (<V_256:MODE>mode)
11541        == GET_MODE_NUNITS (<VI_256:MODE>mode))"
11543   bool ok = ix86_expand_int_vcond (operands);
11544   gcc_assert (ok);
11545   DONE;
11548 (define_expand "vcondu<V_128:mode><VI124_128:mode>"
11549   [(set (match_operand:V_128 0 "register_operand")
11550         (if_then_else:V_128
11551           (match_operator 3 ""
11552             [(match_operand:VI124_128 4 "vector_operand")
11553              (match_operand:VI124_128 5 "vector_operand")])
11554           (match_operand:V_128 1 "general_operand")
11555           (match_operand:V_128 2 "general_operand")))]
11556   "TARGET_SSE2
11557    && (GET_MODE_NUNITS (<V_128:MODE>mode)
11558        == GET_MODE_NUNITS (<VI124_128:MODE>mode))"
11560   bool ok = ix86_expand_int_vcond (operands);
11561   gcc_assert (ok);
11562   DONE;
11565 (define_expand "vcondu<VI8F_128:mode>v2di"
11566   [(set (match_operand:VI8F_128 0 "register_operand")
11567         (if_then_else:VI8F_128
11568           (match_operator 3 ""
11569             [(match_operand:V2DI 4 "vector_operand")
11570              (match_operand:V2DI 5 "vector_operand")])
11571           (match_operand:VI8F_128 1 "general_operand")
11572           (match_operand:VI8F_128 2 "general_operand")))]
11573   "TARGET_SSE4_2"
11575   bool ok = ix86_expand_int_vcond (operands);
11576   gcc_assert (ok);
11577   DONE;
11580 (define_expand "vcondeq<VI8F_128:mode>v2di"
11581   [(set (match_operand:VI8F_128 0 "register_operand")
11582         (if_then_else:VI8F_128
11583           (match_operator 3 ""
11584             [(match_operand:V2DI 4 "vector_operand")
11585              (match_operand:V2DI 5 "general_operand")])
11586           (match_operand:VI8F_128 1)
11587           (match_operand:VI8F_128 2)))]
11588   "TARGET_SSE4_1"
11590   bool ok = ix86_expand_int_vcond (operands);
11591   gcc_assert (ok);
11592   DONE;
11595 (define_mode_iterator VEC_PERM_AVX2
11596   [V16QI V8HI V4SI V2DI V4SF V2DF
11597    (V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
11598    (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")
11599    (V8SF "TARGET_AVX2") (V4DF "TARGET_AVX2")
11600    (V16SF "TARGET_AVX512F") (V8DF "TARGET_AVX512F")
11601    (V16SI "TARGET_AVX512F") (V8DI "TARGET_AVX512F")
11602    (V32HI "TARGET_AVX512BW") (V64QI "TARGET_AVX512VBMI")])
11604 (define_expand "vec_perm<mode>"
11605   [(match_operand:VEC_PERM_AVX2 0 "register_operand")
11606    (match_operand:VEC_PERM_AVX2 1 "register_operand")
11607    (match_operand:VEC_PERM_AVX2 2 "register_operand")
11608    (match_operand:<sseintvecmode> 3 "register_operand")]
11609   "TARGET_SSSE3 || TARGET_AVX || TARGET_XOP"
11611   ix86_expand_vec_perm (operands);
11612   DONE;
11615 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11617 ;; Parallel bitwise logical operations
11619 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11621 (define_expand "one_cmpl<mode>2"
11622   [(set (match_operand:VI 0 "register_operand")
11623         (xor:VI (match_operand:VI 1 "vector_operand")
11624                 (match_dup 2)))]
11625   "TARGET_SSE"
11627   operands[2] = force_reg (<MODE>mode, CONSTM1_RTX (<MODE>mode));
11630 (define_expand "<sse2_avx2>_andnot<mode>3"
11631   [(set (match_operand:VI_AVX2 0 "register_operand")
11632         (and:VI_AVX2
11633           (not:VI_AVX2 (match_operand:VI_AVX2 1 "register_operand"))
11634           (match_operand:VI_AVX2 2 "vector_operand")))]
11635   "TARGET_SSE2")
11637 (define_expand "<sse2_avx2>_andnot<mode>3_mask"
11638   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
11639         (vec_merge:VI48_AVX512VL
11640           (and:VI48_AVX512VL
11641             (not:VI48_AVX512VL
11642               (match_operand:VI48_AVX512VL 1 "register_operand"))
11643             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
11644           (match_operand:VI48_AVX512VL 3 "vector_move_operand")
11645           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
11646   "TARGET_AVX512F")
11648 (define_expand "<sse2_avx2>_andnot<mode>3_mask"
11649   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
11650         (vec_merge:VI12_AVX512VL
11651           (and:VI12_AVX512VL
11652             (not:VI12_AVX512VL
11653               (match_operand:VI12_AVX512VL 1 "register_operand"))
11654             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand"))
11655           (match_operand:VI12_AVX512VL 3 "vector_move_operand")
11656           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
11657   "TARGET_AVX512BW")
11659 (define_insn "*andnot<mode>3"
11660   [(set (match_operand:VI 0 "register_operand" "=x,x,v")
11661         (and:VI
11662           (not:VI (match_operand:VI 1 "register_operand" "0,x,v"))
11663           (match_operand:VI 2 "vector_operand" "xBm,xm,vm")))]
11664   "TARGET_SSE"
11666   static char buf[64];
11667   const char *ops;
11668   const char *tmp;
11669   const char *ssesuffix;
11671   switch (get_attr_mode (insn))
11672     {
11673     case MODE_XI:
11674       gcc_assert (TARGET_AVX512F);
11675       /* FALLTHRU */
11676     case MODE_OI:
11677       gcc_assert (TARGET_AVX2);
11678       /* FALLTHRU */
11679     case MODE_TI:
11680       gcc_assert (TARGET_SSE2);
11681       tmp = "pandn";
11682       switch (<MODE>mode)
11683         {
11684         case E_V64QImode:
11685         case E_V32HImode:
11686           /* There is no vpandnb or vpandnw instruction, nor vpandn for
11687              512-bit vectors. Use vpandnq instead.  */
11688           ssesuffix = "q";
11689           break;
11690         case E_V16SImode:
11691         case E_V8DImode:
11692           ssesuffix = "<ssemodesuffix>";
11693           break;
11694         case E_V8SImode:
11695         case E_V4DImode:
11696         case E_V4SImode:
11697         case E_V2DImode:
11698           ssesuffix = (TARGET_AVX512VL && which_alternative == 2
11699                        ? "<ssemodesuffix>" : "");
11700           break;
11701         default:
11702           ssesuffix = TARGET_AVX512VL && which_alternative == 2 ? "q" : "";
11703         }
11704       break;
11706     case MODE_V16SF:
11707       gcc_assert (TARGET_AVX512F);
11708       /* FALLTHRU */
11709     case MODE_V8SF:
11710       gcc_assert (TARGET_AVX);
11711       /* FALLTHRU */
11712     case MODE_V4SF:
11713       gcc_assert (TARGET_SSE);
11714       tmp = "andn";
11715       ssesuffix = "ps";
11716       break;
11718     default:
11719       gcc_unreachable ();
11720     }
11722   switch (which_alternative)
11723     {
11724     case 0:
11725       ops = "%s%s\t{%%2, %%0|%%0, %%2}";
11726       break;
11727     case 1:
11728     case 2:
11729       ops = "v%s%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
11730       break;
11731     default:
11732       gcc_unreachable ();
11733     }
11735   snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
11736   return buf;
11738   [(set_attr "isa" "noavx,avx,avx")
11739    (set_attr "type" "sselog")
11740    (set (attr "prefix_data16")
11741      (if_then_else
11742        (and (eq_attr "alternative" "0")
11743             (eq_attr "mode" "TI"))
11744        (const_string "1")
11745        (const_string "*")))
11746    (set_attr "prefix" "orig,vex,evex")
11747    (set (attr "mode")
11748         (cond [(and (match_test "<MODE_SIZE> == 16")
11749                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
11750                  (const_string "<ssePSmode>")
11751                (match_test "TARGET_AVX2")
11752                  (const_string "<sseinsnmode>")
11753                (match_test "TARGET_AVX")
11754                  (if_then_else
11755                    (match_test "<MODE_SIZE> > 16")
11756                    (const_string "V8SF")
11757                    (const_string "<sseinsnmode>"))
11758                (ior (not (match_test "TARGET_SSE2"))
11759                     (match_test "optimize_function_for_size_p (cfun)"))
11760                  (const_string "V4SF")
11761               ]
11762               (const_string "<sseinsnmode>")))])
11764 (define_insn "*andnot<mode>3_mask"
11765   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
11766         (vec_merge:VI48_AVX512VL
11767           (and:VI48_AVX512VL
11768             (not:VI48_AVX512VL
11769               (match_operand:VI48_AVX512VL 1 "register_operand" "v"))
11770             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm"))
11771           (match_operand:VI48_AVX512VL 3 "vector_move_operand" "0C")
11772           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
11773   "TARGET_AVX512F"
11774   "vpandn<ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}";
11775   [(set_attr "type" "sselog")
11776    (set_attr "prefix" "evex")
11777    (set_attr "mode" "<sseinsnmode>")])
11779 (define_expand "<code><mode>3"
11780   [(set (match_operand:VI 0 "register_operand")
11781         (any_logic:VI
11782           (match_operand:VI 1 "nonimmediate_or_const_vector_operand")
11783           (match_operand:VI 2 "nonimmediate_or_const_vector_operand")))]
11784   "TARGET_SSE"
11786   ix86_expand_vector_logical_operator (<CODE>, <MODE>mode, operands);
11787   DONE;
11790 (define_insn "<mask_codefor><code><mode>3<mask_name>"
11791   [(set (match_operand:VI48_AVX_AVX512F 0 "register_operand" "=x,x,v")
11792         (any_logic:VI48_AVX_AVX512F
11793           (match_operand:VI48_AVX_AVX512F 1 "vector_operand" "%0,x,v")
11794           (match_operand:VI48_AVX_AVX512F 2 "vector_operand" "xBm,xm,vm")))]
11795   "TARGET_SSE && <mask_mode512bit_condition>
11796    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11798   static char buf[64];
11799   const char *ops;
11800   const char *tmp;
11801   const char *ssesuffix;
11803   switch (get_attr_mode (insn))
11804     {
11805     case MODE_XI:
11806       gcc_assert (TARGET_AVX512F);
11807       /* FALLTHRU */
11808     case MODE_OI:
11809       gcc_assert (TARGET_AVX2);
11810       /* FALLTHRU */
11811     case MODE_TI:
11812       gcc_assert (TARGET_SSE2);
11813       tmp = "p<logic>";
11814       switch (<MODE>mode)
11815         {
11816         case E_V16SImode:
11817         case E_V8DImode:
11818           ssesuffix = "<ssemodesuffix>";
11819           break;
11820         case E_V8SImode:
11821         case E_V4DImode:
11822         case E_V4SImode:
11823         case E_V2DImode:
11824           ssesuffix = (TARGET_AVX512VL
11825                        && (<mask_applied> || which_alternative == 2)
11826                        ? "<ssemodesuffix>" : "");
11827           break;
11828         default:
11829           gcc_unreachable ();
11830         }
11831       break;
11833     case MODE_V8SF:
11834       gcc_assert (TARGET_AVX);
11835       /* FALLTHRU */
11836     case MODE_V4SF:
11837       gcc_assert (TARGET_SSE);
11838       tmp = "<logic>";
11839       ssesuffix = "ps";
11840       break;
11842     default:
11843       gcc_unreachable ();
11844     }
11846   switch (which_alternative)
11847     {
11848     case 0:
11849       if (<mask_applied>)
11850         ops = "v%s%s\t{%%2, %%0, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%0, %%2}";
11851       else
11852         ops = "%s%s\t{%%2, %%0|%%0, %%2}";
11853       break;
11854     case 1:
11855     case 2:
11856       ops = "v%s%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
11857       break;
11858     default:
11859       gcc_unreachable ();
11860     }
11862   snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
11863   return buf;
11865   [(set_attr "isa" "noavx,avx,avx")
11866    (set_attr "type" "sselog")
11867    (set (attr "prefix_data16")
11868      (if_then_else
11869        (and (eq_attr "alternative" "0")
11870             (eq_attr "mode" "TI"))
11871        (const_string "1")
11872        (const_string "*")))
11873    (set_attr "prefix" "<mask_prefix3>,evex")
11874    (set (attr "mode")
11875         (cond [(and (match_test "<MODE_SIZE> == 16")
11876                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
11877                  (const_string "<ssePSmode>")
11878                (match_test "TARGET_AVX2")
11879                  (const_string "<sseinsnmode>")
11880                (match_test "TARGET_AVX")
11881                  (if_then_else
11882                    (match_test "<MODE_SIZE> > 16")
11883                    (const_string "V8SF")
11884                    (const_string "<sseinsnmode>"))
11885                (ior (not (match_test "TARGET_SSE2"))
11886                     (match_test "optimize_function_for_size_p (cfun)"))
11887                  (const_string "V4SF")
11888               ]
11889               (const_string "<sseinsnmode>")))])
11891 (define_insn "*<code><mode>3"
11892   [(set (match_operand:VI12_AVX_AVX512F 0 "register_operand" "=x,x,v")
11893         (any_logic:VI12_AVX_AVX512F
11894           (match_operand:VI12_AVX_AVX512F 1 "vector_operand" "%0,x,v")
11895           (match_operand:VI12_AVX_AVX512F 2 "vector_operand" "xBm,xm,vm")))]
11896   "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11898   static char buf[64];
11899   const char *ops;
11900   const char *tmp;
11901   const char *ssesuffix;
11903   switch (get_attr_mode (insn))
11904     {
11905     case MODE_XI:
11906       gcc_assert (TARGET_AVX512F);
11907       /* FALLTHRU */
11908     case MODE_OI:
11909       gcc_assert (TARGET_AVX2);
11910       /* FALLTHRU */
11911     case MODE_TI:
11912       gcc_assert (TARGET_SSE2);
11913       tmp = "p<logic>";
11914       switch (<MODE>mode)
11915         {
11916         case E_V64QImode:
11917         case E_V32HImode:
11918           ssesuffix = "q";
11919           break;
11920         case E_V32QImode:
11921         case E_V16HImode:
11922         case E_V16QImode:
11923         case E_V8HImode:
11924           ssesuffix = TARGET_AVX512VL && which_alternative == 2 ? "q" : "";
11925           break;
11926         default:
11927           gcc_unreachable ();
11928         }
11929       break;
11931     case MODE_V8SF:
11932       gcc_assert (TARGET_AVX);
11933       /* FALLTHRU */
11934     case MODE_V4SF:
11935       gcc_assert (TARGET_SSE);
11936       tmp = "<logic>";
11937       ssesuffix = "ps";
11938       break;
11940     default:
11941       gcc_unreachable ();
11942     }
11944   switch (which_alternative)
11945     {
11946     case 0:
11947       ops = "%s%s\t{%%2, %%0|%%0, %%2}";
11948       break;
11949     case 1:
11950     case 2:
11951       ops = "v%s%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
11952       break;
11953     default:
11954       gcc_unreachable ();
11955     }
11957   snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
11958   return buf;
11960   [(set_attr "isa" "noavx,avx,avx")
11961    (set_attr "type" "sselog")
11962    (set (attr "prefix_data16")
11963      (if_then_else
11964        (and (eq_attr "alternative" "0")
11965             (eq_attr "mode" "TI"))
11966        (const_string "1")
11967        (const_string "*")))
11968    (set_attr "prefix" "orig,vex,evex")
11969    (set (attr "mode")
11970         (cond [(and (match_test "<MODE_SIZE> == 16")
11971                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
11972                  (const_string "<ssePSmode>")
11973                (match_test "TARGET_AVX2")
11974                  (const_string "<sseinsnmode>")
11975                (match_test "TARGET_AVX")
11976                  (if_then_else
11977                    (match_test "<MODE_SIZE> > 16")
11978                    (const_string "V8SF")
11979                    (const_string "<sseinsnmode>"))
11980                (ior (not (match_test "TARGET_SSE2"))
11981                     (match_test "optimize_function_for_size_p (cfun)"))
11982                  (const_string "V4SF")
11983               ]
11984               (const_string "<sseinsnmode>")))])
11986 (define_insn "<avx512>_testm<mode>3<mask_scalar_merge_name>"
11987   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11988         (unspec:<avx512fmaskmode>
11989          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
11990           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")]
11991          UNSPEC_TESTM))]
11992   "TARGET_AVX512BW"
11993   "vptestm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11994   [(set_attr "prefix" "evex")
11995    (set_attr "mode"  "<sseinsnmode>")])
11997 (define_insn "<avx512>_testm<mode>3<mask_scalar_merge_name>"
11998   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11999         (unspec:<avx512fmaskmode>
12000          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
12001           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")]
12002          UNSPEC_TESTM))]
12003   "TARGET_AVX512F"
12004   "vptestm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
12005   [(set_attr "prefix" "evex")
12006    (set_attr "mode"  "<sseinsnmode>")])
12008 (define_insn "<avx512>_testnm<mode>3<mask_scalar_merge_name>"
12009   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
12010         (unspec:<avx512fmaskmode>
12011          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
12012           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")]
12013          UNSPEC_TESTNM))]
12014   "TARGET_AVX512BW"
12015   "vptestnm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
12016   [(set_attr "prefix" "evex")
12017    (set_attr "mode"  "<sseinsnmode>")])
12019 (define_insn "<avx512>_testnm<mode>3<mask_scalar_merge_name>"
12020   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
12021         (unspec:<avx512fmaskmode>
12022          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
12023           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")]
12024          UNSPEC_TESTNM))]
12025   "TARGET_AVX512F"
12026   "vptestnm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
12027   [(set_attr "prefix" "evex")
12028    (set_attr "mode"  "<sseinsnmode>")])
12030 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12032 ;; Parallel integral element swizzling
12034 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12036 (define_expand "vec_pack_trunc_<mode>"
12037   [(match_operand:<ssepackmode> 0 "register_operand")
12038    (match_operand:VI248_AVX2_8_AVX512F_24_AVX512BW 1 "register_operand")
12039    (match_operand:VI248_AVX2_8_AVX512F_24_AVX512BW 2 "register_operand")]
12040   "TARGET_SSE2"
12042   rtx op1 = gen_lowpart (<ssepackmode>mode, operands[1]);
12043   rtx op2 = gen_lowpart (<ssepackmode>mode, operands[2]);
12044   ix86_expand_vec_extract_even_odd (operands[0], op1, op2, 0);
12045   DONE;
12048 (define_expand "vec_pack_trunc_qi"
12049   [(set (match_operand:HI 0 ("register_operand"))
12050         (ior:HI (ashift:HI (zero_extend:HI (match_operand:QI 2 ("register_operand")))
12051                            (const_int 8))
12052                 (zero_extend:HI (match_operand:QI 1 ("register_operand")))))]
12053   "TARGET_AVX512F")
12055 (define_expand "vec_pack_trunc_<mode>"
12056   [(set (match_operand:<DOUBLEMASKMODE> 0 ("register_operand"))
12057         (ior:<DOUBLEMASKMODE> (ashift:<DOUBLEMASKMODE> (zero_extend:<DOUBLEMASKMODE> (match_operand:SWI24 2 ("register_operand")))
12058                            (match_dup 3))
12059                 (zero_extend:<DOUBLEMASKMODE> (match_operand:SWI24 1 ("register_operand")))))]
12060   "TARGET_AVX512BW"
12062   operands[3] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
12065 (define_insn "<sse2_avx2>_packsswb<mask_name>"
12066   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x,v")
12067         (vec_concat:VI1_AVX512
12068           (ss_truncate:<ssehalfvecmode>
12069             (match_operand:<sseunpackmode> 1 "register_operand" "0,x,v"))
12070           (ss_truncate:<ssehalfvecmode>
12071             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,xm,vm"))))]
12072   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
12073   "@
12074    packsswb\t{%2, %0|%0, %2}
12075    vpacksswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
12076    vpacksswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12077   [(set_attr "isa" "noavx,avx,avx512bw")
12078    (set_attr "type" "sselog")
12079    (set_attr "prefix_data16" "1,*,*")
12080    (set_attr "prefix" "orig,<mask_prefix>,evex")
12081    (set_attr "mode" "<sseinsnmode>")])
12083 (define_insn "<sse2_avx2>_packssdw<mask_name>"
12084   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,x,v")
12085         (vec_concat:VI2_AVX2
12086           (ss_truncate:<ssehalfvecmode>
12087             (match_operand:<sseunpackmode> 1 "register_operand" "0,x,v"))
12088           (ss_truncate:<ssehalfvecmode>
12089             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,xm,vm"))))]
12090   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
12091   "@
12092    packssdw\t{%2, %0|%0, %2}
12093    vpackssdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
12094    vpackssdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12095   [(set_attr "isa" "noavx,avx,avx512bw")
12096    (set_attr "type" "sselog")
12097    (set_attr "prefix_data16" "1,*,*")
12098    (set_attr "prefix" "orig,<mask_prefix>,evex")
12099    (set_attr "mode" "<sseinsnmode>")])
12101 (define_insn "<sse2_avx2>_packuswb<mask_name>"
12102   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x,v")
12103         (vec_concat:VI1_AVX512
12104           (us_truncate:<ssehalfvecmode>
12105             (match_operand:<sseunpackmode> 1 "register_operand" "0,x,v"))
12106           (us_truncate:<ssehalfvecmode>
12107             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,xm,vm"))))]
12108   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
12109   "@
12110    packuswb\t{%2, %0|%0, %2}
12111    vpackuswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
12112    vpackuswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12113   [(set_attr "isa" "noavx,avx,avx512bw")
12114    (set_attr "type" "sselog")
12115    (set_attr "prefix_data16" "1,*,*")
12116    (set_attr "prefix" "orig,<mask_prefix>,evex")
12117    (set_attr "mode" "<sseinsnmode>")])
12119 (define_insn "avx512bw_interleave_highv64qi<mask_name>"
12120   [(set (match_operand:V64QI 0 "register_operand" "=v")
12121         (vec_select:V64QI
12122           (vec_concat:V128QI
12123             (match_operand:V64QI 1 "register_operand" "v")
12124             (match_operand:V64QI 2 "nonimmediate_operand" "vm"))
12125           (parallel [(const_int 8)  (const_int 72)
12126                      (const_int 9)  (const_int 73)
12127                      (const_int 10) (const_int 74)
12128                      (const_int 11) (const_int 75)
12129                      (const_int 12) (const_int 76)
12130                      (const_int 13) (const_int 77)
12131                      (const_int 14) (const_int 78)
12132                      (const_int 15) (const_int 79)
12133                      (const_int 24) (const_int 88)
12134                      (const_int 25) (const_int 89)
12135                      (const_int 26) (const_int 90)
12136                      (const_int 27) (const_int 91)
12137                      (const_int 28) (const_int 92)
12138                      (const_int 29) (const_int 93)
12139                      (const_int 30) (const_int 94)
12140                      (const_int 31) (const_int 95)
12141                      (const_int 40) (const_int 104)
12142                      (const_int 41) (const_int 105)
12143                      (const_int 42) (const_int 106)
12144                      (const_int 43) (const_int 107)
12145                      (const_int 44) (const_int 108)
12146                      (const_int 45) (const_int 109)
12147                      (const_int 46) (const_int 110)
12148                      (const_int 47) (const_int 111)
12149                      (const_int 56) (const_int 120)
12150                      (const_int 57) (const_int 121)
12151                      (const_int 58) (const_int 122)
12152                      (const_int 59) (const_int 123)
12153                      (const_int 60) (const_int 124)
12154                      (const_int 61) (const_int 125)
12155                      (const_int 62) (const_int 126)
12156                      (const_int 63) (const_int 127)])))]
12157   "TARGET_AVX512BW"
12158   "vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12159   [(set_attr "type" "sselog")
12160    (set_attr "prefix" "evex")
12161    (set_attr "mode" "XI")])
12163 (define_insn "avx2_interleave_highv32qi<mask_name>"
12164   [(set (match_operand:V32QI 0 "register_operand" "=v")
12165         (vec_select:V32QI
12166           (vec_concat:V64QI
12167             (match_operand:V32QI 1 "register_operand" "v")
12168             (match_operand:V32QI 2 "nonimmediate_operand" "vm"))
12169           (parallel [(const_int 8)  (const_int 40)
12170                      (const_int 9)  (const_int 41)
12171                      (const_int 10) (const_int 42)
12172                      (const_int 11) (const_int 43)
12173                      (const_int 12) (const_int 44)
12174                      (const_int 13) (const_int 45)
12175                      (const_int 14) (const_int 46)
12176                      (const_int 15) (const_int 47)
12177                      (const_int 24) (const_int 56)
12178                      (const_int 25) (const_int 57)
12179                      (const_int 26) (const_int 58)
12180                      (const_int 27) (const_int 59)
12181                      (const_int 28) (const_int 60)
12182                      (const_int 29) (const_int 61)
12183                      (const_int 30) (const_int 62)
12184                      (const_int 31) (const_int 63)])))]
12185   "TARGET_AVX2 && <mask_avx512vl_condition>"
12186   "vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12187   [(set_attr "type" "sselog")
12188    (set_attr "prefix" "<mask_prefix>")
12189    (set_attr "mode" "OI")])
12191 (define_insn "vec_interleave_highv16qi<mask_name>"
12192   [(set (match_operand:V16QI 0 "register_operand" "=x,v")
12193         (vec_select:V16QI
12194           (vec_concat:V32QI
12195             (match_operand:V16QI 1 "register_operand" "0,v")
12196             (match_operand:V16QI 2 "vector_operand" "xBm,vm"))
12197           (parallel [(const_int 8)  (const_int 24)
12198                      (const_int 9)  (const_int 25)
12199                      (const_int 10) (const_int 26)
12200                      (const_int 11) (const_int 27)
12201                      (const_int 12) (const_int 28)
12202                      (const_int 13) (const_int 29)
12203                      (const_int 14) (const_int 30)
12204                      (const_int 15) (const_int 31)])))]
12205   "TARGET_SSE2 && <mask_avx512vl_condition>"
12206   "@
12207    punpckhbw\t{%2, %0|%0, %2}
12208    vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12209   [(set_attr "isa" "noavx,avx")
12210    (set_attr "type" "sselog")
12211    (set_attr "prefix_data16" "1,*")
12212    (set_attr "prefix" "orig,<mask_prefix>")
12213    (set_attr "mode" "TI")])
12215 (define_insn "avx512bw_interleave_lowv64qi<mask_name>"
12216   [(set (match_operand:V64QI 0 "register_operand" "=v")
12217         (vec_select:V64QI
12218           (vec_concat:V128QI
12219             (match_operand:V64QI 1 "register_operand" "v")
12220             (match_operand:V64QI 2 "nonimmediate_operand" "vm"))
12221           (parallel [(const_int 0) (const_int 64)
12222                      (const_int 1) (const_int 65)
12223                      (const_int 2) (const_int 66)
12224                      (const_int 3) (const_int 67)
12225                      (const_int 4) (const_int 68)
12226                      (const_int 5) (const_int 69)
12227                      (const_int 6) (const_int 70)
12228                      (const_int 7) (const_int 71)
12229                      (const_int 16) (const_int 80)
12230                      (const_int 17) (const_int 81)
12231                      (const_int 18) (const_int 82)
12232                      (const_int 19) (const_int 83)
12233                      (const_int 20) (const_int 84)
12234                      (const_int 21) (const_int 85)
12235                      (const_int 22) (const_int 86)
12236                      (const_int 23) (const_int 87)
12237                      (const_int 32) (const_int 96)
12238                      (const_int 33) (const_int 97)
12239                      (const_int 34) (const_int 98)
12240                      (const_int 35) (const_int 99)
12241                      (const_int 36) (const_int 100)
12242                      (const_int 37) (const_int 101)
12243                      (const_int 38) (const_int 102)
12244                      (const_int 39) (const_int 103)
12245                      (const_int 48) (const_int 112)
12246                      (const_int 49) (const_int 113)
12247                      (const_int 50) (const_int 114)
12248                      (const_int 51) (const_int 115)
12249                      (const_int 52) (const_int 116)
12250                      (const_int 53) (const_int 117)
12251                      (const_int 54) (const_int 118)
12252                      (const_int 55) (const_int 119)])))]
12253   "TARGET_AVX512BW"
12254   "vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12255   [(set_attr "type" "sselog")
12256    (set_attr "prefix" "evex")
12257    (set_attr "mode" "XI")])
12259 (define_insn "avx2_interleave_lowv32qi<mask_name>"
12260   [(set (match_operand:V32QI 0 "register_operand" "=v")
12261         (vec_select:V32QI
12262           (vec_concat:V64QI
12263             (match_operand:V32QI 1 "register_operand" "v")
12264             (match_operand:V32QI 2 "nonimmediate_operand" "vm"))
12265           (parallel [(const_int 0) (const_int 32)
12266                      (const_int 1) (const_int 33)
12267                      (const_int 2) (const_int 34)
12268                      (const_int 3) (const_int 35)
12269                      (const_int 4) (const_int 36)
12270                      (const_int 5) (const_int 37)
12271                      (const_int 6) (const_int 38)
12272                      (const_int 7) (const_int 39)
12273                      (const_int 16) (const_int 48)
12274                      (const_int 17) (const_int 49)
12275                      (const_int 18) (const_int 50)
12276                      (const_int 19) (const_int 51)
12277                      (const_int 20) (const_int 52)
12278                      (const_int 21) (const_int 53)
12279                      (const_int 22) (const_int 54)
12280                      (const_int 23) (const_int 55)])))]
12281   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12282   "vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12283   [(set_attr "type" "sselog")
12284    (set_attr "prefix" "maybe_vex")
12285    (set_attr "mode" "OI")])
12287 (define_insn "vec_interleave_lowv16qi<mask_name>"
12288   [(set (match_operand:V16QI 0 "register_operand" "=x,v")
12289         (vec_select:V16QI
12290           (vec_concat:V32QI
12291             (match_operand:V16QI 1 "register_operand" "0,v")
12292             (match_operand:V16QI 2 "vector_operand" "xBm,vm"))
12293           (parallel [(const_int 0) (const_int 16)
12294                      (const_int 1) (const_int 17)
12295                      (const_int 2) (const_int 18)
12296                      (const_int 3) (const_int 19)
12297                      (const_int 4) (const_int 20)
12298                      (const_int 5) (const_int 21)
12299                      (const_int 6) (const_int 22)
12300                      (const_int 7) (const_int 23)])))]
12301   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12302   "@
12303    punpcklbw\t{%2, %0|%0, %2}
12304    vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12305   [(set_attr "isa" "noavx,avx")
12306    (set_attr "type" "sselog")
12307    (set_attr "prefix_data16" "1,*")
12308    (set_attr "prefix" "orig,vex")
12309    (set_attr "mode" "TI")])
12311 (define_insn "avx512bw_interleave_highv32hi<mask_name>"
12312   [(set (match_operand:V32HI 0 "register_operand" "=v")
12313         (vec_select:V32HI
12314           (vec_concat:V64HI
12315             (match_operand:V32HI 1 "register_operand" "v")
12316             (match_operand:V32HI 2 "nonimmediate_operand" "vm"))
12317           (parallel [(const_int 4) (const_int 36)
12318                      (const_int 5) (const_int 37)
12319                      (const_int 6) (const_int 38)
12320                      (const_int 7) (const_int 39)
12321                      (const_int 12) (const_int 44)
12322                      (const_int 13) (const_int 45)
12323                      (const_int 14) (const_int 46)
12324                      (const_int 15) (const_int 47)
12325                      (const_int 20) (const_int 52)
12326                      (const_int 21) (const_int 53)
12327                      (const_int 22) (const_int 54)
12328                      (const_int 23) (const_int 55)
12329                      (const_int 28) (const_int 60)
12330                      (const_int 29) (const_int 61)
12331                      (const_int 30) (const_int 62)
12332                      (const_int 31) (const_int 63)])))]
12333   "TARGET_AVX512BW"
12334   "vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12335   [(set_attr "type" "sselog")
12336    (set_attr "prefix" "evex")
12337    (set_attr "mode" "XI")])
12339 (define_insn "avx2_interleave_highv16hi<mask_name>"
12340   [(set (match_operand:V16HI 0 "register_operand" "=v")
12341         (vec_select:V16HI
12342           (vec_concat:V32HI
12343             (match_operand:V16HI 1 "register_operand" "v")
12344             (match_operand:V16HI 2 "nonimmediate_operand" "vm"))
12345           (parallel [(const_int 4) (const_int 20)
12346                      (const_int 5) (const_int 21)
12347                      (const_int 6) (const_int 22)
12348                      (const_int 7) (const_int 23)
12349                      (const_int 12) (const_int 28)
12350                      (const_int 13) (const_int 29)
12351                      (const_int 14) (const_int 30)
12352                      (const_int 15) (const_int 31)])))]
12353   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12354   "vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12355   [(set_attr "type" "sselog")
12356    (set_attr "prefix" "maybe_evex")
12357    (set_attr "mode" "OI")])
12359 (define_insn "vec_interleave_highv8hi<mask_name>"
12360   [(set (match_operand:V8HI 0 "register_operand" "=x,v")
12361         (vec_select:V8HI
12362           (vec_concat:V16HI
12363             (match_operand:V8HI 1 "register_operand" "0,v")
12364             (match_operand:V8HI 2 "vector_operand" "xBm,vm"))
12365           (parallel [(const_int 4) (const_int 12)
12366                      (const_int 5) (const_int 13)
12367                      (const_int 6) (const_int 14)
12368                      (const_int 7) (const_int 15)])))]
12369   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12370   "@
12371    punpckhwd\t{%2, %0|%0, %2}
12372    vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12373   [(set_attr "isa" "noavx,avx")
12374    (set_attr "type" "sselog")
12375    (set_attr "prefix_data16" "1,*")
12376    (set_attr "prefix" "orig,maybe_vex")
12377    (set_attr "mode" "TI")])
12379 (define_insn "<mask_codefor>avx512bw_interleave_lowv32hi<mask_name>"
12380   [(set (match_operand:V32HI 0 "register_operand" "=v")
12381         (vec_select:V32HI
12382           (vec_concat:V64HI
12383             (match_operand:V32HI 1 "register_operand" "v")
12384             (match_operand:V32HI 2 "nonimmediate_operand" "vm"))
12385           (parallel [(const_int 0) (const_int 32)
12386                      (const_int 1) (const_int 33)
12387                      (const_int 2) (const_int 34)
12388                      (const_int 3) (const_int 35)
12389                      (const_int 8) (const_int 40)
12390                      (const_int 9) (const_int 41)
12391                      (const_int 10) (const_int 42)
12392                      (const_int 11) (const_int 43)
12393                      (const_int 16) (const_int 48)
12394                      (const_int 17) (const_int 49)
12395                      (const_int 18) (const_int 50)
12396                      (const_int 19) (const_int 51)
12397                      (const_int 24) (const_int 56)
12398                      (const_int 25) (const_int 57)
12399                      (const_int 26) (const_int 58)
12400                      (const_int 27) (const_int 59)])))]
12401   "TARGET_AVX512BW"
12402   "vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12403   [(set_attr "type" "sselog")
12404    (set_attr "prefix" "evex")
12405    (set_attr "mode" "XI")])
12407 (define_insn "avx2_interleave_lowv16hi<mask_name>"
12408   [(set (match_operand:V16HI 0 "register_operand" "=v")
12409         (vec_select:V16HI
12410           (vec_concat:V32HI
12411             (match_operand:V16HI 1 "register_operand" "v")
12412             (match_operand:V16HI 2 "nonimmediate_operand" "vm"))
12413           (parallel [(const_int 0) (const_int 16)
12414                      (const_int 1) (const_int 17)
12415                      (const_int 2) (const_int 18)
12416                      (const_int 3) (const_int 19)
12417                      (const_int 8) (const_int 24)
12418                      (const_int 9) (const_int 25)
12419                      (const_int 10) (const_int 26)
12420                      (const_int 11) (const_int 27)])))]
12421   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12422   "vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12423   [(set_attr "type" "sselog")
12424    (set_attr "prefix" "maybe_evex")
12425    (set_attr "mode" "OI")])
12427 (define_insn "vec_interleave_lowv8hi<mask_name>"
12428   [(set (match_operand:V8HI 0 "register_operand" "=x,v")
12429         (vec_select:V8HI
12430           (vec_concat:V16HI
12431             (match_operand:V8HI 1 "register_operand" "0,v")
12432             (match_operand:V8HI 2 "vector_operand" "xBm,vm"))
12433           (parallel [(const_int 0) (const_int 8)
12434                      (const_int 1) (const_int 9)
12435                      (const_int 2) (const_int 10)
12436                      (const_int 3) (const_int 11)])))]
12437   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12438   "@
12439    punpcklwd\t{%2, %0|%0, %2}
12440    vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12441   [(set_attr "isa" "noavx,avx")
12442    (set_attr "type" "sselog")
12443    (set_attr "prefix_data16" "1,*")
12444    (set_attr "prefix" "orig,maybe_evex")
12445    (set_attr "mode" "TI")])
12447 (define_insn "avx2_interleave_highv8si<mask_name>"
12448   [(set (match_operand:V8SI 0 "register_operand" "=v")
12449         (vec_select:V8SI
12450           (vec_concat:V16SI
12451             (match_operand:V8SI 1 "register_operand" "v")
12452             (match_operand:V8SI 2 "nonimmediate_operand" "vm"))
12453           (parallel [(const_int 2) (const_int 10)
12454                      (const_int 3) (const_int 11)
12455                      (const_int 6) (const_int 14)
12456                      (const_int 7) (const_int 15)])))]
12457   "TARGET_AVX2 && <mask_avx512vl_condition>"
12458   "vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12459   [(set_attr "type" "sselog")
12460    (set_attr "prefix" "maybe_evex")
12461    (set_attr "mode" "OI")])
12463 (define_insn "<mask_codefor>avx512f_interleave_highv16si<mask_name>"
12464   [(set (match_operand:V16SI 0 "register_operand" "=v")
12465         (vec_select:V16SI
12466           (vec_concat:V32SI
12467             (match_operand:V16SI 1 "register_operand" "v")
12468             (match_operand:V16SI 2 "nonimmediate_operand" "vm"))
12469           (parallel [(const_int 2) (const_int 18)
12470                      (const_int 3) (const_int 19)
12471                      (const_int 6) (const_int 22)
12472                      (const_int 7) (const_int 23)
12473                      (const_int 10) (const_int 26)
12474                      (const_int 11) (const_int 27)
12475                      (const_int 14) (const_int 30)
12476                      (const_int 15) (const_int 31)])))]
12477   "TARGET_AVX512F"
12478   "vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12479   [(set_attr "type" "sselog")
12480    (set_attr "prefix" "evex")
12481    (set_attr "mode" "XI")])
12484 (define_insn "vec_interleave_highv4si<mask_name>"
12485   [(set (match_operand:V4SI 0 "register_operand" "=x,v")
12486         (vec_select:V4SI
12487           (vec_concat:V8SI
12488             (match_operand:V4SI 1 "register_operand" "0,v")
12489             (match_operand:V4SI 2 "vector_operand" "xBm,vm"))
12490           (parallel [(const_int 2) (const_int 6)
12491                      (const_int 3) (const_int 7)])))]
12492   "TARGET_SSE2 && <mask_avx512vl_condition>"
12493   "@
12494    punpckhdq\t{%2, %0|%0, %2}
12495    vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12496   [(set_attr "isa" "noavx,avx")
12497    (set_attr "type" "sselog")
12498    (set_attr "prefix_data16" "1,*")
12499    (set_attr "prefix" "orig,maybe_vex")
12500    (set_attr "mode" "TI")])
12502 (define_insn "avx2_interleave_lowv8si<mask_name>"
12503   [(set (match_operand:V8SI 0 "register_operand" "=v")
12504         (vec_select:V8SI
12505           (vec_concat:V16SI
12506             (match_operand:V8SI 1 "register_operand" "v")
12507             (match_operand:V8SI 2 "nonimmediate_operand" "vm"))
12508           (parallel [(const_int 0) (const_int 8)
12509                      (const_int 1) (const_int 9)
12510                      (const_int 4) (const_int 12)
12511                      (const_int 5) (const_int 13)])))]
12512   "TARGET_AVX2 && <mask_avx512vl_condition>"
12513   "vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12514   [(set_attr "type" "sselog")
12515    (set_attr "prefix" "maybe_evex")
12516    (set_attr "mode" "OI")])
12518 (define_insn "<mask_codefor>avx512f_interleave_lowv16si<mask_name>"
12519   [(set (match_operand:V16SI 0 "register_operand" "=v")
12520         (vec_select:V16SI
12521           (vec_concat:V32SI
12522             (match_operand:V16SI 1 "register_operand" "v")
12523             (match_operand:V16SI 2 "nonimmediate_operand" "vm"))
12524           (parallel [(const_int 0) (const_int 16)
12525                      (const_int 1) (const_int 17)
12526                      (const_int 4) (const_int 20)
12527                      (const_int 5) (const_int 21)
12528                      (const_int 8) (const_int 24)
12529                      (const_int 9) (const_int 25)
12530                      (const_int 12) (const_int 28)
12531                      (const_int 13) (const_int 29)])))]
12532   "TARGET_AVX512F"
12533   "vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12534   [(set_attr "type" "sselog")
12535    (set_attr "prefix" "evex")
12536    (set_attr "mode" "XI")])
12538 (define_insn "vec_interleave_lowv4si<mask_name>"
12539   [(set (match_operand:V4SI 0 "register_operand" "=x,v")
12540         (vec_select:V4SI
12541           (vec_concat:V8SI
12542             (match_operand:V4SI 1 "register_operand" "0,v")
12543             (match_operand:V4SI 2 "vector_operand" "xBm,vm"))
12544           (parallel [(const_int 0) (const_int 4)
12545                      (const_int 1) (const_int 5)])))]
12546   "TARGET_SSE2 && <mask_avx512vl_condition>"
12547   "@
12548    punpckldq\t{%2, %0|%0, %2}
12549    vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12550   [(set_attr "isa" "noavx,avx")
12551    (set_attr "type" "sselog")
12552    (set_attr "prefix_data16" "1,*")
12553    (set_attr "prefix" "orig,vex")
12554    (set_attr "mode" "TI")])
12556 (define_expand "vec_interleave_high<mode>"
12557   [(match_operand:VI_256 0 "register_operand")
12558    (match_operand:VI_256 1 "register_operand")
12559    (match_operand:VI_256 2 "nonimmediate_operand")]
12560  "TARGET_AVX2"
12562   rtx t1 = gen_reg_rtx (<MODE>mode);
12563   rtx t2 = gen_reg_rtx (<MODE>mode);
12564   rtx t3 = gen_reg_rtx (V4DImode);
12565   emit_insn (gen_avx2_interleave_low<mode> (t1, operands[1], operands[2]));
12566   emit_insn (gen_avx2_interleave_high<mode> (t2,  operands[1], operands[2]));
12567   emit_insn (gen_avx2_permv2ti (t3, gen_lowpart (V4DImode, t1),
12568                                 gen_lowpart (V4DImode, t2),
12569                                 GEN_INT (1 + (3 << 4))));
12570   emit_move_insn (operands[0], gen_lowpart (<MODE>mode, t3));
12571   DONE;
12574 (define_expand "vec_interleave_low<mode>"
12575   [(match_operand:VI_256 0 "register_operand")
12576    (match_operand:VI_256 1 "register_operand")
12577    (match_operand:VI_256 2 "nonimmediate_operand")]
12578  "TARGET_AVX2"
12580   rtx t1 = gen_reg_rtx (<MODE>mode);
12581   rtx t2 = gen_reg_rtx (<MODE>mode);
12582   rtx t3 = gen_reg_rtx (V4DImode);
12583   emit_insn (gen_avx2_interleave_low<mode> (t1, operands[1], operands[2]));
12584   emit_insn (gen_avx2_interleave_high<mode> (t2, operands[1], operands[2]));
12585   emit_insn (gen_avx2_permv2ti (t3, gen_lowpart (V4DImode, t1),
12586                                 gen_lowpart (V4DImode, t2),
12587                                 GEN_INT (0 + (2 << 4))));
12588   emit_move_insn (operands[0], gen_lowpart (<MODE>mode, t3));
12589   DONE;
12592 ;; Modes handled by pinsr patterns.
12593 (define_mode_iterator PINSR_MODE
12594   [(V16QI "TARGET_SSE4_1") V8HI
12595    (V4SI "TARGET_SSE4_1")
12596    (V2DI "TARGET_SSE4_1 && TARGET_64BIT")])
12598 (define_mode_attr sse2p4_1
12599   [(V16QI "sse4_1") (V8HI "sse2")
12600    (V4SI "sse4_1") (V2DI "sse4_1")])
12602 (define_mode_attr pinsr_evex_isa
12603   [(V16QI "avx512bw") (V8HI "avx512bw")
12604    (V4SI "avx512dq") (V2DI "avx512dq")])
12606 ;; sse4_1_pinsrd must come before sse2_loadld since it is preferred.
12607 (define_insn "<sse2p4_1>_pinsr<ssemodesuffix>"
12608   [(set (match_operand:PINSR_MODE 0 "register_operand" "=x,x,x,x,v,v")
12609         (vec_merge:PINSR_MODE
12610           (vec_duplicate:PINSR_MODE
12611             (match_operand:<ssescalarmode> 2 "nonimmediate_operand" "r,m,r,m,r,m"))
12612           (match_operand:PINSR_MODE 1 "register_operand" "0,0,x,x,v,v")
12613           (match_operand:SI 3 "const_int_operand")))]
12614   "TARGET_SSE2
12615    && ((unsigned) exact_log2 (INTVAL (operands[3]))
12616        < GET_MODE_NUNITS (<MODE>mode))"
12618   operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])));
12620   switch (which_alternative)
12621     {
12622     case 0:
12623       if (GET_MODE_SIZE (<ssescalarmode>mode) < GET_MODE_SIZE (SImode))
12624         return "pinsr<ssemodesuffix>\t{%3, %k2, %0|%0, %k2, %3}";
12625       /* FALLTHRU */
12626     case 1:
12627       return "pinsr<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}";
12628     case 2:
12629     case 4:
12630       if (GET_MODE_SIZE (<ssescalarmode>mode) < GET_MODE_SIZE (SImode))
12631         return "vpinsr<ssemodesuffix>\t{%3, %k2, %1, %0|%0, %1, %k2, %3}";
12632       /* FALLTHRU */
12633     case 3:
12634     case 5:
12635       return "vpinsr<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
12636     default:
12637       gcc_unreachable ();
12638     }
12640   [(set_attr "isa" "noavx,noavx,avx,avx,<pinsr_evex_isa>,<pinsr_evex_isa>")
12641    (set_attr "type" "sselog")
12642    (set (attr "prefix_rex")
12643      (if_then_else
12644        (and (not (match_test "TARGET_AVX"))
12645             (eq (const_string "<MODE>mode") (const_string "V2DImode")))
12646        (const_string "1")
12647        (const_string "*")))
12648    (set (attr "prefix_data16")
12649      (if_then_else
12650        (and (not (match_test "TARGET_AVX"))
12651             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
12652        (const_string "1")
12653        (const_string "*")))
12654    (set (attr "prefix_extra")
12655      (if_then_else
12656        (and (not (match_test "TARGET_AVX"))
12657             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
12658        (const_string "*")
12659        (const_string "1")))
12660    (set_attr "length_immediate" "1")
12661    (set_attr "prefix" "orig,orig,vex,vex,evex,evex")
12662    (set_attr "mode" "TI")])
12664 (define_expand "<extract_type>_vinsert<shuffletype><extract_suf>_mask"
12665   [(match_operand:AVX512_VEC 0 "register_operand")
12666    (match_operand:AVX512_VEC 1 "register_operand")
12667    (match_operand:<ssequartermode> 2 "nonimmediate_operand")
12668    (match_operand:SI 3 "const_0_to_3_operand")
12669    (match_operand:AVX512_VEC 4 "register_operand")
12670    (match_operand:<avx512fmaskmode> 5 "register_operand")]
12671   "TARGET_AVX512F"
12673   int mask, selector;
12674   mask = INTVAL (operands[3]);
12675   selector = (GET_MODE_UNIT_SIZE (<MODE>mode) == 4
12676               ? 0xFFFF ^ (0x000F << mask * 4)
12677               : 0xFF ^ (0x03 << mask * 2));
12678   emit_insn (gen_<extract_type>_vinsert<shuffletype><extract_suf>_1_mask
12679     (operands[0], operands[1], operands[2], GEN_INT (selector),
12680      operands[4], operands[5]));
12681   DONE;
12684 (define_insn "*<extract_type>_vinsert<shuffletype><extract_suf>_0"
12685   [(set (match_operand:AVX512_VEC 0 "register_operand" "=v,x,Yv")
12686         (vec_merge:AVX512_VEC
12687           (match_operand:AVX512_VEC 1 "reg_or_0_operand" "v,C,C")
12688           (vec_duplicate:AVX512_VEC
12689                 (match_operand:<ssequartermode> 2 "nonimmediate_operand" "vm,xm,vm"))
12690           (match_operand:SI 3 "const_int_operand" "n,n,n")))]
12691   "TARGET_AVX512F
12692    && (INTVAL (operands[3])
12693        == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xFFF0 : 0xFC))"
12695   if (which_alternative == 0)
12696     return "vinsert<shuffletype><extract_suf>\t{$0, %2, %1, %0|%0, %1, %2, 0}";
12697   switch (<MODE>mode)
12698     {
12699     case E_V8DFmode:
12700       return "vmovapd\t{%2, %x0|%x0, %2}";
12701     case E_V16SFmode:
12702       return "vmovaps\t{%2, %x0|%x0, %2}";
12703     case E_V8DImode:
12704       return which_alternative == 2 ? "vmovdqa64\t{%2, %x0|%x0, %2}"
12705                                     : "vmovdqa\t{%2, %x0|%x0, %2}";
12706     case E_V16SImode:
12707       return which_alternative == 2 ? "vmovdqa32\t{%2, %x0|%x0, %2}"
12708                                     : "vmovdqa\t{%2, %x0|%x0, %2}";
12709     default:
12710       gcc_unreachable ();
12711     }
12713   [(set_attr "type" "sselog,ssemov,ssemov")
12714    (set_attr "length_immediate" "1,0,0")
12715    (set_attr "prefix" "evex,vex,evex")
12716    (set_attr "mode" "<sseinsnmode>,<ssequarterinsnmode>,<ssequarterinsnmode>")])
12718 (define_insn "<mask_codefor><extract_type>_vinsert<shuffletype><extract_suf>_1<mask_name>"
12719   [(set (match_operand:AVX512_VEC 0 "register_operand" "=v")
12720         (vec_merge:AVX512_VEC
12721           (match_operand:AVX512_VEC 1 "register_operand" "v")
12722           (vec_duplicate:AVX512_VEC
12723                 (match_operand:<ssequartermode> 2 "nonimmediate_operand" "vm"))
12724           (match_operand:SI 3 "const_int_operand" "n")))]
12725   "TARGET_AVX512F"
12727   int mask;
12728   int selector = INTVAL (operands[3]);
12730   if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xFFF0 : 0xFC))
12731     mask = 0;
12732   else if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xFF0F : 0xF3))
12733     mask = 1;
12734   else if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xF0FF : 0xCF))
12735     mask = 2;
12736   else if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0x0FFF : 0x3F))
12737     mask = 3;
12738   else
12739     gcc_unreachable ();
12741   operands[3] = GEN_INT (mask);
12743   return "vinsert<shuffletype><extract_suf>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}";
12745   [(set_attr "type" "sselog")
12746    (set_attr "length_immediate" "1")
12747    (set_attr "prefix" "evex")
12748    (set_attr "mode" "<sseinsnmode>")])
12750 (define_expand "<extract_type_2>_vinsert<shuffletype><extract_suf_2>_mask"
12751   [(match_operand:AVX512_VEC_2 0 "register_operand")
12752    (match_operand:AVX512_VEC_2 1 "register_operand")
12753    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
12754    (match_operand:SI 3 "const_0_to_1_operand")
12755    (match_operand:AVX512_VEC_2 4 "register_operand")
12756    (match_operand:<avx512fmaskmode> 5 "register_operand")]
12757   "TARGET_AVX512F"
12759   int mask = INTVAL (operands[3]);
12760   if (mask == 0)
12761     emit_insn (gen_vec_set_lo_<mode>_mask (operands[0], operands[1],
12762                                            operands[2], operands[4],
12763                                            operands[5]));
12764   else
12765     emit_insn (gen_vec_set_hi_<mode>_mask (operands[0], operands[1],
12766                                            operands[2], operands[4],
12767                                            operands[5]));
12768   DONE;
12771 (define_insn "vec_set_lo_<mode><mask_name>"
12772   [(set (match_operand:V16FI 0 "register_operand" "=v")
12773         (vec_concat:V16FI
12774           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
12775           (vec_select:<ssehalfvecmode>
12776             (match_operand:V16FI 1 "register_operand" "v")
12777             (parallel [(const_int 8) (const_int 9)
12778                        (const_int 10) (const_int 11)
12779                        (const_int 12) (const_int 13)
12780                        (const_int 14) (const_int 15)]))))]
12781   "TARGET_AVX512DQ"
12782   "vinsert<shuffletype>32x8\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}"
12783   [(set_attr "type" "sselog")
12784    (set_attr "length_immediate" "1")
12785    (set_attr "prefix" "evex")
12786    (set_attr "mode" "<sseinsnmode>")])
12788 (define_insn "vec_set_hi_<mode><mask_name>"
12789   [(set (match_operand:V16FI 0 "register_operand" "=v")
12790         (vec_concat:V16FI
12791           (vec_select:<ssehalfvecmode>
12792             (match_operand:V16FI 1 "register_operand" "v")
12793             (parallel [(const_int 0) (const_int 1)
12794                        (const_int 2) (const_int 3)
12795                        (const_int 4) (const_int 5)
12796                        (const_int 6) (const_int 7)]))
12797           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
12798   "TARGET_AVX512DQ"
12799   "vinsert<shuffletype>32x8\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}"
12800   [(set_attr "type" "sselog")
12801    (set_attr "length_immediate" "1")
12802    (set_attr "prefix" "evex")
12803    (set_attr "mode" "<sseinsnmode>")])
12805 (define_insn "vec_set_lo_<mode><mask_name>"
12806   [(set (match_operand:V8FI 0 "register_operand" "=v")
12807         (vec_concat:V8FI
12808           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
12809           (vec_select:<ssehalfvecmode>
12810             (match_operand:V8FI 1 "register_operand" "v")
12811             (parallel [(const_int 4) (const_int 5)
12812                        (const_int 6) (const_int 7)]))))]
12813   "TARGET_AVX512F"
12814   "vinsert<shuffletype>64x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}"
12815   [(set_attr "type" "sselog")
12816    (set_attr "length_immediate" "1")
12817    (set_attr "prefix" "evex")
12818    (set_attr "mode" "XI")])
12820 (define_insn "vec_set_hi_<mode><mask_name>"
12821   [(set (match_operand:V8FI 0 "register_operand" "=v")
12822         (vec_concat:V8FI
12823           (vec_select:<ssehalfvecmode>
12824             (match_operand:V8FI 1 "register_operand" "v")
12825             (parallel [(const_int 0) (const_int 1)
12826                        (const_int 2) (const_int 3)]))
12827           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
12828   "TARGET_AVX512F"
12829   "vinsert<shuffletype>64x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}"
12830   [(set_attr "type" "sselog")
12831    (set_attr "length_immediate" "1")
12832    (set_attr "prefix" "evex")
12833    (set_attr "mode" "XI")])
12835 (define_expand "avx512dq_shuf_<shuffletype>64x2_mask"
12836   [(match_operand:VI8F_256 0 "register_operand")
12837    (match_operand:VI8F_256 1 "register_operand")
12838    (match_operand:VI8F_256 2 "nonimmediate_operand")
12839    (match_operand:SI 3 "const_0_to_3_operand")
12840    (match_operand:VI8F_256 4 "register_operand")
12841    (match_operand:QI 5 "register_operand")]
12842   "TARGET_AVX512DQ"
12844   int mask = INTVAL (operands[3]);
12845   emit_insn (gen_avx512dq_shuf_<shuffletype>64x2_1_mask
12846       (operands[0], operands[1], operands[2],
12847        GEN_INT (((mask >> 0) & 1) * 2 + 0),
12848        GEN_INT (((mask >> 0) & 1) * 2 + 1),
12849        GEN_INT (((mask >> 1) & 1) * 2 + 4),
12850        GEN_INT (((mask >> 1) & 1) * 2 + 5),
12851        operands[4], operands[5]));
12852   DONE;
12855 (define_insn "<mask_codefor>avx512dq_shuf_<shuffletype>64x2_1<mask_name>"
12856   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
12857         (vec_select:VI8F_256
12858           (vec_concat:<ssedoublemode>
12859             (match_operand:VI8F_256 1 "register_operand" "v")
12860             (match_operand:VI8F_256 2 "nonimmediate_operand" "vm"))
12861           (parallel [(match_operand 3  "const_0_to_3_operand")
12862                      (match_operand 4  "const_0_to_3_operand")
12863                      (match_operand 5  "const_4_to_7_operand")
12864                      (match_operand 6  "const_4_to_7_operand")])))]
12865   "TARGET_AVX512VL
12866    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12867        && INTVAL (operands[5]) == (INTVAL (operands[6]) - 1))"
12869   int mask;
12870   mask = INTVAL (operands[3]) / 2;
12871   mask |= (INTVAL (operands[5]) - 4) / 2 << 1;
12872   operands[3] = GEN_INT (mask);
12873   return "vshuf<shuffletype>64x2\t{%3, %2, %1, %0<mask_operand7>|%0<mask_operand7>, %1, %2, %3}";
12875   [(set_attr "type" "sselog")
12876    (set_attr "length_immediate" "1")
12877    (set_attr "prefix" "evex")
12878    (set_attr "mode" "XI")])
12880 (define_expand "avx512f_shuf_<shuffletype>64x2_mask"
12881   [(match_operand:V8FI 0 "register_operand")
12882    (match_operand:V8FI 1 "register_operand")
12883    (match_operand:V8FI 2 "nonimmediate_operand")
12884    (match_operand:SI 3 "const_0_to_255_operand")
12885    (match_operand:V8FI 4 "register_operand")
12886    (match_operand:QI 5 "register_operand")]
12887   "TARGET_AVX512F"
12889   int mask = INTVAL (operands[3]);
12890   emit_insn (gen_avx512f_shuf_<shuffletype>64x2_1_mask
12891       (operands[0], operands[1], operands[2],
12892        GEN_INT (((mask >> 0) & 3) * 2),
12893        GEN_INT (((mask >> 0) & 3) * 2 + 1),
12894        GEN_INT (((mask >> 2) & 3) * 2),
12895        GEN_INT (((mask >> 2) & 3) * 2 + 1),
12896        GEN_INT (((mask >> 4) & 3) * 2 + 8),
12897        GEN_INT (((mask >> 4) & 3) * 2 + 9),
12898        GEN_INT (((mask >> 6) & 3) * 2 + 8),
12899        GEN_INT (((mask >> 6) & 3) * 2 + 9),
12900        operands[4], operands[5]));
12901   DONE;
12904 (define_insn "avx512f_shuf_<shuffletype>64x2_1<mask_name>"
12905   [(set (match_operand:V8FI 0 "register_operand" "=v")
12906         (vec_select:V8FI
12907           (vec_concat:<ssedoublemode>
12908             (match_operand:V8FI 1 "register_operand" "v")
12909             (match_operand:V8FI 2 "nonimmediate_operand" "vm"))
12910           (parallel [(match_operand 3  "const_0_to_7_operand")
12911                      (match_operand 4  "const_0_to_7_operand")
12912                      (match_operand 5  "const_0_to_7_operand")
12913                      (match_operand 6  "const_0_to_7_operand")
12914                      (match_operand 7  "const_8_to_15_operand")
12915                      (match_operand 8  "const_8_to_15_operand")
12916                      (match_operand 9  "const_8_to_15_operand")
12917                      (match_operand 10  "const_8_to_15_operand")])))]
12918   "TARGET_AVX512F
12919    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12920        && INTVAL (operands[5]) == (INTVAL (operands[6]) - 1)
12921        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
12922        && INTVAL (operands[9]) == (INTVAL (operands[10]) - 1))"
12924   int mask;
12925   mask = INTVAL (operands[3]) / 2;
12926   mask |= INTVAL (operands[5]) / 2 << 2;
12927   mask |= (INTVAL (operands[7]) - 8) / 2 << 4;
12928   mask |= (INTVAL (operands[9]) - 8) / 2 << 6;
12929   operands[3] = GEN_INT (mask);
12931   return "vshuf<shuffletype>64x2\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
12933   [(set_attr "type" "sselog")
12934    (set_attr "length_immediate" "1")
12935    (set_attr "prefix" "evex")
12936    (set_attr "mode" "<sseinsnmode>")])
12938 (define_expand "avx512vl_shuf_<shuffletype>32x4_mask"
12939   [(match_operand:VI4F_256 0 "register_operand")
12940    (match_operand:VI4F_256 1 "register_operand")
12941    (match_operand:VI4F_256 2 "nonimmediate_operand")
12942    (match_operand:SI 3 "const_0_to_3_operand")
12943    (match_operand:VI4F_256 4 "register_operand")
12944    (match_operand:QI 5 "register_operand")]
12945   "TARGET_AVX512VL"
12947   int mask = INTVAL (operands[3]);
12948   emit_insn (gen_avx512vl_shuf_<shuffletype>32x4_1_mask
12949       (operands[0], operands[1], operands[2],
12950        GEN_INT (((mask >> 0) & 1) * 4 + 0),
12951        GEN_INT (((mask >> 0) & 1) * 4 + 1),
12952        GEN_INT (((mask >> 0) & 1) * 4 + 2),
12953        GEN_INT (((mask >> 0) & 1) * 4 + 3),
12954        GEN_INT (((mask >> 1) & 1) * 4 + 8),
12955        GEN_INT (((mask >> 1) & 1) * 4 + 9),
12956        GEN_INT (((mask >> 1) & 1) * 4 + 10),
12957        GEN_INT (((mask >> 1) & 1) * 4 + 11),
12958        operands[4], operands[5]));
12959   DONE;
12962 (define_insn "avx512vl_shuf_<shuffletype>32x4_1<mask_name>"
12963   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
12964         (vec_select:VI4F_256
12965           (vec_concat:<ssedoublemode>
12966             (match_operand:VI4F_256 1 "register_operand" "v")
12967             (match_operand:VI4F_256 2 "nonimmediate_operand" "vm"))
12968           (parallel [(match_operand 3  "const_0_to_7_operand")
12969                      (match_operand 4  "const_0_to_7_operand")
12970                      (match_operand 5  "const_0_to_7_operand")
12971                      (match_operand 6  "const_0_to_7_operand")
12972                      (match_operand 7  "const_8_to_15_operand")
12973                      (match_operand 8  "const_8_to_15_operand")
12974                      (match_operand 9  "const_8_to_15_operand")
12975                      (match_operand 10 "const_8_to_15_operand")])))]
12976   "TARGET_AVX512VL
12977    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12978        && INTVAL (operands[3]) == (INTVAL (operands[5]) - 2)
12979        && INTVAL (operands[3]) == (INTVAL (operands[6]) - 3)
12980        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
12981        && INTVAL (operands[7]) == (INTVAL (operands[9]) - 2)
12982        && INTVAL (operands[7]) == (INTVAL (operands[10]) - 3))"
12984   int mask;
12985   mask = INTVAL (operands[3]) / 4;
12986   mask |= (INTVAL (operands[7]) - 8) / 4 << 1;
12987   operands[3] = GEN_INT (mask);
12989   return "vshuf<shuffletype>32x4\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
12991   [(set_attr "type" "sselog")
12992    (set_attr "length_immediate" "1")
12993    (set_attr "prefix" "evex")
12994    (set_attr "mode" "<sseinsnmode>")])
12996 (define_expand "avx512f_shuf_<shuffletype>32x4_mask"
12997   [(match_operand:V16FI 0 "register_operand")
12998    (match_operand:V16FI 1 "register_operand")
12999    (match_operand:V16FI 2 "nonimmediate_operand")
13000    (match_operand:SI 3 "const_0_to_255_operand")
13001    (match_operand:V16FI 4 "register_operand")
13002    (match_operand:HI 5 "register_operand")]
13003   "TARGET_AVX512F"
13005   int mask = INTVAL (operands[3]);
13006   emit_insn (gen_avx512f_shuf_<shuffletype>32x4_1_mask
13007       (operands[0], operands[1], operands[2],
13008        GEN_INT (((mask >> 0) & 3) * 4),
13009        GEN_INT (((mask >> 0) & 3) * 4 + 1),
13010        GEN_INT (((mask >> 0) & 3) * 4 + 2),
13011        GEN_INT (((mask >> 0) & 3) * 4 + 3),
13012        GEN_INT (((mask >> 2) & 3) * 4),
13013        GEN_INT (((mask >> 2) & 3) * 4 + 1),
13014        GEN_INT (((mask >> 2) & 3) * 4 + 2),
13015        GEN_INT (((mask >> 2) & 3) * 4 + 3),
13016        GEN_INT (((mask >> 4) & 3) * 4 + 16),
13017        GEN_INT (((mask >> 4) & 3) * 4 + 17),
13018        GEN_INT (((mask >> 4) & 3) * 4 + 18),
13019        GEN_INT (((mask >> 4) & 3) * 4 + 19),
13020        GEN_INT (((mask >> 6) & 3) * 4 + 16),
13021        GEN_INT (((mask >> 6) & 3) * 4 + 17),
13022        GEN_INT (((mask >> 6) & 3) * 4 + 18),
13023        GEN_INT (((mask >> 6) & 3) * 4 + 19),
13024        operands[4], operands[5]));
13025   DONE;
13028 (define_insn "avx512f_shuf_<shuffletype>32x4_1<mask_name>"
13029   [(set (match_operand:V16FI 0 "register_operand" "=v")
13030         (vec_select:V16FI
13031           (vec_concat:<ssedoublemode>
13032             (match_operand:V16FI 1 "register_operand" "v")
13033             (match_operand:V16FI 2 "nonimmediate_operand" "vm"))
13034           (parallel [(match_operand 3  "const_0_to_15_operand")
13035                      (match_operand 4  "const_0_to_15_operand")
13036                      (match_operand 5  "const_0_to_15_operand")
13037                      (match_operand 6  "const_0_to_15_operand")
13038                      (match_operand 7  "const_0_to_15_operand")
13039                      (match_operand 8  "const_0_to_15_operand")
13040                      (match_operand 9  "const_0_to_15_operand")
13041                      (match_operand 10  "const_0_to_15_operand")
13042                      (match_operand 11  "const_16_to_31_operand")
13043                      (match_operand 12  "const_16_to_31_operand")
13044                      (match_operand 13  "const_16_to_31_operand")
13045                      (match_operand 14  "const_16_to_31_operand")
13046                      (match_operand 15  "const_16_to_31_operand")
13047                      (match_operand 16  "const_16_to_31_operand")
13048                      (match_operand 17  "const_16_to_31_operand")
13049                      (match_operand 18  "const_16_to_31_operand")])))]
13050   "TARGET_AVX512F
13051    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
13052        && INTVAL (operands[3]) == (INTVAL (operands[5]) - 2)
13053        && INTVAL (operands[3]) == (INTVAL (operands[6]) - 3)
13054        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
13055        && INTVAL (operands[7]) == (INTVAL (operands[9]) - 2)
13056        && INTVAL (operands[7]) == (INTVAL (operands[10]) - 3)
13057        && INTVAL (operands[11]) == (INTVAL (operands[12]) - 1)
13058        && INTVAL (operands[11]) == (INTVAL (operands[13]) - 2)
13059        && INTVAL (operands[11]) == (INTVAL (operands[14]) - 3)
13060        && INTVAL (operands[15]) == (INTVAL (operands[16]) - 1)
13061        && INTVAL (operands[15]) == (INTVAL (operands[17]) - 2)
13062        && INTVAL (operands[15]) == (INTVAL (operands[18]) - 3))"
13064   int mask;
13065   mask = INTVAL (operands[3]) / 4;
13066   mask |= INTVAL (operands[7]) / 4 << 2;
13067   mask |= (INTVAL (operands[11]) - 16) / 4 << 4;
13068   mask |= (INTVAL (operands[15]) - 16) / 4 << 6;
13069   operands[3] = GEN_INT (mask);
13071   return "vshuf<shuffletype>32x4\t{%3, %2, %1, %0<mask_operand19>|%0<mask_operand19>, %1, %2, %3}";
13073   [(set_attr "type" "sselog")
13074    (set_attr "length_immediate" "1")
13075    (set_attr "prefix" "evex")
13076    (set_attr "mode" "<sseinsnmode>")])
13078 (define_expand "avx512f_pshufdv3_mask"
13079   [(match_operand:V16SI 0 "register_operand")
13080    (match_operand:V16SI 1 "nonimmediate_operand")
13081    (match_operand:SI 2 "const_0_to_255_operand")
13082    (match_operand:V16SI 3 "register_operand")
13083    (match_operand:HI 4 "register_operand")]
13084   "TARGET_AVX512F"
13086   int mask = INTVAL (operands[2]);
13087   emit_insn (gen_avx512f_pshufd_1_mask (operands[0], operands[1],
13088                                        GEN_INT ((mask >> 0) & 3),
13089                                        GEN_INT ((mask >> 2) & 3),
13090                                        GEN_INT ((mask >> 4) & 3),
13091                                        GEN_INT ((mask >> 6) & 3),
13092                                        GEN_INT (((mask >> 0) & 3) + 4),
13093                                        GEN_INT (((mask >> 2) & 3) + 4),
13094                                        GEN_INT (((mask >> 4) & 3) + 4),
13095                                        GEN_INT (((mask >> 6) & 3) + 4),
13096                                        GEN_INT (((mask >> 0) & 3) + 8),
13097                                        GEN_INT (((mask >> 2) & 3) + 8),
13098                                        GEN_INT (((mask >> 4) & 3) + 8),
13099                                        GEN_INT (((mask >> 6) & 3) + 8),
13100                                        GEN_INT (((mask >> 0) & 3) + 12),
13101                                        GEN_INT (((mask >> 2) & 3) + 12),
13102                                        GEN_INT (((mask >> 4) & 3) + 12),
13103                                        GEN_INT (((mask >> 6) & 3) + 12),
13104                                        operands[3], operands[4]));
13105   DONE;
13108 (define_insn "avx512f_pshufd_1<mask_name>"
13109   [(set (match_operand:V16SI 0 "register_operand" "=v")
13110         (vec_select:V16SI
13111           (match_operand:V16SI 1 "nonimmediate_operand" "vm")
13112           (parallel [(match_operand 2 "const_0_to_3_operand")
13113                      (match_operand 3 "const_0_to_3_operand")
13114                      (match_operand 4 "const_0_to_3_operand")
13115                      (match_operand 5 "const_0_to_3_operand")
13116                      (match_operand 6 "const_4_to_7_operand")
13117                      (match_operand 7 "const_4_to_7_operand")
13118                      (match_operand 8 "const_4_to_7_operand")
13119                      (match_operand 9 "const_4_to_7_operand")
13120                      (match_operand 10 "const_8_to_11_operand")
13121                      (match_operand 11 "const_8_to_11_operand")
13122                      (match_operand 12 "const_8_to_11_operand")
13123                      (match_operand 13 "const_8_to_11_operand")
13124                      (match_operand 14 "const_12_to_15_operand")
13125                      (match_operand 15 "const_12_to_15_operand")
13126                      (match_operand 16 "const_12_to_15_operand")
13127                      (match_operand 17 "const_12_to_15_operand")])))]
13128   "TARGET_AVX512F
13129    && INTVAL (operands[2]) + 4 == INTVAL (operands[6])
13130    && INTVAL (operands[3]) + 4 == INTVAL (operands[7])
13131    && INTVAL (operands[4]) + 4 == INTVAL (operands[8])
13132    && INTVAL (operands[5]) + 4 == INTVAL (operands[9])
13133    && INTVAL (operands[2]) + 8 == INTVAL (operands[10])
13134    && INTVAL (operands[3]) + 8 == INTVAL (operands[11])
13135    && INTVAL (operands[4]) + 8 == INTVAL (operands[12])
13136    && INTVAL (operands[5]) + 8 == INTVAL (operands[13])
13137    && INTVAL (operands[2]) + 12 == INTVAL (operands[14])
13138    && INTVAL (operands[3]) + 12 == INTVAL (operands[15])
13139    && INTVAL (operands[4]) + 12 == INTVAL (operands[16])
13140    && INTVAL (operands[5]) + 12 == INTVAL (operands[17])"
13142   int mask = 0;
13143   mask |= INTVAL (operands[2]) << 0;
13144   mask |= INTVAL (operands[3]) << 2;
13145   mask |= INTVAL (operands[4]) << 4;
13146   mask |= INTVAL (operands[5]) << 6;
13147   operands[2] = GEN_INT (mask);
13149   return "vpshufd\t{%2, %1, %0<mask_operand18>|%0<mask_operand18>, %1, %2}";
13151   [(set_attr "type" "sselog1")
13152    (set_attr "prefix" "evex")
13153    (set_attr "length_immediate" "1")
13154    (set_attr "mode" "XI")])
13156 (define_expand "avx512vl_pshufdv3_mask"
13157   [(match_operand:V8SI 0 "register_operand")
13158    (match_operand:V8SI 1 "nonimmediate_operand")
13159    (match_operand:SI 2 "const_0_to_255_operand")
13160    (match_operand:V8SI 3 "register_operand")
13161    (match_operand:QI 4 "register_operand")]
13162   "TARGET_AVX512VL"
13164   int mask = INTVAL (operands[2]);
13165   emit_insn (gen_avx2_pshufd_1_mask (operands[0], operands[1],
13166                                 GEN_INT ((mask >> 0) & 3),
13167                                 GEN_INT ((mask >> 2) & 3),
13168                                 GEN_INT ((mask >> 4) & 3),
13169                                 GEN_INT ((mask >> 6) & 3),
13170                                 GEN_INT (((mask >> 0) & 3) + 4),
13171                                 GEN_INT (((mask >> 2) & 3) + 4),
13172                                 GEN_INT (((mask >> 4) & 3) + 4),
13173                                 GEN_INT (((mask >> 6) & 3) + 4),
13174                 operands[3], operands[4]));
13175   DONE;
13178 (define_expand "avx2_pshufdv3"
13179   [(match_operand:V8SI 0 "register_operand")
13180    (match_operand:V8SI 1 "nonimmediate_operand")
13181    (match_operand:SI 2 "const_0_to_255_operand")]
13182   "TARGET_AVX2"
13184   int mask = INTVAL (operands[2]);
13185   emit_insn (gen_avx2_pshufd_1 (operands[0], operands[1],
13186                                 GEN_INT ((mask >> 0) & 3),
13187                                 GEN_INT ((mask >> 2) & 3),
13188                                 GEN_INT ((mask >> 4) & 3),
13189                                 GEN_INT ((mask >> 6) & 3),
13190                                 GEN_INT (((mask >> 0) & 3) + 4),
13191                                 GEN_INT (((mask >> 2) & 3) + 4),
13192                                 GEN_INT (((mask >> 4) & 3) + 4),
13193                                 GEN_INT (((mask >> 6) & 3) + 4)));
13194   DONE;
13197 (define_insn "avx2_pshufd_1<mask_name>"
13198   [(set (match_operand:V8SI 0 "register_operand" "=v")
13199         (vec_select:V8SI
13200           (match_operand:V8SI 1 "nonimmediate_operand" "vm")
13201           (parallel [(match_operand 2 "const_0_to_3_operand")
13202                      (match_operand 3 "const_0_to_3_operand")
13203                      (match_operand 4 "const_0_to_3_operand")
13204                      (match_operand 5 "const_0_to_3_operand")
13205                      (match_operand 6 "const_4_to_7_operand")
13206                      (match_operand 7 "const_4_to_7_operand")
13207                      (match_operand 8 "const_4_to_7_operand")
13208                      (match_operand 9 "const_4_to_7_operand")])))]
13209   "TARGET_AVX2
13210    && <mask_avx512vl_condition>
13211    && INTVAL (operands[2]) + 4 == INTVAL (operands[6])
13212    && INTVAL (operands[3]) + 4 == INTVAL (operands[7])
13213    && INTVAL (operands[4]) + 4 == INTVAL (operands[8])
13214    && INTVAL (operands[5]) + 4 == INTVAL (operands[9])"
13216   int mask = 0;
13217   mask |= INTVAL (operands[2]) << 0;
13218   mask |= INTVAL (operands[3]) << 2;
13219   mask |= INTVAL (operands[4]) << 4;
13220   mask |= INTVAL (operands[5]) << 6;
13221   operands[2] = GEN_INT (mask);
13223   return "vpshufd\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
13225   [(set_attr "type" "sselog1")
13226    (set_attr "prefix" "maybe_evex")
13227    (set_attr "length_immediate" "1")
13228    (set_attr "mode" "OI")])
13230 (define_expand "avx512vl_pshufd_mask"
13231   [(match_operand:V4SI 0 "register_operand")
13232    (match_operand:V4SI 1 "nonimmediate_operand")
13233    (match_operand:SI 2 "const_0_to_255_operand")
13234    (match_operand:V4SI 3 "register_operand")
13235    (match_operand:QI 4 "register_operand")]
13236   "TARGET_AVX512VL"
13238   int mask = INTVAL (operands[2]);
13239   emit_insn (gen_sse2_pshufd_1_mask (operands[0], operands[1],
13240                                 GEN_INT ((mask >> 0) & 3),
13241                                 GEN_INT ((mask >> 2) & 3),
13242                                 GEN_INT ((mask >> 4) & 3),
13243                                 GEN_INT ((mask >> 6) & 3),
13244                 operands[3], operands[4]));
13245   DONE;
13248 (define_expand "sse2_pshufd"
13249   [(match_operand:V4SI 0 "register_operand")
13250    (match_operand:V4SI 1 "vector_operand")
13251    (match_operand:SI 2 "const_int_operand")]
13252   "TARGET_SSE2"
13254   int mask = INTVAL (operands[2]);
13255   emit_insn (gen_sse2_pshufd_1 (operands[0], operands[1],
13256                                 GEN_INT ((mask >> 0) & 3),
13257                                 GEN_INT ((mask >> 2) & 3),
13258                                 GEN_INT ((mask >> 4) & 3),
13259                                 GEN_INT ((mask >> 6) & 3)));
13260   DONE;
13263 (define_insn "sse2_pshufd_1<mask_name>"
13264   [(set (match_operand:V4SI 0 "register_operand" "=v")
13265         (vec_select:V4SI
13266           (match_operand:V4SI 1 "vector_operand" "vBm")
13267           (parallel [(match_operand 2 "const_0_to_3_operand")
13268                      (match_operand 3 "const_0_to_3_operand")
13269                      (match_operand 4 "const_0_to_3_operand")
13270                      (match_operand 5 "const_0_to_3_operand")])))]
13271   "TARGET_SSE2 && <mask_avx512vl_condition>"
13273   int mask = 0;
13274   mask |= INTVAL (operands[2]) << 0;
13275   mask |= INTVAL (operands[3]) << 2;
13276   mask |= INTVAL (operands[4]) << 4;
13277   mask |= INTVAL (operands[5]) << 6;
13278   operands[2] = GEN_INT (mask);
13280   return "%vpshufd\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
13282   [(set_attr "type" "sselog1")
13283    (set_attr "prefix_data16" "1")
13284    (set_attr "prefix" "<mask_prefix2>")
13285    (set_attr "length_immediate" "1")
13286    (set_attr "mode" "TI")])
13288 (define_insn "<mask_codefor>avx512bw_pshuflwv32hi<mask_name>"
13289   [(set (match_operand:V32HI 0 "register_operand" "=v")
13290         (unspec:V32HI
13291           [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
13292            (match_operand:SI 2 "const_0_to_255_operand" "n")]
13293           UNSPEC_PSHUFLW))]
13294   "TARGET_AVX512BW"
13295   "vpshuflw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
13296   [(set_attr "type" "sselog")
13297    (set_attr "prefix" "evex")
13298    (set_attr "mode" "XI")])
13300 (define_expand "avx512vl_pshuflwv3_mask"
13301   [(match_operand:V16HI 0 "register_operand")
13302    (match_operand:V16HI 1 "nonimmediate_operand")
13303    (match_operand:SI 2 "const_0_to_255_operand")
13304    (match_operand:V16HI 3 "register_operand")
13305    (match_operand:HI 4 "register_operand")]
13306   "TARGET_AVX512VL && TARGET_AVX512BW"
13308   int mask = INTVAL (operands[2]);
13309   emit_insn (gen_avx2_pshuflw_1_mask (operands[0], operands[1],
13310                                  GEN_INT ((mask >> 0) & 3),
13311                                  GEN_INT ((mask >> 2) & 3),
13312                                  GEN_INT ((mask >> 4) & 3),
13313                                  GEN_INT ((mask >> 6) & 3),
13314                                  GEN_INT (((mask >> 0) & 3) + 8),
13315                                  GEN_INT (((mask >> 2) & 3) + 8),
13316                                  GEN_INT (((mask >> 4) & 3) + 8),
13317                                  GEN_INT (((mask >> 6) & 3) + 8),
13318                  operands[3], operands[4]));
13319   DONE;
13322 (define_expand "avx2_pshuflwv3"
13323   [(match_operand:V16HI 0 "register_operand")
13324    (match_operand:V16HI 1 "nonimmediate_operand")
13325    (match_operand:SI 2 "const_0_to_255_operand")]
13326   "TARGET_AVX2"
13328   int mask = INTVAL (operands[2]);
13329   emit_insn (gen_avx2_pshuflw_1 (operands[0], operands[1],
13330                                  GEN_INT ((mask >> 0) & 3),
13331                                  GEN_INT ((mask >> 2) & 3),
13332                                  GEN_INT ((mask >> 4) & 3),
13333                                  GEN_INT ((mask >> 6) & 3),
13334                                  GEN_INT (((mask >> 0) & 3) + 8),
13335                                  GEN_INT (((mask >> 2) & 3) + 8),
13336                                  GEN_INT (((mask >> 4) & 3) + 8),
13337                                  GEN_INT (((mask >> 6) & 3) + 8)));
13338   DONE;
13341 (define_insn "avx2_pshuflw_1<mask_name>"
13342   [(set (match_operand:V16HI 0 "register_operand" "=v")
13343         (vec_select:V16HI
13344           (match_operand:V16HI 1 "nonimmediate_operand" "vm")
13345           (parallel [(match_operand 2 "const_0_to_3_operand")
13346                      (match_operand 3 "const_0_to_3_operand")
13347                      (match_operand 4 "const_0_to_3_operand")
13348                      (match_operand 5 "const_0_to_3_operand")
13349                      (const_int 4)
13350                      (const_int 5)
13351                      (const_int 6)
13352                      (const_int 7)
13353                      (match_operand 6 "const_8_to_11_operand")
13354                      (match_operand 7 "const_8_to_11_operand")
13355                      (match_operand 8 "const_8_to_11_operand")
13356                      (match_operand 9 "const_8_to_11_operand")
13357                      (const_int 12)
13358                      (const_int 13)
13359                      (const_int 14)
13360                      (const_int 15)])))]
13361   "TARGET_AVX2
13362    && <mask_avx512bw_condition> && <mask_avx512vl_condition>
13363    && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
13364    && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
13365    && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
13366    && INTVAL (operands[5]) + 8 == INTVAL (operands[9])"
13368   int mask = 0;
13369   mask |= INTVAL (operands[2]) << 0;
13370   mask |= INTVAL (operands[3]) << 2;
13371   mask |= INTVAL (operands[4]) << 4;
13372   mask |= INTVAL (operands[5]) << 6;
13373   operands[2] = GEN_INT (mask);
13375   return "vpshuflw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
13377   [(set_attr "type" "sselog")
13378    (set_attr "prefix" "maybe_evex")
13379    (set_attr "length_immediate" "1")
13380    (set_attr "mode" "OI")])
13382 (define_expand "avx512vl_pshuflw_mask"
13383   [(match_operand:V8HI 0 "register_operand")
13384    (match_operand:V8HI 1 "nonimmediate_operand")
13385    (match_operand:SI 2 "const_0_to_255_operand")
13386    (match_operand:V8HI 3 "register_operand")
13387    (match_operand:QI 4 "register_operand")]
13388   "TARGET_AVX512VL && TARGET_AVX512BW"
13390   int mask = INTVAL (operands[2]);
13391   emit_insn (gen_sse2_pshuflw_1_mask (operands[0], operands[1],
13392                                  GEN_INT ((mask >> 0) & 3),
13393                                  GEN_INT ((mask >> 2) & 3),
13394                                  GEN_INT ((mask >> 4) & 3),
13395                                  GEN_INT ((mask >> 6) & 3),
13396                  operands[3], operands[4]));
13397   DONE;
13400 (define_expand "sse2_pshuflw"
13401   [(match_operand:V8HI 0 "register_operand")
13402    (match_operand:V8HI 1 "vector_operand")
13403    (match_operand:SI 2 "const_int_operand")]
13404   "TARGET_SSE2"
13406   int mask = INTVAL (operands[2]);
13407   emit_insn (gen_sse2_pshuflw_1 (operands[0], operands[1],
13408                                  GEN_INT ((mask >> 0) & 3),
13409                                  GEN_INT ((mask >> 2) & 3),
13410                                  GEN_INT ((mask >> 4) & 3),
13411                                  GEN_INT ((mask >> 6) & 3)));
13412   DONE;
13415 (define_insn "sse2_pshuflw_1<mask_name>"
13416   [(set (match_operand:V8HI 0 "register_operand" "=v")
13417         (vec_select:V8HI
13418           (match_operand:V8HI 1 "vector_operand" "vBm")
13419           (parallel [(match_operand 2 "const_0_to_3_operand")
13420                      (match_operand 3 "const_0_to_3_operand")
13421                      (match_operand 4 "const_0_to_3_operand")
13422                      (match_operand 5 "const_0_to_3_operand")
13423                      (const_int 4)
13424                      (const_int 5)
13425                      (const_int 6)
13426                      (const_int 7)])))]
13427   "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
13429   int mask = 0;
13430   mask |= INTVAL (operands[2]) << 0;
13431   mask |= INTVAL (operands[3]) << 2;
13432   mask |= INTVAL (operands[4]) << 4;
13433   mask |= INTVAL (operands[5]) << 6;
13434   operands[2] = GEN_INT (mask);
13436   return "%vpshuflw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
13438   [(set_attr "type" "sselog")
13439    (set_attr "prefix_data16" "0")
13440    (set_attr "prefix_rep" "1")
13441    (set_attr "prefix" "maybe_vex")
13442    (set_attr "length_immediate" "1")
13443    (set_attr "mode" "TI")])
13445 (define_expand "avx2_pshufhwv3"
13446   [(match_operand:V16HI 0 "register_operand")
13447    (match_operand:V16HI 1 "nonimmediate_operand")
13448    (match_operand:SI 2 "const_0_to_255_operand")]
13449   "TARGET_AVX2"
13451   int mask = INTVAL (operands[2]);
13452   emit_insn (gen_avx2_pshufhw_1 (operands[0], operands[1],
13453                                  GEN_INT (((mask >> 0) & 3) + 4),
13454                                  GEN_INT (((mask >> 2) & 3) + 4),
13455                                  GEN_INT (((mask >> 4) & 3) + 4),
13456                                  GEN_INT (((mask >> 6) & 3) + 4),
13457                                  GEN_INT (((mask >> 0) & 3) + 12),
13458                                  GEN_INT (((mask >> 2) & 3) + 12),
13459                                  GEN_INT (((mask >> 4) & 3) + 12),
13460                                  GEN_INT (((mask >> 6) & 3) + 12)));
13461   DONE;
13464 (define_insn "<mask_codefor>avx512bw_pshufhwv32hi<mask_name>"
13465   [(set (match_operand:V32HI 0 "register_operand" "=v")
13466         (unspec:V32HI
13467           [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
13468            (match_operand:SI 2 "const_0_to_255_operand" "n")]
13469           UNSPEC_PSHUFHW))]
13470   "TARGET_AVX512BW"
13471   "vpshufhw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
13472   [(set_attr "type" "sselog")
13473    (set_attr "prefix" "evex")
13474    (set_attr "mode" "XI")])
13476 (define_expand "avx512vl_pshufhwv3_mask"
13477   [(match_operand:V16HI 0 "register_operand")
13478    (match_operand:V16HI 1 "nonimmediate_operand")
13479    (match_operand:SI 2 "const_0_to_255_operand")
13480    (match_operand:V16HI 3 "register_operand")
13481    (match_operand:HI 4 "register_operand")]
13482   "TARGET_AVX512VL && TARGET_AVX512BW"
13484   int mask = INTVAL (operands[2]);
13485   emit_insn (gen_avx2_pshufhw_1_mask (operands[0], operands[1],
13486                                  GEN_INT (((mask >> 0) & 3) + 4),
13487                                  GEN_INT (((mask >> 2) & 3) + 4),
13488                                  GEN_INT (((mask >> 4) & 3) + 4),
13489                                  GEN_INT (((mask >> 6) & 3) + 4),
13490                                  GEN_INT (((mask >> 0) & 3) + 12),
13491                                  GEN_INT (((mask >> 2) & 3) + 12),
13492                                  GEN_INT (((mask >> 4) & 3) + 12),
13493                                  GEN_INT (((mask >> 6) & 3) + 12),
13494                  operands[3], operands[4]));
13495   DONE;
13498 (define_insn "avx2_pshufhw_1<mask_name>"
13499   [(set (match_operand:V16HI 0 "register_operand" "=v")
13500         (vec_select:V16HI
13501           (match_operand:V16HI 1 "nonimmediate_operand" "vm")
13502           (parallel [(const_int 0)
13503                      (const_int 1)
13504                      (const_int 2)
13505                      (const_int 3)
13506                      (match_operand 2 "const_4_to_7_operand")
13507                      (match_operand 3 "const_4_to_7_operand")
13508                      (match_operand 4 "const_4_to_7_operand")
13509                      (match_operand 5 "const_4_to_7_operand")
13510                      (const_int 8)
13511                      (const_int 9)
13512                      (const_int 10)
13513                      (const_int 11)
13514                      (match_operand 6 "const_12_to_15_operand")
13515                      (match_operand 7 "const_12_to_15_operand")
13516                      (match_operand 8 "const_12_to_15_operand")
13517                      (match_operand 9 "const_12_to_15_operand")])))]
13518   "TARGET_AVX2
13519    && <mask_avx512bw_condition> && <mask_avx512vl_condition>
13520    && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
13521    && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
13522    && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
13523    && INTVAL (operands[5]) + 8 == INTVAL (operands[9])"
13525   int mask = 0;
13526   mask |= (INTVAL (operands[2]) - 4) << 0;
13527   mask |= (INTVAL (operands[3]) - 4) << 2;
13528   mask |= (INTVAL (operands[4]) - 4) << 4;
13529   mask |= (INTVAL (operands[5]) - 4) << 6;
13530   operands[2] = GEN_INT (mask);
13532   return "vpshufhw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
13534   [(set_attr "type" "sselog")
13535    (set_attr "prefix" "maybe_evex")
13536    (set_attr "length_immediate" "1")
13537    (set_attr "mode" "OI")])
13539 (define_expand "avx512vl_pshufhw_mask"
13540   [(match_operand:V8HI 0 "register_operand")
13541    (match_operand:V8HI 1 "nonimmediate_operand")
13542    (match_operand:SI 2 "const_0_to_255_operand")
13543    (match_operand:V8HI 3 "register_operand")
13544    (match_operand:QI 4 "register_operand")]
13545   "TARGET_AVX512VL && TARGET_AVX512BW"
13547   int mask = INTVAL (operands[2]);
13548   emit_insn (gen_sse2_pshufhw_1_mask (operands[0], operands[1],
13549                                  GEN_INT (((mask >> 0) & 3) + 4),
13550                                  GEN_INT (((mask >> 2) & 3) + 4),
13551                                  GEN_INT (((mask >> 4) & 3) + 4),
13552                                  GEN_INT (((mask >> 6) & 3) + 4),
13553                  operands[3], operands[4]));
13554   DONE;
13557 (define_expand "sse2_pshufhw"
13558   [(match_operand:V8HI 0 "register_operand")
13559    (match_operand:V8HI 1 "vector_operand")
13560    (match_operand:SI 2 "const_int_operand")]
13561   "TARGET_SSE2"
13563   int mask = INTVAL (operands[2]);
13564   emit_insn (gen_sse2_pshufhw_1 (operands[0], operands[1],
13565                                  GEN_INT (((mask >> 0) & 3) + 4),
13566                                  GEN_INT (((mask >> 2) & 3) + 4),
13567                                  GEN_INT (((mask >> 4) & 3) + 4),
13568                                  GEN_INT (((mask >> 6) & 3) + 4)));
13569   DONE;
13572 (define_insn "sse2_pshufhw_1<mask_name>"
13573   [(set (match_operand:V8HI 0 "register_operand" "=v")
13574         (vec_select:V8HI
13575           (match_operand:V8HI 1 "vector_operand" "vBm")
13576           (parallel [(const_int 0)
13577                      (const_int 1)
13578                      (const_int 2)
13579                      (const_int 3)
13580                      (match_operand 2 "const_4_to_7_operand")
13581                      (match_operand 3 "const_4_to_7_operand")
13582                      (match_operand 4 "const_4_to_7_operand")
13583                      (match_operand 5 "const_4_to_7_operand")])))]
13584   "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
13586   int mask = 0;
13587   mask |= (INTVAL (operands[2]) - 4) << 0;
13588   mask |= (INTVAL (operands[3]) - 4) << 2;
13589   mask |= (INTVAL (operands[4]) - 4) << 4;
13590   mask |= (INTVAL (operands[5]) - 4) << 6;
13591   operands[2] = GEN_INT (mask);
13593   return "%vpshufhw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
13595   [(set_attr "type" "sselog")
13596    (set_attr "prefix_rep" "1")
13597    (set_attr "prefix_data16" "0")
13598    (set_attr "prefix" "maybe_vex")
13599    (set_attr "length_immediate" "1")
13600    (set_attr "mode" "TI")])
13602 (define_expand "sse2_loadd"
13603   [(set (match_operand:V4SI 0 "register_operand")
13604         (vec_merge:V4SI
13605           (vec_duplicate:V4SI
13606             (match_operand:SI 1 "nonimmediate_operand"))
13607           (match_dup 2)
13608           (const_int 1)))]
13609   "TARGET_SSE"
13610   "operands[2] = CONST0_RTX (V4SImode);")
13612 (define_insn "sse2_loadld"
13613   [(set (match_operand:V4SI 0 "register_operand"       "=v,v,x,x,v")
13614         (vec_merge:V4SI
13615           (vec_duplicate:V4SI
13616             (match_operand:SI 2 "nonimmediate_operand" "m ,r ,m,x,v"))
13617           (match_operand:V4SI 1 "reg_or_0_operand"     "C ,C ,C,0,v")
13618           (const_int 1)))]
13619   "TARGET_SSE"
13620   "@
13621    %vmovd\t{%2, %0|%0, %2}
13622    %vmovd\t{%2, %0|%0, %2}
13623    movss\t{%2, %0|%0, %2}
13624    movss\t{%2, %0|%0, %2}
13625    vmovss\t{%2, %1, %0|%0, %1, %2}"
13626   [(set_attr "isa" "sse2,sse2,noavx,noavx,avx")
13627    (set_attr "type" "ssemov")
13628    (set_attr "prefix" "maybe_vex,maybe_vex,orig,orig,maybe_evex")
13629    (set_attr "mode" "TI,TI,V4SF,SF,SF")
13630    (set (attr "preferred_for_speed")
13631      (cond [(eq_attr "alternative" "1")
13632               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
13633            ]
13634            (symbol_ref "true")))])
13636 ;; QI and HI modes handled by pextr patterns.
13637 (define_mode_iterator PEXTR_MODE12
13638   [(V16QI "TARGET_SSE4_1") V8HI])
13640 (define_insn "*vec_extract<mode>"
13641   [(set (match_operand:<ssescalarmode> 0 "register_sse4nonimm_operand" "=r,m,r,m")
13642         (vec_select:<ssescalarmode>
13643           (match_operand:PEXTR_MODE12 1 "register_operand" "x,x,v,v")
13644           (parallel
13645             [(match_operand:SI 2 "const_0_to_<ssescalarnummask>_operand")])))]
13646   "TARGET_SSE2"
13647   "@
13648    %vpextr<ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
13649    %vpextr<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
13650    vpextr<ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
13651    vpextr<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
13652   [(set_attr "isa" "*,sse4,avx512bw,avx512bw")
13653    (set_attr "type" "sselog1")
13654    (set_attr "prefix_data16" "1")
13655    (set (attr "prefix_extra")
13656      (if_then_else
13657        (and (eq_attr "alternative" "0,2")
13658             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
13659        (const_string "*")
13660        (const_string "1")))
13661    (set_attr "length_immediate" "1")
13662    (set_attr "prefix" "maybe_vex,maybe_vex,evex,evex")
13663    (set_attr "mode" "TI")])
13665 (define_insn "*vec_extract<PEXTR_MODE12:mode>_zext"
13666   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
13667         (zero_extend:SWI48
13668           (vec_select:<PEXTR_MODE12:ssescalarmode>
13669             (match_operand:PEXTR_MODE12 1 "register_operand" "x,v")
13670             (parallel
13671               [(match_operand:SI 2
13672                 "const_0_to_<PEXTR_MODE12:ssescalarnummask>_operand")]))))]
13673   "TARGET_SSE2"
13674   "@
13675    %vpextr<PEXTR_MODE12:ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
13676    vpextr<PEXTR_MODE12:ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}"
13677   [(set_attr "isa" "*,avx512bw")
13678    (set_attr "type" "sselog1")
13679    (set_attr "prefix_data16" "1")
13680    (set (attr "prefix_extra")
13681      (if_then_else
13682        (eq (const_string "<PEXTR_MODE12:MODE>mode") (const_string "V8HImode"))
13683        (const_string "*")
13684        (const_string "1")))
13685    (set_attr "length_immediate" "1")
13686    (set_attr "prefix" "maybe_vex")
13687    (set_attr "mode" "TI")])
13689 (define_insn "*vec_extract<mode>_mem"
13690   [(set (match_operand:<ssescalarmode> 0 "register_operand" "=r")
13691         (vec_select:<ssescalarmode>
13692           (match_operand:VI12_128 1 "memory_operand" "o")
13693           (parallel
13694             [(match_operand 2 "const_0_to_<ssescalarnummask>_operand")])))]
13695   "TARGET_SSE"
13696   "#")
13698 (define_insn "*vec_extract<ssevecmodelower>_0"
13699   [(set (match_operand:SWI48 0 "nonimmediate_operand"          "=r,r,v ,m")
13700         (vec_select:SWI48
13701           (match_operand:<ssevecmode> 1 "nonimmediate_operand" "m ,v,vm,v")
13702           (parallel [(const_int 0)])))]
13703   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13704   "#"
13705   [(set_attr "isa" "*,sse2,*,*")
13706    (set (attr "preferred_for_speed")
13707      (cond [(eq_attr "alternative" "1")
13708               (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
13709            ]
13710            (symbol_ref "true")))])
13712 (define_insn "*vec_extractv2di_0_sse"
13713   [(set (match_operand:DI 0 "nonimmediate_operand"     "=v,m")
13714         (vec_select:DI
13715           (match_operand:V2DI 1 "nonimmediate_operand" "vm,v")
13716           (parallel [(const_int 0)])))]
13717   "TARGET_SSE && !TARGET_64BIT
13718    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13719   "#")
13721 (define_split
13722   [(set (match_operand:SWI48x 0 "nonimmediate_operand")
13723         (vec_select:SWI48x
13724           (match_operand:<ssevecmode> 1 "register_operand")
13725           (parallel [(const_int 0)])))]
13726   "TARGET_SSE && reload_completed"
13727   [(set (match_dup 0) (match_dup 1))]
13728   "operands[1] = gen_lowpart (<MODE>mode, operands[1]);")
13730 (define_insn "*vec_extractv4si_0_zext_sse4"
13731   [(set (match_operand:DI 0 "register_operand" "=r,x,v")
13732         (zero_extend:DI
13733           (vec_select:SI
13734             (match_operand:V4SI 1 "register_operand" "v,x,v")
13735             (parallel [(const_int 0)]))))]
13736   "TARGET_SSE4_1"
13737   "#"
13738   [(set_attr "isa" "x64,*,avx512f")
13739    (set (attr "preferred_for_speed")
13740      (cond [(eq_attr "alternative" "0")
13741               (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
13742            ]
13743            (symbol_ref "true")))])
13745 (define_insn "*vec_extractv4si_0_zext"
13746   [(set (match_operand:DI 0 "register_operand" "=r")
13747         (zero_extend:DI
13748           (vec_select:SI
13749             (match_operand:V4SI 1 "register_operand" "x")
13750             (parallel [(const_int 0)]))))]
13751   "TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_FROM_VEC"
13752   "#")
13754 (define_split
13755   [(set (match_operand:DI 0 "register_operand")
13756         (zero_extend:DI
13757           (vec_select:SI
13758             (match_operand:V4SI 1 "register_operand")
13759             (parallel [(const_int 0)]))))]
13760   "TARGET_SSE2 && reload_completed"
13761   [(set (match_dup 0) (zero_extend:DI (match_dup 1)))]
13762   "operands[1] = gen_lowpart (SImode, operands[1]);")
13764 (define_insn "*vec_extractv4si"
13765   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm,Yr,*x,x,Yv")
13766         (vec_select:SI
13767           (match_operand:V4SI 1 "register_operand" "x,v,0,0,x,v")
13768           (parallel [(match_operand:SI 2 "const_0_to_3_operand")])))]
13769   "TARGET_SSE4_1"
13771   switch (which_alternative)
13772     {
13773     case 0:
13774     case 1:
13775       return "%vpextrd\t{%2, %1, %0|%0, %1, %2}";
13777     case 2:
13778     case 3:
13779       operands[2] = GEN_INT (INTVAL (operands[2]) * 4);
13780       return "psrldq\t{%2, %0|%0, %2}";
13782     case 4:
13783     case 5:
13784       operands[2] = GEN_INT (INTVAL (operands[2]) * 4);
13785       return "vpsrldq\t{%2, %1, %0|%0, %1, %2}";
13787     default:
13788       gcc_unreachable ();
13789     }
13791   [(set_attr "isa" "*,avx512dq,noavx,noavx,avx,avx512bw")
13792    (set_attr "type" "sselog1,sselog1,sseishft1,sseishft1,sseishft1,sseishft1")
13793    (set (attr "prefix_extra")
13794      (if_then_else (eq_attr "alternative" "0,1")
13795                    (const_string "1")
13796                    (const_string "*")))
13797    (set_attr "length_immediate" "1")
13798    (set_attr "prefix" "maybe_vex,evex,orig,orig,vex,evex")
13799    (set_attr "mode" "TI")])
13801 (define_insn "*vec_extractv4si_zext"
13802   [(set (match_operand:DI 0 "register_operand" "=r,r")
13803         (zero_extend:DI
13804           (vec_select:SI
13805             (match_operand:V4SI 1 "register_operand" "x,v")
13806             (parallel [(match_operand:SI 2 "const_0_to_3_operand")]))))]
13807   "TARGET_64BIT && TARGET_SSE4_1"
13808   "%vpextrd\t{%2, %1, %k0|%k0, %1, %2}"
13809   [(set_attr "isa" "*,avx512dq")
13810    (set_attr "type" "sselog1")
13811    (set_attr "prefix_extra" "1")
13812    (set_attr "length_immediate" "1")
13813    (set_attr "prefix" "maybe_vex")
13814    (set_attr "mode" "TI")])
13816 (define_insn "*vec_extractv4si_mem"
13817   [(set (match_operand:SI 0 "register_operand" "=x,r")
13818         (vec_select:SI
13819           (match_operand:V4SI 1 "memory_operand" "o,o")
13820           (parallel [(match_operand 2 "const_0_to_3_operand")])))]
13821   "TARGET_SSE"
13822   "#")
13824 (define_insn_and_split "*vec_extractv4si_zext_mem"
13825   [(set (match_operand:DI 0 "register_operand" "=x,r")
13826         (zero_extend:DI
13827           (vec_select:SI
13828             (match_operand:V4SI 1 "memory_operand" "o,o")
13829             (parallel [(match_operand:SI 2 "const_0_to_3_operand")]))))]
13830   "TARGET_64BIT && TARGET_SSE"
13831   "#"
13832   "&& reload_completed"
13833   [(set (match_dup 0) (zero_extend:DI (match_dup 1)))]
13835   operands[1] = adjust_address (operands[1], SImode, INTVAL (operands[2]) * 4);
13838 (define_insn "*vec_extractv2di_1"
13839   [(set (match_operand:DI 0 "nonimmediate_operand"     "=rm,rm,m,x,x,Yv,x,v,r")
13840         (vec_select:DI
13841           (match_operand:V2DI 1 "nonimmediate_operand"  "x ,v ,v,0,x, v,x,o,o")
13842           (parallel [(const_int 1)])))]
13843   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13844   "@
13845    %vpextrq\t{$1, %1, %0|%0, %1, 1}
13846    vpextrq\t{$1, %1, %0|%0, %1, 1}
13847    %vmovhps\t{%1, %0|%0, %1}
13848    psrldq\t{$8, %0|%0, 8}
13849    vpsrldq\t{$8, %1, %0|%0, %1, 8}
13850    vpsrldq\t{$8, %1, %0|%0, %1, 8}
13851    movhlps\t{%1, %0|%0, %1}
13852    #
13853    #"
13854   [(set (attr "isa")
13855      (cond [(eq_attr "alternative" "0")
13856               (const_string "x64_sse4")
13857             (eq_attr "alternative" "1")
13858               (const_string "x64_avx512dq")
13859             (eq_attr "alternative" "3")
13860               (const_string "sse2_noavx")
13861             (eq_attr "alternative" "4")
13862               (const_string "avx")
13863             (eq_attr "alternative" "5")
13864               (const_string "avx512bw")
13865             (eq_attr "alternative" "6")
13866               (const_string "noavx")
13867             (eq_attr "alternative" "8")
13868               (const_string "x64")
13869            ]
13870            (const_string "*")))
13871    (set (attr "type")
13872      (cond [(eq_attr "alternative" "2,6,7")
13873               (const_string "ssemov")
13874             (eq_attr "alternative" "3,4,5")
13875               (const_string "sseishft1")
13876             (eq_attr "alternative" "8")
13877               (const_string "imov")
13878            ]
13879            (const_string "sselog1")))
13880    (set (attr "length_immediate")
13881      (if_then_else (eq_attr "alternative" "0,1,3,4,5")
13882                    (const_string "1")
13883                    (const_string "*")))
13884    (set (attr "prefix_rex")
13885      (if_then_else (eq_attr "alternative" "0,1")
13886                    (const_string "1")
13887                    (const_string "*")))
13888    (set (attr "prefix_extra")
13889      (if_then_else (eq_attr "alternative" "0,1")
13890                    (const_string "1")
13891                    (const_string "*")))
13892    (set_attr "prefix" "maybe_vex,evex,maybe_vex,orig,vex,evex,orig,*,*")
13893    (set_attr "mode" "TI,TI,V2SF,TI,TI,TI,V4SF,DI,DI")])
13895 (define_split
13896   [(set (match_operand:<ssescalarmode> 0 "register_operand")
13897         (vec_select:<ssescalarmode>
13898           (match_operand:VI_128 1 "memory_operand")
13899           (parallel
13900             [(match_operand 2 "const_0_to_<ssescalarnummask>_operand")])))]
13901   "TARGET_SSE && reload_completed"
13902   [(set (match_dup 0) (match_dup 1))]
13904   int offs = INTVAL (operands[2]) * GET_MODE_SIZE (<ssescalarmode>mode);
13906   operands[1] = adjust_address (operands[1], <ssescalarmode>mode, offs);
13909 (define_insn "*vec_extractv2ti"
13910   [(set (match_operand:TI 0 "nonimmediate_operand" "=xm,vm")
13911         (vec_select:TI
13912           (match_operand:V2TI 1 "register_operand" "x,v")
13913           (parallel
13914             [(match_operand:SI 2 "const_0_to_1_operand")])))]
13915   "TARGET_AVX"
13916   "@
13917    vextract%~128\t{%2, %1, %0|%0, %1, %2}
13918    vextracti32x4\t{%2, %g1, %0|%0, %g1, %2}"
13919   [(set_attr "type" "sselog")
13920    (set_attr "prefix_extra" "1")
13921    (set_attr "length_immediate" "1")
13922    (set_attr "prefix" "vex,evex")
13923    (set_attr "mode" "OI")])
13925 (define_insn "*vec_extractv4ti"
13926   [(set (match_operand:TI 0 "nonimmediate_operand" "=vm")
13927         (vec_select:TI
13928           (match_operand:V4TI 1 "register_operand" "v")
13929           (parallel
13930             [(match_operand:SI 2 "const_0_to_3_operand")])))]
13931   "TARGET_AVX512F"
13932   "vextracti32x4\t{%2, %1, %0|%0, %1, %2}"
13933   [(set_attr "type" "sselog")
13934    (set_attr "prefix_extra" "1")
13935    (set_attr "length_immediate" "1")
13936    (set_attr "prefix" "evex")
13937    (set_attr "mode" "XI")])
13939 (define_mode_iterator VEXTRACTI128_MODE
13940   [(V4TI "TARGET_AVX512F") V2TI])
13942 (define_split
13943   [(set (match_operand:TI 0 "nonimmediate_operand")
13944         (vec_select:TI
13945           (match_operand:VEXTRACTI128_MODE 1 "register_operand")
13946           (parallel [(const_int 0)])))]
13947   "TARGET_AVX
13948    && reload_completed
13949    && (TARGET_AVX512VL || !EXT_REX_SSE_REG_P (operands[1]))"
13950   [(set (match_dup 0) (match_dup 1))]
13951   "operands[1] = gen_lowpart (TImode, operands[1]);")
13953 ;; Turn SImode or DImode extraction from arbitrary SSE/AVX/AVX512F
13954 ;; vector modes into vec_extract*.
13955 (define_split
13956   [(set (match_operand:SWI48x 0 "nonimmediate_operand")
13957         (subreg:SWI48x (match_operand 1 "register_operand") 0))]
13958   "can_create_pseudo_p ()
13959    && REG_P (operands[1])
13960    && VECTOR_MODE_P (GET_MODE (operands[1]))
13961    && ((TARGET_SSE && GET_MODE_SIZE (GET_MODE (operands[1])) == 16)
13962        || (TARGET_AVX && GET_MODE_SIZE (GET_MODE (operands[1])) == 32)
13963        || (TARGET_AVX512F && GET_MODE_SIZE (GET_MODE (operands[1])) == 64))
13964    && (<MODE>mode == SImode || TARGET_64BIT || MEM_P (operands[0]))"
13965   [(set (match_dup 0) (vec_select:SWI48x (match_dup 1)
13966                                          (parallel [(const_int 0)])))]
13968   rtx tmp;
13970   switch (GET_MODE_SIZE (GET_MODE (operands[1])))
13971     {
13972     case 64:
13973       if (<MODE>mode == SImode)
13974         {
13975           tmp = gen_reg_rtx (V8SImode);
13976           emit_insn (gen_vec_extract_lo_v16si (tmp,
13977                                                gen_lowpart (V16SImode,
13978                                                             operands[1])));
13979         }
13980       else
13981         {
13982           tmp = gen_reg_rtx (V4DImode);
13983           emit_insn (gen_vec_extract_lo_v8di (tmp,
13984                                               gen_lowpart (V8DImode,
13985                                                            operands[1])));
13986         }
13987       operands[1] = tmp;
13988       /* FALLTHRU */
13989     case 32:
13990       tmp = gen_reg_rtx (<ssevecmode>mode);
13991       if (<MODE>mode == SImode)
13992         emit_insn (gen_vec_extract_lo_v8si (tmp, gen_lowpart (V8SImode,
13993                                                               operands[1])));
13994       else
13995         emit_insn (gen_vec_extract_lo_v4di (tmp, gen_lowpart (V4DImode,
13996                                                               operands[1])));
13997       operands[1] = tmp;
13998       break;
13999     case 16:
14000       operands[1] = gen_lowpart (<ssevecmode>mode, operands[1]);
14001       break;
14002     }
14005 (define_insn "*vec_concatv2si_sse4_1"
14006   [(set (match_operand:V2SI 0 "register_operand"
14007           "=Yr,*x, x, v,Yr,*x, v, v, *y,*y")
14008         (vec_concat:V2SI
14009           (match_operand:SI 1 "nonimmediate_operand"
14010           "  0, 0, x,Yv, 0, 0,Yv,rm,  0,rm")
14011           (match_operand:SI 2 "vector_move_operand"
14012           " rm,rm,rm,rm,Yr,*x,Yv, C,*ym, C")))]
14013   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
14014   "@
14015    pinsrd\t{$1, %2, %0|%0, %2, 1}
14016    pinsrd\t{$1, %2, %0|%0, %2, 1}
14017    vpinsrd\t{$1, %2, %1, %0|%0, %1, %2, 1}
14018    vpinsrd\t{$1, %2, %1, %0|%0, %1, %2, 1}
14019    punpckldq\t{%2, %0|%0, %2}
14020    punpckldq\t{%2, %0|%0, %2}
14021    vpunpckldq\t{%2, %1, %0|%0, %1, %2}
14022    %vmovd\t{%1, %0|%0, %1}
14023    punpckldq\t{%2, %0|%0, %2}
14024    movd\t{%1, %0|%0, %1}"
14025   [(set_attr "isa" "noavx,noavx,avx,avx512dq,noavx,noavx,avx,*,*,*")
14026    (set (attr "type")
14027      (cond [(eq_attr "alternative" "7")
14028               (const_string "ssemov")
14029             (eq_attr "alternative" "8")
14030               (const_string "mmxcvt")
14031             (eq_attr "alternative" "9")
14032               (const_string "mmxmov")
14033            ]
14034            (const_string "sselog")))
14035    (set (attr "prefix_extra")
14036      (if_then_else (eq_attr "alternative" "0,1,2,3")
14037                    (const_string "1")
14038                    (const_string "*")))
14039    (set (attr "length_immediate")
14040      (if_then_else (eq_attr "alternative" "0,1,2,3")
14041                    (const_string "1")
14042                    (const_string "*")))
14043    (set_attr "prefix" "orig,orig,vex,evex,orig,orig,maybe_evex,maybe_vex,orig,orig")
14044    (set_attr "mode" "TI,TI,TI,TI,TI,TI,TI,TI,DI,DI")])
14046 ;; ??? In theory we can match memory for the MMX alternative, but allowing
14047 ;; nonimmediate_operand for operand 2 and *not* allowing memory for the SSE
14048 ;; alternatives pretty much forces the MMX alternative to be chosen.
14049 (define_insn "*vec_concatv2si"
14050   [(set (match_operand:V2SI 0 "register_operand"     "=x,x ,*y,x,x,*y,*y")
14051         (vec_concat:V2SI
14052           (match_operand:SI 1 "nonimmediate_operand" " 0,rm,rm,0,m, 0,*rm")
14053           (match_operand:SI 2 "reg_or_0_operand"     " x,C ,C, x,C,*y,C")))]
14054   "TARGET_SSE && !TARGET_SSE4_1"
14055   "@
14056    punpckldq\t{%2, %0|%0, %2}
14057    movd\t{%1, %0|%0, %1}
14058    movd\t{%1, %0|%0, %1}
14059    unpcklps\t{%2, %0|%0, %2}
14060    movss\t{%1, %0|%0, %1}
14061    punpckldq\t{%2, %0|%0, %2}
14062    movd\t{%1, %0|%0, %1}"
14063   [(set_attr "isa" "sse2,sse2,sse2,*,*,*,*")
14064    (set_attr "type" "sselog,ssemov,mmxmov,sselog,ssemov,mmxcvt,mmxmov")
14065    (set_attr "mode" "TI,TI,DI,V4SF,SF,DI,DI")])
14067 (define_insn "*vec_concatv4si"
14068   [(set (match_operand:V4SI 0 "register_operand"       "=x,v,x,x,v")
14069         (vec_concat:V4SI
14070           (match_operand:V2SI 1 "register_operand"     " 0,v,0,0,v")
14071           (match_operand:V2SI 2 "nonimmediate_operand" " x,v,x,m,m")))]
14072   "TARGET_SSE"
14073   "@
14074    punpcklqdq\t{%2, %0|%0, %2}
14075    vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
14076    movlhps\t{%2, %0|%0, %2}
14077    movhps\t{%2, %0|%0, %q2}
14078    vmovhps\t{%2, %1, %0|%0, %1, %q2}"
14079   [(set_attr "isa" "sse2_noavx,avx,noavx,noavx,avx")
14080    (set_attr "type" "sselog,sselog,ssemov,ssemov,ssemov")
14081    (set_attr "prefix" "orig,maybe_evex,orig,orig,maybe_evex")
14082    (set_attr "mode" "TI,TI,V4SF,V2SF,V2SF")])
14084 ;; movd instead of movq is required to handle broken assemblers.
14085 (define_insn "vec_concatv2di"
14086   [(set (match_operand:V2DI 0 "register_operand"
14087           "=Yr,*x,x ,v ,v,v ,x   ,x,v ,x,x,v")
14088         (vec_concat:V2DI
14089           (match_operand:DI 1 "nonimmediate_operand"
14090           "  0, 0,x ,Yv,r,vm,?!*y,0,Yv,0,0,v")
14091           (match_operand:DI 2 "vector_move_operand"
14092           " rm,rm,rm,rm,C ,C ,C ,x,Yv,x,m,m")))]
14093   "TARGET_SSE"
14094   "@
14095    pinsrq\t{$1, %2, %0|%0, %2, 1}
14096    pinsrq\t{$1, %2, %0|%0, %2, 1}
14097    vpinsrq\t{$1, %2, %1, %0|%0, %1, %2, 1}
14098    vpinsrq\t{$1, %2, %1, %0|%0, %1, %2, 1}
14099    * return HAVE_AS_IX86_INTERUNIT_MOVQ ? \"%vmovq\t{%1, %0|%0, %1}\" : \"%vmovd\t{%1, %0|%0, %1}\";
14100    %vmovq\t{%1, %0|%0, %1}
14101    movq2dq\t{%1, %0|%0, %1}
14102    punpcklqdq\t{%2, %0|%0, %2}
14103    vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
14104    movlhps\t{%2, %0|%0, %2}
14105    movhps\t{%2, %0|%0, %2}
14106    vmovhps\t{%2, %1, %0|%0, %1, %2}"
14107   [(set (attr "isa")
14108      (cond [(eq_attr "alternative" "0,1")
14109               (const_string "x64_sse4_noavx")
14110             (eq_attr "alternative" "2")
14111               (const_string "x64_avx")
14112             (eq_attr "alternative" "3")
14113               (const_string "x64_avx512dq")
14114             (eq_attr "alternative" "4")
14115               (const_string "x64_sse2")
14116             (eq_attr "alternative" "5,6")
14117               (const_string "sse2")
14118             (eq_attr "alternative" "7")
14119               (const_string "sse2_noavx")
14120             (eq_attr "alternative" "8,11")
14121               (const_string "avx")
14122            ]
14123            (const_string "noavx")))
14124    (set (attr "type")
14125      (if_then_else
14126        (eq_attr "alternative" "0,1,2,3,7,8")
14127        (const_string "sselog")
14128        (const_string "ssemov")))
14129    (set (attr "prefix_rex")
14130      (if_then_else (eq_attr "alternative" "0,1,2,3,4")
14131                    (const_string "1")
14132                    (const_string "*")))
14133    (set (attr "prefix_extra")
14134      (if_then_else (eq_attr "alternative" "0,1,2,3")
14135                    (const_string "1")
14136                    (const_string "*")))
14137    (set (attr "length_immediate")
14138      (if_then_else (eq_attr "alternative" "0,1,2,3")
14139                    (const_string "1")
14140                    (const_string "*")))
14141    (set (attr "prefix")
14142      (cond [(eq_attr "alternative" "2")
14143               (const_string "vex")
14144             (eq_attr "alternative" "3")
14145               (const_string "evex")
14146             (eq_attr "alternative" "4,5")
14147               (const_string "maybe_vex")
14148             (eq_attr "alternative" "8,11")
14149               (const_string "maybe_evex")
14150            ]
14151            (const_string "orig")))
14152    (set_attr "mode" "TI,TI,TI,TI,TI,TI,TI,TI,TI,V4SF,V2SF,V2SF")
14153    (set (attr "preferred_for_speed")
14154      (cond [(eq_attr "alternative" "4")
14155               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
14156             (eq_attr "alternative" "6")
14157               (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
14158            ]
14159            (symbol_ref "true")))])
14161 ;; vmovq clears also the higher bits.
14162 (define_insn "vec_set<mode>_0"
14163   [(set (match_operand:VI8_AVX_AVX512F 0 "register_operand" "=v,v")
14164         (vec_merge:VI8_AVX_AVX512F
14165           (vec_duplicate:VI8_AVX_AVX512F
14166             (match_operand:<ssescalarmode> 2 "general_operand" "r,vm"))
14167           (match_operand:VI8_AVX_AVX512F 1 "const0_operand" "C,C")
14168           (const_int 1)))]
14169   "TARGET_AVX"
14170   "vmovq\t{%2, %x0|%x0, %2}"
14171   [(set_attr "isa" "x64,*")
14172    (set_attr "type" "ssemov")
14173    (set_attr "prefix_rex" "1,*")
14174    (set_attr "prefix" "maybe_evex")
14175    (set_attr "mode" "TI")
14176    (set (attr "preferred_for_speed")
14177      (cond [(eq_attr "alternative" "0")
14178               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
14179            ]
14180            (symbol_ref "true")))])
14182 (define_expand "vec_unpacks_lo_<mode>"
14183   [(match_operand:<sseunpackmode> 0 "register_operand")
14184    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
14185   "TARGET_SSE2"
14186   "ix86_expand_sse_unpack (operands[0], operands[1], false, false); DONE;")
14188 (define_expand "vec_unpacks_hi_<mode>"
14189   [(match_operand:<sseunpackmode> 0 "register_operand")
14190    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
14191   "TARGET_SSE2"
14192   "ix86_expand_sse_unpack (operands[0], operands[1], false, true); DONE;")
14194 (define_expand "vec_unpacku_lo_<mode>"
14195   [(match_operand:<sseunpackmode> 0 "register_operand")
14196    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
14197   "TARGET_SSE2"
14198   "ix86_expand_sse_unpack (operands[0], operands[1], true, false); DONE;")
14200 (define_expand "vec_unpacks_lo_hi"
14201   [(set (subreg:HI (match_operand:QI 0 "register_operand") 0)
14202         (match_operand:HI 1 "register_operand"))]
14203   "TARGET_AVX512F")
14205 (define_expand "vec_unpacks_lo_si"
14206   [(set (match_operand:HI 0 "register_operand")
14207         (subreg:HI (match_operand:SI 1 "register_operand") 0))]
14208   "TARGET_AVX512F")
14210 (define_expand "vec_unpacks_lo_di"
14211   [(set (match_operand:SI 0 "register_operand")
14212         (subreg:SI (match_operand:DI 1 "register_operand") 0))]
14213   "TARGET_AVX512BW")
14215 (define_expand "vec_unpacku_hi_<mode>"
14216   [(match_operand:<sseunpackmode> 0 "register_operand")
14217    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
14218   "TARGET_SSE2"
14219   "ix86_expand_sse_unpack (operands[0], operands[1], true, true); DONE;")
14221 (define_expand "vec_unpacks_hi_hi"
14222   [(parallel
14223      [(set (subreg:HI (match_operand:QI 0 "register_operand") 0)
14224            (lshiftrt:HI (match_operand:HI 1 "register_operand")
14225                         (const_int 8)))
14226       (unspec [(const_int 0)] UNSPEC_MASKOP)])]
14227   "TARGET_AVX512F")
14229 (define_expand "vec_unpacks_hi_<mode>"
14230   [(parallel
14231      [(set (subreg:SWI48x
14232              (match_operand:<HALFMASKMODE> 0 "register_operand") 0)
14233            (lshiftrt:SWI48x (match_operand:SWI48x 1 "register_operand")
14234                             (match_dup 2)))
14235       (unspec [(const_int 0)] UNSPEC_MASKOP)])]
14236   "TARGET_AVX512BW"
14237   "operands[2] = GEN_INT (GET_MODE_BITSIZE (<HALFMASKMODE>mode));")
14239 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14241 ;; Miscellaneous
14243 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14245 (define_expand "<sse2_avx2>_uavg<mode>3<mask_name>"
14246   [(set (match_operand:VI12_AVX2 0 "register_operand")
14247         (truncate:VI12_AVX2
14248           (lshiftrt:<ssedoublemode>
14249             (plus:<ssedoublemode>
14250               (plus:<ssedoublemode>
14251                 (zero_extend:<ssedoublemode>
14252                   (match_operand:VI12_AVX2 1 "vector_operand"))
14253                 (zero_extend:<ssedoublemode>
14254                   (match_operand:VI12_AVX2 2 "vector_operand")))
14255               (match_dup <mask_expand_op3>))
14256             (const_int 1))))]
14257   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
14259   operands[<mask_expand_op3>] = CONST1_RTX(<MODE>mode);
14260   ix86_fixup_binary_operands_no_copy (PLUS, <MODE>mode, operands);
14263 (define_insn "*<sse2_avx2>_uavg<mode>3<mask_name>"
14264   [(set (match_operand:VI12_AVX2 0 "register_operand" "=x,v")
14265         (truncate:VI12_AVX2
14266           (lshiftrt:<ssedoublemode>
14267             (plus:<ssedoublemode>
14268               (plus:<ssedoublemode>
14269                 (zero_extend:<ssedoublemode>
14270                   (match_operand:VI12_AVX2 1 "vector_operand" "%0,v"))
14271                 (zero_extend:<ssedoublemode>
14272                   (match_operand:VI12_AVX2 2 "vector_operand" "xBm,vm")))
14273               (match_operand:VI12_AVX2 <mask_expand_op3> "const1_operand"))
14274             (const_int 1))))]
14275   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
14276    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
14277   "@
14278    pavg<ssemodesuffix>\t{%2, %0|%0, %2}
14279    vpavg<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14280   [(set_attr "isa" "noavx,avx")
14281    (set_attr "type" "sseiadd")
14282    (set_attr "prefix_data16" "1,*")
14283    (set_attr "prefix" "orig,<mask_prefix>")
14284    (set_attr "mode" "<sseinsnmode>")])
14286 ;; The correct representation for this is absolutely enormous, and
14287 ;; surely not generally useful.
14288 (define_insn "<sse2_avx2>_psadbw"
14289   [(set (match_operand:VI8_AVX2_AVX512BW 0 "register_operand" "=x,v")
14290         (unspec:VI8_AVX2_AVX512BW
14291           [(match_operand:<ssebytemode> 1 "register_operand" "0,v")
14292            (match_operand:<ssebytemode> 2 "vector_operand" "xBm,vm")]
14293           UNSPEC_PSADBW))]
14294   "TARGET_SSE2"
14295   "@
14296    psadbw\t{%2, %0|%0, %2}
14297    vpsadbw\t{%2, %1, %0|%0, %1, %2}"
14298   [(set_attr "isa" "noavx,avx")
14299    (set_attr "type" "sseiadd")
14300    (set_attr "atom_unit" "simul")
14301    (set_attr "prefix_data16" "1,*")
14302    (set_attr "prefix" "orig,maybe_evex")
14303    (set_attr "mode" "<sseinsnmode>")])
14305 (define_insn "<sse>_movmsk<ssemodesuffix><avxsizesuffix>"
14306   [(set (match_operand:SI 0 "register_operand" "=r")
14307         (unspec:SI
14308           [(match_operand:VF_128_256 1 "register_operand" "x")]
14309           UNSPEC_MOVMSK))]
14310   "TARGET_SSE"
14311   "%vmovmsk<ssemodesuffix>\t{%1, %0|%0, %1}"
14312   [(set_attr "type" "ssemov")
14313    (set_attr "prefix" "maybe_vex")
14314    (set_attr "mode" "<MODE>")])
14316 (define_insn "*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_zext"
14317   [(set (match_operand:DI 0 "register_operand" "=r")
14318         (zero_extend:DI
14319           (unspec:SI
14320             [(match_operand:VF_128_256 1 "register_operand" "x")]
14321             UNSPEC_MOVMSK)))]
14322   "TARGET_64BIT && TARGET_SSE"
14323   "%vmovmsk<ssemodesuffix>\t{%1, %k0|%k0, %1}"
14324   [(set_attr "type" "ssemov")
14325    (set_attr "prefix" "maybe_vex")
14326    (set_attr "mode" "<MODE>")])
14328 (define_insn "<sse2_avx2>_pmovmskb"
14329   [(set (match_operand:SI 0 "register_operand" "=r")
14330         (unspec:SI
14331           [(match_operand:VI1_AVX2 1 "register_operand" "x")]
14332           UNSPEC_MOVMSK))]
14333   "TARGET_SSE2"
14334   "%vpmovmskb\t{%1, %0|%0, %1}"
14335   [(set_attr "type" "ssemov")
14336    (set (attr "prefix_data16")
14337      (if_then_else
14338        (match_test "TARGET_AVX")
14339      (const_string "*")
14340      (const_string "1")))
14341    (set_attr "prefix" "maybe_vex")
14342    (set_attr "mode" "SI")])
14344 (define_insn "*<sse2_avx2>_pmovmskb_zext"
14345   [(set (match_operand:DI 0 "register_operand" "=r")
14346         (zero_extend:DI
14347           (unspec:SI
14348             [(match_operand:VI1_AVX2 1 "register_operand" "x")]
14349             UNSPEC_MOVMSK)))]
14350   "TARGET_64BIT && TARGET_SSE2"
14351   "%vpmovmskb\t{%1, %k0|%k0, %1}"
14352   [(set_attr "type" "ssemov")
14353    (set (attr "prefix_data16")
14354      (if_then_else
14355        (match_test "TARGET_AVX")
14356      (const_string "*")
14357      (const_string "1")))
14358    (set_attr "prefix" "maybe_vex")
14359    (set_attr "mode" "SI")])
14361 (define_expand "sse2_maskmovdqu"
14362   [(set (match_operand:V16QI 0 "memory_operand")
14363         (unspec:V16QI [(match_operand:V16QI 1 "register_operand")
14364                        (match_operand:V16QI 2 "register_operand")
14365                        (match_dup 0)]
14366                       UNSPEC_MASKMOV))]
14367   "TARGET_SSE2")
14369 (define_insn "*sse2_maskmovdqu"
14370   [(set (mem:V16QI (match_operand:P 0 "register_operand" "D"))
14371         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "x")
14372                        (match_operand:V16QI 2 "register_operand" "x")
14373                        (mem:V16QI (match_dup 0))]
14374                       UNSPEC_MASKMOV))]
14375   "TARGET_SSE2"
14377   /* We can't use %^ here due to ASM_OUTPUT_OPCODE processing
14378      that requires %v to be at the beginning of the opcode name.  */
14379   if (Pmode != word_mode)
14380     fputs ("\taddr32", asm_out_file);
14381   return "%vmaskmovdqu\t{%2, %1|%1, %2}";
14383   [(set_attr "type" "ssemov")
14384    (set_attr "prefix_data16" "1")
14385    (set (attr "length_address")
14386      (symbol_ref ("Pmode != word_mode")))
14387    ;; The implicit %rdi operand confuses default length_vex computation.
14388    (set (attr "length_vex")
14389      (symbol_ref ("3 + REX_SSE_REGNO_P (REGNO (operands[2]))")))
14390    (set_attr "prefix" "maybe_vex")
14391    (set_attr "znver1_decode" "vector")
14392    (set_attr "mode" "TI")])
14394 (define_insn "sse_ldmxcsr"
14395   [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m")]
14396                     UNSPECV_LDMXCSR)]
14397   "TARGET_SSE"
14398   "%vldmxcsr\t%0"
14399   [(set_attr "type" "sse")
14400    (set_attr "atom_sse_attr" "mxcsr")
14401    (set_attr "prefix" "maybe_vex")
14402    (set_attr "memory" "load")])
14404 (define_insn "sse_stmxcsr"
14405   [(set (match_operand:SI 0 "memory_operand" "=m")
14406         (unspec_volatile:SI [(const_int 0)] UNSPECV_STMXCSR))]
14407   "TARGET_SSE"
14408   "%vstmxcsr\t%0"
14409   [(set_attr "type" "sse")
14410    (set_attr "atom_sse_attr" "mxcsr")
14411    (set_attr "prefix" "maybe_vex")
14412    (set_attr "memory" "store")])
14414 (define_insn "sse2_clflush"
14415   [(unspec_volatile [(match_operand 0 "address_operand" "p")]
14416                     UNSPECV_CLFLUSH)]
14417   "TARGET_SSE2"
14418   "clflush\t%a0"
14419   [(set_attr "type" "sse")
14420    (set_attr "atom_sse_attr" "fence")
14421    (set_attr "memory" "unknown")])
14423 ;; As per AMD and Intel ISA manuals, the first operand is extensions
14424 ;; and it goes to %ecx. The second operand received is hints and it goes
14425 ;; to %eax.
14426 (define_insn "sse3_mwait"
14427   [(unspec_volatile [(match_operand:SI 0 "register_operand" "c")
14428                      (match_operand:SI 1 "register_operand" "a")]
14429                     UNSPECV_MWAIT)]
14430   "TARGET_SSE3"
14431 ;; 64bit version is "mwait %rax,%rcx". But only lower 32bits are used.
14432 ;; Since 32bit register operands are implicitly zero extended to 64bit,
14433 ;; we only need to set up 32bit registers.
14434   "mwait"
14435   [(set_attr "length" "3")])
14437 (define_insn "sse3_monitor_<mode>"
14438   [(unspec_volatile [(match_operand:P 0 "register_operand" "a")
14439                      (match_operand:SI 1 "register_operand" "c")
14440                      (match_operand:SI 2 "register_operand" "d")]
14441                     UNSPECV_MONITOR)]
14442   "TARGET_SSE3"
14443 ;; 64bit version is "monitor %rax,%rcx,%rdx". But only lower 32bits in
14444 ;; RCX and RDX are used.  Since 32bit register operands are implicitly
14445 ;; zero extended to 64bit, we only need to set up 32bit registers.
14446   "%^monitor"
14447   [(set (attr "length")
14448      (symbol_ref ("(Pmode != word_mode) + 3")))])
14450 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14452 ;; SSSE3 instructions
14454 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14456 (define_code_iterator ssse3_plusminus [plus ss_plus minus ss_minus])
14458 (define_insn "avx2_ph<plusminus_mnemonic>wv16hi3"
14459   [(set (match_operand:V16HI 0 "register_operand" "=x")
14460         (vec_concat:V16HI
14461           (vec_concat:V8HI
14462             (vec_concat:V4HI
14463               (vec_concat:V2HI
14464                 (ssse3_plusminus:HI
14465                   (vec_select:HI
14466                     (match_operand:V16HI 1 "register_operand" "x")
14467                     (parallel [(const_int 0)]))
14468                   (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
14469                 (ssse3_plusminus:HI
14470                   (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
14471                   (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
14472               (vec_concat:V2HI
14473                 (ssse3_plusminus:HI
14474                   (vec_select:HI (match_dup 1) (parallel [(const_int 4)]))
14475                   (vec_select:HI (match_dup 1) (parallel [(const_int 5)])))
14476                 (ssse3_plusminus:HI
14477                   (vec_select:HI (match_dup 1) (parallel [(const_int 6)]))
14478                   (vec_select:HI (match_dup 1) (parallel [(const_int 7)])))))
14479             (vec_concat:V4HI
14480               (vec_concat:V2HI
14481                 (ssse3_plusminus:HI
14482                   (vec_select:HI (match_dup 1) (parallel [(const_int 8)]))
14483                   (vec_select:HI (match_dup 1) (parallel [(const_int 9)])))
14484                 (ssse3_plusminus:HI
14485                   (vec_select:HI (match_dup 1) (parallel [(const_int 10)]))
14486                   (vec_select:HI (match_dup 1) (parallel [(const_int 11)]))))
14487               (vec_concat:V2HI
14488                 (ssse3_plusminus:HI
14489                   (vec_select:HI (match_dup 1) (parallel [(const_int 12)]))
14490                   (vec_select:HI (match_dup 1) (parallel [(const_int 13)])))
14491                 (ssse3_plusminus:HI
14492                   (vec_select:HI (match_dup 1) (parallel [(const_int 14)]))
14493                   (vec_select:HI (match_dup 1) (parallel [(const_int 15)]))))))
14494           (vec_concat:V8HI
14495             (vec_concat:V4HI
14496               (vec_concat:V2HI
14497                 (ssse3_plusminus:HI
14498                   (vec_select:HI
14499                     (match_operand:V16HI 2 "nonimmediate_operand" "xm")
14500                     (parallel [(const_int 0)]))
14501                   (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
14502                 (ssse3_plusminus:HI
14503                   (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
14504                   (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))
14505               (vec_concat:V2HI
14506                 (ssse3_plusminus:HI
14507                   (vec_select:HI (match_dup 2) (parallel [(const_int 4)]))
14508                   (vec_select:HI (match_dup 2) (parallel [(const_int 5)])))
14509                 (ssse3_plusminus:HI
14510                   (vec_select:HI (match_dup 2) (parallel [(const_int 6)]))
14511                   (vec_select:HI (match_dup 2) (parallel [(const_int 7)])))))
14512             (vec_concat:V4HI
14513               (vec_concat:V2HI
14514                 (ssse3_plusminus:HI
14515                   (vec_select:HI (match_dup 2) (parallel [(const_int 8)]))
14516                   (vec_select:HI (match_dup 2) (parallel [(const_int 9)])))
14517                 (ssse3_plusminus:HI
14518                   (vec_select:HI (match_dup 2) (parallel [(const_int 10)]))
14519                   (vec_select:HI (match_dup 2) (parallel [(const_int 11)]))))
14520               (vec_concat:V2HI
14521                 (ssse3_plusminus:HI
14522                   (vec_select:HI (match_dup 2) (parallel [(const_int 12)]))
14523                   (vec_select:HI (match_dup 2) (parallel [(const_int 13)])))
14524                 (ssse3_plusminus:HI
14525                   (vec_select:HI (match_dup 2) (parallel [(const_int 14)]))
14526                   (vec_select:HI (match_dup 2) (parallel [(const_int 15)]))))))))]
14527   "TARGET_AVX2"
14528   "vph<plusminus_mnemonic>w\t{%2, %1, %0|%0, %1, %2}"
14529   [(set_attr "type" "sseiadd")
14530    (set_attr "prefix_extra" "1")
14531    (set_attr "prefix" "vex")
14532    (set_attr "mode" "OI")])
14534 (define_insn "ssse3_ph<plusminus_mnemonic>wv8hi3"
14535   [(set (match_operand:V8HI 0 "register_operand" "=x,x")
14536         (vec_concat:V8HI
14537           (vec_concat:V4HI
14538             (vec_concat:V2HI
14539               (ssse3_plusminus:HI
14540                 (vec_select:HI
14541                   (match_operand:V8HI 1 "register_operand" "0,x")
14542                   (parallel [(const_int 0)]))
14543                 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
14544               (ssse3_plusminus:HI
14545                 (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
14546                 (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
14547             (vec_concat:V2HI
14548               (ssse3_plusminus:HI
14549                 (vec_select:HI (match_dup 1) (parallel [(const_int 4)]))
14550                 (vec_select:HI (match_dup 1) (parallel [(const_int 5)])))
14551               (ssse3_plusminus:HI
14552                 (vec_select:HI (match_dup 1) (parallel [(const_int 6)]))
14553                 (vec_select:HI (match_dup 1) (parallel [(const_int 7)])))))
14554           (vec_concat:V4HI
14555             (vec_concat:V2HI
14556               (ssse3_plusminus:HI
14557                 (vec_select:HI
14558                   (match_operand:V8HI 2 "vector_operand" "xBm,xm")
14559                   (parallel [(const_int 0)]))
14560                 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
14561               (ssse3_plusminus:HI
14562                 (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
14563                 (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))
14564             (vec_concat:V2HI
14565               (ssse3_plusminus:HI
14566                 (vec_select:HI (match_dup 2) (parallel [(const_int 4)]))
14567                 (vec_select:HI (match_dup 2) (parallel [(const_int 5)])))
14568               (ssse3_plusminus:HI
14569                 (vec_select:HI (match_dup 2) (parallel [(const_int 6)]))
14570                 (vec_select:HI (match_dup 2) (parallel [(const_int 7)])))))))]
14571   "TARGET_SSSE3"
14572   "@
14573    ph<plusminus_mnemonic>w\t{%2, %0|%0, %2}
14574    vph<plusminus_mnemonic>w\t{%2, %1, %0|%0, %1, %2}"
14575   [(set_attr "isa" "noavx,avx")
14576    (set_attr "type" "sseiadd")
14577    (set_attr "atom_unit" "complex")
14578    (set_attr "prefix_data16" "1,*")
14579    (set_attr "prefix_extra" "1")
14580    (set_attr "prefix" "orig,vex")
14581    (set_attr "mode" "TI")])
14583 (define_insn "ssse3_ph<plusminus_mnemonic>wv4hi3"
14584   [(set (match_operand:V4HI 0 "register_operand" "=y")
14585         (vec_concat:V4HI
14586           (vec_concat:V2HI
14587             (ssse3_plusminus:HI
14588               (vec_select:HI
14589                 (match_operand:V4HI 1 "register_operand" "0")
14590                 (parallel [(const_int 0)]))
14591               (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
14592             (ssse3_plusminus:HI
14593               (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
14594               (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
14595           (vec_concat:V2HI
14596             (ssse3_plusminus:HI
14597               (vec_select:HI
14598                 (match_operand:V4HI 2 "nonimmediate_operand" "ym")
14599                 (parallel [(const_int 0)]))
14600               (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
14601             (ssse3_plusminus:HI
14602               (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
14603               (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))))]
14604   "TARGET_SSSE3"
14605   "ph<plusminus_mnemonic>w\t{%2, %0|%0, %2}"
14606   [(set_attr "type" "sseiadd")
14607    (set_attr "atom_unit" "complex")
14608    (set_attr "prefix_extra" "1")
14609    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14610    (set_attr "mode" "DI")])
14612 (define_insn "avx2_ph<plusminus_mnemonic>dv8si3"
14613   [(set (match_operand:V8SI 0 "register_operand" "=x")
14614         (vec_concat:V8SI
14615           (vec_concat:V4SI
14616             (vec_concat:V2SI
14617               (plusminus:SI
14618                 (vec_select:SI
14619                   (match_operand:V8SI 1 "register_operand" "x")
14620                   (parallel [(const_int 0)]))
14621                 (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
14622               (plusminus:SI
14623                 (vec_select:SI (match_dup 1) (parallel [(const_int 2)]))
14624                 (vec_select:SI (match_dup 1) (parallel [(const_int 3)]))))
14625             (vec_concat:V2SI
14626               (plusminus:SI
14627                 (vec_select:SI (match_dup 1) (parallel [(const_int 4)]))
14628                 (vec_select:SI (match_dup 1) (parallel [(const_int 5)])))
14629               (plusminus:SI
14630                 (vec_select:SI (match_dup 1) (parallel [(const_int 6)]))
14631                 (vec_select:SI (match_dup 1) (parallel [(const_int 7)])))))
14632           (vec_concat:V4SI
14633             (vec_concat:V2SI
14634               (plusminus:SI
14635                 (vec_select:SI
14636                   (match_operand:V8SI 2 "nonimmediate_operand" "xm")
14637                   (parallel [(const_int 0)]))
14638                 (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))
14639               (plusminus:SI
14640                 (vec_select:SI (match_dup 2) (parallel [(const_int 2)]))
14641                 (vec_select:SI (match_dup 2) (parallel [(const_int 3)]))))
14642             (vec_concat:V2SI
14643               (plusminus:SI
14644                 (vec_select:SI (match_dup 2) (parallel [(const_int 4)]))
14645                 (vec_select:SI (match_dup 2) (parallel [(const_int 5)])))
14646               (plusminus:SI
14647                 (vec_select:SI (match_dup 2) (parallel [(const_int 6)]))
14648                 (vec_select:SI (match_dup 2) (parallel [(const_int 7)])))))))]
14649   "TARGET_AVX2"
14650   "vph<plusminus_mnemonic>d\t{%2, %1, %0|%0, %1, %2}"
14651   [(set_attr "type" "sseiadd")
14652    (set_attr "prefix_extra" "1")
14653    (set_attr "prefix" "vex")
14654    (set_attr "mode" "OI")])
14656 (define_insn "ssse3_ph<plusminus_mnemonic>dv4si3"
14657   [(set (match_operand:V4SI 0 "register_operand" "=x,x")
14658         (vec_concat:V4SI
14659           (vec_concat:V2SI
14660             (plusminus:SI
14661               (vec_select:SI
14662                 (match_operand:V4SI 1 "register_operand" "0,x")
14663                 (parallel [(const_int 0)]))
14664               (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
14665             (plusminus:SI
14666               (vec_select:SI (match_dup 1) (parallel [(const_int 2)]))
14667               (vec_select:SI (match_dup 1) (parallel [(const_int 3)]))))
14668           (vec_concat:V2SI
14669             (plusminus:SI
14670               (vec_select:SI
14671                 (match_operand:V4SI 2 "vector_operand" "xBm,xm")
14672                 (parallel [(const_int 0)]))
14673               (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))
14674             (plusminus:SI
14675               (vec_select:SI (match_dup 2) (parallel [(const_int 2)]))
14676               (vec_select:SI (match_dup 2) (parallel [(const_int 3)]))))))]
14677   "TARGET_SSSE3"
14678   "@
14679    ph<plusminus_mnemonic>d\t{%2, %0|%0, %2}
14680    vph<plusminus_mnemonic>d\t{%2, %1, %0|%0, %1, %2}"
14681   [(set_attr "isa" "noavx,avx")
14682    (set_attr "type" "sseiadd")
14683    (set_attr "atom_unit" "complex")
14684    (set_attr "prefix_data16" "1,*")
14685    (set_attr "prefix_extra" "1")
14686    (set_attr "prefix" "orig,vex")
14687    (set_attr "mode" "TI")])
14689 (define_insn "ssse3_ph<plusminus_mnemonic>dv2si3"
14690   [(set (match_operand:V2SI 0 "register_operand" "=y")
14691         (vec_concat:V2SI
14692           (plusminus:SI
14693             (vec_select:SI
14694               (match_operand:V2SI 1 "register_operand" "0")
14695               (parallel [(const_int 0)]))
14696             (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
14697           (plusminus:SI
14698             (vec_select:SI
14699               (match_operand:V2SI 2 "nonimmediate_operand" "ym")
14700               (parallel [(const_int 0)]))
14701             (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))))]
14702   "TARGET_SSSE3"
14703   "ph<plusminus_mnemonic>d\t{%2, %0|%0, %2}"
14704   [(set_attr "type" "sseiadd")
14705    (set_attr "atom_unit" "complex")
14706    (set_attr "prefix_extra" "1")
14707    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14708    (set_attr "mode" "DI")])
14710 (define_insn "avx2_pmaddubsw256"
14711   [(set (match_operand:V16HI 0 "register_operand" "=x,v")
14712         (ss_plus:V16HI
14713           (mult:V16HI
14714             (zero_extend:V16HI
14715               (vec_select:V16QI
14716                 (match_operand:V32QI 1 "register_operand" "x,v")
14717                 (parallel [(const_int 0) (const_int 2)
14718                            (const_int 4) (const_int 6)
14719                            (const_int 8) (const_int 10)
14720                            (const_int 12) (const_int 14)
14721                            (const_int 16) (const_int 18)
14722                            (const_int 20) (const_int 22)
14723                            (const_int 24) (const_int 26)
14724                            (const_int 28) (const_int 30)])))
14725             (sign_extend:V16HI
14726               (vec_select:V16QI
14727                 (match_operand:V32QI 2 "nonimmediate_operand" "xm,vm")
14728                 (parallel [(const_int 0) (const_int 2)
14729                            (const_int 4) (const_int 6)
14730                            (const_int 8) (const_int 10)
14731                            (const_int 12) (const_int 14)
14732                            (const_int 16) (const_int 18)
14733                            (const_int 20) (const_int 22)
14734                            (const_int 24) (const_int 26)
14735                            (const_int 28) (const_int 30)]))))
14736           (mult:V16HI
14737             (zero_extend:V16HI
14738               (vec_select:V16QI (match_dup 1)
14739                 (parallel [(const_int 1) (const_int 3)
14740                            (const_int 5) (const_int 7)
14741                            (const_int 9) (const_int 11)
14742                            (const_int 13) (const_int 15)
14743                            (const_int 17) (const_int 19)
14744                            (const_int 21) (const_int 23)
14745                            (const_int 25) (const_int 27)
14746                            (const_int 29) (const_int 31)])))
14747             (sign_extend:V16HI
14748               (vec_select:V16QI (match_dup 2)
14749                 (parallel [(const_int 1) (const_int 3)
14750                            (const_int 5) (const_int 7)
14751                            (const_int 9) (const_int 11)
14752                            (const_int 13) (const_int 15)
14753                            (const_int 17) (const_int 19)
14754                            (const_int 21) (const_int 23)
14755                            (const_int 25) (const_int 27)
14756                            (const_int 29) (const_int 31)]))))))]
14757   "TARGET_AVX2"
14758   "vpmaddubsw\t{%2, %1, %0|%0, %1, %2}"
14759   [(set_attr "isa" "*,avx512bw")
14760    (set_attr "type" "sseiadd")
14761    (set_attr "prefix_extra" "1")
14762    (set_attr "prefix" "vex,evex")
14763    (set_attr "mode" "OI")])
14765 ;; The correct representation for this is absolutely enormous, and
14766 ;; surely not generally useful.
14767 (define_insn "avx512bw_pmaddubsw512<mode><mask_name>"
14768   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
14769           (unspec:VI2_AVX512VL
14770             [(match_operand:<dbpsadbwmode> 1 "register_operand" "v")
14771              (match_operand:<dbpsadbwmode> 2 "nonimmediate_operand" "vm")]
14772              UNSPEC_PMADDUBSW512))]
14773    "TARGET_AVX512BW"
14774    "vpmaddubsw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}";
14775   [(set_attr "type" "sseiadd")
14776    (set_attr "prefix" "evex")
14777    (set_attr "mode" "XI")])
14779 (define_insn "avx512bw_umulhrswv32hi3<mask_name>"
14780   [(set (match_operand:V32HI 0 "register_operand" "=v")
14781         (truncate:V32HI
14782           (lshiftrt:V32SI
14783             (plus:V32SI
14784               (lshiftrt:V32SI
14785                 (mult:V32SI
14786                   (sign_extend:V32SI
14787                     (match_operand:V32HI 1 "nonimmediate_operand" "%v"))
14788                   (sign_extend:V32SI
14789                     (match_operand:V32HI 2 "nonimmediate_operand" "vm")))
14790                 (const_int 14))
14791               (const_vector:V32HI [(const_int 1) (const_int 1)
14792                                    (const_int 1) (const_int 1)
14793                                    (const_int 1) (const_int 1)
14794                                    (const_int 1) (const_int 1)
14795                                    (const_int 1) (const_int 1)
14796                                    (const_int 1) (const_int 1)
14797                                    (const_int 1) (const_int 1)
14798                                    (const_int 1) (const_int 1)
14799                                    (const_int 1) (const_int 1)
14800                                    (const_int 1) (const_int 1)
14801                                    (const_int 1) (const_int 1)
14802                                    (const_int 1) (const_int 1)
14803                                    (const_int 1) (const_int 1)
14804                                    (const_int 1) (const_int 1)
14805                                    (const_int 1) (const_int 1)
14806                                    (const_int 1) (const_int 1)]))
14807             (const_int 1))))]
14808   "TARGET_AVX512BW"
14809   "vpmulhrsw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14810   [(set_attr "type" "sseimul")
14811    (set_attr "prefix" "evex")
14812    (set_attr "mode" "XI")])
14814 (define_insn "ssse3_pmaddubsw128"
14815   [(set (match_operand:V8HI 0 "register_operand" "=x,x,v")
14816         (ss_plus:V8HI
14817           (mult:V8HI
14818             (zero_extend:V8HI
14819               (vec_select:V8QI
14820                 (match_operand:V16QI 1 "register_operand" "0,x,v")
14821                 (parallel [(const_int 0) (const_int 2)
14822                            (const_int 4) (const_int 6)
14823                            (const_int 8) (const_int 10)
14824                            (const_int 12) (const_int 14)])))
14825             (sign_extend:V8HI
14826               (vec_select:V8QI
14827                 (match_operand:V16QI 2 "vector_operand" "xBm,xm,vm")
14828                 (parallel [(const_int 0) (const_int 2)
14829                            (const_int 4) (const_int 6)
14830                            (const_int 8) (const_int 10)
14831                            (const_int 12) (const_int 14)]))))
14832           (mult:V8HI
14833             (zero_extend:V8HI
14834               (vec_select:V8QI (match_dup 1)
14835                 (parallel [(const_int 1) (const_int 3)
14836                            (const_int 5) (const_int 7)
14837                            (const_int 9) (const_int 11)
14838                            (const_int 13) (const_int 15)])))
14839             (sign_extend:V8HI
14840               (vec_select:V8QI (match_dup 2)
14841                 (parallel [(const_int 1) (const_int 3)
14842                            (const_int 5) (const_int 7)
14843                            (const_int 9) (const_int 11)
14844                            (const_int 13) (const_int 15)]))))))]
14845   "TARGET_SSSE3"
14846   "@
14847    pmaddubsw\t{%2, %0|%0, %2}
14848    vpmaddubsw\t{%2, %1, %0|%0, %1, %2}
14849    vpmaddubsw\t{%2, %1, %0|%0, %1, %2}"
14850   [(set_attr "isa" "noavx,avx,avx512bw")
14851    (set_attr "type" "sseiadd")
14852    (set_attr "atom_unit" "simul")
14853    (set_attr "prefix_data16" "1,*,*")
14854    (set_attr "prefix_extra" "1")
14855    (set_attr "prefix" "orig,vex,evex")
14856    (set_attr "mode" "TI")])
14858 (define_insn "ssse3_pmaddubsw"
14859   [(set (match_operand:V4HI 0 "register_operand" "=y")
14860         (ss_plus:V4HI
14861           (mult:V4HI
14862             (zero_extend:V4HI
14863               (vec_select:V4QI
14864                 (match_operand:V8QI 1 "register_operand" "0")
14865                 (parallel [(const_int 0) (const_int 2)
14866                            (const_int 4) (const_int 6)])))
14867             (sign_extend:V4HI
14868               (vec_select:V4QI
14869                 (match_operand:V8QI 2 "nonimmediate_operand" "ym")
14870                 (parallel [(const_int 0) (const_int 2)
14871                            (const_int 4) (const_int 6)]))))
14872           (mult:V4HI
14873             (zero_extend:V4HI
14874               (vec_select:V4QI (match_dup 1)
14875                 (parallel [(const_int 1) (const_int 3)
14876                            (const_int 5) (const_int 7)])))
14877             (sign_extend:V4HI
14878               (vec_select:V4QI (match_dup 2)
14879                 (parallel [(const_int 1) (const_int 3)
14880                            (const_int 5) (const_int 7)]))))))]
14881   "TARGET_SSSE3"
14882   "pmaddubsw\t{%2, %0|%0, %2}"
14883   [(set_attr "type" "sseiadd")
14884    (set_attr "atom_unit" "simul")
14885    (set_attr "prefix_extra" "1")
14886    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14887    (set_attr "mode" "DI")])
14889 (define_mode_iterator PMULHRSW
14890   [V4HI V8HI (V16HI "TARGET_AVX2")])
14892 (define_expand "<ssse3_avx2>_pmulhrsw<mode>3_mask"
14893   [(set (match_operand:PMULHRSW 0 "register_operand")
14894         (vec_merge:PMULHRSW
14895           (truncate:PMULHRSW
14896             (lshiftrt:<ssedoublemode>
14897               (plus:<ssedoublemode>
14898                 (lshiftrt:<ssedoublemode>
14899                   (mult:<ssedoublemode>
14900                     (sign_extend:<ssedoublemode>
14901                       (match_operand:PMULHRSW 1 "nonimmediate_operand"))
14902                     (sign_extend:<ssedoublemode>
14903                       (match_operand:PMULHRSW 2 "nonimmediate_operand")))
14904                   (const_int 14))
14905                 (match_dup 5))
14906               (const_int 1)))
14907           (match_operand:PMULHRSW 3 "register_operand")
14908           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
14909   "TARGET_AVX512BW && TARGET_AVX512VL"
14911   operands[5] = CONST1_RTX(<MODE>mode);
14912   ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
14915 (define_expand "<ssse3_avx2>_pmulhrsw<mode>3"
14916   [(set (match_operand:PMULHRSW 0 "register_operand")
14917         (truncate:PMULHRSW
14918           (lshiftrt:<ssedoublemode>
14919             (plus:<ssedoublemode>
14920               (lshiftrt:<ssedoublemode>
14921                 (mult:<ssedoublemode>
14922                   (sign_extend:<ssedoublemode>
14923                     (match_operand:PMULHRSW 1 "nonimmediate_operand"))
14924                   (sign_extend:<ssedoublemode>
14925                     (match_operand:PMULHRSW 2 "nonimmediate_operand")))
14926                 (const_int 14))
14927               (match_dup 3))
14928             (const_int 1))))]
14929   "TARGET_AVX2"
14931   operands[3] = CONST1_RTX(<MODE>mode);
14932   ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
14935 (define_insn "*<ssse3_avx2>_pmulhrsw<mode>3<mask_name>"
14936   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,x,v")
14937         (truncate:VI2_AVX2
14938           (lshiftrt:<ssedoublemode>
14939             (plus:<ssedoublemode>
14940               (lshiftrt:<ssedoublemode>
14941                 (mult:<ssedoublemode>
14942                   (sign_extend:<ssedoublemode>
14943                     (match_operand:VI2_AVX2 1 "vector_operand" "%0,x,v"))
14944                   (sign_extend:<ssedoublemode>
14945                     (match_operand:VI2_AVX2 2 "vector_operand" "xBm,xm,vm")))
14946                 (const_int 14))
14947               (match_operand:VI2_AVX2 3 "const1_operand"))
14948             (const_int 1))))]
14949   "TARGET_SSSE3 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
14950    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
14951   "@
14952    pmulhrsw\t{%2, %0|%0, %2}
14953    vpmulhrsw\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}
14954    vpmulhrsw\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}"
14955   [(set_attr "isa" "noavx,avx,avx512bw")
14956    (set_attr "type" "sseimul")
14957    (set_attr "prefix_data16" "1,*,*")
14958    (set_attr "prefix_extra" "1")
14959    (set_attr "prefix" "orig,maybe_evex,evex")
14960    (set_attr "mode" "<sseinsnmode>")])
14962 (define_insn "*ssse3_pmulhrswv4hi3"
14963   [(set (match_operand:V4HI 0 "register_operand" "=y")
14964         (truncate:V4HI
14965           (lshiftrt:V4SI
14966             (plus:V4SI
14967               (lshiftrt:V4SI
14968                 (mult:V4SI
14969                   (sign_extend:V4SI
14970                     (match_operand:V4HI 1 "nonimmediate_operand" "%0"))
14971                   (sign_extend:V4SI
14972                     (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
14973                 (const_int 14))
14974               (match_operand:V4HI 3 "const1_operand"))
14975             (const_int 1))))]
14976   "TARGET_SSSE3 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
14977   "pmulhrsw\t{%2, %0|%0, %2}"
14978   [(set_attr "type" "sseimul")
14979    (set_attr "prefix_extra" "1")
14980    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14981    (set_attr "mode" "DI")])
14983 (define_insn "<ssse3_avx2>_pshufb<mode>3<mask_name>"
14984   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x,v")
14985         (unspec:VI1_AVX512
14986           [(match_operand:VI1_AVX512 1 "register_operand" "0,x,v")
14987            (match_operand:VI1_AVX512 2 "vector_operand" "xBm,xm,vm")]
14988           UNSPEC_PSHUFB))]
14989   "TARGET_SSSE3 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
14990   "@
14991    pshufb\t{%2, %0|%0, %2}
14992    vpshufb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
14993    vpshufb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14994   [(set_attr "isa" "noavx,avx,avx512bw")
14995    (set_attr "type" "sselog1")
14996    (set_attr "prefix_data16" "1,*,*")
14997    (set_attr "prefix_extra" "1")
14998    (set_attr "prefix" "orig,maybe_evex,evex")
14999    (set_attr "btver2_decode" "vector")
15000    (set_attr "mode" "<sseinsnmode>")])
15002 (define_insn "ssse3_pshufbv8qi3"
15003   [(set (match_operand:V8QI 0 "register_operand" "=y")
15004         (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "0")
15005                       (match_operand:V8QI 2 "nonimmediate_operand" "ym")]
15006                      UNSPEC_PSHUFB))]
15007   "TARGET_SSSE3"
15008   "pshufb\t{%2, %0|%0, %2}";
15009   [(set_attr "type" "sselog1")
15010    (set_attr "prefix_extra" "1")
15011    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15012    (set_attr "mode" "DI")])
15014 (define_insn "<ssse3_avx2>_psign<mode>3"
15015   [(set (match_operand:VI124_AVX2 0 "register_operand" "=x,x")
15016         (unspec:VI124_AVX2
15017           [(match_operand:VI124_AVX2 1 "register_operand" "0,x")
15018            (match_operand:VI124_AVX2 2 "vector_operand" "xBm,xm")]
15019           UNSPEC_PSIGN))]
15020   "TARGET_SSSE3"
15021   "@
15022    psign<ssemodesuffix>\t{%2, %0|%0, %2}
15023    vpsign<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
15024   [(set_attr "isa" "noavx,avx")
15025    (set_attr "type" "sselog1")
15026    (set_attr "prefix_data16" "1,*")
15027    (set_attr "prefix_extra" "1")
15028    (set_attr "prefix" "orig,vex")
15029    (set_attr "mode" "<sseinsnmode>")])
15031 (define_insn "ssse3_psign<mode>3"
15032   [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
15033         (unspec:MMXMODEI
15034           [(match_operand:MMXMODEI 1 "register_operand" "0")
15035            (match_operand:MMXMODEI 2 "nonimmediate_operand" "ym")]
15036           UNSPEC_PSIGN))]
15037   "TARGET_SSSE3"
15038   "psign<mmxvecsize>\t{%2, %0|%0, %2}";
15039   [(set_attr "type" "sselog1")
15040    (set_attr "prefix_extra" "1")
15041    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15042    (set_attr "mode" "DI")])
15044 (define_insn "<ssse3_avx2>_palignr<mode>_mask"
15045   [(set (match_operand:VI1_AVX512 0 "register_operand" "=v")
15046         (vec_merge:VI1_AVX512
15047           (unspec:VI1_AVX512
15048             [(match_operand:VI1_AVX512 1 "register_operand" "v")
15049              (match_operand:VI1_AVX512 2 "nonimmediate_operand" "vm")
15050              (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n")]
15051             UNSPEC_PALIGNR)
15052         (match_operand:VI1_AVX512 4 "vector_move_operand" "0C")
15053         (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
15054   "TARGET_AVX512BW && (<MODE_SIZE> == 64 || TARGET_AVX512VL)"
15056   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
15057   return "vpalignr\t{%3, %2, %1, %0%{%5%}%N4|%0%{%5%}%N4, %1, %2, %3}";
15059   [(set_attr "type" "sseishft")
15060    (set_attr "atom_unit" "sishuf")
15061    (set_attr "prefix_extra" "1")
15062    (set_attr "length_immediate" "1")
15063    (set_attr "prefix" "evex")
15064    (set_attr "mode" "<sseinsnmode>")])
15066 (define_insn "<ssse3_avx2>_palignr<mode>"
15067   [(set (match_operand:SSESCALARMODE 0 "register_operand" "=x,x,v")
15068         (unspec:SSESCALARMODE
15069           [(match_operand:SSESCALARMODE 1 "register_operand" "0,x,v")
15070            (match_operand:SSESCALARMODE 2 "vector_operand" "xBm,xm,vm")
15071            (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n,n,n")]
15072           UNSPEC_PALIGNR))]
15073   "TARGET_SSSE3"
15075   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
15077   switch (which_alternative)
15078     {
15079     case 0:
15080       return "palignr\t{%3, %2, %0|%0, %2, %3}";
15081     case 1:
15082     case 2:
15083       return "vpalignr\t{%3, %2, %1, %0|%0, %1, %2, %3}";
15084     default:
15085       gcc_unreachable ();
15086     }
15088   [(set_attr "isa" "noavx,avx,avx512bw")
15089    (set_attr "type" "sseishft")
15090    (set_attr "atom_unit" "sishuf")
15091    (set_attr "prefix_data16" "1,*,*")
15092    (set_attr "prefix_extra" "1")
15093    (set_attr "length_immediate" "1")
15094    (set_attr "prefix" "orig,vex,evex")
15095    (set_attr "mode" "<sseinsnmode>")])
15097 (define_insn "ssse3_palignrdi"
15098   [(set (match_operand:DI 0 "register_operand" "=y")
15099         (unspec:DI [(match_operand:DI 1 "register_operand" "0")
15100                     (match_operand:DI 2 "nonimmediate_operand" "ym")
15101                     (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n")]
15102                    UNSPEC_PALIGNR))]
15103   "TARGET_SSSE3"
15105   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
15106   return "palignr\t{%3, %2, %0|%0, %2, %3}";
15108   [(set_attr "type" "sseishft")
15109    (set_attr "atom_unit" "sishuf")
15110    (set_attr "prefix_extra" "1")
15111    (set_attr "length_immediate" "1")
15112    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15113    (set_attr "mode" "DI")])
15115 ;; Mode iterator to handle singularity w/ absence of V2DI and V4DI
15116 ;; modes for abs instruction on pre AVX-512 targets.
15117 (define_mode_iterator VI1248_AVX512VL_AVX512BW
15118   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
15119    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI
15120    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI
15121    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
15123 (define_insn "*abs<mode>2"
15124   [(set (match_operand:VI1248_AVX512VL_AVX512BW 0 "register_operand" "=v")
15125         (abs:VI1248_AVX512VL_AVX512BW
15126           (match_operand:VI1248_AVX512VL_AVX512BW 1 "vector_operand" "vBm")))]
15127   "TARGET_SSSE3"
15128   "%vpabs<ssemodesuffix>\t{%1, %0|%0, %1}"
15129   [(set_attr "type" "sselog1")
15130    (set_attr "prefix_data16" "1")
15131    (set_attr "prefix_extra" "1")
15132    (set_attr "prefix" "maybe_vex")
15133    (set_attr "mode" "<sseinsnmode>")])
15135 (define_insn "abs<mode>2_mask"
15136   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
15137         (vec_merge:VI48_AVX512VL
15138           (abs:VI48_AVX512VL
15139             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm"))
15140           (match_operand:VI48_AVX512VL 2 "vector_move_operand" "0C")
15141           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
15142   "TARGET_AVX512F"
15143   "vpabs<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15144   [(set_attr "type" "sselog1")
15145    (set_attr "prefix" "evex")
15146    (set_attr "mode" "<sseinsnmode>")])
15148 (define_insn "abs<mode>2_mask"
15149   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
15150         (vec_merge:VI12_AVX512VL
15151           (abs:VI12_AVX512VL
15152             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "vm"))
15153           (match_operand:VI12_AVX512VL 2 "vector_move_operand" "0C")
15154           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
15155   "TARGET_AVX512BW"
15156   "vpabs<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15157   [(set_attr "type" "sselog1")
15158    (set_attr "prefix" "evex")
15159    (set_attr "mode" "<sseinsnmode>")])
15161 (define_expand "abs<mode>2"
15162   [(set (match_operand:VI_AVX2 0 "register_operand")
15163         (abs:VI_AVX2
15164           (match_operand:VI_AVX2 1 "vector_operand")))]
15165   "TARGET_SSE2"
15167   if (!TARGET_SSSE3
15168       || ((<MODE>mode == V2DImode || <MODE>mode == V4DImode)
15169           && !TARGET_AVX512VL))
15170     {
15171       ix86_expand_sse2_abs (operands[0], operands[1]);
15172       DONE;
15173     }
15176 (define_insn "abs<mode>2"
15177   [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
15178         (abs:MMXMODEI
15179           (match_operand:MMXMODEI 1 "nonimmediate_operand" "ym")))]
15180   "TARGET_SSSE3"
15181   "pabs<mmxvecsize>\t{%1, %0|%0, %1}";
15182   [(set_attr "type" "sselog1")
15183    (set_attr "prefix_rep" "0")
15184    (set_attr "prefix_extra" "1")
15185    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15186    (set_attr "mode" "DI")])
15188 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15190 ;; AMD SSE4A instructions
15192 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15194 (define_insn "sse4a_movnt<mode>"
15195   [(set (match_operand:MODEF 0 "memory_operand" "=m")
15196         (unspec:MODEF
15197           [(match_operand:MODEF 1 "register_operand" "x")]
15198           UNSPEC_MOVNT))]
15199   "TARGET_SSE4A"
15200   "movnt<ssemodesuffix>\t{%1, %0|%0, %1}"
15201   [(set_attr "type" "ssemov")
15202    (set_attr "mode" "<MODE>")])
15204 (define_insn "sse4a_vmmovnt<mode>"
15205   [(set (match_operand:<ssescalarmode> 0 "memory_operand" "=m")
15206         (unspec:<ssescalarmode>
15207           [(vec_select:<ssescalarmode>
15208              (match_operand:VF_128 1 "register_operand" "x")
15209              (parallel [(const_int 0)]))]
15210           UNSPEC_MOVNT))]
15211   "TARGET_SSE4A"
15212   "movnt<ssescalarmodesuffix>\t{%1, %0|%0, %1}"
15213   [(set_attr "type" "ssemov")
15214    (set_attr "mode" "<ssescalarmode>")])
15216 (define_insn "sse4a_extrqi"
15217   [(set (match_operand:V2DI 0 "register_operand" "=x")
15218         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
15219                       (match_operand 2 "const_0_to_255_operand")
15220                       (match_operand 3 "const_0_to_255_operand")]
15221                      UNSPEC_EXTRQI))]
15222   "TARGET_SSE4A"
15223   "extrq\t{%3, %2, %0|%0, %2, %3}"
15224   [(set_attr "type" "sse")
15225    (set_attr "prefix_data16" "1")
15226    (set_attr "length_immediate" "2")
15227    (set_attr "mode" "TI")])
15229 (define_insn "sse4a_extrq"
15230   [(set (match_operand:V2DI 0 "register_operand" "=x")
15231         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
15232                       (match_operand:V16QI 2 "register_operand" "x")]
15233                      UNSPEC_EXTRQ))]
15234   "TARGET_SSE4A"
15235   "extrq\t{%2, %0|%0, %2}"
15236   [(set_attr "type" "sse")
15237    (set_attr "prefix_data16" "1")
15238    (set_attr "mode" "TI")])
15240 (define_insn "sse4a_insertqi"
15241   [(set (match_operand:V2DI 0 "register_operand" "=x")
15242         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
15243                       (match_operand:V2DI 2 "register_operand" "x")
15244                       (match_operand 3 "const_0_to_255_operand")
15245                       (match_operand 4 "const_0_to_255_operand")]
15246                      UNSPEC_INSERTQI))]
15247   "TARGET_SSE4A"
15248   "insertq\t{%4, %3, %2, %0|%0, %2, %3, %4}"
15249   [(set_attr "type" "sseins")
15250    (set_attr "prefix_data16" "0")
15251    (set_attr "prefix_rep" "1")
15252    (set_attr "length_immediate" "2")
15253    (set_attr "mode" "TI")])
15255 (define_insn "sse4a_insertq"
15256   [(set (match_operand:V2DI 0 "register_operand" "=x")
15257         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
15258                       (match_operand:V2DI 2 "register_operand" "x")]
15259                      UNSPEC_INSERTQ))]
15260   "TARGET_SSE4A"
15261   "insertq\t{%2, %0|%0, %2}"
15262   [(set_attr "type" "sseins")
15263    (set_attr "prefix_data16" "0")
15264    (set_attr "prefix_rep" "1")
15265    (set_attr "mode" "TI")])
15267 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15269 ;; Intel SSE4.1 instructions
15271 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15273 ;; Mapping of immediate bits for blend instructions
15274 (define_mode_attr blendbits
15275   [(V8SF "255") (V4SF "15") (V4DF "15") (V2DF "3")])
15277 (define_insn "<sse4_1>_blend<ssemodesuffix><avxsizesuffix>"
15278   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
15279         (vec_merge:VF_128_256
15280           (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
15281           (match_operand:VF_128_256 1 "register_operand" "0,0,x")
15282           (match_operand:SI 3 "const_0_to_<blendbits>_operand")))]
15283   "TARGET_SSE4_1"
15284   "@
15285    blend<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15286    blend<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15287    vblend<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15288   [(set_attr "isa" "noavx,noavx,avx")
15289    (set_attr "type" "ssemov")
15290    (set_attr "length_immediate" "1")
15291    (set_attr "prefix_data16" "1,1,*")
15292    (set_attr "prefix_extra" "1")
15293    (set_attr "prefix" "orig,orig,vex")
15294    (set_attr "mode" "<MODE>")])
15296 (define_insn "<sse4_1>_blendv<ssemodesuffix><avxsizesuffix>"
15297   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
15298         (unspec:VF_128_256
15299           [(match_operand:VF_128_256 1 "register_operand" "0,0,x")
15300            (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
15301            (match_operand:VF_128_256 3 "register_operand" "Yz,Yz,x")]
15302           UNSPEC_BLENDV))]
15303   "TARGET_SSE4_1"
15304   "@
15305    blendv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15306    blendv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15307    vblendv<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15308   [(set_attr "isa" "noavx,noavx,avx")
15309    (set_attr "type" "ssemov")
15310    (set_attr "length_immediate" "1")
15311    (set_attr "prefix_data16" "1,1,*")
15312    (set_attr "prefix_extra" "1")
15313    (set_attr "prefix" "orig,orig,vex")
15314    (set_attr "btver2_decode" "vector,vector,vector") 
15315    (set_attr "mode" "<MODE>")])
15317 (define_insn "<sse4_1>_dp<ssemodesuffix><avxsizesuffix>"
15318   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
15319         (unspec:VF_128_256
15320           [(match_operand:VF_128_256 1 "vector_operand" "%0,0,x")
15321            (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
15322            (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
15323           UNSPEC_DP))]
15324   "TARGET_SSE4_1"
15325   "@
15326    dp<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15327    dp<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15328    vdp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15329   [(set_attr "isa" "noavx,noavx,avx")
15330    (set_attr "type" "ssemul")
15331    (set_attr "length_immediate" "1")
15332    (set_attr "prefix_data16" "1,1,*")
15333    (set_attr "prefix_extra" "1")
15334    (set_attr "prefix" "orig,orig,vex")
15335    (set_attr "btver2_decode" "vector,vector,vector")
15336    (set_attr "znver1_decode" "vector,vector,vector")
15337    (set_attr "mode" "<MODE>")])
15339 ;; Mode attribute used by `vmovntdqa' pattern
15340 (define_mode_attr vi8_sse4_1_avx2_avx512
15341    [(V2DI "sse4_1") (V4DI "avx2") (V8DI "avx512f")])
15343 (define_insn "<vi8_sse4_1_avx2_avx512>_movntdqa"
15344   [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand" "=Yr,*x,v")
15345         (unspec:VI8_AVX2_AVX512F [(match_operand:VI8_AVX2_AVX512F 1 "memory_operand" "m,m,m")]
15346                      UNSPEC_MOVNTDQA))]
15347   "TARGET_SSE4_1"
15348   "%vmovntdqa\t{%1, %0|%0, %1}"
15349   [(set_attr "isa" "noavx,noavx,avx")
15350    (set_attr "type" "ssemov")
15351    (set_attr "prefix_extra" "1,1,*")
15352    (set_attr "prefix" "orig,orig,maybe_evex")
15353    (set_attr "mode" "<sseinsnmode>")])
15355 (define_insn "<sse4_1_avx2>_mpsadbw"
15356   [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
15357         (unspec:VI1_AVX2
15358           [(match_operand:VI1_AVX2 1 "register_operand" "0,0,x")
15359            (match_operand:VI1_AVX2 2 "vector_operand" "YrBm,*xBm,xm")
15360            (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
15361           UNSPEC_MPSADBW))]
15362   "TARGET_SSE4_1"
15363   "@
15364    mpsadbw\t{%3, %2, %0|%0, %2, %3}
15365    mpsadbw\t{%3, %2, %0|%0, %2, %3}
15366    vmpsadbw\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15367   [(set_attr "isa" "noavx,noavx,avx")
15368    (set_attr "type" "sselog1")
15369    (set_attr "length_immediate" "1")
15370    (set_attr "prefix_extra" "1")
15371    (set_attr "prefix" "orig,orig,vex")
15372    (set_attr "btver2_decode" "vector,vector,vector")
15373    (set_attr "znver1_decode" "vector,vector,vector")
15374    (set_attr "mode" "<sseinsnmode>")])
15376 (define_insn "<sse4_1_avx2>_packusdw<mask_name>"
15377   [(set (match_operand:VI2_AVX2 0 "register_operand" "=Yr,*x,x,v")
15378         (vec_concat:VI2_AVX2
15379           (us_truncate:<ssehalfvecmode>
15380             (match_operand:<sseunpackmode> 1 "register_operand" "0,0,x,v"))
15381           (us_truncate:<ssehalfvecmode>
15382             (match_operand:<sseunpackmode> 2 "vector_operand" "YrBm,*xBm,xm,vm"))))]
15383   "TARGET_SSE4_1 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
15384   "@
15385    packusdw\t{%2, %0|%0, %2}
15386    packusdw\t{%2, %0|%0, %2}
15387    vpackusdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
15388    vpackusdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
15389   [(set_attr "isa" "noavx,noavx,avx,avx512bw")
15390    (set_attr "type" "sselog")
15391    (set_attr "prefix_extra" "1")
15392    (set_attr "prefix" "orig,orig,<mask_prefix>,evex")
15393    (set_attr "mode" "<sseinsnmode>")])
15395 (define_insn "<sse4_1_avx2>_pblendvb"
15396   [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
15397         (unspec:VI1_AVX2
15398           [(match_operand:VI1_AVX2 1 "register_operand"  "0,0,x")
15399            (match_operand:VI1_AVX2 2 "vector_operand" "YrBm,*xBm,xm")
15400            (match_operand:VI1_AVX2 3 "register_operand" "Yz,Yz,x")]
15401           UNSPEC_BLENDV))]
15402   "TARGET_SSE4_1"
15403   "@
15404    pblendvb\t{%3, %2, %0|%0, %2, %3}
15405    pblendvb\t{%3, %2, %0|%0, %2, %3}
15406    vpblendvb\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15407   [(set_attr "isa" "noavx,noavx,avx")
15408    (set_attr "type" "ssemov")
15409    (set_attr "prefix_extra" "1")
15410    (set_attr "length_immediate" "*,*,1")
15411    (set_attr "prefix" "orig,orig,vex")
15412    (set_attr "btver2_decode" "vector,vector,vector")
15413    (set_attr "mode" "<sseinsnmode>")])
15415 (define_insn "sse4_1_pblendw"
15416   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,x")
15417         (vec_merge:V8HI
15418           (match_operand:V8HI 2 "vector_operand" "YrBm,*xBm,xm")
15419           (match_operand:V8HI 1 "register_operand" "0,0,x")
15420           (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")))]
15421   "TARGET_SSE4_1"
15422   "@
15423    pblendw\t{%3, %2, %0|%0, %2, %3}
15424    pblendw\t{%3, %2, %0|%0, %2, %3}
15425    vpblendw\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15426   [(set_attr "isa" "noavx,noavx,avx")
15427    (set_attr "type" "ssemov")
15428    (set_attr "prefix_extra" "1")
15429    (set_attr "length_immediate" "1")
15430    (set_attr "prefix" "orig,orig,vex")
15431    (set_attr "mode" "TI")])
15433 ;; The builtin uses an 8-bit immediate.  Expand that.
15434 (define_expand "avx2_pblendw"
15435   [(set (match_operand:V16HI 0 "register_operand")
15436         (vec_merge:V16HI
15437           (match_operand:V16HI 2 "nonimmediate_operand")
15438           (match_operand:V16HI 1 "register_operand")
15439           (match_operand:SI 3 "const_0_to_255_operand")))]
15440   "TARGET_AVX2"
15442   HOST_WIDE_INT val = INTVAL (operands[3]) & 0xff;
15443   operands[3] = GEN_INT (val << 8 | val);
15446 (define_insn "*avx2_pblendw"
15447   [(set (match_operand:V16HI 0 "register_operand" "=x")
15448         (vec_merge:V16HI
15449           (match_operand:V16HI 2 "nonimmediate_operand" "xm")
15450           (match_operand:V16HI 1 "register_operand" "x")
15451           (match_operand:SI 3 "avx2_pblendw_operand" "n")))]
15452   "TARGET_AVX2"
15454   operands[3] = GEN_INT (INTVAL (operands[3]) & 0xff);
15455   return "vpblendw\t{%3, %2, %1, %0|%0, %1, %2, %3}";
15457   [(set_attr "type" "ssemov")
15458    (set_attr "prefix_extra" "1")
15459    (set_attr "length_immediate" "1")
15460    (set_attr "prefix" "vex")
15461    (set_attr "mode" "OI")])
15463 (define_insn "avx2_pblendd<mode>"
15464   [(set (match_operand:VI4_AVX2 0 "register_operand" "=x")
15465         (vec_merge:VI4_AVX2
15466           (match_operand:VI4_AVX2 2 "nonimmediate_operand" "xm")
15467           (match_operand:VI4_AVX2 1 "register_operand" "x")
15468           (match_operand:SI 3 "const_0_to_255_operand" "n")))]
15469   "TARGET_AVX2"
15470   "vpblendd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15471   [(set_attr "type" "ssemov")
15472    (set_attr "prefix_extra" "1")
15473    (set_attr "length_immediate" "1")
15474    (set_attr "prefix" "vex")
15475    (set_attr "mode" "<sseinsnmode>")])
15477 (define_insn "sse4_1_phminposuw"
15478   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,x")
15479         (unspec:V8HI [(match_operand:V8HI 1 "vector_operand" "YrBm,*xBm,xm")]
15480                      UNSPEC_PHMINPOSUW))]
15481   "TARGET_SSE4_1"
15482   "%vphminposuw\t{%1, %0|%0, %1}"
15483   [(set_attr "isa" "noavx,noavx,avx")
15484    (set_attr "type" "sselog1")
15485    (set_attr "prefix_extra" "1")
15486    (set_attr "prefix" "orig,orig,vex")
15487    (set_attr "mode" "TI")])
15489 (define_insn "avx2_<code>v16qiv16hi2<mask_name>"
15490   [(set (match_operand:V16HI 0 "register_operand" "=v")
15491         (any_extend:V16HI
15492           (match_operand:V16QI 1 "nonimmediate_operand" "vm")))]
15493   "TARGET_AVX2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
15494   "vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15495   [(set_attr "type" "ssemov")
15496    (set_attr "prefix_extra" "1")
15497    (set_attr "prefix" "maybe_evex")
15498    (set_attr "mode" "OI")])
15500 (define_insn "avx512bw_<code>v32qiv32hi2<mask_name>"
15501   [(set (match_operand:V32HI 0 "register_operand" "=v")
15502         (any_extend:V32HI
15503           (match_operand:V32QI 1 "nonimmediate_operand" "vm")))]
15504   "TARGET_AVX512BW"
15505   "vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15506   [(set_attr "type" "ssemov")
15507    (set_attr "prefix_extra" "1")
15508    (set_attr "prefix" "evex")
15509    (set_attr "mode" "XI")])
15511 (define_insn "sse4_1_<code>v8qiv8hi2<mask_name>"
15512   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,v")
15513         (any_extend:V8HI
15514           (vec_select:V8QI
15515             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15516             (parallel [(const_int 0) (const_int 1)
15517                        (const_int 2) (const_int 3)
15518                        (const_int 4) (const_int 5)
15519                        (const_int 6) (const_int 7)]))))]
15520   "TARGET_SSE4_1 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
15521   "%vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15522   [(set_attr "isa" "noavx,noavx,avx")
15523    (set_attr "type" "ssemov")
15524    (set_attr "prefix_extra" "1")
15525    (set_attr "prefix" "orig,orig,maybe_evex")
15526    (set_attr "mode" "TI")])
15528 (define_insn "<mask_codefor>avx512f_<code>v16qiv16si2<mask_name>"
15529   [(set (match_operand:V16SI 0 "register_operand" "=v")
15530         (any_extend:V16SI
15531           (match_operand:V16QI 1 "nonimmediate_operand" "vm")))]
15532   "TARGET_AVX512F"
15533   "vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15534   [(set_attr "type" "ssemov")
15535    (set_attr "prefix" "evex")
15536    (set_attr "mode" "XI")])
15538 (define_insn "avx2_<code>v8qiv8si2<mask_name>"
15539   [(set (match_operand:V8SI 0 "register_operand" "=v")
15540         (any_extend:V8SI
15541           (vec_select:V8QI
15542             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
15543             (parallel [(const_int 0) (const_int 1)
15544                        (const_int 2) (const_int 3)
15545                        (const_int 4) (const_int 5)
15546                        (const_int 6) (const_int 7)]))))]
15547   "TARGET_AVX2 && <mask_avx512vl_condition>"
15548   "vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15549   [(set_attr "type" "ssemov")
15550    (set_attr "prefix_extra" "1")
15551    (set_attr "prefix" "maybe_evex")
15552    (set_attr "mode" "OI")])
15554 (define_insn "sse4_1_<code>v4qiv4si2<mask_name>"
15555   [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
15556         (any_extend:V4SI
15557           (vec_select:V4QI
15558             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15559             (parallel [(const_int 0) (const_int 1)
15560                        (const_int 2) (const_int 3)]))))]
15561   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15562   "%vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15563   [(set_attr "isa" "noavx,noavx,avx")
15564    (set_attr "type" "ssemov")
15565    (set_attr "prefix_extra" "1")
15566    (set_attr "prefix" "orig,orig,maybe_evex")
15567    (set_attr "mode" "TI")])
15569 (define_insn "avx512f_<code>v16hiv16si2<mask_name>"
15570   [(set (match_operand:V16SI 0 "register_operand" "=v")
15571         (any_extend:V16SI
15572           (match_operand:V16HI 1 "nonimmediate_operand" "vm")))]
15573   "TARGET_AVX512F"
15574   "vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15575   [(set_attr "type" "ssemov")
15576    (set_attr "prefix" "evex")
15577    (set_attr "mode" "XI")])
15579 (define_insn "avx2_<code>v8hiv8si2<mask_name>"
15580   [(set (match_operand:V8SI 0 "register_operand" "=v")
15581         (any_extend:V8SI
15582             (match_operand:V8HI 1 "nonimmediate_operand" "vm")))]
15583   "TARGET_AVX2 && <mask_avx512vl_condition>"
15584   "vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15585   [(set_attr "type" "ssemov")
15586    (set_attr "prefix_extra" "1")
15587    (set_attr "prefix" "maybe_evex")
15588    (set_attr "mode" "OI")])
15590 (define_insn "sse4_1_<code>v4hiv4si2<mask_name>"
15591   [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
15592         (any_extend:V4SI
15593           (vec_select:V4HI
15594             (match_operand:V8HI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15595             (parallel [(const_int 0) (const_int 1)
15596                        (const_int 2) (const_int 3)]))))]
15597   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15598   "%vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15599   [(set_attr "isa" "noavx,noavx,avx")
15600    (set_attr "type" "ssemov")
15601    (set_attr "prefix_extra" "1")
15602    (set_attr "prefix" "orig,orig,maybe_evex")
15603    (set_attr "mode" "TI")])
15605 (define_insn "avx512f_<code>v8qiv8di2<mask_name>"
15606   [(set (match_operand:V8DI 0 "register_operand" "=v")
15607         (any_extend:V8DI
15608           (vec_select:V8QI
15609             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
15610             (parallel [(const_int 0) (const_int 1)
15611                        (const_int 2) (const_int 3)
15612                        (const_int 4) (const_int 5)
15613                        (const_int 6) (const_int 7)]))))]
15614   "TARGET_AVX512F"
15615   "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15616   [(set_attr "type" "ssemov")
15617    (set_attr "prefix" "evex")
15618    (set_attr "mode" "XI")])
15620 (define_insn "avx2_<code>v4qiv4di2<mask_name>"
15621   [(set (match_operand:V4DI 0 "register_operand" "=v")
15622         (any_extend:V4DI
15623           (vec_select:V4QI
15624             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
15625             (parallel [(const_int 0) (const_int 1)
15626                        (const_int 2) (const_int 3)]))))]
15627   "TARGET_AVX2 && <mask_avx512vl_condition>"
15628   "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15629   [(set_attr "type" "ssemov")
15630    (set_attr "prefix_extra" "1")
15631    (set_attr "prefix" "maybe_evex")
15632    (set_attr "mode" "OI")])
15634 (define_insn "sse4_1_<code>v2qiv2di2<mask_name>"
15635   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
15636         (any_extend:V2DI
15637           (vec_select:V2QI
15638             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15639             (parallel [(const_int 0) (const_int 1)]))))]
15640   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15641   "%vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %w1}"
15642   [(set_attr "isa" "noavx,noavx,avx")
15643    (set_attr "type" "ssemov")
15644    (set_attr "prefix_extra" "1")
15645    (set_attr "prefix" "orig,orig,maybe_evex")
15646    (set_attr "mode" "TI")])
15648 (define_insn "avx512f_<code>v8hiv8di2<mask_name>"
15649   [(set (match_operand:V8DI 0 "register_operand" "=v")
15650         (any_extend:V8DI
15651           (match_operand:V8HI 1 "nonimmediate_operand" "vm")))]
15652   "TARGET_AVX512F"
15653   "vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15654   [(set_attr "type" "ssemov")
15655    (set_attr "prefix" "evex")
15656    (set_attr "mode" "XI")])
15658 (define_insn "avx2_<code>v4hiv4di2<mask_name>"
15659   [(set (match_operand:V4DI 0 "register_operand" "=v")
15660         (any_extend:V4DI
15661           (vec_select:V4HI
15662             (match_operand:V8HI 1 "nonimmediate_operand" "vm")
15663             (parallel [(const_int 0) (const_int 1)
15664                        (const_int 2) (const_int 3)]))))]
15665   "TARGET_AVX2 && <mask_avx512vl_condition>"
15666   "vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15667   [(set_attr "type" "ssemov")
15668    (set_attr "prefix_extra" "1")
15669    (set_attr "prefix" "maybe_evex")
15670    (set_attr "mode" "OI")])
15672 (define_insn "sse4_1_<code>v2hiv2di2<mask_name>"
15673   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
15674         (any_extend:V2DI
15675           (vec_select:V2HI
15676             (match_operand:V8HI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15677             (parallel [(const_int 0) (const_int 1)]))))]
15678   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15679   "%vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15680   [(set_attr "isa" "noavx,noavx,avx")
15681    (set_attr "type" "ssemov")
15682    (set_attr "prefix_extra" "1")
15683    (set_attr "prefix" "orig,orig,maybe_evex")
15684    (set_attr "mode" "TI")])
15686 (define_insn "avx512f_<code>v8siv8di2<mask_name>"
15687   [(set (match_operand:V8DI 0 "register_operand" "=v")
15688         (any_extend:V8DI
15689           (match_operand:V8SI 1 "nonimmediate_operand" "vm")))]
15690   "TARGET_AVX512F"
15691   "vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15692   [(set_attr "type" "ssemov")
15693    (set_attr "prefix" "evex")
15694    (set_attr "mode" "XI")])
15696 (define_insn "avx2_<code>v4siv4di2<mask_name>"
15697   [(set (match_operand:V4DI 0 "register_operand" "=v")
15698         (any_extend:V4DI
15699             (match_operand:V4SI 1 "nonimmediate_operand" "vm")))]
15700   "TARGET_AVX2 && <mask_avx512vl_condition>"
15701   "vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15702   [(set_attr "type" "ssemov")
15703    (set_attr "prefix" "maybe_evex")
15704    (set_attr "prefix_extra" "1")
15705    (set_attr "mode" "OI")])
15707 (define_insn "sse4_1_<code>v2siv2di2<mask_name>"
15708   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
15709         (any_extend:V2DI
15710           (vec_select:V2SI
15711             (match_operand:V4SI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15712             (parallel [(const_int 0) (const_int 1)]))))]
15713   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15714   "%vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15715   [(set_attr "isa" "noavx,noavx,avx")
15716    (set_attr "type" "ssemov")
15717    (set_attr "prefix_extra" "1")
15718    (set_attr "prefix" "orig,orig,maybe_evex")
15719    (set_attr "mode" "TI")])
15721 ;; ptestps/ptestpd are very similar to comiss and ucomiss when
15722 ;; setting FLAGS_REG. But it is not a really compare instruction.
15723 (define_insn "avx_vtest<ssemodesuffix><avxsizesuffix>"
15724   [(set (reg:CC FLAGS_REG)
15725         (unspec:CC [(match_operand:VF_128_256 0 "register_operand" "x")
15726                     (match_operand:VF_128_256 1 "nonimmediate_operand" "xm")]
15727                    UNSPEC_VTESTP))]
15728   "TARGET_AVX"
15729   "vtest<ssemodesuffix>\t{%1, %0|%0, %1}"
15730   [(set_attr "type" "ssecomi")
15731    (set_attr "prefix_extra" "1")
15732    (set_attr "prefix" "vex")
15733    (set_attr "mode" "<MODE>")])
15735 ;; ptest is very similar to comiss and ucomiss when setting FLAGS_REG.
15736 ;; But it is not a really compare instruction.
15737 (define_insn "<sse4_1>_ptest<mode>"
15738   [(set (reg:CC FLAGS_REG)
15739         (unspec:CC [(match_operand:V_AVX 0 "register_operand" "Yr, *x, x")
15740                     (match_operand:V_AVX 1 "vector_operand" "YrBm, *xBm, xm")]
15741                    UNSPEC_PTEST))]
15742   "TARGET_SSE4_1"
15743   "%vptest\t{%1, %0|%0, %1}"
15744   [(set_attr "isa" "noavx,noavx,avx")
15745    (set_attr "type" "ssecomi")
15746    (set_attr "prefix_extra" "1")
15747    (set_attr "prefix" "orig,orig,vex")
15748    (set (attr "btver2_decode")
15749      (if_then_else
15750        (match_test "<sseinsnmode>mode==OImode")
15751      (const_string "vector")
15752      (const_string "*")))
15753    (set_attr "mode" "<sseinsnmode>")])
15755 (define_insn "ptesttf2"
15756   [(set (reg:CC FLAGS_REG)
15757         (unspec:CC [(match_operand:TF 0 "register_operand" "Yr, *x, x")
15758                     (match_operand:TF 1 "vector_operand" "YrBm, *xBm, xm")]
15759                    UNSPEC_PTEST))]
15760   "TARGET_SSE4_1"
15761   "%vptest\t{%1, %0|%0, %1}"
15762   [(set_attr "isa" "noavx,noavx,avx")
15763    (set_attr "type" "ssecomi")
15764    (set_attr "prefix_extra" "1")
15765    (set_attr "prefix" "orig,orig,vex")
15766    (set_attr "mode" "TI")])
15768 (define_insn "<sse4_1>_round<ssemodesuffix><avxsizesuffix>"
15769   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
15770         (unspec:VF_128_256
15771           [(match_operand:VF_128_256 1 "vector_operand" "YrBm,*xBm,xm")
15772            (match_operand:SI 2 "const_0_to_15_operand" "n,n,n")]
15773           UNSPEC_ROUND))]
15774   "TARGET_SSE4_1"
15775   "%vround<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
15776   [(set_attr "isa" "noavx,noavx,avx")
15777    (set_attr "type" "ssecvt")
15778    (set_attr "prefix_data16" "1,1,*")
15779    (set_attr "prefix_extra" "1")
15780    (set_attr "length_immediate" "1")
15781    (set_attr "prefix" "orig,orig,vex")
15782    (set_attr "mode" "<MODE>")])
15784 (define_expand "<sse4_1>_round<ssemodesuffix>_sfix<avxsizesuffix>"
15785   [(match_operand:<sseintvecmode> 0 "register_operand")
15786    (match_operand:VF1_128_256 1 "vector_operand")
15787    (match_operand:SI 2 "const_0_to_15_operand")]
15788   "TARGET_SSE4_1"
15790   rtx tmp = gen_reg_rtx (<MODE>mode);
15792   emit_insn
15793     (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp, operands[1],
15794                                                        operands[2]));
15795   emit_insn
15796     (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
15797   DONE;
15800 (define_expand "avx512f_round<castmode>512"
15801   [(match_operand:VF_512 0 "register_operand")
15802    (match_operand:VF_512 1 "nonimmediate_operand")
15803    (match_operand:SI 2 "const_0_to_15_operand")]
15804   "TARGET_AVX512F"
15806   emit_insn (gen_avx512f_rndscale<mode> (operands[0], operands[1], operands[2]));
15807   DONE;
15810 (define_expand "avx512f_roundps512_sfix"
15811   [(match_operand:V16SI 0 "register_operand")
15812    (match_operand:V16SF 1 "nonimmediate_operand")
15813    (match_operand:SI 2 "const_0_to_15_operand")]
15814   "TARGET_AVX512F"
15816   rtx tmp = gen_reg_rtx (V16SFmode);
15817   emit_insn (gen_avx512f_rndscalev16sf (tmp, operands[1], operands[2]));
15818   emit_insn (gen_fix_truncv16sfv16si2 (operands[0], tmp));
15819   DONE;
15822 (define_expand "<sse4_1>_round<ssemodesuffix>_vec_pack_sfix<avxsizesuffix>"
15823   [(match_operand:<ssepackfltmode> 0 "register_operand")
15824    (match_operand:VF2 1 "vector_operand")
15825    (match_operand:VF2 2 "vector_operand")
15826    (match_operand:SI 3 "const_0_to_15_operand")]
15827   "TARGET_SSE4_1"
15829   rtx tmp0, tmp1;
15831   if (<MODE>mode == V2DFmode
15832       && TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
15833     {
15834       rtx tmp2 = gen_reg_rtx (V4DFmode);
15836       tmp0 = gen_reg_rtx (V4DFmode);
15837       tmp1 = force_reg (V2DFmode, operands[1]);
15839       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
15840       emit_insn (gen_avx_roundpd256 (tmp2, tmp0, operands[3]));
15841       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp2));
15842     }
15843   else
15844     {
15845       tmp0 = gen_reg_rtx (<MODE>mode);
15846       tmp1 = gen_reg_rtx (<MODE>mode);
15848       emit_insn
15849        (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp0, operands[1],
15850                                                           operands[3]));
15851       emit_insn
15852        (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp1, operands[2],
15853                                                           operands[3]));
15854       emit_insn
15855        (gen_vec_pack_sfix_trunc_<mode> (operands[0], tmp0, tmp1));
15856     }
15857   DONE;
15860 (define_insn "sse4_1_round<ssescalarmodesuffix>"
15861   [(set (match_operand:VF_128 0 "register_operand" "=Yr,*x,x,v")
15862         (vec_merge:VF_128
15863           (unspec:VF_128
15864             [(match_operand:VF_128 2 "register_operand" "Yr,*x,x,v")
15865              (match_operand:SI 3 "const_0_to_15_operand" "n,n,n,n")]
15866             UNSPEC_ROUND)
15867           (match_operand:VF_128 1 "register_operand" "0,0,x,v")
15868           (const_int 1)))]
15869   "TARGET_SSE4_1"
15870   "@
15871    round<ssescalarmodesuffix>\t{%3, %2, %0|%0, %2, %3}
15872    round<ssescalarmodesuffix>\t{%3, %2, %0|%0, %2, %3}
15873    vround<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
15874    vrndscale<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15875   [(set_attr "isa" "noavx,noavx,avx,avx512f")
15876    (set_attr "type" "ssecvt")
15877    (set_attr "length_immediate" "1")
15878    (set_attr "prefix_data16" "1,1,*,*")
15879    (set_attr "prefix_extra" "1")
15880    (set_attr "prefix" "orig,orig,vex,evex")
15881    (set_attr "mode" "<MODE>")])
15883 (define_expand "round<mode>2"
15884   [(set (match_dup 3)
15885         (plus:VF
15886           (match_operand:VF 1 "register_operand")
15887           (match_dup 2)))
15888    (set (match_operand:VF 0 "register_operand")
15889         (unspec:VF
15890           [(match_dup 3) (match_dup 4)]
15891           UNSPEC_ROUND))]
15892   "TARGET_SSE4_1 && !flag_trapping_math"
15894   machine_mode scalar_mode;
15895   const struct real_format *fmt;
15896   REAL_VALUE_TYPE pred_half, half_minus_pred_half;
15897   rtx half, vec_half;
15899   scalar_mode = GET_MODE_INNER (<MODE>mode);
15901   /* load nextafter (0.5, 0.0) */
15902   fmt = REAL_MODE_FORMAT (scalar_mode);
15903   real_2expN (&half_minus_pred_half, -(fmt->p) - 1, scalar_mode);
15904   real_arithmetic (&pred_half, MINUS_EXPR, &dconsthalf, &half_minus_pred_half);
15905   half = const_double_from_real_value (pred_half, scalar_mode);
15907   vec_half = ix86_build_const_vector (<MODE>mode, true, half);
15908   vec_half = force_reg (<MODE>mode, vec_half);
15910   operands[2] = gen_reg_rtx (<MODE>mode);
15911   emit_insn (gen_copysign<mode>3 (operands[2], vec_half, operands[1]));
15913   operands[3] = gen_reg_rtx (<MODE>mode);
15914   operands[4] = GEN_INT (ROUND_TRUNC);
15917 (define_expand "round<mode>2_sfix"
15918   [(match_operand:<sseintvecmode> 0 "register_operand")
15919    (match_operand:VF1 1 "register_operand")]
15920   "TARGET_SSE4_1 && !flag_trapping_math"
15922   rtx tmp = gen_reg_rtx (<MODE>mode);
15924   emit_insn (gen_round<mode>2 (tmp, operands[1]));
15926   emit_insn
15927     (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
15928   DONE;
15931 (define_expand "round<mode>2_vec_pack_sfix"
15932   [(match_operand:<ssepackfltmode> 0 "register_operand")
15933    (match_operand:VF2 1 "register_operand")
15934    (match_operand:VF2 2 "register_operand")]
15935   "TARGET_SSE4_1 && !flag_trapping_math"
15937   rtx tmp0, tmp1;
15939   if (<MODE>mode == V2DFmode
15940       && TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
15941     {
15942       rtx tmp2 = gen_reg_rtx (V4DFmode);
15944       tmp0 = gen_reg_rtx (V4DFmode);
15945       tmp1 = force_reg (V2DFmode, operands[1]);
15947       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
15948       emit_insn (gen_roundv4df2 (tmp2, tmp0));
15949       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp2));
15950     }
15951   else
15952     {
15953       tmp0 = gen_reg_rtx (<MODE>mode);
15954       tmp1 = gen_reg_rtx (<MODE>mode);
15956       emit_insn (gen_round<mode>2 (tmp0, operands[1]));
15957       emit_insn (gen_round<mode>2 (tmp1, operands[2]));
15959       emit_insn
15960        (gen_vec_pack_sfix_trunc_<mode> (operands[0], tmp0, tmp1));
15961     }
15962   DONE;
15965 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15967 ;; Intel SSE4.2 string/text processing instructions
15969 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15971 (define_insn_and_split "sse4_2_pcmpestr"
15972   [(set (match_operand:SI 0 "register_operand" "=c,c")
15973         (unspec:SI
15974           [(match_operand:V16QI 2 "register_operand" "x,x")
15975            (match_operand:SI 3 "register_operand" "a,a")
15976            (match_operand:V16QI 4 "nonimmediate_operand" "x,m")
15977            (match_operand:SI 5 "register_operand" "d,d")
15978            (match_operand:SI 6 "const_0_to_255_operand" "n,n")]
15979           UNSPEC_PCMPESTR))
15980    (set (match_operand:V16QI 1 "register_operand" "=Yz,Yz")
15981         (unspec:V16QI
15982           [(match_dup 2)
15983            (match_dup 3)
15984            (match_dup 4)
15985            (match_dup 5)
15986            (match_dup 6)]
15987           UNSPEC_PCMPESTR))
15988    (set (reg:CC FLAGS_REG)
15989         (unspec:CC
15990           [(match_dup 2)
15991            (match_dup 3)
15992            (match_dup 4)
15993            (match_dup 5)
15994            (match_dup 6)]
15995           UNSPEC_PCMPESTR))]
15996   "TARGET_SSE4_2
15997    && can_create_pseudo_p ()"
15998   "#"
15999   "&& 1"
16000   [(const_int 0)]
16002   int ecx = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[0]));
16003   int xmm0 = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[1]));
16004   int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
16006   if (ecx)
16007     emit_insn (gen_sse4_2_pcmpestri (operands[0], operands[2],
16008                                      operands[3], operands[4],
16009                                      operands[5], operands[6]));
16010   if (xmm0)
16011     emit_insn (gen_sse4_2_pcmpestrm (operands[1], operands[2],
16012                                      operands[3], operands[4],
16013                                      operands[5], operands[6]));
16014   if (flags && !(ecx || xmm0))
16015     emit_insn (gen_sse4_2_pcmpestr_cconly (NULL, NULL,
16016                                            operands[2], operands[3],
16017                                            operands[4], operands[5],
16018                                            operands[6]));
16019   if (!(flags || ecx || xmm0))
16020     emit_note (NOTE_INSN_DELETED);
16022   DONE;
16024   [(set_attr "type" "sselog")
16025    (set_attr "prefix_data16" "1")
16026    (set_attr "prefix_extra" "1")
16027    (set_attr "length_immediate" "1")
16028    (set_attr "memory" "none,load")
16029    (set_attr "mode" "TI")])
16031 (define_insn "sse4_2_pcmpestri"
16032   [(set (match_operand:SI 0 "register_operand" "=c,c")
16033         (unspec:SI
16034           [(match_operand:V16QI 1 "register_operand" "x,x")
16035            (match_operand:SI 2 "register_operand" "a,a")
16036            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
16037            (match_operand:SI 4 "register_operand" "d,d")
16038            (match_operand:SI 5 "const_0_to_255_operand" "n,n")]
16039           UNSPEC_PCMPESTR))
16040    (set (reg:CC FLAGS_REG)
16041         (unspec:CC
16042           [(match_dup 1)
16043            (match_dup 2)
16044            (match_dup 3)
16045            (match_dup 4)
16046            (match_dup 5)]
16047           UNSPEC_PCMPESTR))]
16048   "TARGET_SSE4_2"
16049   "%vpcmpestri\t{%5, %3, %1|%1, %3, %5}"
16050   [(set_attr "type" "sselog")
16051    (set_attr "prefix_data16" "1")
16052    (set_attr "prefix_extra" "1")
16053    (set_attr "prefix" "maybe_vex")
16054    (set_attr "length_immediate" "1")
16055    (set_attr "btver2_decode" "vector")
16056    (set_attr "memory" "none,load")
16057    (set_attr "mode" "TI")])
16059 (define_insn "sse4_2_pcmpestrm"
16060   [(set (match_operand:V16QI 0 "register_operand" "=Yz,Yz")
16061         (unspec:V16QI
16062           [(match_operand:V16QI 1 "register_operand" "x,x")
16063            (match_operand:SI 2 "register_operand" "a,a")
16064            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
16065            (match_operand:SI 4 "register_operand" "d,d")
16066            (match_operand:SI 5 "const_0_to_255_operand" "n,n")]
16067           UNSPEC_PCMPESTR))
16068    (set (reg:CC FLAGS_REG)
16069         (unspec:CC
16070           [(match_dup 1)
16071            (match_dup 2)
16072            (match_dup 3)
16073            (match_dup 4)
16074            (match_dup 5)]
16075           UNSPEC_PCMPESTR))]
16076   "TARGET_SSE4_2"
16077   "%vpcmpestrm\t{%5, %3, %1|%1, %3, %5}"
16078   [(set_attr "type" "sselog")
16079    (set_attr "prefix_data16" "1")
16080    (set_attr "prefix_extra" "1")
16081    (set_attr "length_immediate" "1")
16082    (set_attr "prefix" "maybe_vex")
16083    (set_attr "btver2_decode" "vector")
16084    (set_attr "memory" "none,load")
16085    (set_attr "mode" "TI")])
16087 (define_insn "sse4_2_pcmpestr_cconly"
16088   [(set (reg:CC FLAGS_REG)
16089         (unspec:CC
16090           [(match_operand:V16QI 2 "register_operand" "x,x,x,x")
16091            (match_operand:SI 3 "register_operand" "a,a,a,a")
16092            (match_operand:V16QI 4 "nonimmediate_operand" "x,m,x,m")
16093            (match_operand:SI 5 "register_operand" "d,d,d,d")
16094            (match_operand:SI 6 "const_0_to_255_operand" "n,n,n,n")]
16095           UNSPEC_PCMPESTR))
16096    (clobber (match_scratch:V16QI 0 "=Yz,Yz,X,X"))
16097    (clobber (match_scratch:SI    1 "= X, X,c,c"))]
16098   "TARGET_SSE4_2"
16099   "@
16100    %vpcmpestrm\t{%6, %4, %2|%2, %4, %6}
16101    %vpcmpestrm\t{%6, %4, %2|%2, %4, %6}
16102    %vpcmpestri\t{%6, %4, %2|%2, %4, %6}
16103    %vpcmpestri\t{%6, %4, %2|%2, %4, %6}"
16104   [(set_attr "type" "sselog")
16105    (set_attr "prefix_data16" "1")
16106    (set_attr "prefix_extra" "1")
16107    (set_attr "length_immediate" "1")
16108    (set_attr "memory" "none,load,none,load")
16109    (set_attr "btver2_decode" "vector,vector,vector,vector") 
16110    (set_attr "prefix" "maybe_vex")
16111    (set_attr "mode" "TI")])
16113 (define_insn_and_split "sse4_2_pcmpistr"
16114   [(set (match_operand:SI 0 "register_operand" "=c,c")
16115         (unspec:SI
16116           [(match_operand:V16QI 2 "register_operand" "x,x")
16117            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
16118            (match_operand:SI 4 "const_0_to_255_operand" "n,n")]
16119           UNSPEC_PCMPISTR))
16120    (set (match_operand:V16QI 1 "register_operand" "=Yz,Yz")
16121         (unspec:V16QI
16122           [(match_dup 2)
16123            (match_dup 3)
16124            (match_dup 4)]
16125           UNSPEC_PCMPISTR))
16126    (set (reg:CC FLAGS_REG)
16127         (unspec:CC
16128           [(match_dup 2)
16129            (match_dup 3)
16130            (match_dup 4)]
16131           UNSPEC_PCMPISTR))]
16132   "TARGET_SSE4_2
16133    && can_create_pseudo_p ()"
16134   "#"
16135   "&& 1"
16136   [(const_int 0)]
16138   int ecx = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[0]));
16139   int xmm0 = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[1]));
16140   int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
16142   if (ecx)
16143     emit_insn (gen_sse4_2_pcmpistri (operands[0], operands[2],
16144                                      operands[3], operands[4]));
16145   if (xmm0)
16146     emit_insn (gen_sse4_2_pcmpistrm (operands[1], operands[2],
16147                                      operands[3], operands[4]));
16148   if (flags && !(ecx || xmm0))
16149     emit_insn (gen_sse4_2_pcmpistr_cconly (NULL, NULL,
16150                                            operands[2], operands[3],
16151                                            operands[4]));
16152   if (!(flags || ecx || xmm0))
16153     emit_note (NOTE_INSN_DELETED);
16155   DONE;
16157   [(set_attr "type" "sselog")
16158    (set_attr "prefix_data16" "1")
16159    (set_attr "prefix_extra" "1")
16160    (set_attr "length_immediate" "1")
16161    (set_attr "memory" "none,load")
16162    (set_attr "mode" "TI")])
16164 (define_insn "sse4_2_pcmpistri"
16165   [(set (match_operand:SI 0 "register_operand" "=c,c")
16166         (unspec:SI
16167           [(match_operand:V16QI 1 "register_operand" "x,x")
16168            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
16169            (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
16170           UNSPEC_PCMPISTR))
16171    (set (reg:CC FLAGS_REG)
16172         (unspec:CC
16173           [(match_dup 1)
16174            (match_dup 2)
16175            (match_dup 3)]
16176           UNSPEC_PCMPISTR))]
16177   "TARGET_SSE4_2"
16178   "%vpcmpistri\t{%3, %2, %1|%1, %2, %3}"
16179   [(set_attr "type" "sselog")
16180    (set_attr "prefix_data16" "1")
16181    (set_attr "prefix_extra" "1")
16182    (set_attr "length_immediate" "1")
16183    (set_attr "prefix" "maybe_vex")
16184    (set_attr "memory" "none,load")
16185    (set_attr "btver2_decode" "vector")
16186    (set_attr "mode" "TI")])
16188 (define_insn "sse4_2_pcmpistrm"
16189   [(set (match_operand:V16QI 0 "register_operand" "=Yz,Yz")
16190         (unspec:V16QI
16191           [(match_operand:V16QI 1 "register_operand" "x,x")
16192            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
16193            (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
16194           UNSPEC_PCMPISTR))
16195    (set (reg:CC FLAGS_REG)
16196         (unspec:CC
16197           [(match_dup 1)
16198            (match_dup 2)
16199            (match_dup 3)]
16200           UNSPEC_PCMPISTR))]
16201   "TARGET_SSE4_2"
16202   "%vpcmpistrm\t{%3, %2, %1|%1, %2, %3}"
16203   [(set_attr "type" "sselog")
16204    (set_attr "prefix_data16" "1")
16205    (set_attr "prefix_extra" "1")
16206    (set_attr "length_immediate" "1")
16207    (set_attr "prefix" "maybe_vex")
16208    (set_attr "memory" "none,load")
16209    (set_attr "btver2_decode" "vector")
16210    (set_attr "mode" "TI")])
16212 (define_insn "sse4_2_pcmpistr_cconly"
16213   [(set (reg:CC FLAGS_REG)
16214         (unspec:CC
16215           [(match_operand:V16QI 2 "register_operand" "x,x,x,x")
16216            (match_operand:V16QI 3 "nonimmediate_operand" "x,m,x,m")
16217            (match_operand:SI 4 "const_0_to_255_operand" "n,n,n,n")]
16218           UNSPEC_PCMPISTR))
16219    (clobber (match_scratch:V16QI 0 "=Yz,Yz,X,X"))
16220    (clobber (match_scratch:SI    1 "= X, X,c,c"))]
16221   "TARGET_SSE4_2"
16222   "@
16223    %vpcmpistrm\t{%4, %3, %2|%2, %3, %4}
16224    %vpcmpistrm\t{%4, %3, %2|%2, %3, %4}
16225    %vpcmpistri\t{%4, %3, %2|%2, %3, %4}
16226    %vpcmpistri\t{%4, %3, %2|%2, %3, %4}"
16227   [(set_attr "type" "sselog")
16228    (set_attr "prefix_data16" "1")
16229    (set_attr "prefix_extra" "1")
16230    (set_attr "length_immediate" "1")
16231    (set_attr "memory" "none,load,none,load")
16232    (set_attr "prefix" "maybe_vex")
16233    (set_attr "btver2_decode" "vector,vector,vector,vector")
16234    (set_attr "mode" "TI")])
16236 ;; Packed float variants
16237 (define_mode_attr GATHER_SCATTER_SF_MEM_MODE
16238                       [(V8DI "V8SF") (V16SI "V16SF")])
16240 (define_expand "avx512pf_gatherpf<mode>sf"
16241   [(unspec
16242      [(match_operand:<avx512fmaskmode> 0 "register_operand")
16243       (mem:<GATHER_SCATTER_SF_MEM_MODE>
16244         (match_par_dup 5
16245           [(match_operand 2 "vsib_address_operand")
16246            (match_operand:VI48_512 1 "register_operand")
16247            (match_operand:SI 3 "const1248_operand")]))
16248       (match_operand:SI 4 "const_2_to_3_operand")]
16249      UNSPEC_GATHER_PREFETCH)]
16250   "TARGET_AVX512PF"
16252   operands[5]
16253     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
16254                                         operands[3]), UNSPEC_VSIBADDR);
16257 (define_insn "*avx512pf_gatherpf<mode>sf_mask"
16258   [(unspec
16259      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
16260       (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 5 "vsib_mem_operator"
16261         [(unspec:P
16262            [(match_operand:P 2 "vsib_address_operand" "Tv")
16263             (match_operand:VI48_512 1 "register_operand" "v")
16264             (match_operand:SI 3 "const1248_operand" "n")]
16265            UNSPEC_VSIBADDR)])
16266       (match_operand:SI 4 "const_2_to_3_operand" "n")]
16267      UNSPEC_GATHER_PREFETCH)]
16268   "TARGET_AVX512PF"
16270   switch (INTVAL (operands[4]))
16271     {
16272     case 3:
16273       return "vgatherpf0<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
16274     case 2:
16275       return "vgatherpf1<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
16276     default:
16277       gcc_unreachable ();
16278     }
16280   [(set_attr "type" "sse")
16281    (set_attr "prefix" "evex")
16282    (set_attr "mode" "XI")])
16284 ;; Packed double variants
16285 (define_expand "avx512pf_gatherpf<mode>df"
16286   [(unspec
16287      [(match_operand:<avx512fmaskmode> 0 "register_operand")
16288       (mem:V8DF
16289         (match_par_dup 5
16290           [(match_operand 2 "vsib_address_operand")
16291            (match_operand:VI4_256_8_512 1 "register_operand")
16292            (match_operand:SI 3 "const1248_operand")]))
16293       (match_operand:SI 4 "const_2_to_3_operand")]
16294      UNSPEC_GATHER_PREFETCH)]
16295   "TARGET_AVX512PF"
16297   operands[5]
16298     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
16299                                         operands[3]), UNSPEC_VSIBADDR);
16302 (define_insn "*avx512pf_gatherpf<mode>df_mask"
16303   [(unspec
16304      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
16305       (match_operator:V8DF 5 "vsib_mem_operator"
16306         [(unspec:P
16307            [(match_operand:P 2 "vsib_address_operand" "Tv")
16308             (match_operand:VI4_256_8_512 1 "register_operand" "v")
16309             (match_operand:SI 3 "const1248_operand" "n")]
16310            UNSPEC_VSIBADDR)])
16311       (match_operand:SI 4 "const_2_to_3_operand" "n")]
16312      UNSPEC_GATHER_PREFETCH)]
16313   "TARGET_AVX512PF"
16315   switch (INTVAL (operands[4]))
16316     {
16317     case 3:
16318       return "vgatherpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
16319     case 2:
16320       return "vgatherpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
16321     default:
16322       gcc_unreachable ();
16323     }
16325   [(set_attr "type" "sse")
16326    (set_attr "prefix" "evex")
16327    (set_attr "mode" "XI")])
16329 ;; Packed float variants
16330 (define_expand "avx512pf_scatterpf<mode>sf"
16331   [(unspec
16332      [(match_operand:<avx512fmaskmode> 0 "register_operand")
16333       (mem:<GATHER_SCATTER_SF_MEM_MODE>
16334         (match_par_dup 5
16335           [(match_operand 2 "vsib_address_operand")
16336            (match_operand:VI48_512 1 "register_operand")
16337            (match_operand:SI 3 "const1248_operand")]))
16338       (match_operand:SI 4 "const2367_operand")]
16339      UNSPEC_SCATTER_PREFETCH)]
16340   "TARGET_AVX512PF"
16342   operands[5]
16343     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
16344                                         operands[3]), UNSPEC_VSIBADDR);
16347 (define_insn "*avx512pf_scatterpf<mode>sf_mask"
16348   [(unspec
16349      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
16350       (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 5 "vsib_mem_operator"
16351         [(unspec:P
16352            [(match_operand:P 2 "vsib_address_operand" "Tv")
16353             (match_operand:VI48_512 1 "register_operand" "v")
16354             (match_operand:SI 3 "const1248_operand" "n")]
16355            UNSPEC_VSIBADDR)])
16356       (match_operand:SI 4 "const2367_operand" "n")]
16357      UNSPEC_SCATTER_PREFETCH)]
16358   "TARGET_AVX512PF"
16360   switch (INTVAL (operands[4]))
16361     {
16362     case 3:
16363     case 7:
16364       return "vscatterpf0<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
16365     case 2:
16366     case 6:
16367       return "vscatterpf1<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
16368     default:
16369       gcc_unreachable ();
16370     }
16372   [(set_attr "type" "sse")
16373    (set_attr "prefix" "evex")
16374    (set_attr "mode" "XI")])
16376 ;; Packed double variants
16377 (define_expand "avx512pf_scatterpf<mode>df"
16378   [(unspec
16379      [(match_operand:<avx512fmaskmode> 0 "register_operand")
16380       (mem:V8DF
16381         (match_par_dup 5
16382           [(match_operand 2 "vsib_address_operand")
16383            (match_operand:VI4_256_8_512 1 "register_operand")
16384            (match_operand:SI 3 "const1248_operand")]))
16385       (match_operand:SI 4 "const2367_operand")]
16386      UNSPEC_SCATTER_PREFETCH)]
16387   "TARGET_AVX512PF"
16389   operands[5]
16390     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
16391                                         operands[3]), UNSPEC_VSIBADDR);
16394 (define_insn "*avx512pf_scatterpf<mode>df_mask"
16395   [(unspec
16396      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
16397       (match_operator:V8DF 5 "vsib_mem_operator"
16398         [(unspec:P
16399            [(match_operand:P 2 "vsib_address_operand" "Tv")
16400             (match_operand:VI4_256_8_512 1 "register_operand" "v")
16401             (match_operand:SI 3 "const1248_operand" "n")]
16402            UNSPEC_VSIBADDR)])
16403       (match_operand:SI 4 "const2367_operand" "n")]
16404      UNSPEC_SCATTER_PREFETCH)]
16405   "TARGET_AVX512PF"
16407   switch (INTVAL (operands[4]))
16408     {
16409     case 3:
16410     case 7:
16411       return "vscatterpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
16412     case 2:
16413     case 6:
16414       return "vscatterpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
16415     default:
16416       gcc_unreachable ();
16417     }
16419   [(set_attr "type" "sse")
16420    (set_attr "prefix" "evex")
16421    (set_attr "mode" "XI")])
16423 (define_insn "avx512er_exp2<mode><mask_name><round_saeonly_name>"
16424   [(set (match_operand:VF_512 0 "register_operand" "=v")
16425         (unspec:VF_512
16426           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16427           UNSPEC_EXP2))]
16428   "TARGET_AVX512ER"
16429   "vexp2<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
16430   [(set_attr "prefix" "evex")
16431    (set_attr "type" "sse")
16432    (set_attr "mode" "<MODE>")])
16434 (define_insn "<mask_codefor>avx512er_rcp28<mode><mask_name><round_saeonly_name>"
16435   [(set (match_operand:VF_512 0 "register_operand" "=v")
16436         (unspec:VF_512
16437           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16438           UNSPEC_RCP28))]
16439   "TARGET_AVX512ER"
16440   "vrcp28<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
16441   [(set_attr "prefix" "evex")
16442    (set_attr "type" "sse")
16443    (set_attr "mode" "<MODE>")])
16445 (define_insn "avx512er_vmrcp28<mode><round_saeonly_name>"
16446   [(set (match_operand:VF_128 0 "register_operand" "=v")
16447         (vec_merge:VF_128
16448           (unspec:VF_128
16449             [(match_operand:VF_128 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16450             UNSPEC_RCP28)
16451           (match_operand:VF_128 2 "register_operand" "v")
16452           (const_int 1)))]
16453   "TARGET_AVX512ER"
16454   "vrcp28<ssescalarmodesuffix>\t{<round_saeonly_op3>%1, %2, %0|%0, %2, %<iptr>1<round_saeonly_op3>}"
16455   [(set_attr "length_immediate" "1")
16456    (set_attr "prefix" "evex")
16457    (set_attr "type" "sse")
16458    (set_attr "mode" "<MODE>")])
16460 (define_insn "<mask_codefor>avx512er_rsqrt28<mode><mask_name><round_saeonly_name>"
16461   [(set (match_operand:VF_512 0 "register_operand" "=v")
16462         (unspec:VF_512
16463           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16464           UNSPEC_RSQRT28))]
16465   "TARGET_AVX512ER"
16466   "vrsqrt28<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
16467   [(set_attr "prefix" "evex")
16468    (set_attr "type" "sse")
16469    (set_attr "mode" "<MODE>")])
16471 (define_insn "avx512er_vmrsqrt28<mode><round_saeonly_name>"
16472   [(set (match_operand:VF_128 0 "register_operand" "=v")
16473         (vec_merge:VF_128
16474           (unspec:VF_128
16475             [(match_operand:VF_128 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16476             UNSPEC_RSQRT28)
16477           (match_operand:VF_128 2 "register_operand" "v")
16478           (const_int 1)))]
16479   "TARGET_AVX512ER"
16480   "vrsqrt28<ssescalarmodesuffix>\t{<round_saeonly_op3>%1, %2, %0|%0, %2, %<iptr>1<round_saeonly_op3>}"
16481   [(set_attr "length_immediate" "1")
16482    (set_attr "type" "sse")
16483    (set_attr "prefix" "evex")
16484    (set_attr "mode" "<MODE>")])
16486 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16488 ;; XOP instructions
16490 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16492 (define_code_iterator xop_plus [plus ss_plus])
16494 (define_code_attr macs [(plus "macs") (ss_plus "macss")])
16495 (define_code_attr madcs [(plus "madcs") (ss_plus "madcss")])
16497 ;; XOP parallel integer multiply/add instructions.
16499 (define_insn "xop_p<macs><ssemodesuffix><ssemodesuffix>"
16500   [(set (match_operand:VI24_128 0 "register_operand" "=x")
16501         (xop_plus:VI24_128
16502          (mult:VI24_128
16503           (match_operand:VI24_128 1 "nonimmediate_operand" "%x")
16504           (match_operand:VI24_128 2 "nonimmediate_operand" "xm"))
16505          (match_operand:VI24_128 3 "register_operand" "x")))]
16506   "TARGET_XOP"
16507   "vp<macs><ssemodesuffix><ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16508   [(set_attr "type" "ssemuladd")
16509    (set_attr "mode" "TI")])
16511 (define_insn "xop_p<macs>dql"
16512   [(set (match_operand:V2DI 0 "register_operand" "=x")
16513         (xop_plus:V2DI
16514          (mult:V2DI
16515           (sign_extend:V2DI
16516            (vec_select:V2SI
16517             (match_operand:V4SI 1 "nonimmediate_operand" "%x")
16518             (parallel [(const_int 0) (const_int 2)])))
16519           (sign_extend:V2DI
16520            (vec_select:V2SI
16521             (match_operand:V4SI 2 "nonimmediate_operand" "xm")
16522             (parallel [(const_int 0) (const_int 2)]))))
16523          (match_operand:V2DI 3 "register_operand" "x")))]
16524   "TARGET_XOP"
16525   "vp<macs>dql\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16526   [(set_attr "type" "ssemuladd")
16527    (set_attr "mode" "TI")])
16529 (define_insn "xop_p<macs>dqh"
16530   [(set (match_operand:V2DI 0 "register_operand" "=x")
16531         (xop_plus:V2DI
16532          (mult:V2DI
16533           (sign_extend:V2DI
16534            (vec_select:V2SI
16535             (match_operand:V4SI 1 "nonimmediate_operand" "%x")
16536             (parallel [(const_int 1) (const_int 3)])))
16537           (sign_extend:V2DI
16538            (vec_select:V2SI
16539             (match_operand:V4SI 2 "nonimmediate_operand" "xm")
16540             (parallel [(const_int 1) (const_int 3)]))))
16541          (match_operand:V2DI 3 "register_operand" "x")))]
16542   "TARGET_XOP"
16543   "vp<macs>dqh\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16544   [(set_attr "type" "ssemuladd")
16545    (set_attr "mode" "TI")])
16547 ;; XOP parallel integer multiply/add instructions for the intrinisics
16548 (define_insn "xop_p<macs>wd"
16549   [(set (match_operand:V4SI 0 "register_operand" "=x")
16550         (xop_plus:V4SI
16551          (mult:V4SI
16552           (sign_extend:V4SI
16553            (vec_select:V4HI
16554             (match_operand:V8HI 1 "nonimmediate_operand" "%x")
16555             (parallel [(const_int 1) (const_int 3)
16556                        (const_int 5) (const_int 7)])))
16557           (sign_extend:V4SI
16558            (vec_select:V4HI
16559             (match_operand:V8HI 2 "nonimmediate_operand" "xm")
16560             (parallel [(const_int 1) (const_int 3)
16561                        (const_int 5) (const_int 7)]))))
16562          (match_operand:V4SI 3 "register_operand" "x")))]
16563   "TARGET_XOP"
16564   "vp<macs>wd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16565   [(set_attr "type" "ssemuladd")
16566    (set_attr "mode" "TI")])
16568 (define_insn "xop_p<madcs>wd"
16569   [(set (match_operand:V4SI 0 "register_operand" "=x")
16570         (xop_plus:V4SI
16571          (plus:V4SI
16572           (mult:V4SI
16573            (sign_extend:V4SI
16574             (vec_select:V4HI
16575              (match_operand:V8HI 1 "nonimmediate_operand" "%x")
16576              (parallel [(const_int 0) (const_int 2)
16577                         (const_int 4) (const_int 6)])))
16578            (sign_extend:V4SI
16579             (vec_select:V4HI
16580              (match_operand:V8HI 2 "nonimmediate_operand" "xm")
16581              (parallel [(const_int 0) (const_int 2)
16582                         (const_int 4) (const_int 6)]))))
16583           (mult:V4SI
16584            (sign_extend:V4SI
16585             (vec_select:V4HI
16586              (match_dup 1)
16587              (parallel [(const_int 1) (const_int 3)
16588                         (const_int 5) (const_int 7)])))
16589            (sign_extend:V4SI
16590             (vec_select:V4HI
16591              (match_dup 2)
16592              (parallel [(const_int 1) (const_int 3)
16593                         (const_int 5) (const_int 7)])))))
16594          (match_operand:V4SI 3 "register_operand" "x")))]
16595   "TARGET_XOP"
16596   "vp<madcs>wd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16597   [(set_attr "type" "ssemuladd")
16598    (set_attr "mode" "TI")])
16600 ;; XOP parallel XMM conditional moves
16601 (define_insn "xop_pcmov_<mode><avxsizesuffix>"
16602   [(set (match_operand:V_128_256 0 "register_operand" "=x,x")
16603         (if_then_else:V_128_256
16604           (match_operand:V_128_256 3 "nonimmediate_operand" "x,m")
16605           (match_operand:V_128_256 1 "register_operand" "x,x")
16606           (match_operand:V_128_256 2 "nonimmediate_operand" "xm,x")))]
16607   "TARGET_XOP"
16608   "vpcmov\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16609   [(set_attr "type" "sse4arg")])
16611 ;; XOP horizontal add/subtract instructions
16612 (define_insn "xop_phadd<u>bw"
16613   [(set (match_operand:V8HI 0 "register_operand" "=x")
16614         (plus:V8HI
16615          (any_extend:V8HI
16616           (vec_select:V8QI
16617            (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16618            (parallel [(const_int 0) (const_int 2)
16619                       (const_int 4) (const_int 6)
16620                       (const_int 8) (const_int 10)
16621                       (const_int 12) (const_int 14)])))
16622          (any_extend:V8HI
16623           (vec_select:V8QI
16624            (match_dup 1)
16625            (parallel [(const_int 1) (const_int 3)
16626                       (const_int 5) (const_int 7)
16627                       (const_int 9) (const_int 11)
16628                       (const_int 13) (const_int 15)])))))]
16629   "TARGET_XOP"
16630   "vphadd<u>bw\t{%1, %0|%0, %1}"
16631   [(set_attr "type" "sseiadd1")])
16633 (define_insn "xop_phadd<u>bd"
16634   [(set (match_operand:V4SI 0 "register_operand" "=x")
16635         (plus:V4SI
16636          (plus:V4SI
16637           (any_extend:V4SI
16638            (vec_select:V4QI
16639             (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16640             (parallel [(const_int 0) (const_int 4)
16641                        (const_int 8) (const_int 12)])))
16642           (any_extend:V4SI
16643            (vec_select:V4QI
16644             (match_dup 1)
16645             (parallel [(const_int 1) (const_int 5)
16646                        (const_int 9) (const_int 13)]))))
16647          (plus:V4SI
16648           (any_extend:V4SI
16649            (vec_select:V4QI
16650             (match_dup 1)
16651             (parallel [(const_int 2) (const_int 6)
16652                        (const_int 10) (const_int 14)])))
16653           (any_extend:V4SI
16654            (vec_select:V4QI
16655             (match_dup 1)
16656             (parallel [(const_int 3) (const_int 7)
16657                        (const_int 11) (const_int 15)]))))))]
16658   "TARGET_XOP"
16659   "vphadd<u>bd\t{%1, %0|%0, %1}"
16660   [(set_attr "type" "sseiadd1")])
16662 (define_insn "xop_phadd<u>bq"
16663   [(set (match_operand:V2DI 0 "register_operand" "=x")
16664         (plus:V2DI
16665          (plus:V2DI
16666           (plus:V2DI
16667            (any_extend:V2DI
16668             (vec_select:V2QI
16669              (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16670              (parallel [(const_int 0) (const_int 8)])))
16671            (any_extend:V2DI
16672             (vec_select:V2QI
16673              (match_dup 1)
16674              (parallel [(const_int 1) (const_int 9)]))))
16675           (plus:V2DI
16676            (any_extend:V2DI
16677             (vec_select:V2QI
16678              (match_dup 1)
16679              (parallel [(const_int 2) (const_int 10)])))
16680            (any_extend:V2DI
16681             (vec_select:V2QI
16682              (match_dup 1)
16683              (parallel [(const_int 3) (const_int 11)])))))
16684          (plus:V2DI
16685           (plus:V2DI
16686            (any_extend:V2DI
16687             (vec_select:V2QI
16688              (match_dup 1)
16689              (parallel [(const_int 4) (const_int 12)])))
16690            (any_extend:V2DI
16691             (vec_select:V2QI
16692              (match_dup 1)
16693              (parallel [(const_int 5) (const_int 13)]))))
16694           (plus:V2DI
16695            (any_extend:V2DI
16696             (vec_select:V2QI
16697              (match_dup 1)
16698              (parallel [(const_int 6) (const_int 14)])))
16699            (any_extend:V2DI
16700             (vec_select:V2QI
16701              (match_dup 1)
16702              (parallel [(const_int 7) (const_int 15)])))))))]
16703   "TARGET_XOP"
16704   "vphadd<u>bq\t{%1, %0|%0, %1}"
16705   [(set_attr "type" "sseiadd1")])
16707 (define_insn "xop_phadd<u>wd"
16708   [(set (match_operand:V4SI 0 "register_operand" "=x")
16709         (plus:V4SI
16710          (any_extend:V4SI
16711           (vec_select:V4HI
16712            (match_operand:V8HI 1 "nonimmediate_operand" "xm")
16713            (parallel [(const_int 0) (const_int 2)
16714                       (const_int 4) (const_int 6)])))
16715          (any_extend:V4SI
16716           (vec_select:V4HI
16717            (match_dup 1)
16718            (parallel [(const_int 1) (const_int 3)
16719                       (const_int 5) (const_int 7)])))))]
16720   "TARGET_XOP"
16721   "vphadd<u>wd\t{%1, %0|%0, %1}"
16722   [(set_attr "type" "sseiadd1")])
16724 (define_insn "xop_phadd<u>wq"
16725   [(set (match_operand:V2DI 0 "register_operand" "=x")
16726         (plus:V2DI
16727          (plus:V2DI
16728           (any_extend:V2DI
16729            (vec_select:V2HI
16730             (match_operand:V8HI 1 "nonimmediate_operand" "xm")
16731             (parallel [(const_int 0) (const_int 4)])))
16732           (any_extend:V2DI
16733            (vec_select:V2HI
16734             (match_dup 1)
16735             (parallel [(const_int 1) (const_int 5)]))))
16736          (plus:V2DI
16737           (any_extend:V2DI
16738            (vec_select:V2HI
16739             (match_dup 1)
16740             (parallel [(const_int 2) (const_int 6)])))
16741           (any_extend:V2DI
16742            (vec_select:V2HI
16743             (match_dup 1)
16744             (parallel [(const_int 3) (const_int 7)]))))))]
16745   "TARGET_XOP"
16746   "vphadd<u>wq\t{%1, %0|%0, %1}"
16747   [(set_attr "type" "sseiadd1")])
16749 (define_insn "xop_phadd<u>dq"
16750   [(set (match_operand:V2DI 0 "register_operand" "=x")
16751         (plus:V2DI
16752          (any_extend:V2DI
16753           (vec_select:V2SI
16754            (match_operand:V4SI 1 "nonimmediate_operand" "xm")
16755            (parallel [(const_int 0) (const_int 2)])))
16756          (any_extend:V2DI
16757           (vec_select:V2SI
16758            (match_dup 1)
16759            (parallel [(const_int 1) (const_int 3)])))))]
16760   "TARGET_XOP"
16761   "vphadd<u>dq\t{%1, %0|%0, %1}"
16762   [(set_attr "type" "sseiadd1")])
16764 (define_insn "xop_phsubbw"
16765   [(set (match_operand:V8HI 0 "register_operand" "=x")
16766         (minus:V8HI
16767          (sign_extend:V8HI
16768           (vec_select:V8QI
16769            (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16770            (parallel [(const_int 0) (const_int 2)
16771                       (const_int 4) (const_int 6)
16772                       (const_int 8) (const_int 10)
16773                       (const_int 12) (const_int 14)])))
16774          (sign_extend:V8HI
16775           (vec_select:V8QI
16776            (match_dup 1)
16777            (parallel [(const_int 1) (const_int 3)
16778                       (const_int 5) (const_int 7)
16779                       (const_int 9) (const_int 11)
16780                       (const_int 13) (const_int 15)])))))]
16781   "TARGET_XOP"
16782   "vphsubbw\t{%1, %0|%0, %1}"
16783   [(set_attr "type" "sseiadd1")])
16785 (define_insn "xop_phsubwd"
16786   [(set (match_operand:V4SI 0 "register_operand" "=x")
16787         (minus:V4SI
16788          (sign_extend:V4SI
16789           (vec_select:V4HI
16790            (match_operand:V8HI 1 "nonimmediate_operand" "xm")
16791            (parallel [(const_int 0) (const_int 2)
16792                       (const_int 4) (const_int 6)])))
16793          (sign_extend:V4SI
16794           (vec_select:V4HI
16795            (match_dup 1)
16796            (parallel [(const_int 1) (const_int 3)
16797                       (const_int 5) (const_int 7)])))))]
16798   "TARGET_XOP"
16799   "vphsubwd\t{%1, %0|%0, %1}"
16800   [(set_attr "type" "sseiadd1")])
16802 (define_insn "xop_phsubdq"
16803   [(set (match_operand:V2DI 0 "register_operand" "=x")
16804         (minus:V2DI
16805          (sign_extend:V2DI
16806           (vec_select:V2SI
16807            (match_operand:V4SI 1 "nonimmediate_operand" "xm")
16808            (parallel [(const_int 0) (const_int 2)])))
16809          (sign_extend:V2DI
16810           (vec_select:V2SI
16811            (match_dup 1)
16812            (parallel [(const_int 1) (const_int 3)])))))]
16813   "TARGET_XOP"
16814   "vphsubdq\t{%1, %0|%0, %1}"
16815   [(set_attr "type" "sseiadd1")])
16817 ;; XOP permute instructions
16818 (define_insn "xop_pperm"
16819   [(set (match_operand:V16QI 0 "register_operand" "=x,x")
16820         (unspec:V16QI
16821           [(match_operand:V16QI 1 "register_operand" "x,x")
16822            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
16823            (match_operand:V16QI 3 "nonimmediate_operand" "xm,x")]
16824           UNSPEC_XOP_PERMUTE))]
16825   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16826   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16827   [(set_attr "type" "sse4arg")
16828    (set_attr "mode" "TI")])
16830 ;; XOP pack instructions that combine two vectors into a smaller vector
16831 (define_insn "xop_pperm_pack_v2di_v4si"
16832   [(set (match_operand:V4SI 0 "register_operand" "=x,x")
16833         (vec_concat:V4SI
16834          (truncate:V2SI
16835           (match_operand:V2DI 1 "register_operand" "x,x"))
16836          (truncate:V2SI
16837           (match_operand:V2DI 2 "nonimmediate_operand" "x,m"))))
16838    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
16839   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16840   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16841   [(set_attr "type" "sse4arg")
16842    (set_attr "mode" "TI")])
16844 (define_insn "xop_pperm_pack_v4si_v8hi"
16845   [(set (match_operand:V8HI 0 "register_operand" "=x,x")
16846         (vec_concat:V8HI
16847          (truncate:V4HI
16848           (match_operand:V4SI 1 "register_operand" "x,x"))
16849          (truncate:V4HI
16850           (match_operand:V4SI 2 "nonimmediate_operand" "x,m"))))
16851    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
16852   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16853   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16854   [(set_attr "type" "sse4arg")
16855    (set_attr "mode" "TI")])
16857 (define_insn "xop_pperm_pack_v8hi_v16qi"
16858   [(set (match_operand:V16QI 0 "register_operand" "=x,x")
16859         (vec_concat:V16QI
16860          (truncate:V8QI
16861           (match_operand:V8HI 1 "register_operand" "x,x"))
16862          (truncate:V8QI
16863           (match_operand:V8HI 2 "nonimmediate_operand" "x,m"))))
16864    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
16865   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16866   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16867   [(set_attr "type" "sse4arg")
16868    (set_attr "mode" "TI")])
16870 ;; XOP packed rotate instructions
16871 (define_expand "rotl<mode>3"
16872   [(set (match_operand:VI_128 0 "register_operand")
16873         (rotate:VI_128
16874          (match_operand:VI_128 1 "nonimmediate_operand")
16875          (match_operand:SI 2 "general_operand")))]
16876   "TARGET_XOP"
16878   /* If we were given a scalar, convert it to parallel */
16879   if (! const_0_to_<sserotatemax>_operand (operands[2], SImode))
16880     {
16881       rtvec vs = rtvec_alloc (<ssescalarnum>);
16882       rtx par = gen_rtx_PARALLEL (<MODE>mode, vs);
16883       rtx reg = gen_reg_rtx (<MODE>mode);
16884       rtx op2 = operands[2];
16885       int i;
16887       if (GET_MODE (op2) != <ssescalarmode>mode)
16888         {
16889           op2 = gen_reg_rtx (<ssescalarmode>mode);
16890           convert_move (op2, operands[2], false);
16891         }
16893       for (i = 0; i < <ssescalarnum>; i++)
16894         RTVEC_ELT (vs, i) = op2;
16896       emit_insn (gen_vec_init<mode><ssescalarmodelower> (reg, par));
16897       emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], reg));
16898       DONE;
16899     }
16902 (define_expand "rotr<mode>3"
16903   [(set (match_operand:VI_128 0 "register_operand")
16904         (rotatert:VI_128
16905          (match_operand:VI_128 1 "nonimmediate_operand")
16906          (match_operand:SI 2 "general_operand")))]
16907   "TARGET_XOP"
16909   /* If we were given a scalar, convert it to parallel */
16910   if (! const_0_to_<sserotatemax>_operand (operands[2], SImode))
16911     {
16912       rtvec vs = rtvec_alloc (<ssescalarnum>);
16913       rtx par = gen_rtx_PARALLEL (<MODE>mode, vs);
16914       rtx neg = gen_reg_rtx (<MODE>mode);
16915       rtx reg = gen_reg_rtx (<MODE>mode);
16916       rtx op2 = operands[2];
16917       int i;
16919       if (GET_MODE (op2) != <ssescalarmode>mode)
16920         {
16921           op2 = gen_reg_rtx (<ssescalarmode>mode);
16922           convert_move (op2, operands[2], false);
16923         }
16925       for (i = 0; i < <ssescalarnum>; i++)
16926         RTVEC_ELT (vs, i) = op2;
16928       emit_insn (gen_vec_init<mode><ssescalarmodelower> (reg, par));
16929       emit_insn (gen_neg<mode>2 (neg, reg));
16930       emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], neg));
16931       DONE;
16932     }
16935 (define_insn "xop_rotl<mode>3"
16936   [(set (match_operand:VI_128 0 "register_operand" "=x")
16937         (rotate:VI_128
16938          (match_operand:VI_128 1 "nonimmediate_operand" "xm")
16939          (match_operand:SI 2 "const_0_to_<sserotatemax>_operand" "n")))]
16940   "TARGET_XOP"
16941   "vprot<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16942   [(set_attr "type" "sseishft")
16943    (set_attr "length_immediate" "1")
16944    (set_attr "mode" "TI")])
16946 (define_insn "xop_rotr<mode>3"
16947   [(set (match_operand:VI_128 0 "register_operand" "=x")
16948         (rotatert:VI_128
16949          (match_operand:VI_128 1 "nonimmediate_operand" "xm")
16950          (match_operand:SI 2 "const_0_to_<sserotatemax>_operand" "n")))]
16951   "TARGET_XOP"
16953   operands[3]
16954     = GEN_INT (GET_MODE_BITSIZE (<ssescalarmode>mode) - INTVAL (operands[2]));
16955   return \"vprot<ssemodesuffix>\t{%3, %1, %0|%0, %1, %3}\";
16957   [(set_attr "type" "sseishft")
16958    (set_attr "length_immediate" "1")
16959    (set_attr "mode" "TI")])
16961 (define_expand "vrotr<mode>3"
16962   [(match_operand:VI_128 0 "register_operand")
16963    (match_operand:VI_128 1 "register_operand")
16964    (match_operand:VI_128 2 "register_operand")]
16965   "TARGET_XOP"
16967   rtx reg = gen_reg_rtx (<MODE>mode);
16968   emit_insn (gen_neg<mode>2 (reg, operands[2]));
16969   emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], reg));
16970   DONE;
16973 (define_expand "vrotl<mode>3"
16974   [(match_operand:VI_128 0 "register_operand")
16975    (match_operand:VI_128 1 "register_operand")
16976    (match_operand:VI_128 2 "register_operand")]
16977   "TARGET_XOP"
16979   emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], operands[2]));
16980   DONE;
16983 (define_insn "xop_vrotl<mode>3"
16984   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
16985         (if_then_else:VI_128
16986          (ge:VI_128
16987           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
16988           (const_int 0))
16989          (rotate:VI_128
16990           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
16991           (match_dup 2))
16992          (rotatert:VI_128
16993           (match_dup 1)
16994           (neg:VI_128 (match_dup 2)))))]
16995   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16996   "vprot<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16997   [(set_attr "type" "sseishft")
16998    (set_attr "prefix_data16" "0")
16999    (set_attr "prefix_extra" "2")
17000    (set_attr "mode" "TI")])
17002 ;; XOP packed shift instructions.
17003 (define_expand "vlshr<mode>3"
17004   [(set (match_operand:VI12_128 0 "register_operand")
17005         (lshiftrt:VI12_128
17006           (match_operand:VI12_128 1 "register_operand")
17007           (match_operand:VI12_128 2 "nonimmediate_operand")))]
17008   "TARGET_XOP"
17010   rtx neg = gen_reg_rtx (<MODE>mode);
17011   emit_insn (gen_neg<mode>2 (neg, operands[2]));
17012   emit_insn (gen_xop_shl<mode>3 (operands[0], operands[1], neg));
17013   DONE;
17016 (define_expand "vlshr<mode>3"
17017   [(set (match_operand:VI48_128 0 "register_operand")
17018         (lshiftrt:VI48_128
17019           (match_operand:VI48_128 1 "register_operand")
17020           (match_operand:VI48_128 2 "nonimmediate_operand")))]
17021   "TARGET_AVX2 || TARGET_XOP"
17023   if (!TARGET_AVX2)
17024     {
17025       rtx neg = gen_reg_rtx (<MODE>mode);
17026       emit_insn (gen_neg<mode>2 (neg, operands[2]));
17027       emit_insn (gen_xop_shl<mode>3 (operands[0], operands[1], neg));
17028       DONE;
17029     }
17032 (define_expand "vlshr<mode>3"
17033   [(set (match_operand:VI48_512 0 "register_operand")
17034         (lshiftrt:VI48_512
17035           (match_operand:VI48_512 1 "register_operand")
17036           (match_operand:VI48_512 2 "nonimmediate_operand")))]
17037   "TARGET_AVX512F")
17039 (define_expand "vlshr<mode>3"
17040   [(set (match_operand:VI48_256 0 "register_operand")
17041         (lshiftrt:VI48_256
17042           (match_operand:VI48_256 1 "register_operand")
17043           (match_operand:VI48_256 2 "nonimmediate_operand")))]
17044   "TARGET_AVX2")
17046 (define_expand "vashrv8hi3<mask_name>"
17047   [(set (match_operand:V8HI 0 "register_operand")
17048         (ashiftrt:V8HI
17049           (match_operand:V8HI 1 "register_operand")
17050           (match_operand:V8HI 2 "nonimmediate_operand")))]
17051   "TARGET_XOP || (TARGET_AVX512BW && TARGET_AVX512VL)"
17053   if (TARGET_XOP)
17054     {
17055       rtx neg = gen_reg_rtx (V8HImode);
17056       emit_insn (gen_negv8hi2 (neg, operands[2]));
17057       emit_insn (gen_xop_shav8hi3 (operands[0], operands[1], neg));
17058       DONE;
17059     }
17062 (define_expand "vashrv16qi3"
17063   [(set (match_operand:V16QI 0 "register_operand")
17064         (ashiftrt:V16QI
17065           (match_operand:V16QI 1 "register_operand")
17066           (match_operand:V16QI 2 "nonimmediate_operand")))]
17067   "TARGET_XOP"
17069    rtx neg = gen_reg_rtx (V16QImode);
17070    emit_insn (gen_negv16qi2 (neg, operands[2]));
17071    emit_insn (gen_xop_shav16qi3 (operands[0], operands[1], neg));
17072    DONE;
17075 (define_expand "vashrv2di3<mask_name>"
17076   [(set (match_operand:V2DI 0 "register_operand")
17077         (ashiftrt:V2DI
17078           (match_operand:V2DI 1 "register_operand")
17079           (match_operand:V2DI 2 "nonimmediate_operand")))]
17080   "TARGET_XOP || TARGET_AVX512VL"
17082   if (TARGET_XOP)
17083     {
17084       rtx neg = gen_reg_rtx (V2DImode);
17085       emit_insn (gen_negv2di2 (neg, operands[2]));
17086       emit_insn (gen_xop_shav2di3 (operands[0], operands[1], neg));
17087       DONE;
17088     }
17091 (define_expand "vashrv4si3"
17092   [(set (match_operand:V4SI 0 "register_operand")
17093         (ashiftrt:V4SI (match_operand:V4SI 1 "register_operand")
17094                        (match_operand:V4SI 2 "nonimmediate_operand")))]
17095   "TARGET_AVX2 || TARGET_XOP"
17097   if (!TARGET_AVX2)
17098     {
17099       rtx neg = gen_reg_rtx (V4SImode);
17100       emit_insn (gen_negv4si2 (neg, operands[2]));
17101       emit_insn (gen_xop_shav4si3 (operands[0], operands[1], neg));
17102       DONE;
17103     }
17106 (define_expand "vashrv16si3"
17107   [(set (match_operand:V16SI 0 "register_operand")
17108         (ashiftrt:V16SI (match_operand:V16SI 1 "register_operand")
17109                         (match_operand:V16SI 2 "nonimmediate_operand")))]
17110   "TARGET_AVX512F")
17112 (define_expand "vashrv8si3"
17113   [(set (match_operand:V8SI 0 "register_operand")
17114         (ashiftrt:V8SI (match_operand:V8SI 1 "register_operand")
17115                        (match_operand:V8SI 2 "nonimmediate_operand")))]
17116   "TARGET_AVX2")
17118 (define_expand "vashl<mode>3"
17119   [(set (match_operand:VI12_128 0 "register_operand")
17120         (ashift:VI12_128
17121           (match_operand:VI12_128 1 "register_operand")
17122           (match_operand:VI12_128 2 "nonimmediate_operand")))]
17123   "TARGET_XOP"
17125   emit_insn (gen_xop_sha<mode>3 (operands[0], operands[1], operands[2]));
17126   DONE;
17129 (define_expand "vashl<mode>3"
17130   [(set (match_operand:VI48_128 0 "register_operand")
17131         (ashift:VI48_128
17132           (match_operand:VI48_128 1 "register_operand")
17133           (match_operand:VI48_128 2 "nonimmediate_operand")))]
17134   "TARGET_AVX2 || TARGET_XOP"
17136   if (!TARGET_AVX2)
17137     {
17138       operands[2] = force_reg (<MODE>mode, operands[2]);
17139       emit_insn (gen_xop_sha<mode>3 (operands[0], operands[1], operands[2]));
17140       DONE;
17141     }
17144 (define_expand "vashl<mode>3"
17145   [(set (match_operand:VI48_512 0 "register_operand")
17146         (ashift:VI48_512
17147           (match_operand:VI48_512 1 "register_operand")
17148           (match_operand:VI48_512 2 "nonimmediate_operand")))]
17149   "TARGET_AVX512F")
17151 (define_expand "vashl<mode>3"
17152   [(set (match_operand:VI48_256 0 "register_operand")
17153         (ashift:VI48_256
17154           (match_operand:VI48_256 1 "register_operand")
17155           (match_operand:VI48_256 2 "nonimmediate_operand")))]
17156   "TARGET_AVX2")
17158 (define_insn "xop_sha<mode>3"
17159   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
17160         (if_then_else:VI_128
17161          (ge:VI_128
17162           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
17163           (const_int 0))
17164          (ashift:VI_128
17165           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
17166           (match_dup 2))
17167          (ashiftrt:VI_128
17168           (match_dup 1)
17169           (neg:VI_128 (match_dup 2)))))]
17170   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17171   "vpsha<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17172   [(set_attr "type" "sseishft")
17173    (set_attr "prefix_data16" "0")
17174    (set_attr "prefix_extra" "2")
17175    (set_attr "mode" "TI")])
17177 (define_insn "xop_shl<mode>3"
17178   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
17179         (if_then_else:VI_128
17180          (ge:VI_128
17181           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
17182           (const_int 0))
17183          (ashift:VI_128
17184           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
17185           (match_dup 2))
17186          (lshiftrt:VI_128
17187           (match_dup 1)
17188           (neg:VI_128 (match_dup 2)))))]
17189   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17190   "vpshl<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17191   [(set_attr "type" "sseishft")
17192    (set_attr "prefix_data16" "0")
17193    (set_attr "prefix_extra" "2")
17194    (set_attr "mode" "TI")])
17196 (define_expand "<shift_insn><mode>3"
17197   [(set (match_operand:VI1_AVX512 0 "register_operand")
17198         (any_shift:VI1_AVX512
17199           (match_operand:VI1_AVX512 1 "register_operand")
17200           (match_operand:SI 2 "nonmemory_operand")))]
17201   "TARGET_SSE2"
17203   if (TARGET_XOP && <MODE>mode == V16QImode)
17204     {
17205       bool negate = false;
17206       rtx (*gen) (rtx, rtx, rtx);
17207       rtx tmp, par;
17208       int i;
17210       if (<CODE> != ASHIFT)
17211         {
17212           if (CONST_INT_P (operands[2]))
17213             operands[2] = GEN_INT (-INTVAL (operands[2]));
17214           else
17215             negate = true;
17216         }
17217       par = gen_rtx_PARALLEL (V16QImode, rtvec_alloc (16));
17218       for (i = 0; i < 16; i++)
17219         XVECEXP (par, 0, i) = operands[2];
17221       tmp = gen_reg_rtx (V16QImode);
17222       emit_insn (gen_vec_initv16qiqi (tmp, par));
17224       if (negate)
17225         emit_insn (gen_negv16qi2 (tmp, tmp));
17227       gen = (<CODE> == LSHIFTRT ? gen_xop_shlv16qi3 : gen_xop_shav16qi3);
17228       emit_insn (gen (operands[0], operands[1], tmp));
17229     }
17230   else
17231     ix86_expand_vecop_qihi (<CODE>, operands[0], operands[1], operands[2]);
17232   DONE;
17235 (define_expand "ashrv2di3"
17236   [(set (match_operand:V2DI 0 "register_operand")
17237         (ashiftrt:V2DI
17238           (match_operand:V2DI 1 "register_operand")
17239           (match_operand:DI 2 "nonmemory_operand")))]
17240   "TARGET_XOP || TARGET_AVX512VL"
17242   if (!TARGET_AVX512VL)
17243     {
17244       rtx reg = gen_reg_rtx (V2DImode);
17245       rtx par;
17246       bool negate = false;
17247       int i;
17249       if (CONST_INT_P (operands[2]))
17250         operands[2] = GEN_INT (-INTVAL (operands[2]));
17251       else
17252         negate = true;
17254       par = gen_rtx_PARALLEL (V2DImode, rtvec_alloc (2));
17255       for (i = 0; i < 2; i++)
17256         XVECEXP (par, 0, i) = operands[2];
17258       emit_insn (gen_vec_initv2didi (reg, par));
17260       if (negate)
17261         emit_insn (gen_negv2di2 (reg, reg));
17263       emit_insn (gen_xop_shav2di3 (operands[0], operands[1], reg));
17264       DONE;
17265     }
17268 ;; XOP FRCZ support
17269 (define_insn "xop_frcz<mode>2"
17270   [(set (match_operand:FMAMODE 0 "register_operand" "=x")
17271         (unspec:FMAMODE
17272          [(match_operand:FMAMODE 1 "nonimmediate_operand" "xm")]
17273          UNSPEC_FRCZ))]
17274   "TARGET_XOP"
17275   "vfrcz<ssemodesuffix>\t{%1, %0|%0, %1}"
17276   [(set_attr "type" "ssecvt1")
17277    (set_attr "mode" "<MODE>")])
17279 (define_expand "xop_vmfrcz<mode>2"
17280   [(set (match_operand:VF_128 0 "register_operand")
17281         (vec_merge:VF_128
17282           (unspec:VF_128
17283            [(match_operand:VF_128 1 "nonimmediate_operand")]
17284            UNSPEC_FRCZ)
17285           (match_dup 2)
17286           (const_int 1)))]
17287   "TARGET_XOP"
17288   "operands[2] = CONST0_RTX (<MODE>mode);")
17290 (define_insn "*xop_vmfrcz<mode>2"
17291   [(set (match_operand:VF_128 0 "register_operand" "=x")
17292         (vec_merge:VF_128
17293           (unspec:VF_128
17294            [(match_operand:VF_128 1 "nonimmediate_operand" "xm")]
17295            UNSPEC_FRCZ)
17296           (match_operand:VF_128 2 "const0_operand")
17297           (const_int 1)))]
17298   "TARGET_XOP"
17299   "vfrcz<ssescalarmodesuffix>\t{%1, %0|%0, %<iptr>1}"
17300   [(set_attr "type" "ssecvt1")
17301    (set_attr "mode" "<MODE>")])
17303 (define_insn "xop_maskcmp<mode>3"
17304   [(set (match_operand:VI_128 0 "register_operand" "=x")
17305         (match_operator:VI_128 1 "ix86_comparison_int_operator"
17306          [(match_operand:VI_128 2 "register_operand" "x")
17307           (match_operand:VI_128 3 "nonimmediate_operand" "xm")]))]
17308   "TARGET_XOP"
17309   "vpcom%Y1<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
17310   [(set_attr "type" "sse4arg")
17311    (set_attr "prefix_data16" "0")
17312    (set_attr "prefix_rep" "0")
17313    (set_attr "prefix_extra" "2")
17314    (set_attr "length_immediate" "1")
17315    (set_attr "mode" "TI")])
17317 (define_insn "xop_maskcmp_uns<mode>3"
17318   [(set (match_operand:VI_128 0 "register_operand" "=x")
17319         (match_operator:VI_128 1 "ix86_comparison_uns_operator"
17320          [(match_operand:VI_128 2 "register_operand" "x")
17321           (match_operand:VI_128 3 "nonimmediate_operand" "xm")]))]
17322   "TARGET_XOP"
17323   "vpcom%Y1u<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
17324   [(set_attr "type" "ssecmp")
17325    (set_attr "prefix_data16" "0")
17326    (set_attr "prefix_rep" "0")
17327    (set_attr "prefix_extra" "2")
17328    (set_attr "length_immediate" "1")
17329    (set_attr "mode" "TI")])
17331 ;; Version of pcom*u* that is called from the intrinsics that allows pcomequ*
17332 ;; and pcomneu* not to be converted to the signed ones in case somebody needs
17333 ;; the exact instruction generated for the intrinsic.
17334 (define_insn "xop_maskcmp_uns2<mode>3"
17335   [(set (match_operand:VI_128 0 "register_operand" "=x")
17336         (unspec:VI_128
17337          [(match_operator:VI_128 1 "ix86_comparison_uns_operator"
17338           [(match_operand:VI_128 2 "register_operand" "x")
17339            (match_operand:VI_128 3 "nonimmediate_operand" "xm")])]
17340          UNSPEC_XOP_UNSIGNED_CMP))]
17341   "TARGET_XOP"
17342   "vpcom%Y1u<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
17343   [(set_attr "type" "ssecmp")
17344    (set_attr "prefix_data16" "0")
17345    (set_attr "prefix_extra" "2")
17346    (set_attr "length_immediate" "1")
17347    (set_attr "mode" "TI")])
17349 ;; Pcomtrue and pcomfalse support.  These are useless instructions, but are
17350 ;; being added here to be complete.
17351 (define_insn "xop_pcom_tf<mode>3"
17352   [(set (match_operand:VI_128 0 "register_operand" "=x")
17353         (unspec:VI_128
17354           [(match_operand:VI_128 1 "register_operand" "x")
17355            (match_operand:VI_128 2 "nonimmediate_operand" "xm")
17356            (match_operand:SI 3 "const_int_operand" "n")]
17357           UNSPEC_XOP_TRUEFALSE))]
17358   "TARGET_XOP"
17360   return ((INTVAL (operands[3]) != 0)
17361           ? "vpcomtrue<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17362           : "vpcomfalse<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}");
17364   [(set_attr "type" "ssecmp")
17365    (set_attr "prefix_data16" "0")
17366    (set_attr "prefix_extra" "2")
17367    (set_attr "length_immediate" "1")
17368    (set_attr "mode" "TI")])
17370 (define_insn "xop_vpermil2<mode>3"
17371   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
17372         (unspec:VF_128_256
17373           [(match_operand:VF_128_256 1 "register_operand" "x,x")
17374            (match_operand:VF_128_256 2 "nonimmediate_operand" "x,m")
17375            (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "xm,x")
17376            (match_operand:SI 4 "const_0_to_3_operand" "n,n")]
17377           UNSPEC_VPERMIL2))]
17378   "TARGET_XOP"
17379   "vpermil2<ssemodesuffix>\t{%4, %3, %2, %1, %0|%0, %1, %2, %3, %4}"
17380   [(set_attr "type" "sse4arg")
17381    (set_attr "length_immediate" "1")
17382    (set_attr "mode" "<MODE>")])
17384 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17386 (define_insn "aesenc"
17387   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17388         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17389                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
17390                       UNSPEC_AESENC))]
17391   "TARGET_AES"
17392   "@
17393    aesenc\t{%2, %0|%0, %2}
17394    vaesenc\t{%2, %1, %0|%0, %1, %2}"
17395   [(set_attr "isa" "noavx,avx")
17396    (set_attr "type" "sselog1")
17397    (set_attr "prefix_extra" "1")
17398    (set_attr "prefix" "orig,vex")
17399    (set_attr "btver2_decode" "double,double")
17400    (set_attr "mode" "TI")])
17402 (define_insn "aesenclast"
17403   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17404         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17405                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
17406                       UNSPEC_AESENCLAST))]
17407   "TARGET_AES"
17408   "@
17409    aesenclast\t{%2, %0|%0, %2}
17410    vaesenclast\t{%2, %1, %0|%0, %1, %2}"
17411   [(set_attr "isa" "noavx,avx")
17412    (set_attr "type" "sselog1")
17413    (set_attr "prefix_extra" "1")
17414    (set_attr "prefix" "orig,vex")
17415    (set_attr "btver2_decode" "double,double") 
17416    (set_attr "mode" "TI")])
17418 (define_insn "aesdec"
17419   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17420         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17421                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
17422                       UNSPEC_AESDEC))]
17423   "TARGET_AES"
17424   "@
17425    aesdec\t{%2, %0|%0, %2}
17426    vaesdec\t{%2, %1, %0|%0, %1, %2}"
17427   [(set_attr "isa" "noavx,avx")
17428    (set_attr "type" "sselog1")
17429    (set_attr "prefix_extra" "1")
17430    (set_attr "prefix" "orig,vex")
17431    (set_attr "btver2_decode" "double,double") 
17432    (set_attr "mode" "TI")])
17434 (define_insn "aesdeclast"
17435   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17436         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17437                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
17438                       UNSPEC_AESDECLAST))]
17439   "TARGET_AES"
17440   "@
17441    aesdeclast\t{%2, %0|%0, %2}
17442    vaesdeclast\t{%2, %1, %0|%0, %1, %2}"
17443   [(set_attr "isa" "noavx,avx")
17444    (set_attr "type" "sselog1")
17445    (set_attr "prefix_extra" "1")
17446    (set_attr "prefix" "orig,vex")
17447    (set_attr "btver2_decode" "double,double")
17448    (set_attr "mode" "TI")])
17450 (define_insn "aesimc"
17451   [(set (match_operand:V2DI 0 "register_operand" "=x")
17452         (unspec:V2DI [(match_operand:V2DI 1 "vector_operand" "xBm")]
17453                       UNSPEC_AESIMC))]
17454   "TARGET_AES"
17455   "%vaesimc\t{%1, %0|%0, %1}"
17456   [(set_attr "type" "sselog1")
17457    (set_attr "prefix_extra" "1")
17458    (set_attr "prefix" "maybe_vex")
17459    (set_attr "mode" "TI")])
17461 (define_insn "aeskeygenassist"
17462   [(set (match_operand:V2DI 0 "register_operand" "=x")
17463         (unspec:V2DI [(match_operand:V2DI 1 "vector_operand" "xBm")
17464                       (match_operand:SI 2 "const_0_to_255_operand" "n")]
17465                      UNSPEC_AESKEYGENASSIST))]
17466   "TARGET_AES"
17467   "%vaeskeygenassist\t{%2, %1, %0|%0, %1, %2}"
17468   [(set_attr "type" "sselog1")
17469    (set_attr "prefix_extra" "1")
17470    (set_attr "length_immediate" "1")
17471    (set_attr "prefix" "maybe_vex")
17472    (set_attr "mode" "TI")])
17474 (define_insn "pclmulqdq"
17475   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17476         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17477                       (match_operand:V2DI 2 "vector_operand" "xBm,xm")
17478                       (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
17479                      UNSPEC_PCLMUL))]
17480   "TARGET_PCLMUL"
17481   "@
17482    pclmulqdq\t{%3, %2, %0|%0, %2, %3}
17483    vpclmulqdq\t{%3, %2, %1, %0|%0, %1, %2, %3}"
17484   [(set_attr "isa" "noavx,avx")
17485    (set_attr "type" "sselog1")
17486    (set_attr "prefix_extra" "1")
17487    (set_attr "length_immediate" "1")
17488    (set_attr "prefix" "orig,vex")
17489    (set_attr "mode" "TI")])
17491 (define_expand "avx_vzeroall"
17492   [(match_par_dup 0 [(const_int 0)])]
17493   "TARGET_AVX"
17495   int nregs = TARGET_64BIT ? 16 : 8;
17496   int regno;
17498   operands[0] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs + 1));
17500   XVECEXP (operands[0], 0, 0)
17501     = gen_rtx_UNSPEC_VOLATILE (VOIDmode, gen_rtvec (1, const0_rtx),
17502                                UNSPECV_VZEROALL);
17504   for (regno = 0; regno < nregs; regno++)
17505     XVECEXP (operands[0], 0, regno + 1)
17506       = gen_rtx_SET (gen_rtx_REG (V8SImode, GET_SSE_REGNO (regno)),
17507                      CONST0_RTX (V8SImode));
17510 (define_insn "*avx_vzeroall"
17511   [(match_parallel 0 "vzeroall_operation"
17512     [(unspec_volatile [(const_int 0)] UNSPECV_VZEROALL)])]
17513   "TARGET_AVX"
17514   "vzeroall"
17515   [(set_attr "type" "sse")
17516    (set_attr "modrm" "0")
17517    (set_attr "memory" "none")
17518    (set_attr "prefix" "vex")
17519    (set_attr "btver2_decode" "vector")
17520    (set_attr "mode" "OI")])
17522 ;; Clear the upper 128bits of AVX registers, equivalent to a NOP
17523 ;; if the upper 128bits are unused.
17524 (define_insn "avx_vzeroupper"
17525   [(unspec_volatile [(const_int 0)] UNSPECV_VZEROUPPER)]
17526   "TARGET_AVX"
17527   "vzeroupper"
17528   [(set_attr "type" "sse")
17529    (set_attr "modrm" "0")
17530    (set_attr "memory" "none")
17531    (set_attr "prefix" "vex")
17532    (set_attr "btver2_decode" "vector")
17533    (set_attr "mode" "OI")])
17535 (define_mode_attr pbroadcast_evex_isa
17536   [(V64QI "avx512bw") (V32QI "avx512bw") (V16QI "avx512bw")
17537    (V32HI "avx512bw") (V16HI "avx512bw") (V8HI "avx512bw")
17538    (V16SI "avx512f") (V8SI "avx512f") (V4SI "avx512f")
17539    (V8DI "avx512f") (V4DI "avx512f") (V2DI "avx512f")])
17541 (define_insn "avx2_pbroadcast<mode>"
17542   [(set (match_operand:VI 0 "register_operand" "=x,v")
17543         (vec_duplicate:VI
17544           (vec_select:<ssescalarmode>
17545             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "xm,vm")
17546             (parallel [(const_int 0)]))))]
17547   "TARGET_AVX2"
17548   "vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}"
17549   [(set_attr "isa" "*,<pbroadcast_evex_isa>")
17550    (set_attr "type" "ssemov")
17551    (set_attr "prefix_extra" "1")
17552    (set_attr "prefix" "vex,evex")
17553    (set_attr "mode" "<sseinsnmode>")])
17555 (define_insn "avx2_pbroadcast<mode>_1"
17556   [(set (match_operand:VI_256 0 "register_operand" "=x,x,v,v")
17557         (vec_duplicate:VI_256
17558           (vec_select:<ssescalarmode>
17559             (match_operand:VI_256 1 "nonimmediate_operand" "m,x,m,v")
17560             (parallel [(const_int 0)]))))]
17561   "TARGET_AVX2"
17562   "@
17563    vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}
17564    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}
17565    vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}
17566    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}"
17567   [(set_attr "isa" "*,*,<pbroadcast_evex_isa>,<pbroadcast_evex_isa>")
17568    (set_attr "type" "ssemov")
17569    (set_attr "prefix_extra" "1")
17570    (set_attr "prefix" "vex")
17571    (set_attr "mode" "<sseinsnmode>")])
17573 (define_insn "<avx2_avx512>_permvar<mode><mask_name>"
17574   [(set (match_operand:VI48F_256_512 0 "register_operand" "=v")
17575         (unspec:VI48F_256_512
17576           [(match_operand:VI48F_256_512 1 "nonimmediate_operand" "vm")
17577            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
17578           UNSPEC_VPERMVAR))]
17579   "TARGET_AVX2 && <mask_mode512bit_condition>"
17580   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
17581   [(set_attr "type" "sselog")
17582    (set_attr "prefix" "<mask_prefix2>")
17583    (set_attr "mode" "<sseinsnmode>")])
17585 (define_insn "<avx512>_permvar<mode><mask_name>"
17586   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
17587         (unspec:VI1_AVX512VL
17588           [(match_operand:VI1_AVX512VL 1 "nonimmediate_operand" "vm")
17589            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
17590           UNSPEC_VPERMVAR))]
17591   "TARGET_AVX512VBMI && <mask_mode512bit_condition>"
17592   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
17593   [(set_attr "type" "sselog")
17594    (set_attr "prefix" "<mask_prefix2>")
17595    (set_attr "mode" "<sseinsnmode>")])
17597 (define_insn "<avx512>_permvar<mode><mask_name>"
17598   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17599         (unspec:VI2_AVX512VL
17600           [(match_operand:VI2_AVX512VL 1 "nonimmediate_operand" "vm")
17601            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
17602           UNSPEC_VPERMVAR))]
17603   "TARGET_AVX512BW && <mask_mode512bit_condition>"
17604   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
17605   [(set_attr "type" "sselog")
17606    (set_attr "prefix" "<mask_prefix2>")
17607    (set_attr "mode" "<sseinsnmode>")])
17609 (define_expand "avx2_perm<mode>"
17610   [(match_operand:VI8F_256 0 "register_operand")
17611    (match_operand:VI8F_256 1 "nonimmediate_operand")
17612    (match_operand:SI 2 "const_0_to_255_operand")]
17613   "TARGET_AVX2"
17615   int mask = INTVAL (operands[2]);
17616   emit_insn (gen_avx2_perm<mode>_1 (operands[0], operands[1],
17617                                     GEN_INT ((mask >> 0) & 3),
17618                                     GEN_INT ((mask >> 2) & 3),
17619                                     GEN_INT ((mask >> 4) & 3),
17620                                     GEN_INT ((mask >> 6) & 3)));
17621   DONE;
17624 (define_expand "avx512vl_perm<mode>_mask"
17625   [(match_operand:VI8F_256 0 "register_operand")
17626    (match_operand:VI8F_256 1 "nonimmediate_operand")
17627    (match_operand:SI 2 "const_0_to_255_operand")
17628    (match_operand:VI8F_256 3 "vector_move_operand")
17629    (match_operand:<avx512fmaskmode> 4 "register_operand")]
17630   "TARGET_AVX512VL"
17632   int mask = INTVAL (operands[2]);
17633   emit_insn (gen_<avx2_avx512>_perm<mode>_1_mask (operands[0], operands[1],
17634                                                   GEN_INT ((mask >> 0) & 3),
17635                                                   GEN_INT ((mask >> 2) & 3),
17636                                                   GEN_INT ((mask >> 4) & 3),
17637                                                   GEN_INT ((mask >> 6) & 3),
17638                                                   operands[3], operands[4]));
17639   DONE;
17642 (define_insn "avx2_perm<mode>_1<mask_name>"
17643   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
17644         (vec_select:VI8F_256
17645           (match_operand:VI8F_256 1 "nonimmediate_operand" "vm")
17646           (parallel [(match_operand 2 "const_0_to_3_operand")
17647                      (match_operand 3 "const_0_to_3_operand")
17648                      (match_operand 4 "const_0_to_3_operand")
17649                      (match_operand 5 "const_0_to_3_operand")])))]
17650   "TARGET_AVX2 && <mask_mode512bit_condition>"
17652   int mask = 0;
17653   mask |= INTVAL (operands[2]) << 0;
17654   mask |= INTVAL (operands[3]) << 2;
17655   mask |= INTVAL (operands[4]) << 4;
17656   mask |= INTVAL (operands[5]) << 6;
17657   operands[2] = GEN_INT (mask);
17658   return "vperm<ssemodesuffix>\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
17660   [(set_attr "type" "sselog")
17661    (set_attr "prefix" "<mask_prefix2>")
17662    (set_attr "mode" "<sseinsnmode>")])
17664 (define_expand "avx512f_perm<mode>"
17665   [(match_operand:V8FI 0 "register_operand")
17666    (match_operand:V8FI 1 "nonimmediate_operand")
17667    (match_operand:SI 2 "const_0_to_255_operand")]
17668   "TARGET_AVX512F"
17670   int mask = INTVAL (operands[2]);
17671   emit_insn (gen_avx512f_perm<mode>_1 (operands[0], operands[1],
17672                                        GEN_INT ((mask >> 0) & 3),
17673                                        GEN_INT ((mask >> 2) & 3),
17674                                        GEN_INT ((mask >> 4) & 3),
17675                                        GEN_INT ((mask >> 6) & 3),
17676                                        GEN_INT (((mask >> 0) & 3) + 4),
17677                                        GEN_INT (((mask >> 2) & 3) + 4),
17678                                        GEN_INT (((mask >> 4) & 3) + 4),
17679                                        GEN_INT (((mask >> 6) & 3) + 4)));
17680   DONE;
17683 (define_expand "avx512f_perm<mode>_mask"
17684   [(match_operand:V8FI 0 "register_operand")
17685    (match_operand:V8FI 1 "nonimmediate_operand")
17686    (match_operand:SI 2 "const_0_to_255_operand")
17687    (match_operand:V8FI 3 "vector_move_operand")
17688    (match_operand:<avx512fmaskmode> 4 "register_operand")]
17689   "TARGET_AVX512F"
17691   int mask = INTVAL (operands[2]);
17692   emit_insn (gen_avx512f_perm<mode>_1_mask (operands[0], operands[1],
17693                                             GEN_INT ((mask >> 0) & 3),
17694                                             GEN_INT ((mask >> 2) & 3),
17695                                             GEN_INT ((mask >> 4) & 3),
17696                                             GEN_INT ((mask >> 6) & 3),
17697                                             GEN_INT (((mask >> 0) & 3) + 4),
17698                                             GEN_INT (((mask >> 2) & 3) + 4),
17699                                             GEN_INT (((mask >> 4) & 3) + 4),
17700                                             GEN_INT (((mask >> 6) & 3) + 4),
17701                                             operands[3], operands[4]));
17702   DONE;
17705 (define_insn "avx512f_perm<mode>_1<mask_name>"
17706   [(set (match_operand:V8FI 0 "register_operand" "=v")
17707         (vec_select:V8FI
17708           (match_operand:V8FI 1 "nonimmediate_operand" "vm")
17709           (parallel [(match_operand 2 "const_0_to_3_operand")
17710                      (match_operand 3 "const_0_to_3_operand")
17711                      (match_operand 4 "const_0_to_3_operand")
17712                      (match_operand 5 "const_0_to_3_operand")
17713                      (match_operand 6 "const_4_to_7_operand")
17714                      (match_operand 7 "const_4_to_7_operand")
17715                      (match_operand 8 "const_4_to_7_operand")
17716                      (match_operand 9 "const_4_to_7_operand")])))]
17717   "TARGET_AVX512F && <mask_mode512bit_condition>
17718    && (INTVAL (operands[2]) == (INTVAL (operands[6]) - 4)
17719        && INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
17720        && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
17721        && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4))"
17723   int mask = 0;
17724   mask |= INTVAL (operands[2]) << 0;
17725   mask |= INTVAL (operands[3]) << 2;
17726   mask |= INTVAL (operands[4]) << 4;
17727   mask |= INTVAL (operands[5]) << 6;
17728   operands[2] = GEN_INT (mask);
17729   return "vperm<ssemodesuffix>\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
17731   [(set_attr "type" "sselog")
17732    (set_attr "prefix" "<mask_prefix2>")
17733    (set_attr "mode" "<sseinsnmode>")])
17735 (define_insn "avx2_permv2ti"
17736   [(set (match_operand:V4DI 0 "register_operand" "=x")
17737         (unspec:V4DI
17738           [(match_operand:V4DI 1 "register_operand" "x")
17739            (match_operand:V4DI 2 "nonimmediate_operand" "xm")
17740            (match_operand:SI 3 "const_0_to_255_operand" "n")]
17741           UNSPEC_VPERMTI))]
17742   "TARGET_AVX2"
17743   "vperm2i128\t{%3, %2, %1, %0|%0, %1, %2, %3}"
17744   [(set_attr "type" "sselog")
17745    (set_attr "prefix" "vex")
17746    (set_attr "mode" "OI")])
17748 (define_insn "avx2_vec_dupv4df"
17749   [(set (match_operand:V4DF 0 "register_operand" "=v")
17750         (vec_duplicate:V4DF
17751           (vec_select:DF
17752             (match_operand:V2DF 1 "register_operand" "v")
17753             (parallel [(const_int 0)]))))]
17754   "TARGET_AVX2"
17755   "vbroadcastsd\t{%1, %0|%0, %1}"
17756   [(set_attr "type" "sselog1")
17757    (set_attr "prefix" "maybe_evex")
17758    (set_attr "mode" "V4DF")])
17760 (define_insn "<avx512>_vec_dup<mode>_1"
17761   [(set (match_operand:VI_AVX512BW 0 "register_operand" "=v,v")
17762         (vec_duplicate:VI_AVX512BW
17763           (vec_select:<ssescalarmode>
17764             (match_operand:VI_AVX512BW 1 "nonimmediate_operand" "v,m")
17765             (parallel [(const_int 0)]))))]
17766   "TARGET_AVX512F"
17767   "@
17768    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}
17769    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %<iptr>1}"
17770   [(set_attr "type" "ssemov")
17771    (set_attr "prefix" "evex")
17772    (set_attr "mode" "<sseinsnmode>")])
17774 (define_insn "<avx512>_vec_dup<mode><mask_name>"
17775   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v")
17776         (vec_duplicate:V48_AVX512VL
17777           (vec_select:<ssescalarmode>
17778             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
17779             (parallel [(const_int 0)]))))]
17780   "TARGET_AVX512F"
17782   /*  There is no DF broadcast (in AVX-512*) to 128b register.
17783       Mimic it with integer variant.  */
17784   if (<MODE>mode == V2DFmode)
17785     return "vpbroadcastq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}";
17787   return "v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %<iptr>1}";
17789   [(set_attr "type" "ssemov")
17790    (set_attr "prefix" "evex")
17791    (set_attr "mode" "<sseinsnmode>")])
17793 (define_insn "<avx512>_vec_dup<mode><mask_name>"
17794   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
17795         (vec_duplicate:VI12_AVX512VL
17796           (vec_select:<ssescalarmode>
17797             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
17798             (parallel [(const_int 0)]))))]
17799   "TARGET_AVX512BW"
17800   "vpbroadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %<iptr>1}"
17801   [(set_attr "type" "ssemov")
17802    (set_attr "prefix" "evex")
17803    (set_attr "mode" "<sseinsnmode>")])
17805 (define_insn "<mask_codefor>avx512f_broadcast<mode><mask_name>"
17806   [(set (match_operand:V16FI 0 "register_operand" "=v,v")
17807         (vec_duplicate:V16FI
17808           (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "v,m")))]
17809   "TARGET_AVX512F"
17810   "@
17811    vshuf<shuffletype>32x4\t{$0x0, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x0}
17812    vbroadcast<shuffletype>32x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17813   [(set_attr "type" "ssemov")
17814    (set_attr "prefix" "evex")
17815    (set_attr "mode" "<sseinsnmode>")])
17817 (define_insn "<mask_codefor>avx512f_broadcast<mode><mask_name>"
17818   [(set (match_operand:V8FI 0 "register_operand" "=v,v")
17819         (vec_duplicate:V8FI
17820           (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "v,m")))]
17821   "TARGET_AVX512F"
17822   "@
17823    vshuf<shuffletype>64x2\t{$0x44, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x44}
17824    vbroadcast<shuffletype>64x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17825   [(set_attr "type" "ssemov")
17826    (set_attr "prefix" "evex")
17827    (set_attr "mode" "<sseinsnmode>")])
17829 (define_insn "<mask_codefor><avx512>_vec_dup_gpr<mode><mask_name>"
17830   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v,v")
17831         (vec_duplicate:VI12_AVX512VL
17832           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "vm,r")))]
17833   "TARGET_AVX512BW"
17834   "@
17835    vpbroadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}
17836    vpbroadcast<bcstscalarsuff>\t{%k1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
17837   [(set_attr "type" "ssemov")
17838    (set_attr "prefix" "evex")
17839    (set_attr "mode" "<sseinsnmode>")])
17841 (define_insn "<mask_codefor><avx512>_vec_dup_gpr<mode><mask_name>"
17842   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v,v")
17843         (vec_duplicate:V48_AVX512VL
17844           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "vm,r")))]
17845   "TARGET_AVX512F"
17846   "v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17847   [(set_attr "type" "ssemov")
17848    (set_attr "prefix" "evex")
17849    (set_attr "mode" "<sseinsnmode>")
17850    (set (attr "enabled")
17851      (if_then_else (eq_attr "alternative" "1")
17852         (symbol_ref "GET_MODE_CLASS (<ssescalarmode>mode) == MODE_INT
17853                      && (<ssescalarmode>mode != DImode || TARGET_64BIT)")
17854         (const_int 1)))])
17856 (define_insn "vec_dupv4sf"
17857   [(set (match_operand:V4SF 0 "register_operand" "=v,v,x")
17858         (vec_duplicate:V4SF
17859           (match_operand:SF 1 "nonimmediate_operand" "Yv,m,0")))]
17860   "TARGET_SSE"
17861   "@
17862    vshufps\t{$0, %1, %1, %0|%0, %1, %1, 0}
17863    vbroadcastss\t{%1, %0|%0, %1}
17864    shufps\t{$0, %0, %0|%0, %0, 0}"
17865   [(set_attr "isa" "avx,avx,noavx")
17866    (set_attr "type" "sseshuf1,ssemov,sseshuf1")
17867    (set_attr "length_immediate" "1,0,1")
17868    (set_attr "prefix_extra" "0,1,*")
17869    (set_attr "prefix" "maybe_evex,maybe_evex,orig")
17870    (set_attr "mode" "V4SF")])
17872 (define_insn "*vec_dupv4si"
17873   [(set (match_operand:V4SI 0 "register_operand"     "=v,v,x")
17874         (vec_duplicate:V4SI
17875           (match_operand:SI 1 "nonimmediate_operand" "Yv,m,0")))]
17876   "TARGET_SSE"
17877   "@
17878    %vpshufd\t{$0, %1, %0|%0, %1, 0}
17879    vbroadcastss\t{%1, %0|%0, %1}
17880    shufps\t{$0, %0, %0|%0, %0, 0}"
17881   [(set_attr "isa" "sse2,avx,noavx")
17882    (set_attr "type" "sselog1,ssemov,sselog1")
17883    (set_attr "length_immediate" "1,0,1")
17884    (set_attr "prefix_extra" "0,1,*")
17885    (set_attr "prefix" "maybe_vex,maybe_evex,orig")
17886    (set_attr "mode" "TI,V4SF,V4SF")])
17888 (define_insn "*vec_dupv2di"
17889   [(set (match_operand:V2DI 0 "register_operand"     "=x,v,v,x")
17890         (vec_duplicate:V2DI
17891           (match_operand:DI 1 "nonimmediate_operand" " 0,Yv,m,0")))]
17892   "TARGET_SSE"
17893   "@
17894    punpcklqdq\t%0, %0
17895    vpunpcklqdq\t{%d1, %0|%0, %d1}
17896    %vmovddup\t{%1, %0|%0, %1}
17897    movlhps\t%0, %0"
17898   [(set_attr "isa" "sse2_noavx,avx,sse3,noavx")
17899    (set_attr "type" "sselog1,sselog1,sselog1,ssemov")
17900    (set_attr "prefix" "orig,maybe_evex,maybe_vex,orig")
17901    (set_attr "mode" "TI,TI,DF,V4SF")])
17903 (define_insn "avx2_vbroadcasti128_<mode>"
17904   [(set (match_operand:VI_256 0 "register_operand" "=x,v,v")
17905         (vec_concat:VI_256
17906           (match_operand:<ssehalfvecmode> 1 "memory_operand" "m,m,m")
17907           (match_dup 1)))]
17908   "TARGET_AVX2"
17909   "@
17910    vbroadcasti128\t{%1, %0|%0, %1}
17911    vbroadcast<i128vldq>\t{%1, %0|%0, %1}
17912    vbroadcast<shuffletype>32x4\t{%1, %0|%0, %1}"
17913   [(set_attr "isa" "*,avx512dq,avx512vl")
17914    (set_attr "type" "ssemov")
17915    (set_attr "prefix_extra" "1")
17916    (set_attr "prefix" "vex,evex,evex")
17917    (set_attr "mode" "OI")])
17919 ;; Modes handled by AVX vec_dup patterns.
17920 (define_mode_iterator AVX_VEC_DUP_MODE
17921   [V8SI V8SF V4DI V4DF])
17922 (define_mode_attr vecdupssescalarmodesuffix
17923   [(V8SF "ss") (V4DF "sd") (V8SI "ss") (V4DI "sd")])
17924 ;; Modes handled by AVX2 vec_dup patterns.
17925 (define_mode_iterator AVX2_VEC_DUP_MODE
17926   [V32QI V16QI V16HI V8HI V8SI V4SI])
17928 (define_insn "*vec_dup<mode>"
17929   [(set (match_operand:AVX2_VEC_DUP_MODE 0 "register_operand" "=x,x,v")
17930         (vec_duplicate:AVX2_VEC_DUP_MODE
17931           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,x,$r")))]
17932   "TARGET_AVX2"
17933   "@
17934    v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0|%0, %1}
17935    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}
17936    #"
17937   [(set_attr "isa" "*,*,noavx512vl")
17938    (set_attr "type" "ssemov")
17939    (set_attr "prefix_extra" "1")
17940    (set_attr "prefix" "maybe_evex")
17941    (set_attr "mode" "<sseinsnmode>")
17942    (set (attr "preferred_for_speed")
17943      (cond [(eq_attr "alternative" "2")
17944               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
17945            ]
17946            (symbol_ref "true")))])
17948 (define_insn "vec_dup<mode>"
17949   [(set (match_operand:AVX_VEC_DUP_MODE 0 "register_operand" "=x,x,x,v,x")
17950         (vec_duplicate:AVX_VEC_DUP_MODE
17951           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,m,x,v,?x")))]
17952   "TARGET_AVX"
17953   "@
17954    v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0|%0, %1}
17955    vbroadcast<vecdupssescalarmodesuffix>\t{%1, %0|%0, %1}
17956    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}
17957    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %g0|%g0, %x1}
17958    #"
17959   [(set_attr "type" "ssemov")
17960    (set_attr "prefix_extra" "1")
17961    (set_attr "prefix" "maybe_evex")
17962    (set_attr "isa" "avx2,noavx2,avx2,avx512f,noavx2")
17963    (set_attr "mode" "<sseinsnmode>,V8SF,<sseinsnmode>,<sseinsnmode>,V8SF")])
17965 (define_split
17966   [(set (match_operand:AVX2_VEC_DUP_MODE 0 "register_operand")
17967         (vec_duplicate:AVX2_VEC_DUP_MODE
17968           (match_operand:<ssescalarmode> 1 "register_operand")))]
17969   "TARGET_AVX2
17970    /* Disable this splitter if avx512vl_vec_dup_gprv*[qhs]i insn is
17971       available, because then we can broadcast from GPRs directly.
17972       For V*[QH]I modes it requires both -mavx512vl and -mavx512bw,
17973       for V*SI mode it requires just -mavx512vl.  */
17974    && !(TARGET_AVX512VL
17975         && (TARGET_AVX512BW || <ssescalarmode>mode == SImode))
17976    && reload_completed && GENERAL_REG_P (operands[1])"
17977   [(const_int 0)]
17979   emit_insn (gen_vec_setv4si_0 (gen_lowpart (V4SImode, operands[0]),
17980                                 CONST0_RTX (V4SImode),
17981                                 gen_lowpart (SImode, operands[1])));
17982   emit_insn (gen_avx2_pbroadcast<mode> (operands[0],
17983                                         gen_lowpart (<ssexmmmode>mode,
17984                                                      operands[0])));
17985   DONE;
17988 (define_split
17989   [(set (match_operand:AVX_VEC_DUP_MODE 0 "register_operand")
17990         (vec_duplicate:AVX_VEC_DUP_MODE
17991           (match_operand:<ssescalarmode> 1 "register_operand")))]
17992   "TARGET_AVX && !TARGET_AVX2 && reload_completed"
17993   [(set (match_dup 2)
17994         (vec_duplicate:<ssehalfvecmode> (match_dup 1)))
17995    (set (match_dup 0)
17996         (vec_concat:AVX_VEC_DUP_MODE (match_dup 2) (match_dup 2)))]
17997   "operands[2] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);")
17999 (define_insn "avx_vbroadcastf128_<mode>"
18000   [(set (match_operand:V_256 0 "register_operand" "=x,x,x,v,v,v,v")
18001         (vec_concat:V_256
18002           (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "m,0,?x,m,0,m,0")
18003           (match_dup 1)))]
18004   "TARGET_AVX"
18005   "@
18006    vbroadcast<i128>\t{%1, %0|%0, %1}
18007    vinsert<i128>\t{$1, %1, %0, %0|%0, %0, %1, 1}
18008    vperm2<i128>\t{$0, %t1, %t1, %0|%0, %t1, %t1, 0}
18009    vbroadcast<i128vldq>\t{%1, %0|%0, %1}
18010    vinsert<i128vldq>\t{$1, %1, %0, %0|%0, %0, %1, 1}
18011    vbroadcast<shuffletype>32x4\t{%1, %0|%0, %1}
18012    vinsert<shuffletype>32x4\t{$1, %1, %0, %0|%0, %0, %1, 1}"
18013   [(set_attr "isa" "*,*,*,avx512dq,avx512dq,avx512vl,avx512vl")
18014    (set_attr "type" "ssemov,sselog1,sselog1,ssemov,sselog1,ssemov,sselog1")
18015    (set_attr "prefix_extra" "1")
18016    (set_attr "length_immediate" "0,1,1,0,1,0,1")
18017    (set_attr "prefix" "vex,vex,vex,evex,evex,evex,evex")
18018    (set_attr "mode" "<sseinsnmode>")])
18020 ;; For broadcast[i|f]32x2.  Yes there is no v4sf version, only v4si.
18021 (define_mode_iterator VI4F_BRCST32x2
18022   [V16SI (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
18023    V16SF (V8SF "TARGET_AVX512VL")])
18025 (define_mode_attr 64x2mode
18026   [(V8DF "V2DF") (V8DI "V2DI") (V4DI "V2DI") (V4DF "V2DF")])
18028 (define_mode_attr 32x2mode
18029   [(V16SF "V2SF") (V16SI "V2SI") (V8SI "V2SI")
18030   (V8SF "V2SF") (V4SI "V2SI")])
18032 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>"
18033   [(set (match_operand:VI4F_BRCST32x2 0 "register_operand" "=v")
18034         (vec_duplicate:VI4F_BRCST32x2
18035           (vec_select:<32x2mode>
18036             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
18037             (parallel [(const_int 0) (const_int 1)]))))]
18038   "TARGET_AVX512DQ"
18039   "vbroadcast<shuffletype>32x2\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
18040   [(set_attr "type" "ssemov")
18041    (set_attr "prefix_extra" "1")
18042    (set_attr "prefix" "evex")
18043    (set_attr "mode" "<sseinsnmode>")])
18045 (define_insn "<mask_codefor>avx512vl_broadcast<mode><mask_name>_1"
18046   [(set (match_operand:VI4F_256 0 "register_operand" "=v,v")
18047         (vec_duplicate:VI4F_256
18048          (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "v,m")))]
18049   "TARGET_AVX512VL"
18050   "@
18051    vshuf<shuffletype>32x4\t{$0x0, %t1, %t1, %0<mask_operand2>|%0<mask_operand2>, %t1, %t1, 0x0}
18052    vbroadcast<shuffletype>32x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18053   [(set_attr "type" "ssemov")
18054    (set_attr "prefix_extra" "1")
18055    (set_attr "prefix" "evex")
18056    (set_attr "mode" "<sseinsnmode>")])
18058 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>_1"
18059   [(set (match_operand:V16FI 0 "register_operand" "=v,v")
18060        (vec_duplicate:V16FI
18061          (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "v,m")))]
18062   "TARGET_AVX512DQ"
18063   "@
18064    vshuf<shuffletype>32x4\t{$0x44, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x44}
18065    vbroadcast<shuffletype>32x8\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18066   [(set_attr "type" "ssemov")
18067    (set_attr "prefix_extra" "1")
18068    (set_attr "prefix" "evex")
18069    (set_attr "mode" "<sseinsnmode>")])
18071 ;; For broadcast[i|f]64x2
18072 (define_mode_iterator VI8F_BRCST64x2
18073   [V8DI V8DF (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")])
18075 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>_1"
18076   [(set (match_operand:VI8F_BRCST64x2 0 "register_operand" "=v,v")
18077        (vec_duplicate:VI8F_BRCST64x2
18078          (match_operand:<64x2mode> 1 "nonimmediate_operand" "v,m")))]
18079   "TARGET_AVX512DQ"
18080   "@
18081    vshuf<shuffletype>64x2\t{$0x0, %<xtg_mode>1, %<xtg_mode>1, %0<mask_operand2>|%0<mask_operand2>, %<xtg_mode>1, %<xtg_mode>1, 0x0}
18082    vbroadcast<shuffletype>64x2\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18083   [(set_attr "type" "ssemov")
18084    (set_attr "prefix_extra" "1")
18085    (set_attr "prefix" "evex")
18086    (set_attr "mode" "<sseinsnmode>")])
18088 (define_insn "avx512cd_maskb_vec_dup<mode>"
18089   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
18090         (vec_duplicate:VI8_AVX512VL
18091           (zero_extend:DI
18092             (match_operand:QI 1 "register_operand" "Yk"))))]
18093   "TARGET_AVX512CD"
18094   "vpbroadcastmb2q\t{%1, %0|%0, %1}"
18095   [(set_attr "type" "mskmov")
18096    (set_attr "prefix" "evex")
18097    (set_attr "mode" "XI")])
18099 (define_insn "avx512cd_maskw_vec_dup<mode>"
18100   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
18101         (vec_duplicate:VI4_AVX512VL
18102           (zero_extend:SI
18103             (match_operand:HI 1 "register_operand" "Yk"))))]
18104   "TARGET_AVX512CD"
18105   "vpbroadcastmw2d\t{%1, %0|%0, %1}"
18106   [(set_attr "type" "mskmov")
18107    (set_attr "prefix" "evex")
18108    (set_attr "mode" "XI")])
18110 ;; Recognize broadcast as a vec_select as produced by builtin_vec_perm.
18111 ;; If it so happens that the input is in memory, use vbroadcast.
18112 ;; Otherwise use vpermilp (and in the case of 256-bit modes, vperm2f128).
18113 (define_insn "*avx_vperm_broadcast_v4sf"
18114   [(set (match_operand:V4SF 0 "register_operand" "=v,v,v")
18115         (vec_select:V4SF
18116           (match_operand:V4SF 1 "nonimmediate_operand" "m,o,v")
18117           (match_parallel 2 "avx_vbroadcast_operand"
18118             [(match_operand 3 "const_int_operand" "C,n,n")])))]
18119   "TARGET_AVX"
18121   int elt = INTVAL (operands[3]);
18122   switch (which_alternative)
18123     {
18124     case 0:
18125     case 1:
18126       operands[1] = adjust_address_nv (operands[1], SFmode, elt * 4);
18127       return "vbroadcastss\t{%1, %0|%0, %k1}";
18128     case 2:
18129       operands[2] = GEN_INT (elt * 0x55);
18130       return "vpermilps\t{%2, %1, %0|%0, %1, %2}";
18131     default:
18132       gcc_unreachable ();
18133     }
18135   [(set_attr "type" "ssemov,ssemov,sselog1")
18136    (set_attr "prefix_extra" "1")
18137    (set_attr "length_immediate" "0,0,1")
18138    (set_attr "prefix" "maybe_evex")
18139    (set_attr "mode" "SF,SF,V4SF")])
18141 (define_insn_and_split "*avx_vperm_broadcast_<mode>"
18142   [(set (match_operand:VF_256 0 "register_operand" "=v,v,v")
18143         (vec_select:VF_256
18144           (match_operand:VF_256 1 "nonimmediate_operand" "m,o,?v")
18145           (match_parallel 2 "avx_vbroadcast_operand"
18146             [(match_operand 3 "const_int_operand" "C,n,n")])))]
18147   "TARGET_AVX"
18148   "#"
18149   "&& reload_completed && (<MODE>mode != V4DFmode || !TARGET_AVX2)"
18150   [(set (match_dup 0) (vec_duplicate:VF_256 (match_dup 1)))]
18152   rtx op0 = operands[0], op1 = operands[1];
18153   int elt = INTVAL (operands[3]);
18155   if (REG_P (op1))
18156     {
18157       int mask;
18159       if (TARGET_AVX2 && elt == 0)
18160         {
18161           emit_insn (gen_vec_dup<mode> (op0, gen_lowpart (<ssescalarmode>mode,
18162                                                           op1)));
18163           DONE;
18164         }
18166       /* Shuffle element we care about into all elements of the 128-bit lane.
18167          The other lane gets shuffled too, but we don't care.  */
18168       if (<MODE>mode == V4DFmode)
18169         mask = (elt & 1 ? 15 : 0);
18170       else
18171         mask = (elt & 3) * 0x55;
18172       emit_insn (gen_avx_vpermil<mode> (op0, op1, GEN_INT (mask)));
18174       /* Shuffle the lane we care about into both lanes of the dest.  */
18175       mask = (elt / (<ssescalarnum> / 2)) * 0x11;
18176       if (EXT_REX_SSE_REG_P (op0))
18177         {
18178           /* There is no EVEX VPERM2F128, but we can use either VBROADCASTSS
18179              or VSHUFF128.  */
18180           gcc_assert (<MODE>mode == V8SFmode);
18181           if ((mask & 1) == 0)
18182             emit_insn (gen_avx2_vec_dupv8sf (op0,
18183                                              gen_lowpart (V4SFmode, op0)));
18184           else
18185             emit_insn (gen_avx512vl_shuf_f32x4_1 (op0, op0, op0,
18186                                                   GEN_INT (4), GEN_INT (5),
18187                                                   GEN_INT (6), GEN_INT (7),
18188                                                   GEN_INT (12), GEN_INT (13),
18189                                                   GEN_INT (14), GEN_INT (15)));
18190           DONE;
18191         }
18193       emit_insn (gen_avx_vperm2f128<mode>3 (op0, op0, op0, GEN_INT (mask)));
18194       DONE;
18195     }
18197   operands[1] = adjust_address (op1, <ssescalarmode>mode,
18198                                 elt * GET_MODE_SIZE (<ssescalarmode>mode));
18201 (define_expand "<sse2_avx_avx512f>_vpermil<mode><mask_name>"
18202   [(set (match_operand:VF2 0 "register_operand")
18203         (vec_select:VF2
18204           (match_operand:VF2 1 "nonimmediate_operand")
18205           (match_operand:SI 2 "const_0_to_255_operand")))]
18206   "TARGET_AVX && <mask_mode512bit_condition>"
18208   int mask = INTVAL (operands[2]);
18209   rtx perm[<ssescalarnum>];
18211   int i;
18212   for (i = 0; i < <ssescalarnum>; i = i + 2)
18213     {
18214       perm[i]     = GEN_INT (((mask >> i)       & 1) + i);
18215       perm[i + 1] = GEN_INT (((mask >> (i + 1)) & 1) + i);
18216     }
18218   operands[2]
18219     = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (<ssescalarnum>, perm));
18222 (define_expand "<sse2_avx_avx512f>_vpermil<mode><mask_name>"
18223   [(set (match_operand:VF1 0 "register_operand")
18224         (vec_select:VF1
18225           (match_operand:VF1 1 "nonimmediate_operand")
18226           (match_operand:SI 2 "const_0_to_255_operand")))]
18227   "TARGET_AVX && <mask_mode512bit_condition>"
18229   int mask = INTVAL (operands[2]);
18230   rtx perm[<ssescalarnum>];
18232   int i;
18233   for (i = 0; i < <ssescalarnum>; i = i + 4)
18234     {
18235       perm[i]     = GEN_INT (((mask >> 0) & 3) + i);
18236       perm[i + 1] = GEN_INT (((mask >> 2) & 3) + i);
18237       perm[i + 2] = GEN_INT (((mask >> 4) & 3) + i);
18238       perm[i + 3] = GEN_INT (((mask >> 6) & 3) + i);
18239     }
18241   operands[2]
18242     = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (<ssescalarnum>, perm));
18245 (define_insn "*<sse2_avx_avx512f>_vpermilp<mode><mask_name>"
18246   [(set (match_operand:VF 0 "register_operand" "=v")
18247         (vec_select:VF
18248           (match_operand:VF 1 "nonimmediate_operand" "vm")
18249           (match_parallel 2 ""
18250             [(match_operand 3 "const_int_operand")])))]
18251   "TARGET_AVX && <mask_mode512bit_condition>
18252    && avx_vpermilp_parallel (operands[2], <MODE>mode)"
18254   int mask = avx_vpermilp_parallel (operands[2], <MODE>mode) - 1;
18255   operands[2] = GEN_INT (mask);
18256   return "vpermil<ssemodesuffix>\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}";
18258   [(set_attr "type" "sselog")
18259    (set_attr "prefix_extra" "1")
18260    (set_attr "length_immediate" "1")
18261    (set_attr "prefix" "<mask_prefix>")
18262    (set_attr "mode" "<sseinsnmode>")])
18264 (define_insn "<sse2_avx_avx512f>_vpermilvar<mode>3<mask_name>"
18265   [(set (match_operand:VF 0 "register_operand" "=v")
18266         (unspec:VF
18267           [(match_operand:VF 1 "register_operand" "v")
18268            (match_operand:<sseintvecmode> 2 "nonimmediate_operand" "vm")]
18269           UNSPEC_VPERMIL))]
18270   "TARGET_AVX && <mask_mode512bit_condition>"
18271   "vpermil<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18272   [(set_attr "type" "sselog")
18273    (set_attr "prefix_extra" "1")
18274    (set_attr "btver2_decode" "vector")
18275    (set_attr "prefix" "<mask_prefix>")
18276    (set_attr "mode" "<sseinsnmode>")])
18278 (define_mode_iterator VPERMI2
18279   [V16SI V16SF V8DI V8DF
18280    (V8SI "TARGET_AVX512VL") (V8SF "TARGET_AVX512VL")
18281    (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")
18282    (V4SI "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
18283    (V2DI "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")
18284    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX512BW && TARGET_AVX512VL")
18285    (V8HI "TARGET_AVX512BW && TARGET_AVX512VL")
18286    (V64QI "TARGET_AVX512VBMI") (V32QI "TARGET_AVX512VBMI && TARGET_AVX512VL")
18287    (V16QI "TARGET_AVX512VBMI && TARGET_AVX512VL")])
18289 (define_mode_iterator VPERMI2I
18290   [V16SI V8DI
18291    (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
18292    (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")
18293    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX512BW && TARGET_AVX512VL")
18294    (V8HI "TARGET_AVX512BW && TARGET_AVX512VL")
18295    (V64QI "TARGET_AVX512VBMI") (V32QI "TARGET_AVX512VBMI && TARGET_AVX512VL")
18296    (V16QI "TARGET_AVX512VBMI && TARGET_AVX512VL")])
18298 (define_expand "<avx512>_vpermi2var<mode>3_mask"
18299   [(set (match_operand:VPERMI2 0 "register_operand")
18300         (vec_merge:VPERMI2
18301           (unspec:VPERMI2
18302             [(match_operand:<sseintvecmode> 2 "register_operand")
18303              (match_operand:VPERMI2 1 "register_operand")
18304              (match_operand:VPERMI2 3 "nonimmediate_operand")]
18305             UNSPEC_VPERMT2)
18306           (match_dup 5)
18307           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
18308   "TARGET_AVX512F"
18310   operands[2] = force_reg (<sseintvecmode>mode, operands[2]);
18311   operands[5] = gen_lowpart (<MODE>mode, operands[2]);
18314 (define_insn "*<avx512>_vpermi2var<mode>3_mask"
18315   [(set (match_operand:VPERMI2I 0 "register_operand" "=v")
18316         (vec_merge:VPERMI2I
18317           (unspec:VPERMI2I
18318             [(match_operand:<sseintvecmode> 2 "register_operand" "0")
18319              (match_operand:VPERMI2I 1 "register_operand" "v")
18320              (match_operand:VPERMI2I 3 "nonimmediate_operand" "vm")]
18321             UNSPEC_VPERMT2)
18322           (match_dup 2)
18323           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
18324   "TARGET_AVX512F"
18325   "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
18326   [(set_attr "type" "sselog")
18327    (set_attr "prefix" "evex")
18328    (set_attr "mode" "<sseinsnmode>")])
18330 (define_insn "*<avx512>_vpermi2var<mode>3_mask"
18331   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
18332         (vec_merge:VF_AVX512VL
18333           (unspec:VF_AVX512VL
18334             [(match_operand:<sseintvecmode> 2 "register_operand" "0")
18335              (match_operand:VF_AVX512VL 1 "register_operand" "v")
18336              (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "vm")]
18337             UNSPEC_VPERMT2)
18338           (subreg:VF_AVX512VL (match_dup 2) 0)
18339           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
18340   "TARGET_AVX512F"
18341   "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
18342   [(set_attr "type" "sselog")
18343    (set_attr "prefix" "evex")
18344    (set_attr "mode" "<sseinsnmode>")])
18346 (define_expand "<avx512>_vpermt2var<mode>3_maskz"
18347   [(match_operand:VPERMI2 0 "register_operand")
18348    (match_operand:<sseintvecmode> 1 "register_operand")
18349    (match_operand:VPERMI2 2 "register_operand")
18350    (match_operand:VPERMI2 3 "nonimmediate_operand")
18351    (match_operand:<avx512fmaskmode> 4 "register_operand")]
18352   "TARGET_AVX512F"
18354   emit_insn (gen_<avx512>_vpermt2var<mode>3_maskz_1 (
18355         operands[0], operands[1], operands[2], operands[3],
18356         CONST0_RTX (<MODE>mode), operands[4]));
18357   DONE;
18360 (define_insn "<avx512>_vpermt2var<mode>3<sd_maskz_name>"
18361   [(set (match_operand:VPERMI2 0 "register_operand" "=v,v")
18362         (unspec:VPERMI2
18363           [(match_operand:<sseintvecmode> 1 "register_operand" "v,0")
18364            (match_operand:VPERMI2 2 "register_operand" "0,v")
18365            (match_operand:VPERMI2 3 "nonimmediate_operand" "vm,vm")]
18366           UNSPEC_VPERMT2))]
18367   "TARGET_AVX512F"
18368   "@
18369    vpermt2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}
18370    vpermi2<ssemodesuffix>\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}"
18371   [(set_attr "type" "sselog")
18372    (set_attr "prefix" "evex")
18373    (set_attr "mode" "<sseinsnmode>")])
18375 (define_insn "<avx512>_vpermt2var<mode>3_mask"
18376   [(set (match_operand:VPERMI2 0 "register_operand" "=v")
18377         (vec_merge:VPERMI2
18378           (unspec:VPERMI2
18379             [(match_operand:<sseintvecmode> 1 "register_operand" "v")
18380             (match_operand:VPERMI2 2 "register_operand" "0")
18381             (match_operand:VPERMI2 3 "nonimmediate_operand" "vm")]
18382             UNSPEC_VPERMT2)
18383           (match_dup 2)
18384           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
18385   "TARGET_AVX512F"
18386   "vpermt2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
18387   [(set_attr "type" "sselog")
18388    (set_attr "prefix" "evex")
18389    (set_attr "mode" "<sseinsnmode>")])
18391 (define_expand "avx_vperm2f128<mode>3"
18392   [(set (match_operand:AVX256MODE2P 0 "register_operand")
18393         (unspec:AVX256MODE2P
18394           [(match_operand:AVX256MODE2P 1 "register_operand")
18395            (match_operand:AVX256MODE2P 2 "nonimmediate_operand")
18396            (match_operand:SI 3 "const_0_to_255_operand")]
18397           UNSPEC_VPERMIL2F128))]
18398   "TARGET_AVX"
18400   int mask = INTVAL (operands[3]);
18401   if ((mask & 0x88) == 0)
18402     {
18403       rtx perm[<ssescalarnum>], t1, t2;
18404       int i, base, nelt = <ssescalarnum>, nelt2 = nelt / 2;
18406       base = (mask & 3) * nelt2;
18407       for (i = 0; i < nelt2; ++i)
18408         perm[i] = GEN_INT (base + i);
18410       base = ((mask >> 4) & 3) * nelt2;
18411       for (i = 0; i < nelt2; ++i)
18412         perm[i + nelt2] = GEN_INT (base + i);
18414       t2 = gen_rtx_VEC_CONCAT (<ssedoublevecmode>mode,
18415                                operands[1], operands[2]);
18416       t1 = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (nelt, perm));
18417       t2 = gen_rtx_VEC_SELECT (<MODE>mode, t2, t1);
18418       t2 = gen_rtx_SET (operands[0], t2);
18419       emit_insn (t2);
18420       DONE;
18421     }
18424 ;; Note that bits 7 and 3 of the imm8 allow lanes to be zeroed, which
18425 ;; means that in order to represent this properly in rtl we'd have to
18426 ;; nest *another* vec_concat with a zero operand and do the select from
18427 ;; a 4x wide vector.  That doesn't seem very nice.
18428 (define_insn "*avx_vperm2f128<mode>_full"
18429   [(set (match_operand:AVX256MODE2P 0 "register_operand" "=x")
18430         (unspec:AVX256MODE2P
18431           [(match_operand:AVX256MODE2P 1 "register_operand" "x")
18432            (match_operand:AVX256MODE2P 2 "nonimmediate_operand" "xm")
18433            (match_operand:SI 3 "const_0_to_255_operand" "n")]
18434           UNSPEC_VPERMIL2F128))]
18435   "TARGET_AVX"
18436   "vperm2<i128>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
18437   [(set_attr "type" "sselog")
18438    (set_attr "prefix_extra" "1")
18439    (set_attr "length_immediate" "1")
18440    (set_attr "prefix" "vex")
18441    (set_attr "mode" "<sseinsnmode>")])
18443 (define_insn "*avx_vperm2f128<mode>_nozero"
18444   [(set (match_operand:AVX256MODE2P 0 "register_operand" "=x")
18445         (vec_select:AVX256MODE2P
18446           (vec_concat:<ssedoublevecmode>
18447             (match_operand:AVX256MODE2P 1 "register_operand" "x")
18448             (match_operand:AVX256MODE2P 2 "nonimmediate_operand" "xm"))
18449           (match_parallel 3 ""
18450             [(match_operand 4 "const_int_operand")])))]
18451   "TARGET_AVX
18452    && avx_vperm2f128_parallel (operands[3], <MODE>mode)"
18454   int mask = avx_vperm2f128_parallel (operands[3], <MODE>mode) - 1;
18455   if (mask == 0x12)
18456     return "vinsert<i128>\t{$0, %x2, %1, %0|%0, %1, %x2, 0}";
18457   if (mask == 0x20)
18458     return "vinsert<i128>\t{$1, %x2, %1, %0|%0, %1, %x2, 1}";
18459   operands[3] = GEN_INT (mask);
18460   return "vperm2<i128>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
18462   [(set_attr "type" "sselog")
18463    (set_attr "prefix_extra" "1")
18464    (set_attr "length_immediate" "1")
18465    (set_attr "prefix" "vex")
18466    (set_attr "mode" "<sseinsnmode>")])
18468 (define_insn "*ssse3_palignr<mode>_perm"
18469   [(set (match_operand:V_128 0 "register_operand" "=x,x,v")
18470       (vec_select:V_128
18471         (match_operand:V_128 1 "register_operand" "0,x,v")
18472         (match_parallel 2 "palignr_operand"
18473           [(match_operand 3 "const_int_operand" "n,n,n")])))]
18474   "TARGET_SSSE3"
18476   operands[2] = (GEN_INT (INTVAL (operands[3])
18477                  * GET_MODE_UNIT_SIZE (GET_MODE (operands[0]))));
18479   switch (which_alternative)
18480     {
18481     case 0:
18482       return "palignr\t{%2, %1, %0|%0, %1, %2}";
18483     case 1:
18484     case 2:
18485       return "vpalignr\t{%2, %1, %1, %0|%0, %1, %1, %2}";
18486     default:
18487       gcc_unreachable ();
18488     }
18490   [(set_attr "isa" "noavx,avx,avx512bw")
18491    (set_attr "type" "sseishft")
18492    (set_attr "atom_unit" "sishuf")
18493    (set_attr "prefix_data16" "1,*,*")
18494    (set_attr "prefix_extra" "1")
18495    (set_attr "length_immediate" "1")
18496    (set_attr "prefix" "orig,vex,evex")])
18498 (define_expand "avx512vl_vinsert<mode>"
18499   [(match_operand:VI48F_256 0 "register_operand")
18500    (match_operand:VI48F_256 1 "register_operand")
18501    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
18502    (match_operand:SI 3 "const_0_to_1_operand")
18503    (match_operand:VI48F_256 4 "register_operand")
18504    (match_operand:<avx512fmaskmode> 5 "register_operand")]
18505   "TARGET_AVX512VL"
18507   rtx (*insn)(rtx, rtx, rtx, rtx, rtx);
18509   switch (INTVAL (operands[3]))
18510     {
18511     case 0:
18512       insn = gen_vec_set_lo_<mode>_mask;
18513       break;
18514     case 1:
18515       insn = gen_vec_set_hi_<mode>_mask;
18516       break;
18517     default:
18518       gcc_unreachable ();
18519     }
18521   emit_insn (insn (operands[0], operands[1], operands[2], operands[4],
18522                    operands[5]));
18523   DONE;
18526 (define_expand "avx_vinsertf128<mode>"
18527   [(match_operand:V_256 0 "register_operand")
18528    (match_operand:V_256 1 "register_operand")
18529    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
18530    (match_operand:SI 3 "const_0_to_1_operand")]
18531   "TARGET_AVX"
18533   rtx (*insn)(rtx, rtx, rtx);
18535   switch (INTVAL (operands[3]))
18536     {
18537     case 0:
18538       insn = gen_vec_set_lo_<mode>;
18539       break;
18540     case 1:
18541       insn = gen_vec_set_hi_<mode>;
18542       break;
18543     default:
18544       gcc_unreachable ();
18545     }
18547   emit_insn (insn (operands[0], operands[1], operands[2]));
18548   DONE;
18551 (define_insn "vec_set_lo_<mode><mask_name>"
18552   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
18553         (vec_concat:VI8F_256
18554           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
18555           (vec_select:<ssehalfvecmode>
18556             (match_operand:VI8F_256 1 "register_operand" "v")
18557             (parallel [(const_int 2) (const_int 3)]))))]
18558   "TARGET_AVX && <mask_avx512dq_condition>"
18560   if (TARGET_AVX512DQ)
18561     return "vinsert<shuffletype>64x2\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
18562   else if (TARGET_AVX512VL)
18563     return "vinsert<shuffletype>32x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
18564   else
18565     return "vinsert<i128>\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}";
18567   [(set_attr "type" "sselog")
18568    (set_attr "prefix_extra" "1")
18569    (set_attr "length_immediate" "1")
18570    (set_attr "prefix" "vex")
18571    (set_attr "mode" "<sseinsnmode>")])
18573 (define_insn "vec_set_hi_<mode><mask_name>"
18574   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
18575         (vec_concat:VI8F_256
18576           (vec_select:<ssehalfvecmode>
18577             (match_operand:VI8F_256 1 "register_operand" "v")
18578             (parallel [(const_int 0) (const_int 1)]))
18579           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
18580   "TARGET_AVX && <mask_avx512dq_condition>"
18582   if (TARGET_AVX512DQ)
18583     return "vinsert<shuffletype>64x2\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
18584   else if (TARGET_AVX512VL)
18585     return "vinsert<shuffletype>32x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
18586   else
18587     return "vinsert<i128>\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}";
18589   [(set_attr "type" "sselog")
18590    (set_attr "prefix_extra" "1")
18591    (set_attr "length_immediate" "1")
18592    (set_attr "prefix" "vex")
18593    (set_attr "mode" "<sseinsnmode>")])
18595 (define_insn "vec_set_lo_<mode><mask_name>"
18596   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
18597         (vec_concat:VI4F_256
18598           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
18599           (vec_select:<ssehalfvecmode>
18600             (match_operand:VI4F_256 1 "register_operand" "v")
18601             (parallel [(const_int 4) (const_int 5)
18602                        (const_int 6) (const_int 7)]))))]
18603   "TARGET_AVX"
18605   if (TARGET_AVX512VL)
18606     return "vinsert<shuffletype>32x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
18607   else
18608     return "vinsert<i128>\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}";
18610   [(set_attr "type" "sselog")
18611    (set_attr "prefix_extra" "1")
18612    (set_attr "length_immediate" "1")
18613    (set_attr "prefix" "vex")
18614    (set_attr "mode" "<sseinsnmode>")])
18616 (define_insn "vec_set_hi_<mode><mask_name>"
18617   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
18618         (vec_concat:VI4F_256
18619           (vec_select:<ssehalfvecmode>
18620             (match_operand:VI4F_256 1 "register_operand" "v")
18621             (parallel [(const_int 0) (const_int 1)
18622                        (const_int 2) (const_int 3)]))
18623           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
18624   "TARGET_AVX"
18626   if (TARGET_AVX512VL)
18627     return "vinsert<shuffletype>32x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
18628   else
18629     return "vinsert<i128>\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}";
18631   [(set_attr "type" "sselog")
18632    (set_attr "prefix_extra" "1")
18633    (set_attr "length_immediate" "1")
18634    (set_attr "prefix" "vex")
18635    (set_attr "mode" "<sseinsnmode>")])
18637 (define_insn "vec_set_lo_v16hi"
18638   [(set (match_operand:V16HI 0 "register_operand" "=x,v")
18639         (vec_concat:V16HI
18640           (match_operand:V8HI 2 "nonimmediate_operand" "xm,vm")
18641           (vec_select:V8HI
18642             (match_operand:V16HI 1 "register_operand" "x,v")
18643             (parallel [(const_int 8) (const_int 9)
18644                        (const_int 10) (const_int 11)
18645                        (const_int 12) (const_int 13)
18646                        (const_int 14) (const_int 15)]))))]
18647   "TARGET_AVX"
18648   "@
18649    vinsert%~128\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}
18650    vinserti32x4\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}"
18651   [(set_attr "type" "sselog")
18652    (set_attr "prefix_extra" "1")
18653    (set_attr "length_immediate" "1")
18654    (set_attr "prefix" "vex,evex")
18655    (set_attr "mode" "OI")])
18657 (define_insn "vec_set_hi_v16hi"
18658   [(set (match_operand:V16HI 0 "register_operand" "=x,v")
18659         (vec_concat:V16HI
18660           (vec_select:V8HI
18661             (match_operand:V16HI 1 "register_operand" "x,v")
18662             (parallel [(const_int 0) (const_int 1)
18663                        (const_int 2) (const_int 3)
18664                        (const_int 4) (const_int 5)
18665                        (const_int 6) (const_int 7)]))
18666           (match_operand:V8HI 2 "nonimmediate_operand" "xm,vm")))]
18667   "TARGET_AVX"
18668   "@
18669    vinsert%~128\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}
18670    vinserti32x4\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}"
18671   [(set_attr "type" "sselog")
18672    (set_attr "prefix_extra" "1")
18673    (set_attr "length_immediate" "1")
18674    (set_attr "prefix" "vex,evex")
18675    (set_attr "mode" "OI")])
18677 (define_insn "vec_set_lo_v32qi"
18678   [(set (match_operand:V32QI 0 "register_operand" "=x,v")
18679         (vec_concat:V32QI
18680           (match_operand:V16QI 2 "nonimmediate_operand" "xm,v")
18681           (vec_select:V16QI
18682             (match_operand:V32QI 1 "register_operand" "x,v")
18683             (parallel [(const_int 16) (const_int 17)
18684                        (const_int 18) (const_int 19)
18685                        (const_int 20) (const_int 21)
18686                        (const_int 22) (const_int 23)
18687                        (const_int 24) (const_int 25)
18688                        (const_int 26) (const_int 27)
18689                        (const_int 28) (const_int 29)
18690                        (const_int 30) (const_int 31)]))))]
18691   "TARGET_AVX"
18692   "@
18693    vinsert%~128\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}
18694    vinserti32x4\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}"
18695   [(set_attr "type" "sselog")
18696    (set_attr "prefix_extra" "1")
18697    (set_attr "length_immediate" "1")
18698    (set_attr "prefix" "vex,evex")
18699    (set_attr "mode" "OI")])
18701 (define_insn "vec_set_hi_v32qi"
18702   [(set (match_operand:V32QI 0 "register_operand" "=x,v")
18703         (vec_concat:V32QI
18704           (vec_select:V16QI
18705             (match_operand:V32QI 1 "register_operand" "x,v")
18706             (parallel [(const_int 0) (const_int 1)
18707                        (const_int 2) (const_int 3)
18708                        (const_int 4) (const_int 5)
18709                        (const_int 6) (const_int 7)
18710                        (const_int 8) (const_int 9)
18711                        (const_int 10) (const_int 11)
18712                        (const_int 12) (const_int 13)
18713                        (const_int 14) (const_int 15)]))
18714           (match_operand:V16QI 2 "nonimmediate_operand" "xm,vm")))]
18715   "TARGET_AVX"
18716   "@
18717    vinsert%~128\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}
18718    vinserti32x4\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}"
18719   [(set_attr "type" "sselog")
18720    (set_attr "prefix_extra" "1")
18721    (set_attr "length_immediate" "1")
18722    (set_attr "prefix" "vex,evex")
18723    (set_attr "mode" "OI")])
18725 (define_insn "<avx_avx2>_maskload<ssemodesuffix><avxsizesuffix>"
18726   [(set (match_operand:V48_AVX2 0 "register_operand" "=x")
18727         (unspec:V48_AVX2
18728           [(match_operand:<sseintvecmode> 2 "register_operand" "x")
18729            (match_operand:V48_AVX2 1 "memory_operand" "m")]
18730           UNSPEC_MASKMOV))]
18731   "TARGET_AVX"
18732   "v<sseintprefix>maskmov<ssemodesuffix>\t{%1, %2, %0|%0, %2, %1}"
18733   [(set_attr "type" "sselog1")
18734    (set_attr "prefix_extra" "1")
18735    (set_attr "prefix" "vex")
18736    (set_attr "btver2_decode" "vector")
18737    (set_attr "mode" "<sseinsnmode>")])
18739 (define_insn "<avx_avx2>_maskstore<ssemodesuffix><avxsizesuffix>"
18740   [(set (match_operand:V48_AVX2 0 "memory_operand" "+m")
18741         (unspec:V48_AVX2
18742           [(match_operand:<sseintvecmode> 1 "register_operand" "x")
18743            (match_operand:V48_AVX2 2 "register_operand" "x")
18744            (match_dup 0)]
18745           UNSPEC_MASKMOV))]
18746   "TARGET_AVX"
18747   "v<sseintprefix>maskmov<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
18748   [(set_attr "type" "sselog1")
18749    (set_attr "prefix_extra" "1")
18750    (set_attr "prefix" "vex")
18751    (set_attr "btver2_decode" "vector") 
18752    (set_attr "mode" "<sseinsnmode>")])
18754 (define_expand "maskload<mode><sseintvecmodelower>"
18755   [(set (match_operand:V48_AVX2 0 "register_operand")
18756         (unspec:V48_AVX2
18757           [(match_operand:<sseintvecmode> 2 "register_operand")
18758            (match_operand:V48_AVX2 1 "memory_operand")]
18759           UNSPEC_MASKMOV))]
18760   "TARGET_AVX")
18762 (define_expand "maskload<mode><avx512fmaskmodelower>"
18763   [(set (match_operand:V48_AVX512VL 0 "register_operand")
18764         (vec_merge:V48_AVX512VL
18765           (match_operand:V48_AVX512VL 1 "memory_operand")
18766           (match_dup 0)
18767           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18768   "TARGET_AVX512F")
18770 (define_expand "maskload<mode><avx512fmaskmodelower>"
18771   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
18772         (vec_merge:VI12_AVX512VL
18773           (match_operand:VI12_AVX512VL 1 "memory_operand")
18774           (match_dup 0)
18775           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18776   "TARGET_AVX512BW")
18778 (define_expand "maskstore<mode><sseintvecmodelower>"
18779   [(set (match_operand:V48_AVX2 0 "memory_operand")
18780         (unspec:V48_AVX2
18781           [(match_operand:<sseintvecmode> 2 "register_operand")
18782            (match_operand:V48_AVX2 1 "register_operand")
18783            (match_dup 0)]
18784           UNSPEC_MASKMOV))]
18785   "TARGET_AVX")
18787 (define_expand "maskstore<mode><avx512fmaskmodelower>"
18788   [(set (match_operand:V48_AVX512VL 0 "memory_operand")
18789         (vec_merge:V48_AVX512VL
18790           (match_operand:V48_AVX512VL 1 "register_operand")
18791           (match_dup 0)
18792           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18793   "TARGET_AVX512F")
18795 (define_expand "maskstore<mode><avx512fmaskmodelower>"
18796   [(set (match_operand:VI12_AVX512VL 0 "memory_operand")
18797         (vec_merge:VI12_AVX512VL
18798           (match_operand:VI12_AVX512VL 1 "register_operand")
18799           (match_dup 0)
18800           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18801   "TARGET_AVX512BW")
18803 (define_expand "cbranch<mode>4"
18804   [(set (reg:CC FLAGS_REG)
18805         (compare:CC (match_operand:VI48_AVX 1 "register_operand")
18806                     (match_operand:VI48_AVX 2 "nonimmediate_operand")))
18807    (set (pc) (if_then_else
18808                (match_operator 0 "bt_comparison_operator"
18809                 [(reg:CC FLAGS_REG) (const_int 0)])
18810                (label_ref (match_operand 3))
18811                (pc)))]
18812   "TARGET_SSE4_1"
18814   ix86_expand_branch (GET_CODE (operands[0]),
18815                       operands[1], operands[2], operands[3]);
18816   DONE;
18820 (define_insn_and_split "avx_<castmode><avxsizesuffix>_<castmode>"
18821   [(set (match_operand:AVX256MODE2P 0 "nonimmediate_operand" "=x,m")
18822         (unspec:AVX256MODE2P
18823           [(match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "xm,x")]
18824           UNSPEC_CAST))]
18825   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
18826   "#"
18827   "&& reload_completed"
18828   [(set (match_dup 0) (match_dup 1))]
18830   if (REG_P (operands[0]))
18831     operands[0] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);
18832   else
18833     operands[1] = lowpart_subreg (<MODE>mode, operands[1],
18834                                   <ssehalfvecmode>mode);
18837 ;; Modes handled by vec_init expanders.
18838 (define_mode_iterator VEC_INIT_MODE
18839   [(V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
18840    (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI
18841    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
18842    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI
18843    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
18844    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")
18845    (V4TI "TARGET_AVX512F") (V2TI "TARGET_AVX")])
18847 ;; Likewise, but for initialization from half sized vectors.
18848 ;; Thus, these are all VEC_INIT_MODE modes except V2??.
18849 (define_mode_iterator VEC_INIT_HALF_MODE
18850   [(V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
18851    (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI
18852    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
18853    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX")
18854    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
18855    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX")
18856    (V4TI "TARGET_AVX512F")])
18858 (define_expand "vec_init<mode><ssescalarmodelower>"
18859   [(match_operand:VEC_INIT_MODE 0 "register_operand")
18860    (match_operand 1)]
18861   "TARGET_SSE"
18863   ix86_expand_vector_init (false, operands[0], operands[1]);
18864   DONE;
18867 (define_expand "vec_init<mode><ssehalfvecmodelower>"
18868   [(match_operand:VEC_INIT_HALF_MODE 0 "register_operand")
18869    (match_operand 1)]
18870   "TARGET_SSE"
18872   ix86_expand_vector_init (false, operands[0], operands[1]);
18873   DONE;
18876 (define_insn "<avx2_avx512>_ashrv<mode><mask_name>"
18877   [(set (match_operand:VI48_AVX512F_AVX512VL 0 "register_operand" "=v")
18878         (ashiftrt:VI48_AVX512F_AVX512VL
18879           (match_operand:VI48_AVX512F_AVX512VL 1 "register_operand" "v")
18880           (match_operand:VI48_AVX512F_AVX512VL 2 "nonimmediate_operand" "vm")))]
18881   "TARGET_AVX2 && <mask_mode512bit_condition>"
18882   "vpsrav<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18883   [(set_attr "type" "sseishft")
18884    (set_attr "prefix" "maybe_evex")
18885    (set_attr "mode" "<sseinsnmode>")])
18887 (define_insn "<avx2_avx512>_ashrv<mode><mask_name>"
18888   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
18889         (ashiftrt:VI2_AVX512VL
18890           (match_operand:VI2_AVX512VL 1 "register_operand" "v")
18891           (match_operand:VI2_AVX512VL 2 "nonimmediate_operand" "vm")))]
18892   "TARGET_AVX512BW"
18893   "vpsravw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18894   [(set_attr "type" "sseishft")
18895    (set_attr "prefix" "maybe_evex")
18896    (set_attr "mode" "<sseinsnmode>")])
18898 (define_insn "<avx2_avx512>_<shift_insn>v<mode><mask_name>"
18899   [(set (match_operand:VI48_AVX512F 0 "register_operand" "=v")
18900         (any_lshift:VI48_AVX512F
18901           (match_operand:VI48_AVX512F 1 "register_operand" "v")
18902           (match_operand:VI48_AVX512F 2 "nonimmediate_operand" "vm")))]
18903   "TARGET_AVX2 && <mask_mode512bit_condition>"
18904   "vp<vshift>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18905   [(set_attr "type" "sseishft")
18906    (set_attr "prefix" "maybe_evex")
18907    (set_attr "mode" "<sseinsnmode>")])
18909 (define_insn "<avx2_avx512>_<shift_insn>v<mode><mask_name>"
18910   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
18911         (any_lshift:VI2_AVX512VL
18912           (match_operand:VI2_AVX512VL 1 "register_operand" "v")
18913           (match_operand:VI2_AVX512VL 2 "nonimmediate_operand" "vm")))]
18914   "TARGET_AVX512BW"
18915   "vp<vshift>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18916   [(set_attr "type" "sseishft")
18917    (set_attr "prefix" "maybe_evex")
18918    (set_attr "mode" "<sseinsnmode>")])
18920 (define_insn "avx_vec_concat<mode>"
18921   [(set (match_operand:V_256_512 0 "register_operand" "=x,v,x,Yv")
18922         (vec_concat:V_256_512
18923           (match_operand:<ssehalfvecmode> 1 "register_operand" "x,v,x,v")
18924           (match_operand:<ssehalfvecmode> 2 "vector_move_operand" "xm,vm,C,C")))]
18925   "TARGET_AVX"
18927   switch (which_alternative)
18928     {
18929     case 0:
18930       return "vinsert<i128>\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
18931     case 1:
18932       if (<MODE_SIZE> == 64)
18933         {
18934           if (TARGET_AVX512DQ && GET_MODE_SIZE (<ssescalarmode>mode) == 4)
18935             return "vinsert<shuffletype>32x8\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
18936           else
18937             return "vinsert<shuffletype>64x4\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
18938         }
18939       else
18940         {
18941           if (TARGET_AVX512DQ && GET_MODE_SIZE (<ssescalarmode>mode) == 8)
18942             return "vinsert<shuffletype>64x2\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
18943           else
18944             return "vinsert<shuffletype>32x4\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
18945         }
18946     case 2:
18947     case 3:
18948       switch (get_attr_mode (insn))
18949         {
18950         case MODE_V16SF:
18951           return "vmovaps\t{%1, %t0|%t0, %1}";
18952         case MODE_V8DF:
18953           return "vmovapd\t{%1, %t0|%t0, %1}";
18954         case MODE_V8SF:
18955           return "vmovaps\t{%1, %x0|%x0, %1}";
18956         case MODE_V4DF:
18957           return "vmovapd\t{%1, %x0|%x0, %1}";
18958         case MODE_XI:
18959           if (which_alternative == 2)
18960             return "vmovdqa\t{%1, %t0|%t0, %1}";
18961           else if (GET_MODE_SIZE (<ssescalarmode>mode) == 8)
18962             return "vmovdqa64\t{%1, %t0|%t0, %1}";
18963           else
18964             return "vmovdqa32\t{%1, %t0|%t0, %1}";
18965         case MODE_OI:
18966           if (which_alternative == 2)
18967             return "vmovdqa\t{%1, %x0|%x0, %1}";
18968           else if (GET_MODE_SIZE (<ssescalarmode>mode) == 8)
18969             return "vmovdqa64\t{%1, %x0|%x0, %1}";
18970           else
18971             return "vmovdqa32\t{%1, %x0|%x0, %1}";
18972         default:
18973           gcc_unreachable ();
18974         }
18975     default:
18976       gcc_unreachable ();
18977     }
18979   [(set_attr "type" "sselog,sselog,ssemov,ssemov")
18980    (set_attr "prefix_extra" "1,1,*,*")
18981    (set_attr "length_immediate" "1,1,*,*")
18982    (set_attr "prefix" "maybe_evex")
18983    (set_attr "mode" "<sseinsnmode>")])
18985 (define_insn "vcvtph2ps<mask_name>"
18986   [(set (match_operand:V4SF 0 "register_operand" "=v")
18987         (vec_select:V4SF
18988           (unspec:V8SF [(match_operand:V8HI 1 "register_operand" "v")]
18989                        UNSPEC_VCVTPH2PS)
18990           (parallel [(const_int 0) (const_int 1)
18991                      (const_int 2) (const_int 3)])))]
18992   "TARGET_F16C || TARGET_AVX512VL"
18993   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18994   [(set_attr "type" "ssecvt")
18995    (set_attr "prefix" "maybe_evex")
18996    (set_attr "mode" "V4SF")])
18998 (define_insn "*vcvtph2ps_load<mask_name>"
18999   [(set (match_operand:V4SF 0 "register_operand" "=v")
19000         (unspec:V4SF [(match_operand:V4HI 1 "memory_operand" "m")]
19001                      UNSPEC_VCVTPH2PS))]
19002   "TARGET_F16C || TARGET_AVX512VL"
19003   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19004   [(set_attr "type" "ssecvt")
19005    (set_attr "prefix" "vex")
19006    (set_attr "mode" "V8SF")])
19008 (define_insn "vcvtph2ps256<mask_name>"
19009   [(set (match_operand:V8SF 0 "register_operand" "=v")
19010         (unspec:V8SF [(match_operand:V8HI 1 "nonimmediate_operand" "vm")]
19011                      UNSPEC_VCVTPH2PS))]
19012   "TARGET_F16C || TARGET_AVX512VL"
19013   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19014   [(set_attr "type" "ssecvt")
19015    (set_attr "prefix" "vex")
19016    (set_attr "btver2_decode" "double")
19017    (set_attr "mode" "V8SF")])
19019 (define_insn "<mask_codefor>avx512f_vcvtph2ps512<mask_name><round_saeonly_name>"
19020   [(set (match_operand:V16SF 0 "register_operand" "=v")
19021         (unspec:V16SF
19022           [(match_operand:V16HI 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
19023           UNSPEC_VCVTPH2PS))]
19024   "TARGET_AVX512F"
19025   "vcvtph2ps\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
19026   [(set_attr "type" "ssecvt")
19027    (set_attr "prefix" "evex")
19028    (set_attr "mode" "V16SF")])
19030 (define_expand "vcvtps2ph_mask"
19031   [(set (match_operand:V8HI 0 "register_operand")
19032         (vec_merge:V8HI
19033           (vec_concat:V8HI
19034             (unspec:V4HI [(match_operand:V4SF 1 "register_operand")
19035                           (match_operand:SI 2 "const_0_to_255_operand")]
19036                           UNSPEC_VCVTPS2PH)
19037             (match_dup 5))
19038            (match_operand:V8HI 3 "vector_move_operand")
19039            (match_operand:QI 4 "register_operand")))]
19040   "TARGET_AVX512VL"
19041   "operands[5] = CONST0_RTX (V4HImode);")
19043 (define_expand "vcvtps2ph"
19044   [(set (match_operand:V8HI 0 "register_operand")
19045         (vec_concat:V8HI
19046           (unspec:V4HI [(match_operand:V4SF 1 "register_operand")
19047                         (match_operand:SI 2 "const_0_to_255_operand")]
19048                        UNSPEC_VCVTPS2PH)
19049           (match_dup 3)))]
19050   "TARGET_F16C"
19051   "operands[3] = CONST0_RTX (V4HImode);")
19053 (define_insn "*vcvtps2ph<mask_name>"
19054   [(set (match_operand:V8HI 0 "register_operand" "=v")
19055         (vec_concat:V8HI
19056           (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "v")
19057                         (match_operand:SI 2 "const_0_to_255_operand" "N")]
19058                        UNSPEC_VCVTPS2PH)
19059           (match_operand:V4HI 3 "const0_operand")))]
19060   "(TARGET_F16C || TARGET_AVX512VL) && <mask_avx512vl_condition>"
19061   "vcvtps2ph\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}"
19062   [(set_attr "type" "ssecvt")
19063    (set_attr "prefix" "maybe_evex")
19064    (set_attr "mode" "V4SF")])
19066 (define_insn "*vcvtps2ph_store<mask_name>"
19067   [(set (match_operand:V4HI 0 "memory_operand" "=m")
19068         (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "v")
19069                       (match_operand:SI 2 "const_0_to_255_operand" "N")]
19070                      UNSPEC_VCVTPS2PH))]
19071   "TARGET_F16C || TARGET_AVX512VL"
19072   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19073   [(set_attr "type" "ssecvt")
19074    (set_attr "prefix" "maybe_evex")
19075    (set_attr "mode" "V4SF")])
19077 (define_insn "vcvtps2ph256<mask_name>"
19078   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=vm")
19079         (unspec:V8HI [(match_operand:V8SF 1 "register_operand" "v")
19080                       (match_operand:SI 2 "const_0_to_255_operand" "N")]
19081                      UNSPEC_VCVTPS2PH))]
19082   "TARGET_F16C || TARGET_AVX512VL"
19083   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19084   [(set_attr "type" "ssecvt")
19085    (set_attr "prefix" "maybe_evex")
19086    (set_attr "btver2_decode" "vector")
19087    (set_attr "mode" "V8SF")])
19089 (define_insn "<mask_codefor>avx512f_vcvtps2ph512<mask_name>"
19090   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=vm")
19091         (unspec:V16HI
19092           [(match_operand:V16SF 1 "register_operand" "v")
19093            (match_operand:SI 2 "const_0_to_255_operand" "N")]
19094           UNSPEC_VCVTPS2PH))]
19095   "TARGET_AVX512F"
19096   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19097   [(set_attr "type" "ssecvt")
19098    (set_attr "prefix" "evex")
19099    (set_attr "mode" "V16SF")])
19101 ;; For gather* insn patterns
19102 (define_mode_iterator VEC_GATHER_MODE
19103                       [V2DI V2DF V4DI V4DF V4SI V4SF V8SI V8SF])
19104 (define_mode_attr VEC_GATHER_IDXSI
19105                       [(V2DI "V4SI") (V4DI "V4SI") (V8DI "V8SI")
19106                        (V2DF "V4SI") (V4DF "V4SI") (V8DF "V8SI")
19107                        (V4SI "V4SI") (V8SI "V8SI") (V16SI "V16SI")
19108                        (V4SF "V4SI") (V8SF "V8SI") (V16SF "V16SI")])
19110 (define_mode_attr VEC_GATHER_IDXDI
19111                       [(V2DI "V2DI") (V4DI "V4DI") (V8DI "V8DI")
19112                        (V2DF "V2DI") (V4DF "V4DI") (V8DF "V8DI")
19113                        (V4SI "V2DI") (V8SI "V4DI") (V16SI "V8DI")
19114                        (V4SF "V2DI") (V8SF "V4DI") (V16SF "V8DI")])
19116 (define_mode_attr VEC_GATHER_SRCDI
19117                       [(V2DI "V2DI") (V4DI "V4DI") (V8DI "V8DI")
19118                        (V2DF "V2DF") (V4DF "V4DF") (V8DF "V8DF")
19119                        (V4SI "V4SI") (V8SI "V4SI") (V16SI "V8SI")
19120                        (V4SF "V4SF") (V8SF "V4SF") (V16SF "V8SF")])
19122 (define_expand "avx2_gathersi<mode>"
19123   [(parallel [(set (match_operand:VEC_GATHER_MODE 0 "register_operand")
19124                    (unspec:VEC_GATHER_MODE
19125                      [(match_operand:VEC_GATHER_MODE 1 "register_operand")
19126                       (mem:<ssescalarmode>
19127                         (match_par_dup 6
19128                           [(match_operand 2 "vsib_address_operand")
19129                            (match_operand:<VEC_GATHER_IDXSI>
19130                               3 "register_operand")
19131                            (match_operand:SI 5 "const1248_operand ")]))
19132                       (mem:BLK (scratch))
19133                       (match_operand:VEC_GATHER_MODE 4 "register_operand")]
19134                      UNSPEC_GATHER))
19135               (clobber (match_scratch:VEC_GATHER_MODE 7))])]
19136   "TARGET_AVX2"
19138   operands[6]
19139     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
19140                                         operands[5]), UNSPEC_VSIBADDR);
19143 (define_insn "*avx2_gathersi<mode>"
19144   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
19145         (unspec:VEC_GATHER_MODE
19146           [(match_operand:VEC_GATHER_MODE 2 "register_operand" "0")
19147            (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
19148              [(unspec:P
19149                 [(match_operand:P 3 "vsib_address_operand" "Tv")
19150                  (match_operand:<VEC_GATHER_IDXSI> 4 "register_operand" "x")
19151                  (match_operand:SI 6 "const1248_operand" "n")]
19152                 UNSPEC_VSIBADDR)])
19153            (mem:BLK (scratch))
19154            (match_operand:VEC_GATHER_MODE 5 "register_operand" "1")]
19155           UNSPEC_GATHER))
19156    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
19157   "TARGET_AVX2"
19158   "v<sseintprefix>gatherd<ssemodesuffix>\t{%1, %7, %0|%0, %7, %1}"
19159   [(set_attr "type" "ssemov")
19160    (set_attr "prefix" "vex")
19161    (set_attr "mode" "<sseinsnmode>")])
19163 (define_insn "*avx2_gathersi<mode>_2"
19164   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
19165         (unspec:VEC_GATHER_MODE
19166           [(pc)
19167            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19168              [(unspec:P
19169                 [(match_operand:P 2 "vsib_address_operand" "Tv")
19170                  (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand" "x")
19171                  (match_operand:SI 5 "const1248_operand" "n")]
19172                 UNSPEC_VSIBADDR)])
19173            (mem:BLK (scratch))
19174            (match_operand:VEC_GATHER_MODE 4 "register_operand" "1")]
19175           UNSPEC_GATHER))
19176    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
19177   "TARGET_AVX2"
19178   "v<sseintprefix>gatherd<ssemodesuffix>\t{%1, %6, %0|%0, %6, %1}"
19179   [(set_attr "type" "ssemov")
19180    (set_attr "prefix" "vex")
19181    (set_attr "mode" "<sseinsnmode>")])
19183 (define_expand "avx2_gatherdi<mode>"
19184   [(parallel [(set (match_operand:VEC_GATHER_MODE 0 "register_operand")
19185                    (unspec:VEC_GATHER_MODE
19186                      [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand")
19187                       (mem:<ssescalarmode>
19188                         (match_par_dup 6
19189                           [(match_operand 2 "vsib_address_operand")
19190                            (match_operand:<VEC_GATHER_IDXDI>
19191                               3 "register_operand")
19192                            (match_operand:SI 5 "const1248_operand ")]))
19193                       (mem:BLK (scratch))
19194                       (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand")]
19195                      UNSPEC_GATHER))
19196               (clobber (match_scratch:VEC_GATHER_MODE 7))])]
19197   "TARGET_AVX2"
19199   operands[6]
19200     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
19201                                         operands[5]), UNSPEC_VSIBADDR);
19204 (define_insn "*avx2_gatherdi<mode>"
19205   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
19206         (unspec:VEC_GATHER_MODE
19207           [(match_operand:<VEC_GATHER_SRCDI> 2 "register_operand" "0")
19208            (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
19209              [(unspec:P
19210                 [(match_operand:P 3 "vsib_address_operand" "Tv")
19211                  (match_operand:<VEC_GATHER_IDXDI> 4 "register_operand" "x")
19212                  (match_operand:SI 6 "const1248_operand" "n")]
19213                 UNSPEC_VSIBADDR)])
19214            (mem:BLK (scratch))
19215            (match_operand:<VEC_GATHER_SRCDI> 5 "register_operand" "1")]
19216           UNSPEC_GATHER))
19217    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
19218   "TARGET_AVX2"
19219   "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %7, %2|%2, %7, %5}"
19220   [(set_attr "type" "ssemov")
19221    (set_attr "prefix" "vex")
19222    (set_attr "mode" "<sseinsnmode>")])
19224 (define_insn "*avx2_gatherdi<mode>_2"
19225   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
19226         (unspec:VEC_GATHER_MODE
19227           [(pc)
19228            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19229              [(unspec:P
19230                 [(match_operand:P 2 "vsib_address_operand" "Tv")
19231                  (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "x")
19232                  (match_operand:SI 5 "const1248_operand" "n")]
19233                 UNSPEC_VSIBADDR)])
19234            (mem:BLK (scratch))
19235            (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand" "1")]
19236           UNSPEC_GATHER))
19237    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
19238   "TARGET_AVX2"
19240   if (<MODE>mode != <VEC_GATHER_SRCDI>mode)
19241     return "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %x0|%x0, %6, %4}";
19242   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %0|%0, %6, %4}";
19244   [(set_attr "type" "ssemov")
19245    (set_attr "prefix" "vex")
19246    (set_attr "mode" "<sseinsnmode>")])
19248 (define_insn "*avx2_gatherdi<mode>_3"
19249   [(set (match_operand:<VEC_GATHER_SRCDI> 0 "register_operand" "=&x")
19250         (vec_select:<VEC_GATHER_SRCDI>
19251           (unspec:VI4F_256
19252             [(match_operand:<VEC_GATHER_SRCDI> 2 "register_operand" "0")
19253              (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
19254                [(unspec:P
19255                   [(match_operand:P 3 "vsib_address_operand" "Tv")
19256                    (match_operand:<VEC_GATHER_IDXDI> 4 "register_operand" "x")
19257                    (match_operand:SI 6 "const1248_operand" "n")]
19258                   UNSPEC_VSIBADDR)])
19259              (mem:BLK (scratch))
19260              (match_operand:<VEC_GATHER_SRCDI> 5 "register_operand" "1")]
19261              UNSPEC_GATHER)
19262           (parallel [(const_int 0) (const_int 1)
19263                      (const_int 2) (const_int 3)])))
19264    (clobber (match_scratch:VI4F_256 1 "=&x"))]
19265   "TARGET_AVX2"
19266   "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %7, %0|%0, %7, %5}"
19267   [(set_attr "type" "ssemov")
19268    (set_attr "prefix" "vex")
19269    (set_attr "mode" "<sseinsnmode>")])
19271 (define_insn "*avx2_gatherdi<mode>_4"
19272   [(set (match_operand:<VEC_GATHER_SRCDI> 0 "register_operand" "=&x")
19273         (vec_select:<VEC_GATHER_SRCDI>
19274           (unspec:VI4F_256
19275             [(pc)
19276              (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19277                [(unspec:P
19278                   [(match_operand:P 2 "vsib_address_operand" "Tv")
19279                    (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "x")
19280                    (match_operand:SI 5 "const1248_operand" "n")]
19281                   UNSPEC_VSIBADDR)])
19282              (mem:BLK (scratch))
19283              (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand" "1")]
19284             UNSPEC_GATHER)
19285           (parallel [(const_int 0) (const_int 1)
19286                      (const_int 2) (const_int 3)])))
19287    (clobber (match_scratch:VI4F_256 1 "=&x"))]
19288   "TARGET_AVX2"
19289   "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %0|%0, %6, %4}"
19290   [(set_attr "type" "ssemov")
19291    (set_attr "prefix" "vex")
19292    (set_attr "mode" "<sseinsnmode>")])
19294 ;; Memory operand override for -masm=intel of the v*gatherq* patterns.
19295 (define_mode_attr gatherq_mode
19296   [(V4SI "q") (V2DI "x") (V4SF "q") (V2DF "x")
19297    (V8SI "x") (V4DI "t") (V8SF "x") (V4DF "t")
19298    (V16SI "t") (V8DI "g") (V16SF "t") (V8DF "g")])
19300 (define_expand "<avx512>_gathersi<mode>"
19301   [(parallel [(set (match_operand:VI48F 0 "register_operand")
19302                    (unspec:VI48F
19303                      [(match_operand:VI48F 1 "register_operand")
19304                       (match_operand:<avx512fmaskmode> 4 "register_operand")
19305                       (mem:<ssescalarmode>
19306                         (match_par_dup 6
19307                           [(match_operand 2 "vsib_address_operand")
19308                            (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand")
19309                            (match_operand:SI 5 "const1248_operand")]))]
19310                      UNSPEC_GATHER))
19311               (clobber (match_scratch:<avx512fmaskmode> 7))])]
19312   "TARGET_AVX512F"
19314   operands[6]
19315     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
19316                                         operands[5]), UNSPEC_VSIBADDR);
19319 (define_insn "*avx512f_gathersi<mode>"
19320   [(set (match_operand:VI48F 0 "register_operand" "=&v")
19321         (unspec:VI48F
19322           [(match_operand:VI48F 1 "register_operand" "0")
19323            (match_operand:<avx512fmaskmode> 7 "register_operand" "2")
19324            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19325              [(unspec:P
19326                 [(match_operand:P 4 "vsib_address_operand" "Tv")
19327                  (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand" "v")
19328                  (match_operand:SI 5 "const1248_operand" "n")]
19329                 UNSPEC_VSIBADDR)])]
19330           UNSPEC_GATHER))
19331    (clobber (match_scratch:<avx512fmaskmode> 2 "=&Yk"))]
19332   "TARGET_AVX512F"
19333   "v<sseintprefix>gatherd<ssemodesuffix>\t{%6, %0%{%2%}|%0%{%2%}, %<xtg_mode>6}"
19334   [(set_attr "type" "ssemov")
19335    (set_attr "prefix" "evex")
19336    (set_attr "mode" "<sseinsnmode>")])
19338 (define_insn "*avx512f_gathersi<mode>_2"
19339   [(set (match_operand:VI48F 0 "register_operand" "=&v")
19340         (unspec:VI48F
19341           [(pc)
19342            (match_operand:<avx512fmaskmode> 6 "register_operand" "1")
19343            (match_operator:<ssescalarmode> 5 "vsib_mem_operator"
19344              [(unspec:P
19345                 [(match_operand:P 3 "vsib_address_operand" "Tv")
19346                  (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand" "v")
19347                  (match_operand:SI 4 "const1248_operand" "n")]
19348                 UNSPEC_VSIBADDR)])]
19349           UNSPEC_GATHER))
19350    (clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
19351   "TARGET_AVX512F"
19352   "v<sseintprefix>gatherd<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %<xtg_mode>5}"
19353   [(set_attr "type" "ssemov")
19354    (set_attr "prefix" "evex")
19355    (set_attr "mode" "<sseinsnmode>")])
19358 (define_expand "<avx512>_gatherdi<mode>"
19359   [(parallel [(set (match_operand:VI48F 0 "register_operand")
19360                    (unspec:VI48F
19361                      [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand")
19362                       (match_operand:QI 4 "register_operand")
19363                       (mem:<ssescalarmode>
19364                         (match_par_dup 6
19365                           [(match_operand 2 "vsib_address_operand")
19366                            (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand")
19367                            (match_operand:SI 5 "const1248_operand")]))]
19368                      UNSPEC_GATHER))
19369               (clobber (match_scratch:QI 7))])]
19370   "TARGET_AVX512F"
19372   operands[6]
19373     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
19374                                         operands[5]), UNSPEC_VSIBADDR);
19377 (define_insn "*avx512f_gatherdi<mode>"
19378   [(set (match_operand:VI48F 0 "register_operand" "=&v")
19379         (unspec:VI48F
19380           [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand" "0")
19381            (match_operand:QI 7 "register_operand" "2")
19382            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19383              [(unspec:P
19384                 [(match_operand:P 4 "vsib_address_operand" "Tv")
19385                  (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "v")
19386                  (match_operand:SI 5 "const1248_operand" "n")]
19387                 UNSPEC_VSIBADDR)])]
19388           UNSPEC_GATHER))
19389    (clobber (match_scratch:QI 2 "=&Yk"))]
19390   "TARGET_AVX512F"
19392   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%6, %1%{%2%}|%1%{%2%}, %<gatherq_mode>6}";
19394   [(set_attr "type" "ssemov")
19395    (set_attr "prefix" "evex")
19396    (set_attr "mode" "<sseinsnmode>")])
19398 (define_insn "*avx512f_gatherdi<mode>_2"
19399   [(set (match_operand:VI48F 0 "register_operand" "=&v")
19400         (unspec:VI48F
19401           [(pc)
19402            (match_operand:QI 6 "register_operand" "1")
19403            (match_operator:<ssescalarmode> 5 "vsib_mem_operator"
19404              [(unspec:P
19405                 [(match_operand:P 3 "vsib_address_operand" "Tv")
19406                  (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand" "v")
19407                  (match_operand:SI 4 "const1248_operand" "n")]
19408                 UNSPEC_VSIBADDR)])]
19409           UNSPEC_GATHER))
19410    (clobber (match_scratch:QI 1 "=&Yk"))]
19411   "TARGET_AVX512F"
19413   if (<MODE>mode != <VEC_GATHER_SRCDI>mode)
19414     {
19415       if (<MODE_SIZE> != 64)
19416         return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %x0%{%1%}|%x0%{%1%}, %<gatherq_mode>5}";
19417       else
19418         return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %t0%{%1%}|%t0%{%1%}, %t5}";
19419     }
19420   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %<gatherq_mode>5}";
19422   [(set_attr "type" "ssemov")
19423    (set_attr "prefix" "evex")
19424    (set_attr "mode" "<sseinsnmode>")])
19426 (define_expand "<avx512>_scattersi<mode>"
19427   [(parallel [(set (mem:VI48F
19428                      (match_par_dup 5
19429                        [(match_operand 0 "vsib_address_operand")
19430                         (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand")
19431                         (match_operand:SI 4 "const1248_operand")]))
19432                    (unspec:VI48F
19433                      [(match_operand:<avx512fmaskmode> 1 "register_operand")
19434                       (match_operand:VI48F 3 "register_operand")]
19435                      UNSPEC_SCATTER))
19436               (clobber (match_scratch:<avx512fmaskmode> 6))])]
19437   "TARGET_AVX512F"
19439   operands[5]
19440     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[0], operands[2],
19441                                         operands[4]), UNSPEC_VSIBADDR);
19444 (define_insn "*avx512f_scattersi<mode>"
19445   [(set (match_operator:VI48F 5 "vsib_mem_operator"
19446           [(unspec:P
19447              [(match_operand:P 0 "vsib_address_operand" "Tv")
19448               (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand" "v")
19449               (match_operand:SI 4 "const1248_operand" "n")]
19450              UNSPEC_VSIBADDR)])
19451         (unspec:VI48F
19452           [(match_operand:<avx512fmaskmode> 6 "register_operand" "1")
19453            (match_operand:VI48F 3 "register_operand" "v")]
19454           UNSPEC_SCATTER))
19455    (clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
19456   "TARGET_AVX512F"
19457   "v<sseintprefix>scatterd<ssemodesuffix>\t{%3, %5%{%1%}|%5%{%1%}, %3}"
19458   [(set_attr "type" "ssemov")
19459    (set_attr "prefix" "evex")
19460    (set_attr "mode" "<sseinsnmode>")])
19462 (define_expand "<avx512>_scatterdi<mode>"
19463   [(parallel [(set (mem:VI48F
19464                      (match_par_dup 5
19465                        [(match_operand 0 "vsib_address_operand")
19466                         (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand")
19467                         (match_operand:SI 4 "const1248_operand")]))
19468                    (unspec:VI48F
19469                      [(match_operand:QI 1 "register_operand")
19470                       (match_operand:<VEC_GATHER_SRCDI> 3 "register_operand")]
19471                      UNSPEC_SCATTER))
19472               (clobber (match_scratch:QI 6))])]
19473   "TARGET_AVX512F"
19475   operands[5]
19476     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[0], operands[2],
19477                                         operands[4]), UNSPEC_VSIBADDR);
19480 (define_insn "*avx512f_scatterdi<mode>"
19481   [(set (match_operator:VI48F 5 "vsib_mem_operator"
19482           [(unspec:P
19483              [(match_operand:P 0 "vsib_address_operand" "Tv")
19484               (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand" "v")
19485               (match_operand:SI 4 "const1248_operand" "n")]
19486              UNSPEC_VSIBADDR)])
19487         (unspec:VI48F
19488           [(match_operand:QI 6 "register_operand" "1")
19489            (match_operand:<VEC_GATHER_SRCDI> 3 "register_operand" "v")]
19490           UNSPEC_SCATTER))
19491    (clobber (match_scratch:QI 1 "=&Yk"))]
19492   "TARGET_AVX512F"
19494   if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 8)
19495     return "v<sseintprefix>scatterq<ssemodesuffix>\t{%3, %5%{%1%}|%5%{%1%}, %3}";
19496   return "v<sseintprefix>scatterq<ssemodesuffix>\t{%3, %5%{%1%}|%t5%{%1%}, %3}";
19498   [(set_attr "type" "ssemov")
19499    (set_attr "prefix" "evex")
19500    (set_attr "mode" "<sseinsnmode>")])
19502 (define_insn "<avx512>_compress<mode>_mask"
19503   [(set (match_operand:VI48F 0 "register_operand" "=v")
19504         (unspec:VI48F
19505           [(match_operand:VI48F 1 "register_operand" "v")
19506            (match_operand:VI48F 2 "vector_move_operand" "0C")
19507            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")]
19508           UNSPEC_COMPRESS))]
19509   "TARGET_AVX512F"
19510   "v<sseintprefix>compress<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19511   [(set_attr "type" "ssemov")
19512    (set_attr "prefix" "evex")
19513    (set_attr "mode" "<sseinsnmode>")])
19515 (define_insn "compress<mode>_mask"
19516   [(set (match_operand:VI12_AVX512VLBW 0 "register_operand" "=v")
19517         (unspec:VI12_AVX512VLBW
19518           [(match_operand:VI12_AVX512VLBW 1 "register_operand" "v")
19519            (match_operand:VI12_AVX512VLBW 2 "vector_move_operand" "0C")
19520            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")]
19521           UNSPEC_COMPRESS))]
19522   "TARGET_AVX512VBMI2"
19523   "vpcompress<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19524   [(set_attr "type" "ssemov")
19525    (set_attr "prefix" "evex")
19526    (set_attr "mode" "<sseinsnmode>")])
19528 (define_insn "<avx512>_compressstore<mode>_mask"
19529   [(set (match_operand:VI48F 0 "memory_operand" "=m")
19530         (unspec:VI48F
19531           [(match_operand:VI48F 1 "register_operand" "x")
19532            (match_dup 0)
19533            (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")]
19534           UNSPEC_COMPRESS_STORE))]
19535   "TARGET_AVX512F"
19536   "v<sseintprefix>compress<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
19537   [(set_attr "type" "ssemov")
19538    (set_attr "prefix" "evex")
19539    (set_attr "memory" "store")
19540    (set_attr "mode" "<sseinsnmode>")])
19542 (define_insn "compressstore<mode>_mask"
19543   [(set (match_operand:VI12_AVX512VLBW 0 "memory_operand" "=m")
19544         (unspec:VI12_AVX512VLBW
19545           [(match_operand:VI12_AVX512VLBW 1 "register_operand" "x")
19546            (match_dup 0)
19547            (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")]
19548           UNSPEC_COMPRESS_STORE))]
19549   "TARGET_AVX512VBMI2"
19550   "vpcompress<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
19551   [(set_attr "type" "ssemov")
19552    (set_attr "prefix" "evex")
19553    (set_attr "memory" "store")
19554    (set_attr "mode" "<sseinsnmode>")])
19556 (define_expand "<avx512>_expand<mode>_maskz"
19557   [(set (match_operand:VI48F 0 "register_operand")
19558         (unspec:VI48F
19559           [(match_operand:VI48F 1 "nonimmediate_operand")
19560            (match_operand:VI48F 2 "vector_move_operand")
19561            (match_operand:<avx512fmaskmode> 3 "register_operand")]
19562           UNSPEC_EXPAND))]
19563   "TARGET_AVX512F"
19564   "operands[2] = CONST0_RTX (<MODE>mode);")
19566 (define_insn "<avx512>_expand<mode>_mask"
19567   [(set (match_operand:VI48F 0 "register_operand" "=v,v")
19568         (unspec:VI48F
19569           [(match_operand:VI48F 1 "nonimmediate_operand" "v,m")
19570            (match_operand:VI48F 2 "vector_move_operand" "0C,0C")
19571            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")]
19572           UNSPEC_EXPAND))]
19573   "TARGET_AVX512F"
19574   "v<sseintprefix>expand<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19575   [(set_attr "type" "ssemov")
19576    (set_attr "prefix" "evex")
19577    (set_attr "memory" "none,load")
19578    (set_attr "mode" "<sseinsnmode>")])
19580 (define_insn "expand<mode>_mask"
19581   [(set (match_operand:VI12_AVX512VLBW 0 "register_operand" "=v,v")
19582         (unspec:VI12_AVX512VLBW
19583           [(match_operand:VI12_AVX512VLBW 1 "nonimmediate_operand" "v,m")
19584            (match_operand:VI12_AVX512VLBW 2 "vector_move_operand" "0C,0C")
19585            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")]
19586           UNSPEC_EXPAND))]
19587   "TARGET_AVX512VBMI2"
19588   "v<sseintprefix>expand<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19589   [(set_attr "type" "ssemov")
19590    (set_attr "prefix" "evex")
19591    (set_attr "memory" "none,load")
19592    (set_attr "mode" "<sseinsnmode>")])
19594 (define_expand "expand<mode>_maskz"
19595   [(set (match_operand:VI12_AVX512VLBW 0 "register_operand")
19596         (unspec:VI12_AVX512VLBW
19597           [(match_operand:VI12_AVX512VLBW 1 "nonimmediate_operand")
19598            (match_operand:VI12_AVX512VLBW 2 "vector_move_operand")
19599            (match_operand:<avx512fmaskmode> 3 "register_operand")]
19600           UNSPEC_EXPAND))]
19601   "TARGET_AVX512VBMI2"
19602   "operands[2] = CONST0_RTX (<MODE>mode);")
19604 (define_insn "avx512dq_rangep<mode><mask_name><round_saeonly_name>"
19605   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
19606         (unspec:VF_AVX512VL
19607           [(match_operand:VF_AVX512VL 1 "register_operand" "v")
19608            (match_operand:VF_AVX512VL 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
19609            (match_operand:SI 3 "const_0_to_15_operand")]
19610           UNSPEC_RANGE))]
19611   "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
19612   "vrange<ssemodesuffix>\t{%3, <round_saeonly_mask_op4>%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2<round_saeonly_mask_op4>, %3}"
19613   [(set_attr "type" "sse")
19614    (set_attr "prefix" "evex")
19615    (set_attr "mode" "<MODE>")])
19617 (define_insn "avx512dq_ranges<mode><mask_scalar_name><round_saeonly_scalar_name>"
19618   [(set (match_operand:VF_128 0 "register_operand" "=v")
19619         (vec_merge:VF_128
19620           (unspec:VF_128
19621             [(match_operand:VF_128 1 "register_operand" "v")
19622              (match_operand:VF_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")
19623              (match_operand:SI 3 "const_0_to_15_operand")]
19624             UNSPEC_RANGE)
19625           (match_dup 1)
19626           (const_int 1)))]
19627   "TARGET_AVX512DQ"
19628   "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}"
19629   [(set_attr "type" "sse")
19630    (set_attr "prefix" "evex")
19631    (set_attr "mode" "<MODE>")])
19633 (define_insn "avx512dq_fpclass<mode><mask_scalar_merge_name>"
19634   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
19635           (unspec:<avx512fmaskmode>
19636             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
19637              (match_operand:QI 2 "const_0_to_255_operand" "n")]
19638              UNSPEC_FPCLASS))]
19639    "TARGET_AVX512DQ"
19640    "vfpclass<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}";
19641   [(set_attr "type" "sse")
19642    (set_attr "length_immediate" "1")
19643    (set_attr "prefix" "evex")
19644    (set_attr "mode" "<MODE>")])
19646 (define_insn "avx512dq_vmfpclass<mode>"
19647   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
19648         (and:<avx512fmaskmode>
19649           (unspec:<avx512fmaskmode>
19650             [(match_operand:VF_128 1 "register_operand" "v")
19651              (match_operand:QI 2 "const_0_to_255_operand" "n")]
19652             UNSPEC_FPCLASS)
19653           (const_int 1)))]
19654    "TARGET_AVX512DQ"
19655    "vfpclass<ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
19656   [(set_attr "type" "sse")
19657    (set_attr "length_immediate" "1")
19658    (set_attr "prefix" "evex")
19659    (set_attr "mode" "<MODE>")])
19661 (define_insn "<avx512>_getmant<mode><mask_name><round_saeonly_name>"
19662   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
19663         (unspec:VF_AVX512VL
19664           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "<round_saeonly_constraint>")
19665            (match_operand:SI 2 "const_0_to_15_operand")]
19666           UNSPEC_GETMANT))]
19667   "TARGET_AVX512F"
19668   "vgetmant<ssemodesuffix>\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}";
19669   [(set_attr "prefix" "evex")
19670    (set_attr "mode" "<MODE>")])
19672 (define_insn "avx512f_vgetmant<mode><mask_scalar_name><round_saeonly_scalar_name>"
19673   [(set (match_operand:VF_128 0 "register_operand" "=v")
19674         (vec_merge:VF_128
19675           (unspec:VF_128
19676             [(match_operand:VF_128 1 "register_operand" "v")
19677              (match_operand:VF_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")
19678              (match_operand:SI 3 "const_0_to_15_operand")]
19679             UNSPEC_GETMANT)
19680           (match_dup 1)
19681           (const_int 1)))]
19682    "TARGET_AVX512F"
19683    "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}";
19684    [(set_attr "prefix" "evex")
19685    (set_attr "mode" "<ssescalarmode>")])
19687 ;; The correct representation for this is absolutely enormous, and
19688 ;; surely not generally useful.
19689 (define_insn "<mask_codefor>avx512bw_dbpsadbw<mode><mask_name>"
19690   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
19691         (unspec:VI2_AVX512VL
19692           [(match_operand:<dbpsadbwmode> 1 "register_operand" "v")
19693            (match_operand:<dbpsadbwmode> 2 "nonimmediate_operand" "vm")
19694            (match_operand:SI 3 "const_0_to_255_operand")]
19695           UNSPEC_DBPSADBW))]
19696    "TARGET_AVX512BW"
19697   "vdbpsadbw\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}"
19698   [(set_attr "type" "sselog1")
19699    (set_attr "length_immediate" "1")
19700    (set_attr "prefix" "evex")
19701    (set_attr "mode" "<sseinsnmode>")])
19703 (define_insn "clz<mode>2<mask_name>"
19704   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
19705         (clz:VI48_AVX512VL
19706           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")))]
19707   "TARGET_AVX512CD"
19708   "vplzcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19709   [(set_attr "type" "sse")
19710    (set_attr "prefix" "evex")
19711    (set_attr "mode" "<sseinsnmode>")])
19713 (define_insn "<mask_codefor>conflict<mode><mask_name>"
19714   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
19715         (unspec:VI48_AVX512VL
19716           [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")]
19717           UNSPEC_CONFLICT))]
19718   "TARGET_AVX512CD"
19719   "vpconflict<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19720   [(set_attr "type" "sse")
19721    (set_attr "prefix" "evex")
19722    (set_attr "mode" "<sseinsnmode>")])
19724 (define_insn "sha1msg1"
19725   [(set (match_operand:V4SI 0 "register_operand" "=x")
19726         (unspec:V4SI
19727           [(match_operand:V4SI 1 "register_operand" "0")
19728            (match_operand:V4SI 2 "vector_operand" "xBm")]
19729           UNSPEC_SHA1MSG1))]
19730   "TARGET_SHA"
19731   "sha1msg1\t{%2, %0|%0, %2}"
19732   [(set_attr "type" "sselog1")
19733    (set_attr "mode" "TI")])
19735 (define_insn "sha1msg2"
19736   [(set (match_operand:V4SI 0 "register_operand" "=x")
19737         (unspec:V4SI
19738           [(match_operand:V4SI 1 "register_operand" "0")
19739            (match_operand:V4SI 2 "vector_operand" "xBm")]
19740           UNSPEC_SHA1MSG2))]
19741   "TARGET_SHA"
19742   "sha1msg2\t{%2, %0|%0, %2}"
19743   [(set_attr "type" "sselog1")
19744    (set_attr "mode" "TI")])
19746 (define_insn "sha1nexte"
19747   [(set (match_operand:V4SI 0 "register_operand" "=x")
19748         (unspec:V4SI
19749           [(match_operand:V4SI 1 "register_operand" "0")
19750            (match_operand:V4SI 2 "vector_operand" "xBm")]
19751           UNSPEC_SHA1NEXTE))]
19752   "TARGET_SHA"
19753   "sha1nexte\t{%2, %0|%0, %2}"
19754   [(set_attr "type" "sselog1")
19755    (set_attr "mode" "TI")])
19757 (define_insn "sha1rnds4"
19758   [(set (match_operand:V4SI 0 "register_operand" "=x")
19759         (unspec:V4SI
19760           [(match_operand:V4SI 1 "register_operand" "0")
19761            (match_operand:V4SI 2 "vector_operand" "xBm")
19762            (match_operand:SI 3 "const_0_to_3_operand" "n")]
19763           UNSPEC_SHA1RNDS4))]
19764   "TARGET_SHA"
19765   "sha1rnds4\t{%3, %2, %0|%0, %2, %3}"
19766   [(set_attr "type" "sselog1")
19767    (set_attr "length_immediate" "1")
19768    (set_attr "mode" "TI")])
19770 (define_insn "sha256msg1"
19771   [(set (match_operand:V4SI 0 "register_operand" "=x")
19772         (unspec:V4SI
19773           [(match_operand:V4SI 1 "register_operand" "0")
19774            (match_operand:V4SI 2 "vector_operand" "xBm")]
19775           UNSPEC_SHA256MSG1))]
19776   "TARGET_SHA"
19777   "sha256msg1\t{%2, %0|%0, %2}"
19778   [(set_attr "type" "sselog1")
19779    (set_attr "mode" "TI")])
19781 (define_insn "sha256msg2"
19782   [(set (match_operand:V4SI 0 "register_operand" "=x")
19783         (unspec:V4SI
19784           [(match_operand:V4SI 1 "register_operand" "0")
19785            (match_operand:V4SI 2 "vector_operand" "xBm")]
19786           UNSPEC_SHA256MSG2))]
19787   "TARGET_SHA"
19788   "sha256msg2\t{%2, %0|%0, %2}"
19789   [(set_attr "type" "sselog1")
19790    (set_attr "mode" "TI")])
19792 (define_insn "sha256rnds2"
19793   [(set (match_operand:V4SI 0 "register_operand" "=x")
19794         (unspec:V4SI
19795           [(match_operand:V4SI 1 "register_operand" "0")
19796            (match_operand:V4SI 2 "vector_operand" "xBm")
19797            (match_operand:V4SI 3 "register_operand" "Yz")]
19798           UNSPEC_SHA256RNDS2))]
19799   "TARGET_SHA"
19800   "sha256rnds2\t{%3, %2, %0|%0, %2, %3}"
19801   [(set_attr "type" "sselog1")
19802    (set_attr "length_immediate" "1")
19803    (set_attr "mode" "TI")])
19805 (define_insn_and_split "avx512f_<castmode><avxsizesuffix>_<castmode>"
19806   [(set (match_operand:AVX512MODE2P 0 "nonimmediate_operand" "=x,m")
19807         (unspec:AVX512MODE2P
19808           [(match_operand:<ssequartermode> 1 "nonimmediate_operand" "xm,x")]
19809           UNSPEC_CAST))]
19810   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
19811   "#"
19812   "&& reload_completed"
19813   [(set (match_dup 0) (match_dup 1))]
19815   if (REG_P (operands[0]))
19816     operands[0] = gen_lowpart (<ssequartermode>mode, operands[0]);
19817   else
19818     operands[1] = lowpart_subreg (<MODE>mode, operands[1],
19819                                   <ssequartermode>mode);
19822 (define_insn_and_split "avx512f_<castmode><avxsizesuffix>_256<castmode>"
19823   [(set (match_operand:AVX512MODE2P 0 "nonimmediate_operand" "=x,m")
19824         (unspec:AVX512MODE2P
19825           [(match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "xm,x")]
19826           UNSPEC_CAST))]
19827   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
19828   "#"
19829   "&& reload_completed"
19830   [(set (match_dup 0) (match_dup 1))]
19832   if (REG_P (operands[0]))
19833     operands[0] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);
19834   else
19835     operands[1] = lowpart_subreg (<MODE>mode, operands[1],
19836                                   <ssehalfvecmode>mode);
19839 (define_int_iterator VPMADD52
19840         [UNSPEC_VPMADD52LUQ
19841          UNSPEC_VPMADD52HUQ])
19843 (define_int_attr vpmadd52type
19844   [(UNSPEC_VPMADD52LUQ "luq") (UNSPEC_VPMADD52HUQ "huq")])
19846 (define_expand "vpamdd52huq<mode>_maskz"
19847   [(match_operand:VI8_AVX512VL 0 "register_operand")
19848    (match_operand:VI8_AVX512VL 1 "register_operand")
19849    (match_operand:VI8_AVX512VL 2 "register_operand")
19850    (match_operand:VI8_AVX512VL 3 "nonimmediate_operand")
19851    (match_operand:<avx512fmaskmode> 4 "register_operand")]
19852   "TARGET_AVX512IFMA"
19854   emit_insn (gen_vpamdd52huq<mode>_maskz_1 (
19855     operands[0], operands[1], operands[2], operands[3],
19856     CONST0_RTX (<MODE>mode), operands[4]));
19857   DONE;
19860 (define_expand "vpamdd52luq<mode>_maskz"
19861   [(match_operand:VI8_AVX512VL 0 "register_operand")
19862    (match_operand:VI8_AVX512VL 1 "register_operand")
19863    (match_operand:VI8_AVX512VL 2 "register_operand")
19864    (match_operand:VI8_AVX512VL 3 "nonimmediate_operand")
19865    (match_operand:<avx512fmaskmode> 4 "register_operand")]
19866   "TARGET_AVX512IFMA"
19868   emit_insn (gen_vpamdd52luq<mode>_maskz_1 (
19869     operands[0], operands[1], operands[2], operands[3],
19870     CONST0_RTX (<MODE>mode), operands[4]));
19871   DONE;
19874 (define_insn "vpamdd52<vpmadd52type><mode><sd_maskz_name>"
19875   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
19876         (unspec:VI8_AVX512VL
19877           [(match_operand:VI8_AVX512VL 1 "register_operand" "0")
19878            (match_operand:VI8_AVX512VL 2 "register_operand" "v")
19879            (match_operand:VI8_AVX512VL 3 "nonimmediate_operand" "vm")]
19880           VPMADD52))]
19881   "TARGET_AVX512IFMA"
19882   "vpmadd52<vpmadd52type>\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}"
19883   [(set_attr "type" "ssemuladd")
19884    (set_attr "prefix" "evex")
19885    (set_attr "mode" "<sseinsnmode>")])
19887 (define_insn "vpamdd52<vpmadd52type><mode>_mask"
19888   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
19889         (vec_merge:VI8_AVX512VL
19890           (unspec:VI8_AVX512VL
19891             [(match_operand:VI8_AVX512VL 1 "register_operand" "0")
19892              (match_operand:VI8_AVX512VL 2 "register_operand" "v")
19893              (match_operand:VI8_AVX512VL 3 "nonimmediate_operand" "vm")]
19894             VPMADD52)
19895           (match_dup 1)
19896           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
19897   "TARGET_AVX512IFMA"
19898   "vpmadd52<vpmadd52type>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
19899   [(set_attr "type" "ssemuladd")
19900    (set_attr "prefix" "evex")
19901    (set_attr "mode" "<sseinsnmode>")])
19903 (define_insn "vpmultishiftqb<mode><mask_name>"
19904   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
19905         (unspec:VI1_AVX512VL
19906           [(match_operand:VI1_AVX512VL 1 "register_operand" "v")
19907            (match_operand:VI1_AVX512VL 2 "nonimmediate_operand" "vm")]
19908           UNSPEC_VPMULTISHIFT))]
19909   "TARGET_AVX512VBMI"
19910   "vpmultishiftqb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19911   [(set_attr "type" "sselog")
19912    (set_attr "prefix" "evex")
19913    (set_attr "mode" "<sseinsnmode>")])
19915 (define_mode_iterator IMOD4
19916   [(V64SF "TARGET_AVX5124FMAPS") (V64SI "TARGET_AVX5124VNNIW")])
19918 (define_mode_attr imod4_narrow
19919   [(V64SF "V16SF") (V64SI "V16SI")])
19921 (define_expand "mov<mode>"
19922   [(set (match_operand:IMOD4 0 "nonimmediate_operand")
19923         (match_operand:IMOD4 1 "vector_move_operand"))]
19924   "TARGET_AVX512F"
19926   ix86_expand_vector_move (<MODE>mode, operands);
19927   DONE;
19930 (define_insn_and_split "*mov<mode>_internal"
19931   [(set (match_operand:IMOD4 0 "nonimmediate_operand" "=v,v ,m")
19932         (match_operand:IMOD4 1 "vector_move_operand"  " C,vm,v"))]
19933   "TARGET_AVX512F
19934    && (register_operand (operands[0], <MODE>mode)
19935        || register_operand (operands[1], <MODE>mode))"
19936   "#"
19937   "&& reload_completed"
19938   [(const_int 0)]
19940   rtx op0, op1;
19941   int i;
19943   for (i = 0; i < 4; i++)
19944     {
19945       op0 = simplify_subreg
19946              (<imod4_narrow>mode, operands[0], <MODE>mode, i * 64);
19947       op1 = simplify_subreg
19948              (<imod4_narrow>mode, operands[1], <MODE>mode, i * 64);
19949       emit_move_insn (op0, op1);
19950     }
19951   DONE;
19954 (define_insn "avx5124fmaddps_4fmaddps"
19955   [(set (match_operand:V16SF 0 "register_operand" "=v")
19956         (unspec:V16SF
19957           [(match_operand:V16SF 1 "register_operand" "0")
19958            (match_operand:V64SF 2 "register_operand" "v")
19959            (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FMADD))]
19960   "TARGET_AVX5124FMAPS"
19961   "v4fmaddps\t{%3, %g2, %0|%0, %g2, %3}"
19962    [(set_attr ("type") ("ssemuladd"))
19963     (set_attr ("prefix") ("evex"))
19964     (set_attr ("mode") ("V16SF"))])
19966 (define_insn "avx5124fmaddps_4fmaddps_mask"
19967   [(set (match_operand:V16SF 0 "register_operand" "=v")
19968         (vec_merge:V16SF
19969           (unspec:V16SF
19970              [(match_operand:V64SF 1 "register_operand" "v")
19971               (match_operand:V4SF 2 "memory_operand" "m")] UNSPEC_VP4FMADD)
19972           (match_operand:V16SF 3 "register_operand" "0")
19973           (match_operand:HI 4 "register_operand" "Yk")))]
19974   "TARGET_AVX5124FMAPS"
19975   "v4fmaddps\t{%2, %g1, %0%{%4%}|%0%{%4%}, %g1, %2}"
19976    [(set_attr ("type") ("ssemuladd"))
19977     (set_attr ("prefix") ("evex"))
19978     (set_attr ("mode") ("V16SF"))])
19980 (define_insn "avx5124fmaddps_4fmaddps_maskz"
19981   [(set (match_operand:V16SF 0 "register_operand" "=v")
19982         (vec_merge:V16SF
19983           (unspec:V16SF
19984             [(match_operand:V16SF 1 "register_operand" "0")
19985              (match_operand:V64SF 2 "register_operand" "v")
19986              (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FMADD)
19987           (match_operand:V16SF 4 "const0_operand" "C")
19988           (match_operand:HI 5 "register_operand" "Yk")))]
19989   "TARGET_AVX5124FMAPS"
19990   "v4fmaddps\t{%3, %g2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %g2, %3}"
19991    [(set_attr ("type") ("ssemuladd"))
19992     (set_attr ("prefix") ("evex"))
19993     (set_attr ("mode") ("V16SF"))])
19995 (define_insn "avx5124fmaddps_4fmaddss"
19996   [(set (match_operand:V4SF 0 "register_operand" "=v")
19997         (unspec:V4SF
19998           [(match_operand:V4SF 1 "register_operand" "0")
19999            (match_operand:V64SF 2 "register_operand" "v")
20000            (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FMADD))]
20001   "TARGET_AVX5124FMAPS"
20002   "v4fmaddss\t{%3, %x2, %0|%0, %x2, %3}"
20003    [(set_attr ("type") ("ssemuladd"))
20004     (set_attr ("prefix") ("evex"))
20005     (set_attr ("mode") ("SF"))])
20007 (define_insn "avx5124fmaddps_4fmaddss_mask"
20008   [(set (match_operand:V4SF 0 "register_operand" "=v")
20009         (vec_merge:V4SF
20010           (unspec:V4SF
20011             [(match_operand:V64SF 1 "register_operand" "v")
20012              (match_operand:V4SF 2 "memory_operand" "m")] UNSPEC_VP4FMADD)
20013           (match_operand:V4SF 3 "register_operand" "0")
20014           (match_operand:QI 4 "register_operand" "Yk")))]
20015   "TARGET_AVX5124FMAPS"
20016   "v4fmaddss\t{%2, %x1, %0%{%4%}|%0%{%4%}, %x1, %2}"
20017    [(set_attr ("type") ("ssemuladd"))
20018     (set_attr ("prefix") ("evex"))
20019     (set_attr ("mode") ("SF"))])
20021 (define_insn "avx5124fmaddps_4fmaddss_maskz"
20022   [(set (match_operand:V4SF 0 "register_operand" "=v")
20023         (vec_merge:V4SF
20024           (unspec:V4SF
20025             [(match_operand:V4SF 1 "register_operand" "0")
20026              (match_operand:V64SF 2 "register_operand" "v")
20027              (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FMADD)
20028           (match_operand:V4SF 4 "const0_operand" "C")
20029           (match_operand:QI 5 "register_operand" "Yk")))]
20030   "TARGET_AVX5124FMAPS"
20031   "v4fmaddss\t{%3, %x2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %x2, %3}"
20032    [(set_attr ("type") ("ssemuladd"))
20033     (set_attr ("prefix") ("evex"))
20034     (set_attr ("mode") ("SF"))])
20036 (define_insn "avx5124fmaddps_4fnmaddps"
20037   [(set (match_operand:V16SF 0 "register_operand" "=v")
20038         (unspec:V16SF
20039           [(match_operand:V16SF 1 "register_operand" "0")
20040            (match_operand:V64SF 2 "register_operand" "v")
20041            (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FNMADD))]
20042   "TARGET_AVX5124FMAPS"
20043   "v4fnmaddps\t{%3, %g2, %0|%0, %g2, %3}"
20044    [(set_attr ("type") ("ssemuladd"))
20045     (set_attr ("prefix") ("evex"))
20046     (set_attr ("mode") ("V16SF"))])
20048 (define_insn "avx5124fmaddps_4fnmaddps_mask"
20049   [(set (match_operand:V16SF 0 "register_operand" "=v")
20050         (vec_merge:V16SF
20051           (unspec:V16SF
20052              [(match_operand:V64SF 1 "register_operand" "v")
20053               (match_operand:V4SF 2 "memory_operand" "m")] UNSPEC_VP4FNMADD)
20054           (match_operand:V16SF 3 "register_operand" "0")
20055           (match_operand:HI 4 "register_operand" "Yk")))]
20056   "TARGET_AVX5124FMAPS"
20057   "v4fnmaddps\t{%2, %g1, %0%{%4%}|%0%{%4%}, %g1, %2}"
20058    [(set_attr ("type") ("ssemuladd"))
20059     (set_attr ("prefix") ("evex"))
20060     (set_attr ("mode") ("V16SF"))])
20062 (define_insn "avx5124fmaddps_4fnmaddps_maskz"
20063   [(set (match_operand:V16SF 0 "register_operand" "=v")
20064         (vec_merge:V16SF
20065           (unspec:V16SF
20066             [(match_operand:V16SF 1 "register_operand" "0")
20067              (match_operand:V64SF 2 "register_operand" "v")
20068              (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FNMADD)
20069           (match_operand:V16SF 4 "const0_operand" "C")
20070           (match_operand:HI 5 "register_operand" "Yk")))]
20071   "TARGET_AVX5124FMAPS"
20072   "v4fnmaddps\t{%3, %g2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %g2, %3}"
20073    [(set_attr ("type") ("ssemuladd"))
20074     (set_attr ("prefix") ("evex"))
20075     (set_attr ("mode") ("V16SF"))])
20077 (define_insn "avx5124fmaddps_4fnmaddss"
20078   [(set (match_operand:V4SF 0 "register_operand" "=v")
20079         (unspec:V4SF
20080           [(match_operand:V4SF 1 "register_operand" "0")
20081            (match_operand:V64SF 2 "register_operand" "v")
20082            (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FNMADD))]
20083   "TARGET_AVX5124FMAPS"
20084   "v4fnmaddss\t{%3, %x2, %0|%0, %x2, %3}"
20085    [(set_attr ("type") ("ssemuladd"))
20086     (set_attr ("prefix") ("evex"))
20087     (set_attr ("mode") ("SF"))])
20089 (define_insn "avx5124fmaddps_4fnmaddss_mask"
20090   [(set (match_operand:V4SF 0 "register_operand" "=v")
20091         (vec_merge:V4SF
20092           (unspec:V4SF
20093             [(match_operand:V64SF 1 "register_operand" "v")
20094              (match_operand:V4SF 2 "memory_operand" "m")] UNSPEC_VP4FNMADD)
20095           (match_operand:V4SF 3 "register_operand" "0")
20096           (match_operand:QI 4 "register_operand" "Yk")))]
20097   "TARGET_AVX5124FMAPS"
20098   "v4fnmaddss\t{%2, %x1, %0%{%4%}|%0%{%4%}, %x1, %2}"
20099    [(set_attr ("type") ("ssemuladd"))
20100     (set_attr ("prefix") ("evex"))
20101     (set_attr ("mode") ("SF"))])
20103 (define_insn "avx5124fmaddps_4fnmaddss_maskz"
20104   [(set (match_operand:V4SF 0 "register_operand" "=v")
20105         (vec_merge:V4SF
20106           (unspec:V4SF
20107             [(match_operand:V4SF 1 "register_operand" "0")
20108              (match_operand:V64SF 2 "register_operand" "v")
20109              (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FNMADD)
20110           (match_operand:V4SF 4 "const0_operand" "C")
20111           (match_operand:QI 5 "register_operand" "Yk")))]
20112   "TARGET_AVX5124FMAPS"
20113   "v4fnmaddss\t{%3, %x2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %x2, %3}"
20114    [(set_attr ("type") ("ssemuladd"))
20115     (set_attr ("prefix") ("evex"))
20116     (set_attr ("mode") ("SF"))])
20118 (define_insn "avx5124vnniw_vp4dpwssd"
20119   [(set (match_operand:V16SI 0 "register_operand" "=v")
20120         (unspec:V16SI
20121           [(match_operand:V16SI 1 "register_operand" "0")
20122            (match_operand:V64SI 2 "register_operand" "v")
20123            (match_operand:V4SI 3 "memory_operand" "m")] UNSPEC_VP4DPWSSD))]
20124   "TARGET_AVX5124VNNIW"
20125   "vp4dpwssd\t{%3, %g2, %0|%0, %g2, %3}"
20126    [(set_attr ("type") ("ssemuladd"))
20127     (set_attr ("prefix") ("evex"))
20128     (set_attr ("mode") ("TI"))])
20130 (define_insn "avx5124vnniw_vp4dpwssd_mask"
20131   [(set (match_operand:V16SI 0 "register_operand" "=v")
20132         (vec_merge:V16SI
20133           (unspec:V16SI
20134              [(match_operand:V64SI 1 "register_operand" "v")
20135               (match_operand:V4SI 2 "memory_operand" "m")] UNSPEC_VP4DPWSSD)
20136           (match_operand:V16SI 3 "register_operand" "0")
20137           (match_operand:HI 4 "register_operand" "Yk")))]
20138   "TARGET_AVX5124VNNIW"
20139   "vp4dpwssd\t{%2, %g1, %0%{%4%}|%0%{%4%}, %g1, %2}"
20140    [(set_attr ("type") ("ssemuladd"))
20141     (set_attr ("prefix") ("evex"))
20142     (set_attr ("mode") ("TI"))])
20144 (define_insn "avx5124vnniw_vp4dpwssd_maskz"
20145   [(set (match_operand:V16SI 0 "register_operand" "=v")
20146         (vec_merge:V16SI
20147           (unspec:V16SI
20148             [(match_operand:V16SI 1 "register_operand" "0")
20149              (match_operand:V64SI 2 "register_operand" "v")
20150              (match_operand:V4SI 3 "memory_operand" "m")] UNSPEC_VP4DPWSSD)
20151           (match_operand:V16SI 4 "const0_operand" "C")
20152           (match_operand:HI 5 "register_operand" "Yk")))]
20153   "TARGET_AVX5124VNNIW"
20154   "vp4dpwssd\t{%3, %g2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %g2, %3}"
20155    [(set_attr ("type") ("ssemuladd"))
20156     (set_attr ("prefix") ("evex"))
20157     (set_attr ("mode") ("TI"))])
20159 (define_insn "avx5124vnniw_vp4dpwssds"
20160   [(set (match_operand:V16SI 0 "register_operand" "=v")
20161         (unspec:V16SI
20162           [(match_operand:V16SI 1 "register_operand" "0")
20163            (match_operand:V64SI 2 "register_operand" "v")
20164            (match_operand:V4SI 3 "memory_operand" "m")] UNSPEC_VP4DPWSSDS))]
20165   "TARGET_AVX5124VNNIW"
20166   "vp4dpwssds\t{%3, %g2, %0|%0, %g2, %3}"
20167    [(set_attr ("type") ("ssemuladd"))
20168     (set_attr ("prefix") ("evex"))
20169     (set_attr ("mode") ("TI"))])
20171 (define_insn "avx5124vnniw_vp4dpwssds_mask"
20172   [(set (match_operand:V16SI 0 "register_operand" "=v")
20173         (vec_merge:V16SI
20174           (unspec:V16SI
20175              [(match_operand:V64SI 1 "register_operand" "v")
20176               (match_operand:V4SI 2 "memory_operand" "m")] UNSPEC_VP4DPWSSDS)
20177           (match_operand:V16SI 3 "register_operand" "0")
20178           (match_operand:HI 4 "register_operand" "Yk")))]
20179   "TARGET_AVX5124VNNIW"
20180   "vp4dpwssds\t{%2, %g1, %0%{%4%}|%0%{%4%}, %g1, %2}"
20181    [(set_attr ("type") ("ssemuladd"))
20182     (set_attr ("prefix") ("evex"))
20183     (set_attr ("mode") ("TI"))])
20185 (define_insn "avx5124vnniw_vp4dpwssds_maskz"
20186   [(set (match_operand:V16SI 0 "register_operand" "=v")
20187         (vec_merge:V16SI
20188           (unspec:V16SI
20189             [(match_operand:V16SI 1 "register_operand" "0")
20190              (match_operand:V64SI 2 "register_operand" "v")
20191              (match_operand:V4SI 3 "memory_operand" "m")] UNSPEC_VP4DPWSSDS)
20192           (match_operand:V16SI 4 "const0_operand" "C")
20193           (match_operand:HI 5 "register_operand" "Yk")))]
20194   "TARGET_AVX5124VNNIW"
20195   "vp4dpwssds\t{%3, %g2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %g2, %3}"
20196    [(set_attr ("type") ("ssemuladd"))
20197     (set_attr ("prefix") ("evex"))
20198     (set_attr ("mode") ("TI"))])
20200 (define_insn "vpopcount<mode><mask_name>"
20201   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
20202         (popcount:VI48_AVX512VL
20203           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")))]
20204   "TARGET_AVX512VPOPCNTDQ"
20205   "vpopcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}")
20207 ;; Save multiple registers out-of-line.
20208 (define_insn "save_multiple<mode>"
20209   [(match_parallel 0 "save_multiple"
20210     [(use (match_operand:P 1 "symbol_operand"))])]
20211   "TARGET_SSE && TARGET_64BIT"
20212   "call\t%P1")
20214 ;; Restore multiple registers out-of-line.
20215 (define_insn "restore_multiple<mode>"
20216   [(match_parallel 0 "restore_multiple"
20217     [(use (match_operand:P 1 "symbol_operand"))])]
20218   "TARGET_SSE && TARGET_64BIT"
20219   "call\t%P1")
20221 ;; Restore multiple registers out-of-line and return.
20222 (define_insn "restore_multiple_and_return<mode>"
20223   [(match_parallel 0 "restore_multiple"
20224     [(return)
20225      (use (match_operand:P 1 "symbol_operand"))
20226      (set (reg:DI SP_REG) (reg:DI R10_REG))
20227     ])]
20228   "TARGET_SSE && TARGET_64BIT"
20229   "jmp\t%P1")
20231 ;; Restore multiple registers out-of-line when hard frame pointer is used,
20232 ;; perform the leave operation prior to returning (from the function).
20233 (define_insn "restore_multiple_leave_return<mode>"
20234   [(match_parallel 0 "restore_multiple"
20235     [(return)
20236      (use (match_operand:P 1 "symbol_operand"))
20237      (set (reg:DI SP_REG) (plus:DI (reg:DI BP_REG) (const_int 8)))
20238      (set (reg:DI BP_REG) (mem:DI (reg:DI BP_REG)))
20239      (clobber (mem:BLK (scratch)))
20240     ])]
20241   "TARGET_SSE && TARGET_64BIT"
20242   "jmp\t%P1")
20244 (define_insn "vpopcount<mode><mask_name>"
20245   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
20246         (popcount:VI12_AVX512VL
20247           (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "vm")))]
20248   "TARGET_AVX512BITALG"
20249   "vpopcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}")
20251 (define_insn "vgf2p8affineinvqb_<mode><mask_name>"
20252   [(set (match_operand:VI1_AVX512F 0 "register_operand" "=x,x,v")
20253         (unspec:VI1_AVX512F
20254           [(match_operand:VI1_AVX512F 1 "register_operand" "%0,x,v")
20255            (match_operand:VI1_AVX512F 2 "nonimmediate_operand" "xBm,xm,vm")
20256            (match_operand:QI 3 "const_0_to_255_operand" "n,n,n")]
20257           UNSPEC_GF2P8AFFINEINV))]
20258   "TARGET_GFNI"
20259   "@
20260    gf2p8affineinvqb\t{%3, %2, %0| %0, %2, %3}
20261    vgf2p8affineinvqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}
20262    vgf2p8affineinvqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}"
20263   [(set_attr "isa" "noavx,avx,avx512f")
20264    (set_attr "prefix_data16" "1,*,*")
20265    (set_attr "prefix_extra" "1")
20266    (set_attr "prefix" "orig,maybe_evex,evex")
20267    (set_attr "mode" "<sseinsnmode>")])
20269 (define_insn "vgf2p8affineqb_<mode><mask_name>"
20270   [(set (match_operand:VI1_AVX512F 0 "register_operand" "=x,x,v")
20271         (unspec:VI1_AVX512F
20272           [(match_operand:VI1_AVX512F 1 "register_operand" "%0,x,v")
20273            (match_operand:VI1_AVX512F 2 "nonimmediate_operand" "xBm,xm,vm")
20274            (match_operand:QI 3 "const_0_to_255_operand" "n,n,n")]
20275           UNSPEC_GF2P8AFFINE))]
20276   "TARGET_GFNI"
20277   "@
20278    gf2p8affineqb\t{%3, %2, %0| %0, %2, %3}
20279    vgf2p8affineqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}
20280    vgf2p8affineqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}"
20281   [(set_attr "isa" "noavx,avx,avx512f")
20282    (set_attr "prefix_data16" "1,*,*")
20283    (set_attr "prefix_extra" "1")
20284    (set_attr "prefix" "orig,maybe_evex,evex")
20285    (set_attr "mode" "<sseinsnmode>")])
20287 (define_insn "vgf2p8mulb_<mode><mask_name>"
20288   [(set (match_operand:VI1_AVX512F 0 "register_operand" "=x,x,v")
20289         (unspec:VI1_AVX512F
20290           [(match_operand:VI1_AVX512F 1 "register_operand" "%0,x,v")
20291            (match_operand:VI1_AVX512F 2 "nonimmediate_operand" "xBm,xm,vm")]
20292           UNSPEC_GF2P8MUL))]
20293   "TARGET_GFNI"
20294   "@
20295    gf2p8mulb\t{%2, %0| %0, %2}
20296    vgf2p8mulb\t{%2, %1, %0<mask_operand3>| %0<mask_operand3>, %1, %2}
20297    vgf2p8mulb\t{%2, %1, %0<mask_operand3>| %0<mask_operand3>, %1, %2}"
20298   [(set_attr "isa" "noavx,avx,avx512f")
20299    (set_attr "prefix_data16" "1,*,*")
20300    (set_attr "prefix_extra" "1")
20301    (set_attr "prefix" "orig,maybe_evex,evex")
20302    (set_attr "mode" "<sseinsnmode>")])
20304 (define_insn "vpshrd_<mode><mask_name>"
20305   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20306         (unspec:VI248_AVX512VL
20307           [(match_operand:VI248_AVX512VL 1 "register_operand" "v")
20308            (match_operand:VI248_AVX512VL 2 "nonimmediate_operand" "vm")
20309            (match_operand:SI 3 "const_0_to_255_operand" "n")]
20310           UNSPEC_VPSHRD))]
20311   "TARGET_AVX512VBMI2"
20312   "vpshrd<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3 }"
20313    [(set_attr ("prefix") ("evex"))])
20315 (define_insn "vpshld_<mode><mask_name>"
20316   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20317         (unspec:VI248_AVX512VL
20318           [(match_operand:VI248_AVX512VL 1 "register_operand" "v")
20319            (match_operand:VI248_AVX512VL 2 "nonimmediate_operand" "vm")
20320            (match_operand:SI 3 "const_0_to_255_operand" "n")]
20321           UNSPEC_VPSHLD))]
20322   "TARGET_AVX512VBMI2"
20323   "vpshld<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3 }"
20324    [(set_attr ("prefix") ("evex"))])
20326 (define_insn "vpshrdv_<mode>"
20327   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20328         (unspec:VI248_AVX512VL
20329           [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20330            (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20331            (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20332           UNSPEC_VPSHRDV))]
20333   "TARGET_AVX512VBMI2"
20334   "vpshrdv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3 }"
20335    [(set_attr ("prefix") ("evex"))
20336    (set_attr "mode" "<sseinsnmode>")])
20338 (define_insn "vpshrdv_<mode>_mask"
20339   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20340         (vec_merge:VI248_AVX512VL
20341           (unspec:VI248_AVX512VL
20342             [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20343              (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20344              (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20345             UNSPEC_VPSHRDV)
20346           (match_dup 1)
20347           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20348   "TARGET_AVX512VBMI2"
20349   "vpshrdv<ssemodesuffix>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20350    [(set_attr ("prefix") ("evex"))
20351    (set_attr "mode" "<sseinsnmode>")])
20353 (define_expand "vpshrdv_<mode>_maskz"
20354   [(match_operand:VI248_AVX512VL 0 "register_operand")
20355    (match_operand:VI248_AVX512VL 1 "register_operand")
20356    (match_operand:VI248_AVX512VL 2 "register_operand")
20357    (match_operand:VI248_AVX512VL 3 "nonimmediate_operand")
20358    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20359   "TARGET_AVX512VBMI2"
20361   emit_insn (gen_vpshrdv_<mode>_maskz_1 (operands[0], operands[1],
20362                                          operands[2], operands[3],
20363                                          CONST0_RTX (<MODE>mode),
20364                                                      operands[4]));
20365   DONE;
20368 (define_insn "vpshrdv_<mode>_maskz_1"
20369   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20370         (vec_merge:VI248_AVX512VL
20371           (unspec:VI248_AVX512VL
20372             [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20373              (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20374              (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20375             UNSPEC_VPSHRDV)
20376           (match_operand:VI248_AVX512VL 4 "const0_operand" "C")
20377           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20378   "TARGET_AVX512VBMI2"
20379   "vpshrdv<ssemodesuffix>\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20380    [(set_attr ("prefix") ("evex"))
20381    (set_attr "mode" "<sseinsnmode>")])
20383 (define_insn "vpshldv_<mode>"
20384   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20385         (unspec:VI248_AVX512VL
20386           [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20387            (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20388            (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20389           UNSPEC_VPSHLDV))]
20390   "TARGET_AVX512VBMI2"
20391   "vpshldv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3 }"
20392    [(set_attr ("prefix") ("evex"))
20393    (set_attr "mode" "<sseinsnmode>")])
20395 (define_insn "vpshldv_<mode>_mask"
20396   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20397         (vec_merge:VI248_AVX512VL
20398           (unspec:VI248_AVX512VL
20399             [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20400              (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20401              (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20402             UNSPEC_VPSHLDV)
20403           (match_dup 1)
20404           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20405   "TARGET_AVX512VBMI2"
20406   "vpshldv<ssemodesuffix>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20407    [(set_attr ("prefix") ("evex"))
20408    (set_attr "mode" "<sseinsnmode>")])
20410 (define_expand "vpshldv_<mode>_maskz"
20411   [(match_operand:VI248_AVX512VL 0 "register_operand")
20412    (match_operand:VI248_AVX512VL 1 "register_operand")
20413    (match_operand:VI248_AVX512VL 2 "register_operand")
20414    (match_operand:VI248_AVX512VL 3 "nonimmediate_operand")
20415    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20416   "TARGET_AVX512VBMI2"
20418   emit_insn (gen_vpshldv_<mode>_maskz_1 (operands[0], operands[1],
20419                                          operands[2], operands[3],
20420                                          CONST0_RTX (<MODE>mode),
20421                                                      operands[4]));
20422   DONE;
20425 (define_insn "vpshldv_<mode>_maskz_1"
20426   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20427         (vec_merge:VI248_AVX512VL
20428           (unspec:VI248_AVX512VL
20429             [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20430              (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20431              (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20432             UNSPEC_VPSHLDV)
20433           (match_operand:VI248_AVX512VL 4 "const0_operand" "C")
20434           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20435   "TARGET_AVX512VBMI2"
20436   "vpshldv<ssemodesuffix>\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20437    [(set_attr ("prefix") ("evex"))
20438    (set_attr "mode" "<sseinsnmode>")])
20440 (define_insn "vpdpbusd_<mode>"
20441   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20442         (unspec:VI4_AVX512VL
20443           [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20444            (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20445            (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20446           UNSPEC_VPMADDUBSWACCD))]
20447   "TARGET_AVX512VNNI"
20448   "vpdpbusd\t{%3, %2, %0|%0, %2, %3 }"
20449    [(set_attr ("prefix") ("evex"))])
20451 (define_insn "vpdpbusd_<mode>_mask"
20452   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20453         (vec_merge:VI4_AVX512VL
20454           (unspec:VI4_AVX512VL
20455             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20456              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20457              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20458             UNSPEC_VPMADDUBSWACCD)
20459           (match_dup 1)
20460           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20461   "TARGET_AVX512VNNI"
20462   "vpdpbusd\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20463    [(set_attr ("prefix") ("evex"))])
20465 (define_expand "vpdpbusd_<mode>_maskz"
20466   [(match_operand:VI4_AVX512VL 0 "register_operand")
20467    (match_operand:VI4_AVX512VL 1 "register_operand")
20468    (match_operand:VI4_AVX512VL 2 "register_operand")
20469    (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
20470    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20471   "TARGET_AVX512VNNI"
20473   emit_insn (gen_vpdpbusd_<mode>_maskz_1 (operands[0], operands[1],
20474                                           operands[2], operands[3],
20475                                           CONST0_RTX (<MODE>mode),
20476                                                       operands[4]));
20477   DONE;
20480 (define_insn "vpdpbusd_<mode>_maskz_1"
20481   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20482         (vec_merge:VI4_AVX512VL
20483           (unspec:VI4_AVX512VL
20484             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20485              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20486              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")
20487             ] UNSPEC_VPMADDUBSWACCD)
20488           (match_operand:VI4_AVX512VL 4 "const0_operand" "C")
20489           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20490   "TARGET_AVX512VNNI"
20491   "vpdpbusd\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20492    [(set_attr ("prefix") ("evex"))])
20495 (define_insn "vpdpbusds_<mode>"
20496   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20497         (unspec:VI4_AVX512VL
20498           [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20499            (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20500            (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20501           UNSPEC_VPMADDUBSWACCSSD))]
20502   "TARGET_AVX512VNNI"
20503   "vpdpbusds\t{%3, %2, %0|%0, %2, %3 }"
20504    [(set_attr ("prefix") ("evex"))])
20506 (define_insn "vpdpbusds_<mode>_mask"
20507   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20508         (vec_merge:VI4_AVX512VL
20509           (unspec:VI4_AVX512VL
20510             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20511              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20512              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20513             UNSPEC_VPMADDUBSWACCSSD)
20514           (match_dup 1)
20515           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20516   "TARGET_AVX512VNNI"
20517   "vpdpbusds\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20518    [(set_attr ("prefix") ("evex"))])
20520 (define_expand "vpdpbusds_<mode>_maskz"
20521   [(match_operand:VI4_AVX512VL 0 "register_operand")
20522    (match_operand:VI4_AVX512VL 1 "register_operand")
20523    (match_operand:VI4_AVX512VL 2 "register_operand")
20524    (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
20525    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20526   "TARGET_AVX512VNNI"
20528   emit_insn (gen_vpdpbusds_<mode>_maskz_1 (operands[0], operands[1],
20529                                            operands[2], operands[3],
20530                                            CONST0_RTX (<MODE>mode),
20531                                                        operands[4]));
20532   DONE;
20535 (define_insn "vpdpbusds_<mode>_maskz_1"
20536   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20537         (vec_merge:VI4_AVX512VL
20538           (unspec:VI4_AVX512VL
20539             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20540              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20541              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20542             UNSPEC_VPMADDUBSWACCSSD)
20543           (match_operand:VI4_AVX512VL 4 "const0_operand" "C")
20544           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20545   "TARGET_AVX512VNNI"
20546   "vpdpbusds\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20547    [(set_attr ("prefix") ("evex"))])
20550 (define_insn "vpdpwssd_<mode>"
20551   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20552         (unspec:VI4_AVX512VL
20553           [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20554            (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20555            (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20556           UNSPEC_VPMADDWDACCD))]
20557   "TARGET_AVX512VNNI"
20558   "vpdpwssd\t{%3, %2, %0|%0, %2, %3 }"
20559    [(set_attr ("prefix") ("evex"))])
20561 (define_insn "vpdpwssd_<mode>_mask"
20562   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20563         (vec_merge:VI4_AVX512VL
20564           (unspec:VI4_AVX512VL
20565             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20566              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20567              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20568             UNSPEC_VPMADDWDACCD)
20569           (match_dup 1)
20570           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20571   "TARGET_AVX512VNNI"
20572   "vpdpwssd\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20573    [(set_attr ("prefix") ("evex"))])
20575 (define_expand "vpdpwssd_<mode>_maskz"
20576   [(match_operand:VI4_AVX512VL 0 "register_operand")
20577    (match_operand:VI4_AVX512VL 1 "register_operand")
20578    (match_operand:VI4_AVX512VL 2 "register_operand")
20579    (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
20580    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20581   "TARGET_AVX512VNNI"
20583   emit_insn (gen_vpdpwssd_<mode>_maskz_1 (operands[0], operands[1],
20584                                           operands[2], operands[3],
20585                                           CONST0_RTX (<MODE>mode),
20586                                                       operands[4]));
20587   DONE;
20590 (define_insn "vpdpwssd_<mode>_maskz_1"
20591   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20592         (vec_merge:VI4_AVX512VL
20593           (unspec:VI4_AVX512VL
20594             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20595              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20596              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20597             UNSPEC_VPMADDWDACCD)
20598           (match_operand:VI4_AVX512VL 4 "const0_operand" "C")
20599           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20600   "TARGET_AVX512VNNI"
20601   "vpdpwssd\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20602    [(set_attr ("prefix") ("evex"))])
20605 (define_insn "vpdpwssds_<mode>"
20606   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20607         (unspec:VI4_AVX512VL
20608           [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20609            (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20610            (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20611           UNSPEC_VPMADDWDACCSSD))]
20612   "TARGET_AVX512VNNI"
20613   "vpdpwssds\t{%3, %2, %0|%0, %2, %3 }"
20614    [(set_attr ("prefix") ("evex"))])
20616 (define_insn "vpdpwssds_<mode>_mask"
20617   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20618         (vec_merge:VI4_AVX512VL
20619           (unspec:VI4_AVX512VL
20620             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20621              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20622              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20623             UNSPEC_VPMADDWDACCSSD)
20624           (match_dup 1)
20625           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20626   "TARGET_AVX512VNNI"
20627   "vpdpwssds\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20628    [(set_attr ("prefix") ("evex"))])
20630 (define_expand "vpdpwssds_<mode>_maskz"
20631   [(match_operand:VI4_AVX512VL 0 "register_operand")
20632    (match_operand:VI4_AVX512VL 1 "register_operand")
20633    (match_operand:VI4_AVX512VL 2 "register_operand")
20634    (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
20635    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20636   "TARGET_AVX512VNNI"
20638   emit_insn (gen_vpdpwssds_<mode>_maskz_1 (operands[0], operands[1],
20639                                            operands[2], operands[3],
20640                                            CONST0_RTX (<MODE>mode),
20641                                                        operands[4]));
20642   DONE;
20645 (define_insn "vpdpwssds_<mode>_maskz_1"
20646   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20647         (vec_merge:VI4_AVX512VL
20648           (unspec:VI4_AVX512VL
20649             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20650              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20651              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20652             UNSPEC_VPMADDWDACCSSD)
20653           (match_operand:VI4_AVX512VL 4 "const0_operand" "C")
20654           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20655   "TARGET_AVX512VNNI"
20656   "vpdpwssds\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20657    [(set_attr ("prefix") ("evex"))])
20659 (define_insn "vaesdec_<mode>"
20660   [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=v")
20661         (unspec:VI1_AVX512VL_F
20662           [(match_operand:VI1_AVX512VL_F 1 "register_operand" "v")
20663            (match_operand:VI1_AVX512VL_F 2 "vector_operand" "v")]
20664           UNSPEC_VAESDEC))]
20665   "TARGET_VAES"
20666   "vaesdec\t{%2, %1, %0|%0, %1, %2}"
20669 (define_insn "vaesdeclast_<mode>"
20670   [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=v")
20671         (unspec:VI1_AVX512VL_F
20672           [(match_operand:VI1_AVX512VL_F 1 "register_operand" "v")
20673            (match_operand:VI1_AVX512VL_F 2 "vector_operand" "v")]
20674           UNSPEC_VAESDECLAST))]
20675   "TARGET_VAES"
20676   "vaesdeclast\t{%2, %1, %0|%0, %1, %2}"
20679 (define_insn "vaesenc_<mode>"
20680   [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=v")
20681         (unspec:VI1_AVX512VL_F
20682           [(match_operand:VI1_AVX512VL_F 1 "register_operand" "v")
20683            (match_operand:VI1_AVX512VL_F 2 "vector_operand" "vm")]
20684           UNSPEC_VAESENC))]
20685   "TARGET_VAES"
20686   "vaesenc\t{%2, %1, %0|%0, %1, %2}"
20689 (define_insn "vaesenclast_<mode>"
20690   [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=v")
20691         (unspec:VI1_AVX512VL_F
20692           [(match_operand:VI1_AVX512VL_F 1 "register_operand" "v")
20693            (match_operand:VI1_AVX512VL_F 2 "vector_operand" "vm")]
20694           UNSPEC_VAESENCLAST))]
20695   "TARGET_VAES"
20696   "vaesenclast\t{%2, %1, %0|%0, %1, %2}"
20699 (define_insn "vpclmulqdq_<mode>"
20700   [(set (match_operand:VI8_FVL 0 "register_operand" "=v")
20701         (unspec:VI8_FVL [(match_operand:VI8_FVL 1 "register_operand" "v")
20702                          (match_operand:VI8_FVL 2 "vector_operand" "vm")
20703                          (match_operand:SI 3 "const_0_to_255_operand" "n")]
20704                         UNSPEC_VPCLMULQDQ))]
20705   "TARGET_VPCLMULQDQ"
20706   "vpclmulqdq\t{%3, %2, %1, %0|%0, %1, %2, %3}"
20707   [(set_attr "mode" "DI")])
20709 (define_insn "avx512vl_vpshufbitqmb<mode><mask_scalar_merge_name>"
20710   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
20711         (unspec:<avx512fmaskmode>
20712           [(match_operand:VI1_AVX512VLBW 1 "register_operand" "v")
20713            (match_operand:VI1_AVX512VLBW 2 "nonimmediate_operand" "vm")]
20714           UNSPEC_VPSHUFBIT))]
20715   "TARGET_AVX512BITALG"
20716   "vpshufbitqmb\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
20717   [(set_attr "prefix" "evex")
20718    (set_attr "mode" "<sseinsnmode>")])