PR target/70525
[official-gcc.git] / gcc / config / i386 / sse.md
blob8e9d5ec7cd9e4d95acb7e652e0b7925a1f40fb1b
1 ;; GCC machine description for SSE instructions
2 ;; Copyright (C) 2005-2016 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
23   UNSPEC_LOADU
24   UNSPEC_STOREU
26   ;; SSE3
27   UNSPEC_LDDQU
29   ;; SSSE3
30   UNSPEC_PSHUFB
31   UNSPEC_PSIGN
32   UNSPEC_PALIGNR
34   ;; For SSE4A support
35   UNSPEC_EXTRQI
36   UNSPEC_EXTRQ
37   UNSPEC_INSERTQI
38   UNSPEC_INSERTQ
40   ;; For SSE4.1 support
41   UNSPEC_BLENDV
42   UNSPEC_INSERTPS
43   UNSPEC_DP
44   UNSPEC_MOVNTDQA
45   UNSPEC_MPSADBW
46   UNSPEC_PHMINPOSUW
47   UNSPEC_PTEST
49   ;; For SSE4.2 support
50   UNSPEC_PCMPESTR
51   UNSPEC_PCMPISTR
53   ;; For FMA4 support
54   UNSPEC_FMADDSUB
55   UNSPEC_XOP_UNSIGNED_CMP
56   UNSPEC_XOP_TRUEFALSE
57   UNSPEC_XOP_PERMUTE
58   UNSPEC_FRCZ
60   ;; For AES support
61   UNSPEC_AESENC
62   UNSPEC_AESENCLAST
63   UNSPEC_AESDEC
64   UNSPEC_AESDECLAST
65   UNSPEC_AESIMC
66   UNSPEC_AESKEYGENASSIST
68   ;; For PCLMUL support
69   UNSPEC_PCLMUL
71   ;; For AVX support
72   UNSPEC_PCMP
73   UNSPEC_VPERMIL
74   UNSPEC_VPERMIL2
75   UNSPEC_VPERMIL2F128
76   UNSPEC_CAST
77   UNSPEC_VTESTP
78   UNSPEC_VCVTPH2PS
79   UNSPEC_VCVTPS2PH
81   ;; For AVX2 support
82   UNSPEC_VPERMVAR
83   UNSPEC_VPERMTI
84   UNSPEC_GATHER
85   UNSPEC_VSIBADDR
87   ;; For AVX512F support
88   UNSPEC_VPERMI2
89   UNSPEC_VPERMT2
90   UNSPEC_VPERMI2_MASK
91   UNSPEC_UNSIGNED_FIX_NOTRUNC
92   UNSPEC_UNSIGNED_PCMP
93   UNSPEC_TESTM
94   UNSPEC_TESTNM
95   UNSPEC_SCATTER
96   UNSPEC_RCP14
97   UNSPEC_RSQRT14
98   UNSPEC_FIXUPIMM
99   UNSPEC_SCALEF
100   UNSPEC_VTERNLOG
101   UNSPEC_GETEXP
102   UNSPEC_GETMANT
103   UNSPEC_ALIGN
104   UNSPEC_CONFLICT
105   UNSPEC_COMPRESS
106   UNSPEC_COMPRESS_STORE
107   UNSPEC_EXPAND
108   UNSPEC_MASKED_EQ
109   UNSPEC_MASKED_GT
111   ;; For embed. rounding feature
112   UNSPEC_EMBEDDED_ROUNDING
114   ;; For AVX512PF support
115   UNSPEC_GATHER_PREFETCH
116   UNSPEC_SCATTER_PREFETCH
118   ;; For AVX512ER support
119   UNSPEC_EXP2
120   UNSPEC_RCP28
121   UNSPEC_RSQRT28
123   ;; For SHA support
124   UNSPEC_SHA1MSG1
125   UNSPEC_SHA1MSG2
126   UNSPEC_SHA1NEXTE
127   UNSPEC_SHA1RNDS4
128   UNSPEC_SHA256MSG1
129   UNSPEC_SHA256MSG2
130   UNSPEC_SHA256RNDS2
132   ;; For AVX512BW support
133   UNSPEC_DBPSADBW
134   UNSPEC_PMADDUBSW512
135   UNSPEC_PMADDWD512
136   UNSPEC_PSHUFHW
137   UNSPEC_PSHUFLW
138   UNSPEC_CVTINT2MASK
140   ;; For AVX512DQ support
141   UNSPEC_REDUCE
142   UNSPEC_FPCLASS
143   UNSPEC_RANGE
145   ;; For AVX512IFMA support
146   UNSPEC_VPMADD52LUQ
147   UNSPEC_VPMADD52HUQ
149   ;; For AVX512VBMI support
150   UNSPEC_VPMULTISHIFT
153 (define_c_enum "unspecv" [
154   UNSPECV_LDMXCSR
155   UNSPECV_STMXCSR
156   UNSPECV_CLFLUSH
157   UNSPECV_MONITOR
158   UNSPECV_MWAIT
159   UNSPECV_VZEROALL
160   UNSPECV_VZEROUPPER
163 ;; All vector modes including V?TImode, used in move patterns.
164 (define_mode_iterator VMOVE
165   [(V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
166    (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI
167    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
168    (V8DI "TARGET_AVX512F")  (V4DI "TARGET_AVX") V2DI
169    (V4TI "TARGET_AVX512BW") (V2TI "TARGET_AVX") V1TI
170    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
171    (V8DF "TARGET_AVX512F")  (V4DF "TARGET_AVX") V2DF])
173 ;; All AVX-512{F,VL} vector modes. Supposed TARGET_AVX512F baseline.
174 (define_mode_iterator V48_AVX512VL
175   [V16SI (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
176    V8DI  (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")
177    V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
178    V8DF  (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
180 ;; 1,2 byte AVX-512{BW,VL} vector modes. Supposed TARGET_AVX512BW baseline.
181 (define_mode_iterator VI12_AVX512VL
182   [V64QI (V16QI "TARGET_AVX512VL") (V32QI "TARGET_AVX512VL")
183    V32HI (V16HI "TARGET_AVX512VL") (V8HI "TARGET_AVX512VL")])
185 (define_mode_iterator VI1_AVX512VL
186   [V64QI (V16QI "TARGET_AVX512VL") (V32QI "TARGET_AVX512VL")])
188 ;; All vector modes
189 (define_mode_iterator V
190   [(V32QI "TARGET_AVX") V16QI
191    (V16HI "TARGET_AVX") V8HI
192    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
193    (V8DI "TARGET_AVX512F")  (V4DI "TARGET_AVX") V2DI
194    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
195    (V8DF "TARGET_AVX512F")  (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
197 ;; All 128bit vector modes
198 (define_mode_iterator V_128
199   [V16QI V8HI V4SI V2DI V4SF (V2DF "TARGET_SSE2")])
201 ;; All 256bit vector modes
202 (define_mode_iterator V_256
203   [V32QI V16HI V8SI V4DI V8SF V4DF])
205 ;; All 512bit vector modes
206 (define_mode_iterator V_512 [V64QI V32HI V16SI V8DI V16SF V8DF])
208 ;; All 256bit and 512bit vector modes
209 (define_mode_iterator V_256_512
210   [V32QI V16HI V8SI V4DI V8SF V4DF
211    (V64QI "TARGET_AVX512F") (V32HI "TARGET_AVX512F") (V16SI "TARGET_AVX512F")
212    (V8DI "TARGET_AVX512F") (V16SF "TARGET_AVX512F") (V8DF "TARGET_AVX512F")])
214 ;; All vector float modes
215 (define_mode_iterator VF
216   [(V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
217    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
219 ;; 128- and 256-bit float vector modes
220 (define_mode_iterator VF_128_256
221   [(V8SF "TARGET_AVX") V4SF
222    (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
224 ;; All SFmode vector float modes
225 (define_mode_iterator VF1
226   [(V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF])
228 ;; 128- and 256-bit SF vector modes
229 (define_mode_iterator VF1_128_256
230   [(V8SF "TARGET_AVX") V4SF])
232 (define_mode_iterator VF1_128_256VL
233   [V8SF (V4SF "TARGET_AVX512VL")])
235 ;; All DFmode vector float modes
236 (define_mode_iterator VF2
237   [(V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") V2DF])
239 ;; 128- and 256-bit DF vector modes
240 (define_mode_iterator VF2_128_256
241   [(V4DF "TARGET_AVX") V2DF])
243 (define_mode_iterator VF2_512_256
244   [(V8DF "TARGET_AVX512F") V4DF])
246 (define_mode_iterator VF2_512_256VL
247   [V8DF (V4DF "TARGET_AVX512VL")])
249 ;; All 128bit vector float modes
250 (define_mode_iterator VF_128
251   [V4SF (V2DF "TARGET_SSE2")])
253 ;; All 256bit vector float modes
254 (define_mode_iterator VF_256
255   [V8SF V4DF])
257 ;; All 512bit vector float modes
258 (define_mode_iterator VF_512
259   [V16SF V8DF])
261 (define_mode_iterator VI48_AVX512VL
262   [V16SI (V8SI  "TARGET_AVX512VL") (V4SI  "TARGET_AVX512VL")
263    V8DI  (V4DI  "TARGET_AVX512VL") (V2DI  "TARGET_AVX512VL")])
265 (define_mode_iterator VF_AVX512VL
266   [V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
267    V8DF (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
269 (define_mode_iterator VF2_AVX512VL
270   [V8DF (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
272 (define_mode_iterator VF1_AVX512VL
273   [V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")])
275 ;; All vector integer modes
276 (define_mode_iterator VI
277   [(V16SI "TARGET_AVX512F") (V8DI "TARGET_AVX512F")
278    (V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX") V16QI
279    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX") V8HI
280    (V8SI "TARGET_AVX") V4SI
281    (V4DI "TARGET_AVX") V2DI])
283 (define_mode_iterator VI_AVX2
284   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
285    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI
286    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI
287    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX2") V2DI])
289 ;; All QImode vector integer modes
290 (define_mode_iterator VI1
291   [(V32QI "TARGET_AVX") V16QI])
293 (define_mode_iterator VI_ULOADSTORE_BW_AVX512VL
294   [V64QI
295    V32HI (V8HI "TARGET_AVX512VL") (V16HI "TARGET_AVX512VL")])
297 (define_mode_iterator VI_ULOADSTORE_F_AVX512VL
298   [V16SI (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
299    V8DI (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
301 ;; All DImode vector integer modes
302 (define_mode_iterator V_AVX
303   [V16QI V8HI V4SI V2DI V4SF V2DF
304    (V32QI "TARGET_AVX") (V16HI "TARGET_AVX")
305    (V8SI "TARGET_AVX") (V4DI "TARGET_AVX")
306    (V8SF "TARGET_AVX") (V4DF"TARGET_AVX")])
308 (define_mode_iterator VI48_AVX
309  [V4SI V2DI
310   (V8SI "TARGET_AVX") (V4DI "TARGET_AVX")])
312 (define_mode_iterator VI8
313   [(V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI])
315 (define_mode_iterator VI8_AVX512VL
316   [V8DI (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
318 (define_mode_iterator VI8_256_512
319   [V8DI (V4DI "TARGET_AVX512VL")])
321 (define_mode_iterator VI1_AVX2
322   [(V32QI "TARGET_AVX2") V16QI])
324 (define_mode_iterator VI1_AVX512
325   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI])
327 (define_mode_iterator VI2_AVX2
328   [(V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI])
330 (define_mode_iterator VI2_AVX512F
331   [(V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX2") V8HI])
333 (define_mode_iterator VI4_AVX
334   [(V8SI "TARGET_AVX") V4SI])
336 (define_mode_iterator VI4_AVX2
337   [(V8SI "TARGET_AVX2") V4SI])
339 (define_mode_iterator VI4_AVX512F
340   [(V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI])
342 (define_mode_iterator VI4_AVX512VL
343   [V16SI (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")])
345 (define_mode_iterator VI48_AVX512F_AVX512VL
346   [V4SI V8SI (V16SI "TARGET_AVX512F")
347    (V2DI "TARGET_AVX512VL") (V4DI "TARGET_AVX512VL") (V8DI "TARGET_AVX512F")])
349 (define_mode_iterator VI2_AVX512VL
350   [(V8HI "TARGET_AVX512VL") (V16HI "TARGET_AVX512VL") V32HI])
352 (define_mode_iterator VI8_AVX2_AVX512BW
353   [(V8DI "TARGET_AVX512BW") (V4DI "TARGET_AVX2") V2DI])
355 (define_mode_iterator VI8_AVX2
356   [(V4DI "TARGET_AVX2") V2DI])
358 (define_mode_iterator VI8_AVX2_AVX512F
359   [(V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX2") V2DI])
361 (define_mode_iterator VI4_128_8_256
362   [V4SI V4DI])
364 ;; All V8D* modes
365 (define_mode_iterator V8FI
366   [V8DF V8DI])
368 ;; All V16S* modes
369 (define_mode_iterator V16FI
370   [V16SF V16SI])
372 ;; ??? We should probably use TImode instead.
373 (define_mode_iterator VIMAX_AVX2
374   [(V4TI "TARGET_AVX512BW") (V2TI "TARGET_AVX2") V1TI])
376 ;; ??? This should probably be dropped in favor of VIMAX_AVX2.
377 (define_mode_iterator SSESCALARMODE
378   [(V4TI "TARGET_AVX512BW") (V2TI "TARGET_AVX2") TI])
380 (define_mode_iterator VI12_AVX2
381   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
382    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI])
384 (define_mode_iterator VI24_AVX2
385   [(V16HI "TARGET_AVX2") V8HI
386    (V8SI "TARGET_AVX2") V4SI])
388 (define_mode_iterator VI124_AVX2_24_AVX512F_1_AVX512BW
389   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
390    (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX2") V8HI
391    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI])
393 (define_mode_iterator VI124_AVX2
394   [(V32QI "TARGET_AVX2") V16QI
395    (V16HI "TARGET_AVX2") V8HI
396    (V8SI "TARGET_AVX2") V4SI])
398 (define_mode_iterator VI2_AVX2_AVX512BW
399   [(V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI])
401 (define_mode_iterator VI48_AVX2
402   [(V8SI "TARGET_AVX2") V4SI
403    (V4DI "TARGET_AVX2") V2DI])
405 (define_mode_iterator VI248_AVX2_8_AVX512F_24_AVX512BW
406   [(V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI
407    (V16SI "TARGET_AVX512BW") (V8SI "TARGET_AVX2") V4SI
408    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX2") V2DI])
410 (define_mode_iterator VI248_AVX512BW_AVX512VL
411   [(V32HI "TARGET_AVX512BW") 
412    (V4DI "TARGET_AVX512VL") V16SI V8DI])
414 ;; Suppose TARGET_AVX512VL as baseline
415 (define_mode_iterator VI24_AVX512BW_1
416  [(V16HI "TARGET_AVX512BW") (V8HI "TARGET_AVX512BW")
417   V8SI V4SI])
418    
419 (define_mode_iterator VI48_AVX512F
420   [(V16SI "TARGET_AVX512F") V8SI V4SI
421    (V8DI "TARGET_AVX512F") V4DI V2DI])
423 (define_mode_iterator VI48_AVX_AVX512F
424   [(V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
425    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI])
427 (define_mode_iterator VI12_AVX_AVX512F
428   [ (V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
429     (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI])
431 (define_mode_iterator V48_AVX2
432   [V4SF V2DF
433    V8SF V4DF
434    (V4SI "TARGET_AVX2") (V2DI "TARGET_AVX2")
435    (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")])
437 (define_mode_attr avx512
438   [(V16QI "avx512vl") (V32QI "avx512vl") (V64QI "avx512bw")
439    (V8HI  "avx512vl") (V16HI  "avx512vl") (V32HI "avx512bw")
440    (V4SI  "avx512vl") (V8SI  "avx512vl") (V16SI "avx512f")
441    (V2DI  "avx512vl") (V4DI  "avx512vl") (V8DI "avx512f")
442    (V4SF "avx512vl") (V8SF "avx512vl") (V16SF "avx512f")
443    (V2DF "avx512vl") (V4DF "avx512vl") (V8DF "avx512f")])
445 (define_mode_attr sse2_avx_avx512f
446   [(V16QI "sse2") (V32QI "avx") (V64QI "avx512f")
447    (V8HI  "avx512vl") (V16HI  "avx512vl") (V32HI "avx512bw")
448    (V4SI  "sse2") (V8SI  "avx") (V16SI "avx512f")
449    (V2DI  "avx512vl") (V4DI  "avx512vl") (V8DI "avx512f")
450    (V16SF "avx512f") (V8SF "avx") (V4SF "avx")
451    (V8DF "avx512f") (V4DF "avx") (V2DF "avx")])
453 (define_mode_attr sse2_avx2
454   [(V16QI "sse2") (V32QI "avx2") (V64QI "avx512bw")
455    (V8HI "sse2") (V16HI "avx2") (V32HI "avx512bw")
456    (V4SI "sse2") (V8SI "avx2") (V16SI "avx512f")
457    (V2DI "sse2") (V4DI "avx2") (V8DI "avx512f")
458    (V1TI "sse2") (V2TI "avx2") (V4TI "avx512bw")])
460 (define_mode_attr ssse3_avx2
461    [(V16QI "ssse3") (V32QI "avx2") (V64QI "avx512bw")
462     (V4HI "ssse3") (V8HI "ssse3") (V16HI "avx2") (V32HI "avx512bw")
463     (V4SI "ssse3") (V8SI "avx2")
464     (V2DI "ssse3") (V4DI "avx2")
465     (TI "ssse3") (V2TI "avx2") (V4TI "avx512bw")])
467 (define_mode_attr sse4_1_avx2
468    [(V16QI "sse4_1") (V32QI "avx2") (V64QI "avx512bw")
469     (V8HI "sse4_1") (V16HI "avx2") (V32HI "avx512bw")
470     (V4SI "sse4_1") (V8SI "avx2") (V16SI "avx512f")
471     (V2DI "sse4_1") (V4DI "avx2") (V8DI "avx512dq")])
473 (define_mode_attr avx_avx2
474   [(V4SF "avx") (V2DF "avx")
475    (V8SF "avx") (V4DF "avx")
476    (V4SI "avx2") (V2DI "avx2")
477    (V8SI "avx2") (V4DI "avx2")])
479 (define_mode_attr vec_avx2
480   [(V16QI "vec") (V32QI "avx2")
481    (V8HI "vec") (V16HI "avx2")
482    (V4SI "vec") (V8SI "avx2")
483    (V2DI "vec") (V4DI "avx2")])
485 (define_mode_attr avx2_avx512
486   [(V4SI "avx2") (V8SI "avx2") (V16SI "avx512f")
487    (V2DI "avx2") (V4DI "avx2") (V8DI "avx512f")
488    (V4SF "avx2") (V8SF "avx2") (V16SF "avx512f")
489    (V2DF "avx2") (V4DF "avx2") (V8DF "avx512f")
490    (V8HI "avx512vl") (V16HI "avx512vl") (V32HI "avx512bw")])
492 (define_mode_attr shuffletype
493   [(V16SF "f") (V16SI "i") (V8DF "f") (V8DI "i")
494   (V8SF "f") (V8SI "i") (V4DF "f") (V4DI "i")
495   (V4SF "f") (V4SI "i") (V2DF "f") (V2DI "i")
496   (V32QI "i") (V16HI "i") (V16QI "i") (V8HI "i")
497   (V64QI "i") (V1TI "i") (V2TI "i")])
499 (define_mode_attr ssequartermode
500   [(V16SF "V4SF") (V8DF "V2DF") (V16SI "V4SI") (V8DI "V2DI")])
502 (define_mode_attr ssedoublemodelower
503   [(V16QI "v16hi") (V32QI "v32hi") (V64QI "v64hi")
504    (V8HI "v8si")   (V16HI "v16si") (V32HI "v32si")
505    (V4SI "v4di")   (V8SI "v8di")   (V16SI "v16di")])
507 (define_mode_attr ssedoublemode
508   [(V4SF "V8SF") (V8SF "V16SF") (V16SF "V32SF")
509    (V2DF "V4DF") (V4DF "V8DF") (V8DF "V16DF")
510    (V16QI "V16HI") (V32QI "V32HI") (V64QI "V64HI")
511    (V4HI "V4SI") (V8HI "V8SI") (V16HI "V16SI") (V32HI "V32SI")
512    (V4SI "V4DI") (V8SI "V16SI") (V16SI "V32SI")
513    (V4DI "V8DI") (V8DI "V16DI")])
515 (define_mode_attr ssebytemode
516   [(V8DI "V64QI") (V4DI "V32QI") (V2DI "V16QI")])
518 ;; All 128bit vector integer modes
519 (define_mode_iterator VI_128 [V16QI V8HI V4SI V2DI])
521 ;; All 256bit vector integer modes
522 (define_mode_iterator VI_256 [V32QI V16HI V8SI V4DI])
524 ;; All 512bit vector integer modes
525 (define_mode_iterator VI_512
526   [(V64QI "TARGET_AVX512BW")
527    (V32HI "TARGET_AVX512BW")
528    V16SI V8DI])
530 ;; Various 128bit vector integer mode combinations
531 (define_mode_iterator VI12_128 [V16QI V8HI])
532 (define_mode_iterator VI14_128 [V16QI V4SI])
533 (define_mode_iterator VI124_128 [V16QI V8HI V4SI])
534 (define_mode_iterator VI24_128 [V8HI V4SI])
535 (define_mode_iterator VI248_128 [V8HI V4SI V2DI])
536 (define_mode_iterator VI48_128 [V4SI V2DI])
538 ;; Various 256bit and 512 vector integer mode combinations
539 (define_mode_iterator VI124_256 [V32QI V16HI V8SI])
540 (define_mode_iterator VI124_256_AVX512F_AVX512BW
541   [V32QI V16HI V8SI
542    (V64QI "TARGET_AVX512BW")
543    (V32HI "TARGET_AVX512BW")
544    (V16SI "TARGET_AVX512F")])
545 (define_mode_iterator VI48_256 [V8SI V4DI])
546 (define_mode_iterator VI48_512 [V16SI V8DI])
547 (define_mode_iterator VI4_256_8_512 [V8SI V8DI])
548 (define_mode_iterator VI_AVX512BW
549   [V16SI V8DI (V32HI "TARGET_AVX512BW") (V64QI "TARGET_AVX512BW")])
551 ;; Int-float size matches
552 (define_mode_iterator VI4F_128 [V4SI V4SF])
553 (define_mode_iterator VI8F_128 [V2DI V2DF])
554 (define_mode_iterator VI4F_256 [V8SI V8SF])
555 (define_mode_iterator VI8F_256 [V4DI V4DF])
556 (define_mode_iterator VI8F_256_512
557   [V4DI V4DF (V8DI "TARGET_AVX512F") (V8DF "TARGET_AVX512F")])
558 (define_mode_iterator VI48F_256_512
559   [V8SI V8SF
560   (V16SI "TARGET_AVX512F") (V16SF "TARGET_AVX512F")
561   (V8DI  "TARGET_AVX512F") (V8DF  "TARGET_AVX512F")
562   (V4DI  "TARGET_AVX512VL") (V4DF  "TARGET_AVX512VL")])
563 (define_mode_iterator VF48_I1248
564   [V16SI V16SF V8DI V8DF V32HI V64QI])
565 (define_mode_iterator VI48F
566   [V16SI V16SF V8DI V8DF
567    (V8SI "TARGET_AVX512VL") (V8SF "TARGET_AVX512VL")
568    (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")
569    (V4SI "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
570    (V2DI "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
571 (define_mode_iterator VI48F_256 [V8SI V8SF V4DI V4DF])
573 ;; Mapping from float mode to required SSE level
574 (define_mode_attr sse
575   [(SF "sse") (DF "sse2")
576    (V4SF "sse") (V2DF "sse2")
577    (V16SF "avx512f") (V8SF "avx")
578    (V8DF "avx512f") (V4DF "avx")])
580 (define_mode_attr sse2
581   [(V16QI "sse2") (V32QI "avx") (V64QI "avx512f")
582    (V2DI "sse2") (V4DI "avx") (V8DI "avx512f")])
584 (define_mode_attr sse3
585   [(V16QI "sse3") (V32QI "avx")])
587 (define_mode_attr sse4_1
588   [(V4SF "sse4_1") (V2DF "sse4_1")
589    (V8SF "avx") (V4DF "avx")
590    (V8DF "avx512f")
591    (V4DI "avx") (V2DI "sse4_1")
592    (V8SI "avx") (V4SI "sse4_1")
593    (V16QI "sse4_1") (V32QI "avx")
594    (V8HI "sse4_1") (V16HI "avx")])
596 (define_mode_attr avxsizesuffix
597   [(V64QI "512") (V32HI "512") (V16SI "512") (V8DI "512")
598    (V32QI "256") (V16HI "256") (V8SI "256") (V4DI "256")
599    (V16QI "") (V8HI "") (V4SI "") (V2DI "")
600    (V16SF "512") (V8DF "512")
601    (V8SF "256") (V4DF "256")
602    (V4SF "") (V2DF "")])
604 ;; SSE instruction mode
605 (define_mode_attr sseinsnmode
606   [(V64QI "XI") (V32HI "XI") (V16SI "XI") (V8DI "XI") (V4TI "XI")
607    (V32QI "OI") (V16HI "OI") (V8SI "OI") (V4DI "OI") (V2TI "OI")
608    (V16QI "TI") (V8HI "TI") (V4SI "TI") (V2DI "TI") (V1TI "TI")
609    (V16SF "V16SF") (V8DF "V8DF")
610    (V8SF "V8SF") (V4DF "V4DF")
611    (V4SF "V4SF") (V2DF "V2DF")
612    (TI "TI")])
614 ;; Mapping of vector modes to corresponding mask size
615 (define_mode_attr avx512fmaskmode
616   [(V64QI "DI") (V32QI "SI") (V16QI "HI")
617    (V32HI "SI") (V16HI "HI") (V8HI  "QI") (V4HI "QI")
618    (V16SI "HI") (V8SI  "QI") (V4SI  "QI")
619    (V8DI  "QI") (V4DI  "QI") (V2DI  "QI")
620    (V16SF "HI") (V8SF  "QI") (V4SF  "QI")
621    (V8DF  "QI") (V4DF  "QI") (V2DF  "QI")])
623 ;; Mapping of vector modes to corresponding mask size
624 (define_mode_attr avx512fmaskmodelower
625   [(V64QI "di") (V32QI "si") (V16QI "hi")
626    (V32HI "si") (V16HI "hi") (V8HI  "qi") (V4HI "qi")
627    (V16SI "hi") (V8SI  "qi") (V4SI  "qi")
628    (V8DI  "qi") (V4DI  "qi") (V2DI  "qi")
629    (V16SF "hi") (V8SF  "qi") (V4SF  "qi")
630    (V8DF  "qi") (V4DF  "qi") (V2DF  "qi")])
632 ;; Mapping of vector float modes to an integer mode of the same size
633 (define_mode_attr sseintvecmode
634   [(V16SF "V16SI") (V8DF  "V8DI")
635    (V8SF  "V8SI")  (V4DF  "V4DI")
636    (V4SF  "V4SI")  (V2DF  "V2DI")
637    (V16SI "V16SI") (V8DI  "V8DI")
638    (V8SI  "V8SI")  (V4DI  "V4DI")
639    (V4SI  "V4SI")  (V2DI  "V2DI")
640    (V16HI "V16HI") (V8HI  "V8HI")
641    (V32HI "V32HI") (V64QI "V64QI")
642    (V32QI "V32QI") (V16QI "V16QI")])
644 (define_mode_attr sseintvecmode2
645   [(V8DF "XI") (V4DF "OI") (V2DF "TI")
646    (V8SF "OI") (V4SF "TI")])
648 (define_mode_attr sseintvecmodelower
649   [(V16SF "v16si") (V8DF "v8di")
650    (V8SF "v8si") (V4DF "v4di")
651    (V4SF "v4si") (V2DF "v2di")
652    (V8SI "v8si") (V4DI "v4di")
653    (V4SI "v4si") (V2DI "v2di")
654    (V16HI "v16hi") (V8HI "v8hi")
655    (V32QI "v32qi") (V16QI "v16qi")])
657 ;; Mapping of vector modes to a vector mode of double size
658 (define_mode_attr ssedoublevecmode
659   [(V32QI "V64QI") (V16HI "V32HI") (V8SI "V16SI") (V4DI "V8DI")
660    (V16QI "V32QI") (V8HI "V16HI") (V4SI "V8SI") (V2DI "V4DI")
661    (V8SF "V16SF") (V4DF "V8DF")
662    (V4SF "V8SF") (V2DF "V4DF")])
664 ;; Mapping of vector modes to a vector mode of half size
665 (define_mode_attr ssehalfvecmode
666   [(V64QI "V32QI") (V32HI "V16HI") (V16SI "V8SI") (V8DI "V4DI")
667    (V32QI "V16QI") (V16HI  "V8HI") (V8SI  "V4SI") (V4DI "V2DI")
668    (V16QI  "V8QI") (V8HI   "V4HI") (V4SI  "V2SI")
669    (V16SF "V8SF") (V8DF "V4DF")
670    (V8SF  "V4SF") (V4DF "V2DF")
671    (V4SF  "V2SF")])
673 ;; Mapping of vector modes ti packed single mode of the same size
674 (define_mode_attr ssePSmode
675   [(V16SI "V16SF") (V8DF "V16SF")
676    (V16SF "V16SF") (V8DI "V16SF")
677    (V64QI "V16SF") (V32QI "V8SF") (V16QI "V4SF")
678    (V32HI "V16SF") (V16HI "V8SF") (V8HI "V4SF")
679    (V8SI "V8SF") (V4SI "V4SF")
680    (V4DI "V8SF") (V2DI "V4SF")
681    (V4TI "V16SF") (V2TI "V8SF") (V1TI "V4SF")
682    (V8SF "V8SF") (V4SF "V4SF")
683    (V4DF "V8SF") (V2DF "V4SF")])
685 (define_mode_attr ssePSmode2
686   [(V8DI "V8SF") (V4DI "V4SF")])
688 ;; Mapping of vector modes back to the scalar modes
689 (define_mode_attr ssescalarmode
690   [(V64QI "QI") (V32QI "QI") (V16QI "QI")
691    (V32HI "HI") (V16HI "HI") (V8HI "HI")
692    (V16SI "SI") (V8SI "SI")  (V4SI "SI")
693    (V8DI "DI")  (V4DI "DI")  (V2DI "DI")
694    (V16SF "SF") (V8SF "SF")  (V4SF "SF")
695    (V8DF "DF")  (V4DF "DF")  (V2DF "DF")])
697 ;; Mapping of vector modes to the 128bit modes
698 (define_mode_attr ssexmmmode
699   [(V64QI "V16QI") (V32QI "V16QI") (V16QI "V16QI")
700    (V32HI "V8HI")  (V16HI "V8HI") (V8HI "V8HI")
701    (V16SI "V4SI")  (V8SI "V4SI")  (V4SI "V4SI")
702    (V8DI "V2DI")   (V4DI "V2DI")  (V2DI "V2DI")
703    (V16SF "V4SF")  (V8SF "V4SF")  (V4SF "V4SF")
704    (V8DF "V2DF")   (V4DF "V2DF")  (V2DF "V2DF")])
706 ;; Pointer size override for scalar modes (Intel asm dialect)
707 (define_mode_attr iptr
708   [(V32QI "b") (V16HI "w") (V8SI "k") (V4DI "q")
709    (V16QI "b") (V8HI "w") (V4SI "k") (V2DI "q")
710    (V8SF "k") (V4DF "q")
711    (V4SF "k") (V2DF "q")
712    (SF "k") (DF "q")])
714 ;; Number of scalar elements in each vector type
715 (define_mode_attr ssescalarnum
716   [(V64QI "64") (V16SI "16") (V8DI "8")
717    (V32QI "32") (V16HI "16") (V8SI "8") (V4DI "4")
718    (V16QI "16") (V8HI "8") (V4SI "4") (V2DI "2")
719    (V16SF "16") (V8DF "8")
720    (V8SF "8") (V4DF "4")
721    (V4SF "4") (V2DF "2")])
723 ;; Mask of scalar elements in each vector type
724 (define_mode_attr ssescalarnummask
725   [(V32QI "31") (V16HI "15") (V8SI "7") (V4DI "3")
726    (V16QI "15") (V8HI "7") (V4SI "3") (V2DI "1")
727    (V8SF "7") (V4DF "3")
728    (V4SF "3") (V2DF "1")])
730 (define_mode_attr ssescalarsize
731   [(V8DI  "64") (V4DI  "64") (V2DI  "64")
732    (V64QI "8") (V32QI "8") (V16QI "8")
733    (V32HI "16") (V16HI "16") (V8HI "16")
734    (V16SI "32") (V8SI "32") (V4SI "32")
735    (V16SF "32") (V8DF "64")])
737 ;; SSE prefix for integer vector modes
738 (define_mode_attr sseintprefix
739   [(V2DI  "p") (V2DF  "")
740    (V4DI  "p") (V4DF  "")
741    (V8DI  "p") (V8DF  "")
742    (V4SI  "p") (V4SF  "")
743    (V8SI  "p") (V8SF  "")
744    (V16SI "p") (V16SF "")
745    (V16QI "p") (V8HI "p")
746    (V32QI "p") (V16HI "p")
747    (V64QI "p") (V32HI "p")])
749 ;; SSE scalar suffix for vector modes
750 (define_mode_attr ssescalarmodesuffix
751   [(SF "ss") (DF "sd")
752    (V8SF "ss") (V4DF "sd")
753    (V4SF "ss") (V2DF "sd")
754    (V8SI "ss") (V4DI "sd")
755    (V4SI "d")])
757 ;; Pack/unpack vector modes
758 (define_mode_attr sseunpackmode
759   [(V16QI "V8HI") (V8HI "V4SI") (V4SI "V2DI")
760    (V32QI "V16HI") (V16HI "V8SI") (V8SI "V4DI")
761    (V32HI "V16SI") (V64QI "V32HI") (V16SI "V8DI")])
763 (define_mode_attr ssepackmode
764   [(V8HI "V16QI") (V4SI "V8HI") (V2DI "V4SI")
765    (V16HI "V32QI") (V8SI "V16HI") (V4DI "V8SI")
766    (V32HI "V64QI") (V16SI "V32HI") (V8DI "V16SI")])
768 ;; Mapping of the max integer size for xop rotate immediate constraint
769 (define_mode_attr sserotatemax
770   [(V16QI "7") (V8HI "15") (V4SI "31") (V2DI "63")])
772 ;; Mapping of mode to cast intrinsic name
773 (define_mode_attr castmode
774  [(V8SI "si") (V8SF "ps") (V4DF "pd")
775   (V16SI "si") (V16SF "ps") (V8DF "pd")])
777 ;; Instruction suffix for sign and zero extensions.
778 (define_code_attr extsuffix [(sign_extend "sx") (zero_extend "zx")])
780 ;; i128 for integer vectors and TARGET_AVX2, f128 otherwise.
781 ;; i64x4 or f64x4 for 512bit modes.
782 (define_mode_attr i128
783   [(V16SF "f64x4") (V8SF "f128") (V8DF "f64x4") (V4DF "f128")
784    (V64QI "i64x4") (V32QI "%~128") (V32HI "i64x4") (V16HI "%~128")
785    (V16SI "i64x4") (V8SI "%~128") (V8DI "i64x4") (V4DI "%~128")])
787 ;; Mix-n-match
788 (define_mode_iterator AVX256MODE2P [V8SI V8SF V4DF])
789 (define_mode_iterator AVX512MODE2P [V16SI V16SF V8DF])
791 ;; Mapping for dbpsabbw modes
792 (define_mode_attr dbpsadbwmode
793   [(V32HI "V64QI") (V16HI "V32QI") (V8HI "V16QI")])
795 ;; Mapping suffixes for broadcast
796 (define_mode_attr bcstscalarsuff
797   [(V64QI "b")  (V32QI "b") (V16QI "b")
798    (V32HI "w")  (V16HI "w") (V8HI "w")
799    (V16SI "d")  (V8SI "d")  (V4SI "d")
800    (V8DI "q")   (V4DI "q")  (V2DI "q")
801    (V16SF "ss") (V8SF "ss") (V4SF "ss")
802    (V8DF "sd")  (V4DF "sd") (V2DF "sd")])
804 ;; Tie mode of assembler operand to mode iterator
805 (define_mode_attr concat_tg_mode
806   [(V32QI "t") (V16HI "t") (V8SI "t") (V4DI "t") (V8SF "t") (V4DF "t")
807    (V64QI "g") (V32HI "g") (V16SI "g") (V8DI "g") (V16SF "g") (V8DF "g")])
809 ;; Half mask mode for unpacks
810 (define_mode_attr HALFMASKMODE
811   [(DI "SI") (SI "HI")])
813 ;; Double mask mode for packs
814 (define_mode_attr DOUBLEMASKMODE
815   [(HI "SI") (SI "DI")])
818 ;; Include define_subst patterns for instructions with mask
819 (include "subst.md")
821 ;; Patterns whose name begins with "sse{,2,3}_" are invoked by intrinsics.
823 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
825 ;; Move patterns
827 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
829 ;; All of these patterns are enabled for SSE1 as well as SSE2.
830 ;; This is essential for maintaining stable calling conventions.
832 (define_expand "mov<mode>"
833   [(set (match_operand:VMOVE 0 "nonimmediate_operand")
834         (match_operand:VMOVE 1 "nonimmediate_operand"))]
835   "TARGET_SSE"
837   ix86_expand_vector_move (<MODE>mode, operands);
838   DONE;
841 (define_insn "*mov<mode>_internal"
842   [(set (match_operand:VMOVE 0 "nonimmediate_operand"               "=v,v ,m")
843         (match_operand:VMOVE 1 "nonimmediate_or_sse_const_operand"  "BC,vm,v"))]
844   "TARGET_SSE
845    && (register_operand (operands[0], <MODE>mode)
846        || register_operand (operands[1], <MODE>mode))"
848   int mode = get_attr_mode (insn);
849   switch (which_alternative)
850     {
851     case 0:
852       return standard_sse_constant_opcode (insn, operands[1]);
853     case 1:
854     case 2:
855       /* There is no evex-encoded vmov* for sizes smaller than 64-bytes
856          in avx512f, so we need to use workarounds, to access sse registers
857          16-31, which are evex-only. In avx512vl we don't need workarounds.  */
858       if (TARGET_AVX512F && <MODE_SIZE> < 64 && !TARGET_AVX512VL
859           && ((REG_P (operands[0]) && EXT_REX_SSE_REGNO_P (REGNO (operands[0])))
860               || (REG_P (operands[1]) && EXT_REX_SSE_REGNO_P (REGNO (operands[1])))))
861         {
862           if (memory_operand (operands[0], <MODE>mode))
863             {
864               if (<MODE_SIZE> == 32)
865                 return "vextract<shuffletype>64x4\t{$0x0, %g1, %0|%0, %g1, 0x0}";
866               else if (<MODE_SIZE> == 16)
867                 return "vextract<shuffletype>32x4\t{$0x0, %g1, %0|%0, %g1, 0x0}";
868               else
869                 gcc_unreachable ();
870             }
871           else if (memory_operand (operands[1], <MODE>mode))
872             {
873               if (<MODE_SIZE> == 32)
874                 return "vbroadcast<shuffletype>64x4\t{%1, %g0|%g0, %1}";
875               else if (<MODE_SIZE> == 16)
876                 return "vbroadcast<shuffletype>32x4\t{%1, %g0|%g0, %1}";
877               else
878                 gcc_unreachable ();
879             }
880           else
881             /* Reg -> reg move is always aligned.  Just use wider move.  */
882             switch (mode)
883               {
884               case MODE_V8SF:
885               case MODE_V4SF:
886                 return "vmovaps\t{%g1, %g0|%g0, %g1}";
887               case MODE_V4DF:
888               case MODE_V2DF:
889                 return "vmovapd\t{%g1, %g0|%g0, %g1}";
890               case MODE_OI:
891               case MODE_TI:
892                 return "vmovdqa64\t{%g1, %g0|%g0, %g1}";
893               default:
894                 gcc_unreachable ();
895               }
896         }
897       switch (mode)
898         {
899         case MODE_V16SF:
900         case MODE_V8SF:
901         case MODE_V4SF:
902           if ((TARGET_AVX || TARGET_IAMCU)
903               && (misaligned_operand (operands[0], <MODE>mode)
904                   || misaligned_operand (operands[1], <MODE>mode)))
905             return "%vmovups\t{%1, %0|%0, %1}";
906           else
907             return "%vmovaps\t{%1, %0|%0, %1}";
909         case MODE_V8DF:
910         case MODE_V4DF:
911         case MODE_V2DF:
912           if ((TARGET_AVX || TARGET_IAMCU)
913               && (misaligned_operand (operands[0], <MODE>mode)
914                   || misaligned_operand (operands[1], <MODE>mode)))
915             return "%vmovupd\t{%1, %0|%0, %1}";
916           else
917             return "%vmovapd\t{%1, %0|%0, %1}";
919         case MODE_OI:
920         case MODE_TI:
921           if ((TARGET_AVX || TARGET_IAMCU)
922               && (misaligned_operand (operands[0], <MODE>mode)
923                   || misaligned_operand (operands[1], <MODE>mode)))
924             return TARGET_AVX512VL ? "vmovdqu64\t{%1, %0|%0, %1}"
925                                    : "%vmovdqu\t{%1, %0|%0, %1}";
926           else
927             return TARGET_AVX512VL ? "vmovdqa64\t{%1, %0|%0, %1}"
928                                    : "%vmovdqa\t{%1, %0|%0, %1}";
929         case MODE_XI:
930           if (misaligned_operand (operands[0], <MODE>mode)
931               || misaligned_operand (operands[1], <MODE>mode))
932             return "vmovdqu64\t{%1, %0|%0, %1}";
933           else
934             return "vmovdqa64\t{%1, %0|%0, %1}";
936         default:
937           gcc_unreachable ();
938         }
939     default:
940       gcc_unreachable ();
941     }
943   [(set_attr "type" "sselog1,ssemov,ssemov")
944    (set_attr "prefix" "maybe_vex")
945    (set (attr "mode")
946         (cond [(and (match_test "<MODE_SIZE> == 16")
947                     (ior (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
948                          (and (eq_attr "alternative" "2")
949                               (match_test "TARGET_SSE_TYPELESS_STORES"))))
950                  (const_string "<ssePSmode>")
951                (match_test "TARGET_AVX")
952                  (const_string "<sseinsnmode>")
953                (ior (not (match_test "TARGET_SSE2"))
954                     (match_test "optimize_function_for_size_p (cfun)"))
955                  (const_string "V4SF")
956                (and (eq_attr "alternative" "0")
957                     (match_test "TARGET_SSE_LOAD0_BY_PXOR"))
958                  (const_string "TI")
959               ]
960               (const_string "<sseinsnmode>")))])
962 (define_insn "<avx512>_load<mode>_mask"
963   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v,v")
964         (vec_merge:V48_AVX512VL
965           (match_operand:V48_AVX512VL 1 "nonimmediate_operand" "v,m")
966           (match_operand:V48_AVX512VL 2 "vector_move_operand" "0C,0C")
967           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
968   "TARGET_AVX512F"
970   if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
971     {
972       if (misaligned_operand (operands[1], <MODE>mode))
973         return "vmovu<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
974       else
975         return "vmova<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
976     }
977   else
978     {
979       if (misaligned_operand (operands[1], <MODE>mode))
980         return "vmovdqu<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
981       else
982         return "vmovdqa<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
983     }
985   [(set_attr "type" "ssemov")
986    (set_attr "prefix" "evex")
987    (set_attr "memory" "none,load")
988    (set_attr "mode" "<sseinsnmode>")])
990 (define_insn "<avx512>_load<mode>_mask"
991   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v,v")
992         (vec_merge:VI12_AVX512VL
993           (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "v,m")
994           (match_operand:VI12_AVX512VL 2 "vector_move_operand" "0C,0C")
995           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
996   "TARGET_AVX512BW"
997   "vmovdqu<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
998   [(set_attr "type" "ssemov")
999    (set_attr "prefix" "evex")
1000    (set_attr "memory" "none,load")
1001    (set_attr "mode" "<sseinsnmode>")])
1003 (define_insn "<avx512>_blendm<mode>"
1004   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v")
1005         (vec_merge:V48_AVX512VL
1006           (match_operand:V48_AVX512VL 2 "nonimmediate_operand" "vm")
1007           (match_operand:V48_AVX512VL 1 "register_operand" "v")
1008           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
1009   "TARGET_AVX512F"
1010   "vblendm<ssemodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}"
1011   [(set_attr "type" "ssemov")
1012    (set_attr "prefix" "evex")
1013    (set_attr "mode" "<sseinsnmode>")])
1015 (define_insn "<avx512>_blendm<mode>"
1016   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
1017         (vec_merge:VI12_AVX512VL
1018           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
1019           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
1020           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
1021   "TARGET_AVX512BW"
1022   "vpblendm<ssemodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}"
1023   [(set_attr "type" "ssemov")
1024    (set_attr "prefix" "evex")
1025    (set_attr "mode" "<sseinsnmode>")])
1027 (define_insn "<avx512>_store<mode>_mask"
1028   [(set (match_operand:V48_AVX512VL 0 "memory_operand" "=m")
1029         (vec_merge:V48_AVX512VL
1030           (match_operand:V48_AVX512VL 1 "register_operand" "v")
1031           (match_dup 0)
1032           (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1033   "TARGET_AVX512F"
1035   if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
1036     {
1037       if (misaligned_operand (operands[0], <MODE>mode))
1038         return "vmovu<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1039       else
1040         return "vmova<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1041     }
1042   else
1043     {
1044       if (misaligned_operand (operands[0], <MODE>mode))
1045         return "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1046       else
1047         return "vmovdqa<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1048     }
1050   [(set_attr "type" "ssemov")
1051    (set_attr "prefix" "evex")
1052    (set_attr "memory" "store")
1053    (set_attr "mode" "<sseinsnmode>")])
1055 (define_insn "<avx512>_store<mode>_mask"
1056   [(set (match_operand:VI12_AVX512VL 0 "memory_operand" "=m")
1057         (vec_merge:VI12_AVX512VL
1058           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
1059           (match_dup 0)
1060           (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1061   "TARGET_AVX512BW"
1062   "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
1063   [(set_attr "type" "ssemov")
1064    (set_attr "prefix" "evex")
1065    (set_attr "memory" "store")
1066    (set_attr "mode" "<sseinsnmode>")])
1068 (define_insn "sse2_movq128"
1069   [(set (match_operand:V2DI 0 "register_operand" "=x")
1070         (vec_concat:V2DI
1071           (vec_select:DI
1072             (match_operand:V2DI 1 "nonimmediate_operand" "xm")
1073             (parallel [(const_int 0)]))
1074           (const_int 0)))]
1075   "TARGET_SSE2"
1076   "%vmovq\t{%1, %0|%0, %q1}"
1077   [(set_attr "type" "ssemov")
1078    (set_attr "prefix" "maybe_vex")
1079    (set_attr "mode" "TI")])
1081 ;; Move a DI from a 32-bit register pair (e.g. %edx:%eax) to an xmm.
1082 ;; We'd rather avoid this entirely; if the 32-bit reg pair was loaded
1083 ;; from memory, we'd prefer to load the memory directly into the %xmm
1084 ;; register.  To facilitate this happy circumstance, this pattern won't
1085 ;; split until after register allocation.  If the 64-bit value didn't
1086 ;; come from memory, this is the best we can do.  This is much better
1087 ;; than storing %edx:%eax into a stack temporary and loading an %xmm
1088 ;; from there.
1090 (define_insn_and_split "movdi_to_sse"
1091   [(parallel
1092     [(set (match_operand:V4SI 0 "register_operand" "=?x,x")
1093           (subreg:V4SI (match_operand:DI 1 "nonimmediate_operand" "r,m") 0))
1094      (clobber (match_scratch:V4SI 2 "=&x,X"))])]
1095   "!TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_TO_VEC"
1096   "#"
1097   "&& reload_completed"
1098   [(const_int 0)]
1100  if (register_operand (operands[1], DImode))
1101    {
1102       /* The DImode arrived in a pair of integral registers (e.g. %edx:%eax).
1103          Assemble the 64-bit DImode value in an xmm register.  */
1104       emit_insn (gen_sse2_loadld (operands[0], CONST0_RTX (V4SImode),
1105                                   gen_lowpart (SImode, operands[1])));
1106       emit_insn (gen_sse2_loadld (operands[2], CONST0_RTX (V4SImode),
1107                                   gen_highpart (SImode, operands[1])));
1108       emit_insn (gen_vec_interleave_lowv4si (operands[0], operands[0],
1109                                              operands[2]));
1110    }
1111  else if (memory_operand (operands[1], DImode))
1112    {
1113      rtx tmp = gen_reg_rtx (V2DImode);
1114      emit_insn (gen_vec_concatv2di (tmp, operands[1], const0_rtx));
1115      emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp));
1116    }
1117  else
1118    gcc_unreachable ();
1121 (define_split
1122   [(set (match_operand:V4SF 0 "register_operand")
1123         (match_operand:V4SF 1 "zero_extended_scalar_load_operand"))]
1124   "TARGET_SSE && reload_completed"
1125   [(set (match_dup 0)
1126         (vec_merge:V4SF
1127           (vec_duplicate:V4SF (match_dup 1))
1128           (match_dup 2)
1129           (const_int 1)))]
1131   operands[1] = simplify_gen_subreg (SFmode, operands[1], V4SFmode, 0);
1132   operands[2] = CONST0_RTX (V4SFmode);
1135 (define_split
1136   [(set (match_operand:V2DF 0 "register_operand")
1137         (match_operand:V2DF 1 "zero_extended_scalar_load_operand"))]
1138   "TARGET_SSE2 && reload_completed"
1139   [(set (match_dup 0) (vec_concat:V2DF (match_dup 1) (match_dup 2)))]
1141   operands[1] = simplify_gen_subreg (DFmode, operands[1], V2DFmode, 0);
1142   operands[2] = CONST0_RTX (DFmode);
1145 (define_expand "movmisalign<mode>"
1146   [(set (match_operand:VMOVE 0 "nonimmediate_operand")
1147         (match_operand:VMOVE 1 "nonimmediate_operand"))]
1148   "TARGET_SSE"
1150   ix86_expand_vector_move_misalign (<MODE>mode, operands);
1151   DONE;
1154 (define_expand "<sse>_loadu<ssemodesuffix><avxsizesuffix><mask_name>"
1155   [(set (match_operand:VF 0 "register_operand")
1156         (unspec:VF [(match_operand:VF 1 "nonimmediate_operand")]
1157           UNSPEC_LOADU))]
1158   "TARGET_SSE && <mask_mode512bit_condition>"
1160   /* For AVX, normal *mov<mode>_internal pattern will handle unaligned loads
1161      just fine if misaligned_operand is true, and without the UNSPEC it can
1162      be combined with arithmetic instructions.  If misaligned_operand is
1163      false, still emit UNSPEC_LOADU insn to honor user's request for
1164      misaligned load.  */
1165   if (TARGET_AVX
1166       && misaligned_operand (operands[1], <MODE>mode))
1167     {
1168       rtx src = operands[1];
1169       if (<mask_applied>)
1170         src = gen_rtx_VEC_MERGE (<MODE>mode, operands[1],
1171                                  operands[2 * <mask_applied>],
1172                                  operands[3 * <mask_applied>]);
1173       emit_insn (gen_rtx_SET (operands[0], src));
1174       DONE;
1175     }
1178 (define_insn "*<sse>_loadu<ssemodesuffix><avxsizesuffix><mask_name>"
1179   [(set (match_operand:VF 0 "register_operand" "=v")
1180         (unspec:VF
1181           [(match_operand:VF 1 "nonimmediate_operand" "vm")]
1182           UNSPEC_LOADU))]
1183   "TARGET_SSE && <mask_mode512bit_condition>"
1185   switch (get_attr_mode (insn))
1186     {
1187     case MODE_V16SF:
1188     case MODE_V8SF:
1189     case MODE_V4SF:
1190       return "%vmovups\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
1191     default:
1192       return "%vmovu<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
1193     }
1195   [(set_attr "type" "ssemov")
1196    (set_attr "movu" "1")
1197    (set_attr "ssememalign" "8")
1198    (set_attr "prefix" "maybe_vex")
1199    (set (attr "mode")
1200         (cond [(and (match_test "<MODE_SIZE> == 16")
1201                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
1202                  (const_string "<ssePSmode>")
1203                (match_test "TARGET_AVX")
1204                  (const_string "<MODE>")
1205                (match_test "optimize_function_for_size_p (cfun)")
1206                  (const_string "V4SF")
1207               ]
1208               (const_string "<MODE>")))])
1210 ;; Merge movsd/movhpd to movupd for TARGET_SSE_UNALIGNED_LOAD_OPTIMAL targets.
1211 (define_peephole2
1212   [(set (match_operand:V2DF 0 "register_operand")
1213         (vec_concat:V2DF (match_operand:DF 1 "memory_operand")
1214                          (match_operand:DF 4 "const0_operand")))
1215    (set (match_operand:V2DF 2 "register_operand")
1216         (vec_concat:V2DF (vec_select:DF (match_dup 2)
1217                                         (parallel [(const_int 0)]))
1218                          (match_operand:DF 3 "memory_operand")))]
1219   "TARGET_SSE2 && TARGET_SSE_UNALIGNED_LOAD_OPTIMAL
1220    && ix86_operands_ok_for_move_multiple (operands, true, DFmode)"
1221   [(set (match_dup 2)
1222         (unspec:V2DF [(match_dup 4)] UNSPEC_LOADU))]
1223   "operands[4] = adjust_address (operands[1], V2DFmode, 0);")
1225 (define_insn "<sse>_storeu<ssemodesuffix><avxsizesuffix>"
1226   [(set (match_operand:VF 0 "memory_operand" "=m")
1227         (unspec:VF
1228           [(match_operand:VF 1 "register_operand" "v")]
1229           UNSPEC_STOREU))]
1230   "TARGET_SSE"
1232   switch (get_attr_mode (insn))
1233     {
1234     case MODE_V16SF:
1235     case MODE_V8SF:
1236     case MODE_V4SF:
1237       return "%vmovups\t{%1, %0|%0, %1}";
1238     default:
1239       return "%vmovu<ssemodesuffix>\t{%1, %0|%0, %1}";
1240     }
1242   [(set_attr "type" "ssemov")
1243    (set_attr "movu" "1")
1244    (set_attr "ssememalign" "8")
1245    (set_attr "prefix" "maybe_vex")
1246    (set (attr "mode")
1247         (cond [(and (match_test "<MODE_SIZE> == 16")
1248                     (ior (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
1249                          (match_test "TARGET_SSE_TYPELESS_STORES")))
1250                  (const_string "<ssePSmode>")
1251                (match_test "TARGET_AVX")
1252                  (const_string "<MODE>")
1253                (match_test "optimize_function_for_size_p (cfun)")
1254                  (const_string "V4SF")
1255               ]
1256               (const_string "<MODE>")))])
1258 (define_insn "<avx512>_storeu<ssemodesuffix><avxsizesuffix>_mask"
1259   [(set (match_operand:VF_AVX512VL 0 "memory_operand" "=m")
1260         (vec_merge:VF_AVX512VL
1261           (unspec:VF_AVX512VL
1262             [(match_operand:VF_AVX512VL 1 "register_operand" "v")]
1263             UNSPEC_STOREU)
1264           (match_dup 0)
1265           (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1266   "TARGET_AVX512F"
1268   switch (get_attr_mode (insn))
1269     {
1270     case MODE_V16SF:
1271     case MODE_V8SF:
1272     case MODE_V4SF:
1273       return "vmovups\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1274     default:
1275       return "vmovu<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1276     }
1278   [(set_attr "type" "ssemov")
1279    (set_attr "movu" "1")
1280    (set_attr "memory" "store")
1281    (set_attr "prefix" "evex")
1282    (set_attr "mode" "<sseinsnmode>")])
1284 ;; Merge movlpd/movhpd to movupd for TARGET_SSE_UNALIGNED_STORE_OPTIMAL targets.
1285 (define_peephole2
1286   [(set (match_operand:DF 0 "memory_operand")
1287         (vec_select:DF (match_operand:V2DF 1 "register_operand")
1288                        (parallel [(const_int 0)])))
1289    (set (match_operand:DF 2 "memory_operand")
1290         (vec_select:DF (match_operand:V2DF 3 "register_operand")
1291                        (parallel [(const_int 1)])))]
1292   "TARGET_SSE2 && TARGET_SSE_UNALIGNED_STORE_OPTIMAL
1293    && ix86_operands_ok_for_move_multiple (operands, false, DFmode)"
1294   [(set (match_dup 4)
1295         (unspec:V2DF [(match_dup 1)] UNSPEC_STOREU))]
1296   "operands[4] = adjust_address (operands[0], V2DFmode, 0);")
1298 /* For AVX, normal *mov<mode>_internal pattern will handle unaligned loads
1299    just fine if misaligned_operand is true, and without the UNSPEC it can
1300    be combined with arithmetic instructions.  If misaligned_operand is
1301    false, still emit UNSPEC_LOADU insn to honor user's request for
1302    misaligned load.  */
1303 (define_expand "<sse2_avx_avx512f>_loaddqu<mode><mask_name>"
1304   [(set (match_operand:VI1 0 "register_operand")
1305         (unspec:VI1
1306           [(match_operand:VI1 1 "nonimmediate_operand")]
1307           UNSPEC_LOADU))]
1308   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
1310   if (TARGET_AVX
1311       && misaligned_operand (operands[1], <MODE>mode))
1312     {
1313       rtx src = operands[1];
1314       if (<mask_applied>)
1315         src = gen_rtx_VEC_MERGE (<MODE>mode, operands[1],
1316                                  operands[2 * <mask_applied>],
1317                                  operands[3 * <mask_applied>]);
1318       emit_insn (gen_rtx_SET (operands[0], src));
1319       DONE;
1320     }
1323 (define_expand "<sse2_avx_avx512f>_loaddqu<mode><mask_name>"
1324   [(set (match_operand:VI_ULOADSTORE_BW_AVX512VL 0 "register_operand")
1325         (unspec:VI_ULOADSTORE_BW_AVX512VL
1326           [(match_operand:VI_ULOADSTORE_BW_AVX512VL 1 "nonimmediate_operand")]
1327           UNSPEC_LOADU))]
1328   "TARGET_AVX512BW"
1330   if (misaligned_operand (operands[1], <MODE>mode))
1331     {
1332       rtx src = operands[1];
1333       if (<mask_applied>)
1334         src = gen_rtx_VEC_MERGE (<MODE>mode, operands[1],
1335                                  operands[2 * <mask_applied>],
1336                                  operands[3 * <mask_applied>]);
1337       emit_insn (gen_rtx_SET (operands[0], src));
1338       DONE;
1339     }
1342 (define_expand "<sse2_avx_avx512f>_loaddqu<mode><mask_name>"
1343   [(set (match_operand:VI_ULOADSTORE_F_AVX512VL 0 "register_operand")
1344         (unspec:VI_ULOADSTORE_F_AVX512VL
1345           [(match_operand:VI_ULOADSTORE_F_AVX512VL 1 "nonimmediate_operand")]
1346           UNSPEC_LOADU))]
1347   "TARGET_AVX512F"
1349   if (misaligned_operand (operands[1], <MODE>mode))
1350     {
1351       rtx src = operands[1];
1352       if (<mask_applied>)
1353         src = gen_rtx_VEC_MERGE (<MODE>mode, operands[1],
1354                                  operands[2 * <mask_applied>],
1355                                  operands[3 * <mask_applied>]);
1356       emit_insn (gen_rtx_SET (operands[0], src));
1357       DONE;
1358     }
1361 (define_insn "*<sse2_avx_avx512f>_loaddqu<mode><mask_name>"
1362   [(set (match_operand:VI1 0 "register_operand" "=v")
1363         (unspec:VI1
1364           [(match_operand:VI1 1 "nonimmediate_operand" "vm")]
1365           UNSPEC_LOADU))]
1366   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
1368   switch (get_attr_mode (insn))
1369     {
1370     case MODE_V8SF:
1371     case MODE_V4SF:
1372       return "%vmovups\t{%1, %0|%0, %1}";
1373     default:
1374       if (!(TARGET_AVX512VL && TARGET_AVX512BW))
1375         return "%vmovdqu\t{%1, %0|%0, %1}";
1376       else
1377         return "vmovdqu<ssescalarsize>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
1378     }
1380   [(set_attr "type" "ssemov")
1381    (set_attr "movu" "1")
1382    (set_attr "ssememalign" "8")
1383    (set (attr "prefix_data16")
1384      (if_then_else
1385        (match_test "TARGET_AVX")
1386      (const_string "*")
1387      (const_string "1")))
1388    (set_attr "prefix" "maybe_vex")
1389    (set (attr "mode")
1390         (cond [(and (match_test "<MODE_SIZE> == 16")
1391                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
1392                  (const_string "<ssePSmode>")
1393                (match_test "TARGET_AVX")
1394                  (const_string "<sseinsnmode>")
1395                (match_test "optimize_function_for_size_p (cfun)")
1396                  (const_string "V4SF")
1397               ]
1398               (const_string "<sseinsnmode>")))])
1400 (define_insn "*<sse2_avx_avx512f>_loaddqu<mode><mask_name>"
1401   [(set (match_operand:VI_ULOADSTORE_BW_AVX512VL 0 "register_operand" "=v")
1402         (unspec:VI_ULOADSTORE_BW_AVX512VL
1403           [(match_operand:VI_ULOADSTORE_BW_AVX512VL 1 "nonimmediate_operand" "vm")]
1404           UNSPEC_LOADU))]
1405   "TARGET_AVX512BW"
1406   "vmovdqu<ssescalarsize>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
1407   [(set_attr "type" "ssemov")
1408    (set_attr "movu" "1")
1409    (set_attr "ssememalign" "8")
1410    (set_attr "prefix" "maybe_evex")])
1412 (define_insn "*<sse2_avx_avx512f>_loaddqu<mode><mask_name>"
1413   [(set (match_operand:VI_ULOADSTORE_F_AVX512VL 0 "register_operand" "=v")
1414         (unspec:VI_ULOADSTORE_F_AVX512VL
1415           [(match_operand:VI_ULOADSTORE_F_AVX512VL 1 "nonimmediate_operand" "vm")]
1416           UNSPEC_LOADU))]
1417   "TARGET_AVX512F"
1418   "vmovdqu<ssescalarsize>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
1419   [(set_attr "type" "ssemov")
1420    (set_attr "movu" "1")
1421    (set_attr "ssememalign" "8")
1422    (set_attr "prefix" "maybe_evex")])
1424 (define_insn "<sse2_avx_avx512f>_storedqu<mode>"
1425   [(set (match_operand:VI1 0 "memory_operand" "=m")
1426         (unspec:VI1
1427           [(match_operand:VI1 1 "register_operand" "v")]
1428           UNSPEC_STOREU))]
1429   "TARGET_SSE2"
1431   switch (get_attr_mode (insn))
1432     {
1433     case MODE_V16SF:
1434     case MODE_V8SF:
1435     case MODE_V4SF:
1436       return "%vmovups\t{%1, %0|%0, %1}";
1437     default:
1438       switch (<MODE>mode)
1439       {
1440       case V32QImode:
1441       case V16QImode:
1442         if (!(TARGET_AVX512VL && TARGET_AVX512BW))
1443           return "%vmovdqu\t{%1, %0|%0, %1}";
1444       default:
1445           return "vmovdqu<ssescalarsize>\t{%1, %0|%0, %1}";
1446       }
1447     }
1449   [(set_attr "type" "ssemov")
1450    (set_attr "movu" "1")
1451    (set_attr "ssememalign" "8")
1452    (set (attr "prefix_data16")
1453      (if_then_else
1454        (match_test "TARGET_AVX")
1455      (const_string "*")
1456      (const_string "1")))
1457    (set_attr "prefix" "maybe_vex")
1458    (set (attr "mode")
1459         (cond [(and (match_test "<MODE_SIZE> == 16")
1460                     (ior (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
1461                          (match_test "TARGET_SSE_TYPELESS_STORES")))
1462                  (const_string "<ssePSmode>")
1463                (match_test "TARGET_AVX")
1464                  (const_string "<sseinsnmode>")
1465                (match_test "optimize_function_for_size_p (cfun)")
1466                  (const_string "V4SF")
1467               ]
1468               (const_string "<sseinsnmode>")))])
1470 (define_insn "<sse2_avx_avx512f>_storedqu<mode>"
1471   [(set (match_operand:VI_ULOADSTORE_BW_AVX512VL 0 "memory_operand" "=m")
1472         (unspec:VI_ULOADSTORE_BW_AVX512VL
1473           [(match_operand:VI_ULOADSTORE_BW_AVX512VL 1 "register_operand" "v")]
1474           UNSPEC_STOREU))]
1475   "TARGET_AVX512BW"
1476   "vmovdqu<ssescalarsize>\t{%1, %0|%0, %1}"
1477   [(set_attr "type" "ssemov")
1478    (set_attr "movu" "1")
1479    (set_attr "ssememalign" "8")
1480    (set_attr "prefix" "maybe_evex")])
1482 (define_insn "<sse2_avx_avx512f>_storedqu<mode>"
1483   [(set (match_operand:VI_ULOADSTORE_F_AVX512VL 0 "memory_operand" "=m")
1484         (unspec:VI_ULOADSTORE_F_AVX512VL
1485           [(match_operand:VI_ULOADSTORE_F_AVX512VL 1 "register_operand" "v")]
1486           UNSPEC_STOREU))]
1487   "TARGET_AVX512F"
1488   "vmovdqu<ssescalarsize>\t{%1, %0|%0, %1}"
1489   [(set_attr "type" "ssemov")
1490    (set_attr "movu" "1")
1491    (set_attr "ssememalign" "8")
1492    (set_attr "prefix" "maybe_vex")])
1494 (define_insn "<avx512>_storedqu<mode>_mask"
1495   [(set (match_operand:VI48_AVX512VL 0 "memory_operand" "=m")
1496         (vec_merge:VI48_AVX512VL
1497           (unspec:VI48_AVX512VL
1498             [(match_operand:VI48_AVX512VL 1 "register_operand" "v")]
1499             UNSPEC_STOREU)
1500           (match_dup 0)
1501           (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1502   "TARGET_AVX512F"
1503   "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
1504   [(set_attr "type" "ssemov")
1505    (set_attr "movu" "1")
1506    (set_attr "memory" "store")
1507    (set_attr "prefix" "evex")
1508    (set_attr "mode" "<sseinsnmode>")])
1510 (define_insn "<avx512>_storedqu<mode>_mask"
1511   [(set (match_operand:VI12_AVX512VL 0 "memory_operand" "=m")
1512         (vec_merge:VI12_AVX512VL
1513           (unspec:VI12_AVX512VL
1514             [(match_operand:VI12_AVX512VL 1 "register_operand" "v")]
1515             UNSPEC_STOREU)
1516           (match_dup 0)
1517           (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1518   "TARGET_AVX512BW"
1519   "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
1520   [(set_attr "type" "ssemov")
1521    (set_attr "movu" "1")
1522    (set_attr "memory" "store")
1523    (set_attr "prefix" "evex")
1524    (set_attr "mode" "<sseinsnmode>")])
1526 (define_insn "<sse3>_lddqu<avxsizesuffix>"
1527   [(set (match_operand:VI1 0 "register_operand" "=x")
1528         (unspec:VI1 [(match_operand:VI1 1 "memory_operand" "m")]
1529                     UNSPEC_LDDQU))]
1530   "TARGET_SSE3"
1531   "%vlddqu\t{%1, %0|%0, %1}"
1532   [(set_attr "type" "ssemov")
1533    (set_attr "movu" "1")
1534    (set_attr "ssememalign" "8")
1535    (set (attr "prefix_data16")
1536      (if_then_else
1537        (match_test "TARGET_AVX")
1538      (const_string "*")
1539      (const_string "0")))
1540    (set (attr "prefix_rep")
1541      (if_then_else
1542        (match_test "TARGET_AVX")
1543      (const_string "*")
1544      (const_string "1")))
1545    (set_attr "prefix" "maybe_vex")
1546    (set_attr "mode" "<sseinsnmode>")])
1548 (define_insn "sse2_movnti<mode>"
1549   [(set (match_operand:SWI48 0 "memory_operand" "=m")
1550         (unspec:SWI48 [(match_operand:SWI48 1 "register_operand" "r")]
1551                       UNSPEC_MOVNT))]
1552   "TARGET_SSE2"
1553   "movnti\t{%1, %0|%0, %1}"
1554   [(set_attr "type" "ssemov")
1555    (set_attr "prefix_data16" "0")
1556    (set_attr "mode" "<MODE>")])
1558 (define_insn "<sse>_movnt<mode>"
1559   [(set (match_operand:VF 0 "memory_operand" "=m")
1560         (unspec:VF
1561           [(match_operand:VF 1 "register_operand" "v")]
1562           UNSPEC_MOVNT))]
1563   "TARGET_SSE"
1564   "%vmovnt<ssemodesuffix>\t{%1, %0|%0, %1}"
1565   [(set_attr "type" "ssemov")
1566    (set_attr "prefix" "maybe_vex")
1567    (set_attr "mode" "<MODE>")])
1569 (define_insn "<sse2>_movnt<mode>"
1570   [(set (match_operand:VI8 0 "memory_operand" "=m")
1571         (unspec:VI8 [(match_operand:VI8 1 "register_operand" "v")]
1572                     UNSPEC_MOVNT))]
1573   "TARGET_SSE2"
1574   "%vmovntdq\t{%1, %0|%0, %1}"
1575   [(set_attr "type" "ssecvt")
1576    (set (attr "prefix_data16")
1577      (if_then_else
1578        (match_test "TARGET_AVX")
1579      (const_string "*")
1580      (const_string "1")))
1581    (set_attr "prefix" "maybe_vex")
1582    (set_attr "mode" "<sseinsnmode>")])
1584 ; Expand patterns for non-temporal stores.  At the moment, only those
1585 ; that directly map to insns are defined; it would be possible to
1586 ; define patterns for other modes that would expand to several insns.
1588 ;; Modes handled by storent patterns.
1589 (define_mode_iterator STORENT_MODE
1590   [(DI "TARGET_SSE2 && TARGET_64BIT") (SI "TARGET_SSE2")
1591    (SF "TARGET_SSE4A") (DF "TARGET_SSE4A")
1592    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") (V2DI "TARGET_SSE2")
1593    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
1594    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
1596 (define_expand "storent<mode>"
1597   [(set (match_operand:STORENT_MODE 0 "memory_operand")
1598         (unspec:STORENT_MODE
1599           [(match_operand:STORENT_MODE 1 "register_operand")]
1600           UNSPEC_MOVNT))]
1601   "TARGET_SSE")
1603 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1605 ;; Parallel floating point arithmetic
1607 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1609 (define_expand "<code><mode>2"
1610   [(set (match_operand:VF 0 "register_operand")
1611         (absneg:VF
1612           (match_operand:VF 1 "register_operand")))]
1613   "TARGET_SSE"
1614   "ix86_expand_fp_absneg_operator (<CODE>, <MODE>mode, operands); DONE;")
1616 (define_insn_and_split "*absneg<mode>2"
1617   [(set (match_operand:VF 0 "register_operand" "=x,x,v,v")
1618         (match_operator:VF 3 "absneg_operator"
1619           [(match_operand:VF 1 "vector_operand" "0,  xBm,v, m")]))
1620    (use (match_operand:VF 2 "vector_operand"    "xBm,0,  vm,v"))]
1621   "TARGET_SSE"
1622   "#"
1623   "&& reload_completed"
1624   [(const_int 0)]
1626   enum rtx_code absneg_op;
1627   rtx op1, op2;
1628   rtx t;
1630   if (TARGET_AVX)
1631     {
1632       if (MEM_P (operands[1]))
1633         op1 = operands[2], op2 = operands[1];
1634       else
1635         op1 = operands[1], op2 = operands[2];
1636     }
1637   else
1638     {
1639       op1 = operands[0];
1640       if (rtx_equal_p (operands[0], operands[1]))
1641         op2 = operands[2];
1642       else
1643         op2 = operands[1];
1644     }
1646   absneg_op = GET_CODE (operands[3]) == NEG ? XOR : AND;
1647   t = gen_rtx_fmt_ee (absneg_op, <MODE>mode, op1, op2);
1648   t = gen_rtx_SET (operands[0], t);
1649   emit_insn (t);
1650   DONE;
1652   [(set_attr "isa" "noavx,noavx,avx,avx")])
1654 (define_expand "<plusminus_insn><mode>3<mask_name><round_name>"
1655   [(set (match_operand:VF 0 "register_operand")
1656         (plusminus:VF
1657           (match_operand:VF 1 "<round_nimm_predicate>")
1658           (match_operand:VF 2 "<round_nimm_predicate>")))]
1659   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1660   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
1662 (define_insn "*<plusminus_insn><mode>3<mask_name><round_name>"
1663   [(set (match_operand:VF 0 "register_operand" "=x,v")
1664         (plusminus:VF
1665           (match_operand:VF 1 "<round_nimm_predicate>" "<comm>0,v")
1666           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1667   "TARGET_SSE && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands) && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1668   "@
1669    <plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
1670    v<plusminus_mnemonic><ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1671   [(set_attr "isa" "noavx,avx")
1672    (set_attr "type" "sseadd")
1673    (set_attr "prefix" "<mask_prefix3>")
1674    (set_attr "mode" "<MODE>")])
1676 (define_insn "<sse>_vm<plusminus_insn><mode>3<round_name>"
1677   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1678         (vec_merge:VF_128
1679           (plusminus:VF_128
1680             (match_operand:VF_128 1 "register_operand" "0,v")
1681             (match_operand:VF_128 2 "vector_operand" "xBm,<round_constraint>"))
1682           (match_dup 1)
1683           (const_int 1)))]
1684   "TARGET_SSE"
1685   "@
1686    <plusminus_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
1687    v<plusminus_mnemonic><ssescalarmodesuffix>\t{<round_op3>%2, %1, %0|%0, %1, %<iptr>2<round_op3>}"
1688   [(set_attr "isa" "noavx,avx")
1689    (set_attr "type" "sseadd")
1690    (set_attr "prefix" "<round_prefix>")
1691    (set_attr "mode" "<ssescalarmode>")])
1693 (define_expand "mul<mode>3<mask_name><round_name>"
1694   [(set (match_operand:VF 0 "register_operand")
1695         (mult:VF
1696           (match_operand:VF 1 "<round_nimm_predicate>")
1697           (match_operand:VF 2 "<round_nimm_predicate>")))]
1698   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1699   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
1701 (define_insn "*mul<mode>3<mask_name><round_name>"
1702   [(set (match_operand:VF 0 "register_operand" "=x,v")
1703         (mult:VF
1704           (match_operand:VF 1 "<round_nimm_predicate>" "%0,v")
1705           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1706   "TARGET_SSE && ix86_binary_operator_ok (MULT, <MODE>mode, operands) && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1707   "@
1708    mul<ssemodesuffix>\t{%2, %0|%0, %2}
1709    vmul<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1710   [(set_attr "isa" "noavx,avx")
1711    (set_attr "type" "ssemul")
1712    (set_attr "prefix" "<mask_prefix3>")
1713    (set_attr "btver2_decode" "direct,double")
1714    (set_attr "mode" "<MODE>")])
1716 (define_insn "<sse>_vm<multdiv_mnemonic><mode>3<round_name>"
1717   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1718         (vec_merge:VF_128
1719           (multdiv:VF_128
1720             (match_operand:VF_128 1 "register_operand" "0,v")
1721             (match_operand:VF_128 2 "vector_operand" "xBm,<round_constraint>"))
1722           (match_dup 1)
1723           (const_int 1)))]
1724   "TARGET_SSE"
1725   "@
1726    <multdiv_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
1727    v<multdiv_mnemonic><ssescalarmodesuffix>\t{<round_op3>%2, %1, %0|%0, %1, %<iptr>2<round_op3>}"
1728   [(set_attr "isa" "noavx,avx")
1729    (set_attr "type" "sse<multdiv_mnemonic>")
1730    (set_attr "prefix" "<round_prefix>")
1731    (set_attr "btver2_decode" "direct,double")
1732    (set_attr "mode" "<ssescalarmode>")])
1734 (define_expand "div<mode>3"
1735   [(set (match_operand:VF2 0 "register_operand")
1736         (div:VF2 (match_operand:VF2 1 "register_operand")
1737                  (match_operand:VF2 2 "vector_operand")))]
1738   "TARGET_SSE2"
1739   "ix86_fixup_binary_operands_no_copy (DIV, <MODE>mode, operands);")
1741 (define_expand "div<mode>3"
1742   [(set (match_operand:VF1 0 "register_operand")
1743         (div:VF1 (match_operand:VF1 1 "register_operand")
1744                  (match_operand:VF1 2 "vector_operand")))]
1745   "TARGET_SSE"
1747   ix86_fixup_binary_operands_no_copy (DIV, <MODE>mode, operands);
1749   if (TARGET_SSE_MATH
1750       && TARGET_RECIP_VEC_DIV
1751       && !optimize_insn_for_size_p ()
1752       && flag_finite_math_only && !flag_trapping_math
1753       && flag_unsafe_math_optimizations)
1754     {
1755       ix86_emit_swdivsf (operands[0], operands[1], operands[2], <MODE>mode);
1756       DONE;
1757     }
1760 (define_insn "<sse>_div<mode>3<mask_name><round_name>"
1761   [(set (match_operand:VF 0 "register_operand" "=x,v")
1762         (div:VF
1763           (match_operand:VF 1 "register_operand" "0,v")
1764           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1765   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1766   "@
1767    div<ssemodesuffix>\t{%2, %0|%0, %2}
1768    vdiv<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1769   [(set_attr "isa" "noavx,avx")
1770    (set_attr "type" "ssediv")
1771    (set_attr "prefix" "<mask_prefix3>")
1772    (set_attr "mode" "<MODE>")])
1774 (define_insn "<sse>_rcp<mode>2"
1775   [(set (match_operand:VF1_128_256 0 "register_operand" "=x")
1776         (unspec:VF1_128_256
1777           [(match_operand:VF1_128_256 1 "vector_operand" "xBm")] UNSPEC_RCP))]
1778   "TARGET_SSE"
1779   "%vrcpps\t{%1, %0|%0, %1}"
1780   [(set_attr "type" "sse")
1781    (set_attr "atom_sse_attr" "rcp")
1782    (set_attr "btver2_sse_attr" "rcp")
1783    (set_attr "prefix" "maybe_vex")
1784    (set_attr "mode" "<MODE>")])
1786 (define_insn "sse_vmrcpv4sf2"
1787   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
1788         (vec_merge:V4SF
1789           (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,xm")]
1790                        UNSPEC_RCP)
1791           (match_operand:V4SF 2 "register_operand" "0,x")
1792           (const_int 1)))]
1793   "TARGET_SSE"
1794   "@
1795    rcpss\t{%1, %0|%0, %k1}
1796    vrcpss\t{%1, %2, %0|%0, %2, %k1}"
1797   [(set_attr "isa" "noavx,avx")
1798    (set_attr "type" "sse")
1799    (set_attr "ssememalign" "32")
1800    (set_attr "atom_sse_attr" "rcp")
1801    (set_attr "btver2_sse_attr" "rcp")
1802    (set_attr "prefix" "orig,vex")
1803    (set_attr "mode" "SF")])
1805 (define_insn "<mask_codefor>rcp14<mode><mask_name>"
1806   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
1807         (unspec:VF_AVX512VL
1808           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")]
1809           UNSPEC_RCP14))]
1810   "TARGET_AVX512F"
1811   "vrcp14<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
1812   [(set_attr "type" "sse")
1813    (set_attr "prefix" "evex")
1814    (set_attr "mode" "<MODE>")])
1816 (define_insn "srcp14<mode>"
1817   [(set (match_operand:VF_128 0 "register_operand" "=v")
1818         (vec_merge:VF_128
1819           (unspec:VF_128
1820             [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1821             UNSPEC_RCP14)
1822           (match_operand:VF_128 2 "register_operand" "v")
1823           (const_int 1)))]
1824   "TARGET_AVX512F"
1825   "vrcp14<ssescalarmodesuffix>\t{%1, %2, %0|%0, %2, %1}"
1826   [(set_attr "type" "sse")
1827    (set_attr "prefix" "evex")
1828    (set_attr "mode" "<MODE>")])
1830 (define_expand "sqrt<mode>2"
1831   [(set (match_operand:VF2 0 "register_operand")
1832         (sqrt:VF2 (match_operand:VF2 1 "vector_operand")))]
1833   "TARGET_SSE2")
1835 (define_expand "sqrt<mode>2"
1836   [(set (match_operand:VF1 0 "register_operand")
1837         (sqrt:VF1 (match_operand:VF1 1 "vector_operand")))]
1838   "TARGET_SSE"
1840   if (TARGET_SSE_MATH
1841       && TARGET_RECIP_VEC_SQRT
1842       && !optimize_insn_for_size_p ()
1843       && flag_finite_math_only && !flag_trapping_math
1844       && flag_unsafe_math_optimizations)
1845     {
1846       ix86_emit_swsqrtsf (operands[0], operands[1], <MODE>mode, false);
1847       DONE;
1848     }
1851 (define_insn "<sse>_sqrt<mode>2<mask_name><round_name>"
1852   [(set (match_operand:VF 0 "register_operand" "=x,v")
1853         (sqrt:VF (match_operand:VF 1 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1854   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1855   "@
1856    sqrt<ssemodesuffix>\t{%1, %0|%0, %1}
1857    vsqrt<ssemodesuffix>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
1858   [(set_attr "isa" "noavx,avx")
1859    (set_attr "type" "sse")
1860    (set_attr "atom_sse_attr" "sqrt")
1861    (set_attr "btver2_sse_attr" "sqrt")
1862    (set_attr "prefix" "maybe_vex")
1863    (set_attr "mode" "<MODE>")])
1865 (define_insn "<sse>_vmsqrt<mode>2<round_name>"
1866   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1867         (vec_merge:VF_128
1868           (sqrt:VF_128
1869             (match_operand:VF_128 1 "vector_operand" "xBm,<round_constraint>"))
1870           (match_operand:VF_128 2 "register_operand" "0,v")
1871           (const_int 1)))]
1872   "TARGET_SSE"
1873   "@
1874    sqrt<ssescalarmodesuffix>\t{%1, %0|%0, %<iptr>1}
1875    vsqrt<ssescalarmodesuffix>\t{<round_op3>%1, %2, %0|%0, %2, %<iptr>1<round_op3>}"
1876   [(set_attr "isa" "noavx,avx")
1877    (set_attr "type" "sse")
1878    (set_attr "atom_sse_attr" "sqrt")
1879    (set_attr "prefix" "<round_prefix>")
1880    (set_attr "btver2_sse_attr" "sqrt")
1881    (set_attr "mode" "<ssescalarmode>")])
1883 (define_expand "rsqrt<mode>2"
1884   [(set (match_operand:VF1_128_256 0 "register_operand")
1885         (unspec:VF1_128_256
1886           [(match_operand:VF1_128_256 1 "vector_operand")] UNSPEC_RSQRT))]
1887   "TARGET_SSE_MATH"
1889   ix86_emit_swsqrtsf (operands[0], operands[1], <MODE>mode, true);
1890   DONE;
1893 (define_insn "<sse>_rsqrt<mode>2"
1894   [(set (match_operand:VF1_128_256 0 "register_operand" "=x")
1895         (unspec:VF1_128_256
1896           [(match_operand:VF1_128_256 1 "vector_operand" "xBm")] UNSPEC_RSQRT))]
1897   "TARGET_SSE"
1898   "%vrsqrtps\t{%1, %0|%0, %1}"
1899   [(set_attr "type" "sse")
1900    (set_attr "prefix" "maybe_vex")
1901    (set_attr "mode" "<MODE>")])
1903 (define_insn "<mask_codefor>rsqrt14<mode><mask_name>"
1904   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
1905         (unspec:VF_AVX512VL
1906           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")]
1907           UNSPEC_RSQRT14))]
1908   "TARGET_AVX512F"
1909   "vrsqrt14<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
1910   [(set_attr "type" "sse")
1911    (set_attr "prefix" "evex")
1912    (set_attr "mode" "<MODE>")])
1914 (define_insn "rsqrt14<mode>"
1915   [(set (match_operand:VF_128 0 "register_operand" "=v")
1916         (vec_merge:VF_128
1917           (unspec:VF_128
1918             [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1919             UNSPEC_RSQRT14)
1920           (match_operand:VF_128 2 "register_operand" "v")
1921           (const_int 1)))]
1922   "TARGET_AVX512F"
1923   "vrsqrt14<ssescalarmodesuffix>\t{%1, %2, %0|%0, %2, %1}"
1924   [(set_attr "type" "sse")
1925    (set_attr "prefix" "evex")
1926    (set_attr "mode" "<MODE>")])
1928 (define_insn "sse_vmrsqrtv4sf2"
1929   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
1930         (vec_merge:V4SF
1931           (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,xm")]
1932                        UNSPEC_RSQRT)
1933           (match_operand:V4SF 2 "register_operand" "0,x")
1934           (const_int 1)))]
1935   "TARGET_SSE"
1936   "@
1937    rsqrtss\t{%1, %0|%0, %k1}
1938    vrsqrtss\t{%1, %2, %0|%0, %2, %k1}"
1939   [(set_attr "isa" "noavx,avx")
1940    (set_attr "type" "sse")
1941    (set_attr "ssememalign" "32")
1942    (set_attr "prefix" "orig,vex")
1943    (set_attr "mode" "SF")])
1945 ;; ??? For !flag_finite_math_only, the representation with SMIN/SMAX
1946 ;; isn't really correct, as those rtl operators aren't defined when
1947 ;; applied to NaNs.  Hopefully the optimizers won't get too smart on us.
1949 (define_expand "<code><mode>3<mask_name><round_saeonly_name>"
1950   [(set (match_operand:VF 0 "register_operand")
1951         (smaxmin:VF
1952           (match_operand:VF 1 "<round_saeonly_nimm_predicate>")
1953           (match_operand:VF 2 "<round_saeonly_nimm_predicate>")))]
1954   "TARGET_SSE && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
1956   if (!flag_finite_math_only)
1957     operands[1] = force_reg (<MODE>mode, operands[1]);
1958   ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
1961 (define_insn "*<code><mode>3_finite<mask_name><round_saeonly_name>"
1962   [(set (match_operand:VF 0 "register_operand" "=x,v")
1963         (smaxmin:VF
1964           (match_operand:VF 1 "<round_saeonly_nimm_predicate>" "%0,v")
1965           (match_operand:VF 2 "<round_saeonly_nimm_predicate>" "xBm,<round_saeonly_constraint>")))]
1966   "TARGET_SSE && flag_finite_math_only
1967    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)
1968    && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
1969   "@
1970    <maxmin_float><ssemodesuffix>\t{%2, %0|%0, %2}
1971    v<maxmin_float><ssemodesuffix>\t{<round_saeonly_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_saeonly_mask_op3>}"
1972   [(set_attr "isa" "noavx,avx")
1973    (set_attr "type" "sseadd")
1974    (set_attr "btver2_sse_attr" "maxmin")
1975    (set_attr "prefix" "<mask_prefix3>")
1976    (set_attr "mode" "<MODE>")])
1978 (define_insn "*<code><mode>3<mask_name><round_saeonly_name>"
1979   [(set (match_operand:VF 0 "register_operand" "=x,v")
1980         (smaxmin:VF
1981           (match_operand:VF 1 "register_operand" "0,v")
1982           (match_operand:VF 2 "<round_saeonly_nimm_predicate>" "xBm,<round_saeonly_constraint>")))]
1983   "TARGET_SSE && !flag_finite_math_only
1984    && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
1985   "@
1986    <maxmin_float><ssemodesuffix>\t{%2, %0|%0, %2}
1987    v<maxmin_float><ssemodesuffix>\t{<round_saeonly_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_saeonly_mask_op3>}"
1988   [(set_attr "isa" "noavx,avx")
1989    (set_attr "type" "sseadd")
1990    (set_attr "btver2_sse_attr" "maxmin")
1991    (set_attr "prefix" "<mask_prefix3>")
1992    (set_attr "mode" "<MODE>")])
1994 (define_insn "<sse>_vm<code><mode>3<round_saeonly_name>"
1995   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1996         (vec_merge:VF_128
1997           (smaxmin:VF_128
1998             (match_operand:VF_128 1 "register_operand" "0,v")
1999             (match_operand:VF_128 2 "vector_operand" "xBm,<round_saeonly_constraint>"))
2000          (match_dup 1)
2001          (const_int 1)))]
2002   "TARGET_SSE"
2003   "@
2004    <maxmin_float><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
2005    v<maxmin_float><ssescalarmodesuffix>\t{<round_saeonly_op3>%2, %1, %0|%0, %1, %<iptr>2<round_saeonly_op3>}"
2006   [(set_attr "isa" "noavx,avx")
2007    (set_attr "type" "sse")
2008    (set_attr "btver2_sse_attr" "maxmin")
2009    (set_attr "prefix" "<round_saeonly_prefix>")
2010    (set_attr "mode" "<ssescalarmode>")])
2012 ;; These versions of the min/max patterns implement exactly the operations
2013 ;;   min = (op1 < op2 ? op1 : op2)
2014 ;;   max = (!(op1 < op2) ? op1 : op2)
2015 ;; Their operands are not commutative, and thus they may be used in the
2016 ;; presence of -0.0 and NaN.
2018 (define_insn "*ieee_smin<mode>3"
2019   [(set (match_operand:VF 0 "register_operand" "=x,v")
2020         (unspec:VF
2021           [(match_operand:VF 1 "register_operand" "0,v")
2022            (match_operand:VF 2 "vector_operand" "xBm,vm")]
2023          UNSPEC_IEEE_MIN))]
2024   "TARGET_SSE"
2025   "@
2026    min<ssemodesuffix>\t{%2, %0|%0, %2}
2027    vmin<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2028   [(set_attr "isa" "noavx,avx")
2029    (set_attr "type" "sseadd")
2030    (set_attr "prefix" "orig,vex")
2031    (set_attr "mode" "<MODE>")])
2033 (define_insn "*ieee_smax<mode>3"
2034   [(set (match_operand:VF 0 "register_operand" "=x,v")
2035         (unspec:VF
2036           [(match_operand:VF 1 "register_operand" "0,v")
2037            (match_operand:VF 2 "vector_operand" "xBm,vm")]
2038          UNSPEC_IEEE_MAX))]
2039   "TARGET_SSE"
2040   "@
2041    max<ssemodesuffix>\t{%2, %0|%0, %2}
2042    vmax<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2043   [(set_attr "isa" "noavx,avx")
2044    (set_attr "type" "sseadd")
2045    (set_attr "prefix" "orig,vex")
2046    (set_attr "mode" "<MODE>")])
2048 (define_insn "avx_addsubv4df3"
2049   [(set (match_operand:V4DF 0 "register_operand" "=x")
2050         (vec_merge:V4DF
2051           (minus:V4DF
2052             (match_operand:V4DF 1 "register_operand" "x")
2053             (match_operand:V4DF 2 "nonimmediate_operand" "xm"))
2054           (plus:V4DF (match_dup 1) (match_dup 2))
2055           (const_int 5)))]
2056   "TARGET_AVX"
2057   "vaddsubpd\t{%2, %1, %0|%0, %1, %2}"
2058   [(set_attr "type" "sseadd")
2059    (set_attr "prefix" "vex")
2060    (set_attr "mode" "V4DF")])
2062 (define_insn "sse3_addsubv2df3"
2063   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
2064         (vec_merge:V2DF
2065           (minus:V2DF
2066             (match_operand:V2DF 1 "register_operand" "0,x")
2067             (match_operand:V2DF 2 "vector_operand" "xBm,xm"))
2068           (plus:V2DF (match_dup 1) (match_dup 2))
2069           (const_int 1)))]
2070   "TARGET_SSE3"
2071   "@
2072    addsubpd\t{%2, %0|%0, %2}
2073    vaddsubpd\t{%2, %1, %0|%0, %1, %2}"
2074   [(set_attr "isa" "noavx,avx")
2075    (set_attr "type" "sseadd")
2076    (set_attr "atom_unit" "complex")
2077    (set_attr "prefix" "orig,vex")
2078    (set_attr "mode" "V2DF")])
2080 (define_insn "avx_addsubv8sf3"
2081   [(set (match_operand:V8SF 0 "register_operand" "=x")
2082         (vec_merge:V8SF
2083           (minus:V8SF
2084             (match_operand:V8SF 1 "register_operand" "x")
2085             (match_operand:V8SF 2 "nonimmediate_operand" "xm"))
2086           (plus:V8SF (match_dup 1) (match_dup 2))
2087           (const_int 85)))]
2088   "TARGET_AVX"
2089   "vaddsubps\t{%2, %1, %0|%0, %1, %2}"
2090   [(set_attr "type" "sseadd")
2091    (set_attr "prefix" "vex")
2092    (set_attr "mode" "V8SF")])
2094 (define_insn "sse3_addsubv4sf3"
2095   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
2096         (vec_merge:V4SF
2097           (minus:V4SF
2098             (match_operand:V4SF 1 "register_operand" "0,x")
2099             (match_operand:V4SF 2 "vector_operand" "xBm,xm"))
2100           (plus:V4SF (match_dup 1) (match_dup 2))
2101           (const_int 5)))]
2102   "TARGET_SSE3"
2103   "@
2104    addsubps\t{%2, %0|%0, %2}
2105    vaddsubps\t{%2, %1, %0|%0, %1, %2}"
2106   [(set_attr "isa" "noavx,avx")
2107    (set_attr "type" "sseadd")
2108    (set_attr "prefix" "orig,vex")
2109    (set_attr "prefix_rep" "1,*")
2110    (set_attr "mode" "V4SF")])
2112 (define_split
2113   [(set (match_operand:VF_128_256 0 "register_operand")
2114         (match_operator:VF_128_256 6 "addsub_vm_operator"
2115           [(minus:VF_128_256
2116              (match_operand:VF_128_256 1 "register_operand")
2117              (match_operand:VF_128_256 2 "vector_operand"))
2118            (plus:VF_128_256
2119              (match_operand:VF_128_256 3 "vector_operand")
2120              (match_operand:VF_128_256 4 "vector_operand"))
2121            (match_operand 5 "const_int_operand")]))]
2122   "TARGET_SSE3
2123    && can_create_pseudo_p ()
2124    && ((rtx_equal_p (operands[1], operands[3])
2125         && rtx_equal_p (operands[2], operands[4]))
2126        || (rtx_equal_p (operands[1], operands[4])
2127            && rtx_equal_p (operands[2], operands[3])))"
2128   [(set (match_dup 0)
2129         (vec_merge:VF_128_256
2130           (minus:VF_128_256 (match_dup 1) (match_dup 2))
2131           (plus:VF_128_256 (match_dup 1) (match_dup 2))
2132           (match_dup 5)))])
2134 (define_split
2135   [(set (match_operand:VF_128_256 0 "register_operand")
2136         (match_operator:VF_128_256 6 "addsub_vm_operator"
2137           [(plus:VF_128_256
2138              (match_operand:VF_128_256 1 "vector_operand")
2139              (match_operand:VF_128_256 2 "vector_operand"))
2140            (minus:VF_128_256
2141              (match_operand:VF_128_256 3 "register_operand")
2142              (match_operand:VF_128_256 4 "vector_operand"))
2143            (match_operand 5 "const_int_operand")]))]
2144   "TARGET_SSE3
2145    && can_create_pseudo_p ()
2146    && ((rtx_equal_p (operands[1], operands[3])
2147         && rtx_equal_p (operands[2], operands[4]))
2148        || (rtx_equal_p (operands[1], operands[4])
2149            && rtx_equal_p (operands[2], operands[3])))"
2150   [(set (match_dup 0)
2151         (vec_merge:VF_128_256
2152           (minus:VF_128_256 (match_dup 3) (match_dup 4))
2153           (plus:VF_128_256 (match_dup 3) (match_dup 4))
2154           (match_dup 5)))]
2156   /* Negate mask bits to compensate for swapped PLUS and MINUS RTXes.  */
2157   operands[5]
2158     = GEN_INT (~INTVAL (operands[5])
2159                & ((HOST_WIDE_INT_1U << GET_MODE_NUNITS (<MODE>mode)) - 1));
2162 (define_split
2163   [(set (match_operand:VF_128_256 0 "register_operand")
2164         (match_operator:VF_128_256 7 "addsub_vs_operator"
2165           [(vec_concat:<ssedoublemode>
2166              (minus:VF_128_256
2167                (match_operand:VF_128_256 1 "register_operand")
2168                (match_operand:VF_128_256 2 "vector_operand"))
2169              (plus:VF_128_256
2170                (match_operand:VF_128_256 3 "vector_operand")
2171                (match_operand:VF_128_256 4 "vector_operand")))
2172            (match_parallel 5 "addsub_vs_parallel"
2173              [(match_operand 6 "const_int_operand")])]))]
2174   "TARGET_SSE3
2175    && can_create_pseudo_p ()
2176    && ((rtx_equal_p (operands[1], operands[3])
2177         && rtx_equal_p (operands[2], operands[4]))
2178        || (rtx_equal_p (operands[1], operands[4])
2179            && rtx_equal_p (operands[2], operands[3])))"
2180   [(set (match_dup 0)
2181         (vec_merge:VF_128_256
2182           (minus:VF_128_256 (match_dup 1) (match_dup 2))
2183           (plus:VF_128_256 (match_dup 1) (match_dup 2))
2184           (match_dup 5)))]
2186   int i, nelt = XVECLEN (operands[5], 0);
2187   HOST_WIDE_INT ival = 0;
2189   for (i = 0; i < nelt; i++)
2190     if (INTVAL (XVECEXP (operands[5], 0, i)) < GET_MODE_NUNITS (<MODE>mode))
2191       ival |= HOST_WIDE_INT_1 << i;
2193   operands[5] = GEN_INT (ival);
2196 (define_split
2197   [(set (match_operand:VF_128_256 0 "register_operand")
2198         (match_operator:VF_128_256 7 "addsub_vs_operator"
2199           [(vec_concat:<ssedoublemode>
2200              (plus:VF_128_256
2201                (match_operand:VF_128_256 1 "vector_operand")
2202                (match_operand:VF_128_256 2 "vector_operand"))
2203              (minus:VF_128_256
2204                (match_operand:VF_128_256 3 "register_operand")
2205                (match_operand:VF_128_256 4 "vector_operand")))
2206            (match_parallel 5 "addsub_vs_parallel"
2207              [(match_operand 6 "const_int_operand")])]))]
2208   "TARGET_SSE3
2209    && can_create_pseudo_p ()
2210    && ((rtx_equal_p (operands[1], operands[3])
2211         && rtx_equal_p (operands[2], operands[4]))
2212        || (rtx_equal_p (operands[1], operands[4])
2213            && rtx_equal_p (operands[2], operands[3])))"
2214   [(set (match_dup 0)
2215         (vec_merge:VF_128_256
2216           (minus:VF_128_256 (match_dup 3) (match_dup 4))
2217           (plus:VF_128_256 (match_dup 3) (match_dup 4))
2218           (match_dup 5)))]
2220   int i, nelt = XVECLEN (operands[5], 0);
2221   HOST_WIDE_INT ival = 0;
2223   for (i = 0; i < nelt; i++)
2224     if (INTVAL (XVECEXP (operands[5], 0, i)) >= GET_MODE_NUNITS (<MODE>mode))
2225       ival |= HOST_WIDE_INT_1 << i;
2227   operands[5] = GEN_INT (ival);
2230 (define_insn "avx_h<plusminus_insn>v4df3"
2231   [(set (match_operand:V4DF 0 "register_operand" "=x")
2232         (vec_concat:V4DF
2233           (vec_concat:V2DF
2234             (plusminus:DF
2235               (vec_select:DF
2236                 (match_operand:V4DF 1 "register_operand" "x")
2237                 (parallel [(const_int 0)]))
2238               (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
2239             (plusminus:DF
2240               (vec_select:DF
2241                 (match_operand:V4DF 2 "nonimmediate_operand" "xm")
2242                 (parallel [(const_int 0)]))
2243               (vec_select:DF (match_dup 2) (parallel [(const_int 1)]))))
2244           (vec_concat:V2DF
2245             (plusminus:DF
2246               (vec_select:DF (match_dup 1) (parallel [(const_int 2)]))
2247               (vec_select:DF (match_dup 1) (parallel [(const_int 3)])))
2248             (plusminus:DF
2249               (vec_select:DF (match_dup 2) (parallel [(const_int 2)]))
2250               (vec_select:DF (match_dup 2) (parallel [(const_int 3)]))))))]
2251   "TARGET_AVX"
2252   "vh<plusminus_mnemonic>pd\t{%2, %1, %0|%0, %1, %2}"
2253   [(set_attr "type" "sseadd")
2254    (set_attr "prefix" "vex")
2255    (set_attr "mode" "V4DF")])
2257 (define_expand "sse3_haddv2df3"
2258   [(set (match_operand:V2DF 0 "register_operand")
2259         (vec_concat:V2DF
2260           (plus:DF
2261             (vec_select:DF
2262               (match_operand:V2DF 1 "register_operand")
2263               (parallel [(const_int 0)]))
2264             (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
2265           (plus:DF
2266             (vec_select:DF
2267               (match_operand:V2DF 2 "vector_operand")
2268               (parallel [(const_int 0)]))
2269             (vec_select:DF (match_dup 2) (parallel [(const_int 1)])))))]
2270   "TARGET_SSE3")
2272 (define_insn "*sse3_haddv2df3"
2273   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
2274         (vec_concat:V2DF
2275           (plus:DF
2276             (vec_select:DF
2277               (match_operand:V2DF 1 "register_operand" "0,x")
2278               (parallel [(match_operand:SI 3 "const_0_to_1_operand")]))
2279             (vec_select:DF
2280               (match_dup 1)
2281               (parallel [(match_operand:SI 4 "const_0_to_1_operand")])))
2282           (plus:DF
2283             (vec_select:DF
2284               (match_operand:V2DF 2 "vector_operand" "xBm,xm")
2285               (parallel [(match_operand:SI 5 "const_0_to_1_operand")]))
2286             (vec_select:DF
2287               (match_dup 2)
2288               (parallel [(match_operand:SI 6 "const_0_to_1_operand")])))))]
2289   "TARGET_SSE3
2290    && INTVAL (operands[3]) != INTVAL (operands[4])
2291    && INTVAL (operands[5]) != INTVAL (operands[6])"
2292   "@
2293    haddpd\t{%2, %0|%0, %2}
2294    vhaddpd\t{%2, %1, %0|%0, %1, %2}"
2295   [(set_attr "isa" "noavx,avx")
2296    (set_attr "type" "sseadd")
2297    (set_attr "prefix" "orig,vex")
2298    (set_attr "mode" "V2DF")])
2300 (define_insn "sse3_hsubv2df3"
2301   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
2302         (vec_concat:V2DF
2303           (minus:DF
2304             (vec_select:DF
2305               (match_operand:V2DF 1 "register_operand" "0,x")
2306               (parallel [(const_int 0)]))
2307             (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
2308           (minus:DF
2309             (vec_select:DF
2310               (match_operand:V2DF 2 "vector_operand" "xBm,xm")
2311               (parallel [(const_int 0)]))
2312             (vec_select:DF (match_dup 2) (parallel [(const_int 1)])))))]
2313   "TARGET_SSE3"
2314   "@
2315    hsubpd\t{%2, %0|%0, %2}
2316    vhsubpd\t{%2, %1, %0|%0, %1, %2}"
2317   [(set_attr "isa" "noavx,avx")
2318    (set_attr "type" "sseadd")
2319    (set_attr "prefix" "orig,vex")
2320    (set_attr "mode" "V2DF")])
2322 (define_insn "*sse3_haddv2df3_low"
2323   [(set (match_operand:DF 0 "register_operand" "=x,x")
2324         (plus:DF
2325           (vec_select:DF
2326             (match_operand:V2DF 1 "register_operand" "0,x")
2327             (parallel [(match_operand:SI 2 "const_0_to_1_operand")]))
2328           (vec_select:DF
2329             (match_dup 1)
2330             (parallel [(match_operand:SI 3 "const_0_to_1_operand")]))))]
2331   "TARGET_SSE3
2332    && INTVAL (operands[2]) != INTVAL (operands[3])"
2333   "@
2334    haddpd\t{%0, %0|%0, %0}
2335    vhaddpd\t{%1, %1, %0|%0, %1, %1}"
2336   [(set_attr "isa" "noavx,avx")
2337    (set_attr "type" "sseadd1")
2338    (set_attr "prefix" "orig,vex")
2339    (set_attr "mode" "V2DF")])
2341 (define_insn "*sse3_hsubv2df3_low"
2342   [(set (match_operand:DF 0 "register_operand" "=x,x")
2343         (minus:DF
2344           (vec_select:DF
2345             (match_operand:V2DF 1 "register_operand" "0,x")
2346             (parallel [(const_int 0)]))
2347           (vec_select:DF
2348             (match_dup 1)
2349             (parallel [(const_int 1)]))))]
2350   "TARGET_SSE3"
2351   "@
2352    hsubpd\t{%0, %0|%0, %0}
2353    vhsubpd\t{%1, %1, %0|%0, %1, %1}"
2354   [(set_attr "isa" "noavx,avx")
2355    (set_attr "type" "sseadd1")
2356    (set_attr "prefix" "orig,vex")
2357    (set_attr "mode" "V2DF")])
2359 (define_insn "avx_h<plusminus_insn>v8sf3"
2360   [(set (match_operand:V8SF 0 "register_operand" "=x")
2361         (vec_concat:V8SF
2362           (vec_concat:V4SF
2363             (vec_concat:V2SF
2364               (plusminus:SF
2365                 (vec_select:SF
2366                   (match_operand:V8SF 1 "register_operand" "x")
2367                   (parallel [(const_int 0)]))
2368                 (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
2369               (plusminus:SF
2370                 (vec_select:SF (match_dup 1) (parallel [(const_int 2)]))
2371                 (vec_select:SF (match_dup 1) (parallel [(const_int 3)]))))
2372             (vec_concat:V2SF
2373               (plusminus:SF
2374                 (vec_select:SF
2375                   (match_operand:V8SF 2 "nonimmediate_operand" "xm")
2376                   (parallel [(const_int 0)]))
2377                 (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))
2378               (plusminus:SF
2379                 (vec_select:SF (match_dup 2) (parallel [(const_int 2)]))
2380                 (vec_select:SF (match_dup 2) (parallel [(const_int 3)])))))
2381           (vec_concat:V4SF
2382             (vec_concat:V2SF
2383               (plusminus:SF
2384                 (vec_select:SF (match_dup 1) (parallel [(const_int 4)]))
2385                 (vec_select:SF (match_dup 1) (parallel [(const_int 5)])))
2386               (plusminus:SF
2387                 (vec_select:SF (match_dup 1) (parallel [(const_int 6)]))
2388                 (vec_select:SF (match_dup 1) (parallel [(const_int 7)]))))
2389             (vec_concat:V2SF
2390               (plusminus:SF
2391                 (vec_select:SF (match_dup 2) (parallel [(const_int 4)]))
2392                 (vec_select:SF (match_dup 2) (parallel [(const_int 5)])))
2393               (plusminus:SF
2394                 (vec_select:SF (match_dup 2) (parallel [(const_int 6)]))
2395                 (vec_select:SF (match_dup 2) (parallel [(const_int 7)])))))))]
2396   "TARGET_AVX"
2397   "vh<plusminus_mnemonic>ps\t{%2, %1, %0|%0, %1, %2}"
2398   [(set_attr "type" "sseadd")
2399    (set_attr "prefix" "vex")
2400    (set_attr "mode" "V8SF")])
2402 (define_insn "sse3_h<plusminus_insn>v4sf3"
2403   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
2404         (vec_concat:V4SF
2405           (vec_concat:V2SF
2406             (plusminus:SF
2407               (vec_select:SF
2408                 (match_operand:V4SF 1 "register_operand" "0,x")
2409                 (parallel [(const_int 0)]))
2410               (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
2411             (plusminus:SF
2412               (vec_select:SF (match_dup 1) (parallel [(const_int 2)]))
2413               (vec_select:SF (match_dup 1) (parallel [(const_int 3)]))))
2414           (vec_concat:V2SF
2415             (plusminus:SF
2416               (vec_select:SF
2417                 (match_operand:V4SF 2 "vector_operand" "xBm,xm")
2418                 (parallel [(const_int 0)]))
2419               (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))
2420             (plusminus:SF
2421               (vec_select:SF (match_dup 2) (parallel [(const_int 2)]))
2422               (vec_select:SF (match_dup 2) (parallel [(const_int 3)]))))))]
2423   "TARGET_SSE3"
2424   "@
2425    h<plusminus_mnemonic>ps\t{%2, %0|%0, %2}
2426    vh<plusminus_mnemonic>ps\t{%2, %1, %0|%0, %1, %2}"
2427   [(set_attr "isa" "noavx,avx")
2428    (set_attr "type" "sseadd")
2429    (set_attr "atom_unit" "complex")
2430    (set_attr "prefix" "orig,vex")
2431    (set_attr "prefix_rep" "1,*")
2432    (set_attr "mode" "V4SF")])
2434 (define_expand "reduc_plus_scal_v8df"
2435   [(match_operand:DF 0 "register_operand")
2436    (match_operand:V8DF 1 "register_operand")]
2437   "TARGET_AVX512F"
2439   rtx tmp = gen_reg_rtx (V8DFmode);
2440   ix86_expand_reduc (gen_addv8df3, tmp, operands[1]);
2441   emit_insn (gen_vec_extractv8df (operands[0], tmp, const0_rtx));
2442   DONE;
2445 (define_expand "reduc_plus_scal_v4df"
2446   [(match_operand:DF 0 "register_operand")
2447    (match_operand:V4DF 1 "register_operand")]
2448   "TARGET_AVX"
2450   rtx tmp = gen_reg_rtx (V4DFmode);
2451   rtx tmp2 = gen_reg_rtx (V4DFmode);
2452   rtx vec_res = gen_reg_rtx (V4DFmode);
2453   emit_insn (gen_avx_haddv4df3 (tmp, operands[1], operands[1]));
2454   emit_insn (gen_avx_vperm2f128v4df3 (tmp2, tmp, tmp, GEN_INT (1)));
2455   emit_insn (gen_addv4df3 (vec_res, tmp, tmp2));
2456   emit_insn (gen_vec_extractv4df (operands[0], vec_res, const0_rtx));
2457   DONE;
2460 (define_expand "reduc_plus_scal_v2df"
2461   [(match_operand:DF 0 "register_operand")
2462    (match_operand:V2DF 1 "register_operand")]
2463   "TARGET_SSE3"
2465   rtx tmp = gen_reg_rtx (V2DFmode);
2466   emit_insn (gen_sse3_haddv2df3 (tmp, operands[1], operands[1]));
2467   emit_insn (gen_vec_extractv2df (operands[0], tmp, const0_rtx));
2468   DONE;
2471 (define_expand "reduc_plus_scal_v16sf"
2472   [(match_operand:SF 0 "register_operand")
2473    (match_operand:V16SF 1 "register_operand")]
2474   "TARGET_AVX512F"
2476   rtx tmp = gen_reg_rtx (V16SFmode);
2477   ix86_expand_reduc (gen_addv16sf3, tmp, operands[1]);
2478   emit_insn (gen_vec_extractv16sf (operands[0], tmp, const0_rtx));
2479   DONE;
2482 (define_expand "reduc_plus_scal_v8sf"
2483   [(match_operand:SF 0 "register_operand")
2484    (match_operand:V8SF 1 "register_operand")]
2485   "TARGET_AVX"
2487   rtx tmp = gen_reg_rtx (V8SFmode);
2488   rtx tmp2 = gen_reg_rtx (V8SFmode);
2489   rtx vec_res = gen_reg_rtx (V8SFmode);
2490   emit_insn (gen_avx_haddv8sf3 (tmp, operands[1], operands[1]));
2491   emit_insn (gen_avx_haddv8sf3 (tmp2, tmp, tmp));
2492   emit_insn (gen_avx_vperm2f128v8sf3 (tmp, tmp2, tmp2, GEN_INT (1)));
2493   emit_insn (gen_addv8sf3 (vec_res, tmp, tmp2));
2494   emit_insn (gen_vec_extractv8sf (operands[0], vec_res, const0_rtx));
2495   DONE;
2498 (define_expand "reduc_plus_scal_v4sf"
2499   [(match_operand:SF 0 "register_operand")
2500    (match_operand:V4SF 1 "register_operand")]
2501   "TARGET_SSE"
2503   rtx vec_res = gen_reg_rtx (V4SFmode);
2504   if (TARGET_SSE3)
2505     {
2506       rtx tmp = gen_reg_rtx (V4SFmode);
2507       emit_insn (gen_sse3_haddv4sf3 (tmp, operands[1], operands[1]));
2508       emit_insn (gen_sse3_haddv4sf3 (vec_res, tmp, tmp));
2509     }
2510   else
2511     ix86_expand_reduc (gen_addv4sf3, vec_res, operands[1]);
2512   emit_insn (gen_vec_extractv4sf (operands[0], vec_res, const0_rtx));
2513   DONE;
2516 ;; Modes handled by reduc_sm{in,ax}* patterns.
2517 (define_mode_iterator REDUC_SMINMAX_MODE
2518   [(V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
2519    (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")
2520    (V8SF "TARGET_AVX") (V4DF "TARGET_AVX")
2521    (V4SF "TARGET_SSE") (V64QI "TARGET_AVX512BW")
2522    (V32HI "TARGET_AVX512BW") (V16SI "TARGET_AVX512F")
2523    (V8DI "TARGET_AVX512F") (V16SF "TARGET_AVX512F")
2524    (V8DF "TARGET_AVX512F")])
2526 (define_expand "reduc_<code>_scal_<mode>"
2527   [(smaxmin:REDUC_SMINMAX_MODE
2528      (match_operand:<ssescalarmode> 0 "register_operand")
2529      (match_operand:REDUC_SMINMAX_MODE 1 "register_operand"))]
2530   ""
2532   rtx tmp = gen_reg_rtx (<MODE>mode);
2533   ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
2534   emit_insn (gen_vec_extract<mode> (operands[0], tmp, const0_rtx));
2535   DONE;
2538 (define_expand "reduc_<code>_scal_<mode>"
2539   [(umaxmin:VI_AVX512BW
2540      (match_operand:<ssescalarmode> 0 "register_operand")
2541      (match_operand:VI_AVX512BW 1 "register_operand"))]
2542   "TARGET_AVX512F"
2544   rtx tmp = gen_reg_rtx (<MODE>mode);
2545   ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
2546   emit_insn (gen_vec_extract<mode> (operands[0], tmp, const0_rtx));
2547   DONE;
2550 (define_expand "reduc_<code>_scal_<mode>"
2551   [(umaxmin:VI_256
2552      (match_operand:<ssescalarmode> 0 "register_operand")
2553      (match_operand:VI_256 1 "register_operand"))]
2554   "TARGET_AVX2"
2556   rtx tmp = gen_reg_rtx (<MODE>mode);
2557   ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
2558   emit_insn (gen_vec_extract<mode> (operands[0], tmp, const0_rtx));
2559   DONE;
2562 (define_expand "reduc_umin_scal_v8hi"
2563   [(umin:V8HI
2564      (match_operand:HI 0 "register_operand")
2565      (match_operand:V8HI 1 "register_operand"))]
2566   "TARGET_SSE4_1"
2568   rtx tmp = gen_reg_rtx (V8HImode);
2569   ix86_expand_reduc (gen_uminv8hi3, tmp, operands[1]);
2570   emit_insn (gen_vec_extractv8hi (operands[0], tmp, const0_rtx));
2571   DONE;
2574 (define_insn "<mask_codefor>reducep<mode><mask_name>"
2575   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
2576         (unspec:VF_AVX512VL
2577           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")
2578            (match_operand:SI 2 "const_0_to_255_operand")]
2579           UNSPEC_REDUCE))]
2580   "TARGET_AVX512DQ"
2581   "vreduce<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
2582   [(set_attr "type" "sse")
2583    (set_attr "prefix" "evex")
2584    (set_attr "mode" "<MODE>")])
2586 (define_insn "reduces<mode>"
2587   [(set (match_operand:VF_128 0 "register_operand" "=v")
2588         (vec_merge:VF_128
2589           (unspec:VF_128
2590             [(match_operand:VF_128 1 "register_operand" "v")
2591              (match_operand:VF_128 2 "nonimmediate_operand" "vm")
2592              (match_operand:SI 3 "const_0_to_255_operand")]
2593             UNSPEC_REDUCE)
2594           (match_dup 1)
2595           (const_int 1)))]
2596   "TARGET_AVX512DQ"
2597   "vreduce<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
2598   [(set_attr "type" "sse")
2599    (set_attr "prefix" "evex")
2600    (set_attr "mode" "<MODE>")])
2602 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2604 ;; Parallel floating point comparisons
2606 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2608 (define_insn "avx_cmp<mode>3"
2609   [(set (match_operand:VF_128_256 0 "register_operand" "=x")
2610         (unspec:VF_128_256
2611           [(match_operand:VF_128_256 1 "register_operand" "x")
2612            (match_operand:VF_128_256 2 "nonimmediate_operand" "xm")
2613            (match_operand:SI 3 "const_0_to_31_operand" "n")]
2614           UNSPEC_PCMP))]
2615   "TARGET_AVX"
2616   "vcmp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
2617   [(set_attr "type" "ssecmp")
2618    (set_attr "length_immediate" "1")
2619    (set_attr "prefix" "vex")
2620    (set_attr "mode" "<MODE>")])
2622 (define_insn "avx_vmcmp<mode>3"
2623   [(set (match_operand:VF_128 0 "register_operand" "=x")
2624         (vec_merge:VF_128
2625           (unspec:VF_128
2626             [(match_operand:VF_128 1 "register_operand" "x")
2627              (match_operand:VF_128 2 "nonimmediate_operand" "xm")
2628              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2629             UNSPEC_PCMP)
2630          (match_dup 1)
2631          (const_int 1)))]
2632   "TARGET_AVX"
2633   "vcmp<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %3}"
2634   [(set_attr "type" "ssecmp")
2635    (set_attr "length_immediate" "1")
2636    (set_attr "prefix" "vex")
2637    (set_attr "mode" "<ssescalarmode>")])
2639 (define_insn "*<sse>_maskcmp<mode>3_comm"
2640   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
2641         (match_operator:VF_128_256 3 "sse_comparison_operator"
2642           [(match_operand:VF_128_256 1 "register_operand" "%0,x")
2643            (match_operand:VF_128_256 2 "vector_operand" "xBm,xm")]))]
2644   "TARGET_SSE
2645    && GET_RTX_CLASS (GET_CODE (operands[3])) == RTX_COMM_COMPARE"
2646   "@
2647    cmp%D3<ssemodesuffix>\t{%2, %0|%0, %2}
2648    vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2649   [(set_attr "isa" "noavx,avx")
2650    (set_attr "type" "ssecmp")
2651    (set_attr "length_immediate" "1")
2652    (set_attr "prefix" "orig,vex")
2653    (set_attr "mode" "<MODE>")])
2655 (define_insn "<sse>_maskcmp<mode>3"
2656   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
2657         (match_operator:VF_128_256 3 "sse_comparison_operator"
2658           [(match_operand:VF_128_256 1 "register_operand" "0,x")
2659            (match_operand:VF_128_256 2 "vector_operand" "xBm,xm")]))]
2660   "TARGET_SSE"
2661   "@
2662    cmp%D3<ssemodesuffix>\t{%2, %0|%0, %2}
2663    vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2664   [(set_attr "isa" "noavx,avx")
2665    (set_attr "type" "ssecmp")
2666    (set_attr "length_immediate" "1")
2667    (set_attr "prefix" "orig,vex")
2668    (set_attr "mode" "<MODE>")])
2670 (define_insn "<sse>_vmmaskcmp<mode>3"
2671   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
2672         (vec_merge:VF_128
2673          (match_operator:VF_128 3 "sse_comparison_operator"
2674            [(match_operand:VF_128 1 "register_operand" "0,x")
2675             (match_operand:VF_128 2 "vector_operand" "xBm,xm")])
2676          (match_dup 1)
2677          (const_int 1)))]
2678   "TARGET_SSE"
2679   "@
2680    cmp%D3<ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
2681    vcmp%D3<ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %<iptr>2}"
2682   [(set_attr "isa" "noavx,avx")
2683    (set_attr "type" "ssecmp")
2684    (set_attr "length_immediate" "1,*")
2685    (set_attr "prefix" "orig,vex")
2686    (set_attr "mode" "<ssescalarmode>")])
2688 (define_mode_attr cmp_imm_predicate
2689   [(V16SF "const_0_to_31_operand")  (V8DF "const_0_to_31_operand")
2690    (V16SI "const_0_to_7_operand")   (V8DI "const_0_to_7_operand")
2691    (V8SF "const_0_to_31_operand")   (V4DF "const_0_to_31_operand")
2692    (V8SI "const_0_to_7_operand")    (V4DI "const_0_to_7_operand")
2693    (V4SF "const_0_to_31_operand")   (V2DF "const_0_to_31_operand")
2694    (V4SI "const_0_to_7_operand")    (V2DI "const_0_to_7_operand")
2695    (V32HI "const_0_to_7_operand")   (V64QI "const_0_to_7_operand")
2696    (V16HI "const_0_to_7_operand")   (V32QI "const_0_to_7_operand")
2697    (V8HI "const_0_to_7_operand")    (V16QI "const_0_to_7_operand")])
2699 (define_insn "<avx512>_cmp<mode>3<mask_scalar_merge_name><round_saeonly_name>"
2700   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2701         (unspec:<avx512fmaskmode>
2702           [(match_operand:V48_AVX512VL 1 "register_operand" "v")
2703            (match_operand:V48_AVX512VL 2 "nonimmediate_operand" "<round_saeonly_constraint>")
2704            (match_operand:SI 3 "<cmp_imm_predicate>" "n")]
2705           UNSPEC_PCMP))]
2706   "TARGET_AVX512F && <round_saeonly_mode512bit_condition>"
2707   "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}"
2708   [(set_attr "type" "ssecmp")
2709    (set_attr "length_immediate" "1")
2710    (set_attr "prefix" "evex")
2711    (set_attr "mode" "<sseinsnmode>")])
2713 (define_insn "<avx512>_cmp<mode>3<mask_scalar_merge_name>"
2714   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2715         (unspec:<avx512fmaskmode>
2716           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
2717            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
2718            (match_operand:SI 3 "<cmp_imm_predicate>" "n")]
2719           UNSPEC_PCMP))]
2720   "TARGET_AVX512BW"
2721   "vpcmp<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2722   [(set_attr "type" "ssecmp")
2723    (set_attr "length_immediate" "1")
2724    (set_attr "prefix" "evex")
2725    (set_attr "mode" "<sseinsnmode>")])
2727 (define_insn "<avx512>_ucmp<mode>3<mask_scalar_merge_name>"
2728   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2729         (unspec:<avx512fmaskmode>
2730           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
2731            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
2732            (match_operand:SI 3 "const_0_to_7_operand" "n")]
2733           UNSPEC_UNSIGNED_PCMP))]
2734   "TARGET_AVX512BW"
2735   "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2736   [(set_attr "type" "ssecmp")
2737    (set_attr "length_immediate" "1")
2738    (set_attr "prefix" "evex")
2739    (set_attr "mode" "<sseinsnmode>")])
2741 (define_insn "<avx512>_ucmp<mode>3<mask_scalar_merge_name>"
2742   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2743         (unspec:<avx512fmaskmode>
2744           [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
2745            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")
2746            (match_operand:SI 3 "const_0_to_7_operand" "n")]
2747           UNSPEC_UNSIGNED_PCMP))]
2748   "TARGET_AVX512F"
2749   "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2750   [(set_attr "type" "ssecmp")
2751    (set_attr "length_immediate" "1")
2752    (set_attr "prefix" "evex")
2753    (set_attr "mode" "<sseinsnmode>")])
2755 (define_insn "avx512f_vmcmp<mode>3<round_saeonly_name>"
2756   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2757         (and:<avx512fmaskmode>
2758           (unspec:<avx512fmaskmode>
2759             [(match_operand:VF_128 1 "register_operand" "v")
2760              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
2761              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2762             UNSPEC_PCMP)
2763           (const_int 1)))]
2764   "TARGET_AVX512F"
2765   "vcmp<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %2<round_saeonly_op4>, %3}"
2766   [(set_attr "type" "ssecmp")
2767    (set_attr "length_immediate" "1")
2768    (set_attr "prefix" "evex")
2769    (set_attr "mode" "<ssescalarmode>")])
2771 (define_insn "avx512f_vmcmp<mode>3_mask<round_saeonly_name>"
2772   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2773         (and:<avx512fmaskmode>
2774           (unspec:<avx512fmaskmode>
2775             [(match_operand:VF_128 1 "register_operand" "v")
2776              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
2777              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2778             UNSPEC_PCMP)
2779           (and:<avx512fmaskmode>
2780             (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")
2781             (const_int 1))))]
2782   "TARGET_AVX512F"
2783   "vcmp<ssescalarmodesuffix>\t{%3, <round_saeonly_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_saeonly_op5>, %3}"
2784   [(set_attr "type" "ssecmp")
2785    (set_attr "length_immediate" "1")
2786    (set_attr "prefix" "evex")
2787    (set_attr "mode" "<ssescalarmode>")])
2789 (define_insn "avx512f_maskcmp<mode>3"
2790   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2791         (match_operator:<avx512fmaskmode> 3 "sse_comparison_operator"
2792           [(match_operand:VF 1 "register_operand" "v")
2793            (match_operand:VF 2 "nonimmediate_operand" "vm")]))]
2794   "TARGET_AVX512F"
2795   "vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2796   [(set_attr "type" "ssecmp")
2797    (set_attr "length_immediate" "1")
2798    (set_attr "prefix" "evex")
2799    (set_attr "mode" "<sseinsnmode>")])
2801 (define_insn "<sse>_comi<round_saeonly_name>"
2802   [(set (reg:CCFP FLAGS_REG)
2803         (compare:CCFP
2804           (vec_select:MODEF
2805             (match_operand:<ssevecmode> 0 "register_operand" "v")
2806             (parallel [(const_int 0)]))
2807           (vec_select:MODEF
2808             (match_operand:<ssevecmode> 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
2809             (parallel [(const_int 0)]))))]
2810   "SSE_FLOAT_MODE_P (<MODE>mode)"
2811   "%vcomi<ssemodesuffix>\t{<round_saeonly_op2>%1, %0|%0, %<iptr>1<round_saeonly_op2>}"
2812   [(set_attr "type" "ssecomi")
2813    (set_attr "prefix" "maybe_vex")
2814    (set_attr "prefix_rep" "0")
2815    (set (attr "prefix_data16")
2816         (if_then_else (eq_attr "mode" "DF")
2817                       (const_string "1")
2818                       (const_string "0")))
2819    (set_attr "mode" "<MODE>")])
2821 (define_insn "<sse>_ucomi<round_saeonly_name>"
2822   [(set (reg:CCFPU FLAGS_REG)
2823         (compare:CCFPU
2824           (vec_select:MODEF
2825             (match_operand:<ssevecmode> 0 "register_operand" "v")
2826             (parallel [(const_int 0)]))
2827           (vec_select:MODEF
2828             (match_operand:<ssevecmode> 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
2829             (parallel [(const_int 0)]))))]
2830   "SSE_FLOAT_MODE_P (<MODE>mode)"
2831   "%vucomi<ssemodesuffix>\t{<round_saeonly_op2>%1, %0|%0, %<iptr>1<round_saeonly_op2>}"
2832   [(set_attr "type" "ssecomi")
2833    (set_attr "prefix" "maybe_vex")
2834    (set_attr "prefix_rep" "0")
2835    (set (attr "prefix_data16")
2836         (if_then_else (eq_attr "mode" "DF")
2837                       (const_string "1")
2838                       (const_string "0")))
2839    (set_attr "mode" "<MODE>")])
2841 (define_expand "vec_cmp<mode><avx512fmaskmodelower>"
2842   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2843         (match_operator:<avx512fmaskmode> 1 ""
2844           [(match_operand:V48_AVX512VL 2 "register_operand")
2845            (match_operand:V48_AVX512VL 3 "nonimmediate_operand")]))]
2846   "TARGET_AVX512F"
2848   bool ok = ix86_expand_mask_vec_cmp (operands);
2849   gcc_assert (ok);
2850   DONE;
2853 (define_expand "vec_cmp<mode><avx512fmaskmodelower>"
2854   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2855         (match_operator:<avx512fmaskmode> 1 ""
2856           [(match_operand:VI12_AVX512VL 2 "register_operand")
2857            (match_operand:VI12_AVX512VL 3 "nonimmediate_operand")]))]
2858   "TARGET_AVX512BW"
2860   bool ok = ix86_expand_mask_vec_cmp (operands);
2861   gcc_assert (ok);
2862   DONE;
2865 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2866   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2867         (match_operator:<sseintvecmode> 1 ""
2868           [(match_operand:VI_256 2 "register_operand")
2869            (match_operand:VI_256 3 "nonimmediate_operand")]))]
2870   "TARGET_AVX2"
2872   bool ok = ix86_expand_int_vec_cmp (operands);
2873   gcc_assert (ok);
2874   DONE;
2877 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2878   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2879         (match_operator:<sseintvecmode> 1 ""
2880           [(match_operand:VI124_128 2 "register_operand")
2881            (match_operand:VI124_128 3 "vector_operand")]))]
2882   "TARGET_SSE2"
2884   bool ok = ix86_expand_int_vec_cmp (operands);
2885   gcc_assert (ok);
2886   DONE;
2889 (define_expand "vec_cmpv2div2di"
2890   [(set (match_operand:V2DI 0 "register_operand")
2891         (match_operator:V2DI 1 ""
2892           [(match_operand:V2DI 2 "register_operand")
2893            (match_operand:V2DI 3 "vector_operand")]))]
2894   "TARGET_SSE4_2"
2896   bool ok = ix86_expand_int_vec_cmp (operands);
2897   gcc_assert (ok);
2898   DONE;
2901 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2902   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2903         (match_operator:<sseintvecmode> 1 ""
2904           [(match_operand:VF_256 2 "register_operand")
2905            (match_operand:VF_256 3 "nonimmediate_operand")]))]
2906   "TARGET_AVX"
2908   bool ok = ix86_expand_fp_vec_cmp (operands);
2909   gcc_assert (ok);
2910   DONE;
2913 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2914   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2915         (match_operator:<sseintvecmode> 1 ""
2916           [(match_operand:VF_128 2 "register_operand")
2917            (match_operand:VF_128 3 "vector_operand")]))]
2918   "TARGET_SSE"
2920   bool ok = ix86_expand_fp_vec_cmp (operands);
2921   gcc_assert (ok);
2922   DONE;
2925 (define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
2926   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2927         (match_operator:<avx512fmaskmode> 1 ""
2928           [(match_operand:VI48_AVX512VL 2 "register_operand")
2929            (match_operand:VI48_AVX512VL 3 "nonimmediate_operand")]))]
2930   "TARGET_AVX512F"
2932   bool ok = ix86_expand_mask_vec_cmp (operands);
2933   gcc_assert (ok);
2934   DONE;
2937 (define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
2938   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2939         (match_operator:<avx512fmaskmode> 1 ""
2940           [(match_operand:VI12_AVX512VL 2 "register_operand")
2941            (match_operand:VI12_AVX512VL 3 "nonimmediate_operand")]))]
2942   "TARGET_AVX512BW"
2944   bool ok = ix86_expand_mask_vec_cmp (operands);
2945   gcc_assert (ok);
2946   DONE;
2949 (define_expand "vec_cmpu<mode><sseintvecmodelower>"
2950   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2951         (match_operator:<sseintvecmode> 1 ""
2952           [(match_operand:VI_256 2 "register_operand")
2953            (match_operand:VI_256 3 "nonimmediate_operand")]))]
2954   "TARGET_AVX2"
2956   bool ok = ix86_expand_int_vec_cmp (operands);
2957   gcc_assert (ok);
2958   DONE;
2961 (define_expand "vec_cmpu<mode><sseintvecmodelower>"
2962   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2963         (match_operator:<sseintvecmode> 1 ""
2964           [(match_operand:VI124_128 2 "register_operand")
2965            (match_operand:VI124_128 3 "vector_operand")]))]
2966   "TARGET_SSE2"
2968   bool ok = ix86_expand_int_vec_cmp (operands);
2969   gcc_assert (ok);
2970   DONE;
2973 (define_expand "vec_cmpuv2div2di"
2974   [(set (match_operand:V2DI 0 "register_operand")
2975         (match_operator:V2DI 1 ""
2976           [(match_operand:V2DI 2 "register_operand")
2977            (match_operand:V2DI 3 "vector_operand")]))]
2978   "TARGET_SSE4_2"
2980   bool ok = ix86_expand_int_vec_cmp (operands);
2981   gcc_assert (ok);
2982   DONE;
2985 (define_expand "vcond<V_512:mode><VF_512:mode>"
2986   [(set (match_operand:V_512 0 "register_operand")
2987         (if_then_else:V_512
2988           (match_operator 3 ""
2989             [(match_operand:VF_512 4 "nonimmediate_operand")
2990              (match_operand:VF_512 5 "nonimmediate_operand")])
2991           (match_operand:V_512 1 "general_operand")
2992           (match_operand:V_512 2 "general_operand")))]
2993   "TARGET_AVX512F
2994    && (GET_MODE_NUNITS (<V_512:MODE>mode)
2995        == GET_MODE_NUNITS (<VF_512:MODE>mode))"
2997   bool ok = ix86_expand_fp_vcond (operands);
2998   gcc_assert (ok);
2999   DONE;
3002 (define_expand "vcond<V_256:mode><VF_256:mode>"
3003   [(set (match_operand:V_256 0 "register_operand")
3004         (if_then_else:V_256
3005           (match_operator 3 ""
3006             [(match_operand:VF_256 4 "nonimmediate_operand")
3007              (match_operand:VF_256 5 "nonimmediate_operand")])
3008           (match_operand:V_256 1 "general_operand")
3009           (match_operand:V_256 2 "general_operand")))]
3010   "TARGET_AVX
3011    && (GET_MODE_NUNITS (<V_256:MODE>mode)
3012        == GET_MODE_NUNITS (<VF_256:MODE>mode))"
3014   bool ok = ix86_expand_fp_vcond (operands);
3015   gcc_assert (ok);
3016   DONE;
3019 (define_expand "vcond<V_128:mode><VF_128:mode>"
3020   [(set (match_operand:V_128 0 "register_operand")
3021         (if_then_else:V_128
3022           (match_operator 3 ""
3023             [(match_operand:VF_128 4 "vector_operand")
3024              (match_operand:VF_128 5 "vector_operand")])
3025           (match_operand:V_128 1 "general_operand")
3026           (match_operand:V_128 2 "general_operand")))]
3027   "TARGET_SSE
3028    && (GET_MODE_NUNITS (<V_128:MODE>mode)
3029        == GET_MODE_NUNITS (<VF_128:MODE>mode))"
3031   bool ok = ix86_expand_fp_vcond (operands);
3032   gcc_assert (ok);
3033   DONE;
3036 (define_expand "vcond_mask_<mode><avx512fmaskmodelower>"
3037   [(set (match_operand:V48_AVX512VL 0 "register_operand")
3038         (vec_merge:V48_AVX512VL
3039           (match_operand:V48_AVX512VL 1 "nonimmediate_operand")
3040           (match_operand:V48_AVX512VL 2 "vector_move_operand")
3041           (match_operand:<avx512fmaskmode> 3 "register_operand")))]
3042   "TARGET_AVX512F")
3044 (define_expand "vcond_mask_<mode><avx512fmaskmodelower>"
3045   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
3046         (vec_merge:VI12_AVX512VL
3047           (match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
3048           (match_operand:VI12_AVX512VL 2 "vector_move_operand")
3049           (match_operand:<avx512fmaskmode> 3 "register_operand")))]
3050   "TARGET_AVX512BW")
3052 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3053   [(set (match_operand:VI_256 0 "register_operand")
3054         (vec_merge:VI_256
3055           (match_operand:VI_256 1 "nonimmediate_operand")
3056           (match_operand:VI_256 2 "vector_move_operand")
3057           (match_operand:<sseintvecmode> 3 "register_operand")))]
3058   "TARGET_AVX2"
3060   ix86_expand_sse_movcc (operands[0], operands[3],
3061                          operands[1], operands[2]);
3062   DONE;
3065 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3066   [(set (match_operand:VI124_128 0 "register_operand")
3067         (vec_merge:VI124_128
3068           (match_operand:VI124_128 1 "vector_operand")
3069           (match_operand:VI124_128 2 "vector_move_operand")
3070           (match_operand:<sseintvecmode> 3 "register_operand")))]
3071   "TARGET_SSE2"
3073   ix86_expand_sse_movcc (operands[0], operands[3],
3074                          operands[1], operands[2]);
3075   DONE;
3078 (define_expand "vcond_mask_v2div2di"
3079   [(set (match_operand:V2DI 0 "register_operand")
3080         (vec_merge:V2DI
3081           (match_operand:V2DI 1 "vector_operand")
3082           (match_operand:V2DI 2 "vector_move_operand")
3083           (match_operand:V2DI 3 "register_operand")))]
3084   "TARGET_SSE4_2"
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:VF_256 0 "register_operand")
3093         (vec_merge:VF_256
3094           (match_operand:VF_256 1 "nonimmediate_operand")
3095           (match_operand:VF_256 2 "vector_move_operand")
3096           (match_operand:<sseintvecmode> 3 "register_operand")))]
3097   "TARGET_AVX"
3099   ix86_expand_sse_movcc (operands[0], operands[3],
3100                          operands[1], operands[2]);
3101   DONE;
3104 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
3105   [(set (match_operand:VF_128 0 "register_operand")
3106         (vec_merge:VF_128
3107           (match_operand:VF_128 1 "vector_operand")
3108           (match_operand:VF_128 2 "vector_move_operand")
3109           (match_operand:<sseintvecmode> 3 "register_operand")))]
3110   "TARGET_SSE"
3112   ix86_expand_sse_movcc (operands[0], operands[3],
3113                          operands[1], operands[2]);
3114   DONE;
3117 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3119 ;; Parallel floating point logical operations
3121 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3123 (define_insn "<sse>_andnot<mode>3<mask_name>"
3124   [(set (match_operand:VF_128_256 0 "register_operand" "=x,v")
3125         (and:VF_128_256
3126           (not:VF_128_256
3127             (match_operand:VF_128_256 1 "register_operand" "0,v"))
3128           (match_operand:VF_128_256 2 "vector_operand" "xBm,vm")))]
3129   "TARGET_SSE && <mask_avx512vl_condition>"
3131   static char buf[128];
3132   const char *ops;
3133   const char *suffix;
3135   switch (get_attr_mode (insn))
3136     {
3137     case MODE_V8SF:
3138     case MODE_V4SF:
3139       suffix = "ps";
3140       break;
3141     default:
3142       suffix = "<ssemodesuffix>";
3143     }
3145   switch (which_alternative)
3146     {
3147     case 0:
3148       ops = "andn%s\t{%%2, %%0|%%0, %%2}";
3149       break;
3150     case 1:
3151       ops = "vandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3152       break;
3153     default:
3154       gcc_unreachable ();
3155     }
3157   /* There is no vandnp[sd] in avx512f.  Use vpandn[qd].  */
3158   if (<mask_applied> && !TARGET_AVX512DQ)
3159     {
3160       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3161       ops = "vpandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3162     }
3164   snprintf (buf, sizeof (buf), ops, suffix);
3165   return buf;
3167   [(set_attr "isa" "noavx,avx")
3168    (set_attr "type" "sselog")
3169    (set_attr "prefix" "orig,maybe_evex")
3170    (set (attr "mode")
3171         (cond [(and (match_test "<MODE_SIZE> == 16")
3172                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3173                  (const_string "<ssePSmode>")
3174                (match_test "TARGET_AVX")
3175                  (const_string "<MODE>")
3176                (match_test "optimize_function_for_size_p (cfun)")
3177                  (const_string "V4SF")
3178                ]
3179                (const_string "<MODE>")))])
3182 (define_insn "<sse>_andnot<mode>3<mask_name>"
3183   [(set (match_operand:VF_512 0 "register_operand" "=v")
3184         (and:VF_512
3185           (not:VF_512
3186             (match_operand:VF_512 1 "register_operand" "v"))
3187           (match_operand:VF_512 2 "nonimmediate_operand" "vm")))]
3188   "TARGET_AVX512F"
3190   static char buf[128];
3191   const char *ops;
3192   const char *suffix;
3194   suffix = "<ssemodesuffix>";
3195   ops = "";
3197   /* There is no vandnp[sd] in avx512f.  Use vpandn[qd].  */
3198   if (!TARGET_AVX512DQ)
3199     {
3200       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3201       ops = "p";
3202     }
3204   snprintf (buf, sizeof (buf),
3205             "v%sandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}",
3206             ops, suffix);
3207   return buf;
3209   [(set_attr "type" "sselog")
3210    (set_attr "prefix" "evex")
3211    (set_attr "mode" "<sseinsnmode>")])
3213 (define_expand "<code><mode>3<mask_name>"
3214   [(set (match_operand:VF_128_256 0 "register_operand")
3215        (any_logic:VF_128_256
3216          (match_operand:VF_128_256 1 "vector_operand")
3217          (match_operand:VF_128_256 2 "vector_operand")))]
3218   "TARGET_SSE && <mask_avx512vl_condition>"
3219   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
3221 (define_expand "<code><mode>3<mask_name>"
3222   [(set (match_operand:VF_512 0 "register_operand")
3223        (any_logic:VF_512
3224          (match_operand:VF_512 1 "nonimmediate_operand")
3225          (match_operand:VF_512 2 "nonimmediate_operand")))]
3226   "TARGET_AVX512F"
3227   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
3229 (define_insn "*<code><mode>3<mask_name>"
3230   [(set (match_operand:VF_128_256 0 "register_operand" "=x,v")
3231         (any_logic:VF_128_256
3232           (match_operand:VF_128_256 1 "vector_operand" "%0,v")
3233           (match_operand:VF_128_256 2 "vector_operand" "xBm,vm")))]
3234   "TARGET_SSE && <mask_avx512vl_condition>
3235    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
3237   static char buf[128];
3238   const char *ops;
3239   const char *suffix;
3241   switch (get_attr_mode (insn))
3242     {
3243     case MODE_V8SF:
3244     case MODE_V4SF:
3245       suffix = "ps";
3246       break;
3247     default:
3248       suffix = "<ssemodesuffix>";
3249     }
3251   switch (which_alternative)
3252     {
3253     case 0:
3254       ops = "<logic>%s\t{%%2, %%0|%%0, %%2}";
3255       break;
3256     case 1:
3257       ops = "v<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3258       break;
3259     default:
3260       gcc_unreachable ();
3261     }
3263   /* There is no v<logic>p[sd] in avx512f.  Use vp<logic>[dq].  */
3264   if (<mask_applied> && !TARGET_AVX512DQ)
3265     {
3266       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3267       ops = "vp<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
3268     }
3270   snprintf (buf, sizeof (buf), ops, suffix);
3271   return buf;
3273   [(set_attr "isa" "noavx,avx")
3274    (set_attr "type" "sselog")
3275    (set_attr "prefix" "orig,maybe_evex")
3276    (set (attr "mode")
3277         (cond [(and (match_test "<MODE_SIZE> == 16")
3278                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3279                  (const_string "<ssePSmode>")
3280                (match_test "TARGET_AVX")
3281                  (const_string "<MODE>")
3282                (match_test "optimize_function_for_size_p (cfun)")
3283                  (const_string "V4SF")
3284                ]
3285                (const_string "<MODE>")))])
3287 (define_insn "*<code><mode>3<mask_name>"
3288   [(set (match_operand:VF_512 0 "register_operand" "=v")
3289         (any_logic:VF_512
3290           (match_operand:VF_512 1 "nonimmediate_operand" "%v")
3291           (match_operand:VF_512 2 "nonimmediate_operand" "vm")))]
3292   "TARGET_AVX512F && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
3294   static char buf[128];
3295   const char *ops;
3296   const char *suffix;
3298   suffix = "<ssemodesuffix>";
3299   ops = "";
3301   /* There is no v<logic>p[sd] in avx512f.  Use vp<logic>[dq].  */
3302   if ((<MODE_SIZE> == 64 || <mask_applied>) && !TARGET_AVX512DQ)
3303     {
3304       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
3305       ops = "p";
3306     }
3308   snprintf (buf, sizeof (buf),
3309            "v%s<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}",
3310            ops, suffix);
3311   return buf;
3313   [(set_attr "type" "sselog")
3314    (set_attr "prefix" "evex")
3315    (set_attr "mode" "<sseinsnmode>")])
3317 (define_expand "copysign<mode>3"
3318   [(set (match_dup 4)
3319         (and:VF
3320           (not:VF (match_dup 3))
3321           (match_operand:VF 1 "vector_operand")))
3322    (set (match_dup 5)
3323         (and:VF (match_dup 3)
3324                 (match_operand:VF 2 "vector_operand")))
3325    (set (match_operand:VF 0 "register_operand")
3326         (ior:VF (match_dup 4) (match_dup 5)))]
3327   "TARGET_SSE"
3329   operands[3] = ix86_build_signbit_mask (<MODE>mode, 1, 0);
3331   operands[4] = gen_reg_rtx (<MODE>mode);
3332   operands[5] = gen_reg_rtx (<MODE>mode);
3335 ;; Also define scalar versions.  These are used for abs, neg, and
3336 ;; conditional move.  Using subregs into vector modes causes register
3337 ;; allocation lossage.  These patterns do not allow memory operands
3338 ;; because the native instructions read the full 128-bits.
3340 (define_insn "*andnot<mode>3"
3341   [(set (match_operand:MODEF 0 "register_operand" "=x,x")
3342         (and:MODEF
3343           (not:MODEF
3344             (match_operand:MODEF 1 "register_operand" "0,x"))
3345             (match_operand:MODEF 2 "register_operand" "x,x")))]
3346   "SSE_FLOAT_MODE_P (<MODE>mode)"
3348   static char buf[32];
3349   const char *ops;
3350   const char *suffix
3351     = (get_attr_mode (insn) == MODE_V4SF) ? "ps" : "<ssevecmodesuffix>";
3353   switch (which_alternative)
3354     {
3355     case 0:
3356       ops = "andn%s\t{%%2, %%0|%%0, %%2}";
3357       break;
3358     case 1:
3359       ops = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3360       break;
3361     default:
3362       gcc_unreachable ();
3363     }
3365   snprintf (buf, sizeof (buf), ops, suffix);
3366   return buf;
3368   [(set_attr "isa" "noavx,avx")
3369    (set_attr "type" "sselog")
3370    (set_attr "prefix" "orig,vex")
3371    (set (attr "mode")
3372         (cond [(and (match_test "<MODE_SIZE> == 16")
3373                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3374                  (const_string "V4SF")
3375                (match_test "TARGET_AVX")
3376                  (const_string "<ssevecmode>")
3377                (match_test "optimize_function_for_size_p (cfun)")
3378                  (const_string "V4SF")
3379                ]
3380                (const_string "<ssevecmode>")))])
3382 (define_insn "*andnottf3"
3383   [(set (match_operand:TF 0 "register_operand" "=x,x")
3384         (and:TF
3385           (not:TF (match_operand:TF 1 "register_operand" "0,x"))
3386           (match_operand:TF 2 "vector_operand" "xBm,xm")))]
3387   "TARGET_SSE"
3389   static char buf[32];
3390   const char *ops;
3391   const char *tmp
3392     = (get_attr_mode (insn) == MODE_V4SF) ? "andnps" : "pandn";
3394   switch (which_alternative)
3395     {
3396     case 0:
3397       ops = "%s\t{%%2, %%0|%%0, %%2}";
3398       break;
3399     case 1:
3400       ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3401       break;
3402     default:
3403       gcc_unreachable ();
3404     }
3406   snprintf (buf, sizeof (buf), ops, tmp);
3407   return buf;
3409   [(set_attr "isa" "noavx,avx")
3410    (set_attr "type" "sselog")
3411    (set (attr "prefix_data16")
3412      (if_then_else
3413        (and (eq_attr "alternative" "0")
3414             (eq_attr "mode" "TI"))
3415        (const_string "1")
3416        (const_string "*")))
3417    (set_attr "prefix" "orig,vex")
3418    (set (attr "mode")
3419         (cond [(match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
3420                  (const_string "V4SF")
3421                (match_test "TARGET_AVX")
3422                  (const_string "TI")
3423                (ior (not (match_test "TARGET_SSE2"))
3424                     (match_test "optimize_function_for_size_p (cfun)"))
3425                  (const_string "V4SF")
3426                ]
3427                (const_string "TI")))])
3429 (define_insn "*<code><mode>3"
3430   [(set (match_operand:MODEF 0 "register_operand" "=x,x")
3431         (any_logic:MODEF
3432           (match_operand:MODEF 1 "register_operand" "%0,x")
3433           (match_operand:MODEF 2 "register_operand" "x,x")))]
3434   "SSE_FLOAT_MODE_P (<MODE>mode)"
3436   static char buf[32];
3437   const char *ops;
3438   const char *suffix
3439     = (get_attr_mode (insn) == MODE_V4SF) ? "ps" : "<ssevecmodesuffix>";
3441   switch (which_alternative)
3442     {
3443     case 0:
3444       ops = "<logic>%s\t{%%2, %%0|%%0, %%2}";
3445       break;
3446     case 1:
3447       ops = "v<logic>%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3448       break;
3449     default:
3450       gcc_unreachable ();
3451     }
3453   snprintf (buf, sizeof (buf), ops, suffix);
3454   return buf;
3456   [(set_attr "isa" "noavx,avx")
3457    (set_attr "type" "sselog")
3458    (set_attr "prefix" "orig,vex")
3459    (set (attr "mode")
3460         (cond [(and (match_test "<MODE_SIZE> == 16")
3461                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3462                  (const_string "V4SF")
3463                (match_test "TARGET_AVX")
3464                  (const_string "<ssevecmode>")
3465                (match_test "optimize_function_for_size_p (cfun)")
3466                  (const_string "V4SF")
3467                ]
3468                (const_string "<ssevecmode>")))])
3470 (define_expand "<code>tf3"
3471   [(set (match_operand:TF 0 "register_operand")
3472         (any_logic:TF
3473           (match_operand:TF 1 "vector_operand")
3474           (match_operand:TF 2 "vector_operand")))]
3475   "TARGET_SSE"
3476   "ix86_fixup_binary_operands_no_copy (<CODE>, TFmode, operands);")
3478 (define_insn "*<code>tf3"
3479   [(set (match_operand:TF 0 "register_operand" "=x,x")
3480         (any_logic:TF
3481           (match_operand:TF 1 "vector_operand" "%0,x")
3482           (match_operand:TF 2 "vector_operand" "xBm,xm")))]
3483   "TARGET_SSE
3484    && ix86_binary_operator_ok (<CODE>, TFmode, operands)"
3486   static char buf[32];
3487   const char *ops;
3488   const char *tmp
3489     = (get_attr_mode (insn) == MODE_V4SF) ? "<logic>ps" : "p<logic>";
3491   switch (which_alternative)
3492     {
3493     case 0:
3494       ops = "%s\t{%%2, %%0|%%0, %%2}";
3495       break;
3496     case 1:
3497       ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3498       break;
3499     default:
3500       gcc_unreachable ();
3501     }
3503   snprintf (buf, sizeof (buf), ops, tmp);
3504   return buf;
3506   [(set_attr "isa" "noavx,avx")
3507    (set_attr "type" "sselog")
3508    (set (attr "prefix_data16")
3509      (if_then_else
3510        (and (eq_attr "alternative" "0")
3511             (eq_attr "mode" "TI"))
3512        (const_string "1")
3513        (const_string "*")))
3514    (set_attr "prefix" "orig,vex")
3515    (set (attr "mode")
3516         (cond [(match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
3517                  (const_string "V4SF")
3518                (match_test "TARGET_AVX")
3519                  (const_string "TI")
3520                (ior (not (match_test "TARGET_SSE2"))
3521                     (match_test "optimize_function_for_size_p (cfun)"))
3522                  (const_string "V4SF")
3523                ]
3524                (const_string "TI")))])
3526 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3528 ;; FMA floating point multiply/accumulate instructions.  These include
3529 ;; scalar versions of the instructions as well as vector versions.
3531 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3533 ;; The standard names for scalar FMA are only available with SSE math enabled.
3534 ;; CPUID bit AVX512F enables evex encoded scalar and 512-bit fma.  It doesn't
3535 ;; care about FMA bit, so we enable fma for TARGET_AVX512F even when TARGET_FMA
3536 ;; and TARGET_FMA4 are both false.
3537 ;; TODO: In theory AVX512F does not automatically imply FMA, and without FMA
3538 ;; one must force the EVEX encoding of the fma insns.  Ideally we'd improve
3539 ;; GAS to allow proper prefix selection.  However, for the moment all hardware
3540 ;; that supports AVX512F also supports FMA so we can ignore this for now.
3541 (define_mode_iterator FMAMODEM
3542   [(SF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
3543    (DF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
3544    (V4SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3545    (V2DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3546    (V8SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3547    (V4DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3548    (V16SF "TARGET_AVX512F")
3549    (V8DF "TARGET_AVX512F")])
3551 (define_expand "fma<mode>4"
3552   [(set (match_operand:FMAMODEM 0 "register_operand")
3553         (fma:FMAMODEM
3554           (match_operand:FMAMODEM 1 "nonimmediate_operand")
3555           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3556           (match_operand:FMAMODEM 3 "nonimmediate_operand")))])
3558 (define_expand "fms<mode>4"
3559   [(set (match_operand:FMAMODEM 0 "register_operand")
3560         (fma:FMAMODEM
3561           (match_operand:FMAMODEM 1 "nonimmediate_operand")
3562           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3563           (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))])
3565 (define_expand "fnma<mode>4"
3566   [(set (match_operand:FMAMODEM 0 "register_operand")
3567         (fma:FMAMODEM
3568           (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
3569           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3570           (match_operand:FMAMODEM 3 "nonimmediate_operand")))])
3572 (define_expand "fnms<mode>4"
3573   [(set (match_operand:FMAMODEM 0 "register_operand")
3574         (fma:FMAMODEM
3575           (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
3576           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3577           (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))])
3579 ;; The builtins for intrinsics are not constrained by SSE math enabled.
3580 (define_mode_iterator FMAMODE_AVX512
3581  [(SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
3582   (DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
3583   (V4SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3584   (V2DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3585   (V8SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3586   (V4DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3587   (V16SF "TARGET_AVX512F")
3588   (V8DF "TARGET_AVX512F")])
3590 (define_mode_iterator FMAMODE
3591   [SF DF V4SF V2DF V8SF V4DF])
3593 (define_expand "fma4i_fmadd_<mode>"
3594   [(set (match_operand:FMAMODE_AVX512 0 "register_operand")
3595         (fma:FMAMODE_AVX512
3596           (match_operand:FMAMODE_AVX512 1 "nonimmediate_operand")
3597           (match_operand:FMAMODE_AVX512 2 "nonimmediate_operand")
3598           (match_operand:FMAMODE_AVX512 3 "nonimmediate_operand")))])
3600 (define_expand "<avx512>_fmadd_<mode>_maskz<round_expand_name>"
3601   [(match_operand:VF_AVX512VL 0 "register_operand")
3602    (match_operand:VF_AVX512VL 1 "<round_expand_nimm_predicate>")
3603    (match_operand:VF_AVX512VL 2 "<round_expand_nimm_predicate>")
3604    (match_operand:VF_AVX512VL 3 "<round_expand_nimm_predicate>")
3605    (match_operand:<avx512fmaskmode> 4 "register_operand")]
3606   "TARGET_AVX512F && <round_mode512bit_condition>"
3608   emit_insn (gen_fma_fmadd_<mode>_maskz_1<round_expand_name> (
3609     operands[0], operands[1], operands[2], operands[3],
3610     CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
3611   DONE;
3614 (define_insn "*fma_fmadd_<mode>"
3615   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3616         (fma:FMAMODE
3617           (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x")
3618           (match_operand:FMAMODE 2 "nonimmediate_operand" "vm,v,vm,x,m")
3619           (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x")))]
3620   "TARGET_FMA || TARGET_FMA4"
3621   "@
3622    vfmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3623    vfmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3624    vfmadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3625    vfmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3626    vfmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3627   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3628    (set_attr "type" "ssemuladd")
3629    (set_attr "mode" "<MODE>")])
3631 ;; Suppose AVX-512F as baseline
3632 (define_mode_iterator VF_SF_AVX512VL
3633   [SF V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
3634    DF V8DF (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
3636 (define_insn "<sd_mask_codefor>fma_fmadd_<mode><sd_maskz_name><round_name>"
3637   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3638         (fma:VF_SF_AVX512VL
3639           (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v")
3640           (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3641           (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0")))]
3642   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3643   "@
3644    vfmadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3645    vfmadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3646    vfmadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3647   [(set_attr "type" "ssemuladd")
3648    (set_attr "mode" "<MODE>")])
3650 (define_insn "<avx512>_fmadd_<mode>_mask<round_name>"
3651   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3652         (vec_merge:VF_AVX512VL
3653           (fma:VF_AVX512VL
3654             (match_operand:VF_AVX512VL 1 "register_operand" "0,0")
3655             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3656             (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))
3657           (match_dup 1)
3658           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3659   "TARGET_AVX512F && <round_mode512bit_condition>"
3660   "@
3661    vfmadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3662    vfmadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3663   [(set_attr "isa" "fma_avx512f,fma_avx512f")
3664    (set_attr "type" "ssemuladd")
3665    (set_attr "mode" "<MODE>")])
3667 (define_insn "<avx512>_fmadd_<mode>_mask3<round_name>"
3668   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=x")
3669         (vec_merge:VF_AVX512VL
3670           (fma:VF_AVX512VL
3671             (match_operand:VF_AVX512VL 1 "register_operand" "x")
3672             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3673             (match_operand:VF_AVX512VL 3 "register_operand" "0"))
3674           (match_dup 3)
3675           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3676   "TARGET_AVX512F"
3677   "vfmadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3678   [(set_attr "isa" "fma_avx512f")
3679    (set_attr "type" "ssemuladd")
3680    (set_attr "mode" "<MODE>")])
3682 (define_insn "*fma_fmsub_<mode>"
3683   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3684         (fma:FMAMODE
3685           (match_operand:FMAMODE   1 "nonimmediate_operand" "%0,0,v,x,x")
3686           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
3687           (neg:FMAMODE
3688             (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x"))))]
3689   "TARGET_FMA || TARGET_FMA4"
3690   "@
3691    vfmsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3692    vfmsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3693    vfmsub231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3694    vfmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3695    vfmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3696   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3697    (set_attr "type" "ssemuladd")
3698    (set_attr "mode" "<MODE>")])
3700 (define_insn "<sd_mask_codefor>fma_fmsub_<mode><sd_maskz_name><round_name>"
3701   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3702         (fma:VF_SF_AVX512VL
3703           (match_operand:VF_SF_AVX512VL   1 "<round_nimm_predicate>" "%0,0,v")
3704           (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3705           (neg:VF_SF_AVX512VL
3706             (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))))]
3707   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3708   "@
3709    vfmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3710    vfmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3711    vfmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3712   [(set_attr "type" "ssemuladd")
3713    (set_attr "mode" "<MODE>")])
3715 (define_insn "<avx512>_fmsub_<mode>_mask<round_name>"
3716   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3717         (vec_merge:VF_AVX512VL
3718           (fma:VF_AVX512VL
3719             (match_operand:VF_AVX512VL 1 "register_operand" "0,0")
3720             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3721             (neg:VF_AVX512VL
3722               (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")))
3723           (match_dup 1)
3724           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3725   "TARGET_AVX512F"
3726   "@
3727    vfmsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3728    vfmsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3729   [(set_attr "isa" "fma_avx512f,fma_avx512f")
3730    (set_attr "type" "ssemuladd")
3731    (set_attr "mode" "<MODE>")])
3733 (define_insn "<avx512>_fmsub_<mode>_mask3<round_name>"
3734   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3735         (vec_merge:VF_AVX512VL
3736           (fma:VF_AVX512VL
3737             (match_operand:VF_AVX512VL 1 "register_operand" "v")
3738             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3739             (neg:VF_AVX512VL
3740               (match_operand:VF_AVX512VL 3 "register_operand" "0")))
3741           (match_dup 3)
3742           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3743   "TARGET_AVX512F && <round_mode512bit_condition>"
3744   "vfmsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3745   [(set_attr "isa" "fma_avx512f")
3746    (set_attr "type" "ssemuladd")
3747    (set_attr "mode" "<MODE>")])
3749 (define_insn "*fma_fnmadd_<mode>"
3750   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3751         (fma:FMAMODE
3752           (neg:FMAMODE
3753             (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x"))
3754           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
3755           (match_operand:FMAMODE   3 "nonimmediate_operand" "v,vm,0,xm,x")))]
3756   "TARGET_FMA || TARGET_FMA4"
3757   "@
3758    vfnmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3759    vfnmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3760    vfnmadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3761    vfnmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3762    vfnmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3763   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3764    (set_attr "type" "ssemuladd")
3765    (set_attr "mode" "<MODE>")])
3767 (define_insn "<sd_mask_codefor>fma_fnmadd_<mode><sd_maskz_name><round_name>"
3768   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3769         (fma:VF_SF_AVX512VL
3770           (neg:VF_SF_AVX512VL
3771             (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v"))
3772           (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3773           (match_operand:VF_SF_AVX512VL   3 "<round_nimm_predicate>" "v,<round_constraint>,0")))]
3774   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3775   "@
3776    vfnmadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3777    vfnmadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3778    vfnmadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3779   [(set_attr "type" "ssemuladd")
3780    (set_attr "mode" "<MODE>")])
3782 (define_insn "<avx512>_fnmadd_<mode>_mask<round_name>"
3783   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3784         (vec_merge:VF_AVX512VL
3785           (fma:VF_AVX512VL
3786             (neg:VF_AVX512VL
3787               (match_operand:VF_AVX512VL 1 "register_operand" "0,0"))
3788             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3789             (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))
3790           (match_dup 1)
3791           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3792   "TARGET_AVX512F && <round_mode512bit_condition>"
3793   "@
3794    vfnmadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3795    vfnmadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3796   [(set_attr "isa" "fma_avx512f,fma_avx512f")
3797    (set_attr "type" "ssemuladd")
3798    (set_attr "mode" "<MODE>")])
3800 (define_insn "<avx512>_fnmadd_<mode>_mask3<round_name>"
3801   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3802         (vec_merge:VF_AVX512VL
3803           (fma:VF_AVX512VL
3804             (neg:VF_AVX512VL
3805               (match_operand:VF_AVX512VL 1 "register_operand" "v"))
3806             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3807             (match_operand:VF_AVX512VL 3 "register_operand" "0"))
3808           (match_dup 3)
3809           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3810   "TARGET_AVX512F && <round_mode512bit_condition>"
3811   "vfnmadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3812   [(set_attr "isa" "fma_avx512f")
3813    (set_attr "type" "ssemuladd")
3814    (set_attr "mode" "<MODE>")])
3816 (define_insn "*fma_fnmsub_<mode>"
3817   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3818         (fma:FMAMODE
3819           (neg:FMAMODE
3820             (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x"))
3821           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
3822           (neg:FMAMODE
3823             (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x"))))]
3824   "TARGET_FMA || TARGET_FMA4"
3825   "@
3826    vfnmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3827    vfnmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3828    vfnmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}
3829    vfnmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3830    vfnmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3831   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3832    (set_attr "type" "ssemuladd")
3833    (set_attr "mode" "<MODE>")])
3835 (define_insn "<sd_mask_codefor>fma_fnmsub_<mode><sd_maskz_name><round_name>"
3836   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3837         (fma:VF_SF_AVX512VL
3838           (neg:VF_SF_AVX512VL
3839             (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v"))
3840           (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3841           (neg:VF_SF_AVX512VL
3842             (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))))]
3843   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3844   "@
3845    vfnmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3846    vfnmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3847    vfnmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3848   [(set_attr "type" "ssemuladd")
3849    (set_attr "mode" "<MODE>")])
3851 (define_insn "<avx512>_fnmsub_<mode>_mask<round_name>"
3852   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3853         (vec_merge:VF_AVX512VL
3854           (fma:VF_AVX512VL
3855             (neg:VF_AVX512VL
3856               (match_operand:VF_AVX512VL 1 "register_operand" "0,0"))
3857             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3858             (neg:VF_AVX512VL
3859               (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")))
3860           (match_dup 1)
3861           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3862   "TARGET_AVX512F && <round_mode512bit_condition>"
3863   "@
3864    vfnmsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3865    vfnmsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3866   [(set_attr "isa" "fma_avx512f,fma_avx512f")
3867    (set_attr "type" "ssemuladd")
3868    (set_attr "mode" "<MODE>")])
3870 (define_insn "<avx512>_fnmsub_<mode>_mask3<round_name>"
3871   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3872         (vec_merge:VF_AVX512VL
3873           (fma:VF_AVX512VL
3874             (neg:VF_AVX512VL
3875               (match_operand:VF_AVX512VL 1 "register_operand" "v"))
3876             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3877             (neg:VF_AVX512VL
3878               (match_operand:VF_AVX512VL 3 "register_operand" "0")))
3879           (match_dup 3)
3880           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3881   "TARGET_AVX512F"
3882   "vfnmsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3883   [(set_attr "isa" "fma_avx512f")
3884    (set_attr "type" "ssemuladd")
3885    (set_attr "mode" "<MODE>")])
3887 ;; FMA parallel floating point multiply addsub and subadd operations.
3889 ;; It would be possible to represent these without the UNSPEC as
3891 ;; (vec_merge
3892 ;;   (fma op1 op2 op3)
3893 ;;   (fma op1 op2 (neg op3))
3894 ;;   (merge-const))
3896 ;; But this doesn't seem useful in practice.
3898 (define_expand "fmaddsub_<mode>"
3899   [(set (match_operand:VF 0 "register_operand")
3900         (unspec:VF
3901           [(match_operand:VF 1 "nonimmediate_operand")
3902            (match_operand:VF 2 "nonimmediate_operand")
3903            (match_operand:VF 3 "nonimmediate_operand")]
3904           UNSPEC_FMADDSUB))]
3905   "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
3907 (define_expand "<avx512>_fmaddsub_<mode>_maskz<round_expand_name>"
3908   [(match_operand:VF_AVX512VL 0 "register_operand")
3909    (match_operand:VF_AVX512VL 1 "<round_expand_nimm_predicate>")
3910    (match_operand:VF_AVX512VL 2 "<round_expand_nimm_predicate>")
3911    (match_operand:VF_AVX512VL 3 "<round_expand_nimm_predicate>")
3912    (match_operand:<avx512fmaskmode> 4 "register_operand")]
3913   "TARGET_AVX512F"
3915   emit_insn (gen_fma_fmaddsub_<mode>_maskz_1<round_expand_name> (
3916     operands[0], operands[1], operands[2], operands[3],
3917     CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
3918   DONE;
3921 (define_insn "*fma_fmaddsub_<mode>"
3922   [(set (match_operand:VF_128_256 0 "register_operand" "=v,v,v,x,x")
3923         (unspec:VF_128_256
3924           [(match_operand:VF_128_256 1 "nonimmediate_operand" "%0,0,v,x,x")
3925            (match_operand:VF_128_256 2 "nonimmediate_operand" "vm,v,vm,x,m")
3926            (match_operand:VF_128_256 3 "nonimmediate_operand" "v,vm,0,xm,x")]
3927           UNSPEC_FMADDSUB))]
3928   "TARGET_FMA || TARGET_FMA4"
3929   "@
3930    vfmaddsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3931    vfmaddsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3932    vfmaddsub231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3933    vfmaddsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3934    vfmaddsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3935   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3936    (set_attr "type" "ssemuladd")
3937    (set_attr "mode" "<MODE>")])
3939 (define_insn "<sd_mask_codefor>fma_fmaddsub_<mode><sd_maskz_name><round_name>"
3940   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3941         (unspec:VF_SF_AVX512VL
3942           [(match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v")
3943            (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3944            (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0")]
3945           UNSPEC_FMADDSUB))]
3946   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3947   "@
3948    vfmaddsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3949    vfmaddsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3950    vfmaddsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3951   [(set_attr "type" "ssemuladd")
3952    (set_attr "mode" "<MODE>")])
3954 (define_insn "<avx512>_fmaddsub_<mode>_mask<round_name>"
3955   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3956         (vec_merge:VF_AVX512VL
3957           (unspec:VF_AVX512VL
3958             [(match_operand:VF_AVX512VL 1 "register_operand" "0,0")
3959              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3960              (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")]
3961             UNSPEC_FMADDSUB)
3962           (match_dup 1)
3963           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3964   "TARGET_AVX512F"
3965   "@
3966    vfmaddsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3967    vfmaddsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3968   [(set_attr "isa" "fma_avx512f,fma_avx512f")
3969    (set_attr "type" "ssemuladd")
3970    (set_attr "mode" "<MODE>")])
3972 (define_insn "<avx512>_fmaddsub_<mode>_mask3<round_name>"
3973   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3974         (vec_merge:VF_AVX512VL
3975           (unspec:VF_AVX512VL
3976             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
3977              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3978              (match_operand:VF_AVX512VL 3 "register_operand" "0")]
3979             UNSPEC_FMADDSUB)
3980           (match_dup 3)
3981           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3982   "TARGET_AVX512F"
3983   "vfmaddsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3984   [(set_attr "isa" "fma_avx512f")
3985    (set_attr "type" "ssemuladd")
3986    (set_attr "mode" "<MODE>")])
3988 (define_insn "*fma_fmsubadd_<mode>"
3989   [(set (match_operand:VF_128_256 0 "register_operand" "=v,v,v,x,x")
3990         (unspec:VF_128_256
3991           [(match_operand:VF_128_256   1 "nonimmediate_operand" "%0,0,v,x,x")
3992            (match_operand:VF_128_256   2 "nonimmediate_operand" "vm,v,vm,x,m")
3993            (neg:VF_128_256
3994              (match_operand:VF_128_256 3 "nonimmediate_operand" "v,vm,0,xm,x"))]
3995           UNSPEC_FMADDSUB))]
3996   "TARGET_FMA || TARGET_FMA4"
3997   "@
3998    vfmsubadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3999    vfmsubadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
4000    vfmsubadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
4001    vfmsubadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
4002    vfmsubadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
4003   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
4004    (set_attr "type" "ssemuladd")
4005    (set_attr "mode" "<MODE>")])
4007 (define_insn "<sd_mask_codefor>fma_fmsubadd_<mode><sd_maskz_name><round_name>"
4008   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
4009         (unspec:VF_SF_AVX512VL
4010           [(match_operand:VF_SF_AVX512VL   1 "<round_nimm_predicate>" "%0,0,v")
4011            (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
4012            (neg:VF_SF_AVX512VL
4013              (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))]
4014           UNSPEC_FMADDSUB))]
4015   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
4016   "@
4017    vfmsubadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
4018    vfmsubadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
4019    vfmsubadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
4020   [(set_attr "type" "ssemuladd")
4021    (set_attr "mode" "<MODE>")])
4023 (define_insn "<avx512>_fmsubadd_<mode>_mask<round_name>"
4024   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
4025         (vec_merge:VF_AVX512VL
4026           (unspec:VF_AVX512VL
4027             [(match_operand:VF_AVX512VL 1 "register_operand" "0,0")
4028              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
4029              (neg:VF_AVX512VL
4030                (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))]
4031             UNSPEC_FMADDSUB)
4032           (match_dup 1)
4033           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
4034   "TARGET_AVX512F"
4035   "@
4036    vfmsubadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
4037    vfmsubadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
4038   [(set_attr "isa" "fma_avx512f,fma_avx512f")
4039    (set_attr "type" "ssemuladd")
4040    (set_attr "mode" "<MODE>")])
4042 (define_insn "<avx512>_fmsubadd_<mode>_mask3<round_name>"
4043   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
4044         (vec_merge:VF_AVX512VL
4045           (unspec:VF_AVX512VL
4046             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
4047              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
4048              (neg:VF_AVX512VL
4049                (match_operand:VF_AVX512VL 3 "register_operand" "0"))]
4050             UNSPEC_FMADDSUB)
4051           (match_dup 3)
4052           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
4053   "TARGET_AVX512F"
4054   "vfmsubadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
4055   [(set_attr "isa" "fma_avx512f")
4056    (set_attr "type" "ssemuladd")
4057    (set_attr "mode" "<MODE>")])
4059 ;; FMA3 floating point scalar intrinsics. These merge result with
4060 ;; high-order elements from the destination register.
4062 (define_expand "fmai_vmfmadd_<mode><round_name>"
4063   [(set (match_operand:VF_128 0 "register_operand")
4064         (vec_merge:VF_128
4065           (fma:VF_128
4066             (match_operand:VF_128 1 "<round_nimm_predicate>")
4067             (match_operand:VF_128 2 "<round_nimm_predicate>")
4068             (match_operand:VF_128 3 "<round_nimm_predicate>"))
4069           (match_dup 1)
4070           (const_int 1)))]
4071   "TARGET_FMA")
4073 (define_insn "*fmai_fmadd_<mode>"
4074   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4075         (vec_merge:VF_128
4076           (fma:VF_128
4077             (match_operand:VF_128 1 "<round_nimm_predicate>" " 0, 0")
4078             (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>, v")
4079             (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>"))
4080           (match_dup 1)
4081           (const_int 1)))]
4082   "TARGET_FMA || TARGET_AVX512F"
4083   "@
4084    vfmadd132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4085    vfmadd213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4086   [(set_attr "type" "ssemuladd")
4087    (set_attr "mode" "<MODE>")])
4089 (define_insn "*fmai_fmsub_<mode>"
4090   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4091         (vec_merge:VF_128
4092           (fma:VF_128
4093             (match_operand:VF_128   1 "<round_nimm_predicate>" "0,0")
4094             (match_operand:VF_128   2 "<round_nimm_predicate>" "<round_constraint>,v")
4095             (neg:VF_128
4096               (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>")))
4097           (match_dup 1)
4098           (const_int 1)))]
4099   "TARGET_FMA || TARGET_AVX512F"
4100   "@
4101    vfmsub132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4102    vfmsub213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4103   [(set_attr "type" "ssemuladd")
4104    (set_attr "mode" "<MODE>")])
4106 (define_insn "*fmai_fnmadd_<mode><round_name>"
4107   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4108         (vec_merge:VF_128
4109           (fma:VF_128
4110             (neg:VF_128
4111               (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>,v"))
4112             (match_operand:VF_128   1 "<round_nimm_predicate>" "0,0")
4113             (match_operand:VF_128   3 "<round_nimm_predicate>" "v,<round_constraint>"))
4114           (match_dup 1)
4115           (const_int 1)))]
4116   "TARGET_FMA || TARGET_AVX512F"
4117   "@
4118    vfnmadd132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4119    vfnmadd213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4120   [(set_attr "type" "ssemuladd")
4121    (set_attr "mode" "<MODE>")])
4123 (define_insn "*fmai_fnmsub_<mode><round_name>"
4124   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
4125         (vec_merge:VF_128
4126           (fma:VF_128
4127             (neg:VF_128
4128               (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>, v"))
4129             (match_operand:VF_128   1 "<round_nimm_predicate>" " 0, 0")
4130             (neg:VF_128
4131               (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>")))
4132           (match_dup 1)
4133           (const_int 1)))]
4134   "TARGET_FMA || TARGET_AVX512F"
4135   "@
4136    vfnmsub132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
4137    vfnmsub213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
4138   [(set_attr "type" "ssemuladd")
4139    (set_attr "mode" "<MODE>")])
4141 ;; FMA4 floating point scalar intrinsics.  These write the
4142 ;; entire destination register, with the high-order elements zeroed.
4144 (define_expand "fma4i_vmfmadd_<mode>"
4145   [(set (match_operand:VF_128 0 "register_operand")
4146         (vec_merge:VF_128
4147           (fma:VF_128
4148             (match_operand:VF_128 1 "nonimmediate_operand")
4149             (match_operand:VF_128 2 "nonimmediate_operand")
4150             (match_operand:VF_128 3 "nonimmediate_operand"))
4151           (match_dup 4)
4152           (const_int 1)))]
4153   "TARGET_FMA4"
4154   "operands[4] = CONST0_RTX (<MODE>mode);")
4156 (define_insn "*fma4i_vmfmadd_<mode>"
4157   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4158         (vec_merge:VF_128
4159           (fma:VF_128
4160             (match_operand:VF_128 1 "nonimmediate_operand" "%x,x")
4161             (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
4162             (match_operand:VF_128 3 "nonimmediate_operand" "xm,x"))
4163           (match_operand:VF_128 4 "const0_operand")
4164           (const_int 1)))]
4165   "TARGET_FMA4"
4166   "vfmadd<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4167   [(set_attr "type" "ssemuladd")
4168    (set_attr "mode" "<MODE>")])
4170 (define_insn "*fma4i_vmfmsub_<mode>"
4171   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4172         (vec_merge:VF_128
4173           (fma:VF_128
4174             (match_operand:VF_128 1 "nonimmediate_operand" "%x,x")
4175             (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
4176             (neg:VF_128
4177               (match_operand:VF_128 3 "nonimmediate_operand" "xm,x")))
4178           (match_operand:VF_128 4 "const0_operand")
4179           (const_int 1)))]
4180   "TARGET_FMA4"
4181   "vfmsub<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4182   [(set_attr "type" "ssemuladd")
4183    (set_attr "mode" "<MODE>")])
4185 (define_insn "*fma4i_vmfnmadd_<mode>"
4186   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4187         (vec_merge:VF_128
4188           (fma:VF_128
4189             (neg:VF_128
4190               (match_operand:VF_128 1 "nonimmediate_operand" "%x,x"))
4191             (match_operand:VF_128   2 "nonimmediate_operand" " x,m")
4192             (match_operand:VF_128   3 "nonimmediate_operand" "xm,x"))
4193           (match_operand:VF_128 4 "const0_operand")
4194           (const_int 1)))]
4195   "TARGET_FMA4"
4196   "vfnmadd<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4197   [(set_attr "type" "ssemuladd")
4198    (set_attr "mode" "<MODE>")])
4200 (define_insn "*fma4i_vmfnmsub_<mode>"
4201   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
4202         (vec_merge:VF_128
4203           (fma:VF_128
4204             (neg:VF_128
4205               (match_operand:VF_128 1 "nonimmediate_operand" "%x,x"))
4206             (match_operand:VF_128   2 "nonimmediate_operand" " x,m")
4207             (neg:VF_128
4208               (match_operand:VF_128   3 "nonimmediate_operand" "xm,x")))
4209           (match_operand:VF_128 4 "const0_operand")
4210           (const_int 1)))]
4211   "TARGET_FMA4"
4212   "vfnmsub<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
4213   [(set_attr "type" "ssemuladd")
4214    (set_attr "mode" "<MODE>")])
4216 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4218 ;; Parallel single-precision floating point conversion operations
4220 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4222 (define_insn "sse_cvtpi2ps"
4223   [(set (match_operand:V4SF 0 "register_operand" "=x")
4224         (vec_merge:V4SF
4225           (vec_duplicate:V4SF
4226             (float:V2SF (match_operand:V2SI 2 "nonimmediate_operand" "ym")))
4227           (match_operand:V4SF 1 "register_operand" "0")
4228           (const_int 3)))]
4229   "TARGET_SSE"
4230   "cvtpi2ps\t{%2, %0|%0, %2}"
4231   [(set_attr "type" "ssecvt")
4232    (set_attr "mode" "V4SF")])
4234 (define_insn "sse_cvtps2pi"
4235   [(set (match_operand:V2SI 0 "register_operand" "=y")
4236         (vec_select:V2SI
4237           (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
4238                        UNSPEC_FIX_NOTRUNC)
4239           (parallel [(const_int 0) (const_int 1)])))]
4240   "TARGET_SSE"
4241   "cvtps2pi\t{%1, %0|%0, %q1}"
4242   [(set_attr "type" "ssecvt")
4243    (set_attr "unit" "mmx")
4244    (set_attr "mode" "DI")])
4246 (define_insn "sse_cvttps2pi"
4247   [(set (match_operand:V2SI 0 "register_operand" "=y")
4248         (vec_select:V2SI
4249           (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
4250           (parallel [(const_int 0) (const_int 1)])))]
4251   "TARGET_SSE"
4252   "cvttps2pi\t{%1, %0|%0, %q1}"
4253   [(set_attr "type" "ssecvt")
4254    (set_attr "unit" "mmx")
4255    (set_attr "prefix_rep" "0")
4256    (set_attr "mode" "SF")])
4258 (define_insn "sse_cvtsi2ss<round_name>"
4259   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
4260         (vec_merge:V4SF
4261           (vec_duplicate:V4SF
4262             (float:SF (match_operand:SI 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
4263           (match_operand:V4SF 1 "register_operand" "0,0,v")
4264           (const_int 1)))]
4265   "TARGET_SSE"
4266   "@
4267    cvtsi2ss\t{%2, %0|%0, %2}
4268    cvtsi2ss\t{%2, %0|%0, %2}
4269    vcvtsi2ss\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4270   [(set_attr "isa" "noavx,noavx,avx")
4271    (set_attr "type" "sseicvt")
4272    (set_attr "athlon_decode" "vector,double,*")
4273    (set_attr "amdfam10_decode" "vector,double,*")
4274    (set_attr "bdver1_decode" "double,direct,*")
4275    (set_attr "btver2_decode" "double,double,double")
4276    (set_attr "znver1_decode" "double,double,double")
4277    (set_attr "prefix" "orig,orig,maybe_evex")
4278    (set_attr "mode" "SF")])
4280 (define_insn "sse_cvtsi2ssq<round_name>"
4281   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
4282         (vec_merge:V4SF
4283           (vec_duplicate:V4SF
4284             (float:SF (match_operand:DI 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
4285           (match_operand:V4SF 1 "register_operand" "0,0,v")
4286           (const_int 1)))]
4287   "TARGET_SSE && TARGET_64BIT"
4288   "@
4289    cvtsi2ssq\t{%2, %0|%0, %2}
4290    cvtsi2ssq\t{%2, %0|%0, %2}
4291    vcvtsi2ssq\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4292   [(set_attr "isa" "noavx,noavx,avx")
4293    (set_attr "type" "sseicvt")
4294    (set_attr "athlon_decode" "vector,double,*")
4295    (set_attr "amdfam10_decode" "vector,double,*")
4296    (set_attr "bdver1_decode" "double,direct,*")
4297    (set_attr "btver2_decode" "double,double,double")
4298    (set_attr "length_vex" "*,*,4")
4299    (set_attr "prefix_rex" "1,1,*")
4300    (set_attr "prefix" "orig,orig,maybe_evex")
4301    (set_attr "mode" "SF")])
4303 (define_insn "sse_cvtss2si<round_name>"
4304   [(set (match_operand:SI 0 "register_operand" "=r,r")
4305         (unspec:SI
4306           [(vec_select:SF
4307              (match_operand:V4SF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4308              (parallel [(const_int 0)]))]
4309           UNSPEC_FIX_NOTRUNC))]
4310   "TARGET_SSE"
4311   "%vcvtss2si\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
4312   [(set_attr "type" "sseicvt")
4313    (set_attr "athlon_decode" "double,vector")
4314    (set_attr "bdver1_decode" "double,double")
4315    (set_attr "prefix_rep" "1")
4316    (set_attr "prefix" "maybe_vex")
4317    (set_attr "mode" "SI")])
4319 (define_insn "sse_cvtss2si_2"
4320   [(set (match_operand:SI 0 "register_operand" "=r,r")
4321         (unspec:SI [(match_operand:SF 1 "nonimmediate_operand" "v,m")]
4322                    UNSPEC_FIX_NOTRUNC))]
4323   "TARGET_SSE"
4324   "%vcvtss2si\t{%1, %0|%0, %k1}"
4325   [(set_attr "type" "sseicvt")
4326    (set_attr "athlon_decode" "double,vector")
4327    (set_attr "amdfam10_decode" "double,double")
4328    (set_attr "bdver1_decode" "double,double")
4329    (set_attr "prefix_rep" "1")
4330    (set_attr "prefix" "maybe_vex")
4331    (set_attr "mode" "SI")])
4333 (define_insn "sse_cvtss2siq<round_name>"
4334   [(set (match_operand:DI 0 "register_operand" "=r,r")
4335         (unspec:DI
4336           [(vec_select:SF
4337              (match_operand:V4SF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4338              (parallel [(const_int 0)]))]
4339           UNSPEC_FIX_NOTRUNC))]
4340   "TARGET_SSE && TARGET_64BIT"
4341   "%vcvtss2si{q}\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
4342   [(set_attr "type" "sseicvt")
4343    (set_attr "athlon_decode" "double,vector")
4344    (set_attr "bdver1_decode" "double,double")
4345    (set_attr "prefix_rep" "1")
4346    (set_attr "prefix" "maybe_vex")
4347    (set_attr "mode" "DI")])
4349 (define_insn "sse_cvtss2siq_2"
4350   [(set (match_operand:DI 0 "register_operand" "=r,r")
4351         (unspec:DI [(match_operand:SF 1 "nonimmediate_operand" "v,m")]
4352                    UNSPEC_FIX_NOTRUNC))]
4353   "TARGET_SSE && TARGET_64BIT"
4354   "%vcvtss2si{q}\t{%1, %0|%0, %k1}"
4355   [(set_attr "type" "sseicvt")
4356    (set_attr "athlon_decode" "double,vector")
4357    (set_attr "amdfam10_decode" "double,double")
4358    (set_attr "bdver1_decode" "double,double")
4359    (set_attr "prefix_rep" "1")
4360    (set_attr "prefix" "maybe_vex")
4361    (set_attr "mode" "DI")])
4363 (define_insn "sse_cvttss2si<round_saeonly_name>"
4364   [(set (match_operand:SI 0 "register_operand" "=r,r")
4365         (fix:SI
4366           (vec_select:SF
4367             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint2>")
4368             (parallel [(const_int 0)]))))]
4369   "TARGET_SSE"
4370   "%vcvttss2si\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
4371   [(set_attr "type" "sseicvt")
4372    (set_attr "athlon_decode" "double,vector")
4373    (set_attr "amdfam10_decode" "double,double")
4374    (set_attr "bdver1_decode" "double,double")
4375    (set_attr "prefix_rep" "1")
4376    (set_attr "prefix" "maybe_vex")
4377    (set_attr "mode" "SI")])
4379 (define_insn "sse_cvttss2siq<round_saeonly_name>"
4380   [(set (match_operand:DI 0 "register_operand" "=r,r")
4381         (fix:DI
4382           (vec_select:SF
4383             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint>")
4384             (parallel [(const_int 0)]))))]
4385   "TARGET_SSE && TARGET_64BIT"
4386   "%vcvttss2si{q}\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
4387   [(set_attr "type" "sseicvt")
4388    (set_attr "athlon_decode" "double,vector")
4389    (set_attr "amdfam10_decode" "double,double")
4390    (set_attr "bdver1_decode" "double,double")
4391    (set_attr "prefix_rep" "1")
4392    (set_attr "prefix" "maybe_vex")
4393    (set_attr "mode" "DI")])
4395 (define_insn "cvtusi2<ssescalarmodesuffix>32<round_name>"
4396   [(set (match_operand:VF_128 0 "register_operand" "=v")
4397         (vec_merge:VF_128
4398           (vec_duplicate:VF_128
4399             (unsigned_float:<ssescalarmode>
4400               (match_operand:SI 2 "<round_nimm_predicate>" "<round_constraint3>")))
4401           (match_operand:VF_128 1 "register_operand" "v")
4402           (const_int 1)))]
4403   "TARGET_AVX512F && <round_modev4sf_condition>"
4404   "vcvtusi2<ssescalarmodesuffix>\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4405   [(set_attr "type" "sseicvt")
4406    (set_attr "prefix" "evex")
4407    (set_attr "mode" "<ssescalarmode>")])
4409 (define_insn "cvtusi2<ssescalarmodesuffix>64<round_name>"
4410   [(set (match_operand:VF_128 0 "register_operand" "=v")
4411         (vec_merge:VF_128
4412           (vec_duplicate:VF_128
4413             (unsigned_float:<ssescalarmode>
4414               (match_operand:DI 2 "<round_nimm_predicate>" "<round_constraint3>")))
4415           (match_operand:VF_128 1 "register_operand" "v")
4416           (const_int 1)))]
4417   "TARGET_AVX512F && TARGET_64BIT"
4418   "vcvtusi2<ssescalarmodesuffix>\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4419   [(set_attr "type" "sseicvt")
4420    (set_attr "prefix" "evex")
4421    (set_attr "mode" "<ssescalarmode>")])
4423 (define_insn "float<sseintvecmodelower><mode>2<mask_name><round_name>"
4424   [(set (match_operand:VF1 0 "register_operand" "=x,v")
4425         (float:VF1
4426           (match_operand:<sseintvecmode> 1 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
4427   "TARGET_SSE2 && <mask_mode512bit_condition> && <round_mode512bit_condition>"
4428   "@
4429    cvtdq2ps\t{%1, %0|%0, %1}
4430    vcvtdq2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4431   [(set_attr "isa" "noavx,avx")
4432    (set_attr "type" "ssecvt")
4433    (set_attr "prefix" "maybe_vex")
4434    (set_attr "mode" "<sseinsnmode>")])
4436 (define_insn "ufloat<sseintvecmodelower><mode>2<mask_name><round_name>"
4437   [(set (match_operand:VF1_AVX512VL 0 "register_operand" "=v")
4438         (unsigned_float:VF1_AVX512VL
4439           (match_operand:<sseintvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
4440   "TARGET_AVX512F"
4441   "vcvtudq2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4442   [(set_attr "type" "ssecvt")
4443    (set_attr "prefix" "evex")
4444    (set_attr "mode" "<MODE>")])
4446 (define_expand "floatuns<sseintvecmodelower><mode>2"
4447   [(match_operand:VF1 0 "register_operand")
4448    (match_operand:<sseintvecmode> 1 "register_operand")]
4449   "TARGET_SSE2 && (<MODE>mode == V4SFmode || TARGET_AVX2)"
4451   if (<MODE>mode == V16SFmode)
4452     emit_insn (gen_ufloatv16siv16sf2 (operands[0], operands[1]));
4453   else
4454     if (TARGET_AVX512VL)
4455       {
4456         if (<MODE>mode == V4SFmode)
4457           emit_insn (gen_ufloatv4siv4sf2 (operands[0], operands[1]));
4458         else
4459           emit_insn (gen_ufloatv8siv8sf2 (operands[0], operands[1]));
4460       }
4461   else
4462     ix86_expand_vector_convert_uns_vsivsf (operands[0], operands[1]);
4464   DONE;
4468 ;; For <sse2_avx_avx512f>_fix_notrunc<sf2simodelower><mode> insn pattern
4469 (define_mode_attr sf2simodelower
4470   [(V16SI "v16sf") (V8SI "v8sf") (V4SI "v4sf")])
4472 (define_insn "<sse2_avx_avx512f>_fix_notrunc<sf2simodelower><mode><mask_name>"
4473   [(set (match_operand:VI4_AVX 0 "register_operand" "=v")
4474         (unspec:VI4_AVX
4475           [(match_operand:<ssePSmode> 1 "vector_operand" "vBm")]
4476           UNSPEC_FIX_NOTRUNC))]
4477   "TARGET_SSE2 && <mask_mode512bit_condition>"
4478   "%vcvtps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4479   [(set_attr "type" "ssecvt")
4480    (set (attr "prefix_data16")
4481      (if_then_else
4482        (match_test "TARGET_AVX")
4483      (const_string "*")
4484      (const_string "1")))
4485    (set_attr "prefix" "maybe_vex")
4486    (set_attr "mode" "<sseinsnmode>")])
4488 (define_insn "<mask_codefor>avx512f_fix_notruncv16sfv16si<mask_name><round_name>"
4489   [(set (match_operand:V16SI 0 "register_operand" "=v")
4490         (unspec:V16SI
4491           [(match_operand:V16SF 1 "<round_nimm_predicate>" "<round_constraint>")]
4492           UNSPEC_FIX_NOTRUNC))]
4493   "TARGET_AVX512F"
4494   "vcvtps2dq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4495   [(set_attr "type" "ssecvt")
4496    (set_attr "prefix" "evex")
4497    (set_attr "mode" "XI")])
4499 (define_insn "<mask_codefor><avx512>_ufix_notrunc<sf2simodelower><mode><mask_name><round_name>"
4500   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
4501         (unspec:VI4_AVX512VL
4502           [(match_operand:<ssePSmode> 1 "nonimmediate_operand" "<round_constraint>")]
4503           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4504   "TARGET_AVX512F"
4505   "vcvtps2udq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4506   [(set_attr "type" "ssecvt")
4507    (set_attr "prefix" "evex")
4508    (set_attr "mode" "<sseinsnmode>")])
4510 (define_insn "<mask_codefor>avx512dq_cvtps2qq<mode><mask_name><round_name>"
4511   [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
4512         (unspec:VI8_256_512 [(match_operand:<ssePSmode2> 1 "nonimmediate_operand" "<round_constraint>")]
4513                      UNSPEC_FIX_NOTRUNC))]
4514   "TARGET_AVX512DQ && <round_mode512bit_condition>"
4515   "vcvtps2qq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4516   [(set_attr "type" "ssecvt")
4517    (set_attr "prefix" "evex")
4518    (set_attr "mode" "<sseinsnmode>")])
4520 (define_insn "<mask_codefor>avx512dq_cvtps2qqv2di<mask_name>"
4521   [(set (match_operand:V2DI 0 "register_operand" "=v")
4522         (unspec:V2DI
4523           [(vec_select:V2SF
4524              (match_operand:V4SF 1 "nonimmediate_operand" "vm")
4525              (parallel [(const_int 0) (const_int 1)]))]
4526           UNSPEC_FIX_NOTRUNC))]
4527   "TARGET_AVX512DQ && TARGET_AVX512VL"
4528   "vcvtps2qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4529   [(set_attr "type" "ssecvt")
4530    (set_attr "prefix" "evex")
4531    (set_attr "mode" "TI")])
4533 (define_insn "<mask_codefor>avx512dq_cvtps2uqq<mode><mask_name><round_name>"
4534   [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
4535         (unspec:VI8_256_512 [(match_operand:<ssePSmode2> 1 "nonimmediate_operand" "<round_constraint>")]
4536                      UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4537   "TARGET_AVX512DQ && <round_mode512bit_condition>"
4538   "vcvtps2uqq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4539   [(set_attr "type" "ssecvt")
4540    (set_attr "prefix" "evex")
4541    (set_attr "mode" "<sseinsnmode>")])
4543 (define_insn "<mask_codefor>avx512dq_cvtps2uqqv2di<mask_name>"
4544   [(set (match_operand:V2DI 0 "register_operand" "=v")
4545         (unspec:V2DI
4546           [(vec_select:V2SF
4547              (match_operand:V4SF 1 "nonimmediate_operand" "vm")
4548              (parallel [(const_int 0) (const_int 1)]))]
4549           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4550   "TARGET_AVX512DQ && TARGET_AVX512VL"
4551   "vcvtps2uqq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4552   [(set_attr "type" "ssecvt")
4553    (set_attr "prefix" "evex")
4554    (set_attr "mode" "TI")])
4556 (define_insn "<fixsuffix>fix_truncv16sfv16si2<mask_name><round_saeonly_name>"
4557   [(set (match_operand:V16SI 0 "register_operand" "=v")
4558         (any_fix:V16SI
4559           (match_operand:V16SF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
4560   "TARGET_AVX512F"
4561   "vcvttps2<fixsuffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
4562   [(set_attr "type" "ssecvt")
4563    (set_attr "prefix" "evex")
4564    (set_attr "mode" "XI")])
4566 (define_insn "fix_truncv8sfv8si2<mask_name>"
4567   [(set (match_operand:V8SI 0 "register_operand" "=v")
4568         (fix:V8SI (match_operand:V8SF 1 "nonimmediate_operand" "vm")))]
4569   "TARGET_AVX && <mask_avx512vl_condition>"
4570   "vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4571   [(set_attr "type" "ssecvt")
4572    (set_attr "prefix" "<mask_prefix>")
4573    (set_attr "mode" "OI")])
4575 (define_insn "fix_truncv4sfv4si2<mask_name>"
4576   [(set (match_operand:V4SI 0 "register_operand" "=v")
4577         (fix:V4SI (match_operand:V4SF 1 "vector_operand" "vBm")))]
4578   "TARGET_SSE2 && <mask_avx512vl_condition>"
4579   "%vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4580   [(set_attr "type" "ssecvt")
4581    (set (attr "prefix_rep")
4582      (if_then_else
4583        (match_test "TARGET_AVX")
4584      (const_string "*")
4585      (const_string "1")))
4586    (set (attr "prefix_data16")
4587      (if_then_else
4588        (match_test "TARGET_AVX")
4589      (const_string "*")
4590      (const_string "0")))
4591    (set_attr "prefix_data16" "0")
4592    (set_attr "prefix" "<mask_prefix2>")
4593    (set_attr "mode" "TI")])
4595 (define_expand "fixuns_trunc<mode><sseintvecmodelower>2"
4596   [(match_operand:<sseintvecmode> 0 "register_operand")
4597    (match_operand:VF1 1 "register_operand")]
4598   "TARGET_SSE2"
4600   if (<MODE>mode == V16SFmode)
4601     emit_insn (gen_ufix_truncv16sfv16si2 (operands[0],
4602                                           operands[1]));
4603   else
4604     {
4605       rtx tmp[3];
4606       tmp[0] = ix86_expand_adjust_ufix_to_sfix_si (operands[1], &tmp[2]);
4607       tmp[1] = gen_reg_rtx (<sseintvecmode>mode);
4608       emit_insn (gen_fix_trunc<mode><sseintvecmodelower>2 (tmp[1], tmp[0]));
4609       emit_insn (gen_xor<sseintvecmodelower>3 (operands[0], tmp[1], tmp[2]));
4610     }
4611   DONE;
4614 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4616 ;; Parallel double-precision floating point conversion operations
4618 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4620 (define_insn "sse2_cvtpi2pd"
4621   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
4622         (float:V2DF (match_operand:V2SI 1 "nonimmediate_operand" "y,m")))]
4623   "TARGET_SSE2"
4624   "cvtpi2pd\t{%1, %0|%0, %1}"
4625   [(set_attr "type" "ssecvt")
4626    (set_attr "unit" "mmx,*")
4627    (set_attr "prefix_data16" "1,*")
4628    (set_attr "mode" "V2DF")])
4630 (define_insn "sse2_cvtpd2pi"
4631   [(set (match_operand:V2SI 0 "register_operand" "=y")
4632         (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "xm")]
4633                      UNSPEC_FIX_NOTRUNC))]
4634   "TARGET_SSE2"
4635   "cvtpd2pi\t{%1, %0|%0, %1}"
4636   [(set_attr "type" "ssecvt")
4637    (set_attr "unit" "mmx")
4638    (set_attr "bdver1_decode" "double")
4639    (set_attr "btver2_decode" "direct")
4640    (set_attr "prefix_data16" "1")
4641    (set_attr "mode" "DI")])
4643 (define_insn "sse2_cvttpd2pi"
4644   [(set (match_operand:V2SI 0 "register_operand" "=y")
4645         (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "xm")))]
4646   "TARGET_SSE2"
4647   "cvttpd2pi\t{%1, %0|%0, %1}"
4648   [(set_attr "type" "ssecvt")
4649    (set_attr "unit" "mmx")
4650    (set_attr "bdver1_decode" "double")
4651    (set_attr "prefix_data16" "1")
4652    (set_attr "mode" "TI")])
4654 (define_insn "sse2_cvtsi2sd"
4655   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
4656         (vec_merge:V2DF
4657           (vec_duplicate:V2DF
4658             (float:DF (match_operand:SI 2 "nonimmediate_operand" "r,m,rm")))
4659           (match_operand:V2DF 1 "register_operand" "0,0,v")
4660           (const_int 1)))]
4661   "TARGET_SSE2"
4662   "@
4663    cvtsi2sd\t{%2, %0|%0, %2}
4664    cvtsi2sd\t{%2, %0|%0, %2}
4665    vcvtsi2sd\t{%2, %1, %0|%0, %1, %2}"
4666   [(set_attr "isa" "noavx,noavx,avx")
4667    (set_attr "type" "sseicvt")
4668    (set_attr "athlon_decode" "double,direct,*")
4669    (set_attr "amdfam10_decode" "vector,double,*")
4670    (set_attr "bdver1_decode" "double,direct,*")
4671    (set_attr "btver2_decode" "double,double,double")
4672    (set_attr "znver1_decode" "double,double,double")
4673    (set_attr "prefix" "orig,orig,maybe_evex")
4674    (set_attr "mode" "DF")])
4676 (define_insn "sse2_cvtsi2sdq<round_name>"
4677   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
4678         (vec_merge:V2DF
4679           (vec_duplicate:V2DF
4680             (float:DF (match_operand:DI 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
4681           (match_operand:V2DF 1 "register_operand" "0,0,v")
4682           (const_int 1)))]
4683   "TARGET_SSE2 && TARGET_64BIT"
4684   "@
4685    cvtsi2sdq\t{%2, %0|%0, %2}
4686    cvtsi2sdq\t{%2, %0|%0, %2}
4687    vcvtsi2sdq\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4688   [(set_attr "isa" "noavx,noavx,avx")
4689    (set_attr "type" "sseicvt")
4690    (set_attr "athlon_decode" "double,direct,*")
4691    (set_attr "amdfam10_decode" "vector,double,*")
4692    (set_attr "bdver1_decode" "double,direct,*")
4693    (set_attr "length_vex" "*,*,4")
4694    (set_attr "prefix_rex" "1,1,*")
4695    (set_attr "prefix" "orig,orig,maybe_evex")
4696    (set_attr "mode" "DF")])
4698 (define_insn "avx512f_vcvtss2usi<round_name>"
4699   [(set (match_operand:SI 0 "register_operand" "=r")
4700         (unspec:SI
4701           [(vec_select:SF
4702              (match_operand:V4SF 1 "<round_nimm_predicate>" "<round_constraint>")
4703              (parallel [(const_int 0)]))]
4704           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4705   "TARGET_AVX512F"
4706   "vcvtss2usi\t{<round_op2>%1, %0|%0, %1<round_op2>}"
4707   [(set_attr "type" "sseicvt")
4708    (set_attr "prefix" "evex")
4709    (set_attr "mode" "SI")])
4711 (define_insn "avx512f_vcvtss2usiq<round_name>"
4712   [(set (match_operand:DI 0 "register_operand" "=r")
4713         (unspec:DI
4714           [(vec_select:SF
4715              (match_operand:V4SF 1 "<round_nimm_predicate>" "<round_constraint>")
4716              (parallel [(const_int 0)]))]
4717           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4718   "TARGET_AVX512F && TARGET_64BIT"
4719   "vcvtss2usi\t{<round_op2>%1, %0|%0, %1<round_op2>}"
4720   [(set_attr "type" "sseicvt")
4721    (set_attr "prefix" "evex")
4722    (set_attr "mode" "DI")])
4724 (define_insn "avx512f_vcvttss2usi<round_saeonly_name>"
4725   [(set (match_operand:SI 0 "register_operand" "=r")
4726         (unsigned_fix:SI
4727           (vec_select:SF
4728             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4729             (parallel [(const_int 0)]))))]
4730   "TARGET_AVX512F"
4731   "vcvttss2usi\t{<round_saeonly_op2>%1, %0|%0, %1<round_saeonly_op2>}"
4732   [(set_attr "type" "sseicvt")
4733    (set_attr "prefix" "evex")
4734    (set_attr "mode" "SI")])
4736 (define_insn "avx512f_vcvttss2usiq<round_saeonly_name>"
4737   [(set (match_operand:DI 0 "register_operand" "=r")
4738         (unsigned_fix:DI
4739           (vec_select:SF
4740             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4741             (parallel [(const_int 0)]))))]
4742   "TARGET_AVX512F && TARGET_64BIT"
4743   "vcvttss2usi\t{<round_saeonly_op2>%1, %0|%0, %1<round_saeonly_op2>}"
4744   [(set_attr "type" "sseicvt")
4745    (set_attr "prefix" "evex")
4746    (set_attr "mode" "DI")])
4748 (define_insn "avx512f_vcvtsd2usi<round_name>"
4749   [(set (match_operand:SI 0 "register_operand" "=r")
4750         (unspec:SI
4751           [(vec_select:DF
4752              (match_operand:V2DF 1 "<round_nimm_predicate>" "<round_constraint>")
4753              (parallel [(const_int 0)]))]
4754           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4755   "TARGET_AVX512F"
4756   "vcvtsd2usi\t{<round_op2>%1, %0|%0, %1<round_op2>}"
4757   [(set_attr "type" "sseicvt")
4758    (set_attr "prefix" "evex")
4759    (set_attr "mode" "SI")])
4761 (define_insn "avx512f_vcvtsd2usiq<round_name>"
4762   [(set (match_operand:DI 0 "register_operand" "=r")
4763         (unspec:DI
4764           [(vec_select:DF
4765              (match_operand:V2DF 1 "<round_nimm_predicate>" "<round_constraint>")
4766              (parallel [(const_int 0)]))]
4767           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4768   "TARGET_AVX512F && TARGET_64BIT"
4769   "vcvtsd2usi\t{<round_op2>%1, %0|%0, %1<round_op2>}"
4770   [(set_attr "type" "sseicvt")
4771    (set_attr "prefix" "evex")
4772    (set_attr "mode" "DI")])
4774 (define_insn "avx512f_vcvttsd2usi<round_saeonly_name>"
4775   [(set (match_operand:SI 0 "register_operand" "=r")
4776         (unsigned_fix:SI
4777           (vec_select:DF
4778             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4779             (parallel [(const_int 0)]))))]
4780   "TARGET_AVX512F"
4781   "vcvttsd2usi\t{<round_saeonly_op2>%1, %0|%0, %1<round_saeonly_op2>}"
4782   [(set_attr "type" "sseicvt")
4783    (set_attr "prefix" "evex")
4784    (set_attr "mode" "SI")])
4786 (define_insn "avx512f_vcvttsd2usiq<round_saeonly_name>"
4787   [(set (match_operand:DI 0 "register_operand" "=r")
4788         (unsigned_fix:DI
4789           (vec_select:DF
4790             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4791             (parallel [(const_int 0)]))))]
4792   "TARGET_AVX512F && TARGET_64BIT"
4793   "vcvttsd2usi\t{<round_saeonly_op2>%1, %0|%0, %1<round_saeonly_op2>}"
4794   [(set_attr "type" "sseicvt")
4795    (set_attr "prefix" "evex")
4796    (set_attr "mode" "DI")])
4798 (define_insn "sse2_cvtsd2si<round_name>"
4799   [(set (match_operand:SI 0 "register_operand" "=r,r")
4800         (unspec:SI
4801           [(vec_select:DF
4802              (match_operand:V2DF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4803              (parallel [(const_int 0)]))]
4804           UNSPEC_FIX_NOTRUNC))]
4805   "TARGET_SSE2"
4806   "%vcvtsd2si\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
4807   [(set_attr "type" "sseicvt")
4808    (set_attr "athlon_decode" "double,vector")
4809    (set_attr "bdver1_decode" "double,double")
4810    (set_attr "btver2_decode" "double,double")
4811    (set_attr "prefix_rep" "1")
4812    (set_attr "prefix" "maybe_vex")
4813    (set_attr "mode" "SI")])
4815 (define_insn "sse2_cvtsd2si_2"
4816   [(set (match_operand:SI 0 "register_operand" "=r,r")
4817         (unspec:SI [(match_operand:DF 1 "nonimmediate_operand" "v,m")]
4818                    UNSPEC_FIX_NOTRUNC))]
4819   "TARGET_SSE2"
4820   "%vcvtsd2si\t{%1, %0|%0, %q1}"
4821   [(set_attr "type" "sseicvt")
4822    (set_attr "athlon_decode" "double,vector")
4823    (set_attr "amdfam10_decode" "double,double")
4824    (set_attr "bdver1_decode" "double,double")
4825    (set_attr "prefix_rep" "1")
4826    (set_attr "prefix" "maybe_vex")
4827    (set_attr "mode" "SI")])
4829 (define_insn "sse2_cvtsd2siq<round_name>"
4830   [(set (match_operand:DI 0 "register_operand" "=r,r")
4831         (unspec:DI
4832           [(vec_select:DF
4833              (match_operand:V2DF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4834              (parallel [(const_int 0)]))]
4835           UNSPEC_FIX_NOTRUNC))]
4836   "TARGET_SSE2 && TARGET_64BIT"
4837   "%vcvtsd2si{q}\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
4838   [(set_attr "type" "sseicvt")
4839    (set_attr "athlon_decode" "double,vector")
4840    (set_attr "bdver1_decode" "double,double")
4841    (set_attr "prefix_rep" "1")
4842    (set_attr "prefix" "maybe_vex")
4843    (set_attr "mode" "DI")])
4845 (define_insn "sse2_cvtsd2siq_2"
4846   [(set (match_operand:DI 0 "register_operand" "=r,r")
4847         (unspec:DI [(match_operand:DF 1 "nonimmediate_operand" "v,m")]
4848                    UNSPEC_FIX_NOTRUNC))]
4849   "TARGET_SSE2 && TARGET_64BIT"
4850   "%vcvtsd2si{q}\t{%1, %0|%0, %q1}"
4851   [(set_attr "type" "sseicvt")
4852    (set_attr "athlon_decode" "double,vector")
4853    (set_attr "amdfam10_decode" "double,double")
4854    (set_attr "bdver1_decode" "double,double")
4855    (set_attr "prefix_rep" "1")
4856    (set_attr "prefix" "maybe_vex")
4857    (set_attr "mode" "DI")])
4859 (define_insn "sse2_cvttsd2si<round_saeonly_name>"
4860   [(set (match_operand:SI 0 "register_operand" "=r,r")
4861         (fix:SI
4862           (vec_select:DF
4863             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint2>")
4864             (parallel [(const_int 0)]))))]
4865   "TARGET_SSE2"
4866   "%vcvttsd2si\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
4867   [(set_attr "type" "sseicvt")
4868    (set_attr "athlon_decode" "double,vector")
4869    (set_attr "amdfam10_decode" "double,double")
4870    (set_attr "bdver1_decode" "double,double")
4871    (set_attr "btver2_decode" "double,double")
4872    (set_attr "prefix_rep" "1")
4873    (set_attr "prefix" "maybe_vex")
4874    (set_attr "mode" "SI")])
4876 (define_insn "sse2_cvttsd2siq<round_saeonly_name>"
4877   [(set (match_operand:DI 0 "register_operand" "=r,r")
4878         (fix:DI
4879           (vec_select:DF
4880             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint2>")
4881             (parallel [(const_int 0)]))))]
4882   "TARGET_SSE2 && TARGET_64BIT"
4883   "%vcvttsd2si{q}\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
4884   [(set_attr "type" "sseicvt")
4885    (set_attr "athlon_decode" "double,vector")
4886    (set_attr "amdfam10_decode" "double,double")
4887    (set_attr "bdver1_decode" "double,double")
4888    (set_attr "prefix_rep" "1")
4889    (set_attr "prefix" "maybe_vex")
4890    (set_attr "mode" "DI")])
4892 ;; For float<si2dfmode><mode>2 insn pattern
4893 (define_mode_attr si2dfmode
4894   [(V8DF "V8SI") (V4DF "V4SI")])
4895 (define_mode_attr si2dfmodelower
4896   [(V8DF "v8si") (V4DF "v4si")])
4898 (define_insn "float<si2dfmodelower><mode>2<mask_name>"
4899   [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
4900         (float:VF2_512_256 (match_operand:<si2dfmode> 1 "nonimmediate_operand" "vm")))]
4901   "TARGET_AVX && <mask_mode512bit_condition>"
4902   "vcvtdq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4903   [(set_attr "type" "ssecvt")
4904    (set_attr "prefix" "maybe_vex")
4905    (set_attr "mode" "<MODE>")])
4907 (define_insn "<floatsuffix>float<sseintvecmodelower><mode>2<mask_name><round_name>"
4908   [(set (match_operand:VF2_AVX512VL 0 "register_operand" "=v")
4909         (any_float:VF2_AVX512VL
4910           (match_operand:<sseintvecmode> 1 "nonimmediate_operand" "vm")))]
4911   "TARGET_AVX512DQ"
4912   "vcvt<floatsuffix>qq2pd\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4913   [(set_attr "type" "ssecvt")
4914    (set_attr "prefix" "evex")
4915    (set_attr "mode" "<MODE>")])
4917 ;; For <floatsuffix>float<sselondveclower><mode> insn patterns
4918 (define_mode_attr qq2pssuff
4919   [(V8SF "") (V4SF "{y}")])
4921 (define_mode_attr sselongvecmode
4922   [(V8SF "V8DI") (V4SF  "V4DI")])
4924 (define_mode_attr sselongvecmodelower
4925   [(V8SF "v8di") (V4SF  "v4di")])
4927 (define_mode_attr sseintvecmode3
4928   [(V8SF "XI") (V4SF "OI")
4929    (V8DF "OI") (V4DF "TI")])
4931 (define_insn "<floatsuffix>float<sselongvecmodelower><mode>2<mask_name><round_name>"
4932   [(set (match_operand:VF1_128_256VL 0 "register_operand" "=v")
4933          (any_float:VF1_128_256VL
4934            (match_operand:<sselongvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
4935   "TARGET_AVX512DQ && <round_modev8sf_condition>"
4936   "vcvt<floatsuffix>qq2ps<qq2pssuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4937   [(set_attr "type" "ssecvt")
4938    (set_attr "prefix" "evex")
4939    (set_attr "mode" "<MODE>")])
4941 (define_insn "*<floatsuffix>floatv2div2sf2"
4942   [(set (match_operand:V4SF 0 "register_operand" "=v")
4943     (vec_concat:V4SF
4944             (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
4945             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
4946   "TARGET_AVX512DQ && TARGET_AVX512VL"
4947   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0|%0, %1}"
4948   [(set_attr "type" "ssecvt")
4949    (set_attr "prefix" "evex")
4950    (set_attr "mode" "V4SF")])
4952 (define_insn "<floatsuffix>floatv2div2sf2_mask"
4953   [(set (match_operand:V4SF 0 "register_operand" "=v")
4954     (vec_concat:V4SF
4955         (vec_merge:V2SF
4956                 (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
4957             (vec_select:V2SF
4958                 (match_operand:V4SF 2 "vector_move_operand" "0C")
4959                 (parallel [(const_int 0) (const_int 1)]))
4960             (match_operand:QI 3 "register_operand" "Yk"))
4961             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
4962   "TARGET_AVX512DQ && TARGET_AVX512VL"
4963   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
4964   [(set_attr "type" "ssecvt")
4965    (set_attr "prefix" "evex")
4966    (set_attr "mode" "V4SF")])
4968 (define_insn "*<floatsuffix>floatv2div2sf2_mask_1"
4969   [(set (match_operand:V4SF 0 "register_operand" "=v")
4970     (vec_concat:V4SF
4971         (vec_merge:V2SF
4972                 (any_float:V2SF (match_operand:V2DI 1
4973                                   "nonimmediate_operand" "vm"))
4974             (const_vector:V2SF [(const_int 0) (const_int 0)])
4975             (match_operand:QI 2 "register_operand" "Yk"))
4976             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
4977   "TARGET_AVX512DQ && TARGET_AVX512VL"
4978   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
4979   [(set_attr "type" "ssecvt")
4980    (set_attr "prefix" "evex")
4981    (set_attr "mode" "V4SF")])
4983 (define_insn "ufloat<si2dfmodelower><mode>2<mask_name>"
4984   [(set (match_operand:VF2_512_256VL 0 "register_operand" "=v")
4985         (unsigned_float:VF2_512_256VL
4986           (match_operand:<si2dfmode> 1 "nonimmediate_operand" "vm")))]
4987    "TARGET_AVX512F"
4988    "vcvtudq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4989    [(set_attr "type" "ssecvt")
4990     (set_attr "prefix" "evex")
4991     (set_attr "mode" "<MODE>")])
4993 (define_insn "ufloatv2siv2df2<mask_name>"
4994   [(set (match_operand:V2DF 0 "register_operand" "=v")
4995         (unsigned_float:V2DF
4996           (vec_select:V2SI
4997             (match_operand:V4SI 1 "nonimmediate_operand" "vm")
4998             (parallel [(const_int 0) (const_int 1)]))))]
4999   "TARGET_AVX512VL"
5000   "vcvtudq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5001   [(set_attr "type" "ssecvt")
5002    (set_attr "prefix" "evex")
5003    (set_attr "mode" "V2DF")])
5005 (define_insn "avx512f_cvtdq2pd512_2"
5006   [(set (match_operand:V8DF 0 "register_operand" "=v")
5007         (float:V8DF
5008           (vec_select:V8SI
5009             (match_operand:V16SI 1 "nonimmediate_operand" "vm")
5010             (parallel [(const_int 0) (const_int 1)
5011                        (const_int 2) (const_int 3)
5012                        (const_int 4) (const_int 5)
5013                        (const_int 6) (const_int 7)]))))]
5014   "TARGET_AVX512F"
5015   "vcvtdq2pd\t{%t1, %0|%0, %t1}"
5016   [(set_attr "type" "ssecvt")
5017    (set_attr "prefix" "evex")
5018    (set_attr "mode" "V8DF")])
5020 (define_insn "avx_cvtdq2pd256_2"
5021   [(set (match_operand:V4DF 0 "register_operand" "=v")
5022         (float:V4DF
5023           (vec_select:V4SI
5024             (match_operand:V8SI 1 "nonimmediate_operand" "vm")
5025             (parallel [(const_int 0) (const_int 1)
5026                        (const_int 2) (const_int 3)]))))]
5027   "TARGET_AVX"
5028   "vcvtdq2pd\t{%x1, %0|%0, %x1}"
5029   [(set_attr "type" "ssecvt")
5030    (set_attr "prefix" "maybe_evex")
5031    (set_attr "mode" "V4DF")])
5033 (define_insn "sse2_cvtdq2pd<mask_name>"
5034   [(set (match_operand:V2DF 0 "register_operand" "=v")
5035         (float:V2DF
5036           (vec_select:V2SI
5037             (match_operand:V4SI 1 "nonimmediate_operand" "vm")
5038             (parallel [(const_int 0) (const_int 1)]))))]
5039   "TARGET_SSE2 && <mask_avx512vl_condition>"
5040   "%vcvtdq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5041   [(set_attr "type" "ssecvt")
5042    (set_attr "prefix" "maybe_vex")
5043    (set_attr "ssememalign" "64")
5044    (set_attr "mode" "V2DF")])
5046 (define_insn "<mask_codefor>avx512f_cvtpd2dq512<mask_name><round_name>"
5047   [(set (match_operand:V8SI 0 "register_operand" "=v")
5048         (unspec:V8SI
5049           [(match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")]
5050           UNSPEC_FIX_NOTRUNC))]
5051   "TARGET_AVX512F"
5052   "vcvtpd2dq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5053   [(set_attr "type" "ssecvt")
5054    (set_attr "prefix" "evex")
5055    (set_attr "mode" "OI")])
5057 (define_insn "avx_cvtpd2dq256<mask_name>"
5058   [(set (match_operand:V4SI 0 "register_operand" "=v")
5059         (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")]
5060                      UNSPEC_FIX_NOTRUNC))]
5061   "TARGET_AVX && <mask_avx512vl_condition>"
5062   "vcvtpd2dq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5063   [(set_attr "type" "ssecvt")
5064    (set_attr "prefix" "<mask_prefix>")
5065    (set_attr "mode" "OI")])
5067 (define_expand "avx_cvtpd2dq256_2"
5068   [(set (match_operand:V8SI 0 "register_operand")
5069         (vec_concat:V8SI
5070           (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand")]
5071                        UNSPEC_FIX_NOTRUNC)
5072           (match_dup 2)))]
5073   "TARGET_AVX"
5074   "operands[2] = CONST0_RTX (V4SImode);")
5076 (define_insn "*avx_cvtpd2dq256_2"
5077   [(set (match_operand:V8SI 0 "register_operand" "=x")
5078         (vec_concat:V8SI
5079           (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "xm")]
5080                        UNSPEC_FIX_NOTRUNC)
5081           (match_operand:V4SI 2 "const0_operand")))]
5082   "TARGET_AVX"
5083   "vcvtpd2dq{y}\t{%1, %x0|%x0, %1}"
5084   [(set_attr "type" "ssecvt")
5085    (set_attr "prefix" "vex")
5086    (set_attr "btver2_decode" "vector")
5087    (set_attr "mode" "OI")])
5089 (define_insn "sse2_cvtpd2dq<mask_name>"
5090   [(set (match_operand:V4SI 0 "register_operand" "=v")
5091         (vec_concat:V4SI
5092           (unspec:V2SI [(match_operand:V2DF 1 "vector_operand" "vBm")]
5093                        UNSPEC_FIX_NOTRUNC)
5094           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5095   "TARGET_SSE2 && <mask_avx512vl_condition>"
5097   if (TARGET_AVX)
5098     return "vcvtpd2dq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
5099   else
5100     return "cvtpd2dq\t{%1, %0|%0, %1}";
5102   [(set_attr "type" "ssecvt")
5103    (set_attr "prefix_rep" "1")
5104    (set_attr "prefix_data16" "0")
5105    (set_attr "prefix" "maybe_vex")
5106    (set_attr "mode" "TI")
5107    (set_attr "amdfam10_decode" "double")
5108    (set_attr "athlon_decode" "vector")
5109    (set_attr "bdver1_decode" "double")])
5111 ;; For ufix_notrunc* insn patterns
5112 (define_mode_attr pd2udqsuff
5113   [(V8DF "") (V4DF "{y}")])
5115 (define_insn "ufix_notrunc<mode><si2dfmodelower>2<mask_name><round_name>"
5116   [(set (match_operand:<si2dfmode> 0 "register_operand" "=v")
5117         (unspec:<si2dfmode>
5118           [(match_operand:VF2_512_256VL 1 "nonimmediate_operand" "<round_constraint>")]
5119           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
5120   "TARGET_AVX512F"
5121   "vcvtpd2udq<pd2udqsuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5122   [(set_attr "type" "ssecvt")
5123    (set_attr "prefix" "evex")
5124    (set_attr "mode" "<sseinsnmode>")])
5126 (define_insn "ufix_notruncv2dfv2si2<mask_name>"
5127   [(set (match_operand:V4SI 0 "register_operand" "=v")
5128         (vec_concat:V4SI
5129           (unspec:V2SI
5130             [(match_operand:V2DF 1 "nonimmediate_operand" "vm")]
5131             UNSPEC_UNSIGNED_FIX_NOTRUNC)
5132           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5133   "TARGET_AVX512VL"
5134   "vcvtpd2udq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5135   [(set_attr "type" "ssecvt")
5136    (set_attr "prefix" "evex")
5137    (set_attr "mode" "TI")])
5139 (define_insn "<fixsuffix>fix_truncv8dfv8si2<mask_name><round_saeonly_name>"
5140   [(set (match_operand:V8SI 0 "register_operand" "=v")
5141         (any_fix:V8SI
5142           (match_operand:V8DF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5143   "TARGET_AVX512F"
5144   "vcvttpd2<fixsuffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5145   [(set_attr "type" "ssecvt")
5146    (set_attr "prefix" "evex")
5147    (set_attr "mode" "OI")])
5149 (define_insn "ufix_truncv2dfv2si2<mask_name>"
5150   [(set (match_operand:V4SI 0 "register_operand" "=v")
5151         (vec_concat:V4SI
5152           (unsigned_fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "vm"))
5153           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5154   "TARGET_AVX512VL"
5155   "vcvttpd2udq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5156   [(set_attr "type" "ssecvt")
5157    (set_attr "prefix" "evex")
5158    (set_attr "mode" "TI")])
5160 (define_insn "fix_truncv4dfv4si2<mask_name>"
5161   [(set (match_operand:V4SI 0 "register_operand" "=v")
5162         (fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
5163   "TARGET_AVX || (TARGET_AVX512VL && TARGET_AVX512F)"
5164   "vcvttpd2dq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5165   [(set_attr "type" "ssecvt")
5166    (set_attr "prefix" "maybe_evex")
5167    (set_attr "mode" "OI")])
5169 (define_insn "ufix_truncv4dfv4si2<mask_name>"
5170   [(set (match_operand:V4SI 0 "register_operand" "=v")
5171         (unsigned_fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
5172   "TARGET_AVX512VL && TARGET_AVX512F"
5173   "vcvttpd2udq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5174   [(set_attr "type" "ssecvt")
5175    (set_attr "prefix" "maybe_evex")
5176    (set_attr "mode" "OI")])
5178 (define_insn "<fixsuffix>fix_trunc<mode><sseintvecmodelower>2<mask_name><round_saeonly_name>"
5179   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5180         (any_fix:<sseintvecmode>
5181           (match_operand:VF2_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5182   "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
5183   "vcvttpd2<fixsuffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5184   [(set_attr "type" "ssecvt")
5185    (set_attr "prefix" "evex")
5186    (set_attr "mode" "<sseintvecmode2>")])
5188 (define_insn "fix_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>"
5189   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5190         (unspec:<sseintvecmode>
5191           [(match_operand:VF2_AVX512VL 1 "<round_nimm_predicate>" "<round_constraint>")]
5192           UNSPEC_FIX_NOTRUNC))]
5193   "TARGET_AVX512DQ && <round_mode512bit_condition>"
5194   "vcvtpd2qq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5195   [(set_attr "type" "ssecvt")
5196    (set_attr "prefix" "evex")
5197    (set_attr "mode" "<sseintvecmode2>")])
5199 (define_insn "ufix_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>"
5200   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5201         (unspec:<sseintvecmode>
5202           [(match_operand:VF2_AVX512VL 1 "nonimmediate_operand" "<round_constraint>")]
5203           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
5204   "TARGET_AVX512DQ && <round_mode512bit_condition>"
5205   "vcvtpd2uqq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5206   [(set_attr "type" "ssecvt")
5207    (set_attr "prefix" "evex")
5208    (set_attr "mode" "<sseintvecmode2>")])
5210 (define_insn "<fixsuffix>fix_trunc<mode><sselongvecmodelower>2<mask_name><round_saeonly_name>"
5211   [(set (match_operand:<sselongvecmode> 0 "register_operand" "=v")
5212         (any_fix:<sselongvecmode>
5213           (match_operand:VF1_128_256VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5214   "TARGET_AVX512DQ && <round_saeonly_modev8sf_condition>"
5215   "vcvttps2<fixsuffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5216   [(set_attr "type" "ssecvt")
5217    (set_attr "prefix" "evex")
5218    (set_attr "mode" "<sseintvecmode3>")])
5220 (define_insn "<fixsuffix>fix_truncv2sfv2di2<mask_name>"
5221   [(set (match_operand:V2DI 0 "register_operand" "=v")
5222         (any_fix:V2DI
5223           (vec_select:V2SF
5224             (match_operand:V4SF 1 "nonimmediate_operand" "vm")
5225             (parallel [(const_int 0) (const_int 1)]))))]
5226   "TARGET_AVX512DQ && TARGET_AVX512VL"
5227   "vcvttps2<fixsuffix>qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5228   [(set_attr "type" "ssecvt")
5229    (set_attr "prefix" "evex")
5230    (set_attr "mode" "TI")])
5232 (define_insn "ufix_trunc<mode><sseintvecmodelower>2<mask_name>"
5233   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
5234         (unsigned_fix:<sseintvecmode>
5235           (match_operand:VF1_128_256VL 1 "nonimmediate_operand" "vm")))]
5236   "TARGET_AVX512VL"
5237   "vcvttps2udq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5238   [(set_attr "type" "ssecvt")
5239    (set_attr "prefix" "evex")
5240    (set_attr "mode" "<sseintvecmode2>")])
5242 (define_expand "avx_cvttpd2dq256_2"
5243   [(set (match_operand:V8SI 0 "register_operand")
5244         (vec_concat:V8SI
5245           (fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand"))
5246           (match_dup 2)))]
5247   "TARGET_AVX"
5248   "operands[2] = CONST0_RTX (V4SImode);")
5250 (define_insn "sse2_cvttpd2dq<mask_name>"
5251   [(set (match_operand:V4SI 0 "register_operand" "=v")
5252         (vec_concat:V4SI
5253           (fix:V2SI (match_operand:V2DF 1 "vector_operand" "vBm"))
5254           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5255   "TARGET_SSE2 && <mask_avx512vl_condition>"
5257   if (TARGET_AVX)
5258     return "vcvttpd2dq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
5259   else
5260     return "cvttpd2dq\t{%1, %0|%0, %1}";
5262   [(set_attr "type" "ssecvt")
5263    (set_attr "amdfam10_decode" "double")
5264    (set_attr "athlon_decode" "vector")
5265    (set_attr "bdver1_decode" "double")
5266    (set_attr "prefix" "maybe_vex")
5267    (set_attr "mode" "TI")])
5269 (define_insn "sse2_cvtsd2ss<round_name>"
5270   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
5271         (vec_merge:V4SF
5272           (vec_duplicate:V4SF
5273             (float_truncate:V2SF
5274               (match_operand:V2DF 2 "nonimmediate_operand" "x,m,<round_constraint>")))
5275           (match_operand:V4SF 1 "register_operand" "0,0,v")
5276           (const_int 1)))]
5277   "TARGET_SSE2"
5278   "@
5279    cvtsd2ss\t{%2, %0|%0, %2}
5280    cvtsd2ss\t{%2, %0|%0, %q2}
5281    vcvtsd2ss\t{<round_op3>%2, %1, %0|%0, %1, %q2<round_op3>}"
5282   [(set_attr "isa" "noavx,noavx,avx")
5283    (set_attr "type" "ssecvt")
5284    (set_attr "athlon_decode" "vector,double,*")
5285    (set_attr "amdfam10_decode" "vector,double,*")
5286    (set_attr "bdver1_decode" "direct,direct,*")
5287    (set_attr "btver2_decode" "double,double,double")
5288    (set_attr "prefix" "orig,orig,<round_prefix>")
5289    (set_attr "mode" "SF")])
5291 (define_insn "sse2_cvtss2sd<round_saeonly_name>"
5292   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
5293         (vec_merge:V2DF
5294           (float_extend:V2DF
5295             (vec_select:V2SF
5296               (match_operand:V4SF 2 "<round_saeonly_nimm_scalar_predicate>" "x,m,<round_saeonly_constraint>")
5297               (parallel [(const_int 0) (const_int 1)])))
5298           (match_operand:V2DF 1 "register_operand" "0,0,v")
5299           (const_int 1)))]
5300   "TARGET_SSE2"
5301   "@
5302    cvtss2sd\t{%2, %0|%0, %2}
5303    cvtss2sd\t{%2, %0|%0, %k2}
5304    vcvtss2sd\t{<round_saeonly_op3>%2, %1, %0|%0, %1, %k2<round_saeonly_op3>}"
5305   [(set_attr "isa" "noavx,noavx,avx")
5306    (set_attr "type" "ssecvt")
5307    (set_attr "amdfam10_decode" "vector,double,*")
5308    (set_attr "athlon_decode" "direct,direct,*")
5309    (set_attr "bdver1_decode" "direct,direct,*")
5310    (set_attr "btver2_decode" "double,double,double")
5311    (set_attr "prefix" "orig,orig,<round_saeonly_prefix>")
5312    (set_attr "mode" "DF")])
5314 (define_insn "<mask_codefor>avx512f_cvtpd2ps512<mask_name><round_name>"
5315   [(set (match_operand:V8SF 0 "register_operand" "=v")
5316         (float_truncate:V8SF
5317           (match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")))]
5318   "TARGET_AVX512F"
5319   "vcvtpd2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5320   [(set_attr "type" "ssecvt")
5321    (set_attr "prefix" "evex")
5322    (set_attr "mode" "V8SF")])
5324 (define_insn "avx_cvtpd2ps256<mask_name>"
5325   [(set (match_operand:V4SF 0 "register_operand" "=v")
5326         (float_truncate:V4SF
5327           (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
5328   "TARGET_AVX && <mask_avx512vl_condition>"
5329   "vcvtpd2ps{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5330   [(set_attr "type" "ssecvt")
5331    (set_attr "prefix" "maybe_evex")
5332    (set_attr "btver2_decode" "vector")
5333    (set_attr "mode" "V4SF")])
5335 (define_expand "sse2_cvtpd2ps"
5336   [(set (match_operand:V4SF 0 "register_operand")
5337         (vec_concat:V4SF
5338           (float_truncate:V2SF
5339             (match_operand:V2DF 1 "vector_operand"))
5340           (match_dup 2)))]
5341   "TARGET_SSE2"
5342   "operands[2] = CONST0_RTX (V2SFmode);")
5344 (define_expand "sse2_cvtpd2ps_mask"
5345   [(set (match_operand:V4SF 0 "register_operand")
5346         (vec_merge:V4SF
5347           (vec_concat:V4SF
5348             (float_truncate:V2SF
5349               (match_operand:V2DF 1 "vector_operand"))
5350             (match_dup 4))
5351           (match_operand:V4SF 2 "register_operand")
5352           (match_operand:QI 3 "register_operand")))]
5353   "TARGET_SSE2"
5354   "operands[4] = CONST0_RTX (V2SFmode);")
5356 (define_insn "*sse2_cvtpd2ps<mask_name>"
5357   [(set (match_operand:V4SF 0 "register_operand" "=v")
5358         (vec_concat:V4SF
5359           (float_truncate:V2SF
5360             (match_operand:V2DF 1 "vector_operand" "vBm"))
5361           (match_operand:V2SF 2 "const0_operand")))]
5362   "TARGET_SSE2 && <mask_avx512vl_condition>"
5364   if (TARGET_AVX)
5365     return "vcvtpd2ps{x}\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}";
5366   else
5367     return "cvtpd2ps\t{%1, %0|%0, %1}";
5369   [(set_attr "type" "ssecvt")
5370    (set_attr "amdfam10_decode" "double")
5371    (set_attr "athlon_decode" "vector")
5372    (set_attr "bdver1_decode" "double")
5373    (set_attr "prefix_data16" "1")
5374    (set_attr "prefix" "maybe_vex")
5375    (set_attr "mode" "V4SF")])
5377 ;; For <sse2_avx_avx512f>_cvtps2pd<avxsizesuffix> insn pattern
5378 (define_mode_attr sf2dfmode
5379   [(V8DF "V8SF") (V4DF "V4SF")])
5381 (define_insn "<sse2_avx_avx512f>_cvtps2pd<avxsizesuffix><mask_name><round_saeonly_name>"
5382   [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
5383         (float_extend:VF2_512_256
5384           (match_operand:<sf2dfmode> 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5385   "TARGET_AVX && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
5386   "vcvtps2pd\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5387   [(set_attr "type" "ssecvt")
5388    (set_attr "prefix" "maybe_vex")
5389    (set_attr "mode" "<MODE>")])
5391 (define_insn "*avx_cvtps2pd256_2"
5392   [(set (match_operand:V4DF 0 "register_operand" "=x")
5393         (float_extend:V4DF
5394           (vec_select:V4SF
5395             (match_operand:V8SF 1 "nonimmediate_operand" "xm")
5396             (parallel [(const_int 0) (const_int 1)
5397                        (const_int 2) (const_int 3)]))))]
5398   "TARGET_AVX"
5399   "vcvtps2pd\t{%x1, %0|%0, %x1}"
5400   [(set_attr "type" "ssecvt")
5401    (set_attr "prefix" "vex")
5402    (set_attr "mode" "V4DF")])
5404 (define_insn "vec_unpacks_lo_v16sf"
5405   [(set (match_operand:V8DF 0 "register_operand" "=v")
5406         (float_extend:V8DF
5407           (vec_select:V8SF
5408             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
5409             (parallel [(const_int 0) (const_int 1)
5410                        (const_int 2) (const_int 3)
5411                        (const_int 4) (const_int 5)
5412                        (const_int 6) (const_int 7)]))))]
5413   "TARGET_AVX512F"
5414   "vcvtps2pd\t{%t1, %0|%0, %t1}"
5415   [(set_attr "type" "ssecvt")
5416    (set_attr "prefix" "evex")
5417    (set_attr "mode" "V8DF")])
5419 (define_insn "<avx512>_cvt<ssemodesuffix>2mask<mode>"
5420   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
5421         (unspec:<avx512fmaskmode>
5422          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")]
5423          UNSPEC_CVTINT2MASK))]
5424   "TARGET_AVX512BW"
5425   "vpmov<ssemodesuffix>2m\t{%1, %0|%0, %1}"
5426   [(set_attr "prefix" "evex")
5427    (set_attr "mode" "<sseinsnmode>")])
5429 (define_insn "<avx512>_cvt<ssemodesuffix>2mask<mode>"
5430   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
5431         (unspec:<avx512fmaskmode>
5432          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")]
5433          UNSPEC_CVTINT2MASK))]
5434   "TARGET_AVX512DQ"
5435   "vpmov<ssemodesuffix>2m\t{%1, %0|%0, %1}"
5436   [(set_attr "prefix" "evex")
5437    (set_attr "mode" "<sseinsnmode>")])
5439 (define_expand "<avx512>_cvtmask2<ssemodesuffix><mode>"
5440   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
5441         (vec_merge:VI12_AVX512VL
5442           (match_dup 2)
5443           (match_dup 3)
5444           (match_operand:<avx512fmaskmode> 1 "register_operand")))]
5445   "TARGET_AVX512BW"
5446   {
5447     operands[2] = CONSTM1_RTX (<MODE>mode);
5448     operands[3] = CONST0_RTX (<MODE>mode);
5449   })
5451 (define_insn "*<avx512>_cvtmask2<ssemodesuffix><mode>"
5452   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
5453         (vec_merge:VI12_AVX512VL
5454           (match_operand:VI12_AVX512VL 2 "constm1_operand")
5455           (match_operand:VI12_AVX512VL 3 "const0_operand")
5456           (match_operand:<avx512fmaskmode> 1 "register_operand" "Yk")))]
5457   "TARGET_AVX512BW"
5458   "vpmovm2<ssemodesuffix>\t{%1, %0|%0, %1}"
5459   [(set_attr "prefix" "evex")
5460    (set_attr "mode" "<sseinsnmode>")])
5462 (define_expand "<avx512>_cvtmask2<ssemodesuffix><mode>"
5463   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
5464         (vec_merge:VI48_AVX512VL
5465           (match_dup 2)
5466           (match_dup 3)
5467           (match_operand:<avx512fmaskmode> 1 "register_operand")))]
5468   "TARGET_AVX512DQ"
5469   "{
5470     operands[2] = CONSTM1_RTX (<MODE>mode);
5471     operands[3] = CONST0_RTX (<MODE>mode);
5472   }")
5474 (define_insn "*<avx512>_cvtmask2<ssemodesuffix><mode>"
5475   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
5476         (vec_merge:VI48_AVX512VL
5477           (match_operand:VI48_AVX512VL 2 "constm1_operand")
5478           (match_operand:VI48_AVX512VL 3 "const0_operand")
5479           (match_operand:<avx512fmaskmode> 1 "register_operand" "Yk")))]
5480   "TARGET_AVX512DQ"
5481   "vpmovm2<ssemodesuffix>\t{%1, %0|%0, %1}"
5482   [(set_attr "prefix" "evex")
5483    (set_attr "mode" "<sseinsnmode>")])
5485 (define_insn "sse2_cvtps2pd<mask_name>"
5486   [(set (match_operand:V2DF 0 "register_operand" "=v")
5487         (float_extend:V2DF
5488           (vec_select:V2SF
5489             (match_operand:V4SF 1 "vector_operand" "vm")
5490             (parallel [(const_int 0) (const_int 1)]))))]
5491   "TARGET_SSE2 && <mask_avx512vl_condition>"
5492   "%vcvtps2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5493   [(set_attr "type" "ssecvt")
5494    (set_attr "amdfam10_decode" "direct")
5495    (set_attr "athlon_decode" "double")
5496    (set_attr "bdver1_decode" "double")
5497    (set_attr "prefix_data16" "0")
5498    (set_attr "prefix" "maybe_vex")
5499    (set_attr "mode" "V2DF")])
5501 (define_expand "vec_unpacks_hi_v4sf"
5502   [(set (match_dup 2)
5503    (vec_select:V4SF
5504      (vec_concat:V8SF
5505        (match_dup 2)
5506        (match_operand:V4SF 1 "vector_operand"))
5507      (parallel [(const_int 6) (const_int 7)
5508                 (const_int 2) (const_int 3)])))
5509   (set (match_operand:V2DF 0 "register_operand")
5510    (float_extend:V2DF
5511      (vec_select:V2SF
5512        (match_dup 2)
5513        (parallel [(const_int 0) (const_int 1)]))))]
5514   "TARGET_SSE2"
5515   "operands[2] = gen_reg_rtx (V4SFmode);")
5517 (define_expand "vec_unpacks_hi_v8sf"
5518   [(set (match_dup 2)
5519         (vec_select:V4SF
5520           (match_operand:V8SF 1 "register_operand")
5521           (parallel [(const_int 4) (const_int 5)
5522                      (const_int 6) (const_int 7)])))
5523    (set (match_operand:V4DF 0 "register_operand")
5524         (float_extend:V4DF
5525           (match_dup 2)))]
5526   "TARGET_AVX"
5527   "operands[2] = gen_reg_rtx (V4SFmode);")
5529 (define_expand "vec_unpacks_hi_v16sf"
5530   [(set (match_dup 2)
5531         (vec_select:V8SF
5532           (match_operand:V16SF 1 "register_operand")
5533           (parallel [(const_int 8) (const_int 9)
5534                      (const_int 10) (const_int 11)
5535                      (const_int 12) (const_int 13)
5536                      (const_int 14) (const_int 15)])))
5537    (set (match_operand:V8DF 0 "register_operand")
5538         (float_extend:V8DF
5539           (match_dup 2)))]
5540 "TARGET_AVX512F"
5541 "operands[2] = gen_reg_rtx (V8SFmode);")
5543 (define_expand "vec_unpacks_lo_v4sf"
5544   [(set (match_operand:V2DF 0 "register_operand")
5545         (float_extend:V2DF
5546           (vec_select:V2SF
5547             (match_operand:V4SF 1 "vector_operand")
5548             (parallel [(const_int 0) (const_int 1)]))))]
5549   "TARGET_SSE2")
5551 (define_expand "vec_unpacks_lo_v8sf"
5552   [(set (match_operand:V4DF 0 "register_operand")
5553         (float_extend:V4DF
5554           (vec_select:V4SF
5555             (match_operand:V8SF 1 "nonimmediate_operand")
5556             (parallel [(const_int 0) (const_int 1)
5557                        (const_int 2) (const_int 3)]))))]
5558   "TARGET_AVX")
5560 (define_mode_attr sseunpackfltmode
5561   [(V8HI "V4SF") (V4SI "V2DF") (V16HI "V8SF")
5562   (V8SI "V4DF") (V32HI "V16SF") (V16SI "V8DF")])
5564 (define_expand "vec_unpacks_float_hi_<mode>"
5565   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5566    (match_operand:VI2_AVX512F 1 "register_operand")]
5567   "TARGET_SSE2"
5569   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5571   emit_insn (gen_vec_unpacks_hi_<mode> (tmp, operands[1]));
5572   emit_insn (gen_rtx_SET (operands[0],
5573                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5574   DONE;
5577 (define_expand "vec_unpacks_float_lo_<mode>"
5578   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5579    (match_operand:VI2_AVX512F 1 "register_operand")]
5580   "TARGET_SSE2"
5582   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5584   emit_insn (gen_vec_unpacks_lo_<mode> (tmp, operands[1]));
5585   emit_insn (gen_rtx_SET (operands[0],
5586                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5587   DONE;
5590 (define_expand "vec_unpacku_float_hi_<mode>"
5591   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5592    (match_operand:VI2_AVX512F 1 "register_operand")]
5593   "TARGET_SSE2"
5595   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5597   emit_insn (gen_vec_unpacku_hi_<mode> (tmp, operands[1]));
5598   emit_insn (gen_rtx_SET (operands[0],
5599                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5600   DONE;
5603 (define_expand "vec_unpacku_float_lo_<mode>"
5604   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5605    (match_operand:VI2_AVX512F 1 "register_operand")]
5606   "TARGET_SSE2"
5608   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5610   emit_insn (gen_vec_unpacku_lo_<mode> (tmp, operands[1]));
5611   emit_insn (gen_rtx_SET (operands[0],
5612                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5613   DONE;
5616 (define_expand "vec_unpacks_float_hi_v4si"
5617   [(set (match_dup 2)
5618         (vec_select:V4SI
5619           (match_operand:V4SI 1 "vector_operand")
5620           (parallel [(const_int 2) (const_int 3)
5621                      (const_int 2) (const_int 3)])))
5622    (set (match_operand:V2DF 0 "register_operand")
5623         (float:V2DF
5624           (vec_select:V2SI
5625           (match_dup 2)
5626             (parallel [(const_int 0) (const_int 1)]))))]
5627   "TARGET_SSE2"
5628   "operands[2] = gen_reg_rtx (V4SImode);")
5630 (define_expand "vec_unpacks_float_lo_v4si"
5631   [(set (match_operand:V2DF 0 "register_operand")
5632         (float:V2DF
5633           (vec_select:V2SI
5634             (match_operand:V4SI 1 "vector_operand")
5635             (parallel [(const_int 0) (const_int 1)]))))]
5636   "TARGET_SSE2")
5638 (define_expand "vec_unpacks_float_hi_v8si"
5639   [(set (match_dup 2)
5640         (vec_select:V4SI
5641           (match_operand:V8SI 1 "vector_operand")
5642           (parallel [(const_int 4) (const_int 5)
5643                      (const_int 6) (const_int 7)])))
5644    (set (match_operand:V4DF 0 "register_operand")
5645         (float:V4DF
5646           (match_dup 2)))]
5647   "TARGET_AVX"
5648   "operands[2] = gen_reg_rtx (V4SImode);")
5650 (define_expand "vec_unpacks_float_lo_v8si"
5651   [(set (match_operand:V4DF 0 "register_operand")
5652         (float:V4DF
5653           (vec_select:V4SI
5654             (match_operand:V8SI 1 "nonimmediate_operand")
5655             (parallel [(const_int 0) (const_int 1)
5656                        (const_int 2) (const_int 3)]))))]
5657   "TARGET_AVX")
5659 (define_expand "vec_unpacks_float_hi_v16si"
5660   [(set (match_dup 2)
5661         (vec_select:V8SI
5662           (match_operand:V16SI 1 "nonimmediate_operand")
5663           (parallel [(const_int 8) (const_int 9)
5664                      (const_int 10) (const_int 11)
5665                      (const_int 12) (const_int 13)
5666                      (const_int 14) (const_int 15)])))
5667    (set (match_operand:V8DF 0 "register_operand")
5668         (float:V8DF
5669           (match_dup 2)))]
5670   "TARGET_AVX512F"
5671   "operands[2] = gen_reg_rtx (V8SImode);")
5673 (define_expand "vec_unpacks_float_lo_v16si"
5674   [(set (match_operand:V8DF 0 "register_operand")
5675         (float:V8DF
5676           (vec_select:V8SI
5677             (match_operand:V16SI 1 "nonimmediate_operand")
5678             (parallel [(const_int 0) (const_int 1)
5679                        (const_int 2) (const_int 3)
5680                        (const_int 4) (const_int 5)
5681                        (const_int 6) (const_int 7)]))))]
5682   "TARGET_AVX512F")
5684 (define_expand "vec_unpacku_float_hi_v4si"
5685   [(set (match_dup 5)
5686         (vec_select:V4SI
5687           (match_operand:V4SI 1 "vector_operand")
5688           (parallel [(const_int 2) (const_int 3)
5689                      (const_int 2) (const_int 3)])))
5690    (set (match_dup 6)
5691         (float:V2DF
5692           (vec_select:V2SI
5693           (match_dup 5)
5694             (parallel [(const_int 0) (const_int 1)]))))
5695    (set (match_dup 7)
5696         (lt:V2DF (match_dup 6) (match_dup 3)))
5697    (set (match_dup 8)
5698         (and:V2DF (match_dup 7) (match_dup 4)))
5699    (set (match_operand:V2DF 0 "register_operand")
5700         (plus:V2DF (match_dup 6) (match_dup 8)))]
5701   "TARGET_SSE2"
5703   REAL_VALUE_TYPE TWO32r;
5704   rtx x;
5705   int i;
5707   real_ldexp (&TWO32r, &dconst1, 32);
5708   x = const_double_from_real_value (TWO32r, DFmode);
5710   operands[3] = force_reg (V2DFmode, CONST0_RTX (V2DFmode));
5711   operands[4] = force_reg (V2DFmode,
5712                            ix86_build_const_vector (V2DFmode, 1, x));
5714   operands[5] = gen_reg_rtx (V4SImode);
5716   for (i = 6; i < 9; i++)
5717     operands[i] = gen_reg_rtx (V2DFmode);
5720 (define_expand "vec_unpacku_float_lo_v4si"
5721   [(set (match_dup 5)
5722         (float:V2DF
5723           (vec_select:V2SI
5724             (match_operand:V4SI 1 "vector_operand")
5725             (parallel [(const_int 0) (const_int 1)]))))
5726    (set (match_dup 6)
5727         (lt:V2DF (match_dup 5) (match_dup 3)))
5728    (set (match_dup 7)
5729         (and:V2DF (match_dup 6) (match_dup 4)))
5730    (set (match_operand:V2DF 0 "register_operand")
5731         (plus:V2DF (match_dup 5) (match_dup 7)))]
5732   "TARGET_SSE2"
5734   REAL_VALUE_TYPE TWO32r;
5735   rtx x;
5736   int i;
5738   real_ldexp (&TWO32r, &dconst1, 32);
5739   x = const_double_from_real_value (TWO32r, DFmode);
5741   operands[3] = force_reg (V2DFmode, CONST0_RTX (V2DFmode));
5742   operands[4] = force_reg (V2DFmode,
5743                            ix86_build_const_vector (V2DFmode, 1, x));
5745   for (i = 5; i < 8; i++)
5746     operands[i] = gen_reg_rtx (V2DFmode);
5749 (define_expand "vec_unpacku_float_hi_v8si"
5750   [(match_operand:V4DF 0 "register_operand")
5751    (match_operand:V8SI 1 "register_operand")]
5752   "TARGET_AVX"
5754   REAL_VALUE_TYPE TWO32r;
5755   rtx x, tmp[6];
5756   int i;
5758   real_ldexp (&TWO32r, &dconst1, 32);
5759   x = const_double_from_real_value (TWO32r, DFmode);
5761   tmp[0] = force_reg (V4DFmode, CONST0_RTX (V4DFmode));
5762   tmp[1] = force_reg (V4DFmode, ix86_build_const_vector (V4DFmode, 1, x));
5763   tmp[5] = gen_reg_rtx (V4SImode);
5765   for (i = 2; i < 5; i++)
5766     tmp[i] = gen_reg_rtx (V4DFmode);
5767   emit_insn (gen_vec_extract_hi_v8si (tmp[5], operands[1]));
5768   emit_insn (gen_floatv4siv4df2 (tmp[2], tmp[5]));
5769   emit_insn (gen_rtx_SET (tmp[3], gen_rtx_LT (V4DFmode, tmp[2], tmp[0])));
5770   emit_insn (gen_andv4df3 (tmp[4], tmp[3], tmp[1]));
5771   emit_insn (gen_addv4df3 (operands[0], tmp[2], tmp[4]));
5772   DONE;
5775 (define_expand "vec_unpacku_float_hi_v16si"
5776   [(match_operand:V8DF 0 "register_operand")
5777    (match_operand:V16SI 1 "register_operand")]
5778   "TARGET_AVX512F"
5780   REAL_VALUE_TYPE TWO32r;
5781   rtx k, x, tmp[4];
5783   real_ldexp (&TWO32r, &dconst1, 32);
5784   x = const_double_from_real_value (TWO32r, DFmode);
5786   tmp[0] = force_reg (V8DFmode, CONST0_RTX (V8DFmode));
5787   tmp[1] = force_reg (V8DFmode, ix86_build_const_vector (V8DFmode, 1, x));
5788   tmp[2] = gen_reg_rtx (V8DFmode);
5789   tmp[3] = gen_reg_rtx (V8SImode);
5790   k = gen_reg_rtx (QImode);
5792   emit_insn (gen_vec_extract_hi_v16si (tmp[3], operands[1]));
5793   emit_insn (gen_floatv8siv8df2 (tmp[2], tmp[3]));
5794   emit_insn (gen_rtx_SET (k, gen_rtx_LT (QImode, tmp[2], tmp[0])));
5795   emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k));
5796   emit_move_insn (operands[0], tmp[2]);
5797   DONE;
5800 (define_expand "vec_unpacku_float_lo_v8si"
5801   [(match_operand:V4DF 0 "register_operand")
5802    (match_operand:V8SI 1 "nonimmediate_operand")]
5803   "TARGET_AVX"
5805   REAL_VALUE_TYPE TWO32r;
5806   rtx x, tmp[5];
5807   int i;
5809   real_ldexp (&TWO32r, &dconst1, 32);
5810   x = const_double_from_real_value (TWO32r, DFmode);
5812   tmp[0] = force_reg (V4DFmode, CONST0_RTX (V4DFmode));
5813   tmp[1] = force_reg (V4DFmode, ix86_build_const_vector (V4DFmode, 1, x));
5815   for (i = 2; i < 5; i++)
5816     tmp[i] = gen_reg_rtx (V4DFmode);
5817   emit_insn (gen_avx_cvtdq2pd256_2 (tmp[2], operands[1]));
5818   emit_insn (gen_rtx_SET (tmp[3], gen_rtx_LT (V4DFmode, tmp[2], tmp[0])));
5819   emit_insn (gen_andv4df3 (tmp[4], tmp[3], tmp[1]));
5820   emit_insn (gen_addv4df3 (operands[0], tmp[2], tmp[4]));
5821   DONE;
5824 (define_expand "vec_unpacku_float_lo_v16si"
5825   [(match_operand:V8DF 0 "register_operand")
5826    (match_operand:V16SI 1 "nonimmediate_operand")]
5827   "TARGET_AVX512F"
5829   REAL_VALUE_TYPE TWO32r;
5830   rtx k, x, tmp[3];
5832   real_ldexp (&TWO32r, &dconst1, 32);
5833   x = const_double_from_real_value (TWO32r, DFmode);
5835   tmp[0] = force_reg (V8DFmode, CONST0_RTX (V8DFmode));
5836   tmp[1] = force_reg (V8DFmode, ix86_build_const_vector (V8DFmode, 1, x));
5837   tmp[2] = gen_reg_rtx (V8DFmode);
5838   k = gen_reg_rtx (QImode);
5840   emit_insn (gen_avx512f_cvtdq2pd512_2 (tmp[2], operands[1]));
5841   emit_insn (gen_rtx_SET (k, gen_rtx_LT (QImode, tmp[2], tmp[0])));
5842   emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k));
5843   emit_move_insn (operands[0], tmp[2]);
5844   DONE;
5847 (define_expand "vec_pack_trunc_<mode>"
5848   [(set (match_dup 3)
5849         (float_truncate:<sf2dfmode>
5850           (match_operand:VF2_512_256 1 "nonimmediate_operand")))
5851    (set (match_dup 4)
5852         (float_truncate:<sf2dfmode>
5853           (match_operand:VF2_512_256 2 "nonimmediate_operand")))
5854    (set (match_operand:<ssePSmode> 0 "register_operand")
5855         (vec_concat:<ssePSmode>
5856           (match_dup 3)
5857           (match_dup 4)))]
5858   "TARGET_AVX"
5860   operands[3] = gen_reg_rtx (<sf2dfmode>mode);
5861   operands[4] = gen_reg_rtx (<sf2dfmode>mode);
5864 (define_expand "vec_pack_trunc_v2df"
5865   [(match_operand:V4SF 0 "register_operand")
5866    (match_operand:V2DF 1 "vector_operand")
5867    (match_operand:V2DF 2 "vector_operand")]
5868   "TARGET_SSE2"
5870   rtx tmp0, tmp1;
5872   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
5873     {
5874       tmp0 = gen_reg_rtx (V4DFmode);
5875       tmp1 = force_reg (V2DFmode, operands[1]);
5877       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
5878       emit_insn (gen_avx_cvtpd2ps256 (operands[0], tmp0));
5879     }
5880   else
5881     {
5882       tmp0 = gen_reg_rtx (V4SFmode);
5883       tmp1 = gen_reg_rtx (V4SFmode);
5885       emit_insn (gen_sse2_cvtpd2ps (tmp0, operands[1]));
5886       emit_insn (gen_sse2_cvtpd2ps (tmp1, operands[2]));
5887       emit_insn (gen_sse_movlhps (operands[0], tmp0, tmp1));
5888     }
5889   DONE;
5892 (define_expand "vec_pack_sfix_trunc_v8df"
5893   [(match_operand:V16SI 0 "register_operand")
5894    (match_operand:V8DF 1 "nonimmediate_operand")
5895    (match_operand:V8DF 2 "nonimmediate_operand")]
5896   "TARGET_AVX512F"
5898   rtx r1, r2;
5900   r1 = gen_reg_rtx (V8SImode);
5901   r2 = gen_reg_rtx (V8SImode);
5903   emit_insn (gen_fix_truncv8dfv8si2 (r1, operands[1]));
5904   emit_insn (gen_fix_truncv8dfv8si2 (r2, operands[2]));
5905   emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
5906   DONE;
5909 (define_expand "vec_pack_sfix_trunc_v4df"
5910   [(match_operand:V8SI 0 "register_operand")
5911    (match_operand:V4DF 1 "nonimmediate_operand")
5912    (match_operand:V4DF 2 "nonimmediate_operand")]
5913   "TARGET_AVX"
5915   rtx r1, r2;
5917   r1 = gen_reg_rtx (V4SImode);
5918   r2 = gen_reg_rtx (V4SImode);
5920   emit_insn (gen_fix_truncv4dfv4si2 (r1, operands[1]));
5921   emit_insn (gen_fix_truncv4dfv4si2 (r2, operands[2]));
5922   emit_insn (gen_avx_vec_concatv8si (operands[0], r1, r2));
5923   DONE;
5926 (define_expand "vec_pack_sfix_trunc_v2df"
5927   [(match_operand:V4SI 0 "register_operand")
5928    (match_operand:V2DF 1 "vector_operand")
5929    (match_operand:V2DF 2 "vector_operand")]
5930   "TARGET_SSE2"
5932   rtx tmp0, tmp1, tmp2;
5934   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
5935     {
5936       tmp0 = gen_reg_rtx (V4DFmode);
5937       tmp1 = force_reg (V2DFmode, operands[1]);
5939       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
5940       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp0));
5941     }
5942   else
5943     {
5944       tmp0 = gen_reg_rtx (V4SImode);
5945       tmp1 = gen_reg_rtx (V4SImode);
5946       tmp2 = gen_reg_rtx (V2DImode);
5948       emit_insn (gen_sse2_cvttpd2dq (tmp0, operands[1]));
5949       emit_insn (gen_sse2_cvttpd2dq (tmp1, operands[2]));
5950       emit_insn (gen_vec_interleave_lowv2di (tmp2,
5951                                              gen_lowpart (V2DImode, tmp0),
5952                                              gen_lowpart (V2DImode, tmp1)));
5953       emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp2));
5954     }
5955   DONE;
5958 (define_mode_attr ssepackfltmode
5959   [(V8DF "V16SI") (V4DF "V8SI") (V2DF "V4SI")])
5961 (define_expand "vec_pack_ufix_trunc_<mode>"
5962   [(match_operand:<ssepackfltmode> 0 "register_operand")
5963    (match_operand:VF2 1 "register_operand")
5964    (match_operand:VF2 2 "register_operand")]
5965   "TARGET_SSE2"
5967   if (<MODE>mode == V8DFmode)
5968     {
5969       rtx r1, r2;
5971       r1 = gen_reg_rtx (V8SImode);
5972       r2 = gen_reg_rtx (V8SImode);
5974       emit_insn (gen_ufix_truncv8dfv8si2 (r1, operands[1]));
5975       emit_insn (gen_ufix_truncv8dfv8si2 (r2, operands[2]));
5976       emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
5977     }
5978   else
5979     {
5980       rtx tmp[7];
5981       tmp[0] = ix86_expand_adjust_ufix_to_sfix_si (operands[1], &tmp[2]);
5982       tmp[1] = ix86_expand_adjust_ufix_to_sfix_si (operands[2], &tmp[3]);
5983       tmp[4] = gen_reg_rtx (<ssepackfltmode>mode);
5984       emit_insn (gen_vec_pack_sfix_trunc_<mode> (tmp[4], tmp[0], tmp[1]));
5985       if (<ssepackfltmode>mode == V4SImode || TARGET_AVX2)
5986         {
5987           tmp[5] = gen_reg_rtx (<ssepackfltmode>mode);
5988           ix86_expand_vec_extract_even_odd (tmp[5], tmp[2], tmp[3], 0);
5989         }
5990       else
5991         {
5992           tmp[5] = gen_reg_rtx (V8SFmode);
5993           ix86_expand_vec_extract_even_odd (tmp[5], gen_lowpart (V8SFmode, tmp[2]),
5994                                             gen_lowpart (V8SFmode, tmp[3]), 0);
5995           tmp[5] = gen_lowpart (V8SImode, tmp[5]);
5996         }
5997       tmp[6] = expand_simple_binop (<ssepackfltmode>mode, XOR, tmp[4], tmp[5],
5998                                     operands[0], 0, OPTAB_DIRECT);
5999       if (tmp[6] != operands[0])
6000         emit_move_insn (operands[0], tmp[6]);
6001     }
6003   DONE;
6006 (define_expand "vec_pack_sfix_v4df"
6007   [(match_operand:V8SI 0 "register_operand")
6008    (match_operand:V4DF 1 "nonimmediate_operand")
6009    (match_operand:V4DF 2 "nonimmediate_operand")]
6010   "TARGET_AVX"
6012   rtx r1, r2;
6014   r1 = gen_reg_rtx (V4SImode);
6015   r2 = gen_reg_rtx (V4SImode);
6017   emit_insn (gen_avx_cvtpd2dq256 (r1, operands[1]));
6018   emit_insn (gen_avx_cvtpd2dq256 (r2, operands[2]));
6019   emit_insn (gen_avx_vec_concatv8si (operands[0], r1, r2));
6020   DONE;
6023 (define_expand "vec_pack_sfix_v2df"
6024   [(match_operand:V4SI 0 "register_operand")
6025    (match_operand:V2DF 1 "vector_operand")
6026    (match_operand:V2DF 2 "vector_operand")]
6027   "TARGET_SSE2"
6029   rtx tmp0, tmp1, tmp2;
6031   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
6032     {
6033       tmp0 = gen_reg_rtx (V4DFmode);
6034       tmp1 = force_reg (V2DFmode, operands[1]);
6036       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
6037       emit_insn (gen_avx_cvtpd2dq256 (operands[0], tmp0));
6038     }
6039   else
6040     {
6041       tmp0 = gen_reg_rtx (V4SImode);
6042       tmp1 = gen_reg_rtx (V4SImode);
6043       tmp2 = gen_reg_rtx (V2DImode);
6045       emit_insn (gen_sse2_cvtpd2dq (tmp0, operands[1]));
6046       emit_insn (gen_sse2_cvtpd2dq (tmp1, operands[2]));
6047       emit_insn (gen_vec_interleave_lowv2di (tmp2,
6048                                              gen_lowpart (V2DImode, tmp0),
6049                                              gen_lowpart (V2DImode, tmp1)));
6050       emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp2));
6051     }
6052   DONE;
6055 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6057 ;; Parallel single-precision floating point element swizzling
6059 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6061 (define_expand "sse_movhlps_exp"
6062   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6063         (vec_select:V4SF
6064           (vec_concat:V8SF
6065             (match_operand:V4SF 1 "nonimmediate_operand")
6066             (match_operand:V4SF 2 "nonimmediate_operand"))
6067           (parallel [(const_int 6)
6068                      (const_int 7)
6069                      (const_int 2)
6070                      (const_int 3)])))]
6071   "TARGET_SSE"
6073   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6075   emit_insn (gen_sse_movhlps (dst, operands[1], operands[2]));
6077   /* Fix up the destination if needed.  */
6078   if (dst != operands[0])
6079     emit_move_insn (operands[0], dst);
6081   DONE;
6084 (define_insn "sse_movhlps"
6085   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,x,x,x,m")
6086         (vec_select:V4SF
6087           (vec_concat:V8SF
6088             (match_operand:V4SF 1 "nonimmediate_operand" " 0,x,0,x,0")
6089             (match_operand:V4SF 2 "nonimmediate_operand" " x,x,o,o,x"))
6090           (parallel [(const_int 6)
6091                      (const_int 7)
6092                      (const_int 2)
6093                      (const_int 3)])))]
6094   "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
6095   "@
6096    movhlps\t{%2, %0|%0, %2}
6097    vmovhlps\t{%2, %1, %0|%0, %1, %2}
6098    movlps\t{%H2, %0|%0, %H2}
6099    vmovlps\t{%H2, %1, %0|%0, %1, %H2}
6100    %vmovhps\t{%2, %0|%q0, %2}"
6101   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6102    (set_attr "type" "ssemov")
6103    (set_attr "ssememalign" "64")
6104    (set_attr "prefix" "orig,vex,orig,vex,maybe_vex")
6105    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
6107 (define_expand "sse_movlhps_exp"
6108   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6109         (vec_select:V4SF
6110           (vec_concat:V8SF
6111             (match_operand:V4SF 1 "nonimmediate_operand")
6112             (match_operand:V4SF 2 "nonimmediate_operand"))
6113           (parallel [(const_int 0)
6114                      (const_int 1)
6115                      (const_int 4)
6116                      (const_int 5)])))]
6117   "TARGET_SSE"
6119   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6121   emit_insn (gen_sse_movlhps (dst, operands[1], operands[2]));
6123   /* Fix up the destination if needed.  */
6124   if (dst != operands[0])
6125     emit_move_insn (operands[0], dst);
6127   DONE;
6130 (define_insn "sse_movlhps"
6131   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,x,x,x,o")
6132         (vec_select:V4SF
6133           (vec_concat:V8SF
6134             (match_operand:V4SF 1 "nonimmediate_operand" " 0,x,0,x,0")
6135             (match_operand:V4SF 2 "nonimmediate_operand" " x,x,m,m,x"))
6136           (parallel [(const_int 0)
6137                      (const_int 1)
6138                      (const_int 4)
6139                      (const_int 5)])))]
6140   "TARGET_SSE && ix86_binary_operator_ok (UNKNOWN, V4SFmode, operands)"
6141   "@
6142    movlhps\t{%2, %0|%0, %2}
6143    vmovlhps\t{%2, %1, %0|%0, %1, %2}
6144    movhps\t{%2, %0|%0, %q2}
6145    vmovhps\t{%2, %1, %0|%0, %1, %q2}
6146    %vmovlps\t{%2, %H0|%H0, %2}"
6147   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6148    (set_attr "type" "ssemov")
6149    (set_attr "ssememalign" "64")
6150    (set_attr "prefix" "orig,vex,orig,vex,maybe_vex")
6151    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
6153 (define_insn "<mask_codefor>avx512f_unpckhps512<mask_name>"
6154   [(set (match_operand:V16SF 0 "register_operand" "=v")
6155         (vec_select:V16SF
6156           (vec_concat:V32SF
6157             (match_operand:V16SF 1 "register_operand" "v")
6158             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
6159           (parallel [(const_int 2) (const_int 18)
6160                      (const_int 3) (const_int 19)
6161                      (const_int 6) (const_int 22)
6162                      (const_int 7) (const_int 23)
6163                      (const_int 10) (const_int 26)
6164                      (const_int 11) (const_int 27)
6165                      (const_int 14) (const_int 30)
6166                      (const_int 15) (const_int 31)])))]
6167   "TARGET_AVX512F"
6168   "vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6169   [(set_attr "type" "sselog")
6170    (set_attr "prefix" "evex")
6171    (set_attr "mode" "V16SF")])
6173 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
6174 (define_insn "avx_unpckhps256<mask_name>"
6175   [(set (match_operand:V8SF 0 "register_operand" "=v")
6176         (vec_select:V8SF
6177           (vec_concat:V16SF
6178             (match_operand:V8SF 1 "register_operand" "v")
6179             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6180           (parallel [(const_int 2) (const_int 10)
6181                      (const_int 3) (const_int 11)
6182                      (const_int 6) (const_int 14)
6183                      (const_int 7) (const_int 15)])))]
6184   "TARGET_AVX && <mask_avx512vl_condition>"
6185   "vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6186   [(set_attr "type" "sselog")
6187    (set_attr "prefix" "vex")
6188    (set_attr "mode" "V8SF")])
6190 (define_expand "vec_interleave_highv8sf"
6191   [(set (match_dup 3)
6192         (vec_select:V8SF
6193           (vec_concat:V16SF
6194             (match_operand:V8SF 1 "register_operand" "x")
6195             (match_operand:V8SF 2 "nonimmediate_operand" "xm"))
6196           (parallel [(const_int 0) (const_int 8)
6197                      (const_int 1) (const_int 9)
6198                      (const_int 4) (const_int 12)
6199                      (const_int 5) (const_int 13)])))
6200    (set (match_dup 4)
6201         (vec_select:V8SF
6202           (vec_concat:V16SF
6203             (match_dup 1)
6204             (match_dup 2))
6205           (parallel [(const_int 2) (const_int 10)
6206                      (const_int 3) (const_int 11)
6207                      (const_int 6) (const_int 14)
6208                      (const_int 7) (const_int 15)])))
6209    (set (match_operand:V8SF 0 "register_operand")
6210         (vec_select:V8SF
6211           (vec_concat:V16SF
6212             (match_dup 3)
6213             (match_dup 4))
6214           (parallel [(const_int 4) (const_int 5)
6215                      (const_int 6) (const_int 7)
6216                      (const_int 12) (const_int 13)
6217                      (const_int 14) (const_int 15)])))]
6218  "TARGET_AVX"
6220   operands[3] = gen_reg_rtx (V8SFmode);
6221   operands[4] = gen_reg_rtx (V8SFmode);
6224 (define_insn "vec_interleave_highv4sf<mask_name>"
6225   [(set (match_operand:V4SF 0 "register_operand" "=x,v")
6226         (vec_select:V4SF
6227           (vec_concat:V8SF
6228             (match_operand:V4SF 1 "register_operand" "0,v")
6229             (match_operand:V4SF 2 "vector_operand" "xBm,vm"))
6230           (parallel [(const_int 2) (const_int 6)
6231                      (const_int 3) (const_int 7)])))]
6232   "TARGET_SSE && <mask_avx512vl_condition>"
6233   "@
6234    unpckhps\t{%2, %0|%0, %2}
6235    vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6236   [(set_attr "isa" "noavx,avx")
6237    (set_attr "type" "sselog")
6238    (set_attr "prefix" "orig,vex")
6239    (set_attr "mode" "V4SF")])
6241 (define_insn "<mask_codefor>avx512f_unpcklps512<mask_name>"
6242   [(set (match_operand:V16SF 0 "register_operand" "=v")
6243         (vec_select:V16SF
6244           (vec_concat:V32SF
6245             (match_operand:V16SF 1 "register_operand" "v")
6246             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
6247           (parallel [(const_int 0) (const_int 16)
6248                      (const_int 1) (const_int 17)
6249                      (const_int 4) (const_int 20)
6250                      (const_int 5) (const_int 21)
6251                      (const_int 8) (const_int 24)
6252                      (const_int 9) (const_int 25)
6253                      (const_int 12) (const_int 28)
6254                      (const_int 13) (const_int 29)])))]
6255   "TARGET_AVX512F"
6256   "vunpcklps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6257   [(set_attr "type" "sselog")
6258    (set_attr "prefix" "evex")
6259    (set_attr "mode" "V16SF")])
6261 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
6262 (define_insn "avx_unpcklps256<mask_name>"
6263   [(set (match_operand:V8SF 0 "register_operand" "=v")
6264         (vec_select:V8SF
6265           (vec_concat:V16SF
6266             (match_operand:V8SF 1 "register_operand" "v")
6267             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6268           (parallel [(const_int 0) (const_int 8)
6269                      (const_int 1) (const_int 9)
6270                      (const_int 4) (const_int 12)
6271                      (const_int 5) (const_int 13)])))]
6272   "TARGET_AVX && <mask_avx512vl_condition>"
6273   "vunpcklps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6274   [(set_attr "type" "sselog")
6275    (set_attr "prefix" "vex")
6276    (set_attr "mode" "V8SF")])
6278 (define_insn "unpcklps128_mask"
6279   [(set (match_operand:V4SF 0 "register_operand" "=v")
6280         (vec_merge:V4SF
6281           (vec_select:V4SF
6282             (vec_concat:V8SF
6283               (match_operand:V4SF 1 "register_operand" "v")
6284               (match_operand:V4SF 2 "nonimmediate_operand" "vm"))
6285             (parallel [(const_int 0) (const_int 4)
6286                       (const_int 1) (const_int 5)]))
6287           (match_operand:V4SF 3 "vector_move_operand" "0C")
6288           (match_operand:QI 4 "register_operand" "Yk")))]
6289   "TARGET_AVX512VL"
6290   "vunpcklps\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
6291   [(set_attr "type" "sselog")
6292    (set_attr "prefix" "evex")
6293    (set_attr "mode" "V4SF")])
6295 (define_expand "vec_interleave_lowv8sf"
6296   [(set (match_dup 3)
6297         (vec_select:V8SF
6298           (vec_concat:V16SF
6299             (match_operand:V8SF 1 "register_operand" "x")
6300             (match_operand:V8SF 2 "nonimmediate_operand" "xm"))
6301           (parallel [(const_int 0) (const_int 8)
6302                      (const_int 1) (const_int 9)
6303                      (const_int 4) (const_int 12)
6304                      (const_int 5) (const_int 13)])))
6305    (set (match_dup 4)
6306         (vec_select:V8SF
6307           (vec_concat:V16SF
6308             (match_dup 1)
6309             (match_dup 2))
6310           (parallel [(const_int 2) (const_int 10)
6311                      (const_int 3) (const_int 11)
6312                      (const_int 6) (const_int 14)
6313                      (const_int 7) (const_int 15)])))
6314    (set (match_operand:V8SF 0 "register_operand")
6315         (vec_select:V8SF
6316           (vec_concat:V16SF
6317             (match_dup 3)
6318             (match_dup 4))
6319           (parallel [(const_int 0) (const_int 1)
6320                      (const_int 2) (const_int 3)
6321                      (const_int 8) (const_int 9)
6322                      (const_int 10) (const_int 11)])))]
6323  "TARGET_AVX"
6325   operands[3] = gen_reg_rtx (V8SFmode);
6326   operands[4] = gen_reg_rtx (V8SFmode);
6329 (define_insn "vec_interleave_lowv4sf"
6330   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
6331         (vec_select:V4SF
6332           (vec_concat:V8SF
6333             (match_operand:V4SF 1 "register_operand" "0,x")
6334             (match_operand:V4SF 2 "vector_operand" "xBm,xm"))
6335           (parallel [(const_int 0) (const_int 4)
6336                      (const_int 1) (const_int 5)])))]
6337   "TARGET_SSE"
6338   "@
6339    unpcklps\t{%2, %0|%0, %2}
6340    vunpcklps\t{%2, %1, %0|%0, %1, %2}"
6341   [(set_attr "isa" "noavx,avx")
6342    (set_attr "type" "sselog")
6343    (set_attr "prefix" "orig,vex")
6344    (set_attr "mode" "V4SF")])
6346 ;; These are modeled with the same vec_concat as the others so that we
6347 ;; capture users of shufps that can use the new instructions
6348 (define_insn "avx_movshdup256<mask_name>"
6349   [(set (match_operand:V8SF 0 "register_operand" "=v")
6350         (vec_select:V8SF
6351           (vec_concat:V16SF
6352             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
6353             (match_dup 1))
6354           (parallel [(const_int 1) (const_int 1)
6355                      (const_int 3) (const_int 3)
6356                      (const_int 5) (const_int 5)
6357                      (const_int 7) (const_int 7)])))]
6358   "TARGET_AVX && <mask_avx512vl_condition>"
6359   "vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6360   [(set_attr "type" "sse")
6361    (set_attr "prefix" "vex")
6362    (set_attr "mode" "V8SF")])
6364 (define_insn "sse3_movshdup<mask_name>"
6365   [(set (match_operand:V4SF 0 "register_operand" "=v")
6366         (vec_select:V4SF
6367           (vec_concat:V8SF
6368             (match_operand:V4SF 1 "vector_operand" "vBm")
6369             (match_dup 1))
6370           (parallel [(const_int 1)
6371                      (const_int 1)
6372                      (const_int 7)
6373                      (const_int 7)])))]
6374   "TARGET_SSE3 && <mask_avx512vl_condition>"
6375   "%vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6376   [(set_attr "type" "sse")
6377    (set_attr "prefix_rep" "1")
6378    (set_attr "prefix" "maybe_vex")
6379    (set_attr "mode" "V4SF")])
6381 (define_insn "<mask_codefor>avx512f_movshdup512<mask_name>"
6382   [(set (match_operand:V16SF 0 "register_operand" "=v")
6383         (vec_select:V16SF
6384           (vec_concat:V32SF
6385             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
6386             (match_dup 1))
6387           (parallel [(const_int 1) (const_int 1)
6388                      (const_int 3) (const_int 3)
6389                      (const_int 5) (const_int 5)
6390                      (const_int 7) (const_int 7)
6391                      (const_int 9) (const_int 9)
6392                      (const_int 11) (const_int 11)
6393                      (const_int 13) (const_int 13)
6394                      (const_int 15) (const_int 15)])))]
6395   "TARGET_AVX512F"
6396   "vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6397   [(set_attr "type" "sse")
6398    (set_attr "prefix" "evex")
6399    (set_attr "mode" "V16SF")])
6401 (define_insn "avx_movsldup256<mask_name>"
6402   [(set (match_operand:V8SF 0 "register_operand" "=v")
6403         (vec_select:V8SF
6404           (vec_concat:V16SF
6405             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
6406             (match_dup 1))
6407           (parallel [(const_int 0) (const_int 0)
6408                      (const_int 2) (const_int 2)
6409                      (const_int 4) (const_int 4)
6410                      (const_int 6) (const_int 6)])))]
6411   "TARGET_AVX && <mask_avx512vl_condition>"
6412   "vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6413   [(set_attr "type" "sse")
6414    (set_attr "prefix" "vex")
6415    (set_attr "mode" "V8SF")])
6417 (define_insn "sse3_movsldup<mask_name>"
6418   [(set (match_operand:V4SF 0 "register_operand" "=v")
6419         (vec_select:V4SF
6420           (vec_concat:V8SF
6421             (match_operand:V4SF 1 "vector_operand" "vBm")
6422             (match_dup 1))
6423           (parallel [(const_int 0)
6424                      (const_int 0)
6425                      (const_int 6)
6426                      (const_int 6)])))]
6427   "TARGET_SSE3 && <mask_avx512vl_condition>"
6428   "%vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6429   [(set_attr "type" "sse")
6430    (set_attr "prefix_rep" "1")
6431    (set_attr "prefix" "maybe_vex")
6432    (set_attr "mode" "V4SF")])
6434 (define_insn "<mask_codefor>avx512f_movsldup512<mask_name>"
6435   [(set (match_operand:V16SF 0 "register_operand" "=v")
6436         (vec_select:V16SF
6437           (vec_concat:V32SF
6438             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
6439             (match_dup 1))
6440           (parallel [(const_int 0) (const_int 0)
6441                      (const_int 2) (const_int 2)
6442                      (const_int 4) (const_int 4)
6443                      (const_int 6) (const_int 6)
6444                      (const_int 8) (const_int 8)
6445                      (const_int 10) (const_int 10)
6446                      (const_int 12) (const_int 12)
6447                      (const_int 14) (const_int 14)])))]
6448   "TARGET_AVX512F"
6449   "vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6450   [(set_attr "type" "sse")
6451    (set_attr "prefix" "evex")
6452    (set_attr "mode" "V16SF")])
6454 (define_expand "avx_shufps256<mask_expand4_name>"
6455   [(match_operand:V8SF 0 "register_operand")
6456    (match_operand:V8SF 1 "register_operand")
6457    (match_operand:V8SF 2 "nonimmediate_operand")
6458    (match_operand:SI 3 "const_int_operand")]
6459   "TARGET_AVX"
6461   int mask = INTVAL (operands[3]);
6462   emit_insn (gen_avx_shufps256_1<mask_expand4_name> (operands[0],
6463                                                      operands[1],
6464                                                      operands[2],
6465                                                      GEN_INT ((mask >> 0) & 3),
6466                                                      GEN_INT ((mask >> 2) & 3),
6467                                                      GEN_INT (((mask >> 4) & 3) + 8),
6468                                                      GEN_INT (((mask >> 6) & 3) + 8),
6469                                                      GEN_INT (((mask >> 0) & 3) + 4),
6470                                                      GEN_INT (((mask >> 2) & 3) + 4),
6471                                                      GEN_INT (((mask >> 4) & 3) + 12),
6472                                                      GEN_INT (((mask >> 6) & 3) + 12)
6473                                                      <mask_expand4_args>));
6474   DONE;
6477 ;; One bit in mask selects 2 elements.
6478 (define_insn "avx_shufps256_1<mask_name>"
6479   [(set (match_operand:V8SF 0 "register_operand" "=v")
6480         (vec_select:V8SF
6481           (vec_concat:V16SF
6482             (match_operand:V8SF 1 "register_operand" "v")
6483             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6484           (parallel [(match_operand 3  "const_0_to_3_operand"  )
6485                      (match_operand 4  "const_0_to_3_operand"  )
6486                      (match_operand 5  "const_8_to_11_operand" )
6487                      (match_operand 6  "const_8_to_11_operand" )
6488                      (match_operand 7  "const_4_to_7_operand"  )
6489                      (match_operand 8  "const_4_to_7_operand"  )
6490                      (match_operand 9  "const_12_to_15_operand")
6491                      (match_operand 10 "const_12_to_15_operand")])))]
6492   "TARGET_AVX
6493    && <mask_avx512vl_condition>
6494    && (INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
6495        && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
6496        && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4)
6497        && INTVAL (operands[6]) == (INTVAL (operands[10]) - 4))"
6499   int mask;
6500   mask = INTVAL (operands[3]);
6501   mask |= INTVAL (operands[4]) << 2;
6502   mask |= (INTVAL (operands[5]) - 8) << 4;
6503   mask |= (INTVAL (operands[6]) - 8) << 6;
6504   operands[3] = GEN_INT (mask);
6506   return "vshufps\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
6508   [(set_attr "type" "sseshuf")
6509    (set_attr "length_immediate" "1")
6510    (set_attr "prefix" "<mask_prefix>")
6511    (set_attr "mode" "V8SF")])
6513 (define_expand "sse_shufps<mask_expand4_name>"
6514   [(match_operand:V4SF 0 "register_operand")
6515    (match_operand:V4SF 1 "register_operand")
6516    (match_operand:V4SF 2 "vector_operand")
6517    (match_operand:SI 3 "const_int_operand")]
6518   "TARGET_SSE"
6520   int mask = INTVAL (operands[3]);
6521   emit_insn (gen_sse_shufps_v4sf<mask_expand4_name> (operands[0],
6522                                                      operands[1],
6523                                                      operands[2],
6524                                                      GEN_INT ((mask >> 0) & 3),
6525                                                      GEN_INT ((mask >> 2) & 3),
6526                                                      GEN_INT (((mask >> 4) & 3) + 4),
6527                                                      GEN_INT (((mask >> 6) & 3) + 4)
6528                                                      <mask_expand4_args>));
6529   DONE;
6532 (define_insn "sse_shufps_v4sf_mask"
6533   [(set (match_operand:V4SF 0 "register_operand" "=v")
6534     (vec_merge:V4SF
6535           (vec_select:V4SF
6536             (vec_concat:V8SF
6537               (match_operand:V4SF 1 "register_operand" "v")
6538               (match_operand:V4SF 2 "nonimmediate_operand" "vm"))
6539             (parallel [(match_operand 3 "const_0_to_3_operand")
6540                        (match_operand 4 "const_0_to_3_operand")
6541                        (match_operand 5 "const_4_to_7_operand")
6542                        (match_operand 6 "const_4_to_7_operand")]))
6543       (match_operand:V4SF 7 "vector_move_operand" "0C")
6544       (match_operand:QI 8 "register_operand" "Yk")))]
6545   "TARGET_AVX512VL"
6547   int mask = 0;
6548   mask |= INTVAL (operands[3]) << 0;
6549   mask |= INTVAL (operands[4]) << 2;
6550   mask |= (INTVAL (operands[5]) - 4) << 4;
6551   mask |= (INTVAL (operands[6]) - 4) << 6;
6552   operands[3] = GEN_INT (mask);
6554   return "vshufps\t{%3, %2, %1, %0%{%8%}%N7|%0%{%8%}%N7, %1, %2, %3}";
6556   [(set_attr "type" "sseshuf")
6557    (set_attr "length_immediate" "1")
6558    (set_attr "prefix" "evex")
6559    (set_attr "mode" "V4SF")])
6561 (define_insn "sse_shufps_<mode>"
6562   [(set (match_operand:VI4F_128 0 "register_operand" "=x,x")
6563         (vec_select:VI4F_128
6564           (vec_concat:<ssedoublevecmode>
6565             (match_operand:VI4F_128 1 "register_operand" "0,x")
6566             (match_operand:VI4F_128 2 "vector_operand" "xBm,xm"))
6567           (parallel [(match_operand 3 "const_0_to_3_operand")
6568                      (match_operand 4 "const_0_to_3_operand")
6569                      (match_operand 5 "const_4_to_7_operand")
6570                      (match_operand 6 "const_4_to_7_operand")])))]
6571   "TARGET_SSE"
6573   int mask = 0;
6574   mask |= INTVAL (operands[3]) << 0;
6575   mask |= INTVAL (operands[4]) << 2;
6576   mask |= (INTVAL (operands[5]) - 4) << 4;
6577   mask |= (INTVAL (operands[6]) - 4) << 6;
6578   operands[3] = GEN_INT (mask);
6580   switch (which_alternative)
6581     {
6582     case 0:
6583       return "shufps\t{%3, %2, %0|%0, %2, %3}";
6584     case 1:
6585       return "vshufps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
6586     default:
6587       gcc_unreachable ();
6588     }
6590   [(set_attr "isa" "noavx,avx")
6591    (set_attr "type" "sseshuf")
6592    (set_attr "length_immediate" "1")
6593    (set_attr "prefix" "orig,vex")
6594    (set_attr "mode" "V4SF")])
6596 (define_insn "sse_storehps"
6597   [(set (match_operand:V2SF 0 "nonimmediate_operand" "=m,x,x")
6598         (vec_select:V2SF
6599           (match_operand:V4SF 1 "nonimmediate_operand" "x,x,o")
6600           (parallel [(const_int 2) (const_int 3)])))]
6601   "TARGET_SSE"
6602   "@
6603    %vmovhps\t{%1, %0|%q0, %1}
6604    %vmovhlps\t{%1, %d0|%d0, %1}
6605    %vmovlps\t{%H1, %d0|%d0, %H1}"
6606   [(set_attr "type" "ssemov")
6607    (set_attr "ssememalign" "64")
6608    (set_attr "prefix" "maybe_vex")
6609    (set_attr "mode" "V2SF,V4SF,V2SF")])
6611 (define_expand "sse_loadhps_exp"
6612   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6613         (vec_concat:V4SF
6614           (vec_select:V2SF
6615             (match_operand:V4SF 1 "nonimmediate_operand")
6616             (parallel [(const_int 0) (const_int 1)]))
6617           (match_operand:V2SF 2 "nonimmediate_operand")))]
6618   "TARGET_SSE"
6620   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6622   emit_insn (gen_sse_loadhps (dst, operands[1], operands[2]));
6624   /* Fix up the destination if needed.  */
6625   if (dst != operands[0])
6626     emit_move_insn (operands[0], dst);
6628   DONE;
6631 (define_insn "sse_loadhps"
6632   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,x,x,x,o")
6633         (vec_concat:V4SF
6634           (vec_select:V2SF
6635             (match_operand:V4SF 1 "nonimmediate_operand" " 0,x,0,x,0")
6636             (parallel [(const_int 0) (const_int 1)]))
6637           (match_operand:V2SF 2 "nonimmediate_operand"   " m,m,x,x,x")))]
6638   "TARGET_SSE"
6639   "@
6640    movhps\t{%2, %0|%0, %q2}
6641    vmovhps\t{%2, %1, %0|%0, %1, %q2}
6642    movlhps\t{%2, %0|%0, %2}
6643    vmovlhps\t{%2, %1, %0|%0, %1, %2}
6644    %vmovlps\t{%2, %H0|%H0, %2}"
6645   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6646    (set_attr "type" "ssemov")
6647    (set_attr "ssememalign" "64")
6648    (set_attr "prefix" "orig,vex,orig,vex,maybe_vex")
6649    (set_attr "mode" "V2SF,V2SF,V4SF,V4SF,V2SF")])
6651 (define_insn "sse_storelps"
6652   [(set (match_operand:V2SF 0 "nonimmediate_operand"   "=m,x,x")
6653         (vec_select:V2SF
6654           (match_operand:V4SF 1 "nonimmediate_operand" " x,x,m")
6655           (parallel [(const_int 0) (const_int 1)])))]
6656   "TARGET_SSE"
6657   "@
6658    %vmovlps\t{%1, %0|%q0, %1}
6659    %vmovaps\t{%1, %0|%0, %1}
6660    %vmovlps\t{%1, %d0|%d0, %q1}"
6661   [(set_attr "type" "ssemov")
6662    (set_attr "ssememalign" "64")
6663    (set_attr "prefix" "maybe_vex")
6664    (set_attr "mode" "V2SF,V4SF,V2SF")])
6666 (define_expand "sse_loadlps_exp"
6667   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6668         (vec_concat:V4SF
6669           (match_operand:V2SF 2 "nonimmediate_operand")
6670           (vec_select:V2SF
6671             (match_operand:V4SF 1 "nonimmediate_operand")
6672             (parallel [(const_int 2) (const_int 3)]))))]
6673   "TARGET_SSE"
6675   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6677   emit_insn (gen_sse_loadlps (dst, operands[1], operands[2]));
6679   /* Fix up the destination if needed.  */
6680   if (dst != operands[0])
6681     emit_move_insn (operands[0], dst);
6683   DONE;
6686 (define_insn "sse_loadlps"
6687   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,x,x,x,m")
6688         (vec_concat:V4SF
6689           (match_operand:V2SF 2 "nonimmediate_operand"   " 0,x,m,m,x")
6690           (vec_select:V2SF
6691             (match_operand:V4SF 1 "nonimmediate_operand" " x,x,0,x,0")
6692             (parallel [(const_int 2) (const_int 3)]))))]
6693   "TARGET_SSE"
6694   "@
6695    shufps\t{$0xe4, %1, %0|%0, %1, 0xe4}
6696    vshufps\t{$0xe4, %1, %2, %0|%0, %2, %1, 0xe4}
6697    movlps\t{%2, %0|%0, %q2}
6698    vmovlps\t{%2, %1, %0|%0, %1, %q2}
6699    %vmovlps\t{%2, %0|%q0, %2}"
6700   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6701    (set_attr "type" "sseshuf,sseshuf,ssemov,ssemov,ssemov")
6702    (set_attr "ssememalign" "64")
6703    (set_attr "length_immediate" "1,1,*,*,*")
6704    (set_attr "prefix" "orig,vex,orig,vex,maybe_vex")
6705    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
6707 (define_insn "sse_movss"
6708   [(set (match_operand:V4SF 0 "register_operand"   "=x,x")
6709         (vec_merge:V4SF
6710           (match_operand:V4SF 2 "register_operand" " x,x")
6711           (match_operand:V4SF 1 "register_operand" " 0,x")
6712           (const_int 1)))]
6713   "TARGET_SSE"
6714   "@
6715    movss\t{%2, %0|%0, %2}
6716    vmovss\t{%2, %1, %0|%0, %1, %2}"
6717   [(set_attr "isa" "noavx,avx")
6718    (set_attr "type" "ssemov")
6719    (set_attr "prefix" "orig,vex")
6720    (set_attr "mode" "SF")])
6722 (define_insn "avx2_vec_dup<mode>"
6723   [(set (match_operand:VF1_128_256 0 "register_operand" "=x")
6724         (vec_duplicate:VF1_128_256
6725           (vec_select:SF
6726             (match_operand:V4SF 1 "register_operand" "x")
6727             (parallel [(const_int 0)]))))]
6728   "TARGET_AVX2"
6729   "vbroadcastss\t{%1, %0|%0, %1}"
6730   [(set_attr "type" "sselog1")
6731     (set_attr "prefix" "vex")
6732     (set_attr "mode" "<MODE>")])
6734 (define_insn "avx2_vec_dupv8sf_1"
6735   [(set (match_operand:V8SF 0 "register_operand" "=x")
6736         (vec_duplicate:V8SF
6737           (vec_select:SF
6738             (match_operand:V8SF 1 "register_operand" "x")
6739             (parallel [(const_int 0)]))))]
6740   "TARGET_AVX2"
6741   "vbroadcastss\t{%x1, %0|%0, %x1}"
6742   [(set_attr "type" "sselog1")
6743     (set_attr "prefix" "vex")
6744     (set_attr "mode" "V8SF")])
6746 (define_insn "avx512f_vec_dup<mode>_1"
6747   [(set (match_operand:VF_512 0 "register_operand" "=v")
6748         (vec_duplicate:VF_512
6749           (vec_select:<ssescalarmode>
6750             (match_operand:VF_512 1 "register_operand" "v")
6751             (parallel [(const_int 0)]))))]
6752   "TARGET_AVX512F"
6753   "vbroadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}"
6754   [(set_attr "type" "sselog1")
6755     (set_attr "prefix" "evex")
6756     (set_attr "mode" "<MODE>")])
6758 ;; Although insertps takes register source, we prefer
6759 ;; unpcklps with register source since it is shorter.
6760 (define_insn "*vec_concatv2sf_sse4_1"
6761   [(set (match_operand:V2SF 0 "register_operand"
6762           "=Yr,*x,x,Yr,*x,x,x,*y ,*y")
6763         (vec_concat:V2SF
6764           (match_operand:SF 1 "nonimmediate_operand"
6765           "  0, 0,x, 0,0, x,m, 0 , m")
6766           (match_operand:SF 2 "vector_move_operand"
6767           " Yr,*x,x, m,m, m,C,*ym, C")))]
6768   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
6769   "@
6770    unpcklps\t{%2, %0|%0, %2}
6771    unpcklps\t{%2, %0|%0, %2}
6772    vunpcklps\t{%2, %1, %0|%0, %1, %2}
6773    insertps\t{$0x10, %2, %0|%0, %2, 0x10}
6774    insertps\t{$0x10, %2, %0|%0, %2, 0x10}
6775    vinsertps\t{$0x10, %2, %1, %0|%0, %1, %2, 0x10}
6776    %vmovss\t{%1, %0|%0, %1}
6777    punpckldq\t{%2, %0|%0, %2}
6778    movd\t{%1, %0|%0, %1}"
6779   [(set_attr "isa" "noavx,noavx,avx,noavx,noavx,avx,*,*,*")
6780    (set_attr "type" "sselog,sselog,sselog,sselog,sselog,sselog,ssemov,mmxcvt,mmxmov")
6781    (set_attr "prefix_data16" "*,*,*,1,1,*,*,*,*")
6782    (set_attr "prefix_extra" "*,*,*,1,1,1,*,*,*")
6783    (set_attr "length_immediate" "*,*,*,1,1,1,*,*,*")
6784    (set_attr "prefix" "orig,orig,vex,orig,orig,vex,maybe_vex,orig,orig")
6785    (set_attr "mode" "V4SF,V4SF,V4SF,V4SF,V4SF,V4SF,SF,DI,DI")])
6787 ;; ??? In theory we can match memory for the MMX alternative, but allowing
6788 ;; vector_operand for operand 2 and *not* allowing memory for the SSE
6789 ;; alternatives pretty much forces the MMX alternative to be chosen.
6790 (define_insn "*vec_concatv2sf_sse"
6791   [(set (match_operand:V2SF 0 "register_operand"     "=x,x,*y,*y")
6792         (vec_concat:V2SF
6793           (match_operand:SF 1 "nonimmediate_operand" " 0,m, 0, m")
6794           (match_operand:SF 2 "reg_or_0_operand"     " x,C,*y, C")))]
6795   "TARGET_SSE"
6796   "@
6797    unpcklps\t{%2, %0|%0, %2}
6798    movss\t{%1, %0|%0, %1}
6799    punpckldq\t{%2, %0|%0, %2}
6800    movd\t{%1, %0|%0, %1}"
6801   [(set_attr "type" "sselog,ssemov,mmxcvt,mmxmov")
6802    (set_attr "mode" "V4SF,SF,DI,DI")])
6804 (define_insn "*vec_concatv4sf"
6805   [(set (match_operand:V4SF 0 "register_operand"       "=x,x,x,x")
6806         (vec_concat:V4SF
6807           (match_operand:V2SF 1 "register_operand"     " 0,x,0,x")
6808           (match_operand:V2SF 2 "nonimmediate_operand" " x,x,m,m")))]
6809   "TARGET_SSE"
6810   "@
6811    movlhps\t{%2, %0|%0, %2}
6812    vmovlhps\t{%2, %1, %0|%0, %1, %2}
6813    movhps\t{%2, %0|%0, %q2}
6814    vmovhps\t{%2, %1, %0|%0, %1, %q2}"
6815   [(set_attr "isa" "noavx,avx,noavx,avx")
6816    (set_attr "type" "ssemov")
6817    (set_attr "prefix" "orig,vex,orig,vex")
6818    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF")])
6820 (define_expand "vec_init<mode>"
6821   [(match_operand:V_128 0 "register_operand")
6822    (match_operand 1)]
6823   "TARGET_SSE"
6825   ix86_expand_vector_init (false, operands[0], operands[1]);
6826   DONE;
6829 ;; Avoid combining registers from different units in a single alternative,
6830 ;; see comment above inline_secondary_memory_needed function in i386.c
6831 (define_insn "vec_set<mode>_0"
6832   [(set (match_operand:VI4F_128 0 "nonimmediate_operand"
6833           "=Yr,*v,v,Yi,x,x,v,Yr ,*x ,x  ,m ,m   ,m")
6834         (vec_merge:VI4F_128
6835           (vec_duplicate:VI4F_128
6836             (match_operand:<ssescalarmode> 2 "general_operand"
6837           " Yr,*v,m,r ,m,x,v,*rm,*rm,*rm,!x,!*re,!*fF"))
6838           (match_operand:VI4F_128 1 "vector_move_operand"
6839           " C , C,C,C ,C,0,v,0  ,0  ,x  ,0 ,0   ,0")
6840           (const_int 1)))]
6841   "TARGET_SSE"
6842   "@
6843    %vinsertps\t{$0xe, %d2, %0|%0, %d2, 0xe}
6844    %vinsertps\t{$0xe, %d2, %0|%0, %d2, 0xe}
6845    %vmov<ssescalarmodesuffix>\t{%2, %0|%0, %2}
6846    %vmovd\t{%2, %0|%0, %2}
6847    movss\t{%2, %0|%0, %2}
6848    movss\t{%2, %0|%0, %2}
6849    vmovss\t{%2, %1, %0|%0, %1, %2}
6850    pinsrd\t{$0, %2, %0|%0, %2, 0}
6851    pinsrd\t{$0, %2, %0|%0, %2, 0}
6852    vpinsrd\t{$0, %2, %1, %0|%0, %1, %2, 0}
6853    #
6854    #
6855    #"
6856   [(set_attr "isa" "sse4,sse4,sse2,sse2,noavx,noavx,avx,sse4_noavx,sse4_noavx,avx,*,*,*")
6857    (set (attr "type")
6858      (cond [(eq_attr "alternative" "0,1,7,8,9")
6859               (const_string "sselog")
6860             (eq_attr "alternative" "11")
6861               (const_string "imov")
6862             (eq_attr "alternative" "12")
6863               (const_string "fmov")
6864            ]
6865            (const_string "ssemov")))
6866    (set_attr "prefix_extra" "*,*,*,*,*,*,*,1,1,1,*,*,*")
6867    (set_attr "length_immediate" "*,*,*,*,*,*,*,1,1,1,*,*,*")
6868    (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,maybe_vex,orig,orig,vex,orig,orig,vex,*,*,*")
6869    (set_attr "mode" "SF,SF,<ssescalarmode>,SI,SF,SF,SF,TI,TI,TI,*,*,*")])
6871 ;; A subset is vec_setv4sf.
6872 (define_insn "*vec_setv4sf_sse4_1"
6873   [(set (match_operand:V4SF 0 "register_operand" "=Yr,*x,x")
6874         (vec_merge:V4SF
6875           (vec_duplicate:V4SF
6876             (match_operand:SF 2 "nonimmediate_operand" "Yrm,*xm,xm"))
6877           (match_operand:V4SF 1 "register_operand" "0,0,x")
6878           (match_operand:SI 3 "const_int_operand")))]
6879   "TARGET_SSE4_1
6880    && ((unsigned) exact_log2 (INTVAL (operands[3]))
6881        < GET_MODE_NUNITS (V4SFmode))"
6883   operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])) << 4);
6884   switch (which_alternative)
6885     {
6886     case 0:
6887     case 1:
6888       return "insertps\t{%3, %2, %0|%0, %2, %3}";
6889     case 2:
6890       return "vinsertps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
6891     default:
6892       gcc_unreachable ();
6893     }
6895   [(set_attr "isa" "noavx,noavx,avx")
6896    (set_attr "type" "sselog")
6897    (set_attr "prefix_data16" "1,1,*")
6898    (set_attr "prefix_extra" "1")
6899    (set_attr "length_immediate" "1")
6900    (set_attr "prefix" "orig,orig,vex")
6901    (set_attr "mode" "V4SF")])
6903 (define_insn "sse4_1_insertps"
6904   [(set (match_operand:V4SF 0 "register_operand" "=Yr,*x,x")
6905         (unspec:V4SF [(match_operand:V4SF 2 "nonimmediate_operand" "Yrm,*xm,xm")
6906                       (match_operand:V4SF 1 "register_operand" "0,0,x")
6907                       (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
6908                      UNSPEC_INSERTPS))]
6909   "TARGET_SSE4_1"
6911   if (MEM_P (operands[2]))
6912     {
6913       unsigned count_s = INTVAL (operands[3]) >> 6;
6914       if (count_s)
6915         operands[3] = GEN_INT (INTVAL (operands[3]) & 0x3f);
6916       operands[2] = adjust_address_nv (operands[2], SFmode, count_s * 4);
6917     }
6918   switch (which_alternative)
6919     {
6920     case 0:
6921     case 1:
6922       return "insertps\t{%3, %2, %0|%0, %2, %3}";
6923     case 2:
6924       return "vinsertps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
6925     default:
6926       gcc_unreachable ();
6927     }
6929   [(set_attr "isa" "noavx,noavx,avx")
6930    (set_attr "type" "sselog")
6931    (set_attr "prefix_data16" "1,1,*")
6932    (set_attr "prefix_extra" "1")
6933    (set_attr "length_immediate" "1")
6934    (set_attr "prefix" "orig,orig,vex")
6935    (set_attr "mode" "V4SF")])
6937 (define_split
6938   [(set (match_operand:VI4F_128 0 "memory_operand")
6939         (vec_merge:VI4F_128
6940           (vec_duplicate:VI4F_128
6941             (match_operand:<ssescalarmode> 1 "nonmemory_operand"))
6942           (match_dup 0)
6943           (const_int 1)))]
6944   "TARGET_SSE && reload_completed"
6945   [(set (match_dup 0) (match_dup 1))]
6946   "operands[0] = adjust_address (operands[0], <ssescalarmode>mode, 0);")
6948 (define_expand "vec_set<mode>"
6949   [(match_operand:V 0 "register_operand")
6950    (match_operand:<ssescalarmode> 1 "register_operand")
6951    (match_operand 2 "const_int_operand")]
6952   "TARGET_SSE"
6954   ix86_expand_vector_set (false, operands[0], operands[1],
6955                           INTVAL (operands[2]));
6956   DONE;
6959 (define_insn_and_split "*vec_extractv4sf_0"
6960   [(set (match_operand:SF 0 "nonimmediate_operand" "=x,m,f,r")
6961         (vec_select:SF
6962           (match_operand:V4SF 1 "nonimmediate_operand" "xm,x,m,m")
6963           (parallel [(const_int 0)])))]
6964   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
6965   "#"
6966   "&& reload_completed"
6967   [(set (match_dup 0) (match_dup 1))]
6969   if (REG_P (operands[1]))
6970     operands[1] = gen_rtx_REG (SFmode, REGNO (operands[1]));
6971   else
6972     operands[1] = adjust_address (operands[1], SFmode, 0);
6975 (define_insn_and_split "*sse4_1_extractps"
6976   [(set (match_operand:SF 0 "nonimmediate_operand" "=rm,rm,x,x")
6977         (vec_select:SF
6978           (match_operand:V4SF 1 "register_operand" "Yr,*x,0,x")
6979           (parallel [(match_operand:SI 2 "const_0_to_3_operand" "n,n,n,n")])))]
6980   "TARGET_SSE4_1"
6981   "@
6982    %vextractps\t{%2, %1, %0|%0, %1, %2}
6983    %vextractps\t{%2, %1, %0|%0, %1, %2}
6984    #
6985    #"
6986   "&& reload_completed && SSE_REG_P (operands[0])"
6987   [(const_int 0)]
6989   rtx dest = gen_rtx_REG (V4SFmode, REGNO (operands[0]));
6990   switch (INTVAL (operands[2]))
6991     {
6992     case 1:
6993     case 3:
6994       emit_insn (gen_sse_shufps_v4sf (dest, operands[1], operands[1],
6995                                       operands[2], operands[2],
6996                                       GEN_INT (INTVAL (operands[2]) + 4),
6997                                       GEN_INT (INTVAL (operands[2]) + 4)));
6998       break;
6999     case 2:
7000       emit_insn (gen_vec_interleave_highv4sf (dest, operands[1], operands[1]));
7001       break;
7002     default:
7003       /* 0 should be handled by the *vec_extractv4sf_0 pattern above.  */
7004       gcc_unreachable ();
7005     }
7006   DONE;
7008   [(set_attr "isa" "*,*,noavx,avx")
7009    (set_attr "type" "sselog,sselog,*,*")
7010    (set_attr "prefix_data16" "1,1,*,*")
7011    (set_attr "prefix_extra" "1,1,*,*")
7012    (set_attr "length_immediate" "1,1,*,*")
7013    (set_attr "prefix" "maybe_vex,maybe_vex,*,*")
7014    (set_attr "mode" "V4SF,V4SF,*,*")])
7016 (define_insn_and_split "*vec_extractv4sf_mem"
7017   [(set (match_operand:SF 0 "register_operand" "=x,*r,f")
7018         (vec_select:SF
7019           (match_operand:V4SF 1 "memory_operand" "o,o,o")
7020           (parallel [(match_operand 2 "const_0_to_3_operand" "n,n,n")])))]
7021   "TARGET_SSE"
7022   "#"
7023   "&& reload_completed"
7024   [(set (match_dup 0) (match_dup 1))]
7026   operands[1] = adjust_address (operands[1], SFmode, INTVAL (operands[2]) * 4);
7029 (define_mode_attr extract_type
7030   [(V16SF "avx512f") (V16SI "avx512f") (V8DF "avx512dq") (V8DI "avx512dq")])
7032 (define_mode_attr extract_suf
7033   [(V16SF "32x4") (V16SI "32x4") (V8DF "64x2") (V8DI "64x2")])
7035 (define_mode_iterator AVX512_VEC
7036   [(V8DF "TARGET_AVX512DQ") (V8DI "TARGET_AVX512DQ") V16SF V16SI])
7038 (define_expand "<extract_type>_vextract<shuffletype><extract_suf>_mask"
7039   [(match_operand:<ssequartermode> 0 "nonimmediate_operand")
7040    (match_operand:AVX512_VEC 1 "register_operand")
7041    (match_operand:SI 2 "const_0_to_3_operand")
7042    (match_operand:<ssequartermode> 3 "nonimmediate_operand")
7043    (match_operand:QI 4 "register_operand")]
7044   "TARGET_AVX512F"
7046   int mask;
7047   mask = INTVAL (operands[2]);
7049   if (MEM_P (operands[0]) && GET_CODE (operands[3]) == CONST_VECTOR)
7050     operands[0] = force_reg (<ssequartermode>mode, operands[0]);
7052   if (<MODE>mode == V16SImode || <MODE>mode == V16SFmode)
7053     emit_insn (gen_avx512f_vextract<shuffletype>32x4_1_mask (operands[0],
7054         operands[1], GEN_INT (mask * 4), GEN_INT (mask * 4 + 1),
7055         GEN_INT (mask * 4 + 2), GEN_INT (mask * 4 + 3), operands[3],
7056         operands[4]));
7057   else
7058     emit_insn (gen_avx512dq_vextract<shuffletype>64x2_1_mask (operands[0],
7059         operands[1], GEN_INT (mask * 2), GEN_INT (mask * 2 + 1), operands[3],
7060         operands[4]));
7061   DONE;
7064 (define_insn "avx512dq_vextract<shuffletype>64x2_1_maskm"
7065   [(set (match_operand:<ssequartermode> 0 "memory_operand" "=m")
7066         (vec_merge:<ssequartermode>
7067           (vec_select:<ssequartermode>
7068             (match_operand:V8FI 1 "register_operand" "v")
7069             (parallel [(match_operand 2  "const_0_to_7_operand")
7070               (match_operand 3  "const_0_to_7_operand")]))
7071           (match_operand:<ssequartermode> 4 "memory_operand" "0")
7072           (match_operand:QI 5 "register_operand" "k")))]
7073   "TARGET_AVX512DQ
7074    && (INTVAL (operands[2]) % 2 == 0)
7075    && (INTVAL (operands[2]) == INTVAL (operands[3]) - 1)
7076    && rtx_equal_p (operands[4], operands[0])"
7078   operands[2] = GEN_INT ((INTVAL (operands[2])) >> 1);
7079   return "vextract<shuffletype>64x2\t{%2, %1, %0%{%5%}|%0%{%5%}, %1, %2}";
7081   [(set_attr "type" "sselog")
7082    (set_attr "prefix_extra" "1")
7083    (set_attr "length_immediate" "1")
7084    (set_attr "memory" "store")
7085    (set_attr "prefix" "evex")
7086    (set_attr "mode" "<sseinsnmode>")])
7088 (define_insn "avx512f_vextract<shuffletype>32x4_1_maskm"
7089   [(set (match_operand:<ssequartermode> 0 "memory_operand" "=m")
7090         (vec_merge:<ssequartermode>
7091           (vec_select:<ssequartermode>
7092             (match_operand:V16FI 1 "register_operand" "v")
7093             (parallel [(match_operand 2  "const_0_to_15_operand")
7094               (match_operand 3  "const_0_to_15_operand")
7095               (match_operand 4  "const_0_to_15_operand")
7096               (match_operand 5  "const_0_to_15_operand")]))
7097           (match_operand:<ssequartermode> 6 "memory_operand" "0")
7098           (match_operand:QI 7 "register_operand" "Yk")))]
7099   "TARGET_AVX512F
7100    && ((INTVAL (operands[2]) % 4 == 0)
7101        && INTVAL (operands[2]) == (INTVAL (operands[3]) - 1)
7102        && INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
7103        && INTVAL (operands[4]) == (INTVAL (operands[5]) - 1))
7104    && rtx_equal_p (operands[6], operands[0])"
7106   operands[2] = GEN_INT ((INTVAL (operands[2])) >> 2);
7107   return "vextract<shuffletype>32x4\t{%2, %1, %0%{%7%}|%0%{%7%}, %1, %2}";
7109   [(set_attr "type" "sselog")
7110    (set_attr "prefix_extra" "1")
7111    (set_attr "length_immediate" "1")
7112    (set_attr "memory" "store")
7113    (set_attr "prefix" "evex")
7114    (set_attr "mode" "<sseinsnmode>")])
7116 (define_insn "<mask_codefor>avx512dq_vextract<shuffletype>64x2_1<mask_name>"
7117   [(set (match_operand:<ssequartermode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7118         (vec_select:<ssequartermode>
7119           (match_operand:V8FI 1 "register_operand" "v")
7120           (parallel [(match_operand 2  "const_0_to_7_operand")
7121             (match_operand 3  "const_0_to_7_operand")])))]
7122   "TARGET_AVX512DQ && (INTVAL (operands[2]) == INTVAL (operands[3]) - 1)"
7124   operands[2] = GEN_INT ((INTVAL (operands[2])) >> 1);
7125   return "vextract<shuffletype>64x2\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}";
7127   [(set_attr "type" "sselog1")
7128    (set_attr "prefix_extra" "1")
7129    (set_attr "length_immediate" "1")
7130    (set_attr "prefix" "evex")
7131    (set_attr "mode" "<sseinsnmode>")])
7133 (define_insn "<mask_codefor>avx512f_vextract<shuffletype>32x4_1<mask_name>"
7134   [(set (match_operand:<ssequartermode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7135         (vec_select:<ssequartermode>
7136           (match_operand:V16FI 1 "register_operand" "v")
7137           (parallel [(match_operand 2  "const_0_to_15_operand")
7138             (match_operand 3  "const_0_to_15_operand")
7139             (match_operand 4  "const_0_to_15_operand")
7140             (match_operand 5  "const_0_to_15_operand")])))]
7141   "TARGET_AVX512F
7142    && (INTVAL (operands[2]) == (INTVAL (operands[3]) - 1)
7143        && INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
7144        && INTVAL (operands[4]) == (INTVAL (operands[5]) - 1))"
7146   operands[2] = GEN_INT ((INTVAL (operands[2])) >> 2);
7147   return "vextract<shuffletype>32x4\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
7149   [(set_attr "type" "sselog1")
7150    (set_attr "prefix_extra" "1")
7151    (set_attr "length_immediate" "1")
7152    (set_attr "prefix" "evex")
7153    (set_attr "mode" "<sseinsnmode>")])
7155 (define_mode_attr extract_type_2
7156   [(V16SF "avx512dq") (V16SI "avx512dq") (V8DF "avx512f") (V8DI "avx512f")])
7158 (define_mode_attr extract_suf_2
7159   [(V16SF "32x8") (V16SI "32x8") (V8DF "64x4") (V8DI "64x4")])
7161 (define_mode_iterator AVX512_VEC_2
7162   [(V16SF "TARGET_AVX512DQ") (V16SI "TARGET_AVX512DQ") V8DF V8DI])
7164 (define_expand "<extract_type_2>_vextract<shuffletype><extract_suf_2>_mask"
7165   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7166    (match_operand:AVX512_VEC_2 1 "register_operand")
7167    (match_operand:SI 2 "const_0_to_1_operand")
7168    (match_operand:<ssehalfvecmode> 3 "nonimmediate_operand")
7169    (match_operand:QI 4 "register_operand")]
7170   "TARGET_AVX512F"
7172   rtx (*insn)(rtx, rtx, rtx, rtx);
7174   if (MEM_P (operands[0]) && GET_CODE (operands[3]) == CONST_VECTOR)
7175     operands[0] = force_reg (<ssequartermode>mode, operands[0]);
7177   switch (INTVAL (operands[2]))
7178     {
7179     case 0:
7180       insn = gen_vec_extract_lo_<mode>_mask;
7181       break;
7182     case 1:
7183       insn = gen_vec_extract_hi_<mode>_mask;
7184       break;
7185     default:
7186       gcc_unreachable ();
7187     }
7189   emit_insn (insn (operands[0], operands[1], operands[3], operands[4]));
7190   DONE;
7193 (define_split
7194   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7195         (vec_select:<ssehalfvecmode>
7196           (match_operand:V8FI 1 "nonimmediate_operand")
7197           (parallel [(const_int 0) (const_int 1)
7198             (const_int 2) (const_int 3)])))]
7199   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7200   && reload_completed
7201   && (TARGET_AVX512VL || (REG_P (operands[0]) && !EXT_REX_SSE_REG_P (operands[1])))"
7202   [(const_int 0)]
7204   rtx op1 = operands[1];
7205   if (REG_P (op1))
7206     op1 = gen_rtx_REG (<ssehalfvecmode>mode, REGNO (op1));
7207   else
7208     op1 = gen_lowpart (<ssehalfvecmode>mode, op1);
7209   emit_move_insn (operands[0], op1);
7210   DONE;
7213 (define_insn "vec_extract_lo_<mode>_maskm"
7214   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7215         (vec_merge:<ssehalfvecmode>
7216           (vec_select:<ssehalfvecmode>
7217             (match_operand:V8FI 1 "register_operand" "v")
7218             (parallel [(const_int 0) (const_int 1)
7219               (const_int 2) (const_int 3)]))
7220           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7221           (match_operand:QI 3 "register_operand" "Yk")))]
7222   "TARGET_AVX512F
7223    && rtx_equal_p (operands[2], operands[0])"
7224   "vextract<shuffletype>64x4\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}"
7225   [(set_attr "type" "sselog1")
7226    (set_attr "prefix_extra" "1")
7227    (set_attr "length_immediate" "1")
7228    (set_attr "prefix" "evex")
7229    (set_attr "mode" "<sseinsnmode>")])
7231 (define_insn "vec_extract_lo_<mode><mask_name>"
7232   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>,v")
7233         (vec_select:<ssehalfvecmode>
7234           (match_operand:V8FI 1 "nonimmediate_operand" "v,m")
7235           (parallel [(const_int 0) (const_int 1)
7236             (const_int 2) (const_int 3)])))]
7237   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7239   if (<mask_applied> || !TARGET_AVX512VL)
7240     return "vextract<shuffletype>64x4\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7241   else
7242     return "#";
7244   [(set_attr "type" "sselog1")
7245    (set_attr "prefix_extra" "1")
7246    (set_attr "length_immediate" "1")
7247    (set_attr "prefix" "evex")
7248    (set_attr "mode" "<sseinsnmode>")])
7250 (define_insn "vec_extract_hi_<mode>_maskm"
7251   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7252         (vec_merge:<ssehalfvecmode>
7253           (vec_select:<ssehalfvecmode>
7254             (match_operand:V8FI 1 "register_operand" "v")
7255             (parallel [(const_int 4) (const_int 5)
7256               (const_int 6) (const_int 7)]))
7257           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7258           (match_operand:QI 3 "register_operand" "Yk")))]
7259   "TARGET_AVX512F
7260    && rtx_equal_p (operands[2], operands[0])"
7261   "vextract<shuffletype>64x4\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7262   [(set_attr "type" "sselog")
7263    (set_attr "prefix_extra" "1")
7264    (set_attr "length_immediate" "1")
7265    (set_attr "memory" "store")
7266    (set_attr "prefix" "evex")
7267    (set_attr "mode" "<sseinsnmode>")])
7269 (define_insn "vec_extract_hi_<mode><mask_name>"
7270   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7271         (vec_select:<ssehalfvecmode>
7272           (match_operand:V8FI 1 "register_operand" "v")
7273           (parallel [(const_int 4) (const_int 5)
7274             (const_int 6) (const_int 7)])))]
7275   "TARGET_AVX512F"
7276   "vextract<shuffletype>64x4\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}"
7277   [(set_attr "type" "sselog1")
7278    (set_attr "prefix_extra" "1")
7279    (set_attr "length_immediate" "1")
7280    (set_attr "prefix" "evex")
7281    (set_attr "mode" "<sseinsnmode>")])
7283 (define_insn "vec_extract_hi_<mode>_maskm"
7284    [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7285         (vec_merge:<ssehalfvecmode>
7286           (vec_select:<ssehalfvecmode>
7287             (match_operand:V16FI 1 "register_operand" "v")
7288             (parallel [(const_int 8) (const_int 9)
7289               (const_int 10) (const_int 11)
7290               (const_int 12) (const_int 13)
7291               (const_int 14) (const_int 15)]))
7292           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7293           (match_operand:QI 3 "register_operand" "k")))]
7294   "TARGET_AVX512DQ
7295    && rtx_equal_p (operands[2], operands[0])"
7296   "vextract<shuffletype>32x8\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7297   [(set_attr "type" "sselog1")
7298    (set_attr "prefix_extra" "1")
7299    (set_attr "length_immediate" "1")
7300    (set_attr "prefix" "evex")
7301    (set_attr "mode" "<sseinsnmode>")])
7303 (define_insn "vec_extract_hi_<mode><mask_name>"
7304   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>,vm")
7305         (vec_select:<ssehalfvecmode>
7306           (match_operand:V16FI 1 "register_operand" "v,v")
7307           (parallel [(const_int 8) (const_int 9)
7308             (const_int 10) (const_int 11)
7309             (const_int 12) (const_int 13)
7310             (const_int 14) (const_int 15)])))]
7311   "TARGET_AVX512F && <mask_avx512dq_condition>"
7312   "@
7313    vextract<shuffletype>32x8\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}
7314    vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7315   [(set_attr "type" "sselog1")
7316    (set_attr "prefix_extra" "1")
7317    (set_attr "isa" "avx512dq,noavx512dq")
7318    (set_attr "length_immediate" "1")
7319    (set_attr "prefix" "evex")
7320    (set_attr "mode" "<sseinsnmode>")])
7322 (define_expand "avx512vl_vextractf128<mode>"
7323   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7324    (match_operand:VI48F_256 1 "register_operand")
7325    (match_operand:SI 2 "const_0_to_1_operand")
7326    (match_operand:<ssehalfvecmode> 3 "vector_move_operand")
7327    (match_operand:QI 4 "register_operand")]
7328   "TARGET_AVX512DQ && TARGET_AVX512VL"
7330   rtx (*insn)(rtx, rtx, rtx, rtx);
7332   if (MEM_P (operands[0]) && GET_CODE (operands[3]) == CONST_VECTOR)
7333     operands[0] = force_reg (<ssehalfvecmode>mode, operands[0]);
7335   switch (INTVAL (operands[2]))
7336     {
7337     case 0:
7338       insn = gen_vec_extract_lo_<mode>_mask;
7339       break;
7340     case 1:
7341       insn = gen_vec_extract_hi_<mode>_mask;
7342       break;
7343     default:
7344       gcc_unreachable ();
7345     }
7347   emit_insn (insn (operands[0], operands[1], operands[3], operands[4]));
7348   DONE;
7351 (define_expand "avx_vextractf128<mode>"
7352   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7353    (match_operand:V_256 1 "register_operand")
7354    (match_operand:SI 2 "const_0_to_1_operand")]
7355   "TARGET_AVX"
7357   rtx (*insn)(rtx, rtx);
7359   switch (INTVAL (operands[2]))
7360     {
7361     case 0:
7362       insn = gen_vec_extract_lo_<mode>;
7363       break;
7364     case 1:
7365       insn = gen_vec_extract_hi_<mode>;
7366       break;
7367     default:
7368       gcc_unreachable ();
7369     }
7371   emit_insn (insn (operands[0], operands[1]));
7372   DONE;
7375 (define_insn "vec_extract_lo_<mode><mask_name>"
7376   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,m")
7377         (vec_select:<ssehalfvecmode>
7378           (match_operand:V16FI 1 "nonimmediate_operand" "vm,v")
7379           (parallel [(const_int 0) (const_int 1)
7380                      (const_int 2) (const_int 3)
7381                      (const_int 4) (const_int 5)
7382                      (const_int 6) (const_int 7)])))]
7383   "TARGET_AVX512F
7384    && <mask_mode512bit_condition>
7385    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7387   if (<mask_applied>)
7388     return "vextract<shuffletype>32x8\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7389   else
7390     return "#";
7393 (define_split
7394   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7395         (vec_select:<ssehalfvecmode>
7396           (match_operand:V16FI 1 "nonimmediate_operand")
7397           (parallel [(const_int 0) (const_int 1)
7398             (const_int 2) (const_int 3)
7399             (const_int 4) (const_int 5)
7400             (const_int 6) (const_int 7)])))]
7401   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7402    && reload_completed"
7403    [(const_int 0)]
7405   rtx op1 = operands[1];
7406   if (REG_P (op1))
7407     op1 = gen_rtx_REG (<ssehalfvecmode>mode, REGNO (op1));
7408   else
7409     op1 = gen_lowpart (<ssehalfvecmode>mode, op1);
7410   emit_move_insn (operands[0], op1);
7411   DONE;
7414 (define_insn "vec_extract_lo_<mode><mask_name>"
7415   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,m")
7416         (vec_select:<ssehalfvecmode>
7417           (match_operand:VI8F_256 1 "nonimmediate_operand" "vm,v")
7418           (parallel [(const_int 0) (const_int 1)])))]
7419   "TARGET_AVX
7420    && <mask_avx512vl_condition> && <mask_avx512dq_condition>
7421    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7423   if (<mask_applied>)
7424     return "vextract<shuffletype>64x2\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}";
7425   else
7426     return "#";
7428    [(set_attr "type" "sselog")
7429     (set_attr "prefix_extra" "1")
7430     (set_attr "length_immediate" "1")
7431     (set_attr "memory" "none,store")
7432     (set_attr "prefix" "evex")
7433     (set_attr "mode" "XI")])
7435 (define_split
7436   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7437         (vec_select:<ssehalfvecmode>
7438           (match_operand:VI8F_256 1 "nonimmediate_operand")
7439           (parallel [(const_int 0) (const_int 1)])))]
7440   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7441   && reload_completed"
7442    [(const_int 0)]
7444   rtx op1 = operands[1];
7445   if (REG_P (op1))
7446     op1 = gen_rtx_REG (<ssehalfvecmode>mode, REGNO (op1));
7447   else
7448     op1 = gen_lowpart (<ssehalfvecmode>mode, op1);
7449   emit_move_insn (operands[0], op1);
7450   DONE;
7453 (define_insn "vec_extract_hi_<mode><mask_name>"
7454   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,<store_mask_constraint>")
7455         (vec_select:<ssehalfvecmode>
7456           (match_operand:VI8F_256 1 "register_operand" "v,v")
7457           (parallel [(const_int 2) (const_int 3)])))]
7458   "TARGET_AVX && <mask_avx512vl_condition> && <mask_avx512dq_condition>"
7460   if (TARGET_AVX512VL)
7461   {
7462     if (TARGET_AVX512DQ)
7463       return "vextract<shuffletype>64x2\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}";
7464     else
7465       return "vextract<shuffletype>32x4\t{$0x1, %1, %0|%0, %1, 0x1}";
7466   }
7467   else
7468     return "vextract<i128>\t{$0x1, %1, %0|%0, %1, 0x1}";
7470   [(set_attr "type" "sselog")
7471    (set_attr "prefix_extra" "1")
7472    (set_attr "length_immediate" "1")
7473    (set_attr "memory" "none,store")
7474    (set_attr "prefix" "vex")
7475    (set_attr "mode" "<sseinsnmode>")])
7477 (define_split
7478   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7479         (vec_select:<ssehalfvecmode>
7480           (match_operand:VI4F_256 1 "nonimmediate_operand")
7481           (parallel [(const_int 0) (const_int 1)
7482                      (const_int 2) (const_int 3)])))]
7483   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1])) && reload_completed"
7484    [(const_int 0)]
7486   rtx op1 = operands[1];
7487   if (REG_P (op1))
7488     op1 = gen_rtx_REG (<ssehalfvecmode>mode, REGNO (op1));
7489   else
7490     op1 = gen_lowpart (<ssehalfvecmode>mode, op1);
7491   emit_move_insn (operands[0], op1);
7492   DONE;
7496 (define_insn "vec_extract_lo_<mode><mask_name>"
7497   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7498         (vec_select:<ssehalfvecmode>
7499           (match_operand:VI4F_256 1 "register_operand" "v")
7500           (parallel [(const_int 0) (const_int 1)
7501                      (const_int 2) (const_int 3)])))]
7502   "TARGET_AVX && <mask_avx512vl_condition> && <mask_avx512dq_condition>"
7504   if (<mask_applied>)
7505     return "vextract<shuffletype>32x4\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7506   else
7507     return "#";
7509   [(set_attr "type" "sselog1")
7510    (set_attr "prefix_extra" "1")
7511    (set_attr "length_immediate" "1")
7512    (set_attr "prefix" "evex")
7513    (set_attr "mode" "<sseinsnmode>")])
7515 (define_insn "vec_extract_lo_<mode>_maskm"
7516   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7517         (vec_merge:<ssehalfvecmode>
7518           (vec_select:<ssehalfvecmode>
7519             (match_operand:VI4F_256 1 "register_operand" "v")
7520             (parallel [(const_int 0) (const_int 1)
7521                       (const_int 2) (const_int 3)]))
7522           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7523           (match_operand:QI 3 "register_operand" "k")))]
7524   "TARGET_AVX512VL && TARGET_AVX512F
7525    && rtx_equal_p (operands[2], operands[0])"
7526   "vextract<shuffletype>32x4\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}"
7527   [(set_attr "type" "sselog1")
7528    (set_attr "prefix_extra" "1")
7529    (set_attr "length_immediate" "1")
7530    (set_attr "prefix" "evex")
7531    (set_attr "mode" "<sseinsnmode>")])
7533 (define_insn "vec_extract_hi_<mode>_maskm"
7534   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7535         (vec_merge:<ssehalfvecmode>
7536           (vec_select:<ssehalfvecmode>
7537             (match_operand:VI4F_256 1 "register_operand" "v")
7538             (parallel [(const_int 4) (const_int 5)
7539                       (const_int 6) (const_int 7)]))
7540           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7541           (match_operand:<ssehalfvecmode> 3 "register_operand" "k")))]
7542   "TARGET_AVX512F && TARGET_AVX512VL
7543    && rtx_equal_p (operands[2], operands[0])"
7544   "vextract<shuffletype>32x4\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7545   [(set_attr "type" "sselog1")
7546    (set_attr "length_immediate" "1")
7547    (set_attr "prefix" "evex")
7548    (set_attr "mode" "<sseinsnmode>")])
7550 (define_insn "vec_extract_hi_<mode>_mask"
7551   [(set (match_operand:<ssehalfvecmode> 0 "register_operand" "=v")
7552         (vec_merge:<ssehalfvecmode>
7553           (vec_select:<ssehalfvecmode>
7554             (match_operand:VI4F_256 1 "register_operand" "v")
7555             (parallel [(const_int 4) (const_int 5)
7556                        (const_int 6) (const_int 7)]))
7557           (match_operand:<ssehalfvecmode> 2 "vector_move_operand" "0C")
7558           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
7559   "TARGET_AVX512VL"
7560   "vextract<shuffletype>32x4\t{$0x1, %1, %0%{%3%}%N2|%0%{%3%}%N2, %1, 0x1}"
7561   [(set_attr "type" "sselog1")
7562    (set_attr "length_immediate" "1")
7563    (set_attr "prefix" "evex")
7564    (set_attr "mode" "<sseinsnmode>")])
7566 (define_insn "vec_extract_hi_<mode>"
7567   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=xm, vm")
7568         (vec_select:<ssehalfvecmode>
7569           (match_operand:VI4F_256 1 "register_operand" "x, v")
7570           (parallel [(const_int 4) (const_int 5)
7571                      (const_int 6) (const_int 7)])))]
7572   "TARGET_AVX"
7573   "@
7574     vextract<i128>\t{$0x1, %1, %0|%0, %1, 0x1}
7575     vextract<shuffletype>32x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7576   [(set_attr "isa" "*, avx512vl")
7577    (set_attr "prefix" "vex, evex")
7578    (set_attr "type" "sselog1")
7579    (set_attr "length_immediate" "1")
7580    (set_attr "mode" "<sseinsnmode>")])
7582 (define_insn_and_split "vec_extract_lo_v32hi"
7583   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=v,m")
7584         (vec_select:V16HI
7585           (match_operand:V32HI 1 "nonimmediate_operand" "vm,v")
7586           (parallel [(const_int 0) (const_int 1)
7587                      (const_int 2) (const_int 3)
7588                      (const_int 4) (const_int 5)
7589                      (const_int 6) (const_int 7)
7590                      (const_int 8) (const_int 9)
7591                      (const_int 10) (const_int 11)
7592                      (const_int 12) (const_int 13)
7593                      (const_int 14) (const_int 15)])))]
7594   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7595   "#"
7596   "&& reload_completed"
7597   [(set (match_dup 0) (match_dup 1))]
7599   if (REG_P (operands[1]))
7600     operands[1] = gen_rtx_REG (V16HImode, REGNO (operands[1]));
7601   else
7602     operands[1] = adjust_address (operands[1], V16HImode, 0);
7605 (define_insn "vec_extract_hi_v32hi"
7606   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=v,m")
7607         (vec_select:V16HI
7608           (match_operand:V32HI 1 "register_operand" "v,v")
7609           (parallel [(const_int 16) (const_int 17)
7610                      (const_int 18) (const_int 19)
7611                      (const_int 20) (const_int 21)
7612                      (const_int 22) (const_int 23)
7613                      (const_int 24) (const_int 25)
7614                      (const_int 26) (const_int 27)
7615                      (const_int 28) (const_int 29)
7616                      (const_int 30) (const_int 31)])))]
7617   "TARGET_AVX512F"
7618   "vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7619   [(set_attr "type" "sselog")
7620    (set_attr "prefix_extra" "1")
7621    (set_attr "length_immediate" "1")
7622    (set_attr "memory" "none,store")
7623    (set_attr "prefix" "evex")
7624    (set_attr "mode" "XI")])
7626 (define_insn_and_split "vec_extract_lo_v16hi"
7627   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=x,m")
7628         (vec_select:V8HI
7629           (match_operand:V16HI 1 "nonimmediate_operand" "xm,x")
7630           (parallel [(const_int 0) (const_int 1)
7631                      (const_int 2) (const_int 3)
7632                      (const_int 4) (const_int 5)
7633                      (const_int 6) (const_int 7)])))]
7634   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7635   "#"
7636   "&& reload_completed"
7637   [(set (match_dup 0) (match_dup 1))]
7639   if (REG_P (operands[1]))
7640     operands[1] = gen_rtx_REG (V8HImode, REGNO (operands[1]));
7641   else
7642     operands[1] = adjust_address (operands[1], V8HImode, 0);
7645 (define_insn "vec_extract_hi_v16hi"
7646   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=x,m")
7647         (vec_select:V8HI
7648           (match_operand:V16HI 1 "register_operand" "x,x")
7649           (parallel [(const_int 8) (const_int 9)
7650                      (const_int 10) (const_int 11)
7651                      (const_int 12) (const_int 13)
7652                      (const_int 14) (const_int 15)])))]
7653   "TARGET_AVX"
7654   "vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}"
7655   [(set_attr "type" "sselog")
7656    (set_attr "prefix_extra" "1")
7657    (set_attr "length_immediate" "1")
7658    (set_attr "memory" "none,store")
7659    (set_attr "prefix" "vex")
7660    (set_attr "mode" "OI")])
7662 (define_insn_and_split "vec_extract_lo_v64qi"
7663   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
7664         (vec_select:V32QI
7665           (match_operand:V64QI 1 "nonimmediate_operand" "vm,v")
7666           (parallel [(const_int 0) (const_int 1)
7667                      (const_int 2) (const_int 3)
7668                      (const_int 4) (const_int 5)
7669                      (const_int 6) (const_int 7)
7670                      (const_int 8) (const_int 9)
7671                      (const_int 10) (const_int 11)
7672                      (const_int 12) (const_int 13)
7673                      (const_int 14) (const_int 15)
7674                      (const_int 16) (const_int 17)
7675                      (const_int 18) (const_int 19)
7676                      (const_int 20) (const_int 21)
7677                      (const_int 22) (const_int 23)
7678                      (const_int 24) (const_int 25)
7679                      (const_int 26) (const_int 27)
7680                      (const_int 28) (const_int 29)
7681                      (const_int 30) (const_int 31)])))]
7682   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7683   "#"
7684   "&& reload_completed"
7685   [(set (match_dup 0) (match_dup 1))]
7687   if (REG_P (operands[1]))
7688     operands[1] = gen_rtx_REG (V32QImode, REGNO (operands[1]));
7689   else
7690     operands[1] = adjust_address (operands[1], V32QImode, 0);
7693 (define_insn "vec_extract_hi_v64qi"
7694   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
7695         (vec_select:V32QI
7696           (match_operand:V64QI 1 "register_operand" "v,v")
7697           (parallel [(const_int 32) (const_int 33)
7698                      (const_int 34) (const_int 35)
7699                      (const_int 36) (const_int 37)
7700                      (const_int 38) (const_int 39)
7701                      (const_int 40) (const_int 41)
7702                      (const_int 42) (const_int 43)
7703                      (const_int 44) (const_int 45)
7704                      (const_int 46) (const_int 47)
7705                      (const_int 48) (const_int 49)
7706                      (const_int 50) (const_int 51)
7707                      (const_int 52) (const_int 53)
7708                      (const_int 54) (const_int 55)
7709                      (const_int 56) (const_int 57)
7710                      (const_int 58) (const_int 59)
7711                      (const_int 60) (const_int 61)
7712                      (const_int 62) (const_int 63)])))]
7713   "TARGET_AVX512F"
7714   "vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7715   [(set_attr "type" "sselog")
7716    (set_attr "prefix_extra" "1")
7717    (set_attr "length_immediate" "1")
7718    (set_attr "memory" "none,store")
7719    (set_attr "prefix" "evex")
7720    (set_attr "mode" "XI")])
7722 (define_insn_and_split "vec_extract_lo_v32qi"
7723   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=x,m")
7724         (vec_select:V16QI
7725           (match_operand:V32QI 1 "nonimmediate_operand" "xm,x")
7726           (parallel [(const_int 0) (const_int 1)
7727                      (const_int 2) (const_int 3)
7728                      (const_int 4) (const_int 5)
7729                      (const_int 6) (const_int 7)
7730                      (const_int 8) (const_int 9)
7731                      (const_int 10) (const_int 11)
7732                      (const_int 12) (const_int 13)
7733                      (const_int 14) (const_int 15)])))]
7734   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7735   "#"
7736   "&& reload_completed"
7737   [(set (match_dup 0) (match_dup 1))]
7739   if (REG_P (operands[1]))
7740     operands[1] = gen_rtx_REG (V16QImode, REGNO (operands[1]));
7741   else
7742     operands[1] = adjust_address (operands[1], V16QImode, 0);
7745 (define_insn "vec_extract_hi_v32qi"
7746   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=x,m")
7747         (vec_select:V16QI
7748           (match_operand:V32QI 1 "register_operand" "x,x")
7749           (parallel [(const_int 16) (const_int 17)
7750                      (const_int 18) (const_int 19)
7751                      (const_int 20) (const_int 21)
7752                      (const_int 22) (const_int 23)
7753                      (const_int 24) (const_int 25)
7754                      (const_int 26) (const_int 27)
7755                      (const_int 28) (const_int 29)
7756                      (const_int 30) (const_int 31)])))]
7757   "TARGET_AVX"
7758   "vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}"
7759   [(set_attr "type" "sselog")
7760    (set_attr "prefix_extra" "1")
7761    (set_attr "length_immediate" "1")
7762    (set_attr "memory" "none,store")
7763    (set_attr "prefix" "vex")
7764    (set_attr "mode" "OI")])
7766 ;; Modes handled by vec_extract patterns.
7767 (define_mode_iterator VEC_EXTRACT_MODE
7768   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX") V16QI
7769    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX") V8HI
7770    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
7771    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI
7772    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
7773    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") V2DF])
7775 (define_expand "vec_extract<mode>"
7776   [(match_operand:<ssescalarmode> 0 "register_operand")
7777    (match_operand:VEC_EXTRACT_MODE 1 "register_operand")
7778    (match_operand 2 "const_int_operand")]
7779   "TARGET_SSE"
7781   ix86_expand_vector_extract (false, operands[0], operands[1],
7782                               INTVAL (operands[2]));
7783   DONE;
7786 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7788 ;; Parallel double-precision floating point element swizzling
7790 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7792 (define_insn "<mask_codefor>avx512f_unpckhpd512<mask_name>"
7793   [(set (match_operand:V8DF 0 "register_operand" "=v")
7794         (vec_select:V8DF
7795           (vec_concat:V16DF
7796             (match_operand:V8DF 1 "register_operand" "v")
7797             (match_operand:V8DF 2 "nonimmediate_operand" "vm"))
7798           (parallel [(const_int 1) (const_int 9)
7799                      (const_int 3) (const_int 11)
7800                      (const_int 5) (const_int 13)
7801                      (const_int 7) (const_int 15)])))]
7802   "TARGET_AVX512F"
7803   "vunpckhpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
7804   [(set_attr "type" "sselog")
7805    (set_attr "prefix" "evex")
7806    (set_attr "mode" "V8DF")])
7808 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
7809 (define_insn "avx_unpckhpd256<mask_name>"
7810   [(set (match_operand:V4DF 0 "register_operand" "=v")
7811         (vec_select:V4DF
7812           (vec_concat:V8DF
7813             (match_operand:V4DF 1 "register_operand" "v")
7814             (match_operand:V4DF 2 "nonimmediate_operand" "vm"))
7815           (parallel [(const_int 1) (const_int 5)
7816                      (const_int 3) (const_int 7)])))]
7817   "TARGET_AVX && <mask_avx512vl_condition>"
7818   "vunpckhpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
7819   [(set_attr "type" "sselog")
7820    (set_attr "prefix" "vex")
7821    (set_attr "mode" "V4DF")])
7823 (define_expand "vec_interleave_highv4df"
7824   [(set (match_dup 3)
7825         (vec_select:V4DF
7826           (vec_concat:V8DF
7827             (match_operand:V4DF 1 "register_operand" "x")
7828             (match_operand:V4DF 2 "nonimmediate_operand" "xm"))
7829           (parallel [(const_int 0) (const_int 4)
7830                      (const_int 2) (const_int 6)])))
7831    (set (match_dup 4)
7832         (vec_select:V4DF
7833           (vec_concat:V8DF
7834             (match_dup 1)
7835             (match_dup 2))
7836           (parallel [(const_int 1) (const_int 5)
7837                      (const_int 3) (const_int 7)])))
7838    (set (match_operand:V4DF 0 "register_operand")
7839         (vec_select:V4DF
7840           (vec_concat:V8DF
7841             (match_dup 3)
7842             (match_dup 4))
7843           (parallel [(const_int 2) (const_int 3)
7844                      (const_int 6) (const_int 7)])))]
7845  "TARGET_AVX"
7847   operands[3] = gen_reg_rtx (V4DFmode);
7848   operands[4] = gen_reg_rtx (V4DFmode);
7852 (define_insn "avx512vl_unpckhpd128_mask"
7853   [(set (match_operand:V2DF 0 "register_operand" "=v")
7854         (vec_merge:V2DF
7855           (vec_select:V2DF
7856             (vec_concat:V4DF
7857               (match_operand:V2DF 1 "register_operand" "v")
7858               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
7859             (parallel [(const_int 1) (const_int 3)]))
7860           (match_operand:V2DF 3 "vector_move_operand" "0C")
7861           (match_operand:QI 4 "register_operand" "Yk")))]
7862   "TARGET_AVX512VL"
7863   "vunpckhpd\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
7864   [(set_attr "type" "sselog")
7865    (set_attr "prefix" "evex")
7866    (set_attr "mode" "V2DF")])
7868 (define_expand "vec_interleave_highv2df"
7869   [(set (match_operand:V2DF 0 "register_operand")
7870         (vec_select:V2DF
7871           (vec_concat:V4DF
7872             (match_operand:V2DF 1 "nonimmediate_operand")
7873             (match_operand:V2DF 2 "nonimmediate_operand"))
7874           (parallel [(const_int 1)
7875                      (const_int 3)])))]
7876   "TARGET_SSE2"
7878   if (!ix86_vec_interleave_v2df_operator_ok (operands, 1))
7879     operands[2] = force_reg (V2DFmode, operands[2]);
7882 (define_insn "*vec_interleave_highv2df"
7883   [(set (match_operand:V2DF 0 "nonimmediate_operand"     "=x,x,x,x,x,m")
7884         (vec_select:V2DF
7885           (vec_concat:V4DF
7886             (match_operand:V2DF 1 "nonimmediate_operand" " 0,x,o,o,o,x")
7887             (match_operand:V2DF 2 "nonimmediate_operand" " x,x,1,0,x,0"))
7888           (parallel [(const_int 1)
7889                      (const_int 3)])))]
7890   "TARGET_SSE2 && ix86_vec_interleave_v2df_operator_ok (operands, 1)"
7891   "@
7892    unpckhpd\t{%2, %0|%0, %2}
7893    vunpckhpd\t{%2, %1, %0|%0, %1, %2}
7894    %vmovddup\t{%H1, %0|%0, %H1}
7895    movlpd\t{%H1, %0|%0, %H1}
7896    vmovlpd\t{%H1, %2, %0|%0, %2, %H1}
7897    %vmovhpd\t{%1, %0|%q0, %1}"
7898   [(set_attr "isa" "noavx,avx,sse3,noavx,avx,*")
7899    (set_attr "type" "sselog,sselog,sselog,ssemov,ssemov,ssemov")
7900    (set_attr "ssememalign" "64")
7901    (set_attr "prefix_data16" "*,*,*,1,*,1")
7902    (set_attr "prefix" "orig,vex,maybe_vex,orig,vex,maybe_vex")
7903    (set_attr "mode" "V2DF,V2DF,DF,V1DF,V1DF,V1DF")])
7905 (define_expand "avx512f_movddup512<mask_name>"
7906   [(set (match_operand:V8DF 0 "register_operand")
7907         (vec_select:V8DF
7908           (vec_concat:V16DF
7909             (match_operand:V8DF 1 "nonimmediate_operand")
7910             (match_dup 1))
7911           (parallel [(const_int 0) (const_int 8)
7912                      (const_int 2) (const_int 10)
7913                      (const_int 4) (const_int 12)
7914                      (const_int 6) (const_int 14)])))]
7915   "TARGET_AVX512F")
7917 (define_expand "avx512f_unpcklpd512<mask_name>"
7918   [(set (match_operand:V8DF 0 "register_operand")
7919         (vec_select:V8DF
7920           (vec_concat:V16DF
7921             (match_operand:V8DF 1 "register_operand")
7922             (match_operand:V8DF 2 "nonimmediate_operand"))
7923           (parallel [(const_int 0) (const_int 8)
7924                      (const_int 2) (const_int 10)
7925                      (const_int 4) (const_int 12)
7926                      (const_int 6) (const_int 14)])))]
7927   "TARGET_AVX512F")
7929 (define_insn "*avx512f_unpcklpd512<mask_name>"
7930   [(set (match_operand:V8DF 0 "register_operand" "=v,v")
7931         (vec_select:V8DF
7932           (vec_concat:V16DF
7933             (match_operand:V8DF 1 "nonimmediate_operand" "vm, v")
7934             (match_operand:V8DF 2 "nonimmediate_operand" "1 ,vm"))
7935           (parallel [(const_int 0) (const_int 8)
7936                      (const_int 2) (const_int 10)
7937                      (const_int 4) (const_int 12)
7938                      (const_int 6) (const_int 14)])))]
7939   "TARGET_AVX512F"
7940   "@
7941    vmovddup\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}
7942    vunpcklpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
7943   [(set_attr "type" "sselog")
7944    (set_attr "prefix" "evex")
7945    (set_attr "mode" "V8DF")])
7947 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
7948 (define_expand "avx_movddup256<mask_name>"
7949   [(set (match_operand:V4DF 0 "register_operand")
7950         (vec_select:V4DF
7951           (vec_concat:V8DF
7952             (match_operand:V4DF 1 "nonimmediate_operand")
7953             (match_dup 1))
7954           (parallel [(const_int 0) (const_int 4)
7955                      (const_int 2) (const_int 6)])))]
7956   "TARGET_AVX && <mask_avx512vl_condition>")
7958 (define_expand "avx_unpcklpd256<mask_name>"
7959   [(set (match_operand:V4DF 0 "register_operand")
7960         (vec_select:V4DF
7961           (vec_concat:V8DF
7962             (match_operand:V4DF 1 "register_operand")
7963             (match_operand:V4DF 2 "nonimmediate_operand"))
7964           (parallel [(const_int 0) (const_int 4)
7965                      (const_int 2) (const_int 6)])))]
7966   "TARGET_AVX && <mask_avx512vl_condition>")
7968 (define_insn "*avx_unpcklpd256<mask_name>"
7969   [(set (match_operand:V4DF 0 "register_operand"         "=v,v")
7970         (vec_select:V4DF
7971           (vec_concat:V8DF
7972             (match_operand:V4DF 1 "nonimmediate_operand" " v,m")
7973             (match_operand:V4DF 2 "nonimmediate_operand" "vm,1"))
7974           (parallel [(const_int 0) (const_int 4)
7975                      (const_int 2) (const_int 6)])))]
7976   "TARGET_AVX && <mask_avx512vl_condition>"
7977   "@
7978    vunpcklpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
7979    vmovddup\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}"
7980   [(set_attr "type" "sselog")
7981    (set_attr "prefix" "vex")
7982    (set_attr "mode" "V4DF")])
7984 (define_expand "vec_interleave_lowv4df"
7985   [(set (match_dup 3)
7986         (vec_select:V4DF
7987           (vec_concat:V8DF
7988             (match_operand:V4DF 1 "register_operand" "x")
7989             (match_operand:V4DF 2 "nonimmediate_operand" "xm"))
7990           (parallel [(const_int 0) (const_int 4)
7991                      (const_int 2) (const_int 6)])))
7992    (set (match_dup 4)
7993         (vec_select:V4DF
7994           (vec_concat:V8DF
7995             (match_dup 1)
7996             (match_dup 2))
7997           (parallel [(const_int 1) (const_int 5)
7998                      (const_int 3) (const_int 7)])))
7999    (set (match_operand:V4DF 0 "register_operand")
8000         (vec_select:V4DF
8001           (vec_concat:V8DF
8002             (match_dup 3)
8003             (match_dup 4))
8004           (parallel [(const_int 0) (const_int 1)
8005                      (const_int 4) (const_int 5)])))]
8006  "TARGET_AVX"
8008   operands[3] = gen_reg_rtx (V4DFmode);
8009   operands[4] = gen_reg_rtx (V4DFmode);
8012 (define_insn "avx512vl_unpcklpd128_mask"
8013   [(set (match_operand:V2DF 0 "register_operand" "=v")
8014         (vec_merge:V2DF
8015           (vec_select:V2DF
8016             (vec_concat:V4DF
8017               (match_operand:V2DF 1 "register_operand" "v")
8018               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
8019             (parallel [(const_int 0) (const_int 2)]))
8020           (match_operand:V2DF 3 "vector_move_operand" "0C")
8021           (match_operand:QI 4 "register_operand" "Yk")))]
8022   "TARGET_AVX512VL"
8023   "vunpcklpd\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
8024   [(set_attr "type" "sselog")
8025    (set_attr "prefix" "evex")
8026    (set_attr "mode" "V2DF")])
8028 (define_expand "vec_interleave_lowv2df"
8029   [(set (match_operand:V2DF 0 "register_operand")
8030         (vec_select:V2DF
8031           (vec_concat:V4DF
8032             (match_operand:V2DF 1 "nonimmediate_operand")
8033             (match_operand:V2DF 2 "nonimmediate_operand"))
8034           (parallel [(const_int 0)
8035                      (const_int 2)])))]
8036   "TARGET_SSE2"
8038   if (!ix86_vec_interleave_v2df_operator_ok (operands, 0))
8039     operands[1] = force_reg (V2DFmode, operands[1]);
8042 (define_insn "*vec_interleave_lowv2df"
8043   [(set (match_operand:V2DF 0 "nonimmediate_operand"     "=x,x,x,x,x,o")
8044         (vec_select:V2DF
8045           (vec_concat:V4DF
8046             (match_operand:V2DF 1 "nonimmediate_operand" " 0,x,m,0,x,0")
8047             (match_operand:V2DF 2 "nonimmediate_operand" " x,x,1,m,m,x"))
8048           (parallel [(const_int 0)
8049                      (const_int 2)])))]
8050   "TARGET_SSE2 && ix86_vec_interleave_v2df_operator_ok (operands, 0)"
8051   "@
8052    unpcklpd\t{%2, %0|%0, %2}
8053    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
8054    %vmovddup\t{%1, %0|%0, %q1}
8055    movhpd\t{%2, %0|%0, %q2}
8056    vmovhpd\t{%2, %1, %0|%0, %1, %q2}
8057    %vmovlpd\t{%2, %H0|%H0, %2}"
8058   [(set_attr "isa" "noavx,avx,sse3,noavx,avx,*")
8059    (set_attr "type" "sselog,sselog,sselog,ssemov,ssemov,ssemov")
8060    (set_attr "ssememalign" "64")
8061    (set_attr "prefix_data16" "*,*,*,1,*,1")
8062    (set_attr "prefix" "orig,vex,maybe_vex,orig,vex,maybe_vex")
8063    (set_attr "mode" "V2DF,V2DF,DF,V1DF,V1DF,V1DF")])
8065 (define_split
8066   [(set (match_operand:V2DF 0 "memory_operand")
8067         (vec_select:V2DF
8068           (vec_concat:V4DF
8069             (match_operand:V2DF 1 "register_operand")
8070             (match_dup 1))
8071           (parallel [(const_int 0)
8072                      (const_int 2)])))]
8073   "TARGET_SSE3 && reload_completed"
8074   [(const_int 0)]
8076   rtx low = gen_rtx_REG (DFmode, REGNO (operands[1]));
8077   emit_move_insn (adjust_address (operands[0], DFmode, 0), low);
8078   emit_move_insn (adjust_address (operands[0], DFmode, 8), low);
8079   DONE;
8082 (define_split
8083   [(set (match_operand:V2DF 0 "register_operand")
8084         (vec_select:V2DF
8085           (vec_concat:V4DF
8086             (match_operand:V2DF 1 "memory_operand")
8087             (match_dup 1))
8088           (parallel [(match_operand:SI 2 "const_0_to_1_operand")
8089                      (match_operand:SI 3 "const_int_operand")])))]
8090   "TARGET_SSE3 && INTVAL (operands[2]) + 2 == INTVAL (operands[3])"
8091   [(set (match_dup 0) (vec_duplicate:V2DF (match_dup 1)))]
8093   operands[1] = adjust_address (operands[1], DFmode, INTVAL (operands[2]) * 8);
8096 (define_insn "avx512f_vmscalef<mode><round_name>"
8097   [(set (match_operand:VF_128 0 "register_operand" "=v")
8098         (vec_merge:VF_128
8099           (unspec:VF_128
8100             [(match_operand:VF_128 1 "register_operand" "v")
8101              (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>")]
8102             UNSPEC_SCALEF)
8103           (match_dup 1)
8104           (const_int 1)))]
8105   "TARGET_AVX512F"
8106   "vscalef<ssescalarmodesuffix>\t{<round_op3>%2, %1, %0|%0, %1, %2<round_op3>}"
8107   [(set_attr "prefix" "evex")
8108    (set_attr "mode"  "<ssescalarmode>")])
8110 (define_insn "<avx512>_scalef<mode><mask_name><round_name>"
8111   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8112         (unspec:VF_AVX512VL
8113           [(match_operand:VF_AVX512VL 1 "register_operand" "v")
8114            (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")]
8115           UNSPEC_SCALEF))]
8116   "TARGET_AVX512F"
8117   "vscalef<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
8118   [(set_attr "prefix" "evex")
8119    (set_attr "mode"  "<MODE>")])
8121 (define_expand "<avx512>_vternlog<mode>_maskz"
8122   [(match_operand:VI48_AVX512VL 0 "register_operand")
8123    (match_operand:VI48_AVX512VL 1 "register_operand")
8124    (match_operand:VI48_AVX512VL 2 "register_operand")
8125    (match_operand:VI48_AVX512VL 3 "nonimmediate_operand")
8126    (match_operand:SI 4 "const_0_to_255_operand")
8127    (match_operand:<avx512fmaskmode> 5 "register_operand")]
8128   "TARGET_AVX512F"
8130   emit_insn (gen_<avx512>_vternlog<mode>_maskz_1 (
8131     operands[0], operands[1], operands[2], operands[3],
8132     operands[4], CONST0_RTX (<MODE>mode), operands[5]));
8133   DONE;
8136 (define_insn "<avx512>_vternlog<mode><sd_maskz_name>"
8137   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
8138         (unspec:VI48_AVX512VL
8139           [(match_operand:VI48_AVX512VL 1 "register_operand" "0")
8140            (match_operand:VI48_AVX512VL 2 "register_operand" "v")
8141            (match_operand:VI48_AVX512VL 3 "nonimmediate_operand" "vm")
8142            (match_operand:SI 4 "const_0_to_255_operand")]
8143           UNSPEC_VTERNLOG))]
8144   "TARGET_AVX512F"
8145   "vpternlog<ssemodesuffix>\t{%4, %3, %2, %0<sd_mask_op5>|%0<sd_mask_op5>, %2, %3, %4}"
8146   [(set_attr "type" "sselog")
8147    (set_attr "prefix" "evex")
8148    (set_attr "mode" "<sseinsnmode>")])
8150 (define_insn "<avx512>_vternlog<mode>_mask"
8151   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
8152         (vec_merge:VI48_AVX512VL
8153           (unspec:VI48_AVX512VL
8154             [(match_operand:VI48_AVX512VL 1 "register_operand" "0")
8155              (match_operand:VI48_AVX512VL 2 "register_operand" "v")
8156              (match_operand:VI48_AVX512VL 3 "nonimmediate_operand" "vm")
8157              (match_operand:SI 4 "const_0_to_255_operand")]
8158             UNSPEC_VTERNLOG)
8159           (match_dup 1)
8160           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
8161   "TARGET_AVX512F"
8162   "vpternlog<ssemodesuffix>\t{%4, %3, %2, %0%{%5%}|%0%{%5%}, %2, %3, %4}"
8163   [(set_attr "type" "sselog")
8164    (set_attr "prefix" "evex")
8165    (set_attr "mode" "<sseinsnmode>")])
8167 (define_insn "<avx512>_getexp<mode><mask_name><round_saeonly_name>"
8168   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8169         (unspec:VF_AVX512VL [(match_operand:VF_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
8170                         UNSPEC_GETEXP))]
8171    "TARGET_AVX512F"
8172    "vgetexp<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}";
8173     [(set_attr "prefix" "evex")
8174      (set_attr "mode" "<MODE>")])
8176 (define_insn "avx512f_sgetexp<mode><round_saeonly_name>"
8177   [(set (match_operand:VF_128 0 "register_operand" "=v")
8178         (vec_merge:VF_128
8179           (unspec:VF_128
8180             [(match_operand:VF_128 1 "register_operand" "v")
8181              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
8182             UNSPEC_GETEXP)
8183           (match_dup 1)
8184           (const_int 1)))]
8185    "TARGET_AVX512F"
8186    "vgetexp<ssescalarmodesuffix>\t{<round_saeonly_op3>%2, %1, %0|%0, %1, %2<round_saeonly_op3>}";
8187     [(set_attr "prefix" "evex")
8188      (set_attr "mode" "<ssescalarmode>")])
8190 (define_insn "<mask_codefor><avx512>_align<mode><mask_name>"
8191   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
8192         (unspec:VI48_AVX512VL [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
8193                                (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")
8194                                (match_operand:SI 3 "const_0_to_255_operand")]
8195                               UNSPEC_ALIGN))]
8196   "TARGET_AVX512F"
8197   "valign<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}";
8198   [(set_attr "prefix" "evex")
8199    (set_attr "mode" "<sseinsnmode>")])
8201 (define_expand "avx512f_shufps512_mask"
8202   [(match_operand:V16SF 0 "register_operand")
8203    (match_operand:V16SF 1 "register_operand")
8204    (match_operand:V16SF 2 "nonimmediate_operand")
8205    (match_operand:SI 3 "const_0_to_255_operand")
8206    (match_operand:V16SF 4 "register_operand")
8207    (match_operand:HI 5 "register_operand")]
8208   "TARGET_AVX512F"
8210   int mask = INTVAL (operands[3]);
8211   emit_insn (gen_avx512f_shufps512_1_mask (operands[0], operands[1], operands[2],
8212                                           GEN_INT ((mask >> 0) & 3),
8213                                           GEN_INT ((mask >> 2) & 3),
8214                                           GEN_INT (((mask >> 4) & 3) + 16),
8215                                           GEN_INT (((mask >> 6) & 3) + 16),
8216                                           GEN_INT (((mask >> 0) & 3) + 4),
8217                                           GEN_INT (((mask >> 2) & 3) + 4),
8218                                           GEN_INT (((mask >> 4) & 3) + 20),
8219                                           GEN_INT (((mask >> 6) & 3) + 20),
8220                                           GEN_INT (((mask >> 0) & 3) + 8),
8221                                           GEN_INT (((mask >> 2) & 3) + 8),
8222                                           GEN_INT (((mask >> 4) & 3) + 24),
8223                                           GEN_INT (((mask >> 6) & 3) + 24),
8224                                           GEN_INT (((mask >> 0) & 3) + 12),
8225                                           GEN_INT (((mask >> 2) & 3) + 12),
8226                                           GEN_INT (((mask >> 4) & 3) + 28),
8227                                           GEN_INT (((mask >> 6) & 3) + 28),
8228                                           operands[4], operands[5]));
8229   DONE;
8233 (define_expand "<avx512>_fixupimm<mode>_maskz<round_saeonly_expand_name>"
8234   [(match_operand:VF_AVX512VL 0 "register_operand")
8235    (match_operand:VF_AVX512VL 1 "register_operand")
8236    (match_operand:VF_AVX512VL 2 "register_operand")
8237    (match_operand:<sseintvecmode> 3 "<round_saeonly_expand_nimm_predicate>")
8238    (match_operand:SI 4 "const_0_to_255_operand")
8239    (match_operand:<avx512fmaskmode> 5 "register_operand")]
8240   "TARGET_AVX512F"
8242   emit_insn (gen_<avx512>_fixupimm<mode>_maskz_1<round_saeonly_expand_name> (
8243         operands[0], operands[1], operands[2], operands[3],
8244         operands[4], CONST0_RTX (<MODE>mode), operands[5]
8245         <round_saeonly_expand_operand6>));
8246   DONE;
8249 (define_insn "<avx512>_fixupimm<mode><sd_maskz_name><round_saeonly_name>"
8250   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8251         (unspec:VF_AVX512VL
8252           [(match_operand:VF_AVX512VL 1 "register_operand" "0")
8253            (match_operand:VF_AVX512VL 2 "register_operand" "v")
8254            (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "<round_saeonly_constraint>")
8255            (match_operand:SI 4 "const_0_to_255_operand")]
8256            UNSPEC_FIXUPIMM))]
8257   "TARGET_AVX512F"
8258   "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}";
8259   [(set_attr "prefix" "evex")
8260    (set_attr "mode" "<MODE>")])
8262 (define_insn "<avx512>_fixupimm<mode>_mask<round_saeonly_name>"
8263   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8264         (vec_merge:VF_AVX512VL
8265           (unspec:VF_AVX512VL
8266             [(match_operand:VF_AVX512VL 1 "register_operand" "0")
8267              (match_operand:VF_AVX512VL 2 "register_operand" "v")
8268              (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "<round_saeonly_constraint>")
8269              (match_operand:SI 4 "const_0_to_255_operand")]
8270              UNSPEC_FIXUPIMM)
8271           (match_dup 1)
8272           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
8273   "TARGET_AVX512F"
8274   "vfixupimm<ssemodesuffix>\t{%4, <round_saeonly_op6>%3, %2, %0%{%5%}|%0%{%5%}, %2, %3<round_saeonly_op6>, %4}";
8275   [(set_attr "prefix" "evex")
8276    (set_attr "mode" "<MODE>")])
8278 (define_expand "avx512f_sfixupimm<mode>_maskz<round_saeonly_expand_name>"
8279   [(match_operand:VF_128 0 "register_operand")
8280    (match_operand:VF_128 1 "register_operand")
8281    (match_operand:VF_128 2 "register_operand")
8282    (match_operand:<sseintvecmode> 3 "<round_saeonly_expand_nimm_predicate>")
8283    (match_operand:SI 4 "const_0_to_255_operand")
8284    (match_operand:<avx512fmaskmode> 5 "register_operand")]
8285   "TARGET_AVX512F"
8287   emit_insn (gen_avx512f_sfixupimm<mode>_maskz_1<round_saeonly_expand_name> (
8288         operands[0], operands[1], operands[2], operands[3],
8289         operands[4], CONST0_RTX (<MODE>mode), operands[5]
8290         <round_saeonly_expand_operand6>));
8291   DONE;
8294 (define_insn "avx512f_sfixupimm<mode><sd_maskz_name><round_saeonly_name>"
8295   [(set (match_operand:VF_128 0 "register_operand" "=v")
8296         (vec_merge:VF_128
8297           (unspec:VF_128
8298             [(match_operand:VF_128 1 "register_operand" "0")
8299              (match_operand:VF_128 2 "register_operand" "v")
8300              (match_operand:<sseintvecmode> 3 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8301              (match_operand:SI 4 "const_0_to_255_operand")]
8302             UNSPEC_FIXUPIMM)
8303           (match_dup 1)
8304           (const_int 1)))]
8305    "TARGET_AVX512F"
8306    "vfixupimm<ssescalarmodesuffix>\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}";
8307    [(set_attr "prefix" "evex")
8308    (set_attr "mode" "<ssescalarmode>")])
8310 (define_insn "avx512f_sfixupimm<mode>_mask<round_saeonly_name>"
8311   [(set (match_operand:VF_128 0 "register_operand" "=v")
8312         (vec_merge:VF_128
8313           (vec_merge:VF_128
8314             (unspec:VF_128
8315                [(match_operand:VF_128 1 "register_operand" "0")
8316                 (match_operand:VF_128 2 "register_operand" "v")
8317                 (match_operand:<sseintvecmode> 3 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8318                 (match_operand:SI 4 "const_0_to_255_operand")]
8319                UNSPEC_FIXUPIMM)
8320             (match_dup 1)
8321             (const_int 1))
8322           (match_dup 1)
8323           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
8324   "TARGET_AVX512F"
8325   "vfixupimm<ssescalarmodesuffix>\t{%4, <round_saeonly_op6>%3, %2, %0%{%5%}|%0%{%5%}, %2, %3<round_saeonly_op6>, %4}";
8326   [(set_attr "prefix" "evex")
8327    (set_attr "mode" "<ssescalarmode>")])
8329 (define_insn "<avx512>_rndscale<mode><mask_name><round_saeonly_name>"
8330   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8331         (unspec:VF_AVX512VL
8332           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "<round_saeonly_constraint>")
8333            (match_operand:SI 2 "const_0_to_255_operand")]
8334           UNSPEC_ROUND))]
8335   "TARGET_AVX512F"
8336   "vrndscale<ssemodesuffix>\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}"
8337   [(set_attr "length_immediate" "1")
8338    (set_attr "prefix" "evex")
8339    (set_attr "mode" "<MODE>")])
8341 (define_insn "avx512f_rndscale<mode><round_saeonly_name>"
8342   [(set (match_operand:VF_128 0 "register_operand" "=v")
8343         (vec_merge:VF_128
8344           (unspec:VF_128
8345             [(match_operand:VF_128 1 "register_operand" "v")
8346              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8347              (match_operand:SI 3 "const_0_to_255_operand")]
8348             UNSPEC_ROUND)
8349           (match_dup 1)
8350           (const_int 1)))]
8351   "TARGET_AVX512F"
8352   "vrndscale<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %2<round_saeonly_op4>, %3}"
8353   [(set_attr "length_immediate" "1")
8354    (set_attr "prefix" "evex")
8355    (set_attr "mode" "<MODE>")])
8357 ;; One bit in mask selects 2 elements.
8358 (define_insn "avx512f_shufps512_1<mask_name>"
8359   [(set (match_operand:V16SF 0 "register_operand" "=v")
8360         (vec_select:V16SF
8361           (vec_concat:V32SF
8362             (match_operand:V16SF 1 "register_operand" "v")
8363             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
8364           (parallel [(match_operand 3  "const_0_to_3_operand")
8365                      (match_operand 4  "const_0_to_3_operand")
8366                      (match_operand 5  "const_16_to_19_operand")
8367                      (match_operand 6  "const_16_to_19_operand")
8368                      (match_operand 7  "const_4_to_7_operand")
8369                      (match_operand 8  "const_4_to_7_operand")
8370                      (match_operand 9  "const_20_to_23_operand")
8371                      (match_operand 10  "const_20_to_23_operand")
8372                      (match_operand 11  "const_8_to_11_operand")
8373                      (match_operand 12  "const_8_to_11_operand")
8374                      (match_operand 13  "const_24_to_27_operand")
8375                      (match_operand 14  "const_24_to_27_operand")
8376                      (match_operand 15  "const_12_to_15_operand")
8377                      (match_operand 16  "const_12_to_15_operand")
8378                      (match_operand 17  "const_28_to_31_operand")
8379                      (match_operand 18  "const_28_to_31_operand")])))]
8380   "TARGET_AVX512F
8381    && (INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
8382        && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
8383        && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4)
8384        && INTVAL (operands[6]) == (INTVAL (operands[10]) - 4)
8385        && INTVAL (operands[3]) == (INTVAL (operands[11]) - 8)
8386        && INTVAL (operands[4]) == (INTVAL (operands[12]) - 8)
8387        && INTVAL (operands[5]) == (INTVAL (operands[13]) - 8)
8388        && INTVAL (operands[6]) == (INTVAL (operands[14]) - 8)
8389        && INTVAL (operands[3]) == (INTVAL (operands[15]) - 12)
8390        && INTVAL (operands[4]) == (INTVAL (operands[16]) - 12)
8391        && INTVAL (operands[5]) == (INTVAL (operands[17]) - 12)
8392        && INTVAL (operands[6]) == (INTVAL (operands[18]) - 12))"
8394   int mask;
8395   mask = INTVAL (operands[3]);
8396   mask |= INTVAL (operands[4]) << 2;
8397   mask |= (INTVAL (operands[5]) - 16) << 4;
8398   mask |= (INTVAL (operands[6]) - 16) << 6;
8399   operands[3] = GEN_INT (mask);
8401   return "vshufps\t{%3, %2, %1, %0<mask_operand19>|%0<mask_operand19>, %1, %2, %3}";
8403   [(set_attr "type" "sselog")
8404    (set_attr "length_immediate" "1")
8405    (set_attr "prefix" "evex")
8406    (set_attr "mode" "V16SF")])
8408 (define_expand "avx512f_shufpd512_mask"
8409   [(match_operand:V8DF 0 "register_operand")
8410    (match_operand:V8DF 1 "register_operand")
8411    (match_operand:V8DF 2 "nonimmediate_operand")
8412    (match_operand:SI 3 "const_0_to_255_operand")
8413    (match_operand:V8DF 4 "register_operand")
8414    (match_operand:QI 5 "register_operand")]
8415   "TARGET_AVX512F"
8417   int mask = INTVAL (operands[3]);
8418   emit_insn (gen_avx512f_shufpd512_1_mask (operands[0], operands[1], operands[2],
8419                                         GEN_INT (mask & 1),
8420                                         GEN_INT (mask & 2 ? 9 : 8),
8421                                         GEN_INT (mask & 4 ? 3 : 2),
8422                                         GEN_INT (mask & 8 ? 11 : 10),
8423                                         GEN_INT (mask & 16 ? 5 : 4),
8424                                         GEN_INT (mask & 32 ? 13 : 12),
8425                                         GEN_INT (mask & 64 ? 7 : 6),
8426                                         GEN_INT (mask & 128 ? 15 : 14),
8427                                         operands[4], operands[5]));
8428   DONE;
8431 (define_insn "avx512f_shufpd512_1<mask_name>"
8432   [(set (match_operand:V8DF 0 "register_operand" "=v")
8433         (vec_select:V8DF
8434           (vec_concat:V16DF
8435             (match_operand:V8DF 1 "register_operand" "v")
8436             (match_operand:V8DF 2 "nonimmediate_operand" "vm"))
8437           (parallel [(match_operand 3 "const_0_to_1_operand")
8438                      (match_operand 4 "const_8_to_9_operand")
8439                      (match_operand 5 "const_2_to_3_operand")
8440                      (match_operand 6 "const_10_to_11_operand")
8441                      (match_operand 7 "const_4_to_5_operand")
8442                      (match_operand 8 "const_12_to_13_operand")
8443                      (match_operand 9 "const_6_to_7_operand")
8444                      (match_operand 10 "const_14_to_15_operand")])))]
8445   "TARGET_AVX512F"
8447   int mask;
8448   mask = INTVAL (operands[3]);
8449   mask |= (INTVAL (operands[4]) - 8) << 1;
8450   mask |= (INTVAL (operands[5]) - 2) << 2;
8451   mask |= (INTVAL (operands[6]) - 10) << 3;
8452   mask |= (INTVAL (operands[7]) - 4) << 4;
8453   mask |= (INTVAL (operands[8]) - 12) << 5;
8454   mask |= (INTVAL (operands[9]) - 6) << 6;
8455   mask |= (INTVAL (operands[10]) - 14) << 7;
8456   operands[3] = GEN_INT (mask);
8458   return "vshufpd\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
8460   [(set_attr "type" "sselog")
8461    (set_attr "length_immediate" "1")
8462    (set_attr "prefix" "evex")
8463    (set_attr "mode" "V8DF")])
8465 (define_expand "avx_shufpd256<mask_expand4_name>"
8466   [(match_operand:V4DF 0 "register_operand")
8467    (match_operand:V4DF 1 "register_operand")
8468    (match_operand:V4DF 2 "nonimmediate_operand")
8469    (match_operand:SI 3 "const_int_operand")]
8470   "TARGET_AVX"
8472   int mask = INTVAL (operands[3]);
8473   emit_insn (gen_avx_shufpd256_1<mask_expand4_name> (operands[0],
8474                                                      operands[1],
8475                                                      operands[2],
8476                                                      GEN_INT (mask & 1),
8477                                                      GEN_INT (mask & 2 ? 5 : 4),
8478                                                      GEN_INT (mask & 4 ? 3 : 2),
8479                                                      GEN_INT (mask & 8 ? 7 : 6)
8480                                                      <mask_expand4_args>));
8481   DONE;
8484 (define_insn "avx_shufpd256_1<mask_name>"
8485   [(set (match_operand:V4DF 0 "register_operand" "=v")
8486         (vec_select:V4DF
8487           (vec_concat:V8DF
8488             (match_operand:V4DF 1 "register_operand" "v")
8489             (match_operand:V4DF 2 "nonimmediate_operand" "vm"))
8490           (parallel [(match_operand 3 "const_0_to_1_operand")
8491                      (match_operand 4 "const_4_to_5_operand")
8492                      (match_operand 5 "const_2_to_3_operand")
8493                      (match_operand 6 "const_6_to_7_operand")])))]
8494   "TARGET_AVX && <mask_avx512vl_condition>"
8496   int mask;
8497   mask = INTVAL (operands[3]);
8498   mask |= (INTVAL (operands[4]) - 4) << 1;
8499   mask |= (INTVAL (operands[5]) - 2) << 2;
8500   mask |= (INTVAL (operands[6]) - 6) << 3;
8501   operands[3] = GEN_INT (mask);
8503   return "vshufpd\t{%3, %2, %1, %0<mask_operand7>|%0<mask_operand7>, %1, %2, %3}";
8505   [(set_attr "type" "sseshuf")
8506    (set_attr "length_immediate" "1")
8507    (set_attr "prefix" "vex")
8508    (set_attr "mode" "V4DF")])
8510 (define_expand "sse2_shufpd<mask_expand4_name>"
8511   [(match_operand:V2DF 0 "register_operand")
8512    (match_operand:V2DF 1 "register_operand")
8513    (match_operand:V2DF 2 "vector_operand")
8514    (match_operand:SI 3 "const_int_operand")]
8515   "TARGET_SSE2"
8517   int mask = INTVAL (operands[3]);
8518   emit_insn (gen_sse2_shufpd_v2df<mask_expand4_name> (operands[0], operands[1],
8519                                                       operands[2], GEN_INT (mask & 1),
8520                                                       GEN_INT (mask & 2 ? 3 : 2)
8521                                                       <mask_expand4_args>));
8522   DONE;
8525 (define_insn "sse2_shufpd_v2df_mask"
8526   [(set (match_operand:V2DF 0 "register_operand" "=v")
8527     (vec_merge:V2DF
8528           (vec_select:V2DF
8529             (vec_concat:V4DF
8530               (match_operand:V2DF 1 "register_operand" "v")
8531               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
8532             (parallel [(match_operand 3 "const_0_to_1_operand")
8533                            (match_operand 4 "const_2_to_3_operand")]))
8534       (match_operand:V2DF 5 "vector_move_operand" "0C")
8535       (match_operand:QI 6 "register_operand" "Yk")))]
8536   "TARGET_AVX512VL"
8538   int mask;
8539   mask = INTVAL (operands[3]);
8540   mask |= (INTVAL (operands[4]) - 2) << 1;
8541   operands[3] = GEN_INT (mask);
8543   return "vshufpd\t{%3, %2, %1, %0%{%6%}%N5|%0%{6%}%N5, %1, %2, %3}";
8545   [(set_attr "type" "sseshuf")
8546    (set_attr "length_immediate" "1")
8547    (set_attr "prefix" "evex")
8548    (set_attr "mode" "V2DF")])
8550 ;; punpcklqdq and punpckhqdq are shorter than shufpd.
8551 (define_insn "avx2_interleave_highv4di<mask_name>"
8552   [(set (match_operand:V4DI 0 "register_operand" "=v")
8553         (vec_select:V4DI
8554           (vec_concat:V8DI
8555             (match_operand:V4DI 1 "register_operand" "v")
8556             (match_operand:V4DI 2 "nonimmediate_operand" "vm"))
8557           (parallel [(const_int 1)
8558                      (const_int 5)
8559                      (const_int 3)
8560                      (const_int 7)])))]
8561   "TARGET_AVX2 && <mask_avx512vl_condition>"
8562   "vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8563   [(set_attr "type" "sselog")
8564    (set_attr "prefix" "vex")
8565    (set_attr "mode" "OI")])
8567 (define_insn "<mask_codefor>avx512f_interleave_highv8di<mask_name>"
8568   [(set (match_operand:V8DI 0 "register_operand" "=v")
8569         (vec_select:V8DI
8570           (vec_concat:V16DI
8571             (match_operand:V8DI 1 "register_operand" "v")
8572             (match_operand:V8DI 2 "nonimmediate_operand" "vm"))
8573           (parallel [(const_int 1) (const_int 9)
8574                      (const_int 3) (const_int 11)
8575                      (const_int 5) (const_int 13)
8576                      (const_int 7) (const_int 15)])))]
8577   "TARGET_AVX512F"
8578   "vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8579   [(set_attr "type" "sselog")
8580    (set_attr "prefix" "evex")
8581    (set_attr "mode" "XI")])
8583 (define_insn "vec_interleave_highv2di<mask_name>"
8584   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
8585         (vec_select:V2DI
8586           (vec_concat:V4DI
8587             (match_operand:V2DI 1 "register_operand" "0,v")
8588             (match_operand:V2DI 2 "vector_operand" "xBm,vm"))
8589           (parallel [(const_int 1)
8590                      (const_int 3)])))]
8591   "TARGET_SSE2 && <mask_avx512vl_condition>"
8592   "@
8593    punpckhqdq\t{%2, %0|%0, %2}
8594    vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8595   [(set_attr "isa" "noavx,avx")
8596    (set_attr "type" "sselog")
8597    (set_attr "prefix_data16" "1,*")
8598    (set_attr "prefix" "orig,<mask_prefix>")
8599    (set_attr "mode" "TI")])
8601 (define_insn "avx2_interleave_lowv4di<mask_name>"
8602   [(set (match_operand:V4DI 0 "register_operand" "=v")
8603         (vec_select:V4DI
8604           (vec_concat:V8DI
8605             (match_operand:V4DI 1 "register_operand" "v")
8606             (match_operand:V4DI 2 "nonimmediate_operand" "vm"))
8607           (parallel [(const_int 0)
8608                      (const_int 4)
8609                      (const_int 2)
8610                      (const_int 6)])))]
8611   "TARGET_AVX2 && <mask_avx512vl_condition>"
8612   "vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8613   [(set_attr "type" "sselog")
8614    (set_attr "prefix" "vex")
8615    (set_attr "mode" "OI")])
8617 (define_insn "<mask_codefor>avx512f_interleave_lowv8di<mask_name>"
8618   [(set (match_operand:V8DI 0 "register_operand" "=v")
8619         (vec_select:V8DI
8620           (vec_concat:V16DI
8621             (match_operand:V8DI 1 "register_operand" "v")
8622             (match_operand:V8DI 2 "nonimmediate_operand" "vm"))
8623           (parallel [(const_int 0) (const_int 8)
8624                      (const_int 2) (const_int 10)
8625                      (const_int 4) (const_int 12)
8626                      (const_int 6) (const_int 14)])))]
8627   "TARGET_AVX512F"
8628   "vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8629   [(set_attr "type" "sselog")
8630    (set_attr "prefix" "evex")
8631    (set_attr "mode" "XI")])
8633 (define_insn "vec_interleave_lowv2di<mask_name>"
8634   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
8635         (vec_select:V2DI
8636           (vec_concat:V4DI
8637             (match_operand:V2DI 1 "register_operand" "0,v")
8638             (match_operand:V2DI 2 "vector_operand" "xBm,vm"))
8639           (parallel [(const_int 0)
8640                      (const_int 2)])))]
8641   "TARGET_SSE2 && <mask_avx512vl_condition>"
8642   "@
8643    punpcklqdq\t{%2, %0|%0, %2}
8644    vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8645   [(set_attr "isa" "noavx,avx")
8646    (set_attr "type" "sselog")
8647    (set_attr "prefix_data16" "1,*")
8648    (set_attr "prefix" "orig,vex")
8649    (set_attr "mode" "TI")])
8651 (define_insn "sse2_shufpd_<mode>"
8652   [(set (match_operand:VI8F_128 0 "register_operand" "=x,x")
8653         (vec_select:VI8F_128
8654           (vec_concat:<ssedoublevecmode>
8655             (match_operand:VI8F_128 1 "register_operand" "0,x")
8656             (match_operand:VI8F_128 2 "vector_operand" "xBm,xm"))
8657           (parallel [(match_operand 3 "const_0_to_1_operand")
8658                      (match_operand 4 "const_2_to_3_operand")])))]
8659   "TARGET_SSE2"
8661   int mask;
8662   mask = INTVAL (operands[3]);
8663   mask |= (INTVAL (operands[4]) - 2) << 1;
8664   operands[3] = GEN_INT (mask);
8666   switch (which_alternative)
8667     {
8668     case 0:
8669       return "shufpd\t{%3, %2, %0|%0, %2, %3}";
8670     case 1:
8671       return "vshufpd\t{%3, %2, %1, %0|%0, %1, %2, %3}";
8672     default:
8673       gcc_unreachable ();
8674     }
8676   [(set_attr "isa" "noavx,avx")
8677    (set_attr "type" "sseshuf")
8678    (set_attr "length_immediate" "1")
8679    (set_attr "prefix" "orig,vex")
8680    (set_attr "mode" "V2DF")])
8682 ;; Avoid combining registers from different units in a single alternative,
8683 ;; see comment above inline_secondary_memory_needed function in i386.c
8684 (define_insn "sse2_storehpd"
8685   [(set (match_operand:DF 0 "nonimmediate_operand"     "=m,x,x,x,*f,r")
8686         (vec_select:DF
8687           (match_operand:V2DF 1 "nonimmediate_operand" " x,0,x,o,o,o")
8688           (parallel [(const_int 1)])))]
8689   "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8690   "@
8691    %vmovhpd\t{%1, %0|%0, %1}
8692    unpckhpd\t%0, %0
8693    vunpckhpd\t{%d1, %0|%0, %d1}
8694    #
8695    #
8696    #"
8697   [(set_attr "isa" "*,noavx,avx,*,*,*")
8698    (set_attr "type" "ssemov,sselog1,sselog1,ssemov,fmov,imov")
8699    (set (attr "prefix_data16")
8700      (if_then_else
8701        (and (eq_attr "alternative" "0")
8702             (not (match_test "TARGET_AVX")))
8703        (const_string "1")
8704        (const_string "*")))
8705    (set_attr "prefix" "maybe_vex,orig,vex,*,*,*")
8706    (set_attr "mode" "V1DF,V1DF,V2DF,DF,DF,DF")])
8708 (define_split
8709   [(set (match_operand:DF 0 "register_operand")
8710         (vec_select:DF
8711           (match_operand:V2DF 1 "memory_operand")
8712           (parallel [(const_int 1)])))]
8713   "TARGET_SSE2 && reload_completed"
8714   [(set (match_dup 0) (match_dup 1))]
8715   "operands[1] = adjust_address (operands[1], DFmode, 8);")
8717 (define_insn "*vec_extractv2df_1_sse"
8718   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x")
8719         (vec_select:DF
8720           (match_operand:V2DF 1 "nonimmediate_operand" "x,x,o")
8721           (parallel [(const_int 1)])))]
8722   "!TARGET_SSE2 && TARGET_SSE
8723    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8724   "@
8725    movhps\t{%1, %0|%q0, %1}
8726    movhlps\t{%1, %0|%0, %1}
8727    movlps\t{%H1, %0|%0, %H1}"
8728   [(set_attr "type" "ssemov")
8729    (set_attr "ssememalign" "64")
8730    (set_attr "mode" "V2SF,V4SF,V2SF")])
8732 ;; Avoid combining registers from different units in a single alternative,
8733 ;; see comment above inline_secondary_memory_needed function in i386.c
8734 (define_insn "sse2_storelpd"
8735   [(set (match_operand:DF 0 "nonimmediate_operand"     "=m,x,x,*f,r")
8736         (vec_select:DF
8737           (match_operand:V2DF 1 "nonimmediate_operand" " x,x,m,m,m")
8738           (parallel [(const_int 0)])))]
8739   "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8740   "@
8741    %vmovlpd\t{%1, %0|%0, %1}
8742    #
8743    #
8744    #
8745    #"
8746   [(set_attr "type" "ssemov,ssemov,ssemov,fmov,imov")
8747    (set_attr "prefix_data16" "1,*,*,*,*")
8748    (set_attr "prefix" "maybe_vex")
8749    (set_attr "mode" "V1DF,DF,DF,DF,DF")])
8751 (define_split
8752   [(set (match_operand:DF 0 "register_operand")
8753         (vec_select:DF
8754           (match_operand:V2DF 1 "nonimmediate_operand")
8755           (parallel [(const_int 0)])))]
8756   "TARGET_SSE2 && reload_completed"
8757   [(set (match_dup 0) (match_dup 1))]
8759   if (REG_P (operands[1]))
8760     operands[1] = gen_rtx_REG (DFmode, REGNO (operands[1]));
8761   else
8762     operands[1] = adjust_address (operands[1], DFmode, 0);
8765 (define_insn "*vec_extractv2df_0_sse"
8766   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x")
8767         (vec_select:DF
8768           (match_operand:V2DF 1 "nonimmediate_operand" "x,x,m")
8769           (parallel [(const_int 0)])))]
8770   "!TARGET_SSE2 && TARGET_SSE
8771    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8772   "@
8773    movlps\t{%1, %0|%0, %1}
8774    movaps\t{%1, %0|%0, %1}
8775    movlps\t{%1, %0|%0, %q1}"
8776   [(set_attr "type" "ssemov")
8777    (set_attr "mode" "V2SF,V4SF,V2SF")])
8779 (define_expand "sse2_loadhpd_exp"
8780   [(set (match_operand:V2DF 0 "nonimmediate_operand")
8781         (vec_concat:V2DF
8782           (vec_select:DF
8783             (match_operand:V2DF 1 "nonimmediate_operand")
8784             (parallel [(const_int 0)]))
8785           (match_operand:DF 2 "nonimmediate_operand")))]
8786   "TARGET_SSE2"
8788   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V2DFmode, operands);
8790   emit_insn (gen_sse2_loadhpd (dst, operands[1], operands[2]));
8792   /* Fix up the destination if needed.  */
8793   if (dst != operands[0])
8794     emit_move_insn (operands[0], dst);
8796   DONE;
8799 ;; Avoid combining registers from different units in a single alternative,
8800 ;; see comment above inline_secondary_memory_needed function in i386.c
8801 (define_insn "sse2_loadhpd"
8802   [(set (match_operand:V2DF 0 "nonimmediate_operand"
8803           "=x,x,x,x,o,o ,o")
8804         (vec_concat:V2DF
8805           (vec_select:DF
8806             (match_operand:V2DF 1 "nonimmediate_operand"
8807           " 0,x,0,x,0,0 ,0")
8808             (parallel [(const_int 0)]))
8809           (match_operand:DF 2 "nonimmediate_operand"
8810           " m,m,x,x,x,*f,r")))]
8811   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
8812   "@
8813    movhpd\t{%2, %0|%0, %2}
8814    vmovhpd\t{%2, %1, %0|%0, %1, %2}
8815    unpcklpd\t{%2, %0|%0, %2}
8816    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
8817    #
8818    #
8819    #"
8820   [(set_attr "isa" "noavx,avx,noavx,avx,*,*,*")
8821    (set_attr "type" "ssemov,ssemov,sselog,sselog,ssemov,fmov,imov")
8822    (set_attr "ssememalign" "64")
8823    (set_attr "prefix_data16" "1,*,*,*,*,*,*")
8824    (set_attr "prefix" "orig,vex,orig,vex,*,*,*")
8825    (set_attr "mode" "V1DF,V1DF,V2DF,V2DF,DF,DF,DF")])
8827 (define_split
8828   [(set (match_operand:V2DF 0 "memory_operand")
8829         (vec_concat:V2DF
8830           (vec_select:DF (match_dup 0) (parallel [(const_int 0)]))
8831           (match_operand:DF 1 "register_operand")))]
8832   "TARGET_SSE2 && reload_completed"
8833   [(set (match_dup 0) (match_dup 1))]
8834   "operands[0] = adjust_address (operands[0], DFmode, 8);")
8836 (define_expand "sse2_loadlpd_exp"
8837   [(set (match_operand:V2DF 0 "nonimmediate_operand")
8838         (vec_concat:V2DF
8839           (match_operand:DF 2 "nonimmediate_operand")
8840           (vec_select:DF
8841             (match_operand:V2DF 1 "nonimmediate_operand")
8842             (parallel [(const_int 1)]))))]
8843   "TARGET_SSE2"
8845   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V2DFmode, operands);
8847   emit_insn (gen_sse2_loadlpd (dst, operands[1], operands[2]));
8849   /* Fix up the destination if needed.  */
8850   if (dst != operands[0])
8851     emit_move_insn (operands[0], dst);
8853   DONE;
8856 ;; Avoid combining registers from different units in a single alternative,
8857 ;; see comment above inline_secondary_memory_needed function in i386.c
8858 (define_insn "sse2_loadlpd"
8859   [(set (match_operand:V2DF 0 "nonimmediate_operand"
8860           "=x,x,x,x,x,x,x,x,m,m ,m")
8861         (vec_concat:V2DF
8862           (match_operand:DF 2 "nonimmediate_operand"
8863           " m,m,m,x,x,0,0,x,x,*f,r")
8864           (vec_select:DF
8865             (match_operand:V2DF 1 "vector_move_operand"
8866           " C,0,x,0,x,x,o,o,0,0 ,0")
8867             (parallel [(const_int 1)]))))]
8868   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
8869   "@
8870    %vmovsd\t{%2, %0|%0, %2}
8871    movlpd\t{%2, %0|%0, %2}
8872    vmovlpd\t{%2, %1, %0|%0, %1, %2}
8873    movsd\t{%2, %0|%0, %2}
8874    vmovsd\t{%2, %1, %0|%0, %1, %2}
8875    shufpd\t{$2, %1, %0|%0, %1, 2}
8876    movhpd\t{%H1, %0|%0, %H1}
8877    vmovhpd\t{%H1, %2, %0|%0, %2, %H1}
8878    #
8879    #
8880    #"
8881   [(set_attr "isa" "*,noavx,avx,noavx,avx,noavx,noavx,avx,*,*,*")
8882    (set (attr "type")
8883      (cond [(eq_attr "alternative" "5")
8884               (const_string "sselog")
8885             (eq_attr "alternative" "9")
8886               (const_string "fmov")
8887             (eq_attr "alternative" "10")
8888               (const_string "imov")
8889            ]
8890            (const_string "ssemov")))
8891    (set_attr "ssememalign" "64")
8892    (set_attr "prefix_data16" "*,1,*,*,*,*,1,*,*,*,*")
8893    (set_attr "length_immediate" "*,*,*,*,*,1,*,*,*,*,*")
8894    (set_attr "prefix" "maybe_vex,orig,vex,orig,vex,orig,orig,vex,*,*,*")
8895    (set_attr "mode" "DF,V1DF,V1DF,V1DF,V1DF,V2DF,V1DF,V1DF,DF,DF,DF")])
8897 (define_split
8898   [(set (match_operand:V2DF 0 "memory_operand")
8899         (vec_concat:V2DF
8900           (match_operand:DF 1 "register_operand")
8901           (vec_select:DF (match_dup 0) (parallel [(const_int 1)]))))]
8902   "TARGET_SSE2 && reload_completed"
8903   [(set (match_dup 0) (match_dup 1))]
8904   "operands[0] = adjust_address (operands[0], DFmode, 0);")
8906 (define_insn "sse2_movsd"
8907   [(set (match_operand:V2DF 0 "nonimmediate_operand"   "=x,x,x,x,m,x,x,x,o")
8908         (vec_merge:V2DF
8909           (match_operand:V2DF 2 "nonimmediate_operand" " x,x,m,m,x,0,0,x,0")
8910           (match_operand:V2DF 1 "nonimmediate_operand" " 0,x,0,x,0,x,o,o,x")
8911           (const_int 1)))]
8912   "TARGET_SSE2"
8913   "@
8914    movsd\t{%2, %0|%0, %2}
8915    vmovsd\t{%2, %1, %0|%0, %1, %2}
8916    movlpd\t{%2, %0|%0, %q2}
8917    vmovlpd\t{%2, %1, %0|%0, %1, %q2}
8918    %vmovlpd\t{%2, %0|%q0, %2}
8919    shufpd\t{$2, %1, %0|%0, %1, 2}
8920    movhps\t{%H1, %0|%0, %H1}
8921    vmovhps\t{%H1, %2, %0|%0, %2, %H1}
8922    %vmovhps\t{%1, %H0|%H0, %1}"
8923   [(set_attr "isa" "noavx,avx,noavx,avx,*,noavx,noavx,avx,*")
8924    (set (attr "type")
8925      (if_then_else
8926        (eq_attr "alternative" "5")
8927        (const_string "sselog")
8928        (const_string "ssemov")))
8929    (set (attr "prefix_data16")
8930      (if_then_else
8931        (and (eq_attr "alternative" "2,4")
8932             (not (match_test "TARGET_AVX")))
8933        (const_string "1")
8934        (const_string "*")))
8935    (set_attr "length_immediate" "*,*,*,*,*,1,*,*,*")
8936    (set_attr "ssememalign" "64")
8937    (set_attr "prefix" "orig,vex,orig,vex,maybe_vex,orig,orig,vex,maybe_vex")
8938    (set_attr "mode" "DF,DF,V1DF,V1DF,V1DF,V2DF,V1DF,V1DF,V1DF")])
8940 (define_insn "vec_dupv2df<mask_name>"
8941   [(set (match_operand:V2DF 0 "register_operand"     "=x,x,v")
8942         (vec_duplicate:V2DF
8943           (match_operand:DF 1 "nonimmediate_operand" " 0,xm,vm")))]
8944   "TARGET_SSE2 && <mask_avx512vl_condition>"
8945   "@
8946    unpcklpd\t%0, %0
8947    %vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}
8948    vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
8949   [(set_attr "isa" "noavx,sse3,avx512vl")
8950    (set_attr "type" "sselog1")
8951    (set_attr "prefix" "orig,maybe_vex,evex")
8952    (set_attr "mode" "V2DF,DF,DF")])
8954 (define_insn "vec_concatv2df"
8955   [(set (match_operand:V2DF 0 "register_operand"     "=x,x,v,x,v,x,x,v,x,x")
8956         (vec_concat:V2DF
8957           (match_operand:DF 1 "nonimmediate_operand" " 0,x,v,m,m,0,x,m,0,0")
8958           (match_operand:DF 2 "vector_move_operand"  " x,x,v,1,1,m,m,C,x,m")))]
8959   "TARGET_SSE
8960    && (!(MEM_P (operands[1]) && MEM_P (operands[2]))
8961        || (TARGET_SSE3 && rtx_equal_p (operands[1], operands[2])))"
8962   "@
8963    unpcklpd\t{%2, %0|%0, %2}
8964    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
8965    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
8966    %vmovddup\t{%1, %0|%0, %1}
8967    vmovddup\t{%1, %0|%0, %1}
8968    movhpd\t{%2, %0|%0, %2}
8969    vmovhpd\t{%2, %1, %0|%0, %1, %2}
8970    %vmovsd\t{%1, %0|%0, %1}
8971    movlhps\t{%2, %0|%0, %2}
8972    movhps\t{%2, %0|%0, %2}"
8973   [(set_attr "isa" "sse2_noavx,avx,avx512vl,sse3,avx512vl,sse2_noavx,avx,sse2,noavx,noavx")
8974    (set (attr "type")
8975      (if_then_else
8976        (eq_attr "alternative" "0,1,2,3,4")
8977        (const_string "sselog")
8978        (const_string "ssemov")))
8979    (set (attr "prefix_data16")
8980         (if_then_else (eq_attr "alternative" "5")
8981                       (const_string "1")
8982                       (const_string "*")))
8983    (set_attr "prefix" "orig,vex,evex,maybe_vex,evex,orig,vex,maybe_vex,orig,orig")
8984    (set_attr "mode" "V2DF,V2DF,V2DF, DF, DF, V1DF,V1DF,DF,V4SF,V2SF")])
8986 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8988 ;; Parallel integer down-conversion operations
8990 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8992 (define_mode_iterator PMOV_DST_MODE_1 [V16QI V16HI V8SI V8HI])
8993 (define_mode_attr pmov_src_mode
8994   [(V16QI "V16SI") (V16HI "V16SI") (V8SI "V8DI") (V8HI "V8DI")])
8995 (define_mode_attr pmov_src_lower
8996   [(V16QI "v16si") (V16HI "v16si") (V8SI "v8di") (V8HI "v8di")])
8997 (define_mode_attr pmov_suff_1
8998   [(V16QI "db") (V16HI "dw") (V8SI "qd") (V8HI "qw")])
9000 (define_insn "*avx512f_<code><pmov_src_lower><mode>2"
9001   [(set (match_operand:PMOV_DST_MODE_1 0 "nonimmediate_operand" "=v,m")
9002         (any_truncate:PMOV_DST_MODE_1
9003           (match_operand:<pmov_src_mode> 1 "register_operand" "v,v")))]
9004   "TARGET_AVX512F"
9005   "vpmov<trunsuffix><pmov_suff_1>\t{%1, %0|%0, %1}"
9006   [(set_attr "type" "ssemov")
9007    (set_attr "memory" "none,store")
9008    (set_attr "prefix" "evex")
9009    (set_attr "mode" "<sseinsnmode>")])
9011 (define_insn "avx512f_<code><pmov_src_lower><mode>2_mask"
9012   [(set (match_operand:PMOV_DST_MODE_1 0 "nonimmediate_operand" "=v,m")
9013     (vec_merge:PMOV_DST_MODE_1
9014       (any_truncate:PMOV_DST_MODE_1
9015         (match_operand:<pmov_src_mode> 1 "register_operand" "v,v"))
9016       (match_operand:PMOV_DST_MODE_1 2 "vector_move_operand" "0C,0")
9017       (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
9018   "TARGET_AVX512F"
9019   "vpmov<trunsuffix><pmov_suff_1>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9020   [(set_attr "type" "ssemov")
9021    (set_attr "memory" "none,store")
9022    (set_attr "prefix" "evex")
9023    (set_attr "mode" "<sseinsnmode>")])
9025 (define_expand "avx512f_<code><pmov_src_lower><mode>2_mask_store"
9026   [(set (match_operand:PMOV_DST_MODE_1 0 "memory_operand")
9027     (vec_merge:PMOV_DST_MODE_1
9028       (any_truncate:PMOV_DST_MODE_1
9029         (match_operand:<pmov_src_mode> 1 "register_operand"))
9030       (match_dup 0)
9031       (match_operand:<avx512fmaskmode> 2 "register_operand")))]
9032   "TARGET_AVX512F")
9034 (define_insn "avx512bw_<code>v32hiv32qi2"
9035   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
9036         (any_truncate:V32QI
9037             (match_operand:V32HI 1 "register_operand" "v,v")))]
9038   "TARGET_AVX512BW"
9039   "vpmov<trunsuffix>wb\t{%1, %0|%0, %1}"
9040   [(set_attr "type" "ssemov")
9041    (set_attr "memory" "none,store")
9042    (set_attr "prefix" "evex")
9043    (set_attr "mode" "XI")])
9045 (define_insn "avx512bw_<code>v32hiv32qi2_mask"
9046   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
9047     (vec_merge:V32QI
9048       (any_truncate:V32QI
9049         (match_operand:V32HI 1 "register_operand" "v,v"))
9050       (match_operand:V32QI 2 "vector_move_operand" "0C,0")
9051       (match_operand:SI 3 "register_operand" "Yk,Yk")))]
9052   "TARGET_AVX512BW"
9053   "vpmov<trunsuffix>wb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9054   [(set_attr "type" "ssemov")
9055    (set_attr "memory" "none,store")
9056    (set_attr "prefix" "evex")
9057    (set_attr "mode" "XI")])
9059 (define_expand "avx512bw_<code>v32hiv32qi2_mask_store"
9060   [(set (match_operand:V32QI 0 "nonimmediate_operand")
9061     (vec_merge:V32QI
9062       (any_truncate:V32QI
9063         (match_operand:V32HI 1 "register_operand"))
9064       (match_dup 0)
9065       (match_operand:SI 2 "register_operand")))]
9066   "TARGET_AVX512BW")
9068 (define_mode_iterator PMOV_DST_MODE_2
9069   [V4SI V8HI (V16QI "TARGET_AVX512BW")])
9070 (define_mode_attr pmov_suff_2
9071   [(V16QI "wb") (V8HI "dw") (V4SI "qd")])
9073 (define_insn "*avx512vl_<code><ssedoublemodelower><mode>2"
9074   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand" "=v,m")
9075         (any_truncate:PMOV_DST_MODE_2
9076             (match_operand:<ssedoublemode> 1 "register_operand" "v,v")))]
9077   "TARGET_AVX512VL"
9078   "vpmov<trunsuffix><pmov_suff_2>\t{%1, %0|%0, %1}"
9079   [(set_attr "type" "ssemov")
9080    (set_attr "memory" "none,store")
9081    (set_attr "prefix" "evex")
9082    (set_attr "mode" "<sseinsnmode>")])
9084 (define_insn "<avx512>_<code><ssedoublemodelower><mode>2_mask"
9085   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand" "=v,m")
9086     (vec_merge:PMOV_DST_MODE_2
9087       (any_truncate:PMOV_DST_MODE_2
9088         (match_operand:<ssedoublemode> 1 "register_operand" "v,v"))
9089       (match_operand:PMOV_DST_MODE_2 2 "vector_move_operand" "0C,0")
9090       (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
9091   "TARGET_AVX512VL"
9092   "vpmov<trunsuffix><pmov_suff_2>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9093   [(set_attr "type" "ssemov")
9094    (set_attr "memory" "none,store")
9095    (set_attr "prefix" "evex")
9096    (set_attr "mode" "<sseinsnmode>")])
9098 (define_expand "<avx512>_<code><ssedoublemodelower><mode>2_mask_store"
9099   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand")
9100     (vec_merge:PMOV_DST_MODE_2
9101       (any_truncate:PMOV_DST_MODE_2
9102         (match_operand:<ssedoublemode> 1 "register_operand"))
9103       (match_dup 0)
9104       (match_operand:<avx512fmaskmode> 2 "register_operand")))]
9105   "TARGET_AVX512VL")
9107 (define_mode_iterator PMOV_SRC_MODE_3 [V4DI V2DI V8SI V4SI (V8HI "TARGET_AVX512BW")])
9108 (define_mode_attr pmov_dst_3
9109   [(V4DI "V4QI") (V2DI "V2QI") (V8SI "V8QI") (V4SI "V4QI") (V8HI "V8QI")])
9110 (define_mode_attr pmov_dst_zeroed_3
9111   [(V4DI "V12QI") (V2DI "V14QI") (V8SI "V8QI") (V4SI "V12QI") (V8HI "V8QI")])
9112 (define_mode_attr pmov_suff_3
9113   [(V4DI "qb") (V2DI "qb") (V8SI "db") (V4SI "db") (V8HI "wb")])
9115 (define_insn "*avx512vl_<code><mode>v<ssescalarnum>qi2"
9116   [(set (match_operand:V16QI 0 "register_operand" "=v")
9117     (vec_concat:V16QI
9118       (any_truncate:<pmov_dst_3>
9119               (match_operand:PMOV_SRC_MODE_3 1 "register_operand" "v"))
9120       (match_operand:<pmov_dst_zeroed_3> 2 "const0_operand")))]
9121   "TARGET_AVX512VL"
9122   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%0, %1}"
9123   [(set_attr "type" "ssemov")
9124    (set_attr "prefix" "evex")
9125    (set_attr "mode" "TI")])
9127 (define_insn "*avx512vl_<code>v2div2qi2_store"
9128   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9129     (vec_concat:V16QI
9130       (any_truncate:V2QI
9131               (match_operand:V2DI 1 "register_operand" "v"))
9132       (vec_select:V14QI
9133         (match_dup 0)
9134         (parallel [(const_int 2) (const_int 3)
9135                    (const_int 4) (const_int 5)
9136                    (const_int 6) (const_int 7)
9137                    (const_int 8) (const_int 9)
9138                    (const_int 10) (const_int 11)
9139                    (const_int 12) (const_int 13)
9140                    (const_int 14) (const_int 15)]))))]
9141   "TARGET_AVX512VL"
9142   "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
9143   [(set_attr "type" "ssemov")
9144    (set_attr "memory" "store")
9145    (set_attr "prefix" "evex")
9146    (set_attr "mode" "TI")])
9148 (define_insn "avx512vl_<code>v2div2qi2_mask"
9149   [(set (match_operand:V16QI 0 "register_operand" "=v")
9150     (vec_concat:V16QI
9151       (vec_merge:V2QI
9152         (any_truncate:V2QI
9153           (match_operand:V2DI 1 "register_operand" "v"))
9154         (vec_select:V2QI
9155           (match_operand:V16QI 2 "vector_move_operand" "0C")
9156           (parallel [(const_int 0) (const_int 1)]))
9157         (match_operand:QI 3 "register_operand" "Yk"))
9158       (const_vector:V14QI [(const_int 0) (const_int 0)
9159                            (const_int 0) (const_int 0)
9160                            (const_int 0) (const_int 0)
9161                            (const_int 0) (const_int 0)
9162                            (const_int 0) (const_int 0)
9163                            (const_int 0) (const_int 0)
9164                            (const_int 0) (const_int 0)])))]
9165   "TARGET_AVX512VL"
9166   "vpmov<trunsuffix>qb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9167   [(set_attr "type" "ssemov")
9168    (set_attr "prefix" "evex")
9169    (set_attr "mode" "TI")])
9171 (define_insn "*avx512vl_<code>v2div2qi2_mask_1"
9172   [(set (match_operand:V16QI 0 "register_operand" "=v")
9173     (vec_concat:V16QI
9174       (vec_merge:V2QI
9175         (any_truncate:V2QI
9176           (match_operand:V2DI 1 "register_operand" "v"))
9177         (const_vector:V2QI [(const_int 0) (const_int 0)])
9178         (match_operand:QI 2 "register_operand" "Yk"))
9179       (const_vector:V14QI [(const_int 0) (const_int 0)
9180                            (const_int 0) (const_int 0)
9181                            (const_int 0) (const_int 0)
9182                            (const_int 0) (const_int 0)
9183                            (const_int 0) (const_int 0)
9184                            (const_int 0) (const_int 0)
9185                            (const_int 0) (const_int 0)])))]
9186   "TARGET_AVX512VL"
9187   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9188   [(set_attr "type" "ssemov")
9189    (set_attr "prefix" "evex")
9190    (set_attr "mode" "TI")])
9192 (define_insn "avx512vl_<code>v2div2qi2_mask_store"
9193   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9194     (vec_concat:V16QI
9195       (vec_merge:V2QI
9196         (any_truncate:V2QI
9197           (match_operand:V2DI 1 "register_operand" "v"))
9198         (vec_select:V2QI
9199           (match_dup 0)
9200           (parallel [(const_int 0) (const_int 1)]))
9201         (match_operand:QI 2 "register_operand" "Yk"))
9202       (vec_select:V14QI
9203         (match_dup 0)
9204         (parallel [(const_int 2) (const_int 3)
9205                    (const_int 4) (const_int 5)
9206                    (const_int 6) (const_int 7)
9207                    (const_int 8) (const_int 9)
9208                    (const_int 10) (const_int 11)
9209                    (const_int 12) (const_int 13)
9210                    (const_int 14) (const_int 15)]))))]
9211   "TARGET_AVX512VL"
9212   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}|%0%{%2%}, %1}"
9213   [(set_attr "type" "ssemov")
9214    (set_attr "memory" "store")
9215    (set_attr "prefix" "evex")
9216    (set_attr "mode" "TI")])
9218 (define_insn "*avx512vl_<code><mode>v4qi2_store"
9219   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9220     (vec_concat:V16QI
9221       (any_truncate:V4QI
9222               (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9223       (vec_select:V12QI
9224         (match_dup 0)
9225         (parallel [(const_int 4) (const_int 5)
9226                    (const_int 6) (const_int 7)
9227                    (const_int 8) (const_int 9)
9228                    (const_int 10) (const_int 11)
9229                    (const_int 12) (const_int 13)
9230                    (const_int 14) (const_int 15)]))))]
9231   "TARGET_AVX512VL"
9232   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%0, %1}"
9233   [(set_attr "type" "ssemov")
9234    (set_attr "memory" "store")
9235    (set_attr "prefix" "evex")
9236    (set_attr "mode" "TI")])
9238 (define_insn "avx512vl_<code><mode>v4qi2_mask"
9239   [(set (match_operand:V16QI 0 "register_operand" "=v")
9240     (vec_concat:V16QI
9241       (vec_merge:V4QI
9242         (any_truncate:V4QI
9243           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9244         (vec_select:V4QI
9245           (match_operand:V16QI 2 "vector_move_operand" "0C")
9246           (parallel [(const_int 0) (const_int 1)
9247                      (const_int 2) (const_int 3)]))
9248         (match_operand:QI 3 "register_operand" "Yk"))
9249       (const_vector:V12QI [(const_int 0) (const_int 0)
9250                            (const_int 0) (const_int 0)
9251                            (const_int 0) (const_int 0)
9252                            (const_int 0) (const_int 0)
9253                            (const_int 0) (const_int 0)
9254                            (const_int 0) (const_int 0)])))]
9255   "TARGET_AVX512VL"
9256   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9257   [(set_attr "type" "ssemov")
9258    (set_attr "prefix" "evex")
9259    (set_attr "mode" "TI")])
9261 (define_insn "*avx512vl_<code><mode>v4qi2_mask_1"
9262   [(set (match_operand:V16QI 0 "register_operand" "=v")
9263     (vec_concat:V16QI
9264       (vec_merge:V4QI
9265         (any_truncate:V4QI
9266           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9267         (const_vector:V4QI [(const_int 0) (const_int 0)
9268                             (const_int 0) (const_int 0)])
9269         (match_operand:QI 2 "register_operand" "Yk"))
9270       (const_vector:V12QI [(const_int 0) (const_int 0)
9271                            (const_int 0) (const_int 0)
9272                            (const_int 0) (const_int 0)
9273                            (const_int 0) (const_int 0)
9274                            (const_int 0) (const_int 0)
9275                            (const_int 0) (const_int 0)])))]
9276   "TARGET_AVX512VL"
9277   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9278   [(set_attr "type" "ssemov")
9279    (set_attr "prefix" "evex")
9280    (set_attr "mode" "TI")])
9282 (define_insn "avx512vl_<code><mode>v4qi2_mask_store"
9283   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9284     (vec_concat:V16QI
9285       (vec_merge:V4QI
9286         (any_truncate:V4QI
9287           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9288         (vec_select:V4QI
9289           (match_dup 0)
9290           (parallel [(const_int 0) (const_int 1)
9291                      (const_int 2) (const_int 3)]))
9292         (match_operand:QI 2 "register_operand" "Yk"))
9293       (vec_select:V12QI
9294         (match_dup 0)
9295         (parallel [(const_int 4) (const_int 5)
9296                    (const_int 6) (const_int 7)
9297                    (const_int 8) (const_int 9)
9298                    (const_int 10) (const_int 11)
9299                    (const_int 12) (const_int 13)
9300                    (const_int 14) (const_int 15)]))))]
9301   "TARGET_AVX512VL"
9302   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
9303   [(set_attr "type" "ssemov")
9304    (set_attr "memory" "store")
9305    (set_attr "prefix" "evex")
9306    (set_attr "mode" "TI")])
9308 (define_mode_iterator VI2_128_BW_4_256
9309   [(V8HI "TARGET_AVX512BW") V8SI])
9311 (define_insn "*avx512vl_<code><mode>v8qi2_store"
9312   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9313     (vec_concat:V16QI
9314       (any_truncate:V8QI
9315               (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9316       (vec_select:V8QI
9317         (match_dup 0)
9318         (parallel [(const_int 8) (const_int 9)
9319                    (const_int 10) (const_int 11)
9320                    (const_int 12) (const_int 13)
9321                    (const_int 14) (const_int 15)]))))]
9322   "TARGET_AVX512VL"
9323   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%0, %1}"
9324   [(set_attr "type" "ssemov")
9325    (set_attr "memory" "store")
9326    (set_attr "prefix" "evex")
9327    (set_attr "mode" "TI")])
9329 (define_insn "avx512vl_<code><mode>v8qi2_mask"
9330   [(set (match_operand:V16QI 0 "register_operand" "=v")
9331     (vec_concat:V16QI
9332       (vec_merge:V8QI
9333         (any_truncate:V8QI
9334           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9335         (vec_select:V8QI
9336           (match_operand:V16QI 2 "vector_move_operand" "0C")
9337           (parallel [(const_int 0) (const_int 1)
9338                      (const_int 2) (const_int 3)
9339                      (const_int 4) (const_int 5)
9340                      (const_int 6) (const_int 7)]))
9341         (match_operand:QI 3 "register_operand" "Yk"))
9342       (const_vector:V8QI [(const_int 0) (const_int 0)
9343                           (const_int 0) (const_int 0)
9344                           (const_int 0) (const_int 0)
9345                           (const_int 0) (const_int 0)])))]
9346   "TARGET_AVX512VL"
9347   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9348   [(set_attr "type" "ssemov")
9349    (set_attr "prefix" "evex")
9350    (set_attr "mode" "TI")])
9352 (define_insn "*avx512vl_<code><mode>v8qi2_mask_1"
9353   [(set (match_operand:V16QI 0 "register_operand" "=v")
9354     (vec_concat:V16QI
9355       (vec_merge:V8QI
9356         (any_truncate:V8QI
9357           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9358         (const_vector:V8QI [(const_int 0) (const_int 0)
9359                             (const_int 0) (const_int 0)
9360                             (const_int 0) (const_int 0)
9361                             (const_int 0) (const_int 0)])
9362         (match_operand:QI 2 "register_operand" "Yk"))
9363       (const_vector:V8QI [(const_int 0) (const_int 0)
9364                           (const_int 0) (const_int 0)
9365                           (const_int 0) (const_int 0)
9366                           (const_int 0) (const_int 0)])))]
9367   "TARGET_AVX512VL"
9368   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9369   [(set_attr "type" "ssemov")
9370    (set_attr "prefix" "evex")
9371    (set_attr "mode" "TI")])
9373 (define_insn "avx512vl_<code><mode>v8qi2_mask_store"
9374   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9375     (vec_concat:V16QI
9376       (vec_merge:V8QI
9377         (any_truncate:V8QI
9378           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9379         (vec_select:V8QI
9380           (match_dup 0)
9381           (parallel [(const_int 0) (const_int 1)
9382                      (const_int 2) (const_int 3)
9383                      (const_int 4) (const_int 5)
9384                      (const_int 6) (const_int 7)]))
9385         (match_operand:QI 2 "register_operand" "Yk"))
9386       (vec_select:V8QI
9387         (match_dup 0)
9388         (parallel [(const_int 8) (const_int 9)
9389                    (const_int 10) (const_int 11)
9390                    (const_int 12) (const_int 13)
9391                    (const_int 14) (const_int 15)]))))]
9392   "TARGET_AVX512VL"
9393   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
9394   [(set_attr "type" "ssemov")
9395    (set_attr "memory" "store")
9396    (set_attr "prefix" "evex")
9397    (set_attr "mode" "TI")])
9399 (define_mode_iterator PMOV_SRC_MODE_4 [V4DI V2DI V4SI])
9400 (define_mode_attr pmov_dst_4
9401   [(V4DI "V4HI") (V2DI "V2HI") (V4SI "V4HI")])
9402 (define_mode_attr pmov_dst_zeroed_4
9403   [(V4DI "V4HI") (V2DI "V6HI") (V4SI "V4HI")])
9404 (define_mode_attr pmov_suff_4
9405   [(V4DI "qw") (V2DI "qw") (V4SI "dw")])
9407 (define_insn "*avx512vl_<code><mode>v<ssescalarnum>hi2"
9408   [(set (match_operand:V8HI 0 "register_operand" "=v")
9409     (vec_concat:V8HI
9410       (any_truncate:<pmov_dst_4>
9411               (match_operand:PMOV_SRC_MODE_4 1 "register_operand" "v"))
9412       (match_operand:<pmov_dst_zeroed_4> 2 "const0_operand")))]
9413   "TARGET_AVX512VL"
9414   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0|%0, %1}"
9415   [(set_attr "type" "ssemov")
9416    (set_attr "prefix" "evex")
9417    (set_attr "mode" "TI")])
9419 (define_insn "*avx512vl_<code><mode>v4hi2_store"
9420   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9421     (vec_concat:V8HI
9422       (any_truncate:V4HI
9423               (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9424       (vec_select:V4HI
9425         (match_dup 0)
9426         (parallel [(const_int 4) (const_int 5)
9427                    (const_int 6) (const_int 7)]))))]
9428   "TARGET_AVX512VL"
9429   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0|%0, %1}"
9430   [(set_attr "type" "ssemov")
9431    (set_attr "memory" "store")
9432    (set_attr "prefix" "evex")
9433    (set_attr "mode" "TI")])
9435 (define_insn "avx512vl_<code><mode>v4hi2_mask"
9436   [(set (match_operand:V8HI 0 "register_operand" "=v")
9437     (vec_concat:V8HI
9438       (vec_merge:V4HI
9439         (any_truncate:V4HI
9440           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9441         (vec_select:V4HI
9442           (match_operand:V8HI 2 "vector_move_operand" "0C")
9443           (parallel [(const_int 0) (const_int 1)
9444                      (const_int 2) (const_int 3)]))
9445         (match_operand:QI 3 "register_operand" "Yk"))
9446       (const_vector:V4HI [(const_int 0) (const_int 0)
9447                           (const_int 0) (const_int 0)])))]
9448   "TARGET_AVX512VL"
9449   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9450   [(set_attr "type" "ssemov")
9451    (set_attr "prefix" "evex")
9452    (set_attr "mode" "TI")])
9454 (define_insn "*avx512vl_<code><mode>v4hi2_mask_1"
9455   [(set (match_operand:V8HI 0 "register_operand" "=v")
9456     (vec_concat:V8HI
9457       (vec_merge:V4HI
9458         (any_truncate:V4HI
9459           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9460         (const_vector:V4HI [(const_int 0) (const_int 0)
9461                             (const_int 0) (const_int 0)])
9462         (match_operand:QI 2 "register_operand" "Yk"))
9463       (const_vector:V4HI [(const_int 0) (const_int 0)
9464                           (const_int 0) (const_int 0)])))]
9465   "TARGET_AVX512VL"
9466   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9467   [(set_attr "type" "ssemov")
9468    (set_attr "prefix" "evex")
9469    (set_attr "mode" "TI")])
9471 (define_insn "avx512vl_<code><mode>v4hi2_mask_store"
9472   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9473     (vec_concat:V8HI
9474       (vec_merge:V4HI
9475         (any_truncate:V4HI
9476           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9477         (vec_select:V4HI
9478           (match_dup 0)
9479           (parallel [(const_int 0) (const_int 1)
9480                      (const_int 2) (const_int 3)]))
9481         (match_operand:QI 2 "register_operand" "Yk"))
9482       (vec_select:V4HI
9483         (match_dup 0)
9484         (parallel [(const_int 4) (const_int 5)
9485                    (const_int 6) (const_int 7)]))))]
9486   "TARGET_AVX512VL"
9487   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
9488   [(set_attr "type" "ssemov")
9489    (set_attr "memory" "store")
9490    (set_attr "prefix" "evex")
9491    (set_attr "mode" "TI")])
9493 (define_insn "*avx512vl_<code>v2div2hi2_store"
9494   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9495     (vec_concat:V8HI
9496       (any_truncate:V2HI
9497               (match_operand:V2DI 1 "register_operand" "v"))
9498       (vec_select:V6HI
9499         (match_dup 0)
9500         (parallel [(const_int 2) (const_int 3)
9501                    (const_int 4) (const_int 5)
9502                    (const_int 6) (const_int 7)]))))]
9503   "TARGET_AVX512VL"
9504   "vpmov<trunsuffix>qw\t{%1, %0|%0, %1}"
9505   [(set_attr "type" "ssemov")
9506    (set_attr "memory" "store")
9507    (set_attr "prefix" "evex")
9508    (set_attr "mode" "TI")])
9510 (define_insn "avx512vl_<code>v2div2hi2_mask"
9511   [(set (match_operand:V8HI 0 "register_operand" "=v")
9512     (vec_concat:V8HI
9513       (vec_merge:V2HI
9514         (any_truncate:V2HI
9515           (match_operand:V2DI 1 "register_operand" "v"))
9516         (vec_select:V2HI
9517           (match_operand:V8HI 2 "vector_move_operand" "0C")
9518           (parallel [(const_int 0) (const_int 1)]))
9519         (match_operand:QI 3 "register_operand" "Yk"))
9520       (const_vector:V6HI [(const_int 0) (const_int 0)
9521                           (const_int 0) (const_int 0)
9522                           (const_int 0) (const_int 0)])))]
9523   "TARGET_AVX512VL"
9524   "vpmov<trunsuffix>qw\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9525   [(set_attr "type" "ssemov")
9526    (set_attr "prefix" "evex")
9527    (set_attr "mode" "TI")])
9529 (define_insn "*avx512vl_<code>v2div2hi2_mask_1"
9530   [(set (match_operand:V8HI 0 "register_operand" "=v")
9531     (vec_concat:V8HI
9532       (vec_merge:V2HI
9533         (any_truncate:V2HI
9534           (match_operand:V2DI 1 "register_operand" "v"))
9535         (const_vector:V2HI [(const_int 0) (const_int 0)])
9536         (match_operand:QI 2 "register_operand" "Yk"))
9537       (const_vector:V6HI [(const_int 0) (const_int 0)
9538                           (const_int 0) (const_int 0)
9539                           (const_int 0) (const_int 0)])))]
9540   "TARGET_AVX512VL"
9541   "vpmov<trunsuffix>qw\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9542   [(set_attr "type" "ssemov")
9543    (set_attr "prefix" "evex")
9544    (set_attr "mode" "TI")])
9546 (define_insn "avx512vl_<code>v2div2hi2_mask_store"
9547   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9548     (vec_concat:V8HI
9549       (vec_merge:V2HI
9550         (any_truncate:V2HI
9551           (match_operand:V2DI 1 "register_operand" "v"))
9552         (vec_select:V2HI
9553           (match_dup 0)
9554           (parallel [(const_int 0) (const_int 1)]))
9555         (match_operand:QI 2 "register_operand" "Yk"))
9556       (vec_select:V6HI
9557         (match_dup 0)
9558         (parallel [(const_int 2) (const_int 3)
9559                    (const_int 4) (const_int 5)
9560                    (const_int 6) (const_int 7)]))))]
9561   "TARGET_AVX512VL"
9562   "vpmov<trunsuffix>qw\t{%1, %0%{%2%}|%0%{%2%}, %1}"
9563   [(set_attr "type" "ssemov")
9564    (set_attr "memory" "store")
9565    (set_attr "prefix" "evex")
9566    (set_attr "mode" "TI")])
9568 (define_insn "*avx512vl_<code>v2div2si2"
9569   [(set (match_operand:V4SI 0 "register_operand" "=v")
9570     (vec_concat:V4SI
9571       (any_truncate:V2SI
9572               (match_operand:V2DI 1 "register_operand" "v"))
9573       (match_operand:V2SI 2 "const0_operand")))]
9574   "TARGET_AVX512VL"
9575   "vpmov<trunsuffix>qd\t{%1, %0|%0, %1}"
9576   [(set_attr "type" "ssemov")
9577    (set_attr "prefix" "evex")
9578    (set_attr "mode" "TI")])
9580 (define_insn "*avx512vl_<code>v2div2si2_store"
9581   [(set (match_operand:V4SI 0 "memory_operand" "=m")
9582     (vec_concat:V4SI
9583       (any_truncate:V2SI
9584               (match_operand:V2DI 1 "register_operand" "v"))
9585       (vec_select:V2SI
9586         (match_dup 0)
9587         (parallel [(const_int 2) (const_int 3)]))))]
9588   "TARGET_AVX512VL"
9589   "vpmov<trunsuffix>qd\t{%1, %0|%0, %1}"
9590   [(set_attr "type" "ssemov")
9591    (set_attr "memory" "store")
9592    (set_attr "prefix" "evex")
9593    (set_attr "mode" "TI")])
9595 (define_insn "avx512vl_<code>v2div2si2_mask"
9596   [(set (match_operand:V4SI 0 "register_operand" "=v")
9597     (vec_concat:V4SI
9598       (vec_merge:V2SI
9599         (any_truncate:V2SI
9600           (match_operand:V2DI 1 "register_operand" "v"))
9601         (vec_select:V2SI
9602           (match_operand:V4SI 2 "vector_move_operand" "0C")
9603           (parallel [(const_int 0) (const_int 1)]))
9604         (match_operand:QI 3 "register_operand" "Yk"))
9605       (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9606   "TARGET_AVX512VL"
9607   "vpmov<trunsuffix>qd\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9608   [(set_attr "type" "ssemov")
9609    (set_attr "prefix" "evex")
9610    (set_attr "mode" "TI")])
9612 (define_insn "*avx512vl_<code>v2div2si2_mask_1"
9613   [(set (match_operand:V4SI 0 "register_operand" "=v")
9614     (vec_concat:V4SI
9615       (vec_merge:V2SI
9616         (any_truncate:V2SI
9617           (match_operand:V2DI 1 "register_operand" "v"))
9618         (const_vector:V2SI [(const_int 0) (const_int 0)])
9619         (match_operand:QI 2 "register_operand" "Yk"))
9620       (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9621   "TARGET_AVX512VL"
9622   "vpmov<trunsuffix>qd\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9623   [(set_attr "type" "ssemov")
9624    (set_attr "prefix" "evex")
9625    (set_attr "mode" "TI")])
9627 (define_insn "avx512vl_<code>v2div2si2_mask_store"
9628   [(set (match_operand:V4SI 0 "memory_operand" "=m")
9629     (vec_concat:V4SI
9630       (vec_merge:V2SI
9631         (any_truncate:V2SI
9632           (match_operand:V2DI 1 "register_operand" "v"))
9633         (vec_select:V2SI
9634           (match_dup 0)
9635           (parallel [(const_int 0) (const_int 1)]))
9636         (match_operand:QI 2 "register_operand" "Yk"))
9637       (vec_select:V2SI
9638         (match_dup 0)
9639         (parallel [(const_int 2) (const_int 3)]))))]
9640   "TARGET_AVX512VL"
9641   "vpmov<trunsuffix>qd\t{%1, %0%{%2%}|%0%{%2%}, %1}"
9642   [(set_attr "type" "ssemov")
9643    (set_attr "memory" "store")
9644    (set_attr "prefix" "evex")
9645    (set_attr "mode" "TI")])
9647 (define_insn "*avx512f_<code>v8div16qi2"
9648   [(set (match_operand:V16QI 0 "register_operand" "=v")
9649         (vec_concat:V16QI
9650           (any_truncate:V8QI
9651             (match_operand:V8DI 1 "register_operand" "v"))
9652           (const_vector:V8QI [(const_int 0) (const_int 0)
9653                               (const_int 0) (const_int 0)
9654                               (const_int 0) (const_int 0)
9655                               (const_int 0) (const_int 0)])))]
9656   "TARGET_AVX512F"
9657   "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
9658   [(set_attr "type" "ssemov")
9659    (set_attr "prefix" "evex")
9660    (set_attr "mode" "TI")])
9662 (define_insn "*avx512f_<code>v8div16qi2_store"
9663   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9664         (vec_concat:V16QI
9665           (any_truncate:V8QI
9666             (match_operand:V8DI 1 "register_operand" "v"))
9667           (vec_select:V8QI
9668             (match_dup 0)
9669             (parallel [(const_int 8) (const_int 9)
9670                        (const_int 10) (const_int 11)
9671                        (const_int 12) (const_int 13)
9672                        (const_int 14) (const_int 15)]))))]
9673   "TARGET_AVX512F"
9674   "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
9675   [(set_attr "type" "ssemov")
9676    (set_attr "memory" "store")
9677    (set_attr "prefix" "evex")
9678    (set_attr "mode" "TI")])
9680 (define_insn "avx512f_<code>v8div16qi2_mask"
9681   [(set (match_operand:V16QI 0 "register_operand" "=v")
9682     (vec_concat:V16QI
9683       (vec_merge:V8QI
9684         (any_truncate:V8QI
9685           (match_operand:V8DI 1 "register_operand" "v"))
9686         (vec_select:V8QI
9687           (match_operand:V16QI 2 "vector_move_operand" "0C")
9688           (parallel [(const_int 0) (const_int 1)
9689                      (const_int 2) (const_int 3)
9690                      (const_int 4) (const_int 5)
9691                      (const_int 6) (const_int 7)]))
9692         (match_operand:QI 3 "register_operand" "Yk"))
9693       (const_vector:V8QI [(const_int 0) (const_int 0)
9694                           (const_int 0) (const_int 0)
9695                           (const_int 0) (const_int 0)
9696                           (const_int 0) (const_int 0)])))]
9697   "TARGET_AVX512F"
9698   "vpmov<trunsuffix>qb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9699   [(set_attr "type" "ssemov")
9700    (set_attr "prefix" "evex")
9701    (set_attr "mode" "TI")])
9703 (define_insn "*avx512f_<code>v8div16qi2_mask_1"
9704   [(set (match_operand:V16QI 0 "register_operand" "=v")
9705     (vec_concat:V16QI
9706       (vec_merge:V8QI
9707         (any_truncate:V8QI
9708           (match_operand:V8DI 1 "register_operand" "v"))
9709         (const_vector:V8QI [(const_int 0) (const_int 0)
9710                             (const_int 0) (const_int 0)
9711                             (const_int 0) (const_int 0)
9712                             (const_int 0) (const_int 0)])
9713         (match_operand:QI 2 "register_operand" "Yk"))
9714       (const_vector:V8QI [(const_int 0) (const_int 0)
9715                           (const_int 0) (const_int 0)
9716                           (const_int 0) (const_int 0)
9717                           (const_int 0) (const_int 0)])))]
9718   "TARGET_AVX512F"
9719   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9720   [(set_attr "type" "ssemov")
9721    (set_attr "prefix" "evex")
9722    (set_attr "mode" "TI")])
9724 (define_insn "avx512f_<code>v8div16qi2_mask_store"
9725   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9726     (vec_concat:V16QI
9727       (vec_merge:V8QI
9728         (any_truncate:V8QI
9729           (match_operand:V8DI 1 "register_operand" "v"))
9730         (vec_select:V8QI
9731           (match_dup 0)
9732           (parallel [(const_int 0) (const_int 1)
9733                      (const_int 2) (const_int 3)
9734                      (const_int 4) (const_int 5)
9735                      (const_int 6) (const_int 7)]))
9736         (match_operand:QI 2 "register_operand" "Yk"))
9737       (vec_select:V8QI
9738         (match_dup 0)
9739         (parallel [(const_int 8) (const_int 9)
9740                    (const_int 10) (const_int 11)
9741                    (const_int 12) (const_int 13)
9742                    (const_int 14) (const_int 15)]))))]
9743   "TARGET_AVX512F"
9744   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}|%0%{%2%}, %1}"
9745   [(set_attr "type" "ssemov")
9746    (set_attr "memory" "store")
9747    (set_attr "prefix" "evex")
9748    (set_attr "mode" "TI")])
9750 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9752 ;; Parallel integral arithmetic
9754 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9756 (define_expand "neg<mode>2"
9757   [(set (match_operand:VI_AVX2 0 "register_operand")
9758         (minus:VI_AVX2
9759           (match_dup 2)
9760           (match_operand:VI_AVX2 1 "vector_operand")))]
9761   "TARGET_SSE2"
9762   "operands[2] = force_reg (<MODE>mode, CONST0_RTX (<MODE>mode));")
9764 (define_expand "<plusminus_insn><mode>3"
9765   [(set (match_operand:VI_AVX2 0 "register_operand")
9766         (plusminus:VI_AVX2
9767           (match_operand:VI_AVX2 1 "vector_operand")
9768           (match_operand:VI_AVX2 2 "vector_operand")))]
9769   "TARGET_SSE2"
9770   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
9772 (define_expand "<plusminus_insn><mode>3_mask"
9773   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
9774         (vec_merge:VI48_AVX512VL
9775           (plusminus:VI48_AVX512VL
9776             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
9777             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
9778           (match_operand:VI48_AVX512VL 3 "vector_move_operand")
9779           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
9780   "TARGET_AVX512F"
9781   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
9783 (define_expand "<plusminus_insn><mode>3_mask"
9784   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
9785         (vec_merge:VI12_AVX512VL
9786           (plusminus:VI12_AVX512VL
9787             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
9788             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand"))
9789           (match_operand:VI12_AVX512VL 3 "vector_move_operand")
9790           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
9791   "TARGET_AVX512BW"
9792   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
9794 (define_insn "*<plusminus_insn><mode>3"
9795   [(set (match_operand:VI_AVX2 0 "register_operand" "=x,v")
9796         (plusminus:VI_AVX2
9797           (match_operand:VI_AVX2 1 "vector_operand" "<comm>0,v")
9798           (match_operand:VI_AVX2 2 "vector_operand" "xBm,vm")))]
9799   "TARGET_SSE2
9800    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
9801   "@
9802    p<plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
9803    vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9804   [(set_attr "isa" "noavx,avx")
9805    (set_attr "type" "sseiadd")
9806    (set_attr "prefix_data16" "1,*")
9807    (set_attr "prefix" "<mask_prefix3>")
9808    (set_attr "mode" "<sseinsnmode>")])
9810 (define_insn "*<plusminus_insn><mode>3_mask"
9811   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
9812         (vec_merge:VI48_AVX512VL
9813           (plusminus:VI48_AVX512VL
9814             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "<comm>v")
9815             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm"))
9816           (match_operand:VI48_AVX512VL 3 "vector_move_operand" "0C")
9817           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
9818   "TARGET_AVX512F
9819    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
9820   "vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
9821   [(set_attr "type" "sseiadd")
9822    (set_attr "prefix" "evex")
9823    (set_attr "mode" "<sseinsnmode>")])
9825 (define_insn "*<plusminus_insn><mode>3_mask"
9826   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
9827         (vec_merge:VI12_AVX512VL
9828           (plusminus:VI12_AVX512VL
9829             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "<comm>v")
9830             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm"))
9831           (match_operand:VI12_AVX512VL 3 "vector_move_operand" "0C")
9832           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
9833   "TARGET_AVX512BW && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
9834   "vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
9835   [(set_attr "type" "sseiadd")
9836    (set_attr "prefix" "evex")
9837    (set_attr "mode" "<sseinsnmode>")])
9839 (define_expand "<sse2_avx2>_<plusminus_insn><mode>3<mask_name>"
9840   [(set (match_operand:VI12_AVX2 0 "register_operand")
9841         (sat_plusminus:VI12_AVX2
9842           (match_operand:VI12_AVX2 1 "vector_operand")
9843           (match_operand:VI12_AVX2 2 "vector_operand")))]
9844   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
9845   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
9847 (define_insn "*<sse2_avx2>_<plusminus_insn><mode>3<mask_name>"
9848   [(set (match_operand:VI12_AVX2 0 "register_operand" "=x,v")
9849         (sat_plusminus:VI12_AVX2
9850           (match_operand:VI12_AVX2 1 "vector_operand" "<comm>0,v")
9851           (match_operand:VI12_AVX2 2 "vector_operand" "xBm,vm")))]
9852   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
9853    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
9854   "@
9855    p<plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
9856    vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9857   [(set_attr "isa" "noavx,avx")
9858    (set_attr "type" "sseiadd")
9859    (set_attr "prefix_data16" "1,*")
9860    (set_attr "prefix" "orig,maybe_evex")
9861    (set_attr "mode" "TI")])
9863 (define_expand "mul<mode>3<mask_name>"
9864   [(set (match_operand:VI1_AVX512 0 "register_operand")
9865         (mult:VI1_AVX512 (match_operand:VI1_AVX512 1 "register_operand")
9866                        (match_operand:VI1_AVX512 2 "register_operand")))]
9867   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
9869   ix86_expand_vecop_qihi (MULT, operands[0], operands[1], operands[2]);
9870   DONE;
9873 (define_expand "mul<mode>3<mask_name>"
9874   [(set (match_operand:VI2_AVX2 0 "register_operand")
9875         (mult:VI2_AVX2 (match_operand:VI2_AVX2 1 "vector_operand")
9876                        (match_operand:VI2_AVX2 2 "vector_operand")))]
9877   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
9878   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
9880 (define_insn "*mul<mode>3<mask_name>"
9881   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,v")
9882         (mult:VI2_AVX2 (match_operand:VI2_AVX2 1 "vector_operand" "%0,v")
9883                        (match_operand:VI2_AVX2 2 "vector_operand" "xBm,vm")))]
9884   "TARGET_SSE2
9885    && ix86_binary_operator_ok (MULT, <MODE>mode, operands)
9886    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
9887   "@
9888    pmullw\t{%2, %0|%0, %2}
9889    vpmullw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9890   [(set_attr "isa" "noavx,avx")
9891    (set_attr "type" "sseimul")
9892    (set_attr "prefix_data16" "1,*")
9893    (set_attr "prefix" "orig,vex")
9894    (set_attr "mode" "<sseinsnmode>")])
9896 (define_expand "<s>mul<mode>3_highpart<mask_name>"
9897   [(set (match_operand:VI2_AVX2 0 "register_operand")
9898         (truncate:VI2_AVX2
9899           (lshiftrt:<ssedoublemode>
9900             (mult:<ssedoublemode>
9901               (any_extend:<ssedoublemode>
9902                 (match_operand:VI2_AVX2 1 "vector_operand"))
9903               (any_extend:<ssedoublemode>
9904                 (match_operand:VI2_AVX2 2 "vector_operand")))
9905             (const_int 16))))]
9906   "TARGET_SSE2
9907    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
9908   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
9910 (define_insn "*<s>mul<mode>3_highpart<mask_name>"
9911   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,v")
9912         (truncate:VI2_AVX2
9913           (lshiftrt:<ssedoublemode>
9914             (mult:<ssedoublemode>
9915               (any_extend:<ssedoublemode>
9916                 (match_operand:VI2_AVX2 1 "vector_operand" "%0,v"))
9917               (any_extend:<ssedoublemode>
9918                 (match_operand:VI2_AVX2 2 "vector_operand" "xBm,vm")))
9919             (const_int 16))))]
9920   "TARGET_SSE2
9921    && ix86_binary_operator_ok (MULT, <MODE>mode, operands)
9922    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
9923   "@
9924    pmulh<u>w\t{%2, %0|%0, %2}
9925    vpmulh<u>w\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9926   [(set_attr "isa" "noavx,avx")
9927    (set_attr "type" "sseimul")
9928    (set_attr "prefix_data16" "1,*")
9929    (set_attr "prefix" "orig,vex")
9930    (set_attr "mode" "<sseinsnmode>")])
9932 (define_expand "vec_widen_umult_even_v16si<mask_name>"
9933   [(set (match_operand:V8DI 0 "register_operand")
9934         (mult:V8DI
9935           (zero_extend:V8DI
9936             (vec_select:V8SI
9937               (match_operand:V16SI 1 "nonimmediate_operand")
9938               (parallel [(const_int 0) (const_int 2)
9939                          (const_int 4) (const_int 6)
9940                          (const_int 8) (const_int 10)
9941                          (const_int 12) (const_int 14)])))
9942           (zero_extend:V8DI
9943             (vec_select:V8SI
9944               (match_operand:V16SI 2 "nonimmediate_operand")
9945               (parallel [(const_int 0) (const_int 2)
9946                          (const_int 4) (const_int 6)
9947                          (const_int 8) (const_int 10)
9948                          (const_int 12) (const_int 14)])))))]
9949   "TARGET_AVX512F"
9950   "ix86_fixup_binary_operands_no_copy (MULT, V16SImode, operands);")
9952 (define_insn "*vec_widen_umult_even_v16si<mask_name>"
9953   [(set (match_operand:V8DI 0 "register_operand" "=v")
9954         (mult:V8DI
9955           (zero_extend:V8DI
9956             (vec_select:V8SI
9957               (match_operand:V16SI 1 "nonimmediate_operand" "%v")
9958               (parallel [(const_int 0) (const_int 2)
9959                          (const_int 4) (const_int 6)
9960                          (const_int 8) (const_int 10)
9961                          (const_int 12) (const_int 14)])))
9962           (zero_extend:V8DI
9963             (vec_select:V8SI
9964               (match_operand:V16SI 2 "nonimmediate_operand" "vm")
9965               (parallel [(const_int 0) (const_int 2)
9966                          (const_int 4) (const_int 6)
9967                          (const_int 8) (const_int 10)
9968                          (const_int 12) (const_int 14)])))))]
9969   "TARGET_AVX512F && ix86_binary_operator_ok (MULT, V16SImode, operands)"
9970   "vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9971   [(set_attr "isa" "avx512f")
9972    (set_attr "type" "sseimul")
9973    (set_attr "prefix_extra" "1")
9974    (set_attr "prefix" "evex")
9975    (set_attr "mode" "XI")])
9977 (define_expand "vec_widen_umult_even_v8si<mask_name>"
9978   [(set (match_operand:V4DI 0 "register_operand")
9979         (mult:V4DI
9980           (zero_extend:V4DI
9981             (vec_select:V4SI
9982               (match_operand:V8SI 1 "nonimmediate_operand")
9983               (parallel [(const_int 0) (const_int 2)
9984                          (const_int 4) (const_int 6)])))
9985           (zero_extend:V4DI
9986             (vec_select:V4SI
9987               (match_operand:V8SI 2 "nonimmediate_operand")
9988               (parallel [(const_int 0) (const_int 2)
9989                          (const_int 4) (const_int 6)])))))]
9990   "TARGET_AVX2 && <mask_avx512vl_condition>"
9991   "ix86_fixup_binary_operands_no_copy (MULT, V8SImode, operands);")
9993 (define_insn "*vec_widen_umult_even_v8si<mask_name>"
9994   [(set (match_operand:V4DI 0 "register_operand" "=v")
9995         (mult:V4DI
9996           (zero_extend:V4DI
9997             (vec_select:V4SI
9998               (match_operand:V8SI 1 "nonimmediate_operand" "%v")
9999               (parallel [(const_int 0) (const_int 2)
10000                          (const_int 4) (const_int 6)])))
10001           (zero_extend:V4DI
10002             (vec_select:V4SI
10003               (match_operand:V8SI 2 "nonimmediate_operand" "vm")
10004               (parallel [(const_int 0) (const_int 2)
10005                          (const_int 4) (const_int 6)])))))]
10006   "TARGET_AVX2 && <mask_avx512vl_condition>
10007    && ix86_binary_operator_ok (MULT, V8SImode, operands)"
10008   "vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10009   [(set_attr "type" "sseimul")
10010    (set_attr "prefix" "maybe_evex")
10011    (set_attr "mode" "OI")])
10013 (define_expand "vec_widen_umult_even_v4si<mask_name>"
10014   [(set (match_operand:V2DI 0 "register_operand")
10015         (mult:V2DI
10016           (zero_extend:V2DI
10017             (vec_select:V2SI
10018               (match_operand:V4SI 1 "vector_operand")
10019               (parallel [(const_int 0) (const_int 2)])))
10020           (zero_extend:V2DI
10021             (vec_select:V2SI
10022               (match_operand:V4SI 2 "vector_operand")
10023               (parallel [(const_int 0) (const_int 2)])))))]
10024   "TARGET_SSE2 && <mask_avx512vl_condition>"
10025   "ix86_fixup_binary_operands_no_copy (MULT, V4SImode, operands);")
10027 (define_insn "*vec_widen_umult_even_v4si<mask_name>"
10028   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
10029         (mult:V2DI
10030           (zero_extend:V2DI
10031             (vec_select:V2SI
10032               (match_operand:V4SI 1 "vector_operand" "%0,v")
10033               (parallel [(const_int 0) (const_int 2)])))
10034           (zero_extend:V2DI
10035             (vec_select:V2SI
10036               (match_operand:V4SI 2 "vector_operand" "xBm,vm")
10037               (parallel [(const_int 0) (const_int 2)])))))]
10038   "TARGET_SSE2 && <mask_avx512vl_condition>
10039    && ix86_binary_operator_ok (MULT, V4SImode, operands)"
10040   "@
10041    pmuludq\t{%2, %0|%0, %2}
10042    vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10043   [(set_attr "isa" "noavx,avx")
10044    (set_attr "type" "sseimul")
10045    (set_attr "prefix_data16" "1,*")
10046    (set_attr "prefix" "orig,maybe_evex")
10047    (set_attr "mode" "TI")])
10049 (define_expand "vec_widen_smult_even_v16si<mask_name>"
10050   [(set (match_operand:V8DI 0 "register_operand")
10051         (mult:V8DI
10052           (sign_extend:V8DI
10053             (vec_select:V8SI
10054               (match_operand:V16SI 1 "nonimmediate_operand")
10055               (parallel [(const_int 0) (const_int 2)
10056                          (const_int 4) (const_int 6)
10057                          (const_int 8) (const_int 10)
10058                          (const_int 12) (const_int 14)])))
10059           (sign_extend:V8DI
10060             (vec_select:V8SI
10061               (match_operand:V16SI 2 "nonimmediate_operand")
10062               (parallel [(const_int 0) (const_int 2)
10063                          (const_int 4) (const_int 6)
10064                          (const_int 8) (const_int 10)
10065                          (const_int 12) (const_int 14)])))))]
10066   "TARGET_AVX512F"
10067   "ix86_fixup_binary_operands_no_copy (MULT, V16SImode, operands);")
10069 (define_insn "*vec_widen_smult_even_v16si<mask_name>"
10070   [(set (match_operand:V8DI 0 "register_operand" "=v")
10071         (mult:V8DI
10072           (sign_extend:V8DI
10073             (vec_select:V8SI
10074               (match_operand:V16SI 1 "nonimmediate_operand" "%v")
10075               (parallel [(const_int 0) (const_int 2)
10076                          (const_int 4) (const_int 6)
10077                          (const_int 8) (const_int 10)
10078                          (const_int 12) (const_int 14)])))
10079           (sign_extend:V8DI
10080             (vec_select:V8SI
10081               (match_operand:V16SI 2 "nonimmediate_operand" "vm")
10082               (parallel [(const_int 0) (const_int 2)
10083                          (const_int 4) (const_int 6)
10084                          (const_int 8) (const_int 10)
10085                          (const_int 12) (const_int 14)])))))]
10086   "TARGET_AVX512F && ix86_binary_operator_ok (MULT, V16SImode, operands)"
10087   "vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10088   [(set_attr "isa" "avx512f")
10089    (set_attr "type" "sseimul")
10090    (set_attr "prefix_extra" "1")
10091    (set_attr "prefix" "evex")
10092    (set_attr "mode" "XI")])
10094 (define_expand "vec_widen_smult_even_v8si<mask_name>"
10095   [(set (match_operand:V4DI 0 "register_operand")
10096         (mult:V4DI
10097           (sign_extend:V4DI
10098             (vec_select:V4SI
10099               (match_operand:V8SI 1 "nonimmediate_operand")
10100               (parallel [(const_int 0) (const_int 2)
10101                          (const_int 4) (const_int 6)])))
10102           (sign_extend:V4DI
10103             (vec_select:V4SI
10104               (match_operand:V8SI 2 "nonimmediate_operand")
10105               (parallel [(const_int 0) (const_int 2)
10106                          (const_int 4) (const_int 6)])))))]
10107   "TARGET_AVX2 && <mask_avx512vl_condition>"
10108   "ix86_fixup_binary_operands_no_copy (MULT, V8SImode, operands);")
10110 (define_insn "*vec_widen_smult_even_v8si<mask_name>"
10111   [(set (match_operand:V4DI 0 "register_operand" "=v")
10112         (mult:V4DI
10113           (sign_extend:V4DI
10114             (vec_select:V4SI
10115               (match_operand:V8SI 1 "nonimmediate_operand" "%v")
10116               (parallel [(const_int 0) (const_int 2)
10117                          (const_int 4) (const_int 6)])))
10118           (sign_extend:V4DI
10119             (vec_select:V4SI
10120               (match_operand:V8SI 2 "nonimmediate_operand" "vm")
10121               (parallel [(const_int 0) (const_int 2)
10122                          (const_int 4) (const_int 6)])))))]
10123   "TARGET_AVX2
10124    && ix86_binary_operator_ok (MULT, V8SImode, operands)"
10125   "vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10126   [(set_attr "type" "sseimul")
10127    (set_attr "prefix_extra" "1")
10128    (set_attr "prefix" "vex")
10129    (set_attr "mode" "OI")])
10131 (define_expand "sse4_1_mulv2siv2di3<mask_name>"
10132   [(set (match_operand:V2DI 0 "register_operand")
10133         (mult:V2DI
10134           (sign_extend:V2DI
10135             (vec_select:V2SI
10136               (match_operand:V4SI 1 "vector_operand")
10137               (parallel [(const_int 0) (const_int 2)])))
10138           (sign_extend:V2DI
10139             (vec_select:V2SI
10140               (match_operand:V4SI 2 "vector_operand")
10141               (parallel [(const_int 0) (const_int 2)])))))]
10142   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
10143   "ix86_fixup_binary_operands_no_copy (MULT, V4SImode, operands);")
10145 (define_insn "*sse4_1_mulv2siv2di3<mask_name>"
10146   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
10147         (mult:V2DI
10148           (sign_extend:V2DI
10149             (vec_select:V2SI
10150               (match_operand:V4SI 1 "vector_operand" "%0,0,v")
10151               (parallel [(const_int 0) (const_int 2)])))
10152           (sign_extend:V2DI
10153             (vec_select:V2SI
10154               (match_operand:V4SI 2 "vector_operand" "YrBm,*xBm,vm")
10155               (parallel [(const_int 0) (const_int 2)])))))]
10156   "TARGET_SSE4_1 && <mask_avx512vl_condition>
10157    && ix86_binary_operator_ok (MULT, V4SImode, operands)"
10158   "@
10159    pmuldq\t{%2, %0|%0, %2}
10160    pmuldq\t{%2, %0|%0, %2}
10161    vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10162   [(set_attr "isa" "noavx,noavx,avx")
10163    (set_attr "type" "sseimul")
10164    (set_attr "prefix_data16" "1,1,*")
10165    (set_attr "prefix_extra" "1")
10166    (set_attr "prefix" "orig,orig,vex")
10167    (set_attr "mode" "TI")])
10169 (define_insn "avx512bw_pmaddwd512<mode><mask_name>"
10170   [(set (match_operand:<sseunpackmode> 0 "register_operand" "=v")
10171           (unspec:<sseunpackmode>
10172             [(match_operand:VI2_AVX2 1 "register_operand" "v")
10173              (match_operand:VI2_AVX2 2 "nonimmediate_operand" "vm")]
10174              UNSPEC_PMADDWD512))]
10175    "TARGET_AVX512BW && <mask_mode512bit_condition>"
10176    "vpmaddwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}";
10177   [(set_attr "type" "sseiadd")
10178    (set_attr "prefix" "evex")
10179    (set_attr "mode" "XI")])
10181 (define_expand "avx2_pmaddwd"
10182   [(set (match_operand:V8SI 0 "register_operand")
10183         (plus:V8SI
10184           (mult:V8SI
10185             (sign_extend:V8SI
10186               (vec_select:V8HI
10187                 (match_operand:V16HI 1 "nonimmediate_operand")
10188                 (parallel [(const_int 0) (const_int 2)
10189                            (const_int 4) (const_int 6)
10190                            (const_int 8) (const_int 10)
10191                            (const_int 12) (const_int 14)])))
10192             (sign_extend:V8SI
10193               (vec_select:V8HI
10194                 (match_operand:V16HI 2 "nonimmediate_operand")
10195                 (parallel [(const_int 0) (const_int 2)
10196                            (const_int 4) (const_int 6)
10197                            (const_int 8) (const_int 10)
10198                            (const_int 12) (const_int 14)]))))
10199           (mult:V8SI
10200             (sign_extend:V8SI
10201               (vec_select:V8HI (match_dup 1)
10202                 (parallel [(const_int 1) (const_int 3)
10203                            (const_int 5) (const_int 7)
10204                            (const_int 9) (const_int 11)
10205                            (const_int 13) (const_int 15)])))
10206             (sign_extend:V8SI
10207               (vec_select:V8HI (match_dup 2)
10208                 (parallel [(const_int 1) (const_int 3)
10209                            (const_int 5) (const_int 7)
10210                            (const_int 9) (const_int 11)
10211                            (const_int 13) (const_int 15)]))))))]
10212   "TARGET_AVX2"
10213   "ix86_fixup_binary_operands_no_copy (MULT, V16HImode, operands);")
10215 (define_insn "*avx2_pmaddwd"
10216   [(set (match_operand:V8SI 0 "register_operand" "=x")
10217         (plus:V8SI
10218           (mult:V8SI
10219             (sign_extend:V8SI
10220               (vec_select:V8HI
10221                 (match_operand:V16HI 1 "nonimmediate_operand" "%x")
10222                 (parallel [(const_int 0) (const_int 2)
10223                            (const_int 4) (const_int 6)
10224                            (const_int 8) (const_int 10)
10225                            (const_int 12) (const_int 14)])))
10226             (sign_extend:V8SI
10227               (vec_select:V8HI
10228                 (match_operand:V16HI 2 "nonimmediate_operand" "xm")
10229                 (parallel [(const_int 0) (const_int 2)
10230                            (const_int 4) (const_int 6)
10231                            (const_int 8) (const_int 10)
10232                            (const_int 12) (const_int 14)]))))
10233           (mult:V8SI
10234             (sign_extend:V8SI
10235               (vec_select:V8HI (match_dup 1)
10236                 (parallel [(const_int 1) (const_int 3)
10237                            (const_int 5) (const_int 7)
10238                            (const_int 9) (const_int 11)
10239                            (const_int 13) (const_int 15)])))
10240             (sign_extend:V8SI
10241               (vec_select:V8HI (match_dup 2)
10242                 (parallel [(const_int 1) (const_int 3)
10243                            (const_int 5) (const_int 7)
10244                            (const_int 9) (const_int 11)
10245                            (const_int 13) (const_int 15)]))))))]
10246   "TARGET_AVX2 && ix86_binary_operator_ok (MULT, V16HImode, operands)"
10247   "vpmaddwd\t{%2, %1, %0|%0, %1, %2}"
10248   [(set_attr "type" "sseiadd")
10249    (set_attr "prefix" "vex")
10250    (set_attr "mode" "OI")])
10252 (define_expand "sse2_pmaddwd"
10253   [(set (match_operand:V4SI 0 "register_operand")
10254         (plus:V4SI
10255           (mult:V4SI
10256             (sign_extend:V4SI
10257               (vec_select:V4HI
10258                 (match_operand:V8HI 1 "vector_operand")
10259                 (parallel [(const_int 0) (const_int 2)
10260                            (const_int 4) (const_int 6)])))
10261             (sign_extend:V4SI
10262               (vec_select:V4HI
10263                 (match_operand:V8HI 2 "vector_operand")
10264                 (parallel [(const_int 0) (const_int 2)
10265                            (const_int 4) (const_int 6)]))))
10266           (mult:V4SI
10267             (sign_extend:V4SI
10268               (vec_select:V4HI (match_dup 1)
10269                 (parallel [(const_int 1) (const_int 3)
10270                            (const_int 5) (const_int 7)])))
10271             (sign_extend:V4SI
10272               (vec_select:V4HI (match_dup 2)
10273                 (parallel [(const_int 1) (const_int 3)
10274                            (const_int 5) (const_int 7)]))))))]
10275   "TARGET_SSE2"
10276   "ix86_fixup_binary_operands_no_copy (MULT, V8HImode, operands);")
10278 (define_insn "*sse2_pmaddwd"
10279   [(set (match_operand:V4SI 0 "register_operand" "=x,x")
10280         (plus:V4SI
10281           (mult:V4SI
10282             (sign_extend:V4SI
10283               (vec_select:V4HI
10284                 (match_operand:V8HI 1 "vector_operand" "%0,x")
10285                 (parallel [(const_int 0) (const_int 2)
10286                            (const_int 4) (const_int 6)])))
10287             (sign_extend:V4SI
10288               (vec_select:V4HI
10289                 (match_operand:V8HI 2 "vector_operand" "xBm,xm")
10290                 (parallel [(const_int 0) (const_int 2)
10291                            (const_int 4) (const_int 6)]))))
10292           (mult:V4SI
10293             (sign_extend:V4SI
10294               (vec_select:V4HI (match_dup 1)
10295                 (parallel [(const_int 1) (const_int 3)
10296                            (const_int 5) (const_int 7)])))
10297             (sign_extend:V4SI
10298               (vec_select:V4HI (match_dup 2)
10299                 (parallel [(const_int 1) (const_int 3)
10300                            (const_int 5) (const_int 7)]))))))]
10301   "TARGET_SSE2 && ix86_binary_operator_ok (MULT, V8HImode, operands)"
10302   "@
10303    pmaddwd\t{%2, %0|%0, %2}
10304    vpmaddwd\t{%2, %1, %0|%0, %1, %2}"
10305   [(set_attr "isa" "noavx,avx")
10306    (set_attr "type" "sseiadd")
10307    (set_attr "atom_unit" "simul")
10308    (set_attr "prefix_data16" "1,*")
10309    (set_attr "prefix" "orig,vex")
10310    (set_attr "mode" "TI")])
10312 (define_insn "avx512dq_mul<mode>3<mask_name>"
10313   [(set (match_operand:VI8 0 "register_operand" "=v")
10314         (mult:VI8
10315           (match_operand:VI8 1 "register_operand" "v")
10316           (match_operand:VI8 2 "nonimmediate_operand" "vm")))]
10317   "TARGET_AVX512DQ && <mask_mode512bit_condition>"
10318   "vpmullq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10319   [(set_attr "type" "sseimul")
10320    (set_attr "prefix" "evex")
10321    (set_attr "mode" "<sseinsnmode>")])
10323 (define_expand "mul<mode>3<mask_name>"
10324   [(set (match_operand:VI4_AVX512F 0 "register_operand")
10325         (mult:VI4_AVX512F
10326           (match_operand:VI4_AVX512F 1 "general_vector_operand")
10327           (match_operand:VI4_AVX512F 2 "general_vector_operand")))]
10328   "TARGET_SSE2 && <mask_mode512bit_condition>"
10330   if (TARGET_SSE4_1)
10331     {
10332       if (!vector_operand (operands[1], <MODE>mode))
10333         operands[1] = force_reg (<MODE>mode, operands[1]);
10334       if (!vector_operand (operands[2], <MODE>mode))
10335         operands[2] = force_reg (<MODE>mode, operands[2]);
10336       ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
10337     }
10338   else
10339     {
10340       ix86_expand_sse2_mulv4si3 (operands[0], operands[1], operands[2]);
10341       DONE;
10342     }
10345 (define_insn "*<sse4_1_avx2>_mul<mode>3<mask_name>"
10346   [(set (match_operand:VI4_AVX512F 0 "register_operand" "=Yr,*x,v")
10347         (mult:VI4_AVX512F
10348           (match_operand:VI4_AVX512F 1 "vector_operand" "%0,0,v")
10349           (match_operand:VI4_AVX512F 2 "vector_operand" "YrBm,*xBm,vm")))]
10350   "TARGET_SSE4_1 && ix86_binary_operator_ok (MULT, <MODE>mode, operands) && <mask_mode512bit_condition>"
10351   "@
10352    pmulld\t{%2, %0|%0, %2}
10353    pmulld\t{%2, %0|%0, %2}
10354    vpmulld\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10355   [(set_attr "isa" "noavx,noavx,avx")
10356    (set_attr "type" "sseimul")
10357    (set_attr "prefix_extra" "1")
10358    (set_attr "prefix" "<mask_prefix4>")
10359    (set_attr "btver2_decode" "vector,vector,vector")
10360    (set_attr "mode" "<sseinsnmode>")])
10362 (define_expand "mul<mode>3"
10363   [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand")
10364         (mult:VI8_AVX2_AVX512F
10365           (match_operand:VI8_AVX2_AVX512F 1 "register_operand")
10366           (match_operand:VI8_AVX2_AVX512F 2 "register_operand")))]
10367   "TARGET_SSE2"
10369   ix86_expand_sse2_mulvxdi3 (operands[0], operands[1], operands[2]);
10370   DONE;
10373 (define_expand "vec_widen_<s>mult_hi_<mode>"
10374   [(match_operand:<sseunpackmode> 0 "register_operand")
10375    (any_extend:<sseunpackmode>
10376      (match_operand:VI124_AVX2 1 "register_operand"))
10377    (match_operand:VI124_AVX2 2 "register_operand")]
10378   "TARGET_SSE2"
10380   ix86_expand_mul_widen_hilo (operands[0], operands[1], operands[2],
10381                               <u_bool>, true);
10382   DONE;
10385 (define_expand "vec_widen_<s>mult_lo_<mode>"
10386   [(match_operand:<sseunpackmode> 0 "register_operand")
10387    (any_extend:<sseunpackmode>
10388      (match_operand:VI124_AVX2 1 "register_operand"))
10389    (match_operand:VI124_AVX2 2 "register_operand")]
10390   "TARGET_SSE2"
10392   ix86_expand_mul_widen_hilo (operands[0], operands[1], operands[2],
10393                               <u_bool>, false);
10394   DONE;
10397 ;; Most widen_<s>mult_even_<mode> can be handled directly from other
10398 ;; named patterns, but signed V4SI needs special help for plain SSE2.
10399 (define_expand "vec_widen_smult_even_v4si"
10400   [(match_operand:V2DI 0 "register_operand")
10401    (match_operand:V4SI 1 "vector_operand")
10402    (match_operand:V4SI 2 "vector_operand")]
10403   "TARGET_SSE2"
10405   ix86_expand_mul_widen_evenodd (operands[0], operands[1], operands[2],
10406                                  false, false);
10407   DONE;
10410 (define_expand "vec_widen_<s>mult_odd_<mode>"
10411   [(match_operand:<sseunpackmode> 0 "register_operand")
10412    (any_extend:<sseunpackmode>
10413      (match_operand:VI4_AVX512F 1 "general_vector_operand"))
10414    (match_operand:VI4_AVX512F 2 "general_vector_operand")]
10415   "TARGET_SSE2"
10417   ix86_expand_mul_widen_evenodd (operands[0], operands[1], operands[2],
10418                                  <u_bool>, true);
10419   DONE;
10422 (define_mode_attr SDOT_PMADD_SUF
10423   [(V32HI "512v32hi") (V16HI "") (V8HI "")])
10425 (define_expand "sdot_prod<mode>"
10426   [(match_operand:<sseunpackmode> 0 "register_operand")
10427    (match_operand:VI2_AVX2 1 "register_operand")
10428    (match_operand:VI2_AVX2 2 "register_operand")
10429    (match_operand:<sseunpackmode> 3 "register_operand")]
10430   "TARGET_SSE2"
10432   rtx t = gen_reg_rtx (<sseunpackmode>mode);
10433   emit_insn (gen_<sse2_avx2>_pmaddwd<SDOT_PMADD_SUF> (t, operands[1], operands[2]));
10434   emit_insn (gen_rtx_SET (operands[0],
10435                           gen_rtx_PLUS (<sseunpackmode>mode,
10436                                         operands[3], t)));
10437   DONE;
10440 ;; Normally we use widen_mul_even/odd, but combine can't quite get it all
10441 ;; back together when madd is available.
10442 (define_expand "sdot_prodv4si"
10443   [(match_operand:V2DI 0 "register_operand")
10444    (match_operand:V4SI 1 "register_operand")
10445    (match_operand:V4SI 2 "register_operand")
10446    (match_operand:V2DI 3 "register_operand")]
10447   "TARGET_XOP"
10449   rtx t = gen_reg_rtx (V2DImode);
10450   emit_insn (gen_xop_pmacsdqh (t, operands[1], operands[2], operands[3]));
10451   emit_insn (gen_xop_pmacsdql (operands[0], operands[1], operands[2], t));
10452   DONE;
10455 (define_expand "usadv16qi"
10456   [(match_operand:V4SI 0 "register_operand")
10457    (match_operand:V16QI 1 "register_operand")
10458    (match_operand:V16QI 2 "vector_operand")
10459    (match_operand:V4SI 3 "vector_operand")]
10460   "TARGET_SSE2"
10462   rtx t1 = gen_reg_rtx (V2DImode);
10463   rtx t2 = gen_reg_rtx (V4SImode);
10464   emit_insn (gen_sse2_psadbw (t1, operands[1], operands[2]));
10465   convert_move (t2, t1, 0);
10466   emit_insn (gen_addv4si3 (operands[0], t2, operands[3]));
10467   DONE;
10470 (define_expand "usadv32qi"
10471   [(match_operand:V8SI 0 "register_operand")
10472    (match_operand:V32QI 1 "register_operand")
10473    (match_operand:V32QI 2 "nonimmediate_operand")
10474    (match_operand:V8SI 3 "nonimmediate_operand")]
10475   "TARGET_AVX2"
10477   rtx t1 = gen_reg_rtx (V4DImode);
10478   rtx t2 = gen_reg_rtx (V8SImode);
10479   emit_insn (gen_avx2_psadbw (t1, operands[1], operands[2]));
10480   convert_move (t2, t1, 0);
10481   emit_insn (gen_addv8si3 (operands[0], t2, operands[3]));
10482   DONE;
10485 (define_insn "ashr<mode>3"
10486   [(set (match_operand:VI24_AVX2 0 "register_operand" "=x,x")
10487         (ashiftrt:VI24_AVX2
10488           (match_operand:VI24_AVX2 1 "register_operand" "0,x")
10489           (match_operand:SI 2 "nonmemory_operand" "xN,xN")))]
10490   "TARGET_SSE2"
10491   "@
10492    psra<ssemodesuffix>\t{%2, %0|%0, %2}
10493    vpsra<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10494   [(set_attr "isa" "noavx,avx")
10495    (set_attr "type" "sseishft")
10496    (set (attr "length_immediate")
10497      (if_then_else (match_operand 2 "const_int_operand")
10498        (const_string "1")
10499        (const_string "0")))
10500    (set_attr "prefix_data16" "1,*")
10501    (set_attr "prefix" "orig,vex")
10502    (set_attr "mode" "<sseinsnmode>")])
10504 (define_insn "<mask_codefor>ashr<mode>3<mask_name>"
10505   [(set (match_operand:VI24_AVX512BW_1 0 "register_operand" "=v,v")
10506         (ashiftrt:VI24_AVX512BW_1
10507           (match_operand:VI24_AVX512BW_1 1 "nonimmediate_operand" "v,vm")
10508           (match_operand:SI 2 "nonmemory_operand" "v,N")))]
10509   "TARGET_AVX512VL"
10510   "vpsra<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10511   [(set_attr "type" "sseishft")
10512    (set (attr "length_immediate")
10513      (if_then_else (match_operand 2 "const_int_operand")
10514        (const_string "1")
10515        (const_string "0")))
10516    (set_attr "mode" "<sseinsnmode>")])
10518 (define_insn "<mask_codefor>ashrv2di3<mask_name>"
10519   [(set (match_operand:V2DI 0 "register_operand" "=v,v")
10520         (ashiftrt:V2DI
10521           (match_operand:V2DI 1 "nonimmediate_operand" "v,vm")
10522           (match_operand:DI 2 "nonmemory_operand" "v,N")))]
10523   "TARGET_AVX512VL"
10524   "vpsraq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10525   [(set_attr "type" "sseishft")
10526    (set (attr "length_immediate")
10527      (if_then_else (match_operand 2 "const_int_operand")
10528        (const_string "1")
10529        (const_string "0")))
10530    (set_attr "mode" "TI")])
10532 (define_insn "ashr<mode>3<mask_name>"
10533   [(set (match_operand:VI248_AVX512BW_AVX512VL 0 "register_operand" "=v,v")
10534         (ashiftrt:VI248_AVX512BW_AVX512VL
10535           (match_operand:VI248_AVX512BW_AVX512VL 1 "nonimmediate_operand" "v,vm")
10536           (match_operand:SI 2 "nonmemory_operand" "v,N")))]
10537   "TARGET_AVX512F"
10538   "vpsra<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10539   [(set_attr "type" "sseishft")
10540    (set (attr "length_immediate")
10541      (if_then_else (match_operand 2 "const_int_operand")
10542        (const_string "1")
10543        (const_string "0")))
10544    (set_attr "mode" "<sseinsnmode>")])
10546 (define_insn "<shift_insn><mode>3<mask_name>"
10547   [(set (match_operand:VI2_AVX2_AVX512BW 0 "register_operand" "=x,v")
10548         (any_lshift:VI2_AVX2_AVX512BW
10549           (match_operand:VI2_AVX2_AVX512BW 1 "register_operand" "0,v")
10550           (match_operand:SI 2 "nonmemory_operand" "xN,vN")))]
10551   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10552   "@
10553    p<vshift><ssemodesuffix>\t{%2, %0|%0, %2}
10554    vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10555   [(set_attr "isa" "noavx,avx")
10556    (set_attr "type" "sseishft")
10557    (set (attr "length_immediate")
10558      (if_then_else (match_operand 2 "const_int_operand")
10559        (const_string "1")
10560        (const_string "0")))
10561    (set_attr "prefix_data16" "1,*")
10562    (set_attr "prefix" "orig,vex")
10563    (set_attr "mode" "<sseinsnmode>")])
10565 (define_insn "<shift_insn><mode>3<mask_name>"
10566   [(set (match_operand:VI48_AVX2 0 "register_operand" "=x,v")
10567         (any_lshift:VI48_AVX2
10568           (match_operand:VI48_AVX2 1 "register_operand" "0,v")
10569           (match_operand:SI 2 "nonmemory_operand" "xN,vN")))]
10570   "TARGET_SSE2 && <mask_mode512bit_condition>"
10571   "@
10572    p<vshift><ssemodesuffix>\t{%2, %0|%0, %2}
10573    vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10574   [(set_attr "isa" "noavx,avx")
10575    (set_attr "type" "sseishft")
10576    (set (attr "length_immediate")
10577      (if_then_else (match_operand 2 "const_int_operand")
10578        (const_string "1")
10579        (const_string "0")))
10580    (set_attr "prefix_data16" "1,*")
10581    (set_attr "prefix" "orig,vex")
10582    (set_attr "mode" "<sseinsnmode>")])
10584 (define_insn "<shift_insn><mode>3<mask_name>"
10585   [(set (match_operand:VI48_512 0 "register_operand" "=v,v")
10586         (any_lshift:VI48_512
10587           (match_operand:VI48_512 1 "nonimmediate_operand" "v,m")
10588           (match_operand:SI 2 "nonmemory_operand" "vN,N")))]
10589   "TARGET_AVX512F && <mask_mode512bit_condition>"
10590   "vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10591   [(set_attr "isa" "avx512f")
10592    (set_attr "type" "sseishft")
10593    (set (attr "length_immediate")
10594      (if_then_else (match_operand 2 "const_int_operand")
10595        (const_string "1")
10596        (const_string "0")))
10597    (set_attr "prefix" "evex")
10598    (set_attr "mode" "<sseinsnmode>")])
10601 (define_expand "vec_shl_<mode>"
10602   [(set (match_dup 3)
10603         (ashift:V1TI
10604          (match_operand:VI_128 1 "register_operand")
10605          (match_operand:SI 2 "const_0_to_255_mul_8_operand")))
10606    (set (match_operand:VI_128 0 "register_operand") (match_dup 4))]
10607   "TARGET_SSE2"
10609   operands[1] = gen_lowpart (V1TImode, operands[1]);
10610   operands[3] = gen_reg_rtx (V1TImode);
10611   operands[4] = gen_lowpart (<MODE>mode, operands[3]);
10614 (define_insn "<sse2_avx2>_ashl<mode>3"
10615   [(set (match_operand:VIMAX_AVX2 0 "register_operand" "=x,v")
10616         (ashift:VIMAX_AVX2
10617          (match_operand:VIMAX_AVX2 1 "register_operand" "0,v")
10618          (match_operand:SI 2 "const_0_to_255_mul_8_operand" "n,n")))]
10619   "TARGET_SSE2"
10621   operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
10623   switch (which_alternative)
10624     {
10625     case 0:
10626       return "pslldq\t{%2, %0|%0, %2}";
10627     case 1:
10628       return "vpslldq\t{%2, %1, %0|%0, %1, %2}";
10629     default:
10630       gcc_unreachable ();
10631     }
10633   [(set_attr "isa" "noavx,avx")
10634    (set_attr "type" "sseishft")
10635    (set_attr "length_immediate" "1")
10636    (set_attr "prefix_data16" "1,*")
10637    (set_attr "prefix" "orig,vex")
10638    (set_attr "mode" "<sseinsnmode>")])
10640 (define_expand "vec_shr_<mode>"
10641   [(set (match_dup 3)
10642         (lshiftrt:V1TI
10643          (match_operand:VI_128 1 "register_operand")
10644          (match_operand:SI 2 "const_0_to_255_mul_8_operand")))
10645    (set (match_operand:VI_128 0 "register_operand") (match_dup 4))]
10646   "TARGET_SSE2"
10648   operands[1] = gen_lowpart (V1TImode, operands[1]);
10649   operands[3] = gen_reg_rtx (V1TImode);
10650   operands[4] = gen_lowpart (<MODE>mode, operands[3]);
10653 (define_insn "<sse2_avx2>_lshr<mode>3"
10654   [(set (match_operand:VIMAX_AVX2 0 "register_operand" "=x,v")
10655         (lshiftrt:VIMAX_AVX2
10656          (match_operand:VIMAX_AVX2 1 "register_operand" "0,v")
10657          (match_operand:SI 2 "const_0_to_255_mul_8_operand" "n,n")))]
10658   "TARGET_SSE2"
10660   operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
10662   switch (which_alternative)
10663     {
10664     case 0:
10665       return "psrldq\t{%2, %0|%0, %2}";
10666     case 1:
10667       return "vpsrldq\t{%2, %1, %0|%0, %1, %2}";
10668     default:
10669       gcc_unreachable ();
10670     }
10672   [(set_attr "isa" "noavx,avx")
10673    (set_attr "type" "sseishft")
10674    (set_attr "length_immediate" "1")
10675    (set_attr "atom_unit" "sishuf")
10676    (set_attr "prefix_data16" "1,*")
10677    (set_attr "prefix" "orig,vex")
10678    (set_attr "mode" "<sseinsnmode>")])
10680 (define_insn "<avx512>_<rotate>v<mode><mask_name>"
10681   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10682         (any_rotate:VI48_AVX512VL
10683           (match_operand:VI48_AVX512VL 1 "register_operand" "v")
10684           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")))]
10685   "TARGET_AVX512F"
10686   "vp<rotate>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10687   [(set_attr "prefix" "evex")
10688    (set_attr "mode" "<sseinsnmode>")])
10690 (define_insn "<avx512>_<rotate><mode><mask_name>"
10691   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10692         (any_rotate:VI48_AVX512VL
10693           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")
10694           (match_operand:SI 2 "const_0_to_255_operand")))]
10695   "TARGET_AVX512F"
10696   "vp<rotate><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10697   [(set_attr "prefix" "evex")
10698    (set_attr "mode" "<sseinsnmode>")])
10700 (define_expand "<code><mode>3"
10701   [(set (match_operand:VI124_256_AVX512F_AVX512BW 0 "register_operand")
10702         (maxmin:VI124_256_AVX512F_AVX512BW
10703           (match_operand:VI124_256_AVX512F_AVX512BW 1 "nonimmediate_operand")
10704           (match_operand:VI124_256_AVX512F_AVX512BW 2 "nonimmediate_operand")))]
10705   "TARGET_AVX2"
10706   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10708 (define_insn "*avx2_<code><mode>3"
10709   [(set (match_operand:VI124_256 0 "register_operand" "=v")
10710         (maxmin:VI124_256
10711           (match_operand:VI124_256 1 "nonimmediate_operand" "%v")
10712           (match_operand:VI124_256 2 "nonimmediate_operand" "vm")))]
10713   "TARGET_AVX2 && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10714   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10715   [(set_attr "type" "sseiadd")
10716    (set_attr "prefix_extra" "1")
10717    (set_attr "prefix" "vex")
10718    (set_attr "mode" "OI")])
10720 (define_expand "<code><mode>3_mask"
10721   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
10722         (vec_merge:VI48_AVX512VL
10723           (maxmin:VI48_AVX512VL
10724             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
10725             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
10726           (match_operand:VI48_AVX512VL 3 "vector_move_operand")
10727           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
10728   "TARGET_AVX512F"
10729   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10731 (define_insn "*avx512bw_<code><mode>3<mask_name>"
10732   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10733         (maxmin:VI48_AVX512VL
10734           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "%v")
10735           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")))]
10736   "TARGET_AVX512F && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10737   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10738   [(set_attr "type" "sseiadd")
10739    (set_attr "prefix_extra" "1")
10740    (set_attr "prefix" "maybe_evex")
10741    (set_attr "mode" "<sseinsnmode>")])
10743 (define_insn "<mask_codefor><code><mode>3<mask_name>"
10744   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
10745         (maxmin:VI12_AVX512VL
10746           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
10747           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")))]
10748   "TARGET_AVX512BW"
10749   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10750   [(set_attr "type" "sseiadd")
10751    (set_attr "prefix" "evex")
10752    (set_attr "mode" "<sseinsnmode>")])
10754 (define_expand "<code><mode>3"
10755   [(set (match_operand:VI8_AVX2_AVX512BW 0 "register_operand")
10756         (maxmin:VI8_AVX2_AVX512BW
10757           (match_operand:VI8_AVX2_AVX512BW 1 "register_operand")
10758           (match_operand:VI8_AVX2_AVX512BW 2 "register_operand")))]
10759   "TARGET_SSE4_2"
10761   if (TARGET_AVX512F
10762       && (<MODE>mode == V8DImode || TARGET_AVX512VL))
10763     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
10764   else 
10765     {
10766       enum rtx_code code;
10767       rtx xops[6];
10768       bool ok;
10771       xops[0] = operands[0];
10773       if (<CODE> == SMAX || <CODE> == UMAX)
10774         {
10775           xops[1] = operands[1];
10776           xops[2] = operands[2];
10777         }
10778       else
10779         {
10780           xops[1] = operands[2];
10781           xops[2] = operands[1];
10782         }
10784       code = (<CODE> == UMAX || <CODE> == UMIN) ? GTU : GT;
10786       xops[3] = gen_rtx_fmt_ee (code, VOIDmode, operands[1], operands[2]);
10787       xops[4] = operands[1];
10788       xops[5] = operands[2];
10790       ok = ix86_expand_int_vcond (xops);
10791       gcc_assert (ok);
10792       DONE;
10793     }
10796 (define_expand "<code><mode>3"
10797   [(set (match_operand:VI124_128 0 "register_operand")
10798         (smaxmin:VI124_128
10799           (match_operand:VI124_128 1 "vector_operand")
10800           (match_operand:VI124_128 2 "vector_operand")))]
10801   "TARGET_SSE2"
10803   if (TARGET_SSE4_1 || <MODE>mode == V8HImode)
10804     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
10805   else
10806     {
10807       rtx xops[6];
10808       bool ok;
10810       xops[0] = operands[0];
10811       operands[1] = force_reg (<MODE>mode, operands[1]);
10812       operands[2] = force_reg (<MODE>mode, operands[2]);
10814       if (<CODE> == SMAX)
10815         {
10816           xops[1] = operands[1];
10817           xops[2] = operands[2];
10818         }
10819       else
10820         {
10821           xops[1] = operands[2];
10822           xops[2] = operands[1];
10823         }
10825       xops[3] = gen_rtx_GT (VOIDmode, operands[1], operands[2]);
10826       xops[4] = operands[1];
10827       xops[5] = operands[2];
10829       ok = ix86_expand_int_vcond (xops);
10830       gcc_assert (ok);
10831       DONE;
10832     }
10835 (define_insn "*sse4_1_<code><mode>3<mask_name>"
10836   [(set (match_operand:VI14_128 0 "register_operand" "=Yr,*x,v")
10837         (smaxmin:VI14_128
10838           (match_operand:VI14_128 1 "vector_operand" "%0,0,v")
10839           (match_operand:VI14_128 2 "vector_operand" "YrBm,*xBm,vm")))]
10840   "TARGET_SSE4_1
10841    && <mask_mode512bit_condition>
10842    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10843   "@
10844    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
10845    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
10846    vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10847   [(set_attr "isa" "noavx,noavx,avx")
10848    (set_attr "type" "sseiadd")
10849    (set_attr "prefix_extra" "1,1,*")
10850    (set_attr "prefix" "orig,orig,vex")
10851    (set_attr "mode" "TI")])
10853 (define_insn "*<code>v8hi3"
10854   [(set (match_operand:V8HI 0 "register_operand" "=x,x")
10855         (smaxmin:V8HI
10856           (match_operand:V8HI 1 "vector_operand" "%0,x")
10857           (match_operand:V8HI 2 "vector_operand" "xBm,xm")))]
10858   "TARGET_SSE2 && ix86_binary_operator_ok (<CODE>, V8HImode, operands)"
10859   "@
10860    p<maxmin_int>w\t{%2, %0|%0, %2}
10861    vp<maxmin_int>w\t{%2, %1, %0|%0, %1, %2}"
10862   [(set_attr "isa" "noavx,avx")
10863    (set_attr "type" "sseiadd")
10864    (set_attr "prefix_data16" "1,*")
10865    (set_attr "prefix_extra" "*,1")
10866    (set_attr "prefix" "orig,vex")
10867    (set_attr "mode" "TI")])
10869 (define_expand "<code><mode>3"
10870   [(set (match_operand:VI124_128 0 "register_operand")
10871         (umaxmin:VI124_128
10872           (match_operand:VI124_128 1 "vector_operand")
10873           (match_operand:VI124_128 2 "vector_operand")))]
10874   "TARGET_SSE2"
10876   if (TARGET_SSE4_1 || <MODE>mode == V16QImode)
10877     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
10878   else if (<CODE> == UMAX && <MODE>mode == V8HImode)
10879     {
10880       rtx op0 = operands[0], op2 = operands[2], op3 = op0;
10881       operands[1] = force_reg (<MODE>mode, operands[1]);
10882       if (rtx_equal_p (op3, op2))
10883         op3 = gen_reg_rtx (V8HImode);
10884       emit_insn (gen_sse2_ussubv8hi3 (op3, operands[1], op2));
10885       emit_insn (gen_addv8hi3 (op0, op3, op2));
10886       DONE;
10887     }
10888   else
10889     {
10890       rtx xops[6];
10891       bool ok;
10893       operands[1] = force_reg (<MODE>mode, operands[1]);
10894       operands[2] = force_reg (<MODE>mode, operands[2]);
10896       xops[0] = operands[0];
10898       if (<CODE> == UMAX)
10899         {
10900           xops[1] = operands[1];
10901           xops[2] = operands[2];
10902         }
10903       else
10904         {
10905           xops[1] = operands[2];
10906           xops[2] = operands[1];
10907         }
10909       xops[3] = gen_rtx_GTU (VOIDmode, operands[1], operands[2]);
10910       xops[4] = operands[1];
10911       xops[5] = operands[2];
10913       ok = ix86_expand_int_vcond (xops);
10914       gcc_assert (ok);
10915       DONE;
10916     }
10919 (define_insn "*sse4_1_<code><mode>3<mask_name>"
10920   [(set (match_operand:VI24_128 0 "register_operand" "=Yr,*x,v")
10921         (umaxmin:VI24_128
10922           (match_operand:VI24_128 1 "vector_operand" "%0,0,v")
10923           (match_operand:VI24_128 2 "vector_operand" "YrBm,*xBm,vm")))]
10924   "TARGET_SSE4_1
10925    && <mask_mode512bit_condition>
10926    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10927   "@
10928    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
10929    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
10930    vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10931   [(set_attr "isa" "noavx,noavx,avx")
10932    (set_attr "type" "sseiadd")
10933    (set_attr "prefix_extra" "1,1,*")
10934    (set_attr "prefix" "orig,orig,vex")
10935    (set_attr "mode" "TI")])
10937 (define_insn "*<code>v16qi3"
10938   [(set (match_operand:V16QI 0 "register_operand" "=x,x")
10939         (umaxmin:V16QI
10940           (match_operand:V16QI 1 "vector_operand" "%0,x")
10941           (match_operand:V16QI 2 "vector_operand" "xBm,xm")))]
10942   "TARGET_SSE2 && ix86_binary_operator_ok (<CODE>, V16QImode, operands)"
10943   "@
10944    p<maxmin_int>b\t{%2, %0|%0, %2}
10945    vp<maxmin_int>b\t{%2, %1, %0|%0, %1, %2}"
10946   [(set_attr "isa" "noavx,avx")
10947    (set_attr "type" "sseiadd")
10948    (set_attr "prefix_data16" "1,*")
10949    (set_attr "prefix_extra" "*,1")
10950    (set_attr "prefix" "orig,vex")
10951    (set_attr "mode" "TI")])
10953 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10955 ;; Parallel integral comparisons
10957 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10959 (define_expand "avx2_eq<mode>3"
10960   [(set (match_operand:VI_256 0 "register_operand")
10961         (eq:VI_256
10962           (match_operand:VI_256 1 "nonimmediate_operand")
10963           (match_operand:VI_256 2 "nonimmediate_operand")))]
10964   "TARGET_AVX2"
10965   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
10967 (define_insn "*avx2_eq<mode>3"
10968   [(set (match_operand:VI_256 0 "register_operand" "=x")
10969         (eq:VI_256
10970           (match_operand:VI_256 1 "nonimmediate_operand" "%x")
10971           (match_operand:VI_256 2 "nonimmediate_operand" "xm")))]
10972   "TARGET_AVX2 && ix86_binary_operator_ok (EQ, <MODE>mode, operands)"
10973   "vpcmpeq<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10974   [(set_attr "type" "ssecmp")
10975    (set_attr "prefix_extra" "1")
10976    (set_attr "prefix" "vex")
10977    (set_attr "mode" "OI")])
10979 (define_expand "<avx512>_eq<mode>3<mask_scalar_merge_name>"
10980   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
10981         (unspec:<avx512fmaskmode>
10982           [(match_operand:VI12_AVX512VL 1 "register_operand")
10983            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand")]
10984           UNSPEC_MASKED_EQ))]
10985   "TARGET_AVX512BW"
10986   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
10988 (define_expand "<avx512>_eq<mode>3<mask_scalar_merge_name>"
10989   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
10990         (unspec:<avx512fmaskmode>
10991           [(match_operand:VI48_AVX512VL 1 "register_operand")
10992            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand")]
10993           UNSPEC_MASKED_EQ))]
10994   "TARGET_AVX512F"
10995   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
10997 (define_insn "<avx512>_eq<mode>3<mask_scalar_merge_name>_1"
10998   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
10999         (unspec:<avx512fmaskmode>
11000           [(match_operand:VI12_AVX512VL 1 "register_operand" "%v")
11001            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")]
11002           UNSPEC_MASKED_EQ))]
11003   "TARGET_AVX512F && ix86_binary_operator_ok (EQ, <MODE>mode, operands)"
11004   "vpcmpeq<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11005   [(set_attr "type" "ssecmp")
11006    (set_attr "prefix_extra" "1")
11007    (set_attr "prefix" "evex")
11008    (set_attr "mode" "<sseinsnmode>")])
11010 (define_insn "<avx512>_eq<mode>3<mask_scalar_merge_name>_1"
11011   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11012         (unspec:<avx512fmaskmode>
11013           [(match_operand:VI48_AVX512VL 1 "register_operand" "%v")
11014            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")]
11015           UNSPEC_MASKED_EQ))]
11016   "TARGET_AVX512F && ix86_binary_operator_ok (EQ, <MODE>mode, operands)"
11017   "vpcmpeq<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11018   [(set_attr "type" "ssecmp")
11019    (set_attr "prefix_extra" "1")
11020    (set_attr "prefix" "evex")
11021    (set_attr "mode" "<sseinsnmode>")])
11023 (define_insn "*sse4_1_eqv2di3"
11024   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,x")
11025         (eq:V2DI
11026           (match_operand:V2DI 1 "vector_operand" "%0,0,x")
11027           (match_operand:V2DI 2 "vector_operand" "YrBm,*xBm,xm")))]
11028   "TARGET_SSE4_1 && ix86_binary_operator_ok (EQ, V2DImode, operands)"
11029   "@
11030    pcmpeqq\t{%2, %0|%0, %2}
11031    pcmpeqq\t{%2, %0|%0, %2}
11032    vpcmpeqq\t{%2, %1, %0|%0, %1, %2}"
11033   [(set_attr "isa" "noavx,noavx,avx")
11034    (set_attr "type" "ssecmp")
11035    (set_attr "prefix_extra" "1")
11036    (set_attr "prefix" "orig,orig,vex")
11037    (set_attr "mode" "TI")])
11039 (define_insn "*sse2_eq<mode>3"
11040   [(set (match_operand:VI124_128 0 "register_operand" "=x,x")
11041         (eq:VI124_128
11042           (match_operand:VI124_128 1 "vector_operand" "%0,x")
11043           (match_operand:VI124_128 2 "vector_operand" "xBm,xm")))]
11044   "TARGET_SSE2 && !TARGET_XOP
11045    && ix86_binary_operator_ok (EQ, <MODE>mode, operands)"
11046   "@
11047    pcmpeq<ssemodesuffix>\t{%2, %0|%0, %2}
11048    vpcmpeq<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11049   [(set_attr "isa" "noavx,avx")
11050    (set_attr "type" "ssecmp")
11051    (set_attr "prefix_data16" "1,*")
11052    (set_attr "prefix" "orig,vex")
11053    (set_attr "mode" "TI")])
11055 (define_expand "sse2_eq<mode>3"
11056   [(set (match_operand:VI124_128 0 "register_operand")
11057         (eq:VI124_128
11058           (match_operand:VI124_128 1 "vector_operand")
11059           (match_operand:VI124_128 2 "vector_operand")))]
11060   "TARGET_SSE2 && !TARGET_XOP "
11061   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
11063 (define_expand "sse4_1_eqv2di3"
11064   [(set (match_operand:V2DI 0 "register_operand")
11065         (eq:V2DI
11066           (match_operand:V2DI 1 "vector_operand")
11067           (match_operand:V2DI 2 "vector_operand")))]
11068   "TARGET_SSE4_1"
11069   "ix86_fixup_binary_operands_no_copy (EQ, V2DImode, operands);")
11071 (define_insn "sse4_2_gtv2di3"
11072   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,x")
11073         (gt:V2DI
11074           (match_operand:V2DI 1 "register_operand" "0,0,x")
11075           (match_operand:V2DI 2 "vector_operand" "YrBm,*xBm,xm")))]
11076   "TARGET_SSE4_2"
11077   "@
11078    pcmpgtq\t{%2, %0|%0, %2}
11079    pcmpgtq\t{%2, %0|%0, %2}
11080    vpcmpgtq\t{%2, %1, %0|%0, %1, %2}"
11081   [(set_attr "isa" "noavx,noavx,avx")
11082    (set_attr "type" "ssecmp")
11083    (set_attr "prefix_extra" "1")
11084    (set_attr "prefix" "orig,orig,vex")
11085    (set_attr "mode" "TI")])
11087 (define_insn "avx2_gt<mode>3"
11088   [(set (match_operand:VI_256 0 "register_operand" "=x")
11089         (gt:VI_256
11090           (match_operand:VI_256 1 "register_operand" "x")
11091           (match_operand:VI_256 2 "nonimmediate_operand" "xm")))]
11092   "TARGET_AVX2"
11093   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11094   [(set_attr "type" "ssecmp")
11095    (set_attr "prefix_extra" "1")
11096    (set_attr "prefix" "vex")
11097    (set_attr "mode" "OI")])
11099 (define_insn "<avx512>_gt<mode>3<mask_scalar_merge_name>"
11100   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11101         (unspec:<avx512fmaskmode>
11102           [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
11103            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")] UNSPEC_MASKED_GT))]
11104   "TARGET_AVX512F"
11105   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11106   [(set_attr "type" "ssecmp")
11107    (set_attr "prefix_extra" "1")
11108    (set_attr "prefix" "evex")
11109    (set_attr "mode" "<sseinsnmode>")])
11111 (define_insn "<avx512>_gt<mode>3<mask_scalar_merge_name>"
11112   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11113         (unspec:<avx512fmaskmode>
11114           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
11115            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")] UNSPEC_MASKED_GT))]
11116   "TARGET_AVX512BW"
11117   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11118   [(set_attr "type" "ssecmp")
11119    (set_attr "prefix_extra" "1")
11120    (set_attr "prefix" "evex")
11121    (set_attr "mode" "<sseinsnmode>")])
11123 (define_insn "sse2_gt<mode>3"
11124   [(set (match_operand:VI124_128 0 "register_operand" "=x,x")
11125         (gt:VI124_128
11126           (match_operand:VI124_128 1 "register_operand" "0,x")
11127           (match_operand:VI124_128 2 "vector_operand" "xBm,xm")))]
11128   "TARGET_SSE2 && !TARGET_XOP"
11129   "@
11130    pcmpgt<ssemodesuffix>\t{%2, %0|%0, %2}
11131    vpcmpgt<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
11132   [(set_attr "isa" "noavx,avx")
11133    (set_attr "type" "ssecmp")
11134    (set_attr "prefix_data16" "1,*")
11135    (set_attr "prefix" "orig,vex")
11136    (set_attr "mode" "TI")])
11138 (define_expand "vcond<V_512:mode><VI_512:mode>"
11139   [(set (match_operand:V_512 0 "register_operand")
11140         (if_then_else:V_512
11141           (match_operator 3 ""
11142             [(match_operand:VI_512 4 "nonimmediate_operand")
11143              (match_operand:VI_512 5 "general_operand")])
11144           (match_operand:V_512 1)
11145           (match_operand:V_512 2)))]
11146   "TARGET_AVX512F
11147    && (GET_MODE_NUNITS (<V_512:MODE>mode)
11148        == GET_MODE_NUNITS (<VI_512:MODE>mode))"
11150   bool ok = ix86_expand_int_vcond (operands);
11151   gcc_assert (ok);
11152   DONE;
11155 (define_expand "vcond<V_256:mode><VI_256:mode>"
11156   [(set (match_operand:V_256 0 "register_operand")
11157         (if_then_else:V_256
11158           (match_operator 3 ""
11159             [(match_operand:VI_256 4 "nonimmediate_operand")
11160              (match_operand:VI_256 5 "general_operand")])
11161           (match_operand:V_256 1)
11162           (match_operand:V_256 2)))]
11163   "TARGET_AVX2
11164    && (GET_MODE_NUNITS (<V_256:MODE>mode)
11165        == GET_MODE_NUNITS (<VI_256:MODE>mode))"
11167   bool ok = ix86_expand_int_vcond (operands);
11168   gcc_assert (ok);
11169   DONE;
11172 (define_expand "vcond<V_128:mode><VI124_128:mode>"
11173   [(set (match_operand:V_128 0 "register_operand")
11174         (if_then_else:V_128
11175           (match_operator 3 ""
11176             [(match_operand:VI124_128 4 "vector_operand")
11177              (match_operand:VI124_128 5 "general_operand")])
11178           (match_operand:V_128 1)
11179           (match_operand:V_128 2)))]
11180   "TARGET_SSE2
11181    && (GET_MODE_NUNITS (<V_128:MODE>mode)
11182        == GET_MODE_NUNITS (<VI124_128:MODE>mode))"
11184   bool ok = ix86_expand_int_vcond (operands);
11185   gcc_assert (ok);
11186   DONE;
11189 (define_expand "vcond<VI8F_128:mode>v2di"
11190   [(set (match_operand:VI8F_128 0 "register_operand")
11191         (if_then_else:VI8F_128
11192           (match_operator 3 ""
11193             [(match_operand:V2DI 4 "vector_operand")
11194              (match_operand:V2DI 5 "general_operand")])
11195           (match_operand:VI8F_128 1)
11196           (match_operand:VI8F_128 2)))]
11197   "TARGET_SSE4_2"
11199   bool ok = ix86_expand_int_vcond (operands);
11200   gcc_assert (ok);
11201   DONE;
11204 (define_expand "vcondu<V_512:mode><VI_512:mode>"
11205   [(set (match_operand:V_512 0 "register_operand")
11206         (if_then_else:V_512
11207           (match_operator 3 ""
11208             [(match_operand:VI_512 4 "nonimmediate_operand")
11209              (match_operand:VI_512 5 "nonimmediate_operand")])
11210           (match_operand:V_512 1 "general_operand")
11211           (match_operand:V_512 2 "general_operand")))]
11212   "TARGET_AVX512F
11213    && (GET_MODE_NUNITS (<V_512:MODE>mode)
11214        == GET_MODE_NUNITS (<VI_512:MODE>mode))"
11216   bool ok = ix86_expand_int_vcond (operands);
11217   gcc_assert (ok);
11218   DONE;
11221 (define_expand "vcondu<V_256:mode><VI_256:mode>"
11222   [(set (match_operand:V_256 0 "register_operand")
11223         (if_then_else:V_256
11224           (match_operator 3 ""
11225             [(match_operand:VI_256 4 "nonimmediate_operand")
11226              (match_operand:VI_256 5 "nonimmediate_operand")])
11227           (match_operand:V_256 1 "general_operand")
11228           (match_operand:V_256 2 "general_operand")))]
11229   "TARGET_AVX2
11230    && (GET_MODE_NUNITS (<V_256:MODE>mode)
11231        == GET_MODE_NUNITS (<VI_256:MODE>mode))"
11233   bool ok = ix86_expand_int_vcond (operands);
11234   gcc_assert (ok);
11235   DONE;
11238 (define_expand "vcondu<V_128:mode><VI124_128:mode>"
11239   [(set (match_operand:V_128 0 "register_operand")
11240         (if_then_else:V_128
11241           (match_operator 3 ""
11242             [(match_operand:VI124_128 4 "vector_operand")
11243              (match_operand:VI124_128 5 "vector_operand")])
11244           (match_operand:V_128 1 "general_operand")
11245           (match_operand:V_128 2 "general_operand")))]
11246   "TARGET_SSE2
11247    && (GET_MODE_NUNITS (<V_128:MODE>mode)
11248        == GET_MODE_NUNITS (<VI124_128:MODE>mode))"
11250   bool ok = ix86_expand_int_vcond (operands);
11251   gcc_assert (ok);
11252   DONE;
11255 (define_expand "vcondu<VI8F_128:mode>v2di"
11256   [(set (match_operand:VI8F_128 0 "register_operand")
11257         (if_then_else:VI8F_128
11258           (match_operator 3 ""
11259             [(match_operand:V2DI 4 "vector_operand")
11260              (match_operand:V2DI 5 "vector_operand")])
11261           (match_operand:VI8F_128 1 "general_operand")
11262           (match_operand:VI8F_128 2 "general_operand")))]
11263   "TARGET_SSE4_2"
11265   bool ok = ix86_expand_int_vcond (operands);
11266   gcc_assert (ok);
11267   DONE;
11270 (define_mode_iterator VEC_PERM_AVX2
11271   [V16QI V8HI V4SI V2DI V4SF V2DF
11272    (V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
11273    (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")
11274    (V8SF "TARGET_AVX2") (V4DF "TARGET_AVX2")
11275    (V16SF "TARGET_AVX512F") (V8DF "TARGET_AVX512F")
11276    (V16SI "TARGET_AVX512F") (V8DI "TARGET_AVX512F")
11277    (V32HI "TARGET_AVX512BW") (V64QI "TARGET_AVX512VBMI")])
11279 (define_expand "vec_perm<mode>"
11280   [(match_operand:VEC_PERM_AVX2 0 "register_operand")
11281    (match_operand:VEC_PERM_AVX2 1 "register_operand")
11282    (match_operand:VEC_PERM_AVX2 2 "register_operand")
11283    (match_operand:<sseintvecmode> 3 "register_operand")]
11284   "TARGET_SSSE3 || TARGET_AVX || TARGET_XOP"
11286   ix86_expand_vec_perm (operands);
11287   DONE;
11290 (define_mode_iterator VEC_PERM_CONST
11291   [(V4SF "TARGET_SSE") (V4SI "TARGET_SSE")
11292    (V2DF "TARGET_SSE") (V2DI "TARGET_SSE")
11293    (V16QI "TARGET_SSE2") (V8HI "TARGET_SSE2")
11294    (V8SF "TARGET_AVX") (V4DF "TARGET_AVX")
11295    (V8SI "TARGET_AVX") (V4DI "TARGET_AVX")
11296    (V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
11297    (V16SI "TARGET_AVX512F") (V8DI "TARGET_AVX512F")
11298    (V16SF "TARGET_AVX512F") (V8DF "TARGET_AVX512F")
11299    (V32HI "TARGET_AVX512BW") (V64QI "TARGET_AVX512BW")])
11301 (define_expand "vec_perm_const<mode>"
11302   [(match_operand:VEC_PERM_CONST 0 "register_operand")
11303    (match_operand:VEC_PERM_CONST 1 "register_operand")
11304    (match_operand:VEC_PERM_CONST 2 "register_operand")
11305    (match_operand:<sseintvecmode> 3)]
11306   ""
11308   if (ix86_expand_vec_perm_const (operands))
11309     DONE;
11310   else
11311     FAIL;
11314 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11316 ;; Parallel bitwise logical operations
11318 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11320 (define_expand "one_cmpl<mode>2"
11321   [(set (match_operand:VI 0 "register_operand")
11322         (xor:VI (match_operand:VI 1 "vector_operand")
11323                 (match_dup 2)))]
11324   "TARGET_SSE"
11326   int i, n = GET_MODE_NUNITS (<MODE>mode);
11327   rtvec v = rtvec_alloc (n);
11329   for (i = 0; i < n; ++i)
11330     RTVEC_ELT (v, i) = constm1_rtx;
11332   operands[2] = force_reg (<MODE>mode, gen_rtx_CONST_VECTOR (<MODE>mode, v));
11335 (define_expand "<sse2_avx2>_andnot<mode>3"
11336   [(set (match_operand:VI_AVX2 0 "register_operand")
11337         (and:VI_AVX2
11338           (not:VI_AVX2 (match_operand:VI_AVX2 1 "register_operand"))
11339           (match_operand:VI_AVX2 2 "vector_operand")))]
11340   "TARGET_SSE2")
11342 (define_expand "<sse2_avx2>_andnot<mode>3_mask"
11343   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
11344         (vec_merge:VI48_AVX512VL
11345           (and:VI48_AVX512VL
11346             (not:VI48_AVX512VL
11347               (match_operand:VI48_AVX512VL 1 "register_operand"))
11348             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
11349           (match_operand:VI48_AVX512VL 3 "vector_move_operand")
11350           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
11351   "TARGET_AVX512F")
11353 (define_expand "<sse2_avx2>_andnot<mode>3_mask"
11354   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
11355         (vec_merge:VI12_AVX512VL
11356           (and:VI12_AVX512VL
11357             (not:VI12_AVX512VL
11358               (match_operand:VI12_AVX512VL 1 "register_operand"))
11359             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand"))
11360           (match_operand:VI12_AVX512VL 3 "vector_move_operand")
11361           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
11362   "TARGET_AVX512BW")
11364 (define_insn "*andnot<mode>3"
11365   [(set (match_operand:VI 0 "register_operand" "=x,v")
11366         (and:VI
11367           (not:VI (match_operand:VI 1 "register_operand" "0,v"))
11368           (match_operand:VI 2 "vector_operand" "xBm,vm")))]
11369   "TARGET_SSE"
11371   static char buf[64];
11372   const char *ops;
11373   const char *tmp;
11375   switch (get_attr_mode (insn))
11376     {
11377     case MODE_XI:
11378       gcc_assert (TARGET_AVX512F);
11379     case MODE_OI:
11380       gcc_assert (TARGET_AVX2);
11381     case MODE_TI:
11382       gcc_assert (TARGET_SSE2);
11383       switch (<MODE>mode)
11384         {
11385         case V64QImode:
11386         case V32HImode:
11387           /* There is no vpandnb or vpandnw instruction, nor vpandn for
11388              512-bit vectors. Use vpandnq instead.  */
11389           tmp = "pandnq";
11390           break;
11391         case V16SImode:
11392         case V8DImode:
11393           tmp = "pandn<ssemodesuffix>";
11394           break;
11395         case V8SImode:
11396         case V4DImode:
11397         case V4SImode:
11398         case V2DImode:
11399           tmp = TARGET_AVX512VL ? "pandn<ssemodesuffix>" : "pandn";
11400           break;
11401         default:
11402           tmp = TARGET_AVX512VL ? "pandnq" : "pandn";
11403           break;
11404         }
11405       break;
11407     case MODE_V16SF:
11408       gcc_assert (TARGET_AVX512F);
11409     case MODE_V8SF:
11410       gcc_assert (TARGET_AVX);
11411     case MODE_V4SF:
11412       gcc_assert (TARGET_SSE);
11414       tmp = "andnps";
11415       break;
11417     default:
11418       gcc_unreachable ();
11419     }
11421   switch (which_alternative)
11422     {
11423     case 0:
11424       ops = "%s\t{%%2, %%0|%%0, %%2}";
11425       break;
11426     case 1:
11427       ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
11428       break;
11429     default:
11430       gcc_unreachable ();
11431     }
11433   snprintf (buf, sizeof (buf), ops, tmp);
11434   return buf;
11436   [(set_attr "isa" "noavx,avx")
11437    (set_attr "type" "sselog")
11438    (set (attr "prefix_data16")
11439      (if_then_else
11440        (and (eq_attr "alternative" "0")
11441             (eq_attr "mode" "TI"))
11442        (const_string "1")
11443        (const_string "*")))
11444    (set_attr "prefix" "orig,vex")
11445    (set (attr "mode")
11446         (cond [(and (match_test "<MODE_SIZE> == 16")
11447                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
11448                  (const_string "<ssePSmode>")
11449                (match_test "TARGET_AVX2")
11450                  (const_string "<sseinsnmode>")
11451                (match_test "TARGET_AVX")
11452                  (if_then_else
11453                    (match_test "<MODE_SIZE> > 16")
11454                    (const_string "V8SF")
11455                    (const_string "<sseinsnmode>"))
11456                (ior (not (match_test "TARGET_SSE2"))
11457                     (match_test "optimize_function_for_size_p (cfun)"))
11458                  (const_string "V4SF")
11459               ]
11460               (const_string "<sseinsnmode>")))])
11462 (define_insn "*andnot<mode>3_mask"
11463   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
11464         (vec_merge:VI48_AVX512VL
11465           (and:VI48_AVX512VL
11466             (not:VI48_AVX512VL
11467               (match_operand:VI48_AVX512VL 1 "register_operand" "v"))
11468             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm"))
11469           (match_operand:VI48_AVX512VL 3 "vector_move_operand" "0C")
11470           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
11471   "TARGET_AVX512F"
11472   "vpandn<ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}";
11473   [(set_attr "type" "sselog")
11474    (set_attr "prefix" "evex")
11475    (set_attr "mode" "<sseinsnmode>")])
11477 (define_expand "<code><mode>3"
11478   [(set (match_operand:VI 0 "register_operand")
11479         (any_logic:VI
11480           (match_operand:VI 1 "nonimmediate_or_const_vector_operand")
11481           (match_operand:VI 2 "nonimmediate_or_const_vector_operand")))]
11482   "TARGET_SSE"
11484   ix86_expand_vector_logical_operator (<CODE>, <MODE>mode, operands);
11485   DONE;
11488 (define_insn "<mask_codefor><code><mode>3<mask_name>"
11489   [(set (match_operand:VI48_AVX_AVX512F 0 "register_operand" "=x,v")
11490         (any_logic:VI48_AVX_AVX512F
11491           (match_operand:VI48_AVX_AVX512F 1 "vector_operand" "%0,v")
11492           (match_operand:VI48_AVX_AVX512F 2 "vector_operand" "xBm,vm")))]
11493   "TARGET_SSE && <mask_mode512bit_condition>
11494    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
11496   static char buf[64];
11497   const char *ops;
11498   const char *tmp;
11500   switch (get_attr_mode (insn))
11501     {
11502     case MODE_XI:
11503       gcc_assert (TARGET_AVX512F);
11504     case MODE_OI:
11505       gcc_assert (TARGET_AVX2 || TARGET_AVX512VL);
11506     case MODE_TI:
11507       gcc_assert (TARGET_SSE2 || TARGET_AVX512VL);
11508       switch (<MODE>mode)
11509       {
11510         case V16SImode:
11511         case V8DImode:
11512           if (TARGET_AVX512F)
11513           {
11514             tmp = "p<logic><ssemodesuffix>";
11515             break;
11516           }
11517         case V8SImode:
11518         case V4DImode:
11519         case V4SImode:
11520         case V2DImode:
11521           tmp = TARGET_AVX512VL ? "p<logic><ssemodesuffix>" : "p<logic>";
11522           break;
11523         default:
11524           gcc_unreachable ();
11525       }
11526       break;
11528    case MODE_V8SF:
11529       gcc_assert (TARGET_AVX);
11530    case MODE_V4SF:
11531       gcc_assert (TARGET_SSE);
11532       gcc_assert (!<mask_applied>);
11533       tmp = "<logic>ps";
11534       break;
11536    default:
11537       gcc_unreachable ();
11538    }
11540   switch (which_alternative)
11541     {
11542     case 0:
11543       if (<mask_applied>)
11544         ops = "v%s\t{%%2, %%0, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%0, %%2}";
11545       else
11546         ops = "%s\t{%%2, %%0|%%0, %%2}";
11547       break;
11548     case 1:
11549       ops = "v%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
11550       break;
11551     default:
11552       gcc_unreachable ();
11553     }
11555   snprintf (buf, sizeof (buf), ops, tmp);
11556   return buf;
11558   [(set_attr "isa" "noavx,avx")
11559    (set_attr "type" "sselog")
11560    (set (attr "prefix_data16")
11561      (if_then_else
11562        (and (eq_attr "alternative" "0")
11563             (eq_attr "mode" "TI"))
11564        (const_string "1")
11565        (const_string "*")))
11566    (set_attr "prefix" "<mask_prefix3>")
11567    (set (attr "mode")
11568         (cond [(and (match_test "<MODE_SIZE> == 16")
11569                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
11570                  (const_string "<ssePSmode>")
11571                (match_test "TARGET_AVX2")
11572                  (const_string "<sseinsnmode>")
11573                (match_test "TARGET_AVX")
11574                  (if_then_else
11575                    (match_test "<MODE_SIZE> > 16")
11576                    (const_string "V8SF")
11577                    (const_string "<sseinsnmode>"))
11578                (ior (not (match_test "TARGET_SSE2"))
11579                     (match_test "optimize_function_for_size_p (cfun)"))
11580                  (const_string "V4SF")
11581               ]
11582               (const_string "<sseinsnmode>")))])
11584 (define_insn "*<code><mode>3"
11585   [(set (match_operand:VI12_AVX_AVX512F 0 "register_operand" "=x,v")
11586         (any_logic: VI12_AVX_AVX512F
11587           (match_operand:VI12_AVX_AVX512F 1 "vector_operand" "%0,v")
11588           (match_operand:VI12_AVX_AVX512F 2 "vector_operand" "xBm,vm")))]
11589   "TARGET_SSE && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
11591   static char buf[64];
11592   const char *ops;
11593   const char *tmp;
11594   const char *ssesuffix;
11596   switch (get_attr_mode (insn))
11597     {
11598     case MODE_XI:
11599       gcc_assert (TARGET_AVX512F);
11600     case MODE_OI:
11601       gcc_assert (TARGET_AVX2 || TARGET_AVX512VL);
11602     case MODE_TI:
11603       gcc_assert (TARGET_SSE2 || TARGET_AVX512VL);
11604       switch (<MODE>mode)
11605         {
11606         case V64QImode:
11607         case V32HImode:
11608           if (TARGET_AVX512F)
11609           {
11610             tmp = "p<logic>";
11611             ssesuffix = "q";
11612             break;
11613           }
11614         case V32QImode:
11615         case V16HImode:
11616         case V16QImode:
11617         case V8HImode:
11618           if (TARGET_AVX512VL || TARGET_AVX2 || TARGET_SSE2)
11619           {
11620             tmp = "p<logic>";
11621             ssesuffix = TARGET_AVX512VL ? "q" : "";
11622             break;
11623           }
11624         default:
11625           gcc_unreachable ();
11626       }
11627       break;
11629    case MODE_V8SF:
11630       gcc_assert (TARGET_AVX);
11631    case MODE_V4SF:
11632       gcc_assert (TARGET_SSE);
11633       tmp = "<logic>ps";
11634       ssesuffix = "";
11635       break;
11637    default:
11638       gcc_unreachable ();
11639    }
11641   switch (which_alternative)
11642     {
11643     case 0:
11644       ops = "%s\t{%%2, %%0|%%0, %%2}";
11645       snprintf (buf, sizeof (buf), ops, tmp);
11646       break;
11647     case 1:
11648       ops = "v%s%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
11649       snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
11650       break;
11651     default:
11652       gcc_unreachable ();
11653     }
11655   return buf;
11657   [(set_attr "isa" "noavx,avx")
11658    (set_attr "type" "sselog")
11659    (set (attr "prefix_data16")
11660      (if_then_else
11661        (and (eq_attr "alternative" "0")
11662             (eq_attr "mode" "TI"))
11663        (const_string "1")
11664        (const_string "*")))
11665    (set_attr "prefix" "<mask_prefix3>")
11666    (set (attr "mode")
11667         (cond [(and (match_test "<MODE_SIZE> == 16")
11668                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
11669                  (const_string "<ssePSmode>")
11670                (match_test "TARGET_AVX2")
11671                  (const_string "<sseinsnmode>")
11672                (match_test "TARGET_AVX")
11673                  (if_then_else
11674                    (match_test "<MODE_SIZE> > 16")
11675                    (const_string "V8SF")
11676                    (const_string "<sseinsnmode>"))
11677                (ior (not (match_test "TARGET_SSE2"))
11678                     (match_test "optimize_function_for_size_p (cfun)"))
11679                  (const_string "V4SF")
11680               ]
11681               (const_string "<sseinsnmode>")))])
11683 (define_insn "<avx512>_testm<mode>3<mask_scalar_merge_name>"
11684   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11685         (unspec:<avx512fmaskmode>
11686          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
11687           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")]
11688          UNSPEC_TESTM))]
11689   "TARGET_AVX512BW"
11690   "vptestm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11691   [(set_attr "prefix" "evex")
11692    (set_attr "mode"  "<sseinsnmode>")])
11694 (define_insn "<avx512>_testm<mode>3<mask_scalar_merge_name>"
11695   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11696         (unspec:<avx512fmaskmode>
11697          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
11698           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")]
11699          UNSPEC_TESTM))]
11700   "TARGET_AVX512F"
11701   "vptestm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11702   [(set_attr "prefix" "evex")
11703    (set_attr "mode"  "<sseinsnmode>")])
11705 (define_insn "<avx512>_testnm<mode>3<mask_scalar_merge_name>"
11706   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11707         (unspec:<avx512fmaskmode>
11708          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
11709           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")]
11710          UNSPEC_TESTNM))]
11711   "TARGET_AVX512BW"
11712   "vptestnm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11713   [(set_attr "prefix" "evex")
11714    (set_attr "mode"  "<sseinsnmode>")])
11716 (define_insn "<avx512>_testnm<mode>3<mask_scalar_merge_name>"
11717   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11718         (unspec:<avx512fmaskmode>
11719          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
11720           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")]
11721          UNSPEC_TESTNM))]
11722   "TARGET_AVX512F"
11723   "vptestnm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11724   [(set_attr "prefix" "evex")
11725    (set_attr "mode"  "<sseinsnmode>")])
11727 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11729 ;; Parallel integral element swizzling
11731 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11733 (define_expand "vec_pack_trunc_<mode>"
11734   [(match_operand:<ssepackmode> 0 "register_operand")
11735    (match_operand:VI248_AVX2_8_AVX512F_24_AVX512BW 1 "register_operand")
11736    (match_operand:VI248_AVX2_8_AVX512F_24_AVX512BW 2 "register_operand")]
11737   "TARGET_SSE2"
11739   rtx op1 = gen_lowpart (<ssepackmode>mode, operands[1]);
11740   rtx op2 = gen_lowpart (<ssepackmode>mode, operands[2]);
11741   ix86_expand_vec_extract_even_odd (operands[0], op1, op2, 0);
11742   DONE;
11745 (define_expand "vec_pack_trunc_qi"
11746   [(set (match_operand:HI 0 ("register_operand"))
11747         (ior:HI (ashift:HI (zero_extend:HI (match_operand:QI 1 ("register_operand")))
11748                            (const_int 8))
11749                 (zero_extend:HI (match_operand:QI 2 ("register_operand")))))]
11750   "TARGET_AVX512F")
11752 (define_expand "vec_pack_trunc_<mode>"
11753   [(set (match_operand:<DOUBLEMASKMODE> 0 ("register_operand"))
11754         (ior:<DOUBLEMASKMODE> (ashift:<DOUBLEMASKMODE> (zero_extend:<DOUBLEMASKMODE> (match_operand:SWI24 1 ("register_operand")))
11755                            (match_dup 3))
11756                 (zero_extend:<DOUBLEMASKMODE> (match_operand:SWI24 2 ("register_operand")))))]
11757   "TARGET_AVX512BW"
11759   operands[3] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
11762 (define_insn "<sse2_avx2>_packsswb<mask_name>"
11763   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x")
11764         (vec_concat:VI1_AVX512
11765           (ss_truncate:<ssehalfvecmode>
11766             (match_operand:<sseunpackmode> 1 "register_operand" "0,v"))
11767           (ss_truncate:<ssehalfvecmode>
11768             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,vm"))))]
11769   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
11770   "@
11771    packsswb\t{%2, %0|%0, %2}
11772    vpacksswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11773   [(set_attr "isa" "noavx,avx")
11774    (set_attr "type" "sselog")
11775    (set_attr "prefix_data16" "1,*")
11776    (set_attr "prefix" "orig,maybe_evex")
11777    (set_attr "mode" "<sseinsnmode>")])
11779 (define_insn "<sse2_avx2>_packssdw<mask_name>"
11780   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,v")
11781         (vec_concat:VI2_AVX2
11782           (ss_truncate:<ssehalfvecmode>
11783             (match_operand:<sseunpackmode> 1 "register_operand" "0,v"))
11784           (ss_truncate:<ssehalfvecmode>
11785             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,vm"))))]
11786   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
11787   "@
11788    packssdw\t{%2, %0|%0, %2}
11789    vpackssdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11790   [(set_attr "isa" "noavx,avx")
11791    (set_attr "type" "sselog")
11792    (set_attr "prefix_data16" "1,*")
11793    (set_attr "prefix" "orig,vex")
11794    (set_attr "mode" "<sseinsnmode>")])
11796 (define_insn "<sse2_avx2>_packuswb<mask_name>"
11797   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x")
11798         (vec_concat:VI1_AVX512
11799           (us_truncate:<ssehalfvecmode>
11800             (match_operand:<sseunpackmode> 1 "register_operand" "0,v"))
11801           (us_truncate:<ssehalfvecmode>
11802             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,vm"))))]
11803   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
11804   "@
11805    packuswb\t{%2, %0|%0, %2}
11806    vpackuswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11807   [(set_attr "isa" "noavx,avx")
11808    (set_attr "type" "sselog")
11809    (set_attr "prefix_data16" "1,*")
11810    (set_attr "prefix" "orig,vex")
11811    (set_attr "mode" "<sseinsnmode>")])
11813 (define_insn "avx512bw_interleave_highv64qi<mask_name>"
11814   [(set (match_operand:V64QI 0 "register_operand" "=v")
11815         (vec_select:V64QI
11816           (vec_concat:V128QI
11817             (match_operand:V64QI 1 "register_operand" "v")
11818             (match_operand:V64QI 2 "nonimmediate_operand" "vm"))
11819           (parallel [(const_int 8)  (const_int 72)
11820                      (const_int 9)  (const_int 73)
11821                      (const_int 10) (const_int 74)
11822                      (const_int 11) (const_int 75)
11823                      (const_int 12) (const_int 76)
11824                      (const_int 13) (const_int 77)
11825                      (const_int 14) (const_int 78)
11826                      (const_int 15) (const_int 79)
11827                      (const_int 24) (const_int 88)
11828                      (const_int 25) (const_int 89)
11829                      (const_int 26) (const_int 90)
11830                      (const_int 27) (const_int 91)
11831                      (const_int 28) (const_int 92)
11832                      (const_int 29) (const_int 93)
11833                      (const_int 30) (const_int 94)
11834                      (const_int 31) (const_int 95)
11835                      (const_int 40) (const_int 104)
11836                      (const_int 41) (const_int 105)
11837                      (const_int 42) (const_int 106)
11838                      (const_int 43) (const_int 107)
11839                      (const_int 44) (const_int 108)
11840                      (const_int 45) (const_int 109)
11841                      (const_int 46) (const_int 110)
11842                      (const_int 47) (const_int 111)
11843                      (const_int 56) (const_int 120)
11844                      (const_int 57) (const_int 121)
11845                      (const_int 58) (const_int 122)
11846                      (const_int 59) (const_int 123)
11847                      (const_int 60) (const_int 124)
11848                      (const_int 61) (const_int 125)
11849                      (const_int 62) (const_int 126)
11850                      (const_int 63) (const_int 127)])))]
11851   "TARGET_AVX512BW"
11852   "vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11853   [(set_attr "type" "sselog")
11854    (set_attr "prefix" "evex")
11855    (set_attr "mode" "XI")])
11857 (define_insn "avx2_interleave_highv32qi<mask_name>"
11858   [(set (match_operand:V32QI 0 "register_operand" "=v")
11859         (vec_select:V32QI
11860           (vec_concat:V64QI
11861             (match_operand:V32QI 1 "register_operand" "v")
11862             (match_operand:V32QI 2 "nonimmediate_operand" "vm"))
11863           (parallel [(const_int 8)  (const_int 40)
11864                      (const_int 9)  (const_int 41)
11865                      (const_int 10) (const_int 42)
11866                      (const_int 11) (const_int 43)
11867                      (const_int 12) (const_int 44)
11868                      (const_int 13) (const_int 45)
11869                      (const_int 14) (const_int 46)
11870                      (const_int 15) (const_int 47)
11871                      (const_int 24) (const_int 56)
11872                      (const_int 25) (const_int 57)
11873                      (const_int 26) (const_int 58)
11874                      (const_int 27) (const_int 59)
11875                      (const_int 28) (const_int 60)
11876                      (const_int 29) (const_int 61)
11877                      (const_int 30) (const_int 62)
11878                      (const_int 31) (const_int 63)])))]
11879   "TARGET_AVX2 && <mask_avx512vl_condition>"
11880   "vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11881   [(set_attr "type" "sselog")
11882    (set_attr "prefix" "<mask_prefix>")
11883    (set_attr "mode" "OI")])
11885 (define_insn "vec_interleave_highv16qi<mask_name>"
11886   [(set (match_operand:V16QI 0 "register_operand" "=x,v")
11887         (vec_select:V16QI
11888           (vec_concat:V32QI
11889             (match_operand:V16QI 1 "register_operand" "0,v")
11890             (match_operand:V16QI 2 "vector_operand" "xBm,vm"))
11891           (parallel [(const_int 8)  (const_int 24)
11892                      (const_int 9)  (const_int 25)
11893                      (const_int 10) (const_int 26)
11894                      (const_int 11) (const_int 27)
11895                      (const_int 12) (const_int 28)
11896                      (const_int 13) (const_int 29)
11897                      (const_int 14) (const_int 30)
11898                      (const_int 15) (const_int 31)])))]
11899   "TARGET_SSE2 && <mask_avx512vl_condition>"
11900   "@
11901    punpckhbw\t{%2, %0|%0, %2}
11902    vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11903   [(set_attr "isa" "noavx,avx")
11904    (set_attr "type" "sselog")
11905    (set_attr "prefix_data16" "1,*")
11906    (set_attr "prefix" "orig,<mask_prefix>")
11907    (set_attr "mode" "TI")])
11909 (define_insn "avx512bw_interleave_lowv64qi<mask_name>"
11910   [(set (match_operand:V64QI 0 "register_operand" "=v")
11911         (vec_select:V64QI
11912           (vec_concat:V128QI
11913             (match_operand:V64QI 1 "register_operand" "v")
11914             (match_operand:V64QI 2 "nonimmediate_operand" "vm"))
11915           (parallel [(const_int 0) (const_int 64)
11916                      (const_int 1) (const_int 65)
11917                      (const_int 2) (const_int 66)
11918                      (const_int 3) (const_int 67)
11919                      (const_int 4) (const_int 68)
11920                      (const_int 5) (const_int 69)
11921                      (const_int 6) (const_int 70)
11922                      (const_int 7) (const_int 71)
11923                      (const_int 16) (const_int 80)
11924                      (const_int 17) (const_int 81)
11925                      (const_int 18) (const_int 82)
11926                      (const_int 19) (const_int 83)
11927                      (const_int 20) (const_int 84)
11928                      (const_int 21) (const_int 85)
11929                      (const_int 22) (const_int 86)
11930                      (const_int 23) (const_int 87)
11931                      (const_int 32) (const_int 96)
11932                      (const_int 33) (const_int 97)
11933                      (const_int 34) (const_int 98)
11934                      (const_int 35) (const_int 99)
11935                      (const_int 36) (const_int 100)
11936                      (const_int 37) (const_int 101)
11937                      (const_int 38) (const_int 102)
11938                      (const_int 39) (const_int 103)
11939                      (const_int 48) (const_int 112)
11940                      (const_int 49) (const_int 113)
11941                      (const_int 50) (const_int 114)
11942                      (const_int 51) (const_int 115)
11943                      (const_int 52) (const_int 116)
11944                      (const_int 53) (const_int 117)
11945                      (const_int 54) (const_int 118)
11946                      (const_int 55) (const_int 119)])))]
11947   "TARGET_AVX512BW"
11948   "vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11949   [(set_attr "type" "sselog")
11950    (set_attr "prefix" "evex")
11951    (set_attr "mode" "XI")])
11953 (define_insn "avx2_interleave_lowv32qi<mask_name>"
11954   [(set (match_operand:V32QI 0 "register_operand" "=v")
11955         (vec_select:V32QI
11956           (vec_concat:V64QI
11957             (match_operand:V32QI 1 "register_operand" "v")
11958             (match_operand:V32QI 2 "nonimmediate_operand" "vm"))
11959           (parallel [(const_int 0) (const_int 32)
11960                      (const_int 1) (const_int 33)
11961                      (const_int 2) (const_int 34)
11962                      (const_int 3) (const_int 35)
11963                      (const_int 4) (const_int 36)
11964                      (const_int 5) (const_int 37)
11965                      (const_int 6) (const_int 38)
11966                      (const_int 7) (const_int 39)
11967                      (const_int 16) (const_int 48)
11968                      (const_int 17) (const_int 49)
11969                      (const_int 18) (const_int 50)
11970                      (const_int 19) (const_int 51)
11971                      (const_int 20) (const_int 52)
11972                      (const_int 21) (const_int 53)
11973                      (const_int 22) (const_int 54)
11974                      (const_int 23) (const_int 55)])))]
11975   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
11976   "vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11977   [(set_attr "type" "sselog")
11978    (set_attr "prefix" "maybe_vex")
11979    (set_attr "mode" "OI")])
11981 (define_insn "vec_interleave_lowv16qi<mask_name>"
11982   [(set (match_operand:V16QI 0 "register_operand" "=x,v")
11983         (vec_select:V16QI
11984           (vec_concat:V32QI
11985             (match_operand:V16QI 1 "register_operand" "0,v")
11986             (match_operand:V16QI 2 "vector_operand" "xBm,vm"))
11987           (parallel [(const_int 0) (const_int 16)
11988                      (const_int 1) (const_int 17)
11989                      (const_int 2) (const_int 18)
11990                      (const_int 3) (const_int 19)
11991                      (const_int 4) (const_int 20)
11992                      (const_int 5) (const_int 21)
11993                      (const_int 6) (const_int 22)
11994                      (const_int 7) (const_int 23)])))]
11995   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
11996   "@
11997    punpcklbw\t{%2, %0|%0, %2}
11998    vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11999   [(set_attr "isa" "noavx,avx")
12000    (set_attr "type" "sselog")
12001    (set_attr "prefix_data16" "1,*")
12002    (set_attr "prefix" "orig,vex")
12003    (set_attr "mode" "TI")])
12005 (define_insn "avx512bw_interleave_highv32hi<mask_name>"
12006   [(set (match_operand:V32HI 0 "register_operand" "=v")
12007         (vec_select:V32HI
12008           (vec_concat:V64HI
12009             (match_operand:V32HI 1 "register_operand" "v")
12010             (match_operand:V32HI 2 "nonimmediate_operand" "vm"))
12011           (parallel [(const_int 4) (const_int 36)
12012                      (const_int 5) (const_int 37)
12013                      (const_int 6) (const_int 38)
12014                      (const_int 7) (const_int 39)
12015                      (const_int 12) (const_int 44)
12016                      (const_int 13) (const_int 45)
12017                      (const_int 14) (const_int 46)
12018                      (const_int 15) (const_int 47)
12019                      (const_int 20) (const_int 52)
12020                      (const_int 21) (const_int 53)
12021                      (const_int 22) (const_int 54)
12022                      (const_int 23) (const_int 55)
12023                      (const_int 28) (const_int 60)
12024                      (const_int 29) (const_int 61)
12025                      (const_int 30) (const_int 62)
12026                      (const_int 31) (const_int 63)])))]
12027   "TARGET_AVX512BW"
12028   "vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12029   [(set_attr "type" "sselog")
12030    (set_attr "prefix" "evex")
12031    (set_attr "mode" "XI")])
12033 (define_insn "avx2_interleave_highv16hi<mask_name>"
12034   [(set (match_operand:V16HI 0 "register_operand" "=v")
12035         (vec_select:V16HI
12036           (vec_concat:V32HI
12037             (match_operand:V16HI 1 "register_operand" "v")
12038             (match_operand:V16HI 2 "nonimmediate_operand" "vm"))
12039           (parallel [(const_int 4) (const_int 20)
12040                      (const_int 5) (const_int 21)
12041                      (const_int 6) (const_int 22)
12042                      (const_int 7) (const_int 23)
12043                      (const_int 12) (const_int 28)
12044                      (const_int 13) (const_int 29)
12045                      (const_int 14) (const_int 30)
12046                      (const_int 15) (const_int 31)])))]
12047   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12048   "vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12049   [(set_attr "type" "sselog")
12050    (set_attr "prefix" "maybe_evex")
12051    (set_attr "mode" "OI")])
12053 (define_insn "vec_interleave_highv8hi<mask_name>"
12054   [(set (match_operand:V8HI 0 "register_operand" "=x,v")
12055         (vec_select:V8HI
12056           (vec_concat:V16HI
12057             (match_operand:V8HI 1 "register_operand" "0,v")
12058             (match_operand:V8HI 2 "vector_operand" "xBm,vm"))
12059           (parallel [(const_int 4) (const_int 12)
12060                      (const_int 5) (const_int 13)
12061                      (const_int 6) (const_int 14)
12062                      (const_int 7) (const_int 15)])))]
12063   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12064   "@
12065    punpckhwd\t{%2, %0|%0, %2}
12066    vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12067   [(set_attr "isa" "noavx,avx")
12068    (set_attr "type" "sselog")
12069    (set_attr "prefix_data16" "1,*")
12070    (set_attr "prefix" "orig,maybe_vex")
12071    (set_attr "mode" "TI")])
12073 (define_insn "<mask_codefor>avx512bw_interleave_lowv32hi<mask_name>"
12074   [(set (match_operand:V32HI 0 "register_operand" "=v")
12075         (vec_select:V32HI
12076           (vec_concat:V64HI
12077             (match_operand:V32HI 1 "register_operand" "v")
12078             (match_operand:V32HI 2 "nonimmediate_operand" "vm"))
12079           (parallel [(const_int 0) (const_int 32)
12080                      (const_int 1) (const_int 33)
12081                      (const_int 2) (const_int 34)
12082                      (const_int 3) (const_int 35)
12083                      (const_int 8) (const_int 40)
12084                      (const_int 9) (const_int 41)
12085                      (const_int 10) (const_int 42)
12086                      (const_int 11) (const_int 43)
12087                      (const_int 16) (const_int 48)
12088                      (const_int 17) (const_int 49)
12089                      (const_int 18) (const_int 50)
12090                      (const_int 19) (const_int 51)
12091                      (const_int 24) (const_int 56)
12092                      (const_int 25) (const_int 57)
12093                      (const_int 26) (const_int 58)
12094                      (const_int 27) (const_int 59)])))]
12095   "TARGET_AVX512BW"
12096   "vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12097   [(set_attr "type" "sselog")
12098    (set_attr "prefix" "evex")
12099    (set_attr "mode" "XI")])
12101 (define_insn "avx2_interleave_lowv16hi<mask_name>"
12102   [(set (match_operand:V16HI 0 "register_operand" "=v")
12103         (vec_select:V16HI
12104           (vec_concat:V32HI
12105             (match_operand:V16HI 1 "register_operand" "v")
12106             (match_operand:V16HI 2 "nonimmediate_operand" "vm"))
12107           (parallel [(const_int 0) (const_int 16)
12108                      (const_int 1) (const_int 17)
12109                      (const_int 2) (const_int 18)
12110                      (const_int 3) (const_int 19)
12111                      (const_int 8) (const_int 24)
12112                      (const_int 9) (const_int 25)
12113                      (const_int 10) (const_int 26)
12114                      (const_int 11) (const_int 27)])))]
12115   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12116   "vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12117   [(set_attr "type" "sselog")
12118    (set_attr "prefix" "maybe_evex")
12119    (set_attr "mode" "OI")])
12121 (define_insn "vec_interleave_lowv8hi<mask_name>"
12122   [(set (match_operand:V8HI 0 "register_operand" "=x,v")
12123         (vec_select:V8HI
12124           (vec_concat:V16HI
12125             (match_operand:V8HI 1 "register_operand" "0,v")
12126             (match_operand:V8HI 2 "vector_operand" "xBm,vm"))
12127           (parallel [(const_int 0) (const_int 8)
12128                      (const_int 1) (const_int 9)
12129                      (const_int 2) (const_int 10)
12130                      (const_int 3) (const_int 11)])))]
12131   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
12132   "@
12133    punpcklwd\t{%2, %0|%0, %2}
12134    vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12135   [(set_attr "isa" "noavx,avx")
12136    (set_attr "type" "sselog")
12137    (set_attr "prefix_data16" "1,*")
12138    (set_attr "prefix" "orig,maybe_evex")
12139    (set_attr "mode" "TI")])
12141 (define_insn "avx2_interleave_highv8si<mask_name>"
12142   [(set (match_operand:V8SI 0 "register_operand" "=v")
12143         (vec_select:V8SI
12144           (vec_concat:V16SI
12145             (match_operand:V8SI 1 "register_operand" "v")
12146             (match_operand:V8SI 2 "nonimmediate_operand" "vm"))
12147           (parallel [(const_int 2) (const_int 10)
12148                      (const_int 3) (const_int 11)
12149                      (const_int 6) (const_int 14)
12150                      (const_int 7) (const_int 15)])))]
12151   "TARGET_AVX2 && <mask_avx512vl_condition>"
12152   "vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12153   [(set_attr "type" "sselog")
12154    (set_attr "prefix" "maybe_evex")
12155    (set_attr "mode" "OI")])
12157 (define_insn "<mask_codefor>avx512f_interleave_highv16si<mask_name>"
12158   [(set (match_operand:V16SI 0 "register_operand" "=v")
12159         (vec_select:V16SI
12160           (vec_concat:V32SI
12161             (match_operand:V16SI 1 "register_operand" "v")
12162             (match_operand:V16SI 2 "nonimmediate_operand" "vm"))
12163           (parallel [(const_int 2) (const_int 18)
12164                      (const_int 3) (const_int 19)
12165                      (const_int 6) (const_int 22)
12166                      (const_int 7) (const_int 23)
12167                      (const_int 10) (const_int 26)
12168                      (const_int 11) (const_int 27)
12169                      (const_int 14) (const_int 30)
12170                      (const_int 15) (const_int 31)])))]
12171   "TARGET_AVX512F"
12172   "vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12173   [(set_attr "type" "sselog")
12174    (set_attr "prefix" "evex")
12175    (set_attr "mode" "XI")])
12178 (define_insn "vec_interleave_highv4si<mask_name>"
12179   [(set (match_operand:V4SI 0 "register_operand" "=x,v")
12180         (vec_select:V4SI
12181           (vec_concat:V8SI
12182             (match_operand:V4SI 1 "register_operand" "0,v")
12183             (match_operand:V4SI 2 "vector_operand" "xBm,vm"))
12184           (parallel [(const_int 2) (const_int 6)
12185                      (const_int 3) (const_int 7)])))]
12186   "TARGET_SSE2 && <mask_avx512vl_condition>"
12187   "@
12188    punpckhdq\t{%2, %0|%0, %2}
12189    vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12190   [(set_attr "isa" "noavx,avx")
12191    (set_attr "type" "sselog")
12192    (set_attr "prefix_data16" "1,*")
12193    (set_attr "prefix" "orig,maybe_vex")
12194    (set_attr "mode" "TI")])
12196 (define_insn "avx2_interleave_lowv8si<mask_name>"
12197   [(set (match_operand:V8SI 0 "register_operand" "=v")
12198         (vec_select:V8SI
12199           (vec_concat:V16SI
12200             (match_operand:V8SI 1 "register_operand" "v")
12201             (match_operand:V8SI 2 "nonimmediate_operand" "vm"))
12202           (parallel [(const_int 0) (const_int 8)
12203                      (const_int 1) (const_int 9)
12204                      (const_int 4) (const_int 12)
12205                      (const_int 5) (const_int 13)])))]
12206   "TARGET_AVX2 && <mask_avx512vl_condition>"
12207   "vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12208   [(set_attr "type" "sselog")
12209    (set_attr "prefix" "maybe_evex")
12210    (set_attr "mode" "OI")])
12212 (define_insn "<mask_codefor>avx512f_interleave_lowv16si<mask_name>"
12213   [(set (match_operand:V16SI 0 "register_operand" "=v")
12214         (vec_select:V16SI
12215           (vec_concat:V32SI
12216             (match_operand:V16SI 1 "register_operand" "v")
12217             (match_operand:V16SI 2 "nonimmediate_operand" "vm"))
12218           (parallel [(const_int 0) (const_int 16)
12219                      (const_int 1) (const_int 17)
12220                      (const_int 4) (const_int 20)
12221                      (const_int 5) (const_int 21)
12222                      (const_int 8) (const_int 24)
12223                      (const_int 9) (const_int 25)
12224                      (const_int 12) (const_int 28)
12225                      (const_int 13) (const_int 29)])))]
12226   "TARGET_AVX512F"
12227   "vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12228   [(set_attr "type" "sselog")
12229    (set_attr "prefix" "evex")
12230    (set_attr "mode" "XI")])
12232 (define_insn "vec_interleave_lowv4si<mask_name>"
12233   [(set (match_operand:V4SI 0 "register_operand" "=x,v")
12234         (vec_select:V4SI
12235           (vec_concat:V8SI
12236             (match_operand:V4SI 1 "register_operand" "0,v")
12237             (match_operand:V4SI 2 "vector_operand" "xBm,vm"))
12238           (parallel [(const_int 0) (const_int 4)
12239                      (const_int 1) (const_int 5)])))]
12240   "TARGET_SSE2 && <mask_avx512vl_condition>"
12241   "@
12242    punpckldq\t{%2, %0|%0, %2}
12243    vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12244   [(set_attr "isa" "noavx,avx")
12245    (set_attr "type" "sselog")
12246    (set_attr "prefix_data16" "1,*")
12247    (set_attr "prefix" "orig,vex")
12248    (set_attr "mode" "TI")])
12250 (define_expand "vec_interleave_high<mode>"
12251   [(match_operand:VI_256 0 "register_operand" "=x")
12252    (match_operand:VI_256 1 "register_operand" "x")
12253    (match_operand:VI_256 2 "nonimmediate_operand" "xm")]
12254  "TARGET_AVX2"
12256   rtx t1 = gen_reg_rtx (<MODE>mode);
12257   rtx t2 = gen_reg_rtx (<MODE>mode);
12258   rtx t3 = gen_reg_rtx (V4DImode);
12259   emit_insn (gen_avx2_interleave_low<mode> (t1, operands[1], operands[2]));
12260   emit_insn (gen_avx2_interleave_high<mode> (t2,  operands[1], operands[2]));
12261   emit_insn (gen_avx2_permv2ti (t3, gen_lowpart (V4DImode, t1),
12262                                 gen_lowpart (V4DImode, t2),
12263                                 GEN_INT (1 + (3 << 4))));
12264   emit_move_insn (operands[0], gen_lowpart (<MODE>mode, t3));
12265   DONE;
12268 (define_expand "vec_interleave_low<mode>"
12269   [(match_operand:VI_256 0 "register_operand" "=x")
12270    (match_operand:VI_256 1 "register_operand" "x")
12271    (match_operand:VI_256 2 "nonimmediate_operand" "xm")]
12272  "TARGET_AVX2"
12274   rtx t1 = gen_reg_rtx (<MODE>mode);
12275   rtx t2 = gen_reg_rtx (<MODE>mode);
12276   rtx t3 = gen_reg_rtx (V4DImode);
12277   emit_insn (gen_avx2_interleave_low<mode> (t1, operands[1], operands[2]));
12278   emit_insn (gen_avx2_interleave_high<mode> (t2, operands[1], operands[2]));
12279   emit_insn (gen_avx2_permv2ti (t3, gen_lowpart (V4DImode, t1),
12280                                 gen_lowpart (V4DImode, t2),
12281                                 GEN_INT (0 + (2 << 4))));
12282   emit_move_insn (operands[0], gen_lowpart (<MODE>mode, t3));
12283   DONE;
12286 ;; Modes handled by pinsr patterns.
12287 (define_mode_iterator PINSR_MODE
12288   [(V16QI "TARGET_SSE4_1") V8HI
12289    (V4SI "TARGET_SSE4_1")
12290    (V2DI "TARGET_SSE4_1 && TARGET_64BIT")])
12292 (define_mode_attr sse2p4_1
12293   [(V16QI "sse4_1") (V8HI "sse2")
12294    (V4SI "sse4_1") (V2DI "sse4_1")])
12296 ;; sse4_1_pinsrd must come before sse2_loadld since it is preferred.
12297 (define_insn "<sse2p4_1>_pinsr<ssemodesuffix>"
12298   [(set (match_operand:PINSR_MODE 0 "register_operand" "=x,x,x,x")
12299         (vec_merge:PINSR_MODE
12300           (vec_duplicate:PINSR_MODE
12301             (match_operand:<ssescalarmode> 2 "nonimmediate_operand" "r,m,r,m"))
12302           (match_operand:PINSR_MODE 1 "register_operand" "0,0,x,x")
12303           (match_operand:SI 3 "const_int_operand")))]
12304   "TARGET_SSE2
12305    && ((unsigned) exact_log2 (INTVAL (operands[3]))
12306        < GET_MODE_NUNITS (<MODE>mode))"
12308   operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])));
12310   switch (which_alternative)
12311     {
12312     case 0:
12313       if (GET_MODE_SIZE (<ssescalarmode>mode) < GET_MODE_SIZE (SImode))
12314         return "pinsr<ssemodesuffix>\t{%3, %k2, %0|%0, %k2, %3}";
12315       /* FALLTHRU */
12316     case 1:
12317       return "pinsr<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}";
12318     case 2:
12319       if (GET_MODE_SIZE (<ssescalarmode>mode) < GET_MODE_SIZE (SImode))
12320         return "vpinsr<ssemodesuffix>\t{%3, %k2, %1, %0|%0, %1, %k2, %3}";
12321       /* FALLTHRU */
12322     case 3:
12323       return "vpinsr<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
12324     default:
12325       gcc_unreachable ();
12326     }
12328   [(set_attr "isa" "noavx,noavx,avx,avx")
12329    (set_attr "type" "sselog")
12330    (set (attr "prefix_rex")
12331      (if_then_else
12332        (and (not (match_test "TARGET_AVX"))
12333             (eq (const_string "<MODE>mode") (const_string "V2DImode")))
12334        (const_string "1")
12335        (const_string "*")))
12336    (set (attr "prefix_data16")
12337      (if_then_else
12338        (and (not (match_test "TARGET_AVX"))
12339             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
12340        (const_string "1")
12341        (const_string "*")))
12342    (set (attr "prefix_extra")
12343      (if_then_else
12344        (and (not (match_test "TARGET_AVX"))
12345             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
12346        (const_string "*")
12347        (const_string "1")))
12348    (set_attr "length_immediate" "1")
12349    (set_attr "prefix" "orig,orig,vex,vex")
12350    (set_attr "mode" "TI")])
12352 (define_expand "<extract_type>_vinsert<shuffletype><extract_suf>_mask"
12353   [(match_operand:AVX512_VEC 0 "register_operand")
12354    (match_operand:AVX512_VEC 1 "register_operand")
12355    (match_operand:<ssequartermode> 2 "nonimmediate_operand")
12356    (match_operand:SI 3 "const_0_to_3_operand")
12357    (match_operand:AVX512_VEC 4 "register_operand")
12358    (match_operand:<avx512fmaskmode> 5 "register_operand")]
12359   "TARGET_AVX512F"
12361   int mask,selector;
12362   mask = INTVAL (operands[3]);
12363   selector = GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ?
12364     0xFFFF ^ (0xF000 >> mask * 4)
12365     : 0xFF ^ (0xC0 >> mask * 2);
12366   emit_insn (gen_<extract_type>_vinsert<shuffletype><extract_suf>_1_mask
12367     (operands[0], operands[1], operands[2], GEN_INT (selector),
12368      operands[4], operands[5]));
12369   DONE;
12372 (define_insn "<mask_codefor><extract_type>_vinsert<shuffletype><extract_suf>_1<mask_name>"
12373   [(set (match_operand:AVX512_VEC 0 "register_operand" "=v")
12374         (vec_merge:AVX512_VEC
12375           (match_operand:AVX512_VEC 1 "register_operand" "v")
12376           (vec_duplicate:AVX512_VEC
12377                 (match_operand:<ssequartermode> 2 "nonimmediate_operand" "vm"))
12378           (match_operand:SI 3 "const_int_operand" "n")))]
12379   "TARGET_AVX512F"
12381   int mask;
12382   int selector = INTVAL (operands[3]);
12384   if (selector == 0xFFF || selector == 0x3F)
12385     mask = 0;
12386   else if ( selector == 0xF0FF || selector == 0xCF)
12387     mask = 1;
12388   else if ( selector == 0xFF0F || selector == 0xF3)
12389     mask = 2;
12390   else if ( selector == 0xFFF0 || selector == 0xFC)
12391     mask = 3;
12392   else
12393       gcc_unreachable ();
12395   operands[3] = GEN_INT (mask);
12397   return "vinsert<shuffletype><extract_suf>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}";
12399   [(set_attr "type" "sselog")
12400    (set_attr "length_immediate" "1")
12401    (set_attr "prefix" "evex")
12402    (set_attr "mode" "<sseinsnmode>")])
12404 (define_expand "<extract_type_2>_vinsert<shuffletype><extract_suf_2>_mask"
12405   [(match_operand:AVX512_VEC_2 0 "register_operand")
12406    (match_operand:AVX512_VEC_2 1 "register_operand")
12407    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
12408    (match_operand:SI 3 "const_0_to_1_operand")
12409    (match_operand:AVX512_VEC_2 4 "register_operand")
12410    (match_operand:<avx512fmaskmode> 5 "register_operand")]
12411   "TARGET_AVX512F"
12413   int mask = INTVAL (operands[3]);
12414   if (mask == 0)
12415     emit_insn (gen_vec_set_lo_<mode>_mask (operands[0], operands[1],
12416                                            operands[2], operands[4],
12417                                            operands[5]));
12418   else
12419     emit_insn (gen_vec_set_hi_<mode>_mask (operands[0], operands[1],
12420                                            operands[2], operands[4],
12421                                            operands[5]));
12422   DONE;
12425 (define_insn "vec_set_lo_<mode><mask_name>"
12426   [(set (match_operand:V16FI 0 "register_operand" "=v")
12427         (vec_concat:V16FI
12428           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
12429           (vec_select:<ssehalfvecmode>
12430             (match_operand:V16FI 1 "register_operand" "v")
12431             (parallel [(const_int 8) (const_int 9)
12432                        (const_int 10) (const_int 11)
12433                        (const_int 12) (const_int 13)
12434                        (const_int 14) (const_int 15)]))))]
12435   "TARGET_AVX512DQ"
12436   "vinsert<shuffletype>32x8\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, $0x0}"
12437   [(set_attr "type" "sselog")
12438    (set_attr "length_immediate" "1")
12439    (set_attr "prefix" "evex")
12440    (set_attr "mode" "<sseinsnmode>")])
12442 (define_insn "vec_set_hi_<mode><mask_name>"
12443   [(set (match_operand:V16FI 0 "register_operand" "=v")
12444         (vec_concat:V16FI
12445           (vec_select:<ssehalfvecmode>
12446             (match_operand:V16FI 1 "register_operand" "v")
12447             (parallel [(const_int 0) (const_int 1)
12448                        (const_int 2) (const_int 3)
12449                        (const_int 4) (const_int 5)
12450                        (const_int 6) (const_int 7)]))
12451           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
12452   "TARGET_AVX512DQ"
12453   "vinsert<shuffletype>32x8\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, $0x1}"
12454   [(set_attr "type" "sselog")
12455    (set_attr "length_immediate" "1")
12456    (set_attr "prefix" "evex")
12457    (set_attr "mode" "<sseinsnmode>")])
12459 (define_insn "vec_set_lo_<mode><mask_name>"
12460   [(set (match_operand:V8FI 0 "register_operand" "=v")
12461         (vec_concat:V8FI
12462           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
12463           (vec_select:<ssehalfvecmode>
12464             (match_operand:V8FI 1 "register_operand" "v")
12465             (parallel [(const_int 4) (const_int 5)
12466                        (const_int 6) (const_int 7)]))))]
12467   "TARGET_AVX512F"
12468   "vinsert<shuffletype>64x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, $0x0}"
12469   [(set_attr "type" "sselog")
12470    (set_attr "length_immediate" "1")
12471    (set_attr "prefix" "evex")
12472    (set_attr "mode" "XI")])
12474 (define_insn "vec_set_hi_<mode><mask_name>"
12475   [(set (match_operand:V8FI 0 "register_operand" "=v")
12476         (vec_concat:V8FI
12477           (vec_select:<ssehalfvecmode>
12478             (match_operand:V8FI 1 "register_operand" "v")
12479             (parallel [(const_int 0) (const_int 1)
12480                        (const_int 2) (const_int 3)]))
12481           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
12482   "TARGET_AVX512F"
12483   "vinsert<shuffletype>64x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, $0x1}"
12484   [(set_attr "type" "sselog")
12485    (set_attr "length_immediate" "1")
12486    (set_attr "prefix" "evex")
12487    (set_attr "mode" "XI")])
12489 (define_expand "avx512dq_shuf_<shuffletype>64x2_mask"
12490   [(match_operand:VI8F_256 0 "register_operand")
12491    (match_operand:VI8F_256 1 "register_operand")
12492    (match_operand:VI8F_256 2 "nonimmediate_operand")
12493    (match_operand:SI 3 "const_0_to_3_operand")
12494    (match_operand:VI8F_256 4 "register_operand")
12495    (match_operand:QI 5 "register_operand")]
12496   "TARGET_AVX512DQ"
12498   int mask = INTVAL (operands[3]);
12499   emit_insn (gen_avx512dq_shuf_<shuffletype>64x2_1_mask
12500       (operands[0], operands[1], operands[2],
12501        GEN_INT (((mask >> 0) & 1) * 2 + 0),
12502        GEN_INT (((mask >> 0) & 1) * 2 + 1),
12503        GEN_INT (((mask >> 1) & 1) * 2 + 4),
12504        GEN_INT (((mask >> 1) & 1) * 2 + 5),
12505        operands[4], operands[5]));
12506   DONE;
12509 (define_insn "<mask_codefor>avx512dq_shuf_<shuffletype>64x2_1<mask_name>"
12510   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
12511         (vec_select:VI8F_256
12512           (vec_concat:<ssedoublemode>
12513             (match_operand:VI8F_256 1 "register_operand" "v")
12514             (match_operand:VI8F_256 2 "nonimmediate_operand" "vm"))
12515           (parallel [(match_operand 3  "const_0_to_3_operand")
12516                      (match_operand 4  "const_0_to_3_operand")
12517                      (match_operand 5  "const_4_to_7_operand")
12518                      (match_operand 6  "const_4_to_7_operand")])))]
12519   "TARGET_AVX512VL
12520    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12521        && INTVAL (operands[5]) == (INTVAL (operands[6]) - 1))"
12523   int mask;
12524   mask = INTVAL (operands[3]) / 2;
12525   mask |= (INTVAL (operands[5]) - 4) / 2 << 1;
12526   operands[3] = GEN_INT (mask);
12527   return "vshuf<shuffletype>64x2\t{%3, %2, %1, %0<mask_operand7>|%0<mask_operand7>, %1, %2, %3}";
12529   [(set_attr "type" "sselog")
12530    (set_attr "length_immediate" "1")
12531    (set_attr "prefix" "evex")
12532    (set_attr "mode" "XI")])
12534 (define_expand "avx512f_shuf_<shuffletype>64x2_mask"
12535   [(match_operand:V8FI 0 "register_operand")
12536    (match_operand:V8FI 1 "register_operand")
12537    (match_operand:V8FI 2 "nonimmediate_operand")
12538    (match_operand:SI 3 "const_0_to_255_operand")
12539    (match_operand:V8FI 4 "register_operand")
12540    (match_operand:QI 5 "register_operand")]
12541   "TARGET_AVX512F"
12543   int mask = INTVAL (operands[3]);
12544   emit_insn (gen_avx512f_shuf_<shuffletype>64x2_1_mask
12545       (operands[0], operands[1], operands[2],
12546        GEN_INT (((mask >> 0) & 3) * 2),
12547        GEN_INT (((mask >> 0) & 3) * 2 + 1),
12548        GEN_INT (((mask >> 2) & 3) * 2),
12549        GEN_INT (((mask >> 2) & 3) * 2 + 1),
12550        GEN_INT (((mask >> 4) & 3) * 2 + 8),
12551        GEN_INT (((mask >> 4) & 3) * 2 + 9),
12552        GEN_INT (((mask >> 6) & 3) * 2 + 8),
12553        GEN_INT (((mask >> 6) & 3) * 2 + 9),
12554        operands[4], operands[5]));
12555   DONE;
12558 (define_insn "avx512f_shuf_<shuffletype>64x2_1<mask_name>"
12559   [(set (match_operand:V8FI 0 "register_operand" "=v")
12560         (vec_select:V8FI
12561           (vec_concat:<ssedoublemode>
12562             (match_operand:V8FI 1 "register_operand" "v")
12563             (match_operand:V8FI 2 "nonimmediate_operand" "vm"))
12564           (parallel [(match_operand 3  "const_0_to_7_operand")
12565                      (match_operand 4  "const_0_to_7_operand")
12566                      (match_operand 5  "const_0_to_7_operand")
12567                      (match_operand 6  "const_0_to_7_operand")
12568                      (match_operand 7  "const_8_to_15_operand")
12569                      (match_operand 8  "const_8_to_15_operand")
12570                      (match_operand 9  "const_8_to_15_operand")
12571                      (match_operand 10  "const_8_to_15_operand")])))]
12572   "TARGET_AVX512F
12573    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12574        && INTVAL (operands[5]) == (INTVAL (operands[6]) - 1)
12575        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
12576        && INTVAL (operands[9]) == (INTVAL (operands[10]) - 1))"
12578   int mask;
12579   mask = INTVAL (operands[3]) / 2;
12580   mask |= INTVAL (operands[5]) / 2 << 2;
12581   mask |= (INTVAL (operands[7]) - 8) / 2 << 4;
12582   mask |= (INTVAL (operands[9]) - 8) / 2 << 6;
12583   operands[3] = GEN_INT (mask);
12585   return "vshuf<shuffletype>64x2\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
12587   [(set_attr "type" "sselog")
12588    (set_attr "length_immediate" "1")
12589    (set_attr "prefix" "evex")
12590    (set_attr "mode" "<sseinsnmode>")])
12592 (define_expand "avx512vl_shuf_<shuffletype>32x4_mask"
12593   [(match_operand:VI4F_256 0 "register_operand")
12594    (match_operand:VI4F_256 1 "register_operand")
12595    (match_operand:VI4F_256 2 "nonimmediate_operand")
12596    (match_operand:SI 3 "const_0_to_3_operand")
12597    (match_operand:VI4F_256 4 "register_operand")
12598    (match_operand:QI 5 "register_operand")]
12599   "TARGET_AVX512VL"
12601   int mask = INTVAL (operands[3]);
12602   emit_insn (gen_avx512vl_shuf_<shuffletype>32x4_1_mask
12603       (operands[0], operands[1], operands[2],
12604        GEN_INT (((mask >> 0) & 1) * 4 + 0),
12605        GEN_INT (((mask >> 0) & 1) * 4 + 1),
12606        GEN_INT (((mask >> 0) & 1) * 4 + 2),
12607        GEN_INT (((mask >> 0) & 1) * 4 + 3),
12608        GEN_INT (((mask >> 1) & 1) * 4 + 8),
12609        GEN_INT (((mask >> 1) & 1) * 4 + 9),
12610        GEN_INT (((mask >> 1) & 1) * 4 + 10),
12611        GEN_INT (((mask >> 1) & 1) * 4 + 11),
12612        operands[4], operands[5]));
12613   DONE;
12616 (define_insn "<mask_codefor>avx512vl_shuf_<shuffletype>32x4_1<mask_name>"
12617   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
12618         (vec_select:VI4F_256
12619           (vec_concat:<ssedoublemode>
12620             (match_operand:VI4F_256 1 "register_operand" "v")
12621             (match_operand:VI4F_256 2 "nonimmediate_operand" "vm"))
12622           (parallel [(match_operand 3  "const_0_to_7_operand")
12623                      (match_operand 4  "const_0_to_7_operand")
12624                      (match_operand 5  "const_0_to_7_operand")
12625                      (match_operand 6  "const_0_to_7_operand")
12626                      (match_operand 7  "const_8_to_15_operand")
12627                      (match_operand 8  "const_8_to_15_operand")
12628                      (match_operand 9  "const_8_to_15_operand")
12629                      (match_operand 10 "const_8_to_15_operand")])))]
12630   "TARGET_AVX512VL
12631    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12632        && INTVAL (operands[3]) == (INTVAL (operands[5]) - 2)
12633        && INTVAL (operands[3]) == (INTVAL (operands[6]) - 3)
12634        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
12635        && INTVAL (operands[7]) == (INTVAL (operands[9]) - 2)
12636        && INTVAL (operands[7]) == (INTVAL (operands[10]) - 3))"
12638   int mask;
12639   mask = INTVAL (operands[3]) / 4;
12640   mask |= (INTVAL (operands[7]) - 8) / 4 << 1;
12641   operands[3] = GEN_INT (mask);
12643   return "vshuf<shuffletype>32x4\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
12645   [(set_attr "type" "sselog")
12646    (set_attr "length_immediate" "1")
12647    (set_attr "prefix" "evex")
12648    (set_attr "mode" "<sseinsnmode>")])
12650 (define_expand "avx512f_shuf_<shuffletype>32x4_mask"
12651   [(match_operand:V16FI 0 "register_operand")
12652    (match_operand:V16FI 1 "register_operand")
12653    (match_operand:V16FI 2 "nonimmediate_operand")
12654    (match_operand:SI 3 "const_0_to_255_operand")
12655    (match_operand:V16FI 4 "register_operand")
12656    (match_operand:HI 5 "register_operand")]
12657   "TARGET_AVX512F"
12659   int mask = INTVAL (operands[3]);
12660   emit_insn (gen_avx512f_shuf_<shuffletype>32x4_1_mask
12661       (operands[0], operands[1], operands[2],
12662        GEN_INT (((mask >> 0) & 3) * 4),
12663        GEN_INT (((mask >> 0) & 3) * 4 + 1),
12664        GEN_INT (((mask >> 0) & 3) * 4 + 2),
12665        GEN_INT (((mask >> 0) & 3) * 4 + 3),
12666        GEN_INT (((mask >> 2) & 3) * 4),
12667        GEN_INT (((mask >> 2) & 3) * 4 + 1),
12668        GEN_INT (((mask >> 2) & 3) * 4 + 2),
12669        GEN_INT (((mask >> 2) & 3) * 4 + 3),
12670        GEN_INT (((mask >> 4) & 3) * 4 + 16),
12671        GEN_INT (((mask >> 4) & 3) * 4 + 17),
12672        GEN_INT (((mask >> 4) & 3) * 4 + 18),
12673        GEN_INT (((mask >> 4) & 3) * 4 + 19),
12674        GEN_INT (((mask >> 6) & 3) * 4 + 16),
12675        GEN_INT (((mask >> 6) & 3) * 4 + 17),
12676        GEN_INT (((mask >> 6) & 3) * 4 + 18),
12677        GEN_INT (((mask >> 6) & 3) * 4 + 19),
12678        operands[4], operands[5]));
12679   DONE;
12682 (define_insn "avx512f_shuf_<shuffletype>32x4_1<mask_name>"
12683   [(set (match_operand:V16FI 0 "register_operand" "=v")
12684         (vec_select:V16FI
12685           (vec_concat:<ssedoublemode>
12686             (match_operand:V16FI 1 "register_operand" "v")
12687             (match_operand:V16FI 2 "nonimmediate_operand" "vm"))
12688           (parallel [(match_operand 3  "const_0_to_15_operand")
12689                      (match_operand 4  "const_0_to_15_operand")
12690                      (match_operand 5  "const_0_to_15_operand")
12691                      (match_operand 6  "const_0_to_15_operand")
12692                      (match_operand 7  "const_0_to_15_operand")
12693                      (match_operand 8  "const_0_to_15_operand")
12694                      (match_operand 9  "const_0_to_15_operand")
12695                      (match_operand 10  "const_0_to_15_operand")
12696                      (match_operand 11  "const_16_to_31_operand")
12697                      (match_operand 12  "const_16_to_31_operand")
12698                      (match_operand 13  "const_16_to_31_operand")
12699                      (match_operand 14  "const_16_to_31_operand")
12700                      (match_operand 15  "const_16_to_31_operand")
12701                      (match_operand 16  "const_16_to_31_operand")
12702                      (match_operand 17  "const_16_to_31_operand")
12703                      (match_operand 18  "const_16_to_31_operand")])))]
12704   "TARGET_AVX512F
12705    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12706        && INTVAL (operands[3]) == (INTVAL (operands[5]) - 2)
12707        && INTVAL (operands[3]) == (INTVAL (operands[6]) - 3)
12708        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
12709        && INTVAL (operands[7]) == (INTVAL (operands[9]) - 2)
12710        && INTVAL (operands[7]) == (INTVAL (operands[10]) - 3)
12711        && INTVAL (operands[11]) == (INTVAL (operands[12]) - 1)
12712        && INTVAL (operands[11]) == (INTVAL (operands[13]) - 2)
12713        && INTVAL (operands[11]) == (INTVAL (operands[14]) - 3)
12714        && INTVAL (operands[15]) == (INTVAL (operands[16]) - 1)
12715        && INTVAL (operands[15]) == (INTVAL (operands[17]) - 2)
12716        && INTVAL (operands[15]) == (INTVAL (operands[18]) - 3))"
12718   int mask;
12719   mask = INTVAL (operands[3]) / 4;
12720   mask |= INTVAL (operands[7]) / 4 << 2;
12721   mask |= (INTVAL (operands[11]) - 16) / 4 << 4;
12722   mask |= (INTVAL (operands[15]) - 16) / 4 << 6;
12723   operands[3] = GEN_INT (mask);
12725   return "vshuf<shuffletype>32x4\t{%3, %2, %1, %0<mask_operand19>|%0<mask_operand19>, %1, %2, %3}";
12727   [(set_attr "type" "sselog")
12728    (set_attr "length_immediate" "1")
12729    (set_attr "prefix" "evex")
12730    (set_attr "mode" "<sseinsnmode>")])
12732 (define_expand "avx512f_pshufdv3_mask"
12733   [(match_operand:V16SI 0 "register_operand")
12734    (match_operand:V16SI 1 "nonimmediate_operand")
12735    (match_operand:SI 2 "const_0_to_255_operand")
12736    (match_operand:V16SI 3 "register_operand")
12737    (match_operand:HI 4 "register_operand")]
12738   "TARGET_AVX512F"
12740   int mask = INTVAL (operands[2]);
12741   emit_insn (gen_avx512f_pshufd_1_mask (operands[0], operands[1],
12742                                        GEN_INT ((mask >> 0) & 3),
12743                                        GEN_INT ((mask >> 2) & 3),
12744                                        GEN_INT ((mask >> 4) & 3),
12745                                        GEN_INT ((mask >> 6) & 3),
12746                                        GEN_INT (((mask >> 0) & 3) + 4),
12747                                        GEN_INT (((mask >> 2) & 3) + 4),
12748                                        GEN_INT (((mask >> 4) & 3) + 4),
12749                                        GEN_INT (((mask >> 6) & 3) + 4),
12750                                        GEN_INT (((mask >> 0) & 3) + 8),
12751                                        GEN_INT (((mask >> 2) & 3) + 8),
12752                                        GEN_INT (((mask >> 4) & 3) + 8),
12753                                        GEN_INT (((mask >> 6) & 3) + 8),
12754                                        GEN_INT (((mask >> 0) & 3) + 12),
12755                                        GEN_INT (((mask >> 2) & 3) + 12),
12756                                        GEN_INT (((mask >> 4) & 3) + 12),
12757                                        GEN_INT (((mask >> 6) & 3) + 12),
12758                                        operands[3], operands[4]));
12759   DONE;
12762 (define_insn "avx512f_pshufd_1<mask_name>"
12763   [(set (match_operand:V16SI 0 "register_operand" "=v")
12764         (vec_select:V16SI
12765           (match_operand:V16SI 1 "nonimmediate_operand" "vm")
12766           (parallel [(match_operand 2 "const_0_to_3_operand")
12767                      (match_operand 3 "const_0_to_3_operand")
12768                      (match_operand 4 "const_0_to_3_operand")
12769                      (match_operand 5 "const_0_to_3_operand")
12770                      (match_operand 6 "const_4_to_7_operand")
12771                      (match_operand 7 "const_4_to_7_operand")
12772                      (match_operand 8 "const_4_to_7_operand")
12773                      (match_operand 9 "const_4_to_7_operand")
12774                      (match_operand 10 "const_8_to_11_operand")
12775                      (match_operand 11 "const_8_to_11_operand")
12776                      (match_operand 12 "const_8_to_11_operand")
12777                      (match_operand 13 "const_8_to_11_operand")
12778                      (match_operand 14 "const_12_to_15_operand")
12779                      (match_operand 15 "const_12_to_15_operand")
12780                      (match_operand 16 "const_12_to_15_operand")
12781                      (match_operand 17 "const_12_to_15_operand")])))]
12782   "TARGET_AVX512F
12783    && INTVAL (operands[2]) + 4 == INTVAL (operands[6])
12784    && INTVAL (operands[3]) + 4 == INTVAL (operands[7])
12785    && INTVAL (operands[4]) + 4 == INTVAL (operands[8])
12786    && INTVAL (operands[5]) + 4 == INTVAL (operands[9])
12787    && INTVAL (operands[2]) + 8 == INTVAL (operands[10])
12788    && INTVAL (operands[3]) + 8 == INTVAL (operands[11])
12789    && INTVAL (operands[4]) + 8 == INTVAL (operands[12])
12790    && INTVAL (operands[5]) + 8 == INTVAL (operands[13])
12791    && INTVAL (operands[2]) + 12 == INTVAL (operands[14])
12792    && INTVAL (operands[3]) + 12 == INTVAL (operands[15])
12793    && INTVAL (operands[4]) + 12 == INTVAL (operands[16])
12794    && INTVAL (operands[5]) + 12 == INTVAL (operands[17])"
12796   int mask = 0;
12797   mask |= INTVAL (operands[2]) << 0;
12798   mask |= INTVAL (operands[3]) << 2;
12799   mask |= INTVAL (operands[4]) << 4;
12800   mask |= INTVAL (operands[5]) << 6;
12801   operands[2] = GEN_INT (mask);
12803   return "vpshufd\t{%2, %1, %0<mask_operand18>|%0<mask_operand18>, %1, %2}";
12805   [(set_attr "type" "sselog1")
12806    (set_attr "prefix" "evex")
12807    (set_attr "length_immediate" "1")
12808    (set_attr "mode" "XI")])
12810 (define_expand "avx512vl_pshufdv3_mask"
12811   [(match_operand:V8SI 0 "register_operand")
12812    (match_operand:V8SI 1 "nonimmediate_operand")
12813    (match_operand:SI 2 "const_0_to_255_operand")
12814    (match_operand:V8SI 3 "register_operand")
12815    (match_operand:QI 4 "register_operand")]
12816   "TARGET_AVX512VL"
12818   int mask = INTVAL (operands[2]);
12819   emit_insn (gen_avx2_pshufd_1_mask (operands[0], operands[1],
12820                                 GEN_INT ((mask >> 0) & 3),
12821                                 GEN_INT ((mask >> 2) & 3),
12822                                 GEN_INT ((mask >> 4) & 3),
12823                                 GEN_INT ((mask >> 6) & 3),
12824                                 GEN_INT (((mask >> 0) & 3) + 4),
12825                                 GEN_INT (((mask >> 2) & 3) + 4),
12826                                 GEN_INT (((mask >> 4) & 3) + 4),
12827                                 GEN_INT (((mask >> 6) & 3) + 4),
12828                 operands[3], operands[4]));
12829   DONE;
12832 (define_expand "avx2_pshufdv3"
12833   [(match_operand:V8SI 0 "register_operand")
12834    (match_operand:V8SI 1 "nonimmediate_operand")
12835    (match_operand:SI 2 "const_0_to_255_operand")]
12836   "TARGET_AVX2"
12838   int mask = INTVAL (operands[2]);
12839   emit_insn (gen_avx2_pshufd_1 (operands[0], operands[1],
12840                                 GEN_INT ((mask >> 0) & 3),
12841                                 GEN_INT ((mask >> 2) & 3),
12842                                 GEN_INT ((mask >> 4) & 3),
12843                                 GEN_INT ((mask >> 6) & 3),
12844                                 GEN_INT (((mask >> 0) & 3) + 4),
12845                                 GEN_INT (((mask >> 2) & 3) + 4),
12846                                 GEN_INT (((mask >> 4) & 3) + 4),
12847                                 GEN_INT (((mask >> 6) & 3) + 4)));
12848   DONE;
12851 (define_insn "avx2_pshufd_1<mask_name>"
12852   [(set (match_operand:V8SI 0 "register_operand" "=v")
12853         (vec_select:V8SI
12854           (match_operand:V8SI 1 "nonimmediate_operand" "vm")
12855           (parallel [(match_operand 2 "const_0_to_3_operand")
12856                      (match_operand 3 "const_0_to_3_operand")
12857                      (match_operand 4 "const_0_to_3_operand")
12858                      (match_operand 5 "const_0_to_3_operand")
12859                      (match_operand 6 "const_4_to_7_operand")
12860                      (match_operand 7 "const_4_to_7_operand")
12861                      (match_operand 8 "const_4_to_7_operand")
12862                      (match_operand 9 "const_4_to_7_operand")])))]
12863   "TARGET_AVX2
12864    && <mask_avx512vl_condition>
12865    && INTVAL (operands[2]) + 4 == INTVAL (operands[6])
12866    && INTVAL (operands[3]) + 4 == INTVAL (operands[7])
12867    && INTVAL (operands[4]) + 4 == INTVAL (operands[8])
12868    && INTVAL (operands[5]) + 4 == INTVAL (operands[9])"
12870   int mask = 0;
12871   mask |= INTVAL (operands[2]) << 0;
12872   mask |= INTVAL (operands[3]) << 2;
12873   mask |= INTVAL (operands[4]) << 4;
12874   mask |= INTVAL (operands[5]) << 6;
12875   operands[2] = GEN_INT (mask);
12877   return "vpshufd\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
12879   [(set_attr "type" "sselog1")
12880    (set_attr "prefix" "maybe_evex")
12881    (set_attr "length_immediate" "1")
12882    (set_attr "mode" "OI")])
12884 (define_expand "avx512vl_pshufd_mask"
12885   [(match_operand:V4SI 0 "register_operand")
12886    (match_operand:V4SI 1 "nonimmediate_operand")
12887    (match_operand:SI 2 "const_0_to_255_operand")
12888    (match_operand:V4SI 3 "register_operand")
12889    (match_operand:QI 4 "register_operand")]
12890   "TARGET_AVX512VL"
12892   int mask = INTVAL (operands[2]);
12893   emit_insn (gen_sse2_pshufd_1_mask (operands[0], operands[1],
12894                                 GEN_INT ((mask >> 0) & 3),
12895                                 GEN_INT ((mask >> 2) & 3),
12896                                 GEN_INT ((mask >> 4) & 3),
12897                                 GEN_INT ((mask >> 6) & 3),
12898                 operands[3], operands[4]));
12899   DONE;
12902 (define_expand "sse2_pshufd"
12903   [(match_operand:V4SI 0 "register_operand")
12904    (match_operand:V4SI 1 "vector_operand")
12905    (match_operand:SI 2 "const_int_operand")]
12906   "TARGET_SSE2"
12908   int mask = INTVAL (operands[2]);
12909   emit_insn (gen_sse2_pshufd_1 (operands[0], operands[1],
12910                                 GEN_INT ((mask >> 0) & 3),
12911                                 GEN_INT ((mask >> 2) & 3),
12912                                 GEN_INT ((mask >> 4) & 3),
12913                                 GEN_INT ((mask >> 6) & 3)));
12914   DONE;
12917 (define_insn "sse2_pshufd_1<mask_name>"
12918   [(set (match_operand:V4SI 0 "register_operand" "=v")
12919         (vec_select:V4SI
12920           (match_operand:V4SI 1 "vector_operand" "vBm")
12921           (parallel [(match_operand 2 "const_0_to_3_operand")
12922                      (match_operand 3 "const_0_to_3_operand")
12923                      (match_operand 4 "const_0_to_3_operand")
12924                      (match_operand 5 "const_0_to_3_operand")])))]
12925   "TARGET_SSE2 && <mask_avx512vl_condition>"
12927   int mask = 0;
12928   mask |= INTVAL (operands[2]) << 0;
12929   mask |= INTVAL (operands[3]) << 2;
12930   mask |= INTVAL (operands[4]) << 4;
12931   mask |= INTVAL (operands[5]) << 6;
12932   operands[2] = GEN_INT (mask);
12934   return "%vpshufd\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
12936   [(set_attr "type" "sselog1")
12937    (set_attr "prefix_data16" "1")
12938    (set_attr "prefix" "<mask_prefix2>")
12939    (set_attr "length_immediate" "1")
12940    (set_attr "mode" "TI")])
12942 (define_insn "<mask_codefor>avx512bw_pshuflwv32hi<mask_name>"
12943   [(set (match_operand:V32HI 0 "register_operand" "=v")
12944         (unspec:V32HI
12945           [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
12946            (match_operand:SI 2 "const_0_to_255_operand" "n")]
12947           UNSPEC_PSHUFLW))]
12948   "TARGET_AVX512BW"
12949   "vpshuflw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12950   [(set_attr "type" "sselog")
12951    (set_attr "prefix" "evex")
12952    (set_attr "mode" "XI")])
12954 (define_expand "avx512vl_pshuflwv3_mask"
12955   [(match_operand:V16HI 0 "register_operand")
12956    (match_operand:V16HI 1 "nonimmediate_operand")
12957    (match_operand:SI 2 "const_0_to_255_operand")
12958    (match_operand:V16HI 3 "register_operand")
12959    (match_operand:HI 4 "register_operand")]
12960   "TARGET_AVX512VL && TARGET_AVX512BW"
12962   int mask = INTVAL (operands[2]);
12963   emit_insn (gen_avx2_pshuflw_1_mask (operands[0], operands[1],
12964                                  GEN_INT ((mask >> 0) & 3),
12965                                  GEN_INT ((mask >> 2) & 3),
12966                                  GEN_INT ((mask >> 4) & 3),
12967                                  GEN_INT ((mask >> 6) & 3),
12968                                  GEN_INT (((mask >> 0) & 3) + 8),
12969                                  GEN_INT (((mask >> 2) & 3) + 8),
12970                                  GEN_INT (((mask >> 4) & 3) + 8),
12971                                  GEN_INT (((mask >> 6) & 3) + 8),
12972                  operands[3], operands[4]));
12973   DONE;
12976 (define_expand "avx2_pshuflwv3"
12977   [(match_operand:V16HI 0 "register_operand")
12978    (match_operand:V16HI 1 "nonimmediate_operand")
12979    (match_operand:SI 2 "const_0_to_255_operand")]
12980   "TARGET_AVX2"
12982   int mask = INTVAL (operands[2]);
12983   emit_insn (gen_avx2_pshuflw_1 (operands[0], operands[1],
12984                                  GEN_INT ((mask >> 0) & 3),
12985                                  GEN_INT ((mask >> 2) & 3),
12986                                  GEN_INT ((mask >> 4) & 3),
12987                                  GEN_INT ((mask >> 6) & 3),
12988                                  GEN_INT (((mask >> 0) & 3) + 8),
12989                                  GEN_INT (((mask >> 2) & 3) + 8),
12990                                  GEN_INT (((mask >> 4) & 3) + 8),
12991                                  GEN_INT (((mask >> 6) & 3) + 8)));
12992   DONE;
12995 (define_insn "avx2_pshuflw_1<mask_name>"
12996   [(set (match_operand:V16HI 0 "register_operand" "=v")
12997         (vec_select:V16HI
12998           (match_operand:V16HI 1 "nonimmediate_operand" "vm")
12999           (parallel [(match_operand 2 "const_0_to_3_operand")
13000                      (match_operand 3 "const_0_to_3_operand")
13001                      (match_operand 4 "const_0_to_3_operand")
13002                      (match_operand 5 "const_0_to_3_operand")
13003                      (const_int 4)
13004                      (const_int 5)
13005                      (const_int 6)
13006                      (const_int 7)
13007                      (match_operand 6 "const_8_to_11_operand")
13008                      (match_operand 7 "const_8_to_11_operand")
13009                      (match_operand 8 "const_8_to_11_operand")
13010                      (match_operand 9 "const_8_to_11_operand")
13011                      (const_int 12)
13012                      (const_int 13)
13013                      (const_int 14)
13014                      (const_int 15)])))]
13015   "TARGET_AVX2
13016    && <mask_avx512bw_condition> && <mask_avx512vl_condition>
13017    && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
13018    && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
13019    && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
13020    && INTVAL (operands[5]) + 8 == INTVAL (operands[9])"
13022   int mask = 0;
13023   mask |= INTVAL (operands[2]) << 0;
13024   mask |= INTVAL (operands[3]) << 2;
13025   mask |= INTVAL (operands[4]) << 4;
13026   mask |= INTVAL (operands[5]) << 6;
13027   operands[2] = GEN_INT (mask);
13029   return "vpshuflw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
13031   [(set_attr "type" "sselog")
13032    (set_attr "prefix" "maybe_evex")
13033    (set_attr "length_immediate" "1")
13034    (set_attr "mode" "OI")])
13036 (define_expand "avx512vl_pshuflw_mask"
13037   [(match_operand:V8HI 0 "register_operand")
13038    (match_operand:V8HI 1 "nonimmediate_operand")
13039    (match_operand:SI 2 "const_0_to_255_operand")
13040    (match_operand:V8HI 3 "register_operand")
13041    (match_operand:QI 4 "register_operand")]
13042   "TARGET_AVX512VL && TARGET_AVX512BW"
13044   int mask = INTVAL (operands[2]);
13045   emit_insn (gen_sse2_pshuflw_1_mask (operands[0], operands[1],
13046                                  GEN_INT ((mask >> 0) & 3),
13047                                  GEN_INT ((mask >> 2) & 3),
13048                                  GEN_INT ((mask >> 4) & 3),
13049                                  GEN_INT ((mask >> 6) & 3),
13050                  operands[3], operands[4]));
13051   DONE;
13054 (define_expand "sse2_pshuflw"
13055   [(match_operand:V8HI 0 "register_operand")
13056    (match_operand:V8HI 1 "vector_operand")
13057    (match_operand:SI 2 "const_int_operand")]
13058   "TARGET_SSE2"
13060   int mask = INTVAL (operands[2]);
13061   emit_insn (gen_sse2_pshuflw_1 (operands[0], operands[1],
13062                                  GEN_INT ((mask >> 0) & 3),
13063                                  GEN_INT ((mask >> 2) & 3),
13064                                  GEN_INT ((mask >> 4) & 3),
13065                                  GEN_INT ((mask >> 6) & 3)));
13066   DONE;
13069 (define_insn "sse2_pshuflw_1<mask_name>"
13070   [(set (match_operand:V8HI 0 "register_operand" "=v")
13071         (vec_select:V8HI
13072           (match_operand:V8HI 1 "vector_operand" "vBm")
13073           (parallel [(match_operand 2 "const_0_to_3_operand")
13074                      (match_operand 3 "const_0_to_3_operand")
13075                      (match_operand 4 "const_0_to_3_operand")
13076                      (match_operand 5 "const_0_to_3_operand")
13077                      (const_int 4)
13078                      (const_int 5)
13079                      (const_int 6)
13080                      (const_int 7)])))]
13081   "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
13083   int mask = 0;
13084   mask |= INTVAL (operands[2]) << 0;
13085   mask |= INTVAL (operands[3]) << 2;
13086   mask |= INTVAL (operands[4]) << 4;
13087   mask |= INTVAL (operands[5]) << 6;
13088   operands[2] = GEN_INT (mask);
13090   return "%vpshuflw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
13092   [(set_attr "type" "sselog")
13093    (set_attr "prefix_data16" "0")
13094    (set_attr "prefix_rep" "1")
13095    (set_attr "prefix" "maybe_vex")
13096    (set_attr "length_immediate" "1")
13097    (set_attr "mode" "TI")])
13099 (define_expand "avx2_pshufhwv3"
13100   [(match_operand:V16HI 0 "register_operand")
13101    (match_operand:V16HI 1 "nonimmediate_operand")
13102    (match_operand:SI 2 "const_0_to_255_operand")]
13103   "TARGET_AVX2"
13105   int mask = INTVAL (operands[2]);
13106   emit_insn (gen_avx2_pshufhw_1 (operands[0], operands[1],
13107                                  GEN_INT (((mask >> 0) & 3) + 4),
13108                                  GEN_INT (((mask >> 2) & 3) + 4),
13109                                  GEN_INT (((mask >> 4) & 3) + 4),
13110                                  GEN_INT (((mask >> 6) & 3) + 4),
13111                                  GEN_INT (((mask >> 0) & 3) + 12),
13112                                  GEN_INT (((mask >> 2) & 3) + 12),
13113                                  GEN_INT (((mask >> 4) & 3) + 12),
13114                                  GEN_INT (((mask >> 6) & 3) + 12)));
13115   DONE;
13118 (define_insn "<mask_codefor>avx512bw_pshufhwv32hi<mask_name>"
13119   [(set (match_operand:V32HI 0 "register_operand" "=v")
13120         (unspec:V32HI
13121           [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
13122            (match_operand:SI 2 "const_0_to_255_operand" "n")]
13123           UNSPEC_PSHUFHW))]
13124   "TARGET_AVX512BW"
13125   "vpshufhw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
13126   [(set_attr "type" "sselog")
13127    (set_attr "prefix" "evex")
13128    (set_attr "mode" "XI")])
13130 (define_expand "avx512vl_pshufhwv3_mask"
13131   [(match_operand:V16HI 0 "register_operand")
13132    (match_operand:V16HI 1 "nonimmediate_operand")
13133    (match_operand:SI 2 "const_0_to_255_operand")
13134    (match_operand:V16HI 3 "register_operand")
13135    (match_operand:HI 4 "register_operand")]
13136   "TARGET_AVX512VL && TARGET_AVX512BW"
13138   int mask = INTVAL (operands[2]);
13139   emit_insn (gen_avx2_pshufhw_1_mask (operands[0], operands[1],
13140                                  GEN_INT (((mask >> 0) & 3) + 4),
13141                                  GEN_INT (((mask >> 2) & 3) + 4),
13142                                  GEN_INT (((mask >> 4) & 3) + 4),
13143                                  GEN_INT (((mask >> 6) & 3) + 4),
13144                                  GEN_INT (((mask >> 0) & 3) + 12),
13145                                  GEN_INT (((mask >> 2) & 3) + 12),
13146                                  GEN_INT (((mask >> 4) & 3) + 12),
13147                                  GEN_INT (((mask >> 6) & 3) + 12),
13148                  operands[3], operands[4]));
13149   DONE;
13152 (define_insn "avx2_pshufhw_1<mask_name>"
13153   [(set (match_operand:V16HI 0 "register_operand" "=v")
13154         (vec_select:V16HI
13155           (match_operand:V16HI 1 "nonimmediate_operand" "vm")
13156           (parallel [(const_int 0)
13157                      (const_int 1)
13158                      (const_int 2)
13159                      (const_int 3)
13160                      (match_operand 2 "const_4_to_7_operand")
13161                      (match_operand 3 "const_4_to_7_operand")
13162                      (match_operand 4 "const_4_to_7_operand")
13163                      (match_operand 5 "const_4_to_7_operand")
13164                      (const_int 8)
13165                      (const_int 9)
13166                      (const_int 10)
13167                      (const_int 11)
13168                      (match_operand 6 "const_12_to_15_operand")
13169                      (match_operand 7 "const_12_to_15_operand")
13170                      (match_operand 8 "const_12_to_15_operand")
13171                      (match_operand 9 "const_12_to_15_operand")])))]
13172   "TARGET_AVX2
13173    && <mask_avx512bw_condition> && <mask_avx512vl_condition>
13174    && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
13175    && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
13176    && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
13177    && INTVAL (operands[5]) + 8 == INTVAL (operands[9])"
13179   int mask = 0;
13180   mask |= (INTVAL (operands[2]) - 4) << 0;
13181   mask |= (INTVAL (operands[3]) - 4) << 2;
13182   mask |= (INTVAL (operands[4]) - 4) << 4;
13183   mask |= (INTVAL (operands[5]) - 4) << 6;
13184   operands[2] = GEN_INT (mask);
13186   return "vpshufhw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
13188   [(set_attr "type" "sselog")
13189    (set_attr "prefix" "maybe_evex")
13190    (set_attr "length_immediate" "1")
13191    (set_attr "mode" "OI")])
13193 (define_expand "avx512vl_pshufhw_mask"
13194   [(match_operand:V8HI 0 "register_operand")
13195    (match_operand:V8HI 1 "nonimmediate_operand")
13196    (match_operand:SI 2 "const_0_to_255_operand")
13197    (match_operand:V8HI 3 "register_operand")
13198    (match_operand:QI 4 "register_operand")]
13199   "TARGET_AVX512VL && TARGET_AVX512BW"
13201   int mask = INTVAL (operands[2]);
13202   emit_insn (gen_sse2_pshufhw_1_mask (operands[0], operands[1],
13203                                  GEN_INT (((mask >> 0) & 3) + 4),
13204                                  GEN_INT (((mask >> 2) & 3) + 4),
13205                                  GEN_INT (((mask >> 4) & 3) + 4),
13206                                  GEN_INT (((mask >> 6) & 3) + 4),
13207                  operands[3], operands[4]));
13208   DONE;
13211 (define_expand "sse2_pshufhw"
13212   [(match_operand:V8HI 0 "register_operand")
13213    (match_operand:V8HI 1 "vector_operand")
13214    (match_operand:SI 2 "const_int_operand")]
13215   "TARGET_SSE2"
13217   int mask = INTVAL (operands[2]);
13218   emit_insn (gen_sse2_pshufhw_1 (operands[0], operands[1],
13219                                  GEN_INT (((mask >> 0) & 3) + 4),
13220                                  GEN_INT (((mask >> 2) & 3) + 4),
13221                                  GEN_INT (((mask >> 4) & 3) + 4),
13222                                  GEN_INT (((mask >> 6) & 3) + 4)));
13223   DONE;
13226 (define_insn "sse2_pshufhw_1<mask_name>"
13227   [(set (match_operand:V8HI 0 "register_operand" "=v")
13228         (vec_select:V8HI
13229           (match_operand:V8HI 1 "vector_operand" "vBm")
13230           (parallel [(const_int 0)
13231                      (const_int 1)
13232                      (const_int 2)
13233                      (const_int 3)
13234                      (match_operand 2 "const_4_to_7_operand")
13235                      (match_operand 3 "const_4_to_7_operand")
13236                      (match_operand 4 "const_4_to_7_operand")
13237                      (match_operand 5 "const_4_to_7_operand")])))]
13238   "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
13240   int mask = 0;
13241   mask |= (INTVAL (operands[2]) - 4) << 0;
13242   mask |= (INTVAL (operands[3]) - 4) << 2;
13243   mask |= (INTVAL (operands[4]) - 4) << 4;
13244   mask |= (INTVAL (operands[5]) - 4) << 6;
13245   operands[2] = GEN_INT (mask);
13247   return "%vpshufhw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
13249   [(set_attr "type" "sselog")
13250    (set_attr "prefix_rep" "1")
13251    (set_attr "prefix_data16" "0")
13252    (set_attr "prefix" "maybe_vex")
13253    (set_attr "length_immediate" "1")
13254    (set_attr "mode" "TI")])
13256 (define_expand "sse2_loadd"
13257   [(set (match_operand:V4SI 0 "register_operand")
13258         (vec_merge:V4SI
13259           (vec_duplicate:V4SI
13260             (match_operand:SI 1 "nonimmediate_operand"))
13261           (match_dup 2)
13262           (const_int 1)))]
13263   "TARGET_SSE"
13264   "operands[2] = CONST0_RTX (V4SImode);")
13266 (define_insn "sse2_loadld"
13267   [(set (match_operand:V4SI 0 "register_operand"       "=x,Yi,x,x,x")
13268         (vec_merge:V4SI
13269           (vec_duplicate:V4SI
13270             (match_operand:SI 2 "nonimmediate_operand" "m ,r ,m,x,x"))
13271           (match_operand:V4SI 1 "reg_or_0_operand"     "C ,C ,C,0,x")
13272           (const_int 1)))]
13273   "TARGET_SSE"
13274   "@
13275    %vmovd\t{%2, %0|%0, %2}
13276    %vmovd\t{%2, %0|%0, %2}
13277    movss\t{%2, %0|%0, %2}
13278    movss\t{%2, %0|%0, %2}
13279    vmovss\t{%2, %1, %0|%0, %1, %2}"
13280   [(set_attr "isa" "sse2,sse2,noavx,noavx,avx")
13281    (set_attr "type" "ssemov")
13282    (set_attr "prefix" "maybe_vex,maybe_vex,orig,orig,vex")
13283    (set_attr "mode" "TI,TI,V4SF,SF,SF")])
13285 ;; QI and HI modes handled by pextr patterns.
13286 (define_mode_iterator PEXTR_MODE12
13287   [(V16QI "TARGET_SSE4_1") V8HI])
13289 (define_insn "*vec_extract<mode>"
13290   [(set (match_operand:<ssescalarmode> 0 "register_sse4nonimm_operand" "=r,m")
13291         (vec_select:<ssescalarmode>
13292           (match_operand:PEXTR_MODE12 1 "register_operand" "x,x")
13293           (parallel
13294             [(match_operand:SI 2 "const_0_to_<ssescalarnummask>_operand")])))]
13295   "TARGET_SSE2"
13296   "@
13297    %vpextr<ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
13298    %vpextr<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
13299   [(set_attr "isa" "*,sse4")
13300    (set_attr "type" "sselog1")
13301    (set_attr "prefix_data16" "1")
13302    (set (attr "prefix_extra")
13303      (if_then_else
13304        (and (eq_attr "alternative" "0")
13305             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
13306        (const_string "*")
13307        (const_string "1")))
13308    (set_attr "length_immediate" "1")
13309    (set_attr "prefix" "maybe_vex")
13310    (set_attr "mode" "TI")])
13312 (define_insn "*vec_extract<PEXTR_MODE12:mode>_zext"
13313   [(set (match_operand:SWI48 0 "register_operand" "=r")
13314         (zero_extend:SWI48
13315           (vec_select:<PEXTR_MODE12:ssescalarmode>
13316             (match_operand:PEXTR_MODE12 1 "register_operand" "x")
13317             (parallel
13318               [(match_operand:SI 2
13319                 "const_0_to_<PEXTR_MODE12:ssescalarnummask>_operand")]))))]
13320   "TARGET_SSE2"
13321   "%vpextr<PEXTR_MODE12:ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}"
13322   [(set_attr "type" "sselog1")
13323    (set_attr "prefix_data16" "1")
13324    (set (attr "prefix_extra")
13325      (if_then_else
13326        (eq (const_string "<PEXTR_MODE12:MODE>mode") (const_string "V8HImode"))
13327        (const_string "*")
13328        (const_string "1")))
13329    (set_attr "length_immediate" "1")
13330    (set_attr "prefix" "maybe_vex")
13331    (set_attr "mode" "TI")])
13333 (define_insn "*vec_extract<mode>_mem"
13334   [(set (match_operand:<ssescalarmode> 0 "register_operand" "=r")
13335         (vec_select:<ssescalarmode>
13336           (match_operand:VI12_128 1 "memory_operand" "o")
13337           (parallel
13338             [(match_operand 2 "const_0_to_<ssescalarnummask>_operand")])))]
13339   "TARGET_SSE"
13340   "#")
13342 (define_insn "*vec_extract<ssevecmodelower>_0"
13343   [(set (match_operand:SWI48 0 "nonimmediate_operand"          "=r ,r,x ,m")
13344         (vec_select:SWI48
13345           (match_operand:<ssevecmode> 1 "nonimmediate_operand" "mYj,x,xm,x")
13346           (parallel [(const_int 0)])))]
13347   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13348   "#"
13349   [(set_attr "isa" "*,sse4,*,*")])
13351 (define_insn_and_split "*vec_extractv4si_0_zext"
13352   [(set (match_operand:DI 0 "register_operand" "=r")
13353         (zero_extend:DI
13354           (vec_select:SI
13355             (match_operand:V4SI 1 "register_operand" "x")
13356             (parallel [(const_int 0)]))))]
13357   "TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_FROM_VEC"
13358   "#"
13359   "&& reload_completed"
13360   [(set (match_dup 0) (zero_extend:DI (match_dup 1)))]
13361   "operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]));")
13363 (define_insn "*vec_extractv2di_0_sse"
13364   [(set (match_operand:DI 0 "nonimmediate_operand"     "=x,m")
13365         (vec_select:DI
13366           (match_operand:V2DI 1 "nonimmediate_operand" "xm,x")
13367           (parallel [(const_int 0)])))]
13368   "TARGET_SSE && !TARGET_64BIT
13369    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13370   "#")
13372 (define_split
13373   [(set (match_operand:SWI48x 0 "nonimmediate_operand")
13374         (vec_select:SWI48x
13375           (match_operand:<ssevecmode> 1 "register_operand")
13376           (parallel [(const_int 0)])))]
13377   "TARGET_SSE && reload_completed"
13378   [(set (match_dup 0) (match_dup 1))]
13379   "operands[1] = gen_rtx_REG (<MODE>mode, REGNO (operands[1]));")
13381 (define_insn "*vec_extractv4si"
13382   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,Yr,*x,x")
13383         (vec_select:SI
13384           (match_operand:V4SI 1 "register_operand" "x,0,0,x")
13385           (parallel [(match_operand:SI 2 "const_0_to_3_operand")])))]
13386   "TARGET_SSE4_1"
13388   switch (which_alternative)
13389     {
13390     case 0:
13391       return "%vpextrd\t{%2, %1, %0|%0, %1, %2}";
13393     case 1:
13394     case 2:
13395       operands [2] = GEN_INT (INTVAL (operands[2]) * 4);
13396       return "psrldq\t{%2, %0|%0, %2}";
13398     case 3:
13399       operands [2] = GEN_INT (INTVAL (operands[2]) * 4);
13400       return "vpsrldq\t{%2, %1, %0|%0, %1, %2}";
13402     default:
13403       gcc_unreachable ();
13404     }
13406   [(set_attr "isa" "*,noavx,noavx,avx")
13407    (set_attr "type" "sselog1,sseishft1,sseishft1,sseishft1")
13408    (set_attr "prefix_extra" "1,*,*,*")
13409    (set_attr "length_immediate" "1")
13410    (set_attr "prefix" "maybe_vex,orig,orig,vex")
13411    (set_attr "mode" "TI")])
13413 (define_insn "*vec_extractv4si_zext"
13414   [(set (match_operand:DI 0 "register_operand" "=r")
13415         (zero_extend:DI
13416           (vec_select:SI
13417             (match_operand:V4SI 1 "register_operand" "x")
13418             (parallel [(match_operand:SI 2 "const_0_to_3_operand")]))))]
13419   "TARGET_64BIT && TARGET_SSE4_1"
13420   "%vpextrd\t{%2, %1, %k0|%k0, %1, %2}"
13421   [(set_attr "type" "sselog1")
13422    (set_attr "prefix_extra" "1")
13423    (set_attr "length_immediate" "1")
13424    (set_attr "prefix" "maybe_vex")
13425    (set_attr "mode" "TI")])
13427 (define_insn "*vec_extractv4si_mem"
13428   [(set (match_operand:SI 0 "register_operand" "=x,r")
13429         (vec_select:SI
13430           (match_operand:V4SI 1 "memory_operand" "o,o")
13431           (parallel [(match_operand 2 "const_0_to_3_operand")])))]
13432   "TARGET_SSE"
13433   "#")
13435 (define_insn_and_split "*vec_extractv4si_zext_mem"
13436   [(set (match_operand:DI 0 "register_operand" "=x,r")
13437         (zero_extend:DI
13438           (vec_select:SI
13439             (match_operand:V4SI 1 "memory_operand" "o,o")
13440             (parallel [(match_operand:SI 2 "const_0_to_3_operand")]))))]
13441   "TARGET_64BIT && TARGET_SSE"
13442   "#"
13443   "&& reload_completed"
13444   [(set (match_dup 0) (zero_extend:DI (match_dup 1)))]
13446   operands[1] = adjust_address (operands[1], SImode, INTVAL (operands[2]) * 4);
13449 (define_insn "*vec_extractv2di_1"
13450   [(set (match_operand:DI 0 "nonimmediate_operand"     "=rm,m,x,x,x,x,r")
13451         (vec_select:DI
13452           (match_operand:V2DI 1 "nonimmediate_operand"  "x ,x,0,x,x,o,o")
13453           (parallel [(const_int 1)])))]
13454   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13455   "@
13456    %vpextrq\t{$1, %1, %0|%0, %1, 1}
13457    %vmovhps\t{%1, %0|%0, %1}
13458    psrldq\t{$8, %0|%0, 8}
13459    vpsrldq\t{$8, %1, %0|%0, %1, 8}
13460    movhlps\t{%1, %0|%0, %1}
13461    #
13462    #"
13463   [(set_attr "isa" "x64_sse4,*,sse2_noavx,avx,noavx,*,x64")
13464    (set_attr "type" "sselog1,ssemov,sseishft1,sseishft1,ssemov,ssemov,imov")
13465    (set_attr "length_immediate" "1,*,1,1,*,*,*")
13466    (set_attr "prefix_rex" "1,*,*,*,*,*,*")
13467    (set_attr "prefix_extra" "1,*,*,*,*,*,*")
13468    (set_attr "prefix" "maybe_vex,maybe_vex,orig,vex,orig,*,*")
13469    (set_attr "mode" "TI,V2SF,TI,TI,V4SF,DI,DI")])
13471 (define_split
13472   [(set (match_operand:<ssescalarmode> 0 "register_operand")
13473         (vec_select:<ssescalarmode>
13474           (match_operand:VI_128 1 "memory_operand")
13475           (parallel
13476             [(match_operand 2 "const_0_to_<ssescalarnummask>_operand")])))]
13477   "TARGET_SSE && reload_completed"
13478   [(set (match_dup 0) (match_dup 1))]
13480   int offs = INTVAL (operands[2]) * GET_MODE_SIZE (<ssescalarmode>mode);
13482   operands[1] = adjust_address (operands[1], <ssescalarmode>mode, offs);
13485 ;; Turn SImode or DImode extraction from arbitrary SSE/AVX/AVX512F
13486 ;; vector modes into vec_extract*.
13487 (define_split
13488   [(set (match_operand:SWI48x 0 "nonimmediate_operand")
13489         (match_operand:SWI48x 1 "register_operand"))]
13490   "can_create_pseudo_p ()
13491    && SUBREG_P (operands[1])
13492    && REG_P (SUBREG_REG (operands[1]))
13493    && (GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[1]))) == MODE_VECTOR_INT
13494        || (GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[1])))
13495            == MODE_VECTOR_FLOAT))
13496    && SUBREG_BYTE (operands[1]) == 0
13497    && TARGET_SSE
13498    && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[1]))) == 16
13499        || (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[1]))) == 32
13500            && TARGET_AVX)
13501        || (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[1]))) == 64
13502            && TARGET_AVX512F))
13503    && (<MODE>mode == SImode || TARGET_64BIT || MEM_P (operands[0]))"
13504   [(set (match_dup 0) (vec_select:SWI48x (match_dup 1)
13505                                          (parallel [(const_int 0)])))]
13507   rtx tmp;
13508   operands[1] = SUBREG_REG (operands[1]);
13509   switch (GET_MODE_SIZE (GET_MODE (operands[1])))
13510     {
13511     case 64:
13512       if (<MODE>mode == SImode)
13513         {
13514           tmp = gen_reg_rtx (V8SImode);
13515           emit_insn (gen_vec_extract_lo_v16si (tmp,
13516                                                gen_lowpart (V16SImode,
13517                                                             operands[1])));
13518         }
13519       else
13520         {
13521           tmp = gen_reg_rtx (V4DImode);
13522           emit_insn (gen_vec_extract_lo_v8di (tmp,
13523                                               gen_lowpart (V8DImode,
13524                                                            operands[1])));
13525         }
13526       operands[1] = tmp;
13527       /* FALLTHRU */
13528     case 32:
13529       tmp = gen_reg_rtx (<ssevecmode>mode);
13530       if (<MODE>mode == SImode)
13531         emit_insn (gen_vec_extract_lo_v8si (tmp, gen_lowpart (V8SImode,
13532                                                               operands[1])));
13533       else
13534         emit_insn (gen_vec_extract_lo_v4di (tmp, gen_lowpart (V4DImode,
13535                                                               operands[1])));
13536       operands[1] = tmp;
13537       break;
13538     case 16:
13539       operands[1] = gen_lowpart (<ssevecmode>mode, operands[1]);
13540       break;
13541     }
13544 (define_insn "*vec_concatv2si_sse4_1"
13545   [(set (match_operand:V2SI 0 "register_operand"
13546           "=Yr,*x,x, Yr,*x,x, x, *y,*y")
13547         (vec_concat:V2SI
13548           (match_operand:SI 1 "nonimmediate_operand"
13549           "  0, 0,x,  0,0, x,rm,  0,rm")
13550           (match_operand:SI 2 "vector_move_operand"
13551           " rm,rm,rm,Yr,*x,x, C,*ym, C")))]
13552   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
13553   "@
13554    pinsrd\t{$1, %2, %0|%0, %2, 1}
13555    pinsrd\t{$1, %2, %0|%0, %2, 1}
13556    vpinsrd\t{$1, %2, %1, %0|%0, %1, %2, 1}
13557    punpckldq\t{%2, %0|%0, %2}
13558    punpckldq\t{%2, %0|%0, %2}
13559    vpunpckldq\t{%2, %1, %0|%0, %1, %2}
13560    %vmovd\t{%1, %0|%0, %1}
13561    punpckldq\t{%2, %0|%0, %2}
13562    movd\t{%1, %0|%0, %1}"
13563   [(set_attr "isa" "noavx,noavx,avx,noavx,noavx,avx,*,*,*")
13564    (set_attr "type" "sselog,sselog,sselog,sselog,sselog,sselog,ssemov,mmxcvt,mmxmov")
13565    (set_attr "prefix_extra" "1,1,1,*,*,*,*,*,*")
13566    (set_attr "length_immediate" "1,1,1,*,*,*,*,*,*")
13567    (set_attr "prefix" "orig,orig,vex,orig,orig,vex,maybe_vex,orig,orig")
13568    (set_attr "mode" "TI,TI,TI,TI,TI,TI,TI,DI,DI")])
13570 ;; ??? In theory we can match memory for the MMX alternative, but allowing
13571 ;; nonimmediate_operand for operand 2 and *not* allowing memory for the SSE
13572 ;; alternatives pretty much forces the MMX alternative to be chosen.
13573 (define_insn "*vec_concatv2si"
13574   [(set (match_operand:V2SI 0 "register_operand"     "=x,x ,*y,x,x,*y,*y")
13575         (vec_concat:V2SI
13576           (match_operand:SI 1 "nonimmediate_operand" " 0,rm,rm,0,m, 0,*rm")
13577           (match_operand:SI 2 "reg_or_0_operand"     " x,C ,C, x,C,*y,C")))]
13578   "TARGET_SSE && !TARGET_SSE4_1"
13579   "@
13580    punpckldq\t{%2, %0|%0, %2}
13581    movd\t{%1, %0|%0, %1}
13582    movd\t{%1, %0|%0, %1}
13583    unpcklps\t{%2, %0|%0, %2}
13584    movss\t{%1, %0|%0, %1}
13585    punpckldq\t{%2, %0|%0, %2}
13586    movd\t{%1, %0|%0, %1}"
13587   [(set_attr "isa" "sse2,sse2,sse2,*,*,*,*")
13588    (set_attr "type" "sselog,ssemov,mmxmov,sselog,ssemov,mmxcvt,mmxmov")
13589    (set_attr "mode" "TI,TI,DI,V4SF,SF,DI,DI")])
13591 (define_insn "*vec_concatv4si"
13592   [(set (match_operand:V4SI 0 "register_operand"       "=x,x,x,x,x")
13593         (vec_concat:V4SI
13594           (match_operand:V2SI 1 "register_operand"     " 0,x,0,0,x")
13595           (match_operand:V2SI 2 "nonimmediate_operand" " x,x,x,m,m")))]
13596   "TARGET_SSE"
13597   "@
13598    punpcklqdq\t{%2, %0|%0, %2}
13599    vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
13600    movlhps\t{%2, %0|%0, %2}
13601    movhps\t{%2, %0|%0, %q2}
13602    vmovhps\t{%2, %1, %0|%0, %1, %q2}"
13603   [(set_attr "isa" "sse2_noavx,avx,noavx,noavx,avx")
13604    (set_attr "type" "sselog,sselog,ssemov,ssemov,ssemov")
13605    (set_attr "prefix" "orig,vex,orig,orig,vex")
13606    (set_attr "mode" "TI,TI,V4SF,V2SF,V2SF")])
13608 ;; movd instead of movq is required to handle broken assemblers.
13609 (define_insn "vec_concatv2di"
13610   [(set (match_operand:V2DI 0 "register_operand"
13611           "=Yr,*x,x ,Yi,x ,!x,x,x,x,x,x")
13612         (vec_concat:V2DI
13613           (match_operand:DI 1 "nonimmediate_operand"
13614           "  0, 0,x ,r ,xm,*y,0,x,0,0,x")
13615           (match_operand:DI 2 "vector_move_operand"
13616           "*rm,rm,rm,C ,C ,C ,x,x,x,m,m")))]
13617   "TARGET_SSE"
13618   "@
13619    pinsrq\t{$1, %2, %0|%0, %2, 1}
13620    pinsrq\t{$1, %2, %0|%0, %2, 1}
13621    vpinsrq\t{$1, %2, %1, %0|%0, %1, %2, 1}
13622    * return HAVE_AS_IX86_INTERUNIT_MOVQ ? \"%vmovq\t{%1, %0|%0, %1}\" : \"%vmovd\t{%1, %0|%0, %1}\";
13623    %vmovq\t{%1, %0|%0, %1}
13624    movq2dq\t{%1, %0|%0, %1}
13625    punpcklqdq\t{%2, %0|%0, %2}
13626    vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
13627    movlhps\t{%2, %0|%0, %2}
13628    movhps\t{%2, %0|%0, %2}
13629    vmovhps\t{%2, %1, %0|%0, %1, %2}"
13630   [(set_attr "isa" "x64_sse4_noavx,x64_sse4_noavx,x64_avx,x64,sse2,sse2,sse2_noavx,avx,noavx,noavx,avx")
13631    (set (attr "type")
13632      (if_then_else
13633        (eq_attr "alternative" "0,1,2,6,7")
13634        (const_string "sselog")
13635        (const_string "ssemov")))
13636    (set_attr "prefix_rex" "1,1,1,1,*,*,*,*,*,*,*")
13637    (set_attr "prefix_extra" "1,1,1,*,*,*,*,*,*,*,*")
13638    (set_attr "length_immediate" "1,1,1,*,*,*,*,*,*,*,*")
13639    (set_attr "prefix" "orig,orig,vex,maybe_vex,maybe_vex,orig,orig,vex,orig,orig,vex")
13640    (set_attr "mode" "TI,TI,TI,TI,TI,TI,TI,TI,V4SF,V2SF,V2SF")])
13642 (define_expand "vec_unpacks_lo_<mode>"
13643   [(match_operand:<sseunpackmode> 0 "register_operand")
13644    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
13645   "TARGET_SSE2"
13646   "ix86_expand_sse_unpack (operands[0], operands[1], false, false); DONE;")
13648 (define_expand "vec_unpacks_hi_<mode>"
13649   [(match_operand:<sseunpackmode> 0 "register_operand")
13650    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
13651   "TARGET_SSE2"
13652   "ix86_expand_sse_unpack (operands[0], operands[1], false, true); DONE;")
13654 (define_expand "vec_unpacku_lo_<mode>"
13655   [(match_operand:<sseunpackmode> 0 "register_operand")
13656    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
13657   "TARGET_SSE2"
13658   "ix86_expand_sse_unpack (operands[0], operands[1], true, false); DONE;")
13660 (define_expand "vec_unpacks_lo_hi"
13661   [(set (match_operand:QI 0 "register_operand")
13662         (subreg:QI (match_operand:HI 1 "register_operand") 0))]
13663   "TARGET_AVX512DQ")
13665 (define_expand "vec_unpacks_lo_si"
13666   [(set (match_operand:HI 0 "register_operand")
13667         (subreg:HI (match_operand:SI 1 "register_operand") 0))]
13668   "TARGET_AVX512F")
13670 (define_expand "vec_unpacks_lo_di"
13671   [(set (match_operand:SI 0 "register_operand")
13672         (subreg:SI (match_operand:DI 1 "register_operand") 0))]
13673   "TARGET_AVX512BW")
13675 (define_expand "vec_unpacku_hi_<mode>"
13676   [(match_operand:<sseunpackmode> 0 "register_operand")
13677    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
13678   "TARGET_SSE2"
13679   "ix86_expand_sse_unpack (operands[0], operands[1], true, true); DONE;")
13681 (define_expand "vec_unpacks_hi_hi"
13682   [(set (subreg:HI (match_operand:QI 0 "register_operand") 0)
13683         (lshiftrt:HI (match_operand:HI 1 "register_operand")
13684                      (const_int 8)))]
13685   "TARGET_AVX512F")
13687 (define_expand "vec_unpacks_hi_<mode>"
13688   [(set (subreg:SWI48x (match_operand:<HALFMASKMODE> 0 "register_operand") 0)
13689         (lshiftrt:SWI48x (match_operand:SWI48x 1 "register_operand")
13690                          (match_dup 2)))]
13691   "TARGET_AVX512BW"
13693   operands[2] = GEN_INT (GET_MODE_BITSIZE (<HALFMASKMODE>mode));
13696 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13698 ;; Miscellaneous
13700 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13702 (define_expand "<sse2_avx2>_uavg<mode>3<mask_name>"
13703   [(set (match_operand:VI12_AVX2 0 "register_operand")
13704         (truncate:VI12_AVX2
13705           (lshiftrt:<ssedoublemode>
13706             (plus:<ssedoublemode>
13707               (plus:<ssedoublemode>
13708                 (zero_extend:<ssedoublemode>
13709                   (match_operand:VI12_AVX2 1 "vector_operand"))
13710                 (zero_extend:<ssedoublemode>
13711                   (match_operand:VI12_AVX2 2 "vector_operand")))
13712               (match_dup <mask_expand_op3>))
13713             (const_int 1))))]
13714   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
13716   rtx tmp;
13717   if (<mask_applied>)
13718     tmp = operands[3];
13719   operands[3] = CONST1_RTX(<MODE>mode);
13720   ix86_fixup_binary_operands_no_copy (PLUS, <MODE>mode, operands);
13722   if (<mask_applied>)
13723     {
13724       operands[5] = operands[3];
13725       operands[3] = tmp;
13726     }
13729 (define_insn "*<sse2_avx2>_uavg<mode>3<mask_name>"
13730   [(set (match_operand:VI12_AVX2 0 "register_operand" "=x,v")
13731         (truncate:VI12_AVX2
13732           (lshiftrt:<ssedoublemode>
13733             (plus:<ssedoublemode>
13734               (plus:<ssedoublemode>
13735                 (zero_extend:<ssedoublemode>
13736                   (match_operand:VI12_AVX2 1 "vector_operand" "%0,v"))
13737                 (zero_extend:<ssedoublemode>
13738                   (match_operand:VI12_AVX2 2 "vector_operand" "xBm,vm")))
13739               (match_operand:VI12_AVX2 <mask_expand_op3> "const1_operand"))
13740             (const_int 1))))]
13741   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
13742    && ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
13743   "@
13744    pavg<ssemodesuffix>\t{%2, %0|%0, %2}
13745    vpavg<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
13746   [(set_attr "isa" "noavx,avx")
13747    (set_attr "type" "sseiadd")
13748    (set_attr "prefix_data16" "1,*")
13749    (set_attr "prefix" "orig,<mask_prefix>")
13750    (set_attr "mode" "<sseinsnmode>")])
13752 ;; The correct representation for this is absolutely enormous, and
13753 ;; surely not generally useful.
13754 (define_insn "<sse2_avx2>_psadbw"
13755   [(set (match_operand:VI8_AVX2_AVX512BW 0 "register_operand" "=x,v")
13756         (unspec:VI8_AVX2_AVX512BW
13757           [(match_operand:<ssebytemode> 1 "register_operand" "0,v")
13758            (match_operand:<ssebytemode> 2 "vector_operand" "xBm,vm")]
13759           UNSPEC_PSADBW))]
13760   "TARGET_SSE2"
13761   "@
13762    psadbw\t{%2, %0|%0, %2}
13763    vpsadbw\t{%2, %1, %0|%0, %1, %2}"
13764   [(set_attr "isa" "noavx,avx")
13765    (set_attr "type" "sseiadd")
13766    (set_attr "atom_unit" "simul")
13767    (set_attr "prefix_data16" "1,*")
13768    (set_attr "prefix" "orig,maybe_evex")
13769    (set_attr "mode" "<sseinsnmode>")])
13771 (define_insn "<sse>_movmsk<ssemodesuffix><avxsizesuffix>"
13772   [(set (match_operand:SI 0 "register_operand" "=r")
13773         (unspec:SI
13774           [(match_operand:VF_128_256 1 "register_operand" "x")]
13775           UNSPEC_MOVMSK))]
13776   "TARGET_SSE"
13777   "%vmovmsk<ssemodesuffix>\t{%1, %0|%0, %1}"
13778   [(set_attr "type" "ssemov")
13779    (set_attr "prefix" "maybe_vex")
13780    (set_attr "mode" "<MODE>")])
13782 (define_insn "*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_zext"
13783   [(set (match_operand:DI 0 "register_operand" "=r")
13784         (zero_extend:DI
13785           (unspec:SI
13786             [(match_operand:VF_128_256 1 "register_operand" "x")]
13787             UNSPEC_MOVMSK)))]
13788   "TARGET_64BIT && TARGET_SSE"
13789   "%vmovmsk<ssemodesuffix>\t{%1, %k0|%k0, %1}"
13790   [(set_attr "type" "ssemov")
13791    (set_attr "prefix" "maybe_vex")
13792    (set_attr "mode" "<MODE>")])
13794 (define_insn "<sse2_avx2>_pmovmskb"
13795   [(set (match_operand:SI 0 "register_operand" "=r")
13796         (unspec:SI
13797           [(match_operand:VI1_AVX2 1 "register_operand" "x")]
13798           UNSPEC_MOVMSK))]
13799   "TARGET_SSE2"
13800   "%vpmovmskb\t{%1, %0|%0, %1}"
13801   [(set_attr "type" "ssemov")
13802    (set (attr "prefix_data16")
13803      (if_then_else
13804        (match_test "TARGET_AVX")
13805      (const_string "*")
13806      (const_string "1")))
13807    (set_attr "prefix" "maybe_vex")
13808    (set_attr "mode" "SI")])
13810 (define_insn "*<sse2_avx2>_pmovmskb_zext"
13811   [(set (match_operand:DI 0 "register_operand" "=r")
13812         (zero_extend:DI
13813           (unspec:SI
13814             [(match_operand:VI1_AVX2 1 "register_operand" "x")]
13815             UNSPEC_MOVMSK)))]
13816   "TARGET_64BIT && TARGET_SSE2"
13817   "%vpmovmskb\t{%1, %k0|%k0, %1}"
13818   [(set_attr "type" "ssemov")
13819    (set (attr "prefix_data16")
13820      (if_then_else
13821        (match_test "TARGET_AVX")
13822      (const_string "*")
13823      (const_string "1")))
13824    (set_attr "prefix" "maybe_vex")
13825    (set_attr "mode" "SI")])
13827 (define_expand "sse2_maskmovdqu"
13828   [(set (match_operand:V16QI 0 "memory_operand")
13829         (unspec:V16QI [(match_operand:V16QI 1 "register_operand")
13830                        (match_operand:V16QI 2 "register_operand")
13831                        (match_dup 0)]
13832                       UNSPEC_MASKMOV))]
13833   "TARGET_SSE2")
13835 (define_insn "*sse2_maskmovdqu"
13836   [(set (mem:V16QI (match_operand:P 0 "register_operand" "D"))
13837         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "x")
13838                        (match_operand:V16QI 2 "register_operand" "x")
13839                        (mem:V16QI (match_dup 0))]
13840                       UNSPEC_MASKMOV))]
13841   "TARGET_SSE2"
13843   /* We can't use %^ here due to ASM_OUTPUT_OPCODE processing
13844      that requires %v to be at the beginning of the opcode name.  */
13845   if (Pmode != word_mode)
13846     fputs ("\taddr32", asm_out_file);
13847   return "%vmaskmovdqu\t{%2, %1|%1, %2}";
13849   [(set_attr "type" "ssemov")
13850    (set_attr "prefix_data16" "1")
13851    (set (attr "length_address")
13852      (symbol_ref ("Pmode != word_mode")))
13853    ;; The implicit %rdi operand confuses default length_vex computation.
13854    (set (attr "length_vex")
13855      (symbol_ref ("3 + REX_SSE_REGNO_P (REGNO (operands[2]))")))
13856    (set_attr "prefix" "maybe_vex")
13857    (set_attr "znver1_decode" "vector")
13858    (set_attr "mode" "TI")])
13860 (define_insn "sse_ldmxcsr"
13861   [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m")]
13862                     UNSPECV_LDMXCSR)]
13863   "TARGET_SSE"
13864   "%vldmxcsr\t%0"
13865   [(set_attr "type" "sse")
13866    (set_attr "atom_sse_attr" "mxcsr")
13867    (set_attr "prefix" "maybe_vex")
13868    (set_attr "memory" "load")])
13870 (define_insn "sse_stmxcsr"
13871   [(set (match_operand:SI 0 "memory_operand" "=m")
13872         (unspec_volatile:SI [(const_int 0)] UNSPECV_STMXCSR))]
13873   "TARGET_SSE"
13874   "%vstmxcsr\t%0"
13875   [(set_attr "type" "sse")
13876    (set_attr "atom_sse_attr" "mxcsr")
13877    (set_attr "prefix" "maybe_vex")
13878    (set_attr "memory" "store")])
13880 (define_insn "sse2_clflush"
13881   [(unspec_volatile [(match_operand 0 "address_operand" "p")]
13882                     UNSPECV_CLFLUSH)]
13883   "TARGET_SSE2"
13884   "clflush\t%a0"
13885   [(set_attr "type" "sse")
13886    (set_attr "atom_sse_attr" "fence")
13887    (set_attr "memory" "unknown")])
13889 ;; As per AMD and Intel ISA manuals, the first operand is extensions
13890 ;; and it goes to %ecx. The second operand received is hints and it goes
13891 ;; to %eax.
13892 (define_insn "sse3_mwait"
13893   [(unspec_volatile [(match_operand:SI 0 "register_operand" "c")
13894                      (match_operand:SI 1 "register_operand" "a")]
13895                     UNSPECV_MWAIT)]
13896   "TARGET_SSE3"
13897 ;; 64bit version is "mwait %rax,%rcx". But only lower 32bits are used.
13898 ;; Since 32bit register operands are implicitly zero extended to 64bit,
13899 ;; we only need to set up 32bit registers.
13900   "mwait"
13901   [(set_attr "length" "3")])
13903 (define_insn "sse3_monitor_<mode>"
13904   [(unspec_volatile [(match_operand:P 0 "register_operand" "a")
13905                      (match_operand:SI 1 "register_operand" "c")
13906                      (match_operand:SI 2 "register_operand" "d")]
13907                     UNSPECV_MONITOR)]
13908   "TARGET_SSE3"
13909 ;; 64bit version is "monitor %rax,%rcx,%rdx". But only lower 32bits in
13910 ;; RCX and RDX are used.  Since 32bit register operands are implicitly
13911 ;; zero extended to 64bit, we only need to set up 32bit registers.
13912   "%^monitor"
13913   [(set (attr "length")
13914      (symbol_ref ("(Pmode != word_mode) + 3")))])
13916 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13918 ;; SSSE3 instructions
13920 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13922 (define_code_iterator ssse3_plusminus [plus ss_plus minus ss_minus])
13924 (define_insn "avx2_ph<plusminus_mnemonic>wv16hi3"
13925   [(set (match_operand:V16HI 0 "register_operand" "=x")
13926         (vec_concat:V16HI
13927           (vec_concat:V8HI
13928             (vec_concat:V4HI
13929               (vec_concat:V2HI
13930                 (ssse3_plusminus:HI
13931                   (vec_select:HI
13932                     (match_operand:V16HI 1 "register_operand" "x")
13933                     (parallel [(const_int 0)]))
13934                   (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
13935                 (ssse3_plusminus:HI
13936                   (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
13937                   (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
13938               (vec_concat:V2HI
13939                 (ssse3_plusminus:HI
13940                   (vec_select:HI (match_dup 1) (parallel [(const_int 4)]))
13941                   (vec_select:HI (match_dup 1) (parallel [(const_int 5)])))
13942                 (ssse3_plusminus:HI
13943                   (vec_select:HI (match_dup 1) (parallel [(const_int 6)]))
13944                   (vec_select:HI (match_dup 1) (parallel [(const_int 7)])))))
13945             (vec_concat:V4HI
13946               (vec_concat:V2HI
13947                 (ssse3_plusminus:HI
13948                   (vec_select:HI (match_dup 1) (parallel [(const_int 8)]))
13949                   (vec_select:HI (match_dup 1) (parallel [(const_int 9)])))
13950                 (ssse3_plusminus:HI
13951                   (vec_select:HI (match_dup 1) (parallel [(const_int 10)]))
13952                   (vec_select:HI (match_dup 1) (parallel [(const_int 11)]))))
13953               (vec_concat:V2HI
13954                 (ssse3_plusminus:HI
13955                   (vec_select:HI (match_dup 1) (parallel [(const_int 12)]))
13956                   (vec_select:HI (match_dup 1) (parallel [(const_int 13)])))
13957                 (ssse3_plusminus:HI
13958                   (vec_select:HI (match_dup 1) (parallel [(const_int 14)]))
13959                   (vec_select:HI (match_dup 1) (parallel [(const_int 15)]))))))
13960           (vec_concat:V8HI
13961             (vec_concat:V4HI
13962               (vec_concat:V2HI
13963                 (ssse3_plusminus:HI
13964                   (vec_select:HI
13965                     (match_operand:V16HI 2 "nonimmediate_operand" "xm")
13966                     (parallel [(const_int 0)]))
13967                   (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
13968                 (ssse3_plusminus:HI
13969                   (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
13970                   (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))
13971               (vec_concat:V2HI
13972                 (ssse3_plusminus:HI
13973                   (vec_select:HI (match_dup 2) (parallel [(const_int 4)]))
13974                   (vec_select:HI (match_dup 2) (parallel [(const_int 5)])))
13975                 (ssse3_plusminus:HI
13976                   (vec_select:HI (match_dup 2) (parallel [(const_int 6)]))
13977                   (vec_select:HI (match_dup 2) (parallel [(const_int 7)])))))
13978             (vec_concat:V4HI
13979               (vec_concat:V2HI
13980                 (ssse3_plusminus:HI
13981                   (vec_select:HI (match_dup 2) (parallel [(const_int 8)]))
13982                   (vec_select:HI (match_dup 2) (parallel [(const_int 9)])))
13983                 (ssse3_plusminus:HI
13984                   (vec_select:HI (match_dup 2) (parallel [(const_int 10)]))
13985                   (vec_select:HI (match_dup 2) (parallel [(const_int 11)]))))
13986               (vec_concat:V2HI
13987                 (ssse3_plusminus:HI
13988                   (vec_select:HI (match_dup 2) (parallel [(const_int 12)]))
13989                   (vec_select:HI (match_dup 2) (parallel [(const_int 13)])))
13990                 (ssse3_plusminus:HI
13991                   (vec_select:HI (match_dup 2) (parallel [(const_int 14)]))
13992                   (vec_select:HI (match_dup 2) (parallel [(const_int 15)]))))))))]
13993   "TARGET_AVX2"
13994   "vph<plusminus_mnemonic>w\t{%2, %1, %0|%0, %1, %2}"
13995   [(set_attr "type" "sseiadd")
13996    (set_attr "prefix_extra" "1")
13997    (set_attr "prefix" "vex")
13998    (set_attr "mode" "OI")])
14000 (define_insn "ssse3_ph<plusminus_mnemonic>wv8hi3"
14001   [(set (match_operand:V8HI 0 "register_operand" "=x,x")
14002         (vec_concat:V8HI
14003           (vec_concat:V4HI
14004             (vec_concat:V2HI
14005               (ssse3_plusminus:HI
14006                 (vec_select:HI
14007                   (match_operand:V8HI 1 "register_operand" "0,x")
14008                   (parallel [(const_int 0)]))
14009                 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
14010               (ssse3_plusminus:HI
14011                 (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
14012                 (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
14013             (vec_concat:V2HI
14014               (ssse3_plusminus:HI
14015                 (vec_select:HI (match_dup 1) (parallel [(const_int 4)]))
14016                 (vec_select:HI (match_dup 1) (parallel [(const_int 5)])))
14017               (ssse3_plusminus:HI
14018                 (vec_select:HI (match_dup 1) (parallel [(const_int 6)]))
14019                 (vec_select:HI (match_dup 1) (parallel [(const_int 7)])))))
14020           (vec_concat:V4HI
14021             (vec_concat:V2HI
14022               (ssse3_plusminus:HI
14023                 (vec_select:HI
14024                   (match_operand:V8HI 2 "vector_operand" "xBm,xm")
14025                   (parallel [(const_int 0)]))
14026                 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
14027               (ssse3_plusminus:HI
14028                 (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
14029                 (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))
14030             (vec_concat:V2HI
14031               (ssse3_plusminus:HI
14032                 (vec_select:HI (match_dup 2) (parallel [(const_int 4)]))
14033                 (vec_select:HI (match_dup 2) (parallel [(const_int 5)])))
14034               (ssse3_plusminus:HI
14035                 (vec_select:HI (match_dup 2) (parallel [(const_int 6)]))
14036                 (vec_select:HI (match_dup 2) (parallel [(const_int 7)])))))))]
14037   "TARGET_SSSE3"
14038   "@
14039    ph<plusminus_mnemonic>w\t{%2, %0|%0, %2}
14040    vph<plusminus_mnemonic>w\t{%2, %1, %0|%0, %1, %2}"
14041   [(set_attr "isa" "noavx,avx")
14042    (set_attr "type" "sseiadd")
14043    (set_attr "atom_unit" "complex")
14044    (set_attr "prefix_data16" "1,*")
14045    (set_attr "prefix_extra" "1")
14046    (set_attr "prefix" "orig,vex")
14047    (set_attr "mode" "TI")])
14049 (define_insn "ssse3_ph<plusminus_mnemonic>wv4hi3"
14050   [(set (match_operand:V4HI 0 "register_operand" "=y")
14051         (vec_concat:V4HI
14052           (vec_concat:V2HI
14053             (ssse3_plusminus:HI
14054               (vec_select:HI
14055                 (match_operand:V4HI 1 "register_operand" "0")
14056                 (parallel [(const_int 0)]))
14057               (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
14058             (ssse3_plusminus:HI
14059               (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
14060               (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
14061           (vec_concat:V2HI
14062             (ssse3_plusminus:HI
14063               (vec_select:HI
14064                 (match_operand:V4HI 2 "nonimmediate_operand" "ym")
14065                 (parallel [(const_int 0)]))
14066               (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
14067             (ssse3_plusminus:HI
14068               (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
14069               (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))))]
14070   "TARGET_SSSE3"
14071   "ph<plusminus_mnemonic>w\t{%2, %0|%0, %2}"
14072   [(set_attr "type" "sseiadd")
14073    (set_attr "atom_unit" "complex")
14074    (set_attr "prefix_extra" "1")
14075    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14076    (set_attr "mode" "DI")])
14078 (define_insn "avx2_ph<plusminus_mnemonic>dv8si3"
14079   [(set (match_operand:V8SI 0 "register_operand" "=x")
14080         (vec_concat:V8SI
14081           (vec_concat:V4SI
14082             (vec_concat:V2SI
14083               (plusminus:SI
14084                 (vec_select:SI
14085                   (match_operand:V8SI 1 "register_operand" "x")
14086                   (parallel [(const_int 0)]))
14087                 (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
14088               (plusminus:SI
14089                 (vec_select:SI (match_dup 1) (parallel [(const_int 2)]))
14090                 (vec_select:SI (match_dup 1) (parallel [(const_int 3)]))))
14091             (vec_concat:V2SI
14092               (plusminus:SI
14093                 (vec_select:SI (match_dup 1) (parallel [(const_int 4)]))
14094                 (vec_select:SI (match_dup 1) (parallel [(const_int 5)])))
14095               (plusminus:SI
14096                 (vec_select:SI (match_dup 1) (parallel [(const_int 6)]))
14097                 (vec_select:SI (match_dup 1) (parallel [(const_int 7)])))))
14098           (vec_concat:V4SI
14099             (vec_concat:V2SI
14100               (plusminus:SI
14101                 (vec_select:SI
14102                   (match_operand:V8SI 2 "nonimmediate_operand" "xm")
14103                   (parallel [(const_int 0)]))
14104                 (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))
14105               (plusminus:SI
14106                 (vec_select:SI (match_dup 2) (parallel [(const_int 2)]))
14107                 (vec_select:SI (match_dup 2) (parallel [(const_int 3)]))))
14108             (vec_concat:V2SI
14109               (plusminus:SI
14110                 (vec_select:SI (match_dup 2) (parallel [(const_int 4)]))
14111                 (vec_select:SI (match_dup 2) (parallel [(const_int 5)])))
14112               (plusminus:SI
14113                 (vec_select:SI (match_dup 2) (parallel [(const_int 6)]))
14114                 (vec_select:SI (match_dup 2) (parallel [(const_int 7)])))))))]
14115   "TARGET_AVX2"
14116   "vph<plusminus_mnemonic>d\t{%2, %1, %0|%0, %1, %2}"
14117   [(set_attr "type" "sseiadd")
14118    (set_attr "prefix_extra" "1")
14119    (set_attr "prefix" "vex")
14120    (set_attr "mode" "OI")])
14122 (define_insn "ssse3_ph<plusminus_mnemonic>dv4si3"
14123   [(set (match_operand:V4SI 0 "register_operand" "=x,x")
14124         (vec_concat:V4SI
14125           (vec_concat:V2SI
14126             (plusminus:SI
14127               (vec_select:SI
14128                 (match_operand:V4SI 1 "register_operand" "0,x")
14129                 (parallel [(const_int 0)]))
14130               (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
14131             (plusminus:SI
14132               (vec_select:SI (match_dup 1) (parallel [(const_int 2)]))
14133               (vec_select:SI (match_dup 1) (parallel [(const_int 3)]))))
14134           (vec_concat:V2SI
14135             (plusminus:SI
14136               (vec_select:SI
14137                 (match_operand:V4SI 2 "vector_operand" "xBm,xm")
14138                 (parallel [(const_int 0)]))
14139               (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))
14140             (plusminus:SI
14141               (vec_select:SI (match_dup 2) (parallel [(const_int 2)]))
14142               (vec_select:SI (match_dup 2) (parallel [(const_int 3)]))))))]
14143   "TARGET_SSSE3"
14144   "@
14145    ph<plusminus_mnemonic>d\t{%2, %0|%0, %2}
14146    vph<plusminus_mnemonic>d\t{%2, %1, %0|%0, %1, %2}"
14147   [(set_attr "isa" "noavx,avx")
14148    (set_attr "type" "sseiadd")
14149    (set_attr "atom_unit" "complex")
14150    (set_attr "prefix_data16" "1,*")
14151    (set_attr "prefix_extra" "1")
14152    (set_attr "prefix" "orig,vex")
14153    (set_attr "mode" "TI")])
14155 (define_insn "ssse3_ph<plusminus_mnemonic>dv2si3"
14156   [(set (match_operand:V2SI 0 "register_operand" "=y")
14157         (vec_concat:V2SI
14158           (plusminus:SI
14159             (vec_select:SI
14160               (match_operand:V2SI 1 "register_operand" "0")
14161               (parallel [(const_int 0)]))
14162             (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
14163           (plusminus:SI
14164             (vec_select:SI
14165               (match_operand:V2SI 2 "nonimmediate_operand" "ym")
14166               (parallel [(const_int 0)]))
14167             (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))))]
14168   "TARGET_SSSE3"
14169   "ph<plusminus_mnemonic>d\t{%2, %0|%0, %2}"
14170   [(set_attr "type" "sseiadd")
14171    (set_attr "atom_unit" "complex")
14172    (set_attr "prefix_extra" "1")
14173    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14174    (set_attr "mode" "DI")])
14176 (define_insn "avx2_pmaddubsw256"
14177   [(set (match_operand:V16HI 0 "register_operand" "=x")
14178         (ss_plus:V16HI
14179           (mult:V16HI
14180             (zero_extend:V16HI
14181               (vec_select:V16QI
14182                 (match_operand:V32QI 1 "register_operand" "x")
14183                 (parallel [(const_int 0) (const_int 2)
14184                            (const_int 4) (const_int 6)
14185                            (const_int 8) (const_int 10)
14186                            (const_int 12) (const_int 14)
14187                            (const_int 16) (const_int 18)
14188                            (const_int 20) (const_int 22)
14189                            (const_int 24) (const_int 26)
14190                            (const_int 28) (const_int 30)])))
14191             (sign_extend:V16HI
14192               (vec_select:V16QI
14193                 (match_operand:V32QI 2 "nonimmediate_operand" "xm")
14194                 (parallel [(const_int 0) (const_int 2)
14195                            (const_int 4) (const_int 6)
14196                            (const_int 8) (const_int 10)
14197                            (const_int 12) (const_int 14)
14198                            (const_int 16) (const_int 18)
14199                            (const_int 20) (const_int 22)
14200                            (const_int 24) (const_int 26)
14201                            (const_int 28) (const_int 30)]))))
14202           (mult:V16HI
14203             (zero_extend:V16HI
14204               (vec_select:V16QI (match_dup 1)
14205                 (parallel [(const_int 1) (const_int 3)
14206                            (const_int 5) (const_int 7)
14207                            (const_int 9) (const_int 11)
14208                            (const_int 13) (const_int 15)
14209                            (const_int 17) (const_int 19)
14210                            (const_int 21) (const_int 23)
14211                            (const_int 25) (const_int 27)
14212                            (const_int 29) (const_int 31)])))
14213             (sign_extend:V16HI
14214               (vec_select:V16QI (match_dup 2)
14215                 (parallel [(const_int 1) (const_int 3)
14216                            (const_int 5) (const_int 7)
14217                            (const_int 9) (const_int 11)
14218                            (const_int 13) (const_int 15)
14219                            (const_int 17) (const_int 19)
14220                            (const_int 21) (const_int 23)
14221                            (const_int 25) (const_int 27)
14222                            (const_int 29) (const_int 31)]))))))]
14223   "TARGET_AVX2"
14224   "vpmaddubsw\t{%2, %1, %0|%0, %1, %2}"
14225   [(set_attr "type" "sseiadd")
14226    (set_attr "prefix_extra" "1")
14227    (set_attr "prefix" "vex")
14228    (set_attr "mode" "OI")])
14230 ;; The correct representation for this is absolutely enormous, and
14231 ;; surely not generally useful.
14232 (define_insn "avx512bw_pmaddubsw512<mode><mask_name>"
14233   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
14234           (unspec:VI2_AVX512VL
14235             [(match_operand:<dbpsadbwmode> 1 "register_operand" "v")
14236              (match_operand:<dbpsadbwmode> 2 "nonimmediate_operand" "vm")]
14237              UNSPEC_PMADDUBSW512))]
14238    "TARGET_AVX512BW"
14239    "vpmaddubsw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}";
14240   [(set_attr "type" "sseiadd")
14241    (set_attr "prefix" "evex")
14242    (set_attr "mode" "XI")])
14244 (define_insn "avx512bw_umulhrswv32hi3<mask_name>"
14245   [(set (match_operand:V32HI 0 "register_operand" "=v")
14246         (truncate:V32HI
14247           (lshiftrt:V32SI
14248             (plus:V32SI
14249               (lshiftrt:V32SI
14250                 (mult:V32SI
14251                   (sign_extend:V32SI
14252                     (match_operand:V32HI 1 "nonimmediate_operand" "%v"))
14253                   (sign_extend:V32SI
14254                     (match_operand:V32HI 2 "nonimmediate_operand" "vm")))
14255                 (const_int 14))
14256               (const_vector:V32HI [(const_int 1) (const_int 1)
14257                                    (const_int 1) (const_int 1)
14258                                    (const_int 1) (const_int 1)
14259                                    (const_int 1) (const_int 1)
14260                                    (const_int 1) (const_int 1)
14261                                    (const_int 1) (const_int 1)
14262                                    (const_int 1) (const_int 1)
14263                                    (const_int 1) (const_int 1)
14264                                    (const_int 1) (const_int 1)
14265                                    (const_int 1) (const_int 1)
14266                                    (const_int 1) (const_int 1)
14267                                    (const_int 1) (const_int 1)
14268                                    (const_int 1) (const_int 1)
14269                                    (const_int 1) (const_int 1)
14270                                    (const_int 1) (const_int 1)
14271                                    (const_int 1) (const_int 1)]))
14272             (const_int 1))))]
14273   "TARGET_AVX512BW"
14274   "vpmulhrsw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14275   [(set_attr "type" "sseimul")
14276    (set_attr "prefix" "evex")
14277    (set_attr "mode" "XI")])
14279 (define_insn "ssse3_pmaddubsw128"
14280   [(set (match_operand:V8HI 0 "register_operand" "=x,x")
14281         (ss_plus:V8HI
14282           (mult:V8HI
14283             (zero_extend:V8HI
14284               (vec_select:V8QI
14285                 (match_operand:V16QI 1 "register_operand" "0,x")
14286                 (parallel [(const_int 0) (const_int 2)
14287                            (const_int 4) (const_int 6)
14288                            (const_int 8) (const_int 10)
14289                            (const_int 12) (const_int 14)])))
14290             (sign_extend:V8HI
14291               (vec_select:V8QI
14292                 (match_operand:V16QI 2 "vector_operand" "xBm,xm")
14293                 (parallel [(const_int 0) (const_int 2)
14294                            (const_int 4) (const_int 6)
14295                            (const_int 8) (const_int 10)
14296                            (const_int 12) (const_int 14)]))))
14297           (mult:V8HI
14298             (zero_extend:V8HI
14299               (vec_select:V8QI (match_dup 1)
14300                 (parallel [(const_int 1) (const_int 3)
14301                            (const_int 5) (const_int 7)
14302                            (const_int 9) (const_int 11)
14303                            (const_int 13) (const_int 15)])))
14304             (sign_extend:V8HI
14305               (vec_select:V8QI (match_dup 2)
14306                 (parallel [(const_int 1) (const_int 3)
14307                            (const_int 5) (const_int 7)
14308                            (const_int 9) (const_int 11)
14309                            (const_int 13) (const_int 15)]))))))]
14310   "TARGET_SSSE3"
14311   "@
14312    pmaddubsw\t{%2, %0|%0, %2}
14313    vpmaddubsw\t{%2, %1, %0|%0, %1, %2}"
14314   [(set_attr "isa" "noavx,avx")
14315    (set_attr "type" "sseiadd")
14316    (set_attr "atom_unit" "simul")
14317    (set_attr "prefix_data16" "1,*")
14318    (set_attr "prefix_extra" "1")
14319    (set_attr "prefix" "orig,vex")
14320    (set_attr "mode" "TI")])
14322 (define_insn "ssse3_pmaddubsw"
14323   [(set (match_operand:V4HI 0 "register_operand" "=y")
14324         (ss_plus:V4HI
14325           (mult:V4HI
14326             (zero_extend:V4HI
14327               (vec_select:V4QI
14328                 (match_operand:V8QI 1 "register_operand" "0")
14329                 (parallel [(const_int 0) (const_int 2)
14330                            (const_int 4) (const_int 6)])))
14331             (sign_extend:V4HI
14332               (vec_select:V4QI
14333                 (match_operand:V8QI 2 "nonimmediate_operand" "ym")
14334                 (parallel [(const_int 0) (const_int 2)
14335                            (const_int 4) (const_int 6)]))))
14336           (mult:V4HI
14337             (zero_extend:V4HI
14338               (vec_select:V4QI (match_dup 1)
14339                 (parallel [(const_int 1) (const_int 3)
14340                            (const_int 5) (const_int 7)])))
14341             (sign_extend:V4HI
14342               (vec_select:V4QI (match_dup 2)
14343                 (parallel [(const_int 1) (const_int 3)
14344                            (const_int 5) (const_int 7)]))))))]
14345   "TARGET_SSSE3"
14346   "pmaddubsw\t{%2, %0|%0, %2}"
14347   [(set_attr "type" "sseiadd")
14348    (set_attr "atom_unit" "simul")
14349    (set_attr "prefix_extra" "1")
14350    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14351    (set_attr "mode" "DI")])
14353 (define_mode_iterator PMULHRSW
14354   [V4HI V8HI (V16HI "TARGET_AVX2")])
14356 (define_expand "<ssse3_avx2>_pmulhrsw<mode>3_mask"
14357   [(set (match_operand:PMULHRSW 0 "register_operand")
14358         (vec_merge:PMULHRSW
14359           (truncate:PMULHRSW
14360             (lshiftrt:<ssedoublemode>
14361               (plus:<ssedoublemode>
14362                 (lshiftrt:<ssedoublemode>
14363                   (mult:<ssedoublemode>
14364                     (sign_extend:<ssedoublemode>
14365                       (match_operand:PMULHRSW 1 "nonimmediate_operand"))
14366                     (sign_extend:<ssedoublemode>
14367                       (match_operand:PMULHRSW 2 "nonimmediate_operand")))
14368                   (const_int 14))
14369                 (match_dup 5))
14370               (const_int 1)))
14371           (match_operand:PMULHRSW 3 "register_operand")
14372           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
14373   "TARGET_AVX512BW && TARGET_AVX512VL"
14375   operands[5] = CONST1_RTX(<MODE>mode);
14376   ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
14379 (define_expand "<ssse3_avx2>_pmulhrsw<mode>3"
14380   [(set (match_operand:PMULHRSW 0 "register_operand")
14381         (truncate:PMULHRSW
14382           (lshiftrt:<ssedoublemode>
14383             (plus:<ssedoublemode>
14384               (lshiftrt:<ssedoublemode>
14385                 (mult:<ssedoublemode>
14386                   (sign_extend:<ssedoublemode>
14387                     (match_operand:PMULHRSW 1 "nonimmediate_operand"))
14388                   (sign_extend:<ssedoublemode>
14389                     (match_operand:PMULHRSW 2 "nonimmediate_operand")))
14390                 (const_int 14))
14391               (match_dup 3))
14392             (const_int 1))))]
14393   "TARGET_AVX2"
14395   operands[3] = CONST1_RTX(<MODE>mode);
14396   ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
14399 (define_insn "*<ssse3_avx2>_pmulhrsw<mode>3<mask_name>"
14400   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,v")
14401         (truncate:VI2_AVX2
14402           (lshiftrt:<ssedoublemode>
14403             (plus:<ssedoublemode>
14404               (lshiftrt:<ssedoublemode>
14405                 (mult:<ssedoublemode>
14406                   (sign_extend:<ssedoublemode>
14407                     (match_operand:VI2_AVX2 1 "vector_operand" "%0,v"))
14408                   (sign_extend:<ssedoublemode>
14409                     (match_operand:VI2_AVX2 2 "vector_operand" "xBm,vm")))
14410                 (const_int 14))
14411               (match_operand:VI2_AVX2 3 "const1_operand"))
14412             (const_int 1))))]
14413   "TARGET_SSSE3 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
14414    && ix86_binary_operator_ok (MULT, <MODE>mode, operands)"
14415   "@
14416    pmulhrsw\t{%2, %0|%0, %2}
14417    vpmulhrsw\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}"
14418   [(set_attr "isa" "noavx,avx")
14419    (set_attr "type" "sseimul")
14420    (set_attr "prefix_data16" "1,*")
14421    (set_attr "prefix_extra" "1")
14422    (set_attr "prefix" "orig,maybe_evex")
14423    (set_attr "mode" "<sseinsnmode>")])
14425 (define_insn "*ssse3_pmulhrswv4hi3"
14426   [(set (match_operand:V4HI 0 "register_operand" "=y")
14427         (truncate:V4HI
14428           (lshiftrt:V4SI
14429             (plus:V4SI
14430               (lshiftrt:V4SI
14431                 (mult:V4SI
14432                   (sign_extend:V4SI
14433                     (match_operand:V4HI 1 "nonimmediate_operand" "%0"))
14434                   (sign_extend:V4SI
14435                     (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
14436                 (const_int 14))
14437               (match_operand:V4HI 3 "const1_operand"))
14438             (const_int 1))))]
14439   "TARGET_SSSE3 && ix86_binary_operator_ok (MULT, V4HImode, operands)"
14440   "pmulhrsw\t{%2, %0|%0, %2}"
14441   [(set_attr "type" "sseimul")
14442    (set_attr "prefix_extra" "1")
14443    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14444    (set_attr "mode" "DI")])
14446 (define_insn "<ssse3_avx2>_pshufb<mode>3<mask_name>"
14447   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,v")
14448         (unspec:VI1_AVX512
14449           [(match_operand:VI1_AVX512 1 "register_operand" "0,v")
14450            (match_operand:VI1_AVX512 2 "vector_operand" "xBm,vm")]
14451           UNSPEC_PSHUFB))]
14452   "TARGET_SSSE3 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
14453   "@
14454    pshufb\t{%2, %0|%0, %2}
14455    vpshufb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14456   [(set_attr "isa" "noavx,avx")
14457    (set_attr "type" "sselog1")
14458    (set_attr "prefix_data16" "1,*")
14459    (set_attr "prefix_extra" "1")
14460    (set_attr "prefix" "orig,maybe_evex")
14461    (set_attr "btver2_decode" "vector,vector")
14462    (set_attr "mode" "<sseinsnmode>")])
14464 (define_insn "ssse3_pshufbv8qi3"
14465   [(set (match_operand:V8QI 0 "register_operand" "=y")
14466         (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "0")
14467                       (match_operand:V8QI 2 "nonimmediate_operand" "ym")]
14468                      UNSPEC_PSHUFB))]
14469   "TARGET_SSSE3"
14470   "pshufb\t{%2, %0|%0, %2}";
14471   [(set_attr "type" "sselog1")
14472    (set_attr "prefix_extra" "1")
14473    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14474    (set_attr "mode" "DI")])
14476 (define_insn "<ssse3_avx2>_psign<mode>3"
14477   [(set (match_operand:VI124_AVX2 0 "register_operand" "=x,x")
14478         (unspec:VI124_AVX2
14479           [(match_operand:VI124_AVX2 1 "register_operand" "0,x")
14480            (match_operand:VI124_AVX2 2 "vector_operand" "xBm,xm")]
14481           UNSPEC_PSIGN))]
14482   "TARGET_SSSE3"
14483   "@
14484    psign<ssemodesuffix>\t{%2, %0|%0, %2}
14485    vpsign<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
14486   [(set_attr "isa" "noavx,avx")
14487    (set_attr "type" "sselog1")
14488    (set_attr "prefix_data16" "1,*")
14489    (set_attr "prefix_extra" "1")
14490    (set_attr "prefix" "orig,vex")
14491    (set_attr "mode" "<sseinsnmode>")])
14493 (define_insn "ssse3_psign<mode>3"
14494   [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
14495         (unspec:MMXMODEI
14496           [(match_operand:MMXMODEI 1 "register_operand" "0")
14497            (match_operand:MMXMODEI 2 "nonimmediate_operand" "ym")]
14498           UNSPEC_PSIGN))]
14499   "TARGET_SSSE3"
14500   "psign<mmxvecsize>\t{%2, %0|%0, %2}";
14501   [(set_attr "type" "sselog1")
14502    (set_attr "prefix_extra" "1")
14503    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14504    (set_attr "mode" "DI")])
14506 (define_insn "<ssse3_avx2>_palignr<mode>_mask"
14507   [(set (match_operand:VI1_AVX512 0 "register_operand" "=v")
14508         (vec_merge:VI1_AVX512
14509           (unspec:VI1_AVX512
14510             [(match_operand:VI1_AVX512 1 "register_operand" "v")
14511              (match_operand:VI1_AVX512 2 "nonimmediate_operand" "vm")
14512              (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n")]
14513             UNSPEC_PALIGNR)
14514         (match_operand:VI1_AVX512 4 "vector_move_operand" "0C")
14515         (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
14516   "TARGET_AVX512BW && (<MODE_SIZE> == 64 || TARGET_AVX512VL)"
14518   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
14519   return "vpalignr\t{%3, %2, %1, %0%{%5%}%N4|%0%{%5%}%N4, %1, %2, %3}";
14521   [(set_attr "type" "sseishft")
14522    (set_attr "atom_unit" "sishuf")
14523    (set_attr "prefix_extra" "1")
14524    (set_attr "length_immediate" "1")
14525    (set_attr "prefix" "evex")
14526    (set_attr "mode" "<sseinsnmode>")])
14528 (define_insn "<ssse3_avx2>_palignr<mode>"
14529   [(set (match_operand:SSESCALARMODE 0 "register_operand" "=x,v")
14530         (unspec:SSESCALARMODE
14531           [(match_operand:SSESCALARMODE 1 "register_operand" "0,v")
14532            (match_operand:SSESCALARMODE 2 "vector_operand" "xBm,vm")
14533            (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n,n")]
14534           UNSPEC_PALIGNR))]
14535   "TARGET_SSSE3"
14537   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
14539   switch (which_alternative)
14540     {
14541     case 0:
14542       return "palignr\t{%3, %2, %0|%0, %2, %3}";
14543     case 1:
14544       return "vpalignr\t{%3, %2, %1, %0|%0, %1, %2, %3}";
14545     default:
14546       gcc_unreachable ();
14547     }
14549   [(set_attr "isa" "noavx,avx")
14550    (set_attr "type" "sseishft")
14551    (set_attr "atom_unit" "sishuf")
14552    (set_attr "prefix_data16" "1,*")
14553    (set_attr "prefix_extra" "1")
14554    (set_attr "length_immediate" "1")
14555    (set_attr "prefix" "orig,vex")
14556    (set_attr "mode" "<sseinsnmode>")])
14558 (define_insn "ssse3_palignrdi"
14559   [(set (match_operand:DI 0 "register_operand" "=y")
14560         (unspec:DI [(match_operand:DI 1 "register_operand" "0")
14561                     (match_operand:DI 2 "nonimmediate_operand" "ym")
14562                     (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n")]
14563                    UNSPEC_PALIGNR))]
14564   "TARGET_SSSE3"
14566   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
14567   return "palignr\t{%3, %2, %0|%0, %2, %3}";
14569   [(set_attr "type" "sseishft")
14570    (set_attr "atom_unit" "sishuf")
14571    (set_attr "prefix_extra" "1")
14572    (set_attr "length_immediate" "1")
14573    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14574    (set_attr "mode" "DI")])
14576 ;; Mode iterator to handle singularity w/ absence of V2DI and V4DI
14577 ;; modes for abs instruction on pre AVX-512 targets.
14578 (define_mode_iterator VI1248_AVX512VL_AVX512BW
14579   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
14580    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI
14581    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI
14582    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
14584 (define_insn "*abs<mode>2"
14585   [(set (match_operand:VI1248_AVX512VL_AVX512BW 0 "register_operand" "=v")
14586         (abs:VI1248_AVX512VL_AVX512BW
14587           (match_operand:VI1248_AVX512VL_AVX512BW 1 "vector_operand" "vBm")))]
14588   "TARGET_SSSE3"
14589   "%vpabs<ssemodesuffix>\t{%1, %0|%0, %1}"
14590   [(set_attr "type" "sselog1")
14591    (set_attr "prefix_data16" "1")
14592    (set_attr "prefix_extra" "1")
14593    (set_attr "prefix" "maybe_vex")
14594    (set_attr "mode" "<sseinsnmode>")])
14596 (define_insn "abs<mode>2_mask"
14597   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
14598         (vec_merge:VI48_AVX512VL
14599           (abs:VI48_AVX512VL
14600             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm"))
14601           (match_operand:VI48_AVX512VL 2 "vector_move_operand" "0C")
14602           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
14603   "TARGET_AVX512F"
14604   "vpabs<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
14605   [(set_attr "type" "sselog1")
14606    (set_attr "prefix" "evex")
14607    (set_attr "mode" "<sseinsnmode>")])
14609 (define_insn "abs<mode>2_mask"
14610   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
14611         (vec_merge:VI12_AVX512VL
14612           (abs:VI12_AVX512VL
14613             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "vm"))
14614           (match_operand:VI12_AVX512VL 2 "vector_move_operand" "0C")
14615           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
14616   "TARGET_AVX512BW"
14617   "vpabs<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
14618   [(set_attr "type" "sselog1")
14619    (set_attr "prefix" "evex")
14620    (set_attr "mode" "<sseinsnmode>")])
14622 (define_expand "abs<mode>2"
14623   [(set (match_operand:VI1248_AVX512VL_AVX512BW 0 "register_operand")
14624         (abs:VI1248_AVX512VL_AVX512BW
14625           (match_operand:VI1248_AVX512VL_AVX512BW 1 "vector_operand")))]
14626   "TARGET_SSE2"
14628   if (!TARGET_SSSE3)
14629     {
14630       ix86_expand_sse2_abs (operands[0], operands[1]);
14631       DONE;
14632     }
14635 (define_insn "abs<mode>2"
14636   [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
14637         (abs:MMXMODEI
14638           (match_operand:MMXMODEI 1 "nonimmediate_operand" "ym")))]
14639   "TARGET_SSSE3"
14640   "pabs<mmxvecsize>\t{%1, %0|%0, %1}";
14641   [(set_attr "type" "sselog1")
14642    (set_attr "prefix_rep" "0")
14643    (set_attr "prefix_extra" "1")
14644    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14645    (set_attr "mode" "DI")])
14647 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14649 ;; AMD SSE4A instructions
14651 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14653 (define_insn "sse4a_movnt<mode>"
14654   [(set (match_operand:MODEF 0 "memory_operand" "=m")
14655         (unspec:MODEF
14656           [(match_operand:MODEF 1 "register_operand" "x")]
14657           UNSPEC_MOVNT))]
14658   "TARGET_SSE4A"
14659   "movnt<ssemodesuffix>\t{%1, %0|%0, %1}"
14660   [(set_attr "type" "ssemov")
14661    (set_attr "mode" "<MODE>")])
14663 (define_insn "sse4a_vmmovnt<mode>"
14664   [(set (match_operand:<ssescalarmode> 0 "memory_operand" "=m")
14665         (unspec:<ssescalarmode>
14666           [(vec_select:<ssescalarmode>
14667              (match_operand:VF_128 1 "register_operand" "x")
14668              (parallel [(const_int 0)]))]
14669           UNSPEC_MOVNT))]
14670   "TARGET_SSE4A"
14671   "movnt<ssescalarmodesuffix>\t{%1, %0|%0, %1}"
14672   [(set_attr "type" "ssemov")
14673    (set_attr "mode" "<ssescalarmode>")])
14675 (define_insn "sse4a_extrqi"
14676   [(set (match_operand:V2DI 0 "register_operand" "=x")
14677         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
14678                       (match_operand 2 "const_0_to_255_operand")
14679                       (match_operand 3 "const_0_to_255_operand")]
14680                      UNSPEC_EXTRQI))]
14681   "TARGET_SSE4A"
14682   "extrq\t{%3, %2, %0|%0, %2, %3}"
14683   [(set_attr "type" "sse")
14684    (set_attr "prefix_data16" "1")
14685    (set_attr "length_immediate" "2")
14686    (set_attr "mode" "TI")])
14688 (define_insn "sse4a_extrq"
14689   [(set (match_operand:V2DI 0 "register_operand" "=x")
14690         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
14691                       (match_operand:V16QI 2 "register_operand" "x")]
14692                      UNSPEC_EXTRQ))]
14693   "TARGET_SSE4A"
14694   "extrq\t{%2, %0|%0, %2}"
14695   [(set_attr "type" "sse")
14696    (set_attr "prefix_data16" "1")
14697    (set_attr "mode" "TI")])
14699 (define_insn "sse4a_insertqi"
14700   [(set (match_operand:V2DI 0 "register_operand" "=x")
14701         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
14702                       (match_operand:V2DI 2 "register_operand" "x")
14703                       (match_operand 3 "const_0_to_255_operand")
14704                       (match_operand 4 "const_0_to_255_operand")]
14705                      UNSPEC_INSERTQI))]
14706   "TARGET_SSE4A"
14707   "insertq\t{%4, %3, %2, %0|%0, %2, %3, %4}"
14708   [(set_attr "type" "sseins")
14709    (set_attr "prefix_data16" "0")
14710    (set_attr "prefix_rep" "1")
14711    (set_attr "length_immediate" "2")
14712    (set_attr "mode" "TI")])
14714 (define_insn "sse4a_insertq"
14715   [(set (match_operand:V2DI 0 "register_operand" "=x")
14716         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
14717                       (match_operand:V2DI 2 "register_operand" "x")]
14718                      UNSPEC_INSERTQ))]
14719   "TARGET_SSE4A"
14720   "insertq\t{%2, %0|%0, %2}"
14721   [(set_attr "type" "sseins")
14722    (set_attr "prefix_data16" "0")
14723    (set_attr "prefix_rep" "1")
14724    (set_attr "mode" "TI")])
14726 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14728 ;; Intel SSE4.1 instructions
14730 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14732 ;; Mapping of immediate bits for blend instructions
14733 (define_mode_attr blendbits
14734   [(V8SF "255") (V4SF "15") (V4DF "15") (V2DF "3")])
14736 (define_insn "<sse4_1>_blend<ssemodesuffix><avxsizesuffix>"
14737   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
14738         (vec_merge:VF_128_256
14739           (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
14740           (match_operand:VF_128_256 1 "register_operand" "0,0,x")
14741           (match_operand:SI 3 "const_0_to_<blendbits>_operand")))]
14742   "TARGET_SSE4_1"
14743   "@
14744    blend<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
14745    blend<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
14746    vblend<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14747   [(set_attr "isa" "noavx,noavx,avx")
14748    (set_attr "type" "ssemov")
14749    (set_attr "length_immediate" "1")
14750    (set_attr "prefix_data16" "1,1,*")
14751    (set_attr "prefix_extra" "1")
14752    (set_attr "prefix" "orig,orig,vex")
14753    (set_attr "mode" "<MODE>")])
14755 (define_insn "<sse4_1>_blendv<ssemodesuffix><avxsizesuffix>"
14756   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
14757         (unspec:VF_128_256
14758           [(match_operand:VF_128_256 1 "register_operand" "0,0,x")
14759            (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
14760            (match_operand:VF_128_256 3 "register_operand" "Yz,Yz,x")]
14761           UNSPEC_BLENDV))]
14762   "TARGET_SSE4_1"
14763   "@
14764    blendv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
14765    blendv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
14766    vblendv<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14767   [(set_attr "isa" "noavx,noavx,avx")
14768    (set_attr "type" "ssemov")
14769    (set_attr "length_immediate" "1")
14770    (set_attr "prefix_data16" "1,1,*")
14771    (set_attr "prefix_extra" "1")
14772    (set_attr "prefix" "orig,orig,vex")
14773    (set_attr "btver2_decode" "vector,vector,vector") 
14774    (set_attr "mode" "<MODE>")])
14776 (define_insn "<sse4_1>_dp<ssemodesuffix><avxsizesuffix>"
14777   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
14778         (unspec:VF_128_256
14779           [(match_operand:VF_128_256 1 "vector_operand" "%0,0,x")
14780            (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
14781            (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
14782           UNSPEC_DP))]
14783   "TARGET_SSE4_1"
14784   "@
14785    dp<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
14786    dp<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
14787    vdp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14788   [(set_attr "isa" "noavx,noavx,avx")
14789    (set_attr "type" "ssemul")
14790    (set_attr "length_immediate" "1")
14791    (set_attr "prefix_data16" "1,1,*")
14792    (set_attr "prefix_extra" "1")
14793    (set_attr "prefix" "orig,orig,vex")
14794    (set_attr "btver2_decode" "vector,vector,vector")
14795    (set_attr "znver1_decode" "vector,vector,vector")
14796    (set_attr "mode" "<MODE>")])
14798 ;; Mode attribute used by `vmovntdqa' pattern
14799 (define_mode_attr vi8_sse4_1_avx2_avx512
14800    [(V2DI "sse4_1") (V4DI "avx2") (V8DI "avx512f")])
14802 (define_insn "<vi8_sse4_1_avx2_avx512>_movntdqa"
14803   [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand" "=Yr,*x, v")
14804         (unspec:VI8_AVX2_AVX512F [(match_operand:VI8_AVX2_AVX512F 1 "memory_operand" "m, m, m")]
14805                      UNSPEC_MOVNTDQA))]
14806   "TARGET_SSE4_1"
14807   "%vmovntdqa\t{%1, %0|%0, %1}"
14808   [(set_attr "type" "ssemov")
14809    (set_attr "prefix_extra" "1,1,*")
14810    (set_attr "prefix" "maybe_vex,maybe_vex,evex")
14811    (set_attr "mode" "<sseinsnmode>")])
14813 (define_insn "<sse4_1_avx2>_mpsadbw"
14814   [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
14815         (unspec:VI1_AVX2
14816           [(match_operand:VI1_AVX2 1 "register_operand" "0,0,x")
14817            (match_operand:VI1_AVX2 2 "vector_operand" "YrBm,*xBm,xm")
14818            (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
14819           UNSPEC_MPSADBW))]
14820   "TARGET_SSE4_1"
14821   "@
14822    mpsadbw\t{%3, %2, %0|%0, %2, %3}
14823    mpsadbw\t{%3, %2, %0|%0, %2, %3}
14824    vmpsadbw\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14825   [(set_attr "isa" "noavx,noavx,avx")
14826    (set_attr "type" "sselog1")
14827    (set_attr "length_immediate" "1")
14828    (set_attr "prefix_extra" "1")
14829    (set_attr "prefix" "orig,orig,vex")
14830    (set_attr "btver2_decode" "vector,vector,vector")
14831    (set_attr "znver1_decode" "vector,vector,vector")
14832    (set_attr "mode" "<sseinsnmode>")])
14834 (define_insn "<sse4_1_avx2>_packusdw<mask_name>"
14835   [(set (match_operand:VI2_AVX2 0 "register_operand" "=Yr,*x,v")
14836         (vec_concat:VI2_AVX2
14837           (us_truncate:<ssehalfvecmode>
14838             (match_operand:<sseunpackmode> 1 "register_operand" "0,0,v"))
14839           (us_truncate:<ssehalfvecmode>
14840             (match_operand:<sseunpackmode> 2 "vector_operand" "YrBm,*xBm,vm"))))]
14841   "TARGET_SSE4_1 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
14842   "@
14843    packusdw\t{%2, %0|%0, %2}
14844    packusdw\t{%2, %0|%0, %2}
14845    vpackusdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14846   [(set_attr "isa" "noavx,noavx,avx")
14847    (set_attr "type" "sselog")
14848    (set_attr "prefix_extra" "1")
14849    (set_attr "prefix" "orig,orig,maybe_evex")
14850    (set_attr "mode" "<sseinsnmode>")])
14852 (define_insn "<sse4_1_avx2>_pblendvb"
14853   [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
14854         (unspec:VI1_AVX2
14855           [(match_operand:VI1_AVX2 1 "register_operand"  "0,0,x")
14856            (match_operand:VI1_AVX2 2 "vector_operand" "YrBm,*xBm,xm")
14857            (match_operand:VI1_AVX2 3 "register_operand" "Yz,Yz,x")]
14858           UNSPEC_BLENDV))]
14859   "TARGET_SSE4_1"
14860   "@
14861    pblendvb\t{%3, %2, %0|%0, %2, %3}
14862    pblendvb\t{%3, %2, %0|%0, %2, %3}
14863    vpblendvb\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14864   [(set_attr "isa" "noavx,noavx,avx")
14865    (set_attr "type" "ssemov")
14866    (set_attr "prefix_extra" "1")
14867    (set_attr "length_immediate" "*,*,1")
14868    (set_attr "prefix" "orig,orig,vex")
14869    (set_attr "btver2_decode" "vector,vector,vector")
14870    (set_attr "mode" "<sseinsnmode>")])
14872 (define_insn "sse4_1_pblendw"
14873   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,x")
14874         (vec_merge:V8HI
14875           (match_operand:V8HI 2 "vector_operand" "YrBm,*xBm,xm")
14876           (match_operand:V8HI 1 "register_operand" "0,0,x")
14877           (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")))]
14878   "TARGET_SSE4_1"
14879   "@
14880    pblendw\t{%3, %2, %0|%0, %2, %3}
14881    pblendw\t{%3, %2, %0|%0, %2, %3}
14882    vpblendw\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14883   [(set_attr "isa" "noavx,noavx,avx")
14884    (set_attr "type" "ssemov")
14885    (set_attr "prefix_extra" "1")
14886    (set_attr "length_immediate" "1")
14887    (set_attr "prefix" "orig,orig,vex")
14888    (set_attr "mode" "TI")])
14890 ;; The builtin uses an 8-bit immediate.  Expand that.
14891 (define_expand "avx2_pblendw"
14892   [(set (match_operand:V16HI 0 "register_operand")
14893         (vec_merge:V16HI
14894           (match_operand:V16HI 2 "nonimmediate_operand")
14895           (match_operand:V16HI 1 "register_operand")
14896           (match_operand:SI 3 "const_0_to_255_operand")))]
14897   "TARGET_AVX2"
14899   HOST_WIDE_INT val = INTVAL (operands[3]) & 0xff;
14900   operands[3] = GEN_INT (val << 8 | val);
14903 (define_insn "*avx2_pblendw"
14904   [(set (match_operand:V16HI 0 "register_operand" "=x")
14905         (vec_merge:V16HI
14906           (match_operand:V16HI 2 "nonimmediate_operand" "xm")
14907           (match_operand:V16HI 1 "register_operand" "x")
14908           (match_operand:SI 3 "avx2_pblendw_operand" "n")))]
14909   "TARGET_AVX2"
14911   operands[3] = GEN_INT (INTVAL (operands[3]) & 0xff);
14912   return "vpblendw\t{%3, %2, %1, %0|%0, %1, %2, %3}";
14914   [(set_attr "type" "ssemov")
14915    (set_attr "prefix_extra" "1")
14916    (set_attr "length_immediate" "1")
14917    (set_attr "prefix" "vex")
14918    (set_attr "mode" "OI")])
14920 (define_insn "avx2_pblendd<mode>"
14921   [(set (match_operand:VI4_AVX2 0 "register_operand" "=x")
14922         (vec_merge:VI4_AVX2
14923           (match_operand:VI4_AVX2 2 "nonimmediate_operand" "xm")
14924           (match_operand:VI4_AVX2 1 "register_operand" "x")
14925           (match_operand:SI 3 "const_0_to_255_operand" "n")))]
14926   "TARGET_AVX2"
14927   "vpblendd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14928   [(set_attr "type" "ssemov")
14929    (set_attr "prefix_extra" "1")
14930    (set_attr "length_immediate" "1")
14931    (set_attr "prefix" "vex")
14932    (set_attr "mode" "<sseinsnmode>")])
14934 (define_insn "sse4_1_phminposuw"
14935   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x")
14936         (unspec:V8HI [(match_operand:V8HI 1 "vector_operand" "YrBm,*xBm")]
14937                      UNSPEC_PHMINPOSUW))]
14938   "TARGET_SSE4_1"
14939   "%vphminposuw\t{%1, %0|%0, %1}"
14940   [(set_attr "type" "sselog1")
14941    (set_attr "prefix_extra" "1")
14942    (set_attr "prefix" "maybe_vex")
14943    (set_attr "mode" "TI")])
14945 (define_insn "avx2_<code>v16qiv16hi2<mask_name>"
14946   [(set (match_operand:V16HI 0 "register_operand" "=v")
14947         (any_extend:V16HI
14948           (match_operand:V16QI 1 "nonimmediate_operand" "vm")))]
14949   "TARGET_AVX2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
14950   "vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
14951   [(set_attr "type" "ssemov")
14952    (set_attr "prefix_extra" "1")
14953    (set_attr "prefix" "maybe_evex")
14954    (set_attr "mode" "OI")])
14956 (define_insn "avx512bw_<code>v32qiv32hi2<mask_name>"
14957   [(set (match_operand:V32HI 0 "register_operand" "=v")
14958         (any_extend:V32HI
14959           (match_operand:V32QI 1 "nonimmediate_operand" "vm")))]
14960   "TARGET_AVX512BW"
14961   "vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
14962   [(set_attr "type" "ssemov")
14963    (set_attr "prefix_extra" "1")
14964    (set_attr "prefix" "evex")
14965    (set_attr "mode" "XI")])
14967 (define_insn "sse4_1_<code>v8qiv8hi2<mask_name>"
14968   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*v")
14969         (any_extend:V8HI
14970           (vec_select:V8QI
14971             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*vm")
14972             (parallel [(const_int 0) (const_int 1)
14973                        (const_int 2) (const_int 3)
14974                        (const_int 4) (const_int 5)
14975                        (const_int 6) (const_int 7)]))))]
14976   "TARGET_SSE4_1 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
14977   "%vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
14978   [(set_attr "type" "ssemov")
14979    (set_attr "ssememalign" "64")
14980    (set_attr "prefix_extra" "1")
14981    (set_attr "prefix" "maybe_vex")
14982    (set_attr "mode" "TI")])
14984 (define_insn "<mask_codefor>avx512f_<code>v16qiv16si2<mask_name>"
14985   [(set (match_operand:V16SI 0 "register_operand" "=v")
14986         (any_extend:V16SI
14987           (match_operand:V16QI 1 "nonimmediate_operand" "vm")))]
14988   "TARGET_AVX512F"
14989   "vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
14990   [(set_attr "type" "ssemov")
14991    (set_attr "prefix" "evex")
14992    (set_attr "mode" "XI")])
14994 (define_insn "avx2_<code>v8qiv8si2<mask_name>"
14995   [(set (match_operand:V8SI 0 "register_operand" "=v")
14996         (any_extend:V8SI
14997           (vec_select:V8QI
14998             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
14999             (parallel [(const_int 0) (const_int 1)
15000                        (const_int 2) (const_int 3)
15001                        (const_int 4) (const_int 5)
15002                        (const_int 6) (const_int 7)]))))]
15003   "TARGET_AVX2 && <mask_avx512vl_condition>"
15004   "vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15005   [(set_attr "type" "ssemov")
15006    (set_attr "prefix_extra" "1")
15007    (set_attr "prefix" "maybe_evex")
15008    (set_attr "mode" "OI")])
15010 (define_insn "sse4_1_<code>v4qiv4si2<mask_name>"
15011   [(set (match_operand:V4SI 0 "register_operand" "=Yr,*v")
15012         (any_extend:V4SI
15013           (vec_select:V4QI
15014             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*vm")
15015             (parallel [(const_int 0) (const_int 1)
15016                        (const_int 2) (const_int 3)]))))]
15017   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15018   "%vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15019   [(set_attr "type" "ssemov")
15020    (set_attr "ssememalign" "32")
15021    (set_attr "prefix_extra" "1")
15022    (set_attr "prefix" "maybe_vex")
15023    (set_attr "mode" "TI")])
15025 (define_insn "avx512f_<code>v16hiv16si2<mask_name>"
15026   [(set (match_operand:V16SI 0 "register_operand" "=v")
15027         (any_extend:V16SI
15028           (match_operand:V16HI 1 "nonimmediate_operand" "vm")))]
15029   "TARGET_AVX512F"
15030   "vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15031   [(set_attr "type" "ssemov")
15032    (set_attr "prefix" "evex")
15033    (set_attr "mode" "XI")])
15035 (define_insn "avx2_<code>v8hiv8si2<mask_name>"
15036   [(set (match_operand:V8SI 0 "register_operand" "=v")
15037         (any_extend:V8SI
15038             (match_operand:V8HI 1 "nonimmediate_operand" "vm")))]
15039   "TARGET_AVX2 && <mask_avx512vl_condition>"
15040   "vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15041   [(set_attr "type" "ssemov")
15042    (set_attr "prefix_extra" "1")
15043    (set_attr "prefix" "maybe_evex")
15044    (set_attr "mode" "OI")])
15046 (define_insn "sse4_1_<code>v4hiv4si2<mask_name>"
15047   [(set (match_operand:V4SI 0 "register_operand" "=Yr,*v")
15048         (any_extend:V4SI
15049           (vec_select:V4HI
15050             (match_operand:V8HI 1 "nonimmediate_operand" "Yrm,*vm")
15051             (parallel [(const_int 0) (const_int 1)
15052                        (const_int 2) (const_int 3)]))))]
15053   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15054   "%vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15055   [(set_attr "type" "ssemov")
15056    (set_attr "ssememalign" "64")
15057    (set_attr "prefix_extra" "1")
15058    (set_attr "prefix" "maybe_vex")
15059    (set_attr "mode" "TI")])
15061 (define_insn "avx512f_<code>v8qiv8di2<mask_name>"
15062   [(set (match_operand:V8DI 0 "register_operand" "=v")
15063         (any_extend:V8DI
15064           (vec_select:V8QI
15065             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
15066             (parallel [(const_int 0) (const_int 1)
15067                        (const_int 2) (const_int 3)
15068                        (const_int 4) (const_int 5)
15069                        (const_int 6) (const_int 7)]))))]
15070   "TARGET_AVX512F"
15071   "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15072   [(set_attr "type" "ssemov")
15073    (set_attr "prefix" "evex")
15074    (set_attr "mode" "XI")])
15076 (define_insn "avx2_<code>v4qiv4di2<mask_name>"
15077   [(set (match_operand:V4DI 0 "register_operand" "=v")
15078         (any_extend:V4DI
15079           (vec_select:V4QI
15080             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
15081             (parallel [(const_int 0) (const_int 1)
15082                        (const_int 2) (const_int 3)]))))]
15083   "TARGET_AVX2 && <mask_avx512vl_condition>"
15084   "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15085   [(set_attr "type" "ssemov")
15086    (set_attr "prefix_extra" "1")
15087    (set_attr "prefix" "maybe_evex")
15088    (set_attr "mode" "OI")])
15090 (define_insn "sse4_1_<code>v2qiv2di2<mask_name>"
15091   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*v")
15092         (any_extend:V2DI
15093           (vec_select:V2QI
15094             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*vm")
15095             (parallel [(const_int 0) (const_int 1)]))))]
15096   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15097   "%vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %w1}"
15098   [(set_attr "type" "ssemov")
15099    (set_attr "ssememalign" "16")
15100    (set_attr "prefix_extra" "1")
15101    (set_attr "prefix" "maybe_vex")
15102    (set_attr "mode" "TI")])
15104 (define_insn "avx512f_<code>v8hiv8di2<mask_name>"
15105   [(set (match_operand:V8DI 0 "register_operand" "=v")
15106         (any_extend:V8DI
15107           (match_operand:V8HI 1 "nonimmediate_operand" "vm")))]
15108   "TARGET_AVX512F"
15109   "vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15110   [(set_attr "type" "ssemov")
15111    (set_attr "prefix" "evex")
15112    (set_attr "mode" "XI")])
15114 (define_insn "avx2_<code>v4hiv4di2<mask_name>"
15115   [(set (match_operand:V4DI 0 "register_operand" "=v")
15116         (any_extend:V4DI
15117           (vec_select:V4HI
15118             (match_operand:V8HI 1 "nonimmediate_operand" "vm")
15119             (parallel [(const_int 0) (const_int 1)
15120                        (const_int 2) (const_int 3)]))))]
15121   "TARGET_AVX2 && <mask_avx512vl_condition>"
15122   "vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15123   [(set_attr "type" "ssemov")
15124    (set_attr "prefix_extra" "1")
15125    (set_attr "prefix" "maybe_evex")
15126    (set_attr "mode" "OI")])
15128 (define_insn "sse4_1_<code>v2hiv2di2<mask_name>"
15129   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*v")
15130         (any_extend:V2DI
15131           (vec_select:V2HI
15132             (match_operand:V8HI 1 "nonimmediate_operand" "Yrm,*vm")
15133             (parallel [(const_int 0) (const_int 1)]))))]
15134   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15135   "%vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
15136   [(set_attr "type" "ssemov")
15137    (set_attr "ssememalign" "32")
15138    (set_attr "prefix_extra" "1")
15139    (set_attr "prefix" "maybe_vex")
15140    (set_attr "mode" "TI")])
15142 (define_insn "avx512f_<code>v8siv8di2<mask_name>"
15143   [(set (match_operand:V8DI 0 "register_operand" "=v")
15144         (any_extend:V8DI
15145           (match_operand:V8SI 1 "nonimmediate_operand" "vm")))]
15146   "TARGET_AVX512F"
15147   "vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15148   [(set_attr "type" "ssemov")
15149    (set_attr "prefix" "evex")
15150    (set_attr "mode" "XI")])
15152 (define_insn "avx2_<code>v4siv4di2<mask_name>"
15153   [(set (match_operand:V4DI 0 "register_operand" "=v")
15154         (any_extend:V4DI
15155             (match_operand:V4SI 1 "nonimmediate_operand" "vm")))]
15156   "TARGET_AVX2 && <mask_avx512vl_condition>"
15157   "vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
15158   [(set_attr "type" "ssemov")
15159    (set_attr "prefix" "maybe_evex")
15160    (set_attr "prefix_extra" "1")
15161    (set_attr "mode" "OI")])
15163 (define_insn "sse4_1_<code>v2siv2di2<mask_name>"
15164   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*v")
15165         (any_extend:V2DI
15166           (vec_select:V2SI
15167             (match_operand:V4SI 1 "nonimmediate_operand" "Yrm,*vm")
15168             (parallel [(const_int 0) (const_int 1)]))))]
15169   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
15170   "%vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
15171   [(set_attr "type" "ssemov")
15172    (set_attr "ssememalign" "64")
15173    (set_attr "prefix_extra" "1")
15174    (set_attr "prefix" "maybe_vex")
15175    (set_attr "mode" "TI")])
15177 ;; ptestps/ptestpd are very similar to comiss and ucomiss when
15178 ;; setting FLAGS_REG. But it is not a really compare instruction.
15179 (define_insn "avx_vtest<ssemodesuffix><avxsizesuffix>"
15180   [(set (reg:CC FLAGS_REG)
15181         (unspec:CC [(match_operand:VF_128_256 0 "register_operand" "x")
15182                     (match_operand:VF_128_256 1 "nonimmediate_operand" "xm")]
15183                    UNSPEC_VTESTP))]
15184   "TARGET_AVX"
15185   "vtest<ssemodesuffix>\t{%1, %0|%0, %1}"
15186   [(set_attr "type" "ssecomi")
15187    (set_attr "prefix_extra" "1")
15188    (set_attr "prefix" "vex")
15189    (set_attr "mode" "<MODE>")])
15191 ;; ptest is very similar to comiss and ucomiss when setting FLAGS_REG.
15192 ;; But it is not a really compare instruction.
15193 (define_insn "<sse4_1>_ptest<mode>"
15194   [(set (reg:CC FLAGS_REG)
15195         (unspec:CC [(match_operand:V_AVX 0 "register_operand" "Yr, *x, x")
15196                     (match_operand:V_AVX 1 "vector_operand" "YrBm, *xBm, xm")]
15197                    UNSPEC_PTEST))]
15198   "TARGET_SSE4_1"
15199   "%vptest\t{%1, %0|%0, %1}"
15200   [(set_attr "isa" "*,*,avx")
15201    (set_attr "type" "ssecomi")
15202    (set_attr "prefix_extra" "1")
15203    (set_attr "prefix" "maybe_vex")
15204    (set (attr "btver2_decode")
15205      (if_then_else
15206        (match_test "<sseinsnmode>mode==OImode")
15207      (const_string "vector")
15208      (const_string "*")))
15209    (set_attr "mode" "<sseinsnmode>")])
15211 (define_insn "<sse4_1>_round<ssemodesuffix><avxsizesuffix>"
15212   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x")
15213         (unspec:VF_128_256
15214           [(match_operand:VF_128_256 1 "vector_operand" "YrBm,*xBm")
15215            (match_operand:SI 2 "const_0_to_15_operand" "n,n")]
15216           UNSPEC_ROUND))]
15217   "TARGET_ROUND"
15218   "%vround<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
15219   [(set_attr "type" "ssecvt")
15220    (set (attr "prefix_data16")
15221      (if_then_else
15222        (match_test "TARGET_AVX")
15223      (const_string "*")
15224      (const_string "1")))
15225    (set_attr "prefix_extra" "1")
15226    (set_attr "length_immediate" "1")
15227    (set_attr "prefix" "maybe_vex")
15228    (set_attr "mode" "<MODE>")])
15230 (define_expand "<sse4_1>_round<ssemodesuffix>_sfix<avxsizesuffix>"
15231   [(match_operand:<sseintvecmode> 0 "register_operand")
15232    (match_operand:VF1_128_256 1 "vector_operand")
15233    (match_operand:SI 2 "const_0_to_15_operand")]
15234   "TARGET_ROUND"
15236   rtx tmp = gen_reg_rtx (<MODE>mode);
15238   emit_insn
15239     (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp, operands[1],
15240                                                        operands[2]));
15241   emit_insn
15242     (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
15243   DONE;
15246 (define_expand "avx512f_roundpd512"
15247   [(match_operand:V8DF 0 "register_operand")
15248    (match_operand:V8DF 1 "nonimmediate_operand")
15249    (match_operand:SI 2 "const_0_to_15_operand")]
15250   "TARGET_AVX512F"
15252   emit_insn (gen_avx512f_rndscalev8df (operands[0], operands[1], operands[2]));
15253   DONE;
15256 (define_expand "<sse4_1>_round<ssemodesuffix>_vec_pack_sfix<avxsizesuffix>"
15257   [(match_operand:<ssepackfltmode> 0 "register_operand")
15258    (match_operand:VF2 1 "vector_operand")
15259    (match_operand:VF2 2 "vector_operand")
15260    (match_operand:SI 3 "const_0_to_15_operand")]
15261   "TARGET_ROUND"
15263   rtx tmp0, tmp1;
15265   if (<MODE>mode == V2DFmode
15266       && TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
15267     {
15268       rtx tmp2 = gen_reg_rtx (V4DFmode);
15270       tmp0 = gen_reg_rtx (V4DFmode);
15271       tmp1 = force_reg (V2DFmode, operands[1]);
15273       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
15274       emit_insn (gen_avx_roundpd256 (tmp2, tmp0, operands[3]));
15275       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp2));
15276     }
15277   else
15278     {
15279       tmp0 = gen_reg_rtx (<MODE>mode);
15280       tmp1 = gen_reg_rtx (<MODE>mode);
15282       emit_insn
15283        (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp0, operands[1],
15284                                                           operands[3]));
15285       emit_insn
15286        (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp1, operands[2],
15287                                                           operands[3]));
15288       emit_insn
15289        (gen_vec_pack_sfix_trunc_<mode> (operands[0], tmp0, tmp1));
15290     }
15291   DONE;
15294 (define_insn "sse4_1_round<ssescalarmodesuffix>"
15295   [(set (match_operand:VF_128 0 "register_operand" "=Yr,*x,x")
15296         (vec_merge:VF_128
15297           (unspec:VF_128
15298             [(match_operand:VF_128 2 "register_operand" "Yr,*x,x")
15299              (match_operand:SI 3 "const_0_to_15_operand" "n,n,n")]
15300             UNSPEC_ROUND)
15301           (match_operand:VF_128 1 "register_operand" "0,0,x")
15302           (const_int 1)))]
15303   "TARGET_ROUND"
15304   "@
15305    round<ssescalarmodesuffix>\t{%3, %2, %0|%0, %2, %3}
15306    round<ssescalarmodesuffix>\t{%3, %2, %0|%0, %2, %3}
15307    vround<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15308   [(set_attr "isa" "noavx,noavx,avx")
15309    (set_attr "type" "ssecvt")
15310    (set_attr "length_immediate" "1")
15311    (set_attr "prefix_data16" "1,1,*")
15312    (set_attr "prefix_extra" "1")
15313    (set_attr "prefix" "orig,orig,vex")
15314    (set_attr "mode" "<MODE>")])
15316 (define_expand "round<mode>2"
15317   [(set (match_dup 4)
15318         (plus:VF
15319           (match_operand:VF 1 "register_operand")
15320           (match_dup 3)))
15321    (set (match_operand:VF 0 "register_operand")
15322         (unspec:VF
15323           [(match_dup 4) (match_dup 5)]
15324           UNSPEC_ROUND))]
15325   "TARGET_ROUND && !flag_trapping_math"
15327   machine_mode scalar_mode;
15328   const struct real_format *fmt;
15329   REAL_VALUE_TYPE pred_half, half_minus_pred_half;
15330   rtx half, vec_half;
15332   scalar_mode = GET_MODE_INNER (<MODE>mode);
15334   /* load nextafter (0.5, 0.0) */
15335   fmt = REAL_MODE_FORMAT (scalar_mode);
15336   real_2expN (&half_minus_pred_half, -(fmt->p) - 1, scalar_mode);
15337   real_arithmetic (&pred_half, MINUS_EXPR, &dconsthalf, &half_minus_pred_half);
15338   half = const_double_from_real_value (pred_half, scalar_mode);
15340   vec_half = ix86_build_const_vector (<MODE>mode, true, half);
15341   vec_half = force_reg (<MODE>mode, vec_half);
15343   operands[3] = gen_reg_rtx (<MODE>mode);
15344   emit_insn (gen_copysign<mode>3 (operands[3], vec_half, operands[1]));
15346   operands[4] = gen_reg_rtx (<MODE>mode);
15347   operands[5] = GEN_INT (ROUND_TRUNC);
15350 (define_expand "round<mode>2_sfix"
15351   [(match_operand:<sseintvecmode> 0 "register_operand")
15352    (match_operand:VF1_128_256 1 "register_operand")]
15353   "TARGET_ROUND && !flag_trapping_math"
15355   rtx tmp = gen_reg_rtx (<MODE>mode);
15357   emit_insn (gen_round<mode>2 (tmp, operands[1]));
15359   emit_insn
15360     (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
15361   DONE;
15364 (define_expand "round<mode>2_vec_pack_sfix"
15365   [(match_operand:<ssepackfltmode> 0 "register_operand")
15366    (match_operand:VF2 1 "register_operand")
15367    (match_operand:VF2 2 "register_operand")]
15368   "TARGET_ROUND && !flag_trapping_math"
15370   rtx tmp0, tmp1;
15372   if (<MODE>mode == V2DFmode
15373       && TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
15374     {
15375       rtx tmp2 = gen_reg_rtx (V4DFmode);
15377       tmp0 = gen_reg_rtx (V4DFmode);
15378       tmp1 = force_reg (V2DFmode, operands[1]);
15380       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
15381       emit_insn (gen_roundv4df2 (tmp2, tmp0));
15382       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp2));
15383     }
15384   else
15385     {
15386       tmp0 = gen_reg_rtx (<MODE>mode);
15387       tmp1 = gen_reg_rtx (<MODE>mode);
15389       emit_insn (gen_round<mode>2 (tmp0, operands[1]));
15390       emit_insn (gen_round<mode>2 (tmp1, operands[2]));
15392       emit_insn
15393        (gen_vec_pack_sfix_trunc_<mode> (operands[0], tmp0, tmp1));
15394     }
15395   DONE;
15398 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15400 ;; Intel SSE4.2 string/text processing instructions
15402 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15404 (define_insn_and_split "sse4_2_pcmpestr"
15405   [(set (match_operand:SI 0 "register_operand" "=c,c")
15406         (unspec:SI
15407           [(match_operand:V16QI 2 "register_operand" "x,x")
15408            (match_operand:SI 3 "register_operand" "a,a")
15409            (match_operand:V16QI 4 "nonimmediate_operand" "x,m")
15410            (match_operand:SI 5 "register_operand" "d,d")
15411            (match_operand:SI 6 "const_0_to_255_operand" "n,n")]
15412           UNSPEC_PCMPESTR))
15413    (set (match_operand:V16QI 1 "register_operand" "=Yz,Yz")
15414         (unspec:V16QI
15415           [(match_dup 2)
15416            (match_dup 3)
15417            (match_dup 4)
15418            (match_dup 5)
15419            (match_dup 6)]
15420           UNSPEC_PCMPESTR))
15421    (set (reg:CC FLAGS_REG)
15422         (unspec:CC
15423           [(match_dup 2)
15424            (match_dup 3)
15425            (match_dup 4)
15426            (match_dup 5)
15427            (match_dup 6)]
15428           UNSPEC_PCMPESTR))]
15429   "TARGET_SSE4_2
15430    && can_create_pseudo_p ()"
15431   "#"
15432   "&& 1"
15433   [(const_int 0)]
15435   int ecx = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[0]));
15436   int xmm0 = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[1]));
15437   int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
15439   if (ecx)
15440     emit_insn (gen_sse4_2_pcmpestri (operands[0], operands[2],
15441                                      operands[3], operands[4],
15442                                      operands[5], operands[6]));
15443   if (xmm0)
15444     emit_insn (gen_sse4_2_pcmpestrm (operands[1], operands[2],
15445                                      operands[3], operands[4],
15446                                      operands[5], operands[6]));
15447   if (flags && !(ecx || xmm0))
15448     emit_insn (gen_sse4_2_pcmpestr_cconly (NULL, NULL,
15449                                            operands[2], operands[3],
15450                                            operands[4], operands[5],
15451                                            operands[6]));
15452   if (!(flags || ecx || xmm0))
15453     emit_note (NOTE_INSN_DELETED);
15455   DONE;
15457   [(set_attr "type" "sselog")
15458    (set_attr "prefix_data16" "1")
15459    (set_attr "prefix_extra" "1")
15460    (set_attr "ssememalign" "8")
15461    (set_attr "length_immediate" "1")
15462    (set_attr "memory" "none,load")
15463    (set_attr "mode" "TI")])
15465 (define_insn_and_split "*sse4_2_pcmpestr_unaligned"
15466   [(set (match_operand:SI 0 "register_operand" "=c")
15467         (unspec:SI
15468           [(match_operand:V16QI 2 "register_operand" "x")
15469            (match_operand:SI 3 "register_operand" "a")
15470            (unspec:V16QI
15471              [(match_operand:V16QI 4 "memory_operand" "m")]
15472              UNSPEC_LOADU)
15473            (match_operand:SI 5 "register_operand" "d")
15474            (match_operand:SI 6 "const_0_to_255_operand" "n")]
15475           UNSPEC_PCMPESTR))
15476    (set (match_operand:V16QI 1 "register_operand" "=Yz")
15477         (unspec:V16QI
15478           [(match_dup 2)
15479            (match_dup 3)
15480            (unspec:V16QI [(match_dup 4)] UNSPEC_LOADU)
15481            (match_dup 5)
15482            (match_dup 6)]
15483           UNSPEC_PCMPESTR))
15484    (set (reg:CC FLAGS_REG)
15485         (unspec:CC
15486           [(match_dup 2)
15487            (match_dup 3)
15488            (unspec:V16QI [(match_dup 4)] UNSPEC_LOADU)
15489            (match_dup 5)
15490            (match_dup 6)]
15491           UNSPEC_PCMPESTR))]
15492   "TARGET_SSE4_2
15493    && can_create_pseudo_p ()"
15494   "#"
15495   "&& 1"
15496   [(const_int 0)]
15498   int ecx = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[0]));
15499   int xmm0 = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[1]));
15500   int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
15502   if (ecx)
15503     emit_insn (gen_sse4_2_pcmpestri (operands[0], operands[2],
15504                                      operands[3], operands[4],
15505                                      operands[5], operands[6]));
15506   if (xmm0)
15507     emit_insn (gen_sse4_2_pcmpestrm (operands[1], operands[2],
15508                                      operands[3], operands[4],
15509                                      operands[5], operands[6]));
15510   if (flags && !(ecx || xmm0))
15511     emit_insn (gen_sse4_2_pcmpestr_cconly (NULL, NULL,
15512                                            operands[2], operands[3],
15513                                            operands[4], operands[5],
15514                                            operands[6]));
15515   if (!(flags || ecx || xmm0))
15516     emit_note (NOTE_INSN_DELETED);
15518   DONE;
15520   [(set_attr "type" "sselog")
15521    (set_attr "prefix_data16" "1")
15522    (set_attr "prefix_extra" "1")
15523    (set_attr "ssememalign" "8")
15524    (set_attr "length_immediate" "1")
15525    (set_attr "memory" "load")
15526    (set_attr "mode" "TI")])
15528 (define_insn "sse4_2_pcmpestri"
15529   [(set (match_operand:SI 0 "register_operand" "=c,c")
15530         (unspec:SI
15531           [(match_operand:V16QI 1 "register_operand" "x,x")
15532            (match_operand:SI 2 "register_operand" "a,a")
15533            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
15534            (match_operand:SI 4 "register_operand" "d,d")
15535            (match_operand:SI 5 "const_0_to_255_operand" "n,n")]
15536           UNSPEC_PCMPESTR))
15537    (set (reg:CC FLAGS_REG)
15538         (unspec:CC
15539           [(match_dup 1)
15540            (match_dup 2)
15541            (match_dup 3)
15542            (match_dup 4)
15543            (match_dup 5)]
15544           UNSPEC_PCMPESTR))]
15545   "TARGET_SSE4_2"
15546   "%vpcmpestri\t{%5, %3, %1|%1, %3, %5}"
15547   [(set_attr "type" "sselog")
15548    (set_attr "prefix_data16" "1")
15549    (set_attr "prefix_extra" "1")
15550    (set_attr "prefix" "maybe_vex")
15551    (set_attr "ssememalign" "8")
15552    (set_attr "length_immediate" "1")
15553    (set_attr "btver2_decode" "vector")
15554    (set_attr "memory" "none,load")
15555    (set_attr "mode" "TI")])
15557 (define_insn "sse4_2_pcmpestrm"
15558   [(set (match_operand:V16QI 0 "register_operand" "=Yz,Yz")
15559         (unspec:V16QI
15560           [(match_operand:V16QI 1 "register_operand" "x,x")
15561            (match_operand:SI 2 "register_operand" "a,a")
15562            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
15563            (match_operand:SI 4 "register_operand" "d,d")
15564            (match_operand:SI 5 "const_0_to_255_operand" "n,n")]
15565           UNSPEC_PCMPESTR))
15566    (set (reg:CC FLAGS_REG)
15567         (unspec:CC
15568           [(match_dup 1)
15569            (match_dup 2)
15570            (match_dup 3)
15571            (match_dup 4)
15572            (match_dup 5)]
15573           UNSPEC_PCMPESTR))]
15574   "TARGET_SSE4_2"
15575   "%vpcmpestrm\t{%5, %3, %1|%1, %3, %5}"
15576   [(set_attr "type" "sselog")
15577    (set_attr "prefix_data16" "1")
15578    (set_attr "prefix_extra" "1")
15579    (set_attr "ssememalign" "8")
15580    (set_attr "length_immediate" "1")
15581    (set_attr "prefix" "maybe_vex")
15582    (set_attr "btver2_decode" "vector")
15583    (set_attr "memory" "none,load")
15584    (set_attr "mode" "TI")])
15586 (define_insn "sse4_2_pcmpestr_cconly"
15587   [(set (reg:CC FLAGS_REG)
15588         (unspec:CC
15589           [(match_operand:V16QI 2 "register_operand" "x,x,x,x")
15590            (match_operand:SI 3 "register_operand" "a,a,a,a")
15591            (match_operand:V16QI 4 "nonimmediate_operand" "x,m,x,m")
15592            (match_operand:SI 5 "register_operand" "d,d,d,d")
15593            (match_operand:SI 6 "const_0_to_255_operand" "n,n,n,n")]
15594           UNSPEC_PCMPESTR))
15595    (clobber (match_scratch:V16QI 0 "=Yz,Yz,X,X"))
15596    (clobber (match_scratch:SI    1 "= X, X,c,c"))]
15597   "TARGET_SSE4_2"
15598   "@
15599    %vpcmpestrm\t{%6, %4, %2|%2, %4, %6}
15600    %vpcmpestrm\t{%6, %4, %2|%2, %4, %6}
15601    %vpcmpestri\t{%6, %4, %2|%2, %4, %6}
15602    %vpcmpestri\t{%6, %4, %2|%2, %4, %6}"
15603   [(set_attr "type" "sselog")
15604    (set_attr "prefix_data16" "1")
15605    (set_attr "prefix_extra" "1")
15606    (set_attr "ssememalign" "8")
15607    (set_attr "length_immediate" "1")
15608    (set_attr "memory" "none,load,none,load")
15609    (set_attr "btver2_decode" "vector,vector,vector,vector") 
15610    (set_attr "prefix" "maybe_vex")
15611    (set_attr "mode" "TI")])
15613 (define_insn_and_split "sse4_2_pcmpistr"
15614   [(set (match_operand:SI 0 "register_operand" "=c,c")
15615         (unspec:SI
15616           [(match_operand:V16QI 2 "register_operand" "x,x")
15617            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
15618            (match_operand:SI 4 "const_0_to_255_operand" "n,n")]
15619           UNSPEC_PCMPISTR))
15620    (set (match_operand:V16QI 1 "register_operand" "=Yz,Yz")
15621         (unspec:V16QI
15622           [(match_dup 2)
15623            (match_dup 3)
15624            (match_dup 4)]
15625           UNSPEC_PCMPISTR))
15626    (set (reg:CC FLAGS_REG)
15627         (unspec:CC
15628           [(match_dup 2)
15629            (match_dup 3)
15630            (match_dup 4)]
15631           UNSPEC_PCMPISTR))]
15632   "TARGET_SSE4_2
15633    && can_create_pseudo_p ()"
15634   "#"
15635   "&& 1"
15636   [(const_int 0)]
15638   int ecx = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[0]));
15639   int xmm0 = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[1]));
15640   int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
15642   if (ecx)
15643     emit_insn (gen_sse4_2_pcmpistri (operands[0], operands[2],
15644                                      operands[3], operands[4]));
15645   if (xmm0)
15646     emit_insn (gen_sse4_2_pcmpistrm (operands[1], operands[2],
15647                                      operands[3], operands[4]));
15648   if (flags && !(ecx || xmm0))
15649     emit_insn (gen_sse4_2_pcmpistr_cconly (NULL, NULL,
15650                                            operands[2], operands[3],
15651                                            operands[4]));
15652   if (!(flags || ecx || xmm0))
15653     emit_note (NOTE_INSN_DELETED);
15655   DONE;
15657   [(set_attr "type" "sselog")
15658    (set_attr "prefix_data16" "1")
15659    (set_attr "prefix_extra" "1")
15660    (set_attr "ssememalign" "8")
15661    (set_attr "length_immediate" "1")
15662    (set_attr "memory" "none,load")
15663    (set_attr "mode" "TI")])
15665 (define_insn_and_split "*sse4_2_pcmpistr_unaligned"
15666   [(set (match_operand:SI 0 "register_operand" "=c")
15667         (unspec:SI
15668           [(match_operand:V16QI 2 "register_operand" "x")
15669            (unspec:V16QI
15670              [(match_operand:V16QI 3 "memory_operand" "m")]
15671              UNSPEC_LOADU)
15672            (match_operand:SI 4 "const_0_to_255_operand" "n")]
15673           UNSPEC_PCMPISTR))
15674    (set (match_operand:V16QI 1 "register_operand" "=Yz")
15675         (unspec:V16QI
15676           [(match_dup 2)
15677            (unspec:V16QI [(match_dup 3)] UNSPEC_LOADU)
15678            (match_dup 4)]
15679           UNSPEC_PCMPISTR))
15680    (set (reg:CC FLAGS_REG)
15681         (unspec:CC
15682           [(match_dup 2)
15683            (unspec:V16QI [(match_dup 3)] UNSPEC_LOADU)
15684            (match_dup 4)]
15685           UNSPEC_PCMPISTR))]
15686   "TARGET_SSE4_2
15687    && can_create_pseudo_p ()"
15688   "#"
15689   "&& 1"
15690   [(const_int 0)]
15692   int ecx = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[0]));
15693   int xmm0 = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[1]));
15694   int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
15696   if (ecx)
15697     emit_insn (gen_sse4_2_pcmpistri (operands[0], operands[2],
15698                                      operands[3], operands[4]));
15699   if (xmm0)
15700     emit_insn (gen_sse4_2_pcmpistrm (operands[1], operands[2],
15701                                      operands[3], operands[4]));
15702   if (flags && !(ecx || xmm0))
15703     emit_insn (gen_sse4_2_pcmpistr_cconly (NULL, NULL,
15704                                            operands[2], operands[3],
15705                                            operands[4]));
15706   if (!(flags || ecx || xmm0))
15707     emit_note (NOTE_INSN_DELETED);
15709   DONE;
15711   [(set_attr "type" "sselog")
15712    (set_attr "prefix_data16" "1")
15713    (set_attr "prefix_extra" "1")
15714    (set_attr "ssememalign" "8")
15715    (set_attr "length_immediate" "1")
15716    (set_attr "memory" "load")
15717    (set_attr "mode" "TI")])
15719 (define_insn "sse4_2_pcmpistri"
15720   [(set (match_operand:SI 0 "register_operand" "=c,c")
15721         (unspec:SI
15722           [(match_operand:V16QI 1 "register_operand" "x,x")
15723            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
15724            (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
15725           UNSPEC_PCMPISTR))
15726    (set (reg:CC FLAGS_REG)
15727         (unspec:CC
15728           [(match_dup 1)
15729            (match_dup 2)
15730            (match_dup 3)]
15731           UNSPEC_PCMPISTR))]
15732   "TARGET_SSE4_2"
15733   "%vpcmpistri\t{%3, %2, %1|%1, %2, %3}"
15734   [(set_attr "type" "sselog")
15735    (set_attr "prefix_data16" "1")
15736    (set_attr "prefix_extra" "1")
15737    (set_attr "ssememalign" "8")
15738    (set_attr "length_immediate" "1")
15739    (set_attr "prefix" "maybe_vex")
15740    (set_attr "memory" "none,load")
15741    (set_attr "btver2_decode" "vector")
15742    (set_attr "mode" "TI")])
15744 (define_insn "sse4_2_pcmpistrm"
15745   [(set (match_operand:V16QI 0 "register_operand" "=Yz,Yz")
15746         (unspec:V16QI
15747           [(match_operand:V16QI 1 "register_operand" "x,x")
15748            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
15749            (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
15750           UNSPEC_PCMPISTR))
15751    (set (reg:CC FLAGS_REG)
15752         (unspec:CC
15753           [(match_dup 1)
15754            (match_dup 2)
15755            (match_dup 3)]
15756           UNSPEC_PCMPISTR))]
15757   "TARGET_SSE4_2"
15758   "%vpcmpistrm\t{%3, %2, %1|%1, %2, %3}"
15759   [(set_attr "type" "sselog")
15760    (set_attr "prefix_data16" "1")
15761    (set_attr "prefix_extra" "1")
15762    (set_attr "ssememalign" "8")
15763    (set_attr "length_immediate" "1")
15764    (set_attr "prefix" "maybe_vex")
15765    (set_attr "memory" "none,load")
15766    (set_attr "btver2_decode" "vector")
15767    (set_attr "mode" "TI")])
15769 (define_insn "sse4_2_pcmpistr_cconly"
15770   [(set (reg:CC FLAGS_REG)
15771         (unspec:CC
15772           [(match_operand:V16QI 2 "register_operand" "x,x,x,x")
15773            (match_operand:V16QI 3 "nonimmediate_operand" "x,m,x,m")
15774            (match_operand:SI 4 "const_0_to_255_operand" "n,n,n,n")]
15775           UNSPEC_PCMPISTR))
15776    (clobber (match_scratch:V16QI 0 "=Yz,Yz,X,X"))
15777    (clobber (match_scratch:SI    1 "= X, X,c,c"))]
15778   "TARGET_SSE4_2"
15779   "@
15780    %vpcmpistrm\t{%4, %3, %2|%2, %3, %4}
15781    %vpcmpistrm\t{%4, %3, %2|%2, %3, %4}
15782    %vpcmpistri\t{%4, %3, %2|%2, %3, %4}
15783    %vpcmpistri\t{%4, %3, %2|%2, %3, %4}"
15784   [(set_attr "type" "sselog")
15785    (set_attr "prefix_data16" "1")
15786    (set_attr "prefix_extra" "1")
15787    (set_attr "ssememalign" "8")
15788    (set_attr "length_immediate" "1")
15789    (set_attr "memory" "none,load,none,load")
15790    (set_attr "prefix" "maybe_vex")
15791    (set_attr "btver2_decode" "vector,vector,vector,vector")
15792    (set_attr "mode" "TI")])
15794 ;; Packed float variants
15795 (define_mode_attr GATHER_SCATTER_SF_MEM_MODE
15796                       [(V8DI "V8SF") (V16SI "V16SF")])
15798 (define_expand "avx512pf_gatherpf<mode>sf"
15799   [(unspec
15800      [(match_operand:<avx512fmaskmode> 0 "register_operand")
15801       (mem:<GATHER_SCATTER_SF_MEM_MODE>
15802         (match_par_dup 5
15803           [(match_operand 2 "vsib_address_operand")
15804            (match_operand:VI48_512 1 "register_operand")
15805            (match_operand:SI 3 "const1248_operand")]))
15806       (match_operand:SI 4 "const_2_to_3_operand")]
15807      UNSPEC_GATHER_PREFETCH)]
15808   "TARGET_AVX512PF"
15810   operands[5]
15811     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
15812                                         operands[3]), UNSPEC_VSIBADDR);
15815 (define_insn "*avx512pf_gatherpf<mode>sf_mask"
15816   [(unspec
15817      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
15818       (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 5 "vsib_mem_operator"
15819         [(unspec:P
15820            [(match_operand:P 2 "vsib_address_operand" "Tv")
15821             (match_operand:VI48_512 1 "register_operand" "v")
15822             (match_operand:SI 3 "const1248_operand" "n")]
15823            UNSPEC_VSIBADDR)])
15824       (match_operand:SI 4 "const_2_to_3_operand" "n")]
15825      UNSPEC_GATHER_PREFETCH)]
15826   "TARGET_AVX512PF"
15828   switch (INTVAL (operands[4]))
15829     {
15830     case 3:
15831       return "vgatherpf0<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
15832     case 2:
15833       return "vgatherpf1<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
15834     default:
15835       gcc_unreachable ();
15836     }
15838   [(set_attr "type" "sse")
15839    (set_attr "prefix" "evex")
15840    (set_attr "mode" "XI")])
15842 ;; Packed double variants
15843 (define_expand "avx512pf_gatherpf<mode>df"
15844   [(unspec
15845      [(match_operand:<avx512fmaskmode> 0 "register_operand")
15846       (mem:V8DF
15847         (match_par_dup 5
15848           [(match_operand 2 "vsib_address_operand")
15849            (match_operand:VI4_256_8_512 1 "register_operand")
15850            (match_operand:SI 3 "const1248_operand")]))
15851       (match_operand:SI 4 "const_2_to_3_operand")]
15852      UNSPEC_GATHER_PREFETCH)]
15853   "TARGET_AVX512PF"
15855   operands[5]
15856     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
15857                                         operands[3]), UNSPEC_VSIBADDR);
15860 (define_insn "*avx512pf_gatherpf<mode>df_mask"
15861   [(unspec
15862      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
15863       (match_operator:V8DF 5 "vsib_mem_operator"
15864         [(unspec:P
15865            [(match_operand:P 2 "vsib_address_operand" "Tv")
15866             (match_operand:VI4_256_8_512 1 "register_operand" "v")
15867             (match_operand:SI 3 "const1248_operand" "n")]
15868            UNSPEC_VSIBADDR)])
15869       (match_operand:SI 4 "const_2_to_3_operand" "n")]
15870      UNSPEC_GATHER_PREFETCH)]
15871   "TARGET_AVX512PF"
15873   switch (INTVAL (operands[4]))
15874     {
15875     case 3:
15876       return "vgatherpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
15877     case 2:
15878       return "vgatherpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
15879     default:
15880       gcc_unreachable ();
15881     }
15883   [(set_attr "type" "sse")
15884    (set_attr "prefix" "evex")
15885    (set_attr "mode" "XI")])
15887 ;; Packed float variants
15888 (define_expand "avx512pf_scatterpf<mode>sf"
15889   [(unspec
15890      [(match_operand:<avx512fmaskmode> 0 "register_operand")
15891       (mem:<GATHER_SCATTER_SF_MEM_MODE>
15892         (match_par_dup 5
15893           [(match_operand 2 "vsib_address_operand")
15894            (match_operand:VI48_512 1 "register_operand")
15895            (match_operand:SI 3 "const1248_operand")]))
15896       (match_operand:SI 4 "const2367_operand")]
15897      UNSPEC_SCATTER_PREFETCH)]
15898   "TARGET_AVX512PF"
15900   operands[5]
15901     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
15902                                         operands[3]), UNSPEC_VSIBADDR);
15905 (define_insn "*avx512pf_scatterpf<mode>sf_mask"
15906   [(unspec
15907      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
15908       (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 5 "vsib_mem_operator"
15909         [(unspec:P
15910            [(match_operand:P 2 "vsib_address_operand" "Tv")
15911             (match_operand:VI48_512 1 "register_operand" "v")
15912             (match_operand:SI 3 "const1248_operand" "n")]
15913            UNSPEC_VSIBADDR)])
15914       (match_operand:SI 4 "const2367_operand" "n")]
15915      UNSPEC_SCATTER_PREFETCH)]
15916   "TARGET_AVX512PF"
15918   switch (INTVAL (operands[4]))
15919     {
15920     case 3:
15921     case 7:
15922       return "vscatterpf0<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
15923     case 2:
15924     case 6:
15925       return "vscatterpf1<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
15926     default:
15927       gcc_unreachable ();
15928     }
15930   [(set_attr "type" "sse")
15931    (set_attr "prefix" "evex")
15932    (set_attr "mode" "XI")])
15934 ;; Packed double variants
15935 (define_expand "avx512pf_scatterpf<mode>df"
15936   [(unspec
15937      [(match_operand:<avx512fmaskmode> 0 "register_operand")
15938       (mem:V8DF
15939         (match_par_dup 5
15940           [(match_operand 2 "vsib_address_operand")
15941            (match_operand:VI4_256_8_512 1 "register_operand")
15942            (match_operand:SI 3 "const1248_operand")]))
15943       (match_operand:SI 4 "const2367_operand")]
15944      UNSPEC_SCATTER_PREFETCH)]
15945   "TARGET_AVX512PF"
15947   operands[5]
15948     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
15949                                         operands[3]), UNSPEC_VSIBADDR);
15952 (define_insn "*avx512pf_scatterpf<mode>df_mask"
15953   [(unspec
15954      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
15955       (match_operator:V8DF 5 "vsib_mem_operator"
15956         [(unspec:P
15957            [(match_operand:P 2 "vsib_address_operand" "Tv")
15958             (match_operand:VI4_256_8_512 1 "register_operand" "v")
15959             (match_operand:SI 3 "const1248_operand" "n")]
15960            UNSPEC_VSIBADDR)])
15961       (match_operand:SI 4 "const2367_operand" "n")]
15962      UNSPEC_SCATTER_PREFETCH)]
15963   "TARGET_AVX512PF"
15965   switch (INTVAL (operands[4]))
15966     {
15967     case 3:
15968     case 7:
15969       return "vscatterpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
15970     case 2:
15971     case 6:
15972       return "vscatterpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
15973     default:
15974       gcc_unreachable ();
15975     }
15977   [(set_attr "type" "sse")
15978    (set_attr "prefix" "evex")
15979    (set_attr "mode" "XI")])
15981 (define_insn "avx512er_exp2<mode><mask_name><round_saeonly_name>"
15982   [(set (match_operand:VF_512 0 "register_operand" "=v")
15983         (unspec:VF_512
15984           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
15985           UNSPEC_EXP2))]
15986   "TARGET_AVX512ER"
15987   "vexp2<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
15988   [(set_attr "prefix" "evex")
15989    (set_attr "type" "sse")
15990    (set_attr "mode" "<MODE>")])
15992 (define_insn "<mask_codefor>avx512er_rcp28<mode><mask_name><round_saeonly_name>"
15993   [(set (match_operand:VF_512 0 "register_operand" "=v")
15994         (unspec:VF_512
15995           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
15996           UNSPEC_RCP28))]
15997   "TARGET_AVX512ER"
15998   "vrcp28<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
15999   [(set_attr "prefix" "evex")
16000    (set_attr "type" "sse")
16001    (set_attr "mode" "<MODE>")])
16003 (define_insn "avx512er_vmrcp28<mode><round_saeonly_name>"
16004   [(set (match_operand:VF_128 0 "register_operand" "=v")
16005         (vec_merge:VF_128
16006           (unspec:VF_128
16007             [(match_operand:VF_128 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16008             UNSPEC_RCP28)
16009           (match_operand:VF_128 2 "register_operand" "v")
16010           (const_int 1)))]
16011   "TARGET_AVX512ER"
16012   "vrcp28<ssescalarmodesuffix>\t{<round_saeonly_op3>%1, %2, %0|%0, %2, %1<round_saeonly_op3>}"
16013   [(set_attr "length_immediate" "1")
16014    (set_attr "prefix" "evex")
16015    (set_attr "type" "sse")
16016    (set_attr "mode" "<MODE>")])
16018 (define_insn "<mask_codefor>avx512er_rsqrt28<mode><mask_name><round_saeonly_name>"
16019   [(set (match_operand:VF_512 0 "register_operand" "=v")
16020         (unspec:VF_512
16021           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16022           UNSPEC_RSQRT28))]
16023   "TARGET_AVX512ER"
16024   "vrsqrt28<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
16025   [(set_attr "prefix" "evex")
16026    (set_attr "type" "sse")
16027    (set_attr "mode" "<MODE>")])
16029 (define_insn "avx512er_vmrsqrt28<mode><round_saeonly_name>"
16030   [(set (match_operand:VF_128 0 "register_operand" "=v")
16031         (vec_merge:VF_128
16032           (unspec:VF_128
16033             [(match_operand:VF_128 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
16034             UNSPEC_RSQRT28)
16035           (match_operand:VF_128 2 "register_operand" "v")
16036           (const_int 1)))]
16037   "TARGET_AVX512ER"
16038   "vrsqrt28<ssescalarmodesuffix>\t{<round_saeonly_op3>%1, %2, %0|%0, %2, %1<round_saeonly_op3>}"
16039   [(set_attr "length_immediate" "1")
16040    (set_attr "type" "sse")
16041    (set_attr "prefix" "evex")
16042    (set_attr "mode" "<MODE>")])
16044 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16046 ;; XOP instructions
16048 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16050 (define_code_iterator xop_plus [plus ss_plus])
16052 (define_code_attr macs [(plus "macs") (ss_plus "macss")])
16053 (define_code_attr madcs [(plus "madcs") (ss_plus "madcss")])
16055 ;; XOP parallel integer multiply/add instructions.
16057 (define_insn "xop_p<macs><ssemodesuffix><ssemodesuffix>"
16058   [(set (match_operand:VI24_128 0 "register_operand" "=x")
16059         (xop_plus:VI24_128
16060          (mult:VI24_128
16061           (match_operand:VI24_128 1 "nonimmediate_operand" "%x")
16062           (match_operand:VI24_128 2 "nonimmediate_operand" "xm"))
16063          (match_operand:VI24_128 3 "register_operand" "x")))]
16064   "TARGET_XOP"
16065   "vp<macs><ssemodesuffix><ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16066   [(set_attr "type" "ssemuladd")
16067    (set_attr "mode" "TI")])
16069 (define_insn "xop_p<macs>dql"
16070   [(set (match_operand:V2DI 0 "register_operand" "=x")
16071         (xop_plus:V2DI
16072          (mult:V2DI
16073           (sign_extend:V2DI
16074            (vec_select:V2SI
16075             (match_operand:V4SI 1 "nonimmediate_operand" "%x")
16076             (parallel [(const_int 0) (const_int 2)])))
16077           (sign_extend:V2DI
16078            (vec_select:V2SI
16079             (match_operand:V4SI 2 "nonimmediate_operand" "xm")
16080             (parallel [(const_int 0) (const_int 2)]))))
16081          (match_operand:V2DI 3 "register_operand" "x")))]
16082   "TARGET_XOP"
16083   "vp<macs>dql\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16084   [(set_attr "type" "ssemuladd")
16085    (set_attr "mode" "TI")])
16087 (define_insn "xop_p<macs>dqh"
16088   [(set (match_operand:V2DI 0 "register_operand" "=x")
16089         (xop_plus:V2DI
16090          (mult:V2DI
16091           (sign_extend:V2DI
16092            (vec_select:V2SI
16093             (match_operand:V4SI 1 "nonimmediate_operand" "%x")
16094             (parallel [(const_int 1) (const_int 3)])))
16095           (sign_extend:V2DI
16096            (vec_select:V2SI
16097             (match_operand:V4SI 2 "nonimmediate_operand" "xm")
16098             (parallel [(const_int 1) (const_int 3)]))))
16099          (match_operand:V2DI 3 "register_operand" "x")))]
16100   "TARGET_XOP"
16101   "vp<macs>dqh\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16102   [(set_attr "type" "ssemuladd")
16103    (set_attr "mode" "TI")])
16105 ;; XOP parallel integer multiply/add instructions for the intrinisics
16106 (define_insn "xop_p<macs>wd"
16107   [(set (match_operand:V4SI 0 "register_operand" "=x")
16108         (xop_plus:V4SI
16109          (mult:V4SI
16110           (sign_extend:V4SI
16111            (vec_select:V4HI
16112             (match_operand:V8HI 1 "nonimmediate_operand" "%x")
16113             (parallel [(const_int 1) (const_int 3)
16114                        (const_int 5) (const_int 7)])))
16115           (sign_extend:V4SI
16116            (vec_select:V4HI
16117             (match_operand:V8HI 2 "nonimmediate_operand" "xm")
16118             (parallel [(const_int 1) (const_int 3)
16119                        (const_int 5) (const_int 7)]))))
16120          (match_operand:V4SI 3 "register_operand" "x")))]
16121   "TARGET_XOP"
16122   "vp<macs>wd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16123   [(set_attr "type" "ssemuladd")
16124    (set_attr "mode" "TI")])
16126 (define_insn "xop_p<madcs>wd"
16127   [(set (match_operand:V4SI 0 "register_operand" "=x")
16128         (xop_plus:V4SI
16129          (plus:V4SI
16130           (mult:V4SI
16131            (sign_extend:V4SI
16132             (vec_select:V4HI
16133              (match_operand:V8HI 1 "nonimmediate_operand" "%x")
16134              (parallel [(const_int 0) (const_int 2)
16135                         (const_int 4) (const_int 6)])))
16136            (sign_extend:V4SI
16137             (vec_select:V4HI
16138              (match_operand:V8HI 2 "nonimmediate_operand" "xm")
16139              (parallel [(const_int 0) (const_int 2)
16140                         (const_int 4) (const_int 6)]))))
16141           (mult:V4SI
16142            (sign_extend:V4SI
16143             (vec_select:V4HI
16144              (match_dup 1)
16145              (parallel [(const_int 1) (const_int 3)
16146                         (const_int 5) (const_int 7)])))
16147            (sign_extend:V4SI
16148             (vec_select:V4HI
16149              (match_dup 2)
16150              (parallel [(const_int 1) (const_int 3)
16151                         (const_int 5) (const_int 7)])))))
16152          (match_operand:V4SI 3 "register_operand" "x")))]
16153   "TARGET_XOP"
16154   "vp<madcs>wd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16155   [(set_attr "type" "ssemuladd")
16156    (set_attr "mode" "TI")])
16158 ;; XOP parallel XMM conditional moves
16159 (define_insn "xop_pcmov_<mode><avxsizesuffix>"
16160   [(set (match_operand:V 0 "register_operand" "=x,x")
16161         (if_then_else:V
16162           (match_operand:V 3 "nonimmediate_operand" "x,m")
16163           (match_operand:V 1 "register_operand" "x,x")
16164           (match_operand:V 2 "nonimmediate_operand" "xm,x")))]
16165   "TARGET_XOP"
16166   "vpcmov\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16167   [(set_attr "type" "sse4arg")])
16169 ;; XOP horizontal add/subtract instructions
16170 (define_insn "xop_phadd<u>bw"
16171   [(set (match_operand:V8HI 0 "register_operand" "=x")
16172         (plus:V8HI
16173          (any_extend:V8HI
16174           (vec_select:V8QI
16175            (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16176            (parallel [(const_int 0) (const_int 2)
16177                       (const_int 4) (const_int 6)
16178                       (const_int 8) (const_int 10)
16179                       (const_int 12) (const_int 14)])))
16180          (any_extend:V8HI
16181           (vec_select:V8QI
16182            (match_dup 1)
16183            (parallel [(const_int 1) (const_int 3)
16184                       (const_int 5) (const_int 7)
16185                       (const_int 9) (const_int 11)
16186                       (const_int 13) (const_int 15)])))))]
16187   "TARGET_XOP"
16188   "vphadd<u>bw\t{%1, %0|%0, %1}"
16189   [(set_attr "type" "sseiadd1")])
16191 (define_insn "xop_phadd<u>bd"
16192   [(set (match_operand:V4SI 0 "register_operand" "=x")
16193         (plus:V4SI
16194          (plus:V4SI
16195           (any_extend:V4SI
16196            (vec_select:V4QI
16197             (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16198             (parallel [(const_int 0) (const_int 4)
16199                        (const_int 8) (const_int 12)])))
16200           (any_extend:V4SI
16201            (vec_select:V4QI
16202             (match_dup 1)
16203             (parallel [(const_int 1) (const_int 5)
16204                        (const_int 9) (const_int 13)]))))
16205          (plus:V4SI
16206           (any_extend:V4SI
16207            (vec_select:V4QI
16208             (match_dup 1)
16209             (parallel [(const_int 2) (const_int 6)
16210                        (const_int 10) (const_int 14)])))
16211           (any_extend:V4SI
16212            (vec_select:V4QI
16213             (match_dup 1)
16214             (parallel [(const_int 3) (const_int 7)
16215                        (const_int 11) (const_int 15)]))))))]
16216   "TARGET_XOP"
16217   "vphadd<u>bd\t{%1, %0|%0, %1}"
16218   [(set_attr "type" "sseiadd1")])
16220 (define_insn "xop_phadd<u>bq"
16221   [(set (match_operand:V2DI 0 "register_operand" "=x")
16222         (plus:V2DI
16223          (plus:V2DI
16224           (plus:V2DI
16225            (any_extend:V2DI
16226             (vec_select:V2QI
16227              (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16228              (parallel [(const_int 0) (const_int 8)])))
16229            (any_extend:V2DI
16230             (vec_select:V2QI
16231              (match_dup 1)
16232              (parallel [(const_int 1) (const_int 9)]))))
16233           (plus:V2DI
16234            (any_extend:V2DI
16235             (vec_select:V2QI
16236              (match_dup 1)
16237              (parallel [(const_int 2) (const_int 10)])))
16238            (any_extend:V2DI
16239             (vec_select:V2QI
16240              (match_dup 1)
16241              (parallel [(const_int 3) (const_int 11)])))))
16242          (plus:V2DI
16243           (plus:V2DI
16244            (any_extend:V2DI
16245             (vec_select:V2QI
16246              (match_dup 1)
16247              (parallel [(const_int 4) (const_int 12)])))
16248            (any_extend:V2DI
16249             (vec_select:V2QI
16250              (match_dup 1)
16251              (parallel [(const_int 5) (const_int 13)]))))
16252           (plus:V2DI
16253            (any_extend:V2DI
16254             (vec_select:V2QI
16255              (match_dup 1)
16256              (parallel [(const_int 6) (const_int 14)])))
16257            (any_extend:V2DI
16258             (vec_select:V2QI
16259              (match_dup 1)
16260              (parallel [(const_int 7) (const_int 15)])))))))]
16261   "TARGET_XOP"
16262   "vphadd<u>bq\t{%1, %0|%0, %1}"
16263   [(set_attr "type" "sseiadd1")])
16265 (define_insn "xop_phadd<u>wd"
16266   [(set (match_operand:V4SI 0 "register_operand" "=x")
16267         (plus:V4SI
16268          (any_extend:V4SI
16269           (vec_select:V4HI
16270            (match_operand:V8HI 1 "nonimmediate_operand" "xm")
16271            (parallel [(const_int 0) (const_int 2)
16272                       (const_int 4) (const_int 6)])))
16273          (any_extend:V4SI
16274           (vec_select:V4HI
16275            (match_dup 1)
16276            (parallel [(const_int 1) (const_int 3)
16277                       (const_int 5) (const_int 7)])))))]
16278   "TARGET_XOP"
16279   "vphadd<u>wd\t{%1, %0|%0, %1}"
16280   [(set_attr "type" "sseiadd1")])
16282 (define_insn "xop_phadd<u>wq"
16283   [(set (match_operand:V2DI 0 "register_operand" "=x")
16284         (plus:V2DI
16285          (plus:V2DI
16286           (any_extend:V2DI
16287            (vec_select:V2HI
16288             (match_operand:V8HI 1 "nonimmediate_operand" "xm")
16289             (parallel [(const_int 0) (const_int 4)])))
16290           (any_extend:V2DI
16291            (vec_select:V2HI
16292             (match_dup 1)
16293             (parallel [(const_int 1) (const_int 5)]))))
16294          (plus:V2DI
16295           (any_extend:V2DI
16296            (vec_select:V2HI
16297             (match_dup 1)
16298             (parallel [(const_int 2) (const_int 6)])))
16299           (any_extend:V2DI
16300            (vec_select:V2HI
16301             (match_dup 1)
16302             (parallel [(const_int 3) (const_int 7)]))))))]
16303   "TARGET_XOP"
16304   "vphadd<u>wq\t{%1, %0|%0, %1}"
16305   [(set_attr "type" "sseiadd1")])
16307 (define_insn "xop_phadd<u>dq"
16308   [(set (match_operand:V2DI 0 "register_operand" "=x")
16309         (plus:V2DI
16310          (any_extend:V2DI
16311           (vec_select:V2SI
16312            (match_operand:V4SI 1 "nonimmediate_operand" "xm")
16313            (parallel [(const_int 0) (const_int 2)])))
16314          (any_extend:V2DI
16315           (vec_select:V2SI
16316            (match_dup 1)
16317            (parallel [(const_int 1) (const_int 3)])))))]
16318   "TARGET_XOP"
16319   "vphadd<u>dq\t{%1, %0|%0, %1}"
16320   [(set_attr "type" "sseiadd1")])
16322 (define_insn "xop_phsubbw"
16323   [(set (match_operand:V8HI 0 "register_operand" "=x")
16324         (minus:V8HI
16325          (sign_extend:V8HI
16326           (vec_select:V8QI
16327            (match_operand:V16QI 1 "nonimmediate_operand" "xm")
16328            (parallel [(const_int 0) (const_int 2)
16329                       (const_int 4) (const_int 6)
16330                       (const_int 8) (const_int 10)
16331                       (const_int 12) (const_int 14)])))
16332          (sign_extend:V8HI
16333           (vec_select:V8QI
16334            (match_dup 1)
16335            (parallel [(const_int 1) (const_int 3)
16336                       (const_int 5) (const_int 7)
16337                       (const_int 9) (const_int 11)
16338                       (const_int 13) (const_int 15)])))))]
16339   "TARGET_XOP"
16340   "vphsubbw\t{%1, %0|%0, %1}"
16341   [(set_attr "type" "sseiadd1")])
16343 (define_insn "xop_phsubwd"
16344   [(set (match_operand:V4SI 0 "register_operand" "=x")
16345         (minus:V4SI
16346          (sign_extend:V4SI
16347           (vec_select:V4HI
16348            (match_operand:V8HI 1 "nonimmediate_operand" "xm")
16349            (parallel [(const_int 0) (const_int 2)
16350                       (const_int 4) (const_int 6)])))
16351          (sign_extend:V4SI
16352           (vec_select:V4HI
16353            (match_dup 1)
16354            (parallel [(const_int 1) (const_int 3)
16355                       (const_int 5) (const_int 7)])))))]
16356   "TARGET_XOP"
16357   "vphsubwd\t{%1, %0|%0, %1}"
16358   [(set_attr "type" "sseiadd1")])
16360 (define_insn "xop_phsubdq"
16361   [(set (match_operand:V2DI 0 "register_operand" "=x")
16362         (minus:V2DI
16363          (sign_extend:V2DI
16364           (vec_select:V2SI
16365            (match_operand:V4SI 1 "nonimmediate_operand" "xm")
16366            (parallel [(const_int 0) (const_int 2)])))
16367          (sign_extend:V2DI
16368           (vec_select:V2SI
16369            (match_dup 1)
16370            (parallel [(const_int 1) (const_int 3)])))))]
16371   "TARGET_XOP"
16372   "vphsubdq\t{%1, %0|%0, %1}"
16373   [(set_attr "type" "sseiadd1")])
16375 ;; XOP permute instructions
16376 (define_insn "xop_pperm"
16377   [(set (match_operand:V16QI 0 "register_operand" "=x,x")
16378         (unspec:V16QI
16379           [(match_operand:V16QI 1 "register_operand" "x,x")
16380            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
16381            (match_operand:V16QI 3 "nonimmediate_operand" "xm,x")]
16382           UNSPEC_XOP_PERMUTE))]
16383   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16384   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16385   [(set_attr "type" "sse4arg")
16386    (set_attr "mode" "TI")])
16388 ;; XOP pack instructions that combine two vectors into a smaller vector
16389 (define_insn "xop_pperm_pack_v2di_v4si"
16390   [(set (match_operand:V4SI 0 "register_operand" "=x,x")
16391         (vec_concat:V4SI
16392          (truncate:V2SI
16393           (match_operand:V2DI 1 "register_operand" "x,x"))
16394          (truncate:V2SI
16395           (match_operand:V2DI 2 "nonimmediate_operand" "x,m"))))
16396    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
16397   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16398   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16399   [(set_attr "type" "sse4arg")
16400    (set_attr "mode" "TI")])
16402 (define_insn "xop_pperm_pack_v4si_v8hi"
16403   [(set (match_operand:V8HI 0 "register_operand" "=x,x")
16404         (vec_concat:V8HI
16405          (truncate:V4HI
16406           (match_operand:V4SI 1 "register_operand" "x,x"))
16407          (truncate:V4HI
16408           (match_operand:V4SI 2 "nonimmediate_operand" "x,m"))))
16409    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
16410   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16411   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16412   [(set_attr "type" "sse4arg")
16413    (set_attr "mode" "TI")])
16415 (define_insn "xop_pperm_pack_v8hi_v16qi"
16416   [(set (match_operand:V16QI 0 "register_operand" "=x,x")
16417         (vec_concat:V16QI
16418          (truncate:V8QI
16419           (match_operand:V8HI 1 "register_operand" "x,x"))
16420          (truncate:V8QI
16421           (match_operand:V8HI 2 "nonimmediate_operand" "x,m"))))
16422    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
16423   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16424   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16425   [(set_attr "type" "sse4arg")
16426    (set_attr "mode" "TI")])
16428 ;; XOP packed rotate instructions
16429 (define_expand "rotl<mode>3"
16430   [(set (match_operand:VI_128 0 "register_operand")
16431         (rotate:VI_128
16432          (match_operand:VI_128 1 "nonimmediate_operand")
16433          (match_operand:SI 2 "general_operand")))]
16434   "TARGET_XOP"
16436   /* If we were given a scalar, convert it to parallel */
16437   if (! const_0_to_<sserotatemax>_operand (operands[2], SImode))
16438     {
16439       rtvec vs = rtvec_alloc (<ssescalarnum>);
16440       rtx par = gen_rtx_PARALLEL (<MODE>mode, vs);
16441       rtx reg = gen_reg_rtx (<MODE>mode);
16442       rtx op2 = operands[2];
16443       int i;
16445       if (GET_MODE (op2) != <ssescalarmode>mode)
16446         {
16447           op2 = gen_reg_rtx (<ssescalarmode>mode);
16448           convert_move (op2, operands[2], false);
16449         }
16451       for (i = 0; i < <ssescalarnum>; i++)
16452         RTVEC_ELT (vs, i) = op2;
16454       emit_insn (gen_vec_init<mode> (reg, par));
16455       emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], reg));
16456       DONE;
16457     }
16460 (define_expand "rotr<mode>3"
16461   [(set (match_operand:VI_128 0 "register_operand")
16462         (rotatert:VI_128
16463          (match_operand:VI_128 1 "nonimmediate_operand")
16464          (match_operand:SI 2 "general_operand")))]
16465   "TARGET_XOP"
16467   /* If we were given a scalar, convert it to parallel */
16468   if (! const_0_to_<sserotatemax>_operand (operands[2], SImode))
16469     {
16470       rtvec vs = rtvec_alloc (<ssescalarnum>);
16471       rtx par = gen_rtx_PARALLEL (<MODE>mode, vs);
16472       rtx neg = gen_reg_rtx (<MODE>mode);
16473       rtx reg = gen_reg_rtx (<MODE>mode);
16474       rtx op2 = operands[2];
16475       int i;
16477       if (GET_MODE (op2) != <ssescalarmode>mode)
16478         {
16479           op2 = gen_reg_rtx (<ssescalarmode>mode);
16480           convert_move (op2, operands[2], false);
16481         }
16483       for (i = 0; i < <ssescalarnum>; i++)
16484         RTVEC_ELT (vs, i) = op2;
16486       emit_insn (gen_vec_init<mode> (reg, par));
16487       emit_insn (gen_neg<mode>2 (neg, reg));
16488       emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], neg));
16489       DONE;
16490     }
16493 (define_insn "xop_rotl<mode>3"
16494   [(set (match_operand:VI_128 0 "register_operand" "=x")
16495         (rotate:VI_128
16496          (match_operand:VI_128 1 "nonimmediate_operand" "xm")
16497          (match_operand:SI 2 "const_0_to_<sserotatemax>_operand" "n")))]
16498   "TARGET_XOP"
16499   "vprot<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16500   [(set_attr "type" "sseishft")
16501    (set_attr "length_immediate" "1")
16502    (set_attr "mode" "TI")])
16504 (define_insn "xop_rotr<mode>3"
16505   [(set (match_operand:VI_128 0 "register_operand" "=x")
16506         (rotatert:VI_128
16507          (match_operand:VI_128 1 "nonimmediate_operand" "xm")
16508          (match_operand:SI 2 "const_0_to_<sserotatemax>_operand" "n")))]
16509   "TARGET_XOP"
16511   operands[3]
16512     = GEN_INT (GET_MODE_BITSIZE (<ssescalarmode>mode) - INTVAL (operands[2]));
16513   return \"vprot<ssemodesuffix>\t{%3, %1, %0|%0, %1, %3}\";
16515   [(set_attr "type" "sseishft")
16516    (set_attr "length_immediate" "1")
16517    (set_attr "mode" "TI")])
16519 (define_expand "vrotr<mode>3"
16520   [(match_operand:VI_128 0 "register_operand")
16521    (match_operand:VI_128 1 "register_operand")
16522    (match_operand:VI_128 2 "register_operand")]
16523   "TARGET_XOP"
16525   rtx reg = gen_reg_rtx (<MODE>mode);
16526   emit_insn (gen_neg<mode>2 (reg, operands[2]));
16527   emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], reg));
16528   DONE;
16531 (define_expand "vrotl<mode>3"
16532   [(match_operand:VI_128 0 "register_operand")
16533    (match_operand:VI_128 1 "register_operand")
16534    (match_operand:VI_128 2 "register_operand")]
16535   "TARGET_XOP"
16537   emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], operands[2]));
16538   DONE;
16541 (define_insn "xop_vrotl<mode>3"
16542   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
16543         (if_then_else:VI_128
16544          (ge:VI_128
16545           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
16546           (const_int 0))
16547          (rotate:VI_128
16548           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
16549           (match_dup 2))
16550          (rotatert:VI_128
16551           (match_dup 1)
16552           (neg:VI_128 (match_dup 2)))))]
16553   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16554   "vprot<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16555   [(set_attr "type" "sseishft")
16556    (set_attr "prefix_data16" "0")
16557    (set_attr "prefix_extra" "2")
16558    (set_attr "mode" "TI")])
16560 ;; XOP packed shift instructions.
16561 (define_expand "vlshr<mode>3"
16562   [(set (match_operand:VI12_128 0 "register_operand")
16563         (lshiftrt:VI12_128
16564           (match_operand:VI12_128 1 "register_operand")
16565           (match_operand:VI12_128 2 "nonimmediate_operand")))]
16566   "TARGET_XOP"
16568   rtx neg = gen_reg_rtx (<MODE>mode);
16569   emit_insn (gen_neg<mode>2 (neg, operands[2]));
16570   emit_insn (gen_xop_shl<mode>3 (operands[0], operands[1], neg));
16571   DONE;
16574 (define_expand "vlshr<mode>3"
16575   [(set (match_operand:VI48_128 0 "register_operand")
16576         (lshiftrt:VI48_128
16577           (match_operand:VI48_128 1 "register_operand")
16578           (match_operand:VI48_128 2 "nonimmediate_operand")))]
16579   "TARGET_AVX2 || TARGET_XOP"
16581   if (!TARGET_AVX2)
16582     {
16583       rtx neg = gen_reg_rtx (<MODE>mode);
16584       emit_insn (gen_neg<mode>2 (neg, operands[2]));
16585       emit_insn (gen_xop_shl<mode>3 (operands[0], operands[1], neg));
16586       DONE;
16587     }
16590 (define_expand "vlshr<mode>3"
16591   [(set (match_operand:VI48_512 0 "register_operand")
16592         (lshiftrt:VI48_512
16593           (match_operand:VI48_512 1 "register_operand")
16594           (match_operand:VI48_512 2 "nonimmediate_operand")))]
16595   "TARGET_AVX512F")
16597 (define_expand "vlshr<mode>3"
16598   [(set (match_operand:VI48_256 0 "register_operand")
16599         (lshiftrt:VI48_256
16600           (match_operand:VI48_256 1 "register_operand")
16601           (match_operand:VI48_256 2 "nonimmediate_operand")))]
16602   "TARGET_AVX2")
16604 (define_expand "vashrv8hi3<mask_name>"
16605   [(set (match_operand:V8HI 0 "register_operand")
16606         (ashiftrt:V8HI
16607           (match_operand:V8HI 1 "register_operand")
16608           (match_operand:V8HI 2 "nonimmediate_operand")))]
16609   "TARGET_XOP || (TARGET_AVX512BW && TARGET_AVX512VL)"
16611   if (TARGET_XOP)
16612     {
16613       rtx neg = gen_reg_rtx (V8HImode);
16614       emit_insn (gen_negv8hi2 (neg, operands[2]));
16615       emit_insn (gen_xop_shav8hi3 (operands[0], operands[1], neg));
16616       DONE;
16617     }
16620 (define_expand "vashrv16qi3"
16621   [(set (match_operand:V16QI 0 "register_operand")
16622         (ashiftrt:V16QI
16623           (match_operand:V16QI 1 "register_operand")
16624           (match_operand:V16QI 2 "nonimmediate_operand")))]
16625   "TARGET_XOP"
16627    rtx neg = gen_reg_rtx (V16QImode);
16628    emit_insn (gen_negv16qi2 (neg, operands[2]));
16629    emit_insn (gen_xop_shav16qi3 (operands[0], operands[1], neg));
16630    DONE;
16633 (define_expand "vashrv2di3<mask_name>"
16634   [(set (match_operand:V2DI 0 "register_operand")
16635         (ashiftrt:V2DI
16636           (match_operand:V2DI 1 "register_operand")
16637           (match_operand:V2DI 2 "nonimmediate_operand")))]
16638   "TARGET_XOP || TARGET_AVX512VL"
16640   if (TARGET_XOP)
16641     {
16642       rtx neg = gen_reg_rtx (V2DImode);
16643       emit_insn (gen_negv2di2 (neg, operands[2]));
16644       emit_insn (gen_xop_shav2di3 (operands[0], operands[1], neg));
16645       DONE;
16646     }
16649 (define_expand "vashrv4si3"
16650   [(set (match_operand:V4SI 0 "register_operand")
16651         (ashiftrt:V4SI (match_operand:V4SI 1 "register_operand")
16652                        (match_operand:V4SI 2 "nonimmediate_operand")))]
16653   "TARGET_AVX2 || TARGET_XOP"
16655   if (!TARGET_AVX2)
16656     {
16657       rtx neg = gen_reg_rtx (V4SImode);
16658       emit_insn (gen_negv4si2 (neg, operands[2]));
16659       emit_insn (gen_xop_shav4si3 (operands[0], operands[1], neg));
16660       DONE;
16661     }
16664 (define_expand "vashrv16si3"
16665   [(set (match_operand:V16SI 0 "register_operand")
16666         (ashiftrt:V16SI (match_operand:V16SI 1 "register_operand")
16667                         (match_operand:V16SI 2 "nonimmediate_operand")))]
16668   "TARGET_AVX512F")
16670 (define_expand "vashrv8si3"
16671   [(set (match_operand:V8SI 0 "register_operand")
16672         (ashiftrt:V8SI (match_operand:V8SI 1 "register_operand")
16673                        (match_operand:V8SI 2 "nonimmediate_operand")))]
16674   "TARGET_AVX2")
16676 (define_expand "vashl<mode>3"
16677   [(set (match_operand:VI12_128 0 "register_operand")
16678         (ashift:VI12_128
16679           (match_operand:VI12_128 1 "register_operand")
16680           (match_operand:VI12_128 2 "nonimmediate_operand")))]
16681   "TARGET_XOP"
16683   emit_insn (gen_xop_sha<mode>3 (operands[0], operands[1], operands[2]));
16684   DONE;
16687 (define_expand "vashl<mode>3"
16688   [(set (match_operand:VI48_128 0 "register_operand")
16689         (ashift:VI48_128
16690           (match_operand:VI48_128 1 "register_operand")
16691           (match_operand:VI48_128 2 "nonimmediate_operand")))]
16692   "TARGET_AVX2 || TARGET_XOP"
16694   if (!TARGET_AVX2)
16695     {
16696       operands[2] = force_reg (<MODE>mode, operands[2]);
16697       emit_insn (gen_xop_sha<mode>3 (operands[0], operands[1], operands[2]));
16698       DONE;
16699     }
16702 (define_expand "vashl<mode>3"
16703   [(set (match_operand:VI48_512 0 "register_operand")
16704         (ashift:VI48_512
16705           (match_operand:VI48_512 1 "register_operand")
16706           (match_operand:VI48_512 2 "nonimmediate_operand")))]
16707   "TARGET_AVX512F")
16709 (define_expand "vashl<mode>3"
16710   [(set (match_operand:VI48_256 0 "register_operand")
16711         (ashift:VI48_256
16712           (match_operand:VI48_256 1 "register_operand")
16713           (match_operand:VI48_256 2 "nonimmediate_operand")))]
16714   "TARGET_AVX2")
16716 (define_insn "xop_sha<mode>3"
16717   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
16718         (if_then_else:VI_128
16719          (ge:VI_128
16720           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
16721           (const_int 0))
16722          (ashift:VI_128
16723           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
16724           (match_dup 2))
16725          (ashiftrt:VI_128
16726           (match_dup 1)
16727           (neg:VI_128 (match_dup 2)))))]
16728   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16729   "vpsha<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16730   [(set_attr "type" "sseishft")
16731    (set_attr "prefix_data16" "0")
16732    (set_attr "prefix_extra" "2")
16733    (set_attr "mode" "TI")])
16735 (define_insn "xop_shl<mode>3"
16736   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
16737         (if_then_else:VI_128
16738          (ge:VI_128
16739           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
16740           (const_int 0))
16741          (ashift:VI_128
16742           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
16743           (match_dup 2))
16744          (lshiftrt:VI_128
16745           (match_dup 1)
16746           (neg:VI_128 (match_dup 2)))))]
16747   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16748   "vpshl<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16749   [(set_attr "type" "sseishft")
16750    (set_attr "prefix_data16" "0")
16751    (set_attr "prefix_extra" "2")
16752    (set_attr "mode" "TI")])
16754 (define_expand "<shift_insn><mode>3"
16755   [(set (match_operand:VI1_AVX512 0 "register_operand")
16756         (any_shift:VI1_AVX512
16757           (match_operand:VI1_AVX512 1 "register_operand")
16758           (match_operand:SI 2 "nonmemory_operand")))]
16759   "TARGET_SSE2"
16761   if (TARGET_XOP && <MODE>mode == V16QImode)
16762     {
16763       bool negate = false;
16764       rtx (*gen) (rtx, rtx, rtx);
16765       rtx tmp, par;
16766       int i;
16768       if (<CODE> != ASHIFT)
16769         {
16770           if (CONST_INT_P (operands[2]))
16771             operands[2] = GEN_INT (-INTVAL (operands[2]));
16772           else
16773             negate = true;
16774         }
16775       par = gen_rtx_PARALLEL (V16QImode, rtvec_alloc (16));
16776       for (i = 0; i < 16; i++)
16777         XVECEXP (par, 0, i) = operands[2];
16779       tmp = gen_reg_rtx (V16QImode);
16780       emit_insn (gen_vec_initv16qi (tmp, par));
16782       if (negate)
16783         emit_insn (gen_negv16qi2 (tmp, tmp));
16785       gen = (<CODE> == LSHIFTRT ? gen_xop_shlv16qi3 : gen_xop_shav16qi3);
16786       emit_insn (gen (operands[0], operands[1], tmp));
16787     }
16788   else
16789     ix86_expand_vecop_qihi (<CODE>, operands[0], operands[1], operands[2]);
16790   DONE;
16793 (define_expand "ashrv2di3"
16794   [(set (match_operand:V2DI 0 "register_operand")
16795         (ashiftrt:V2DI
16796           (match_operand:V2DI 1 "register_operand")
16797           (match_operand:DI 2 "nonmemory_operand")))]
16798   "TARGET_XOP || TARGET_AVX512VL"
16800   if (!TARGET_AVX512VL)
16801     {
16802       rtx reg = gen_reg_rtx (V2DImode);
16803       rtx par;
16804       bool negate = false;
16805       int i;
16807       if (CONST_INT_P (operands[2]))
16808         operands[2] = GEN_INT (-INTVAL (operands[2]));
16809       else
16810         negate = true;
16812       par = gen_rtx_PARALLEL (V2DImode, rtvec_alloc (2));
16813       for (i = 0; i < 2; i++)
16814         XVECEXP (par, 0, i) = operands[2];
16816       emit_insn (gen_vec_initv2di (reg, par));
16818       if (negate)
16819         emit_insn (gen_negv2di2 (reg, reg));
16821       emit_insn (gen_xop_shav2di3 (operands[0], operands[1], reg));
16822       DONE;
16823     }
16826 ;; XOP FRCZ support
16827 (define_insn "xop_frcz<mode>2"
16828   [(set (match_operand:FMAMODE 0 "register_operand" "=x")
16829         (unspec:FMAMODE
16830          [(match_operand:FMAMODE 1 "nonimmediate_operand" "xm")]
16831          UNSPEC_FRCZ))]
16832   "TARGET_XOP"
16833   "vfrcz<ssemodesuffix>\t{%1, %0|%0, %1}"
16834   [(set_attr "type" "ssecvt1")
16835    (set_attr "mode" "<MODE>")])
16837 (define_expand "xop_vmfrcz<mode>2"
16838   [(set (match_operand:VF_128 0 "register_operand")
16839         (vec_merge:VF_128
16840           (unspec:VF_128
16841            [(match_operand:VF_128 1 "nonimmediate_operand")]
16842            UNSPEC_FRCZ)
16843           (match_dup 2)
16844           (const_int 1)))]
16845   "TARGET_XOP"
16846   "operands[2] = CONST0_RTX (<MODE>mode);")
16848 (define_insn "*xop_vmfrcz<mode>2"
16849   [(set (match_operand:VF_128 0 "register_operand" "=x")
16850         (vec_merge:VF_128
16851           (unspec:VF_128
16852            [(match_operand:VF_128 1 "nonimmediate_operand" "xm")]
16853            UNSPEC_FRCZ)
16854           (match_operand:VF_128 2 "const0_operand")
16855           (const_int 1)))]
16856   "TARGET_XOP"
16857   "vfrcz<ssescalarmodesuffix>\t{%1, %0|%0, %<iptr>1}"
16858   [(set_attr "type" "ssecvt1")
16859    (set_attr "mode" "<MODE>")])
16861 (define_insn "xop_maskcmp<mode>3"
16862   [(set (match_operand:VI_128 0 "register_operand" "=x")
16863         (match_operator:VI_128 1 "ix86_comparison_int_operator"
16864          [(match_operand:VI_128 2 "register_operand" "x")
16865           (match_operand:VI_128 3 "nonimmediate_operand" "xm")]))]
16866   "TARGET_XOP"
16867   "vpcom%Y1<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
16868   [(set_attr "type" "sse4arg")
16869    (set_attr "prefix_data16" "0")
16870    (set_attr "prefix_rep" "0")
16871    (set_attr "prefix_extra" "2")
16872    (set_attr "length_immediate" "1")
16873    (set_attr "mode" "TI")])
16875 (define_insn "xop_maskcmp_uns<mode>3"
16876   [(set (match_operand:VI_128 0 "register_operand" "=x")
16877         (match_operator:VI_128 1 "ix86_comparison_uns_operator"
16878          [(match_operand:VI_128 2 "register_operand" "x")
16879           (match_operand:VI_128 3 "nonimmediate_operand" "xm")]))]
16880   "TARGET_XOP"
16881   "vpcom%Y1u<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
16882   [(set_attr "type" "ssecmp")
16883    (set_attr "prefix_data16" "0")
16884    (set_attr "prefix_rep" "0")
16885    (set_attr "prefix_extra" "2")
16886    (set_attr "length_immediate" "1")
16887    (set_attr "mode" "TI")])
16889 ;; Version of pcom*u* that is called from the intrinsics that allows pcomequ*
16890 ;; and pcomneu* not to be converted to the signed ones in case somebody needs
16891 ;; the exact instruction generated for the intrinsic.
16892 (define_insn "xop_maskcmp_uns2<mode>3"
16893   [(set (match_operand:VI_128 0 "register_operand" "=x")
16894         (unspec:VI_128
16895          [(match_operator:VI_128 1 "ix86_comparison_uns_operator"
16896           [(match_operand:VI_128 2 "register_operand" "x")
16897            (match_operand:VI_128 3 "nonimmediate_operand" "xm")])]
16898          UNSPEC_XOP_UNSIGNED_CMP))]
16899   "TARGET_XOP"
16900   "vpcom%Y1u<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
16901   [(set_attr "type" "ssecmp")
16902    (set_attr "prefix_data16" "0")
16903    (set_attr "prefix_extra" "2")
16904    (set_attr "length_immediate" "1")
16905    (set_attr "mode" "TI")])
16907 ;; Pcomtrue and pcomfalse support.  These are useless instructions, but are
16908 ;; being added here to be complete.
16909 (define_insn "xop_pcom_tf<mode>3"
16910   [(set (match_operand:VI_128 0 "register_operand" "=x")
16911         (unspec:VI_128
16912           [(match_operand:VI_128 1 "register_operand" "x")
16913            (match_operand:VI_128 2 "nonimmediate_operand" "xm")
16914            (match_operand:SI 3 "const_int_operand" "n")]
16915           UNSPEC_XOP_TRUEFALSE))]
16916   "TARGET_XOP"
16918   return ((INTVAL (operands[3]) != 0)
16919           ? "vpcomtrue<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16920           : "vpcomfalse<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}");
16922   [(set_attr "type" "ssecmp")
16923    (set_attr "prefix_data16" "0")
16924    (set_attr "prefix_extra" "2")
16925    (set_attr "length_immediate" "1")
16926    (set_attr "mode" "TI")])
16928 (define_insn "xop_vpermil2<mode>3"
16929   [(set (match_operand:VF_128_256 0 "register_operand" "=x")
16930         (unspec:VF_128_256
16931           [(match_operand:VF_128_256 1 "register_operand" "x")
16932            (match_operand:VF_128_256 2 "nonimmediate_operand" "%x")
16933            (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "xm")
16934            (match_operand:SI 4 "const_0_to_3_operand" "n")]
16935           UNSPEC_VPERMIL2))]
16936   "TARGET_XOP"
16937   "vpermil2<ssemodesuffix>\t{%4, %3, %2, %1, %0|%0, %1, %2, %3, %4}"
16938   [(set_attr "type" "sse4arg")
16939    (set_attr "length_immediate" "1")
16940    (set_attr "mode" "<MODE>")])
16942 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16944 (define_insn "aesenc"
16945   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
16946         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
16947                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
16948                       UNSPEC_AESENC))]
16949   "TARGET_AES"
16950   "@
16951    aesenc\t{%2, %0|%0, %2}
16952    vaesenc\t{%2, %1, %0|%0, %1, %2}"
16953   [(set_attr "isa" "noavx,avx")
16954    (set_attr "type" "sselog1")
16955    (set_attr "prefix_extra" "1")
16956    (set_attr "prefix" "orig,vex")
16957    (set_attr "btver2_decode" "double,double")
16958    (set_attr "mode" "TI")])
16960 (define_insn "aesenclast"
16961   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
16962         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
16963                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
16964                       UNSPEC_AESENCLAST))]
16965   "TARGET_AES"
16966   "@
16967    aesenclast\t{%2, %0|%0, %2}
16968    vaesenclast\t{%2, %1, %0|%0, %1, %2}"
16969   [(set_attr "isa" "noavx,avx")
16970    (set_attr "type" "sselog1")
16971    (set_attr "prefix_extra" "1")
16972    (set_attr "prefix" "orig,vex")
16973    (set_attr "btver2_decode" "double,double") 
16974    (set_attr "mode" "TI")])
16976 (define_insn "aesdec"
16977   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
16978         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
16979                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
16980                       UNSPEC_AESDEC))]
16981   "TARGET_AES"
16982   "@
16983    aesdec\t{%2, %0|%0, %2}
16984    vaesdec\t{%2, %1, %0|%0, %1, %2}"
16985   [(set_attr "isa" "noavx,avx")
16986    (set_attr "type" "sselog1")
16987    (set_attr "prefix_extra" "1")
16988    (set_attr "prefix" "orig,vex")
16989    (set_attr "btver2_decode" "double,double") 
16990    (set_attr "mode" "TI")])
16992 (define_insn "aesdeclast"
16993   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
16994         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
16995                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
16996                       UNSPEC_AESDECLAST))]
16997   "TARGET_AES"
16998   "@
16999    aesdeclast\t{%2, %0|%0, %2}
17000    vaesdeclast\t{%2, %1, %0|%0, %1, %2}"
17001   [(set_attr "isa" "noavx,avx")
17002    (set_attr "type" "sselog1")
17003    (set_attr "prefix_extra" "1")
17004    (set_attr "prefix" "orig,vex")
17005    (set_attr "btver2_decode" "double,double")
17006    (set_attr "mode" "TI")])
17008 (define_insn "aesimc"
17009   [(set (match_operand:V2DI 0 "register_operand" "=x")
17010         (unspec:V2DI [(match_operand:V2DI 1 "vector_operand" "xBm")]
17011                       UNSPEC_AESIMC))]
17012   "TARGET_AES"
17013   "%vaesimc\t{%1, %0|%0, %1}"
17014   [(set_attr "type" "sselog1")
17015    (set_attr "prefix_extra" "1")
17016    (set_attr "prefix" "maybe_vex")
17017    (set_attr "mode" "TI")])
17019 (define_insn "aeskeygenassist"
17020   [(set (match_operand:V2DI 0 "register_operand" "=x")
17021         (unspec:V2DI [(match_operand:V2DI 1 "vector_operand" "xBm")
17022                       (match_operand:SI 2 "const_0_to_255_operand" "n")]
17023                      UNSPEC_AESKEYGENASSIST))]
17024   "TARGET_AES"
17025   "%vaeskeygenassist\t{%2, %1, %0|%0, %1, %2}"
17026   [(set_attr "type" "sselog1")
17027    (set_attr "prefix_extra" "1")
17028    (set_attr "length_immediate" "1")
17029    (set_attr "prefix" "maybe_vex")
17030    (set_attr "mode" "TI")])
17032 (define_insn "pclmulqdq"
17033   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
17034         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
17035                       (match_operand:V2DI 2 "vector_operand" "xBm,xm")
17036                       (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
17037                      UNSPEC_PCLMUL))]
17038   "TARGET_PCLMUL"
17039   "@
17040    pclmulqdq\t{%3, %2, %0|%0, %2, %3}
17041    vpclmulqdq\t{%3, %2, %1, %0|%0, %1, %2, %3}"
17042   [(set_attr "isa" "noavx,avx")
17043    (set_attr "type" "sselog1")
17044    (set_attr "prefix_extra" "1")
17045    (set_attr "length_immediate" "1")
17046    (set_attr "prefix" "orig,vex")
17047    (set_attr "mode" "TI")])
17049 (define_expand "avx_vzeroall"
17050   [(match_par_dup 0 [(const_int 0)])]
17051   "TARGET_AVX"
17053   int nregs = TARGET_64BIT ? 16 : 8;
17054   int regno;
17056   operands[0] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs + 1));
17058   XVECEXP (operands[0], 0, 0)
17059     = gen_rtx_UNSPEC_VOLATILE (VOIDmode, gen_rtvec (1, const0_rtx),
17060                                UNSPECV_VZEROALL);
17062   for (regno = 0; regno < nregs; regno++)
17063     XVECEXP (operands[0], 0, regno + 1)
17064       = gen_rtx_SET (gen_rtx_REG (V8SImode, SSE_REGNO (regno)),
17065                      CONST0_RTX (V8SImode));
17068 (define_insn "*avx_vzeroall"
17069   [(match_parallel 0 "vzeroall_operation"
17070     [(unspec_volatile [(const_int 0)] UNSPECV_VZEROALL)])]
17071   "TARGET_AVX"
17072   "vzeroall"
17073   [(set_attr "type" "sse")
17074    (set_attr "modrm" "0")
17075    (set_attr "memory" "none")
17076    (set_attr "prefix" "vex")
17077    (set_attr "btver2_decode" "vector")
17078    (set_attr "mode" "OI")])
17080 ;; Clear the upper 128bits of AVX registers, equivalent to a NOP
17081 ;; if the upper 128bits are unused.
17082 (define_insn "avx_vzeroupper"
17083   [(unspec_volatile [(const_int 0)] UNSPECV_VZEROUPPER)]
17084   "TARGET_AVX"
17085   "vzeroupper"
17086   [(set_attr "type" "sse")
17087    (set_attr "modrm" "0")
17088    (set_attr "memory" "none")
17089    (set_attr "prefix" "vex")
17090    (set_attr "btver2_decode" "vector")
17091    (set_attr "mode" "OI")])
17093 (define_insn "avx2_pbroadcast<mode>"
17094   [(set (match_operand:VI 0 "register_operand" "=x")
17095         (vec_duplicate:VI
17096           (vec_select:<ssescalarmode>
17097             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "xm")
17098             (parallel [(const_int 0)]))))]
17099   "TARGET_AVX2"
17100   "vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}"
17101   [(set_attr "type" "ssemov")
17102    (set_attr "prefix_extra" "1")
17103    (set_attr "prefix" "vex")
17104    (set_attr "mode" "<sseinsnmode>")])
17106 (define_insn "avx2_pbroadcast<mode>_1"
17107   [(set (match_operand:VI_256 0 "register_operand" "=x,x")
17108         (vec_duplicate:VI_256
17109           (vec_select:<ssescalarmode>
17110             (match_operand:VI_256 1 "nonimmediate_operand" "m,x")
17111             (parallel [(const_int 0)]))))]
17112   "TARGET_AVX2"
17113   "@
17114    vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}
17115    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}"
17116   [(set_attr "type" "ssemov")
17117    (set_attr "prefix_extra" "1")
17118    (set_attr "prefix" "vex")
17119    (set_attr "mode" "<sseinsnmode>")])
17121 (define_insn "<avx2_avx512>_permvar<mode><mask_name>"
17122   [(set (match_operand:VI48F_256_512 0 "register_operand" "=v")
17123         (unspec:VI48F_256_512
17124           [(match_operand:VI48F_256_512 1 "nonimmediate_operand" "vm")
17125            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
17126           UNSPEC_VPERMVAR))]
17127   "TARGET_AVX2 && <mask_mode512bit_condition>"
17128   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
17129   [(set_attr "type" "sselog")
17130    (set_attr "prefix" "<mask_prefix2>")
17131    (set_attr "mode" "<sseinsnmode>")])
17133 (define_insn "<avx512>_permvar<mode><mask_name>"
17134   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
17135         (unspec:VI1_AVX512VL
17136           [(match_operand:VI1_AVX512VL 1 "nonimmediate_operand" "vm")
17137            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
17138           UNSPEC_VPERMVAR))]
17139   "TARGET_AVX512VBMI && <mask_mode512bit_condition>"
17140   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
17141   [(set_attr "type" "sselog")
17142    (set_attr "prefix" "<mask_prefix2>")
17143    (set_attr "mode" "<sseinsnmode>")])
17145 (define_insn "<avx512>_permvar<mode><mask_name>"
17146   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17147         (unspec:VI2_AVX512VL
17148           [(match_operand:VI2_AVX512VL 1 "nonimmediate_operand" "vm")
17149            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
17150           UNSPEC_VPERMVAR))]
17151   "TARGET_AVX512BW && <mask_mode512bit_condition>"
17152   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
17153   [(set_attr "type" "sselog")
17154    (set_attr "prefix" "<mask_prefix2>")
17155    (set_attr "mode" "<sseinsnmode>")])
17157 (define_expand "<avx2_avx512>_perm<mode>"
17158   [(match_operand:VI8F_256_512 0 "register_operand")
17159    (match_operand:VI8F_256_512 1 "nonimmediate_operand")
17160    (match_operand:SI 2 "const_0_to_255_operand")]
17161   "TARGET_AVX2"
17163   int mask = INTVAL (operands[2]);
17164   emit_insn (gen_<avx2_avx512>_perm<mode>_1 (operands[0], operands[1],
17165                                               GEN_INT ((mask >> 0) & 3),
17166                                               GEN_INT ((mask >> 2) & 3),
17167                                               GEN_INT ((mask >> 4) & 3),
17168                                               GEN_INT ((mask >> 6) & 3)));
17169   DONE;
17172 (define_expand "<avx512>_perm<mode>_mask"
17173   [(match_operand:VI8F_256_512 0 "register_operand")
17174    (match_operand:VI8F_256_512 1 "nonimmediate_operand")
17175    (match_operand:SI 2 "const_0_to_255_operand")
17176    (match_operand:VI8F_256_512 3 "vector_move_operand")
17177    (match_operand:<avx512fmaskmode> 4 "register_operand")]
17178   "TARGET_AVX512F"
17180   int mask = INTVAL (operands[2]);
17181   emit_insn (gen_<avx2_avx512>_perm<mode>_1_mask (operands[0], operands[1],
17182                                                    GEN_INT ((mask >> 0) & 3),
17183                                                    GEN_INT ((mask >> 2) & 3),
17184                                                    GEN_INT ((mask >> 4) & 3),
17185                                                    GEN_INT ((mask >> 6) & 3),
17186                                                    operands[3], operands[4]));
17187   DONE;
17190 (define_insn "<avx2_avx512>_perm<mode>_1<mask_name>"
17191   [(set (match_operand:VI8F_256_512 0 "register_operand" "=v")
17192         (vec_select:VI8F_256_512
17193           (match_operand:VI8F_256_512 1 "nonimmediate_operand" "vm")
17194           (parallel [(match_operand 2 "const_0_to_3_operand")
17195                      (match_operand 3 "const_0_to_3_operand")
17196                      (match_operand 4 "const_0_to_3_operand")
17197                      (match_operand 5 "const_0_to_3_operand")])))]
17198   "TARGET_AVX2 && <mask_mode512bit_condition>"
17200   int mask = 0;
17201   mask |= INTVAL (operands[2]) << 0;
17202   mask |= INTVAL (operands[3]) << 2;
17203   mask |= INTVAL (operands[4]) << 4;
17204   mask |= INTVAL (operands[5]) << 6;
17205   operands[2] = GEN_INT (mask);
17206   return "vperm<ssemodesuffix>\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
17208   [(set_attr "type" "sselog")
17209    (set_attr "prefix" "<mask_prefix2>")
17210    (set_attr "mode" "<sseinsnmode>")])
17212 (define_insn "avx2_permv2ti"
17213   [(set (match_operand:V4DI 0 "register_operand" "=x")
17214         (unspec:V4DI
17215           [(match_operand:V4DI 1 "register_operand" "x")
17216            (match_operand:V4DI 2 "nonimmediate_operand" "xm")
17217            (match_operand:SI 3 "const_0_to_255_operand" "n")]
17218           UNSPEC_VPERMTI))]
17219   "TARGET_AVX2"
17220   "vperm2i128\t{%3, %2, %1, %0|%0, %1, %2, %3}"
17221   [(set_attr "type" "sselog")
17222    (set_attr "prefix" "vex")
17223    (set_attr "mode" "OI")])
17225 (define_insn "avx2_vec_dupv4df"
17226   [(set (match_operand:V4DF 0 "register_operand" "=x")
17227         (vec_duplicate:V4DF
17228           (vec_select:DF
17229             (match_operand:V2DF 1 "register_operand" "x")
17230             (parallel [(const_int 0)]))))]
17231   "TARGET_AVX2"
17232   "vbroadcastsd\t{%1, %0|%0, %1}"
17233   [(set_attr "type" "sselog1")
17234    (set_attr "prefix" "vex")
17235    (set_attr "mode" "V4DF")])
17237 (define_insn "<avx512>_vec_dup<mode>_1"
17238   [(set (match_operand:VI_AVX512BW 0 "register_operand" "=v,v")
17239         (vec_duplicate:VI_AVX512BW
17240           (vec_select:VI_AVX512BW
17241             (match_operand:VI_AVX512BW 1 "nonimmediate_operand" "v,m")
17242             (parallel [(const_int 0)]))))]
17243   "TARGET_AVX512F"
17244   "@
17245    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}
17246    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %<iptr>1}"
17247   [(set_attr "type" "ssemov")
17248    (set_attr "prefix" "evex")
17249    (set_attr "mode" "<sseinsnmode>")])
17251 (define_insn "<avx512>_vec_dup<mode><mask_name>"
17252   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v")
17253         (vec_duplicate:V48_AVX512VL
17254           (vec_select:<ssescalarmode>
17255             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
17256             (parallel [(const_int 0)]))))]
17257   "TARGET_AVX512F"
17259   /*  There is no DF broadcast (in AVX-512*) to 128b register.
17260       Mimic it with integer variant.  */
17261   if (<MODE>mode == V2DFmode)
17262     return "vpbroadcastq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
17263   else
17264     return "v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
17266   [(set_attr "type" "ssemov")
17267    (set_attr "prefix" "evex")
17268    (set_attr "mode" "<sseinsnmode>")])
17270 (define_insn "<avx512>_vec_dup<mode><mask_name>"
17271   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
17272         (vec_duplicate:VI12_AVX512VL
17273           (vec_select:<ssescalarmode>
17274             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
17275             (parallel [(const_int 0)]))))]
17276   "TARGET_AVX512BW"
17277   "vpbroadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17278   [(set_attr "type" "ssemov")
17279    (set_attr "prefix" "evex")
17280    (set_attr "mode" "<sseinsnmode>")])
17282 (define_insn "<mask_codefor>avx512f_broadcast<mode><mask_name>"
17283   [(set (match_operand:V16FI 0 "register_operand" "=v,v")
17284         (vec_duplicate:V16FI
17285           (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "v,m")))]
17286   "TARGET_AVX512F"
17287   "@
17288    vshuf<shuffletype>32x4\t{$0x0, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x0}
17289    vbroadcast<shuffletype>32x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17290   [(set_attr "type" "ssemov")
17291    (set_attr "prefix" "evex")
17292    (set_attr "mode" "<sseinsnmode>")])
17294 (define_insn "<mask_codefor>avx512f_broadcast<mode><mask_name>"
17295   [(set (match_operand:V8FI 0 "register_operand" "=v,v")
17296         (vec_duplicate:V8FI
17297           (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "v,m")))]
17298   "TARGET_AVX512F"
17299   "@
17300    vshuf<shuffletype>64x2\t{$0x44, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x44}
17301    vbroadcast<shuffletype>64x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17302   [(set_attr "type" "ssemov")
17303    (set_attr "prefix" "evex")
17304    (set_attr "mode" "<sseinsnmode>")])
17306 (define_insn "<mask_codefor><avx512>_vec_dup_gpr<mode><mask_name>"
17307   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v,v")
17308         (vec_duplicate:VI12_AVX512VL
17309           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "vm,r")))]
17310   "TARGET_AVX512BW"
17311   "@
17312    vpbroadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}
17313    vpbroadcast<bcstscalarsuff>\t{%k1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
17314   [(set_attr "type" "ssemov")
17315    (set_attr "prefix" "evex")
17316    (set_attr "mode" "<sseinsnmode>")])
17318 (define_insn "<mask_codefor><avx512>_vec_dup_gpr<mode><mask_name>"
17319   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v,v")
17320         (vec_duplicate:V48_AVX512VL
17321           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "vm,r")))]
17322   "TARGET_AVX512F"
17323   "v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17324   [(set_attr "type" "ssemov")
17325    (set_attr "prefix" "evex")
17326    (set_attr "mode" "<sseinsnmode>")
17327    (set (attr "enabled")
17328      (if_then_else (eq_attr "alternative" "1")
17329         (symbol_ref "GET_MODE_CLASS (<ssescalarmode>mode) == MODE_INT
17330                      && (<ssescalarmode>mode != DImode || TARGET_64BIT)")
17331         (const_int 1)))])
17333 (define_insn "vec_dupv4sf"
17334   [(set (match_operand:V4SF 0 "register_operand" "=x,x,x")
17335         (vec_duplicate:V4SF
17336           (match_operand:SF 1 "nonimmediate_operand" "x,m,0")))]
17337   "TARGET_SSE"
17338   "@
17339    vshufps\t{$0, %1, %1, %0|%0, %1, %1, 0}
17340    vbroadcastss\t{%1, %0|%0, %1}
17341    shufps\t{$0, %0, %0|%0, %0, 0}"
17342   [(set_attr "isa" "avx,avx,noavx")
17343    (set_attr "type" "sseshuf1,ssemov,sseshuf1")
17344    (set_attr "length_immediate" "1,0,1")
17345    (set_attr "prefix_extra" "0,1,*")
17346    (set_attr "prefix" "vex,vex,orig")
17347    (set_attr "mode" "V4SF")])
17349 (define_insn "*vec_dupv4si"
17350   [(set (match_operand:V4SI 0 "register_operand"     "=x,x,x")
17351         (vec_duplicate:V4SI
17352           (match_operand:SI 1 "nonimmediate_operand" " x,m,0")))]
17353   "TARGET_SSE"
17354   "@
17355    %vpshufd\t{$0, %1, %0|%0, %1, 0}
17356    vbroadcastss\t{%1, %0|%0, %1}
17357    shufps\t{$0, %0, %0|%0, %0, 0}"
17358   [(set_attr "isa" "sse2,avx,noavx")
17359    (set_attr "type" "sselog1,ssemov,sselog1")
17360    (set_attr "length_immediate" "1,0,1")
17361    (set_attr "prefix_extra" "0,1,*")
17362    (set_attr "prefix" "maybe_vex,vex,orig")
17363    (set_attr "mode" "TI,V4SF,V4SF")])
17365 (define_insn "*vec_dupv2di"
17366   [(set (match_operand:V2DI 0 "register_operand"     "=x,x,x,x")
17367         (vec_duplicate:V2DI
17368           (match_operand:DI 1 "nonimmediate_operand" " 0,x,m,0")))]
17369   "TARGET_SSE"
17370   "@
17371    punpcklqdq\t%0, %0
17372    vpunpcklqdq\t{%d1, %0|%0, %d1}
17373    %vmovddup\t{%1, %0|%0, %1}
17374    movlhps\t%0, %0"
17375   [(set_attr "isa" "sse2_noavx,avx,sse3,noavx")
17376    (set_attr "type" "sselog1,sselog1,sselog1,ssemov")
17377    (set_attr "prefix" "orig,vex,maybe_vex,orig")
17378    (set_attr "mode" "TI,TI,DF,V4SF")])
17380 (define_insn "avx2_vbroadcasti128_<mode>"
17381   [(set (match_operand:VI_256 0 "register_operand" "=x")
17382         (vec_concat:VI_256
17383           (match_operand:<ssehalfvecmode> 1 "memory_operand" "m")
17384           (match_dup 1)))]
17385   "TARGET_AVX2"
17386   "vbroadcasti128\t{%1, %0|%0, %1}"
17387   [(set_attr "type" "ssemov")
17388    (set_attr "prefix_extra" "1")
17389    (set_attr "prefix" "vex")
17390    (set_attr "mode" "OI")])
17392 ;; Modes handled by AVX vec_dup patterns.
17393 (define_mode_iterator AVX_VEC_DUP_MODE
17394   [V8SI V8SF V4DI V4DF])
17395 ;; Modes handled by AVX2 vec_dup patterns.
17396 (define_mode_iterator AVX2_VEC_DUP_MODE
17397   [V32QI V16QI V16HI V8HI V8SI V4SI])
17399 (define_insn "*vec_dup<mode>"
17400   [(set (match_operand:AVX2_VEC_DUP_MODE 0 "register_operand" "=x,x,Yi")
17401         (vec_duplicate:AVX2_VEC_DUP_MODE
17402           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,x,$r")))]
17403   "TARGET_AVX2"
17404   "@
17405    v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0|%0, %1}
17406    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}
17407    #"
17408   [(set_attr "isa" "*,*,noavx512vl")
17409    (set_attr "type" "ssemov")
17410    (set_attr "prefix_extra" "1")
17411    (set_attr "prefix" "maybe_evex")
17412    (set_attr "mode" "<sseinsnmode>")])
17414 (define_insn "vec_dup<mode>"
17415   [(set (match_operand:AVX_VEC_DUP_MODE 0 "register_operand" "=x,x,x,v,x")
17416         (vec_duplicate:AVX_VEC_DUP_MODE
17417           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,m,x,v,?x")))]
17418   "TARGET_AVX"
17419   "@
17420    v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0|%0, %1}
17421    vbroadcast<ssescalarmodesuffix>\t{%1, %0|%0, %1}
17422    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}
17423    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %g0|%g0, %x1}
17424    #"
17425   [(set_attr "type" "ssemov")
17426    (set_attr "prefix_extra" "1")
17427    (set_attr "prefix" "maybe_evex")
17428    (set_attr "isa" "avx2,noavx2,avx2,avx512f,noavx2")
17429    (set_attr "mode" "<sseinsnmode>,V8SF,<sseinsnmode>,<sseinsnmode>,V8SF")])
17431 (define_split
17432   [(set (match_operand:AVX2_VEC_DUP_MODE 0 "register_operand")
17433         (vec_duplicate:AVX2_VEC_DUP_MODE
17434           (match_operand:<ssescalarmode> 1 "register_operand")))]
17435   "TARGET_AVX2
17436    /* Disable this splitter if avx512vl_vec_dup_gprv*[qhs]i insn is
17437       available, because then we can broadcast from GPRs directly.
17438       For V*[QH]I modes it requires both -mavx512vl and -mavx512bw,
17439       for V*SI mode it requires just -mavx512vl.  */
17440    && !(TARGET_AVX512VL
17441         && (TARGET_AVX512BW || <ssescalarmode>mode == SImode))
17442    && reload_completed && GENERAL_REG_P (operands[1])"
17443   [(const_int 0)]
17445   emit_insn (gen_vec_setv4si_0 (gen_lowpart (V4SImode, operands[0]),
17446                                 CONST0_RTX (V4SImode),
17447                                 gen_lowpart (SImode, operands[1])));
17448   emit_insn (gen_avx2_pbroadcast<mode> (operands[0],
17449                                         gen_lowpart (<ssexmmmode>mode,
17450                                                      operands[0])));
17451   DONE;
17454 (define_split
17455   [(set (match_operand:AVX_VEC_DUP_MODE 0 "register_operand")
17456         (vec_duplicate:AVX_VEC_DUP_MODE
17457           (match_operand:<ssescalarmode> 1 "register_operand")))]
17458   "TARGET_AVX && !TARGET_AVX2 && reload_completed"
17459   [(set (match_dup 2)
17460         (vec_duplicate:<ssehalfvecmode> (match_dup 1)))
17461    (set (match_dup 0)
17462         (vec_concat:AVX_VEC_DUP_MODE (match_dup 2) (match_dup 2)))]
17463   "operands[2] = gen_rtx_REG (<ssehalfvecmode>mode, REGNO (operands[0]));")
17465 (define_insn "avx_vbroadcastf128_<mode>"
17466   [(set (match_operand:V_256 0 "register_operand" "=x,x,x")
17467         (vec_concat:V_256
17468           (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "m,0,?x")
17469           (match_dup 1)))]
17470   "TARGET_AVX"
17471   "@
17472    vbroadcast<i128>\t{%1, %0|%0, %1}
17473    vinsert<i128>\t{$1, %1, %0, %0|%0, %0, %1, 1}
17474    vperm2<i128>\t{$0, %t1, %t1, %0|%0, %t1, %t1, 0}"
17475   [(set_attr "type" "ssemov,sselog1,sselog1")
17476    (set_attr "prefix_extra" "1")
17477    (set_attr "length_immediate" "0,1,1")
17478    (set_attr "prefix" "vex")
17479    (set_attr "mode" "<sseinsnmode>")])
17481 ;; For broadcast[i|f]32x2.  Yes there is no v4sf version, only v4si.
17482 (define_mode_iterator VI4F_BRCST32x2
17483   [V16SI (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
17484    V16SF (V8SF "TARGET_AVX512VL")])
17486 (define_mode_attr 64x2mode
17487   [(V8DF "V2DF") (V8DI "V2DI") (V4DI "V2DI") (V4DF "V2DF")])
17489 (define_mode_attr 32x2mode
17490   [(V16SF "V2SF") (V16SI "V2SI") (V8SI "V2SI")
17491   (V8SF "V2SF") (V4SI "V2SI")])
17493 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>"
17494   [(set (match_operand:VI4F_BRCST32x2 0 "register_operand" "=v")
17495         (vec_duplicate:VI4F_BRCST32x2
17496           (vec_select:<32x2mode>
17497             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
17498             (parallel [(const_int 0) (const_int 1)]))))]
17499   "TARGET_AVX512DQ"
17500   "vbroadcast<shuffletype>32x2\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17501   [(set_attr "type" "ssemov")
17502    (set_attr "prefix_extra" "1")
17503    (set_attr "prefix" "evex")
17504    (set_attr "mode" "<sseinsnmode>")])
17506 (define_insn "<mask_codefor>avx512vl_broadcast<mode><mask_name>_1"
17507   [(set (match_operand:VI4F_256 0 "register_operand" "=v,v")
17508         (vec_duplicate:VI4F_256
17509          (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "v,m")))]
17510   "TARGET_AVX512VL"
17511   "@
17512    vshuf<shuffletype>32x4\t{$0x0, %t1, %t1, %0<mask_operand2>|%0<mask_operand2>, %t1, %t1, 0x0}
17513    vbroadcast<shuffletype>32x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17514   [(set_attr "type" "ssemov")
17515    (set_attr "prefix_extra" "1")
17516    (set_attr "prefix" "evex")
17517    (set_attr "mode" "<sseinsnmode>")])
17519 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>_1"
17520   [(set (match_operand:V16FI 0 "register_operand" "=v,v")
17521        (vec_duplicate:V16FI
17522          (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "v,m")))]
17523   "TARGET_AVX512DQ"
17524   "@
17525    vshuf<shuffletype>32x4\t{$0x44, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x44}
17526    vbroadcast<shuffletype>32x8\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17527   [(set_attr "type" "ssemov")
17528    (set_attr "prefix_extra" "1")
17529    (set_attr "prefix" "evex")
17530    (set_attr "mode" "<sseinsnmode>")])
17532 ;; For broadcast[i|f]64x2
17533 (define_mode_iterator VI8F_BRCST64x2
17534   [V8DI V8DF (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")])
17536 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>_1"
17537   [(set (match_operand:VI8F_BRCST64x2 0 "register_operand" "=v,v")
17538        (vec_duplicate:VI8F_BRCST64x2
17539          (match_operand:<64x2mode> 1 "nonimmediate_operand" "v,m")))]
17540   "TARGET_AVX512DQ"
17541   "@
17542    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}
17543    vbroadcast<shuffletype>64x2\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17544   [(set_attr "type" "ssemov")
17545    (set_attr "prefix_extra" "1")
17546    (set_attr "prefix" "evex")
17547    (set_attr "mode" "<sseinsnmode>")])
17549 (define_insn "avx512cd_maskb_vec_dup<mode>"
17550   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
17551         (vec_duplicate:VI8_AVX512VL
17552           (zero_extend:DI
17553             (match_operand:QI 1 "register_operand" "Yk"))))]
17554   "TARGET_AVX512CD"
17555   "vpbroadcastmb2q\t{%1, %0|%0, %1}"
17556   [(set_attr "type" "mskmov")
17557    (set_attr "prefix" "evex")
17558    (set_attr "mode" "XI")])
17560 (define_insn "avx512cd_maskw_vec_dup<mode>"
17561   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
17562         (vec_duplicate:VI4_AVX512VL
17563           (zero_extend:SI
17564             (match_operand:HI 1 "register_operand" "Yk"))))]
17565   "TARGET_AVX512CD"
17566   "vpbroadcastmw2d\t{%1, %0|%0, %1}"
17567   [(set_attr "type" "mskmov")
17568    (set_attr "prefix" "evex")
17569    (set_attr "mode" "XI")])
17571 ;; Recognize broadcast as a vec_select as produced by builtin_vec_perm.
17572 ;; If it so happens that the input is in memory, use vbroadcast.
17573 ;; Otherwise use vpermilp (and in the case of 256-bit modes, vperm2f128).
17574 (define_insn "*avx_vperm_broadcast_v4sf"
17575   [(set (match_operand:V4SF 0 "register_operand" "=x,x,x")
17576         (vec_select:V4SF
17577           (match_operand:V4SF 1 "nonimmediate_operand" "m,o,x")
17578           (match_parallel 2 "avx_vbroadcast_operand"
17579             [(match_operand 3 "const_int_operand" "C,n,n")])))]
17580   "TARGET_AVX"
17582   int elt = INTVAL (operands[3]);
17583   switch (which_alternative)
17584     {
17585     case 0:
17586     case 1:
17587       operands[1] = adjust_address_nv (operands[1], SFmode, elt * 4);
17588       return "vbroadcastss\t{%1, %0|%0, %k1}";
17589     case 2:
17590       operands[2] = GEN_INT (elt * 0x55);
17591       return "vpermilps\t{%2, %1, %0|%0, %1, %2}";
17592     default:
17593       gcc_unreachable ();
17594     }
17596   [(set_attr "type" "ssemov,ssemov,sselog1")
17597    (set_attr "prefix_extra" "1")
17598    (set_attr "length_immediate" "0,0,1")
17599    (set_attr "prefix" "vex")
17600    (set_attr "mode" "SF,SF,V4SF")])
17602 (define_insn_and_split "*avx_vperm_broadcast_<mode>"
17603   [(set (match_operand:VF_256 0 "register_operand" "=x,x,x")
17604         (vec_select:VF_256
17605           (match_operand:VF_256 1 "nonimmediate_operand" "m,o,?x")
17606           (match_parallel 2 "avx_vbroadcast_operand"
17607             [(match_operand 3 "const_int_operand" "C,n,n")])))]
17608   "TARGET_AVX"
17609   "#"
17610   "&& reload_completed && (<MODE>mode != V4DFmode || !TARGET_AVX2)"
17611   [(set (match_dup 0) (vec_duplicate:VF_256 (match_dup 1)))]
17613   rtx op0 = operands[0], op1 = operands[1];
17614   int elt = INTVAL (operands[3]);
17616   if (REG_P (op1))
17617     {
17618       int mask;
17620       if (TARGET_AVX2 && elt == 0)
17621         {
17622           emit_insn (gen_vec_dup<mode> (op0, gen_lowpart (<ssescalarmode>mode,
17623                                                           op1)));
17624           DONE;
17625         }
17627       /* Shuffle element we care about into all elements of the 128-bit lane.
17628          The other lane gets shuffled too, but we don't care.  */
17629       if (<MODE>mode == V4DFmode)
17630         mask = (elt & 1 ? 15 : 0);
17631       else
17632         mask = (elt & 3) * 0x55;
17633       emit_insn (gen_avx_vpermil<mode> (op0, op1, GEN_INT (mask)));
17635       /* Shuffle the lane we care about into both lanes of the dest.  */
17636       mask = (elt / (<ssescalarnum> / 2)) * 0x11;
17637       emit_insn (gen_avx_vperm2f128<mode>3 (op0, op0, op0, GEN_INT (mask)));
17638       DONE;
17639     }
17641   operands[1] = adjust_address (op1, <ssescalarmode>mode,
17642                                 elt * GET_MODE_SIZE (<ssescalarmode>mode));
17645 (define_expand "<sse2_avx_avx512f>_vpermil<mode><mask_name>"
17646   [(set (match_operand:VF2 0 "register_operand")
17647         (vec_select:VF2
17648           (match_operand:VF2 1 "nonimmediate_operand")
17649           (match_operand:SI 2 "const_0_to_255_operand")))]
17650   "TARGET_AVX && <mask_mode512bit_condition>"
17652   int mask = INTVAL (operands[2]);
17653   rtx perm[<ssescalarnum>];
17655   int i;
17656   for (i = 0; i < <ssescalarnum>; i = i + 2)
17657     {
17658       perm[i]     = GEN_INT (((mask >> i)       & 1) + i);
17659       perm[i + 1] = GEN_INT (((mask >> (i + 1)) & 1) + i);
17660     }
17662   operands[2]
17663     = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (<ssescalarnum>, perm));
17666 (define_expand "<sse2_avx_avx512f>_vpermil<mode><mask_name>"
17667   [(set (match_operand:VF1 0 "register_operand")
17668         (vec_select:VF1
17669           (match_operand:VF1 1 "nonimmediate_operand")
17670           (match_operand:SI 2 "const_0_to_255_operand")))]
17671   "TARGET_AVX && <mask_mode512bit_condition>"
17673   int mask = INTVAL (operands[2]);
17674   rtx perm[<ssescalarnum>];
17676   int i;
17677   for (i = 0; i < <ssescalarnum>; i = i + 4)
17678     {
17679       perm[i]     = GEN_INT (((mask >> 0) & 3) + i);
17680       perm[i + 1] = GEN_INT (((mask >> 2) & 3) + i);
17681       perm[i + 2] = GEN_INT (((mask >> 4) & 3) + i);
17682       perm[i + 3] = GEN_INT (((mask >> 6) & 3) + i);
17683     }
17685   operands[2]
17686     = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (<ssescalarnum>, perm));
17689 (define_insn "*<sse2_avx_avx512f>_vpermilp<mode><mask_name>"
17690   [(set (match_operand:VF 0 "register_operand" "=v")
17691         (vec_select:VF
17692           (match_operand:VF 1 "nonimmediate_operand" "vm")
17693           (match_parallel 2 ""
17694             [(match_operand 3 "const_int_operand")])))]
17695   "TARGET_AVX && <mask_mode512bit_condition>
17696    && avx_vpermilp_parallel (operands[2], <MODE>mode)"
17698   int mask = avx_vpermilp_parallel (operands[2], <MODE>mode) - 1;
17699   operands[2] = GEN_INT (mask);
17700   return "vpermil<ssemodesuffix>\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}";
17702   [(set_attr "type" "sselog")
17703    (set_attr "prefix_extra" "1")
17704    (set_attr "length_immediate" "1")
17705    (set_attr "prefix" "<mask_prefix>")
17706    (set_attr "mode" "<sseinsnmode>")])
17708 (define_insn "<sse2_avx_avx512f>_vpermilvar<mode>3<mask_name>"
17709   [(set (match_operand:VF 0 "register_operand" "=v")
17710         (unspec:VF
17711           [(match_operand:VF 1 "register_operand" "v")
17712            (match_operand:<sseintvecmode> 2 "nonimmediate_operand" "vm")]
17713           UNSPEC_VPERMIL))]
17714   "TARGET_AVX && <mask_mode512bit_condition>"
17715   "vpermil<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
17716   [(set_attr "type" "sselog")
17717    (set_attr "prefix_extra" "1")
17718    (set_attr "btver2_decode" "vector")
17719    (set_attr "prefix" "<mask_prefix>")
17720    (set_attr "mode" "<sseinsnmode>")])
17722 (define_expand "<avx512>_vpermi2var<mode>3_maskz"
17723   [(match_operand:VI48F 0 "register_operand" "=v")
17724    (match_operand:VI48F 1 "register_operand" "v")
17725    (match_operand:<sseintvecmode> 2 "register_operand" "0")
17726    (match_operand:VI48F 3 "nonimmediate_operand" "vm")
17727    (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")]
17728   "TARGET_AVX512F"
17730   emit_insn (gen_<avx512>_vpermi2var<mode>3_maskz_1 (
17731         operands[0], operands[1], operands[2], operands[3],
17732         CONST0_RTX (<MODE>mode), operands[4]));
17733   DONE;
17736 (define_expand "<avx512>_vpermi2var<mode>3_maskz"
17737   [(match_operand:VI1_AVX512VL 0 "register_operand")
17738    (match_operand:VI1_AVX512VL 1 "register_operand")
17739    (match_operand:<sseintvecmode> 2 "register_operand")
17740    (match_operand:VI1_AVX512VL 3 "nonimmediate_operand")
17741    (match_operand:<avx512fmaskmode> 4 "register_operand")]
17742   "TARGET_AVX512VBMI"
17744   emit_insn (gen_<avx512>_vpermi2var<mode>3_maskz_1 (
17745         operands[0], operands[1], operands[2], operands[3],
17746         CONST0_RTX (<MODE>mode), operands[4]));
17747   DONE;
17750 (define_expand "<avx512>_vpermi2var<mode>3_maskz"
17751   [(match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17752    (match_operand:VI2_AVX512VL 1 "register_operand" "v")
17753    (match_operand:<sseintvecmode> 2 "register_operand" "0")
17754    (match_operand:VI2_AVX512VL 3 "nonimmediate_operand" "vm")
17755    (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")]
17756   "TARGET_AVX512BW"
17758   emit_insn (gen_<avx512>_vpermi2var<mode>3_maskz_1 (
17759         operands[0], operands[1], operands[2], operands[3],
17760         CONST0_RTX (<MODE>mode), operands[4]));
17761   DONE;
17764 (define_insn "<avx512>_vpermi2var<mode>3<sd_maskz_name>"
17765   [(set (match_operand:VI48F 0 "register_operand" "=v")
17766         (unspec:VI48F
17767           [(match_operand:VI48F 1 "register_operand" "v")
17768            (match_operand:<sseintvecmode> 2 "register_operand" "0")
17769            (match_operand:VI48F 3 "nonimmediate_operand" "vm")]
17770           UNSPEC_VPERMI2))]
17771   "TARGET_AVX512F"
17772   "vpermi2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}"
17773   [(set_attr "type" "sselog")
17774    (set_attr "prefix" "evex")
17775    (set_attr "mode" "<sseinsnmode>")])
17777 (define_insn "<avx512>_vpermi2var<mode>3<sd_maskz_name>"
17778   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
17779         (unspec:VI1_AVX512VL
17780           [(match_operand:VI1_AVX512VL 1 "register_operand" "v")
17781            (match_operand:<sseintvecmode> 2 "register_operand" "0")
17782            (match_operand:VI1_AVX512VL 3 "nonimmediate_operand" "vm")]
17783           UNSPEC_VPERMI2))]
17784   "TARGET_AVX512VBMI"
17785   "vpermi2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}"
17786   [(set_attr "type" "sselog")
17787    (set_attr "prefix" "evex")
17788    (set_attr "mode" "<sseinsnmode>")])
17790 (define_insn "<avx512>_vpermi2var<mode>3<sd_maskz_name>"
17791   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17792         (unspec:VI2_AVX512VL
17793           [(match_operand:VI2_AVX512VL 1 "register_operand" "v")
17794            (match_operand:<sseintvecmode> 2 "register_operand" "0")
17795            (match_operand:VI2_AVX512VL 3 "nonimmediate_operand" "vm")]
17796           UNSPEC_VPERMI2))]
17797   "TARGET_AVX512BW"
17798   "vpermi2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}"
17799   [(set_attr "type" "sselog")
17800    (set_attr "prefix" "evex")
17801    (set_attr "mode" "<sseinsnmode>")])
17803 (define_insn "<avx512>_vpermi2var<mode>3_mask"
17804   [(set (match_operand:VI48F 0 "register_operand" "=v")
17805         (vec_merge:VI48F
17806           (unspec:VI48F
17807             [(match_operand:VI48F 1 "register_operand" "v")
17808             (match_operand:<sseintvecmode> 2 "register_operand" "0")
17809             (match_operand:VI48F 3 "nonimmediate_operand" "vm")]
17810             UNSPEC_VPERMI2_MASK)
17811           (match_dup 0)
17812           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
17813   "TARGET_AVX512F"
17814   "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
17815   [(set_attr "type" "sselog")
17816    (set_attr "prefix" "evex")
17817    (set_attr "mode" "<sseinsnmode>")])
17819 (define_insn "<avx512>_vpermi2var<mode>3_mask"
17820   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
17821         (vec_merge:VI1_AVX512VL
17822           (unspec:VI1_AVX512VL
17823             [(match_operand:VI1_AVX512VL 1 "register_operand" "v")
17824             (match_operand:<sseintvecmode> 2 "register_operand" "0")
17825             (match_operand:VI1_AVX512VL 3 "nonimmediate_operand" "vm")]
17826             UNSPEC_VPERMI2_MASK)
17827           (match_dup 0)
17828           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
17829   "TARGET_AVX512VBMI"
17830   "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
17831   [(set_attr "type" "sselog")
17832    (set_attr "prefix" "evex")
17833    (set_attr "mode" "<sseinsnmode>")])
17835 (define_insn "<avx512>_vpermi2var<mode>3_mask"
17836   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17837         (vec_merge:VI2_AVX512VL
17838           (unspec:VI2_AVX512VL
17839             [(match_operand:VI2_AVX512VL 1 "register_operand" "v")
17840             (match_operand:<sseintvecmode> 2 "register_operand" "0")
17841             (match_operand:VI2_AVX512VL 3 "nonimmediate_operand" "vm")]
17842             UNSPEC_VPERMI2_MASK)
17843           (match_dup 0)
17844           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
17845   "TARGET_AVX512BW"
17846   "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
17847   [(set_attr "type" "sselog")
17848    (set_attr "prefix" "evex")
17849    (set_attr "mode" "<sseinsnmode>")])
17851 (define_expand "<avx512>_vpermt2var<mode>3_maskz"
17852   [(match_operand:VI48F 0 "register_operand" "=v")
17853    (match_operand:<sseintvecmode> 1 "register_operand" "v")
17854    (match_operand:VI48F 2 "register_operand" "0")
17855    (match_operand:VI48F 3 "nonimmediate_operand" "vm")
17856    (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")]
17857   "TARGET_AVX512F"
17859   emit_insn (gen_<avx512>_vpermt2var<mode>3_maskz_1 (
17860         operands[0], operands[1], operands[2], operands[3],
17861         CONST0_RTX (<MODE>mode), operands[4]));
17862   DONE;
17865 (define_expand "<avx512>_vpermt2var<mode>3_maskz"
17866   [(match_operand:VI1_AVX512VL 0 "register_operand" "=v")
17867    (match_operand:<sseintvecmode> 1 "register_operand" "v")
17868    (match_operand:VI1_AVX512VL 2 "register_operand" "0")
17869    (match_operand:VI1_AVX512VL 3 "nonimmediate_operand" "vm")
17870    (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")]
17871   "TARGET_AVX512VBMI"
17873   emit_insn (gen_<avx512>_vpermt2var<mode>3_maskz_1 (
17874         operands[0], operands[1], operands[2], operands[3],
17875         CONST0_RTX (<MODE>mode), operands[4]));
17876   DONE;
17879 (define_expand "<avx512>_vpermt2var<mode>3_maskz"
17880   [(match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17881    (match_operand:<sseintvecmode> 1 "register_operand" "v")
17882    (match_operand:VI2_AVX512VL 2 "register_operand" "0")
17883    (match_operand:VI2_AVX512VL 3 "nonimmediate_operand" "vm")
17884    (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")]
17885   "TARGET_AVX512BW"
17887   emit_insn (gen_<avx512>_vpermt2var<mode>3_maskz_1 (
17888         operands[0], operands[1], operands[2], operands[3],
17889         CONST0_RTX (<MODE>mode), operands[4]));
17890   DONE;
17893 (define_insn "<avx512>_vpermt2var<mode>3<sd_maskz_name>"
17894   [(set (match_operand:VI48F 0 "register_operand" "=v")
17895         (unspec:VI48F
17896           [(match_operand:<sseintvecmode> 1 "register_operand" "v")
17897            (match_operand:VI48F 2 "register_operand" "0")
17898            (match_operand:VI48F 3 "nonimmediate_operand" "vm")]
17899           UNSPEC_VPERMT2))]
17900   "TARGET_AVX512F"
17901   "vpermt2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}"
17902   [(set_attr "type" "sselog")
17903    (set_attr "prefix" "evex")
17904    (set_attr "mode" "<sseinsnmode>")])
17906 (define_insn "<avx512>_vpermt2var<mode>3<sd_maskz_name>"
17907   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
17908         (unspec:VI1_AVX512VL
17909           [(match_operand:<sseintvecmode> 1 "register_operand" "v")
17910            (match_operand:VI1_AVX512VL 2 "register_operand" "0")
17911            (match_operand:VI1_AVX512VL 3 "nonimmediate_operand" "vm")]
17912           UNSPEC_VPERMT2))]
17913   "TARGET_AVX512VBMI"
17914   "vpermt2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}"
17915   [(set_attr "type" "sselog")
17916    (set_attr "prefix" "evex")
17917    (set_attr "mode" "<sseinsnmode>")])
17919 (define_insn "<avx512>_vpermt2var<mode>3<sd_maskz_name>"
17920   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17921         (unspec:VI2_AVX512VL
17922           [(match_operand:<sseintvecmode> 1 "register_operand" "v")
17923            (match_operand:VI2_AVX512VL 2 "register_operand" "0")
17924            (match_operand:VI2_AVX512VL 3 "nonimmediate_operand" "vm")]
17925           UNSPEC_VPERMT2))]
17926   "TARGET_AVX512BW"
17927   "vpermt2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}"
17928   [(set_attr "type" "sselog")
17929    (set_attr "prefix" "evex")
17930    (set_attr "mode" "<sseinsnmode>")])
17932 (define_insn "<avx512>_vpermt2var<mode>3_mask"
17933   [(set (match_operand:VI48F 0 "register_operand" "=v")
17934         (vec_merge:VI48F
17935           (unspec:VI48F
17936             [(match_operand:<sseintvecmode> 1 "register_operand" "v")
17937             (match_operand:VI48F 2 "register_operand" "0")
17938             (match_operand:VI48F 3 "nonimmediate_operand" "vm")]
17939             UNSPEC_VPERMT2)
17940           (match_dup 2)
17941           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
17942   "TARGET_AVX512F"
17943   "vpermt2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
17944   [(set_attr "type" "sselog")
17945    (set_attr "prefix" "evex")
17946    (set_attr "mode" "<sseinsnmode>")])
17948 (define_insn "<avx512>_vpermt2var<mode>3_mask"
17949   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
17950         (vec_merge:VI1_AVX512VL
17951           (unspec:VI1_AVX512VL
17952             [(match_operand:<sseintvecmode> 1 "register_operand" "v")
17953             (match_operand:VI1_AVX512VL 2 "register_operand" "0")
17954             (match_operand:VI1_AVX512VL 3 "nonimmediate_operand" "vm")]
17955             UNSPEC_VPERMT2)
17956           (match_dup 2)
17957           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
17958   "TARGET_AVX512VBMI"
17959   "vpermt2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
17960   [(set_attr "type" "sselog")
17961    (set_attr "prefix" "evex")
17962    (set_attr "mode" "<sseinsnmode>")])
17964 (define_insn "<avx512>_vpermt2var<mode>3_mask"
17965   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17966         (vec_merge:VI2_AVX512VL
17967           (unspec:VI2_AVX512VL
17968             [(match_operand:<sseintvecmode> 1 "register_operand" "v")
17969             (match_operand:VI2_AVX512VL 2 "register_operand" "0")
17970             (match_operand:VI2_AVX512VL 3 "nonimmediate_operand" "vm")]
17971             UNSPEC_VPERMT2)
17972           (match_dup 2)
17973           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
17974   "TARGET_AVX512BW"
17975   "vpermt2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
17976   [(set_attr "type" "sselog")
17977    (set_attr "prefix" "evex")
17978    (set_attr "mode" "<sseinsnmode>")])
17980 (define_expand "avx_vperm2f128<mode>3"
17981   [(set (match_operand:AVX256MODE2P 0 "register_operand")
17982         (unspec:AVX256MODE2P
17983           [(match_operand:AVX256MODE2P 1 "register_operand")
17984            (match_operand:AVX256MODE2P 2 "nonimmediate_operand")
17985            (match_operand:SI 3 "const_0_to_255_operand")]
17986           UNSPEC_VPERMIL2F128))]
17987   "TARGET_AVX"
17989   int mask = INTVAL (operands[3]);
17990   if ((mask & 0x88) == 0)
17991     {
17992       rtx perm[<ssescalarnum>], t1, t2;
17993       int i, base, nelt = <ssescalarnum>, nelt2 = nelt / 2;
17995       base = (mask & 3) * nelt2;
17996       for (i = 0; i < nelt2; ++i)
17997         perm[i] = GEN_INT (base + i);
17999       base = ((mask >> 4) & 3) * nelt2;
18000       for (i = 0; i < nelt2; ++i)
18001         perm[i + nelt2] = GEN_INT (base + i);
18003       t2 = gen_rtx_VEC_CONCAT (<ssedoublevecmode>mode,
18004                                operands[1], operands[2]);
18005       t1 = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (nelt, perm));
18006       t2 = gen_rtx_VEC_SELECT (<MODE>mode, t2, t1);
18007       t2 = gen_rtx_SET (operands[0], t2);
18008       emit_insn (t2);
18009       DONE;
18010     }
18013 ;; Note that bits 7 and 3 of the imm8 allow lanes to be zeroed, which
18014 ;; means that in order to represent this properly in rtl we'd have to
18015 ;; nest *another* vec_concat with a zero operand and do the select from
18016 ;; a 4x wide vector.  That doesn't seem very nice.
18017 (define_insn "*avx_vperm2f128<mode>_full"
18018   [(set (match_operand:AVX256MODE2P 0 "register_operand" "=x")
18019         (unspec:AVX256MODE2P
18020           [(match_operand:AVX256MODE2P 1 "register_operand" "x")
18021            (match_operand:AVX256MODE2P 2 "nonimmediate_operand" "xm")
18022            (match_operand:SI 3 "const_0_to_255_operand" "n")]
18023           UNSPEC_VPERMIL2F128))]
18024   "TARGET_AVX"
18025   "vperm2<i128>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
18026   [(set_attr "type" "sselog")
18027    (set_attr "prefix_extra" "1")
18028    (set_attr "length_immediate" "1")
18029    (set_attr "prefix" "vex")
18030    (set_attr "mode" "<sseinsnmode>")])
18032 (define_insn "*avx_vperm2f128<mode>_nozero"
18033   [(set (match_operand:AVX256MODE2P 0 "register_operand" "=x")
18034         (vec_select:AVX256MODE2P
18035           (vec_concat:<ssedoublevecmode>
18036             (match_operand:AVX256MODE2P 1 "register_operand" "x")
18037             (match_operand:AVX256MODE2P 2 "nonimmediate_operand" "xm"))
18038           (match_parallel 3 ""
18039             [(match_operand 4 "const_int_operand")])))]
18040   "TARGET_AVX
18041    && avx_vperm2f128_parallel (operands[3], <MODE>mode)"
18043   int mask = avx_vperm2f128_parallel (operands[3], <MODE>mode) - 1;
18044   if (mask == 0x12)
18045     return "vinsert<i128>\t{$0, %x2, %1, %0|%0, %1, %x2, 0}";
18046   if (mask == 0x20)
18047     return "vinsert<i128>\t{$1, %x2, %1, %0|%0, %1, %x2, 1}";
18048   operands[3] = GEN_INT (mask);
18049   return "vperm2<i128>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
18051   [(set_attr "type" "sselog")
18052    (set_attr "prefix_extra" "1")
18053    (set_attr "length_immediate" "1")
18054    (set_attr "prefix" "vex")
18055    (set_attr "mode" "<sseinsnmode>")])
18057 (define_insn "*ssse3_palignr<mode>_perm"
18058   [(set (match_operand:V_128 0 "register_operand" "=x,x")
18059       (vec_select:V_128
18060         (match_operand:V_128 1 "register_operand" "0,x")
18061         (match_parallel 2 "palignr_operand"
18062           [(match_operand 3 "const_int_operand" "n, n")])))]
18063   "TARGET_SSSE3"
18065   operands[2] =
18066    GEN_INT (INTVAL (operands[3]) * GET_MODE_UNIT_SIZE (GET_MODE (operands[0])));
18068   switch (which_alternative)
18069     {
18070     case 0:
18071       return "palignr\t{%2, %1, %0|%0, %1, %2}";
18072     case 1:
18073       return "vpalignr\t{%2, %1, %1, %0|%0, %1, %1, %2}";
18074     default:
18075       gcc_unreachable ();
18076     }
18078   [(set_attr "isa" "noavx,avx")
18079    (set_attr "type" "sseishft")
18080    (set_attr "atom_unit" "sishuf")
18081    (set_attr "prefix_data16" "1,*")
18082    (set_attr "prefix_extra" "1")
18083    (set_attr "length_immediate" "1")
18084    (set_attr "prefix" "orig,vex")])
18086 (define_expand "avx512vl_vinsert<mode>"
18087   [(match_operand:VI48F_256 0 "register_operand")
18088    (match_operand:VI48F_256 1 "register_operand")
18089    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
18090    (match_operand:SI 3 "const_0_to_1_operand")
18091    (match_operand:VI48F_256 4 "register_operand")
18092    (match_operand:<avx512fmaskmode> 5 "register_operand")]
18093   "TARGET_AVX512VL"
18095   rtx (*insn)(rtx, rtx, rtx, rtx, rtx);
18097   switch (INTVAL (operands[3]))
18098     {
18099     case 0:
18100       insn = gen_vec_set_lo_<mode>_mask;
18101       break;
18102     case 1:
18103       insn = gen_vec_set_hi_<mode>_mask;
18104       break;
18105     default:
18106       gcc_unreachable ();
18107     }
18109   emit_insn (insn (operands[0], operands[1], operands[2], operands[4],
18110                    operands[5]));
18111   DONE;
18114 (define_expand "avx_vinsertf128<mode>"
18115   [(match_operand:V_256 0 "register_operand")
18116    (match_operand:V_256 1 "register_operand")
18117    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
18118    (match_operand:SI 3 "const_0_to_1_operand")]
18119   "TARGET_AVX"
18121   rtx (*insn)(rtx, rtx, rtx);
18123   switch (INTVAL (operands[3]))
18124     {
18125     case 0:
18126       insn = gen_vec_set_lo_<mode>;
18127       break;
18128     case 1:
18129       insn = gen_vec_set_hi_<mode>;
18130       break;
18131     default:
18132       gcc_unreachable ();
18133     }
18135   emit_insn (insn (operands[0], operands[1], operands[2]));
18136   DONE;
18139 (define_insn "vec_set_lo_<mode><mask_name>"
18140   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
18141         (vec_concat:VI8F_256
18142           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
18143           (vec_select:<ssehalfvecmode>
18144             (match_operand:VI8F_256 1 "register_operand" "v")
18145             (parallel [(const_int 2) (const_int 3)]))))]
18146   "TARGET_AVX"
18148   if (TARGET_AVX512VL)
18149     return "vinsert<shuffletype>64x2\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
18150   else
18151     return "vinsert<i128>\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}";
18153   [(set_attr "type" "sselog")
18154    (set_attr "prefix_extra" "1")
18155    (set_attr "length_immediate" "1")
18156    (set_attr "prefix" "vex")
18157    (set_attr "mode" "<sseinsnmode>")])
18159 (define_insn "vec_set_hi_<mode><mask_name>"
18160   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
18161         (vec_concat:VI8F_256
18162           (vec_select:<ssehalfvecmode>
18163             (match_operand:VI8F_256 1 "register_operand" "v")
18164             (parallel [(const_int 0) (const_int 1)]))
18165           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
18166   "TARGET_AVX"
18168   if (TARGET_AVX512VL)
18169     return "vinsert<shuffletype>64x2\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
18170   else
18171     return "vinsert<i128>\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}";
18173   [(set_attr "type" "sselog")
18174    (set_attr "prefix_extra" "1")
18175    (set_attr "length_immediate" "1")
18176    (set_attr "prefix" "vex")
18177    (set_attr "mode" "<sseinsnmode>")])
18179 (define_insn "vec_set_lo_<mode><mask_name>"
18180   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
18181         (vec_concat:VI4F_256
18182           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
18183           (vec_select:<ssehalfvecmode>
18184             (match_operand:VI4F_256 1 "register_operand" "v")
18185             (parallel [(const_int 4) (const_int 5)
18186                        (const_int 6) (const_int 7)]))))]
18187   "TARGET_AVX"
18189   if (TARGET_AVX512VL)
18190     return "vinsert<shuffletype>32x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
18191   else
18192     return "vinsert<i128>\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}";
18194   [(set_attr "type" "sselog")
18195    (set_attr "prefix_extra" "1")
18196    (set_attr "length_immediate" "1")
18197    (set_attr "prefix" "vex")
18198    (set_attr "mode" "<sseinsnmode>")])
18200 (define_insn "vec_set_hi_<mode><mask_name>"
18201   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
18202         (vec_concat:VI4F_256
18203           (vec_select:<ssehalfvecmode>
18204             (match_operand:VI4F_256 1 "register_operand" "v")
18205             (parallel [(const_int 0) (const_int 1)
18206                        (const_int 2) (const_int 3)]))
18207           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
18208   "TARGET_AVX"
18210   if (TARGET_AVX512VL)
18211     return "vinsert<shuffletype>32x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
18212   else
18213     return "vinsert<i128>\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}";
18215   [(set_attr "type" "sselog")
18216    (set_attr "prefix_extra" "1")
18217    (set_attr "length_immediate" "1")
18218    (set_attr "prefix" "vex")
18219    (set_attr "mode" "<sseinsnmode>")])
18221 (define_insn "vec_set_lo_v16hi"
18222   [(set (match_operand:V16HI 0 "register_operand" "=x")
18223         (vec_concat:V16HI
18224           (match_operand:V8HI 2 "nonimmediate_operand" "xm")
18225           (vec_select:V8HI
18226             (match_operand:V16HI 1 "register_operand" "x")
18227             (parallel [(const_int 8) (const_int 9)
18228                        (const_int 10) (const_int 11)
18229                        (const_int 12) (const_int 13)
18230                        (const_int 14) (const_int 15)]))))]
18231   "TARGET_AVX"
18232   "vinsert%~128\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}"
18233   [(set_attr "type" "sselog")
18234    (set_attr "prefix_extra" "1")
18235    (set_attr "length_immediate" "1")
18236    (set_attr "prefix" "vex")
18237    (set_attr "mode" "OI")])
18239 (define_insn "vec_set_hi_v16hi"
18240   [(set (match_operand:V16HI 0 "register_operand" "=x")
18241         (vec_concat:V16HI
18242           (vec_select:V8HI
18243             (match_operand:V16HI 1 "register_operand" "x")
18244             (parallel [(const_int 0) (const_int 1)
18245                        (const_int 2) (const_int 3)
18246                        (const_int 4) (const_int 5)
18247                        (const_int 6) (const_int 7)]))
18248           (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
18249   "TARGET_AVX"
18250   "vinsert%~128\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}"
18251   [(set_attr "type" "sselog")
18252    (set_attr "prefix_extra" "1")
18253    (set_attr "length_immediate" "1")
18254    (set_attr "prefix" "vex")
18255    (set_attr "mode" "OI")])
18257 (define_insn "vec_set_lo_v32qi"
18258   [(set (match_operand:V32QI 0 "register_operand" "=x")
18259         (vec_concat:V32QI
18260           (match_operand:V16QI 2 "nonimmediate_operand" "xm")
18261           (vec_select:V16QI
18262             (match_operand:V32QI 1 "register_operand" "x")
18263             (parallel [(const_int 16) (const_int 17)
18264                        (const_int 18) (const_int 19)
18265                        (const_int 20) (const_int 21)
18266                        (const_int 22) (const_int 23)
18267                        (const_int 24) (const_int 25)
18268                        (const_int 26) (const_int 27)
18269                        (const_int 28) (const_int 29)
18270                        (const_int 30) (const_int 31)]))))]
18271   "TARGET_AVX"
18272   "vinsert%~128\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}"
18273   [(set_attr "type" "sselog")
18274    (set_attr "prefix_extra" "1")
18275    (set_attr "length_immediate" "1")
18276    (set_attr "prefix" "vex")
18277    (set_attr "mode" "OI")])
18279 (define_insn "vec_set_hi_v32qi"
18280   [(set (match_operand:V32QI 0 "register_operand" "=x")
18281         (vec_concat:V32QI
18282           (vec_select:V16QI
18283             (match_operand:V32QI 1 "register_operand" "x")
18284             (parallel [(const_int 0) (const_int 1)
18285                        (const_int 2) (const_int 3)
18286                        (const_int 4) (const_int 5)
18287                        (const_int 6) (const_int 7)
18288                        (const_int 8) (const_int 9)
18289                        (const_int 10) (const_int 11)
18290                        (const_int 12) (const_int 13)
18291                        (const_int 14) (const_int 15)]))
18292           (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
18293   "TARGET_AVX"
18294   "vinsert%~128\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}"
18295   [(set_attr "type" "sselog")
18296    (set_attr "prefix_extra" "1")
18297    (set_attr "length_immediate" "1")
18298    (set_attr "prefix" "vex")
18299    (set_attr "mode" "OI")])
18301 (define_insn "<avx_avx2>_maskload<ssemodesuffix><avxsizesuffix>"
18302   [(set (match_operand:V48_AVX2 0 "register_operand" "=x")
18303         (unspec:V48_AVX2
18304           [(match_operand:<sseintvecmode> 2 "register_operand" "x")
18305            (match_operand:V48_AVX2 1 "memory_operand" "m")]
18306           UNSPEC_MASKMOV))]
18307   "TARGET_AVX"
18308   "v<sseintprefix>maskmov<ssemodesuffix>\t{%1, %2, %0|%0, %2, %1}"
18309   [(set_attr "type" "sselog1")
18310    (set_attr "prefix_extra" "1")
18311    (set_attr "prefix" "vex")
18312    (set_attr "btver2_decode" "vector")
18313    (set_attr "mode" "<sseinsnmode>")])
18315 (define_insn "<avx_avx2>_maskstore<ssemodesuffix><avxsizesuffix>"
18316   [(set (match_operand:V48_AVX2 0 "memory_operand" "+m")
18317         (unspec:V48_AVX2
18318           [(match_operand:<sseintvecmode> 1 "register_operand" "x")
18319            (match_operand:V48_AVX2 2 "register_operand" "x")
18320            (match_dup 0)]
18321           UNSPEC_MASKMOV))]
18322   "TARGET_AVX"
18323   "v<sseintprefix>maskmov<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
18324   [(set_attr "type" "sselog1")
18325    (set_attr "prefix_extra" "1")
18326    (set_attr "prefix" "vex")
18327    (set_attr "btver2_decode" "vector") 
18328    (set_attr "mode" "<sseinsnmode>")])
18330 (define_expand "maskload<mode><sseintvecmodelower>"
18331   [(set (match_operand:V48_AVX2 0 "register_operand")
18332         (unspec:V48_AVX2
18333           [(match_operand:<sseintvecmode> 2 "register_operand")
18334            (match_operand:V48_AVX2 1 "memory_operand")]
18335           UNSPEC_MASKMOV))]
18336   "TARGET_AVX")
18338 (define_expand "maskload<mode><avx512fmaskmodelower>"
18339   [(set (match_operand:V48_AVX512VL 0 "register_operand")
18340         (vec_merge:V48_AVX512VL
18341           (match_operand:V48_AVX512VL 1 "memory_operand")
18342           (match_dup 0)
18343           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18344   "TARGET_AVX512F")
18346 (define_expand "maskload<mode><avx512fmaskmodelower>"
18347   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
18348         (vec_merge:VI12_AVX512VL
18349           (match_operand:VI12_AVX512VL 1 "memory_operand")
18350           (match_dup 0)
18351           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18352   "TARGET_AVX512BW")
18354 (define_expand "maskstore<mode><sseintvecmodelower>"
18355   [(set (match_operand:V48_AVX2 0 "memory_operand")
18356         (unspec:V48_AVX2
18357           [(match_operand:<sseintvecmode> 2 "register_operand")
18358            (match_operand:V48_AVX2 1 "register_operand")
18359            (match_dup 0)]
18360           UNSPEC_MASKMOV))]
18361   "TARGET_AVX")
18363 (define_expand "maskstore<mode><avx512fmaskmodelower>"
18364   [(set (match_operand:V48_AVX512VL 0 "memory_operand")
18365         (vec_merge:V48_AVX512VL
18366           (match_operand:V48_AVX512VL 1 "register_operand")
18367           (match_dup 0)
18368           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18369   "TARGET_AVX512F")
18371 (define_expand "maskstore<mode><avx512fmaskmodelower>"
18372   [(set (match_operand:VI12_AVX512VL 0 "memory_operand")
18373         (vec_merge:VI12_AVX512VL
18374           (match_operand:VI12_AVX512VL 1 "register_operand")
18375           (match_dup 0)
18376           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18377   "TARGET_AVX512BW")
18379 (define_expand "cbranch<mode>4"
18380   [(set (reg:CC FLAGS_REG)
18381         (compare:CC (match_operand:VI48_AVX 1 "register_operand")
18382                     (match_operand:VI48_AVX 2 "nonimmediate_operand")))
18383    (set (pc) (if_then_else
18384                (match_operator 0 "bt_comparison_operator"
18385                 [(reg:CC FLAGS_REG) (const_int 0)])
18386                (label_ref (match_operand 3))
18387                (pc)))]
18388   "TARGET_SSE4_1"
18390   ix86_expand_branch (GET_CODE (operands[0]),
18391                       operands[1], operands[2], operands[3]);
18392   DONE;
18396 (define_insn_and_split "avx_<castmode><avxsizesuffix>_<castmode>"
18397   [(set (match_operand:AVX256MODE2P 0 "nonimmediate_operand" "=x,m")
18398         (unspec:AVX256MODE2P
18399           [(match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "xm,x")]
18400           UNSPEC_CAST))]
18401   "TARGET_AVX"
18402   "#"
18403   "&& reload_completed"
18404   [(const_int 0)]
18406   rtx op0 = operands[0];
18407   rtx op1 = operands[1];
18408   if (REG_P (op0))
18409     op0 = gen_rtx_REG (<ssehalfvecmode>mode, REGNO (op0));
18410   else
18411     op1 = gen_rtx_REG (<MODE>mode, REGNO (op1));
18412   emit_move_insn (op0, op1);
18413   DONE;
18416 (define_expand "vec_init<mode>"
18417   [(match_operand:V_256 0 "register_operand")
18418    (match_operand 1)]
18419   "TARGET_AVX"
18421   ix86_expand_vector_init (false, operands[0], operands[1]);
18422   DONE;
18425 (define_expand "vec_init<mode>"
18426   [(match_operand:VF48_I1248 0 "register_operand")
18427    (match_operand 1)]
18428   "TARGET_AVX512F"
18430   ix86_expand_vector_init (false, operands[0], operands[1]);
18431   DONE;
18434 (define_insn "<avx2_avx512>_ashrv<mode><mask_name>"
18435   [(set (match_operand:VI48_AVX512F_AVX512VL 0 "register_operand" "=v")
18436         (ashiftrt:VI48_AVX512F_AVX512VL
18437           (match_operand:VI48_AVX512F_AVX512VL 1 "register_operand" "v")
18438           (match_operand:VI48_AVX512F_AVX512VL 2 "nonimmediate_operand" "vm")))]
18439   "TARGET_AVX2 && <mask_mode512bit_condition>"
18440   "vpsrav<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18441   [(set_attr "type" "sseishft")
18442    (set_attr "prefix" "maybe_evex")
18443    (set_attr "mode" "<sseinsnmode>")])
18445 (define_insn "<avx2_avx512>_ashrv<mode><mask_name>"
18446   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
18447         (ashiftrt:VI2_AVX512VL
18448           (match_operand:VI2_AVX512VL 1 "register_operand" "v")
18449           (match_operand:VI2_AVX512VL 2 "nonimmediate_operand" "vm")))]
18450   "TARGET_AVX512BW"
18451   "vpsravw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18452   [(set_attr "type" "sseishft")
18453    (set_attr "prefix" "maybe_evex")
18454    (set_attr "mode" "<sseinsnmode>")])
18456 (define_insn "<avx2_avx512>_<shift_insn>v<mode><mask_name>"
18457   [(set (match_operand:VI48_AVX512F 0 "register_operand" "=v")
18458         (any_lshift:VI48_AVX512F
18459           (match_operand:VI48_AVX512F 1 "register_operand" "v")
18460           (match_operand:VI48_AVX512F 2 "nonimmediate_operand" "vm")))]
18461   "TARGET_AVX2 && <mask_mode512bit_condition>"
18462   "vp<vshift>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18463   [(set_attr "type" "sseishft")
18464    (set_attr "prefix" "maybe_evex")
18465    (set_attr "mode" "<sseinsnmode>")])
18467 (define_insn "<avx2_avx512>_<shift_insn>v<mode><mask_name>"
18468   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
18469         (any_lshift:VI2_AVX512VL
18470           (match_operand:VI2_AVX512VL 1 "register_operand" "v")
18471           (match_operand:VI2_AVX512VL 2 "nonimmediate_operand" "vm")))]
18472   "TARGET_AVX512BW"
18473   "vp<vshift>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18474   [(set_attr "type" "sseishft")
18475    (set_attr "prefix" "maybe_evex")
18476    (set_attr "mode" "<sseinsnmode>")])
18478 (define_insn "avx_vec_concat<mode>"
18479   [(set (match_operand:V_256_512 0 "register_operand" "=x,x")
18480         (vec_concat:V_256_512
18481           (match_operand:<ssehalfvecmode> 1 "register_operand" "x,x")
18482           (match_operand:<ssehalfvecmode> 2 "vector_move_operand" "xm,C")))]
18483   "TARGET_AVX"
18485   switch (which_alternative)
18486     {
18487     case 0:
18488       return "vinsert<i128>\t{$0x1, %2, %<concat_tg_mode>1, %0|%0, %<concat_tg_mode>1, %2, 0x1}";
18489     case 1:
18490       switch (get_attr_mode (insn))
18491         {
18492         case MODE_V16SF:
18493           return "vmovaps\t{%1, %t0|%t0, %1}";
18494         case MODE_V8DF:
18495           return "vmovapd\t{%1, %t0|%t0, %1}";
18496         case MODE_V8SF:
18497           return "vmovaps\t{%1, %x0|%x0, %1}";
18498         case MODE_V4DF:
18499           return "vmovapd\t{%1, %x0|%x0, %1}";
18500         case MODE_XI:
18501           return "vmovdqa\t{%1, %t0|%t0, %1}";
18502         case MODE_OI:
18503           return "vmovdqa\t{%1, %x0|%x0, %1}";
18504         default:
18505           gcc_unreachable ();
18506         }
18507     default:
18508       gcc_unreachable ();
18509     }
18511   [(set_attr "type" "sselog,ssemov")
18512    (set_attr "prefix_extra" "1,*")
18513    (set_attr "length_immediate" "1,*")
18514    (set_attr "prefix" "maybe_evex")
18515    (set_attr "mode" "<sseinsnmode>")])
18517 (define_insn "vcvtph2ps<mask_name>"
18518   [(set (match_operand:V4SF 0 "register_operand" "=v")
18519         (vec_select:V4SF
18520           (unspec:V8SF [(match_operand:V8HI 1 "register_operand" "v")]
18521                        UNSPEC_VCVTPH2PS)
18522           (parallel [(const_int 0) (const_int 1)
18523                      (const_int 2) (const_int 3)])))]
18524   "TARGET_F16C || TARGET_AVX512VL"
18525   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18526   [(set_attr "type" "ssecvt")
18527    (set_attr "prefix" "maybe_evex")
18528    (set_attr "mode" "V4SF")])
18530 (define_insn "*vcvtph2ps_load<mask_name>"
18531   [(set (match_operand:V4SF 0 "register_operand" "=v")
18532         (unspec:V4SF [(match_operand:V4HI 1 "memory_operand" "m")]
18533                      UNSPEC_VCVTPH2PS))]
18534   "TARGET_F16C || TARGET_AVX512VL"
18535   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18536   [(set_attr "type" "ssecvt")
18537    (set_attr "prefix" "vex")
18538    (set_attr "mode" "V8SF")])
18540 (define_insn "vcvtph2ps256<mask_name>"
18541   [(set (match_operand:V8SF 0 "register_operand" "=v")
18542         (unspec:V8SF [(match_operand:V8HI 1 "nonimmediate_operand" "vm")]
18543                      UNSPEC_VCVTPH2PS))]
18544   "TARGET_F16C || TARGET_AVX512VL"
18545   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18546   [(set_attr "type" "ssecvt")
18547    (set_attr "prefix" "vex")
18548    (set_attr "btver2_decode" "double")
18549    (set_attr "mode" "V8SF")])
18551 (define_insn "<mask_codefor>avx512f_vcvtph2ps512<mask_name><round_saeonly_name>"
18552   [(set (match_operand:V16SF 0 "register_operand" "=v")
18553         (unspec:V16SF
18554           [(match_operand:V16HI 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
18555           UNSPEC_VCVTPH2PS))]
18556   "TARGET_AVX512F"
18557   "vcvtph2ps\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
18558   [(set_attr "type" "ssecvt")
18559    (set_attr "prefix" "evex")
18560    (set_attr "mode" "V16SF")])
18562 (define_expand "vcvtps2ph_mask"
18563   [(set (match_operand:V8HI 0 "register_operand")
18564         (vec_merge:V8HI
18565           (vec_concat:V8HI
18566             (unspec:V4HI [(match_operand:V4SF 1 "register_operand")
18567                           (match_operand:SI 2 "const_0_to_255_operand")]
18568                           UNSPEC_VCVTPS2PH)
18569             (match_dup 5))
18570            (match_operand:V8HI 3 "vector_move_operand")
18571            (match_operand:QI 4 "register_operand")))]
18572   "TARGET_AVX512VL"
18573   "operands[5] = CONST0_RTX (V4HImode);")
18575 (define_expand "vcvtps2ph"
18576   [(set (match_operand:V8HI 0 "register_operand")
18577         (vec_concat:V8HI
18578           (unspec:V4HI [(match_operand:V4SF 1 "register_operand")
18579                         (match_operand:SI 2 "const_0_to_255_operand")]
18580                        UNSPEC_VCVTPS2PH)
18581           (match_dup 3)))]
18582   "TARGET_F16C"
18583   "operands[3] = CONST0_RTX (V4HImode);")
18585 (define_insn "*vcvtps2ph<mask_name>"
18586   [(set (match_operand:V8HI 0 "register_operand" "=v")
18587         (vec_concat:V8HI
18588           (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "v")
18589                         (match_operand:SI 2 "const_0_to_255_operand" "N")]
18590                        UNSPEC_VCVTPS2PH)
18591           (match_operand:V4HI 3 "const0_operand")))]
18592   "(TARGET_F16C || TARGET_AVX512VL) && <mask_avx512vl_condition>"
18593   "vcvtps2ph\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}"
18594   [(set_attr "type" "ssecvt")
18595    (set_attr "prefix" "maybe_evex")
18596    (set_attr "mode" "V4SF")])
18598 (define_insn "*vcvtps2ph_store<mask_name>"
18599   [(set (match_operand:V4HI 0 "memory_operand" "=m")
18600         (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "x")
18601                       (match_operand:SI 2 "const_0_to_255_operand" "N")]
18602                      UNSPEC_VCVTPS2PH))]
18603   "TARGET_F16C || TARGET_AVX512VL"
18604   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18605   [(set_attr "type" "ssecvt")
18606    (set_attr "prefix" "maybe_evex")
18607    (set_attr "mode" "V4SF")])
18609 (define_insn "vcvtps2ph256<mask_name>"
18610   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=xm")
18611         (unspec:V8HI [(match_operand:V8SF 1 "register_operand" "x")
18612                       (match_operand:SI 2 "const_0_to_255_operand" "N")]
18613                      UNSPEC_VCVTPS2PH))]
18614   "TARGET_F16C || TARGET_AVX512VL"
18615   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18616   [(set_attr "type" "ssecvt")
18617    (set_attr "prefix" "maybe_evex")
18618    (set_attr "btver2_decode" "vector")
18619    (set_attr "mode" "V8SF")])
18621 (define_insn "<mask_codefor>avx512f_vcvtps2ph512<mask_name>"
18622   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=vm")
18623         (unspec:V16HI
18624           [(match_operand:V16SF 1 "register_operand" "v")
18625            (match_operand:SI 2 "const_0_to_255_operand" "N")]
18626           UNSPEC_VCVTPS2PH))]
18627   "TARGET_AVX512F"
18628   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18629   [(set_attr "type" "ssecvt")
18630    (set_attr "prefix" "evex")
18631    (set_attr "mode" "V16SF")])
18633 ;; For gather* insn patterns
18634 (define_mode_iterator VEC_GATHER_MODE
18635                       [V2DI V2DF V4DI V4DF V4SI V4SF V8SI V8SF])
18636 (define_mode_attr VEC_GATHER_IDXSI
18637                       [(V2DI "V4SI") (V4DI "V4SI") (V8DI "V8SI")
18638                        (V2DF "V4SI") (V4DF "V4SI") (V8DF "V8SI")
18639                        (V4SI "V4SI") (V8SI "V8SI") (V16SI "V16SI")
18640                        (V4SF "V4SI") (V8SF "V8SI") (V16SF "V16SI")])
18642 (define_mode_attr VEC_GATHER_IDXDI
18643                       [(V2DI "V2DI") (V4DI "V4DI") (V8DI "V8DI")
18644                        (V2DF "V2DI") (V4DF "V4DI") (V8DF "V8DI")
18645                        (V4SI "V2DI") (V8SI "V4DI") (V16SI "V8DI")
18646                        (V4SF "V2DI") (V8SF "V4DI") (V16SF "V8DI")])
18648 (define_mode_attr VEC_GATHER_SRCDI
18649                       [(V2DI "V2DI") (V4DI "V4DI") (V8DI "V8DI")
18650                        (V2DF "V2DF") (V4DF "V4DF") (V8DF "V8DF")
18651                        (V4SI "V4SI") (V8SI "V4SI") (V16SI "V8SI")
18652                        (V4SF "V4SF") (V8SF "V4SF") (V16SF "V8SF")])
18654 (define_expand "avx2_gathersi<mode>"
18655   [(parallel [(set (match_operand:VEC_GATHER_MODE 0 "register_operand")
18656                    (unspec:VEC_GATHER_MODE
18657                      [(match_operand:VEC_GATHER_MODE 1 "register_operand")
18658                       (mem:<ssescalarmode>
18659                         (match_par_dup 7
18660                           [(match_operand 2 "vsib_address_operand")
18661                            (match_operand:<VEC_GATHER_IDXSI>
18662                               3 "register_operand")
18663                            (match_operand:SI 5 "const1248_operand ")]))
18664                       (mem:BLK (scratch))
18665                       (match_operand:VEC_GATHER_MODE 4 "register_operand")]
18666                      UNSPEC_GATHER))
18667               (clobber (match_scratch:VEC_GATHER_MODE 6))])]
18668   "TARGET_AVX2"
18670   operands[7]
18671     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
18672                                         operands[5]), UNSPEC_VSIBADDR);
18675 (define_insn "*avx2_gathersi<mode>"
18676   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
18677         (unspec:VEC_GATHER_MODE
18678           [(match_operand:VEC_GATHER_MODE 2 "register_operand" "0")
18679            (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
18680              [(unspec:P
18681                 [(match_operand:P 3 "vsib_address_operand" "Tv")
18682                  (match_operand:<VEC_GATHER_IDXSI> 4 "register_operand" "x")
18683                  (match_operand:SI 6 "const1248_operand" "n")]
18684                 UNSPEC_VSIBADDR)])
18685            (mem:BLK (scratch))
18686            (match_operand:VEC_GATHER_MODE 5 "register_operand" "1")]
18687           UNSPEC_GATHER))
18688    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
18689   "TARGET_AVX2"
18690   "v<sseintprefix>gatherd<ssemodesuffix>\t{%1, %7, %0|%0, %7, %1}"
18691   [(set_attr "type" "ssemov")
18692    (set_attr "prefix" "vex")
18693    (set_attr "mode" "<sseinsnmode>")])
18695 (define_insn "*avx2_gathersi<mode>_2"
18696   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
18697         (unspec:VEC_GATHER_MODE
18698           [(pc)
18699            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
18700              [(unspec:P
18701                 [(match_operand:P 2 "vsib_address_operand" "Tv")
18702                  (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand" "x")
18703                  (match_operand:SI 5 "const1248_operand" "n")]
18704                 UNSPEC_VSIBADDR)])
18705            (mem:BLK (scratch))
18706            (match_operand:VEC_GATHER_MODE 4 "register_operand" "1")]
18707           UNSPEC_GATHER))
18708    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
18709   "TARGET_AVX2"
18710   "v<sseintprefix>gatherd<ssemodesuffix>\t{%1, %6, %0|%0, %6, %1}"
18711   [(set_attr "type" "ssemov")
18712    (set_attr "prefix" "vex")
18713    (set_attr "mode" "<sseinsnmode>")])
18715 (define_expand "avx2_gatherdi<mode>"
18716   [(parallel [(set (match_operand:VEC_GATHER_MODE 0 "register_operand")
18717                    (unspec:VEC_GATHER_MODE
18718                      [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand")
18719                       (mem:<ssescalarmode>
18720                         (match_par_dup 7
18721                           [(match_operand 2 "vsib_address_operand")
18722                            (match_operand:<VEC_GATHER_IDXDI>
18723                               3 "register_operand")
18724                            (match_operand:SI 5 "const1248_operand ")]))
18725                       (mem:BLK (scratch))
18726                       (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand")]
18727                      UNSPEC_GATHER))
18728               (clobber (match_scratch:VEC_GATHER_MODE 6))])]
18729   "TARGET_AVX2"
18731   operands[7]
18732     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
18733                                         operands[5]), UNSPEC_VSIBADDR);
18736 (define_insn "*avx2_gatherdi<mode>"
18737   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
18738         (unspec:VEC_GATHER_MODE
18739           [(match_operand:<VEC_GATHER_SRCDI> 2 "register_operand" "0")
18740            (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
18741              [(unspec:P
18742                 [(match_operand:P 3 "vsib_address_operand" "Tv")
18743                  (match_operand:<VEC_GATHER_IDXDI> 4 "register_operand" "x")
18744                  (match_operand:SI 6 "const1248_operand" "n")]
18745                 UNSPEC_VSIBADDR)])
18746            (mem:BLK (scratch))
18747            (match_operand:<VEC_GATHER_SRCDI> 5 "register_operand" "1")]
18748           UNSPEC_GATHER))
18749    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
18750   "TARGET_AVX2"
18751   "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %7, %2|%2, %7, %5}"
18752   [(set_attr "type" "ssemov")
18753    (set_attr "prefix" "vex")
18754    (set_attr "mode" "<sseinsnmode>")])
18756 (define_insn "*avx2_gatherdi<mode>_2"
18757   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
18758         (unspec:VEC_GATHER_MODE
18759           [(pc)
18760            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
18761              [(unspec:P
18762                 [(match_operand:P 2 "vsib_address_operand" "Tv")
18763                  (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "x")
18764                  (match_operand:SI 5 "const1248_operand" "n")]
18765                 UNSPEC_VSIBADDR)])
18766            (mem:BLK (scratch))
18767            (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand" "1")]
18768           UNSPEC_GATHER))
18769    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
18770   "TARGET_AVX2"
18772   if (<MODE>mode != <VEC_GATHER_SRCDI>mode)
18773     return "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %x0|%x0, %6, %4}";
18774   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %0|%0, %6, %4}";
18776   [(set_attr "type" "ssemov")
18777    (set_attr "prefix" "vex")
18778    (set_attr "mode" "<sseinsnmode>")])
18780 (define_insn "*avx2_gatherdi<mode>_3"
18781   [(set (match_operand:<VEC_GATHER_SRCDI> 0 "register_operand" "=&x")
18782         (vec_select:<VEC_GATHER_SRCDI>
18783           (unspec:VI4F_256
18784             [(match_operand:<VEC_GATHER_SRCDI> 2 "register_operand" "0")
18785              (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
18786                [(unspec:P
18787                   [(match_operand:P 3 "vsib_address_operand" "Tv")
18788                    (match_operand:<VEC_GATHER_IDXDI> 4 "register_operand" "x")
18789                    (match_operand:SI 6 "const1248_operand" "n")]
18790                   UNSPEC_VSIBADDR)])
18791              (mem:BLK (scratch))
18792              (match_operand:<VEC_GATHER_SRCDI> 5 "register_operand" "1")]
18793              UNSPEC_GATHER)
18794           (parallel [(const_int 0) (const_int 1)
18795                      (const_int 2) (const_int 3)])))
18796    (clobber (match_scratch:VI4F_256 1 "=&x"))]
18797   "TARGET_AVX2"
18798   "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %7, %0|%0, %7, %5}"
18799   [(set_attr "type" "ssemov")
18800    (set_attr "prefix" "vex")
18801    (set_attr "mode" "<sseinsnmode>")])
18803 (define_insn "*avx2_gatherdi<mode>_4"
18804   [(set (match_operand:<VEC_GATHER_SRCDI> 0 "register_operand" "=&x")
18805         (vec_select:<VEC_GATHER_SRCDI>
18806           (unspec:VI4F_256
18807             [(pc)
18808              (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
18809                [(unspec:P
18810                   [(match_operand:P 2 "vsib_address_operand" "Tv")
18811                    (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "x")
18812                    (match_operand:SI 5 "const1248_operand" "n")]
18813                   UNSPEC_VSIBADDR)])
18814              (mem:BLK (scratch))
18815              (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand" "1")]
18816             UNSPEC_GATHER)
18817           (parallel [(const_int 0) (const_int 1)
18818                      (const_int 2) (const_int 3)])))
18819    (clobber (match_scratch:VI4F_256 1 "=&x"))]
18820   "TARGET_AVX2"
18821   "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %0|%0, %6, %4}"
18822   [(set_attr "type" "ssemov")
18823    (set_attr "prefix" "vex")
18824    (set_attr "mode" "<sseinsnmode>")])
18826 (define_expand "<avx512>_gathersi<mode>"
18827   [(parallel [(set (match_operand:VI48F 0 "register_operand")
18828                    (unspec:VI48F
18829                      [(match_operand:VI48F 1 "register_operand")
18830                       (match_operand:<avx512fmaskmode> 4 "register_operand")
18831                       (mem:<ssescalarmode>
18832                         (match_par_dup 6
18833                           [(match_operand 2 "vsib_address_operand")
18834                            (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand")
18835                            (match_operand:SI 5 "const1248_operand")]))]
18836                      UNSPEC_GATHER))
18837               (clobber (match_scratch:<avx512fmaskmode> 7))])]
18838   "TARGET_AVX512F"
18840   operands[6]
18841     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
18842                                         operands[5]), UNSPEC_VSIBADDR);
18845 (define_insn "*avx512f_gathersi<mode>"
18846   [(set (match_operand:VI48F 0 "register_operand" "=&v")
18847         (unspec:VI48F
18848           [(match_operand:VI48F 1 "register_operand" "0")
18849            (match_operand:<avx512fmaskmode> 7 "register_operand" "2")
18850            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
18851              [(unspec:P
18852                 [(match_operand:P 4 "vsib_address_operand" "Tv")
18853                  (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand" "v")
18854                  (match_operand:SI 5 "const1248_operand" "n")]
18855                 UNSPEC_VSIBADDR)])]
18856           UNSPEC_GATHER))
18857    (clobber (match_scratch:<avx512fmaskmode> 2 "=&Yk"))]
18858   "TARGET_AVX512F"
18859   "v<sseintprefix>gatherd<ssemodesuffix>\t{%6, %0%{%2%}|%0%{%2%}, %g6}"
18860   [(set_attr "type" "ssemov")
18861    (set_attr "prefix" "evex")
18862    (set_attr "mode" "<sseinsnmode>")])
18864 (define_insn "*avx512f_gathersi<mode>_2"
18865   [(set (match_operand:VI48F 0 "register_operand" "=&v")
18866         (unspec:VI48F
18867           [(pc)
18868            (match_operand:<avx512fmaskmode> 6 "register_operand" "1")
18869            (match_operator:<ssescalarmode> 5 "vsib_mem_operator"
18870              [(unspec:P
18871                 [(match_operand:P 3 "vsib_address_operand" "Tv")
18872                  (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand" "v")
18873                  (match_operand:SI 4 "const1248_operand" "n")]
18874                 UNSPEC_VSIBADDR)])]
18875           UNSPEC_GATHER))
18876    (clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
18877   "TARGET_AVX512F"
18878   "v<sseintprefix>gatherd<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %g5}"
18879   [(set_attr "type" "ssemov")
18880    (set_attr "prefix" "evex")
18881    (set_attr "mode" "<sseinsnmode>")])
18884 (define_expand "<avx512>_gatherdi<mode>"
18885   [(parallel [(set (match_operand:VI48F 0 "register_operand")
18886                    (unspec:VI48F
18887                      [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand")
18888                       (match_operand:QI 4 "register_operand")
18889                       (mem:<ssescalarmode>
18890                         (match_par_dup 6
18891                           [(match_operand 2 "vsib_address_operand")
18892                            (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand")
18893                            (match_operand:SI 5 "const1248_operand")]))]
18894                      UNSPEC_GATHER))
18895               (clobber (match_scratch:QI 7))])]
18896   "TARGET_AVX512F"
18898   operands[6]
18899     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
18900                                         operands[5]), UNSPEC_VSIBADDR);
18903 (define_insn "*avx512f_gatherdi<mode>"
18904   [(set (match_operand:VI48F 0 "register_operand" "=&v")
18905         (unspec:VI48F
18906           [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand" "0")
18907            (match_operand:QI 7 "register_operand" "2")
18908            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
18909              [(unspec:P
18910                 [(match_operand:P 4 "vsib_address_operand" "Tv")
18911                  (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "v")
18912                  (match_operand:SI 5 "const1248_operand" "n")]
18913                 UNSPEC_VSIBADDR)])]
18914           UNSPEC_GATHER))
18915    (clobber (match_scratch:QI 2 "=&Yk"))]
18916   "TARGET_AVX512F"
18917   "v<sseintprefix>gatherq<ssemodesuffix>\t{%6, %1%{%2%}|%1%{%2%}, %g6}"
18918   [(set_attr "type" "ssemov")
18919    (set_attr "prefix" "evex")
18920    (set_attr "mode" "<sseinsnmode>")])
18922 (define_insn "*avx512f_gatherdi<mode>_2"
18923   [(set (match_operand:VI48F 0 "register_operand" "=&v")
18924         (unspec:VI48F
18925           [(pc)
18926            (match_operand:QI 6 "register_operand" "1")
18927            (match_operator:<ssescalarmode> 5 "vsib_mem_operator"
18928              [(unspec:P
18929                 [(match_operand:P 3 "vsib_address_operand" "Tv")
18930                  (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand" "v")
18931                  (match_operand:SI 4 "const1248_operand" "n")]
18932                 UNSPEC_VSIBADDR)])]
18933           UNSPEC_GATHER))
18934    (clobber (match_scratch:QI 1 "=&Yk"))]
18935   "TARGET_AVX512F"
18937   if (<MODE>mode != <VEC_GATHER_SRCDI>mode)
18938     {
18939       if (<MODE_SIZE> != 64)
18940         return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %x0%{%1%}|%t0%{%1%}, %g5}";
18941       else
18942         return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %t0%{%1%}|%t0%{%1%}, %g5}";
18943     }
18944   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %g5}";
18946   [(set_attr "type" "ssemov")
18947    (set_attr "prefix" "evex")
18948    (set_attr "mode" "<sseinsnmode>")])
18950 (define_expand "<avx512>_scattersi<mode>"
18951   [(parallel [(set (mem:VI48F
18952                      (match_par_dup 5
18953                        [(match_operand 0 "vsib_address_operand")
18954                         (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand")
18955                         (match_operand:SI 4 "const1248_operand")]))
18956                    (unspec:VI48F
18957                      [(match_operand:<avx512fmaskmode> 1 "register_operand")
18958                       (match_operand:VI48F 3 "register_operand")]
18959                      UNSPEC_SCATTER))
18960               (clobber (match_scratch:<avx512fmaskmode> 6))])]
18961   "TARGET_AVX512F"
18963   operands[5]
18964     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[0], operands[2],
18965                                         operands[4]), UNSPEC_VSIBADDR);
18968 (define_insn "*avx512f_scattersi<mode>"
18969   [(set (match_operator:VI48F 5 "vsib_mem_operator"
18970           [(unspec:P
18971              [(match_operand:P 0 "vsib_address_operand" "Tv")
18972               (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand" "v")
18973               (match_operand:SI 4 "const1248_operand" "n")]
18974              UNSPEC_VSIBADDR)])
18975         (unspec:VI48F
18976           [(match_operand:<avx512fmaskmode> 6 "register_operand" "1")
18977            (match_operand:VI48F 3 "register_operand" "v")]
18978           UNSPEC_SCATTER))
18979    (clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
18980   "TARGET_AVX512F"
18981   "v<sseintprefix>scatterd<ssemodesuffix>\t{%3, %5%{%1%}|%5%{%1%}, %3}"
18982   [(set_attr "type" "ssemov")
18983    (set_attr "prefix" "evex")
18984    (set_attr "mode" "<sseinsnmode>")])
18986 (define_expand "<avx512>_scatterdi<mode>"
18987   [(parallel [(set (mem:VI48F
18988                      (match_par_dup 5
18989                        [(match_operand 0 "vsib_address_operand")
18990                         (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand")
18991                         (match_operand:SI 4 "const1248_operand")]))
18992                    (unspec:VI48F
18993                      [(match_operand:QI 1 "register_operand")
18994                       (match_operand:<VEC_GATHER_SRCDI> 3 "register_operand")]
18995                      UNSPEC_SCATTER))
18996               (clobber (match_scratch:QI 6))])]
18997   "TARGET_AVX512F"
18999   operands[5]
19000     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[0], operands[2],
19001                                         operands[4]), UNSPEC_VSIBADDR);
19004 (define_insn "*avx512f_scatterdi<mode>"
19005   [(set (match_operator:VI48F 5 "vsib_mem_operator"
19006           [(unspec:P
19007              [(match_operand:P 0 "vsib_address_operand" "Tv")
19008               (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand" "v")
19009               (match_operand:SI 4 "const1248_operand" "n")]
19010              UNSPEC_VSIBADDR)])
19011         (unspec:VI48F
19012           [(match_operand:QI 6 "register_operand" "1")
19013            (match_operand:<VEC_GATHER_SRCDI> 3 "register_operand" "v")]
19014           UNSPEC_SCATTER))
19015    (clobber (match_scratch:QI 1 "=&Yk"))]
19016   "TARGET_AVX512F"
19017   "v<sseintprefix>scatterq<ssemodesuffix>\t{%3, %5%{%1%}|%5%{%1%}, %3}"
19018   [(set_attr "type" "ssemov")
19019    (set_attr "prefix" "evex")
19020    (set_attr "mode" "<sseinsnmode>")])
19022 (define_insn "<avx512>_compress<mode>_mask"
19023   [(set (match_operand:VI48F 0 "register_operand" "=v")
19024         (unspec:VI48F
19025           [(match_operand:VI48F 1 "register_operand" "v")
19026            (match_operand:VI48F 2 "vector_move_operand" "0C")
19027            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")]
19028           UNSPEC_COMPRESS))]
19029   "TARGET_AVX512F"
19030   "v<sseintprefix>compress<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19031   [(set_attr "type" "ssemov")
19032    (set_attr "prefix" "evex")
19033    (set_attr "mode" "<sseinsnmode>")])
19035 (define_insn "<avx512>_compressstore<mode>_mask"
19036   [(set (match_operand:VI48F 0 "memory_operand" "=m")
19037         (unspec:VI48F
19038           [(match_operand:VI48F 1 "register_operand" "x")
19039            (match_dup 0)
19040            (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")]
19041           UNSPEC_COMPRESS_STORE))]
19042   "TARGET_AVX512F"
19043   "v<sseintprefix>compress<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
19044   [(set_attr "type" "ssemov")
19045    (set_attr "prefix" "evex")
19046    (set_attr "memory" "store")
19047    (set_attr "mode" "<sseinsnmode>")])
19049 (define_expand "<avx512>_expand<mode>_maskz"
19050   [(set (match_operand:VI48F 0 "register_operand")
19051         (unspec:VI48F
19052           [(match_operand:VI48F 1 "nonimmediate_operand")
19053            (match_operand:VI48F 2 "vector_move_operand")
19054            (match_operand:<avx512fmaskmode> 3 "register_operand")]
19055           UNSPEC_EXPAND))]
19056   "TARGET_AVX512F"
19057   "operands[2] = CONST0_RTX (<MODE>mode);")
19059 (define_insn "<avx512>_expand<mode>_mask"
19060   [(set (match_operand:VI48F 0 "register_operand" "=v,v")
19061         (unspec:VI48F
19062           [(match_operand:VI48F 1 "nonimmediate_operand" "v,m")
19063            (match_operand:VI48F 2 "vector_move_operand" "0C,0C")
19064            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")]
19065           UNSPEC_EXPAND))]
19066   "TARGET_AVX512F"
19067   "v<sseintprefix>expand<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
19068   [(set_attr "type" "ssemov")
19069    (set_attr "prefix" "evex")
19070    (set_attr "memory" "none,load")
19071    (set_attr "mode" "<sseinsnmode>")])
19073 (define_insn "avx512dq_rangep<mode><mask_name><round_saeonly_name>"
19074   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
19075         (unspec:VF_AVX512VL
19076           [(match_operand:VF_AVX512VL 1 "register_operand" "v")
19077            (match_operand:VF_AVX512VL 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
19078            (match_operand:SI 3 "const_0_to_15_operand")]
19079           UNSPEC_RANGE))]
19080   "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
19081   "vrange<ssemodesuffix>\t{%3, <round_saeonly_mask_op4>%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2<round_saeonly_mask_op4>, %3}"
19082   [(set_attr "type" "sse")
19083    (set_attr "prefix" "evex")
19084    (set_attr "mode" "<MODE>")])
19086 (define_insn "avx512dq_ranges<mode><round_saeonly_name>"
19087   [(set (match_operand:VF_128 0 "register_operand" "=v")
19088         (vec_merge:VF_128
19089           (unspec:VF_128
19090             [(match_operand:VF_128 1 "register_operand" "v")
19091              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
19092              (match_operand:SI 3 "const_0_to_15_operand")]
19093             UNSPEC_RANGE)
19094           (match_dup 1)
19095           (const_int 1)))]
19096   "TARGET_AVX512DQ"
19097   "vrange<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %2<round_saeonly_op4>, %3}"
19098   [(set_attr "type" "sse")
19099    (set_attr "prefix" "evex")
19100    (set_attr "mode" "<MODE>")])
19102 (define_insn "avx512dq_fpclass<mode><mask_scalar_merge_name>"
19103   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
19104           (unspec:<avx512fmaskmode>
19105             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
19106              (match_operand:QI 2 "const_0_to_255_operand" "n")]
19107              UNSPEC_FPCLASS))]
19108    "TARGET_AVX512DQ"
19109    "vfpclass<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}";
19110   [(set_attr "type" "sse")
19111    (set_attr "length_immediate" "1")
19112    (set_attr "prefix" "evex")
19113    (set_attr "mode" "<MODE>")])
19115 (define_insn "avx512dq_vmfpclass<mode>"
19116   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
19117         (and:<avx512fmaskmode>
19118           (unspec:<avx512fmaskmode>
19119             [(match_operand:VF_128 1 "register_operand" "v")
19120              (match_operand:QI 2 "const_0_to_255_operand" "n")]
19121             UNSPEC_FPCLASS)
19122           (const_int 1)))]
19123    "TARGET_AVX512DQ"
19124    "vfpclass<ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
19125   [(set_attr "type" "sse")
19126    (set_attr "length_immediate" "1")
19127    (set_attr "prefix" "evex")
19128    (set_attr "mode" "<MODE>")])
19130 (define_insn "<avx512>_getmant<mode><mask_name><round_saeonly_name>"
19131   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
19132         (unspec:VF_AVX512VL
19133           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "<round_saeonly_constraint>")
19134            (match_operand:SI 2 "const_0_to_15_operand")]
19135           UNSPEC_GETMANT))]
19136   "TARGET_AVX512F"
19137   "vgetmant<ssemodesuffix>\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}";
19138   [(set_attr "prefix" "evex")
19139    (set_attr "mode" "<MODE>")])
19141 (define_insn "avx512f_vgetmant<mode><round_saeonly_name>"
19142   [(set (match_operand:VF_128 0 "register_operand" "=v")
19143         (vec_merge:VF_128
19144           (unspec:VF_128
19145             [(match_operand:VF_128 1 "register_operand" "v")
19146              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
19147              (match_operand:SI 3 "const_0_to_15_operand")]
19148             UNSPEC_GETMANT)
19149           (match_dup 1)
19150           (const_int 1)))]
19151    "TARGET_AVX512F"
19152    "vgetmant<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %2<round_saeonly_op4>, %3}";
19153    [(set_attr "prefix" "evex")
19154    (set_attr "mode" "<ssescalarmode>")])
19156 ;; The correct representation for this is absolutely enormous, and
19157 ;; surely not generally useful.
19158 (define_insn "<mask_codefor>avx512bw_dbpsadbw<mode><mask_name>"
19159   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
19160         (unspec:VI2_AVX512VL
19161           [(match_operand:<dbpsadbwmode> 1 "register_operand" "v")
19162            (match_operand:<dbpsadbwmode> 2 "nonimmediate_operand" "vm")
19163            (match_operand:SI 3 "const_0_to_255_operand")]
19164           UNSPEC_DBPSADBW))]
19165    "TARGET_AVX512BW"
19166   "vdbpsadbw\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}"
19167   [(set_attr "isa" "avx")
19168    (set_attr "type" "sselog1")
19169    (set_attr "length_immediate" "1")
19170    (set_attr "prefix" "evex")
19171    (set_attr "mode" "<sseinsnmode>")])
19173 (define_insn "clz<mode>2<mask_name>"
19174   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
19175         (clz:VI48_AVX512VL
19176           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")))]
19177   "TARGET_AVX512CD"
19178   "vplzcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19179   [(set_attr "type" "sse")
19180    (set_attr "prefix" "evex")
19181    (set_attr "mode" "<sseinsnmode>")])
19183 (define_insn "<mask_codefor>conflict<mode><mask_name>"
19184   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
19185         (unspec:VI48_AVX512VL
19186           [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")]
19187           UNSPEC_CONFLICT))]
19188   "TARGET_AVX512CD"
19189   "vpconflict<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
19190   [(set_attr "type" "sse")
19191    (set_attr "prefix" "evex")
19192    (set_attr "mode" "<sseinsnmode>")])
19194 (define_insn "sha1msg1"
19195   [(set (match_operand:V4SI 0 "register_operand" "=x")
19196         (unspec:V4SI
19197           [(match_operand:V4SI 1 "register_operand" "0")
19198            (match_operand:V4SI 2 "vector_operand" "xBm")]
19199           UNSPEC_SHA1MSG1))]
19200   "TARGET_SHA"
19201   "sha1msg1\t{%2, %0|%0, %2}"
19202   [(set_attr "type" "sselog1")
19203    (set_attr "mode" "TI")])
19205 (define_insn "sha1msg2"
19206   [(set (match_operand:V4SI 0 "register_operand" "=x")
19207         (unspec:V4SI
19208           [(match_operand:V4SI 1 "register_operand" "0")
19209            (match_operand:V4SI 2 "vector_operand" "xBm")]
19210           UNSPEC_SHA1MSG2))]
19211   "TARGET_SHA"
19212   "sha1msg2\t{%2, %0|%0, %2}"
19213   [(set_attr "type" "sselog1")
19214    (set_attr "mode" "TI")])
19216 (define_insn "sha1nexte"
19217   [(set (match_operand:V4SI 0 "register_operand" "=x")
19218         (unspec:V4SI
19219           [(match_operand:V4SI 1 "register_operand" "0")
19220            (match_operand:V4SI 2 "vector_operand" "xBm")]
19221           UNSPEC_SHA1NEXTE))]
19222   "TARGET_SHA"
19223   "sha1nexte\t{%2, %0|%0, %2}"
19224   [(set_attr "type" "sselog1")
19225    (set_attr "mode" "TI")])
19227 (define_insn "sha1rnds4"
19228   [(set (match_operand:V4SI 0 "register_operand" "=x")
19229         (unspec:V4SI
19230           [(match_operand:V4SI 1 "register_operand" "0")
19231            (match_operand:V4SI 2 "vector_operand" "xBm")
19232            (match_operand:SI 3 "const_0_to_3_operand" "n")]
19233           UNSPEC_SHA1RNDS4))]
19234   "TARGET_SHA"
19235   "sha1rnds4\t{%3, %2, %0|%0, %2, %3}"
19236   [(set_attr "type" "sselog1")
19237    (set_attr "length_immediate" "1")
19238    (set_attr "mode" "TI")])
19240 (define_insn "sha256msg1"
19241   [(set (match_operand:V4SI 0 "register_operand" "=x")
19242         (unspec:V4SI
19243           [(match_operand:V4SI 1 "register_operand" "0")
19244            (match_operand:V4SI 2 "vector_operand" "xBm")]
19245           UNSPEC_SHA256MSG1))]
19246   "TARGET_SHA"
19247   "sha256msg1\t{%2, %0|%0, %2}"
19248   [(set_attr "type" "sselog1")
19249    (set_attr "mode" "TI")])
19251 (define_insn "sha256msg2"
19252   [(set (match_operand:V4SI 0 "register_operand" "=x")
19253         (unspec:V4SI
19254           [(match_operand:V4SI 1 "register_operand" "0")
19255            (match_operand:V4SI 2 "vector_operand" "xBm")]
19256           UNSPEC_SHA256MSG2))]
19257   "TARGET_SHA"
19258   "sha256msg2\t{%2, %0|%0, %2}"
19259   [(set_attr "type" "sselog1")
19260    (set_attr "mode" "TI")])
19262 (define_insn "sha256rnds2"
19263   [(set (match_operand:V4SI 0 "register_operand" "=x")
19264         (unspec:V4SI
19265           [(match_operand:V4SI 1 "register_operand" "0")
19266            (match_operand:V4SI 2 "vector_operand" "xBm")
19267            (match_operand:V4SI 3 "register_operand" "Yz")]
19268           UNSPEC_SHA256RNDS2))]
19269   "TARGET_SHA"
19270   "sha256rnds2\t{%3, %2, %0|%0, %2, %3}"
19271   [(set_attr "type" "sselog1")
19272    (set_attr "length_immediate" "1")
19273    (set_attr "mode" "TI")])
19275 (define_insn_and_split "avx512f_<castmode><avxsizesuffix>_<castmode>"
19276   [(set (match_operand:AVX512MODE2P 0 "nonimmediate_operand" "=x,m")
19277         (unspec:AVX512MODE2P
19278           [(match_operand:<ssequartermode> 1 "nonimmediate_operand" "xm,x")]
19279           UNSPEC_CAST))]
19280   "TARGET_AVX512F"
19281   "#"
19282   "&& reload_completed"
19283   [(const_int 0)]
19285   rtx op0 = operands[0];
19286   rtx op1 = operands[1];
19287   if (REG_P (op0))
19288     op0 = gen_rtx_REG (<ssequartermode>mode, REGNO (op0));
19289   else
19290     op1 = gen_rtx_REG (<MODE>mode, REGNO (op1));
19291   emit_move_insn (op0, op1);
19292   DONE;
19295 (define_insn_and_split "avx512f_<castmode><avxsizesuffix>_256<castmode>"
19296   [(set (match_operand:AVX512MODE2P 0 "nonimmediate_operand" "=x,m")
19297         (unspec:AVX512MODE2P
19298           [(match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "xm,x")]
19299           UNSPEC_CAST))]
19300   "TARGET_AVX512F"
19301   "#"
19302   "&& reload_completed"
19303   [(const_int 0)]
19305   rtx op0 = operands[0];
19306   rtx op1 = operands[1];
19307   if (REG_P (op0))
19308     op0 = gen_rtx_REG (<ssehalfvecmode>mode, REGNO (op0));
19309   else
19310     op1 = gen_rtx_REG (<MODE>mode, REGNO (op1));
19311   emit_move_insn (op0, op1);
19312   DONE;
19315 (define_int_iterator VPMADD52
19316         [UNSPEC_VPMADD52LUQ
19317          UNSPEC_VPMADD52HUQ])
19319 (define_int_attr vpmadd52type
19320   [(UNSPEC_VPMADD52LUQ "luq") (UNSPEC_VPMADD52HUQ "huq")])
19322 (define_expand "vpamdd52huq<mode>_maskz"
19323   [(match_operand:VI8_AVX512VL 0 "register_operand")
19324    (match_operand:VI8_AVX512VL 1 "register_operand")
19325    (match_operand:VI8_AVX512VL 2 "register_operand")
19326    (match_operand:VI8_AVX512VL 3 "nonimmediate_operand")
19327    (match_operand:<avx512fmaskmode> 4 "register_operand")]
19328   "TARGET_AVX512IFMA"
19330   emit_insn (gen_vpamdd52huq<mode>_maskz_1 (
19331     operands[0], operands[1], operands[2], operands[3],
19332     CONST0_RTX (<MODE>mode), operands[4]));
19333   DONE;
19336 (define_expand "vpamdd52luq<mode>_maskz"
19337   [(match_operand:VI8_AVX512VL 0 "register_operand")
19338    (match_operand:VI8_AVX512VL 1 "register_operand")
19339    (match_operand:VI8_AVX512VL 2 "register_operand")
19340    (match_operand:VI8_AVX512VL 3 "nonimmediate_operand")
19341    (match_operand:<avx512fmaskmode> 4 "register_operand")]
19342   "TARGET_AVX512IFMA"
19344   emit_insn (gen_vpamdd52luq<mode>_maskz_1 (
19345     operands[0], operands[1], operands[2], operands[3],
19346     CONST0_RTX (<MODE>mode), operands[4]));
19347   DONE;
19350 (define_insn "vpamdd52<vpmadd52type><mode><sd_maskz_name>"
19351   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
19352         (unspec:VI8_AVX512VL
19353           [(match_operand:VI8_AVX512VL 1 "register_operand" "0")
19354            (match_operand:VI8_AVX512VL 2 "register_operand" "v")
19355            (match_operand:VI8_AVX512VL 3 "nonimmediate_operand" "vm")]
19356           VPMADD52))]
19357   "TARGET_AVX512IFMA"
19358   "vpmadd52<vpmadd52type>\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}"
19359   [(set_attr "type" "ssemuladd")
19360    (set_attr "prefix" "evex")
19361    (set_attr "mode" "<sseinsnmode>")])
19363 (define_insn "vpamdd52<vpmadd52type><mode>_mask"
19364   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
19365         (vec_merge:VI8_AVX512VL
19366           (unspec:VI8_AVX512VL
19367             [(match_operand:VI8_AVX512VL 1 "register_operand" "0")
19368              (match_operand:VI8_AVX512VL 2 "register_operand" "v")
19369              (match_operand:VI8_AVX512VL 3 "nonimmediate_operand" "vm")]
19370             VPMADD52)
19371           (match_dup 1)
19372           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
19373   "TARGET_AVX512IFMA"
19374   "vpmadd52<vpmadd52type>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
19375   [(set_attr "type" "ssemuladd")
19376    (set_attr "prefix" "evex")
19377    (set_attr "mode" "<sseinsnmode>")])
19379 (define_insn "vpmultishiftqb<mode><mask_name>"
19380   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
19381         (unspec:VI1_AVX512VL
19382           [(match_operand:VI1_AVX512VL 1 "register_operand" "v")
19383            (match_operand:VI1_AVX512VL 2 "nonimmediate_operand" "vm")]
19384           UNSPEC_VPMULTISHIFT))]
19385   "TARGET_AVX512VBMI"
19386   "vpmultishiftqb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19387   [(set_attr "type" "sselog")
19388    (set_attr "prefix" "evex")
19389    (set_attr "mode" "<sseinsnmode>")])