[AArch64] Use UNSPEC_MERGE_PTRUE for comparisons
[official-gcc.git] / gcc / config / i386 / sse.md
blob858c29ec3e262ae8cd75a2784c6c4d8dc2329a4e
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 ssedoublemodelower
585   [(V16QI "v16hi") (V32QI "v32hi") (V64QI "v64hi")
586    (V8HI "v8si")   (V16HI "v16si") (V32HI "v32si")
587    (V4SI "v4di")   (V8SI "v8di")   (V16SI "v16di")])
589 (define_mode_attr ssedoublemode
590   [(V4SF "V8SF") (V8SF "V16SF") (V16SF "V32SF")
591    (V2DF "V4DF") (V4DF "V8DF") (V8DF "V16DF")
592    (V16QI "V16HI") (V32QI "V32HI") (V64QI "V64HI")
593    (V4HI "V4SI") (V8HI "V8SI") (V16HI "V16SI") (V32HI "V32SI")
594    (V4SI "V4DI") (V8SI "V16SI") (V16SI "V32SI")
595    (V4DI "V8DI") (V8DI "V16DI")])
597 (define_mode_attr ssebytemode
598   [(V8DI "V64QI") (V4DI "V32QI") (V2DI "V16QI")])
600 ;; All 128bit vector integer modes
601 (define_mode_iterator VI_128 [V16QI V8HI V4SI V2DI])
603 ;; All 256bit vector integer modes
604 (define_mode_iterator VI_256 [V32QI V16HI V8SI V4DI])
606 ;; Various 128bit vector integer mode combinations
607 (define_mode_iterator VI12_128 [V16QI V8HI])
608 (define_mode_iterator VI14_128 [V16QI V4SI])
609 (define_mode_iterator VI124_128 [V16QI V8HI V4SI])
610 (define_mode_iterator VI24_128 [V8HI V4SI])
611 (define_mode_iterator VI248_128 [V8HI V4SI V2DI])
612 (define_mode_iterator VI48_128 [V4SI V2DI])
614 ;; Various 256bit and 512 vector integer mode combinations
615 (define_mode_iterator VI124_256 [V32QI V16HI V8SI])
616 (define_mode_iterator VI124_256_AVX512F_AVX512BW
617   [V32QI V16HI V8SI
618    (V64QI "TARGET_AVX512BW")
619    (V32HI "TARGET_AVX512BW")
620    (V16SI "TARGET_AVX512F")])
621 (define_mode_iterator VI48_256 [V8SI V4DI])
622 (define_mode_iterator VI48_512 [V16SI V8DI])
623 (define_mode_iterator VI4_256_8_512 [V8SI V8DI])
624 (define_mode_iterator VI_AVX512BW
625   [V16SI V8DI (V32HI "TARGET_AVX512BW") (V64QI "TARGET_AVX512BW")])
627 ;; Int-float size matches
628 (define_mode_iterator VI4F_128 [V4SI V4SF])
629 (define_mode_iterator VI8F_128 [V2DI V2DF])
630 (define_mode_iterator VI4F_256 [V8SI V8SF])
631 (define_mode_iterator VI8F_256 [V4DI V4DF])
632 (define_mode_iterator VI4F_256_512
633   [V8SI V8SF
634    (V16SI "TARGET_AVX512F") (V16SF "TARGET_AVX512F")])
635 (define_mode_iterator VI48F_256_512
636   [V8SI V8SF
637   (V16SI "TARGET_AVX512F") (V16SF "TARGET_AVX512F")
638   (V8DI  "TARGET_AVX512F") (V8DF  "TARGET_AVX512F")
639   (V4DI  "TARGET_AVX512VL") (V4DF  "TARGET_AVX512VL")])
640 (define_mode_iterator VF48_I1248
641   [V16SI V16SF V8DI V8DF V32HI V64QI])
642 (define_mode_iterator VI48F
643   [V16SI V16SF V8DI V8DF
644    (V8SI "TARGET_AVX512VL") (V8SF "TARGET_AVX512VL")
645    (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")
646    (V4SI "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
647    (V2DI "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
648 (define_mode_iterator VI48F_256 [V8SI V8SF V4DI V4DF])
650 ;; Mapping from float mode to required SSE level
651 (define_mode_attr sse
652   [(SF "sse") (DF "sse2")
653    (V4SF "sse") (V2DF "sse2")
654    (V16SF "avx512f") (V8SF "avx")
655    (V8DF "avx512f") (V4DF "avx")])
657 (define_mode_attr sse2
658   [(V16QI "sse2") (V32QI "avx") (V64QI "avx512f")
659    (V2DI "sse2") (V4DI "avx") (V8DI "avx512f")])
661 (define_mode_attr sse3
662   [(V16QI "sse3") (V32QI "avx")])
664 (define_mode_attr sse4_1
665   [(V4SF "sse4_1") (V2DF "sse4_1")
666    (V8SF "avx") (V4DF "avx")
667    (V8DF "avx512f")
668    (V4DI "avx") (V2DI "sse4_1")
669    (V8SI "avx") (V4SI "sse4_1")
670    (V16QI "sse4_1") (V32QI "avx")
671    (V8HI "sse4_1") (V16HI "avx")])
673 (define_mode_attr avxsizesuffix
674   [(V64QI "512") (V32HI "512") (V16SI "512") (V8DI "512")
675    (V32QI "256") (V16HI "256") (V8SI "256") (V4DI "256")
676    (V16QI "") (V8HI "") (V4SI "") (V2DI "")
677    (V16SF "512") (V8DF "512")
678    (V8SF "256") (V4DF "256")
679    (V4SF "") (V2DF "")])
681 ;; SSE instruction mode
682 (define_mode_attr sseinsnmode
683   [(V64QI "XI") (V32HI "XI") (V16SI "XI") (V8DI "XI") (V4TI "XI")
684    (V32QI "OI") (V16HI "OI") (V8SI "OI") (V4DI "OI") (V2TI "OI")
685    (V16QI "TI") (V8HI "TI") (V4SI "TI") (V2DI "TI") (V1TI "TI")
686    (V16SF "V16SF") (V8DF "V8DF")
687    (V8SF "V8SF") (V4DF "V4DF")
688    (V4SF "V4SF") (V2DF "V2DF")
689    (TI "TI")])
691 ;; Mapping of vector modes to corresponding mask size
692 (define_mode_attr avx512fmaskmode
693   [(V64QI "DI") (V32QI "SI") (V16QI "HI")
694    (V32HI "SI") (V16HI "HI") (V8HI  "QI") (V4HI "QI")
695    (V16SI "HI") (V8SI  "QI") (V4SI  "QI")
696    (V8DI  "QI") (V4DI  "QI") (V2DI  "QI")
697    (V16SF "HI") (V8SF  "QI") (V4SF  "QI")
698    (V8DF  "QI") (V4DF  "QI") (V2DF  "QI")])
700 ;; Mapping of vector modes to corresponding mask size
701 (define_mode_attr avx512fmaskmodelower
702   [(V64QI "di") (V32QI "si") (V16QI "hi")
703    (V32HI "si") (V16HI "hi") (V8HI  "qi") (V4HI "qi")
704    (V16SI "hi") (V8SI  "qi") (V4SI  "qi")
705    (V8DI  "qi") (V4DI  "qi") (V2DI  "qi")
706    (V16SF "hi") (V8SF  "qi") (V4SF  "qi")
707    (V8DF  "qi") (V4DF  "qi") (V2DF  "qi")])
709 ;; Mapping of vector float modes to an integer mode of the same size
710 (define_mode_attr sseintvecmode
711   [(V16SF "V16SI") (V8DF  "V8DI")
712    (V8SF  "V8SI")  (V4DF  "V4DI")
713    (V4SF  "V4SI")  (V2DF  "V2DI")
714    (V16SI "V16SI") (V8DI  "V8DI")
715    (V8SI  "V8SI")  (V4DI  "V4DI")
716    (V4SI  "V4SI")  (V2DI  "V2DI")
717    (V16HI "V16HI") (V8HI  "V8HI")
718    (V32HI "V32HI") (V64QI "V64QI")
719    (V32QI "V32QI") (V16QI "V16QI")])
721 (define_mode_attr sseintvecmode2
722   [(V8DF "XI") (V4DF "OI") (V2DF "TI")
723    (V8SF "OI") (V4SF "TI")])
725 (define_mode_attr sseintvecmodelower
726   [(V16SF "v16si") (V8DF "v8di")
727    (V8SF "v8si") (V4DF "v4di")
728    (V4SF "v4si") (V2DF "v2di")
729    (V8SI "v8si") (V4DI "v4di")
730    (V4SI "v4si") (V2DI "v2di")
731    (V16HI "v16hi") (V8HI "v8hi")
732    (V32QI "v32qi") (V16QI "v16qi")])
734 ;; Mapping of vector modes to a vector mode of double size
735 (define_mode_attr ssedoublevecmode
736   [(V32QI "V64QI") (V16HI "V32HI") (V8SI "V16SI") (V4DI "V8DI")
737    (V16QI "V32QI") (V8HI "V16HI") (V4SI "V8SI") (V2DI "V4DI")
738    (V8SF "V16SF") (V4DF "V8DF")
739    (V4SF "V8SF") (V2DF "V4DF")])
741 ;; Mapping of vector modes to a vector mode of half size
742 (define_mode_attr ssehalfvecmode
743   [(V64QI "V32QI") (V32HI "V16HI") (V16SI "V8SI") (V8DI "V4DI") (V4TI "V2TI")
744    (V32QI "V16QI") (V16HI  "V8HI") (V8SI  "V4SI") (V4DI "V2DI")
745    (V16QI  "V8QI") (V8HI   "V4HI") (V4SI  "V2SI")
746    (V16SF "V8SF") (V8DF "V4DF")
747    (V8SF  "V4SF") (V4DF "V2DF")
748    (V4SF  "V2SF")])
750 (define_mode_attr ssehalfvecmodelower
751   [(V64QI "v32qi") (V32HI "v16hi") (V16SI "v8si") (V8DI "v4di") (V4TI "v2ti")
752    (V32QI "v16qi") (V16HI  "v8hi") (V8SI  "v4si") (V4DI "v2di")
753    (V16QI  "v8qi") (V8HI   "v4hi") (V4SI  "v2si")
754    (V16SF "v8sf") (V8DF "v4df")
755    (V8SF  "v4sf") (V4DF "v2df")
756    (V4SF  "v2sf")])
758 ;; Mapping of vector modes ti packed single mode of the same size
759 (define_mode_attr ssePSmode
760   [(V16SI "V16SF") (V8DF "V16SF")
761    (V16SF "V16SF") (V8DI "V16SF")
762    (V64QI "V16SF") (V32QI "V8SF") (V16QI "V4SF")
763    (V32HI "V16SF") (V16HI "V8SF") (V8HI "V4SF")
764    (V8SI "V8SF") (V4SI "V4SF")
765    (V4DI "V8SF") (V2DI "V4SF")
766    (V4TI "V16SF") (V2TI "V8SF") (V1TI "V4SF")
767    (V8SF "V8SF") (V4SF "V4SF")
768    (V4DF "V8SF") (V2DF "V4SF")])
770 (define_mode_attr ssePSmode2
771   [(V8DI "V8SF") (V4DI "V4SF")])
773 ;; Mapping of vector modes back to the scalar modes
774 (define_mode_attr ssescalarmode
775   [(V64QI "QI") (V32QI "QI") (V16QI "QI")
776    (V32HI "HI") (V16HI "HI") (V8HI "HI")
777    (V16SI "SI") (V8SI "SI")  (V4SI "SI")
778    (V8DI "DI")  (V4DI "DI")  (V2DI "DI")
779    (V16SF "SF") (V8SF "SF")  (V4SF "SF")
780    (V8DF "DF")  (V4DF "DF")  (V2DF "DF")
781    (V4TI "TI")  (V2TI "TI")])
783 ;; Mapping of vector modes back to the scalar modes
784 (define_mode_attr ssescalarmodelower
785   [(V64QI "qi") (V32QI "qi") (V16QI "qi")
786    (V32HI "hi") (V16HI "hi") (V8HI "hi")
787    (V16SI "si") (V8SI "si")  (V4SI "si")
788    (V8DI "di")  (V4DI "di")  (V2DI "di")
789    (V16SF "sf") (V8SF "sf")  (V4SF "sf")
790    (V8DF "df")  (V4DF "df")  (V2DF "df")
791    (V4TI "ti")  (V2TI "ti")])
793 ;; Mapping of vector modes to the 128bit modes
794 (define_mode_attr ssexmmmode
795   [(V64QI "V16QI") (V32QI "V16QI") (V16QI "V16QI")
796    (V32HI "V8HI")  (V16HI "V8HI") (V8HI "V8HI")
797    (V16SI "V4SI")  (V8SI "V4SI")  (V4SI "V4SI")
798    (V8DI "V2DI")   (V4DI "V2DI")  (V2DI "V2DI")
799    (V16SF "V4SF")  (V8SF "V4SF")  (V4SF "V4SF")
800    (V8DF "V2DF")   (V4DF "V2DF")  (V2DF "V2DF")])
802 ;; Pointer size override for scalar modes (Intel asm dialect)
803 (define_mode_attr iptr
804   [(V64QI "b") (V32HI "w") (V16SI "k") (V8DI "q")
805    (V32QI "b") (V16HI "w") (V8SI "k") (V4DI "q")
806    (V16QI "b") (V8HI "w") (V4SI "k") (V2DI "q")
807    (V16SF "k") (V8DF "q")
808    (V8SF "k") (V4DF "q")
809    (V4SF "k") (V2DF "q")
810    (SF "k") (DF "q")])
812 ;; Number of scalar elements in each vector type
813 (define_mode_attr ssescalarnum
814   [(V64QI "64") (V16SI "16") (V8DI "8")
815    (V32QI "32") (V16HI "16") (V8SI "8") (V4DI "4")
816    (V16QI "16") (V8HI "8") (V4SI "4") (V2DI "2")
817    (V16SF "16") (V8DF "8")
818    (V8SF "8") (V4DF "4")
819    (V4SF "4") (V2DF "2")])
821 ;; Mask of scalar elements in each vector type
822 (define_mode_attr ssescalarnummask
823   [(V32QI "31") (V16HI "15") (V8SI "7") (V4DI "3")
824    (V16QI "15") (V8HI "7") (V4SI "3") (V2DI "1")
825    (V8SF "7") (V4DF "3")
826    (V4SF "3") (V2DF "1")])
828 (define_mode_attr ssescalarsize
829   [(V4TI  "64") (V2TI  "64") (V1TI  "64")
830    (V8DI  "64") (V4DI  "64") (V2DI  "64")
831    (V64QI "8") (V32QI "8") (V16QI "8")
832    (V32HI "16") (V16HI "16") (V8HI "16")
833    (V16SI "32") (V8SI "32") (V4SI "32")
834    (V16SF "32") (V8SF "32") (V4SF "32")
835    (V8DF "64") (V4DF "64") (V2DF "64")])
837 ;; SSE prefix for integer vector modes
838 (define_mode_attr sseintprefix
839   [(V2DI  "p") (V2DF  "")
840    (V4DI  "p") (V4DF  "")
841    (V8DI  "p") (V8DF  "")
842    (V4SI  "p") (V4SF  "")
843    (V8SI  "p") (V8SF  "")
844    (V16SI "p") (V16SF "")
845    (V16QI "p") (V8HI "p")
846    (V32QI "p") (V16HI "p")
847    (V64QI "p") (V32HI "p")])
849 ;; SSE scalar suffix for vector modes
850 (define_mode_attr ssescalarmodesuffix
851   [(SF "ss") (DF "sd")
852    (V16SF "ss") (V8DF "sd")
853    (V8SF "ss") (V4DF "sd")
854    (V4SF "ss") (V2DF "sd")
855    (V16SI "d") (V8DI "q")
856    (V8SI "d") (V4DI "q")
857    (V4SI "d") (V2DI "q")])
859 ;; Pack/unpack vector modes
860 (define_mode_attr sseunpackmode
861   [(V16QI "V8HI") (V8HI "V4SI") (V4SI "V2DI")
862    (V32QI "V16HI") (V16HI "V8SI") (V8SI "V4DI")
863    (V32HI "V16SI") (V64QI "V32HI") (V16SI "V8DI")])
865 (define_mode_attr ssepackmode
866   [(V8HI "V16QI") (V4SI "V8HI") (V2DI "V4SI")
867    (V16HI "V32QI") (V8SI "V16HI") (V4DI "V8SI")
868    (V32HI "V64QI") (V16SI "V32HI") (V8DI "V16SI")])
870 ;; Mapping of the max integer size for xop rotate immediate constraint
871 (define_mode_attr sserotatemax
872   [(V16QI "7") (V8HI "15") (V4SI "31") (V2DI "63")])
874 ;; Mapping of mode to cast intrinsic name
875 (define_mode_attr castmode
876  [(V8SI "si") (V8SF "ps") (V4DF "pd")
877   (V16SI "si") (V16SF "ps") (V8DF "pd")])
879 ;; Instruction suffix for sign and zero extensions.
880 (define_code_attr extsuffix [(sign_extend "sx") (zero_extend "zx")])
882 ;; i128 for integer vectors and TARGET_AVX2, f128 otherwise.
883 ;; i64x4 or f64x4 for 512bit modes.
884 (define_mode_attr i128
885   [(V16SF "f64x4") (V8SF "f128") (V8DF "f64x4") (V4DF "f128")
886    (V64QI "i64x4") (V32QI "%~128") (V32HI "i64x4") (V16HI "%~128")
887    (V16SI "i64x4") (V8SI "%~128") (V8DI "i64x4") (V4DI "%~128")])
889 ;; For 256-bit modes for TARGET_AVX512VL && TARGET_AVX512DQ
890 ;; i32x4, f32x4, i64x2 or f64x2 suffixes.
891 (define_mode_attr i128vldq
892   [(V8SF "f32x4") (V4DF "f64x2")
893    (V32QI "i32x4") (V16HI "i32x4") (V8SI "i32x4") (V4DI "i64x2")])
895 ;; Mix-n-match
896 (define_mode_iterator AVX256MODE2P [V8SI V8SF V4DF])
897 (define_mode_iterator AVX512MODE2P [V16SI V16SF V8DF])
899 ;; Mapping for dbpsabbw modes
900 (define_mode_attr dbpsadbwmode
901   [(V32HI "V64QI") (V16HI "V32QI") (V8HI "V16QI")])
903 ;; Mapping suffixes for broadcast
904 (define_mode_attr bcstscalarsuff
905   [(V64QI "b")  (V32QI "b") (V16QI "b")
906    (V32HI "w")  (V16HI "w") (V8HI "w")
907    (V16SI "d")  (V8SI "d")  (V4SI "d")
908    (V8DI "q")   (V4DI "q")  (V2DI "q")
909    (V16SF "ss") (V8SF "ss") (V4SF "ss")
910    (V8DF "sd")  (V4DF "sd") (V2DF "sd")])
912 ;; Tie mode of assembler operand to mode iterator
913 (define_mode_attr concat_tg_mode
914   [(V32QI "t") (V16HI "t") (V8SI "t") (V4DI "t") (V8SF "t") (V4DF "t")
915    (V64QI "g") (V32HI "g") (V16SI "g") (V8DI "g") (V16SF "g") (V8DF "g")])
917 ;; Tie mode of assembler operand to mode iterator
918 (define_mode_attr xtg_mode
919   [(V16QI "x") (V8HI "x") (V4SI "x") (V2DI "x") (V4SF "x") (V2DF "x")
920    (V32QI "t") (V16HI "t") (V8SI "t") (V4DI "t") (V8SF "t") (V4DF "t")
921    (V64QI "g") (V32HI "g") (V16SI "g") (V8DI "g") (V16SF "g") (V8DF "g")])
923 ;; Half mask mode for unpacks
924 (define_mode_attr HALFMASKMODE
925   [(DI "SI") (SI "HI")])
927 ;; Double mask mode for packs
928 (define_mode_attr DOUBLEMASKMODE
929   [(HI "SI") (SI "DI")])
932 ;; Include define_subst patterns for instructions with mask
933 (include "subst.md")
935 ;; Patterns whose name begins with "sse{,2,3}_" are invoked by intrinsics.
937 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
939 ;; Move patterns
941 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
943 ;; All of these patterns are enabled for SSE1 as well as SSE2.
944 ;; This is essential for maintaining stable calling conventions.
946 (define_expand "mov<mode>"
947   [(set (match_operand:VMOVE 0 "nonimmediate_operand")
948         (match_operand:VMOVE 1 "nonimmediate_operand"))]
949   "TARGET_SSE"
951   ix86_expand_vector_move (<MODE>mode, operands);
952   DONE;
955 (define_insn "mov<mode>_internal"
956   [(set (match_operand:VMOVE 0 "nonimmediate_operand"
957          "=v,v ,v ,m")
958         (match_operand:VMOVE 1 "nonimmediate_or_sse_const_operand"
959          " C,BC,vm,v"))]
960   "TARGET_SSE
961    && (register_operand (operands[0], <MODE>mode)
962        || register_operand (operands[1], <MODE>mode))"
964   switch (get_attr_type (insn))
965     {
966     case TYPE_SSELOG1:
967       return standard_sse_constant_opcode (insn, operands);
969     case TYPE_SSEMOV:
970       /* There is no evex-encoded vmov* for sizes smaller than 64-bytes
971          in avx512f, so we need to use workarounds, to access sse registers
972          16-31, which are evex-only. In avx512vl we don't need workarounds.  */
973       if (TARGET_AVX512F && <MODE_SIZE> < 64 && !TARGET_AVX512VL
974           && (EXT_REX_SSE_REG_P (operands[0])
975               || EXT_REX_SSE_REG_P (operands[1])))
976         {
977           if (memory_operand (operands[0], <MODE>mode))
978             {
979               if (<MODE_SIZE> == 32)
980                 return "vextract<shuffletype>64x4\t{$0x0, %g1, %0|%0, %g1, 0x0}";
981               else if (<MODE_SIZE> == 16)
982                 return "vextract<shuffletype>32x4\t{$0x0, %g1, %0|%0, %g1, 0x0}";
983               else
984                 gcc_unreachable ();
985             }
986           else if (memory_operand (operands[1], <MODE>mode))
987             {
988               if (<MODE_SIZE> == 32)
989                 return "vbroadcast<shuffletype>64x4\t{%1, %g0|%g0, %1}";
990               else if (<MODE_SIZE> == 16)
991                 return "vbroadcast<shuffletype>32x4\t{%1, %g0|%g0, %1}";
992               else
993                 gcc_unreachable ();
994             }
995           else
996             /* Reg -> reg move is always aligned.  Just use wider move.  */
997             switch (get_attr_mode (insn))
998               {
999               case MODE_V8SF:
1000               case MODE_V4SF:
1001                 return "vmovaps\t{%g1, %g0|%g0, %g1}";
1002               case MODE_V4DF:
1003               case MODE_V2DF:
1004                 return "vmovapd\t{%g1, %g0|%g0, %g1}";
1005               case MODE_OI:
1006               case MODE_TI:
1007                 return "vmovdqa64\t{%g1, %g0|%g0, %g1}";
1008               default:
1009                 gcc_unreachable ();
1010               }
1011         }
1013       switch (get_attr_mode (insn))
1014         {
1015         case MODE_V16SF:
1016         case MODE_V8SF:
1017         case MODE_V4SF:
1018           if (misaligned_operand (operands[0], <MODE>mode)
1019               || misaligned_operand (operands[1], <MODE>mode))
1020             return "%vmovups\t{%1, %0|%0, %1}";
1021           else
1022             return "%vmovaps\t{%1, %0|%0, %1}";
1024         case MODE_V8DF:
1025         case MODE_V4DF:
1026         case MODE_V2DF:
1027           if (misaligned_operand (operands[0], <MODE>mode)
1028               || misaligned_operand (operands[1], <MODE>mode))
1029             return "%vmovupd\t{%1, %0|%0, %1}";
1030           else
1031             return "%vmovapd\t{%1, %0|%0, %1}";
1033         case MODE_OI:
1034         case MODE_TI:
1035           if (misaligned_operand (operands[0], <MODE>mode)
1036               || misaligned_operand (operands[1], <MODE>mode))
1037             return TARGET_AVX512VL
1038                    && (<MODE>mode == V4SImode
1039                        || <MODE>mode == V2DImode
1040                        || <MODE>mode == V8SImode
1041                        || <MODE>mode == V4DImode
1042                        || TARGET_AVX512BW)
1043                    ? "vmovdqu<ssescalarsize>\t{%1, %0|%0, %1}"
1044                    : "%vmovdqu\t{%1, %0|%0, %1}";
1045           else
1046             return TARGET_AVX512VL ? "vmovdqa64\t{%1, %0|%0, %1}"
1047                                    : "%vmovdqa\t{%1, %0|%0, %1}";
1048         case MODE_XI:
1049           if (misaligned_operand (operands[0], <MODE>mode)
1050               || misaligned_operand (operands[1], <MODE>mode))
1051             return (<MODE>mode == V16SImode
1052                     || <MODE>mode == V8DImode
1053                     || TARGET_AVX512BW)
1054                    ? "vmovdqu<ssescalarsize>\t{%1, %0|%0, %1}"
1055                    : "vmovdqu64\t{%1, %0|%0, %1}";
1056           else
1057             return "vmovdqa64\t{%1, %0|%0, %1}";
1059         default:
1060           gcc_unreachable ();
1061         }
1063     default:
1064       gcc_unreachable ();
1065     }
1067   [(set_attr "type" "sselog1,sselog1,ssemov,ssemov")
1068    (set_attr "prefix" "maybe_vex")
1069    (set (attr "mode")
1070         (cond [(and (eq_attr "alternative" "1")
1071                     (match_test "TARGET_AVX512VL"))
1072                  (const_string "<sseinsnmode>")
1073                (and (match_test "<MODE_SIZE> == 16")
1074                     (ior (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
1075                          (and (eq_attr "alternative" "3")
1076                               (match_test "TARGET_SSE_TYPELESS_STORES"))))
1077                  (const_string "<ssePSmode>")
1078                (match_test "TARGET_AVX")
1079                  (const_string "<sseinsnmode>")
1080                (ior (not (match_test "TARGET_SSE2"))
1081                     (match_test "optimize_function_for_size_p (cfun)"))
1082                  (const_string "V4SF")
1083                (and (eq_attr "alternative" "0")
1084                     (match_test "TARGET_SSE_LOAD0_BY_PXOR"))
1085                  (const_string "TI")
1086               ]
1087               (const_string "<sseinsnmode>")))
1088    (set (attr "enabled")
1089         (cond [(and (match_test "<MODE_SIZE> == 16")
1090                     (eq_attr "alternative" "1"))
1091                  (symbol_ref "TARGET_SSE2")
1092                (and (match_test "<MODE_SIZE> == 32")
1093                     (eq_attr "alternative" "1"))
1094                  (symbol_ref "TARGET_AVX2")
1095               ]
1096               (symbol_ref "true")))])
1098 (define_insn "<avx512>_load<mode>_mask"
1099   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v,v")
1100         (vec_merge:V48_AVX512VL
1101           (match_operand:V48_AVX512VL 1 "nonimmediate_operand" "v,m")
1102           (match_operand:V48_AVX512VL 2 "vector_move_operand" "0C,0C")
1103           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
1104   "TARGET_AVX512F"
1106   if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
1107     {
1108       if (misaligned_operand (operands[1], <MODE>mode))
1109         return "vmovu<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1110       else
1111         return "vmova<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1112     }
1113   else
1114     {
1115       if (misaligned_operand (operands[1], <MODE>mode))
1116         return "vmovdqu<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1117       else
1118         return "vmovdqa<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
1119     }
1121   [(set_attr "type" "ssemov")
1122    (set_attr "prefix" "evex")
1123    (set_attr "memory" "none,load")
1124    (set_attr "mode" "<sseinsnmode>")])
1126 (define_insn "<avx512>_load<mode>_mask"
1127   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v,v")
1128         (vec_merge:VI12_AVX512VL
1129           (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "v,m")
1130           (match_operand:VI12_AVX512VL 2 "vector_move_operand" "0C,0C")
1131           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
1132   "TARGET_AVX512BW"
1133   "vmovdqu<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
1134   [(set_attr "type" "ssemov")
1135    (set_attr "prefix" "evex")
1136    (set_attr "memory" "none,load")
1137    (set_attr "mode" "<sseinsnmode>")])
1139 (define_insn "<avx512>_blendm<mode>"
1140   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v")
1141         (vec_merge:V48_AVX512VL
1142           (match_operand:V48_AVX512VL 2 "nonimmediate_operand" "vm")
1143           (match_operand:V48_AVX512VL 1 "register_operand" "v")
1144           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
1145   "TARGET_AVX512F"
1146   "v<sseintprefix>blendm<ssemodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}"
1147   [(set_attr "type" "ssemov")
1148    (set_attr "prefix" "evex")
1149    (set_attr "mode" "<sseinsnmode>")])
1151 (define_insn "<avx512>_blendm<mode>"
1152   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
1153         (vec_merge:VI12_AVX512VL
1154           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
1155           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
1156           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
1157   "TARGET_AVX512BW"
1158   "vpblendm<ssemodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}"
1159   [(set_attr "type" "ssemov")
1160    (set_attr "prefix" "evex")
1161    (set_attr "mode" "<sseinsnmode>")])
1163 (define_insn "<avx512>_store<mode>_mask"
1164   [(set (match_operand:V48_AVX512VL 0 "memory_operand" "=m")
1165         (vec_merge:V48_AVX512VL
1166           (match_operand:V48_AVX512VL 1 "register_operand" "v")
1167           (match_dup 0)
1168           (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1169   "TARGET_AVX512F"
1171   if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
1172     {
1173       if (misaligned_operand (operands[0], <MODE>mode))
1174         return "vmovu<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1175       else
1176         return "vmova<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1177     }
1178   else
1179     {
1180       if (misaligned_operand (operands[0], <MODE>mode))
1181         return "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1182       else
1183         return "vmovdqa<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1184     }
1186   [(set_attr "type" "ssemov")
1187    (set_attr "prefix" "evex")
1188    (set_attr "memory" "store")
1189    (set_attr "mode" "<sseinsnmode>")])
1191 (define_insn "<avx512>_store<mode>_mask"
1192   [(set (match_operand:VI12_AVX512VL 0 "memory_operand" "=m")
1193         (vec_merge:VI12_AVX512VL
1194           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
1195           (match_dup 0)
1196           (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1197   "TARGET_AVX512BW"
1198   "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
1199   [(set_attr "type" "ssemov")
1200    (set_attr "prefix" "evex")
1201    (set_attr "memory" "store")
1202    (set_attr "mode" "<sseinsnmode>")])
1204 (define_insn "sse2_movq128"
1205   [(set (match_operand:V2DI 0 "register_operand" "=v")
1206         (vec_concat:V2DI
1207           (vec_select:DI
1208             (match_operand:V2DI 1 "nonimmediate_operand" "vm")
1209             (parallel [(const_int 0)]))
1210           (const_int 0)))]
1211   "TARGET_SSE2"
1212   "%vmovq\t{%1, %0|%0, %q1}"
1213   [(set_attr "type" "ssemov")
1214    (set_attr "prefix" "maybe_vex")
1215    (set_attr "mode" "TI")])
1217 ;; Move a DI from a 32-bit register pair (e.g. %edx:%eax) to an xmm.
1218 ;; We'd rather avoid this entirely; if the 32-bit reg pair was loaded
1219 ;; from memory, we'd prefer to load the memory directly into the %xmm
1220 ;; register.  To facilitate this happy circumstance, this pattern won't
1221 ;; split until after register allocation.  If the 64-bit value didn't
1222 ;; come from memory, this is the best we can do.  This is much better
1223 ;; than storing %edx:%eax into a stack temporary and loading an %xmm
1224 ;; from there.
1226 (define_insn_and_split "movdi_to_sse"
1227   [(parallel
1228     [(set (match_operand:V4SI 0 "register_operand" "=?x,x")
1229           (subreg:V4SI (match_operand:DI 1 "nonimmediate_operand" "r,m") 0))
1230      (clobber (match_scratch:V4SI 2 "=&x,X"))])]
1231   "!TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_TO_VEC"
1232   "#"
1233   "&& reload_completed"
1234   [(const_int 0)]
1236  if (register_operand (operands[1], DImode))
1237    {
1238       /* The DImode arrived in a pair of integral registers (e.g. %edx:%eax).
1239          Assemble the 64-bit DImode value in an xmm register.  */
1240       emit_insn (gen_sse2_loadld (operands[0], CONST0_RTX (V4SImode),
1241                                   gen_lowpart (SImode, operands[1])));
1242       emit_insn (gen_sse2_loadld (operands[2], CONST0_RTX (V4SImode),
1243                                   gen_highpart (SImode, operands[1])));
1244       emit_insn (gen_vec_interleave_lowv4si (operands[0], operands[0],
1245                                              operands[2]));
1246    }
1247  else if (memory_operand (operands[1], DImode))
1248    {
1249      rtx tmp = gen_reg_rtx (V2DImode);
1250      emit_insn (gen_vec_concatv2di (tmp, operands[1], const0_rtx));
1251      emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp));
1252    }
1253  else
1254    gcc_unreachable ();
1255  DONE;
1258 (define_split
1259   [(set (match_operand:V4SF 0 "register_operand")
1260         (match_operand:V4SF 1 "zero_extended_scalar_load_operand"))]
1261   "TARGET_SSE && reload_completed"
1262   [(set (match_dup 0)
1263         (vec_merge:V4SF
1264           (vec_duplicate:V4SF (match_dup 1))
1265           (match_dup 2)
1266           (const_int 1)))]
1268   operands[1] = gen_lowpart (SFmode, operands[1]);
1269   operands[2] = CONST0_RTX (V4SFmode);
1272 (define_split
1273   [(set (match_operand:V2DF 0 "register_operand")
1274         (match_operand:V2DF 1 "zero_extended_scalar_load_operand"))]
1275   "TARGET_SSE2 && reload_completed"
1276   [(set (match_dup 0) (vec_concat:V2DF (match_dup 1) (match_dup 2)))]
1278   operands[1] = gen_lowpart (DFmode, operands[1]);
1279   operands[2] = CONST0_RTX (DFmode);
1282 (define_expand "movmisalign<mode>"
1283   [(set (match_operand:VMOVE 0 "nonimmediate_operand")
1284         (match_operand:VMOVE 1 "nonimmediate_operand"))]
1285   "TARGET_SSE"
1287   ix86_expand_vector_move_misalign (<MODE>mode, operands);
1288   DONE;
1291 ;; Merge movsd/movhpd to movupd for TARGET_SSE_UNALIGNED_LOAD_OPTIMAL targets.
1292 (define_peephole2
1293   [(set (match_operand:V2DF 0 "sse_reg_operand")
1294         (vec_concat:V2DF (match_operand:DF 1 "memory_operand")
1295                          (match_operand:DF 4 "const0_operand")))
1296    (set (match_operand:V2DF 2 "sse_reg_operand")
1297         (vec_concat:V2DF (vec_select:DF (match_dup 2)
1298                                         (parallel [(const_int 0)]))
1299                          (match_operand:DF 3 "memory_operand")))]
1300   "TARGET_SSE2 && TARGET_SSE_UNALIGNED_LOAD_OPTIMAL
1301    && ix86_operands_ok_for_move_multiple (operands, true, DFmode)"
1302   [(set (match_dup 2) (match_dup 5))]
1303   "operands[5] = adjust_address (operands[1], V2DFmode, 0);")
1305 (define_peephole2
1306   [(set (match_operand:DF 0 "sse_reg_operand")
1307         (match_operand:DF 1 "memory_operand"))
1308    (set (match_operand:V2DF 2 "sse_reg_operand")
1309         (vec_concat:V2DF (match_operand:DF 4 "sse_reg_operand")
1310                          (match_operand:DF 3 "memory_operand")))]
1311   "TARGET_SSE2 && TARGET_SSE_UNALIGNED_LOAD_OPTIMAL
1312    && REGNO (operands[4]) == REGNO (operands[2])
1313    && ix86_operands_ok_for_move_multiple (operands, true, DFmode)"
1314   [(set (match_dup 2) (match_dup 5))]
1315   "operands[5] = adjust_address (operands[1], V2DFmode, 0);")
1317 ;; Merge movlpd/movhpd to movupd for TARGET_SSE_UNALIGNED_STORE_OPTIMAL targets.
1318 (define_peephole2
1319   [(set (match_operand:DF 0 "memory_operand")
1320         (vec_select:DF (match_operand:V2DF 1 "sse_reg_operand")
1321                        (parallel [(const_int 0)])))
1322    (set (match_operand:DF 2 "memory_operand")
1323         (vec_select:DF (match_operand:V2DF 3 "sse_reg_operand")
1324                        (parallel [(const_int 1)])))]
1325   "TARGET_SSE2 && TARGET_SSE_UNALIGNED_STORE_OPTIMAL
1326    && ix86_operands_ok_for_move_multiple (operands, false, DFmode)"
1327   [(set (match_dup 4) (match_dup 1))]
1328   "operands[4] = adjust_address (operands[0], V2DFmode, 0);")
1330 (define_insn "<sse3>_lddqu<avxsizesuffix>"
1331   [(set (match_operand:VI1 0 "register_operand" "=x")
1332         (unspec:VI1 [(match_operand:VI1 1 "memory_operand" "m")]
1333                     UNSPEC_LDDQU))]
1334   "TARGET_SSE3"
1335   "%vlddqu\t{%1, %0|%0, %1}"
1336   [(set_attr "type" "ssemov")
1337    (set_attr "movu" "1")
1338    (set (attr "prefix_data16")
1339      (if_then_else
1340        (match_test "TARGET_AVX")
1341      (const_string "*")
1342      (const_string "0")))
1343    (set (attr "prefix_rep")
1344      (if_then_else
1345        (match_test "TARGET_AVX")
1346      (const_string "*")
1347      (const_string "1")))
1348    (set_attr "prefix" "maybe_vex")
1349    (set_attr "mode" "<sseinsnmode>")])
1351 (define_insn "sse2_movnti<mode>"
1352   [(set (match_operand:SWI48 0 "memory_operand" "=m")
1353         (unspec:SWI48 [(match_operand:SWI48 1 "register_operand" "r")]
1354                       UNSPEC_MOVNT))]
1355   "TARGET_SSE2"
1356   "movnti\t{%1, %0|%0, %1}"
1357   [(set_attr "type" "ssemov")
1358    (set_attr "prefix_data16" "0")
1359    (set_attr "mode" "<MODE>")])
1361 (define_insn "<sse>_movnt<mode>"
1362   [(set (match_operand:VF 0 "memory_operand" "=m")
1363         (unspec:VF
1364           [(match_operand:VF 1 "register_operand" "v")]
1365           UNSPEC_MOVNT))]
1366   "TARGET_SSE"
1367   "%vmovnt<ssemodesuffix>\t{%1, %0|%0, %1}"
1368   [(set_attr "type" "ssemov")
1369    (set_attr "prefix" "maybe_vex")
1370    (set_attr "mode" "<MODE>")])
1372 (define_insn "<sse2>_movnt<mode>"
1373   [(set (match_operand:VI8 0 "memory_operand" "=m")
1374         (unspec:VI8 [(match_operand:VI8 1 "register_operand" "v")]
1375                     UNSPEC_MOVNT))]
1376   "TARGET_SSE2"
1377   "%vmovntdq\t{%1, %0|%0, %1}"
1378   [(set_attr "type" "ssecvt")
1379    (set (attr "prefix_data16")
1380      (if_then_else
1381        (match_test "TARGET_AVX")
1382      (const_string "*")
1383      (const_string "1")))
1384    (set_attr "prefix" "maybe_vex")
1385    (set_attr "mode" "<sseinsnmode>")])
1387 ; Expand patterns for non-temporal stores.  At the moment, only those
1388 ; that directly map to insns are defined; it would be possible to
1389 ; define patterns for other modes that would expand to several insns.
1391 ;; Modes handled by storent patterns.
1392 (define_mode_iterator STORENT_MODE
1393   [(DI "TARGET_SSE2 && TARGET_64BIT") (SI "TARGET_SSE2")
1394    (SF "TARGET_SSE4A") (DF "TARGET_SSE4A")
1395    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") (V2DI "TARGET_SSE2")
1396    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
1397    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
1399 (define_expand "storent<mode>"
1400   [(set (match_operand:STORENT_MODE 0 "memory_operand")
1401         (unspec:STORENT_MODE
1402           [(match_operand:STORENT_MODE 1 "register_operand")]
1403           UNSPEC_MOVNT))]
1404   "TARGET_SSE")
1406 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1408 ;; Mask operations
1410 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1412 ;; All integer modes with AVX512BW/DQ.
1413 (define_mode_iterator SWI1248_AVX512BWDQ
1414   [(QI "TARGET_AVX512DQ") HI (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW")])
1416 ;; All integer modes with AVX512BW, where HImode operation
1417 ;; can be used instead of QImode.
1418 (define_mode_iterator SWI1248_AVX512BW
1419   [QI HI (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW")])
1421 ;; All integer modes with AVX512BW/DQ, even HImode requires DQ.
1422 (define_mode_iterator SWI1248_AVX512BWDQ2
1423   [(QI "TARGET_AVX512DQ") (HI "TARGET_AVX512DQ")
1424    (SI "TARGET_AVX512BW") (DI "TARGET_AVX512BW")])
1426 (define_expand "kmov<mskmodesuffix>"
1427   [(set (match_operand:SWI1248_AVX512BWDQ 0 "nonimmediate_operand")
1428         (match_operand:SWI1248_AVX512BWDQ 1 "nonimmediate_operand"))]
1429   "TARGET_AVX512F
1430    && !(MEM_P (operands[0]) && MEM_P (operands[1]))")
1432 (define_insn "k<code><mode>"
1433   [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
1434         (any_logic:SWI1248_AVX512BW
1435           (match_operand:SWI1248_AVX512BW 1 "register_operand" "k")
1436           (match_operand:SWI1248_AVX512BW 2 "register_operand" "k")))
1437    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1438   "TARGET_AVX512F"
1440   if (get_attr_mode (insn) == MODE_HI)
1441     return "k<logic>w\t{%2, %1, %0|%0, %1, %2}";
1442   else
1443     return "k<logic><mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
1445   [(set_attr "type" "msklog")
1446    (set_attr "prefix" "vex")
1447    (set (attr "mode")
1448      (cond [(and (match_test "<MODE>mode == QImode")
1449                  (not (match_test "TARGET_AVX512DQ")))
1450                (const_string "HI")
1451            ]
1452            (const_string "<MODE>")))])
1454 (define_insn "kandn<mode>"
1455   [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
1456         (and:SWI1248_AVX512BW
1457           (not:SWI1248_AVX512BW
1458             (match_operand:SWI1248_AVX512BW 1 "register_operand" "k"))
1459           (match_operand:SWI1248_AVX512BW 2 "register_operand" "k")))
1460    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1461   "TARGET_AVX512F"
1463   if (get_attr_mode (insn) == MODE_HI)
1464     return "kandnw\t{%2, %1, %0|%0, %1, %2}";
1465   else
1466     return "kandn<mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
1468   [(set_attr "type" "msklog")
1469    (set_attr "prefix" "vex")
1470    (set (attr "mode")
1471      (cond [(and (match_test "<MODE>mode == QImode")
1472                  (not (match_test "TARGET_AVX512DQ")))
1473               (const_string "HI")
1474            ]
1475            (const_string "<MODE>")))])
1477 (define_insn "kxnor<mode>"
1478   [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
1479         (not:SWI1248_AVX512BW
1480           (xor:SWI1248_AVX512BW
1481             (match_operand:SWI1248_AVX512BW 1 "register_operand" "k")
1482             (match_operand:SWI1248_AVX512BW 2 "register_operand" "k"))))
1483    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1484   "TARGET_AVX512F"
1486   if (get_attr_mode (insn) == MODE_HI)
1487     return "kxnorw\t{%2, %1, %0|%0, %1, %2}";
1488   else
1489     return "kxnor<mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
1491   [(set_attr "type" "msklog")
1492    (set_attr "prefix" "vex")
1493    (set (attr "mode")
1494      (cond [(and (match_test "<MODE>mode == QImode")
1495                  (not (match_test "TARGET_AVX512DQ")))
1496               (const_string "HI")
1497            ]
1498            (const_string "<MODE>")))])
1500 (define_insn "knot<mode>"
1501   [(set (match_operand:SWI1248_AVX512BW 0 "register_operand" "=k")
1502         (not:SWI1248_AVX512BW
1503           (match_operand:SWI1248_AVX512BW 1 "register_operand" "k")))
1504    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1505   "TARGET_AVX512F"
1507   if (get_attr_mode (insn) == MODE_HI)
1508     return "knotw\t{%1, %0|%0, %1}";
1509   else
1510     return "knot<mskmodesuffix>\t{%1, %0|%0, %1}";
1512   [(set_attr "type" "msklog")
1513    (set_attr "prefix" "vex")
1514    (set (attr "mode")
1515      (cond [(and (match_test "<MODE>mode == QImode")
1516                  (not (match_test "TARGET_AVX512DQ")))
1517                (const_string "HI")
1518            ]
1519            (const_string "<MODE>")))])
1521 (define_insn "kadd<mode>"
1522   [(set (match_operand:SWI1248_AVX512BWDQ2 0 "register_operand" "=k")
1523         (plus:SWI1248_AVX512BWDQ2
1524           (match_operand:SWI1248_AVX512BWDQ2 1 "register_operand" "k")
1525           (match_operand:SWI1248_AVX512BWDQ2 2 "register_operand" "k")))
1526    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1527   "TARGET_AVX512F"
1528   "kadd<mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}"
1529   [(set_attr "type" "msklog")
1530    (set_attr "prefix" "vex")
1531    (set_attr "mode" "<MODE>")])
1533 ;; Mask variant shift mnemonics
1534 (define_code_attr mshift [(ashift "shiftl") (lshiftrt "shiftr")])
1536 (define_insn "k<code><mode>"
1537   [(set (match_operand:SWI1248_AVX512BWDQ 0 "register_operand" "=k")
1538         (any_lshift:SWI1248_AVX512BWDQ
1539           (match_operand:SWI1248_AVX512BWDQ 1 "register_operand" "k")
1540           (match_operand:QI 2 "immediate_operand" "n")))
1541    (unspec [(const_int 0)] UNSPEC_MASKOP)]
1542   "TARGET_AVX512F"
1543   "k<mshift><mskmodesuffix>\t{%2, %1, %0|%0, %1, %2}"
1544   [(set_attr "type" "msklog")
1545    (set_attr "prefix" "vex")
1546    (set_attr "mode" "<MODE>")])
1548 (define_insn "ktest<mode>"
1549   [(set (reg:CC FLAGS_REG)
1550         (unspec:CC
1551           [(match_operand:SWI1248_AVX512BWDQ2 0 "register_operand" "k")
1552            (match_operand:SWI1248_AVX512BWDQ2 1 "register_operand" "k")]
1553           UNSPEC_KTEST))]
1554   "TARGET_AVX512F"
1555   "ktest<mskmodesuffix>\t{%1, %0|%0, %1}"
1556   [(set_attr "mode" "<MODE>")
1557    (set_attr "type" "msklog")
1558    (set_attr "prefix" "vex")])
1560 (define_insn "kortest<mode>"
1561   [(set (reg:CC FLAGS_REG)
1562         (unspec:CC
1563           [(match_operand:SWI1248_AVX512BWDQ 0 "register_operand" "k")
1564            (match_operand:SWI1248_AVX512BWDQ 1 "register_operand" "k")]
1565           UNSPEC_KORTEST))]
1566   "TARGET_AVX512F"
1567   "kortest<mskmodesuffix>\t{%1, %0|%0, %1}"
1568   [(set_attr "mode" "<MODE>")
1569    (set_attr "type" "msklog")
1570    (set_attr "prefix" "vex")])
1572 (define_insn "kunpckhi"
1573   [(set (match_operand:HI 0 "register_operand" "=k")
1574         (ior:HI
1575           (ashift:HI
1576             (zero_extend:HI (match_operand:QI 1 "register_operand" "k"))
1577             (const_int 8))
1578           (zero_extend:HI (match_operand:QI 2 "register_operand" "k"))))]
1579   "TARGET_AVX512F"
1580   "kunpckbw\t{%2, %1, %0|%0, %1, %2}"
1581   [(set_attr "mode" "HI")
1582    (set_attr "type" "msklog")
1583    (set_attr "prefix" "vex")])
1585 (define_insn "kunpcksi"
1586   [(set (match_operand:SI 0 "register_operand" "=k")
1587         (ior:SI
1588           (ashift:SI
1589             (zero_extend:SI (match_operand:HI 1 "register_operand" "k"))
1590             (const_int 16))
1591           (zero_extend:SI (match_operand:HI 2 "register_operand" "k"))))]
1592   "TARGET_AVX512BW"
1593   "kunpckwd\t{%2, %1, %0|%0, %1, %2}"
1594   [(set_attr "mode" "SI")])
1596 (define_insn "kunpckdi"
1597   [(set (match_operand:DI 0 "register_operand" "=k")
1598         (ior:DI
1599           (ashift:DI
1600             (zero_extend:DI (match_operand:SI 1 "register_operand" "k"))
1601             (const_int 32))
1602           (zero_extend:DI (match_operand:SI 2 "register_operand" "k"))))]
1603   "TARGET_AVX512BW"
1604   "kunpckdq\t{%2, %1, %0|%0, %1, %2}"
1605   [(set_attr "mode" "DI")])
1608 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1610 ;; Parallel floating point arithmetic
1612 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1614 (define_expand "<code><mode>2"
1615   [(set (match_operand:VF 0 "register_operand")
1616         (absneg:VF
1617           (match_operand:VF 1 "register_operand")))]
1618   "TARGET_SSE"
1619   "ix86_expand_fp_absneg_operator (<CODE>, <MODE>mode, operands); DONE;")
1621 (define_insn_and_split "*absneg<mode>2"
1622   [(set (match_operand:VF 0 "register_operand" "=x,x,v,v")
1623         (match_operator:VF 3 "absneg_operator"
1624           [(match_operand:VF 1 "vector_operand" "0,  xBm,v, m")]))
1625    (use (match_operand:VF 2 "vector_operand"    "xBm,0,  vm,v"))]
1626   "TARGET_SSE"
1627   "#"
1628   "&& reload_completed"
1629   [(const_int 0)]
1631   enum rtx_code absneg_op;
1632   rtx op1, op2;
1633   rtx t;
1635   if (TARGET_AVX)
1636     {
1637       if (MEM_P (operands[1]))
1638         op1 = operands[2], op2 = operands[1];
1639       else
1640         op1 = operands[1], op2 = operands[2];
1641     }
1642   else
1643     {
1644       op1 = operands[0];
1645       if (rtx_equal_p (operands[0], operands[1]))
1646         op2 = operands[2];
1647       else
1648         op2 = operands[1];
1649     }
1651   absneg_op = GET_CODE (operands[3]) == NEG ? XOR : AND;
1652   t = gen_rtx_fmt_ee (absneg_op, <MODE>mode, op1, op2);
1653   t = gen_rtx_SET (operands[0], t);
1654   emit_insn (t);
1655   DONE;
1657   [(set_attr "isa" "noavx,noavx,avx,avx")])
1659 (define_expand "<plusminus_insn><mode>3<mask_name><round_name>"
1660   [(set (match_operand:VF 0 "register_operand")
1661         (plusminus:VF
1662           (match_operand:VF 1 "<round_nimm_predicate>")
1663           (match_operand:VF 2 "<round_nimm_predicate>")))]
1664   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1665   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
1667 (define_insn "*<plusminus_insn><mode>3<mask_name><round_name>"
1668   [(set (match_operand:VF 0 "register_operand" "=x,v")
1669         (plusminus:VF
1670           (match_operand:VF 1 "<round_nimm_predicate>" "<comm>0,v")
1671           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1672   "TARGET_SSE && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)
1673    && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1674   "@
1675    <plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
1676    v<plusminus_mnemonic><ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1677   [(set_attr "isa" "noavx,avx")
1678    (set_attr "type" "sseadd")
1679    (set_attr "prefix" "<mask_prefix3>")
1680    (set_attr "mode" "<MODE>")])
1682 (define_insn "<sse>_vm<plusminus_insn><mode>3<mask_scalar_name><round_scalar_name>"
1683   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1684         (vec_merge:VF_128
1685           (plusminus:VF_128
1686             (match_operand:VF_128 1 "register_operand" "0,v")
1687             (match_operand:VF_128 2 "vector_operand" "xBm,<round_scalar_constraint>"))
1688           (match_dup 1)
1689           (const_int 1)))]
1690   "TARGET_SSE"
1691   "@
1692    <plusminus_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
1693    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>}"
1694   [(set_attr "isa" "noavx,avx")
1695    (set_attr "type" "sseadd")
1696    (set_attr "prefix" "<round_scalar_prefix>")
1697    (set_attr "mode" "<ssescalarmode>")])
1699 (define_expand "mul<mode>3<mask_name><round_name>"
1700   [(set (match_operand:VF 0 "register_operand")
1701         (mult:VF
1702           (match_operand:VF 1 "<round_nimm_predicate>")
1703           (match_operand:VF 2 "<round_nimm_predicate>")))]
1704   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1705   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
1707 (define_insn "*mul<mode>3<mask_name><round_name>"
1708   [(set (match_operand:VF 0 "register_operand" "=x,v")
1709         (mult:VF
1710           (match_operand:VF 1 "<round_nimm_predicate>" "%0,v")
1711           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1712   "TARGET_SSE
1713    && !(MEM_P (operands[1]) && MEM_P (operands[2]))
1714    && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1715   "@
1716    mul<ssemodesuffix>\t{%2, %0|%0, %2}
1717    vmul<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1718   [(set_attr "isa" "noavx,avx")
1719    (set_attr "type" "ssemul")
1720    (set_attr "prefix" "<mask_prefix3>")
1721    (set_attr "btver2_decode" "direct,double")
1722    (set_attr "mode" "<MODE>")])
1724 (define_insn "<sse>_vm<multdiv_mnemonic><mode>3<mask_scalar_name><round_scalar_name>"
1725   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1726         (vec_merge:VF_128
1727           (multdiv:VF_128
1728             (match_operand:VF_128 1 "register_operand" "0,v")
1729             (match_operand:VF_128 2 "vector_operand" "xBm,<round_scalar_constraint>"))
1730           (match_dup 1)
1731           (const_int 1)))]
1732   "TARGET_SSE"
1733   "@
1734    <multdiv_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
1735    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>}"
1736   [(set_attr "isa" "noavx,avx")
1737    (set_attr "type" "sse<multdiv_mnemonic>")
1738    (set_attr "prefix" "<round_scalar_prefix>")
1739    (set_attr "btver2_decode" "direct,double")
1740    (set_attr "mode" "<ssescalarmode>")])
1742 (define_expand "div<mode>3"
1743   [(set (match_operand:VF2 0 "register_operand")
1744         (div:VF2 (match_operand:VF2 1 "register_operand")
1745                  (match_operand:VF2 2 "vector_operand")))]
1746   "TARGET_SSE2"
1747   "ix86_fixup_binary_operands_no_copy (DIV, <MODE>mode, operands);")
1749 (define_expand "div<mode>3"
1750   [(set (match_operand:VF1 0 "register_operand")
1751         (div:VF1 (match_operand:VF1 1 "register_operand")
1752                  (match_operand:VF1 2 "vector_operand")))]
1753   "TARGET_SSE"
1755   ix86_fixup_binary_operands_no_copy (DIV, <MODE>mode, operands);
1757   if (TARGET_SSE_MATH
1758       && TARGET_RECIP_VEC_DIV
1759       && !optimize_insn_for_size_p ()
1760       && flag_finite_math_only && !flag_trapping_math
1761       && flag_unsafe_math_optimizations)
1762     {
1763       ix86_emit_swdivsf (operands[0], operands[1], operands[2], <MODE>mode);
1764       DONE;
1765     }
1768 (define_insn "<sse>_div<mode>3<mask_name><round_name>"
1769   [(set (match_operand:VF 0 "register_operand" "=x,v")
1770         (div:VF
1771           (match_operand:VF 1 "register_operand" "0,v")
1772           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1773   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1774   "@
1775    div<ssemodesuffix>\t{%2, %0|%0, %2}
1776    vdiv<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1777   [(set_attr "isa" "noavx,avx")
1778    (set_attr "type" "ssediv")
1779    (set_attr "prefix" "<mask_prefix3>")
1780    (set_attr "mode" "<MODE>")])
1782 (define_insn "<sse>_rcp<mode>2"
1783   [(set (match_operand:VF1_128_256 0 "register_operand" "=x")
1784         (unspec:VF1_128_256
1785           [(match_operand:VF1_128_256 1 "vector_operand" "xBm")] UNSPEC_RCP))]
1786   "TARGET_SSE"
1787   "%vrcpps\t{%1, %0|%0, %1}"
1788   [(set_attr "type" "sse")
1789    (set_attr "atom_sse_attr" "rcp")
1790    (set_attr "btver2_sse_attr" "rcp")
1791    (set_attr "prefix" "maybe_vex")
1792    (set_attr "mode" "<MODE>")])
1794 (define_insn "sse_vmrcpv4sf2"
1795   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
1796         (vec_merge:V4SF
1797           (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,xm")]
1798                        UNSPEC_RCP)
1799           (match_operand:V4SF 2 "register_operand" "0,x")
1800           (const_int 1)))]
1801   "TARGET_SSE"
1802   "@
1803    rcpss\t{%1, %0|%0, %k1}
1804    vrcpss\t{%1, %2, %0|%0, %2, %k1}"
1805   [(set_attr "isa" "noavx,avx")
1806    (set_attr "type" "sse")
1807    (set_attr "atom_sse_attr" "rcp")
1808    (set_attr "btver2_sse_attr" "rcp")
1809    (set_attr "prefix" "orig,vex")
1810    (set_attr "mode" "SF")])
1812 (define_insn "<mask_codefor>rcp14<mode><mask_name>"
1813   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
1814         (unspec:VF_AVX512VL
1815           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")]
1816           UNSPEC_RCP14))]
1817   "TARGET_AVX512F"
1818   "vrcp14<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
1819   [(set_attr "type" "sse")
1820    (set_attr "prefix" "evex")
1821    (set_attr "mode" "<MODE>")])
1823 (define_insn "srcp14<mode>"
1824   [(set (match_operand:VF_128 0 "register_operand" "=v")
1825         (vec_merge:VF_128
1826           (unspec:VF_128
1827             [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1828             UNSPEC_RCP14)
1829           (match_operand:VF_128 2 "register_operand" "v")
1830           (const_int 1)))]
1831   "TARGET_AVX512F"
1832   "vrcp14<ssescalarmodesuffix>\t{%1, %2, %0|%0, %2, %<iptr>1}"
1833   [(set_attr "type" "sse")
1834    (set_attr "prefix" "evex")
1835    (set_attr "mode" "<MODE>")])
1837 (define_insn "srcp14<mode>_mask"
1838   [(set (match_operand:VF_128 0 "register_operand" "=v")
1839         (vec_merge:VF_128
1840           (vec_merge:VF_128
1841             (unspec:VF_128
1842               [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1843             UNSPEC_RCP14)
1844               (match_operand:VF_128 3 "vector_move_operand" "0C")
1845             (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk"))
1846           (match_operand:VF_128 2 "register_operand" "v")
1847           (const_int 1)))]
1848   "TARGET_AVX512F"
1849   "vrcp14<ssescalarmodesuffix>\t{%1, %2, %0%{%4%}%N3|%0%{%4%}%N3, %2, %<iptr>1}"
1850   [(set_attr "type" "sse")
1851    (set_attr "prefix" "evex")
1852    (set_attr "mode" "<MODE>")])
1854 (define_expand "sqrt<mode>2"
1855   [(set (match_operand:VF2 0 "register_operand")
1856         (sqrt:VF2 (match_operand:VF2 1 "vector_operand")))]
1857   "TARGET_SSE2")
1859 (define_expand "sqrt<mode>2"
1860   [(set (match_operand:VF1 0 "register_operand")
1861         (sqrt:VF1 (match_operand:VF1 1 "vector_operand")))]
1862   "TARGET_SSE"
1864   if (TARGET_SSE_MATH
1865       && TARGET_RECIP_VEC_SQRT
1866       && !optimize_insn_for_size_p ()
1867       && flag_finite_math_only && !flag_trapping_math
1868       && flag_unsafe_math_optimizations)
1869     {
1870       ix86_emit_swsqrtsf (operands[0], operands[1], <MODE>mode, false);
1871       DONE;
1872     }
1875 (define_insn "<sse>_sqrt<mode>2<mask_name><round_name>"
1876   [(set (match_operand:VF 0 "register_operand" "=x,v")
1877         (sqrt:VF (match_operand:VF 1 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1878   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1879   "@
1880    sqrt<ssemodesuffix>\t{%1, %0|%0, %1}
1881    vsqrt<ssemodesuffix>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
1882   [(set_attr "isa" "noavx,avx")
1883    (set_attr "type" "sse")
1884    (set_attr "atom_sse_attr" "sqrt")
1885    (set_attr "btver2_sse_attr" "sqrt")
1886    (set_attr "prefix" "maybe_vex")
1887    (set_attr "mode" "<MODE>")])
1889 (define_insn "<sse>_vmsqrt<mode>2<mask_scalar_name><round_scalar_name>"
1890   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1891         (vec_merge:VF_128
1892           (sqrt:VF_128
1893             (match_operand:VF_128 1 "vector_operand" "xBm,<round_scalar_constraint>"))
1894           (match_operand:VF_128 2 "register_operand" "0,v")
1895           (const_int 1)))]
1896   "TARGET_SSE"
1897   "@
1898    sqrt<ssescalarmodesuffix>\t{%1, %0|%0, %<iptr>1}
1899    vsqrt<ssescalarmodesuffix>\t{<round_scalar_mask_op3>%1, %2, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %2, %<iptr>1<round_scalar_mask_op3>}"
1900   [(set_attr "isa" "noavx,avx")
1901    (set_attr "type" "sse")
1902    (set_attr "atom_sse_attr" "sqrt")
1903    (set_attr "prefix" "<round_scalar_prefix>")
1904    (set_attr "btver2_sse_attr" "sqrt")
1905    (set_attr "mode" "<ssescalarmode>")])
1907 (define_expand "rsqrt<mode>2"
1908   [(set (match_operand:VF1_128_256 0 "register_operand")
1909         (unspec:VF1_128_256
1910           [(match_operand:VF1_128_256 1 "vector_operand")] UNSPEC_RSQRT))]
1911   "TARGET_SSE_MATH"
1913   ix86_emit_swsqrtsf (operands[0], operands[1], <MODE>mode, true);
1914   DONE;
1917 (define_expand "rsqrtv16sf2"
1918   [(set (match_operand:V16SF 0 "register_operand")
1919         (unspec:V16SF
1920           [(match_operand:V16SF 1 "vector_operand")]
1921           UNSPEC_RSQRT28))]
1922   "TARGET_SSE_MATH && TARGET_AVX512ER"
1924   ix86_emit_swsqrtsf (operands[0], operands[1], V16SFmode, true);
1925   DONE;
1928 (define_insn "<sse>_rsqrt<mode>2"
1929   [(set (match_operand:VF1_128_256 0 "register_operand" "=x")
1930         (unspec:VF1_128_256
1931           [(match_operand:VF1_128_256 1 "vector_operand" "xBm")] UNSPEC_RSQRT))]
1932   "TARGET_SSE"
1933   "%vrsqrtps\t{%1, %0|%0, %1}"
1934   [(set_attr "type" "sse")
1935    (set_attr "prefix" "maybe_vex")
1936    (set_attr "mode" "<MODE>")])
1938 (define_insn "<mask_codefor>rsqrt14<mode><mask_name>"
1939   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
1940         (unspec:VF_AVX512VL
1941           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")]
1942           UNSPEC_RSQRT14))]
1943   "TARGET_AVX512F"
1944   "vrsqrt14<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
1945   [(set_attr "type" "sse")
1946    (set_attr "prefix" "evex")
1947    (set_attr "mode" "<MODE>")])
1949 (define_insn "rsqrt14<mode>"
1950   [(set (match_operand:VF_128 0 "register_operand" "=v")
1951         (vec_merge:VF_128
1952           (unspec:VF_128
1953             [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1954             UNSPEC_RSQRT14)
1955           (match_operand:VF_128 2 "register_operand" "v")
1956           (const_int 1)))]
1957   "TARGET_AVX512F"
1958   "vrsqrt14<ssescalarmodesuffix>\t{%1, %2, %0|%0, %2, %<iptr>1}"
1959   [(set_attr "type" "sse")
1960    (set_attr "prefix" "evex")
1961    (set_attr "mode" "<MODE>")])
1963 (define_insn "rsqrt14_<mode>_mask"
1964   [(set (match_operand:VF_128 0 "register_operand" "=v")
1965         (vec_merge:VF_128
1966           (vec_merge:VF_128
1967             (unspec:VF_128
1968               [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1969               UNSPEC_RSQRT14)
1970               (match_operand:VF_128 3 "vector_move_operand" "0C")
1971               (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk"))
1972           (match_operand:VF_128 2 "register_operand" "v")
1973           (const_int 1)))]
1974   "TARGET_AVX512F"
1975   "vrsqrt14<ssescalarmodesuffix>\t{%1, %2, %0%{%4%}%N3|%0%{%4%}%N3, %2, %<iptr>1}"
1976   [(set_attr "type" "sse")
1977    (set_attr "prefix" "evex")
1978    (set_attr "mode" "<MODE>")])
1980 (define_insn "sse_vmrsqrtv4sf2"
1981   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
1982         (vec_merge:V4SF
1983           (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,xm")]
1984                        UNSPEC_RSQRT)
1985           (match_operand:V4SF 2 "register_operand" "0,x")
1986           (const_int 1)))]
1987   "TARGET_SSE"
1988   "@
1989    rsqrtss\t{%1, %0|%0, %k1}
1990    vrsqrtss\t{%1, %2, %0|%0, %2, %k1}"
1991   [(set_attr "isa" "noavx,avx")
1992    (set_attr "type" "sse")
1993    (set_attr "prefix" "orig,vex")
1994    (set_attr "mode" "SF")])
1996 (define_expand "<code><mode>3<mask_name><round_saeonly_name>"
1997   [(set (match_operand:VF 0 "register_operand")
1998         (smaxmin:VF
1999           (match_operand:VF 1 "<round_saeonly_nimm_predicate>")
2000           (match_operand:VF 2 "<round_saeonly_nimm_predicate>")))]
2001   "TARGET_SSE && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
2003   if (!flag_finite_math_only || flag_signed_zeros)
2004     {
2005       operands[1] = force_reg (<MODE>mode, operands[1]);
2006       emit_insn (gen_ieee_<maxmin_float><mode>3<mask_name><round_saeonly_name>
2007                  (operands[0], operands[1], operands[2]
2008                   <mask_operand_arg34>
2009                   <round_saeonly_mask_arg3>));
2010       DONE;
2011     }
2012   else
2013     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
2016 ;; These versions of the min/max patterns are intentionally ignorant of
2017 ;; their behavior wrt -0.0 and NaN (via the commutative operand mark).
2018 ;; Since both the tree-level MAX_EXPR and the rtl-level SMAX operator
2019 ;; are undefined in this condition, we're certain this is correct.
2021 (define_insn "*<code><mode>3<mask_name><round_saeonly_name>"
2022   [(set (match_operand:VF 0 "register_operand" "=x,v")
2023         (smaxmin:VF
2024           (match_operand:VF 1 "<round_saeonly_nimm_predicate>" "%0,v")
2025           (match_operand:VF 2 "<round_saeonly_nimm_predicate>" "xBm,<round_saeonly_constraint>")))]
2026   "TARGET_SSE
2027    && !(MEM_P (operands[1]) && MEM_P (operands[2]))
2028    && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
2029   "@
2030    <maxmin_float><ssemodesuffix>\t{%2, %0|%0, %2}
2031    v<maxmin_float><ssemodesuffix>\t{<round_saeonly_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_saeonly_mask_op3>}"
2032   [(set_attr "isa" "noavx,avx")
2033    (set_attr "type" "sseadd")
2034    (set_attr "btver2_sse_attr" "maxmin")
2035    (set_attr "prefix" "<mask_prefix3>")
2036    (set_attr "mode" "<MODE>")])
2038 ;; These versions of the min/max patterns implement exactly the operations
2039 ;;   min = (op1 < op2 ? op1 : op2)
2040 ;;   max = (!(op1 < op2) ? op1 : op2)
2041 ;; Their operands are not commutative, and thus they may be used in the
2042 ;; presence of -0.0 and NaN.
2044 (define_insn "ieee_<ieee_maxmin><mode>3<mask_name><round_saeonly_name>"
2045   [(set (match_operand:VF 0 "register_operand" "=x,v")
2046         (unspec:VF
2047           [(match_operand:VF 1 "register_operand" "0,v")
2048            (match_operand:VF 2 "<round_saeonly_nimm_predicate>" "xBm,<round_saeonly_constraint>")]
2049           IEEE_MAXMIN))]
2050   "TARGET_SSE
2051    && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
2052   "@
2053    <ieee_maxmin><ssemodesuffix>\t{%2, %0|%0, %2}
2054    v<ieee_maxmin><ssemodesuffix>\t{<round_saeonly_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_saeonly_mask_op3>}"
2055   [(set_attr "isa" "noavx,avx")
2056    (set_attr "type" "sseadd")
2057    (set_attr "btver2_sse_attr" "maxmin")
2058    (set_attr "prefix" "<mask_prefix3>")
2059    (set_attr "mode" "<MODE>")])
2061 (define_insn "<sse>_vm<code><mode>3<mask_scalar_name><round_saeonly_scalar_name>"
2062   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
2063         (vec_merge:VF_128
2064           (smaxmin:VF_128
2065             (match_operand:VF_128 1 "register_operand" "0,v")
2066             (match_operand:VF_128 2 "vector_operand" "xBm,<round_saeonly_scalar_constraint>"))
2067          (match_dup 1)
2068          (const_int 1)))]
2069   "TARGET_SSE"
2070   "@
2071    <maxmin_float><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
2072    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>}"
2073   [(set_attr "isa" "noavx,avx")
2074    (set_attr "type" "sse")
2075    (set_attr "btver2_sse_attr" "maxmin")
2076    (set_attr "prefix" "<round_saeonly_scalar_prefix>")
2077    (set_attr "mode" "<ssescalarmode>")])
2079 (define_insn "avx_addsubv4df3"
2080   [(set (match_operand:V4DF 0 "register_operand" "=x")
2081         (vec_merge:V4DF
2082           (minus:V4DF
2083             (match_operand:V4DF 1 "register_operand" "x")
2084             (match_operand:V4DF 2 "nonimmediate_operand" "xm"))
2085           (plus:V4DF (match_dup 1) (match_dup 2))
2086           (const_int 5)))]
2087   "TARGET_AVX"
2088   "vaddsubpd\t{%2, %1, %0|%0, %1, %2}"
2089   [(set_attr "type" "sseadd")
2090    (set_attr "prefix" "vex")
2091    (set_attr "mode" "V4DF")])
2093 (define_insn "sse3_addsubv2df3"
2094   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
2095         (vec_merge:V2DF
2096           (minus:V2DF
2097             (match_operand:V2DF 1 "register_operand" "0,x")
2098             (match_operand:V2DF 2 "vector_operand" "xBm,xm"))
2099           (plus:V2DF (match_dup 1) (match_dup 2))
2100           (const_int 1)))]
2101   "TARGET_SSE3"
2102   "@
2103    addsubpd\t{%2, %0|%0, %2}
2104    vaddsubpd\t{%2, %1, %0|%0, %1, %2}"
2105   [(set_attr "isa" "noavx,avx")
2106    (set_attr "type" "sseadd")
2107    (set_attr "atom_unit" "complex")
2108    (set_attr "prefix" "orig,vex")
2109    (set_attr "mode" "V2DF")])
2111 (define_insn "avx_addsubv8sf3"
2112   [(set (match_operand:V8SF 0 "register_operand" "=x")
2113         (vec_merge:V8SF
2114           (minus:V8SF
2115             (match_operand:V8SF 1 "register_operand" "x")
2116             (match_operand:V8SF 2 "nonimmediate_operand" "xm"))
2117           (plus:V8SF (match_dup 1) (match_dup 2))
2118           (const_int 85)))]
2119   "TARGET_AVX"
2120   "vaddsubps\t{%2, %1, %0|%0, %1, %2}"
2121   [(set_attr "type" "sseadd")
2122    (set_attr "prefix" "vex")
2123    (set_attr "mode" "V8SF")])
2125 (define_insn "sse3_addsubv4sf3"
2126   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
2127         (vec_merge:V4SF
2128           (minus:V4SF
2129             (match_operand:V4SF 1 "register_operand" "0,x")
2130             (match_operand:V4SF 2 "vector_operand" "xBm,xm"))
2131           (plus:V4SF (match_dup 1) (match_dup 2))
2132           (const_int 5)))]
2133   "TARGET_SSE3"
2134   "@
2135    addsubps\t{%2, %0|%0, %2}
2136    vaddsubps\t{%2, %1, %0|%0, %1, %2}"
2137   [(set_attr "isa" "noavx,avx")
2138    (set_attr "type" "sseadd")
2139    (set_attr "prefix" "orig,vex")
2140    (set_attr "prefix_rep" "1,*")
2141    (set_attr "mode" "V4SF")])
2143 (define_split
2144   [(set (match_operand:VF_128_256 0 "register_operand")
2145         (match_operator:VF_128_256 6 "addsub_vm_operator"
2146           [(minus:VF_128_256
2147              (match_operand:VF_128_256 1 "register_operand")
2148              (match_operand:VF_128_256 2 "vector_operand"))
2149            (plus:VF_128_256
2150              (match_operand:VF_128_256 3 "vector_operand")
2151              (match_operand:VF_128_256 4 "vector_operand"))
2152            (match_operand 5 "const_int_operand")]))]
2153   "TARGET_SSE3
2154    && can_create_pseudo_p ()
2155    && ((rtx_equal_p (operands[1], operands[3])
2156         && rtx_equal_p (operands[2], operands[4]))
2157        || (rtx_equal_p (operands[1], operands[4])
2158            && rtx_equal_p (operands[2], operands[3])))"
2159   [(set (match_dup 0)
2160         (vec_merge:VF_128_256
2161           (minus:VF_128_256 (match_dup 1) (match_dup 2))
2162           (plus:VF_128_256 (match_dup 1) (match_dup 2))
2163           (match_dup 5)))])
2165 (define_split
2166   [(set (match_operand:VF_128_256 0 "register_operand")
2167         (match_operator:VF_128_256 6 "addsub_vm_operator"
2168           [(plus:VF_128_256
2169              (match_operand:VF_128_256 1 "vector_operand")
2170              (match_operand:VF_128_256 2 "vector_operand"))
2171            (minus:VF_128_256
2172              (match_operand:VF_128_256 3 "register_operand")
2173              (match_operand:VF_128_256 4 "vector_operand"))
2174            (match_operand 5 "const_int_operand")]))]
2175   "TARGET_SSE3
2176    && can_create_pseudo_p ()
2177    && ((rtx_equal_p (operands[1], operands[3])
2178         && rtx_equal_p (operands[2], operands[4]))
2179        || (rtx_equal_p (operands[1], operands[4])
2180            && rtx_equal_p (operands[2], operands[3])))"
2181   [(set (match_dup 0)
2182         (vec_merge:VF_128_256
2183           (minus:VF_128_256 (match_dup 3) (match_dup 4))
2184           (plus:VF_128_256 (match_dup 3) (match_dup 4))
2185           (match_dup 5)))]
2187   /* Negate mask bits to compensate for swapped PLUS and MINUS RTXes.  */
2188   operands[5]
2189     = GEN_INT (~INTVAL (operands[5])
2190                & ((HOST_WIDE_INT_1U << GET_MODE_NUNITS (<MODE>mode)) - 1));
2193 (define_split
2194   [(set (match_operand:VF_128_256 0 "register_operand")
2195         (match_operator:VF_128_256 7 "addsub_vs_operator"
2196           [(vec_concat:<ssedoublemode>
2197              (minus:VF_128_256
2198                (match_operand:VF_128_256 1 "register_operand")
2199                (match_operand:VF_128_256 2 "vector_operand"))
2200              (plus:VF_128_256
2201                (match_operand:VF_128_256 3 "vector_operand")
2202                (match_operand:VF_128_256 4 "vector_operand")))
2203            (match_parallel 5 "addsub_vs_parallel"
2204              [(match_operand 6 "const_int_operand")])]))]
2205   "TARGET_SSE3
2206    && can_create_pseudo_p ()
2207    && ((rtx_equal_p (operands[1], operands[3])
2208         && rtx_equal_p (operands[2], operands[4]))
2209        || (rtx_equal_p (operands[1], operands[4])
2210            && rtx_equal_p (operands[2], operands[3])))"
2211   [(set (match_dup 0)
2212         (vec_merge:VF_128_256
2213           (minus:VF_128_256 (match_dup 1) (match_dup 2))
2214           (plus:VF_128_256 (match_dup 1) (match_dup 2))
2215           (match_dup 5)))]
2217   int i, nelt = XVECLEN (operands[5], 0);
2218   HOST_WIDE_INT ival = 0;
2220   for (i = 0; i < nelt; i++)
2221     if (INTVAL (XVECEXP (operands[5], 0, i)) < GET_MODE_NUNITS (<MODE>mode))
2222       ival |= HOST_WIDE_INT_1 << i;
2224   operands[5] = GEN_INT (ival);
2227 (define_split
2228   [(set (match_operand:VF_128_256 0 "register_operand")
2229         (match_operator:VF_128_256 7 "addsub_vs_operator"
2230           [(vec_concat:<ssedoublemode>
2231              (plus:VF_128_256
2232                (match_operand:VF_128_256 1 "vector_operand")
2233                (match_operand:VF_128_256 2 "vector_operand"))
2234              (minus:VF_128_256
2235                (match_operand:VF_128_256 3 "register_operand")
2236                (match_operand:VF_128_256 4 "vector_operand")))
2237            (match_parallel 5 "addsub_vs_parallel"
2238              [(match_operand 6 "const_int_operand")])]))]
2239   "TARGET_SSE3
2240    && can_create_pseudo_p ()
2241    && ((rtx_equal_p (operands[1], operands[3])
2242         && rtx_equal_p (operands[2], operands[4]))
2243        || (rtx_equal_p (operands[1], operands[4])
2244            && rtx_equal_p (operands[2], operands[3])))"
2245   [(set (match_dup 0)
2246         (vec_merge:VF_128_256
2247           (minus:VF_128_256 (match_dup 3) (match_dup 4))
2248           (plus:VF_128_256 (match_dup 3) (match_dup 4))
2249           (match_dup 5)))]
2251   int i, nelt = XVECLEN (operands[5], 0);
2252   HOST_WIDE_INT ival = 0;
2254   for (i = 0; i < nelt; i++)
2255     if (INTVAL (XVECEXP (operands[5], 0, i)) >= GET_MODE_NUNITS (<MODE>mode))
2256       ival |= HOST_WIDE_INT_1 << i;
2258   operands[5] = GEN_INT (ival);
2261 (define_insn "avx_h<plusminus_insn>v4df3"
2262   [(set (match_operand:V4DF 0 "register_operand" "=x")
2263         (vec_concat:V4DF
2264           (vec_concat:V2DF
2265             (plusminus:DF
2266               (vec_select:DF
2267                 (match_operand:V4DF 1 "register_operand" "x")
2268                 (parallel [(const_int 0)]))
2269               (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
2270             (plusminus:DF
2271               (vec_select:DF
2272                 (match_operand:V4DF 2 "nonimmediate_operand" "xm")
2273                 (parallel [(const_int 0)]))
2274               (vec_select:DF (match_dup 2) (parallel [(const_int 1)]))))
2275           (vec_concat:V2DF
2276             (plusminus:DF
2277               (vec_select:DF (match_dup 1) (parallel [(const_int 2)]))
2278               (vec_select:DF (match_dup 1) (parallel [(const_int 3)])))
2279             (plusminus:DF
2280               (vec_select:DF (match_dup 2) (parallel [(const_int 2)]))
2281               (vec_select:DF (match_dup 2) (parallel [(const_int 3)]))))))]
2282   "TARGET_AVX"
2283   "vh<plusminus_mnemonic>pd\t{%2, %1, %0|%0, %1, %2}"
2284   [(set_attr "type" "sseadd")
2285    (set_attr "prefix" "vex")
2286    (set_attr "mode" "V4DF")])
2288 (define_expand "sse3_haddv2df3"
2289   [(set (match_operand:V2DF 0 "register_operand")
2290         (vec_concat:V2DF
2291           (plus:DF
2292             (vec_select:DF
2293               (match_operand:V2DF 1 "register_operand")
2294               (parallel [(const_int 0)]))
2295             (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
2296           (plus:DF
2297             (vec_select:DF
2298               (match_operand:V2DF 2 "vector_operand")
2299               (parallel [(const_int 0)]))
2300             (vec_select:DF (match_dup 2) (parallel [(const_int 1)])))))]
2301   "TARGET_SSE3")
2303 (define_insn "*sse3_haddv2df3"
2304   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
2305         (vec_concat:V2DF
2306           (plus:DF
2307             (vec_select:DF
2308               (match_operand:V2DF 1 "register_operand" "0,x")
2309               (parallel [(match_operand:SI 3 "const_0_to_1_operand")]))
2310             (vec_select:DF
2311               (match_dup 1)
2312               (parallel [(match_operand:SI 4 "const_0_to_1_operand")])))
2313           (plus:DF
2314             (vec_select:DF
2315               (match_operand:V2DF 2 "vector_operand" "xBm,xm")
2316               (parallel [(match_operand:SI 5 "const_0_to_1_operand")]))
2317             (vec_select:DF
2318               (match_dup 2)
2319               (parallel [(match_operand:SI 6 "const_0_to_1_operand")])))))]
2320   "TARGET_SSE3
2321    && INTVAL (operands[3]) != INTVAL (operands[4])
2322    && INTVAL (operands[5]) != INTVAL (operands[6])"
2323   "@
2324    haddpd\t{%2, %0|%0, %2}
2325    vhaddpd\t{%2, %1, %0|%0, %1, %2}"
2326   [(set_attr "isa" "noavx,avx")
2327    (set_attr "type" "sseadd")
2328    (set_attr "prefix" "orig,vex")
2329    (set_attr "mode" "V2DF")])
2331 (define_insn "sse3_hsubv2df3"
2332   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
2333         (vec_concat:V2DF
2334           (minus:DF
2335             (vec_select:DF
2336               (match_operand:V2DF 1 "register_operand" "0,x")
2337               (parallel [(const_int 0)]))
2338             (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
2339           (minus:DF
2340             (vec_select:DF
2341               (match_operand:V2DF 2 "vector_operand" "xBm,xm")
2342               (parallel [(const_int 0)]))
2343             (vec_select:DF (match_dup 2) (parallel [(const_int 1)])))))]
2344   "TARGET_SSE3"
2345   "@
2346    hsubpd\t{%2, %0|%0, %2}
2347    vhsubpd\t{%2, %1, %0|%0, %1, %2}"
2348   [(set_attr "isa" "noavx,avx")
2349    (set_attr "type" "sseadd")
2350    (set_attr "prefix" "orig,vex")
2351    (set_attr "mode" "V2DF")])
2353 (define_insn "*sse3_haddv2df3_low"
2354   [(set (match_operand:DF 0 "register_operand" "=x,x")
2355         (plus:DF
2356           (vec_select:DF
2357             (match_operand:V2DF 1 "register_operand" "0,x")
2358             (parallel [(match_operand:SI 2 "const_0_to_1_operand")]))
2359           (vec_select:DF
2360             (match_dup 1)
2361             (parallel [(match_operand:SI 3 "const_0_to_1_operand")]))))]
2362   "TARGET_SSE3
2363    && INTVAL (operands[2]) != INTVAL (operands[3])"
2364   "@
2365    haddpd\t{%0, %0|%0, %0}
2366    vhaddpd\t{%1, %1, %0|%0, %1, %1}"
2367   [(set_attr "isa" "noavx,avx")
2368    (set_attr "type" "sseadd1")
2369    (set_attr "prefix" "orig,vex")
2370    (set_attr "mode" "V2DF")])
2372 (define_insn "*sse3_hsubv2df3_low"
2373   [(set (match_operand:DF 0 "register_operand" "=x,x")
2374         (minus:DF
2375           (vec_select:DF
2376             (match_operand:V2DF 1 "register_operand" "0,x")
2377             (parallel [(const_int 0)]))
2378           (vec_select:DF
2379             (match_dup 1)
2380             (parallel [(const_int 1)]))))]
2381   "TARGET_SSE3"
2382   "@
2383    hsubpd\t{%0, %0|%0, %0}
2384    vhsubpd\t{%1, %1, %0|%0, %1, %1}"
2385   [(set_attr "isa" "noavx,avx")
2386    (set_attr "type" "sseadd1")
2387    (set_attr "prefix" "orig,vex")
2388    (set_attr "mode" "V2DF")])
2390 (define_insn "avx_h<plusminus_insn>v8sf3"
2391   [(set (match_operand:V8SF 0 "register_operand" "=x")
2392         (vec_concat:V8SF
2393           (vec_concat:V4SF
2394             (vec_concat:V2SF
2395               (plusminus:SF
2396                 (vec_select:SF
2397                   (match_operand:V8SF 1 "register_operand" "x")
2398                   (parallel [(const_int 0)]))
2399                 (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
2400               (plusminus:SF
2401                 (vec_select:SF (match_dup 1) (parallel [(const_int 2)]))
2402                 (vec_select:SF (match_dup 1) (parallel [(const_int 3)]))))
2403             (vec_concat:V2SF
2404               (plusminus:SF
2405                 (vec_select:SF
2406                   (match_operand:V8SF 2 "nonimmediate_operand" "xm")
2407                   (parallel [(const_int 0)]))
2408                 (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))
2409               (plusminus:SF
2410                 (vec_select:SF (match_dup 2) (parallel [(const_int 2)]))
2411                 (vec_select:SF (match_dup 2) (parallel [(const_int 3)])))))
2412           (vec_concat:V4SF
2413             (vec_concat:V2SF
2414               (plusminus:SF
2415                 (vec_select:SF (match_dup 1) (parallel [(const_int 4)]))
2416                 (vec_select:SF (match_dup 1) (parallel [(const_int 5)])))
2417               (plusminus:SF
2418                 (vec_select:SF (match_dup 1) (parallel [(const_int 6)]))
2419                 (vec_select:SF (match_dup 1) (parallel [(const_int 7)]))))
2420             (vec_concat:V2SF
2421               (plusminus:SF
2422                 (vec_select:SF (match_dup 2) (parallel [(const_int 4)]))
2423                 (vec_select:SF (match_dup 2) (parallel [(const_int 5)])))
2424               (plusminus:SF
2425                 (vec_select:SF (match_dup 2) (parallel [(const_int 6)]))
2426                 (vec_select:SF (match_dup 2) (parallel [(const_int 7)])))))))]
2427   "TARGET_AVX"
2428   "vh<plusminus_mnemonic>ps\t{%2, %1, %0|%0, %1, %2}"
2429   [(set_attr "type" "sseadd")
2430    (set_attr "prefix" "vex")
2431    (set_attr "mode" "V8SF")])
2433 (define_insn "sse3_h<plusminus_insn>v4sf3"
2434   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
2435         (vec_concat:V4SF
2436           (vec_concat:V2SF
2437             (plusminus:SF
2438               (vec_select:SF
2439                 (match_operand:V4SF 1 "register_operand" "0,x")
2440                 (parallel [(const_int 0)]))
2441               (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
2442             (plusminus:SF
2443               (vec_select:SF (match_dup 1) (parallel [(const_int 2)]))
2444               (vec_select:SF (match_dup 1) (parallel [(const_int 3)]))))
2445           (vec_concat:V2SF
2446             (plusminus:SF
2447               (vec_select:SF
2448                 (match_operand:V4SF 2 "vector_operand" "xBm,xm")
2449                 (parallel [(const_int 0)]))
2450               (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))
2451             (plusminus:SF
2452               (vec_select:SF (match_dup 2) (parallel [(const_int 2)]))
2453               (vec_select:SF (match_dup 2) (parallel [(const_int 3)]))))))]
2454   "TARGET_SSE3"
2455   "@
2456    h<plusminus_mnemonic>ps\t{%2, %0|%0, %2}
2457    vh<plusminus_mnemonic>ps\t{%2, %1, %0|%0, %1, %2}"
2458   [(set_attr "isa" "noavx,avx")
2459    (set_attr "type" "sseadd")
2460    (set_attr "atom_unit" "complex")
2461    (set_attr "prefix" "orig,vex")
2462    (set_attr "prefix_rep" "1,*")
2463    (set_attr "mode" "V4SF")])
2465 (define_expand "reduc_plus_scal_v8df"
2466   [(match_operand:DF 0 "register_operand")
2467    (match_operand:V8DF 1 "register_operand")]
2468   "TARGET_AVX512F"
2470   rtx tmp = gen_reg_rtx (V8DFmode);
2471   ix86_expand_reduc (gen_addv8df3, tmp, operands[1]);
2472   emit_insn (gen_vec_extractv8dfdf (operands[0], tmp, const0_rtx));
2473   DONE;
2476 (define_expand "reduc_plus_scal_v4df"
2477   [(match_operand:DF 0 "register_operand")
2478    (match_operand:V4DF 1 "register_operand")]
2479   "TARGET_AVX"
2481   rtx tmp = gen_reg_rtx (V4DFmode);
2482   rtx tmp2 = gen_reg_rtx (V4DFmode);
2483   rtx vec_res = gen_reg_rtx (V4DFmode);
2484   emit_insn (gen_avx_haddv4df3 (tmp, operands[1], operands[1]));
2485   emit_insn (gen_avx_vperm2f128v4df3 (tmp2, tmp, tmp, GEN_INT (1)));
2486   emit_insn (gen_addv4df3 (vec_res, tmp, tmp2));
2487   emit_insn (gen_vec_extractv4dfdf (operands[0], vec_res, const0_rtx));
2488   DONE;
2491 (define_expand "reduc_plus_scal_v2df"
2492   [(match_operand:DF 0 "register_operand")
2493    (match_operand:V2DF 1 "register_operand")]
2494   "TARGET_SSE3"
2496   rtx tmp = gen_reg_rtx (V2DFmode);
2497   emit_insn (gen_sse3_haddv2df3 (tmp, operands[1], operands[1]));
2498   emit_insn (gen_vec_extractv2dfdf (operands[0], tmp, const0_rtx));
2499   DONE;
2502 (define_expand "reduc_plus_scal_v16sf"
2503   [(match_operand:SF 0 "register_operand")
2504    (match_operand:V16SF 1 "register_operand")]
2505   "TARGET_AVX512F"
2507   rtx tmp = gen_reg_rtx (V16SFmode);
2508   ix86_expand_reduc (gen_addv16sf3, tmp, operands[1]);
2509   emit_insn (gen_vec_extractv16sfsf (operands[0], tmp, const0_rtx));
2510   DONE;
2513 (define_expand "reduc_plus_scal_v8sf"
2514   [(match_operand:SF 0 "register_operand")
2515    (match_operand:V8SF 1 "register_operand")]
2516   "TARGET_AVX"
2518   rtx tmp = gen_reg_rtx (V8SFmode);
2519   rtx tmp2 = gen_reg_rtx (V8SFmode);
2520   rtx vec_res = gen_reg_rtx (V8SFmode);
2521   emit_insn (gen_avx_haddv8sf3 (tmp, operands[1], operands[1]));
2522   emit_insn (gen_avx_haddv8sf3 (tmp2, tmp, tmp));
2523   emit_insn (gen_avx_vperm2f128v8sf3 (tmp, tmp2, tmp2, GEN_INT (1)));
2524   emit_insn (gen_addv8sf3 (vec_res, tmp, tmp2));
2525   emit_insn (gen_vec_extractv8sfsf (operands[0], vec_res, const0_rtx));
2526   DONE;
2529 (define_expand "reduc_plus_scal_v4sf"
2530   [(match_operand:SF 0 "register_operand")
2531    (match_operand:V4SF 1 "register_operand")]
2532   "TARGET_SSE"
2534   rtx vec_res = gen_reg_rtx (V4SFmode);
2535   if (TARGET_SSE3)
2536     {
2537       rtx tmp = gen_reg_rtx (V4SFmode);
2538       emit_insn (gen_sse3_haddv4sf3 (tmp, operands[1], operands[1]));
2539       emit_insn (gen_sse3_haddv4sf3 (vec_res, tmp, tmp));
2540     }
2541   else
2542     ix86_expand_reduc (gen_addv4sf3, vec_res, operands[1]);
2543   emit_insn (gen_vec_extractv4sfsf (operands[0], vec_res, const0_rtx));
2544   DONE;
2547 ;; Modes handled by reduc_sm{in,ax}* patterns.
2548 (define_mode_iterator REDUC_SMINMAX_MODE
2549   [(V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
2550    (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")
2551    (V8SF "TARGET_AVX") (V4DF "TARGET_AVX")
2552    (V4SF "TARGET_SSE") (V64QI "TARGET_AVX512BW")
2553    (V32HI "TARGET_AVX512BW") (V16SI "TARGET_AVX512F")
2554    (V8DI "TARGET_AVX512F") (V16SF "TARGET_AVX512F")
2555    (V8DF "TARGET_AVX512F")])
2557 (define_expand "reduc_<code>_scal_<mode>"
2558   [(smaxmin:REDUC_SMINMAX_MODE
2559      (match_operand:<ssescalarmode> 0 "register_operand")
2560      (match_operand:REDUC_SMINMAX_MODE 1 "register_operand"))]
2561   ""
2563   rtx tmp = gen_reg_rtx (<MODE>mode);
2564   ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
2565   emit_insn (gen_vec_extract<mode><ssescalarmodelower> (operands[0], tmp,
2566                                                         const0_rtx));
2567   DONE;
2570 (define_expand "reduc_<code>_scal_<mode>"
2571   [(umaxmin:VI_AVX512BW
2572      (match_operand:<ssescalarmode> 0 "register_operand")
2573      (match_operand:VI_AVX512BW 1 "register_operand"))]
2574   "TARGET_AVX512F"
2576   rtx tmp = gen_reg_rtx (<MODE>mode);
2577   ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
2578   emit_insn (gen_vec_extract<mode><ssescalarmodelower> (operands[0], tmp,
2579                                                         const0_rtx));
2580   DONE;
2583 (define_expand "reduc_<code>_scal_<mode>"
2584   [(umaxmin:VI_256
2585      (match_operand:<ssescalarmode> 0 "register_operand")
2586      (match_operand:VI_256 1 "register_operand"))]
2587   "TARGET_AVX2"
2589   rtx tmp = gen_reg_rtx (<MODE>mode);
2590   ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
2591   emit_insn (gen_vec_extract<mode><ssescalarmodelower> (operands[0], tmp,
2592                                                         const0_rtx));
2593   DONE;
2596 (define_expand "reduc_umin_scal_v8hi"
2597   [(umin:V8HI
2598      (match_operand:HI 0 "register_operand")
2599      (match_operand:V8HI 1 "register_operand"))]
2600   "TARGET_SSE4_1"
2602   rtx tmp = gen_reg_rtx (V8HImode);
2603   ix86_expand_reduc (gen_uminv8hi3, tmp, operands[1]);
2604   emit_insn (gen_vec_extractv8hihi (operands[0], tmp, const0_rtx));
2605   DONE;
2608 (define_insn "<mask_codefor>reducep<mode><mask_name>"
2609   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
2610         (unspec:VF_AVX512VL
2611           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")
2612            (match_operand:SI 2 "const_0_to_255_operand")]
2613           UNSPEC_REDUCE))]
2614   "TARGET_AVX512DQ"
2615   "vreduce<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
2616   [(set_attr "type" "sse")
2617    (set_attr "prefix" "evex")
2618    (set_attr "mode" "<MODE>")])
2620 (define_insn "reduces<mode><mask_scalar_name>"
2621   [(set (match_operand:VF_128 0 "register_operand" "=v")
2622         (vec_merge:VF_128
2623           (unspec:VF_128
2624             [(match_operand:VF_128 1 "register_operand" "v")
2625              (match_operand:VF_128 2 "nonimmediate_operand" "vm")
2626              (match_operand:SI 3 "const_0_to_255_operand")]
2627             UNSPEC_REDUCE)
2628           (match_dup 1)
2629           (const_int 1)))]
2630   "TARGET_AVX512DQ"
2631   "vreduce<ssescalarmodesuffix>\t{%3, %2, %1, %0<mask_scalar_operand4>|%0<mask_scalar_operand4>, %1, %<iptr>2, %3}"
2632   [(set_attr "type" "sse")
2633    (set_attr "prefix" "evex")
2634    (set_attr "mode" "<MODE>")])
2636 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2638 ;; Parallel floating point comparisons
2640 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2642 (define_insn "avx_cmp<mode>3"
2643   [(set (match_operand:VF_128_256 0 "register_operand" "=x")
2644         (unspec:VF_128_256
2645           [(match_operand:VF_128_256 1 "register_operand" "x")
2646            (match_operand:VF_128_256 2 "nonimmediate_operand" "xm")
2647            (match_operand:SI 3 "const_0_to_31_operand" "n")]
2648           UNSPEC_PCMP))]
2649   "TARGET_AVX"
2650   "vcmp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
2651   [(set_attr "type" "ssecmp")
2652    (set_attr "length_immediate" "1")
2653    (set_attr "prefix" "vex")
2654    (set_attr "mode" "<MODE>")])
2656 (define_insn "avx_vmcmp<mode>3"
2657   [(set (match_operand:VF_128 0 "register_operand" "=x")
2658         (vec_merge:VF_128
2659           (unspec:VF_128
2660             [(match_operand:VF_128 1 "register_operand" "x")
2661              (match_operand:VF_128 2 "nonimmediate_operand" "xm")
2662              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2663             UNSPEC_PCMP)
2664          (match_dup 1)
2665          (const_int 1)))]
2666   "TARGET_AVX"
2667   "vcmp<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %3}"
2668   [(set_attr "type" "ssecmp")
2669    (set_attr "length_immediate" "1")
2670    (set_attr "prefix" "vex")
2671    (set_attr "mode" "<ssescalarmode>")])
2673 (define_insn "*<sse>_maskcmp<mode>3_comm"
2674   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
2675         (match_operator:VF_128_256 3 "sse_comparison_operator"
2676           [(match_operand:VF_128_256 1 "register_operand" "%0,x")
2677            (match_operand:VF_128_256 2 "vector_operand" "xBm,xm")]))]
2678   "TARGET_SSE
2679    && GET_RTX_CLASS (GET_CODE (operands[3])) == RTX_COMM_COMPARE"
2680   "@
2681    cmp%D3<ssemodesuffix>\t{%2, %0|%0, %2}
2682    vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2683   [(set_attr "isa" "noavx,avx")
2684    (set_attr "type" "ssecmp")
2685    (set_attr "length_immediate" "1")
2686    (set_attr "prefix" "orig,vex")
2687    (set_attr "mode" "<MODE>")])
2689 (define_insn "<sse>_maskcmp<mode>3"
2690   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
2691         (match_operator:VF_128_256 3 "sse_comparison_operator"
2692           [(match_operand:VF_128_256 1 "register_operand" "0,x")
2693            (match_operand:VF_128_256 2 "vector_operand" "xBm,xm")]))]
2694   "TARGET_SSE"
2695   "@
2696    cmp%D3<ssemodesuffix>\t{%2, %0|%0, %2}
2697    vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2698   [(set_attr "isa" "noavx,avx")
2699    (set_attr "type" "ssecmp")
2700    (set_attr "length_immediate" "1")
2701    (set_attr "prefix" "orig,vex")
2702    (set_attr "mode" "<MODE>")])
2704 (define_insn "<sse>_vmmaskcmp<mode>3"
2705   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
2706         (vec_merge:VF_128
2707          (match_operator:VF_128 3 "sse_comparison_operator"
2708            [(match_operand:VF_128 1 "register_operand" "0,x")
2709             (match_operand:VF_128 2 "vector_operand" "xBm,xm")])
2710          (match_dup 1)
2711          (const_int 1)))]
2712   "TARGET_SSE"
2713   "@
2714    cmp%D3<ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
2715    vcmp%D3<ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %<iptr>2}"
2716   [(set_attr "isa" "noavx,avx")
2717    (set_attr "type" "ssecmp")
2718    (set_attr "length_immediate" "1,*")
2719    (set_attr "prefix" "orig,vex")
2720    (set_attr "mode" "<ssescalarmode>")])
2722 (define_mode_attr cmp_imm_predicate
2723   [(V16SF "const_0_to_31_operand")  (V8DF "const_0_to_31_operand")
2724    (V16SI "const_0_to_7_operand")   (V8DI "const_0_to_7_operand")
2725    (V8SF "const_0_to_31_operand")   (V4DF "const_0_to_31_operand")
2726    (V8SI "const_0_to_7_operand")    (V4DI "const_0_to_7_operand")
2727    (V4SF "const_0_to_31_operand")   (V2DF "const_0_to_31_operand")
2728    (V4SI "const_0_to_7_operand")    (V2DI "const_0_to_7_operand")
2729    (V32HI "const_0_to_7_operand")   (V64QI "const_0_to_7_operand")
2730    (V16HI "const_0_to_7_operand")   (V32QI "const_0_to_7_operand")
2731    (V8HI "const_0_to_7_operand")    (V16QI "const_0_to_7_operand")])
2733 (define_insn "<avx512>_cmp<mode>3<mask_scalar_merge_name><round_saeonly_name>"
2734   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2735         (unspec:<avx512fmaskmode>
2736           [(match_operand:V48_AVX512VL 1 "register_operand" "v")
2737            (match_operand:V48_AVX512VL 2 "nonimmediate_operand" "<round_saeonly_constraint>")
2738            (match_operand:SI 3 "<cmp_imm_predicate>" "n")]
2739           UNSPEC_PCMP))]
2740   "TARGET_AVX512F && <round_saeonly_mode512bit_condition>"
2741   "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}"
2742   [(set_attr "type" "ssecmp")
2743    (set_attr "length_immediate" "1")
2744    (set_attr "prefix" "evex")
2745    (set_attr "mode" "<sseinsnmode>")])
2747 (define_insn "<avx512>_cmp<mode>3<mask_scalar_merge_name>"
2748   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2749         (unspec:<avx512fmaskmode>
2750           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
2751            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
2752            (match_operand:SI 3 "<cmp_imm_predicate>" "n")]
2753           UNSPEC_PCMP))]
2754   "TARGET_AVX512BW"
2755   "vpcmp<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2756   [(set_attr "type" "ssecmp")
2757    (set_attr "length_immediate" "1")
2758    (set_attr "prefix" "evex")
2759    (set_attr "mode" "<sseinsnmode>")])
2761 (define_insn "<avx512>_ucmp<mode>3<mask_scalar_merge_name>"
2762   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2763         (unspec:<avx512fmaskmode>
2764           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
2765            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
2766            (match_operand:SI 3 "const_0_to_7_operand" "n")]
2767           UNSPEC_UNSIGNED_PCMP))]
2768   "TARGET_AVX512BW"
2769   "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2770   [(set_attr "type" "ssecmp")
2771    (set_attr "length_immediate" "1")
2772    (set_attr "prefix" "evex")
2773    (set_attr "mode" "<sseinsnmode>")])
2775 (define_insn "<avx512>_ucmp<mode>3<mask_scalar_merge_name>"
2776   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2777         (unspec:<avx512fmaskmode>
2778           [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
2779            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")
2780            (match_operand:SI 3 "const_0_to_7_operand" "n")]
2781           UNSPEC_UNSIGNED_PCMP))]
2782   "TARGET_AVX512F"
2783   "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2784   [(set_attr "type" "ssecmp")
2785    (set_attr "length_immediate" "1")
2786    (set_attr "prefix" "evex")
2787    (set_attr "mode" "<sseinsnmode>")])
2789 (define_insn "avx512f_vmcmp<mode>3<round_saeonly_name>"
2790   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2791         (and:<avx512fmaskmode>
2792           (unspec:<avx512fmaskmode>
2793             [(match_operand:VF_128 1 "register_operand" "v")
2794              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
2795              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2796             UNSPEC_PCMP)
2797           (const_int 1)))]
2798   "TARGET_AVX512F"
2799   "vcmp<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %<iptr>2<round_saeonly_op4>, %3}"
2800   [(set_attr "type" "ssecmp")
2801    (set_attr "length_immediate" "1")
2802    (set_attr "prefix" "evex")
2803    (set_attr "mode" "<ssescalarmode>")])
2805 (define_insn "avx512f_vmcmp<mode>3_mask<round_saeonly_name>"
2806   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2807         (and:<avx512fmaskmode>
2808           (unspec:<avx512fmaskmode>
2809             [(match_operand:VF_128 1 "register_operand" "v")
2810              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
2811              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2812             UNSPEC_PCMP)
2813           (and:<avx512fmaskmode>
2814             (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")
2815             (const_int 1))))]
2816   "TARGET_AVX512F"
2817   "vcmp<ssescalarmodesuffix>\t{%3, <round_saeonly_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %<iptr>2<round_saeonly_op5>, %3}"
2818   [(set_attr "type" "ssecmp")
2819    (set_attr "length_immediate" "1")
2820    (set_attr "prefix" "evex")
2821    (set_attr "mode" "<ssescalarmode>")])
2823 (define_insn "avx512f_maskcmp<mode>3"
2824   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2825         (match_operator:<avx512fmaskmode> 3 "sse_comparison_operator"
2826           [(match_operand:VF 1 "register_operand" "v")
2827            (match_operand:VF 2 "nonimmediate_operand" "vm")]))]
2828   "TARGET_AVX512F"
2829   "vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2830   [(set_attr "type" "ssecmp")
2831    (set_attr "length_immediate" "1")
2832    (set_attr "prefix" "evex")
2833    (set_attr "mode" "<sseinsnmode>")])
2835 (define_insn "<sse>_<unord>comi<round_saeonly_name>"
2836   [(set (reg:CCFP FLAGS_REG)
2837         (compare:CCFP
2838           (vec_select:MODEF
2839             (match_operand:<ssevecmode> 0 "register_operand" "v")
2840             (parallel [(const_int 0)]))
2841           (vec_select:MODEF
2842             (match_operand:<ssevecmode> 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
2843             (parallel [(const_int 0)]))))]
2844   "SSE_FLOAT_MODE_P (<MODE>mode)"
2845   "%v<unord>comi<ssemodesuffix>\t{<round_saeonly_op2>%1, %0|%0, %<iptr>1<round_saeonly_op2>}"
2846   [(set_attr "type" "ssecomi")
2847    (set_attr "prefix" "maybe_vex")
2848    (set_attr "prefix_rep" "0")
2849    (set (attr "prefix_data16")
2850         (if_then_else (eq_attr "mode" "DF")
2851                       (const_string "1")
2852                       (const_string "0")))
2853    (set_attr "mode" "<MODE>")])
2855 (define_expand "vec_cmp<mode><avx512fmaskmodelower>"
2856   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2857         (match_operator:<avx512fmaskmode> 1 ""
2858           [(match_operand:V48_AVX512VL 2 "register_operand")
2859            (match_operand:V48_AVX512VL 3 "nonimmediate_operand")]))]
2860   "TARGET_AVX512F"
2862   bool ok = ix86_expand_mask_vec_cmp (operands);
2863   gcc_assert (ok);
2864   DONE;
2867 (define_expand "vec_cmp<mode><avx512fmaskmodelower>"
2868   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2869         (match_operator:<avx512fmaskmode> 1 ""
2870           [(match_operand:VI12_AVX512VL 2 "register_operand")
2871            (match_operand:VI12_AVX512VL 3 "nonimmediate_operand")]))]
2872   "TARGET_AVX512BW"
2874   bool ok = ix86_expand_mask_vec_cmp (operands);
2875   gcc_assert (ok);
2876   DONE;
2879 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2880   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2881         (match_operator:<sseintvecmode> 1 ""
2882           [(match_operand:VI_256 2 "register_operand")
2883            (match_operand:VI_256 3 "nonimmediate_operand")]))]
2884   "TARGET_AVX2"
2886   bool ok = ix86_expand_int_vec_cmp (operands);
2887   gcc_assert (ok);
2888   DONE;
2891 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2892   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2893         (match_operator:<sseintvecmode> 1 ""
2894           [(match_operand:VI124_128 2 "register_operand")
2895            (match_operand:VI124_128 3 "vector_operand")]))]
2896   "TARGET_SSE2"
2898   bool ok = ix86_expand_int_vec_cmp (operands);
2899   gcc_assert (ok);
2900   DONE;
2903 (define_expand "vec_cmpv2div2di"
2904   [(set (match_operand:V2DI 0 "register_operand")
2905         (match_operator:V2DI 1 ""
2906           [(match_operand:V2DI 2 "register_operand")
2907            (match_operand:V2DI 3 "vector_operand")]))]
2908   "TARGET_SSE4_2"
2910   bool ok = ix86_expand_int_vec_cmp (operands);
2911   gcc_assert (ok);
2912   DONE;
2915 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2916   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2917         (match_operator:<sseintvecmode> 1 ""
2918           [(match_operand:VF_256 2 "register_operand")
2919            (match_operand:VF_256 3 "nonimmediate_operand")]))]
2920   "TARGET_AVX"
2922   bool ok = ix86_expand_fp_vec_cmp (operands);
2923   gcc_assert (ok);
2924   DONE;
2927 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2928   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2929         (match_operator:<sseintvecmode> 1 ""
2930           [(match_operand:VF_128 2 "register_operand")
2931            (match_operand:VF_128 3 "vector_operand")]))]
2932   "TARGET_SSE"
2934   bool ok = ix86_expand_fp_vec_cmp (operands);
2935   gcc_assert (ok);
2936   DONE;
2939 (define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
2940   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2941         (match_operator:<avx512fmaskmode> 1 ""
2942           [(match_operand:VI48_AVX512VL 2 "register_operand")
2943            (match_operand:VI48_AVX512VL 3 "nonimmediate_operand")]))]
2944   "TARGET_AVX512F"
2946   bool ok = ix86_expand_mask_vec_cmp (operands);
2947   gcc_assert (ok);
2948   DONE;
2951 (define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
2952   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2953         (match_operator:<avx512fmaskmode> 1 ""
2954           [(match_operand:VI12_AVX512VL 2 "register_operand")
2955            (match_operand:VI12_AVX512VL 3 "nonimmediate_operand")]))]
2956   "TARGET_AVX512BW"
2958   bool ok = ix86_expand_mask_vec_cmp (operands);
2959   gcc_assert (ok);
2960   DONE;
2963 (define_expand "vec_cmpu<mode><sseintvecmodelower>"
2964   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2965         (match_operator:<sseintvecmode> 1 ""
2966           [(match_operand:VI_256 2 "register_operand")
2967            (match_operand:VI_256 3 "nonimmediate_operand")]))]
2968   "TARGET_AVX2"
2970   bool ok = ix86_expand_int_vec_cmp (operands);
2971   gcc_assert (ok);
2972   DONE;
2975 (define_expand "vec_cmpu<mode><sseintvecmodelower>"
2976   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2977         (match_operator:<sseintvecmode> 1 ""
2978           [(match_operand:VI124_128 2 "register_operand")
2979            (match_operand:VI124_128 3 "vector_operand")]))]
2980   "TARGET_SSE2"
2982   bool ok = ix86_expand_int_vec_cmp (operands);
2983   gcc_assert (ok);
2984   DONE;
2987 (define_expand "vec_cmpuv2div2di"
2988   [(set (match_operand:V2DI 0 "register_operand")
2989         (match_operator:V2DI 1 ""
2990           [(match_operand:V2DI 2 "register_operand")
2991            (match_operand:V2DI 3 "vector_operand")]))]
2992   "TARGET_SSE4_2"
2994   bool ok = ix86_expand_int_vec_cmp (operands);
2995   gcc_assert (ok);
2996   DONE;
2999 (define_expand "vec_cmpeqv2div2di"
3000   [(set (match_operand:V2DI 0 "register_operand")
3001         (match_operator:V2DI 1 ""
3002           [(match_operand:V2DI 2 "register_operand")
3003            (match_operand:V2DI 3 "vector_operand")]))]
3004   "TARGET_SSE4_1"
3006   bool ok = ix86_expand_int_vec_cmp (operands);
3007   gcc_assert (ok);
3008   DONE;
3011 (define_expand "vcond<V_512:mode><VF_512:mode>"
3012   [(set (match_operand:V_512 0 "register_operand")
3013         (if_then_else:V_512
3014           (match_operator 3 ""
3015             [(match_operand:VF_512 4 "nonimmediate_operand")
3016              (match_operand:VF_512 5 "nonimmediate_operand")])
3017           (match_operand:V_512 1 "general_operand")
3018           (match_operand:V_512 2 "general_operand")))]
3019   "TARGET_AVX512F
3020    && (GET_MODE_NUNITS (<V_512:MODE>mode)
3021        == GET_MODE_NUNITS (<VF_512:MODE>mode))"
3023   bool ok = ix86_expand_fp_vcond (operands);
3024   gcc_assert (ok);
3025   DONE;
3028 (define_expand "vcond<V_256:mode><VF_256:mode>"
3029   [(set (match_operand:V_256 0 "register_operand")
3030         (if_then_else:V_256
3031           (match_operator 3 ""
3032             [(match_operand:VF_256 4 "nonimmediate_operand")
3033              (match_operand:VF_256 5 "nonimmediate_operand")])
3034           (match_operand:V_256 1 "general_operand")
3035           (match_operand:V_256 2 "general_operand")))]
3036   "TARGET_AVX
3037    && (GET_MODE_NUNITS (<V_256:MODE>mode)
3038        == GET_MODE_NUNITS (<VF_256:MODE>mode))"
3040   bool ok = ix86_expand_fp_vcond (operands);
3041   gcc_assert (ok);
3042   DONE;
3045 (define_expand "vcond<V_128:mode><VF_128:mode>"
3046   [(set (match_operand:V_128 0 "register_operand")
3047         (if_then_else:V_128
3048           (match_operator 3 ""
3049             [(match_operand:VF_128 4 "vector_operand")
3050              (match_operand:VF_128 5 "vector_operand")])
3051           (match_operand:V_128 1 "general_operand")
3052           (match_operand:V_128 2 "general_operand")))]
3053   "TARGET_SSE
3054    && (GET_MODE_NUNITS (<V_128:MODE>mode)
3055        == GET_MODE_NUNITS (<VF_128:MODE>mode))"
3057   bool ok = ix86_expand_fp_vcond (operands);
3058   gcc_assert (ok);
3059   DONE;
3062 (define_expand "vcond_mask_<mode><avx512fmaskmodelower>"
3063   [(set (match_operand:V48_AVX512VL 0 "register_operand")
3064         (vec_merge:V48_AVX512VL
3065           (match_operand:V48_AVX512VL 1 "nonimmediate_operand")
3066           (match_operand:V48_AVX512VL 2 "vector_move_operand")
3067           (match_operand:<avx512fmaskmode> 3 "register_operand")))]
3068   "TARGET_AVX512F")
3070 (define_expand "vcond_mask_<mode><avx512fmaskmodelower>"
3071   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
3072         (vec_merge:VI12_AVX512VL
3073           (match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
3074           (match_operand:VI12_AVX512VL 2 "vector_move_operand")
3075           (match_operand:<avx512fmaskmode> 3 "register_operand")))]
3076   "TARGET_AVX512BW")
3078 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3079   [(set (match_operand:VI_256 0 "register_operand")
3080         (vec_merge:VI_256
3081           (match_operand:VI_256 1 "nonimmediate_operand")
3082           (match_operand:VI_256 2 "vector_move_operand")
3083           (match_operand:<sseintvecmode> 3 "register_operand")))]
3084   "TARGET_AVX2"
3086   ix86_expand_sse_movcc (operands[0], operands[3],
3087                          operands[1], operands[2]);
3088   DONE;
3091 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3092   [(set (match_operand:VI124_128 0 "register_operand")
3093         (vec_merge:VI124_128
3094           (match_operand:VI124_128 1 "vector_operand")
3095           (match_operand:VI124_128 2 "vector_move_operand")
3096           (match_operand:<sseintvecmode> 3 "register_operand")))]
3097   "TARGET_SSE2"
3099   ix86_expand_sse_movcc (operands[0], operands[3],
3100                          operands[1], operands[2]);
3101   DONE;
3104 (define_expand "vcond_mask_v2div2di"
3105   [(set (match_operand:V2DI 0 "register_operand")
3106         (vec_merge:V2DI
3107           (match_operand:V2DI 1 "vector_operand")
3108           (match_operand:V2DI 2 "vector_move_operand")
3109           (match_operand:V2DI 3 "register_operand")))]
3110   "TARGET_SSE4_2"
3112   ix86_expand_sse_movcc (operands[0], operands[3],
3113                          operands[1], operands[2]);
3114   DONE;
3117 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3118   [(set (match_operand:VF_256 0 "register_operand")
3119         (vec_merge:VF_256
3120           (match_operand:VF_256 1 "nonimmediate_operand")
3121           (match_operand:VF_256 2 "vector_move_operand")
3122           (match_operand:<sseintvecmode> 3 "register_operand")))]
3123   "TARGET_AVX"
3125   ix86_expand_sse_movcc (operands[0], operands[3],
3126                          operands[1], operands[2]);
3127   DONE;
3130 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3131   [(set (match_operand:VF_128 0 "register_operand")
3132         (vec_merge:VF_128
3133           (match_operand:VF_128 1 "vector_operand")
3134           (match_operand:VF_128 2 "vector_move_operand")
3135           (match_operand:<sseintvecmode> 3 "register_operand")))]
3136   "TARGET_SSE"
3138   ix86_expand_sse_movcc (operands[0], operands[3],
3139                          operands[1], operands[2]);
3140   DONE;
3143 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3145 ;; Parallel floating point logical operations
3147 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3149 (define_insn "<sse>_andnot<mode>3<mask_name>"
3150   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x,v,v")
3151         (and:VF_128_256
3152           (not:VF_128_256
3153             (match_operand:VF_128_256 1 "register_operand" "0,x,v,v"))
3154           (match_operand:VF_128_256 2 "vector_operand" "xBm,xm,vm,vm")))]
3155   "TARGET_SSE && <mask_avx512vl_condition>"
3157   static char buf[128];
3158   const char *ops;
3159   const char *suffix;
3161   switch (which_alternative)
3162     {
3163     case 0:
3164       ops = "andn%s\t{%%2, %%0|%%0, %%2}";
3165       break;
3166     case 1:
3167     case 2:
3168     case 3:
3169       ops = "vandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3170       break;
3171     default:
3172       gcc_unreachable ();
3173     }
3175   switch (get_attr_mode (insn))
3176     {
3177     case MODE_V8SF:
3178     case MODE_V4SF:
3179       suffix = "ps";
3180       break;
3181     case MODE_OI:
3182     case MODE_TI:
3183       /* There is no vandnp[sd] in avx512f.  Use vpandn[qd].  */
3184       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3185       ops = "vpandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3186       break;
3187     default:
3188       suffix = "<ssemodesuffix>";
3189     }
3191   snprintf (buf, sizeof (buf), ops, suffix);
3192   return buf;
3194   [(set_attr "isa" "noavx,avx,avx512dq,avx512f")
3195    (set_attr "type" "sselog")
3196    (set_attr "prefix" "orig,maybe_vex,evex,evex")
3197    (set (attr "mode")
3198         (cond [(and (match_test "<mask_applied>")
3199                     (and (eq_attr "alternative" "1")
3200                          (match_test "!TARGET_AVX512DQ")))
3201                  (const_string "<sseintvecmode2>")
3202                (eq_attr "alternative" "3")
3203                  (const_string "<sseintvecmode2>")
3204                (and (match_test "<MODE_SIZE> == 16")
3205                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3206                  (const_string "<ssePSmode>")
3207                (match_test "TARGET_AVX")
3208                  (const_string "<MODE>")
3209                (match_test "optimize_function_for_size_p (cfun)")
3210                  (const_string "V4SF")
3211                ]
3212                (const_string "<MODE>")))])
3215 (define_insn "<sse>_andnot<mode>3<mask_name>"
3216   [(set (match_operand:VF_512 0 "register_operand" "=v")
3217         (and:VF_512
3218           (not:VF_512
3219             (match_operand:VF_512 1 "register_operand" "v"))
3220           (match_operand:VF_512 2 "nonimmediate_operand" "vm")))]
3221   "TARGET_AVX512F"
3223   static char buf[128];
3224   const char *ops;
3225   const char *suffix;
3227   suffix = "<ssemodesuffix>";
3228   ops = "";
3230   /* There is no vandnp[sd] in avx512f.  Use vpandn[qd].  */
3231   if (!TARGET_AVX512DQ)
3232     {
3233       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3234       ops = "p";
3235     }
3237   snprintf (buf, sizeof (buf),
3238             "v%sandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}",
3239             ops, suffix);
3240   return buf;
3242   [(set_attr "type" "sselog")
3243    (set_attr "prefix" "evex")
3244    (set (attr "mode")
3245         (if_then_else (match_test "TARGET_AVX512DQ")
3246                       (const_string "<sseinsnmode>")
3247                       (const_string "XI")))])
3249 (define_expand "<code><mode>3<mask_name>"
3250   [(set (match_operand:VF_128_256 0 "register_operand")
3251        (any_logic:VF_128_256
3252          (match_operand:VF_128_256 1 "vector_operand")
3253          (match_operand:VF_128_256 2 "vector_operand")))]
3254   "TARGET_SSE && <mask_avx512vl_condition>"
3255   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
3257 (define_expand "<code><mode>3<mask_name>"
3258   [(set (match_operand:VF_512 0 "register_operand")
3259        (any_logic:VF_512
3260          (match_operand:VF_512 1 "nonimmediate_operand")
3261          (match_operand:VF_512 2 "nonimmediate_operand")))]
3262   "TARGET_AVX512F"
3263   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
3265 (define_insn "*<code><mode>3<mask_name>"
3266   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x,v,v")
3267         (any_logic:VF_128_256
3268           (match_operand:VF_128_256 1 "vector_operand" "%0,x,v,v")
3269           (match_operand:VF_128_256 2 "vector_operand" "xBm,xm,vm,vm")))]
3270   "TARGET_SSE && <mask_avx512vl_condition>
3271    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
3273   static char buf[128];
3274   const char *ops;
3275   const char *suffix;
3277   switch (which_alternative)
3278     {
3279     case 0:
3280       ops = "<logic>%s\t{%%2, %%0|%%0, %%2}";
3281       break;
3282     case 1:
3283     case 2:
3284     case 3:
3285       ops = "v<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3286       break;
3287     default:
3288       gcc_unreachable ();
3289     }
3291   switch (get_attr_mode (insn))
3292     {
3293     case MODE_V8SF:
3294     case MODE_V4SF:
3295       suffix = "ps";
3296       break;
3297     case MODE_OI:
3298     case MODE_TI:
3299       /* There is no v<logic>p[sd] in avx512f.  Use vp<logic>[qd].  */
3300       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3301       ops = "vp<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3302       break;
3303     default:
3304       suffix = "<ssemodesuffix>";
3305     }
3307   snprintf (buf, sizeof (buf), ops, suffix);
3308   return buf;
3310   [(set_attr "isa" "noavx,avx,avx512dq,avx512f")
3311    (set_attr "type" "sselog")
3312    (set_attr "prefix" "orig,maybe_evex,evex,evex")
3313    (set (attr "mode")
3314         (cond [(and (match_test "<mask_applied>")
3315                     (and (eq_attr "alternative" "1")
3316                          (match_test "!TARGET_AVX512DQ")))
3317                  (const_string "<sseintvecmode2>")
3318                (eq_attr "alternative" "3")
3319                  (const_string "<sseintvecmode2>")
3320                (and (match_test "<MODE_SIZE> == 16")
3321                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3322                  (const_string "<ssePSmode>")
3323                (match_test "TARGET_AVX")
3324                  (const_string "<MODE>")
3325                (match_test "optimize_function_for_size_p (cfun)")
3326                  (const_string "V4SF")
3327                ]
3328                (const_string "<MODE>")))])
3330 (define_insn "*<code><mode>3<mask_name>"
3331   [(set (match_operand:VF_512 0 "register_operand" "=v")
3332         (any_logic:VF_512
3333           (match_operand:VF_512 1 "nonimmediate_operand" "%v")
3334           (match_operand:VF_512 2 "nonimmediate_operand" "vm")))]
3335   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
3337   static char buf[128];
3338   const char *ops;
3339   const char *suffix;
3341   suffix = "<ssemodesuffix>";
3342   ops = "";
3344   /* There is no v<logic>p[sd] in avx512f.  Use vp<logic>[dq].  */
3345   if (!TARGET_AVX512DQ)
3346     {
3347       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3348       ops = "p";
3349     }
3351   snprintf (buf, sizeof (buf),
3352            "v%s<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}",
3353            ops, suffix);
3354   return buf;
3356   [(set_attr "type" "sselog")
3357    (set_attr "prefix" "evex")
3358    (set (attr "mode")
3359         (if_then_else (match_test "TARGET_AVX512DQ")
3360                       (const_string "<sseinsnmode>")
3361                       (const_string "XI")))])
3363 (define_expand "copysign<mode>3"
3364   [(set (match_dup 4)
3365         (and:VF
3366           (not:VF (match_dup 3))
3367           (match_operand:VF 1 "vector_operand")))
3368    (set (match_dup 5)
3369         (and:VF (match_dup 3)
3370                 (match_operand:VF 2 "vector_operand")))
3371    (set (match_operand:VF 0 "register_operand")
3372         (ior:VF (match_dup 4) (match_dup 5)))]
3373   "TARGET_SSE"
3375   operands[3] = ix86_build_signbit_mask (<MODE>mode, 1, 0);
3377   operands[4] = gen_reg_rtx (<MODE>mode);
3378   operands[5] = gen_reg_rtx (<MODE>mode);
3381 ;; Also define scalar versions.  These are used for abs, neg, and
3382 ;; conditional move.  Using subregs into vector modes causes register
3383 ;; allocation lossage.  These patterns do not allow memory operands
3384 ;; because the native instructions read the full 128-bits.
3386 (define_insn "*andnot<mode>3"
3387   [(set (match_operand:MODEF 0 "register_operand" "=x,x,v,v")
3388         (and:MODEF
3389           (not:MODEF
3390             (match_operand:MODEF 1 "register_operand" "0,x,v,v"))
3391             (match_operand:MODEF 2 "register_operand" "x,x,v,v")))]
3392   "SSE_FLOAT_MODE_P (<MODE>mode)"
3394   static char buf[128];
3395   const char *ops;
3396   const char *suffix
3397     = (get_attr_mode (insn) == MODE_V4SF) ? "ps" : "<ssevecmodesuffix>";
3399   switch (which_alternative)
3400     {
3401     case 0:
3402       ops = "andn%s\t{%%2, %%0|%%0, %%2}";
3403       break;
3404     case 1:
3405       ops = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3406       break;
3407     case 2:
3408       if (TARGET_AVX512DQ)
3409         ops = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3410       else
3411         {
3412           suffix = <MODE>mode == DFmode ? "q" : "d";
3413           ops = "vpandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3414         }
3415       break;
3416     case 3:
3417       if (TARGET_AVX512DQ)
3418         ops = "vandn%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3419       else
3420         {
3421           suffix = <MODE>mode == DFmode ? "q" : "d";
3422           ops = "vpandn%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3423         }
3424       break;
3425     default:
3426       gcc_unreachable ();
3427     }
3429   snprintf (buf, sizeof (buf), ops, suffix);
3430   return buf;
3432   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3433    (set_attr "type" "sselog")
3434    (set_attr "prefix" "orig,vex,evex,evex")
3435    (set (attr "mode")
3436         (cond [(eq_attr "alternative" "2")
3437                  (if_then_else (match_test "TARGET_AVX512DQ")
3438                                (const_string "<ssevecmode>")
3439                                (const_string "TI"))
3440                (eq_attr "alternative" "3")
3441                  (if_then_else (match_test "TARGET_AVX512DQ")
3442                                (const_string "<avx512fvecmode>")
3443                                (const_string "XI"))
3444                (and (match_test "<MODE_SIZE> == 16")
3445                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3446                  (const_string "V4SF")
3447                (match_test "TARGET_AVX")
3448                  (const_string "<ssevecmode>")
3449                (match_test "optimize_function_for_size_p (cfun)")
3450                  (const_string "V4SF")
3451                ]
3452                (const_string "<ssevecmode>")))])
3454 (define_insn "*andnottf3"
3455   [(set (match_operand:TF 0 "register_operand" "=x,x,v,v")
3456         (and:TF
3457           (not:TF (match_operand:TF 1 "register_operand" "0,x,v,v"))
3458           (match_operand:TF 2 "vector_operand" "xBm,xm,vm,v")))]
3459   "TARGET_SSE"
3461   static char buf[128];
3462   const char *ops;
3463   const char *tmp
3464     = (which_alternative >= 2 ? "pandnq"
3465        : get_attr_mode (insn) == MODE_V4SF ? "andnps" : "pandn");
3467   switch (which_alternative)
3468     {
3469     case 0:
3470       ops = "%s\t{%%2, %%0|%%0, %%2}";
3471       break;
3472     case 1:
3473     case 2:
3474       ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3475       break;
3476     case 3:
3477       ops = "v%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3478       break;
3479     default:
3480       gcc_unreachable ();
3481     }
3483   snprintf (buf, sizeof (buf), ops, tmp);
3484   return buf;
3486   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3487    (set_attr "type" "sselog")
3488    (set (attr "prefix_data16")
3489      (if_then_else
3490        (and (eq_attr "alternative" "0")
3491             (eq_attr "mode" "TI"))
3492        (const_string "1")
3493        (const_string "*")))
3494    (set_attr "prefix" "orig,vex,evex,evex")
3495    (set (attr "mode")
3496         (cond [(eq_attr "alternative" "2")
3497                  (const_string "TI")
3498                (eq_attr "alternative" "3")
3499                  (const_string "XI")
3500                (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
3501                  (const_string "V4SF")
3502                (match_test "TARGET_AVX")
3503                  (const_string "TI")
3504                (ior (not (match_test "TARGET_SSE2"))
3505                     (match_test "optimize_function_for_size_p (cfun)"))
3506                  (const_string "V4SF")
3507                ]
3508                (const_string "TI")))])
3510 (define_insn "*<code><mode>3"
3511   [(set (match_operand:MODEF 0 "register_operand" "=x,x,v,v")
3512         (any_logic:MODEF
3513           (match_operand:MODEF 1 "register_operand" "%0,x,v,v")
3514           (match_operand:MODEF 2 "register_operand" "x,x,v,v")))]
3515   "SSE_FLOAT_MODE_P (<MODE>mode)"
3517   static char buf[128];
3518   const char *ops;
3519   const char *suffix
3520     = (get_attr_mode (insn) == MODE_V4SF) ? "ps" : "<ssevecmodesuffix>";
3522   switch (which_alternative)
3523     {
3524     case 0:
3525       ops = "<logic>%s\t{%%2, %%0|%%0, %%2}";
3526       break;
3527     case 2:
3528       if (!TARGET_AVX512DQ)
3529         {
3530           suffix = <MODE>mode == DFmode ? "q" : "d";
3531           ops = "vp<logic>%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3532           break;
3533         }
3534       /* FALLTHRU */
3535     case 1:
3536       ops = "v<logic>%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3537       break;
3538     case 3:
3539       if (TARGET_AVX512DQ)
3540         ops = "v<logic>%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3541       else
3542         {
3543           suffix = <MODE>mode == DFmode ? "q" : "d";
3544           ops = "vp<logic>%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3545         }
3546       break;
3547     default:
3548       gcc_unreachable ();
3549     }
3551   snprintf (buf, sizeof (buf), ops, suffix);
3552   return buf;
3554   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3555    (set_attr "type" "sselog")
3556    (set_attr "prefix" "orig,vex,evex,evex")
3557    (set (attr "mode")
3558         (cond [(eq_attr "alternative" "2")
3559                  (if_then_else (match_test "TARGET_AVX512DQ")
3560                                (const_string "<ssevecmode>")
3561                                (const_string "TI"))
3562                (eq_attr "alternative" "3")
3563                  (if_then_else (match_test "TARGET_AVX512DQ")
3564                                (const_string "<avx512fvecmode>")
3565                                (const_string "XI"))
3566                (and (match_test "<MODE_SIZE> == 16")
3567                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3568                  (const_string "V4SF")
3569                (match_test "TARGET_AVX")
3570                  (const_string "<ssevecmode>")
3571                (match_test "optimize_function_for_size_p (cfun)")
3572                  (const_string "V4SF")
3573                ]
3574                (const_string "<ssevecmode>")))])
3576 (define_expand "<code>tf3"
3577   [(set (match_operand:TF 0 "register_operand")
3578         (any_logic:TF
3579           (match_operand:TF 1 "vector_operand")
3580           (match_operand:TF 2 "vector_operand")))]
3581   "TARGET_SSE"
3582   "ix86_fixup_binary_operands_no_copy (<CODE>, TFmode, operands);")
3584 (define_insn "*<code>tf3"
3585   [(set (match_operand:TF 0 "register_operand" "=x,x,v,v")
3586         (any_logic:TF
3587           (match_operand:TF 1 "vector_operand" "%0,x,v,v")
3588           (match_operand:TF 2 "vector_operand" "xBm,xm,vm,v")))]
3589   "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
3591   static char buf[128];
3592   const char *ops;
3593   const char *tmp
3594     = (which_alternative >= 2 ? "p<logic>q"
3595        : get_attr_mode (insn) == MODE_V4SF ? "<logic>ps" : "p<logic>");
3597   switch (which_alternative)
3598     {
3599     case 0:
3600       ops = "%s\t{%%2, %%0|%%0, %%2}";
3601       break;
3602     case 1:
3603     case 2:
3604       ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3605       break;
3606     case 3:
3607       ops = "v%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3608       break;
3609     default:
3610       gcc_unreachable ();
3611     }
3613   snprintf (buf, sizeof (buf), ops, tmp);
3614   return buf;
3616   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3617    (set_attr "type" "sselog")
3618    (set (attr "prefix_data16")
3619      (if_then_else
3620        (and (eq_attr "alternative" "0")
3621             (eq_attr "mode" "TI"))
3622        (const_string "1")
3623        (const_string "*")))
3624    (set_attr "prefix" "orig,vex,evex,evex")
3625    (set (attr "mode")
3626         (cond [(eq_attr "alternative" "2")
3627                  (const_string "TI")
3628                (eq_attr "alternative" "3")
3629                  (const_string "QI")
3630                (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
3631                  (const_string "V4SF")
3632                (match_test "TARGET_AVX")
3633                  (const_string "TI")
3634                (ior (not (match_test "TARGET_SSE2"))
3635                     (match_test "optimize_function_for_size_p (cfun)"))
3636                  (const_string "V4SF")
3637                ]
3638                (const_string "TI")))])
3640 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3642 ;; FMA floating point multiply/accumulate instructions.  These include
3643 ;; scalar versions of the instructions as well as vector versions.
3645 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3647 ;; The standard names for scalar FMA are only available with SSE math enabled.
3648 ;; CPUID bit AVX512F enables evex encoded scalar and 512-bit fma.  It doesn't
3649 ;; care about FMA bit, so we enable fma for TARGET_AVX512F even when TARGET_FMA
3650 ;; and TARGET_FMA4 are both false.
3651 ;; TODO: In theory AVX512F does not automatically imply FMA, and without FMA
3652 ;; one must force the EVEX encoding of the fma insns.  Ideally we'd improve
3653 ;; GAS to allow proper prefix selection.  However, for the moment all hardware
3654 ;; that supports AVX512F also supports FMA so we can ignore this for now.
3655 (define_mode_iterator FMAMODEM
3656   [(SF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
3657    (DF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
3658    (V4SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3659    (V2DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3660    (V8SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3661    (V4DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3662    (V16SF "TARGET_AVX512F")
3663    (V8DF "TARGET_AVX512F")])
3665 (define_expand "fma<mode>4"
3666   [(set (match_operand:FMAMODEM 0 "register_operand")
3667         (fma:FMAMODEM
3668           (match_operand:FMAMODEM 1 "nonimmediate_operand")
3669           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3670           (match_operand:FMAMODEM 3 "nonimmediate_operand")))])
3672 (define_expand "fms<mode>4"
3673   [(set (match_operand:FMAMODEM 0 "register_operand")
3674         (fma:FMAMODEM
3675           (match_operand:FMAMODEM 1 "nonimmediate_operand")
3676           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3677           (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))])
3679 (define_expand "fnma<mode>4"
3680   [(set (match_operand:FMAMODEM 0 "register_operand")
3681         (fma:FMAMODEM
3682           (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
3683           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3684           (match_operand:FMAMODEM 3 "nonimmediate_operand")))])
3686 (define_expand "fnms<mode>4"
3687   [(set (match_operand:FMAMODEM 0 "register_operand")
3688         (fma:FMAMODEM
3689           (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
3690           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3691           (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))])
3693 ;; The builtins for intrinsics are not constrained by SSE math enabled.
3694 (define_mode_iterator FMAMODE_AVX512
3695  [(SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
3696   (DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
3697   (V4SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3698   (V2DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3699   (V8SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3700   (V4DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3701   (V16SF "TARGET_AVX512F")
3702   (V8DF "TARGET_AVX512F")])
3704 (define_mode_iterator FMAMODE
3705   [SF DF V4SF V2DF V8SF V4DF])
3707 (define_expand "fma4i_fmadd_<mode>"
3708   [(set (match_operand:FMAMODE_AVX512 0 "register_operand")
3709         (fma:FMAMODE_AVX512
3710           (match_operand:FMAMODE_AVX512 1 "nonimmediate_operand")
3711           (match_operand:FMAMODE_AVX512 2 "nonimmediate_operand")
3712           (match_operand:FMAMODE_AVX512 3 "nonimmediate_operand")))])
3714 (define_expand "<avx512>_fmadd_<mode>_maskz<round_expand_name>"
3715   [(match_operand:VF_AVX512VL 0 "register_operand")
3716    (match_operand:VF_AVX512VL 1 "<round_expand_nimm_predicate>")
3717    (match_operand:VF_AVX512VL 2 "<round_expand_nimm_predicate>")
3718    (match_operand:VF_AVX512VL 3 "<round_expand_nimm_predicate>")
3719    (match_operand:<avx512fmaskmode> 4 "register_operand")]
3720   "TARGET_AVX512F && <round_mode512bit_condition>"
3722   emit_insn (gen_fma_fmadd_<mode>_maskz_1<round_expand_name> (
3723     operands[0], operands[1], operands[2], operands[3],
3724     CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
3725   DONE;
3728 (define_insn "*fma_fmadd_<mode>"
3729   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3730         (fma:FMAMODE
3731           (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x")
3732           (match_operand:FMAMODE 2 "nonimmediate_operand" "vm,v,vm,x,m")
3733           (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x")))]
3734   "TARGET_FMA || TARGET_FMA4"
3735   "@
3736    vfmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3737    vfmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3738    vfmadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3739    vfmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3740    vfmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3741   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3742    (set_attr "type" "ssemuladd")
3743    (set_attr "mode" "<MODE>")])
3745 ;; Suppose AVX-512F as baseline
3746 (define_mode_iterator VF_SF_AVX512VL
3747   [SF V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
3748    DF V8DF (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
3750 (define_insn "<sd_mask_codefor>fma_fmadd_<mode><sd_maskz_name><round_name>"
3751   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3752         (fma:VF_SF_AVX512VL
3753           (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v")
3754           (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3755           (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0")))]
3756   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3757   "@
3758    vfmadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3759    vfmadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3760    vfmadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3761   [(set_attr "type" "ssemuladd")
3762    (set_attr "mode" "<MODE>")])
3764 (define_insn "<avx512>_fmadd_<mode>_mask<round_name>"
3765   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3766         (vec_merge:VF_AVX512VL
3767           (fma:VF_AVX512VL
3768             (match_operand:VF_AVX512VL 1 "register_operand" "0,0")
3769             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3770             (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))
3771           (match_dup 1)
3772           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3773   "TARGET_AVX512F && <round_mode512bit_condition>"
3774   "@
3775    vfmadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3776    vfmadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3777   [(set_attr "type" "ssemuladd")
3778    (set_attr "mode" "<MODE>")])
3780 (define_insn "<avx512>_fmadd_<mode>_mask3<round_name>"
3781   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3782         (vec_merge:VF_AVX512VL
3783           (fma:VF_AVX512VL
3784             (match_operand:VF_AVX512VL 1 "register_operand" "v")
3785             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3786             (match_operand:VF_AVX512VL 3 "register_operand" "0"))
3787           (match_dup 3)
3788           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3789   "TARGET_AVX512F"
3790   "vfmadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3791   [(set_attr "type" "ssemuladd")
3792    (set_attr "mode" "<MODE>")])
3794 (define_insn "*fma_fmsub_<mode>"
3795   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3796         (fma:FMAMODE
3797           (match_operand:FMAMODE   1 "nonimmediate_operand" "%0,0,v,x,x")
3798           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
3799           (neg:FMAMODE
3800             (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x"))))]
3801   "TARGET_FMA || TARGET_FMA4"
3802   "@
3803    vfmsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3804    vfmsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3805    vfmsub231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3806    vfmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3807    vfmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3808   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3809    (set_attr "type" "ssemuladd")
3810    (set_attr "mode" "<MODE>")])
3812 (define_insn "<sd_mask_codefor>fma_fmsub_<mode><sd_maskz_name><round_name>"
3813   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3814         (fma:VF_SF_AVX512VL
3815           (match_operand:VF_SF_AVX512VL   1 "<round_nimm_predicate>" "%0,0,v")
3816           (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3817           (neg:VF_SF_AVX512VL
3818             (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))))]
3819   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3820   "@
3821    vfmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3822    vfmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3823    vfmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3824   [(set_attr "type" "ssemuladd")
3825    (set_attr "mode" "<MODE>")])
3827 (define_insn "<avx512>_fmsub_<mode>_mask<round_name>"
3828   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3829         (vec_merge:VF_AVX512VL
3830           (fma:VF_AVX512VL
3831             (match_operand:VF_AVX512VL 1 "register_operand" "0,0")
3832             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3833             (neg:VF_AVX512VL
3834               (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")))
3835           (match_dup 1)
3836           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3837   "TARGET_AVX512F"
3838   "@
3839    vfmsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3840    vfmsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3841   [(set_attr "type" "ssemuladd")
3842    (set_attr "mode" "<MODE>")])
3844 (define_insn "<avx512>_fmsub_<mode>_mask3<round_name>"
3845   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3846         (vec_merge:VF_AVX512VL
3847           (fma:VF_AVX512VL
3848             (match_operand:VF_AVX512VL 1 "register_operand" "v")
3849             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3850             (neg:VF_AVX512VL
3851               (match_operand:VF_AVX512VL 3 "register_operand" "0")))
3852           (match_dup 3)
3853           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3854   "TARGET_AVX512F && <round_mode512bit_condition>"
3855   "vfmsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3856   [(set_attr "type" "ssemuladd")
3857    (set_attr "mode" "<MODE>")])
3859 (define_insn "*fma_fnmadd_<mode>"
3860   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3861         (fma:FMAMODE
3862           (neg:FMAMODE
3863             (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x"))
3864           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
3865           (match_operand:FMAMODE   3 "nonimmediate_operand" "v,vm,0,xm,x")))]
3866   "TARGET_FMA || TARGET_FMA4"
3867   "@
3868    vfnmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3869    vfnmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3870    vfnmadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3871    vfnmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3872    vfnmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3873   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3874    (set_attr "type" "ssemuladd")
3875    (set_attr "mode" "<MODE>")])
3877 (define_insn "<sd_mask_codefor>fma_fnmadd_<mode><sd_maskz_name><round_name>"
3878   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3879         (fma:VF_SF_AVX512VL
3880           (neg:VF_SF_AVX512VL
3881             (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v"))
3882           (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3883           (match_operand:VF_SF_AVX512VL   3 "<round_nimm_predicate>" "v,<round_constraint>,0")))]
3884   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3885   "@
3886    vfnmadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3887    vfnmadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3888    vfnmadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3889   [(set_attr "type" "ssemuladd")
3890    (set_attr "mode" "<MODE>")])
3892 (define_insn "<avx512>_fnmadd_<mode>_mask<round_name>"
3893   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3894         (vec_merge:VF_AVX512VL
3895           (fma:VF_AVX512VL
3896             (neg:VF_AVX512VL
3897               (match_operand:VF_AVX512VL 1 "register_operand" "0,0"))
3898             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3899             (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))
3900           (match_dup 1)
3901           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3902   "TARGET_AVX512F && <round_mode512bit_condition>"
3903   "@
3904    vfnmadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3905    vfnmadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3906   [(set_attr "type" "ssemuladd")
3907    (set_attr "mode" "<MODE>")])
3909 (define_insn "<avx512>_fnmadd_<mode>_mask3<round_name>"
3910   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3911         (vec_merge:VF_AVX512VL
3912           (fma:VF_AVX512VL
3913             (neg:VF_AVX512VL
3914               (match_operand:VF_AVX512VL 1 "register_operand" "v"))
3915             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3916             (match_operand:VF_AVX512VL 3 "register_operand" "0"))
3917           (match_dup 3)
3918           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3919   "TARGET_AVX512F && <round_mode512bit_condition>"
3920   "vfnmadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3921   [(set_attr "type" "ssemuladd")
3922    (set_attr "mode" "<MODE>")])
3924 (define_insn "*fma_fnmsub_<mode>"
3925   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3926         (fma:FMAMODE
3927           (neg:FMAMODE
3928             (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x"))
3929           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
3930           (neg:FMAMODE
3931             (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x"))))]
3932   "TARGET_FMA || TARGET_FMA4"
3933   "@
3934    vfnmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3935    vfnmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3936    vfnmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}
3937    vfnmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3938    vfnmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3939   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3940    (set_attr "type" "ssemuladd")
3941    (set_attr "mode" "<MODE>")])
3943 (define_insn "<sd_mask_codefor>fma_fnmsub_<mode><sd_maskz_name><round_name>"
3944   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3945         (fma:VF_SF_AVX512VL
3946           (neg:VF_SF_AVX512VL
3947             (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v"))
3948           (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3949           (neg:VF_SF_AVX512VL
3950             (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))))]
3951   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3952   "@
3953    vfnmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3954    vfnmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3955    vfnmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3956   [(set_attr "type" "ssemuladd")
3957    (set_attr "mode" "<MODE>")])
3959 (define_insn "<avx512>_fnmsub_<mode>_mask<round_name>"
3960   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3961         (vec_merge:VF_AVX512VL
3962           (fma:VF_AVX512VL
3963             (neg:VF_AVX512VL
3964               (match_operand:VF_AVX512VL 1 "register_operand" "0,0"))
3965             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3966             (neg:VF_AVX512VL
3967               (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")))
3968           (match_dup 1)
3969           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3970   "TARGET_AVX512F && <round_mode512bit_condition>"
3971   "@
3972    vfnmsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3973    vfnmsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3974   [(set_attr "type" "ssemuladd")
3975    (set_attr "mode" "<MODE>")])
3977 (define_insn "<avx512>_fnmsub_<mode>_mask3<round_name>"
3978   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3979         (vec_merge:VF_AVX512VL
3980           (fma:VF_AVX512VL
3981             (neg:VF_AVX512VL
3982               (match_operand:VF_AVX512VL 1 "register_operand" "v"))
3983             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3984             (neg:VF_AVX512VL
3985               (match_operand:VF_AVX512VL 3 "register_operand" "0")))
3986           (match_dup 3)
3987           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3988   "TARGET_AVX512F"
3989   "vfnmsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3990   [(set_attr "type" "ssemuladd")
3991    (set_attr "mode" "<MODE>")])
3993 ;; FMA parallel floating point multiply addsub and subadd operations.
3995 ;; It would be possible to represent these without the UNSPEC as
3997 ;; (vec_merge
3998 ;;   (fma op1 op2 op3)
3999 ;;   (fma op1 op2 (neg op3))
4000 ;;   (merge-const))
4002 ;; But this doesn't seem useful in practice.
4004 (define_expand "fmaddsub_<mode>"
4005   [(set (match_operand:VF 0 "register_operand")
4006         (unspec:VF
4007           [(match_operand:VF 1 "nonimmediate_operand")
4008            (match_operand:VF 2 "nonimmediate_operand")
4009            (match_operand:VF 3 "nonimmediate_operand")]
4010           UNSPEC_FMADDSUB))]
4011   "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
4013 (define_expand "<avx512>_fmaddsub_<mode>_maskz<round_expand_name>"
4014   [(match_operand:VF_AVX512VL 0 "register_operand")
4015    (match_operand:VF_AVX512VL 1 "<round_expand_nimm_predicate>")
4016    (match_operand:VF_AVX512VL 2 "<round_expand_nimm_predicate>")
4017    (match_operand:VF_AVX512VL 3 "<round_expand_nimm_predicate>")
4018    (match_operand:<avx512fmaskmode> 4 "register_operand")]
4019   "TARGET_AVX512F"
4021   emit_insn (gen_fma_fmaddsub_<mode>_maskz_1<round_expand_name> (
4022     operands[0], operands[1], operands[2], operands[3],
4023     CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
4024   DONE;
4027 (define_insn "*fma_fmaddsub_<mode>"
4028   [(set (match_operand:VF_128_256 0 "register_operand" "=v,v,v,x,x")
4029         (unspec:VF_128_256
4030           [(match_operand:VF_128_256 1 "nonimmediate_operand" "%0,0,v,x,x")
4031            (match_operand:VF_128_256 2 "nonimmediate_operand" "vm,v,vm,x,m")
4032            (match_operand:VF_128_256 3 "nonimmediate_operand" "v,vm,0,xm,x")]
4033           UNSPEC_FMADDSUB))]
4034   "TARGET_FMA || TARGET_FMA4"
4035   "@
4036    vfmaddsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
4037    vfmaddsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
4038    vfmaddsub231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
4039    vfmaddsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
4040    vfmaddsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4041   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
4042    (set_attr "type" "ssemuladd")
4043    (set_attr "mode" "<MODE>")])
4045 (define_insn "<sd_mask_codefor>fma_fmaddsub_<mode><sd_maskz_name><round_name>"
4046   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
4047         (unspec:VF_SF_AVX512VL
4048           [(match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v")
4049            (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
4050            (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0")]
4051           UNSPEC_FMADDSUB))]
4052   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
4053   "@
4054    vfmaddsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
4055    vfmaddsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
4056    vfmaddsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
4057   [(set_attr "type" "ssemuladd")
4058    (set_attr "mode" "<MODE>")])
4060 (define_insn "<avx512>_fmaddsub_<mode>_mask<round_name>"
4061   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
4062         (vec_merge:VF_AVX512VL
4063           (unspec:VF_AVX512VL
4064             [(match_operand:VF_AVX512VL 1 "register_operand" "0,0")
4065              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
4066              (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")]
4067             UNSPEC_FMADDSUB)
4068           (match_dup 1)
4069           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
4070   "TARGET_AVX512F"
4071   "@
4072    vfmaddsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
4073    vfmaddsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
4074   [(set_attr "type" "ssemuladd")
4075    (set_attr "mode" "<MODE>")])
4077 (define_insn "<avx512>_fmaddsub_<mode>_mask3<round_name>"
4078   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
4079         (vec_merge:VF_AVX512VL
4080           (unspec:VF_AVX512VL
4081             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
4082              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
4083              (match_operand:VF_AVX512VL 3 "register_operand" "0")]
4084             UNSPEC_FMADDSUB)
4085           (match_dup 3)
4086           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
4087   "TARGET_AVX512F"
4088   "vfmaddsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
4089   [(set_attr "type" "ssemuladd")
4090    (set_attr "mode" "<MODE>")])
4092 (define_insn "*fma_fmsubadd_<mode>"
4093   [(set (match_operand:VF_128_256 0 "register_operand" "=v,v,v,x,x")
4094         (unspec:VF_128_256
4095           [(match_operand:VF_128_256   1 "nonimmediate_operand" "%0,0,v,x,x")
4096            (match_operand:VF_128_256   2 "nonimmediate_operand" "vm,v,vm,x,m")
4097            (neg:VF_128_256
4098              (match_operand:VF_128_256 3 "nonimmediate_operand" "v,vm,0,xm,x"))]
4099           UNSPEC_FMADDSUB))]
4100   "TARGET_FMA || TARGET_FMA4"
4101   "@
4102    vfmsubadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
4103    vfmsubadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
4104    vfmsubadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
4105    vfmsubadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
4106    vfmsubadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4107   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
4108    (set_attr "type" "ssemuladd")
4109    (set_attr "mode" "<MODE>")])
4111 (define_insn "<sd_mask_codefor>fma_fmsubadd_<mode><sd_maskz_name><round_name>"
4112   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
4113         (unspec:VF_SF_AVX512VL
4114           [(match_operand:VF_SF_AVX512VL   1 "<round_nimm_predicate>" "%0,0,v")
4115            (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
4116            (neg:VF_SF_AVX512VL
4117              (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))]
4118           UNSPEC_FMADDSUB))]
4119   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
4120   "@
4121    vfmsubadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
4122    vfmsubadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
4123    vfmsubadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
4124   [(set_attr "type" "ssemuladd")
4125    (set_attr "mode" "<MODE>")])
4127 (define_insn "<avx512>_fmsubadd_<mode>_mask<round_name>"
4128   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
4129         (vec_merge:VF_AVX512VL
4130           (unspec:VF_AVX512VL
4131             [(match_operand:VF_AVX512VL 1 "register_operand" "0,0")
4132              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
4133              (neg:VF_AVX512VL
4134                (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))]
4135             UNSPEC_FMADDSUB)
4136           (match_dup 1)
4137           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
4138   "TARGET_AVX512F"
4139   "@
4140    vfmsubadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
4141    vfmsubadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
4142   [(set_attr "type" "ssemuladd")
4143    (set_attr "mode" "<MODE>")])
4145 (define_insn "<avx512>_fmsubadd_<mode>_mask3<round_name>"
4146   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
4147         (vec_merge:VF_AVX512VL
4148           (unspec:VF_AVX512VL
4149             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
4150              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
4151              (neg:VF_AVX512VL
4152                (match_operand:VF_AVX512VL 3 "register_operand" "0"))]
4153             UNSPEC_FMADDSUB)
4154           (match_dup 3)
4155           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
4156   "TARGET_AVX512F"
4157   "vfmsubadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
4158   [(set_attr "type" "ssemuladd")
4159    (set_attr "mode" "<MODE>")])
4161 ;; FMA3 floating point scalar intrinsics. These merge result with
4162 ;; high-order elements from the destination register.
4164 (define_expand "fmai_vmfmadd_<mode><round_name>"
4165   [(set (match_operand:VF_128 0 "register_operand")
4166         (vec_merge:VF_128
4167           (fma:VF_128
4168             (match_operand:VF_128 1 "<round_nimm_predicate>")
4169             (match_operand:VF_128 2 "<round_nimm_predicate>")
4170             (match_operand:VF_128 3 "<round_nimm_predicate>"))
4171           (match_dup 1)
4172           (const_int 1)))]
4173   "TARGET_FMA")
4175 (define_insn "*fmai_fmadd_<mode>"
4176   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4177         (vec_merge:VF_128
4178           (fma:VF_128
4179             (match_operand:VF_128 1 "<round_nimm_predicate>" " 0, 0")
4180             (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>, v")
4181             (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>"))
4182           (match_dup 1)
4183           (const_int 1)))]
4184   "TARGET_FMA || TARGET_AVX512F"
4185   "@
4186    vfmadd132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4187    vfmadd213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4188   [(set_attr "type" "ssemuladd")
4189    (set_attr "mode" "<MODE>")])
4191 (define_insn "*fmai_fmsub_<mode>"
4192   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4193         (vec_merge:VF_128
4194           (fma:VF_128
4195             (match_operand:VF_128   1 "<round_nimm_predicate>" "0,0")
4196             (match_operand:VF_128   2 "<round_nimm_predicate>" "<round_constraint>,v")
4197             (neg:VF_128
4198               (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>")))
4199           (match_dup 1)
4200           (const_int 1)))]
4201   "TARGET_FMA || TARGET_AVX512F"
4202   "@
4203    vfmsub132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4204    vfmsub213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4205   [(set_attr "type" "ssemuladd")
4206    (set_attr "mode" "<MODE>")])
4208 (define_insn "*fmai_fnmadd_<mode><round_name>"
4209   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4210         (vec_merge:VF_128
4211           (fma:VF_128
4212             (neg:VF_128
4213               (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>,v"))
4214             (match_operand:VF_128   1 "<round_nimm_predicate>" "0,0")
4215             (match_operand:VF_128   3 "<round_nimm_predicate>" "v,<round_constraint>"))
4216           (match_dup 1)
4217           (const_int 1)))]
4218   "TARGET_FMA || TARGET_AVX512F"
4219   "@
4220    vfnmadd132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4221    vfnmadd213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4222   [(set_attr "type" "ssemuladd")
4223    (set_attr "mode" "<MODE>")])
4225 (define_insn "*fmai_fnmsub_<mode><round_name>"
4226   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4227         (vec_merge:VF_128
4228           (fma:VF_128
4229             (neg:VF_128
4230               (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>, v"))
4231             (match_operand:VF_128   1 "<round_nimm_predicate>" " 0, 0")
4232             (neg:VF_128
4233               (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>")))
4234           (match_dup 1)
4235           (const_int 1)))]
4236   "TARGET_FMA || TARGET_AVX512F"
4237   "@
4238    vfnmsub132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4239    vfnmsub213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4240   [(set_attr "type" "ssemuladd")
4241    (set_attr "mode" "<MODE>")])
4243 ;; FMA4 floating point scalar intrinsics.  These write the
4244 ;; entire destination register, with the high-order elements zeroed.
4246 (define_expand "fma4i_vmfmadd_<mode>"
4247   [(set (match_operand:VF_128 0 "register_operand")
4248         (vec_merge:VF_128
4249           (fma:VF_128
4250             (match_operand:VF_128 1 "nonimmediate_operand")
4251             (match_operand:VF_128 2 "nonimmediate_operand")
4252             (match_operand:VF_128 3 "nonimmediate_operand"))
4253           (match_dup 4)
4254           (const_int 1)))]
4255   "TARGET_FMA4"
4256   "operands[4] = CONST0_RTX (<MODE>mode);")
4258 (define_insn "*fma4i_vmfmadd_<mode>"
4259   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4260         (vec_merge:VF_128
4261           (fma:VF_128
4262             (match_operand:VF_128 1 "nonimmediate_operand" "%x,x")
4263             (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
4264             (match_operand:VF_128 3 "nonimmediate_operand" "xm,x"))
4265           (match_operand:VF_128 4 "const0_operand")
4266           (const_int 1)))]
4267   "TARGET_FMA4"
4268   "vfmadd<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4269   [(set_attr "type" "ssemuladd")
4270    (set_attr "mode" "<MODE>")])
4272 (define_insn "*fma4i_vmfmsub_<mode>"
4273   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4274         (vec_merge:VF_128
4275           (fma:VF_128
4276             (match_operand:VF_128 1 "nonimmediate_operand" "%x,x")
4277             (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
4278             (neg:VF_128
4279               (match_operand:VF_128 3 "nonimmediate_operand" "xm,x")))
4280           (match_operand:VF_128 4 "const0_operand")
4281           (const_int 1)))]
4282   "TARGET_FMA4"
4283   "vfmsub<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4284   [(set_attr "type" "ssemuladd")
4285    (set_attr "mode" "<MODE>")])
4287 (define_insn "*fma4i_vmfnmadd_<mode>"
4288   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4289         (vec_merge:VF_128
4290           (fma:VF_128
4291             (neg:VF_128
4292               (match_operand:VF_128 1 "nonimmediate_operand" "%x,x"))
4293             (match_operand:VF_128   2 "nonimmediate_operand" " x,m")
4294             (match_operand:VF_128   3 "nonimmediate_operand" "xm,x"))
4295           (match_operand:VF_128 4 "const0_operand")
4296           (const_int 1)))]
4297   "TARGET_FMA4"
4298   "vfnmadd<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4299   [(set_attr "type" "ssemuladd")
4300    (set_attr "mode" "<MODE>")])
4302 (define_insn "*fma4i_vmfnmsub_<mode>"
4303   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4304         (vec_merge:VF_128
4305           (fma:VF_128
4306             (neg:VF_128
4307               (match_operand:VF_128 1 "nonimmediate_operand" "%x,x"))
4308             (match_operand:VF_128   2 "nonimmediate_operand" " x,m")
4309             (neg:VF_128
4310               (match_operand:VF_128   3 "nonimmediate_operand" "xm,x")))
4311           (match_operand:VF_128 4 "const0_operand")
4312           (const_int 1)))]
4313   "TARGET_FMA4"
4314   "vfnmsub<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4315   [(set_attr "type" "ssemuladd")
4316    (set_attr "mode" "<MODE>")])
4318 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4320 ;; Parallel single-precision floating point conversion operations
4322 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4324 (define_insn "sse_cvtpi2ps"
4325   [(set (match_operand:V4SF 0 "register_operand" "=x")
4326         (vec_merge:V4SF
4327           (vec_duplicate:V4SF
4328             (float:V2SF (match_operand:V2SI 2 "nonimmediate_operand" "ym")))
4329           (match_operand:V4SF 1 "register_operand" "0")
4330           (const_int 3)))]
4331   "TARGET_SSE"
4332   "cvtpi2ps\t{%2, %0|%0, %2}"
4333   [(set_attr "type" "ssecvt")
4334    (set_attr "mode" "V4SF")])
4336 (define_insn "sse_cvtps2pi"
4337   [(set (match_operand:V2SI 0 "register_operand" "=y")
4338         (vec_select:V2SI
4339           (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
4340                        UNSPEC_FIX_NOTRUNC)
4341           (parallel [(const_int 0) (const_int 1)])))]
4342   "TARGET_SSE"
4343   "cvtps2pi\t{%1, %0|%0, %q1}"
4344   [(set_attr "type" "ssecvt")
4345    (set_attr "unit" "mmx")
4346    (set_attr "mode" "DI")])
4348 (define_insn "sse_cvttps2pi"
4349   [(set (match_operand:V2SI 0 "register_operand" "=y")
4350         (vec_select:V2SI
4351           (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
4352           (parallel [(const_int 0) (const_int 1)])))]
4353   "TARGET_SSE"
4354   "cvttps2pi\t{%1, %0|%0, %q1}"
4355   [(set_attr "type" "ssecvt")
4356    (set_attr "unit" "mmx")
4357    (set_attr "prefix_rep" "0")
4358    (set_attr "mode" "SF")])
4360 (define_insn "sse_cvtsi2ss<round_name>"
4361   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
4362         (vec_merge:V4SF
4363           (vec_duplicate:V4SF
4364             (float:SF (match_operand:SI 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
4365           (match_operand:V4SF 1 "register_operand" "0,0,v")
4366           (const_int 1)))]
4367   "TARGET_SSE"
4368   "@
4369    cvtsi2ss\t{%2, %0|%0, %2}
4370    cvtsi2ss\t{%2, %0|%0, %2}
4371    vcvtsi2ss\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4372   [(set_attr "isa" "noavx,noavx,avx")
4373    (set_attr "type" "sseicvt")
4374    (set_attr "athlon_decode" "vector,double,*")
4375    (set_attr "amdfam10_decode" "vector,double,*")
4376    (set_attr "bdver1_decode" "double,direct,*")
4377    (set_attr "btver2_decode" "double,double,double")
4378    (set_attr "znver1_decode" "double,double,double")
4379    (set_attr "prefix" "orig,orig,maybe_evex")
4380    (set_attr "mode" "SF")])
4382 (define_insn "sse_cvtsi2ssq<round_name>"
4383   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
4384         (vec_merge:V4SF
4385           (vec_duplicate:V4SF
4386             (float:SF (match_operand:DI 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
4387           (match_operand:V4SF 1 "register_operand" "0,0,v")
4388           (const_int 1)))]
4389   "TARGET_SSE && TARGET_64BIT"
4390   "@
4391    cvtsi2ssq\t{%2, %0|%0, %2}
4392    cvtsi2ssq\t{%2, %0|%0, %2}
4393    vcvtsi2ssq\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4394   [(set_attr "isa" "noavx,noavx,avx")
4395    (set_attr "type" "sseicvt")
4396    (set_attr "athlon_decode" "vector,double,*")
4397    (set_attr "amdfam10_decode" "vector,double,*")
4398    (set_attr "bdver1_decode" "double,direct,*")
4399    (set_attr "btver2_decode" "double,double,double")
4400    (set_attr "length_vex" "*,*,4")
4401    (set_attr "prefix_rex" "1,1,*")
4402    (set_attr "prefix" "orig,orig,maybe_evex")
4403    (set_attr "mode" "SF")])
4405 (define_insn "sse_cvtss2si<round_name>"
4406   [(set (match_operand:SI 0 "register_operand" "=r,r")
4407         (unspec:SI
4408           [(vec_select:SF
4409              (match_operand:V4SF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4410              (parallel [(const_int 0)]))]
4411           UNSPEC_FIX_NOTRUNC))]
4412   "TARGET_SSE"
4413   "%vcvtss2si\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
4414   [(set_attr "type" "sseicvt")
4415    (set_attr "athlon_decode" "double,vector")
4416    (set_attr "bdver1_decode" "double,double")
4417    (set_attr "prefix_rep" "1")
4418    (set_attr "prefix" "maybe_vex")
4419    (set_attr "mode" "SI")])
4421 (define_insn "sse_cvtss2si_2"
4422   [(set (match_operand:SI 0 "register_operand" "=r,r")
4423         (unspec:SI [(match_operand:SF 1 "nonimmediate_operand" "v,m")]
4424                    UNSPEC_FIX_NOTRUNC))]
4425   "TARGET_SSE"
4426   "%vcvtss2si\t{%1, %0|%0, %k1}"
4427   [(set_attr "type" "sseicvt")
4428    (set_attr "athlon_decode" "double,vector")
4429    (set_attr "amdfam10_decode" "double,double")
4430    (set_attr "bdver1_decode" "double,double")
4431    (set_attr "prefix_rep" "1")
4432    (set_attr "prefix" "maybe_vex")
4433    (set_attr "mode" "SI")])
4435 (define_insn "sse_cvtss2siq<round_name>"
4436   [(set (match_operand:DI 0 "register_operand" "=r,r")
4437         (unspec:DI
4438           [(vec_select:SF
4439              (match_operand:V4SF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4440              (parallel [(const_int 0)]))]
4441           UNSPEC_FIX_NOTRUNC))]
4442   "TARGET_SSE && TARGET_64BIT"
4443   "%vcvtss2si{q}\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
4444   [(set_attr "type" "sseicvt")
4445    (set_attr "athlon_decode" "double,vector")
4446    (set_attr "bdver1_decode" "double,double")
4447    (set_attr "prefix_rep" "1")
4448    (set_attr "prefix" "maybe_vex")
4449    (set_attr "mode" "DI")])
4451 (define_insn "sse_cvtss2siq_2"
4452   [(set (match_operand:DI 0 "register_operand" "=r,r")
4453         (unspec:DI [(match_operand:SF 1 "nonimmediate_operand" "v,m")]
4454                    UNSPEC_FIX_NOTRUNC))]
4455   "TARGET_SSE && TARGET_64BIT"
4456   "%vcvtss2si{q}\t{%1, %0|%0, %k1}"
4457   [(set_attr "type" "sseicvt")
4458    (set_attr "athlon_decode" "double,vector")
4459    (set_attr "amdfam10_decode" "double,double")
4460    (set_attr "bdver1_decode" "double,double")
4461    (set_attr "prefix_rep" "1")
4462    (set_attr "prefix" "maybe_vex")
4463    (set_attr "mode" "DI")])
4465 (define_insn "sse_cvttss2si<round_saeonly_name>"
4466   [(set (match_operand:SI 0 "register_operand" "=r,r")
4467         (fix:SI
4468           (vec_select:SF
4469             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint2>")
4470             (parallel [(const_int 0)]))))]
4471   "TARGET_SSE"
4472   "%vcvttss2si\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
4473   [(set_attr "type" "sseicvt")
4474    (set_attr "athlon_decode" "double,vector")
4475    (set_attr "amdfam10_decode" "double,double")
4476    (set_attr "bdver1_decode" "double,double")
4477    (set_attr "prefix_rep" "1")
4478    (set_attr "prefix" "maybe_vex")
4479    (set_attr "mode" "SI")])
4481 (define_insn "sse_cvttss2siq<round_saeonly_name>"
4482   [(set (match_operand:DI 0 "register_operand" "=r,r")
4483         (fix:DI
4484           (vec_select:SF
4485             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint>")
4486             (parallel [(const_int 0)]))))]
4487   "TARGET_SSE && TARGET_64BIT"
4488   "%vcvttss2si{q}\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
4489   [(set_attr "type" "sseicvt")
4490    (set_attr "athlon_decode" "double,vector")
4491    (set_attr "amdfam10_decode" "double,double")
4492    (set_attr "bdver1_decode" "double,double")
4493    (set_attr "prefix_rep" "1")
4494    (set_attr "prefix" "maybe_vex")
4495    (set_attr "mode" "DI")])
4497 (define_insn "cvtusi2<ssescalarmodesuffix>32<round_name>"
4498   [(set (match_operand:VF_128 0 "register_operand" "=v")
4499         (vec_merge:VF_128
4500           (vec_duplicate:VF_128
4501             (unsigned_float:<ssescalarmode>
4502               (match_operand:SI 2 "<round_nimm_predicate>" "<round_constraint3>")))
4503           (match_operand:VF_128 1 "register_operand" "v")
4504           (const_int 1)))]
4505   "TARGET_AVX512F && <round_modev4sf_condition>"
4506   "vcvtusi2<ssescalarmodesuffix>\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4507   [(set_attr "type" "sseicvt")
4508    (set_attr "prefix" "evex")
4509    (set_attr "mode" "<ssescalarmode>")])
4511 (define_insn "cvtusi2<ssescalarmodesuffix>64<round_name>"
4512   [(set (match_operand:VF_128 0 "register_operand" "=v")
4513         (vec_merge:VF_128
4514           (vec_duplicate:VF_128
4515             (unsigned_float:<ssescalarmode>
4516               (match_operand:DI 2 "<round_nimm_predicate>" "<round_constraint3>")))
4517           (match_operand:VF_128 1 "register_operand" "v")
4518           (const_int 1)))]
4519   "TARGET_AVX512F && TARGET_64BIT"
4520   "vcvtusi2<ssescalarmodesuffix>\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4521   [(set_attr "type" "sseicvt")
4522    (set_attr "prefix" "evex")
4523    (set_attr "mode" "<ssescalarmode>")])
4525 (define_insn "float<sseintvecmodelower><mode>2<mask_name><round_name>"
4526   [(set (match_operand:VF1 0 "register_operand" "=x,v")
4527         (float:VF1
4528           (match_operand:<sseintvecmode> 1 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
4529   "TARGET_SSE2 && <mask_mode512bit_condition> && <round_mode512bit_condition>"
4530   "@
4531    cvtdq2ps\t{%1, %0|%0, %1}
4532    vcvtdq2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4533   [(set_attr "isa" "noavx,avx")
4534    (set_attr "type" "ssecvt")
4535    (set_attr "prefix" "maybe_vex")
4536    (set_attr "mode" "<sseinsnmode>")])
4538 (define_insn "ufloat<sseintvecmodelower><mode>2<mask_name><round_name>"
4539   [(set (match_operand:VF1_AVX512VL 0 "register_operand" "=v")
4540         (unsigned_float:VF1_AVX512VL
4541           (match_operand:<sseintvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
4542   "TARGET_AVX512F"
4543   "vcvtudq2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4544   [(set_attr "type" "ssecvt")
4545    (set_attr "prefix" "evex")
4546    (set_attr "mode" "<MODE>")])
4548 (define_expand "floatuns<sseintvecmodelower><mode>2"
4549   [(match_operand:VF1 0 "register_operand")
4550    (match_operand:<sseintvecmode> 1 "register_operand")]
4551   "TARGET_SSE2 && (<MODE>mode == V4SFmode || TARGET_AVX2)"
4553   if (<MODE>mode == V16SFmode)
4554     emit_insn (gen_ufloatv16siv16sf2 (operands[0], operands[1]));
4555   else
4556     if (TARGET_AVX512VL)
4557       {
4558         if (<MODE>mode == V4SFmode)
4559           emit_insn (gen_ufloatv4siv4sf2 (operands[0], operands[1]));
4560         else
4561           emit_insn (gen_ufloatv8siv8sf2 (operands[0], operands[1]));
4562       }
4563   else
4564     ix86_expand_vector_convert_uns_vsivsf (operands[0], operands[1]);
4566   DONE;
4570 ;; For <sse2_avx_avx512f>_fix_notrunc<sf2simodelower><mode> insn pattern
4571 (define_mode_attr sf2simodelower
4572   [(V16SI "v16sf") (V8SI "v8sf") (V4SI "v4sf")])
4574 (define_insn "<sse2_avx_avx512f>_fix_notrunc<sf2simodelower><mode><mask_name>"
4575   [(set (match_operand:VI4_AVX 0 "register_operand" "=v")
4576         (unspec:VI4_AVX
4577           [(match_operand:<ssePSmode> 1 "vector_operand" "vBm")]
4578           UNSPEC_FIX_NOTRUNC))]
4579   "TARGET_SSE2 && <mask_mode512bit_condition>"
4580   "%vcvtps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4581   [(set_attr "type" "ssecvt")
4582    (set (attr "prefix_data16")
4583      (if_then_else
4584        (match_test "TARGET_AVX")
4585      (const_string "*")
4586      (const_string "1")))
4587    (set_attr "prefix" "maybe_vex")
4588    (set_attr "mode" "<sseinsnmode>")])
4590 (define_insn "avx512f_fix_notruncv16sfv16si<mask_name><round_name>"
4591   [(set (match_operand:V16SI 0 "register_operand" "=v")
4592         (unspec:V16SI
4593           [(match_operand:V16SF 1 "<round_nimm_predicate>" "<round_constraint>")]
4594           UNSPEC_FIX_NOTRUNC))]
4595   "TARGET_AVX512F"
4596   "vcvtps2dq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4597   [(set_attr "type" "ssecvt")
4598    (set_attr "prefix" "evex")
4599    (set_attr "mode" "XI")])
4601 (define_insn "<mask_codefor><avx512>_ufix_notrunc<sf2simodelower><mode><mask_name><round_name>"
4602   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
4603         (unspec:VI4_AVX512VL
4604           [(match_operand:<ssePSmode> 1 "nonimmediate_operand" "<round_constraint>")]
4605           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4606   "TARGET_AVX512F"
4607   "vcvtps2udq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4608   [(set_attr "type" "ssecvt")
4609    (set_attr "prefix" "evex")
4610    (set_attr "mode" "<sseinsnmode>")])
4612 (define_insn "<mask_codefor>avx512dq_cvtps2qq<mode><mask_name><round_name>"
4613   [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
4614         (unspec:VI8_256_512 [(match_operand:<ssePSmode2> 1 "nonimmediate_operand" "<round_constraint>")]
4615                      UNSPEC_FIX_NOTRUNC))]
4616   "TARGET_AVX512DQ && <round_mode512bit_condition>"
4617   "vcvtps2qq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4618   [(set_attr "type" "ssecvt")
4619    (set_attr "prefix" "evex")
4620    (set_attr "mode" "<sseinsnmode>")])
4622 (define_insn "<mask_codefor>avx512dq_cvtps2qqv2di<mask_name>"
4623   [(set (match_operand:V2DI 0 "register_operand" "=v")
4624         (unspec:V2DI
4625           [(vec_select:V2SF
4626              (match_operand:V4SF 1 "nonimmediate_operand" "vm")
4627              (parallel [(const_int 0) (const_int 1)]))]
4628           UNSPEC_FIX_NOTRUNC))]
4629   "TARGET_AVX512DQ && TARGET_AVX512VL"
4630   "vcvtps2qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
4631   [(set_attr "type" "ssecvt")
4632    (set_attr "prefix" "evex")
4633    (set_attr "mode" "TI")])
4635 (define_insn "<mask_codefor>avx512dq_cvtps2uqq<mode><mask_name><round_name>"
4636   [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
4637         (unspec:VI8_256_512 [(match_operand:<ssePSmode2> 1 "nonimmediate_operand" "<round_constraint>")]
4638                      UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4639   "TARGET_AVX512DQ && <round_mode512bit_condition>"
4640   "vcvtps2uqq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4641   [(set_attr "type" "ssecvt")
4642    (set_attr "prefix" "evex")
4643    (set_attr "mode" "<sseinsnmode>")])
4645 (define_insn "<mask_codefor>avx512dq_cvtps2uqqv2di<mask_name>"
4646   [(set (match_operand:V2DI 0 "register_operand" "=v")
4647         (unspec:V2DI
4648           [(vec_select:V2SF
4649              (match_operand:V4SF 1 "nonimmediate_operand" "vm")
4650              (parallel [(const_int 0) (const_int 1)]))]
4651           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4652   "TARGET_AVX512DQ && TARGET_AVX512VL"
4653   "vcvtps2uqq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
4654   [(set_attr "type" "ssecvt")
4655    (set_attr "prefix" "evex")
4656    (set_attr "mode" "TI")])
4658 (define_insn "<fixsuffix>fix_truncv16sfv16si2<mask_name><round_saeonly_name>"
4659   [(set (match_operand:V16SI 0 "register_operand" "=v")
4660         (any_fix:V16SI
4661           (match_operand:V16SF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
4662   "TARGET_AVX512F"
4663   "vcvttps2<fixsuffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
4664   [(set_attr "type" "ssecvt")
4665    (set_attr "prefix" "evex")
4666    (set_attr "mode" "XI")])
4668 (define_insn "fix_truncv8sfv8si2<mask_name>"
4669   [(set (match_operand:V8SI 0 "register_operand" "=v")
4670         (fix:V8SI (match_operand:V8SF 1 "nonimmediate_operand" "vm")))]
4671   "TARGET_AVX && <mask_avx512vl_condition>"
4672   "vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4673   [(set_attr "type" "ssecvt")
4674    (set_attr "prefix" "<mask_prefix>")
4675    (set_attr "mode" "OI")])
4677 (define_insn "fix_truncv4sfv4si2<mask_name>"
4678   [(set (match_operand:V4SI 0 "register_operand" "=v")
4679         (fix:V4SI (match_operand:V4SF 1 "vector_operand" "vBm")))]
4680   "TARGET_SSE2 && <mask_avx512vl_condition>"
4681   "%vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4682   [(set_attr "type" "ssecvt")
4683    (set (attr "prefix_rep")
4684      (if_then_else
4685        (match_test "TARGET_AVX")
4686      (const_string "*")
4687      (const_string "1")))
4688    (set (attr "prefix_data16")
4689      (if_then_else
4690        (match_test "TARGET_AVX")
4691      (const_string "*")
4692      (const_string "0")))
4693    (set_attr "prefix_data16" "0")
4694    (set_attr "prefix" "<mask_prefix2>")
4695    (set_attr "mode" "TI")])
4697 (define_expand "fixuns_trunc<mode><sseintvecmodelower>2"
4698   [(match_operand:<sseintvecmode> 0 "register_operand")
4699    (match_operand:VF1 1 "register_operand")]
4700   "TARGET_SSE2"
4702   if (<MODE>mode == V16SFmode)
4703     emit_insn (gen_ufix_truncv16sfv16si2 (operands[0],
4704                                           operands[1]));
4705   else
4706     {
4707       rtx tmp[3];
4708       tmp[0] = ix86_expand_adjust_ufix_to_sfix_si (operands[1], &tmp[2]);
4709       tmp[1] = gen_reg_rtx (<sseintvecmode>mode);
4710       emit_insn (gen_fix_trunc<mode><sseintvecmodelower>2 (tmp[1], tmp[0]));
4711       emit_insn (gen_xor<sseintvecmodelower>3 (operands[0], tmp[1], tmp[2]));
4712     }
4713   DONE;
4716 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4718 ;; Parallel double-precision floating point conversion operations
4720 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4722 (define_insn "sse2_cvtpi2pd"
4723   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
4724         (float:V2DF (match_operand:V2SI 1 "nonimmediate_operand" "y,m")))]
4725   "TARGET_SSE2"
4726   "cvtpi2pd\t{%1, %0|%0, %1}"
4727   [(set_attr "type" "ssecvt")
4728    (set_attr "unit" "mmx,*")
4729    (set_attr "prefix_data16" "1,*")
4730    (set_attr "mode" "V2DF")])
4732 (define_insn "sse2_cvtpd2pi"
4733   [(set (match_operand:V2SI 0 "register_operand" "=y")
4734         (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "xm")]
4735                      UNSPEC_FIX_NOTRUNC))]
4736   "TARGET_SSE2"
4737   "cvtpd2pi\t{%1, %0|%0, %1}"
4738   [(set_attr "type" "ssecvt")
4739    (set_attr "unit" "mmx")
4740    (set_attr "bdver1_decode" "double")
4741    (set_attr "btver2_decode" "direct")
4742    (set_attr "prefix_data16" "1")
4743    (set_attr "mode" "DI")])
4745 (define_insn "sse2_cvttpd2pi"
4746   [(set (match_operand:V2SI 0 "register_operand" "=y")
4747         (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "xm")))]
4748   "TARGET_SSE2"
4749   "cvttpd2pi\t{%1, %0|%0, %1}"
4750   [(set_attr "type" "ssecvt")
4751    (set_attr "unit" "mmx")
4752    (set_attr "bdver1_decode" "double")
4753    (set_attr "prefix_data16" "1")
4754    (set_attr "mode" "TI")])
4756 (define_insn "sse2_cvtsi2sd"
4757   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
4758         (vec_merge:V2DF
4759           (vec_duplicate:V2DF
4760             (float:DF (match_operand:SI 2 "nonimmediate_operand" "r,m,rm")))
4761           (match_operand:V2DF 1 "register_operand" "0,0,v")
4762           (const_int 1)))]
4763   "TARGET_SSE2"
4764   "@
4765    cvtsi2sd\t{%2, %0|%0, %2}
4766    cvtsi2sd\t{%2, %0|%0, %2}
4767    vcvtsi2sd\t{%2, %1, %0|%0, %1, %2}"
4768   [(set_attr "isa" "noavx,noavx,avx")
4769    (set_attr "type" "sseicvt")
4770    (set_attr "athlon_decode" "double,direct,*")
4771    (set_attr "amdfam10_decode" "vector,double,*")
4772    (set_attr "bdver1_decode" "double,direct,*")
4773    (set_attr "btver2_decode" "double,double,double")
4774    (set_attr "znver1_decode" "double,double,double")
4775    (set_attr "prefix" "orig,orig,maybe_evex")
4776    (set_attr "mode" "DF")])
4778 (define_insn "sse2_cvtsi2sdq<round_name>"
4779   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
4780         (vec_merge:V2DF
4781           (vec_duplicate:V2DF
4782             (float:DF (match_operand:DI 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
4783           (match_operand:V2DF 1 "register_operand" "0,0,v")
4784           (const_int 1)))]
4785   "TARGET_SSE2 && TARGET_64BIT"
4786   "@
4787    cvtsi2sdq\t{%2, %0|%0, %2}
4788    cvtsi2sdq\t{%2, %0|%0, %2}
4789    vcvtsi2sdq\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4790   [(set_attr "isa" "noavx,noavx,avx")
4791    (set_attr "type" "sseicvt")
4792    (set_attr "athlon_decode" "double,direct,*")
4793    (set_attr "amdfam10_decode" "vector,double,*")
4794    (set_attr "bdver1_decode" "double,direct,*")
4795    (set_attr "length_vex" "*,*,4")
4796    (set_attr "prefix_rex" "1,1,*")
4797    (set_attr "prefix" "orig,orig,maybe_evex")
4798    (set_attr "mode" "DF")])
4800 (define_insn "avx512f_vcvtss2usi<round_name>"
4801   [(set (match_operand:SI 0 "register_operand" "=r")
4802         (unspec:SI
4803           [(vec_select:SF
4804              (match_operand:V4SF 1 "<round_nimm_predicate>" "<round_constraint>")
4805              (parallel [(const_int 0)]))]
4806           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4807   "TARGET_AVX512F"
4808   "vcvtss2usi\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
4809   [(set_attr "type" "sseicvt")
4810    (set_attr "prefix" "evex")
4811    (set_attr "mode" "SI")])
4813 (define_insn "avx512f_vcvtss2usiq<round_name>"
4814   [(set (match_operand:DI 0 "register_operand" "=r")
4815         (unspec:DI
4816           [(vec_select:SF
4817              (match_operand:V4SF 1 "<round_nimm_predicate>" "<round_constraint>")
4818              (parallel [(const_int 0)]))]
4819           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4820   "TARGET_AVX512F && TARGET_64BIT"
4821   "vcvtss2usi\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
4822   [(set_attr "type" "sseicvt")
4823    (set_attr "prefix" "evex")
4824    (set_attr "mode" "DI")])
4826 (define_insn "avx512f_vcvttss2usi<round_saeonly_name>"
4827   [(set (match_operand:SI 0 "register_operand" "=r")
4828         (unsigned_fix:SI
4829           (vec_select:SF
4830             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4831             (parallel [(const_int 0)]))))]
4832   "TARGET_AVX512F"
4833   "vcvttss2usi\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
4834   [(set_attr "type" "sseicvt")
4835    (set_attr "prefix" "evex")
4836    (set_attr "mode" "SI")])
4838 (define_insn "avx512f_vcvttss2usiq<round_saeonly_name>"
4839   [(set (match_operand:DI 0 "register_operand" "=r")
4840         (unsigned_fix:DI
4841           (vec_select:SF
4842             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4843             (parallel [(const_int 0)]))))]
4844   "TARGET_AVX512F && TARGET_64BIT"
4845   "vcvttss2usi\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
4846   [(set_attr "type" "sseicvt")
4847    (set_attr "prefix" "evex")
4848    (set_attr "mode" "DI")])
4850 (define_insn "avx512f_vcvtsd2usi<round_name>"
4851   [(set (match_operand:SI 0 "register_operand" "=r")
4852         (unspec:SI
4853           [(vec_select:DF
4854              (match_operand:V2DF 1 "<round_nimm_predicate>" "<round_constraint>")
4855              (parallel [(const_int 0)]))]
4856           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4857   "TARGET_AVX512F"
4858   "vcvtsd2usi\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
4859   [(set_attr "type" "sseicvt")
4860    (set_attr "prefix" "evex")
4861    (set_attr "mode" "SI")])
4863 (define_insn "avx512f_vcvtsd2usiq<round_name>"
4864   [(set (match_operand:DI 0 "register_operand" "=r")
4865         (unspec:DI
4866           [(vec_select:DF
4867              (match_operand:V2DF 1 "<round_nimm_predicate>" "<round_constraint>")
4868              (parallel [(const_int 0)]))]
4869           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4870   "TARGET_AVX512F && TARGET_64BIT"
4871   "vcvtsd2usi\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
4872   [(set_attr "type" "sseicvt")
4873    (set_attr "prefix" "evex")
4874    (set_attr "mode" "DI")])
4876 (define_insn "avx512f_vcvttsd2usi<round_saeonly_name>"
4877   [(set (match_operand:SI 0 "register_operand" "=r")
4878         (unsigned_fix:SI
4879           (vec_select:DF
4880             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4881             (parallel [(const_int 0)]))))]
4882   "TARGET_AVX512F"
4883   "vcvttsd2usi\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
4884   [(set_attr "type" "sseicvt")
4885    (set_attr "prefix" "evex")
4886    (set_attr "mode" "SI")])
4888 (define_insn "avx512f_vcvttsd2usiq<round_saeonly_name>"
4889   [(set (match_operand:DI 0 "register_operand" "=r")
4890         (unsigned_fix:DI
4891           (vec_select:DF
4892             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4893             (parallel [(const_int 0)]))))]
4894   "TARGET_AVX512F && TARGET_64BIT"
4895   "vcvttsd2usi\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
4896   [(set_attr "type" "sseicvt")
4897    (set_attr "prefix" "evex")
4898    (set_attr "mode" "DI")])
4900 (define_insn "sse2_cvtsd2si<round_name>"
4901   [(set (match_operand:SI 0 "register_operand" "=r,r")
4902         (unspec:SI
4903           [(vec_select:DF
4904              (match_operand:V2DF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4905              (parallel [(const_int 0)]))]
4906           UNSPEC_FIX_NOTRUNC))]
4907   "TARGET_SSE2"
4908   "%vcvtsd2si\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
4909   [(set_attr "type" "sseicvt")
4910    (set_attr "athlon_decode" "double,vector")
4911    (set_attr "bdver1_decode" "double,double")
4912    (set_attr "btver2_decode" "double,double")
4913    (set_attr "prefix_rep" "1")
4914    (set_attr "prefix" "maybe_vex")
4915    (set_attr "mode" "SI")])
4917 (define_insn "sse2_cvtsd2si_2"
4918   [(set (match_operand:SI 0 "register_operand" "=r,r")
4919         (unspec:SI [(match_operand:DF 1 "nonimmediate_operand" "v,m")]
4920                    UNSPEC_FIX_NOTRUNC))]
4921   "TARGET_SSE2"
4922   "%vcvtsd2si\t{%1, %0|%0, %q1}"
4923   [(set_attr "type" "sseicvt")
4924    (set_attr "athlon_decode" "double,vector")
4925    (set_attr "amdfam10_decode" "double,double")
4926    (set_attr "bdver1_decode" "double,double")
4927    (set_attr "prefix_rep" "1")
4928    (set_attr "prefix" "maybe_vex")
4929    (set_attr "mode" "SI")])
4931 (define_insn "sse2_cvtsd2siq<round_name>"
4932   [(set (match_operand:DI 0 "register_operand" "=r,r")
4933         (unspec:DI
4934           [(vec_select:DF
4935              (match_operand:V2DF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4936              (parallel [(const_int 0)]))]
4937           UNSPEC_FIX_NOTRUNC))]
4938   "TARGET_SSE2 && TARGET_64BIT"
4939   "%vcvtsd2si{q}\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
4940   [(set_attr "type" "sseicvt")
4941    (set_attr "athlon_decode" "double,vector")
4942    (set_attr "bdver1_decode" "double,double")
4943    (set_attr "prefix_rep" "1")
4944    (set_attr "prefix" "maybe_vex")
4945    (set_attr "mode" "DI")])
4947 (define_insn "sse2_cvtsd2siq_2"
4948   [(set (match_operand:DI 0 "register_operand" "=r,r")
4949         (unspec:DI [(match_operand:DF 1 "nonimmediate_operand" "v,m")]
4950                    UNSPEC_FIX_NOTRUNC))]
4951   "TARGET_SSE2 && TARGET_64BIT"
4952   "%vcvtsd2si{q}\t{%1, %0|%0, %q1}"
4953   [(set_attr "type" "sseicvt")
4954    (set_attr "athlon_decode" "double,vector")
4955    (set_attr "amdfam10_decode" "double,double")
4956    (set_attr "bdver1_decode" "double,double")
4957    (set_attr "prefix_rep" "1")
4958    (set_attr "prefix" "maybe_vex")
4959    (set_attr "mode" "DI")])
4961 (define_insn "sse2_cvttsd2si<round_saeonly_name>"
4962   [(set (match_operand:SI 0 "register_operand" "=r,r")
4963         (fix:SI
4964           (vec_select:DF
4965             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint2>")
4966             (parallel [(const_int 0)]))))]
4967   "TARGET_SSE2"
4968   "%vcvttsd2si\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
4969   [(set_attr "type" "sseicvt")
4970    (set_attr "athlon_decode" "double,vector")
4971    (set_attr "amdfam10_decode" "double,double")
4972    (set_attr "bdver1_decode" "double,double")
4973    (set_attr "btver2_decode" "double,double")
4974    (set_attr "prefix_rep" "1")
4975    (set_attr "prefix" "maybe_vex")
4976    (set_attr "mode" "SI")])
4978 (define_insn "sse2_cvttsd2siq<round_saeonly_name>"
4979   [(set (match_operand:DI 0 "register_operand" "=r,r")
4980         (fix:DI
4981           (vec_select:DF
4982             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint2>")
4983             (parallel [(const_int 0)]))))]
4984   "TARGET_SSE2 && TARGET_64BIT"
4985   "%vcvttsd2si{q}\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
4986   [(set_attr "type" "sseicvt")
4987    (set_attr "athlon_decode" "double,vector")
4988    (set_attr "amdfam10_decode" "double,double")
4989    (set_attr "bdver1_decode" "double,double")
4990    (set_attr "prefix_rep" "1")
4991    (set_attr "prefix" "maybe_vex")
4992    (set_attr "mode" "DI")])
4994 ;; For float<si2dfmode><mode>2 insn pattern
4995 (define_mode_attr si2dfmode
4996   [(V8DF "V8SI") (V4DF "V4SI")])
4997 (define_mode_attr si2dfmodelower
4998   [(V8DF "v8si") (V4DF "v4si")])
5000 (define_insn "float<si2dfmodelower><mode>2<mask_name>"
5001   [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
5002         (float:VF2_512_256 (match_operand:<si2dfmode> 1 "nonimmediate_operand" "vm")))]
5003   "TARGET_AVX && <mask_mode512bit_condition>"
5004   "vcvtdq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5005   [(set_attr "type" "ssecvt")
5006    (set_attr "prefix" "maybe_vex")
5007    (set_attr "mode" "<MODE>")])
5009 (define_insn "<floatsuffix>float<sseintvecmodelower><mode>2<mask_name><round_name>"
5010   [(set (match_operand:VF2_AVX512VL 0 "register_operand" "=v")
5011         (any_float:VF2_AVX512VL
5012           (match_operand:<sseintvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
5013   "TARGET_AVX512DQ"
5014   "vcvt<floatsuffix>qq2pd\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5015   [(set_attr "type" "ssecvt")
5016    (set_attr "prefix" "evex")
5017    (set_attr "mode" "<MODE>")])
5019 ;; For <floatsuffix>float<sselondveclower><mode> insn patterns
5020 (define_mode_attr qq2pssuff
5021   [(V8SF "") (V4SF "{y}")])
5023 (define_mode_attr sselongvecmode
5024   [(V8SF "V8DI") (V4SF  "V4DI")])
5026 (define_mode_attr sselongvecmodelower
5027   [(V8SF "v8di") (V4SF  "v4di")])
5029 (define_mode_attr sseintvecmode3
5030   [(V8SF "XI") (V4SF "OI")
5031    (V8DF "OI") (V4DF "TI")])
5033 (define_insn "<floatsuffix>float<sselongvecmodelower><mode>2<mask_name><round_name>"
5034   [(set (match_operand:VF1_128_256VL 0 "register_operand" "=v")
5035          (any_float:VF1_128_256VL
5036            (match_operand:<sselongvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
5037   "TARGET_AVX512DQ && <round_modev8sf_condition>"
5038   "vcvt<floatsuffix>qq2ps<qq2pssuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5039   [(set_attr "type" "ssecvt")
5040    (set_attr "prefix" "evex")
5041    (set_attr "mode" "<MODE>")])
5043 (define_insn "*<floatsuffix>floatv2div2sf2"
5044   [(set (match_operand:V4SF 0 "register_operand" "=v")
5045     (vec_concat:V4SF
5046             (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
5047             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
5048   "TARGET_AVX512DQ && TARGET_AVX512VL"
5049   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0|%0, %1}"
5050   [(set_attr "type" "ssecvt")
5051    (set_attr "prefix" "evex")
5052    (set_attr "mode" "V4SF")])
5054 (define_insn "<floatsuffix>floatv2div2sf2_mask"
5055   [(set (match_operand:V4SF 0 "register_operand" "=v")
5056     (vec_concat:V4SF
5057         (vec_merge:V2SF
5058                 (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
5059             (vec_select:V2SF
5060                 (match_operand:V4SF 2 "vector_move_operand" "0C")
5061                 (parallel [(const_int 0) (const_int 1)]))
5062             (match_operand:QI 3 "register_operand" "Yk"))
5063             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
5064   "TARGET_AVX512DQ && TARGET_AVX512VL"
5065   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
5066   [(set_attr "type" "ssecvt")
5067    (set_attr "prefix" "evex")
5068    (set_attr "mode" "V4SF")])
5070 (define_insn "*<floatsuffix>floatv2div2sf2_mask_1"
5071   [(set (match_operand:V4SF 0 "register_operand" "=v")
5072     (vec_concat:V4SF
5073         (vec_merge:V2SF
5074                 (any_float:V2SF (match_operand:V2DI 1
5075                                   "nonimmediate_operand" "vm"))
5076             (const_vector:V2SF [(const_int 0) (const_int 0)])
5077             (match_operand:QI 2 "register_operand" "Yk"))
5078             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
5079   "TARGET_AVX512DQ && TARGET_AVX512VL"
5080   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
5081   [(set_attr "type" "ssecvt")
5082    (set_attr "prefix" "evex")
5083    (set_attr "mode" "V4SF")])
5085 (define_insn "ufloat<si2dfmodelower><mode>2<mask_name>"
5086   [(set (match_operand:VF2_512_256VL 0 "register_operand" "=v")
5087         (unsigned_float:VF2_512_256VL
5088           (match_operand:<si2dfmode> 1 "nonimmediate_operand" "vm")))]
5089    "TARGET_AVX512F"
5090    "vcvtudq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5091    [(set_attr "type" "ssecvt")
5092     (set_attr "prefix" "evex")
5093     (set_attr "mode" "<MODE>")])
5095 (define_insn "ufloatv2siv2df2<mask_name>"
5096   [(set (match_operand:V2DF 0 "register_operand" "=v")
5097         (unsigned_float:V2DF
5098           (vec_select:V2SI
5099             (match_operand:V4SI 1 "nonimmediate_operand" "vm")
5100             (parallel [(const_int 0) (const_int 1)]))))]
5101   "TARGET_AVX512VL"
5102   "vcvtudq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5103   [(set_attr "type" "ssecvt")
5104    (set_attr "prefix" "evex")
5105    (set_attr "mode" "V2DF")])
5107 (define_insn "avx512f_cvtdq2pd512_2"
5108   [(set (match_operand:V8DF 0 "register_operand" "=v")
5109         (float:V8DF
5110           (vec_select:V8SI
5111             (match_operand:V16SI 1 "nonimmediate_operand" "vm")
5112             (parallel [(const_int 0) (const_int 1)
5113                        (const_int 2) (const_int 3)
5114                        (const_int 4) (const_int 5)
5115                        (const_int 6) (const_int 7)]))))]
5116   "TARGET_AVX512F"
5117   "vcvtdq2pd\t{%t1, %0|%0, %t1}"
5118   [(set_attr "type" "ssecvt")
5119    (set_attr "prefix" "evex")
5120    (set_attr "mode" "V8DF")])
5122 (define_insn "avx_cvtdq2pd256_2"
5123   [(set (match_operand:V4DF 0 "register_operand" "=v")
5124         (float:V4DF
5125           (vec_select:V4SI
5126             (match_operand:V8SI 1 "nonimmediate_operand" "vm")
5127             (parallel [(const_int 0) (const_int 1)
5128                        (const_int 2) (const_int 3)]))))]
5129   "TARGET_AVX"
5130   "vcvtdq2pd\t{%x1, %0|%0, %x1}"
5131   [(set_attr "type" "ssecvt")
5132    (set_attr "prefix" "maybe_evex")
5133    (set_attr "mode" "V4DF")])
5135 (define_insn "sse2_cvtdq2pd<mask_name>"
5136   [(set (match_operand:V2DF 0 "register_operand" "=v")
5137         (float:V2DF
5138           (vec_select:V2SI
5139             (match_operand:V4SI 1 "nonimmediate_operand" "vm")
5140             (parallel [(const_int 0) (const_int 1)]))))]
5141   "TARGET_SSE2 && <mask_avx512vl_condition>"
5142   "%vcvtdq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5143   [(set_attr "type" "ssecvt")
5144    (set_attr "prefix" "maybe_vex")
5145    (set_attr "mode" "V2DF")])
5147 (define_insn "avx512f_cvtpd2dq512<mask_name><round_name>"
5148   [(set (match_operand:V8SI 0 "register_operand" "=v")
5149         (unspec:V8SI
5150           [(match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")]
5151           UNSPEC_FIX_NOTRUNC))]
5152   "TARGET_AVX512F"
5153   "vcvtpd2dq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5154   [(set_attr "type" "ssecvt")
5155    (set_attr "prefix" "evex")
5156    (set_attr "mode" "OI")])
5158 (define_insn "avx_cvtpd2dq256<mask_name>"
5159   [(set (match_operand:V4SI 0 "register_operand" "=v")
5160         (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")]
5161                      UNSPEC_FIX_NOTRUNC))]
5162   "TARGET_AVX && <mask_avx512vl_condition>"
5163   "vcvtpd2dq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5164   [(set_attr "type" "ssecvt")
5165    (set_attr "prefix" "<mask_prefix>")
5166    (set_attr "mode" "OI")])
5168 (define_expand "avx_cvtpd2dq256_2"
5169   [(set (match_operand:V8SI 0 "register_operand")
5170         (vec_concat:V8SI
5171           (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand")]
5172                        UNSPEC_FIX_NOTRUNC)
5173           (match_dup 2)))]
5174   "TARGET_AVX"
5175   "operands[2] = CONST0_RTX (V4SImode);")
5177 (define_insn "*avx_cvtpd2dq256_2"
5178   [(set (match_operand:V8SI 0 "register_operand" "=v")
5179         (vec_concat:V8SI
5180           (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")]
5181                        UNSPEC_FIX_NOTRUNC)
5182           (match_operand:V4SI 2 "const0_operand")))]
5183   "TARGET_AVX"
5184   "vcvtpd2dq{y}\t{%1, %x0|%x0, %1}"
5185   [(set_attr "type" "ssecvt")
5186    (set_attr "prefix" "vex")
5187    (set_attr "btver2_decode" "vector")
5188    (set_attr "mode" "OI")])
5190 (define_insn "sse2_cvtpd2dq<mask_name>"
5191   [(set (match_operand:V4SI 0 "register_operand" "=v")
5192         (vec_concat:V4SI
5193           (unspec:V2SI [(match_operand:V2DF 1 "vector_operand" "vBm")]
5194                        UNSPEC_FIX_NOTRUNC)
5195           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5196   "TARGET_SSE2 && <mask_avx512vl_condition>"
5198   if (TARGET_AVX)
5199     return "vcvtpd2dq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
5200   else
5201     return "cvtpd2dq\t{%1, %0|%0, %1}";
5203   [(set_attr "type" "ssecvt")
5204    (set_attr "prefix_rep" "1")
5205    (set_attr "prefix_data16" "0")
5206    (set_attr "prefix" "maybe_vex")
5207    (set_attr "mode" "TI")
5208    (set_attr "amdfam10_decode" "double")
5209    (set_attr "athlon_decode" "vector")
5210    (set_attr "bdver1_decode" "double")])
5212 ;; For ufix_notrunc* insn patterns
5213 (define_mode_attr pd2udqsuff
5214   [(V8DF "") (V4DF "{y}")])
5216 (define_insn "ufix_notrunc<mode><si2dfmodelower>2<mask_name><round_name>"
5217   [(set (match_operand:<si2dfmode> 0 "register_operand" "=v")
5218         (unspec:<si2dfmode>
5219           [(match_operand:VF2_512_256VL 1 "nonimmediate_operand" "<round_constraint>")]
5220           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
5221   "TARGET_AVX512F"
5222   "vcvtpd2udq<pd2udqsuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5223   [(set_attr "type" "ssecvt")
5224    (set_attr "prefix" "evex")
5225    (set_attr "mode" "<sseinsnmode>")])
5227 (define_insn "ufix_notruncv2dfv2si2<mask_name>"
5228   [(set (match_operand:V4SI 0 "register_operand" "=v")
5229         (vec_concat:V4SI
5230           (unspec:V2SI
5231             [(match_operand:V2DF 1 "nonimmediate_operand" "vm")]
5232             UNSPEC_UNSIGNED_FIX_NOTRUNC)
5233           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5234   "TARGET_AVX512VL"
5235   "vcvtpd2udq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5236   [(set_attr "type" "ssecvt")
5237    (set_attr "prefix" "evex")
5238    (set_attr "mode" "TI")])
5240 (define_insn "<fixsuffix>fix_truncv8dfv8si2<mask_name><round_saeonly_name>"
5241   [(set (match_operand:V8SI 0 "register_operand" "=v")
5242         (any_fix:V8SI
5243           (match_operand:V8DF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5244   "TARGET_AVX512F"
5245   "vcvttpd2<fixsuffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5246   [(set_attr "type" "ssecvt")
5247    (set_attr "prefix" "evex")
5248    (set_attr "mode" "OI")])
5250 (define_insn "ufix_truncv2dfv2si2<mask_name>"
5251   [(set (match_operand:V4SI 0 "register_operand" "=v")
5252         (vec_concat:V4SI
5253           (unsigned_fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "vm"))
5254           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5255   "TARGET_AVX512VL"
5256   "vcvttpd2udq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5257   [(set_attr "type" "ssecvt")
5258    (set_attr "prefix" "evex")
5259    (set_attr "mode" "TI")])
5261 (define_insn "fix_truncv4dfv4si2<mask_name>"
5262   [(set (match_operand:V4SI 0 "register_operand" "=v")
5263         (fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
5264   "TARGET_AVX || (TARGET_AVX512VL && TARGET_AVX512F)"
5265   "vcvttpd2dq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5266   [(set_attr "type" "ssecvt")
5267    (set_attr "prefix" "maybe_evex")
5268    (set_attr "mode" "OI")])
5270 (define_insn "ufix_truncv4dfv4si2<mask_name>"
5271   [(set (match_operand:V4SI 0 "register_operand" "=v")
5272         (unsigned_fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
5273   "TARGET_AVX512VL && TARGET_AVX512F"
5274   "vcvttpd2udq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5275   [(set_attr "type" "ssecvt")
5276    (set_attr "prefix" "maybe_evex")
5277    (set_attr "mode" "OI")])
5279 (define_insn "<fixsuffix>fix_trunc<mode><sseintvecmodelower>2<mask_name><round_saeonly_name>"
5280   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5281         (any_fix:<sseintvecmode>
5282           (match_operand:VF2_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5283   "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
5284   "vcvttpd2<fixsuffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5285   [(set_attr "type" "ssecvt")
5286    (set_attr "prefix" "evex")
5287    (set_attr "mode" "<sseintvecmode2>")])
5289 (define_insn "fix_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>"
5290   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5291         (unspec:<sseintvecmode>
5292           [(match_operand:VF2_AVX512VL 1 "<round_nimm_predicate>" "<round_constraint>")]
5293           UNSPEC_FIX_NOTRUNC))]
5294   "TARGET_AVX512DQ && <round_mode512bit_condition>"
5295   "vcvtpd2qq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5296   [(set_attr "type" "ssecvt")
5297    (set_attr "prefix" "evex")
5298    (set_attr "mode" "<sseintvecmode2>")])
5300 (define_insn "ufix_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>"
5301   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5302         (unspec:<sseintvecmode>
5303           [(match_operand:VF2_AVX512VL 1 "nonimmediate_operand" "<round_constraint>")]
5304           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
5305   "TARGET_AVX512DQ && <round_mode512bit_condition>"
5306   "vcvtpd2uqq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5307   [(set_attr "type" "ssecvt")
5308    (set_attr "prefix" "evex")
5309    (set_attr "mode" "<sseintvecmode2>")])
5311 (define_insn "<fixsuffix>fix_trunc<mode><sselongvecmodelower>2<mask_name><round_saeonly_name>"
5312   [(set (match_operand:<sselongvecmode> 0 "register_operand" "=v")
5313         (any_fix:<sselongvecmode>
5314           (match_operand:VF1_128_256VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5315   "TARGET_AVX512DQ && <round_saeonly_modev8sf_condition>"
5316   "vcvttps2<fixsuffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5317   [(set_attr "type" "ssecvt")
5318    (set_attr "prefix" "evex")
5319    (set_attr "mode" "<sseintvecmode3>")])
5321 (define_insn "<fixsuffix>fix_truncv2sfv2di2<mask_name>"
5322   [(set (match_operand:V2DI 0 "register_operand" "=v")
5323         (any_fix:V2DI
5324           (vec_select:V2SF
5325             (match_operand:V4SF 1 "nonimmediate_operand" "vm")
5326             (parallel [(const_int 0) (const_int 1)]))))]
5327   "TARGET_AVX512DQ && TARGET_AVX512VL"
5328   "vcvttps2<fixsuffix>qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5329   [(set_attr "type" "ssecvt")
5330    (set_attr "prefix" "evex")
5331    (set_attr "mode" "TI")])
5333 (define_insn "ufix_trunc<mode><sseintvecmodelower>2<mask_name>"
5334   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5335         (unsigned_fix:<sseintvecmode>
5336           (match_operand:VF1_128_256VL 1 "nonimmediate_operand" "vm")))]
5337   "TARGET_AVX512VL"
5338   "vcvttps2udq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5339   [(set_attr "type" "ssecvt")
5340    (set_attr "prefix" "evex")
5341    (set_attr "mode" "<sseintvecmode2>")])
5343 (define_expand "avx_cvttpd2dq256_2"
5344   [(set (match_operand:V8SI 0 "register_operand")
5345         (vec_concat:V8SI
5346           (fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand"))
5347           (match_dup 2)))]
5348   "TARGET_AVX"
5349   "operands[2] = CONST0_RTX (V4SImode);")
5351 (define_insn "sse2_cvttpd2dq<mask_name>"
5352   [(set (match_operand:V4SI 0 "register_operand" "=v")
5353         (vec_concat:V4SI
5354           (fix:V2SI (match_operand:V2DF 1 "vector_operand" "vBm"))
5355           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5356   "TARGET_SSE2 && <mask_avx512vl_condition>"
5358   if (TARGET_AVX)
5359     return "vcvttpd2dq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
5360   else
5361     return "cvttpd2dq\t{%1, %0|%0, %1}";
5363   [(set_attr "type" "ssecvt")
5364    (set_attr "amdfam10_decode" "double")
5365    (set_attr "athlon_decode" "vector")
5366    (set_attr "bdver1_decode" "double")
5367    (set_attr "prefix" "maybe_vex")
5368    (set_attr "mode" "TI")])
5370 (define_insn "sse2_cvtsd2ss<round_name>"
5371   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
5372         (vec_merge:V4SF
5373           (vec_duplicate:V4SF
5374             (float_truncate:V2SF
5375               (match_operand:V2DF 2 "nonimmediate_operand" "x,m,<round_constraint>")))
5376           (match_operand:V4SF 1 "register_operand" "0,0,v")
5377           (const_int 1)))]
5378   "TARGET_SSE2"
5379   "@
5380    cvtsd2ss\t{%2, %0|%0, %2}
5381    cvtsd2ss\t{%2, %0|%0, %q2}
5382    vcvtsd2ss\t{<round_op3>%2, %1, %0|%0, %1, %q2<round_op3>}"
5383   [(set_attr "isa" "noavx,noavx,avx")
5384    (set_attr "type" "ssecvt")
5385    (set_attr "athlon_decode" "vector,double,*")
5386    (set_attr "amdfam10_decode" "vector,double,*")
5387    (set_attr "bdver1_decode" "direct,direct,*")
5388    (set_attr "btver2_decode" "double,double,double")
5389    (set_attr "prefix" "orig,orig,<round_prefix>")
5390    (set_attr "mode" "SF")])
5392 (define_insn "*sse2_vd_cvtsd2ss"
5393   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
5394         (vec_merge:V4SF
5395           (vec_duplicate:V4SF
5396             (float_truncate:SF (match_operand:DF 2 "nonimmediate_operand" "x,m,vm")))
5397           (match_operand:V4SF 1 "register_operand" "0,0,v")
5398           (const_int 1)))]
5399   "TARGET_SSE2"
5400   "@
5401    cvtsd2ss\t{%2, %0|%0, %2}
5402    cvtsd2ss\t{%2, %0|%0, %2}
5403    vcvtsd2ss\t{%2, %1, %0|%0, %1, %2}"
5404   [(set_attr "isa" "noavx,noavx,avx")
5405    (set_attr "type" "ssecvt")
5406    (set_attr "athlon_decode" "vector,double,*")
5407    (set_attr "amdfam10_decode" "vector,double,*")
5408    (set_attr "bdver1_decode" "direct,direct,*")
5409    (set_attr "btver2_decode" "double,double,double")
5410    (set_attr "prefix" "orig,orig,vex")
5411    (set_attr "mode" "SF")])
5413 (define_insn "sse2_cvtss2sd<round_saeonly_name>"
5414   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
5415         (vec_merge:V2DF
5416           (float_extend:V2DF
5417             (vec_select:V2SF
5418               (match_operand:V4SF 2 "<round_saeonly_nimm_scalar_predicate>" "x,m,<round_saeonly_constraint>")
5419               (parallel [(const_int 0) (const_int 1)])))
5420           (match_operand:V2DF 1 "register_operand" "0,0,v")
5421           (const_int 1)))]
5422   "TARGET_SSE2"
5423   "@
5424    cvtss2sd\t{%2, %0|%0, %2}
5425    cvtss2sd\t{%2, %0|%0, %k2}
5426    vcvtss2sd\t{<round_saeonly_op3>%2, %1, %0|%0, %1, %k2<round_saeonly_op3>}"
5427   [(set_attr "isa" "noavx,noavx,avx")
5428    (set_attr "type" "ssecvt")
5429    (set_attr "amdfam10_decode" "vector,double,*")
5430    (set_attr "athlon_decode" "direct,direct,*")
5431    (set_attr "bdver1_decode" "direct,direct,*")
5432    (set_attr "btver2_decode" "double,double,double")
5433    (set_attr "prefix" "orig,orig,<round_saeonly_prefix>")
5434    (set_attr "mode" "DF")])
5436 (define_insn "*sse2_vd_cvtss2sd"
5437   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
5438         (vec_merge:V2DF
5439           (vec_duplicate:V2DF
5440             (float_extend:DF (match_operand:SF 2 "nonimmediate_operand" "x,m,vm")))
5441           (match_operand:V2DF 1 "register_operand" "0,0,v")
5442           (const_int 1)))]
5443   "TARGET_SSE2"
5444   "@
5445    cvtss2sd\t{%2, %0|%0, %2}
5446    cvtss2sd\t{%2, %0|%0, %2}
5447    vcvtss2sd\t{%2, %1, %0|%0, %1, %2}"
5448   [(set_attr "isa" "noavx,noavx,avx")
5449    (set_attr "type" "ssecvt")
5450    (set_attr "amdfam10_decode" "vector,double,*")
5451    (set_attr "athlon_decode" "direct,direct,*")
5452    (set_attr "bdver1_decode" "direct,direct,*")
5453    (set_attr "btver2_decode" "double,double,double")
5454    (set_attr "prefix" "orig,orig,vex")
5455    (set_attr "mode" "DF")])
5457 (define_insn "<mask_codefor>avx512f_cvtpd2ps512<mask_name><round_name>"
5458   [(set (match_operand:V8SF 0 "register_operand" "=v")
5459         (float_truncate:V8SF
5460           (match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")))]
5461   "TARGET_AVX512F"
5462   "vcvtpd2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5463   [(set_attr "type" "ssecvt")
5464    (set_attr "prefix" "evex")
5465    (set_attr "mode" "V8SF")])
5467 (define_insn "avx_cvtpd2ps256<mask_name>"
5468   [(set (match_operand:V4SF 0 "register_operand" "=v")
5469         (float_truncate:V4SF
5470           (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
5471   "TARGET_AVX && <mask_avx512vl_condition>"
5472   "vcvtpd2ps{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5473   [(set_attr "type" "ssecvt")
5474    (set_attr "prefix" "maybe_evex")
5475    (set_attr "btver2_decode" "vector")
5476    (set_attr "mode" "V4SF")])
5478 (define_expand "sse2_cvtpd2ps"
5479   [(set (match_operand:V4SF 0 "register_operand")
5480         (vec_concat:V4SF
5481           (float_truncate:V2SF
5482             (match_operand:V2DF 1 "vector_operand"))
5483           (match_dup 2)))]
5484   "TARGET_SSE2"
5485   "operands[2] = CONST0_RTX (V2SFmode);")
5487 (define_expand "sse2_cvtpd2ps_mask"
5488   [(set (match_operand:V4SF 0 "register_operand")
5489         (vec_merge:V4SF
5490           (vec_concat:V4SF
5491             (float_truncate:V2SF
5492               (match_operand:V2DF 1 "vector_operand"))
5493             (match_dup 4))
5494           (match_operand:V4SF 2 "register_operand")
5495           (match_operand:QI 3 "register_operand")))]
5496   "TARGET_SSE2"
5497   "operands[4] = CONST0_RTX (V2SFmode);")
5499 (define_insn "*sse2_cvtpd2ps<mask_name>"
5500   [(set (match_operand:V4SF 0 "register_operand" "=v")
5501         (vec_concat:V4SF
5502           (float_truncate:V2SF
5503             (match_operand:V2DF 1 "vector_operand" "vBm"))
5504           (match_operand:V2SF 2 "const0_operand")))]
5505   "TARGET_SSE2 && <mask_avx512vl_condition>"
5507   if (TARGET_AVX)
5508     return "vcvtpd2ps{x}\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}";
5509   else
5510     return "cvtpd2ps\t{%1, %0|%0, %1}";
5512   [(set_attr "type" "ssecvt")
5513    (set_attr "amdfam10_decode" "double")
5514    (set_attr "athlon_decode" "vector")
5515    (set_attr "bdver1_decode" "double")
5516    (set_attr "prefix_data16" "1")
5517    (set_attr "prefix" "maybe_vex")
5518    (set_attr "mode" "V4SF")])
5520 ;; For <sse2_avx_avx512f>_cvtps2pd<avxsizesuffix> insn pattern
5521 (define_mode_attr sf2dfmode
5522   [(V8DF "V8SF") (V4DF "V4SF")])
5524 (define_insn "<sse2_avx_avx512f>_cvtps2pd<avxsizesuffix><mask_name><round_saeonly_name>"
5525   [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
5526         (float_extend:VF2_512_256
5527           (match_operand:<sf2dfmode> 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5528   "TARGET_AVX && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
5529   "vcvtps2pd\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5530   [(set_attr "type" "ssecvt")
5531    (set_attr "prefix" "maybe_vex")
5532    (set_attr "mode" "<MODE>")])
5534 (define_insn "*avx_cvtps2pd256_2"
5535   [(set (match_operand:V4DF 0 "register_operand" "=v")
5536         (float_extend:V4DF
5537           (vec_select:V4SF
5538             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
5539             (parallel [(const_int 0) (const_int 1)
5540                        (const_int 2) (const_int 3)]))))]
5541   "TARGET_AVX"
5542   "vcvtps2pd\t{%x1, %0|%0, %x1}"
5543   [(set_attr "type" "ssecvt")
5544    (set_attr "prefix" "vex")
5545    (set_attr "mode" "V4DF")])
5547 (define_insn "vec_unpacks_lo_v16sf"
5548   [(set (match_operand:V8DF 0 "register_operand" "=v")
5549         (float_extend:V8DF
5550           (vec_select:V8SF
5551             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
5552             (parallel [(const_int 0) (const_int 1)
5553                        (const_int 2) (const_int 3)
5554                        (const_int 4) (const_int 5)
5555                        (const_int 6) (const_int 7)]))))]
5556   "TARGET_AVX512F"
5557   "vcvtps2pd\t{%t1, %0|%0, %t1}"
5558   [(set_attr "type" "ssecvt")
5559    (set_attr "prefix" "evex")
5560    (set_attr "mode" "V8DF")])
5562 (define_insn "<avx512>_cvt<ssemodesuffix>2mask<mode>"
5563   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
5564         (unspec:<avx512fmaskmode>
5565          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")]
5566          UNSPEC_CVTINT2MASK))]
5567   "TARGET_AVX512BW"
5568   "vpmov<ssemodesuffix>2m\t{%1, %0|%0, %1}"
5569   [(set_attr "prefix" "evex")
5570    (set_attr "mode" "<sseinsnmode>")])
5572 (define_insn "<avx512>_cvt<ssemodesuffix>2mask<mode>"
5573   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
5574         (unspec:<avx512fmaskmode>
5575          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")]
5576          UNSPEC_CVTINT2MASK))]
5577   "TARGET_AVX512DQ"
5578   "vpmov<ssemodesuffix>2m\t{%1, %0|%0, %1}"
5579   [(set_attr "prefix" "evex")
5580    (set_attr "mode" "<sseinsnmode>")])
5582 (define_expand "<avx512>_cvtmask2<ssemodesuffix><mode>"
5583   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
5584         (vec_merge:VI12_AVX512VL
5585           (match_dup 2)
5586           (match_dup 3)
5587           (match_operand:<avx512fmaskmode> 1 "register_operand")))]
5588   "TARGET_AVX512BW"
5589   {
5590     operands[2] = CONSTM1_RTX (<MODE>mode);
5591     operands[3] = CONST0_RTX (<MODE>mode);
5592   })
5594 (define_insn "*<avx512>_cvtmask2<ssemodesuffix><mode>"
5595   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
5596         (vec_merge:VI12_AVX512VL
5597           (match_operand:VI12_AVX512VL 2 "vector_all_ones_operand")
5598           (match_operand:VI12_AVX512VL 3 "const0_operand")
5599           (match_operand:<avx512fmaskmode> 1 "register_operand" "Yk")))]
5600   "TARGET_AVX512BW"
5601   "vpmovm2<ssemodesuffix>\t{%1, %0|%0, %1}"
5602   [(set_attr "prefix" "evex")
5603    (set_attr "mode" "<sseinsnmode>")])
5605 (define_expand "<avx512>_cvtmask2<ssemodesuffix><mode>"
5606   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
5607         (vec_merge:VI48_AVX512VL
5608           (match_dup 2)
5609           (match_dup 3)
5610           (match_operand:<avx512fmaskmode> 1 "register_operand")))]
5611   "TARGET_AVX512DQ"
5612   "{
5613     operands[2] = CONSTM1_RTX (<MODE>mode);
5614     operands[3] = CONST0_RTX (<MODE>mode);
5615   }")
5617 (define_insn "*<avx512>_cvtmask2<ssemodesuffix><mode>"
5618   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
5619         (vec_merge:VI48_AVX512VL
5620           (match_operand:VI48_AVX512VL 2 "vector_all_ones_operand")
5621           (match_operand:VI48_AVX512VL 3 "const0_operand")
5622           (match_operand:<avx512fmaskmode> 1 "register_operand" "Yk")))]
5623   "TARGET_AVX512DQ"
5624   "vpmovm2<ssemodesuffix>\t{%1, %0|%0, %1}"
5625   [(set_attr "prefix" "evex")
5626    (set_attr "mode" "<sseinsnmode>")])
5628 (define_insn "sse2_cvtps2pd<mask_name>"
5629   [(set (match_operand:V2DF 0 "register_operand" "=v")
5630         (float_extend:V2DF
5631           (vec_select:V2SF
5632             (match_operand:V4SF 1 "vector_operand" "vm")
5633             (parallel [(const_int 0) (const_int 1)]))))]
5634   "TARGET_SSE2 && <mask_avx512vl_condition>"
5635   "%vcvtps2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5636   [(set_attr "type" "ssecvt")
5637    (set_attr "amdfam10_decode" "direct")
5638    (set_attr "athlon_decode" "double")
5639    (set_attr "bdver1_decode" "double")
5640    (set_attr "prefix_data16" "0")
5641    (set_attr "prefix" "maybe_vex")
5642    (set_attr "mode" "V2DF")])
5644 (define_expand "vec_unpacks_hi_v4sf"
5645   [(set (match_dup 2)
5646    (vec_select:V4SF
5647      (vec_concat:V8SF
5648        (match_dup 2)
5649        (match_operand:V4SF 1 "vector_operand"))
5650      (parallel [(const_int 6) (const_int 7)
5651                 (const_int 2) (const_int 3)])))
5652   (set (match_operand:V2DF 0 "register_operand")
5653    (float_extend:V2DF
5654      (vec_select:V2SF
5655        (match_dup 2)
5656        (parallel [(const_int 0) (const_int 1)]))))]
5657   "TARGET_SSE2"
5658   "operands[2] = gen_reg_rtx (V4SFmode);")
5660 (define_expand "vec_unpacks_hi_v8sf"
5661   [(set (match_dup 2)
5662         (vec_select:V4SF
5663           (match_operand:V8SF 1 "register_operand")
5664           (parallel [(const_int 4) (const_int 5)
5665                      (const_int 6) (const_int 7)])))
5666    (set (match_operand:V4DF 0 "register_operand")
5667         (float_extend:V4DF
5668           (match_dup 2)))]
5669   "TARGET_AVX"
5670   "operands[2] = gen_reg_rtx (V4SFmode);")
5672 (define_expand "vec_unpacks_hi_v16sf"
5673   [(set (match_dup 2)
5674         (vec_select:V8SF
5675           (match_operand:V16SF 1 "register_operand")
5676           (parallel [(const_int 8) (const_int 9)
5677                      (const_int 10) (const_int 11)
5678                      (const_int 12) (const_int 13)
5679                      (const_int 14) (const_int 15)])))
5680    (set (match_operand:V8DF 0 "register_operand")
5681         (float_extend:V8DF
5682           (match_dup 2)))]
5683 "TARGET_AVX512F"
5684 "operands[2] = gen_reg_rtx (V8SFmode);")
5686 (define_expand "vec_unpacks_lo_v4sf"
5687   [(set (match_operand:V2DF 0 "register_operand")
5688         (float_extend:V2DF
5689           (vec_select:V2SF
5690             (match_operand:V4SF 1 "vector_operand")
5691             (parallel [(const_int 0) (const_int 1)]))))]
5692   "TARGET_SSE2")
5694 (define_expand "vec_unpacks_lo_v8sf"
5695   [(set (match_operand:V4DF 0 "register_operand")
5696         (float_extend:V4DF
5697           (vec_select:V4SF
5698             (match_operand:V8SF 1 "nonimmediate_operand")
5699             (parallel [(const_int 0) (const_int 1)
5700                        (const_int 2) (const_int 3)]))))]
5701   "TARGET_AVX")
5703 (define_mode_attr sseunpackfltmode
5704   [(V8HI "V4SF") (V4SI "V2DF") (V16HI "V8SF")
5705   (V8SI "V4DF") (V32HI "V16SF") (V16SI "V8DF")])
5707 (define_expand "vec_unpacks_float_hi_<mode>"
5708   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5709    (match_operand:VI2_AVX512F 1 "register_operand")]
5710   "TARGET_SSE2"
5712   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5714   emit_insn (gen_vec_unpacks_hi_<mode> (tmp, operands[1]));
5715   emit_insn (gen_rtx_SET (operands[0],
5716                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5717   DONE;
5720 (define_expand "vec_unpacks_float_lo_<mode>"
5721   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5722    (match_operand:VI2_AVX512F 1 "register_operand")]
5723   "TARGET_SSE2"
5725   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5727   emit_insn (gen_vec_unpacks_lo_<mode> (tmp, operands[1]));
5728   emit_insn (gen_rtx_SET (operands[0],
5729                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5730   DONE;
5733 (define_expand "vec_unpacku_float_hi_<mode>"
5734   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5735    (match_operand:VI2_AVX512F 1 "register_operand")]
5736   "TARGET_SSE2"
5738   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5740   emit_insn (gen_vec_unpacku_hi_<mode> (tmp, operands[1]));
5741   emit_insn (gen_rtx_SET (operands[0],
5742                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5743   DONE;
5746 (define_expand "vec_unpacku_float_lo_<mode>"
5747   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5748    (match_operand:VI2_AVX512F 1 "register_operand")]
5749   "TARGET_SSE2"
5751   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5753   emit_insn (gen_vec_unpacku_lo_<mode> (tmp, operands[1]));
5754   emit_insn (gen_rtx_SET (operands[0],
5755                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5756   DONE;
5759 (define_expand "vec_unpacks_float_hi_v4si"
5760   [(set (match_dup 2)
5761         (vec_select:V4SI
5762           (match_operand:V4SI 1 "vector_operand")
5763           (parallel [(const_int 2) (const_int 3)
5764                      (const_int 2) (const_int 3)])))
5765    (set (match_operand:V2DF 0 "register_operand")
5766         (float:V2DF
5767           (vec_select:V2SI
5768           (match_dup 2)
5769             (parallel [(const_int 0) (const_int 1)]))))]
5770   "TARGET_SSE2"
5771   "operands[2] = gen_reg_rtx (V4SImode);")
5773 (define_expand "vec_unpacks_float_lo_v4si"
5774   [(set (match_operand:V2DF 0 "register_operand")
5775         (float:V2DF
5776           (vec_select:V2SI
5777             (match_operand:V4SI 1 "vector_operand")
5778             (parallel [(const_int 0) (const_int 1)]))))]
5779   "TARGET_SSE2")
5781 (define_expand "vec_unpacks_float_hi_v8si"
5782   [(set (match_dup 2)
5783         (vec_select:V4SI
5784           (match_operand:V8SI 1 "vector_operand")
5785           (parallel [(const_int 4) (const_int 5)
5786                      (const_int 6) (const_int 7)])))
5787    (set (match_operand:V4DF 0 "register_operand")
5788         (float:V4DF
5789           (match_dup 2)))]
5790   "TARGET_AVX"
5791   "operands[2] = gen_reg_rtx (V4SImode);")
5793 (define_expand "vec_unpacks_float_lo_v8si"
5794   [(set (match_operand:V4DF 0 "register_operand")
5795         (float:V4DF
5796           (vec_select:V4SI
5797             (match_operand:V8SI 1 "nonimmediate_operand")
5798             (parallel [(const_int 0) (const_int 1)
5799                        (const_int 2) (const_int 3)]))))]
5800   "TARGET_AVX")
5802 (define_expand "vec_unpacks_float_hi_v16si"
5803   [(set (match_dup 2)
5804         (vec_select:V8SI
5805           (match_operand:V16SI 1 "nonimmediate_operand")
5806           (parallel [(const_int 8) (const_int 9)
5807                      (const_int 10) (const_int 11)
5808                      (const_int 12) (const_int 13)
5809                      (const_int 14) (const_int 15)])))
5810    (set (match_operand:V8DF 0 "register_operand")
5811         (float:V8DF
5812           (match_dup 2)))]
5813   "TARGET_AVX512F"
5814   "operands[2] = gen_reg_rtx (V8SImode);")
5816 (define_expand "vec_unpacks_float_lo_v16si"
5817   [(set (match_operand:V8DF 0 "register_operand")
5818         (float:V8DF
5819           (vec_select:V8SI
5820             (match_operand:V16SI 1 "nonimmediate_operand")
5821             (parallel [(const_int 0) (const_int 1)
5822                        (const_int 2) (const_int 3)
5823                        (const_int 4) (const_int 5)
5824                        (const_int 6) (const_int 7)]))))]
5825   "TARGET_AVX512F")
5827 (define_expand "vec_unpacku_float_hi_v4si"
5828   [(set (match_dup 5)
5829         (vec_select:V4SI
5830           (match_operand:V4SI 1 "vector_operand")
5831           (parallel [(const_int 2) (const_int 3)
5832                      (const_int 2) (const_int 3)])))
5833    (set (match_dup 6)
5834         (float:V2DF
5835           (vec_select:V2SI
5836           (match_dup 5)
5837             (parallel [(const_int 0) (const_int 1)]))))
5838    (set (match_dup 7)
5839         (lt:V2DF (match_dup 6) (match_dup 3)))
5840    (set (match_dup 8)
5841         (and:V2DF (match_dup 7) (match_dup 4)))
5842    (set (match_operand:V2DF 0 "register_operand")
5843         (plus:V2DF (match_dup 6) (match_dup 8)))]
5844   "TARGET_SSE2"
5846   REAL_VALUE_TYPE TWO32r;
5847   rtx x;
5848   int i;
5850   real_ldexp (&TWO32r, &dconst1, 32);
5851   x = const_double_from_real_value (TWO32r, DFmode);
5853   operands[3] = force_reg (V2DFmode, CONST0_RTX (V2DFmode));
5854   operands[4] = force_reg (V2DFmode,
5855                            ix86_build_const_vector (V2DFmode, 1, x));
5857   operands[5] = gen_reg_rtx (V4SImode);
5859   for (i = 6; i < 9; i++)
5860     operands[i] = gen_reg_rtx (V2DFmode);
5863 (define_expand "vec_unpacku_float_lo_v4si"
5864   [(set (match_dup 5)
5865         (float:V2DF
5866           (vec_select:V2SI
5867             (match_operand:V4SI 1 "vector_operand")
5868             (parallel [(const_int 0) (const_int 1)]))))
5869    (set (match_dup 6)
5870         (lt:V2DF (match_dup 5) (match_dup 3)))
5871    (set (match_dup 7)
5872         (and:V2DF (match_dup 6) (match_dup 4)))
5873    (set (match_operand:V2DF 0 "register_operand")
5874         (plus:V2DF (match_dup 5) (match_dup 7)))]
5875   "TARGET_SSE2"
5877   REAL_VALUE_TYPE TWO32r;
5878   rtx x;
5879   int i;
5881   real_ldexp (&TWO32r, &dconst1, 32);
5882   x = const_double_from_real_value (TWO32r, DFmode);
5884   operands[3] = force_reg (V2DFmode, CONST0_RTX (V2DFmode));
5885   operands[4] = force_reg (V2DFmode,
5886                            ix86_build_const_vector (V2DFmode, 1, x));
5888   for (i = 5; i < 8; i++)
5889     operands[i] = gen_reg_rtx (V2DFmode);
5892 (define_expand "vec_unpacku_float_hi_v8si"
5893   [(match_operand:V4DF 0 "register_operand")
5894    (match_operand:V8SI 1 "register_operand")]
5895   "TARGET_AVX"
5897   REAL_VALUE_TYPE TWO32r;
5898   rtx x, tmp[6];
5899   int i;
5901   real_ldexp (&TWO32r, &dconst1, 32);
5902   x = const_double_from_real_value (TWO32r, DFmode);
5904   tmp[0] = force_reg (V4DFmode, CONST0_RTX (V4DFmode));
5905   tmp[1] = force_reg (V4DFmode, ix86_build_const_vector (V4DFmode, 1, x));
5906   tmp[5] = gen_reg_rtx (V4SImode);
5908   for (i = 2; i < 5; i++)
5909     tmp[i] = gen_reg_rtx (V4DFmode);
5910   emit_insn (gen_vec_extract_hi_v8si (tmp[5], operands[1]));
5911   emit_insn (gen_floatv4siv4df2 (tmp[2], tmp[5]));
5912   emit_insn (gen_rtx_SET (tmp[3], gen_rtx_LT (V4DFmode, tmp[2], tmp[0])));
5913   emit_insn (gen_andv4df3 (tmp[4], tmp[3], tmp[1]));
5914   emit_insn (gen_addv4df3 (operands[0], tmp[2], tmp[4]));
5915   DONE;
5918 (define_expand "vec_unpacku_float_hi_v16si"
5919   [(match_operand:V8DF 0 "register_operand")
5920    (match_operand:V16SI 1 "register_operand")]
5921   "TARGET_AVX512F"
5923   REAL_VALUE_TYPE TWO32r;
5924   rtx k, x, tmp[4];
5926   real_ldexp (&TWO32r, &dconst1, 32);
5927   x = const_double_from_real_value (TWO32r, DFmode);
5929   tmp[0] = force_reg (V8DFmode, CONST0_RTX (V8DFmode));
5930   tmp[1] = force_reg (V8DFmode, ix86_build_const_vector (V8DFmode, 1, x));
5931   tmp[2] = gen_reg_rtx (V8DFmode);
5932   tmp[3] = gen_reg_rtx (V8SImode);
5933   k = gen_reg_rtx (QImode);
5935   emit_insn (gen_vec_extract_hi_v16si (tmp[3], operands[1]));
5936   emit_insn (gen_floatv8siv8df2 (tmp[2], tmp[3]));
5937   emit_insn (gen_rtx_SET (k, gen_rtx_LT (QImode, tmp[2], tmp[0])));
5938   emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k));
5939   emit_move_insn (operands[0], tmp[2]);
5940   DONE;
5943 (define_expand "vec_unpacku_float_lo_v8si"
5944   [(match_operand:V4DF 0 "register_operand")
5945    (match_operand:V8SI 1 "nonimmediate_operand")]
5946   "TARGET_AVX"
5948   REAL_VALUE_TYPE TWO32r;
5949   rtx x, tmp[5];
5950   int i;
5952   real_ldexp (&TWO32r, &dconst1, 32);
5953   x = const_double_from_real_value (TWO32r, DFmode);
5955   tmp[0] = force_reg (V4DFmode, CONST0_RTX (V4DFmode));
5956   tmp[1] = force_reg (V4DFmode, ix86_build_const_vector (V4DFmode, 1, x));
5958   for (i = 2; i < 5; i++)
5959     tmp[i] = gen_reg_rtx (V4DFmode);
5960   emit_insn (gen_avx_cvtdq2pd256_2 (tmp[2], operands[1]));
5961   emit_insn (gen_rtx_SET (tmp[3], gen_rtx_LT (V4DFmode, tmp[2], tmp[0])));
5962   emit_insn (gen_andv4df3 (tmp[4], tmp[3], tmp[1]));
5963   emit_insn (gen_addv4df3 (operands[0], tmp[2], tmp[4]));
5964   DONE;
5967 (define_expand "vec_unpacku_float_lo_v16si"
5968   [(match_operand:V8DF 0 "register_operand")
5969    (match_operand:V16SI 1 "nonimmediate_operand")]
5970   "TARGET_AVX512F"
5972   REAL_VALUE_TYPE TWO32r;
5973   rtx k, x, tmp[3];
5975   real_ldexp (&TWO32r, &dconst1, 32);
5976   x = const_double_from_real_value (TWO32r, DFmode);
5978   tmp[0] = force_reg (V8DFmode, CONST0_RTX (V8DFmode));
5979   tmp[1] = force_reg (V8DFmode, ix86_build_const_vector (V8DFmode, 1, x));
5980   tmp[2] = gen_reg_rtx (V8DFmode);
5981   k = gen_reg_rtx (QImode);
5983   emit_insn (gen_avx512f_cvtdq2pd512_2 (tmp[2], operands[1]));
5984   emit_insn (gen_rtx_SET (k, gen_rtx_LT (QImode, tmp[2], tmp[0])));
5985   emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k));
5986   emit_move_insn (operands[0], tmp[2]);
5987   DONE;
5990 (define_expand "vec_pack_trunc_<mode>"
5991   [(set (match_dup 3)
5992         (float_truncate:<sf2dfmode>
5993           (match_operand:VF2_512_256 1 "nonimmediate_operand")))
5994    (set (match_dup 4)
5995         (float_truncate:<sf2dfmode>
5996           (match_operand:VF2_512_256 2 "nonimmediate_operand")))
5997    (set (match_operand:<ssePSmode> 0 "register_operand")
5998         (vec_concat:<ssePSmode>
5999           (match_dup 3)
6000           (match_dup 4)))]
6001   "TARGET_AVX"
6003   operands[3] = gen_reg_rtx (<sf2dfmode>mode);
6004   operands[4] = gen_reg_rtx (<sf2dfmode>mode);
6007 (define_expand "vec_pack_trunc_v2df"
6008   [(match_operand:V4SF 0 "register_operand")
6009    (match_operand:V2DF 1 "vector_operand")
6010    (match_operand:V2DF 2 "vector_operand")]
6011   "TARGET_SSE2"
6013   rtx tmp0, tmp1;
6015   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
6016     {
6017       tmp0 = gen_reg_rtx (V4DFmode);
6018       tmp1 = force_reg (V2DFmode, operands[1]);
6020       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
6021       emit_insn (gen_avx_cvtpd2ps256 (operands[0], tmp0));
6022     }
6023   else
6024     {
6025       tmp0 = gen_reg_rtx (V4SFmode);
6026       tmp1 = gen_reg_rtx (V4SFmode);
6028       emit_insn (gen_sse2_cvtpd2ps (tmp0, operands[1]));
6029       emit_insn (gen_sse2_cvtpd2ps (tmp1, operands[2]));
6030       emit_insn (gen_sse_movlhps (operands[0], tmp0, tmp1));
6031     }
6032   DONE;
6035 (define_expand "vec_pack_sfix_trunc_v8df"
6036   [(match_operand:V16SI 0 "register_operand")
6037    (match_operand:V8DF 1 "nonimmediate_operand")
6038    (match_operand:V8DF 2 "nonimmediate_operand")]
6039   "TARGET_AVX512F"
6041   rtx r1, r2;
6043   r1 = gen_reg_rtx (V8SImode);
6044   r2 = gen_reg_rtx (V8SImode);
6046   emit_insn (gen_fix_truncv8dfv8si2 (r1, operands[1]));
6047   emit_insn (gen_fix_truncv8dfv8si2 (r2, operands[2]));
6048   emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
6049   DONE;
6052 (define_expand "vec_pack_sfix_trunc_v4df"
6053   [(match_operand:V8SI 0 "register_operand")
6054    (match_operand:V4DF 1 "nonimmediate_operand")
6055    (match_operand:V4DF 2 "nonimmediate_operand")]
6056   "TARGET_AVX"
6058   rtx r1, r2;
6060   r1 = gen_reg_rtx (V4SImode);
6061   r2 = gen_reg_rtx (V4SImode);
6063   emit_insn (gen_fix_truncv4dfv4si2 (r1, operands[1]));
6064   emit_insn (gen_fix_truncv4dfv4si2 (r2, operands[2]));
6065   emit_insn (gen_avx_vec_concatv8si (operands[0], r1, r2));
6066   DONE;
6069 (define_expand "vec_pack_sfix_trunc_v2df"
6070   [(match_operand:V4SI 0 "register_operand")
6071    (match_operand:V2DF 1 "vector_operand")
6072    (match_operand:V2DF 2 "vector_operand")]
6073   "TARGET_SSE2"
6075   rtx tmp0, tmp1, tmp2;
6077   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
6078     {
6079       tmp0 = gen_reg_rtx (V4DFmode);
6080       tmp1 = force_reg (V2DFmode, operands[1]);
6082       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
6083       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp0));
6084     }
6085   else
6086     {
6087       tmp0 = gen_reg_rtx (V4SImode);
6088       tmp1 = gen_reg_rtx (V4SImode);
6089       tmp2 = gen_reg_rtx (V2DImode);
6091       emit_insn (gen_sse2_cvttpd2dq (tmp0, operands[1]));
6092       emit_insn (gen_sse2_cvttpd2dq (tmp1, operands[2]));
6093       emit_insn (gen_vec_interleave_lowv2di (tmp2,
6094                                              gen_lowpart (V2DImode, tmp0),
6095                                              gen_lowpart (V2DImode, tmp1)));
6096       emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp2));
6097     }
6098   DONE;
6101 (define_mode_attr ssepackfltmode
6102   [(V8DF "V16SI") (V4DF "V8SI") (V2DF "V4SI")])
6104 (define_expand "vec_pack_ufix_trunc_<mode>"
6105   [(match_operand:<ssepackfltmode> 0 "register_operand")
6106    (match_operand:VF2 1 "register_operand")
6107    (match_operand:VF2 2 "register_operand")]
6108   "TARGET_SSE2"
6110   if (<MODE>mode == V8DFmode)
6111     {
6112       rtx r1, r2;
6114       r1 = gen_reg_rtx (V8SImode);
6115       r2 = gen_reg_rtx (V8SImode);
6117       emit_insn (gen_ufix_truncv8dfv8si2 (r1, operands[1]));
6118       emit_insn (gen_ufix_truncv8dfv8si2 (r2, operands[2]));
6119       emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
6120     }
6121   else
6122     {
6123       rtx tmp[7];
6124       tmp[0] = ix86_expand_adjust_ufix_to_sfix_si (operands[1], &tmp[2]);
6125       tmp[1] = ix86_expand_adjust_ufix_to_sfix_si (operands[2], &tmp[3]);
6126       tmp[4] = gen_reg_rtx (<ssepackfltmode>mode);
6127       emit_insn (gen_vec_pack_sfix_trunc_<mode> (tmp[4], tmp[0], tmp[1]));
6128       if (<ssepackfltmode>mode == V4SImode || TARGET_AVX2)
6129         {
6130           tmp[5] = gen_reg_rtx (<ssepackfltmode>mode);
6131           ix86_expand_vec_extract_even_odd (tmp[5], tmp[2], tmp[3], 0);
6132         }
6133       else
6134         {
6135           tmp[5] = gen_reg_rtx (V8SFmode);
6136           ix86_expand_vec_extract_even_odd (tmp[5],
6137                                             gen_lowpart (V8SFmode, tmp[2]),
6138                                             gen_lowpart (V8SFmode, tmp[3]), 0);
6139           tmp[5] = gen_lowpart (V8SImode, tmp[5]);
6140         }
6141       tmp[6] = expand_simple_binop (<ssepackfltmode>mode, XOR, tmp[4], tmp[5],
6142                                     operands[0], 0, OPTAB_DIRECT);
6143       if (tmp[6] != operands[0])
6144         emit_move_insn (operands[0], tmp[6]);
6145     }
6147   DONE;
6150 (define_expand "avx512f_vec_pack_sfix_v8df"
6151   [(match_operand:V16SI 0 "register_operand")
6152    (match_operand:V8DF 1 "nonimmediate_operand")
6153    (match_operand:V8DF 2 "nonimmediate_operand")]
6154   "TARGET_AVX512F"
6156   rtx r1, r2;
6158   r1 = gen_reg_rtx (V8SImode);
6159   r2 = gen_reg_rtx (V8SImode);
6161   emit_insn (gen_avx512f_cvtpd2dq512 (r1, operands[1]));
6162   emit_insn (gen_avx512f_cvtpd2dq512 (r2, operands[2]));
6163   emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
6164   DONE;
6167 (define_expand "vec_pack_sfix_v4df"
6168   [(match_operand:V8SI 0 "register_operand")
6169    (match_operand:V4DF 1 "nonimmediate_operand")
6170    (match_operand:V4DF 2 "nonimmediate_operand")]
6171   "TARGET_AVX"
6173   rtx r1, r2;
6175   r1 = gen_reg_rtx (V4SImode);
6176   r2 = gen_reg_rtx (V4SImode);
6178   emit_insn (gen_avx_cvtpd2dq256 (r1, operands[1]));
6179   emit_insn (gen_avx_cvtpd2dq256 (r2, operands[2]));
6180   emit_insn (gen_avx_vec_concatv8si (operands[0], r1, r2));
6181   DONE;
6184 (define_expand "vec_pack_sfix_v2df"
6185   [(match_operand:V4SI 0 "register_operand")
6186    (match_operand:V2DF 1 "vector_operand")
6187    (match_operand:V2DF 2 "vector_operand")]
6188   "TARGET_SSE2"
6190   rtx tmp0, tmp1, tmp2;
6192   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
6193     {
6194       tmp0 = gen_reg_rtx (V4DFmode);
6195       tmp1 = force_reg (V2DFmode, operands[1]);
6197       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
6198       emit_insn (gen_avx_cvtpd2dq256 (operands[0], tmp0));
6199     }
6200   else
6201     {
6202       tmp0 = gen_reg_rtx (V4SImode);
6203       tmp1 = gen_reg_rtx (V4SImode);
6204       tmp2 = gen_reg_rtx (V2DImode);
6206       emit_insn (gen_sse2_cvtpd2dq (tmp0, operands[1]));
6207       emit_insn (gen_sse2_cvtpd2dq (tmp1, operands[2]));
6208       emit_insn (gen_vec_interleave_lowv2di (tmp2,
6209                                              gen_lowpart (V2DImode, tmp0),
6210                                              gen_lowpart (V2DImode, tmp1)));
6211       emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp2));
6212     }
6213   DONE;
6216 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6218 ;; Parallel single-precision floating point element swizzling
6220 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6222 (define_expand "sse_movhlps_exp"
6223   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6224         (vec_select:V4SF
6225           (vec_concat:V8SF
6226             (match_operand:V4SF 1 "nonimmediate_operand")
6227             (match_operand:V4SF 2 "nonimmediate_operand"))
6228           (parallel [(const_int 6)
6229                      (const_int 7)
6230                      (const_int 2)
6231                      (const_int 3)])))]
6232   "TARGET_SSE"
6234   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6236   emit_insn (gen_sse_movhlps (dst, operands[1], operands[2]));
6238   /* Fix up the destination if needed.  */
6239   if (dst != operands[0])
6240     emit_move_insn (operands[0], dst);
6242   DONE;
6245 (define_insn "sse_movhlps"
6246   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,m")
6247         (vec_select:V4SF
6248           (vec_concat:V8SF
6249             (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
6250             (match_operand:V4SF 2 "nonimmediate_operand" " x,v,o,o,v"))
6251           (parallel [(const_int 6)
6252                      (const_int 7)
6253                      (const_int 2)
6254                      (const_int 3)])))]
6255   "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
6256   "@
6257    movhlps\t{%2, %0|%0, %2}
6258    vmovhlps\t{%2, %1, %0|%0, %1, %2}
6259    movlps\t{%H2, %0|%0, %H2}
6260    vmovlps\t{%H2, %1, %0|%0, %1, %H2}
6261    %vmovhps\t{%2, %0|%q0, %2}"
6262   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6263    (set_attr "type" "ssemov")
6264    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
6265    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
6267 (define_expand "sse_movlhps_exp"
6268   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6269         (vec_select:V4SF
6270           (vec_concat:V8SF
6271             (match_operand:V4SF 1 "nonimmediate_operand")
6272             (match_operand:V4SF 2 "nonimmediate_operand"))
6273           (parallel [(const_int 0)
6274                      (const_int 1)
6275                      (const_int 4)
6276                      (const_int 5)])))]
6277   "TARGET_SSE"
6279   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6281   emit_insn (gen_sse_movlhps (dst, operands[1], operands[2]));
6283   /* Fix up the destination if needed.  */
6284   if (dst != operands[0])
6285     emit_move_insn (operands[0], dst);
6287   DONE;
6290 (define_insn "sse_movlhps"
6291   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,o")
6292         (vec_select:V4SF
6293           (vec_concat:V8SF
6294             (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
6295             (match_operand:V4SF 2 "nonimmediate_operand" " x,v,m,v,v"))
6296           (parallel [(const_int 0)
6297                      (const_int 1)
6298                      (const_int 4)
6299                      (const_int 5)])))]
6300   "TARGET_SSE && ix86_binary_operator_ok (UNKNOWN, V4SFmode, operands)"
6301   "@
6302    movlhps\t{%2, %0|%0, %2}
6303    vmovlhps\t{%2, %1, %0|%0, %1, %2}
6304    movhps\t{%2, %0|%0, %q2}
6305    vmovhps\t{%2, %1, %0|%0, %1, %q2}
6306    %vmovlps\t{%2, %H0|%H0, %2}"
6307   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6308    (set_attr "type" "ssemov")
6309    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
6310    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
6312 (define_insn "<mask_codefor>avx512f_unpckhps512<mask_name>"
6313   [(set (match_operand:V16SF 0 "register_operand" "=v")
6314         (vec_select:V16SF
6315           (vec_concat:V32SF
6316             (match_operand:V16SF 1 "register_operand" "v")
6317             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
6318           (parallel [(const_int 2) (const_int 18)
6319                      (const_int 3) (const_int 19)
6320                      (const_int 6) (const_int 22)
6321                      (const_int 7) (const_int 23)
6322                      (const_int 10) (const_int 26)
6323                      (const_int 11) (const_int 27)
6324                      (const_int 14) (const_int 30)
6325                      (const_int 15) (const_int 31)])))]
6326   "TARGET_AVX512F"
6327   "vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6328   [(set_attr "type" "sselog")
6329    (set_attr "prefix" "evex")
6330    (set_attr "mode" "V16SF")])
6332 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
6333 (define_insn "avx_unpckhps256<mask_name>"
6334   [(set (match_operand:V8SF 0 "register_operand" "=v")
6335         (vec_select:V8SF
6336           (vec_concat:V16SF
6337             (match_operand:V8SF 1 "register_operand" "v")
6338             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6339           (parallel [(const_int 2) (const_int 10)
6340                      (const_int 3) (const_int 11)
6341                      (const_int 6) (const_int 14)
6342                      (const_int 7) (const_int 15)])))]
6343   "TARGET_AVX && <mask_avx512vl_condition>"
6344   "vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6345   [(set_attr "type" "sselog")
6346    (set_attr "prefix" "vex")
6347    (set_attr "mode" "V8SF")])
6349 (define_expand "vec_interleave_highv8sf"
6350   [(set (match_dup 3)
6351         (vec_select:V8SF
6352           (vec_concat:V16SF
6353             (match_operand:V8SF 1 "register_operand")
6354             (match_operand:V8SF 2 "nonimmediate_operand"))
6355           (parallel [(const_int 0) (const_int 8)
6356                      (const_int 1) (const_int 9)
6357                      (const_int 4) (const_int 12)
6358                      (const_int 5) (const_int 13)])))
6359    (set (match_dup 4)
6360         (vec_select:V8SF
6361           (vec_concat:V16SF
6362             (match_dup 1)
6363             (match_dup 2))
6364           (parallel [(const_int 2) (const_int 10)
6365                      (const_int 3) (const_int 11)
6366                      (const_int 6) (const_int 14)
6367                      (const_int 7) (const_int 15)])))
6368    (set (match_operand:V8SF 0 "register_operand")
6369         (vec_select:V8SF
6370           (vec_concat:V16SF
6371             (match_dup 3)
6372             (match_dup 4))
6373           (parallel [(const_int 4) (const_int 5)
6374                      (const_int 6) (const_int 7)
6375                      (const_int 12) (const_int 13)
6376                      (const_int 14) (const_int 15)])))]
6377  "TARGET_AVX"
6379   operands[3] = gen_reg_rtx (V8SFmode);
6380   operands[4] = gen_reg_rtx (V8SFmode);
6383 (define_insn "vec_interleave_highv4sf<mask_name>"
6384   [(set (match_operand:V4SF 0 "register_operand" "=x,v")
6385         (vec_select:V4SF
6386           (vec_concat:V8SF
6387             (match_operand:V4SF 1 "register_operand" "0,v")
6388             (match_operand:V4SF 2 "vector_operand" "xBm,vm"))
6389           (parallel [(const_int 2) (const_int 6)
6390                      (const_int 3) (const_int 7)])))]
6391   "TARGET_SSE && <mask_avx512vl_condition>"
6392   "@
6393    unpckhps\t{%2, %0|%0, %2}
6394    vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6395   [(set_attr "isa" "noavx,avx")
6396    (set_attr "type" "sselog")
6397    (set_attr "prefix" "orig,vex")
6398    (set_attr "mode" "V4SF")])
6400 (define_insn "<mask_codefor>avx512f_unpcklps512<mask_name>"
6401   [(set (match_operand:V16SF 0 "register_operand" "=v")
6402         (vec_select:V16SF
6403           (vec_concat:V32SF
6404             (match_operand:V16SF 1 "register_operand" "v")
6405             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
6406           (parallel [(const_int 0) (const_int 16)
6407                      (const_int 1) (const_int 17)
6408                      (const_int 4) (const_int 20)
6409                      (const_int 5) (const_int 21)
6410                      (const_int 8) (const_int 24)
6411                      (const_int 9) (const_int 25)
6412                      (const_int 12) (const_int 28)
6413                      (const_int 13) (const_int 29)])))]
6414   "TARGET_AVX512F"
6415   "vunpcklps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6416   [(set_attr "type" "sselog")
6417    (set_attr "prefix" "evex")
6418    (set_attr "mode" "V16SF")])
6420 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
6421 (define_insn "avx_unpcklps256<mask_name>"
6422   [(set (match_operand:V8SF 0 "register_operand" "=v")
6423         (vec_select:V8SF
6424           (vec_concat:V16SF
6425             (match_operand:V8SF 1 "register_operand" "v")
6426             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6427           (parallel [(const_int 0) (const_int 8)
6428                      (const_int 1) (const_int 9)
6429                      (const_int 4) (const_int 12)
6430                      (const_int 5) (const_int 13)])))]
6431   "TARGET_AVX && <mask_avx512vl_condition>"
6432   "vunpcklps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6433   [(set_attr "type" "sselog")
6434    (set_attr "prefix" "vex")
6435    (set_attr "mode" "V8SF")])
6437 (define_insn "unpcklps128_mask"
6438   [(set (match_operand:V4SF 0 "register_operand" "=v")
6439         (vec_merge:V4SF
6440           (vec_select:V4SF
6441             (vec_concat:V8SF
6442               (match_operand:V4SF 1 "register_operand" "v")
6443               (match_operand:V4SF 2 "nonimmediate_operand" "vm"))
6444             (parallel [(const_int 0) (const_int 4)
6445                       (const_int 1) (const_int 5)]))
6446           (match_operand:V4SF 3 "vector_move_operand" "0C")
6447           (match_operand:QI 4 "register_operand" "Yk")))]
6448   "TARGET_AVX512VL"
6449   "vunpcklps\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
6450   [(set_attr "type" "sselog")
6451    (set_attr "prefix" "evex")
6452    (set_attr "mode" "V4SF")])
6454 (define_expand "vec_interleave_lowv8sf"
6455   [(set (match_dup 3)
6456         (vec_select:V8SF
6457           (vec_concat:V16SF
6458             (match_operand:V8SF 1 "register_operand")
6459             (match_operand:V8SF 2 "nonimmediate_operand"))
6460           (parallel [(const_int 0) (const_int 8)
6461                      (const_int 1) (const_int 9)
6462                      (const_int 4) (const_int 12)
6463                      (const_int 5) (const_int 13)])))
6464    (set (match_dup 4)
6465         (vec_select:V8SF
6466           (vec_concat:V16SF
6467             (match_dup 1)
6468             (match_dup 2))
6469           (parallel [(const_int 2) (const_int 10)
6470                      (const_int 3) (const_int 11)
6471                      (const_int 6) (const_int 14)
6472                      (const_int 7) (const_int 15)])))
6473    (set (match_operand:V8SF 0 "register_operand")
6474         (vec_select:V8SF
6475           (vec_concat:V16SF
6476             (match_dup 3)
6477             (match_dup 4))
6478           (parallel [(const_int 0) (const_int 1)
6479                      (const_int 2) (const_int 3)
6480                      (const_int 8) (const_int 9)
6481                      (const_int 10) (const_int 11)])))]
6482  "TARGET_AVX"
6484   operands[3] = gen_reg_rtx (V8SFmode);
6485   operands[4] = gen_reg_rtx (V8SFmode);
6488 (define_insn "vec_interleave_lowv4sf"
6489   [(set (match_operand:V4SF 0 "register_operand" "=x,v")
6490         (vec_select:V4SF
6491           (vec_concat:V8SF
6492             (match_operand:V4SF 1 "register_operand" "0,v")
6493             (match_operand:V4SF 2 "vector_operand" "xBm,vm"))
6494           (parallel [(const_int 0) (const_int 4)
6495                      (const_int 1) (const_int 5)])))]
6496   "TARGET_SSE"
6497   "@
6498    unpcklps\t{%2, %0|%0, %2}
6499    vunpcklps\t{%2, %1, %0|%0, %1, %2}"
6500   [(set_attr "isa" "noavx,avx")
6501    (set_attr "type" "sselog")
6502    (set_attr "prefix" "orig,maybe_evex")
6503    (set_attr "mode" "V4SF")])
6505 ;; These are modeled with the same vec_concat as the others so that we
6506 ;; capture users of shufps that can use the new instructions
6507 (define_insn "avx_movshdup256<mask_name>"
6508   [(set (match_operand:V8SF 0 "register_operand" "=v")
6509         (vec_select:V8SF
6510           (vec_concat:V16SF
6511             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
6512             (match_dup 1))
6513           (parallel [(const_int 1) (const_int 1)
6514                      (const_int 3) (const_int 3)
6515                      (const_int 5) (const_int 5)
6516                      (const_int 7) (const_int 7)])))]
6517   "TARGET_AVX && <mask_avx512vl_condition>"
6518   "vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6519   [(set_attr "type" "sse")
6520    (set_attr "prefix" "vex")
6521    (set_attr "mode" "V8SF")])
6523 (define_insn "sse3_movshdup<mask_name>"
6524   [(set (match_operand:V4SF 0 "register_operand" "=v")
6525         (vec_select:V4SF
6526           (vec_concat:V8SF
6527             (match_operand:V4SF 1 "vector_operand" "vBm")
6528             (match_dup 1))
6529           (parallel [(const_int 1)
6530                      (const_int 1)
6531                      (const_int 7)
6532                      (const_int 7)])))]
6533   "TARGET_SSE3 && <mask_avx512vl_condition>"
6534   "%vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6535   [(set_attr "type" "sse")
6536    (set_attr "prefix_rep" "1")
6537    (set_attr "prefix" "maybe_vex")
6538    (set_attr "mode" "V4SF")])
6540 (define_insn "<mask_codefor>avx512f_movshdup512<mask_name>"
6541   [(set (match_operand:V16SF 0 "register_operand" "=v")
6542         (vec_select:V16SF
6543           (vec_concat:V32SF
6544             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
6545             (match_dup 1))
6546           (parallel [(const_int 1) (const_int 1)
6547                      (const_int 3) (const_int 3)
6548                      (const_int 5) (const_int 5)
6549                      (const_int 7) (const_int 7)
6550                      (const_int 9) (const_int 9)
6551                      (const_int 11) (const_int 11)
6552                      (const_int 13) (const_int 13)
6553                      (const_int 15) (const_int 15)])))]
6554   "TARGET_AVX512F"
6555   "vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6556   [(set_attr "type" "sse")
6557    (set_attr "prefix" "evex")
6558    (set_attr "mode" "V16SF")])
6560 (define_insn "avx_movsldup256<mask_name>"
6561   [(set (match_operand:V8SF 0 "register_operand" "=v")
6562         (vec_select:V8SF
6563           (vec_concat:V16SF
6564             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
6565             (match_dup 1))
6566           (parallel [(const_int 0) (const_int 0)
6567                      (const_int 2) (const_int 2)
6568                      (const_int 4) (const_int 4)
6569                      (const_int 6) (const_int 6)])))]
6570   "TARGET_AVX && <mask_avx512vl_condition>"
6571   "vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6572   [(set_attr "type" "sse")
6573    (set_attr "prefix" "vex")
6574    (set_attr "mode" "V8SF")])
6576 (define_insn "sse3_movsldup<mask_name>"
6577   [(set (match_operand:V4SF 0 "register_operand" "=v")
6578         (vec_select:V4SF
6579           (vec_concat:V8SF
6580             (match_operand:V4SF 1 "vector_operand" "vBm")
6581             (match_dup 1))
6582           (parallel [(const_int 0)
6583                      (const_int 0)
6584                      (const_int 6)
6585                      (const_int 6)])))]
6586   "TARGET_SSE3 && <mask_avx512vl_condition>"
6587   "%vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6588   [(set_attr "type" "sse")
6589    (set_attr "prefix_rep" "1")
6590    (set_attr "prefix" "maybe_vex")
6591    (set_attr "mode" "V4SF")])
6593 (define_insn "<mask_codefor>avx512f_movsldup512<mask_name>"
6594   [(set (match_operand:V16SF 0 "register_operand" "=v")
6595         (vec_select:V16SF
6596           (vec_concat:V32SF
6597             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
6598             (match_dup 1))
6599           (parallel [(const_int 0) (const_int 0)
6600                      (const_int 2) (const_int 2)
6601                      (const_int 4) (const_int 4)
6602                      (const_int 6) (const_int 6)
6603                      (const_int 8) (const_int 8)
6604                      (const_int 10) (const_int 10)
6605                      (const_int 12) (const_int 12)
6606                      (const_int 14) (const_int 14)])))]
6607   "TARGET_AVX512F"
6608   "vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6609   [(set_attr "type" "sse")
6610    (set_attr "prefix" "evex")
6611    (set_attr "mode" "V16SF")])
6613 (define_expand "avx_shufps256<mask_expand4_name>"
6614   [(match_operand:V8SF 0 "register_operand")
6615    (match_operand:V8SF 1 "register_operand")
6616    (match_operand:V8SF 2 "nonimmediate_operand")
6617    (match_operand:SI 3 "const_int_operand")]
6618   "TARGET_AVX"
6620   int mask = INTVAL (operands[3]);
6621   emit_insn (gen_avx_shufps256_1<mask_expand4_name> (operands[0],
6622                                                      operands[1],
6623                                                      operands[2],
6624                                                      GEN_INT ((mask >> 0) & 3),
6625                                                      GEN_INT ((mask >> 2) & 3),
6626                                                      GEN_INT (((mask >> 4) & 3) + 8),
6627                                                      GEN_INT (((mask >> 6) & 3) + 8),
6628                                                      GEN_INT (((mask >> 0) & 3) + 4),
6629                                                      GEN_INT (((mask >> 2) & 3) + 4),
6630                                                      GEN_INT (((mask >> 4) & 3) + 12),
6631                                                      GEN_INT (((mask >> 6) & 3) + 12)
6632                                                      <mask_expand4_args>));
6633   DONE;
6636 ;; One bit in mask selects 2 elements.
6637 (define_insn "avx_shufps256_1<mask_name>"
6638   [(set (match_operand:V8SF 0 "register_operand" "=v")
6639         (vec_select:V8SF
6640           (vec_concat:V16SF
6641             (match_operand:V8SF 1 "register_operand" "v")
6642             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6643           (parallel [(match_operand 3  "const_0_to_3_operand"  )
6644                      (match_operand 4  "const_0_to_3_operand"  )
6645                      (match_operand 5  "const_8_to_11_operand" )
6646                      (match_operand 6  "const_8_to_11_operand" )
6647                      (match_operand 7  "const_4_to_7_operand"  )
6648                      (match_operand 8  "const_4_to_7_operand"  )
6649                      (match_operand 9  "const_12_to_15_operand")
6650                      (match_operand 10 "const_12_to_15_operand")])))]
6651   "TARGET_AVX
6652    && <mask_avx512vl_condition>
6653    && (INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
6654        && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
6655        && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4)
6656        && INTVAL (operands[6]) == (INTVAL (operands[10]) - 4))"
6658   int mask;
6659   mask = INTVAL (operands[3]);
6660   mask |= INTVAL (operands[4]) << 2;
6661   mask |= (INTVAL (operands[5]) - 8) << 4;
6662   mask |= (INTVAL (operands[6]) - 8) << 6;
6663   operands[3] = GEN_INT (mask);
6665   return "vshufps\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
6667   [(set_attr "type" "sseshuf")
6668    (set_attr "length_immediate" "1")
6669    (set_attr "prefix" "<mask_prefix>")
6670    (set_attr "mode" "V8SF")])
6672 (define_expand "sse_shufps<mask_expand4_name>"
6673   [(match_operand:V4SF 0 "register_operand")
6674    (match_operand:V4SF 1 "register_operand")
6675    (match_operand:V4SF 2 "vector_operand")
6676    (match_operand:SI 3 "const_int_operand")]
6677   "TARGET_SSE"
6679   int mask = INTVAL (operands[3]);
6680   emit_insn (gen_sse_shufps_v4sf<mask_expand4_name> (operands[0],
6681                                                      operands[1],
6682                                                      operands[2],
6683                                                      GEN_INT ((mask >> 0) & 3),
6684                                                      GEN_INT ((mask >> 2) & 3),
6685                                                      GEN_INT (((mask >> 4) & 3) + 4),
6686                                                      GEN_INT (((mask >> 6) & 3) + 4)
6687                                                      <mask_expand4_args>));
6688   DONE;
6691 (define_insn "sse_shufps_v4sf_mask"
6692   [(set (match_operand:V4SF 0 "register_operand" "=v")
6693     (vec_merge:V4SF
6694           (vec_select:V4SF
6695             (vec_concat:V8SF
6696               (match_operand:V4SF 1 "register_operand" "v")
6697               (match_operand:V4SF 2 "nonimmediate_operand" "vm"))
6698             (parallel [(match_operand 3 "const_0_to_3_operand")
6699                        (match_operand 4 "const_0_to_3_operand")
6700                        (match_operand 5 "const_4_to_7_operand")
6701                        (match_operand 6 "const_4_to_7_operand")]))
6702       (match_operand:V4SF 7 "vector_move_operand" "0C")
6703       (match_operand:QI 8 "register_operand" "Yk")))]
6704   "TARGET_AVX512VL"
6706   int mask = 0;
6707   mask |= INTVAL (operands[3]) << 0;
6708   mask |= INTVAL (operands[4]) << 2;
6709   mask |= (INTVAL (operands[5]) - 4) << 4;
6710   mask |= (INTVAL (operands[6]) - 4) << 6;
6711   operands[3] = GEN_INT (mask);
6713   return "vshufps\t{%3, %2, %1, %0%{%8%}%N7|%0%{%8%}%N7, %1, %2, %3}";
6715   [(set_attr "type" "sseshuf")
6716    (set_attr "length_immediate" "1")
6717    (set_attr "prefix" "evex")
6718    (set_attr "mode" "V4SF")])
6720 (define_insn "sse_shufps_<mode>"
6721   [(set (match_operand:VI4F_128 0 "register_operand" "=x,v")
6722         (vec_select:VI4F_128
6723           (vec_concat:<ssedoublevecmode>
6724             (match_operand:VI4F_128 1 "register_operand" "0,v")
6725             (match_operand:VI4F_128 2 "vector_operand" "xBm,vm"))
6726           (parallel [(match_operand 3 "const_0_to_3_operand")
6727                      (match_operand 4 "const_0_to_3_operand")
6728                      (match_operand 5 "const_4_to_7_operand")
6729                      (match_operand 6 "const_4_to_7_operand")])))]
6730   "TARGET_SSE"
6732   int mask = 0;
6733   mask |= INTVAL (operands[3]) << 0;
6734   mask |= INTVAL (operands[4]) << 2;
6735   mask |= (INTVAL (operands[5]) - 4) << 4;
6736   mask |= (INTVAL (operands[6]) - 4) << 6;
6737   operands[3] = GEN_INT (mask);
6739   switch (which_alternative)
6740     {
6741     case 0:
6742       return "shufps\t{%3, %2, %0|%0, %2, %3}";
6743     case 1:
6744       return "vshufps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
6745     default:
6746       gcc_unreachable ();
6747     }
6749   [(set_attr "isa" "noavx,avx")
6750    (set_attr "type" "sseshuf")
6751    (set_attr "length_immediate" "1")
6752    (set_attr "prefix" "orig,maybe_evex")
6753    (set_attr "mode" "V4SF")])
6755 (define_insn "sse_storehps"
6756   [(set (match_operand:V2SF 0 "nonimmediate_operand" "=m,v,v")
6757         (vec_select:V2SF
6758           (match_operand:V4SF 1 "nonimmediate_operand" "v,v,o")
6759           (parallel [(const_int 2) (const_int 3)])))]
6760   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
6761   "@
6762    %vmovhps\t{%1, %0|%q0, %1}
6763    %vmovhlps\t{%1, %d0|%d0, %1}
6764    %vmovlps\t{%H1, %d0|%d0, %H1}"
6765   [(set_attr "type" "ssemov")
6766    (set_attr "prefix" "maybe_vex")
6767    (set_attr "mode" "V2SF,V4SF,V2SF")])
6769 (define_expand "sse_loadhps_exp"
6770   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6771         (vec_concat:V4SF
6772           (vec_select:V2SF
6773             (match_operand:V4SF 1 "nonimmediate_operand")
6774             (parallel [(const_int 0) (const_int 1)]))
6775           (match_operand:V2SF 2 "nonimmediate_operand")))]
6776   "TARGET_SSE"
6778   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6780   emit_insn (gen_sse_loadhps (dst, operands[1], operands[2]));
6782   /* Fix up the destination if needed.  */
6783   if (dst != operands[0])
6784     emit_move_insn (operands[0], dst);
6786   DONE;
6789 (define_insn "sse_loadhps"
6790   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,o")
6791         (vec_concat:V4SF
6792           (vec_select:V2SF
6793             (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
6794             (parallel [(const_int 0) (const_int 1)]))
6795           (match_operand:V2SF 2 "nonimmediate_operand"   " m,m,x,v,v")))]
6796   "TARGET_SSE"
6797   "@
6798    movhps\t{%2, %0|%0, %q2}
6799    vmovhps\t{%2, %1, %0|%0, %1, %q2}
6800    movlhps\t{%2, %0|%0, %2}
6801    vmovlhps\t{%2, %1, %0|%0, %1, %2}
6802    %vmovlps\t{%2, %H0|%H0, %2}"
6803   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6804    (set_attr "type" "ssemov")
6805    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
6806    (set_attr "mode" "V2SF,V2SF,V4SF,V4SF,V2SF")])
6808 (define_insn "sse_storelps"
6809   [(set (match_operand:V2SF 0 "nonimmediate_operand"   "=m,v,v")
6810         (vec_select:V2SF
6811           (match_operand:V4SF 1 "nonimmediate_operand" " v,v,m")
6812           (parallel [(const_int 0) (const_int 1)])))]
6813   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
6814   "@
6815    %vmovlps\t{%1, %0|%q0, %1}
6816    %vmovaps\t{%1, %0|%0, %1}
6817    %vmovlps\t{%1, %d0|%d0, %q1}"
6818   [(set_attr "type" "ssemov")
6819    (set_attr "prefix" "maybe_vex")
6820    (set_attr "mode" "V2SF,V4SF,V2SF")])
6822 (define_expand "sse_loadlps_exp"
6823   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6824         (vec_concat:V4SF
6825           (match_operand:V2SF 2 "nonimmediate_operand")
6826           (vec_select:V2SF
6827             (match_operand:V4SF 1 "nonimmediate_operand")
6828             (parallel [(const_int 2) (const_int 3)]))))]
6829   "TARGET_SSE"
6831   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6833   emit_insn (gen_sse_loadlps (dst, operands[1], operands[2]));
6835   /* Fix up the destination if needed.  */
6836   if (dst != operands[0])
6837     emit_move_insn (operands[0], dst);
6839   DONE;
6842 (define_insn "sse_loadlps"
6843   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,m")
6844         (vec_concat:V4SF
6845           (match_operand:V2SF 2 "nonimmediate_operand"   " 0,v,m,m,v")
6846           (vec_select:V2SF
6847             (match_operand:V4SF 1 "nonimmediate_operand" " x,v,0,v,0")
6848             (parallel [(const_int 2) (const_int 3)]))))]
6849   "TARGET_SSE"
6850   "@
6851    shufps\t{$0xe4, %1, %0|%0, %1, 0xe4}
6852    vshufps\t{$0xe4, %1, %2, %0|%0, %2, %1, 0xe4}
6853    movlps\t{%2, %0|%0, %q2}
6854    vmovlps\t{%2, %1, %0|%0, %1, %q2}
6855    %vmovlps\t{%2, %0|%q0, %2}"
6856   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6857    (set_attr "type" "sseshuf,sseshuf,ssemov,ssemov,ssemov")
6858    (set (attr "length_immediate")
6859      (if_then_else (eq_attr "alternative" "0,1")
6860                    (const_string "1")
6861                    (const_string "*")))
6862    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
6863    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
6865 (define_insn "sse_movss"
6866   [(set (match_operand:V4SF 0 "register_operand"   "=x,v")
6867         (vec_merge:V4SF
6868           (match_operand:V4SF 2 "register_operand" " x,v")
6869           (match_operand:V4SF 1 "register_operand" " 0,v")
6870           (const_int 1)))]
6871   "TARGET_SSE"
6872   "@
6873    movss\t{%2, %0|%0, %2}
6874    vmovss\t{%2, %1, %0|%0, %1, %2}"
6875   [(set_attr "isa" "noavx,avx")
6876    (set_attr "type" "ssemov")
6877    (set_attr "prefix" "orig,maybe_evex")
6878    (set_attr "mode" "SF")])
6880 (define_insn "avx2_vec_dup<mode>"
6881   [(set (match_operand:VF1_128_256 0 "register_operand" "=v")
6882         (vec_duplicate:VF1_128_256
6883           (vec_select:SF
6884             (match_operand:V4SF 1 "register_operand" "v")
6885             (parallel [(const_int 0)]))))]
6886   "TARGET_AVX2"
6887   "vbroadcastss\t{%1, %0|%0, %1}"
6888   [(set_attr "type" "sselog1")
6889     (set_attr "prefix" "maybe_evex")
6890     (set_attr "mode" "<MODE>")])
6892 (define_insn "avx2_vec_dupv8sf_1"
6893   [(set (match_operand:V8SF 0 "register_operand" "=v")
6894         (vec_duplicate:V8SF
6895           (vec_select:SF
6896             (match_operand:V8SF 1 "register_operand" "v")
6897             (parallel [(const_int 0)]))))]
6898   "TARGET_AVX2"
6899   "vbroadcastss\t{%x1, %0|%0, %x1}"
6900   [(set_attr "type" "sselog1")
6901     (set_attr "prefix" "maybe_evex")
6902     (set_attr "mode" "V8SF")])
6904 (define_insn "avx512f_vec_dup<mode>_1"
6905   [(set (match_operand:VF_512 0 "register_operand" "=v")
6906         (vec_duplicate:VF_512
6907           (vec_select:<ssescalarmode>
6908             (match_operand:VF_512 1 "register_operand" "v")
6909             (parallel [(const_int 0)]))))]
6910   "TARGET_AVX512F"
6911   "vbroadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}"
6912   [(set_attr "type" "sselog1")
6913     (set_attr "prefix" "evex")
6914     (set_attr "mode" "<MODE>")])
6916 ;; Although insertps takes register source, we prefer
6917 ;; unpcklps with register source since it is shorter.
6918 (define_insn "*vec_concatv2sf_sse4_1"
6919   [(set (match_operand:V2SF 0 "register_operand"
6920           "=Yr,*x, v,Yr,*x,v,v,*y ,*y")
6921         (vec_concat:V2SF
6922           (match_operand:SF 1 "nonimmediate_operand"
6923           "  0, 0,Yv, 0,0, v,m, 0 , m")
6924           (match_operand:SF 2 "vector_move_operand"
6925           " Yr,*x,Yv, m,m, m,C,*ym, C")))]
6926   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
6927   "@
6928    unpcklps\t{%2, %0|%0, %2}
6929    unpcklps\t{%2, %0|%0, %2}
6930    vunpcklps\t{%2, %1, %0|%0, %1, %2}
6931    insertps\t{$0x10, %2, %0|%0, %2, 0x10}
6932    insertps\t{$0x10, %2, %0|%0, %2, 0x10}
6933    vinsertps\t{$0x10, %2, %1, %0|%0, %1, %2, 0x10}
6934    %vmovss\t{%1, %0|%0, %1}
6935    punpckldq\t{%2, %0|%0, %2}
6936    movd\t{%1, %0|%0, %1}"
6937   [(set (attr "isa")
6938      (cond [(eq_attr "alternative" "0,1,3,4")
6939               (const_string "noavx")
6940             (eq_attr "alternative" "2,5")
6941               (const_string "avx")
6942            ]
6943            (const_string "*")))
6944    (set (attr "type")
6945      (cond [(eq_attr "alternative" "6")
6946               (const_string "ssemov")
6947             (eq_attr "alternative" "7")
6948               (const_string "mmxcvt")
6949             (eq_attr "alternative" "8")
6950               (const_string "mmxmov")
6951            ]
6952            (const_string "sselog")))
6953    (set (attr "prefix_data16")
6954      (if_then_else (eq_attr "alternative" "3,4")
6955                    (const_string "1")
6956                    (const_string "*")))
6957    (set (attr "prefix_extra")
6958      (if_then_else (eq_attr "alternative" "3,4,5")
6959                    (const_string "1")
6960                    (const_string "*")))
6961    (set (attr "length_immediate")
6962      (if_then_else (eq_attr "alternative" "3,4,5")
6963                    (const_string "1")
6964                    (const_string "*")))
6965    (set (attr "prefix")
6966      (cond [(eq_attr "alternative" "2,5")
6967               (const_string "maybe_evex")
6968             (eq_attr "alternative" "6")
6969               (const_string "maybe_vex")
6970            ]
6971            (const_string "orig")))
6972    (set_attr "mode" "V4SF,V4SF,V4SF,V4SF,V4SF,V4SF,SF,DI,DI")])
6974 ;; ??? In theory we can match memory for the MMX alternative, but allowing
6975 ;; vector_operand for operand 2 and *not* allowing memory for the SSE
6976 ;; alternatives pretty much forces the MMX alternative to be chosen.
6977 (define_insn "*vec_concatv2sf_sse"
6978   [(set (match_operand:V2SF 0 "register_operand"     "=x,x,*y,*y")
6979         (vec_concat:V2SF
6980           (match_operand:SF 1 "nonimmediate_operand" " 0,m, 0, m")
6981           (match_operand:SF 2 "reg_or_0_operand"     " x,C,*y, C")))]
6982   "TARGET_SSE"
6983   "@
6984    unpcklps\t{%2, %0|%0, %2}
6985    movss\t{%1, %0|%0, %1}
6986    punpckldq\t{%2, %0|%0, %2}
6987    movd\t{%1, %0|%0, %1}"
6988   [(set_attr "type" "sselog,ssemov,mmxcvt,mmxmov")
6989    (set_attr "mode" "V4SF,SF,DI,DI")])
6991 (define_insn "*vec_concatv4sf"
6992   [(set (match_operand:V4SF 0 "register_operand"       "=x,v,x,v")
6993         (vec_concat:V4SF
6994           (match_operand:V2SF 1 "register_operand"     " 0,v,0,v")
6995           (match_operand:V2SF 2 "nonimmediate_operand" " x,v,m,m")))]
6996   "TARGET_SSE"
6997   "@
6998    movlhps\t{%2, %0|%0, %2}
6999    vmovlhps\t{%2, %1, %0|%0, %1, %2}
7000    movhps\t{%2, %0|%0, %q2}
7001    vmovhps\t{%2, %1, %0|%0, %1, %q2}"
7002   [(set_attr "isa" "noavx,avx,noavx,avx")
7003    (set_attr "type" "ssemov")
7004    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex")
7005    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF")])
7007 ;; Avoid combining registers from different units in a single alternative,
7008 ;; see comment above inline_secondary_memory_needed function in i386.c
7009 (define_insn "vec_set<mode>_0"
7010   [(set (match_operand:VI4F_128 0 "nonimmediate_operand"
7011           "=Yr,*x,v,v,v,x,x,v,Yr ,*x ,x  ,m ,m   ,m")
7012         (vec_merge:VI4F_128
7013           (vec_duplicate:VI4F_128
7014             (match_operand:<ssescalarmode> 2 "general_operand"
7015           " Yr,*x,v,m,r ,m,x,v,*rm,*rm,*rm,!x,!*re,!*fF"))
7016           (match_operand:VI4F_128 1 "vector_move_operand"
7017           " C , C,C,C,C ,C,0,v,0  ,0  ,x  ,0 ,0   ,0")
7018           (const_int 1)))]
7019   "TARGET_SSE"
7020   "@
7021    insertps\t{$0xe, %2, %0|%0, %2, 0xe}
7022    insertps\t{$0xe, %2, %0|%0, %2, 0xe}
7023    vinsertps\t{$0xe, %2, %2, %0|%0, %2, %2, 0xe}
7024    %vmov<ssescalarmodesuffix>\t{%2, %0|%0, %2}
7025    %vmovd\t{%2, %0|%0, %2}
7026    movss\t{%2, %0|%0, %2}
7027    movss\t{%2, %0|%0, %2}
7028    vmovss\t{%2, %1, %0|%0, %1, %2}
7029    pinsrd\t{$0, %2, %0|%0, %2, 0}
7030    pinsrd\t{$0, %2, %0|%0, %2, 0}
7031    vpinsrd\t{$0, %2, %1, %0|%0, %1, %2, 0}
7032    #
7033    #
7034    #"
7035   [(set (attr "isa")
7036      (cond [(eq_attr "alternative" "0,1,8,9")
7037               (const_string "sse4_noavx")
7038             (eq_attr "alternative" "2,7,10")
7039               (const_string "avx")
7040             (eq_attr "alternative" "3,4")
7041               (const_string "sse2")
7042             (eq_attr "alternative" "5,6")
7043               (const_string "noavx")
7044            ]
7045            (const_string "*")))
7046    (set (attr "type")
7047      (cond [(eq_attr "alternative" "0,1,2,8,9,10")
7048               (const_string "sselog")
7049             (eq_attr "alternative" "12")
7050               (const_string "imov")
7051             (eq_attr "alternative" "13")
7052               (const_string "fmov")
7053            ]
7054            (const_string "ssemov")))
7055    (set (attr "prefix_extra")
7056      (if_then_else (eq_attr "alternative" "8,9,10")
7057                    (const_string "1")
7058                    (const_string "*")))
7059    (set (attr "length_immediate")
7060      (if_then_else (eq_attr "alternative" "8,9,10")
7061                    (const_string "1")
7062                    (const_string "*")))
7063    (set (attr "prefix")
7064      (cond [(eq_attr "alternative" "0,1,5,6,8,9")
7065               (const_string "orig")
7066             (eq_attr "alternative" "2")
7067               (const_string "maybe_evex")
7068             (eq_attr "alternative" "3,4")
7069               (const_string "maybe_vex")
7070             (eq_attr "alternative" "7,10")
7071               (const_string "vex")
7072            ]
7073            (const_string "*")))
7074    (set_attr "mode" "SF,SF,SF,<ssescalarmode>,SI,SF,SF,SF,TI,TI,TI,*,*,*")
7075    (set (attr "preferred_for_speed")
7076      (cond [(eq_attr "alternative" "4")
7077               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
7078            ]
7079            (symbol_ref "true")))])
7081 ;; A subset is vec_setv4sf.
7082 (define_insn "*vec_setv4sf_sse4_1"
7083   [(set (match_operand:V4SF 0 "register_operand" "=Yr,*x,v")
7084         (vec_merge:V4SF
7085           (vec_duplicate:V4SF
7086             (match_operand:SF 2 "nonimmediate_operand" "Yrm,*xm,vm"))
7087           (match_operand:V4SF 1 "register_operand" "0,0,v")
7088           (match_operand:SI 3 "const_int_operand")))]
7089   "TARGET_SSE4_1
7090    && ((unsigned) exact_log2 (INTVAL (operands[3]))
7091        < GET_MODE_NUNITS (V4SFmode))"
7093   operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])) << 4);
7094   switch (which_alternative)
7095     {
7096     case 0:
7097     case 1:
7098       return "insertps\t{%3, %2, %0|%0, %2, %3}";
7099     case 2:
7100       return "vinsertps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
7101     default:
7102       gcc_unreachable ();
7103     }
7105   [(set_attr "isa" "noavx,noavx,avx")
7106    (set_attr "type" "sselog")
7107    (set_attr "prefix_data16" "1,1,*")
7108    (set_attr "prefix_extra" "1")
7109    (set_attr "length_immediate" "1")
7110    (set_attr "prefix" "orig,orig,maybe_evex")
7111    (set_attr "mode" "V4SF")])
7113 ;; All of vinsertps, vmovss, vmovd clear also the higher bits.
7114 (define_insn "vec_set<mode>_0"
7115   [(set (match_operand:VI4F_256_512 0 "register_operand" "=v,v,v")
7116         (vec_merge:VI4F_256_512
7117           (vec_duplicate:VI4F_256_512
7118             (match_operand:<ssescalarmode> 2 "general_operand" "v,m,r"))
7119           (match_operand:VI4F_256_512 1 "const0_operand" "C,C,C")
7120           (const_int 1)))]
7121   "TARGET_AVX"
7122   "@
7123    vinsertps\t{$0xe, %2, %2, %x0|%x0, %2, %2, 0xe}
7124    vmov<ssescalarmodesuffix>\t{%x2, %x0|%x0, %2}
7125    vmovd\t{%2, %x0|%x0, %2}"
7126   [(set (attr "type")
7127      (if_then_else (eq_attr "alternative" "0")
7128                    (const_string "sselog")
7129                    (const_string "ssemov")))
7130    (set_attr "prefix" "maybe_evex")
7131    (set_attr "mode" "SF,<ssescalarmode>,SI")
7132    (set (attr "preferred_for_speed")
7133      (cond [(eq_attr "alternative" "2")
7134               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
7135            ]
7136            (symbol_ref "true")))])
7138 (define_insn "sse4_1_insertps"
7139   [(set (match_operand:V4SF 0 "register_operand" "=Yr,*x,v")
7140         (unspec:V4SF [(match_operand:V4SF 2 "nonimmediate_operand" "Yrm,*xm,vm")
7141                       (match_operand:V4SF 1 "register_operand" "0,0,v")
7142                       (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
7143                      UNSPEC_INSERTPS))]
7144   "TARGET_SSE4_1"
7146   if (MEM_P (operands[2]))
7147     {
7148       unsigned count_s = INTVAL (operands[3]) >> 6;
7149       if (count_s)
7150         operands[3] = GEN_INT (INTVAL (operands[3]) & 0x3f);
7151       operands[2] = adjust_address_nv (operands[2], SFmode, count_s * 4);
7152     }
7153   switch (which_alternative)
7154     {
7155     case 0:
7156     case 1:
7157       return "insertps\t{%3, %2, %0|%0, %2, %3}";
7158     case 2:
7159       return "vinsertps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
7160     default:
7161       gcc_unreachable ();
7162     }
7164   [(set_attr "isa" "noavx,noavx,avx")
7165    (set_attr "type" "sselog")
7166    (set_attr "prefix_data16" "1,1,*")
7167    (set_attr "prefix_extra" "1")
7168    (set_attr "length_immediate" "1")
7169    (set_attr "prefix" "orig,orig,maybe_evex")
7170    (set_attr "mode" "V4SF")])
7172 (define_split
7173   [(set (match_operand:VI4F_128 0 "memory_operand")
7174         (vec_merge:VI4F_128
7175           (vec_duplicate:VI4F_128
7176             (match_operand:<ssescalarmode> 1 "nonmemory_operand"))
7177           (match_dup 0)
7178           (const_int 1)))]
7179   "TARGET_SSE && reload_completed"
7180   [(set (match_dup 0) (match_dup 1))]
7181   "operands[0] = adjust_address (operands[0], <ssescalarmode>mode, 0);")
7183 (define_expand "vec_set<mode>"
7184   [(match_operand:V 0 "register_operand")
7185    (match_operand:<ssescalarmode> 1 "register_operand")
7186    (match_operand 2 "const_int_operand")]
7187   "TARGET_SSE"
7189   ix86_expand_vector_set (false, operands[0], operands[1],
7190                           INTVAL (operands[2]));
7191   DONE;
7194 (define_insn_and_split "*vec_extractv4sf_0"
7195   [(set (match_operand:SF 0 "nonimmediate_operand" "=v,m,f,r")
7196         (vec_select:SF
7197           (match_operand:V4SF 1 "nonimmediate_operand" "vm,v,m,m")
7198           (parallel [(const_int 0)])))]
7199   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7200   "#"
7201   "&& reload_completed"
7202   [(set (match_dup 0) (match_dup 1))]
7203   "operands[1] = gen_lowpart (SFmode, operands[1]);")
7205 (define_insn_and_split "*sse4_1_extractps"
7206   [(set (match_operand:SF 0 "nonimmediate_operand" "=rm,rm,rm,Yv,Yv")
7207         (vec_select:SF
7208           (match_operand:V4SF 1 "register_operand" "Yr,*x,v,0,v")
7209           (parallel [(match_operand:SI 2 "const_0_to_3_operand" "n,n,n,n,n")])))]
7210   "TARGET_SSE4_1"
7211   "@
7212    extractps\t{%2, %1, %0|%0, %1, %2}
7213    extractps\t{%2, %1, %0|%0, %1, %2}
7214    vextractps\t{%2, %1, %0|%0, %1, %2}
7215    #
7216    #"
7217   "&& reload_completed && SSE_REG_P (operands[0])"
7218   [(const_int 0)]
7220   rtx dest = lowpart_subreg (V4SFmode, operands[0], SFmode);
7221   switch (INTVAL (operands[2]))
7222     {
7223     case 1:
7224     case 3:
7225       emit_insn (gen_sse_shufps_v4sf (dest, operands[1], operands[1],
7226                                       operands[2], operands[2],
7227                                       GEN_INT (INTVAL (operands[2]) + 4),
7228                                       GEN_INT (INTVAL (operands[2]) + 4)));
7229       break;
7230     case 2:
7231       emit_insn (gen_vec_interleave_highv4sf (dest, operands[1], operands[1]));
7232       break;
7233     default:
7234       /* 0 should be handled by the *vec_extractv4sf_0 pattern above.  */
7235       gcc_unreachable ();
7236     }
7237   DONE;
7239   [(set_attr "isa" "noavx,noavx,avx,noavx,avx")
7240    (set_attr "type" "sselog,sselog,sselog,*,*")
7241    (set_attr "prefix_data16" "1,1,1,*,*")
7242    (set_attr "prefix_extra" "1,1,1,*,*")
7243    (set_attr "length_immediate" "1,1,1,*,*")
7244    (set_attr "prefix" "orig,orig,maybe_evex,*,*")
7245    (set_attr "mode" "V4SF,V4SF,V4SF,*,*")])
7247 (define_insn_and_split "*vec_extractv4sf_mem"
7248   [(set (match_operand:SF 0 "register_operand" "=v,*r,f")
7249         (vec_select:SF
7250           (match_operand:V4SF 1 "memory_operand" "o,o,o")
7251           (parallel [(match_operand 2 "const_0_to_3_operand" "n,n,n")])))]
7252   "TARGET_SSE"
7253   "#"
7254   "&& reload_completed"
7255   [(set (match_dup 0) (match_dup 1))]
7257   operands[1] = adjust_address (operands[1], SFmode, INTVAL (operands[2]) * 4);
7260 (define_mode_attr extract_type
7261   [(V16SF "avx512f") (V16SI "avx512f") (V8DF "avx512dq") (V8DI "avx512dq")])
7263 (define_mode_attr extract_suf
7264   [(V16SF "32x4") (V16SI "32x4") (V8DF "64x2") (V8DI "64x2")])
7266 (define_mode_iterator AVX512_VEC
7267   [(V8DF "TARGET_AVX512DQ") (V8DI "TARGET_AVX512DQ") V16SF V16SI])
7269 (define_expand "<extract_type>_vextract<shuffletype><extract_suf>_mask"
7270   [(match_operand:<ssequartermode> 0 "nonimmediate_operand")
7271    (match_operand:AVX512_VEC 1 "register_operand")
7272    (match_operand:SI 2 "const_0_to_3_operand")
7273    (match_operand:<ssequartermode> 3 "nonimmediate_operand")
7274    (match_operand:QI 4 "register_operand")]
7275   "TARGET_AVX512F"
7277   int mask;
7278   mask = INTVAL (operands[2]);
7279   rtx dest = operands[0];
7281   if (MEM_P (operands[0]) && !rtx_equal_p (operands[0], operands[3]))
7282     dest = gen_reg_rtx (<ssequartermode>mode);
7284   if (<MODE>mode == V16SImode || <MODE>mode == V16SFmode)
7285     emit_insn (gen_avx512f_vextract<shuffletype>32x4_1_mask (dest,
7286         operands[1], GEN_INT (mask * 4), GEN_INT (mask * 4 + 1),
7287         GEN_INT (mask * 4 + 2), GEN_INT (mask * 4 + 3), operands[3],
7288         operands[4]));
7289   else
7290     emit_insn (gen_avx512dq_vextract<shuffletype>64x2_1_mask (dest,
7291         operands[1], GEN_INT (mask * 2), GEN_INT (mask * 2 + 1), operands[3],
7292         operands[4]));
7293   if (dest != operands[0])
7294     emit_move_insn (operands[0], dest);
7295   DONE;
7298 (define_insn "avx512dq_vextract<shuffletype>64x2_1_maskm"
7299   [(set (match_operand:<ssequartermode> 0 "memory_operand" "=m")
7300         (vec_merge:<ssequartermode>
7301           (vec_select:<ssequartermode>
7302             (match_operand:V8FI 1 "register_operand" "v")
7303             (parallel [(match_operand 2  "const_0_to_7_operand")
7304               (match_operand 3  "const_0_to_7_operand")]))
7305           (match_operand:<ssequartermode> 4 "memory_operand" "0")
7306           (match_operand:QI 5 "register_operand" "Yk")))]
7307   "TARGET_AVX512DQ
7308    && INTVAL (operands[2]) % 2 == 0
7309    && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
7310    && rtx_equal_p (operands[4], operands[0])"
7312   operands[2] = GEN_INT ((INTVAL (operands[2])) >> 1);
7313   return "vextract<shuffletype>64x2\t{%2, %1, %0%{%5%}|%0%{%5%}, %1, %2}";
7315   [(set_attr "type" "sselog")
7316    (set_attr "prefix_extra" "1")
7317    (set_attr "length_immediate" "1")
7318    (set_attr "memory" "store")
7319    (set_attr "prefix" "evex")
7320    (set_attr "mode" "<sseinsnmode>")])
7322 (define_insn "avx512f_vextract<shuffletype>32x4_1_maskm"
7323   [(set (match_operand:<ssequartermode> 0 "memory_operand" "=m")
7324         (vec_merge:<ssequartermode>
7325           (vec_select:<ssequartermode>
7326             (match_operand:V16FI 1 "register_operand" "v")
7327             (parallel [(match_operand 2  "const_0_to_15_operand")
7328               (match_operand 3  "const_0_to_15_operand")
7329               (match_operand 4  "const_0_to_15_operand")
7330               (match_operand 5  "const_0_to_15_operand")]))
7331           (match_operand:<ssequartermode> 6 "memory_operand" "0")
7332           (match_operand:QI 7 "register_operand" "Yk")))]
7333   "TARGET_AVX512F
7334    && INTVAL (operands[2]) % 4 == 0
7335    && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
7336    && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
7337    && INTVAL (operands[4]) == INTVAL (operands[5]) - 1
7338    && rtx_equal_p (operands[6], operands[0])"
7340   operands[2] = GEN_INT (INTVAL (operands[2]) >> 2);
7341   return "vextract<shuffletype>32x4\t{%2, %1, %0%{%7%}|%0%{%7%}, %1, %2}";
7343   [(set_attr "type" "sselog")
7344    (set_attr "prefix_extra" "1")
7345    (set_attr "length_immediate" "1")
7346    (set_attr "memory" "store")
7347    (set_attr "prefix" "evex")
7348    (set_attr "mode" "<sseinsnmode>")])
7350 (define_insn "<mask_codefor>avx512dq_vextract<shuffletype>64x2_1<mask_name>"
7351   [(set (match_operand:<ssequartermode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7352         (vec_select:<ssequartermode>
7353           (match_operand:V8FI 1 "register_operand" "v")
7354           (parallel [(match_operand 2  "const_0_to_7_operand")
7355             (match_operand 3  "const_0_to_7_operand")])))]
7356   "TARGET_AVX512DQ
7357    && INTVAL (operands[2]) % 2 == 0
7358    && INTVAL (operands[2]) == INTVAL (operands[3]) - 1"
7360   operands[2] = GEN_INT (INTVAL (operands[2]) >> 1);
7361   return "vextract<shuffletype>64x2\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}";
7363   [(set_attr "type" "sselog1")
7364    (set_attr "prefix_extra" "1")
7365    (set_attr "length_immediate" "1")
7366    (set_attr "prefix" "evex")
7367    (set_attr "mode" "<sseinsnmode>")])
7369 (define_split
7370   [(set (match_operand:<ssequartermode> 0 "nonimmediate_operand")
7371         (vec_select:<ssequartermode>
7372           (match_operand:V8FI 1 "register_operand")
7373           (parallel [(const_int 0) (const_int 1)])))]
7374   "TARGET_AVX512DQ
7375    && reload_completed
7376    && (TARGET_AVX512VL
7377        || REG_P (operands[0])
7378        || !EXT_REX_SSE_REG_P (operands[1]))"
7379   [(set (match_dup 0) (match_dup 1))]
7381   if (!TARGET_AVX512VL
7382       && REG_P (operands[0])
7383       && EXT_REX_SSE_REG_P (operands[1]))
7384     operands[0]
7385       = lowpart_subreg (<MODE>mode, operands[0], <ssequartermode>mode);
7386   else
7387     operands[1] = gen_lowpart (<ssequartermode>mode, operands[1]);
7390 (define_insn "<mask_codefor>avx512f_vextract<shuffletype>32x4_1<mask_name>"
7391   [(set (match_operand:<ssequartermode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7392         (vec_select:<ssequartermode>
7393           (match_operand:V16FI 1 "register_operand" "v")
7394           (parallel [(match_operand 2  "const_0_to_15_operand")
7395             (match_operand 3  "const_0_to_15_operand")
7396             (match_operand 4  "const_0_to_15_operand")
7397             (match_operand 5  "const_0_to_15_operand")])))]
7398   "TARGET_AVX512F
7399    && INTVAL (operands[2]) % 4 == 0
7400    && INTVAL (operands[2]) == INTVAL (operands[3]) - 1
7401    && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
7402    && INTVAL (operands[4]) == INTVAL (operands[5]) - 1"
7404   operands[2] = GEN_INT (INTVAL (operands[2]) >> 2);
7405   return "vextract<shuffletype>32x4\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
7407   [(set_attr "type" "sselog1")
7408    (set_attr "prefix_extra" "1")
7409    (set_attr "length_immediate" "1")
7410    (set_attr "prefix" "evex")
7411    (set_attr "mode" "<sseinsnmode>")])
7413 (define_split
7414   [(set (match_operand:<ssequartermode> 0 "nonimmediate_operand")
7415         (vec_select:<ssequartermode>
7416           (match_operand:V16FI 1 "register_operand")
7417           (parallel [(const_int 0) (const_int 1)
7418                      (const_int 2) (const_int 3)])))]
7419   "TARGET_AVX512F
7420    && reload_completed
7421    && (TARGET_AVX512VL
7422        || REG_P (operands[0])
7423        || !EXT_REX_SSE_REG_P (operands[1]))"
7424   [(set (match_dup 0) (match_dup 1))]
7426   if (!TARGET_AVX512VL
7427       && REG_P (operands[0])
7428       && EXT_REX_SSE_REG_P (operands[1]))
7429     operands[0]
7430       = lowpart_subreg (<MODE>mode, operands[0], <ssequartermode>mode);
7431   else
7432     operands[1] = gen_lowpart (<ssequartermode>mode, operands[1]);
7435 (define_mode_attr extract_type_2
7436   [(V16SF "avx512dq") (V16SI "avx512dq") (V8DF "avx512f") (V8DI "avx512f")])
7438 (define_mode_attr extract_suf_2
7439   [(V16SF "32x8") (V16SI "32x8") (V8DF "64x4") (V8DI "64x4")])
7441 (define_mode_iterator AVX512_VEC_2
7442   [(V16SF "TARGET_AVX512DQ") (V16SI "TARGET_AVX512DQ") V8DF V8DI])
7444 (define_expand "<extract_type_2>_vextract<shuffletype><extract_suf_2>_mask"
7445   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7446    (match_operand:AVX512_VEC_2 1 "register_operand")
7447    (match_operand:SI 2 "const_0_to_1_operand")
7448    (match_operand:<ssehalfvecmode> 3 "nonimmediate_operand")
7449    (match_operand:QI 4 "register_operand")]
7450   "TARGET_AVX512F"
7452   rtx (*insn)(rtx, rtx, rtx, rtx);
7453   rtx dest = operands[0];
7455   if (MEM_P (dest) && !rtx_equal_p (dest, operands[3]))
7456     dest = gen_reg_rtx (<ssehalfvecmode>mode);
7458   switch (INTVAL (operands[2]))
7459     {
7460     case 0:
7461       insn = gen_vec_extract_lo_<mode>_mask;
7462       break;
7463     case 1:
7464       insn = gen_vec_extract_hi_<mode>_mask;
7465       break;
7466     default:
7467       gcc_unreachable ();
7468     }
7470   emit_insn (insn (dest, operands[1], operands[3], operands[4]));
7471   if (dest != operands[0])
7472     emit_move_insn (operands[0], dest);
7473   DONE;
7476 (define_split
7477   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7478         (vec_select:<ssehalfvecmode>
7479           (match_operand:V8FI 1 "nonimmediate_operand")
7480           (parallel [(const_int 0) (const_int 1)
7481             (const_int 2) (const_int 3)])))]
7482   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7483    && reload_completed
7484    && (TARGET_AVX512VL
7485        || (REG_P (operands[0]) && !EXT_REX_SSE_REG_P (operands[1])))"
7486   [(set (match_dup 0) (match_dup 1))]
7487   "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
7489 (define_insn "vec_extract_lo_<mode>_maskm"
7490   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7491         (vec_merge:<ssehalfvecmode>
7492           (vec_select:<ssehalfvecmode>
7493             (match_operand:V8FI 1 "register_operand" "v")
7494             (parallel [(const_int 0) (const_int 1)
7495               (const_int 2) (const_int 3)]))
7496           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7497           (match_operand:QI 3 "register_operand" "Yk")))]
7498   "TARGET_AVX512F
7499    && rtx_equal_p (operands[2], operands[0])"
7500   "vextract<shuffletype>64x4\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}"
7501   [(set_attr "type" "sselog1")
7502    (set_attr "prefix_extra" "1")
7503    (set_attr "length_immediate" "1")
7504    (set_attr "prefix" "evex")
7505    (set_attr "mode" "<sseinsnmode>")])
7507 (define_insn "vec_extract_lo_<mode><mask_name>"
7508   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,<store_mask_constraint>,v")
7509         (vec_select:<ssehalfvecmode>
7510           (match_operand:V8FI 1 "<store_mask_predicate>" "v,v,<store_mask_constraint>")
7511           (parallel [(const_int 0) (const_int 1)
7512             (const_int 2) (const_int 3)])))]
7513   "TARGET_AVX512F
7514    && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))"
7516   if (<mask_applied> || (!TARGET_AVX512VL && !MEM_P (operands[1])))
7517     return "vextract<shuffletype>64x4\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7518   else
7519     return "#";
7521   [(set_attr "type" "sselog1")
7522    (set_attr "prefix_extra" "1")
7523    (set_attr "length_immediate" "1")
7524    (set_attr "memory" "none,store,load")
7525    (set_attr "prefix" "evex")
7526    (set_attr "mode" "<sseinsnmode>")])
7528 (define_insn "vec_extract_hi_<mode>_maskm"
7529   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7530         (vec_merge:<ssehalfvecmode>
7531           (vec_select:<ssehalfvecmode>
7532             (match_operand:V8FI 1 "register_operand" "v")
7533             (parallel [(const_int 4) (const_int 5)
7534               (const_int 6) (const_int 7)]))
7535           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7536           (match_operand:QI 3 "register_operand" "Yk")))]
7537   "TARGET_AVX512F
7538    && rtx_equal_p (operands[2], operands[0])"
7539   "vextract<shuffletype>64x4\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7540   [(set_attr "type" "sselog")
7541    (set_attr "prefix_extra" "1")
7542    (set_attr "length_immediate" "1")
7543    (set_attr "memory" "store")
7544    (set_attr "prefix" "evex")
7545    (set_attr "mode" "<sseinsnmode>")])
7547 (define_insn "vec_extract_hi_<mode><mask_name>"
7548   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7549         (vec_select:<ssehalfvecmode>
7550           (match_operand:V8FI 1 "register_operand" "v")
7551           (parallel [(const_int 4) (const_int 5)
7552             (const_int 6) (const_int 7)])))]
7553   "TARGET_AVX512F"
7554   "vextract<shuffletype>64x4\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}"
7555   [(set_attr "type" "sselog1")
7556    (set_attr "prefix_extra" "1")
7557    (set_attr "length_immediate" "1")
7558    (set_attr "prefix" "evex")
7559    (set_attr "mode" "<sseinsnmode>")])
7561 (define_insn "vec_extract_hi_<mode>_maskm"
7562    [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7563         (vec_merge:<ssehalfvecmode>
7564           (vec_select:<ssehalfvecmode>
7565             (match_operand:V16FI 1 "register_operand" "v")
7566             (parallel [(const_int 8) (const_int 9)
7567               (const_int 10) (const_int 11)
7568               (const_int 12) (const_int 13)
7569               (const_int 14) (const_int 15)]))
7570           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7571           (match_operand:QI 3 "register_operand" "Yk")))]
7572   "TARGET_AVX512DQ
7573    && rtx_equal_p (operands[2], operands[0])"
7574   "vextract<shuffletype>32x8\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7575   [(set_attr "type" "sselog1")
7576    (set_attr "prefix_extra" "1")
7577    (set_attr "length_immediate" "1")
7578    (set_attr "prefix" "evex")
7579    (set_attr "mode" "<sseinsnmode>")])
7581 (define_insn "vec_extract_hi_<mode><mask_name>"
7582   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>,vm")
7583         (vec_select:<ssehalfvecmode>
7584           (match_operand:V16FI 1 "register_operand" "v,v")
7585           (parallel [(const_int 8) (const_int 9)
7586             (const_int 10) (const_int 11)
7587             (const_int 12) (const_int 13)
7588             (const_int 14) (const_int 15)])))]
7589   "TARGET_AVX512F && <mask_avx512dq_condition>"
7590   "@
7591    vextract<shuffletype>32x8\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}
7592    vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7593   [(set_attr "type" "sselog1")
7594    (set_attr "prefix_extra" "1")
7595    (set_attr "isa" "avx512dq,noavx512dq")
7596    (set_attr "length_immediate" "1")
7597    (set_attr "prefix" "evex")
7598    (set_attr "mode" "<sseinsnmode>")])
7600 (define_expand "avx512vl_vextractf128<mode>"
7601   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7602    (match_operand:VI48F_256 1 "register_operand")
7603    (match_operand:SI 2 "const_0_to_1_operand")
7604    (match_operand:<ssehalfvecmode> 3 "vector_move_operand")
7605    (match_operand:QI 4 "register_operand")]
7606   "TARGET_AVX512DQ && TARGET_AVX512VL"
7608   rtx (*insn)(rtx, rtx, rtx, rtx);
7609   rtx dest = operands[0];
7611   if (MEM_P (dest)
7612       && (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 4
7613           /* For V8S[IF]mode there are maskm insns with =m and 0
7614              constraints.  */
7615           ? !rtx_equal_p (dest, operands[3])
7616           /* For V4D[IF]mode, hi insns don't allow memory, and
7617              lo insns have =m and 0C constraints.  */
7618           : (operands[2] != const0_rtx
7619              || (!rtx_equal_p (dest, operands[3])
7620                  && GET_CODE (operands[3]) != CONST_VECTOR))))
7621     dest = gen_reg_rtx (<ssehalfvecmode>mode);
7622   switch (INTVAL (operands[2]))
7623     {
7624     case 0:
7625       insn = gen_vec_extract_lo_<mode>_mask;
7626       break;
7627     case 1:
7628       insn = gen_vec_extract_hi_<mode>_mask;
7629       break;
7630     default:
7631       gcc_unreachable ();
7632     }
7634   emit_insn (insn (dest, operands[1], operands[3], operands[4]));
7635   if (dest != operands[0])
7636     emit_move_insn (operands[0], dest);
7637   DONE;
7640 (define_expand "avx_vextractf128<mode>"
7641   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7642    (match_operand:V_256 1 "register_operand")
7643    (match_operand:SI 2 "const_0_to_1_operand")]
7644   "TARGET_AVX"
7646   rtx (*insn)(rtx, rtx);
7648   switch (INTVAL (operands[2]))
7649     {
7650     case 0:
7651       insn = gen_vec_extract_lo_<mode>;
7652       break;
7653     case 1:
7654       insn = gen_vec_extract_hi_<mode>;
7655       break;
7656     default:
7657       gcc_unreachable ();
7658     }
7660   emit_insn (insn (operands[0], operands[1]));
7661   DONE;
7664 (define_insn "vec_extract_lo_<mode><mask_name>"
7665   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,v,m")
7666         (vec_select:<ssehalfvecmode>
7667           (match_operand:V16FI 1 "<store_mask_predicate>"
7668                                  "v,<store_mask_constraint>,v")
7669           (parallel [(const_int 0) (const_int 1)
7670                      (const_int 2) (const_int 3)
7671                      (const_int 4) (const_int 5)
7672                      (const_int 6) (const_int 7)])))]
7673   "TARGET_AVX512F
7674    && <mask_mode512bit_condition>
7675    && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))"
7677   if (<mask_applied>
7678       || (!TARGET_AVX512VL
7679           && !REG_P (operands[0])
7680           && EXT_REX_SSE_REG_P (operands[1])))
7681     return "vextract<shuffletype>32x8\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7682   else
7683     return "#";
7685   [(set_attr "type" "sselog1")
7686    (set_attr "prefix_extra" "1")
7687    (set_attr "length_immediate" "1")
7688    (set_attr "memory" "none,load,store")
7689    (set_attr "prefix" "evex")
7690    (set_attr "mode" "<sseinsnmode>")])
7692 (define_split
7693   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7694         (vec_select:<ssehalfvecmode>
7695           (match_operand:V16FI 1 "nonimmediate_operand")
7696           (parallel [(const_int 0) (const_int 1)
7697             (const_int 2) (const_int 3)
7698             (const_int 4) (const_int 5)
7699             (const_int 6) (const_int 7)])))]
7700   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7701    && reload_completed
7702    && (TARGET_AVX512VL
7703        || REG_P (operands[0])
7704        || !EXT_REX_SSE_REG_P (operands[1]))"
7705   [(set (match_dup 0) (match_dup 1))]
7707   if (!TARGET_AVX512VL
7708       && REG_P (operands[0])
7709       && EXT_REX_SSE_REG_P (operands[1]))
7710     operands[0]
7711       = lowpart_subreg (<MODE>mode, operands[0], <ssehalfvecmode>mode);
7712   else
7713     operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);
7716 (define_insn "vec_extract_lo_<mode><mask_name>"
7717   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,v,m")
7718         (vec_select:<ssehalfvecmode>
7719           (match_operand:VI8F_256 1 "<store_mask_predicate>"
7720                                     "v,<store_mask_constraint>,v")
7721           (parallel [(const_int 0) (const_int 1)])))]
7722   "TARGET_AVX
7723    && <mask_avx512vl_condition> && <mask_avx512dq_condition>
7724    && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))"
7726   if (<mask_applied>)
7727     return "vextract<shuffletype>64x2\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}";
7728   else
7729     return "#";
7731    [(set_attr "type" "sselog1")
7732     (set_attr "prefix_extra" "1")
7733     (set_attr "length_immediate" "1")
7734     (set_attr "memory" "none,load,store")
7735     (set_attr "prefix" "evex")
7736     (set_attr "mode" "XI")])
7738 (define_split
7739   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7740         (vec_select:<ssehalfvecmode>
7741           (match_operand:VI8F_256 1 "nonimmediate_operand")
7742           (parallel [(const_int 0) (const_int 1)])))]
7743   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7744    && reload_completed"
7745   [(set (match_dup 0) (match_dup 1))]
7746   "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
7748 (define_insn "vec_extract_hi_<mode><mask_name>"
7749   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,<store_mask_constraint>")
7750         (vec_select:<ssehalfvecmode>
7751           (match_operand:VI8F_256 1 "register_operand" "v,v")
7752           (parallel [(const_int 2) (const_int 3)])))]
7753   "TARGET_AVX && <mask_avx512vl_condition> && <mask_avx512dq_condition>"
7755   if (TARGET_AVX512VL)
7756   {
7757     if (TARGET_AVX512DQ)
7758       return "vextract<shuffletype>64x2\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}";
7759     else
7760       return "vextract<shuffletype>32x4\t{$0x1, %1, %0|%0, %1, 0x1}";
7761   }
7762   else
7763     return "vextract<i128>\t{$0x1, %1, %0|%0, %1, 0x1}";
7765   [(set_attr "type" "sselog1")
7766    (set_attr "prefix_extra" "1")
7767    (set_attr "length_immediate" "1")
7768    (set_attr "prefix" "vex")
7769    (set_attr "mode" "<sseinsnmode>")])
7771 (define_split
7772   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7773         (vec_select:<ssehalfvecmode>
7774           (match_operand:VI4F_256 1 "nonimmediate_operand")
7775           (parallel [(const_int 0) (const_int 1)
7776                      (const_int 2) (const_int 3)])))]
7777   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7778    && reload_completed"
7779   [(set (match_dup 0) (match_dup 1))]
7780   "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
7782 (define_insn "vec_extract_lo_<mode><mask_name>"
7783   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>"
7784                                           "=<store_mask_constraint>,v")
7785         (vec_select:<ssehalfvecmode>
7786           (match_operand:VI4F_256 1 "<store_mask_predicate>"
7787                                     "v,<store_mask_constraint>")
7788           (parallel [(const_int 0) (const_int 1)
7789                      (const_int 2) (const_int 3)])))]
7790   "TARGET_AVX
7791    && <mask_avx512vl_condition> && <mask_avx512dq_condition>
7792    && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))"
7794   if (<mask_applied>)
7795     return "vextract<shuffletype>32x4\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7796   else
7797     return "#";
7799   [(set_attr "type" "sselog1")
7800    (set_attr "prefix_extra" "1")
7801    (set_attr "length_immediate" "1")
7802    (set_attr "prefix" "evex")
7803    (set_attr "mode" "<sseinsnmode>")])
7805 (define_insn "vec_extract_lo_<mode>_maskm"
7806   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7807         (vec_merge:<ssehalfvecmode>
7808           (vec_select:<ssehalfvecmode>
7809             (match_operand:VI4F_256 1 "register_operand" "v")
7810             (parallel [(const_int 0) (const_int 1)
7811                       (const_int 2) (const_int 3)]))
7812           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7813           (match_operand:QI 3 "register_operand" "Yk")))]
7814   "TARGET_AVX512VL && TARGET_AVX512F
7815    && rtx_equal_p (operands[2], operands[0])"
7816   "vextract<shuffletype>32x4\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}"
7817   [(set_attr "type" "sselog1")
7818    (set_attr "prefix_extra" "1")
7819    (set_attr "length_immediate" "1")
7820    (set_attr "prefix" "evex")
7821    (set_attr "mode" "<sseinsnmode>")])
7823 (define_insn "vec_extract_hi_<mode>_maskm"
7824   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7825         (vec_merge:<ssehalfvecmode>
7826           (vec_select:<ssehalfvecmode>
7827             (match_operand:VI4F_256 1 "register_operand" "v")
7828             (parallel [(const_int 4) (const_int 5)
7829                       (const_int 6) (const_int 7)]))
7830           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7831           (match_operand:<ssehalfvecmode> 3 "register_operand" "Yk")))]
7832   "TARGET_AVX512F && TARGET_AVX512VL
7833    && rtx_equal_p (operands[2], operands[0])"
7834   "vextract<shuffletype>32x4\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7835   [(set_attr "type" "sselog1")
7836    (set_attr "length_immediate" "1")
7837    (set_attr "prefix" "evex")
7838    (set_attr "mode" "<sseinsnmode>")])
7840 (define_insn "vec_extract_hi_<mode>_mask"
7841   [(set (match_operand:<ssehalfvecmode> 0 "register_operand" "=v")
7842         (vec_merge:<ssehalfvecmode>
7843           (vec_select:<ssehalfvecmode>
7844             (match_operand:VI4F_256 1 "register_operand" "v")
7845             (parallel [(const_int 4) (const_int 5)
7846                        (const_int 6) (const_int 7)]))
7847           (match_operand:<ssehalfvecmode> 2 "vector_move_operand" "0C")
7848           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
7849   "TARGET_AVX512VL"
7850   "vextract<shuffletype>32x4\t{$0x1, %1, %0%{%3%}%N2|%0%{%3%}%N2, %1, 0x1}"
7851   [(set_attr "type" "sselog1")
7852    (set_attr "length_immediate" "1")
7853    (set_attr "prefix" "evex")
7854    (set_attr "mode" "<sseinsnmode>")])
7856 (define_insn "vec_extract_hi_<mode>"
7857   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=xm, vm")
7858         (vec_select:<ssehalfvecmode>
7859           (match_operand:VI4F_256 1 "register_operand" "x, v")
7860           (parallel [(const_int 4) (const_int 5)
7861                      (const_int 6) (const_int 7)])))]
7862   "TARGET_AVX"
7863   "@
7864     vextract<i128>\t{$0x1, %1, %0|%0, %1, 0x1}
7865     vextract<shuffletype>32x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7866   [(set_attr "isa" "*, avx512vl")
7867    (set_attr "prefix" "vex, evex")
7868    (set_attr "type" "sselog1")
7869    (set_attr "length_immediate" "1")
7870    (set_attr "mode" "<sseinsnmode>")])
7872 (define_insn_and_split "vec_extract_lo_v32hi"
7873   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=v,v,m")
7874         (vec_select:V16HI
7875           (match_operand:V32HI 1 "nonimmediate_operand" "v,m,v")
7876           (parallel [(const_int 0) (const_int 1)
7877                      (const_int 2) (const_int 3)
7878                      (const_int 4) (const_int 5)
7879                      (const_int 6) (const_int 7)
7880                      (const_int 8) (const_int 9)
7881                      (const_int 10) (const_int 11)
7882                      (const_int 12) (const_int 13)
7883                      (const_int 14) (const_int 15)])))]
7884   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7886   if (TARGET_AVX512VL
7887       || REG_P (operands[0])
7888       || !EXT_REX_SSE_REG_P (operands[1]))
7889     return "#";
7890   else
7891     return "vextracti64x4\t{$0x0, %1, %0|%0, %1, 0x0}";
7893   "&& reload_completed
7894    && (TARGET_AVX512VL
7895        || REG_P (operands[0])
7896        || !EXT_REX_SSE_REG_P (operands[1]))"
7897   [(set (match_dup 0) (match_dup 1))]
7899   if (!TARGET_AVX512VL
7900       && REG_P (operands[0])
7901       && EXT_REX_SSE_REG_P (operands[1]))
7902     operands[0] = lowpart_subreg (V32HImode, operands[0], V16HImode);
7903   else
7904     operands[1] = gen_lowpart (V16HImode, operands[1]);
7906   [(set_attr "type" "sselog1")
7907    (set_attr "prefix_extra" "1")
7908    (set_attr "length_immediate" "1")
7909    (set_attr "memory" "none,load,store")
7910    (set_attr "prefix" "evex")
7911    (set_attr "mode" "XI")])
7913 (define_insn "vec_extract_hi_v32hi"
7914   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=vm")
7915         (vec_select:V16HI
7916           (match_operand:V32HI 1 "register_operand" "v")
7917           (parallel [(const_int 16) (const_int 17)
7918                      (const_int 18) (const_int 19)
7919                      (const_int 20) (const_int 21)
7920                      (const_int 22) (const_int 23)
7921                      (const_int 24) (const_int 25)
7922                      (const_int 26) (const_int 27)
7923                      (const_int 28) (const_int 29)
7924                      (const_int 30) (const_int 31)])))]
7925   "TARGET_AVX512F"
7926   "vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7927   [(set_attr "type" "sselog1")
7928    (set_attr "prefix_extra" "1")
7929    (set_attr "length_immediate" "1")
7930    (set_attr "prefix" "evex")
7931    (set_attr "mode" "XI")])
7933 (define_insn_and_split "vec_extract_lo_v16hi"
7934   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=v,m")
7935         (vec_select:V8HI
7936           (match_operand:V16HI 1 "nonimmediate_operand" "vm,v")
7937           (parallel [(const_int 0) (const_int 1)
7938                      (const_int 2) (const_int 3)
7939                      (const_int 4) (const_int 5)
7940                      (const_int 6) (const_int 7)])))]
7941   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7942   "#"
7943   "&& reload_completed"
7944   [(set (match_dup 0) (match_dup 1))]
7945   "operands[1] = gen_lowpart (V8HImode, operands[1]);")
7947 (define_insn "vec_extract_hi_v16hi"
7948   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=xm,vm,vm")
7949         (vec_select:V8HI
7950           (match_operand:V16HI 1 "register_operand" "x,v,v")
7951           (parallel [(const_int 8) (const_int 9)
7952                      (const_int 10) (const_int 11)
7953                      (const_int 12) (const_int 13)
7954                      (const_int 14) (const_int 15)])))]
7955   "TARGET_AVX"
7956   "@
7957    vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}
7958    vextracti32x4\t{$0x1, %1, %0|%0, %1, 0x1}
7959    vextracti32x4\t{$0x1, %g1, %0|%0, %g1, 0x1}"
7960   [(set_attr "type" "sselog1")
7961    (set_attr "prefix_extra" "1")
7962    (set_attr "length_immediate" "1")
7963    (set_attr "isa" "*,avx512dq,avx512f")
7964    (set_attr "prefix" "vex,evex,evex")
7965    (set_attr "mode" "OI")])
7967 (define_insn_and_split "vec_extract_lo_v64qi"
7968   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,v,m")
7969         (vec_select:V32QI
7970           (match_operand:V64QI 1 "nonimmediate_operand" "v,m,v")
7971           (parallel [(const_int 0) (const_int 1)
7972                      (const_int 2) (const_int 3)
7973                      (const_int 4) (const_int 5)
7974                      (const_int 6) (const_int 7)
7975                      (const_int 8) (const_int 9)
7976                      (const_int 10) (const_int 11)
7977                      (const_int 12) (const_int 13)
7978                      (const_int 14) (const_int 15)
7979                      (const_int 16) (const_int 17)
7980                      (const_int 18) (const_int 19)
7981                      (const_int 20) (const_int 21)
7982                      (const_int 22) (const_int 23)
7983                      (const_int 24) (const_int 25)
7984                      (const_int 26) (const_int 27)
7985                      (const_int 28) (const_int 29)
7986                      (const_int 30) (const_int 31)])))]
7987   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7989   if (TARGET_AVX512VL
7990       || REG_P (operands[0])
7991       || !EXT_REX_SSE_REG_P (operands[1]))
7992     return "#";
7993   else
7994     return "vextracti64x4\t{$0x0, %1, %0|%0, %1, 0x0}";
7996   "&& reload_completed
7997    && (TARGET_AVX512VL
7998        || REG_P (operands[0])
7999        || !EXT_REX_SSE_REG_P (operands[1]))"
8000   [(set (match_dup 0) (match_dup 1))]
8002   if (!TARGET_AVX512VL
8003       && REG_P (operands[0])
8004       && EXT_REX_SSE_REG_P (operands[1]))
8005     operands[0] = lowpart_subreg (V64QImode, operands[0], V32QImode);
8006   else
8007     operands[1] = gen_lowpart (V32QImode, operands[1]);
8009   [(set_attr "type" "sselog1")
8010    (set_attr "prefix_extra" "1")
8011    (set_attr "length_immediate" "1")
8012    (set_attr "memory" "none,load,store")
8013    (set_attr "prefix" "evex")
8014    (set_attr "mode" "XI")])
8016 (define_insn "vec_extract_hi_v64qi"
8017   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=vm")
8018         (vec_select:V32QI
8019           (match_operand:V64QI 1 "register_operand" "v")
8020           (parallel [(const_int 32) (const_int 33)
8021                      (const_int 34) (const_int 35)
8022                      (const_int 36) (const_int 37)
8023                      (const_int 38) (const_int 39)
8024                      (const_int 40) (const_int 41)
8025                      (const_int 42) (const_int 43)
8026                      (const_int 44) (const_int 45)
8027                      (const_int 46) (const_int 47)
8028                      (const_int 48) (const_int 49)
8029                      (const_int 50) (const_int 51)
8030                      (const_int 52) (const_int 53)
8031                      (const_int 54) (const_int 55)
8032                      (const_int 56) (const_int 57)
8033                      (const_int 58) (const_int 59)
8034                      (const_int 60) (const_int 61)
8035                      (const_int 62) (const_int 63)])))]
8036   "TARGET_AVX512F"
8037   "vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
8038   [(set_attr "type" "sselog1")
8039    (set_attr "prefix_extra" "1")
8040    (set_attr "length_immediate" "1")
8041    (set_attr "prefix" "evex")
8042    (set_attr "mode" "XI")])
8044 (define_insn_and_split "vec_extract_lo_v32qi"
8045   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=v,m")
8046         (vec_select:V16QI
8047           (match_operand:V32QI 1 "nonimmediate_operand" "vm,v")
8048           (parallel [(const_int 0) (const_int 1)
8049                      (const_int 2) (const_int 3)
8050                      (const_int 4) (const_int 5)
8051                      (const_int 6) (const_int 7)
8052                      (const_int 8) (const_int 9)
8053                      (const_int 10) (const_int 11)
8054                      (const_int 12) (const_int 13)
8055                      (const_int 14) (const_int 15)])))]
8056   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8057   "#"
8058   "&& reload_completed"
8059   [(set (match_dup 0) (match_dup 1))]
8060   "operands[1] = gen_lowpart (V16QImode, operands[1]);")
8062 (define_insn "vec_extract_hi_v32qi"
8063   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=xm,vm,vm")
8064         (vec_select:V16QI
8065           (match_operand:V32QI 1 "register_operand" "x,v,v")
8066           (parallel [(const_int 16) (const_int 17)
8067                      (const_int 18) (const_int 19)
8068                      (const_int 20) (const_int 21)
8069                      (const_int 22) (const_int 23)
8070                      (const_int 24) (const_int 25)
8071                      (const_int 26) (const_int 27)
8072                      (const_int 28) (const_int 29)
8073                      (const_int 30) (const_int 31)])))]
8074   "TARGET_AVX"
8075   "@
8076    vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}
8077    vextracti32x4\t{$0x1, %1, %0|%0, %1, 0x1}
8078    vextracti32x4\t{$0x1, %g1, %0|%0, %g1, 0x1}"
8079   [(set_attr "type" "sselog1")
8080    (set_attr "prefix_extra" "1")
8081    (set_attr "length_immediate" "1")
8082    (set_attr "isa" "*,avx512dq,avx512f")
8083    (set_attr "prefix" "vex,evex,evex")
8084    (set_attr "mode" "OI")])
8086 ;; Modes handled by vec_extract patterns.
8087 (define_mode_iterator VEC_EXTRACT_MODE
8088   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX") V16QI
8089    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX") V8HI
8090    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
8091    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI
8092    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
8093    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") V2DF
8094    (V4TI "TARGET_AVX512F") (V2TI "TARGET_AVX")])
8096 (define_expand "vec_extract<mode><ssescalarmodelower>"
8097   [(match_operand:<ssescalarmode> 0 "register_operand")
8098    (match_operand:VEC_EXTRACT_MODE 1 "register_operand")
8099    (match_operand 2 "const_int_operand")]
8100   "TARGET_SSE"
8102   ix86_expand_vector_extract (false, operands[0], operands[1],
8103                               INTVAL (operands[2]));
8104   DONE;
8107 (define_expand "vec_extract<mode><ssehalfvecmodelower>"
8108   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
8109    (match_operand:V_512 1 "register_operand")
8110    (match_operand 2 "const_0_to_1_operand")]
8111   "TARGET_AVX512F"
8113   if (INTVAL (operands[2]))
8114     emit_insn (gen_vec_extract_hi_<mode> (operands[0], operands[1]));
8115   else
8116     emit_insn (gen_vec_extract_lo_<mode> (operands[0], operands[1]));
8117   DONE;
8120 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8122 ;; Parallel double-precision floating point element swizzling
8124 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8126 (define_insn "<mask_codefor>avx512f_unpckhpd512<mask_name>"
8127   [(set (match_operand:V8DF 0 "register_operand" "=v")
8128         (vec_select:V8DF
8129           (vec_concat:V16DF
8130             (match_operand:V8DF 1 "register_operand" "v")
8131             (match_operand:V8DF 2 "nonimmediate_operand" "vm"))
8132           (parallel [(const_int 1) (const_int 9)
8133                      (const_int 3) (const_int 11)
8134                      (const_int 5) (const_int 13)
8135                      (const_int 7) (const_int 15)])))]
8136   "TARGET_AVX512F"
8137   "vunpckhpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8138   [(set_attr "type" "sselog")
8139    (set_attr "prefix" "evex")
8140    (set_attr "mode" "V8DF")])
8142 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
8143 (define_insn "avx_unpckhpd256<mask_name>"
8144   [(set (match_operand:V4DF 0 "register_operand" "=v")
8145         (vec_select:V4DF
8146           (vec_concat:V8DF
8147             (match_operand:V4DF 1 "register_operand" "v")
8148             (match_operand:V4DF 2 "nonimmediate_operand" "vm"))
8149           (parallel [(const_int 1) (const_int 5)
8150                      (const_int 3) (const_int 7)])))]
8151   "TARGET_AVX && <mask_avx512vl_condition>"
8152   "vunpckhpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8153   [(set_attr "type" "sselog")
8154    (set_attr "prefix" "vex")
8155    (set_attr "mode" "V4DF")])
8157 (define_expand "vec_interleave_highv4df"
8158   [(set (match_dup 3)
8159         (vec_select:V4DF
8160           (vec_concat:V8DF
8161             (match_operand:V4DF 1 "register_operand")
8162             (match_operand:V4DF 2 "nonimmediate_operand"))
8163           (parallel [(const_int 0) (const_int 4)
8164                      (const_int 2) (const_int 6)])))
8165    (set (match_dup 4)
8166         (vec_select:V4DF
8167           (vec_concat:V8DF
8168             (match_dup 1)
8169             (match_dup 2))
8170           (parallel [(const_int 1) (const_int 5)
8171                      (const_int 3) (const_int 7)])))
8172    (set (match_operand:V4DF 0 "register_operand")
8173         (vec_select:V4DF
8174           (vec_concat:V8DF
8175             (match_dup 3)
8176             (match_dup 4))
8177           (parallel [(const_int 2) (const_int 3)
8178                      (const_int 6) (const_int 7)])))]
8179  "TARGET_AVX"
8181   operands[3] = gen_reg_rtx (V4DFmode);
8182   operands[4] = gen_reg_rtx (V4DFmode);
8186 (define_insn "avx512vl_unpckhpd128_mask"
8187   [(set (match_operand:V2DF 0 "register_operand" "=v")
8188         (vec_merge:V2DF
8189           (vec_select:V2DF
8190             (vec_concat:V4DF
8191               (match_operand:V2DF 1 "register_operand" "v")
8192               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
8193             (parallel [(const_int 1) (const_int 3)]))
8194           (match_operand:V2DF 3 "vector_move_operand" "0C")
8195           (match_operand:QI 4 "register_operand" "Yk")))]
8196   "TARGET_AVX512VL"
8197   "vunpckhpd\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
8198   [(set_attr "type" "sselog")
8199    (set_attr "prefix" "evex")
8200    (set_attr "mode" "V2DF")])
8202 (define_expand "vec_interleave_highv2df"
8203   [(set (match_operand:V2DF 0 "register_operand")
8204         (vec_select:V2DF
8205           (vec_concat:V4DF
8206             (match_operand:V2DF 1 "nonimmediate_operand")
8207             (match_operand:V2DF 2 "nonimmediate_operand"))
8208           (parallel [(const_int 1)
8209                      (const_int 3)])))]
8210   "TARGET_SSE2"
8212   if (!ix86_vec_interleave_v2df_operator_ok (operands, 1))
8213     operands[2] = force_reg (V2DFmode, operands[2]);
8216 (define_insn "*vec_interleave_highv2df"
8217   [(set (match_operand:V2DF 0 "nonimmediate_operand"     "=x,v,v,x,v,m")
8218         (vec_select:V2DF
8219           (vec_concat:V4DF
8220             (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,o,o,o,v")
8221             (match_operand:V2DF 2 "nonimmediate_operand" " x,v,1,0,v,0"))
8222           (parallel [(const_int 1)
8223                      (const_int 3)])))]
8224   "TARGET_SSE2 && ix86_vec_interleave_v2df_operator_ok (operands, 1)"
8225   "@
8226    unpckhpd\t{%2, %0|%0, %2}
8227    vunpckhpd\t{%2, %1, %0|%0, %1, %2}
8228    %vmovddup\t{%H1, %0|%0, %H1}
8229    movlpd\t{%H1, %0|%0, %H1}
8230    vmovlpd\t{%H1, %2, %0|%0, %2, %H1}
8231    %vmovhpd\t{%1, %0|%q0, %1}"
8232   [(set_attr "isa" "noavx,avx,sse3,noavx,avx,*")
8233    (set_attr "type" "sselog,sselog,sselog,ssemov,ssemov,ssemov")
8234    (set (attr "prefix_data16")
8235      (if_then_else (eq_attr "alternative" "3,5")
8236                    (const_string "1")
8237                    (const_string "*")))
8238    (set_attr "prefix" "orig,maybe_evex,maybe_vex,orig,maybe_evex,maybe_vex")
8239    (set_attr "mode" "V2DF,V2DF,DF,V1DF,V1DF,V1DF")])
8241 (define_expand "avx512f_movddup512<mask_name>"
8242   [(set (match_operand:V8DF 0 "register_operand")
8243         (vec_select:V8DF
8244           (vec_concat:V16DF
8245             (match_operand:V8DF 1 "nonimmediate_operand")
8246             (match_dup 1))
8247           (parallel [(const_int 0) (const_int 8)
8248                      (const_int 2) (const_int 10)
8249                      (const_int 4) (const_int 12)
8250                      (const_int 6) (const_int 14)])))]
8251   "TARGET_AVX512F")
8253 (define_expand "avx512f_unpcklpd512<mask_name>"
8254   [(set (match_operand:V8DF 0 "register_operand")
8255         (vec_select:V8DF
8256           (vec_concat:V16DF
8257             (match_operand:V8DF 1 "register_operand")
8258             (match_operand:V8DF 2 "nonimmediate_operand"))
8259           (parallel [(const_int 0) (const_int 8)
8260                      (const_int 2) (const_int 10)
8261                      (const_int 4) (const_int 12)
8262                      (const_int 6) (const_int 14)])))]
8263   "TARGET_AVX512F")
8265 (define_insn "*avx512f_unpcklpd512<mask_name>"
8266   [(set (match_operand:V8DF 0 "register_operand" "=v,v")
8267         (vec_select:V8DF
8268           (vec_concat:V16DF
8269             (match_operand:V8DF 1 "nonimmediate_operand" "vm, v")
8270             (match_operand:V8DF 2 "nonimmediate_operand" "1 ,vm"))
8271           (parallel [(const_int 0) (const_int 8)
8272                      (const_int 2) (const_int 10)
8273                      (const_int 4) (const_int 12)
8274                      (const_int 6) (const_int 14)])))]
8275   "TARGET_AVX512F"
8276   "@
8277    vmovddup\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}
8278    vunpcklpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8279   [(set_attr "type" "sselog")
8280    (set_attr "prefix" "evex")
8281    (set_attr "mode" "V8DF")])
8283 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
8284 (define_expand "avx_movddup256<mask_name>"
8285   [(set (match_operand:V4DF 0 "register_operand")
8286         (vec_select:V4DF
8287           (vec_concat:V8DF
8288             (match_operand:V4DF 1 "nonimmediate_operand")
8289             (match_dup 1))
8290           (parallel [(const_int 0) (const_int 4)
8291                      (const_int 2) (const_int 6)])))]
8292   "TARGET_AVX && <mask_avx512vl_condition>")
8294 (define_expand "avx_unpcklpd256<mask_name>"
8295   [(set (match_operand:V4DF 0 "register_operand")
8296         (vec_select:V4DF
8297           (vec_concat:V8DF
8298             (match_operand:V4DF 1 "register_operand")
8299             (match_operand:V4DF 2 "nonimmediate_operand"))
8300           (parallel [(const_int 0) (const_int 4)
8301                      (const_int 2) (const_int 6)])))]
8302   "TARGET_AVX && <mask_avx512vl_condition>")
8304 (define_insn "*avx_unpcklpd256<mask_name>"
8305   [(set (match_operand:V4DF 0 "register_operand"         "=v,v")
8306         (vec_select:V4DF
8307           (vec_concat:V8DF
8308             (match_operand:V4DF 1 "nonimmediate_operand" " v,m")
8309             (match_operand:V4DF 2 "nonimmediate_operand" "vm,1"))
8310           (parallel [(const_int 0) (const_int 4)
8311                      (const_int 2) (const_int 6)])))]
8312   "TARGET_AVX && <mask_avx512vl_condition>"
8313   "@
8314    vunpcklpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
8315    vmovddup\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}"
8316   [(set_attr "type" "sselog")
8317    (set_attr "prefix" "vex")
8318    (set_attr "mode" "V4DF")])
8320 (define_expand "vec_interleave_lowv4df"
8321   [(set (match_dup 3)
8322         (vec_select:V4DF
8323           (vec_concat:V8DF
8324             (match_operand:V4DF 1 "register_operand")
8325             (match_operand:V4DF 2 "nonimmediate_operand"))
8326           (parallel [(const_int 0) (const_int 4)
8327                      (const_int 2) (const_int 6)])))
8328    (set (match_dup 4)
8329         (vec_select:V4DF
8330           (vec_concat:V8DF
8331             (match_dup 1)
8332             (match_dup 2))
8333           (parallel [(const_int 1) (const_int 5)
8334                      (const_int 3) (const_int 7)])))
8335    (set (match_operand:V4DF 0 "register_operand")
8336         (vec_select:V4DF
8337           (vec_concat:V8DF
8338             (match_dup 3)
8339             (match_dup 4))
8340           (parallel [(const_int 0) (const_int 1)
8341                      (const_int 4) (const_int 5)])))]
8342  "TARGET_AVX"
8344   operands[3] = gen_reg_rtx (V4DFmode);
8345   operands[4] = gen_reg_rtx (V4DFmode);
8348 (define_insn "avx512vl_unpcklpd128_mask"
8349   [(set (match_operand:V2DF 0 "register_operand" "=v")
8350         (vec_merge:V2DF
8351           (vec_select:V2DF
8352             (vec_concat:V4DF
8353               (match_operand:V2DF 1 "register_operand" "v")
8354               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
8355             (parallel [(const_int 0) (const_int 2)]))
8356           (match_operand:V2DF 3 "vector_move_operand" "0C")
8357           (match_operand:QI 4 "register_operand" "Yk")))]
8358   "TARGET_AVX512VL"
8359   "vunpcklpd\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
8360   [(set_attr "type" "sselog")
8361    (set_attr "prefix" "evex")
8362    (set_attr "mode" "V2DF")])
8364 (define_expand "vec_interleave_lowv2df"
8365   [(set (match_operand:V2DF 0 "register_operand")
8366         (vec_select:V2DF
8367           (vec_concat:V4DF
8368             (match_operand:V2DF 1 "nonimmediate_operand")
8369             (match_operand:V2DF 2 "nonimmediate_operand"))
8370           (parallel [(const_int 0)
8371                      (const_int 2)])))]
8372   "TARGET_SSE2"
8374   if (!ix86_vec_interleave_v2df_operator_ok (operands, 0))
8375     operands[1] = force_reg (V2DFmode, operands[1]);
8378 (define_insn "*vec_interleave_lowv2df"
8379   [(set (match_operand:V2DF 0 "nonimmediate_operand"     "=x,v,v,x,v,o")
8380         (vec_select:V2DF
8381           (vec_concat:V4DF
8382             (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,m,0,v,0")
8383             (match_operand:V2DF 2 "nonimmediate_operand" " x,v,1,m,m,v"))
8384           (parallel [(const_int 0)
8385                      (const_int 2)])))]
8386   "TARGET_SSE2 && ix86_vec_interleave_v2df_operator_ok (operands, 0)"
8387   "@
8388    unpcklpd\t{%2, %0|%0, %2}
8389    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
8390    %vmovddup\t{%1, %0|%0, %q1}
8391    movhpd\t{%2, %0|%0, %q2}
8392    vmovhpd\t{%2, %1, %0|%0, %1, %q2}
8393    %vmovlpd\t{%2, %H0|%H0, %2}"
8394   [(set_attr "isa" "noavx,avx,sse3,noavx,avx,*")
8395    (set_attr "type" "sselog,sselog,sselog,ssemov,ssemov,ssemov")
8396    (set (attr "prefix_data16")
8397      (if_then_else (eq_attr "alternative" "3,5")
8398                    (const_string "1")
8399                    (const_string "*")))
8400    (set_attr "prefix" "orig,maybe_evex,maybe_vex,orig,maybe_evex,maybe_vex")
8401    (set_attr "mode" "V2DF,V2DF,DF,V1DF,V1DF,V1DF")])
8403 (define_split
8404   [(set (match_operand:V2DF 0 "memory_operand")
8405         (vec_select:V2DF
8406           (vec_concat:V4DF
8407             (match_operand:V2DF 1 "register_operand")
8408             (match_dup 1))
8409           (parallel [(const_int 0)
8410                      (const_int 2)])))]
8411   "TARGET_SSE3 && reload_completed"
8412   [(const_int 0)]
8414   rtx low = gen_lowpart (DFmode, operands[1]);
8416   emit_move_insn (adjust_address (operands[0], DFmode, 0), low);
8417   emit_move_insn (adjust_address (operands[0], DFmode, 8), low);
8418   DONE;
8421 (define_split
8422   [(set (match_operand:V2DF 0 "register_operand")
8423         (vec_select:V2DF
8424           (vec_concat:V4DF
8425             (match_operand:V2DF 1 "memory_operand")
8426             (match_dup 1))
8427           (parallel [(match_operand:SI 2 "const_0_to_1_operand")
8428                      (match_operand:SI 3 "const_int_operand")])))]
8429   "TARGET_SSE3 && INTVAL (operands[2]) + 2 == INTVAL (operands[3])"
8430   [(set (match_dup 0) (vec_duplicate:V2DF (match_dup 1)))]
8432   operands[1] = adjust_address (operands[1], DFmode, INTVAL (operands[2]) * 8);
8435 (define_insn "avx512f_vmscalef<mode><mask_scalar_name><round_scalar_name>"
8436   [(set (match_operand:VF_128 0 "register_operand" "=v")
8437         (vec_merge:VF_128
8438           (unspec:VF_128
8439             [(match_operand:VF_128 1 "register_operand" "v")
8440              (match_operand:VF_128 2 "<round_scalar_nimm_predicate>" "<round_scalar_constraint>")]
8441             UNSPEC_SCALEF)
8442           (match_dup 1)
8443           (const_int 1)))]
8444   "TARGET_AVX512F"
8445   "vscalef<ssescalarmodesuffix>\t{<round_scalar_mask_op3>%2, %1, %0<mask_scalar_operand3>|%0<mask_scalar_operand3>, %1, %2<round_scalar_mask_op3>}"
8446   [(set_attr "prefix" "evex")
8447    (set_attr "mode"  "<ssescalarmode>")])
8449 (define_insn "<avx512>_scalef<mode><mask_name><round_name>"
8450   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8451         (unspec:VF_AVX512VL
8452           [(match_operand:VF_AVX512VL 1 "register_operand" "v")
8453            (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")]
8454           UNSPEC_SCALEF))]
8455   "TARGET_AVX512F"
8456   "vscalef<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
8457   [(set_attr "prefix" "evex")
8458    (set_attr "mode"  "<MODE>")])
8460 (define_expand "<avx512>_vternlog<mode>_maskz"
8461   [(match_operand:VI48_AVX512VL 0 "register_operand")
8462    (match_operand:VI48_AVX512VL 1 "register_operand")
8463    (match_operand:VI48_AVX512VL 2 "register_operand")
8464    (match_operand:VI48_AVX512VL 3 "nonimmediate_operand")
8465    (match_operand:SI 4 "const_0_to_255_operand")
8466    (match_operand:<avx512fmaskmode> 5 "register_operand")]
8467   "TARGET_AVX512F"
8469   emit_insn (gen_<avx512>_vternlog<mode>_maskz_1 (
8470     operands[0], operands[1], operands[2], operands[3],
8471     operands[4], CONST0_RTX (<MODE>mode), operands[5]));
8472   DONE;
8475 (define_insn "<avx512>_vternlog<mode><sd_maskz_name>"
8476   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
8477         (unspec:VI48_AVX512VL
8478           [(match_operand:VI48_AVX512VL 1 "register_operand" "0")
8479            (match_operand:VI48_AVX512VL 2 "register_operand" "v")
8480            (match_operand:VI48_AVX512VL 3 "nonimmediate_operand" "vm")
8481            (match_operand:SI 4 "const_0_to_255_operand")]
8482           UNSPEC_VTERNLOG))]
8483   "TARGET_AVX512F"
8484   "vpternlog<ssemodesuffix>\t{%4, %3, %2, %0<sd_mask_op5>|%0<sd_mask_op5>, %2, %3, %4}"
8485   [(set_attr "type" "sselog")
8486    (set_attr "prefix" "evex")
8487    (set_attr "mode" "<sseinsnmode>")])
8489 (define_insn "<avx512>_vternlog<mode>_mask"
8490   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
8491         (vec_merge:VI48_AVX512VL
8492           (unspec:VI48_AVX512VL
8493             [(match_operand:VI48_AVX512VL 1 "register_operand" "0")
8494              (match_operand:VI48_AVX512VL 2 "register_operand" "v")
8495              (match_operand:VI48_AVX512VL 3 "nonimmediate_operand" "vm")
8496              (match_operand:SI 4 "const_0_to_255_operand")]
8497             UNSPEC_VTERNLOG)
8498           (match_dup 1)
8499           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
8500   "TARGET_AVX512F"
8501   "vpternlog<ssemodesuffix>\t{%4, %3, %2, %0%{%5%}|%0%{%5%}, %2, %3, %4}"
8502   [(set_attr "type" "sselog")
8503    (set_attr "prefix" "evex")
8504    (set_attr "mode" "<sseinsnmode>")])
8506 (define_insn "<avx512>_getexp<mode><mask_name><round_saeonly_name>"
8507   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8508         (unspec:VF_AVX512VL [(match_operand:VF_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
8509                         UNSPEC_GETEXP))]
8510    "TARGET_AVX512F"
8511    "vgetexp<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}";
8512     [(set_attr "prefix" "evex")
8513      (set_attr "mode" "<MODE>")])
8515 (define_insn "avx512f_sgetexp<mode><mask_scalar_name><round_saeonly_scalar_name>"
8516   [(set (match_operand:VF_128 0 "register_operand" "=v")
8517         (vec_merge:VF_128
8518           (unspec:VF_128
8519             [(match_operand:VF_128 1 "register_operand" "v")
8520              (match_operand:VF_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")]
8521             UNSPEC_GETEXP)
8522           (match_dup 1)
8523           (const_int 1)))]
8524    "TARGET_AVX512F"
8525    "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>}";
8526     [(set_attr "prefix" "evex")
8527      (set_attr "mode" "<ssescalarmode>")])
8529 (define_insn "<mask_codefor><avx512>_align<mode><mask_name>"
8530   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
8531         (unspec:VI48_AVX512VL [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
8532                                (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")
8533                                (match_operand:SI 3 "const_0_to_255_operand")]
8534                               UNSPEC_ALIGN))]
8535   "TARGET_AVX512F"
8536   "valign<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}";
8537   [(set_attr "prefix" "evex")
8538    (set_attr "mode" "<sseinsnmode>")])
8540 (define_expand "avx512f_shufps512_mask"
8541   [(match_operand:V16SF 0 "register_operand")
8542    (match_operand:V16SF 1 "register_operand")
8543    (match_operand:V16SF 2 "nonimmediate_operand")
8544    (match_operand:SI 3 "const_0_to_255_operand")
8545    (match_operand:V16SF 4 "register_operand")
8546    (match_operand:HI 5 "register_operand")]
8547   "TARGET_AVX512F"
8549   int mask = INTVAL (operands[3]);
8550   emit_insn (gen_avx512f_shufps512_1_mask (operands[0], operands[1], operands[2],
8551                                           GEN_INT ((mask >> 0) & 3),
8552                                           GEN_INT ((mask >> 2) & 3),
8553                                           GEN_INT (((mask >> 4) & 3) + 16),
8554                                           GEN_INT (((mask >> 6) & 3) + 16),
8555                                           GEN_INT (((mask >> 0) & 3) + 4),
8556                                           GEN_INT (((mask >> 2) & 3) + 4),
8557                                           GEN_INT (((mask >> 4) & 3) + 20),
8558                                           GEN_INT (((mask >> 6) & 3) + 20),
8559                                           GEN_INT (((mask >> 0) & 3) + 8),
8560                                           GEN_INT (((mask >> 2) & 3) + 8),
8561                                           GEN_INT (((mask >> 4) & 3) + 24),
8562                                           GEN_INT (((mask >> 6) & 3) + 24),
8563                                           GEN_INT (((mask >> 0) & 3) + 12),
8564                                           GEN_INT (((mask >> 2) & 3) + 12),
8565                                           GEN_INT (((mask >> 4) & 3) + 28),
8566                                           GEN_INT (((mask >> 6) & 3) + 28),
8567                                           operands[4], operands[5]));
8568   DONE;
8572 (define_expand "<avx512>_fixupimm<mode>_maskz<round_saeonly_expand_name>"
8573   [(match_operand:VF_AVX512VL 0 "register_operand")
8574    (match_operand:VF_AVX512VL 1 "register_operand")
8575    (match_operand:VF_AVX512VL 2 "register_operand")
8576    (match_operand:<sseintvecmode> 3 "<round_saeonly_expand_nimm_predicate>")
8577    (match_operand:SI 4 "const_0_to_255_operand")
8578    (match_operand:<avx512fmaskmode> 5 "register_operand")]
8579   "TARGET_AVX512F"
8581   emit_insn (gen_<avx512>_fixupimm<mode>_maskz_1<round_saeonly_expand_name> (
8582         operands[0], operands[1], operands[2], operands[3],
8583         operands[4], CONST0_RTX (<MODE>mode), operands[5]
8584         <round_saeonly_expand_operand6>));
8585   DONE;
8588 (define_insn "<avx512>_fixupimm<mode><sd_maskz_name><round_saeonly_name>"
8589   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8590         (unspec:VF_AVX512VL
8591           [(match_operand:VF_AVX512VL 1 "register_operand" "0")
8592            (match_operand:VF_AVX512VL 2 "register_operand" "v")
8593            (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "<round_saeonly_constraint>")
8594            (match_operand:SI 4 "const_0_to_255_operand")]
8595            UNSPEC_FIXUPIMM))]
8596   "TARGET_AVX512F"
8597   "vfixupimm<ssemodesuffix>\t{%4, <round_saeonly_sd_mask_op5>%3, %2, %0<sd_mask_op5>|%0<sd_mask_op5>, %2, %3<round_saeonly_sd_mask_op5>, %4}";
8598   [(set_attr "prefix" "evex")
8599    (set_attr "mode" "<MODE>")])
8601 (define_insn "<avx512>_fixupimm<mode>_mask<round_saeonly_name>"
8602   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8603         (vec_merge:VF_AVX512VL
8604           (unspec:VF_AVX512VL
8605             [(match_operand:VF_AVX512VL 1 "register_operand" "0")
8606              (match_operand:VF_AVX512VL 2 "register_operand" "v")
8607              (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "<round_saeonly_constraint>")
8608              (match_operand:SI 4 "const_0_to_255_operand")]
8609              UNSPEC_FIXUPIMM)
8610           (match_dup 1)
8611           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
8612   "TARGET_AVX512F"
8613   "vfixupimm<ssemodesuffix>\t{%4, <round_saeonly_op6>%3, %2, %0%{%5%}|%0%{%5%}, %2, %3<round_saeonly_op6>, %4}";
8614   [(set_attr "prefix" "evex")
8615    (set_attr "mode" "<MODE>")])
8617 (define_expand "avx512f_sfixupimm<mode>_maskz<round_saeonly_expand_name>"
8618   [(match_operand:VF_128 0 "register_operand")
8619    (match_operand:VF_128 1 "register_operand")
8620    (match_operand:VF_128 2 "register_operand")
8621    (match_operand:<sseintvecmode> 3 "<round_saeonly_expand_nimm_predicate>")
8622    (match_operand:SI 4 "const_0_to_255_operand")
8623    (match_operand:<avx512fmaskmode> 5 "register_operand")]
8624   "TARGET_AVX512F"
8626   emit_insn (gen_avx512f_sfixupimm<mode>_maskz_1<round_saeonly_expand_name> (
8627         operands[0], operands[1], operands[2], operands[3],
8628         operands[4], CONST0_RTX (<MODE>mode), operands[5]
8629         <round_saeonly_expand_operand6>));
8630   DONE;
8633 (define_insn "avx512f_sfixupimm<mode><sd_maskz_name><round_saeonly_name>"
8634   [(set (match_operand:VF_128 0 "register_operand" "=v")
8635         (vec_merge:VF_128
8636           (unspec:VF_128
8637             [(match_operand:VF_128 1 "register_operand" "0")
8638              (match_operand:VF_128 2 "register_operand" "v")
8639              (match_operand:<sseintvecmode> 3 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8640              (match_operand:SI 4 "const_0_to_255_operand")]
8641             UNSPEC_FIXUPIMM)
8642           (match_dup 1)
8643           (const_int 1)))]
8644    "TARGET_AVX512F"
8645    "vfixupimm<ssescalarmodesuffix>\t{%4, <round_saeonly_sd_mask_op5>%3, %2, %0<sd_mask_op5>|%0<sd_mask_op5>, %2, %<iptr>3<round_saeonly_sd_mask_op5>, %4}";
8646    [(set_attr "prefix" "evex")
8647    (set_attr "mode" "<ssescalarmode>")])
8649 (define_insn "avx512f_sfixupimm<mode>_mask<round_saeonly_name>"
8650   [(set (match_operand:VF_128 0 "register_operand" "=v")
8651         (vec_merge:VF_128
8652           (vec_merge:VF_128
8653             (unspec:VF_128
8654                [(match_operand:VF_128 1 "register_operand" "0")
8655                 (match_operand:VF_128 2 "register_operand" "v")
8656                 (match_operand:<sseintvecmode> 3 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8657                 (match_operand:SI 4 "const_0_to_255_operand")]
8658                UNSPEC_FIXUPIMM)
8659             (match_dup 1)
8660             (const_int 1))
8661           (match_dup 1)
8662           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
8663   "TARGET_AVX512F"
8664   "vfixupimm<ssescalarmodesuffix>\t{%4, <round_saeonly_op6>%3, %2, %0%{%5%}|%0%{%5%}, %2, %<iptr>3<round_saeonly_op6>, %4}";
8665   [(set_attr "prefix" "evex")
8666    (set_attr "mode" "<ssescalarmode>")])
8668 (define_insn "<avx512>_rndscale<mode><mask_name><round_saeonly_name>"
8669   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8670         (unspec:VF_AVX512VL
8671           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "<round_saeonly_constraint>")
8672            (match_operand:SI 2 "const_0_to_255_operand")]
8673           UNSPEC_ROUND))]
8674   "TARGET_AVX512F"
8675   "vrndscale<ssemodesuffix>\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}"
8676   [(set_attr "length_immediate" "1")
8677    (set_attr "prefix" "evex")
8678    (set_attr "mode" "<MODE>")])
8680 (define_insn "avx512f_rndscale<mode><round_saeonly_name>"
8681   [(set (match_operand:VF_128 0 "register_operand" "=v")
8682         (vec_merge:VF_128
8683           (unspec:VF_128
8684             [(match_operand:VF_128 1 "register_operand" "v")
8685              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8686              (match_operand:SI 3 "const_0_to_255_operand")]
8687             UNSPEC_ROUND)
8688           (match_dup 1)
8689           (const_int 1)))]
8690   "TARGET_AVX512F"
8691   "vrndscale<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %<iptr>2<round_saeonly_op4>, %3}"
8692   [(set_attr "length_immediate" "1")
8693    (set_attr "prefix" "evex")
8694    (set_attr "mode" "<MODE>")])
8696 ;; One bit in mask selects 2 elements.
8697 (define_insn "avx512f_shufps512_1<mask_name>"
8698   [(set (match_operand:V16SF 0 "register_operand" "=v")
8699         (vec_select:V16SF
8700           (vec_concat:V32SF
8701             (match_operand:V16SF 1 "register_operand" "v")
8702             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
8703           (parallel [(match_operand 3  "const_0_to_3_operand")
8704                      (match_operand 4  "const_0_to_3_operand")
8705                      (match_operand 5  "const_16_to_19_operand")
8706                      (match_operand 6  "const_16_to_19_operand")
8707                      (match_operand 7  "const_4_to_7_operand")
8708                      (match_operand 8  "const_4_to_7_operand")
8709                      (match_operand 9  "const_20_to_23_operand")
8710                      (match_operand 10  "const_20_to_23_operand")
8711                      (match_operand 11  "const_8_to_11_operand")
8712                      (match_operand 12  "const_8_to_11_operand")
8713                      (match_operand 13  "const_24_to_27_operand")
8714                      (match_operand 14  "const_24_to_27_operand")
8715                      (match_operand 15  "const_12_to_15_operand")
8716                      (match_operand 16  "const_12_to_15_operand")
8717                      (match_operand 17  "const_28_to_31_operand")
8718                      (match_operand 18  "const_28_to_31_operand")])))]
8719   "TARGET_AVX512F
8720    && (INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
8721        && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
8722        && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4)
8723        && INTVAL (operands[6]) == (INTVAL (operands[10]) - 4)
8724        && INTVAL (operands[3]) == (INTVAL (operands[11]) - 8)
8725        && INTVAL (operands[4]) == (INTVAL (operands[12]) - 8)
8726        && INTVAL (operands[5]) == (INTVAL (operands[13]) - 8)
8727        && INTVAL (operands[6]) == (INTVAL (operands[14]) - 8)
8728        && INTVAL (operands[3]) == (INTVAL (operands[15]) - 12)
8729        && INTVAL (operands[4]) == (INTVAL (operands[16]) - 12)
8730        && INTVAL (operands[5]) == (INTVAL (operands[17]) - 12)
8731        && INTVAL (operands[6]) == (INTVAL (operands[18]) - 12))"
8733   int mask;
8734   mask = INTVAL (operands[3]);
8735   mask |= INTVAL (operands[4]) << 2;
8736   mask |= (INTVAL (operands[5]) - 16) << 4;
8737   mask |= (INTVAL (operands[6]) - 16) << 6;
8738   operands[3] = GEN_INT (mask);
8740   return "vshufps\t{%3, %2, %1, %0<mask_operand19>|%0<mask_operand19>, %1, %2, %3}";
8742   [(set_attr "type" "sselog")
8743    (set_attr "length_immediate" "1")
8744    (set_attr "prefix" "evex")
8745    (set_attr "mode" "V16SF")])
8747 (define_expand "avx512f_shufpd512_mask"
8748   [(match_operand:V8DF 0 "register_operand")
8749    (match_operand:V8DF 1 "register_operand")
8750    (match_operand:V8DF 2 "nonimmediate_operand")
8751    (match_operand:SI 3 "const_0_to_255_operand")
8752    (match_operand:V8DF 4 "register_operand")
8753    (match_operand:QI 5 "register_operand")]
8754   "TARGET_AVX512F"
8756   int mask = INTVAL (operands[3]);
8757   emit_insn (gen_avx512f_shufpd512_1_mask (operands[0], operands[1], operands[2],
8758                                         GEN_INT (mask & 1),
8759                                         GEN_INT (mask & 2 ? 9 : 8),
8760                                         GEN_INT (mask & 4 ? 3 : 2),
8761                                         GEN_INT (mask & 8 ? 11 : 10),
8762                                         GEN_INT (mask & 16 ? 5 : 4),
8763                                         GEN_INT (mask & 32 ? 13 : 12),
8764                                         GEN_INT (mask & 64 ? 7 : 6),
8765                                         GEN_INT (mask & 128 ? 15 : 14),
8766                                         operands[4], operands[5]));
8767   DONE;
8770 (define_insn "avx512f_shufpd512_1<mask_name>"
8771   [(set (match_operand:V8DF 0 "register_operand" "=v")
8772         (vec_select:V8DF
8773           (vec_concat:V16DF
8774             (match_operand:V8DF 1 "register_operand" "v")
8775             (match_operand:V8DF 2 "nonimmediate_operand" "vm"))
8776           (parallel [(match_operand 3 "const_0_to_1_operand")
8777                      (match_operand 4 "const_8_to_9_operand")
8778                      (match_operand 5 "const_2_to_3_operand")
8779                      (match_operand 6 "const_10_to_11_operand")
8780                      (match_operand 7 "const_4_to_5_operand")
8781                      (match_operand 8 "const_12_to_13_operand")
8782                      (match_operand 9 "const_6_to_7_operand")
8783                      (match_operand 10 "const_14_to_15_operand")])))]
8784   "TARGET_AVX512F"
8786   int mask;
8787   mask = INTVAL (operands[3]);
8788   mask |= (INTVAL (operands[4]) - 8) << 1;
8789   mask |= (INTVAL (operands[5]) - 2) << 2;
8790   mask |= (INTVAL (operands[6]) - 10) << 3;
8791   mask |= (INTVAL (operands[7]) - 4) << 4;
8792   mask |= (INTVAL (operands[8]) - 12) << 5;
8793   mask |= (INTVAL (operands[9]) - 6) << 6;
8794   mask |= (INTVAL (operands[10]) - 14) << 7;
8795   operands[3] = GEN_INT (mask);
8797   return "vshufpd\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
8799   [(set_attr "type" "sselog")
8800    (set_attr "length_immediate" "1")
8801    (set_attr "prefix" "evex")
8802    (set_attr "mode" "V8DF")])
8804 (define_expand "avx_shufpd256<mask_expand4_name>"
8805   [(match_operand:V4DF 0 "register_operand")
8806    (match_operand:V4DF 1 "register_operand")
8807    (match_operand:V4DF 2 "nonimmediate_operand")
8808    (match_operand:SI 3 "const_int_operand")]
8809   "TARGET_AVX"
8811   int mask = INTVAL (operands[3]);
8812   emit_insn (gen_avx_shufpd256_1<mask_expand4_name> (operands[0],
8813                                                      operands[1],
8814                                                      operands[2],
8815                                                      GEN_INT (mask & 1),
8816                                                      GEN_INT (mask & 2 ? 5 : 4),
8817                                                      GEN_INT (mask & 4 ? 3 : 2),
8818                                                      GEN_INT (mask & 8 ? 7 : 6)
8819                                                      <mask_expand4_args>));
8820   DONE;
8823 (define_insn "avx_shufpd256_1<mask_name>"
8824   [(set (match_operand:V4DF 0 "register_operand" "=v")
8825         (vec_select:V4DF
8826           (vec_concat:V8DF
8827             (match_operand:V4DF 1 "register_operand" "v")
8828             (match_operand:V4DF 2 "nonimmediate_operand" "vm"))
8829           (parallel [(match_operand 3 "const_0_to_1_operand")
8830                      (match_operand 4 "const_4_to_5_operand")
8831                      (match_operand 5 "const_2_to_3_operand")
8832                      (match_operand 6 "const_6_to_7_operand")])))]
8833   "TARGET_AVX && <mask_avx512vl_condition>"
8835   int mask;
8836   mask = INTVAL (operands[3]);
8837   mask |= (INTVAL (operands[4]) - 4) << 1;
8838   mask |= (INTVAL (operands[5]) - 2) << 2;
8839   mask |= (INTVAL (operands[6]) - 6) << 3;
8840   operands[3] = GEN_INT (mask);
8842   return "vshufpd\t{%3, %2, %1, %0<mask_operand7>|%0<mask_operand7>, %1, %2, %3}";
8844   [(set_attr "type" "sseshuf")
8845    (set_attr "length_immediate" "1")
8846    (set_attr "prefix" "vex")
8847    (set_attr "mode" "V4DF")])
8849 (define_expand "sse2_shufpd<mask_expand4_name>"
8850   [(match_operand:V2DF 0 "register_operand")
8851    (match_operand:V2DF 1 "register_operand")
8852    (match_operand:V2DF 2 "vector_operand")
8853    (match_operand:SI 3 "const_int_operand")]
8854   "TARGET_SSE2"
8856   int mask = INTVAL (operands[3]);
8857   emit_insn (gen_sse2_shufpd_v2df<mask_expand4_name> (operands[0], operands[1],
8858                                                       operands[2], GEN_INT (mask & 1),
8859                                                       GEN_INT (mask & 2 ? 3 : 2)
8860                                                       <mask_expand4_args>));
8861   DONE;
8864 (define_insn "sse2_shufpd_v2df_mask"
8865   [(set (match_operand:V2DF 0 "register_operand" "=v")
8866     (vec_merge:V2DF
8867           (vec_select:V2DF
8868             (vec_concat:V4DF
8869               (match_operand:V2DF 1 "register_operand" "v")
8870               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
8871             (parallel [(match_operand 3 "const_0_to_1_operand")
8872                            (match_operand 4 "const_2_to_3_operand")]))
8873       (match_operand:V2DF 5 "vector_move_operand" "0C")
8874       (match_operand:QI 6 "register_operand" "Yk")))]
8875   "TARGET_AVX512VL"
8877   int mask;
8878   mask = INTVAL (operands[3]);
8879   mask |= (INTVAL (operands[4]) - 2) << 1;
8880   operands[3] = GEN_INT (mask);
8882   return "vshufpd\t{%3, %2, %1, %0%{%6%}%N5|%0%{%6%}%N5, %1, %2, %3}";
8884   [(set_attr "type" "sseshuf")
8885    (set_attr "length_immediate" "1")
8886    (set_attr "prefix" "evex")
8887    (set_attr "mode" "V2DF")])
8889 ;; punpcklqdq and punpckhqdq are shorter than shufpd.
8890 (define_insn "avx2_interleave_highv4di<mask_name>"
8891   [(set (match_operand:V4DI 0 "register_operand" "=v")
8892         (vec_select:V4DI
8893           (vec_concat:V8DI
8894             (match_operand:V4DI 1 "register_operand" "v")
8895             (match_operand:V4DI 2 "nonimmediate_operand" "vm"))
8896           (parallel [(const_int 1)
8897                      (const_int 5)
8898                      (const_int 3)
8899                      (const_int 7)])))]
8900   "TARGET_AVX2 && <mask_avx512vl_condition>"
8901   "vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8902   [(set_attr "type" "sselog")
8903    (set_attr "prefix" "vex")
8904    (set_attr "mode" "OI")])
8906 (define_insn "<mask_codefor>avx512f_interleave_highv8di<mask_name>"
8907   [(set (match_operand:V8DI 0 "register_operand" "=v")
8908         (vec_select:V8DI
8909           (vec_concat:V16DI
8910             (match_operand:V8DI 1 "register_operand" "v")
8911             (match_operand:V8DI 2 "nonimmediate_operand" "vm"))
8912           (parallel [(const_int 1) (const_int 9)
8913                      (const_int 3) (const_int 11)
8914                      (const_int 5) (const_int 13)
8915                      (const_int 7) (const_int 15)])))]
8916   "TARGET_AVX512F"
8917   "vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8918   [(set_attr "type" "sselog")
8919    (set_attr "prefix" "evex")
8920    (set_attr "mode" "XI")])
8922 (define_insn "vec_interleave_highv2di<mask_name>"
8923   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
8924         (vec_select:V2DI
8925           (vec_concat:V4DI
8926             (match_operand:V2DI 1 "register_operand" "0,v")
8927             (match_operand:V2DI 2 "vector_operand" "xBm,vm"))
8928           (parallel [(const_int 1)
8929                      (const_int 3)])))]
8930   "TARGET_SSE2 && <mask_avx512vl_condition>"
8931   "@
8932    punpckhqdq\t{%2, %0|%0, %2}
8933    vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8934   [(set_attr "isa" "noavx,avx")
8935    (set_attr "type" "sselog")
8936    (set_attr "prefix_data16" "1,*")
8937    (set_attr "prefix" "orig,<mask_prefix>")
8938    (set_attr "mode" "TI")])
8940 (define_insn "avx2_interleave_lowv4di<mask_name>"
8941   [(set (match_operand:V4DI 0 "register_operand" "=v")
8942         (vec_select:V4DI
8943           (vec_concat:V8DI
8944             (match_operand:V4DI 1 "register_operand" "v")
8945             (match_operand:V4DI 2 "nonimmediate_operand" "vm"))
8946           (parallel [(const_int 0)
8947                      (const_int 4)
8948                      (const_int 2)
8949                      (const_int 6)])))]
8950   "TARGET_AVX2 && <mask_avx512vl_condition>"
8951   "vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8952   [(set_attr "type" "sselog")
8953    (set_attr "prefix" "vex")
8954    (set_attr "mode" "OI")])
8956 (define_insn "<mask_codefor>avx512f_interleave_lowv8di<mask_name>"
8957   [(set (match_operand:V8DI 0 "register_operand" "=v")
8958         (vec_select:V8DI
8959           (vec_concat:V16DI
8960             (match_operand:V8DI 1 "register_operand" "v")
8961             (match_operand:V8DI 2 "nonimmediate_operand" "vm"))
8962           (parallel [(const_int 0) (const_int 8)
8963                      (const_int 2) (const_int 10)
8964                      (const_int 4) (const_int 12)
8965                      (const_int 6) (const_int 14)])))]
8966   "TARGET_AVX512F"
8967   "vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8968   [(set_attr "type" "sselog")
8969    (set_attr "prefix" "evex")
8970    (set_attr "mode" "XI")])
8972 (define_insn "vec_interleave_lowv2di<mask_name>"
8973   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
8974         (vec_select:V2DI
8975           (vec_concat:V4DI
8976             (match_operand:V2DI 1 "register_operand" "0,v")
8977             (match_operand:V2DI 2 "vector_operand" "xBm,vm"))
8978           (parallel [(const_int 0)
8979                      (const_int 2)])))]
8980   "TARGET_SSE2 && <mask_avx512vl_condition>"
8981   "@
8982    punpcklqdq\t{%2, %0|%0, %2}
8983    vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8984   [(set_attr "isa" "noavx,avx")
8985    (set_attr "type" "sselog")
8986    (set_attr "prefix_data16" "1,*")
8987    (set_attr "prefix" "orig,vex")
8988    (set_attr "mode" "TI")])
8990 (define_insn "sse2_shufpd_<mode>"
8991   [(set (match_operand:VI8F_128 0 "register_operand" "=x,v")
8992         (vec_select:VI8F_128
8993           (vec_concat:<ssedoublevecmode>
8994             (match_operand:VI8F_128 1 "register_operand" "0,v")
8995             (match_operand:VI8F_128 2 "vector_operand" "xBm,vm"))
8996           (parallel [(match_operand 3 "const_0_to_1_operand")
8997                      (match_operand 4 "const_2_to_3_operand")])))]
8998   "TARGET_SSE2"
9000   int mask;
9001   mask = INTVAL (operands[3]);
9002   mask |= (INTVAL (operands[4]) - 2) << 1;
9003   operands[3] = GEN_INT (mask);
9005   switch (which_alternative)
9006     {
9007     case 0:
9008       return "shufpd\t{%3, %2, %0|%0, %2, %3}";
9009     case 1:
9010       return "vshufpd\t{%3, %2, %1, %0|%0, %1, %2, %3}";
9011     default:
9012       gcc_unreachable ();
9013     }
9015   [(set_attr "isa" "noavx,avx")
9016    (set_attr "type" "sseshuf")
9017    (set_attr "length_immediate" "1")
9018    (set_attr "prefix" "orig,maybe_evex")
9019    (set_attr "mode" "V2DF")])
9021 ;; Avoid combining registers from different units in a single alternative,
9022 ;; see comment above inline_secondary_memory_needed function in i386.c
9023 (define_insn "sse2_storehpd"
9024   [(set (match_operand:DF 0 "nonimmediate_operand"     "=m,x,Yv,x,*f,r")
9025         (vec_select:DF
9026           (match_operand:V2DF 1 "nonimmediate_operand" " v,0, v,o,o,o")
9027           (parallel [(const_int 1)])))]
9028   "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
9029   "@
9030    %vmovhpd\t{%1, %0|%0, %1}
9031    unpckhpd\t%0, %0
9032    vunpckhpd\t{%d1, %0|%0, %d1}
9033    #
9034    #
9035    #"
9036   [(set_attr "isa" "*,noavx,avx,*,*,*")
9037    (set_attr "type" "ssemov,sselog1,sselog1,ssemov,fmov,imov")
9038    (set (attr "prefix_data16")
9039      (if_then_else
9040        (and (eq_attr "alternative" "0")
9041             (not (match_test "TARGET_AVX")))
9042        (const_string "1")
9043        (const_string "*")))
9044    (set_attr "prefix" "maybe_vex,orig,maybe_evex,*,*,*")
9045    (set_attr "mode" "V1DF,V1DF,V2DF,DF,DF,DF")])
9047 (define_split
9048   [(set (match_operand:DF 0 "register_operand")
9049         (vec_select:DF
9050           (match_operand:V2DF 1 "memory_operand")
9051           (parallel [(const_int 1)])))]
9052   "TARGET_SSE2 && reload_completed"
9053   [(set (match_dup 0) (match_dup 1))]
9054   "operands[1] = adjust_address (operands[1], DFmode, 8);")
9056 (define_insn "*vec_extractv2df_1_sse"
9057   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x")
9058         (vec_select:DF
9059           (match_operand:V2DF 1 "nonimmediate_operand" "x,x,o")
9060           (parallel [(const_int 1)])))]
9061   "!TARGET_SSE2 && TARGET_SSE
9062    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
9063   "@
9064    movhps\t{%1, %0|%q0, %1}
9065    movhlps\t{%1, %0|%0, %1}
9066    movlps\t{%H1, %0|%0, %H1}"
9067   [(set_attr "type" "ssemov")
9068    (set_attr "mode" "V2SF,V4SF,V2SF")])
9070 ;; Avoid combining registers from different units in a single alternative,
9071 ;; see comment above inline_secondary_memory_needed function in i386.c
9072 (define_insn "sse2_storelpd"
9073   [(set (match_operand:DF 0 "nonimmediate_operand"     "=m,x,x,*f,r")
9074         (vec_select:DF
9075           (match_operand:V2DF 1 "nonimmediate_operand" " v,x,m,m,m")
9076           (parallel [(const_int 0)])))]
9077   "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
9078   "@
9079    %vmovlpd\t{%1, %0|%0, %1}
9080    #
9081    #
9082    #
9083    #"
9084   [(set_attr "type" "ssemov,ssemov,ssemov,fmov,imov")
9085    (set (attr "prefix_data16")
9086      (if_then_else (eq_attr "alternative" "0")
9087                    (const_string "1")
9088                    (const_string "*")))
9089    (set_attr "prefix" "maybe_vex")
9090    (set_attr "mode" "V1DF,DF,DF,DF,DF")])
9092 (define_split
9093   [(set (match_operand:DF 0 "register_operand")
9094         (vec_select:DF
9095           (match_operand:V2DF 1 "nonimmediate_operand")
9096           (parallel [(const_int 0)])))]
9097   "TARGET_SSE2 && reload_completed"
9098   [(set (match_dup 0) (match_dup 1))]
9099   "operands[1] = gen_lowpart (DFmode, operands[1]);")
9101 (define_insn "*vec_extractv2df_0_sse"
9102   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x")
9103         (vec_select:DF
9104           (match_operand:V2DF 1 "nonimmediate_operand" "x,x,m")
9105           (parallel [(const_int 0)])))]
9106   "!TARGET_SSE2 && TARGET_SSE
9107    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
9108   "@
9109    movlps\t{%1, %0|%0, %1}
9110    movaps\t{%1, %0|%0, %1}
9111    movlps\t{%1, %0|%0, %q1}"
9112   [(set_attr "type" "ssemov")
9113    (set_attr "mode" "V2SF,V4SF,V2SF")])
9115 (define_expand "sse2_loadhpd_exp"
9116   [(set (match_operand:V2DF 0 "nonimmediate_operand")
9117         (vec_concat:V2DF
9118           (vec_select:DF
9119             (match_operand:V2DF 1 "nonimmediate_operand")
9120             (parallel [(const_int 0)]))
9121           (match_operand:DF 2 "nonimmediate_operand")))]
9122   "TARGET_SSE2"
9124   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V2DFmode, operands);
9126   emit_insn (gen_sse2_loadhpd (dst, operands[1], operands[2]));
9128   /* Fix up the destination if needed.  */
9129   if (dst != operands[0])
9130     emit_move_insn (operands[0], dst);
9132   DONE;
9135 ;; Avoid combining registers from different units in a single alternative,
9136 ;; see comment above inline_secondary_memory_needed function in i386.c
9137 (define_insn "sse2_loadhpd"
9138   [(set (match_operand:V2DF 0 "nonimmediate_operand"
9139           "=x,v,x,v ,o,o ,o")
9140         (vec_concat:V2DF
9141           (vec_select:DF
9142             (match_operand:V2DF 1 "nonimmediate_operand"
9143           " 0,v,0,v ,0,0 ,0")
9144             (parallel [(const_int 0)]))
9145           (match_operand:DF 2 "nonimmediate_operand"
9146           " m,m,x,Yv,x,*f,r")))]
9147   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
9148   "@
9149    movhpd\t{%2, %0|%0, %2}
9150    vmovhpd\t{%2, %1, %0|%0, %1, %2}
9151    unpcklpd\t{%2, %0|%0, %2}
9152    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
9153    #
9154    #
9155    #"
9156   [(set_attr "isa" "noavx,avx,noavx,avx,*,*,*")
9157    (set_attr "type" "ssemov,ssemov,sselog,sselog,ssemov,fmov,imov")
9158    (set (attr "prefix_data16")
9159      (if_then_else (eq_attr "alternative" "0")
9160                    (const_string "1")
9161                    (const_string "*")))
9162    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,*,*,*")
9163    (set_attr "mode" "V1DF,V1DF,V2DF,V2DF,DF,DF,DF")])
9165 (define_split
9166   [(set (match_operand:V2DF 0 "memory_operand")
9167         (vec_concat:V2DF
9168           (vec_select:DF (match_dup 0) (parallel [(const_int 0)]))
9169           (match_operand:DF 1 "register_operand")))]
9170   "TARGET_SSE2 && reload_completed"
9171   [(set (match_dup 0) (match_dup 1))]
9172   "operands[0] = adjust_address (operands[0], DFmode, 8);")
9174 (define_expand "sse2_loadlpd_exp"
9175   [(set (match_operand:V2DF 0 "nonimmediate_operand")
9176         (vec_concat:V2DF
9177           (match_operand:DF 2 "nonimmediate_operand")
9178           (vec_select:DF
9179             (match_operand:V2DF 1 "nonimmediate_operand")
9180             (parallel [(const_int 1)]))))]
9181   "TARGET_SSE2"
9183   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V2DFmode, operands);
9185   emit_insn (gen_sse2_loadlpd (dst, operands[1], operands[2]));
9187   /* Fix up the destination if needed.  */
9188   if (dst != operands[0])
9189     emit_move_insn (operands[0], dst);
9191   DONE;
9194 ;; Avoid combining registers from different units in a single alternative,
9195 ;; see comment above inline_secondary_memory_needed function in i386.c
9196 (define_insn "sse2_loadlpd"
9197   [(set (match_operand:V2DF 0 "nonimmediate_operand"
9198           "=v,x,v,x,v,x,x,v,m,m ,m")
9199         (vec_concat:V2DF
9200           (match_operand:DF 2 "nonimmediate_operand"
9201           "vm,m,m,x,v,0,0,v,x,*f,r")
9202           (vec_select:DF
9203             (match_operand:V2DF 1 "vector_move_operand"
9204           " C,0,v,0,v,x,o,o,0,0 ,0")
9205             (parallel [(const_int 1)]))))]
9206   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
9207   "@
9208    %vmovq\t{%2, %0|%0, %2}
9209    movlpd\t{%2, %0|%0, %2}
9210    vmovlpd\t{%2, %1, %0|%0, %1, %2}
9211    movsd\t{%2, %0|%0, %2}
9212    vmovsd\t{%2, %1, %0|%0, %1, %2}
9213    shufpd\t{$2, %1, %0|%0, %1, 2}
9214    movhpd\t{%H1, %0|%0, %H1}
9215    vmovhpd\t{%H1, %2, %0|%0, %2, %H1}
9216    #
9217    #
9218    #"
9219   [(set_attr "isa" "*,noavx,avx,noavx,avx,noavx,noavx,avx,*,*,*")
9220    (set (attr "type")
9221      (cond [(eq_attr "alternative" "5")
9222               (const_string "sselog")
9223             (eq_attr "alternative" "9")
9224               (const_string "fmov")
9225             (eq_attr "alternative" "10")
9226               (const_string "imov")
9227            ]
9228            (const_string "ssemov")))
9229    (set (attr "prefix_data16")
9230      (if_then_else (eq_attr "alternative" "1,6")
9231                    (const_string "1")
9232                    (const_string "*")))
9233    (set (attr "length_immediate")
9234      (if_then_else (eq_attr "alternative" "5")
9235                    (const_string "1")
9236                    (const_string "*")))
9237    (set (attr "prefix")
9238      (cond [(eq_attr "alternative" "0")
9239               (const_string "maybe_vex")
9240             (eq_attr "alternative" "1,3,5,6")
9241               (const_string "orig")
9242             (eq_attr "alternative" "2,4,7")
9243               (const_string "maybe_evex")
9244            ]
9245            (const_string "*")))
9246    (set_attr "mode" "DF,V1DF,V1DF,V1DF,V1DF,V2DF,V1DF,V1DF,DF,DF,DF")])
9248 (define_split
9249   [(set (match_operand:V2DF 0 "memory_operand")
9250         (vec_concat:V2DF
9251           (match_operand:DF 1 "register_operand")
9252           (vec_select:DF (match_dup 0) (parallel [(const_int 1)]))))]
9253   "TARGET_SSE2 && reload_completed"
9254   [(set (match_dup 0) (match_dup 1))]
9255   "operands[0] = adjust_address (operands[0], DFmode, 0);")
9257 (define_insn "sse2_movsd"
9258   [(set (match_operand:V2DF 0 "nonimmediate_operand"   "=x,v,x,v,m,x,x,v,o")
9259         (vec_merge:V2DF
9260           (match_operand:V2DF 2 "nonimmediate_operand" " x,v,m,m,v,0,0,v,0")
9261           (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,0,v,0,x,o,o,v")
9262           (const_int 1)))]
9263   "TARGET_SSE2"
9264   "@
9265    movsd\t{%2, %0|%0, %2}
9266    vmovsd\t{%2, %1, %0|%0, %1, %2}
9267    movlpd\t{%2, %0|%0, %q2}
9268    vmovlpd\t{%2, %1, %0|%0, %1, %q2}
9269    %vmovlpd\t{%2, %0|%q0, %2}
9270    shufpd\t{$2, %1, %0|%0, %1, 2}
9271    movhps\t{%H1, %0|%0, %H1}
9272    vmovhps\t{%H1, %2, %0|%0, %2, %H1}
9273    %vmovhps\t{%1, %H0|%H0, %1}"
9274   [(set_attr "isa" "noavx,avx,noavx,avx,*,noavx,noavx,avx,*")
9275    (set (attr "type")
9276      (if_then_else
9277        (eq_attr "alternative" "5")
9278        (const_string "sselog")
9279        (const_string "ssemov")))
9280    (set (attr "prefix_data16")
9281      (if_then_else
9282        (and (eq_attr "alternative" "2,4")
9283             (not (match_test "TARGET_AVX")))
9284        (const_string "1")
9285        (const_string "*")))
9286    (set (attr "length_immediate")
9287      (if_then_else (eq_attr "alternative" "5")
9288                    (const_string "1")
9289                    (const_string "*")))
9290    (set (attr "prefix")
9291      (cond [(eq_attr "alternative" "1,3,7")
9292               (const_string "maybe_evex")
9293             (eq_attr "alternative" "4,8")
9294               (const_string "maybe_vex")
9295            ]
9296            (const_string "orig")))
9297    (set_attr "mode" "DF,DF,V1DF,V1DF,V1DF,V2DF,V1DF,V1DF,V1DF")])
9299 (define_insn "vec_dupv2df<mask_name>"
9300   [(set (match_operand:V2DF 0 "register_operand"     "=x,x,v")
9301         (vec_duplicate:V2DF
9302           (match_operand:DF 1 "nonimmediate_operand" " 0,xm,vm")))]
9303   "TARGET_SSE2 && <mask_avx512vl_condition>"
9304   "@
9305    unpcklpd\t%0, %0
9306    %vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}
9307    vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
9308   [(set_attr "isa" "noavx,sse3,avx512vl")
9309    (set_attr "type" "sselog1")
9310    (set_attr "prefix" "orig,maybe_vex,evex")
9311    (set_attr "mode" "V2DF,DF,DF")])
9313 (define_insn "vec_concatv2df"
9314   [(set (match_operand:V2DF 0 "register_operand"     "=x,x,v,x,v,x,x, v,x,x")
9315         (vec_concat:V2DF
9316           (match_operand:DF 1 "nonimmediate_operand" " 0,x,v,m,m,0,x,xm,0,0")
9317           (match_operand:DF 2 "vector_move_operand"  " x,x,v,1,1,m,m, C,x,m")))]
9318   "TARGET_SSE
9319    && (!(MEM_P (operands[1]) && MEM_P (operands[2]))
9320        || (TARGET_SSE3 && rtx_equal_p (operands[1], operands[2])))"
9321   "@
9322    unpcklpd\t{%2, %0|%0, %2}
9323    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
9324    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
9325    %vmovddup\t{%1, %0|%0, %1}
9326    vmovddup\t{%1, %0|%0, %1}
9327    movhpd\t{%2, %0|%0, %2}
9328    vmovhpd\t{%2, %1, %0|%0, %1, %2}
9329    %vmovq\t{%1, %0|%0, %1}
9330    movlhps\t{%2, %0|%0, %2}
9331    movhps\t{%2, %0|%0, %2}"
9332   [(set (attr "isa")
9333      (cond [(eq_attr "alternative" "0,5")
9334               (const_string "sse2_noavx")
9335             (eq_attr "alternative" "1,6")
9336               (const_string "avx")
9337             (eq_attr "alternative" "2,4")
9338               (const_string "avx512vl")
9339             (eq_attr "alternative" "3")
9340               (const_string "sse3")
9341             (eq_attr "alternative" "7")
9342               (const_string "sse2")
9343            ]
9344            (const_string "noavx")))
9345    (set (attr "type")
9346      (if_then_else
9347        (eq_attr "alternative" "0,1,2,3,4")
9348        (const_string "sselog")
9349        (const_string "ssemov")))
9350    (set (attr "prefix_data16")
9351         (if_then_else (eq_attr "alternative" "5")
9352                       (const_string "1")
9353                       (const_string "*")))
9354    (set (attr "prefix")
9355      (cond [(eq_attr "alternative" "1,6")
9356               (const_string "vex")
9357             (eq_attr "alternative" "2,4")
9358               (const_string "evex")
9359             (eq_attr "alternative" "3,7")
9360               (const_string "maybe_vex")
9361            ]
9362            (const_string "orig")))
9363    (set_attr "mode" "V2DF,V2DF,V2DF, DF, DF, V1DF,V1DF,DF,V4SF,V2SF")])
9365 ;; vmovq clears also the higher bits.
9366 (define_insn "vec_set<mode>_0"
9367   [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
9368         (vec_merge:VF2_512_256
9369           (vec_duplicate:VF2_512_256
9370             (match_operand:<ssescalarmode> 2 "general_operand" "xm"))
9371           (match_operand:VF2_512_256 1 "const0_operand" "C")
9372           (const_int 1)))]
9373   "TARGET_AVX"
9374   "vmovq\t{%2, %x0|%x0, %2}"
9375   [(set_attr "type" "ssemov")
9376    (set_attr "prefix" "maybe_evex")
9377    (set_attr "mode" "DF")])
9379 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9381 ;; Parallel integer down-conversion operations
9383 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9385 (define_mode_iterator PMOV_DST_MODE_1 [V16QI V16HI V8SI V8HI])
9386 (define_mode_attr pmov_src_mode
9387   [(V16QI "V16SI") (V16HI "V16SI") (V8SI "V8DI") (V8HI "V8DI")])
9388 (define_mode_attr pmov_src_lower
9389   [(V16QI "v16si") (V16HI "v16si") (V8SI "v8di") (V8HI "v8di")])
9390 (define_mode_attr pmov_suff_1
9391   [(V16QI "db") (V16HI "dw") (V8SI "qd") (V8HI "qw")])
9393 (define_insn "*avx512f_<code><pmov_src_lower><mode>2"
9394   [(set (match_operand:PMOV_DST_MODE_1 0 "nonimmediate_operand" "=v,m")
9395         (any_truncate:PMOV_DST_MODE_1
9396           (match_operand:<pmov_src_mode> 1 "register_operand" "v,v")))]
9397   "TARGET_AVX512F"
9398   "vpmov<trunsuffix><pmov_suff_1>\t{%1, %0|%0, %1}"
9399   [(set_attr "type" "ssemov")
9400    (set_attr "memory" "none,store")
9401    (set_attr "prefix" "evex")
9402    (set_attr "mode" "<sseinsnmode>")])
9404 (define_insn "avx512f_<code><pmov_src_lower><mode>2_mask"
9405   [(set (match_operand:PMOV_DST_MODE_1 0 "nonimmediate_operand" "=v,m")
9406     (vec_merge:PMOV_DST_MODE_1
9407       (any_truncate:PMOV_DST_MODE_1
9408         (match_operand:<pmov_src_mode> 1 "register_operand" "v,v"))
9409       (match_operand:PMOV_DST_MODE_1 2 "vector_move_operand" "0C,0")
9410       (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
9411   "TARGET_AVX512F"
9412   "vpmov<trunsuffix><pmov_suff_1>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9413   [(set_attr "type" "ssemov")
9414    (set_attr "memory" "none,store")
9415    (set_attr "prefix" "evex")
9416    (set_attr "mode" "<sseinsnmode>")])
9418 (define_expand "avx512f_<code><pmov_src_lower><mode>2_mask_store"
9419   [(set (match_operand:PMOV_DST_MODE_1 0 "memory_operand")
9420     (vec_merge:PMOV_DST_MODE_1
9421       (any_truncate:PMOV_DST_MODE_1
9422         (match_operand:<pmov_src_mode> 1 "register_operand"))
9423       (match_dup 0)
9424       (match_operand:<avx512fmaskmode> 2 "register_operand")))]
9425   "TARGET_AVX512F")
9427 (define_insn "avx512bw_<code>v32hiv32qi2"
9428   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
9429         (any_truncate:V32QI
9430             (match_operand:V32HI 1 "register_operand" "v,v")))]
9431   "TARGET_AVX512BW"
9432   "vpmov<trunsuffix>wb\t{%1, %0|%0, %1}"
9433   [(set_attr "type" "ssemov")
9434    (set_attr "memory" "none,store")
9435    (set_attr "prefix" "evex")
9436    (set_attr "mode" "XI")])
9438 (define_insn "avx512bw_<code>v32hiv32qi2_mask"
9439   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
9440     (vec_merge:V32QI
9441       (any_truncate:V32QI
9442         (match_operand:V32HI 1 "register_operand" "v,v"))
9443       (match_operand:V32QI 2 "vector_move_operand" "0C,0")
9444       (match_operand:SI 3 "register_operand" "Yk,Yk")))]
9445   "TARGET_AVX512BW"
9446   "vpmov<trunsuffix>wb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9447   [(set_attr "type" "ssemov")
9448    (set_attr "memory" "none,store")
9449    (set_attr "prefix" "evex")
9450    (set_attr "mode" "XI")])
9452 (define_expand "avx512bw_<code>v32hiv32qi2_mask_store"
9453   [(set (match_operand:V32QI 0 "nonimmediate_operand")
9454     (vec_merge:V32QI
9455       (any_truncate:V32QI
9456         (match_operand:V32HI 1 "register_operand"))
9457       (match_dup 0)
9458       (match_operand:SI 2 "register_operand")))]
9459   "TARGET_AVX512BW")
9461 (define_mode_iterator PMOV_DST_MODE_2
9462   [V4SI V8HI (V16QI "TARGET_AVX512BW")])
9463 (define_mode_attr pmov_suff_2
9464   [(V16QI "wb") (V8HI "dw") (V4SI "qd")])
9466 (define_insn "*avx512vl_<code><ssedoublemodelower><mode>2"
9467   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand" "=v,m")
9468         (any_truncate:PMOV_DST_MODE_2
9469             (match_operand:<ssedoublemode> 1 "register_operand" "v,v")))]
9470   "TARGET_AVX512VL"
9471   "vpmov<trunsuffix><pmov_suff_2>\t{%1, %0|%0, %1}"
9472   [(set_attr "type" "ssemov")
9473    (set_attr "memory" "none,store")
9474    (set_attr "prefix" "evex")
9475    (set_attr "mode" "<sseinsnmode>")])
9477 (define_insn "<avx512>_<code><ssedoublemodelower><mode>2_mask"
9478   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand" "=v,m")
9479     (vec_merge:PMOV_DST_MODE_2
9480       (any_truncate:PMOV_DST_MODE_2
9481         (match_operand:<ssedoublemode> 1 "register_operand" "v,v"))
9482       (match_operand:PMOV_DST_MODE_2 2 "vector_move_operand" "0C,0")
9483       (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
9484   "TARGET_AVX512VL"
9485   "vpmov<trunsuffix><pmov_suff_2>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9486   [(set_attr "type" "ssemov")
9487    (set_attr "memory" "none,store")
9488    (set_attr "prefix" "evex")
9489    (set_attr "mode" "<sseinsnmode>")])
9491 (define_expand "<avx512>_<code><ssedoublemodelower><mode>2_mask_store"
9492   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand")
9493     (vec_merge:PMOV_DST_MODE_2
9494       (any_truncate:PMOV_DST_MODE_2
9495         (match_operand:<ssedoublemode> 1 "register_operand"))
9496       (match_dup 0)
9497       (match_operand:<avx512fmaskmode> 2 "register_operand")))]
9498   "TARGET_AVX512VL")
9500 (define_mode_iterator PMOV_SRC_MODE_3 [V4DI V2DI V8SI V4SI (V8HI "TARGET_AVX512BW")])
9501 (define_mode_attr pmov_dst_3
9502   [(V4DI "V4QI") (V2DI "V2QI") (V8SI "V8QI") (V4SI "V4QI") (V8HI "V8QI")])
9503 (define_mode_attr pmov_dst_zeroed_3
9504   [(V4DI "V12QI") (V2DI "V14QI") (V8SI "V8QI") (V4SI "V12QI") (V8HI "V8QI")])
9505 (define_mode_attr pmov_suff_3
9506   [(V4DI "qb") (V2DI "qb") (V8SI "db") (V4SI "db") (V8HI "wb")])
9508 (define_insn "*avx512vl_<code><mode>v<ssescalarnum>qi2"
9509   [(set (match_operand:V16QI 0 "register_operand" "=v")
9510     (vec_concat:V16QI
9511       (any_truncate:<pmov_dst_3>
9512               (match_operand:PMOV_SRC_MODE_3 1 "register_operand" "v"))
9513       (match_operand:<pmov_dst_zeroed_3> 2 "const0_operand")))]
9514   "TARGET_AVX512VL"
9515   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%0, %1}"
9516   [(set_attr "type" "ssemov")
9517    (set_attr "prefix" "evex")
9518    (set_attr "mode" "TI")])
9520 (define_insn "*avx512vl_<code>v2div2qi2_store"
9521   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9522     (vec_concat:V16QI
9523       (any_truncate:V2QI
9524               (match_operand:V2DI 1 "register_operand" "v"))
9525       (vec_select:V14QI
9526         (match_dup 0)
9527         (parallel [(const_int 2) (const_int 3)
9528                    (const_int 4) (const_int 5)
9529                    (const_int 6) (const_int 7)
9530                    (const_int 8) (const_int 9)
9531                    (const_int 10) (const_int 11)
9532                    (const_int 12) (const_int 13)
9533                    (const_int 14) (const_int 15)]))))]
9534   "TARGET_AVX512VL"
9535   "vpmov<trunsuffix>qb\t{%1, %0|%w0, %1}"
9536   [(set_attr "type" "ssemov")
9537    (set_attr "memory" "store")
9538    (set_attr "prefix" "evex")
9539    (set_attr "mode" "TI")])
9541 (define_insn "avx512vl_<code>v2div2qi2_mask"
9542   [(set (match_operand:V16QI 0 "register_operand" "=v")
9543     (vec_concat:V16QI
9544       (vec_merge:V2QI
9545         (any_truncate:V2QI
9546           (match_operand:V2DI 1 "register_operand" "v"))
9547         (vec_select:V2QI
9548           (match_operand:V16QI 2 "vector_move_operand" "0C")
9549           (parallel [(const_int 0) (const_int 1)]))
9550         (match_operand:QI 3 "register_operand" "Yk"))
9551       (const_vector:V14QI [(const_int 0) (const_int 0)
9552                            (const_int 0) (const_int 0)
9553                            (const_int 0) (const_int 0)
9554                            (const_int 0) (const_int 0)
9555                            (const_int 0) (const_int 0)
9556                            (const_int 0) (const_int 0)
9557                            (const_int 0) (const_int 0)])))]
9558   "TARGET_AVX512VL"
9559   "vpmov<trunsuffix>qb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9560   [(set_attr "type" "ssemov")
9561    (set_attr "prefix" "evex")
9562    (set_attr "mode" "TI")])
9564 (define_insn "*avx512vl_<code>v2div2qi2_mask_1"
9565   [(set (match_operand:V16QI 0 "register_operand" "=v")
9566     (vec_concat:V16QI
9567       (vec_merge:V2QI
9568         (any_truncate:V2QI
9569           (match_operand:V2DI 1 "register_operand" "v"))
9570         (const_vector:V2QI [(const_int 0) (const_int 0)])
9571         (match_operand:QI 2 "register_operand" "Yk"))
9572       (const_vector:V14QI [(const_int 0) (const_int 0)
9573                            (const_int 0) (const_int 0)
9574                            (const_int 0) (const_int 0)
9575                            (const_int 0) (const_int 0)
9576                            (const_int 0) (const_int 0)
9577                            (const_int 0) (const_int 0)
9578                            (const_int 0) (const_int 0)])))]
9579   "TARGET_AVX512VL"
9580   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9581   [(set_attr "type" "ssemov")
9582    (set_attr "prefix" "evex")
9583    (set_attr "mode" "TI")])
9585 (define_insn "avx512vl_<code>v2div2qi2_mask_store"
9586   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9587     (vec_concat:V16QI
9588       (vec_merge:V2QI
9589         (any_truncate:V2QI
9590           (match_operand:V2DI 1 "register_operand" "v"))
9591         (vec_select:V2QI
9592           (match_dup 0)
9593           (parallel [(const_int 0) (const_int 1)]))
9594         (match_operand:QI 2 "register_operand" "Yk"))
9595       (vec_select:V14QI
9596         (match_dup 0)
9597         (parallel [(const_int 2) (const_int 3)
9598                    (const_int 4) (const_int 5)
9599                    (const_int 6) (const_int 7)
9600                    (const_int 8) (const_int 9)
9601                    (const_int 10) (const_int 11)
9602                    (const_int 12) (const_int 13)
9603                    (const_int 14) (const_int 15)]))))]
9604   "TARGET_AVX512VL"
9605   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}|%w0%{%2%}, %1}"
9606   [(set_attr "type" "ssemov")
9607    (set_attr "memory" "store")
9608    (set_attr "prefix" "evex")
9609    (set_attr "mode" "TI")])
9611 (define_insn "*avx512vl_<code><mode>v4qi2_store"
9612   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9613     (vec_concat:V16QI
9614       (any_truncate:V4QI
9615               (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9616       (vec_select:V12QI
9617         (match_dup 0)
9618         (parallel [(const_int 4) (const_int 5)
9619                    (const_int 6) (const_int 7)
9620                    (const_int 8) (const_int 9)
9621                    (const_int 10) (const_int 11)
9622                    (const_int 12) (const_int 13)
9623                    (const_int 14) (const_int 15)]))))]
9624   "TARGET_AVX512VL"
9625   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%k0, %1}"
9626   [(set_attr "type" "ssemov")
9627    (set_attr "memory" "store")
9628    (set_attr "prefix" "evex")
9629    (set_attr "mode" "TI")])
9631 (define_insn "avx512vl_<code><mode>v4qi2_mask"
9632   [(set (match_operand:V16QI 0 "register_operand" "=v")
9633     (vec_concat:V16QI
9634       (vec_merge:V4QI
9635         (any_truncate:V4QI
9636           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9637         (vec_select:V4QI
9638           (match_operand:V16QI 2 "vector_move_operand" "0C")
9639           (parallel [(const_int 0) (const_int 1)
9640                      (const_int 2) (const_int 3)]))
9641         (match_operand:QI 3 "register_operand" "Yk"))
9642       (const_vector:V12QI [(const_int 0) (const_int 0)
9643                            (const_int 0) (const_int 0)
9644                            (const_int 0) (const_int 0)
9645                            (const_int 0) (const_int 0)
9646                            (const_int 0) (const_int 0)
9647                            (const_int 0) (const_int 0)])))]
9648   "TARGET_AVX512VL"
9649   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9650   [(set_attr "type" "ssemov")
9651    (set_attr "prefix" "evex")
9652    (set_attr "mode" "TI")])
9654 (define_insn "*avx512vl_<code><mode>v4qi2_mask_1"
9655   [(set (match_operand:V16QI 0 "register_operand" "=v")
9656     (vec_concat:V16QI
9657       (vec_merge:V4QI
9658         (any_truncate:V4QI
9659           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9660         (const_vector:V4QI [(const_int 0) (const_int 0)
9661                             (const_int 0) (const_int 0)])
9662         (match_operand:QI 2 "register_operand" "Yk"))
9663       (const_vector:V12QI [(const_int 0) (const_int 0)
9664                            (const_int 0) (const_int 0)
9665                            (const_int 0) (const_int 0)
9666                            (const_int 0) (const_int 0)
9667                            (const_int 0) (const_int 0)
9668                            (const_int 0) (const_int 0)])))]
9669   "TARGET_AVX512VL"
9670   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9671   [(set_attr "type" "ssemov")
9672    (set_attr "prefix" "evex")
9673    (set_attr "mode" "TI")])
9675 (define_insn "avx512vl_<code><mode>v4qi2_mask_store"
9676   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9677     (vec_concat:V16QI
9678       (vec_merge:V4QI
9679         (any_truncate:V4QI
9680           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9681         (vec_select:V4QI
9682           (match_dup 0)
9683           (parallel [(const_int 0) (const_int 1)
9684                      (const_int 2) (const_int 3)]))
9685         (match_operand:QI 2 "register_operand" "Yk"))
9686       (vec_select:V12QI
9687         (match_dup 0)
9688         (parallel [(const_int 4) (const_int 5)
9689                    (const_int 6) (const_int 7)
9690                    (const_int 8) (const_int 9)
9691                    (const_int 10) (const_int 11)
9692                    (const_int 12) (const_int 13)
9693                    (const_int 14) (const_int 15)]))))]
9694   "TARGET_AVX512VL"
9695   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%k0%{%2%}, %1}"
9696   [(set_attr "type" "ssemov")
9697    (set_attr "memory" "store")
9698    (set_attr "prefix" "evex")
9699    (set_attr "mode" "TI")])
9701 (define_mode_iterator VI2_128_BW_4_256
9702   [(V8HI "TARGET_AVX512BW") V8SI])
9704 (define_insn "*avx512vl_<code><mode>v8qi2_store"
9705   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9706     (vec_concat:V16QI
9707       (any_truncate:V8QI
9708               (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9709       (vec_select:V8QI
9710         (match_dup 0)
9711         (parallel [(const_int 8) (const_int 9)
9712                    (const_int 10) (const_int 11)
9713                    (const_int 12) (const_int 13)
9714                    (const_int 14) (const_int 15)]))))]
9715   "TARGET_AVX512VL"
9716   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%q0, %1}"
9717   [(set_attr "type" "ssemov")
9718    (set_attr "memory" "store")
9719    (set_attr "prefix" "evex")
9720    (set_attr "mode" "TI")])
9722 (define_insn "avx512vl_<code><mode>v8qi2_mask"
9723   [(set (match_operand:V16QI 0 "register_operand" "=v")
9724     (vec_concat:V16QI
9725       (vec_merge:V8QI
9726         (any_truncate:V8QI
9727           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9728         (vec_select:V8QI
9729           (match_operand:V16QI 2 "vector_move_operand" "0C")
9730           (parallel [(const_int 0) (const_int 1)
9731                      (const_int 2) (const_int 3)
9732                      (const_int 4) (const_int 5)
9733                      (const_int 6) (const_int 7)]))
9734         (match_operand:QI 3 "register_operand" "Yk"))
9735       (const_vector:V8QI [(const_int 0) (const_int 0)
9736                           (const_int 0) (const_int 0)
9737                           (const_int 0) (const_int 0)
9738                           (const_int 0) (const_int 0)])))]
9739   "TARGET_AVX512VL"
9740   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9741   [(set_attr "type" "ssemov")
9742    (set_attr "prefix" "evex")
9743    (set_attr "mode" "TI")])
9745 (define_insn "*avx512vl_<code><mode>v8qi2_mask_1"
9746   [(set (match_operand:V16QI 0 "register_operand" "=v")
9747     (vec_concat:V16QI
9748       (vec_merge:V8QI
9749         (any_truncate:V8QI
9750           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9751         (const_vector:V8QI [(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         (match_operand:QI 2 "register_operand" "Yk"))
9756       (const_vector:V8QI [(const_int 0) (const_int 0)
9757                           (const_int 0) (const_int 0)
9758                           (const_int 0) (const_int 0)
9759                           (const_int 0) (const_int 0)])))]
9760   "TARGET_AVX512VL"
9761   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9762   [(set_attr "type" "ssemov")
9763    (set_attr "prefix" "evex")
9764    (set_attr "mode" "TI")])
9766 (define_insn "avx512vl_<code><mode>v8qi2_mask_store"
9767   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9768     (vec_concat:V16QI
9769       (vec_merge:V8QI
9770         (any_truncate:V8QI
9771           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9772         (vec_select:V8QI
9773           (match_dup 0)
9774           (parallel [(const_int 0) (const_int 1)
9775                      (const_int 2) (const_int 3)
9776                      (const_int 4) (const_int 5)
9777                      (const_int 6) (const_int 7)]))
9778         (match_operand:QI 2 "register_operand" "Yk"))
9779       (vec_select:V8QI
9780         (match_dup 0)
9781         (parallel [(const_int 8) (const_int 9)
9782                    (const_int 10) (const_int 11)
9783                    (const_int 12) (const_int 13)
9784                    (const_int 14) (const_int 15)]))))]
9785   "TARGET_AVX512VL"
9786   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%q0%{%2%}, %1}"
9787   [(set_attr "type" "ssemov")
9788    (set_attr "memory" "store")
9789    (set_attr "prefix" "evex")
9790    (set_attr "mode" "TI")])
9792 (define_mode_iterator PMOV_SRC_MODE_4 [V4DI V2DI V4SI])
9793 (define_mode_attr pmov_dst_4
9794   [(V4DI "V4HI") (V2DI "V2HI") (V4SI "V4HI")])
9795 (define_mode_attr pmov_dst_zeroed_4
9796   [(V4DI "V4HI") (V2DI "V6HI") (V4SI "V4HI")])
9797 (define_mode_attr pmov_suff_4
9798   [(V4DI "qw") (V2DI "qw") (V4SI "dw")])
9800 (define_insn "*avx512vl_<code><mode>v<ssescalarnum>hi2"
9801   [(set (match_operand:V8HI 0 "register_operand" "=v")
9802     (vec_concat:V8HI
9803       (any_truncate:<pmov_dst_4>
9804               (match_operand:PMOV_SRC_MODE_4 1 "register_operand" "v"))
9805       (match_operand:<pmov_dst_zeroed_4> 2 "const0_operand")))]
9806   "TARGET_AVX512VL"
9807   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0|%0, %1}"
9808   [(set_attr "type" "ssemov")
9809    (set_attr "prefix" "evex")
9810    (set_attr "mode" "TI")])
9812 (define_insn "*avx512vl_<code><mode>v4hi2_store"
9813   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9814     (vec_concat:V8HI
9815       (any_truncate:V4HI
9816               (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9817       (vec_select:V4HI
9818         (match_dup 0)
9819         (parallel [(const_int 4) (const_int 5)
9820                    (const_int 6) (const_int 7)]))))]
9821   "TARGET_AVX512VL"
9822   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0|%0, %1}"
9823   [(set_attr "type" "ssemov")
9824    (set_attr "memory" "store")
9825    (set_attr "prefix" "evex")
9826    (set_attr "mode" "TI")])
9828 (define_insn "avx512vl_<code><mode>v4hi2_mask"
9829   [(set (match_operand:V8HI 0 "register_operand" "=v")
9830     (vec_concat:V8HI
9831       (vec_merge:V4HI
9832         (any_truncate:V4HI
9833           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9834         (vec_select:V4HI
9835           (match_operand:V8HI 2 "vector_move_operand" "0C")
9836           (parallel [(const_int 0) (const_int 1)
9837                      (const_int 2) (const_int 3)]))
9838         (match_operand:QI 3 "register_operand" "Yk"))
9839       (const_vector:V4HI [(const_int 0) (const_int 0)
9840                           (const_int 0) (const_int 0)])))]
9841   "TARGET_AVX512VL"
9842   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9843   [(set_attr "type" "ssemov")
9844    (set_attr "prefix" "evex")
9845    (set_attr "mode" "TI")])
9847 (define_insn "*avx512vl_<code><mode>v4hi2_mask_1"
9848   [(set (match_operand:V8HI 0 "register_operand" "=v")
9849     (vec_concat:V8HI
9850       (vec_merge:V4HI
9851         (any_truncate:V4HI
9852           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9853         (const_vector:V4HI [(const_int 0) (const_int 0)
9854                             (const_int 0) (const_int 0)])
9855         (match_operand:QI 2 "register_operand" "Yk"))
9856       (const_vector:V4HI [(const_int 0) (const_int 0)
9857                           (const_int 0) (const_int 0)])))]
9858   "TARGET_AVX512VL"
9859   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9860   [(set_attr "type" "ssemov")
9861    (set_attr "prefix" "evex")
9862    (set_attr "mode" "TI")])
9864 (define_insn "avx512vl_<code><mode>v4hi2_mask_store"
9865   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9866     (vec_concat:V8HI
9867       (vec_merge:V4HI
9868         (any_truncate:V4HI
9869           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9870         (vec_select:V4HI
9871           (match_dup 0)
9872           (parallel [(const_int 0) (const_int 1)
9873                      (const_int 2) (const_int 3)]))
9874         (match_operand:QI 2 "register_operand" "Yk"))
9875       (vec_select:V4HI
9876         (match_dup 0)
9877         (parallel [(const_int 4) (const_int 5)
9878                    (const_int 6) (const_int 7)]))))]
9879   "TARGET_AVX512VL"
9881   if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 4)
9882     return "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}|%0%{%2%}, %t1}";
9883   return "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}|%0%{%2%}, %g1}";
9885   [(set_attr "type" "ssemov")
9886    (set_attr "memory" "store")
9887    (set_attr "prefix" "evex")
9888    (set_attr "mode" "TI")])
9890 (define_insn "*avx512vl_<code>v2div2hi2_store"
9891   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9892     (vec_concat:V8HI
9893       (any_truncate:V2HI
9894               (match_operand:V2DI 1 "register_operand" "v"))
9895       (vec_select:V6HI
9896         (match_dup 0)
9897         (parallel [(const_int 2) (const_int 3)
9898                    (const_int 4) (const_int 5)
9899                    (const_int 6) (const_int 7)]))))]
9900   "TARGET_AVX512VL"
9901   "vpmov<trunsuffix>qw\t{%1, %0|%0, %1}"
9902   [(set_attr "type" "ssemov")
9903    (set_attr "memory" "store")
9904    (set_attr "prefix" "evex")
9905    (set_attr "mode" "TI")])
9907 (define_insn "avx512vl_<code>v2div2hi2_mask"
9908   [(set (match_operand:V8HI 0 "register_operand" "=v")
9909     (vec_concat:V8HI
9910       (vec_merge:V2HI
9911         (any_truncate:V2HI
9912           (match_operand:V2DI 1 "register_operand" "v"))
9913         (vec_select:V2HI
9914           (match_operand:V8HI 2 "vector_move_operand" "0C")
9915           (parallel [(const_int 0) (const_int 1)]))
9916         (match_operand:QI 3 "register_operand" "Yk"))
9917       (const_vector:V6HI [(const_int 0) (const_int 0)
9918                           (const_int 0) (const_int 0)
9919                           (const_int 0) (const_int 0)])))]
9920   "TARGET_AVX512VL"
9921   "vpmov<trunsuffix>qw\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9922   [(set_attr "type" "ssemov")
9923    (set_attr "prefix" "evex")
9924    (set_attr "mode" "TI")])
9926 (define_insn "*avx512vl_<code>v2div2hi2_mask_1"
9927   [(set (match_operand:V8HI 0 "register_operand" "=v")
9928     (vec_concat:V8HI
9929       (vec_merge:V2HI
9930         (any_truncate:V2HI
9931           (match_operand:V2DI 1 "register_operand" "v"))
9932         (const_vector:V2HI [(const_int 0) (const_int 0)])
9933         (match_operand:QI 2 "register_operand" "Yk"))
9934       (const_vector:V6HI [(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>qw\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9939   [(set_attr "type" "ssemov")
9940    (set_attr "prefix" "evex")
9941    (set_attr "mode" "TI")])
9943 (define_insn "avx512vl_<code>v2div2hi2_mask_store"
9944   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9945     (vec_concat:V8HI
9946       (vec_merge:V2HI
9947         (any_truncate:V2HI
9948           (match_operand:V2DI 1 "register_operand" "v"))
9949         (vec_select:V2HI
9950           (match_dup 0)
9951           (parallel [(const_int 0) (const_int 1)]))
9952         (match_operand:QI 2 "register_operand" "Yk"))
9953       (vec_select:V6HI
9954         (match_dup 0)
9955         (parallel [(const_int 2) (const_int 3)
9956                    (const_int 4) (const_int 5)
9957                    (const_int 6) (const_int 7)]))))]
9958   "TARGET_AVX512VL"
9959   "vpmov<trunsuffix>qw\t{%1, %0%{%2%}|%0%{%2%}, %g1}"
9960   [(set_attr "type" "ssemov")
9961    (set_attr "memory" "store")
9962    (set_attr "prefix" "evex")
9963    (set_attr "mode" "TI")])
9965 (define_insn "*avx512vl_<code>v2div2si2"
9966   [(set (match_operand:V4SI 0 "register_operand" "=v")
9967     (vec_concat:V4SI
9968       (any_truncate:V2SI
9969               (match_operand:V2DI 1 "register_operand" "v"))
9970       (match_operand:V2SI 2 "const0_operand")))]
9971   "TARGET_AVX512VL"
9972   "vpmov<trunsuffix>qd\t{%1, %0|%0, %1}"
9973   [(set_attr "type" "ssemov")
9974    (set_attr "prefix" "evex")
9975    (set_attr "mode" "TI")])
9977 (define_insn "*avx512vl_<code>v2div2si2_store"
9978   [(set (match_operand:V4SI 0 "memory_operand" "=m")
9979     (vec_concat:V4SI
9980       (any_truncate:V2SI
9981               (match_operand:V2DI 1 "register_operand" "v"))
9982       (vec_select:V2SI
9983         (match_dup 0)
9984         (parallel [(const_int 2) (const_int 3)]))))]
9985   "TARGET_AVX512VL"
9986   "vpmov<trunsuffix>qd\t{%1, %0|%0, %1}"
9987   [(set_attr "type" "ssemov")
9988    (set_attr "memory" "store")
9989    (set_attr "prefix" "evex")
9990    (set_attr "mode" "TI")])
9992 (define_insn "avx512vl_<code>v2div2si2_mask"
9993   [(set (match_operand:V4SI 0 "register_operand" "=v")
9994     (vec_concat:V4SI
9995       (vec_merge:V2SI
9996         (any_truncate:V2SI
9997           (match_operand:V2DI 1 "register_operand" "v"))
9998         (vec_select:V2SI
9999           (match_operand:V4SI 2 "vector_move_operand" "0C")
10000           (parallel [(const_int 0) (const_int 1)]))
10001         (match_operand:QI 3 "register_operand" "Yk"))
10002       (const_vector:V2SI [(const_int 0) (const_int 0)])))]
10003   "TARGET_AVX512VL"
10004   "vpmov<trunsuffix>qd\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
10005   [(set_attr "type" "ssemov")
10006    (set_attr "prefix" "evex")
10007    (set_attr "mode" "TI")])
10009 (define_insn "*avx512vl_<code>v2div2si2_mask_1"
10010   [(set (match_operand:V4SI 0 "register_operand" "=v")
10011     (vec_concat:V4SI
10012       (vec_merge:V2SI
10013         (any_truncate:V2SI
10014           (match_operand:V2DI 1 "register_operand" "v"))
10015         (const_vector:V2SI [(const_int 0) (const_int 0)])
10016         (match_operand:QI 2 "register_operand" "Yk"))
10017       (const_vector:V2SI [(const_int 0) (const_int 0)])))]
10018   "TARGET_AVX512VL"
10019   "vpmov<trunsuffix>qd\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
10020   [(set_attr "type" "ssemov")
10021    (set_attr "prefix" "evex")
10022    (set_attr "mode" "TI")])
10024 (define_insn "avx512vl_<code>v2div2si2_mask_store"
10025   [(set (match_operand:V4SI 0 "memory_operand" "=m")
10026     (vec_concat:V4SI
10027       (vec_merge:V2SI
10028         (any_truncate:V2SI
10029           (match_operand:V2DI 1 "register_operand" "v"))
10030         (vec_select:V2SI
10031           (match_dup 0)
10032           (parallel [(const_int 0) (const_int 1)]))
10033         (match_operand:QI 2 "register_operand" "Yk"))
10034       (vec_select:V2SI
10035         (match_dup 0)
10036         (parallel [(const_int 2) (const_int 3)]))))]
10037   "TARGET_AVX512VL"
10038   "vpmov<trunsuffix>qd\t{%1, %0%{%2%}|%0%{%2%}, %t1}"
10039   [(set_attr "type" "ssemov")
10040    (set_attr "memory" "store")
10041    (set_attr "prefix" "evex")
10042    (set_attr "mode" "TI")])
10044 (define_insn "*avx512f_<code>v8div16qi2"
10045   [(set (match_operand:V16QI 0 "register_operand" "=v")
10046         (vec_concat:V16QI
10047           (any_truncate:V8QI
10048             (match_operand:V8DI 1 "register_operand" "v"))
10049           (const_vector:V8QI [(const_int 0) (const_int 0)
10050                               (const_int 0) (const_int 0)
10051                               (const_int 0) (const_int 0)
10052                               (const_int 0) (const_int 0)])))]
10053   "TARGET_AVX512F"
10054   "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
10055   [(set_attr "type" "ssemov")
10056    (set_attr "prefix" "evex")
10057    (set_attr "mode" "TI")])
10059 (define_insn "*avx512f_<code>v8div16qi2_store"
10060   [(set (match_operand:V16QI 0 "memory_operand" "=m")
10061         (vec_concat:V16QI
10062           (any_truncate:V8QI
10063             (match_operand:V8DI 1 "register_operand" "v"))
10064           (vec_select:V8QI
10065             (match_dup 0)
10066             (parallel [(const_int 8) (const_int 9)
10067                        (const_int 10) (const_int 11)
10068                        (const_int 12) (const_int 13)
10069                        (const_int 14) (const_int 15)]))))]
10070   "TARGET_AVX512F"
10071   "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
10072   [(set_attr "type" "ssemov")
10073    (set_attr "memory" "store")
10074    (set_attr "prefix" "evex")
10075    (set_attr "mode" "TI")])
10077 (define_insn "avx512f_<code>v8div16qi2_mask"
10078   [(set (match_operand:V16QI 0 "register_operand" "=v")
10079     (vec_concat:V16QI
10080       (vec_merge:V8QI
10081         (any_truncate:V8QI
10082           (match_operand:V8DI 1 "register_operand" "v"))
10083         (vec_select:V8QI
10084           (match_operand:V16QI 2 "vector_move_operand" "0C")
10085           (parallel [(const_int 0) (const_int 1)
10086                      (const_int 2) (const_int 3)
10087                      (const_int 4) (const_int 5)
10088                      (const_int 6) (const_int 7)]))
10089         (match_operand:QI 3 "register_operand" "Yk"))
10090       (const_vector:V8QI [(const_int 0) (const_int 0)
10091                           (const_int 0) (const_int 0)
10092                           (const_int 0) (const_int 0)
10093                           (const_int 0) (const_int 0)])))]
10094   "TARGET_AVX512F"
10095   "vpmov<trunsuffix>qb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
10096   [(set_attr "type" "ssemov")
10097    (set_attr "prefix" "evex")
10098    (set_attr "mode" "TI")])
10100 (define_insn "*avx512f_<code>v8div16qi2_mask_1"
10101   [(set (match_operand:V16QI 0 "register_operand" "=v")
10102     (vec_concat:V16QI
10103       (vec_merge:V8QI
10104         (any_truncate:V8QI
10105           (match_operand:V8DI 1 "register_operand" "v"))
10106         (const_vector:V8QI [(const_int 0) (const_int 0)
10107                             (const_int 0) (const_int 0)
10108                             (const_int 0) (const_int 0)
10109                             (const_int 0) (const_int 0)])
10110         (match_operand:QI 2 "register_operand" "Yk"))
10111       (const_vector:V8QI [(const_int 0) (const_int 0)
10112                           (const_int 0) (const_int 0)
10113                           (const_int 0) (const_int 0)
10114                           (const_int 0) (const_int 0)])))]
10115   "TARGET_AVX512F"
10116   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
10117   [(set_attr "type" "ssemov")
10118    (set_attr "prefix" "evex")
10119    (set_attr "mode" "TI")])
10121 (define_insn "avx512f_<code>v8div16qi2_mask_store"
10122   [(set (match_operand:V16QI 0 "memory_operand" "=m")
10123     (vec_concat:V16QI
10124       (vec_merge:V8QI
10125         (any_truncate:V8QI
10126           (match_operand:V8DI 1 "register_operand" "v"))
10127         (vec_select:V8QI
10128           (match_dup 0)
10129           (parallel [(const_int 0) (const_int 1)
10130                      (const_int 2) (const_int 3)
10131                      (const_int 4) (const_int 5)
10132                      (const_int 6) (const_int 7)]))
10133         (match_operand:QI 2 "register_operand" "Yk"))
10134       (vec_select:V8QI
10135         (match_dup 0)
10136         (parallel [(const_int 8) (const_int 9)
10137                    (const_int 10) (const_int 11)
10138                    (const_int 12) (const_int 13)
10139                    (const_int 14) (const_int 15)]))))]
10140   "TARGET_AVX512F"
10141   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}|%q0%{%2%}, %1}"
10142   [(set_attr "type" "ssemov")
10143    (set_attr "memory" "store")
10144    (set_attr "prefix" "evex")
10145    (set_attr "mode" "TI")])
10147 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10149 ;; Parallel integral arithmetic
10151 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10153 (define_expand "neg<mode>2"
10154   [(set (match_operand:VI_AVX2 0 "register_operand")
10155         (minus:VI_AVX2
10156           (match_dup 2)
10157           (match_operand:VI_AVX2 1 "vector_operand")))]
10158   "TARGET_SSE2"
10159   "operands[2] = force_reg (<MODE>mode, CONST0_RTX (<MODE>mode));")
10161 (define_expand "<plusminus_insn><mode>3"
10162   [(set (match_operand:VI_AVX2 0 "register_operand")
10163         (plusminus:VI_AVX2
10164           (match_operand:VI_AVX2 1 "vector_operand")
10165           (match_operand:VI_AVX2 2 "vector_operand")))]
10166   "TARGET_SSE2"
10167   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10169 (define_expand "<plusminus_insn><mode>3_mask"
10170   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
10171         (vec_merge:VI48_AVX512VL
10172           (plusminus:VI48_AVX512VL
10173             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
10174             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
10175           (match_operand:VI48_AVX512VL 3 "vector_move_operand")
10176           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
10177   "TARGET_AVX512F"
10178   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10180 (define_expand "<plusminus_insn><mode>3_mask"
10181   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
10182         (vec_merge:VI12_AVX512VL
10183           (plusminus:VI12_AVX512VL
10184             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
10185             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand"))
10186           (match_operand:VI12_AVX512VL 3 "vector_move_operand")
10187           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
10188   "TARGET_AVX512BW"
10189   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10191 (define_insn "*<plusminus_insn><mode>3"
10192   [(set (match_operand:VI_AVX2 0 "register_operand" "=x,v")
10193         (plusminus:VI_AVX2
10194           (match_operand:VI_AVX2 1 "vector_operand" "<comm>0,v")
10195           (match_operand:VI_AVX2 2 "vector_operand" "xBm,vm")))]
10196   "TARGET_SSE2 && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10197   "@
10198    p<plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
10199    vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10200   [(set_attr "isa" "noavx,avx")
10201    (set_attr "type" "sseiadd")
10202    (set_attr "prefix_data16" "1,*")
10203    (set_attr "prefix" "orig,vex")
10204    (set_attr "mode" "<sseinsnmode>")])
10206 (define_insn "*<plusminus_insn><mode>3_mask"
10207   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10208         (vec_merge:VI48_AVX512VL
10209           (plusminus:VI48_AVX512VL
10210             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "<comm>v")
10211             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm"))
10212           (match_operand:VI48_AVX512VL 3 "vector_move_operand" "0C")
10213           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
10214   "TARGET_AVX512F && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10215   "vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
10216   [(set_attr "type" "sseiadd")
10217    (set_attr "prefix" "evex")
10218    (set_attr "mode" "<sseinsnmode>")])
10220 (define_insn "*<plusminus_insn><mode>3_mask"
10221   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
10222         (vec_merge:VI12_AVX512VL
10223           (plusminus:VI12_AVX512VL
10224             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "<comm>v")
10225             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm"))
10226           (match_operand:VI12_AVX512VL 3 "vector_move_operand" "0C")
10227           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
10228   "TARGET_AVX512BW && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10229   "vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
10230   [(set_attr "type" "sseiadd")
10231    (set_attr "prefix" "evex")
10232    (set_attr "mode" "<sseinsnmode>")])
10234 (define_expand "<sse2_avx2>_<plusminus_insn><mode>3<mask_name>"
10235   [(set (match_operand:VI12_AVX2 0 "register_operand")
10236         (sat_plusminus:VI12_AVX2
10237           (match_operand:VI12_AVX2 1 "vector_operand")
10238           (match_operand:VI12_AVX2 2 "vector_operand")))]
10239   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10240   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10242 (define_insn "*<sse2_avx2>_<plusminus_insn><mode>3<mask_name>"
10243   [(set (match_operand:VI12_AVX2 0 "register_operand" "=x,v")
10244         (sat_plusminus:VI12_AVX2
10245           (match_operand:VI12_AVX2 1 "vector_operand" "<comm>0,v")
10246           (match_operand:VI12_AVX2 2 "vector_operand" "xBm,vm")))]
10247   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
10248    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10249   "@
10250    p<plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
10251    vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10252   [(set_attr "isa" "noavx,avx")
10253    (set_attr "type" "sseiadd")
10254    (set_attr "prefix_data16" "1,*")
10255    (set_attr "prefix" "orig,maybe_evex")
10256    (set_attr "mode" "TI")])
10258 (define_expand "mul<mode>3<mask_name>"
10259   [(set (match_operand:VI1_AVX512 0 "register_operand")
10260         (mult:VI1_AVX512 (match_operand:VI1_AVX512 1 "register_operand")
10261                        (match_operand:VI1_AVX512 2 "register_operand")))]
10262   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10264   ix86_expand_vecop_qihi (MULT, operands[0], operands[1], operands[2]);
10265   DONE;
10268 (define_expand "mul<mode>3<mask_name>"
10269   [(set (match_operand:VI2_AVX2 0 "register_operand")
10270         (mult:VI2_AVX2 (match_operand:VI2_AVX2 1 "vector_operand")
10271                        (match_operand:VI2_AVX2 2 "vector_operand")))]
10272   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10273   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
10275 (define_insn "*mul<mode>3<mask_name>"
10276   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,v")
10277         (mult:VI2_AVX2 (match_operand:VI2_AVX2 1 "vector_operand" "%0,v")
10278                        (match_operand:VI2_AVX2 2 "vector_operand" "xBm,vm")))]
10279   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))
10280    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10281   "@
10282    pmullw\t{%2, %0|%0, %2}
10283    vpmullw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10284   [(set_attr "isa" "noavx,avx")
10285    (set_attr "type" "sseimul")
10286    (set_attr "prefix_data16" "1,*")
10287    (set_attr "prefix" "orig,vex")
10288    (set_attr "mode" "<sseinsnmode>")])
10290 (define_expand "<s>mul<mode>3_highpart<mask_name>"
10291   [(set (match_operand:VI2_AVX2 0 "register_operand")
10292         (truncate:VI2_AVX2
10293           (lshiftrt:<ssedoublemode>
10294             (mult:<ssedoublemode>
10295               (any_extend:<ssedoublemode>
10296                 (match_operand:VI2_AVX2 1 "vector_operand"))
10297               (any_extend:<ssedoublemode>
10298                 (match_operand:VI2_AVX2 2 "vector_operand")))
10299             (const_int 16))))]
10300   "TARGET_SSE2
10301    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10302   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
10304 (define_insn "*<s>mul<mode>3_highpart<mask_name>"
10305   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,v")
10306         (truncate:VI2_AVX2
10307           (lshiftrt:<ssedoublemode>
10308             (mult:<ssedoublemode>
10309               (any_extend:<ssedoublemode>
10310                 (match_operand:VI2_AVX2 1 "vector_operand" "%0,v"))
10311               (any_extend:<ssedoublemode>
10312                 (match_operand:VI2_AVX2 2 "vector_operand" "xBm,vm")))
10313             (const_int 16))))]
10314   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))
10315    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10316   "@
10317    pmulh<u>w\t{%2, %0|%0, %2}
10318    vpmulh<u>w\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10319   [(set_attr "isa" "noavx,avx")
10320    (set_attr "type" "sseimul")
10321    (set_attr "prefix_data16" "1,*")
10322    (set_attr "prefix" "orig,vex")
10323    (set_attr "mode" "<sseinsnmode>")])
10325 (define_expand "vec_widen_umult_even_v16si<mask_name>"
10326   [(set (match_operand:V8DI 0 "register_operand")
10327         (mult:V8DI
10328           (zero_extend:V8DI
10329             (vec_select:V8SI
10330               (match_operand:V16SI 1 "nonimmediate_operand")
10331               (parallel [(const_int 0) (const_int 2)
10332                          (const_int 4) (const_int 6)
10333                          (const_int 8) (const_int 10)
10334                          (const_int 12) (const_int 14)])))
10335           (zero_extend:V8DI
10336             (vec_select:V8SI
10337               (match_operand:V16SI 2 "nonimmediate_operand")
10338               (parallel [(const_int 0) (const_int 2)
10339                          (const_int 4) (const_int 6)
10340                          (const_int 8) (const_int 10)
10341                          (const_int 12) (const_int 14)])))))]
10342   "TARGET_AVX512F"
10343   "ix86_fixup_binary_operands_no_copy (MULT, V16SImode, operands);")
10345 (define_insn "*vec_widen_umult_even_v16si<mask_name>"
10346   [(set (match_operand:V8DI 0 "register_operand" "=v")
10347         (mult:V8DI
10348           (zero_extend:V8DI
10349             (vec_select:V8SI
10350               (match_operand:V16SI 1 "nonimmediate_operand" "%v")
10351               (parallel [(const_int 0) (const_int 2)
10352                          (const_int 4) (const_int 6)
10353                          (const_int 8) (const_int 10)
10354                          (const_int 12) (const_int 14)])))
10355           (zero_extend:V8DI
10356             (vec_select:V8SI
10357               (match_operand:V16SI 2 "nonimmediate_operand" "vm")
10358               (parallel [(const_int 0) (const_int 2)
10359                          (const_int 4) (const_int 6)
10360                          (const_int 8) (const_int 10)
10361                          (const_int 12) (const_int 14)])))))]
10362   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10363   "vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10364   [(set_attr "type" "sseimul")
10365    (set_attr "prefix_extra" "1")
10366    (set_attr "prefix" "evex")
10367    (set_attr "mode" "XI")])
10369 (define_expand "vec_widen_umult_even_v8si<mask_name>"
10370   [(set (match_operand:V4DI 0 "register_operand")
10371         (mult:V4DI
10372           (zero_extend:V4DI
10373             (vec_select:V4SI
10374               (match_operand:V8SI 1 "nonimmediate_operand")
10375               (parallel [(const_int 0) (const_int 2)
10376                          (const_int 4) (const_int 6)])))
10377           (zero_extend:V4DI
10378             (vec_select:V4SI
10379               (match_operand:V8SI 2 "nonimmediate_operand")
10380               (parallel [(const_int 0) (const_int 2)
10381                          (const_int 4) (const_int 6)])))))]
10382   "TARGET_AVX2 && <mask_avx512vl_condition>"
10383   "ix86_fixup_binary_operands_no_copy (MULT, V8SImode, operands);")
10385 (define_insn "*vec_widen_umult_even_v8si<mask_name>"
10386   [(set (match_operand:V4DI 0 "register_operand" "=v")
10387         (mult:V4DI
10388           (zero_extend:V4DI
10389             (vec_select:V4SI
10390               (match_operand:V8SI 1 "nonimmediate_operand" "%v")
10391               (parallel [(const_int 0) (const_int 2)
10392                          (const_int 4) (const_int 6)])))
10393           (zero_extend:V4DI
10394             (vec_select:V4SI
10395               (match_operand:V8SI 2 "nonimmediate_operand" "vm")
10396               (parallel [(const_int 0) (const_int 2)
10397                          (const_int 4) (const_int 6)])))))]
10398   "TARGET_AVX2 && <mask_avx512vl_condition>
10399    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10400   "vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10401   [(set_attr "type" "sseimul")
10402    (set_attr "prefix" "maybe_evex")
10403    (set_attr "mode" "OI")])
10405 (define_expand "vec_widen_umult_even_v4si<mask_name>"
10406   [(set (match_operand:V2DI 0 "register_operand")
10407         (mult:V2DI
10408           (zero_extend:V2DI
10409             (vec_select:V2SI
10410               (match_operand:V4SI 1 "vector_operand")
10411               (parallel [(const_int 0) (const_int 2)])))
10412           (zero_extend:V2DI
10413             (vec_select:V2SI
10414               (match_operand:V4SI 2 "vector_operand")
10415               (parallel [(const_int 0) (const_int 2)])))))]
10416   "TARGET_SSE2 && <mask_avx512vl_condition>"
10417   "ix86_fixup_binary_operands_no_copy (MULT, V4SImode, operands);")
10419 (define_insn "*vec_widen_umult_even_v4si<mask_name>"
10420   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
10421         (mult:V2DI
10422           (zero_extend:V2DI
10423             (vec_select:V2SI
10424               (match_operand:V4SI 1 "vector_operand" "%0,v")
10425               (parallel [(const_int 0) (const_int 2)])))
10426           (zero_extend:V2DI
10427             (vec_select:V2SI
10428               (match_operand:V4SI 2 "vector_operand" "xBm,vm")
10429               (parallel [(const_int 0) (const_int 2)])))))]
10430   "TARGET_SSE2 && <mask_avx512vl_condition>
10431    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10432   "@
10433    pmuludq\t{%2, %0|%0, %2}
10434    vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10435   [(set_attr "isa" "noavx,avx")
10436    (set_attr "type" "sseimul")
10437    (set_attr "prefix_data16" "1,*")
10438    (set_attr "prefix" "orig,maybe_evex")
10439    (set_attr "mode" "TI")])
10441 (define_expand "vec_widen_smult_even_v16si<mask_name>"
10442   [(set (match_operand:V8DI 0 "register_operand")
10443         (mult:V8DI
10444           (sign_extend:V8DI
10445             (vec_select:V8SI
10446               (match_operand:V16SI 1 "nonimmediate_operand")
10447               (parallel [(const_int 0) (const_int 2)
10448                          (const_int 4) (const_int 6)
10449                          (const_int 8) (const_int 10)
10450                          (const_int 12) (const_int 14)])))
10451           (sign_extend:V8DI
10452             (vec_select:V8SI
10453               (match_operand:V16SI 2 "nonimmediate_operand")
10454               (parallel [(const_int 0) (const_int 2)
10455                          (const_int 4) (const_int 6)
10456                          (const_int 8) (const_int 10)
10457                          (const_int 12) (const_int 14)])))))]
10458   "TARGET_AVX512F"
10459   "ix86_fixup_binary_operands_no_copy (MULT, V16SImode, operands);")
10461 (define_insn "*vec_widen_smult_even_v16si<mask_name>"
10462   [(set (match_operand:V8DI 0 "register_operand" "=v")
10463         (mult:V8DI
10464           (sign_extend:V8DI
10465             (vec_select:V8SI
10466               (match_operand:V16SI 1 "nonimmediate_operand" "%v")
10467               (parallel [(const_int 0) (const_int 2)
10468                          (const_int 4) (const_int 6)
10469                          (const_int 8) (const_int 10)
10470                          (const_int 12) (const_int 14)])))
10471           (sign_extend:V8DI
10472             (vec_select:V8SI
10473               (match_operand:V16SI 2 "nonimmediate_operand" "vm")
10474               (parallel [(const_int 0) (const_int 2)
10475                          (const_int 4) (const_int 6)
10476                          (const_int 8) (const_int 10)
10477                          (const_int 12) (const_int 14)])))))]
10478   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10479   "vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10480   [(set_attr "type" "sseimul")
10481    (set_attr "prefix_extra" "1")
10482    (set_attr "prefix" "evex")
10483    (set_attr "mode" "XI")])
10485 (define_expand "vec_widen_smult_even_v8si<mask_name>"
10486   [(set (match_operand:V4DI 0 "register_operand")
10487         (mult:V4DI
10488           (sign_extend:V4DI
10489             (vec_select:V4SI
10490               (match_operand:V8SI 1 "nonimmediate_operand")
10491               (parallel [(const_int 0) (const_int 2)
10492                          (const_int 4) (const_int 6)])))
10493           (sign_extend:V4DI
10494             (vec_select:V4SI
10495               (match_operand:V8SI 2 "nonimmediate_operand")
10496               (parallel [(const_int 0) (const_int 2)
10497                          (const_int 4) (const_int 6)])))))]
10498   "TARGET_AVX2 && <mask_avx512vl_condition>"
10499   "ix86_fixup_binary_operands_no_copy (MULT, V8SImode, operands);")
10501 (define_insn "*vec_widen_smult_even_v8si<mask_name>"
10502   [(set (match_operand:V4DI 0 "register_operand" "=v")
10503         (mult:V4DI
10504           (sign_extend:V4DI
10505             (vec_select:V4SI
10506               (match_operand:V8SI 1 "nonimmediate_operand" "%v")
10507               (parallel [(const_int 0) (const_int 2)
10508                          (const_int 4) (const_int 6)])))
10509           (sign_extend:V4DI
10510             (vec_select:V4SI
10511               (match_operand:V8SI 2 "nonimmediate_operand" "vm")
10512               (parallel [(const_int 0) (const_int 2)
10513                          (const_int 4) (const_int 6)])))))]
10514   "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10515   "vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10516   [(set_attr "type" "sseimul")
10517    (set_attr "prefix_extra" "1")
10518    (set_attr "prefix" "vex")
10519    (set_attr "mode" "OI")])
10521 (define_expand "sse4_1_mulv2siv2di3<mask_name>"
10522   [(set (match_operand:V2DI 0 "register_operand")
10523         (mult:V2DI
10524           (sign_extend:V2DI
10525             (vec_select:V2SI
10526               (match_operand:V4SI 1 "vector_operand")
10527               (parallel [(const_int 0) (const_int 2)])))
10528           (sign_extend:V2DI
10529             (vec_select:V2SI
10530               (match_operand:V4SI 2 "vector_operand")
10531               (parallel [(const_int 0) (const_int 2)])))))]
10532   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
10533   "ix86_fixup_binary_operands_no_copy (MULT, V4SImode, operands);")
10535 (define_insn "*sse4_1_mulv2siv2di3<mask_name>"
10536   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
10537         (mult:V2DI
10538           (sign_extend:V2DI
10539             (vec_select:V2SI
10540               (match_operand:V4SI 1 "vector_operand" "%0,0,v")
10541               (parallel [(const_int 0) (const_int 2)])))
10542           (sign_extend:V2DI
10543             (vec_select:V2SI
10544               (match_operand:V4SI 2 "vector_operand" "YrBm,*xBm,vm")
10545               (parallel [(const_int 0) (const_int 2)])))))]
10546   "TARGET_SSE4_1 && <mask_avx512vl_condition>
10547    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10548   "@
10549    pmuldq\t{%2, %0|%0, %2}
10550    pmuldq\t{%2, %0|%0, %2}
10551    vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10552   [(set_attr "isa" "noavx,noavx,avx")
10553    (set_attr "type" "sseimul")
10554    (set_attr "prefix_data16" "1,1,*")
10555    (set_attr "prefix_extra" "1")
10556    (set_attr "prefix" "orig,orig,vex")
10557    (set_attr "mode" "TI")])
10559 (define_insn "avx512bw_pmaddwd512<mode><mask_name>"
10560   [(set (match_operand:<sseunpackmode> 0 "register_operand" "=v")
10561           (unspec:<sseunpackmode>
10562             [(match_operand:VI2_AVX2 1 "register_operand" "v")
10563              (match_operand:VI2_AVX2 2 "nonimmediate_operand" "vm")]
10564              UNSPEC_PMADDWD512))]
10565    "TARGET_AVX512BW && <mask_mode512bit_condition>"
10566    "vpmaddwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}";
10567   [(set_attr "type" "sseiadd")
10568    (set_attr "prefix" "evex")
10569    (set_attr "mode" "XI")])
10571 (define_expand "avx2_pmaddwd"
10572   [(set (match_operand:V8SI 0 "register_operand")
10573         (plus:V8SI
10574           (mult:V8SI
10575             (sign_extend:V8SI
10576               (vec_select:V8HI
10577                 (match_operand:V16HI 1 "nonimmediate_operand")
10578                 (parallel [(const_int 0) (const_int 2)
10579                            (const_int 4) (const_int 6)
10580                            (const_int 8) (const_int 10)
10581                            (const_int 12) (const_int 14)])))
10582             (sign_extend:V8SI
10583               (vec_select:V8HI
10584                 (match_operand:V16HI 2 "nonimmediate_operand")
10585                 (parallel [(const_int 0) (const_int 2)
10586                            (const_int 4) (const_int 6)
10587                            (const_int 8) (const_int 10)
10588                            (const_int 12) (const_int 14)]))))
10589           (mult:V8SI
10590             (sign_extend:V8SI
10591               (vec_select:V8HI (match_dup 1)
10592                 (parallel [(const_int 1) (const_int 3)
10593                            (const_int 5) (const_int 7)
10594                            (const_int 9) (const_int 11)
10595                            (const_int 13) (const_int 15)])))
10596             (sign_extend:V8SI
10597               (vec_select:V8HI (match_dup 2)
10598                 (parallel [(const_int 1) (const_int 3)
10599                            (const_int 5) (const_int 7)
10600                            (const_int 9) (const_int 11)
10601                            (const_int 13) (const_int 15)]))))))]
10602   "TARGET_AVX2"
10603   "ix86_fixup_binary_operands_no_copy (MULT, V16HImode, operands);")
10605 (define_insn "*avx2_pmaddwd"
10606   [(set (match_operand:V8SI 0 "register_operand" "=x,v")
10607         (plus:V8SI
10608           (mult:V8SI
10609             (sign_extend:V8SI
10610               (vec_select:V8HI
10611                 (match_operand:V16HI 1 "nonimmediate_operand" "%x,v")
10612                 (parallel [(const_int 0) (const_int 2)
10613                            (const_int 4) (const_int 6)
10614                            (const_int 8) (const_int 10)
10615                            (const_int 12) (const_int 14)])))
10616             (sign_extend:V8SI
10617               (vec_select:V8HI
10618                 (match_operand:V16HI 2 "nonimmediate_operand" "xm,vm")
10619                 (parallel [(const_int 0) (const_int 2)
10620                            (const_int 4) (const_int 6)
10621                            (const_int 8) (const_int 10)
10622                            (const_int 12) (const_int 14)]))))
10623           (mult:V8SI
10624             (sign_extend:V8SI
10625               (vec_select:V8HI (match_dup 1)
10626                 (parallel [(const_int 1) (const_int 3)
10627                            (const_int 5) (const_int 7)
10628                            (const_int 9) (const_int 11)
10629                            (const_int 13) (const_int 15)])))
10630             (sign_extend:V8SI
10631               (vec_select:V8HI (match_dup 2)
10632                 (parallel [(const_int 1) (const_int 3)
10633                            (const_int 5) (const_int 7)
10634                            (const_int 9) (const_int 11)
10635                            (const_int 13) (const_int 15)]))))))]
10636   "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10637   "vpmaddwd\t{%2, %1, %0|%0, %1, %2}"
10638   [(set_attr "type" "sseiadd")
10639    (set_attr "isa" "*,avx512bw")
10640    (set_attr "prefix" "vex,evex")
10641    (set_attr "mode" "OI")])
10643 (define_expand "sse2_pmaddwd"
10644   [(set (match_operand:V4SI 0 "register_operand")
10645         (plus:V4SI
10646           (mult:V4SI
10647             (sign_extend:V4SI
10648               (vec_select:V4HI
10649                 (match_operand:V8HI 1 "vector_operand")
10650                 (parallel [(const_int 0) (const_int 2)
10651                            (const_int 4) (const_int 6)])))
10652             (sign_extend:V4SI
10653               (vec_select:V4HI
10654                 (match_operand:V8HI 2 "vector_operand")
10655                 (parallel [(const_int 0) (const_int 2)
10656                            (const_int 4) (const_int 6)]))))
10657           (mult:V4SI
10658             (sign_extend:V4SI
10659               (vec_select:V4HI (match_dup 1)
10660                 (parallel [(const_int 1) (const_int 3)
10661                            (const_int 5) (const_int 7)])))
10662             (sign_extend:V4SI
10663               (vec_select:V4HI (match_dup 2)
10664                 (parallel [(const_int 1) (const_int 3)
10665                            (const_int 5) (const_int 7)]))))))]
10666   "TARGET_SSE2"
10667   "ix86_fixup_binary_operands_no_copy (MULT, V8HImode, operands);")
10669 (define_insn "*sse2_pmaddwd"
10670   [(set (match_operand:V4SI 0 "register_operand" "=x,x,v")
10671         (plus:V4SI
10672           (mult:V4SI
10673             (sign_extend:V4SI
10674               (vec_select:V4HI
10675                 (match_operand:V8HI 1 "vector_operand" "%0,x,v")
10676                 (parallel [(const_int 0) (const_int 2)
10677                            (const_int 4) (const_int 6)])))
10678             (sign_extend:V4SI
10679               (vec_select:V4HI
10680                 (match_operand:V8HI 2 "vector_operand" "xBm,xm,vm")
10681                 (parallel [(const_int 0) (const_int 2)
10682                            (const_int 4) (const_int 6)]))))
10683           (mult:V4SI
10684             (sign_extend:V4SI
10685               (vec_select:V4HI (match_dup 1)
10686                 (parallel [(const_int 1) (const_int 3)
10687                            (const_int 5) (const_int 7)])))
10688             (sign_extend:V4SI
10689               (vec_select:V4HI (match_dup 2)
10690                 (parallel [(const_int 1) (const_int 3)
10691                            (const_int 5) (const_int 7)]))))))]
10692   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
10693   "@
10694    pmaddwd\t{%2, %0|%0, %2}
10695    vpmaddwd\t{%2, %1, %0|%0, %1, %2}
10696    vpmaddwd\t{%2, %1, %0|%0, %1, %2}"
10697   [(set_attr "isa" "noavx,avx,avx512bw")
10698    (set_attr "type" "sseiadd")
10699    (set_attr "atom_unit" "simul")
10700    (set_attr "prefix_data16" "1,*,*")
10701    (set_attr "prefix" "orig,vex,evex")
10702    (set_attr "mode" "TI")])
10704 (define_insn "avx512dq_mul<mode>3<mask_name>"
10705   [(set (match_operand:VI8 0 "register_operand" "=v")
10706         (mult:VI8
10707           (match_operand:VI8 1 "register_operand" "v")
10708           (match_operand:VI8 2 "nonimmediate_operand" "vm")))]
10709   "TARGET_AVX512DQ && <mask_mode512bit_condition>"
10710   "vpmullq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10711   [(set_attr "type" "sseimul")
10712    (set_attr "prefix" "evex")
10713    (set_attr "mode" "<sseinsnmode>")])
10715 (define_expand "mul<mode>3<mask_name>"
10716   [(set (match_operand:VI4_AVX512F 0 "register_operand")
10717         (mult:VI4_AVX512F
10718           (match_operand:VI4_AVX512F 1 "general_vector_operand")
10719           (match_operand:VI4_AVX512F 2 "general_vector_operand")))]
10720   "TARGET_SSE2 && <mask_mode512bit_condition>"
10722   if (TARGET_SSE4_1)
10723     {
10724       if (!vector_operand (operands[1], <MODE>mode))
10725         operands[1] = force_reg (<MODE>mode, operands[1]);
10726       if (!vector_operand (operands[2], <MODE>mode))
10727         operands[2] = force_reg (<MODE>mode, operands[2]);
10728       ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
10729     }
10730   else
10731     {
10732       ix86_expand_sse2_mulv4si3 (operands[0], operands[1], operands[2]);
10733       DONE;
10734     }
10737 (define_insn "*<sse4_1_avx2>_mul<mode>3<mask_name>"
10738   [(set (match_operand:VI4_AVX512F 0 "register_operand" "=Yr,*x,v")
10739         (mult:VI4_AVX512F
10740           (match_operand:VI4_AVX512F 1 "vector_operand" "%0,0,v")
10741           (match_operand:VI4_AVX512F 2 "vector_operand" "YrBm,*xBm,vm")))]
10742   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))
10743    && <mask_mode512bit_condition>"
10744   "@
10745    pmulld\t{%2, %0|%0, %2}
10746    pmulld\t{%2, %0|%0, %2}
10747    vpmulld\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10748   [(set_attr "isa" "noavx,noavx,avx")
10749    (set_attr "type" "sseimul")
10750    (set_attr "prefix_extra" "1")
10751    (set_attr "prefix" "<mask_prefix4>")
10752    (set_attr "btver2_decode" "vector,vector,vector")
10753    (set_attr "mode" "<sseinsnmode>")])
10755 (define_expand "mul<mode>3"
10756   [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand")
10757         (mult:VI8_AVX2_AVX512F
10758           (match_operand:VI8_AVX2_AVX512F 1 "register_operand")
10759           (match_operand:VI8_AVX2_AVX512F 2 "register_operand")))]
10760   "TARGET_SSE2"
10762   ix86_expand_sse2_mulvxdi3 (operands[0], operands[1], operands[2]);
10763   DONE;
10766 (define_expand "vec_widen_<s>mult_hi_<mode>"
10767   [(match_operand:<sseunpackmode> 0 "register_operand")
10768    (any_extend:<sseunpackmode>
10769      (match_operand:VI124_AVX2 1 "register_operand"))
10770    (match_operand:VI124_AVX2 2 "register_operand")]
10771   "TARGET_SSE2"
10773   ix86_expand_mul_widen_hilo (operands[0], operands[1], operands[2],
10774                               <u_bool>, true);
10775   DONE;
10778 (define_expand "vec_widen_<s>mult_lo_<mode>"
10779   [(match_operand:<sseunpackmode> 0 "register_operand")
10780    (any_extend:<sseunpackmode>
10781      (match_operand:VI124_AVX2 1 "register_operand"))
10782    (match_operand:VI124_AVX2 2 "register_operand")]
10783   "TARGET_SSE2"
10785   ix86_expand_mul_widen_hilo (operands[0], operands[1], operands[2],
10786                               <u_bool>, false);
10787   DONE;
10790 ;; Most widen_<s>mult_even_<mode> can be handled directly from other
10791 ;; named patterns, but signed V4SI needs special help for plain SSE2.
10792 (define_expand "vec_widen_smult_even_v4si"
10793   [(match_operand:V2DI 0 "register_operand")
10794    (match_operand:V4SI 1 "vector_operand")
10795    (match_operand:V4SI 2 "vector_operand")]
10796   "TARGET_SSE2"
10798   ix86_expand_mul_widen_evenodd (operands[0], operands[1], operands[2],
10799                                  false, false);
10800   DONE;
10803 (define_expand "vec_widen_<s>mult_odd_<mode>"
10804   [(match_operand:<sseunpackmode> 0 "register_operand")
10805    (any_extend:<sseunpackmode>
10806      (match_operand:VI4_AVX512F 1 "general_vector_operand"))
10807    (match_operand:VI4_AVX512F 2 "general_vector_operand")]
10808   "TARGET_SSE2"
10810   ix86_expand_mul_widen_evenodd (operands[0], operands[1], operands[2],
10811                                  <u_bool>, true);
10812   DONE;
10815 (define_mode_attr SDOT_PMADD_SUF
10816   [(V32HI "512v32hi") (V16HI "") (V8HI "")])
10818 (define_expand "sdot_prod<mode>"
10819   [(match_operand:<sseunpackmode> 0 "register_operand")
10820    (match_operand:VI2_AVX2 1 "register_operand")
10821    (match_operand:VI2_AVX2 2 "register_operand")
10822    (match_operand:<sseunpackmode> 3 "register_operand")]
10823   "TARGET_SSE2"
10825   rtx t = gen_reg_rtx (<sseunpackmode>mode);
10826   emit_insn (gen_<sse2_avx2>_pmaddwd<SDOT_PMADD_SUF> (t, operands[1], operands[2]));
10827   emit_insn (gen_rtx_SET (operands[0],
10828                           gen_rtx_PLUS (<sseunpackmode>mode,
10829                                         operands[3], t)));
10830   DONE;
10833 ;; Normally we use widen_mul_even/odd, but combine can't quite get it all
10834 ;; back together when madd is available.
10835 (define_expand "sdot_prodv4si"
10836   [(match_operand:V2DI 0 "register_operand")
10837    (match_operand:V4SI 1 "register_operand")
10838    (match_operand:V4SI 2 "register_operand")
10839    (match_operand:V2DI 3 "register_operand")]
10840   "TARGET_XOP"
10842   rtx t = gen_reg_rtx (V2DImode);
10843   emit_insn (gen_xop_pmacsdqh (t, operands[1], operands[2], operands[3]));
10844   emit_insn (gen_xop_pmacsdql (operands[0], operands[1], operands[2], t));
10845   DONE;
10848 (define_expand "usadv16qi"
10849   [(match_operand:V4SI 0 "register_operand")
10850    (match_operand:V16QI 1 "register_operand")
10851    (match_operand:V16QI 2 "vector_operand")
10852    (match_operand:V4SI 3 "vector_operand")]
10853   "TARGET_SSE2"
10855   rtx t1 = gen_reg_rtx (V2DImode);
10856   rtx t2 = gen_reg_rtx (V4SImode);
10857   emit_insn (gen_sse2_psadbw (t1, operands[1], operands[2]));
10858   convert_move (t2, t1, 0);
10859   emit_insn (gen_addv4si3 (operands[0], t2, operands[3]));
10860   DONE;
10863 (define_expand "usadv32qi"
10864   [(match_operand:V8SI 0 "register_operand")
10865    (match_operand:V32QI 1 "register_operand")
10866    (match_operand:V32QI 2 "nonimmediate_operand")
10867    (match_operand:V8SI 3 "nonimmediate_operand")]
10868   "TARGET_AVX2"
10870   rtx t1 = gen_reg_rtx (V4DImode);
10871   rtx t2 = gen_reg_rtx (V8SImode);
10872   emit_insn (gen_avx2_psadbw (t1, operands[1], operands[2]));
10873   convert_move (t2, t1, 0);
10874   emit_insn (gen_addv8si3 (operands[0], t2, operands[3]));
10875   DONE;
10878 (define_insn "<mask_codefor>ashr<mode>3<mask_name>"
10879   [(set (match_operand:VI248_AVX512BW_1 0 "register_operand" "=v,v")
10880         (ashiftrt:VI248_AVX512BW_1
10881           (match_operand:VI248_AVX512BW_1 1 "nonimmediate_operand" "v,vm")
10882           (match_operand:DI 2 "nonmemory_operand" "v,N")))]
10883   "TARGET_AVX512VL"
10884   "vpsra<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10885   [(set_attr "type" "sseishft")
10886    (set (attr "length_immediate")
10887      (if_then_else (match_operand 2 "const_int_operand")
10888        (const_string "1")
10889        (const_string "0")))
10890    (set_attr "mode" "<sseinsnmode>")])
10892 (define_insn "ashr<mode>3"
10893   [(set (match_operand:VI24_AVX2 0 "register_operand" "=x,x")
10894         (ashiftrt:VI24_AVX2
10895           (match_operand:VI24_AVX2 1 "register_operand" "0,x")
10896           (match_operand:DI 2 "nonmemory_operand" "xN,xN")))]
10897   "TARGET_SSE2"
10898   "@
10899    psra<ssemodesuffix>\t{%2, %0|%0, %2}
10900    vpsra<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10901   [(set_attr "isa" "noavx,avx")
10902    (set_attr "type" "sseishft")
10903    (set (attr "length_immediate")
10904      (if_then_else (match_operand 2 "const_int_operand")
10905        (const_string "1")
10906        (const_string "0")))
10907    (set_attr "prefix_data16" "1,*")
10908    (set_attr "prefix" "orig,vex")
10909    (set_attr "mode" "<sseinsnmode>")])
10911 (define_insn "ashr<mode>3<mask_name>"
10912   [(set (match_operand:VI248_AVX512BW_AVX512VL 0 "register_operand" "=v,v")
10913         (ashiftrt:VI248_AVX512BW_AVX512VL
10914           (match_operand:VI248_AVX512BW_AVX512VL 1 "nonimmediate_operand" "v,vm")
10915           (match_operand:DI 2 "nonmemory_operand" "v,N")))]
10916   "TARGET_AVX512F"
10917   "vpsra<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10918   [(set_attr "type" "sseishft")
10919    (set (attr "length_immediate")
10920      (if_then_else (match_operand 2 "const_int_operand")
10921        (const_string "1")
10922        (const_string "0")))
10923    (set_attr "mode" "<sseinsnmode>")])
10925 (define_insn "<mask_codefor><shift_insn><mode>3<mask_name>"
10926   [(set (match_operand:VI248_AVX512BW_2 0 "register_operand" "=v,v")
10927         (any_lshift:VI248_AVX512BW_2
10928           (match_operand:VI248_AVX512BW_2 1 "nonimmediate_operand" "v,vm")
10929           (match_operand:DI 2 "nonmemory_operand" "v,N")))]
10930   "TARGET_AVX512VL"
10931   "vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10932   [(set_attr "type" "sseishft")
10933    (set (attr "length_immediate")
10934      (if_then_else (match_operand 2 "const_int_operand")
10935        (const_string "1")
10936        (const_string "0")))
10937    (set_attr "mode" "<sseinsnmode>")])
10939 (define_insn "<shift_insn><mode>3"
10940   [(set (match_operand:VI248_AVX2 0 "register_operand" "=x,x")
10941         (any_lshift:VI248_AVX2
10942           (match_operand:VI248_AVX2 1 "register_operand" "0,x")
10943           (match_operand:DI 2 "nonmemory_operand" "xN,xN")))]
10944   "TARGET_SSE2"
10945   "@
10946    p<vshift><ssemodesuffix>\t{%2, %0|%0, %2}
10947    vp<vshift><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10948   [(set_attr "isa" "noavx,avx")
10949    (set_attr "type" "sseishft")
10950    (set (attr "length_immediate")
10951      (if_then_else (match_operand 2 "const_int_operand")
10952        (const_string "1")
10953        (const_string "0")))
10954    (set_attr "prefix_data16" "1,*")
10955    (set_attr "prefix" "orig,vex")
10956    (set_attr "mode" "<sseinsnmode>")])
10958 (define_insn "<shift_insn><mode>3<mask_name>"
10959   [(set (match_operand:VI248_AVX512BW 0 "register_operand" "=v,v")
10960         (any_lshift:VI248_AVX512BW
10961           (match_operand:VI248_AVX512BW 1 "nonimmediate_operand" "v,m")
10962           (match_operand:DI 2 "nonmemory_operand" "vN,N")))]
10963   "TARGET_AVX512F"
10964   "vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10965   [(set_attr "type" "sseishft")
10966    (set (attr "length_immediate")
10967      (if_then_else (match_operand 2 "const_int_operand")
10968        (const_string "1")
10969        (const_string "0")))
10970    (set_attr "mode" "<sseinsnmode>")])
10973 (define_expand "vec_shr_<mode>"
10974   [(set (match_dup 3)
10975         (lshiftrt:V1TI
10976          (match_operand:VI_128 1 "register_operand")
10977          (match_operand:SI 2 "const_0_to_255_mul_8_operand")))
10978    (set (match_operand:VI_128 0 "register_operand") (match_dup 4))]
10979   "TARGET_SSE2"
10981   operands[1] = gen_lowpart (V1TImode, operands[1]);
10982   operands[3] = gen_reg_rtx (V1TImode);
10983   operands[4] = gen_lowpart (<MODE>mode, operands[3]);
10986 (define_insn "avx512bw_<shift_insn><mode>3"
10987   [(set (match_operand:VIMAX_AVX512VL 0 "register_operand" "=v")
10988         (any_lshift:VIMAX_AVX512VL
10989          (match_operand:VIMAX_AVX512VL 1 "nonimmediate_operand" "vm")
10990          (match_operand:SI 2 "const_0_to_255_mul_8_operand" "n")))]
10991   "TARGET_AVX512BW"
10993   operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
10994   return "vp<vshift>dq\t{%2, %1, %0|%0, %1, %2}";
10996   [(set_attr "type" "sseishft")
10997    (set_attr "length_immediate" "1")
10998    (set_attr "prefix" "maybe_evex")
10999    (set_attr "mode" "<sseinsnmode>")])
11001 (define_insn "<sse2_avx2>_<shift_insn><mode>3"
11002   [(set (match_operand:VIMAX_AVX2 0 "register_operand" "=x,v")
11003         (any_lshift:VIMAX_AVX2
11004          (match_operand:VIMAX_AVX2 1 "register_operand" "0,v")
11005          (match_operand:SI 2 "const_0_to_255_mul_8_operand" "n,n")))]
11006   "TARGET_SSE2"
11008   operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
11010   switch (which_alternative)
11011     {
11012     case 0:
11013       return "p<vshift>dq\t{%2, %0|%0, %2}";
11014     case 1:
11015       return "vp<vshift>dq\t{%2, %1, %0|%0, %1, %2}";
11016     default:
11017       gcc_unreachable ();
11018     }
11020   [(set_attr "isa" "noavx,avx")
11021    (set_attr "type" "sseishft")
11022    (set_attr "length_immediate" "1")
11023    (set_attr "atom_unit" "sishuf")
11024    (set_attr "prefix_data16" "1,*")
11025    (set_attr "prefix" "orig,vex")
11026    (set_attr "mode" "<sseinsnmode>")])
11028 (define_insn "<avx512>_<rotate>v<mode><mask_name>"
11029   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
11030         (any_rotate:VI48_AVX512VL
11031           (match_operand:VI48_AVX512VL 1 "register_operand" "v")
11032           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")))]
11033   "TARGET_AVX512F"
11034   "vp<rotate>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11035   [(set_attr "prefix" "evex")
11036    (set_attr "mode" "<sseinsnmode>")])
11038 (define_insn "<avx512>_<rotate><mode><mask_name>"
11039   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
11040         (any_rotate:VI48_AVX512VL
11041           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")
11042           (match_operand:SI 2 "const_0_to_255_operand")))]
11043   "TARGET_AVX512F"
11044   "vp<rotate><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11045   [(set_attr "prefix" "evex")
11046    (set_attr "mode" "<sseinsnmode>")])
11048 (define_expand "<code><mode>3"
11049   [(set (match_operand:VI124_256_AVX512F_AVX512BW 0 "register_operand")
11050         (maxmin:VI124_256_AVX512F_AVX512BW
11051           (match_operand:VI124_256_AVX512F_AVX512BW 1 "nonimmediate_operand")
11052           (match_operand:VI124_256_AVX512F_AVX512BW 2 "nonimmediate_operand")))]
11053   "TARGET_AVX2"
11054   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
11056 (define_insn "*avx2_<code><mode>3"
11057   [(set (match_operand:VI124_256 0 "register_operand" "=v")
11058         (maxmin:VI124_256
11059           (match_operand:VI124_256 1 "nonimmediate_operand" "%v")
11060           (match_operand:VI124_256 2 "nonimmediate_operand" "vm")))]
11061   "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11062   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11063   [(set_attr "type" "sseiadd")
11064    (set_attr "prefix_extra" "1")
11065    (set_attr "prefix" "vex")
11066    (set_attr "mode" "OI")])
11068 (define_expand "<code><mode>3_mask"
11069   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
11070         (vec_merge:VI48_AVX512VL
11071           (maxmin:VI48_AVX512VL
11072             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
11073             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
11074           (match_operand:VI48_AVX512VL 3 "vector_move_operand")
11075           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
11076   "TARGET_AVX512F"
11077   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
11079 (define_insn "*avx512f_<code><mode>3<mask_name>"
11080   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
11081         (maxmin:VI48_AVX512VL
11082           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "%v")
11083           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")))]
11084   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11085   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11086   [(set_attr "type" "sseiadd")
11087    (set_attr "prefix_extra" "1")
11088    (set_attr "prefix" "maybe_evex")
11089    (set_attr "mode" "<sseinsnmode>")])
11091 (define_insn "<mask_codefor><code><mode>3<mask_name>"
11092   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
11093         (maxmin:VI12_AVX512VL
11094           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
11095           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")))]
11096   "TARGET_AVX512BW"
11097   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11098   [(set_attr "type" "sseiadd")
11099    (set_attr "prefix" "evex")
11100    (set_attr "mode" "<sseinsnmode>")])
11102 (define_expand "<code><mode>3"
11103   [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand")
11104         (maxmin:VI8_AVX2_AVX512F
11105           (match_operand:VI8_AVX2_AVX512F 1 "register_operand")
11106           (match_operand:VI8_AVX2_AVX512F 2 "register_operand")))]
11107   "TARGET_SSE4_2"
11109   if (TARGET_AVX512F
11110       && (<MODE>mode == V8DImode || TARGET_AVX512VL))
11111     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
11112   else 
11113     {
11114       enum rtx_code code;
11115       rtx xops[6];
11116       bool ok;
11119       xops[0] = operands[0];
11121       if (<CODE> == SMAX || <CODE> == UMAX)
11122         {
11123           xops[1] = operands[1];
11124           xops[2] = operands[2];
11125         }
11126       else
11127         {
11128           xops[1] = operands[2];
11129           xops[2] = operands[1];
11130         }
11132       code = (<CODE> == UMAX || <CODE> == UMIN) ? GTU : GT;
11134       xops[3] = gen_rtx_fmt_ee (code, VOIDmode, operands[1], operands[2]);
11135       xops[4] = operands[1];
11136       xops[5] = operands[2];
11138       ok = ix86_expand_int_vcond (xops);
11139       gcc_assert (ok);
11140       DONE;
11141     }
11144 (define_expand "<code><mode>3"
11145   [(set (match_operand:VI124_128 0 "register_operand")
11146         (smaxmin:VI124_128
11147           (match_operand:VI124_128 1 "vector_operand")
11148           (match_operand:VI124_128 2 "vector_operand")))]
11149   "TARGET_SSE2"
11151   if (TARGET_SSE4_1 || <MODE>mode == V8HImode)
11152     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
11153   else
11154     {
11155       rtx xops[6];
11156       bool ok;
11158       xops[0] = operands[0];
11159       operands[1] = force_reg (<MODE>mode, operands[1]);
11160       operands[2] = force_reg (<MODE>mode, operands[2]);
11162       if (<CODE> == SMAX)
11163         {
11164           xops[1] = operands[1];
11165           xops[2] = operands[2];
11166         }
11167       else
11168         {
11169           xops[1] = operands[2];
11170           xops[2] = operands[1];
11171         }
11173       xops[3] = gen_rtx_GT (VOIDmode, operands[1], operands[2]);
11174       xops[4] = operands[1];
11175       xops[5] = operands[2];
11177       ok = ix86_expand_int_vcond (xops);
11178       gcc_assert (ok);
11179       DONE;
11180     }
11183 (define_insn "*sse4_1_<code><mode>3<mask_name>"
11184   [(set (match_operand:VI14_128 0 "register_operand" "=Yr,*x,v")
11185         (smaxmin:VI14_128
11186           (match_operand:VI14_128 1 "vector_operand" "%0,0,v")
11187           (match_operand:VI14_128 2 "vector_operand" "YrBm,*xBm,vm")))]
11188   "TARGET_SSE4_1
11189    && <mask_mode512bit_condition>
11190    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11191   "@
11192    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
11193    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
11194    vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11195   [(set_attr "isa" "noavx,noavx,avx")
11196    (set_attr "type" "sseiadd")
11197    (set_attr "prefix_extra" "1,1,*")
11198    (set_attr "prefix" "orig,orig,vex")
11199    (set_attr "mode" "TI")])
11201 (define_insn "*<code>v8hi3"
11202   [(set (match_operand:V8HI 0 "register_operand" "=x,x,v")
11203         (smaxmin:V8HI
11204           (match_operand:V8HI 1 "vector_operand" "%0,x,v")
11205           (match_operand:V8HI 2 "vector_operand" "xBm,xm,vm")))]
11206   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11207   "@
11208    p<maxmin_int>w\t{%2, %0|%0, %2}
11209    vp<maxmin_int>w\t{%2, %1, %0|%0, %1, %2}
11210    vp<maxmin_int>w\t{%2, %1, %0|%0, %1, %2}"
11211   [(set_attr "isa" "noavx,avx,avx512bw")
11212    (set_attr "type" "sseiadd")
11213    (set_attr "prefix_data16" "1,*,*")
11214    (set_attr "prefix_extra" "*,1,1")
11215    (set_attr "prefix" "orig,vex,evex")
11216    (set_attr "mode" "TI")])
11218 (define_expand "<code><mode>3"
11219   [(set (match_operand:VI124_128 0 "register_operand")
11220         (umaxmin:VI124_128
11221           (match_operand:VI124_128 1 "vector_operand")
11222           (match_operand:VI124_128 2 "vector_operand")))]
11223   "TARGET_SSE2"
11225   if (TARGET_SSE4_1 || <MODE>mode == V16QImode)
11226     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
11227   else if (<CODE> == UMAX && <MODE>mode == V8HImode)
11228     {
11229       rtx op0 = operands[0], op2 = operands[2], op3 = op0;
11230       operands[1] = force_reg (<MODE>mode, operands[1]);
11231       if (rtx_equal_p (op3, op2))
11232         op3 = gen_reg_rtx (V8HImode);
11233       emit_insn (gen_sse2_ussubv8hi3 (op3, operands[1], op2));
11234       emit_insn (gen_addv8hi3 (op0, op3, op2));
11235       DONE;
11236     }
11237   else
11238     {
11239       rtx xops[6];
11240       bool ok;
11242       operands[1] = force_reg (<MODE>mode, operands[1]);
11243       operands[2] = force_reg (<MODE>mode, operands[2]);
11245       xops[0] = operands[0];
11247       if (<CODE> == UMAX)
11248         {
11249           xops[1] = operands[1];
11250           xops[2] = operands[2];
11251         }
11252       else
11253         {
11254           xops[1] = operands[2];
11255           xops[2] = operands[1];
11256         }
11258       xops[3] = gen_rtx_GTU (VOIDmode, operands[1], operands[2]);
11259       xops[4] = operands[1];
11260       xops[5] = operands[2];
11262       ok = ix86_expand_int_vcond (xops);
11263       gcc_assert (ok);
11264       DONE;
11265     }
11268 (define_insn "*sse4_1_<code><mode>3<mask_name>"
11269   [(set (match_operand:VI24_128 0 "register_operand" "=Yr,*x,v")
11270         (umaxmin:VI24_128
11271           (match_operand:VI24_128 1 "vector_operand" "%0,0,v")
11272           (match_operand:VI24_128 2 "vector_operand" "YrBm,*xBm,vm")))]
11273   "TARGET_SSE4_1
11274    && <mask_mode512bit_condition>
11275    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11276   "@
11277    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
11278    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
11279    vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11280   [(set_attr "isa" "noavx,noavx,avx")
11281    (set_attr "type" "sseiadd")
11282    (set_attr "prefix_extra" "1,1,*")
11283    (set_attr "prefix" "orig,orig,vex")
11284    (set_attr "mode" "TI")])
11286 (define_insn "*<code>v16qi3"
11287   [(set (match_operand:V16QI 0 "register_operand" "=x,x,v")
11288         (umaxmin:V16QI
11289           (match_operand:V16QI 1 "vector_operand" "%0,x,v")
11290           (match_operand:V16QI 2 "vector_operand" "xBm,xm,vm")))]
11291   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11292   "@
11293    p<maxmin_int>b\t{%2, %0|%0, %2}
11294    vp<maxmin_int>b\t{%2, %1, %0|%0, %1, %2}
11295    vp<maxmin_int>b\t{%2, %1, %0|%0, %1, %2}"
11296   [(set_attr "isa" "noavx,avx,avx512bw")
11297    (set_attr "type" "sseiadd")
11298    (set_attr "prefix_data16" "1,*,*")
11299    (set_attr "prefix_extra" "*,1,1")
11300    (set_attr "prefix" "orig,vex,evex")
11301    (set_attr "mode" "TI")])
11303 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11305 ;; Parallel integral comparisons
11307 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11309 (define_expand "avx2_eq<mode>3"
11310   [(set (match_operand:VI_256 0 "register_operand")
11311         (eq:VI_256
11312           (match_operand:VI_256 1 "nonimmediate_operand")
11313           (match_operand:VI_256 2 "nonimmediate_operand")))]
11314   "TARGET_AVX2"
11315   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
11317 (define_insn "*avx2_eq<mode>3"
11318   [(set (match_operand:VI_256 0 "register_operand" "=x")
11319         (eq:VI_256
11320           (match_operand:VI_256 1 "nonimmediate_operand" "%x")
11321           (match_operand:VI_256 2 "nonimmediate_operand" "xm")))]
11322   "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11323   "vpcmpeq<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11324   [(set_attr "type" "ssecmp")
11325    (set_attr "prefix_extra" "1")
11326    (set_attr "prefix" "vex")
11327    (set_attr "mode" "OI")])
11329 (define_expand "<avx512>_eq<mode>3<mask_scalar_merge_name>"
11330   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
11331         (unspec:<avx512fmaskmode>
11332           [(match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
11333            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand")]
11334           UNSPEC_MASKED_EQ))]
11335   "TARGET_AVX512BW"
11336   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
11338 (define_expand "<avx512>_eq<mode>3<mask_scalar_merge_name>"
11339   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
11340         (unspec:<avx512fmaskmode>
11341           [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
11342            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand")]
11343           UNSPEC_MASKED_EQ))]
11344   "TARGET_AVX512F"
11345   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
11347 (define_insn "<avx512>_eq<mode>3<mask_scalar_merge_name>_1"
11348   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11349         (unspec:<avx512fmaskmode>
11350           [(match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "%v")
11351            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")]
11352           UNSPEC_MASKED_EQ))]
11353   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11354   "vpcmpeq<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11355   [(set_attr "type" "ssecmp")
11356    (set_attr "prefix_extra" "1")
11357    (set_attr "prefix" "evex")
11358    (set_attr "mode" "<sseinsnmode>")])
11360 (define_insn "<avx512>_eq<mode>3<mask_scalar_merge_name>_1"
11361   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11362         (unspec:<avx512fmaskmode>
11363           [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "%v")
11364            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")]
11365           UNSPEC_MASKED_EQ))]
11366   "TARGET_AVX512F && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11367   "vpcmpeq<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11368   [(set_attr "type" "ssecmp")
11369    (set_attr "prefix_extra" "1")
11370    (set_attr "prefix" "evex")
11371    (set_attr "mode" "<sseinsnmode>")])
11373 (define_insn "*sse4_1_eqv2di3"
11374   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,x")
11375         (eq:V2DI
11376           (match_operand:V2DI 1 "vector_operand" "%0,0,x")
11377           (match_operand:V2DI 2 "vector_operand" "YrBm,*xBm,xm")))]
11378   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11379   "@
11380    pcmpeqq\t{%2, %0|%0, %2}
11381    pcmpeqq\t{%2, %0|%0, %2}
11382    vpcmpeqq\t{%2, %1, %0|%0, %1, %2}"
11383   [(set_attr "isa" "noavx,noavx,avx")
11384    (set_attr "type" "ssecmp")
11385    (set_attr "prefix_extra" "1")
11386    (set_attr "prefix" "orig,orig,vex")
11387    (set_attr "mode" "TI")])
11389 (define_insn "*sse2_eq<mode>3"
11390   [(set (match_operand:VI124_128 0 "register_operand" "=x,x")
11391         (eq:VI124_128
11392           (match_operand:VI124_128 1 "vector_operand" "%0,x")
11393           (match_operand:VI124_128 2 "vector_operand" "xBm,xm")))]
11394   "TARGET_SSE2 && !TARGET_XOP
11395    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11396   "@
11397    pcmpeq<ssemodesuffix>\t{%2, %0|%0, %2}
11398    vpcmpeq<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11399   [(set_attr "isa" "noavx,avx")
11400    (set_attr "type" "ssecmp")
11401    (set_attr "prefix_data16" "1,*")
11402    (set_attr "prefix" "orig,vex")
11403    (set_attr "mode" "TI")])
11405 (define_expand "sse2_eq<mode>3"
11406   [(set (match_operand:VI124_128 0 "register_operand")
11407         (eq:VI124_128
11408           (match_operand:VI124_128 1 "vector_operand")
11409           (match_operand:VI124_128 2 "vector_operand")))]
11410   "TARGET_SSE2 && !TARGET_XOP "
11411   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
11413 (define_expand "sse4_1_eqv2di3"
11414   [(set (match_operand:V2DI 0 "register_operand")
11415         (eq:V2DI
11416           (match_operand:V2DI 1 "vector_operand")
11417           (match_operand:V2DI 2 "vector_operand")))]
11418   "TARGET_SSE4_1"
11419   "ix86_fixup_binary_operands_no_copy (EQ, V2DImode, operands);")
11421 (define_insn "sse4_2_gtv2di3"
11422   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,x")
11423         (gt:V2DI
11424           (match_operand:V2DI 1 "register_operand" "0,0,x")
11425           (match_operand:V2DI 2 "vector_operand" "YrBm,*xBm,xm")))]
11426   "TARGET_SSE4_2"
11427   "@
11428    pcmpgtq\t{%2, %0|%0, %2}
11429    pcmpgtq\t{%2, %0|%0, %2}
11430    vpcmpgtq\t{%2, %1, %0|%0, %1, %2}"
11431   [(set_attr "isa" "noavx,noavx,avx")
11432    (set_attr "type" "ssecmp")
11433    (set_attr "prefix_extra" "1")
11434    (set_attr "prefix" "orig,orig,vex")
11435    (set_attr "mode" "TI")])
11437 (define_insn "avx2_gt<mode>3"
11438   [(set (match_operand:VI_256 0 "register_operand" "=x")
11439         (gt:VI_256
11440           (match_operand:VI_256 1 "register_operand" "x")
11441           (match_operand:VI_256 2 "nonimmediate_operand" "xm")))]
11442   "TARGET_AVX2"
11443   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11444   [(set_attr "type" "ssecmp")
11445    (set_attr "prefix_extra" "1")
11446    (set_attr "prefix" "vex")
11447    (set_attr "mode" "OI")])
11449 (define_insn "<avx512>_gt<mode>3<mask_scalar_merge_name>"
11450   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11451         (unspec:<avx512fmaskmode>
11452           [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
11453            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")] UNSPEC_MASKED_GT))]
11454   "TARGET_AVX512F"
11455   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11456   [(set_attr "type" "ssecmp")
11457    (set_attr "prefix_extra" "1")
11458    (set_attr "prefix" "evex")
11459    (set_attr "mode" "<sseinsnmode>")])
11461 (define_insn "<avx512>_gt<mode>3<mask_scalar_merge_name>"
11462   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11463         (unspec:<avx512fmaskmode>
11464           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
11465            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")] UNSPEC_MASKED_GT))]
11466   "TARGET_AVX512BW"
11467   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11468   [(set_attr "type" "ssecmp")
11469    (set_attr "prefix_extra" "1")
11470    (set_attr "prefix" "evex")
11471    (set_attr "mode" "<sseinsnmode>")])
11473 (define_insn "sse2_gt<mode>3"
11474   [(set (match_operand:VI124_128 0 "register_operand" "=x,x")
11475         (gt:VI124_128
11476           (match_operand:VI124_128 1 "register_operand" "0,x")
11477           (match_operand:VI124_128 2 "vector_operand" "xBm,xm")))]
11478   "TARGET_SSE2 && !TARGET_XOP"
11479   "@
11480    pcmpgt<ssemodesuffix>\t{%2, %0|%0, %2}
11481    vpcmpgt<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11482   [(set_attr "isa" "noavx,avx")
11483    (set_attr "type" "ssecmp")
11484    (set_attr "prefix_data16" "1,*")
11485    (set_attr "prefix" "orig,vex")
11486    (set_attr "mode" "TI")])
11488 (define_expand "vcond<V_512:mode><VI_AVX512BW:mode>"
11489   [(set (match_operand:V_512 0 "register_operand")
11490         (if_then_else:V_512
11491           (match_operator 3 ""
11492             [(match_operand:VI_AVX512BW 4 "nonimmediate_operand")
11493              (match_operand:VI_AVX512BW 5 "general_operand")])
11494           (match_operand:V_512 1)
11495           (match_operand:V_512 2)))]
11496   "TARGET_AVX512F
11497    && (GET_MODE_NUNITS (<V_512:MODE>mode)
11498        == GET_MODE_NUNITS (<VI_AVX512BW:MODE>mode))"
11500   bool ok = ix86_expand_int_vcond (operands);
11501   gcc_assert (ok);
11502   DONE;
11505 (define_expand "vcond<V_256:mode><VI_256:mode>"
11506   [(set (match_operand:V_256 0 "register_operand")
11507         (if_then_else:V_256
11508           (match_operator 3 ""
11509             [(match_operand:VI_256 4 "nonimmediate_operand")
11510              (match_operand:VI_256 5 "general_operand")])
11511           (match_operand:V_256 1)
11512           (match_operand:V_256 2)))]
11513   "TARGET_AVX2
11514    && (GET_MODE_NUNITS (<V_256:MODE>mode)
11515        == GET_MODE_NUNITS (<VI_256:MODE>mode))"
11517   bool ok = ix86_expand_int_vcond (operands);
11518   gcc_assert (ok);
11519   DONE;
11522 (define_expand "vcond<V_128:mode><VI124_128:mode>"
11523   [(set (match_operand:V_128 0 "register_operand")
11524         (if_then_else:V_128
11525           (match_operator 3 ""
11526             [(match_operand:VI124_128 4 "vector_operand")
11527              (match_operand:VI124_128 5 "general_operand")])
11528           (match_operand:V_128 1)
11529           (match_operand:V_128 2)))]
11530   "TARGET_SSE2
11531    && (GET_MODE_NUNITS (<V_128:MODE>mode)
11532        == GET_MODE_NUNITS (<VI124_128:MODE>mode))"
11534   bool ok = ix86_expand_int_vcond (operands);
11535   gcc_assert (ok);
11536   DONE;
11539 (define_expand "vcond<VI8F_128:mode>v2di"
11540   [(set (match_operand:VI8F_128 0 "register_operand")
11541         (if_then_else:VI8F_128
11542           (match_operator 3 ""
11543             [(match_operand:V2DI 4 "vector_operand")
11544              (match_operand:V2DI 5 "general_operand")])
11545           (match_operand:VI8F_128 1)
11546           (match_operand:VI8F_128 2)))]
11547   "TARGET_SSE4_2"
11549   bool ok = ix86_expand_int_vcond (operands);
11550   gcc_assert (ok);
11551   DONE;
11554 (define_expand "vcondu<V_512:mode><VI_AVX512BW:mode>"
11555   [(set (match_operand:V_512 0 "register_operand")
11556         (if_then_else:V_512
11557           (match_operator 3 ""
11558             [(match_operand:VI_AVX512BW 4 "nonimmediate_operand")
11559              (match_operand:VI_AVX512BW 5 "nonimmediate_operand")])
11560           (match_operand:V_512 1 "general_operand")
11561           (match_operand:V_512 2 "general_operand")))]
11562   "TARGET_AVX512F
11563    && (GET_MODE_NUNITS (<V_512:MODE>mode)
11564        == GET_MODE_NUNITS (<VI_AVX512BW:MODE>mode))"
11566   bool ok = ix86_expand_int_vcond (operands);
11567   gcc_assert (ok);
11568   DONE;
11571 (define_expand "vcondu<V_256:mode><VI_256:mode>"
11572   [(set (match_operand:V_256 0 "register_operand")
11573         (if_then_else:V_256
11574           (match_operator 3 ""
11575             [(match_operand:VI_256 4 "nonimmediate_operand")
11576              (match_operand:VI_256 5 "nonimmediate_operand")])
11577           (match_operand:V_256 1 "general_operand")
11578           (match_operand:V_256 2 "general_operand")))]
11579   "TARGET_AVX2
11580    && (GET_MODE_NUNITS (<V_256:MODE>mode)
11581        == GET_MODE_NUNITS (<VI_256:MODE>mode))"
11583   bool ok = ix86_expand_int_vcond (operands);
11584   gcc_assert (ok);
11585   DONE;
11588 (define_expand "vcondu<V_128:mode><VI124_128:mode>"
11589   [(set (match_operand:V_128 0 "register_operand")
11590         (if_then_else:V_128
11591           (match_operator 3 ""
11592             [(match_operand:VI124_128 4 "vector_operand")
11593              (match_operand:VI124_128 5 "vector_operand")])
11594           (match_operand:V_128 1 "general_operand")
11595           (match_operand:V_128 2 "general_operand")))]
11596   "TARGET_SSE2
11597    && (GET_MODE_NUNITS (<V_128:MODE>mode)
11598        == GET_MODE_NUNITS (<VI124_128:MODE>mode))"
11600   bool ok = ix86_expand_int_vcond (operands);
11601   gcc_assert (ok);
11602   DONE;
11605 (define_expand "vcondu<VI8F_128:mode>v2di"
11606   [(set (match_operand:VI8F_128 0 "register_operand")
11607         (if_then_else:VI8F_128
11608           (match_operator 3 ""
11609             [(match_operand:V2DI 4 "vector_operand")
11610              (match_operand:V2DI 5 "vector_operand")])
11611           (match_operand:VI8F_128 1 "general_operand")
11612           (match_operand:VI8F_128 2 "general_operand")))]
11613   "TARGET_SSE4_2"
11615   bool ok = ix86_expand_int_vcond (operands);
11616   gcc_assert (ok);
11617   DONE;
11620 (define_expand "vcondeq<VI8F_128:mode>v2di"
11621   [(set (match_operand:VI8F_128 0 "register_operand")
11622         (if_then_else:VI8F_128
11623           (match_operator 3 ""
11624             [(match_operand:V2DI 4 "vector_operand")
11625              (match_operand:V2DI 5 "general_operand")])
11626           (match_operand:VI8F_128 1)
11627           (match_operand:VI8F_128 2)))]
11628   "TARGET_SSE4_1"
11630   bool ok = ix86_expand_int_vcond (operands);
11631   gcc_assert (ok);
11632   DONE;
11635 (define_mode_iterator VEC_PERM_AVX2
11636   [V16QI V8HI V4SI V2DI V4SF V2DF
11637    (V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
11638    (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")
11639    (V8SF "TARGET_AVX2") (V4DF "TARGET_AVX2")
11640    (V16SF "TARGET_AVX512F") (V8DF "TARGET_AVX512F")
11641    (V16SI "TARGET_AVX512F") (V8DI "TARGET_AVX512F")
11642    (V32HI "TARGET_AVX512BW") (V64QI "TARGET_AVX512VBMI")])
11644 (define_expand "vec_perm<mode>"
11645   [(match_operand:VEC_PERM_AVX2 0 "register_operand")
11646    (match_operand:VEC_PERM_AVX2 1 "register_operand")
11647    (match_operand:VEC_PERM_AVX2 2 "register_operand")
11648    (match_operand:<sseintvecmode> 3 "register_operand")]
11649   "TARGET_SSSE3 || TARGET_AVX || TARGET_XOP"
11651   ix86_expand_vec_perm (operands);
11652   DONE;
11655 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11657 ;; Parallel bitwise logical operations
11659 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11661 (define_expand "one_cmpl<mode>2"
11662   [(set (match_operand:VI 0 "register_operand")
11663         (xor:VI (match_operand:VI 1 "vector_operand")
11664                 (match_dup 2)))]
11665   "TARGET_SSE"
11667   operands[2] = force_reg (<MODE>mode, CONSTM1_RTX (<MODE>mode));
11670 (define_expand "<sse2_avx2>_andnot<mode>3"
11671   [(set (match_operand:VI_AVX2 0 "register_operand")
11672         (and:VI_AVX2
11673           (not:VI_AVX2 (match_operand:VI_AVX2 1 "register_operand"))
11674           (match_operand:VI_AVX2 2 "vector_operand")))]
11675   "TARGET_SSE2")
11677 (define_expand "<sse2_avx2>_andnot<mode>3_mask"
11678   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
11679         (vec_merge:VI48_AVX512VL
11680           (and:VI48_AVX512VL
11681             (not:VI48_AVX512VL
11682               (match_operand:VI48_AVX512VL 1 "register_operand"))
11683             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
11684           (match_operand:VI48_AVX512VL 3 "vector_move_operand")
11685           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
11686   "TARGET_AVX512F")
11688 (define_expand "<sse2_avx2>_andnot<mode>3_mask"
11689   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
11690         (vec_merge:VI12_AVX512VL
11691           (and:VI12_AVX512VL
11692             (not:VI12_AVX512VL
11693               (match_operand:VI12_AVX512VL 1 "register_operand"))
11694             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand"))
11695           (match_operand:VI12_AVX512VL 3 "vector_move_operand")
11696           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
11697   "TARGET_AVX512BW")
11699 (define_insn "*andnot<mode>3"
11700   [(set (match_operand:VI 0 "register_operand" "=x,x,v")
11701         (and:VI
11702           (not:VI (match_operand:VI 1 "register_operand" "0,x,v"))
11703           (match_operand:VI 2 "vector_operand" "xBm,xm,vm")))]
11704   "TARGET_SSE"
11706   static char buf[64];
11707   const char *ops;
11708   const char *tmp;
11709   const char *ssesuffix;
11711   switch (get_attr_mode (insn))
11712     {
11713     case MODE_XI:
11714       gcc_assert (TARGET_AVX512F);
11715       /* FALLTHRU */
11716     case MODE_OI:
11717       gcc_assert (TARGET_AVX2);
11718       /* FALLTHRU */
11719     case MODE_TI:
11720       gcc_assert (TARGET_SSE2);
11721       tmp = "pandn";
11722       switch (<MODE>mode)
11723         {
11724         case E_V64QImode:
11725         case E_V32HImode:
11726           /* There is no vpandnb or vpandnw instruction, nor vpandn for
11727              512-bit vectors. Use vpandnq instead.  */
11728           ssesuffix = "q";
11729           break;
11730         case E_V16SImode:
11731         case E_V8DImode:
11732           ssesuffix = "<ssemodesuffix>";
11733           break;
11734         case E_V8SImode:
11735         case E_V4DImode:
11736         case E_V4SImode:
11737         case E_V2DImode:
11738           ssesuffix = (TARGET_AVX512VL && which_alternative == 2
11739                        ? "<ssemodesuffix>" : "");
11740           break;
11741         default:
11742           ssesuffix = TARGET_AVX512VL && which_alternative == 2 ? "q" : "";
11743         }
11744       break;
11746     case MODE_V16SF:
11747       gcc_assert (TARGET_AVX512F);
11748       /* FALLTHRU */
11749     case MODE_V8SF:
11750       gcc_assert (TARGET_AVX);
11751       /* FALLTHRU */
11752     case MODE_V4SF:
11753       gcc_assert (TARGET_SSE);
11754       tmp = "andn";
11755       ssesuffix = "ps";
11756       break;
11758     default:
11759       gcc_unreachable ();
11760     }
11762   switch (which_alternative)
11763     {
11764     case 0:
11765       ops = "%s%s\t{%%2, %%0|%%0, %%2}";
11766       break;
11767     case 1:
11768     case 2:
11769       ops = "v%s%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
11770       break;
11771     default:
11772       gcc_unreachable ();
11773     }
11775   snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
11776   return buf;
11778   [(set_attr "isa" "noavx,avx,avx")
11779    (set_attr "type" "sselog")
11780    (set (attr "prefix_data16")
11781      (if_then_else
11782        (and (eq_attr "alternative" "0")
11783             (eq_attr "mode" "TI"))
11784        (const_string "1")
11785        (const_string "*")))
11786    (set_attr "prefix" "orig,vex,evex")
11787    (set (attr "mode")
11788         (cond [(and (match_test "<MODE_SIZE> == 16")
11789                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
11790                  (const_string "<ssePSmode>")
11791                (match_test "TARGET_AVX2")
11792                  (const_string "<sseinsnmode>")
11793                (match_test "TARGET_AVX")
11794                  (if_then_else
11795                    (match_test "<MODE_SIZE> > 16")
11796                    (const_string "V8SF")
11797                    (const_string "<sseinsnmode>"))
11798                (ior (not (match_test "TARGET_SSE2"))
11799                     (match_test "optimize_function_for_size_p (cfun)"))
11800                  (const_string "V4SF")
11801               ]
11802               (const_string "<sseinsnmode>")))])
11804 (define_insn "*andnot<mode>3_mask"
11805   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
11806         (vec_merge:VI48_AVX512VL
11807           (and:VI48_AVX512VL
11808             (not:VI48_AVX512VL
11809               (match_operand:VI48_AVX512VL 1 "register_operand" "v"))
11810             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm"))
11811           (match_operand:VI48_AVX512VL 3 "vector_move_operand" "0C")
11812           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
11813   "TARGET_AVX512F"
11814   "vpandn<ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}";
11815   [(set_attr "type" "sselog")
11816    (set_attr "prefix" "evex")
11817    (set_attr "mode" "<sseinsnmode>")])
11819 (define_expand "<code><mode>3"
11820   [(set (match_operand:VI 0 "register_operand")
11821         (any_logic:VI
11822           (match_operand:VI 1 "nonimmediate_or_const_vector_operand")
11823           (match_operand:VI 2 "nonimmediate_or_const_vector_operand")))]
11824   "TARGET_SSE"
11826   ix86_expand_vector_logical_operator (<CODE>, <MODE>mode, operands);
11827   DONE;
11830 (define_insn "<mask_codefor><code><mode>3<mask_name>"
11831   [(set (match_operand:VI48_AVX_AVX512F 0 "register_operand" "=x,x,v")
11832         (any_logic:VI48_AVX_AVX512F
11833           (match_operand:VI48_AVX_AVX512F 1 "vector_operand" "%0,x,v")
11834           (match_operand:VI48_AVX_AVX512F 2 "vector_operand" "xBm,xm,vm")))]
11835   "TARGET_SSE && <mask_mode512bit_condition>
11836    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11838   static char buf[64];
11839   const char *ops;
11840   const char *tmp;
11841   const char *ssesuffix;
11843   switch (get_attr_mode (insn))
11844     {
11845     case MODE_XI:
11846       gcc_assert (TARGET_AVX512F);
11847       /* FALLTHRU */
11848     case MODE_OI:
11849       gcc_assert (TARGET_AVX2);
11850       /* FALLTHRU */
11851     case MODE_TI:
11852       gcc_assert (TARGET_SSE2);
11853       tmp = "p<logic>";
11854       switch (<MODE>mode)
11855         {
11856         case E_V16SImode:
11857         case E_V8DImode:
11858           ssesuffix = "<ssemodesuffix>";
11859           break;
11860         case E_V8SImode:
11861         case E_V4DImode:
11862         case E_V4SImode:
11863         case E_V2DImode:
11864           ssesuffix = (TARGET_AVX512VL
11865                        && (<mask_applied> || which_alternative == 2)
11866                        ? "<ssemodesuffix>" : "");
11867           break;
11868         default:
11869           gcc_unreachable ();
11870         }
11871       break;
11873     case MODE_V8SF:
11874       gcc_assert (TARGET_AVX);
11875       /* FALLTHRU */
11876     case MODE_V4SF:
11877       gcc_assert (TARGET_SSE);
11878       tmp = "<logic>";
11879       ssesuffix = "ps";
11880       break;
11882     default:
11883       gcc_unreachable ();
11884     }
11886   switch (which_alternative)
11887     {
11888     case 0:
11889       if (<mask_applied>)
11890         ops = "v%s%s\t{%%2, %%0, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%0, %%2}";
11891       else
11892         ops = "%s%s\t{%%2, %%0|%%0, %%2}";
11893       break;
11894     case 1:
11895     case 2:
11896       ops = "v%s%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
11897       break;
11898     default:
11899       gcc_unreachable ();
11900     }
11902   snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
11903   return buf;
11905   [(set_attr "isa" "noavx,avx,avx")
11906    (set_attr "type" "sselog")
11907    (set (attr "prefix_data16")
11908      (if_then_else
11909        (and (eq_attr "alternative" "0")
11910             (eq_attr "mode" "TI"))
11911        (const_string "1")
11912        (const_string "*")))
11913    (set_attr "prefix" "<mask_prefix3>,evex")
11914    (set (attr "mode")
11915         (cond [(and (match_test "<MODE_SIZE> == 16")
11916                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
11917                  (const_string "<ssePSmode>")
11918                (match_test "TARGET_AVX2")
11919                  (const_string "<sseinsnmode>")
11920                (match_test "TARGET_AVX")
11921                  (if_then_else
11922                    (match_test "<MODE_SIZE> > 16")
11923                    (const_string "V8SF")
11924                    (const_string "<sseinsnmode>"))
11925                (ior (not (match_test "TARGET_SSE2"))
11926                     (match_test "optimize_function_for_size_p (cfun)"))
11927                  (const_string "V4SF")
11928               ]
11929               (const_string "<sseinsnmode>")))])
11931 (define_insn "*<code><mode>3"
11932   [(set (match_operand:VI12_AVX_AVX512F 0 "register_operand" "=x,x,v")
11933         (any_logic:VI12_AVX_AVX512F
11934           (match_operand:VI12_AVX_AVX512F 1 "vector_operand" "%0,x,v")
11935           (match_operand:VI12_AVX_AVX512F 2 "vector_operand" "xBm,xm,vm")))]
11936   "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
11938   static char buf[64];
11939   const char *ops;
11940   const char *tmp;
11941   const char *ssesuffix;
11943   switch (get_attr_mode (insn))
11944     {
11945     case MODE_XI:
11946       gcc_assert (TARGET_AVX512F);
11947       /* FALLTHRU */
11948     case MODE_OI:
11949       gcc_assert (TARGET_AVX2);
11950       /* FALLTHRU */
11951     case MODE_TI:
11952       gcc_assert (TARGET_SSE2);
11953       tmp = "p<logic>";
11954       switch (<MODE>mode)
11955         {
11956         case E_V64QImode:
11957         case E_V32HImode:
11958           ssesuffix = "q";
11959           break;
11960         case E_V32QImode:
11961         case E_V16HImode:
11962         case E_V16QImode:
11963         case E_V8HImode:
11964           ssesuffix = TARGET_AVX512VL && which_alternative == 2 ? "q" : "";
11965           break;
11966         default:
11967           gcc_unreachable ();
11968         }
11969       break;
11971     case MODE_V8SF:
11972       gcc_assert (TARGET_AVX);
11973       /* FALLTHRU */
11974     case MODE_V4SF:
11975       gcc_assert (TARGET_SSE);
11976       tmp = "<logic>";
11977       ssesuffix = "ps";
11978       break;
11980     default:
11981       gcc_unreachable ();
11982     }
11984   switch (which_alternative)
11985     {
11986     case 0:
11987       ops = "%s%s\t{%%2, %%0|%%0, %%2}";
11988       break;
11989     case 1:
11990     case 2:
11991       ops = "v%s%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
11992       break;
11993     default:
11994       gcc_unreachable ();
11995     }
11997   snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
11998   return buf;
12000   [(set_attr "isa" "noavx,avx,avx")
12001    (set_attr "type" "sselog")
12002    (set (attr "prefix_data16")
12003      (if_then_else
12004        (and (eq_attr "alternative" "0")
12005             (eq_attr "mode" "TI"))
12006        (const_string "1")
12007        (const_string "*")))
12008    (set_attr "prefix" "orig,vex,evex")
12009    (set (attr "mode")
12010         (cond [(and (match_test "<MODE_SIZE> == 16")
12011                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
12012                  (const_string "<ssePSmode>")
12013                (match_test "TARGET_AVX2")
12014                  (const_string "<sseinsnmode>")
12015                (match_test "TARGET_AVX")
12016                  (if_then_else
12017                    (match_test "<MODE_SIZE> > 16")
12018                    (const_string "V8SF")
12019                    (const_string "<sseinsnmode>"))
12020                (ior (not (match_test "TARGET_SSE2"))
12021                     (match_test "optimize_function_for_size_p (cfun)"))
12022                  (const_string "V4SF")
12023               ]
12024               (const_string "<sseinsnmode>")))])
12026 (define_insn "<avx512>_testm<mode>3<mask_scalar_merge_name>"
12027   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
12028         (unspec:<avx512fmaskmode>
12029          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
12030           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")]
12031          UNSPEC_TESTM))]
12032   "TARGET_AVX512BW"
12033   "vptestm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
12034   [(set_attr "prefix" "evex")
12035    (set_attr "mode"  "<sseinsnmode>")])
12037 (define_insn "<avx512>_testm<mode>3<mask_scalar_merge_name>"
12038   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
12039         (unspec:<avx512fmaskmode>
12040          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
12041           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")]
12042          UNSPEC_TESTM))]
12043   "TARGET_AVX512F"
12044   "vptestm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
12045   [(set_attr "prefix" "evex")
12046    (set_attr "mode"  "<sseinsnmode>")])
12048 (define_insn "<avx512>_testnm<mode>3<mask_scalar_merge_name>"
12049   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
12050         (unspec:<avx512fmaskmode>
12051          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
12052           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")]
12053          UNSPEC_TESTNM))]
12054   "TARGET_AVX512BW"
12055   "vptestnm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
12056   [(set_attr "prefix" "evex")
12057    (set_attr "mode"  "<sseinsnmode>")])
12059 (define_insn "<avx512>_testnm<mode>3<mask_scalar_merge_name>"
12060   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
12061         (unspec:<avx512fmaskmode>
12062          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
12063           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")]
12064          UNSPEC_TESTNM))]
12065   "TARGET_AVX512F"
12066   "vptestnm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
12067   [(set_attr "prefix" "evex")
12068    (set_attr "mode"  "<sseinsnmode>")])
12070 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12072 ;; Parallel integral element swizzling
12074 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12076 (define_expand "vec_pack_trunc_<mode>"
12077   [(match_operand:<ssepackmode> 0 "register_operand")
12078    (match_operand:VI248_AVX2_8_AVX512F_24_AVX512BW 1 "register_operand")
12079    (match_operand:VI248_AVX2_8_AVX512F_24_AVX512BW 2 "register_operand")]
12080   "TARGET_SSE2"
12082   rtx op1 = gen_lowpart (<ssepackmode>mode, operands[1]);
12083   rtx op2 = gen_lowpart (<ssepackmode>mode, operands[2]);
12084   ix86_expand_vec_extract_even_odd (operands[0], op1, op2, 0);
12085   DONE;
12088 (define_expand "vec_pack_trunc_qi"
12089   [(set (match_operand:HI 0 ("register_operand"))
12090         (ior:HI (ashift:HI (zero_extend:HI (match_operand:QI 2 ("register_operand")))
12091                            (const_int 8))
12092                 (zero_extend:HI (match_operand:QI 1 ("register_operand")))))]
12093   "TARGET_AVX512F")
12095 (define_expand "vec_pack_trunc_<mode>"
12096   [(set (match_operand:<DOUBLEMASKMODE> 0 ("register_operand"))
12097         (ior:<DOUBLEMASKMODE> (ashift:<DOUBLEMASKMODE> (zero_extend:<DOUBLEMASKMODE> (match_operand:SWI24 2 ("register_operand")))
12098                            (match_dup 3))
12099                 (zero_extend:<DOUBLEMASKMODE> (match_operand:SWI24 1 ("register_operand")))))]
12100   "TARGET_AVX512BW"
12102   operands[3] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
12105 (define_insn "<sse2_avx2>_packsswb<mask_name>"
12106   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x,v")
12107         (vec_concat:VI1_AVX512
12108           (ss_truncate:<ssehalfvecmode>
12109             (match_operand:<sseunpackmode> 1 "register_operand" "0,x,v"))
12110           (ss_truncate:<ssehalfvecmode>
12111             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,xm,vm"))))]
12112   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
12113   "@
12114    packsswb\t{%2, %0|%0, %2}
12115    vpacksswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
12116    vpacksswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12117   [(set_attr "isa" "noavx,avx,avx512bw")
12118    (set_attr "type" "sselog")
12119    (set_attr "prefix_data16" "1,*,*")
12120    (set_attr "prefix" "orig,<mask_prefix>,evex")
12121    (set_attr "mode" "<sseinsnmode>")])
12123 (define_insn "<sse2_avx2>_packssdw<mask_name>"
12124   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,x,v")
12125         (vec_concat:VI2_AVX2
12126           (ss_truncate:<ssehalfvecmode>
12127             (match_operand:<sseunpackmode> 1 "register_operand" "0,x,v"))
12128           (ss_truncate:<ssehalfvecmode>
12129             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,xm,vm"))))]
12130   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
12131   "@
12132    packssdw\t{%2, %0|%0, %2}
12133    vpackssdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
12134    vpackssdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12135   [(set_attr "isa" "noavx,avx,avx512bw")
12136    (set_attr "type" "sselog")
12137    (set_attr "prefix_data16" "1,*,*")
12138    (set_attr "prefix" "orig,<mask_prefix>,evex")
12139    (set_attr "mode" "<sseinsnmode>")])
12141 (define_insn "<sse2_avx2>_packuswb<mask_name>"
12142   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x,v")
12143         (vec_concat:VI1_AVX512
12144           (us_truncate:<ssehalfvecmode>
12145             (match_operand:<sseunpackmode> 1 "register_operand" "0,x,v"))
12146           (us_truncate:<ssehalfvecmode>
12147             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,xm,vm"))))]
12148   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
12149   "@
12150    packuswb\t{%2, %0|%0, %2}
12151    vpackuswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
12152    vpackuswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12153   [(set_attr "isa" "noavx,avx,avx512bw")
12154    (set_attr "type" "sselog")
12155    (set_attr "prefix_data16" "1,*,*")
12156    (set_attr "prefix" "orig,<mask_prefix>,evex")
12157    (set_attr "mode" "<sseinsnmode>")])
12159 (define_insn "avx512bw_interleave_highv64qi<mask_name>"
12160   [(set (match_operand:V64QI 0 "register_operand" "=v")
12161         (vec_select:V64QI
12162           (vec_concat:V128QI
12163             (match_operand:V64QI 1 "register_operand" "v")
12164             (match_operand:V64QI 2 "nonimmediate_operand" "vm"))
12165           (parallel [(const_int 8)  (const_int 72)
12166                      (const_int 9)  (const_int 73)
12167                      (const_int 10) (const_int 74)
12168                      (const_int 11) (const_int 75)
12169                      (const_int 12) (const_int 76)
12170                      (const_int 13) (const_int 77)
12171                      (const_int 14) (const_int 78)
12172                      (const_int 15) (const_int 79)
12173                      (const_int 24) (const_int 88)
12174                      (const_int 25) (const_int 89)
12175                      (const_int 26) (const_int 90)
12176                      (const_int 27) (const_int 91)
12177                      (const_int 28) (const_int 92)
12178                      (const_int 29) (const_int 93)
12179                      (const_int 30) (const_int 94)
12180                      (const_int 31) (const_int 95)
12181                      (const_int 40) (const_int 104)
12182                      (const_int 41) (const_int 105)
12183                      (const_int 42) (const_int 106)
12184                      (const_int 43) (const_int 107)
12185                      (const_int 44) (const_int 108)
12186                      (const_int 45) (const_int 109)
12187                      (const_int 46) (const_int 110)
12188                      (const_int 47) (const_int 111)
12189                      (const_int 56) (const_int 120)
12190                      (const_int 57) (const_int 121)
12191                      (const_int 58) (const_int 122)
12192                      (const_int 59) (const_int 123)
12193                      (const_int 60) (const_int 124)
12194                      (const_int 61) (const_int 125)
12195                      (const_int 62) (const_int 126)
12196                      (const_int 63) (const_int 127)])))]
12197   "TARGET_AVX512BW"
12198   "vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12199   [(set_attr "type" "sselog")
12200    (set_attr "prefix" "evex")
12201    (set_attr "mode" "XI")])
12203 (define_insn "avx2_interleave_highv32qi<mask_name>"
12204   [(set (match_operand:V32QI 0 "register_operand" "=v")
12205         (vec_select:V32QI
12206           (vec_concat:V64QI
12207             (match_operand:V32QI 1 "register_operand" "v")
12208             (match_operand:V32QI 2 "nonimmediate_operand" "vm"))
12209           (parallel [(const_int 8)  (const_int 40)
12210                      (const_int 9)  (const_int 41)
12211                      (const_int 10) (const_int 42)
12212                      (const_int 11) (const_int 43)
12213                      (const_int 12) (const_int 44)
12214                      (const_int 13) (const_int 45)
12215                      (const_int 14) (const_int 46)
12216                      (const_int 15) (const_int 47)
12217                      (const_int 24) (const_int 56)
12218                      (const_int 25) (const_int 57)
12219                      (const_int 26) (const_int 58)
12220                      (const_int 27) (const_int 59)
12221                      (const_int 28) (const_int 60)
12222                      (const_int 29) (const_int 61)
12223                      (const_int 30) (const_int 62)
12224                      (const_int 31) (const_int 63)])))]
12225   "TARGET_AVX2 && <mask_avx512vl_condition>"
12226   "vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12227   [(set_attr "type" "sselog")
12228    (set_attr "prefix" "<mask_prefix>")
12229    (set_attr "mode" "OI")])
12231 (define_insn "vec_interleave_highv16qi<mask_name>"
12232   [(set (match_operand:V16QI 0 "register_operand" "=x,v")
12233         (vec_select:V16QI
12234           (vec_concat:V32QI
12235             (match_operand:V16QI 1 "register_operand" "0,v")
12236             (match_operand:V16QI 2 "vector_operand" "xBm,vm"))
12237           (parallel [(const_int 8)  (const_int 24)
12238                      (const_int 9)  (const_int 25)
12239                      (const_int 10) (const_int 26)
12240                      (const_int 11) (const_int 27)
12241                      (const_int 12) (const_int 28)
12242                      (const_int 13) (const_int 29)
12243                      (const_int 14) (const_int 30)
12244                      (const_int 15) (const_int 31)])))]
12245   "TARGET_SSE2 && <mask_avx512vl_condition>"
12246   "@
12247    punpckhbw\t{%2, %0|%0, %2}
12248    vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12249   [(set_attr "isa" "noavx,avx")
12250    (set_attr "type" "sselog")
12251    (set_attr "prefix_data16" "1,*")
12252    (set_attr "prefix" "orig,<mask_prefix>")
12253    (set_attr "mode" "TI")])
12255 (define_insn "avx512bw_interleave_lowv64qi<mask_name>"
12256   [(set (match_operand:V64QI 0 "register_operand" "=v")
12257         (vec_select:V64QI
12258           (vec_concat:V128QI
12259             (match_operand:V64QI 1 "register_operand" "v")
12260             (match_operand:V64QI 2 "nonimmediate_operand" "vm"))
12261           (parallel [(const_int 0) (const_int 64)
12262                      (const_int 1) (const_int 65)
12263                      (const_int 2) (const_int 66)
12264                      (const_int 3) (const_int 67)
12265                      (const_int 4) (const_int 68)
12266                      (const_int 5) (const_int 69)
12267                      (const_int 6) (const_int 70)
12268                      (const_int 7) (const_int 71)
12269                      (const_int 16) (const_int 80)
12270                      (const_int 17) (const_int 81)
12271                      (const_int 18) (const_int 82)
12272                      (const_int 19) (const_int 83)
12273                      (const_int 20) (const_int 84)
12274                      (const_int 21) (const_int 85)
12275                      (const_int 22) (const_int 86)
12276                      (const_int 23) (const_int 87)
12277                      (const_int 32) (const_int 96)
12278                      (const_int 33) (const_int 97)
12279                      (const_int 34) (const_int 98)
12280                      (const_int 35) (const_int 99)
12281                      (const_int 36) (const_int 100)
12282                      (const_int 37) (const_int 101)
12283                      (const_int 38) (const_int 102)
12284                      (const_int 39) (const_int 103)
12285                      (const_int 48) (const_int 112)
12286                      (const_int 49) (const_int 113)
12287                      (const_int 50) (const_int 114)
12288                      (const_int 51) (const_int 115)
12289                      (const_int 52) (const_int 116)
12290                      (const_int 53) (const_int 117)
12291                      (const_int 54) (const_int 118)
12292                      (const_int 55) (const_int 119)])))]
12293   "TARGET_AVX512BW"
12294   "vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12295   [(set_attr "type" "sselog")
12296    (set_attr "prefix" "evex")
12297    (set_attr "mode" "XI")])
12299 (define_insn "avx2_interleave_lowv32qi<mask_name>"
12300   [(set (match_operand:V32QI 0 "register_operand" "=v")
12301         (vec_select:V32QI
12302           (vec_concat:V64QI
12303             (match_operand:V32QI 1 "register_operand" "v")
12304             (match_operand:V32QI 2 "nonimmediate_operand" "vm"))
12305           (parallel [(const_int 0) (const_int 32)
12306                      (const_int 1) (const_int 33)
12307                      (const_int 2) (const_int 34)
12308                      (const_int 3) (const_int 35)
12309                      (const_int 4) (const_int 36)
12310                      (const_int 5) (const_int 37)
12311                      (const_int 6) (const_int 38)
12312                      (const_int 7) (const_int 39)
12313                      (const_int 16) (const_int 48)
12314                      (const_int 17) (const_int 49)
12315                      (const_int 18) (const_int 50)
12316                      (const_int 19) (const_int 51)
12317                      (const_int 20) (const_int 52)
12318                      (const_int 21) (const_int 53)
12319                      (const_int 22) (const_int 54)
12320                      (const_int 23) (const_int 55)])))]
12321   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12322   "vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12323   [(set_attr "type" "sselog")
12324    (set_attr "prefix" "maybe_vex")
12325    (set_attr "mode" "OI")])
12327 (define_insn "vec_interleave_lowv16qi<mask_name>"
12328   [(set (match_operand:V16QI 0 "register_operand" "=x,v")
12329         (vec_select:V16QI
12330           (vec_concat:V32QI
12331             (match_operand:V16QI 1 "register_operand" "0,v")
12332             (match_operand:V16QI 2 "vector_operand" "xBm,vm"))
12333           (parallel [(const_int 0) (const_int 16)
12334                      (const_int 1) (const_int 17)
12335                      (const_int 2) (const_int 18)
12336                      (const_int 3) (const_int 19)
12337                      (const_int 4) (const_int 20)
12338                      (const_int 5) (const_int 21)
12339                      (const_int 6) (const_int 22)
12340                      (const_int 7) (const_int 23)])))]
12341   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12342   "@
12343    punpcklbw\t{%2, %0|%0, %2}
12344    vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12345   [(set_attr "isa" "noavx,avx")
12346    (set_attr "type" "sselog")
12347    (set_attr "prefix_data16" "1,*")
12348    (set_attr "prefix" "orig,vex")
12349    (set_attr "mode" "TI")])
12351 (define_insn "avx512bw_interleave_highv32hi<mask_name>"
12352   [(set (match_operand:V32HI 0 "register_operand" "=v")
12353         (vec_select:V32HI
12354           (vec_concat:V64HI
12355             (match_operand:V32HI 1 "register_operand" "v")
12356             (match_operand:V32HI 2 "nonimmediate_operand" "vm"))
12357           (parallel [(const_int 4) (const_int 36)
12358                      (const_int 5) (const_int 37)
12359                      (const_int 6) (const_int 38)
12360                      (const_int 7) (const_int 39)
12361                      (const_int 12) (const_int 44)
12362                      (const_int 13) (const_int 45)
12363                      (const_int 14) (const_int 46)
12364                      (const_int 15) (const_int 47)
12365                      (const_int 20) (const_int 52)
12366                      (const_int 21) (const_int 53)
12367                      (const_int 22) (const_int 54)
12368                      (const_int 23) (const_int 55)
12369                      (const_int 28) (const_int 60)
12370                      (const_int 29) (const_int 61)
12371                      (const_int 30) (const_int 62)
12372                      (const_int 31) (const_int 63)])))]
12373   "TARGET_AVX512BW"
12374   "vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12375   [(set_attr "type" "sselog")
12376    (set_attr "prefix" "evex")
12377    (set_attr "mode" "XI")])
12379 (define_insn "avx2_interleave_highv16hi<mask_name>"
12380   [(set (match_operand:V16HI 0 "register_operand" "=v")
12381         (vec_select:V16HI
12382           (vec_concat:V32HI
12383             (match_operand:V16HI 1 "register_operand" "v")
12384             (match_operand:V16HI 2 "nonimmediate_operand" "vm"))
12385           (parallel [(const_int 4) (const_int 20)
12386                      (const_int 5) (const_int 21)
12387                      (const_int 6) (const_int 22)
12388                      (const_int 7) (const_int 23)
12389                      (const_int 12) (const_int 28)
12390                      (const_int 13) (const_int 29)
12391                      (const_int 14) (const_int 30)
12392                      (const_int 15) (const_int 31)])))]
12393   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12394   "vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12395   [(set_attr "type" "sselog")
12396    (set_attr "prefix" "maybe_evex")
12397    (set_attr "mode" "OI")])
12399 (define_insn "vec_interleave_highv8hi<mask_name>"
12400   [(set (match_operand:V8HI 0 "register_operand" "=x,v")
12401         (vec_select:V8HI
12402           (vec_concat:V16HI
12403             (match_operand:V8HI 1 "register_operand" "0,v")
12404             (match_operand:V8HI 2 "vector_operand" "xBm,vm"))
12405           (parallel [(const_int 4) (const_int 12)
12406                      (const_int 5) (const_int 13)
12407                      (const_int 6) (const_int 14)
12408                      (const_int 7) (const_int 15)])))]
12409   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12410   "@
12411    punpckhwd\t{%2, %0|%0, %2}
12412    vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12413   [(set_attr "isa" "noavx,avx")
12414    (set_attr "type" "sselog")
12415    (set_attr "prefix_data16" "1,*")
12416    (set_attr "prefix" "orig,maybe_vex")
12417    (set_attr "mode" "TI")])
12419 (define_insn "<mask_codefor>avx512bw_interleave_lowv32hi<mask_name>"
12420   [(set (match_operand:V32HI 0 "register_operand" "=v")
12421         (vec_select:V32HI
12422           (vec_concat:V64HI
12423             (match_operand:V32HI 1 "register_operand" "v")
12424             (match_operand:V32HI 2 "nonimmediate_operand" "vm"))
12425           (parallel [(const_int 0) (const_int 32)
12426                      (const_int 1) (const_int 33)
12427                      (const_int 2) (const_int 34)
12428                      (const_int 3) (const_int 35)
12429                      (const_int 8) (const_int 40)
12430                      (const_int 9) (const_int 41)
12431                      (const_int 10) (const_int 42)
12432                      (const_int 11) (const_int 43)
12433                      (const_int 16) (const_int 48)
12434                      (const_int 17) (const_int 49)
12435                      (const_int 18) (const_int 50)
12436                      (const_int 19) (const_int 51)
12437                      (const_int 24) (const_int 56)
12438                      (const_int 25) (const_int 57)
12439                      (const_int 26) (const_int 58)
12440                      (const_int 27) (const_int 59)])))]
12441   "TARGET_AVX512BW"
12442   "vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12443   [(set_attr "type" "sselog")
12444    (set_attr "prefix" "evex")
12445    (set_attr "mode" "XI")])
12447 (define_insn "avx2_interleave_lowv16hi<mask_name>"
12448   [(set (match_operand:V16HI 0 "register_operand" "=v")
12449         (vec_select:V16HI
12450           (vec_concat:V32HI
12451             (match_operand:V16HI 1 "register_operand" "v")
12452             (match_operand:V16HI 2 "nonimmediate_operand" "vm"))
12453           (parallel [(const_int 0) (const_int 16)
12454                      (const_int 1) (const_int 17)
12455                      (const_int 2) (const_int 18)
12456                      (const_int 3) (const_int 19)
12457                      (const_int 8) (const_int 24)
12458                      (const_int 9) (const_int 25)
12459                      (const_int 10) (const_int 26)
12460                      (const_int 11) (const_int 27)])))]
12461   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12462   "vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12463   [(set_attr "type" "sselog")
12464    (set_attr "prefix" "maybe_evex")
12465    (set_attr "mode" "OI")])
12467 (define_insn "vec_interleave_lowv8hi<mask_name>"
12468   [(set (match_operand:V8HI 0 "register_operand" "=x,v")
12469         (vec_select:V8HI
12470           (vec_concat:V16HI
12471             (match_operand:V8HI 1 "register_operand" "0,v")
12472             (match_operand:V8HI 2 "vector_operand" "xBm,vm"))
12473           (parallel [(const_int 0) (const_int 8)
12474                      (const_int 1) (const_int 9)
12475                      (const_int 2) (const_int 10)
12476                      (const_int 3) (const_int 11)])))]
12477   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12478   "@
12479    punpcklwd\t{%2, %0|%0, %2}
12480    vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12481   [(set_attr "isa" "noavx,avx")
12482    (set_attr "type" "sselog")
12483    (set_attr "prefix_data16" "1,*")
12484    (set_attr "prefix" "orig,maybe_evex")
12485    (set_attr "mode" "TI")])
12487 (define_insn "avx2_interleave_highv8si<mask_name>"
12488   [(set (match_operand:V8SI 0 "register_operand" "=v")
12489         (vec_select:V8SI
12490           (vec_concat:V16SI
12491             (match_operand:V8SI 1 "register_operand" "v")
12492             (match_operand:V8SI 2 "nonimmediate_operand" "vm"))
12493           (parallel [(const_int 2) (const_int 10)
12494                      (const_int 3) (const_int 11)
12495                      (const_int 6) (const_int 14)
12496                      (const_int 7) (const_int 15)])))]
12497   "TARGET_AVX2 && <mask_avx512vl_condition>"
12498   "vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12499   [(set_attr "type" "sselog")
12500    (set_attr "prefix" "maybe_evex")
12501    (set_attr "mode" "OI")])
12503 (define_insn "<mask_codefor>avx512f_interleave_highv16si<mask_name>"
12504   [(set (match_operand:V16SI 0 "register_operand" "=v")
12505         (vec_select:V16SI
12506           (vec_concat:V32SI
12507             (match_operand:V16SI 1 "register_operand" "v")
12508             (match_operand:V16SI 2 "nonimmediate_operand" "vm"))
12509           (parallel [(const_int 2) (const_int 18)
12510                      (const_int 3) (const_int 19)
12511                      (const_int 6) (const_int 22)
12512                      (const_int 7) (const_int 23)
12513                      (const_int 10) (const_int 26)
12514                      (const_int 11) (const_int 27)
12515                      (const_int 14) (const_int 30)
12516                      (const_int 15) (const_int 31)])))]
12517   "TARGET_AVX512F"
12518   "vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12519   [(set_attr "type" "sselog")
12520    (set_attr "prefix" "evex")
12521    (set_attr "mode" "XI")])
12524 (define_insn "vec_interleave_highv4si<mask_name>"
12525   [(set (match_operand:V4SI 0 "register_operand" "=x,v")
12526         (vec_select:V4SI
12527           (vec_concat:V8SI
12528             (match_operand:V4SI 1 "register_operand" "0,v")
12529             (match_operand:V4SI 2 "vector_operand" "xBm,vm"))
12530           (parallel [(const_int 2) (const_int 6)
12531                      (const_int 3) (const_int 7)])))]
12532   "TARGET_SSE2 && <mask_avx512vl_condition>"
12533   "@
12534    punpckhdq\t{%2, %0|%0, %2}
12535    vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12536   [(set_attr "isa" "noavx,avx")
12537    (set_attr "type" "sselog")
12538    (set_attr "prefix_data16" "1,*")
12539    (set_attr "prefix" "orig,maybe_vex")
12540    (set_attr "mode" "TI")])
12542 (define_insn "avx2_interleave_lowv8si<mask_name>"
12543   [(set (match_operand:V8SI 0 "register_operand" "=v")
12544         (vec_select:V8SI
12545           (vec_concat:V16SI
12546             (match_operand:V8SI 1 "register_operand" "v")
12547             (match_operand:V8SI 2 "nonimmediate_operand" "vm"))
12548           (parallel [(const_int 0) (const_int 8)
12549                      (const_int 1) (const_int 9)
12550                      (const_int 4) (const_int 12)
12551                      (const_int 5) (const_int 13)])))]
12552   "TARGET_AVX2 && <mask_avx512vl_condition>"
12553   "vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12554   [(set_attr "type" "sselog")
12555    (set_attr "prefix" "maybe_evex")
12556    (set_attr "mode" "OI")])
12558 (define_insn "<mask_codefor>avx512f_interleave_lowv16si<mask_name>"
12559   [(set (match_operand:V16SI 0 "register_operand" "=v")
12560         (vec_select:V16SI
12561           (vec_concat:V32SI
12562             (match_operand:V16SI 1 "register_operand" "v")
12563             (match_operand:V16SI 2 "nonimmediate_operand" "vm"))
12564           (parallel [(const_int 0) (const_int 16)
12565                      (const_int 1) (const_int 17)
12566                      (const_int 4) (const_int 20)
12567                      (const_int 5) (const_int 21)
12568                      (const_int 8) (const_int 24)
12569                      (const_int 9) (const_int 25)
12570                      (const_int 12) (const_int 28)
12571                      (const_int 13) (const_int 29)])))]
12572   "TARGET_AVX512F"
12573   "vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12574   [(set_attr "type" "sselog")
12575    (set_attr "prefix" "evex")
12576    (set_attr "mode" "XI")])
12578 (define_insn "vec_interleave_lowv4si<mask_name>"
12579   [(set (match_operand:V4SI 0 "register_operand" "=x,v")
12580         (vec_select:V4SI
12581           (vec_concat:V8SI
12582             (match_operand:V4SI 1 "register_operand" "0,v")
12583             (match_operand:V4SI 2 "vector_operand" "xBm,vm"))
12584           (parallel [(const_int 0) (const_int 4)
12585                      (const_int 1) (const_int 5)])))]
12586   "TARGET_SSE2 && <mask_avx512vl_condition>"
12587   "@
12588    punpckldq\t{%2, %0|%0, %2}
12589    vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12590   [(set_attr "isa" "noavx,avx")
12591    (set_attr "type" "sselog")
12592    (set_attr "prefix_data16" "1,*")
12593    (set_attr "prefix" "orig,vex")
12594    (set_attr "mode" "TI")])
12596 (define_expand "vec_interleave_high<mode>"
12597   [(match_operand:VI_256 0 "register_operand")
12598    (match_operand:VI_256 1 "register_operand")
12599    (match_operand:VI_256 2 "nonimmediate_operand")]
12600  "TARGET_AVX2"
12602   rtx t1 = gen_reg_rtx (<MODE>mode);
12603   rtx t2 = gen_reg_rtx (<MODE>mode);
12604   rtx t3 = gen_reg_rtx (V4DImode);
12605   emit_insn (gen_avx2_interleave_low<mode> (t1, operands[1], operands[2]));
12606   emit_insn (gen_avx2_interleave_high<mode> (t2,  operands[1], operands[2]));
12607   emit_insn (gen_avx2_permv2ti (t3, gen_lowpart (V4DImode, t1),
12608                                 gen_lowpart (V4DImode, t2),
12609                                 GEN_INT (1 + (3 << 4))));
12610   emit_move_insn (operands[0], gen_lowpart (<MODE>mode, t3));
12611   DONE;
12614 (define_expand "vec_interleave_low<mode>"
12615   [(match_operand:VI_256 0 "register_operand")
12616    (match_operand:VI_256 1 "register_operand")
12617    (match_operand:VI_256 2 "nonimmediate_operand")]
12618  "TARGET_AVX2"
12620   rtx t1 = gen_reg_rtx (<MODE>mode);
12621   rtx t2 = gen_reg_rtx (<MODE>mode);
12622   rtx t3 = gen_reg_rtx (V4DImode);
12623   emit_insn (gen_avx2_interleave_low<mode> (t1, operands[1], operands[2]));
12624   emit_insn (gen_avx2_interleave_high<mode> (t2, operands[1], operands[2]));
12625   emit_insn (gen_avx2_permv2ti (t3, gen_lowpart (V4DImode, t1),
12626                                 gen_lowpart (V4DImode, t2),
12627                                 GEN_INT (0 + (2 << 4))));
12628   emit_move_insn (operands[0], gen_lowpart (<MODE>mode, t3));
12629   DONE;
12632 ;; Modes handled by pinsr patterns.
12633 (define_mode_iterator PINSR_MODE
12634   [(V16QI "TARGET_SSE4_1") V8HI
12635    (V4SI "TARGET_SSE4_1")
12636    (V2DI "TARGET_SSE4_1 && TARGET_64BIT")])
12638 (define_mode_attr sse2p4_1
12639   [(V16QI "sse4_1") (V8HI "sse2")
12640    (V4SI "sse4_1") (V2DI "sse4_1")])
12642 (define_mode_attr pinsr_evex_isa
12643   [(V16QI "avx512bw") (V8HI "avx512bw")
12644    (V4SI "avx512dq") (V2DI "avx512dq")])
12646 ;; sse4_1_pinsrd must come before sse2_loadld since it is preferred.
12647 (define_insn "<sse2p4_1>_pinsr<ssemodesuffix>"
12648   [(set (match_operand:PINSR_MODE 0 "register_operand" "=x,x,x,x,v,v")
12649         (vec_merge:PINSR_MODE
12650           (vec_duplicate:PINSR_MODE
12651             (match_operand:<ssescalarmode> 2 "nonimmediate_operand" "r,m,r,m,r,m"))
12652           (match_operand:PINSR_MODE 1 "register_operand" "0,0,x,x,v,v")
12653           (match_operand:SI 3 "const_int_operand")))]
12654   "TARGET_SSE2
12655    && ((unsigned) exact_log2 (INTVAL (operands[3]))
12656        < GET_MODE_NUNITS (<MODE>mode))"
12658   operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])));
12660   switch (which_alternative)
12661     {
12662     case 0:
12663       if (GET_MODE_SIZE (<ssescalarmode>mode) < GET_MODE_SIZE (SImode))
12664         return "pinsr<ssemodesuffix>\t{%3, %k2, %0|%0, %k2, %3}";
12665       /* FALLTHRU */
12666     case 1:
12667       return "pinsr<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}";
12668     case 2:
12669     case 4:
12670       if (GET_MODE_SIZE (<ssescalarmode>mode) < GET_MODE_SIZE (SImode))
12671         return "vpinsr<ssemodesuffix>\t{%3, %k2, %1, %0|%0, %1, %k2, %3}";
12672       /* FALLTHRU */
12673     case 3:
12674     case 5:
12675       return "vpinsr<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
12676     default:
12677       gcc_unreachable ();
12678     }
12680   [(set_attr "isa" "noavx,noavx,avx,avx,<pinsr_evex_isa>,<pinsr_evex_isa>")
12681    (set_attr "type" "sselog")
12682    (set (attr "prefix_rex")
12683      (if_then_else
12684        (and (not (match_test "TARGET_AVX"))
12685             (eq (const_string "<MODE>mode") (const_string "V2DImode")))
12686        (const_string "1")
12687        (const_string "*")))
12688    (set (attr "prefix_data16")
12689      (if_then_else
12690        (and (not (match_test "TARGET_AVX"))
12691             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
12692        (const_string "1")
12693        (const_string "*")))
12694    (set (attr "prefix_extra")
12695      (if_then_else
12696        (and (not (match_test "TARGET_AVX"))
12697             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
12698        (const_string "*")
12699        (const_string "1")))
12700    (set_attr "length_immediate" "1")
12701    (set_attr "prefix" "orig,orig,vex,vex,evex,evex")
12702    (set_attr "mode" "TI")])
12704 (define_expand "<extract_type>_vinsert<shuffletype><extract_suf>_mask"
12705   [(match_operand:AVX512_VEC 0 "register_operand")
12706    (match_operand:AVX512_VEC 1 "register_operand")
12707    (match_operand:<ssequartermode> 2 "nonimmediate_operand")
12708    (match_operand:SI 3 "const_0_to_3_operand")
12709    (match_operand:AVX512_VEC 4 "register_operand")
12710    (match_operand:<avx512fmaskmode> 5 "register_operand")]
12711   "TARGET_AVX512F"
12713   int mask, selector;
12714   mask = INTVAL (operands[3]);
12715   selector = (GET_MODE_UNIT_SIZE (<MODE>mode) == 4
12716               ? 0xFFFF ^ (0x000F << mask * 4)
12717               : 0xFF ^ (0x03 << mask * 2));
12718   emit_insn (gen_<extract_type>_vinsert<shuffletype><extract_suf>_1_mask
12719     (operands[0], operands[1], operands[2], GEN_INT (selector),
12720      operands[4], operands[5]));
12721   DONE;
12724 (define_insn "<mask_codefor><extract_type>_vinsert<shuffletype><extract_suf>_1<mask_name>"
12725   [(set (match_operand:AVX512_VEC 0 "register_operand" "=v")
12726         (vec_merge:AVX512_VEC
12727           (match_operand:AVX512_VEC 1 "register_operand" "v")
12728           (vec_duplicate:AVX512_VEC
12729                 (match_operand:<ssequartermode> 2 "nonimmediate_operand" "vm"))
12730           (match_operand:SI 3 "const_int_operand" "n")))]
12731   "TARGET_AVX512F"
12733   int mask;
12734   int selector = INTVAL (operands[3]);
12736   if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xFFF0 : 0xFC))
12737     mask = 0;
12738   else if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xFF0F : 0xF3))
12739     mask = 1;
12740   else if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0xF0FF : 0xCF))
12741     mask = 2;
12742   else if (selector == (GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ? 0x0FFF : 0x3F))
12743     mask = 3;
12744   else
12745     gcc_unreachable ();
12747   operands[3] = GEN_INT (mask);
12749   return "vinsert<shuffletype><extract_suf>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}";
12751   [(set_attr "type" "sselog")
12752    (set_attr "length_immediate" "1")
12753    (set_attr "prefix" "evex")
12754    (set_attr "mode" "<sseinsnmode>")])
12756 (define_expand "<extract_type_2>_vinsert<shuffletype><extract_suf_2>_mask"
12757   [(match_operand:AVX512_VEC_2 0 "register_operand")
12758    (match_operand:AVX512_VEC_2 1 "register_operand")
12759    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
12760    (match_operand:SI 3 "const_0_to_1_operand")
12761    (match_operand:AVX512_VEC_2 4 "register_operand")
12762    (match_operand:<avx512fmaskmode> 5 "register_operand")]
12763   "TARGET_AVX512F"
12765   int mask = INTVAL (operands[3]);
12766   if (mask == 0)
12767     emit_insn (gen_vec_set_lo_<mode>_mask (operands[0], operands[1],
12768                                            operands[2], operands[4],
12769                                            operands[5]));
12770   else
12771     emit_insn (gen_vec_set_hi_<mode>_mask (operands[0], operands[1],
12772                                            operands[2], operands[4],
12773                                            operands[5]));
12774   DONE;
12777 (define_insn "vec_set_lo_<mode><mask_name>"
12778   [(set (match_operand:V16FI 0 "register_operand" "=v")
12779         (vec_concat:V16FI
12780           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
12781           (vec_select:<ssehalfvecmode>
12782             (match_operand:V16FI 1 "register_operand" "v")
12783             (parallel [(const_int 8) (const_int 9)
12784                        (const_int 10) (const_int 11)
12785                        (const_int 12) (const_int 13)
12786                        (const_int 14) (const_int 15)]))))]
12787   "TARGET_AVX512DQ"
12788   "vinsert<shuffletype>32x8\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}"
12789   [(set_attr "type" "sselog")
12790    (set_attr "length_immediate" "1")
12791    (set_attr "prefix" "evex")
12792    (set_attr "mode" "<sseinsnmode>")])
12794 (define_insn "vec_set_hi_<mode><mask_name>"
12795   [(set (match_operand:V16FI 0 "register_operand" "=v")
12796         (vec_concat:V16FI
12797           (vec_select:<ssehalfvecmode>
12798             (match_operand:V16FI 1 "register_operand" "v")
12799             (parallel [(const_int 0) (const_int 1)
12800                        (const_int 2) (const_int 3)
12801                        (const_int 4) (const_int 5)
12802                        (const_int 6) (const_int 7)]))
12803           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
12804   "TARGET_AVX512DQ"
12805   "vinsert<shuffletype>32x8\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}"
12806   [(set_attr "type" "sselog")
12807    (set_attr "length_immediate" "1")
12808    (set_attr "prefix" "evex")
12809    (set_attr "mode" "<sseinsnmode>")])
12811 (define_insn "vec_set_lo_<mode><mask_name>"
12812   [(set (match_operand:V8FI 0 "register_operand" "=v")
12813         (vec_concat:V8FI
12814           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
12815           (vec_select:<ssehalfvecmode>
12816             (match_operand:V8FI 1 "register_operand" "v")
12817             (parallel [(const_int 4) (const_int 5)
12818                        (const_int 6) (const_int 7)]))))]
12819   "TARGET_AVX512F"
12820   "vinsert<shuffletype>64x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}"
12821   [(set_attr "type" "sselog")
12822    (set_attr "length_immediate" "1")
12823    (set_attr "prefix" "evex")
12824    (set_attr "mode" "XI")])
12826 (define_insn "vec_set_hi_<mode><mask_name>"
12827   [(set (match_operand:V8FI 0 "register_operand" "=v")
12828         (vec_concat:V8FI
12829           (vec_select:<ssehalfvecmode>
12830             (match_operand:V8FI 1 "register_operand" "v")
12831             (parallel [(const_int 0) (const_int 1)
12832                        (const_int 2) (const_int 3)]))
12833           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
12834   "TARGET_AVX512F"
12835   "vinsert<shuffletype>64x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}"
12836   [(set_attr "type" "sselog")
12837    (set_attr "length_immediate" "1")
12838    (set_attr "prefix" "evex")
12839    (set_attr "mode" "XI")])
12841 (define_expand "avx512dq_shuf_<shuffletype>64x2_mask"
12842   [(match_operand:VI8F_256 0 "register_operand")
12843    (match_operand:VI8F_256 1 "register_operand")
12844    (match_operand:VI8F_256 2 "nonimmediate_operand")
12845    (match_operand:SI 3 "const_0_to_3_operand")
12846    (match_operand:VI8F_256 4 "register_operand")
12847    (match_operand:QI 5 "register_operand")]
12848   "TARGET_AVX512DQ"
12850   int mask = INTVAL (operands[3]);
12851   emit_insn (gen_avx512dq_shuf_<shuffletype>64x2_1_mask
12852       (operands[0], operands[1], operands[2],
12853        GEN_INT (((mask >> 0) & 1) * 2 + 0),
12854        GEN_INT (((mask >> 0) & 1) * 2 + 1),
12855        GEN_INT (((mask >> 1) & 1) * 2 + 4),
12856        GEN_INT (((mask >> 1) & 1) * 2 + 5),
12857        operands[4], operands[5]));
12858   DONE;
12861 (define_insn "<mask_codefor>avx512dq_shuf_<shuffletype>64x2_1<mask_name>"
12862   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
12863         (vec_select:VI8F_256
12864           (vec_concat:<ssedoublemode>
12865             (match_operand:VI8F_256 1 "register_operand" "v")
12866             (match_operand:VI8F_256 2 "nonimmediate_operand" "vm"))
12867           (parallel [(match_operand 3  "const_0_to_3_operand")
12868                      (match_operand 4  "const_0_to_3_operand")
12869                      (match_operand 5  "const_4_to_7_operand")
12870                      (match_operand 6  "const_4_to_7_operand")])))]
12871   "TARGET_AVX512VL
12872    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12873        && INTVAL (operands[5]) == (INTVAL (operands[6]) - 1))"
12875   int mask;
12876   mask = INTVAL (operands[3]) / 2;
12877   mask |= (INTVAL (operands[5]) - 4) / 2 << 1;
12878   operands[3] = GEN_INT (mask);
12879   return "vshuf<shuffletype>64x2\t{%3, %2, %1, %0<mask_operand7>|%0<mask_operand7>, %1, %2, %3}";
12881   [(set_attr "type" "sselog")
12882    (set_attr "length_immediate" "1")
12883    (set_attr "prefix" "evex")
12884    (set_attr "mode" "XI")])
12886 (define_expand "avx512f_shuf_<shuffletype>64x2_mask"
12887   [(match_operand:V8FI 0 "register_operand")
12888    (match_operand:V8FI 1 "register_operand")
12889    (match_operand:V8FI 2 "nonimmediate_operand")
12890    (match_operand:SI 3 "const_0_to_255_operand")
12891    (match_operand:V8FI 4 "register_operand")
12892    (match_operand:QI 5 "register_operand")]
12893   "TARGET_AVX512F"
12895   int mask = INTVAL (operands[3]);
12896   emit_insn (gen_avx512f_shuf_<shuffletype>64x2_1_mask
12897       (operands[0], operands[1], operands[2],
12898        GEN_INT (((mask >> 0) & 3) * 2),
12899        GEN_INT (((mask >> 0) & 3) * 2 + 1),
12900        GEN_INT (((mask >> 2) & 3) * 2),
12901        GEN_INT (((mask >> 2) & 3) * 2 + 1),
12902        GEN_INT (((mask >> 4) & 3) * 2 + 8),
12903        GEN_INT (((mask >> 4) & 3) * 2 + 9),
12904        GEN_INT (((mask >> 6) & 3) * 2 + 8),
12905        GEN_INT (((mask >> 6) & 3) * 2 + 9),
12906        operands[4], operands[5]));
12907   DONE;
12910 (define_insn "avx512f_shuf_<shuffletype>64x2_1<mask_name>"
12911   [(set (match_operand:V8FI 0 "register_operand" "=v")
12912         (vec_select:V8FI
12913           (vec_concat:<ssedoublemode>
12914             (match_operand:V8FI 1 "register_operand" "v")
12915             (match_operand:V8FI 2 "nonimmediate_operand" "vm"))
12916           (parallel [(match_operand 3  "const_0_to_7_operand")
12917                      (match_operand 4  "const_0_to_7_operand")
12918                      (match_operand 5  "const_0_to_7_operand")
12919                      (match_operand 6  "const_0_to_7_operand")
12920                      (match_operand 7  "const_8_to_15_operand")
12921                      (match_operand 8  "const_8_to_15_operand")
12922                      (match_operand 9  "const_8_to_15_operand")
12923                      (match_operand 10  "const_8_to_15_operand")])))]
12924   "TARGET_AVX512F
12925    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12926        && INTVAL (operands[5]) == (INTVAL (operands[6]) - 1)
12927        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
12928        && INTVAL (operands[9]) == (INTVAL (operands[10]) - 1))"
12930   int mask;
12931   mask = INTVAL (operands[3]) / 2;
12932   mask |= INTVAL (operands[5]) / 2 << 2;
12933   mask |= (INTVAL (operands[7]) - 8) / 2 << 4;
12934   mask |= (INTVAL (operands[9]) - 8) / 2 << 6;
12935   operands[3] = GEN_INT (mask);
12937   return "vshuf<shuffletype>64x2\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
12939   [(set_attr "type" "sselog")
12940    (set_attr "length_immediate" "1")
12941    (set_attr "prefix" "evex")
12942    (set_attr "mode" "<sseinsnmode>")])
12944 (define_expand "avx512vl_shuf_<shuffletype>32x4_mask"
12945   [(match_operand:VI4F_256 0 "register_operand")
12946    (match_operand:VI4F_256 1 "register_operand")
12947    (match_operand:VI4F_256 2 "nonimmediate_operand")
12948    (match_operand:SI 3 "const_0_to_3_operand")
12949    (match_operand:VI4F_256 4 "register_operand")
12950    (match_operand:QI 5 "register_operand")]
12951   "TARGET_AVX512VL"
12953   int mask = INTVAL (operands[3]);
12954   emit_insn (gen_avx512vl_shuf_<shuffletype>32x4_1_mask
12955       (operands[0], operands[1], operands[2],
12956        GEN_INT (((mask >> 0) & 1) * 4 + 0),
12957        GEN_INT (((mask >> 0) & 1) * 4 + 1),
12958        GEN_INT (((mask >> 0) & 1) * 4 + 2),
12959        GEN_INT (((mask >> 0) & 1) * 4 + 3),
12960        GEN_INT (((mask >> 1) & 1) * 4 + 8),
12961        GEN_INT (((mask >> 1) & 1) * 4 + 9),
12962        GEN_INT (((mask >> 1) & 1) * 4 + 10),
12963        GEN_INT (((mask >> 1) & 1) * 4 + 11),
12964        operands[4], operands[5]));
12965   DONE;
12968 (define_insn "avx512vl_shuf_<shuffletype>32x4_1<mask_name>"
12969   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
12970         (vec_select:VI4F_256
12971           (vec_concat:<ssedoublemode>
12972             (match_operand:VI4F_256 1 "register_operand" "v")
12973             (match_operand:VI4F_256 2 "nonimmediate_operand" "vm"))
12974           (parallel [(match_operand 3  "const_0_to_7_operand")
12975                      (match_operand 4  "const_0_to_7_operand")
12976                      (match_operand 5  "const_0_to_7_operand")
12977                      (match_operand 6  "const_0_to_7_operand")
12978                      (match_operand 7  "const_8_to_15_operand")
12979                      (match_operand 8  "const_8_to_15_operand")
12980                      (match_operand 9  "const_8_to_15_operand")
12981                      (match_operand 10 "const_8_to_15_operand")])))]
12982   "TARGET_AVX512VL
12983    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12984        && INTVAL (operands[3]) == (INTVAL (operands[5]) - 2)
12985        && INTVAL (operands[3]) == (INTVAL (operands[6]) - 3)
12986        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
12987        && INTVAL (operands[7]) == (INTVAL (operands[9]) - 2)
12988        && INTVAL (operands[7]) == (INTVAL (operands[10]) - 3))"
12990   int mask;
12991   mask = INTVAL (operands[3]) / 4;
12992   mask |= (INTVAL (operands[7]) - 8) / 4 << 1;
12993   operands[3] = GEN_INT (mask);
12995   return "vshuf<shuffletype>32x4\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
12997   [(set_attr "type" "sselog")
12998    (set_attr "length_immediate" "1")
12999    (set_attr "prefix" "evex")
13000    (set_attr "mode" "<sseinsnmode>")])
13002 (define_expand "avx512f_shuf_<shuffletype>32x4_mask"
13003   [(match_operand:V16FI 0 "register_operand")
13004    (match_operand:V16FI 1 "register_operand")
13005    (match_operand:V16FI 2 "nonimmediate_operand")
13006    (match_operand:SI 3 "const_0_to_255_operand")
13007    (match_operand:V16FI 4 "register_operand")
13008    (match_operand:HI 5 "register_operand")]
13009   "TARGET_AVX512F"
13011   int mask = INTVAL (operands[3]);
13012   emit_insn (gen_avx512f_shuf_<shuffletype>32x4_1_mask
13013       (operands[0], operands[1], operands[2],
13014        GEN_INT (((mask >> 0) & 3) * 4),
13015        GEN_INT (((mask >> 0) & 3) * 4 + 1),
13016        GEN_INT (((mask >> 0) & 3) * 4 + 2),
13017        GEN_INT (((mask >> 0) & 3) * 4 + 3),
13018        GEN_INT (((mask >> 2) & 3) * 4),
13019        GEN_INT (((mask >> 2) & 3) * 4 + 1),
13020        GEN_INT (((mask >> 2) & 3) * 4 + 2),
13021        GEN_INT (((mask >> 2) & 3) * 4 + 3),
13022        GEN_INT (((mask >> 4) & 3) * 4 + 16),
13023        GEN_INT (((mask >> 4) & 3) * 4 + 17),
13024        GEN_INT (((mask >> 4) & 3) * 4 + 18),
13025        GEN_INT (((mask >> 4) & 3) * 4 + 19),
13026        GEN_INT (((mask >> 6) & 3) * 4 + 16),
13027        GEN_INT (((mask >> 6) & 3) * 4 + 17),
13028        GEN_INT (((mask >> 6) & 3) * 4 + 18),
13029        GEN_INT (((mask >> 6) & 3) * 4 + 19),
13030        operands[4], operands[5]));
13031   DONE;
13034 (define_insn "avx512f_shuf_<shuffletype>32x4_1<mask_name>"
13035   [(set (match_operand:V16FI 0 "register_operand" "=v")
13036         (vec_select:V16FI
13037           (vec_concat:<ssedoublemode>
13038             (match_operand:V16FI 1 "register_operand" "v")
13039             (match_operand:V16FI 2 "nonimmediate_operand" "vm"))
13040           (parallel [(match_operand 3  "const_0_to_15_operand")
13041                      (match_operand 4  "const_0_to_15_operand")
13042                      (match_operand 5  "const_0_to_15_operand")
13043                      (match_operand 6  "const_0_to_15_operand")
13044                      (match_operand 7  "const_0_to_15_operand")
13045                      (match_operand 8  "const_0_to_15_operand")
13046                      (match_operand 9  "const_0_to_15_operand")
13047                      (match_operand 10  "const_0_to_15_operand")
13048                      (match_operand 11  "const_16_to_31_operand")
13049                      (match_operand 12  "const_16_to_31_operand")
13050                      (match_operand 13  "const_16_to_31_operand")
13051                      (match_operand 14  "const_16_to_31_operand")
13052                      (match_operand 15  "const_16_to_31_operand")
13053                      (match_operand 16  "const_16_to_31_operand")
13054                      (match_operand 17  "const_16_to_31_operand")
13055                      (match_operand 18  "const_16_to_31_operand")])))]
13056   "TARGET_AVX512F
13057    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
13058        && INTVAL (operands[3]) == (INTVAL (operands[5]) - 2)
13059        && INTVAL (operands[3]) == (INTVAL (operands[6]) - 3)
13060        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
13061        && INTVAL (operands[7]) == (INTVAL (operands[9]) - 2)
13062        && INTVAL (operands[7]) == (INTVAL (operands[10]) - 3)
13063        && INTVAL (operands[11]) == (INTVAL (operands[12]) - 1)
13064        && INTVAL (operands[11]) == (INTVAL (operands[13]) - 2)
13065        && INTVAL (operands[11]) == (INTVAL (operands[14]) - 3)
13066        && INTVAL (operands[15]) == (INTVAL (operands[16]) - 1)
13067        && INTVAL (operands[15]) == (INTVAL (operands[17]) - 2)
13068        && INTVAL (operands[15]) == (INTVAL (operands[18]) - 3))"
13070   int mask;
13071   mask = INTVAL (operands[3]) / 4;
13072   mask |= INTVAL (operands[7]) / 4 << 2;
13073   mask |= (INTVAL (operands[11]) - 16) / 4 << 4;
13074   mask |= (INTVAL (operands[15]) - 16) / 4 << 6;
13075   operands[3] = GEN_INT (mask);
13077   return "vshuf<shuffletype>32x4\t{%3, %2, %1, %0<mask_operand19>|%0<mask_operand19>, %1, %2, %3}";
13079   [(set_attr "type" "sselog")
13080    (set_attr "length_immediate" "1")
13081    (set_attr "prefix" "evex")
13082    (set_attr "mode" "<sseinsnmode>")])
13084 (define_expand "avx512f_pshufdv3_mask"
13085   [(match_operand:V16SI 0 "register_operand")
13086    (match_operand:V16SI 1 "nonimmediate_operand")
13087    (match_operand:SI 2 "const_0_to_255_operand")
13088    (match_operand:V16SI 3 "register_operand")
13089    (match_operand:HI 4 "register_operand")]
13090   "TARGET_AVX512F"
13092   int mask = INTVAL (operands[2]);
13093   emit_insn (gen_avx512f_pshufd_1_mask (operands[0], operands[1],
13094                                        GEN_INT ((mask >> 0) & 3),
13095                                        GEN_INT ((mask >> 2) & 3),
13096                                        GEN_INT ((mask >> 4) & 3),
13097                                        GEN_INT ((mask >> 6) & 3),
13098                                        GEN_INT (((mask >> 0) & 3) + 4),
13099                                        GEN_INT (((mask >> 2) & 3) + 4),
13100                                        GEN_INT (((mask >> 4) & 3) + 4),
13101                                        GEN_INT (((mask >> 6) & 3) + 4),
13102                                        GEN_INT (((mask >> 0) & 3) + 8),
13103                                        GEN_INT (((mask >> 2) & 3) + 8),
13104                                        GEN_INT (((mask >> 4) & 3) + 8),
13105                                        GEN_INT (((mask >> 6) & 3) + 8),
13106                                        GEN_INT (((mask >> 0) & 3) + 12),
13107                                        GEN_INT (((mask >> 2) & 3) + 12),
13108                                        GEN_INT (((mask >> 4) & 3) + 12),
13109                                        GEN_INT (((mask >> 6) & 3) + 12),
13110                                        operands[3], operands[4]));
13111   DONE;
13114 (define_insn "avx512f_pshufd_1<mask_name>"
13115   [(set (match_operand:V16SI 0 "register_operand" "=v")
13116         (vec_select:V16SI
13117           (match_operand:V16SI 1 "nonimmediate_operand" "vm")
13118           (parallel [(match_operand 2 "const_0_to_3_operand")
13119                      (match_operand 3 "const_0_to_3_operand")
13120                      (match_operand 4 "const_0_to_3_operand")
13121                      (match_operand 5 "const_0_to_3_operand")
13122                      (match_operand 6 "const_4_to_7_operand")
13123                      (match_operand 7 "const_4_to_7_operand")
13124                      (match_operand 8 "const_4_to_7_operand")
13125                      (match_operand 9 "const_4_to_7_operand")
13126                      (match_operand 10 "const_8_to_11_operand")
13127                      (match_operand 11 "const_8_to_11_operand")
13128                      (match_operand 12 "const_8_to_11_operand")
13129                      (match_operand 13 "const_8_to_11_operand")
13130                      (match_operand 14 "const_12_to_15_operand")
13131                      (match_operand 15 "const_12_to_15_operand")
13132                      (match_operand 16 "const_12_to_15_operand")
13133                      (match_operand 17 "const_12_to_15_operand")])))]
13134   "TARGET_AVX512F
13135    && INTVAL (operands[2]) + 4 == INTVAL (operands[6])
13136    && INTVAL (operands[3]) + 4 == INTVAL (operands[7])
13137    && INTVAL (operands[4]) + 4 == INTVAL (operands[8])
13138    && INTVAL (operands[5]) + 4 == INTVAL (operands[9])
13139    && INTVAL (operands[2]) + 8 == INTVAL (operands[10])
13140    && INTVAL (operands[3]) + 8 == INTVAL (operands[11])
13141    && INTVAL (operands[4]) + 8 == INTVAL (operands[12])
13142    && INTVAL (operands[5]) + 8 == INTVAL (operands[13])
13143    && INTVAL (operands[2]) + 12 == INTVAL (operands[14])
13144    && INTVAL (operands[3]) + 12 == INTVAL (operands[15])
13145    && INTVAL (operands[4]) + 12 == INTVAL (operands[16])
13146    && INTVAL (operands[5]) + 12 == INTVAL (operands[17])"
13148   int mask = 0;
13149   mask |= INTVAL (operands[2]) << 0;
13150   mask |= INTVAL (operands[3]) << 2;
13151   mask |= INTVAL (operands[4]) << 4;
13152   mask |= INTVAL (operands[5]) << 6;
13153   operands[2] = GEN_INT (mask);
13155   return "vpshufd\t{%2, %1, %0<mask_operand18>|%0<mask_operand18>, %1, %2}";
13157   [(set_attr "type" "sselog1")
13158    (set_attr "prefix" "evex")
13159    (set_attr "length_immediate" "1")
13160    (set_attr "mode" "XI")])
13162 (define_expand "avx512vl_pshufdv3_mask"
13163   [(match_operand:V8SI 0 "register_operand")
13164    (match_operand:V8SI 1 "nonimmediate_operand")
13165    (match_operand:SI 2 "const_0_to_255_operand")
13166    (match_operand:V8SI 3 "register_operand")
13167    (match_operand:QI 4 "register_operand")]
13168   "TARGET_AVX512VL"
13170   int mask = INTVAL (operands[2]);
13171   emit_insn (gen_avx2_pshufd_1_mask (operands[0], operands[1],
13172                                 GEN_INT ((mask >> 0) & 3),
13173                                 GEN_INT ((mask >> 2) & 3),
13174                                 GEN_INT ((mask >> 4) & 3),
13175                                 GEN_INT ((mask >> 6) & 3),
13176                                 GEN_INT (((mask >> 0) & 3) + 4),
13177                                 GEN_INT (((mask >> 2) & 3) + 4),
13178                                 GEN_INT (((mask >> 4) & 3) + 4),
13179                                 GEN_INT (((mask >> 6) & 3) + 4),
13180                 operands[3], operands[4]));
13181   DONE;
13184 (define_expand "avx2_pshufdv3"
13185   [(match_operand:V8SI 0 "register_operand")
13186    (match_operand:V8SI 1 "nonimmediate_operand")
13187    (match_operand:SI 2 "const_0_to_255_operand")]
13188   "TARGET_AVX2"
13190   int mask = INTVAL (operands[2]);
13191   emit_insn (gen_avx2_pshufd_1 (operands[0], operands[1],
13192                                 GEN_INT ((mask >> 0) & 3),
13193                                 GEN_INT ((mask >> 2) & 3),
13194                                 GEN_INT ((mask >> 4) & 3),
13195                                 GEN_INT ((mask >> 6) & 3),
13196                                 GEN_INT (((mask >> 0) & 3) + 4),
13197                                 GEN_INT (((mask >> 2) & 3) + 4),
13198                                 GEN_INT (((mask >> 4) & 3) + 4),
13199                                 GEN_INT (((mask >> 6) & 3) + 4)));
13200   DONE;
13203 (define_insn "avx2_pshufd_1<mask_name>"
13204   [(set (match_operand:V8SI 0 "register_operand" "=v")
13205         (vec_select:V8SI
13206           (match_operand:V8SI 1 "nonimmediate_operand" "vm")
13207           (parallel [(match_operand 2 "const_0_to_3_operand")
13208                      (match_operand 3 "const_0_to_3_operand")
13209                      (match_operand 4 "const_0_to_3_operand")
13210                      (match_operand 5 "const_0_to_3_operand")
13211                      (match_operand 6 "const_4_to_7_operand")
13212                      (match_operand 7 "const_4_to_7_operand")
13213                      (match_operand 8 "const_4_to_7_operand")
13214                      (match_operand 9 "const_4_to_7_operand")])))]
13215   "TARGET_AVX2
13216    && <mask_avx512vl_condition>
13217    && INTVAL (operands[2]) + 4 == INTVAL (operands[6])
13218    && INTVAL (operands[3]) + 4 == INTVAL (operands[7])
13219    && INTVAL (operands[4]) + 4 == INTVAL (operands[8])
13220    && INTVAL (operands[5]) + 4 == INTVAL (operands[9])"
13222   int mask = 0;
13223   mask |= INTVAL (operands[2]) << 0;
13224   mask |= INTVAL (operands[3]) << 2;
13225   mask |= INTVAL (operands[4]) << 4;
13226   mask |= INTVAL (operands[5]) << 6;
13227   operands[2] = GEN_INT (mask);
13229   return "vpshufd\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
13231   [(set_attr "type" "sselog1")
13232    (set_attr "prefix" "maybe_evex")
13233    (set_attr "length_immediate" "1")
13234    (set_attr "mode" "OI")])
13236 (define_expand "avx512vl_pshufd_mask"
13237   [(match_operand:V4SI 0 "register_operand")
13238    (match_operand:V4SI 1 "nonimmediate_operand")
13239    (match_operand:SI 2 "const_0_to_255_operand")
13240    (match_operand:V4SI 3 "register_operand")
13241    (match_operand:QI 4 "register_operand")]
13242   "TARGET_AVX512VL"
13244   int mask = INTVAL (operands[2]);
13245   emit_insn (gen_sse2_pshufd_1_mask (operands[0], operands[1],
13246                                 GEN_INT ((mask >> 0) & 3),
13247                                 GEN_INT ((mask >> 2) & 3),
13248                                 GEN_INT ((mask >> 4) & 3),
13249                                 GEN_INT ((mask >> 6) & 3),
13250                 operands[3], operands[4]));
13251   DONE;
13254 (define_expand "sse2_pshufd"
13255   [(match_operand:V4SI 0 "register_operand")
13256    (match_operand:V4SI 1 "vector_operand")
13257    (match_operand:SI 2 "const_int_operand")]
13258   "TARGET_SSE2"
13260   int mask = INTVAL (operands[2]);
13261   emit_insn (gen_sse2_pshufd_1 (operands[0], operands[1],
13262                                 GEN_INT ((mask >> 0) & 3),
13263                                 GEN_INT ((mask >> 2) & 3),
13264                                 GEN_INT ((mask >> 4) & 3),
13265                                 GEN_INT ((mask >> 6) & 3)));
13266   DONE;
13269 (define_insn "sse2_pshufd_1<mask_name>"
13270   [(set (match_operand:V4SI 0 "register_operand" "=v")
13271         (vec_select:V4SI
13272           (match_operand:V4SI 1 "vector_operand" "vBm")
13273           (parallel [(match_operand 2 "const_0_to_3_operand")
13274                      (match_operand 3 "const_0_to_3_operand")
13275                      (match_operand 4 "const_0_to_3_operand")
13276                      (match_operand 5 "const_0_to_3_operand")])))]
13277   "TARGET_SSE2 && <mask_avx512vl_condition>"
13279   int mask = 0;
13280   mask |= INTVAL (operands[2]) << 0;
13281   mask |= INTVAL (operands[3]) << 2;
13282   mask |= INTVAL (operands[4]) << 4;
13283   mask |= INTVAL (operands[5]) << 6;
13284   operands[2] = GEN_INT (mask);
13286   return "%vpshufd\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
13288   [(set_attr "type" "sselog1")
13289    (set_attr "prefix_data16" "1")
13290    (set_attr "prefix" "<mask_prefix2>")
13291    (set_attr "length_immediate" "1")
13292    (set_attr "mode" "TI")])
13294 (define_insn "<mask_codefor>avx512bw_pshuflwv32hi<mask_name>"
13295   [(set (match_operand:V32HI 0 "register_operand" "=v")
13296         (unspec:V32HI
13297           [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
13298            (match_operand:SI 2 "const_0_to_255_operand" "n")]
13299           UNSPEC_PSHUFLW))]
13300   "TARGET_AVX512BW"
13301   "vpshuflw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
13302   [(set_attr "type" "sselog")
13303    (set_attr "prefix" "evex")
13304    (set_attr "mode" "XI")])
13306 (define_expand "avx512vl_pshuflwv3_mask"
13307   [(match_operand:V16HI 0 "register_operand")
13308    (match_operand:V16HI 1 "nonimmediate_operand")
13309    (match_operand:SI 2 "const_0_to_255_operand")
13310    (match_operand:V16HI 3 "register_operand")
13311    (match_operand:HI 4 "register_operand")]
13312   "TARGET_AVX512VL && TARGET_AVX512BW"
13314   int mask = INTVAL (operands[2]);
13315   emit_insn (gen_avx2_pshuflw_1_mask (operands[0], operands[1],
13316                                  GEN_INT ((mask >> 0) & 3),
13317                                  GEN_INT ((mask >> 2) & 3),
13318                                  GEN_INT ((mask >> 4) & 3),
13319                                  GEN_INT ((mask >> 6) & 3),
13320                                  GEN_INT (((mask >> 0) & 3) + 8),
13321                                  GEN_INT (((mask >> 2) & 3) + 8),
13322                                  GEN_INT (((mask >> 4) & 3) + 8),
13323                                  GEN_INT (((mask >> 6) & 3) + 8),
13324                  operands[3], operands[4]));
13325   DONE;
13328 (define_expand "avx2_pshuflwv3"
13329   [(match_operand:V16HI 0 "register_operand")
13330    (match_operand:V16HI 1 "nonimmediate_operand")
13331    (match_operand:SI 2 "const_0_to_255_operand")]
13332   "TARGET_AVX2"
13334   int mask = INTVAL (operands[2]);
13335   emit_insn (gen_avx2_pshuflw_1 (operands[0], operands[1],
13336                                  GEN_INT ((mask >> 0) & 3),
13337                                  GEN_INT ((mask >> 2) & 3),
13338                                  GEN_INT ((mask >> 4) & 3),
13339                                  GEN_INT ((mask >> 6) & 3),
13340                                  GEN_INT (((mask >> 0) & 3) + 8),
13341                                  GEN_INT (((mask >> 2) & 3) + 8),
13342                                  GEN_INT (((mask >> 4) & 3) + 8),
13343                                  GEN_INT (((mask >> 6) & 3) + 8)));
13344   DONE;
13347 (define_insn "avx2_pshuflw_1<mask_name>"
13348   [(set (match_operand:V16HI 0 "register_operand" "=v")
13349         (vec_select:V16HI
13350           (match_operand:V16HI 1 "nonimmediate_operand" "vm")
13351           (parallel [(match_operand 2 "const_0_to_3_operand")
13352                      (match_operand 3 "const_0_to_3_operand")
13353                      (match_operand 4 "const_0_to_3_operand")
13354                      (match_operand 5 "const_0_to_3_operand")
13355                      (const_int 4)
13356                      (const_int 5)
13357                      (const_int 6)
13358                      (const_int 7)
13359                      (match_operand 6 "const_8_to_11_operand")
13360                      (match_operand 7 "const_8_to_11_operand")
13361                      (match_operand 8 "const_8_to_11_operand")
13362                      (match_operand 9 "const_8_to_11_operand")
13363                      (const_int 12)
13364                      (const_int 13)
13365                      (const_int 14)
13366                      (const_int 15)])))]
13367   "TARGET_AVX2
13368    && <mask_avx512bw_condition> && <mask_avx512vl_condition>
13369    && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
13370    && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
13371    && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
13372    && INTVAL (operands[5]) + 8 == INTVAL (operands[9])"
13374   int mask = 0;
13375   mask |= INTVAL (operands[2]) << 0;
13376   mask |= INTVAL (operands[3]) << 2;
13377   mask |= INTVAL (operands[4]) << 4;
13378   mask |= INTVAL (operands[5]) << 6;
13379   operands[2] = GEN_INT (mask);
13381   return "vpshuflw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
13383   [(set_attr "type" "sselog")
13384    (set_attr "prefix" "maybe_evex")
13385    (set_attr "length_immediate" "1")
13386    (set_attr "mode" "OI")])
13388 (define_expand "avx512vl_pshuflw_mask"
13389   [(match_operand:V8HI 0 "register_operand")
13390    (match_operand:V8HI 1 "nonimmediate_operand")
13391    (match_operand:SI 2 "const_0_to_255_operand")
13392    (match_operand:V8HI 3 "register_operand")
13393    (match_operand:QI 4 "register_operand")]
13394   "TARGET_AVX512VL && TARGET_AVX512BW"
13396   int mask = INTVAL (operands[2]);
13397   emit_insn (gen_sse2_pshuflw_1_mask (operands[0], operands[1],
13398                                  GEN_INT ((mask >> 0) & 3),
13399                                  GEN_INT ((mask >> 2) & 3),
13400                                  GEN_INT ((mask >> 4) & 3),
13401                                  GEN_INT ((mask >> 6) & 3),
13402                  operands[3], operands[4]));
13403   DONE;
13406 (define_expand "sse2_pshuflw"
13407   [(match_operand:V8HI 0 "register_operand")
13408    (match_operand:V8HI 1 "vector_operand")
13409    (match_operand:SI 2 "const_int_operand")]
13410   "TARGET_SSE2"
13412   int mask = INTVAL (operands[2]);
13413   emit_insn (gen_sse2_pshuflw_1 (operands[0], operands[1],
13414                                  GEN_INT ((mask >> 0) & 3),
13415                                  GEN_INT ((mask >> 2) & 3),
13416                                  GEN_INT ((mask >> 4) & 3),
13417                                  GEN_INT ((mask >> 6) & 3)));
13418   DONE;
13421 (define_insn "sse2_pshuflw_1<mask_name>"
13422   [(set (match_operand:V8HI 0 "register_operand" "=v")
13423         (vec_select:V8HI
13424           (match_operand:V8HI 1 "vector_operand" "vBm")
13425           (parallel [(match_operand 2 "const_0_to_3_operand")
13426                      (match_operand 3 "const_0_to_3_operand")
13427                      (match_operand 4 "const_0_to_3_operand")
13428                      (match_operand 5 "const_0_to_3_operand")
13429                      (const_int 4)
13430                      (const_int 5)
13431                      (const_int 6)
13432                      (const_int 7)])))]
13433   "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
13435   int mask = 0;
13436   mask |= INTVAL (operands[2]) << 0;
13437   mask |= INTVAL (operands[3]) << 2;
13438   mask |= INTVAL (operands[4]) << 4;
13439   mask |= INTVAL (operands[5]) << 6;
13440   operands[2] = GEN_INT (mask);
13442   return "%vpshuflw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
13444   [(set_attr "type" "sselog")
13445    (set_attr "prefix_data16" "0")
13446    (set_attr "prefix_rep" "1")
13447    (set_attr "prefix" "maybe_vex")
13448    (set_attr "length_immediate" "1")
13449    (set_attr "mode" "TI")])
13451 (define_expand "avx2_pshufhwv3"
13452   [(match_operand:V16HI 0 "register_operand")
13453    (match_operand:V16HI 1 "nonimmediate_operand")
13454    (match_operand:SI 2 "const_0_to_255_operand")]
13455   "TARGET_AVX2"
13457   int mask = INTVAL (operands[2]);
13458   emit_insn (gen_avx2_pshufhw_1 (operands[0], operands[1],
13459                                  GEN_INT (((mask >> 0) & 3) + 4),
13460                                  GEN_INT (((mask >> 2) & 3) + 4),
13461                                  GEN_INT (((mask >> 4) & 3) + 4),
13462                                  GEN_INT (((mask >> 6) & 3) + 4),
13463                                  GEN_INT (((mask >> 0) & 3) + 12),
13464                                  GEN_INT (((mask >> 2) & 3) + 12),
13465                                  GEN_INT (((mask >> 4) & 3) + 12),
13466                                  GEN_INT (((mask >> 6) & 3) + 12)));
13467   DONE;
13470 (define_insn "<mask_codefor>avx512bw_pshufhwv32hi<mask_name>"
13471   [(set (match_operand:V32HI 0 "register_operand" "=v")
13472         (unspec:V32HI
13473           [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
13474            (match_operand:SI 2 "const_0_to_255_operand" "n")]
13475           UNSPEC_PSHUFHW))]
13476   "TARGET_AVX512BW"
13477   "vpshufhw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
13478   [(set_attr "type" "sselog")
13479    (set_attr "prefix" "evex")
13480    (set_attr "mode" "XI")])
13482 (define_expand "avx512vl_pshufhwv3_mask"
13483   [(match_operand:V16HI 0 "register_operand")
13484    (match_operand:V16HI 1 "nonimmediate_operand")
13485    (match_operand:SI 2 "const_0_to_255_operand")
13486    (match_operand:V16HI 3 "register_operand")
13487    (match_operand:HI 4 "register_operand")]
13488   "TARGET_AVX512VL && TARGET_AVX512BW"
13490   int mask = INTVAL (operands[2]);
13491   emit_insn (gen_avx2_pshufhw_1_mask (operands[0], operands[1],
13492                                  GEN_INT (((mask >> 0) & 3) + 4),
13493                                  GEN_INT (((mask >> 2) & 3) + 4),
13494                                  GEN_INT (((mask >> 4) & 3) + 4),
13495                                  GEN_INT (((mask >> 6) & 3) + 4),
13496                                  GEN_INT (((mask >> 0) & 3) + 12),
13497                                  GEN_INT (((mask >> 2) & 3) + 12),
13498                                  GEN_INT (((mask >> 4) & 3) + 12),
13499                                  GEN_INT (((mask >> 6) & 3) + 12),
13500                  operands[3], operands[4]));
13501   DONE;
13504 (define_insn "avx2_pshufhw_1<mask_name>"
13505   [(set (match_operand:V16HI 0 "register_operand" "=v")
13506         (vec_select:V16HI
13507           (match_operand:V16HI 1 "nonimmediate_operand" "vm")
13508           (parallel [(const_int 0)
13509                      (const_int 1)
13510                      (const_int 2)
13511                      (const_int 3)
13512                      (match_operand 2 "const_4_to_7_operand")
13513                      (match_operand 3 "const_4_to_7_operand")
13514                      (match_operand 4 "const_4_to_7_operand")
13515                      (match_operand 5 "const_4_to_7_operand")
13516                      (const_int 8)
13517                      (const_int 9)
13518                      (const_int 10)
13519                      (const_int 11)
13520                      (match_operand 6 "const_12_to_15_operand")
13521                      (match_operand 7 "const_12_to_15_operand")
13522                      (match_operand 8 "const_12_to_15_operand")
13523                      (match_operand 9 "const_12_to_15_operand")])))]
13524   "TARGET_AVX2
13525    && <mask_avx512bw_condition> && <mask_avx512vl_condition>
13526    && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
13527    && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
13528    && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
13529    && INTVAL (operands[5]) + 8 == INTVAL (operands[9])"
13531   int mask = 0;
13532   mask |= (INTVAL (operands[2]) - 4) << 0;
13533   mask |= (INTVAL (operands[3]) - 4) << 2;
13534   mask |= (INTVAL (operands[4]) - 4) << 4;
13535   mask |= (INTVAL (operands[5]) - 4) << 6;
13536   operands[2] = GEN_INT (mask);
13538   return "vpshufhw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
13540   [(set_attr "type" "sselog")
13541    (set_attr "prefix" "maybe_evex")
13542    (set_attr "length_immediate" "1")
13543    (set_attr "mode" "OI")])
13545 (define_expand "avx512vl_pshufhw_mask"
13546   [(match_operand:V8HI 0 "register_operand")
13547    (match_operand:V8HI 1 "nonimmediate_operand")
13548    (match_operand:SI 2 "const_0_to_255_operand")
13549    (match_operand:V8HI 3 "register_operand")
13550    (match_operand:QI 4 "register_operand")]
13551   "TARGET_AVX512VL && TARGET_AVX512BW"
13553   int mask = INTVAL (operands[2]);
13554   emit_insn (gen_sse2_pshufhw_1_mask (operands[0], operands[1],
13555                                  GEN_INT (((mask >> 0) & 3) + 4),
13556                                  GEN_INT (((mask >> 2) & 3) + 4),
13557                                  GEN_INT (((mask >> 4) & 3) + 4),
13558                                  GEN_INT (((mask >> 6) & 3) + 4),
13559                  operands[3], operands[4]));
13560   DONE;
13563 (define_expand "sse2_pshufhw"
13564   [(match_operand:V8HI 0 "register_operand")
13565    (match_operand:V8HI 1 "vector_operand")
13566    (match_operand:SI 2 "const_int_operand")]
13567   "TARGET_SSE2"
13569   int mask = INTVAL (operands[2]);
13570   emit_insn (gen_sse2_pshufhw_1 (operands[0], operands[1],
13571                                  GEN_INT (((mask >> 0) & 3) + 4),
13572                                  GEN_INT (((mask >> 2) & 3) + 4),
13573                                  GEN_INT (((mask >> 4) & 3) + 4),
13574                                  GEN_INT (((mask >> 6) & 3) + 4)));
13575   DONE;
13578 (define_insn "sse2_pshufhw_1<mask_name>"
13579   [(set (match_operand:V8HI 0 "register_operand" "=v")
13580         (vec_select:V8HI
13581           (match_operand:V8HI 1 "vector_operand" "vBm")
13582           (parallel [(const_int 0)
13583                      (const_int 1)
13584                      (const_int 2)
13585                      (const_int 3)
13586                      (match_operand 2 "const_4_to_7_operand")
13587                      (match_operand 3 "const_4_to_7_operand")
13588                      (match_operand 4 "const_4_to_7_operand")
13589                      (match_operand 5 "const_4_to_7_operand")])))]
13590   "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
13592   int mask = 0;
13593   mask |= (INTVAL (operands[2]) - 4) << 0;
13594   mask |= (INTVAL (operands[3]) - 4) << 2;
13595   mask |= (INTVAL (operands[4]) - 4) << 4;
13596   mask |= (INTVAL (operands[5]) - 4) << 6;
13597   operands[2] = GEN_INT (mask);
13599   return "%vpshufhw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
13601   [(set_attr "type" "sselog")
13602    (set_attr "prefix_rep" "1")
13603    (set_attr "prefix_data16" "0")
13604    (set_attr "prefix" "maybe_vex")
13605    (set_attr "length_immediate" "1")
13606    (set_attr "mode" "TI")])
13608 (define_expand "sse2_loadd"
13609   [(set (match_operand:V4SI 0 "register_operand")
13610         (vec_merge:V4SI
13611           (vec_duplicate:V4SI
13612             (match_operand:SI 1 "nonimmediate_operand"))
13613           (match_dup 2)
13614           (const_int 1)))]
13615   "TARGET_SSE"
13616   "operands[2] = CONST0_RTX (V4SImode);")
13618 (define_insn "sse2_loadld"
13619   [(set (match_operand:V4SI 0 "register_operand"       "=v,v,x,x,v")
13620         (vec_merge:V4SI
13621           (vec_duplicate:V4SI
13622             (match_operand:SI 2 "nonimmediate_operand" "m ,r ,m,x,v"))
13623           (match_operand:V4SI 1 "reg_or_0_operand"     "C ,C ,C,0,v")
13624           (const_int 1)))]
13625   "TARGET_SSE"
13626   "@
13627    %vmovd\t{%2, %0|%0, %2}
13628    %vmovd\t{%2, %0|%0, %2}
13629    movss\t{%2, %0|%0, %2}
13630    movss\t{%2, %0|%0, %2}
13631    vmovss\t{%2, %1, %0|%0, %1, %2}"
13632   [(set_attr "isa" "sse2,sse2,noavx,noavx,avx")
13633    (set_attr "type" "ssemov")
13634    (set_attr "prefix" "maybe_vex,maybe_vex,orig,orig,maybe_evex")
13635    (set_attr "mode" "TI,TI,V4SF,SF,SF")
13636    (set (attr "preferred_for_speed")
13637      (cond [(eq_attr "alternative" "1")
13638               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
13639            ]
13640            (symbol_ref "true")))])
13642 ;; QI and HI modes handled by pextr patterns.
13643 (define_mode_iterator PEXTR_MODE12
13644   [(V16QI "TARGET_SSE4_1") V8HI])
13646 (define_insn "*vec_extract<mode>"
13647   [(set (match_operand:<ssescalarmode> 0 "register_sse4nonimm_operand" "=r,m,r,m")
13648         (vec_select:<ssescalarmode>
13649           (match_operand:PEXTR_MODE12 1 "register_operand" "x,x,v,v")
13650           (parallel
13651             [(match_operand:SI 2 "const_0_to_<ssescalarnummask>_operand")])))]
13652   "TARGET_SSE2"
13653   "@
13654    %vpextr<ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
13655    %vpextr<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
13656    vpextr<ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
13657    vpextr<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
13658   [(set_attr "isa" "*,sse4,avx512bw,avx512bw")
13659    (set_attr "type" "sselog1")
13660    (set_attr "prefix_data16" "1")
13661    (set (attr "prefix_extra")
13662      (if_then_else
13663        (and (eq_attr "alternative" "0,2")
13664             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
13665        (const_string "*")
13666        (const_string "1")))
13667    (set_attr "length_immediate" "1")
13668    (set_attr "prefix" "maybe_vex,maybe_vex,evex,evex")
13669    (set_attr "mode" "TI")])
13671 (define_insn "*vec_extract<PEXTR_MODE12:mode>_zext"
13672   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
13673         (zero_extend:SWI48
13674           (vec_select:<PEXTR_MODE12:ssescalarmode>
13675             (match_operand:PEXTR_MODE12 1 "register_operand" "x,v")
13676             (parallel
13677               [(match_operand:SI 2
13678                 "const_0_to_<PEXTR_MODE12:ssescalarnummask>_operand")]))))]
13679   "TARGET_SSE2"
13680   "@
13681    %vpextr<PEXTR_MODE12:ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
13682    vpextr<PEXTR_MODE12:ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}"
13683   [(set_attr "isa" "*,avx512bw")
13684    (set_attr "type" "sselog1")
13685    (set_attr "prefix_data16" "1")
13686    (set (attr "prefix_extra")
13687      (if_then_else
13688        (eq (const_string "<PEXTR_MODE12:MODE>mode") (const_string "V8HImode"))
13689        (const_string "*")
13690        (const_string "1")))
13691    (set_attr "length_immediate" "1")
13692    (set_attr "prefix" "maybe_vex")
13693    (set_attr "mode" "TI")])
13695 (define_insn "*vec_extract<mode>_mem"
13696   [(set (match_operand:<ssescalarmode> 0 "register_operand" "=r")
13697         (vec_select:<ssescalarmode>
13698           (match_operand:VI12_128 1 "memory_operand" "o")
13699           (parallel
13700             [(match_operand 2 "const_0_to_<ssescalarnummask>_operand")])))]
13701   "TARGET_SSE"
13702   "#")
13704 (define_insn "*vec_extract<ssevecmodelower>_0"
13705   [(set (match_operand:SWI48 0 "nonimmediate_operand"          "=r,r,v ,m")
13706         (vec_select:SWI48
13707           (match_operand:<ssevecmode> 1 "nonimmediate_operand" "m ,v,vm,v")
13708           (parallel [(const_int 0)])))]
13709   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13710   "#"
13711   [(set_attr "isa" "*,sse2,*,*")
13712    (set (attr "preferred_for_speed")
13713      (cond [(eq_attr "alternative" "1")
13714               (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
13715            ]
13716            (symbol_ref "true")))])
13718 (define_insn "*vec_extractv2di_0_sse"
13719   [(set (match_operand:DI 0 "nonimmediate_operand"     "=v,m")
13720         (vec_select:DI
13721           (match_operand:V2DI 1 "nonimmediate_operand" "vm,v")
13722           (parallel [(const_int 0)])))]
13723   "TARGET_SSE && !TARGET_64BIT
13724    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13725   "#")
13727 (define_split
13728   [(set (match_operand:SWI48x 0 "nonimmediate_operand")
13729         (vec_select:SWI48x
13730           (match_operand:<ssevecmode> 1 "register_operand")
13731           (parallel [(const_int 0)])))]
13732   "TARGET_SSE && reload_completed"
13733   [(set (match_dup 0) (match_dup 1))]
13734   "operands[1] = gen_lowpart (<MODE>mode, operands[1]);")
13736 (define_insn "*vec_extractv4si_0_zext_sse4"
13737   [(set (match_operand:DI 0 "register_operand" "=r,x,v")
13738         (zero_extend:DI
13739           (vec_select:SI
13740             (match_operand:V4SI 1 "register_operand" "v,x,v")
13741             (parallel [(const_int 0)]))))]
13742   "TARGET_SSE4_1"
13743   "#"
13744   [(set_attr "isa" "x64,*,avx512f")
13745    (set (attr "preferred_for_speed")
13746      (cond [(eq_attr "alternative" "1")
13747               (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
13748            ]
13749            (symbol_ref "true")))])
13751 (define_insn "*vec_extractv4si_0_zext"
13752   [(set (match_operand:DI 0 "register_operand" "=r")
13753         (zero_extend:DI
13754           (vec_select:SI
13755             (match_operand:V4SI 1 "register_operand" "x")
13756             (parallel [(const_int 0)]))))]
13757   "TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_FROM_VEC"
13758   "#")
13760 (define_split
13761   [(set (match_operand:DI 0 "register_operand")
13762         (zero_extend:DI
13763           (vec_select:SI
13764             (match_operand:V4SI 1 "register_operand")
13765             (parallel [(const_int 0)]))))]
13766   "TARGET_SSE2 && reload_completed"
13767   [(set (match_dup 0) (zero_extend:DI (match_dup 1)))]
13768   "operands[1] = gen_lowpart (SImode, operands[1]);")
13770 (define_insn "*vec_extractv4si"
13771   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm,Yr,*x,x,Yv")
13772         (vec_select:SI
13773           (match_operand:V4SI 1 "register_operand" "x,v,0,0,x,v")
13774           (parallel [(match_operand:SI 2 "const_0_to_3_operand")])))]
13775   "TARGET_SSE4_1"
13777   switch (which_alternative)
13778     {
13779     case 0:
13780     case 1:
13781       return "%vpextrd\t{%2, %1, %0|%0, %1, %2}";
13783     case 2:
13784     case 3:
13785       operands[2] = GEN_INT (INTVAL (operands[2]) * 4);
13786       return "psrldq\t{%2, %0|%0, %2}";
13788     case 4:
13789     case 5:
13790       operands[2] = GEN_INT (INTVAL (operands[2]) * 4);
13791       return "vpsrldq\t{%2, %1, %0|%0, %1, %2}";
13793     default:
13794       gcc_unreachable ();
13795     }
13797   [(set_attr "isa" "*,avx512dq,noavx,noavx,avx,avx512bw")
13798    (set_attr "type" "sselog1,sselog1,sseishft1,sseishft1,sseishft1,sseishft1")
13799    (set (attr "prefix_extra")
13800      (if_then_else (eq_attr "alternative" "0,1")
13801                    (const_string "1")
13802                    (const_string "*")))
13803    (set_attr "length_immediate" "1")
13804    (set_attr "prefix" "maybe_vex,evex,orig,orig,vex,evex")
13805    (set_attr "mode" "TI")])
13807 (define_insn "*vec_extractv4si_zext"
13808   [(set (match_operand:DI 0 "register_operand" "=r,r")
13809         (zero_extend:DI
13810           (vec_select:SI
13811             (match_operand:V4SI 1 "register_operand" "x,v")
13812             (parallel [(match_operand:SI 2 "const_0_to_3_operand")]))))]
13813   "TARGET_64BIT && TARGET_SSE4_1"
13814   "%vpextrd\t{%2, %1, %k0|%k0, %1, %2}"
13815   [(set_attr "isa" "*,avx512dq")
13816    (set_attr "type" "sselog1")
13817    (set_attr "prefix_extra" "1")
13818    (set_attr "length_immediate" "1")
13819    (set_attr "prefix" "maybe_vex")
13820    (set_attr "mode" "TI")])
13822 (define_insn "*vec_extractv4si_mem"
13823   [(set (match_operand:SI 0 "register_operand" "=x,r")
13824         (vec_select:SI
13825           (match_operand:V4SI 1 "memory_operand" "o,o")
13826           (parallel [(match_operand 2 "const_0_to_3_operand")])))]
13827   "TARGET_SSE"
13828   "#")
13830 (define_insn_and_split "*vec_extractv4si_zext_mem"
13831   [(set (match_operand:DI 0 "register_operand" "=x,r")
13832         (zero_extend:DI
13833           (vec_select:SI
13834             (match_operand:V4SI 1 "memory_operand" "o,o")
13835             (parallel [(match_operand:SI 2 "const_0_to_3_operand")]))))]
13836   "TARGET_64BIT && TARGET_SSE"
13837   "#"
13838   "&& reload_completed"
13839   [(set (match_dup 0) (zero_extend:DI (match_dup 1)))]
13841   operands[1] = adjust_address (operands[1], SImode, INTVAL (operands[2]) * 4);
13844 (define_insn "*vec_extractv2di_1"
13845   [(set (match_operand:DI 0 "nonimmediate_operand"     "=rm,rm,m,x,x,Yv,x,v,r")
13846         (vec_select:DI
13847           (match_operand:V2DI 1 "nonimmediate_operand"  "x ,v ,v,0,x, v,x,o,o")
13848           (parallel [(const_int 1)])))]
13849   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13850   "@
13851    %vpextrq\t{$1, %1, %0|%0, %1, 1}
13852    vpextrq\t{$1, %1, %0|%0, %1, 1}
13853    %vmovhps\t{%1, %0|%0, %1}
13854    psrldq\t{$8, %0|%0, 8}
13855    vpsrldq\t{$8, %1, %0|%0, %1, 8}
13856    vpsrldq\t{$8, %1, %0|%0, %1, 8}
13857    movhlps\t{%1, %0|%0, %1}
13858    #
13859    #"
13860   [(set (attr "isa")
13861      (cond [(eq_attr "alternative" "0")
13862               (const_string "x64_sse4")
13863             (eq_attr "alternative" "1")
13864               (const_string "x64_avx512dq")
13865             (eq_attr "alternative" "3")
13866               (const_string "sse2_noavx")
13867             (eq_attr "alternative" "4")
13868               (const_string "avx")
13869             (eq_attr "alternative" "5")
13870               (const_string "avx512bw")
13871             (eq_attr "alternative" "6")
13872               (const_string "noavx")
13873             (eq_attr "alternative" "8")
13874               (const_string "x64")
13875            ]
13876            (const_string "*")))
13877    (set (attr "type")
13878      (cond [(eq_attr "alternative" "2,6,7")
13879               (const_string "ssemov")
13880             (eq_attr "alternative" "3,4,5")
13881               (const_string "sseishft1")
13882             (eq_attr "alternative" "8")
13883               (const_string "imov")
13884            ]
13885            (const_string "sselog1")))
13886    (set (attr "length_immediate")
13887      (if_then_else (eq_attr "alternative" "0,1,3,4,5")
13888                    (const_string "1")
13889                    (const_string "*")))
13890    (set (attr "prefix_rex")
13891      (if_then_else (eq_attr "alternative" "0,1")
13892                    (const_string "1")
13893                    (const_string "*")))
13894    (set (attr "prefix_extra")
13895      (if_then_else (eq_attr "alternative" "0,1")
13896                    (const_string "1")
13897                    (const_string "*")))
13898    (set_attr "prefix" "maybe_vex,evex,maybe_vex,orig,vex,evex,orig,*,*")
13899    (set_attr "mode" "TI,TI,V2SF,TI,TI,TI,V4SF,DI,DI")])
13901 (define_split
13902   [(set (match_operand:<ssescalarmode> 0 "register_operand")
13903         (vec_select:<ssescalarmode>
13904           (match_operand:VI_128 1 "memory_operand")
13905           (parallel
13906             [(match_operand 2 "const_0_to_<ssescalarnummask>_operand")])))]
13907   "TARGET_SSE && reload_completed"
13908   [(set (match_dup 0) (match_dup 1))]
13910   int offs = INTVAL (operands[2]) * GET_MODE_SIZE (<ssescalarmode>mode);
13912   operands[1] = adjust_address (operands[1], <ssescalarmode>mode, offs);
13915 (define_insn "*vec_extractv2ti"
13916   [(set (match_operand:TI 0 "nonimmediate_operand" "=xm,vm")
13917         (vec_select:TI
13918           (match_operand:V2TI 1 "register_operand" "x,v")
13919           (parallel
13920             [(match_operand:SI 2 "const_0_to_1_operand")])))]
13921   "TARGET_AVX"
13922   "@
13923    vextract%~128\t{%2, %1, %0|%0, %1, %2}
13924    vextracti32x4\t{%2, %g1, %0|%0, %g1, %2}"
13925   [(set_attr "type" "sselog")
13926    (set_attr "prefix_extra" "1")
13927    (set_attr "length_immediate" "1")
13928    (set_attr "prefix" "vex,evex")
13929    (set_attr "mode" "OI")])
13931 (define_insn "*vec_extractv4ti"
13932   [(set (match_operand:TI 0 "nonimmediate_operand" "=vm")
13933         (vec_select:TI
13934           (match_operand:V4TI 1 "register_operand" "v")
13935           (parallel
13936             [(match_operand:SI 2 "const_0_to_3_operand")])))]
13937   "TARGET_AVX512F"
13938   "vextracti32x4\t{%2, %1, %0|%0, %1, %2}"
13939   [(set_attr "type" "sselog")
13940    (set_attr "prefix_extra" "1")
13941    (set_attr "length_immediate" "1")
13942    (set_attr "prefix" "evex")
13943    (set_attr "mode" "XI")])
13945 (define_mode_iterator VEXTRACTI128_MODE
13946   [(V4TI "TARGET_AVX512F") V2TI])
13948 (define_split
13949   [(set (match_operand:TI 0 "nonimmediate_operand")
13950         (vec_select:TI
13951           (match_operand:VEXTRACTI128_MODE 1 "register_operand")
13952           (parallel [(const_int 0)])))]
13953   "TARGET_AVX
13954    && reload_completed
13955    && (TARGET_AVX512VL || !EXT_REX_SSE_REG_P (operands[1]))"
13956   [(set (match_dup 0) (match_dup 1))]
13957   "operands[1] = gen_lowpart (TImode, operands[1]);")
13959 ;; Turn SImode or DImode extraction from arbitrary SSE/AVX/AVX512F
13960 ;; vector modes into vec_extract*.
13961 (define_split
13962   [(set (match_operand:SWI48x 0 "nonimmediate_operand")
13963         (subreg:SWI48x (match_operand 1 "register_operand") 0))]
13964   "can_create_pseudo_p ()
13965    && REG_P (operands[1])
13966    && VECTOR_MODE_P (GET_MODE (operands[1]))
13967    && ((TARGET_SSE && GET_MODE_SIZE (GET_MODE (operands[1])) == 16)
13968        || (TARGET_AVX && GET_MODE_SIZE (GET_MODE (operands[1])) == 32)
13969        || (TARGET_AVX512F && GET_MODE_SIZE (GET_MODE (operands[1])) == 64))
13970    && (<MODE>mode == SImode || TARGET_64BIT || MEM_P (operands[0]))"
13971   [(set (match_dup 0) (vec_select:SWI48x (match_dup 1)
13972                                          (parallel [(const_int 0)])))]
13974   rtx tmp;
13976   switch (GET_MODE_SIZE (GET_MODE (operands[1])))
13977     {
13978     case 64:
13979       if (<MODE>mode == SImode)
13980         {
13981           tmp = gen_reg_rtx (V8SImode);
13982           emit_insn (gen_vec_extract_lo_v16si (tmp,
13983                                                gen_lowpart (V16SImode,
13984                                                             operands[1])));
13985         }
13986       else
13987         {
13988           tmp = gen_reg_rtx (V4DImode);
13989           emit_insn (gen_vec_extract_lo_v8di (tmp,
13990                                               gen_lowpart (V8DImode,
13991                                                            operands[1])));
13992         }
13993       operands[1] = tmp;
13994       /* FALLTHRU */
13995     case 32:
13996       tmp = gen_reg_rtx (<ssevecmode>mode);
13997       if (<MODE>mode == SImode)
13998         emit_insn (gen_vec_extract_lo_v8si (tmp, gen_lowpart (V8SImode,
13999                                                               operands[1])));
14000       else
14001         emit_insn (gen_vec_extract_lo_v4di (tmp, gen_lowpart (V4DImode,
14002                                                               operands[1])));
14003       operands[1] = tmp;
14004       break;
14005     case 16:
14006       operands[1] = gen_lowpart (<ssevecmode>mode, operands[1]);
14007       break;
14008     }
14011 (define_insn "*vec_concatv2si_sse4_1"
14012   [(set (match_operand:V2SI 0 "register_operand"
14013           "=Yr,*x, x, v,Yr,*x, v, v, *y,*y")
14014         (vec_concat:V2SI
14015           (match_operand:SI 1 "nonimmediate_operand"
14016           "  0, 0, x,Yv, 0, 0,Yv,rm,  0,rm")
14017           (match_operand:SI 2 "vector_move_operand"
14018           " rm,rm,rm,rm,Yr,*x,Yv, C,*ym, C")))]
14019   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
14020   "@
14021    pinsrd\t{$1, %2, %0|%0, %2, 1}
14022    pinsrd\t{$1, %2, %0|%0, %2, 1}
14023    vpinsrd\t{$1, %2, %1, %0|%0, %1, %2, 1}
14024    vpinsrd\t{$1, %2, %1, %0|%0, %1, %2, 1}
14025    punpckldq\t{%2, %0|%0, %2}
14026    punpckldq\t{%2, %0|%0, %2}
14027    vpunpckldq\t{%2, %1, %0|%0, %1, %2}
14028    %vmovd\t{%1, %0|%0, %1}
14029    punpckldq\t{%2, %0|%0, %2}
14030    movd\t{%1, %0|%0, %1}"
14031   [(set_attr "isa" "noavx,noavx,avx,avx512dq,noavx,noavx,avx,*,*,*")
14032    (set (attr "type")
14033      (cond [(eq_attr "alternative" "7")
14034               (const_string "ssemov")
14035             (eq_attr "alternative" "8")
14036               (const_string "mmxcvt")
14037             (eq_attr "alternative" "9")
14038               (const_string "mmxmov")
14039            ]
14040            (const_string "sselog")))
14041    (set (attr "prefix_extra")
14042      (if_then_else (eq_attr "alternative" "0,1,2,3")
14043                    (const_string "1")
14044                    (const_string "*")))
14045    (set (attr "length_immediate")
14046      (if_then_else (eq_attr "alternative" "0,1,2,3")
14047                    (const_string "1")
14048                    (const_string "*")))
14049    (set_attr "prefix" "orig,orig,vex,evex,orig,orig,maybe_evex,maybe_vex,orig,orig")
14050    (set_attr "mode" "TI,TI,TI,TI,TI,TI,TI,TI,DI,DI")])
14052 ;; ??? In theory we can match memory for the MMX alternative, but allowing
14053 ;; nonimmediate_operand for operand 2 and *not* allowing memory for the SSE
14054 ;; alternatives pretty much forces the MMX alternative to be chosen.
14055 (define_insn "*vec_concatv2si"
14056   [(set (match_operand:V2SI 0 "register_operand"     "=x,x ,*y,x,x,*y,*y")
14057         (vec_concat:V2SI
14058           (match_operand:SI 1 "nonimmediate_operand" " 0,rm,rm,0,m, 0,*rm")
14059           (match_operand:SI 2 "reg_or_0_operand"     " x,C ,C, x,C,*y,C")))]
14060   "TARGET_SSE && !TARGET_SSE4_1"
14061   "@
14062    punpckldq\t{%2, %0|%0, %2}
14063    movd\t{%1, %0|%0, %1}
14064    movd\t{%1, %0|%0, %1}
14065    unpcklps\t{%2, %0|%0, %2}
14066    movss\t{%1, %0|%0, %1}
14067    punpckldq\t{%2, %0|%0, %2}
14068    movd\t{%1, %0|%0, %1}"
14069   [(set_attr "isa" "sse2,sse2,sse2,*,*,*,*")
14070    (set_attr "type" "sselog,ssemov,mmxmov,sselog,ssemov,mmxcvt,mmxmov")
14071    (set_attr "mode" "TI,TI,DI,V4SF,SF,DI,DI")])
14073 (define_insn "*vec_concatv4si"
14074   [(set (match_operand:V4SI 0 "register_operand"       "=x,v,x,x,v")
14075         (vec_concat:V4SI
14076           (match_operand:V2SI 1 "register_operand"     " 0,v,0,0,v")
14077           (match_operand:V2SI 2 "nonimmediate_operand" " x,v,x,m,m")))]
14078   "TARGET_SSE"
14079   "@
14080    punpcklqdq\t{%2, %0|%0, %2}
14081    vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
14082    movlhps\t{%2, %0|%0, %2}
14083    movhps\t{%2, %0|%0, %q2}
14084    vmovhps\t{%2, %1, %0|%0, %1, %q2}"
14085   [(set_attr "isa" "sse2_noavx,avx,noavx,noavx,avx")
14086    (set_attr "type" "sselog,sselog,ssemov,ssemov,ssemov")
14087    (set_attr "prefix" "orig,maybe_evex,orig,orig,maybe_evex")
14088    (set_attr "mode" "TI,TI,V4SF,V2SF,V2SF")])
14090 ;; movd instead of movq is required to handle broken assemblers.
14091 (define_insn "vec_concatv2di"
14092   [(set (match_operand:V2DI 0 "register_operand"
14093           "=Yr,*x,x ,v ,v,v ,x   ,x,v ,x,x,v")
14094         (vec_concat:V2DI
14095           (match_operand:DI 1 "nonimmediate_operand"
14096           "  0, 0,x ,Yv,r,vm,?!*y,0,Yv,0,0,v")
14097           (match_operand:DI 2 "vector_move_operand"
14098           " rm,rm,rm,rm,C ,C ,C ,x,Yv,x,m,m")))]
14099   "TARGET_SSE"
14100   "@
14101    pinsrq\t{$1, %2, %0|%0, %2, 1}
14102    pinsrq\t{$1, %2, %0|%0, %2, 1}
14103    vpinsrq\t{$1, %2, %1, %0|%0, %1, %2, 1}
14104    vpinsrq\t{$1, %2, %1, %0|%0, %1, %2, 1}
14105    * return HAVE_AS_IX86_INTERUNIT_MOVQ ? \"%vmovq\t{%1, %0|%0, %1}\" : \"%vmovd\t{%1, %0|%0, %1}\";
14106    %vmovq\t{%1, %0|%0, %1}
14107    movq2dq\t{%1, %0|%0, %1}
14108    punpcklqdq\t{%2, %0|%0, %2}
14109    vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
14110    movlhps\t{%2, %0|%0, %2}
14111    movhps\t{%2, %0|%0, %2}
14112    vmovhps\t{%2, %1, %0|%0, %1, %2}"
14113   [(set (attr "isa")
14114      (cond [(eq_attr "alternative" "0,1")
14115               (const_string "x64_sse4_noavx")
14116             (eq_attr "alternative" "2")
14117               (const_string "x64_avx")
14118             (eq_attr "alternative" "3")
14119               (const_string "x64_avx512dq")
14120             (eq_attr "alternative" "4")
14121               (const_string "x64_sse2")
14122             (eq_attr "alternative" "5,6")
14123               (const_string "sse2")
14124             (eq_attr "alternative" "7")
14125               (const_string "sse2_noavx")
14126             (eq_attr "alternative" "8,11")
14127               (const_string "avx")
14128            ]
14129            (const_string "noavx")))
14130    (set (attr "type")
14131      (if_then_else
14132        (eq_attr "alternative" "0,1,2,3,7,8")
14133        (const_string "sselog")
14134        (const_string "ssemov")))
14135    (set (attr "prefix_rex")
14136      (if_then_else (eq_attr "alternative" "0,1,2,3,4")
14137                    (const_string "1")
14138                    (const_string "*")))
14139    (set (attr "prefix_extra")
14140      (if_then_else (eq_attr "alternative" "0,1,2,3")
14141                    (const_string "1")
14142                    (const_string "*")))
14143    (set (attr "length_immediate")
14144      (if_then_else (eq_attr "alternative" "0,1,2,3")
14145                    (const_string "1")
14146                    (const_string "*")))
14147    (set (attr "prefix")
14148      (cond [(eq_attr "alternative" "2")
14149               (const_string "vex")
14150             (eq_attr "alternative" "3")
14151               (const_string "evex")
14152             (eq_attr "alternative" "4,5")
14153               (const_string "maybe_vex")
14154             (eq_attr "alternative" "8,11")
14155               (const_string "maybe_evex")
14156            ]
14157            (const_string "orig")))
14158    (set_attr "mode" "TI,TI,TI,TI,TI,TI,TI,TI,TI,V4SF,V2SF,V2SF")
14159    (set (attr "preferred_for_speed")
14160      (cond [(eq_attr "alternative" "4")
14161               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
14162             (eq_attr "alternative" "6")
14163               (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
14164            ]
14165            (symbol_ref "true")))])
14167 ;; vmovq clears also the higher bits.
14168 (define_insn "vec_set<mode>_0"
14169   [(set (match_operand:VI8_AVX_AVX512F 0 "register_operand" "=v,v")
14170         (vec_merge:VI8_AVX_AVX512F
14171           (vec_duplicate:VI8_AVX_AVX512F
14172             (match_operand:<ssescalarmode> 2 "general_operand" "r,vm"))
14173           (match_operand:VI8_AVX_AVX512F 1 "const0_operand" "C,C")
14174           (const_int 1)))]
14175   "TARGET_AVX"
14176   "vmovq\t{%2, %x0|%x0, %2}"
14177   [(set_attr "isa" "x64,*")
14178    (set_attr "type" "ssemov")
14179    (set_attr "prefix_rex" "1,*")
14180    (set_attr "prefix" "maybe_evex")
14181    (set_attr "mode" "TI")
14182    (set (attr "preferred_for_speed")
14183      (cond [(eq_attr "alternative" "0")
14184               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
14185            ]
14186            (symbol_ref "true")))])
14188 (define_expand "vec_unpacks_lo_<mode>"
14189   [(match_operand:<sseunpackmode> 0 "register_operand")
14190    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
14191   "TARGET_SSE2"
14192   "ix86_expand_sse_unpack (operands[0], operands[1], false, false); DONE;")
14194 (define_expand "vec_unpacks_hi_<mode>"
14195   [(match_operand:<sseunpackmode> 0 "register_operand")
14196    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
14197   "TARGET_SSE2"
14198   "ix86_expand_sse_unpack (operands[0], operands[1], false, true); DONE;")
14200 (define_expand "vec_unpacku_lo_<mode>"
14201   [(match_operand:<sseunpackmode> 0 "register_operand")
14202    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
14203   "TARGET_SSE2"
14204   "ix86_expand_sse_unpack (operands[0], operands[1], true, false); DONE;")
14206 (define_expand "vec_unpacks_lo_hi"
14207   [(set (subreg:HI (match_operand:QI 0 "register_operand") 0)
14208         (match_operand:HI 1 "register_operand"))]
14209   "TARGET_AVX512F")
14211 (define_expand "vec_unpacks_lo_si"
14212   [(set (match_operand:HI 0 "register_operand")
14213         (subreg:HI (match_operand:SI 1 "register_operand") 0))]
14214   "TARGET_AVX512F")
14216 (define_expand "vec_unpacks_lo_di"
14217   [(set (match_operand:SI 0 "register_operand")
14218         (subreg:SI (match_operand:DI 1 "register_operand") 0))]
14219   "TARGET_AVX512BW")
14221 (define_expand "vec_unpacku_hi_<mode>"
14222   [(match_operand:<sseunpackmode> 0 "register_operand")
14223    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
14224   "TARGET_SSE2"
14225   "ix86_expand_sse_unpack (operands[0], operands[1], true, true); DONE;")
14227 (define_expand "vec_unpacks_hi_hi"
14228   [(parallel
14229      [(set (subreg:HI (match_operand:QI 0 "register_operand") 0)
14230            (lshiftrt:HI (match_operand:HI 1 "register_operand")
14231                         (const_int 8)))
14232       (unspec [(const_int 0)] UNSPEC_MASKOP)])]
14233   "TARGET_AVX512F")
14235 (define_expand "vec_unpacks_hi_<mode>"
14236   [(parallel
14237      [(set (subreg:SWI48x
14238              (match_operand:<HALFMASKMODE> 0 "register_operand") 0)
14239            (lshiftrt:SWI48x (match_operand:SWI48x 1 "register_operand")
14240                             (match_dup 2)))
14241       (unspec [(const_int 0)] UNSPEC_MASKOP)])]
14242   "TARGET_AVX512BW"
14243   "operands[2] = GEN_INT (GET_MODE_BITSIZE (<HALFMASKMODE>mode));")
14245 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14247 ;; Miscellaneous
14249 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14251 (define_expand "<sse2_avx2>_uavg<mode>3<mask_name>"
14252   [(set (match_operand:VI12_AVX2 0 "register_operand")
14253         (truncate:VI12_AVX2
14254           (lshiftrt:<ssedoublemode>
14255             (plus:<ssedoublemode>
14256               (plus:<ssedoublemode>
14257                 (zero_extend:<ssedoublemode>
14258                   (match_operand:VI12_AVX2 1 "vector_operand"))
14259                 (zero_extend:<ssedoublemode>
14260                   (match_operand:VI12_AVX2 2 "vector_operand")))
14261               (match_dup <mask_expand_op3>))
14262             (const_int 1))))]
14263   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
14265   rtx tmp;
14266   if (<mask_applied>)
14267     tmp = operands[3];
14268   operands[3] = CONST1_RTX(<MODE>mode);
14269   ix86_fixup_binary_operands_no_copy (PLUS, <MODE>mode, operands);
14271   if (<mask_applied>)
14272     {
14273       operands[5] = operands[3];
14274       operands[3] = tmp;
14275     }
14278 (define_insn "*<sse2_avx2>_uavg<mode>3<mask_name>"
14279   [(set (match_operand:VI12_AVX2 0 "register_operand" "=x,v")
14280         (truncate:VI12_AVX2
14281           (lshiftrt:<ssedoublemode>
14282             (plus:<ssedoublemode>
14283               (plus:<ssedoublemode>
14284                 (zero_extend:<ssedoublemode>
14285                   (match_operand:VI12_AVX2 1 "vector_operand" "%0,v"))
14286                 (zero_extend:<ssedoublemode>
14287                   (match_operand:VI12_AVX2 2 "vector_operand" "xBm,vm")))
14288               (match_operand:VI12_AVX2 <mask_expand_op3> "const1_operand"))
14289             (const_int 1))))]
14290   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
14291    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
14292   "@
14293    pavg<ssemodesuffix>\t{%2, %0|%0, %2}
14294    vpavg<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14295   [(set_attr "isa" "noavx,avx")
14296    (set_attr "type" "sseiadd")
14297    (set_attr "prefix_data16" "1,*")
14298    (set_attr "prefix" "orig,<mask_prefix>")
14299    (set_attr "mode" "<sseinsnmode>")])
14301 ;; The correct representation for this is absolutely enormous, and
14302 ;; surely not generally useful.
14303 (define_insn "<sse2_avx2>_psadbw"
14304   [(set (match_operand:VI8_AVX2_AVX512BW 0 "register_operand" "=x,v")
14305         (unspec:VI8_AVX2_AVX512BW
14306           [(match_operand:<ssebytemode> 1 "register_operand" "0,v")
14307            (match_operand:<ssebytemode> 2 "vector_operand" "xBm,vm")]
14308           UNSPEC_PSADBW))]
14309   "TARGET_SSE2"
14310   "@
14311    psadbw\t{%2, %0|%0, %2}
14312    vpsadbw\t{%2, %1, %0|%0, %1, %2}"
14313   [(set_attr "isa" "noavx,avx")
14314    (set_attr "type" "sseiadd")
14315    (set_attr "atom_unit" "simul")
14316    (set_attr "prefix_data16" "1,*")
14317    (set_attr "prefix" "orig,maybe_evex")
14318    (set_attr "mode" "<sseinsnmode>")])
14320 (define_insn "<sse>_movmsk<ssemodesuffix><avxsizesuffix>"
14321   [(set (match_operand:SI 0 "register_operand" "=r")
14322         (unspec:SI
14323           [(match_operand:VF_128_256 1 "register_operand" "x")]
14324           UNSPEC_MOVMSK))]
14325   "TARGET_SSE"
14326   "%vmovmsk<ssemodesuffix>\t{%1, %0|%0, %1}"
14327   [(set_attr "type" "ssemov")
14328    (set_attr "prefix" "maybe_vex")
14329    (set_attr "mode" "<MODE>")])
14331 (define_insn "*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_zext"
14332   [(set (match_operand:DI 0 "register_operand" "=r")
14333         (zero_extend:DI
14334           (unspec:SI
14335             [(match_operand:VF_128_256 1 "register_operand" "x")]
14336             UNSPEC_MOVMSK)))]
14337   "TARGET_64BIT && TARGET_SSE"
14338   "%vmovmsk<ssemodesuffix>\t{%1, %k0|%k0, %1}"
14339   [(set_attr "type" "ssemov")
14340    (set_attr "prefix" "maybe_vex")
14341    (set_attr "mode" "<MODE>")])
14343 (define_insn "<sse2_avx2>_pmovmskb"
14344   [(set (match_operand:SI 0 "register_operand" "=r")
14345         (unspec:SI
14346           [(match_operand:VI1_AVX2 1 "register_operand" "x")]
14347           UNSPEC_MOVMSK))]
14348   "TARGET_SSE2"
14349   "%vpmovmskb\t{%1, %0|%0, %1}"
14350   [(set_attr "type" "ssemov")
14351    (set (attr "prefix_data16")
14352      (if_then_else
14353        (match_test "TARGET_AVX")
14354      (const_string "*")
14355      (const_string "1")))
14356    (set_attr "prefix" "maybe_vex")
14357    (set_attr "mode" "SI")])
14359 (define_insn "*<sse2_avx2>_pmovmskb_zext"
14360   [(set (match_operand:DI 0 "register_operand" "=r")
14361         (zero_extend:DI
14362           (unspec:SI
14363             [(match_operand:VI1_AVX2 1 "register_operand" "x")]
14364             UNSPEC_MOVMSK)))]
14365   "TARGET_64BIT && TARGET_SSE2"
14366   "%vpmovmskb\t{%1, %k0|%k0, %1}"
14367   [(set_attr "type" "ssemov")
14368    (set (attr "prefix_data16")
14369      (if_then_else
14370        (match_test "TARGET_AVX")
14371      (const_string "*")
14372      (const_string "1")))
14373    (set_attr "prefix" "maybe_vex")
14374    (set_attr "mode" "SI")])
14376 (define_expand "sse2_maskmovdqu"
14377   [(set (match_operand:V16QI 0 "memory_operand")
14378         (unspec:V16QI [(match_operand:V16QI 1 "register_operand")
14379                        (match_operand:V16QI 2 "register_operand")
14380                        (match_dup 0)]
14381                       UNSPEC_MASKMOV))]
14382   "TARGET_SSE2")
14384 (define_insn "*sse2_maskmovdqu"
14385   [(set (mem:V16QI (match_operand:P 0 "register_operand" "D"))
14386         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "x")
14387                        (match_operand:V16QI 2 "register_operand" "x")
14388                        (mem:V16QI (match_dup 0))]
14389                       UNSPEC_MASKMOV))]
14390   "TARGET_SSE2"
14392   /* We can't use %^ here due to ASM_OUTPUT_OPCODE processing
14393      that requires %v to be at the beginning of the opcode name.  */
14394   if (Pmode != word_mode)
14395     fputs ("\taddr32", asm_out_file);
14396   return "%vmaskmovdqu\t{%2, %1|%1, %2}";
14398   [(set_attr "type" "ssemov")
14399    (set_attr "prefix_data16" "1")
14400    (set (attr "length_address")
14401      (symbol_ref ("Pmode != word_mode")))
14402    ;; The implicit %rdi operand confuses default length_vex computation.
14403    (set (attr "length_vex")
14404      (symbol_ref ("3 + REX_SSE_REGNO_P (REGNO (operands[2]))")))
14405    (set_attr "prefix" "maybe_vex")
14406    (set_attr "znver1_decode" "vector")
14407    (set_attr "mode" "TI")])
14409 (define_insn "sse_ldmxcsr"
14410   [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m")]
14411                     UNSPECV_LDMXCSR)]
14412   "TARGET_SSE"
14413   "%vldmxcsr\t%0"
14414   [(set_attr "type" "sse")
14415    (set_attr "atom_sse_attr" "mxcsr")
14416    (set_attr "prefix" "maybe_vex")
14417    (set_attr "memory" "load")])
14419 (define_insn "sse_stmxcsr"
14420   [(set (match_operand:SI 0 "memory_operand" "=m")
14421         (unspec_volatile:SI [(const_int 0)] UNSPECV_STMXCSR))]
14422   "TARGET_SSE"
14423   "%vstmxcsr\t%0"
14424   [(set_attr "type" "sse")
14425    (set_attr "atom_sse_attr" "mxcsr")
14426    (set_attr "prefix" "maybe_vex")
14427    (set_attr "memory" "store")])
14429 (define_insn "sse2_clflush"
14430   [(unspec_volatile [(match_operand 0 "address_operand" "p")]
14431                     UNSPECV_CLFLUSH)]
14432   "TARGET_SSE2"
14433   "clflush\t%a0"
14434   [(set_attr "type" "sse")
14435    (set_attr "atom_sse_attr" "fence")
14436    (set_attr "memory" "unknown")])
14438 ;; As per AMD and Intel ISA manuals, the first operand is extensions
14439 ;; and it goes to %ecx. The second operand received is hints and it goes
14440 ;; to %eax.
14441 (define_insn "sse3_mwait"
14442   [(unspec_volatile [(match_operand:SI 0 "register_operand" "c")
14443                      (match_operand:SI 1 "register_operand" "a")]
14444                     UNSPECV_MWAIT)]
14445   "TARGET_SSE3"
14446 ;; 64bit version is "mwait %rax,%rcx". But only lower 32bits are used.
14447 ;; Since 32bit register operands are implicitly zero extended to 64bit,
14448 ;; we only need to set up 32bit registers.
14449   "mwait"
14450   [(set_attr "length" "3")])
14452 (define_insn "sse3_monitor_<mode>"
14453   [(unspec_volatile [(match_operand:P 0 "register_operand" "a")
14454                      (match_operand:SI 1 "register_operand" "c")
14455                      (match_operand:SI 2 "register_operand" "d")]
14456                     UNSPECV_MONITOR)]
14457   "TARGET_SSE3"
14458 ;; 64bit version is "monitor %rax,%rcx,%rdx". But only lower 32bits in
14459 ;; RCX and RDX are used.  Since 32bit register operands are implicitly
14460 ;; zero extended to 64bit, we only need to set up 32bit registers.
14461   "%^monitor"
14462   [(set (attr "length")
14463      (symbol_ref ("(Pmode != word_mode) + 3")))])
14465 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14467 ;; SSSE3 instructions
14469 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14471 (define_code_iterator ssse3_plusminus [plus ss_plus minus ss_minus])
14473 (define_insn "avx2_ph<plusminus_mnemonic>wv16hi3"
14474   [(set (match_operand:V16HI 0 "register_operand" "=x")
14475         (vec_concat:V16HI
14476           (vec_concat:V8HI
14477             (vec_concat:V4HI
14478               (vec_concat:V2HI
14479                 (ssse3_plusminus:HI
14480                   (vec_select:HI
14481                     (match_operand:V16HI 1 "register_operand" "x")
14482                     (parallel [(const_int 0)]))
14483                   (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
14484                 (ssse3_plusminus:HI
14485                   (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
14486                   (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
14487               (vec_concat:V2HI
14488                 (ssse3_plusminus:HI
14489                   (vec_select:HI (match_dup 1) (parallel [(const_int 4)]))
14490                   (vec_select:HI (match_dup 1) (parallel [(const_int 5)])))
14491                 (ssse3_plusminus:HI
14492                   (vec_select:HI (match_dup 1) (parallel [(const_int 6)]))
14493                   (vec_select:HI (match_dup 1) (parallel [(const_int 7)])))))
14494             (vec_concat:V4HI
14495               (vec_concat:V2HI
14496                 (ssse3_plusminus:HI
14497                   (vec_select:HI (match_dup 1) (parallel [(const_int 8)]))
14498                   (vec_select:HI (match_dup 1) (parallel [(const_int 9)])))
14499                 (ssse3_plusminus:HI
14500                   (vec_select:HI (match_dup 1) (parallel [(const_int 10)]))
14501                   (vec_select:HI (match_dup 1) (parallel [(const_int 11)]))))
14502               (vec_concat:V2HI
14503                 (ssse3_plusminus:HI
14504                   (vec_select:HI (match_dup 1) (parallel [(const_int 12)]))
14505                   (vec_select:HI (match_dup 1) (parallel [(const_int 13)])))
14506                 (ssse3_plusminus:HI
14507                   (vec_select:HI (match_dup 1) (parallel [(const_int 14)]))
14508                   (vec_select:HI (match_dup 1) (parallel [(const_int 15)]))))))
14509           (vec_concat:V8HI
14510             (vec_concat:V4HI
14511               (vec_concat:V2HI
14512                 (ssse3_plusminus:HI
14513                   (vec_select:HI
14514                     (match_operand:V16HI 2 "nonimmediate_operand" "xm")
14515                     (parallel [(const_int 0)]))
14516                   (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
14517                 (ssse3_plusminus:HI
14518                   (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
14519                   (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))
14520               (vec_concat:V2HI
14521                 (ssse3_plusminus:HI
14522                   (vec_select:HI (match_dup 2) (parallel [(const_int 4)]))
14523                   (vec_select:HI (match_dup 2) (parallel [(const_int 5)])))
14524                 (ssse3_plusminus:HI
14525                   (vec_select:HI (match_dup 2) (parallel [(const_int 6)]))
14526                   (vec_select:HI (match_dup 2) (parallel [(const_int 7)])))))
14527             (vec_concat:V4HI
14528               (vec_concat:V2HI
14529                 (ssse3_plusminus:HI
14530                   (vec_select:HI (match_dup 2) (parallel [(const_int 8)]))
14531                   (vec_select:HI (match_dup 2) (parallel [(const_int 9)])))
14532                 (ssse3_plusminus:HI
14533                   (vec_select:HI (match_dup 2) (parallel [(const_int 10)]))
14534                   (vec_select:HI (match_dup 2) (parallel [(const_int 11)]))))
14535               (vec_concat:V2HI
14536                 (ssse3_plusminus:HI
14537                   (vec_select:HI (match_dup 2) (parallel [(const_int 12)]))
14538                   (vec_select:HI (match_dup 2) (parallel [(const_int 13)])))
14539                 (ssse3_plusminus:HI
14540                   (vec_select:HI (match_dup 2) (parallel [(const_int 14)]))
14541                   (vec_select:HI (match_dup 2) (parallel [(const_int 15)]))))))))]
14542   "TARGET_AVX2"
14543   "vph<plusminus_mnemonic>w\t{%2, %1, %0|%0, %1, %2}"
14544   [(set_attr "type" "sseiadd")
14545    (set_attr "prefix_extra" "1")
14546    (set_attr "prefix" "vex")
14547    (set_attr "mode" "OI")])
14549 (define_insn "ssse3_ph<plusminus_mnemonic>wv8hi3"
14550   [(set (match_operand:V8HI 0 "register_operand" "=x,x")
14551         (vec_concat:V8HI
14552           (vec_concat:V4HI
14553             (vec_concat:V2HI
14554               (ssse3_plusminus:HI
14555                 (vec_select:HI
14556                   (match_operand:V8HI 1 "register_operand" "0,x")
14557                   (parallel [(const_int 0)]))
14558                 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
14559               (ssse3_plusminus:HI
14560                 (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
14561                 (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
14562             (vec_concat:V2HI
14563               (ssse3_plusminus:HI
14564                 (vec_select:HI (match_dup 1) (parallel [(const_int 4)]))
14565                 (vec_select:HI (match_dup 1) (parallel [(const_int 5)])))
14566               (ssse3_plusminus:HI
14567                 (vec_select:HI (match_dup 1) (parallel [(const_int 6)]))
14568                 (vec_select:HI (match_dup 1) (parallel [(const_int 7)])))))
14569           (vec_concat:V4HI
14570             (vec_concat:V2HI
14571               (ssse3_plusminus:HI
14572                 (vec_select:HI
14573                   (match_operand:V8HI 2 "vector_operand" "xBm,xm")
14574                   (parallel [(const_int 0)]))
14575                 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
14576               (ssse3_plusminus:HI
14577                 (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
14578                 (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))
14579             (vec_concat:V2HI
14580               (ssse3_plusminus:HI
14581                 (vec_select:HI (match_dup 2) (parallel [(const_int 4)]))
14582                 (vec_select:HI (match_dup 2) (parallel [(const_int 5)])))
14583               (ssse3_plusminus:HI
14584                 (vec_select:HI (match_dup 2) (parallel [(const_int 6)]))
14585                 (vec_select:HI (match_dup 2) (parallel [(const_int 7)])))))))]
14586   "TARGET_SSSE3"
14587   "@
14588    ph<plusminus_mnemonic>w\t{%2, %0|%0, %2}
14589    vph<plusminus_mnemonic>w\t{%2, %1, %0|%0, %1, %2}"
14590   [(set_attr "isa" "noavx,avx")
14591    (set_attr "type" "sseiadd")
14592    (set_attr "atom_unit" "complex")
14593    (set_attr "prefix_data16" "1,*")
14594    (set_attr "prefix_extra" "1")
14595    (set_attr "prefix" "orig,vex")
14596    (set_attr "mode" "TI")])
14598 (define_insn "ssse3_ph<plusminus_mnemonic>wv4hi3"
14599   [(set (match_operand:V4HI 0 "register_operand" "=y")
14600         (vec_concat:V4HI
14601           (vec_concat:V2HI
14602             (ssse3_plusminus:HI
14603               (vec_select:HI
14604                 (match_operand:V4HI 1 "register_operand" "0")
14605                 (parallel [(const_int 0)]))
14606               (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
14607             (ssse3_plusminus:HI
14608               (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
14609               (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
14610           (vec_concat:V2HI
14611             (ssse3_plusminus:HI
14612               (vec_select:HI
14613                 (match_operand:V4HI 2 "nonimmediate_operand" "ym")
14614                 (parallel [(const_int 0)]))
14615               (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
14616             (ssse3_plusminus:HI
14617               (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
14618               (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))))]
14619   "TARGET_SSSE3"
14620   "ph<plusminus_mnemonic>w\t{%2, %0|%0, %2}"
14621   [(set_attr "type" "sseiadd")
14622    (set_attr "atom_unit" "complex")
14623    (set_attr "prefix_extra" "1")
14624    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14625    (set_attr "mode" "DI")])
14627 (define_insn "avx2_ph<plusminus_mnemonic>dv8si3"
14628   [(set (match_operand:V8SI 0 "register_operand" "=x")
14629         (vec_concat:V8SI
14630           (vec_concat:V4SI
14631             (vec_concat:V2SI
14632               (plusminus:SI
14633                 (vec_select:SI
14634                   (match_operand:V8SI 1 "register_operand" "x")
14635                   (parallel [(const_int 0)]))
14636                 (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
14637               (plusminus:SI
14638                 (vec_select:SI (match_dup 1) (parallel [(const_int 2)]))
14639                 (vec_select:SI (match_dup 1) (parallel [(const_int 3)]))))
14640             (vec_concat:V2SI
14641               (plusminus:SI
14642                 (vec_select:SI (match_dup 1) (parallel [(const_int 4)]))
14643                 (vec_select:SI (match_dup 1) (parallel [(const_int 5)])))
14644               (plusminus:SI
14645                 (vec_select:SI (match_dup 1) (parallel [(const_int 6)]))
14646                 (vec_select:SI (match_dup 1) (parallel [(const_int 7)])))))
14647           (vec_concat:V4SI
14648             (vec_concat:V2SI
14649               (plusminus:SI
14650                 (vec_select:SI
14651                   (match_operand:V8SI 2 "nonimmediate_operand" "xm")
14652                   (parallel [(const_int 0)]))
14653                 (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))
14654               (plusminus:SI
14655                 (vec_select:SI (match_dup 2) (parallel [(const_int 2)]))
14656                 (vec_select:SI (match_dup 2) (parallel [(const_int 3)]))))
14657             (vec_concat:V2SI
14658               (plusminus:SI
14659                 (vec_select:SI (match_dup 2) (parallel [(const_int 4)]))
14660                 (vec_select:SI (match_dup 2) (parallel [(const_int 5)])))
14661               (plusminus:SI
14662                 (vec_select:SI (match_dup 2) (parallel [(const_int 6)]))
14663                 (vec_select:SI (match_dup 2) (parallel [(const_int 7)])))))))]
14664   "TARGET_AVX2"
14665   "vph<plusminus_mnemonic>d\t{%2, %1, %0|%0, %1, %2}"
14666   [(set_attr "type" "sseiadd")
14667    (set_attr "prefix_extra" "1")
14668    (set_attr "prefix" "vex")
14669    (set_attr "mode" "OI")])
14671 (define_insn "ssse3_ph<plusminus_mnemonic>dv4si3"
14672   [(set (match_operand:V4SI 0 "register_operand" "=x,x")
14673         (vec_concat:V4SI
14674           (vec_concat:V2SI
14675             (plusminus:SI
14676               (vec_select:SI
14677                 (match_operand:V4SI 1 "register_operand" "0,x")
14678                 (parallel [(const_int 0)]))
14679               (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
14680             (plusminus:SI
14681               (vec_select:SI (match_dup 1) (parallel [(const_int 2)]))
14682               (vec_select:SI (match_dup 1) (parallel [(const_int 3)]))))
14683           (vec_concat:V2SI
14684             (plusminus:SI
14685               (vec_select:SI
14686                 (match_operand:V4SI 2 "vector_operand" "xBm,xm")
14687                 (parallel [(const_int 0)]))
14688               (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))
14689             (plusminus:SI
14690               (vec_select:SI (match_dup 2) (parallel [(const_int 2)]))
14691               (vec_select:SI (match_dup 2) (parallel [(const_int 3)]))))))]
14692   "TARGET_SSSE3"
14693   "@
14694    ph<plusminus_mnemonic>d\t{%2, %0|%0, %2}
14695    vph<plusminus_mnemonic>d\t{%2, %1, %0|%0, %1, %2}"
14696   [(set_attr "isa" "noavx,avx")
14697    (set_attr "type" "sseiadd")
14698    (set_attr "atom_unit" "complex")
14699    (set_attr "prefix_data16" "1,*")
14700    (set_attr "prefix_extra" "1")
14701    (set_attr "prefix" "orig,vex")
14702    (set_attr "mode" "TI")])
14704 (define_insn "ssse3_ph<plusminus_mnemonic>dv2si3"
14705   [(set (match_operand:V2SI 0 "register_operand" "=y")
14706         (vec_concat:V2SI
14707           (plusminus:SI
14708             (vec_select:SI
14709               (match_operand:V2SI 1 "register_operand" "0")
14710               (parallel [(const_int 0)]))
14711             (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
14712           (plusminus:SI
14713             (vec_select:SI
14714               (match_operand:V2SI 2 "nonimmediate_operand" "ym")
14715               (parallel [(const_int 0)]))
14716             (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))))]
14717   "TARGET_SSSE3"
14718   "ph<plusminus_mnemonic>d\t{%2, %0|%0, %2}"
14719   [(set_attr "type" "sseiadd")
14720    (set_attr "atom_unit" "complex")
14721    (set_attr "prefix_extra" "1")
14722    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14723    (set_attr "mode" "DI")])
14725 (define_insn "avx2_pmaddubsw256"
14726   [(set (match_operand:V16HI 0 "register_operand" "=x,v")
14727         (ss_plus:V16HI
14728           (mult:V16HI
14729             (zero_extend:V16HI
14730               (vec_select:V16QI
14731                 (match_operand:V32QI 1 "register_operand" "x,v")
14732                 (parallel [(const_int 0) (const_int 2)
14733                            (const_int 4) (const_int 6)
14734                            (const_int 8) (const_int 10)
14735                            (const_int 12) (const_int 14)
14736                            (const_int 16) (const_int 18)
14737                            (const_int 20) (const_int 22)
14738                            (const_int 24) (const_int 26)
14739                            (const_int 28) (const_int 30)])))
14740             (sign_extend:V16HI
14741               (vec_select:V16QI
14742                 (match_operand:V32QI 2 "nonimmediate_operand" "xm,vm")
14743                 (parallel [(const_int 0) (const_int 2)
14744                            (const_int 4) (const_int 6)
14745                            (const_int 8) (const_int 10)
14746                            (const_int 12) (const_int 14)
14747                            (const_int 16) (const_int 18)
14748                            (const_int 20) (const_int 22)
14749                            (const_int 24) (const_int 26)
14750                            (const_int 28) (const_int 30)]))))
14751           (mult:V16HI
14752             (zero_extend:V16HI
14753               (vec_select:V16QI (match_dup 1)
14754                 (parallel [(const_int 1) (const_int 3)
14755                            (const_int 5) (const_int 7)
14756                            (const_int 9) (const_int 11)
14757                            (const_int 13) (const_int 15)
14758                            (const_int 17) (const_int 19)
14759                            (const_int 21) (const_int 23)
14760                            (const_int 25) (const_int 27)
14761                            (const_int 29) (const_int 31)])))
14762             (sign_extend:V16HI
14763               (vec_select:V16QI (match_dup 2)
14764                 (parallel [(const_int 1) (const_int 3)
14765                            (const_int 5) (const_int 7)
14766                            (const_int 9) (const_int 11)
14767                            (const_int 13) (const_int 15)
14768                            (const_int 17) (const_int 19)
14769                            (const_int 21) (const_int 23)
14770                            (const_int 25) (const_int 27)
14771                            (const_int 29) (const_int 31)]))))))]
14772   "TARGET_AVX2"
14773   "vpmaddubsw\t{%2, %1, %0|%0, %1, %2}"
14774   [(set_attr "isa" "*,avx512bw")
14775    (set_attr "type" "sseiadd")
14776    (set_attr "prefix_extra" "1")
14777    (set_attr "prefix" "vex,evex")
14778    (set_attr "mode" "OI")])
14780 ;; The correct representation for this is absolutely enormous, and
14781 ;; surely not generally useful.
14782 (define_insn "avx512bw_pmaddubsw512<mode><mask_name>"
14783   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
14784           (unspec:VI2_AVX512VL
14785             [(match_operand:<dbpsadbwmode> 1 "register_operand" "v")
14786              (match_operand:<dbpsadbwmode> 2 "nonimmediate_operand" "vm")]
14787              UNSPEC_PMADDUBSW512))]
14788    "TARGET_AVX512BW"
14789    "vpmaddubsw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}";
14790   [(set_attr "type" "sseiadd")
14791    (set_attr "prefix" "evex")
14792    (set_attr "mode" "XI")])
14794 (define_insn "avx512bw_umulhrswv32hi3<mask_name>"
14795   [(set (match_operand:V32HI 0 "register_operand" "=v")
14796         (truncate:V32HI
14797           (lshiftrt:V32SI
14798             (plus:V32SI
14799               (lshiftrt:V32SI
14800                 (mult:V32SI
14801                   (sign_extend:V32SI
14802                     (match_operand:V32HI 1 "nonimmediate_operand" "%v"))
14803                   (sign_extend:V32SI
14804                     (match_operand:V32HI 2 "nonimmediate_operand" "vm")))
14805                 (const_int 14))
14806               (const_vector:V32HI [(const_int 1) (const_int 1)
14807                                    (const_int 1) (const_int 1)
14808                                    (const_int 1) (const_int 1)
14809                                    (const_int 1) (const_int 1)
14810                                    (const_int 1) (const_int 1)
14811                                    (const_int 1) (const_int 1)
14812                                    (const_int 1) (const_int 1)
14813                                    (const_int 1) (const_int 1)
14814                                    (const_int 1) (const_int 1)
14815                                    (const_int 1) (const_int 1)
14816                                    (const_int 1) (const_int 1)
14817                                    (const_int 1) (const_int 1)
14818                                    (const_int 1) (const_int 1)
14819                                    (const_int 1) (const_int 1)
14820                                    (const_int 1) (const_int 1)
14821                                    (const_int 1) (const_int 1)]))
14822             (const_int 1))))]
14823   "TARGET_AVX512BW"
14824   "vpmulhrsw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14825   [(set_attr "type" "sseimul")
14826    (set_attr "prefix" "evex")
14827    (set_attr "mode" "XI")])
14829 (define_insn "ssse3_pmaddubsw128"
14830   [(set (match_operand:V8HI 0 "register_operand" "=x,x,v")
14831         (ss_plus:V8HI
14832           (mult:V8HI
14833             (zero_extend:V8HI
14834               (vec_select:V8QI
14835                 (match_operand:V16QI 1 "register_operand" "0,x,v")
14836                 (parallel [(const_int 0) (const_int 2)
14837                            (const_int 4) (const_int 6)
14838                            (const_int 8) (const_int 10)
14839                            (const_int 12) (const_int 14)])))
14840             (sign_extend:V8HI
14841               (vec_select:V8QI
14842                 (match_operand:V16QI 2 "vector_operand" "xBm,xm,vm")
14843                 (parallel [(const_int 0) (const_int 2)
14844                            (const_int 4) (const_int 6)
14845                            (const_int 8) (const_int 10)
14846                            (const_int 12) (const_int 14)]))))
14847           (mult:V8HI
14848             (zero_extend:V8HI
14849               (vec_select:V8QI (match_dup 1)
14850                 (parallel [(const_int 1) (const_int 3)
14851                            (const_int 5) (const_int 7)
14852                            (const_int 9) (const_int 11)
14853                            (const_int 13) (const_int 15)])))
14854             (sign_extend:V8HI
14855               (vec_select:V8QI (match_dup 2)
14856                 (parallel [(const_int 1) (const_int 3)
14857                            (const_int 5) (const_int 7)
14858                            (const_int 9) (const_int 11)
14859                            (const_int 13) (const_int 15)]))))))]
14860   "TARGET_SSSE3"
14861   "@
14862    pmaddubsw\t{%2, %0|%0, %2}
14863    vpmaddubsw\t{%2, %1, %0|%0, %1, %2}
14864    vpmaddubsw\t{%2, %1, %0|%0, %1, %2}"
14865   [(set_attr "isa" "noavx,avx,avx512bw")
14866    (set_attr "type" "sseiadd")
14867    (set_attr "atom_unit" "simul")
14868    (set_attr "prefix_data16" "1,*,*")
14869    (set_attr "prefix_extra" "1")
14870    (set_attr "prefix" "orig,vex,evex")
14871    (set_attr "mode" "TI")])
14873 (define_insn "ssse3_pmaddubsw"
14874   [(set (match_operand:V4HI 0 "register_operand" "=y")
14875         (ss_plus:V4HI
14876           (mult:V4HI
14877             (zero_extend:V4HI
14878               (vec_select:V4QI
14879                 (match_operand:V8QI 1 "register_operand" "0")
14880                 (parallel [(const_int 0) (const_int 2)
14881                            (const_int 4) (const_int 6)])))
14882             (sign_extend:V4HI
14883               (vec_select:V4QI
14884                 (match_operand:V8QI 2 "nonimmediate_operand" "ym")
14885                 (parallel [(const_int 0) (const_int 2)
14886                            (const_int 4) (const_int 6)]))))
14887           (mult:V4HI
14888             (zero_extend:V4HI
14889               (vec_select:V4QI (match_dup 1)
14890                 (parallel [(const_int 1) (const_int 3)
14891                            (const_int 5) (const_int 7)])))
14892             (sign_extend:V4HI
14893               (vec_select:V4QI (match_dup 2)
14894                 (parallel [(const_int 1) (const_int 3)
14895                            (const_int 5) (const_int 7)]))))))]
14896   "TARGET_SSSE3"
14897   "pmaddubsw\t{%2, %0|%0, %2}"
14898   [(set_attr "type" "sseiadd")
14899    (set_attr "atom_unit" "simul")
14900    (set_attr "prefix_extra" "1")
14901    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14902    (set_attr "mode" "DI")])
14904 (define_mode_iterator PMULHRSW
14905   [V4HI V8HI (V16HI "TARGET_AVX2")])
14907 (define_expand "<ssse3_avx2>_pmulhrsw<mode>3_mask"
14908   [(set (match_operand:PMULHRSW 0 "register_operand")
14909         (vec_merge:PMULHRSW
14910           (truncate:PMULHRSW
14911             (lshiftrt:<ssedoublemode>
14912               (plus:<ssedoublemode>
14913                 (lshiftrt:<ssedoublemode>
14914                   (mult:<ssedoublemode>
14915                     (sign_extend:<ssedoublemode>
14916                       (match_operand:PMULHRSW 1 "nonimmediate_operand"))
14917                     (sign_extend:<ssedoublemode>
14918                       (match_operand:PMULHRSW 2 "nonimmediate_operand")))
14919                   (const_int 14))
14920                 (match_dup 5))
14921               (const_int 1)))
14922           (match_operand:PMULHRSW 3 "register_operand")
14923           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
14924   "TARGET_AVX512BW && TARGET_AVX512VL"
14926   operands[5] = CONST1_RTX(<MODE>mode);
14927   ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
14930 (define_expand "<ssse3_avx2>_pmulhrsw<mode>3"
14931   [(set (match_operand:PMULHRSW 0 "register_operand")
14932         (truncate:PMULHRSW
14933           (lshiftrt:<ssedoublemode>
14934             (plus:<ssedoublemode>
14935               (lshiftrt:<ssedoublemode>
14936                 (mult:<ssedoublemode>
14937                   (sign_extend:<ssedoublemode>
14938                     (match_operand:PMULHRSW 1 "nonimmediate_operand"))
14939                   (sign_extend:<ssedoublemode>
14940                     (match_operand:PMULHRSW 2 "nonimmediate_operand")))
14941                 (const_int 14))
14942               (match_dup 3))
14943             (const_int 1))))]
14944   "TARGET_AVX2"
14946   operands[3] = CONST1_RTX(<MODE>mode);
14947   ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
14950 (define_insn "*<ssse3_avx2>_pmulhrsw<mode>3<mask_name>"
14951   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,x,v")
14952         (truncate:VI2_AVX2
14953           (lshiftrt:<ssedoublemode>
14954             (plus:<ssedoublemode>
14955               (lshiftrt:<ssedoublemode>
14956                 (mult:<ssedoublemode>
14957                   (sign_extend:<ssedoublemode>
14958                     (match_operand:VI2_AVX2 1 "vector_operand" "%0,x,v"))
14959                   (sign_extend:<ssedoublemode>
14960                     (match_operand:VI2_AVX2 2 "vector_operand" "xBm,xm,vm")))
14961                 (const_int 14))
14962               (match_operand:VI2_AVX2 3 "const1_operand"))
14963             (const_int 1))))]
14964   "TARGET_SSSE3 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
14965    && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
14966   "@
14967    pmulhrsw\t{%2, %0|%0, %2}
14968    vpmulhrsw\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}
14969    vpmulhrsw\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}"
14970   [(set_attr "isa" "noavx,avx,avx512bw")
14971    (set_attr "type" "sseimul")
14972    (set_attr "prefix_data16" "1,*,*")
14973    (set_attr "prefix_extra" "1")
14974    (set_attr "prefix" "orig,maybe_evex,evex")
14975    (set_attr "mode" "<sseinsnmode>")])
14977 (define_insn "*ssse3_pmulhrswv4hi3"
14978   [(set (match_operand:V4HI 0 "register_operand" "=y")
14979         (truncate:V4HI
14980           (lshiftrt:V4SI
14981             (plus:V4SI
14982               (lshiftrt:V4SI
14983                 (mult:V4SI
14984                   (sign_extend:V4SI
14985                     (match_operand:V4HI 1 "nonimmediate_operand" "%0"))
14986                   (sign_extend:V4SI
14987                     (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
14988                 (const_int 14))
14989               (match_operand:V4HI 3 "const1_operand"))
14990             (const_int 1))))]
14991   "TARGET_SSSE3 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
14992   "pmulhrsw\t{%2, %0|%0, %2}"
14993   [(set_attr "type" "sseimul")
14994    (set_attr "prefix_extra" "1")
14995    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14996    (set_attr "mode" "DI")])
14998 (define_insn "<ssse3_avx2>_pshufb<mode>3<mask_name>"
14999   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x,v")
15000         (unspec:VI1_AVX512
15001           [(match_operand:VI1_AVX512 1 "register_operand" "0,x,v")
15002            (match_operand:VI1_AVX512 2 "vector_operand" "xBm,xm,vm")]
15003           UNSPEC_PSHUFB))]
15004   "TARGET_SSSE3 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
15005   "@
15006    pshufb\t{%2, %0|%0, %2}
15007    vpshufb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
15008    vpshufb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
15009   [(set_attr "isa" "noavx,avx,avx512bw")
15010    (set_attr "type" "sselog1")
15011    (set_attr "prefix_data16" "1,*,*")
15012    (set_attr "prefix_extra" "1")
15013    (set_attr "prefix" "orig,maybe_evex,evex")
15014    (set_attr "btver2_decode" "vector")
15015    (set_attr "mode" "<sseinsnmode>")])
15017 (define_insn "ssse3_pshufbv8qi3"
15018   [(set (match_operand:V8QI 0 "register_operand" "=y")
15019         (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "0")
15020                       (match_operand:V8QI 2 "nonimmediate_operand" "ym")]
15021                      UNSPEC_PSHUFB))]
15022   "TARGET_SSSE3"
15023   "pshufb\t{%2, %0|%0, %2}";
15024   [(set_attr "type" "sselog1")
15025    (set_attr "prefix_extra" "1")
15026    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15027    (set_attr "mode" "DI")])
15029 (define_insn "<ssse3_avx2>_psign<mode>3"
15030   [(set (match_operand:VI124_AVX2 0 "register_operand" "=x,x")
15031         (unspec:VI124_AVX2
15032           [(match_operand:VI124_AVX2 1 "register_operand" "0,x")
15033            (match_operand:VI124_AVX2 2 "vector_operand" "xBm,xm")]
15034           UNSPEC_PSIGN))]
15035   "TARGET_SSSE3"
15036   "@
15037    psign<ssemodesuffix>\t{%2, %0|%0, %2}
15038    vpsign<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
15039   [(set_attr "isa" "noavx,avx")
15040    (set_attr "type" "sselog1")
15041    (set_attr "prefix_data16" "1,*")
15042    (set_attr "prefix_extra" "1")
15043    (set_attr "prefix" "orig,vex")
15044    (set_attr "mode" "<sseinsnmode>")])
15046 (define_insn "ssse3_psign<mode>3"
15047   [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
15048         (unspec:MMXMODEI
15049           [(match_operand:MMXMODEI 1 "register_operand" "0")
15050            (match_operand:MMXMODEI 2 "nonimmediate_operand" "ym")]
15051           UNSPEC_PSIGN))]
15052   "TARGET_SSSE3"
15053   "psign<mmxvecsize>\t{%2, %0|%0, %2}";
15054   [(set_attr "type" "sselog1")
15055    (set_attr "prefix_extra" "1")
15056    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15057    (set_attr "mode" "DI")])
15059 (define_insn "<ssse3_avx2>_palignr<mode>_mask"
15060   [(set (match_operand:VI1_AVX512 0 "register_operand" "=v")
15061         (vec_merge:VI1_AVX512
15062           (unspec:VI1_AVX512
15063             [(match_operand:VI1_AVX512 1 "register_operand" "v")
15064              (match_operand:VI1_AVX512 2 "nonimmediate_operand" "vm")
15065              (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n")]
15066             UNSPEC_PALIGNR)
15067         (match_operand:VI1_AVX512 4 "vector_move_operand" "0C")
15068         (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
15069   "TARGET_AVX512BW && (<MODE_SIZE> == 64 || TARGET_AVX512VL)"
15071   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
15072   return "vpalignr\t{%3, %2, %1, %0%{%5%}%N4|%0%{%5%}%N4, %1, %2, %3}";
15074   [(set_attr "type" "sseishft")
15075    (set_attr "atom_unit" "sishuf")
15076    (set_attr "prefix_extra" "1")
15077    (set_attr "length_immediate" "1")
15078    (set_attr "prefix" "evex")
15079    (set_attr "mode" "<sseinsnmode>")])
15081 (define_insn "<ssse3_avx2>_palignr<mode>"
15082   [(set (match_operand:SSESCALARMODE 0 "register_operand" "=x,x,v")
15083         (unspec:SSESCALARMODE
15084           [(match_operand:SSESCALARMODE 1 "register_operand" "0,x,v")
15085            (match_operand:SSESCALARMODE 2 "vector_operand" "xBm,xm,vm")
15086            (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n,n,n")]
15087           UNSPEC_PALIGNR))]
15088   "TARGET_SSSE3"
15090   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
15092   switch (which_alternative)
15093     {
15094     case 0:
15095       return "palignr\t{%3, %2, %0|%0, %2, %3}";
15096     case 1:
15097     case 2:
15098       return "vpalignr\t{%3, %2, %1, %0|%0, %1, %2, %3}";
15099     default:
15100       gcc_unreachable ();
15101     }
15103   [(set_attr "isa" "noavx,avx,avx512bw")
15104    (set_attr "type" "sseishft")
15105    (set_attr "atom_unit" "sishuf")
15106    (set_attr "prefix_data16" "1,*,*")
15107    (set_attr "prefix_extra" "1")
15108    (set_attr "length_immediate" "1")
15109    (set_attr "prefix" "orig,vex,evex")
15110    (set_attr "mode" "<sseinsnmode>")])
15112 (define_insn "ssse3_palignrdi"
15113   [(set (match_operand:DI 0 "register_operand" "=y")
15114         (unspec:DI [(match_operand:DI 1 "register_operand" "0")
15115                     (match_operand:DI 2 "nonimmediate_operand" "ym")
15116                     (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n")]
15117                    UNSPEC_PALIGNR))]
15118   "TARGET_SSSE3"
15120   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
15121   return "palignr\t{%3, %2, %0|%0, %2, %3}";
15123   [(set_attr "type" "sseishft")
15124    (set_attr "atom_unit" "sishuf")
15125    (set_attr "prefix_extra" "1")
15126    (set_attr "length_immediate" "1")
15127    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15128    (set_attr "mode" "DI")])
15130 ;; Mode iterator to handle singularity w/ absence of V2DI and V4DI
15131 ;; modes for abs instruction on pre AVX-512 targets.
15132 (define_mode_iterator VI1248_AVX512VL_AVX512BW
15133   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
15134    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI
15135    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI
15136    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
15138 (define_insn "*abs<mode>2"
15139   [(set (match_operand:VI1248_AVX512VL_AVX512BW 0 "register_operand" "=v")
15140         (abs:VI1248_AVX512VL_AVX512BW
15141           (match_operand:VI1248_AVX512VL_AVX512BW 1 "vector_operand" "vBm")))]
15142   "TARGET_SSSE3"
15143   "%vpabs<ssemodesuffix>\t{%1, %0|%0, %1}"
15144   [(set_attr "type" "sselog1")
15145    (set_attr "prefix_data16" "1")
15146    (set_attr "prefix_extra" "1")
15147    (set_attr "prefix" "maybe_vex")
15148    (set_attr "mode" "<sseinsnmode>")])
15150 (define_insn "abs<mode>2_mask"
15151   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
15152         (vec_merge:VI48_AVX512VL
15153           (abs:VI48_AVX512VL
15154             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm"))
15155           (match_operand:VI48_AVX512VL 2 "vector_move_operand" "0C")
15156           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
15157   "TARGET_AVX512F"
15158   "vpabs<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15159   [(set_attr "type" "sselog1")
15160    (set_attr "prefix" "evex")
15161    (set_attr "mode" "<sseinsnmode>")])
15163 (define_insn "abs<mode>2_mask"
15164   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
15165         (vec_merge:VI12_AVX512VL
15166           (abs:VI12_AVX512VL
15167             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "vm"))
15168           (match_operand:VI12_AVX512VL 2 "vector_move_operand" "0C")
15169           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
15170   "TARGET_AVX512BW"
15171   "vpabs<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
15172   [(set_attr "type" "sselog1")
15173    (set_attr "prefix" "evex")
15174    (set_attr "mode" "<sseinsnmode>")])
15176 (define_expand "abs<mode>2"
15177   [(set (match_operand:VI1248_AVX512VL_AVX512BW 0 "register_operand")
15178         (abs:VI1248_AVX512VL_AVX512BW
15179           (match_operand:VI1248_AVX512VL_AVX512BW 1 "vector_operand")))]
15180   "TARGET_SSE2"
15182   if (!TARGET_SSSE3)
15183     {
15184       ix86_expand_sse2_abs (operands[0], operands[1]);
15185       DONE;
15186     }
15189 (define_insn "abs<mode>2"
15190   [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
15191         (abs:MMXMODEI
15192           (match_operand:MMXMODEI 1 "nonimmediate_operand" "ym")))]
15193   "TARGET_SSSE3"
15194   "pabs<mmxvecsize>\t{%1, %0|%0, %1}";
15195   [(set_attr "type" "sselog1")
15196    (set_attr "prefix_rep" "0")
15197    (set_attr "prefix_extra" "1")
15198    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
15199    (set_attr "mode" "DI")])
15201 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15203 ;; AMD SSE4A instructions
15205 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15207 (define_insn "sse4a_movnt<mode>"
15208   [(set (match_operand:MODEF 0 "memory_operand" "=m")
15209         (unspec:MODEF
15210           [(match_operand:MODEF 1 "register_operand" "x")]
15211           UNSPEC_MOVNT))]
15212   "TARGET_SSE4A"
15213   "movnt<ssemodesuffix>\t{%1, %0|%0, %1}"
15214   [(set_attr "type" "ssemov")
15215    (set_attr "mode" "<MODE>")])
15217 (define_insn "sse4a_vmmovnt<mode>"
15218   [(set (match_operand:<ssescalarmode> 0 "memory_operand" "=m")
15219         (unspec:<ssescalarmode>
15220           [(vec_select:<ssescalarmode>
15221              (match_operand:VF_128 1 "register_operand" "x")
15222              (parallel [(const_int 0)]))]
15223           UNSPEC_MOVNT))]
15224   "TARGET_SSE4A"
15225   "movnt<ssescalarmodesuffix>\t{%1, %0|%0, %1}"
15226   [(set_attr "type" "ssemov")
15227    (set_attr "mode" "<ssescalarmode>")])
15229 (define_insn "sse4a_extrqi"
15230   [(set (match_operand:V2DI 0 "register_operand" "=x")
15231         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
15232                       (match_operand 2 "const_0_to_255_operand")
15233                       (match_operand 3 "const_0_to_255_operand")]
15234                      UNSPEC_EXTRQI))]
15235   "TARGET_SSE4A"
15236   "extrq\t{%3, %2, %0|%0, %2, %3}"
15237   [(set_attr "type" "sse")
15238    (set_attr "prefix_data16" "1")
15239    (set_attr "length_immediate" "2")
15240    (set_attr "mode" "TI")])
15242 (define_insn "sse4a_extrq"
15243   [(set (match_operand:V2DI 0 "register_operand" "=x")
15244         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
15245                       (match_operand:V16QI 2 "register_operand" "x")]
15246                      UNSPEC_EXTRQ))]
15247   "TARGET_SSE4A"
15248   "extrq\t{%2, %0|%0, %2}"
15249   [(set_attr "type" "sse")
15250    (set_attr "prefix_data16" "1")
15251    (set_attr "mode" "TI")])
15253 (define_insn "sse4a_insertqi"
15254   [(set (match_operand:V2DI 0 "register_operand" "=x")
15255         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
15256                       (match_operand:V2DI 2 "register_operand" "x")
15257                       (match_operand 3 "const_0_to_255_operand")
15258                       (match_operand 4 "const_0_to_255_operand")]
15259                      UNSPEC_INSERTQI))]
15260   "TARGET_SSE4A"
15261   "insertq\t{%4, %3, %2, %0|%0, %2, %3, %4}"
15262   [(set_attr "type" "sseins")
15263    (set_attr "prefix_data16" "0")
15264    (set_attr "prefix_rep" "1")
15265    (set_attr "length_immediate" "2")
15266    (set_attr "mode" "TI")])
15268 (define_insn "sse4a_insertq"
15269   [(set (match_operand:V2DI 0 "register_operand" "=x")
15270         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
15271                       (match_operand:V2DI 2 "register_operand" "x")]
15272                      UNSPEC_INSERTQ))]
15273   "TARGET_SSE4A"
15274   "insertq\t{%2, %0|%0, %2}"
15275   [(set_attr "type" "sseins")
15276    (set_attr "prefix_data16" "0")
15277    (set_attr "prefix_rep" "1")
15278    (set_attr "mode" "TI")])
15280 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15282 ;; Intel SSE4.1 instructions
15284 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15286 ;; Mapping of immediate bits for blend instructions
15287 (define_mode_attr blendbits
15288   [(V8SF "255") (V4SF "15") (V4DF "15") (V2DF "3")])
15290 (define_insn "<sse4_1>_blend<ssemodesuffix><avxsizesuffix>"
15291   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
15292         (vec_merge:VF_128_256
15293           (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
15294           (match_operand:VF_128_256 1 "register_operand" "0,0,x")
15295           (match_operand:SI 3 "const_0_to_<blendbits>_operand")))]
15296   "TARGET_SSE4_1"
15297   "@
15298    blend<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15299    blend<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15300    vblend<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15301   [(set_attr "isa" "noavx,noavx,avx")
15302    (set_attr "type" "ssemov")
15303    (set_attr "length_immediate" "1")
15304    (set_attr "prefix_data16" "1,1,*")
15305    (set_attr "prefix_extra" "1")
15306    (set_attr "prefix" "orig,orig,vex")
15307    (set_attr "mode" "<MODE>")])
15309 (define_insn "<sse4_1>_blendv<ssemodesuffix><avxsizesuffix>"
15310   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
15311         (unspec:VF_128_256
15312           [(match_operand:VF_128_256 1 "register_operand" "0,0,x")
15313            (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
15314            (match_operand:VF_128_256 3 "register_operand" "Yz,Yz,x")]
15315           UNSPEC_BLENDV))]
15316   "TARGET_SSE4_1"
15317   "@
15318    blendv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15319    blendv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15320    vblendv<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15321   [(set_attr "isa" "noavx,noavx,avx")
15322    (set_attr "type" "ssemov")
15323    (set_attr "length_immediate" "1")
15324    (set_attr "prefix_data16" "1,1,*")
15325    (set_attr "prefix_extra" "1")
15326    (set_attr "prefix" "orig,orig,vex")
15327    (set_attr "btver2_decode" "vector,vector,vector") 
15328    (set_attr "mode" "<MODE>")])
15330 (define_insn "<sse4_1>_dp<ssemodesuffix><avxsizesuffix>"
15331   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
15332         (unspec:VF_128_256
15333           [(match_operand:VF_128_256 1 "vector_operand" "%0,0,x")
15334            (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
15335            (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
15336           UNSPEC_DP))]
15337   "TARGET_SSE4_1"
15338   "@
15339    dp<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15340    dp<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
15341    vdp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15342   [(set_attr "isa" "noavx,noavx,avx")
15343    (set_attr "type" "ssemul")
15344    (set_attr "length_immediate" "1")
15345    (set_attr "prefix_data16" "1,1,*")
15346    (set_attr "prefix_extra" "1")
15347    (set_attr "prefix" "orig,orig,vex")
15348    (set_attr "btver2_decode" "vector,vector,vector")
15349    (set_attr "znver1_decode" "vector,vector,vector")
15350    (set_attr "mode" "<MODE>")])
15352 ;; Mode attribute used by `vmovntdqa' pattern
15353 (define_mode_attr vi8_sse4_1_avx2_avx512
15354    [(V2DI "sse4_1") (V4DI "avx2") (V8DI "avx512f")])
15356 (define_insn "<vi8_sse4_1_avx2_avx512>_movntdqa"
15357   [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand" "=Yr,*x,v")
15358         (unspec:VI8_AVX2_AVX512F [(match_operand:VI8_AVX2_AVX512F 1 "memory_operand" "m,m,m")]
15359                      UNSPEC_MOVNTDQA))]
15360   "TARGET_SSE4_1"
15361   "%vmovntdqa\t{%1, %0|%0, %1}"
15362   [(set_attr "isa" "noavx,noavx,avx")
15363    (set_attr "type" "ssemov")
15364    (set_attr "prefix_extra" "1,1,*")
15365    (set_attr "prefix" "orig,orig,maybe_evex")
15366    (set_attr "mode" "<sseinsnmode>")])
15368 (define_insn "<sse4_1_avx2>_mpsadbw"
15369   [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
15370         (unspec:VI1_AVX2
15371           [(match_operand:VI1_AVX2 1 "register_operand" "0,0,x")
15372            (match_operand:VI1_AVX2 2 "vector_operand" "YrBm,*xBm,xm")
15373            (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
15374           UNSPEC_MPSADBW))]
15375   "TARGET_SSE4_1"
15376   "@
15377    mpsadbw\t{%3, %2, %0|%0, %2, %3}
15378    mpsadbw\t{%3, %2, %0|%0, %2, %3}
15379    vmpsadbw\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15380   [(set_attr "isa" "noavx,noavx,avx")
15381    (set_attr "type" "sselog1")
15382    (set_attr "length_immediate" "1")
15383    (set_attr "prefix_extra" "1")
15384    (set_attr "prefix" "orig,orig,vex")
15385    (set_attr "btver2_decode" "vector,vector,vector")
15386    (set_attr "znver1_decode" "vector,vector,vector")
15387    (set_attr "mode" "<sseinsnmode>")])
15389 (define_insn "<sse4_1_avx2>_packusdw<mask_name>"
15390   [(set (match_operand:VI2_AVX2 0 "register_operand" "=Yr,*x,x,v")
15391         (vec_concat:VI2_AVX2
15392           (us_truncate:<ssehalfvecmode>
15393             (match_operand:<sseunpackmode> 1 "register_operand" "0,0,x,v"))
15394           (us_truncate:<ssehalfvecmode>
15395             (match_operand:<sseunpackmode> 2 "vector_operand" "YrBm,*xBm,xm,vm"))))]
15396   "TARGET_SSE4_1 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
15397   "@
15398    packusdw\t{%2, %0|%0, %2}
15399    packusdw\t{%2, %0|%0, %2}
15400    vpackusdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
15401    vpackusdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
15402   [(set_attr "isa" "noavx,noavx,avx,avx512bw")
15403    (set_attr "type" "sselog")
15404    (set_attr "prefix_extra" "1")
15405    (set_attr "prefix" "orig,orig,<mask_prefix>,evex")
15406    (set_attr "mode" "<sseinsnmode>")])
15408 (define_insn "<sse4_1_avx2>_pblendvb"
15409   [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
15410         (unspec:VI1_AVX2
15411           [(match_operand:VI1_AVX2 1 "register_operand"  "0,0,x")
15412            (match_operand:VI1_AVX2 2 "vector_operand" "YrBm,*xBm,xm")
15413            (match_operand:VI1_AVX2 3 "register_operand" "Yz,Yz,x")]
15414           UNSPEC_BLENDV))]
15415   "TARGET_SSE4_1"
15416   "@
15417    pblendvb\t{%3, %2, %0|%0, %2, %3}
15418    pblendvb\t{%3, %2, %0|%0, %2, %3}
15419    vpblendvb\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15420   [(set_attr "isa" "noavx,noavx,avx")
15421    (set_attr "type" "ssemov")
15422    (set_attr "prefix_extra" "1")
15423    (set_attr "length_immediate" "*,*,1")
15424    (set_attr "prefix" "orig,orig,vex")
15425    (set_attr "btver2_decode" "vector,vector,vector")
15426    (set_attr "mode" "<sseinsnmode>")])
15428 (define_insn "sse4_1_pblendw"
15429   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,x")
15430         (vec_merge:V8HI
15431           (match_operand:V8HI 2 "vector_operand" "YrBm,*xBm,xm")
15432           (match_operand:V8HI 1 "register_operand" "0,0,x")
15433           (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")))]
15434   "TARGET_SSE4_1"
15435   "@
15436    pblendw\t{%3, %2, %0|%0, %2, %3}
15437    pblendw\t{%3, %2, %0|%0, %2, %3}
15438    vpblendw\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15439   [(set_attr "isa" "noavx,noavx,avx")
15440    (set_attr "type" "ssemov")
15441    (set_attr "prefix_extra" "1")
15442    (set_attr "length_immediate" "1")
15443    (set_attr "prefix" "orig,orig,vex")
15444    (set_attr "mode" "TI")])
15446 ;; The builtin uses an 8-bit immediate.  Expand that.
15447 (define_expand "avx2_pblendw"
15448   [(set (match_operand:V16HI 0 "register_operand")
15449         (vec_merge:V16HI
15450           (match_operand:V16HI 2 "nonimmediate_operand")
15451           (match_operand:V16HI 1 "register_operand")
15452           (match_operand:SI 3 "const_0_to_255_operand")))]
15453   "TARGET_AVX2"
15455   HOST_WIDE_INT val = INTVAL (operands[3]) & 0xff;
15456   operands[3] = GEN_INT (val << 8 | val);
15459 (define_insn "*avx2_pblendw"
15460   [(set (match_operand:V16HI 0 "register_operand" "=x")
15461         (vec_merge:V16HI
15462           (match_operand:V16HI 2 "nonimmediate_operand" "xm")
15463           (match_operand:V16HI 1 "register_operand" "x")
15464           (match_operand:SI 3 "avx2_pblendw_operand" "n")))]
15465   "TARGET_AVX2"
15467   operands[3] = GEN_INT (INTVAL (operands[3]) & 0xff);
15468   return "vpblendw\t{%3, %2, %1, %0|%0, %1, %2, %3}";
15470   [(set_attr "type" "ssemov")
15471    (set_attr "prefix_extra" "1")
15472    (set_attr "length_immediate" "1")
15473    (set_attr "prefix" "vex")
15474    (set_attr "mode" "OI")])
15476 (define_insn "avx2_pblendd<mode>"
15477   [(set (match_operand:VI4_AVX2 0 "register_operand" "=x")
15478         (vec_merge:VI4_AVX2
15479           (match_operand:VI4_AVX2 2 "nonimmediate_operand" "xm")
15480           (match_operand:VI4_AVX2 1 "register_operand" "x")
15481           (match_operand:SI 3 "const_0_to_255_operand" "n")))]
15482   "TARGET_AVX2"
15483   "vpblendd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15484   [(set_attr "type" "ssemov")
15485    (set_attr "prefix_extra" "1")
15486    (set_attr "length_immediate" "1")
15487    (set_attr "prefix" "vex")
15488    (set_attr "mode" "<sseinsnmode>")])
15490 (define_insn "sse4_1_phminposuw"
15491   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,x")
15492         (unspec:V8HI [(match_operand:V8HI 1 "vector_operand" "YrBm,*xBm,xm")]
15493                      UNSPEC_PHMINPOSUW))]
15494   "TARGET_SSE4_1"
15495   "%vphminposuw\t{%1, %0|%0, %1}"
15496   [(set_attr "isa" "noavx,noavx,avx")
15497    (set_attr "type" "sselog1")
15498    (set_attr "prefix_extra" "1")
15499    (set_attr "prefix" "orig,orig,vex")
15500    (set_attr "mode" "TI")])
15502 (define_insn "avx2_<code>v16qiv16hi2<mask_name>"
15503   [(set (match_operand:V16HI 0 "register_operand" "=v")
15504         (any_extend:V16HI
15505           (match_operand:V16QI 1 "nonimmediate_operand" "vm")))]
15506   "TARGET_AVX2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
15507   "vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15508   [(set_attr "type" "ssemov")
15509    (set_attr "prefix_extra" "1")
15510    (set_attr "prefix" "maybe_evex")
15511    (set_attr "mode" "OI")])
15513 (define_insn "avx512bw_<code>v32qiv32hi2<mask_name>"
15514   [(set (match_operand:V32HI 0 "register_operand" "=v")
15515         (any_extend:V32HI
15516           (match_operand:V32QI 1 "nonimmediate_operand" "vm")))]
15517   "TARGET_AVX512BW"
15518   "vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15519   [(set_attr "type" "ssemov")
15520    (set_attr "prefix_extra" "1")
15521    (set_attr "prefix" "evex")
15522    (set_attr "mode" "XI")])
15524 (define_insn "sse4_1_<code>v8qiv8hi2<mask_name>"
15525   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,v")
15526         (any_extend:V8HI
15527           (vec_select:V8QI
15528             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15529             (parallel [(const_int 0) (const_int 1)
15530                        (const_int 2) (const_int 3)
15531                        (const_int 4) (const_int 5)
15532                        (const_int 6) (const_int 7)]))))]
15533   "TARGET_SSE4_1 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
15534   "%vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15535   [(set_attr "isa" "noavx,noavx,avx")
15536    (set_attr "type" "ssemov")
15537    (set_attr "prefix_extra" "1")
15538    (set_attr "prefix" "orig,orig,maybe_evex")
15539    (set_attr "mode" "TI")])
15541 (define_insn "<mask_codefor>avx512f_<code>v16qiv16si2<mask_name>"
15542   [(set (match_operand:V16SI 0 "register_operand" "=v")
15543         (any_extend:V16SI
15544           (match_operand:V16QI 1 "nonimmediate_operand" "vm")))]
15545   "TARGET_AVX512F"
15546   "vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15547   [(set_attr "type" "ssemov")
15548    (set_attr "prefix" "evex")
15549    (set_attr "mode" "XI")])
15551 (define_insn "avx2_<code>v8qiv8si2<mask_name>"
15552   [(set (match_operand:V8SI 0 "register_operand" "=v")
15553         (any_extend:V8SI
15554           (vec_select:V8QI
15555             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
15556             (parallel [(const_int 0) (const_int 1)
15557                        (const_int 2) (const_int 3)
15558                        (const_int 4) (const_int 5)
15559                        (const_int 6) (const_int 7)]))))]
15560   "TARGET_AVX2 && <mask_avx512vl_condition>"
15561   "vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15562   [(set_attr "type" "ssemov")
15563    (set_attr "prefix_extra" "1")
15564    (set_attr "prefix" "maybe_evex")
15565    (set_attr "mode" "OI")])
15567 (define_insn "sse4_1_<code>v4qiv4si2<mask_name>"
15568   [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
15569         (any_extend:V4SI
15570           (vec_select:V4QI
15571             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15572             (parallel [(const_int 0) (const_int 1)
15573                        (const_int 2) (const_int 3)]))))]
15574   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15575   "%vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15576   [(set_attr "isa" "noavx,noavx,avx")
15577    (set_attr "type" "ssemov")
15578    (set_attr "prefix_extra" "1")
15579    (set_attr "prefix" "orig,orig,maybe_evex")
15580    (set_attr "mode" "TI")])
15582 (define_insn "avx512f_<code>v16hiv16si2<mask_name>"
15583   [(set (match_operand:V16SI 0 "register_operand" "=v")
15584         (any_extend:V16SI
15585           (match_operand:V16HI 1 "nonimmediate_operand" "vm")))]
15586   "TARGET_AVX512F"
15587   "vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15588   [(set_attr "type" "ssemov")
15589    (set_attr "prefix" "evex")
15590    (set_attr "mode" "XI")])
15592 (define_insn "avx2_<code>v8hiv8si2<mask_name>"
15593   [(set (match_operand:V8SI 0 "register_operand" "=v")
15594         (any_extend:V8SI
15595             (match_operand:V8HI 1 "nonimmediate_operand" "vm")))]
15596   "TARGET_AVX2 && <mask_avx512vl_condition>"
15597   "vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15598   [(set_attr "type" "ssemov")
15599    (set_attr "prefix_extra" "1")
15600    (set_attr "prefix" "maybe_evex")
15601    (set_attr "mode" "OI")])
15603 (define_insn "sse4_1_<code>v4hiv4si2<mask_name>"
15604   [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
15605         (any_extend:V4SI
15606           (vec_select:V4HI
15607             (match_operand:V8HI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15608             (parallel [(const_int 0) (const_int 1)
15609                        (const_int 2) (const_int 3)]))))]
15610   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15611   "%vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15612   [(set_attr "isa" "noavx,noavx,avx")
15613    (set_attr "type" "ssemov")
15614    (set_attr "prefix_extra" "1")
15615    (set_attr "prefix" "orig,orig,maybe_evex")
15616    (set_attr "mode" "TI")])
15618 (define_insn "avx512f_<code>v8qiv8di2<mask_name>"
15619   [(set (match_operand:V8DI 0 "register_operand" "=v")
15620         (any_extend:V8DI
15621           (vec_select:V8QI
15622             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
15623             (parallel [(const_int 0) (const_int 1)
15624                        (const_int 2) (const_int 3)
15625                        (const_int 4) (const_int 5)
15626                        (const_int 6) (const_int 7)]))))]
15627   "TARGET_AVX512F"
15628   "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15629   [(set_attr "type" "ssemov")
15630    (set_attr "prefix" "evex")
15631    (set_attr "mode" "XI")])
15633 (define_insn "avx2_<code>v4qiv4di2<mask_name>"
15634   [(set (match_operand:V4DI 0 "register_operand" "=v")
15635         (any_extend:V4DI
15636           (vec_select:V4QI
15637             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
15638             (parallel [(const_int 0) (const_int 1)
15639                        (const_int 2) (const_int 3)]))))]
15640   "TARGET_AVX2 && <mask_avx512vl_condition>"
15641   "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15642   [(set_attr "type" "ssemov")
15643    (set_attr "prefix_extra" "1")
15644    (set_attr "prefix" "maybe_evex")
15645    (set_attr "mode" "OI")])
15647 (define_insn "sse4_1_<code>v2qiv2di2<mask_name>"
15648   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
15649         (any_extend:V2DI
15650           (vec_select:V2QI
15651             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15652             (parallel [(const_int 0) (const_int 1)]))))]
15653   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15654   "%vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %w1}"
15655   [(set_attr "isa" "noavx,noavx,avx")
15656    (set_attr "type" "ssemov")
15657    (set_attr "prefix_extra" "1")
15658    (set_attr "prefix" "orig,orig,maybe_evex")
15659    (set_attr "mode" "TI")])
15661 (define_insn "avx512f_<code>v8hiv8di2<mask_name>"
15662   [(set (match_operand:V8DI 0 "register_operand" "=v")
15663         (any_extend:V8DI
15664           (match_operand:V8HI 1 "nonimmediate_operand" "vm")))]
15665   "TARGET_AVX512F"
15666   "vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15667   [(set_attr "type" "ssemov")
15668    (set_attr "prefix" "evex")
15669    (set_attr "mode" "XI")])
15671 (define_insn "avx2_<code>v4hiv4di2<mask_name>"
15672   [(set (match_operand:V4DI 0 "register_operand" "=v")
15673         (any_extend:V4DI
15674           (vec_select:V4HI
15675             (match_operand:V8HI 1 "nonimmediate_operand" "vm")
15676             (parallel [(const_int 0) (const_int 1)
15677                        (const_int 2) (const_int 3)]))))]
15678   "TARGET_AVX2 && <mask_avx512vl_condition>"
15679   "vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15680   [(set_attr "type" "ssemov")
15681    (set_attr "prefix_extra" "1")
15682    (set_attr "prefix" "maybe_evex")
15683    (set_attr "mode" "OI")])
15685 (define_insn "sse4_1_<code>v2hiv2di2<mask_name>"
15686   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
15687         (any_extend:V2DI
15688           (vec_select:V2HI
15689             (match_operand:V8HI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15690             (parallel [(const_int 0) (const_int 1)]))))]
15691   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15692   "%vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15693   [(set_attr "isa" "noavx,noavx,avx")
15694    (set_attr "type" "ssemov")
15695    (set_attr "prefix_extra" "1")
15696    (set_attr "prefix" "orig,orig,maybe_evex")
15697    (set_attr "mode" "TI")])
15699 (define_insn "avx512f_<code>v8siv8di2<mask_name>"
15700   [(set (match_operand:V8DI 0 "register_operand" "=v")
15701         (any_extend:V8DI
15702           (match_operand:V8SI 1 "nonimmediate_operand" "vm")))]
15703   "TARGET_AVX512F"
15704   "vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15705   [(set_attr "type" "ssemov")
15706    (set_attr "prefix" "evex")
15707    (set_attr "mode" "XI")])
15709 (define_insn "avx2_<code>v4siv4di2<mask_name>"
15710   [(set (match_operand:V4DI 0 "register_operand" "=v")
15711         (any_extend:V4DI
15712             (match_operand:V4SI 1 "nonimmediate_operand" "vm")))]
15713   "TARGET_AVX2 && <mask_avx512vl_condition>"
15714   "vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15715   [(set_attr "type" "ssemov")
15716    (set_attr "prefix" "maybe_evex")
15717    (set_attr "prefix_extra" "1")
15718    (set_attr "mode" "OI")])
15720 (define_insn "sse4_1_<code>v2siv2di2<mask_name>"
15721   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
15722         (any_extend:V2DI
15723           (vec_select:V2SI
15724             (match_operand:V4SI 1 "nonimmediate_operand" "Yrm,*xm,vm")
15725             (parallel [(const_int 0) (const_int 1)]))))]
15726   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15727   "%vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15728   [(set_attr "isa" "noavx,noavx,avx")
15729    (set_attr "type" "ssemov")
15730    (set_attr "prefix_extra" "1")
15731    (set_attr "prefix" "orig,orig,maybe_evex")
15732    (set_attr "mode" "TI")])
15734 ;; ptestps/ptestpd are very similar to comiss and ucomiss when
15735 ;; setting FLAGS_REG. But it is not a really compare instruction.
15736 (define_insn "avx_vtest<ssemodesuffix><avxsizesuffix>"
15737   [(set (reg:CC FLAGS_REG)
15738         (unspec:CC [(match_operand:VF_128_256 0 "register_operand" "x")
15739                     (match_operand:VF_128_256 1 "nonimmediate_operand" "xm")]
15740                    UNSPEC_VTESTP))]
15741   "TARGET_AVX"
15742   "vtest<ssemodesuffix>\t{%1, %0|%0, %1}"
15743   [(set_attr "type" "ssecomi")
15744    (set_attr "prefix_extra" "1")
15745    (set_attr "prefix" "vex")
15746    (set_attr "mode" "<MODE>")])
15748 ;; ptest is very similar to comiss and ucomiss when setting FLAGS_REG.
15749 ;; But it is not a really compare instruction.
15750 (define_insn "<sse4_1>_ptest<mode>"
15751   [(set (reg:CC FLAGS_REG)
15752         (unspec:CC [(match_operand:V_AVX 0 "register_operand" "Yr, *x, x")
15753                     (match_operand:V_AVX 1 "vector_operand" "YrBm, *xBm, xm")]
15754                    UNSPEC_PTEST))]
15755   "TARGET_SSE4_1"
15756   "%vptest\t{%1, %0|%0, %1}"
15757   [(set_attr "isa" "noavx,noavx,avx")
15758    (set_attr "type" "ssecomi")
15759    (set_attr "prefix_extra" "1")
15760    (set_attr "prefix" "orig,orig,vex")
15761    (set (attr "btver2_decode")
15762      (if_then_else
15763        (match_test "<sseinsnmode>mode==OImode")
15764      (const_string "vector")
15765      (const_string "*")))
15766    (set_attr "mode" "<sseinsnmode>")])
15768 (define_insn "ptesttf2"
15769   [(set (reg:CC FLAGS_REG)
15770         (unspec:CC [(match_operand:TF 0 "register_operand" "Yr, *x, x")
15771                     (match_operand:TF 1 "vector_operand" "YrBm, *xBm, xm")]
15772                    UNSPEC_PTEST))]
15773   "TARGET_SSE4_1"
15774   "%vptest\t{%1, %0|%0, %1}"
15775   [(set_attr "isa" "noavx,noavx,avx")
15776    (set_attr "type" "ssecomi")
15777    (set_attr "prefix_extra" "1")
15778    (set_attr "prefix" "orig,orig,vex")
15779    (set_attr "mode" "TI")])
15781 (define_insn "<sse4_1>_round<ssemodesuffix><avxsizesuffix>"
15782   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
15783         (unspec:VF_128_256
15784           [(match_operand:VF_128_256 1 "vector_operand" "YrBm,*xBm,xm")
15785            (match_operand:SI 2 "const_0_to_15_operand" "n,n,n")]
15786           UNSPEC_ROUND))]
15787   "TARGET_SSE4_1"
15788   "%vround<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
15789   [(set_attr "isa" "noavx,noavx,avx")
15790    (set_attr "type" "ssecvt")
15791    (set_attr "prefix_data16" "1,1,*")
15792    (set_attr "prefix_extra" "1")
15793    (set_attr "length_immediate" "1")
15794    (set_attr "prefix" "orig,orig,vex")
15795    (set_attr "mode" "<MODE>")])
15797 (define_expand "<sse4_1>_round<ssemodesuffix>_sfix<avxsizesuffix>"
15798   [(match_operand:<sseintvecmode> 0 "register_operand")
15799    (match_operand:VF1_128_256 1 "vector_operand")
15800    (match_operand:SI 2 "const_0_to_15_operand")]
15801   "TARGET_SSE4_1"
15803   rtx tmp = gen_reg_rtx (<MODE>mode);
15805   emit_insn
15806     (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp, operands[1],
15807                                                        operands[2]));
15808   emit_insn
15809     (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
15810   DONE;
15813 (define_expand "avx512f_round<castmode>512"
15814   [(match_operand:VF_512 0 "register_operand")
15815    (match_operand:VF_512 1 "nonimmediate_operand")
15816    (match_operand:SI 2 "const_0_to_15_operand")]
15817   "TARGET_AVX512F"
15819   emit_insn (gen_avx512f_rndscale<mode> (operands[0], operands[1], operands[2]));
15820   DONE;
15823 (define_expand "avx512f_roundps512_sfix"
15824   [(match_operand:V16SI 0 "register_operand")
15825    (match_operand:V16SF 1 "nonimmediate_operand")
15826    (match_operand:SI 2 "const_0_to_15_operand")]
15827   "TARGET_AVX512F"
15829   rtx tmp = gen_reg_rtx (V16SFmode);
15830   emit_insn (gen_avx512f_rndscalev16sf (tmp, operands[1], operands[2]));
15831   emit_insn (gen_fix_truncv16sfv16si2 (operands[0], tmp));
15832   DONE;
15835 (define_expand "<sse4_1>_round<ssemodesuffix>_vec_pack_sfix<avxsizesuffix>"
15836   [(match_operand:<ssepackfltmode> 0 "register_operand")
15837    (match_operand:VF2 1 "vector_operand")
15838    (match_operand:VF2 2 "vector_operand")
15839    (match_operand:SI 3 "const_0_to_15_operand")]
15840   "TARGET_SSE4_1"
15842   rtx tmp0, tmp1;
15844   if (<MODE>mode == V2DFmode
15845       && TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
15846     {
15847       rtx tmp2 = gen_reg_rtx (V4DFmode);
15849       tmp0 = gen_reg_rtx (V4DFmode);
15850       tmp1 = force_reg (V2DFmode, operands[1]);
15852       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
15853       emit_insn (gen_avx_roundpd256 (tmp2, tmp0, operands[3]));
15854       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp2));
15855     }
15856   else
15857     {
15858       tmp0 = gen_reg_rtx (<MODE>mode);
15859       tmp1 = gen_reg_rtx (<MODE>mode);
15861       emit_insn
15862        (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp0, operands[1],
15863                                                           operands[3]));
15864       emit_insn
15865        (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp1, operands[2],
15866                                                           operands[3]));
15867       emit_insn
15868        (gen_vec_pack_sfix_trunc_<mode> (operands[0], tmp0, tmp1));
15869     }
15870   DONE;
15873 (define_insn "sse4_1_round<ssescalarmodesuffix>"
15874   [(set (match_operand:VF_128 0 "register_operand" "=Yr,*x,x,v")
15875         (vec_merge:VF_128
15876           (unspec:VF_128
15877             [(match_operand:VF_128 2 "register_operand" "Yr,*x,x,v")
15878              (match_operand:SI 3 "const_0_to_15_operand" "n,n,n,n")]
15879             UNSPEC_ROUND)
15880           (match_operand:VF_128 1 "register_operand" "0,0,x,v")
15881           (const_int 1)))]
15882   "TARGET_SSE4_1"
15883   "@
15884    round<ssescalarmodesuffix>\t{%3, %2, %0|%0, %2, %3}
15885    round<ssescalarmodesuffix>\t{%3, %2, %0|%0, %2, %3}
15886    vround<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
15887    vrndscale<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15888   [(set_attr "isa" "noavx,noavx,avx,avx512f")
15889    (set_attr "type" "ssecvt")
15890    (set_attr "length_immediate" "1")
15891    (set_attr "prefix_data16" "1,1,*,*")
15892    (set_attr "prefix_extra" "1")
15893    (set_attr "prefix" "orig,orig,vex,evex")
15894    (set_attr "mode" "<MODE>")])
15896 (define_expand "round<mode>2"
15897   [(set (match_dup 3)
15898         (plus:VF
15899           (match_operand:VF 1 "register_operand")
15900           (match_dup 2)))
15901    (set (match_operand:VF 0 "register_operand")
15902         (unspec:VF
15903           [(match_dup 3) (match_dup 4)]
15904           UNSPEC_ROUND))]
15905   "TARGET_SSE4_1 && !flag_trapping_math"
15907   machine_mode scalar_mode;
15908   const struct real_format *fmt;
15909   REAL_VALUE_TYPE pred_half, half_minus_pred_half;
15910   rtx half, vec_half;
15912   scalar_mode = GET_MODE_INNER (<MODE>mode);
15914   /* load nextafter (0.5, 0.0) */
15915   fmt = REAL_MODE_FORMAT (scalar_mode);
15916   real_2expN (&half_minus_pred_half, -(fmt->p) - 1, scalar_mode);
15917   real_arithmetic (&pred_half, MINUS_EXPR, &dconsthalf, &half_minus_pred_half);
15918   half = const_double_from_real_value (pred_half, scalar_mode);
15920   vec_half = ix86_build_const_vector (<MODE>mode, true, half);
15921   vec_half = force_reg (<MODE>mode, vec_half);
15923   operands[2] = gen_reg_rtx (<MODE>mode);
15924   emit_insn (gen_copysign<mode>3 (operands[2], vec_half, operands[1]));
15926   operands[3] = gen_reg_rtx (<MODE>mode);
15927   operands[4] = GEN_INT (ROUND_TRUNC);
15930 (define_expand "round<mode>2_sfix"
15931   [(match_operand:<sseintvecmode> 0 "register_operand")
15932    (match_operand:VF1 1 "register_operand")]
15933   "TARGET_SSE4_1 && !flag_trapping_math"
15935   rtx tmp = gen_reg_rtx (<MODE>mode);
15937   emit_insn (gen_round<mode>2 (tmp, operands[1]));
15939   emit_insn
15940     (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
15941   DONE;
15944 (define_expand "round<mode>2_vec_pack_sfix"
15945   [(match_operand:<ssepackfltmode> 0 "register_operand")
15946    (match_operand:VF2 1 "register_operand")
15947    (match_operand:VF2 2 "register_operand")]
15948   "TARGET_SSE4_1 && !flag_trapping_math"
15950   rtx tmp0, tmp1;
15952   if (<MODE>mode == V2DFmode
15953       && TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
15954     {
15955       rtx tmp2 = gen_reg_rtx (V4DFmode);
15957       tmp0 = gen_reg_rtx (V4DFmode);
15958       tmp1 = force_reg (V2DFmode, operands[1]);
15960       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
15961       emit_insn (gen_roundv4df2 (tmp2, tmp0));
15962       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp2));
15963     }
15964   else
15965     {
15966       tmp0 = gen_reg_rtx (<MODE>mode);
15967       tmp1 = gen_reg_rtx (<MODE>mode);
15969       emit_insn (gen_round<mode>2 (tmp0, operands[1]));
15970       emit_insn (gen_round<mode>2 (tmp1, operands[2]));
15972       emit_insn
15973        (gen_vec_pack_sfix_trunc_<mode> (operands[0], tmp0, tmp1));
15974     }
15975   DONE;
15978 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15980 ;; Intel SSE4.2 string/text processing instructions
15982 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15984 (define_insn_and_split "sse4_2_pcmpestr"
15985   [(set (match_operand:SI 0 "register_operand" "=c,c")
15986         (unspec:SI
15987           [(match_operand:V16QI 2 "register_operand" "x,x")
15988            (match_operand:SI 3 "register_operand" "a,a")
15989            (match_operand:V16QI 4 "nonimmediate_operand" "x,m")
15990            (match_operand:SI 5 "register_operand" "d,d")
15991            (match_operand:SI 6 "const_0_to_255_operand" "n,n")]
15992           UNSPEC_PCMPESTR))
15993    (set (match_operand:V16QI 1 "register_operand" "=Yz,Yz")
15994         (unspec:V16QI
15995           [(match_dup 2)
15996            (match_dup 3)
15997            (match_dup 4)
15998            (match_dup 5)
15999            (match_dup 6)]
16000           UNSPEC_PCMPESTR))
16001    (set (reg:CC FLAGS_REG)
16002         (unspec:CC
16003           [(match_dup 2)
16004            (match_dup 3)
16005            (match_dup 4)
16006            (match_dup 5)
16007            (match_dup 6)]
16008           UNSPEC_PCMPESTR))]
16009   "TARGET_SSE4_2
16010    && can_create_pseudo_p ()"
16011   "#"
16012   "&& 1"
16013   [(const_int 0)]
16015   int ecx = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[0]));
16016   int xmm0 = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[1]));
16017   int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
16019   if (ecx)
16020     emit_insn (gen_sse4_2_pcmpestri (operands[0], operands[2],
16021                                      operands[3], operands[4],
16022                                      operands[5], operands[6]));
16023   if (xmm0)
16024     emit_insn (gen_sse4_2_pcmpestrm (operands[1], operands[2],
16025                                      operands[3], operands[4],
16026                                      operands[5], operands[6]));
16027   if (flags && !(ecx || xmm0))
16028     emit_insn (gen_sse4_2_pcmpestr_cconly (NULL, NULL,
16029                                            operands[2], operands[3],
16030                                            operands[4], operands[5],
16031                                            operands[6]));
16032   if (!(flags || ecx || xmm0))
16033     emit_note (NOTE_INSN_DELETED);
16035   DONE;
16037   [(set_attr "type" "sselog")
16038    (set_attr "prefix_data16" "1")
16039    (set_attr "prefix_extra" "1")
16040    (set_attr "length_immediate" "1")
16041    (set_attr "memory" "none,load")
16042    (set_attr "mode" "TI")])
16044 (define_insn "sse4_2_pcmpestri"
16045   [(set (match_operand:SI 0 "register_operand" "=c,c")
16046         (unspec:SI
16047           [(match_operand:V16QI 1 "register_operand" "x,x")
16048            (match_operand:SI 2 "register_operand" "a,a")
16049            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
16050            (match_operand:SI 4 "register_operand" "d,d")
16051            (match_operand:SI 5 "const_0_to_255_operand" "n,n")]
16052           UNSPEC_PCMPESTR))
16053    (set (reg:CC FLAGS_REG)
16054         (unspec:CC
16055           [(match_dup 1)
16056            (match_dup 2)
16057            (match_dup 3)
16058            (match_dup 4)
16059            (match_dup 5)]
16060           UNSPEC_PCMPESTR))]
16061   "TARGET_SSE4_2"
16062   "%vpcmpestri\t{%5, %3, %1|%1, %3, %5}"
16063   [(set_attr "type" "sselog")
16064    (set_attr "prefix_data16" "1")
16065    (set_attr "prefix_extra" "1")
16066    (set_attr "prefix" "maybe_vex")
16067    (set_attr "length_immediate" "1")
16068    (set_attr "btver2_decode" "vector")
16069    (set_attr "memory" "none,load")
16070    (set_attr "mode" "TI")])
16072 (define_insn "sse4_2_pcmpestrm"
16073   [(set (match_operand:V16QI 0 "register_operand" "=Yz,Yz")
16074         (unspec:V16QI
16075           [(match_operand:V16QI 1 "register_operand" "x,x")
16076            (match_operand:SI 2 "register_operand" "a,a")
16077            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
16078            (match_operand:SI 4 "register_operand" "d,d")
16079            (match_operand:SI 5 "const_0_to_255_operand" "n,n")]
16080           UNSPEC_PCMPESTR))
16081    (set (reg:CC FLAGS_REG)
16082         (unspec:CC
16083           [(match_dup 1)
16084            (match_dup 2)
16085            (match_dup 3)
16086            (match_dup 4)
16087            (match_dup 5)]
16088           UNSPEC_PCMPESTR))]
16089   "TARGET_SSE4_2"
16090   "%vpcmpestrm\t{%5, %3, %1|%1, %3, %5}"
16091   [(set_attr "type" "sselog")
16092    (set_attr "prefix_data16" "1")
16093    (set_attr "prefix_extra" "1")
16094    (set_attr "length_immediate" "1")
16095    (set_attr "prefix" "maybe_vex")
16096    (set_attr "btver2_decode" "vector")
16097    (set_attr "memory" "none,load")
16098    (set_attr "mode" "TI")])
16100 (define_insn "sse4_2_pcmpestr_cconly"
16101   [(set (reg:CC FLAGS_REG)
16102         (unspec:CC
16103           [(match_operand:V16QI 2 "register_operand" "x,x,x,x")
16104            (match_operand:SI 3 "register_operand" "a,a,a,a")
16105            (match_operand:V16QI 4 "nonimmediate_operand" "x,m,x,m")
16106            (match_operand:SI 5 "register_operand" "d,d,d,d")
16107            (match_operand:SI 6 "const_0_to_255_operand" "n,n,n,n")]
16108           UNSPEC_PCMPESTR))
16109    (clobber (match_scratch:V16QI 0 "=Yz,Yz,X,X"))
16110    (clobber (match_scratch:SI    1 "= X, X,c,c"))]
16111   "TARGET_SSE4_2"
16112   "@
16113    %vpcmpestrm\t{%6, %4, %2|%2, %4, %6}
16114    %vpcmpestrm\t{%6, %4, %2|%2, %4, %6}
16115    %vpcmpestri\t{%6, %4, %2|%2, %4, %6}
16116    %vpcmpestri\t{%6, %4, %2|%2, %4, %6}"
16117   [(set_attr "type" "sselog")
16118    (set_attr "prefix_data16" "1")
16119    (set_attr "prefix_extra" "1")
16120    (set_attr "length_immediate" "1")
16121    (set_attr "memory" "none,load,none,load")
16122    (set_attr "btver2_decode" "vector,vector,vector,vector") 
16123    (set_attr "prefix" "maybe_vex")
16124    (set_attr "mode" "TI")])
16126 (define_insn_and_split "sse4_2_pcmpistr"
16127   [(set (match_operand:SI 0 "register_operand" "=c,c")
16128         (unspec:SI
16129           [(match_operand:V16QI 2 "register_operand" "x,x")
16130            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
16131            (match_operand:SI 4 "const_0_to_255_operand" "n,n")]
16132           UNSPEC_PCMPISTR))
16133    (set (match_operand:V16QI 1 "register_operand" "=Yz,Yz")
16134         (unspec:V16QI
16135           [(match_dup 2)
16136            (match_dup 3)
16137            (match_dup 4)]
16138           UNSPEC_PCMPISTR))
16139    (set (reg:CC FLAGS_REG)
16140         (unspec:CC
16141           [(match_dup 2)
16142            (match_dup 3)
16143            (match_dup 4)]
16144           UNSPEC_PCMPISTR))]
16145   "TARGET_SSE4_2
16146    && can_create_pseudo_p ()"
16147   "#"
16148   "&& 1"
16149   [(const_int 0)]
16151   int ecx = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[0]));
16152   int xmm0 = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[1]));
16153   int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
16155   if (ecx)
16156     emit_insn (gen_sse4_2_pcmpistri (operands[0], operands[2],
16157                                      operands[3], operands[4]));
16158   if (xmm0)
16159     emit_insn (gen_sse4_2_pcmpistrm (operands[1], operands[2],
16160                                      operands[3], operands[4]));
16161   if (flags && !(ecx || xmm0))
16162     emit_insn (gen_sse4_2_pcmpistr_cconly (NULL, NULL,
16163                                            operands[2], operands[3],
16164                                            operands[4]));
16165   if (!(flags || ecx || xmm0))
16166     emit_note (NOTE_INSN_DELETED);
16168   DONE;
16170   [(set_attr "type" "sselog")
16171    (set_attr "prefix_data16" "1")
16172    (set_attr "prefix_extra" "1")
16173    (set_attr "length_immediate" "1")
16174    (set_attr "memory" "none,load")
16175    (set_attr "mode" "TI")])
16177 (define_insn "sse4_2_pcmpistri"
16178   [(set (match_operand:SI 0 "register_operand" "=c,c")
16179         (unspec:SI
16180           [(match_operand:V16QI 1 "register_operand" "x,x")
16181            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
16182            (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
16183           UNSPEC_PCMPISTR))
16184    (set (reg:CC FLAGS_REG)
16185         (unspec:CC
16186           [(match_dup 1)
16187            (match_dup 2)
16188            (match_dup 3)]
16189           UNSPEC_PCMPISTR))]
16190   "TARGET_SSE4_2"
16191   "%vpcmpistri\t{%3, %2, %1|%1, %2, %3}"
16192   [(set_attr "type" "sselog")
16193    (set_attr "prefix_data16" "1")
16194    (set_attr "prefix_extra" "1")
16195    (set_attr "length_immediate" "1")
16196    (set_attr "prefix" "maybe_vex")
16197    (set_attr "memory" "none,load")
16198    (set_attr "btver2_decode" "vector")
16199    (set_attr "mode" "TI")])
16201 (define_insn "sse4_2_pcmpistrm"
16202   [(set (match_operand:V16QI 0 "register_operand" "=Yz,Yz")
16203         (unspec:V16QI
16204           [(match_operand:V16QI 1 "register_operand" "x,x")
16205            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
16206            (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
16207           UNSPEC_PCMPISTR))
16208    (set (reg:CC FLAGS_REG)
16209         (unspec:CC
16210           [(match_dup 1)
16211            (match_dup 2)
16212            (match_dup 3)]
16213           UNSPEC_PCMPISTR))]
16214   "TARGET_SSE4_2"
16215   "%vpcmpistrm\t{%3, %2, %1|%1, %2, %3}"
16216   [(set_attr "type" "sselog")
16217    (set_attr "prefix_data16" "1")
16218    (set_attr "prefix_extra" "1")
16219    (set_attr "length_immediate" "1")
16220    (set_attr "prefix" "maybe_vex")
16221    (set_attr "memory" "none,load")
16222    (set_attr "btver2_decode" "vector")
16223    (set_attr "mode" "TI")])
16225 (define_insn "sse4_2_pcmpistr_cconly"
16226   [(set (reg:CC FLAGS_REG)
16227         (unspec:CC
16228           [(match_operand:V16QI 2 "register_operand" "x,x,x,x")
16229            (match_operand:V16QI 3 "nonimmediate_operand" "x,m,x,m")
16230            (match_operand:SI 4 "const_0_to_255_operand" "n,n,n,n")]
16231           UNSPEC_PCMPISTR))
16232    (clobber (match_scratch:V16QI 0 "=Yz,Yz,X,X"))
16233    (clobber (match_scratch:SI    1 "= X, X,c,c"))]
16234   "TARGET_SSE4_2"
16235   "@
16236    %vpcmpistrm\t{%4, %3, %2|%2, %3, %4}
16237    %vpcmpistrm\t{%4, %3, %2|%2, %3, %4}
16238    %vpcmpistri\t{%4, %3, %2|%2, %3, %4}
16239    %vpcmpistri\t{%4, %3, %2|%2, %3, %4}"
16240   [(set_attr "type" "sselog")
16241    (set_attr "prefix_data16" "1")
16242    (set_attr "prefix_extra" "1")
16243    (set_attr "length_immediate" "1")
16244    (set_attr "memory" "none,load,none,load")
16245    (set_attr "prefix" "maybe_vex")
16246    (set_attr "btver2_decode" "vector,vector,vector,vector")
16247    (set_attr "mode" "TI")])
16249 ;; Packed float variants
16250 (define_mode_attr GATHER_SCATTER_SF_MEM_MODE
16251                       [(V8DI "V8SF") (V16SI "V16SF")])
16253 (define_expand "avx512pf_gatherpf<mode>sf"
16254   [(unspec
16255      [(match_operand:<avx512fmaskmode> 0 "register_operand")
16256       (mem:<GATHER_SCATTER_SF_MEM_MODE>
16257         (match_par_dup 5
16258           [(match_operand 2 "vsib_address_operand")
16259            (match_operand:VI48_512 1 "register_operand")
16260            (match_operand:SI 3 "const1248_operand")]))
16261       (match_operand:SI 4 "const_2_to_3_operand")]
16262      UNSPEC_GATHER_PREFETCH)]
16263   "TARGET_AVX512PF"
16265   operands[5]
16266     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
16267                                         operands[3]), UNSPEC_VSIBADDR);
16270 (define_insn "*avx512pf_gatherpf<mode>sf_mask"
16271   [(unspec
16272      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
16273       (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 5 "vsib_mem_operator"
16274         [(unspec:P
16275            [(match_operand:P 2 "vsib_address_operand" "Tv")
16276             (match_operand:VI48_512 1 "register_operand" "v")
16277             (match_operand:SI 3 "const1248_operand" "n")]
16278            UNSPEC_VSIBADDR)])
16279       (match_operand:SI 4 "const_2_to_3_operand" "n")]
16280      UNSPEC_GATHER_PREFETCH)]
16281   "TARGET_AVX512PF"
16283   switch (INTVAL (operands[4]))
16284     {
16285     case 3:
16286       return "vgatherpf0<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
16287     case 2:
16288       return "vgatherpf1<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
16289     default:
16290       gcc_unreachable ();
16291     }
16293   [(set_attr "type" "sse")
16294    (set_attr "prefix" "evex")
16295    (set_attr "mode" "XI")])
16297 ;; Packed double variants
16298 (define_expand "avx512pf_gatherpf<mode>df"
16299   [(unspec
16300      [(match_operand:<avx512fmaskmode> 0 "register_operand")
16301       (mem:V8DF
16302         (match_par_dup 5
16303           [(match_operand 2 "vsib_address_operand")
16304            (match_operand:VI4_256_8_512 1 "register_operand")
16305            (match_operand:SI 3 "const1248_operand")]))
16306       (match_operand:SI 4 "const_2_to_3_operand")]
16307      UNSPEC_GATHER_PREFETCH)]
16308   "TARGET_AVX512PF"
16310   operands[5]
16311     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
16312                                         operands[3]), UNSPEC_VSIBADDR);
16315 (define_insn "*avx512pf_gatherpf<mode>df_mask"
16316   [(unspec
16317      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
16318       (match_operator:V8DF 5 "vsib_mem_operator"
16319         [(unspec:P
16320            [(match_operand:P 2 "vsib_address_operand" "Tv")
16321             (match_operand:VI4_256_8_512 1 "register_operand" "v")
16322             (match_operand:SI 3 "const1248_operand" "n")]
16323            UNSPEC_VSIBADDR)])
16324       (match_operand:SI 4 "const_2_to_3_operand" "n")]
16325      UNSPEC_GATHER_PREFETCH)]
16326   "TARGET_AVX512PF"
16328   switch (INTVAL (operands[4]))
16329     {
16330     case 3:
16331       return "vgatherpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
16332     case 2:
16333       return "vgatherpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
16334     default:
16335       gcc_unreachable ();
16336     }
16338   [(set_attr "type" "sse")
16339    (set_attr "prefix" "evex")
16340    (set_attr "mode" "XI")])
16342 ;; Packed float variants
16343 (define_expand "avx512pf_scatterpf<mode>sf"
16344   [(unspec
16345      [(match_operand:<avx512fmaskmode> 0 "register_operand")
16346       (mem:<GATHER_SCATTER_SF_MEM_MODE>
16347         (match_par_dup 5
16348           [(match_operand 2 "vsib_address_operand")
16349            (match_operand:VI48_512 1 "register_operand")
16350            (match_operand:SI 3 "const1248_operand")]))
16351       (match_operand:SI 4 "const2367_operand")]
16352      UNSPEC_SCATTER_PREFETCH)]
16353   "TARGET_AVX512PF"
16355   operands[5]
16356     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
16357                                         operands[3]), UNSPEC_VSIBADDR);
16360 (define_insn "*avx512pf_scatterpf<mode>sf_mask"
16361   [(unspec
16362      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
16363       (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 5 "vsib_mem_operator"
16364         [(unspec:P
16365            [(match_operand:P 2 "vsib_address_operand" "Tv")
16366             (match_operand:VI48_512 1 "register_operand" "v")
16367             (match_operand:SI 3 "const1248_operand" "n")]
16368            UNSPEC_VSIBADDR)])
16369       (match_operand:SI 4 "const2367_operand" "n")]
16370      UNSPEC_SCATTER_PREFETCH)]
16371   "TARGET_AVX512PF"
16373   switch (INTVAL (operands[4]))
16374     {
16375     case 3:
16376     case 7:
16377       return "vscatterpf0<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
16378     case 2:
16379     case 6:
16380       return "vscatterpf1<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
16381     default:
16382       gcc_unreachable ();
16383     }
16385   [(set_attr "type" "sse")
16386    (set_attr "prefix" "evex")
16387    (set_attr "mode" "XI")])
16389 ;; Packed double variants
16390 (define_expand "avx512pf_scatterpf<mode>df"
16391   [(unspec
16392      [(match_operand:<avx512fmaskmode> 0 "register_operand")
16393       (mem:V8DF
16394         (match_par_dup 5
16395           [(match_operand 2 "vsib_address_operand")
16396            (match_operand:VI4_256_8_512 1 "register_operand")
16397            (match_operand:SI 3 "const1248_operand")]))
16398       (match_operand:SI 4 "const2367_operand")]
16399      UNSPEC_SCATTER_PREFETCH)]
16400   "TARGET_AVX512PF"
16402   operands[5]
16403     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
16404                                         operands[3]), UNSPEC_VSIBADDR);
16407 (define_insn "*avx512pf_scatterpf<mode>df_mask"
16408   [(unspec
16409      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
16410       (match_operator:V8DF 5 "vsib_mem_operator"
16411         [(unspec:P
16412            [(match_operand:P 2 "vsib_address_operand" "Tv")
16413             (match_operand:VI4_256_8_512 1 "register_operand" "v")
16414             (match_operand:SI 3 "const1248_operand" "n")]
16415            UNSPEC_VSIBADDR)])
16416       (match_operand:SI 4 "const2367_operand" "n")]
16417      UNSPEC_SCATTER_PREFETCH)]
16418   "TARGET_AVX512PF"
16420   switch (INTVAL (operands[4]))
16421     {
16422     case 3:
16423     case 7:
16424       return "vscatterpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
16425     case 2:
16426     case 6:
16427       return "vscatterpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
16428     default:
16429       gcc_unreachable ();
16430     }
16432   [(set_attr "type" "sse")
16433    (set_attr "prefix" "evex")
16434    (set_attr "mode" "XI")])
16436 (define_insn "avx512er_exp2<mode><mask_name><round_saeonly_name>"
16437   [(set (match_operand:VF_512 0 "register_operand" "=v")
16438         (unspec:VF_512
16439           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16440           UNSPEC_EXP2))]
16441   "TARGET_AVX512ER"
16442   "vexp2<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
16443   [(set_attr "prefix" "evex")
16444    (set_attr "type" "sse")
16445    (set_attr "mode" "<MODE>")])
16447 (define_insn "<mask_codefor>avx512er_rcp28<mode><mask_name><round_saeonly_name>"
16448   [(set (match_operand:VF_512 0 "register_operand" "=v")
16449         (unspec:VF_512
16450           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16451           UNSPEC_RCP28))]
16452   "TARGET_AVX512ER"
16453   "vrcp28<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
16454   [(set_attr "prefix" "evex")
16455    (set_attr "type" "sse")
16456    (set_attr "mode" "<MODE>")])
16458 (define_insn "avx512er_vmrcp28<mode><round_saeonly_name>"
16459   [(set (match_operand:VF_128 0 "register_operand" "=v")
16460         (vec_merge:VF_128
16461           (unspec:VF_128
16462             [(match_operand:VF_128 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16463             UNSPEC_RCP28)
16464           (match_operand:VF_128 2 "register_operand" "v")
16465           (const_int 1)))]
16466   "TARGET_AVX512ER"
16467   "vrcp28<ssescalarmodesuffix>\t{<round_saeonly_op3>%1, %2, %0|%0, %2, %<iptr>1<round_saeonly_op3>}"
16468   [(set_attr "length_immediate" "1")
16469    (set_attr "prefix" "evex")
16470    (set_attr "type" "sse")
16471    (set_attr "mode" "<MODE>")])
16473 (define_insn "<mask_codefor>avx512er_rsqrt28<mode><mask_name><round_saeonly_name>"
16474   [(set (match_operand:VF_512 0 "register_operand" "=v")
16475         (unspec:VF_512
16476           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16477           UNSPEC_RSQRT28))]
16478   "TARGET_AVX512ER"
16479   "vrsqrt28<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
16480   [(set_attr "prefix" "evex")
16481    (set_attr "type" "sse")
16482    (set_attr "mode" "<MODE>")])
16484 (define_insn "avx512er_vmrsqrt28<mode><round_saeonly_name>"
16485   [(set (match_operand:VF_128 0 "register_operand" "=v")
16486         (vec_merge:VF_128
16487           (unspec:VF_128
16488             [(match_operand:VF_128 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16489             UNSPEC_RSQRT28)
16490           (match_operand:VF_128 2 "register_operand" "v")
16491           (const_int 1)))]
16492   "TARGET_AVX512ER"
16493   "vrsqrt28<ssescalarmodesuffix>\t{<round_saeonly_op3>%1, %2, %0|%0, %2, %<iptr>1<round_saeonly_op3>}"
16494   [(set_attr "length_immediate" "1")
16495    (set_attr "type" "sse")
16496    (set_attr "prefix" "evex")
16497    (set_attr "mode" "<MODE>")])
16499 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16501 ;; XOP instructions
16503 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16505 (define_code_iterator xop_plus [plus ss_plus])
16507 (define_code_attr macs [(plus "macs") (ss_plus "macss")])
16508 (define_code_attr madcs [(plus "madcs") (ss_plus "madcss")])
16510 ;; XOP parallel integer multiply/add instructions.
16512 (define_insn "xop_p<macs><ssemodesuffix><ssemodesuffix>"
16513   [(set (match_operand:VI24_128 0 "register_operand" "=x")
16514         (xop_plus:VI24_128
16515          (mult:VI24_128
16516           (match_operand:VI24_128 1 "nonimmediate_operand" "%x")
16517           (match_operand:VI24_128 2 "nonimmediate_operand" "xm"))
16518          (match_operand:VI24_128 3 "register_operand" "x")))]
16519   "TARGET_XOP"
16520   "vp<macs><ssemodesuffix><ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16521   [(set_attr "type" "ssemuladd")
16522    (set_attr "mode" "TI")])
16524 (define_insn "xop_p<macs>dql"
16525   [(set (match_operand:V2DI 0 "register_operand" "=x")
16526         (xop_plus:V2DI
16527          (mult:V2DI
16528           (sign_extend:V2DI
16529            (vec_select:V2SI
16530             (match_operand:V4SI 1 "nonimmediate_operand" "%x")
16531             (parallel [(const_int 0) (const_int 2)])))
16532           (sign_extend:V2DI
16533            (vec_select:V2SI
16534             (match_operand:V4SI 2 "nonimmediate_operand" "xm")
16535             (parallel [(const_int 0) (const_int 2)]))))
16536          (match_operand:V2DI 3 "register_operand" "x")))]
16537   "TARGET_XOP"
16538   "vp<macs>dql\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16539   [(set_attr "type" "ssemuladd")
16540    (set_attr "mode" "TI")])
16542 (define_insn "xop_p<macs>dqh"
16543   [(set (match_operand:V2DI 0 "register_operand" "=x")
16544         (xop_plus:V2DI
16545          (mult:V2DI
16546           (sign_extend:V2DI
16547            (vec_select:V2SI
16548             (match_operand:V4SI 1 "nonimmediate_operand" "%x")
16549             (parallel [(const_int 1) (const_int 3)])))
16550           (sign_extend:V2DI
16551            (vec_select:V2SI
16552             (match_operand:V4SI 2 "nonimmediate_operand" "xm")
16553             (parallel [(const_int 1) (const_int 3)]))))
16554          (match_operand:V2DI 3 "register_operand" "x")))]
16555   "TARGET_XOP"
16556   "vp<macs>dqh\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16557   [(set_attr "type" "ssemuladd")
16558    (set_attr "mode" "TI")])
16560 ;; XOP parallel integer multiply/add instructions for the intrinisics
16561 (define_insn "xop_p<macs>wd"
16562   [(set (match_operand:V4SI 0 "register_operand" "=x")
16563         (xop_plus:V4SI
16564          (mult:V4SI
16565           (sign_extend:V4SI
16566            (vec_select:V4HI
16567             (match_operand:V8HI 1 "nonimmediate_operand" "%x")
16568             (parallel [(const_int 1) (const_int 3)
16569                        (const_int 5) (const_int 7)])))
16570           (sign_extend:V4SI
16571            (vec_select:V4HI
16572             (match_operand:V8HI 2 "nonimmediate_operand" "xm")
16573             (parallel [(const_int 1) (const_int 3)
16574                        (const_int 5) (const_int 7)]))))
16575          (match_operand:V4SI 3 "register_operand" "x")))]
16576   "TARGET_XOP"
16577   "vp<macs>wd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16578   [(set_attr "type" "ssemuladd")
16579    (set_attr "mode" "TI")])
16581 (define_insn "xop_p<madcs>wd"
16582   [(set (match_operand:V4SI 0 "register_operand" "=x")
16583         (xop_plus:V4SI
16584          (plus:V4SI
16585           (mult:V4SI
16586            (sign_extend:V4SI
16587             (vec_select:V4HI
16588              (match_operand:V8HI 1 "nonimmediate_operand" "%x")
16589              (parallel [(const_int 0) (const_int 2)
16590                         (const_int 4) (const_int 6)])))
16591            (sign_extend:V4SI
16592             (vec_select:V4HI
16593              (match_operand:V8HI 2 "nonimmediate_operand" "xm")
16594              (parallel [(const_int 0) (const_int 2)
16595                         (const_int 4) (const_int 6)]))))
16596           (mult:V4SI
16597            (sign_extend:V4SI
16598             (vec_select:V4HI
16599              (match_dup 1)
16600              (parallel [(const_int 1) (const_int 3)
16601                         (const_int 5) (const_int 7)])))
16602            (sign_extend:V4SI
16603             (vec_select:V4HI
16604              (match_dup 2)
16605              (parallel [(const_int 1) (const_int 3)
16606                         (const_int 5) (const_int 7)])))))
16607          (match_operand:V4SI 3 "register_operand" "x")))]
16608   "TARGET_XOP"
16609   "vp<madcs>wd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16610   [(set_attr "type" "ssemuladd")
16611    (set_attr "mode" "TI")])
16613 ;; XOP parallel XMM conditional moves
16614 (define_insn "xop_pcmov_<mode><avxsizesuffix>"
16615   [(set (match_operand:V_128_256 0 "register_operand" "=x,x")
16616         (if_then_else:V_128_256
16617           (match_operand:V_128_256 3 "nonimmediate_operand" "x,m")
16618           (match_operand:V_128_256 1 "register_operand" "x,x")
16619           (match_operand:V_128_256 2 "nonimmediate_operand" "xm,x")))]
16620   "TARGET_XOP"
16621   "vpcmov\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16622   [(set_attr "type" "sse4arg")])
16624 ;; XOP horizontal add/subtract instructions
16625 (define_insn "xop_phadd<u>bw"
16626   [(set (match_operand:V8HI 0 "register_operand" "=x")
16627         (plus:V8HI
16628          (any_extend:V8HI
16629           (vec_select:V8QI
16630            (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16631            (parallel [(const_int 0) (const_int 2)
16632                       (const_int 4) (const_int 6)
16633                       (const_int 8) (const_int 10)
16634                       (const_int 12) (const_int 14)])))
16635          (any_extend:V8HI
16636           (vec_select:V8QI
16637            (match_dup 1)
16638            (parallel [(const_int 1) (const_int 3)
16639                       (const_int 5) (const_int 7)
16640                       (const_int 9) (const_int 11)
16641                       (const_int 13) (const_int 15)])))))]
16642   "TARGET_XOP"
16643   "vphadd<u>bw\t{%1, %0|%0, %1}"
16644   [(set_attr "type" "sseiadd1")])
16646 (define_insn "xop_phadd<u>bd"
16647   [(set (match_operand:V4SI 0 "register_operand" "=x")
16648         (plus:V4SI
16649          (plus:V4SI
16650           (any_extend:V4SI
16651            (vec_select:V4QI
16652             (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16653             (parallel [(const_int 0) (const_int 4)
16654                        (const_int 8) (const_int 12)])))
16655           (any_extend:V4SI
16656            (vec_select:V4QI
16657             (match_dup 1)
16658             (parallel [(const_int 1) (const_int 5)
16659                        (const_int 9) (const_int 13)]))))
16660          (plus:V4SI
16661           (any_extend:V4SI
16662            (vec_select:V4QI
16663             (match_dup 1)
16664             (parallel [(const_int 2) (const_int 6)
16665                        (const_int 10) (const_int 14)])))
16666           (any_extend:V4SI
16667            (vec_select:V4QI
16668             (match_dup 1)
16669             (parallel [(const_int 3) (const_int 7)
16670                        (const_int 11) (const_int 15)]))))))]
16671   "TARGET_XOP"
16672   "vphadd<u>bd\t{%1, %0|%0, %1}"
16673   [(set_attr "type" "sseiadd1")])
16675 (define_insn "xop_phadd<u>bq"
16676   [(set (match_operand:V2DI 0 "register_operand" "=x")
16677         (plus:V2DI
16678          (plus:V2DI
16679           (plus:V2DI
16680            (any_extend:V2DI
16681             (vec_select:V2QI
16682              (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16683              (parallel [(const_int 0) (const_int 8)])))
16684            (any_extend:V2DI
16685             (vec_select:V2QI
16686              (match_dup 1)
16687              (parallel [(const_int 1) (const_int 9)]))))
16688           (plus:V2DI
16689            (any_extend:V2DI
16690             (vec_select:V2QI
16691              (match_dup 1)
16692              (parallel [(const_int 2) (const_int 10)])))
16693            (any_extend:V2DI
16694             (vec_select:V2QI
16695              (match_dup 1)
16696              (parallel [(const_int 3) (const_int 11)])))))
16697          (plus:V2DI
16698           (plus:V2DI
16699            (any_extend:V2DI
16700             (vec_select:V2QI
16701              (match_dup 1)
16702              (parallel [(const_int 4) (const_int 12)])))
16703            (any_extend:V2DI
16704             (vec_select:V2QI
16705              (match_dup 1)
16706              (parallel [(const_int 5) (const_int 13)]))))
16707           (plus:V2DI
16708            (any_extend:V2DI
16709             (vec_select:V2QI
16710              (match_dup 1)
16711              (parallel [(const_int 6) (const_int 14)])))
16712            (any_extend:V2DI
16713             (vec_select:V2QI
16714              (match_dup 1)
16715              (parallel [(const_int 7) (const_int 15)])))))))]
16716   "TARGET_XOP"
16717   "vphadd<u>bq\t{%1, %0|%0, %1}"
16718   [(set_attr "type" "sseiadd1")])
16720 (define_insn "xop_phadd<u>wd"
16721   [(set (match_operand:V4SI 0 "register_operand" "=x")
16722         (plus:V4SI
16723          (any_extend:V4SI
16724           (vec_select:V4HI
16725            (match_operand:V8HI 1 "nonimmediate_operand" "xm")
16726            (parallel [(const_int 0) (const_int 2)
16727                       (const_int 4) (const_int 6)])))
16728          (any_extend:V4SI
16729           (vec_select:V4HI
16730            (match_dup 1)
16731            (parallel [(const_int 1) (const_int 3)
16732                       (const_int 5) (const_int 7)])))))]
16733   "TARGET_XOP"
16734   "vphadd<u>wd\t{%1, %0|%0, %1}"
16735   [(set_attr "type" "sseiadd1")])
16737 (define_insn "xop_phadd<u>wq"
16738   [(set (match_operand:V2DI 0 "register_operand" "=x")
16739         (plus:V2DI
16740          (plus:V2DI
16741           (any_extend:V2DI
16742            (vec_select:V2HI
16743             (match_operand:V8HI 1 "nonimmediate_operand" "xm")
16744             (parallel [(const_int 0) (const_int 4)])))
16745           (any_extend:V2DI
16746            (vec_select:V2HI
16747             (match_dup 1)
16748             (parallel [(const_int 1) (const_int 5)]))))
16749          (plus:V2DI
16750           (any_extend:V2DI
16751            (vec_select:V2HI
16752             (match_dup 1)
16753             (parallel [(const_int 2) (const_int 6)])))
16754           (any_extend:V2DI
16755            (vec_select:V2HI
16756             (match_dup 1)
16757             (parallel [(const_int 3) (const_int 7)]))))))]
16758   "TARGET_XOP"
16759   "vphadd<u>wq\t{%1, %0|%0, %1}"
16760   [(set_attr "type" "sseiadd1")])
16762 (define_insn "xop_phadd<u>dq"
16763   [(set (match_operand:V2DI 0 "register_operand" "=x")
16764         (plus:V2DI
16765          (any_extend:V2DI
16766           (vec_select:V2SI
16767            (match_operand:V4SI 1 "nonimmediate_operand" "xm")
16768            (parallel [(const_int 0) (const_int 2)])))
16769          (any_extend:V2DI
16770           (vec_select:V2SI
16771            (match_dup 1)
16772            (parallel [(const_int 1) (const_int 3)])))))]
16773   "TARGET_XOP"
16774   "vphadd<u>dq\t{%1, %0|%0, %1}"
16775   [(set_attr "type" "sseiadd1")])
16777 (define_insn "xop_phsubbw"
16778   [(set (match_operand:V8HI 0 "register_operand" "=x")
16779         (minus:V8HI
16780          (sign_extend:V8HI
16781           (vec_select:V8QI
16782            (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16783            (parallel [(const_int 0) (const_int 2)
16784                       (const_int 4) (const_int 6)
16785                       (const_int 8) (const_int 10)
16786                       (const_int 12) (const_int 14)])))
16787          (sign_extend:V8HI
16788           (vec_select:V8QI
16789            (match_dup 1)
16790            (parallel [(const_int 1) (const_int 3)
16791                       (const_int 5) (const_int 7)
16792                       (const_int 9) (const_int 11)
16793                       (const_int 13) (const_int 15)])))))]
16794   "TARGET_XOP"
16795   "vphsubbw\t{%1, %0|%0, %1}"
16796   [(set_attr "type" "sseiadd1")])
16798 (define_insn "xop_phsubwd"
16799   [(set (match_operand:V4SI 0 "register_operand" "=x")
16800         (minus:V4SI
16801          (sign_extend:V4SI
16802           (vec_select:V4HI
16803            (match_operand:V8HI 1 "nonimmediate_operand" "xm")
16804            (parallel [(const_int 0) (const_int 2)
16805                       (const_int 4) (const_int 6)])))
16806          (sign_extend:V4SI
16807           (vec_select:V4HI
16808            (match_dup 1)
16809            (parallel [(const_int 1) (const_int 3)
16810                       (const_int 5) (const_int 7)])))))]
16811   "TARGET_XOP"
16812   "vphsubwd\t{%1, %0|%0, %1}"
16813   [(set_attr "type" "sseiadd1")])
16815 (define_insn "xop_phsubdq"
16816   [(set (match_operand:V2DI 0 "register_operand" "=x")
16817         (minus:V2DI
16818          (sign_extend:V2DI
16819           (vec_select:V2SI
16820            (match_operand:V4SI 1 "nonimmediate_operand" "xm")
16821            (parallel [(const_int 0) (const_int 2)])))
16822          (sign_extend:V2DI
16823           (vec_select:V2SI
16824            (match_dup 1)
16825            (parallel [(const_int 1) (const_int 3)])))))]
16826   "TARGET_XOP"
16827   "vphsubdq\t{%1, %0|%0, %1}"
16828   [(set_attr "type" "sseiadd1")])
16830 ;; XOP permute instructions
16831 (define_insn "xop_pperm"
16832   [(set (match_operand:V16QI 0 "register_operand" "=x,x")
16833         (unspec:V16QI
16834           [(match_operand:V16QI 1 "register_operand" "x,x")
16835            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
16836            (match_operand:V16QI 3 "nonimmediate_operand" "xm,x")]
16837           UNSPEC_XOP_PERMUTE))]
16838   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16839   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16840   [(set_attr "type" "sse4arg")
16841    (set_attr "mode" "TI")])
16843 ;; XOP pack instructions that combine two vectors into a smaller vector
16844 (define_insn "xop_pperm_pack_v2di_v4si"
16845   [(set (match_operand:V4SI 0 "register_operand" "=x,x")
16846         (vec_concat:V4SI
16847          (truncate:V2SI
16848           (match_operand:V2DI 1 "register_operand" "x,x"))
16849          (truncate:V2SI
16850           (match_operand:V2DI 2 "nonimmediate_operand" "x,m"))))
16851    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
16852   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16853   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16854   [(set_attr "type" "sse4arg")
16855    (set_attr "mode" "TI")])
16857 (define_insn "xop_pperm_pack_v4si_v8hi"
16858   [(set (match_operand:V8HI 0 "register_operand" "=x,x")
16859         (vec_concat:V8HI
16860          (truncate:V4HI
16861           (match_operand:V4SI 1 "register_operand" "x,x"))
16862          (truncate:V4HI
16863           (match_operand:V4SI 2 "nonimmediate_operand" "x,m"))))
16864    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
16865   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16866   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16867   [(set_attr "type" "sse4arg")
16868    (set_attr "mode" "TI")])
16870 (define_insn "xop_pperm_pack_v8hi_v16qi"
16871   [(set (match_operand:V16QI 0 "register_operand" "=x,x")
16872         (vec_concat:V16QI
16873          (truncate:V8QI
16874           (match_operand:V8HI 1 "register_operand" "x,x"))
16875          (truncate:V8QI
16876           (match_operand:V8HI 2 "nonimmediate_operand" "x,m"))))
16877    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
16878   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16879   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16880   [(set_attr "type" "sse4arg")
16881    (set_attr "mode" "TI")])
16883 ;; XOP packed rotate instructions
16884 (define_expand "rotl<mode>3"
16885   [(set (match_operand:VI_128 0 "register_operand")
16886         (rotate:VI_128
16887          (match_operand:VI_128 1 "nonimmediate_operand")
16888          (match_operand:SI 2 "general_operand")))]
16889   "TARGET_XOP"
16891   /* If we were given a scalar, convert it to parallel */
16892   if (! const_0_to_<sserotatemax>_operand (operands[2], SImode))
16893     {
16894       rtvec vs = rtvec_alloc (<ssescalarnum>);
16895       rtx par = gen_rtx_PARALLEL (<MODE>mode, vs);
16896       rtx reg = gen_reg_rtx (<MODE>mode);
16897       rtx op2 = operands[2];
16898       int i;
16900       if (GET_MODE (op2) != <ssescalarmode>mode)
16901         {
16902           op2 = gen_reg_rtx (<ssescalarmode>mode);
16903           convert_move (op2, operands[2], false);
16904         }
16906       for (i = 0; i < <ssescalarnum>; i++)
16907         RTVEC_ELT (vs, i) = op2;
16909       emit_insn (gen_vec_init<mode><ssescalarmodelower> (reg, par));
16910       emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], reg));
16911       DONE;
16912     }
16915 (define_expand "rotr<mode>3"
16916   [(set (match_operand:VI_128 0 "register_operand")
16917         (rotatert:VI_128
16918          (match_operand:VI_128 1 "nonimmediate_operand")
16919          (match_operand:SI 2 "general_operand")))]
16920   "TARGET_XOP"
16922   /* If we were given a scalar, convert it to parallel */
16923   if (! const_0_to_<sserotatemax>_operand (operands[2], SImode))
16924     {
16925       rtvec vs = rtvec_alloc (<ssescalarnum>);
16926       rtx par = gen_rtx_PARALLEL (<MODE>mode, vs);
16927       rtx neg = gen_reg_rtx (<MODE>mode);
16928       rtx reg = gen_reg_rtx (<MODE>mode);
16929       rtx op2 = operands[2];
16930       int i;
16932       if (GET_MODE (op2) != <ssescalarmode>mode)
16933         {
16934           op2 = gen_reg_rtx (<ssescalarmode>mode);
16935           convert_move (op2, operands[2], false);
16936         }
16938       for (i = 0; i < <ssescalarnum>; i++)
16939         RTVEC_ELT (vs, i) = op2;
16941       emit_insn (gen_vec_init<mode><ssescalarmodelower> (reg, par));
16942       emit_insn (gen_neg<mode>2 (neg, reg));
16943       emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], neg));
16944       DONE;
16945     }
16948 (define_insn "xop_rotl<mode>3"
16949   [(set (match_operand:VI_128 0 "register_operand" "=x")
16950         (rotate:VI_128
16951          (match_operand:VI_128 1 "nonimmediate_operand" "xm")
16952          (match_operand:SI 2 "const_0_to_<sserotatemax>_operand" "n")))]
16953   "TARGET_XOP"
16954   "vprot<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16955   [(set_attr "type" "sseishft")
16956    (set_attr "length_immediate" "1")
16957    (set_attr "mode" "TI")])
16959 (define_insn "xop_rotr<mode>3"
16960   [(set (match_operand:VI_128 0 "register_operand" "=x")
16961         (rotatert:VI_128
16962          (match_operand:VI_128 1 "nonimmediate_operand" "xm")
16963          (match_operand:SI 2 "const_0_to_<sserotatemax>_operand" "n")))]
16964   "TARGET_XOP"
16966   operands[3]
16967     = GEN_INT (GET_MODE_BITSIZE (<ssescalarmode>mode) - INTVAL (operands[2]));
16968   return \"vprot<ssemodesuffix>\t{%3, %1, %0|%0, %1, %3}\";
16970   [(set_attr "type" "sseishft")
16971    (set_attr "length_immediate" "1")
16972    (set_attr "mode" "TI")])
16974 (define_expand "vrotr<mode>3"
16975   [(match_operand:VI_128 0 "register_operand")
16976    (match_operand:VI_128 1 "register_operand")
16977    (match_operand:VI_128 2 "register_operand")]
16978   "TARGET_XOP"
16980   rtx reg = gen_reg_rtx (<MODE>mode);
16981   emit_insn (gen_neg<mode>2 (reg, operands[2]));
16982   emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], reg));
16983   DONE;
16986 (define_expand "vrotl<mode>3"
16987   [(match_operand:VI_128 0 "register_operand")
16988    (match_operand:VI_128 1 "register_operand")
16989    (match_operand:VI_128 2 "register_operand")]
16990   "TARGET_XOP"
16992   emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], operands[2]));
16993   DONE;
16996 (define_insn "xop_vrotl<mode>3"
16997   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
16998         (if_then_else:VI_128
16999          (ge:VI_128
17000           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
17001           (const_int 0))
17002          (rotate:VI_128
17003           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
17004           (match_dup 2))
17005          (rotatert:VI_128
17006           (match_dup 1)
17007           (neg:VI_128 (match_dup 2)))))]
17008   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17009   "vprot<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17010   [(set_attr "type" "sseishft")
17011    (set_attr "prefix_data16" "0")
17012    (set_attr "prefix_extra" "2")
17013    (set_attr "mode" "TI")])
17015 ;; XOP packed shift instructions.
17016 (define_expand "vlshr<mode>3"
17017   [(set (match_operand:VI12_128 0 "register_operand")
17018         (lshiftrt:VI12_128
17019           (match_operand:VI12_128 1 "register_operand")
17020           (match_operand:VI12_128 2 "nonimmediate_operand")))]
17021   "TARGET_XOP"
17023   rtx neg = gen_reg_rtx (<MODE>mode);
17024   emit_insn (gen_neg<mode>2 (neg, operands[2]));
17025   emit_insn (gen_xop_shl<mode>3 (operands[0], operands[1], neg));
17026   DONE;
17029 (define_expand "vlshr<mode>3"
17030   [(set (match_operand:VI48_128 0 "register_operand")
17031         (lshiftrt:VI48_128
17032           (match_operand:VI48_128 1 "register_operand")
17033           (match_operand:VI48_128 2 "nonimmediate_operand")))]
17034   "TARGET_AVX2 || TARGET_XOP"
17036   if (!TARGET_AVX2)
17037     {
17038       rtx neg = gen_reg_rtx (<MODE>mode);
17039       emit_insn (gen_neg<mode>2 (neg, operands[2]));
17040       emit_insn (gen_xop_shl<mode>3 (operands[0], operands[1], neg));
17041       DONE;
17042     }
17045 (define_expand "vlshr<mode>3"
17046   [(set (match_operand:VI48_512 0 "register_operand")
17047         (lshiftrt:VI48_512
17048           (match_operand:VI48_512 1 "register_operand")
17049           (match_operand:VI48_512 2 "nonimmediate_operand")))]
17050   "TARGET_AVX512F")
17052 (define_expand "vlshr<mode>3"
17053   [(set (match_operand:VI48_256 0 "register_operand")
17054         (lshiftrt:VI48_256
17055           (match_operand:VI48_256 1 "register_operand")
17056           (match_operand:VI48_256 2 "nonimmediate_operand")))]
17057   "TARGET_AVX2")
17059 (define_expand "vashrv8hi3<mask_name>"
17060   [(set (match_operand:V8HI 0 "register_operand")
17061         (ashiftrt:V8HI
17062           (match_operand:V8HI 1 "register_operand")
17063           (match_operand:V8HI 2 "nonimmediate_operand")))]
17064   "TARGET_XOP || (TARGET_AVX512BW && TARGET_AVX512VL)"
17066   if (TARGET_XOP)
17067     {
17068       rtx neg = gen_reg_rtx (V8HImode);
17069       emit_insn (gen_negv8hi2 (neg, operands[2]));
17070       emit_insn (gen_xop_shav8hi3 (operands[0], operands[1], neg));
17071       DONE;
17072     }
17075 (define_expand "vashrv16qi3"
17076   [(set (match_operand:V16QI 0 "register_operand")
17077         (ashiftrt:V16QI
17078           (match_operand:V16QI 1 "register_operand")
17079           (match_operand:V16QI 2 "nonimmediate_operand")))]
17080   "TARGET_XOP"
17082    rtx neg = gen_reg_rtx (V16QImode);
17083    emit_insn (gen_negv16qi2 (neg, operands[2]));
17084    emit_insn (gen_xop_shav16qi3 (operands[0], operands[1], neg));
17085    DONE;
17088 (define_expand "vashrv2di3<mask_name>"
17089   [(set (match_operand:V2DI 0 "register_operand")
17090         (ashiftrt:V2DI
17091           (match_operand:V2DI 1 "register_operand")
17092           (match_operand:V2DI 2 "nonimmediate_operand")))]
17093   "TARGET_XOP || TARGET_AVX512VL"
17095   if (TARGET_XOP)
17096     {
17097       rtx neg = gen_reg_rtx (V2DImode);
17098       emit_insn (gen_negv2di2 (neg, operands[2]));
17099       emit_insn (gen_xop_shav2di3 (operands[0], operands[1], neg));
17100       DONE;
17101     }
17104 (define_expand "vashrv4si3"
17105   [(set (match_operand:V4SI 0 "register_operand")
17106         (ashiftrt:V4SI (match_operand:V4SI 1 "register_operand")
17107                        (match_operand:V4SI 2 "nonimmediate_operand")))]
17108   "TARGET_AVX2 || TARGET_XOP"
17110   if (!TARGET_AVX2)
17111     {
17112       rtx neg = gen_reg_rtx (V4SImode);
17113       emit_insn (gen_negv4si2 (neg, operands[2]));
17114       emit_insn (gen_xop_shav4si3 (operands[0], operands[1], neg));
17115       DONE;
17116     }
17119 (define_expand "vashrv16si3"
17120   [(set (match_operand:V16SI 0 "register_operand")
17121         (ashiftrt:V16SI (match_operand:V16SI 1 "register_operand")
17122                         (match_operand:V16SI 2 "nonimmediate_operand")))]
17123   "TARGET_AVX512F")
17125 (define_expand "vashrv8si3"
17126   [(set (match_operand:V8SI 0 "register_operand")
17127         (ashiftrt:V8SI (match_operand:V8SI 1 "register_operand")
17128                        (match_operand:V8SI 2 "nonimmediate_operand")))]
17129   "TARGET_AVX2")
17131 (define_expand "vashl<mode>3"
17132   [(set (match_operand:VI12_128 0 "register_operand")
17133         (ashift:VI12_128
17134           (match_operand:VI12_128 1 "register_operand")
17135           (match_operand:VI12_128 2 "nonimmediate_operand")))]
17136   "TARGET_XOP"
17138   emit_insn (gen_xop_sha<mode>3 (operands[0], operands[1], operands[2]));
17139   DONE;
17142 (define_expand "vashl<mode>3"
17143   [(set (match_operand:VI48_128 0 "register_operand")
17144         (ashift:VI48_128
17145           (match_operand:VI48_128 1 "register_operand")
17146           (match_operand:VI48_128 2 "nonimmediate_operand")))]
17147   "TARGET_AVX2 || TARGET_XOP"
17149   if (!TARGET_AVX2)
17150     {
17151       operands[2] = force_reg (<MODE>mode, operands[2]);
17152       emit_insn (gen_xop_sha<mode>3 (operands[0], operands[1], operands[2]));
17153       DONE;
17154     }
17157 (define_expand "vashl<mode>3"
17158   [(set (match_operand:VI48_512 0 "register_operand")
17159         (ashift:VI48_512
17160           (match_operand:VI48_512 1 "register_operand")
17161           (match_operand:VI48_512 2 "nonimmediate_operand")))]
17162   "TARGET_AVX512F")
17164 (define_expand "vashl<mode>3"
17165   [(set (match_operand:VI48_256 0 "register_operand")
17166         (ashift:VI48_256
17167           (match_operand:VI48_256 1 "register_operand")
17168           (match_operand:VI48_256 2 "nonimmediate_operand")))]
17169   "TARGET_AVX2")
17171 (define_insn "xop_sha<mode>3"
17172   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
17173         (if_then_else:VI_128
17174          (ge:VI_128
17175           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
17176           (const_int 0))
17177          (ashift:VI_128
17178           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
17179           (match_dup 2))
17180          (ashiftrt:VI_128
17181           (match_dup 1)
17182           (neg:VI_128 (match_dup 2)))))]
17183   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17184   "vpsha<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17185   [(set_attr "type" "sseishft")
17186    (set_attr "prefix_data16" "0")
17187    (set_attr "prefix_extra" "2")
17188    (set_attr "mode" "TI")])
17190 (define_insn "xop_shl<mode>3"
17191   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
17192         (if_then_else:VI_128
17193          (ge:VI_128
17194           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
17195           (const_int 0))
17196          (ashift:VI_128
17197           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
17198           (match_dup 2))
17199          (lshiftrt:VI_128
17200           (match_dup 1)
17201           (neg:VI_128 (match_dup 2)))))]
17202   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
17203   "vpshl<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17204   [(set_attr "type" "sseishft")
17205    (set_attr "prefix_data16" "0")
17206    (set_attr "prefix_extra" "2")
17207    (set_attr "mode" "TI")])
17209 (define_expand "<shift_insn><mode>3"
17210   [(set (match_operand:VI1_AVX512 0 "register_operand")
17211         (any_shift:VI1_AVX512
17212           (match_operand:VI1_AVX512 1 "register_operand")
17213           (match_operand:SI 2 "nonmemory_operand")))]
17214   "TARGET_SSE2"
17216   if (TARGET_XOP && <MODE>mode == V16QImode)
17217     {
17218       bool negate = false;
17219       rtx (*gen) (rtx, rtx, rtx);
17220       rtx tmp, par;
17221       int i;
17223       if (<CODE> != ASHIFT)
17224         {
17225           if (CONST_INT_P (operands[2]))
17226             operands[2] = GEN_INT (-INTVAL (operands[2]));
17227           else
17228             negate = true;
17229         }
17230       par = gen_rtx_PARALLEL (V16QImode, rtvec_alloc (16));
17231       for (i = 0; i < 16; i++)
17232         XVECEXP (par, 0, i) = operands[2];
17234       tmp = gen_reg_rtx (V16QImode);
17235       emit_insn (gen_vec_initv16qiqi (tmp, par));
17237       if (negate)
17238         emit_insn (gen_negv16qi2 (tmp, tmp));
17240       gen = (<CODE> == LSHIFTRT ? gen_xop_shlv16qi3 : gen_xop_shav16qi3);
17241       emit_insn (gen (operands[0], operands[1], tmp));
17242     }
17243   else
17244     ix86_expand_vecop_qihi (<CODE>, operands[0], operands[1], operands[2]);
17245   DONE;
17248 (define_expand "ashrv2di3"
17249   [(set (match_operand:V2DI 0 "register_operand")
17250         (ashiftrt:V2DI
17251           (match_operand:V2DI 1 "register_operand")
17252           (match_operand:DI 2 "nonmemory_operand")))]
17253   "TARGET_XOP || TARGET_AVX512VL"
17255   if (!TARGET_AVX512VL)
17256     {
17257       rtx reg = gen_reg_rtx (V2DImode);
17258       rtx par;
17259       bool negate = false;
17260       int i;
17262       if (CONST_INT_P (operands[2]))
17263         operands[2] = GEN_INT (-INTVAL (operands[2]));
17264       else
17265         negate = true;
17267       par = gen_rtx_PARALLEL (V2DImode, rtvec_alloc (2));
17268       for (i = 0; i < 2; i++)
17269         XVECEXP (par, 0, i) = operands[2];
17271       emit_insn (gen_vec_initv2didi (reg, par));
17273       if (negate)
17274         emit_insn (gen_negv2di2 (reg, reg));
17276       emit_insn (gen_xop_shav2di3 (operands[0], operands[1], reg));
17277       DONE;
17278     }
17281 ;; XOP FRCZ support
17282 (define_insn "xop_frcz<mode>2"
17283   [(set (match_operand:FMAMODE 0 "register_operand" "=x")
17284         (unspec:FMAMODE
17285          [(match_operand:FMAMODE 1 "nonimmediate_operand" "xm")]
17286          UNSPEC_FRCZ))]
17287   "TARGET_XOP"
17288   "vfrcz<ssemodesuffix>\t{%1, %0|%0, %1}"
17289   [(set_attr "type" "ssecvt1")
17290    (set_attr "mode" "<MODE>")])
17292 (define_expand "xop_vmfrcz<mode>2"
17293   [(set (match_operand:VF_128 0 "register_operand")
17294         (vec_merge:VF_128
17295           (unspec:VF_128
17296            [(match_operand:VF_128 1 "nonimmediate_operand")]
17297            UNSPEC_FRCZ)
17298           (match_dup 2)
17299           (const_int 1)))]
17300   "TARGET_XOP"
17301   "operands[2] = CONST0_RTX (<MODE>mode);")
17303 (define_insn "*xop_vmfrcz<mode>2"
17304   [(set (match_operand:VF_128 0 "register_operand" "=x")
17305         (vec_merge:VF_128
17306           (unspec:VF_128
17307            [(match_operand:VF_128 1 "nonimmediate_operand" "xm")]
17308            UNSPEC_FRCZ)
17309           (match_operand:VF_128 2 "const0_operand")
17310           (const_int 1)))]
17311   "TARGET_XOP"
17312   "vfrcz<ssescalarmodesuffix>\t{%1, %0|%0, %<iptr>1}"
17313   [(set_attr "type" "ssecvt1")
17314    (set_attr "mode" "<MODE>")])
17316 (define_insn "xop_maskcmp<mode>3"
17317   [(set (match_operand:VI_128 0 "register_operand" "=x")
17318         (match_operator:VI_128 1 "ix86_comparison_int_operator"
17319          [(match_operand:VI_128 2 "register_operand" "x")
17320           (match_operand:VI_128 3 "nonimmediate_operand" "xm")]))]
17321   "TARGET_XOP"
17322   "vpcom%Y1<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
17323   [(set_attr "type" "sse4arg")
17324    (set_attr "prefix_data16" "0")
17325    (set_attr "prefix_rep" "0")
17326    (set_attr "prefix_extra" "2")
17327    (set_attr "length_immediate" "1")
17328    (set_attr "mode" "TI")])
17330 (define_insn "xop_maskcmp_uns<mode>3"
17331   [(set (match_operand:VI_128 0 "register_operand" "=x")
17332         (match_operator:VI_128 1 "ix86_comparison_uns_operator"
17333          [(match_operand:VI_128 2 "register_operand" "x")
17334           (match_operand:VI_128 3 "nonimmediate_operand" "xm")]))]
17335   "TARGET_XOP"
17336   "vpcom%Y1u<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
17337   [(set_attr "type" "ssecmp")
17338    (set_attr "prefix_data16" "0")
17339    (set_attr "prefix_rep" "0")
17340    (set_attr "prefix_extra" "2")
17341    (set_attr "length_immediate" "1")
17342    (set_attr "mode" "TI")])
17344 ;; Version of pcom*u* that is called from the intrinsics that allows pcomequ*
17345 ;; and pcomneu* not to be converted to the signed ones in case somebody needs
17346 ;; the exact instruction generated for the intrinsic.
17347 (define_insn "xop_maskcmp_uns2<mode>3"
17348   [(set (match_operand:VI_128 0 "register_operand" "=x")
17349         (unspec:VI_128
17350          [(match_operator:VI_128 1 "ix86_comparison_uns_operator"
17351           [(match_operand:VI_128 2 "register_operand" "x")
17352            (match_operand:VI_128 3 "nonimmediate_operand" "xm")])]
17353          UNSPEC_XOP_UNSIGNED_CMP))]
17354   "TARGET_XOP"
17355   "vpcom%Y1u<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
17356   [(set_attr "type" "ssecmp")
17357    (set_attr "prefix_data16" "0")
17358    (set_attr "prefix_extra" "2")
17359    (set_attr "length_immediate" "1")
17360    (set_attr "mode" "TI")])
17362 ;; Pcomtrue and pcomfalse support.  These are useless instructions, but are
17363 ;; being added here to be complete.
17364 (define_insn "xop_pcom_tf<mode>3"
17365   [(set (match_operand:VI_128 0 "register_operand" "=x")
17366         (unspec:VI_128
17367           [(match_operand:VI_128 1 "register_operand" "x")
17368            (match_operand:VI_128 2 "nonimmediate_operand" "xm")
17369            (match_operand:SI 3 "const_int_operand" "n")]
17370           UNSPEC_XOP_TRUEFALSE))]
17371   "TARGET_XOP"
17373   return ((INTVAL (operands[3]) != 0)
17374           ? "vpcomtrue<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
17375           : "vpcomfalse<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}");
17377   [(set_attr "type" "ssecmp")
17378    (set_attr "prefix_data16" "0")
17379    (set_attr "prefix_extra" "2")
17380    (set_attr "length_immediate" "1")
17381    (set_attr "mode" "TI")])
17383 (define_insn "xop_vpermil2<mode>3"
17384   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
17385         (unspec:VF_128_256
17386           [(match_operand:VF_128_256 1 "register_operand" "x,x")
17387            (match_operand:VF_128_256 2 "nonimmediate_operand" "x,m")
17388            (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "xm,x")
17389            (match_operand:SI 4 "const_0_to_3_operand" "n,n")]
17390           UNSPEC_VPERMIL2))]
17391   "TARGET_XOP"
17392   "vpermil2<ssemodesuffix>\t{%4, %3, %2, %1, %0|%0, %1, %2, %3, %4}"
17393   [(set_attr "type" "sse4arg")
17394    (set_attr "length_immediate" "1")
17395    (set_attr "mode" "<MODE>")])
17397 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17399 (define_insn "aesenc"
17400   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17401         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17402                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
17403                       UNSPEC_AESENC))]
17404   "TARGET_AES"
17405   "@
17406    aesenc\t{%2, %0|%0, %2}
17407    vaesenc\t{%2, %1, %0|%0, %1, %2}"
17408   [(set_attr "isa" "noavx,avx")
17409    (set_attr "type" "sselog1")
17410    (set_attr "prefix_extra" "1")
17411    (set_attr "prefix" "orig,vex")
17412    (set_attr "btver2_decode" "double,double")
17413    (set_attr "mode" "TI")])
17415 (define_insn "aesenclast"
17416   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17417         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17418                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
17419                       UNSPEC_AESENCLAST))]
17420   "TARGET_AES"
17421   "@
17422    aesenclast\t{%2, %0|%0, %2}
17423    vaesenclast\t{%2, %1, %0|%0, %1, %2}"
17424   [(set_attr "isa" "noavx,avx")
17425    (set_attr "type" "sselog1")
17426    (set_attr "prefix_extra" "1")
17427    (set_attr "prefix" "orig,vex")
17428    (set_attr "btver2_decode" "double,double") 
17429    (set_attr "mode" "TI")])
17431 (define_insn "aesdec"
17432   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17433         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17434                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
17435                       UNSPEC_AESDEC))]
17436   "TARGET_AES"
17437   "@
17438    aesdec\t{%2, %0|%0, %2}
17439    vaesdec\t{%2, %1, %0|%0, %1, %2}"
17440   [(set_attr "isa" "noavx,avx")
17441    (set_attr "type" "sselog1")
17442    (set_attr "prefix_extra" "1")
17443    (set_attr "prefix" "orig,vex")
17444    (set_attr "btver2_decode" "double,double") 
17445    (set_attr "mode" "TI")])
17447 (define_insn "aesdeclast"
17448   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17449         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17450                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
17451                       UNSPEC_AESDECLAST))]
17452   "TARGET_AES"
17453   "@
17454    aesdeclast\t{%2, %0|%0, %2}
17455    vaesdeclast\t{%2, %1, %0|%0, %1, %2}"
17456   [(set_attr "isa" "noavx,avx")
17457    (set_attr "type" "sselog1")
17458    (set_attr "prefix_extra" "1")
17459    (set_attr "prefix" "orig,vex")
17460    (set_attr "btver2_decode" "double,double")
17461    (set_attr "mode" "TI")])
17463 (define_insn "aesimc"
17464   [(set (match_operand:V2DI 0 "register_operand" "=x")
17465         (unspec:V2DI [(match_operand:V2DI 1 "vector_operand" "xBm")]
17466                       UNSPEC_AESIMC))]
17467   "TARGET_AES"
17468   "%vaesimc\t{%1, %0|%0, %1}"
17469   [(set_attr "type" "sselog1")
17470    (set_attr "prefix_extra" "1")
17471    (set_attr "prefix" "maybe_vex")
17472    (set_attr "mode" "TI")])
17474 (define_insn "aeskeygenassist"
17475   [(set (match_operand:V2DI 0 "register_operand" "=x")
17476         (unspec:V2DI [(match_operand:V2DI 1 "vector_operand" "xBm")
17477                       (match_operand:SI 2 "const_0_to_255_operand" "n")]
17478                      UNSPEC_AESKEYGENASSIST))]
17479   "TARGET_AES"
17480   "%vaeskeygenassist\t{%2, %1, %0|%0, %1, %2}"
17481   [(set_attr "type" "sselog1")
17482    (set_attr "prefix_extra" "1")
17483    (set_attr "length_immediate" "1")
17484    (set_attr "prefix" "maybe_vex")
17485    (set_attr "mode" "TI")])
17487 (define_insn "pclmulqdq"
17488   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17489         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17490                       (match_operand:V2DI 2 "vector_operand" "xBm,xm")
17491                       (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
17492                      UNSPEC_PCLMUL))]
17493   "TARGET_PCLMUL"
17494   "@
17495    pclmulqdq\t{%3, %2, %0|%0, %2, %3}
17496    vpclmulqdq\t{%3, %2, %1, %0|%0, %1, %2, %3}"
17497   [(set_attr "isa" "noavx,avx")
17498    (set_attr "type" "sselog1")
17499    (set_attr "prefix_extra" "1")
17500    (set_attr "length_immediate" "1")
17501    (set_attr "prefix" "orig,vex")
17502    (set_attr "mode" "TI")])
17504 (define_expand "avx_vzeroall"
17505   [(match_par_dup 0 [(const_int 0)])]
17506   "TARGET_AVX"
17508   int nregs = TARGET_64BIT ? 16 : 8;
17509   int regno;
17511   operands[0] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs + 1));
17513   XVECEXP (operands[0], 0, 0)
17514     = gen_rtx_UNSPEC_VOLATILE (VOIDmode, gen_rtvec (1, const0_rtx),
17515                                UNSPECV_VZEROALL);
17517   for (regno = 0; regno < nregs; regno++)
17518     XVECEXP (operands[0], 0, regno + 1)
17519       = gen_rtx_SET (gen_rtx_REG (V8SImode, SSE_REGNO (regno)),
17520                      CONST0_RTX (V8SImode));
17523 (define_insn "*avx_vzeroall"
17524   [(match_parallel 0 "vzeroall_operation"
17525     [(unspec_volatile [(const_int 0)] UNSPECV_VZEROALL)])]
17526   "TARGET_AVX"
17527   "vzeroall"
17528   [(set_attr "type" "sse")
17529    (set_attr "modrm" "0")
17530    (set_attr "memory" "none")
17531    (set_attr "prefix" "vex")
17532    (set_attr "btver2_decode" "vector")
17533    (set_attr "mode" "OI")])
17535 ;; Clear the upper 128bits of AVX registers, equivalent to a NOP
17536 ;; if the upper 128bits are unused.
17537 (define_insn "avx_vzeroupper"
17538   [(unspec_volatile [(const_int 0)] UNSPECV_VZEROUPPER)]
17539   "TARGET_AVX"
17540   "vzeroupper"
17541   [(set_attr "type" "sse")
17542    (set_attr "modrm" "0")
17543    (set_attr "memory" "none")
17544    (set_attr "prefix" "vex")
17545    (set_attr "btver2_decode" "vector")
17546    (set_attr "mode" "OI")])
17548 (define_mode_attr pbroadcast_evex_isa
17549   [(V64QI "avx512bw") (V32QI "avx512bw") (V16QI "avx512bw")
17550    (V32HI "avx512bw") (V16HI "avx512bw") (V8HI "avx512bw")
17551    (V16SI "avx512f") (V8SI "avx512f") (V4SI "avx512f")
17552    (V8DI "avx512f") (V4DI "avx512f") (V2DI "avx512f")])
17554 (define_insn "avx2_pbroadcast<mode>"
17555   [(set (match_operand:VI 0 "register_operand" "=x,v")
17556         (vec_duplicate:VI
17557           (vec_select:<ssescalarmode>
17558             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "xm,vm")
17559             (parallel [(const_int 0)]))))]
17560   "TARGET_AVX2"
17561   "vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}"
17562   [(set_attr "isa" "*,<pbroadcast_evex_isa>")
17563    (set_attr "type" "ssemov")
17564    (set_attr "prefix_extra" "1")
17565    (set_attr "prefix" "vex,evex")
17566    (set_attr "mode" "<sseinsnmode>")])
17568 (define_insn "avx2_pbroadcast<mode>_1"
17569   [(set (match_operand:VI_256 0 "register_operand" "=x,x,v,v")
17570         (vec_duplicate:VI_256
17571           (vec_select:<ssescalarmode>
17572             (match_operand:VI_256 1 "nonimmediate_operand" "m,x,m,v")
17573             (parallel [(const_int 0)]))))]
17574   "TARGET_AVX2"
17575   "@
17576    vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}
17577    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}
17578    vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}
17579    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}"
17580   [(set_attr "isa" "*,*,<pbroadcast_evex_isa>,<pbroadcast_evex_isa>")
17581    (set_attr "type" "ssemov")
17582    (set_attr "prefix_extra" "1")
17583    (set_attr "prefix" "vex")
17584    (set_attr "mode" "<sseinsnmode>")])
17586 (define_insn "<avx2_avx512>_permvar<mode><mask_name>"
17587   [(set (match_operand:VI48F_256_512 0 "register_operand" "=v")
17588         (unspec:VI48F_256_512
17589           [(match_operand:VI48F_256_512 1 "nonimmediate_operand" "vm")
17590            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
17591           UNSPEC_VPERMVAR))]
17592   "TARGET_AVX2 && <mask_mode512bit_condition>"
17593   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
17594   [(set_attr "type" "sselog")
17595    (set_attr "prefix" "<mask_prefix2>")
17596    (set_attr "mode" "<sseinsnmode>")])
17598 (define_insn "<avx512>_permvar<mode><mask_name>"
17599   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
17600         (unspec:VI1_AVX512VL
17601           [(match_operand:VI1_AVX512VL 1 "nonimmediate_operand" "vm")
17602            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
17603           UNSPEC_VPERMVAR))]
17604   "TARGET_AVX512VBMI && <mask_mode512bit_condition>"
17605   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
17606   [(set_attr "type" "sselog")
17607    (set_attr "prefix" "<mask_prefix2>")
17608    (set_attr "mode" "<sseinsnmode>")])
17610 (define_insn "<avx512>_permvar<mode><mask_name>"
17611   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17612         (unspec:VI2_AVX512VL
17613           [(match_operand:VI2_AVX512VL 1 "nonimmediate_operand" "vm")
17614            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
17615           UNSPEC_VPERMVAR))]
17616   "TARGET_AVX512BW && <mask_mode512bit_condition>"
17617   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
17618   [(set_attr "type" "sselog")
17619    (set_attr "prefix" "<mask_prefix2>")
17620    (set_attr "mode" "<sseinsnmode>")])
17622 (define_expand "avx2_perm<mode>"
17623   [(match_operand:VI8F_256 0 "register_operand")
17624    (match_operand:VI8F_256 1 "nonimmediate_operand")
17625    (match_operand:SI 2 "const_0_to_255_operand")]
17626   "TARGET_AVX2"
17628   int mask = INTVAL (operands[2]);
17629   emit_insn (gen_avx2_perm<mode>_1 (operands[0], operands[1],
17630                                     GEN_INT ((mask >> 0) & 3),
17631                                     GEN_INT ((mask >> 2) & 3),
17632                                     GEN_INT ((mask >> 4) & 3),
17633                                     GEN_INT ((mask >> 6) & 3)));
17634   DONE;
17637 (define_expand "avx512vl_perm<mode>_mask"
17638   [(match_operand:VI8F_256 0 "register_operand")
17639    (match_operand:VI8F_256 1 "nonimmediate_operand")
17640    (match_operand:SI 2 "const_0_to_255_operand")
17641    (match_operand:VI8F_256 3 "vector_move_operand")
17642    (match_operand:<avx512fmaskmode> 4 "register_operand")]
17643   "TARGET_AVX512VL"
17645   int mask = INTVAL (operands[2]);
17646   emit_insn (gen_<avx2_avx512>_perm<mode>_1_mask (operands[0], operands[1],
17647                                                   GEN_INT ((mask >> 0) & 3),
17648                                                   GEN_INT ((mask >> 2) & 3),
17649                                                   GEN_INT ((mask >> 4) & 3),
17650                                                   GEN_INT ((mask >> 6) & 3),
17651                                                   operands[3], operands[4]));
17652   DONE;
17655 (define_insn "avx2_perm<mode>_1<mask_name>"
17656   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
17657         (vec_select:VI8F_256
17658           (match_operand:VI8F_256 1 "nonimmediate_operand" "vm")
17659           (parallel [(match_operand 2 "const_0_to_3_operand")
17660                      (match_operand 3 "const_0_to_3_operand")
17661                      (match_operand 4 "const_0_to_3_operand")
17662                      (match_operand 5 "const_0_to_3_operand")])))]
17663   "TARGET_AVX2 && <mask_mode512bit_condition>"
17665   int mask = 0;
17666   mask |= INTVAL (operands[2]) << 0;
17667   mask |= INTVAL (operands[3]) << 2;
17668   mask |= INTVAL (operands[4]) << 4;
17669   mask |= INTVAL (operands[5]) << 6;
17670   operands[2] = GEN_INT (mask);
17671   return "vperm<ssemodesuffix>\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
17673   [(set_attr "type" "sselog")
17674    (set_attr "prefix" "<mask_prefix2>")
17675    (set_attr "mode" "<sseinsnmode>")])
17677 (define_expand "avx512f_perm<mode>"
17678   [(match_operand:V8FI 0 "register_operand")
17679    (match_operand:V8FI 1 "nonimmediate_operand")
17680    (match_operand:SI 2 "const_0_to_255_operand")]
17681   "TARGET_AVX512F"
17683   int mask = INTVAL (operands[2]);
17684   emit_insn (gen_avx512f_perm<mode>_1 (operands[0], operands[1],
17685                                        GEN_INT ((mask >> 0) & 3),
17686                                        GEN_INT ((mask >> 2) & 3),
17687                                        GEN_INT ((mask >> 4) & 3),
17688                                        GEN_INT ((mask >> 6) & 3),
17689                                        GEN_INT (((mask >> 0) & 3) + 4),
17690                                        GEN_INT (((mask >> 2) & 3) + 4),
17691                                        GEN_INT (((mask >> 4) & 3) + 4),
17692                                        GEN_INT (((mask >> 6) & 3) + 4)));
17693   DONE;
17696 (define_expand "avx512f_perm<mode>_mask"
17697   [(match_operand:V8FI 0 "register_operand")
17698    (match_operand:V8FI 1 "nonimmediate_operand")
17699    (match_operand:SI 2 "const_0_to_255_operand")
17700    (match_operand:V8FI 3 "vector_move_operand")
17701    (match_operand:<avx512fmaskmode> 4 "register_operand")]
17702   "TARGET_AVX512F"
17704   int mask = INTVAL (operands[2]);
17705   emit_insn (gen_avx512f_perm<mode>_1_mask (operands[0], operands[1],
17706                                             GEN_INT ((mask >> 0) & 3),
17707                                             GEN_INT ((mask >> 2) & 3),
17708                                             GEN_INT ((mask >> 4) & 3),
17709                                             GEN_INT ((mask >> 6) & 3),
17710                                             GEN_INT (((mask >> 0) & 3) + 4),
17711                                             GEN_INT (((mask >> 2) & 3) + 4),
17712                                             GEN_INT (((mask >> 4) & 3) + 4),
17713                                             GEN_INT (((mask >> 6) & 3) + 4),
17714                                             operands[3], operands[4]));
17715   DONE;
17718 (define_insn "avx512f_perm<mode>_1<mask_name>"
17719   [(set (match_operand:V8FI 0 "register_operand" "=v")
17720         (vec_select:V8FI
17721           (match_operand:V8FI 1 "nonimmediate_operand" "vm")
17722           (parallel [(match_operand 2 "const_0_to_3_operand")
17723                      (match_operand 3 "const_0_to_3_operand")
17724                      (match_operand 4 "const_0_to_3_operand")
17725                      (match_operand 5 "const_0_to_3_operand")
17726                      (match_operand 6 "const_4_to_7_operand")
17727                      (match_operand 7 "const_4_to_7_operand")
17728                      (match_operand 8 "const_4_to_7_operand")
17729                      (match_operand 9 "const_4_to_7_operand")])))]
17730   "TARGET_AVX512F && <mask_mode512bit_condition>
17731    && (INTVAL (operands[2]) == (INTVAL (operands[6]) - 4)
17732        && INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
17733        && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
17734        && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4))"
17736   int mask = 0;
17737   mask |= INTVAL (operands[2]) << 0;
17738   mask |= INTVAL (operands[3]) << 2;
17739   mask |= INTVAL (operands[4]) << 4;
17740   mask |= INTVAL (operands[5]) << 6;
17741   operands[2] = GEN_INT (mask);
17742   return "vperm<ssemodesuffix>\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
17744   [(set_attr "type" "sselog")
17745    (set_attr "prefix" "<mask_prefix2>")
17746    (set_attr "mode" "<sseinsnmode>")])
17748 (define_insn "avx2_permv2ti"
17749   [(set (match_operand:V4DI 0 "register_operand" "=x")
17750         (unspec:V4DI
17751           [(match_operand:V4DI 1 "register_operand" "x")
17752            (match_operand:V4DI 2 "nonimmediate_operand" "xm")
17753            (match_operand:SI 3 "const_0_to_255_operand" "n")]
17754           UNSPEC_VPERMTI))]
17755   "TARGET_AVX2"
17756   "vperm2i128\t{%3, %2, %1, %0|%0, %1, %2, %3}"
17757   [(set_attr "type" "sselog")
17758    (set_attr "prefix" "vex")
17759    (set_attr "mode" "OI")])
17761 (define_insn "avx2_vec_dupv4df"
17762   [(set (match_operand:V4DF 0 "register_operand" "=v")
17763         (vec_duplicate:V4DF
17764           (vec_select:DF
17765             (match_operand:V2DF 1 "register_operand" "v")
17766             (parallel [(const_int 0)]))))]
17767   "TARGET_AVX2"
17768   "vbroadcastsd\t{%1, %0|%0, %1}"
17769   [(set_attr "type" "sselog1")
17770    (set_attr "prefix" "maybe_evex")
17771    (set_attr "mode" "V4DF")])
17773 (define_insn "<avx512>_vec_dup<mode>_1"
17774   [(set (match_operand:VI_AVX512BW 0 "register_operand" "=v,v")
17775         (vec_duplicate:VI_AVX512BW
17776           (vec_select:<ssescalarmode>
17777             (match_operand:VI_AVX512BW 1 "nonimmediate_operand" "v,m")
17778             (parallel [(const_int 0)]))))]
17779   "TARGET_AVX512F"
17780   "@
17781    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}
17782    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %<iptr>1}"
17783   [(set_attr "type" "ssemov")
17784    (set_attr "prefix" "evex")
17785    (set_attr "mode" "<sseinsnmode>")])
17787 (define_insn "<avx512>_vec_dup<mode><mask_name>"
17788   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v")
17789         (vec_duplicate:V48_AVX512VL
17790           (vec_select:<ssescalarmode>
17791             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
17792             (parallel [(const_int 0)]))))]
17793   "TARGET_AVX512F"
17795   /*  There is no DF broadcast (in AVX-512*) to 128b register.
17796       Mimic it with integer variant.  */
17797   if (<MODE>mode == V2DFmode)
17798     return "vpbroadcastq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}";
17800   return "v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %<iptr>1}";
17802   [(set_attr "type" "ssemov")
17803    (set_attr "prefix" "evex")
17804    (set_attr "mode" "<sseinsnmode>")])
17806 (define_insn "<avx512>_vec_dup<mode><mask_name>"
17807   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
17808         (vec_duplicate:VI12_AVX512VL
17809           (vec_select:<ssescalarmode>
17810             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
17811             (parallel [(const_int 0)]))))]
17812   "TARGET_AVX512BW"
17813   "vpbroadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %<iptr>1}"
17814   [(set_attr "type" "ssemov")
17815    (set_attr "prefix" "evex")
17816    (set_attr "mode" "<sseinsnmode>")])
17818 (define_insn "<mask_codefor>avx512f_broadcast<mode><mask_name>"
17819   [(set (match_operand:V16FI 0 "register_operand" "=v,v")
17820         (vec_duplicate:V16FI
17821           (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "v,m")))]
17822   "TARGET_AVX512F"
17823   "@
17824    vshuf<shuffletype>32x4\t{$0x0, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x0}
17825    vbroadcast<shuffletype>32x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17826   [(set_attr "type" "ssemov")
17827    (set_attr "prefix" "evex")
17828    (set_attr "mode" "<sseinsnmode>")])
17830 (define_insn "<mask_codefor>avx512f_broadcast<mode><mask_name>"
17831   [(set (match_operand:V8FI 0 "register_operand" "=v,v")
17832         (vec_duplicate:V8FI
17833           (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "v,m")))]
17834   "TARGET_AVX512F"
17835   "@
17836    vshuf<shuffletype>64x2\t{$0x44, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x44}
17837    vbroadcast<shuffletype>64x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17838   [(set_attr "type" "ssemov")
17839    (set_attr "prefix" "evex")
17840    (set_attr "mode" "<sseinsnmode>")])
17842 (define_insn "<mask_codefor><avx512>_vec_dup_gpr<mode><mask_name>"
17843   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v,v")
17844         (vec_duplicate:VI12_AVX512VL
17845           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "vm,r")))]
17846   "TARGET_AVX512BW"
17847   "@
17848    vpbroadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}
17849    vpbroadcast<bcstscalarsuff>\t{%k1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
17850   [(set_attr "type" "ssemov")
17851    (set_attr "prefix" "evex")
17852    (set_attr "mode" "<sseinsnmode>")])
17854 (define_insn "<mask_codefor><avx512>_vec_dup_gpr<mode><mask_name>"
17855   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v,v")
17856         (vec_duplicate:V48_AVX512VL
17857           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "vm,r")))]
17858   "TARGET_AVX512F"
17859   "v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17860   [(set_attr "type" "ssemov")
17861    (set_attr "prefix" "evex")
17862    (set_attr "mode" "<sseinsnmode>")
17863    (set (attr "enabled")
17864      (if_then_else (eq_attr "alternative" "1")
17865         (symbol_ref "GET_MODE_CLASS (<ssescalarmode>mode) == MODE_INT
17866                      && (<ssescalarmode>mode != DImode || TARGET_64BIT)")
17867         (const_int 1)))])
17869 (define_insn "vec_dupv4sf"
17870   [(set (match_operand:V4SF 0 "register_operand" "=v,v,x")
17871         (vec_duplicate:V4SF
17872           (match_operand:SF 1 "nonimmediate_operand" "Yv,m,0")))]
17873   "TARGET_SSE"
17874   "@
17875    vshufps\t{$0, %1, %1, %0|%0, %1, %1, 0}
17876    vbroadcastss\t{%1, %0|%0, %1}
17877    shufps\t{$0, %0, %0|%0, %0, 0}"
17878   [(set_attr "isa" "avx,avx,noavx")
17879    (set_attr "type" "sseshuf1,ssemov,sseshuf1")
17880    (set_attr "length_immediate" "1,0,1")
17881    (set_attr "prefix_extra" "0,1,*")
17882    (set_attr "prefix" "maybe_evex,maybe_evex,orig")
17883    (set_attr "mode" "V4SF")])
17885 (define_insn "*vec_dupv4si"
17886   [(set (match_operand:V4SI 0 "register_operand"     "=v,v,x")
17887         (vec_duplicate:V4SI
17888           (match_operand:SI 1 "nonimmediate_operand" "Yv,m,0")))]
17889   "TARGET_SSE"
17890   "@
17891    %vpshufd\t{$0, %1, %0|%0, %1, 0}
17892    vbroadcastss\t{%1, %0|%0, %1}
17893    shufps\t{$0, %0, %0|%0, %0, 0}"
17894   [(set_attr "isa" "sse2,avx,noavx")
17895    (set_attr "type" "sselog1,ssemov,sselog1")
17896    (set_attr "length_immediate" "1,0,1")
17897    (set_attr "prefix_extra" "0,1,*")
17898    (set_attr "prefix" "maybe_vex,maybe_evex,orig")
17899    (set_attr "mode" "TI,V4SF,V4SF")])
17901 (define_insn "*vec_dupv2di"
17902   [(set (match_operand:V2DI 0 "register_operand"     "=x,v,v,x")
17903         (vec_duplicate:V2DI
17904           (match_operand:DI 1 "nonimmediate_operand" " 0,Yv,m,0")))]
17905   "TARGET_SSE"
17906   "@
17907    punpcklqdq\t%0, %0
17908    vpunpcklqdq\t{%d1, %0|%0, %d1}
17909    %vmovddup\t{%1, %0|%0, %1}
17910    movlhps\t%0, %0"
17911   [(set_attr "isa" "sse2_noavx,avx,sse3,noavx")
17912    (set_attr "type" "sselog1,sselog1,sselog1,ssemov")
17913    (set_attr "prefix" "orig,maybe_evex,maybe_vex,orig")
17914    (set_attr "mode" "TI,TI,DF,V4SF")])
17916 (define_insn "avx2_vbroadcasti128_<mode>"
17917   [(set (match_operand:VI_256 0 "register_operand" "=x,v,v")
17918         (vec_concat:VI_256
17919           (match_operand:<ssehalfvecmode> 1 "memory_operand" "m,m,m")
17920           (match_dup 1)))]
17921   "TARGET_AVX2"
17922   "@
17923    vbroadcasti128\t{%1, %0|%0, %1}
17924    vbroadcast<i128vldq>\t{%1, %0|%0, %1}
17925    vbroadcast<shuffletype>32x4\t{%1, %0|%0, %1}"
17926   [(set_attr "isa" "*,avx512dq,avx512vl")
17927    (set_attr "type" "ssemov")
17928    (set_attr "prefix_extra" "1")
17929    (set_attr "prefix" "vex,evex,evex")
17930    (set_attr "mode" "OI")])
17932 ;; Modes handled by AVX vec_dup patterns.
17933 (define_mode_iterator AVX_VEC_DUP_MODE
17934   [V8SI V8SF V4DI V4DF])
17935 (define_mode_attr vecdupssescalarmodesuffix
17936   [(V8SF "ss") (V4DF "sd") (V8SI "ss") (V4DI "sd")])
17937 ;; Modes handled by AVX2 vec_dup patterns.
17938 (define_mode_iterator AVX2_VEC_DUP_MODE
17939   [V32QI V16QI V16HI V8HI V8SI V4SI])
17941 (define_insn "*vec_dup<mode>"
17942   [(set (match_operand:AVX2_VEC_DUP_MODE 0 "register_operand" "=x,x,v")
17943         (vec_duplicate:AVX2_VEC_DUP_MODE
17944           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,x,$r")))]
17945   "TARGET_AVX2"
17946   "@
17947    v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0|%0, %1}
17948    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}
17949    #"
17950   [(set_attr "isa" "*,*,noavx512vl")
17951    (set_attr "type" "ssemov")
17952    (set_attr "prefix_extra" "1")
17953    (set_attr "prefix" "maybe_evex")
17954    (set_attr "mode" "<sseinsnmode>")
17955    (set (attr "preferred_for_speed")
17956      (cond [(eq_attr "alternative" "2")
17957               (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
17958            ]
17959            (symbol_ref "true")))])
17961 (define_insn "vec_dup<mode>"
17962   [(set (match_operand:AVX_VEC_DUP_MODE 0 "register_operand" "=x,x,x,v,x")
17963         (vec_duplicate:AVX_VEC_DUP_MODE
17964           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,m,x,v,?x")))]
17965   "TARGET_AVX"
17966   "@
17967    v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0|%0, %1}
17968    vbroadcast<vecdupssescalarmodesuffix>\t{%1, %0|%0, %1}
17969    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}
17970    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %g0|%g0, %x1}
17971    #"
17972   [(set_attr "type" "ssemov")
17973    (set_attr "prefix_extra" "1")
17974    (set_attr "prefix" "maybe_evex")
17975    (set_attr "isa" "avx2,noavx2,avx2,avx512f,noavx2")
17976    (set_attr "mode" "<sseinsnmode>,V8SF,<sseinsnmode>,<sseinsnmode>,V8SF")])
17978 (define_split
17979   [(set (match_operand:AVX2_VEC_DUP_MODE 0 "register_operand")
17980         (vec_duplicate:AVX2_VEC_DUP_MODE
17981           (match_operand:<ssescalarmode> 1 "register_operand")))]
17982   "TARGET_AVX2
17983    /* Disable this splitter if avx512vl_vec_dup_gprv*[qhs]i insn is
17984       available, because then we can broadcast from GPRs directly.
17985       For V*[QH]I modes it requires both -mavx512vl and -mavx512bw,
17986       for V*SI mode it requires just -mavx512vl.  */
17987    && !(TARGET_AVX512VL
17988         && (TARGET_AVX512BW || <ssescalarmode>mode == SImode))
17989    && reload_completed && GENERAL_REG_P (operands[1])"
17990   [(const_int 0)]
17992   emit_insn (gen_vec_setv4si_0 (gen_lowpart (V4SImode, operands[0]),
17993                                 CONST0_RTX (V4SImode),
17994                                 gen_lowpart (SImode, operands[1])));
17995   emit_insn (gen_avx2_pbroadcast<mode> (operands[0],
17996                                         gen_lowpart (<ssexmmmode>mode,
17997                                                      operands[0])));
17998   DONE;
18001 (define_split
18002   [(set (match_operand:AVX_VEC_DUP_MODE 0 "register_operand")
18003         (vec_duplicate:AVX_VEC_DUP_MODE
18004           (match_operand:<ssescalarmode> 1 "register_operand")))]
18005   "TARGET_AVX && !TARGET_AVX2 && reload_completed"
18006   [(set (match_dup 2)
18007         (vec_duplicate:<ssehalfvecmode> (match_dup 1)))
18008    (set (match_dup 0)
18009         (vec_concat:AVX_VEC_DUP_MODE (match_dup 2) (match_dup 2)))]
18010   "operands[2] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);")
18012 (define_insn "avx_vbroadcastf128_<mode>"
18013   [(set (match_operand:V_256 0 "register_operand" "=x,x,x,v,v,v,v")
18014         (vec_concat:V_256
18015           (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "m,0,?x,m,0,m,0")
18016           (match_dup 1)))]
18017   "TARGET_AVX"
18018   "@
18019    vbroadcast<i128>\t{%1, %0|%0, %1}
18020    vinsert<i128>\t{$1, %1, %0, %0|%0, %0, %1, 1}
18021    vperm2<i128>\t{$0, %t1, %t1, %0|%0, %t1, %t1, 0}
18022    vbroadcast<i128vldq>\t{%1, %0|%0, %1}
18023    vinsert<i128vldq>\t{$1, %1, %0, %0|%0, %0, %1, 1}
18024    vbroadcast<shuffletype>32x4\t{%1, %0|%0, %1}
18025    vinsert<shuffletype>32x4\t{$1, %1, %0, %0|%0, %0, %1, 1}"
18026   [(set_attr "isa" "*,*,*,avx512dq,avx512dq,avx512vl,avx512vl")
18027    (set_attr "type" "ssemov,sselog1,sselog1,ssemov,sselog1,ssemov,sselog1")
18028    (set_attr "prefix_extra" "1")
18029    (set_attr "length_immediate" "0,1,1,0,1,0,1")
18030    (set_attr "prefix" "vex,vex,vex,evex,evex,evex,evex")
18031    (set_attr "mode" "<sseinsnmode>")])
18033 ;; For broadcast[i|f]32x2.  Yes there is no v4sf version, only v4si.
18034 (define_mode_iterator VI4F_BRCST32x2
18035   [V16SI (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
18036    V16SF (V8SF "TARGET_AVX512VL")])
18038 (define_mode_attr 64x2mode
18039   [(V8DF "V2DF") (V8DI "V2DI") (V4DI "V2DI") (V4DF "V2DF")])
18041 (define_mode_attr 32x2mode
18042   [(V16SF "V2SF") (V16SI "V2SI") (V8SI "V2SI")
18043   (V8SF "V2SF") (V4SI "V2SI")])
18045 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>"
18046   [(set (match_operand:VI4F_BRCST32x2 0 "register_operand" "=v")
18047         (vec_duplicate:VI4F_BRCST32x2
18048           (vec_select:<32x2mode>
18049             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
18050             (parallel [(const_int 0) (const_int 1)]))))]
18051   "TARGET_AVX512DQ"
18052   "vbroadcast<shuffletype>32x2\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
18053   [(set_attr "type" "ssemov")
18054    (set_attr "prefix_extra" "1")
18055    (set_attr "prefix" "evex")
18056    (set_attr "mode" "<sseinsnmode>")])
18058 (define_insn "<mask_codefor>avx512vl_broadcast<mode><mask_name>_1"
18059   [(set (match_operand:VI4F_256 0 "register_operand" "=v,v")
18060         (vec_duplicate:VI4F_256
18061          (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "v,m")))]
18062   "TARGET_AVX512VL"
18063   "@
18064    vshuf<shuffletype>32x4\t{$0x0, %t1, %t1, %0<mask_operand2>|%0<mask_operand2>, %t1, %t1, 0x0}
18065    vbroadcast<shuffletype>32x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18066   [(set_attr "type" "ssemov")
18067    (set_attr "prefix_extra" "1")
18068    (set_attr "prefix" "evex")
18069    (set_attr "mode" "<sseinsnmode>")])
18071 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>_1"
18072   [(set (match_operand:V16FI 0 "register_operand" "=v,v")
18073        (vec_duplicate:V16FI
18074          (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "v,m")))]
18075   "TARGET_AVX512DQ"
18076   "@
18077    vshuf<shuffletype>32x4\t{$0x44, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x44}
18078    vbroadcast<shuffletype>32x8\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18079   [(set_attr "type" "ssemov")
18080    (set_attr "prefix_extra" "1")
18081    (set_attr "prefix" "evex")
18082    (set_attr "mode" "<sseinsnmode>")])
18084 ;; For broadcast[i|f]64x2
18085 (define_mode_iterator VI8F_BRCST64x2
18086   [V8DI V8DF (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")])
18088 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>_1"
18089   [(set (match_operand:VI8F_BRCST64x2 0 "register_operand" "=v,v")
18090        (vec_duplicate:VI8F_BRCST64x2
18091          (match_operand:<64x2mode> 1 "nonimmediate_operand" "v,m")))]
18092   "TARGET_AVX512DQ"
18093   "@
18094    vshuf<shuffletype>64x2\t{$0x0, %<concat_tg_mode>1, %<concat_tg_mode>1, %0<mask_operand2>|%0<mask_operand2>, %<concat_tg_mode>1, %<concat_tg_mode>1, 0x0}
18095    vbroadcast<shuffletype>64x2\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18096   [(set_attr "type" "ssemov")
18097    (set_attr "prefix_extra" "1")
18098    (set_attr "prefix" "evex")
18099    (set_attr "mode" "<sseinsnmode>")])
18101 (define_insn "avx512cd_maskb_vec_dup<mode>"
18102   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
18103         (vec_duplicate:VI8_AVX512VL
18104           (zero_extend:DI
18105             (match_operand:QI 1 "register_operand" "Yk"))))]
18106   "TARGET_AVX512CD"
18107   "vpbroadcastmb2q\t{%1, %0|%0, %1}"
18108   [(set_attr "type" "mskmov")
18109    (set_attr "prefix" "evex")
18110    (set_attr "mode" "XI")])
18112 (define_insn "avx512cd_maskw_vec_dup<mode>"
18113   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
18114         (vec_duplicate:VI4_AVX512VL
18115           (zero_extend:SI
18116             (match_operand:HI 1 "register_operand" "Yk"))))]
18117   "TARGET_AVX512CD"
18118   "vpbroadcastmw2d\t{%1, %0|%0, %1}"
18119   [(set_attr "type" "mskmov")
18120    (set_attr "prefix" "evex")
18121    (set_attr "mode" "XI")])
18123 ;; Recognize broadcast as a vec_select as produced by builtin_vec_perm.
18124 ;; If it so happens that the input is in memory, use vbroadcast.
18125 ;; Otherwise use vpermilp (and in the case of 256-bit modes, vperm2f128).
18126 (define_insn "*avx_vperm_broadcast_v4sf"
18127   [(set (match_operand:V4SF 0 "register_operand" "=v,v,v")
18128         (vec_select:V4SF
18129           (match_operand:V4SF 1 "nonimmediate_operand" "m,o,v")
18130           (match_parallel 2 "avx_vbroadcast_operand"
18131             [(match_operand 3 "const_int_operand" "C,n,n")])))]
18132   "TARGET_AVX"
18134   int elt = INTVAL (operands[3]);
18135   switch (which_alternative)
18136     {
18137     case 0:
18138     case 1:
18139       operands[1] = adjust_address_nv (operands[1], SFmode, elt * 4);
18140       return "vbroadcastss\t{%1, %0|%0, %k1}";
18141     case 2:
18142       operands[2] = GEN_INT (elt * 0x55);
18143       return "vpermilps\t{%2, %1, %0|%0, %1, %2}";
18144     default:
18145       gcc_unreachable ();
18146     }
18148   [(set_attr "type" "ssemov,ssemov,sselog1")
18149    (set_attr "prefix_extra" "1")
18150    (set_attr "length_immediate" "0,0,1")
18151    (set_attr "prefix" "maybe_evex")
18152    (set_attr "mode" "SF,SF,V4SF")])
18154 (define_insn_and_split "*avx_vperm_broadcast_<mode>"
18155   [(set (match_operand:VF_256 0 "register_operand" "=v,v,v")
18156         (vec_select:VF_256
18157           (match_operand:VF_256 1 "nonimmediate_operand" "m,o,?v")
18158           (match_parallel 2 "avx_vbroadcast_operand"
18159             [(match_operand 3 "const_int_operand" "C,n,n")])))]
18160   "TARGET_AVX"
18161   "#"
18162   "&& reload_completed && (<MODE>mode != V4DFmode || !TARGET_AVX2)"
18163   [(set (match_dup 0) (vec_duplicate:VF_256 (match_dup 1)))]
18165   rtx op0 = operands[0], op1 = operands[1];
18166   int elt = INTVAL (operands[3]);
18168   if (REG_P (op1))
18169     {
18170       int mask;
18172       if (TARGET_AVX2 && elt == 0)
18173         {
18174           emit_insn (gen_vec_dup<mode> (op0, gen_lowpart (<ssescalarmode>mode,
18175                                                           op1)));
18176           DONE;
18177         }
18179       /* Shuffle element we care about into all elements of the 128-bit lane.
18180          The other lane gets shuffled too, but we don't care.  */
18181       if (<MODE>mode == V4DFmode)
18182         mask = (elt & 1 ? 15 : 0);
18183       else
18184         mask = (elt & 3) * 0x55;
18185       emit_insn (gen_avx_vpermil<mode> (op0, op1, GEN_INT (mask)));
18187       /* Shuffle the lane we care about into both lanes of the dest.  */
18188       mask = (elt / (<ssescalarnum> / 2)) * 0x11;
18189       if (EXT_REX_SSE_REG_P (op0))
18190         {
18191           /* There is no EVEX VPERM2F128, but we can use either VBROADCASTSS
18192              or VSHUFF128.  */
18193           gcc_assert (<MODE>mode == V8SFmode);
18194           if ((mask & 1) == 0)
18195             emit_insn (gen_avx2_vec_dupv8sf (op0,
18196                                              gen_lowpart (V4SFmode, op0)));
18197           else
18198             emit_insn (gen_avx512vl_shuf_f32x4_1 (op0, op0, op0,
18199                                                   GEN_INT (4), GEN_INT (5),
18200                                                   GEN_INT (6), GEN_INT (7),
18201                                                   GEN_INT (12), GEN_INT (13),
18202                                                   GEN_INT (14), GEN_INT (15)));
18203           DONE;
18204         }
18206       emit_insn (gen_avx_vperm2f128<mode>3 (op0, op0, op0, GEN_INT (mask)));
18207       DONE;
18208     }
18210   operands[1] = adjust_address (op1, <ssescalarmode>mode,
18211                                 elt * GET_MODE_SIZE (<ssescalarmode>mode));
18214 (define_expand "<sse2_avx_avx512f>_vpermil<mode><mask_name>"
18215   [(set (match_operand:VF2 0 "register_operand")
18216         (vec_select:VF2
18217           (match_operand:VF2 1 "nonimmediate_operand")
18218           (match_operand:SI 2 "const_0_to_255_operand")))]
18219   "TARGET_AVX && <mask_mode512bit_condition>"
18221   int mask = INTVAL (operands[2]);
18222   rtx perm[<ssescalarnum>];
18224   int i;
18225   for (i = 0; i < <ssescalarnum>; i = i + 2)
18226     {
18227       perm[i]     = GEN_INT (((mask >> i)       & 1) + i);
18228       perm[i + 1] = GEN_INT (((mask >> (i + 1)) & 1) + i);
18229     }
18231   operands[2]
18232     = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (<ssescalarnum>, perm));
18235 (define_expand "<sse2_avx_avx512f>_vpermil<mode><mask_name>"
18236   [(set (match_operand:VF1 0 "register_operand")
18237         (vec_select:VF1
18238           (match_operand:VF1 1 "nonimmediate_operand")
18239           (match_operand:SI 2 "const_0_to_255_operand")))]
18240   "TARGET_AVX && <mask_mode512bit_condition>"
18242   int mask = INTVAL (operands[2]);
18243   rtx perm[<ssescalarnum>];
18245   int i;
18246   for (i = 0; i < <ssescalarnum>; i = i + 4)
18247     {
18248       perm[i]     = GEN_INT (((mask >> 0) & 3) + i);
18249       perm[i + 1] = GEN_INT (((mask >> 2) & 3) + i);
18250       perm[i + 2] = GEN_INT (((mask >> 4) & 3) + i);
18251       perm[i + 3] = GEN_INT (((mask >> 6) & 3) + i);
18252     }
18254   operands[2]
18255     = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (<ssescalarnum>, perm));
18258 (define_insn "*<sse2_avx_avx512f>_vpermilp<mode><mask_name>"
18259   [(set (match_operand:VF 0 "register_operand" "=v")
18260         (vec_select:VF
18261           (match_operand:VF 1 "nonimmediate_operand" "vm")
18262           (match_parallel 2 ""
18263             [(match_operand 3 "const_int_operand")])))]
18264   "TARGET_AVX && <mask_mode512bit_condition>
18265    && avx_vpermilp_parallel (operands[2], <MODE>mode)"
18267   int mask = avx_vpermilp_parallel (operands[2], <MODE>mode) - 1;
18268   operands[2] = GEN_INT (mask);
18269   return "vpermil<ssemodesuffix>\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}";
18271   [(set_attr "type" "sselog")
18272    (set_attr "prefix_extra" "1")
18273    (set_attr "length_immediate" "1")
18274    (set_attr "prefix" "<mask_prefix>")
18275    (set_attr "mode" "<sseinsnmode>")])
18277 (define_insn "<sse2_avx_avx512f>_vpermilvar<mode>3<mask_name>"
18278   [(set (match_operand:VF 0 "register_operand" "=v")
18279         (unspec:VF
18280           [(match_operand:VF 1 "register_operand" "v")
18281            (match_operand:<sseintvecmode> 2 "nonimmediate_operand" "vm")]
18282           UNSPEC_VPERMIL))]
18283   "TARGET_AVX && <mask_mode512bit_condition>"
18284   "vpermil<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18285   [(set_attr "type" "sselog")
18286    (set_attr "prefix_extra" "1")
18287    (set_attr "btver2_decode" "vector")
18288    (set_attr "prefix" "<mask_prefix>")
18289    (set_attr "mode" "<sseinsnmode>")])
18291 (define_mode_iterator VPERMI2
18292   [V16SI V16SF V8DI V8DF
18293    (V8SI "TARGET_AVX512VL") (V8SF "TARGET_AVX512VL")
18294    (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")
18295    (V4SI "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
18296    (V2DI "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")
18297    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX512BW && TARGET_AVX512VL")
18298    (V8HI "TARGET_AVX512BW && TARGET_AVX512VL")
18299    (V64QI "TARGET_AVX512VBMI") (V32QI "TARGET_AVX512VBMI && TARGET_AVX512VL")
18300    (V16QI "TARGET_AVX512VBMI && TARGET_AVX512VL")])
18302 (define_mode_iterator VPERMI2I
18303   [V16SI V8DI
18304    (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
18305    (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")
18306    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX512BW && TARGET_AVX512VL")
18307    (V8HI "TARGET_AVX512BW && TARGET_AVX512VL")
18308    (V64QI "TARGET_AVX512VBMI") (V32QI "TARGET_AVX512VBMI && TARGET_AVX512VL")
18309    (V16QI "TARGET_AVX512VBMI && TARGET_AVX512VL")])
18311 (define_expand "<avx512>_vpermi2var<mode>3_mask"
18312   [(set (match_operand:VPERMI2 0 "register_operand")
18313         (vec_merge:VPERMI2
18314           (unspec:VPERMI2
18315             [(match_operand:<sseintvecmode> 2 "register_operand")
18316              (match_operand:VPERMI2 1 "register_operand")
18317              (match_operand:VPERMI2 3 "nonimmediate_operand")]
18318             UNSPEC_VPERMT2)
18319           (match_dup 5)
18320           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
18321   "TARGET_AVX512F"
18323   operands[2] = force_reg (<sseintvecmode>mode, operands[2]);
18324   operands[5] = gen_lowpart (<MODE>mode, operands[2]);
18327 (define_insn "*<avx512>_vpermi2var<mode>3_mask"
18328   [(set (match_operand:VPERMI2I 0 "register_operand" "=v")
18329         (vec_merge:VPERMI2I
18330           (unspec:VPERMI2I
18331             [(match_operand:<sseintvecmode> 2 "register_operand" "0")
18332              (match_operand:VPERMI2I 1 "register_operand" "v")
18333              (match_operand:VPERMI2I 3 "nonimmediate_operand" "vm")]
18334             UNSPEC_VPERMT2)
18335           (match_dup 2)
18336           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
18337   "TARGET_AVX512F"
18338   "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
18339   [(set_attr "type" "sselog")
18340    (set_attr "prefix" "evex")
18341    (set_attr "mode" "<sseinsnmode>")])
18343 (define_insn "*<avx512>_vpermi2var<mode>3_mask"
18344   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
18345         (vec_merge:VF_AVX512VL
18346           (unspec:VF_AVX512VL
18347             [(match_operand:<sseintvecmode> 2 "register_operand" "0")
18348              (match_operand:VF_AVX512VL 1 "register_operand" "v")
18349              (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "vm")]
18350             UNSPEC_VPERMT2)
18351           (subreg:VF_AVX512VL (match_dup 2) 0)
18352           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
18353   "TARGET_AVX512F"
18354   "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
18355   [(set_attr "type" "sselog")
18356    (set_attr "prefix" "evex")
18357    (set_attr "mode" "<sseinsnmode>")])
18359 (define_expand "<avx512>_vpermt2var<mode>3_maskz"
18360   [(match_operand:VPERMI2 0 "register_operand")
18361    (match_operand:<sseintvecmode> 1 "register_operand")
18362    (match_operand:VPERMI2 2 "register_operand")
18363    (match_operand:VPERMI2 3 "nonimmediate_operand")
18364    (match_operand:<avx512fmaskmode> 4 "register_operand")]
18365   "TARGET_AVX512F"
18367   emit_insn (gen_<avx512>_vpermt2var<mode>3_maskz_1 (
18368         operands[0], operands[1], operands[2], operands[3],
18369         CONST0_RTX (<MODE>mode), operands[4]));
18370   DONE;
18373 (define_insn "<avx512>_vpermt2var<mode>3<sd_maskz_name>"
18374   [(set (match_operand:VPERMI2 0 "register_operand" "=v,v")
18375         (unspec:VPERMI2
18376           [(match_operand:<sseintvecmode> 1 "register_operand" "v,0")
18377            (match_operand:VPERMI2 2 "register_operand" "0,v")
18378            (match_operand:VPERMI2 3 "nonimmediate_operand" "vm,vm")]
18379           UNSPEC_VPERMT2))]
18380   "TARGET_AVX512F"
18381   "@
18382    vpermt2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}
18383    vpermi2<ssemodesuffix>\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}"
18384   [(set_attr "type" "sselog")
18385    (set_attr "prefix" "evex")
18386    (set_attr "mode" "<sseinsnmode>")])
18388 (define_insn "<avx512>_vpermt2var<mode>3_mask"
18389   [(set (match_operand:VPERMI2 0 "register_operand" "=v")
18390         (vec_merge:VPERMI2
18391           (unspec:VPERMI2
18392             [(match_operand:<sseintvecmode> 1 "register_operand" "v")
18393             (match_operand:VPERMI2 2 "register_operand" "0")
18394             (match_operand:VPERMI2 3 "nonimmediate_operand" "vm")]
18395             UNSPEC_VPERMT2)
18396           (match_dup 2)
18397           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
18398   "TARGET_AVX512F"
18399   "vpermt2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
18400   [(set_attr "type" "sselog")
18401    (set_attr "prefix" "evex")
18402    (set_attr "mode" "<sseinsnmode>")])
18404 (define_expand "avx_vperm2f128<mode>3"
18405   [(set (match_operand:AVX256MODE2P 0 "register_operand")
18406         (unspec:AVX256MODE2P
18407           [(match_operand:AVX256MODE2P 1 "register_operand")
18408            (match_operand:AVX256MODE2P 2 "nonimmediate_operand")
18409            (match_operand:SI 3 "const_0_to_255_operand")]
18410           UNSPEC_VPERMIL2F128))]
18411   "TARGET_AVX"
18413   int mask = INTVAL (operands[3]);
18414   if ((mask & 0x88) == 0)
18415     {
18416       rtx perm[<ssescalarnum>], t1, t2;
18417       int i, base, nelt = <ssescalarnum>, nelt2 = nelt / 2;
18419       base = (mask & 3) * nelt2;
18420       for (i = 0; i < nelt2; ++i)
18421         perm[i] = GEN_INT (base + i);
18423       base = ((mask >> 4) & 3) * nelt2;
18424       for (i = 0; i < nelt2; ++i)
18425         perm[i + nelt2] = GEN_INT (base + i);
18427       t2 = gen_rtx_VEC_CONCAT (<ssedoublevecmode>mode,
18428                                operands[1], operands[2]);
18429       t1 = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (nelt, perm));
18430       t2 = gen_rtx_VEC_SELECT (<MODE>mode, t2, t1);
18431       t2 = gen_rtx_SET (operands[0], t2);
18432       emit_insn (t2);
18433       DONE;
18434     }
18437 ;; Note that bits 7 and 3 of the imm8 allow lanes to be zeroed, which
18438 ;; means that in order to represent this properly in rtl we'd have to
18439 ;; nest *another* vec_concat with a zero operand and do the select from
18440 ;; a 4x wide vector.  That doesn't seem very nice.
18441 (define_insn "*avx_vperm2f128<mode>_full"
18442   [(set (match_operand:AVX256MODE2P 0 "register_operand" "=x")
18443         (unspec:AVX256MODE2P
18444           [(match_operand:AVX256MODE2P 1 "register_operand" "x")
18445            (match_operand:AVX256MODE2P 2 "nonimmediate_operand" "xm")
18446            (match_operand:SI 3 "const_0_to_255_operand" "n")]
18447           UNSPEC_VPERMIL2F128))]
18448   "TARGET_AVX"
18449   "vperm2<i128>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
18450   [(set_attr "type" "sselog")
18451    (set_attr "prefix_extra" "1")
18452    (set_attr "length_immediate" "1")
18453    (set_attr "prefix" "vex")
18454    (set_attr "mode" "<sseinsnmode>")])
18456 (define_insn "*avx_vperm2f128<mode>_nozero"
18457   [(set (match_operand:AVX256MODE2P 0 "register_operand" "=x")
18458         (vec_select:AVX256MODE2P
18459           (vec_concat:<ssedoublevecmode>
18460             (match_operand:AVX256MODE2P 1 "register_operand" "x")
18461             (match_operand:AVX256MODE2P 2 "nonimmediate_operand" "xm"))
18462           (match_parallel 3 ""
18463             [(match_operand 4 "const_int_operand")])))]
18464   "TARGET_AVX
18465    && avx_vperm2f128_parallel (operands[3], <MODE>mode)"
18467   int mask = avx_vperm2f128_parallel (operands[3], <MODE>mode) - 1;
18468   if (mask == 0x12)
18469     return "vinsert<i128>\t{$0, %x2, %1, %0|%0, %1, %x2, 0}";
18470   if (mask == 0x20)
18471     return "vinsert<i128>\t{$1, %x2, %1, %0|%0, %1, %x2, 1}";
18472   operands[3] = GEN_INT (mask);
18473   return "vperm2<i128>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
18475   [(set_attr "type" "sselog")
18476    (set_attr "prefix_extra" "1")
18477    (set_attr "length_immediate" "1")
18478    (set_attr "prefix" "vex")
18479    (set_attr "mode" "<sseinsnmode>")])
18481 (define_insn "*ssse3_palignr<mode>_perm"
18482   [(set (match_operand:V_128 0 "register_operand" "=x,x,v")
18483       (vec_select:V_128
18484         (match_operand:V_128 1 "register_operand" "0,x,v")
18485         (match_parallel 2 "palignr_operand"
18486           [(match_operand 3 "const_int_operand" "n,n,n")])))]
18487   "TARGET_SSSE3"
18489   operands[2] = (GEN_INT (INTVAL (operands[3])
18490                  * GET_MODE_UNIT_SIZE (GET_MODE (operands[0]))));
18492   switch (which_alternative)
18493     {
18494     case 0:
18495       return "palignr\t{%2, %1, %0|%0, %1, %2}";
18496     case 1:
18497     case 2:
18498       return "vpalignr\t{%2, %1, %1, %0|%0, %1, %1, %2}";
18499     default:
18500       gcc_unreachable ();
18501     }
18503   [(set_attr "isa" "noavx,avx,avx512bw")
18504    (set_attr "type" "sseishft")
18505    (set_attr "atom_unit" "sishuf")
18506    (set_attr "prefix_data16" "1,*,*")
18507    (set_attr "prefix_extra" "1")
18508    (set_attr "length_immediate" "1")
18509    (set_attr "prefix" "orig,vex,evex")])
18511 (define_expand "avx512vl_vinsert<mode>"
18512   [(match_operand:VI48F_256 0 "register_operand")
18513    (match_operand:VI48F_256 1 "register_operand")
18514    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
18515    (match_operand:SI 3 "const_0_to_1_operand")
18516    (match_operand:VI48F_256 4 "register_operand")
18517    (match_operand:<avx512fmaskmode> 5 "register_operand")]
18518   "TARGET_AVX512VL"
18520   rtx (*insn)(rtx, rtx, rtx, rtx, rtx);
18522   switch (INTVAL (operands[3]))
18523     {
18524     case 0:
18525       insn = gen_vec_set_lo_<mode>_mask;
18526       break;
18527     case 1:
18528       insn = gen_vec_set_hi_<mode>_mask;
18529       break;
18530     default:
18531       gcc_unreachable ();
18532     }
18534   emit_insn (insn (operands[0], operands[1], operands[2], operands[4],
18535                    operands[5]));
18536   DONE;
18539 (define_expand "avx_vinsertf128<mode>"
18540   [(match_operand:V_256 0 "register_operand")
18541    (match_operand:V_256 1 "register_operand")
18542    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
18543    (match_operand:SI 3 "const_0_to_1_operand")]
18544   "TARGET_AVX"
18546   rtx (*insn)(rtx, rtx, rtx);
18548   switch (INTVAL (operands[3]))
18549     {
18550     case 0:
18551       insn = gen_vec_set_lo_<mode>;
18552       break;
18553     case 1:
18554       insn = gen_vec_set_hi_<mode>;
18555       break;
18556     default:
18557       gcc_unreachable ();
18558     }
18560   emit_insn (insn (operands[0], operands[1], operands[2]));
18561   DONE;
18564 (define_insn "vec_set_lo_<mode><mask_name>"
18565   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
18566         (vec_concat:VI8F_256
18567           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
18568           (vec_select:<ssehalfvecmode>
18569             (match_operand:VI8F_256 1 "register_operand" "v")
18570             (parallel [(const_int 2) (const_int 3)]))))]
18571   "TARGET_AVX && <mask_avx512dq_condition>"
18573   if (TARGET_AVX512DQ)
18574     return "vinsert<shuffletype>64x2\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
18575   else if (TARGET_AVX512VL)
18576     return "vinsert<shuffletype>32x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
18577   else
18578     return "vinsert<i128>\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}";
18580   [(set_attr "type" "sselog")
18581    (set_attr "prefix_extra" "1")
18582    (set_attr "length_immediate" "1")
18583    (set_attr "prefix" "vex")
18584    (set_attr "mode" "<sseinsnmode>")])
18586 (define_insn "vec_set_hi_<mode><mask_name>"
18587   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
18588         (vec_concat:VI8F_256
18589           (vec_select:<ssehalfvecmode>
18590             (match_operand:VI8F_256 1 "register_operand" "v")
18591             (parallel [(const_int 0) (const_int 1)]))
18592           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
18593   "TARGET_AVX && <mask_avx512dq_condition>"
18595   if (TARGET_AVX512DQ)
18596     return "vinsert<shuffletype>64x2\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
18597   else if (TARGET_AVX512VL)
18598     return "vinsert<shuffletype>32x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
18599   else
18600     return "vinsert<i128>\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}";
18602   [(set_attr "type" "sselog")
18603    (set_attr "prefix_extra" "1")
18604    (set_attr "length_immediate" "1")
18605    (set_attr "prefix" "vex")
18606    (set_attr "mode" "<sseinsnmode>")])
18608 (define_insn "vec_set_lo_<mode><mask_name>"
18609   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
18610         (vec_concat:VI4F_256
18611           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
18612           (vec_select:<ssehalfvecmode>
18613             (match_operand:VI4F_256 1 "register_operand" "v")
18614             (parallel [(const_int 4) (const_int 5)
18615                        (const_int 6) (const_int 7)]))))]
18616   "TARGET_AVX"
18618   if (TARGET_AVX512VL)
18619     return "vinsert<shuffletype>32x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
18620   else
18621     return "vinsert<i128>\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}";
18623   [(set_attr "type" "sselog")
18624    (set_attr "prefix_extra" "1")
18625    (set_attr "length_immediate" "1")
18626    (set_attr "prefix" "vex")
18627    (set_attr "mode" "<sseinsnmode>")])
18629 (define_insn "vec_set_hi_<mode><mask_name>"
18630   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
18631         (vec_concat:VI4F_256
18632           (vec_select:<ssehalfvecmode>
18633             (match_operand:VI4F_256 1 "register_operand" "v")
18634             (parallel [(const_int 0) (const_int 1)
18635                        (const_int 2) (const_int 3)]))
18636           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
18637   "TARGET_AVX"
18639   if (TARGET_AVX512VL)
18640     return "vinsert<shuffletype>32x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
18641   else
18642     return "vinsert<i128>\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}";
18644   [(set_attr "type" "sselog")
18645    (set_attr "prefix_extra" "1")
18646    (set_attr "length_immediate" "1")
18647    (set_attr "prefix" "vex")
18648    (set_attr "mode" "<sseinsnmode>")])
18650 (define_insn "vec_set_lo_v16hi"
18651   [(set (match_operand:V16HI 0 "register_operand" "=x,v")
18652         (vec_concat:V16HI
18653           (match_operand:V8HI 2 "nonimmediate_operand" "xm,vm")
18654           (vec_select:V8HI
18655             (match_operand:V16HI 1 "register_operand" "x,v")
18656             (parallel [(const_int 8) (const_int 9)
18657                        (const_int 10) (const_int 11)
18658                        (const_int 12) (const_int 13)
18659                        (const_int 14) (const_int 15)]))))]
18660   "TARGET_AVX"
18661   "@
18662    vinsert%~128\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}
18663    vinserti32x4\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}"
18664   [(set_attr "type" "sselog")
18665    (set_attr "prefix_extra" "1")
18666    (set_attr "length_immediate" "1")
18667    (set_attr "prefix" "vex,evex")
18668    (set_attr "mode" "OI")])
18670 (define_insn "vec_set_hi_v16hi"
18671   [(set (match_operand:V16HI 0 "register_operand" "=x,v")
18672         (vec_concat:V16HI
18673           (vec_select:V8HI
18674             (match_operand:V16HI 1 "register_operand" "x,v")
18675             (parallel [(const_int 0) (const_int 1)
18676                        (const_int 2) (const_int 3)
18677                        (const_int 4) (const_int 5)
18678                        (const_int 6) (const_int 7)]))
18679           (match_operand:V8HI 2 "nonimmediate_operand" "xm,vm")))]
18680   "TARGET_AVX"
18681   "@
18682    vinsert%~128\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}
18683    vinserti32x4\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}"
18684   [(set_attr "type" "sselog")
18685    (set_attr "prefix_extra" "1")
18686    (set_attr "length_immediate" "1")
18687    (set_attr "prefix" "vex,evex")
18688    (set_attr "mode" "OI")])
18690 (define_insn "vec_set_lo_v32qi"
18691   [(set (match_operand:V32QI 0 "register_operand" "=x,v")
18692         (vec_concat:V32QI
18693           (match_operand:V16QI 2 "nonimmediate_operand" "xm,v")
18694           (vec_select:V16QI
18695             (match_operand:V32QI 1 "register_operand" "x,v")
18696             (parallel [(const_int 16) (const_int 17)
18697                        (const_int 18) (const_int 19)
18698                        (const_int 20) (const_int 21)
18699                        (const_int 22) (const_int 23)
18700                        (const_int 24) (const_int 25)
18701                        (const_int 26) (const_int 27)
18702                        (const_int 28) (const_int 29)
18703                        (const_int 30) (const_int 31)]))))]
18704   "TARGET_AVX"
18705   "@
18706    vinsert%~128\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}
18707    vinserti32x4\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}"
18708   [(set_attr "type" "sselog")
18709    (set_attr "prefix_extra" "1")
18710    (set_attr "length_immediate" "1")
18711    (set_attr "prefix" "vex,evex")
18712    (set_attr "mode" "OI")])
18714 (define_insn "vec_set_hi_v32qi"
18715   [(set (match_operand:V32QI 0 "register_operand" "=x,v")
18716         (vec_concat:V32QI
18717           (vec_select:V16QI
18718             (match_operand:V32QI 1 "register_operand" "x,v")
18719             (parallel [(const_int 0) (const_int 1)
18720                        (const_int 2) (const_int 3)
18721                        (const_int 4) (const_int 5)
18722                        (const_int 6) (const_int 7)
18723                        (const_int 8) (const_int 9)
18724                        (const_int 10) (const_int 11)
18725                        (const_int 12) (const_int 13)
18726                        (const_int 14) (const_int 15)]))
18727           (match_operand:V16QI 2 "nonimmediate_operand" "xm,vm")))]
18728   "TARGET_AVX"
18729   "@
18730    vinsert%~128\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}
18731    vinserti32x4\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}"
18732   [(set_attr "type" "sselog")
18733    (set_attr "prefix_extra" "1")
18734    (set_attr "length_immediate" "1")
18735    (set_attr "prefix" "vex,evex")
18736    (set_attr "mode" "OI")])
18738 (define_insn "<avx_avx2>_maskload<ssemodesuffix><avxsizesuffix>"
18739   [(set (match_operand:V48_AVX2 0 "register_operand" "=x")
18740         (unspec:V48_AVX2
18741           [(match_operand:<sseintvecmode> 2 "register_operand" "x")
18742            (match_operand:V48_AVX2 1 "memory_operand" "m")]
18743           UNSPEC_MASKMOV))]
18744   "TARGET_AVX"
18745   "v<sseintprefix>maskmov<ssemodesuffix>\t{%1, %2, %0|%0, %2, %1}"
18746   [(set_attr "type" "sselog1")
18747    (set_attr "prefix_extra" "1")
18748    (set_attr "prefix" "vex")
18749    (set_attr "btver2_decode" "vector")
18750    (set_attr "mode" "<sseinsnmode>")])
18752 (define_insn "<avx_avx2>_maskstore<ssemodesuffix><avxsizesuffix>"
18753   [(set (match_operand:V48_AVX2 0 "memory_operand" "+m")
18754         (unspec:V48_AVX2
18755           [(match_operand:<sseintvecmode> 1 "register_operand" "x")
18756            (match_operand:V48_AVX2 2 "register_operand" "x")
18757            (match_dup 0)]
18758           UNSPEC_MASKMOV))]
18759   "TARGET_AVX"
18760   "v<sseintprefix>maskmov<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
18761   [(set_attr "type" "sselog1")
18762    (set_attr "prefix_extra" "1")
18763    (set_attr "prefix" "vex")
18764    (set_attr "btver2_decode" "vector") 
18765    (set_attr "mode" "<sseinsnmode>")])
18767 (define_expand "maskload<mode><sseintvecmodelower>"
18768   [(set (match_operand:V48_AVX2 0 "register_operand")
18769         (unspec:V48_AVX2
18770           [(match_operand:<sseintvecmode> 2 "register_operand")
18771            (match_operand:V48_AVX2 1 "memory_operand")]
18772           UNSPEC_MASKMOV))]
18773   "TARGET_AVX")
18775 (define_expand "maskload<mode><avx512fmaskmodelower>"
18776   [(set (match_operand:V48_AVX512VL 0 "register_operand")
18777         (vec_merge:V48_AVX512VL
18778           (match_operand:V48_AVX512VL 1 "memory_operand")
18779           (match_dup 0)
18780           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18781   "TARGET_AVX512F")
18783 (define_expand "maskload<mode><avx512fmaskmodelower>"
18784   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
18785         (vec_merge:VI12_AVX512VL
18786           (match_operand:VI12_AVX512VL 1 "memory_operand")
18787           (match_dup 0)
18788           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18789   "TARGET_AVX512BW")
18791 (define_expand "maskstore<mode><sseintvecmodelower>"
18792   [(set (match_operand:V48_AVX2 0 "memory_operand")
18793         (unspec:V48_AVX2
18794           [(match_operand:<sseintvecmode> 2 "register_operand")
18795            (match_operand:V48_AVX2 1 "register_operand")
18796            (match_dup 0)]
18797           UNSPEC_MASKMOV))]
18798   "TARGET_AVX")
18800 (define_expand "maskstore<mode><avx512fmaskmodelower>"
18801   [(set (match_operand:V48_AVX512VL 0 "memory_operand")
18802         (vec_merge:V48_AVX512VL
18803           (match_operand:V48_AVX512VL 1 "register_operand")
18804           (match_dup 0)
18805           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18806   "TARGET_AVX512F")
18808 (define_expand "maskstore<mode><avx512fmaskmodelower>"
18809   [(set (match_operand:VI12_AVX512VL 0 "memory_operand")
18810         (vec_merge:VI12_AVX512VL
18811           (match_operand:VI12_AVX512VL 1 "register_operand")
18812           (match_dup 0)
18813           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18814   "TARGET_AVX512BW")
18816 (define_expand "cbranch<mode>4"
18817   [(set (reg:CC FLAGS_REG)
18818         (compare:CC (match_operand:VI48_AVX 1 "register_operand")
18819                     (match_operand:VI48_AVX 2 "nonimmediate_operand")))
18820    (set (pc) (if_then_else
18821                (match_operator 0 "bt_comparison_operator"
18822                 [(reg:CC FLAGS_REG) (const_int 0)])
18823                (label_ref (match_operand 3))
18824                (pc)))]
18825   "TARGET_SSE4_1"
18827   ix86_expand_branch (GET_CODE (operands[0]),
18828                       operands[1], operands[2], operands[3]);
18829   DONE;
18833 (define_insn_and_split "avx_<castmode><avxsizesuffix>_<castmode>"
18834   [(set (match_operand:AVX256MODE2P 0 "nonimmediate_operand" "=x,m")
18835         (unspec:AVX256MODE2P
18836           [(match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "xm,x")]
18837           UNSPEC_CAST))]
18838   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
18839   "#"
18840   "&& reload_completed"
18841   [(set (match_dup 0) (match_dup 1))]
18843   if (REG_P (operands[0]))
18844     operands[0] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);
18845   else
18846     operands[1] = lowpart_subreg (<MODE>mode, operands[1],
18847                                   <ssehalfvecmode>mode);
18850 ;; Modes handled by vec_init expanders.
18851 (define_mode_iterator VEC_INIT_MODE
18852   [(V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
18853    (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI
18854    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
18855    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI
18856    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
18857    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")
18858    (V4TI "TARGET_AVX512F") (V2TI "TARGET_AVX")])
18860 ;; Likewise, but for initialization from half sized vectors.
18861 ;; Thus, these are all VEC_INIT_MODE modes except V2??.
18862 (define_mode_iterator VEC_INIT_HALF_MODE
18863   [(V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
18864    (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI
18865    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
18866    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX")
18867    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
18868    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX")
18869    (V4TI "TARGET_AVX512F")])
18871 (define_expand "vec_init<mode><ssescalarmodelower>"
18872   [(match_operand:VEC_INIT_MODE 0 "register_operand")
18873    (match_operand 1)]
18874   "TARGET_SSE"
18876   ix86_expand_vector_init (false, operands[0], operands[1]);
18877   DONE;
18880 (define_expand "vec_init<mode><ssehalfvecmodelower>"
18881   [(match_operand:VEC_INIT_HALF_MODE 0 "register_operand")
18882    (match_operand 1)]
18883   "TARGET_SSE"
18885   ix86_expand_vector_init (false, operands[0], operands[1]);
18886   DONE;
18889 (define_insn "<avx2_avx512>_ashrv<mode><mask_name>"
18890   [(set (match_operand:VI48_AVX512F_AVX512VL 0 "register_operand" "=v")
18891         (ashiftrt:VI48_AVX512F_AVX512VL
18892           (match_operand:VI48_AVX512F_AVX512VL 1 "register_operand" "v")
18893           (match_operand:VI48_AVX512F_AVX512VL 2 "nonimmediate_operand" "vm")))]
18894   "TARGET_AVX2 && <mask_mode512bit_condition>"
18895   "vpsrav<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18896   [(set_attr "type" "sseishft")
18897    (set_attr "prefix" "maybe_evex")
18898    (set_attr "mode" "<sseinsnmode>")])
18900 (define_insn "<avx2_avx512>_ashrv<mode><mask_name>"
18901   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
18902         (ashiftrt:VI2_AVX512VL
18903           (match_operand:VI2_AVX512VL 1 "register_operand" "v")
18904           (match_operand:VI2_AVX512VL 2 "nonimmediate_operand" "vm")))]
18905   "TARGET_AVX512BW"
18906   "vpsravw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18907   [(set_attr "type" "sseishft")
18908    (set_attr "prefix" "maybe_evex")
18909    (set_attr "mode" "<sseinsnmode>")])
18911 (define_insn "<avx2_avx512>_<shift_insn>v<mode><mask_name>"
18912   [(set (match_operand:VI48_AVX512F 0 "register_operand" "=v")
18913         (any_lshift:VI48_AVX512F
18914           (match_operand:VI48_AVX512F 1 "register_operand" "v")
18915           (match_operand:VI48_AVX512F 2 "nonimmediate_operand" "vm")))]
18916   "TARGET_AVX2 && <mask_mode512bit_condition>"
18917   "vp<vshift>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18918   [(set_attr "type" "sseishft")
18919    (set_attr "prefix" "maybe_evex")
18920    (set_attr "mode" "<sseinsnmode>")])
18922 (define_insn "<avx2_avx512>_<shift_insn>v<mode><mask_name>"
18923   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
18924         (any_lshift:VI2_AVX512VL
18925           (match_operand:VI2_AVX512VL 1 "register_operand" "v")
18926           (match_operand:VI2_AVX512VL 2 "nonimmediate_operand" "vm")))]
18927   "TARGET_AVX512BW"
18928   "vp<vshift>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18929   [(set_attr "type" "sseishft")
18930    (set_attr "prefix" "maybe_evex")
18931    (set_attr "mode" "<sseinsnmode>")])
18933 (define_insn "avx_vec_concat<mode>"
18934   [(set (match_operand:V_256_512 0 "register_operand" "=x,v,x,Yv")
18935         (vec_concat:V_256_512
18936           (match_operand:<ssehalfvecmode> 1 "register_operand" "x,v,x,v")
18937           (match_operand:<ssehalfvecmode> 2 "vector_move_operand" "xm,vm,C,C")))]
18938   "TARGET_AVX"
18940   switch (which_alternative)
18941     {
18942     case 0:
18943       return "vinsert<i128>\t{$0x1, %2, %<concat_tg_mode>1, %0|%0, %<concat_tg_mode>1, %2, 0x1}";
18944     case 1:
18945       if (<MODE_SIZE> == 64)
18946         {
18947           if (TARGET_AVX512DQ && GET_MODE_SIZE (<ssescalarmode>mode) == 4)
18948             return "vinsert<shuffletype>32x8\t{$0x1, %2, %<concat_tg_mode>1, %0|%0, %<concat_tg_mode>1, %2, 0x1}";
18949           else
18950             return "vinsert<shuffletype>64x4\t{$0x1, %2, %<concat_tg_mode>1, %0|%0, %<concat_tg_mode>1, %2, 0x1}";
18951         }
18952       else
18953         {
18954           if (TARGET_AVX512DQ && GET_MODE_SIZE (<ssescalarmode>mode) == 8)
18955             return "vinsert<shuffletype>64x2\t{$0x1, %2, %<concat_tg_mode>1, %0|%0, %<concat_tg_mode>1, %2, 0x1}";
18956           else
18957             return "vinsert<shuffletype>32x4\t{$0x1, %2, %<concat_tg_mode>1, %0|%0, %<concat_tg_mode>1, %2, 0x1}";
18958         }
18959     case 2:
18960     case 3:
18961       switch (get_attr_mode (insn))
18962         {
18963         case MODE_V16SF:
18964           return "vmovaps\t{%1, %t0|%t0, %1}";
18965         case MODE_V8DF:
18966           return "vmovapd\t{%1, %t0|%t0, %1}";
18967         case MODE_V8SF:
18968           return "vmovaps\t{%1, %x0|%x0, %1}";
18969         case MODE_V4DF:
18970           return "vmovapd\t{%1, %x0|%x0, %1}";
18971         case MODE_XI:
18972           if (which_alternative == 2)
18973             return "vmovdqa\t{%1, %t0|%t0, %1}";
18974           else if (GET_MODE_SIZE (<ssescalarmode>mode) == 8)
18975             return "vmovdqa64\t{%1, %t0|%t0, %1}";
18976           else
18977             return "vmovdqa32\t{%1, %t0|%t0, %1}";
18978         case MODE_OI:
18979           if (which_alternative == 2)
18980             return "vmovdqa\t{%1, %x0|%x0, %1}";
18981           else if (GET_MODE_SIZE (<ssescalarmode>mode) == 8)
18982             return "vmovdqa64\t{%1, %x0|%x0, %1}";
18983           else
18984             return "vmovdqa32\t{%1, %x0|%x0, %1}";
18985         default:
18986           gcc_unreachable ();
18987         }
18988     default:
18989       gcc_unreachable ();
18990     }
18992   [(set_attr "type" "sselog,sselog,ssemov,ssemov")
18993    (set_attr "prefix_extra" "1,1,*,*")
18994    (set_attr "length_immediate" "1,1,*,*")
18995    (set_attr "prefix" "maybe_evex")
18996    (set_attr "mode" "<sseinsnmode>")])
18998 (define_insn "vcvtph2ps<mask_name>"
18999   [(set (match_operand:V4SF 0 "register_operand" "=v")
19000         (vec_select:V4SF
19001           (unspec:V8SF [(match_operand:V8HI 1 "register_operand" "v")]
19002                        UNSPEC_VCVTPH2PS)
19003           (parallel [(const_int 0) (const_int 1)
19004                      (const_int 2) (const_int 3)])))]
19005   "TARGET_F16C || TARGET_AVX512VL"
19006   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19007   [(set_attr "type" "ssecvt")
19008    (set_attr "prefix" "maybe_evex")
19009    (set_attr "mode" "V4SF")])
19011 (define_insn "*vcvtph2ps_load<mask_name>"
19012   [(set (match_operand:V4SF 0 "register_operand" "=v")
19013         (unspec:V4SF [(match_operand:V4HI 1 "memory_operand" "m")]
19014                      UNSPEC_VCVTPH2PS))]
19015   "TARGET_F16C || TARGET_AVX512VL"
19016   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19017   [(set_attr "type" "ssecvt")
19018    (set_attr "prefix" "vex")
19019    (set_attr "mode" "V8SF")])
19021 (define_insn "vcvtph2ps256<mask_name>"
19022   [(set (match_operand:V8SF 0 "register_operand" "=v")
19023         (unspec:V8SF [(match_operand:V8HI 1 "nonimmediate_operand" "vm")]
19024                      UNSPEC_VCVTPH2PS))]
19025   "TARGET_F16C || TARGET_AVX512VL"
19026   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19027   [(set_attr "type" "ssecvt")
19028    (set_attr "prefix" "vex")
19029    (set_attr "btver2_decode" "double")
19030    (set_attr "mode" "V8SF")])
19032 (define_insn "<mask_codefor>avx512f_vcvtph2ps512<mask_name><round_saeonly_name>"
19033   [(set (match_operand:V16SF 0 "register_operand" "=v")
19034         (unspec:V16SF
19035           [(match_operand:V16HI 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
19036           UNSPEC_VCVTPH2PS))]
19037   "TARGET_AVX512F"
19038   "vcvtph2ps\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
19039   [(set_attr "type" "ssecvt")
19040    (set_attr "prefix" "evex")
19041    (set_attr "mode" "V16SF")])
19043 (define_expand "vcvtps2ph_mask"
19044   [(set (match_operand:V8HI 0 "register_operand")
19045         (vec_merge:V8HI
19046           (vec_concat:V8HI
19047             (unspec:V4HI [(match_operand:V4SF 1 "register_operand")
19048                           (match_operand:SI 2 "const_0_to_255_operand")]
19049                           UNSPEC_VCVTPS2PH)
19050             (match_dup 5))
19051            (match_operand:V8HI 3 "vector_move_operand")
19052            (match_operand:QI 4 "register_operand")))]
19053   "TARGET_AVX512VL"
19054   "operands[5] = CONST0_RTX (V4HImode);")
19056 (define_expand "vcvtps2ph"
19057   [(set (match_operand:V8HI 0 "register_operand")
19058         (vec_concat:V8HI
19059           (unspec:V4HI [(match_operand:V4SF 1 "register_operand")
19060                         (match_operand:SI 2 "const_0_to_255_operand")]
19061                        UNSPEC_VCVTPS2PH)
19062           (match_dup 3)))]
19063   "TARGET_F16C"
19064   "operands[3] = CONST0_RTX (V4HImode);")
19066 (define_insn "*vcvtps2ph<mask_name>"
19067   [(set (match_operand:V8HI 0 "register_operand" "=v")
19068         (vec_concat:V8HI
19069           (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "v")
19070                         (match_operand:SI 2 "const_0_to_255_operand" "N")]
19071                        UNSPEC_VCVTPS2PH)
19072           (match_operand:V4HI 3 "const0_operand")))]
19073   "(TARGET_F16C || TARGET_AVX512VL) && <mask_avx512vl_condition>"
19074   "vcvtps2ph\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}"
19075   [(set_attr "type" "ssecvt")
19076    (set_attr "prefix" "maybe_evex")
19077    (set_attr "mode" "V4SF")])
19079 (define_insn "*vcvtps2ph_store<mask_name>"
19080   [(set (match_operand:V4HI 0 "memory_operand" "=m")
19081         (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "v")
19082                       (match_operand:SI 2 "const_0_to_255_operand" "N")]
19083                      UNSPEC_VCVTPS2PH))]
19084   "TARGET_F16C || TARGET_AVX512VL"
19085   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19086   [(set_attr "type" "ssecvt")
19087    (set_attr "prefix" "maybe_evex")
19088    (set_attr "mode" "V4SF")])
19090 (define_insn "vcvtps2ph256<mask_name>"
19091   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=vm")
19092         (unspec:V8HI [(match_operand:V8SF 1 "register_operand" "v")
19093                       (match_operand:SI 2 "const_0_to_255_operand" "N")]
19094                      UNSPEC_VCVTPS2PH))]
19095   "TARGET_F16C || TARGET_AVX512VL"
19096   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19097   [(set_attr "type" "ssecvt")
19098    (set_attr "prefix" "maybe_evex")
19099    (set_attr "btver2_decode" "vector")
19100    (set_attr "mode" "V8SF")])
19102 (define_insn "<mask_codefor>avx512f_vcvtps2ph512<mask_name>"
19103   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=vm")
19104         (unspec:V16HI
19105           [(match_operand:V16SF 1 "register_operand" "v")
19106            (match_operand:SI 2 "const_0_to_255_operand" "N")]
19107           UNSPEC_VCVTPS2PH))]
19108   "TARGET_AVX512F"
19109   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19110   [(set_attr "type" "ssecvt")
19111    (set_attr "prefix" "evex")
19112    (set_attr "mode" "V16SF")])
19114 ;; For gather* insn patterns
19115 (define_mode_iterator VEC_GATHER_MODE
19116                       [V2DI V2DF V4DI V4DF V4SI V4SF V8SI V8SF])
19117 (define_mode_attr VEC_GATHER_IDXSI
19118                       [(V2DI "V4SI") (V4DI "V4SI") (V8DI "V8SI")
19119                        (V2DF "V4SI") (V4DF "V4SI") (V8DF "V8SI")
19120                        (V4SI "V4SI") (V8SI "V8SI") (V16SI "V16SI")
19121                        (V4SF "V4SI") (V8SF "V8SI") (V16SF "V16SI")])
19123 (define_mode_attr VEC_GATHER_IDXDI
19124                       [(V2DI "V2DI") (V4DI "V4DI") (V8DI "V8DI")
19125                        (V2DF "V2DI") (V4DF "V4DI") (V8DF "V8DI")
19126                        (V4SI "V2DI") (V8SI "V4DI") (V16SI "V8DI")
19127                        (V4SF "V2DI") (V8SF "V4DI") (V16SF "V8DI")])
19129 (define_mode_attr VEC_GATHER_SRCDI
19130                       [(V2DI "V2DI") (V4DI "V4DI") (V8DI "V8DI")
19131                        (V2DF "V2DF") (V4DF "V4DF") (V8DF "V8DF")
19132                        (V4SI "V4SI") (V8SI "V4SI") (V16SI "V8SI")
19133                        (V4SF "V4SF") (V8SF "V4SF") (V16SF "V8SF")])
19135 (define_expand "avx2_gathersi<mode>"
19136   [(parallel [(set (match_operand:VEC_GATHER_MODE 0 "register_operand")
19137                    (unspec:VEC_GATHER_MODE
19138                      [(match_operand:VEC_GATHER_MODE 1 "register_operand")
19139                       (mem:<ssescalarmode>
19140                         (match_par_dup 6
19141                           [(match_operand 2 "vsib_address_operand")
19142                            (match_operand:<VEC_GATHER_IDXSI>
19143                               3 "register_operand")
19144                            (match_operand:SI 5 "const1248_operand ")]))
19145                       (mem:BLK (scratch))
19146                       (match_operand:VEC_GATHER_MODE 4 "register_operand")]
19147                      UNSPEC_GATHER))
19148               (clobber (match_scratch:VEC_GATHER_MODE 7))])]
19149   "TARGET_AVX2"
19151   operands[6]
19152     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
19153                                         operands[5]), UNSPEC_VSIBADDR);
19156 (define_insn "*avx2_gathersi<mode>"
19157   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
19158         (unspec:VEC_GATHER_MODE
19159           [(match_operand:VEC_GATHER_MODE 2 "register_operand" "0")
19160            (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
19161              [(unspec:P
19162                 [(match_operand:P 3 "vsib_address_operand" "Tv")
19163                  (match_operand:<VEC_GATHER_IDXSI> 4 "register_operand" "x")
19164                  (match_operand:SI 6 "const1248_operand" "n")]
19165                 UNSPEC_VSIBADDR)])
19166            (mem:BLK (scratch))
19167            (match_operand:VEC_GATHER_MODE 5 "register_operand" "1")]
19168           UNSPEC_GATHER))
19169    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
19170   "TARGET_AVX2"
19171   "v<sseintprefix>gatherd<ssemodesuffix>\t{%1, %7, %0|%0, %7, %1}"
19172   [(set_attr "type" "ssemov")
19173    (set_attr "prefix" "vex")
19174    (set_attr "mode" "<sseinsnmode>")])
19176 (define_insn "*avx2_gathersi<mode>_2"
19177   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
19178         (unspec:VEC_GATHER_MODE
19179           [(pc)
19180            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19181              [(unspec:P
19182                 [(match_operand:P 2 "vsib_address_operand" "Tv")
19183                  (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand" "x")
19184                  (match_operand:SI 5 "const1248_operand" "n")]
19185                 UNSPEC_VSIBADDR)])
19186            (mem:BLK (scratch))
19187            (match_operand:VEC_GATHER_MODE 4 "register_operand" "1")]
19188           UNSPEC_GATHER))
19189    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
19190   "TARGET_AVX2"
19191   "v<sseintprefix>gatherd<ssemodesuffix>\t{%1, %6, %0|%0, %6, %1}"
19192   [(set_attr "type" "ssemov")
19193    (set_attr "prefix" "vex")
19194    (set_attr "mode" "<sseinsnmode>")])
19196 (define_expand "avx2_gatherdi<mode>"
19197   [(parallel [(set (match_operand:VEC_GATHER_MODE 0 "register_operand")
19198                    (unspec:VEC_GATHER_MODE
19199                      [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand")
19200                       (mem:<ssescalarmode>
19201                         (match_par_dup 6
19202                           [(match_operand 2 "vsib_address_operand")
19203                            (match_operand:<VEC_GATHER_IDXDI>
19204                               3 "register_operand")
19205                            (match_operand:SI 5 "const1248_operand ")]))
19206                       (mem:BLK (scratch))
19207                       (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand")]
19208                      UNSPEC_GATHER))
19209               (clobber (match_scratch:VEC_GATHER_MODE 7))])]
19210   "TARGET_AVX2"
19212   operands[6]
19213     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
19214                                         operands[5]), UNSPEC_VSIBADDR);
19217 (define_insn "*avx2_gatherdi<mode>"
19218   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
19219         (unspec:VEC_GATHER_MODE
19220           [(match_operand:<VEC_GATHER_SRCDI> 2 "register_operand" "0")
19221            (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
19222              [(unspec:P
19223                 [(match_operand:P 3 "vsib_address_operand" "Tv")
19224                  (match_operand:<VEC_GATHER_IDXDI> 4 "register_operand" "x")
19225                  (match_operand:SI 6 "const1248_operand" "n")]
19226                 UNSPEC_VSIBADDR)])
19227            (mem:BLK (scratch))
19228            (match_operand:<VEC_GATHER_SRCDI> 5 "register_operand" "1")]
19229           UNSPEC_GATHER))
19230    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
19231   "TARGET_AVX2"
19232   "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %7, %2|%2, %7, %5}"
19233   [(set_attr "type" "ssemov")
19234    (set_attr "prefix" "vex")
19235    (set_attr "mode" "<sseinsnmode>")])
19237 (define_insn "*avx2_gatherdi<mode>_2"
19238   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
19239         (unspec:VEC_GATHER_MODE
19240           [(pc)
19241            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19242              [(unspec:P
19243                 [(match_operand:P 2 "vsib_address_operand" "Tv")
19244                  (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "x")
19245                  (match_operand:SI 5 "const1248_operand" "n")]
19246                 UNSPEC_VSIBADDR)])
19247            (mem:BLK (scratch))
19248            (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand" "1")]
19249           UNSPEC_GATHER))
19250    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
19251   "TARGET_AVX2"
19253   if (<MODE>mode != <VEC_GATHER_SRCDI>mode)
19254     return "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %x0|%x0, %6, %4}";
19255   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %0|%0, %6, %4}";
19257   [(set_attr "type" "ssemov")
19258    (set_attr "prefix" "vex")
19259    (set_attr "mode" "<sseinsnmode>")])
19261 (define_insn "*avx2_gatherdi<mode>_3"
19262   [(set (match_operand:<VEC_GATHER_SRCDI> 0 "register_operand" "=&x")
19263         (vec_select:<VEC_GATHER_SRCDI>
19264           (unspec:VI4F_256
19265             [(match_operand:<VEC_GATHER_SRCDI> 2 "register_operand" "0")
19266              (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
19267                [(unspec:P
19268                   [(match_operand:P 3 "vsib_address_operand" "Tv")
19269                    (match_operand:<VEC_GATHER_IDXDI> 4 "register_operand" "x")
19270                    (match_operand:SI 6 "const1248_operand" "n")]
19271                   UNSPEC_VSIBADDR)])
19272              (mem:BLK (scratch))
19273              (match_operand:<VEC_GATHER_SRCDI> 5 "register_operand" "1")]
19274              UNSPEC_GATHER)
19275           (parallel [(const_int 0) (const_int 1)
19276                      (const_int 2) (const_int 3)])))
19277    (clobber (match_scratch:VI4F_256 1 "=&x"))]
19278   "TARGET_AVX2"
19279   "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %7, %0|%0, %7, %5}"
19280   [(set_attr "type" "ssemov")
19281    (set_attr "prefix" "vex")
19282    (set_attr "mode" "<sseinsnmode>")])
19284 (define_insn "*avx2_gatherdi<mode>_4"
19285   [(set (match_operand:<VEC_GATHER_SRCDI> 0 "register_operand" "=&x")
19286         (vec_select:<VEC_GATHER_SRCDI>
19287           (unspec:VI4F_256
19288             [(pc)
19289              (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19290                [(unspec:P
19291                   [(match_operand:P 2 "vsib_address_operand" "Tv")
19292                    (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "x")
19293                    (match_operand:SI 5 "const1248_operand" "n")]
19294                   UNSPEC_VSIBADDR)])
19295              (mem:BLK (scratch))
19296              (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand" "1")]
19297             UNSPEC_GATHER)
19298           (parallel [(const_int 0) (const_int 1)
19299                      (const_int 2) (const_int 3)])))
19300    (clobber (match_scratch:VI4F_256 1 "=&x"))]
19301   "TARGET_AVX2"
19302   "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %0|%0, %6, %4}"
19303   [(set_attr "type" "ssemov")
19304    (set_attr "prefix" "vex")
19305    (set_attr "mode" "<sseinsnmode>")])
19307 ;; Memory operand override for -masm=intel of the v*gatherq* patterns.
19308 (define_mode_attr gatherq_mode
19309   [(V4SI "q") (V2DI "x") (V4SF "q") (V2DF "x")
19310    (V8SI "x") (V4DI "t") (V8SF "x") (V4DF "t")
19311    (V16SI "t") (V8DI "g") (V16SF "t") (V8DF "g")])
19313 (define_expand "<avx512>_gathersi<mode>"
19314   [(parallel [(set (match_operand:VI48F 0 "register_operand")
19315                    (unspec:VI48F
19316                      [(match_operand:VI48F 1 "register_operand")
19317                       (match_operand:<avx512fmaskmode> 4 "register_operand")
19318                       (mem:<ssescalarmode>
19319                         (match_par_dup 6
19320                           [(match_operand 2 "vsib_address_operand")
19321                            (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand")
19322                            (match_operand:SI 5 "const1248_operand")]))]
19323                      UNSPEC_GATHER))
19324               (clobber (match_scratch:<avx512fmaskmode> 7))])]
19325   "TARGET_AVX512F"
19327   operands[6]
19328     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
19329                                         operands[5]), UNSPEC_VSIBADDR);
19332 (define_insn "*avx512f_gathersi<mode>"
19333   [(set (match_operand:VI48F 0 "register_operand" "=&v")
19334         (unspec:VI48F
19335           [(match_operand:VI48F 1 "register_operand" "0")
19336            (match_operand:<avx512fmaskmode> 7 "register_operand" "2")
19337            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19338              [(unspec:P
19339                 [(match_operand:P 4 "vsib_address_operand" "Tv")
19340                  (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand" "v")
19341                  (match_operand:SI 5 "const1248_operand" "n")]
19342                 UNSPEC_VSIBADDR)])]
19343           UNSPEC_GATHER))
19344    (clobber (match_scratch:<avx512fmaskmode> 2 "=&Yk"))]
19345   "TARGET_AVX512F"
19346   "v<sseintprefix>gatherd<ssemodesuffix>\t{%6, %0%{%2%}|%0%{%2%}, %<xtg_mode>6}"
19347   [(set_attr "type" "ssemov")
19348    (set_attr "prefix" "evex")
19349    (set_attr "mode" "<sseinsnmode>")])
19351 (define_insn "*avx512f_gathersi<mode>_2"
19352   [(set (match_operand:VI48F 0 "register_operand" "=&v")
19353         (unspec:VI48F
19354           [(pc)
19355            (match_operand:<avx512fmaskmode> 6 "register_operand" "1")
19356            (match_operator:<ssescalarmode> 5 "vsib_mem_operator"
19357              [(unspec:P
19358                 [(match_operand:P 3 "vsib_address_operand" "Tv")
19359                  (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand" "v")
19360                  (match_operand:SI 4 "const1248_operand" "n")]
19361                 UNSPEC_VSIBADDR)])]
19362           UNSPEC_GATHER))
19363    (clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
19364   "TARGET_AVX512F"
19365   "v<sseintprefix>gatherd<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %<xtg_mode>5}"
19366   [(set_attr "type" "ssemov")
19367    (set_attr "prefix" "evex")
19368    (set_attr "mode" "<sseinsnmode>")])
19371 (define_expand "<avx512>_gatherdi<mode>"
19372   [(parallel [(set (match_operand:VI48F 0 "register_operand")
19373                    (unspec:VI48F
19374                      [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand")
19375                       (match_operand:QI 4 "register_operand")
19376                       (mem:<ssescalarmode>
19377                         (match_par_dup 6
19378                           [(match_operand 2 "vsib_address_operand")
19379                            (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand")
19380                            (match_operand:SI 5 "const1248_operand")]))]
19381                      UNSPEC_GATHER))
19382               (clobber (match_scratch:QI 7))])]
19383   "TARGET_AVX512F"
19385   operands[6]
19386     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
19387                                         operands[5]), UNSPEC_VSIBADDR);
19390 (define_insn "*avx512f_gatherdi<mode>"
19391   [(set (match_operand:VI48F 0 "register_operand" "=&v")
19392         (unspec:VI48F
19393           [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand" "0")
19394            (match_operand:QI 7 "register_operand" "2")
19395            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
19396              [(unspec:P
19397                 [(match_operand:P 4 "vsib_address_operand" "Tv")
19398                  (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "v")
19399                  (match_operand:SI 5 "const1248_operand" "n")]
19400                 UNSPEC_VSIBADDR)])]
19401           UNSPEC_GATHER))
19402    (clobber (match_scratch:QI 2 "=&Yk"))]
19403   "TARGET_AVX512F"
19405   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%6, %1%{%2%}|%1%{%2%}, %<gatherq_mode>6}";
19407   [(set_attr "type" "ssemov")
19408    (set_attr "prefix" "evex")
19409    (set_attr "mode" "<sseinsnmode>")])
19411 (define_insn "*avx512f_gatherdi<mode>_2"
19412   [(set (match_operand:VI48F 0 "register_operand" "=&v")
19413         (unspec:VI48F
19414           [(pc)
19415            (match_operand:QI 6 "register_operand" "1")
19416            (match_operator:<ssescalarmode> 5 "vsib_mem_operator"
19417              [(unspec:P
19418                 [(match_operand:P 3 "vsib_address_operand" "Tv")
19419                  (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand" "v")
19420                  (match_operand:SI 4 "const1248_operand" "n")]
19421                 UNSPEC_VSIBADDR)])]
19422           UNSPEC_GATHER))
19423    (clobber (match_scratch:QI 1 "=&Yk"))]
19424   "TARGET_AVX512F"
19426   if (<MODE>mode != <VEC_GATHER_SRCDI>mode)
19427     {
19428       if (<MODE_SIZE> != 64)
19429         return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %x0%{%1%}|%x0%{%1%}, %<gatherq_mode>5}";
19430       else
19431         return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %t0%{%1%}|%t0%{%1%}, %t5}";
19432     }
19433   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %<gatherq_mode>5}";
19435   [(set_attr "type" "ssemov")
19436    (set_attr "prefix" "evex")
19437    (set_attr "mode" "<sseinsnmode>")])
19439 (define_expand "<avx512>_scattersi<mode>"
19440   [(parallel [(set (mem:VI48F
19441                      (match_par_dup 5
19442                        [(match_operand 0 "vsib_address_operand")
19443                         (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand")
19444                         (match_operand:SI 4 "const1248_operand")]))
19445                    (unspec:VI48F
19446                      [(match_operand:<avx512fmaskmode> 1 "register_operand")
19447                       (match_operand:VI48F 3 "register_operand")]
19448                      UNSPEC_SCATTER))
19449               (clobber (match_scratch:<avx512fmaskmode> 6))])]
19450   "TARGET_AVX512F"
19452   operands[5]
19453     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[0], operands[2],
19454                                         operands[4]), UNSPEC_VSIBADDR);
19457 (define_insn "*avx512f_scattersi<mode>"
19458   [(set (match_operator:VI48F 5 "vsib_mem_operator"
19459           [(unspec:P
19460              [(match_operand:P 0 "vsib_address_operand" "Tv")
19461               (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand" "v")
19462               (match_operand:SI 4 "const1248_operand" "n")]
19463              UNSPEC_VSIBADDR)])
19464         (unspec:VI48F
19465           [(match_operand:<avx512fmaskmode> 6 "register_operand" "1")
19466            (match_operand:VI48F 3 "register_operand" "v")]
19467           UNSPEC_SCATTER))
19468    (clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
19469   "TARGET_AVX512F"
19470   "v<sseintprefix>scatterd<ssemodesuffix>\t{%3, %5%{%1%}|%5%{%1%}, %3}"
19471   [(set_attr "type" "ssemov")
19472    (set_attr "prefix" "evex")
19473    (set_attr "mode" "<sseinsnmode>")])
19475 (define_expand "<avx512>_scatterdi<mode>"
19476   [(parallel [(set (mem:VI48F
19477                      (match_par_dup 5
19478                        [(match_operand 0 "vsib_address_operand")
19479                         (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand")
19480                         (match_operand:SI 4 "const1248_operand")]))
19481                    (unspec:VI48F
19482                      [(match_operand:QI 1 "register_operand")
19483                       (match_operand:<VEC_GATHER_SRCDI> 3 "register_operand")]
19484                      UNSPEC_SCATTER))
19485               (clobber (match_scratch:QI 6))])]
19486   "TARGET_AVX512F"
19488   operands[5]
19489     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[0], operands[2],
19490                                         operands[4]), UNSPEC_VSIBADDR);
19493 (define_insn "*avx512f_scatterdi<mode>"
19494   [(set (match_operator:VI48F 5 "vsib_mem_operator"
19495           [(unspec:P
19496              [(match_operand:P 0 "vsib_address_operand" "Tv")
19497               (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand" "v")
19498               (match_operand:SI 4 "const1248_operand" "n")]
19499              UNSPEC_VSIBADDR)])
19500         (unspec:VI48F
19501           [(match_operand:QI 6 "register_operand" "1")
19502            (match_operand:<VEC_GATHER_SRCDI> 3 "register_operand" "v")]
19503           UNSPEC_SCATTER))
19504    (clobber (match_scratch:QI 1 "=&Yk"))]
19505   "TARGET_AVX512F"
19507   if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 8)
19508     return "v<sseintprefix>scatterq<ssemodesuffix>\t{%3, %5%{%1%}|%5%{%1%}, %3}";
19509   return "v<sseintprefix>scatterq<ssemodesuffix>\t{%3, %5%{%1%}|%t5%{%1%}, %3}";
19511   [(set_attr "type" "ssemov")
19512    (set_attr "prefix" "evex")
19513    (set_attr "mode" "<sseinsnmode>")])
19515 (define_insn "<avx512>_compress<mode>_mask"
19516   [(set (match_operand:VI48F 0 "register_operand" "=v")
19517         (unspec:VI48F
19518           [(match_operand:VI48F 1 "register_operand" "v")
19519            (match_operand:VI48F 2 "vector_move_operand" "0C")
19520            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")]
19521           UNSPEC_COMPRESS))]
19522   "TARGET_AVX512F"
19523   "v<sseintprefix>compress<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19524   [(set_attr "type" "ssemov")
19525    (set_attr "prefix" "evex")
19526    (set_attr "mode" "<sseinsnmode>")])
19528 (define_insn "compress<mode>_mask"
19529   [(set (match_operand:VI12_AVX512VLBW 0 "register_operand" "=v")
19530         (unspec:VI12_AVX512VLBW
19531           [(match_operand:VI12_AVX512VLBW 1 "register_operand" "v")
19532            (match_operand:VI12_AVX512VLBW 2 "vector_move_operand" "0C")
19533            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")]
19534           UNSPEC_COMPRESS))]
19535   "TARGET_AVX512VBMI2"
19536   "vpcompress<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19537   [(set_attr "type" "ssemov")
19538    (set_attr "prefix" "evex")
19539    (set_attr "mode" "<sseinsnmode>")])
19541 (define_insn "<avx512>_compressstore<mode>_mask"
19542   [(set (match_operand:VI48F 0 "memory_operand" "=m")
19543         (unspec:VI48F
19544           [(match_operand:VI48F 1 "register_operand" "x")
19545            (match_dup 0)
19546            (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")]
19547           UNSPEC_COMPRESS_STORE))]
19548   "TARGET_AVX512F"
19549   "v<sseintprefix>compress<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
19550   [(set_attr "type" "ssemov")
19551    (set_attr "prefix" "evex")
19552    (set_attr "memory" "store")
19553    (set_attr "mode" "<sseinsnmode>")])
19555 (define_insn "compressstore<mode>_mask"
19556   [(set (match_operand:VI12_AVX512VLBW 0 "memory_operand" "=m")
19557         (unspec:VI12_AVX512VLBW
19558           [(match_operand:VI12_AVX512VLBW 1 "register_operand" "x")
19559            (match_dup 0)
19560            (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")]
19561           UNSPEC_COMPRESS_STORE))]
19562   "TARGET_AVX512VBMI2"
19563   "vpcompress<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
19564   [(set_attr "type" "ssemov")
19565    (set_attr "prefix" "evex")
19566    (set_attr "memory" "store")
19567    (set_attr "mode" "<sseinsnmode>")])
19569 (define_expand "<avx512>_expand<mode>_maskz"
19570   [(set (match_operand:VI48F 0 "register_operand")
19571         (unspec:VI48F
19572           [(match_operand:VI48F 1 "nonimmediate_operand")
19573            (match_operand:VI48F 2 "vector_move_operand")
19574            (match_operand:<avx512fmaskmode> 3 "register_operand")]
19575           UNSPEC_EXPAND))]
19576   "TARGET_AVX512F"
19577   "operands[2] = CONST0_RTX (<MODE>mode);")
19579 (define_insn "<avx512>_expand<mode>_mask"
19580   [(set (match_operand:VI48F 0 "register_operand" "=v,v")
19581         (unspec:VI48F
19582           [(match_operand:VI48F 1 "nonimmediate_operand" "v,m")
19583            (match_operand:VI48F 2 "vector_move_operand" "0C,0C")
19584            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")]
19585           UNSPEC_EXPAND))]
19586   "TARGET_AVX512F"
19587   "v<sseintprefix>expand<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19588   [(set_attr "type" "ssemov")
19589    (set_attr "prefix" "evex")
19590    (set_attr "memory" "none,load")
19591    (set_attr "mode" "<sseinsnmode>")])
19593 (define_insn "expand<mode>_mask"
19594   [(set (match_operand:VI12_AVX512VLBW 0 "register_operand" "=v,v")
19595         (unspec:VI12_AVX512VLBW
19596           [(match_operand:VI12_AVX512VLBW 1 "nonimmediate_operand" "v,m")
19597            (match_operand:VI12_AVX512VLBW 2 "vector_move_operand" "0C,0C")
19598            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")]
19599           UNSPEC_EXPAND))]
19600   "TARGET_AVX512VBMI2"
19601   "v<sseintprefix>expand<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19602   [(set_attr "type" "ssemov")
19603    (set_attr "prefix" "evex")
19604    (set_attr "memory" "none,load")
19605    (set_attr "mode" "<sseinsnmode>")])
19607 (define_expand "expand<mode>_maskz"
19608   [(set (match_operand:VI12_AVX512VLBW 0 "register_operand")
19609         (unspec:VI12_AVX512VLBW
19610           [(match_operand:VI12_AVX512VLBW 1 "nonimmediate_operand")
19611            (match_operand:VI12_AVX512VLBW 2 "vector_move_operand")
19612            (match_operand:<avx512fmaskmode> 3 "register_operand")]
19613           UNSPEC_EXPAND))]
19614   "TARGET_AVX512VBMI2"
19615   "operands[2] = CONST0_RTX (<MODE>mode);")
19617 (define_insn "avx512dq_rangep<mode><mask_name><round_saeonly_name>"
19618   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
19619         (unspec:VF_AVX512VL
19620           [(match_operand:VF_AVX512VL 1 "register_operand" "v")
19621            (match_operand:VF_AVX512VL 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
19622            (match_operand:SI 3 "const_0_to_15_operand")]
19623           UNSPEC_RANGE))]
19624   "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
19625   "vrange<ssemodesuffix>\t{%3, <round_saeonly_mask_op4>%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2<round_saeonly_mask_op4>, %3}"
19626   [(set_attr "type" "sse")
19627    (set_attr "prefix" "evex")
19628    (set_attr "mode" "<MODE>")])
19630 (define_insn "avx512dq_ranges<mode><mask_scalar_name><round_saeonly_scalar_name>"
19631   [(set (match_operand:VF_128 0 "register_operand" "=v")
19632         (vec_merge:VF_128
19633           (unspec:VF_128
19634             [(match_operand:VF_128 1 "register_operand" "v")
19635              (match_operand:VF_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")
19636              (match_operand:SI 3 "const_0_to_15_operand")]
19637             UNSPEC_RANGE)
19638           (match_dup 1)
19639           (const_int 1)))]
19640   "TARGET_AVX512DQ"
19641   "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}"
19642   [(set_attr "type" "sse")
19643    (set_attr "prefix" "evex")
19644    (set_attr "mode" "<MODE>")])
19646 (define_insn "avx512dq_fpclass<mode><mask_scalar_merge_name>"
19647   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
19648           (unspec:<avx512fmaskmode>
19649             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
19650              (match_operand:QI 2 "const_0_to_255_operand" "n")]
19651              UNSPEC_FPCLASS))]
19652    "TARGET_AVX512DQ"
19653    "vfpclass<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}";
19654   [(set_attr "type" "sse")
19655    (set_attr "length_immediate" "1")
19656    (set_attr "prefix" "evex")
19657    (set_attr "mode" "<MODE>")])
19659 (define_insn "avx512dq_vmfpclass<mode>"
19660   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
19661         (and:<avx512fmaskmode>
19662           (unspec:<avx512fmaskmode>
19663             [(match_operand:VF_128 1 "register_operand" "v")
19664              (match_operand:QI 2 "const_0_to_255_operand" "n")]
19665             UNSPEC_FPCLASS)
19666           (const_int 1)))]
19667    "TARGET_AVX512DQ"
19668    "vfpclass<ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
19669   [(set_attr "type" "sse")
19670    (set_attr "length_immediate" "1")
19671    (set_attr "prefix" "evex")
19672    (set_attr "mode" "<MODE>")])
19674 (define_insn "<avx512>_getmant<mode><mask_name><round_saeonly_name>"
19675   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
19676         (unspec:VF_AVX512VL
19677           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "<round_saeonly_constraint>")
19678            (match_operand:SI 2 "const_0_to_15_operand")]
19679           UNSPEC_GETMANT))]
19680   "TARGET_AVX512F"
19681   "vgetmant<ssemodesuffix>\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}";
19682   [(set_attr "prefix" "evex")
19683    (set_attr "mode" "<MODE>")])
19685 (define_insn "avx512f_vgetmant<mode><mask_scalar_name><round_saeonly_scalar_name>"
19686   [(set (match_operand:VF_128 0 "register_operand" "=v")
19687         (vec_merge:VF_128
19688           (unspec:VF_128
19689             [(match_operand:VF_128 1 "register_operand" "v")
19690              (match_operand:VF_128 2 "<round_saeonly_scalar_nimm_predicate>" "<round_saeonly_scalar_constraint>")
19691              (match_operand:SI 3 "const_0_to_15_operand")]
19692             UNSPEC_GETMANT)
19693           (match_dup 1)
19694           (const_int 1)))]
19695    "TARGET_AVX512F"
19696    "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}";
19697    [(set_attr "prefix" "evex")
19698    (set_attr "mode" "<ssescalarmode>")])
19700 ;; The correct representation for this is absolutely enormous, and
19701 ;; surely not generally useful.
19702 (define_insn "<mask_codefor>avx512bw_dbpsadbw<mode><mask_name>"
19703   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
19704         (unspec:VI2_AVX512VL
19705           [(match_operand:<dbpsadbwmode> 1 "register_operand" "v")
19706            (match_operand:<dbpsadbwmode> 2 "nonimmediate_operand" "vm")
19707            (match_operand:SI 3 "const_0_to_255_operand")]
19708           UNSPEC_DBPSADBW))]
19709    "TARGET_AVX512BW"
19710   "vdbpsadbw\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}"
19711   [(set_attr "type" "sselog1")
19712    (set_attr "length_immediate" "1")
19713    (set_attr "prefix" "evex")
19714    (set_attr "mode" "<sseinsnmode>")])
19716 (define_insn "clz<mode>2<mask_name>"
19717   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
19718         (clz:VI48_AVX512VL
19719           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")))]
19720   "TARGET_AVX512CD"
19721   "vplzcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19722   [(set_attr "type" "sse")
19723    (set_attr "prefix" "evex")
19724    (set_attr "mode" "<sseinsnmode>")])
19726 (define_insn "<mask_codefor>conflict<mode><mask_name>"
19727   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
19728         (unspec:VI48_AVX512VL
19729           [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")]
19730           UNSPEC_CONFLICT))]
19731   "TARGET_AVX512CD"
19732   "vpconflict<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19733   [(set_attr "type" "sse")
19734    (set_attr "prefix" "evex")
19735    (set_attr "mode" "<sseinsnmode>")])
19737 (define_insn "sha1msg1"
19738   [(set (match_operand:V4SI 0 "register_operand" "=x")
19739         (unspec:V4SI
19740           [(match_operand:V4SI 1 "register_operand" "0")
19741            (match_operand:V4SI 2 "vector_operand" "xBm")]
19742           UNSPEC_SHA1MSG1))]
19743   "TARGET_SHA"
19744   "sha1msg1\t{%2, %0|%0, %2}"
19745   [(set_attr "type" "sselog1")
19746    (set_attr "mode" "TI")])
19748 (define_insn "sha1msg2"
19749   [(set (match_operand:V4SI 0 "register_operand" "=x")
19750         (unspec:V4SI
19751           [(match_operand:V4SI 1 "register_operand" "0")
19752            (match_operand:V4SI 2 "vector_operand" "xBm")]
19753           UNSPEC_SHA1MSG2))]
19754   "TARGET_SHA"
19755   "sha1msg2\t{%2, %0|%0, %2}"
19756   [(set_attr "type" "sselog1")
19757    (set_attr "mode" "TI")])
19759 (define_insn "sha1nexte"
19760   [(set (match_operand:V4SI 0 "register_operand" "=x")
19761         (unspec:V4SI
19762           [(match_operand:V4SI 1 "register_operand" "0")
19763            (match_operand:V4SI 2 "vector_operand" "xBm")]
19764           UNSPEC_SHA1NEXTE))]
19765   "TARGET_SHA"
19766   "sha1nexte\t{%2, %0|%0, %2}"
19767   [(set_attr "type" "sselog1")
19768    (set_attr "mode" "TI")])
19770 (define_insn "sha1rnds4"
19771   [(set (match_operand:V4SI 0 "register_operand" "=x")
19772         (unspec:V4SI
19773           [(match_operand:V4SI 1 "register_operand" "0")
19774            (match_operand:V4SI 2 "vector_operand" "xBm")
19775            (match_operand:SI 3 "const_0_to_3_operand" "n")]
19776           UNSPEC_SHA1RNDS4))]
19777   "TARGET_SHA"
19778   "sha1rnds4\t{%3, %2, %0|%0, %2, %3}"
19779   [(set_attr "type" "sselog1")
19780    (set_attr "length_immediate" "1")
19781    (set_attr "mode" "TI")])
19783 (define_insn "sha256msg1"
19784   [(set (match_operand:V4SI 0 "register_operand" "=x")
19785         (unspec:V4SI
19786           [(match_operand:V4SI 1 "register_operand" "0")
19787            (match_operand:V4SI 2 "vector_operand" "xBm")]
19788           UNSPEC_SHA256MSG1))]
19789   "TARGET_SHA"
19790   "sha256msg1\t{%2, %0|%0, %2}"
19791   [(set_attr "type" "sselog1")
19792    (set_attr "mode" "TI")])
19794 (define_insn "sha256msg2"
19795   [(set (match_operand:V4SI 0 "register_operand" "=x")
19796         (unspec:V4SI
19797           [(match_operand:V4SI 1 "register_operand" "0")
19798            (match_operand:V4SI 2 "vector_operand" "xBm")]
19799           UNSPEC_SHA256MSG2))]
19800   "TARGET_SHA"
19801   "sha256msg2\t{%2, %0|%0, %2}"
19802   [(set_attr "type" "sselog1")
19803    (set_attr "mode" "TI")])
19805 (define_insn "sha256rnds2"
19806   [(set (match_operand:V4SI 0 "register_operand" "=x")
19807         (unspec:V4SI
19808           [(match_operand:V4SI 1 "register_operand" "0")
19809            (match_operand:V4SI 2 "vector_operand" "xBm")
19810            (match_operand:V4SI 3 "register_operand" "Yz")]
19811           UNSPEC_SHA256RNDS2))]
19812   "TARGET_SHA"
19813   "sha256rnds2\t{%3, %2, %0|%0, %2, %3}"
19814   [(set_attr "type" "sselog1")
19815    (set_attr "length_immediate" "1")
19816    (set_attr "mode" "TI")])
19818 (define_insn_and_split "avx512f_<castmode><avxsizesuffix>_<castmode>"
19819   [(set (match_operand:AVX512MODE2P 0 "nonimmediate_operand" "=x,m")
19820         (unspec:AVX512MODE2P
19821           [(match_operand:<ssequartermode> 1 "nonimmediate_operand" "xm,x")]
19822           UNSPEC_CAST))]
19823   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
19824   "#"
19825   "&& reload_completed"
19826   [(set (match_dup 0) (match_dup 1))]
19828   if (REG_P (operands[0]))
19829     operands[0] = gen_lowpart (<ssequartermode>mode, operands[0]);
19830   else
19831     operands[1] = lowpart_subreg (<MODE>mode, operands[1],
19832                                   <ssequartermode>mode);
19835 (define_insn_and_split "avx512f_<castmode><avxsizesuffix>_256<castmode>"
19836   [(set (match_operand:AVX512MODE2P 0 "nonimmediate_operand" "=x,m")
19837         (unspec:AVX512MODE2P
19838           [(match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "xm,x")]
19839           UNSPEC_CAST))]
19840   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
19841   "#"
19842   "&& reload_completed"
19843   [(set (match_dup 0) (match_dup 1))]
19845   if (REG_P (operands[0]))
19846     operands[0] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);
19847   else
19848     operands[1] = lowpart_subreg (<MODE>mode, operands[1],
19849                                   <ssehalfvecmode>mode);
19852 (define_int_iterator VPMADD52
19853         [UNSPEC_VPMADD52LUQ
19854          UNSPEC_VPMADD52HUQ])
19856 (define_int_attr vpmadd52type
19857   [(UNSPEC_VPMADD52LUQ "luq") (UNSPEC_VPMADD52HUQ "huq")])
19859 (define_expand "vpamdd52huq<mode>_maskz"
19860   [(match_operand:VI8_AVX512VL 0 "register_operand")
19861    (match_operand:VI8_AVX512VL 1 "register_operand")
19862    (match_operand:VI8_AVX512VL 2 "register_operand")
19863    (match_operand:VI8_AVX512VL 3 "nonimmediate_operand")
19864    (match_operand:<avx512fmaskmode> 4 "register_operand")]
19865   "TARGET_AVX512IFMA"
19867   emit_insn (gen_vpamdd52huq<mode>_maskz_1 (
19868     operands[0], operands[1], operands[2], operands[3],
19869     CONST0_RTX (<MODE>mode), operands[4]));
19870   DONE;
19873 (define_expand "vpamdd52luq<mode>_maskz"
19874   [(match_operand:VI8_AVX512VL 0 "register_operand")
19875    (match_operand:VI8_AVX512VL 1 "register_operand")
19876    (match_operand:VI8_AVX512VL 2 "register_operand")
19877    (match_operand:VI8_AVX512VL 3 "nonimmediate_operand")
19878    (match_operand:<avx512fmaskmode> 4 "register_operand")]
19879   "TARGET_AVX512IFMA"
19881   emit_insn (gen_vpamdd52luq<mode>_maskz_1 (
19882     operands[0], operands[1], operands[2], operands[3],
19883     CONST0_RTX (<MODE>mode), operands[4]));
19884   DONE;
19887 (define_insn "vpamdd52<vpmadd52type><mode><sd_maskz_name>"
19888   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
19889         (unspec:VI8_AVX512VL
19890           [(match_operand:VI8_AVX512VL 1 "register_operand" "0")
19891            (match_operand:VI8_AVX512VL 2 "register_operand" "v")
19892            (match_operand:VI8_AVX512VL 3 "nonimmediate_operand" "vm")]
19893           VPMADD52))]
19894   "TARGET_AVX512IFMA"
19895   "vpmadd52<vpmadd52type>\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}"
19896   [(set_attr "type" "ssemuladd")
19897    (set_attr "prefix" "evex")
19898    (set_attr "mode" "<sseinsnmode>")])
19900 (define_insn "vpamdd52<vpmadd52type><mode>_mask"
19901   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
19902         (vec_merge:VI8_AVX512VL
19903           (unspec:VI8_AVX512VL
19904             [(match_operand:VI8_AVX512VL 1 "register_operand" "0")
19905              (match_operand:VI8_AVX512VL 2 "register_operand" "v")
19906              (match_operand:VI8_AVX512VL 3 "nonimmediate_operand" "vm")]
19907             VPMADD52)
19908           (match_dup 1)
19909           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
19910   "TARGET_AVX512IFMA"
19911   "vpmadd52<vpmadd52type>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
19912   [(set_attr "type" "ssemuladd")
19913    (set_attr "prefix" "evex")
19914    (set_attr "mode" "<sseinsnmode>")])
19916 (define_insn "vpmultishiftqb<mode><mask_name>"
19917   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
19918         (unspec:VI1_AVX512VL
19919           [(match_operand:VI1_AVX512VL 1 "register_operand" "v")
19920            (match_operand:VI1_AVX512VL 2 "nonimmediate_operand" "vm")]
19921           UNSPEC_VPMULTISHIFT))]
19922   "TARGET_AVX512VBMI"
19923   "vpmultishiftqb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19924   [(set_attr "type" "sselog")
19925    (set_attr "prefix" "evex")
19926    (set_attr "mode" "<sseinsnmode>")])
19928 (define_mode_iterator IMOD4
19929   [(V64SF "TARGET_AVX5124FMAPS") (V64SI "TARGET_AVX5124VNNIW")])
19931 (define_mode_attr imod4_narrow
19932   [(V64SF "V16SF") (V64SI "V16SI")])
19934 (define_expand "mov<mode>"
19935   [(set (match_operand:IMOD4 0 "nonimmediate_operand")
19936         (match_operand:IMOD4 1 "vector_move_operand"))]
19937   "TARGET_AVX512F"
19939   ix86_expand_vector_move (<MODE>mode, operands);
19940   DONE;
19943 (define_insn_and_split "*mov<mode>_internal"
19944   [(set (match_operand:IMOD4 0 "nonimmediate_operand" "=v,v ,m")
19945         (match_operand:IMOD4 1 "vector_move_operand"  " C,vm,v"))]
19946   "TARGET_AVX512F
19947    && (register_operand (operands[0], <MODE>mode)
19948        || register_operand (operands[1], <MODE>mode))"
19949   "#"
19950   "&& reload_completed"
19951   [(const_int 0)]
19953   rtx op0, op1;
19954   int i;
19956   for (i = 0; i < 4; i++)
19957     {
19958       op0 = simplify_subreg
19959              (<imod4_narrow>mode, operands[0], <MODE>mode, i * 64);
19960       op1 = simplify_subreg
19961              (<imod4_narrow>mode, operands[1], <MODE>mode, i * 64);
19962       emit_move_insn (op0, op1);
19963     }
19964   DONE;
19967 (define_insn "avx5124fmaddps_4fmaddps"
19968   [(set (match_operand:V16SF 0 "register_operand" "=v")
19969         (unspec:V16SF
19970           [(match_operand:V16SF 1 "register_operand" "0")
19971            (match_operand:V64SF 2 "register_operand" "Yh")
19972            (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FMADD))]
19973   "TARGET_AVX5124FMAPS"
19974   "v4fmaddps\t{%3, %g2, %0|%0, %g2, %3}"
19975    [(set_attr ("type") ("ssemuladd"))
19976     (set_attr ("prefix") ("evex"))
19977     (set_attr ("mode") ("V16SF"))])
19979 (define_insn "avx5124fmaddps_4fmaddps_mask"
19980   [(set (match_operand:V16SF 0 "register_operand" "=v")
19981         (vec_merge:V16SF
19982           (unspec:V16SF
19983              [(match_operand:V64SF 1 "register_operand" "Yh")
19984               (match_operand:V4SF 2 "memory_operand" "m")] UNSPEC_VP4FMADD)
19985           (match_operand:V16SF 3 "register_operand" "0")
19986           (match_operand:HI 4 "register_operand" "Yk")))]
19987   "TARGET_AVX5124FMAPS"
19988   "v4fmaddps\t{%2, %g1, %0%{%4%}|%0%{%4%}, %g1, %2}"
19989    [(set_attr ("type") ("ssemuladd"))
19990     (set_attr ("prefix") ("evex"))
19991     (set_attr ("mode") ("V16SF"))])
19993 (define_insn "avx5124fmaddps_4fmaddps_maskz"
19994   [(set (match_operand:V16SF 0 "register_operand" "=v")
19995         (vec_merge:V16SF
19996           (unspec:V16SF
19997             [(match_operand:V16SF 1 "register_operand" "0")
19998              (match_operand:V64SF 2 "register_operand" "Yh")
19999              (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FMADD)
20000           (match_operand:V16SF 4 "const0_operand" "C")
20001           (match_operand:HI 5 "register_operand" "Yk")))]
20002   "TARGET_AVX5124FMAPS"
20003   "v4fmaddps\t{%3, %g2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %g2, %3}"
20004    [(set_attr ("type") ("ssemuladd"))
20005     (set_attr ("prefix") ("evex"))
20006     (set_attr ("mode") ("V16SF"))])
20008 (define_insn "avx5124fmaddps_4fmaddss"
20009   [(set (match_operand:V4SF 0 "register_operand" "=v")
20010         (unspec:V4SF
20011           [(match_operand:V4SF 1 "register_operand" "0")
20012            (match_operand:V64SF 2 "register_operand" "Yh")
20013            (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FMADD))]
20014   "TARGET_AVX5124FMAPS"
20015   "v4fmaddss\t{%3, %x2, %0|%0, %x2, %3}"
20016    [(set_attr ("type") ("ssemuladd"))
20017     (set_attr ("prefix") ("evex"))
20018     (set_attr ("mode") ("SF"))])
20020 (define_insn "avx5124fmaddps_4fmaddss_mask"
20021   [(set (match_operand:V4SF 0 "register_operand" "=v")
20022         (vec_merge:V4SF
20023           (unspec:V4SF
20024             [(match_operand:V64SF 1 "register_operand" "Yh")
20025              (match_operand:V4SF 2 "memory_operand" "m")] UNSPEC_VP4FMADD)
20026           (match_operand:V4SF 3 "register_operand" "0")
20027           (match_operand:QI 4 "register_operand" "Yk")))]
20028   "TARGET_AVX5124FMAPS"
20029   "v4fmaddss\t{%2, %x1, %0%{%4%}|%0%{%4%}, %x1, %2}"
20030    [(set_attr ("type") ("ssemuladd"))
20031     (set_attr ("prefix") ("evex"))
20032     (set_attr ("mode") ("SF"))])
20034 (define_insn "avx5124fmaddps_4fmaddss_maskz"
20035   [(set (match_operand:V4SF 0 "register_operand" "=v")
20036         (vec_merge:V4SF
20037           (unspec:V4SF
20038             [(match_operand:V4SF 1 "register_operand" "0")
20039              (match_operand:V64SF 2 "register_operand" "Yh")
20040              (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FMADD)
20041           (match_operand:V4SF 4 "const0_operand" "C")
20042           (match_operand:QI 5 "register_operand" "Yk")))]
20043   "TARGET_AVX5124FMAPS"
20044   "v4fmaddss\t{%3, %x2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %x2, %3}"
20045    [(set_attr ("type") ("ssemuladd"))
20046     (set_attr ("prefix") ("evex"))
20047     (set_attr ("mode") ("SF"))])
20049 (define_insn "avx5124fmaddps_4fnmaddps"
20050   [(set (match_operand:V16SF 0 "register_operand" "=v")
20051         (unspec:V16SF
20052           [(match_operand:V16SF 1 "register_operand" "0")
20053            (match_operand:V64SF 2 "register_operand" "Yh")
20054            (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FNMADD))]
20055   "TARGET_AVX5124FMAPS"
20056   "v4fnmaddps\t{%3, %g2, %0|%0, %g2, %3}"
20057    [(set_attr ("type") ("ssemuladd"))
20058     (set_attr ("prefix") ("evex"))
20059     (set_attr ("mode") ("V16SF"))])
20061 (define_insn "avx5124fmaddps_4fnmaddps_mask"
20062   [(set (match_operand:V16SF 0 "register_operand" "=v")
20063         (vec_merge:V16SF
20064           (unspec:V16SF
20065              [(match_operand:V64SF 1 "register_operand" "Yh")
20066               (match_operand:V4SF 2 "memory_operand" "m")] UNSPEC_VP4FNMADD)
20067           (match_operand:V16SF 3 "register_operand" "0")
20068           (match_operand:HI 4 "register_operand" "Yk")))]
20069   "TARGET_AVX5124FMAPS"
20070   "v4fnmaddps\t{%2, %g1, %0%{%4%}|%0%{%4%}, %g1, %2}"
20071    [(set_attr ("type") ("ssemuladd"))
20072     (set_attr ("prefix") ("evex"))
20073     (set_attr ("mode") ("V16SF"))])
20075 (define_insn "avx5124fmaddps_4fnmaddps_maskz"
20076   [(set (match_operand:V16SF 0 "register_operand" "=v")
20077         (vec_merge:V16SF
20078           (unspec:V16SF
20079             [(match_operand:V16SF 1 "register_operand" "0")
20080              (match_operand:V64SF 2 "register_operand" "Yh")
20081              (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FNMADD)
20082           (match_operand:V16SF 4 "const0_operand" "C")
20083           (match_operand:HI 5 "register_operand" "Yk")))]
20084   "TARGET_AVX5124FMAPS"
20085   "v4fnmaddps\t{%3, %g2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %g2, %3}"
20086    [(set_attr ("type") ("ssemuladd"))
20087     (set_attr ("prefix") ("evex"))
20088     (set_attr ("mode") ("V16SF"))])
20090 (define_insn "avx5124fmaddps_4fnmaddss"
20091   [(set (match_operand:V4SF 0 "register_operand" "=v")
20092         (unspec:V4SF
20093           [(match_operand:V4SF 1 "register_operand" "0")
20094            (match_operand:V64SF 2 "register_operand" "Yh")
20095            (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FNMADD))]
20096   "TARGET_AVX5124FMAPS"
20097   "v4fnmaddss\t{%3, %x2, %0|%0, %x2, %3}"
20098    [(set_attr ("type") ("ssemuladd"))
20099     (set_attr ("prefix") ("evex"))
20100     (set_attr ("mode") ("SF"))])
20102 (define_insn "avx5124fmaddps_4fnmaddss_mask"
20103   [(set (match_operand:V4SF 0 "register_operand" "=v")
20104         (vec_merge:V4SF
20105           (unspec:V4SF
20106             [(match_operand:V64SF 1 "register_operand" "Yh")
20107              (match_operand:V4SF 2 "memory_operand" "m")] UNSPEC_VP4FNMADD)
20108           (match_operand:V4SF 3 "register_operand" "0")
20109           (match_operand:QI 4 "register_operand" "Yk")))]
20110   "TARGET_AVX5124FMAPS"
20111   "v4fnmaddss\t{%2, %x1, %0%{%4%}|%0%{%4%}, %x1, %2}"
20112    [(set_attr ("type") ("ssemuladd"))
20113     (set_attr ("prefix") ("evex"))
20114     (set_attr ("mode") ("SF"))])
20116 (define_insn "avx5124fmaddps_4fnmaddss_maskz"
20117   [(set (match_operand:V4SF 0 "register_operand" "=v")
20118         (vec_merge:V4SF
20119           (unspec:V4SF
20120             [(match_operand:V4SF 1 "register_operand" "0")
20121              (match_operand:V64SF 2 "register_operand" "Yh")
20122              (match_operand:V4SF 3 "memory_operand" "m")] UNSPEC_VP4FNMADD)
20123           (match_operand:V4SF 4 "const0_operand" "C")
20124           (match_operand:QI 5 "register_operand" "Yk")))]
20125   "TARGET_AVX5124FMAPS"
20126   "v4fnmaddss\t{%3, %x2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %x2, %3}"
20127    [(set_attr ("type") ("ssemuladd"))
20128     (set_attr ("prefix") ("evex"))
20129     (set_attr ("mode") ("SF"))])
20131 (define_insn "avx5124vnniw_vp4dpwssd"
20132   [(set (match_operand:V16SI 0 "register_operand" "=v")
20133         (unspec:V16SI
20134           [(match_operand:V16SI 1 "register_operand" "0")
20135            (match_operand:V64SI 2 "register_operand" "Yh")
20136            (match_operand:V4SI 3 "memory_operand" "m")] UNSPEC_VP4DPWSSD))]
20137   "TARGET_AVX5124VNNIW"
20138   "vp4dpwssd\t{%3, %g2, %0|%0, %g2, %3}"
20139    [(set_attr ("type") ("ssemuladd"))
20140     (set_attr ("prefix") ("evex"))
20141     (set_attr ("mode") ("TI"))])
20143 (define_insn "avx5124vnniw_vp4dpwssd_mask"
20144   [(set (match_operand:V16SI 0 "register_operand" "=v")
20145         (vec_merge:V16SI
20146           (unspec:V16SI
20147              [(match_operand:V64SI 1 "register_operand" "Yh")
20148               (match_operand:V4SI 2 "memory_operand" "m")] UNSPEC_VP4DPWSSD)
20149           (match_operand:V16SI 3 "register_operand" "0")
20150           (match_operand:HI 4 "register_operand" "Yk")))]
20151   "TARGET_AVX5124VNNIW"
20152   "vp4dpwssd\t{%2, %g1, %0%{%4%}|%0%{%4%}, %g1, %2}"
20153    [(set_attr ("type") ("ssemuladd"))
20154     (set_attr ("prefix") ("evex"))
20155     (set_attr ("mode") ("TI"))])
20157 (define_insn "avx5124vnniw_vp4dpwssd_maskz"
20158   [(set (match_operand:V16SI 0 "register_operand" "=v")
20159         (vec_merge:V16SI
20160           (unspec:V16SI
20161             [(match_operand:V16SI 1 "register_operand" "0")
20162              (match_operand:V64SI 2 "register_operand" "Yh")
20163              (match_operand:V4SI 3 "memory_operand" "m")] UNSPEC_VP4DPWSSD)
20164           (match_operand:V16SI 4 "const0_operand" "C")
20165           (match_operand:HI 5 "register_operand" "Yk")))]
20166   "TARGET_AVX5124VNNIW"
20167   "vp4dpwssd\t{%3, %g2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %g2, %3}"
20168    [(set_attr ("type") ("ssemuladd"))
20169     (set_attr ("prefix") ("evex"))
20170     (set_attr ("mode") ("TI"))])
20172 (define_insn "avx5124vnniw_vp4dpwssds"
20173   [(set (match_operand:V16SI 0 "register_operand" "=v")
20174         (unspec:V16SI
20175           [(match_operand:V16SI 1 "register_operand" "0")
20176            (match_operand:V64SI 2 "register_operand" "Yh")
20177            (match_operand:V4SI 3 "memory_operand" "m")] UNSPEC_VP4DPWSSDS))]
20178   "TARGET_AVX5124VNNIW"
20179   "vp4dpwssds\t{%3, %g2, %0|%0, %g2, %3}"
20180    [(set_attr ("type") ("ssemuladd"))
20181     (set_attr ("prefix") ("evex"))
20182     (set_attr ("mode") ("TI"))])
20184 (define_insn "avx5124vnniw_vp4dpwssds_mask"
20185   [(set (match_operand:V16SI 0 "register_operand" "=v")
20186         (vec_merge:V16SI
20187           (unspec:V16SI
20188              [(match_operand:V64SI 1 "register_operand" "Yh")
20189               (match_operand:V4SI 2 "memory_operand" "m")] UNSPEC_VP4DPWSSDS)
20190           (match_operand:V16SI 3 "register_operand" "0")
20191           (match_operand:HI 4 "register_operand" "Yk")))]
20192   "TARGET_AVX5124VNNIW"
20193   "vp4dpwssds\t{%2, %g1, %0%{%4%}|%0%{%4%}, %g1, %2}"
20194    [(set_attr ("type") ("ssemuladd"))
20195     (set_attr ("prefix") ("evex"))
20196     (set_attr ("mode") ("TI"))])
20198 (define_insn "avx5124vnniw_vp4dpwssds_maskz"
20199   [(set (match_operand:V16SI 0 "register_operand" "=v")
20200         (vec_merge:V16SI
20201           (unspec:V16SI
20202             [(match_operand:V16SI 1 "register_operand" "0")
20203              (match_operand:V64SI 2 "register_operand" "Yh")
20204              (match_operand:V4SI 3 "memory_operand" "m")] UNSPEC_VP4DPWSSDS)
20205           (match_operand:V16SI 4 "const0_operand" "C")
20206           (match_operand:HI 5 "register_operand" "Yk")))]
20207   "TARGET_AVX5124VNNIW"
20208   "vp4dpwssds\t{%3, %g2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %g2, %3}"
20209    [(set_attr ("type") ("ssemuladd"))
20210     (set_attr ("prefix") ("evex"))
20211     (set_attr ("mode") ("TI"))])
20213 (define_insn "vpopcount<mode><mask_name>"
20214   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
20215         (popcount:VI48_AVX512VL
20216           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")))]
20217   "TARGET_AVX512VPOPCNTDQ"
20218   "vpopcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}")
20220 ;; Save multiple registers out-of-line.
20221 (define_insn "save_multiple<mode>"
20222   [(match_parallel 0 "save_multiple"
20223     [(use (match_operand:P 1 "symbol_operand"))])]
20224   "TARGET_SSE && TARGET_64BIT"
20225   "call\t%P1")
20227 ;; Restore multiple registers out-of-line.
20228 (define_insn "restore_multiple<mode>"
20229   [(match_parallel 0 "restore_multiple"
20230     [(use (match_operand:P 1 "symbol_operand"))])]
20231   "TARGET_SSE && TARGET_64BIT"
20232   "call\t%P1")
20234 ;; Restore multiple registers out-of-line and return.
20235 (define_insn "restore_multiple_and_return<mode>"
20236   [(match_parallel 0 "restore_multiple"
20237     [(return)
20238      (use (match_operand:P 1 "symbol_operand"))
20239      (set (reg:DI SP_REG) (reg:DI R10_REG))
20240     ])]
20241   "TARGET_SSE && TARGET_64BIT"
20242   "jmp\t%P1")
20244 ;; Restore multiple registers out-of-line when hard frame pointer is used,
20245 ;; perform the leave operation prior to returning (from the function).
20246 (define_insn "restore_multiple_leave_return<mode>"
20247   [(match_parallel 0 "restore_multiple"
20248     [(return)
20249      (use (match_operand:P 1 "symbol_operand"))
20250      (set (reg:DI SP_REG) (plus:DI (reg:DI BP_REG) (const_int 8)))
20251      (set (reg:DI BP_REG) (mem:DI (reg:DI BP_REG)))
20252      (clobber (mem:BLK (scratch)))
20253     ])]
20254   "TARGET_SSE && TARGET_64BIT"
20255   "jmp\t%P1")
20257 (define_insn "vpopcount<mode><mask_name>"
20258   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
20259         (popcount:VI12_AVX512VL
20260           (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "vm")))]
20261   "TARGET_AVX512BITALG"
20262   "vpopcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}")
20264 (define_insn "vgf2p8affineinvqb_<mode><mask_name>"
20265   [(set (match_operand:VI1_AVX512F 0 "register_operand" "=x,x,v")
20266         (unspec:VI1_AVX512F
20267           [(match_operand:VI1_AVX512F 1 "register_operand" "%0,x,v")
20268            (match_operand:VI1_AVX512F 2 "nonimmediate_operand" "xBm,xm,vm")
20269            (match_operand:QI 3 "const_0_to_255_operand" "n,n,n")]
20270           UNSPEC_GF2P8AFFINEINV))]
20271   "TARGET_GFNI"
20272   "@
20273    gf2p8affineinvqb\t{%3, %2, %0| %0, %2, %3}
20274    vgf2p8affineinvqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}
20275    vgf2p8affineinvqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}"
20276   [(set_attr "isa" "noavx,avx,avx512f")
20277    (set_attr "prefix_data16" "1,*,*")
20278    (set_attr "prefix_extra" "1")
20279    (set_attr "prefix" "orig,maybe_evex,evex")
20280    (set_attr "mode" "<sseinsnmode>")])
20282 (define_insn "vgf2p8affineqb_<mode><mask_name>"
20283   [(set (match_operand:VI1_AVX512F 0 "register_operand" "=x,x,v")
20284         (unspec:VI1_AVX512F
20285           [(match_operand:VI1_AVX512F 1 "register_operand" "%0,x,v")
20286            (match_operand:VI1_AVX512F 2 "nonimmediate_operand" "xBm,xm,vm")
20287            (match_operand:QI 3 "const_0_to_255_operand" "n,n,n")]
20288           UNSPEC_GF2P8AFFINE))]
20289   "TARGET_GFNI"
20290   "@
20291    gf2p8affineqb\t{%3, %2, %0| %0, %2, %3}
20292    vgf2p8affineqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}
20293    vgf2p8affineqb\t{%3, %2, %1, %0<mask_operand4>| %0<mask_operand4>, %1, %2, %3}"
20294   [(set_attr "isa" "noavx,avx,avx512f")
20295    (set_attr "prefix_data16" "1,*,*")
20296    (set_attr "prefix_extra" "1")
20297    (set_attr "prefix" "orig,maybe_evex,evex")
20298    (set_attr "mode" "<sseinsnmode>")])
20300 (define_insn "vgf2p8mulb_<mode><mask_name>"
20301   [(set (match_operand:VI1_AVX512F 0 "register_operand" "=x,x,v")
20302         (unspec:VI1_AVX512F
20303           [(match_operand:VI1_AVX512F 1 "register_operand" "%0,x,v")
20304            (match_operand:VI1_AVX512F 2 "nonimmediate_operand" "xBm,xm,vm")]
20305           UNSPEC_GF2P8MUL))]
20306   "TARGET_GFNI"
20307   "@
20308    gf2p8mulb\t{%2, %0| %0, %2}
20309    vgf2p8mulb\t{%2, %1, %0<mask_operand3>| %0<mask_operand3>, %1, %2}
20310    vgf2p8mulb\t{%2, %1, %0<mask_operand3>| %0<mask_operand3>, %1, %2}"
20311   [(set_attr "isa" "noavx,avx,avx512f")
20312    (set_attr "prefix_data16" "1,*,*")
20313    (set_attr "prefix_extra" "1")
20314    (set_attr "prefix" "orig,maybe_evex,evex")
20315    (set_attr "mode" "<sseinsnmode>")])
20317 (define_insn "vpshrd_<mode><mask_name>"
20318   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20319         (unspec:VI248_AVX512VL
20320           [(match_operand:VI248_AVX512VL 1 "register_operand" "v")
20321            (match_operand:VI248_AVX512VL 2 "nonimmediate_operand" "vm")
20322            (match_operand:SI 3 "const_0_to_255_operand" "n")]
20323           UNSPEC_VPSHRD))]
20324   "TARGET_AVX512VBMI2"
20325   "vpshrd<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3 }"
20326    [(set_attr ("prefix") ("evex"))])
20328 (define_insn "vpshld_<mode><mask_name>"
20329   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20330         (unspec:VI248_AVX512VL
20331           [(match_operand:VI248_AVX512VL 1 "register_operand" "v")
20332            (match_operand:VI248_AVX512VL 2 "nonimmediate_operand" "vm")
20333            (match_operand:SI 3 "const_0_to_255_operand" "n")]
20334           UNSPEC_VPSHLD))]
20335   "TARGET_AVX512VBMI2"
20336   "vpshld<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3 }"
20337    [(set_attr ("prefix") ("evex"))])
20339 (define_insn "vpshrdv_<mode>"
20340   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20341         (unspec:VI248_AVX512VL
20342           [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20343            (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20344            (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20345           UNSPEC_VPSHRDV))]
20346   "TARGET_AVX512VBMI2"
20347   "vpshrdv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3 }"
20348    [(set_attr ("prefix") ("evex"))
20349    (set_attr "mode" "<sseinsnmode>")])
20351 (define_insn "vpshrdv_<mode>_mask"
20352   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20353         (vec_merge:VI248_AVX512VL
20354           (unspec:VI248_AVX512VL
20355             [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20356              (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20357              (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20358             UNSPEC_VPSHRDV)
20359           (match_dup 1)
20360           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20361   "TARGET_AVX512VBMI2"
20362   "vpshrdv<ssemodesuffix>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20363    [(set_attr ("prefix") ("evex"))
20364    (set_attr "mode" "<sseinsnmode>")])
20366 (define_expand "vpshrdv_<mode>_maskz"
20367   [(match_operand:VI248_AVX512VL 0 "register_operand")
20368    (match_operand:VI248_AVX512VL 1 "register_operand")
20369    (match_operand:VI248_AVX512VL 2 "register_operand")
20370    (match_operand:VI248_AVX512VL 3 "nonimmediate_operand")
20371    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20372   "TARGET_AVX512VBMI2"
20374   emit_insn (gen_vpshrdv_<mode>_maskz_1 (operands[0], operands[1],
20375                                          operands[2], operands[3],
20376                                          CONST0_RTX (<MODE>mode),
20377                                                      operands[4]));
20378   DONE;
20381 (define_insn "vpshrdv_<mode>_maskz_1"
20382   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20383         (vec_merge:VI248_AVX512VL
20384           (unspec:VI248_AVX512VL
20385             [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20386              (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20387              (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20388             UNSPEC_VPSHRDV)
20389           (match_operand:VI248_AVX512VL 4 "const0_operand" "C")
20390           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20391   "TARGET_AVX512VBMI2"
20392   "vpshrdv<ssemodesuffix>\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20393    [(set_attr ("prefix") ("evex"))
20394    (set_attr "mode" "<sseinsnmode>")])
20396 (define_insn "vpshldv_<mode>"
20397   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20398         (unspec:VI248_AVX512VL
20399           [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20400            (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20401            (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20402           UNSPEC_VPSHLDV))]
20403   "TARGET_AVX512VBMI2"
20404   "vpshldv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3 }"
20405    [(set_attr ("prefix") ("evex"))
20406    (set_attr "mode" "<sseinsnmode>")])
20408 (define_insn "vpshldv_<mode>_mask"
20409   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20410         (vec_merge:VI248_AVX512VL
20411           (unspec:VI248_AVX512VL
20412             [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20413              (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20414              (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20415             UNSPEC_VPSHLDV)
20416           (match_dup 1)
20417           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20418   "TARGET_AVX512VBMI2"
20419   "vpshldv<ssemodesuffix>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20420    [(set_attr ("prefix") ("evex"))
20421    (set_attr "mode" "<sseinsnmode>")])
20423 (define_expand "vpshldv_<mode>_maskz"
20424   [(match_operand:VI248_AVX512VL 0 "register_operand")
20425    (match_operand:VI248_AVX512VL 1 "register_operand")
20426    (match_operand:VI248_AVX512VL 2 "register_operand")
20427    (match_operand:VI248_AVX512VL 3 "nonimmediate_operand")
20428    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20429   "TARGET_AVX512VBMI2"
20431   emit_insn (gen_vpshldv_<mode>_maskz_1 (operands[0], operands[1],
20432                                          operands[2], operands[3],
20433                                          CONST0_RTX (<MODE>mode),
20434                                                      operands[4]));
20435   DONE;
20438 (define_insn "vpshldv_<mode>_maskz_1"
20439   [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v")
20440         (vec_merge:VI248_AVX512VL
20441           (unspec:VI248_AVX512VL
20442             [(match_operand:VI248_AVX512VL 1 "register_operand" "0")
20443              (match_operand:VI248_AVX512VL 2 "register_operand" "v")
20444              (match_operand:VI248_AVX512VL 3 "nonimmediate_operand" "vm")]
20445             UNSPEC_VPSHLDV)
20446           (match_operand:VI248_AVX512VL 4 "const0_operand" "C")
20447           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20448   "TARGET_AVX512VBMI2"
20449   "vpshldv<ssemodesuffix>\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20450    [(set_attr ("prefix") ("evex"))
20451    (set_attr "mode" "<sseinsnmode>")])
20453 (define_insn "vpdpbusd_<mode>"
20454   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20455         (unspec:VI4_AVX512VL
20456           [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20457            (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20458            (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20459           UNSPEC_VPMADDUBSWACCD))]
20460   "TARGET_AVX512VNNI"
20461   "vpdpbusd\t{%3, %2, %0|%0, %2, %3 }"
20462    [(set_attr ("prefix") ("evex"))])
20464 (define_insn "vpdpbusd_<mode>_mask"
20465   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20466         (vec_merge:VI4_AVX512VL
20467           (unspec:VI4_AVX512VL
20468             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20469              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20470              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20471             UNSPEC_VPMADDUBSWACCD)
20472           (match_dup 1)
20473           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20474   "TARGET_AVX512VNNI"
20475   "vpdpbusd\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20476    [(set_attr ("prefix") ("evex"))])
20478 (define_expand "vpdpbusd_<mode>_maskz"
20479   [(match_operand:VI4_AVX512VL 0 "register_operand")
20480    (match_operand:VI4_AVX512VL 1 "register_operand")
20481    (match_operand:VI4_AVX512VL 2 "register_operand")
20482    (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
20483    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20484   "TARGET_AVX512VNNI"
20486   emit_insn (gen_vpdpbusd_<mode>_maskz_1 (operands[0], operands[1],
20487                                           operands[2], operands[3],
20488                                           CONST0_RTX (<MODE>mode),
20489                                                       operands[4]));
20490   DONE;
20493 (define_insn "vpdpbusd_<mode>_maskz_1"
20494   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20495         (vec_merge:VI4_AVX512VL
20496           (unspec:VI4_AVX512VL
20497             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20498              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20499              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")
20500             ] UNSPEC_VPMADDUBSWACCD)
20501           (match_operand:VI4_AVX512VL 4 "const0_operand" "C")
20502           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20503   "TARGET_AVX512VNNI"
20504   "vpdpbusd\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20505    [(set_attr ("prefix") ("evex"))])
20508 (define_insn "vpdpbusds_<mode>"
20509   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20510         (unspec:VI4_AVX512VL
20511           [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20512            (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20513            (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20514           UNSPEC_VPMADDUBSWACCSSD))]
20515   "TARGET_AVX512VNNI"
20516   "vpdpbusds\t{%3, %2, %0|%0, %2, %3 }"
20517    [(set_attr ("prefix") ("evex"))])
20519 (define_insn "vpdpbusds_<mode>_mask"
20520   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20521         (vec_merge:VI4_AVX512VL
20522           (unspec:VI4_AVX512VL
20523             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20524              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20525              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20526             UNSPEC_VPMADDUBSWACCSSD)
20527           (match_dup 1)
20528           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20529   "TARGET_AVX512VNNI"
20530   "vpdpbusds\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20531    [(set_attr ("prefix") ("evex"))])
20533 (define_expand "vpdpbusds_<mode>_maskz"
20534   [(match_operand:VI4_AVX512VL 0 "register_operand")
20535    (match_operand:VI4_AVX512VL 1 "register_operand")
20536    (match_operand:VI4_AVX512VL 2 "register_operand")
20537    (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
20538    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20539   "TARGET_AVX512VNNI"
20541   emit_insn (gen_vpdpbusds_<mode>_maskz_1 (operands[0], operands[1],
20542                                            operands[2], operands[3],
20543                                            CONST0_RTX (<MODE>mode),
20544                                                        operands[4]));
20545   DONE;
20548 (define_insn "vpdpbusds_<mode>_maskz_1"
20549   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20550         (vec_merge:VI4_AVX512VL
20551           (unspec:VI4_AVX512VL
20552             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20553              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20554              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20555             UNSPEC_VPMADDUBSWACCSSD)
20556           (match_operand:VI4_AVX512VL 4 "const0_operand" "C")
20557           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20558   "TARGET_AVX512VNNI"
20559   "vpdpbusds\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20560    [(set_attr ("prefix") ("evex"))])
20563 (define_insn "vpdpwssd_<mode>"
20564   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20565         (unspec:VI4_AVX512VL
20566           [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20567            (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20568            (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20569           UNSPEC_VPMADDWDACCD))]
20570   "TARGET_AVX512VNNI"
20571   "vpdpwssd\t{%3, %2, %0|%0, %2, %3 }"
20572    [(set_attr ("prefix") ("evex"))])
20574 (define_insn "vpdpwssd_<mode>_mask"
20575   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20576         (vec_merge:VI4_AVX512VL
20577           (unspec:VI4_AVX512VL
20578             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20579              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20580              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20581             UNSPEC_VPMADDWDACCD)
20582           (match_dup 1)
20583           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20584   "TARGET_AVX512VNNI"
20585   "vpdpwssd\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20586    [(set_attr ("prefix") ("evex"))])
20588 (define_expand "vpdpwssd_<mode>_maskz"
20589   [(match_operand:VI4_AVX512VL 0 "register_operand")
20590    (match_operand:VI4_AVX512VL 1 "register_operand")
20591    (match_operand:VI4_AVX512VL 2 "register_operand")
20592    (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
20593    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20594   "TARGET_AVX512VNNI"
20596   emit_insn (gen_vpdpwssd_<mode>_maskz_1 (operands[0], operands[1],
20597                                           operands[2], operands[3],
20598                                           CONST0_RTX (<MODE>mode),
20599                                                       operands[4]));
20600   DONE;
20603 (define_insn "vpdpwssd_<mode>_maskz_1"
20604   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20605         (vec_merge:VI4_AVX512VL
20606           (unspec:VI4_AVX512VL
20607             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20608              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20609              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20610             UNSPEC_VPMADDWDACCD)
20611           (match_operand:VI4_AVX512VL 4 "const0_operand" "C")
20612           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20613   "TARGET_AVX512VNNI"
20614   "vpdpwssd\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20615    [(set_attr ("prefix") ("evex"))])
20618 (define_insn "vpdpwssds_<mode>"
20619   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20620         (unspec:VI4_AVX512VL
20621           [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20622            (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20623            (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20624           UNSPEC_VPMADDWDACCSSD))]
20625   "TARGET_AVX512VNNI"
20626   "vpdpwssds\t{%3, %2, %0|%0, %2, %3 }"
20627    [(set_attr ("prefix") ("evex"))])
20629 (define_insn "vpdpwssds_<mode>_mask"
20630   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20631         (vec_merge:VI4_AVX512VL
20632           (unspec:VI4_AVX512VL
20633             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20634              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20635              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20636             UNSPEC_VPMADDWDACCSSD)
20637           (match_dup 1)
20638           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
20639   "TARGET_AVX512VNNI"
20640   "vpdpwssds\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3 }"
20641    [(set_attr ("prefix") ("evex"))])
20643 (define_expand "vpdpwssds_<mode>_maskz"
20644   [(match_operand:VI4_AVX512VL 0 "register_operand")
20645    (match_operand:VI4_AVX512VL 1 "register_operand")
20646    (match_operand:VI4_AVX512VL 2 "register_operand")
20647    (match_operand:VI4_AVX512VL 3 "nonimmediate_operand")
20648    (match_operand:<avx512fmaskmode> 4 "register_operand")]
20649   "TARGET_AVX512VNNI"
20651   emit_insn (gen_vpdpwssds_<mode>_maskz_1 (operands[0], operands[1],
20652                                            operands[2], operands[3],
20653                                            CONST0_RTX (<MODE>mode),
20654                                                        operands[4]));
20655   DONE;
20658 (define_insn "vpdpwssds_<mode>_maskz_1"
20659   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
20660         (vec_merge:VI4_AVX512VL
20661           (unspec:VI4_AVX512VL
20662             [(match_operand:VI4_AVX512VL 1 "register_operand" "0")
20663              (match_operand:VI4_AVX512VL 2 "register_operand" "v")
20664              (match_operand:VI4_AVX512VL 3 "nonimmediate_operand" "vm")]
20665             UNSPEC_VPMADDWDACCSSD)
20666           (match_operand:VI4_AVX512VL 4 "const0_operand" "C")
20667           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
20668   "TARGET_AVX512VNNI"
20669   "vpdpwssds\t{%3, %2, %0%{%5%}%{z%}|%0%{%5%}%{z%}, %2, %3 }"
20670    [(set_attr ("prefix") ("evex"))])
20672 (define_insn "vaesdec_<mode>"
20673   [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=v")
20674         (unspec:VI1_AVX512VL_F
20675           [(match_operand:VI1_AVX512VL_F 1 "register_operand" "v")
20676            (match_operand:VI1_AVX512VL_F 2 "vector_operand" "v")]
20677           UNSPEC_VAESDEC))]
20678   "TARGET_VAES"
20679   "vaesdec\t{%2, %1, %0|%0, %1, %2}"
20682 (define_insn "vaesdeclast_<mode>"
20683   [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=v")
20684         (unspec:VI1_AVX512VL_F
20685           [(match_operand:VI1_AVX512VL_F 1 "register_operand" "v")
20686            (match_operand:VI1_AVX512VL_F 2 "vector_operand" "v")]
20687           UNSPEC_VAESDECLAST))]
20688   "TARGET_VAES"
20689   "vaesdeclast\t{%2, %1, %0|%0, %1, %2}"
20692 (define_insn "vaesenc_<mode>"
20693   [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=v")
20694         (unspec:VI1_AVX512VL_F
20695           [(match_operand:VI1_AVX512VL_F 1 "register_operand" "v")
20696            (match_operand:VI1_AVX512VL_F 2 "vector_operand" "vm")]
20697           UNSPEC_VAESENC))]
20698   "TARGET_VAES"
20699   "vaesenc\t{%2, %1, %0|%0, %1, %2}"
20702 (define_insn "vaesenclast_<mode>"
20703   [(set (match_operand:VI1_AVX512VL_F 0 "register_operand" "=v")
20704         (unspec:VI1_AVX512VL_F
20705           [(match_operand:VI1_AVX512VL_F 1 "register_operand" "v")
20706            (match_operand:VI1_AVX512VL_F 2 "vector_operand" "vm")]
20707           UNSPEC_VAESENCLAST))]
20708   "TARGET_VAES"
20709   "vaesenclast\t{%2, %1, %0|%0, %1, %2}"
20712 (define_insn "vpclmulqdq_<mode>"
20713   [(set (match_operand:VI8_FVL 0 "register_operand" "=v")
20714         (unspec:VI8_FVL [(match_operand:VI8_FVL 1 "register_operand" "v")
20715                          (match_operand:VI8_FVL 2 "vector_operand" "vm")
20716                          (match_operand:SI 3 "const_0_to_255_operand" "n")]
20717                         UNSPEC_VPCLMULQDQ))]
20718   "TARGET_VPCLMULQDQ"
20719   "vpclmulqdq\t{%3, %2, %1, %0|%0, %1, %2, %3}"
20720   [(set_attr "mode" "DI")])
20722 (define_insn "avx512vl_vpshufbitqmb<mode><mask_scalar_merge_name>"
20723   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
20724         (unspec:<avx512fmaskmode>
20725           [(match_operand:VI1_AVX512VLBW 1 "register_operand" "v")
20726            (match_operand:VI1_AVX512VLBW 2 "nonimmediate_operand" "vm")]
20727           UNSPEC_VPSHUFBIT))]
20728   "TARGET_AVX512BITALG"
20729   "vpshufbitqmb\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
20730   [(set_attr "prefix" "evex")
20731    (set_attr "mode" "<sseinsnmode>")])