Fix error when selecting number of memory pools
[official-gcc.git] / gcc / config / i386 / sse.md
blob5020c058d648c95488c3a66d086997a5da794f86
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 (define_mode_iterator VF_AVX512
654   [(V4SF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")
655    (V8SF "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")
656    V16SF V8DF])
658 (define_mode_attr avx512bcst
659   [(V4SI "%{1to4%}") (V2DI "%{1to2%}")
660    (V8SI "%{1to8%}") (V4DI "%{1to4%}")
661    (V16SI "%{1to16%}") (V8DI "%{1to8%}")
662    (V4SF "%{1to4%}") (V2DF "%{1to2%}")
663    (V8SF "%{1to8%}") (V4DF "%{1to4%}")
664    (V16SF "%{1to16%}") (V8DF "%{1to8%}")])
666 ;; Mapping from float mode to required SSE level
667 (define_mode_attr sse
668   [(SF "sse") (DF "sse2")
669    (V4SF "sse") (V2DF "sse2")
670    (V16SF "avx512f") (V8SF "avx")
671    (V8DF "avx512f") (V4DF "avx")])
673 (define_mode_attr sse2
674   [(V16QI "sse2") (V32QI "avx") (V64QI "avx512f")
675    (V2DI "sse2") (V4DI "avx") (V8DI "avx512f")])
677 (define_mode_attr sse3
678   [(V16QI "sse3") (V32QI "avx")])
680 (define_mode_attr sse4_1
681   [(V4SF "sse4_1") (V2DF "sse4_1")
682    (V8SF "avx") (V4DF "avx")
683    (V8DF "avx512f")
684    (V4DI "avx") (V2DI "sse4_1")
685    (V8SI "avx") (V4SI "sse4_1")
686    (V16QI "sse4_1") (V32QI "avx")
687    (V8HI "sse4_1") (V16HI "avx")])
689 (define_mode_attr avxsizesuffix
690   [(V64QI "512") (V32HI "512") (V16SI "512") (V8DI "512")
691    (V32QI "256") (V16HI "256") (V8SI "256") (V4DI "256")
692    (V16QI "") (V8HI "") (V4SI "") (V2DI "")
693    (V16SF "512") (V8DF "512")
694    (V8SF "256") (V4DF "256")
695    (V4SF "") (V2DF "")])
697 ;; SSE instruction mode
698 (define_mode_attr sseinsnmode
699   [(V64QI "XI") (V32HI "XI") (V16SI "XI") (V8DI "XI") (V4TI "XI")
700    (V32QI "OI") (V16HI "OI") (V8SI "OI") (V4DI "OI") (V2TI "OI")
701    (V16QI "TI") (V8HI "TI") (V4SI "TI") (V2DI "TI") (V1TI "TI")
702    (V16SF "V16SF") (V8DF "V8DF")
703    (V8SF "V8SF") (V4DF "V4DF")
704    (V4SF "V4SF") (V2DF "V2DF")
705    (TI "TI")])
707 ;; Mapping of vector modes to corresponding mask size
708 (define_mode_attr avx512fmaskmode
709   [(V64QI "DI") (V32QI "SI") (V16QI "HI")
710    (V32HI "SI") (V16HI "HI") (V8HI  "QI") (V4HI "QI")
711    (V16SI "HI") (V8SI  "QI") (V4SI  "QI")
712    (V8DI  "QI") (V4DI  "QI") (V2DI  "QI")
713    (V16SF "HI") (V8SF  "QI") (V4SF  "QI")
714    (V8DF  "QI") (V4DF  "QI") (V2DF  "QI")])
716 ;; Mapping of vector modes to corresponding mask size
717 (define_mode_attr avx512fmaskmodelower
718   [(V64QI "di") (V32QI "si") (V16QI "hi")
719    (V32HI "si") (V16HI "hi") (V8HI  "qi") (V4HI "qi")
720    (V16SI "hi") (V8SI  "qi") (V4SI  "qi")
721    (V8DI  "qi") (V4DI  "qi") (V2DI  "qi")
722    (V16SF "hi") (V8SF  "qi") (V4SF  "qi")
723    (V8DF  "qi") (V4DF  "qi") (V2DF  "qi")])
725 ;; Mapping of vector float modes to an integer mode of the same size
726 (define_mode_attr sseintvecmode
727   [(V16SF "V16SI") (V8DF  "V8DI")
728    (V8SF  "V8SI")  (V4DF  "V4DI")
729    (V4SF  "V4SI")  (V2DF  "V2DI")
730    (V16SI "V16SI") (V8DI  "V8DI")
731    (V8SI  "V8SI")  (V4DI  "V4DI")
732    (V4SI  "V4SI")  (V2DI  "V2DI")
733    (V16HI "V16HI") (V8HI  "V8HI")
734    (V32HI "V32HI") (V64QI "V64QI")
735    (V32QI "V32QI") (V16QI "V16QI")])
737 (define_mode_attr sseintvecmode2
738   [(V8DF "XI") (V4DF "OI") (V2DF "TI")
739    (V8SF "OI") (V4SF "TI")])
741 (define_mode_attr sseintvecmodelower
742   [(V16SF "v16si") (V8DF "v8di")
743    (V8SF "v8si") (V4DF "v4di")
744    (V4SF "v4si") (V2DF "v2di")
745    (V8SI "v8si") (V4DI "v4di")
746    (V4SI "v4si") (V2DI "v2di")
747    (V16HI "v16hi") (V8HI "v8hi")
748    (V32QI "v32qi") (V16QI "v16qi")])
750 ;; Mapping of vector modes to a vector mode of double size
751 (define_mode_attr ssedoublevecmode
752   [(V32QI "V64QI") (V16HI "V32HI") (V8SI "V16SI") (V4DI "V8DI")
753    (V16QI "V32QI") (V8HI "V16HI") (V4SI "V8SI") (V2DI "V4DI")
754    (V8SF "V16SF") (V4DF "V8DF")
755    (V4SF "V8SF") (V2DF "V4DF")])
757 ;; Mapping of vector modes to a vector mode of half size
758 (define_mode_attr ssehalfvecmode
759   [(V64QI "V32QI") (V32HI "V16HI") (V16SI "V8SI") (V8DI "V4DI") (V4TI "V2TI")
760    (V32QI "V16QI") (V16HI  "V8HI") (V8SI  "V4SI") (V4DI "V2DI")
761    (V16QI  "V8QI") (V8HI   "V4HI") (V4SI  "V2SI")
762    (V16SF "V8SF") (V8DF "V4DF")
763    (V8SF  "V4SF") (V4DF "V2DF")
764    (V4SF  "V2SF")])
766 (define_mode_attr ssehalfvecmodelower
767   [(V64QI "v32qi") (V32HI "v16hi") (V16SI "v8si") (V8DI "v4di") (V4TI "v2ti")
768    (V32QI "v16qi") (V16HI  "v8hi") (V8SI  "v4si") (V4DI "v2di")
769    (V16QI  "v8qi") (V8HI   "v4hi") (V4SI  "v2si")
770    (V16SF "v8sf") (V8DF "v4df")
771    (V8SF  "v4sf") (V4DF "v2df")
772    (V4SF  "v2sf")])
774 ;; Mapping of vector modes ti packed single mode of the same size
775 (define_mode_attr ssePSmode
776   [(V16SI "V16SF") (V8DF "V16SF")
777    (V16SF "V16SF") (V8DI "V16SF")
778    (V64QI "V16SF") (V32QI "V8SF") (V16QI "V4SF")
779    (V32HI "V16SF") (V16HI "V8SF") (V8HI "V4SF")
780    (V8SI "V8SF") (V4SI "V4SF")
781    (V4DI "V8SF") (V2DI "V4SF")
782    (V4TI "V16SF") (V2TI "V8SF") (V1TI "V4SF")
783    (V8SF "V8SF") (V4SF "V4SF")
784    (V4DF "V8SF") (V2DF "V4SF")])
786 (define_mode_attr ssePSmode2
787   [(V8DI "V8SF") (V4DI "V4SF")])
789 ;; Mapping of vector modes back to the scalar modes
790 (define_mode_attr ssescalarmode
791   [(V64QI "QI") (V32QI "QI") (V16QI "QI")
792    (V32HI "HI") (V16HI "HI") (V8HI "HI")
793    (V16SI "SI") (V8SI "SI")  (V4SI "SI")
794    (V8DI "DI")  (V4DI "DI")  (V2DI "DI")
795    (V16SF "SF") (V8SF "SF")  (V4SF "SF")
796    (V8DF "DF")  (V4DF "DF")  (V2DF "DF")
797    (V4TI "TI")  (V2TI "TI")])
799 ;; Mapping of vector modes back to the scalar modes
800 (define_mode_attr ssescalarmodelower
801   [(V64QI "qi") (V32QI "qi") (V16QI "qi")
802    (V32HI "hi") (V16HI "hi") (V8HI "hi")
803    (V16SI "si") (V8SI "si")  (V4SI "si")
804    (V8DI "di")  (V4DI "di")  (V2DI "di")
805    (V16SF "sf") (V8SF "sf")  (V4SF "sf")
806    (V8DF "df")  (V4DF "df")  (V2DF "df")
807    (V4TI "ti")  (V2TI "ti")])
809 ;; Mapping of vector modes to the 128bit modes
810 (define_mode_attr ssexmmmode
811   [(V64QI "V16QI") (V32QI "V16QI") (V16QI "V16QI")
812    (V32HI "V8HI")  (V16HI "V8HI") (V8HI "V8HI")
813    (V16SI "V4SI")  (V8SI "V4SI")  (V4SI "V4SI")
814    (V8DI "V2DI")   (V4DI "V2DI")  (V2DI "V2DI")
815    (V16SF "V4SF")  (V8SF "V4SF")  (V4SF "V4SF")
816    (V8DF "V2DF")   (V4DF "V2DF")  (V2DF "V2DF")])
818 ;; Pointer size override for scalar modes (Intel asm dialect)
819 (define_mode_attr iptr
820   [(V64QI "b") (V32HI "w") (V16SI "k") (V8DI "q")
821    (V32QI "b") (V16HI "w") (V8SI "k") (V4DI "q")
822    (V16QI "b") (V8HI "w") (V4SI "k") (V2DI "q")
823    (V16SF "k") (V8DF "q")
824    (V8SF "k") (V4DF "q")
825    (V4SF "k") (V2DF "q")
826    (SF "k") (DF "q")])
828 ;; Number of scalar elements in each vector type
829 (define_mode_attr ssescalarnum
830   [(V64QI "64") (V16SI "16") (V8DI "8")
831    (V32QI "32") (V16HI "16") (V8SI "8") (V4DI "4")
832    (V16QI "16") (V8HI "8") (V4SI "4") (V2DI "2")
833    (V16SF "16") (V8DF "8")
834    (V8SF "8") (V4DF "4")
835    (V4SF "4") (V2DF "2")])
837 ;; Mask of scalar elements in each vector type
838 (define_mode_attr ssescalarnummask
839   [(V32QI "31") (V16HI "15") (V8SI "7") (V4DI "3")
840    (V16QI "15") (V8HI "7") (V4SI "3") (V2DI "1")
841    (V8SF "7") (V4DF "3")
842    (V4SF "3") (V2DF "1")])
844 (define_mode_attr ssescalarsize
845   [(V4TI  "64") (V2TI  "64") (V1TI  "64")
846    (V8DI  "64") (V4DI  "64") (V2DI  "64")
847    (V64QI "8") (V32QI "8") (V16QI "8")
848    (V32HI "16") (V16HI "16") (V8HI "16")
849    (V16SI "32") (V8SI "32") (V4SI "32")
850    (V16SF "32") (V8SF "32") (V4SF "32")
851    (V8DF "64") (V4DF "64") (V2DF "64")])
853 ;; SSE prefix for integer vector modes
854 (define_mode_attr sseintprefix
855   [(V2DI  "p") (V2DF  "")
856    (V4DI  "p") (V4DF  "")
857    (V8DI  "p") (V8DF  "")
858    (V4SI  "p") (V4SF  "")
859    (V8SI  "p") (V8SF  "")
860    (V16SI "p") (V16SF "")
861    (V16QI "p") (V8HI "p")
862    (V32QI "p") (V16HI "p")
863    (V64QI "p") (V32HI "p")])
865 ;; SSE scalar suffix for vector modes
866 (define_mode_attr ssescalarmodesuffix
867   [(SF "ss") (DF "sd")
868    (V16SF "ss") (V8DF "sd")
869    (V8SF "ss") (V4DF "sd")
870    (V4SF "ss") (V2DF "sd")
871    (V16SI "d") (V8DI "q")
872    (V8SI "d") (V4DI "q")
873    (V4SI "d") (V2DI "q")])
875 ;; Pack/unpack vector modes
876 (define_mode_attr sseunpackmode
877   [(V16QI "V8HI") (V8HI "V4SI") (V4SI "V2DI")
878    (V32QI "V16HI") (V16HI "V8SI") (V8SI "V4DI")
879    (V32HI "V16SI") (V64QI "V32HI") (V16SI "V8DI")])
881 (define_mode_attr ssepackmode
882   [(V8HI "V16QI") (V4SI "V8HI") (V2DI "V4SI")
883    (V16HI "V32QI") (V8SI "V16HI") (V4DI "V8SI")
884    (V32HI "V64QI") (V16SI "V32HI") (V8DI "V16SI")])
886 ;; Mapping of the max integer size for xop rotate immediate constraint
887 (define_mode_attr sserotatemax
888   [(V16QI "7") (V8HI "15") (V4SI "31") (V2DI "63")])
890 ;; Mapping of mode to cast intrinsic name
891 (define_mode_attr castmode
892  [(V8SI "si") (V8SF "ps") (V4DF "pd")
893   (V16SI "si") (V16SF "ps") (V8DF "pd")])
895 ;; Instruction suffix for sign and zero extensions.
896 (define_code_attr extsuffix [(sign_extend "sx") (zero_extend "zx")])
898 ;; i128 for integer vectors and TARGET_AVX2, f128 otherwise.
899 ;; i64x4 or f64x4 for 512bit modes.
900 (define_mode_attr i128
901   [(V16SF "f64x4") (V8SF "f128") (V8DF "f64x4") (V4DF "f128")
902    (V64QI "i64x4") (V32QI "%~128") (V32HI "i64x4") (V16HI "%~128")
903    (V16SI "i64x4") (V8SI "%~128") (V8DI "i64x4") (V4DI "%~128")])
905 ;; For 256-bit modes for TARGET_AVX512VL && TARGET_AVX512DQ
906 ;; i32x4, f32x4, i64x2 or f64x2 suffixes.
907 (define_mode_attr i128vldq
908   [(V8SF "f32x4") (V4DF "f64x2")
909    (V32QI "i32x4") (V16HI "i32x4") (V8SI "i32x4") (V4DI "i64x2")])
911 ;; Mix-n-match
912 (define_mode_iterator AVX256MODE2P [V8SI V8SF V4DF])
913 (define_mode_iterator AVX512MODE2P [V16SI V16SF V8DF])
915 ;; Mapping for dbpsabbw modes
916 (define_mode_attr dbpsadbwmode
917   [(V32HI "V64QI") (V16HI "V32QI") (V8HI "V16QI")])
919 ;; Mapping suffixes for broadcast
920 (define_mode_attr bcstscalarsuff
921   [(V64QI "b")  (V32QI "b") (V16QI "b")
922    (V32HI "w")  (V16HI "w") (V8HI "w")
923    (V16SI "d")  (V8SI "d")  (V4SI "d")
924    (V8DI "q")   (V4DI "q")  (V2DI "q")
925    (V16SF "ss") (V8SF "ss") (V4SF "ss")
926    (V8DF "sd")  (V4DF "sd") (V2DF "sd")])
928 ;; Tie mode of assembler operand to mode iterator
929 (define_mode_attr xtg_mode
930   [(V16QI "x") (V8HI "x") (V4SI "x") (V2DI "x") (V4SF "x") (V2DF "x")
931    (V32QI "t") (V16HI "t") (V8SI "t") (V4DI "t") (V8SF "t") (V4DF "t")
932    (V64QI "g") (V32HI "g") (V16SI "g") (V8DI "g") (V16SF "g") (V8DF "g")])
934 ;; Half mask mode for unpacks
935 (define_mode_attr HALFMASKMODE
936   [(DI "SI") (SI "HI")])
938 ;; Double mask mode for packs
939 (define_mode_attr DOUBLEMASKMODE
940   [(HI "SI") (SI "DI")])
943 ;; Include define_subst patterns for instructions with mask
944 (include "subst.md")
946 ;; Patterns whose name begins with "sse{,2,3}_" are invoked by intrinsics.
948 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
950 ;; Move patterns
952 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
954 ;; All of these patterns are enabled for SSE1 as well as SSE2.
955 ;; This is essential for maintaining stable calling conventions.
957 (define_expand "mov<mode>"
958   [(set (match_operand:VMOVE 0 "nonimmediate_operand")
959         (match_operand:VMOVE 1 "nonimmediate_operand"))]
960   "TARGET_SSE"
962   ix86_expand_vector_move (<MODE>mode, operands);
963   DONE;
966 (define_insn "mov<mode>_internal"
967   [(set (match_operand:VMOVE 0 "nonimmediate_operand"
968          "=v,v ,v ,m")
969         (match_operand:VMOVE 1 "nonimmediate_or_sse_const_operand"
970          " C,BC,vm,v"))]
971   "TARGET_SSE
972    && (register_operand (operands[0], <MODE>mode)
973        || register_operand (operands[1], <MODE>mode))"
975   switch (get_attr_type (insn))
976     {
977     case TYPE_SSELOG1:
978       return standard_sse_constant_opcode (insn, operands);
980     case TYPE_SSEMOV:
981       /* There is no evex-encoded vmov* for sizes smaller than 64-bytes
982          in avx512f, so we need to use workarounds, to access sse registers
983          16-31, which are evex-only. In avx512vl we don't need workarounds.  */
984       if (TARGET_AVX512F && <MODE_SIZE> < 64 && !TARGET_AVX512VL
985           && (EXT_REX_SSE_REG_P (operands[0])
986               || EXT_REX_SSE_REG_P (operands[1])))
987         {
988           if (memory_operand (operands[0], <MODE>mode))
989             {
990               if (<MODE_SIZE> == 32)
991                 return "vextract<shuffletype>64x4\t{$0x0, %g1, %0|%0, %g1, 0x0}";
992               else if (<MODE_SIZE> == 16)
993                 return "vextract<shuffletype>32x4\t{$0x0, %g1, %0|%0, %g1, 0x0}";
994               else
995                 gcc_unreachable ();
996             }
997           else if (memory_operand (operands[1], <MODE>mode))
998             {
999               if (<MODE_SIZE> == 32)
1000                 return "vbroadcast<shuffletype>64x4\t{%1, %g0|%g0, %1}";
1001               else if (<MODE_SIZE> == 16)
1002                 return "vbroadcast<shuffletype>32x4\t{%1, %g0|%g0, %1}";
1003               else
1004                 gcc_unreachable ();
1005             }
1006           else
1007             /* Reg -> reg move is always aligned.  Just use wider move.  */
1008             switch (get_attr_mode (insn))
1009               {
1010               case MODE_V8SF:
1011               case MODE_V4SF:
1012                 return "vmovaps\t{%g1, %g0|%g0, %g1}";
1013               case MODE_V4DF:
1014               case MODE_V2DF:
1015                 return "vmovapd\t{%g1, %g0|%g0, %g1}";
1016               case MODE_OI:
1017               case MODE_TI:
1018                 return "vmovdqa64\t{%g1, %g0|%g0, %g1}";
1019               default:
1020                 gcc_unreachable ();
1021               }
1022         }
1024       switch (get_attr_mode (insn))
1025         {
1026         case MODE_V16SF:
1027         case MODE_V8SF:
1028         case MODE_V4SF:
1029           if (misaligned_operand (operands[0], <MODE>mode)
1030               || misaligned_operand (operands[1], <MODE>mode))
1031             return "%vmovups\t{%1, %0|%0, %1}";
1032           else
1033             return "%vmovaps\t{%1, %0|%0, %1}";
1035         case MODE_V8DF:
1036         case MODE_V4DF:
1037         case MODE_V2DF:
1038           if (misaligned_operand (operands[0], <MODE>mode)
1039               || misaligned_operand (operands[1], <MODE>mode))
1040             return "%vmovupd\t{%1, %0|%0, %1}";
1041           else
1042             return "%vmovapd\t{%1, %0|%0, %1}";
1044         case MODE_OI:
1045         case MODE_TI:
1046           if (misaligned_operand (operands[0], <MODE>mode)
1047               || misaligned_operand (operands[1], <MODE>mode))
1048             return TARGET_AVX512VL
1049                    && (<MODE>mode == V4SImode
1050                        || <MODE>mode == V2DImode
1051                        || <MODE>mode == V8SImode
1052                        || <MODE>mode == V4DImode
1053                        || TARGET_AVX512BW)
1054                    ? "vmovdqu<ssescalarsize>\t{%1, %0|%0, %1}"
1055                    : "%vmovdqu\t{%1, %0|%0, %1}";
1056           else
1057             return TARGET_AVX512VL ? "vmovdqa64\t{%1, %0|%0, %1}"
1058                                    : "%vmovdqa\t{%1, %0|%0, %1}";
1059         case MODE_XI:
1060           if (misaligned_operand (operands[0], <MODE>mode)
1061               || misaligned_operand (operands[1], <MODE>mode))
1062             return (<MODE>mode == V16SImode
1063                     || <MODE>mode == V8DImode
1064                     || TARGET_AVX512BW)
1065                    ? "vmovdqu<ssescalarsize>\t{%1, %0|%0, %1}"
1066                    : "vmovdqu64\t{%1, %0|%0, %1}";
1067           else
1068             return "vmovdqa64\t{%1, %0|%0, %1}";
1070         default:
1071           gcc_unreachable ();
1072         }
1074     default:
1075       gcc_unreachable ();
1076     }
1078   [(set_attr "type" "sselog1,sselog1,ssemov,ssemov")
1079    (set_attr "prefix" "maybe_vex")
1080    (set (attr "mode")
1081         (cond [(and (eq_attr "alternative" "1")
1082                     (match_test "TARGET_AVX512VL"))
1083                  (const_string "<sseinsnmode>")
1084                (and (match_test "<MODE_SIZE> == 16")
1085                     (ior (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
1086                          (and (eq_attr "alternative" "3")
1087                               (match_test "TARGET_SSE_TYPELESS_STORES"))))
1088                  (const_string "<ssePSmode>")
1089                (match_test "TARGET_AVX")
1090                  (const_string "<sseinsnmode>")
1091                (ior (not (match_test "TARGET_SSE2"))
1092                     (match_test "optimize_function_for_size_p (cfun)"))
1093                  (const_string "V4SF")
1094                (and (eq_attr "alternative" "0")
1095                     (match_test "TARGET_SSE_LOAD0_BY_PXOR"))
1096                  (const_string "TI")
1097               ]
1098               (const_string "<sseinsnmode>")))
1099    (set (attr "enabled")
1100         (cond [(and (match_test "<MODE_SIZE> == 16")
1101                     (eq_attr "alternative" "1"))
1102                  (symbol_ref "TARGET_SSE2")
1103                (and (match_test "<MODE_SIZE> == 32")
1104                     (eq_attr "alternative" "1"))
1105                  (symbol_ref "TARGET_AVX2")
1106               ]
1107               (symbol_ref "true")))])
1109 (define_insn "<avx512>_load<mode>_mask"
1110   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v,v")
1111         (vec_merge:V48_AVX512VL
1112           (match_operand:V48_AVX512VL 1 "nonimmediate_operand" "v,m")
1113           (match_operand:V48_AVX512VL 2 "nonimm_or_0_operand" "0C,0C")
1114           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
1115   "TARGET_AVX512F"
1117   if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
1118     {
1119       if (misaligned_operand (operands[1], <MODE>mode))
1120         return "vmovu<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1121       else
1122         return "vmova<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1123     }
1124   else
1125     {
1126       if (misaligned_operand (operands[1], <MODE>mode))
1127         return "vmovdqu<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1128       else
1129         return "vmovdqa<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1130     }
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>_load<mode>_mask"
1138   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v,v")
1139         (vec_merge:VI12_AVX512VL
1140           (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "v,m")
1141           (match_operand:VI12_AVX512VL 2 "nonimm_or_0_operand" "0C,0C")
1142           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
1143   "TARGET_AVX512BW"
1144   "vmovdqu<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
1145   [(set_attr "type" "ssemov")
1146    (set_attr "prefix" "evex")
1147    (set_attr "memory" "none,load")
1148    (set_attr "mode" "<sseinsnmode>")])
1150 (define_insn "<avx512>_blendm<mode>"
1151   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v")
1152         (vec_merge:V48_AVX512VL
1153           (match_operand:V48_AVX512VL 2 "nonimmediate_operand" "vm")
1154           (match_operand:V48_AVX512VL 1 "register_operand" "v")
1155           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
1156   "TARGET_AVX512F"
1157   "v<sseintprefix>blendm<ssemodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}"
1158   [(set_attr "type" "ssemov")
1159    (set_attr "prefix" "evex")
1160    (set_attr "mode" "<sseinsnmode>")])
1162 (define_insn "<avx512>_blendm<mode>"
1163   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
1164         (vec_merge:VI12_AVX512VL
1165           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
1166           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
1167           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
1168   "TARGET_AVX512BW"
1169   "vpblendm<ssemodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}"
1170   [(set_attr "type" "ssemov")
1171    (set_attr "prefix" "evex")
1172    (set_attr "mode" "<sseinsnmode>")])
1174 (define_insn "<avx512>_store<mode>_mask"
1175   [(set (match_operand:V48_AVX512VL 0 "memory_operand" "=m")
1176         (vec_merge:V48_AVX512VL
1177           (match_operand:V48_AVX512VL 1 "register_operand" "v")
1178           (match_dup 0)
1179           (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1180   "TARGET_AVX512F"
1182   if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
1183     {
1184       if (misaligned_operand (operands[0], <MODE>mode))
1185         return "vmovu<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1186       else
1187         return "vmova<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1188     }
1189   else
1190     {
1191       if (misaligned_operand (operands[0], <MODE>mode))
1192         return "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1193       else
1194         return "vmovdqa<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1195     }
1197   [(set_attr "type" "ssemov")
1198    (set_attr "prefix" "evex")
1199    (set_attr "memory" "store")
1200    (set_attr "mode" "<sseinsnmode>")])
1202 (define_insn "<avx512>_store<mode>_mask"
1203   [(set (match_operand:VI12_AVX512VL 0 "memory_operand" "=m")
1204         (vec_merge:VI12_AVX512VL
1205           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
1206           (match_dup 0)
1207           (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1208   "TARGET_AVX512BW"
1209   "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
1210   [(set_attr "type" "ssemov")
1211    (set_attr "prefix" "evex")
1212    (set_attr "memory" "store")
1213    (set_attr "mode" "<sseinsnmode>")])
1215 (define_insn "sse2_movq128"
1216   [(set (match_operand:V2DI 0 "register_operand" "=v")
1217         (vec_concat:V2DI
1218           (vec_select:DI
1219             (match_operand:V2DI 1 "nonimmediate_operand" "vm")
1220             (parallel [(const_int 0)]))
1221           (const_int 0)))]
1222   "TARGET_SSE2"
1223   "%vmovq\t{%1, %0|%0, %q1}"
1224   [(set_attr "type" "ssemov")
1225    (set_attr "prefix" "maybe_vex")
1226    (set_attr "mode" "TI")])
1228 ;; Move a DI from a 32-bit register pair (e.g. %edx:%eax) to an xmm.
1229 ;; We'd rather avoid this entirely; if the 32-bit reg pair was loaded
1230 ;; from memory, we'd prefer to load the memory directly into the %xmm
1231 ;; register.  To facilitate this happy circumstance, this pattern won't
1232 ;; split until after register allocation.  If the 64-bit value didn't
1233 ;; come from memory, this is the best we can do.  This is much better
1234 ;; than storing %edx:%eax into a stack temporary and loading an %xmm
1235 ;; from there.
1237 (define_insn_and_split "movdi_to_sse"
1238   [(parallel
1239     [(set (match_operand:V4SI 0 "register_operand" "=?x,x")
1240           (subreg:V4SI (match_operand:DI 1 "nonimmediate_operand" "r,m") 0))
1241      (clobber (match_scratch:V4SI 2 "=&x,X"))])]
1242   "!TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_TO_VEC"
1243   "#"
1244   "&& reload_completed"
1245   [(const_int 0)]
1247  if (register_operand (operands[1], DImode))
1248    {
1249       /* The DImode arrived in a pair of integral registers (e.g. %edx:%eax).
1250          Assemble the 64-bit DImode value in an xmm register.  */
1251       emit_insn (gen_sse2_loadld (operands[0], CONST0_RTX (V4SImode),
1252                                   gen_lowpart (SImode, operands[1])));
1253       emit_insn (gen_sse2_loadld (operands[2], CONST0_RTX (V4SImode),
1254                                   gen_highpart (SImode, operands[1])));
1255       emit_insn (gen_vec_interleave_lowv4si (operands[0], operands[0],
1256                                              operands[2]));
1257    }
1258  else if (memory_operand (operands[1], DImode))
1259    emit_insn (gen_vec_concatv2di (gen_lowpart (V2DImode, operands[0]),
1260                                   operands[1], const0_rtx));
1261  else
1262    gcc_unreachable ();
1263  DONE;
1266 (define_split
1267   [(set (match_operand:V4SF 0 "register_operand")
1268         (match_operand:V4SF 1 "zero_extended_scalar_load_operand"))]
1269   "TARGET_SSE && reload_completed"
1270   [(set (match_dup 0)
1271         (vec_merge:V4SF
1272           (vec_duplicate:V4SF (match_dup 1))
1273           (match_dup 2)
1274           (const_int 1)))]
1276   operands[1] = gen_lowpart (SFmode, operands[1]);
1277   operands[2] = CONST0_RTX (V4SFmode);
1280 (define_split
1281   [(set (match_operand:V2DF 0 "register_operand")
1282         (match_operand:V2DF 1 "zero_extended_scalar_load_operand"))]
1283   "TARGET_SSE2 && reload_completed"
1284   [(set (match_dup 0) (vec_concat:V2DF (match_dup 1) (match_dup 2)))]
1286   operands[1] = gen_lowpart (DFmode, operands[1]);
1287   operands[2] = CONST0_RTX (DFmode);
1290 (define_expand "movmisalign<mode>"
1291   [(set (match_operand:VMOVE 0 "nonimmediate_operand")
1292         (match_operand:VMOVE 1 "nonimmediate_operand"))]
1293   "TARGET_SSE"
1295   ix86_expand_vector_move_misalign (<MODE>mode, operands);
1296   DONE;
1299 ;; Merge movsd/movhpd to movupd for TARGET_SSE_UNALIGNED_LOAD_OPTIMAL targets.
1300 (define_peephole2
1301   [(set (match_operand:V2DF 0 "sse_reg_operand")
1302         (vec_concat:V2DF (match_operand:DF 1 "memory_operand")
1303                          (match_operand:DF 4 "const0_operand")))
1304    (set (match_operand:V2DF 2 "sse_reg_operand")
1305         (vec_concat:V2DF (vec_select:DF (match_dup 2)
1306                                         (parallel [(const_int 0)]))
1307                          (match_operand:DF 3 "memory_operand")))]
1308   "TARGET_SSE2 && TARGET_SSE_UNALIGNED_LOAD_OPTIMAL
1309    && ix86_operands_ok_for_move_multiple (operands, true, DFmode)"
1310   [(set (match_dup 2) (match_dup 5))]
1311   "operands[5] = adjust_address (operands[1], V2DFmode, 0);")
1313 (define_peephole2
1314   [(set (match_operand:DF 0 "sse_reg_operand")
1315         (match_operand:DF 1 "memory_operand"))
1316    (set (match_operand:V2DF 2 "sse_reg_operand")
1317         (vec_concat:V2DF (match_operand:DF 4 "sse_reg_operand")
1318                          (match_operand:DF 3 "memory_operand")))]
1319   "TARGET_SSE2 && TARGET_SSE_UNALIGNED_LOAD_OPTIMAL
1320    && REGNO (operands[4]) == REGNO (operands[2])
1321    && ix86_operands_ok_for_move_multiple (operands, true, DFmode)"
1322   [(set (match_dup 2) (match_dup 5))]
1323   "operands[5] = adjust_address (operands[1], V2DFmode, 0);")
1325 ;; Merge movlpd/movhpd to movupd for TARGET_SSE_UNALIGNED_STORE_OPTIMAL targets.
1326 (define_peephole2
1327   [(set (match_operand:DF 0 "memory_operand")
1328         (vec_select:DF (match_operand:V2DF 1 "sse_reg_operand")
1329                        (parallel [(const_int 0)])))
1330    (set (match_operand:DF 2 "memory_operand")
1331         (vec_select:DF (match_operand:V2DF 3 "sse_reg_operand")
1332                        (parallel [(const_int 1)])))]
1333   "TARGET_SSE2 && TARGET_SSE_UNALIGNED_STORE_OPTIMAL
1334    && ix86_operands_ok_for_move_multiple (operands, false, DFmode)"
1335   [(set (match_dup 4) (match_dup 1))]
1336   "operands[4] = adjust_address (operands[0], V2DFmode, 0);")
1338 (define_insn "<sse3>_lddqu<avxsizesuffix>"
1339   [(set (match_operand:VI1 0 "register_operand" "=x")
1340         (unspec:VI1 [(match_operand:VI1 1 "memory_operand" "m")]
1341                     UNSPEC_LDDQU))]
1342   "TARGET_SSE3"
1343   "%vlddqu\t{%1, %0|%0, %1}"
1344   [(set_attr "type" "ssemov")
1345    (set_attr "movu" "1")
1346    (set (attr "prefix_data16")
1347      (if_then_else
1348        (match_test "TARGET_AVX")
1349      (const_string "*")
1350      (const_string "0")))
1351    (set (attr "prefix_rep")
1352      (if_then_else
1353        (match_test "TARGET_AVX")
1354      (const_string "*")
1355      (const_string "1")))
1356    (set_attr "prefix" "maybe_vex")
1357    (set_attr "mode" "<sseinsnmode>")])
1359 (define_insn "sse2_movnti<mode>"
1360   [(set (match_operand:SWI48 0 "memory_operand" "=m")
1361         (unspec:SWI48 [(match_operand:SWI48 1 "register_operand" "r")]
1362                       UNSPEC_MOVNT))]
1363   "TARGET_SSE2"
1364   "movnti\t{%1, %0|%0, %1}"
1365   [(set_attr "type" "ssemov")
1366    (set_attr "prefix_data16" "0")
1367    (set_attr "mode" "<MODE>")])
1369 (define_insn "<sse>_movnt<mode>"
1370   [(set (match_operand:VF 0 "memory_operand" "=m")
1371         (unspec:VF
1372           [(match_operand:VF 1 "register_operand" "v")]
1373           UNSPEC_MOVNT))]
1374   "TARGET_SSE"
1375   "%vmovnt<ssemodesuffix>\t{%1, %0|%0, %1}"
1376   [(set_attr "type" "ssemov")
1377    (set_attr "prefix" "maybe_vex")
1378    (set_attr "mode" "<MODE>")])
1380 (define_insn "<sse2>_movnt<mode>"
1381   [(set (match_operand:VI8 0 "memory_operand" "=m")
1382         (unspec:VI8 [(match_operand:VI8 1 "register_operand" "v")]
1383                     UNSPEC_MOVNT))]
1384   "TARGET_SSE2"
1385   "%vmovntdq\t{%1, %0|%0, %1}"
1386   [(set_attr "type" "ssecvt")
1387    (set (attr "prefix_data16")
1388      (if_then_else
1389        (match_test "TARGET_AVX")
1390      (const_string "*")
1391      (const_string "1")))
1392    (set_attr "prefix" "maybe_vex")
1393    (set_attr "mode" "<sseinsnmode>")])
1395 ; Expand patterns for non-temporal stores.  At the moment, only those
1396 ; that directly map to insns are defined; it would be possible to
1397 ; define patterns for other modes that would expand to several insns.
1399 ;; Modes handled by storent patterns.
1400 (define_mode_iterator STORENT_MODE
1401   [(DI "TARGET_SSE2 && TARGET_64BIT") (SI "TARGET_SSE2")
1402    (SF "TARGET_SSE4A") (DF "TARGET_SSE4A")
1403    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") (V2DI "TARGET_SSE2")
1404    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
1405    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
1407 (define_expand "storent<mode>"
1408   [(set (match_operand:STORENT_MODE 0 "memory_operand")
1409         (unspec:STORENT_MODE
1410           [(match_operand:STORENT_MODE 1 "register_operand")]
1411           UNSPEC_MOVNT))]
1412   "TARGET_SSE")
1414 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1416 ;; Mask operations
1418 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1420 ;; All integer modes with AVX512BW/DQ.
1421 (define_mode_iterator SWI1248_AVX512BWDQ
1422   [(QI "TARGET_AVX512DQ") HI (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW")])
1424 ;; All integer modes with AVX512BW, where HImode operation
1425 ;; can be used instead of QImode.
1426 (define_mode_iterator SWI1248_AVX512BW
1427   [QI HI (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW")])
1429 ;; All integer modes with AVX512BW/DQ, even HImode requires DQ.
1430 (define_mode_iterator SWI1248_AVX512BWDQ2
1431   [(QI "TARGET_AVX512DQ") (HI "TARGET_AVX512DQ")
1432    (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW")])
1434 (define_expand "kmov<mskmodesuffix>"
1435   [(set (match_operand:SWI1248_AVX512BWDQ 0 "nonimmediate_operand")
1436         (match_operand:SWI1248_AVX512BWDQ 1 "nonimmediate_operand"))]
1437   "TARGET_AVX512F
1438    && !(MEM_P (operands[0]) && MEM_P (operands[1]))")
1440 (define_insn "k<code><mode>"
1441   [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
1442         (any_logic:SWI1248_AVX512BW
1443           (match_operand:SWI1248_AVX512BW 1 "register_operand" "k")
1444           (match_operand:SWI1248_AVX512BW 2 "register_operand" "k")))
1445    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1446   "TARGET_AVX512F"
1448   if (get_attr_mode (insn) == MODE_HI)
1449     return "k<logic>w\t{%2, %1, %0|%0, %1, %2}";
1450   else
1451     return "k<logic><mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
1453   [(set_attr "type" "msklog")
1454    (set_attr "prefix" "vex")
1455    (set (attr "mode")
1456      (cond [(and (match_test "<MODE>mode == QImode")
1457                  (not (match_test "TARGET_AVX512DQ")))
1458                (const_string "HI")
1459            ]
1460            (const_string "<MODE>")))])
1462 (define_insn "kandn<mode>"
1463   [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
1464         (and:SWI1248_AVX512BW
1465           (not:SWI1248_AVX512BW
1466             (match_operand:SWI1248_AVX512BW 1 "register_operand" "k"))
1467           (match_operand:SWI1248_AVX512BW 2 "register_operand" "k")))
1468    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1469   "TARGET_AVX512F"
1471   if (get_attr_mode (insn) == MODE_HI)
1472     return "kandnw\t{%2, %1, %0|%0, %1, %2}";
1473   else
1474     return "kandn<mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
1476   [(set_attr "type" "msklog")
1477    (set_attr "prefix" "vex")
1478    (set (attr "mode")
1479      (cond [(and (match_test "<MODE>mode == QImode")
1480                  (not (match_test "TARGET_AVX512DQ")))
1481               (const_string "HI")
1482            ]
1483            (const_string "<MODE>")))])
1485 (define_insn "kxnor<mode>"
1486   [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
1487         (not:SWI1248_AVX512BW
1488           (xor:SWI1248_AVX512BW
1489             (match_operand:SWI1248_AVX512BW 1 "register_operand" "k")
1490             (match_operand:SWI1248_AVX512BW 2 "register_operand" "k"))))
1491    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1492   "TARGET_AVX512F"
1494   if (get_attr_mode (insn) == MODE_HI)
1495     return "kxnorw\t{%2, %1, %0|%0, %1, %2}";
1496   else
1497     return "kxnor<mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
1499   [(set_attr "type" "msklog")
1500    (set_attr "prefix" "vex")
1501    (set (attr "mode")
1502      (cond [(and (match_test "<MODE>mode == QImode")
1503                  (not (match_test "TARGET_AVX512DQ")))
1504               (const_string "HI")
1505            ]
1506            (const_string "<MODE>")))])
1508 (define_insn "knot<mode>"
1509   [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
1510         (not:SWI1248_AVX512BW
1511           (match_operand:SWI1248_AVX512BW 1 "register_operand" "k")))
1512    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1513   "TARGET_AVX512F"
1515   if (get_attr_mode (insn) == MODE_HI)
1516     return "knotw\t{%1, %0|%0, %1}";
1517   else
1518     return "knot<mskmodesuffix>\t{%1, %0|%0, %1}";
1520   [(set_attr "type" "msklog")
1521    (set_attr "prefix" "vex")
1522    (set (attr "mode")
1523      (cond [(and (match_test "<MODE>mode == QImode")
1524                  (not (match_test "TARGET_AVX512DQ")))
1525                (const_string "HI")
1526            ]
1527            (const_string "<MODE>")))])
1529 (define_insn "kadd<mode>"
1530   [(set (match_operand:SWI1248_AVX512BWDQ2 0 "register_operand" "=k")
1531         (plus:SWI1248_AVX512BWDQ2
1532           (match_operand:SWI1248_AVX512BWDQ2 1 "register_operand" "k")
1533           (match_operand:SWI1248_AVX512BWDQ2 2 "register_operand" "k")))
1534    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1535   "TARGET_AVX512F"
1536   "kadd<mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}"
1537   [(set_attr "type" "msklog")
1538    (set_attr "prefix" "vex")
1539    (set_attr "mode" "<MODE>")])
1541 ;; Mask variant shift mnemonics
1542 (define_code_attr mshift [(ashift "shiftl") (lshiftrt "shiftr")])
1544 (define_insn "k<code><mode>"
1545   [(set (match_operand:SWI1248_AVX512BWDQ 0 "register_operand" "=k")
1546         (any_lshift:SWI1248_AVX512BWDQ
1547           (match_operand:SWI1248_AVX512BWDQ 1 "register_operand" "k")
1548           (match_operand:QI 2 "immediate_operand" "n")))
1549    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1550   "TARGET_AVX512F"
1551   "k<mshift><mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}"
1552   [(set_attr "type" "msklog")
1553    (set_attr "prefix" "vex")
1554    (set_attr "mode" "<MODE>")])
1556 (define_insn "ktest<mode>"
1557   [(set (reg:CC FLAGS_REG)
1558         (unspec:CC
1559           [(match_operand:SWI1248_AVX512BWDQ2 0 "register_operand" "k")
1560            (match_operand:SWI1248_AVX512BWDQ2 1 "register_operand" "k")]
1561           UNSPEC_KTEST))]
1562   "TARGET_AVX512F"
1563   "ktest<mskmodesuffix>\t{%1, %0|%0, %1}"
1564   [(set_attr "mode" "<MODE>")
1565    (set_attr "type" "msklog")
1566    (set_attr "prefix" "vex")])
1568 (define_insn "kortest<mode>"
1569   [(set (reg:CC FLAGS_REG)
1570         (unspec:CC
1571           [(match_operand:SWI1248_AVX512BWDQ 0 "register_operand" "k")
1572            (match_operand:SWI1248_AVX512BWDQ 1 "register_operand" "k")]
1573           UNSPEC_KORTEST))]
1574   "TARGET_AVX512F"
1575   "kortest<mskmodesuffix>\t{%1, %0|%0, %1}"
1576   [(set_attr "mode" "<MODE>")
1577    (set_attr "type" "msklog")
1578    (set_attr "prefix" "vex")])
1580 (define_insn "kunpckhi"
1581   [(set (match_operand:HI 0 "register_operand" "=k")
1582         (ior:HI
1583           (ashift:HI
1584             (zero_extend:HI (match_operand:QI 1 "register_operand" "k"))
1585             (const_int 8))
1586           (zero_extend:HI (match_operand:QI 2 "register_operand" "k"))))]
1587   "TARGET_AVX512F"
1588   "kunpckbw\t{%2, %1, %0|%0, %1, %2}"
1589   [(set_attr "mode" "HI")
1590    (set_attr "type" "msklog")
1591    (set_attr "prefix" "vex")])
1593 (define_insn "kunpcksi"
1594   [(set (match_operand:SI 0 "register_operand" "=k")
1595         (ior:SI
1596           (ashift:SI
1597             (zero_extend:SI (match_operand:HI 1 "register_operand" "k"))
1598             (const_int 16))
1599           (zero_extend:SI (match_operand:HI 2 "register_operand" "k"))))]
1600   "TARGET_AVX512BW"
1601   "kunpckwd\t{%2, %1, %0|%0, %1, %2}"
1602   [(set_attr "mode" "SI")])
1604 (define_insn "kunpckdi"
1605   [(set (match_operand:DI 0 "register_operand" "=k")
1606         (ior:DI
1607           (ashift:DI
1608             (zero_extend:DI (match_operand:SI 1 "register_operand" "k"))
1609             (const_int 32))
1610           (zero_extend:DI (match_operand:SI 2 "register_operand" "k"))))]
1611   "TARGET_AVX512BW"
1612   "kunpckdq\t{%2, %1, %0|%0, %1, %2}"
1613   [(set_attr "mode" "DI")])
1616 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1618 ;; Parallel floating point arithmetic
1620 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1622 (define_expand "<code><mode>2"
1623   [(set (match_operand:VF 0 "register_operand")
1624         (absneg:VF
1625           (match_operand:VF 1 "register_operand")))]
1626   "TARGET_SSE"
1627   "ix86_expand_fp_absneg_operator (<CODE>, <MODE>mode, operands); DONE;")
1629 (define_insn_and_split "*absneg<mode>2"
1630   [(set (match_operand:VF 0 "register_operand" "=x,x,v,v")
1631         (match_operator:VF 3 "absneg_operator"
1632           [(match_operand:VF 1 "vector_operand" "0,  xBm,v, m")]))
1633    (use (match_operand:VF 2 "vector_operand"    "xBm,0,  vm,v"))]
1634   "TARGET_SSE"
1635   "#"
1636   "&& reload_completed"
1637   [(const_int 0)]
1639   enum rtx_code absneg_op;
1640   rtx op1, op2;
1641   rtx t;
1643   if (TARGET_AVX)
1644     {
1645       if (MEM_P (operands[1]))
1646         op1 = operands[2], op2 = operands[1];
1647       else
1648         op1 = operands[1], op2 = operands[2];
1649     }
1650   else
1651     {
1652       op1 = operands[0];
1653       if (rtx_equal_p (operands[0], operands[1]))
1654         op2 = operands[2];
1655       else
1656         op2 = operands[1];
1657     }
1659   absneg_op = GET_CODE (operands[3]) == NEG ? XOR : AND;
1660   t = gen_rtx_fmt_ee (absneg_op, <MODE>mode, op1, op2);
1661   t = gen_rtx_SET (operands[0], t);
1662   emit_insn (t);
1663   DONE;
1665   [(set_attr "isa" "noavx,noavx,avx,avx")])
1667 (define_expand "<plusminus_insn><mode>3<mask_name><round_name>"
1668   [(set (match_operand:VF 0 "register_operand")
1669         (plusminus:VF
1670           (match_operand:VF 1 "<round_nimm_predicate>")
1671           (match_operand:VF 2 "<round_nimm_predicate>")))]
1672   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1673   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
1675 (define_insn "*<plusminus_insn><mode>3<mask_name><round_name>"
1676   [(set (match_operand:VF 0 "register_operand" "=x,v")
1677         (plusminus:VF
1678           (match_operand:VF 1 "<round_nimm_predicate>" "<comm>0,v")
1679           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1680   "TARGET_SSE && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)
1681    && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1682   "@
1683    <plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
1684    v<plusminus_mnemonic><ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1685   [(set_attr "isa" "noavx,avx")
1686    (set_attr "type" "sseadd")
1687    (set_attr "prefix" "<mask_prefix3>")
1688    (set_attr "mode" "<MODE>")])
1690 (define_insn "*sub<mode>3<mask_name>_bcst"
1691   [(set (match_operand:VF_AVX512 0 "register_operand" "=v")
1692         (minus:VF_AVX512
1693           (match_operand:VF_AVX512 1 "register_operand" "v")
1694           (vec_duplicate:VF_AVX512
1695             (match_operand:<ssescalarmode> 2 "memory_operand" "m"))))]
1696   "TARGET_AVX512F
1697    && ix86_binary_operator_ok (MINUS, <MODE>mode, operands)
1698    && <mask_mode512bit_condition>"
1699   "vsub<ssemodesuffix>\t{%2<avx512bcst>, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<avx512bcst>}"
1700   [(set_attr "prefix" "evex")
1701    (set_attr "type" "sseadd")
1702    (set_attr "mode" "<MODE>")])
1704 (define_insn "*add<mode>3<mask_name>_bcst"
1705   [(set (match_operand:VF_AVX512 0 "register_operand" "=v")
1706         (plus:VF_AVX512
1707           (vec_duplicate:VF_AVX512
1708             (match_operand:<ssescalarmode> 1 "memory_operand" "m"))
1709           (match_operand:VF_AVX512 2 "register_operand" "v")))]
1710   "TARGET_AVX512F
1711    && ix86_binary_operator_ok (PLUS, <MODE>mode, operands)
1712    && <mask_mode512bit_condition>"
1713   "vadd<ssemodesuffix>\t{%1<avx512bcst>, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1<avx512bcst>}"
1714   [(set_attr "prefix" "evex")
1715    (set_attr "type" "sseadd")
1716    (set_attr "mode" "<MODE>")])
1718 (define_insn "<sse>_vm<plusminus_insn><mode>3<mask_scalar_name><round_scalar_name>"
1719   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1720         (vec_merge:VF_128
1721           (plusminus:VF_128
1722             (match_operand:VF_128 1 "register_operand" "0,v")
1723             (match_operand:VF_128 2 "vector_operand" "xBm,<round_scalar_constraint>"))
1724           (match_dup 1)
1725           (const_int 1)))]
1726   "TARGET_SSE"
1727   "@
1728    <plusminus_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
1729    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>}"
1730   [(set_attr "isa" "noavx,avx")
1731    (set_attr "type" "sseadd")
1732    (set_attr "prefix" "<round_scalar_prefix>")
1733    (set_attr "mode" "<ssescalarmode>")])
1735 (define_expand "mul<mode>3<mask_name><round_name>"
1736   [(set (match_operand:VF 0 "register_operand")
1737         (mult:VF
1738           (match_operand:VF 1 "<round_nimm_predicate>")
1739           (match_operand:VF 2 "<round_nimm_predicate>")))]
1740   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1741   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
1743 (define_insn "*mul<mode>3<mask_name><round_name>"
1744   [(set (match_operand:VF 0 "register_operand" "=x,v")
1745         (mult:VF
1746           (match_operand:VF 1 "<round_nimm_predicate>" "%0,v")
1747           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1748   "TARGET_SSE
1749    && !(MEM_P (operands[1]) && MEM_P (operands[2]))
1750    && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1751   "@
1752    mul<ssemodesuffix>\t{%2, %0|%0, %2}
1753    vmul<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1754   [(set_attr "isa" "noavx,avx")
1755    (set_attr "type" "ssemul")
1756    (set_attr "prefix" "<mask_prefix3>")
1757    (set_attr "btver2_decode" "direct,double")
1758    (set_attr "mode" "<MODE>")])
1760 (define_insn "*mul<mode>3<mask_name>_bcst"
1761   [(set (match_operand:VF_AVX512 0 "register_operand" "=v")
1762         (mult:VF_AVX512
1763           (vec_duplicate:VF_AVX512
1764              (match_operand:<ssescalarmode> 1 "memory_operand" "m"))
1765           (match_operand:VF_AVX512 2 "register_operand" "v")))]
1766   "TARGET_AVX512F && <mask_mode512bit_condition>"
1767   "vmul<ssemodesuffix>\t{%1<avx512bcst>, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1<<avx512bcst>>}"
1768   [(set_attr "prefix" "evex")
1769    (set_attr "type" "ssemul")
1770    (set_attr "mode" "<MODE>")])
1772 (define_insn "<sse>_vm<multdiv_mnemonic><mode>3<mask_scalar_name><round_scalar_name>"
1773   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1774         (vec_merge:VF_128
1775           (multdiv:VF_128
1776             (match_operand:VF_128 1 "register_operand" "0,v")
1777             (match_operand:VF_128 2 "vector_operand" "xBm,<round_scalar_constraint>"))
1778           (match_dup 1)
1779           (const_int 1)))]
1780   "TARGET_SSE"
1781   "@
1782    <multdiv_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
1783    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>}"
1784   [(set_attr "isa" "noavx,avx")
1785    (set_attr "type" "sse<multdiv_mnemonic>")
1786    (set_attr "prefix" "<round_scalar_prefix>")
1787    (set_attr "btver2_decode" "direct,double")
1788    (set_attr "mode" "<ssescalarmode>")])
1790 (define_expand "div<mode>3"
1791   [(set (match_operand:VF2 0 "register_operand")
1792         (div:VF2 (match_operand:VF2 1 "register_operand")
1793                  (match_operand:VF2 2 "vector_operand")))]
1794   "TARGET_SSE2"
1795   "ix86_fixup_binary_operands_no_copy (DIV, <MODE>mode, operands);")
1797 (define_expand "div<mode>3"
1798   [(set (match_operand:VF1 0 "register_operand")
1799         (div:VF1 (match_operand:VF1 1 "register_operand")
1800                  (match_operand:VF1 2 "vector_operand")))]
1801   "TARGET_SSE"
1803   ix86_fixup_binary_operands_no_copy (DIV, <MODE>mode, operands);
1805   if (TARGET_SSE_MATH
1806       && TARGET_RECIP_VEC_DIV
1807       && !optimize_insn_for_size_p ()
1808       && flag_finite_math_only && !flag_trapping_math
1809       && flag_unsafe_math_optimizations)
1810     {
1811       ix86_emit_swdivsf (operands[0], operands[1], operands[2], <MODE>mode);
1812       DONE;
1813     }
1816 (define_insn "<sse>_div<mode>3<mask_name><round_name>"
1817   [(set (match_operand:VF 0 "register_operand" "=x,v")
1818         (div:VF
1819           (match_operand:VF 1 "register_operand" "0,v")
1820           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1821   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1822   "@
1823    div<ssemodesuffix>\t{%2, %0|%0, %2}
1824    vdiv<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1825   [(set_attr "isa" "noavx,avx")
1826    (set_attr "type" "ssediv")
1827    (set_attr "prefix" "<mask_prefix3>")
1828    (set_attr "mode" "<MODE>")])
1830 (define_insn "*<avx512>_div<mode>3<mask_name>_bcst"
1831   [(set (match_operand:VF_AVX512 0 "register_operand" "=v")
1832         (div:VF_AVX512
1833           (match_operand:VF_AVX512 1 "register_operand" "v")
1834           (vec_duplicate:VF_AVX512
1835              (match_operand:<ssescalarmode> 2 "memory_operand" "m"))))]
1836   "TARGET_AVX512F && <mask_mode512bit_condition>"
1837   "vdiv<ssemodesuffix>\t{%2<avx512bcst>, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<<avx512bcst>>}"
1838   [(set_attr "prefix" "evex")
1839     (set_attr "type" "ssediv")
1840    (set_attr "mode" "<MODE>")])
1842 (define_insn "<sse>_rcp<mode>2"
1843   [(set (match_operand:VF1_128_256 0 "register_operand" "=x")
1844         (unspec:VF1_128_256
1845           [(match_operand:VF1_128_256 1 "vector_operand" "xBm")] UNSPEC_RCP))]
1846   "TARGET_SSE"
1847   "%vrcpps\t{%1, %0|%0, %1}"
1848   [(set_attr "type" "sse")
1849    (set_attr "atom_sse_attr" "rcp")
1850    (set_attr "btver2_sse_attr" "rcp")
1851    (set_attr "prefix" "maybe_vex")
1852    (set_attr "mode" "<MODE>")])
1854 (define_insn "sse_vmrcpv4sf2"
1855   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
1856         (vec_merge:V4SF
1857           (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,xm")]
1858                        UNSPEC_RCP)
1859           (match_operand:V4SF 2 "register_operand" "0,x")
1860           (const_int 1)))]
1861   "TARGET_SSE"
1862   "@
1863    rcpss\t{%1, %0|%0, %k1}
1864    vrcpss\t{%1, %2, %0|%0, %2, %k1}"
1865   [(set_attr "isa" "noavx,avx")
1866    (set_attr "type" "sse")
1867    (set_attr "atom_sse_attr" "rcp")
1868    (set_attr "btver2_sse_attr" "rcp")
1869    (set_attr "prefix" "orig,vex")
1870    (set_attr "mode" "SF")])
1872 (define_insn "<mask_codefor>rcp14<mode><mask_name>"
1873   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
1874         (unspec:VF_AVX512VL
1875           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")]
1876           UNSPEC_RCP14))]
1877   "TARGET_AVX512F"
1878   "vrcp14<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
1879   [(set_attr "type" "sse")
1880    (set_attr "prefix" "evex")
1881    (set_attr "mode" "<MODE>")])
1883 (define_insn "srcp14<mode>"
1884   [(set (match_operand:VF_128 0 "register_operand" "=v")
1885         (vec_merge:VF_128
1886           (unspec:VF_128
1887             [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1888             UNSPEC_RCP14)
1889           (match_operand:VF_128 2 "register_operand" "v")
1890           (const_int 1)))]
1891   "TARGET_AVX512F"
1892   "vrcp14<ssescalarmodesuffix>\t{%1, %2, %0|%0, %2, %<iptr>1}"
1893   [(set_attr "type" "sse")
1894    (set_attr "prefix" "evex")
1895    (set_attr "mode" "<MODE>")])
1897 (define_insn "srcp14<mode>_mask"
1898   [(set (match_operand:VF_128 0 "register_operand" "=v")
1899         (vec_merge:VF_128
1900           (vec_merge:VF_128
1901             (unspec:VF_128
1902               [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1903             UNSPEC_RCP14)
1904               (match_operand:VF_128 3 "nonimm_or_0_operand" "0C")
1905             (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk"))
1906           (match_operand:VF_128 2 "register_operand" "v")
1907           (const_int 1)))]
1908   "TARGET_AVX512F"
1909   "vrcp14<ssescalarmodesuffix>\t{%1, %2, %0%{%4%}%N3|%0%{%4%}%N3, %2, %<iptr>1}"
1910   [(set_attr "type" "sse")
1911    (set_attr "prefix" "evex")
1912    (set_attr "mode" "<MODE>")])
1914 (define_expand "sqrt<mode>2"
1915   [(set (match_operand:VF2 0 "register_operand")
1916         (sqrt:VF2 (match_operand:VF2 1 "vector_operand")))]
1917   "TARGET_SSE2")
1919 (define_expand "sqrt<mode>2"
1920   [(set (match_operand:VF1 0 "register_operand")
1921         (sqrt:VF1 (match_operand:VF1 1 "vector_operand")))]
1922   "TARGET_SSE"
1924   if (TARGET_SSE_MATH
1925       && TARGET_RECIP_VEC_SQRT
1926       && !optimize_insn_for_size_p ()
1927       && flag_finite_math_only && !flag_trapping_math
1928       && flag_unsafe_math_optimizations)
1929     {
1930       ix86_emit_swsqrtsf (operands[0], operands[1], <MODE>mode, false);
1931       DONE;
1932     }
1935 (define_insn "<sse>_sqrt<mode>2<mask_name><round_name>"
1936   [(set (match_operand:VF 0 "register_operand" "=x,v")
1937         (sqrt:VF (match_operand:VF 1 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1938   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1939   "@
1940    sqrt<ssemodesuffix>\t{%1, %0|%0, %1}
1941    vsqrt<ssemodesuffix>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
1942   [(set_attr "isa" "noavx,avx")
1943    (set_attr "type" "sse")
1944    (set_attr "atom_sse_attr" "sqrt")
1945    (set_attr "btver2_sse_attr" "sqrt")
1946    (set_attr "prefix" "maybe_vex")
1947    (set_attr "mode" "<MODE>")])
1949 (define_insn "<sse>_vmsqrt<mode>2<mask_scalar_name><round_scalar_name>"
1950   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1951         (vec_merge:VF_128
1952           (sqrt:VF_128
1953             (match_operand:VF_128 1 "vector_operand" "xBm,<round_scalar_constraint>"))
1954           (match_operand:VF_128 2 "register_operand" "0,v")
1955           (const_int 1)))]
1956   "TARGET_SSE"
1957   "@
1958    sqrt<ssescalarmodesuffix>\t{%1, %0|%0, %<iptr>1}
1959    vsqrt<ssescalarmodesuffix>\t{<round_scalar_mask_op3>%1, %2, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %2, %<iptr>1<round_scalar_mask_op3>}"
1960   [(set_attr "isa" "noavx,avx")
1961    (set_attr "type" "sse")
1962    (set_attr "atom_sse_attr" "sqrt")
1963    (set_attr "prefix" "<round_scalar_prefix>")
1964    (set_attr "btver2_sse_attr" "sqrt")
1965    (set_attr "mode" "<ssescalarmode>")])
1967 (define_expand "rsqrt<mode>2"
1968   [(set (match_operand:VF1_128_256 0 "register_operand")
1969         (unspec:VF1_128_256
1970           [(match_operand:VF1_128_256 1 "vector_operand")] UNSPEC_RSQRT))]
1971   "TARGET_SSE_MATH"
1973   ix86_emit_swsqrtsf (operands[0], operands[1], <MODE>mode, true);
1974   DONE;
1977 (define_expand "rsqrtv16sf2"
1978   [(set (match_operand:V16SF 0 "register_operand")
1979         (unspec:V16SF
1980           [(match_operand:V16SF 1 "vector_operand")]
1981           UNSPEC_RSQRT28))]
1982   "TARGET_SSE_MATH && TARGET_AVX512ER"
1984   ix86_emit_swsqrtsf (operands[0], operands[1], V16SFmode, true);
1985   DONE;
1988 (define_insn "<sse>_rsqrt<mode>2"
1989   [(set (match_operand:VF1_128_256 0 "register_operand" "=x")
1990         (unspec:VF1_128_256
1991           [(match_operand:VF1_128_256 1 "vector_operand" "xBm")] UNSPEC_RSQRT))]
1992   "TARGET_SSE"
1993   "%vrsqrtps\t{%1, %0|%0, %1}"
1994   [(set_attr "type" "sse")
1995    (set_attr "prefix" "maybe_vex")
1996    (set_attr "mode" "<MODE>")])
1998 (define_insn "<mask_codefor>rsqrt14<mode><mask_name>"
1999   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
2000         (unspec:VF_AVX512VL
2001           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")]
2002           UNSPEC_RSQRT14))]
2003   "TARGET_AVX512F"
2004   "vrsqrt14<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
2005   [(set_attr "type" "sse")
2006    (set_attr "prefix" "evex")
2007    (set_attr "mode" "<MODE>")])
2009 (define_insn "rsqrt14<mode>"
2010   [(set (match_operand:VF_128 0 "register_operand" "=v")
2011         (vec_merge:VF_128
2012           (unspec:VF_128
2013             [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
2014             UNSPEC_RSQRT14)
2015           (match_operand:VF_128 2 "register_operand" "v")
2016           (const_int 1)))]
2017   "TARGET_AVX512F"
2018   "vrsqrt14<ssescalarmodesuffix>\t{%1, %2, %0|%0, %2, %<iptr>1}"
2019   [(set_attr "type" "sse")
2020    (set_attr "prefix" "evex")
2021    (set_attr "mode" "<MODE>")])
2023 (define_insn "rsqrt14_<mode>_mask"
2024   [(set (match_operand:VF_128 0 "register_operand" "=v")
2025         (vec_merge:VF_128
2026           (vec_merge:VF_128
2027             (unspec:VF_128
2028               [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
2029               UNSPEC_RSQRT14)
2030               (match_operand:VF_128 3 "nonimm_or_0_operand" "0C")
2031               (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk"))
2032           (match_operand:VF_128 2 "register_operand" "v")
2033           (const_int 1)))]
2034   "TARGET_AVX512F"
2035   "vrsqrt14<ssescalarmodesuffix>\t{%1, %2, %0%{%4%}%N3|%0%{%4%}%N3, %2, %<iptr>1}"
2036   [(set_attr "type" "sse")
2037    (set_attr "prefix" "evex")
2038    (set_attr "mode" "<MODE>")])
2040 (define_insn "sse_vmrsqrtv4sf2"
2041   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
2042         (vec_merge:V4SF
2043           (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,xm")]
2044                        UNSPEC_RSQRT)
2045           (match_operand:V4SF 2 "register_operand" "0,x")
2046           (const_int 1)))]
2047   "TARGET_SSE"
2048   "@
2049    rsqrtss\t{%1, %0|%0, %k1}
2050    vrsqrtss\t{%1, %2, %0|%0, %2, %k1}"
2051   [(set_attr "isa" "noavx,avx")
2052    (set_attr "type" "sse")
2053    (set_attr "prefix" "orig,vex")
2054    (set_attr "mode" "SF")])
2056 (define_expand "<code><mode>3<mask_name><round_saeonly_name>"
2057   [(set (match_operand:VF 0 "register_operand")
2058         (smaxmin:VF
2059           (match_operand:VF 1 "<round_saeonly_nimm_predicate>")
2060           (match_operand:VF 2 "<round_saeonly_nimm_predicate>")))]
2061   "TARGET_SSE && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
2063   if (!flag_finite_math_only || flag_signed_zeros)
2064     {
2065       operands[1] = force_reg (<MODE>mode, operands[1]);
2066       emit_insn (gen_ieee_<maxmin_float><mode>3<mask_name><round_saeonly_name>
2067                  (operands[0], operands[1], operands[2]
2068                   <mask_operand_arg34>
2069                   <round_saeonly_mask_arg3>));
2070       DONE;
2071     }
2072   else
2073     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
2076 ;; These versions of the min/max patterns are intentionally ignorant of
2077 ;; their behavior wrt -0.0 and NaN (via the commutative operand mark).
2078 ;; Since both the tree-level MAX_EXPR and the rtl-level SMAX operator
2079 ;; are undefined in this condition, we're certain this is correct.
2081 (define_insn "*<code><mode>3<mask_name><round_saeonly_name>"
2082   [(set (match_operand:VF 0 "register_operand" "=x,v")
2083         (smaxmin:VF
2084           (match_operand:VF 1 "<round_saeonly_nimm_predicate>" "%0,v")
2085           (match_operand:VF 2 "<round_saeonly_nimm_predicate>" "xBm,<round_saeonly_constraint>")))]
2086   "TARGET_SSE
2087    && !(MEM_P (operands[1]) && MEM_P (operands[2]))
2088    && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
2089   "@
2090    <maxmin_float><ssemodesuffix>\t{%2, %0|%0, %2}
2091    v<maxmin_float><ssemodesuffix>\t{<round_saeonly_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_saeonly_mask_op3>}"
2092   [(set_attr "isa" "noavx,avx")
2093    (set_attr "type" "sseadd")
2094    (set_attr "btver2_sse_attr" "maxmin")
2095    (set_attr "prefix" "<mask_prefix3>")
2096    (set_attr "mode" "<MODE>")])
2098 ;; These versions of the min/max patterns implement exactly the operations
2099 ;;   min = (op1 < op2 ? op1 : op2)
2100 ;;   max = (!(op1 < op2) ? op1 : op2)
2101 ;; Their operands are not commutative, and thus they may be used in the
2102 ;; presence of -0.0 and NaN.
2104 (define_insn "ieee_<ieee_maxmin><mode>3<mask_name><round_saeonly_name>"
2105   [(set (match_operand:VF 0 "register_operand" "=x,v")
2106         (unspec:VF
2107           [(match_operand:VF 1 "register_operand" "0,v")
2108            (match_operand:VF 2 "<round_saeonly_nimm_predicate>" "xBm,<round_saeonly_constraint>")]
2109           IEEE_MAXMIN))]
2110   "TARGET_SSE
2111    && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
2112   "@
2113    <ieee_maxmin><ssemodesuffix>\t{%2, %0|%0, %2}
2114    v<ieee_maxmin><ssemodesuffix>\t{<round_saeonly_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_saeonly_mask_op3>}"
2115   [(set_attr "isa" "noavx,avx")
2116    (set_attr "type" "sseadd")
2117    (set_attr "btver2_sse_attr" "maxmin")
2118    (set_attr "prefix" "<mask_prefix3>")
2119    (set_attr "mode" "<MODE>")])
2121 (define_insn "<sse>_vm<code><mode>3<mask_scalar_name><round_saeonly_scalar_name>"
2122   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
2123         (vec_merge:VF_128
2124           (smaxmin:VF_128
2125             (match_operand:VF_128 1 "register_operand" "0,v")
2126             (match_operand:VF_128 2 "vector_operand" "xBm,<round_saeonly_scalar_constraint>"))
2127          (match_dup 1)
2128          (const_int 1)))]
2129   "TARGET_SSE"
2130   "@
2131    <maxmin_float><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
2132    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>}"
2133   [(set_attr "isa" "noavx,avx")
2134    (set_attr "type" "sse")
2135    (set_attr "btver2_sse_attr" "maxmin")
2136    (set_attr "prefix" "<round_saeonly_scalar_prefix>")
2137    (set_attr "mode" "<ssescalarmode>")])
2139 (define_insn "avx_addsubv4df3"
2140   [(set (match_operand:V4DF 0 "register_operand" "=x")
2141         (vec_merge:V4DF
2142           (minus:V4DF
2143             (match_operand:V4DF 1 "register_operand" "x")
2144             (match_operand:V4DF 2 "nonimmediate_operand" "xm"))
2145           (plus:V4DF (match_dup 1) (match_dup 2))
2146           (const_int 5)))]
2147   "TARGET_AVX"
2148   "vaddsubpd\t{%2, %1, %0|%0, %1, %2}"
2149   [(set_attr "type" "sseadd")
2150    (set_attr "prefix" "vex")
2151    (set_attr "mode" "V4DF")])
2153 (define_insn "sse3_addsubv2df3"
2154   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
2155         (vec_merge:V2DF
2156           (minus:V2DF
2157             (match_operand:V2DF 1 "register_operand" "0,x")
2158             (match_operand:V2DF 2 "vector_operand" "xBm,xm"))
2159           (plus:V2DF (match_dup 1) (match_dup 2))
2160           (const_int 1)))]
2161   "TARGET_SSE3"
2162   "@
2163    addsubpd\t{%2, %0|%0, %2}
2164    vaddsubpd\t{%2, %1, %0|%0, %1, %2}"
2165   [(set_attr "isa" "noavx,avx")
2166    (set_attr "type" "sseadd")
2167    (set_attr "atom_unit" "complex")
2168    (set_attr "prefix" "orig,vex")
2169    (set_attr "mode" "V2DF")])
2171 (define_insn "avx_addsubv8sf3"
2172   [(set (match_operand:V8SF 0 "register_operand" "=x")
2173         (vec_merge:V8SF
2174           (minus:V8SF
2175             (match_operand:V8SF 1 "register_operand" "x")
2176             (match_operand:V8SF 2 "nonimmediate_operand" "xm"))
2177           (plus:V8SF (match_dup 1) (match_dup 2))
2178           (const_int 85)))]
2179   "TARGET_AVX"
2180   "vaddsubps\t{%2, %1, %0|%0, %1, %2}"
2181   [(set_attr "type" "sseadd")
2182    (set_attr "prefix" "vex")
2183    (set_attr "mode" "V8SF")])
2185 (define_insn "sse3_addsubv4sf3"
2186   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
2187         (vec_merge:V4SF
2188           (minus:V4SF
2189             (match_operand:V4SF 1 "register_operand" "0,x")
2190             (match_operand:V4SF 2 "vector_operand" "xBm,xm"))
2191           (plus:V4SF (match_dup 1) (match_dup 2))
2192           (const_int 5)))]
2193   "TARGET_SSE3"
2194   "@
2195    addsubps\t{%2, %0|%0, %2}
2196    vaddsubps\t{%2, %1, %0|%0, %1, %2}"
2197   [(set_attr "isa" "noavx,avx")
2198    (set_attr "type" "sseadd")
2199    (set_attr "prefix" "orig,vex")
2200    (set_attr "prefix_rep" "1,*")
2201    (set_attr "mode" "V4SF")])
2203 (define_split
2204   [(set (match_operand:VF_128_256 0 "register_operand")
2205         (match_operator:VF_128_256 6 "addsub_vm_operator"
2206           [(minus:VF_128_256
2207              (match_operand:VF_128_256 1 "register_operand")
2208              (match_operand:VF_128_256 2 "vector_operand"))
2209            (plus:VF_128_256
2210              (match_operand:VF_128_256 3 "vector_operand")
2211              (match_operand:VF_128_256 4 "vector_operand"))
2212            (match_operand 5 "const_int_operand")]))]
2213   "TARGET_SSE3
2214    && can_create_pseudo_p ()
2215    && ((rtx_equal_p (operands[1], operands[3])
2216         && rtx_equal_p (operands[2], operands[4]))
2217        || (rtx_equal_p (operands[1], operands[4])
2218            && rtx_equal_p (operands[2], operands[3])))"
2219   [(set (match_dup 0)
2220         (vec_merge:VF_128_256
2221           (minus:VF_128_256 (match_dup 1) (match_dup 2))
2222           (plus:VF_128_256 (match_dup 1) (match_dup 2))
2223           (match_dup 5)))])
2225 (define_split
2226   [(set (match_operand:VF_128_256 0 "register_operand")
2227         (match_operator:VF_128_256 6 "addsub_vm_operator"
2228           [(plus:VF_128_256
2229              (match_operand:VF_128_256 1 "vector_operand")
2230              (match_operand:VF_128_256 2 "vector_operand"))
2231            (minus:VF_128_256
2232              (match_operand:VF_128_256 3 "register_operand")
2233              (match_operand:VF_128_256 4 "vector_operand"))
2234            (match_operand 5 "const_int_operand")]))]
2235   "TARGET_SSE3
2236    && can_create_pseudo_p ()
2237    && ((rtx_equal_p (operands[1], operands[3])
2238         && rtx_equal_p (operands[2], operands[4]))
2239        || (rtx_equal_p (operands[1], operands[4])
2240            && rtx_equal_p (operands[2], operands[3])))"
2241   [(set (match_dup 0)
2242         (vec_merge:VF_128_256
2243           (minus:VF_128_256 (match_dup 3) (match_dup 4))
2244           (plus:VF_128_256 (match_dup 3) (match_dup 4))
2245           (match_dup 5)))]
2247   /* Negate mask bits to compensate for swapped PLUS and MINUS RTXes.  */
2248   operands[5]
2249     = GEN_INT (~INTVAL (operands[5])
2250                & ((HOST_WIDE_INT_1U << GET_MODE_NUNITS (<MODE>mode)) - 1));
2253 (define_split
2254   [(set (match_operand:VF_128_256 0 "register_operand")
2255         (match_operator:VF_128_256 7 "addsub_vs_operator"
2256           [(vec_concat:<ssedoublemode>
2257              (minus:VF_128_256
2258                (match_operand:VF_128_256 1 "register_operand")
2259                (match_operand:VF_128_256 2 "vector_operand"))
2260              (plus:VF_128_256
2261                (match_operand:VF_128_256 3 "vector_operand")
2262                (match_operand:VF_128_256 4 "vector_operand")))
2263            (match_parallel 5 "addsub_vs_parallel"
2264              [(match_operand 6 "const_int_operand")])]))]
2265   "TARGET_SSE3
2266    && can_create_pseudo_p ()
2267    && ((rtx_equal_p (operands[1], operands[3])
2268         && rtx_equal_p (operands[2], operands[4]))
2269        || (rtx_equal_p (operands[1], operands[4])
2270            && rtx_equal_p (operands[2], operands[3])))"
2271   [(set (match_dup 0)
2272         (vec_merge:VF_128_256
2273           (minus:VF_128_256 (match_dup 1) (match_dup 2))
2274           (plus:VF_128_256 (match_dup 1) (match_dup 2))
2275           (match_dup 5)))]
2277   int i, nelt = XVECLEN (operands[5], 0);
2278   HOST_WIDE_INT ival = 0;
2280   for (i = 0; i < nelt; i++)
2281     if (INTVAL (XVECEXP (operands[5], 0, i)) < GET_MODE_NUNITS (<MODE>mode))
2282       ival |= HOST_WIDE_INT_1 << i;
2284   operands[5] = GEN_INT (ival);
2287 (define_split
2288   [(set (match_operand:VF_128_256 0 "register_operand")
2289         (match_operator:VF_128_256 7 "addsub_vs_operator"
2290           [(vec_concat:<ssedoublemode>
2291              (plus:VF_128_256
2292                (match_operand:VF_128_256 1 "vector_operand")
2293                (match_operand:VF_128_256 2 "vector_operand"))
2294              (minus:VF_128_256
2295                (match_operand:VF_128_256 3 "register_operand")
2296                (match_operand:VF_128_256 4 "vector_operand")))
2297            (match_parallel 5 "addsub_vs_parallel"
2298              [(match_operand 6 "const_int_operand")])]))]
2299   "TARGET_SSE3
2300    && can_create_pseudo_p ()
2301    && ((rtx_equal_p (operands[1], operands[3])
2302         && rtx_equal_p (operands[2], operands[4]))
2303        || (rtx_equal_p (operands[1], operands[4])
2304            && rtx_equal_p (operands[2], operands[3])))"
2305   [(set (match_dup 0)
2306         (vec_merge:VF_128_256
2307           (minus:VF_128_256 (match_dup 3) (match_dup 4))
2308           (plus:VF_128_256 (match_dup 3) (match_dup 4))
2309           (match_dup 5)))]
2311   int i, nelt = XVECLEN (operands[5], 0);
2312   HOST_WIDE_INT ival = 0;
2314   for (i = 0; i < nelt; i++)
2315     if (INTVAL (XVECEXP (operands[5], 0, i)) >= GET_MODE_NUNITS (<MODE>mode))
2316       ival |= HOST_WIDE_INT_1 << i;
2318   operands[5] = GEN_INT (ival);
2321 (define_insn "avx_h<plusminus_insn>v4df3"
2322   [(set (match_operand:V4DF 0 "register_operand" "=x")
2323         (vec_concat:V4DF
2324           (vec_concat:V2DF
2325             (plusminus:DF
2326               (vec_select:DF
2327                 (match_operand:V4DF 1 "register_operand" "x")
2328                 (parallel [(const_int 0)]))
2329               (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
2330             (plusminus:DF
2331               (vec_select:DF
2332                 (match_operand:V4DF 2 "nonimmediate_operand" "xm")
2333                 (parallel [(const_int 0)]))
2334               (vec_select:DF (match_dup 2) (parallel [(const_int 1)]))))
2335           (vec_concat:V2DF
2336             (plusminus:DF
2337               (vec_select:DF (match_dup 1) (parallel [(const_int 2)]))
2338               (vec_select:DF (match_dup 1) (parallel [(const_int 3)])))
2339             (plusminus:DF
2340               (vec_select:DF (match_dup 2) (parallel [(const_int 2)]))
2341               (vec_select:DF (match_dup 2) (parallel [(const_int 3)]))))))]
2342   "TARGET_AVX"
2343   "vh<plusminus_mnemonic>pd\t{%2, %1, %0|%0, %1, %2}"
2344   [(set_attr "type" "sseadd")
2345    (set_attr "prefix" "vex")
2346    (set_attr "mode" "V4DF")])
2348 (define_expand "sse3_haddv2df3"
2349   [(set (match_operand:V2DF 0 "register_operand")
2350         (vec_concat:V2DF
2351           (plus:DF
2352             (vec_select:DF
2353               (match_operand:V2DF 1 "register_operand")
2354               (parallel [(const_int 0)]))
2355             (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
2356           (plus:DF
2357             (vec_select:DF
2358               (match_operand:V2DF 2 "vector_operand")
2359               (parallel [(const_int 0)]))
2360             (vec_select:DF (match_dup 2) (parallel [(const_int 1)])))))]
2361   "TARGET_SSE3")
2363 (define_insn "*sse3_haddv2df3"
2364   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
2365         (vec_concat:V2DF
2366           (plus:DF
2367             (vec_select:DF
2368               (match_operand:V2DF 1 "register_operand" "0,x")
2369               (parallel [(match_operand:SI 3 "const_0_to_1_operand")]))
2370             (vec_select:DF
2371               (match_dup 1)
2372               (parallel [(match_operand:SI 4 "const_0_to_1_operand")])))
2373           (plus:DF
2374             (vec_select:DF
2375               (match_operand:V2DF 2 "vector_operand" "xBm,xm")
2376               (parallel [(match_operand:SI 5 "const_0_to_1_operand")]))
2377             (vec_select:DF
2378               (match_dup 2)
2379               (parallel [(match_operand:SI 6 "const_0_to_1_operand")])))))]
2380   "TARGET_SSE3
2381    && INTVAL (operands[3]) != INTVAL (operands[4])
2382    && INTVAL (operands[5]) != INTVAL (operands[6])"
2383   "@
2384    haddpd\t{%2, %0|%0, %2}
2385    vhaddpd\t{%2, %1, %0|%0, %1, %2}"
2386   [(set_attr "isa" "noavx,avx")
2387    (set_attr "type" "sseadd")
2388    (set_attr "prefix" "orig,vex")
2389    (set_attr "mode" "V2DF")])
2391 (define_insn "sse3_hsubv2df3"
2392   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
2393         (vec_concat:V2DF
2394           (minus:DF
2395             (vec_select:DF
2396               (match_operand:V2DF 1 "register_operand" "0,x")
2397               (parallel [(const_int 0)]))
2398             (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
2399           (minus:DF
2400             (vec_select:DF
2401               (match_operand:V2DF 2 "vector_operand" "xBm,xm")
2402               (parallel [(const_int 0)]))
2403             (vec_select:DF (match_dup 2) (parallel [(const_int 1)])))))]
2404   "TARGET_SSE3"
2405   "@
2406    hsubpd\t{%2, %0|%0, %2}
2407    vhsubpd\t{%2, %1, %0|%0, %1, %2}"
2408   [(set_attr "isa" "noavx,avx")
2409    (set_attr "type" "sseadd")
2410    (set_attr "prefix" "orig,vex")
2411    (set_attr "mode" "V2DF")])
2413 (define_insn "*sse3_haddv2df3_low"
2414   [(set (match_operand:DF 0 "register_operand" "=x,x")
2415         (plus:DF
2416           (vec_select:DF
2417             (match_operand:V2DF 1 "register_operand" "0,x")
2418             (parallel [(match_operand:SI 2 "const_0_to_1_operand")]))
2419           (vec_select:DF
2420             (match_dup 1)
2421             (parallel [(match_operand:SI 3 "const_0_to_1_operand")]))))]
2422   "TARGET_SSE3
2423    && INTVAL (operands[2]) != INTVAL (operands[3])"
2424   "@
2425    haddpd\t{%0, %0|%0, %0}
2426    vhaddpd\t{%1, %1, %0|%0, %1, %1}"
2427   [(set_attr "isa" "noavx,avx")
2428    (set_attr "type" "sseadd1")
2429    (set_attr "prefix" "orig,vex")
2430    (set_attr "mode" "V2DF")])
2432 (define_insn "*sse3_hsubv2df3_low"
2433   [(set (match_operand:DF 0 "register_operand" "=x,x")
2434         (minus:DF
2435           (vec_select:DF
2436             (match_operand:V2DF 1 "register_operand" "0,x")
2437             (parallel [(const_int 0)]))
2438           (vec_select:DF
2439             (match_dup 1)
2440             (parallel [(const_int 1)]))))]
2441   "TARGET_SSE3"
2442   "@
2443    hsubpd\t{%0, %0|%0, %0}
2444    vhsubpd\t{%1, %1, %0|%0, %1, %1}"
2445   [(set_attr "isa" "noavx,avx")
2446    (set_attr "type" "sseadd1")
2447    (set_attr "prefix" "orig,vex")
2448    (set_attr "mode" "V2DF")])
2450 (define_insn "avx_h<plusminus_insn>v8sf3"
2451   [(set (match_operand:V8SF 0 "register_operand" "=x")
2452         (vec_concat:V8SF
2453           (vec_concat:V4SF
2454             (vec_concat:V2SF
2455               (plusminus:SF
2456                 (vec_select:SF
2457                   (match_operand:V8SF 1 "register_operand" "x")
2458                   (parallel [(const_int 0)]))
2459                 (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
2460               (plusminus:SF
2461                 (vec_select:SF (match_dup 1) (parallel [(const_int 2)]))
2462                 (vec_select:SF (match_dup 1) (parallel [(const_int 3)]))))
2463             (vec_concat:V2SF
2464               (plusminus:SF
2465                 (vec_select:SF
2466                   (match_operand:V8SF 2 "nonimmediate_operand" "xm")
2467                   (parallel [(const_int 0)]))
2468                 (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))
2469               (plusminus:SF
2470                 (vec_select:SF (match_dup 2) (parallel [(const_int 2)]))
2471                 (vec_select:SF (match_dup 2) (parallel [(const_int 3)])))))
2472           (vec_concat:V4SF
2473             (vec_concat:V2SF
2474               (plusminus:SF
2475                 (vec_select:SF (match_dup 1) (parallel [(const_int 4)]))
2476                 (vec_select:SF (match_dup 1) (parallel [(const_int 5)])))
2477               (plusminus:SF
2478                 (vec_select:SF (match_dup 1) (parallel [(const_int 6)]))
2479                 (vec_select:SF (match_dup 1) (parallel [(const_int 7)]))))
2480             (vec_concat:V2SF
2481               (plusminus:SF
2482                 (vec_select:SF (match_dup 2) (parallel [(const_int 4)]))
2483                 (vec_select:SF (match_dup 2) (parallel [(const_int 5)])))
2484               (plusminus:SF
2485                 (vec_select:SF (match_dup 2) (parallel [(const_int 6)]))
2486                 (vec_select:SF (match_dup 2) (parallel [(const_int 7)])))))))]
2487   "TARGET_AVX"
2488   "vh<plusminus_mnemonic>ps\t{%2, %1, %0|%0, %1, %2}"
2489   [(set_attr "type" "sseadd")
2490    (set_attr "prefix" "vex")
2491    (set_attr "mode" "V8SF")])
2493 (define_insn "sse3_h<plusminus_insn>v4sf3"
2494   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
2495         (vec_concat:V4SF
2496           (vec_concat:V2SF
2497             (plusminus:SF
2498               (vec_select:SF
2499                 (match_operand:V4SF 1 "register_operand" "0,x")
2500                 (parallel [(const_int 0)]))
2501               (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
2502             (plusminus:SF
2503               (vec_select:SF (match_dup 1) (parallel [(const_int 2)]))
2504               (vec_select:SF (match_dup 1) (parallel [(const_int 3)]))))
2505           (vec_concat:V2SF
2506             (plusminus:SF
2507               (vec_select:SF
2508                 (match_operand:V4SF 2 "vector_operand" "xBm,xm")
2509                 (parallel [(const_int 0)]))
2510               (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))
2511             (plusminus:SF
2512               (vec_select:SF (match_dup 2) (parallel [(const_int 2)]))
2513               (vec_select:SF (match_dup 2) (parallel [(const_int 3)]))))))]
2514   "TARGET_SSE3"
2515   "@
2516    h<plusminus_mnemonic>ps\t{%2, %0|%0, %2}
2517    vh<plusminus_mnemonic>ps\t{%2, %1, %0|%0, %1, %2}"
2518   [(set_attr "isa" "noavx,avx")
2519    (set_attr "type" "sseadd")
2520    (set_attr "atom_unit" "complex")
2521    (set_attr "prefix" "orig,vex")
2522    (set_attr "prefix_rep" "1,*")
2523    (set_attr "mode" "V4SF")])
2525 (define_mode_iterator REDUC_SSE_PLUS_MODE
2526  [(V2DF "TARGET_SSE") (V4SF "TARGET_SSE")])
2528 (define_expand "reduc_plus_scal_<mode>"
2529  [(plus:REDUC_SSE_PLUS_MODE
2530    (match_operand:<ssescalarmode> 0 "register_operand")
2531    (match_operand:REDUC_SSE_PLUS_MODE 1 "register_operand"))]
2532  ""
2534   rtx tmp = gen_reg_rtx (<MODE>mode);
2535   ix86_expand_reduc (gen_add<mode>3, tmp, operands[1]);
2536   emit_insn (gen_vec_extract<mode><ssescalarmodelower> (operands[0], tmp,
2537                                                         const0_rtx));
2538   DONE;
2541 (define_mode_iterator REDUC_PLUS_MODE
2542  [(V4DF "TARGET_AVX") (V8SF "TARGET_AVX")
2543   (V8DF "TARGET_AVX512F") (V16SF "TARGET_AVX512F")])
2545 (define_expand "reduc_plus_scal_<mode>"
2546  [(plus:REDUC_PLUS_MODE
2547    (match_operand:<ssescalarmode> 0 "register_operand")
2548    (match_operand:REDUC_PLUS_MODE 1 "register_operand"))]
2549  ""
2551   rtx tmp = gen_reg_rtx (<ssehalfvecmode>mode);
2552   emit_insn (gen_vec_extract_hi_<mode> (tmp, operands[1]));
2553   rtx tmp2 = gen_reg_rtx (<ssehalfvecmode>mode);
2554   emit_insn (gen_add<ssehalfvecmodelower>3
2555     (tmp2, tmp, gen_lowpart (<ssehalfvecmode>mode, operands[1])));
2556   emit_insn (gen_reduc_plus_scal_<ssehalfvecmodelower> (operands[0], tmp2));
2557   DONE;
2560 ;; Modes handled by reduc_sm{in,ax}* patterns.
2561 (define_mode_iterator REDUC_SSE_SMINMAX_MODE
2562   [(V4SF "TARGET_SSE") (V2DF "TARGET_SSE")
2563    (V2DI "TARGET_SSE") (V4SI "TARGET_SSE") (V8HI "TARGET_SSE")
2564    (V16QI "TARGET_SSE")])
2566 (define_expand "reduc_<code>_scal_<mode>"
2567   [(smaxmin:REDUC_SSE_SMINMAX_MODE
2568      (match_operand:<ssescalarmode> 0 "register_operand")
2569      (match_operand:REDUC_SSE_SMINMAX_MODE 1 "register_operand"))]
2570   ""
2572   rtx tmp = gen_reg_rtx (<MODE>mode);
2573   ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
2574   emit_insn (gen_vec_extract<mode><ssescalarmodelower> (operands[0], tmp,
2575                                                         const0_rtx));
2576   DONE;
2579 (define_mode_iterator REDUC_SMINMAX_MODE
2580   [(V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
2581    (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")
2582    (V8SF "TARGET_AVX") (V4DF "TARGET_AVX")
2583    (V64QI "TARGET_AVX512BW")
2584    (V32HI "TARGET_AVX512BW") (V16SI "TARGET_AVX512F")
2585    (V8DI "TARGET_AVX512F") (V16SF "TARGET_AVX512F")
2586    (V8DF "TARGET_AVX512F")])
2588 (define_expand "reduc_<code>_scal_<mode>"
2589   [(smaxmin:REDUC_SMINMAX_MODE
2590      (match_operand:<ssescalarmode> 0 "register_operand")
2591      (match_operand:REDUC_SMINMAX_MODE 1 "register_operand"))]
2592   ""
2594   rtx tmp = gen_reg_rtx (<ssehalfvecmode>mode);
2595   emit_insn (gen_vec_extract_hi_<mode> (tmp, operands[1]));
2596   rtx tmp2 = gen_reg_rtx (<ssehalfvecmode>mode);
2597   emit_insn (gen_<code><ssehalfvecmodelower>3
2598     (tmp2, tmp, gen_lowpart (<ssehalfvecmode>mode, operands[1])));
2599   emit_insn (gen_reduc_<code>_scal_<ssehalfvecmodelower> (operands[0], tmp2));
2600   DONE;
2603 (define_expand "reduc_<code>_scal_<mode>"
2604   [(umaxmin:VI_AVX512BW
2605      (match_operand:<ssescalarmode> 0 "register_operand")
2606      (match_operand:VI_AVX512BW 1 "register_operand"))]
2607   "TARGET_AVX512F"
2609   rtx tmp = gen_reg_rtx (<ssehalfvecmode>mode);
2610   emit_insn (gen_vec_extract_hi_<mode> (tmp, operands[1]));
2611   rtx tmp2 = gen_reg_rtx (<ssehalfvecmode>mode);
2612   emit_insn (gen_<code><ssehalfvecmodelower>3
2613     (tmp2, tmp, gen_lowpart (<ssehalfvecmode>mode, operands[1])));
2614   emit_insn (gen_reduc_<code>_scal_<ssehalfvecmodelower> (operands[0], tmp2));
2615   DONE;
2618 (define_expand "reduc_<code>_scal_<mode>"
2619   [(umaxmin:VI_256
2620      (match_operand:<ssescalarmode> 0 "register_operand")
2621      (match_operand:VI_256 1 "register_operand"))]
2622   "TARGET_AVX2"
2624   rtx tmp = gen_reg_rtx (<ssehalfvecmode>mode);
2625   emit_insn (gen_vec_extract_hi_<mode> (tmp, operands[1]));
2626   rtx tmp2 = gen_reg_rtx (<ssehalfvecmode>mode);
2627   emit_insn (gen_<code><ssehalfvecmodelower>3
2628     (tmp2, tmp, gen_lowpart (<ssehalfvecmode>mode, operands[1])));
2629   rtx tmp3 = gen_reg_rtx (<ssehalfvecmode>mode);
2630   ix86_expand_reduc (gen_<code><ssehalfvecmodelower>3, tmp3, tmp2);
2631   emit_insn (gen_vec_extract<ssehalfvecmodelower><ssescalarmodelower>
2632                 (operands[0], tmp3, const0_rtx));
2633   DONE;
2636 (define_expand "reduc_umin_scal_v8hi"
2637   [(umin:V8HI
2638      (match_operand:HI 0 "register_operand")
2639      (match_operand:V8HI 1 "register_operand"))]
2640   "TARGET_SSE4_1"
2642   rtx tmp = gen_reg_rtx (V8HImode);
2643   ix86_expand_reduc (gen_uminv8hi3, tmp, operands[1]);
2644   emit_insn (gen_vec_extractv8hihi (operands[0], tmp, const0_rtx));
2645   DONE;
2648 (define_insn "<mask_codefor>reducep<mode><mask_name>"
2649   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
2650         (unspec:VF_AVX512VL
2651           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")
2652            (match_operand:SI 2 "const_0_to_255_operand")]
2653           UNSPEC_REDUCE))]
2654   "TARGET_AVX512DQ"
2655   "vreduce<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
2656   [(set_attr "type" "sse")
2657    (set_attr "prefix" "evex")
2658    (set_attr "mode" "<MODE>")])
2660 (define_insn "reduces<mode><mask_scalar_name>"
2661   [(set (match_operand:VF_128 0 "register_operand" "=v")
2662         (vec_merge:VF_128
2663           (unspec:VF_128
2664             [(match_operand:VF_128 1 "register_operand" "v")
2665              (match_operand:VF_128 2 "nonimmediate_operand" "vm")
2666              (match_operand:SI 3 "const_0_to_255_operand")]
2667             UNSPEC_REDUCE)
2668           (match_dup 1)
2669           (const_int 1)))]
2670   "TARGET_AVX512DQ"
2671   "vreduce<ssescalarmodesuffix>\t{%3, %2, %1, %0<mask_scalar_operand4>|%0<mask_scalar_operand4>, %1, %<iptr>2, %3}"
2672   [(set_attr "type" "sse")
2673    (set_attr "prefix" "evex")
2674    (set_attr "mode" "<MODE>")])
2676 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2678 ;; Parallel floating point comparisons
2680 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2682 (define_insn "avx_cmp<mode>3"
2683   [(set (match_operand:VF_128_256 0 "register_operand" "=x")
2684         (unspec:VF_128_256
2685           [(match_operand:VF_128_256 1 "register_operand" "x")
2686            (match_operand:VF_128_256 2 "nonimmediate_operand" "xm")
2687            (match_operand:SI 3 "const_0_to_31_operand" "n")]
2688           UNSPEC_PCMP))]
2689   "TARGET_AVX"
2690   "vcmp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
2691   [(set_attr "type" "ssecmp")
2692    (set_attr "length_immediate" "1")
2693    (set_attr "prefix" "vex")
2694    (set_attr "mode" "<MODE>")])
2696 (define_insn "avx_vmcmp<mode>3"
2697   [(set (match_operand:VF_128 0 "register_operand" "=x")
2698         (vec_merge:VF_128
2699           (unspec:VF_128
2700             [(match_operand:VF_128 1 "register_operand" "x")
2701              (match_operand:VF_128 2 "nonimmediate_operand" "xm")
2702              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2703             UNSPEC_PCMP)
2704          (match_dup 1)
2705          (const_int 1)))]
2706   "TARGET_AVX"
2707   "vcmp<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %3}"
2708   [(set_attr "type" "ssecmp")
2709    (set_attr "length_immediate" "1")
2710    (set_attr "prefix" "vex")
2711    (set_attr "mode" "<ssescalarmode>")])
2713 (define_insn "*<sse>_maskcmp<mode>3_comm"
2714   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
2715         (match_operator:VF_128_256 3 "sse_comparison_operator"
2716           [(match_operand:VF_128_256 1 "register_operand" "%0,x")
2717            (match_operand:VF_128_256 2 "vector_operand" "xBm,xm")]))]
2718   "TARGET_SSE
2719    && GET_RTX_CLASS (GET_CODE (operands[3])) == RTX_COMM_COMPARE"
2720   "@
2721    cmp%D3<ssemodesuffix>\t{%2, %0|%0, %2}
2722    vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2723   [(set_attr "isa" "noavx,avx")
2724    (set_attr "type" "ssecmp")
2725    (set_attr "length_immediate" "1")
2726    (set_attr "prefix" "orig,vex")
2727    (set_attr "mode" "<MODE>")])
2729 (define_insn "<sse>_maskcmp<mode>3"
2730   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
2731         (match_operator:VF_128_256 3 "sse_comparison_operator"
2732           [(match_operand:VF_128_256 1 "register_operand" "0,x")
2733            (match_operand:VF_128_256 2 "vector_operand" "xBm,xm")]))]
2734   "TARGET_SSE"
2735   "@
2736    cmp%D3<ssemodesuffix>\t{%2, %0|%0, %2}
2737    vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2738   [(set_attr "isa" "noavx,avx")
2739    (set_attr "type" "ssecmp")
2740    (set_attr "length_immediate" "1")
2741    (set_attr "prefix" "orig,vex")
2742    (set_attr "mode" "<MODE>")])
2744 (define_insn "<sse>_vmmaskcmp<mode>3"
2745   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
2746         (vec_merge:VF_128
2747          (match_operator:VF_128 3 "sse_comparison_operator"
2748            [(match_operand:VF_128 1 "register_operand" "0,x")
2749             (match_operand:VF_128 2 "vector_operand" "xBm,xm")])
2750          (match_dup 1)
2751          (const_int 1)))]
2752   "TARGET_SSE"
2753   "@
2754    cmp%D3<ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
2755    vcmp%D3<ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %<iptr>2}"
2756   [(set_attr "isa" "noavx,avx")
2757    (set_attr "type" "ssecmp")
2758    (set_attr "length_immediate" "1,*")
2759    (set_attr "prefix" "orig,vex")
2760    (set_attr "mode" "<ssescalarmode>")])
2762 (define_mode_attr cmp_imm_predicate
2763   [(V16SF "const_0_to_31_operand")  (V8DF "const_0_to_31_operand")
2764    (V16SI "const_0_to_7_operand")   (V8DI "const_0_to_7_operand")
2765    (V8SF "const_0_to_31_operand")   (V4DF "const_0_to_31_operand")
2766    (V8SI "const_0_to_7_operand")    (V4DI "const_0_to_7_operand")
2767    (V4SF "const_0_to_31_operand")   (V2DF "const_0_to_31_operand")
2768    (V4SI "const_0_to_7_operand")    (V2DI "const_0_to_7_operand")
2769    (V32HI "const_0_to_7_operand")   (V64QI "const_0_to_7_operand")
2770    (V16HI "const_0_to_7_operand")   (V32QI "const_0_to_7_operand")
2771    (V8HI "const_0_to_7_operand")    (V16QI "const_0_to_7_operand")])
2773 (define_insn "<avx512>_cmp<mode>3<mask_scalar_merge_name><round_saeonly_name>"
2774   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2775         (unspec:<avx512fmaskmode>
2776           [(match_operand:V48_AVX512VL 1 "register_operand" "v")
2777            (match_operand:V48_AVX512VL 2 "nonimmediate_operand" "<round_saeonly_constraint>")
2778            (match_operand:SI 3 "<cmp_imm_predicate>" "n")]
2779           UNSPEC_PCMP))]
2780   "TARGET_AVX512F && <round_saeonly_mode512bit_condition>"
2781   "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}"
2782   [(set_attr "type" "ssecmp")
2783    (set_attr "length_immediate" "1")
2784    (set_attr "prefix" "evex")
2785    (set_attr "mode" "<sseinsnmode>")])
2787 (define_insn "<avx512>_cmp<mode>3<mask_scalar_merge_name>"
2788   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2789         (unspec:<avx512fmaskmode>
2790           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
2791            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
2792            (match_operand:SI 3 "<cmp_imm_predicate>" "n")]
2793           UNSPEC_PCMP))]
2794   "TARGET_AVX512BW"
2795   "vpcmp<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2796   [(set_attr "type" "ssecmp")
2797    (set_attr "length_immediate" "1")
2798    (set_attr "prefix" "evex")
2799    (set_attr "mode" "<sseinsnmode>")])
2801 (define_insn "<avx512>_ucmp<mode>3<mask_scalar_merge_name>"
2802   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2803         (unspec:<avx512fmaskmode>
2804           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
2805            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
2806            (match_operand:SI 3 "const_0_to_7_operand" "n")]
2807           UNSPEC_UNSIGNED_PCMP))]
2808   "TARGET_AVX512BW"
2809   "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2810   [(set_attr "type" "ssecmp")
2811    (set_attr "length_immediate" "1")
2812    (set_attr "prefix" "evex")
2813    (set_attr "mode" "<sseinsnmode>")])
2815 (define_insn "<avx512>_ucmp<mode>3<mask_scalar_merge_name>"
2816   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2817         (unspec:<avx512fmaskmode>
2818           [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
2819            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")
2820            (match_operand:SI 3 "const_0_to_7_operand" "n")]
2821           UNSPEC_UNSIGNED_PCMP))]
2822   "TARGET_AVX512F"
2823   "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2824   [(set_attr "type" "ssecmp")
2825    (set_attr "length_immediate" "1")
2826    (set_attr "prefix" "evex")
2827    (set_attr "mode" "<sseinsnmode>")])
2829 (define_insn "avx512f_vmcmp<mode>3<round_saeonly_name>"
2830   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2831         (and:<avx512fmaskmode>
2832           (unspec:<avx512fmaskmode>
2833             [(match_operand:VF_128 1 "register_operand" "v")
2834              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
2835              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2836             UNSPEC_PCMP)
2837           (const_int 1)))]
2838   "TARGET_AVX512F"
2839   "vcmp<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %<iptr>2<round_saeonly_op4>, %3}"
2840   [(set_attr "type" "ssecmp")
2841    (set_attr "length_immediate" "1")
2842    (set_attr "prefix" "evex")
2843    (set_attr "mode" "<ssescalarmode>")])
2845 (define_insn "avx512f_vmcmp<mode>3_mask<round_saeonly_name>"
2846   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2847         (and:<avx512fmaskmode>
2848           (unspec:<avx512fmaskmode>
2849             [(match_operand:VF_128 1 "register_operand" "v")
2850              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
2851              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2852             UNSPEC_PCMP)
2853           (and:<avx512fmaskmode>
2854             (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")
2855             (const_int 1))))]
2856   "TARGET_AVX512F"
2857   "vcmp<ssescalarmodesuffix>\t{%3, <round_saeonly_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %<iptr>2<round_saeonly_op5>, %3}"
2858   [(set_attr "type" "ssecmp")
2859    (set_attr "length_immediate" "1")
2860    (set_attr "prefix" "evex")
2861    (set_attr "mode" "<ssescalarmode>")])
2863 (define_insn "avx512f_maskcmp<mode>3"
2864   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2865         (match_operator:<avx512fmaskmode> 3 "sse_comparison_operator"
2866           [(match_operand:VF 1 "register_operand" "v")
2867            (match_operand:VF 2 "nonimmediate_operand" "vm")]))]
2868   "TARGET_AVX512F"
2869   "vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2870   [(set_attr "type" "ssecmp")
2871    (set_attr "length_immediate" "1")
2872    (set_attr "prefix" "evex")
2873    (set_attr "mode" "<sseinsnmode>")])
2875 (define_insn "<sse>_<unord>comi<round_saeonly_name>"
2876   [(set (reg:CCFP FLAGS_REG)
2877         (compare:CCFP
2878           (vec_select:MODEF
2879             (match_operand:<ssevecmode> 0 "register_operand" "v")
2880             (parallel [(const_int 0)]))
2881           (vec_select:MODEF
2882             (match_operand:<ssevecmode> 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
2883             (parallel [(const_int 0)]))))]
2884   "SSE_FLOAT_MODE_P (<MODE>mode)"
2885   "%v<unord>comi<ssemodesuffix>\t{<round_saeonly_op2>%1, %0|%0, %<iptr>1<round_saeonly_op2>}"
2886   [(set_attr "type" "ssecomi")
2887    (set_attr "prefix" "maybe_vex")
2888    (set_attr "prefix_rep" "0")
2889    (set (attr "prefix_data16")
2890         (if_then_else (eq_attr "mode" "DF")
2891                       (const_string "1")
2892                       (const_string "0")))
2893    (set_attr "mode" "<MODE>")])
2895 (define_expand "vec_cmp<mode><avx512fmaskmodelower>"
2896   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2897         (match_operator:<avx512fmaskmode> 1 ""
2898           [(match_operand:V48_AVX512VL 2 "register_operand")
2899            (match_operand:V48_AVX512VL 3 "nonimmediate_operand")]))]
2900   "TARGET_AVX512F"
2902   bool ok = ix86_expand_mask_vec_cmp (operands);
2903   gcc_assert (ok);
2904   DONE;
2907 (define_expand "vec_cmp<mode><avx512fmaskmodelower>"
2908   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2909         (match_operator:<avx512fmaskmode> 1 ""
2910           [(match_operand:VI12_AVX512VL 2 "register_operand")
2911            (match_operand:VI12_AVX512VL 3 "nonimmediate_operand")]))]
2912   "TARGET_AVX512BW"
2914   bool ok = ix86_expand_mask_vec_cmp (operands);
2915   gcc_assert (ok);
2916   DONE;
2919 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2920   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2921         (match_operator:<sseintvecmode> 1 ""
2922           [(match_operand:VI_256 2 "register_operand")
2923            (match_operand:VI_256 3 "nonimmediate_operand")]))]
2924   "TARGET_AVX2"
2926   bool ok = ix86_expand_int_vec_cmp (operands);
2927   gcc_assert (ok);
2928   DONE;
2931 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2932   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2933         (match_operator:<sseintvecmode> 1 ""
2934           [(match_operand:VI124_128 2 "register_operand")
2935            (match_operand:VI124_128 3 "vector_operand")]))]
2936   "TARGET_SSE2"
2938   bool ok = ix86_expand_int_vec_cmp (operands);
2939   gcc_assert (ok);
2940   DONE;
2943 (define_expand "vec_cmpv2div2di"
2944   [(set (match_operand:V2DI 0 "register_operand")
2945         (match_operator:V2DI 1 ""
2946           [(match_operand:V2DI 2 "register_operand")
2947            (match_operand:V2DI 3 "vector_operand")]))]
2948   "TARGET_SSE4_2"
2950   bool ok = ix86_expand_int_vec_cmp (operands);
2951   gcc_assert (ok);
2952   DONE;
2955 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2956   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2957         (match_operator:<sseintvecmode> 1 ""
2958           [(match_operand:VF_256 2 "register_operand")
2959            (match_operand:VF_256 3 "nonimmediate_operand")]))]
2960   "TARGET_AVX"
2962   bool ok = ix86_expand_fp_vec_cmp (operands);
2963   gcc_assert (ok);
2964   DONE;
2967 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2968   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2969         (match_operator:<sseintvecmode> 1 ""
2970           [(match_operand:VF_128 2 "register_operand")
2971            (match_operand:VF_128 3 "vector_operand")]))]
2972   "TARGET_SSE"
2974   bool ok = ix86_expand_fp_vec_cmp (operands);
2975   gcc_assert (ok);
2976   DONE;
2979 (define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
2980   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2981         (match_operator:<avx512fmaskmode> 1 ""
2982           [(match_operand:VI48_AVX512VL 2 "register_operand")
2983            (match_operand:VI48_AVX512VL 3 "nonimmediate_operand")]))]
2984   "TARGET_AVX512F"
2986   bool ok = ix86_expand_mask_vec_cmp (operands);
2987   gcc_assert (ok);
2988   DONE;
2991 (define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
2992   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2993         (match_operator:<avx512fmaskmode> 1 ""
2994           [(match_operand:VI12_AVX512VL 2 "register_operand")
2995            (match_operand:VI12_AVX512VL 3 "nonimmediate_operand")]))]
2996   "TARGET_AVX512BW"
2998   bool ok = ix86_expand_mask_vec_cmp (operands);
2999   gcc_assert (ok);
3000   DONE;
3003 (define_expand "vec_cmpu<mode><sseintvecmodelower>"
3004   [(set (match_operand:<sseintvecmode> 0 "register_operand")
3005         (match_operator:<sseintvecmode> 1 ""
3006           [(match_operand:VI_256 2 "register_operand")
3007            (match_operand:VI_256 3 "nonimmediate_operand")]))]
3008   "TARGET_AVX2"
3010   bool ok = ix86_expand_int_vec_cmp (operands);
3011   gcc_assert (ok);
3012   DONE;
3015 (define_expand "vec_cmpu<mode><sseintvecmodelower>"
3016   [(set (match_operand:<sseintvecmode> 0 "register_operand")
3017         (match_operator:<sseintvecmode> 1 ""
3018           [(match_operand:VI124_128 2 "register_operand")
3019            (match_operand:VI124_128 3 "vector_operand")]))]
3020   "TARGET_SSE2"
3022   bool ok = ix86_expand_int_vec_cmp (operands);
3023   gcc_assert (ok);
3024   DONE;
3027 (define_expand "vec_cmpuv2div2di"
3028   [(set (match_operand:V2DI 0 "register_operand")
3029         (match_operator:V2DI 1 ""
3030           [(match_operand:V2DI 2 "register_operand")
3031            (match_operand:V2DI 3 "vector_operand")]))]
3032   "TARGET_SSE4_2"
3034   bool ok = ix86_expand_int_vec_cmp (operands);
3035   gcc_assert (ok);
3036   DONE;
3039 (define_expand "vec_cmpeqv2div2di"
3040   [(set (match_operand:V2DI 0 "register_operand")
3041         (match_operator:V2DI 1 ""
3042           [(match_operand:V2DI 2 "register_operand")
3043            (match_operand:V2DI 3 "vector_operand")]))]
3044   "TARGET_SSE4_1"
3046   bool ok = ix86_expand_int_vec_cmp (operands);
3047   gcc_assert (ok);
3048   DONE;
3051 (define_expand "vcond<V_512:mode><VF_512:mode>"
3052   [(set (match_operand:V_512 0 "register_operand")
3053         (if_then_else:V_512
3054           (match_operator 3 ""
3055             [(match_operand:VF_512 4 "nonimmediate_operand")
3056              (match_operand:VF_512 5 "nonimmediate_operand")])
3057           (match_operand:V_512 1 "general_operand")
3058           (match_operand:V_512 2 "general_operand")))]
3059   "TARGET_AVX512F
3060    && (GET_MODE_NUNITS (<V_512:MODE>mode)
3061        == GET_MODE_NUNITS (<VF_512:MODE>mode))"
3063   bool ok = ix86_expand_fp_vcond (operands);
3064   gcc_assert (ok);
3065   DONE;
3068 (define_expand "vcond<V_256:mode><VF_256:mode>"
3069   [(set (match_operand:V_256 0 "register_operand")
3070         (if_then_else:V_256
3071           (match_operator 3 ""
3072             [(match_operand:VF_256 4 "nonimmediate_operand")
3073              (match_operand:VF_256 5 "nonimmediate_operand")])
3074           (match_operand:V_256 1 "general_operand")
3075           (match_operand:V_256 2 "general_operand")))]
3076   "TARGET_AVX
3077    && (GET_MODE_NUNITS (<V_256:MODE>mode)
3078        == GET_MODE_NUNITS (<VF_256:MODE>mode))"
3080   bool ok = ix86_expand_fp_vcond (operands);
3081   gcc_assert (ok);
3082   DONE;
3085 (define_expand "vcond<V_128:mode><VF_128:mode>"
3086   [(set (match_operand:V_128 0 "register_operand")
3087         (if_then_else:V_128
3088           (match_operator 3 ""
3089             [(match_operand:VF_128 4 "vector_operand")
3090              (match_operand:VF_128 5 "vector_operand")])
3091           (match_operand:V_128 1 "general_operand")
3092           (match_operand:V_128 2 "general_operand")))]
3093   "TARGET_SSE
3094    && (GET_MODE_NUNITS (<V_128:MODE>mode)
3095        == GET_MODE_NUNITS (<VF_128:MODE>mode))"
3097   bool ok = ix86_expand_fp_vcond (operands);
3098   gcc_assert (ok);
3099   DONE;
3102 (define_expand "vcond_mask_<mode><avx512fmaskmodelower>"
3103   [(set (match_operand:V48_AVX512VL 0 "register_operand")
3104         (vec_merge:V48_AVX512VL
3105           (match_operand:V48_AVX512VL 1 "nonimmediate_operand")
3106           (match_operand:V48_AVX512VL 2 "nonimm_or_0_operand")
3107           (match_operand:<avx512fmaskmode> 3 "register_operand")))]
3108   "TARGET_AVX512F")
3110 (define_expand "vcond_mask_<mode><avx512fmaskmodelower>"
3111   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
3112         (vec_merge:VI12_AVX512VL
3113           (match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
3114           (match_operand:VI12_AVX512VL 2 "nonimm_or_0_operand")
3115           (match_operand:<avx512fmaskmode> 3 "register_operand")))]
3116   "TARGET_AVX512BW")
3118 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3119   [(set (match_operand:VI_256 0 "register_operand")
3120         (vec_merge:VI_256
3121           (match_operand:VI_256 1 "nonimmediate_operand")
3122           (match_operand:VI_256 2 "nonimm_or_0_operand")
3123           (match_operand:<sseintvecmode> 3 "register_operand")))]
3124   "TARGET_AVX2"
3126   ix86_expand_sse_movcc (operands[0], operands[3],
3127                          operands[1], operands[2]);
3128   DONE;
3131 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3132   [(set (match_operand:VI124_128 0 "register_operand")
3133         (vec_merge:VI124_128
3134           (match_operand:VI124_128 1 "vector_operand")
3135           (match_operand:VI124_128 2 "nonimm_or_0_operand")
3136           (match_operand:<sseintvecmode> 3 "register_operand")))]
3137   "TARGET_SSE2"
3139   ix86_expand_sse_movcc (operands[0], operands[3],
3140                          operands[1], operands[2]);
3141   DONE;
3144 (define_expand "vcond_mask_v2div2di"
3145   [(set (match_operand:V2DI 0 "register_operand")
3146         (vec_merge:V2DI
3147           (match_operand:V2DI 1 "vector_operand")
3148           (match_operand:V2DI 2 "nonimm_or_0_operand")
3149           (match_operand:V2DI 3 "register_operand")))]
3150   "TARGET_SSE4_2"
3152   ix86_expand_sse_movcc (operands[0], operands[3],
3153                          operands[1], operands[2]);
3154   DONE;
3157 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3158   [(set (match_operand:VF_256 0 "register_operand")
3159         (vec_merge:VF_256
3160           (match_operand:VF_256 1 "nonimmediate_operand")
3161           (match_operand:VF_256 2 "nonimm_or_0_operand")
3162           (match_operand:<sseintvecmode> 3 "register_operand")))]
3163   "TARGET_AVX"
3165   ix86_expand_sse_movcc (operands[0], operands[3],
3166                          operands[1], operands[2]);
3167   DONE;
3170 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3171   [(set (match_operand:VF_128 0 "register_operand")
3172         (vec_merge:VF_128
3173           (match_operand:VF_128 1 "vector_operand")
3174           (match_operand:VF_128 2 "nonimm_or_0_operand")
3175           (match_operand:<sseintvecmode> 3 "register_operand")))]
3176   "TARGET_SSE"
3178   ix86_expand_sse_movcc (operands[0], operands[3],
3179                          operands[1], operands[2]);
3180   DONE;
3183 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3185 ;; Parallel floating point logical operations
3187 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3189 (define_insn "<sse>_andnot<mode>3<mask_name>"
3190   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x,v,v")
3191         (and:VF_128_256
3192           (not:VF_128_256
3193             (match_operand:VF_128_256 1 "register_operand" "0,x,v,v"))
3194           (match_operand:VF_128_256 2 "vector_operand" "xBm,xm,vm,vm")))]
3195   "TARGET_SSE && <mask_avx512vl_condition>"
3197   static char buf[128];
3198   const char *ops;
3199   const char *suffix;
3201   switch (which_alternative)
3202     {
3203     case 0:
3204       ops = "andn%s\t{%%2, %%0|%%0, %%2}";
3205       break;
3206     case 1:
3207     case 2:
3208     case 3:
3209       ops = "vandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3210       break;
3211     default:
3212       gcc_unreachable ();
3213     }
3215   switch (get_attr_mode (insn))
3216     {
3217     case MODE_V8SF:
3218     case MODE_V4SF:
3219       suffix = "ps";
3220       break;
3221     case MODE_OI:
3222     case MODE_TI:
3223       /* There is no vandnp[sd] in avx512f.  Use vpandn[qd].  */
3224       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3225       ops = "vpandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3226       break;
3227     default:
3228       suffix = "<ssemodesuffix>";
3229     }
3231   snprintf (buf, sizeof (buf), ops, suffix);
3232   return buf;
3234   [(set_attr "isa" "noavx,avx,avx512dq,avx512f")
3235    (set_attr "type" "sselog")
3236    (set_attr "prefix" "orig,maybe_vex,evex,evex")
3237    (set (attr "mode")
3238         (cond [(and (match_test "<mask_applied>")
3239                     (and (eq_attr "alternative" "1")
3240                          (match_test "!TARGET_AVX512DQ")))
3241                  (const_string "<sseintvecmode2>")
3242                (eq_attr "alternative" "3")
3243                  (const_string "<sseintvecmode2>")
3244                (and (match_test "<MODE_SIZE> == 16")
3245                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3246                  (const_string "<ssePSmode>")
3247                (match_test "TARGET_AVX")
3248                  (const_string "<MODE>")
3249                (match_test "optimize_function_for_size_p (cfun)")
3250                  (const_string "V4SF")
3251                ]
3252                (const_string "<MODE>")))])
3255 (define_insn "<sse>_andnot<mode>3<mask_name>"
3256   [(set (match_operand:VF_512 0 "register_operand" "=v")
3257         (and:VF_512
3258           (not:VF_512
3259             (match_operand:VF_512 1 "register_operand" "v"))
3260           (match_operand:VF_512 2 "nonimmediate_operand" "vm")))]
3261   "TARGET_AVX512F"
3263   static char buf[128];
3264   const char *ops;
3265   const char *suffix;
3267   suffix = "<ssemodesuffix>";
3268   ops = "";
3270   /* There is no vandnp[sd] in avx512f.  Use vpandn[qd].  */
3271   if (!TARGET_AVX512DQ)
3272     {
3273       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3274       ops = "p";
3275     }
3277   snprintf (buf, sizeof (buf),
3278             "v%sandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}",
3279             ops, suffix);
3280   return buf;
3282   [(set_attr "type" "sselog")
3283    (set_attr "prefix" "evex")
3284    (set (attr "mode")
3285         (if_then_else (match_test "TARGET_AVX512DQ")
3286                       (const_string "<sseinsnmode>")
3287                       (const_string "XI")))])
3289 (define_expand "<code><mode>3<mask_name>"
3290   [(set (match_operand:VF_128_256 0 "register_operand")
3291        (any_logic:VF_128_256
3292          (match_operand:VF_128_256 1 "vector_operand")
3293          (match_operand:VF_128_256 2 "vector_operand")))]
3294   "TARGET_SSE && <mask_avx512vl_condition>"
3295   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
3297 (define_expand "<code><mode>3<mask_name>"
3298   [(set (match_operand:VF_512 0 "register_operand")
3299        (any_logic:VF_512
3300          (match_operand:VF_512 1 "nonimmediate_operand")
3301          (match_operand:VF_512 2 "nonimmediate_operand")))]
3302   "TARGET_AVX512F"
3303   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
3305 (define_insn "*<code><mode>3<mask_name>"
3306   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x,v,v")
3307         (any_logic:VF_128_256
3308           (match_operand:VF_128_256 1 "vector_operand" "%0,x,v,v")
3309           (match_operand:VF_128_256 2 "vector_operand" "xBm,xm,vm,vm")))]
3310   "TARGET_SSE && <mask_avx512vl_condition>
3311    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
3313   static char buf[128];
3314   const char *ops;
3315   const char *suffix;
3317   switch (which_alternative)
3318     {
3319     case 0:
3320       ops = "<logic>%s\t{%%2, %%0|%%0, %%2}";
3321       break;
3322     case 1:
3323     case 2:
3324     case 3:
3325       ops = "v<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3326       break;
3327     default:
3328       gcc_unreachable ();
3329     }
3331   switch (get_attr_mode (insn))
3332     {
3333     case MODE_V8SF:
3334     case MODE_V4SF:
3335       suffix = "ps";
3336       break;
3337     case MODE_OI:
3338     case MODE_TI:
3339       /* There is no v<logic>p[sd] in avx512f.  Use vp<logic>[qd].  */
3340       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3341       ops = "vp<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3342       break;
3343     default:
3344       suffix = "<ssemodesuffix>";
3345     }
3347   snprintf (buf, sizeof (buf), ops, suffix);
3348   return buf;
3350   [(set_attr "isa" "noavx,avx,avx512dq,avx512f")
3351    (set_attr "type" "sselog")
3352    (set_attr "prefix" "orig,maybe_evex,evex,evex")
3353    (set (attr "mode")
3354         (cond [(and (match_test "<mask_applied>")
3355                     (and (eq_attr "alternative" "1")
3356                          (match_test "!TARGET_AVX512DQ")))
3357                  (const_string "<sseintvecmode2>")
3358                (eq_attr "alternative" "3")
3359                  (const_string "<sseintvecmode2>")
3360                (and (match_test "<MODE_SIZE> == 16")
3361                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3362                  (const_string "<ssePSmode>")
3363                (match_test "TARGET_AVX")
3364                  (const_string "<MODE>")
3365                (match_test "optimize_function_for_size_p (cfun)")
3366                  (const_string "V4SF")
3367                ]
3368                (const_string "<MODE>")))])
3370 (define_insn "*<code><mode>3<mask_name>"
3371   [(set (match_operand:VF_512 0 "register_operand" "=v")
3372         (any_logic:VF_512
3373           (match_operand:VF_512 1 "nonimmediate_operand" "%v")
3374           (match_operand:VF_512 2 "nonimmediate_operand" "vm")))]
3375   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
3377   static char buf[128];
3378   const char *ops;
3379   const char *suffix;
3381   suffix = "<ssemodesuffix>";
3382   ops = "";
3384   /* There is no v<logic>p[sd] in avx512f.  Use vp<logic>[dq].  */
3385   if (!TARGET_AVX512DQ)
3386     {
3387       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3388       ops = "p";
3389     }
3391   snprintf (buf, sizeof (buf),
3392            "v%s<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}",
3393            ops, suffix);
3394   return buf;
3396   [(set_attr "type" "sselog")
3397    (set_attr "prefix" "evex")
3398    (set (attr "mode")
3399         (if_then_else (match_test "TARGET_AVX512DQ")
3400                       (const_string "<sseinsnmode>")
3401                       (const_string "XI")))])
3403 (define_expand "copysign<mode>3"
3404   [(set (match_dup 4)
3405         (and:VF
3406           (not:VF (match_dup 3))
3407           (match_operand:VF 1 "vector_operand")))
3408    (set (match_dup 5)
3409         (and:VF (match_dup 3)
3410                 (match_operand:VF 2 "vector_operand")))
3411    (set (match_operand:VF 0 "register_operand")
3412         (ior:VF (match_dup 4) (match_dup 5)))]
3413   "TARGET_SSE"
3415   operands[3] = ix86_build_signbit_mask (<MODE>mode, 1, 0);
3417   operands[4] = gen_reg_rtx (<MODE>mode);
3418   operands[5] = gen_reg_rtx (<MODE>mode);
3421 ;; Also define scalar versions.  These are used for abs, neg, and
3422 ;; conditional move.  Using subregs into vector modes causes register
3423 ;; allocation lossage.  These patterns do not allow memory operands
3424 ;; because the native instructions read the full 128-bits.
3426 (define_insn "*andnot<mode>3"
3427   [(set (match_operand:MODEF 0 "register_operand" "=x,x,v,v")
3428         (and:MODEF
3429           (not:MODEF
3430             (match_operand:MODEF 1 "register_operand" "0,x,v,v"))
3431             (match_operand:MODEF 2 "register_operand" "x,x,v,v")))]
3432   "SSE_FLOAT_MODE_P (<MODE>mode)"
3434   static char buf[128];
3435   const char *ops;
3436   const char *suffix
3437     = (get_attr_mode (insn) == MODE_V4SF) ? "ps" : "<ssevecmodesuffix>";
3439   switch (which_alternative)
3440     {
3441     case 0:
3442       ops = "andn%s\t{%%2, %%0|%%0, %%2}";
3443       break;
3444     case 1:
3445       ops = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3446       break;
3447     case 2:
3448       if (TARGET_AVX512DQ)
3449         ops = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3450       else
3451         {
3452           suffix = <MODE>mode == DFmode ? "q" : "d";
3453           ops = "vpandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3454         }
3455       break;
3456     case 3:
3457       if (TARGET_AVX512DQ)
3458         ops = "vandn%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3459       else
3460         {
3461           suffix = <MODE>mode == DFmode ? "q" : "d";
3462           ops = "vpandn%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3463         }
3464       break;
3465     default:
3466       gcc_unreachable ();
3467     }
3469   snprintf (buf, sizeof (buf), ops, suffix);
3470   return buf;
3472   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3473    (set_attr "type" "sselog")
3474    (set_attr "prefix" "orig,vex,evex,evex")
3475    (set (attr "mode")
3476         (cond [(eq_attr "alternative" "2")
3477                  (if_then_else (match_test "TARGET_AVX512DQ")
3478                                (const_string "<ssevecmode>")
3479                                (const_string "TI"))
3480                (eq_attr "alternative" "3")
3481                  (if_then_else (match_test "TARGET_AVX512DQ")
3482                                (const_string "<avx512fvecmode>")
3483                                (const_string "XI"))
3484                (and (match_test "<MODE_SIZE> == 16")
3485                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3486                  (const_string "V4SF")
3487                (match_test "TARGET_AVX")
3488                  (const_string "<ssevecmode>")
3489                (match_test "optimize_function_for_size_p (cfun)")
3490                  (const_string "V4SF")
3491                ]
3492                (const_string "<ssevecmode>")))])
3494 (define_insn "*andnottf3"
3495   [(set (match_operand:TF 0 "register_operand" "=x,x,v,v")
3496         (and:TF
3497           (not:TF (match_operand:TF 1 "register_operand" "0,x,v,v"))
3498           (match_operand:TF 2 "vector_operand" "xBm,xm,vm,v")))]
3499   "TARGET_SSE"
3501   static char buf[128];
3502   const char *ops;
3503   const char *tmp
3504     = (which_alternative >= 2 ? "pandnq"
3505        : get_attr_mode (insn) == MODE_V4SF ? "andnps" : "pandn");
3507   switch (which_alternative)
3508     {
3509     case 0:
3510       ops = "%s\t{%%2, %%0|%%0, %%2}";
3511       break;
3512     case 1:
3513     case 2:
3514       ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3515       break;
3516     case 3:
3517       ops = "v%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3518       break;
3519     default:
3520       gcc_unreachable ();
3521     }
3523   snprintf (buf, sizeof (buf), ops, tmp);
3524   return buf;
3526   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3527    (set_attr "type" "sselog")
3528    (set (attr "prefix_data16")
3529      (if_then_else
3530        (and (eq_attr "alternative" "0")
3531             (eq_attr "mode" "TI"))
3532        (const_string "1")
3533        (const_string "*")))
3534    (set_attr "prefix" "orig,vex,evex,evex")
3535    (set (attr "mode")
3536         (cond [(eq_attr "alternative" "2")
3537                  (const_string "TI")
3538                (eq_attr "alternative" "3")
3539                  (const_string "XI")
3540                (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
3541                  (const_string "V4SF")
3542                (match_test "TARGET_AVX")
3543                  (const_string "TI")
3544                (ior (not (match_test "TARGET_SSE2"))
3545                     (match_test "optimize_function_for_size_p (cfun)"))
3546                  (const_string "V4SF")
3547                ]
3548                (const_string "TI")))])
3550 (define_insn "*<code><mode>3"
3551   [(set (match_operand:MODEF 0 "register_operand" "=x,x,v,v")
3552         (any_logic:MODEF
3553           (match_operand:MODEF 1 "register_operand" "%0,x,v,v")
3554           (match_operand:MODEF 2 "register_operand" "x,x,v,v")))]
3555   "SSE_FLOAT_MODE_P (<MODE>mode)"
3557   static char buf[128];
3558   const char *ops;
3559   const char *suffix
3560     = (get_attr_mode (insn) == MODE_V4SF) ? "ps" : "<ssevecmodesuffix>";
3562   switch (which_alternative)
3563     {
3564     case 0:
3565       ops = "<logic>%s\t{%%2, %%0|%%0, %%2}";
3566       break;
3567     case 2:
3568       if (!TARGET_AVX512DQ)
3569         {
3570           suffix = <MODE>mode == DFmode ? "q" : "d";
3571           ops = "vp<logic>%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3572           break;
3573         }
3574       /* FALLTHRU */
3575     case 1:
3576       ops = "v<logic>%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3577       break;
3578     case 3:
3579       if (TARGET_AVX512DQ)
3580         ops = "v<logic>%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3581       else
3582         {
3583           suffix = <MODE>mode == DFmode ? "q" : "d";
3584           ops = "vp<logic>%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3585         }
3586       break;
3587     default:
3588       gcc_unreachable ();
3589     }
3591   snprintf (buf, sizeof (buf), ops, suffix);
3592   return buf;
3594   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3595    (set_attr "type" "sselog")
3596    (set_attr "prefix" "orig,vex,evex,evex")
3597    (set (attr "mode")
3598         (cond [(eq_attr "alternative" "2")
3599                  (if_then_else (match_test "TARGET_AVX512DQ")
3600                                (const_string "<ssevecmode>")
3601                                (const_string "TI"))
3602                (eq_attr "alternative" "3")
3603                  (if_then_else (match_test "TARGET_AVX512DQ")
3604                                (const_string "<avx512fvecmode>")
3605                                (const_string "XI"))
3606                (and (match_test "<MODE_SIZE> == 16")
3607                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3608                  (const_string "V4SF")
3609                (match_test "TARGET_AVX")
3610                  (const_string "<ssevecmode>")
3611                (match_test "optimize_function_for_size_p (cfun)")
3612                  (const_string "V4SF")
3613                ]
3614                (const_string "<ssevecmode>")))])
3616 (define_expand "<code>tf3"
3617   [(set (match_operand:TF 0 "register_operand")
3618         (any_logic:TF
3619           (match_operand:TF 1 "vector_operand")
3620           (match_operand:TF 2 "vector_operand")))]
3621   "TARGET_SSE"
3622   "ix86_fixup_binary_operands_no_copy (<CODE>, TFmode, operands);")
3624 (define_insn "*<code>tf3"
3625   [(set (match_operand:TF 0 "register_operand" "=x,x,v,v")
3626         (any_logic:TF
3627           (match_operand:TF 1 "vector_operand" "%0,x,v,v")
3628           (match_operand:TF 2 "vector_operand" "xBm,xm,vm,v")))]
3629   "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
3631   static char buf[128];
3632   const char *ops;
3633   const char *tmp
3634     = (which_alternative >= 2 ? "p<logic>q"
3635        : get_attr_mode (insn) == MODE_V4SF ? "<logic>ps" : "p<logic>");
3637   switch (which_alternative)
3638     {
3639     case 0:
3640       ops = "%s\t{%%2, %%0|%%0, %%2}";
3641       break;
3642     case 1:
3643     case 2:
3644       ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3645       break;
3646     case 3:
3647       ops = "v%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3648       break;
3649     default:
3650       gcc_unreachable ();
3651     }
3653   snprintf (buf, sizeof (buf), ops, tmp);
3654   return buf;
3656   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3657    (set_attr "type" "sselog")
3658    (set (attr "prefix_data16")
3659      (if_then_else
3660        (and (eq_attr "alternative" "0")
3661             (eq_attr "mode" "TI"))
3662        (const_string "1")
3663        (const_string "*")))
3664    (set_attr "prefix" "orig,vex,evex,evex")
3665    (set (attr "mode")
3666         (cond [(eq_attr "alternative" "2")
3667                  (const_string "TI")
3668                (eq_attr "alternative" "3")
3669                  (const_string "QI")
3670                (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
3671                  (const_string "V4SF")
3672                (match_test "TARGET_AVX")
3673                  (const_string "TI")
3674                (ior (not (match_test "TARGET_SSE2"))
3675                     (match_test "optimize_function_for_size_p (cfun)"))
3676                  (const_string "V4SF")
3677                ]
3678                (const_string "TI")))])
3680 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3682 ;; FMA floating point multiply/accumulate instructions.  These include
3683 ;; scalar versions of the instructions as well as vector versions.
3685 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3687 ;; The standard names for scalar FMA are only available with SSE math enabled.
3688 ;; CPUID bit AVX512F enables evex encoded scalar and 512-bit fma.  It doesn't
3689 ;; care about FMA bit, so we enable fma for TARGET_AVX512F even when TARGET_FMA
3690 ;; and TARGET_FMA4 are both false.
3691 ;; TODO: In theory AVX512F does not automatically imply FMA, and without FMA
3692 ;; one must force the EVEX encoding of the fma insns.  Ideally we'd improve
3693 ;; GAS to allow proper prefix selection.  However, for the moment all hardware
3694 ;; that supports AVX512F also supports FMA so we can ignore this for now.
3695 (define_mode_iterator FMAMODEM
3696   [(SF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
3697    (DF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
3698    (V4SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3699    (V2DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3700    (V8SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3701    (V4DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3702    (V16SF "TARGET_AVX512F")
3703    (V8DF "TARGET_AVX512F")])
3705 (define_expand "fma<mode>4"
3706   [(set (match_operand:FMAMODEM 0 "register_operand")
3707         (fma:FMAMODEM
3708           (match_operand:FMAMODEM 1 "nonimmediate_operand")
3709           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3710           (match_operand:FMAMODEM 3 "nonimmediate_operand")))])
3712 (define_expand "fms<mode>4"
3713   [(set (match_operand:FMAMODEM 0 "register_operand")
3714         (fma:FMAMODEM
3715           (match_operand:FMAMODEM 1 "nonimmediate_operand")
3716           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3717           (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))])
3719 (define_expand "fnma<mode>4"
3720   [(set (match_operand:FMAMODEM 0 "register_operand")
3721         (fma:FMAMODEM
3722           (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
3723           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3724           (match_operand:FMAMODEM 3 "nonimmediate_operand")))])
3726 (define_expand "fnms<mode>4"
3727   [(set (match_operand:FMAMODEM 0 "register_operand")
3728         (fma:FMAMODEM
3729           (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
3730           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3731           (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))])
3733 ;; The builtins for intrinsics are not constrained by SSE math enabled.
3734 (define_mode_iterator FMAMODE_AVX512
3735  [(SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
3736   (DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
3737   (V4SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3738   (V2DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3739   (V8SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3740   (V4DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3741   (V16SF "TARGET_AVX512F")
3742   (V8DF "TARGET_AVX512F")])
3744 (define_mode_iterator FMAMODE
3745   [SF DF V4SF V2DF V8SF V4DF])
3747 (define_expand "fma4i_fmadd_<mode>"
3748   [(set (match_operand:FMAMODE_AVX512 0 "register_operand")
3749         (fma:FMAMODE_AVX512
3750           (match_operand:FMAMODE_AVX512 1 "nonimmediate_operand")
3751           (match_operand:FMAMODE_AVX512 2 "nonimmediate_operand")
3752           (match_operand:FMAMODE_AVX512 3 "nonimmediate_operand")))])
3754 (define_expand "fma4i_fmsub_<mode>"
3755   [(set (match_operand:FMAMODE_AVX512 0 "register_operand")
3756         (fma:FMAMODE_AVX512
3757           (match_operand:FMAMODE_AVX512 1 "nonimmediate_operand")
3758           (match_operand:FMAMODE_AVX512 2 "nonimmediate_operand")
3759           (neg:FMAMODE_AVX512
3760             (match_operand:FMAMODE_AVX512 3 "nonimmediate_operand"))))])
3762 (define_expand "fma4i_fnmadd_<mode>"
3763   [(set (match_operand:FMAMODE_AVX512 0 "register_operand")
3764         (fma:FMAMODE_AVX512
3765           (neg:FMAMODE_AVX512
3766             (match_operand:FMAMODE_AVX512 1 "nonimmediate_operand"))
3767           (match_operand:FMAMODE_AVX512 2 "nonimmediate_operand")
3768           (match_operand:FMAMODE_AVX512 3 "nonimmediate_operand")))])
3770 (define_expand "fma4i_fnmsub_<mode>"
3771   [(set (match_operand:FMAMODE_AVX512 0 "register_operand")
3772         (fma:FMAMODE_AVX512
3773           (neg:FMAMODE_AVX512
3774             (match_operand:FMAMODE_AVX512 1 "nonimmediate_operand"))
3775           (match_operand:FMAMODE_AVX512 2 "nonimmediate_operand")
3776           (neg:FMAMODE_AVX512
3777             (match_operand:FMAMODE_AVX512 3 "nonimmediate_operand"))))])
3779 (define_expand "<avx512>_fmadd_<mode>_maskz<round_expand_name>"
3780   [(match_operand:VF_AVX512VL 0 "register_operand")
3781    (match_operand:VF_AVX512VL 1 "<round_expand_nimm_predicate>")
3782    (match_operand:VF_AVX512VL 2 "<round_expand_nimm_predicate>")
3783    (match_operand:VF_AVX512VL 3 "<round_expand_nimm_predicate>")
3784    (match_operand:<avx512fmaskmode> 4 "register_operand")]
3785   "TARGET_AVX512F && <round_mode512bit_condition>"
3787   emit_insn (gen_fma_fmadd_<mode>_maskz_1<round_expand_name> (
3788     operands[0], operands[1], operands[2], operands[3],
3789     CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
3790   DONE;
3793 (define_insn "*fma_fmadd_<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           (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x")))]
3799   "TARGET_FMA || TARGET_FMA4"
3800   "@
3801    vfmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3802    vfmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3803    vfmadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3804    vfmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3805    vfmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3806   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3807    (set_attr "type" "ssemuladd")
3808    (set_attr "mode" "<MODE>")])
3810 ;; Suppose AVX-512F as baseline
3811 (define_mode_iterator VF_SF_AVX512VL
3812   [SF V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
3813    DF V8DF (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
3815 (define_insn "<sd_mask_codefor>fma_fmadd_<mode><sd_maskz_name><round_name>"
3816   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3817         (fma:VF_SF_AVX512VL
3818           (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v")
3819           (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3820           (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0")))]
3821   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3822   "@
3823    vfmadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3824    vfmadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3825    vfmadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3826   [(set_attr "type" "ssemuladd")
3827    (set_attr "mode" "<MODE>")])
3829 (define_insn "*<sd_mask_codefor>fma_fmadd_<mode><sd_maskz_name>_bcst_1"
3830   [(set (match_operand:VF_AVX512 0 "register_operand" "=v,v")
3831         (fma:VF_AVX512
3832           (match_operand:VF_AVX512 1 "register_operand" "0,v")
3833           (match_operand:VF_AVX512 2 "register_operand" "v,0")
3834           (vec_duplicate:VF_AVX512
3835             (match_operand:<ssescalarmode> 3 "memory_operand" "m,m"))))]
3836   "TARGET_AVX512F && <sd_mask_mode512bit_condition>"
3837   "vfmadd213<ssemodesuffix>\t{%3<avx512bcst>, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<avx512bcst>}"
3838   [(set_attr "type" "ssemuladd")
3839    (set_attr "mode" "<MODE>")])
3841 (define_insn "*<sd_mask_codefor>fma_fmadd_<mode><sd_maskz_name>_bcst_2"
3842   [(set (match_operand:VF_AVX512 0 "register_operand" "=v,v")
3843         (fma:VF_AVX512
3844           (vec_duplicate:VF_AVX512
3845             (match_operand:<ssescalarmode> 1 "memory_operand" "m,m"))
3846           (match_operand:VF_AVX512 2 "register_operand" "0,v")
3847           (match_operand:VF_AVX512 3 "register_operand" "v,0")))]
3848   "TARGET_AVX512F && <sd_mask_mode512bit_condition>"
3849   "@
3850    vfmadd132<ssemodesuffix>\t{%1<avx512bcst>, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %1<avx512bcst>}
3851    vfmadd231<ssemodesuffix>\t{%1<avx512bcst>, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %1<avx512bcst>}"
3852   [(set_attr "type" "ssemuladd")
3853    (set_attr "mode" "<MODE>")])
3855 (define_insn "*<sd_mask_codefor>fma_fmadd_<mode><sd_maskz_name>_bcst_3"
3856   [(set (match_operand:VF_AVX512 0 "register_operand" "=v,v")
3857         (fma:VF_AVX512
3858           (match_operand:VF_AVX512 1 "register_operand" "0,v")
3859           (vec_duplicate:VF_AVX512
3860             (match_operand:<ssescalarmode> 2 "memory_operand" "m,m"))
3861           (match_operand:VF_AVX512 3 "register_operand" "v,0")))]
3862   "TARGET_AVX512F && <sd_mask_mode512bit_condition>"
3863   "@
3864    vfmadd132<ssemodesuffix>\t{%2<avx512bcst>, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<avx512bcst>}
3865    vfmadd231<ssemodesuffix>\t{%2<avx512bcst>, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<avx512bcst>}"
3866   [(set_attr "type" "ssemuladd")
3867    (set_attr "mode" "<MODE>")])
3869 (define_insn "<avx512>_fmadd_<mode>_mask<round_name>"
3870   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3871         (vec_merge:VF_AVX512VL
3872           (fma:VF_AVX512VL
3873             (match_operand:VF_AVX512VL 1 "register_operand" "0,0")
3874             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3875             (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))
3876           (match_dup 1)
3877           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3878   "TARGET_AVX512F && <round_mode512bit_condition>"
3879   "@
3880    vfmadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3881    vfmadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3882   [(set_attr "type" "ssemuladd")
3883    (set_attr "mode" "<MODE>")])
3885 (define_insn "<avx512>_fmadd_<mode>_mask3<round_name>"
3886   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3887         (vec_merge:VF_AVX512VL
3888           (fma:VF_AVX512VL
3889             (match_operand:VF_AVX512VL 1 "register_operand" "v")
3890             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3891             (match_operand:VF_AVX512VL 3 "register_operand" "0"))
3892           (match_dup 3)
3893           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3894   "TARGET_AVX512F"
3895   "vfmadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3896   [(set_attr "type" "ssemuladd")
3897    (set_attr "mode" "<MODE>")])
3899 (define_insn "*fma_fmsub_<mode>"
3900   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3901         (fma:FMAMODE
3902           (match_operand:FMAMODE   1 "nonimmediate_operand" "%0,0,v,x,x")
3903           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
3904           (neg:FMAMODE
3905             (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x"))))]
3906   "TARGET_FMA || TARGET_FMA4"
3907   "@
3908    vfmsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3909    vfmsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3910    vfmsub231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3911    vfmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3912    vfmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3913   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3914    (set_attr "type" "ssemuladd")
3915    (set_attr "mode" "<MODE>")])
3917 (define_expand "<avx512>_fmsub_<mode>_maskz<round_expand_name>"
3918   [(match_operand:VF_AVX512VL 0 "register_operand")
3919    (match_operand:VF_AVX512VL 1 "<round_expand_nimm_predicate>")
3920    (match_operand:VF_AVX512VL 2 "<round_expand_nimm_predicate>")
3921    (match_operand:VF_AVX512VL 3 "<round_expand_nimm_predicate>")
3922    (match_operand:<avx512fmaskmode> 4 "register_operand")]
3923   "TARGET_AVX512F && <round_mode512bit_condition>"
3925   emit_insn (gen_fma_fmsub_<mode>_maskz_1<round_expand_name> (
3926     operands[0], operands[1], operands[2], operands[3],
3927     CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
3928   DONE;
3931 (define_insn "<sd_mask_codefor>fma_fmsub_<mode><sd_maskz_name><round_name>"
3932   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3933         (fma:VF_SF_AVX512VL
3934           (match_operand:VF_SF_AVX512VL   1 "<round_nimm_predicate>" "%0,0,v")
3935           (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3936           (neg:VF_SF_AVX512VL
3937             (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))))]
3938   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3939   "@
3940    vfmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3941    vfmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3942    vfmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3943   [(set_attr "type" "ssemuladd")
3944    (set_attr "mode" "<MODE>")])
3946 (define_insn "*<sd_mask_codefor>fma_fmsub_<mode><sd_maskz_name>_bcst_1"
3947   [(set (match_operand:VF_AVX512 0 "register_operand" "=v,v")
3948         (fma:VF_AVX512
3949           (match_operand:VF_AVX512 1 "register_operand" "0,v")
3950           (match_operand:VF_AVX512 2 "register_operand" "v,0")
3951           (neg:VF_AVX512
3952             (vec_duplicate:VF_AVX512
3953               (match_operand:<ssescalarmode> 3 "memory_operand" "m,m")))))]
3954   "TARGET_AVX512F && <sd_mask_mode512bit_condition>"
3955   "vfmsub213<ssemodesuffix>\t{%3<avx512bcst>, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<avx512bcst>}"
3956   [(set_attr "type" "ssemuladd")
3957    (set_attr "mode" "<MODE>")])
3959 (define_insn "*<sd_mask_codefor>fma_fmsub_<mode><sd_maskz_name>_bcst_2"
3960   [(set (match_operand:VF_AVX512 0 "register_operand" "=v,v")
3961         (fma:VF_AVX512
3962           (vec_duplicate:VF_AVX512
3963             (match_operand:<ssescalarmode> 1 "memory_operand" "m,m"))
3964           (match_operand:VF_AVX512 2 "register_operand" "0,v")
3965           (neg:VF_AVX512
3966             (match_operand:VF_AVX512 3 "register_operand" "v,0"))))]
3967   "TARGET_AVX512F && <sd_mask_mode512bit_condition>"
3968   "@
3969    vfmsub132<ssemodesuffix>\t{%1<avx512bcst>, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %1<avx512bcst>}
3970    vfmsub231<ssemodesuffix>\t{%1<avx512bcst>, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %1<avx512bcst>}"
3971   [(set_attr "type" "ssemuladd")
3972    (set_attr "mode" "<MODE>")])
3974 (define_insn "*<sd_mask_codefor>fma_fmsub_<mode><sd_maskz_name>_bcst_3"
3975   [(set (match_operand:VF_AVX512 0 "register_operand" "=v,v")
3976         (fma:VF_AVX512
3977           (match_operand:VF_AVX512 1 "register_operand" "0,v")
3978           (vec_duplicate:VF_AVX512
3979             (match_operand:<ssescalarmode> 2 "memory_operand" "m,m"))
3980           (neg:VF_AVX512
3981             (match_operand:VF_AVX512 3 "nonimmediate_operand" "v,0"))))]
3982   "TARGET_AVX512F && <sd_mask_mode512bit_condition>"
3983   "@
3984    vfmsub132<ssemodesuffix>\t{%2<avx512bcst>, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<avx512bcst>}
3985    vfmsub231<ssemodesuffix>\t{%2<avx512bcst>, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<avx512bcst>}"
3986   [(set_attr "type" "ssemuladd")
3987    (set_attr "mode" "<MODE>")])
3989 (define_insn "<avx512>_fmsub_<mode>_mask<round_name>"
3990   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3991         (vec_merge:VF_AVX512VL
3992           (fma:VF_AVX512VL
3993             (match_operand:VF_AVX512VL 1 "register_operand" "0,0")
3994             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3995             (neg:VF_AVX512VL
3996               (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")))
3997           (match_dup 1)
3998           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3999   "TARGET_AVX512F"
4000   "@
4001    vfmsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
4002    vfmsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
4003   [(set_attr "type" "ssemuladd")
4004    (set_attr "mode" "<MODE>")])
4006 (define_insn "<avx512>_fmsub_<mode>_mask3<round_name>"
4007   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
4008         (vec_merge:VF_AVX512VL
4009           (fma:VF_AVX512VL
4010             (match_operand:VF_AVX512VL 1 "register_operand" "v")
4011             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
4012             (neg:VF_AVX512VL
4013               (match_operand:VF_AVX512VL 3 "register_operand" "0")))
4014           (match_dup 3)
4015           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
4016   "TARGET_AVX512F && <round_mode512bit_condition>"
4017   "vfmsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
4018   [(set_attr "type" "ssemuladd")
4019    (set_attr "mode" "<MODE>")])
4021 (define_insn "*fma_fnmadd_<mode>"
4022   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
4023         (fma:FMAMODE
4024           (neg:FMAMODE
4025             (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x"))
4026           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
4027           (match_operand:FMAMODE   3 "nonimmediate_operand" "v,vm,0,xm,x")))]
4028   "TARGET_FMA || TARGET_FMA4"
4029   "@
4030    vfnmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
4031    vfnmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
4032    vfnmadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
4033    vfnmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
4034    vfnmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4035   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
4036    (set_attr "type" "ssemuladd")
4037    (set_attr "mode" "<MODE>")])
4039 (define_expand "<avx512>_fnmadd_<mode>_maskz<round_expand_name>"
4040   [(match_operand:VF_AVX512VL 0 "register_operand")
4041    (match_operand:VF_AVX512VL 1 "<round_expand_nimm_predicate>")
4042    (match_operand:VF_AVX512VL 2 "<round_expand_nimm_predicate>")
4043    (match_operand:VF_AVX512VL 3 "<round_expand_nimm_predicate>")
4044    (match_operand:<avx512fmaskmode> 4 "register_operand")]
4045   "TARGET_AVX512F && <round_mode512bit_condition>"
4047   emit_insn (gen_fma_fnmadd_<mode>_maskz_1<round_expand_name> (
4048     operands[0], operands[1], operands[2], operands[3],
4049     CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
4050   DONE;
4053 (define_insn "<sd_mask_codefor>fma_fnmadd_<mode><sd_maskz_name><round_name>"
4054   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
4055         (fma:VF_SF_AVX512VL
4056           (neg:VF_SF_AVX512VL
4057             (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v"))
4058           (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
4059           (match_operand:VF_SF_AVX512VL   3 "<round_nimm_predicate>" "v,<round_constraint>,0")))]
4060   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
4061   "@
4062    vfnmadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
4063    vfnmadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
4064    vfnmadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
4065   [(set_attr "type" "ssemuladd")
4066    (set_attr "mode" "<MODE>")])
4068 (define_insn "*<sd_mask_codefor>fma_fnmadd_<mode><sd_maskz_name>_bcst_1"
4069   [(set (match_operand:VF_AVX512 0 "register_operand" "=v,v")
4070         (fma:VF_AVX512
4071           (neg:VF_AVX512
4072             (match_operand:VF_AVX512 1 "register_operand" "0,v"))
4073           (match_operand:VF_AVX512 2 "register_operand" "v,0")
4074           (vec_duplicate:VF_AVX512
4075             (match_operand:<ssescalarmode> 3 "memory_operand" "m,m"))))]
4076   "TARGET_AVX512F && <sd_mask_mode512bit_condition>"
4077   "vfnmadd213<ssemodesuffix>\t{%3<avx512bcst>, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<avx512bcst>}"
4078   [(set_attr "type" "ssemuladd")
4079    (set_attr "mode" "<MODE>")])
4081 (define_insn "*<sd_mask_codefor>fma_fnmadd_<mode><sd_maskz_name>_bcst_2"
4082   [(set (match_operand:VF_AVX512 0 "register_operand" "=v,v")
4083         (fma:VF_AVX512
4084           (neg:VF_AVX512
4085             (vec_duplicate:VF_AVX512
4086               (match_operand:<ssescalarmode> 1 "memory_operand" "m,m")))
4087           (match_operand:VF_AVX512 2 "register_operand" "0,v")
4088           (match_operand:VF_AVX512 3 "register_operand" "v,0")))]
4089   "TARGET_AVX512F && <sd_mask_mode512bit_condition>"
4090   "@
4091    vfnmadd132<ssemodesuffix>\t{%1<avx512bcst>, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %1<avx512bcst>}
4092    vfnmadd231<ssemodesuffix>\t{%1<avx512bcst>, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %1<avx512bcst>}"
4093   [(set_attr "type" "ssemuladd")
4094    (set_attr "mode" "<MODE>")])
4096 (define_insn "*<sd_mask_codefor>fma_fnmadd_<mode><sd_maskz_name>_bcst_3"
4097   [(set (match_operand:VF_AVX512 0 "register_operand" "=v,v")
4098         (fma:VF_AVX512
4099           (neg:VF_AVX512
4100             (match_operand:VF_AVX512 1 "register_operand" "0,v"))
4101           (vec_duplicate:VF_AVX512
4102             (match_operand:<ssescalarmode> 2 "memory_operand" "m,m"))
4103           (match_operand:VF_AVX512 3 "register_operand" "v,0")))]
4104   "TARGET_AVX512F && <sd_mask_mode512bit_condition>"
4105   "@
4106    vfnmadd132<ssemodesuffix>\t{%2<avx512bcst>, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<avx512bcst>}
4107    vfnmadd231<ssemodesuffix>\t{%2<avx512bcst>, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<avx512bcst>}"
4108   [(set_attr "type" "ssemuladd")
4109    (set_attr "mode" "<MODE>")])
4111 (define_insn "<avx512>_fnmadd_<mode>_mask<round_name>"
4112   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
4113         (vec_merge:VF_AVX512VL
4114           (fma:VF_AVX512VL
4115             (neg:VF_AVX512VL
4116               (match_operand:VF_AVX512VL 1 "register_operand" "0,0"))
4117             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
4118             (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))
4119           (match_dup 1)
4120           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
4121   "TARGET_AVX512F && <round_mode512bit_condition>"
4122   "@
4123    vfnmadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
4124    vfnmadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
4125   [(set_attr "type" "ssemuladd")
4126    (set_attr "mode" "<MODE>")])
4128 (define_insn "<avx512>_fnmadd_<mode>_mask3<round_name>"
4129   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
4130         (vec_merge:VF_AVX512VL
4131           (fma:VF_AVX512VL
4132             (neg:VF_AVX512VL
4133               (match_operand:VF_AVX512VL 1 "register_operand" "v"))
4134             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
4135             (match_operand:VF_AVX512VL 3 "register_operand" "0"))
4136           (match_dup 3)
4137           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
4138   "TARGET_AVX512F && <round_mode512bit_condition>"
4139   "vfnmadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
4140   [(set_attr "type" "ssemuladd")
4141    (set_attr "mode" "<MODE>")])
4143 (define_insn "*fma_fnmsub_<mode>"
4144   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
4145         (fma:FMAMODE
4146           (neg:FMAMODE
4147             (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x"))
4148           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
4149           (neg:FMAMODE
4150             (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x"))))]
4151   "TARGET_FMA || TARGET_FMA4"
4152   "@
4153    vfnmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
4154    vfnmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
4155    vfnmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}
4156    vfnmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
4157    vfnmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4158   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
4159    (set_attr "type" "ssemuladd")
4160    (set_attr "mode" "<MODE>")])
4162 (define_expand "<avx512>_fnmsub_<mode>_maskz<round_expand_name>"
4163   [(match_operand:VF_AVX512VL 0 "register_operand")
4164    (match_operand:VF_AVX512VL 1 "<round_expand_nimm_predicate>")
4165    (match_operand:VF_AVX512VL 2 "<round_expand_nimm_predicate>")
4166    (match_operand:VF_AVX512VL 3 "<round_expand_nimm_predicate>")
4167    (match_operand:<avx512fmaskmode> 4 "register_operand")]
4168   "TARGET_AVX512F && <round_mode512bit_condition>"
4170   emit_insn (gen_fma_fnmsub_<mode>_maskz_1<round_expand_name> (
4171     operands[0], operands[1], operands[2], operands[3],
4172     CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
4173   DONE;
4176 (define_insn "<sd_mask_codefor>fma_fnmsub_<mode><sd_maskz_name><round_name>"
4177   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
4178         (fma:VF_SF_AVX512VL
4179           (neg:VF_SF_AVX512VL
4180             (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v"))
4181           (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
4182           (neg:VF_SF_AVX512VL
4183             (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))))]
4184   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
4185   "@
4186    vfnmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
4187    vfnmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
4188    vfnmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
4189   [(set_attr "type" "ssemuladd")
4190    (set_attr "mode" "<MODE>")])
4192 (define_insn "*<sd_mask_codefor>fma_fnmsub_<mode><sd_maskz_name>_bcst_1"
4193   [(set (match_operand:VF_AVX512 0 "register_operand" "=v,v")
4194         (fma:VF_AVX512
4195           (neg:VF_AVX512
4196             (match_operand:VF_AVX512 1 "register_operand" "0,v"))
4197           (match_operand:VF_AVX512 2 "register_operand" "v,0")
4198           (neg:VF_AVX512
4199             (vec_duplicate:VF_AVX512
4200               (match_operand:<ssescalarmode> 3 "memory_operand" "m,m")))))]
4201   "TARGET_AVX512F && <sd_mask_mode512bit_condition>"
4202   "vfnmsub213<ssemodesuffix>\t{%3<avx512bcst>, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<avx512bcst>}"
4203   [(set_attr "type" "ssemuladd")
4204    (set_attr "mode" "<MODE>")])
4206 (define_insn "*<sd_mask_codefor>fma_fnmsub_<mode><sd_maskz_name>_bcst_2"
4207   [(set (match_operand:VF_AVX512 0 "register_operand" "=v,v")
4208         (fma:VF_AVX512
4209           (neg:VF_AVX512
4210             (vec_duplicate:VF_AVX512
4211               (match_operand:<ssescalarmode> 1 "memory_operand" "m,m")))
4212           (match_operand:VF_AVX512 2 "register_operand" "0,v")
4213           (neg:VF_AVX512
4214             (match_operand:VF_AVX512 3 "register_operand" "v,0"))))]
4215   "TARGET_AVX512F && <sd_mask_mode512bit_condition>"
4216   "@
4217    vfnmsub132<ssemodesuffix>\t{%1<avx512bcst>, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %1<avx512bcst>}
4218    vfnmsub231<ssemodesuffix>\t{%1<avx512bcst>, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %1<avx512bcst>}"
4219   [(set_attr "type" "ssemuladd")
4220    (set_attr "mode" "<MODE>")])
4222 (define_insn "*<sd_mask_codefor>fma_fnmsub_<mode><sd_maskz_name>_bcst_3"
4223   [(set (match_operand:VF_AVX512 0 "register_operand" "=v,v")
4224         (fma:VF_AVX512
4225           (neg:VF_AVX512
4226             (match_operand:VF_AVX512 1 "register_operand" "0,v"))
4227           (vec_duplicate:VF_AVX512
4228             (match_operand:<ssescalarmode> 2 "memory_operand" "m,m"))
4229           (neg:VF_AVX512
4230             (match_operand:VF_AVX512 3 "register_operand" "v,0"))))]
4231   "TARGET_AVX512F && <sd_mask_mode512bit_condition>"
4232   "@
4233    vfnmsub132<ssemodesuffix>\t{%2<avx512bcst>, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<avx512bcst>}
4234    vfnmsub231<ssemodesuffix>\t{%2<avx512bcst>, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<avx512bcst>}"
4235   [(set_attr "type" "ssemuladd")
4236    (set_attr "mode" "<MODE>")])
4238 (define_insn "<avx512>_fnmsub_<mode>_mask<round_name>"
4239   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
4240         (vec_merge:VF_AVX512VL
4241           (fma:VF_AVX512VL
4242             (neg:VF_AVX512VL
4243               (match_operand:VF_AVX512VL 1 "register_operand" "0,0"))
4244             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
4245             (neg:VF_AVX512VL
4246               (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")))
4247           (match_dup 1)
4248           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
4249   "TARGET_AVX512F && <round_mode512bit_condition>"
4250   "@
4251    vfnmsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
4252    vfnmsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
4253   [(set_attr "type" "ssemuladd")
4254    (set_attr "mode" "<MODE>")])
4256 (define_insn "<avx512>_fnmsub_<mode>_mask3<round_name>"
4257   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
4258         (vec_merge:VF_AVX512VL
4259           (fma:VF_AVX512VL
4260             (neg:VF_AVX512VL
4261               (match_operand:VF_AVX512VL 1 "register_operand" "v"))
4262             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
4263             (neg:VF_AVX512VL
4264               (match_operand:VF_AVX512VL 3 "register_operand" "0")))
4265           (match_dup 3)
4266           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
4267   "TARGET_AVX512F"
4268   "vfnmsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
4269   [(set_attr "type" "ssemuladd")
4270    (set_attr "mode" "<MODE>")])
4272 ;; FMA parallel floating point multiply addsub and subadd operations.
4274 ;; It would be possible to represent these without the UNSPEC as
4276 ;; (vec_merge
4277 ;;   (fma op1 op2 op3)
4278 ;;   (fma op1 op2 (neg op3))
4279 ;;   (merge-const))
4281 ;; But this doesn't seem useful in practice.
4283 (define_expand "fmaddsub_<mode>"
4284   [(set (match_operand:VF 0 "register_operand")
4285         (unspec:VF
4286           [(match_operand:VF 1 "nonimmediate_operand")
4287            (match_operand:VF 2 "nonimmediate_operand")
4288            (match_operand:VF 3 "nonimmediate_operand")]
4289           UNSPEC_FMADDSUB))]
4290   "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
4292 (define_expand "<avx512>_fmaddsub_<mode>_maskz<round_expand_name>"
4293   [(match_operand:VF_AVX512VL 0 "register_operand")
4294    (match_operand:VF_AVX512VL 1 "<round_expand_nimm_predicate>")
4295    (match_operand:VF_AVX512VL 2 "<round_expand_nimm_predicate>")
4296    (match_operand:VF_AVX512VL 3 "<round_expand_nimm_predicate>")
4297    (match_operand:<avx512fmaskmode> 4 "register_operand")]
4298   "TARGET_AVX512F"
4300   emit_insn (gen_fma_fmaddsub_<mode>_maskz_1<round_expand_name> (
4301     operands[0], operands[1], operands[2], operands[3],
4302     CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
4303   DONE;
4306 (define_insn "*fma_fmaddsub_<mode>"
4307   [(set (match_operand:VF_128_256 0 "register_operand" "=v,v,v,x,x")
4308         (unspec:VF_128_256
4309           [(match_operand:VF_128_256 1 "nonimmediate_operand" "%0,0,v,x,x")
4310            (match_operand:VF_128_256 2 "nonimmediate_operand" "vm,v,vm,x,m")
4311            (match_operand:VF_128_256 3 "nonimmediate_operand" "v,vm,0,xm,x")]
4312           UNSPEC_FMADDSUB))]
4313   "TARGET_FMA || TARGET_FMA4"
4314   "@
4315    vfmaddsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
4316    vfmaddsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
4317    vfmaddsub231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
4318    vfmaddsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
4319    vfmaddsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4320   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
4321    (set_attr "type" "ssemuladd")
4322    (set_attr "mode" "<MODE>")])
4324 (define_insn "<sd_mask_codefor>fma_fmaddsub_<mode><sd_maskz_name><round_name>"
4325   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
4326         (unspec:VF_SF_AVX512VL
4327           [(match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v")
4328            (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
4329            (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0")]
4330           UNSPEC_FMADDSUB))]
4331   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
4332   "@
4333    vfmaddsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
4334    vfmaddsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
4335    vfmaddsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
4336   [(set_attr "type" "ssemuladd")
4337    (set_attr "mode" "<MODE>")])
4339 (define_insn "<avx512>_fmaddsub_<mode>_mask<round_name>"
4340   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
4341         (vec_merge:VF_AVX512VL
4342           (unspec:VF_AVX512VL
4343             [(match_operand:VF_AVX512VL 1 "register_operand" "0,0")
4344              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
4345              (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")]
4346             UNSPEC_FMADDSUB)
4347           (match_dup 1)
4348           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
4349   "TARGET_AVX512F"
4350   "@
4351    vfmaddsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
4352    vfmaddsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
4353   [(set_attr "type" "ssemuladd")
4354    (set_attr "mode" "<MODE>")])
4356 (define_insn "<avx512>_fmaddsub_<mode>_mask3<round_name>"
4357   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
4358         (vec_merge:VF_AVX512VL
4359           (unspec:VF_AVX512VL
4360             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
4361              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
4362              (match_operand:VF_AVX512VL 3 "register_operand" "0")]
4363             UNSPEC_FMADDSUB)
4364           (match_dup 3)
4365           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
4366   "TARGET_AVX512F"
4367   "vfmaddsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
4368   [(set_attr "type" "ssemuladd")
4369    (set_attr "mode" "<MODE>")])
4371 (define_insn "*fma_fmsubadd_<mode>"
4372   [(set (match_operand:VF_128_256 0 "register_operand" "=v,v,v,x,x")
4373         (unspec:VF_128_256
4374           [(match_operand:VF_128_256   1 "nonimmediate_operand" "%0,0,v,x,x")
4375            (match_operand:VF_128_256   2 "nonimmediate_operand" "vm,v,vm,x,m")
4376            (neg:VF_128_256
4377              (match_operand:VF_128_256 3 "nonimmediate_operand" "v,vm,0,xm,x"))]
4378           UNSPEC_FMADDSUB))]
4379   "TARGET_FMA || TARGET_FMA4"
4380   "@
4381    vfmsubadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
4382    vfmsubadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
4383    vfmsubadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
4384    vfmsubadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
4385    vfmsubadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4386   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
4387    (set_attr "type" "ssemuladd")
4388    (set_attr "mode" "<MODE>")])
4390 (define_insn "<sd_mask_codefor>fma_fmsubadd_<mode><sd_maskz_name><round_name>"
4391   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
4392         (unspec:VF_SF_AVX512VL
4393           [(match_operand:VF_SF_AVX512VL   1 "<round_nimm_predicate>" "%0,0,v")
4394            (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
4395            (neg:VF_SF_AVX512VL
4396              (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))]
4397           UNSPEC_FMADDSUB))]
4398   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
4399   "@
4400    vfmsubadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
4401    vfmsubadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
4402    vfmsubadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
4403   [(set_attr "type" "ssemuladd")
4404    (set_attr "mode" "<MODE>")])
4406 (define_insn "<avx512>_fmsubadd_<mode>_mask<round_name>"
4407   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
4408         (vec_merge:VF_AVX512VL
4409           (unspec:VF_AVX512VL
4410             [(match_operand:VF_AVX512VL 1 "register_operand" "0,0")
4411              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
4412              (neg:VF_AVX512VL
4413                (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))]
4414             UNSPEC_FMADDSUB)
4415           (match_dup 1)
4416           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
4417   "TARGET_AVX512F"
4418   "@
4419    vfmsubadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
4420    vfmsubadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
4421   [(set_attr "type" "ssemuladd")
4422    (set_attr "mode" "<MODE>")])
4424 (define_insn "<avx512>_fmsubadd_<mode>_mask3<round_name>"
4425   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
4426         (vec_merge:VF_AVX512VL
4427           (unspec:VF_AVX512VL
4428             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
4429              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
4430              (neg:VF_AVX512VL
4431                (match_operand:VF_AVX512VL 3 "register_operand" "0"))]
4432             UNSPEC_FMADDSUB)
4433           (match_dup 3)
4434           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
4435   "TARGET_AVX512F"
4436   "vfmsubadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
4437   [(set_attr "type" "ssemuladd")
4438    (set_attr "mode" "<MODE>")])
4440 ;; FMA3 floating point scalar intrinsics. These merge result with
4441 ;; high-order elements from the destination register.
4443 (define_expand "fmai_vmfmadd_<mode><round_name>"
4444   [(set (match_operand:VF_128 0 "register_operand")
4445         (vec_merge:VF_128
4446           (fma:VF_128
4447             (match_operand:VF_128 1 "<round_nimm_predicate>")
4448             (match_operand:VF_128 2 "<round_nimm_predicate>")
4449             (match_operand:VF_128 3 "<round_nimm_predicate>"))
4450           (match_dup 1)
4451           (const_int 1)))]
4452   "TARGET_FMA")
4454 (define_expand "fmai_vmfmsub_<mode><round_name>"
4455   [(set (match_operand:VF_128 0 "register_operand")
4456         (vec_merge:VF_128
4457           (fma:VF_128
4458             (match_operand:VF_128 1 "<round_nimm_predicate>")
4459             (match_operand:VF_128 2 "<round_nimm_predicate>")
4460             (neg:VF_128
4461               (match_operand:VF_128 3 "<round_nimm_predicate>")))
4462           (match_dup 1)
4463           (const_int 1)))]
4464   "TARGET_FMA")
4466 (define_expand "fmai_vmfnmadd_<mode><round_name>"
4467   [(set (match_operand:VF_128 0 "register_operand")
4468         (vec_merge:VF_128
4469           (fma:VF_128
4470             (neg:VF_128
4471               (match_operand:VF_128 2 "<round_nimm_predicate>"))
4472             (match_operand:VF_128 1 "<round_nimm_predicate>")
4473             (match_operand:VF_128 3 "<round_nimm_predicate>"))
4474           (match_dup 1)
4475           (const_int 1)))]
4476   "TARGET_FMA")
4478 (define_expand "fmai_vmfnmsub_<mode><round_name>"
4479   [(set (match_operand:VF_128 0 "register_operand")
4480         (vec_merge:VF_128
4481           (fma:VF_128
4482             (neg:VF_128
4483               (match_operand:VF_128 2 "<round_nimm_predicate>"))
4484             (match_operand:VF_128 1 "<round_nimm_predicate>")
4485             (neg:VF_128
4486               (match_operand:VF_128 3 "<round_nimm_predicate>")))
4487           (match_dup 1)
4488           (const_int 1)))]
4489   "TARGET_FMA")
4491 (define_insn "*fmai_fmadd_<mode>"
4492   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4493         (vec_merge:VF_128
4494           (fma:VF_128
4495             (match_operand:VF_128 1 "<round_nimm_predicate>" " 0, 0")
4496             (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>, v")
4497             (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>"))
4498           (match_dup 1)
4499           (const_int 1)))]
4500   "TARGET_FMA || TARGET_AVX512F"
4501   "@
4502    vfmadd132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4503    vfmadd213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4504   [(set_attr "type" "ssemuladd")
4505    (set_attr "mode" "<MODE>")])
4507 (define_insn "*fmai_fmsub_<mode>"
4508   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4509         (vec_merge:VF_128
4510           (fma:VF_128
4511             (match_operand:VF_128   1 "<round_nimm_predicate>" "0,0")
4512             (match_operand:VF_128   2 "<round_nimm_predicate>" "<round_constraint>,v")
4513             (neg:VF_128
4514               (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>")))
4515           (match_dup 1)
4516           (const_int 1)))]
4517   "TARGET_FMA || TARGET_AVX512F"
4518   "@
4519    vfmsub132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4520    vfmsub213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4521   [(set_attr "type" "ssemuladd")
4522    (set_attr "mode" "<MODE>")])
4524 (define_insn "*fmai_fnmadd_<mode><round_name>"
4525   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4526         (vec_merge:VF_128
4527           (fma:VF_128
4528             (neg:VF_128
4529               (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>,v"))
4530             (match_operand:VF_128   1 "<round_nimm_predicate>" "0,0")
4531             (match_operand:VF_128   3 "<round_nimm_predicate>" "v,<round_constraint>"))
4532           (match_dup 1)
4533           (const_int 1)))]
4534   "TARGET_FMA || TARGET_AVX512F"
4535   "@
4536    vfnmadd132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4537    vfnmadd213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4538   [(set_attr "type" "ssemuladd")
4539    (set_attr "mode" "<MODE>")])
4541 (define_insn "*fmai_fnmsub_<mode><round_name>"
4542   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4543         (vec_merge:VF_128
4544           (fma:VF_128
4545             (neg:VF_128
4546               (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>, v"))
4547             (match_operand:VF_128   1 "<round_nimm_predicate>" " 0, 0")
4548             (neg:VF_128
4549               (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>")))
4550           (match_dup 1)
4551           (const_int 1)))]
4552   "TARGET_FMA || TARGET_AVX512F"
4553   "@
4554    vfnmsub132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4555    vfnmsub213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4556   [(set_attr "type" "ssemuladd")
4557    (set_attr "mode" "<MODE>")])
4559 ;; FMA4 floating point scalar intrinsics.  These write the
4560 ;; entire destination register, with the high-order elements zeroed.
4562 (define_expand "fma4i_vmfmadd_<mode>"
4563   [(set (match_operand:VF_128 0 "register_operand")
4564         (vec_merge:VF_128
4565           (fma:VF_128
4566             (match_operand:VF_128 1 "nonimmediate_operand")
4567             (match_operand:VF_128 2 "nonimmediate_operand")
4568             (match_operand:VF_128 3 "nonimmediate_operand"))
4569           (match_dup 4)
4570           (const_int 1)))]
4571   "TARGET_FMA4"
4572   "operands[4] = CONST0_RTX (<MODE>mode);")
4574 (define_insn "*fma4i_vmfmadd_<mode>"
4575   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4576         (vec_merge:VF_128
4577           (fma:VF_128
4578             (match_operand:VF_128 1 "nonimmediate_operand" "%x,x")
4579             (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
4580             (match_operand:VF_128 3 "nonimmediate_operand" "xm,x"))
4581           (match_operand:VF_128 4 "const0_operand")
4582           (const_int 1)))]
4583   "TARGET_FMA4"
4584   "vfmadd<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4585   [(set_attr "type" "ssemuladd")
4586    (set_attr "mode" "<MODE>")])
4588 (define_insn "*fma4i_vmfmsub_<mode>"
4589   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4590         (vec_merge:VF_128
4591           (fma:VF_128
4592             (match_operand:VF_128 1 "nonimmediate_operand" "%x,x")
4593             (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
4594             (neg:VF_128
4595               (match_operand:VF_128 3 "nonimmediate_operand" "xm,x")))
4596           (match_operand:VF_128 4 "const0_operand")
4597           (const_int 1)))]
4598   "TARGET_FMA4"
4599   "vfmsub<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4600   [(set_attr "type" "ssemuladd")
4601    (set_attr "mode" "<MODE>")])
4603 (define_insn "*fma4i_vmfnmadd_<mode>"
4604   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4605         (vec_merge:VF_128
4606           (fma:VF_128
4607             (neg:VF_128
4608               (match_operand:VF_128 1 "nonimmediate_operand" "%x,x"))
4609             (match_operand:VF_128   2 "nonimmediate_operand" " x,m")
4610             (match_operand:VF_128   3 "nonimmediate_operand" "xm,x"))
4611           (match_operand:VF_128 4 "const0_operand")
4612           (const_int 1)))]
4613   "TARGET_FMA4"
4614   "vfnmadd<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4615   [(set_attr "type" "ssemuladd")
4616    (set_attr "mode" "<MODE>")])
4618 (define_insn "*fma4i_vmfnmsub_<mode>"
4619   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4620         (vec_merge:VF_128
4621           (fma:VF_128
4622             (neg:VF_128
4623               (match_operand:VF_128 1 "nonimmediate_operand" "%x,x"))
4624             (match_operand:VF_128   2 "nonimmediate_operand" " x,m")
4625             (neg:VF_128
4626               (match_operand:VF_128   3 "nonimmediate_operand" "xm,x")))
4627           (match_operand:VF_128 4 "const0_operand")
4628           (const_int 1)))]
4629   "TARGET_FMA4"
4630   "vfnmsub<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4631   [(set_attr "type" "ssemuladd")
4632    (set_attr "mode" "<MODE>")])
4634 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4636 ;; Parallel single-precision floating point conversion operations
4638 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4640 (define_insn "sse_cvtpi2ps"
4641   [(set (match_operand:V4SF 0 "register_operand" "=x")
4642         (vec_merge:V4SF
4643           (vec_duplicate:V4SF
4644             (float:V2SF (match_operand:V2SI 2 "nonimmediate_operand" "ym")))
4645           (match_operand:V4SF 1 "register_operand" "0")
4646           (const_int 3)))]
4647   "TARGET_SSE"
4648   "cvtpi2ps\t{%2, %0|%0, %2}"
4649   [(set_attr "type" "ssecvt")
4650    (set_attr "mode" "V4SF")])
4652 (define_insn "sse_cvtps2pi"
4653   [(set (match_operand:V2SI 0 "register_operand" "=y")
4654         (vec_select:V2SI
4655           (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
4656                        UNSPEC_FIX_NOTRUNC)
4657           (parallel [(const_int 0) (const_int 1)])))]
4658   "TARGET_SSE"
4659   "cvtps2pi\t{%1, %0|%0, %q1}"
4660   [(set_attr "type" "ssecvt")
4661    (set_attr "unit" "mmx")
4662    (set_attr "mode" "DI")])
4664 (define_insn "sse_cvttps2pi"
4665   [(set (match_operand:V2SI 0 "register_operand" "=y")
4666         (vec_select:V2SI
4667           (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
4668           (parallel [(const_int 0) (const_int 1)])))]
4669   "TARGET_SSE"
4670   "cvttps2pi\t{%1, %0|%0, %q1}"
4671   [(set_attr "type" "ssecvt")
4672    (set_attr "unit" "mmx")
4673    (set_attr "prefix_rep" "0")
4674    (set_attr "mode" "SF")])
4676 (define_insn "sse_cvtsi2ss<rex64namesuffix><round_name>"
4677   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
4678         (vec_merge:V4SF
4679           (vec_duplicate:V4SF
4680             (float:SF (match_operand:SWI48 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
4681           (match_operand:V4SF 1 "register_operand" "0,0,v")
4682           (const_int 1)))]
4683   "TARGET_SSE"
4684   "@
4685    cvtsi2ss<rex64suffix>\t{%2, %0|%0, %2}
4686    cvtsi2ss<rex64suffix>\t{%2, %0|%0, %2}
4687    vcvtsi2ss<rex64suffix>\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4688   [(set_attr "isa" "noavx,noavx,avx")
4689    (set_attr "type" "sseicvt")
4690    (set_attr "athlon_decode" "vector,double,*")
4691    (set_attr "amdfam10_decode" "vector,double,*")
4692    (set_attr "bdver1_decode" "double,direct,*")
4693    (set_attr "btver2_decode" "double,double,double")
4694    (set_attr "znver1_decode" "double,double,double")
4695    (set (attr "length_vex")
4696         (if_then_else
4697           (and (match_test "<MODE>mode == DImode")
4698                (eq_attr "alternative" "2"))
4699           (const_string "4")
4700           (const_string "*")))
4701    (set (attr "prefix_rex")
4702         (if_then_else
4703           (and (match_test "<MODE>mode == DImode")
4704                (eq_attr "alternative" "0,1"))
4705           (const_string "1")
4706           (const_string "*")))
4707    (set_attr "prefix" "orig,orig,maybe_evex")
4708    (set_attr "mode" "SF")])
4710 (define_insn "sse_cvtss2si<rex64namesuffix><round_name>"
4711   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
4712         (unspec:SWI48
4713           [(vec_select:SF
4714              (match_operand:V4SF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4715              (parallel [(const_int 0)]))]
4716           UNSPEC_FIX_NOTRUNC))]
4717   "TARGET_SSE"
4718   "%vcvtss2si<rex64suffix>\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
4719   [(set_attr "type" "sseicvt")
4720    (set_attr "athlon_decode" "double,vector")
4721    (set_attr "bdver1_decode" "double,double")
4722    (set_attr "prefix_rep" "1")
4723    (set_attr "prefix" "maybe_vex")
4724    (set_attr "mode" "<MODE>")])
4726 (define_insn "sse_cvtss2si<rex64namesuffix>_2"
4727   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
4728         (unspec:SWI48 [(match_operand:SF 1 "nonimmediate_operand" "v,m")]
4729                       UNSPEC_FIX_NOTRUNC))]
4730   "TARGET_SSE"
4731   "%vcvtss2si<rex64suffix>\t{%1, %0|%0, %k1}"
4732   [(set_attr "type" "sseicvt")
4733    (set_attr "athlon_decode" "double,vector")
4734    (set_attr "amdfam10_decode" "double,double")
4735    (set_attr "bdver1_decode" "double,double")
4736    (set_attr "prefix_rep" "1")
4737    (set_attr "prefix" "maybe_vex")
4738    (set_attr "mode" "<MODE>")])
4740 (define_insn "sse_cvttss2si<rex64namesuffix><round_saeonly_name>"
4741   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
4742         (fix:SWI48
4743           (vec_select:SF
4744             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint>")
4745             (parallel [(const_int 0)]))))]
4746   "TARGET_SSE"
4747   "%vcvttss2si<rex64suffix>\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
4748   [(set_attr "type" "sseicvt")
4749    (set_attr "athlon_decode" "double,vector")
4750    (set_attr "amdfam10_decode" "double,double")
4751    (set_attr "bdver1_decode" "double,double")
4752    (set_attr "prefix_rep" "1")
4753    (set_attr "prefix" "maybe_vex")
4754    (set_attr "mode" "<MODE>")])
4756 (define_insn "cvtusi2<ssescalarmodesuffix>32<round_name>"
4757   [(set (match_operand:VF_128 0 "register_operand" "=v")
4758         (vec_merge:VF_128
4759           (vec_duplicate:VF_128
4760             (unsigned_float:<ssescalarmode>
4761               (match_operand:SI 2 "<round_nimm_predicate>" "<round_constraint3>")))
4762           (match_operand:VF_128 1 "register_operand" "v")
4763           (const_int 1)))]
4764   "TARGET_AVX512F && <round_modev4sf_condition>"
4765   "vcvtusi2<ssescalarmodesuffix>\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4766   [(set_attr "type" "sseicvt")
4767    (set_attr "prefix" "evex")
4768    (set_attr "mode" "<ssescalarmode>")])
4770 (define_insn "cvtusi2<ssescalarmodesuffix>64<round_name>"
4771   [(set (match_operand:VF_128 0 "register_operand" "=v")
4772         (vec_merge:VF_128
4773           (vec_duplicate:VF_128
4774             (unsigned_float:<ssescalarmode>
4775               (match_operand:DI 2 "<round_nimm_predicate>" "<round_constraint3>")))
4776           (match_operand:VF_128 1 "register_operand" "v")
4777           (const_int 1)))]
4778   "TARGET_AVX512F && TARGET_64BIT"
4779   "vcvtusi2<ssescalarmodesuffix>{q}\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4780   [(set_attr "type" "sseicvt")
4781    (set_attr "prefix" "evex")
4782    (set_attr "mode" "<ssescalarmode>")])
4784 (define_insn "float<sseintvecmodelower><mode>2<mask_name><round_name>"
4785   [(set (match_operand:VF1 0 "register_operand" "=x,v")
4786         (float:VF1
4787           (match_operand:<sseintvecmode> 1 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
4788   "TARGET_SSE2 && <mask_mode512bit_condition> && <round_mode512bit_condition>"
4789   "@
4790    cvtdq2ps\t{%1, %0|%0, %1}
4791    vcvtdq2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4792   [(set_attr "isa" "noavx,avx")
4793    (set_attr "type" "ssecvt")
4794    (set_attr "prefix" "maybe_vex")
4795    (set_attr "mode" "<sseinsnmode>")])
4797 (define_insn "ufloat<sseintvecmodelower><mode>2<mask_name><round_name>"
4798   [(set (match_operand:VF1_AVX512VL 0 "register_operand" "=v")
4799         (unsigned_float:VF1_AVX512VL
4800           (match_operand:<sseintvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
4801   "TARGET_AVX512F"
4802   "vcvtudq2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4803   [(set_attr "type" "ssecvt")
4804    (set_attr "prefix" "evex")
4805    (set_attr "mode" "<MODE>")])
4807 (define_expand "floatuns<sseintvecmodelower><mode>2"
4808   [(match_operand:VF1 0 "register_operand")
4809    (match_operand:<sseintvecmode> 1 "register_operand")]
4810   "TARGET_SSE2 && (<MODE>mode == V4SFmode || TARGET_AVX2)"
4812   if (<MODE>mode == V16SFmode)
4813     emit_insn (gen_ufloatv16siv16sf2 (operands[0], operands[1]));
4814   else
4815     if (TARGET_AVX512VL)
4816       {
4817         if (<MODE>mode == V4SFmode)
4818           emit_insn (gen_ufloatv4siv4sf2 (operands[0], operands[1]));
4819         else
4820           emit_insn (gen_ufloatv8siv8sf2 (operands[0], operands[1]));
4821       }
4822   else
4823     ix86_expand_vector_convert_uns_vsivsf (operands[0], operands[1]);
4825   DONE;
4829 ;; For <sse2_avx_avx512f>_fix_notrunc<sf2simodelower><mode> insn pattern
4830 (define_mode_attr sf2simodelower
4831   [(V16SI "v16sf") (V8SI "v8sf") (V4SI "v4sf")])
4833 (define_insn "<sse2_avx_avx512f>_fix_notrunc<sf2simodelower><mode><mask_name>"
4834   [(set (match_operand:VI4_AVX 0 "register_operand" "=v")
4835         (unspec:VI4_AVX
4836           [(match_operand:<ssePSmode> 1 "vector_operand" "vBm")]
4837           UNSPEC_FIX_NOTRUNC))]
4838   "TARGET_SSE2 && <mask_mode512bit_condition>"
4839   "%vcvtps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4840   [(set_attr "type" "ssecvt")
4841    (set (attr "prefix_data16")
4842      (if_then_else
4843        (match_test "TARGET_AVX")
4844      (const_string "*")
4845      (const_string "1")))
4846    (set_attr "prefix" "maybe_vex")
4847    (set_attr "mode" "<sseinsnmode>")])
4849 (define_insn "avx512f_fix_notruncv16sfv16si<mask_name><round_name>"
4850   [(set (match_operand:V16SI 0 "register_operand" "=v")
4851         (unspec:V16SI
4852           [(match_operand:V16SF 1 "<round_nimm_predicate>" "<round_constraint>")]
4853           UNSPEC_FIX_NOTRUNC))]
4854   "TARGET_AVX512F"
4855   "vcvtps2dq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4856   [(set_attr "type" "ssecvt")
4857    (set_attr "prefix" "evex")
4858    (set_attr "mode" "XI")])
4860 (define_insn "<mask_codefor><avx512>_ufix_notrunc<sf2simodelower><mode><mask_name><round_name>"
4861   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
4862         (unspec:VI4_AVX512VL
4863           [(match_operand:<ssePSmode> 1 "nonimmediate_operand" "<round_constraint>")]
4864           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4865   "TARGET_AVX512F"
4866   "vcvtps2udq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4867   [(set_attr "type" "ssecvt")
4868    (set_attr "prefix" "evex")
4869    (set_attr "mode" "<sseinsnmode>")])
4871 (define_insn "<mask_codefor>avx512dq_cvtps2qq<mode><mask_name><round_name>"
4872   [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
4873         (unspec:VI8_256_512 [(match_operand:<ssePSmode2> 1 "nonimmediate_operand" "<round_constraint>")]
4874                      UNSPEC_FIX_NOTRUNC))]
4875   "TARGET_AVX512DQ && <round_mode512bit_condition>"
4876   "vcvtps2qq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4877   [(set_attr "type" "ssecvt")
4878    (set_attr "prefix" "evex")
4879    (set_attr "mode" "<sseinsnmode>")])
4881 (define_insn "<mask_codefor>avx512dq_cvtps2qqv2di<mask_name>"
4882   [(set (match_operand:V2DI 0 "register_operand" "=v")
4883         (unspec:V2DI
4884           [(vec_select:V2SF
4885              (match_operand:V4SF 1 "nonimmediate_operand" "vm")
4886              (parallel [(const_int 0) (const_int 1)]))]
4887           UNSPEC_FIX_NOTRUNC))]
4888   "TARGET_AVX512DQ && TARGET_AVX512VL"
4889   "vcvtps2qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
4890   [(set_attr "type" "ssecvt")
4891    (set_attr "prefix" "evex")
4892    (set_attr "mode" "TI")])
4894 (define_insn "<mask_codefor>avx512dq_cvtps2uqq<mode><mask_name><round_name>"
4895   [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
4896         (unspec:VI8_256_512 [(match_operand:<ssePSmode2> 1 "nonimmediate_operand" "<round_constraint>")]
4897                      UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4898   "TARGET_AVX512DQ && <round_mode512bit_condition>"
4899   "vcvtps2uqq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4900   [(set_attr "type" "ssecvt")
4901    (set_attr "prefix" "evex")
4902    (set_attr "mode" "<sseinsnmode>")])
4904 (define_insn "<mask_codefor>avx512dq_cvtps2uqqv2di<mask_name>"
4905   [(set (match_operand:V2DI 0 "register_operand" "=v")
4906         (unspec:V2DI
4907           [(vec_select:V2SF
4908              (match_operand:V4SF 1 "nonimmediate_operand" "vm")
4909              (parallel [(const_int 0) (const_int 1)]))]
4910           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4911   "TARGET_AVX512DQ && TARGET_AVX512VL"
4912   "vcvtps2uqq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
4913   [(set_attr "type" "ssecvt")
4914    (set_attr "prefix" "evex")
4915    (set_attr "mode" "TI")])
4917 (define_insn "<fixsuffix>fix_truncv16sfv16si2<mask_name><round_saeonly_name>"
4918   [(set (match_operand:V16SI 0 "register_operand" "=v")
4919         (any_fix:V16SI
4920           (match_operand:V16SF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
4921   "TARGET_AVX512F"
4922   "vcvttps2<fixsuffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
4923   [(set_attr "type" "ssecvt")
4924    (set_attr "prefix" "evex")
4925    (set_attr "mode" "XI")])
4927 (define_insn "fix_truncv8sfv8si2<mask_name>"
4928   [(set (match_operand:V8SI 0 "register_operand" "=v")
4929         (fix:V8SI (match_operand:V8SF 1 "nonimmediate_operand" "vm")))]
4930   "TARGET_AVX && <mask_avx512vl_condition>"
4931   "vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4932   [(set_attr "type" "ssecvt")
4933    (set_attr "prefix" "<mask_prefix>")
4934    (set_attr "mode" "OI")])
4936 (define_insn "fix_truncv4sfv4si2<mask_name>"
4937   [(set (match_operand:V4SI 0 "register_operand" "=v")
4938         (fix:V4SI (match_operand:V4SF 1 "vector_operand" "vBm")))]
4939   "TARGET_SSE2 && <mask_avx512vl_condition>"
4940   "%vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4941   [(set_attr "type" "ssecvt")
4942    (set (attr "prefix_rep")
4943      (if_then_else
4944        (match_test "TARGET_AVX")
4945      (const_string "*")
4946      (const_string "1")))
4947    (set (attr "prefix_data16")
4948      (if_then_else
4949        (match_test "TARGET_AVX")
4950      (const_string "*")
4951      (const_string "0")))
4952    (set_attr "prefix_data16" "0")
4953    (set_attr "prefix" "<mask_prefix2>")
4954    (set_attr "mode" "TI")])
4956 (define_expand "fixuns_trunc<mode><sseintvecmodelower>2"
4957   [(match_operand:<sseintvecmode> 0 "register_operand")
4958    (match_operand:VF1 1 "register_operand")]
4959   "TARGET_SSE2"
4961   if (<MODE>mode == V16SFmode)
4962     emit_insn (gen_ufix_truncv16sfv16si2 (operands[0],
4963                                           operands[1]));
4964   else
4965     {
4966       rtx tmp[3];
4967       tmp[0] = ix86_expand_adjust_ufix_to_sfix_si (operands[1], &tmp[2]);
4968       tmp[1] = gen_reg_rtx (<sseintvecmode>mode);
4969       emit_insn (gen_fix_trunc<mode><sseintvecmodelower>2 (tmp[1], tmp[0]));
4970       emit_insn (gen_xor<sseintvecmodelower>3 (operands[0], tmp[1], tmp[2]));
4971     }
4972   DONE;
4975 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4977 ;; Parallel double-precision floating point conversion operations
4979 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4981 (define_insn "sse2_cvtpi2pd"
4982   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
4983         (float:V2DF (match_operand:V2SI 1 "nonimmediate_operand" "y,m")))]
4984   "TARGET_SSE2"
4985   "cvtpi2pd\t{%1, %0|%0, %1}"
4986   [(set_attr "type" "ssecvt")
4987    (set_attr "unit" "mmx,*")
4988    (set_attr "prefix_data16" "1,*")
4989    (set_attr "mode" "V2DF")])
4991 (define_insn "sse2_cvtpd2pi"
4992   [(set (match_operand:V2SI 0 "register_operand" "=y")
4993         (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "xm")]
4994                      UNSPEC_FIX_NOTRUNC))]
4995   "TARGET_SSE2"
4996   "cvtpd2pi\t{%1, %0|%0, %1}"
4997   [(set_attr "type" "ssecvt")
4998    (set_attr "unit" "mmx")
4999    (set_attr "bdver1_decode" "double")
5000    (set_attr "btver2_decode" "direct")
5001    (set_attr "prefix_data16" "1")
5002    (set_attr "mode" "DI")])
5004 (define_insn "sse2_cvttpd2pi"
5005   [(set (match_operand:V2SI 0 "register_operand" "=y")
5006         (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "xm")))]
5007   "TARGET_SSE2"
5008   "cvttpd2pi\t{%1, %0|%0, %1}"
5009   [(set_attr "type" "ssecvt")
5010    (set_attr "unit" "mmx")
5011    (set_attr "bdver1_decode" "double")
5012    (set_attr "prefix_data16" "1")
5013    (set_attr "mode" "TI")])
5015 (define_insn "sse2_cvtsi2sd"
5016   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
5017         (vec_merge:V2DF
5018           (vec_duplicate:V2DF
5019             (float:DF (match_operand:SI 2 "nonimmediate_operand" "r,m,rm")))
5020           (match_operand:V2DF 1 "register_operand" "0,0,v")
5021           (const_int 1)))]
5022   "TARGET_SSE2"
5023   "@
5024    cvtsi2sd\t{%2, %0|%0, %2}
5025    cvtsi2sd\t{%2, %0|%0, %2}
5026    vcvtsi2sd\t{%2, %1, %0|%0, %1, %2}"
5027   [(set_attr "isa" "noavx,noavx,avx")
5028    (set_attr "type" "sseicvt")
5029    (set_attr "athlon_decode" "double,direct,*")
5030    (set_attr "amdfam10_decode" "vector,double,*")
5031    (set_attr "bdver1_decode" "double,direct,*")
5032    (set_attr "btver2_decode" "double,double,double")
5033    (set_attr "znver1_decode" "double,double,double")
5034    (set_attr "prefix" "orig,orig,maybe_evex")
5035    (set_attr "mode" "DF")])
5037 (define_insn "sse2_cvtsi2sdq<round_name>"
5038   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
5039         (vec_merge:V2DF
5040           (vec_duplicate:V2DF
5041             (float:DF (match_operand:DI 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
5042           (match_operand:V2DF 1 "register_operand" "0,0,v")
5043           (const_int 1)))]
5044   "TARGET_SSE2 && TARGET_64BIT"
5045   "@
5046    cvtsi2sdq\t{%2, %0|%0, %2}
5047    cvtsi2sdq\t{%2, %0|%0, %2}
5048    vcvtsi2sdq\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
5049   [(set_attr "isa" "noavx,noavx,avx")
5050    (set_attr "type" "sseicvt")
5051    (set_attr "athlon_decode" "double,direct,*")
5052    (set_attr "amdfam10_decode" "vector,double,*")
5053    (set_attr "bdver1_decode" "double,direct,*")
5054    (set_attr "length_vex" "*,*,4")
5055    (set_attr "prefix_rex" "1,1,*")
5056    (set_attr "prefix" "orig,orig,maybe_evex")
5057    (set_attr "mode" "DF")])
5059 (define_insn "avx512f_vcvtss2usi<rex64namesuffix><round_name>"
5060   [(set (match_operand:SWI48 0 "register_operand" "=r")
5061         (unspec:SWI48
5062           [(vec_select:SF
5063              (match_operand:V4SF 1 "<round_nimm_predicate>" "<round_constraint>")
5064              (parallel [(const_int 0)]))]
5065           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
5066   "TARGET_AVX512F"
5067   "vcvtss2usi\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
5068   [(set_attr "type" "sseicvt")
5069    (set_attr "prefix" "evex")
5070    (set_attr "mode" "<MODE>")])
5072 (define_insn "avx512f_vcvttss2usi<rex64namesuffix><round_saeonly_name>"
5073   [(set (match_operand:SWI48 0 "register_operand" "=r")
5074         (unsigned_fix:SWI48
5075           (vec_select:SF
5076             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
5077             (parallel [(const_int 0)]))))]
5078   "TARGET_AVX512F"
5079   "vcvttss2usi\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
5080   [(set_attr "type" "sseicvt")
5081    (set_attr "prefix" "evex")
5082    (set_attr "mode" "<MODE>")])
5084 (define_insn "avx512f_vcvtsd2usi<rex64namesuffix><round_name>"
5085   [(set (match_operand:SWI48 0 "register_operand" "=r")
5086         (unspec:SWI48
5087           [(vec_select:DF
5088              (match_operand:V2DF 1 "<round_nimm_predicate>" "<round_constraint>")
5089              (parallel [(const_int 0)]))]
5090           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
5091   "TARGET_AVX512F"
5092   "vcvtsd2usi\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
5093   [(set_attr "type" "sseicvt")
5094    (set_attr "prefix" "evex")
5095    (set_attr "mode" "<MODE>")])
5097 (define_insn "avx512f_vcvttsd2usi<rex64namesuffix><round_saeonly_name>"
5098   [(set (match_operand:SWI48 0 "register_operand" "=r")
5099         (unsigned_fix:SWI48
5100           (vec_select:DF
5101             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
5102             (parallel [(const_int 0)]))))]
5103   "TARGET_AVX512F"
5104   "vcvttsd2usi\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
5105   [(set_attr "type" "sseicvt")
5106    (set_attr "prefix" "evex")
5107    (set_attr "mode" "<MODE>")])
5109 (define_insn "sse2_cvtsd2si<rex64namesuffix><round_name>"
5110   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
5111         (unspec:SWI48
5112           [(vec_select:DF
5113              (match_operand:V2DF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
5114              (parallel [(const_int 0)]))]
5115           UNSPEC_FIX_NOTRUNC))]
5116   "TARGET_SSE2"
5117   "%vcvtsd2si<rex64suffix>\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
5118   [(set_attr "type" "sseicvt")
5119    (set_attr "athlon_decode" "double,vector")
5120    (set_attr "bdver1_decode" "double,double")
5121    (set_attr "btver2_decode" "double,double")
5122    (set_attr "prefix_rep" "1")
5123    (set_attr "prefix" "maybe_vex")
5124    (set_attr "mode" "<MODE>")])
5126 (define_insn "sse2_cvtsd2si<rex64namesuffix>_2"
5127   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
5128         (unspec:SWI48 [(match_operand:DF 1 "nonimmediate_operand" "v,m")]
5129                       UNSPEC_FIX_NOTRUNC))]
5130   "TARGET_SSE2"
5131   "%vcvtsd2si<rex64suffix>\t{%1, %0|%0, %q1}"
5132   [(set_attr "type" "sseicvt")
5133    (set_attr "athlon_decode" "double,vector")
5134    (set_attr "amdfam10_decode" "double,double")
5135    (set_attr "bdver1_decode" "double,double")
5136    (set_attr "prefix_rep" "1")
5137    (set_attr "prefix" "maybe_vex")
5138    (set_attr "mode" "<MODE>")])
5140 (define_insn "sse2_cvttsd2si<rex64namesuffix><round_saeonly_name>"
5141   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
5142         (fix:SWI48
5143           (vec_select:DF
5144             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint2>")
5145             (parallel [(const_int 0)]))))]
5146   "TARGET_SSE2"
5147   "%vcvttsd2si<rex64suffix>\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
5148   [(set_attr "type" "sseicvt")
5149    (set_attr "athlon_decode" "double,vector")
5150    (set_attr "amdfam10_decode" "double,double")
5151    (set_attr "bdver1_decode" "double,double")
5152    (set_attr "btver2_decode" "double,double")
5153    (set_attr "prefix_rep" "1")
5154    (set_attr "prefix" "maybe_vex")
5155    (set_attr "mode" "<MODE>")])
5157 ;; For float<si2dfmode><mode>2 insn pattern
5158 (define_mode_attr si2dfmode
5159   [(V8DF "V8SI") (V4DF "V4SI")])
5160 (define_mode_attr si2dfmodelower
5161   [(V8DF "v8si") (V4DF "v4si")])
5163 (define_insn "float<si2dfmodelower><mode>2<mask_name>"
5164   [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
5165         (float:VF2_512_256 (match_operand:<si2dfmode> 1 "nonimmediate_operand" "vm")))]
5166   "TARGET_AVX && <mask_mode512bit_condition>"
5167   "vcvtdq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5168   [(set_attr "type" "ssecvt")
5169    (set_attr "prefix" "maybe_vex")
5170    (set_attr "mode" "<MODE>")])
5172 (define_insn "float<floatunssuffix><sseintvecmodelower><mode>2<mask_name><round_name>"
5173   [(set (match_operand:VF2_AVX512VL 0 "register_operand" "=v")
5174         (any_float:VF2_AVX512VL
5175           (match_operand:<sseintvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
5176   "TARGET_AVX512DQ"
5177   "vcvt<floatsuffix>qq2pd\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5178   [(set_attr "type" "ssecvt")
5179    (set_attr "prefix" "evex")
5180    (set_attr "mode" "<MODE>")])
5182 ;; For float<floatunssuffix><sselondveclower><mode> insn patterns
5183 (define_mode_attr qq2pssuff
5184   [(V8SF "") (V4SF "{y}")])
5186 (define_mode_attr sselongvecmode
5187   [(V8SF "V8DI") (V4SF  "V4DI")])
5189 (define_mode_attr sselongvecmodelower
5190   [(V8SF "v8di") (V4SF  "v4di")])
5192 (define_mode_attr sseintvecmode3
5193   [(V8SF "XI") (V4SF "OI")
5194    (V8DF "OI") (V4DF "TI")])
5196 (define_insn "float<floatunssuffix><sselongvecmodelower><mode>2<mask_name><round_name>"
5197   [(set (match_operand:VF1_128_256VL 0 "register_operand" "=v")
5198          (any_float:VF1_128_256VL
5199            (match_operand:<sselongvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
5200   "TARGET_AVX512DQ && <round_modev8sf_condition>"
5201   "vcvt<floatsuffix>qq2ps<qq2pssuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5202   [(set_attr "type" "ssecvt")
5203    (set_attr "prefix" "evex")
5204    (set_attr "mode" "<MODE>")])
5206 (define_insn "float<floatunssuffix>v2div2sf2"
5207   [(set (match_operand:V4SF 0 "register_operand" "=v")
5208         (vec_concat:V4SF
5209             (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
5210             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
5211   "TARGET_AVX512DQ && TARGET_AVX512VL"
5212   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0|%0, %1}"
5213   [(set_attr "type" "ssecvt")
5214    (set_attr "prefix" "evex")
5215    (set_attr "mode" "V4SF")])
5217 (define_mode_attr vpckfloat_concat_mode
5218   [(V8DI "v16sf") (V4DI "v8sf") (V2DI "v8sf")])
5219 (define_mode_attr vpckfloat_temp_mode
5220   [(V8DI "V8SF") (V4DI "V4SF") (V2DI "V4SF")])
5221 (define_mode_attr vpckfloat_op_mode
5222   [(V8DI "v8sf") (V4DI "v4sf") (V2DI "v2sf")])
5224 (define_expand "vec_pack<floatprefix>_float_<mode>"
5225   [(match_operand:<ssePSmode> 0 "register_operand")
5226    (any_float:<ssePSmode>
5227      (match_operand:VI8_AVX512VL 1 "register_operand"))
5228    (match_operand:VI8_AVX512VL 2 "register_operand")]
5229   "TARGET_AVX512DQ"
5231   rtx r1 = gen_reg_rtx (<vpckfloat_temp_mode>mode);
5232   rtx r2 = gen_reg_rtx (<vpckfloat_temp_mode>mode);
5233   rtx (*gen) (rtx, rtx) = gen_float<floatunssuffix><mode><vpckfloat_op_mode>2;
5234   emit_insn (gen (r1, operands[1]));
5235   emit_insn (gen (r2, operands[2]));
5236   if (<MODE>mode == V2DImode)
5237     emit_insn (gen_sse_movlhps (operands[0], r1, r2));
5238   else
5239     emit_insn (gen_avx_vec_concat<vpckfloat_concat_mode> (operands[0],
5240                                                           r1, r2));
5241   DONE;
5244 (define_insn "float<floatunssuffix>v2div2sf2_mask"
5245   [(set (match_operand:V4SF 0 "register_operand" "=v")
5246     (vec_concat:V4SF
5247         (vec_merge:V2SF
5248                 (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
5249             (vec_select:V2SF
5250                 (match_operand:V4SF 2 "nonimm_or_0_operand" "0C")
5251                 (parallel [(const_int 0) (const_int 1)]))
5252             (match_operand:QI 3 "register_operand" "Yk"))
5253             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
5254   "TARGET_AVX512DQ && TARGET_AVX512VL"
5255   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
5256   [(set_attr "type" "ssecvt")
5257    (set_attr "prefix" "evex")
5258    (set_attr "mode" "V4SF")])
5260 (define_insn "*float<floatunssuffix>v2div2sf2_mask_1"
5261   [(set (match_operand:V4SF 0 "register_operand" "=v")
5262     (vec_concat:V4SF
5263         (vec_merge:V2SF
5264                 (any_float:V2SF (match_operand:V2DI 1
5265                                   "nonimmediate_operand" "vm"))
5266             (const_vector:V2SF [(const_int 0) (const_int 0)])
5267             (match_operand:QI 2 "register_operand" "Yk"))
5268             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
5269   "TARGET_AVX512DQ && TARGET_AVX512VL"
5270   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
5271   [(set_attr "type" "ssecvt")
5272    (set_attr "prefix" "evex")
5273    (set_attr "mode" "V4SF")])
5275 (define_insn "ufloat<si2dfmodelower><mode>2<mask_name>"
5276   [(set (match_operand:VF2_512_256VL 0 "register_operand" "=v")
5277         (unsigned_float:VF2_512_256VL
5278           (match_operand:<si2dfmode> 1 "nonimmediate_operand" "vm")))]
5279    "TARGET_AVX512F"
5280    "vcvtudq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5281    [(set_attr "type" "ssecvt")
5282     (set_attr "prefix" "evex")
5283     (set_attr "mode" "<MODE>")])
5285 (define_insn "ufloatv2siv2df2<mask_name>"
5286   [(set (match_operand:V2DF 0 "register_operand" "=v")
5287         (unsigned_float:V2DF
5288           (vec_select:V2SI
5289             (match_operand:V4SI 1 "nonimmediate_operand" "vm")
5290             (parallel [(const_int 0) (const_int 1)]))))]
5291   "TARGET_AVX512VL"
5292   "vcvtudq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5293   [(set_attr "type" "ssecvt")
5294    (set_attr "prefix" "evex")
5295    (set_attr "mode" "V2DF")])
5297 (define_insn "avx512f_cvtdq2pd512_2"
5298   [(set (match_operand:V8DF 0 "register_operand" "=v")
5299         (float:V8DF
5300           (vec_select:V8SI
5301             (match_operand:V16SI 1 "nonimmediate_operand" "vm")
5302             (parallel [(const_int 0) (const_int 1)
5303                        (const_int 2) (const_int 3)
5304                        (const_int 4) (const_int 5)
5305                        (const_int 6) (const_int 7)]))))]
5306   "TARGET_AVX512F"
5307   "vcvtdq2pd\t{%t1, %0|%0, %t1}"
5308   [(set_attr "type" "ssecvt")
5309    (set_attr "prefix" "evex")
5310    (set_attr "mode" "V8DF")])
5312 (define_insn "avx_cvtdq2pd256_2"
5313   [(set (match_operand:V4DF 0 "register_operand" "=v")
5314         (float:V4DF
5315           (vec_select:V4SI
5316             (match_operand:V8SI 1 "nonimmediate_operand" "vm")
5317             (parallel [(const_int 0) (const_int 1)
5318                        (const_int 2) (const_int 3)]))))]
5319   "TARGET_AVX"
5320   "vcvtdq2pd\t{%x1, %0|%0, %x1}"
5321   [(set_attr "type" "ssecvt")
5322    (set_attr "prefix" "maybe_evex")
5323    (set_attr "mode" "V4DF")])
5325 (define_insn "sse2_cvtdq2pd<mask_name>"
5326   [(set (match_operand:V2DF 0 "register_operand" "=v")
5327         (float:V2DF
5328           (vec_select:V2SI
5329             (match_operand:V4SI 1 "nonimmediate_operand" "vm")
5330             (parallel [(const_int 0) (const_int 1)]))))]
5331   "TARGET_SSE2 && <mask_avx512vl_condition>"
5332   "%vcvtdq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5333   [(set_attr "type" "ssecvt")
5334    (set_attr "prefix" "maybe_vex")
5335    (set_attr "mode" "V2DF")])
5337 (define_insn "avx512f_cvtpd2dq512<mask_name><round_name>"
5338   [(set (match_operand:V8SI 0 "register_operand" "=v")
5339         (unspec:V8SI
5340           [(match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")]
5341           UNSPEC_FIX_NOTRUNC))]
5342   "TARGET_AVX512F"
5343   "vcvtpd2dq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5344   [(set_attr "type" "ssecvt")
5345    (set_attr "prefix" "evex")
5346    (set_attr "mode" "OI")])
5348 (define_insn "avx_cvtpd2dq256<mask_name>"
5349   [(set (match_operand:V4SI 0 "register_operand" "=v")
5350         (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")]
5351                      UNSPEC_FIX_NOTRUNC))]
5352   "TARGET_AVX && <mask_avx512vl_condition>"
5353   "vcvtpd2dq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5354   [(set_attr "type" "ssecvt")
5355    (set_attr "prefix" "<mask_prefix>")
5356    (set_attr "mode" "OI")])
5358 (define_expand "avx_cvtpd2dq256_2"
5359   [(set (match_operand:V8SI 0 "register_operand")
5360         (vec_concat:V8SI
5361           (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand")]
5362                        UNSPEC_FIX_NOTRUNC)
5363           (match_dup 2)))]
5364   "TARGET_AVX"
5365   "operands[2] = CONST0_RTX (V4SImode);")
5367 (define_insn "*avx_cvtpd2dq256_2"
5368   [(set (match_operand:V8SI 0 "register_operand" "=v")
5369         (vec_concat:V8SI
5370           (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")]
5371                        UNSPEC_FIX_NOTRUNC)
5372           (match_operand:V4SI 2 "const0_operand")))]
5373   "TARGET_AVX"
5374   "vcvtpd2dq{y}\t{%1, %x0|%x0, %1}"
5375   [(set_attr "type" "ssecvt")
5376    (set_attr "prefix" "vex")
5377    (set_attr "btver2_decode" "vector")
5378    (set_attr "mode" "OI")])
5380 (define_insn "sse2_cvtpd2dq<mask_name>"
5381   [(set (match_operand:V4SI 0 "register_operand" "=v")
5382         (vec_concat:V4SI
5383           (unspec:V2SI [(match_operand:V2DF 1 "vector_operand" "vBm")]
5384                        UNSPEC_FIX_NOTRUNC)
5385           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5386   "TARGET_SSE2 && <mask_avx512vl_condition>"
5388   if (TARGET_AVX)
5389     return "vcvtpd2dq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
5390   else
5391     return "cvtpd2dq\t{%1, %0|%0, %1}";
5393   [(set_attr "type" "ssecvt")
5394    (set_attr "prefix_rep" "1")
5395    (set_attr "prefix_data16" "0")
5396    (set_attr "prefix" "maybe_vex")
5397    (set_attr "mode" "TI")
5398    (set_attr "amdfam10_decode" "double")
5399    (set_attr "athlon_decode" "vector")
5400    (set_attr "bdver1_decode" "double")])
5402 ;; For ufix_notrunc* insn patterns
5403 (define_mode_attr pd2udqsuff
5404   [(V8DF "") (V4DF "{y}")])
5406 (define_insn "ufix_notrunc<mode><si2dfmodelower>2<mask_name><round_name>"
5407   [(set (match_operand:<si2dfmode> 0 "register_operand" "=v")
5408         (unspec:<si2dfmode>
5409           [(match_operand:VF2_512_256VL 1 "nonimmediate_operand" "<round_constraint>")]
5410           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
5411   "TARGET_AVX512F"
5412   "vcvtpd2udq<pd2udqsuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5413   [(set_attr "type" "ssecvt")
5414    (set_attr "prefix" "evex")
5415    (set_attr "mode" "<sseinsnmode>")])
5417 (define_insn "ufix_notruncv2dfv2si2<mask_name>"
5418   [(set (match_operand:V4SI 0 "register_operand" "=v")
5419         (vec_concat:V4SI
5420           (unspec:V2SI
5421             [(match_operand:V2DF 1 "nonimmediate_operand" "vm")]
5422             UNSPEC_UNSIGNED_FIX_NOTRUNC)
5423           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5424   "TARGET_AVX512VL"
5425   "vcvtpd2udq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5426   [(set_attr "type" "ssecvt")
5427    (set_attr "prefix" "evex")
5428    (set_attr "mode" "TI")])
5430 (define_insn "fix<fixunssuffix>_truncv8dfv8si2<mask_name><round_saeonly_name>"
5431   [(set (match_operand:V8SI 0 "register_operand" "=v")
5432         (any_fix:V8SI
5433           (match_operand:V8DF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5434   "TARGET_AVX512F"
5435   "vcvttpd2<fixsuffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5436   [(set_attr "type" "ssecvt")
5437    (set_attr "prefix" "evex")
5438    (set_attr "mode" "OI")])
5440 (define_insn "ufix_truncv2dfv2si2<mask_name>"
5441   [(set (match_operand:V4SI 0 "register_operand" "=v")
5442         (vec_concat:V4SI
5443           (unsigned_fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "vm"))
5444           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5445   "TARGET_AVX512VL"
5446   "vcvttpd2udq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5447   [(set_attr "type" "ssecvt")
5448    (set_attr "prefix" "evex")
5449    (set_attr "mode" "TI")])
5451 (define_insn "fix_truncv4dfv4si2<mask_name>"
5452   [(set (match_operand:V4SI 0 "register_operand" "=v")
5453         (fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
5454   "TARGET_AVX || (TARGET_AVX512VL && TARGET_AVX512F)"
5455   "vcvttpd2dq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5456   [(set_attr "type" "ssecvt")
5457    (set_attr "prefix" "maybe_evex")
5458    (set_attr "mode" "OI")])
5460 (define_insn "ufix_truncv4dfv4si2<mask_name>"
5461   [(set (match_operand:V4SI 0 "register_operand" "=v")
5462         (unsigned_fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
5463   "TARGET_AVX512VL && TARGET_AVX512F"
5464   "vcvttpd2udq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5465   [(set_attr "type" "ssecvt")
5466    (set_attr "prefix" "maybe_evex")
5467    (set_attr "mode" "OI")])
5469 (define_insn "fix<fixunssuffix>_trunc<mode><sseintvecmodelower>2<mask_name><round_saeonly_name>"
5470   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5471         (any_fix:<sseintvecmode>
5472           (match_operand:VF2_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5473   "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
5474   "vcvttpd2<fixsuffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5475   [(set_attr "type" "ssecvt")
5476    (set_attr "prefix" "evex")
5477    (set_attr "mode" "<sseintvecmode2>")])
5479 (define_insn "fix_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>"
5480   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5481         (unspec:<sseintvecmode>
5482           [(match_operand:VF2_AVX512VL 1 "<round_nimm_predicate>" "<round_constraint>")]
5483           UNSPEC_FIX_NOTRUNC))]
5484   "TARGET_AVX512DQ && <round_mode512bit_condition>"
5485   "vcvtpd2qq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5486   [(set_attr "type" "ssecvt")
5487    (set_attr "prefix" "evex")
5488    (set_attr "mode" "<sseintvecmode2>")])
5490 (define_insn "ufix_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>"
5491   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5492         (unspec:<sseintvecmode>
5493           [(match_operand:VF2_AVX512VL 1 "nonimmediate_operand" "<round_constraint>")]
5494           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
5495   "TARGET_AVX512DQ && <round_mode512bit_condition>"
5496   "vcvtpd2uqq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5497   [(set_attr "type" "ssecvt")
5498    (set_attr "prefix" "evex")
5499    (set_attr "mode" "<sseintvecmode2>")])
5501 (define_insn "fix<fixunssuffix>_trunc<mode><sselongvecmodelower>2<mask_name><round_saeonly_name>"
5502   [(set (match_operand:<sselongvecmode> 0 "register_operand" "=v")
5503         (any_fix:<sselongvecmode>
5504           (match_operand:VF1_128_256VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5505   "TARGET_AVX512DQ && <round_saeonly_modev8sf_condition>"
5506   "vcvttps2<fixsuffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5507   [(set_attr "type" "ssecvt")
5508    (set_attr "prefix" "evex")
5509    (set_attr "mode" "<sseintvecmode3>")])
5511 (define_insn "fix<fixunssuffix>_truncv2sfv2di2<mask_name>"
5512   [(set (match_operand:V2DI 0 "register_operand" "=v")
5513         (any_fix:V2DI
5514           (vec_select:V2SF
5515             (match_operand:V4SF 1 "nonimmediate_operand" "vm")
5516             (parallel [(const_int 0) (const_int 1)]))))]
5517   "TARGET_AVX512DQ && TARGET_AVX512VL"
5518   "vcvttps2<fixsuffix>qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5519   [(set_attr "type" "ssecvt")
5520    (set_attr "prefix" "evex")
5521    (set_attr "mode" "TI")])
5523 (define_mode_attr vunpckfixt_mode
5524   [(V16SF "V8DI") (V8SF "V4DI") (V4SF "V2DI")])
5525 (define_mode_attr vunpckfixt_model
5526   [(V16SF "v8di") (V8SF "v4di") (V4SF "v2di")])
5527 (define_mode_attr vunpckfixt_extract_mode
5528   [(V16SF "v16sf") (V8SF "v8sf") (V4SF "v8sf")])
5530 (define_expand "vec_unpack_<fixprefix>fix_trunc_lo_<mode>"
5531   [(match_operand:<vunpckfixt_mode> 0 "register_operand")
5532    (any_fix:<vunpckfixt_mode>
5533      (match_operand:VF1_AVX512VL 1 "register_operand"))]
5534   "TARGET_AVX512DQ"
5536   rtx tem = operands[1];
5537   if (<MODE>mode != V4SFmode)
5538     {
5539       tem = gen_reg_rtx (<ssehalfvecmode>mode);
5540       emit_insn (gen_vec_extract_lo_<vunpckfixt_extract_mode> (tem,
5541                                                                operands[1]));
5542     }
5543   rtx (*gen) (rtx, rtx)
5544     = gen_fix<fixunssuffix>_trunc<ssehalfvecmodelower><vunpckfixt_model>2;
5545   emit_insn (gen (operands[0], tem));
5546   DONE;
5549 (define_expand "vec_unpack_<fixprefix>fix_trunc_hi_<mode>"
5550   [(match_operand:<vunpckfixt_mode> 0 "register_operand")
5551    (any_fix:<vunpckfixt_mode>
5552      (match_operand:VF1_AVX512VL 1 "register_operand"))]
5553   "TARGET_AVX512DQ"
5555   rtx tem;
5556   if (<MODE>mode != V4SFmode)
5557     {
5558       tem = gen_reg_rtx (<ssehalfvecmode>mode);
5559       emit_insn (gen_vec_extract_hi_<vunpckfixt_extract_mode> (tem,
5560                                                                operands[1]));
5561     }
5562   else
5563     {
5564       tem = gen_reg_rtx (V4SFmode);
5565       emit_insn (gen_avx_vpermilv4sf (tem, operands[1], GEN_INT (0x4e)));
5566     }
5567   rtx (*gen) (rtx, rtx)
5568     = gen_fix<fixunssuffix>_trunc<ssehalfvecmodelower><vunpckfixt_model>2;
5569   emit_insn (gen (operands[0], tem));
5570   DONE;
5573 (define_insn "ufix_trunc<mode><sseintvecmodelower>2<mask_name>"
5574   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5575         (unsigned_fix:<sseintvecmode>
5576           (match_operand:VF1_128_256VL 1 "nonimmediate_operand" "vm")))]
5577   "TARGET_AVX512VL"
5578   "vcvttps2udq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5579   [(set_attr "type" "ssecvt")
5580    (set_attr "prefix" "evex")
5581    (set_attr "mode" "<sseintvecmode2>")])
5583 (define_expand "avx_cvttpd2dq256_2"
5584   [(set (match_operand:V8SI 0 "register_operand")
5585         (vec_concat:V8SI
5586           (fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand"))
5587           (match_dup 2)))]
5588   "TARGET_AVX"
5589   "operands[2] = CONST0_RTX (V4SImode);")
5591 (define_insn "sse2_cvttpd2dq<mask_name>"
5592   [(set (match_operand:V4SI 0 "register_operand" "=v")
5593         (vec_concat:V4SI
5594           (fix:V2SI (match_operand:V2DF 1 "vector_operand" "vBm"))
5595           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5596   "TARGET_SSE2 && <mask_avx512vl_condition>"
5598   if (TARGET_AVX)
5599     return "vcvttpd2dq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
5600   else
5601     return "cvttpd2dq\t{%1, %0|%0, %1}";
5603   [(set_attr "type" "ssecvt")
5604    (set_attr "amdfam10_decode" "double")
5605    (set_attr "athlon_decode" "vector")
5606    (set_attr "bdver1_decode" "double")
5607    (set_attr "prefix" "maybe_vex")
5608    (set_attr "mode" "TI")])
5610 (define_insn "sse2_cvtsd2ss<round_name>"
5611   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
5612         (vec_merge:V4SF
5613           (vec_duplicate:V4SF
5614             (float_truncate:V2SF
5615               (match_operand:V2DF 2 "nonimmediate_operand" "x,m,<round_constraint>")))
5616           (match_operand:V4SF 1 "register_operand" "0,0,v")
5617           (const_int 1)))]
5618   "TARGET_SSE2"
5619   "@
5620    cvtsd2ss\t{%2, %0|%0, %2}
5621    cvtsd2ss\t{%2, %0|%0, %q2}
5622    vcvtsd2ss\t{<round_op3>%2, %1, %0|%0, %1, %q2<round_op3>}"
5623   [(set_attr "isa" "noavx,noavx,avx")
5624    (set_attr "type" "ssecvt")
5625    (set_attr "athlon_decode" "vector,double,*")
5626    (set_attr "amdfam10_decode" "vector,double,*")
5627    (set_attr "bdver1_decode" "direct,direct,*")
5628    (set_attr "btver2_decode" "double,double,double")
5629    (set_attr "prefix" "orig,orig,<round_prefix>")
5630    (set_attr "mode" "SF")])
5632 (define_insn "*sse2_vd_cvtsd2ss"
5633   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
5634         (vec_merge:V4SF
5635           (vec_duplicate:V4SF
5636             (float_truncate:SF (match_operand:DF 2 "nonimmediate_operand" "x,m,vm")))
5637           (match_operand:V4SF 1 "register_operand" "0,0,v")
5638           (const_int 1)))]
5639   "TARGET_SSE2"
5640   "@
5641    cvtsd2ss\t{%2, %0|%0, %2}
5642    cvtsd2ss\t{%2, %0|%0, %2}
5643    vcvtsd2ss\t{%2, %1, %0|%0, %1, %2}"
5644   [(set_attr "isa" "noavx,noavx,avx")
5645    (set_attr "type" "ssecvt")
5646    (set_attr "athlon_decode" "vector,double,*")
5647    (set_attr "amdfam10_decode" "vector,double,*")
5648    (set_attr "bdver1_decode" "direct,direct,*")
5649    (set_attr "btver2_decode" "double,double,double")
5650    (set_attr "prefix" "orig,orig,vex")
5651    (set_attr "mode" "SF")])
5653 (define_insn "sse2_cvtss2sd<round_saeonly_name>"
5654   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
5655         (vec_merge:V2DF
5656           (float_extend:V2DF
5657             (vec_select:V2SF
5658               (match_operand:V4SF 2 "<round_saeonly_nimm_scalar_predicate>" "x,m,<round_saeonly_constraint>")
5659               (parallel [(const_int 0) (const_int 1)])))
5660           (match_operand:V2DF 1 "register_operand" "0,0,v")
5661           (const_int 1)))]
5662   "TARGET_SSE2"
5663   "@
5664    cvtss2sd\t{%2, %0|%0, %2}
5665    cvtss2sd\t{%2, %0|%0, %k2}
5666    vcvtss2sd\t{<round_saeonly_op3>%2, %1, %0|%0, %1, %k2<round_saeonly_op3>}"
5667   [(set_attr "isa" "noavx,noavx,avx")
5668    (set_attr "type" "ssecvt")
5669    (set_attr "amdfam10_decode" "vector,double,*")
5670    (set_attr "athlon_decode" "direct,direct,*")
5671    (set_attr "bdver1_decode" "direct,direct,*")
5672    (set_attr "btver2_decode" "double,double,double")
5673    (set_attr "prefix" "orig,orig,<round_saeonly_prefix>")
5674    (set_attr "mode" "DF")])
5676 (define_insn "*sse2_vd_cvtss2sd"
5677   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
5678         (vec_merge:V2DF
5679           (vec_duplicate:V2DF
5680             (float_extend:DF (match_operand:SF 2 "nonimmediate_operand" "x,m,vm")))
5681           (match_operand:V2DF 1 "register_operand" "0,0,v")
5682           (const_int 1)))]
5683   "TARGET_SSE2"
5684   "@
5685    cvtss2sd\t{%2, %0|%0, %2}
5686    cvtss2sd\t{%2, %0|%0, %2}
5687    vcvtss2sd\t{%2, %1, %0|%0, %1, %2}"
5688   [(set_attr "isa" "noavx,noavx,avx")
5689    (set_attr "type" "ssecvt")
5690    (set_attr "amdfam10_decode" "vector,double,*")
5691    (set_attr "athlon_decode" "direct,direct,*")
5692    (set_attr "bdver1_decode" "direct,direct,*")
5693    (set_attr "btver2_decode" "double,double,double")
5694    (set_attr "prefix" "orig,orig,vex")
5695    (set_attr "mode" "DF")])
5697 (define_insn "<mask_codefor>avx512f_cvtpd2ps512<mask_name><round_name>"
5698   [(set (match_operand:V8SF 0 "register_operand" "=v")
5699         (float_truncate:V8SF
5700           (match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")))]
5701   "TARGET_AVX512F"
5702   "vcvtpd2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5703   [(set_attr "type" "ssecvt")
5704    (set_attr "prefix" "evex")
5705    (set_attr "mode" "V8SF")])
5707 (define_insn "avx_cvtpd2ps256<mask_name>"
5708   [(set (match_operand:V4SF 0 "register_operand" "=v")
5709         (float_truncate:V4SF
5710           (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
5711   "TARGET_AVX && <mask_avx512vl_condition>"
5712   "vcvtpd2ps{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5713   [(set_attr "type" "ssecvt")
5714    (set_attr "prefix" "maybe_evex")
5715    (set_attr "btver2_decode" "vector")
5716    (set_attr "mode" "V4SF")])
5718 (define_expand "sse2_cvtpd2ps"
5719   [(set (match_operand:V4SF 0 "register_operand")
5720         (vec_concat:V4SF
5721           (float_truncate:V2SF
5722             (match_operand:V2DF 1 "vector_operand"))
5723           (match_dup 2)))]
5724   "TARGET_SSE2"
5725   "operands[2] = CONST0_RTX (V2SFmode);")
5727 (define_expand "sse2_cvtpd2ps_mask"
5728   [(set (match_operand:V4SF 0 "register_operand")
5729         (vec_merge:V4SF
5730           (vec_concat:V4SF
5731             (float_truncate:V2SF
5732               (match_operand:V2DF 1 "vector_operand"))
5733             (match_dup 4))
5734           (match_operand:V4SF 2 "register_operand")
5735           (match_operand:QI 3 "register_operand")))]
5736   "TARGET_SSE2"
5737   "operands[4] = CONST0_RTX (V2SFmode);")
5739 (define_insn "*sse2_cvtpd2ps<mask_name>"
5740   [(set (match_operand:V4SF 0 "register_operand" "=v")
5741         (vec_concat:V4SF
5742           (float_truncate:V2SF
5743             (match_operand:V2DF 1 "vector_operand" "vBm"))
5744           (match_operand:V2SF 2 "const0_operand")))]
5745   "TARGET_SSE2 && <mask_avx512vl_condition>"
5747   if (TARGET_AVX)
5748     return "vcvtpd2ps{x}\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}";
5749   else
5750     return "cvtpd2ps\t{%1, %0|%0, %1}";
5752   [(set_attr "type" "ssecvt")
5753    (set_attr "amdfam10_decode" "double")
5754    (set_attr "athlon_decode" "vector")
5755    (set_attr "bdver1_decode" "double")
5756    (set_attr "prefix_data16" "1")
5757    (set_attr "prefix" "maybe_vex")
5758    (set_attr "mode" "V4SF")])
5760 ;; For <sse2_avx_avx512f>_cvtps2pd<avxsizesuffix> insn pattern
5761 (define_mode_attr sf2dfmode
5762   [(V8DF "V8SF") (V4DF "V4SF")])
5764 (define_insn "<sse2_avx_avx512f>_cvtps2pd<avxsizesuffix><mask_name><round_saeonly_name>"
5765   [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
5766         (float_extend:VF2_512_256
5767           (match_operand:<sf2dfmode> 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5768   "TARGET_AVX && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
5769   "vcvtps2pd\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5770   [(set_attr "type" "ssecvt")
5771    (set_attr "prefix" "maybe_vex")
5772    (set_attr "mode" "<MODE>")])
5774 (define_insn "*avx_cvtps2pd256_2"
5775   [(set (match_operand:V4DF 0 "register_operand" "=v")
5776         (float_extend:V4DF
5777           (vec_select:V4SF
5778             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
5779             (parallel [(const_int 0) (const_int 1)
5780                        (const_int 2) (const_int 3)]))))]
5781   "TARGET_AVX"
5782   "vcvtps2pd\t{%x1, %0|%0, %x1}"
5783   [(set_attr "type" "ssecvt")
5784    (set_attr "prefix" "vex")
5785    (set_attr "mode" "V4DF")])
5787 (define_insn "vec_unpacks_lo_v16sf"
5788   [(set (match_operand:V8DF 0 "register_operand" "=v")
5789         (float_extend:V8DF
5790           (vec_select:V8SF
5791             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
5792             (parallel [(const_int 0) (const_int 1)
5793                        (const_int 2) (const_int 3)
5794                        (const_int 4) (const_int 5)
5795                        (const_int 6) (const_int 7)]))))]
5796   "TARGET_AVX512F"
5797   "vcvtps2pd\t{%t1, %0|%0, %t1}"
5798   [(set_attr "type" "ssecvt")
5799    (set_attr "prefix" "evex")
5800    (set_attr "mode" "V8DF")])
5802 (define_insn "<avx512>_cvt<ssemodesuffix>2mask<mode>"
5803   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
5804         (unspec:<avx512fmaskmode>
5805          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")]
5806          UNSPEC_CVTINT2MASK))]
5807   "TARGET_AVX512BW"
5808   "vpmov<ssemodesuffix>2m\t{%1, %0|%0, %1}"
5809   [(set_attr "prefix" "evex")
5810    (set_attr "mode" "<sseinsnmode>")])
5812 (define_insn "<avx512>_cvt<ssemodesuffix>2mask<mode>"
5813   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
5814         (unspec:<avx512fmaskmode>
5815          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")]
5816          UNSPEC_CVTINT2MASK))]
5817   "TARGET_AVX512DQ"
5818   "vpmov<ssemodesuffix>2m\t{%1, %0|%0, %1}"
5819   [(set_attr "prefix" "evex")
5820    (set_attr "mode" "<sseinsnmode>")])
5822 (define_expand "<avx512>_cvtmask2<ssemodesuffix><mode>"
5823   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
5824         (vec_merge:VI12_AVX512VL
5825           (match_dup 2)
5826           (match_dup 3)
5827           (match_operand:<avx512fmaskmode> 1 "register_operand")))]
5828   "TARGET_AVX512BW"
5829   {
5830     operands[2] = CONSTM1_RTX (<MODE>mode);
5831     operands[3] = CONST0_RTX (<MODE>mode);
5832   })
5834 (define_insn "*<avx512>_cvtmask2<ssemodesuffix><mode>"
5835   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
5836         (vec_merge:VI12_AVX512VL
5837           (match_operand:VI12_AVX512VL 2 "vector_all_ones_operand")
5838           (match_operand:VI12_AVX512VL 3 "const0_operand")
5839           (match_operand:<avx512fmaskmode> 1 "register_operand" "Yk")))]
5840   "TARGET_AVX512BW"
5841   "vpmovm2<ssemodesuffix>\t{%1, %0|%0, %1}"
5842   [(set_attr "prefix" "evex")
5843    (set_attr "mode" "<sseinsnmode>")])
5845 (define_expand "<avx512>_cvtmask2<ssemodesuffix><mode>"
5846   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
5847         (vec_merge:VI48_AVX512VL
5848           (match_dup 2)
5849           (match_dup 3)
5850           (match_operand:<avx512fmaskmode> 1 "register_operand")))]
5851   "TARGET_AVX512DQ"
5852   "{
5853     operands[2] = CONSTM1_RTX (<MODE>mode);
5854     operands[3] = CONST0_RTX (<MODE>mode);
5855   }")
5857 (define_insn "*<avx512>_cvtmask2<ssemodesuffix><mode>"
5858   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
5859         (vec_merge:VI48_AVX512VL
5860           (match_operand:VI48_AVX512VL 2 "vector_all_ones_operand")
5861           (match_operand:VI48_AVX512VL 3 "const0_operand")
5862           (match_operand:<avx512fmaskmode> 1 "register_operand" "Yk")))]
5863   "TARGET_AVX512DQ"
5864   "vpmovm2<ssemodesuffix>\t{%1, %0|%0, %1}"
5865   [(set_attr "prefix" "evex")
5866    (set_attr "mode" "<sseinsnmode>")])
5868 (define_insn "sse2_cvtps2pd<mask_name>"
5869   [(set (match_operand:V2DF 0 "register_operand" "=v")
5870         (float_extend:V2DF
5871           (vec_select:V2SF
5872             (match_operand:V4SF 1 "vector_operand" "vm")
5873             (parallel [(const_int 0) (const_int 1)]))))]
5874   "TARGET_SSE2 && <mask_avx512vl_condition>"
5875   "%vcvtps2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5876   [(set_attr "type" "ssecvt")
5877    (set_attr "amdfam10_decode" "direct")
5878    (set_attr "athlon_decode" "double")
5879    (set_attr "bdver1_decode" "double")
5880    (set_attr "prefix_data16" "0")
5881    (set_attr "prefix" "maybe_vex")
5882    (set_attr "mode" "V2DF")])
5884 (define_expand "vec_unpacks_hi_v4sf"
5885   [(set (match_dup 2)
5886    (vec_select:V4SF
5887      (vec_concat:V8SF
5888        (match_dup 2)
5889        (match_operand:V4SF 1 "vector_operand"))
5890      (parallel [(const_int 6) (const_int 7)
5891                 (const_int 2) (const_int 3)])))
5892   (set (match_operand:V2DF 0 "register_operand")
5893    (float_extend:V2DF
5894      (vec_select:V2SF
5895        (match_dup 2)
5896        (parallel [(const_int 0) (const_int 1)]))))]
5897   "TARGET_SSE2"
5898   "operands[2] = gen_reg_rtx (V4SFmode);")
5900 (define_expand "vec_unpacks_hi_v8sf"
5901   [(set (match_dup 2)
5902         (vec_select:V4SF
5903           (match_operand:V8SF 1 "register_operand")
5904           (parallel [(const_int 4) (const_int 5)
5905                      (const_int 6) (const_int 7)])))
5906    (set (match_operand:V4DF 0 "register_operand")
5907         (float_extend:V4DF
5908           (match_dup 2)))]
5909   "TARGET_AVX"
5910   "operands[2] = gen_reg_rtx (V4SFmode);")
5912 (define_expand "vec_unpacks_hi_v16sf"
5913   [(set (match_dup 2)
5914         (vec_select:V8SF
5915           (match_operand:V16SF 1 "register_operand")
5916           (parallel [(const_int 8) (const_int 9)
5917                      (const_int 10) (const_int 11)
5918                      (const_int 12) (const_int 13)
5919                      (const_int 14) (const_int 15)])))
5920    (set (match_operand:V8DF 0 "register_operand")
5921         (float_extend:V8DF
5922           (match_dup 2)))]
5923 "TARGET_AVX512F"
5924 "operands[2] = gen_reg_rtx (V8SFmode);")
5926 (define_expand "vec_unpacks_lo_v4sf"
5927   [(set (match_operand:V2DF 0 "register_operand")
5928         (float_extend:V2DF
5929           (vec_select:V2SF
5930             (match_operand:V4SF 1 "vector_operand")
5931             (parallel [(const_int 0) (const_int 1)]))))]
5932   "TARGET_SSE2")
5934 (define_expand "vec_unpacks_lo_v8sf"
5935   [(set (match_operand:V4DF 0 "register_operand")
5936         (float_extend:V4DF
5937           (vec_select:V4SF
5938             (match_operand:V8SF 1 "nonimmediate_operand")
5939             (parallel [(const_int 0) (const_int 1)
5940                        (const_int 2) (const_int 3)]))))]
5941   "TARGET_AVX")
5943 (define_mode_attr sseunpackfltmode
5944   [(V8HI "V4SF") (V4SI "V2DF") (V16HI "V8SF")
5945   (V8SI "V4DF") (V32HI "V16SF") (V16SI "V8DF")])
5947 (define_expand "vec_unpacks_float_hi_<mode>"
5948   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5949    (match_operand:VI2_AVX512F 1 "register_operand")]
5950   "TARGET_SSE2"
5952   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5954   emit_insn (gen_vec_unpacks_hi_<mode> (tmp, operands[1]));
5955   emit_insn (gen_rtx_SET (operands[0],
5956                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5957   DONE;
5960 (define_expand "vec_unpacks_float_lo_<mode>"
5961   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5962    (match_operand:VI2_AVX512F 1 "register_operand")]
5963   "TARGET_SSE2"
5965   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5967   emit_insn (gen_vec_unpacks_lo_<mode> (tmp, operands[1]));
5968   emit_insn (gen_rtx_SET (operands[0],
5969                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5970   DONE;
5973 (define_expand "vec_unpacku_float_hi_<mode>"
5974   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5975    (match_operand:VI2_AVX512F 1 "register_operand")]
5976   "TARGET_SSE2"
5978   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5980   emit_insn (gen_vec_unpacku_hi_<mode> (tmp, operands[1]));
5981   emit_insn (gen_rtx_SET (operands[0],
5982                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5983   DONE;
5986 (define_expand "vec_unpacku_float_lo_<mode>"
5987   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5988    (match_operand:VI2_AVX512F 1 "register_operand")]
5989   "TARGET_SSE2"
5991   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5993   emit_insn (gen_vec_unpacku_lo_<mode> (tmp, operands[1]));
5994   emit_insn (gen_rtx_SET (operands[0],
5995                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5996   DONE;
5999 (define_expand "vec_unpacks_float_hi_v4si"
6000   [(set (match_dup 2)
6001         (vec_select:V4SI
6002           (match_operand:V4SI 1 "vector_operand")
6003           (parallel [(const_int 2) (const_int 3)
6004                      (const_int 2) (const_int 3)])))
6005    (set (match_operand:V2DF 0 "register_operand")
6006         (float:V2DF
6007           (vec_select:V2SI
6008           (match_dup 2)
6009             (parallel [(const_int 0) (const_int 1)]))))]
6010   "TARGET_SSE2"
6011   "operands[2] = gen_reg_rtx (V4SImode);")
6013 (define_expand "vec_unpacks_float_lo_v4si"
6014   [(set (match_operand:V2DF 0 "register_operand")
6015         (float:V2DF
6016           (vec_select:V2SI
6017             (match_operand:V4SI 1 "vector_operand")
6018             (parallel [(const_int 0) (const_int 1)]))))]
6019   "TARGET_SSE2")
6021 (define_expand "vec_unpacks_float_hi_v8si"
6022   [(set (match_dup 2)
6023         (vec_select:V4SI
6024           (match_operand:V8SI 1 "vector_operand")
6025           (parallel [(const_int 4) (const_int 5)
6026                      (const_int 6) (const_int 7)])))
6027    (set (match_operand:V4DF 0 "register_operand")
6028         (float:V4DF
6029           (match_dup 2)))]
6030   "TARGET_AVX"
6031   "operands[2] = gen_reg_rtx (V4SImode);")
6033 (define_expand "vec_unpacks_float_lo_v8si"
6034   [(set (match_operand:V4DF 0 "register_operand")
6035         (float:V4DF
6036           (vec_select:V4SI
6037             (match_operand:V8SI 1 "nonimmediate_operand")
6038             (parallel [(const_int 0) (const_int 1)
6039                        (const_int 2) (const_int 3)]))))]
6040   "TARGET_AVX")
6042 (define_expand "vec_unpacks_float_hi_v16si"
6043   [(set (match_dup 2)
6044         (vec_select:V8SI
6045           (match_operand:V16SI 1 "nonimmediate_operand")
6046           (parallel [(const_int 8) (const_int 9)
6047                      (const_int 10) (const_int 11)
6048                      (const_int 12) (const_int 13)
6049                      (const_int 14) (const_int 15)])))
6050    (set (match_operand:V8DF 0 "register_operand")
6051         (float:V8DF
6052           (match_dup 2)))]
6053   "TARGET_AVX512F"
6054   "operands[2] = gen_reg_rtx (V8SImode);")
6056 (define_expand "vec_unpacks_float_lo_v16si"
6057   [(set (match_operand:V8DF 0 "register_operand")
6058         (float:V8DF
6059           (vec_select:V8SI
6060             (match_operand:V16SI 1 "nonimmediate_operand")
6061             (parallel [(const_int 0) (const_int 1)
6062                        (const_int 2) (const_int 3)
6063                        (const_int 4) (const_int 5)
6064                        (const_int 6) (const_int 7)]))))]
6065   "TARGET_AVX512F")
6067 (define_expand "vec_unpacku_float_hi_v4si"
6068   [(set (match_dup 5)
6069         (vec_select:V4SI
6070           (match_operand:V4SI 1 "vector_operand")
6071           (parallel [(const_int 2) (const_int 3)
6072                      (const_int 2) (const_int 3)])))
6073    (set (match_dup 6)
6074         (float:V2DF
6075           (vec_select:V2SI
6076           (match_dup 5)
6077             (parallel [(const_int 0) (const_int 1)]))))
6078    (set (match_dup 7)
6079         (lt:V2DF (match_dup 6) (match_dup 3)))
6080    (set (match_dup 8)
6081         (and:V2DF (match_dup 7) (match_dup 4)))
6082    (set (match_operand:V2DF 0 "register_operand")
6083         (plus:V2DF (match_dup 6) (match_dup 8)))]
6084   "TARGET_SSE2"
6086   REAL_VALUE_TYPE TWO32r;
6087   rtx x;
6088   int i;
6090   real_ldexp (&TWO32r, &dconst1, 32);
6091   x = const_double_from_real_value (TWO32r, DFmode);
6093   operands[3] = force_reg (V2DFmode, CONST0_RTX (V2DFmode));
6094   operands[4] = force_reg (V2DFmode,
6095                            ix86_build_const_vector (V2DFmode, 1, x));
6097   operands[5] = gen_reg_rtx (V4SImode);
6099   for (i = 6; i < 9; i++)
6100     operands[i] = gen_reg_rtx (V2DFmode);
6103 (define_expand "vec_unpacku_float_lo_v4si"
6104   [(set (match_dup 5)
6105         (float:V2DF
6106           (vec_select:V2SI
6107             (match_operand:V4SI 1 "vector_operand")
6108             (parallel [(const_int 0) (const_int 1)]))))
6109    (set (match_dup 6)
6110         (lt:V2DF (match_dup 5) (match_dup 3)))
6111    (set (match_dup 7)
6112         (and:V2DF (match_dup 6) (match_dup 4)))
6113    (set (match_operand:V2DF 0 "register_operand")
6114         (plus:V2DF (match_dup 5) (match_dup 7)))]
6115   "TARGET_SSE2"
6117   REAL_VALUE_TYPE TWO32r;
6118   rtx x;
6119   int i;
6121   real_ldexp (&TWO32r, &dconst1, 32);
6122   x = const_double_from_real_value (TWO32r, DFmode);
6124   operands[3] = force_reg (V2DFmode, CONST0_RTX (V2DFmode));
6125   operands[4] = force_reg (V2DFmode,
6126                            ix86_build_const_vector (V2DFmode, 1, x));
6128   for (i = 5; i < 8; i++)
6129     operands[i] = gen_reg_rtx (V2DFmode);
6132 (define_expand "vec_unpacku_float_hi_v8si"
6133   [(match_operand:V4DF 0 "register_operand")
6134    (match_operand:V8SI 1 "register_operand")]
6135   "TARGET_AVX"
6137   REAL_VALUE_TYPE TWO32r;
6138   rtx x, tmp[6];
6139   int i;
6141   real_ldexp (&TWO32r, &dconst1, 32);
6142   x = const_double_from_real_value (TWO32r, DFmode);
6144   tmp[0] = force_reg (V4DFmode, CONST0_RTX (V4DFmode));
6145   tmp[1] = force_reg (V4DFmode, ix86_build_const_vector (V4DFmode, 1, x));
6146   tmp[5] = gen_reg_rtx (V4SImode);
6148   for (i = 2; i < 5; i++)
6149     tmp[i] = gen_reg_rtx (V4DFmode);
6150   emit_insn (gen_vec_extract_hi_v8si (tmp[5], operands[1]));
6151   emit_insn (gen_floatv4siv4df2 (tmp[2], tmp[5]));
6152   emit_insn (gen_rtx_SET (tmp[3], gen_rtx_LT (V4DFmode, tmp[2], tmp[0])));
6153   emit_insn (gen_andv4df3 (tmp[4], tmp[3], tmp[1]));
6154   emit_insn (gen_addv4df3 (operands[0], tmp[2], tmp[4]));
6155   DONE;
6158 (define_expand "vec_unpacku_float_hi_v16si"
6159   [(match_operand:V8DF 0 "register_operand")
6160    (match_operand:V16SI 1 "register_operand")]
6161   "TARGET_AVX512F"
6163   REAL_VALUE_TYPE TWO32r;
6164   rtx k, x, tmp[4];
6166   real_ldexp (&TWO32r, &dconst1, 32);
6167   x = const_double_from_real_value (TWO32r, DFmode);
6169   tmp[0] = force_reg (V8DFmode, CONST0_RTX (V8DFmode));
6170   tmp[1] = force_reg (V8DFmode, ix86_build_const_vector (V8DFmode, 1, x));
6171   tmp[2] = gen_reg_rtx (V8DFmode);
6172   tmp[3] = gen_reg_rtx (V8SImode);
6173   k = gen_reg_rtx (QImode);
6175   emit_insn (gen_vec_extract_hi_v16si (tmp[3], operands[1]));
6176   emit_insn (gen_floatv8siv8df2 (tmp[2], tmp[3]));
6177   emit_insn (gen_rtx_SET (k, gen_rtx_LT (QImode, tmp[2], tmp[0])));
6178   emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k));
6179   emit_move_insn (operands[0], tmp[2]);
6180   DONE;
6183 (define_expand "vec_unpacku_float_lo_v8si"
6184   [(match_operand:V4DF 0 "register_operand")
6185    (match_operand:V8SI 1 "nonimmediate_operand")]
6186   "TARGET_AVX"
6188   REAL_VALUE_TYPE TWO32r;
6189   rtx x, tmp[5];
6190   int i;
6192   real_ldexp (&TWO32r, &dconst1, 32);
6193   x = const_double_from_real_value (TWO32r, DFmode);
6195   tmp[0] = force_reg (V4DFmode, CONST0_RTX (V4DFmode));
6196   tmp[1] = force_reg (V4DFmode, ix86_build_const_vector (V4DFmode, 1, x));
6198   for (i = 2; i < 5; i++)
6199     tmp[i] = gen_reg_rtx (V4DFmode);
6200   emit_insn (gen_avx_cvtdq2pd256_2 (tmp[2], operands[1]));
6201   emit_insn (gen_rtx_SET (tmp[3], gen_rtx_LT (V4DFmode, tmp[2], tmp[0])));
6202   emit_insn (gen_andv4df3 (tmp[4], tmp[3], tmp[1]));
6203   emit_insn (gen_addv4df3 (operands[0], tmp[2], tmp[4]));
6204   DONE;
6207 (define_expand "vec_unpacku_float_lo_v16si"
6208   [(match_operand:V8DF 0 "register_operand")
6209    (match_operand:V16SI 1 "nonimmediate_operand")]
6210   "TARGET_AVX512F"
6212   REAL_VALUE_TYPE TWO32r;
6213   rtx k, x, tmp[3];
6215   real_ldexp (&TWO32r, &dconst1, 32);
6216   x = const_double_from_real_value (TWO32r, DFmode);
6218   tmp[0] = force_reg (V8DFmode, CONST0_RTX (V8DFmode));
6219   tmp[1] = force_reg (V8DFmode, ix86_build_const_vector (V8DFmode, 1, x));
6220   tmp[2] = gen_reg_rtx (V8DFmode);
6221   k = gen_reg_rtx (QImode);
6223   emit_insn (gen_avx512f_cvtdq2pd512_2 (tmp[2], operands[1]));
6224   emit_insn (gen_rtx_SET (k, gen_rtx_LT (QImode, tmp[2], tmp[0])));
6225   emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k));
6226   emit_move_insn (operands[0], tmp[2]);
6227   DONE;
6230 (define_expand "vec_pack_trunc_<mode>"
6231   [(set (match_dup 3)
6232         (float_truncate:<sf2dfmode>
6233           (match_operand:VF2_512_256 1 "nonimmediate_operand")))
6234    (set (match_dup 4)
6235         (float_truncate:<sf2dfmode>
6236           (match_operand:VF2_512_256 2 "nonimmediate_operand")))
6237    (set (match_operand:<ssePSmode> 0 "register_operand")
6238         (vec_concat:<ssePSmode>
6239           (match_dup 3)
6240           (match_dup 4)))]
6241   "TARGET_AVX"
6243   operands[3] = gen_reg_rtx (<sf2dfmode>mode);
6244   operands[4] = gen_reg_rtx (<sf2dfmode>mode);
6247 (define_expand "vec_pack_trunc_v2df"
6248   [(match_operand:V4SF 0 "register_operand")
6249    (match_operand:V2DF 1 "vector_operand")
6250    (match_operand:V2DF 2 "vector_operand")]
6251   "TARGET_SSE2"
6253   rtx tmp0, tmp1;
6255   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
6256     {
6257       tmp0 = gen_reg_rtx (V4DFmode);
6258       tmp1 = force_reg (V2DFmode, operands[1]);
6260       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
6261       emit_insn (gen_avx_cvtpd2ps256 (operands[0], tmp0));
6262     }
6263   else
6264     {
6265       tmp0 = gen_reg_rtx (V4SFmode);
6266       tmp1 = gen_reg_rtx (V4SFmode);
6268       emit_insn (gen_sse2_cvtpd2ps (tmp0, operands[1]));
6269       emit_insn (gen_sse2_cvtpd2ps (tmp1, operands[2]));
6270       emit_insn (gen_sse_movlhps (operands[0], tmp0, tmp1));
6271     }
6272   DONE;
6275 (define_expand "vec_pack_sfix_trunc_v8df"
6276   [(match_operand:V16SI 0 "register_operand")
6277    (match_operand:V8DF 1 "nonimmediate_operand")
6278    (match_operand:V8DF 2 "nonimmediate_operand")]
6279   "TARGET_AVX512F"
6281   rtx r1, r2;
6283   r1 = gen_reg_rtx (V8SImode);
6284   r2 = gen_reg_rtx (V8SImode);
6286   emit_insn (gen_fix_truncv8dfv8si2 (r1, operands[1]));
6287   emit_insn (gen_fix_truncv8dfv8si2 (r2, operands[2]));
6288   emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
6289   DONE;
6292 (define_expand "vec_pack_sfix_trunc_v4df"
6293   [(match_operand:V8SI 0 "register_operand")
6294    (match_operand:V4DF 1 "nonimmediate_operand")
6295    (match_operand:V4DF 2 "nonimmediate_operand")]
6296   "TARGET_AVX"
6298   rtx r1, r2;
6300   r1 = gen_reg_rtx (V4SImode);
6301   r2 = gen_reg_rtx (V4SImode);
6303   emit_insn (gen_fix_truncv4dfv4si2 (r1, operands[1]));
6304   emit_insn (gen_fix_truncv4dfv4si2 (r2, operands[2]));
6305   emit_insn (gen_avx_vec_concatv8si (operands[0], r1, r2));
6306   DONE;
6309 (define_expand "vec_pack_sfix_trunc_v2df"
6310   [(match_operand:V4SI 0 "register_operand")
6311    (match_operand:V2DF 1 "vector_operand")
6312    (match_operand:V2DF 2 "vector_operand")]
6313   "TARGET_SSE2"
6315   rtx tmp0, tmp1, tmp2;
6317   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
6318     {
6319       tmp0 = gen_reg_rtx (V4DFmode);
6320       tmp1 = force_reg (V2DFmode, operands[1]);
6322       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
6323       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp0));
6324     }
6325   else
6326     {
6327       tmp0 = gen_reg_rtx (V4SImode);
6328       tmp1 = gen_reg_rtx (V4SImode);
6329       tmp2 = gen_reg_rtx (V2DImode);
6331       emit_insn (gen_sse2_cvttpd2dq (tmp0, operands[1]));
6332       emit_insn (gen_sse2_cvttpd2dq (tmp1, operands[2]));
6333       emit_insn (gen_vec_interleave_lowv2di (tmp2,
6334                                              gen_lowpart (V2DImode, tmp0),
6335                                              gen_lowpart (V2DImode, tmp1)));
6336       emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp2));
6337     }
6338   DONE;
6341 (define_mode_attr ssepackfltmode
6342   [(V8DF "V16SI") (V4DF "V8SI") (V2DF "V4SI")])
6344 (define_expand "vec_pack_ufix_trunc_<mode>"
6345   [(match_operand:<ssepackfltmode> 0 "register_operand")
6346    (match_operand:VF2 1 "register_operand")
6347    (match_operand:VF2 2 "register_operand")]
6348   "TARGET_SSE2"
6350   if (<MODE>mode == V8DFmode)
6351     {
6352       rtx r1, r2;
6354       r1 = gen_reg_rtx (V8SImode);
6355       r2 = gen_reg_rtx (V8SImode);
6357       emit_insn (gen_fixuns_truncv8dfv8si2 (r1, operands[1]));
6358       emit_insn (gen_fixuns_truncv8dfv8si2 (r2, operands[2]));
6359       emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
6360     }
6361   else
6362     {
6363       rtx tmp[7];
6364       tmp[0] = ix86_expand_adjust_ufix_to_sfix_si (operands[1], &tmp[2]);
6365       tmp[1] = ix86_expand_adjust_ufix_to_sfix_si (operands[2], &tmp[3]);
6366       tmp[4] = gen_reg_rtx (<ssepackfltmode>mode);
6367       emit_insn (gen_vec_pack_sfix_trunc_<mode> (tmp[4], tmp[0], tmp[1]));
6368       if (<ssepackfltmode>mode == V4SImode || TARGET_AVX2)
6369         {
6370           tmp[5] = gen_reg_rtx (<ssepackfltmode>mode);
6371           ix86_expand_vec_extract_even_odd (tmp[5], tmp[2], tmp[3], 0);
6372         }
6373       else
6374         {
6375           tmp[5] = gen_reg_rtx (V8SFmode);
6376           ix86_expand_vec_extract_even_odd (tmp[5],
6377                                             gen_lowpart (V8SFmode, tmp[2]),
6378                                             gen_lowpart (V8SFmode, tmp[3]), 0);
6379           tmp[5] = gen_lowpart (V8SImode, tmp[5]);
6380         }
6381       tmp[6] = expand_simple_binop (<ssepackfltmode>mode, XOR, tmp[4], tmp[5],
6382                                     operands[0], 0, OPTAB_DIRECT);
6383       if (tmp[6] != operands[0])
6384         emit_move_insn (operands[0], tmp[6]);
6385     }
6387   DONE;
6390 (define_expand "avx512f_vec_pack_sfix_v8df"
6391   [(match_operand:V16SI 0 "register_operand")
6392    (match_operand:V8DF 1 "nonimmediate_operand")
6393    (match_operand:V8DF 2 "nonimmediate_operand")]
6394   "TARGET_AVX512F"
6396   rtx r1, r2;
6398   r1 = gen_reg_rtx (V8SImode);
6399   r2 = gen_reg_rtx (V8SImode);
6401   emit_insn (gen_avx512f_cvtpd2dq512 (r1, operands[1]));
6402   emit_insn (gen_avx512f_cvtpd2dq512 (r2, operands[2]));
6403   emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
6404   DONE;
6407 (define_expand "vec_pack_sfix_v4df"
6408   [(match_operand:V8SI 0 "register_operand")
6409    (match_operand:V4DF 1 "nonimmediate_operand")
6410    (match_operand:V4DF 2 "nonimmediate_operand")]
6411   "TARGET_AVX"
6413   rtx r1, r2;
6415   r1 = gen_reg_rtx (V4SImode);
6416   r2 = gen_reg_rtx (V4SImode);
6418   emit_insn (gen_avx_cvtpd2dq256 (r1, operands[1]));
6419   emit_insn (gen_avx_cvtpd2dq256 (r2, operands[2]));
6420   emit_insn (gen_avx_vec_concatv8si (operands[0], r1, r2));
6421   DONE;
6424 (define_expand "vec_pack_sfix_v2df"
6425   [(match_operand:V4SI 0 "register_operand")
6426    (match_operand:V2DF 1 "vector_operand")
6427    (match_operand:V2DF 2 "vector_operand")]
6428   "TARGET_SSE2"
6430   rtx tmp0, tmp1, tmp2;
6432   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
6433     {
6434       tmp0 = gen_reg_rtx (V4DFmode);
6435       tmp1 = force_reg (V2DFmode, operands[1]);
6437       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
6438       emit_insn (gen_avx_cvtpd2dq256 (operands[0], tmp0));
6439     }
6440   else
6441     {
6442       tmp0 = gen_reg_rtx (V4SImode);
6443       tmp1 = gen_reg_rtx (V4SImode);
6444       tmp2 = gen_reg_rtx (V2DImode);
6446       emit_insn (gen_sse2_cvtpd2dq (tmp0, operands[1]));
6447       emit_insn (gen_sse2_cvtpd2dq (tmp1, operands[2]));
6448       emit_insn (gen_vec_interleave_lowv2di (tmp2,
6449                                              gen_lowpart (V2DImode, tmp0),
6450                                              gen_lowpart (V2DImode, tmp1)));
6451       emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp2));
6452     }
6453   DONE;
6456 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6458 ;; Parallel single-precision floating point element swizzling
6460 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6462 (define_expand "sse_movhlps_exp"
6463   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6464         (vec_select:V4SF
6465           (vec_concat:V8SF
6466             (match_operand:V4SF 1 "nonimmediate_operand")
6467             (match_operand:V4SF 2 "nonimmediate_operand"))
6468           (parallel [(const_int 6)
6469                      (const_int 7)
6470                      (const_int 2)
6471                      (const_int 3)])))]
6472   "TARGET_SSE"
6474   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6476   emit_insn (gen_sse_movhlps (dst, operands[1], operands[2]));
6478   /* Fix up the destination if needed.  */
6479   if (dst != operands[0])
6480     emit_move_insn (operands[0], dst);
6482   DONE;
6485 (define_insn "sse_movhlps"
6486   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,m")
6487         (vec_select:V4SF
6488           (vec_concat:V8SF
6489             (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
6490             (match_operand:V4SF 2 "nonimmediate_operand" " x,v,o,o,v"))
6491           (parallel [(const_int 6)
6492                      (const_int 7)
6493                      (const_int 2)
6494                      (const_int 3)])))]
6495   "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
6496   "@
6497    movhlps\t{%2, %0|%0, %2}
6498    vmovhlps\t{%2, %1, %0|%0, %1, %2}
6499    movlps\t{%H2, %0|%0, %H2}
6500    vmovlps\t{%H2, %1, %0|%0, %1, %H2}
6501    %vmovhps\t{%2, %0|%q0, %2}"
6502   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6503    (set_attr "type" "ssemov")
6504    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
6505    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
6507 (define_expand "sse_movlhps_exp"
6508   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6509         (vec_select:V4SF
6510           (vec_concat:V8SF
6511             (match_operand:V4SF 1 "nonimmediate_operand")
6512             (match_operand:V4SF 2 "nonimmediate_operand"))
6513           (parallel [(const_int 0)
6514                      (const_int 1)
6515                      (const_int 4)
6516                      (const_int 5)])))]
6517   "TARGET_SSE"
6519   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6521   emit_insn (gen_sse_movlhps (dst, operands[1], operands[2]));
6523   /* Fix up the destination if needed.  */
6524   if (dst != operands[0])
6525     emit_move_insn (operands[0], dst);
6527   DONE;
6530 (define_insn "sse_movlhps"
6531   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,o")
6532         (vec_select:V4SF
6533           (vec_concat:V8SF
6534             (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
6535             (match_operand:V4SF 2 "nonimmediate_operand" " x,v,m,v,v"))
6536           (parallel [(const_int 0)
6537                      (const_int 1)
6538                      (const_int 4)
6539                      (const_int 5)])))]
6540   "TARGET_SSE && ix86_binary_operator_ok (UNKNOWN, V4SFmode, operands)"
6541   "@
6542    movlhps\t{%2, %0|%0, %2}
6543    vmovlhps\t{%2, %1, %0|%0, %1, %2}
6544    movhps\t{%2, %0|%0, %q2}
6545    vmovhps\t{%2, %1, %0|%0, %1, %q2}
6546    %vmovlps\t{%2, %H0|%H0, %2}"
6547   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6548    (set_attr "type" "ssemov")
6549    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
6550    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
6552 (define_insn "<mask_codefor>avx512f_unpckhps512<mask_name>"
6553   [(set (match_operand:V16SF 0 "register_operand" "=v")
6554         (vec_select:V16SF
6555           (vec_concat:V32SF
6556             (match_operand:V16SF 1 "register_operand" "v")
6557             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
6558           (parallel [(const_int 2) (const_int 18)
6559                      (const_int 3) (const_int 19)
6560                      (const_int 6) (const_int 22)
6561                      (const_int 7) (const_int 23)
6562                      (const_int 10) (const_int 26)
6563                      (const_int 11) (const_int 27)
6564                      (const_int 14) (const_int 30)
6565                      (const_int 15) (const_int 31)])))]
6566   "TARGET_AVX512F"
6567   "vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6568   [(set_attr "type" "sselog")
6569    (set_attr "prefix" "evex")
6570    (set_attr "mode" "V16SF")])
6572 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
6573 (define_insn "avx_unpckhps256<mask_name>"
6574   [(set (match_operand:V8SF 0 "register_operand" "=v")
6575         (vec_select:V8SF
6576           (vec_concat:V16SF
6577             (match_operand:V8SF 1 "register_operand" "v")
6578             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6579           (parallel [(const_int 2) (const_int 10)
6580                      (const_int 3) (const_int 11)
6581                      (const_int 6) (const_int 14)
6582                      (const_int 7) (const_int 15)])))]
6583   "TARGET_AVX && <mask_avx512vl_condition>"
6584   "vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6585   [(set_attr "type" "sselog")
6586    (set_attr "prefix" "vex")
6587    (set_attr "mode" "V8SF")])
6589 (define_expand "vec_interleave_highv8sf"
6590   [(set (match_dup 3)
6591         (vec_select:V8SF
6592           (vec_concat:V16SF
6593             (match_operand:V8SF 1 "register_operand")
6594             (match_operand:V8SF 2 "nonimmediate_operand"))
6595           (parallel [(const_int 0) (const_int 8)
6596                      (const_int 1) (const_int 9)
6597                      (const_int 4) (const_int 12)
6598                      (const_int 5) (const_int 13)])))
6599    (set (match_dup 4)
6600         (vec_select:V8SF
6601           (vec_concat:V16SF
6602             (match_dup 1)
6603             (match_dup 2))
6604           (parallel [(const_int 2) (const_int 10)
6605                      (const_int 3) (const_int 11)
6606                      (const_int 6) (const_int 14)
6607                      (const_int 7) (const_int 15)])))
6608    (set (match_operand:V8SF 0 "register_operand")
6609         (vec_select:V8SF
6610           (vec_concat:V16SF
6611             (match_dup 3)
6612             (match_dup 4))
6613           (parallel [(const_int 4) (const_int 5)
6614                      (const_int 6) (const_int 7)
6615                      (const_int 12) (const_int 13)
6616                      (const_int 14) (const_int 15)])))]
6617  "TARGET_AVX"
6619   operands[3] = gen_reg_rtx (V8SFmode);
6620   operands[4] = gen_reg_rtx (V8SFmode);
6623 (define_insn "vec_interleave_highv4sf<mask_name>"
6624   [(set (match_operand:V4SF 0 "register_operand" "=x,v")
6625         (vec_select:V4SF
6626           (vec_concat:V8SF
6627             (match_operand:V4SF 1 "register_operand" "0,v")
6628             (match_operand:V4SF 2 "vector_operand" "xBm,vm"))
6629           (parallel [(const_int 2) (const_int 6)
6630                      (const_int 3) (const_int 7)])))]
6631   "TARGET_SSE && <mask_avx512vl_condition>"
6632   "@
6633    unpckhps\t{%2, %0|%0, %2}
6634    vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6635   [(set_attr "isa" "noavx,avx")
6636    (set_attr "type" "sselog")
6637    (set_attr "prefix" "orig,vex")
6638    (set_attr "mode" "V4SF")])
6640 (define_insn "<mask_codefor>avx512f_unpcklps512<mask_name>"
6641   [(set (match_operand:V16SF 0 "register_operand" "=v")
6642         (vec_select:V16SF
6643           (vec_concat:V32SF
6644             (match_operand:V16SF 1 "register_operand" "v")
6645             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
6646           (parallel [(const_int 0) (const_int 16)
6647                      (const_int 1) (const_int 17)
6648                      (const_int 4) (const_int 20)
6649                      (const_int 5) (const_int 21)
6650                      (const_int 8) (const_int 24)
6651                      (const_int 9) (const_int 25)
6652                      (const_int 12) (const_int 28)
6653                      (const_int 13) (const_int 29)])))]
6654   "TARGET_AVX512F"
6655   "vunpcklps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6656   [(set_attr "type" "sselog")
6657    (set_attr "prefix" "evex")
6658    (set_attr "mode" "V16SF")])
6660 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
6661 (define_insn "avx_unpcklps256<mask_name>"
6662   [(set (match_operand:V8SF 0 "register_operand" "=v")
6663         (vec_select:V8SF
6664           (vec_concat:V16SF
6665             (match_operand:V8SF 1 "register_operand" "v")
6666             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6667           (parallel [(const_int 0) (const_int 8)
6668                      (const_int 1) (const_int 9)
6669                      (const_int 4) (const_int 12)
6670                      (const_int 5) (const_int 13)])))]
6671   "TARGET_AVX && <mask_avx512vl_condition>"
6672   "vunpcklps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6673   [(set_attr "type" "sselog")
6674    (set_attr "prefix" "vex")
6675    (set_attr "mode" "V8SF")])
6677 (define_insn "unpcklps128_mask"
6678   [(set (match_operand:V4SF 0 "register_operand" "=v")
6679         (vec_merge:V4SF
6680           (vec_select:V4SF
6681             (vec_concat:V8SF
6682               (match_operand:V4SF 1 "register_operand" "v")
6683               (match_operand:V4SF 2 "nonimmediate_operand" "vm"))
6684             (parallel [(const_int 0) (const_int 4)
6685                       (const_int 1) (const_int 5)]))
6686           (match_operand:V4SF 3 "nonimm_or_0_operand" "0C")
6687           (match_operand:QI 4 "register_operand" "Yk")))]
6688   "TARGET_AVX512VL"
6689   "vunpcklps\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
6690   [(set_attr "type" "sselog")
6691    (set_attr "prefix" "evex")
6692    (set_attr "mode" "V4SF")])
6694 (define_expand "vec_interleave_lowv8sf"
6695   [(set (match_dup 3)
6696         (vec_select:V8SF
6697           (vec_concat:V16SF
6698             (match_operand:V8SF 1 "register_operand")
6699             (match_operand:V8SF 2 "nonimmediate_operand"))
6700           (parallel [(const_int 0) (const_int 8)
6701                      (const_int 1) (const_int 9)
6702                      (const_int 4) (const_int 12)
6703                      (const_int 5) (const_int 13)])))
6704    (set (match_dup 4)
6705         (vec_select:V8SF
6706           (vec_concat:V16SF
6707             (match_dup 1)
6708             (match_dup 2))
6709           (parallel [(const_int 2) (const_int 10)
6710                      (const_int 3) (const_int 11)
6711                      (const_int 6) (const_int 14)
6712                      (const_int 7) (const_int 15)])))
6713    (set (match_operand:V8SF 0 "register_operand")
6714         (vec_select:V8SF
6715           (vec_concat:V16SF
6716             (match_dup 3)
6717             (match_dup 4))
6718           (parallel [(const_int 0) (const_int 1)
6719                      (const_int 2) (const_int 3)
6720                      (const_int 8) (const_int 9)
6721                      (const_int 10) (const_int 11)])))]
6722  "TARGET_AVX"
6724   operands[3] = gen_reg_rtx (V8SFmode);
6725   operands[4] = gen_reg_rtx (V8SFmode);
6728 (define_insn "vec_interleave_lowv4sf"
6729   [(set (match_operand:V4SF 0 "register_operand" "=x,v")
6730         (vec_select:V4SF
6731           (vec_concat:V8SF
6732             (match_operand:V4SF 1 "register_operand" "0,v")
6733             (match_operand:V4SF 2 "vector_operand" "xBm,vm"))
6734           (parallel [(const_int 0) (const_int 4)
6735                      (const_int 1) (const_int 5)])))]
6736   "TARGET_SSE"
6737   "@
6738    unpcklps\t{%2, %0|%0, %2}
6739    vunpcklps\t{%2, %1, %0|%0, %1, %2}"
6740   [(set_attr "isa" "noavx,avx")
6741    (set_attr "type" "sselog")
6742    (set_attr "prefix" "orig,maybe_evex")
6743    (set_attr "mode" "V4SF")])
6745 ;; These are modeled with the same vec_concat as the others so that we
6746 ;; capture users of shufps that can use the new instructions
6747 (define_insn "avx_movshdup256<mask_name>"
6748   [(set (match_operand:V8SF 0 "register_operand" "=v")
6749         (vec_select:V8SF
6750           (vec_concat:V16SF
6751             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
6752             (match_dup 1))
6753           (parallel [(const_int 1) (const_int 1)
6754                      (const_int 3) (const_int 3)
6755                      (const_int 5) (const_int 5)
6756                      (const_int 7) (const_int 7)])))]
6757   "TARGET_AVX && <mask_avx512vl_condition>"
6758   "vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6759   [(set_attr "type" "sse")
6760    (set_attr "prefix" "vex")
6761    (set_attr "mode" "V8SF")])
6763 (define_insn "sse3_movshdup<mask_name>"
6764   [(set (match_operand:V4SF 0 "register_operand" "=v")
6765         (vec_select:V4SF
6766           (vec_concat:V8SF
6767             (match_operand:V4SF 1 "vector_operand" "vBm")
6768             (match_dup 1))
6769           (parallel [(const_int 1)
6770                      (const_int 1)
6771                      (const_int 7)
6772                      (const_int 7)])))]
6773   "TARGET_SSE3 && <mask_avx512vl_condition>"
6774   "%vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6775   [(set_attr "type" "sse")
6776    (set_attr "prefix_rep" "1")
6777    (set_attr "prefix" "maybe_vex")
6778    (set_attr "mode" "V4SF")])
6780 (define_insn "<mask_codefor>avx512f_movshdup512<mask_name>"
6781   [(set (match_operand:V16SF 0 "register_operand" "=v")
6782         (vec_select:V16SF
6783           (vec_concat:V32SF
6784             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
6785             (match_dup 1))
6786           (parallel [(const_int 1) (const_int 1)
6787                      (const_int 3) (const_int 3)
6788                      (const_int 5) (const_int 5)
6789                      (const_int 7) (const_int 7)
6790                      (const_int 9) (const_int 9)
6791                      (const_int 11) (const_int 11)
6792                      (const_int 13) (const_int 13)
6793                      (const_int 15) (const_int 15)])))]
6794   "TARGET_AVX512F"
6795   "vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6796   [(set_attr "type" "sse")
6797    (set_attr "prefix" "evex")
6798    (set_attr "mode" "V16SF")])
6800 (define_insn "avx_movsldup256<mask_name>"
6801   [(set (match_operand:V8SF 0 "register_operand" "=v")
6802         (vec_select:V8SF
6803           (vec_concat:V16SF
6804             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
6805             (match_dup 1))
6806           (parallel [(const_int 0) (const_int 0)
6807                      (const_int 2) (const_int 2)
6808                      (const_int 4) (const_int 4)
6809                      (const_int 6) (const_int 6)])))]
6810   "TARGET_AVX && <mask_avx512vl_condition>"
6811   "vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6812   [(set_attr "type" "sse")
6813    (set_attr "prefix" "vex")
6814    (set_attr "mode" "V8SF")])
6816 (define_insn "sse3_movsldup<mask_name>"
6817   [(set (match_operand:V4SF 0 "register_operand" "=v")
6818         (vec_select:V4SF
6819           (vec_concat:V8SF
6820             (match_operand:V4SF 1 "vector_operand" "vBm")
6821             (match_dup 1))
6822           (parallel [(const_int 0)
6823                      (const_int 0)
6824                      (const_int 6)
6825                      (const_int 6)])))]
6826   "TARGET_SSE3 && <mask_avx512vl_condition>"
6827   "%vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6828   [(set_attr "type" "sse")
6829    (set_attr "prefix_rep" "1")
6830    (set_attr "prefix" "maybe_vex")
6831    (set_attr "mode" "V4SF")])
6833 (define_insn "<mask_codefor>avx512f_movsldup512<mask_name>"
6834   [(set (match_operand:V16SF 0 "register_operand" "=v")
6835         (vec_select:V16SF
6836           (vec_concat:V32SF
6837             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
6838             (match_dup 1))
6839           (parallel [(const_int 0) (const_int 0)
6840                      (const_int 2) (const_int 2)
6841                      (const_int 4) (const_int 4)
6842                      (const_int 6) (const_int 6)
6843                      (const_int 8) (const_int 8)
6844                      (const_int 10) (const_int 10)
6845                      (const_int 12) (const_int 12)
6846                      (const_int 14) (const_int 14)])))]
6847   "TARGET_AVX512F"
6848   "vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6849   [(set_attr "type" "sse")
6850    (set_attr "prefix" "evex")
6851    (set_attr "mode" "V16SF")])
6853 (define_expand "avx_shufps256<mask_expand4_name>"
6854   [(match_operand:V8SF 0 "register_operand")
6855    (match_operand:V8SF 1 "register_operand")
6856    (match_operand:V8SF 2 "nonimmediate_operand")
6857    (match_operand:SI 3 "const_int_operand")]
6858   "TARGET_AVX"
6860   int mask = INTVAL (operands[3]);
6861   emit_insn (gen_avx_shufps256_1<mask_expand4_name> (operands[0],
6862                                                      operands[1],
6863                                                      operands[2],
6864                                                      GEN_INT ((mask >> 0) & 3),
6865                                                      GEN_INT ((mask >> 2) & 3),
6866                                                      GEN_INT (((mask >> 4) & 3) + 8),
6867                                                      GEN_INT (((mask >> 6) & 3) + 8),
6868                                                      GEN_INT (((mask >> 0) & 3) + 4),
6869                                                      GEN_INT (((mask >> 2) & 3) + 4),
6870                                                      GEN_INT (((mask >> 4) & 3) + 12),
6871                                                      GEN_INT (((mask >> 6) & 3) + 12)
6872                                                      <mask_expand4_args>));
6873   DONE;
6876 ;; One bit in mask selects 2 elements.
6877 (define_insn "avx_shufps256_1<mask_name>"
6878   [(set (match_operand:V8SF 0 "register_operand" "=v")
6879         (vec_select:V8SF
6880           (vec_concat:V16SF
6881             (match_operand:V8SF 1 "register_operand" "v")
6882             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6883           (parallel [(match_operand 3  "const_0_to_3_operand"  )
6884                      (match_operand 4  "const_0_to_3_operand"  )
6885                      (match_operand 5  "const_8_to_11_operand" )
6886                      (match_operand 6  "const_8_to_11_operand" )
6887                      (match_operand 7  "const_4_to_7_operand"  )
6888                      (match_operand 8  "const_4_to_7_operand"  )
6889                      (match_operand 9  "const_12_to_15_operand")
6890                      (match_operand 10 "const_12_to_15_operand")])))]
6891   "TARGET_AVX
6892    && <mask_avx512vl_condition>
6893    && (INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
6894        && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
6895        && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4)
6896        && INTVAL (operands[6]) == (INTVAL (operands[10]) - 4))"
6898   int mask;
6899   mask = INTVAL (operands[3]);
6900   mask |= INTVAL (operands[4]) << 2;
6901   mask |= (INTVAL (operands[5]) - 8) << 4;
6902   mask |= (INTVAL (operands[6]) - 8) << 6;
6903   operands[3] = GEN_INT (mask);
6905   return "vshufps\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
6907   [(set_attr "type" "sseshuf")
6908    (set_attr "length_immediate" "1")
6909    (set_attr "prefix" "<mask_prefix>")
6910    (set_attr "mode" "V8SF")])
6912 (define_expand "sse_shufps<mask_expand4_name>"
6913   [(match_operand:V4SF 0 "register_operand")
6914    (match_operand:V4SF 1 "register_operand")
6915    (match_operand:V4SF 2 "vector_operand")
6916    (match_operand:SI 3 "const_int_operand")]
6917   "TARGET_SSE"
6919   int mask = INTVAL (operands[3]);
6920   emit_insn (gen_sse_shufps_v4sf<mask_expand4_name> (operands[0],
6921                                                      operands[1],
6922                                                      operands[2],
6923                                                      GEN_INT ((mask >> 0) & 3),
6924                                                      GEN_INT ((mask >> 2) & 3),
6925                                                      GEN_INT (((mask >> 4) & 3) + 4),
6926                                                      GEN_INT (((mask >> 6) & 3) + 4)
6927                                                      <mask_expand4_args>));
6928   DONE;
6931 (define_insn "sse_shufps_v4sf_mask"
6932   [(set (match_operand:V4SF 0 "register_operand" "=v")
6933     (vec_merge:V4SF
6934           (vec_select:V4SF
6935             (vec_concat:V8SF
6936               (match_operand:V4SF 1 "register_operand" "v")
6937               (match_operand:V4SF 2 "nonimmediate_operand" "vm"))
6938             (parallel [(match_operand 3 "const_0_to_3_operand")
6939                        (match_operand 4 "const_0_to_3_operand")
6940                        (match_operand 5 "const_4_to_7_operand")
6941                        (match_operand 6 "const_4_to_7_operand")]))
6942       (match_operand:V4SF 7 "nonimm_or_0_operand" "0C")
6943       (match_operand:QI 8 "register_operand" "Yk")))]
6944   "TARGET_AVX512VL"
6946   int mask = 0;
6947   mask |= INTVAL (operands[3]) << 0;
6948   mask |= INTVAL (operands[4]) << 2;
6949   mask |= (INTVAL (operands[5]) - 4) << 4;
6950   mask |= (INTVAL (operands[6]) - 4) << 6;
6951   operands[3] = GEN_INT (mask);
6953   return "vshufps\t{%3, %2, %1, %0%{%8%}%N7|%0%{%8%}%N7, %1, %2, %3}";
6955   [(set_attr "type" "sseshuf")
6956    (set_attr "length_immediate" "1")
6957    (set_attr "prefix" "evex")
6958    (set_attr "mode" "V4SF")])
6960 (define_insn "sse_shufps_<mode>"
6961   [(set (match_operand:VI4F_128 0 "register_operand" "=x,v")
6962         (vec_select:VI4F_128
6963           (vec_concat:<ssedoublevecmode>
6964             (match_operand:VI4F_128 1 "register_operand" "0,v")
6965             (match_operand:VI4F_128 2 "vector_operand" "xBm,vm"))
6966           (parallel [(match_operand 3 "const_0_to_3_operand")
6967                      (match_operand 4 "const_0_to_3_operand")
6968                      (match_operand 5 "const_4_to_7_operand")
6969                      (match_operand 6 "const_4_to_7_operand")])))]
6970   "TARGET_SSE"
6972   int mask = 0;
6973   mask |= INTVAL (operands[3]) << 0;
6974   mask |= INTVAL (operands[4]) << 2;
6975   mask |= (INTVAL (operands[5]) - 4) << 4;
6976   mask |= (INTVAL (operands[6]) - 4) << 6;
6977   operands[3] = GEN_INT (mask);
6979   switch (which_alternative)
6980     {
6981     case 0:
6982       return "shufps\t{%3, %2, %0|%0, %2, %3}";
6983     case 1:
6984       return "vshufps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
6985     default:
6986       gcc_unreachable ();
6987     }
6989   [(set_attr "isa" "noavx,avx")
6990    (set_attr "type" "sseshuf")
6991    (set_attr "length_immediate" "1")
6992    (set_attr "prefix" "orig,maybe_evex")
6993    (set_attr "mode" "V4SF")])
6995 (define_insn "sse_storehps"
6996   [(set (match_operand:V2SF 0 "nonimmediate_operand" "=m,v,v")
6997         (vec_select:V2SF
6998           (match_operand:V4SF 1 "nonimmediate_operand" "v,v,o")
6999           (parallel [(const_int 2) (const_int 3)])))]
7000   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7001   "@
7002    %vmovhps\t{%1, %0|%q0, %1}
7003    %vmovhlps\t{%1, %d0|%d0, %1}
7004    %vmovlps\t{%H1, %d0|%d0, %H1}"
7005   [(set_attr "type" "ssemov")
7006    (set_attr "prefix" "maybe_vex")
7007    (set_attr "mode" "V2SF,V4SF,V2SF")])
7009 (define_expand "sse_loadhps_exp"
7010   [(set (match_operand:V4SF 0 "nonimmediate_operand")
7011         (vec_concat:V4SF
7012           (vec_select:V2SF
7013             (match_operand:V4SF 1 "nonimmediate_operand")
7014             (parallel [(const_int 0) (const_int 1)]))
7015           (match_operand:V2SF 2 "nonimmediate_operand")))]
7016   "TARGET_SSE"
7018   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
7020   emit_insn (gen_sse_loadhps (dst, operands[1], operands[2]));
7022   /* Fix up the destination if needed.  */
7023   if (dst != operands[0])
7024     emit_move_insn (operands[0], dst);
7026   DONE;
7029 (define_insn "sse_loadhps"
7030   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,o")
7031         (vec_concat:V4SF
7032           (vec_select:V2SF
7033             (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
7034             (parallel [(const_int 0) (const_int 1)]))
7035           (match_operand:V2SF 2 "nonimmediate_operand"   " m,m,x,v,v")))]
7036   "TARGET_SSE"
7037   "@
7038    movhps\t{%2, %0|%0, %q2}
7039    vmovhps\t{%2, %1, %0|%0, %1, %q2}
7040    movlhps\t{%2, %0|%0, %2}
7041    vmovlhps\t{%2, %1, %0|%0, %1, %2}
7042    %vmovlps\t{%2, %H0|%H0, %2}"
7043   [(set_attr "isa" "noavx,avx,noavx,avx,*")
7044    (set_attr "type" "ssemov")
7045    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
7046    (set_attr "mode" "V2SF,V2SF,V4SF,V4SF,V2SF")])
7048 (define_insn "sse_storelps"
7049   [(set (match_operand:V2SF 0 "nonimmediate_operand"   "=m,v,v")
7050         (vec_select:V2SF
7051           (match_operand:V4SF 1 "nonimmediate_operand" " v,v,m")
7052           (parallel [(const_int 0) (const_int 1)])))]
7053   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7054   "@
7055    %vmovlps\t{%1, %0|%q0, %1}
7056    %vmovaps\t{%1, %0|%0, %1}
7057    %vmovlps\t{%1, %d0|%d0, %q1}"
7058   [(set_attr "type" "ssemov")
7059    (set_attr "prefix" "maybe_vex")
7060    (set_attr "mode" "V2SF,V4SF,V2SF")])
7062 (define_expand "sse_loadlps_exp"
7063   [(set (match_operand:V4SF 0 "nonimmediate_operand")
7064         (vec_concat:V4SF
7065           (match_operand:V2SF 2 "nonimmediate_operand")
7066           (vec_select:V2SF
7067             (match_operand:V4SF 1 "nonimmediate_operand")
7068             (parallel [(const_int 2) (const_int 3)]))))]
7069   "TARGET_SSE"
7071   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
7073   emit_insn (gen_sse_loadlps (dst, operands[1], operands[2]));
7075   /* Fix up the destination if needed.  */
7076   if (dst != operands[0])
7077     emit_move_insn (operands[0], dst);
7079   DONE;
7082 (define_insn "sse_loadlps"
7083   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,m")
7084         (vec_concat:V4SF
7085           (match_operand:V2SF 2 "nonimmediate_operand"   " 0,v,m,m,v")
7086           (vec_select:V2SF
7087             (match_operand:V4SF 1 "nonimmediate_operand" " x,v,0,v,0")
7088             (parallel [(const_int 2) (const_int 3)]))))]
7089   "TARGET_SSE"
7090   "@
7091    shufps\t{$0xe4, %1, %0|%0, %1, 0xe4}
7092    vshufps\t{$0xe4, %1, %2, %0|%0, %2, %1, 0xe4}
7093    movlps\t{%2, %0|%0, %q2}
7094    vmovlps\t{%2, %1, %0|%0, %1, %q2}
7095    %vmovlps\t{%2, %0|%q0, %2}"
7096   [(set_attr "isa" "noavx,avx,noavx,avx,*")
7097    (set_attr "type" "sseshuf,sseshuf,ssemov,ssemov,ssemov")
7098    (set (attr "length_immediate")
7099      (if_then_else (eq_attr "alternative" "0,1")
7100                    (const_string "1")
7101                    (const_string "*")))
7102    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
7103    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
7105 (define_insn "sse_movss"
7106   [(set (match_operand:V4SF 0 "register_operand"   "=x,v")
7107         (vec_merge:V4SF
7108           (match_operand:V4SF 2 "register_operand" " x,v")
7109           (match_operand:V4SF 1 "register_operand" " 0,v")
7110           (const_int 1)))]
7111   "TARGET_SSE"
7112   "@
7113    movss\t{%2, %0|%0, %2}
7114    vmovss\t{%2, %1, %0|%0, %1, %2}"
7115   [(set_attr "isa" "noavx,avx")
7116    (set_attr "type" "ssemov")
7117    (set_attr "prefix" "orig,maybe_evex")
7118    (set_attr "mode" "SF")])
7120 (define_insn "avx2_vec_dup<mode>"
7121   [(set (match_operand:VF1_128_256 0 "register_operand" "=v")
7122         (vec_duplicate:VF1_128_256
7123           (vec_select:SF
7124             (match_operand:V4SF 1 "register_operand" "v")
7125             (parallel [(const_int 0)]))))]
7126   "TARGET_AVX2"
7127   "vbroadcastss\t{%1, %0|%0, %1}"
7128   [(set_attr "type" "sselog1")
7129     (set_attr "prefix" "maybe_evex")
7130     (set_attr "mode" "<MODE>")])
7132 (define_insn "avx2_vec_dupv8sf_1"
7133   [(set (match_operand:V8SF 0 "register_operand" "=v")
7134         (vec_duplicate:V8SF
7135           (vec_select:SF
7136             (match_operand:V8SF 1 "register_operand" "v")
7137             (parallel [(const_int 0)]))))]
7138   "TARGET_AVX2"
7139   "vbroadcastss\t{%x1, %0|%0, %x1}"
7140   [(set_attr "type" "sselog1")
7141     (set_attr "prefix" "maybe_evex")
7142     (set_attr "mode" "V8SF")])
7144 (define_insn "avx512f_vec_dup<mode>_1"
7145   [(set (match_operand:VF_512 0 "register_operand" "=v")
7146         (vec_duplicate:VF_512
7147           (vec_select:<ssescalarmode>
7148             (match_operand:VF_512 1 "register_operand" "v")
7149             (parallel [(const_int 0)]))))]
7150   "TARGET_AVX512F"
7151   "vbroadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}"
7152   [(set_attr "type" "sselog1")
7153     (set_attr "prefix" "evex")
7154     (set_attr "mode" "<MODE>")])
7156 ;; Although insertps takes register source, we prefer
7157 ;; unpcklps with register source since it is shorter.
7158 (define_insn "*vec_concatv2sf_sse4_1"
7159   [(set (match_operand:V2SF 0 "register_operand"
7160           "=Yr,*x, v,Yr,*x,v,v,*y ,*y")
7161         (vec_concat:V2SF
7162           (match_operand:SF 1 "nonimmediate_operand"
7163           "  0, 0,Yv, 0,0, v,m, 0 , m")
7164           (match_operand:SF 2 "nonimm_or_0_operand"
7165           " Yr,*x,Yv, m,m, m,C,*ym, C")))]
7166   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
7167   "@
7168    unpcklps\t{%2, %0|%0, %2}
7169    unpcklps\t{%2, %0|%0, %2}
7170    vunpcklps\t{%2, %1, %0|%0, %1, %2}
7171    insertps\t{$0x10, %2, %0|%0, %2, 0x10}
7172    insertps\t{$0x10, %2, %0|%0, %2, 0x10}
7173    vinsertps\t{$0x10, %2, %1, %0|%0, %1, %2, 0x10}
7174    %vmovss\t{%1, %0|%0, %1}
7175    punpckldq\t{%2, %0|%0, %2}
7176    movd\t{%1, %0|%0, %1}"
7177   [(set (attr "isa")
7178      (cond [(eq_attr "alternative" "0,1,3,4")
7179               (const_string "noavx")
7180             (eq_attr "alternative" "2,5")
7181               (const_string "avx")
7182            ]
7183            (const_string "*")))
7184    (set (attr "type")
7185      (cond [(eq_attr "alternative" "6")
7186               (const_string "ssemov")
7187             (eq_attr "alternative" "7")
7188               (const_string "mmxcvt")
7189             (eq_attr "alternative" "8")
7190               (const_string "mmxmov")
7191            ]
7192            (const_string "sselog")))
7193    (set (attr "prefix_data16")
7194      (if_then_else (eq_attr "alternative" "3,4")
7195                    (const_string "1")
7196                    (const_string "*")))
7197    (set (attr "prefix_extra")
7198      (if_then_else (eq_attr "alternative" "3,4,5")
7199                    (const_string "1")
7200                    (const_string "*")))
7201    (set (attr "length_immediate")
7202      (if_then_else (eq_attr "alternative" "3,4,5")
7203                    (const_string "1")
7204                    (const_string "*")))
7205    (set (attr "prefix")
7206      (cond [(eq_attr "alternative" "2,5")
7207               (const_string "maybe_evex")
7208             (eq_attr "alternative" "6")
7209               (const_string "maybe_vex")
7210            ]
7211            (const_string "orig")))
7212    (set_attr "mode" "V4SF,V4SF,V4SF,V4SF,V4SF,V4SF,SF,DI,DI")])
7214 ;; ??? In theory we can match memory for the MMX alternative, but allowing
7215 ;; vector_operand for operand 2 and *not* allowing memory for the SSE
7216 ;; alternatives pretty much forces the MMX alternative to be chosen.
7217 (define_insn "*vec_concatv2sf_sse"
7218   [(set (match_operand:V2SF 0 "register_operand"     "=x,x,*y,*y")
7219         (vec_concat:V2SF
7220           (match_operand:SF 1 "nonimmediate_operand" " 0,m, 0, m")
7221           (match_operand:SF 2 "reg_or_0_operand"     " x,C,*y, C")))]
7222   "TARGET_SSE"
7223   "@
7224    unpcklps\t{%2, %0|%0, %2}
7225    movss\t{%1, %0|%0, %1}
7226    punpckldq\t{%2, %0|%0, %2}
7227    movd\t{%1, %0|%0, %1}"
7228   [(set_attr "type" "sselog,ssemov,mmxcvt,mmxmov")
7229    (set_attr "mode" "V4SF,SF,DI,DI")])
7231 (define_insn "*vec_concatv4sf"
7232   [(set (match_operand:V4SF 0 "register_operand"       "=x,v,x,v")
7233         (vec_concat:V4SF
7234           (match_operand:V2SF 1 "register_operand"     " 0,v,0,v")
7235           (match_operand:V2SF 2 "nonimmediate_operand" " x,v,m,m")))]
7236   "TARGET_SSE"
7237   "@
7238    movlhps\t{%2, %0|%0, %2}
7239    vmovlhps\t{%2, %1, %0|%0, %1, %2}
7240    movhps\t{%2, %0|%0, %q2}
7241    vmovhps\t{%2, %1, %0|%0, %1, %q2}"
7242   [(set_attr "isa" "noavx,avx,noavx,avx")
7243    (set_attr "type" "ssemov")
7244    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex")
7245    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF")])
7247 ;; Avoid combining registers from different units in a single alternative,
7248 ;; see comment above inline_secondary_memory_needed function in i386.c
7249 (define_insn "vec_set<mode>_0"
7250   [(set (match_operand:VI4F_128 0 "nonimmediate_operand"
7251           "=Yr,*x,v,v,v,x,x,v,Yr ,*x ,x  ,m ,m   ,m")
7252         (vec_merge:VI4F_128
7253           (vec_duplicate:VI4F_128
7254             (match_operand:<ssescalarmode> 2 "general_operand"
7255           " Yr,*x,v,m,r ,m,x,v,*rm,*rm,*rm,!x,!*re,!*fF"))
7256           (match_operand:VI4F_128 1 "nonimm_or_0_operand"
7257           " C , C,C,C,C ,C,0,v,0  ,0  ,x  ,0 ,0   ,0")
7258           (const_int 1)))]
7259   "TARGET_SSE"
7260   "@
7261    insertps\t{$0xe, %2, %0|%0, %2, 0xe}
7262    insertps\t{$0xe, %2, %0|%0, %2, 0xe}
7263    vinsertps\t{$0xe, %2, %2, %0|%0, %2, %2, 0xe}
7264    %vmov<ssescalarmodesuffix>\t{%2, %0|%0, %2}
7265    %vmovd\t{%2, %0|%0, %2}
7266    movss\t{%2, %0|%0, %2}
7267    movss\t{%2, %0|%0, %2}
7268    vmovss\t{%2, %1, %0|%0, %1, %2}
7269    pinsrd\t{$0, %2, %0|%0, %2, 0}
7270    pinsrd\t{$0, %2, %0|%0, %2, 0}
7271    vpinsrd\t{$0, %2, %1, %0|%0, %1, %2, 0}
7272    #
7273    #
7274    #"
7275   [(set (attr "isa")
7276      (cond [(eq_attr "alternative" "0,1,8,9")
7277               (const_string "sse4_noavx")
7278             (eq_attr "alternative" "2,7,10")
7279               (const_string "avx")
7280             (eq_attr "alternative" "3,4")
7281               (const_string "sse2")
7282             (eq_attr "alternative" "5,6")
7283               (const_string "noavx")
7284            ]
7285            (const_string "*")))
7286    (set (attr "type")
7287      (cond [(eq_attr "alternative" "0,1,2,8,9,10")
7288               (const_string "sselog")
7289             (eq_attr "alternative" "12")
7290               (const_string "imov")
7291             (eq_attr "alternative" "13")
7292               (const_string "fmov")
7293            ]
7294            (const_string "ssemov")))
7295    (set (attr "prefix_extra")
7296      (if_then_else (eq_attr "alternative" "8,9,10")
7297                    (const_string "1")
7298                    (const_string "*")))
7299    (set (attr "length_immediate")
7300      (if_then_else (eq_attr "alternative" "8,9,10")
7301                    (const_string "1")
7302                    (const_string "*")))
7303    (set (attr "prefix")
7304      (cond [(eq_attr "alternative" "0,1,5,6,8,9")
7305               (const_string "orig")
7306             (eq_attr "alternative" "2")
7307               (const_string "maybe_evex")
7308             (eq_attr "alternative" "3,4")
7309               (const_string "maybe_vex")
7310             (eq_attr "alternative" "7,10")
7311               (const_string "vex")
7312            ]
7313            (const_string "*")))
7314    (set_attr "mode" "SF,SF,SF,<ssescalarmode>,SI,SF,SF,SF,TI,TI,TI,*,*,*")
7315    (set (attr "preferred_for_speed")
7316      (cond [(eq_attr "alternative" "4")
7317               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
7318            ]
7319            (symbol_ref "true")))])
7321 ;; A subset is vec_setv4sf.
7322 (define_insn "*vec_setv4sf_sse4_1"
7323   [(set (match_operand:V4SF 0 "register_operand" "=Yr,*x,v")
7324         (vec_merge:V4SF
7325           (vec_duplicate:V4SF
7326             (match_operand:SF 2 "nonimmediate_operand" "Yrm,*xm,vm"))
7327           (match_operand:V4SF 1 "register_operand" "0,0,v")
7328           (match_operand:SI 3 "const_int_operand")))]
7329   "TARGET_SSE4_1
7330    && ((unsigned) exact_log2 (INTVAL (operands[3]))
7331        < GET_MODE_NUNITS (V4SFmode))"
7333   operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])) << 4);
7334   switch (which_alternative)
7335     {
7336     case 0:
7337     case 1:
7338       return "insertps\t{%3, %2, %0|%0, %2, %3}";
7339     case 2:
7340       return "vinsertps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
7341     default:
7342       gcc_unreachable ();
7343     }
7345   [(set_attr "isa" "noavx,noavx,avx")
7346    (set_attr "type" "sselog")
7347    (set_attr "prefix_data16" "1,1,*")
7348    (set_attr "prefix_extra" "1")
7349    (set_attr "length_immediate" "1")
7350    (set_attr "prefix" "orig,orig,maybe_evex")
7351    (set_attr "mode" "V4SF")])
7353 ;; All of vinsertps, vmovss, vmovd clear also the higher bits.
7354 (define_insn "vec_set<mode>_0"
7355   [(set (match_operand:VI4F_256_512 0 "register_operand" "=v,v,v")
7356         (vec_merge:VI4F_256_512
7357           (vec_duplicate:VI4F_256_512
7358             (match_operand:<ssescalarmode> 2 "general_operand" "v,m,r"))
7359           (match_operand:VI4F_256_512 1 "const0_operand" "C,C,C")
7360           (const_int 1)))]
7361   "TARGET_AVX"
7362   "@
7363    vinsertps\t{$0xe, %2, %2, %x0|%x0, %2, %2, 0xe}
7364    vmov<ssescalarmodesuffix>\t{%x2, %x0|%x0, %2}
7365    vmovd\t{%2, %x0|%x0, %2}"
7366   [(set (attr "type")
7367      (if_then_else (eq_attr "alternative" "0")
7368                    (const_string "sselog")
7369                    (const_string "ssemov")))
7370    (set_attr "prefix" "maybe_evex")
7371    (set_attr "mode" "SF,<ssescalarmode>,SI")
7372    (set (attr "preferred_for_speed")
7373      (cond [(eq_attr "alternative" "2")
7374               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
7375            ]
7376            (symbol_ref "true")))])
7378 (define_insn "sse4_1_insertps"
7379   [(set (match_operand:V4SF 0 "register_operand" "=Yr,*x,v")
7380         (unspec:V4SF [(match_operand:V4SF 2 "nonimmediate_operand" "Yrm,*xm,vm")
7381                       (match_operand:V4SF 1 "register_operand" "0,0,v")
7382                       (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
7383                      UNSPEC_INSERTPS))]
7384   "TARGET_SSE4_1"
7386   if (MEM_P (operands[2]))
7387     {
7388       unsigned count_s = INTVAL (operands[3]) >> 6;
7389       if (count_s)
7390         operands[3] = GEN_INT (INTVAL (operands[3]) & 0x3f);
7391       operands[2] = adjust_address_nv (operands[2], SFmode, count_s * 4);
7392     }
7393   switch (which_alternative)
7394     {
7395     case 0:
7396     case 1:
7397       return "insertps\t{%3, %2, %0|%0, %2, %3}";
7398     case 2:
7399       return "vinsertps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
7400     default:
7401       gcc_unreachable ();
7402     }
7404   [(set_attr "isa" "noavx,noavx,avx")
7405    (set_attr "type" "sselog")
7406    (set_attr "prefix_data16" "1,1,*")
7407    (set_attr "prefix_extra" "1")
7408    (set_attr "length_immediate" "1")
7409    (set_attr "prefix" "orig,orig,maybe_evex")
7410    (set_attr "mode" "V4SF")])
7412 (define_split
7413   [(set (match_operand:VI4F_128 0 "memory_operand")
7414         (vec_merge:VI4F_128
7415           (vec_duplicate:VI4F_128
7416             (match_operand:<ssescalarmode> 1 "nonmemory_operand"))
7417           (match_dup 0)
7418           (const_int 1)))]
7419   "TARGET_SSE && reload_completed"
7420   [(set (match_dup 0) (match_dup 1))]
7421   "operands[0] = adjust_address (operands[0], <ssescalarmode>mode, 0);")
7423 (define_expand "vec_set<mode>"
7424   [(match_operand:V 0 "register_operand")
7425    (match_operand:<ssescalarmode> 1 "register_operand")
7426    (match_operand 2 "const_int_operand")]
7427   "TARGET_SSE"
7429   ix86_expand_vector_set (false, operands[0], operands[1],
7430                           INTVAL (operands[2]));
7431   DONE;
7434 (define_insn_and_split "*vec_extractv4sf_0"
7435   [(set (match_operand:SF 0 "nonimmediate_operand" "=v,m,f,r")
7436         (vec_select:SF
7437           (match_operand:V4SF 1 "nonimmediate_operand" "vm,v,m,m")
7438           (parallel [(const_int 0)])))]
7439   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7440   "#"
7441   "&& reload_completed"
7442   [(set (match_dup 0) (match_dup 1))]
7443   "operands[1] = gen_lowpart (SFmode, operands[1]);")
7445 (define_insn_and_split "*sse4_1_extractps"
7446   [(set (match_operand:SF 0 "nonimmediate_operand" "=rm,rm,rm,Yv,Yv")
7447         (vec_select:SF
7448           (match_operand:V4SF 1 "register_operand" "Yr,*x,v,0,v")
7449           (parallel [(match_operand:SI 2 "const_0_to_3_operand" "n,n,n,n,n")])))]
7450   "TARGET_SSE4_1"
7451   "@
7452    extractps\t{%2, %1, %0|%0, %1, %2}
7453    extractps\t{%2, %1, %0|%0, %1, %2}
7454    vextractps\t{%2, %1, %0|%0, %1, %2}
7455    #
7456    #"
7457   "&& reload_completed && SSE_REG_P (operands[0])"
7458   [(const_int 0)]
7460   rtx dest = lowpart_subreg (V4SFmode, operands[0], SFmode);
7461   switch (INTVAL (operands[2]))
7462     {
7463     case 1:
7464     case 3:
7465       emit_insn (gen_sse_shufps_v4sf (dest, operands[1], operands[1],
7466                                       operands[2], operands[2],
7467                                       GEN_INT (INTVAL (operands[2]) + 4),
7468                                       GEN_INT (INTVAL (operands[2]) + 4)));
7469       break;
7470     case 2:
7471       emit_insn (gen_vec_interleave_highv4sf (dest, operands[1], operands[1]));
7472       break;
7473     default:
7474       /* 0 should be handled by the *vec_extractv4sf_0 pattern above.  */
7475       gcc_unreachable ();
7476     }
7477   DONE;
7479   [(set_attr "isa" "noavx,noavx,avx,noavx,avx")
7480    (set_attr "type" "sselog,sselog,sselog,*,*")
7481    (set_attr "prefix_data16" "1,1,1,*,*")
7482    (set_attr "prefix_extra" "1,1,1,*,*")
7483    (set_attr "length_immediate" "1,1,1,*,*")
7484    (set_attr "prefix" "orig,orig,maybe_evex,*,*")
7485    (set_attr "mode" "V4SF,V4SF,V4SF,*,*")])
7487 (define_insn_and_split "*vec_extractv4sf_mem"
7488   [(set (match_operand:SF 0 "register_operand" "=v,*r,f")
7489         (vec_select:SF
7490           (match_operand:V4SF 1 "memory_operand" "o,o,o")
7491           (parallel [(match_operand 2 "const_0_to_3_operand" "n,n,n")])))]
7492   "TARGET_SSE"
7493   "#"
7494   "&& reload_completed"
7495   [(set (match_dup 0) (match_dup 1))]
7497   operands[1] = adjust_address (operands[1], SFmode, INTVAL (operands[2]) * 4);
7500 (define_mode_attr extract_type
7501   [(V16SF "avx512f") (V16SI "avx512f") (V8DF "avx512dq") (V8DI "avx512dq")])
7503 (define_mode_attr extract_suf
7504   [(V16SF "32x4") (V16SI "32x4") (V8DF "64x2") (V8DI "64x2")])
7506 (define_mode_iterator AVX512_VEC
7507   [(V8DF "TARGET_AVX512DQ") (V8DI "TARGET_AVX512DQ") V16SF V16SI])
7509 (define_expand "<extract_type>_vextract<shuffletype><extract_suf>_mask"
7510   [(match_operand:<ssequartermode> 0 "nonimmediate_operand")
7511    (match_operand:AVX512_VEC 1 "register_operand")
7512    (match_operand:SI 2 "const_0_to_3_operand")
7513    (match_operand:<ssequartermode> 3 "nonimmediate_operand")
7514    (match_operand:QI 4 "register_operand")]
7515   "TARGET_AVX512F"
7517   int mask;
7518   mask = INTVAL (operands[2]);
7519   rtx dest = operands[0];
7521   if (MEM_P (operands[0]) && !rtx_equal_p (operands[0], operands[3]))
7522     dest = gen_reg_rtx (<ssequartermode>mode);
7524   if (<MODE>mode == V16SImode || <MODE>mode == V16SFmode)
7525     emit_insn (gen_avx512f_vextract<shuffletype>32x4_1_mask (dest,
7526         operands[1], GEN_INT (mask * 4), GEN_INT (mask * 4 + 1),
7527         GEN_INT (mask * 4 + 2), GEN_INT (mask * 4 + 3), operands[3],
7528         operands[4]));
7529   else
7530     emit_insn (gen_avx512dq_vextract<shuffletype>64x2_1_mask (dest,
7531         operands[1], GEN_INT (mask * 2), GEN_INT (mask * 2 + 1), operands[3],
7532         operands[4]));
7533   if (dest != operands[0])
7534     emit_move_insn (operands[0], dest);
7535   DONE;
7538 (define_insn "avx512dq_vextract<shuffletype>64x2_1_maskm"
7539   [(set (match_operand:<ssequartermode> 0 "memory_operand" "=m")
7540         (vec_merge:<ssequartermode>
7541           (vec_select:<ssequartermode>
7542             (match_operand:V8FI 1 "register_operand" "v")
7543             (parallel [(match_operand 2  "const_0_to_7_operand")
7544               (match_operand 3  "const_0_to_7_operand")]))
7545           (match_operand:<ssequartermode> 4 "memory_operand" "0")
7546           (match_operand:QI 5 "register_operand" "Yk")))]
7547   "TARGET_AVX512DQ
7548    && INTVAL (operands[2]) % 2 == 0
7549    && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
7550    && rtx_equal_p (operands[4], operands[0])"
7552   operands[2] = GEN_INT ((INTVAL (operands[2])) >> 1);
7553   return "vextract<shuffletype>64x2\t{%2, %1, %0%{%5%}|%0%{%5%}, %1, %2}";
7555   [(set_attr "type" "sselog")
7556    (set_attr "prefix_extra" "1")
7557    (set_attr "length_immediate" "1")
7558    (set_attr "memory" "store")
7559    (set_attr "prefix" "evex")
7560    (set_attr "mode" "<sseinsnmode>")])
7562 (define_insn "avx512f_vextract<shuffletype>32x4_1_maskm"
7563   [(set (match_operand:<ssequartermode> 0 "memory_operand" "=m")
7564         (vec_merge:<ssequartermode>
7565           (vec_select:<ssequartermode>
7566             (match_operand:V16FI 1 "register_operand" "v")
7567             (parallel [(match_operand 2  "const_0_to_15_operand")
7568               (match_operand 3  "const_0_to_15_operand")
7569               (match_operand 4  "const_0_to_15_operand")
7570               (match_operand 5  "const_0_to_15_operand")]))
7571           (match_operand:<ssequartermode> 6 "memory_operand" "0")
7572           (match_operand:QI 7 "register_operand" "Yk")))]
7573   "TARGET_AVX512F
7574    && INTVAL (operands[2]) % 4 == 0
7575    && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
7576    && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
7577    && INTVAL (operands[4]) == INTVAL (operands[5]) - 1
7578    && rtx_equal_p (operands[6], operands[0])"
7580   operands[2] = GEN_INT (INTVAL (operands[2]) >> 2);
7581   return "vextract<shuffletype>32x4\t{%2, %1, %0%{%7%}|%0%{%7%}, %1, %2}";
7583   [(set_attr "type" "sselog")
7584    (set_attr "prefix_extra" "1")
7585    (set_attr "length_immediate" "1")
7586    (set_attr "memory" "store")
7587    (set_attr "prefix" "evex")
7588    (set_attr "mode" "<sseinsnmode>")])
7590 (define_insn "<mask_codefor>avx512dq_vextract<shuffletype>64x2_1<mask_name>"
7591   [(set (match_operand:<ssequartermode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7592         (vec_select:<ssequartermode>
7593           (match_operand:V8FI 1 "register_operand" "v")
7594           (parallel [(match_operand 2  "const_0_to_7_operand")
7595             (match_operand 3  "const_0_to_7_operand")])))]
7596   "TARGET_AVX512DQ
7597    && INTVAL (operands[2]) % 2 == 0
7598    && INTVAL (operands[2]) == INTVAL (operands[3]) - 1"
7600   operands[2] = GEN_INT (INTVAL (operands[2]) >> 1);
7601   return "vextract<shuffletype>64x2\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}";
7603   [(set_attr "type" "sselog1")
7604    (set_attr "prefix_extra" "1")
7605    (set_attr "length_immediate" "1")
7606    (set_attr "prefix" "evex")
7607    (set_attr "mode" "<sseinsnmode>")])
7609 (define_split
7610   [(set (match_operand:<ssequartermode> 0 "nonimmediate_operand")
7611         (vec_select:<ssequartermode>
7612           (match_operand:V8FI 1 "register_operand")
7613           (parallel [(const_int 0) (const_int 1)])))]
7614   "TARGET_AVX512DQ
7615    && reload_completed
7616    && (TARGET_AVX512VL
7617        || REG_P (operands[0])
7618        || !EXT_REX_SSE_REG_P (operands[1]))"
7619   [(set (match_dup 0) (match_dup 1))]
7621   if (!TARGET_AVX512VL
7622       && REG_P (operands[0])
7623       && EXT_REX_SSE_REG_P (operands[1]))
7624     operands[0]
7625       = lowpart_subreg (<MODE>mode, operands[0], <ssequartermode>mode);
7626   else
7627     operands[1] = gen_lowpart (<ssequartermode>mode, operands[1]);
7630 (define_insn "<mask_codefor>avx512f_vextract<shuffletype>32x4_1<mask_name>"
7631   [(set (match_operand:<ssequartermode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7632         (vec_select:<ssequartermode>
7633           (match_operand:V16FI 1 "register_operand" "v")
7634           (parallel [(match_operand 2  "const_0_to_15_operand")
7635             (match_operand 3  "const_0_to_15_operand")
7636             (match_operand 4  "const_0_to_15_operand")
7637             (match_operand 5  "const_0_to_15_operand")])))]
7638   "TARGET_AVX512F
7639    && INTVAL (operands[2]) % 4 == 0
7640    && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
7641    && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
7642    && INTVAL (operands[4]) == INTVAL (operands[5]) - 1"
7644   operands[2] = GEN_INT (INTVAL (operands[2]) >> 2);
7645   return "vextract<shuffletype>32x4\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
7647   [(set_attr "type" "sselog1")
7648    (set_attr "prefix_extra" "1")
7649    (set_attr "length_immediate" "1")
7650    (set_attr "prefix" "evex")
7651    (set_attr "mode" "<sseinsnmode>")])
7653 (define_split
7654   [(set (match_operand:<ssequartermode> 0 "nonimmediate_operand")
7655         (vec_select:<ssequartermode>
7656           (match_operand:V16FI 1 "register_operand")
7657           (parallel [(const_int 0) (const_int 1)
7658                      (const_int 2) (const_int 3)])))]
7659   "TARGET_AVX512F
7660    && reload_completed
7661    && (TARGET_AVX512VL
7662        || REG_P (operands[0])
7663        || !EXT_REX_SSE_REG_P (operands[1]))"
7664   [(set (match_dup 0) (match_dup 1))]
7666   if (!TARGET_AVX512VL
7667       && REG_P (operands[0])
7668       && EXT_REX_SSE_REG_P (operands[1]))
7669     operands[0]
7670       = lowpart_subreg (<MODE>mode, operands[0], <ssequartermode>mode);
7671   else
7672     operands[1] = gen_lowpart (<ssequartermode>mode, operands[1]);
7675 (define_mode_attr extract_type_2
7676   [(V16SF "avx512dq") (V16SI "avx512dq") (V8DF "avx512f") (V8DI "avx512f")])
7678 (define_mode_attr extract_suf_2
7679   [(V16SF "32x8") (V16SI "32x8") (V8DF "64x4") (V8DI "64x4")])
7681 (define_mode_iterator AVX512_VEC_2
7682   [(V16SF "TARGET_AVX512DQ") (V16SI "TARGET_AVX512DQ") V8DF V8DI])
7684 (define_expand "<extract_type_2>_vextract<shuffletype><extract_suf_2>_mask"
7685   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7686    (match_operand:AVX512_VEC_2 1 "register_operand")
7687    (match_operand:SI 2 "const_0_to_1_operand")
7688    (match_operand:<ssehalfvecmode> 3 "nonimmediate_operand")
7689    (match_operand:QI 4 "register_operand")]
7690   "TARGET_AVX512F"
7692   rtx (*insn)(rtx, rtx, rtx, rtx);
7693   rtx dest = operands[0];
7695   if (MEM_P (dest) && !rtx_equal_p (dest, operands[3]))
7696     dest = gen_reg_rtx (<ssehalfvecmode>mode);
7698   switch (INTVAL (operands[2]))
7699     {
7700     case 0:
7701       insn = gen_vec_extract_lo_<mode>_mask;
7702       break;
7703     case 1:
7704       insn = gen_vec_extract_hi_<mode>_mask;
7705       break;
7706     default:
7707       gcc_unreachable ();
7708     }
7710   emit_insn (insn (dest, operands[1], operands[3], operands[4]));
7711   if (dest != operands[0])
7712     emit_move_insn (operands[0], dest);
7713   DONE;
7716 (define_split
7717   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7718         (vec_select:<ssehalfvecmode>
7719           (match_operand:V8FI 1 "nonimmediate_operand")
7720           (parallel [(const_int 0) (const_int 1)
7721             (const_int 2) (const_int 3)])))]
7722   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7723    && reload_completed
7724    && (TARGET_AVX512VL
7725        || (REG_P (operands[0]) && !EXT_REX_SSE_REG_P (operands[1])))"
7726   [(set (match_dup 0) (match_dup 1))]
7727   "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
7729 (define_insn "vec_extract_lo_<mode>_maskm"
7730   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7731         (vec_merge:<ssehalfvecmode>
7732           (vec_select:<ssehalfvecmode>
7733             (match_operand:V8FI 1 "register_operand" "v")
7734             (parallel [(const_int 0) (const_int 1)
7735               (const_int 2) (const_int 3)]))
7736           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7737           (match_operand:QI 3 "register_operand" "Yk")))]
7738   "TARGET_AVX512F
7739    && rtx_equal_p (operands[2], operands[0])"
7740   "vextract<shuffletype>64x4\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}"
7741   [(set_attr "type" "sselog1")
7742    (set_attr "prefix_extra" "1")
7743    (set_attr "length_immediate" "1")
7744    (set_attr "prefix" "evex")
7745    (set_attr "mode" "<sseinsnmode>")])
7747 (define_insn "vec_extract_lo_<mode><mask_name>"
7748   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,<store_mask_constraint>,v")
7749         (vec_select:<ssehalfvecmode>
7750           (match_operand:V8FI 1 "<store_mask_predicate>" "v,v,<store_mask_constraint>")
7751           (parallel [(const_int 0) (const_int 1)
7752             (const_int 2) (const_int 3)])))]
7753   "TARGET_AVX512F
7754    && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))"
7756   if (<mask_applied> || (!TARGET_AVX512VL && !MEM_P (operands[1])))
7757     return "vextract<shuffletype>64x4\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7758   else
7759     return "#";
7761   [(set_attr "type" "sselog1")
7762    (set_attr "prefix_extra" "1")
7763    (set_attr "length_immediate" "1")
7764    (set_attr "memory" "none,store,load")
7765    (set_attr "prefix" "evex")
7766    (set_attr "mode" "<sseinsnmode>")])
7768 (define_insn "vec_extract_hi_<mode>_maskm"
7769   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7770         (vec_merge:<ssehalfvecmode>
7771           (vec_select:<ssehalfvecmode>
7772             (match_operand:V8FI 1 "register_operand" "v")
7773             (parallel [(const_int 4) (const_int 5)
7774               (const_int 6) (const_int 7)]))
7775           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7776           (match_operand:QI 3 "register_operand" "Yk")))]
7777   "TARGET_AVX512F
7778    && rtx_equal_p (operands[2], operands[0])"
7779   "vextract<shuffletype>64x4\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7780   [(set_attr "type" "sselog")
7781    (set_attr "prefix_extra" "1")
7782    (set_attr "length_immediate" "1")
7783    (set_attr "memory" "store")
7784    (set_attr "prefix" "evex")
7785    (set_attr "mode" "<sseinsnmode>")])
7787 (define_insn "vec_extract_hi_<mode><mask_name>"
7788   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7789         (vec_select:<ssehalfvecmode>
7790           (match_operand:V8FI 1 "register_operand" "v")
7791           (parallel [(const_int 4) (const_int 5)
7792             (const_int 6) (const_int 7)])))]
7793   "TARGET_AVX512F"
7794   "vextract<shuffletype>64x4\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}"
7795   [(set_attr "type" "sselog1")
7796    (set_attr "prefix_extra" "1")
7797    (set_attr "length_immediate" "1")
7798    (set_attr "prefix" "evex")
7799    (set_attr "mode" "<sseinsnmode>")])
7801 (define_insn "vec_extract_hi_<mode>_maskm"
7802    [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7803         (vec_merge:<ssehalfvecmode>
7804           (vec_select:<ssehalfvecmode>
7805             (match_operand:V16FI 1 "register_operand" "v")
7806             (parallel [(const_int 8) (const_int 9)
7807               (const_int 10) (const_int 11)
7808               (const_int 12) (const_int 13)
7809               (const_int 14) (const_int 15)]))
7810           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7811           (match_operand:QI 3 "register_operand" "Yk")))]
7812   "TARGET_AVX512DQ
7813    && rtx_equal_p (operands[2], operands[0])"
7814   "vextract<shuffletype>32x8\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7815   [(set_attr "type" "sselog1")
7816    (set_attr "prefix_extra" "1")
7817    (set_attr "length_immediate" "1")
7818    (set_attr "prefix" "evex")
7819    (set_attr "mode" "<sseinsnmode>")])
7821 (define_insn "vec_extract_hi_<mode><mask_name>"
7822   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>,vm")
7823         (vec_select:<ssehalfvecmode>
7824           (match_operand:V16FI 1 "register_operand" "v,v")
7825           (parallel [(const_int 8) (const_int 9)
7826             (const_int 10) (const_int 11)
7827             (const_int 12) (const_int 13)
7828             (const_int 14) (const_int 15)])))]
7829   "TARGET_AVX512F && <mask_avx512dq_condition>"
7830   "@
7831    vextract<shuffletype>32x8\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}
7832    vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7833   [(set_attr "type" "sselog1")
7834    (set_attr "prefix_extra" "1")
7835    (set_attr "isa" "avx512dq,noavx512dq")
7836    (set_attr "length_immediate" "1")
7837    (set_attr "prefix" "evex")
7838    (set_attr "mode" "<sseinsnmode>")])
7840 (define_expand "avx512vl_vextractf128<mode>"
7841   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7842    (match_operand:VI48F_256 1 "register_operand")
7843    (match_operand:SI 2 "const_0_to_1_operand")
7844    (match_operand:<ssehalfvecmode> 3 "nonimm_or_0_operand")
7845    (match_operand:QI 4 "register_operand")]
7846   "TARGET_AVX512DQ && TARGET_AVX512VL"
7848   rtx (*insn)(rtx, rtx, rtx, rtx);
7849   rtx dest = operands[0];
7851   if (MEM_P (dest)
7852       && (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 4
7853           /* For V8S[IF]mode there are maskm insns with =m and 0
7854              constraints.  */
7855           ? !rtx_equal_p (dest, operands[3])
7856           /* For V4D[IF]mode, hi insns don't allow memory, and
7857              lo insns have =m and 0C constraints.  */
7858           : (operands[2] != const0_rtx
7859              || (!rtx_equal_p (dest, operands[3])
7860                  && GET_CODE (operands[3]) != CONST_VECTOR))))
7861     dest = gen_reg_rtx (<ssehalfvecmode>mode);
7862   switch (INTVAL (operands[2]))
7863     {
7864     case 0:
7865       insn = gen_vec_extract_lo_<mode>_mask;
7866       break;
7867     case 1:
7868       insn = gen_vec_extract_hi_<mode>_mask;
7869       break;
7870     default:
7871       gcc_unreachable ();
7872     }
7874   emit_insn (insn (dest, operands[1], operands[3], operands[4]));
7875   if (dest != operands[0])
7876     emit_move_insn (operands[0], dest);
7877   DONE;
7880 (define_expand "avx_vextractf128<mode>"
7881   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7882    (match_operand:V_256 1 "register_operand")
7883    (match_operand:SI 2 "const_0_to_1_operand")]
7884   "TARGET_AVX"
7886   rtx (*insn)(rtx, rtx);
7888   switch (INTVAL (operands[2]))
7889     {
7890     case 0:
7891       insn = gen_vec_extract_lo_<mode>;
7892       break;
7893     case 1:
7894       insn = gen_vec_extract_hi_<mode>;
7895       break;
7896     default:
7897       gcc_unreachable ();
7898     }
7900   emit_insn (insn (operands[0], operands[1]));
7901   DONE;
7904 (define_insn "vec_extract_lo_<mode><mask_name>"
7905   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,v,m")
7906         (vec_select:<ssehalfvecmode>
7907           (match_operand:V16FI 1 "<store_mask_predicate>"
7908                                  "v,<store_mask_constraint>,v")
7909           (parallel [(const_int 0) (const_int 1)
7910                      (const_int 2) (const_int 3)
7911                      (const_int 4) (const_int 5)
7912                      (const_int 6) (const_int 7)])))]
7913   "TARGET_AVX512F
7914    && <mask_mode512bit_condition>
7915    && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))"
7917   if (<mask_applied>
7918       || (!TARGET_AVX512VL
7919           && !REG_P (operands[0])
7920           && EXT_REX_SSE_REG_P (operands[1])))
7921     return "vextract<shuffletype>32x8\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7922   else
7923     return "#";
7925   [(set_attr "type" "sselog1")
7926    (set_attr "prefix_extra" "1")
7927    (set_attr "length_immediate" "1")
7928    (set_attr "memory" "none,load,store")
7929    (set_attr "prefix" "evex")
7930    (set_attr "mode" "<sseinsnmode>")])
7932 (define_split
7933   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7934         (vec_select:<ssehalfvecmode>
7935           (match_operand:V16FI 1 "nonimmediate_operand")
7936           (parallel [(const_int 0) (const_int 1)
7937             (const_int 2) (const_int 3)
7938             (const_int 4) (const_int 5)
7939             (const_int 6) (const_int 7)])))]
7940   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7941    && reload_completed
7942    && (TARGET_AVX512VL
7943        || REG_P (operands[0])
7944        || !EXT_REX_SSE_REG_P (operands[1]))"
7945   [(set (match_dup 0) (match_dup 1))]
7947   if (!TARGET_AVX512VL
7948       && REG_P (operands[0])
7949       && EXT_REX_SSE_REG_P (operands[1]))
7950     operands[0]
7951       = lowpart_subreg (<MODE>mode, operands[0], <ssehalfvecmode>mode);
7952   else
7953     operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);
7956 (define_insn "vec_extract_lo_<mode><mask_name>"
7957   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,v,m")
7958         (vec_select:<ssehalfvecmode>
7959           (match_operand:VI8F_256 1 "<store_mask_predicate>"
7960                                     "v,<store_mask_constraint>,v")
7961           (parallel [(const_int 0) (const_int 1)])))]
7962   "TARGET_AVX
7963    && <mask_avx512vl_condition> && <mask_avx512dq_condition>
7964    && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))"
7966   if (<mask_applied>)
7967     return "vextract<shuffletype>64x2\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}";
7968   else
7969     return "#";
7971    [(set_attr "type" "sselog1")
7972     (set_attr "prefix_extra" "1")
7973     (set_attr "length_immediate" "1")
7974     (set_attr "memory" "none,load,store")
7975     (set_attr "prefix" "evex")
7976     (set_attr "mode" "XI")])
7978 (define_split
7979   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7980         (vec_select:<ssehalfvecmode>
7981           (match_operand:VI8F_256 1 "nonimmediate_operand")
7982           (parallel [(const_int 0) (const_int 1)])))]
7983   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7984    && reload_completed"
7985   [(set (match_dup 0) (match_dup 1))]
7986   "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
7988 (define_insn "vec_extract_hi_<mode><mask_name>"
7989   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,<store_mask_constraint>")
7990         (vec_select:<ssehalfvecmode>
7991           (match_operand:VI8F_256 1 "register_operand" "v,v")
7992           (parallel [(const_int 2) (const_int 3)])))]
7993   "TARGET_AVX && <mask_avx512vl_condition> && <mask_avx512dq_condition>"
7995   if (TARGET_AVX512VL)
7996   {
7997     if (TARGET_AVX512DQ)
7998       return "vextract<shuffletype>64x2\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}";
7999     else
8000       return "vextract<shuffletype>32x4\t{$0x1, %1, %0|%0, %1, 0x1}";
8001   }
8002   else
8003     return "vextract<i128>\t{$0x1, %1, %0|%0, %1, 0x1}";
8005   [(set_attr "type" "sselog1")
8006    (set_attr "prefix_extra" "1")
8007    (set_attr "length_immediate" "1")
8008    (set_attr "prefix" "vex")
8009    (set_attr "mode" "<sseinsnmode>")])
8011 (define_split
8012   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
8013         (vec_select:<ssehalfvecmode>
8014           (match_operand:VI4F_256 1 "nonimmediate_operand")
8015           (parallel [(const_int 0) (const_int 1)
8016                      (const_int 2) (const_int 3)])))]
8017   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))
8018    && reload_completed"
8019   [(set (match_dup 0) (match_dup 1))]
8020   "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
8022 (define_insn "vec_extract_lo_<mode><mask_name>"
8023   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>"
8024                                           "=<store_mask_constraint>,v")
8025         (vec_select:<ssehalfvecmode>
8026           (match_operand:VI4F_256 1 "<store_mask_predicate>"
8027                                     "v,<store_mask_constraint>")
8028           (parallel [(const_int 0) (const_int 1)
8029                      (const_int 2) (const_int 3)])))]
8030   "TARGET_AVX
8031    && <mask_avx512vl_condition> && <mask_avx512dq_condition>
8032    && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))"
8034   if (<mask_applied>)
8035     return "vextract<shuffletype>32x4\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
8036   else
8037     return "#";
8039   [(set_attr "type" "sselog1")
8040    (set_attr "prefix_extra" "1")
8041    (set_attr "length_immediate" "1")
8042    (set_attr "prefix" "evex")
8043    (set_attr "mode" "<sseinsnmode>")])
8045 (define_insn "vec_extract_lo_<mode>_maskm"
8046   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
8047         (vec_merge:<ssehalfvecmode>
8048           (vec_select:<ssehalfvecmode>
8049             (match_operand:VI4F_256 1 "register_operand" "v")
8050             (parallel [(const_int 0) (const_int 1)
8051                       (const_int 2) (const_int 3)]))
8052           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
8053           (match_operand:QI 3 "register_operand" "Yk")))]
8054   "TARGET_AVX512VL && TARGET_AVX512F
8055    && rtx_equal_p (operands[2], operands[0])"
8056   "vextract<shuffletype>32x4\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}"
8057   [(set_attr "type" "sselog1")
8058    (set_attr "prefix_extra" "1")
8059    (set_attr "length_immediate" "1")
8060    (set_attr "prefix" "evex")
8061    (set_attr "mode" "<sseinsnmode>")])
8063 (define_insn "vec_extract_hi_<mode>_maskm"
8064   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
8065         (vec_merge:<ssehalfvecmode>
8066           (vec_select:<ssehalfvecmode>
8067             (match_operand:VI4F_256 1 "register_operand" "v")
8068             (parallel [(const_int 4) (const_int 5)
8069                       (const_int 6) (const_int 7)]))
8070           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
8071           (match_operand:<ssehalfvecmode> 3 "register_operand" "Yk")))]
8072   "TARGET_AVX512F && TARGET_AVX512VL
8073    && rtx_equal_p (operands[2], operands[0])"
8074   "vextract<shuffletype>32x4\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
8075   [(set_attr "type" "sselog1")
8076    (set_attr "length_immediate" "1")
8077    (set_attr "prefix" "evex")
8078    (set_attr "mode" "<sseinsnmode>")])
8080 (define_insn "vec_extract_hi_<mode>_mask"
8081   [(set (match_operand:<ssehalfvecmode> 0 "register_operand" "=v")
8082         (vec_merge:<ssehalfvecmode>
8083           (vec_select:<ssehalfvecmode>
8084             (match_operand:VI4F_256 1 "register_operand" "v")
8085             (parallel [(const_int 4) (const_int 5)
8086                        (const_int 6) (const_int 7)]))
8087           (match_operand:<ssehalfvecmode> 2 "nonimm_or_0_operand" "0C")
8088           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
8089   "TARGET_AVX512VL"
8090   "vextract<shuffletype>32x4\t{$0x1, %1, %0%{%3%}%N2|%0%{%3%}%N2, %1, 0x1}"
8091   [(set_attr "type" "sselog1")
8092    (set_attr "length_immediate" "1")
8093    (set_attr "prefix" "evex")
8094    (set_attr "mode" "<sseinsnmode>")])
8096 (define_insn "vec_extract_hi_<mode>"
8097   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=xm, vm")
8098         (vec_select:<ssehalfvecmode>
8099           (match_operand:VI4F_256 1 "register_operand" "x, v")
8100           (parallel [(const_int 4) (const_int 5)
8101                      (const_int 6) (const_int 7)])))]
8102   "TARGET_AVX"
8103   "@
8104     vextract<i128>\t{$0x1, %1, %0|%0, %1, 0x1}
8105     vextract<shuffletype>32x4\t{$0x1, %1, %0|%0, %1, 0x1}"
8106   [(set_attr "isa" "*, avx512vl")
8107    (set_attr "prefix" "vex, evex")
8108    (set_attr "type" "sselog1")
8109    (set_attr "length_immediate" "1")
8110    (set_attr "mode" "<sseinsnmode>")])
8112 (define_insn_and_split "vec_extract_lo_v32hi"
8113   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=v,v,m")
8114         (vec_select:V16HI
8115           (match_operand:V32HI 1 "nonimmediate_operand" "v,m,v")
8116           (parallel [(const_int 0) (const_int 1)
8117                      (const_int 2) (const_int 3)
8118                      (const_int 4) (const_int 5)
8119                      (const_int 6) (const_int 7)
8120                      (const_int 8) (const_int 9)
8121                      (const_int 10) (const_int 11)
8122                      (const_int 12) (const_int 13)
8123                      (const_int 14) (const_int 15)])))]
8124   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8126   if (TARGET_AVX512VL
8127       || REG_P (operands[0])
8128       || !EXT_REX_SSE_REG_P (operands[1]))
8129     return "#";
8130   else
8131     return "vextracti64x4\t{$0x0, %1, %0|%0, %1, 0x0}";
8133   "&& reload_completed
8134    && (TARGET_AVX512VL
8135        || REG_P (operands[0])
8136        || !EXT_REX_SSE_REG_P (operands[1]))"
8137   [(set (match_dup 0) (match_dup 1))]
8139   if (!TARGET_AVX512VL
8140       && REG_P (operands[0])
8141       && EXT_REX_SSE_REG_P (operands[1]))
8142     operands[0] = lowpart_subreg (V32HImode, operands[0], V16HImode);
8143   else
8144     operands[1] = gen_lowpart (V16HImode, operands[1]);
8146   [(set_attr "type" "sselog1")
8147    (set_attr "prefix_extra" "1")
8148    (set_attr "length_immediate" "1")
8149    (set_attr "memory" "none,load,store")
8150    (set_attr "prefix" "evex")
8151    (set_attr "mode" "XI")])
8153 (define_insn "vec_extract_hi_v32hi"
8154   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=vm")
8155         (vec_select:V16HI
8156           (match_operand:V32HI 1 "register_operand" "v")
8157           (parallel [(const_int 16) (const_int 17)
8158                      (const_int 18) (const_int 19)
8159                      (const_int 20) (const_int 21)
8160                      (const_int 22) (const_int 23)
8161                      (const_int 24) (const_int 25)
8162                      (const_int 26) (const_int 27)
8163                      (const_int 28) (const_int 29)
8164                      (const_int 30) (const_int 31)])))]
8165   "TARGET_AVX512F"
8166   "vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
8167   [(set_attr "type" "sselog1")
8168    (set_attr "prefix_extra" "1")
8169    (set_attr "length_immediate" "1")
8170    (set_attr "prefix" "evex")
8171    (set_attr "mode" "XI")])
8173 (define_insn_and_split "vec_extract_lo_v16hi"
8174   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=v,m")
8175         (vec_select:V8HI
8176           (match_operand:V16HI 1 "nonimmediate_operand" "vm,v")
8177           (parallel [(const_int 0) (const_int 1)
8178                      (const_int 2) (const_int 3)
8179                      (const_int 4) (const_int 5)
8180                      (const_int 6) (const_int 7)])))]
8181   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8182   "#"
8183   "&& reload_completed"
8184   [(set (match_dup 0) (match_dup 1))]
8185   "operands[1] = gen_lowpart (V8HImode, operands[1]);")
8187 (define_insn "vec_extract_hi_v16hi"
8188   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=xm,vm,vm")
8189         (vec_select:V8HI
8190           (match_operand:V16HI 1 "register_operand" "x,v,v")
8191           (parallel [(const_int 8) (const_int 9)
8192                      (const_int 10) (const_int 11)
8193                      (const_int 12) (const_int 13)
8194                      (const_int 14) (const_int 15)])))]
8195   "TARGET_AVX"
8196   "@
8197    vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}
8198    vextracti32x4\t{$0x1, %1, %0|%0, %1, 0x1}
8199    vextracti32x4\t{$0x1, %g1, %0|%0, %g1, 0x1}"
8200   [(set_attr "type" "sselog1")
8201    (set_attr "prefix_extra" "1")
8202    (set_attr "length_immediate" "1")
8203    (set_attr "isa" "*,avx512dq,avx512f")
8204    (set_attr "prefix" "vex,evex,evex")
8205    (set_attr "mode" "OI")])
8207 (define_insn_and_split "vec_extract_lo_v64qi"
8208   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,v,m")
8209         (vec_select:V32QI
8210           (match_operand:V64QI 1 "nonimmediate_operand" "v,m,v")
8211           (parallel [(const_int 0) (const_int 1)
8212                      (const_int 2) (const_int 3)
8213                      (const_int 4) (const_int 5)
8214                      (const_int 6) (const_int 7)
8215                      (const_int 8) (const_int 9)
8216                      (const_int 10) (const_int 11)
8217                      (const_int 12) (const_int 13)
8218                      (const_int 14) (const_int 15)
8219                      (const_int 16) (const_int 17)
8220                      (const_int 18) (const_int 19)
8221                      (const_int 20) (const_int 21)
8222                      (const_int 22) (const_int 23)
8223                      (const_int 24) (const_int 25)
8224                      (const_int 26) (const_int 27)
8225                      (const_int 28) (const_int 29)
8226                      (const_int 30) (const_int 31)])))]
8227   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8229   if (TARGET_AVX512VL
8230       || REG_P (operands[0])
8231       || !EXT_REX_SSE_REG_P (operands[1]))
8232     return "#";
8233   else
8234     return "vextracti64x4\t{$0x0, %1, %0|%0, %1, 0x0}";
8236   "&& reload_completed
8237    && (TARGET_AVX512VL
8238        || REG_P (operands[0])
8239        || !EXT_REX_SSE_REG_P (operands[1]))"
8240   [(set (match_dup 0) (match_dup 1))]
8242   if (!TARGET_AVX512VL
8243       && REG_P (operands[0])
8244       && EXT_REX_SSE_REG_P (operands[1]))
8245     operands[0] = lowpart_subreg (V64QImode, operands[0], V32QImode);
8246   else
8247     operands[1] = gen_lowpart (V32QImode, operands[1]);
8249   [(set_attr "type" "sselog1")
8250    (set_attr "prefix_extra" "1")
8251    (set_attr "length_immediate" "1")
8252    (set_attr "memory" "none,load,store")
8253    (set_attr "prefix" "evex")
8254    (set_attr "mode" "XI")])
8256 (define_insn "vec_extract_hi_v64qi"
8257   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=vm")
8258         (vec_select:V32QI
8259           (match_operand:V64QI 1 "register_operand" "v")
8260           (parallel [(const_int 32) (const_int 33)
8261                      (const_int 34) (const_int 35)
8262                      (const_int 36) (const_int 37)
8263                      (const_int 38) (const_int 39)
8264                      (const_int 40) (const_int 41)
8265                      (const_int 42) (const_int 43)
8266                      (const_int 44) (const_int 45)
8267                      (const_int 46) (const_int 47)
8268                      (const_int 48) (const_int 49)
8269                      (const_int 50) (const_int 51)
8270                      (const_int 52) (const_int 53)
8271                      (const_int 54) (const_int 55)
8272                      (const_int 56) (const_int 57)
8273                      (const_int 58) (const_int 59)
8274                      (const_int 60) (const_int 61)
8275                      (const_int 62) (const_int 63)])))]
8276   "TARGET_AVX512F"
8277   "vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
8278   [(set_attr "type" "sselog1")
8279    (set_attr "prefix_extra" "1")
8280    (set_attr "length_immediate" "1")
8281    (set_attr "prefix" "evex")
8282    (set_attr "mode" "XI")])
8284 (define_insn_and_split "vec_extract_lo_v32qi"
8285   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=v,m")
8286         (vec_select:V16QI
8287           (match_operand:V32QI 1 "nonimmediate_operand" "vm,v")
8288           (parallel [(const_int 0) (const_int 1)
8289                      (const_int 2) (const_int 3)
8290                      (const_int 4) (const_int 5)
8291                      (const_int 6) (const_int 7)
8292                      (const_int 8) (const_int 9)
8293                      (const_int 10) (const_int 11)
8294                      (const_int 12) (const_int 13)
8295                      (const_int 14) (const_int 15)])))]
8296   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8297   "#"
8298   "&& reload_completed"
8299   [(set (match_dup 0) (match_dup 1))]
8300   "operands[1] = gen_lowpart (V16QImode, operands[1]);")
8302 (define_insn "vec_extract_hi_v32qi"
8303   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=xm,vm,vm")
8304         (vec_select:V16QI
8305           (match_operand:V32QI 1 "register_operand" "x,v,v")
8306           (parallel [(const_int 16) (const_int 17)
8307                      (const_int 18) (const_int 19)
8308                      (const_int 20) (const_int 21)
8309                      (const_int 22) (const_int 23)
8310                      (const_int 24) (const_int 25)
8311                      (const_int 26) (const_int 27)
8312                      (const_int 28) (const_int 29)
8313                      (const_int 30) (const_int 31)])))]
8314   "TARGET_AVX"
8315   "@
8316    vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}
8317    vextracti32x4\t{$0x1, %1, %0|%0, %1, 0x1}
8318    vextracti32x4\t{$0x1, %g1, %0|%0, %g1, 0x1}"
8319   [(set_attr "type" "sselog1")
8320    (set_attr "prefix_extra" "1")
8321    (set_attr "length_immediate" "1")
8322    (set_attr "isa" "*,avx512dq,avx512f")
8323    (set_attr "prefix" "vex,evex,evex")
8324    (set_attr "mode" "OI")])
8326 ;; Modes handled by vec_extract patterns.
8327 (define_mode_iterator VEC_EXTRACT_MODE
8328   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX") V16QI
8329    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX") V8HI
8330    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
8331    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI
8332    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
8333    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") V2DF
8334    (V4TI "TARGET_AVX512F") (V2TI "TARGET_AVX")])
8336 (define_expand "vec_extract<mode><ssescalarmodelower>"
8337   [(match_operand:<ssescalarmode> 0 "register_operand")
8338    (match_operand:VEC_EXTRACT_MODE 1 "register_operand")
8339    (match_operand 2 "const_int_operand")]
8340   "TARGET_SSE"
8342   ix86_expand_vector_extract (false, operands[0], operands[1],
8343                               INTVAL (operands[2]));
8344   DONE;
8347 (define_expand "vec_extract<mode><ssehalfvecmodelower>"
8348   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
8349    (match_operand:V_512 1 "register_operand")
8350    (match_operand 2 "const_0_to_1_operand")]
8351   "TARGET_AVX512F"
8353   if (INTVAL (operands[2]))
8354     emit_insn (gen_vec_extract_hi_<mode> (operands[0], operands[1]));
8355   else
8356     emit_insn (gen_vec_extract_lo_<mode> (operands[0], operands[1]));
8357   DONE;
8360 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8362 ;; Parallel double-precision floating point element swizzling
8364 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8366 (define_insn "<mask_codefor>avx512f_unpckhpd512<mask_name>"
8367   [(set (match_operand:V8DF 0 "register_operand" "=v")
8368         (vec_select:V8DF
8369           (vec_concat:V16DF
8370             (match_operand:V8DF 1 "register_operand" "v")
8371             (match_operand:V8DF 2 "nonimmediate_operand" "vm"))
8372           (parallel [(const_int 1) (const_int 9)
8373                      (const_int 3) (const_int 11)
8374                      (const_int 5) (const_int 13)
8375                      (const_int 7) (const_int 15)])))]
8376   "TARGET_AVX512F"
8377   "vunpckhpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8378   [(set_attr "type" "sselog")
8379    (set_attr "prefix" "evex")
8380    (set_attr "mode" "V8DF")])
8382 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
8383 (define_insn "avx_unpckhpd256<mask_name>"
8384   [(set (match_operand:V4DF 0 "register_operand" "=v")
8385         (vec_select:V4DF
8386           (vec_concat:V8DF
8387             (match_operand:V4DF 1 "register_operand" "v")
8388             (match_operand:V4DF 2 "nonimmediate_operand" "vm"))
8389           (parallel [(const_int 1) (const_int 5)
8390                      (const_int 3) (const_int 7)])))]
8391   "TARGET_AVX && <mask_avx512vl_condition>"
8392   "vunpckhpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8393   [(set_attr "type" "sselog")
8394    (set_attr "prefix" "vex")
8395    (set_attr "mode" "V4DF")])
8397 (define_expand "vec_interleave_highv4df"
8398   [(set (match_dup 3)
8399         (vec_select:V4DF
8400           (vec_concat:V8DF
8401             (match_operand:V4DF 1 "register_operand")
8402             (match_operand:V4DF 2 "nonimmediate_operand"))
8403           (parallel [(const_int 0) (const_int 4)
8404                      (const_int 2) (const_int 6)])))
8405    (set (match_dup 4)
8406         (vec_select:V4DF
8407           (vec_concat:V8DF
8408             (match_dup 1)
8409             (match_dup 2))
8410           (parallel [(const_int 1) (const_int 5)
8411                      (const_int 3) (const_int 7)])))
8412    (set (match_operand:V4DF 0 "register_operand")
8413         (vec_select:V4DF
8414           (vec_concat:V8DF
8415             (match_dup 3)
8416             (match_dup 4))
8417           (parallel [(const_int 2) (const_int 3)
8418                      (const_int 6) (const_int 7)])))]
8419  "TARGET_AVX"
8421   operands[3] = gen_reg_rtx (V4DFmode);
8422   operands[4] = gen_reg_rtx (V4DFmode);
8426 (define_insn "avx512vl_unpckhpd128_mask"
8427   [(set (match_operand:V2DF 0 "register_operand" "=v")
8428         (vec_merge:V2DF
8429           (vec_select:V2DF
8430             (vec_concat:V4DF
8431               (match_operand:V2DF 1 "register_operand" "v")
8432               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
8433             (parallel [(const_int 1) (const_int 3)]))
8434           (match_operand:V2DF 3 "nonimm_or_0_operand" "0C")
8435           (match_operand:QI 4 "register_operand" "Yk")))]
8436   "TARGET_AVX512VL"
8437   "vunpckhpd\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
8438   [(set_attr "type" "sselog")
8439    (set_attr "prefix" "evex")
8440    (set_attr "mode" "V2DF")])
8442 (define_expand "vec_interleave_highv2df"
8443   [(set (match_operand:V2DF 0 "register_operand")
8444         (vec_select:V2DF
8445           (vec_concat:V4DF
8446             (match_operand:V2DF 1 "nonimmediate_operand")
8447             (match_operand:V2DF 2 "nonimmediate_operand"))
8448           (parallel [(const_int 1)
8449                      (const_int 3)])))]
8450   "TARGET_SSE2"
8452   if (!ix86_vec_interleave_v2df_operator_ok (operands, 1))
8453     operands[2] = force_reg (V2DFmode, operands[2]);
8456 (define_insn "*vec_interleave_highv2df"
8457   [(set (match_operand:V2DF 0 "nonimmediate_operand"     "=x,v,v,x,v,m")
8458         (vec_select:V2DF
8459           (vec_concat:V4DF
8460             (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,o,o,o,v")
8461             (match_operand:V2DF 2 "nonimmediate_operand" " x,v,1,0,v,0"))
8462           (parallel [(const_int 1)
8463                      (const_int 3)])))]
8464   "TARGET_SSE2 && ix86_vec_interleave_v2df_operator_ok (operands, 1)"
8465   "@
8466    unpckhpd\t{%2, %0|%0, %2}
8467    vunpckhpd\t{%2, %1, %0|%0, %1, %2}
8468    %vmovddup\t{%H1, %0|%0, %H1}
8469    movlpd\t{%H1, %0|%0, %H1}
8470    vmovlpd\t{%H1, %2, %0|%0, %2, %H1}
8471    %vmovhpd\t{%1, %0|%q0, %1}"
8472   [(set_attr "isa" "noavx,avx,sse3,noavx,avx,*")
8473    (set_attr "type" "sselog,sselog,sselog,ssemov,ssemov,ssemov")
8474    (set (attr "prefix_data16")
8475      (if_then_else (eq_attr "alternative" "3,5")
8476                    (const_string "1")
8477                    (const_string "*")))
8478    (set_attr "prefix" "orig,maybe_evex,maybe_vex,orig,maybe_evex,maybe_vex")
8479    (set_attr "mode" "V2DF,V2DF,DF,V1DF,V1DF,V1DF")])
8481 (define_expand "avx512f_movddup512<mask_name>"
8482   [(set (match_operand:V8DF 0 "register_operand")
8483         (vec_select:V8DF
8484           (vec_concat:V16DF
8485             (match_operand:V8DF 1 "nonimmediate_operand")
8486             (match_dup 1))
8487           (parallel [(const_int 0) (const_int 8)
8488                      (const_int 2) (const_int 10)
8489                      (const_int 4) (const_int 12)
8490                      (const_int 6) (const_int 14)])))]
8491   "TARGET_AVX512F")
8493 (define_expand "avx512f_unpcklpd512<mask_name>"
8494   [(set (match_operand:V8DF 0 "register_operand")
8495         (vec_select:V8DF
8496           (vec_concat:V16DF
8497             (match_operand:V8DF 1 "register_operand")
8498             (match_operand:V8DF 2 "nonimmediate_operand"))
8499           (parallel [(const_int 0) (const_int 8)
8500                      (const_int 2) (const_int 10)
8501                      (const_int 4) (const_int 12)
8502                      (const_int 6) (const_int 14)])))]
8503   "TARGET_AVX512F")
8505 (define_insn "*avx512f_unpcklpd512<mask_name>"
8506   [(set (match_operand:V8DF 0 "register_operand" "=v,v")
8507         (vec_select:V8DF
8508           (vec_concat:V16DF
8509             (match_operand:V8DF 1 "nonimmediate_operand" "vm, v")
8510             (match_operand:V8DF 2 "nonimmediate_operand" "1 ,vm"))
8511           (parallel [(const_int 0) (const_int 8)
8512                      (const_int 2) (const_int 10)
8513                      (const_int 4) (const_int 12)
8514                      (const_int 6) (const_int 14)])))]
8515   "TARGET_AVX512F"
8516   "@
8517    vmovddup\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}
8518    vunpcklpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8519   [(set_attr "type" "sselog")
8520    (set_attr "prefix" "evex")
8521    (set_attr "mode" "V8DF")])
8523 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
8524 (define_expand "avx_movddup256<mask_name>"
8525   [(set (match_operand:V4DF 0 "register_operand")
8526         (vec_select:V4DF
8527           (vec_concat:V8DF
8528             (match_operand:V4DF 1 "nonimmediate_operand")
8529             (match_dup 1))
8530           (parallel [(const_int 0) (const_int 4)
8531                      (const_int 2) (const_int 6)])))]
8532   "TARGET_AVX && <mask_avx512vl_condition>")
8534 (define_expand "avx_unpcklpd256<mask_name>"
8535   [(set (match_operand:V4DF 0 "register_operand")
8536         (vec_select:V4DF
8537           (vec_concat:V8DF
8538             (match_operand:V4DF 1 "register_operand")
8539             (match_operand:V4DF 2 "nonimmediate_operand"))
8540           (parallel [(const_int 0) (const_int 4)
8541                      (const_int 2) (const_int 6)])))]
8542   "TARGET_AVX && <mask_avx512vl_condition>")
8544 (define_insn "*avx_unpcklpd256<mask_name>"
8545   [(set (match_operand:V4DF 0 "register_operand"         "=v,v")
8546         (vec_select:V4DF
8547           (vec_concat:V8DF
8548             (match_operand:V4DF 1 "nonimmediate_operand" " v,m")
8549             (match_operand:V4DF 2 "nonimmediate_operand" "vm,1"))
8550           (parallel [(const_int 0) (const_int 4)
8551                      (const_int 2) (const_int 6)])))]
8552   "TARGET_AVX && <mask_avx512vl_condition>"
8553   "@
8554    vunpcklpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
8555    vmovddup\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}"
8556   [(set_attr "type" "sselog")
8557    (set_attr "prefix" "vex")
8558    (set_attr "mode" "V4DF")])
8560 (define_expand "vec_interleave_lowv4df"
8561   [(set (match_dup 3)
8562         (vec_select:V4DF
8563           (vec_concat:V8DF
8564             (match_operand:V4DF 1 "register_operand")
8565             (match_operand:V4DF 2 "nonimmediate_operand"))
8566           (parallel [(const_int 0) (const_int 4)
8567                      (const_int 2) (const_int 6)])))
8568    (set (match_dup 4)
8569         (vec_select:V4DF
8570           (vec_concat:V8DF
8571             (match_dup 1)
8572             (match_dup 2))
8573           (parallel [(const_int 1) (const_int 5)
8574                      (const_int 3) (const_int 7)])))
8575    (set (match_operand:V4DF 0 "register_operand")
8576         (vec_select:V4DF
8577           (vec_concat:V8DF
8578             (match_dup 3)
8579             (match_dup 4))
8580           (parallel [(const_int 0) (const_int 1)
8581                      (const_int 4) (const_int 5)])))]
8582  "TARGET_AVX"
8584   operands[3] = gen_reg_rtx (V4DFmode);
8585   operands[4] = gen_reg_rtx (V4DFmode);
8588 (define_insn "avx512vl_unpcklpd128_mask"
8589   [(set (match_operand:V2DF 0 "register_operand" "=v")
8590         (vec_merge:V2DF
8591           (vec_select:V2DF
8592             (vec_concat:V4DF
8593               (match_operand:V2DF 1 "register_operand" "v")
8594               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
8595             (parallel [(const_int 0) (const_int 2)]))
8596           (match_operand:V2DF 3 "nonimm_or_0_operand" "0C")
8597           (match_operand:QI 4 "register_operand" "Yk")))]
8598   "TARGET_AVX512VL"
8599   "vunpcklpd\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
8600   [(set_attr "type" "sselog")
8601    (set_attr "prefix" "evex")
8602    (set_attr "mode" "V2DF")])
8604 (define_expand "vec_interleave_lowv2df"
8605   [(set (match_operand:V2DF 0 "register_operand")
8606         (vec_select:V2DF
8607           (vec_concat:V4DF
8608             (match_operand:V2DF 1 "nonimmediate_operand")
8609             (match_operand:V2DF 2 "nonimmediate_operand"))
8610           (parallel [(const_int 0)
8611                      (const_int 2)])))]
8612   "TARGET_SSE2"
8614   if (!ix86_vec_interleave_v2df_operator_ok (operands, 0))
8615     operands[1] = force_reg (V2DFmode, operands[1]);
8618 (define_insn "*vec_interleave_lowv2df"
8619   [(set (match_operand:V2DF 0 "nonimmediate_operand"     "=x,v,v,x,v,o")
8620         (vec_select:V2DF
8621           (vec_concat:V4DF
8622             (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,m,0,v,0")
8623             (match_operand:V2DF 2 "nonimmediate_operand" " x,v,1,m,m,v"))
8624           (parallel [(const_int 0)
8625                      (const_int 2)])))]
8626   "TARGET_SSE2 && ix86_vec_interleave_v2df_operator_ok (operands, 0)"
8627   "@
8628    unpcklpd\t{%2, %0|%0, %2}
8629    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
8630    %vmovddup\t{%1, %0|%0, %q1}
8631    movhpd\t{%2, %0|%0, %q2}
8632    vmovhpd\t{%2, %1, %0|%0, %1, %q2}
8633    %vmovlpd\t{%2, %H0|%H0, %2}"
8634   [(set_attr "isa" "noavx,avx,sse3,noavx,avx,*")
8635    (set_attr "type" "sselog,sselog,sselog,ssemov,ssemov,ssemov")
8636    (set (attr "prefix_data16")
8637      (if_then_else (eq_attr "alternative" "3,5")
8638                    (const_string "1")
8639                    (const_string "*")))
8640    (set_attr "prefix" "orig,maybe_evex,maybe_vex,orig,maybe_evex,maybe_vex")
8641    (set_attr "mode" "V2DF,V2DF,DF,V1DF,V1DF,V1DF")])
8643 (define_split
8644   [(set (match_operand:V2DF 0 "memory_operand")
8645         (vec_select:V2DF
8646           (vec_concat:V4DF
8647             (match_operand:V2DF 1 "register_operand")
8648             (match_dup 1))
8649           (parallel [(const_int 0)
8650                      (const_int 2)])))]
8651   "TARGET_SSE3 && reload_completed"
8652   [(const_int 0)]
8654   rtx low = gen_lowpart (DFmode, operands[1]);
8656   emit_move_insn (adjust_address (operands[0], DFmode, 0), low);
8657   emit_move_insn (adjust_address (operands[0], DFmode, 8), low);
8658   DONE;
8661 (define_split
8662   [(set (match_operand:V2DF 0 "register_operand")
8663         (vec_select:V2DF
8664           (vec_concat:V4DF
8665             (match_operand:V2DF 1 "memory_operand")
8666             (match_dup 1))
8667           (parallel [(match_operand:SI 2 "const_0_to_1_operand")
8668                      (match_operand:SI 3 "const_int_operand")])))]
8669   "TARGET_SSE3 && INTVAL (operands[2]) + 2 == INTVAL (operands[3])"
8670   [(set (match_dup 0) (vec_duplicate:V2DF (match_dup 1)))]
8672   operands[1] = adjust_address (operands[1], DFmode, INTVAL (operands[2]) * 8);
8675 (define_insn "avx512f_vmscalef<mode><mask_scalar_name><round_scalar_name>"
8676   [(set (match_operand:VF_128 0 "register_operand" "=v")
8677         (vec_merge:VF_128
8678           (unspec:VF_128
8679             [(match_operand:VF_128 1 "register_operand" "v")
8680              (match_operand:VF_128 2 "<round_scalar_nimm_predicate>" "<round_scalar_constraint>")]
8681             UNSPEC_SCALEF)
8682           (match_dup 1)
8683           (const_int 1)))]
8684   "TARGET_AVX512F"
8685   "vscalef<ssescalarmodesuffix>\t{<round_scalar_mask_op3>%2, %1, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %1, %2<round_scalar_mask_op3>}"
8686   [(set_attr "prefix" "evex")
8687    (set_attr "mode"  "<ssescalarmode>")])
8689 (define_insn "<avx512>_scalef<mode><mask_name><round_name>"
8690   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8691         (unspec:VF_AVX512VL
8692           [(match_operand:VF_AVX512VL 1 "register_operand" "v")
8693            (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")]
8694           UNSPEC_SCALEF))]
8695   "TARGET_AVX512F"
8696   "vscalef<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
8697   [(set_attr "prefix" "evex")
8698    (set_attr "mode"  "<MODE>")])
8700 (define_expand "<avx512>_vternlog<mode>_maskz"
8701   [(match_operand:VI48_AVX512VL 0 "register_operand")
8702    (match_operand:VI48_AVX512VL 1 "register_operand")
8703    (match_operand:VI48_AVX512VL 2 "register_operand")
8704    (match_operand:VI48_AVX512VL 3 "nonimmediate_operand")
8705    (match_operand:SI 4 "const_0_to_255_operand")
8706    (match_operand:<avx512fmaskmode> 5 "register_operand")]
8707   "TARGET_AVX512F"
8709   emit_insn (gen_<avx512>_vternlog<mode>_maskz_1 (
8710     operands[0], operands[1], operands[2], operands[3],
8711     operands[4], CONST0_RTX (<MODE>mode), operands[5]));
8712   DONE;
8715 (define_insn "<avx512>_vternlog<mode><sd_maskz_name>"
8716   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
8717         (unspec:VI48_AVX512VL
8718           [(match_operand:VI48_AVX512VL 1 "register_operand" "0")
8719            (match_operand:VI48_AVX512VL 2 "register_operand" "v")
8720            (match_operand:VI48_AVX512VL 3 "nonimmediate_operand" "vm")
8721            (match_operand:SI 4 "const_0_to_255_operand")]
8722           UNSPEC_VTERNLOG))]
8723   "TARGET_AVX512F"
8724   "vpternlog<ssemodesuffix>\t{%4, %3, %2, %0<sd_mask_op5>|%0<sd_mask_op5>, %2, %3, %4}"
8725   [(set_attr "type" "sselog")
8726    (set_attr "prefix" "evex")
8727    (set_attr "mode" "<sseinsnmode>")])
8729 (define_insn "<avx512>_vternlog<mode>_mask"
8730   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
8731         (vec_merge:VI48_AVX512VL
8732           (unspec:VI48_AVX512VL
8733             [(match_operand:VI48_AVX512VL 1 "register_operand" "0")
8734              (match_operand:VI48_AVX512VL 2 "register_operand" "v")
8735              (match_operand:VI48_AVX512VL 3 "nonimmediate_operand" "vm")
8736              (match_operand:SI 4 "const_0_to_255_operand")]
8737             UNSPEC_VTERNLOG)
8738           (match_dup 1)
8739           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
8740   "TARGET_AVX512F"
8741   "vpternlog<ssemodesuffix>\t{%4, %3, %2, %0%{%5%}|%0%{%5%}, %2, %3, %4}"
8742   [(set_attr "type" "sselog")
8743    (set_attr "prefix" "evex")
8744    (set_attr "mode" "<sseinsnmode>")])
8746 (define_insn "<avx512>_getexp<mode><mask_name><round_saeonly_name>"
8747   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8748         (unspec:VF_AVX512VL [(match_operand:VF_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
8749                         UNSPEC_GETEXP))]
8750    "TARGET_AVX512F"
8751    "vgetexp<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}";
8752     [(set_attr "prefix" "evex")
8753      (set_attr "mode" "<MODE>")])
8755 (define_insn "avx512f_sgetexp<mode><mask_scalar_name><round_saeonly_scalar_name>"
8756   [(set (match_operand:VF_128 0 "register_operand" "=v")
8757         (vec_merge:VF_128
8758           (unspec:VF_128
8759             [(match_operand:VF_128 1 "register_operand" "v")
8760              (match_operand:VF_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")]
8761             UNSPEC_GETEXP)
8762           (match_dup 1)
8763           (const_int 1)))]
8764    "TARGET_AVX512F"
8765    "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>}";
8766     [(set_attr "prefix" "evex")
8767      (set_attr "mode" "<ssescalarmode>")])
8769 (define_insn "<mask_codefor><avx512>_align<mode><mask_name>"
8770   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
8771         (unspec:VI48_AVX512VL [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
8772                                (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")
8773                                (match_operand:SI 3 "const_0_to_255_operand")]
8774                               UNSPEC_ALIGN))]
8775   "TARGET_AVX512F"
8776   "valign<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}";
8777   [(set_attr "prefix" "evex")
8778    (set_attr "mode" "<sseinsnmode>")])
8780 (define_expand "avx512f_shufps512_mask"
8781   [(match_operand:V16SF 0 "register_operand")
8782    (match_operand:V16SF 1 "register_operand")
8783    (match_operand:V16SF 2 "nonimmediate_operand")
8784    (match_operand:SI 3 "const_0_to_255_operand")
8785    (match_operand:V16SF 4 "register_operand")
8786    (match_operand:HI 5 "register_operand")]
8787   "TARGET_AVX512F"
8789   int mask = INTVAL (operands[3]);
8790   emit_insn (gen_avx512f_shufps512_1_mask (operands[0], operands[1], operands[2],
8791                                           GEN_INT ((mask >> 0) & 3),
8792                                           GEN_INT ((mask >> 2) & 3),
8793                                           GEN_INT (((mask >> 4) & 3) + 16),
8794                                           GEN_INT (((mask >> 6) & 3) + 16),
8795                                           GEN_INT (((mask >> 0) & 3) + 4),
8796                                           GEN_INT (((mask >> 2) & 3) + 4),
8797                                           GEN_INT (((mask >> 4) & 3) + 20),
8798                                           GEN_INT (((mask >> 6) & 3) + 20),
8799                                           GEN_INT (((mask >> 0) & 3) + 8),
8800                                           GEN_INT (((mask >> 2) & 3) + 8),
8801                                           GEN_INT (((mask >> 4) & 3) + 24),
8802                                           GEN_INT (((mask >> 6) & 3) + 24),
8803                                           GEN_INT (((mask >> 0) & 3) + 12),
8804                                           GEN_INT (((mask >> 2) & 3) + 12),
8805                                           GEN_INT (((mask >> 4) & 3) + 28),
8806                                           GEN_INT (((mask >> 6) & 3) + 28),
8807                                           operands[4], operands[5]));
8808   DONE;
8812 (define_expand "<avx512>_fixupimm<mode>_maskz<round_saeonly_expand_name>"
8813   [(match_operand:VF_AVX512VL 0 "register_operand")
8814    (match_operand:VF_AVX512VL 1 "register_operand")
8815    (match_operand:<sseintvecmode> 2 "<round_saeonly_expand_nimm_predicate>")
8816    (match_operand:SI 3 "const_0_to_255_operand")
8817    (match_operand:<avx512fmaskmode> 4 "register_operand")]
8818   "TARGET_AVX512F"
8820   emit_insn (gen_<avx512>_fixupimm<mode>_mask<round_saeonly_expand_name> (
8821         operands[0], operands[1], operands[2], operands[3],
8822         CONST0_RTX (<MODE>mode), operands[4]
8823         <round_saeonly_expand_operand5>));
8824   DONE;
8827 (define_insn "<avx512>_fixupimm<mode><mask_name><round_saeonly_name>"
8828   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8829         (unspec:VF_AVX512VL
8830           [(match_operand:VF_AVX512VL 1 "register_operand" "v")
8831            (match_operand:<sseintvecmode> 2 "nonimmediate_operand" "<round_saeonly_constraint>")
8832            (match_operand:SI 3 "const_0_to_255_operand")]
8833            UNSPEC_FIXUPIMM))]
8834   "TARGET_AVX512F"
8835   "vfixupimm<ssemodesuffix>\t{%3, <round_saeonly_mask_op4>%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2<round_saeonly_mask_op4>, %3}";
8836   [(set_attr "prefix" "evex")
8837    (set_attr "mode" "<MODE>")])
8839 (define_expand "avx512f_sfixupimm<mode>_maskz<round_saeonly_expand_name>"
8840   [(match_operand:VF_128 0 "register_operand")
8841    (match_operand:VF_128 1 "register_operand")
8842    (match_operand:<sseintvecmode> 2 "<round_saeonly_expand_nimm_predicate>")
8843    (match_operand:SI 3 "const_0_to_255_operand")
8844    (match_operand:<avx512fmaskmode> 4 "register_operand")]
8845   "TARGET_AVX512F"
8847   emit_insn (gen_avx512f_sfixupimm<mode>_mask<round_saeonly_expand_name> (
8848         operands[0], operands[1], operands[2], operands[3],
8849         CONST0_RTX (<MODE>mode), operands[4]
8850         <round_saeonly_expand_operand5>));
8851   DONE;
8854 (define_insn "avx512f_sfixupimm<mode><mask_name><round_saeonly_name>"
8855   [(set (match_operand:VF_128 0 "register_operand" "=v")
8856         (unspec:VF_128
8857           [(match_operand:VF_128 1 "register_operand" "v")
8858              (match_operand:<sseintvecmode> 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8859              (match_operand:SI 3 "const_0_to_255_operand")]
8860             UNSPEC_FIXUPIMM))]
8861    "TARGET_AVX512F"
8862   "vfixupimm<ssescalarmodesuffix>\t{%3, <round_saeonly_mask_op4>%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %<iptr>2<round_saeonly_mask_op4>, %3}";
8863   [(set_attr "prefix" "evex")
8864    (set_attr "mode" "<ssescalarmode>")])
8866 (define_insn "<avx512>_rndscale<mode><mask_name><round_saeonly_name>"
8867   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8868         (unspec:VF_AVX512VL
8869           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "<round_saeonly_constraint>")
8870            (match_operand:SI 2 "const_0_to_255_operand")]
8871           UNSPEC_ROUND))]
8872   "TARGET_AVX512F"
8873   "vrndscale<ssemodesuffix>\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}"
8874   [(set_attr "length_immediate" "1")
8875    (set_attr "prefix" "evex")
8876    (set_attr "mode" "<MODE>")])
8878 (define_insn "avx512f_rndscale<mode><round_saeonly_name>"
8879   [(set (match_operand:VF_128 0 "register_operand" "=v")
8880         (vec_merge:VF_128
8881           (unspec:VF_128
8882             [(match_operand:VF_128 1 "register_operand" "v")
8883              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8884              (match_operand:SI 3 "const_0_to_255_operand")]
8885             UNSPEC_ROUND)
8886           (match_dup 1)
8887           (const_int 1)))]
8888   "TARGET_AVX512F"
8889   "vrndscale<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %<iptr>2<round_saeonly_op4>, %3}"
8890   [(set_attr "length_immediate" "1")
8891    (set_attr "prefix" "evex")
8892    (set_attr "mode" "<MODE>")])
8894 ;; One bit in mask selects 2 elements.
8895 (define_insn "avx512f_shufps512_1<mask_name>"
8896   [(set (match_operand:V16SF 0 "register_operand" "=v")
8897         (vec_select:V16SF
8898           (vec_concat:V32SF
8899             (match_operand:V16SF 1 "register_operand" "v")
8900             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
8901           (parallel [(match_operand 3  "const_0_to_3_operand")
8902                      (match_operand 4  "const_0_to_3_operand")
8903                      (match_operand 5  "const_16_to_19_operand")
8904                      (match_operand 6  "const_16_to_19_operand")
8905                      (match_operand 7  "const_4_to_7_operand")
8906                      (match_operand 8  "const_4_to_7_operand")
8907                      (match_operand 9  "const_20_to_23_operand")
8908                      (match_operand 10  "const_20_to_23_operand")
8909                      (match_operand 11  "const_8_to_11_operand")
8910                      (match_operand 12  "const_8_to_11_operand")
8911                      (match_operand 13  "const_24_to_27_operand")
8912                      (match_operand 14  "const_24_to_27_operand")
8913                      (match_operand 15  "const_12_to_15_operand")
8914                      (match_operand 16  "const_12_to_15_operand")
8915                      (match_operand 17  "const_28_to_31_operand")
8916                      (match_operand 18  "const_28_to_31_operand")])))]
8917   "TARGET_AVX512F
8918    && (INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
8919        && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
8920        && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4)
8921        && INTVAL (operands[6]) == (INTVAL (operands[10]) - 4)
8922        && INTVAL (operands[3]) == (INTVAL (operands[11]) - 8)
8923        && INTVAL (operands[4]) == (INTVAL (operands[12]) - 8)
8924        && INTVAL (operands[5]) == (INTVAL (operands[13]) - 8)
8925        && INTVAL (operands[6]) == (INTVAL (operands[14]) - 8)
8926        && INTVAL (operands[3]) == (INTVAL (operands[15]) - 12)
8927        && INTVAL (operands[4]) == (INTVAL (operands[16]) - 12)
8928        && INTVAL (operands[5]) == (INTVAL (operands[17]) - 12)
8929        && INTVAL (operands[6]) == (INTVAL (operands[18]) - 12))"
8931   int mask;
8932   mask = INTVAL (operands[3]);
8933   mask |= INTVAL (operands[4]) << 2;
8934   mask |= (INTVAL (operands[5]) - 16) << 4;
8935   mask |= (INTVAL (operands[6]) - 16) << 6;
8936   operands[3] = GEN_INT (mask);
8938   return "vshufps\t{%3, %2, %1, %0<mask_operand19>|%0<mask_operand19>, %1, %2, %3}";
8940   [(set_attr "type" "sselog")
8941    (set_attr "length_immediate" "1")
8942    (set_attr "prefix" "evex")
8943    (set_attr "mode" "V16SF")])
8945 (define_expand "avx512f_shufpd512_mask"
8946   [(match_operand:V8DF 0 "register_operand")
8947    (match_operand:V8DF 1 "register_operand")
8948    (match_operand:V8DF 2 "nonimmediate_operand")
8949    (match_operand:SI 3 "const_0_to_255_operand")
8950    (match_operand:V8DF 4 "register_operand")
8951    (match_operand:QI 5 "register_operand")]
8952   "TARGET_AVX512F"
8954   int mask = INTVAL (operands[3]);
8955   emit_insn (gen_avx512f_shufpd512_1_mask (operands[0], operands[1], operands[2],
8956                                         GEN_INT (mask & 1),
8957                                         GEN_INT (mask & 2 ? 9 : 8),
8958                                         GEN_INT (mask & 4 ? 3 : 2),
8959                                         GEN_INT (mask & 8 ? 11 : 10),
8960                                         GEN_INT (mask & 16 ? 5 : 4),
8961                                         GEN_INT (mask & 32 ? 13 : 12),
8962                                         GEN_INT (mask & 64 ? 7 : 6),
8963                                         GEN_INT (mask & 128 ? 15 : 14),
8964                                         operands[4], operands[5]));
8965   DONE;
8968 (define_insn "avx512f_shufpd512_1<mask_name>"
8969   [(set (match_operand:V8DF 0 "register_operand" "=v")
8970         (vec_select:V8DF
8971           (vec_concat:V16DF
8972             (match_operand:V8DF 1 "register_operand" "v")
8973             (match_operand:V8DF 2 "nonimmediate_operand" "vm"))
8974           (parallel [(match_operand 3 "const_0_to_1_operand")
8975                      (match_operand 4 "const_8_to_9_operand")
8976                      (match_operand 5 "const_2_to_3_operand")
8977                      (match_operand 6 "const_10_to_11_operand")
8978                      (match_operand 7 "const_4_to_5_operand")
8979                      (match_operand 8 "const_12_to_13_operand")
8980                      (match_operand 9 "const_6_to_7_operand")
8981                      (match_operand 10 "const_14_to_15_operand")])))]
8982   "TARGET_AVX512F"
8984   int mask;
8985   mask = INTVAL (operands[3]);
8986   mask |= (INTVAL (operands[4]) - 8) << 1;
8987   mask |= (INTVAL (operands[5]) - 2) << 2;
8988   mask |= (INTVAL (operands[6]) - 10) << 3;
8989   mask |= (INTVAL (operands[7]) - 4) << 4;
8990   mask |= (INTVAL (operands[8]) - 12) << 5;
8991   mask |= (INTVAL (operands[9]) - 6) << 6;
8992   mask |= (INTVAL (operands[10]) - 14) << 7;
8993   operands[3] = GEN_INT (mask);
8995   return "vshufpd\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
8997   [(set_attr "type" "sselog")
8998    (set_attr "length_immediate" "1")
8999    (set_attr "prefix" "evex")
9000    (set_attr "mode" "V8DF")])
9002 (define_expand "avx_shufpd256<mask_expand4_name>"
9003   [(match_operand:V4DF 0 "register_operand")
9004    (match_operand:V4DF 1 "register_operand")
9005    (match_operand:V4DF 2 "nonimmediate_operand")
9006    (match_operand:SI 3 "const_int_operand")]
9007   "TARGET_AVX"
9009   int mask = INTVAL (operands[3]);
9010   emit_insn (gen_avx_shufpd256_1<mask_expand4_name> (operands[0],
9011                                                      operands[1],
9012                                                      operands[2],
9013                                                      GEN_INT (mask & 1),
9014                                                      GEN_INT (mask & 2 ? 5 : 4),
9015                                                      GEN_INT (mask & 4 ? 3 : 2),
9016                                                      GEN_INT (mask & 8 ? 7 : 6)
9017                                                      <mask_expand4_args>));
9018   DONE;
9021 (define_insn "avx_shufpd256_1<mask_name>"
9022   [(set (match_operand:V4DF 0 "register_operand" "=v")
9023         (vec_select:V4DF
9024           (vec_concat:V8DF
9025             (match_operand:V4DF 1 "register_operand" "v")
9026             (match_operand:V4DF 2 "nonimmediate_operand" "vm"))
9027           (parallel [(match_operand 3 "const_0_to_1_operand")
9028                      (match_operand 4 "const_4_to_5_operand")
9029                      (match_operand 5 "const_2_to_3_operand")
9030                      (match_operand 6 "const_6_to_7_operand")])))]
9031   "TARGET_AVX && <mask_avx512vl_condition>"
9033   int mask;
9034   mask = INTVAL (operands[3]);
9035   mask |= (INTVAL (operands[4]) - 4) << 1;
9036   mask |= (INTVAL (operands[5]) - 2) << 2;
9037   mask |= (INTVAL (operands[6]) - 6) << 3;
9038   operands[3] = GEN_INT (mask);
9040   return "vshufpd\t{%3, %2, %1, %0<mask_operand7>|%0<mask_operand7>, %1, %2, %3}";
9042   [(set_attr "type" "sseshuf")
9043    (set_attr "length_immediate" "1")
9044    (set_attr "prefix" "vex")
9045    (set_attr "mode" "V4DF")])
9047 (define_expand "sse2_shufpd<mask_expand4_name>"
9048   [(match_operand:V2DF 0 "register_operand")
9049    (match_operand:V2DF 1 "register_operand")
9050    (match_operand:V2DF 2 "vector_operand")
9051    (match_operand:SI 3 "const_int_operand")]
9052   "TARGET_SSE2"
9054   int mask = INTVAL (operands[3]);
9055   emit_insn (gen_sse2_shufpd_v2df<mask_expand4_name> (operands[0], operands[1],
9056                                                       operands[2], GEN_INT (mask & 1),
9057                                                       GEN_INT (mask & 2 ? 3 : 2)
9058                                                       <mask_expand4_args>));
9059   DONE;
9062 (define_insn "sse2_shufpd_v2df_mask"
9063   [(set (match_operand:V2DF 0 "register_operand" "=v")
9064     (vec_merge:V2DF
9065           (vec_select:V2DF
9066             (vec_concat:V4DF
9067               (match_operand:V2DF 1 "register_operand" "v")
9068               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
9069             (parallel [(match_operand 3 "const_0_to_1_operand")
9070                            (match_operand 4 "const_2_to_3_operand")]))
9071       (match_operand:V2DF 5 "nonimm_or_0_operand" "0C")
9072       (match_operand:QI 6 "register_operand" "Yk")))]
9073   "TARGET_AVX512VL"
9075   int mask;
9076   mask = INTVAL (operands[3]);
9077   mask |= (INTVAL (operands[4]) - 2) << 1;
9078   operands[3] = GEN_INT (mask);
9080   return "vshufpd\t{%3, %2, %1, %0%{%6%}%N5|%0%{%6%}%N5, %1, %2, %3}";
9082   [(set_attr "type" "sseshuf")
9083    (set_attr "length_immediate" "1")
9084    (set_attr "prefix" "evex")
9085    (set_attr "mode" "V2DF")])
9087 ;; punpcklqdq and punpckhqdq are shorter than shufpd.
9088 (define_insn "avx2_interleave_highv4di<mask_name>"
9089   [(set (match_operand:V4DI 0 "register_operand" "=v")
9090         (vec_select:V4DI
9091           (vec_concat:V8DI
9092             (match_operand:V4DI 1 "register_operand" "v")
9093             (match_operand:V4DI 2 "nonimmediate_operand" "vm"))
9094           (parallel [(const_int 1)
9095                      (const_int 5)
9096                      (const_int 3)
9097                      (const_int 7)])))]
9098   "TARGET_AVX2 && <mask_avx512vl_condition>"
9099   "vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9100   [(set_attr "type" "sselog")
9101    (set_attr "prefix" "vex")
9102    (set_attr "mode" "OI")])
9104 (define_insn "<mask_codefor>avx512f_interleave_highv8di<mask_name>"
9105   [(set (match_operand:V8DI 0 "register_operand" "=v")
9106         (vec_select:V8DI
9107           (vec_concat:V16DI
9108             (match_operand:V8DI 1 "register_operand" "v")
9109             (match_operand:V8DI 2 "nonimmediate_operand" "vm"))
9110           (parallel [(const_int 1) (const_int 9)
9111                      (const_int 3) (const_int 11)
9112                      (const_int 5) (const_int 13)
9113                      (const_int 7) (const_int 15)])))]
9114   "TARGET_AVX512F"
9115   "vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9116   [(set_attr "type" "sselog")
9117    (set_attr "prefix" "evex")
9118    (set_attr "mode" "XI")])
9120 (define_insn "vec_interleave_highv2di<mask_name>"
9121   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
9122         (vec_select:V2DI
9123           (vec_concat:V4DI
9124             (match_operand:V2DI 1 "register_operand" "0,v")
9125             (match_operand:V2DI 2 "vector_operand" "xBm,vm"))
9126           (parallel [(const_int 1)
9127                      (const_int 3)])))]
9128   "TARGET_SSE2 && <mask_avx512vl_condition>"
9129   "@
9130    punpckhqdq\t{%2, %0|%0, %2}
9131    vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9132   [(set_attr "isa" "noavx,avx")
9133    (set_attr "type" "sselog")
9134    (set_attr "prefix_data16" "1,*")
9135    (set_attr "prefix" "orig,<mask_prefix>")
9136    (set_attr "mode" "TI")])
9138 (define_insn "avx2_interleave_lowv4di<mask_name>"
9139   [(set (match_operand:V4DI 0 "register_operand" "=v")
9140         (vec_select:V4DI
9141           (vec_concat:V8DI
9142             (match_operand:V4DI 1 "register_operand" "v")
9143             (match_operand:V4DI 2 "nonimmediate_operand" "vm"))
9144           (parallel [(const_int 0)
9145                      (const_int 4)
9146                      (const_int 2)
9147                      (const_int 6)])))]
9148   "TARGET_AVX2 && <mask_avx512vl_condition>"
9149   "vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9150   [(set_attr "type" "sselog")
9151    (set_attr "prefix" "vex")
9152    (set_attr "mode" "OI")])
9154 (define_insn "<mask_codefor>avx512f_interleave_lowv8di<mask_name>"
9155   [(set (match_operand:V8DI 0 "register_operand" "=v")
9156         (vec_select:V8DI
9157           (vec_concat:V16DI
9158             (match_operand:V8DI 1 "register_operand" "v")
9159             (match_operand:V8DI 2 "nonimmediate_operand" "vm"))
9160           (parallel [(const_int 0) (const_int 8)
9161                      (const_int 2) (const_int 10)
9162                      (const_int 4) (const_int 12)
9163                      (const_int 6) (const_int 14)])))]
9164   "TARGET_AVX512F"
9165   "vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9166   [(set_attr "type" "sselog")
9167    (set_attr "prefix" "evex")
9168    (set_attr "mode" "XI")])
9170 (define_insn "vec_interleave_lowv2di<mask_name>"
9171   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
9172         (vec_select:V2DI
9173           (vec_concat:V4DI
9174             (match_operand:V2DI 1 "register_operand" "0,v")
9175             (match_operand:V2DI 2 "vector_operand" "xBm,vm"))
9176           (parallel [(const_int 0)
9177                      (const_int 2)])))]
9178   "TARGET_SSE2 && <mask_avx512vl_condition>"
9179   "@
9180    punpcklqdq\t{%2, %0|%0, %2}
9181    vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9182   [(set_attr "isa" "noavx,avx")
9183    (set_attr "type" "sselog")
9184    (set_attr "prefix_data16" "1,*")
9185    (set_attr "prefix" "orig,vex")
9186    (set_attr "mode" "TI")])
9188 (define_insn "sse2_shufpd_<mode>"
9189   [(set (match_operand:VI8F_128 0 "register_operand" "=x,v")
9190         (vec_select:VI8F_128
9191           (vec_concat:<ssedoublevecmode>
9192             (match_operand:VI8F_128 1 "register_operand" "0,v")
9193             (match_operand:VI8F_128 2 "vector_operand" "xBm,vm"))
9194           (parallel [(match_operand 3 "const_0_to_1_operand")
9195                      (match_operand 4 "const_2_to_3_operand")])))]
9196   "TARGET_SSE2"
9198   int mask;
9199   mask = INTVAL (operands[3]);
9200   mask |= (INTVAL (operands[4]) - 2) << 1;
9201   operands[3] = GEN_INT (mask);
9203   switch (which_alternative)
9204     {
9205     case 0:
9206       return "shufpd\t{%3, %2, %0|%0, %2, %3}";
9207     case 1:
9208       return "vshufpd\t{%3, %2, %1, %0|%0, %1, %2, %3}";
9209     default:
9210       gcc_unreachable ();
9211     }
9213   [(set_attr "isa" "noavx,avx")
9214    (set_attr "type" "sseshuf")
9215    (set_attr "length_immediate" "1")
9216    (set_attr "prefix" "orig,maybe_evex")
9217    (set_attr "mode" "V2DF")])
9219 ;; Avoid combining registers from different units in a single alternative,
9220 ;; see comment above inline_secondary_memory_needed function in i386.c
9221 (define_insn "sse2_storehpd"
9222   [(set (match_operand:DF 0 "nonimmediate_operand"     "=m,x,Yv,x,*f,r")
9223         (vec_select:DF
9224           (match_operand:V2DF 1 "nonimmediate_operand" " v,0, v,o,o,o")
9225           (parallel [(const_int 1)])))]
9226   "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
9227   "@
9228    %vmovhpd\t{%1, %0|%0, %1}
9229    unpckhpd\t%0, %0
9230    vunpckhpd\t{%d1, %0|%0, %d1}
9231    #
9232    #
9233    #"
9234   [(set_attr "isa" "*,noavx,avx,*,*,*")
9235    (set_attr "type" "ssemov,sselog1,sselog1,ssemov,fmov,imov")
9236    (set (attr "prefix_data16")
9237      (if_then_else
9238        (and (eq_attr "alternative" "0")
9239             (not (match_test "TARGET_AVX")))
9240        (const_string "1")
9241        (const_string "*")))
9242    (set_attr "prefix" "maybe_vex,orig,maybe_evex,*,*,*")
9243    (set_attr "mode" "V1DF,V1DF,V2DF,DF,DF,DF")])
9245 (define_split
9246   [(set (match_operand:DF 0 "register_operand")
9247         (vec_select:DF
9248           (match_operand:V2DF 1 "memory_operand")
9249           (parallel [(const_int 1)])))]
9250   "TARGET_SSE2 && reload_completed"
9251   [(set (match_dup 0) (match_dup 1))]
9252   "operands[1] = adjust_address (operands[1], DFmode, 8);")
9254 (define_insn "*vec_extractv2df_1_sse"
9255   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x")
9256         (vec_select:DF
9257           (match_operand:V2DF 1 "nonimmediate_operand" "x,x,o")
9258           (parallel [(const_int 1)])))]
9259   "!TARGET_SSE2 && TARGET_SSE
9260    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
9261   "@
9262    movhps\t{%1, %0|%q0, %1}
9263    movhlps\t{%1, %0|%0, %1}
9264    movlps\t{%H1, %0|%0, %H1}"
9265   [(set_attr "type" "ssemov")
9266    (set_attr "mode" "V2SF,V4SF,V2SF")])
9268 ;; Avoid combining registers from different units in a single alternative,
9269 ;; see comment above inline_secondary_memory_needed function in i386.c
9270 (define_insn "sse2_storelpd"
9271   [(set (match_operand:DF 0 "nonimmediate_operand"     "=m,x,x,*f,r")
9272         (vec_select:DF
9273           (match_operand:V2DF 1 "nonimmediate_operand" " v,x,m,m,m")
9274           (parallel [(const_int 0)])))]
9275   "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
9276   "@
9277    %vmovlpd\t{%1, %0|%0, %1}
9278    #
9279    #
9280    #
9281    #"
9282   [(set_attr "type" "ssemov,ssemov,ssemov,fmov,imov")
9283    (set (attr "prefix_data16")
9284      (if_then_else (eq_attr "alternative" "0")
9285                    (const_string "1")
9286                    (const_string "*")))
9287    (set_attr "prefix" "maybe_vex")
9288    (set_attr "mode" "V1DF,DF,DF,DF,DF")])
9290 (define_split
9291   [(set (match_operand:DF 0 "register_operand")
9292         (vec_select:DF
9293           (match_operand:V2DF 1 "nonimmediate_operand")
9294           (parallel [(const_int 0)])))]
9295   "TARGET_SSE2 && reload_completed"
9296   [(set (match_dup 0) (match_dup 1))]
9297   "operands[1] = gen_lowpart (DFmode, operands[1]);")
9299 (define_insn "*vec_extractv2df_0_sse"
9300   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x")
9301         (vec_select:DF
9302           (match_operand:V2DF 1 "nonimmediate_operand" "x,x,m")
9303           (parallel [(const_int 0)])))]
9304   "!TARGET_SSE2 && TARGET_SSE
9305    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
9306   "@
9307    movlps\t{%1, %0|%0, %1}
9308    movaps\t{%1, %0|%0, %1}
9309    movlps\t{%1, %0|%0, %q1}"
9310   [(set_attr "type" "ssemov")
9311    (set_attr "mode" "V2SF,V4SF,V2SF")])
9313 (define_expand "sse2_loadhpd_exp"
9314   [(set (match_operand:V2DF 0 "nonimmediate_operand")
9315         (vec_concat:V2DF
9316           (vec_select:DF
9317             (match_operand:V2DF 1 "nonimmediate_operand")
9318             (parallel [(const_int 0)]))
9319           (match_operand:DF 2 "nonimmediate_operand")))]
9320   "TARGET_SSE2"
9322   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V2DFmode, operands);
9324   emit_insn (gen_sse2_loadhpd (dst, operands[1], operands[2]));
9326   /* Fix up the destination if needed.  */
9327   if (dst != operands[0])
9328     emit_move_insn (operands[0], dst);
9330   DONE;
9333 ;; Avoid combining registers from different units in a single alternative,
9334 ;; see comment above inline_secondary_memory_needed function in i386.c
9335 (define_insn "sse2_loadhpd"
9336   [(set (match_operand:V2DF 0 "nonimmediate_operand"
9337           "=x,v,x,v ,o,o ,o")
9338         (vec_concat:V2DF
9339           (vec_select:DF
9340             (match_operand:V2DF 1 "nonimmediate_operand"
9341           " 0,v,0,v ,0,0 ,0")
9342             (parallel [(const_int 0)]))
9343           (match_operand:DF 2 "nonimmediate_operand"
9344           " m,m,x,Yv,x,*f,r")))]
9345   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
9346   "@
9347    movhpd\t{%2, %0|%0, %2}
9348    vmovhpd\t{%2, %1, %0|%0, %1, %2}
9349    unpcklpd\t{%2, %0|%0, %2}
9350    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
9351    #
9352    #
9353    #"
9354   [(set_attr "isa" "noavx,avx,noavx,avx,*,*,*")
9355    (set_attr "type" "ssemov,ssemov,sselog,sselog,ssemov,fmov,imov")
9356    (set (attr "prefix_data16")
9357      (if_then_else (eq_attr "alternative" "0")
9358                    (const_string "1")
9359                    (const_string "*")))
9360    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,*,*,*")
9361    (set_attr "mode" "V1DF,V1DF,V2DF,V2DF,DF,DF,DF")])
9363 (define_split
9364   [(set (match_operand:V2DF 0 "memory_operand")
9365         (vec_concat:V2DF
9366           (vec_select:DF (match_dup 0) (parallel [(const_int 0)]))
9367           (match_operand:DF 1 "register_operand")))]
9368   "TARGET_SSE2 && reload_completed"
9369   [(set (match_dup 0) (match_dup 1))]
9370   "operands[0] = adjust_address (operands[0], DFmode, 8);")
9372 (define_expand "sse2_loadlpd_exp"
9373   [(set (match_operand:V2DF 0 "nonimmediate_operand")
9374         (vec_concat:V2DF
9375           (match_operand:DF 2 "nonimmediate_operand")
9376           (vec_select:DF
9377             (match_operand:V2DF 1 "nonimmediate_operand")
9378             (parallel [(const_int 1)]))))]
9379   "TARGET_SSE2"
9381   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V2DFmode, operands);
9383   emit_insn (gen_sse2_loadlpd (dst, operands[1], operands[2]));
9385   /* Fix up the destination if needed.  */
9386   if (dst != operands[0])
9387     emit_move_insn (operands[0], dst);
9389   DONE;
9392 ;; Avoid combining registers from different units in a single alternative,
9393 ;; see comment above inline_secondary_memory_needed function in i386.c
9394 (define_insn "sse2_loadlpd"
9395   [(set (match_operand:V2DF 0 "nonimmediate_operand"
9396           "=v,x,v,x,v,x,x,v,m,m ,m")
9397         (vec_concat:V2DF
9398           (match_operand:DF 2 "nonimmediate_operand"
9399           "vm,m,m,x,v,0,0,v,x,*f,r")
9400           (vec_select:DF
9401             (match_operand:V2DF 1 "nonimm_or_0_operand"
9402           " C,0,v,0,v,x,o,o,0,0 ,0")
9403             (parallel [(const_int 1)]))))]
9404   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
9405   "@
9406    %vmovq\t{%2, %0|%0, %2}
9407    movlpd\t{%2, %0|%0, %2}
9408    vmovlpd\t{%2, %1, %0|%0, %1, %2}
9409    movsd\t{%2, %0|%0, %2}
9410    vmovsd\t{%2, %1, %0|%0, %1, %2}
9411    shufpd\t{$2, %1, %0|%0, %1, 2}
9412    movhpd\t{%H1, %0|%0, %H1}
9413    vmovhpd\t{%H1, %2, %0|%0, %2, %H1}
9414    #
9415    #
9416    #"
9417   [(set_attr "isa" "*,noavx,avx,noavx,avx,noavx,noavx,avx,*,*,*")
9418    (set (attr "type")
9419      (cond [(eq_attr "alternative" "5")
9420               (const_string "sselog")
9421             (eq_attr "alternative" "9")
9422               (const_string "fmov")
9423             (eq_attr "alternative" "10")
9424               (const_string "imov")
9425            ]
9426            (const_string "ssemov")))
9427    (set (attr "prefix_data16")
9428      (if_then_else (eq_attr "alternative" "1,6")
9429                    (const_string "1")
9430                    (const_string "*")))
9431    (set (attr "length_immediate")
9432      (if_then_else (eq_attr "alternative" "5")
9433                    (const_string "1")
9434                    (const_string "*")))
9435    (set (attr "prefix")
9436      (cond [(eq_attr "alternative" "0")
9437               (const_string "maybe_vex")
9438             (eq_attr "alternative" "1,3,5,6")
9439               (const_string "orig")
9440             (eq_attr "alternative" "2,4,7")
9441               (const_string "maybe_evex")
9442            ]
9443            (const_string "*")))
9444    (set_attr "mode" "DF,V1DF,V1DF,V1DF,V1DF,V2DF,V1DF,V1DF,DF,DF,DF")])
9446 (define_split
9447   [(set (match_operand:V2DF 0 "memory_operand")
9448         (vec_concat:V2DF
9449           (match_operand:DF 1 "register_operand")
9450           (vec_select:DF (match_dup 0) (parallel [(const_int 1)]))))]
9451   "TARGET_SSE2 && reload_completed"
9452   [(set (match_dup 0) (match_dup 1))]
9453   "operands[0] = adjust_address (operands[0], DFmode, 0);")
9455 (define_insn "sse2_movsd"
9456   [(set (match_operand:V2DF 0 "nonimmediate_operand"   "=x,v,x,v,m,x,x,v,o")
9457         (vec_merge:V2DF
9458           (match_operand:V2DF 2 "nonimmediate_operand" " x,v,m,m,v,0,0,v,0")
9459           (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,0,v,0,x,o,o,v")
9460           (const_int 1)))]
9461   "TARGET_SSE2"
9462   "@
9463    movsd\t{%2, %0|%0, %2}
9464    vmovsd\t{%2, %1, %0|%0, %1, %2}
9465    movlpd\t{%2, %0|%0, %q2}
9466    vmovlpd\t{%2, %1, %0|%0, %1, %q2}
9467    %vmovlpd\t{%2, %0|%q0, %2}
9468    shufpd\t{$2, %1, %0|%0, %1, 2}
9469    movhps\t{%H1, %0|%0, %H1}
9470    vmovhps\t{%H1, %2, %0|%0, %2, %H1}
9471    %vmovhps\t{%1, %H0|%H0, %1}"
9472   [(set_attr "isa" "noavx,avx,noavx,avx,*,noavx,noavx,avx,*")
9473    (set (attr "type")
9474      (if_then_else
9475        (eq_attr "alternative" "5")
9476        (const_string "sselog")
9477        (const_string "ssemov")))
9478    (set (attr "prefix_data16")
9479      (if_then_else
9480        (and (eq_attr "alternative" "2,4")
9481             (not (match_test "TARGET_AVX")))
9482        (const_string "1")
9483        (const_string "*")))
9484    (set (attr "length_immediate")
9485      (if_then_else (eq_attr "alternative" "5")
9486                    (const_string "1")
9487                    (const_string "*")))
9488    (set (attr "prefix")
9489      (cond [(eq_attr "alternative" "1,3,7")
9490               (const_string "maybe_evex")
9491             (eq_attr "alternative" "4,8")
9492               (const_string "maybe_vex")
9493            ]
9494            (const_string "orig")))
9495    (set_attr "mode" "DF,DF,V1DF,V1DF,V1DF,V2DF,V1DF,V1DF,V1DF")])
9497 (define_insn "vec_dupv2df<mask_name>"
9498   [(set (match_operand:V2DF 0 "register_operand"     "=x,x,v")
9499         (vec_duplicate:V2DF
9500           (match_operand:DF 1 "nonimmediate_operand" " 0,xm,vm")))]
9501   "TARGET_SSE2 && <mask_avx512vl_condition>"
9502   "@
9503    unpcklpd\t%0, %0
9504    %vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}
9505    vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
9506   [(set_attr "isa" "noavx,sse3,avx512vl")
9507    (set_attr "type" "sselog1")
9508    (set_attr "prefix" "orig,maybe_vex,evex")
9509    (set_attr "mode" "V2DF,DF,DF")])
9511 (define_insn "vec_concatv2df"
9512   [(set (match_operand:V2DF 0 "register_operand"     "=x,x,v,x,v,x,x, v,x,x")
9513         (vec_concat:V2DF
9514           (match_operand:DF 1 "nonimmediate_operand" " 0,x,v,m,m,0,x,xm,0,0")
9515           (match_operand:DF 2 "nonimm_or_0_operand"  " x,x,v,1,1,m,m, C,x,m")))]
9516   "TARGET_SSE
9517    && (!(MEM_P (operands[1]) && MEM_P (operands[2]))
9518        || (TARGET_SSE3 && rtx_equal_p (operands[1], operands[2])))"
9519   "@
9520    unpcklpd\t{%2, %0|%0, %2}
9521    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
9522    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
9523    %vmovddup\t{%1, %0|%0, %1}
9524    vmovddup\t{%1, %0|%0, %1}
9525    movhpd\t{%2, %0|%0, %2}
9526    vmovhpd\t{%2, %1, %0|%0, %1, %2}
9527    %vmovq\t{%1, %0|%0, %1}
9528    movlhps\t{%2, %0|%0, %2}
9529    movhps\t{%2, %0|%0, %2}"
9530   [(set (attr "isa")
9531      (cond [(eq_attr "alternative" "0,5")
9532               (const_string "sse2_noavx")
9533             (eq_attr "alternative" "1,6")
9534               (const_string "avx")
9535             (eq_attr "alternative" "2,4")
9536               (const_string "avx512vl")
9537             (eq_attr "alternative" "3")
9538               (const_string "sse3")
9539             (eq_attr "alternative" "7")
9540               (const_string "sse2")
9541            ]
9542            (const_string "noavx")))
9543    (set (attr "type")
9544      (if_then_else
9545        (eq_attr "alternative" "0,1,2,3,4")
9546        (const_string "sselog")
9547        (const_string "ssemov")))
9548    (set (attr "prefix_data16")
9549         (if_then_else (eq_attr "alternative" "5")
9550                       (const_string "1")
9551                       (const_string "*")))
9552    (set (attr "prefix")
9553      (cond [(eq_attr "alternative" "1,6")
9554               (const_string "vex")
9555             (eq_attr "alternative" "2,4")
9556               (const_string "evex")
9557             (eq_attr "alternative" "3,7")
9558               (const_string "maybe_vex")
9559            ]
9560            (const_string "orig")))
9561    (set_attr "mode" "V2DF,V2DF,V2DF, DF, DF, V1DF,V1DF,DF,V4SF,V2SF")])
9563 ;; vmovq clears also the higher bits.
9564 (define_insn "vec_set<mode>_0"
9565   [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
9566         (vec_merge:VF2_512_256
9567           (vec_duplicate:VF2_512_256
9568             (match_operand:<ssescalarmode> 2 "general_operand" "xm"))
9569           (match_operand:VF2_512_256 1 "const0_operand" "C")
9570           (const_int 1)))]
9571   "TARGET_AVX"
9572   "vmovq\t{%2, %x0|%x0, %2}"
9573   [(set_attr "type" "ssemov")
9574    (set_attr "prefix" "maybe_evex")
9575    (set_attr "mode" "DF")])
9577 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9579 ;; Parallel integer down-conversion operations
9581 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9583 (define_mode_iterator PMOV_DST_MODE_1 [V16QI V16HI V8SI V8HI])
9584 (define_mode_attr pmov_src_mode
9585   [(V16QI "V16SI") (V16HI "V16SI") (V8SI "V8DI") (V8HI "V8DI")])
9586 (define_mode_attr pmov_src_lower
9587   [(V16QI "v16si") (V16HI "v16si") (V8SI "v8di") (V8HI "v8di")])
9588 (define_mode_attr pmov_suff_1
9589   [(V16QI "db") (V16HI "dw") (V8SI "qd") (V8HI "qw")])
9591 (define_insn "*avx512f_<code><pmov_src_lower><mode>2"
9592   [(set (match_operand:PMOV_DST_MODE_1 0 "nonimmediate_operand" "=v,m")
9593         (any_truncate:PMOV_DST_MODE_1
9594           (match_operand:<pmov_src_mode> 1 "register_operand" "v,v")))]
9595   "TARGET_AVX512F"
9596   "vpmov<trunsuffix><pmov_suff_1>\t{%1, %0|%0, %1}"
9597   [(set_attr "type" "ssemov")
9598    (set_attr "memory" "none,store")
9599    (set_attr "prefix" "evex")
9600    (set_attr "mode" "<sseinsnmode>")])
9602 (define_insn "avx512f_<code><pmov_src_lower><mode>2_mask"
9603   [(set (match_operand:PMOV_DST_MODE_1 0 "nonimmediate_operand" "=v,m")
9604     (vec_merge:PMOV_DST_MODE_1
9605       (any_truncate:PMOV_DST_MODE_1
9606         (match_operand:<pmov_src_mode> 1 "register_operand" "v,v"))
9607       (match_operand:PMOV_DST_MODE_1 2 "nonimm_or_0_operand" "0C,0")
9608       (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
9609   "TARGET_AVX512F"
9610   "vpmov<trunsuffix><pmov_suff_1>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9611   [(set_attr "type" "ssemov")
9612    (set_attr "memory" "none,store")
9613    (set_attr "prefix" "evex")
9614    (set_attr "mode" "<sseinsnmode>")])
9616 (define_expand "avx512f_<code><pmov_src_lower><mode>2_mask_store"
9617   [(set (match_operand:PMOV_DST_MODE_1 0 "memory_operand")
9618     (vec_merge:PMOV_DST_MODE_1
9619       (any_truncate:PMOV_DST_MODE_1
9620         (match_operand:<pmov_src_mode> 1 "register_operand"))
9621       (match_dup 0)
9622       (match_operand:<avx512fmaskmode> 2 "register_operand")))]
9623   "TARGET_AVX512F")
9625 (define_insn "avx512bw_<code>v32hiv32qi2"
9626   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
9627         (any_truncate:V32QI
9628             (match_operand:V32HI 1 "register_operand" "v,v")))]
9629   "TARGET_AVX512BW"
9630   "vpmov<trunsuffix>wb\t{%1, %0|%0, %1}"
9631   [(set_attr "type" "ssemov")
9632    (set_attr "memory" "none,store")
9633    (set_attr "prefix" "evex")
9634    (set_attr "mode" "XI")])
9636 (define_insn "avx512bw_<code>v32hiv32qi2_mask"
9637   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
9638     (vec_merge:V32QI
9639       (any_truncate:V32QI
9640         (match_operand:V32HI 1 "register_operand" "v,v"))
9641       (match_operand:V32QI 2 "nonimm_or_0_operand" "0C,0")
9642       (match_operand:SI 3 "register_operand" "Yk,Yk")))]
9643   "TARGET_AVX512BW"
9644   "vpmov<trunsuffix>wb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9645   [(set_attr "type" "ssemov")
9646    (set_attr "memory" "none,store")
9647    (set_attr "prefix" "evex")
9648    (set_attr "mode" "XI")])
9650 (define_expand "avx512bw_<code>v32hiv32qi2_mask_store"
9651   [(set (match_operand:V32QI 0 "nonimmediate_operand")
9652     (vec_merge:V32QI
9653       (any_truncate:V32QI
9654         (match_operand:V32HI 1 "register_operand"))
9655       (match_dup 0)
9656       (match_operand:SI 2 "register_operand")))]
9657   "TARGET_AVX512BW")
9659 (define_mode_iterator PMOV_DST_MODE_2
9660   [V4SI V8HI (V16QI "TARGET_AVX512BW")])
9661 (define_mode_attr pmov_suff_2
9662   [(V16QI "wb") (V8HI "dw") (V4SI "qd")])
9664 (define_insn "*avx512vl_<code><ssedoublemodelower><mode>2"
9665   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand" "=v,m")
9666         (any_truncate:PMOV_DST_MODE_2
9667             (match_operand:<ssedoublemode> 1 "register_operand" "v,v")))]
9668   "TARGET_AVX512VL"
9669   "vpmov<trunsuffix><pmov_suff_2>\t{%1, %0|%0, %1}"
9670   [(set_attr "type" "ssemov")
9671    (set_attr "memory" "none,store")
9672    (set_attr "prefix" "evex")
9673    (set_attr "mode" "<sseinsnmode>")])
9675 (define_insn "<avx512>_<code><ssedoublemodelower><mode>2_mask"
9676   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand" "=v,m")
9677     (vec_merge:PMOV_DST_MODE_2
9678       (any_truncate:PMOV_DST_MODE_2
9679         (match_operand:<ssedoublemode> 1 "register_operand" "v,v"))
9680       (match_operand:PMOV_DST_MODE_2 2 "nonimm_or_0_operand" "0C,0")
9681       (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
9682   "TARGET_AVX512VL"
9683   "vpmov<trunsuffix><pmov_suff_2>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9684   [(set_attr "type" "ssemov")
9685    (set_attr "memory" "none,store")
9686    (set_attr "prefix" "evex")
9687    (set_attr "mode" "<sseinsnmode>")])
9689 (define_expand "<avx512>_<code><ssedoublemodelower><mode>2_mask_store"
9690   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand")
9691     (vec_merge:PMOV_DST_MODE_2
9692       (any_truncate:PMOV_DST_MODE_2
9693         (match_operand:<ssedoublemode> 1 "register_operand"))
9694       (match_dup 0)
9695       (match_operand:<avx512fmaskmode> 2 "register_operand")))]
9696   "TARGET_AVX512VL")
9698 (define_mode_iterator PMOV_SRC_MODE_3 [V4DI V2DI V8SI V4SI (V8HI "TARGET_AVX512BW")])
9699 (define_mode_attr pmov_dst_3
9700   [(V4DI "V4QI") (V2DI "V2QI") (V8SI "V8QI") (V4SI "V4QI") (V8HI "V8QI")])
9701 (define_mode_attr pmov_dst_zeroed_3
9702   [(V4DI "V12QI") (V2DI "V14QI") (V8SI "V8QI") (V4SI "V12QI") (V8HI "V8QI")])
9703 (define_mode_attr pmov_suff_3
9704   [(V4DI "qb") (V2DI "qb") (V8SI "db") (V4SI "db") (V8HI "wb")])
9706 (define_insn "*avx512vl_<code><mode>v<ssescalarnum>qi2"
9707   [(set (match_operand:V16QI 0 "register_operand" "=v")
9708     (vec_concat:V16QI
9709       (any_truncate:<pmov_dst_3>
9710               (match_operand:PMOV_SRC_MODE_3 1 "register_operand" "v"))
9711       (match_operand:<pmov_dst_zeroed_3> 2 "const0_operand")))]
9712   "TARGET_AVX512VL"
9713   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%0, %1}"
9714   [(set_attr "type" "ssemov")
9715    (set_attr "prefix" "evex")
9716    (set_attr "mode" "TI")])
9718 (define_insn "*avx512vl_<code>v2div2qi2_store"
9719   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9720     (vec_concat:V16QI
9721       (any_truncate:V2QI
9722               (match_operand:V2DI 1 "register_operand" "v"))
9723       (vec_select:V14QI
9724         (match_dup 0)
9725         (parallel [(const_int 2) (const_int 3)
9726                    (const_int 4) (const_int 5)
9727                    (const_int 6) (const_int 7)
9728                    (const_int 8) (const_int 9)
9729                    (const_int 10) (const_int 11)
9730                    (const_int 12) (const_int 13)
9731                    (const_int 14) (const_int 15)]))))]
9732   "TARGET_AVX512VL"
9733   "vpmov<trunsuffix>qb\t{%1, %0|%w0, %1}"
9734   [(set_attr "type" "ssemov")
9735    (set_attr "memory" "store")
9736    (set_attr "prefix" "evex")
9737    (set_attr "mode" "TI")])
9739 (define_insn "avx512vl_<code>v2div2qi2_mask"
9740   [(set (match_operand:V16QI 0 "register_operand" "=v")
9741     (vec_concat:V16QI
9742       (vec_merge:V2QI
9743         (any_truncate:V2QI
9744           (match_operand:V2DI 1 "register_operand" "v"))
9745         (vec_select:V2QI
9746           (match_operand:V16QI 2 "nonimm_or_0_operand" "0C")
9747           (parallel [(const_int 0) (const_int 1)]))
9748         (match_operand:QI 3 "register_operand" "Yk"))
9749       (const_vector:V14QI [(const_int 0) (const_int 0)
9750                            (const_int 0) (const_int 0)
9751                            (const_int 0) (const_int 0)
9752                            (const_int 0) (const_int 0)
9753                            (const_int 0) (const_int 0)
9754                            (const_int 0) (const_int 0)
9755                            (const_int 0) (const_int 0)])))]
9756   "TARGET_AVX512VL"
9757   "vpmov<trunsuffix>qb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9758   [(set_attr "type" "ssemov")
9759    (set_attr "prefix" "evex")
9760    (set_attr "mode" "TI")])
9762 (define_insn "*avx512vl_<code>v2div2qi2_mask_1"
9763   [(set (match_operand:V16QI 0 "register_operand" "=v")
9764     (vec_concat:V16QI
9765       (vec_merge:V2QI
9766         (any_truncate:V2QI
9767           (match_operand:V2DI 1 "register_operand" "v"))
9768         (const_vector:V2QI [(const_int 0) (const_int 0)])
9769         (match_operand:QI 2 "register_operand" "Yk"))
9770       (const_vector:V14QI [(const_int 0) (const_int 0)
9771                            (const_int 0) (const_int 0)
9772                            (const_int 0) (const_int 0)
9773                            (const_int 0) (const_int 0)
9774                            (const_int 0) (const_int 0)
9775                            (const_int 0) (const_int 0)
9776                            (const_int 0) (const_int 0)])))]
9777   "TARGET_AVX512VL"
9778   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9779   [(set_attr "type" "ssemov")
9780    (set_attr "prefix" "evex")
9781    (set_attr "mode" "TI")])
9783 (define_insn "avx512vl_<code>v2div2qi2_mask_store"
9784   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9785     (vec_concat:V16QI
9786       (vec_merge:V2QI
9787         (any_truncate:V2QI
9788           (match_operand:V2DI 1 "register_operand" "v"))
9789         (vec_select:V2QI
9790           (match_dup 0)
9791           (parallel [(const_int 0) (const_int 1)]))
9792         (match_operand:QI 2 "register_operand" "Yk"))
9793       (vec_select:V14QI
9794         (match_dup 0)
9795         (parallel [(const_int 2) (const_int 3)
9796                    (const_int 4) (const_int 5)
9797                    (const_int 6) (const_int 7)
9798                    (const_int 8) (const_int 9)
9799                    (const_int 10) (const_int 11)
9800                    (const_int 12) (const_int 13)
9801                    (const_int 14) (const_int 15)]))))]
9802   "TARGET_AVX512VL"
9803   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}|%w0%{%2%}, %1}"
9804   [(set_attr "type" "ssemov")
9805    (set_attr "memory" "store")
9806    (set_attr "prefix" "evex")
9807    (set_attr "mode" "TI")])
9809 (define_insn "*avx512vl_<code><mode>v4qi2_store"
9810   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9811     (vec_concat:V16QI
9812       (any_truncate:V4QI
9813               (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9814       (vec_select:V12QI
9815         (match_dup 0)
9816         (parallel [(const_int 4) (const_int 5)
9817                    (const_int 6) (const_int 7)
9818                    (const_int 8) (const_int 9)
9819                    (const_int 10) (const_int 11)
9820                    (const_int 12) (const_int 13)
9821                    (const_int 14) (const_int 15)]))))]
9822   "TARGET_AVX512VL"
9823   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%k0, %1}"
9824   [(set_attr "type" "ssemov")
9825    (set_attr "memory" "store")
9826    (set_attr "prefix" "evex")
9827    (set_attr "mode" "TI")])
9829 (define_insn "avx512vl_<code><mode>v4qi2_mask"
9830   [(set (match_operand:V16QI 0 "register_operand" "=v")
9831     (vec_concat:V16QI
9832       (vec_merge:V4QI
9833         (any_truncate:V4QI
9834           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9835         (vec_select:V4QI
9836           (match_operand:V16QI 2 "nonimm_or_0_operand" "0C")
9837           (parallel [(const_int 0) (const_int 1)
9838                      (const_int 2) (const_int 3)]))
9839         (match_operand:QI 3 "register_operand" "Yk"))
9840       (const_vector:V12QI [(const_int 0) (const_int 0)
9841                            (const_int 0) (const_int 0)
9842                            (const_int 0) (const_int 0)
9843                            (const_int 0) (const_int 0)
9844                            (const_int 0) (const_int 0)
9845                            (const_int 0) (const_int 0)])))]
9846   "TARGET_AVX512VL"
9847   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9848   [(set_attr "type" "ssemov")
9849    (set_attr "prefix" "evex")
9850    (set_attr "mode" "TI")])
9852 (define_insn "*avx512vl_<code><mode>v4qi2_mask_1"
9853   [(set (match_operand:V16QI 0 "register_operand" "=v")
9854     (vec_concat:V16QI
9855       (vec_merge:V4QI
9856         (any_truncate:V4QI
9857           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9858         (const_vector:V4QI [(const_int 0) (const_int 0)
9859                             (const_int 0) (const_int 0)])
9860         (match_operand:QI 2 "register_operand" "Yk"))
9861       (const_vector:V12QI [(const_int 0) (const_int 0)
9862                            (const_int 0) (const_int 0)
9863                            (const_int 0) (const_int 0)
9864                            (const_int 0) (const_int 0)
9865                            (const_int 0) (const_int 0)
9866                            (const_int 0) (const_int 0)])))]
9867   "TARGET_AVX512VL"
9868   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9869   [(set_attr "type" "ssemov")
9870    (set_attr "prefix" "evex")
9871    (set_attr "mode" "TI")])
9873 (define_insn "avx512vl_<code><mode>v4qi2_mask_store"
9874   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9875     (vec_concat:V16QI
9876       (vec_merge:V4QI
9877         (any_truncate:V4QI
9878           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9879         (vec_select:V4QI
9880           (match_dup 0)
9881           (parallel [(const_int 0) (const_int 1)
9882                      (const_int 2) (const_int 3)]))
9883         (match_operand:QI 2 "register_operand" "Yk"))
9884       (vec_select:V12QI
9885         (match_dup 0)
9886         (parallel [(const_int 4) (const_int 5)
9887                    (const_int 6) (const_int 7)
9888                    (const_int 8) (const_int 9)
9889                    (const_int 10) (const_int 11)
9890                    (const_int 12) (const_int 13)
9891                    (const_int 14) (const_int 15)]))))]
9892   "TARGET_AVX512VL"
9893   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%k0%{%2%}, %1}"
9894   [(set_attr "type" "ssemov")
9895    (set_attr "memory" "store")
9896    (set_attr "prefix" "evex")
9897    (set_attr "mode" "TI")])
9899 (define_mode_iterator VI2_128_BW_4_256
9900   [(V8HI "TARGET_AVX512BW") V8SI])
9902 (define_insn "*avx512vl_<code><mode>v8qi2_store"
9903   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9904     (vec_concat:V16QI
9905       (any_truncate:V8QI
9906               (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9907       (vec_select:V8QI
9908         (match_dup 0)
9909         (parallel [(const_int 8) (const_int 9)
9910                    (const_int 10) (const_int 11)
9911                    (const_int 12) (const_int 13)
9912                    (const_int 14) (const_int 15)]))))]
9913   "TARGET_AVX512VL"
9914   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%q0, %1}"
9915   [(set_attr "type" "ssemov")
9916    (set_attr "memory" "store")
9917    (set_attr "prefix" "evex")
9918    (set_attr "mode" "TI")])
9920 (define_insn "avx512vl_<code><mode>v8qi2_mask"
9921   [(set (match_operand:V16QI 0 "register_operand" "=v")
9922     (vec_concat:V16QI
9923       (vec_merge:V8QI
9924         (any_truncate:V8QI
9925           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9926         (vec_select:V8QI
9927           (match_operand:V16QI 2 "nonimm_or_0_operand" "0C")
9928           (parallel [(const_int 0) (const_int 1)
9929                      (const_int 2) (const_int 3)
9930                      (const_int 4) (const_int 5)
9931                      (const_int 6) (const_int 7)]))
9932         (match_operand:QI 3 "register_operand" "Yk"))
9933       (const_vector:V8QI [(const_int 0) (const_int 0)
9934                           (const_int 0) (const_int 0)
9935                           (const_int 0) (const_int 0)
9936                           (const_int 0) (const_int 0)])))]
9937   "TARGET_AVX512VL"
9938   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9939   [(set_attr "type" "ssemov")
9940    (set_attr "prefix" "evex")
9941    (set_attr "mode" "TI")])
9943 (define_insn "*avx512vl_<code><mode>v8qi2_mask_1"
9944   [(set (match_operand:V16QI 0 "register_operand" "=v")
9945     (vec_concat:V16QI
9946       (vec_merge:V8QI
9947         (any_truncate:V8QI
9948           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9949         (const_vector:V8QI [(const_int 0) (const_int 0)
9950                             (const_int 0) (const_int 0)
9951                             (const_int 0) (const_int 0)
9952                             (const_int 0) (const_int 0)])
9953         (match_operand:QI 2 "register_operand" "Yk"))
9954       (const_vector:V8QI [(const_int 0) (const_int 0)
9955                           (const_int 0) (const_int 0)
9956                           (const_int 0) (const_int 0)
9957                           (const_int 0) (const_int 0)])))]
9958   "TARGET_AVX512VL"
9959   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9960   [(set_attr "type" "ssemov")
9961    (set_attr "prefix" "evex")
9962    (set_attr "mode" "TI")])
9964 (define_insn "avx512vl_<code><mode>v8qi2_mask_store"
9965   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9966     (vec_concat:V16QI
9967       (vec_merge:V8QI
9968         (any_truncate:V8QI
9969           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9970         (vec_select:V8QI
9971           (match_dup 0)
9972           (parallel [(const_int 0) (const_int 1)
9973                      (const_int 2) (const_int 3)
9974                      (const_int 4) (const_int 5)
9975                      (const_int 6) (const_int 7)]))
9976         (match_operand:QI 2 "register_operand" "Yk"))
9977       (vec_select:V8QI
9978         (match_dup 0)
9979         (parallel [(const_int 8) (const_int 9)
9980                    (const_int 10) (const_int 11)
9981                    (const_int 12) (const_int 13)
9982                    (const_int 14) (const_int 15)]))))]
9983   "TARGET_AVX512VL"
9984   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%q0%{%2%}, %1}"
9985   [(set_attr "type" "ssemov")
9986    (set_attr "memory" "store")
9987    (set_attr "prefix" "evex")
9988    (set_attr "mode" "TI")])
9990 (define_mode_iterator PMOV_SRC_MODE_4 [V4DI V2DI V4SI])
9991 (define_mode_attr pmov_dst_4
9992   [(V4DI "V4HI") (V2DI "V2HI") (V4SI "V4HI")])
9993 (define_mode_attr pmov_dst_zeroed_4
9994   [(V4DI "V4HI") (V2DI "V6HI") (V4SI "V4HI")])
9995 (define_mode_attr pmov_suff_4
9996   [(V4DI "qw") (V2DI "qw") (V4SI "dw")])
9998 (define_insn "*avx512vl_<code><mode>v<ssescalarnum>hi2"
9999   [(set (match_operand:V8HI 0 "register_operand" "=v")
10000     (vec_concat:V8HI
10001       (any_truncate:<pmov_dst_4>
10002               (match_operand:PMOV_SRC_MODE_4 1 "register_operand" "v"))
10003       (match_operand:<pmov_dst_zeroed_4> 2 "const0_operand")))]
10004   "TARGET_AVX512VL"
10005   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0|%0, %1}"
10006   [(set_attr "type" "ssemov")
10007    (set_attr "prefix" "evex")
10008    (set_attr "mode" "TI")])
10010 (define_insn "*avx512vl_<code><mode>v4hi2_store"
10011   [(set (match_operand:V8HI 0 "memory_operand" "=m")
10012     (vec_concat:V8HI
10013       (any_truncate:V4HI
10014               (match_operand:VI4_128_8_256 1 "register_operand" "v"))
10015       (vec_select:V4HI
10016         (match_dup 0)
10017         (parallel [(const_int 4) (const_int 5)
10018                    (const_int 6) (const_int 7)]))))]
10019   "TARGET_AVX512VL"
10020   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0|%0, %1}"
10021   [(set_attr "type" "ssemov")
10022    (set_attr "memory" "store")
10023    (set_attr "prefix" "evex")
10024    (set_attr "mode" "TI")])
10026 (define_insn "avx512vl_<code><mode>v4hi2_mask"
10027   [(set (match_operand:V8HI 0 "register_operand" "=v")
10028     (vec_concat:V8HI
10029       (vec_merge:V4HI
10030         (any_truncate:V4HI
10031           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
10032         (vec_select:V4HI
10033           (match_operand:V8HI 2 "nonimm_or_0_operand" "0C")
10034           (parallel [(const_int 0) (const_int 1)
10035                      (const_int 2) (const_int 3)]))
10036         (match_operand:QI 3 "register_operand" "Yk"))
10037       (const_vector:V4HI [(const_int 0) (const_int 0)
10038                           (const_int 0) (const_int 0)])))]
10039   "TARGET_AVX512VL"
10040   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
10041   [(set_attr "type" "ssemov")
10042    (set_attr "prefix" "evex")
10043    (set_attr "mode" "TI")])
10045 (define_insn "*avx512vl_<code><mode>v4hi2_mask_1"
10046   [(set (match_operand:V8HI 0 "register_operand" "=v")
10047     (vec_concat:V8HI
10048       (vec_merge:V4HI
10049         (any_truncate:V4HI
10050           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
10051         (const_vector:V4HI [(const_int 0) (const_int 0)
10052                             (const_int 0) (const_int 0)])
10053         (match_operand:QI 2 "register_operand" "Yk"))
10054       (const_vector:V4HI [(const_int 0) (const_int 0)
10055                           (const_int 0) (const_int 0)])))]
10056   "TARGET_AVX512VL"
10057   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
10058   [(set_attr "type" "ssemov")
10059    (set_attr "prefix" "evex")
10060    (set_attr "mode" "TI")])
10062 (define_insn "avx512vl_<code><mode>v4hi2_mask_store"
10063   [(set (match_operand:V8HI 0 "memory_operand" "=m")
10064     (vec_concat:V8HI
10065       (vec_merge:V4HI
10066         (any_truncate:V4HI
10067           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
10068         (vec_select:V4HI
10069           (match_dup 0)
10070           (parallel [(const_int 0) (const_int 1)
10071                      (const_int 2) (const_int 3)]))
10072         (match_operand:QI 2 "register_operand" "Yk"))
10073       (vec_select:V4HI
10074         (match_dup 0)
10075         (parallel [(const_int 4) (const_int 5)
10076                    (const_int 6) (const_int 7)]))))]
10077   "TARGET_AVX512VL"
10079   if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 4)
10080     return "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}|%0%{%2%}, %t1}";
10081   return "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}|%0%{%2%}, %g1}";
10083   [(set_attr "type" "ssemov")
10084    (set_attr "memory" "store")
10085    (set_attr "prefix" "evex")
10086    (set_attr "mode" "TI")])
10088 (define_insn "*avx512vl_<code>v2div2hi2_store"
10089   [(set (match_operand:V8HI 0 "memory_operand" "=m")
10090     (vec_concat:V8HI
10091       (any_truncate:V2HI
10092               (match_operand:V2DI 1 "register_operand" "v"))
10093       (vec_select:V6HI
10094         (match_dup 0)
10095         (parallel [(const_int 2) (const_int 3)
10096                    (const_int 4) (const_int 5)
10097                    (const_int 6) (const_int 7)]))))]
10098   "TARGET_AVX512VL"
10099   "vpmov<trunsuffix>qw\t{%1, %0|%0, %1}"
10100   [(set_attr "type" "ssemov")
10101    (set_attr "memory" "store")
10102    (set_attr "prefix" "evex")
10103    (set_attr "mode" "TI")])
10105 (define_insn "avx512vl_<code>v2div2hi2_mask"
10106   [(set (match_operand:V8HI 0 "register_operand" "=v")
10107     (vec_concat:V8HI
10108       (vec_merge:V2HI
10109         (any_truncate:V2HI
10110           (match_operand:V2DI 1 "register_operand" "v"))
10111         (vec_select:V2HI
10112           (match_operand:V8HI 2 "nonimm_or_0_operand" "0C")
10113           (parallel [(const_int 0) (const_int 1)]))
10114         (match_operand:QI 3 "register_operand" "Yk"))
10115       (const_vector:V6HI [(const_int 0) (const_int 0)
10116                           (const_int 0) (const_int 0)
10117                           (const_int 0) (const_int 0)])))]
10118   "TARGET_AVX512VL"
10119   "vpmov<trunsuffix>qw\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
10120   [(set_attr "type" "ssemov")
10121    (set_attr "prefix" "evex")
10122    (set_attr "mode" "TI")])
10124 (define_insn "*avx512vl_<code>v2div2hi2_mask_1"
10125   [(set (match_operand:V8HI 0 "register_operand" "=v")
10126     (vec_concat:V8HI
10127       (vec_merge:V2HI
10128         (any_truncate:V2HI
10129           (match_operand:V2DI 1 "register_operand" "v"))
10130         (const_vector:V2HI [(const_int 0) (const_int 0)])
10131         (match_operand:QI 2 "register_operand" "Yk"))
10132       (const_vector:V6HI [(const_int 0) (const_int 0)
10133                           (const_int 0) (const_int 0)
10134                           (const_int 0) (const_int 0)])))]
10135   "TARGET_AVX512VL"
10136   "vpmov<trunsuffix>qw\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
10137   [(set_attr "type" "ssemov")
10138    (set_attr "prefix" "evex")
10139    (set_attr "mode" "TI")])
10141 (define_insn "avx512vl_<code>v2div2hi2_mask_store"
10142   [(set (match_operand:V8HI 0 "memory_operand" "=m")
10143     (vec_concat:V8HI
10144       (vec_merge:V2HI
10145         (any_truncate:V2HI
10146           (match_operand:V2DI 1 "register_operand" "v"))
10147         (vec_select:V2HI
10148           (match_dup 0)
10149           (parallel [(const_int 0) (const_int 1)]))
10150         (match_operand:QI 2 "register_operand" "Yk"))
10151       (vec_select:V6HI
10152         (match_dup 0)
10153         (parallel [(const_int 2) (const_int 3)
10154                    (const_int 4) (const_int 5)
10155                    (const_int 6) (const_int 7)]))))]
10156   "TARGET_AVX512VL"
10157   "vpmov<trunsuffix>qw\t{%1, %0%{%2%}|%0%{%2%}, %g1}"
10158   [(set_attr "type" "ssemov")
10159    (set_attr "memory" "store")
10160    (set_attr "prefix" "evex")
10161    (set_attr "mode" "TI")])
10163 (define_insn "*avx512vl_<code>v2div2si2"
10164   [(set (match_operand:V4SI 0 "register_operand" "=v")
10165     (vec_concat:V4SI
10166       (any_truncate:V2SI
10167               (match_operand:V2DI 1 "register_operand" "v"))
10168       (match_operand:V2SI 2 "const0_operand")))]
10169   "TARGET_AVX512VL"
10170   "vpmov<trunsuffix>qd\t{%1, %0|%0, %1}"
10171   [(set_attr "type" "ssemov")
10172    (set_attr "prefix" "evex")
10173    (set_attr "mode" "TI")])
10175 (define_insn "*avx512vl_<code>v2div2si2_store"
10176   [(set (match_operand:V4SI 0 "memory_operand" "=m")
10177     (vec_concat:V4SI
10178       (any_truncate:V2SI
10179               (match_operand:V2DI 1 "register_operand" "v"))
10180       (vec_select:V2SI
10181         (match_dup 0)
10182         (parallel [(const_int 2) (const_int 3)]))))]
10183   "TARGET_AVX512VL"
10184   "vpmov<trunsuffix>qd\t{%1, %0|%0, %1}"
10185   [(set_attr "type" "ssemov")
10186    (set_attr "memory" "store")
10187    (set_attr "prefix" "evex")
10188    (set_attr "mode" "TI")])
10190 (define_insn "avx512vl_<code>v2div2si2_mask"
10191   [(set (match_operand:V4SI 0 "register_operand" "=v")
10192     (vec_concat:V4SI
10193       (vec_merge:V2SI
10194         (any_truncate:V2SI
10195           (match_operand:V2DI 1 "register_operand" "v"))
10196         (vec_select:V2SI
10197           (match_operand:V4SI 2 "nonimm_or_0_operand" "0C")
10198           (parallel [(const_int 0) (const_int 1)]))
10199         (match_operand:QI 3 "register_operand" "Yk"))
10200       (const_vector:V2SI [(const_int 0) (const_int 0)])))]
10201   "TARGET_AVX512VL"
10202   "vpmov<trunsuffix>qd\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
10203   [(set_attr "type" "ssemov")
10204    (set_attr "prefix" "evex")
10205    (set_attr "mode" "TI")])
10207 (define_insn "*avx512vl_<code>v2div2si2_mask_1"
10208   [(set (match_operand:V4SI 0 "register_operand" "=v")
10209     (vec_concat:V4SI
10210       (vec_merge:V2SI
10211         (any_truncate:V2SI
10212           (match_operand:V2DI 1 "register_operand" "v"))
10213         (const_vector:V2SI [(const_int 0) (const_int 0)])
10214         (match_operand:QI 2 "register_operand" "Yk"))
10215       (const_vector:V2SI [(const_int 0) (const_int 0)])))]
10216   "TARGET_AVX512VL"
10217   "vpmov<trunsuffix>qd\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
10218   [(set_attr "type" "ssemov")
10219    (set_attr "prefix" "evex")
10220    (set_attr "mode" "TI")])
10222 (define_insn "avx512vl_<code>v2div2si2_mask_store"
10223   [(set (match_operand:V4SI 0 "memory_operand" "=m")
10224     (vec_concat:V4SI
10225       (vec_merge:V2SI
10226         (any_truncate:V2SI
10227           (match_operand:V2DI 1 "register_operand" "v"))
10228         (vec_select:V2SI
10229           (match_dup 0)
10230           (parallel [(const_int 0) (const_int 1)]))
10231         (match_operand:QI 2 "register_operand" "Yk"))
10232       (vec_select:V2SI
10233         (match_dup 0)
10234         (parallel [(const_int 2) (const_int 3)]))))]
10235   "TARGET_AVX512VL"
10236   "vpmov<trunsuffix>qd\t{%1, %0%{%2%}|%0%{%2%}, %t1}"
10237   [(set_attr "type" "ssemov")
10238    (set_attr "memory" "store")
10239    (set_attr "prefix" "evex")
10240    (set_attr "mode" "TI")])
10242 (define_insn "*avx512f_<code>v8div16qi2"
10243   [(set (match_operand:V16QI 0 "register_operand" "=v")
10244         (vec_concat:V16QI
10245           (any_truncate:V8QI
10246             (match_operand:V8DI 1 "register_operand" "v"))
10247           (const_vector:V8QI [(const_int 0) (const_int 0)
10248                               (const_int 0) (const_int 0)
10249                               (const_int 0) (const_int 0)
10250                               (const_int 0) (const_int 0)])))]
10251   "TARGET_AVX512F"
10252   "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
10253   [(set_attr "type" "ssemov")
10254    (set_attr "prefix" "evex")
10255    (set_attr "mode" "TI")])
10257 (define_insn "*avx512f_<code>v8div16qi2_store"
10258   [(set (match_operand:V16QI 0 "memory_operand" "=m")
10259         (vec_concat:V16QI
10260           (any_truncate:V8QI
10261             (match_operand:V8DI 1 "register_operand" "v"))
10262           (vec_select:V8QI
10263             (match_dup 0)
10264             (parallel [(const_int 8) (const_int 9)
10265                        (const_int 10) (const_int 11)
10266                        (const_int 12) (const_int 13)
10267                        (const_int 14) (const_int 15)]))))]
10268   "TARGET_AVX512F"
10269   "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
10270   [(set_attr "type" "ssemov")
10271    (set_attr "memory" "store")
10272    (set_attr "prefix" "evex")
10273    (set_attr "mode" "TI")])
10275 (define_insn "avx512f_<code>v8div16qi2_mask"
10276   [(set (match_operand:V16QI 0 "register_operand" "=v")
10277     (vec_concat:V16QI
10278       (vec_merge:V8QI
10279         (any_truncate:V8QI
10280           (match_operand:V8DI 1 "register_operand" "v"))
10281         (vec_select:V8QI
10282           (match_operand:V16QI 2 "nonimm_or_0_operand" "0C")
10283           (parallel [(const_int 0) (const_int 1)
10284                      (const_int 2) (const_int 3)
10285                      (const_int 4) (const_int 5)
10286                      (const_int 6) (const_int 7)]))
10287         (match_operand:QI 3 "register_operand" "Yk"))
10288       (const_vector:V8QI [(const_int 0) (const_int 0)
10289                           (const_int 0) (const_int 0)
10290                           (const_int 0) (const_int 0)
10291                           (const_int 0) (const_int 0)])))]
10292   "TARGET_AVX512F"
10293   "vpmov<trunsuffix>qb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
10294   [(set_attr "type" "ssemov")
10295    (set_attr "prefix" "evex")
10296    (set_attr "mode" "TI")])
10298 (define_insn "*avx512f_<code>v8div16qi2_mask_1"
10299   [(set (match_operand:V16QI 0 "register_operand" "=v")
10300     (vec_concat:V16QI
10301       (vec_merge:V8QI
10302         (any_truncate:V8QI
10303           (match_operand:V8DI 1 "register_operand" "v"))
10304         (const_vector:V8QI [(const_int 0) (const_int 0)
10305                             (const_int 0) (const_int 0)
10306                             (const_int 0) (const_int 0)
10307                             (const_int 0) (const_int 0)])
10308         (match_operand:QI 2 "register_operand" "Yk"))
10309       (const_vector:V8QI [(const_int 0) (const_int 0)
10310                           (const_int 0) (const_int 0)
10311                           (const_int 0) (const_int 0)
10312                           (const_int 0) (const_int 0)])))]
10313   "TARGET_AVX512F"
10314   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
10315   [(set_attr "type" "ssemov")
10316    (set_attr "prefix" "evex")
10317    (set_attr "mode" "TI")])
10319 (define_insn "avx512f_<code>v8div16qi2_mask_store"
10320   [(set (match_operand:V16QI 0 "memory_operand" "=m")
10321     (vec_concat:V16QI
10322       (vec_merge:V8QI
10323         (any_truncate:V8QI
10324           (match_operand:V8DI 1 "register_operand" "v"))
10325         (vec_select:V8QI
10326           (match_dup 0)
10327           (parallel [(const_int 0) (const_int 1)
10328                      (const_int 2) (const_int 3)
10329                      (const_int 4) (const_int 5)
10330                      (const_int 6) (const_int 7)]))
10331         (match_operand:QI 2 "register_operand" "Yk"))
10332       (vec_select:V8QI
10333         (match_dup 0)
10334         (parallel [(const_int 8) (const_int 9)
10335                    (const_int 10) (const_int 11)
10336                    (const_int 12) (const_int 13)
10337                    (const_int 14) (const_int 15)]))))]
10338   "TARGET_AVX512F"
10339   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}|%q0%{%2%}, %1}"
10340   [(set_attr "type" "ssemov")
10341    (set_attr "memory" "store")
10342    (set_attr "prefix" "evex")
10343    (set_attr "mode" "TI")])
10345 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10347 ;; Parallel integral arithmetic
10349 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10351 (define_expand "neg<mode>2"
10352   [(set (match_operand:VI_AVX2 0 "register_operand")
10353         (minus:VI_AVX2
10354           (match_dup 2)
10355           (match_operand:VI_AVX2 1 "vector_operand")))]
10356   "TARGET_SSE2"
10357   "operands[2] = force_reg (<MODE>mode, CONST0_RTX (<MODE>mode));")
10359 (define_expand "<plusminus_insn><mode>3"
10360   [(set (match_operand:VI_AVX2 0 "register_operand")
10361         (plusminus:VI_AVX2
10362           (match_operand:VI_AVX2 1 "vector_operand")
10363           (match_operand:VI_AVX2 2 "vector_operand")))]
10364   "TARGET_SSE2"
10365   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10367 (define_expand "<plusminus_insn><mode>3_mask"
10368   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
10369         (vec_merge:VI48_AVX512VL
10370           (plusminus:VI48_AVX512VL
10371             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
10372             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
10373           (match_operand:VI48_AVX512VL 3 "nonimm_or_0_operand")
10374           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
10375   "TARGET_AVX512F"
10376   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10378 (define_expand "<plusminus_insn><mode>3_mask"
10379   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
10380         (vec_merge:VI12_AVX512VL
10381           (plusminus:VI12_AVX512VL
10382             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
10383             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand"))
10384           (match_operand:VI12_AVX512VL 3 "nonimm_or_0_operand")
10385           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
10386   "TARGET_AVX512BW"
10387   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10389 (define_insn "*<plusminus_insn><mode>3"
10390   [(set (match_operand:VI_AVX2 0 "register_operand" "=x,v")
10391         (plusminus:VI_AVX2
10392           (match_operand:VI_AVX2 1 "vector_operand" "<comm>0,v")
10393           (match_operand:VI_AVX2 2 "vector_operand" "xBm,vm")))]
10394   "TARGET_SSE2 && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10395   "@
10396    p<plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
10397    vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10398   [(set_attr "isa" "noavx,avx")
10399    (set_attr "type" "sseiadd")
10400    (set_attr "prefix_data16" "1,*")
10401    (set_attr "prefix" "orig,vex")
10402    (set_attr "mode" "<sseinsnmode>")])
10404 (define_insn "*sub<mode>3_bcst"
10405   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10406         (minus:VI48_AVX512VL
10407           (match_operand:VI48_AVX512VL 1 "register_operand" "v")
10408           (vec_duplicate:VI48_AVX512VL
10409             (match_operand:<ssescalarmode> 2 "memory_operand" "m"))))]
10410   "TARGET_AVX512F && ix86_binary_operator_ok (MINUS, <MODE>mode, operands)"
10411   "vpsub<ssemodesuffix>\t{%2<avx512bcst>, %1, %0|%0, %1, %2<avx512bcst>}"
10412   [(set_attr "type" "sseiadd")
10413    (set_attr "prefix" "evex")
10414    (set_attr "mode" "<sseinsnmode>")])
10416 (define_insn "*add<mode>3_bcst"
10417   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10418         (plus:VI48_AVX512VL
10419           (vec_duplicate:VI48_AVX512VL
10420             (match_operand:<ssescalarmode> 1 "memory_operand" "m"))
10421           (match_operand:VI48_AVX512VL 2 "register_operand" "v")))]
10422   "TARGET_AVX512F && ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
10423   "vpadd<ssemodesuffix>\t{%1<avx512bcst>, %2, %0|%0, %2, %1<avx512bcst>}"
10424   [(set_attr "type" "sseiadd")
10425    (set_attr "prefix" "evex")
10426    (set_attr "mode" "<sseinsnmode>")])
10428 (define_insn "*<plusminus_insn><mode>3_mask"
10429   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10430         (vec_merge:VI48_AVX512VL
10431           (plusminus:VI48_AVX512VL
10432             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "<comm>v")
10433             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm"))
10434           (match_operand:VI48_AVX512VL 3 "nonimm_or_0_operand" "0C")
10435           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
10436   "TARGET_AVX512F && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10437   "vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
10438   [(set_attr "type" "sseiadd")
10439    (set_attr "prefix" "evex")
10440    (set_attr "mode" "<sseinsnmode>")])
10442 (define_insn "*<plusminus_insn><mode>3_mask"
10443   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
10444         (vec_merge:VI12_AVX512VL
10445           (plusminus:VI12_AVX512VL
10446             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "<comm>v")
10447             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm"))
10448           (match_operand:VI12_AVX512VL 3 "nonimm_or_0_operand" "0C")
10449           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
10450   "TARGET_AVX512BW && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10451   "vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
10452   [(set_attr "type" "sseiadd")
10453    (set_attr "prefix" "evex")
10454    (set_attr "mode" "<sseinsnmode>")])
10456 (define_expand "<sse2_avx2>_<plusminus_insn><mode>3<mask_name>"
10457   [(set (match_operand:VI12_AVX2 0 "register_operand")
10458         (sat_plusminus:VI12_AVX2
10459           (match_operand:VI12_AVX2 1 "vector_operand")
10460           (match_operand:VI12_AVX2 2 "vector_operand")))]
10461   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10462   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10464 (define_insn "*<sse2_avx2>_<plusminus_insn><mode>3<mask_name>"
10465   [(set (match_operand:VI12_AVX2 0 "register_operand" "=x,v")
10466         (sat_plusminus:VI12_AVX2
10467           (match_operand:VI12_AVX2 1 "vector_operand" "<comm>0,v")
10468           (match_operand:VI12_AVX2 2 "vector_operand" "xBm,vm")))]
10469   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
10470    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10471   "@
10472    p<plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
10473    vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10474   [(set_attr "isa" "noavx,avx")
10475    (set_attr "type" "sseiadd")
10476    (set_attr "prefix_data16" "1,*")
10477    (set_attr "prefix" "orig,maybe_evex")
10478    (set_attr "mode" "TI")])
10480 (define_expand "mul<mode>3<mask_name>"
10481   [(set (match_operand:VI1_AVX512 0 "register_operand")
10482         (mult:VI1_AVX512 (match_operand:VI1_AVX512 1 "register_operand")
10483                        (match_operand:VI1_AVX512 2 "register_operand")))]
10484   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10486   ix86_expand_vecop_qihi (MULT, operands[0], operands[1], operands[2]);
10487   DONE;
10490 (define_expand "mul<mode>3<mask_name>"
10491   [(set (match_operand:VI2_AVX2 0 "register_operand")
10492         (mult:VI2_AVX2 (match_operand:VI2_AVX2 1 "vector_operand")
10493                        (match_operand:VI2_AVX2 2 "vector_operand")))]
10494   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10495   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
10497 (define_insn "*mul<mode>3<mask_name>"
10498   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,v")
10499         (mult:VI2_AVX2 (match_operand:VI2_AVX2 1 "vector_operand" "%0,v")
10500                        (match_operand:VI2_AVX2 2 "vector_operand" "xBm,vm")))]
10501   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))
10502    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10503   "@
10504    pmullw\t{%2, %0|%0, %2}
10505    vpmullw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10506   [(set_attr "isa" "noavx,avx")
10507    (set_attr "type" "sseimul")
10508    (set_attr "prefix_data16" "1,*")
10509    (set_attr "prefix" "orig,vex")
10510    (set_attr "mode" "<sseinsnmode>")])
10512 (define_expand "<s>mul<mode>3_highpart<mask_name>"
10513   [(set (match_operand:VI2_AVX2 0 "register_operand")
10514         (truncate:VI2_AVX2
10515           (lshiftrt:<ssedoublemode>
10516             (mult:<ssedoublemode>
10517               (any_extend:<ssedoublemode>
10518                 (match_operand:VI2_AVX2 1 "vector_operand"))
10519               (any_extend:<ssedoublemode>
10520                 (match_operand:VI2_AVX2 2 "vector_operand")))
10521             (const_int 16))))]
10522   "TARGET_SSE2
10523    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10524   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
10526 (define_insn "*<s>mul<mode>3_highpart<mask_name>"
10527   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,v")
10528         (truncate:VI2_AVX2
10529           (lshiftrt:<ssedoublemode>
10530             (mult:<ssedoublemode>
10531               (any_extend:<ssedoublemode>
10532                 (match_operand:VI2_AVX2 1 "vector_operand" "%0,v"))
10533               (any_extend:<ssedoublemode>
10534                 (match_operand:VI2_AVX2 2 "vector_operand" "xBm,vm")))
10535             (const_int 16))))]
10536   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))
10537    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10538   "@
10539    pmulh<u>w\t{%2, %0|%0, %2}
10540    vpmulh<u>w\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10541   [(set_attr "isa" "noavx,avx")
10542    (set_attr "type" "sseimul")
10543    (set_attr "prefix_data16" "1,*")
10544    (set_attr "prefix" "orig,vex")
10545    (set_attr "mode" "<sseinsnmode>")])
10547 (define_expand "vec_widen_umult_even_v16si<mask_name>"
10548   [(set (match_operand:V8DI 0 "register_operand")
10549         (mult:V8DI
10550           (zero_extend:V8DI
10551             (vec_select:V8SI
10552               (match_operand:V16SI 1 "nonimmediate_operand")
10553               (parallel [(const_int 0) (const_int 2)
10554                          (const_int 4) (const_int 6)
10555                          (const_int 8) (const_int 10)
10556                          (const_int 12) (const_int 14)])))
10557           (zero_extend:V8DI
10558             (vec_select:V8SI
10559               (match_operand:V16SI 2 "nonimmediate_operand")
10560               (parallel [(const_int 0) (const_int 2)
10561                          (const_int 4) (const_int 6)
10562                          (const_int 8) (const_int 10)
10563                          (const_int 12) (const_int 14)])))))]
10564   "TARGET_AVX512F"
10565   "ix86_fixup_binary_operands_no_copy (MULT, V16SImode, operands);")
10567 (define_insn "*vec_widen_umult_even_v16si<mask_name>"
10568   [(set (match_operand:V8DI 0 "register_operand" "=v")
10569         (mult:V8DI
10570           (zero_extend:V8DI
10571             (vec_select:V8SI
10572               (match_operand:V16SI 1 "nonimmediate_operand" "%v")
10573               (parallel [(const_int 0) (const_int 2)
10574                          (const_int 4) (const_int 6)
10575                          (const_int 8) (const_int 10)
10576                          (const_int 12) (const_int 14)])))
10577           (zero_extend:V8DI
10578             (vec_select:V8SI
10579               (match_operand:V16SI 2 "nonimmediate_operand" "vm")
10580               (parallel [(const_int 0) (const_int 2)
10581                          (const_int 4) (const_int 6)
10582                          (const_int 8) (const_int 10)
10583                          (const_int 12) (const_int 14)])))))]
10584   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10585   "vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10586   [(set_attr "type" "sseimul")
10587    (set_attr "prefix_extra" "1")
10588    (set_attr "prefix" "evex")
10589    (set_attr "mode" "XI")])
10591 (define_expand "vec_widen_umult_even_v8si<mask_name>"
10592   [(set (match_operand:V4DI 0 "register_operand")
10593         (mult:V4DI
10594           (zero_extend:V4DI
10595             (vec_select:V4SI
10596               (match_operand:V8SI 1 "nonimmediate_operand")
10597               (parallel [(const_int 0) (const_int 2)
10598                          (const_int 4) (const_int 6)])))
10599           (zero_extend:V4DI
10600             (vec_select:V4SI
10601               (match_operand:V8SI 2 "nonimmediate_operand")
10602               (parallel [(const_int 0) (const_int 2)
10603                          (const_int 4) (const_int 6)])))))]
10604   "TARGET_AVX2 && <mask_avx512vl_condition>"
10605   "ix86_fixup_binary_operands_no_copy (MULT, V8SImode, operands);")
10607 (define_insn "*vec_widen_umult_even_v8si<mask_name>"
10608   [(set (match_operand:V4DI 0 "register_operand" "=v")
10609         (mult:V4DI
10610           (zero_extend:V4DI
10611             (vec_select:V4SI
10612               (match_operand:V8SI 1 "nonimmediate_operand" "%v")
10613               (parallel [(const_int 0) (const_int 2)
10614                          (const_int 4) (const_int 6)])))
10615           (zero_extend:V4DI
10616             (vec_select:V4SI
10617               (match_operand:V8SI 2 "nonimmediate_operand" "vm")
10618               (parallel [(const_int 0) (const_int 2)
10619                          (const_int 4) (const_int 6)])))))]
10620   "TARGET_AVX2 && <mask_avx512vl_condition>
10621    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10622   "vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10623   [(set_attr "type" "sseimul")
10624    (set_attr "prefix" "maybe_evex")
10625    (set_attr "mode" "OI")])
10627 (define_expand "vec_widen_umult_even_v4si<mask_name>"
10628   [(set (match_operand:V2DI 0 "register_operand")
10629         (mult:V2DI
10630           (zero_extend:V2DI
10631             (vec_select:V2SI
10632               (match_operand:V4SI 1 "vector_operand")
10633               (parallel [(const_int 0) (const_int 2)])))
10634           (zero_extend:V2DI
10635             (vec_select:V2SI
10636               (match_operand:V4SI 2 "vector_operand")
10637               (parallel [(const_int 0) (const_int 2)])))))]
10638   "TARGET_SSE2 && <mask_avx512vl_condition>"
10639   "ix86_fixup_binary_operands_no_copy (MULT, V4SImode, operands);")
10641 (define_insn "*vec_widen_umult_even_v4si<mask_name>"
10642   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
10643         (mult:V2DI
10644           (zero_extend:V2DI
10645             (vec_select:V2SI
10646               (match_operand:V4SI 1 "vector_operand" "%0,v")
10647               (parallel [(const_int 0) (const_int 2)])))
10648           (zero_extend:V2DI
10649             (vec_select:V2SI
10650               (match_operand:V4SI 2 "vector_operand" "xBm,vm")
10651               (parallel [(const_int 0) (const_int 2)])))))]
10652   "TARGET_SSE2 && <mask_avx512vl_condition>
10653    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10654   "@
10655    pmuludq\t{%2, %0|%0, %2}
10656    vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10657   [(set_attr "isa" "noavx,avx")
10658    (set_attr "type" "sseimul")
10659    (set_attr "prefix_data16" "1,*")
10660    (set_attr "prefix" "orig,maybe_evex")
10661    (set_attr "mode" "TI")])
10663 (define_expand "vec_widen_smult_even_v16si<mask_name>"
10664   [(set (match_operand:V8DI 0 "register_operand")
10665         (mult:V8DI
10666           (sign_extend:V8DI
10667             (vec_select:V8SI
10668               (match_operand:V16SI 1 "nonimmediate_operand")
10669               (parallel [(const_int 0) (const_int 2)
10670                          (const_int 4) (const_int 6)
10671                          (const_int 8) (const_int 10)
10672                          (const_int 12) (const_int 14)])))
10673           (sign_extend:V8DI
10674             (vec_select:V8SI
10675               (match_operand:V16SI 2 "nonimmediate_operand")
10676               (parallel [(const_int 0) (const_int 2)
10677                          (const_int 4) (const_int 6)
10678                          (const_int 8) (const_int 10)
10679                          (const_int 12) (const_int 14)])))))]
10680   "TARGET_AVX512F"
10681   "ix86_fixup_binary_operands_no_copy (MULT, V16SImode, operands);")
10683 (define_insn "*vec_widen_smult_even_v16si<mask_name>"
10684   [(set (match_operand:V8DI 0 "register_operand" "=v")
10685         (mult:V8DI
10686           (sign_extend:V8DI
10687             (vec_select:V8SI
10688               (match_operand:V16SI 1 "nonimmediate_operand" "%v")
10689               (parallel [(const_int 0) (const_int 2)
10690                          (const_int 4) (const_int 6)
10691                          (const_int 8) (const_int 10)
10692                          (const_int 12) (const_int 14)])))
10693           (sign_extend:V8DI
10694             (vec_select:V8SI
10695               (match_operand:V16SI 2 "nonimmediate_operand" "vm")
10696               (parallel [(const_int 0) (const_int 2)
10697                          (const_int 4) (const_int 6)
10698                          (const_int 8) (const_int 10)
10699                          (const_int 12) (const_int 14)])))))]
10700   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10701   "vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10702   [(set_attr "type" "sseimul")
10703    (set_attr "prefix_extra" "1")
10704    (set_attr "prefix" "evex")
10705    (set_attr "mode" "XI")])
10707 (define_expand "vec_widen_smult_even_v8si<mask_name>"
10708   [(set (match_operand:V4DI 0 "register_operand")
10709         (mult:V4DI
10710           (sign_extend:V4DI
10711             (vec_select:V4SI
10712               (match_operand:V8SI 1 "nonimmediate_operand")
10713               (parallel [(const_int 0) (const_int 2)
10714                          (const_int 4) (const_int 6)])))
10715           (sign_extend:V4DI
10716             (vec_select:V4SI
10717               (match_operand:V8SI 2 "nonimmediate_operand")
10718               (parallel [(const_int 0) (const_int 2)
10719                          (const_int 4) (const_int 6)])))))]
10720   "TARGET_AVX2 && <mask_avx512vl_condition>"
10721   "ix86_fixup_binary_operands_no_copy (MULT, V8SImode, operands);")
10723 (define_insn "*vec_widen_smult_even_v8si<mask_name>"
10724   [(set (match_operand:V4DI 0 "register_operand" "=v")
10725         (mult:V4DI
10726           (sign_extend:V4DI
10727             (vec_select:V4SI
10728               (match_operand:V8SI 1 "nonimmediate_operand" "%v")
10729               (parallel [(const_int 0) (const_int 2)
10730                          (const_int 4) (const_int 6)])))
10731           (sign_extend:V4DI
10732             (vec_select:V4SI
10733               (match_operand:V8SI 2 "nonimmediate_operand" "vm")
10734               (parallel [(const_int 0) (const_int 2)
10735                          (const_int 4) (const_int 6)])))))]
10736   "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10737   "vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10738   [(set_attr "type" "sseimul")
10739    (set_attr "prefix_extra" "1")
10740    (set_attr "prefix" "vex")
10741    (set_attr "mode" "OI")])
10743 (define_expand "sse4_1_mulv2siv2di3<mask_name>"
10744   [(set (match_operand:V2DI 0 "register_operand")
10745         (mult:V2DI
10746           (sign_extend:V2DI
10747             (vec_select:V2SI
10748               (match_operand:V4SI 1 "vector_operand")
10749               (parallel [(const_int 0) (const_int 2)])))
10750           (sign_extend:V2DI
10751             (vec_select:V2SI
10752               (match_operand:V4SI 2 "vector_operand")
10753               (parallel [(const_int 0) (const_int 2)])))))]
10754   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
10755   "ix86_fixup_binary_operands_no_copy (MULT, V4SImode, operands);")
10757 (define_insn "*sse4_1_mulv2siv2di3<mask_name>"
10758   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
10759         (mult:V2DI
10760           (sign_extend:V2DI
10761             (vec_select:V2SI
10762               (match_operand:V4SI 1 "vector_operand" "%0,0,v")
10763               (parallel [(const_int 0) (const_int 2)])))
10764           (sign_extend:V2DI
10765             (vec_select:V2SI
10766               (match_operand:V4SI 2 "vector_operand" "YrBm,*xBm,vm")
10767               (parallel [(const_int 0) (const_int 2)])))))]
10768   "TARGET_SSE4_1 && <mask_avx512vl_condition>
10769    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10770   "@
10771    pmuldq\t{%2, %0|%0, %2}
10772    pmuldq\t{%2, %0|%0, %2}
10773    vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10774   [(set_attr "isa" "noavx,noavx,avx")
10775    (set_attr "type" "sseimul")
10776    (set_attr "prefix_data16" "1,1,*")
10777    (set_attr "prefix_extra" "1")
10778    (set_attr "prefix" "orig,orig,vex")
10779    (set_attr "mode" "TI")])
10781 (define_insn "avx512bw_pmaddwd512<mode><mask_name>"
10782   [(set (match_operand:<sseunpackmode> 0 "register_operand" "=v")
10783           (unspec:<sseunpackmode>
10784             [(match_operand:VI2_AVX2 1 "register_operand" "v")
10785              (match_operand:VI2_AVX2 2 "nonimmediate_operand" "vm")]
10786              UNSPEC_PMADDWD512))]
10787    "TARGET_AVX512BW && <mask_mode512bit_condition>"
10788    "vpmaddwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}";
10789   [(set_attr "type" "sseiadd")
10790    (set_attr "prefix" "evex")
10791    (set_attr "mode" "XI")])
10793 (define_expand "avx2_pmaddwd"
10794   [(set (match_operand:V8SI 0 "register_operand")
10795         (plus:V8SI
10796           (mult:V8SI
10797             (sign_extend:V8SI
10798               (vec_select:V8HI
10799                 (match_operand:V16HI 1 "nonimmediate_operand")
10800                 (parallel [(const_int 0) (const_int 2)
10801                            (const_int 4) (const_int 6)
10802                            (const_int 8) (const_int 10)
10803                            (const_int 12) (const_int 14)])))
10804             (sign_extend:V8SI
10805               (vec_select:V8HI
10806                 (match_operand:V16HI 2 "nonimmediate_operand")
10807                 (parallel [(const_int 0) (const_int 2)
10808                            (const_int 4) (const_int 6)
10809                            (const_int 8) (const_int 10)
10810                            (const_int 12) (const_int 14)]))))
10811           (mult:V8SI
10812             (sign_extend:V8SI
10813               (vec_select:V8HI (match_dup 1)
10814                 (parallel [(const_int 1) (const_int 3)
10815                            (const_int 5) (const_int 7)
10816                            (const_int 9) (const_int 11)
10817                            (const_int 13) (const_int 15)])))
10818             (sign_extend:V8SI
10819               (vec_select:V8HI (match_dup 2)
10820                 (parallel [(const_int 1) (const_int 3)
10821                            (const_int 5) (const_int 7)
10822                            (const_int 9) (const_int 11)
10823                            (const_int 13) (const_int 15)]))))))]
10824   "TARGET_AVX2"
10825   "ix86_fixup_binary_operands_no_copy (MULT, V16HImode, operands);")
10827 (define_insn "*avx2_pmaddwd"
10828   [(set (match_operand:V8SI 0 "register_operand" "=x,v")
10829         (plus:V8SI
10830           (mult:V8SI
10831             (sign_extend:V8SI
10832               (vec_select:V8HI
10833                 (match_operand:V16HI 1 "nonimmediate_operand" "%x,v")
10834                 (parallel [(const_int 0) (const_int 2)
10835                            (const_int 4) (const_int 6)
10836                            (const_int 8) (const_int 10)
10837                            (const_int 12) (const_int 14)])))
10838             (sign_extend:V8SI
10839               (vec_select:V8HI
10840                 (match_operand:V16HI 2 "nonimmediate_operand" "xm,vm")
10841                 (parallel [(const_int 0) (const_int 2)
10842                            (const_int 4) (const_int 6)
10843                            (const_int 8) (const_int 10)
10844                            (const_int 12) (const_int 14)]))))
10845           (mult:V8SI
10846             (sign_extend:V8SI
10847               (vec_select:V8HI (match_dup 1)
10848                 (parallel [(const_int 1) (const_int 3)
10849                            (const_int 5) (const_int 7)
10850                            (const_int 9) (const_int 11)
10851                            (const_int 13) (const_int 15)])))
10852             (sign_extend:V8SI
10853               (vec_select:V8HI (match_dup 2)
10854                 (parallel [(const_int 1) (const_int 3)
10855                            (const_int 5) (const_int 7)
10856                            (const_int 9) (const_int 11)
10857                            (const_int 13) (const_int 15)]))))))]
10858   "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10859   "vpmaddwd\t{%2, %1, %0|%0, %1, %2}"
10860   [(set_attr "type" "sseiadd")
10861    (set_attr "isa" "*,avx512bw")
10862    (set_attr "prefix" "vex,evex")
10863    (set_attr "mode" "OI")])
10865 (define_expand "sse2_pmaddwd"
10866   [(set (match_operand:V4SI 0 "register_operand")
10867         (plus:V4SI
10868           (mult:V4SI
10869             (sign_extend:V4SI
10870               (vec_select:V4HI
10871                 (match_operand:V8HI 1 "vector_operand")
10872                 (parallel [(const_int 0) (const_int 2)
10873                            (const_int 4) (const_int 6)])))
10874             (sign_extend:V4SI
10875               (vec_select:V4HI
10876                 (match_operand:V8HI 2 "vector_operand")
10877                 (parallel [(const_int 0) (const_int 2)
10878                            (const_int 4) (const_int 6)]))))
10879           (mult:V4SI
10880             (sign_extend:V4SI
10881               (vec_select:V4HI (match_dup 1)
10882                 (parallel [(const_int 1) (const_int 3)
10883                            (const_int 5) (const_int 7)])))
10884             (sign_extend:V4SI
10885               (vec_select:V4HI (match_dup 2)
10886                 (parallel [(const_int 1) (const_int 3)
10887                            (const_int 5) (const_int 7)]))))))]
10888   "TARGET_SSE2"
10889   "ix86_fixup_binary_operands_no_copy (MULT, V8HImode, operands);")
10891 (define_insn "*sse2_pmaddwd"
10892   [(set (match_operand:V4SI 0 "register_operand" "=x,x,v")
10893         (plus:V4SI
10894           (mult:V4SI
10895             (sign_extend:V4SI
10896               (vec_select:V4HI
10897                 (match_operand:V8HI 1 "vector_operand" "%0,x,v")
10898                 (parallel [(const_int 0) (const_int 2)
10899                            (const_int 4) (const_int 6)])))
10900             (sign_extend:V4SI
10901               (vec_select:V4HI
10902                 (match_operand:V8HI 2 "vector_operand" "xBm,xm,vm")
10903                 (parallel [(const_int 0) (const_int 2)
10904                            (const_int 4) (const_int 6)]))))
10905           (mult:V4SI
10906             (sign_extend:V4SI
10907               (vec_select:V4HI (match_dup 1)
10908                 (parallel [(const_int 1) (const_int 3)
10909                            (const_int 5) (const_int 7)])))
10910             (sign_extend:V4SI
10911               (vec_select:V4HI (match_dup 2)
10912                 (parallel [(const_int 1) (const_int 3)
10913                            (const_int 5) (const_int 7)]))))))]
10914   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10915   "@
10916    pmaddwd\t{%2, %0|%0, %2}
10917    vpmaddwd\t{%2, %1, %0|%0, %1, %2}
10918    vpmaddwd\t{%2, %1, %0|%0, %1, %2}"
10919   [(set_attr "isa" "noavx,avx,avx512bw")
10920    (set_attr "type" "sseiadd")
10921    (set_attr "atom_unit" "simul")
10922    (set_attr "prefix_data16" "1,*,*")
10923    (set_attr "prefix" "orig,vex,evex")
10924    (set_attr "mode" "TI")])
10926 (define_insn "avx512dq_mul<mode>3<mask_name>"
10927   [(set (match_operand:VI8 0 "register_operand" "=v")
10928         (mult:VI8
10929           (match_operand:VI8 1 "register_operand" "v")
10930           (match_operand:VI8 2 "nonimmediate_operand" "vm")))]
10931   "TARGET_AVX512DQ && <mask_mode512bit_condition>"
10932   "vpmullq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10933   [(set_attr "type" "sseimul")
10934    (set_attr "prefix" "evex")
10935    (set_attr "mode" "<sseinsnmode>")])
10937 (define_expand "mul<mode>3<mask_name>"
10938   [(set (match_operand:VI4_AVX512F 0 "register_operand")
10939         (mult:VI4_AVX512F
10940           (match_operand:VI4_AVX512F 1 "general_vector_operand")
10941           (match_operand:VI4_AVX512F 2 "general_vector_operand")))]
10942   "TARGET_SSE2 && <mask_mode512bit_condition>"
10944   if (TARGET_SSE4_1)
10945     {
10946       if (!vector_operand (operands[1], <MODE>mode))
10947         operands[1] = force_reg (<MODE>mode, operands[1]);
10948       if (!vector_operand (operands[2], <MODE>mode))
10949         operands[2] = force_reg (<MODE>mode, operands[2]);
10950       ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
10951     }
10952   else
10953     {
10954       ix86_expand_sse2_mulv4si3 (operands[0], operands[1], operands[2]);
10955       DONE;
10956     }
10959 (define_insn "*<sse4_1_avx2>_mul<mode>3<mask_name>"
10960   [(set (match_operand:VI4_AVX512F 0 "register_operand" "=Yr,*x,v")
10961         (mult:VI4_AVX512F
10962           (match_operand:VI4_AVX512F 1 "vector_operand" "%0,0,v")
10963           (match_operand:VI4_AVX512F 2 "vector_operand" "YrBm,*xBm,vm")))]
10964   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))
10965    && <mask_mode512bit_condition>"
10966   "@
10967    pmulld\t{%2, %0|%0, %2}
10968    pmulld\t{%2, %0|%0, %2}
10969    vpmulld\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10970   [(set_attr "isa" "noavx,noavx,avx")
10971    (set_attr "type" "sseimul")
10972    (set_attr "prefix_extra" "1")
10973    (set_attr "prefix" "<mask_prefix4>")
10974    (set_attr "btver2_decode" "vector,vector,vector")
10975    (set_attr "mode" "<sseinsnmode>")])
10977 (define_expand "mul<mode>3"
10978   [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand")
10979         (mult:VI8_AVX2_AVX512F
10980           (match_operand:VI8_AVX2_AVX512F 1 "register_operand")
10981           (match_operand:VI8_AVX2_AVX512F 2 "register_operand")))]
10982   "TARGET_SSE2"
10984   ix86_expand_sse2_mulvxdi3 (operands[0], operands[1], operands[2]);
10985   DONE;
10988 (define_expand "vec_widen_<s>mult_hi_<mode>"
10989   [(match_operand:<sseunpackmode> 0 "register_operand")
10990    (any_extend:<sseunpackmode>
10991      (match_operand:VI124_AVX2 1 "register_operand"))
10992    (match_operand:VI124_AVX2 2 "register_operand")]
10993   "TARGET_SSE2"
10995   ix86_expand_mul_widen_hilo (operands[0], operands[1], operands[2],
10996                               <u_bool>, true);
10997   DONE;
11000 (define_expand "vec_widen_<s>mult_lo_<mode>"
11001   [(match_operand:<sseunpackmode> 0 "register_operand")
11002    (any_extend:<sseunpackmode>
11003      (match_operand:VI124_AVX2 1 "register_operand"))
11004    (match_operand:VI124_AVX2 2 "register_operand")]
11005   "TARGET_SSE2"
11007   ix86_expand_mul_widen_hilo (operands[0], operands[1], operands[2],
11008                               <u_bool>, false);
11009   DONE;
11012 ;; Most widen_<s>mult_even_<mode> can be handled directly from other
11013 ;; named patterns, but signed V4SI needs special help for plain SSE2.
11014 (define_expand "vec_widen_smult_even_v4si"
11015   [(match_operand:V2DI 0 "register_operand")
11016    (match_operand:V4SI 1 "vector_operand")
11017    (match_operand:V4SI 2 "vector_operand")]
11018   "TARGET_SSE2"
11020   ix86_expand_mul_widen_evenodd (operands[0], operands[1], operands[2],
11021                                  false, false);
11022   DONE;
11025 (define_expand "vec_widen_<s>mult_odd_<mode>"
11026   [(match_operand:<sseunpackmode> 0 "register_operand")
11027    (any_extend:<sseunpackmode>
11028      (match_operand:VI4_AVX512F 1 "general_vector_operand"))
11029    (match_operand:VI4_AVX512F 2 "general_vector_operand")]
11030   "TARGET_SSE2"
11032   ix86_expand_mul_widen_evenodd (operands[0], operands[1], operands[2],
11033                                  <u_bool>, true);
11034   DONE;
11037 (define_mode_attr SDOT_PMADD_SUF
11038   [(V32HI "512v32hi") (V16HI "") (V8HI "")])
11040 (define_expand "sdot_prod<mode>"
11041   [(match_operand:<sseunpackmode> 0 "register_operand")
11042    (match_operand:VI2_AVX2 1 "register_operand")
11043    (match_operand:VI2_AVX2 2 "register_operand")
11044    (match_operand:<sseunpackmode> 3 "register_operand")]
11045   "TARGET_SSE2"
11047   rtx t = gen_reg_rtx (<sseunpackmode>mode);
11048   emit_insn (gen_<sse2_avx2>_pmaddwd<SDOT_PMADD_SUF> (t, operands[1], operands[2]));
11049   emit_insn (gen_rtx_SET (operands[0],
11050                           gen_rtx_PLUS (<sseunpackmode>mode,
11051                                         operands[3], t)));
11052   DONE;
11055 ;; Normally we use widen_mul_even/odd, but combine can't quite get it all
11056 ;; back together when madd is available.
11057 (define_expand "sdot_prodv4si"
11058   [(match_operand:V2DI 0 "register_operand")
11059    (match_operand:V4SI 1 "register_operand")
11060    (match_operand:V4SI 2 "register_operand")
11061    (match_operand:V2DI 3 "register_operand")]
11062   "TARGET_XOP"
11064   rtx t = gen_reg_rtx (V2DImode);
11065   emit_insn (gen_xop_pmacsdqh (t, operands[1], operands[2], operands[3]));
11066   emit_insn (gen_xop_pmacsdql (operands[0], operands[1], operands[2], t));
11067   DONE;
11070 (define_expand "uavg<mode>3_ceil"
11071   [(set (match_operand:VI12_AVX2 0 "register_operand")
11072         (truncate:VI12_AVX2
11073           (lshiftrt:<ssedoublemode>
11074             (plus:<ssedoublemode>
11075               (plus:<ssedoublemode>
11076                 (zero_extend:<ssedoublemode>
11077                   (match_operand:VI12_AVX2 1 "vector_operand"))
11078                 (zero_extend:<ssedoublemode>
11079                   (match_operand:VI12_AVX2 2 "vector_operand")))
11080               (match_dup 3))
11081             (const_int 1))))]
11082   "TARGET_SSE2"
11084   operands[3] = CONST1_RTX(<MODE>mode);
11085   ix86_fixup_binary_operands_no_copy (PLUS, <MODE>mode, operands);
11088 (define_expand "usadv16qi"
11089   [(match_operand:V4SI 0 "register_operand")
11090    (match_operand:V16QI 1 "register_operand")
11091    (match_operand:V16QI 2 "vector_operand")
11092    (match_operand:V4SI 3 "vector_operand")]
11093   "TARGET_SSE2"
11095   rtx t1 = gen_reg_rtx (V2DImode);
11096   rtx t2 = gen_reg_rtx (V4SImode);
11097   emit_insn (gen_sse2_psadbw (t1, operands[1], operands[2]));
11098   convert_move (t2, t1, 0);
11099   emit_insn (gen_addv4si3 (operands[0], t2, operands[3]));
11100   DONE;
11103 (define_expand "usadv32qi"
11104   [(match_operand:V8SI 0 "register_operand")
11105    (match_operand:V32QI 1 "register_operand")
11106    (match_operand:V32QI 2 "nonimmediate_operand")
11107    (match_operand:V8SI 3 "nonimmediate_operand")]
11108   "TARGET_AVX2"
11110   rtx t1 = gen_reg_rtx (V4DImode);
11111   rtx t2 = gen_reg_rtx (V8SImode);
11112   emit_insn (gen_avx2_psadbw (t1, operands[1], operands[2]));
11113   convert_move (t2, t1, 0);
11114   emit_insn (gen_addv8si3 (operands[0], t2, operands[3]));
11115   DONE;
11118 (define_expand "usadv64qi"
11119   [(match_operand:V16SI 0 "register_operand")
11120    (match_operand:V64QI 1 "register_operand")
11121    (match_operand:V64QI 2 "nonimmediate_operand")
11122    (match_operand:V16SI 3 "nonimmediate_operand")]
11123   "TARGET_AVX512BW"
11125   rtx t1 = gen_reg_rtx (V8DImode);
11126   rtx t2 = gen_reg_rtx (V16SImode);
11127   emit_insn (gen_avx512f_psadbw (t1, operands[1], operands[2]));
11128   convert_move (t2, t1, 0);
11129   emit_insn (gen_addv16si3 (operands[0], t2, operands[3]));
11130   DONE;
11133 (define_insn "<mask_codefor>ashr<mode>3<mask_name>"
11134   [(set (match_operand:VI248_AVX512BW_1 0 "register_operand" "=v,v")
11135         (ashiftrt:VI248_AVX512BW_1
11136           (match_operand:VI248_AVX512BW_1 1 "nonimmediate_operand" "v,vm")
11137           (match_operand:DI 2 "nonmemory_operand" "v,N")))]
11138   "TARGET_AVX512VL"
11139   "vpsra<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11140   [(set_attr "type" "sseishft")
11141    (set (attr "length_immediate")
11142      (if_then_else (match_operand 2 "const_int_operand")
11143        (const_string "1")
11144        (const_string "0")))
11145    (set_attr "mode" "<sseinsnmode>")])
11147 (define_insn "ashr<mode>3"
11148   [(set (match_operand:VI24_AVX2 0 "register_operand" "=x,x")
11149         (ashiftrt:VI24_AVX2
11150           (match_operand:VI24_AVX2 1 "register_operand" "0,x")
11151           (match_operand:DI 2 "nonmemory_operand" "xN,xN")))]
11152   "TARGET_SSE2"
11153   "@
11154    psra<ssemodesuffix>\t{%2, %0|%0, %2}
11155    vpsra<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11156   [(set_attr "isa" "noavx,avx")
11157    (set_attr "type" "sseishft")
11158    (set (attr "length_immediate")
11159      (if_then_else (match_operand 2 "const_int_operand")
11160        (const_string "1")
11161        (const_string "0")))
11162    (set_attr "prefix_data16" "1,*")
11163    (set_attr "prefix" "orig,vex")
11164    (set_attr "mode" "<sseinsnmode>")])
11166 (define_insn "ashr<mode>3<mask_name>"
11167   [(set (match_operand:VI248_AVX512BW_AVX512VL 0 "register_operand" "=v,v")
11168         (ashiftrt:VI248_AVX512BW_AVX512VL
11169           (match_operand:VI248_AVX512BW_AVX512VL 1 "nonimmediate_operand" "v,vm")
11170           (match_operand:DI 2 "nonmemory_operand" "v,N")))]
11171   "TARGET_AVX512F"
11172   "vpsra<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11173   [(set_attr "type" "sseishft")
11174    (set (attr "length_immediate")
11175      (if_then_else (match_operand 2 "const_int_operand")
11176        (const_string "1")
11177        (const_string "0")))
11178    (set_attr "mode" "<sseinsnmode>")])
11180 (define_insn "<mask_codefor><shift_insn><mode>3<mask_name>"
11181   [(set (match_operand:VI248_AVX512BW_2 0 "register_operand" "=v,v")
11182         (any_lshift:VI248_AVX512BW_2
11183           (match_operand:VI248_AVX512BW_2 1 "nonimmediate_operand" "v,vm")
11184           (match_operand:DI 2 "nonmemory_operand" "v,N")))]
11185   "TARGET_AVX512VL"
11186   "vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11187   [(set_attr "type" "sseishft")
11188    (set (attr "length_immediate")
11189      (if_then_else (match_operand 2 "const_int_operand")
11190        (const_string "1")
11191        (const_string "0")))
11192    (set_attr "mode" "<sseinsnmode>")])
11194 (define_insn "<shift_insn><mode>3"
11195   [(set (match_operand:VI248_AVX2 0 "register_operand" "=x,x")
11196         (any_lshift:VI248_AVX2
11197           (match_operand:VI248_AVX2 1 "register_operand" "0,x")
11198           (match_operand:DI 2 "nonmemory_operand" "xN,xN")))]
11199   "TARGET_SSE2"
11200   "@
11201    p<vshift><ssemodesuffix>\t{%2, %0|%0, %2}
11202    vp<vshift><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11203   [(set_attr "isa" "noavx,avx")
11204    (set_attr "type" "sseishft")
11205    (set (attr "length_immediate")
11206      (if_then_else (match_operand 2 "const_int_operand")
11207        (const_string "1")
11208        (const_string "0")))
11209    (set_attr "prefix_data16" "1,*")
11210    (set_attr "prefix" "orig,vex")
11211    (set_attr "mode" "<sseinsnmode>")])
11213 (define_insn "<shift_insn><mode>3<mask_name>"
11214   [(set (match_operand:VI248_AVX512BW 0 "register_operand" "=v,v")
11215         (any_lshift:VI248_AVX512BW
11216           (match_operand:VI248_AVX512BW 1 "nonimmediate_operand" "v,m")
11217           (match_operand:DI 2 "nonmemory_operand" "vN,N")))]
11218   "TARGET_AVX512F"
11219   "vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11220   [(set_attr "type" "sseishft")
11221    (set (attr "length_immediate")
11222      (if_then_else (match_operand 2 "const_int_operand")
11223        (const_string "1")
11224        (const_string "0")))
11225    (set_attr "mode" "<sseinsnmode>")])
11228 (define_expand "vec_shr_<mode>"
11229   [(set (match_dup 3)
11230         (lshiftrt:V1TI
11231          (match_operand:VI_128 1 "register_operand")
11232          (match_operand:SI 2 "const_0_to_255_mul_8_operand")))
11233    (set (match_operand:VI_128 0 "register_operand") (match_dup 4))]
11234   "TARGET_SSE2"
11236   operands[1] = gen_lowpart (V1TImode, operands[1]);
11237   operands[3] = gen_reg_rtx (V1TImode);
11238   operands[4] = gen_lowpart (<MODE>mode, operands[3]);
11241 (define_insn "avx512bw_<shift_insn><mode>3"
11242   [(set (match_operand:VIMAX_AVX512VL 0 "register_operand" "=v")
11243         (any_lshift:VIMAX_AVX512VL
11244          (match_operand:VIMAX_AVX512VL 1 "nonimmediate_operand" "vm")
11245          (match_operand:SI 2 "const_0_to_255_mul_8_operand" "n")))]
11246   "TARGET_AVX512BW"
11248   operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
11249   return "vp<vshift>dq\t{%2, %1, %0|%0, %1, %2}";
11251   [(set_attr "type" "sseishft")
11252    (set_attr "length_immediate" "1")
11253    (set_attr "prefix" "maybe_evex")
11254    (set_attr "mode" "<sseinsnmode>")])
11256 (define_insn "<sse2_avx2>_<shift_insn><mode>3"
11257   [(set (match_operand:VIMAX_AVX2 0 "register_operand" "=x,v")
11258         (any_lshift:VIMAX_AVX2
11259          (match_operand:VIMAX_AVX2 1 "register_operand" "0,v")
11260          (match_operand:SI 2 "const_0_to_255_mul_8_operand" "n,n")))]
11261   "TARGET_SSE2"
11263   operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
11265   switch (which_alternative)
11266     {
11267     case 0:
11268       return "p<vshift>dq\t{%2, %0|%0, %2}";
11269     case 1:
11270       return "vp<vshift>dq\t{%2, %1, %0|%0, %1, %2}";
11271     default:
11272       gcc_unreachable ();
11273     }
11275   [(set_attr "isa" "noavx,avx")
11276    (set_attr "type" "sseishft")
11277    (set_attr "length_immediate" "1")
11278    (set_attr "atom_unit" "sishuf")
11279    (set_attr "prefix_data16" "1,*")
11280    (set_attr "prefix" "orig,vex")
11281    (set_attr "mode" "<sseinsnmode>")])
11283 (define_insn "<avx512>_<rotate>v<mode><mask_name>"
11284   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
11285         (any_rotate:VI48_AVX512VL
11286           (match_operand:VI48_AVX512VL 1 "register_operand" "v")
11287           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")))]
11288   "TARGET_AVX512F"
11289   "vp<rotate>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11290   [(set_attr "prefix" "evex")
11291    (set_attr "mode" "<sseinsnmode>")])
11293 (define_insn "<avx512>_<rotate><mode><mask_name>"
11294   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
11295         (any_rotate:VI48_AVX512VL
11296           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")
11297           (match_operand:SI 2 "const_0_to_255_operand")))]
11298   "TARGET_AVX512F"
11299   "vp<rotate><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11300   [(set_attr "prefix" "evex")
11301    (set_attr "mode" "<sseinsnmode>")])
11303 (define_expand "<code><mode>3"
11304   [(set (match_operand:VI124_256_AVX512F_AVX512BW 0 "register_operand")
11305         (maxmin:VI124_256_AVX512F_AVX512BW
11306           (match_operand:VI124_256_AVX512F_AVX512BW 1 "nonimmediate_operand")
11307           (match_operand:VI124_256_AVX512F_AVX512BW 2 "nonimmediate_operand")))]
11308   "TARGET_AVX2"
11309   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
11311 (define_insn "*avx2_<code><mode>3"
11312   [(set (match_operand:VI124_256 0 "register_operand" "=v")
11313         (maxmin:VI124_256
11314           (match_operand:VI124_256 1 "nonimmediate_operand" "%v")
11315           (match_operand:VI124_256 2 "nonimmediate_operand" "vm")))]
11316   "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11317   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11318   [(set_attr "type" "sseiadd")
11319    (set_attr "prefix_extra" "1")
11320    (set_attr "prefix" "vex")
11321    (set_attr "mode" "OI")])
11323 (define_expand "<code><mode>3_mask"
11324   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
11325         (vec_merge:VI48_AVX512VL
11326           (maxmin:VI48_AVX512VL
11327             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
11328             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
11329           (match_operand:VI48_AVX512VL 3 "nonimm_or_0_operand")
11330           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
11331   "TARGET_AVX512F"
11332   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
11334 (define_insn "*avx512f_<code><mode>3<mask_name>"
11335   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
11336         (maxmin:VI48_AVX512VL
11337           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "%v")
11338           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")))]
11339   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11340   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11341   [(set_attr "type" "sseiadd")
11342    (set_attr "prefix_extra" "1")
11343    (set_attr "prefix" "maybe_evex")
11344    (set_attr "mode" "<sseinsnmode>")])
11346 (define_insn "<mask_codefor><code><mode>3<mask_name>"
11347   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
11348         (maxmin:VI12_AVX512VL
11349           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
11350           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")))]
11351   "TARGET_AVX512BW"
11352   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11353   [(set_attr "type" "sseiadd")
11354    (set_attr "prefix" "evex")
11355    (set_attr "mode" "<sseinsnmode>")])
11357 (define_expand "<code><mode>3"
11358   [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand")
11359         (maxmin:VI8_AVX2_AVX512F
11360           (match_operand:VI8_AVX2_AVX512F 1 "register_operand")
11361           (match_operand:VI8_AVX2_AVX512F 2 "register_operand")))]
11362   "TARGET_SSE4_2"
11364   if (TARGET_AVX512F
11365       && (<MODE>mode == V8DImode || TARGET_AVX512VL))
11366     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
11367   else 
11368     {
11369       enum rtx_code code;
11370       rtx xops[6];
11371       bool ok;
11374       xops[0] = operands[0];
11376       if (<CODE> == SMAX || <CODE> == UMAX)
11377         {
11378           xops[1] = operands[1];
11379           xops[2] = operands[2];
11380         }
11381       else
11382         {
11383           xops[1] = operands[2];
11384           xops[2] = operands[1];
11385         }
11387       code = (<CODE> == UMAX || <CODE> == UMIN) ? GTU : GT;
11389       xops[3] = gen_rtx_fmt_ee (code, VOIDmode, operands[1], operands[2]);
11390       xops[4] = operands[1];
11391       xops[5] = operands[2];
11393       ok = ix86_expand_int_vcond (xops);
11394       gcc_assert (ok);
11395       DONE;
11396     }
11399 (define_expand "<code><mode>3"
11400   [(set (match_operand:VI124_128 0 "register_operand")
11401         (smaxmin:VI124_128
11402           (match_operand:VI124_128 1 "vector_operand")
11403           (match_operand:VI124_128 2 "vector_operand")))]
11404   "TARGET_SSE2"
11406   if (TARGET_SSE4_1 || <MODE>mode == V8HImode)
11407     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
11408   else
11409     {
11410       rtx xops[6];
11411       bool ok;
11413       xops[0] = operands[0];
11414       operands[1] = force_reg (<MODE>mode, operands[1]);
11415       operands[2] = force_reg (<MODE>mode, operands[2]);
11417       if (<CODE> == SMAX)
11418         {
11419           xops[1] = operands[1];
11420           xops[2] = operands[2];
11421         }
11422       else
11423         {
11424           xops[1] = operands[2];
11425           xops[2] = operands[1];
11426         }
11428       xops[3] = gen_rtx_GT (VOIDmode, operands[1], operands[2]);
11429       xops[4] = operands[1];
11430       xops[5] = operands[2];
11432       ok = ix86_expand_int_vcond (xops);
11433       gcc_assert (ok);
11434       DONE;
11435     }
11438 (define_insn "*sse4_1_<code><mode>3<mask_name>"
11439   [(set (match_operand:VI14_128 0 "register_operand" "=Yr,*x,v")
11440         (smaxmin:VI14_128
11441           (match_operand:VI14_128 1 "vector_operand" "%0,0,v")
11442           (match_operand:VI14_128 2 "vector_operand" "YrBm,*xBm,vm")))]
11443   "TARGET_SSE4_1
11444    && <mask_mode512bit_condition>
11445    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11446   "@
11447    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
11448    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
11449    vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11450   [(set_attr "isa" "noavx,noavx,avx")
11451    (set_attr "type" "sseiadd")
11452    (set_attr "prefix_extra" "1,1,*")
11453    (set_attr "prefix" "orig,orig,vex")
11454    (set_attr "mode" "TI")])
11456 (define_insn "*<code>v8hi3"
11457   [(set (match_operand:V8HI 0 "register_operand" "=x,x,v")
11458         (smaxmin:V8HI
11459           (match_operand:V8HI 1 "vector_operand" "%0,x,v")
11460           (match_operand:V8HI 2 "vector_operand" "xBm,xm,vm")))]
11461   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11462   "@
11463    p<maxmin_int>w\t{%2, %0|%0, %2}
11464    vp<maxmin_int>w\t{%2, %1, %0|%0, %1, %2}
11465    vp<maxmin_int>w\t{%2, %1, %0|%0, %1, %2}"
11466   [(set_attr "isa" "noavx,avx,avx512bw")
11467    (set_attr "type" "sseiadd")
11468    (set_attr "prefix_data16" "1,*,*")
11469    (set_attr "prefix_extra" "*,1,1")
11470    (set_attr "prefix" "orig,vex,evex")
11471    (set_attr "mode" "TI")])
11473 (define_expand "<code><mode>3"
11474   [(set (match_operand:VI124_128 0 "register_operand")
11475         (umaxmin:VI124_128
11476           (match_operand:VI124_128 1 "vector_operand")
11477           (match_operand:VI124_128 2 "vector_operand")))]
11478   "TARGET_SSE2"
11480   if (TARGET_SSE4_1 || <MODE>mode == V16QImode)
11481     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
11482   else if (<CODE> == UMAX && <MODE>mode == V8HImode)
11483     {
11484       rtx op0 = operands[0], op2 = operands[2], op3 = op0;
11485       operands[1] = force_reg (<MODE>mode, operands[1]);
11486       if (rtx_equal_p (op3, op2))
11487         op3 = gen_reg_rtx (V8HImode);
11488       emit_insn (gen_sse2_ussubv8hi3 (op3, operands[1], op2));
11489       emit_insn (gen_addv8hi3 (op0, op3, op2));
11490       DONE;
11491     }
11492   else
11493     {
11494       rtx xops[6];
11495       bool ok;
11497       operands[1] = force_reg (<MODE>mode, operands[1]);
11498       operands[2] = force_reg (<MODE>mode, operands[2]);
11500       xops[0] = operands[0];
11502       if (<CODE> == UMAX)
11503         {
11504           xops[1] = operands[1];
11505           xops[2] = operands[2];
11506         }
11507       else
11508         {
11509           xops[1] = operands[2];
11510           xops[2] = operands[1];
11511         }
11513       xops[3] = gen_rtx_GTU (VOIDmode, operands[1], operands[2]);
11514       xops[4] = operands[1];
11515       xops[5] = operands[2];
11517       ok = ix86_expand_int_vcond (xops);
11518       gcc_assert (ok);
11519       DONE;
11520     }
11523 (define_insn "*sse4_1_<code><mode>3<mask_name>"
11524   [(set (match_operand:VI24_128 0 "register_operand" "=Yr,*x,v")
11525         (umaxmin:VI24_128
11526           (match_operand:VI24_128 1 "vector_operand" "%0,0,v")
11527           (match_operand:VI24_128 2 "vector_operand" "YrBm,*xBm,vm")))]
11528   "TARGET_SSE4_1
11529    && <mask_mode512bit_condition>
11530    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11531   "@
11532    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
11533    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
11534    vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11535   [(set_attr "isa" "noavx,noavx,avx")
11536    (set_attr "type" "sseiadd")
11537    (set_attr "prefix_extra" "1,1,*")
11538    (set_attr "prefix" "orig,orig,vex")
11539    (set_attr "mode" "TI")])
11541 (define_insn "*<code>v16qi3"
11542   [(set (match_operand:V16QI 0 "register_operand" "=x,x,v")
11543         (umaxmin:V16QI
11544           (match_operand:V16QI 1 "vector_operand" "%0,x,v")
11545           (match_operand:V16QI 2 "vector_operand" "xBm,xm,vm")))]
11546   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11547   "@
11548    p<maxmin_int>b\t{%2, %0|%0, %2}
11549    vp<maxmin_int>b\t{%2, %1, %0|%0, %1, %2}
11550    vp<maxmin_int>b\t{%2, %1, %0|%0, %1, %2}"
11551   [(set_attr "isa" "noavx,avx,avx512bw")
11552    (set_attr "type" "sseiadd")
11553    (set_attr "prefix_data16" "1,*,*")
11554    (set_attr "prefix_extra" "*,1,1")
11555    (set_attr "prefix" "orig,vex,evex")
11556    (set_attr "mode" "TI")])
11558 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11560 ;; Parallel integral comparisons
11562 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11564 (define_expand "avx2_eq<mode>3"
11565   [(set (match_operand:VI_256 0 "register_operand")
11566         (eq:VI_256
11567           (match_operand:VI_256 1 "nonimmediate_operand")
11568           (match_operand:VI_256 2 "nonimmediate_operand")))]
11569   "TARGET_AVX2"
11570   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
11572 (define_insn "*avx2_eq<mode>3"
11573   [(set (match_operand:VI_256 0 "register_operand" "=x")
11574         (eq:VI_256
11575           (match_operand:VI_256 1 "nonimmediate_operand" "%x")
11576           (match_operand:VI_256 2 "nonimmediate_operand" "xm")))]
11577   "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11578   "vpcmpeq<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11579   [(set_attr "type" "ssecmp")
11580    (set_attr "prefix_extra" "1")
11581    (set_attr "prefix" "vex")
11582    (set_attr "mode" "OI")])
11584 (define_expand "<avx512>_eq<mode>3<mask_scalar_merge_name>"
11585   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
11586         (unspec:<avx512fmaskmode>
11587           [(match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
11588            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand")]
11589           UNSPEC_MASKED_EQ))]
11590   "TARGET_AVX512BW"
11591   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
11593 (define_expand "<avx512>_eq<mode>3<mask_scalar_merge_name>"
11594   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
11595         (unspec:<avx512fmaskmode>
11596           [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
11597            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand")]
11598           UNSPEC_MASKED_EQ))]
11599   "TARGET_AVX512F"
11600   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
11602 (define_insn "<avx512>_eq<mode>3<mask_scalar_merge_name>_1"
11603   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk,Yk")
11604         (unspec:<avx512fmaskmode>
11605           [(match_operand:VI12_AVX512VL 1 "nonimm_or_0_operand" "%v,v")
11606            (match_operand:VI12_AVX512VL 2 "nonimm_or_0_operand" "vm,C")]
11607           UNSPEC_MASKED_EQ))]
11608   "TARGET_AVX512BW && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11609   "@
11610    vpcmpeq<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}
11611    vptestnm<ssemodesuffix>\t{%1, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %1}"
11612   [(set_attr "type" "ssecmp")
11613    (set_attr "prefix_extra" "1")
11614    (set_attr "prefix" "evex")
11615    (set_attr "mode" "<sseinsnmode>")])
11617 (define_insn "<avx512>_eq<mode>3<mask_scalar_merge_name>_1"
11618   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk,Yk")
11619         (unspec:<avx512fmaskmode>
11620           [(match_operand:VI48_AVX512VL 1 "nonimm_or_0_operand" "%v,v")
11621            (match_operand:VI48_AVX512VL 2 "nonimm_or_0_operand" "vm,C")]
11622           UNSPEC_MASKED_EQ))]
11623   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11624   "@
11625    vpcmpeq<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}
11626    vptestnm<ssemodesuffix>\t{%1, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %1}"
11627   [(set_attr "type" "ssecmp")
11628    (set_attr "prefix_extra" "1")
11629    (set_attr "prefix" "evex")
11630    (set_attr "mode" "<sseinsnmode>")])
11632 (define_insn "*sse4_1_eqv2di3"
11633   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,x")
11634         (eq:V2DI
11635           (match_operand:V2DI 1 "vector_operand" "%0,0,x")
11636           (match_operand:V2DI 2 "vector_operand" "YrBm,*xBm,xm")))]
11637   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11638   "@
11639    pcmpeqq\t{%2, %0|%0, %2}
11640    pcmpeqq\t{%2, %0|%0, %2}
11641    vpcmpeqq\t{%2, %1, %0|%0, %1, %2}"
11642   [(set_attr "isa" "noavx,noavx,avx")
11643    (set_attr "type" "ssecmp")
11644    (set_attr "prefix_extra" "1")
11645    (set_attr "prefix" "orig,orig,vex")
11646    (set_attr "mode" "TI")])
11648 (define_insn "*sse2_eq<mode>3"
11649   [(set (match_operand:VI124_128 0 "register_operand" "=x,x")
11650         (eq:VI124_128
11651           (match_operand:VI124_128 1 "vector_operand" "%0,x")
11652           (match_operand:VI124_128 2 "vector_operand" "xBm,xm")))]
11653   "TARGET_SSE2 && !TARGET_XOP
11654    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11655   "@
11656    pcmpeq<ssemodesuffix>\t{%2, %0|%0, %2}
11657    vpcmpeq<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11658   [(set_attr "isa" "noavx,avx")
11659    (set_attr "type" "ssecmp")
11660    (set_attr "prefix_data16" "1,*")
11661    (set_attr "prefix" "orig,vex")
11662    (set_attr "mode" "TI")])
11664 (define_expand "sse2_eq<mode>3"
11665   [(set (match_operand:VI124_128 0 "register_operand")
11666         (eq:VI124_128
11667           (match_operand:VI124_128 1 "vector_operand")
11668           (match_operand:VI124_128 2 "vector_operand")))]
11669   "TARGET_SSE2 && !TARGET_XOP "
11670   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
11672 (define_expand "sse4_1_eqv2di3"
11673   [(set (match_operand:V2DI 0 "register_operand")
11674         (eq:V2DI
11675           (match_operand:V2DI 1 "vector_operand")
11676           (match_operand:V2DI 2 "vector_operand")))]
11677   "TARGET_SSE4_1"
11678   "ix86_fixup_binary_operands_no_copy (EQ, V2DImode, operands);")
11680 (define_insn "sse4_2_gtv2di3"
11681   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,x")
11682         (gt:V2DI
11683           (match_operand:V2DI 1 "register_operand" "0,0,x")
11684           (match_operand:V2DI 2 "vector_operand" "YrBm,*xBm,xm")))]
11685   "TARGET_SSE4_2"
11686   "@
11687    pcmpgtq\t{%2, %0|%0, %2}
11688    pcmpgtq\t{%2, %0|%0, %2}
11689    vpcmpgtq\t{%2, %1, %0|%0, %1, %2}"
11690   [(set_attr "isa" "noavx,noavx,avx")
11691    (set_attr "type" "ssecmp")
11692    (set_attr "prefix_extra" "1")
11693    (set_attr "prefix" "orig,orig,vex")
11694    (set_attr "mode" "TI")])
11696 (define_insn "avx2_gt<mode>3"
11697   [(set (match_operand:VI_256 0 "register_operand" "=x")
11698         (gt:VI_256
11699           (match_operand:VI_256 1 "register_operand" "x")
11700           (match_operand:VI_256 2 "nonimmediate_operand" "xm")))]
11701   "TARGET_AVX2"
11702   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11703   [(set_attr "type" "ssecmp")
11704    (set_attr "prefix_extra" "1")
11705    (set_attr "prefix" "vex")
11706    (set_attr "mode" "OI")])
11708 (define_insn "<avx512>_gt<mode>3<mask_scalar_merge_name>"
11709   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11710         (unspec:<avx512fmaskmode>
11711           [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
11712            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")] UNSPEC_MASKED_GT))]
11713   "TARGET_AVX512F"
11714   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11715   [(set_attr "type" "ssecmp")
11716    (set_attr "prefix_extra" "1")
11717    (set_attr "prefix" "evex")
11718    (set_attr "mode" "<sseinsnmode>")])
11720 (define_insn "<avx512>_gt<mode>3<mask_scalar_merge_name>"
11721   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11722         (unspec:<avx512fmaskmode>
11723           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
11724            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")] UNSPEC_MASKED_GT))]
11725   "TARGET_AVX512BW"
11726   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11727   [(set_attr "type" "ssecmp")
11728    (set_attr "prefix_extra" "1")
11729    (set_attr "prefix" "evex")
11730    (set_attr "mode" "<sseinsnmode>")])
11732 (define_insn "sse2_gt<mode>3"
11733   [(set (match_operand:VI124_128 0 "register_operand" "=x,x")
11734         (gt:VI124_128
11735           (match_operand:VI124_128 1 "register_operand" "0,x")
11736           (match_operand:VI124_128 2 "vector_operand" "xBm,xm")))]
11737   "TARGET_SSE2 && !TARGET_XOP"
11738   "@
11739    pcmpgt<ssemodesuffix>\t{%2, %0|%0, %2}
11740    vpcmpgt<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11741   [(set_attr "isa" "noavx,avx")
11742    (set_attr "type" "ssecmp")
11743    (set_attr "prefix_data16" "1,*")
11744    (set_attr "prefix" "orig,vex")
11745    (set_attr "mode" "TI")])
11747 (define_expand "vcond<V_512:mode><VI_AVX512BW:mode>"
11748   [(set (match_operand:V_512 0 "register_operand")
11749         (if_then_else:V_512
11750           (match_operator 3 ""
11751             [(match_operand:VI_AVX512BW 4 "nonimmediate_operand")
11752              (match_operand:VI_AVX512BW 5 "general_operand")])
11753           (match_operand:V_512 1)
11754           (match_operand:V_512 2)))]
11755   "TARGET_AVX512F
11756    && (GET_MODE_NUNITS (<V_512:MODE>mode)
11757        == GET_MODE_NUNITS (<VI_AVX512BW:MODE>mode))"
11759   bool ok = ix86_expand_int_vcond (operands);
11760   gcc_assert (ok);
11761   DONE;
11764 (define_expand "vcond<V_256:mode><VI_256:mode>"
11765   [(set (match_operand:V_256 0 "register_operand")
11766         (if_then_else:V_256
11767           (match_operator 3 ""
11768             [(match_operand:VI_256 4 "nonimmediate_operand")
11769              (match_operand:VI_256 5 "general_operand")])
11770           (match_operand:V_256 1)
11771           (match_operand:V_256 2)))]
11772   "TARGET_AVX2
11773    && (GET_MODE_NUNITS (<V_256:MODE>mode)
11774        == GET_MODE_NUNITS (<VI_256:MODE>mode))"
11776   bool ok = ix86_expand_int_vcond (operands);
11777   gcc_assert (ok);
11778   DONE;
11781 (define_expand "vcond<V_128:mode><VI124_128:mode>"
11782   [(set (match_operand:V_128 0 "register_operand")
11783         (if_then_else:V_128
11784           (match_operator 3 ""
11785             [(match_operand:VI124_128 4 "vector_operand")
11786              (match_operand:VI124_128 5 "general_operand")])
11787           (match_operand:V_128 1)
11788           (match_operand:V_128 2)))]
11789   "TARGET_SSE2
11790    && (GET_MODE_NUNITS (<V_128:MODE>mode)
11791        == GET_MODE_NUNITS (<VI124_128:MODE>mode))"
11793   bool ok = ix86_expand_int_vcond (operands);
11794   gcc_assert (ok);
11795   DONE;
11798 (define_expand "vcond<VI8F_128:mode>v2di"
11799   [(set (match_operand:VI8F_128 0 "register_operand")
11800         (if_then_else:VI8F_128
11801           (match_operator 3 ""
11802             [(match_operand:V2DI 4 "vector_operand")
11803              (match_operand:V2DI 5 "general_operand")])
11804           (match_operand:VI8F_128 1)
11805           (match_operand:VI8F_128 2)))]
11806   "TARGET_SSE4_2"
11808   bool ok = ix86_expand_int_vcond (operands);
11809   gcc_assert (ok);
11810   DONE;
11813 (define_expand "vcondu<V_512:mode><VI_AVX512BW:mode>"
11814   [(set (match_operand:V_512 0 "register_operand")
11815         (if_then_else:V_512
11816           (match_operator 3 ""
11817             [(match_operand:VI_AVX512BW 4 "nonimmediate_operand")
11818              (match_operand:VI_AVX512BW 5 "nonimmediate_operand")])
11819           (match_operand:V_512 1 "general_operand")
11820           (match_operand:V_512 2 "general_operand")))]
11821   "TARGET_AVX512F
11822    && (GET_MODE_NUNITS (<V_512:MODE>mode)
11823        == GET_MODE_NUNITS (<VI_AVX512BW:MODE>mode))"
11825   bool ok = ix86_expand_int_vcond (operands);
11826   gcc_assert (ok);
11827   DONE;
11830 (define_expand "vcondu<V_256:mode><VI_256:mode>"
11831   [(set (match_operand:V_256 0 "register_operand")
11832         (if_then_else:V_256
11833           (match_operator 3 ""
11834             [(match_operand:VI_256 4 "nonimmediate_operand")
11835              (match_operand:VI_256 5 "nonimmediate_operand")])
11836           (match_operand:V_256 1 "general_operand")
11837           (match_operand:V_256 2 "general_operand")))]
11838   "TARGET_AVX2
11839    && (GET_MODE_NUNITS (<V_256:MODE>mode)
11840        == GET_MODE_NUNITS (<VI_256:MODE>mode))"
11842   bool ok = ix86_expand_int_vcond (operands);
11843   gcc_assert (ok);
11844   DONE;
11847 (define_expand "vcondu<V_128:mode><VI124_128:mode>"
11848   [(set (match_operand:V_128 0 "register_operand")
11849         (if_then_else:V_128
11850           (match_operator 3 ""
11851             [(match_operand:VI124_128 4 "vector_operand")
11852              (match_operand:VI124_128 5 "vector_operand")])
11853           (match_operand:V_128 1 "general_operand")
11854           (match_operand:V_128 2 "general_operand")))]
11855   "TARGET_SSE2
11856    && (GET_MODE_NUNITS (<V_128:MODE>mode)
11857        == GET_MODE_NUNITS (<VI124_128:MODE>mode))"
11859   bool ok = ix86_expand_int_vcond (operands);
11860   gcc_assert (ok);
11861   DONE;
11864 (define_expand "vcondu<VI8F_128:mode>v2di"
11865   [(set (match_operand:VI8F_128 0 "register_operand")
11866         (if_then_else:VI8F_128
11867           (match_operator 3 ""
11868             [(match_operand:V2DI 4 "vector_operand")
11869              (match_operand:V2DI 5 "vector_operand")])
11870           (match_operand:VI8F_128 1 "general_operand")
11871           (match_operand:VI8F_128 2 "general_operand")))]
11872   "TARGET_SSE4_2"
11874   bool ok = ix86_expand_int_vcond (operands);
11875   gcc_assert (ok);
11876   DONE;
11879 (define_expand "vcondeq<VI8F_128:mode>v2di"
11880   [(set (match_operand:VI8F_128 0 "register_operand")
11881         (if_then_else:VI8F_128
11882           (match_operator 3 ""
11883             [(match_operand:V2DI 4 "vector_operand")
11884              (match_operand:V2DI 5 "general_operand")])
11885           (match_operand:VI8F_128 1)
11886           (match_operand:VI8F_128 2)))]
11887   "TARGET_SSE4_1"
11889   bool ok = ix86_expand_int_vcond (operands);
11890   gcc_assert (ok);
11891   DONE;
11894 (define_mode_iterator VEC_PERM_AVX2
11895   [V16QI V8HI V4SI V2DI V4SF V2DF
11896    (V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
11897    (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")
11898    (V8SF "TARGET_AVX2") (V4DF "TARGET_AVX2")
11899    (V16SF "TARGET_AVX512F") (V8DF "TARGET_AVX512F")
11900    (V16SI "TARGET_AVX512F") (V8DI "TARGET_AVX512F")
11901    (V32HI "TARGET_AVX512BW") (V64QI "TARGET_AVX512VBMI")])
11903 (define_expand "vec_perm<mode>"
11904   [(match_operand:VEC_PERM_AVX2 0 "register_operand")
11905    (match_operand:VEC_PERM_AVX2 1 "register_operand")
11906    (match_operand:VEC_PERM_AVX2 2 "register_operand")
11907    (match_operand:<sseintvecmode> 3 "register_operand")]
11908   "TARGET_SSSE3 || TARGET_AVX || TARGET_XOP"
11910   ix86_expand_vec_perm (operands);
11911   DONE;
11914 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11916 ;; Parallel bitwise logical operations
11918 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11920 (define_expand "one_cmpl<mode>2"
11921   [(set (match_operand:VI 0 "register_operand")
11922         (xor:VI (match_operand:VI 1 "vector_operand")
11923                 (match_dup 2)))]
11924   "TARGET_SSE"
11926   operands[2] = force_reg (<MODE>mode, CONSTM1_RTX (<MODE>mode));
11929 (define_expand "<sse2_avx2>_andnot<mode>3"
11930   [(set (match_operand:VI_AVX2 0 "register_operand")
11931         (and:VI_AVX2
11932           (not:VI_AVX2 (match_operand:VI_AVX2 1 "register_operand"))
11933           (match_operand:VI_AVX2 2 "vector_operand")))]
11934   "TARGET_SSE2")
11936 (define_expand "<sse2_avx2>_andnot<mode>3_mask"
11937   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
11938         (vec_merge:VI48_AVX512VL
11939           (and:VI48_AVX512VL
11940             (not:VI48_AVX512VL
11941               (match_operand:VI48_AVX512VL 1 "register_operand"))
11942             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
11943           (match_operand:VI48_AVX512VL 3 "nonimm_or_0_operand")
11944           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
11945   "TARGET_AVX512F")
11947 (define_expand "<sse2_avx2>_andnot<mode>3_mask"
11948   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
11949         (vec_merge:VI12_AVX512VL
11950           (and:VI12_AVX512VL
11951             (not:VI12_AVX512VL
11952               (match_operand:VI12_AVX512VL 1 "register_operand"))
11953             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand"))
11954           (match_operand:VI12_AVX512VL 3 "nonimm_or_0_operand")
11955           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
11956   "TARGET_AVX512BW")
11958 (define_insn "*andnot<mode>3"
11959   [(set (match_operand:VI 0 "register_operand" "=x,x,v")
11960         (and:VI
11961           (not:VI (match_operand:VI 1 "register_operand" "0,x,v"))
11962           (match_operand:VI 2 "vector_operand" "xBm,xm,vm")))]
11963   "TARGET_SSE"
11965   static char buf[64];
11966   const char *ops;
11967   const char *tmp;
11968   const char *ssesuffix;
11970   switch (get_attr_mode (insn))
11971     {
11972     case MODE_XI:
11973       gcc_assert (TARGET_AVX512F);
11974       /* FALLTHRU */
11975     case MODE_OI:
11976       gcc_assert (TARGET_AVX2);
11977       /* FALLTHRU */
11978     case MODE_TI:
11979       gcc_assert (TARGET_SSE2);
11980       tmp = "pandn";
11981       switch (<MODE>mode)
11982         {
11983         case E_V64QImode:
11984         case E_V32HImode:
11985           /* There is no vpandnb or vpandnw instruction, nor vpandn for
11986              512-bit vectors. Use vpandnq instead.  */
11987           ssesuffix = "q";
11988           break;
11989         case E_V16SImode:
11990         case E_V8DImode:
11991           ssesuffix = "<ssemodesuffix>";
11992           break;
11993         case E_V8SImode:
11994         case E_V4DImode:
11995         case E_V4SImode:
11996         case E_V2DImode:
11997           ssesuffix = (TARGET_AVX512VL && which_alternative == 2
11998                        ? "<ssemodesuffix>" : "");
11999           break;
12000         default:
12001           ssesuffix = TARGET_AVX512VL && which_alternative == 2 ? "q" : "";
12002         }
12003       break;
12005     case MODE_V16SF:
12006       gcc_assert (TARGET_AVX512F);
12007       /* FALLTHRU */
12008     case MODE_V8SF:
12009       gcc_assert (TARGET_AVX);
12010       /* FALLTHRU */
12011     case MODE_V4SF:
12012       gcc_assert (TARGET_SSE);
12013       tmp = "andn";
12014       ssesuffix = "ps";
12015       break;
12017     default:
12018       gcc_unreachable ();
12019     }
12021   switch (which_alternative)
12022     {
12023     case 0:
12024       ops = "%s%s\t{%%2, %%0|%%0, %%2}";
12025       break;
12026     case 1:
12027     case 2:
12028       ops = "v%s%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
12029       break;
12030     default:
12031       gcc_unreachable ();
12032     }
12034   snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
12035   return buf;
12037   [(set_attr "isa" "noavx,avx,avx")
12038    (set_attr "type" "sselog")
12039    (set (attr "prefix_data16")
12040      (if_then_else
12041        (and (eq_attr "alternative" "0")
12042             (eq_attr "mode" "TI"))
12043        (const_string "1")
12044        (const_string "*")))
12045    (set_attr "prefix" "orig,vex,evex")
12046    (set (attr "mode")
12047         (cond [(and (match_test "<MODE_SIZE> == 16")
12048                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
12049                  (const_string "<ssePSmode>")
12050                (match_test "TARGET_AVX2")
12051                  (const_string "<sseinsnmode>")
12052                (match_test "TARGET_AVX")
12053                  (if_then_else
12054                    (match_test "<MODE_SIZE> > 16")
12055                    (const_string "V8SF")
12056                    (const_string "<sseinsnmode>"))
12057                (ior (not (match_test "TARGET_SSE2"))
12058                     (match_test "optimize_function_for_size_p (cfun)"))
12059                  (const_string "V4SF")
12060               ]
12061               (const_string "<sseinsnmode>")))])
12063 (define_insn "*andnot<mode>3_bcst"
12064   [(set (match_operand:VI 0 "register_operand" "=v")
12065         (and:VI
12066           (not:VI48_AVX512VL
12067              (match_operand:VI48_AVX512VL 1 "register_operand" "v"))
12068           (vec_duplicate:VI48_AVX512VL
12069             (match_operand:<ssescalarmode> 2 "memory_operand" "m"))))]
12070   "TARGET_AVX512F"
12071   "vpandn<ssemodesuffix>\t{%2<avx512bcst>, %1, %0|%0, %1, %2<avx512bcst>}"
12072   [(set_attr "type" "sselog")
12073    (set_attr "prefix" "evex")
12074    (set_attr "mode" "<sseinsnmode>")])
12076 (define_insn "*andnot<mode>3_mask"
12077   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
12078         (vec_merge:VI48_AVX512VL
12079           (and:VI48_AVX512VL
12080             (not:VI48_AVX512VL
12081               (match_operand:VI48_AVX512VL 1 "register_operand" "v"))
12082             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm"))
12083           (match_operand:VI48_AVX512VL 3 "nonimm_or_0_operand" "0C")
12084           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
12085   "TARGET_AVX512F"
12086   "vpandn<ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}";
12087   [(set_attr "type" "sselog")
12088    (set_attr "prefix" "evex")
12089    (set_attr "mode" "<sseinsnmode>")])
12091 (define_expand "<code><mode>3"
12092   [(set (match_operand:VI 0 "register_operand")
12093         (any_logic:VI
12094           (match_operand:VI 1 "nonimmediate_or_const_vector_operand")
12095           (match_operand:VI 2 "nonimmediate_or_const_vector_operand")))]
12096   "TARGET_SSE"
12098   ix86_expand_vector_logical_operator (<CODE>, <MODE>mode, operands);
12099   DONE;
12102 (define_insn "<mask_codefor><code><mode>3<mask_name>"
12103   [(set (match_operand:VI48_AVX_AVX512F 0 "register_operand" "=x,x,v")
12104         (any_logic:VI48_AVX_AVX512F
12105           (match_operand:VI48_AVX_AVX512F 1 "vector_operand" "%0,x,v")
12106           (match_operand:VI48_AVX_AVX512F 2 "vector_operand" "xBm,xm,vm")))]
12107   "TARGET_SSE && <mask_mode512bit_condition>
12108    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
12110   static char buf[64];
12111   const char *ops;
12112   const char *tmp;
12113   const char *ssesuffix;
12115   switch (get_attr_mode (insn))
12116     {
12117     case MODE_XI:
12118       gcc_assert (TARGET_AVX512F);
12119       /* FALLTHRU */
12120     case MODE_OI:
12121       gcc_assert (TARGET_AVX2);
12122       /* FALLTHRU */
12123     case MODE_TI:
12124       gcc_assert (TARGET_SSE2);
12125       tmp = "p<logic>";
12126       switch (<MODE>mode)
12127         {
12128         case E_V16SImode:
12129         case E_V8DImode:
12130           ssesuffix = "<ssemodesuffix>";
12131           break;
12132         case E_V8SImode:
12133         case E_V4DImode:
12134         case E_V4SImode:
12135         case E_V2DImode:
12136           ssesuffix = (TARGET_AVX512VL
12137                        && (<mask_applied> || which_alternative == 2)
12138                        ? "<ssemodesuffix>" : "");
12139           break;
12140         default:
12141           gcc_unreachable ();
12142         }
12143       break;
12145     case MODE_V8SF:
12146       gcc_assert (TARGET_AVX);
12147       /* FALLTHRU */
12148     case MODE_V4SF:
12149       gcc_assert (TARGET_SSE);
12150       tmp = "<logic>";
12151       ssesuffix = "ps";
12152       break;
12154     default:
12155       gcc_unreachable ();
12156     }
12158   switch (which_alternative)
12159     {
12160     case 0:
12161       if (<mask_applied>)
12162         ops = "v%s%s\t{%%2, %%0, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%0, %%2}";
12163       else
12164         ops = "%s%s\t{%%2, %%0|%%0, %%2}";
12165       break;
12166     case 1:
12167     case 2:
12168       ops = "v%s%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
12169       break;
12170     default:
12171       gcc_unreachable ();
12172     }
12174   snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
12175   return buf;
12177   [(set_attr "isa" "noavx,avx,avx")
12178    (set_attr "type" "sselog")
12179    (set (attr "prefix_data16")
12180      (if_then_else
12181        (and (eq_attr "alternative" "0")
12182             (eq_attr "mode" "TI"))
12183        (const_string "1")
12184        (const_string "*")))
12185    (set_attr "prefix" "<mask_prefix3>,evex")
12186    (set (attr "mode")
12187         (cond [(and (match_test "<MODE_SIZE> == 16")
12188                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
12189                  (const_string "<ssePSmode>")
12190                (match_test "TARGET_AVX2")
12191                  (const_string "<sseinsnmode>")
12192                (match_test "TARGET_AVX")
12193                  (if_then_else
12194                    (match_test "<MODE_SIZE> > 16")
12195                    (const_string "V8SF")
12196                    (const_string "<sseinsnmode>"))
12197                (ior (not (match_test "TARGET_SSE2"))
12198                     (match_test "optimize_function_for_size_p (cfun)"))
12199                  (const_string "V4SF")
12200               ]
12201               (const_string "<sseinsnmode>")))])
12203 (define_insn "*<code><mode>3"
12204   [(set (match_operand:VI12_AVX_AVX512F 0 "register_operand" "=x,x,v")
12205         (any_logic:VI12_AVX_AVX512F
12206           (match_operand:VI12_AVX_AVX512F 1 "vector_operand" "%0,x,v")
12207           (match_operand:VI12_AVX_AVX512F 2 "vector_operand" "xBm,xm,vm")))]
12208   "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
12210   static char buf[64];
12211   const char *ops;
12212   const char *tmp;
12213   const char *ssesuffix;
12215   switch (get_attr_mode (insn))
12216     {
12217     case MODE_XI:
12218       gcc_assert (TARGET_AVX512F);
12219       /* FALLTHRU */
12220     case MODE_OI:
12221       gcc_assert (TARGET_AVX2);
12222       /* FALLTHRU */
12223     case MODE_TI:
12224       gcc_assert (TARGET_SSE2);
12225       tmp = "p<logic>";
12226       switch (<MODE>mode)
12227         {
12228         case E_V64QImode:
12229         case E_V32HImode:
12230           ssesuffix = "q";
12231           break;
12232         case E_V32QImode:
12233         case E_V16HImode:
12234         case E_V16QImode:
12235         case E_V8HImode:
12236           ssesuffix = TARGET_AVX512VL && which_alternative == 2 ? "q" : "";
12237           break;
12238         default:
12239           gcc_unreachable ();
12240         }
12241       break;
12243     case MODE_V8SF:
12244       gcc_assert (TARGET_AVX);
12245       /* FALLTHRU */
12246     case MODE_V4SF:
12247       gcc_assert (TARGET_SSE);
12248       tmp = "<logic>";
12249       ssesuffix = "ps";
12250       break;
12252     default:
12253       gcc_unreachable ();
12254     }
12256   switch (which_alternative)
12257     {
12258     case 0:
12259       ops = "%s%s\t{%%2, %%0|%%0, %%2}";
12260       break;
12261     case 1:
12262     case 2:
12263       ops = "v%s%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
12264       break;
12265     default:
12266       gcc_unreachable ();
12267     }
12269   snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
12270   return buf;
12272   [(set_attr "isa" "noavx,avx,avx")
12273    (set_attr "type" "sselog")
12274    (set (attr "prefix_data16")
12275      (if_then_else
12276        (and (eq_attr "alternative" "0")
12277             (eq_attr "mode" "TI"))
12278        (const_string "1")
12279        (const_string "*")))
12280    (set_attr "prefix" "orig,vex,evex")
12281    (set (attr "mode")
12282         (cond [(and (match_test "<MODE_SIZE> == 16")
12283                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
12284                  (const_string "<ssePSmode>")
12285                (match_test "TARGET_AVX2")
12286                  (const_string "<sseinsnmode>")
12287                (match_test "TARGET_AVX")
12288                  (if_then_else
12289                    (match_test "<MODE_SIZE> > 16")
12290                    (const_string "V8SF")
12291                    (const_string "<sseinsnmode>"))
12292                (ior (not (match_test "TARGET_SSE2"))
12293                     (match_test "optimize_function_for_size_p (cfun)"))
12294                  (const_string "V4SF")
12295               ]
12296               (const_string "<sseinsnmode>")))])
12298 (define_insn "*<code><mode>3_bcst"
12299   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
12300         (any_logic:VI48_AVX512VL
12301           (vec_duplicate:VI48_AVX512VL
12302             (match_operand:<ssescalarmode> 1 "memory_operand" "m"))
12303           (match_operand:VI48_AVX512VL 2 "register_operand" "v")))]
12304   "TARGET_AVX512F && <mask_avx512vl_condition>"
12305   "vp<logic><ssemodesuffix>\t{%1<avx512bcst>, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1<avx512bcst>}"
12306   [(set_attr "type" "sseiadd")
12307    (set_attr "prefix" "evex")
12308    (set_attr "mode" "<sseinsnmode>")])
12310 (define_insn "<avx512>_testm<mode>3<mask_scalar_merge_name>"
12311   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
12312         (unspec:<avx512fmaskmode>
12313          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
12314           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")]
12315          UNSPEC_TESTM))]
12316   "TARGET_AVX512BW"
12317   "vptestm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
12318   [(set_attr "prefix" "evex")
12319    (set_attr "mode"  "<sseinsnmode>")])
12321 (define_insn "<avx512>_testm<mode>3<mask_scalar_merge_name>"
12322   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
12323         (unspec:<avx512fmaskmode>
12324          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
12325           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")]
12326          UNSPEC_TESTM))]
12327   "TARGET_AVX512F"
12328   "vptestm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
12329   [(set_attr "prefix" "evex")
12330    (set_attr "mode"  "<sseinsnmode>")])
12332 (define_insn "<avx512>_testnm<mode>3<mask_scalar_merge_name>"
12333   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
12334         (unspec:<avx512fmaskmode>
12335          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
12336           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")]
12337          UNSPEC_TESTNM))]
12338   "TARGET_AVX512BW"
12339   "vptestnm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
12340   [(set_attr "prefix" "evex")
12341    (set_attr "mode"  "<sseinsnmode>")])
12343 (define_insn "<avx512>_testnm<mode>3<mask_scalar_merge_name>"
12344   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
12345         (unspec:<avx512fmaskmode>
12346          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
12347           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")]
12348          UNSPEC_TESTNM))]
12349   "TARGET_AVX512F"
12350   "vptestnm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
12351   [(set_attr "prefix" "evex")
12352    (set_attr "mode"  "<sseinsnmode>")])
12354 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12356 ;; Parallel integral element swizzling
12358 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12360 (define_expand "vec_pack_trunc_<mode>"
12361   [(match_operand:<ssepackmode> 0 "register_operand")
12362    (match_operand:VI248_AVX2_8_AVX512F_24_AVX512BW 1 "register_operand")
12363    (match_operand:VI248_AVX2_8_AVX512F_24_AVX512BW 2 "register_operand")]
12364   "TARGET_SSE2"
12366   rtx op1 = gen_lowpart (<ssepackmode>mode, operands[1]);
12367   rtx op2 = gen_lowpart (<ssepackmode>mode, operands[2]);
12368   ix86_expand_vec_extract_even_odd (operands[0], op1, op2, 0);
12369   DONE;
12372 (define_expand "vec_pack_trunc_qi"
12373   [(set (match_operand:HI 0 ("register_operand"))
12374         (ior:HI (ashift:HI (zero_extend:HI (match_operand:QI 2 ("register_operand")))
12375                            (const_int 8))
12376                 (zero_extend:HI (match_operand:QI 1 ("register_operand")))))]
12377   "TARGET_AVX512F")
12379 (define_expand "vec_pack_trunc_<mode>"
12380   [(set (match_operand:<DOUBLEMASKMODE> 0 ("register_operand"))
12381         (ior:<DOUBLEMASKMODE> (ashift:<DOUBLEMASKMODE> (zero_extend:<DOUBLEMASKMODE> (match_operand:SWI24 2 ("register_operand")))
12382                            (match_dup 3))
12383                 (zero_extend:<DOUBLEMASKMODE> (match_operand:SWI24 1 ("register_operand")))))]
12384   "TARGET_AVX512BW"
12386   operands[3] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
12389 (define_insn "<sse2_avx2>_packsswb<mask_name>"
12390   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x,v")
12391         (vec_concat:VI1_AVX512
12392           (ss_truncate:<ssehalfvecmode>
12393             (match_operand:<sseunpackmode> 1 "register_operand" "0,x,v"))
12394           (ss_truncate:<ssehalfvecmode>
12395             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,xm,vm"))))]
12396   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
12397   "@
12398    packsswb\t{%2, %0|%0, %2}
12399    vpacksswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
12400    vpacksswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12401   [(set_attr "isa" "noavx,avx,avx512bw")
12402    (set_attr "type" "sselog")
12403    (set_attr "prefix_data16" "1,*,*")
12404    (set_attr "prefix" "orig,<mask_prefix>,evex")
12405    (set_attr "mode" "<sseinsnmode>")])
12407 (define_insn "<sse2_avx2>_packssdw<mask_name>"
12408   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,x,v")
12409         (vec_concat:VI2_AVX2
12410           (ss_truncate:<ssehalfvecmode>
12411             (match_operand:<sseunpackmode> 1 "register_operand" "0,x,v"))
12412           (ss_truncate:<ssehalfvecmode>
12413             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,xm,vm"))))]
12414   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
12415   "@
12416    packssdw\t{%2, %0|%0, %2}
12417    vpackssdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
12418    vpackssdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12419   [(set_attr "isa" "noavx,avx,avx512bw")
12420    (set_attr "type" "sselog")
12421    (set_attr "prefix_data16" "1,*,*")
12422    (set_attr "prefix" "orig,<mask_prefix>,evex")
12423    (set_attr "mode" "<sseinsnmode>")])
12425 (define_insn "<sse2_avx2>_packuswb<mask_name>"
12426   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x,v")
12427         (vec_concat:VI1_AVX512
12428           (us_truncate:<ssehalfvecmode>
12429             (match_operand:<sseunpackmode> 1 "register_operand" "0,x,v"))
12430           (us_truncate:<ssehalfvecmode>
12431             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,xm,vm"))))]
12432   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
12433   "@
12434    packuswb\t{%2, %0|%0, %2}
12435    vpackuswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
12436    vpackuswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12437   [(set_attr "isa" "noavx,avx,avx512bw")
12438    (set_attr "type" "sselog")
12439    (set_attr "prefix_data16" "1,*,*")
12440    (set_attr "prefix" "orig,<mask_prefix>,evex")
12441    (set_attr "mode" "<sseinsnmode>")])
12443 (define_insn "avx512bw_interleave_highv64qi<mask_name>"
12444   [(set (match_operand:V64QI 0 "register_operand" "=v")
12445         (vec_select:V64QI
12446           (vec_concat:V128QI
12447             (match_operand:V64QI 1 "register_operand" "v")
12448             (match_operand:V64QI 2 "nonimmediate_operand" "vm"))
12449           (parallel [(const_int 8)  (const_int 72)
12450                      (const_int 9)  (const_int 73)
12451                      (const_int 10) (const_int 74)
12452                      (const_int 11) (const_int 75)
12453                      (const_int 12) (const_int 76)
12454                      (const_int 13) (const_int 77)
12455                      (const_int 14) (const_int 78)
12456                      (const_int 15) (const_int 79)
12457                      (const_int 24) (const_int 88)
12458                      (const_int 25) (const_int 89)
12459                      (const_int 26) (const_int 90)
12460                      (const_int 27) (const_int 91)
12461                      (const_int 28) (const_int 92)
12462                      (const_int 29) (const_int 93)
12463                      (const_int 30) (const_int 94)
12464                      (const_int 31) (const_int 95)
12465                      (const_int 40) (const_int 104)
12466                      (const_int 41) (const_int 105)
12467                      (const_int 42) (const_int 106)
12468                      (const_int 43) (const_int 107)
12469                      (const_int 44) (const_int 108)
12470                      (const_int 45) (const_int 109)
12471                      (const_int 46) (const_int 110)
12472                      (const_int 47) (const_int 111)
12473                      (const_int 56) (const_int 120)
12474                      (const_int 57) (const_int 121)
12475                      (const_int 58) (const_int 122)
12476                      (const_int 59) (const_int 123)
12477                      (const_int 60) (const_int 124)
12478                      (const_int 61) (const_int 125)
12479                      (const_int 62) (const_int 126)
12480                      (const_int 63) (const_int 127)])))]
12481   "TARGET_AVX512BW"
12482   "vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12483   [(set_attr "type" "sselog")
12484    (set_attr "prefix" "evex")
12485    (set_attr "mode" "XI")])
12487 (define_insn "avx2_interleave_highv32qi<mask_name>"
12488   [(set (match_operand:V32QI 0 "register_operand" "=v")
12489         (vec_select:V32QI
12490           (vec_concat:V64QI
12491             (match_operand:V32QI 1 "register_operand" "v")
12492             (match_operand:V32QI 2 "nonimmediate_operand" "vm"))
12493           (parallel [(const_int 8)  (const_int 40)
12494                      (const_int 9)  (const_int 41)
12495                      (const_int 10) (const_int 42)
12496                      (const_int 11) (const_int 43)
12497                      (const_int 12) (const_int 44)
12498                      (const_int 13) (const_int 45)
12499                      (const_int 14) (const_int 46)
12500                      (const_int 15) (const_int 47)
12501                      (const_int 24) (const_int 56)
12502                      (const_int 25) (const_int 57)
12503                      (const_int 26) (const_int 58)
12504                      (const_int 27) (const_int 59)
12505                      (const_int 28) (const_int 60)
12506                      (const_int 29) (const_int 61)
12507                      (const_int 30) (const_int 62)
12508                      (const_int 31) (const_int 63)])))]
12509   "TARGET_AVX2 && <mask_avx512vl_condition>"
12510   "vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12511   [(set_attr "type" "sselog")
12512    (set_attr "prefix" "<mask_prefix>")
12513    (set_attr "mode" "OI")])
12515 (define_insn "vec_interleave_highv16qi<mask_name>"
12516   [(set (match_operand:V16QI 0 "register_operand" "=x,v")
12517         (vec_select:V16QI
12518           (vec_concat:V32QI
12519             (match_operand:V16QI 1 "register_operand" "0,v")
12520             (match_operand:V16QI 2 "vector_operand" "xBm,vm"))
12521           (parallel [(const_int 8)  (const_int 24)
12522                      (const_int 9)  (const_int 25)
12523                      (const_int 10) (const_int 26)
12524                      (const_int 11) (const_int 27)
12525                      (const_int 12) (const_int 28)
12526                      (const_int 13) (const_int 29)
12527                      (const_int 14) (const_int 30)
12528                      (const_int 15) (const_int 31)])))]
12529   "TARGET_SSE2 && <mask_avx512vl_condition>"
12530   "@
12531    punpckhbw\t{%2, %0|%0, %2}
12532    vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12533   [(set_attr "isa" "noavx,avx")
12534    (set_attr "type" "sselog")
12535    (set_attr "prefix_data16" "1,*")
12536    (set_attr "prefix" "orig,<mask_prefix>")
12537    (set_attr "mode" "TI")])
12539 (define_insn "avx512bw_interleave_lowv64qi<mask_name>"
12540   [(set (match_operand:V64QI 0 "register_operand" "=v")
12541         (vec_select:V64QI
12542           (vec_concat:V128QI
12543             (match_operand:V64QI 1 "register_operand" "v")
12544             (match_operand:V64QI 2 "nonimmediate_operand" "vm"))
12545           (parallel [(const_int 0) (const_int 64)
12546                      (const_int 1) (const_int 65)
12547                      (const_int 2) (const_int 66)
12548                      (const_int 3) (const_int 67)
12549                      (const_int 4) (const_int 68)
12550                      (const_int 5) (const_int 69)
12551                      (const_int 6) (const_int 70)
12552                      (const_int 7) (const_int 71)
12553                      (const_int 16) (const_int 80)
12554                      (const_int 17) (const_int 81)
12555                      (const_int 18) (const_int 82)
12556                      (const_int 19) (const_int 83)
12557                      (const_int 20) (const_int 84)
12558                      (const_int 21) (const_int 85)
12559                      (const_int 22) (const_int 86)
12560                      (const_int 23) (const_int 87)
12561                      (const_int 32) (const_int 96)
12562                      (const_int 33) (const_int 97)
12563                      (const_int 34) (const_int 98)
12564                      (const_int 35) (const_int 99)
12565                      (const_int 36) (const_int 100)
12566                      (const_int 37) (const_int 101)
12567                      (const_int 38) (const_int 102)
12568                      (const_int 39) (const_int 103)
12569                      (const_int 48) (const_int 112)
12570                      (const_int 49) (const_int 113)
12571                      (const_int 50) (const_int 114)
12572                      (const_int 51) (const_int 115)
12573                      (const_int 52) (const_int 116)
12574                      (const_int 53) (const_int 117)
12575                      (const_int 54) (const_int 118)
12576                      (const_int 55) (const_int 119)])))]
12577   "TARGET_AVX512BW"
12578   "vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12579   [(set_attr "type" "sselog")
12580    (set_attr "prefix" "evex")
12581    (set_attr "mode" "XI")])
12583 (define_insn "avx2_interleave_lowv32qi<mask_name>"
12584   [(set (match_operand:V32QI 0 "register_operand" "=v")
12585         (vec_select:V32QI
12586           (vec_concat:V64QI
12587             (match_operand:V32QI 1 "register_operand" "v")
12588             (match_operand:V32QI 2 "nonimmediate_operand" "vm"))
12589           (parallel [(const_int 0) (const_int 32)
12590                      (const_int 1) (const_int 33)
12591                      (const_int 2) (const_int 34)
12592                      (const_int 3) (const_int 35)
12593                      (const_int 4) (const_int 36)
12594                      (const_int 5) (const_int 37)
12595                      (const_int 6) (const_int 38)
12596                      (const_int 7) (const_int 39)
12597                      (const_int 16) (const_int 48)
12598                      (const_int 17) (const_int 49)
12599                      (const_int 18) (const_int 50)
12600                      (const_int 19) (const_int 51)
12601                      (const_int 20) (const_int 52)
12602                      (const_int 21) (const_int 53)
12603                      (const_int 22) (const_int 54)
12604                      (const_int 23) (const_int 55)])))]
12605   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12606   "vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12607   [(set_attr "type" "sselog")
12608    (set_attr "prefix" "maybe_vex")
12609    (set_attr "mode" "OI")])
12611 (define_insn "vec_interleave_lowv16qi<mask_name>"
12612   [(set (match_operand:V16QI 0 "register_operand" "=x,v")
12613         (vec_select:V16QI
12614           (vec_concat:V32QI
12615             (match_operand:V16QI 1 "register_operand" "0,v")
12616             (match_operand:V16QI 2 "vector_operand" "xBm,vm"))
12617           (parallel [(const_int 0) (const_int 16)
12618                      (const_int 1) (const_int 17)
12619                      (const_int 2) (const_int 18)
12620                      (const_int 3) (const_int 19)
12621                      (const_int 4) (const_int 20)
12622                      (const_int 5) (const_int 21)
12623                      (const_int 6) (const_int 22)
12624                      (const_int 7) (const_int 23)])))]
12625   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12626   "@
12627    punpcklbw\t{%2, %0|%0, %2}
12628    vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12629   [(set_attr "isa" "noavx,avx")
12630    (set_attr "type" "sselog")
12631    (set_attr "prefix_data16" "1,*")
12632    (set_attr "prefix" "orig,vex")
12633    (set_attr "mode" "TI")])
12635 (define_insn "avx512bw_interleave_highv32hi<mask_name>"
12636   [(set (match_operand:V32HI 0 "register_operand" "=v")
12637         (vec_select:V32HI
12638           (vec_concat:V64HI
12639             (match_operand:V32HI 1 "register_operand" "v")
12640             (match_operand:V32HI 2 "nonimmediate_operand" "vm"))
12641           (parallel [(const_int 4) (const_int 36)
12642                      (const_int 5) (const_int 37)
12643                      (const_int 6) (const_int 38)
12644                      (const_int 7) (const_int 39)
12645                      (const_int 12) (const_int 44)
12646                      (const_int 13) (const_int 45)
12647                      (const_int 14) (const_int 46)
12648                      (const_int 15) (const_int 47)
12649                      (const_int 20) (const_int 52)
12650                      (const_int 21) (const_int 53)
12651                      (const_int 22) (const_int 54)
12652                      (const_int 23) (const_int 55)
12653                      (const_int 28) (const_int 60)
12654                      (const_int 29) (const_int 61)
12655                      (const_int 30) (const_int 62)
12656                      (const_int 31) (const_int 63)])))]
12657   "TARGET_AVX512BW"
12658   "vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12659   [(set_attr "type" "sselog")
12660    (set_attr "prefix" "evex")
12661    (set_attr "mode" "XI")])
12663 (define_insn "avx2_interleave_highv16hi<mask_name>"
12664   [(set (match_operand:V16HI 0 "register_operand" "=v")
12665         (vec_select:V16HI
12666           (vec_concat:V32HI
12667             (match_operand:V16HI 1 "register_operand" "v")
12668             (match_operand:V16HI 2 "nonimmediate_operand" "vm"))
12669           (parallel [(const_int 4) (const_int 20)
12670                      (const_int 5) (const_int 21)
12671                      (const_int 6) (const_int 22)
12672                      (const_int 7) (const_int 23)
12673                      (const_int 12) (const_int 28)
12674                      (const_int 13) (const_int 29)
12675                      (const_int 14) (const_int 30)
12676                      (const_int 15) (const_int 31)])))]
12677   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12678   "vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12679   [(set_attr "type" "sselog")
12680    (set_attr "prefix" "maybe_evex")
12681    (set_attr "mode" "OI")])
12683 (define_insn "vec_interleave_highv8hi<mask_name>"
12684   [(set (match_operand:V8HI 0 "register_operand" "=x,v")
12685         (vec_select:V8HI
12686           (vec_concat:V16HI
12687             (match_operand:V8HI 1 "register_operand" "0,v")
12688             (match_operand:V8HI 2 "vector_operand" "xBm,vm"))
12689           (parallel [(const_int 4) (const_int 12)
12690                      (const_int 5) (const_int 13)
12691                      (const_int 6) (const_int 14)
12692                      (const_int 7) (const_int 15)])))]
12693   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12694   "@
12695    punpckhwd\t{%2, %0|%0, %2}
12696    vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12697   [(set_attr "isa" "noavx,avx")
12698    (set_attr "type" "sselog")
12699    (set_attr "prefix_data16" "1,*")
12700    (set_attr "prefix" "orig,maybe_vex")
12701    (set_attr "mode" "TI")])
12703 (define_insn "<mask_codefor>avx512bw_interleave_lowv32hi<mask_name>"
12704   [(set (match_operand:V32HI 0 "register_operand" "=v")
12705         (vec_select:V32HI
12706           (vec_concat:V64HI
12707             (match_operand:V32HI 1 "register_operand" "v")
12708             (match_operand:V32HI 2 "nonimmediate_operand" "vm"))
12709           (parallel [(const_int 0) (const_int 32)
12710                      (const_int 1) (const_int 33)
12711                      (const_int 2) (const_int 34)
12712                      (const_int 3) (const_int 35)
12713                      (const_int 8) (const_int 40)
12714                      (const_int 9) (const_int 41)
12715                      (const_int 10) (const_int 42)
12716                      (const_int 11) (const_int 43)
12717                      (const_int 16) (const_int 48)
12718                      (const_int 17) (const_int 49)
12719                      (const_int 18) (const_int 50)
12720                      (const_int 19) (const_int 51)
12721                      (const_int 24) (const_int 56)
12722                      (const_int 25) (const_int 57)
12723                      (const_int 26) (const_int 58)
12724                      (const_int 27) (const_int 59)])))]
12725   "TARGET_AVX512BW"
12726   "vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12727   [(set_attr "type" "sselog")
12728    (set_attr "prefix" "evex")
12729    (set_attr "mode" "XI")])
12731 (define_insn "avx2_interleave_lowv16hi<mask_name>"
12732   [(set (match_operand:V16HI 0 "register_operand" "=v")
12733         (vec_select:V16HI
12734           (vec_concat:V32HI
12735             (match_operand:V16HI 1 "register_operand" "v")
12736             (match_operand:V16HI 2 "nonimmediate_operand" "vm"))
12737           (parallel [(const_int 0) (const_int 16)
12738                      (const_int 1) (const_int 17)
12739                      (const_int 2) (const_int 18)
12740                      (const_int 3) (const_int 19)
12741                      (const_int 8) (const_int 24)
12742                      (const_int 9) (const_int 25)
12743                      (const_int 10) (const_int 26)
12744                      (const_int 11) (const_int 27)])))]
12745   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12746   "vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12747   [(set_attr "type" "sselog")
12748    (set_attr "prefix" "maybe_evex")
12749    (set_attr "mode" "OI")])
12751 (define_insn "vec_interleave_lowv8hi<mask_name>"
12752   [(set (match_operand:V8HI 0 "register_operand" "=x,v")
12753         (vec_select:V8HI
12754           (vec_concat:V16HI
12755             (match_operand:V8HI 1 "register_operand" "0,v")
12756             (match_operand:V8HI 2 "vector_operand" "xBm,vm"))
12757           (parallel [(const_int 0) (const_int 8)
12758                      (const_int 1) (const_int 9)
12759                      (const_int 2) (const_int 10)
12760                      (const_int 3) (const_int 11)])))]
12761   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12762   "@
12763    punpcklwd\t{%2, %0|%0, %2}
12764    vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12765   [(set_attr "isa" "noavx,avx")
12766    (set_attr "type" "sselog")
12767    (set_attr "prefix_data16" "1,*")
12768    (set_attr "prefix" "orig,maybe_evex")
12769    (set_attr "mode" "TI")])
12771 (define_insn "avx2_interleave_highv8si<mask_name>"
12772   [(set (match_operand:V8SI 0 "register_operand" "=v")
12773         (vec_select:V8SI
12774           (vec_concat:V16SI
12775             (match_operand:V8SI 1 "register_operand" "v")
12776             (match_operand:V8SI 2 "nonimmediate_operand" "vm"))
12777           (parallel [(const_int 2) (const_int 10)
12778                      (const_int 3) (const_int 11)
12779                      (const_int 6) (const_int 14)
12780                      (const_int 7) (const_int 15)])))]
12781   "TARGET_AVX2 && <mask_avx512vl_condition>"
12782   "vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12783   [(set_attr "type" "sselog")
12784    (set_attr "prefix" "maybe_evex")
12785    (set_attr "mode" "OI")])
12787 (define_insn "<mask_codefor>avx512f_interleave_highv16si<mask_name>"
12788   [(set (match_operand:V16SI 0 "register_operand" "=v")
12789         (vec_select:V16SI
12790           (vec_concat:V32SI
12791             (match_operand:V16SI 1 "register_operand" "v")
12792             (match_operand:V16SI 2 "nonimmediate_operand" "vm"))
12793           (parallel [(const_int 2) (const_int 18)
12794                      (const_int 3) (const_int 19)
12795                      (const_int 6) (const_int 22)
12796                      (const_int 7) (const_int 23)
12797                      (const_int 10) (const_int 26)
12798                      (const_int 11) (const_int 27)
12799                      (const_int 14) (const_int 30)
12800                      (const_int 15) (const_int 31)])))]
12801   "TARGET_AVX512F"
12802   "vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12803   [(set_attr "type" "sselog")
12804    (set_attr "prefix" "evex")
12805    (set_attr "mode" "XI")])
12808 (define_insn "vec_interleave_highv4si<mask_name>"
12809   [(set (match_operand:V4SI 0 "register_operand" "=x,v")
12810         (vec_select:V4SI
12811           (vec_concat:V8SI
12812             (match_operand:V4SI 1 "register_operand" "0,v")
12813             (match_operand:V4SI 2 "vector_operand" "xBm,vm"))
12814           (parallel [(const_int 2) (const_int 6)
12815                      (const_int 3) (const_int 7)])))]
12816   "TARGET_SSE2 && <mask_avx512vl_condition>"
12817   "@
12818    punpckhdq\t{%2, %0|%0, %2}
12819    vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12820   [(set_attr "isa" "noavx,avx")
12821    (set_attr "type" "sselog")
12822    (set_attr "prefix_data16" "1,*")
12823    (set_attr "prefix" "orig,maybe_vex")
12824    (set_attr "mode" "TI")])
12826 (define_insn "avx2_interleave_lowv8si<mask_name>"
12827   [(set (match_operand:V8SI 0 "register_operand" "=v")
12828         (vec_select:V8SI
12829           (vec_concat:V16SI
12830             (match_operand:V8SI 1 "register_operand" "v")
12831             (match_operand:V8SI 2 "nonimmediate_operand" "vm"))
12832           (parallel [(const_int 0) (const_int 8)
12833                      (const_int 1) (const_int 9)
12834                      (const_int 4) (const_int 12)
12835                      (const_int 5) (const_int 13)])))]
12836   "TARGET_AVX2 && <mask_avx512vl_condition>"
12837   "vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12838   [(set_attr "type" "sselog")
12839    (set_attr "prefix" "maybe_evex")
12840    (set_attr "mode" "OI")])
12842 (define_insn "<mask_codefor>avx512f_interleave_lowv16si<mask_name>"
12843   [(set (match_operand:V16SI 0 "register_operand" "=v")
12844         (vec_select:V16SI
12845           (vec_concat:V32SI
12846             (match_operand:V16SI 1 "register_operand" "v")
12847             (match_operand:V16SI 2 "nonimmediate_operand" "vm"))
12848           (parallel [(const_int 0) (const_int 16)
12849                      (const_int 1) (const_int 17)
12850                      (const_int 4) (const_int 20)
12851                      (const_int 5) (const_int 21)
12852                      (const_int 8) (const_int 24)
12853                      (const_int 9) (const_int 25)
12854                      (const_int 12) (const_int 28)
12855                      (const_int 13) (const_int 29)])))]
12856   "TARGET_AVX512F"
12857   "vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12858   [(set_attr "type" "sselog")
12859    (set_attr "prefix" "evex")
12860    (set_attr "mode" "XI")])
12862 (define_insn "vec_interleave_lowv4si<mask_name>"
12863   [(set (match_operand:V4SI 0 "register_operand" "=x,v")
12864         (vec_select:V4SI
12865           (vec_concat:V8SI
12866             (match_operand:V4SI 1 "register_operand" "0,v")
12867             (match_operand:V4SI 2 "vector_operand" "xBm,vm"))
12868           (parallel [(const_int 0) (const_int 4)
12869                      (const_int 1) (const_int 5)])))]
12870   "TARGET_SSE2 && <mask_avx512vl_condition>"
12871   "@
12872    punpckldq\t{%2, %0|%0, %2}
12873    vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12874   [(set_attr "isa" "noavx,avx")
12875    (set_attr "type" "sselog")
12876    (set_attr "prefix_data16" "1,*")
12877    (set_attr "prefix" "orig,vex")
12878    (set_attr "mode" "TI")])
12880 (define_expand "vec_interleave_high<mode>"
12881   [(match_operand:VI_256 0 "register_operand")
12882    (match_operand:VI_256 1 "register_operand")
12883    (match_operand:VI_256 2 "nonimmediate_operand")]
12884  "TARGET_AVX2"
12886   rtx t1 = gen_reg_rtx (<MODE>mode);
12887   rtx t2 = gen_reg_rtx (<MODE>mode);
12888   rtx t3 = gen_reg_rtx (V4DImode);
12889   emit_insn (gen_avx2_interleave_low<mode> (t1, operands[1], operands[2]));
12890   emit_insn (gen_avx2_interleave_high<mode> (t2,  operands[1], operands[2]));
12891   emit_insn (gen_avx2_permv2ti (t3, gen_lowpart (V4DImode, t1),
12892                                 gen_lowpart (V4DImode, t2),
12893                                 GEN_INT (1 + (3 << 4))));
12894   emit_move_insn (operands[0], gen_lowpart (<MODE>mode, t3));
12895   DONE;
12898 (define_expand "vec_interleave_low<mode>"
12899   [(match_operand:VI_256 0 "register_operand")
12900    (match_operand:VI_256 1 "register_operand")
12901    (match_operand:VI_256 2 "nonimmediate_operand")]
12902  "TARGET_AVX2"
12904   rtx t1 = gen_reg_rtx (<MODE>mode);
12905   rtx t2 = gen_reg_rtx (<MODE>mode);
12906   rtx t3 = gen_reg_rtx (V4DImode);
12907   emit_insn (gen_avx2_interleave_low<mode> (t1, operands[1], operands[2]));
12908   emit_insn (gen_avx2_interleave_high<mode> (t2, operands[1], operands[2]));
12909   emit_insn (gen_avx2_permv2ti (t3, gen_lowpart (V4DImode, t1),
12910                                 gen_lowpart (V4DImode, t2),
12911                                 GEN_INT (0 + (2 << 4))));
12912   emit_move_insn (operands[0], gen_lowpart (<MODE>mode, t3));
12913   DONE;
12916 ;; Modes handled by pinsr patterns.
12917 (define_mode_iterator PINSR_MODE
12918   [(V16QI "TARGET_SSE4_1") V8HI
12919    (V4SI "TARGET_SSE4_1")
12920    (V2DI "TARGET_SSE4_1 && TARGET_64BIT")])
12922 (define_mode_attr sse2p4_1
12923   [(V16QI "sse4_1") (V8HI "sse2")
12924    (V4SI "sse4_1") (V2DI "sse4_1")])
12926 (define_mode_attr pinsr_evex_isa
12927   [(V16QI "avx512bw") (V8HI "avx512bw")
12928    (V4SI "avx512dq") (V2DI "avx512dq")])
12930 ;; sse4_1_pinsrd must come before sse2_loadld since it is preferred.
12931 (define_insn "<sse2p4_1>_pinsr<ssemodesuffix>"
12932   [(set (match_operand:PINSR_MODE 0 "register_operand" "=x,x,x,x,v,v")
12933         (vec_merge:PINSR_MODE
12934           (vec_duplicate:PINSR_MODE
12935             (match_operand:<ssescalarmode> 2 "nonimmediate_operand" "r,m,r,m,r,m"))
12936           (match_operand:PINSR_MODE 1 "register_operand" "0,0,x,x,v,v")
12937           (match_operand:SI 3 "const_int_operand")))]
12938   "TARGET_SSE2
12939    && ((unsigned) exact_log2 (INTVAL (operands[3]))
12940        < GET_MODE_NUNITS (<MODE>mode))"
12942   operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])));
12944   switch (which_alternative)
12945     {
12946     case 0:
12947       if (GET_MODE_SIZE (<ssescalarmode>mode) < GET_MODE_SIZE (SImode))
12948         return "pinsr<ssemodesuffix>\t{%3, %k2, %0|%0, %k2, %3}";
12949       /* FALLTHRU */
12950     case 1:
12951       return "pinsr<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}";
12952     case 2:
12953     case 4:
12954       if (GET_MODE_SIZE (<ssescalarmode>mode) < GET_MODE_SIZE (SImode))
12955         return "vpinsr<ssemodesuffix>\t{%3, %k2, %1, %0|%0, %1, %k2, %3}";
12956       /* FALLTHRU */
12957     case 3:
12958     case 5:
12959       return "vpinsr<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
12960     default:
12961       gcc_unreachable ();
12962     }
12964   [(set_attr "isa" "noavx,noavx,avx,avx,<pinsr_evex_isa>,<pinsr_evex_isa>")
12965    (set_attr "type" "sselog")
12966    (set (attr "prefix_rex")
12967      (if_then_else
12968        (and (not (match_test "TARGET_AVX"))
12969             (eq (const_string "<MODE>mode") (const_string "V2DImode")))
12970        (const_string "1")
12971        (const_string "*")))
12972    (set (attr "prefix_data16")
12973      (if_then_else
12974        (and (not (match_test "TARGET_AVX"))
12975             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
12976        (const_string "1")
12977        (const_string "*")))
12978    (set (attr "prefix_extra")
12979      (if_then_else
12980        (and (not (match_test "TARGET_AVX"))
12981             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
12982        (const_string "*")
12983        (const_string "1")))
12984    (set_attr "length_immediate" "1")
12985    (set_attr "prefix" "orig,orig,vex,vex,evex,evex")
12986    (set_attr "mode" "TI")])
12988 (define_expand "<extract_type>_vinsert<shuffletype><extract_suf>_mask"
12989   [(match_operand:AVX512_VEC 0 "register_operand")
12990    (match_operand:AVX512_VEC 1 "register_operand")
12991    (match_operand:<ssequartermode> 2 "nonimmediate_operand")
12992    (match_operand:SI 3 "const_0_to_3_operand")
12993    (match_operand:AVX512_VEC 4 "register_operand")
12994    (match_operand:<avx512fmaskmode> 5 "register_operand")]
12995   "TARGET_AVX512F"
12997   int mask, selector;
12998   mask = INTVAL (operands[3]);
12999   selector = (GET_MODE_UNIT_SIZE (<MODE>mode) == 4
13000               ? 0xFFFF ^ (0x000F << mask * 4)
13001               : 0xFF ^ (0x03 << mask * 2));
13002   emit_insn (gen_<extract_type>_vinsert<shuffletype><extract_suf>_1_mask
13003     (operands[0], operands[1], operands[2], GEN_INT (selector),
13004      operands[4], operands[5]));
13005   DONE;
13008 (define_insn "*<extract_type>_vinsert<shuffletype><extract_suf>_0"
13009   [(set (match_operand:AVX512_VEC 0 "register_operand" "=v,x,Yv")
13010         (vec_merge:AVX512_VEC
13011           (match_operand:AVX512_VEC 1 "reg_or_0_operand" "v,C,C")
13012           (vec_duplicate:AVX512_VEC
13013                 (match_operand:<ssequartermode> 2 "nonimmediate_operand" "vm,xm,vm"))
13014           (match_operand:SI 3 "const_int_operand" "n,n,n")))]
13015   "TARGET_AVX512F
13016    && (INTVAL (operands[3])
13017        == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xFFF0 : 0xFC))"
13019   if (which_alternative == 0)
13020     return "vinsert<shuffletype><extract_suf>\t{$0, %2, %1, %0|%0, %1, %2, 0}";
13021   switch (<MODE>mode)
13022     {
13023     case E_V8DFmode:
13024       return "vmovapd\t{%2, %x0|%x0, %2}";
13025     case E_V16SFmode:
13026       return "vmovaps\t{%2, %x0|%x0, %2}";
13027     case E_V8DImode:
13028       return which_alternative == 2 ? "vmovdqa64\t{%2, %x0|%x0, %2}"
13029                                     : "vmovdqa\t{%2, %x0|%x0, %2}";
13030     case E_V16SImode:
13031       return which_alternative == 2 ? "vmovdqa32\t{%2, %x0|%x0, %2}"
13032                                     : "vmovdqa\t{%2, %x0|%x0, %2}";
13033     default:
13034       gcc_unreachable ();
13035     }
13037   [(set_attr "type" "sselog,ssemov,ssemov")
13038    (set_attr "length_immediate" "1,0,0")
13039    (set_attr "prefix" "evex,vex,evex")
13040    (set_attr "mode" "<sseinsnmode>,<ssequarterinsnmode>,<ssequarterinsnmode>")])
13042 (define_insn "<mask_codefor><extract_type>_vinsert<shuffletype><extract_suf>_1<mask_name>"
13043   [(set (match_operand:AVX512_VEC 0 "register_operand" "=v")
13044         (vec_merge:AVX512_VEC
13045           (match_operand:AVX512_VEC 1 "register_operand" "v")
13046           (vec_duplicate:AVX512_VEC
13047                 (match_operand:<ssequartermode> 2 "nonimmediate_operand" "vm"))
13048           (match_operand:SI 3 "const_int_operand" "n")))]
13049   "TARGET_AVX512F"
13051   int mask;
13052   int selector = INTVAL (operands[3]);
13054   if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xFFF0 : 0xFC))
13055     mask = 0;
13056   else if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xFF0F : 0xF3))
13057     mask = 1;
13058   else if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xF0FF : 0xCF))
13059     mask = 2;
13060   else if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0x0FFF : 0x3F))
13061     mask = 3;
13062   else
13063     gcc_unreachable ();
13065   operands[3] = GEN_INT (mask);
13067   return "vinsert<shuffletype><extract_suf>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}";
13069   [(set_attr "type" "sselog")
13070    (set_attr "length_immediate" "1")
13071    (set_attr "prefix" "evex")
13072    (set_attr "mode" "<sseinsnmode>")])
13074 (define_expand "<extract_type_2>_vinsert<shuffletype><extract_suf_2>_mask"
13075   [(match_operand:AVX512_VEC_2 0 "register_operand")
13076    (match_operand:AVX512_VEC_2 1 "register_operand")
13077    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
13078    (match_operand:SI 3 "const_0_to_1_operand")
13079    (match_operand:AVX512_VEC_2 4 "register_operand")
13080    (match_operand:<avx512fmaskmode> 5 "register_operand")]
13081   "TARGET_AVX512F"
13083   int mask = INTVAL (operands[3]);
13084   if (mask == 0)
13085     emit_insn (gen_vec_set_lo_<mode>_mask (operands[0], operands[1],
13086                                            operands[2], operands[4],
13087                                            operands[5]));
13088   else
13089     emit_insn (gen_vec_set_hi_<mode>_mask (operands[0], operands[1],
13090                                            operands[2], operands[4],
13091                                            operands[5]));
13092   DONE;
13095 (define_insn "vec_set_lo_<mode><mask_name>"
13096   [(set (match_operand:V16FI 0 "register_operand" "=v")
13097         (vec_concat:V16FI
13098           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
13099           (vec_select:<ssehalfvecmode>
13100             (match_operand:V16FI 1 "register_operand" "v")
13101             (parallel [(const_int 8) (const_int 9)
13102                        (const_int 10) (const_int 11)
13103                        (const_int 12) (const_int 13)
13104                        (const_int 14) (const_int 15)]))))]
13105   "TARGET_AVX512DQ"
13106   "vinsert<shuffletype>32x8\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}"
13107   [(set_attr "type" "sselog")
13108    (set_attr "length_immediate" "1")
13109    (set_attr "prefix" "evex")
13110    (set_attr "mode" "<sseinsnmode>")])
13112 (define_insn "vec_set_hi_<mode><mask_name>"
13113   [(set (match_operand:V16FI 0 "register_operand" "=v")
13114         (vec_concat:V16FI
13115           (vec_select:<ssehalfvecmode>
13116             (match_operand:V16FI 1 "register_operand" "v")
13117             (parallel [(const_int 0) (const_int 1)
13118                        (const_int 2) (const_int 3)
13119                        (const_int 4) (const_int 5)
13120                        (const_int 6) (const_int 7)]))
13121           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
13122   "TARGET_AVX512DQ"
13123   "vinsert<shuffletype>32x8\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}"
13124   [(set_attr "type" "sselog")
13125    (set_attr "length_immediate" "1")
13126    (set_attr "prefix" "evex")
13127    (set_attr "mode" "<sseinsnmode>")])
13129 (define_insn "vec_set_lo_<mode><mask_name>"
13130   [(set (match_operand:V8FI 0 "register_operand" "=v")
13131         (vec_concat:V8FI
13132           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
13133           (vec_select:<ssehalfvecmode>
13134             (match_operand:V8FI 1 "register_operand" "v")
13135             (parallel [(const_int 4) (const_int 5)
13136                        (const_int 6) (const_int 7)]))))]
13137   "TARGET_AVX512F"
13138   "vinsert<shuffletype>64x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}"
13139   [(set_attr "type" "sselog")
13140    (set_attr "length_immediate" "1")
13141    (set_attr "prefix" "evex")
13142    (set_attr "mode" "XI")])
13144 (define_insn "vec_set_hi_<mode><mask_name>"
13145   [(set (match_operand:V8FI 0 "register_operand" "=v")
13146         (vec_concat:V8FI
13147           (vec_select:<ssehalfvecmode>
13148             (match_operand:V8FI 1 "register_operand" "v")
13149             (parallel [(const_int 0) (const_int 1)
13150                        (const_int 2) (const_int 3)]))
13151           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
13152   "TARGET_AVX512F"
13153   "vinsert<shuffletype>64x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}"
13154   [(set_attr "type" "sselog")
13155    (set_attr "length_immediate" "1")
13156    (set_attr "prefix" "evex")
13157    (set_attr "mode" "XI")])
13159 (define_expand "avx512dq_shuf_<shuffletype>64x2_mask"
13160   [(match_operand:VI8F_256 0 "register_operand")
13161    (match_operand:VI8F_256 1 "register_operand")
13162    (match_operand:VI8F_256 2 "nonimmediate_operand")
13163    (match_operand:SI 3 "const_0_to_3_operand")
13164    (match_operand:VI8F_256 4 "register_operand")
13165    (match_operand:QI 5 "register_operand")]
13166   "TARGET_AVX512DQ"
13168   int mask = INTVAL (operands[3]);
13169   emit_insn (gen_avx512dq_shuf_<shuffletype>64x2_1_mask
13170       (operands[0], operands[1], operands[2],
13171        GEN_INT (((mask >> 0) & 1) * 2 + 0),
13172        GEN_INT (((mask >> 0) & 1) * 2 + 1),
13173        GEN_INT (((mask >> 1) & 1) * 2 + 4),
13174        GEN_INT (((mask >> 1) & 1) * 2 + 5),
13175        operands[4], operands[5]));
13176   DONE;
13179 (define_insn "<mask_codefor>avx512dq_shuf_<shuffletype>64x2_1<mask_name>"
13180   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
13181         (vec_select:VI8F_256
13182           (vec_concat:<ssedoublemode>
13183             (match_operand:VI8F_256 1 "register_operand" "v")
13184             (match_operand:VI8F_256 2 "nonimmediate_operand" "vm"))
13185           (parallel [(match_operand 3  "const_0_to_3_operand")
13186                      (match_operand 4  "const_0_to_3_operand")
13187                      (match_operand 5  "const_4_to_7_operand")
13188                      (match_operand 6  "const_4_to_7_operand")])))]
13189   "TARGET_AVX512VL
13190    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
13191        && INTVAL (operands[5]) == (INTVAL (operands[6]) - 1))"
13193   int mask;
13194   mask = INTVAL (operands[3]) / 2;
13195   mask |= (INTVAL (operands[5]) - 4) / 2 << 1;
13196   operands[3] = GEN_INT (mask);
13197   return "vshuf<shuffletype>64x2\t{%3, %2, %1, %0<mask_operand7>|%0<mask_operand7>, %1, %2, %3}";
13199   [(set_attr "type" "sselog")
13200    (set_attr "length_immediate" "1")
13201    (set_attr "prefix" "evex")
13202    (set_attr "mode" "XI")])
13204 (define_expand "avx512f_shuf_<shuffletype>64x2_mask"
13205   [(match_operand:V8FI 0 "register_operand")
13206    (match_operand:V8FI 1 "register_operand")
13207    (match_operand:V8FI 2 "nonimmediate_operand")
13208    (match_operand:SI 3 "const_0_to_255_operand")
13209    (match_operand:V8FI 4 "register_operand")
13210    (match_operand:QI 5 "register_operand")]
13211   "TARGET_AVX512F"
13213   int mask = INTVAL (operands[3]);
13214   emit_insn (gen_avx512f_shuf_<shuffletype>64x2_1_mask
13215       (operands[0], operands[1], operands[2],
13216        GEN_INT (((mask >> 0) & 3) * 2),
13217        GEN_INT (((mask >> 0) & 3) * 2 + 1),
13218        GEN_INT (((mask >> 2) & 3) * 2),
13219        GEN_INT (((mask >> 2) & 3) * 2 + 1),
13220        GEN_INT (((mask >> 4) & 3) * 2 + 8),
13221        GEN_INT (((mask >> 4) & 3) * 2 + 9),
13222        GEN_INT (((mask >> 6) & 3) * 2 + 8),
13223        GEN_INT (((mask >> 6) & 3) * 2 + 9),
13224        operands[4], operands[5]));
13225   DONE;
13228 (define_insn "avx512f_shuf_<shuffletype>64x2_1<mask_name>"
13229   [(set (match_operand:V8FI 0 "register_operand" "=v")
13230         (vec_select:V8FI
13231           (vec_concat:<ssedoublemode>
13232             (match_operand:V8FI 1 "register_operand" "v")
13233             (match_operand:V8FI 2 "nonimmediate_operand" "vm"))
13234           (parallel [(match_operand 3  "const_0_to_7_operand")
13235                      (match_operand 4  "const_0_to_7_operand")
13236                      (match_operand 5  "const_0_to_7_operand")
13237                      (match_operand 6  "const_0_to_7_operand")
13238                      (match_operand 7  "const_8_to_15_operand")
13239                      (match_operand 8  "const_8_to_15_operand")
13240                      (match_operand 9  "const_8_to_15_operand")
13241                      (match_operand 10  "const_8_to_15_operand")])))]
13242   "TARGET_AVX512F
13243    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
13244        && INTVAL (operands[5]) == (INTVAL (operands[6]) - 1)
13245        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
13246        && INTVAL (operands[9]) == (INTVAL (operands[10]) - 1))"
13248   int mask;
13249   mask = INTVAL (operands[3]) / 2;
13250   mask |= INTVAL (operands[5]) / 2 << 2;
13251   mask |= (INTVAL (operands[7]) - 8) / 2 << 4;
13252   mask |= (INTVAL (operands[9]) - 8) / 2 << 6;
13253   operands[3] = GEN_INT (mask);
13255   return "vshuf<shuffletype>64x2\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
13257   [(set_attr "type" "sselog")
13258    (set_attr "length_immediate" "1")
13259    (set_attr "prefix" "evex")
13260    (set_attr "mode" "<sseinsnmode>")])
13262 (define_expand "avx512vl_shuf_<shuffletype>32x4_mask"
13263   [(match_operand:VI4F_256 0 "register_operand")
13264    (match_operand:VI4F_256 1 "register_operand")
13265    (match_operand:VI4F_256 2 "nonimmediate_operand")
13266    (match_operand:SI 3 "const_0_to_3_operand")
13267    (match_operand:VI4F_256 4 "register_operand")
13268    (match_operand:QI 5 "register_operand")]
13269   "TARGET_AVX512VL"
13271   int mask = INTVAL (operands[3]);
13272   emit_insn (gen_avx512vl_shuf_<shuffletype>32x4_1_mask
13273       (operands[0], operands[1], operands[2],
13274        GEN_INT (((mask >> 0) & 1) * 4 + 0),
13275        GEN_INT (((mask >> 0) & 1) * 4 + 1),
13276        GEN_INT (((mask >> 0) & 1) * 4 + 2),
13277        GEN_INT (((mask >> 0) & 1) * 4 + 3),
13278        GEN_INT (((mask >> 1) & 1) * 4 + 8),
13279        GEN_INT (((mask >> 1) & 1) * 4 + 9),
13280        GEN_INT (((mask >> 1) & 1) * 4 + 10),
13281        GEN_INT (((mask >> 1) & 1) * 4 + 11),
13282        operands[4], operands[5]));
13283   DONE;
13286 (define_insn "avx512vl_shuf_<shuffletype>32x4_1<mask_name>"
13287   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
13288         (vec_select:VI4F_256
13289           (vec_concat:<ssedoublemode>
13290             (match_operand:VI4F_256 1 "register_operand" "v")
13291             (match_operand:VI4F_256 2 "nonimmediate_operand" "vm"))
13292           (parallel [(match_operand 3  "const_0_to_7_operand")
13293                      (match_operand 4  "const_0_to_7_operand")
13294                      (match_operand 5  "const_0_to_7_operand")
13295                      (match_operand 6  "const_0_to_7_operand")
13296                      (match_operand 7  "const_8_to_15_operand")
13297                      (match_operand 8  "const_8_to_15_operand")
13298                      (match_operand 9  "const_8_to_15_operand")
13299                      (match_operand 10 "const_8_to_15_operand")])))]
13300   "TARGET_AVX512VL
13301    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
13302        && INTVAL (operands[3]) == (INTVAL (operands[5]) - 2)
13303        && INTVAL (operands[3]) == (INTVAL (operands[6]) - 3)
13304        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
13305        && INTVAL (operands[7]) == (INTVAL (operands[9]) - 2)
13306        && INTVAL (operands[7]) == (INTVAL (operands[10]) - 3))"
13308   int mask;
13309   mask = INTVAL (operands[3]) / 4;
13310   mask |= (INTVAL (operands[7]) - 8) / 4 << 1;
13311   operands[3] = GEN_INT (mask);
13313   return "vshuf<shuffletype>32x4\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
13315   [(set_attr "type" "sselog")
13316    (set_attr "length_immediate" "1")
13317    (set_attr "prefix" "evex")
13318    (set_attr "mode" "<sseinsnmode>")])
13320 (define_expand "avx512f_shuf_<shuffletype>32x4_mask"
13321   [(match_operand:V16FI 0 "register_operand")
13322    (match_operand:V16FI 1 "register_operand")
13323    (match_operand:V16FI 2 "nonimmediate_operand")
13324    (match_operand:SI 3 "const_0_to_255_operand")
13325    (match_operand:V16FI 4 "register_operand")
13326    (match_operand:HI 5 "register_operand")]
13327   "TARGET_AVX512F"
13329   int mask = INTVAL (operands[3]);
13330   emit_insn (gen_avx512f_shuf_<shuffletype>32x4_1_mask
13331       (operands[0], operands[1], operands[2],
13332        GEN_INT (((mask >> 0) & 3) * 4),
13333        GEN_INT (((mask >> 0) & 3) * 4 + 1),
13334        GEN_INT (((mask >> 0) & 3) * 4 + 2),
13335        GEN_INT (((mask >> 0) & 3) * 4 + 3),
13336        GEN_INT (((mask >> 2) & 3) * 4),
13337        GEN_INT (((mask >> 2) & 3) * 4 + 1),
13338        GEN_INT (((mask >> 2) & 3) * 4 + 2),
13339        GEN_INT (((mask >> 2) & 3) * 4 + 3),
13340        GEN_INT (((mask >> 4) & 3) * 4 + 16),
13341        GEN_INT (((mask >> 4) & 3) * 4 + 17),
13342        GEN_INT (((mask >> 4) & 3) * 4 + 18),
13343        GEN_INT (((mask >> 4) & 3) * 4 + 19),
13344        GEN_INT (((mask >> 6) & 3) * 4 + 16),
13345        GEN_INT (((mask >> 6) & 3) * 4 + 17),
13346        GEN_INT (((mask >> 6) & 3) * 4 + 18),
13347        GEN_INT (((mask >> 6) & 3) * 4 + 19),
13348        operands[4], operands[5]));
13349   DONE;
13352 (define_insn "avx512f_shuf_<shuffletype>32x4_1<mask_name>"
13353   [(set (match_operand:V16FI 0 "register_operand" "=v")
13354         (vec_select:V16FI
13355           (vec_concat:<ssedoublemode>
13356             (match_operand:V16FI 1 "register_operand" "v")
13357             (match_operand:V16FI 2 "nonimmediate_operand" "vm"))
13358           (parallel [(match_operand 3  "const_0_to_15_operand")
13359                      (match_operand 4  "const_0_to_15_operand")
13360                      (match_operand 5  "const_0_to_15_operand")
13361                      (match_operand 6  "const_0_to_15_operand")
13362                      (match_operand 7  "const_0_to_15_operand")
13363                      (match_operand 8  "const_0_to_15_operand")
13364                      (match_operand 9  "const_0_to_15_operand")
13365                      (match_operand 10  "const_0_to_15_operand")
13366                      (match_operand 11  "const_16_to_31_operand")
13367                      (match_operand 12  "const_16_to_31_operand")
13368                      (match_operand 13  "const_16_to_31_operand")
13369                      (match_operand 14  "const_16_to_31_operand")
13370                      (match_operand 15  "const_16_to_31_operand")
13371                      (match_operand 16  "const_16_to_31_operand")
13372                      (match_operand 17  "const_16_to_31_operand")
13373                      (match_operand 18  "const_16_to_31_operand")])))]
13374   "TARGET_AVX512F
13375    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
13376        && INTVAL (operands[3]) == (INTVAL (operands[5]) - 2)
13377        && INTVAL (operands[3]) == (INTVAL (operands[6]) - 3)
13378        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
13379        && INTVAL (operands[7]) == (INTVAL (operands[9]) - 2)
13380        && INTVAL (operands[7]) == (INTVAL (operands[10]) - 3)
13381        && INTVAL (operands[11]) == (INTVAL (operands[12]) - 1)
13382        && INTVAL (operands[11]) == (INTVAL (operands[13]) - 2)
13383        && INTVAL (operands[11]) == (INTVAL (operands[14]) - 3)
13384        && INTVAL (operands[15]) == (INTVAL (operands[16]) - 1)
13385        && INTVAL (operands[15]) == (INTVAL (operands[17]) - 2)
13386        && INTVAL (operands[15]) == (INTVAL (operands[18]) - 3))"
13388   int mask;
13389   mask = INTVAL (operands[3]) / 4;
13390   mask |= INTVAL (operands[7]) / 4 << 2;
13391   mask |= (INTVAL (operands[11]) - 16) / 4 << 4;
13392   mask |= (INTVAL (operands[15]) - 16) / 4 << 6;
13393   operands[3] = GEN_INT (mask);
13395   return "vshuf<shuffletype>32x4\t{%3, %2, %1, %0<mask_operand19>|%0<mask_operand19>, %1, %2, %3}";
13397   [(set_attr "type" "sselog")
13398    (set_attr "length_immediate" "1")
13399    (set_attr "prefix" "evex")
13400    (set_attr "mode" "<sseinsnmode>")])
13402 (define_expand "avx512f_pshufdv3_mask"
13403   [(match_operand:V16SI 0 "register_operand")
13404    (match_operand:V16SI 1 "nonimmediate_operand")
13405    (match_operand:SI 2 "const_0_to_255_operand")
13406    (match_operand:V16SI 3 "register_operand")
13407    (match_operand:HI 4 "register_operand")]
13408   "TARGET_AVX512F"
13410   int mask = INTVAL (operands[2]);
13411   emit_insn (gen_avx512f_pshufd_1_mask (operands[0], operands[1],
13412                                        GEN_INT ((mask >> 0) & 3),
13413                                        GEN_INT ((mask >> 2) & 3),
13414                                        GEN_INT ((mask >> 4) & 3),
13415                                        GEN_INT ((mask >> 6) & 3),
13416                                        GEN_INT (((mask >> 0) & 3) + 4),
13417                                        GEN_INT (((mask >> 2) & 3) + 4),
13418                                        GEN_INT (((mask >> 4) & 3) + 4),
13419                                        GEN_INT (((mask >> 6) & 3) + 4),
13420                                        GEN_INT (((mask >> 0) & 3) + 8),
13421                                        GEN_INT (((mask >> 2) & 3) + 8),
13422                                        GEN_INT (((mask >> 4) & 3) + 8),
13423                                        GEN_INT (((mask >> 6) & 3) + 8),
13424                                        GEN_INT (((mask >> 0) & 3) + 12),
13425                                        GEN_INT (((mask >> 2) & 3) + 12),
13426                                        GEN_INT (((mask >> 4) & 3) + 12),
13427                                        GEN_INT (((mask >> 6) & 3) + 12),
13428                                        operands[3], operands[4]));
13429   DONE;
13432 (define_insn "avx512f_pshufd_1<mask_name>"
13433   [(set (match_operand:V16SI 0 "register_operand" "=v")
13434         (vec_select:V16SI
13435           (match_operand:V16SI 1 "nonimmediate_operand" "vm")
13436           (parallel [(match_operand 2 "const_0_to_3_operand")
13437                      (match_operand 3 "const_0_to_3_operand")
13438                      (match_operand 4 "const_0_to_3_operand")
13439                      (match_operand 5 "const_0_to_3_operand")
13440                      (match_operand 6 "const_4_to_7_operand")
13441                      (match_operand 7 "const_4_to_7_operand")
13442                      (match_operand 8 "const_4_to_7_operand")
13443                      (match_operand 9 "const_4_to_7_operand")
13444                      (match_operand 10 "const_8_to_11_operand")
13445                      (match_operand 11 "const_8_to_11_operand")
13446                      (match_operand 12 "const_8_to_11_operand")
13447                      (match_operand 13 "const_8_to_11_operand")
13448                      (match_operand 14 "const_12_to_15_operand")
13449                      (match_operand 15 "const_12_to_15_operand")
13450                      (match_operand 16 "const_12_to_15_operand")
13451                      (match_operand 17 "const_12_to_15_operand")])))]
13452   "TARGET_AVX512F
13453    && INTVAL (operands[2]) + 4 == INTVAL (operands[6])
13454    && INTVAL (operands[3]) + 4 == INTVAL (operands[7])
13455    && INTVAL (operands[4]) + 4 == INTVAL (operands[8])
13456    && INTVAL (operands[5]) + 4 == INTVAL (operands[9])
13457    && INTVAL (operands[2]) + 8 == INTVAL (operands[10])
13458    && INTVAL (operands[3]) + 8 == INTVAL (operands[11])
13459    && INTVAL (operands[4]) + 8 == INTVAL (operands[12])
13460    && INTVAL (operands[5]) + 8 == INTVAL (operands[13])
13461    && INTVAL (operands[2]) + 12 == INTVAL (operands[14])
13462    && INTVAL (operands[3]) + 12 == INTVAL (operands[15])
13463    && INTVAL (operands[4]) + 12 == INTVAL (operands[16])
13464    && INTVAL (operands[5]) + 12 == INTVAL (operands[17])"
13466   int mask = 0;
13467   mask |= INTVAL (operands[2]) << 0;
13468   mask |= INTVAL (operands[3]) << 2;
13469   mask |= INTVAL (operands[4]) << 4;
13470   mask |= INTVAL (operands[5]) << 6;
13471   operands[2] = GEN_INT (mask);
13473   return "vpshufd\t{%2, %1, %0<mask_operand18>|%0<mask_operand18>, %1, %2}";
13475   [(set_attr "type" "sselog1")
13476    (set_attr "prefix" "evex")
13477    (set_attr "length_immediate" "1")
13478    (set_attr "mode" "XI")])
13480 (define_expand "avx512vl_pshufdv3_mask"
13481   [(match_operand:V8SI 0 "register_operand")
13482    (match_operand:V8SI 1 "nonimmediate_operand")
13483    (match_operand:SI 2 "const_0_to_255_operand")
13484    (match_operand:V8SI 3 "register_operand")
13485    (match_operand:QI 4 "register_operand")]
13486   "TARGET_AVX512VL"
13488   int mask = INTVAL (operands[2]);
13489   emit_insn (gen_avx2_pshufd_1_mask (operands[0], operands[1],
13490                                 GEN_INT ((mask >> 0) & 3),
13491                                 GEN_INT ((mask >> 2) & 3),
13492                                 GEN_INT ((mask >> 4) & 3),
13493                                 GEN_INT ((mask >> 6) & 3),
13494                                 GEN_INT (((mask >> 0) & 3) + 4),
13495                                 GEN_INT (((mask >> 2) & 3) + 4),
13496                                 GEN_INT (((mask >> 4) & 3) + 4),
13497                                 GEN_INT (((mask >> 6) & 3) + 4),
13498                 operands[3], operands[4]));
13499   DONE;
13502 (define_expand "avx2_pshufdv3"
13503   [(match_operand:V8SI 0 "register_operand")
13504    (match_operand:V8SI 1 "nonimmediate_operand")
13505    (match_operand:SI 2 "const_0_to_255_operand")]
13506   "TARGET_AVX2"
13508   int mask = INTVAL (operands[2]);
13509   emit_insn (gen_avx2_pshufd_1 (operands[0], operands[1],
13510                                 GEN_INT ((mask >> 0) & 3),
13511                                 GEN_INT ((mask >> 2) & 3),
13512                                 GEN_INT ((mask >> 4) & 3),
13513                                 GEN_INT ((mask >> 6) & 3),
13514                                 GEN_INT (((mask >> 0) & 3) + 4),
13515                                 GEN_INT (((mask >> 2) & 3) + 4),
13516                                 GEN_INT (((mask >> 4) & 3) + 4),
13517                                 GEN_INT (((mask >> 6) & 3) + 4)));
13518   DONE;
13521 (define_insn "avx2_pshufd_1<mask_name>"
13522   [(set (match_operand:V8SI 0 "register_operand" "=v")
13523         (vec_select:V8SI
13524           (match_operand:V8SI 1 "nonimmediate_operand" "vm")
13525           (parallel [(match_operand 2 "const_0_to_3_operand")
13526                      (match_operand 3 "const_0_to_3_operand")
13527                      (match_operand 4 "const_0_to_3_operand")
13528                      (match_operand 5 "const_0_to_3_operand")
13529                      (match_operand 6 "const_4_to_7_operand")
13530                      (match_operand 7 "const_4_to_7_operand")
13531                      (match_operand 8 "const_4_to_7_operand")
13532                      (match_operand 9 "const_4_to_7_operand")])))]
13533   "TARGET_AVX2
13534    && <mask_avx512vl_condition>
13535    && INTVAL (operands[2]) + 4 == INTVAL (operands[6])
13536    && INTVAL (operands[3]) + 4 == INTVAL (operands[7])
13537    && INTVAL (operands[4]) + 4 == INTVAL (operands[8])
13538    && INTVAL (operands[5]) + 4 == INTVAL (operands[9])"
13540   int mask = 0;
13541   mask |= INTVAL (operands[2]) << 0;
13542   mask |= INTVAL (operands[3]) << 2;
13543   mask |= INTVAL (operands[4]) << 4;
13544   mask |= INTVAL (operands[5]) << 6;
13545   operands[2] = GEN_INT (mask);
13547   return "vpshufd\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
13549   [(set_attr "type" "sselog1")
13550    (set_attr "prefix" "maybe_evex")
13551    (set_attr "length_immediate" "1")
13552    (set_attr "mode" "OI")])
13554 (define_expand "avx512vl_pshufd_mask"
13555   [(match_operand:V4SI 0 "register_operand")
13556    (match_operand:V4SI 1 "nonimmediate_operand")
13557    (match_operand:SI 2 "const_0_to_255_operand")
13558    (match_operand:V4SI 3 "register_operand")
13559    (match_operand:QI 4 "register_operand")]
13560   "TARGET_AVX512VL"
13562   int mask = INTVAL (operands[2]);
13563   emit_insn (gen_sse2_pshufd_1_mask (operands[0], operands[1],
13564                                 GEN_INT ((mask >> 0) & 3),
13565                                 GEN_INT ((mask >> 2) & 3),
13566                                 GEN_INT ((mask >> 4) & 3),
13567                                 GEN_INT ((mask >> 6) & 3),
13568                 operands[3], operands[4]));
13569   DONE;
13572 (define_expand "sse2_pshufd"
13573   [(match_operand:V4SI 0 "register_operand")
13574    (match_operand:V4SI 1 "vector_operand")
13575    (match_operand:SI 2 "const_int_operand")]
13576   "TARGET_SSE2"
13578   int mask = INTVAL (operands[2]);
13579   emit_insn (gen_sse2_pshufd_1 (operands[0], operands[1],
13580                                 GEN_INT ((mask >> 0) & 3),
13581                                 GEN_INT ((mask >> 2) & 3),
13582                                 GEN_INT ((mask >> 4) & 3),
13583                                 GEN_INT ((mask >> 6) & 3)));
13584   DONE;
13587 (define_insn "sse2_pshufd_1<mask_name>"
13588   [(set (match_operand:V4SI 0 "register_operand" "=v")
13589         (vec_select:V4SI
13590           (match_operand:V4SI 1 "vector_operand" "vBm")
13591           (parallel [(match_operand 2 "const_0_to_3_operand")
13592                      (match_operand 3 "const_0_to_3_operand")
13593                      (match_operand 4 "const_0_to_3_operand")
13594                      (match_operand 5 "const_0_to_3_operand")])))]
13595   "TARGET_SSE2 && <mask_avx512vl_condition>"
13597   int mask = 0;
13598   mask |= INTVAL (operands[2]) << 0;
13599   mask |= INTVAL (operands[3]) << 2;
13600   mask |= INTVAL (operands[4]) << 4;
13601   mask |= INTVAL (operands[5]) << 6;
13602   operands[2] = GEN_INT (mask);
13604   return "%vpshufd\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
13606   [(set_attr "type" "sselog1")
13607    (set_attr "prefix_data16" "1")
13608    (set_attr "prefix" "<mask_prefix2>")
13609    (set_attr "length_immediate" "1")
13610    (set_attr "mode" "TI")])
13612 (define_insn "<mask_codefor>avx512bw_pshuflwv32hi<mask_name>"
13613   [(set (match_operand:V32HI 0 "register_operand" "=v")
13614         (unspec:V32HI
13615           [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
13616            (match_operand:SI 2 "const_0_to_255_operand" "n")]
13617           UNSPEC_PSHUFLW))]
13618   "TARGET_AVX512BW"
13619   "vpshuflw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
13620   [(set_attr "type" "sselog")
13621    (set_attr "prefix" "evex")
13622    (set_attr "mode" "XI")])
13624 (define_expand "avx512vl_pshuflwv3_mask"
13625   [(match_operand:V16HI 0 "register_operand")
13626    (match_operand:V16HI 1 "nonimmediate_operand")
13627    (match_operand:SI 2 "const_0_to_255_operand")
13628    (match_operand:V16HI 3 "register_operand")
13629    (match_operand:HI 4 "register_operand")]
13630   "TARGET_AVX512VL && TARGET_AVX512BW"
13632   int mask = INTVAL (operands[2]);
13633   emit_insn (gen_avx2_pshuflw_1_mask (operands[0], operands[1],
13634                                  GEN_INT ((mask >> 0) & 3),
13635                                  GEN_INT ((mask >> 2) & 3),
13636                                  GEN_INT ((mask >> 4) & 3),
13637                                  GEN_INT ((mask >> 6) & 3),
13638                                  GEN_INT (((mask >> 0) & 3) + 8),
13639                                  GEN_INT (((mask >> 2) & 3) + 8),
13640                                  GEN_INT (((mask >> 4) & 3) + 8),
13641                                  GEN_INT (((mask >> 6) & 3) + 8),
13642                  operands[3], operands[4]));
13643   DONE;
13646 (define_expand "avx2_pshuflwv3"
13647   [(match_operand:V16HI 0 "register_operand")
13648    (match_operand:V16HI 1 "nonimmediate_operand")
13649    (match_operand:SI 2 "const_0_to_255_operand")]
13650   "TARGET_AVX2"
13652   int mask = INTVAL (operands[2]);
13653   emit_insn (gen_avx2_pshuflw_1 (operands[0], operands[1],
13654                                  GEN_INT ((mask >> 0) & 3),
13655                                  GEN_INT ((mask >> 2) & 3),
13656                                  GEN_INT ((mask >> 4) & 3),
13657                                  GEN_INT ((mask >> 6) & 3),
13658                                  GEN_INT (((mask >> 0) & 3) + 8),
13659                                  GEN_INT (((mask >> 2) & 3) + 8),
13660                                  GEN_INT (((mask >> 4) & 3) + 8),
13661                                  GEN_INT (((mask >> 6) & 3) + 8)));
13662   DONE;
13665 (define_insn "avx2_pshuflw_1<mask_name>"
13666   [(set (match_operand:V16HI 0 "register_operand" "=v")
13667         (vec_select:V16HI
13668           (match_operand:V16HI 1 "nonimmediate_operand" "vm")
13669           (parallel [(match_operand 2 "const_0_to_3_operand")
13670                      (match_operand 3 "const_0_to_3_operand")
13671                      (match_operand 4 "const_0_to_3_operand")
13672                      (match_operand 5 "const_0_to_3_operand")
13673                      (const_int 4)
13674                      (const_int 5)
13675                      (const_int 6)
13676                      (const_int 7)
13677                      (match_operand 6 "const_8_to_11_operand")
13678                      (match_operand 7 "const_8_to_11_operand")
13679                      (match_operand 8 "const_8_to_11_operand")
13680                      (match_operand 9 "const_8_to_11_operand")
13681                      (const_int 12)
13682                      (const_int 13)
13683                      (const_int 14)
13684                      (const_int 15)])))]
13685   "TARGET_AVX2
13686    && <mask_avx512bw_condition> && <mask_avx512vl_condition>
13687    && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
13688    && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
13689    && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
13690    && INTVAL (operands[5]) + 8 == INTVAL (operands[9])"
13692   int mask = 0;
13693   mask |= INTVAL (operands[2]) << 0;
13694   mask |= INTVAL (operands[3]) << 2;
13695   mask |= INTVAL (operands[4]) << 4;
13696   mask |= INTVAL (operands[5]) << 6;
13697   operands[2] = GEN_INT (mask);
13699   return "vpshuflw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
13701   [(set_attr "type" "sselog")
13702    (set_attr "prefix" "maybe_evex")
13703    (set_attr "length_immediate" "1")
13704    (set_attr "mode" "OI")])
13706 (define_expand "avx512vl_pshuflw_mask"
13707   [(match_operand:V8HI 0 "register_operand")
13708    (match_operand:V8HI 1 "nonimmediate_operand")
13709    (match_operand:SI 2 "const_0_to_255_operand")
13710    (match_operand:V8HI 3 "register_operand")
13711    (match_operand:QI 4 "register_operand")]
13712   "TARGET_AVX512VL && TARGET_AVX512BW"
13714   int mask = INTVAL (operands[2]);
13715   emit_insn (gen_sse2_pshuflw_1_mask (operands[0], operands[1],
13716                                  GEN_INT ((mask >> 0) & 3),
13717                                  GEN_INT ((mask >> 2) & 3),
13718                                  GEN_INT ((mask >> 4) & 3),
13719                                  GEN_INT ((mask >> 6) & 3),
13720                  operands[3], operands[4]));
13721   DONE;
13724 (define_expand "sse2_pshuflw"
13725   [(match_operand:V8HI 0 "register_operand")
13726    (match_operand:V8HI 1 "vector_operand")
13727    (match_operand:SI 2 "const_int_operand")]
13728   "TARGET_SSE2"
13730   int mask = INTVAL (operands[2]);
13731   emit_insn (gen_sse2_pshuflw_1 (operands[0], operands[1],
13732                                  GEN_INT ((mask >> 0) & 3),
13733                                  GEN_INT ((mask >> 2) & 3),
13734                                  GEN_INT ((mask >> 4) & 3),
13735                                  GEN_INT ((mask >> 6) & 3)));
13736   DONE;
13739 (define_insn "sse2_pshuflw_1<mask_name>"
13740   [(set (match_operand:V8HI 0 "register_operand" "=v")
13741         (vec_select:V8HI
13742           (match_operand:V8HI 1 "vector_operand" "vBm")
13743           (parallel [(match_operand 2 "const_0_to_3_operand")
13744                      (match_operand 3 "const_0_to_3_operand")
13745                      (match_operand 4 "const_0_to_3_operand")
13746                      (match_operand 5 "const_0_to_3_operand")
13747                      (const_int 4)
13748                      (const_int 5)
13749                      (const_int 6)
13750                      (const_int 7)])))]
13751   "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
13753   int mask = 0;
13754   mask |= INTVAL (operands[2]) << 0;
13755   mask |= INTVAL (operands[3]) << 2;
13756   mask |= INTVAL (operands[4]) << 4;
13757   mask |= INTVAL (operands[5]) << 6;
13758   operands[2] = GEN_INT (mask);
13760   return "%vpshuflw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
13762   [(set_attr "type" "sselog")
13763    (set_attr "prefix_data16" "0")
13764    (set_attr "prefix_rep" "1")
13765    (set_attr "prefix" "maybe_vex")
13766    (set_attr "length_immediate" "1")
13767    (set_attr "mode" "TI")])
13769 (define_expand "avx2_pshufhwv3"
13770   [(match_operand:V16HI 0 "register_operand")
13771    (match_operand:V16HI 1 "nonimmediate_operand")
13772    (match_operand:SI 2 "const_0_to_255_operand")]
13773   "TARGET_AVX2"
13775   int mask = INTVAL (operands[2]);
13776   emit_insn (gen_avx2_pshufhw_1 (operands[0], operands[1],
13777                                  GEN_INT (((mask >> 0) & 3) + 4),
13778                                  GEN_INT (((mask >> 2) & 3) + 4),
13779                                  GEN_INT (((mask >> 4) & 3) + 4),
13780                                  GEN_INT (((mask >> 6) & 3) + 4),
13781                                  GEN_INT (((mask >> 0) & 3) + 12),
13782                                  GEN_INT (((mask >> 2) & 3) + 12),
13783                                  GEN_INT (((mask >> 4) & 3) + 12),
13784                                  GEN_INT (((mask >> 6) & 3) + 12)));
13785   DONE;
13788 (define_insn "<mask_codefor>avx512bw_pshufhwv32hi<mask_name>"
13789   [(set (match_operand:V32HI 0 "register_operand" "=v")
13790         (unspec:V32HI
13791           [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
13792            (match_operand:SI 2 "const_0_to_255_operand" "n")]
13793           UNSPEC_PSHUFHW))]
13794   "TARGET_AVX512BW"
13795   "vpshufhw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
13796   [(set_attr "type" "sselog")
13797    (set_attr "prefix" "evex")
13798    (set_attr "mode" "XI")])
13800 (define_expand "avx512vl_pshufhwv3_mask"
13801   [(match_operand:V16HI 0 "register_operand")
13802    (match_operand:V16HI 1 "nonimmediate_operand")
13803    (match_operand:SI 2 "const_0_to_255_operand")
13804    (match_operand:V16HI 3 "register_operand")
13805    (match_operand:HI 4 "register_operand")]
13806   "TARGET_AVX512VL && TARGET_AVX512BW"
13808   int mask = INTVAL (operands[2]);
13809   emit_insn (gen_avx2_pshufhw_1_mask (operands[0], operands[1],
13810                                  GEN_INT (((mask >> 0) & 3) + 4),
13811                                  GEN_INT (((mask >> 2) & 3) + 4),
13812                                  GEN_INT (((mask >> 4) & 3) + 4),
13813                                  GEN_INT (((mask >> 6) & 3) + 4),
13814                                  GEN_INT (((mask >> 0) & 3) + 12),
13815                                  GEN_INT (((mask >> 2) & 3) + 12),
13816                                  GEN_INT (((mask >> 4) & 3) + 12),
13817                                  GEN_INT (((mask >> 6) & 3) + 12),
13818                  operands[3], operands[4]));
13819   DONE;
13822 (define_insn "avx2_pshufhw_1<mask_name>"
13823   [(set (match_operand:V16HI 0 "register_operand" "=v")
13824         (vec_select:V16HI
13825           (match_operand:V16HI 1 "nonimmediate_operand" "vm")
13826           (parallel [(const_int 0)
13827                      (const_int 1)
13828                      (const_int 2)
13829                      (const_int 3)
13830                      (match_operand 2 "const_4_to_7_operand")
13831                      (match_operand 3 "const_4_to_7_operand")
13832                      (match_operand 4 "const_4_to_7_operand")
13833                      (match_operand 5 "const_4_to_7_operand")
13834                      (const_int 8)
13835                      (const_int 9)
13836                      (const_int 10)
13837                      (const_int 11)
13838                      (match_operand 6 "const_12_to_15_operand")
13839                      (match_operand 7 "const_12_to_15_operand")
13840                      (match_operand 8 "const_12_to_15_operand")
13841                      (match_operand 9 "const_12_to_15_operand")])))]
13842   "TARGET_AVX2
13843    && <mask_avx512bw_condition> && <mask_avx512vl_condition>
13844    && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
13845    && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
13846    && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
13847    && INTVAL (operands[5]) + 8 == INTVAL (operands[9])"
13849   int mask = 0;
13850   mask |= (INTVAL (operands[2]) - 4) << 0;
13851   mask |= (INTVAL (operands[3]) - 4) << 2;
13852   mask |= (INTVAL (operands[4]) - 4) << 4;
13853   mask |= (INTVAL (operands[5]) - 4) << 6;
13854   operands[2] = GEN_INT (mask);
13856   return "vpshufhw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
13858   [(set_attr "type" "sselog")
13859    (set_attr "prefix" "maybe_evex")
13860    (set_attr "length_immediate" "1")
13861    (set_attr "mode" "OI")])
13863 (define_expand "avx512vl_pshufhw_mask"
13864   [(match_operand:V8HI 0 "register_operand")
13865    (match_operand:V8HI 1 "nonimmediate_operand")
13866    (match_operand:SI 2 "const_0_to_255_operand")
13867    (match_operand:V8HI 3 "register_operand")
13868    (match_operand:QI 4 "register_operand")]
13869   "TARGET_AVX512VL && TARGET_AVX512BW"
13871   int mask = INTVAL (operands[2]);
13872   emit_insn (gen_sse2_pshufhw_1_mask (operands[0], operands[1],
13873                                  GEN_INT (((mask >> 0) & 3) + 4),
13874                                  GEN_INT (((mask >> 2) & 3) + 4),
13875                                  GEN_INT (((mask >> 4) & 3) + 4),
13876                                  GEN_INT (((mask >> 6) & 3) + 4),
13877                  operands[3], operands[4]));
13878   DONE;
13881 (define_expand "sse2_pshufhw"
13882   [(match_operand:V8HI 0 "register_operand")
13883    (match_operand:V8HI 1 "vector_operand")
13884    (match_operand:SI 2 "const_int_operand")]
13885   "TARGET_SSE2"
13887   int mask = INTVAL (operands[2]);
13888   emit_insn (gen_sse2_pshufhw_1 (operands[0], operands[1],
13889                                  GEN_INT (((mask >> 0) & 3) + 4),
13890                                  GEN_INT (((mask >> 2) & 3) + 4),
13891                                  GEN_INT (((mask >> 4) & 3) + 4),
13892                                  GEN_INT (((mask >> 6) & 3) + 4)));
13893   DONE;
13896 (define_insn "sse2_pshufhw_1<mask_name>"
13897   [(set (match_operand:V8HI 0 "register_operand" "=v")
13898         (vec_select:V8HI
13899           (match_operand:V8HI 1 "vector_operand" "vBm")
13900           (parallel [(const_int 0)
13901                      (const_int 1)
13902                      (const_int 2)
13903                      (const_int 3)
13904                      (match_operand 2 "const_4_to_7_operand")
13905                      (match_operand 3 "const_4_to_7_operand")
13906                      (match_operand 4 "const_4_to_7_operand")
13907                      (match_operand 5 "const_4_to_7_operand")])))]
13908   "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
13910   int mask = 0;
13911   mask |= (INTVAL (operands[2]) - 4) << 0;
13912   mask |= (INTVAL (operands[3]) - 4) << 2;
13913   mask |= (INTVAL (operands[4]) - 4) << 4;
13914   mask |= (INTVAL (operands[5]) - 4) << 6;
13915   operands[2] = GEN_INT (mask);
13917   return "%vpshufhw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
13919   [(set_attr "type" "sselog")
13920    (set_attr "prefix_rep" "1")
13921    (set_attr "prefix_data16" "0")
13922    (set_attr "prefix" "maybe_vex")
13923    (set_attr "length_immediate" "1")
13924    (set_attr "mode" "TI")])
13926 (define_expand "sse2_loadd"
13927   [(set (match_operand:V4SI 0 "register_operand")
13928         (vec_merge:V4SI
13929           (vec_duplicate:V4SI
13930             (match_operand:SI 1 "nonimmediate_operand"))
13931           (match_dup 2)
13932           (const_int 1)))]
13933   "TARGET_SSE"
13934   "operands[2] = CONST0_RTX (V4SImode);")
13936 (define_insn "sse2_loadld"
13937   [(set (match_operand:V4SI 0 "register_operand"       "=v,v,x,x,v")
13938         (vec_merge:V4SI
13939           (vec_duplicate:V4SI
13940             (match_operand:SI 2 "nonimmediate_operand" "m ,r ,m,x,v"))
13941           (match_operand:V4SI 1 "reg_or_0_operand"     "C ,C ,C,0,v")
13942           (const_int 1)))]
13943   "TARGET_SSE"
13944   "@
13945    %vmovd\t{%2, %0|%0, %2}
13946    %vmovd\t{%2, %0|%0, %2}
13947    movss\t{%2, %0|%0, %2}
13948    movss\t{%2, %0|%0, %2}
13949    vmovss\t{%2, %1, %0|%0, %1, %2}"
13950   [(set_attr "isa" "sse2,sse2,noavx,noavx,avx")
13951    (set_attr "type" "ssemov")
13952    (set_attr "prefix" "maybe_vex,maybe_vex,orig,orig,maybe_evex")
13953    (set_attr "mode" "TI,TI,V4SF,SF,SF")
13954    (set (attr "preferred_for_speed")
13955      (cond [(eq_attr "alternative" "1")
13956               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
13957            ]
13958            (symbol_ref "true")))])
13960 ;; QI and HI modes handled by pextr patterns.
13961 (define_mode_iterator PEXTR_MODE12
13962   [(V16QI "TARGET_SSE4_1") V8HI])
13964 (define_insn "*vec_extract<mode>"
13965   [(set (match_operand:<ssescalarmode> 0 "register_sse4nonimm_operand" "=r,m,r,m")
13966         (vec_select:<ssescalarmode>
13967           (match_operand:PEXTR_MODE12 1 "register_operand" "x,x,v,v")
13968           (parallel
13969             [(match_operand:SI 2 "const_0_to_<ssescalarnummask>_operand")])))]
13970   "TARGET_SSE2"
13971   "@
13972    %vpextr<ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
13973    %vpextr<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
13974    vpextr<ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
13975    vpextr<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
13976   [(set_attr "isa" "*,sse4,avx512bw,avx512bw")
13977    (set_attr "type" "sselog1")
13978    (set_attr "prefix_data16" "1")
13979    (set (attr "prefix_extra")
13980      (if_then_else
13981        (and (eq_attr "alternative" "0,2")
13982             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
13983        (const_string "*")
13984        (const_string "1")))
13985    (set_attr "length_immediate" "1")
13986    (set_attr "prefix" "maybe_vex,maybe_vex,evex,evex")
13987    (set_attr "mode" "TI")])
13989 (define_insn "*vec_extract<PEXTR_MODE12:mode>_zext"
13990   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
13991         (zero_extend:SWI48
13992           (vec_select:<PEXTR_MODE12:ssescalarmode>
13993             (match_operand:PEXTR_MODE12 1 "register_operand" "x,v")
13994             (parallel
13995               [(match_operand:SI 2
13996                 "const_0_to_<PEXTR_MODE12:ssescalarnummask>_operand")]))))]
13997   "TARGET_SSE2"
13998   "@
13999    %vpextr<PEXTR_MODE12:ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
14000    vpextr<PEXTR_MODE12:ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}"
14001   [(set_attr "isa" "*,avx512bw")
14002    (set_attr "type" "sselog1")
14003    (set_attr "prefix_data16" "1")
14004    (set (attr "prefix_extra")
14005      (if_then_else
14006        (eq (const_string "<PEXTR_MODE12:MODE>mode") (const_string "V8HImode"))
14007        (const_string "*")
14008        (const_string "1")))
14009    (set_attr "length_immediate" "1")
14010    (set_attr "prefix" "maybe_vex")
14011    (set_attr "mode" "TI")])
14013 (define_insn "*vec_extract<mode>_mem"
14014   [(set (match_operand:<ssescalarmode> 0 "register_operand" "=r")
14015         (vec_select:<ssescalarmode>
14016           (match_operand:VI12_128 1 "memory_operand" "o")
14017           (parallel
14018             [(match_operand 2 "const_0_to_<ssescalarnummask>_operand")])))]
14019   "TARGET_SSE"
14020   "#")
14022 (define_insn "*vec_extract<ssevecmodelower>_0"
14023   [(set (match_operand:SWI48 0 "nonimmediate_operand"          "=r,r,v ,m")
14024         (vec_select:SWI48
14025           (match_operand:<ssevecmode> 1 "nonimmediate_operand" "m ,v,vm,v")
14026           (parallel [(const_int 0)])))]
14027   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
14028   "#"
14029   [(set_attr "isa" "*,sse2,*,*")
14030    (set (attr "preferred_for_speed")
14031      (cond [(eq_attr "alternative" "1")
14032               (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
14033            ]
14034            (symbol_ref "true")))])
14036 (define_insn "*vec_extractv2di_0_sse"
14037   [(set (match_operand:DI 0 "nonimmediate_operand"     "=v,m")
14038         (vec_select:DI
14039           (match_operand:V2DI 1 "nonimmediate_operand" "vm,v")
14040           (parallel [(const_int 0)])))]
14041   "TARGET_SSE && !TARGET_64BIT
14042    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
14043   "#")
14045 (define_split
14046   [(set (match_operand:SWI48x 0 "nonimmediate_operand")
14047         (vec_select:SWI48x
14048           (match_operand:<ssevecmode> 1 "register_operand")
14049           (parallel [(const_int 0)])))]
14050   "TARGET_SSE && reload_completed"
14051   [(set (match_dup 0) (match_dup 1))]
14052   "operands[1] = gen_lowpart (<MODE>mode, operands[1]);")
14054 (define_insn "*vec_extractv4si_0_zext_sse4"
14055   [(set (match_operand:DI 0 "register_operand" "=r,x,v")
14056         (zero_extend:DI
14057           (vec_select:SI
14058             (match_operand:V4SI 1 "register_operand" "v,x,v")
14059             (parallel [(const_int 0)]))))]
14060   "TARGET_SSE4_1"
14061   "#"
14062   [(set_attr "isa" "x64,*,avx512f")
14063    (set (attr "preferred_for_speed")
14064      (cond [(eq_attr "alternative" "0")
14065               (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
14066            ]
14067            (symbol_ref "true")))])
14069 (define_insn "*vec_extractv4si_0_zext"
14070   [(set (match_operand:DI 0 "register_operand" "=r")
14071         (zero_extend:DI
14072           (vec_select:SI
14073             (match_operand:V4SI 1 "register_operand" "x")
14074             (parallel [(const_int 0)]))))]
14075   "TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_FROM_VEC"
14076   "#")
14078 (define_split
14079   [(set (match_operand:DI 0 "register_operand")
14080         (zero_extend:DI
14081           (vec_select:SI
14082             (match_operand:V4SI 1 "register_operand")
14083             (parallel [(const_int 0)]))))]
14084   "TARGET_SSE2 && reload_completed"
14085   [(set (match_dup 0) (zero_extend:DI (match_dup 1)))]
14086   "operands[1] = gen_lowpart (SImode, operands[1]);")
14088 (define_insn "*vec_extractv4si"
14089   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm,Yr,*x,x,Yv")
14090         (vec_select:SI
14091           (match_operand:V4SI 1 "register_operand" "x,v,0,0,x,v")
14092           (parallel [(match_operand:SI 2 "const_0_to_3_operand")])))]
14093   "TARGET_SSE4_1"
14095   switch (which_alternative)
14096     {
14097     case 0:
14098     case 1:
14099       return "%vpextrd\t{%2, %1, %0|%0, %1, %2}";
14101     case 2:
14102     case 3:
14103       operands[2] = GEN_INT (INTVAL (operands[2]) * 4);
14104       return "psrldq\t{%2, %0|%0, %2}";
14106     case 4:
14107     case 5:
14108       operands[2] = GEN_INT (INTVAL (operands[2]) * 4);
14109       return "vpsrldq\t{%2, %1, %0|%0, %1, %2}";
14111     default:
14112       gcc_unreachable ();
14113     }
14115   [(set_attr "isa" "*,avx512dq,noavx,noavx,avx,avx512bw")
14116    (set_attr "type" "sselog1,sselog1,sseishft1,sseishft1,sseishft1,sseishft1")
14117    (set (attr "prefix_extra")
14118      (if_then_else (eq_attr "alternative" "0,1")
14119                    (const_string "1")
14120                    (const_string "*")))
14121    (set_attr "length_immediate" "1")
14122    (set_attr "prefix" "maybe_vex,evex,orig,orig,vex,evex")
14123    (set_attr "mode" "TI")])
14125 (define_insn "*vec_extractv4si_zext"
14126   [(set (match_operand:DI 0 "register_operand" "=r,r")
14127         (zero_extend:DI
14128           (vec_select:SI
14129             (match_operand:V4SI 1 "register_operand" "x,v")
14130             (parallel [(match_operand:SI 2 "const_0_to_3_operand")]))))]
14131   "TARGET_64BIT && TARGET_SSE4_1"
14132   "%vpextrd\t{%2, %1, %k0|%k0, %1, %2}"
14133   [(set_attr "isa" "*,avx512dq")
14134    (set_attr "type" "sselog1")
14135    (set_attr "prefix_extra" "1")
14136    (set_attr "length_immediate" "1")
14137    (set_attr "prefix" "maybe_vex")
14138    (set_attr "mode" "TI")])
14140 (define_insn "*vec_extractv4si_mem"
14141   [(set (match_operand:SI 0 "register_operand" "=x,r")
14142         (vec_select:SI
14143           (match_operand:V4SI 1 "memory_operand" "o,o")
14144           (parallel [(match_operand 2 "const_0_to_3_operand")])))]
14145   "TARGET_SSE"
14146   "#")
14148 (define_insn_and_split "*vec_extractv4si_zext_mem"
14149   [(set (match_operand:DI 0 "register_operand" "=x,r")
14150         (zero_extend:DI
14151           (vec_select:SI
14152             (match_operand:V4SI 1 "memory_operand" "o,o")
14153             (parallel [(match_operand:SI 2 "const_0_to_3_operand")]))))]
14154   "TARGET_64BIT && TARGET_SSE"
14155   "#"
14156   "&& reload_completed"
14157   [(set (match_dup 0) (zero_extend:DI (match_dup 1)))]
14159   operands[1] = adjust_address (operands[1], SImode, INTVAL (operands[2]) * 4);
14162 (define_insn "*vec_extractv2di_1"
14163   [(set (match_operand:DI 0 "nonimmediate_operand"     "=rm,rm,m,x,x,Yv,x,v,r")
14164         (vec_select:DI
14165           (match_operand:V2DI 1 "nonimmediate_operand"  "x ,v ,v,0,x, v,x,o,o")
14166           (parallel [(const_int 1)])))]
14167   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
14168   "@
14169    %vpextrq\t{$1, %1, %0|%0, %1, 1}
14170    vpextrq\t{$1, %1, %0|%0, %1, 1}
14171    %vmovhps\t{%1, %0|%0, %1}
14172    psrldq\t{$8, %0|%0, 8}
14173    vpsrldq\t{$8, %1, %0|%0, %1, 8}
14174    vpsrldq\t{$8, %1, %0|%0, %1, 8}
14175    movhlps\t{%1, %0|%0, %1}
14176    #
14177    #"
14178   [(set (attr "isa")
14179      (cond [(eq_attr "alternative" "0")
14180               (const_string "x64_sse4")
14181             (eq_attr "alternative" "1")
14182               (const_string "x64_avx512dq")
14183             (eq_attr "alternative" "3")
14184               (const_string "sse2_noavx")
14185             (eq_attr "alternative" "4")
14186               (const_string "avx")
14187             (eq_attr "alternative" "5")
14188               (const_string "avx512bw")
14189             (eq_attr "alternative" "6")
14190               (const_string "noavx")
14191             (eq_attr "alternative" "8")
14192               (const_string "x64")
14193            ]
14194            (const_string "*")))
14195    (set (attr "type")
14196      (cond [(eq_attr "alternative" "2,6,7")
14197               (const_string "ssemov")
14198             (eq_attr "alternative" "3,4,5")
14199               (const_string "sseishft1")
14200             (eq_attr "alternative" "8")
14201               (const_string "imov")
14202            ]
14203            (const_string "sselog1")))
14204    (set (attr "length_immediate")
14205      (if_then_else (eq_attr "alternative" "0,1,3,4,5")
14206                    (const_string "1")
14207                    (const_string "*")))
14208    (set (attr "prefix_rex")
14209      (if_then_else (eq_attr "alternative" "0,1")
14210                    (const_string "1")
14211                    (const_string "*")))
14212    (set (attr "prefix_extra")
14213      (if_then_else (eq_attr "alternative" "0,1")
14214                    (const_string "1")
14215                    (const_string "*")))
14216    (set_attr "prefix" "maybe_vex,evex,maybe_vex,orig,vex,evex,orig,*,*")
14217    (set_attr "mode" "TI,TI,V2SF,TI,TI,TI,V4SF,DI,DI")])
14219 (define_split
14220   [(set (match_operand:<ssescalarmode> 0 "register_operand")
14221         (vec_select:<ssescalarmode>
14222           (match_operand:VI_128 1 "memory_operand")
14223           (parallel
14224             [(match_operand 2 "const_0_to_<ssescalarnummask>_operand")])))]
14225   "TARGET_SSE && reload_completed"
14226   [(set (match_dup 0) (match_dup 1))]
14228   int offs = INTVAL (operands[2]) * GET_MODE_SIZE (<ssescalarmode>mode);
14230   operands[1] = adjust_address (operands[1], <ssescalarmode>mode, offs);
14233 (define_insn "*vec_extractv2ti"
14234   [(set (match_operand:TI 0 "nonimmediate_operand" "=xm,vm")
14235         (vec_select:TI
14236           (match_operand:V2TI 1 "register_operand" "x,v")
14237           (parallel
14238             [(match_operand:SI 2 "const_0_to_1_operand")])))]
14239   "TARGET_AVX"
14240   "@
14241    vextract%~128\t{%2, %1, %0|%0, %1, %2}
14242    vextracti32x4\t{%2, %g1, %0|%0, %g1, %2}"
14243   [(set_attr "type" "sselog")
14244    (set_attr "prefix_extra" "1")
14245    (set_attr "length_immediate" "1")
14246    (set_attr "prefix" "vex,evex")
14247    (set_attr "mode" "OI")])
14249 (define_insn "*vec_extractv4ti"
14250   [(set (match_operand:TI 0 "nonimmediate_operand" "=vm")
14251         (vec_select:TI
14252           (match_operand:V4TI 1 "register_operand" "v")
14253           (parallel
14254             [(match_operand:SI 2 "const_0_to_3_operand")])))]
14255   "TARGET_AVX512F"
14256   "vextracti32x4\t{%2, %1, %0|%0, %1, %2}"
14257   [(set_attr "type" "sselog")
14258    (set_attr "prefix_extra" "1")
14259    (set_attr "length_immediate" "1")
14260    (set_attr "prefix" "evex")
14261    (set_attr "mode" "XI")])
14263 (define_mode_iterator VEXTRACTI128_MODE
14264   [(V4TI "TARGET_AVX512F") V2TI])
14266 (define_split
14267   [(set (match_operand:TI 0 "nonimmediate_operand")
14268         (vec_select:TI
14269           (match_operand:VEXTRACTI128_MODE 1 "register_operand")
14270           (parallel [(const_int 0)])))]
14271   "TARGET_AVX
14272    && reload_completed
14273    && (TARGET_AVX512VL || !EXT_REX_SSE_REG_P (operands[1]))"
14274   [(set (match_dup 0) (match_dup 1))]
14275   "operands[1] = gen_lowpart (TImode, operands[1]);")
14277 ;; Turn SImode or DImode extraction from arbitrary SSE/AVX/AVX512F
14278 ;; vector modes into vec_extract*.
14279 (define_split
14280   [(set (match_operand:SWI48x 0 "nonimmediate_operand")
14281         (subreg:SWI48x (match_operand 1 "register_operand") 0))]
14282   "can_create_pseudo_p ()
14283    && REG_P (operands[1])
14284    && VECTOR_MODE_P (GET_MODE (operands[1]))
14285    && ((TARGET_SSE && GET_MODE_SIZE (GET_MODE (operands[1])) == 16)
14286        || (TARGET_AVX && GET_MODE_SIZE (GET_MODE (operands[1])) == 32)
14287        || (TARGET_AVX512F && GET_MODE_SIZE (GET_MODE (operands[1])) == 64))
14288    && (<MODE>mode == SImode || TARGET_64BIT || MEM_P (operands[0]))"
14289   [(set (match_dup 0) (vec_select:SWI48x (match_dup 1)
14290                                          (parallel [(const_int 0)])))]
14292   rtx tmp;
14294   switch (GET_MODE_SIZE (GET_MODE (operands[1])))
14295     {
14296     case 64:
14297       if (<MODE>mode == SImode)
14298         {
14299           tmp = gen_reg_rtx (V8SImode);
14300           emit_insn (gen_vec_extract_lo_v16si (tmp,
14301                                                gen_lowpart (V16SImode,
14302                                                             operands[1])));
14303         }
14304       else
14305         {
14306           tmp = gen_reg_rtx (V4DImode);
14307           emit_insn (gen_vec_extract_lo_v8di (tmp,
14308                                               gen_lowpart (V8DImode,
14309                                                            operands[1])));
14310         }
14311       operands[1] = tmp;
14312       /* FALLTHRU */
14313     case 32:
14314       tmp = gen_reg_rtx (<ssevecmode>mode);
14315       if (<MODE>mode == SImode)
14316         emit_insn (gen_vec_extract_lo_v8si (tmp, gen_lowpart (V8SImode,
14317                                                               operands[1])));
14318       else
14319         emit_insn (gen_vec_extract_lo_v4di (tmp, gen_lowpart (V4DImode,
14320                                                               operands[1])));
14321       operands[1] = tmp;
14322       break;
14323     case 16:
14324       operands[1] = gen_lowpart (<ssevecmode>mode, operands[1]);
14325       break;
14326     }
14329 (define_insn "*vec_concatv2si_sse4_1"
14330   [(set (match_operand:V2SI 0 "register_operand"
14331           "=Yr,*x, x, v,Yr,*x, v, v, *y,*y")
14332         (vec_concat:V2SI
14333           (match_operand:SI 1 "nonimmediate_operand"
14334           "  0, 0, x,Yv, 0, 0,Yv,rm,  0,rm")
14335           (match_operand:SI 2 "nonimm_or_0_operand"
14336           " rm,rm,rm,rm,Yr,*x,Yv, C,*ym, C")))]
14337   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
14338   "@
14339    pinsrd\t{$1, %2, %0|%0, %2, 1}
14340    pinsrd\t{$1, %2, %0|%0, %2, 1}
14341    vpinsrd\t{$1, %2, %1, %0|%0, %1, %2, 1}
14342    vpinsrd\t{$1, %2, %1, %0|%0, %1, %2, 1}
14343    punpckldq\t{%2, %0|%0, %2}
14344    punpckldq\t{%2, %0|%0, %2}
14345    vpunpckldq\t{%2, %1, %0|%0, %1, %2}
14346    %vmovd\t{%1, %0|%0, %1}
14347    punpckldq\t{%2, %0|%0, %2}
14348    movd\t{%1, %0|%0, %1}"
14349   [(set_attr "isa" "noavx,noavx,avx,avx512dq,noavx,noavx,avx,*,*,*")
14350    (set (attr "type")
14351      (cond [(eq_attr "alternative" "7")
14352               (const_string "ssemov")
14353             (eq_attr "alternative" "8")
14354               (const_string "mmxcvt")
14355             (eq_attr "alternative" "9")
14356               (const_string "mmxmov")
14357            ]
14358            (const_string "sselog")))
14359    (set (attr "prefix_extra")
14360      (if_then_else (eq_attr "alternative" "0,1,2,3")
14361                    (const_string "1")
14362                    (const_string "*")))
14363    (set (attr "length_immediate")
14364      (if_then_else (eq_attr "alternative" "0,1,2,3")
14365                    (const_string "1")
14366                    (const_string "*")))
14367    (set_attr "prefix" "orig,orig,vex,evex,orig,orig,maybe_evex,maybe_vex,orig,orig")
14368    (set_attr "mode" "TI,TI,TI,TI,TI,TI,TI,TI,DI,DI")])
14370 ;; ??? In theory we can match memory for the MMX alternative, but allowing
14371 ;; nonimmediate_operand for operand 2 and *not* allowing memory for the SSE
14372 ;; alternatives pretty much forces the MMX alternative to be chosen.
14373 (define_insn "*vec_concatv2si"
14374   [(set (match_operand:V2SI 0 "register_operand"     "=x,x ,*y,x,x,*y,*y")
14375         (vec_concat:V2SI
14376           (match_operand:SI 1 "nonimmediate_operand" " 0,rm,rm,0,m, 0,*rm")
14377           (match_operand:SI 2 "reg_or_0_operand"     " x,C ,C, x,C,*y,C")))]
14378   "TARGET_SSE && !TARGET_SSE4_1"
14379   "@
14380    punpckldq\t{%2, %0|%0, %2}
14381    movd\t{%1, %0|%0, %1}
14382    movd\t{%1, %0|%0, %1}
14383    unpcklps\t{%2, %0|%0, %2}
14384    movss\t{%1, %0|%0, %1}
14385    punpckldq\t{%2, %0|%0, %2}
14386    movd\t{%1, %0|%0, %1}"
14387   [(set_attr "isa" "sse2,sse2,sse2,*,*,*,*")
14388    (set_attr "type" "sselog,ssemov,mmxmov,sselog,ssemov,mmxcvt,mmxmov")
14389    (set_attr "mode" "TI,TI,DI,V4SF,SF,DI,DI")])
14391 (define_insn "*vec_concatv4si"
14392   [(set (match_operand:V4SI 0 "register_operand"       "=x,v,x,x,v")
14393         (vec_concat:V4SI
14394           (match_operand:V2SI 1 "register_operand"     " 0,v,0,0,v")
14395           (match_operand:V2SI 2 "nonimmediate_operand" " x,v,x,m,m")))]
14396   "TARGET_SSE"
14397   "@
14398    punpcklqdq\t{%2, %0|%0, %2}
14399    vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
14400    movlhps\t{%2, %0|%0, %2}
14401    movhps\t{%2, %0|%0, %q2}
14402    vmovhps\t{%2, %1, %0|%0, %1, %q2}"
14403   [(set_attr "isa" "sse2_noavx,avx,noavx,noavx,avx")
14404    (set_attr "type" "sselog,sselog,ssemov,ssemov,ssemov")
14405    (set_attr "prefix" "orig,maybe_evex,orig,orig,maybe_evex")
14406    (set_attr "mode" "TI,TI,V4SF,V2SF,V2SF")])
14408 ;; movd instead of movq is required to handle broken assemblers.
14409 (define_insn "vec_concatv2di"
14410   [(set (match_operand:V2DI 0 "register_operand"
14411           "=Yr,*x,x ,v ,v,v ,x   ,x,v ,x,x,v")
14412         (vec_concat:V2DI
14413           (match_operand:DI 1 "nonimmediate_operand"
14414           "  0, 0,x ,Yv,r,vm,?!*y,0,Yv,0,0,v")
14415           (match_operand:DI 2 "nonimm_or_0_operand"
14416           " rm,rm,rm,rm,C ,C ,C ,x,Yv,x,m,m")))]
14417   "TARGET_SSE"
14418   "@
14419    pinsrq\t{$1, %2, %0|%0, %2, 1}
14420    pinsrq\t{$1, %2, %0|%0, %2, 1}
14421    vpinsrq\t{$1, %2, %1, %0|%0, %1, %2, 1}
14422    vpinsrq\t{$1, %2, %1, %0|%0, %1, %2, 1}
14423    * return HAVE_AS_IX86_INTERUNIT_MOVQ ? \"%vmovq\t{%1, %0|%0, %1}\" : \"%vmovd\t{%1, %0|%0, %1}\";
14424    %vmovq\t{%1, %0|%0, %1}
14425    movq2dq\t{%1, %0|%0, %1}
14426    punpcklqdq\t{%2, %0|%0, %2}
14427    vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
14428    movlhps\t{%2, %0|%0, %2}
14429    movhps\t{%2, %0|%0, %2}
14430    vmovhps\t{%2, %1, %0|%0, %1, %2}"
14431   [(set (attr "isa")
14432      (cond [(eq_attr "alternative" "0,1")
14433               (const_string "x64_sse4_noavx")
14434             (eq_attr "alternative" "2")
14435               (const_string "x64_avx")
14436             (eq_attr "alternative" "3")
14437               (const_string "x64_avx512dq")
14438             (eq_attr "alternative" "4")
14439               (const_string "x64_sse2")
14440             (eq_attr "alternative" "5,6")
14441               (const_string "sse2")
14442             (eq_attr "alternative" "7")
14443               (const_string "sse2_noavx")
14444             (eq_attr "alternative" "8,11")
14445               (const_string "avx")
14446            ]
14447            (const_string "noavx")))
14448    (set (attr "type")
14449      (if_then_else
14450        (eq_attr "alternative" "0,1,2,3,7,8")
14451        (const_string "sselog")
14452        (const_string "ssemov")))
14453    (set (attr "prefix_rex")
14454      (if_then_else (eq_attr "alternative" "0,1,2,3,4")
14455                    (const_string "1")
14456                    (const_string "*")))
14457    (set (attr "prefix_extra")
14458      (if_then_else (eq_attr "alternative" "0,1,2,3")
14459                    (const_string "1")
14460                    (const_string "*")))
14461    (set (attr "length_immediate")
14462      (if_then_else (eq_attr "alternative" "0,1,2,3")
14463                    (const_string "1")
14464                    (const_string "*")))
14465    (set (attr "prefix")
14466      (cond [(eq_attr "alternative" "2")
14467               (const_string "vex")
14468             (eq_attr "alternative" "3")
14469               (const_string "evex")
14470             (eq_attr "alternative" "4,5")
14471               (const_string "maybe_vex")
14472             (eq_attr "alternative" "8,11")
14473               (const_string "maybe_evex")
14474            ]
14475            (const_string "orig")))
14476    (set_attr "mode" "TI,TI,TI,TI,TI,TI,TI,TI,TI,V4SF,V2SF,V2SF")
14477    (set (attr "preferred_for_speed")
14478      (cond [(eq_attr "alternative" "4")
14479               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
14480             (eq_attr "alternative" "6")
14481               (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
14482            ]
14483            (symbol_ref "true")))])
14485 ;; vmovq clears also the higher bits.
14486 (define_insn "vec_set<mode>_0"
14487   [(set (match_operand:VI8_AVX_AVX512F 0 "register_operand" "=v,v")
14488         (vec_merge:VI8_AVX_AVX512F
14489           (vec_duplicate:VI8_AVX_AVX512F
14490             (match_operand:<ssescalarmode> 2 "general_operand" "r,vm"))
14491           (match_operand:VI8_AVX_AVX512F 1 "const0_operand" "C,C")
14492           (const_int 1)))]
14493   "TARGET_AVX"
14494   "vmovq\t{%2, %x0|%x0, %2}"
14495   [(set_attr "isa" "x64,*")
14496    (set_attr "type" "ssemov")
14497    (set_attr "prefix_rex" "1,*")
14498    (set_attr "prefix" "maybe_evex")
14499    (set_attr "mode" "TI")
14500    (set (attr "preferred_for_speed")
14501      (cond [(eq_attr "alternative" "0")
14502               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
14503            ]
14504            (symbol_ref "true")))])
14506 (define_expand "vec_unpacks_lo_<mode>"
14507   [(match_operand:<sseunpackmode> 0 "register_operand")
14508    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
14509   "TARGET_SSE2"
14510   "ix86_expand_sse_unpack (operands[0], operands[1], false, false); DONE;")
14512 (define_expand "vec_unpacks_hi_<mode>"
14513   [(match_operand:<sseunpackmode> 0 "register_operand")
14514    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
14515   "TARGET_SSE2"
14516   "ix86_expand_sse_unpack (operands[0], operands[1], false, true); DONE;")
14518 (define_expand "vec_unpacku_lo_<mode>"
14519   [(match_operand:<sseunpackmode> 0 "register_operand")
14520    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
14521   "TARGET_SSE2"
14522   "ix86_expand_sse_unpack (operands[0], operands[1], true, false); DONE;")
14524 (define_expand "vec_unpacks_lo_hi"
14525   [(set (subreg:HI (match_operand:QI 0 "register_operand") 0)
14526         (match_operand:HI 1 "register_operand"))]
14527   "TARGET_AVX512F")
14529 (define_expand "vec_unpacks_lo_si"
14530   [(set (match_operand:HI 0 "register_operand")
14531         (subreg:HI (match_operand:SI 1 "register_operand") 0))]
14532   "TARGET_AVX512F")
14534 (define_expand "vec_unpacks_lo_di"
14535   [(set (match_operand:SI 0 "register_operand")
14536         (subreg:SI (match_operand:DI 1 "register_operand") 0))]
14537   "TARGET_AVX512BW")
14539 (define_expand "vec_unpacku_hi_<mode>"
14540   [(match_operand:<sseunpackmode> 0 "register_operand")
14541    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
14542   "TARGET_SSE2"
14543   "ix86_expand_sse_unpack (operands[0], operands[1], true, true); DONE;")
14545 (define_expand "vec_unpacks_hi_hi"
14546   [(parallel
14547      [(set (subreg:HI (match_operand:QI 0 "register_operand") 0)
14548            (lshiftrt:HI (match_operand:HI 1 "register_operand")
14549                         (const_int 8)))
14550       (unspec [(const_int 0)] UNSPEC_MASKOP)])]
14551   "TARGET_AVX512F")
14553 (define_expand "vec_unpacks_hi_<mode>"
14554   [(parallel
14555      [(set (subreg:SWI48x
14556              (match_operand:<HALFMASKMODE> 0 "register_operand") 0)
14557            (lshiftrt:SWI48x (match_operand:SWI48x 1 "register_operand")
14558                             (match_dup 2)))
14559       (unspec [(const_int 0)] UNSPEC_MASKOP)])]
14560   "TARGET_AVX512BW"
14561   "operands[2] = GEN_INT (GET_MODE_BITSIZE (<HALFMASKMODE>mode));")
14563 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14565 ;; Miscellaneous
14567 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14569 (define_expand "<sse2_avx2>_uavg<mode>3<mask_name>"
14570   [(set (match_operand:VI12_AVX2 0 "register_operand")
14571         (truncate:VI12_AVX2
14572           (lshiftrt:<ssedoublemode>
14573             (plus:<ssedoublemode>
14574               (plus:<ssedoublemode>
14575                 (zero_extend:<ssedoublemode>
14576                   (match_operand:VI12_AVX2 1 "vector_operand"))
14577                 (zero_extend:<ssedoublemode>
14578                   (match_operand:VI12_AVX2 2 "vector_operand")))
14579               (match_dup <mask_expand_op3>))
14580             (const_int 1))))]
14581   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
14583   operands[<mask_expand_op3>] = CONST1_RTX(<MODE>mode);
14584   ix86_fixup_binary_operands_no_copy (PLUS, <MODE>mode, operands);
14587 (define_insn "*<sse2_avx2>_uavg<mode>3<mask_name>"
14588   [(set (match_operand:VI12_AVX2 0 "register_operand" "=x,v")
14589         (truncate:VI12_AVX2
14590           (lshiftrt:<ssedoublemode>
14591             (plus:<ssedoublemode>
14592               (plus:<ssedoublemode>
14593                 (zero_extend:<ssedoublemode>
14594                   (match_operand:VI12_AVX2 1 "vector_operand" "%0,v"))
14595                 (zero_extend:<ssedoublemode>
14596                   (match_operand:VI12_AVX2 2 "vector_operand" "xBm,vm")))
14597               (match_operand:VI12_AVX2 <mask_expand_op3> "const1_operand"))
14598             (const_int 1))))]
14599   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
14600    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
14601   "@
14602    pavg<ssemodesuffix>\t{%2, %0|%0, %2}
14603    vpavg<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14604   [(set_attr "isa" "noavx,avx")
14605    (set_attr "type" "sseiadd")
14606    (set_attr "prefix_data16" "1,*")
14607    (set_attr "prefix" "orig,<mask_prefix>")
14608    (set_attr "mode" "<sseinsnmode>")])
14610 ;; The correct representation for this is absolutely enormous, and
14611 ;; surely not generally useful.
14612 (define_insn "<sse2_avx2>_psadbw"
14613   [(set (match_operand:VI8_AVX2_AVX512BW 0 "register_operand" "=x,v")
14614         (unspec:VI8_AVX2_AVX512BW
14615           [(match_operand:<ssebytemode> 1 "register_operand" "0,v")
14616            (match_operand:<ssebytemode> 2 "vector_operand" "xBm,vm")]
14617           UNSPEC_PSADBW))]
14618   "TARGET_SSE2"
14619   "@
14620    psadbw\t{%2, %0|%0, %2}
14621    vpsadbw\t{%2, %1, %0|%0, %1, %2}"
14622   [(set_attr "isa" "noavx,avx")
14623    (set_attr "type" "sseiadd")
14624    (set_attr "atom_unit" "simul")
14625    (set_attr "prefix_data16" "1,*")
14626    (set_attr "prefix" "orig,maybe_evex")
14627    (set_attr "mode" "<sseinsnmode>")])
14629 (define_insn "<sse>_movmsk<ssemodesuffix><avxsizesuffix>"
14630   [(set (match_operand:SI 0 "register_operand" "=r")
14631         (unspec:SI
14632           [(match_operand:VF_128_256 1 "register_operand" "x")]
14633           UNSPEC_MOVMSK))]
14634   "TARGET_SSE"
14635   "%vmovmsk<ssemodesuffix>\t{%1, %0|%0, %1}"
14636   [(set_attr "type" "ssemov")
14637    (set_attr "prefix" "maybe_vex")
14638    (set_attr "mode" "<MODE>")])
14640 (define_insn "*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_zext"
14641   [(set (match_operand:DI 0 "register_operand" "=r")
14642         (zero_extend:DI
14643           (unspec:SI
14644             [(match_operand:VF_128_256 1 "register_operand" "x")]
14645             UNSPEC_MOVMSK)))]
14646   "TARGET_64BIT && TARGET_SSE"
14647   "%vmovmsk<ssemodesuffix>\t{%1, %k0|%k0, %1}"
14648   [(set_attr "type" "ssemov")
14649    (set_attr "prefix" "maybe_vex")
14650    (set_attr "mode" "<MODE>")])
14652 (define_insn "<sse2_avx2>_pmovmskb"
14653   [(set (match_operand:SI 0 "register_operand" "=r")
14654         (unspec:SI
14655           [(match_operand:VI1_AVX2 1 "register_operand" "x")]
14656           UNSPEC_MOVMSK))]
14657   "TARGET_SSE2"
14658   "%vpmovmskb\t{%1, %0|%0, %1}"
14659   [(set_attr "type" "ssemov")
14660    (set (attr "prefix_data16")
14661      (if_then_else
14662        (match_test "TARGET_AVX")
14663      (const_string "*")
14664      (const_string "1")))
14665    (set_attr "prefix" "maybe_vex")
14666    (set_attr "mode" "SI")])
14668 (define_insn "*<sse2_avx2>_pmovmskb_zext"
14669   [(set (match_operand:DI 0 "register_operand" "=r")
14670         (zero_extend:DI
14671           (unspec:SI
14672             [(match_operand:VI1_AVX2 1 "register_operand" "x")]
14673             UNSPEC_MOVMSK)))]
14674   "TARGET_64BIT && TARGET_SSE2"
14675   "%vpmovmskb\t{%1, %k0|%k0, %1}"
14676   [(set_attr "type" "ssemov")
14677    (set (attr "prefix_data16")
14678      (if_then_else
14679        (match_test "TARGET_AVX")
14680      (const_string "*")
14681      (const_string "1")))
14682    (set_attr "prefix" "maybe_vex")
14683    (set_attr "mode" "SI")])
14685 (define_expand "sse2_maskmovdqu"
14686   [(set (match_operand:V16QI 0 "memory_operand")
14687         (unspec:V16QI [(match_operand:V16QI 1 "register_operand")
14688                        (match_operand:V16QI 2 "register_operand")
14689                        (match_dup 0)]
14690                       UNSPEC_MASKMOV))]
14691   "TARGET_SSE2")
14693 (define_insn "*sse2_maskmovdqu"
14694   [(set (mem:V16QI (match_operand:P 0 "register_operand" "D"))
14695         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "x")
14696                        (match_operand:V16QI 2 "register_operand" "x")
14697                        (mem:V16QI (match_dup 0))]
14698                       UNSPEC_MASKMOV))]
14699   "TARGET_SSE2"
14701   /* We can't use %^ here due to ASM_OUTPUT_OPCODE processing
14702      that requires %v to be at the beginning of the opcode name.  */
14703   if (Pmode != word_mode)
14704     fputs ("\taddr32", asm_out_file);
14705   return "%vmaskmovdqu\t{%2, %1|%1, %2}";
14707   [(set_attr "type" "ssemov")
14708    (set_attr "prefix_data16" "1")
14709    (set (attr "length_address")
14710      (symbol_ref ("Pmode != word_mode")))
14711    ;; The implicit %rdi operand confuses default length_vex computation.
14712    (set (attr "length_vex")
14713      (symbol_ref ("3 + REX_SSE_REGNO_P (REGNO (operands[2]))")))
14714    (set_attr "prefix" "maybe_vex")
14715    (set_attr "znver1_decode" "vector")
14716    (set_attr "mode" "TI")])
14718 (define_insn "sse_ldmxcsr"
14719   [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m")]
14720                     UNSPECV_LDMXCSR)]
14721   "TARGET_SSE"
14722   "%vldmxcsr\t%0"
14723   [(set_attr "type" "sse")
14724    (set_attr "atom_sse_attr" "mxcsr")
14725    (set_attr "prefix" "maybe_vex")
14726    (set_attr "memory" "load")])
14728 (define_insn "sse_stmxcsr"
14729   [(set (match_operand:SI 0 "memory_operand" "=m")
14730         (unspec_volatile:SI [(const_int 0)] UNSPECV_STMXCSR))]
14731   "TARGET_SSE"
14732   "%vstmxcsr\t%0"
14733   [(set_attr "type" "sse")
14734    (set_attr "atom_sse_attr" "mxcsr")
14735    (set_attr "prefix" "maybe_vex")
14736    (set_attr "memory" "store")])
14738 (define_insn "sse2_clflush"
14739   [(unspec_volatile [(match_operand 0 "address_operand" "p")]
14740                     UNSPECV_CLFLUSH)]
14741   "TARGET_SSE2"
14742   "clflush\t%a0"
14743   [(set_attr "type" "sse")
14744    (set_attr "atom_sse_attr" "fence")
14745    (set_attr "memory" "unknown")])
14747 ;; As per AMD and Intel ISA manuals, the first operand is extensions
14748 ;; and it goes to %ecx. The second operand received is hints and it goes
14749 ;; to %eax.
14750 (define_insn "sse3_mwait"
14751   [(unspec_volatile [(match_operand:SI 0 "register_operand" "c")
14752                      (match_operand:SI 1 "register_operand" "a")]
14753                     UNSPECV_MWAIT)]
14754   "TARGET_SSE3"
14755 ;; 64bit version is "mwait %rax,%rcx". But only lower 32bits are used.
14756 ;; Since 32bit register operands are implicitly zero extended to 64bit,
14757 ;; we only need to set up 32bit registers.
14758   "mwait"
14759   [(set_attr "length" "3")])
14761 (define_insn "sse3_monitor_<mode>"
14762   [(unspec_volatile [(match_operand:P 0 "register_operand" "a")
14763                      (match_operand:SI 1 "register_operand" "c")
14764                      (match_operand:SI 2 "register_operand" "d")]
14765                     UNSPECV_MONITOR)]
14766   "TARGET_SSE3"
14767 ;; 64bit version is "monitor %rax,%rcx,%rdx". But only lower 32bits in
14768 ;; RCX and RDX are used.  Since 32bit register operands are implicitly
14769 ;; zero extended to 64bit, we only need to set up 32bit registers.
14770   "%^monitor"
14771   [(set (attr "length")
14772      (symbol_ref ("(Pmode != word_mode) + 3")))])
14774 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14776 ;; SSSE3 instructions
14778 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14780 (define_code_iterator ssse3_plusminus [plus ss_plus minus ss_minus])
14782 (define_insn "avx2_ph<plusminus_mnemonic>wv16hi3"
14783   [(set (match_operand:V16HI 0 "register_operand" "=x")
14784         (vec_concat:V16HI
14785           (vec_concat:V8HI
14786             (vec_concat:V4HI
14787               (vec_concat:V2HI
14788                 (ssse3_plusminus:HI
14789                   (vec_select:HI
14790                     (match_operand:V16HI 1 "register_operand" "x")
14791                     (parallel [(const_int 0)]))
14792                   (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
14793                 (ssse3_plusminus:HI
14794                   (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
14795                   (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
14796               (vec_concat:V2HI
14797                 (ssse3_plusminus:HI
14798                   (vec_select:HI (match_dup 1) (parallel [(const_int 4)]))
14799                   (vec_select:HI (match_dup 1) (parallel [(const_int 5)])))
14800                 (ssse3_plusminus:HI
14801                   (vec_select:HI (match_dup 1) (parallel [(const_int 6)]))
14802                   (vec_select:HI (match_dup 1) (parallel [(const_int 7)])))))
14803             (vec_concat:V4HI
14804               (vec_concat:V2HI
14805                 (ssse3_plusminus:HI
14806                   (vec_select:HI (match_dup 1) (parallel [(const_int 8)]))
14807                   (vec_select:HI (match_dup 1) (parallel [(const_int 9)])))
14808                 (ssse3_plusminus:HI
14809                   (vec_select:HI (match_dup 1) (parallel [(const_int 10)]))
14810                   (vec_select:HI (match_dup 1) (parallel [(const_int 11)]))))
14811               (vec_concat:V2HI
14812                 (ssse3_plusminus:HI
14813                   (vec_select:HI (match_dup 1) (parallel [(const_int 12)]))
14814                   (vec_select:HI (match_dup 1) (parallel [(const_int 13)])))
14815                 (ssse3_plusminus:HI
14816                   (vec_select:HI (match_dup 1) (parallel [(const_int 14)]))
14817                   (vec_select:HI (match_dup 1) (parallel [(const_int 15)]))))))
14818           (vec_concat:V8HI
14819             (vec_concat:V4HI
14820               (vec_concat:V2HI
14821                 (ssse3_plusminus:HI
14822                   (vec_select:HI
14823                     (match_operand:V16HI 2 "nonimmediate_operand" "xm")
14824                     (parallel [(const_int 0)]))
14825                   (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
14826                 (ssse3_plusminus:HI
14827                   (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
14828                   (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))
14829               (vec_concat:V2HI
14830                 (ssse3_plusminus:HI
14831                   (vec_select:HI (match_dup 2) (parallel [(const_int 4)]))
14832                   (vec_select:HI (match_dup 2) (parallel [(const_int 5)])))
14833                 (ssse3_plusminus:HI
14834                   (vec_select:HI (match_dup 2) (parallel [(const_int 6)]))
14835                   (vec_select:HI (match_dup 2) (parallel [(const_int 7)])))))
14836             (vec_concat:V4HI
14837               (vec_concat:V2HI
14838                 (ssse3_plusminus:HI
14839                   (vec_select:HI (match_dup 2) (parallel [(const_int 8)]))
14840                   (vec_select:HI (match_dup 2) (parallel [(const_int 9)])))
14841                 (ssse3_plusminus:HI
14842                   (vec_select:HI (match_dup 2) (parallel [(const_int 10)]))
14843                   (vec_select:HI (match_dup 2) (parallel [(const_int 11)]))))
14844               (vec_concat:V2HI
14845                 (ssse3_plusminus:HI
14846                   (vec_select:HI (match_dup 2) (parallel [(const_int 12)]))
14847                   (vec_select:HI (match_dup 2) (parallel [(const_int 13)])))
14848                 (ssse3_plusminus:HI
14849                   (vec_select:HI (match_dup 2) (parallel [(const_int 14)]))
14850                   (vec_select:HI (match_dup 2) (parallel [(const_int 15)]))))))))]
14851   "TARGET_AVX2"
14852   "vph<plusminus_mnemonic>w\t{%2, %1, %0|%0, %1, %2}"
14853   [(set_attr "type" "sseiadd")
14854    (set_attr "prefix_extra" "1")
14855    (set_attr "prefix" "vex")
14856    (set_attr "mode" "OI")])
14858 (define_insn "ssse3_ph<plusminus_mnemonic>wv8hi3"
14859   [(set (match_operand:V8HI 0 "register_operand" "=x,x")
14860         (vec_concat:V8HI
14861           (vec_concat:V4HI
14862             (vec_concat:V2HI
14863               (ssse3_plusminus:HI
14864                 (vec_select:HI
14865                   (match_operand:V8HI 1 "register_operand" "0,x")
14866                   (parallel [(const_int 0)]))
14867                 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
14868               (ssse3_plusminus:HI
14869                 (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
14870                 (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
14871             (vec_concat:V2HI
14872               (ssse3_plusminus:HI
14873                 (vec_select:HI (match_dup 1) (parallel [(const_int 4)]))
14874                 (vec_select:HI (match_dup 1) (parallel [(const_int 5)])))
14875               (ssse3_plusminus:HI
14876                 (vec_select:HI (match_dup 1) (parallel [(const_int 6)]))
14877                 (vec_select:HI (match_dup 1) (parallel [(const_int 7)])))))
14878           (vec_concat:V4HI
14879             (vec_concat:V2HI
14880               (ssse3_plusminus:HI
14881                 (vec_select:HI
14882                   (match_operand:V8HI 2 "vector_operand" "xBm,xm")
14883                   (parallel [(const_int 0)]))
14884                 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
14885               (ssse3_plusminus:HI
14886                 (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
14887                 (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))
14888             (vec_concat:V2HI
14889               (ssse3_plusminus:HI
14890                 (vec_select:HI (match_dup 2) (parallel [(const_int 4)]))
14891                 (vec_select:HI (match_dup 2) (parallel [(const_int 5)])))
14892               (ssse3_plusminus:HI
14893                 (vec_select:HI (match_dup 2) (parallel [(const_int 6)]))
14894                 (vec_select:HI (match_dup 2) (parallel [(const_int 7)])))))))]
14895   "TARGET_SSSE3"
14896   "@
14897    ph<plusminus_mnemonic>w\t{%2, %0|%0, %2}
14898    vph<plusminus_mnemonic>w\t{%2, %1, %0|%0, %1, %2}"
14899   [(set_attr "isa" "noavx,avx")
14900    (set_attr "type" "sseiadd")
14901    (set_attr "atom_unit" "complex")
14902    (set_attr "prefix_data16" "1,*")
14903    (set_attr "prefix_extra" "1")
14904    (set_attr "prefix" "orig,vex")
14905    (set_attr "mode" "TI")])
14907 (define_insn "ssse3_ph<plusminus_mnemonic>wv4hi3"
14908   [(set (match_operand:V4HI 0 "register_operand" "=y")
14909         (vec_concat:V4HI
14910           (vec_concat:V2HI
14911             (ssse3_plusminus:HI
14912               (vec_select:HI
14913                 (match_operand:V4HI 1 "register_operand" "0")
14914                 (parallel [(const_int 0)]))
14915               (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
14916             (ssse3_plusminus:HI
14917               (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
14918               (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
14919           (vec_concat:V2HI
14920             (ssse3_plusminus:HI
14921               (vec_select:HI
14922                 (match_operand:V4HI 2 "nonimmediate_operand" "ym")
14923                 (parallel [(const_int 0)]))
14924               (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
14925             (ssse3_plusminus:HI
14926               (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
14927               (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))))]
14928   "TARGET_SSSE3"
14929   "ph<plusminus_mnemonic>w\t{%2, %0|%0, %2}"
14930   [(set_attr "type" "sseiadd")
14931    (set_attr "atom_unit" "complex")
14932    (set_attr "prefix_extra" "1")
14933    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14934    (set_attr "mode" "DI")])
14936 (define_insn "avx2_ph<plusminus_mnemonic>dv8si3"
14937   [(set (match_operand:V8SI 0 "register_operand" "=x")
14938         (vec_concat:V8SI
14939           (vec_concat:V4SI
14940             (vec_concat:V2SI
14941               (plusminus:SI
14942                 (vec_select:SI
14943                   (match_operand:V8SI 1 "register_operand" "x")
14944                   (parallel [(const_int 0)]))
14945                 (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
14946               (plusminus:SI
14947                 (vec_select:SI (match_dup 1) (parallel [(const_int 2)]))
14948                 (vec_select:SI (match_dup 1) (parallel [(const_int 3)]))))
14949             (vec_concat:V2SI
14950               (plusminus:SI
14951                 (vec_select:SI (match_dup 1) (parallel [(const_int 4)]))
14952                 (vec_select:SI (match_dup 1) (parallel [(const_int 5)])))
14953               (plusminus:SI
14954                 (vec_select:SI (match_dup 1) (parallel [(const_int 6)]))
14955                 (vec_select:SI (match_dup 1) (parallel [(const_int 7)])))))
14956           (vec_concat:V4SI
14957             (vec_concat:V2SI
14958               (plusminus:SI
14959                 (vec_select:SI
14960                   (match_operand:V8SI 2 "nonimmediate_operand" "xm")
14961                   (parallel [(const_int 0)]))
14962                 (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))
14963               (plusminus:SI
14964                 (vec_select:SI (match_dup 2) (parallel [(const_int 2)]))
14965                 (vec_select:SI (match_dup 2) (parallel [(const_int 3)]))))
14966             (vec_concat:V2SI
14967               (plusminus:SI
14968                 (vec_select:SI (match_dup 2) (parallel [(const_int 4)]))
14969                 (vec_select:SI (match_dup 2) (parallel [(const_int 5)])))
14970               (plusminus:SI
14971                 (vec_select:SI (match_dup 2) (parallel [(const_int 6)]))
14972                 (vec_select:SI (match_dup 2) (parallel [(const_int 7)])))))))]
14973   "TARGET_AVX2"
14974   "vph<plusminus_mnemonic>d\t{%2, %1, %0|%0, %1, %2}"
14975   [(set_attr "type" "sseiadd")
14976    (set_attr "prefix_extra" "1")
14977    (set_attr "prefix" "vex")
14978    (set_attr "mode" "OI")])
14980 (define_insn "ssse3_ph<plusminus_mnemonic>dv4si3"
14981   [(set (match_operand:V4SI 0 "register_operand" "=x,x")
14982         (vec_concat:V4SI
14983           (vec_concat:V2SI
14984             (plusminus:SI
14985               (vec_select:SI
14986                 (match_operand:V4SI 1 "register_operand" "0,x")
14987                 (parallel [(const_int 0)]))
14988               (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
14989             (plusminus:SI
14990               (vec_select:SI (match_dup 1) (parallel [(const_int 2)]))
14991               (vec_select:SI (match_dup 1) (parallel [(const_int 3)]))))
14992           (vec_concat:V2SI
14993             (plusminus:SI
14994               (vec_select:SI
14995                 (match_operand:V4SI 2 "vector_operand" "xBm,xm")
14996                 (parallel [(const_int 0)]))
14997               (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))
14998             (plusminus:SI
14999               (vec_select:SI (match_dup 2) (parallel [(const_int 2)]))
15000               (vec_select:SI (match_dup 2) (parallel [(const_int 3)]))))))]
15001   "TARGET_SSSE3"
15002   "@
15003    ph<plusminus_mnemonic>d\t{%2, %0|%0, %2}
15004    vph<plusminus_mnemonic>d\t{%2, %1, %0|%0, %1, %2}"
15005   [(set_attr "isa" "noavx,avx")
15006    (set_attr "type" "sseiadd")
15007    (set_attr "atom_unit" "complex")
15008    (set_attr "prefix_data16" "1,*")
15009    (set_attr "prefix_extra" "1")
15010    (set_attr "prefix" "orig,vex")
15011    (set_attr "mode" "TI")])
15013 (define_insn "ssse3_ph<plusminus_mnemonic>dv2si3"
15014   [(set (match_operand:V2SI 0 "register_operand" "=y")
15015         (vec_concat:V2SI
15016           (plusminus:SI
15017             (vec_select:SI
15018               (match_operand:V2SI 1 "register_operand" "0")
15019               (parallel [(const_int 0)]))
15020             (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
15021           (plusminus:SI
15022             (vec_select:SI
15023               (match_operand:V2SI 2 "nonimmediate_operand" "ym")
15024               (parallel [(const_int 0)]))
15025             (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))))]
15026   "TARGET_SSSE3"
15027   "ph<plusminus_mnemonic>d\t{%2, %0|%0, %2}"
15028   [(set_attr "type" "sseiadd")
15029    (set_attr "atom_unit" "complex")
15030    (set_attr "prefix_extra" "1")
15031    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15032    (set_attr "mode" "DI")])
15034 (define_insn "avx2_pmaddubsw256"
15035   [(set (match_operand:V16HI 0 "register_operand" "=x,v")
15036         (ss_plus:V16HI
15037           (mult:V16HI
15038             (zero_extend:V16HI
15039               (vec_select:V16QI
15040                 (match_operand:V32QI 1 "register_operand" "x,v")
15041                 (parallel [(const_int 0) (const_int 2)
15042                            (const_int 4) (const_int 6)
15043                            (const_int 8) (const_int 10)
15044                            (const_int 12) (const_int 14)
15045                            (const_int 16) (const_int 18)
15046                            (const_int 20) (const_int 22)
15047                            (const_int 24) (const_int 26)
15048                            (const_int 28) (const_int 30)])))
15049             (sign_extend:V16HI
15050               (vec_select:V16QI
15051                 (match_operand:V32QI 2 "nonimmediate_operand" "xm,vm")
15052                 (parallel [(const_int 0) (const_int 2)
15053                            (const_int 4) (const_int 6)
15054                            (const_int 8) (const_int 10)
15055                            (const_int 12) (const_int 14)
15056                            (const_int 16) (const_int 18)
15057                            (const_int 20) (const_int 22)
15058                            (const_int 24) (const_int 26)
15059                            (const_int 28) (const_int 30)]))))
15060           (mult:V16HI
15061             (zero_extend:V16HI
15062               (vec_select:V16QI (match_dup 1)
15063                 (parallel [(const_int 1) (const_int 3)
15064                            (const_int 5) (const_int 7)
15065                            (const_int 9) (const_int 11)
15066                            (const_int 13) (const_int 15)
15067                            (const_int 17) (const_int 19)
15068                            (const_int 21) (const_int 23)
15069                            (const_int 25) (const_int 27)
15070                            (const_int 29) (const_int 31)])))
15071             (sign_extend:V16HI
15072               (vec_select:V16QI (match_dup 2)
15073                 (parallel [(const_int 1) (const_int 3)
15074                            (const_int 5) (const_int 7)
15075                            (const_int 9) (const_int 11)
15076                            (const_int 13) (const_int 15)
15077                            (const_int 17) (const_int 19)
15078                            (const_int 21) (const_int 23)
15079                            (const_int 25) (const_int 27)
15080                            (const_int 29) (const_int 31)]))))))]
15081   "TARGET_AVX2"
15082   "vpmaddubsw\t{%2, %1, %0|%0, %1, %2}"
15083   [(set_attr "isa" "*,avx512bw")
15084    (set_attr "type" "sseiadd")
15085    (set_attr "prefix_extra" "1")
15086    (set_attr "prefix" "vex,evex")
15087    (set_attr "mode" "OI")])
15089 ;; The correct representation for this is absolutely enormous, and
15090 ;; surely not generally useful.
15091 (define_insn "avx512bw_pmaddubsw512<mode><mask_name>"
15092   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
15093           (unspec:VI2_AVX512VL
15094             [(match_operand:<dbpsadbwmode> 1 "register_operand" "v")
15095              (match_operand:<dbpsadbwmode> 2 "nonimmediate_operand" "vm")]
15096              UNSPEC_PMADDUBSW512))]
15097    "TARGET_AVX512BW"
15098    "vpmaddubsw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}";
15099   [(set_attr "type" "sseiadd")
15100    (set_attr "prefix" "evex")
15101    (set_attr "mode" "XI")])
15103 (define_insn "avx512bw_umulhrswv32hi3<mask_name>"
15104   [(set (match_operand:V32HI 0 "register_operand" "=v")
15105         (truncate:V32HI
15106           (lshiftrt:V32SI
15107             (plus:V32SI
15108               (lshiftrt:V32SI
15109                 (mult:V32SI
15110                   (sign_extend:V32SI
15111                     (match_operand:V32HI 1 "nonimmediate_operand" "%v"))
15112                   (sign_extend:V32SI
15113                     (match_operand:V32HI 2 "nonimmediate_operand" "vm")))
15114                 (const_int 14))
15115               (const_vector:V32HI [(const_int 1) (const_int 1)
15116                                    (const_int 1) (const_int 1)
15117                                    (const_int 1) (const_int 1)
15118                                    (const_int 1) (const_int 1)
15119                                    (const_int 1) (const_int 1)
15120                                    (const_int 1) (const_int 1)
15121                                    (const_int 1) (const_int 1)
15122                                    (const_int 1) (const_int 1)
15123                                    (const_int 1) (const_int 1)
15124                                    (const_int 1) (const_int 1)
15125                                    (const_int 1) (const_int 1)
15126                                    (const_int 1) (const_int 1)
15127                                    (const_int 1) (const_int 1)
15128                                    (const_int 1) (const_int 1)
15129                                    (const_int 1) (const_int 1)
15130                                    (const_int 1) (const_int 1)]))
15131             (const_int 1))))]
15132   "TARGET_AVX512BW"
15133   "vpmulhrsw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
15134   [(set_attr "type" "sseimul")
15135    (set_attr "prefix" "evex")
15136    (set_attr "mode" "XI")])
15138 (define_insn "ssse3_pmaddubsw128"
15139   [(set (match_operand:V8HI 0 "register_operand" "=x,x,v")
15140         (ss_plus:V8HI
15141           (mult:V8HI
15142             (zero_extend:V8HI
15143               (vec_select:V8QI
15144                 (match_operand:V16QI 1 "register_operand" "0,x,v")
15145                 (parallel [(const_int 0) (const_int 2)
15146                            (const_int 4) (const_int 6)
15147                            (const_int 8) (const_int 10)
15148                            (const_int 12) (const_int 14)])))
15149             (sign_extend:V8HI
15150               (vec_select:V8QI
15151                 (match_operand:V16QI 2 "vector_operand" "xBm,xm,vm")
15152                 (parallel [(const_int 0) (const_int 2)
15153                            (const_int 4) (const_int 6)
15154                            (const_int 8) (const_int 10)
15155                            (const_int 12) (const_int 14)]))))
15156           (mult:V8HI
15157             (zero_extend:V8HI
15158               (vec_select:V8QI (match_dup 1)
15159                 (parallel [(const_int 1) (const_int 3)
15160                            (const_int 5) (const_int 7)
15161                            (const_int 9) (const_int 11)
15162                            (const_int 13) (const_int 15)])))
15163             (sign_extend:V8HI
15164               (vec_select:V8QI (match_dup 2)
15165                 (parallel [(const_int 1) (const_int 3)
15166                            (const_int 5) (const_int 7)
15167                            (const_int 9) (const_int 11)
15168                            (const_int 13) (const_int 15)]))))))]
15169   "TARGET_SSSE3"
15170   "@
15171    pmaddubsw\t{%2, %0|%0, %2}
15172    vpmaddubsw\t{%2, %1, %0|%0, %1, %2}
15173    vpmaddubsw\t{%2, %1, %0|%0, %1, %2}"
15174   [(set_attr "isa" "noavx,avx,avx512bw")
15175    (set_attr "type" "sseiadd")
15176    (set_attr "atom_unit" "simul")
15177    (set_attr "prefix_data16" "1,*,*")
15178    (set_attr "prefix_extra" "1")
15179    (set_attr "prefix" "orig,vex,evex")
15180    (set_attr "mode" "TI")])
15182 (define_insn "ssse3_pmaddubsw"
15183   [(set (match_operand:V4HI 0 "register_operand" "=y")
15184         (ss_plus:V4HI
15185           (mult:V4HI
15186             (zero_extend:V4HI
15187               (vec_select:V4QI
15188                 (match_operand:V8QI 1 "register_operand" "0")
15189                 (parallel [(const_int 0) (const_int 2)
15190                            (const_int 4) (const_int 6)])))
15191             (sign_extend:V4HI
15192               (vec_select:V4QI
15193                 (match_operand:V8QI 2 "nonimmediate_operand" "ym")
15194                 (parallel [(const_int 0) (const_int 2)
15195                            (const_int 4) (const_int 6)]))))
15196           (mult:V4HI
15197             (zero_extend:V4HI
15198               (vec_select:V4QI (match_dup 1)
15199                 (parallel [(const_int 1) (const_int 3)
15200                            (const_int 5) (const_int 7)])))
15201             (sign_extend:V4HI
15202               (vec_select:V4QI (match_dup 2)
15203                 (parallel [(const_int 1) (const_int 3)
15204                            (const_int 5) (const_int 7)]))))))]
15205   "TARGET_SSSE3"
15206   "pmaddubsw\t{%2, %0|%0, %2}"
15207   [(set_attr "type" "sseiadd")
15208    (set_attr "atom_unit" "simul")
15209    (set_attr "prefix_extra" "1")
15210    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15211    (set_attr "mode" "DI")])
15213 (define_mode_iterator PMULHRSW
15214   [V4HI V8HI (V16HI "TARGET_AVX2")])
15216 (define_expand "<ssse3_avx2>_pmulhrsw<mode>3_mask"
15217   [(set (match_operand:PMULHRSW 0 "register_operand")
15218         (vec_merge:PMULHRSW
15219           (truncate:PMULHRSW
15220             (lshiftrt:<ssedoublemode>
15221               (plus:<ssedoublemode>
15222                 (lshiftrt:<ssedoublemode>
15223                   (mult:<ssedoublemode>
15224                     (sign_extend:<ssedoublemode>
15225                       (match_operand:PMULHRSW 1 "nonimmediate_operand"))
15226                     (sign_extend:<ssedoublemode>
15227                       (match_operand:PMULHRSW 2 "nonimmediate_operand")))
15228                   (const_int 14))
15229                 (match_dup 5))
15230               (const_int 1)))
15231           (match_operand:PMULHRSW 3 "register_operand")
15232           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
15233   "TARGET_AVX512BW && TARGET_AVX512VL"
15235   operands[5] = CONST1_RTX(<MODE>mode);
15236   ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
15239 (define_expand "<ssse3_avx2>_pmulhrsw<mode>3"
15240   [(set (match_operand:PMULHRSW 0 "register_operand")
15241         (truncate:PMULHRSW
15242           (lshiftrt:<ssedoublemode>
15243             (plus:<ssedoublemode>
15244               (lshiftrt:<ssedoublemode>
15245                 (mult:<ssedoublemode>
15246                   (sign_extend:<ssedoublemode>
15247                     (match_operand:PMULHRSW 1 "nonimmediate_operand"))
15248                   (sign_extend:<ssedoublemode>
15249                     (match_operand:PMULHRSW 2 "nonimmediate_operand")))
15250                 (const_int 14))
15251               (match_dup 3))
15252             (const_int 1))))]
15253   "TARGET_AVX2"
15255   operands[3] = CONST1_RTX(<MODE>mode);
15256   ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
15259 (define_insn "*<ssse3_avx2>_pmulhrsw<mode>3<mask_name>"
15260   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,x,v")
15261         (truncate:VI2_AVX2
15262           (lshiftrt:<ssedoublemode>
15263             (plus:<ssedoublemode>
15264               (lshiftrt:<ssedoublemode>
15265                 (mult:<ssedoublemode>
15266                   (sign_extend:<ssedoublemode>
15267                     (match_operand:VI2_AVX2 1 "vector_operand" "%0,x,v"))
15268                   (sign_extend:<ssedoublemode>
15269                     (match_operand:VI2_AVX2 2 "vector_operand" "xBm,xm,vm")))
15270                 (const_int 14))
15271               (match_operand:VI2_AVX2 3 "const1_operand"))
15272             (const_int 1))))]
15273   "TARGET_SSSE3 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
15274    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
15275   "@
15276    pmulhrsw\t{%2, %0|%0, %2}
15277    vpmulhrsw\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}
15278    vpmulhrsw\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}"
15279   [(set_attr "isa" "noavx,avx,avx512bw")
15280    (set_attr "type" "sseimul")
15281    (set_attr "prefix_data16" "1,*,*")
15282    (set_attr "prefix_extra" "1")
15283    (set_attr "prefix" "orig,maybe_evex,evex")
15284    (set_attr "mode" "<sseinsnmode>")])
15286 (define_insn "*ssse3_pmulhrswv4hi3"
15287   [(set (match_operand:V4HI 0 "register_operand" "=y")
15288         (truncate:V4HI
15289           (lshiftrt:V4SI
15290             (plus:V4SI
15291               (lshiftrt:V4SI
15292                 (mult:V4SI
15293                   (sign_extend:V4SI
15294                     (match_operand:V4HI 1 "nonimmediate_operand" "%0"))
15295                   (sign_extend:V4SI
15296                     (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
15297                 (const_int 14))
15298               (match_operand:V4HI 3 "const1_operand"))
15299             (const_int 1))))]
15300   "TARGET_SSSE3 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
15301   "pmulhrsw\t{%2, %0|%0, %2}"
15302   [(set_attr "type" "sseimul")
15303    (set_attr "prefix_extra" "1")
15304    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15305    (set_attr "mode" "DI")])
15307 (define_insn "<ssse3_avx2>_pshufb<mode>3<mask_name>"
15308   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x,v")
15309         (unspec:VI1_AVX512
15310           [(match_operand:VI1_AVX512 1 "register_operand" "0,x,v")
15311            (match_operand:VI1_AVX512 2 "vector_operand" "xBm,xm,vm")]
15312           UNSPEC_PSHUFB))]
15313   "TARGET_SSSE3 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
15314   "@
15315    pshufb\t{%2, %0|%0, %2}
15316    vpshufb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
15317    vpshufb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
15318   [(set_attr "isa" "noavx,avx,avx512bw")
15319    (set_attr "type" "sselog1")
15320    (set_attr "prefix_data16" "1,*,*")
15321    (set_attr "prefix_extra" "1")
15322    (set_attr "prefix" "orig,maybe_evex,evex")
15323    (set_attr "btver2_decode" "vector")
15324    (set_attr "mode" "<sseinsnmode>")])
15326 (define_insn "ssse3_pshufbv8qi3"
15327   [(set (match_operand:V8QI 0 "register_operand" "=y")
15328         (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "0")
15329                       (match_operand:V8QI 2 "nonimmediate_operand" "ym")]
15330                      UNSPEC_PSHUFB))]
15331   "TARGET_SSSE3"
15332   "pshufb\t{%2, %0|%0, %2}";
15333   [(set_attr "type" "sselog1")
15334    (set_attr "prefix_extra" "1")
15335    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15336    (set_attr "mode" "DI")])
15338 (define_insn "<ssse3_avx2>_psign<mode>3"
15339   [(set (match_operand:VI124_AVX2 0 "register_operand" "=x,x")
15340         (unspec:VI124_AVX2
15341           [(match_operand:VI124_AVX2 1 "register_operand" "0,x")
15342            (match_operand:VI124_AVX2 2 "vector_operand" "xBm,xm")]
15343           UNSPEC_PSIGN))]
15344   "TARGET_SSSE3"
15345   "@
15346    psign<ssemodesuffix>\t{%2, %0|%0, %2}
15347    vpsign<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
15348   [(set_attr "isa" "noavx,avx")
15349    (set_attr "type" "sselog1")
15350    (set_attr "prefix_data16" "1,*")
15351    (set_attr "prefix_extra" "1")
15352    (set_attr "prefix" "orig,vex")
15353    (set_attr "mode" "<sseinsnmode>")])
15355 (define_insn "ssse3_psign<mode>3"
15356   [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
15357         (unspec:MMXMODEI
15358           [(match_operand:MMXMODEI 1 "register_operand" "0")
15359            (match_operand:MMXMODEI 2 "nonimmediate_operand" "ym")]
15360           UNSPEC_PSIGN))]
15361   "TARGET_SSSE3"
15362   "psign<mmxvecsize>\t{%2, %0|%0, %2}";
15363   [(set_attr "type" "sselog1")
15364    (set_attr "prefix_extra" "1")
15365    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15366    (set_attr "mode" "DI")])
15368 (define_insn "<ssse3_avx2>_palignr<mode>_mask"
15369   [(set (match_operand:VI1_AVX512 0 "register_operand" "=v")
15370         (vec_merge:VI1_AVX512
15371           (unspec:VI1_AVX512
15372             [(match_operand:VI1_AVX512 1 "register_operand" "v")
15373              (match_operand:VI1_AVX512 2 "nonimmediate_operand" "vm")
15374              (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n")]
15375             UNSPEC_PALIGNR)
15376         (match_operand:VI1_AVX512 4 "nonimm_or_0_operand" "0C")
15377         (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
15378   "TARGET_AVX512BW && (<MODE_SIZE> == 64 || TARGET_AVX512VL)"
15380   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
15381   return "vpalignr\t{%3, %2, %1, %0%{%5%}%N4|%0%{%5%}%N4, %1, %2, %3}";
15383   [(set_attr "type" "sseishft")
15384    (set_attr "atom_unit" "sishuf")
15385    (set_attr "prefix_extra" "1")
15386    (set_attr "length_immediate" "1")
15387    (set_attr "prefix" "evex")
15388    (set_attr "mode" "<sseinsnmode>")])
15390 (define_insn "<ssse3_avx2>_palignr<mode>"
15391   [(set (match_operand:SSESCALARMODE 0 "register_operand" "=x,x,v")
15392         (unspec:SSESCALARMODE
15393           [(match_operand:SSESCALARMODE 1 "register_operand" "0,x,v")
15394            (match_operand:SSESCALARMODE 2 "vector_operand" "xBm,xm,vm")
15395            (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n,n,n")]
15396           UNSPEC_PALIGNR))]
15397   "TARGET_SSSE3"
15399   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
15401   switch (which_alternative)
15402     {
15403     case 0:
15404       return "palignr\t{%3, %2, %0|%0, %2, %3}";
15405     case 1:
15406     case 2:
15407       return "vpalignr\t{%3, %2, %1, %0|%0, %1, %2, %3}";
15408     default:
15409       gcc_unreachable ();
15410     }
15412   [(set_attr "isa" "noavx,avx,avx512bw")
15413    (set_attr "type" "sseishft")
15414    (set_attr "atom_unit" "sishuf")
15415    (set_attr "prefix_data16" "1,*,*")
15416    (set_attr "prefix_extra" "1")
15417    (set_attr "length_immediate" "1")
15418    (set_attr "prefix" "orig,vex,evex")
15419    (set_attr "mode" "<sseinsnmode>")])
15421 (define_insn "ssse3_palignrdi"
15422   [(set (match_operand:DI 0 "register_operand" "=y")
15423         (unspec:DI [(match_operand:DI 1 "register_operand" "0")
15424                     (match_operand:DI 2 "nonimmediate_operand" "ym")
15425                     (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n")]
15426                    UNSPEC_PALIGNR))]
15427   "TARGET_SSSE3"
15429   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
15430   return "palignr\t{%3, %2, %0|%0, %2, %3}";
15432   [(set_attr "type" "sseishft")
15433    (set_attr "atom_unit" "sishuf")
15434    (set_attr "prefix_extra" "1")
15435    (set_attr "length_immediate" "1")
15436    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15437    (set_attr "mode" "DI")])
15439 ;; Mode iterator to handle singularity w/ absence of V2DI and V4DI
15440 ;; modes for abs instruction on pre AVX-512 targets.
15441 (define_mode_iterator VI1248_AVX512VL_AVX512BW
15442   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
15443    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI
15444    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI
15445    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
15447 (define_insn "*abs<mode>2"
15448   [(set (match_operand:VI1248_AVX512VL_AVX512BW 0 "register_operand" "=v")
15449         (abs:VI1248_AVX512VL_AVX512BW
15450           (match_operand:VI1248_AVX512VL_AVX512BW 1 "vector_operand" "vBm")))]
15451   "TARGET_SSSE3"
15452   "%vpabs<ssemodesuffix>\t{%1, %0|%0, %1}"
15453   [(set_attr "type" "sselog1")
15454    (set_attr "prefix_data16" "1")
15455    (set_attr "prefix_extra" "1")
15456    (set_attr "prefix" "maybe_vex")
15457    (set_attr "mode" "<sseinsnmode>")])
15459 (define_insn "abs<mode>2_mask"
15460   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
15461         (vec_merge:VI48_AVX512VL
15462           (abs:VI48_AVX512VL
15463             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm"))
15464           (match_operand:VI48_AVX512VL 2 "nonimm_or_0_operand" "0C")
15465           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
15466   "TARGET_AVX512F"
15467   "vpabs<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15468   [(set_attr "type" "sselog1")
15469    (set_attr "prefix" "evex")
15470    (set_attr "mode" "<sseinsnmode>")])
15472 (define_insn "abs<mode>2_mask"
15473   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
15474         (vec_merge:VI12_AVX512VL
15475           (abs:VI12_AVX512VL
15476             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "vm"))
15477           (match_operand:VI12_AVX512VL 2 "nonimm_or_0_operand" "0C")
15478           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
15479   "TARGET_AVX512BW"
15480   "vpabs<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15481   [(set_attr "type" "sselog1")
15482    (set_attr "prefix" "evex")
15483    (set_attr "mode" "<sseinsnmode>")])
15485 (define_expand "abs<mode>2"
15486   [(set (match_operand:VI_AVX2 0 "register_operand")
15487         (abs:VI_AVX2
15488           (match_operand:VI_AVX2 1 "vector_operand")))]
15489   "TARGET_SSE2"
15491   if (!TARGET_SSSE3
15492       || ((<MODE>mode == V2DImode || <MODE>mode == V4DImode)
15493           && !TARGET_AVX512VL))
15494     {
15495       ix86_expand_sse2_abs (operands[0], operands[1]);
15496       DONE;
15497     }
15500 (define_insn "abs<mode>2"
15501   [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
15502         (abs:MMXMODEI
15503           (match_operand:MMXMODEI 1 "nonimmediate_operand" "ym")))]
15504   "TARGET_SSSE3"
15505   "pabs<mmxvecsize>\t{%1, %0|%0, %1}";
15506   [(set_attr "type" "sselog1")
15507    (set_attr "prefix_rep" "0")
15508    (set_attr "prefix_extra" "1")
15509    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15510    (set_attr "mode" "DI")])
15512 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15514 ;; AMD SSE4A instructions
15516 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15518 (define_insn "sse4a_movnt<mode>"
15519   [(set (match_operand:MODEF 0 "memory_operand" "=m")
15520         (unspec:MODEF
15521           [(match_operand:MODEF 1 "register_operand" "x")]
15522           UNSPEC_MOVNT))]
15523   "TARGET_SSE4A"
15524   "movnt<ssemodesuffix>\t{%1, %0|%0, %1}"
15525   [(set_attr "type" "ssemov")
15526    (set_attr "mode" "<MODE>")])
15528 (define_insn "sse4a_vmmovnt<mode>"
15529   [(set (match_operand:<ssescalarmode> 0 "memory_operand" "=m")
15530         (unspec:<ssescalarmode>
15531           [(vec_select:<ssescalarmode>
15532              (match_operand:VF_128 1 "register_operand" "x")
15533              (parallel [(const_int 0)]))]
15534           UNSPEC_MOVNT))]
15535   "TARGET_SSE4A"
15536   "movnt<ssescalarmodesuffix>\t{%1, %0|%0, %1}"
15537   [(set_attr "type" "ssemov")
15538    (set_attr "mode" "<ssescalarmode>")])
15540 (define_insn "sse4a_extrqi"
15541   [(set (match_operand:V2DI 0 "register_operand" "=x")
15542         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
15543                       (match_operand 2 "const_0_to_255_operand")
15544                       (match_operand 3 "const_0_to_255_operand")]
15545                      UNSPEC_EXTRQI))]
15546   "TARGET_SSE4A"
15547   "extrq\t{%3, %2, %0|%0, %2, %3}"
15548   [(set_attr "type" "sse")
15549    (set_attr "prefix_data16" "1")
15550    (set_attr "length_immediate" "2")
15551    (set_attr "mode" "TI")])
15553 (define_insn "sse4a_extrq"
15554   [(set (match_operand:V2DI 0 "register_operand" "=x")
15555         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
15556                       (match_operand:V16QI 2 "register_operand" "x")]
15557                      UNSPEC_EXTRQ))]
15558   "TARGET_SSE4A"
15559   "extrq\t{%2, %0|%0, %2}"
15560   [(set_attr "type" "sse")
15561    (set_attr "prefix_data16" "1")
15562    (set_attr "mode" "TI")])
15564 (define_insn "sse4a_insertqi"
15565   [(set (match_operand:V2DI 0 "register_operand" "=x")
15566         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
15567                       (match_operand:V2DI 2 "register_operand" "x")
15568                       (match_operand 3 "const_0_to_255_operand")
15569                       (match_operand 4 "const_0_to_255_operand")]
15570                      UNSPEC_INSERTQI))]
15571   "TARGET_SSE4A"
15572   "insertq\t{%4, %3, %2, %0|%0, %2, %3, %4}"
15573   [(set_attr "type" "sseins")
15574    (set_attr "prefix_data16" "0")
15575    (set_attr "prefix_rep" "1")
15576    (set_attr "length_immediate" "2")
15577    (set_attr "mode" "TI")])
15579 (define_insn "sse4a_insertq"
15580   [(set (match_operand:V2DI 0 "register_operand" "=x")
15581         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
15582                       (match_operand:V2DI 2 "register_operand" "x")]
15583                      UNSPEC_INSERTQ))]
15584   "TARGET_SSE4A"
15585   "insertq\t{%2, %0|%0, %2}"
15586   [(set_attr "type" "sseins")
15587    (set_attr "prefix_data16" "0")
15588    (set_attr "prefix_rep" "1")
15589    (set_attr "mode" "TI")])
15591 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15593 ;; Intel SSE4.1 instructions
15595 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15597 ;; Mapping of immediate bits for blend instructions
15598 (define_mode_attr blendbits
15599   [(V8SF "255") (V4SF "15") (V4DF "15") (V2DF "3")])
15601 (define_insn "<sse4_1>_blend<ssemodesuffix><avxsizesuffix>"
15602   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
15603         (vec_merge:VF_128_256
15604           (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
15605           (match_operand:VF_128_256 1 "register_operand" "0,0,x")
15606           (match_operand:SI 3 "const_0_to_<blendbits>_operand")))]
15607   "TARGET_SSE4_1"
15608   "@
15609    blend<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15610    blend<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15611    vblend<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15612   [(set_attr "isa" "noavx,noavx,avx")
15613    (set_attr "type" "ssemov")
15614    (set_attr "length_immediate" "1")
15615    (set_attr "prefix_data16" "1,1,*")
15616    (set_attr "prefix_extra" "1")
15617    (set_attr "prefix" "orig,orig,vex")
15618    (set_attr "mode" "<MODE>")])
15620 (define_insn "<sse4_1>_blendv<ssemodesuffix><avxsizesuffix>"
15621   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
15622         (unspec:VF_128_256
15623           [(match_operand:VF_128_256 1 "register_operand" "0,0,x")
15624            (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
15625            (match_operand:VF_128_256 3 "register_operand" "Yz,Yz,x")]
15626           UNSPEC_BLENDV))]
15627   "TARGET_SSE4_1"
15628   "@
15629    blendv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15630    blendv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15631    vblendv<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15632   [(set_attr "isa" "noavx,noavx,avx")
15633    (set_attr "type" "ssemov")
15634    (set_attr "length_immediate" "1")
15635    (set_attr "prefix_data16" "1,1,*")
15636    (set_attr "prefix_extra" "1")
15637    (set_attr "prefix" "orig,orig,vex")
15638    (set_attr "btver2_decode" "vector,vector,vector") 
15639    (set_attr "mode" "<MODE>")])
15641 (define_insn "<sse4_1>_dp<ssemodesuffix><avxsizesuffix>"
15642   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
15643         (unspec:VF_128_256
15644           [(match_operand:VF_128_256 1 "vector_operand" "%0,0,x")
15645            (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
15646            (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
15647           UNSPEC_DP))]
15648   "TARGET_SSE4_1"
15649   "@
15650    dp<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15651    dp<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15652    vdp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15653   [(set_attr "isa" "noavx,noavx,avx")
15654    (set_attr "type" "ssemul")
15655    (set_attr "length_immediate" "1")
15656    (set_attr "prefix_data16" "1,1,*")
15657    (set_attr "prefix_extra" "1")
15658    (set_attr "prefix" "orig,orig,vex")
15659    (set_attr "btver2_decode" "vector,vector,vector")
15660    (set_attr "znver1_decode" "vector,vector,vector")
15661    (set_attr "mode" "<MODE>")])
15663 ;; Mode attribute used by `vmovntdqa' pattern
15664 (define_mode_attr vi8_sse4_1_avx2_avx512
15665    [(V2DI "sse4_1") (V4DI "avx2") (V8DI "avx512f")])
15667 (define_insn "<vi8_sse4_1_avx2_avx512>_movntdqa"
15668   [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand" "=Yr,*x,v")
15669         (unspec:VI8_AVX2_AVX512F [(match_operand:VI8_AVX2_AVX512F 1 "memory_operand" "m,m,m")]
15670                      UNSPEC_MOVNTDQA))]
15671   "TARGET_SSE4_1"
15672   "%vmovntdqa\t{%1, %0|%0, %1}"
15673   [(set_attr "isa" "noavx,noavx,avx")
15674    (set_attr "type" "ssemov")
15675    (set_attr "prefix_extra" "1,1,*")
15676    (set_attr "prefix" "orig,orig,maybe_evex")
15677    (set_attr "mode" "<sseinsnmode>")])
15679 (define_insn "<sse4_1_avx2>_mpsadbw"
15680   [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
15681         (unspec:VI1_AVX2
15682           [(match_operand:VI1_AVX2 1 "register_operand" "0,0,x")
15683            (match_operand:VI1_AVX2 2 "vector_operand" "YrBm,*xBm,xm")
15684            (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
15685           UNSPEC_MPSADBW))]
15686   "TARGET_SSE4_1"
15687   "@
15688    mpsadbw\t{%3, %2, %0|%0, %2, %3}
15689    mpsadbw\t{%3, %2, %0|%0, %2, %3}
15690    vmpsadbw\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15691   [(set_attr "isa" "noavx,noavx,avx")
15692    (set_attr "type" "sselog1")
15693    (set_attr "length_immediate" "1")
15694    (set_attr "prefix_extra" "1")
15695    (set_attr "prefix" "orig,orig,vex")
15696    (set_attr "btver2_decode" "vector,vector,vector")
15697    (set_attr "znver1_decode" "vector,vector,vector")
15698    (set_attr "mode" "<sseinsnmode>")])
15700 (define_insn "<sse4_1_avx2>_packusdw<mask_name>"
15701   [(set (match_operand:VI2_AVX2 0 "register_operand" "=Yr,*x,x,v")
15702         (vec_concat:VI2_AVX2
15703           (us_truncate:<ssehalfvecmode>
15704             (match_operand:<sseunpackmode> 1 "register_operand" "0,0,x,v"))
15705           (us_truncate:<ssehalfvecmode>
15706             (match_operand:<sseunpackmode> 2 "vector_operand" "YrBm,*xBm,xm,vm"))))]
15707   "TARGET_SSE4_1 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
15708   "@
15709    packusdw\t{%2, %0|%0, %2}
15710    packusdw\t{%2, %0|%0, %2}
15711    vpackusdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
15712    vpackusdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
15713   [(set_attr "isa" "noavx,noavx,avx,avx512bw")
15714    (set_attr "type" "sselog")
15715    (set_attr "prefix_extra" "1")
15716    (set_attr "prefix" "orig,orig,<mask_prefix>,evex")
15717    (set_attr "mode" "<sseinsnmode>")])
15719 (define_insn "<sse4_1_avx2>_pblendvb"
15720   [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
15721         (unspec:VI1_AVX2
15722           [(match_operand:VI1_AVX2 1 "register_operand"  "0,0,x")
15723            (match_operand:VI1_AVX2 2 "vector_operand" "YrBm,*xBm,xm")
15724            (match_operand:VI1_AVX2 3 "register_operand" "Yz,Yz,x")]
15725           UNSPEC_BLENDV))]
15726   "TARGET_SSE4_1"
15727   "@
15728    pblendvb\t{%3, %2, %0|%0, %2, %3}
15729    pblendvb\t{%3, %2, %0|%0, %2, %3}
15730    vpblendvb\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15731   [(set_attr "isa" "noavx,noavx,avx")
15732    (set_attr "type" "ssemov")
15733    (set_attr "prefix_extra" "1")
15734    (set_attr "length_immediate" "*,*,1")
15735    (set_attr "prefix" "orig,orig,vex")
15736    (set_attr "btver2_decode" "vector,vector,vector")
15737    (set_attr "mode" "<sseinsnmode>")])
15739 (define_insn "sse4_1_pblendw"
15740   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,x")
15741         (vec_merge:V8HI
15742           (match_operand:V8HI 2 "vector_operand" "YrBm,*xBm,xm")
15743           (match_operand:V8HI 1 "register_operand" "0,0,x")
15744           (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")))]
15745   "TARGET_SSE4_1"
15746   "@
15747    pblendw\t{%3, %2, %0|%0, %2, %3}
15748    pblendw\t{%3, %2, %0|%0, %2, %3}
15749    vpblendw\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15750   [(set_attr "isa" "noavx,noavx,avx")
15751    (set_attr "type" "ssemov")
15752    (set_attr "prefix_extra" "1")
15753    (set_attr "length_immediate" "1")
15754    (set_attr "prefix" "orig,orig,vex")
15755    (set_attr "mode" "TI")])
15757 ;; The builtin uses an 8-bit immediate.  Expand that.
15758 (define_expand "avx2_pblendw"
15759   [(set (match_operand:V16HI 0 "register_operand")
15760         (vec_merge:V16HI
15761           (match_operand:V16HI 2 "nonimmediate_operand")
15762           (match_operand:V16HI 1 "register_operand")
15763           (match_operand:SI 3 "const_0_to_255_operand")))]
15764   "TARGET_AVX2"
15766   HOST_WIDE_INT val = INTVAL (operands[3]) & 0xff;
15767   operands[3] = GEN_INT (val << 8 | val);
15770 (define_insn "*avx2_pblendw"
15771   [(set (match_operand:V16HI 0 "register_operand" "=x")
15772         (vec_merge:V16HI
15773           (match_operand:V16HI 2 "nonimmediate_operand" "xm")
15774           (match_operand:V16HI 1 "register_operand" "x")
15775           (match_operand:SI 3 "avx2_pblendw_operand" "n")))]
15776   "TARGET_AVX2"
15778   operands[3] = GEN_INT (INTVAL (operands[3]) & 0xff);
15779   return "vpblendw\t{%3, %2, %1, %0|%0, %1, %2, %3}";
15781   [(set_attr "type" "ssemov")
15782    (set_attr "prefix_extra" "1")
15783    (set_attr "length_immediate" "1")
15784    (set_attr "prefix" "vex")
15785    (set_attr "mode" "OI")])
15787 (define_insn "avx2_pblendd<mode>"
15788   [(set (match_operand:VI4_AVX2 0 "register_operand" "=x")
15789         (vec_merge:VI4_AVX2
15790           (match_operand:VI4_AVX2 2 "nonimmediate_operand" "xm")
15791           (match_operand:VI4_AVX2 1 "register_operand" "x")
15792           (match_operand:SI 3 "const_0_to_255_operand" "n")))]
15793   "TARGET_AVX2"
15794   "vpblendd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15795   [(set_attr "type" "ssemov")
15796    (set_attr "prefix_extra" "1")
15797    (set_attr "length_immediate" "1")
15798    (set_attr "prefix" "vex")
15799    (set_attr "mode" "<sseinsnmode>")])
15801 (define_insn "sse4_1_phminposuw"
15802   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,x")
15803         (unspec:V8HI [(match_operand:V8HI 1 "vector_operand" "YrBm,*xBm,xm")]
15804                      UNSPEC_PHMINPOSUW))]
15805   "TARGET_SSE4_1"
15806   "%vphminposuw\t{%1, %0|%0, %1}"
15807   [(set_attr "isa" "noavx,noavx,avx")
15808    (set_attr "type" "sselog1")
15809    (set_attr "prefix_extra" "1")
15810    (set_attr "prefix" "orig,orig,vex")
15811    (set_attr "mode" "TI")])
15813 (define_insn "avx2_<code>v16qiv16hi2<mask_name>"
15814   [(set (match_operand:V16HI 0 "register_operand" "=v")
15815         (any_extend:V16HI
15816           (match_operand:V16QI 1 "nonimmediate_operand" "vm")))]
15817   "TARGET_AVX2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
15818   "vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15819   [(set_attr "type" "ssemov")
15820    (set_attr "prefix_extra" "1")
15821    (set_attr "prefix" "maybe_evex")
15822    (set_attr "mode" "OI")])
15824 (define_insn "avx512bw_<code>v32qiv32hi2<mask_name>"
15825   [(set (match_operand:V32HI 0 "register_operand" "=v")
15826         (any_extend:V32HI
15827           (match_operand:V32QI 1 "nonimmediate_operand" "vm")))]
15828   "TARGET_AVX512BW"
15829   "vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15830   [(set_attr "type" "ssemov")
15831    (set_attr "prefix_extra" "1")
15832    (set_attr "prefix" "evex")
15833    (set_attr "mode" "XI")])
15835 (define_insn "sse4_1_<code>v8qiv8hi2<mask_name>"
15836   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,v")
15837         (any_extend:V8HI
15838           (vec_select:V8QI
15839             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15840             (parallel [(const_int 0) (const_int 1)
15841                        (const_int 2) (const_int 3)
15842                        (const_int 4) (const_int 5)
15843                        (const_int 6) (const_int 7)]))))]
15844   "TARGET_SSE4_1 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
15845   "%vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15846   [(set_attr "isa" "noavx,noavx,avx")
15847    (set_attr "type" "ssemov")
15848    (set_attr "prefix_extra" "1")
15849    (set_attr "prefix" "orig,orig,maybe_evex")
15850    (set_attr "mode" "TI")])
15852 (define_insn "<mask_codefor>avx512f_<code>v16qiv16si2<mask_name>"
15853   [(set (match_operand:V16SI 0 "register_operand" "=v")
15854         (any_extend:V16SI
15855           (match_operand:V16QI 1 "nonimmediate_operand" "vm")))]
15856   "TARGET_AVX512F"
15857   "vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15858   [(set_attr "type" "ssemov")
15859    (set_attr "prefix" "evex")
15860    (set_attr "mode" "XI")])
15862 (define_insn "avx2_<code>v8qiv8si2<mask_name>"
15863   [(set (match_operand:V8SI 0 "register_operand" "=v")
15864         (any_extend:V8SI
15865           (vec_select:V8QI
15866             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
15867             (parallel [(const_int 0) (const_int 1)
15868                        (const_int 2) (const_int 3)
15869                        (const_int 4) (const_int 5)
15870                        (const_int 6) (const_int 7)]))))]
15871   "TARGET_AVX2 && <mask_avx512vl_condition>"
15872   "vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15873   [(set_attr "type" "ssemov")
15874    (set_attr "prefix_extra" "1")
15875    (set_attr "prefix" "maybe_evex")
15876    (set_attr "mode" "OI")])
15878 (define_insn "sse4_1_<code>v4qiv4si2<mask_name>"
15879   [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
15880         (any_extend:V4SI
15881           (vec_select:V4QI
15882             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15883             (parallel [(const_int 0) (const_int 1)
15884                        (const_int 2) (const_int 3)]))))]
15885   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15886   "%vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15887   [(set_attr "isa" "noavx,noavx,avx")
15888    (set_attr "type" "ssemov")
15889    (set_attr "prefix_extra" "1")
15890    (set_attr "prefix" "orig,orig,maybe_evex")
15891    (set_attr "mode" "TI")])
15893 (define_insn "avx512f_<code>v16hiv16si2<mask_name>"
15894   [(set (match_operand:V16SI 0 "register_operand" "=v")
15895         (any_extend:V16SI
15896           (match_operand:V16HI 1 "nonimmediate_operand" "vm")))]
15897   "TARGET_AVX512F"
15898   "vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15899   [(set_attr "type" "ssemov")
15900    (set_attr "prefix" "evex")
15901    (set_attr "mode" "XI")])
15903 (define_insn "avx2_<code>v8hiv8si2<mask_name>"
15904   [(set (match_operand:V8SI 0 "register_operand" "=v")
15905         (any_extend:V8SI
15906             (match_operand:V8HI 1 "nonimmediate_operand" "vm")))]
15907   "TARGET_AVX2 && <mask_avx512vl_condition>"
15908   "vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15909   [(set_attr "type" "ssemov")
15910    (set_attr "prefix_extra" "1")
15911    (set_attr "prefix" "maybe_evex")
15912    (set_attr "mode" "OI")])
15914 (define_insn "sse4_1_<code>v4hiv4si2<mask_name>"
15915   [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
15916         (any_extend:V4SI
15917           (vec_select:V4HI
15918             (match_operand:V8HI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15919             (parallel [(const_int 0) (const_int 1)
15920                        (const_int 2) (const_int 3)]))))]
15921   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15922   "%vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15923   [(set_attr "isa" "noavx,noavx,avx")
15924    (set_attr "type" "ssemov")
15925    (set_attr "prefix_extra" "1")
15926    (set_attr "prefix" "orig,orig,maybe_evex")
15927    (set_attr "mode" "TI")])
15929 (define_insn "avx512f_<code>v8qiv8di2<mask_name>"
15930   [(set (match_operand:V8DI 0 "register_operand" "=v")
15931         (any_extend:V8DI
15932           (vec_select:V8QI
15933             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
15934             (parallel [(const_int 0) (const_int 1)
15935                        (const_int 2) (const_int 3)
15936                        (const_int 4) (const_int 5)
15937                        (const_int 6) (const_int 7)]))))]
15938   "TARGET_AVX512F"
15939   "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15940   [(set_attr "type" "ssemov")
15941    (set_attr "prefix" "evex")
15942    (set_attr "mode" "XI")])
15944 (define_insn "avx2_<code>v4qiv4di2<mask_name>"
15945   [(set (match_operand:V4DI 0 "register_operand" "=v")
15946         (any_extend:V4DI
15947           (vec_select:V4QI
15948             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
15949             (parallel [(const_int 0) (const_int 1)
15950                        (const_int 2) (const_int 3)]))))]
15951   "TARGET_AVX2 && <mask_avx512vl_condition>"
15952   "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15953   [(set_attr "type" "ssemov")
15954    (set_attr "prefix_extra" "1")
15955    (set_attr "prefix" "maybe_evex")
15956    (set_attr "mode" "OI")])
15958 (define_insn "sse4_1_<code>v2qiv2di2<mask_name>"
15959   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
15960         (any_extend:V2DI
15961           (vec_select:V2QI
15962             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15963             (parallel [(const_int 0) (const_int 1)]))))]
15964   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15965   "%vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %w1}"
15966   [(set_attr "isa" "noavx,noavx,avx")
15967    (set_attr "type" "ssemov")
15968    (set_attr "prefix_extra" "1")
15969    (set_attr "prefix" "orig,orig,maybe_evex")
15970    (set_attr "mode" "TI")])
15972 (define_insn "avx512f_<code>v8hiv8di2<mask_name>"
15973   [(set (match_operand:V8DI 0 "register_operand" "=v")
15974         (any_extend:V8DI
15975           (match_operand:V8HI 1 "nonimmediate_operand" "vm")))]
15976   "TARGET_AVX512F"
15977   "vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15978   [(set_attr "type" "ssemov")
15979    (set_attr "prefix" "evex")
15980    (set_attr "mode" "XI")])
15982 (define_insn "avx2_<code>v4hiv4di2<mask_name>"
15983   [(set (match_operand:V4DI 0 "register_operand" "=v")
15984         (any_extend:V4DI
15985           (vec_select:V4HI
15986             (match_operand:V8HI 1 "nonimmediate_operand" "vm")
15987             (parallel [(const_int 0) (const_int 1)
15988                        (const_int 2) (const_int 3)]))))]
15989   "TARGET_AVX2 && <mask_avx512vl_condition>"
15990   "vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15991   [(set_attr "type" "ssemov")
15992    (set_attr "prefix_extra" "1")
15993    (set_attr "prefix" "maybe_evex")
15994    (set_attr "mode" "OI")])
15996 (define_insn "sse4_1_<code>v2hiv2di2<mask_name>"
15997   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
15998         (any_extend:V2DI
15999           (vec_select:V2HI
16000             (match_operand:V8HI 1 "nonimmediate_operand" "Yrm,*xm,vm")
16001             (parallel [(const_int 0) (const_int 1)]))))]
16002   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
16003   "%vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
16004   [(set_attr "isa" "noavx,noavx,avx")
16005    (set_attr "type" "ssemov")
16006    (set_attr "prefix_extra" "1")
16007    (set_attr "prefix" "orig,orig,maybe_evex")
16008    (set_attr "mode" "TI")])
16010 (define_insn "avx512f_<code>v8siv8di2<mask_name>"
16011   [(set (match_operand:V8DI 0 "register_operand" "=v")
16012         (any_extend:V8DI
16013           (match_operand:V8SI 1 "nonimmediate_operand" "vm")))]
16014   "TARGET_AVX512F"
16015   "vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
16016   [(set_attr "type" "ssemov")
16017    (set_attr "prefix" "evex")
16018    (set_attr "mode" "XI")])
16020 (define_insn "avx2_<code>v4siv4di2<mask_name>"
16021   [(set (match_operand:V4DI 0 "register_operand" "=v")
16022         (any_extend:V4DI
16023             (match_operand:V4SI 1 "nonimmediate_operand" "vm")))]
16024   "TARGET_AVX2 && <mask_avx512vl_condition>"
16025   "vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
16026   [(set_attr "type" "ssemov")
16027    (set_attr "prefix" "maybe_evex")
16028    (set_attr "prefix_extra" "1")
16029    (set_attr "mode" "OI")])
16031 (define_insn "sse4_1_<code>v2siv2di2<mask_name>"
16032   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
16033         (any_extend:V2DI
16034           (vec_select:V2SI
16035             (match_operand:V4SI 1 "nonimmediate_operand" "Yrm,*xm,vm")
16036             (parallel [(const_int 0) (const_int 1)]))))]
16037   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
16038   "%vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
16039   [(set_attr "isa" "noavx,noavx,avx")
16040    (set_attr "type" "ssemov")
16041    (set_attr "prefix_extra" "1")
16042    (set_attr "prefix" "orig,orig,maybe_evex")
16043    (set_attr "mode" "TI")])
16045 ;; ptestps/ptestpd are very similar to comiss and ucomiss when
16046 ;; setting FLAGS_REG. But it is not a really compare instruction.
16047 (define_insn "avx_vtest<ssemodesuffix><avxsizesuffix>"
16048   [(set (reg:CC FLAGS_REG)
16049         (unspec:CC [(match_operand:VF_128_256 0 "register_operand" "x")
16050                     (match_operand:VF_128_256 1 "nonimmediate_operand" "xm")]
16051                    UNSPEC_VTESTP))]
16052   "TARGET_AVX"
16053   "vtest<ssemodesuffix>\t{%1, %0|%0, %1}"
16054   [(set_attr "type" "ssecomi")
16055    (set_attr "prefix_extra" "1")
16056    (set_attr "prefix" "vex")
16057    (set_attr "mode" "<MODE>")])
16059 ;; ptest is very similar to comiss and ucomiss when setting FLAGS_REG.
16060 ;; But it is not a really compare instruction.
16061 (define_insn "<sse4_1>_ptest<mode>"
16062   [(set (reg:CC FLAGS_REG)
16063         (unspec:CC [(match_operand:V_AVX 0 "register_operand" "Yr, *x, x")
16064                     (match_operand:V_AVX 1 "vector_operand" "YrBm, *xBm, xm")]
16065                    UNSPEC_PTEST))]
16066   "TARGET_SSE4_1"
16067   "%vptest\t{%1, %0|%0, %1}"
16068   [(set_attr "isa" "noavx,noavx,avx")
16069    (set_attr "type" "ssecomi")
16070    (set_attr "prefix_extra" "1")
16071    (set_attr "prefix" "orig,orig,vex")
16072    (set (attr "btver2_decode")
16073      (if_then_else
16074        (match_test "<sseinsnmode>mode==OImode")
16075      (const_string "vector")
16076      (const_string "*")))
16077    (set_attr "mode" "<sseinsnmode>")])
16079 (define_insn "ptesttf2"
16080   [(set (reg:CC FLAGS_REG)
16081         (unspec:CC [(match_operand:TF 0 "register_operand" "Yr, *x, x")
16082                     (match_operand:TF 1 "vector_operand" "YrBm, *xBm, xm")]
16083                    UNSPEC_PTEST))]
16084   "TARGET_SSE4_1"
16085   "%vptest\t{%1, %0|%0, %1}"
16086   [(set_attr "isa" "noavx,noavx,avx")
16087    (set_attr "type" "ssecomi")
16088    (set_attr "prefix_extra" "1")
16089    (set_attr "prefix" "orig,orig,vex")
16090    (set_attr "mode" "TI")])
16092 (define_insn "<sse4_1>_round<ssemodesuffix><avxsizesuffix>"
16093   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
16094         (unspec:VF_128_256
16095           [(match_operand:VF_128_256 1 "vector_operand" "YrBm,*xBm,xm")
16096            (match_operand:SI 2 "const_0_to_15_operand" "n,n,n")]
16097           UNSPEC_ROUND))]
16098   "TARGET_SSE4_1"
16099   "%vround<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16100   [(set_attr "isa" "noavx,noavx,avx")
16101    (set_attr "type" "ssecvt")
16102    (set_attr "prefix_data16" "1,1,*")
16103    (set_attr "prefix_extra" "1")
16104    (set_attr "length_immediate" "1")
16105    (set_attr "prefix" "orig,orig,vex")
16106    (set_attr "mode" "<MODE>")])
16108 (define_expand "<sse4_1>_round<ssemodesuffix>_sfix<avxsizesuffix>"
16109   [(match_operand:<sseintvecmode> 0 "register_operand")
16110    (match_operand:VF1_128_256 1 "vector_operand")
16111    (match_operand:SI 2 "const_0_to_15_operand")]
16112   "TARGET_SSE4_1"
16114   rtx tmp = gen_reg_rtx (<MODE>mode);
16116   emit_insn
16117     (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp, operands[1],
16118                                                        operands[2]));
16119   emit_insn
16120     (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
16121   DONE;
16124 (define_expand "avx512f_round<castmode>512"
16125   [(match_operand:VF_512 0 "register_operand")
16126    (match_operand:VF_512 1 "nonimmediate_operand")
16127    (match_operand:SI 2 "const_0_to_15_operand")]
16128   "TARGET_AVX512F"
16130   emit_insn (gen_avx512f_rndscale<mode> (operands[0], operands[1], operands[2]));
16131   DONE;
16134 (define_expand "avx512f_roundps512_sfix"
16135   [(match_operand:V16SI 0 "register_operand")
16136    (match_operand:V16SF 1 "nonimmediate_operand")
16137    (match_operand:SI 2 "const_0_to_15_operand")]
16138   "TARGET_AVX512F"
16140   rtx tmp = gen_reg_rtx (V16SFmode);
16141   emit_insn (gen_avx512f_rndscalev16sf (tmp, operands[1], operands[2]));
16142   emit_insn (gen_fix_truncv16sfv16si2 (operands[0], tmp));
16143   DONE;
16146 (define_expand "<sse4_1>_round<ssemodesuffix>_vec_pack_sfix<avxsizesuffix>"
16147   [(match_operand:<ssepackfltmode> 0 "register_operand")
16148    (match_operand:VF2 1 "vector_operand")
16149    (match_operand:VF2 2 "vector_operand")
16150    (match_operand:SI 3 "const_0_to_15_operand")]
16151   "TARGET_SSE4_1"
16153   rtx tmp0, tmp1;
16155   if (<MODE>mode == V2DFmode
16156       && TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
16157     {
16158       rtx tmp2 = gen_reg_rtx (V4DFmode);
16160       tmp0 = gen_reg_rtx (V4DFmode);
16161       tmp1 = force_reg (V2DFmode, operands[1]);
16163       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
16164       emit_insn (gen_avx_roundpd256 (tmp2, tmp0, operands[3]));
16165       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp2));
16166     }
16167   else
16168     {
16169       tmp0 = gen_reg_rtx (<MODE>mode);
16170       tmp1 = gen_reg_rtx (<MODE>mode);
16172       emit_insn
16173        (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp0, operands[1],
16174                                                           operands[3]));
16175       emit_insn
16176        (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp1, operands[2],
16177                                                           operands[3]));
16178       emit_insn
16179        (gen_vec_pack_sfix_trunc_<mode> (operands[0], tmp0, tmp1));
16180     }
16181   DONE;
16184 (define_insn "sse4_1_round<ssescalarmodesuffix>"
16185   [(set (match_operand:VF_128 0 "register_operand" "=Yr,*x,x,v")
16186         (vec_merge:VF_128
16187           (unspec:VF_128
16188             [(match_operand:VF_128 2 "register_operand" "Yr,*x,x,v")
16189              (match_operand:SI 3 "const_0_to_15_operand" "n,n,n,n")]
16190             UNSPEC_ROUND)
16191           (match_operand:VF_128 1 "register_operand" "0,0,x,v")
16192           (const_int 1)))]
16193   "TARGET_SSE4_1"
16194   "@
16195    round<ssescalarmodesuffix>\t{%3, %2, %0|%0, %2, %3}
16196    round<ssescalarmodesuffix>\t{%3, %2, %0|%0, %2, %3}
16197    vround<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
16198    vrndscale<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16199   [(set_attr "isa" "noavx,noavx,avx,avx512f")
16200    (set_attr "type" "ssecvt")
16201    (set_attr "length_immediate" "1")
16202    (set_attr "prefix_data16" "1,1,*,*")
16203    (set_attr "prefix_extra" "1")
16204    (set_attr "prefix" "orig,orig,vex,evex")
16205    (set_attr "mode" "<MODE>")])
16207 (define_expand "round<mode>2"
16208   [(set (match_dup 3)
16209         (plus:VF
16210           (match_operand:VF 1 "register_operand")
16211           (match_dup 2)))
16212    (set (match_operand:VF 0 "register_operand")
16213         (unspec:VF
16214           [(match_dup 3) (match_dup 4)]
16215           UNSPEC_ROUND))]
16216   "TARGET_SSE4_1 && !flag_trapping_math"
16218   machine_mode scalar_mode;
16219   const struct real_format *fmt;
16220   REAL_VALUE_TYPE pred_half, half_minus_pred_half;
16221   rtx half, vec_half;
16223   scalar_mode = GET_MODE_INNER (<MODE>mode);
16225   /* load nextafter (0.5, 0.0) */
16226   fmt = REAL_MODE_FORMAT (scalar_mode);
16227   real_2expN (&half_minus_pred_half, -(fmt->p) - 1, scalar_mode);
16228   real_arithmetic (&pred_half, MINUS_EXPR, &dconsthalf, &half_minus_pred_half);
16229   half = const_double_from_real_value (pred_half, scalar_mode);
16231   vec_half = ix86_build_const_vector (<MODE>mode, true, half);
16232   vec_half = force_reg (<MODE>mode, vec_half);
16234   operands[2] = gen_reg_rtx (<MODE>mode);
16235   emit_insn (gen_copysign<mode>3 (operands[2], vec_half, operands[1]));
16237   operands[3] = gen_reg_rtx (<MODE>mode);
16238   operands[4] = GEN_INT (ROUND_TRUNC);
16241 (define_expand "round<mode>2_sfix"
16242   [(match_operand:<sseintvecmode> 0 "register_operand")
16243    (match_operand:VF1 1 "register_operand")]
16244   "TARGET_SSE4_1 && !flag_trapping_math"
16246   rtx tmp = gen_reg_rtx (<MODE>mode);
16248   emit_insn (gen_round<mode>2 (tmp, operands[1]));
16250   emit_insn
16251     (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
16252   DONE;
16255 (define_expand "round<mode>2_vec_pack_sfix"
16256   [(match_operand:<ssepackfltmode> 0 "register_operand")
16257    (match_operand:VF2 1 "register_operand")
16258    (match_operand:VF2 2 "register_operand")]
16259   "TARGET_SSE4_1 && !flag_trapping_math"
16261   rtx tmp0, tmp1;
16263   if (<MODE>mode == V2DFmode
16264       && TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
16265     {
16266       rtx tmp2 = gen_reg_rtx (V4DFmode);
16268       tmp0 = gen_reg_rtx (V4DFmode);
16269       tmp1 = force_reg (V2DFmode, operands[1]);
16271       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
16272       emit_insn (gen_roundv4df2 (tmp2, tmp0));
16273       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp2));
16274     }
16275   else
16276     {
16277       tmp0 = gen_reg_rtx (<MODE>mode);
16278       tmp1 = gen_reg_rtx (<MODE>mode);
16280       emit_insn (gen_round<mode>2 (tmp0, operands[1]));
16281       emit_insn (gen_round<mode>2 (tmp1, operands[2]));
16283       emit_insn
16284        (gen_vec_pack_sfix_trunc_<mode> (operands[0], tmp0, tmp1));
16285     }
16286   DONE;
16289 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16291 ;; Intel SSE4.2 string/text processing instructions
16293 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16295 (define_insn_and_split "sse4_2_pcmpestr"
16296   [(set (match_operand:SI 0 "register_operand" "=c,c")
16297         (unspec:SI
16298           [(match_operand:V16QI 2 "register_operand" "x,x")
16299            (match_operand:SI 3 "register_operand" "a,a")
16300            (match_operand:V16QI 4 "nonimmediate_operand" "x,m")
16301            (match_operand:SI 5 "register_operand" "d,d")
16302            (match_operand:SI 6 "const_0_to_255_operand" "n,n")]
16303           UNSPEC_PCMPESTR))
16304    (set (match_operand:V16QI 1 "register_operand" "=Yz,Yz")
16305         (unspec:V16QI
16306           [(match_dup 2)
16307            (match_dup 3)
16308            (match_dup 4)
16309            (match_dup 5)
16310            (match_dup 6)]
16311           UNSPEC_PCMPESTR))
16312    (set (reg:CC FLAGS_REG)
16313         (unspec:CC
16314           [(match_dup 2)
16315            (match_dup 3)
16316            (match_dup 4)
16317            (match_dup 5)
16318            (match_dup 6)]
16319           UNSPEC_PCMPESTR))]
16320   "TARGET_SSE4_2
16321    && can_create_pseudo_p ()"
16322   "#"
16323   "&& 1"
16324   [(const_int 0)]
16326   int ecx = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[0]));
16327   int xmm0 = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[1]));
16328   int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
16330   if (ecx)
16331     emit_insn (gen_sse4_2_pcmpestri (operands[0], operands[2],
16332                                      operands[3], operands[4],
16333                                      operands[5], operands[6]));
16334   if (xmm0)
16335     emit_insn (gen_sse4_2_pcmpestrm (operands[1], operands[2],
16336                                      operands[3], operands[4],
16337                                      operands[5], operands[6]));
16338   if (flags && !(ecx || xmm0))
16339     emit_insn (gen_sse4_2_pcmpestr_cconly (NULL, NULL,
16340                                            operands[2], operands[3],
16341                                            operands[4], operands[5],
16342                                            operands[6]));
16343   if (!(flags || ecx || xmm0))
16344     emit_note (NOTE_INSN_DELETED);
16346   DONE;
16348   [(set_attr "type" "sselog")
16349    (set_attr "prefix_data16" "1")
16350    (set_attr "prefix_extra" "1")
16351    (set_attr "length_immediate" "1")
16352    (set_attr "memory" "none,load")
16353    (set_attr "mode" "TI")])
16355 (define_insn "sse4_2_pcmpestri"
16356   [(set (match_operand:SI 0 "register_operand" "=c,c")
16357         (unspec:SI
16358           [(match_operand:V16QI 1 "register_operand" "x,x")
16359            (match_operand:SI 2 "register_operand" "a,a")
16360            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
16361            (match_operand:SI 4 "register_operand" "d,d")
16362            (match_operand:SI 5 "const_0_to_255_operand" "n,n")]
16363           UNSPEC_PCMPESTR))
16364    (set (reg:CC FLAGS_REG)
16365         (unspec:CC
16366           [(match_dup 1)
16367            (match_dup 2)
16368            (match_dup 3)
16369            (match_dup 4)
16370            (match_dup 5)]
16371           UNSPEC_PCMPESTR))]
16372   "TARGET_SSE4_2"
16373   "%vpcmpestri\t{%5, %3, %1|%1, %3, %5}"
16374   [(set_attr "type" "sselog")
16375    (set_attr "prefix_data16" "1")
16376    (set_attr "prefix_extra" "1")
16377    (set_attr "prefix" "maybe_vex")
16378    (set_attr "length_immediate" "1")
16379    (set_attr "btver2_decode" "vector")
16380    (set_attr "memory" "none,load")
16381    (set_attr "mode" "TI")])
16383 (define_insn "sse4_2_pcmpestrm"
16384   [(set (match_operand:V16QI 0 "register_operand" "=Yz,Yz")
16385         (unspec:V16QI
16386           [(match_operand:V16QI 1 "register_operand" "x,x")
16387            (match_operand:SI 2 "register_operand" "a,a")
16388            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
16389            (match_operand:SI 4 "register_operand" "d,d")
16390            (match_operand:SI 5 "const_0_to_255_operand" "n,n")]
16391           UNSPEC_PCMPESTR))
16392    (set (reg:CC FLAGS_REG)
16393         (unspec:CC
16394           [(match_dup 1)
16395            (match_dup 2)
16396            (match_dup 3)
16397            (match_dup 4)
16398            (match_dup 5)]
16399           UNSPEC_PCMPESTR))]
16400   "TARGET_SSE4_2"
16401   "%vpcmpestrm\t{%5, %3, %1|%1, %3, %5}"
16402   [(set_attr "type" "sselog")
16403    (set_attr "prefix_data16" "1")
16404    (set_attr "prefix_extra" "1")
16405    (set_attr "length_immediate" "1")
16406    (set_attr "prefix" "maybe_vex")
16407    (set_attr "btver2_decode" "vector")
16408    (set_attr "memory" "none,load")
16409    (set_attr "mode" "TI")])
16411 (define_insn "sse4_2_pcmpestr_cconly"
16412   [(set (reg:CC FLAGS_REG)
16413         (unspec:CC
16414           [(match_operand:V16QI 2 "register_operand" "x,x,x,x")
16415            (match_operand:SI 3 "register_operand" "a,a,a,a")
16416            (match_operand:V16QI 4 "nonimmediate_operand" "x,m,x,m")
16417            (match_operand:SI 5 "register_operand" "d,d,d,d")
16418            (match_operand:SI 6 "const_0_to_255_operand" "n,n,n,n")]
16419           UNSPEC_PCMPESTR))
16420    (clobber (match_scratch:V16QI 0 "=Yz,Yz,X,X"))
16421    (clobber (match_scratch:SI    1 "= X, X,c,c"))]
16422   "TARGET_SSE4_2"
16423   "@
16424    %vpcmpestrm\t{%6, %4, %2|%2, %4, %6}
16425    %vpcmpestrm\t{%6, %4, %2|%2, %4, %6}
16426    %vpcmpestri\t{%6, %4, %2|%2, %4, %6}
16427    %vpcmpestri\t{%6, %4, %2|%2, %4, %6}"
16428   [(set_attr "type" "sselog")
16429    (set_attr "prefix_data16" "1")
16430    (set_attr "prefix_extra" "1")
16431    (set_attr "length_immediate" "1")
16432    (set_attr "memory" "none,load,none,load")
16433    (set_attr "btver2_decode" "vector,vector,vector,vector") 
16434    (set_attr "prefix" "maybe_vex")
16435    (set_attr "mode" "TI")])
16437 (define_insn_and_split "sse4_2_pcmpistr"
16438   [(set (match_operand:SI 0 "register_operand" "=c,c")
16439         (unspec:SI
16440           [(match_operand:V16QI 2 "register_operand" "x,x")
16441            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
16442            (match_operand:SI 4 "const_0_to_255_operand" "n,n")]
16443           UNSPEC_PCMPISTR))
16444    (set (match_operand:V16QI 1 "register_operand" "=Yz,Yz")
16445         (unspec:V16QI
16446           [(match_dup 2)
16447            (match_dup 3)
16448            (match_dup 4)]
16449           UNSPEC_PCMPISTR))
16450    (set (reg:CC FLAGS_REG)
16451         (unspec:CC
16452           [(match_dup 2)
16453            (match_dup 3)
16454            (match_dup 4)]
16455           UNSPEC_PCMPISTR))]
16456   "TARGET_SSE4_2
16457    && can_create_pseudo_p ()"
16458   "#"
16459   "&& 1"
16460   [(const_int 0)]
16462   int ecx = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[0]));
16463   int xmm0 = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[1]));
16464   int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
16466   if (ecx)
16467     emit_insn (gen_sse4_2_pcmpistri (operands[0], operands[2],
16468                                      operands[3], operands[4]));
16469   if (xmm0)
16470     emit_insn (gen_sse4_2_pcmpistrm (operands[1], operands[2],
16471                                      operands[3], operands[4]));
16472   if (flags && !(ecx || xmm0))
16473     emit_insn (gen_sse4_2_pcmpistr_cconly (NULL, NULL,
16474                                            operands[2], operands[3],
16475                                            operands[4]));
16476   if (!(flags || ecx || xmm0))
16477     emit_note (NOTE_INSN_DELETED);
16479   DONE;
16481   [(set_attr "type" "sselog")
16482    (set_attr "prefix_data16" "1")
16483    (set_attr "prefix_extra" "1")
16484    (set_attr "length_immediate" "1")
16485    (set_attr "memory" "none,load")
16486    (set_attr "mode" "TI")])
16488 (define_insn "sse4_2_pcmpistri"
16489   [(set (match_operand:SI 0 "register_operand" "=c,c")
16490         (unspec:SI
16491           [(match_operand:V16QI 1 "register_operand" "x,x")
16492            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
16493            (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
16494           UNSPEC_PCMPISTR))
16495    (set (reg:CC FLAGS_REG)
16496         (unspec:CC
16497           [(match_dup 1)
16498            (match_dup 2)
16499            (match_dup 3)]
16500           UNSPEC_PCMPISTR))]
16501   "TARGET_SSE4_2"
16502   "%vpcmpistri\t{%3, %2, %1|%1, %2, %3}"
16503   [(set_attr "type" "sselog")
16504    (set_attr "prefix_data16" "1")
16505    (set_attr "prefix_extra" "1")
16506    (set_attr "length_immediate" "1")
16507    (set_attr "prefix" "maybe_vex")
16508    (set_attr "memory" "none,load")
16509    (set_attr "btver2_decode" "vector")
16510    (set_attr "mode" "TI")])
16512 (define_insn "sse4_2_pcmpistrm"
16513   [(set (match_operand:V16QI 0 "register_operand" "=Yz,Yz")
16514         (unspec:V16QI
16515           [(match_operand:V16QI 1 "register_operand" "x,x")
16516            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
16517            (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
16518           UNSPEC_PCMPISTR))
16519    (set (reg:CC FLAGS_REG)
16520         (unspec:CC
16521           [(match_dup 1)
16522            (match_dup 2)
16523            (match_dup 3)]
16524           UNSPEC_PCMPISTR))]
16525   "TARGET_SSE4_2"
16526   "%vpcmpistrm\t{%3, %2, %1|%1, %2, %3}"
16527   [(set_attr "type" "sselog")
16528    (set_attr "prefix_data16" "1")
16529    (set_attr "prefix_extra" "1")
16530    (set_attr "length_immediate" "1")
16531    (set_attr "prefix" "maybe_vex")
16532    (set_attr "memory" "none,load")
16533    (set_attr "btver2_decode" "vector")
16534    (set_attr "mode" "TI")])
16536 (define_insn "sse4_2_pcmpistr_cconly"
16537   [(set (reg:CC FLAGS_REG)
16538         (unspec:CC
16539           [(match_operand:V16QI 2 "register_operand" "x,x,x,x")
16540            (match_operand:V16QI 3 "nonimmediate_operand" "x,m,x,m")
16541            (match_operand:SI 4 "const_0_to_255_operand" "n,n,n,n")]
16542           UNSPEC_PCMPISTR))
16543    (clobber (match_scratch:V16QI 0 "=Yz,Yz,X,X"))
16544    (clobber (match_scratch:SI    1 "= X, X,c,c"))]
16545   "TARGET_SSE4_2"
16546   "@
16547    %vpcmpistrm\t{%4, %3, %2|%2, %3, %4}
16548    %vpcmpistrm\t{%4, %3, %2|%2, %3, %4}
16549    %vpcmpistri\t{%4, %3, %2|%2, %3, %4}
16550    %vpcmpistri\t{%4, %3, %2|%2, %3, %4}"
16551   [(set_attr "type" "sselog")
16552    (set_attr "prefix_data16" "1")
16553    (set_attr "prefix_extra" "1")
16554    (set_attr "length_immediate" "1")
16555    (set_attr "memory" "none,load,none,load")
16556    (set_attr "prefix" "maybe_vex")
16557    (set_attr "btver2_decode" "vector,vector,vector,vector")
16558    (set_attr "mode" "TI")])
16560 ;; Packed float variants
16561 (define_mode_attr GATHER_SCATTER_SF_MEM_MODE
16562                       [(V8DI "V8SF") (V16SI "V16SF")])
16564 (define_expand "avx512pf_gatherpf<mode>sf"
16565   [(unspec
16566      [(match_operand:<avx512fmaskmode> 0 "register_operand")
16567       (mem:<GATHER_SCATTER_SF_MEM_MODE>
16568         (match_par_dup 5
16569           [(match_operand 2 "vsib_address_operand")
16570            (match_operand:VI48_512 1 "register_operand")
16571            (match_operand:SI 3 "const1248_operand")]))
16572       (match_operand:SI 4 "const_2_to_3_operand")]
16573      UNSPEC_GATHER_PREFETCH)]
16574   "TARGET_AVX512PF"
16576   operands[5]
16577     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
16578                                         operands[3]), UNSPEC_VSIBADDR);
16581 (define_insn "*avx512pf_gatherpf<mode>sf_mask"
16582   [(unspec
16583      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
16584       (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 5 "vsib_mem_operator"
16585         [(unspec:P
16586            [(match_operand:P 2 "vsib_address_operand" "Tv")
16587             (match_operand:VI48_512 1 "register_operand" "v")
16588             (match_operand:SI 3 "const1248_operand" "n")]
16589            UNSPEC_VSIBADDR)])
16590       (match_operand:SI 4 "const_2_to_3_operand" "n")]
16591      UNSPEC_GATHER_PREFETCH)]
16592   "TARGET_AVX512PF"
16594   switch (INTVAL (operands[4]))
16595     {
16596     case 3:
16597       return "vgatherpf0<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
16598     case 2:
16599       return "vgatherpf1<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
16600     default:
16601       gcc_unreachable ();
16602     }
16604   [(set_attr "type" "sse")
16605    (set_attr "prefix" "evex")
16606    (set_attr "mode" "XI")])
16608 ;; Packed double variants
16609 (define_expand "avx512pf_gatherpf<mode>df"
16610   [(unspec
16611      [(match_operand:<avx512fmaskmode> 0 "register_operand")
16612       (mem:V8DF
16613         (match_par_dup 5
16614           [(match_operand 2 "vsib_address_operand")
16615            (match_operand:VI4_256_8_512 1 "register_operand")
16616            (match_operand:SI 3 "const1248_operand")]))
16617       (match_operand:SI 4 "const_2_to_3_operand")]
16618      UNSPEC_GATHER_PREFETCH)]
16619   "TARGET_AVX512PF"
16621   operands[5]
16622     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
16623                                         operands[3]), UNSPEC_VSIBADDR);
16626 (define_insn "*avx512pf_gatherpf<mode>df_mask"
16627   [(unspec
16628      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
16629       (match_operator:V8DF 5 "vsib_mem_operator"
16630         [(unspec:P
16631            [(match_operand:P 2 "vsib_address_operand" "Tv")
16632             (match_operand:VI4_256_8_512 1 "register_operand" "v")
16633             (match_operand:SI 3 "const1248_operand" "n")]
16634            UNSPEC_VSIBADDR)])
16635       (match_operand:SI 4 "const_2_to_3_operand" "n")]
16636      UNSPEC_GATHER_PREFETCH)]
16637   "TARGET_AVX512PF"
16639   switch (INTVAL (operands[4]))
16640     {
16641     case 3:
16642       return "vgatherpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
16643     case 2:
16644       return "vgatherpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
16645     default:
16646       gcc_unreachable ();
16647     }
16649   [(set_attr "type" "sse")
16650    (set_attr "prefix" "evex")
16651    (set_attr "mode" "XI")])
16653 ;; Packed float variants
16654 (define_expand "avx512pf_scatterpf<mode>sf"
16655   [(unspec
16656      [(match_operand:<avx512fmaskmode> 0 "register_operand")
16657       (mem:<GATHER_SCATTER_SF_MEM_MODE>
16658         (match_par_dup 5
16659           [(match_operand 2 "vsib_address_operand")
16660            (match_operand:VI48_512 1 "register_operand")
16661            (match_operand:SI 3 "const1248_operand")]))
16662       (match_operand:SI 4 "const2367_operand")]
16663      UNSPEC_SCATTER_PREFETCH)]
16664   "TARGET_AVX512PF"
16666   operands[5]
16667     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
16668                                         operands[3]), UNSPEC_VSIBADDR);
16671 (define_insn "*avx512pf_scatterpf<mode>sf_mask"
16672   [(unspec
16673      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
16674       (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 5 "vsib_mem_operator"
16675         [(unspec:P
16676            [(match_operand:P 2 "vsib_address_operand" "Tv")
16677             (match_operand:VI48_512 1 "register_operand" "v")
16678             (match_operand:SI 3 "const1248_operand" "n")]
16679            UNSPEC_VSIBADDR)])
16680       (match_operand:SI 4 "const2367_operand" "n")]
16681      UNSPEC_SCATTER_PREFETCH)]
16682   "TARGET_AVX512PF"
16684   switch (INTVAL (operands[4]))
16685     {
16686     case 3:
16687     case 7:
16688       return "vscatterpf0<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
16689     case 2:
16690     case 6:
16691       return "vscatterpf1<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
16692     default:
16693       gcc_unreachable ();
16694     }
16696   [(set_attr "type" "sse")
16697    (set_attr "prefix" "evex")
16698    (set_attr "mode" "XI")])
16700 ;; Packed double variants
16701 (define_expand "avx512pf_scatterpf<mode>df"
16702   [(unspec
16703      [(match_operand:<avx512fmaskmode> 0 "register_operand")
16704       (mem:V8DF
16705         (match_par_dup 5
16706           [(match_operand 2 "vsib_address_operand")
16707            (match_operand:VI4_256_8_512 1 "register_operand")
16708            (match_operand:SI 3 "const1248_operand")]))
16709       (match_operand:SI 4 "const2367_operand")]
16710      UNSPEC_SCATTER_PREFETCH)]
16711   "TARGET_AVX512PF"
16713   operands[5]
16714     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
16715                                         operands[3]), UNSPEC_VSIBADDR);
16718 (define_insn "*avx512pf_scatterpf<mode>df_mask"
16719   [(unspec
16720      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
16721       (match_operator:V8DF 5 "vsib_mem_operator"
16722         [(unspec:P
16723            [(match_operand:P 2 "vsib_address_operand" "Tv")
16724             (match_operand:VI4_256_8_512 1 "register_operand" "v")
16725             (match_operand:SI 3 "const1248_operand" "n")]
16726            UNSPEC_VSIBADDR)])
16727       (match_operand:SI 4 "const2367_operand" "n")]
16728      UNSPEC_SCATTER_PREFETCH)]
16729   "TARGET_AVX512PF"
16731   switch (INTVAL (operands[4]))
16732     {
16733     case 3:
16734     case 7:
16735       return "vscatterpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
16736     case 2:
16737     case 6:
16738       return "vscatterpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
16739     default:
16740       gcc_unreachable ();
16741     }
16743   [(set_attr "type" "sse")
16744    (set_attr "prefix" "evex")
16745    (set_attr "mode" "XI")])
16747 (define_insn "avx512er_exp2<mode><mask_name><round_saeonly_name>"
16748   [(set (match_operand:VF_512 0 "register_operand" "=v")
16749         (unspec:VF_512
16750           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16751           UNSPEC_EXP2))]
16752   "TARGET_AVX512ER"
16753   "vexp2<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
16754   [(set_attr "prefix" "evex")
16755    (set_attr "type" "sse")
16756    (set_attr "mode" "<MODE>")])
16758 (define_insn "<mask_codefor>avx512er_rcp28<mode><mask_name><round_saeonly_name>"
16759   [(set (match_operand:VF_512 0 "register_operand" "=v")
16760         (unspec:VF_512
16761           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16762           UNSPEC_RCP28))]
16763   "TARGET_AVX512ER"
16764   "vrcp28<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
16765   [(set_attr "prefix" "evex")
16766    (set_attr "type" "sse")
16767    (set_attr "mode" "<MODE>")])
16769 (define_insn "avx512er_vmrcp28<mode><round_saeonly_name>"
16770   [(set (match_operand:VF_128 0 "register_operand" "=v")
16771         (vec_merge:VF_128
16772           (unspec:VF_128
16773             [(match_operand:VF_128 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16774             UNSPEC_RCP28)
16775           (match_operand:VF_128 2 "register_operand" "v")
16776           (const_int 1)))]
16777   "TARGET_AVX512ER"
16778   "vrcp28<ssescalarmodesuffix>\t{<round_saeonly_op3>%1, %2, %0|%0, %2, %<iptr>1<round_saeonly_op3>}"
16779   [(set_attr "length_immediate" "1")
16780    (set_attr "prefix" "evex")
16781    (set_attr "type" "sse")
16782    (set_attr "mode" "<MODE>")])
16784 (define_insn "<mask_codefor>avx512er_rsqrt28<mode><mask_name><round_saeonly_name>"
16785   [(set (match_operand:VF_512 0 "register_operand" "=v")
16786         (unspec:VF_512
16787           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16788           UNSPEC_RSQRT28))]
16789   "TARGET_AVX512ER"
16790   "vrsqrt28<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
16791   [(set_attr "prefix" "evex")
16792    (set_attr "type" "sse")
16793    (set_attr "mode" "<MODE>")])
16795 (define_insn "avx512er_vmrsqrt28<mode><round_saeonly_name>"
16796   [(set (match_operand:VF_128 0 "register_operand" "=v")
16797         (vec_merge:VF_128
16798           (unspec:VF_128
16799             [(match_operand:VF_128 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16800             UNSPEC_RSQRT28)
16801           (match_operand:VF_128 2 "register_operand" "v")
16802           (const_int 1)))]
16803   "TARGET_AVX512ER"
16804   "vrsqrt28<ssescalarmodesuffix>\t{<round_saeonly_op3>%1, %2, %0|%0, %2, %<iptr>1<round_saeonly_op3>}"
16805   [(set_attr "length_immediate" "1")
16806    (set_attr "type" "sse")
16807    (set_attr "prefix" "evex")
16808    (set_attr "mode" "<MODE>")])
16810 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16812 ;; XOP instructions
16814 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16816 (define_code_iterator xop_plus [plus ss_plus])
16818 (define_code_attr macs [(plus "macs") (ss_plus "macss")])
16819 (define_code_attr madcs [(plus "madcs") (ss_plus "madcss")])
16821 ;; XOP parallel integer multiply/add instructions.
16823 (define_insn "xop_p<macs><ssemodesuffix><ssemodesuffix>"
16824   [(set (match_operand:VI24_128 0 "register_operand" "=x")
16825         (xop_plus:VI24_128
16826          (mult:VI24_128
16827           (match_operand:VI24_128 1 "nonimmediate_operand" "%x")
16828           (match_operand:VI24_128 2 "nonimmediate_operand" "xm"))
16829          (match_operand:VI24_128 3 "register_operand" "x")))]
16830   "TARGET_XOP"
16831   "vp<macs><ssemodesuffix><ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16832   [(set_attr "type" "ssemuladd")
16833    (set_attr "mode" "TI")])
16835 (define_insn "xop_p<macs>dql"
16836   [(set (match_operand:V2DI 0 "register_operand" "=x")
16837         (xop_plus:V2DI
16838          (mult:V2DI
16839           (sign_extend:V2DI
16840            (vec_select:V2SI
16841             (match_operand:V4SI 1 "nonimmediate_operand" "%x")
16842             (parallel [(const_int 0) (const_int 2)])))
16843           (sign_extend:V2DI
16844            (vec_select:V2SI
16845             (match_operand:V4SI 2 "nonimmediate_operand" "xm")
16846             (parallel [(const_int 0) (const_int 2)]))))
16847          (match_operand:V2DI 3 "register_operand" "x")))]
16848   "TARGET_XOP"
16849   "vp<macs>dql\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16850   [(set_attr "type" "ssemuladd")
16851    (set_attr "mode" "TI")])
16853 (define_insn "xop_p<macs>dqh"
16854   [(set (match_operand:V2DI 0 "register_operand" "=x")
16855         (xop_plus:V2DI
16856          (mult:V2DI
16857           (sign_extend:V2DI
16858            (vec_select:V2SI
16859             (match_operand:V4SI 1 "nonimmediate_operand" "%x")
16860             (parallel [(const_int 1) (const_int 3)])))
16861           (sign_extend:V2DI
16862            (vec_select:V2SI
16863             (match_operand:V4SI 2 "nonimmediate_operand" "xm")
16864             (parallel [(const_int 1) (const_int 3)]))))
16865          (match_operand:V2DI 3 "register_operand" "x")))]
16866   "TARGET_XOP"
16867   "vp<macs>dqh\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16868   [(set_attr "type" "ssemuladd")
16869    (set_attr "mode" "TI")])
16871 ;; XOP parallel integer multiply/add instructions for the intrinisics
16872 (define_insn "xop_p<macs>wd"
16873   [(set (match_operand:V4SI 0 "register_operand" "=x")
16874         (xop_plus:V4SI
16875          (mult:V4SI
16876           (sign_extend:V4SI
16877            (vec_select:V4HI
16878             (match_operand:V8HI 1 "nonimmediate_operand" "%x")
16879             (parallel [(const_int 1) (const_int 3)
16880                        (const_int 5) (const_int 7)])))
16881           (sign_extend:V4SI
16882            (vec_select:V4HI
16883             (match_operand:V8HI 2 "nonimmediate_operand" "xm")
16884             (parallel [(const_int 1) (const_int 3)
16885                        (const_int 5) (const_int 7)]))))
16886          (match_operand:V4SI 3 "register_operand" "x")))]
16887   "TARGET_XOP"
16888   "vp<macs>wd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16889   [(set_attr "type" "ssemuladd")
16890    (set_attr "mode" "TI")])
16892 (define_insn "xop_p<madcs>wd"
16893   [(set (match_operand:V4SI 0 "register_operand" "=x")
16894         (xop_plus:V4SI
16895          (plus:V4SI
16896           (mult:V4SI
16897            (sign_extend:V4SI
16898             (vec_select:V4HI
16899              (match_operand:V8HI 1 "nonimmediate_operand" "%x")
16900              (parallel [(const_int 0) (const_int 2)
16901                         (const_int 4) (const_int 6)])))
16902            (sign_extend:V4SI
16903             (vec_select:V4HI
16904              (match_operand:V8HI 2 "nonimmediate_operand" "xm")
16905              (parallel [(const_int 0) (const_int 2)
16906                         (const_int 4) (const_int 6)]))))
16907           (mult:V4SI
16908            (sign_extend:V4SI
16909             (vec_select:V4HI
16910              (match_dup 1)
16911              (parallel [(const_int 1) (const_int 3)
16912                         (const_int 5) (const_int 7)])))
16913            (sign_extend:V4SI
16914             (vec_select:V4HI
16915              (match_dup 2)
16916              (parallel [(const_int 1) (const_int 3)
16917                         (const_int 5) (const_int 7)])))))
16918          (match_operand:V4SI 3 "register_operand" "x")))]
16919   "TARGET_XOP"
16920   "vp<madcs>wd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16921   [(set_attr "type" "ssemuladd")
16922    (set_attr "mode" "TI")])
16924 ;; XOP parallel XMM conditional moves
16925 (define_insn "xop_pcmov_<mode><avxsizesuffix>"
16926   [(set (match_operand:V_128_256 0 "register_operand" "=x,x")
16927         (if_then_else:V_128_256
16928           (match_operand:V_128_256 3 "nonimmediate_operand" "x,m")
16929           (match_operand:V_128_256 1 "register_operand" "x,x")
16930           (match_operand:V_128_256 2 "nonimmediate_operand" "xm,x")))]
16931   "TARGET_XOP"
16932   "vpcmov\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16933   [(set_attr "type" "sse4arg")])
16935 ;; XOP horizontal add/subtract instructions
16936 (define_insn "xop_phadd<u>bw"
16937   [(set (match_operand:V8HI 0 "register_operand" "=x")
16938         (plus:V8HI
16939          (any_extend:V8HI
16940           (vec_select:V8QI
16941            (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16942            (parallel [(const_int 0) (const_int 2)
16943                       (const_int 4) (const_int 6)
16944                       (const_int 8) (const_int 10)
16945                       (const_int 12) (const_int 14)])))
16946          (any_extend:V8HI
16947           (vec_select:V8QI
16948            (match_dup 1)
16949            (parallel [(const_int 1) (const_int 3)
16950                       (const_int 5) (const_int 7)
16951                       (const_int 9) (const_int 11)
16952                       (const_int 13) (const_int 15)])))))]
16953   "TARGET_XOP"
16954   "vphadd<u>bw\t{%1, %0|%0, %1}"
16955   [(set_attr "type" "sseiadd1")])
16957 (define_insn "xop_phadd<u>bd"
16958   [(set (match_operand:V4SI 0 "register_operand" "=x")
16959         (plus:V4SI
16960          (plus:V4SI
16961           (any_extend:V4SI
16962            (vec_select:V4QI
16963             (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16964             (parallel [(const_int 0) (const_int 4)
16965                        (const_int 8) (const_int 12)])))
16966           (any_extend:V4SI
16967            (vec_select:V4QI
16968             (match_dup 1)
16969             (parallel [(const_int 1) (const_int 5)
16970                        (const_int 9) (const_int 13)]))))
16971          (plus:V4SI
16972           (any_extend:V4SI
16973            (vec_select:V4QI
16974             (match_dup 1)
16975             (parallel [(const_int 2) (const_int 6)
16976                        (const_int 10) (const_int 14)])))
16977           (any_extend:V4SI
16978            (vec_select:V4QI
16979             (match_dup 1)
16980             (parallel [(const_int 3) (const_int 7)
16981                        (const_int 11) (const_int 15)]))))))]
16982   "TARGET_XOP"
16983   "vphadd<u>bd\t{%1, %0|%0, %1}"
16984   [(set_attr "type" "sseiadd1")])
16986 (define_insn "xop_phadd<u>bq"
16987   [(set (match_operand:V2DI 0 "register_operand" "=x")
16988         (plus:V2DI
16989          (plus:V2DI
16990           (plus:V2DI
16991            (any_extend:V2DI
16992             (vec_select:V2QI
16993              (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16994              (parallel [(const_int 0) (const_int 8)])))
16995            (any_extend:V2DI
16996             (vec_select:V2QI
16997              (match_dup 1)
16998              (parallel [(const_int 1) (const_int 9)]))))
16999           (plus:V2DI
17000            (any_extend:V2DI
17001             (vec_select:V2QI
17002              (match_dup 1)
17003              (parallel [(const_int 2) (const_int 10)])))
17004            (any_extend:V2DI
17005             (vec_select:V2QI
17006              (match_dup 1)
17007              (parallel [(const_int 3) (const_int 11)])))))
17008          (plus:V2DI
17009           (plus:V2DI
17010            (any_extend:V2DI
17011             (vec_select:V2QI
17012              (match_dup 1)
17013              (parallel [(const_int 4) (const_int 12)])))
17014            (any_extend:V2DI
17015             (vec_select:V2QI
17016              (match_dup 1)
17017              (parallel [(const_int 5) (const_int 13)]))))
17018           (plus:V2DI
17019            (any_extend:V2DI
17020             (vec_select:V2QI
17021              (match_dup 1)
17022              (parallel [(const_int 6) (const_int 14)])))
17023            (any_extend:V2DI
17024             (vec_select:V2QI
17025              (match_dup 1)
17026              (parallel [(const_int 7) (const_int 15)])))))))]
17027   "TARGET_XOP"
17028   "vphadd<u>bq\t{%1, %0|%0, %1}"
17029   [(set_attr "type" "sseiadd1")])
17031 (define_insn "xop_phadd<u>wd"
17032   [(set (match_operand:V4SI 0 "register_operand" "=x")
17033         (plus:V4SI
17034          (any_extend:V4SI
17035           (vec_select:V4HI
17036            (match_operand:V8HI 1 "nonimmediate_operand" "xm")
17037            (parallel [(const_int 0) (const_int 2)
17038                       (const_int 4) (const_int 6)])))
17039          (any_extend:V4SI
17040           (vec_select:V4HI
17041            (match_dup 1)
17042            (parallel [(const_int 1) (const_int 3)
17043                       (const_int 5) (const_int 7)])))))]
17044   "TARGET_XOP"
17045   "vphadd<u>wd\t{%1, %0|%0, %1}"
17046   [(set_attr "type" "sseiadd1")])
17048 (define_insn "xop_phadd<u>wq"
17049   [(set (match_operand:V2DI 0 "register_operand" "=x")
17050         (plus:V2DI
17051          (plus:V2DI
17052           (any_extend:V2DI
17053            (vec_select:V2HI
17054             (match_operand:V8HI 1 "nonimmediate_operand" "xm")
17055             (parallel [(const_int 0) (const_int 4)])))
17056           (any_extend:V2DI
17057            (vec_select:V2HI
17058             (match_dup 1)
17059             (parallel [(const_int 1) (const_int 5)]))))
17060          (plus:V2DI
17061           (any_extend:V2DI
17062            (vec_select:V2HI
17063             (match_dup 1)
17064             (parallel [(const_int 2) (const_int 6)])))
17065           (any_extend:V2DI
17066            (vec_select:V2HI
17067             (match_dup 1)
17068             (parallel [(const_int 3) (const_int 7)]))))))]
17069   "TARGET_XOP"
17070   "vphadd<u>wq\t{%1, %0|%0, %1}"
17071   [(set_attr "type" "sseiadd1")])
17073 (define_insn "xop_phadd<u>dq"
17074   [(set (match_operand:V2DI 0 "register_operand" "=x")
17075         (plus:V2DI
17076          (any_extend:V2DI
17077           (vec_select:V2SI
17078            (match_operand:V4SI 1 "nonimmediate_operand" "xm")
17079            (parallel [(const_int 0) (const_int 2)])))
17080          (any_extend:V2DI
17081           (vec_select:V2SI
17082            (match_dup 1)
17083            (parallel [(const_int 1) (const_int 3)])))))]
17084   "TARGET_XOP"
17085   "vphadd<u>dq\t{%1, %0|%0, %1}"
17086   [(set_attr "type" "sseiadd1")])
17088 (define_insn "xop_phsubbw"
17089   [(set (match_operand:V8HI 0 "register_operand" "=x")
17090         (minus:V8HI
17091          (sign_extend:V8HI
17092           (vec_select:V8QI
17093            (match_operand:V16QI 1 "nonimmediate_operand" "xm")
17094            (parallel [(const_int 0) (const_int 2)
17095                       (const_int 4) (const_int 6)
17096                       (const_int 8) (const_int 10)
17097                       (const_int 12) (const_int 14)])))
17098          (sign_extend:V8HI
17099           (vec_select:V8QI
17100            (match_dup 1)
17101            (parallel [(const_int 1) (const_int 3)
17102                       (const_int 5) (const_int 7)
17103                       (const_int 9) (const_int 11)
17104                       (const_int 13) (const_int 15)])))))]
17105   "TARGET_XOP"
17106   "vphsubbw\t{%1, %0|%0, %1}"
17107   [(set_attr "type" "sseiadd1")])
17109 (define_insn "xop_phsubwd"
17110   [(set (match_operand:V4SI 0 "register_operand" "=x")
17111         (minus:V4SI
17112          (sign_extend:V4SI
17113           (vec_select:V4HI
17114            (match_operand:V8HI 1 "nonimmediate_operand" "xm")
17115            (parallel [(const_int 0) (const_int 2)
17116                       (const_int 4) (const_int 6)])))
17117          (sign_extend:V4SI
17118           (vec_select:V4HI
17119            (match_dup 1)
17120            (parallel [(const_int 1) (const_int 3)
17121                       (const_int 5) (const_int 7)])))))]
17122   "TARGET_XOP"
17123   "vphsubwd\t{%1, %0|%0, %1}"
17124   [(set_attr "type" "sseiadd1")])
17126 (define_insn "xop_phsubdq"
17127   [(set (match_operand:V2DI 0 "register_operand" "=x")
17128         (minus:V2DI
17129          (sign_extend:V2DI
17130           (vec_select:V2SI
17131            (match_operand:V4SI 1 "nonimmediate_operand" "xm")
17132            (parallel [(const_int 0) (const_int 2)])))
17133          (sign_extend:V2DI
17134           (vec_select:V2SI
17135            (match_dup 1)
17136            (parallel [(const_int 1) (const_int 3)])))))]
17137   "TARGET_XOP"
17138   "vphsubdq\t{%1, %0|%0, %1}"
17139   [(set_attr "type" "sseiadd1")])
17141 ;; XOP permute instructions
17142 (define_insn "xop_pperm"
17143   [(set (match_operand:V16QI 0 "register_operand" "=x,x")
17144         (unspec:V16QI
17145           [(match_operand:V16QI 1 "register_operand" "x,x")
17146            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
17147            (match_operand:V16QI 3 "nonimmediate_operand" "xm,x")]
17148           UNSPEC_XOP_PERMUTE))]
17149   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
17150   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
17151   [(set_attr "type" "sse4arg")
17152    (set_attr "mode" "TI")])
17154 ;; XOP pack instructions that combine two vectors into a smaller vector
17155 (define_insn "xop_pperm_pack_v2di_v4si"
17156   [(set (match_operand:V4SI 0 "register_operand" "=x,x")
17157         (vec_concat:V4SI
17158          (truncate:V2SI
17159           (match_operand:V2DI 1 "register_operand" "x,x"))
17160          (truncate:V2SI
17161           (match_operand:V2DI 2 "nonimmediate_operand" "x,m"))))
17162    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
17163   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
17164   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
17165   [(set_attr "type" "sse4arg")
17166    (set_attr "mode" "TI")])
17168 (define_insn "xop_pperm_pack_v4si_v8hi"
17169   [(set (match_operand:V8HI 0 "register_operand" "=x,x")
17170         (vec_concat:V8HI
17171          (truncate:V4HI
17172           (match_operand:V4SI 1 "register_operand" "x,x"))
17173          (truncate:V4HI
17174           (match_operand:V4SI 2 "nonimmediate_operand" "x,m"))))
17175    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
17176   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
17177   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
17178   [(set_attr "type" "sse4arg")
17179    (set_attr "mode" "TI")])
17181 (define_insn "xop_pperm_pack_v8hi_v16qi"
17182   [(set (match_operand:V16QI 0 "register_operand" "=x,x")
17183         (vec_concat:V16QI
17184          (truncate:V8QI
17185           (match_operand:V8HI 1 "register_operand" "x,x"))
17186          (truncate:V8QI
17187           (match_operand:V8HI 2 "nonimmediate_operand" "x,m"))))
17188    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
17189   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
17190   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
17191   [(set_attr "type" "sse4arg")
17192    (set_attr "mode" "TI")])
17194 ;; XOP packed rotate instructions
17195 (define_expand "rotl<mode>3"
17196   [(set (match_operand:VI_128 0 "register_operand")
17197         (rotate:VI_128
17198          (match_operand:VI_128 1 "nonimmediate_operand")
17199          (match_operand:SI 2 "general_operand")))]
17200   "TARGET_XOP"
17202   /* If we were given a scalar, convert it to parallel */
17203   if (! const_0_to_<sserotatemax>_operand (operands[2], SImode))
17204     {
17205       rtvec vs = rtvec_alloc (<ssescalarnum>);
17206       rtx par = gen_rtx_PARALLEL (<MODE>mode, vs);
17207       rtx reg = gen_reg_rtx (<MODE>mode);
17208       rtx op2 = operands[2];
17209       int i;
17211       if (GET_MODE (op2) != <ssescalarmode>mode)
17212         {
17213           op2 = gen_reg_rtx (<ssescalarmode>mode);
17214           convert_move (op2, operands[2], false);
17215         }
17217       for (i = 0; i < <ssescalarnum>; i++)
17218         RTVEC_ELT (vs, i) = op2;
17220       emit_insn (gen_vec_init<mode><ssescalarmodelower> (reg, par));
17221       emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], reg));
17222       DONE;
17223     }
17226 (define_expand "rotr<mode>3"
17227   [(set (match_operand:VI_128 0 "register_operand")
17228         (rotatert:VI_128
17229          (match_operand:VI_128 1 "nonimmediate_operand")
17230          (match_operand:SI 2 "general_operand")))]
17231   "TARGET_XOP"
17233   /* If we were given a scalar, convert it to parallel */
17234   if (! const_0_to_<sserotatemax>_operand (operands[2], SImode))
17235     {
17236       rtvec vs = rtvec_alloc (<ssescalarnum>);
17237       rtx par = gen_rtx_PARALLEL (<MODE>mode, vs);
17238       rtx neg = gen_reg_rtx (<MODE>mode);
17239       rtx reg = gen_reg_rtx (<MODE>mode);
17240       rtx op2 = operands[2];
17241       int i;
17243       if (GET_MODE (op2) != <ssescalarmode>mode)
17244         {
17245           op2 = gen_reg_rtx (<ssescalarmode>mode);
17246           convert_move (op2, operands[2], false);
17247         }
17249       for (i = 0; i < <ssescalarnum>; i++)
17250         RTVEC_ELT (vs, i) = op2;
17252       emit_insn (gen_vec_init<mode><ssescalarmodelower> (reg, par));
17253       emit_insn (gen_neg<mode>2 (neg, reg));
17254       emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], neg));
17255       DONE;
17256     }
17259 (define_insn "xop_rotl<mode>3"
17260   [(set (match_operand:VI_128 0 "register_operand" "=x")
17261         (rotate:VI_128
17262          (match_operand:VI_128 1 "nonimmediate_operand" "xm")
17263          (match_operand:SI 2 "const_0_to_<sserotatemax>_operand" "n")))]
17264   "TARGET_XOP"
17265   "vprot<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17266   [(set_attr "type" "sseishft")
17267    (set_attr "length_immediate" "1")
17268    (set_attr "mode" "TI")])
17270 (define_insn "xop_rotr<mode>3"
17271   [(set (match_operand:VI_128 0 "register_operand" "=x")
17272         (rotatert:VI_128
17273          (match_operand:VI_128 1 "nonimmediate_operand" "xm")
17274          (match_operand:SI 2 "const_0_to_<sserotatemax>_operand" "n")))]
17275   "TARGET_XOP"
17277   operands[3]
17278     = GEN_INT (GET_MODE_BITSIZE (<ssescalarmode>mode) - INTVAL (operands[2]));
17279   return \"vprot<ssemodesuffix>\t{%3, %1, %0|%0, %1, %3}\";
17281   [(set_attr "type" "sseishft")
17282    (set_attr "length_immediate" "1")
17283    (set_attr "mode" "TI")])
17285 (define_expand "vrotr<mode>3"
17286   [(match_operand:VI_128 0 "register_operand")
17287    (match_operand:VI_128 1 "register_operand")
17288    (match_operand:VI_128 2 "register_operand")]
17289   "TARGET_XOP"
17291   rtx reg = gen_reg_rtx (<MODE>mode);
17292   emit_insn (gen_neg<mode>2 (reg, operands[2]));
17293   emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], reg));
17294   DONE;
17297 (define_expand "vrotl<mode>3"
17298   [(match_operand:VI_128 0 "register_operand")
17299    (match_operand:VI_128 1 "register_operand")
17300    (match_operand:VI_128 2 "register_operand")]
17301   "TARGET_XOP"
17303   emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], operands[2]));
17304   DONE;
17307 (define_insn "xop_vrotl<mode>3"
17308   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
17309         (if_then_else:VI_128
17310          (ge:VI_128
17311           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
17312           (const_int 0))
17313          (rotate:VI_128
17314           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
17315           (match_dup 2))
17316          (rotatert:VI_128
17317           (match_dup 1)
17318           (neg:VI_128 (match_dup 2)))))]
17319   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17320   "vprot<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17321   [(set_attr "type" "sseishft")
17322    (set_attr "prefix_data16" "0")
17323    (set_attr "prefix_extra" "2")
17324    (set_attr "mode" "TI")])
17326 ;; XOP packed shift instructions.
17327 (define_expand "vlshr<mode>3"
17328   [(set (match_operand:VI12_128 0 "register_operand")
17329         (lshiftrt:VI12_128
17330           (match_operand:VI12_128 1 "register_operand")
17331           (match_operand:VI12_128 2 "nonimmediate_operand")))]
17332   "TARGET_XOP"
17334   rtx neg = gen_reg_rtx (<MODE>mode);
17335   emit_insn (gen_neg<mode>2 (neg, operands[2]));
17336   emit_insn (gen_xop_shl<mode>3 (operands[0], operands[1], neg));
17337   DONE;
17340 (define_expand "vlshr<mode>3"
17341   [(set (match_operand:VI48_128 0 "register_operand")
17342         (lshiftrt:VI48_128
17343           (match_operand:VI48_128 1 "register_operand")
17344           (match_operand:VI48_128 2 "nonimmediate_operand")))]
17345   "TARGET_AVX2 || TARGET_XOP"
17347   if (!TARGET_AVX2)
17348     {
17349       rtx neg = gen_reg_rtx (<MODE>mode);
17350       emit_insn (gen_neg<mode>2 (neg, operands[2]));
17351       emit_insn (gen_xop_shl<mode>3 (operands[0], operands[1], neg));
17352       DONE;
17353     }
17356 (define_expand "vlshr<mode>3"
17357   [(set (match_operand:VI48_512 0 "register_operand")
17358         (lshiftrt:VI48_512
17359           (match_operand:VI48_512 1 "register_operand")
17360           (match_operand:VI48_512 2 "nonimmediate_operand")))]
17361   "TARGET_AVX512F")
17363 (define_expand "vlshr<mode>3"
17364   [(set (match_operand:VI48_256 0 "register_operand")
17365         (lshiftrt:VI48_256
17366           (match_operand:VI48_256 1 "register_operand")
17367           (match_operand:VI48_256 2 "nonimmediate_operand")))]
17368   "TARGET_AVX2")
17370 (define_expand "vashrv8hi3<mask_name>"
17371   [(set (match_operand:V8HI 0 "register_operand")
17372         (ashiftrt:V8HI
17373           (match_operand:V8HI 1 "register_operand")
17374           (match_operand:V8HI 2 "nonimmediate_operand")))]
17375   "TARGET_XOP || (TARGET_AVX512BW && TARGET_AVX512VL)"
17377   if (TARGET_XOP)
17378     {
17379       rtx neg = gen_reg_rtx (V8HImode);
17380       emit_insn (gen_negv8hi2 (neg, operands[2]));
17381       emit_insn (gen_xop_shav8hi3 (operands[0], operands[1], neg));
17382       DONE;
17383     }
17386 (define_expand "vashrv16qi3"
17387   [(set (match_operand:V16QI 0 "register_operand")
17388         (ashiftrt:V16QI
17389           (match_operand:V16QI 1 "register_operand")
17390           (match_operand:V16QI 2 "nonimmediate_operand")))]
17391   "TARGET_XOP"
17393    rtx neg = gen_reg_rtx (V16QImode);
17394    emit_insn (gen_negv16qi2 (neg, operands[2]));
17395    emit_insn (gen_xop_shav16qi3 (operands[0], operands[1], neg));
17396    DONE;
17399 (define_expand "vashrv2di3<mask_name>"
17400   [(set (match_operand:V2DI 0 "register_operand")
17401         (ashiftrt:V2DI
17402           (match_operand:V2DI 1 "register_operand")
17403           (match_operand:V2DI 2 "nonimmediate_operand")))]
17404   "TARGET_XOP || TARGET_AVX512VL"
17406   if (TARGET_XOP)
17407     {
17408       rtx neg = gen_reg_rtx (V2DImode);
17409       emit_insn (gen_negv2di2 (neg, operands[2]));
17410       emit_insn (gen_xop_shav2di3 (operands[0], operands[1], neg));
17411       DONE;
17412     }
17415 (define_expand "vashrv4si3"
17416   [(set (match_operand:V4SI 0 "register_operand")
17417         (ashiftrt:V4SI (match_operand:V4SI 1 "register_operand")
17418                        (match_operand:V4SI 2 "nonimmediate_operand")))]
17419   "TARGET_AVX2 || TARGET_XOP"
17421   if (!TARGET_AVX2)
17422     {
17423       rtx neg = gen_reg_rtx (V4SImode);
17424       emit_insn (gen_negv4si2 (neg, operands[2]));
17425       emit_insn (gen_xop_shav4si3 (operands[0], operands[1], neg));
17426       DONE;
17427     }
17430 (define_expand "vashrv16si3"
17431   [(set (match_operand:V16SI 0 "register_operand")
17432         (ashiftrt:V16SI (match_operand:V16SI 1 "register_operand")
17433                         (match_operand:V16SI 2 "nonimmediate_operand")))]
17434   "TARGET_AVX512F")
17436 (define_expand "vashrv8si3"
17437   [(set (match_operand:V8SI 0 "register_operand")
17438         (ashiftrt:V8SI (match_operand:V8SI 1 "register_operand")
17439                        (match_operand:V8SI 2 "nonimmediate_operand")))]
17440   "TARGET_AVX2")
17442 (define_expand "vashl<mode>3"
17443   [(set (match_operand:VI12_128 0 "register_operand")
17444         (ashift:VI12_128
17445           (match_operand:VI12_128 1 "register_operand")
17446           (match_operand:VI12_128 2 "nonimmediate_operand")))]
17447   "TARGET_XOP"
17449   emit_insn (gen_xop_sha<mode>3 (operands[0], operands[1], operands[2]));
17450   DONE;
17453 (define_expand "vashl<mode>3"
17454   [(set (match_operand:VI48_128 0 "register_operand")
17455         (ashift:VI48_128
17456           (match_operand:VI48_128 1 "register_operand")
17457           (match_operand:VI48_128 2 "nonimmediate_operand")))]
17458   "TARGET_AVX2 || TARGET_XOP"
17460   if (!TARGET_AVX2)
17461     {
17462       operands[2] = force_reg (<MODE>mode, operands[2]);
17463       emit_insn (gen_xop_sha<mode>3 (operands[0], operands[1], operands[2]));
17464       DONE;
17465     }
17468 (define_expand "vashl<mode>3"
17469   [(set (match_operand:VI48_512 0 "register_operand")
17470         (ashift:VI48_512
17471           (match_operand:VI48_512 1 "register_operand")
17472           (match_operand:VI48_512 2 "nonimmediate_operand")))]
17473   "TARGET_AVX512F")
17475 (define_expand "vashl<mode>3"
17476   [(set (match_operand:VI48_256 0 "register_operand")
17477         (ashift:VI48_256
17478           (match_operand:VI48_256 1 "register_operand")
17479           (match_operand:VI48_256 2 "nonimmediate_operand")))]
17480   "TARGET_AVX2")
17482 (define_insn "xop_sha<mode>3"
17483   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
17484         (if_then_else:VI_128
17485          (ge:VI_128
17486           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
17487           (const_int 0))
17488          (ashift:VI_128
17489           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
17490           (match_dup 2))
17491          (ashiftrt:VI_128
17492           (match_dup 1)
17493           (neg:VI_128 (match_dup 2)))))]
17494   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17495   "vpsha<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17496   [(set_attr "type" "sseishft")
17497    (set_attr "prefix_data16" "0")
17498    (set_attr "prefix_extra" "2")
17499    (set_attr "mode" "TI")])
17501 (define_insn "xop_shl<mode>3"
17502   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
17503         (if_then_else:VI_128
17504          (ge:VI_128
17505           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
17506           (const_int 0))
17507          (ashift:VI_128
17508           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
17509           (match_dup 2))
17510          (lshiftrt:VI_128
17511           (match_dup 1)
17512           (neg:VI_128 (match_dup 2)))))]
17513   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17514   "vpshl<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17515   [(set_attr "type" "sseishft")
17516    (set_attr "prefix_data16" "0")
17517    (set_attr "prefix_extra" "2")
17518    (set_attr "mode" "TI")])
17520 (define_expand "<shift_insn><mode>3"
17521   [(set (match_operand:VI1_AVX512 0 "register_operand")
17522         (any_shift:VI1_AVX512
17523           (match_operand:VI1_AVX512 1 "register_operand")
17524           (match_operand:SI 2 "nonmemory_operand")))]
17525   "TARGET_SSE2"
17527   if (TARGET_XOP && <MODE>mode == V16QImode)
17528     {
17529       bool negate = false;
17530       rtx (*gen) (rtx, rtx, rtx);
17531       rtx tmp, par;
17532       int i;
17534       if (<CODE> != ASHIFT)
17535         {
17536           if (CONST_INT_P (operands[2]))
17537             operands[2] = GEN_INT (-INTVAL (operands[2]));
17538           else
17539             negate = true;
17540         }
17541       par = gen_rtx_PARALLEL (V16QImode, rtvec_alloc (16));
17542       for (i = 0; i < 16; i++)
17543         XVECEXP (par, 0, i) = operands[2];
17545       tmp = gen_reg_rtx (V16QImode);
17546       emit_insn (gen_vec_initv16qiqi (tmp, par));
17548       if (negate)
17549         emit_insn (gen_negv16qi2 (tmp, tmp));
17551       gen = (<CODE> == LSHIFTRT ? gen_xop_shlv16qi3 : gen_xop_shav16qi3);
17552       emit_insn (gen (operands[0], operands[1], tmp));
17553     }
17554   else
17555     ix86_expand_vecop_qihi (<CODE>, operands[0], operands[1], operands[2]);
17556   DONE;
17559 (define_expand "ashrv2di3"
17560   [(set (match_operand:V2DI 0 "register_operand")
17561         (ashiftrt:V2DI
17562           (match_operand:V2DI 1 "register_operand")
17563           (match_operand:DI 2 "nonmemory_operand")))]
17564   "TARGET_XOP || TARGET_AVX512VL"
17566   if (!TARGET_AVX512VL)
17567     {
17568       rtx reg = gen_reg_rtx (V2DImode);
17569       rtx par;
17570       bool negate = false;
17571       int i;
17573       if (CONST_INT_P (operands[2]))
17574         operands[2] = GEN_INT (-INTVAL (operands[2]));
17575       else
17576         negate = true;
17578       par = gen_rtx_PARALLEL (V2DImode, rtvec_alloc (2));
17579       for (i = 0; i < 2; i++)
17580         XVECEXP (par, 0, i) = operands[2];
17582       emit_insn (gen_vec_initv2didi (reg, par));
17584       if (negate)
17585         emit_insn (gen_negv2di2 (reg, reg));
17587       emit_insn (gen_xop_shav2di3 (operands[0], operands[1], reg));
17588       DONE;
17589     }
17592 ;; XOP FRCZ support
17593 (define_insn "xop_frcz<mode>2"
17594   [(set (match_operand:FMAMODE 0 "register_operand" "=x")
17595         (unspec:FMAMODE
17596          [(match_operand:FMAMODE 1 "nonimmediate_operand" "xm")]
17597          UNSPEC_FRCZ))]
17598   "TARGET_XOP"
17599   "vfrcz<ssemodesuffix>\t{%1, %0|%0, %1}"
17600   [(set_attr "type" "ssecvt1")
17601    (set_attr "mode" "<MODE>")])
17603 (define_expand "xop_vmfrcz<mode>2"
17604   [(set (match_operand:VF_128 0 "register_operand")
17605         (vec_merge:VF_128
17606           (unspec:VF_128
17607            [(match_operand:VF_128 1 "nonimmediate_operand")]
17608            UNSPEC_FRCZ)
17609           (match_dup 2)
17610           (const_int 1)))]
17611   "TARGET_XOP"
17612   "operands[2] = CONST0_RTX (<MODE>mode);")
17614 (define_insn "*xop_vmfrcz<mode>2"
17615   [(set (match_operand:VF_128 0 "register_operand" "=x")
17616         (vec_merge:VF_128
17617           (unspec:VF_128
17618            [(match_operand:VF_128 1 "nonimmediate_operand" "xm")]
17619            UNSPEC_FRCZ)
17620           (match_operand:VF_128 2 "const0_operand")
17621           (const_int 1)))]
17622   "TARGET_XOP"
17623   "vfrcz<ssescalarmodesuffix>\t{%1, %0|%0, %<iptr>1}"
17624   [(set_attr "type" "ssecvt1")
17625    (set_attr "mode" "<MODE>")])
17627 (define_insn "xop_maskcmp<mode>3"
17628   [(set (match_operand:VI_128 0 "register_operand" "=x")
17629         (match_operator:VI_128 1 "ix86_comparison_int_operator"
17630          [(match_operand:VI_128 2 "register_operand" "x")
17631           (match_operand:VI_128 3 "nonimmediate_operand" "xm")]))]
17632   "TARGET_XOP"
17633   "vpcom%Y1<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
17634   [(set_attr "type" "sse4arg")
17635    (set_attr "prefix_data16" "0")
17636    (set_attr "prefix_rep" "0")
17637    (set_attr "prefix_extra" "2")
17638    (set_attr "length_immediate" "1")
17639    (set_attr "mode" "TI")])
17641 (define_insn "xop_maskcmp_uns<mode>3"
17642   [(set (match_operand:VI_128 0 "register_operand" "=x")
17643         (match_operator:VI_128 1 "ix86_comparison_uns_operator"
17644          [(match_operand:VI_128 2 "register_operand" "x")
17645           (match_operand:VI_128 3 "nonimmediate_operand" "xm")]))]
17646   "TARGET_XOP"
17647   "vpcom%Y1u<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
17648   [(set_attr "type" "ssecmp")
17649    (set_attr "prefix_data16" "0")
17650    (set_attr "prefix_rep" "0")
17651    (set_attr "prefix_extra" "2")
17652    (set_attr "length_immediate" "1")
17653    (set_attr "mode" "TI")])
17655 ;; Version of pcom*u* that is called from the intrinsics that allows pcomequ*
17656 ;; and pcomneu* not to be converted to the signed ones in case somebody needs
17657 ;; the exact instruction generated for the intrinsic.
17658 (define_insn "xop_maskcmp_uns2<mode>3"
17659   [(set (match_operand:VI_128 0 "register_operand" "=x")
17660         (unspec:VI_128
17661          [(match_operator:VI_128 1 "ix86_comparison_uns_operator"
17662           [(match_operand:VI_128 2 "register_operand" "x")
17663            (match_operand:VI_128 3 "nonimmediate_operand" "xm")])]
17664          UNSPEC_XOP_UNSIGNED_CMP))]
17665   "TARGET_XOP"
17666   "vpcom%Y1u<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
17667   [(set_attr "type" "ssecmp")
17668    (set_attr "prefix_data16" "0")
17669    (set_attr "prefix_extra" "2")
17670    (set_attr "length_immediate" "1")
17671    (set_attr "mode" "TI")])
17673 ;; Pcomtrue and pcomfalse support.  These are useless instructions, but are
17674 ;; being added here to be complete.
17675 (define_insn "xop_pcom_tf<mode>3"
17676   [(set (match_operand:VI_128 0 "register_operand" "=x")
17677         (unspec:VI_128
17678           [(match_operand:VI_128 1 "register_operand" "x")
17679            (match_operand:VI_128 2 "nonimmediate_operand" "xm")
17680            (match_operand:SI 3 "const_int_operand" "n")]
17681           UNSPEC_XOP_TRUEFALSE))]
17682   "TARGET_XOP"
17684   return ((INTVAL (operands[3]) != 0)
17685           ? "vpcomtrue<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17686           : "vpcomfalse<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}");
17688   [(set_attr "type" "ssecmp")
17689    (set_attr "prefix_data16" "0")
17690    (set_attr "prefix_extra" "2")
17691    (set_attr "length_immediate" "1")
17692    (set_attr "mode" "TI")])
17694 (define_insn "xop_vpermil2<mode>3"
17695   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
17696         (unspec:VF_128_256
17697           [(match_operand:VF_128_256 1 "register_operand" "x,x")
17698            (match_operand:VF_128_256 2 "nonimmediate_operand" "x,m")
17699            (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "xm,x")
17700            (match_operand:SI 4 "const_0_to_3_operand" "n,n")]
17701           UNSPEC_VPERMIL2))]
17702   "TARGET_XOP"
17703   "vpermil2<ssemodesuffix>\t{%4, %3, %2, %1, %0|%0, %1, %2, %3, %4}"
17704   [(set_attr "type" "sse4arg")
17705    (set_attr "length_immediate" "1")
17706    (set_attr "mode" "<MODE>")])
17708 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17710 (define_insn "aesenc"
17711   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17712         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17713                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
17714                       UNSPEC_AESENC))]
17715   "TARGET_AES"
17716   "@
17717    aesenc\t{%2, %0|%0, %2}
17718    vaesenc\t{%2, %1, %0|%0, %1, %2}"
17719   [(set_attr "isa" "noavx,avx")
17720    (set_attr "type" "sselog1")
17721    (set_attr "prefix_extra" "1")
17722    (set_attr "prefix" "orig,vex")
17723    (set_attr "btver2_decode" "double,double")
17724    (set_attr "mode" "TI")])
17726 (define_insn "aesenclast"
17727   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17728         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17729                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
17730                       UNSPEC_AESENCLAST))]
17731   "TARGET_AES"
17732   "@
17733    aesenclast\t{%2, %0|%0, %2}
17734    vaesenclast\t{%2, %1, %0|%0, %1, %2}"
17735   [(set_attr "isa" "noavx,avx")
17736    (set_attr "type" "sselog1")
17737    (set_attr "prefix_extra" "1")
17738    (set_attr "prefix" "orig,vex")
17739    (set_attr "btver2_decode" "double,double") 
17740    (set_attr "mode" "TI")])
17742 (define_insn "aesdec"
17743   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17744         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17745                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
17746                       UNSPEC_AESDEC))]
17747   "TARGET_AES"
17748   "@
17749    aesdec\t{%2, %0|%0, %2}
17750    vaesdec\t{%2, %1, %0|%0, %1, %2}"
17751   [(set_attr "isa" "noavx,avx")
17752    (set_attr "type" "sselog1")
17753    (set_attr "prefix_extra" "1")
17754    (set_attr "prefix" "orig,vex")
17755    (set_attr "btver2_decode" "double,double") 
17756    (set_attr "mode" "TI")])
17758 (define_insn "aesdeclast"
17759   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17760         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17761                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
17762                       UNSPEC_AESDECLAST))]
17763   "TARGET_AES"
17764   "@
17765    aesdeclast\t{%2, %0|%0, %2}
17766    vaesdeclast\t{%2, %1, %0|%0, %1, %2}"
17767   [(set_attr "isa" "noavx,avx")
17768    (set_attr "type" "sselog1")
17769    (set_attr "prefix_extra" "1")
17770    (set_attr "prefix" "orig,vex")
17771    (set_attr "btver2_decode" "double,double")
17772    (set_attr "mode" "TI")])
17774 (define_insn "aesimc"
17775   [(set (match_operand:V2DI 0 "register_operand" "=x")
17776         (unspec:V2DI [(match_operand:V2DI 1 "vector_operand" "xBm")]
17777                       UNSPEC_AESIMC))]
17778   "TARGET_AES"
17779   "%vaesimc\t{%1, %0|%0, %1}"
17780   [(set_attr "type" "sselog1")
17781    (set_attr "prefix_extra" "1")
17782    (set_attr "prefix" "maybe_vex")
17783    (set_attr "mode" "TI")])
17785 (define_insn "aeskeygenassist"
17786   [(set (match_operand:V2DI 0 "register_operand" "=x")
17787         (unspec:V2DI [(match_operand:V2DI 1 "vector_operand" "xBm")
17788                       (match_operand:SI 2 "const_0_to_255_operand" "n")]
17789                      UNSPEC_AESKEYGENASSIST))]
17790   "TARGET_AES"
17791   "%vaeskeygenassist\t{%2, %1, %0|%0, %1, %2}"
17792   [(set_attr "type" "sselog1")
17793    (set_attr "prefix_extra" "1")
17794    (set_attr "length_immediate" "1")
17795    (set_attr "prefix" "maybe_vex")
17796    (set_attr "mode" "TI")])
17798 (define_insn "pclmulqdq"
17799   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17800         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17801                       (match_operand:V2DI 2 "vector_operand" "xBm,xm")
17802                       (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
17803                      UNSPEC_PCLMUL))]
17804   "TARGET_PCLMUL"
17805   "@
17806    pclmulqdq\t{%3, %2, %0|%0, %2, %3}
17807    vpclmulqdq\t{%3, %2, %1, %0|%0, %1, %2, %3}"
17808   [(set_attr "isa" "noavx,avx")
17809    (set_attr "type" "sselog1")
17810    (set_attr "prefix_extra" "1")
17811    (set_attr "length_immediate" "1")
17812    (set_attr "prefix" "orig,vex")
17813    (set_attr "mode" "TI")])
17815 (define_expand "avx_vzeroall"
17816   [(match_par_dup 0 [(const_int 0)])]
17817   "TARGET_AVX"
17819   int nregs = TARGET_64BIT ? 16 : 8;
17820   int regno;
17822   operands[0] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs + 1));
17824   XVECEXP (operands[0], 0, 0)
17825     = gen_rtx_UNSPEC_VOLATILE (VOIDmode, gen_rtvec (1, const0_rtx),
17826                                UNSPECV_VZEROALL);
17828   for (regno = 0; regno < nregs; regno++)
17829     XVECEXP (operands[0], 0, regno + 1)
17830       = gen_rtx_SET (gen_rtx_REG (V8SImode, GET_SSE_REGNO (regno)),
17831                      CONST0_RTX (V8SImode));
17834 (define_insn "*avx_vzeroall"
17835   [(match_parallel 0 "vzeroall_operation"
17836     [(unspec_volatile [(const_int 0)] UNSPECV_VZEROALL)])]
17837   "TARGET_AVX"
17838   "vzeroall"
17839   [(set_attr "type" "sse")
17840    (set_attr "modrm" "0")
17841    (set_attr "memory" "none")
17842    (set_attr "prefix" "vex")
17843    (set_attr "btver2_decode" "vector")
17844    (set_attr "mode" "OI")])
17846 ;; Clear the upper 128bits of AVX registers, equivalent to a NOP
17847 ;; if the upper 128bits are unused.
17848 (define_insn "avx_vzeroupper"
17849   [(unspec_volatile [(const_int 0)] UNSPECV_VZEROUPPER)]
17850   "TARGET_AVX"
17851   "vzeroupper"
17852   [(set_attr "type" "sse")
17853    (set_attr "modrm" "0")
17854    (set_attr "memory" "none")
17855    (set_attr "prefix" "vex")
17856    (set_attr "btver2_decode" "vector")
17857    (set_attr "mode" "OI")])
17859 (define_mode_attr pbroadcast_evex_isa
17860   [(V64QI "avx512bw") (V32QI "avx512bw") (V16QI "avx512bw")
17861    (V32HI "avx512bw") (V16HI "avx512bw") (V8HI "avx512bw")
17862    (V16SI "avx512f") (V8SI "avx512f") (V4SI "avx512f")
17863    (V8DI "avx512f") (V4DI "avx512f") (V2DI "avx512f")])
17865 (define_insn "avx2_pbroadcast<mode>"
17866   [(set (match_operand:VI 0 "register_operand" "=x,v")
17867         (vec_duplicate:VI
17868           (vec_select:<ssescalarmode>
17869             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "xm,vm")
17870             (parallel [(const_int 0)]))))]
17871   "TARGET_AVX2"
17872   "vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}"
17873   [(set_attr "isa" "*,<pbroadcast_evex_isa>")
17874    (set_attr "type" "ssemov")
17875    (set_attr "prefix_extra" "1")
17876    (set_attr "prefix" "vex,evex")
17877    (set_attr "mode" "<sseinsnmode>")])
17879 (define_insn "avx2_pbroadcast<mode>_1"
17880   [(set (match_operand:VI_256 0 "register_operand" "=x,x,v,v")
17881         (vec_duplicate:VI_256
17882           (vec_select:<ssescalarmode>
17883             (match_operand:VI_256 1 "nonimmediate_operand" "m,x,m,v")
17884             (parallel [(const_int 0)]))))]
17885   "TARGET_AVX2"
17886   "@
17887    vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}
17888    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}
17889    vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}
17890    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}"
17891   [(set_attr "isa" "*,*,<pbroadcast_evex_isa>,<pbroadcast_evex_isa>")
17892    (set_attr "type" "ssemov")
17893    (set_attr "prefix_extra" "1")
17894    (set_attr "prefix" "vex")
17895    (set_attr "mode" "<sseinsnmode>")])
17897 (define_insn "<avx2_avx512>_permvar<mode><mask_name>"
17898   [(set (match_operand:VI48F_256_512 0 "register_operand" "=v")
17899         (unspec:VI48F_256_512
17900           [(match_operand:VI48F_256_512 1 "nonimmediate_operand" "vm")
17901            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
17902           UNSPEC_VPERMVAR))]
17903   "TARGET_AVX2 && <mask_mode512bit_condition>"
17904   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
17905   [(set_attr "type" "sselog")
17906    (set_attr "prefix" "<mask_prefix2>")
17907    (set_attr "mode" "<sseinsnmode>")])
17909 (define_insn "<avx512>_permvar<mode><mask_name>"
17910   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
17911         (unspec:VI1_AVX512VL
17912           [(match_operand:VI1_AVX512VL 1 "nonimmediate_operand" "vm")
17913            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
17914           UNSPEC_VPERMVAR))]
17915   "TARGET_AVX512VBMI && <mask_mode512bit_condition>"
17916   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
17917   [(set_attr "type" "sselog")
17918    (set_attr "prefix" "<mask_prefix2>")
17919    (set_attr "mode" "<sseinsnmode>")])
17921 (define_insn "<avx512>_permvar<mode><mask_name>"
17922   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17923         (unspec:VI2_AVX512VL
17924           [(match_operand:VI2_AVX512VL 1 "nonimmediate_operand" "vm")
17925            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
17926           UNSPEC_VPERMVAR))]
17927   "TARGET_AVX512BW && <mask_mode512bit_condition>"
17928   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
17929   [(set_attr "type" "sselog")
17930    (set_attr "prefix" "<mask_prefix2>")
17931    (set_attr "mode" "<sseinsnmode>")])
17933 (define_expand "avx2_perm<mode>"
17934   [(match_operand:VI8F_256 0 "register_operand")
17935    (match_operand:VI8F_256 1 "nonimmediate_operand")
17936    (match_operand:SI 2 "const_0_to_255_operand")]
17937   "TARGET_AVX2"
17939   int mask = INTVAL (operands[2]);
17940   emit_insn (gen_avx2_perm<mode>_1 (operands[0], operands[1],
17941                                     GEN_INT ((mask >> 0) & 3),
17942                                     GEN_INT ((mask >> 2) & 3),
17943                                     GEN_INT ((mask >> 4) & 3),
17944                                     GEN_INT ((mask >> 6) & 3)));
17945   DONE;
17948 (define_expand "avx512vl_perm<mode>_mask"
17949   [(match_operand:VI8F_256 0 "register_operand")
17950    (match_operand:VI8F_256 1 "nonimmediate_operand")
17951    (match_operand:SI 2 "const_0_to_255_operand")
17952    (match_operand:VI8F_256 3 "nonimm_or_0_operand")
17953    (match_operand:<avx512fmaskmode> 4 "register_operand")]
17954   "TARGET_AVX512VL"
17956   int mask = INTVAL (operands[2]);
17957   emit_insn (gen_<avx2_avx512>_perm<mode>_1_mask (operands[0], operands[1],
17958                                                   GEN_INT ((mask >> 0) & 3),
17959                                                   GEN_INT ((mask >> 2) & 3),
17960                                                   GEN_INT ((mask >> 4) & 3),
17961                                                   GEN_INT ((mask >> 6) & 3),
17962                                                   operands[3], operands[4]));
17963   DONE;
17966 (define_insn "avx2_perm<mode>_1<mask_name>"
17967   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
17968         (vec_select:VI8F_256
17969           (match_operand:VI8F_256 1 "nonimmediate_operand" "vm")
17970           (parallel [(match_operand 2 "const_0_to_3_operand")
17971                      (match_operand 3 "const_0_to_3_operand")
17972                      (match_operand 4 "const_0_to_3_operand")
17973                      (match_operand 5 "const_0_to_3_operand")])))]
17974   "TARGET_AVX2 && <mask_mode512bit_condition>"
17976   int mask = 0;
17977   mask |= INTVAL (operands[2]) << 0;
17978   mask |= INTVAL (operands[3]) << 2;
17979   mask |= INTVAL (operands[4]) << 4;
17980   mask |= INTVAL (operands[5]) << 6;
17981   operands[2] = GEN_INT (mask);
17982   return "vperm<ssemodesuffix>\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
17984   [(set_attr "type" "sselog")
17985    (set_attr "prefix" "<mask_prefix2>")
17986    (set_attr "mode" "<sseinsnmode>")])
17988 (define_expand "avx512f_perm<mode>"
17989   [(match_operand:V8FI 0 "register_operand")
17990    (match_operand:V8FI 1 "nonimmediate_operand")
17991    (match_operand:SI 2 "const_0_to_255_operand")]
17992   "TARGET_AVX512F"
17994   int mask = INTVAL (operands[2]);
17995   emit_insn (gen_avx512f_perm<mode>_1 (operands[0], operands[1],
17996                                        GEN_INT ((mask >> 0) & 3),
17997                                        GEN_INT ((mask >> 2) & 3),
17998                                        GEN_INT ((mask >> 4) & 3),
17999                                        GEN_INT ((mask >> 6) & 3),
18000                                        GEN_INT (((mask >> 0) & 3) + 4),
18001                                        GEN_INT (((mask >> 2) & 3) + 4),
18002                                        GEN_INT (((mask >> 4) & 3) + 4),
18003                                        GEN_INT (((mask >> 6) & 3) + 4)));
18004   DONE;
18007 (define_expand "avx512f_perm<mode>_mask"
18008   [(match_operand:V8FI 0 "register_operand")
18009    (match_operand:V8FI 1 "nonimmediate_operand")
18010    (match_operand:SI 2 "const_0_to_255_operand")
18011    (match_operand:V8FI 3 "nonimm_or_0_operand")
18012    (match_operand:<avx512fmaskmode> 4 "register_operand")]
18013   "TARGET_AVX512F"
18015   int mask = INTVAL (operands[2]);
18016   emit_insn (gen_avx512f_perm<mode>_1_mask (operands[0], operands[1],
18017                                             GEN_INT ((mask >> 0) & 3),
18018                                             GEN_INT ((mask >> 2) & 3),
18019                                             GEN_INT ((mask >> 4) & 3),
18020                                             GEN_INT ((mask >> 6) & 3),
18021                                             GEN_INT (((mask >> 0) & 3) + 4),
18022                                             GEN_INT (((mask >> 2) & 3) + 4),
18023                                             GEN_INT (((mask >> 4) & 3) + 4),
18024                                             GEN_INT (((mask >> 6) & 3) + 4),
18025                                             operands[3], operands[4]));
18026   DONE;
18029 (define_insn "avx512f_perm<mode>_1<mask_name>"
18030   [(set (match_operand:V8FI 0 "register_operand" "=v")
18031         (vec_select:V8FI
18032           (match_operand:V8FI 1 "nonimmediate_operand" "vm")
18033           (parallel [(match_operand 2 "const_0_to_3_operand")
18034                      (match_operand 3 "const_0_to_3_operand")
18035                      (match_operand 4 "const_0_to_3_operand")
18036                      (match_operand 5 "const_0_to_3_operand")
18037                      (match_operand 6 "const_4_to_7_operand")
18038                      (match_operand 7 "const_4_to_7_operand")
18039                      (match_operand 8 "const_4_to_7_operand")
18040                      (match_operand 9 "const_4_to_7_operand")])))]
18041   "TARGET_AVX512F && <mask_mode512bit_condition>
18042    && (INTVAL (operands[2]) == (INTVAL (operands[6]) - 4)
18043        && INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
18044        && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
18045        && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4))"
18047   int mask = 0;
18048   mask |= INTVAL (operands[2]) << 0;
18049   mask |= INTVAL (operands[3]) << 2;
18050   mask |= INTVAL (operands[4]) << 4;
18051   mask |= INTVAL (operands[5]) << 6;
18052   operands[2] = GEN_INT (mask);
18053   return "vperm<ssemodesuffix>\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
18055   [(set_attr "type" "sselog")
18056    (set_attr "prefix" "<mask_prefix2>")
18057    (set_attr "mode" "<sseinsnmode>")])
18059 (define_insn "avx2_permv2ti"
18060   [(set (match_operand:V4DI 0 "register_operand" "=x")
18061         (unspec:V4DI
18062           [(match_operand:V4DI 1 "register_operand" "x")
18063            (match_operand:V4DI 2 "nonimmediate_operand" "xm")
18064            (match_operand:SI 3 "const_0_to_255_operand" "n")]
18065           UNSPEC_VPERMTI))]
18066   "TARGET_AVX2"
18067   "vperm2i128\t{%3, %2, %1, %0|%0, %1, %2, %3}"
18068   [(set_attr "type" "sselog")
18069    (set_attr "prefix" "vex")
18070    (set_attr "mode" "OI")])
18072 (define_insn "avx2_vec_dupv4df"
18073   [(set (match_operand:V4DF 0 "register_operand" "=v")
18074         (vec_duplicate:V4DF
18075           (vec_select:DF
18076             (match_operand:V2DF 1 "register_operand" "v")
18077             (parallel [(const_int 0)]))))]
18078   "TARGET_AVX2"
18079   "vbroadcastsd\t{%1, %0|%0, %1}"
18080   [(set_attr "type" "sselog1")
18081    (set_attr "prefix" "maybe_evex")
18082    (set_attr "mode" "V4DF")])
18084 (define_insn "<avx512>_vec_dup<mode>_1"
18085   [(set (match_operand:VI_AVX512BW 0 "register_operand" "=v,v")
18086         (vec_duplicate:VI_AVX512BW
18087           (vec_select:<ssescalarmode>
18088             (match_operand:VI_AVX512BW 1 "nonimmediate_operand" "v,m")
18089             (parallel [(const_int 0)]))))]
18090   "TARGET_AVX512F"
18091   "@
18092    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}
18093    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %<iptr>1}"
18094   [(set_attr "type" "ssemov")
18095    (set_attr "prefix" "evex")
18096    (set_attr "mode" "<sseinsnmode>")])
18098 (define_insn "<avx512>_vec_dup<mode><mask_name>"
18099   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v")
18100         (vec_duplicate:V48_AVX512VL
18101           (vec_select:<ssescalarmode>
18102             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
18103             (parallel [(const_int 0)]))))]
18104   "TARGET_AVX512F"
18106   /*  There is no DF broadcast (in AVX-512*) to 128b register.
18107       Mimic it with integer variant.  */
18108   if (<MODE>mode == V2DFmode)
18109     return "vpbroadcastq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}";
18111   return "v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %<iptr>1}";
18113   [(set_attr "type" "ssemov")
18114    (set_attr "prefix" "evex")
18115    (set_attr "mode" "<sseinsnmode>")])
18117 (define_insn "<avx512>_vec_dup<mode><mask_name>"
18118   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
18119         (vec_duplicate:VI12_AVX512VL
18120           (vec_select:<ssescalarmode>
18121             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
18122             (parallel [(const_int 0)]))))]
18123   "TARGET_AVX512BW"
18124   "vpbroadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %<iptr>1}"
18125   [(set_attr "type" "ssemov")
18126    (set_attr "prefix" "evex")
18127    (set_attr "mode" "<sseinsnmode>")])
18129 (define_insn "<mask_codefor>avx512f_broadcast<mode><mask_name>"
18130   [(set (match_operand:V16FI 0 "register_operand" "=v,v")
18131         (vec_duplicate:V16FI
18132           (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "v,m")))]
18133   "TARGET_AVX512F"
18134   "@
18135    vshuf<shuffletype>32x4\t{$0x0, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x0}
18136    vbroadcast<shuffletype>32x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18137   [(set_attr "type" "ssemov")
18138    (set_attr "prefix" "evex")
18139    (set_attr "mode" "<sseinsnmode>")])
18141 (define_insn "<mask_codefor>avx512f_broadcast<mode><mask_name>"
18142   [(set (match_operand:V8FI 0 "register_operand" "=v,v")
18143         (vec_duplicate:V8FI
18144           (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "v,m")))]
18145   "TARGET_AVX512F"
18146   "@
18147    vshuf<shuffletype>64x2\t{$0x44, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x44}
18148    vbroadcast<shuffletype>64x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18149   [(set_attr "type" "ssemov")
18150    (set_attr "prefix" "evex")
18151    (set_attr "mode" "<sseinsnmode>")])
18153 (define_insn "<mask_codefor><avx512>_vec_dup_gpr<mode><mask_name>"
18154   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v,v")
18155         (vec_duplicate:VI12_AVX512VL
18156           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "vm,r")))]
18157   "TARGET_AVX512BW"
18158   "@
18159    vpbroadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}
18160    vpbroadcast<bcstscalarsuff>\t{%k1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
18161   [(set_attr "type" "ssemov")
18162    (set_attr "prefix" "evex")
18163    (set_attr "mode" "<sseinsnmode>")])
18165 (define_insn "<mask_codefor><avx512>_vec_dup_gpr<mode><mask_name>"
18166   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v,v")
18167         (vec_duplicate:V48_AVX512VL
18168           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "vm,r")))]
18169   "TARGET_AVX512F"
18170   "v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18171   [(set_attr "type" "ssemov")
18172    (set_attr "prefix" "evex")
18173    (set_attr "mode" "<sseinsnmode>")
18174    (set (attr "enabled")
18175      (if_then_else (eq_attr "alternative" "1")
18176         (symbol_ref "GET_MODE_CLASS (<ssescalarmode>mode) == MODE_INT
18177                      && (<ssescalarmode>mode != DImode || TARGET_64BIT)")
18178         (const_int 1)))])
18180 (define_insn "vec_dupv4sf"
18181   [(set (match_operand:V4SF 0 "register_operand" "=v,v,x")
18182         (vec_duplicate:V4SF
18183           (match_operand:SF 1 "nonimmediate_operand" "Yv,m,0")))]
18184   "TARGET_SSE"
18185   "@
18186    vshufps\t{$0, %1, %1, %0|%0, %1, %1, 0}
18187    vbroadcastss\t{%1, %0|%0, %1}
18188    shufps\t{$0, %0, %0|%0, %0, 0}"
18189   [(set_attr "isa" "avx,avx,noavx")
18190    (set_attr "type" "sseshuf1,ssemov,sseshuf1")
18191    (set_attr "length_immediate" "1,0,1")
18192    (set_attr "prefix_extra" "0,1,*")
18193    (set_attr "prefix" "maybe_evex,maybe_evex,orig")
18194    (set_attr "mode" "V4SF")])
18196 (define_insn "*vec_dupv4si"
18197   [(set (match_operand:V4SI 0 "register_operand"     "=v,v,x")
18198         (vec_duplicate:V4SI
18199           (match_operand:SI 1 "nonimmediate_operand" "Yv,m,0")))]
18200   "TARGET_SSE"
18201   "@
18202    %vpshufd\t{$0, %1, %0|%0, %1, 0}
18203    vbroadcastss\t{%1, %0|%0, %1}
18204    shufps\t{$0, %0, %0|%0, %0, 0}"
18205   [(set_attr "isa" "sse2,avx,noavx")
18206    (set_attr "type" "sselog1,ssemov,sselog1")
18207    (set_attr "length_immediate" "1,0,1")
18208    (set_attr "prefix_extra" "0,1,*")
18209    (set_attr "prefix" "maybe_vex,maybe_evex,orig")
18210    (set_attr "mode" "TI,V4SF,V4SF")])
18212 (define_insn "*vec_dupv2di"
18213   [(set (match_operand:V2DI 0 "register_operand"     "=x,v,v,x")
18214         (vec_duplicate:V2DI
18215           (match_operand:DI 1 "nonimmediate_operand" " 0,Yv,vm,0")))]
18216   "TARGET_SSE"
18217   "@
18218    punpcklqdq\t%0, %0
18219    vpunpcklqdq\t{%d1, %0|%0, %d1}
18220    %vmovddup\t{%1, %0|%0, %1}
18221    movlhps\t%0, %0"
18222   [(set_attr "isa" "sse2_noavx,avx,sse3,noavx")
18223    (set_attr "type" "sselog1,sselog1,sselog1,ssemov")
18224    (set_attr "prefix" "orig,maybe_evex,maybe_vex,orig")
18225    (set_attr "mode" "TI,TI,DF,V4SF")])
18227 (define_insn "avx2_vbroadcasti128_<mode>"
18228   [(set (match_operand:VI_256 0 "register_operand" "=x,v,v")
18229         (vec_concat:VI_256
18230           (match_operand:<ssehalfvecmode> 1 "memory_operand" "m,m,m")
18231           (match_dup 1)))]
18232   "TARGET_AVX2"
18233   "@
18234    vbroadcasti128\t{%1, %0|%0, %1}
18235    vbroadcast<i128vldq>\t{%1, %0|%0, %1}
18236    vbroadcast<shuffletype>32x4\t{%1, %0|%0, %1}"
18237   [(set_attr "isa" "*,avx512dq,avx512vl")
18238    (set_attr "type" "ssemov")
18239    (set_attr "prefix_extra" "1")
18240    (set_attr "prefix" "vex,evex,evex")
18241    (set_attr "mode" "OI")])
18243 ;; Modes handled by AVX vec_dup patterns.
18244 (define_mode_iterator AVX_VEC_DUP_MODE
18245   [V8SI V8SF V4DI V4DF])
18246 (define_mode_attr vecdupssescalarmodesuffix
18247   [(V8SF "ss") (V4DF "sd") (V8SI "ss") (V4DI "sd")])
18248 ;; Modes handled by AVX2 vec_dup patterns.
18249 (define_mode_iterator AVX2_VEC_DUP_MODE
18250   [V32QI V16QI V16HI V8HI V8SI V4SI])
18252 (define_insn "*vec_dup<mode>"
18253   [(set (match_operand:AVX2_VEC_DUP_MODE 0 "register_operand" "=x,x,v")
18254         (vec_duplicate:AVX2_VEC_DUP_MODE
18255           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,x,$r")))]
18256   "TARGET_AVX2"
18257   "@
18258    v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0|%0, %1}
18259    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}
18260    #"
18261   [(set_attr "isa" "*,*,noavx512vl")
18262    (set_attr "type" "ssemov")
18263    (set_attr "prefix_extra" "1")
18264    (set_attr "prefix" "maybe_evex")
18265    (set_attr "mode" "<sseinsnmode>")
18266    (set (attr "preferred_for_speed")
18267      (cond [(eq_attr "alternative" "2")
18268               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
18269            ]
18270            (symbol_ref "true")))])
18272 (define_insn "vec_dup<mode>"
18273   [(set (match_operand:AVX_VEC_DUP_MODE 0 "register_operand" "=x,x,x,v,x")
18274         (vec_duplicate:AVX_VEC_DUP_MODE
18275           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,m,x,v,?x")))]
18276   "TARGET_AVX"
18277   "@
18278    v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0|%0, %1}
18279    vbroadcast<vecdupssescalarmodesuffix>\t{%1, %0|%0, %1}
18280    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}
18281    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %g0|%g0, %x1}
18282    #"
18283   [(set_attr "type" "ssemov")
18284    (set_attr "prefix_extra" "1")
18285    (set_attr "prefix" "maybe_evex")
18286    (set_attr "isa" "avx2,noavx2,avx2,avx512f,noavx2")
18287    (set_attr "mode" "<sseinsnmode>,V8SF,<sseinsnmode>,<sseinsnmode>,V8SF")])
18289 (define_split
18290   [(set (match_operand:AVX2_VEC_DUP_MODE 0 "register_operand")
18291         (vec_duplicate:AVX2_VEC_DUP_MODE
18292           (match_operand:<ssescalarmode> 1 "register_operand")))]
18293   "TARGET_AVX2
18294    /* Disable this splitter if avx512vl_vec_dup_gprv*[qhs]i insn is
18295       available, because then we can broadcast from GPRs directly.
18296       For V*[QH]I modes it requires both -mavx512vl and -mavx512bw,
18297       for V*SI mode it requires just -mavx512vl.  */
18298    && !(TARGET_AVX512VL
18299         && (TARGET_AVX512BW || <ssescalarmode>mode == SImode))
18300    && reload_completed && GENERAL_REG_P (operands[1])"
18301   [(const_int 0)]
18303   emit_insn (gen_vec_setv4si_0 (gen_lowpart (V4SImode, operands[0]),
18304                                 CONST0_RTX (V4SImode),
18305                                 gen_lowpart (SImode, operands[1])));
18306   emit_insn (gen_avx2_pbroadcast<mode> (operands[0],
18307                                         gen_lowpart (<ssexmmmode>mode,
18308                                                      operands[0])));
18309   DONE;
18312 (define_split
18313   [(set (match_operand:AVX_VEC_DUP_MODE 0 "register_operand")
18314         (vec_duplicate:AVX_VEC_DUP_MODE
18315           (match_operand:<ssescalarmode> 1 "register_operand")))]
18316   "TARGET_AVX && !TARGET_AVX2 && reload_completed"
18317   [(set (match_dup 2)
18318         (vec_duplicate:<ssehalfvecmode> (match_dup 1)))
18319    (set (match_dup 0)
18320         (vec_concat:AVX_VEC_DUP_MODE (match_dup 2) (match_dup 2)))]
18321   "operands[2] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);")
18323 (define_insn "avx_vbroadcastf128_<mode>"
18324   [(set (match_operand:V_256 0 "register_operand" "=x,x,x,v,v,v,v")
18325         (vec_concat:V_256
18326           (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "m,0,?x,m,0,m,0")
18327           (match_dup 1)))]
18328   "TARGET_AVX"
18329   "@
18330    vbroadcast<i128>\t{%1, %0|%0, %1}
18331    vinsert<i128>\t{$1, %1, %0, %0|%0, %0, %1, 1}
18332    vperm2<i128>\t{$0, %t1, %t1, %0|%0, %t1, %t1, 0}
18333    vbroadcast<i128vldq>\t{%1, %0|%0, %1}
18334    vinsert<i128vldq>\t{$1, %1, %0, %0|%0, %0, %1, 1}
18335    vbroadcast<shuffletype>32x4\t{%1, %0|%0, %1}
18336    vinsert<shuffletype>32x4\t{$1, %1, %0, %0|%0, %0, %1, 1}"
18337   [(set_attr "isa" "*,*,*,avx512dq,avx512dq,avx512vl,avx512vl")
18338    (set_attr "type" "ssemov,sselog1,sselog1,ssemov,sselog1,ssemov,sselog1")
18339    (set_attr "prefix_extra" "1")
18340    (set_attr "length_immediate" "0,1,1,0,1,0,1")
18341    (set_attr "prefix" "vex,vex,vex,evex,evex,evex,evex")
18342    (set_attr "mode" "<sseinsnmode>")])
18344 ;; For broadcast[i|f]32x2.  Yes there is no v4sf version, only v4si.
18345 (define_mode_iterator VI4F_BRCST32x2
18346   [V16SI (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
18347    V16SF (V8SF "TARGET_AVX512VL")])
18349 (define_mode_attr 64x2mode
18350   [(V8DF "V2DF") (V8DI "V2DI") (V4DI "V2DI") (V4DF "V2DF")])
18352 (define_mode_attr 32x2mode
18353   [(V16SF "V2SF") (V16SI "V2SI") (V8SI "V2SI")
18354   (V8SF "V2SF") (V4SI "V2SI")])
18356 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>"
18357   [(set (match_operand:VI4F_BRCST32x2 0 "register_operand" "=v")
18358         (vec_duplicate:VI4F_BRCST32x2
18359           (vec_select:<32x2mode>
18360             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
18361             (parallel [(const_int 0) (const_int 1)]))))]
18362   "TARGET_AVX512DQ"
18363   "vbroadcast<shuffletype>32x2\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
18364   [(set_attr "type" "ssemov")
18365    (set_attr "prefix_extra" "1")
18366    (set_attr "prefix" "evex")
18367    (set_attr "mode" "<sseinsnmode>")])
18369 (define_insn "<mask_codefor>avx512vl_broadcast<mode><mask_name>_1"
18370   [(set (match_operand:VI4F_256 0 "register_operand" "=v,v")
18371         (vec_duplicate:VI4F_256
18372          (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "v,m")))]
18373   "TARGET_AVX512VL"
18374   "@
18375    vshuf<shuffletype>32x4\t{$0x0, %t1, %t1, %0<mask_operand2>|%0<mask_operand2>, %t1, %t1, 0x0}
18376    vbroadcast<shuffletype>32x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18377   [(set_attr "type" "ssemov")
18378    (set_attr "prefix_extra" "1")
18379    (set_attr "prefix" "evex")
18380    (set_attr "mode" "<sseinsnmode>")])
18382 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>_1"
18383   [(set (match_operand:V16FI 0 "register_operand" "=v,v")
18384        (vec_duplicate:V16FI
18385          (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "v,m")))]
18386   "TARGET_AVX512DQ"
18387   "@
18388    vshuf<shuffletype>32x4\t{$0x44, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x44}
18389    vbroadcast<shuffletype>32x8\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18390   [(set_attr "type" "ssemov")
18391    (set_attr "prefix_extra" "1")
18392    (set_attr "prefix" "evex")
18393    (set_attr "mode" "<sseinsnmode>")])
18395 ;; For broadcast[i|f]64x2
18396 (define_mode_iterator VI8F_BRCST64x2
18397   [V8DI V8DF (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")])
18399 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>_1"
18400   [(set (match_operand:VI8F_BRCST64x2 0 "register_operand" "=v,v")
18401        (vec_duplicate:VI8F_BRCST64x2
18402          (match_operand:<64x2mode> 1 "nonimmediate_operand" "v,m")))]
18403   "TARGET_AVX512DQ"
18404   "@
18405    vshuf<shuffletype>64x2\t{$0x0, %<xtg_mode>1, %<xtg_mode>1, %0<mask_operand2>|%0<mask_operand2>, %<xtg_mode>1, %<xtg_mode>1, 0x0}
18406    vbroadcast<shuffletype>64x2\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18407   [(set_attr "type" "ssemov")
18408    (set_attr "prefix_extra" "1")
18409    (set_attr "prefix" "evex")
18410    (set_attr "mode" "<sseinsnmode>")])
18412 (define_insn "avx512cd_maskb_vec_dup<mode>"
18413   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
18414         (vec_duplicate:VI8_AVX512VL
18415           (zero_extend:DI
18416             (match_operand:QI 1 "register_operand" "Yk"))))]
18417   "TARGET_AVX512CD"
18418   "vpbroadcastmb2q\t{%1, %0|%0, %1}"
18419   [(set_attr "type" "mskmov")
18420    (set_attr "prefix" "evex")
18421    (set_attr "mode" "XI")])
18423 (define_insn "avx512cd_maskw_vec_dup<mode>"
18424   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
18425         (vec_duplicate:VI4_AVX512VL
18426           (zero_extend:SI
18427             (match_operand:HI 1 "register_operand" "Yk"))))]
18428   "TARGET_AVX512CD"
18429   "vpbroadcastmw2d\t{%1, %0|%0, %1}"
18430   [(set_attr "type" "mskmov")
18431    (set_attr "prefix" "evex")
18432    (set_attr "mode" "XI")])
18434 ;; Recognize broadcast as a vec_select as produced by builtin_vec_perm.
18435 ;; If it so happens that the input is in memory, use vbroadcast.
18436 ;; Otherwise use vpermilp (and in the case of 256-bit modes, vperm2f128).
18437 (define_insn "*avx_vperm_broadcast_v4sf"
18438   [(set (match_operand:V4SF 0 "register_operand" "=v,v,v")
18439         (vec_select:V4SF
18440           (match_operand:V4SF 1 "nonimmediate_operand" "m,o,v")
18441           (match_parallel 2 "avx_vbroadcast_operand"
18442             [(match_operand 3 "const_int_operand" "C,n,n")])))]
18443   "TARGET_AVX"
18445   int elt = INTVAL (operands[3]);
18446   switch (which_alternative)
18447     {
18448     case 0:
18449     case 1:
18450       operands[1] = adjust_address_nv (operands[1], SFmode, elt * 4);
18451       return "vbroadcastss\t{%1, %0|%0, %k1}";
18452     case 2:
18453       operands[2] = GEN_INT (elt * 0x55);
18454       return "vpermilps\t{%2, %1, %0|%0, %1, %2}";
18455     default:
18456       gcc_unreachable ();
18457     }
18459   [(set_attr "type" "ssemov,ssemov,sselog1")
18460    (set_attr "prefix_extra" "1")
18461    (set_attr "length_immediate" "0,0,1")
18462    (set_attr "prefix" "maybe_evex")
18463    (set_attr "mode" "SF,SF,V4SF")])
18465 (define_insn_and_split "*avx_vperm_broadcast_<mode>"
18466   [(set (match_operand:VF_256 0 "register_operand" "=v,v,v")
18467         (vec_select:VF_256
18468           (match_operand:VF_256 1 "nonimmediate_operand" "m,o,?v")
18469           (match_parallel 2 "avx_vbroadcast_operand"
18470             [(match_operand 3 "const_int_operand" "C,n,n")])))]
18471   "TARGET_AVX"
18472   "#"
18473   "&& reload_completed && (<MODE>mode != V4DFmode || !TARGET_AVX2)"
18474   [(set (match_dup 0) (vec_duplicate:VF_256 (match_dup 1)))]
18476   rtx op0 = operands[0], op1 = operands[1];
18477   int elt = INTVAL (operands[3]);
18479   if (REG_P (op1))
18480     {
18481       int mask;
18483       if (TARGET_AVX2 && elt == 0)
18484         {
18485           emit_insn (gen_vec_dup<mode> (op0, gen_lowpart (<ssescalarmode>mode,
18486                                                           op1)));
18487           DONE;
18488         }
18490       /* Shuffle element we care about into all elements of the 128-bit lane.
18491          The other lane gets shuffled too, but we don't care.  */
18492       if (<MODE>mode == V4DFmode)
18493         mask = (elt & 1 ? 15 : 0);
18494       else
18495         mask = (elt & 3) * 0x55;
18496       emit_insn (gen_avx_vpermil<mode> (op0, op1, GEN_INT (mask)));
18498       /* Shuffle the lane we care about into both lanes of the dest.  */
18499       mask = (elt / (<ssescalarnum> / 2)) * 0x11;
18500       if (EXT_REX_SSE_REG_P (op0))
18501         {
18502           /* There is no EVEX VPERM2F128, but we can use either VBROADCASTSS
18503              or VSHUFF128.  */
18504           gcc_assert (<MODE>mode == V8SFmode);
18505           if ((mask & 1) == 0)
18506             emit_insn (gen_avx2_vec_dupv8sf (op0,
18507                                              gen_lowpart (V4SFmode, op0)));
18508           else
18509             emit_insn (gen_avx512vl_shuf_f32x4_1 (op0, op0, op0,
18510                                                   GEN_INT (4), GEN_INT (5),
18511                                                   GEN_INT (6), GEN_INT (7),
18512                                                   GEN_INT (12), GEN_INT (13),
18513                                                   GEN_INT (14), GEN_INT (15)));
18514           DONE;
18515         }
18517       emit_insn (gen_avx_vperm2f128<mode>3 (op0, op0, op0, GEN_INT (mask)));
18518       DONE;
18519     }
18521   operands[1] = adjust_address (op1, <ssescalarmode>mode,
18522                                 elt * GET_MODE_SIZE (<ssescalarmode>mode));
18525 (define_expand "<sse2_avx_avx512f>_vpermil<mode><mask_name>"
18526   [(set (match_operand:VF2 0 "register_operand")
18527         (vec_select:VF2
18528           (match_operand:VF2 1 "nonimmediate_operand")
18529           (match_operand:SI 2 "const_0_to_255_operand")))]
18530   "TARGET_AVX && <mask_mode512bit_condition>"
18532   int mask = INTVAL (operands[2]);
18533   rtx perm[<ssescalarnum>];
18535   int i;
18536   for (i = 0; i < <ssescalarnum>; i = i + 2)
18537     {
18538       perm[i]     = GEN_INT (((mask >> i)       & 1) + i);
18539       perm[i + 1] = GEN_INT (((mask >> (i + 1)) & 1) + i);
18540     }
18542   operands[2]
18543     = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (<ssescalarnum>, perm));
18546 (define_expand "<sse2_avx_avx512f>_vpermil<mode><mask_name>"
18547   [(set (match_operand:VF1 0 "register_operand")
18548         (vec_select:VF1
18549           (match_operand:VF1 1 "nonimmediate_operand")
18550           (match_operand:SI 2 "const_0_to_255_operand")))]
18551   "TARGET_AVX && <mask_mode512bit_condition>"
18553   int mask = INTVAL (operands[2]);
18554   rtx perm[<ssescalarnum>];
18556   int i;
18557   for (i = 0; i < <ssescalarnum>; i = i + 4)
18558     {
18559       perm[i]     = GEN_INT (((mask >> 0) & 3) + i);
18560       perm[i + 1] = GEN_INT (((mask >> 2) & 3) + i);
18561       perm[i + 2] = GEN_INT (((mask >> 4) & 3) + i);
18562       perm[i + 3] = GEN_INT (((mask >> 6) & 3) + i);
18563     }
18565   operands[2]
18566     = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (<ssescalarnum>, perm));
18569 (define_insn "*<sse2_avx_avx512f>_vpermilp<mode><mask_name>"
18570   [(set (match_operand:VF 0 "register_operand" "=v")
18571         (vec_select:VF
18572           (match_operand:VF 1 "nonimmediate_operand" "vm")
18573           (match_parallel 2 ""
18574             [(match_operand 3 "const_int_operand")])))]
18575   "TARGET_AVX && <mask_mode512bit_condition>
18576    && avx_vpermilp_parallel (operands[2], <MODE>mode)"
18578   int mask = avx_vpermilp_parallel (operands[2], <MODE>mode) - 1;
18579   operands[2] = GEN_INT (mask);
18580   return "vpermil<ssemodesuffix>\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}";
18582   [(set_attr "type" "sselog")
18583    (set_attr "prefix_extra" "1")
18584    (set_attr "length_immediate" "1")
18585    (set_attr "prefix" "<mask_prefix>")
18586    (set_attr "mode" "<sseinsnmode>")])
18588 (define_insn "<sse2_avx_avx512f>_vpermilvar<mode>3<mask_name>"
18589   [(set (match_operand:VF 0 "register_operand" "=v")
18590         (unspec:VF
18591           [(match_operand:VF 1 "register_operand" "v")
18592            (match_operand:<sseintvecmode> 2 "nonimmediate_operand" "vm")]
18593           UNSPEC_VPERMIL))]
18594   "TARGET_AVX && <mask_mode512bit_condition>"
18595   "vpermil<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18596   [(set_attr "type" "sselog")
18597    (set_attr "prefix_extra" "1")
18598    (set_attr "btver2_decode" "vector")
18599    (set_attr "prefix" "<mask_prefix>")
18600    (set_attr "mode" "<sseinsnmode>")])
18602 (define_mode_iterator VPERMI2
18603   [V16SI V16SF V8DI V8DF
18604    (V8SI "TARGET_AVX512VL") (V8SF "TARGET_AVX512VL")
18605    (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")
18606    (V4SI "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
18607    (V2DI "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")
18608    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX512BW && TARGET_AVX512VL")
18609    (V8HI "TARGET_AVX512BW && TARGET_AVX512VL")
18610    (V64QI "TARGET_AVX512VBMI") (V32QI "TARGET_AVX512VBMI && TARGET_AVX512VL")
18611    (V16QI "TARGET_AVX512VBMI && TARGET_AVX512VL")])
18613 (define_mode_iterator VPERMI2I
18614   [V16SI V8DI
18615    (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
18616    (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")
18617    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX512BW && TARGET_AVX512VL")
18618    (V8HI "TARGET_AVX512BW && TARGET_AVX512VL")
18619    (V64QI "TARGET_AVX512VBMI") (V32QI "TARGET_AVX512VBMI && TARGET_AVX512VL")
18620    (V16QI "TARGET_AVX512VBMI && TARGET_AVX512VL")])
18622 (define_expand "<avx512>_vpermi2var<mode>3_mask"
18623   [(set (match_operand:VPERMI2 0 "register_operand")
18624         (vec_merge:VPERMI2
18625           (unspec:VPERMI2
18626             [(match_operand:<sseintvecmode> 2 "register_operand")
18627              (match_operand:VPERMI2 1 "register_operand")
18628              (match_operand:VPERMI2 3 "nonimmediate_operand")]
18629             UNSPEC_VPERMT2)
18630           (match_dup 5)
18631           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
18632   "TARGET_AVX512F"
18634   operands[2] = force_reg (<sseintvecmode>mode, operands[2]);
18635   operands[5] = gen_lowpart (<MODE>mode, operands[2]);
18638 (define_insn "*<avx512>_vpermi2var<mode>3_mask"
18639   [(set (match_operand:VPERMI2I 0 "register_operand" "=v")
18640         (vec_merge:VPERMI2I
18641           (unspec:VPERMI2I
18642             [(match_operand:<sseintvecmode> 2 "register_operand" "0")
18643              (match_operand:VPERMI2I 1 "register_operand" "v")
18644              (match_operand:VPERMI2I 3 "nonimmediate_operand" "vm")]
18645             UNSPEC_VPERMT2)
18646           (match_dup 2)
18647           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
18648   "TARGET_AVX512F"
18649   "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
18650   [(set_attr "type" "sselog")
18651    (set_attr "prefix" "evex")
18652    (set_attr "mode" "<sseinsnmode>")])
18654 (define_insn "*<avx512>_vpermi2var<mode>3_mask"
18655   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
18656         (vec_merge:VF_AVX512VL
18657           (unspec:VF_AVX512VL
18658             [(match_operand:<sseintvecmode> 2 "register_operand" "0")
18659              (match_operand:VF_AVX512VL 1 "register_operand" "v")
18660              (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "vm")]
18661             UNSPEC_VPERMT2)
18662           (subreg:VF_AVX512VL (match_dup 2) 0)
18663           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
18664   "TARGET_AVX512F"
18665   "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
18666   [(set_attr "type" "sselog")
18667    (set_attr "prefix" "evex")
18668    (set_attr "mode" "<sseinsnmode>")])
18670 (define_expand "<avx512>_vpermt2var<mode>3_maskz"
18671   [(match_operand:VPERMI2 0 "register_operand")
18672    (match_operand:<sseintvecmode> 1 "register_operand")
18673    (match_operand:VPERMI2 2 "register_operand")
18674    (match_operand:VPERMI2 3 "nonimmediate_operand")
18675    (match_operand:<avx512fmaskmode> 4 "register_operand")]
18676   "TARGET_AVX512F"
18678   emit_insn (gen_<avx512>_vpermt2var<mode>3_maskz_1 (
18679         operands[0], operands[1], operands[2], operands[3],
18680         CONST0_RTX (<MODE>mode), operands[4]));
18681   DONE;
18684 (define_insn "<avx512>_vpermt2var<mode>3<sd_maskz_name>"
18685   [(set (match_operand:VPERMI2 0 "register_operand" "=v,v")
18686         (unspec:VPERMI2
18687           [(match_operand:<sseintvecmode> 1 "register_operand" "v,0")
18688            (match_operand:VPERMI2 2 "register_operand" "0,v")
18689            (match_operand:VPERMI2 3 "nonimmediate_operand" "vm,vm")]
18690           UNSPEC_VPERMT2))]
18691   "TARGET_AVX512F"
18692   "@
18693    vpermt2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}
18694    vpermi2<ssemodesuffix>\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}"
18695   [(set_attr "type" "sselog")
18696    (set_attr "prefix" "evex")
18697    (set_attr "mode" "<sseinsnmode>")])
18699 (define_insn "<avx512>_vpermt2var<mode>3_mask"
18700   [(set (match_operand:VPERMI2 0 "register_operand" "=v")
18701         (vec_merge:VPERMI2
18702           (unspec:VPERMI2
18703             [(match_operand:<sseintvecmode> 1 "register_operand" "v")
18704             (match_operand:VPERMI2 2 "register_operand" "0")
18705             (match_operand:VPERMI2 3 "nonimmediate_operand" "vm")]
18706             UNSPEC_VPERMT2)
18707           (match_dup 2)
18708           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
18709   "TARGET_AVX512F"
18710   "vpermt2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
18711   [(set_attr "type" "sselog")
18712    (set_attr "prefix" "evex")
18713    (set_attr "mode" "<sseinsnmode>")])
18715 (define_expand "avx_vperm2f128<mode>3"
18716   [(set (match_operand:AVX256MODE2P 0 "register_operand")
18717         (unspec:AVX256MODE2P
18718           [(match_operand:AVX256MODE2P 1 "register_operand")
18719            (match_operand:AVX256MODE2P 2 "nonimmediate_operand")
18720            (match_operand:SI 3 "const_0_to_255_operand")]
18721           UNSPEC_VPERMIL2F128))]
18722   "TARGET_AVX"
18724   int mask = INTVAL (operands[3]);
18725   if ((mask & 0x88) == 0)
18726     {
18727       rtx perm[<ssescalarnum>], t1, t2;
18728       int i, base, nelt = <ssescalarnum>, nelt2 = nelt / 2;
18730       base = (mask & 3) * nelt2;
18731       for (i = 0; i < nelt2; ++i)
18732         perm[i] = GEN_INT (base + i);
18734       base = ((mask >> 4) & 3) * nelt2;
18735       for (i = 0; i < nelt2; ++i)
18736         perm[i + nelt2] = GEN_INT (base + i);
18738       t2 = gen_rtx_VEC_CONCAT (<ssedoublevecmode>mode,
18739                                operands[1], operands[2]);
18740       t1 = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (nelt, perm));
18741       t2 = gen_rtx_VEC_SELECT (<MODE>mode, t2, t1);
18742       t2 = gen_rtx_SET (operands[0], t2);
18743       emit_insn (t2);
18744       DONE;
18745     }
18748 ;; Note that bits 7 and 3 of the imm8 allow lanes to be zeroed, which
18749 ;; means that in order to represent this properly in rtl we'd have to
18750 ;; nest *another* vec_concat with a zero operand and do the select from
18751 ;; a 4x wide vector.  That doesn't seem very nice.
18752 (define_insn "*avx_vperm2f128<mode>_full"
18753   [(set (match_operand:AVX256MODE2P 0 "register_operand" "=x")
18754         (unspec:AVX256MODE2P
18755           [(match_operand:AVX256MODE2P 1 "register_operand" "x")
18756            (match_operand:AVX256MODE2P 2 "nonimmediate_operand" "xm")
18757            (match_operand:SI 3 "const_0_to_255_operand" "n")]
18758           UNSPEC_VPERMIL2F128))]
18759   "TARGET_AVX"
18760   "vperm2<i128>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
18761   [(set_attr "type" "sselog")
18762    (set_attr "prefix_extra" "1")
18763    (set_attr "length_immediate" "1")
18764    (set_attr "prefix" "vex")
18765    (set_attr "mode" "<sseinsnmode>")])
18767 (define_insn "*avx_vperm2f128<mode>_nozero"
18768   [(set (match_operand:AVX256MODE2P 0 "register_operand" "=x")
18769         (vec_select:AVX256MODE2P
18770           (vec_concat:<ssedoublevecmode>
18771             (match_operand:AVX256MODE2P 1 "register_operand" "x")
18772             (match_operand:AVX256MODE2P 2 "nonimmediate_operand" "xm"))
18773           (match_parallel 3 ""
18774             [(match_operand 4 "const_int_operand")])))]
18775   "TARGET_AVX
18776    && avx_vperm2f128_parallel (operands[3], <MODE>mode)"
18778   int mask = avx_vperm2f128_parallel (operands[3], <MODE>mode) - 1;
18779   if (mask == 0x12)
18780     return "vinsert<i128>\t{$0, %x2, %1, %0|%0, %1, %x2, 0}";
18781   if (mask == 0x20)
18782     return "vinsert<i128>\t{$1, %x2, %1, %0|%0, %1, %x2, 1}";
18783   operands[3] = GEN_INT (mask);
18784   return "vperm2<i128>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
18786   [(set_attr "type" "sselog")
18787    (set_attr "prefix_extra" "1")
18788    (set_attr "length_immediate" "1")
18789    (set_attr "prefix" "vex")
18790    (set_attr "mode" "<sseinsnmode>")])
18792 (define_insn "*ssse3_palignr<mode>_perm"
18793   [(set (match_operand:V_128 0 "register_operand" "=x,x,v")
18794       (vec_select:V_128
18795         (match_operand:V_128 1 "register_operand" "0,x,v")
18796         (match_parallel 2 "palignr_operand"
18797           [(match_operand 3 "const_int_operand" "n,n,n")])))]
18798   "TARGET_SSSE3"
18800   operands[2] = (GEN_INT (INTVAL (operands[3])
18801                  * GET_MODE_UNIT_SIZE (GET_MODE (operands[0]))));
18803   switch (which_alternative)
18804     {
18805     case 0:
18806       return "palignr\t{%2, %1, %0|%0, %1, %2}";
18807     case 1:
18808     case 2:
18809       return "vpalignr\t{%2, %1, %1, %0|%0, %1, %1, %2}";
18810     default:
18811       gcc_unreachable ();
18812     }
18814   [(set_attr "isa" "noavx,avx,avx512bw")
18815    (set_attr "type" "sseishft")
18816    (set_attr "atom_unit" "sishuf")
18817    (set_attr "prefix_data16" "1,*,*")
18818    (set_attr "prefix_extra" "1")
18819    (set_attr "length_immediate" "1")
18820    (set_attr "prefix" "orig,vex,evex")])
18822 (define_expand "avx512vl_vinsert<mode>"
18823   [(match_operand:VI48F_256 0 "register_operand")
18824    (match_operand:VI48F_256 1 "register_operand")
18825    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
18826    (match_operand:SI 3 "const_0_to_1_operand")
18827    (match_operand:VI48F_256 4 "register_operand")
18828    (match_operand:<avx512fmaskmode> 5 "register_operand")]
18829   "TARGET_AVX512VL"
18831   rtx (*insn)(rtx, rtx, rtx, rtx, rtx);
18833   switch (INTVAL (operands[3]))
18834     {
18835     case 0:
18836       insn = gen_vec_set_lo_<mode>_mask;
18837       break;
18838     case 1:
18839       insn = gen_vec_set_hi_<mode>_mask;
18840       break;
18841     default:
18842       gcc_unreachable ();
18843     }
18845   emit_insn (insn (operands[0], operands[1], operands[2], operands[4],
18846                    operands[5]));
18847   DONE;
18850 (define_expand "avx_vinsertf128<mode>"
18851   [(match_operand:V_256 0 "register_operand")
18852    (match_operand:V_256 1 "register_operand")
18853    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
18854    (match_operand:SI 3 "const_0_to_1_operand")]
18855   "TARGET_AVX"
18857   rtx (*insn)(rtx, rtx, rtx);
18859   switch (INTVAL (operands[3]))
18860     {
18861     case 0:
18862       insn = gen_vec_set_lo_<mode>;
18863       break;
18864     case 1:
18865       insn = gen_vec_set_hi_<mode>;
18866       break;
18867     default:
18868       gcc_unreachable ();
18869     }
18871   emit_insn (insn (operands[0], operands[1], operands[2]));
18872   DONE;
18875 (define_insn "vec_set_lo_<mode><mask_name>"
18876   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
18877         (vec_concat:VI8F_256
18878           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
18879           (vec_select:<ssehalfvecmode>
18880             (match_operand:VI8F_256 1 "register_operand" "v")
18881             (parallel [(const_int 2) (const_int 3)]))))]
18882   "TARGET_AVX && <mask_avx512dq_condition>"
18884   if (TARGET_AVX512DQ)
18885     return "vinsert<shuffletype>64x2\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
18886   else if (TARGET_AVX512VL)
18887     return "vinsert<shuffletype>32x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
18888   else
18889     return "vinsert<i128>\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}";
18891   [(set_attr "type" "sselog")
18892    (set_attr "prefix_extra" "1")
18893    (set_attr "length_immediate" "1")
18894    (set_attr "prefix" "vex")
18895    (set_attr "mode" "<sseinsnmode>")])
18897 (define_insn "vec_set_hi_<mode><mask_name>"
18898   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
18899         (vec_concat:VI8F_256
18900           (vec_select:<ssehalfvecmode>
18901             (match_operand:VI8F_256 1 "register_operand" "v")
18902             (parallel [(const_int 0) (const_int 1)]))
18903           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
18904   "TARGET_AVX && <mask_avx512dq_condition>"
18906   if (TARGET_AVX512DQ)
18907     return "vinsert<shuffletype>64x2\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
18908   else if (TARGET_AVX512VL)
18909     return "vinsert<shuffletype>32x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
18910   else
18911     return "vinsert<i128>\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}";
18913   [(set_attr "type" "sselog")
18914    (set_attr "prefix_extra" "1")
18915    (set_attr "length_immediate" "1")
18916    (set_attr "prefix" "vex")
18917    (set_attr "mode" "<sseinsnmode>")])
18919 (define_insn "vec_set_lo_<mode><mask_name>"
18920   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
18921         (vec_concat:VI4F_256
18922           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
18923           (vec_select:<ssehalfvecmode>
18924             (match_operand:VI4F_256 1 "register_operand" "v")
18925             (parallel [(const_int 4) (const_int 5)
18926                        (const_int 6) (const_int 7)]))))]
18927   "TARGET_AVX"
18929   if (TARGET_AVX512VL)
18930     return "vinsert<shuffletype>32x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
18931   else
18932     return "vinsert<i128>\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}";
18934   [(set_attr "type" "sselog")
18935    (set_attr "prefix_extra" "1")
18936    (set_attr "length_immediate" "1")
18937    (set_attr "prefix" "vex")
18938    (set_attr "mode" "<sseinsnmode>")])
18940 (define_insn "vec_set_hi_<mode><mask_name>"
18941   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
18942         (vec_concat:VI4F_256
18943           (vec_select:<ssehalfvecmode>
18944             (match_operand:VI4F_256 1 "register_operand" "v")
18945             (parallel [(const_int 0) (const_int 1)
18946                        (const_int 2) (const_int 3)]))
18947           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
18948   "TARGET_AVX"
18950   if (TARGET_AVX512VL)
18951     return "vinsert<shuffletype>32x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
18952   else
18953     return "vinsert<i128>\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}";
18955   [(set_attr "type" "sselog")
18956    (set_attr "prefix_extra" "1")
18957    (set_attr "length_immediate" "1")
18958    (set_attr "prefix" "vex")
18959    (set_attr "mode" "<sseinsnmode>")])
18961 (define_insn "vec_set_lo_v16hi"
18962   [(set (match_operand:V16HI 0 "register_operand" "=x,v")
18963         (vec_concat:V16HI
18964           (match_operand:V8HI 2 "nonimmediate_operand" "xm,vm")
18965           (vec_select:V8HI
18966             (match_operand:V16HI 1 "register_operand" "x,v")
18967             (parallel [(const_int 8) (const_int 9)
18968                        (const_int 10) (const_int 11)
18969                        (const_int 12) (const_int 13)
18970                        (const_int 14) (const_int 15)]))))]
18971   "TARGET_AVX"
18972   "@
18973    vinsert%~128\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}
18974    vinserti32x4\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}"
18975   [(set_attr "type" "sselog")
18976    (set_attr "prefix_extra" "1")
18977    (set_attr "length_immediate" "1")
18978    (set_attr "prefix" "vex,evex")
18979    (set_attr "mode" "OI")])
18981 (define_insn "vec_set_hi_v16hi"
18982   [(set (match_operand:V16HI 0 "register_operand" "=x,v")
18983         (vec_concat:V16HI
18984           (vec_select:V8HI
18985             (match_operand:V16HI 1 "register_operand" "x,v")
18986             (parallel [(const_int 0) (const_int 1)
18987                        (const_int 2) (const_int 3)
18988                        (const_int 4) (const_int 5)
18989                        (const_int 6) (const_int 7)]))
18990           (match_operand:V8HI 2 "nonimmediate_operand" "xm,vm")))]
18991   "TARGET_AVX"
18992   "@
18993    vinsert%~128\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}
18994    vinserti32x4\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}"
18995   [(set_attr "type" "sselog")
18996    (set_attr "prefix_extra" "1")
18997    (set_attr "length_immediate" "1")
18998    (set_attr "prefix" "vex,evex")
18999    (set_attr "mode" "OI")])
19001 (define_insn "vec_set_lo_v32qi"
19002   [(set (match_operand:V32QI 0 "register_operand" "=x,v")
19003         (vec_concat:V32QI
19004           (match_operand:V16QI 2 "nonimmediate_operand" "xm,v")
19005           (vec_select:V16QI
19006             (match_operand:V32QI 1 "register_operand" "x,v")
19007             (parallel [(const_int 16) (const_int 17)
19008                        (const_int 18) (const_int 19)
19009                        (const_int 20) (const_int 21)
19010                        (const_int 22) (const_int 23)
19011                        (const_int 24) (const_int 25)
19012                        (const_int 26) (const_int 27)
19013                        (const_int 28) (const_int 29)
19014                        (const_int 30) (const_int 31)]))))]
19015   "TARGET_AVX"
19016   "@
19017    vinsert%~128\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}
19018    vinserti32x4\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}"
19019   [(set_attr "type" "sselog")
19020    (set_attr "prefix_extra" "1")
19021    (set_attr "length_immediate" "1")
19022    (set_attr "prefix" "vex,evex")
19023    (set_attr "mode" "OI")])
19025 (define_insn "vec_set_hi_v32qi"
19026   [(set (match_operand:V32QI 0 "register_operand" "=x,v")
19027         (vec_concat:V32QI
19028           (vec_select:V16QI
19029             (match_operand:V32QI 1 "register_operand" "x,v")
19030             (parallel [(const_int 0) (const_int 1)
19031                        (const_int 2) (const_int 3)
19032                        (const_int 4) (const_int 5)
19033                        (const_int 6) (const_int 7)
19034                        (const_int 8) (const_int 9)
19035                        (const_int 10) (const_int 11)
19036                        (const_int 12) (const_int 13)
19037                        (const_int 14) (const_int 15)]))
19038           (match_operand:V16QI 2 "nonimmediate_operand" "xm,vm")))]
19039   "TARGET_AVX"
19040   "@
19041    vinsert%~128\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}
19042    vinserti32x4\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}"
19043   [(set_attr "type" "sselog")
19044    (set_attr "prefix_extra" "1")
19045    (set_attr "length_immediate" "1")
19046    (set_attr "prefix" "vex,evex")
19047    (set_attr "mode" "OI")])
19049 (define_insn "<avx_avx2>_maskload<ssemodesuffix><avxsizesuffix>"
19050   [(set (match_operand:V48_AVX2 0 "register_operand" "=x")
19051         (unspec:V48_AVX2
19052           [(match_operand:<sseintvecmode> 2 "register_operand" "x")
19053            (match_operand:V48_AVX2 1 "memory_operand" "m")]
19054           UNSPEC_MASKMOV))]
19055   "TARGET_AVX"
19056   "v<sseintprefix>maskmov<ssemodesuffix>\t{%1, %2, %0|%0, %2, %1}"
19057   [(set_attr "type" "sselog1")
19058    (set_attr "prefix_extra" "1")
19059    (set_attr "prefix" "vex")
19060    (set_attr "btver2_decode" "vector")
19061    (set_attr "mode" "<sseinsnmode>")])
19063 (define_insn "<avx_avx2>_maskstore<ssemodesuffix><avxsizesuffix>"
19064   [(set (match_operand:V48_AVX2 0 "memory_operand" "+m")
19065         (unspec:V48_AVX2
19066           [(match_operand:<sseintvecmode> 1 "register_operand" "x")
19067            (match_operand:V48_AVX2 2 "register_operand" "x")
19068            (match_dup 0)]
19069           UNSPEC_MASKMOV))]
19070   "TARGET_AVX"
19071   "v<sseintprefix>maskmov<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
19072   [(set_attr "type" "sselog1")
19073    (set_attr "prefix_extra" "1")
19074    (set_attr "prefix" "vex")
19075    (set_attr "btver2_decode" "vector") 
19076    (set_attr "mode" "<sseinsnmode>")])
19078 (define_expand "maskload<mode><sseintvecmodelower>"
19079   [(set (match_operand:V48_AVX2 0 "register_operand")
19080         (unspec:V48_AVX2
19081           [(match_operand:<sseintvecmode> 2 "register_operand")
19082            (match_operand:V48_AVX2 1 "memory_operand")]
19083           UNSPEC_MASKMOV))]
19084   "TARGET_AVX")
19086 (define_expand "maskload<mode><avx512fmaskmodelower>"
19087   [(set (match_operand:V48_AVX512VL 0 "register_operand")
19088         (vec_merge:V48_AVX512VL
19089           (match_operand:V48_AVX512VL 1 "memory_operand")
19090           (match_dup 0)
19091           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
19092   "TARGET_AVX512F")
19094 (define_expand "maskload<mode><avx512fmaskmodelower>"
19095   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
19096         (vec_merge:VI12_AVX512VL
19097           (match_operand:VI12_AVX512VL 1 "memory_operand")
19098           (match_dup 0)
19099           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
19100   "TARGET_AVX512BW")
19102 (define_expand "maskstore<mode><sseintvecmodelower>"
19103   [(set (match_operand:V48_AVX2 0 "memory_operand")
19104         (unspec:V48_AVX2
19105           [(match_operand:<sseintvecmode> 2 "register_operand")
19106            (match_operand:V48_AVX2 1 "register_operand")
19107            (match_dup 0)]
19108           UNSPEC_MASKMOV))]
19109   "TARGET_AVX")
19111 (define_expand "maskstore<mode><avx512fmaskmodelower>"
19112   [(set (match_operand:V48_AVX512VL 0 "memory_operand")
19113         (vec_merge:V48_AVX512VL
19114           (match_operand:V48_AVX512VL 1 "register_operand")
19115           (match_dup 0)
19116           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
19117   "TARGET_AVX512F")
19119 (define_expand "maskstore<mode><avx512fmaskmodelower>"
19120   [(set (match_operand:VI12_AVX512VL 0 "memory_operand")
19121         (vec_merge:VI12_AVX512VL
19122           (match_operand:VI12_AVX512VL 1 "register_operand")
19123           (match_dup 0)
19124           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
19125   "TARGET_AVX512BW")
19127 (define_expand "cbranch<mode>4"
19128   [(set (reg:CC FLAGS_REG)
19129         (compare:CC (match_operand:VI48_AVX 1 "register_operand")
19130                     (match_operand:VI48_AVX 2 "nonimmediate_operand")))
19131    (set (pc) (if_then_else
19132                (match_operator 0 "bt_comparison_operator"
19133                 [(reg:CC FLAGS_REG) (const_int 0)])
19134                (label_ref (match_operand 3))
19135                (pc)))]
19136   "TARGET_SSE4_1"
19138   ix86_expand_branch (GET_CODE (operands[0]),
19139                       operands[1], operands[2], operands[3]);
19140   DONE;
19144 (define_insn_and_split "avx_<castmode><avxsizesuffix>_<castmode>"
19145   [(set (match_operand:AVX256MODE2P 0 "nonimmediate_operand" "=x,m")
19146         (unspec:AVX256MODE2P
19147           [(match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "xm,x")]
19148           UNSPEC_CAST))]
19149   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
19150   "#"
19151   "&& reload_completed"
19152   [(set (match_dup 0) (match_dup 1))]
19154   if (REG_P (operands[0]))
19155     operands[0] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);
19156   else
19157     operands[1] = lowpart_subreg (<MODE>mode, operands[1],
19158                                   <ssehalfvecmode>mode);
19161 ;; Modes handled by vec_init expanders.
19162 (define_mode_iterator VEC_INIT_MODE
19163   [(V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
19164    (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI
19165    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
19166    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI
19167    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
19168    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")
19169    (V4TI "TARGET_AVX512F") (V2TI "TARGET_AVX")])
19171 ;; Likewise, but for initialization from half sized vectors.
19172 ;; Thus, these are all VEC_INIT_MODE modes except V2??.
19173 (define_mode_iterator VEC_INIT_HALF_MODE
19174   [(V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
19175    (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI
19176    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
19177    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX")
19178    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
19179    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX")
19180    (V4TI "TARGET_AVX512F")])
19182 (define_expand "vec_init<mode><ssescalarmodelower>"
19183   [(match_operand:VEC_INIT_MODE 0 "register_operand")
19184    (match_operand 1)]
19185   "TARGET_SSE"
19187   ix86_expand_vector_init (false, operands[0], operands[1]);
19188   DONE;
19191 (define_expand "vec_init<mode><ssehalfvecmodelower>"
19192   [(match_operand:VEC_INIT_HALF_MODE 0 "register_operand")
19193    (match_operand 1)]
19194   "TARGET_SSE"
19196   ix86_expand_vector_init (false, operands[0], operands[1]);
19197   DONE;
19200 (define_insn "<avx2_avx512>_ashrv<mode><mask_name>"
19201   [(set (match_operand:VI48_AVX512F_AVX512VL 0 "register_operand" "=v")
19202         (ashiftrt:VI48_AVX512F_AVX512VL
19203           (match_operand:VI48_AVX512F_AVX512VL 1 "register_operand" "v")
19204           (match_operand:VI48_AVX512F_AVX512VL 2 "nonimmediate_operand" "vm")))]
19205   "TARGET_AVX2 && <mask_mode512bit_condition>"
19206   "vpsrav<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19207   [(set_attr "type" "sseishft")
19208    (set_attr "prefix" "maybe_evex")
19209    (set_attr "mode" "<sseinsnmode>")])
19211 (define_insn "<avx2_avx512>_ashrv<mode><mask_name>"
19212   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
19213         (ashiftrt:VI2_AVX512VL
19214           (match_operand:VI2_AVX512VL 1 "register_operand" "v")
19215           (match_operand:VI2_AVX512VL 2 "nonimmediate_operand" "vm")))]
19216   "TARGET_AVX512BW"
19217   "vpsravw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19218   [(set_attr "type" "sseishft")
19219    (set_attr "prefix" "maybe_evex")
19220    (set_attr "mode" "<sseinsnmode>")])
19222 (define_insn "<avx2_avx512>_<shift_insn>v<mode><mask_name>"
19223   [(set (match_operand:VI48_AVX512F 0 "register_operand" "=v")
19224         (any_lshift:VI48_AVX512F
19225           (match_operand:VI48_AVX512F 1 "register_operand" "v")
19226           (match_operand:VI48_AVX512F 2 "nonimmediate_operand" "vm")))]
19227   "TARGET_AVX2 && <mask_mode512bit_condition>"
19228   "vp<vshift>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19229   [(set_attr "type" "sseishft")
19230    (set_attr "prefix" "maybe_evex")
19231    (set_attr "mode" "<sseinsnmode>")])
19233 (define_insn "<avx2_avx512>_<shift_insn>v<mode><mask_name>"
19234   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
19235         (any_lshift:VI2_AVX512VL
19236           (match_operand:VI2_AVX512VL 1 "register_operand" "v")
19237           (match_operand:VI2_AVX512VL 2 "nonimmediate_operand" "vm")))]
19238   "TARGET_AVX512BW"
19239   "vp<vshift>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19240   [(set_attr "type" "sseishft")
19241    (set_attr "prefix" "maybe_evex")
19242    (set_attr "mode" "<sseinsnmode>")])
19244 (define_insn "avx_vec_concat<mode>"
19245   [(set (match_operand:V_256_512 0 "register_operand" "=x,v,x,Yv")
19246         (vec_concat:V_256_512
19247           (match_operand:<ssehalfvecmode> 1 "register_operand" "x,v,x,v")
19248           (match_operand:<ssehalfvecmode> 2 "nonimm_or_0_operand" "xm,vm,C,C")))]
19249   "TARGET_AVX"
19251   switch (which_alternative)
19252     {
19253     case 0:
19254       return "vinsert<i128>\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
19255     case 1:
19256       if (<MODE_SIZE> == 64)
19257         {
19258           if (TARGET_AVX512DQ && GET_MODE_SIZE (<ssescalarmode>mode) == 4)
19259             return "vinsert<shuffletype>32x8\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
19260           else
19261             return "vinsert<shuffletype>64x4\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
19262         }
19263       else
19264         {
19265           if (TARGET_AVX512DQ && GET_MODE_SIZE (<ssescalarmode>mode) == 8)
19266             return "vinsert<shuffletype>64x2\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
19267           else
19268             return "vinsert<shuffletype>32x4\t{$0x1, %2, %<xtg_mode>1, %0|%0, %<xtg_mode>1, %2, 0x1}";
19269         }
19270     case 2:
19271     case 3:
19272       switch (get_attr_mode (insn))
19273         {
19274         case MODE_V16SF:
19275           return "vmovaps\t{%1, %t0|%t0, %1}";
19276         case MODE_V8DF:
19277           return "vmovapd\t{%1, %t0|%t0, %1}";
19278         case MODE_V8SF:
19279           return "vmovaps\t{%1, %x0|%x0, %1}";
19280         case MODE_V4DF:
19281           return "vmovapd\t{%1, %x0|%x0, %1}";
19282         case MODE_XI:
19283           if (which_alternative == 2)
19284             return "vmovdqa\t{%1, %t0|%t0, %1}";
19285           else if (GET_MODE_SIZE (<ssescalarmode>mode) == 8)
19286             return "vmovdqa64\t{%1, %t0|%t0, %1}";
19287           else
19288             return "vmovdqa32\t{%1, %t0|%t0, %1}";
19289         case MODE_OI:
19290           if (which_alternative == 2)
19291             return "vmovdqa\t{%1, %x0|%x0, %1}";
19292           else if (GET_MODE_SIZE (<ssescalarmode>mode) == 8)
19293             return "vmovdqa64\t{%1, %x0|%x0, %1}";
19294           else
19295             return "vmovdqa32\t{%1, %x0|%x0, %1}";
19296         default:
19297           gcc_unreachable ();
19298         }
19299     default:
19300       gcc_unreachable ();
19301     }
19303   [(set_attr "type" "sselog,sselog,ssemov,ssemov")
19304    (set_attr "prefix_extra" "1,1,*,*")
19305    (set_attr "length_immediate" "1,1,*,*")
19306    (set_attr "prefix" "maybe_evex")
19307    (set_attr "mode" "<sseinsnmode>")])
19309 (define_insn "vcvtph2ps<mask_name>"
19310   [(set (match_operand:V4SF 0 "register_operand" "=v")
19311         (vec_select:V4SF
19312           (unspec:V8SF [(match_operand:V8HI 1 "register_operand" "v")]
19313                        UNSPEC_VCVTPH2PS)
19314           (parallel [(const_int 0) (const_int 1)
19315                      (const_int 2) (const_int 3)])))]
19316   "TARGET_F16C || TARGET_AVX512VL"
19317   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19318   [(set_attr "type" "ssecvt")
19319    (set_attr "prefix" "maybe_evex")
19320    (set_attr "mode" "V4SF")])
19322 (define_insn "*vcvtph2ps_load<mask_name>"
19323   [(set (match_operand:V4SF 0 "register_operand" "=v")
19324         (unspec:V4SF [(match_operand:V4HI 1 "memory_operand" "m")]
19325                      UNSPEC_VCVTPH2PS))]
19326   "TARGET_F16C || TARGET_AVX512VL"
19327   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19328   [(set_attr "type" "ssecvt")
19329    (set_attr "prefix" "vex")
19330    (set_attr "mode" "V8SF")])
19332 (define_insn "vcvtph2ps256<mask_name>"
19333   [(set (match_operand:V8SF 0 "register_operand" "=v")
19334         (unspec:V8SF [(match_operand:V8HI 1 "nonimmediate_operand" "vm")]
19335                      UNSPEC_VCVTPH2PS))]
19336   "TARGET_F16C || TARGET_AVX512VL"
19337   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19338   [(set_attr "type" "ssecvt")
19339    (set_attr "prefix" "vex")
19340    (set_attr "btver2_decode" "double")
19341    (set_attr "mode" "V8SF")])
19343 (define_insn "<mask_codefor>avx512f_vcvtph2ps512<mask_name><round_saeonly_name>"
19344   [(set (match_operand:V16SF 0 "register_operand" "=v")
19345         (unspec:V16SF
19346           [(match_operand:V16HI 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
19347           UNSPEC_VCVTPH2PS))]
19348   "TARGET_AVX512F"
19349   "vcvtph2ps\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
19350   [(set_attr "type" "ssecvt")
19351    (set_attr "prefix" "evex")
19352    (set_attr "mode" "V16SF")])
19354 (define_expand "vcvtps2ph_mask"
19355   [(set (match_operand:V8HI 0 "register_operand")
19356         (vec_merge:V8HI
19357           (vec_concat:V8HI
19358             (unspec:V4HI [(match_operand:V4SF 1 "register_operand")
19359                           (match_operand:SI 2 "const_0_to_255_operand")]
19360                           UNSPEC_VCVTPS2PH)
19361             (match_dup 5))
19362            (match_operand:V8HI 3 "nonimm_or_0_operand")
19363            (match_operand:QI 4 "register_operand")))]
19364   "TARGET_AVX512VL"
19365   "operands[5] = CONST0_RTX (V4HImode);")
19367 (define_expand "vcvtps2ph"
19368   [(set (match_operand:V8HI 0 "register_operand")
19369         (vec_concat:V8HI
19370           (unspec:V4HI [(match_operand:V4SF 1 "register_operand")
19371                         (match_operand:SI 2 "const_0_to_255_operand")]
19372                        UNSPEC_VCVTPS2PH)
19373           (match_dup 3)))]
19374   "TARGET_F16C"
19375   "operands[3] = CONST0_RTX (V4HImode);")
19377 (define_insn "*vcvtps2ph<mask_name>"
19378   [(set (match_operand:V8HI 0 "register_operand" "=v")
19379         (vec_concat:V8HI
19380           (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "v")
19381                         (match_operand:SI 2 "const_0_to_255_operand" "N")]
19382                        UNSPEC_VCVTPS2PH)
19383           (match_operand:V4HI 3 "const0_operand")))]
19384   "(TARGET_F16C || TARGET_AVX512VL) && <mask_avx512vl_condition>"
19385   "vcvtps2ph\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}"
19386   [(set_attr "type" "ssecvt")
19387    (set_attr "prefix" "maybe_evex")
19388    (set_attr "mode" "V4SF")])
19390 (define_insn "*vcvtps2ph_store<mask_name>"
19391   [(set (match_operand:V4HI 0 "memory_operand" "=m")
19392         (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "v")
19393                       (match_operand:SI 2 "const_0_to_255_operand" "N")]
19394                      UNSPEC_VCVTPS2PH))]
19395   "TARGET_F16C || TARGET_AVX512VL"
19396   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19397   [(set_attr "type" "ssecvt")
19398    (set_attr "prefix" "maybe_evex")
19399    (set_attr "mode" "V4SF")])
19401 (define_insn "vcvtps2ph256<mask_name>"
19402   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=vm")
19403         (unspec:V8HI [(match_operand:V8SF 1 "register_operand" "v")
19404                       (match_operand:SI 2 "const_0_to_255_operand" "N")]
19405                      UNSPEC_VCVTPS2PH))]
19406   "TARGET_F16C || TARGET_AVX512VL"
19407   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19408   [(set_attr "type" "ssecvt")
19409    (set_attr "prefix" "maybe_evex")
19410    (set_attr "btver2_decode" "vector")
19411    (set_attr "mode" "V8SF")])
19413 (define_insn "<mask_codefor>avx512f_vcvtps2ph512<mask_name>"
19414   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=vm")
19415         (unspec:V16HI
19416           [(match_operand:V16SF 1 "register_operand" "v")
19417            (match_operand:SI 2 "const_0_to_255_operand" "N")]
19418           UNSPEC_VCVTPS2PH))]
19419   "TARGET_AVX512F"
19420   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19421   [(set_attr "type" "ssecvt")
19422    (set_attr "prefix" "evex")
19423    (set_attr "mode" "V16SF")])
19425 ;; For gather* insn patterns
19426 (define_mode_iterator VEC_GATHER_MODE
19427                       [V2DI V2DF V4DI V4DF V4SI V4SF V8SI V8SF])
19428 (define_mode_attr VEC_GATHER_IDXSI
19429                       [(V2DI "V4SI") (V4DI "V4SI") (V8DI "V8SI")
19430                        (V2DF "V4SI") (V4DF "V4SI") (V8DF "V8SI")
19431                        (V4SI "V4SI") (V8SI "V8SI") (V16SI "V16SI")
19432                        (V4SF "V4SI") (V8SF "V8SI") (V16SF "V16SI")])
19434 (define_mode_attr VEC_GATHER_IDXDI
19435                       [(V2DI "V2DI") (V4DI "V4DI") (V8DI "V8DI")
19436                        (V2DF "V2DI") (V4DF "V4DI") (V8DF "V8DI")
19437                        (V4SI "V2DI") (V8SI "V4DI") (V16SI "V8DI")
19438                        (V4SF "V2DI") (V8SF "V4DI") (V16SF "V8DI")])
19440 (define_mode_attr VEC_GATHER_SRCDI
19441                       [(V2DI "V2DI") (V4DI "V4DI") (V8DI "V8DI")
19442                        (V2DF "V2DF") (V4DF "V4DF") (V8DF "V8DF")
19443                        (V4SI "V4SI") (V8SI "V4SI") (V16SI "V8SI")
19444                        (V4SF "V4SF") (V8SF "V4SF") (V16SF "V8SF")])
19446 (define_expand "avx2_gathersi<mode>"
19447   [(parallel [(set (match_operand:VEC_GATHER_MODE 0 "register_operand")
19448                    (unspec:VEC_GATHER_MODE
19449                      [(match_operand:VEC_GATHER_MODE 1 "register_operand")
19450                       (mem:<ssescalarmode>
19451                         (match_par_dup 6
19452                           [(match_operand 2 "vsib_address_operand")
19453                            (match_operand:<VEC_GATHER_IDXSI>
19454                               3 "register_operand")
19455                            (match_operand:SI 5 "const1248_operand ")]))
19456                       (mem:BLK (scratch))
19457                       (match_operand:VEC_GATHER_MODE 4 "register_operand")]
19458                      UNSPEC_GATHER))
19459               (clobber (match_scratch:VEC_GATHER_MODE 7))])]
19460   "TARGET_AVX2"
19462   operands[6]
19463     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
19464                                         operands[5]), UNSPEC_VSIBADDR);
19467 (define_insn "*avx2_gathersi<mode>"
19468   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
19469         (unspec:VEC_GATHER_MODE
19470           [(match_operand:VEC_GATHER_MODE 2 "register_operand" "0")
19471            (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
19472              [(unspec:P
19473                 [(match_operand:P 3 "vsib_address_operand" "Tv")
19474                  (match_operand:<VEC_GATHER_IDXSI> 4 "register_operand" "x")
19475                  (match_operand:SI 6 "const1248_operand" "n")]
19476                 UNSPEC_VSIBADDR)])
19477            (mem:BLK (scratch))
19478            (match_operand:VEC_GATHER_MODE 5 "register_operand" "1")]
19479           UNSPEC_GATHER))
19480    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
19481   "TARGET_AVX2"
19482   "v<sseintprefix>gatherd<ssemodesuffix>\t{%1, %7, %0|%0, %7, %1}"
19483   [(set_attr "type" "ssemov")
19484    (set_attr "prefix" "vex")
19485    (set_attr "mode" "<sseinsnmode>")])
19487 (define_insn "*avx2_gathersi<mode>_2"
19488   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
19489         (unspec:VEC_GATHER_MODE
19490           [(pc)
19491            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19492              [(unspec:P
19493                 [(match_operand:P 2 "vsib_address_operand" "Tv")
19494                  (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand" "x")
19495                  (match_operand:SI 5 "const1248_operand" "n")]
19496                 UNSPEC_VSIBADDR)])
19497            (mem:BLK (scratch))
19498            (match_operand:VEC_GATHER_MODE 4 "register_operand" "1")]
19499           UNSPEC_GATHER))
19500    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
19501   "TARGET_AVX2"
19502   "v<sseintprefix>gatherd<ssemodesuffix>\t{%1, %6, %0|%0, %6, %1}"
19503   [(set_attr "type" "ssemov")
19504    (set_attr "prefix" "vex")
19505    (set_attr "mode" "<sseinsnmode>")])
19507 (define_expand "avx2_gatherdi<mode>"
19508   [(parallel [(set (match_operand:VEC_GATHER_MODE 0 "register_operand")
19509                    (unspec:VEC_GATHER_MODE
19510                      [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand")
19511                       (mem:<ssescalarmode>
19512                         (match_par_dup 6
19513                           [(match_operand 2 "vsib_address_operand")
19514                            (match_operand:<VEC_GATHER_IDXDI>
19515                               3 "register_operand")
19516                            (match_operand:SI 5 "const1248_operand ")]))
19517                       (mem:BLK (scratch))
19518                       (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand")]
19519                      UNSPEC_GATHER))
19520               (clobber (match_scratch:VEC_GATHER_MODE 7))])]
19521   "TARGET_AVX2"
19523   operands[6]
19524     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
19525                                         operands[5]), UNSPEC_VSIBADDR);
19528 (define_insn "*avx2_gatherdi<mode>"
19529   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
19530         (unspec:VEC_GATHER_MODE
19531           [(match_operand:<VEC_GATHER_SRCDI> 2 "register_operand" "0")
19532            (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
19533              [(unspec:P
19534                 [(match_operand:P 3 "vsib_address_operand" "Tv")
19535                  (match_operand:<VEC_GATHER_IDXDI> 4 "register_operand" "x")
19536                  (match_operand:SI 6 "const1248_operand" "n")]
19537                 UNSPEC_VSIBADDR)])
19538            (mem:BLK (scratch))
19539            (match_operand:<VEC_GATHER_SRCDI> 5 "register_operand" "1")]
19540           UNSPEC_GATHER))
19541    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
19542   "TARGET_AVX2"
19543   "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %7, %2|%2, %7, %5}"
19544   [(set_attr "type" "ssemov")
19545    (set_attr "prefix" "vex")
19546    (set_attr "mode" "<sseinsnmode>")])
19548 (define_insn "*avx2_gatherdi<mode>_2"
19549   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
19550         (unspec:VEC_GATHER_MODE
19551           [(pc)
19552            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19553              [(unspec:P
19554                 [(match_operand:P 2 "vsib_address_operand" "Tv")
19555                  (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "x")
19556                  (match_operand:SI 5 "const1248_operand" "n")]
19557                 UNSPEC_VSIBADDR)])
19558            (mem:BLK (scratch))
19559            (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand" "1")]
19560           UNSPEC_GATHER))
19561    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
19562   "TARGET_AVX2"
19564   if (<MODE>mode != <VEC_GATHER_SRCDI>mode)
19565     return "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %x0|%x0, %6, %4}";
19566   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %0|%0, %6, %4}";
19568   [(set_attr "type" "ssemov")
19569    (set_attr "prefix" "vex")
19570    (set_attr "mode" "<sseinsnmode>")])
19572 (define_insn "*avx2_gatherdi<mode>_3"
19573   [(set (match_operand:<VEC_GATHER_SRCDI> 0 "register_operand" "=&x")
19574         (vec_select:<VEC_GATHER_SRCDI>
19575           (unspec:VI4F_256
19576             [(match_operand:<VEC_GATHER_SRCDI> 2 "register_operand" "0")
19577              (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
19578                [(unspec:P
19579                   [(match_operand:P 3 "vsib_address_operand" "Tv")
19580                    (match_operand:<VEC_GATHER_IDXDI> 4 "register_operand" "x")
19581                    (match_operand:SI 6 "const1248_operand" "n")]
19582                   UNSPEC_VSIBADDR)])
19583              (mem:BLK (scratch))
19584              (match_operand:<VEC_GATHER_SRCDI> 5 "register_operand" "1")]
19585              UNSPEC_GATHER)
19586           (parallel [(const_int 0) (const_int 1)
19587                      (const_int 2) (const_int 3)])))
19588    (clobber (match_scratch:VI4F_256 1 "=&x"))]
19589   "TARGET_AVX2"
19590   "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %7, %0|%0, %7, %5}"
19591   [(set_attr "type" "ssemov")
19592    (set_attr "prefix" "vex")
19593    (set_attr "mode" "<sseinsnmode>")])
19595 (define_insn "*avx2_gatherdi<mode>_4"
19596   [(set (match_operand:<VEC_GATHER_SRCDI> 0 "register_operand" "=&x")
19597         (vec_select:<VEC_GATHER_SRCDI>
19598           (unspec:VI4F_256
19599             [(pc)
19600              (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19601                [(unspec:P
19602                   [(match_operand:P 2 "vsib_address_operand" "Tv")
19603                    (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "x")
19604                    (match_operand:SI 5 "const1248_operand" "n")]
19605                   UNSPEC_VSIBADDR)])
19606              (mem:BLK (scratch))
19607              (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand" "1")]
19608             UNSPEC_GATHER)
19609           (parallel [(const_int 0) (const_int 1)
19610                      (const_int 2) (const_int 3)])))
19611    (clobber (match_scratch:VI4F_256 1 "=&x"))]
19612   "TARGET_AVX2"
19613   "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %0|%0, %6, %4}"
19614   [(set_attr "type" "ssemov")
19615    (set_attr "prefix" "vex")
19616    (set_attr "mode" "<sseinsnmode>")])
19618 ;; Memory operand override for -masm=intel of the v*gatherq* patterns.
19619 (define_mode_attr gatherq_mode
19620   [(V4SI "q") (V2DI "x") (V4SF "q") (V2DF "x")
19621    (V8SI "x") (V4DI "t") (V8SF "x") (V4DF "t")
19622    (V16SI "t") (V8DI "g") (V16SF "t") (V8DF "g")])
19624 (define_expand "<avx512>_gathersi<mode>"
19625   [(parallel [(set (match_operand:VI48F 0 "register_operand")
19626                    (unspec:VI48F
19627                      [(match_operand:VI48F 1 "register_operand")
19628                       (match_operand:<avx512fmaskmode> 4 "register_operand")
19629                       (mem:<ssescalarmode>
19630                         (match_par_dup 6
19631                           [(match_operand 2 "vsib_address_operand")
19632                            (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand")
19633                            (match_operand:SI 5 "const1248_operand")]))]
19634                      UNSPEC_GATHER))
19635               (clobber (match_scratch:<avx512fmaskmode> 7))])]
19636   "TARGET_AVX512F"
19638   operands[6]
19639     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
19640                                         operands[5]), UNSPEC_VSIBADDR);
19643 (define_insn "*avx512f_gathersi<mode>"
19644   [(set (match_operand:VI48F 0 "register_operand" "=&v")
19645         (unspec:VI48F
19646           [(match_operand:VI48F 1 "register_operand" "0")
19647            (match_operand:<avx512fmaskmode> 7 "register_operand" "2")
19648            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19649              [(unspec:P
19650                 [(match_operand:P 4 "vsib_address_operand" "Tv")
19651                  (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand" "v")
19652                  (match_operand:SI 5 "const1248_operand" "n")]
19653                 UNSPEC_VSIBADDR)])]
19654           UNSPEC_GATHER))
19655    (clobber (match_scratch:<avx512fmaskmode> 2 "=&Yk"))]
19656   "TARGET_AVX512F"
19657   "v<sseintprefix>gatherd<ssemodesuffix>\t{%6, %0%{%2%}|%0%{%2%}, %<xtg_mode>6}"
19658   [(set_attr "type" "ssemov")
19659    (set_attr "prefix" "evex")
19660    (set_attr "mode" "<sseinsnmode>")])
19662 (define_insn "*avx512f_gathersi<mode>_2"
19663   [(set (match_operand:VI48F 0 "register_operand" "=&v")
19664         (unspec:VI48F
19665           [(pc)
19666            (match_operand:<avx512fmaskmode> 6 "register_operand" "1")
19667            (match_operator:<ssescalarmode> 5 "vsib_mem_operator"
19668              [(unspec:P
19669                 [(match_operand:P 3 "vsib_address_operand" "Tv")
19670                  (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand" "v")
19671                  (match_operand:SI 4 "const1248_operand" "n")]
19672                 UNSPEC_VSIBADDR)])]
19673           UNSPEC_GATHER))
19674    (clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
19675   "TARGET_AVX512F"
19676   "v<sseintprefix>gatherd<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %<xtg_mode>5}"
19677   [(set_attr "type" "ssemov")
19678    (set_attr "prefix" "evex")
19679    (set_attr "mode" "<sseinsnmode>")])
19682 (define_expand "<avx512>_gatherdi<mode>"
19683   [(parallel [(set (match_operand:VI48F 0 "register_operand")
19684                    (unspec:VI48F
19685                      [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand")
19686                       (match_operand:QI 4 "register_operand")
19687                       (mem:<ssescalarmode>
19688                         (match_par_dup 6
19689                           [(match_operand 2 "vsib_address_operand")
19690                            (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand")
19691                            (match_operand:SI 5 "const1248_operand")]))]
19692                      UNSPEC_GATHER))
19693               (clobber (match_scratch:QI 7))])]
19694   "TARGET_AVX512F"
19696   operands[6]
19697     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
19698                                         operands[5]), UNSPEC_VSIBADDR);
19701 (define_insn "*avx512f_gatherdi<mode>"
19702   [(set (match_operand:VI48F 0 "register_operand" "=&v")
19703         (unspec:VI48F
19704           [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand" "0")
19705            (match_operand:QI 7 "register_operand" "2")
19706            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19707              [(unspec:P
19708                 [(match_operand:P 4 "vsib_address_operand" "Tv")
19709                  (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "v")
19710                  (match_operand:SI 5 "const1248_operand" "n")]
19711                 UNSPEC_VSIBADDR)])]
19712           UNSPEC_GATHER))
19713    (clobber (match_scratch:QI 2 "=&Yk"))]
19714   "TARGET_AVX512F"
19716   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%6, %1%{%2%}|%1%{%2%}, %<gatherq_mode>6}";
19718   [(set_attr "type" "ssemov")
19719    (set_attr "prefix" "evex")
19720    (set_attr "mode" "<sseinsnmode>")])
19722 (define_insn "*avx512f_gatherdi<mode>_2"
19723   [(set (match_operand:VI48F 0 "register_operand" "=&v")
19724         (unspec:VI48F
19725           [(pc)
19726            (match_operand:QI 6 "register_operand" "1")
19727            (match_operator:<ssescalarmode> 5 "vsib_mem_operator"
19728              [(unspec:P
19729                 [(match_operand:P 3 "vsib_address_operand" "Tv")
19730                  (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand" "v")
19731                  (match_operand:SI 4 "const1248_operand" "n")]
19732                 UNSPEC_VSIBADDR)])]
19733           UNSPEC_GATHER))
19734    (clobber (match_scratch:QI 1 "=&Yk"))]
19735   "TARGET_AVX512F"
19737   if (<MODE>mode != <VEC_GATHER_SRCDI>mode)
19738     {
19739       if (<MODE_SIZE> != 64)
19740         return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %x0%{%1%}|%x0%{%1%}, %<gatherq_mode>5}";
19741       else
19742         return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %t0%{%1%}|%t0%{%1%}, %t5}";
19743     }
19744   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %<gatherq_mode>5}";
19746   [(set_attr "type" "ssemov")
19747    (set_attr "prefix" "evex")
19748    (set_attr "mode" "<sseinsnmode>")])
19750 (define_expand "<avx512>_scattersi<mode>"
19751   [(parallel [(set (mem:VI48F
19752                      (match_par_dup 5
19753                        [(match_operand 0 "vsib_address_operand")
19754                         (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand")
19755                         (match_operand:SI 4 "const1248_operand")]))
19756                    (unspec:VI48F
19757                      [(match_operand:<avx512fmaskmode> 1 "register_operand")
19758                       (match_operand:VI48F 3 "register_operand")]
19759                      UNSPEC_SCATTER))
19760               (clobber (match_scratch:<avx512fmaskmode> 6))])]
19761   "TARGET_AVX512F"
19763   operands[5]
19764     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[0], operands[2],
19765                                         operands[4]), UNSPEC_VSIBADDR);
19768 (define_insn "*avx512f_scattersi<mode>"
19769   [(set (match_operator:VI48F 5 "vsib_mem_operator"
19770           [(unspec:P
19771              [(match_operand:P 0 "vsib_address_operand" "Tv")
19772               (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand" "v")
19773               (match_operand:SI 4 "const1248_operand" "n")]
19774              UNSPEC_VSIBADDR)])
19775         (unspec:VI48F
19776           [(match_operand:<avx512fmaskmode> 6 "register_operand" "1")
19777            (match_operand:VI48F 3 "register_operand" "v")]
19778           UNSPEC_SCATTER))
19779    (clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
19780   "TARGET_AVX512F"
19781   "v<sseintprefix>scatterd<ssemodesuffix>\t{%3, %5%{%1%}|%5%{%1%}, %3}"
19782   [(set_attr "type" "ssemov")
19783    (set_attr "prefix" "evex")
19784    (set_attr "mode" "<sseinsnmode>")])
19786 (define_expand "<avx512>_scatterdi<mode>"
19787   [(parallel [(set (mem:VI48F
19788                      (match_par_dup 5
19789                        [(match_operand 0 "vsib_address_operand")
19790                         (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand")
19791                         (match_operand:SI 4 "const1248_operand")]))
19792                    (unspec:VI48F
19793                      [(match_operand:QI 1 "register_operand")
19794                       (match_operand:<VEC_GATHER_SRCDI> 3 "register_operand")]
19795                      UNSPEC_SCATTER))
19796               (clobber (match_scratch:QI 6))])]
19797   "TARGET_AVX512F"
19799   operands[5]
19800     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[0], operands[2],
19801                                         operands[4]), UNSPEC_VSIBADDR);
19804 (define_insn "*avx512f_scatterdi<mode>"
19805   [(set (match_operator:VI48F 5 "vsib_mem_operator"
19806           [(unspec:P
19807              [(match_operand:P 0 "vsib_address_operand" "Tv")
19808               (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand" "v")
19809               (match_operand:SI 4 "const1248_operand" "n")]
19810              UNSPEC_VSIBADDR)])
19811         (unspec:VI48F
19812           [(match_operand:QI 6 "register_operand" "1")
19813            (match_operand:<VEC_GATHER_SRCDI> 3 "register_operand" "v")]
19814           UNSPEC_SCATTER))
19815    (clobber (match_scratch:QI 1 "=&Yk"))]
19816   "TARGET_AVX512F"
19818   if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 8)
19819     return "v<sseintprefix>scatterq<ssemodesuffix>\t{%3, %5%{%1%}|%5%{%1%}, %3}";
19820   return "v<sseintprefix>scatterq<ssemodesuffix>\t{%3, %5%{%1%}|%t5%{%1%}, %3}";
19822   [(set_attr "type" "ssemov")
19823    (set_attr "prefix" "evex")
19824    (set_attr "mode" "<sseinsnmode>")])
19826 (define_insn "<avx512>_compress<mode>_mask"
19827   [(set (match_operand:VI48F 0 "register_operand" "=v")
19828         (unspec:VI48F
19829           [(match_operand:VI48F 1 "register_operand" "v")
19830            (match_operand:VI48F 2 "nonimm_or_0_operand" "0C")
19831            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")]
19832           UNSPEC_COMPRESS))]
19833   "TARGET_AVX512F"
19834   "v<sseintprefix>compress<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19835   [(set_attr "type" "ssemov")
19836    (set_attr "prefix" "evex")
19837    (set_attr "mode" "<sseinsnmode>")])
19839 (define_insn "compress<mode>_mask"
19840   [(set (match_operand:VI12_AVX512VLBW 0 "register_operand" "=v")
19841         (unspec:VI12_AVX512VLBW
19842           [(match_operand:VI12_AVX512VLBW 1 "register_operand" "v")
19843            (match_operand:VI12_AVX512VLBW 2 "nonimm_or_0_operand" "0C")
19844            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")]
19845           UNSPEC_COMPRESS))]
19846   "TARGET_AVX512VBMI2"
19847   "vpcompress<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19848   [(set_attr "type" "ssemov")
19849    (set_attr "prefix" "evex")
19850    (set_attr "mode" "<sseinsnmode>")])
19852 (define_insn "<avx512>_compressstore<mode>_mask"
19853   [(set (match_operand:VI48F 0 "memory_operand" "=m")
19854         (unspec:VI48F
19855           [(match_operand:VI48F 1 "register_operand" "x")
19856            (match_dup 0)
19857            (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")]
19858           UNSPEC_COMPRESS_STORE))]
19859   "TARGET_AVX512F"
19860   "v<sseintprefix>compress<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
19861   [(set_attr "type" "ssemov")
19862    (set_attr "prefix" "evex")
19863    (set_attr "memory" "store")
19864    (set_attr "mode" "<sseinsnmode>")])
19866 (define_insn "compressstore<mode>_mask"
19867   [(set (match_operand:VI12_AVX512VLBW 0 "memory_operand" "=m")
19868         (unspec:VI12_AVX512VLBW
19869           [(match_operand:VI12_AVX512VLBW 1 "register_operand" "x")
19870            (match_dup 0)
19871            (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")]
19872           UNSPEC_COMPRESS_STORE))]
19873   "TARGET_AVX512VBMI2"
19874   "vpcompress<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
19875   [(set_attr "type" "ssemov")
19876    (set_attr "prefix" "evex")
19877    (set_attr "memory" "store")
19878    (set_attr "mode" "<sseinsnmode>")])
19880 (define_expand "<avx512>_expand<mode>_maskz"
19881   [(set (match_operand:VI48F 0 "register_operand")
19882         (unspec:VI48F
19883           [(match_operand:VI48F 1 "nonimmediate_operand")
19884            (match_operand:VI48F 2 "nonimm_or_0_operand")
19885            (match_operand:<avx512fmaskmode> 3 "register_operand")]
19886           UNSPEC_EXPAND))]
19887   "TARGET_AVX512F"
19888   "operands[2] = CONST0_RTX (<MODE>mode);")
19890 (define_insn "<avx512>_expand<mode>_mask"
19891   [(set (match_operand:VI48F 0 "register_operand" "=v,v")
19892         (unspec:VI48F
19893           [(match_operand:VI48F 1 "nonimmediate_operand" "v,m")
19894            (match_operand:VI48F 2 "nonimm_or_0_operand" "0C,0C")
19895            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")]
19896           UNSPEC_EXPAND))]
19897   "TARGET_AVX512F"
19898   "v<sseintprefix>expand<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19899   [(set_attr "type" "ssemov")
19900    (set_attr "prefix" "evex")
19901    (set_attr "memory" "none,load")
19902    (set_attr "mode" "<sseinsnmode>")])
19904 (define_insn "expand<mode>_mask"
19905   [(set (match_operand:VI12_AVX512VLBW 0 "register_operand" "=v,v")
19906         (unspec:VI12_AVX512VLBW
19907           [(match_operand:VI12_AVX512VLBW 1 "nonimmediate_operand" "v,m")
19908            (match_operand:VI12_AVX512VLBW 2 "nonimm_or_0_operand" "0C,0C")
19909            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")]
19910           UNSPEC_EXPAND))]
19911   "TARGET_AVX512VBMI2"
19912   "v<sseintprefix>expand<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19913   [(set_attr "type" "ssemov")
19914    (set_attr "prefix" "evex")
19915    (set_attr "memory" "none,load")
19916    (set_attr "mode" "<sseinsnmode>")])
19918 (define_expand "expand<mode>_maskz"
19919   [(set (match_operand:VI12_AVX512VLBW 0 "register_operand")
19920         (unspec:VI12_AVX512VLBW
19921           [(match_operand:VI12_AVX512VLBW 1 "nonimmediate_operand")
19922            (match_operand:VI12_AVX512VLBW 2 "nonimm_or_0_operand")
19923            (match_operand:<avx512fmaskmode> 3 "register_operand")]
19924           UNSPEC_EXPAND))]
19925   "TARGET_AVX512VBMI2"
19926   "operands[2] = CONST0_RTX (<MODE>mode);")
19928 (define_insn "avx512dq_rangep<mode><mask_name><round_saeonly_name>"
19929   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
19930         (unspec:VF_AVX512VL
19931           [(match_operand:VF_AVX512VL 1 "register_operand" "v")
19932            (match_operand:VF_AVX512VL 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
19933            (match_operand:SI 3 "const_0_to_15_operand")]
19934           UNSPEC_RANGE))]
19935   "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
19936   "vrange<ssemodesuffix>\t{%3, <round_saeonly_mask_op4>%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2<round_saeonly_mask_op4>, %3}"
19937   [(set_attr "type" "sse")
19938    (set_attr "prefix" "evex")
19939    (set_attr "mode" "<MODE>")])
19941 (define_insn "avx512dq_ranges<mode><mask_scalar_name><round_saeonly_scalar_name>"
19942   [(set (match_operand:VF_128 0 "register_operand" "=v")
19943         (vec_merge:VF_128
19944           (unspec:VF_128
19945             [(match_operand:VF_128 1 "register_operand" "v")
19946              (match_operand:VF_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")
19947              (match_operand:SI 3 "const_0_to_15_operand")]
19948             UNSPEC_RANGE)
19949           (match_dup 1)
19950           (const_int 1)))]
19951   "TARGET_AVX512DQ"
19952   "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}"
19953   [(set_attr "type" "sse")
19954    (set_attr "prefix" "evex")
19955    (set_attr "mode" "<MODE>")])
19957 (define_insn "avx512dq_fpclass<mode><mask_scalar_merge_name>"
19958   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
19959           (unspec:<avx512fmaskmode>
19960             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
19961              (match_operand:QI 2 "const_0_to_255_operand" "n")]
19962              UNSPEC_FPCLASS))]
19963    "TARGET_AVX512DQ"
19964    "vfpclass<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}";
19965   [(set_attr "type" "sse")
19966    (set_attr "length_immediate" "1")
19967    (set_attr "prefix" "evex")
19968    (set_attr "mode" "<MODE>")])
19970 (define_insn "avx512dq_vmfpclass<mode>"
19971   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
19972         (and:<avx512fmaskmode>
19973           (unspec:<avx512fmaskmode>
19974             [(match_operand:VF_128 1 "register_operand" "v")
19975              (match_operand:QI 2 "const_0_to_255_operand" "n")]
19976             UNSPEC_FPCLASS)
19977           (const_int 1)))]
19978    "TARGET_AVX512DQ"
19979    "vfpclass<ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
19980   [(set_attr "type" "sse")
19981    (set_attr "length_immediate" "1")
19982    (set_attr "prefix" "evex")
19983    (set_attr "mode" "<MODE>")])
19985 (define_insn "<avx512>_getmant<mode><mask_name><round_saeonly_name>"
19986   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
19987         (unspec:VF_AVX512VL
19988           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "<round_saeonly_constraint>")
19989            (match_operand:SI 2 "const_0_to_15_operand")]
19990           UNSPEC_GETMANT))]
19991   "TARGET_AVX512F"
19992   "vgetmant<ssemodesuffix>\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}";
19993   [(set_attr "prefix" "evex")
19994    (set_attr "mode" "<MODE>")])
19996 (define_insn "avx512f_vgetmant<mode><mask_scalar_name><round_saeonly_scalar_name>"
19997   [(set (match_operand:VF_128 0 "register_operand" "=v")
19998         (vec_merge:VF_128
19999           (unspec:VF_128
20000             [(match_operand:VF_128 1 "register_operand" "v")
20001              (match_operand:VF_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")
20002              (match_operand:SI 3 "const_0_to_15_operand")]
20003             UNSPEC_GETMANT)
20004           (match_dup 1)
20005           (const_int 1)))]
20006    "TARGET_AVX512F"
20007    "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}";
20008    [(set_attr "prefix" "evex")
20009    (set_attr "mode" "<ssescalarmode>")])
20011 ;; The correct representation for this is absolutely enormous, and
20012 ;; surely not generally useful.
20013 (define_insn "<mask_codefor>avx512bw_dbpsadbw<mode><mask_name>"
20014   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
20015         (unspec:VI2_AVX512VL
20016           [(match_operand:<dbpsadbwmode> 1 "register_operand" "v")
20017            (match_operand:<dbpsadbwmode> 2 "nonimmediate_operand" "vm")
20018            (match_operand:SI 3 "const_0_to_255_operand")]
20019           UNSPEC_DBPSADBW))]
20020    "TARGET_AVX512BW"
20021   "vdbpsadbw\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}"
20022   [(set_attr "type" "sselog1")
20023    (set_attr "length_immediate" "1")
20024    (set_attr "prefix" "evex")
20025    (set_attr "mode" "<sseinsnmode>")])
20027 (define_insn "clz<mode>2<mask_name>"
20028   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
20029         (clz:VI48_AVX512VL
20030           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")))]
20031   "TARGET_AVX512CD"
20032   "vplzcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
20033   [(set_attr "type" "sse")
20034    (set_attr "prefix" "evex")
20035    (set_attr "mode" "<sseinsnmode>")])
20037 (define_insn "<mask_codefor>conflict<mode><mask_name>"
20038   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
20039         (unspec:VI48_AVX512VL
20040           [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")]
20041           UNSPEC_CONFLICT))]
20042   "TARGET_AVX512CD"
20043   "vpconflict<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
20044   [(set_attr "type" "sse")
20045    (set_attr "prefix" "evex")
20046    (set_attr "mode" "<sseinsnmode>")])
20048 (define_insn "sha1msg1"
20049   [(set (match_operand:V4SI 0 "register_operand" "=x")
20050         (unspec:V4SI
20051           [(match_operand:V4SI 1 "register_operand" "0")
20052            (match_operand:V4SI 2 "vector_operand" "xBm")]
20053           UNSPEC_SHA1MSG1))]
20054   "TARGET_SHA"
20055   "sha1msg1\t{%2, %0|%0, %2}"
20056   [(set_attr "type" "sselog1")
20057    (set_attr "mode" "TI")])
20059 (define_insn "sha1msg2"
20060   [(set (match_operand:V4SI 0 "register_operand" "=x")
20061         (unspec:V4SI
20062           [(match_operand:V4SI 1 "register_operand" "0")
20063            (match_operand:V4SI 2 "vector_operand" "xBm")]
20064           UNSPEC_SHA1MSG2))]
20065   "TARGET_SHA"
20066   "sha1msg2\t{%2, %0|%0, %2}"
20067   [(set_attr "type" "sselog1")
20068    (set_attr "mode" "TI")])
20070 (define_insn "sha1nexte"
20071   [(set (match_operand:V4SI 0 "register_operand" "=x")
20072         (unspec:V4SI
20073           [(match_operand:V4SI 1 "register_operand" "0")
20074            (match_operand:V4SI 2 "vector_operand" "xBm")]
20075           UNSPEC_SHA1NEXTE))]
20076   "TARGET_SHA"
20077   "sha1nexte\t{%2, %0|%0, %2}"
20078   [(set_attr "type" "sselog1")
20079    (set_attr "mode" "TI")])
20081 (define_insn "sha1rnds4"
20082   [(set (match_operand:V4SI 0 "register_operand" "=x")
20083         (unspec:V4SI
20084           [(match_operand:V4SI 1 "register_operand" "0")
20085            (match_operand:V4SI 2 "vector_operand" "xBm")
20086            (match_operand:SI 3 "const_0_to_3_operand" "n")]
20087           UNSPEC_SHA1RNDS4))]
20088   "TARGET_SHA"
20089   "sha1rnds4\t{%3, %2, %0|%0, %2, %3}"
20090   [(set_attr "type" "sselog1")
20091    (set_attr "length_immediate" "1")
20092    (set_attr "mode" "TI")])
20094 (define_insn "sha256msg1"
20095   [(set (match_operand:V4SI 0 "register_operand" "=x")
20096         (unspec:V4SI
20097           [(match_operand:V4SI 1 "register_operand" "0")
20098            (match_operand:V4SI 2 "vector_operand" "xBm")]
20099           UNSPEC_SHA256MSG1))]
20100   "TARGET_SHA"
20101   "sha256msg1\t{%2, %0|%0, %2}"
20102   [(set_attr "type" "sselog1")
20103    (set_attr "mode" "TI")])
20105 (define_insn "sha256msg2"
20106   [(set (match_operand:V4SI 0 "register_operand" "=x")
20107         (unspec:V4SI
20108           [(match_operand:V4SI 1 "register_operand" "0")
20109            (match_operand:V4SI 2 "vector_operand" "xBm")]
20110           UNSPEC_SHA256MSG2))]
20111   "TARGET_SHA"
20112   "sha256msg2\t{%2, %0|%0, %2}"
20113   [(set_attr "type" "sselog1")
20114    (set_attr "mode" "TI")])
20116 (define_insn "sha256rnds2"
20117   [(set (match_operand:V4SI 0 "register_operand" "=x")
20118         (unspec:V4SI
20119           [(match_operand:V4SI 1 "register_operand" "0")
20120            (match_operand:V4SI 2 "vector_operand" "xBm")
20121            (match_operand:V4SI 3 "register_operand" "Yz")]
20122           UNSPEC_SHA256RNDS2))]
20123   "TARGET_SHA"
20124   "sha256rnds2\t{%3, %2, %0|%0, %2, %3}"
20125   [(set_attr "type" "sselog1")
20126    (set_attr "length_immediate" "1")
20127    (set_attr "mode" "TI")])
20129 (define_insn_and_split "avx512f_<castmode><avxsizesuffix>_<castmode>"
20130   [(set (match_operand:AVX512MODE2P 0 "nonimmediate_operand" "=x,m")
20131         (unspec:AVX512MODE2P
20132           [(match_operand:<ssequartermode> 1 "nonimmediate_operand" "xm,x")]
20133           UNSPEC_CAST))]
20134   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
20135   "#"
20136   "&& reload_completed"
20137   [(set (match_dup 0) (match_dup 1))]
20139   if (REG_P (operands[0]))
20140     operands[0] = gen_lowpart (<ssequartermode>mode, operands[0]);
20141   else
20142     operands[1] = lowpart_subreg (<MODE>mode, operands[1],
20143                                   <ssequartermode>mode);
20146 (define_insn_and_split "avx512f_<castmode><avxsizesuffix>_256<castmode>"
20147   [(set (match_operand:AVX512MODE2P 0 "nonimmediate_operand" "=x,m")
20148         (unspec:AVX512MODE2P
20149           [(match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "xm,x")]
20150           UNSPEC_CAST))]
20151   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
20152   "#"
20153   "&& reload_completed"
20154   [(set (match_dup 0) (match_dup 1))]
20156   if (REG_P (operands[0]))
20157     operands[0] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);
20158   else
20159     operands[1] = lowpart_subreg (<MODE>mode, operands[1],
20160                                   <ssehalfvecmode>mode);
20163 (define_int_iterator VPMADD52
20164         [UNSPEC_VPMADD52LUQ
20165          UNSPEC_VPMADD52HUQ])
20167 (define_int_attr vpmadd52type
20168   [(UNSPEC_VPMADD52LUQ "luq") (UNSPEC_VPMADD52HUQ "huq")])
20170 (define_expand "vpamdd52huq<mode>_maskz"
20171   [(match_operand:VI8_AVX512VL 0 "register_operand")
20172    (match_operand:VI8_AVX512VL 1 "register_operand")
20173    (match_operand:VI8_AVX512VL 2 "register_operand")
20174    (match_operand:VI8_AVX512VL 3 "nonimmediate_operand")
20175    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20176   "TARGET_AVX512IFMA"
20178   emit_insn (gen_vpamdd52huq<mode>_maskz_1 (
20179     operands[0], operands[1], operands[2], operands[3],
20180     CONST0_RTX (<MODE>mode), operands[4]));
20181   DONE;
20184 (define_expand "vpamdd52luq<mode>_maskz"
20185   [(match_operand:VI8_AVX512VL 0 "register_operand")
20186    (match_operand:VI8_AVX512VL 1 "register_operand")
20187    (match_operand:VI8_AVX512VL 2 "register_operand")
20188    (match_operand:VI8_AVX512VL 3 "nonimmediate_operand")
20189    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20190   "TARGET_AVX512IFMA"
20192   emit_insn (gen_vpamdd52luq<mode>_maskz_1 (
20193     operands[0], operands[1], operands[2], operands[3],
20194     CONST0_RTX (<MODE>mode), operands[4]));
20195   DONE;
20198 (define_insn "vpamdd52<vpmadd52type><mode><sd_maskz_name>"
20199   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
20200         (unspec:VI8_AVX512VL
20201           [(match_operand:VI8_AVX512VL 1 "register_operand" "0")
20202            (match_operand:VI8_AVX512VL 2 "register_operand" "v")
20203            (match_operand:VI8_AVX512VL 3 "nonimmediate_operand" "vm")]
20204           VPMADD52))]
20205   "TARGET_AVX512IFMA"
20206   "vpmadd52<vpmadd52type>\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}"
20207   [(set_attr "type" "ssemuladd")
20208    (set_attr "prefix" "evex")
20209    (set_attr "mode" "<sseinsnmode>")])
20211 (define_insn "vpamdd52<vpmadd52type><mode>_mask"
20212   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
20213         (vec_merge:VI8_AVX512VL
20214           (unspec:VI8_AVX512VL
20215             [(match_operand:VI8_AVX512VL 1 "register_operand" "0")
20216              (match_operand:VI8_AVX512VL 2 "register_operand" "v")
20217              (match_operand:VI8_AVX512VL 3 "nonimmediate_operand" "vm")]
20218             VPMADD52)
20219           (match_dup 1)
20220           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20221   "TARGET_AVX512IFMA"
20222   "vpmadd52<vpmadd52type>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
20223   [(set_attr "type" "ssemuladd")
20224    (set_attr "prefix" "evex")
20225    (set_attr "mode" "<sseinsnmode>")])
20227 (define_insn "vpmultishiftqb<mode><mask_name>"
20228   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
20229         (unspec:VI1_AVX512VL
20230           [(match_operand:VI1_AVX512VL 1 "register_operand" "v")
20231            (match_operand:VI1_AVX512VL 2 "nonimmediate_operand" "vm")]
20232           UNSPEC_VPMULTISHIFT))]
20233   "TARGET_AVX512VBMI"
20234   "vpmultishiftqb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
20235   [(set_attr "type" "sselog")
20236    (set_attr "prefix" "evex")
20237    (set_attr "mode" "<sseinsnmode>")])
20239 (define_mode_iterator IMOD4
20240   [(V64SF "TARGET_AVX5124FMAPS") (V64SI "TARGET_AVX5124VNNIW")])
20242 (define_mode_attr imod4_narrow
20243   [(V64SF "V16SF") (V64SI "V16SI")])
20245 (define_expand "mov<mode>"
20246   [(set (match_operand:IMOD4 0 "nonimmediate_operand")
20247         (match_operand:IMOD4 1 "nonimm_or_0_operand"))]
20248   "TARGET_AVX512F"
20250   ix86_expand_vector_move (<MODE>mode, operands);
20251   DONE;
20254 (define_insn_and_split "*mov<mode>_internal"
20255   [(set (match_operand:IMOD4 0 "nonimmediate_operand" "=v,v ,m")
20256         (match_operand:IMOD4 1 "nonimm_or_0_operand"  " C,vm,v"))]
20257   "TARGET_AVX512F
20258    && (register_operand (operands[0], <MODE>mode)
20259        || register_operand (operands[1], <MODE>mode))"
20260   "#"
20261   "&& reload_completed"
20262   [(const_int 0)]
20264   rtx op0, op1;
20265   int i;
20267   for (i = 0; i < 4; i++)
20268     {
20269       op0 = simplify_subreg
20270              (<imod4_narrow>mode, operands[0], <MODE>mode, i * 64);
20271       op1 = simplify_subreg
20272              (<imod4_narrow>mode, operands[1], <MODE>mode, i * 64);
20273       emit_move_insn (op0, op1);
20274     }
20275   DONE;
20278 (define_insn "avx5124fmaddps_4fmaddps"
20279   [(set (match_operand:V16SF 0 "register_operand" "=v")
20280         (unspec:V16SF
20281           [(match_operand:V16SF 1 "register_operand" "0")
20282            (match_operand:V64SF 2 "register_operand" "v")
20283            (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FMADD))]
20284   "TARGET_AVX5124FMAPS"
20285   "v4fmaddps\t{%3, %g2, %0|%0, %g2, %3}"
20286    [(set_attr ("type") ("ssemuladd"))
20287     (set_attr ("prefix") ("evex"))
20288     (set_attr ("mode") ("V16SF"))])
20290 (define_insn "avx5124fmaddps_4fmaddps_mask"
20291   [(set (match_operand:V16SF 0 "register_operand" "=v")
20292         (vec_merge:V16SF
20293           (unspec:V16SF
20294              [(match_operand:V64SF 1 "register_operand" "v")
20295               (match_operand:V4SF 2 "memory_operand" "m")] UNSPEC_VP4FMADD)
20296           (match_operand:V16SF 3 "register_operand" "0")
20297           (match_operand:HI 4 "register_operand" "Yk")))]
20298   "TARGET_AVX5124FMAPS"
20299   "v4fmaddps\t{%2, %g1, %0%{%4%}|%0%{%4%}, %g1, %2}"
20300    [(set_attr ("type") ("ssemuladd"))
20301     (set_attr ("prefix") ("evex"))
20302     (set_attr ("mode") ("V16SF"))])
20304 (define_insn "avx5124fmaddps_4fmaddps_maskz"
20305   [(set (match_operand:V16SF 0 "register_operand" "=v")
20306         (vec_merge:V16SF
20307           (unspec:V16SF
20308             [(match_operand:V16SF 1 "register_operand" "0")
20309              (match_operand:V64SF 2 "register_operand" "v")
20310              (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FMADD)
20311           (match_operand:V16SF 4 "const0_operand" "C")
20312           (match_operand:HI 5 "register_operand" "Yk")))]
20313   "TARGET_AVX5124FMAPS"
20314   "v4fmaddps\t{%3, %g2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %g2, %3}"
20315    [(set_attr ("type") ("ssemuladd"))
20316     (set_attr ("prefix") ("evex"))
20317     (set_attr ("mode") ("V16SF"))])
20319 (define_insn "avx5124fmaddps_4fmaddss"
20320   [(set (match_operand:V4SF 0 "register_operand" "=v")
20321         (unspec:V4SF
20322           [(match_operand:V4SF 1 "register_operand" "0")
20323            (match_operand:V64SF 2 "register_operand" "v")
20324            (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FMADD))]
20325   "TARGET_AVX5124FMAPS"
20326   "v4fmaddss\t{%3, %x2, %0|%0, %x2, %3}"
20327    [(set_attr ("type") ("ssemuladd"))
20328     (set_attr ("prefix") ("evex"))
20329     (set_attr ("mode") ("SF"))])
20331 (define_insn "avx5124fmaddps_4fmaddss_mask"
20332   [(set (match_operand:V4SF 0 "register_operand" "=v")
20333         (vec_merge:V4SF
20334           (unspec:V4SF
20335             [(match_operand:V64SF 1 "register_operand" "v")
20336              (match_operand:V4SF 2 "memory_operand" "m")] UNSPEC_VP4FMADD)
20337           (match_operand:V4SF 3 "register_operand" "0")
20338           (match_operand:QI 4 "register_operand" "Yk")))]
20339   "TARGET_AVX5124FMAPS"
20340   "v4fmaddss\t{%2, %x1, %0%{%4%}|%0%{%4%}, %x1, %2}"
20341    [(set_attr ("type") ("ssemuladd"))
20342     (set_attr ("prefix") ("evex"))
20343     (set_attr ("mode") ("SF"))])
20345 (define_insn "avx5124fmaddps_4fmaddss_maskz"
20346   [(set (match_operand:V4SF 0 "register_operand" "=v")
20347         (vec_merge:V4SF
20348           (unspec:V4SF
20349             [(match_operand:V4SF 1 "register_operand" "0")
20350              (match_operand:V64SF 2 "register_operand" "v")
20351              (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FMADD)
20352           (match_operand:V4SF 4 "const0_operand" "C")
20353           (match_operand:QI 5 "register_operand" "Yk")))]
20354   "TARGET_AVX5124FMAPS"
20355   "v4fmaddss\t{%3, %x2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %x2, %3}"
20356    [(set_attr ("type") ("ssemuladd"))
20357     (set_attr ("prefix") ("evex"))
20358     (set_attr ("mode") ("SF"))])
20360 (define_insn "avx5124fmaddps_4fnmaddps"
20361   [(set (match_operand:V16SF 0 "register_operand" "=v")
20362         (unspec:V16SF
20363           [(match_operand:V16SF 1 "register_operand" "0")
20364            (match_operand:V64SF 2 "register_operand" "v")
20365            (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FNMADD))]
20366   "TARGET_AVX5124FMAPS"
20367   "v4fnmaddps\t{%3, %g2, %0|%0, %g2, %3}"
20368    [(set_attr ("type") ("ssemuladd"))
20369     (set_attr ("prefix") ("evex"))
20370     (set_attr ("mode") ("V16SF"))])
20372 (define_insn "avx5124fmaddps_4fnmaddps_mask"
20373   [(set (match_operand:V16SF 0 "register_operand" "=v")
20374         (vec_merge:V16SF
20375           (unspec:V16SF
20376              [(match_operand:V64SF 1 "register_operand" "v")
20377               (match_operand:V4SF 2 "memory_operand" "m")] UNSPEC_VP4FNMADD)
20378           (match_operand:V16SF 3 "register_operand" "0")
20379           (match_operand:HI 4 "register_operand" "Yk")))]
20380   "TARGET_AVX5124FMAPS"
20381   "v4fnmaddps\t{%2, %g1, %0%{%4%}|%0%{%4%}, %g1, %2}"
20382    [(set_attr ("type") ("ssemuladd"))
20383     (set_attr ("prefix") ("evex"))
20384     (set_attr ("mode") ("V16SF"))])
20386 (define_insn "avx5124fmaddps_4fnmaddps_maskz"
20387   [(set (match_operand:V16SF 0 "register_operand" "=v")
20388         (vec_merge:V16SF
20389           (unspec:V16SF
20390             [(match_operand:V16SF 1 "register_operand" "0")
20391              (match_operand:V64SF 2 "register_operand" "v")
20392              (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FNMADD)
20393           (match_operand:V16SF 4 "const0_operand" "C")
20394           (match_operand:HI 5 "register_operand" "Yk")))]
20395   "TARGET_AVX5124FMAPS"
20396   "v4fnmaddps\t{%3, %g2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %g2, %3}"
20397    [(set_attr ("type") ("ssemuladd"))
20398     (set_attr ("prefix") ("evex"))
20399     (set_attr ("mode") ("V16SF"))])
20401 (define_insn "avx5124fmaddps_4fnmaddss"
20402   [(set (match_operand:V4SF 0 "register_operand" "=v")
20403         (unspec:V4SF
20404           [(match_operand:V4SF 1 "register_operand" "0")
20405            (match_operand:V64SF 2 "register_operand" "v")
20406            (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FNMADD))]
20407   "TARGET_AVX5124FMAPS"
20408   "v4fnmaddss\t{%3, %x2, %0|%0, %x2, %3}"
20409    [(set_attr ("type") ("ssemuladd"))
20410     (set_attr ("prefix") ("evex"))
20411     (set_attr ("mode") ("SF"))])
20413 (define_insn "avx5124fmaddps_4fnmaddss_mask"
20414   [(set (match_operand:V4SF 0 "register_operand" "=v")
20415         (vec_merge:V4SF
20416           (unspec:V4SF
20417             [(match_operand:V64SF 1 "register_operand" "v")
20418              (match_operand:V4SF 2 "memory_operand" "m")] UNSPEC_VP4FNMADD)
20419           (match_operand:V4SF 3 "register_operand" "0")
20420           (match_operand:QI 4 "register_operand" "Yk")))]
20421   "TARGET_AVX5124FMAPS"
20422   "v4fnmaddss\t{%2, %x1, %0%{%4%}|%0%{%4%}, %x1, %2}"
20423    [(set_attr ("type") ("ssemuladd"))
20424     (set_attr ("prefix") ("evex"))
20425     (set_attr ("mode") ("SF"))])
20427 (define_insn "avx5124fmaddps_4fnmaddss_maskz"
20428   [(set (match_operand:V4SF 0 "register_operand" "=v")
20429         (vec_merge:V4SF
20430           (unspec:V4SF
20431             [(match_operand:V4SF 1 "register_operand" "0")
20432              (match_operand:V64SF 2 "register_operand" "v")
20433              (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FNMADD)
20434           (match_operand:V4SF 4 "const0_operand" "C")
20435           (match_operand:QI 5 "register_operand" "Yk")))]
20436   "TARGET_AVX5124FMAPS"
20437   "v4fnmaddss\t{%3, %x2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %x2, %3}"
20438    [(set_attr ("type") ("ssemuladd"))
20439     (set_attr ("prefix") ("evex"))
20440     (set_attr ("mode") ("SF"))])
20442 (define_insn "avx5124vnniw_vp4dpwssd"
20443   [(set (match_operand:V16SI 0 "register_operand" "=v")
20444         (unspec:V16SI
20445           [(match_operand:V16SI 1 "register_operand" "0")
20446            (match_operand:V64SI 2 "register_operand" "v")
20447            (match_operand:V4SI 3 "memory_operand" "m")] UNSPEC_VP4DPWSSD))]
20448   "TARGET_AVX5124VNNIW"
20449   "vp4dpwssd\t{%3, %g2, %0|%0, %g2, %3}"
20450    [(set_attr ("type") ("ssemuladd"))
20451     (set_attr ("prefix") ("evex"))
20452     (set_attr ("mode") ("TI"))])
20454 (define_insn "avx5124vnniw_vp4dpwssd_mask"
20455   [(set (match_operand:V16SI 0 "register_operand" "=v")
20456         (vec_merge:V16SI
20457           (unspec:V16SI
20458              [(match_operand:V64SI 1 "register_operand" "v")
20459               (match_operand:V4SI 2 "memory_operand" "m")] UNSPEC_VP4DPWSSD)
20460           (match_operand:V16SI 3 "register_operand" "0")
20461           (match_operand:HI 4 "register_operand" "Yk")))]
20462   "TARGET_AVX5124VNNIW"
20463   "vp4dpwssd\t{%2, %g1, %0%{%4%}|%0%{%4%}, %g1, %2}"
20464    [(set_attr ("type") ("ssemuladd"))
20465     (set_attr ("prefix") ("evex"))
20466     (set_attr ("mode") ("TI"))])
20468 (define_insn "avx5124vnniw_vp4dpwssd_maskz"
20469   [(set (match_operand:V16SI 0 "register_operand" "=v")
20470         (vec_merge:V16SI
20471           (unspec:V16SI
20472             [(match_operand:V16SI 1 "register_operand" "0")
20473              (match_operand:V64SI 2 "register_operand" "v")
20474              (match_operand:V4SI 3 "memory_operand" "m")] UNSPEC_VP4DPWSSD)
20475           (match_operand:V16SI 4 "const0_operand" "C")
20476           (match_operand:HI 5 "register_operand" "Yk")))]
20477   "TARGET_AVX5124VNNIW"
20478   "vp4dpwssd\t{%3, %g2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %g2, %3}"
20479    [(set_attr ("type") ("ssemuladd"))
20480     (set_attr ("prefix") ("evex"))
20481     (set_attr ("mode") ("TI"))])
20483 (define_insn "avx5124vnniw_vp4dpwssds"
20484   [(set (match_operand:V16SI 0 "register_operand" "=v")
20485         (unspec:V16SI
20486           [(match_operand:V16SI 1 "register_operand" "0")
20487            (match_operand:V64SI 2 "register_operand" "v")
20488            (match_operand:V4SI 3 "memory_operand" "m")] UNSPEC_VP4DPWSSDS))]
20489   "TARGET_AVX5124VNNIW"
20490   "vp4dpwssds\t{%3, %g2, %0|%0, %g2, %3}"
20491    [(set_attr ("type") ("ssemuladd"))
20492     (set_attr ("prefix") ("evex"))
20493     (set_attr ("mode") ("TI"))])
20495 (define_insn "avx5124vnniw_vp4dpwssds_mask"
20496   [(set (match_operand:V16SI 0 "register_operand" "=v")
20497         (vec_merge:V16SI
20498           (unspec:V16SI
20499              [(match_operand:V64SI 1 "register_operand" "v")
20500               (match_operand:V4SI 2 "memory_operand" "m")] UNSPEC_VP4DPWSSDS)
20501           (match_operand:V16SI 3 "register_operand" "0")
20502           (match_operand:HI 4 "register_operand" "Yk")))]
20503   "TARGET_AVX5124VNNIW"
20504   "vp4dpwssds\t{%2, %g1, %0%{%4%}|%0%{%4%}, %g1, %2}"
20505    [(set_attr ("type") ("ssemuladd"))
20506     (set_attr ("prefix") ("evex"))
20507     (set_attr ("mode") ("TI"))])
20509 (define_insn "avx5124vnniw_vp4dpwssds_maskz"
20510   [(set (match_operand:V16SI 0 "register_operand" "=v")
20511         (vec_merge:V16SI
20512           (unspec:V16SI
20513             [(match_operand:V16SI 1 "register_operand" "0")
20514              (match_operand:V64SI 2 "register_operand" "v")
20515              (match_operand:V4SI 3 "memory_operand" "m")] UNSPEC_VP4DPWSSDS)
20516           (match_operand:V16SI 4 "const0_operand" "C")
20517           (match_operand:HI 5 "register_operand" "Yk")))]
20518   "TARGET_AVX5124VNNIW"
20519   "vp4dpwssds\t{%3, %g2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %g2, %3}"
20520    [(set_attr ("type") ("ssemuladd"))
20521     (set_attr ("prefix") ("evex"))
20522     (set_attr ("mode") ("TI"))])
20524 (define_insn "vpopcount<mode><mask_name>"
20525   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
20526         (popcount:VI48_AVX512VL
20527           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")))]
20528   "TARGET_AVX512VPOPCNTDQ"
20529   "vpopcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}")
20531 ;; Save multiple registers out-of-line.
20532 (define_insn "save_multiple<mode>"
20533   [(match_parallel 0 "save_multiple"
20534     [(use (match_operand:P 1 "symbol_operand"))])]
20535   "TARGET_SSE && TARGET_64BIT"
20536   "call\t%P1")
20538 ;; Restore multiple registers out-of-line.
20539 (define_insn "restore_multiple<mode>"
20540   [(match_parallel 0 "restore_multiple"
20541     [(use (match_operand:P 1 "symbol_operand"))])]
20542   "TARGET_SSE && TARGET_64BIT"
20543   "call\t%P1")
20545 ;; Restore multiple registers out-of-line and return.
20546 (define_insn "restore_multiple_and_return<mode>"
20547   [(match_parallel 0 "restore_multiple"
20548     [(return)
20549      (use (match_operand:P 1 "symbol_operand"))
20550      (set (reg:DI SP_REG) (reg:DI R10_REG))
20551     ])]
20552   "TARGET_SSE && TARGET_64BIT"
20553   "jmp\t%P1")
20555 ;; Restore multiple registers out-of-line when hard frame pointer is used,
20556 ;; perform the leave operation prior to returning (from the function).
20557 (define_insn "restore_multiple_leave_return<mode>"
20558   [(match_parallel 0 "restore_multiple"
20559     [(return)
20560      (use (match_operand:P 1 "symbol_operand"))
20561      (set (reg:DI SP_REG) (plus:DI (reg:DI BP_REG) (const_int 8)))
20562      (set (reg:DI BP_REG) (mem:DI (reg:DI BP_REG)))
20563      (clobber (mem:BLK (scratch)))
20564     ])]
20565   "TARGET_SSE && TARGET_64BIT"
20566   "jmp\t%P1")
20568 (define_insn "vpopcount<mode><mask_name>"
20569   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
20570         (popcount:VI12_AVX512VL
20571           (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "vm")))]
20572   "TARGET_AVX512BITALG"
20573   "vpopcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}")
20575 (define_insn "vgf2p8affineinvqb_<mode><mask_name>"
20576   [(set (match_operand:VI1_AVX512F 0 "register_operand" "=x,x,v")
20577         (unspec:VI1_AVX512F
20578           [(match_operand:VI1_AVX512F 1 "register_operand" "%0,x,v")
20579            (match_operand:VI1_AVX512F 2 "nonimmediate_operand" "xBm,xm,vm")
20580            (match_operand:QI 3 "const_0_to_255_operand" "n,n,n")]
20581           UNSPEC_GF2P8AFFINEINV))]
20582   "TARGET_GFNI"
20583   "@
20584    gf2p8affineinvqb\t{%3, %2, %0| %0, %2, %3}
20585    vgf2p8affineinvqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}
20586    vgf2p8affineinvqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}"
20587   [(set_attr "isa" "noavx,avx,avx512f")
20588    (set_attr "prefix_data16" "1,*,*")
20589    (set_attr "prefix_extra" "1")
20590    (set_attr "prefix" "orig,maybe_evex,evex")
20591    (set_attr "mode" "<sseinsnmode>")])
20593 (define_insn "vgf2p8affineqb_<mode><mask_name>"
20594   [(set (match_operand:VI1_AVX512F 0 "register_operand" "=x,x,v")
20595         (unspec:VI1_AVX512F
20596           [(match_operand:VI1_AVX512F 1 "register_operand" "%0,x,v")
20597            (match_operand:VI1_AVX512F 2 "nonimmediate_operand" "xBm,xm,vm")
20598            (match_operand:QI 3 "const_0_to_255_operand" "n,n,n")]
20599           UNSPEC_GF2P8AFFINE))]
20600   "TARGET_GFNI"
20601   "@
20602    gf2p8affineqb\t{%3, %2, %0| %0, %2, %3}
20603    vgf2p8affineqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}
20604    vgf2p8affineqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}"
20605   [(set_attr "isa" "noavx,avx,avx512f")
20606    (set_attr "prefix_data16" "1,*,*")
20607    (set_attr "prefix_extra" "1")
20608    (set_attr "prefix" "orig,maybe_evex,evex")
20609    (set_attr "mode" "<sseinsnmode>")])
20611 (define_insn "vgf2p8mulb_<mode><mask_name>"
20612   [(set (match_operand:VI1_AVX512F 0 "register_operand" "=x,x,v")
20613         (unspec:VI1_AVX512F
20614           [(match_operand:VI1_AVX512F 1 "register_operand" "%0,x,v")
20615            (match_operand:VI1_AVX512F 2 "nonimmediate_operand" "xBm,xm,vm")]
20616           UNSPEC_GF2P8MUL))]
20617   "TARGET_GFNI"
20618   "@
20619    gf2p8mulb\t{%2, %0| %0, %2}
20620    vgf2p8mulb\t{%2, %1, %0<mask_operand3>| %0<mask_operand3>, %1, %2}
20621    vgf2p8mulb\t{%2, %1, %0<mask_operand3>| %0<mask_operand3>, %1, %2}"
20622   [(set_attr "isa" "noavx,avx,avx512f")
20623    (set_attr "prefix_data16" "1,*,*")
20624    (set_attr "prefix_extra" "1")
20625    (set_attr "prefix" "orig,maybe_evex,evex")
20626    (set_attr "mode" "<sseinsnmode>")])
20628 (define_insn "vpshrd_<mode><mask_name>"
20629   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20630         (unspec:VI248_AVX512VL
20631           [(match_operand:VI248_AVX512VL 1 "register_operand" "v")
20632            (match_operand:VI248_AVX512VL 2 "nonimmediate_operand" "vm")
20633            (match_operand:SI 3 "const_0_to_255_operand" "n")]
20634           UNSPEC_VPSHRD))]
20635   "TARGET_AVX512VBMI2"
20636   "vpshrd<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3 }"
20637    [(set_attr ("prefix") ("evex"))])
20639 (define_insn "vpshld_<mode><mask_name>"
20640   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20641         (unspec:VI248_AVX512VL
20642           [(match_operand:VI248_AVX512VL 1 "register_operand" "v")
20643            (match_operand:VI248_AVX512VL 2 "nonimmediate_operand" "vm")
20644            (match_operand:SI 3 "const_0_to_255_operand" "n")]
20645           UNSPEC_VPSHLD))]
20646   "TARGET_AVX512VBMI2"
20647   "vpshld<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3 }"
20648    [(set_attr ("prefix") ("evex"))])
20650 (define_insn "vpshrdv_<mode>"
20651   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20652         (unspec:VI248_AVX512VL
20653           [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20654            (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20655            (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20656           UNSPEC_VPSHRDV))]
20657   "TARGET_AVX512VBMI2"
20658   "vpshrdv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3 }"
20659    [(set_attr ("prefix") ("evex"))
20660    (set_attr "mode" "<sseinsnmode>")])
20662 (define_insn "vpshrdv_<mode>_mask"
20663   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20664         (vec_merge:VI248_AVX512VL
20665           (unspec:VI248_AVX512VL
20666             [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20667              (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20668              (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20669             UNSPEC_VPSHRDV)
20670           (match_dup 1)
20671           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20672   "TARGET_AVX512VBMI2"
20673   "vpshrdv<ssemodesuffix>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20674    [(set_attr ("prefix") ("evex"))
20675    (set_attr "mode" "<sseinsnmode>")])
20677 (define_expand "vpshrdv_<mode>_maskz"
20678   [(match_operand:VI248_AVX512VL 0 "register_operand")
20679    (match_operand:VI248_AVX512VL 1 "register_operand")
20680    (match_operand:VI248_AVX512VL 2 "register_operand")
20681    (match_operand:VI248_AVX512VL 3 "nonimmediate_operand")
20682    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20683   "TARGET_AVX512VBMI2"
20685   emit_insn (gen_vpshrdv_<mode>_maskz_1 (operands[0], operands[1],
20686                                          operands[2], operands[3],
20687                                          CONST0_RTX (<MODE>mode),
20688                                                      operands[4]));
20689   DONE;
20692 (define_insn "vpshrdv_<mode>_maskz_1"
20693   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20694         (vec_merge:VI248_AVX512VL
20695           (unspec:VI248_AVX512VL
20696             [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20697              (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20698              (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20699             UNSPEC_VPSHRDV)
20700           (match_operand:VI248_AVX512VL 4 "const0_operand" "C")
20701           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20702   "TARGET_AVX512VBMI2"
20703   "vpshrdv<ssemodesuffix>\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20704    [(set_attr ("prefix") ("evex"))
20705    (set_attr "mode" "<sseinsnmode>")])
20707 (define_insn "vpshldv_<mode>"
20708   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20709         (unspec:VI248_AVX512VL
20710           [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20711            (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20712            (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20713           UNSPEC_VPSHLDV))]
20714   "TARGET_AVX512VBMI2"
20715   "vpshldv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3 }"
20716    [(set_attr ("prefix") ("evex"))
20717    (set_attr "mode" "<sseinsnmode>")])
20719 (define_insn "vpshldv_<mode>_mask"
20720   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20721         (vec_merge:VI248_AVX512VL
20722           (unspec:VI248_AVX512VL
20723             [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20724              (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20725              (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20726             UNSPEC_VPSHLDV)
20727           (match_dup 1)
20728           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20729   "TARGET_AVX512VBMI2"
20730   "vpshldv<ssemodesuffix>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20731    [(set_attr ("prefix") ("evex"))
20732    (set_attr "mode" "<sseinsnmode>")])
20734 (define_expand "vpshldv_<mode>_maskz"
20735   [(match_operand:VI248_AVX512VL 0 "register_operand")
20736    (match_operand:VI248_AVX512VL 1 "register_operand")
20737    (match_operand:VI248_AVX512VL 2 "register_operand")
20738    (match_operand:VI248_AVX512VL 3 "nonimmediate_operand")
20739    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20740   "TARGET_AVX512VBMI2"
20742   emit_insn (gen_vpshldv_<mode>_maskz_1 (operands[0], operands[1],
20743                                          operands[2], operands[3],
20744                                          CONST0_RTX (<MODE>mode),
20745                                                      operands[4]));
20746   DONE;
20749 (define_insn "vpshldv_<mode>_maskz_1"
20750   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20751         (vec_merge:VI248_AVX512VL
20752           (unspec:VI248_AVX512VL
20753             [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20754              (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20755              (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20756             UNSPEC_VPSHLDV)
20757           (match_operand:VI248_AVX512VL 4 "const0_operand" "C")
20758           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20759   "TARGET_AVX512VBMI2"
20760   "vpshldv<ssemodesuffix>\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20761    [(set_attr ("prefix") ("evex"))
20762    (set_attr "mode" "<sseinsnmode>")])
20764 (define_insn "vpdpbusd_<mode>"
20765   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20766         (unspec:VI4_AVX512VL
20767           [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20768            (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20769            (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20770           UNSPEC_VPMADDUBSWACCD))]
20771   "TARGET_AVX512VNNI"
20772   "vpdpbusd\t{%3, %2, %0|%0, %2, %3 }"
20773    [(set_attr ("prefix") ("evex"))])
20775 (define_insn "vpdpbusd_<mode>_mask"
20776   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20777         (vec_merge:VI4_AVX512VL
20778           (unspec:VI4_AVX512VL
20779             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20780              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20781              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20782             UNSPEC_VPMADDUBSWACCD)
20783           (match_dup 1)
20784           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20785   "TARGET_AVX512VNNI"
20786   "vpdpbusd\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20787    [(set_attr ("prefix") ("evex"))])
20789 (define_expand "vpdpbusd_<mode>_maskz"
20790   [(match_operand:VI4_AVX512VL 0 "register_operand")
20791    (match_operand:VI4_AVX512VL 1 "register_operand")
20792    (match_operand:VI4_AVX512VL 2 "register_operand")
20793    (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
20794    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20795   "TARGET_AVX512VNNI"
20797   emit_insn (gen_vpdpbusd_<mode>_maskz_1 (operands[0], operands[1],
20798                                           operands[2], operands[3],
20799                                           CONST0_RTX (<MODE>mode),
20800                                                       operands[4]));
20801   DONE;
20804 (define_insn "vpdpbusd_<mode>_maskz_1"
20805   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20806         (vec_merge:VI4_AVX512VL
20807           (unspec:VI4_AVX512VL
20808             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20809              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20810              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")
20811             ] UNSPEC_VPMADDUBSWACCD)
20812           (match_operand:VI4_AVX512VL 4 "const0_operand" "C")
20813           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20814   "TARGET_AVX512VNNI"
20815   "vpdpbusd\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20816    [(set_attr ("prefix") ("evex"))])
20819 (define_insn "vpdpbusds_<mode>"
20820   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20821         (unspec:VI4_AVX512VL
20822           [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20823            (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20824            (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20825           UNSPEC_VPMADDUBSWACCSSD))]
20826   "TARGET_AVX512VNNI"
20827   "vpdpbusds\t{%3, %2, %0|%0, %2, %3 }"
20828    [(set_attr ("prefix") ("evex"))])
20830 (define_insn "vpdpbusds_<mode>_mask"
20831   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20832         (vec_merge:VI4_AVX512VL
20833           (unspec:VI4_AVX512VL
20834             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20835              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20836              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20837             UNSPEC_VPMADDUBSWACCSSD)
20838           (match_dup 1)
20839           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20840   "TARGET_AVX512VNNI"
20841   "vpdpbusds\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20842    [(set_attr ("prefix") ("evex"))])
20844 (define_expand "vpdpbusds_<mode>_maskz"
20845   [(match_operand:VI4_AVX512VL 0 "register_operand")
20846    (match_operand:VI4_AVX512VL 1 "register_operand")
20847    (match_operand:VI4_AVX512VL 2 "register_operand")
20848    (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
20849    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20850   "TARGET_AVX512VNNI"
20852   emit_insn (gen_vpdpbusds_<mode>_maskz_1 (operands[0], operands[1],
20853                                            operands[2], operands[3],
20854                                            CONST0_RTX (<MODE>mode),
20855                                                        operands[4]));
20856   DONE;
20859 (define_insn "vpdpbusds_<mode>_maskz_1"
20860   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20861         (vec_merge:VI4_AVX512VL
20862           (unspec:VI4_AVX512VL
20863             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20864              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20865              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20866             UNSPEC_VPMADDUBSWACCSSD)
20867           (match_operand:VI4_AVX512VL 4 "const0_operand" "C")
20868           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20869   "TARGET_AVX512VNNI"
20870   "vpdpbusds\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20871    [(set_attr ("prefix") ("evex"))])
20874 (define_insn "vpdpwssd_<mode>"
20875   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20876         (unspec:VI4_AVX512VL
20877           [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20878            (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20879            (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20880           UNSPEC_VPMADDWDACCD))]
20881   "TARGET_AVX512VNNI"
20882   "vpdpwssd\t{%3, %2, %0|%0, %2, %3 }"
20883    [(set_attr ("prefix") ("evex"))])
20885 (define_insn "vpdpwssd_<mode>_mask"
20886   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20887         (vec_merge:VI4_AVX512VL
20888           (unspec:VI4_AVX512VL
20889             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20890              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20891              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20892             UNSPEC_VPMADDWDACCD)
20893           (match_dup 1)
20894           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20895   "TARGET_AVX512VNNI"
20896   "vpdpwssd\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20897    [(set_attr ("prefix") ("evex"))])
20899 (define_expand "vpdpwssd_<mode>_maskz"
20900   [(match_operand:VI4_AVX512VL 0 "register_operand")
20901    (match_operand:VI4_AVX512VL 1 "register_operand")
20902    (match_operand:VI4_AVX512VL 2 "register_operand")
20903    (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
20904    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20905   "TARGET_AVX512VNNI"
20907   emit_insn (gen_vpdpwssd_<mode>_maskz_1 (operands[0], operands[1],
20908                                           operands[2], operands[3],
20909                                           CONST0_RTX (<MODE>mode),
20910                                                       operands[4]));
20911   DONE;
20914 (define_insn "vpdpwssd_<mode>_maskz_1"
20915   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20916         (vec_merge:VI4_AVX512VL
20917           (unspec:VI4_AVX512VL
20918             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20919              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20920              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20921             UNSPEC_VPMADDWDACCD)
20922           (match_operand:VI4_AVX512VL 4 "const0_operand" "C")
20923           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20924   "TARGET_AVX512VNNI"
20925   "vpdpwssd\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20926    [(set_attr ("prefix") ("evex"))])
20929 (define_insn "vpdpwssds_<mode>"
20930   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20931         (unspec:VI4_AVX512VL
20932           [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20933            (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20934            (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20935           UNSPEC_VPMADDWDACCSSD))]
20936   "TARGET_AVX512VNNI"
20937   "vpdpwssds\t{%3, %2, %0|%0, %2, %3 }"
20938    [(set_attr ("prefix") ("evex"))])
20940 (define_insn "vpdpwssds_<mode>_mask"
20941   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20942         (vec_merge:VI4_AVX512VL
20943           (unspec:VI4_AVX512VL
20944             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20945              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20946              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20947             UNSPEC_VPMADDWDACCSSD)
20948           (match_dup 1)
20949           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20950   "TARGET_AVX512VNNI"
20951   "vpdpwssds\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20952    [(set_attr ("prefix") ("evex"))])
20954 (define_expand "vpdpwssds_<mode>_maskz"
20955   [(match_operand:VI4_AVX512VL 0 "register_operand")
20956    (match_operand:VI4_AVX512VL 1 "register_operand")
20957    (match_operand:VI4_AVX512VL 2 "register_operand")
20958    (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
20959    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20960   "TARGET_AVX512VNNI"
20962   emit_insn (gen_vpdpwssds_<mode>_maskz_1 (operands[0], operands[1],
20963                                            operands[2], operands[3],
20964                                            CONST0_RTX (<MODE>mode),
20965                                                        operands[4]));
20966   DONE;
20969 (define_insn "vpdpwssds_<mode>_maskz_1"
20970   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20971         (vec_merge:VI4_AVX512VL
20972           (unspec:VI4_AVX512VL
20973             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20974              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20975              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20976             UNSPEC_VPMADDWDACCSSD)
20977           (match_operand:VI4_AVX512VL 4 "const0_operand" "C")
20978           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20979   "TARGET_AVX512VNNI"
20980   "vpdpwssds\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20981    [(set_attr ("prefix") ("evex"))])
20983 (define_insn "vaesdec_<mode>"
20984   [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=v")
20985         (unspec:VI1_AVX512VL_F
20986           [(match_operand:VI1_AVX512VL_F 1 "register_operand" "v")
20987            (match_operand:VI1_AVX512VL_F 2 "vector_operand" "v")]
20988           UNSPEC_VAESDEC))]
20989   "TARGET_VAES"
20990   "vaesdec\t{%2, %1, %0|%0, %1, %2}"
20993 (define_insn "vaesdeclast_<mode>"
20994   [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=v")
20995         (unspec:VI1_AVX512VL_F
20996           [(match_operand:VI1_AVX512VL_F 1 "register_operand" "v")
20997            (match_operand:VI1_AVX512VL_F 2 "vector_operand" "v")]
20998           UNSPEC_VAESDECLAST))]
20999   "TARGET_VAES"
21000   "vaesdeclast\t{%2, %1, %0|%0, %1, %2}"
21003 (define_insn "vaesenc_<mode>"
21004   [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=v")
21005         (unspec:VI1_AVX512VL_F
21006           [(match_operand:VI1_AVX512VL_F 1 "register_operand" "v")
21007            (match_operand:VI1_AVX512VL_F 2 "vector_operand" "vm")]
21008           UNSPEC_VAESENC))]
21009   "TARGET_VAES"
21010   "vaesenc\t{%2, %1, %0|%0, %1, %2}"
21013 (define_insn "vaesenclast_<mode>"
21014   [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=v")
21015         (unspec:VI1_AVX512VL_F
21016           [(match_operand:VI1_AVX512VL_F 1 "register_operand" "v")
21017            (match_operand:VI1_AVX512VL_F 2 "vector_operand" "vm")]
21018           UNSPEC_VAESENCLAST))]
21019   "TARGET_VAES"
21020   "vaesenclast\t{%2, %1, %0|%0, %1, %2}"
21023 (define_insn "vpclmulqdq_<mode>"
21024   [(set (match_operand:VI8_FVL 0 "register_operand" "=v")
21025         (unspec:VI8_FVL [(match_operand:VI8_FVL 1 "register_operand" "v")
21026                          (match_operand:VI8_FVL 2 "vector_operand" "vm")
21027                          (match_operand:SI 3 "const_0_to_255_operand" "n")]
21028                         UNSPEC_VPCLMULQDQ))]
21029   "TARGET_VPCLMULQDQ"
21030   "vpclmulqdq\t{%3, %2, %1, %0|%0, %1, %2, %3}"
21031   [(set_attr "mode" "DI")])
21033 (define_insn "avx512vl_vpshufbitqmb<mode><mask_scalar_merge_name>"
21034   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
21035         (unspec:<avx512fmaskmode>
21036           [(match_operand:VI1_AVX512VLBW 1 "register_operand" "v")
21037            (match_operand:VI1_AVX512VLBW 2 "nonimmediate_operand" "vm")]
21038           UNSPEC_VPSHUFBIT))]
21039   "TARGET_AVX512BITALG"
21040   "vpshufbitqmb\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
21041   [(set_attr "prefix" "evex")
21042    (set_attr "mode" "<sseinsnmode>")])