* config/i386/sse.md (<sse4_1>_round<ssemodesuffix><avxsizesuffix>):
[official-gcc.git] / gcc / config / i386 / sse.md
blob3c6099808be41661173bfeab90ab94b9aea24823
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
24   ;; SSE3
25   UNSPEC_LDDQU
27   ;; SSSE3
28   UNSPEC_PSHUFB
29   UNSPEC_PSIGN
30   UNSPEC_PALIGNR
32   ;; For SSE4A support
33   UNSPEC_EXTRQI
34   UNSPEC_EXTRQ
35   UNSPEC_INSERTQI
36   UNSPEC_INSERTQ
38   ;; For SSE4.1 support
39   UNSPEC_BLENDV
40   UNSPEC_INSERTPS
41   UNSPEC_DP
42   UNSPEC_MOVNTDQA
43   UNSPEC_MPSADBW
44   UNSPEC_PHMINPOSUW
45   UNSPEC_PTEST
47   ;; For SSE4.2 support
48   UNSPEC_PCMPESTR
49   UNSPEC_PCMPISTR
51   ;; For FMA4 support
52   UNSPEC_FMADDSUB
53   UNSPEC_XOP_UNSIGNED_CMP
54   UNSPEC_XOP_TRUEFALSE
55   UNSPEC_XOP_PERMUTE
56   UNSPEC_FRCZ
58   ;; For AES support
59   UNSPEC_AESENC
60   UNSPEC_AESENCLAST
61   UNSPEC_AESDEC
62   UNSPEC_AESDECLAST
63   UNSPEC_AESIMC
64   UNSPEC_AESKEYGENASSIST
66   ;; For PCLMUL support
67   UNSPEC_PCLMUL
69   ;; For AVX support
70   UNSPEC_PCMP
71   UNSPEC_VPERMIL
72   UNSPEC_VPERMIL2
73   UNSPEC_VPERMIL2F128
74   UNSPEC_CAST
75   UNSPEC_VTESTP
76   UNSPEC_VCVTPH2PS
77   UNSPEC_VCVTPS2PH
79   ;; For AVX2 support
80   UNSPEC_VPERMVAR
81   UNSPEC_VPERMTI
82   UNSPEC_GATHER
83   UNSPEC_VSIBADDR
85   ;; For AVX512F support
86   UNSPEC_VPERMI2
87   UNSPEC_VPERMT2
88   UNSPEC_VPERMI2_MASK
89   UNSPEC_UNSIGNED_FIX_NOTRUNC
90   UNSPEC_UNSIGNED_PCMP
91   UNSPEC_TESTM
92   UNSPEC_TESTNM
93   UNSPEC_SCATTER
94   UNSPEC_RCP14
95   UNSPEC_RSQRT14
96   UNSPEC_FIXUPIMM
97   UNSPEC_SCALEF
98   UNSPEC_VTERNLOG
99   UNSPEC_GETEXP
100   UNSPEC_GETMANT
101   UNSPEC_ALIGN
102   UNSPEC_CONFLICT
103   UNSPEC_COMPRESS
104   UNSPEC_COMPRESS_STORE
105   UNSPEC_EXPAND
106   UNSPEC_MASKED_EQ
107   UNSPEC_MASKED_GT
109   ;; For embed. rounding feature
110   UNSPEC_EMBEDDED_ROUNDING
112   ;; For AVX512PF support
113   UNSPEC_GATHER_PREFETCH
114   UNSPEC_SCATTER_PREFETCH
116   ;; For AVX512ER support
117   UNSPEC_EXP2
118   UNSPEC_RCP28
119   UNSPEC_RSQRT28
121   ;; For SHA support
122   UNSPEC_SHA1MSG1
123   UNSPEC_SHA1MSG2
124   UNSPEC_SHA1NEXTE
125   UNSPEC_SHA1RNDS4
126   UNSPEC_SHA256MSG1
127   UNSPEC_SHA256MSG2
128   UNSPEC_SHA256RNDS2
130   ;; For AVX512BW support
131   UNSPEC_DBPSADBW
132   UNSPEC_PMADDUBSW512
133   UNSPEC_PMADDWD512
134   UNSPEC_PSHUFHW
135   UNSPEC_PSHUFLW
136   UNSPEC_CVTINT2MASK
138   ;; For AVX512DQ support
139   UNSPEC_REDUCE
140   UNSPEC_FPCLASS
141   UNSPEC_RANGE
143   ;; For AVX512IFMA support
144   UNSPEC_VPMADD52LUQ
145   UNSPEC_VPMADD52HUQ
147   ;; For AVX512VBMI support
148   UNSPEC_VPMULTISHIFT
151 (define_c_enum "unspecv" [
152   UNSPECV_LDMXCSR
153   UNSPECV_STMXCSR
154   UNSPECV_CLFLUSH
155   UNSPECV_MONITOR
156   UNSPECV_MWAIT
157   UNSPECV_VZEROALL
158   UNSPECV_VZEROUPPER
161 ;; All vector modes including V?TImode, used in move patterns.
162 (define_mode_iterator VMOVE
163   [(V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
164    (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI
165    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
166    (V8DI "TARGET_AVX512F")  (V4DI "TARGET_AVX") V2DI
167    (V4TI "TARGET_AVX512BW") (V2TI "TARGET_AVX") V1TI
168    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
169    (V8DF "TARGET_AVX512F")  (V4DF "TARGET_AVX") V2DF])
171 ;; All AVX-512{F,VL} vector modes. Supposed TARGET_AVX512F baseline.
172 (define_mode_iterator V48_AVX512VL
173   [V16SI (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
174    V8DI  (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")
175    V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
176    V8DF  (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
178 ;; 1,2 byte AVX-512{BW,VL} vector modes. Supposed TARGET_AVX512BW baseline.
179 (define_mode_iterator VI12_AVX512VL
180   [V64QI (V16QI "TARGET_AVX512VL") (V32QI "TARGET_AVX512VL")
181    V32HI (V16HI "TARGET_AVX512VL") (V8HI "TARGET_AVX512VL")])
183 (define_mode_iterator VI1_AVX512VL
184   [V64QI (V16QI "TARGET_AVX512VL") (V32QI "TARGET_AVX512VL")])
186 ;; All vector modes
187 (define_mode_iterator V
188   [(V32QI "TARGET_AVX") V16QI
189    (V16HI "TARGET_AVX") V8HI
190    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
191    (V8DI "TARGET_AVX512F")  (V4DI "TARGET_AVX") V2DI
192    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
193    (V8DF "TARGET_AVX512F")  (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
195 ;; All 128bit vector modes
196 (define_mode_iterator V_128
197   [V16QI V8HI V4SI V2DI V4SF (V2DF "TARGET_SSE2")])
199 ;; All 256bit vector modes
200 (define_mode_iterator V_256
201   [V32QI V16HI V8SI V4DI V8SF V4DF])
203 ;; All 512bit vector modes
204 (define_mode_iterator V_512 [V64QI V32HI V16SI V8DI V16SF V8DF])
206 ;; All 256bit and 512bit vector modes
207 (define_mode_iterator V_256_512
208   [V32QI V16HI V8SI V4DI V8SF V4DF
209    (V64QI "TARGET_AVX512F") (V32HI "TARGET_AVX512F") (V16SI "TARGET_AVX512F")
210    (V8DI "TARGET_AVX512F") (V16SF "TARGET_AVX512F") (V8DF "TARGET_AVX512F")])
212 ;; All vector float modes
213 (define_mode_iterator VF
214   [(V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
215    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
217 ;; 128- and 256-bit float vector modes
218 (define_mode_iterator VF_128_256
219   [(V8SF "TARGET_AVX") V4SF
220    (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
222 ;; All SFmode vector float modes
223 (define_mode_iterator VF1
224   [(V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF])
226 ;; 128- and 256-bit SF vector modes
227 (define_mode_iterator VF1_128_256
228   [(V8SF "TARGET_AVX") V4SF])
230 (define_mode_iterator VF1_128_256VL
231   [V8SF (V4SF "TARGET_AVX512VL")])
233 ;; All DFmode vector float modes
234 (define_mode_iterator VF2
235   [(V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") V2DF])
237 ;; 128- and 256-bit DF vector modes
238 (define_mode_iterator VF2_128_256
239   [(V4DF "TARGET_AVX") V2DF])
241 (define_mode_iterator VF2_512_256
242   [(V8DF "TARGET_AVX512F") V4DF])
244 (define_mode_iterator VF2_512_256VL
245   [V8DF (V4DF "TARGET_AVX512VL")])
247 ;; All 128bit vector float modes
248 (define_mode_iterator VF_128
249   [V4SF (V2DF "TARGET_SSE2")])
251 ;; All 256bit vector float modes
252 (define_mode_iterator VF_256
253   [V8SF V4DF])
255 ;; All 512bit vector float modes
256 (define_mode_iterator VF_512
257   [V16SF V8DF])
259 (define_mode_iterator VI48_AVX512VL
260   [V16SI (V8SI  "TARGET_AVX512VL") (V4SI  "TARGET_AVX512VL")
261    V8DI  (V4DI  "TARGET_AVX512VL") (V2DI  "TARGET_AVX512VL")])
263 (define_mode_iterator VF_AVX512VL
264   [V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
265    V8DF (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
267 (define_mode_iterator VF2_AVX512VL
268   [V8DF (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
270 (define_mode_iterator VF1_AVX512VL
271   [V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")])
273 ;; All vector integer modes
274 (define_mode_iterator VI
275   [(V16SI "TARGET_AVX512F") (V8DI "TARGET_AVX512F")
276    (V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX") V16QI
277    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX") V8HI
278    (V8SI "TARGET_AVX") V4SI
279    (V4DI "TARGET_AVX") V2DI])
281 (define_mode_iterator VI_AVX2
282   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
283    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI
284    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI
285    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX2") V2DI])
287 ;; All QImode vector integer modes
288 (define_mode_iterator VI1
289   [(V32QI "TARGET_AVX") V16QI])
291 ;; All DImode vector integer modes
292 (define_mode_iterator V_AVX
293   [V16QI V8HI V4SI V2DI V4SF V2DF
294    (V32QI "TARGET_AVX") (V16HI "TARGET_AVX")
295    (V8SI "TARGET_AVX") (V4DI "TARGET_AVX")
296    (V8SF "TARGET_AVX") (V4DF"TARGET_AVX")])
298 (define_mode_iterator VI48_AVX
299  [V4SI V2DI
300   (V8SI "TARGET_AVX") (V4DI "TARGET_AVX")])
302 (define_mode_iterator VI8
303   [(V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI])
305 (define_mode_iterator VI8_AVX512VL
306   [V8DI (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
308 (define_mode_iterator VI8_256_512
309   [V8DI (V4DI "TARGET_AVX512VL")])
311 (define_mode_iterator VI1_AVX2
312   [(V32QI "TARGET_AVX2") V16QI])
314 (define_mode_iterator VI1_AVX512
315   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI])
317 (define_mode_iterator VI2_AVX2
318   [(V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI])
320 (define_mode_iterator VI2_AVX512F
321   [(V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX2") V8HI])
323 (define_mode_iterator VI4_AVX
324   [(V8SI "TARGET_AVX") V4SI])
326 (define_mode_iterator VI4_AVX2
327   [(V8SI "TARGET_AVX2") V4SI])
329 (define_mode_iterator VI4_AVX512F
330   [(V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI])
332 (define_mode_iterator VI4_AVX512VL
333   [V16SI (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")])
335 (define_mode_iterator VI48_AVX512F_AVX512VL
336   [V4SI V8SI (V16SI "TARGET_AVX512F")
337    (V2DI "TARGET_AVX512VL") (V4DI "TARGET_AVX512VL") (V8DI "TARGET_AVX512F")])
339 (define_mode_iterator VI2_AVX512VL
340   [(V8HI "TARGET_AVX512VL") (V16HI "TARGET_AVX512VL") V32HI])
342 (define_mode_iterator VI8_AVX2_AVX512BW
343   [(V8DI "TARGET_AVX512BW") (V4DI "TARGET_AVX2") V2DI])
345 (define_mode_iterator VI8_AVX2
346   [(V4DI "TARGET_AVX2") V2DI])
348 (define_mode_iterator VI8_AVX2_AVX512F
349   [(V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX2") V2DI])
351 (define_mode_iterator VI4_128_8_256
352   [V4SI V4DI])
354 ;; All V8D* modes
355 (define_mode_iterator V8FI
356   [V8DF V8DI])
358 ;; All V16S* modes
359 (define_mode_iterator V16FI
360   [V16SF V16SI])
362 ;; ??? We should probably use TImode instead.
363 (define_mode_iterator VIMAX_AVX2
364   [(V4TI "TARGET_AVX512BW") (V2TI "TARGET_AVX2") V1TI])
366 ;; ??? This should probably be dropped in favor of VIMAX_AVX2.
367 (define_mode_iterator SSESCALARMODE
368   [(V4TI "TARGET_AVX512BW") (V2TI "TARGET_AVX2") TI])
370 (define_mode_iterator VI12_AVX2
371   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
372    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI])
374 (define_mode_iterator VI24_AVX2
375   [(V16HI "TARGET_AVX2") V8HI
376    (V8SI "TARGET_AVX2") V4SI])
378 (define_mode_iterator VI124_AVX2_24_AVX512F_1_AVX512BW
379   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
380    (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX2") V8HI
381    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI])
383 (define_mode_iterator VI124_AVX2
384   [(V32QI "TARGET_AVX2") V16QI
385    (V16HI "TARGET_AVX2") V8HI
386    (V8SI "TARGET_AVX2") V4SI])
388 (define_mode_iterator VI2_AVX2_AVX512BW
389   [(V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI])
391 (define_mode_iterator VI48_AVX2
392   [(V8SI "TARGET_AVX2") V4SI
393    (V4DI "TARGET_AVX2") V2DI])
395 (define_mode_iterator VI248_AVX2_8_AVX512F_24_AVX512BW
396   [(V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI
397    (V16SI "TARGET_AVX512BW") (V8SI "TARGET_AVX2") V4SI
398    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX2") V2DI])
400 (define_mode_iterator VI248_AVX512BW_AVX512VL
401   [(V32HI "TARGET_AVX512BW") 
402    (V4DI "TARGET_AVX512VL") V16SI V8DI])
404 ;; Suppose TARGET_AVX512VL as baseline
405 (define_mode_iterator VI24_AVX512BW_1
406  [(V16HI "TARGET_AVX512BW") (V8HI "TARGET_AVX512BW")
407   V8SI V4SI])
408    
409 (define_mode_iterator VI48_AVX512F
410   [(V16SI "TARGET_AVX512F") V8SI V4SI
411    (V8DI "TARGET_AVX512F") V4DI V2DI])
413 (define_mode_iterator VI48_AVX_AVX512F
414   [(V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
415    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI])
417 (define_mode_iterator VI12_AVX_AVX512F
418   [ (V64QI "TARGET_AVX512F") (V32QI "TARGET_AVX") V16QI
419     (V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX") V8HI])
421 (define_mode_iterator V48_AVX2
422   [V4SF V2DF
423    V8SF V4DF
424    (V4SI "TARGET_AVX2") (V2DI "TARGET_AVX2")
425    (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")])
427 (define_mode_attr avx512
428   [(V16QI "avx512vl") (V32QI "avx512vl") (V64QI "avx512bw")
429    (V8HI  "avx512vl") (V16HI  "avx512vl") (V32HI "avx512bw")
430    (V4SI  "avx512vl") (V8SI  "avx512vl") (V16SI "avx512f")
431    (V2DI  "avx512vl") (V4DI  "avx512vl") (V8DI "avx512f")
432    (V4SF "avx512vl") (V8SF "avx512vl") (V16SF "avx512f")
433    (V2DF "avx512vl") (V4DF "avx512vl") (V8DF "avx512f")])
435 (define_mode_attr sse2_avx_avx512f
436   [(V16QI "sse2") (V32QI "avx") (V64QI "avx512f")
437    (V8HI  "avx512vl") (V16HI  "avx512vl") (V32HI "avx512bw")
438    (V4SI  "sse2") (V8SI  "avx") (V16SI "avx512f")
439    (V2DI  "avx512vl") (V4DI  "avx512vl") (V8DI "avx512f")
440    (V16SF "avx512f") (V8SF "avx") (V4SF "avx")
441    (V8DF "avx512f") (V4DF "avx") (V2DF "avx")])
443 (define_mode_attr sse2_avx2
444   [(V16QI "sse2") (V32QI "avx2") (V64QI "avx512bw")
445    (V8HI "sse2") (V16HI "avx2") (V32HI "avx512bw")
446    (V4SI "sse2") (V8SI "avx2") (V16SI "avx512f")
447    (V2DI "sse2") (V4DI "avx2") (V8DI "avx512f")
448    (V1TI "sse2") (V2TI "avx2") (V4TI "avx512bw")])
450 (define_mode_attr ssse3_avx2
451    [(V16QI "ssse3") (V32QI "avx2") (V64QI "avx512bw")
452     (V4HI "ssse3") (V8HI "ssse3") (V16HI "avx2") (V32HI "avx512bw")
453     (V4SI "ssse3") (V8SI "avx2")
454     (V2DI "ssse3") (V4DI "avx2")
455     (TI "ssse3") (V2TI "avx2") (V4TI "avx512bw")])
457 (define_mode_attr sse4_1_avx2
458    [(V16QI "sse4_1") (V32QI "avx2") (V64QI "avx512bw")
459     (V8HI "sse4_1") (V16HI "avx2") (V32HI "avx512bw")
460     (V4SI "sse4_1") (V8SI "avx2") (V16SI "avx512f")
461     (V2DI "sse4_1") (V4DI "avx2") (V8DI "avx512dq")])
463 (define_mode_attr avx_avx2
464   [(V4SF "avx") (V2DF "avx")
465    (V8SF "avx") (V4DF "avx")
466    (V4SI "avx2") (V2DI "avx2")
467    (V8SI "avx2") (V4DI "avx2")])
469 (define_mode_attr vec_avx2
470   [(V16QI "vec") (V32QI "avx2")
471    (V8HI "vec") (V16HI "avx2")
472    (V4SI "vec") (V8SI "avx2")
473    (V2DI "vec") (V4DI "avx2")])
475 (define_mode_attr avx2_avx512
476   [(V4SI "avx2") (V8SI "avx2") (V16SI "avx512f")
477    (V2DI "avx2") (V4DI "avx2") (V8DI "avx512f")
478    (V4SF "avx2") (V8SF "avx2") (V16SF "avx512f")
479    (V2DF "avx2") (V4DF "avx2") (V8DF "avx512f")
480    (V8HI "avx512vl") (V16HI "avx512vl") (V32HI "avx512bw")])
482 (define_mode_attr shuffletype
483   [(V16SF "f") (V16SI "i") (V8DF "f") (V8DI "i")
484   (V8SF "f") (V8SI "i") (V4DF "f") (V4DI "i")
485   (V4SF "f") (V4SI "i") (V2DF "f") (V2DI "i")
486   (V32HI "i") (V16HI "i") (V8HI "i")
487   (V64QI "i") (V32QI "i") (V16QI "i")
488   (V4TI "i") (V2TI "i") (V1TI "i")])
490 (define_mode_attr ssequartermode
491   [(V16SF "V4SF") (V8DF "V2DF") (V16SI "V4SI") (V8DI "V2DI")])
493 (define_mode_attr ssedoublemodelower
494   [(V16QI "v16hi") (V32QI "v32hi") (V64QI "v64hi")
495    (V8HI "v8si")   (V16HI "v16si") (V32HI "v32si")
496    (V4SI "v4di")   (V8SI "v8di")   (V16SI "v16di")])
498 (define_mode_attr ssedoublemode
499   [(V4SF "V8SF") (V8SF "V16SF") (V16SF "V32SF")
500    (V2DF "V4DF") (V4DF "V8DF") (V8DF "V16DF")
501    (V16QI "V16HI") (V32QI "V32HI") (V64QI "V64HI")
502    (V4HI "V4SI") (V8HI "V8SI") (V16HI "V16SI") (V32HI "V32SI")
503    (V4SI "V4DI") (V8SI "V16SI") (V16SI "V32SI")
504    (V4DI "V8DI") (V8DI "V16DI")])
506 (define_mode_attr ssebytemode
507   [(V8DI "V64QI") (V4DI "V32QI") (V2DI "V16QI")])
509 ;; All 128bit vector integer modes
510 (define_mode_iterator VI_128 [V16QI V8HI V4SI V2DI])
512 ;; All 256bit vector integer modes
513 (define_mode_iterator VI_256 [V32QI V16HI V8SI V4DI])
515 ;; All 512bit vector integer modes
516 (define_mode_iterator VI_512
517   [(V64QI "TARGET_AVX512BW")
518    (V32HI "TARGET_AVX512BW")
519    V16SI V8DI])
521 ;; Various 128bit vector integer mode combinations
522 (define_mode_iterator VI12_128 [V16QI V8HI])
523 (define_mode_iterator VI14_128 [V16QI V4SI])
524 (define_mode_iterator VI124_128 [V16QI V8HI V4SI])
525 (define_mode_iterator VI24_128 [V8HI V4SI])
526 (define_mode_iterator VI248_128 [V8HI V4SI V2DI])
527 (define_mode_iterator VI48_128 [V4SI V2DI])
529 ;; Various 256bit and 512 vector integer mode combinations
530 (define_mode_iterator VI124_256 [V32QI V16HI V8SI])
531 (define_mode_iterator VI124_256_AVX512F_AVX512BW
532   [V32QI V16HI V8SI
533    (V64QI "TARGET_AVX512BW")
534    (V32HI "TARGET_AVX512BW")
535    (V16SI "TARGET_AVX512F")])
536 (define_mode_iterator VI48_256 [V8SI V4DI])
537 (define_mode_iterator VI48_512 [V16SI V8DI])
538 (define_mode_iterator VI4_256_8_512 [V8SI V8DI])
539 (define_mode_iterator VI_AVX512BW
540   [V16SI V8DI (V32HI "TARGET_AVX512BW") (V64QI "TARGET_AVX512BW")])
542 ;; Int-float size matches
543 (define_mode_iterator VI4F_128 [V4SI V4SF])
544 (define_mode_iterator VI8F_128 [V2DI V2DF])
545 (define_mode_iterator VI4F_256 [V8SI V8SF])
546 (define_mode_iterator VI8F_256 [V4DI V4DF])
547 (define_mode_iterator VI8F_256_512
548   [V4DI V4DF (V8DI "TARGET_AVX512F") (V8DF "TARGET_AVX512F")])
549 (define_mode_iterator VI48F_256_512
550   [V8SI V8SF
551   (V16SI "TARGET_AVX512F") (V16SF "TARGET_AVX512F")
552   (V8DI  "TARGET_AVX512F") (V8DF  "TARGET_AVX512F")
553   (V4DI  "TARGET_AVX512VL") (V4DF  "TARGET_AVX512VL")])
554 (define_mode_iterator VF48_I1248
555   [V16SI V16SF V8DI V8DF V32HI V64QI])
556 (define_mode_iterator VI48F
557   [V16SI V16SF V8DI V8DF
558    (V8SI "TARGET_AVX512VL") (V8SF "TARGET_AVX512VL")
559    (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")
560    (V4SI "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
561    (V2DI "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
562 (define_mode_iterator VI48F_256 [V8SI V8SF V4DI V4DF])
564 ;; Mapping from float mode to required SSE level
565 (define_mode_attr sse
566   [(SF "sse") (DF "sse2")
567    (V4SF "sse") (V2DF "sse2")
568    (V16SF "avx512f") (V8SF "avx")
569    (V8DF "avx512f") (V4DF "avx")])
571 (define_mode_attr sse2
572   [(V16QI "sse2") (V32QI "avx") (V64QI "avx512f")
573    (V2DI "sse2") (V4DI "avx") (V8DI "avx512f")])
575 (define_mode_attr sse3
576   [(V16QI "sse3") (V32QI "avx")])
578 (define_mode_attr sse4_1
579   [(V4SF "sse4_1") (V2DF "sse4_1")
580    (V8SF "avx") (V4DF "avx")
581    (V8DF "avx512f")
582    (V4DI "avx") (V2DI "sse4_1")
583    (V8SI "avx") (V4SI "sse4_1")
584    (V16QI "sse4_1") (V32QI "avx")
585    (V8HI "sse4_1") (V16HI "avx")])
587 (define_mode_attr avxsizesuffix
588   [(V64QI "512") (V32HI "512") (V16SI "512") (V8DI "512")
589    (V32QI "256") (V16HI "256") (V8SI "256") (V4DI "256")
590    (V16QI "") (V8HI "") (V4SI "") (V2DI "")
591    (V16SF "512") (V8DF "512")
592    (V8SF "256") (V4DF "256")
593    (V4SF "") (V2DF "")])
595 ;; SSE instruction mode
596 (define_mode_attr sseinsnmode
597   [(V64QI "XI") (V32HI "XI") (V16SI "XI") (V8DI "XI") (V4TI "XI")
598    (V32QI "OI") (V16HI "OI") (V8SI "OI") (V4DI "OI") (V2TI "OI")
599    (V16QI "TI") (V8HI "TI") (V4SI "TI") (V2DI "TI") (V1TI "TI")
600    (V16SF "V16SF") (V8DF "V8DF")
601    (V8SF "V8SF") (V4DF "V4DF")
602    (V4SF "V4SF") (V2DF "V2DF")
603    (TI "TI")])
605 ;; Mapping of vector modes to corresponding mask size
606 (define_mode_attr avx512fmaskmode
607   [(V64QI "DI") (V32QI "SI") (V16QI "HI")
608    (V32HI "SI") (V16HI "HI") (V8HI  "QI") (V4HI "QI")
609    (V16SI "HI") (V8SI  "QI") (V4SI  "QI")
610    (V8DI  "QI") (V4DI  "QI") (V2DI  "QI")
611    (V16SF "HI") (V8SF  "QI") (V4SF  "QI")
612    (V8DF  "QI") (V4DF  "QI") (V2DF  "QI")])
614 ;; Mapping of vector modes to corresponding mask size
615 (define_mode_attr avx512fmaskmodelower
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 float modes to an integer mode of the same size
624 (define_mode_attr sseintvecmode
625   [(V16SF "V16SI") (V8DF  "V8DI")
626    (V8SF  "V8SI")  (V4DF  "V4DI")
627    (V4SF  "V4SI")  (V2DF  "V2DI")
628    (V16SI "V16SI") (V8DI  "V8DI")
629    (V8SI  "V8SI")  (V4DI  "V4DI")
630    (V4SI  "V4SI")  (V2DI  "V2DI")
631    (V16HI "V16HI") (V8HI  "V8HI")
632    (V32HI "V32HI") (V64QI "V64QI")
633    (V32QI "V32QI") (V16QI "V16QI")])
635 (define_mode_attr sseintvecmode2
636   [(V8DF "XI") (V4DF "OI") (V2DF "TI")
637    (V8SF "OI") (V4SF "TI")])
639 (define_mode_attr sseintvecmodelower
640   [(V16SF "v16si") (V8DF "v8di")
641    (V8SF "v8si") (V4DF "v4di")
642    (V4SF "v4si") (V2DF "v2di")
643    (V8SI "v8si") (V4DI "v4di")
644    (V4SI "v4si") (V2DI "v2di")
645    (V16HI "v16hi") (V8HI "v8hi")
646    (V32QI "v32qi") (V16QI "v16qi")])
648 ;; Mapping of vector modes to a vector mode of double size
649 (define_mode_attr ssedoublevecmode
650   [(V32QI "V64QI") (V16HI "V32HI") (V8SI "V16SI") (V4DI "V8DI")
651    (V16QI "V32QI") (V8HI "V16HI") (V4SI "V8SI") (V2DI "V4DI")
652    (V8SF "V16SF") (V4DF "V8DF")
653    (V4SF "V8SF") (V2DF "V4DF")])
655 ;; Mapping of vector modes to a vector mode of half size
656 (define_mode_attr ssehalfvecmode
657   [(V64QI "V32QI") (V32HI "V16HI") (V16SI "V8SI") (V8DI "V4DI")
658    (V32QI "V16QI") (V16HI  "V8HI") (V8SI  "V4SI") (V4DI "V2DI")
659    (V16QI  "V8QI") (V8HI   "V4HI") (V4SI  "V2SI")
660    (V16SF "V8SF") (V8DF "V4DF")
661    (V8SF  "V4SF") (V4DF "V2DF")
662    (V4SF  "V2SF")])
664 ;; Mapping of vector modes ti packed single mode of the same size
665 (define_mode_attr ssePSmode
666   [(V16SI "V16SF") (V8DF "V16SF")
667    (V16SF "V16SF") (V8DI "V16SF")
668    (V64QI "V16SF") (V32QI "V8SF") (V16QI "V4SF")
669    (V32HI "V16SF") (V16HI "V8SF") (V8HI "V4SF")
670    (V8SI "V8SF") (V4SI "V4SF")
671    (V4DI "V8SF") (V2DI "V4SF")
672    (V4TI "V16SF") (V2TI "V8SF") (V1TI "V4SF")
673    (V8SF "V8SF") (V4SF "V4SF")
674    (V4DF "V8SF") (V2DF "V4SF")])
676 (define_mode_attr ssePSmode2
677   [(V8DI "V8SF") (V4DI "V4SF")])
679 ;; Mapping of vector modes back to the scalar modes
680 (define_mode_attr ssescalarmode
681   [(V64QI "QI") (V32QI "QI") (V16QI "QI")
682    (V32HI "HI") (V16HI "HI") (V8HI "HI")
683    (V16SI "SI") (V8SI "SI")  (V4SI "SI")
684    (V8DI "DI")  (V4DI "DI")  (V2DI "DI")
685    (V16SF "SF") (V8SF "SF")  (V4SF "SF")
686    (V8DF "DF")  (V4DF "DF")  (V2DF "DF")])
688 ;; Mapping of vector modes to the 128bit modes
689 (define_mode_attr ssexmmmode
690   [(V64QI "V16QI") (V32QI "V16QI") (V16QI "V16QI")
691    (V32HI "V8HI")  (V16HI "V8HI") (V8HI "V8HI")
692    (V16SI "V4SI")  (V8SI "V4SI")  (V4SI "V4SI")
693    (V8DI "V2DI")   (V4DI "V2DI")  (V2DI "V2DI")
694    (V16SF "V4SF")  (V8SF "V4SF")  (V4SF "V4SF")
695    (V8DF "V2DF")   (V4DF "V2DF")  (V2DF "V2DF")])
697 ;; Pointer size override for scalar modes (Intel asm dialect)
698 (define_mode_attr iptr
699   [(V64QI "b") (V32HI "w") (V16SI "k") (V8DI "q")
700    (V32QI "b") (V16HI "w") (V8SI "k") (V4DI "q")
701    (V16QI "b") (V8HI "w") (V4SI "k") (V2DI "q")
702    (V8SF "k") (V4DF "q")
703    (V4SF "k") (V2DF "q")
704    (SF "k") (DF "q")])
706 ;; Number of scalar elements in each vector type
707 (define_mode_attr ssescalarnum
708   [(V64QI "64") (V16SI "16") (V8DI "8")
709    (V32QI "32") (V16HI "16") (V8SI "8") (V4DI "4")
710    (V16QI "16") (V8HI "8") (V4SI "4") (V2DI "2")
711    (V16SF "16") (V8DF "8")
712    (V8SF "8") (V4DF "4")
713    (V4SF "4") (V2DF "2")])
715 ;; Mask of scalar elements in each vector type
716 (define_mode_attr ssescalarnummask
717   [(V32QI "31") (V16HI "15") (V8SI "7") (V4DI "3")
718    (V16QI "15") (V8HI "7") (V4SI "3") (V2DI "1")
719    (V8SF "7") (V4DF "3")
720    (V4SF "3") (V2DF "1")])
722 (define_mode_attr ssescalarsize
723   [(V4TI  "64") (V2TI  "64") (V1TI  "64")
724    (V8DI  "64") (V4DI  "64") (V2DI  "64")
725    (V64QI "8") (V32QI "8") (V16QI "8")
726    (V32HI "16") (V16HI "16") (V8HI "16")
727    (V16SI "32") (V8SI "32") (V4SI "32")
728    (V16SF "32") (V8SF "32") (V4SF "32")
729    (V8DF "64") (V4DF "64") (V2DF "64")])
731 ;; SSE prefix for integer vector modes
732 (define_mode_attr sseintprefix
733   [(V2DI  "p") (V2DF  "")
734    (V4DI  "p") (V4DF  "")
735    (V8DI  "p") (V8DF  "")
736    (V4SI  "p") (V4SF  "")
737    (V8SI  "p") (V8SF  "")
738    (V16SI "p") (V16SF "")
739    (V16QI "p") (V8HI "p")
740    (V32QI "p") (V16HI "p")
741    (V64QI "p") (V32HI "p")])
743 ;; SSE scalar suffix for vector modes
744 (define_mode_attr ssescalarmodesuffix
745   [(SF "ss") (DF "sd")
746    (V8SF "ss") (V4DF "sd")
747    (V4SF "ss") (V2DF "sd")
748    (V8SI "ss") (V4DI "sd")
749    (V4SI "d")])
751 ;; Pack/unpack vector modes
752 (define_mode_attr sseunpackmode
753   [(V16QI "V8HI") (V8HI "V4SI") (V4SI "V2DI")
754    (V32QI "V16HI") (V16HI "V8SI") (V8SI "V4DI")
755    (V32HI "V16SI") (V64QI "V32HI") (V16SI "V8DI")])
757 (define_mode_attr ssepackmode
758   [(V8HI "V16QI") (V4SI "V8HI") (V2DI "V4SI")
759    (V16HI "V32QI") (V8SI "V16HI") (V4DI "V8SI")
760    (V32HI "V64QI") (V16SI "V32HI") (V8DI "V16SI")])
762 ;; Mapping of the max integer size for xop rotate immediate constraint
763 (define_mode_attr sserotatemax
764   [(V16QI "7") (V8HI "15") (V4SI "31") (V2DI "63")])
766 ;; Mapping of mode to cast intrinsic name
767 (define_mode_attr castmode
768  [(V8SI "si") (V8SF "ps") (V4DF "pd")
769   (V16SI "si") (V16SF "ps") (V8DF "pd")])
771 ;; Instruction suffix for sign and zero extensions.
772 (define_code_attr extsuffix [(sign_extend "sx") (zero_extend "zx")])
774 ;; i128 for integer vectors and TARGET_AVX2, f128 otherwise.
775 ;; i64x4 or f64x4 for 512bit modes.
776 (define_mode_attr i128
777   [(V16SF "f64x4") (V8SF "f128") (V8DF "f64x4") (V4DF "f128")
778    (V64QI "i64x4") (V32QI "%~128") (V32HI "i64x4") (V16HI "%~128")
779    (V16SI "i64x4") (V8SI "%~128") (V8DI "i64x4") (V4DI "%~128")])
781 ;; For 256-bit modes for TARGET_AVX512VL && TARGET_AVX512DQ
782 ;; i32x4, f32x4, i64x2 or f64x2 suffixes.
783 (define_mode_attr i128vldq
784   [(V8SF "f32x4") (V4DF "f64x2")
785    (V32QI "i32x4") (V16HI "i32x4") (V8SI "i32x4") (V4DI "i64x2")])
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"
843          "=v,v ,v ,m")
844         (match_operand:VMOVE 1 "nonimmediate_or_sse_const_operand"
845          " C,BC,vm,v"))]
846   "TARGET_SSE
847    && (register_operand (operands[0], <MODE>mode)
848        || register_operand (operands[1], <MODE>mode))"
850   switch (get_attr_type (insn))
851     {
852     case TYPE_SSELOG1:
853       return standard_sse_constant_opcode (insn, operands[1]);
855     case TYPE_SSEMOV:
856       /* There is no evex-encoded vmov* for sizes smaller than 64-bytes
857          in avx512f, so we need to use workarounds, to access sse registers
858          16-31, which are evex-only. In avx512vl we don't need workarounds.  */
859       if (TARGET_AVX512F && <MODE_SIZE> < 64 && !TARGET_AVX512VL
860           && (EXT_REX_SSE_REG_P (operands[0])
861               || EXT_REX_SSE_REG_P (operands[1])))
862         {
863           if (memory_operand (operands[0], <MODE>mode))
864             {
865               if (<MODE_SIZE> == 32)
866                 return "vextract<shuffletype>64x4\t{$0x0, %g1, %0|%0, %g1, 0x0}";
867               else if (<MODE_SIZE> == 16)
868                 return "vextract<shuffletype>32x4\t{$0x0, %g1, %0|%0, %g1, 0x0}";
869               else
870                 gcc_unreachable ();
871             }
872           else if (memory_operand (operands[1], <MODE>mode))
873             {
874               if (<MODE_SIZE> == 32)
875                 return "vbroadcast<shuffletype>64x4\t{%1, %g0|%g0, %1}";
876               else if (<MODE_SIZE> == 16)
877                 return "vbroadcast<shuffletype>32x4\t{%1, %g0|%g0, %1}";
878               else
879                 gcc_unreachable ();
880             }
881           else
882             /* Reg -> reg move is always aligned.  Just use wider move.  */
883             switch (get_attr_mode (insn))
884               {
885               case MODE_V8SF:
886               case MODE_V4SF:
887                 return "vmovaps\t{%g1, %g0|%g0, %g1}";
888               case MODE_V4DF:
889               case MODE_V2DF:
890                 return "vmovapd\t{%g1, %g0|%g0, %g1}";
891               case MODE_OI:
892               case MODE_TI:
893                 return "vmovdqa64\t{%g1, %g0|%g0, %g1}";
894               default:
895                 gcc_unreachable ();
896               }
897         }
899       switch (get_attr_mode (insn))
900         {
901         case MODE_V16SF:
902         case MODE_V8SF:
903         case MODE_V4SF:
904           if (misaligned_operand (operands[0], <MODE>mode)
905               || misaligned_operand (operands[1], <MODE>mode))
906             return "%vmovups\t{%1, %0|%0, %1}";
907           else
908             return "%vmovaps\t{%1, %0|%0, %1}";
910         case MODE_V8DF:
911         case MODE_V4DF:
912         case MODE_V2DF:
913           if (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 (misaligned_operand (operands[0], <MODE>mode)
922               || misaligned_operand (operands[1], <MODE>mode))
923             return TARGET_AVX512VL ? "vmovdqu<ssescalarsize>\t{%1, %0|%0, %1}"
924                                    : "%vmovdqu\t{%1, %0|%0, %1}";
925           else
926             return TARGET_AVX512VL ? "vmovdqa64\t{%1, %0|%0, %1}"
927                                    : "%vmovdqa\t{%1, %0|%0, %1}";
928         case MODE_XI:
929           if (misaligned_operand (operands[0], <MODE>mode)
930               || misaligned_operand (operands[1], <MODE>mode))
931             return (<MODE>mode == V16SImode
932                     || <MODE>mode == V8DImode
933                     || TARGET_AVX512BW)
934                    ? "vmovdqu<ssescalarsize>\t{%1, %0|%0, %1}"
935                    : "vmovdqu64\t{%1, %0|%0, %1}";
936           else
937             return "vmovdqa64\t{%1, %0|%0, %1}";
939         default:
940           gcc_unreachable ();
941         }
943     default:
944       gcc_unreachable ();
945     }
947   [(set_attr "type" "sselog1,sselog1,ssemov,ssemov")
948    (set_attr "prefix" "maybe_vex")
949    (set (attr "mode")
950         (cond [(and (eq_attr "alternative" "1")
951                     (match_test "TARGET_AVX512VL"))
952                  (const_string "XI")
953                (and (match_test "<MODE_SIZE> == 16")
954                     (ior (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
955                          (and (eq_attr "alternative" "3")
956                               (match_test "TARGET_SSE_TYPELESS_STORES"))))
957                  (const_string "<ssePSmode>")
958                (match_test "TARGET_AVX")
959                  (const_string "<sseinsnmode>")
960                (ior (not (match_test "TARGET_SSE2"))
961                     (match_test "optimize_function_for_size_p (cfun)"))
962                  (const_string "V4SF")
963                (and (eq_attr "alternative" "0")
964                     (match_test "TARGET_SSE_LOAD0_BY_PXOR"))
965                  (const_string "TI")
966               ]
967               (const_string "<sseinsnmode>")))
968    (set (attr "enabled")
969         (cond [(and (match_test "<MODE_SIZE> == 16")
970                     (eq_attr "alternative" "1"))
971                  (symbol_ref "TARGET_SSE2")
972                (and (match_test "<MODE_SIZE> == 32")
973                     (eq_attr "alternative" "1"))
974                  (symbol_ref "TARGET_AVX2")
975               ]
976               (symbol_ref "true")))])
978 (define_insn "<avx512>_load<mode>_mask"
979   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v,v")
980         (vec_merge:V48_AVX512VL
981           (match_operand:V48_AVX512VL 1 "nonimmediate_operand" "v,m")
982           (match_operand:V48_AVX512VL 2 "vector_move_operand" "0C,0C")
983           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
984   "TARGET_AVX512F"
986   if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
987     {
988       if (misaligned_operand (operands[1], <MODE>mode))
989         return "vmovu<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
990       else
991         return "vmova<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
992     }
993   else
994     {
995       if (misaligned_operand (operands[1], <MODE>mode))
996         return "vmovdqu<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
997       else
998         return "vmovdqa<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}";
999     }
1001   [(set_attr "type" "ssemov")
1002    (set_attr "prefix" "evex")
1003    (set_attr "memory" "none,load")
1004    (set_attr "mode" "<sseinsnmode>")])
1006 (define_insn "<avx512>_load<mode>_mask"
1007   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v,v")
1008         (vec_merge:VI12_AVX512VL
1009           (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "v,m")
1010           (match_operand:VI12_AVX512VL 2 "vector_move_operand" "0C,0C")
1011           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
1012   "TARGET_AVX512BW"
1013   "vmovdqu<ssescalarsize>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
1014   [(set_attr "type" "ssemov")
1015    (set_attr "prefix" "evex")
1016    (set_attr "memory" "none,load")
1017    (set_attr "mode" "<sseinsnmode>")])
1019 (define_insn "<avx512>_blendm<mode>"
1020   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v")
1021         (vec_merge:V48_AVX512VL
1022           (match_operand:V48_AVX512VL 2 "nonimmediate_operand" "vm")
1023           (match_operand:V48_AVX512VL 1 "register_operand" "v")
1024           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
1025   "TARGET_AVX512F"
1026   "vblendm<ssemodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}"
1027   [(set_attr "type" "ssemov")
1028    (set_attr "prefix" "evex")
1029    (set_attr "mode" "<sseinsnmode>")])
1031 (define_insn "<avx512>_blendm<mode>"
1032   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
1033         (vec_merge:VI12_AVX512VL
1034           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
1035           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
1036           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
1037   "TARGET_AVX512BW"
1038   "vpblendm<ssemodesuffix>\t{%2, %1, %0%{%3%}|%0%{%3%}, %1, %2}"
1039   [(set_attr "type" "ssemov")
1040    (set_attr "prefix" "evex")
1041    (set_attr "mode" "<sseinsnmode>")])
1043 (define_insn "<avx512>_store<mode>_mask"
1044   [(set (match_operand:V48_AVX512VL 0 "memory_operand" "=m")
1045         (vec_merge:V48_AVX512VL
1046           (match_operand:V48_AVX512VL 1 "register_operand" "v")
1047           (match_dup 0)
1048           (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1049   "TARGET_AVX512F"
1051   if (FLOAT_MODE_P (GET_MODE_INNER (<MODE>mode)))
1052     {
1053       if (misaligned_operand (operands[0], <MODE>mode))
1054         return "vmovu<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1055       else
1056         return "vmova<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1057     }
1058   else
1059     {
1060       if (misaligned_operand (operands[0], <MODE>mode))
1061         return "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1062       else
1063         return "vmovdqa<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
1064     }
1066   [(set_attr "type" "ssemov")
1067    (set_attr "prefix" "evex")
1068    (set_attr "memory" "store")
1069    (set_attr "mode" "<sseinsnmode>")])
1071 (define_insn "<avx512>_store<mode>_mask"
1072   [(set (match_operand:VI12_AVX512VL 0 "memory_operand" "=m")
1073         (vec_merge:VI12_AVX512VL
1074           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
1075           (match_dup 0)
1076           (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")))]
1077   "TARGET_AVX512BW"
1078   "vmovdqu<ssescalarsize>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
1079   [(set_attr "type" "ssemov")
1080    (set_attr "prefix" "evex")
1081    (set_attr "memory" "store")
1082    (set_attr "mode" "<sseinsnmode>")])
1084 (define_insn "sse2_movq128"
1085   [(set (match_operand:V2DI 0 "register_operand" "=v")
1086         (vec_concat:V2DI
1087           (vec_select:DI
1088             (match_operand:V2DI 1 "nonimmediate_operand" "vm")
1089             (parallel [(const_int 0)]))
1090           (const_int 0)))]
1091   "TARGET_SSE2"
1092   "%vmovq\t{%1, %0|%0, %q1}"
1093   [(set_attr "type" "ssemov")
1094    (set_attr "prefix" "maybe_vex")
1095    (set_attr "mode" "TI")])
1097 ;; Move a DI from a 32-bit register pair (e.g. %edx:%eax) to an xmm.
1098 ;; We'd rather avoid this entirely; if the 32-bit reg pair was loaded
1099 ;; from memory, we'd prefer to load the memory directly into the %xmm
1100 ;; register.  To facilitate this happy circumstance, this pattern won't
1101 ;; split until after register allocation.  If the 64-bit value didn't
1102 ;; come from memory, this is the best we can do.  This is much better
1103 ;; than storing %edx:%eax into a stack temporary and loading an %xmm
1104 ;; from there.
1106 (define_insn_and_split "movdi_to_sse"
1107   [(parallel
1108     [(set (match_operand:V4SI 0 "register_operand" "=?x,x")
1109           (subreg:V4SI (match_operand:DI 1 "nonimmediate_operand" "r,m") 0))
1110      (clobber (match_scratch:V4SI 2 "=&x,X"))])]
1111   "!TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_TO_VEC"
1112   "#"
1113   "&& reload_completed"
1114   [(const_int 0)]
1116  if (register_operand (operands[1], DImode))
1117    {
1118       /* The DImode arrived in a pair of integral registers (e.g. %edx:%eax).
1119          Assemble the 64-bit DImode value in an xmm register.  */
1120       emit_insn (gen_sse2_loadld (operands[0], CONST0_RTX (V4SImode),
1121                                   gen_lowpart (SImode, operands[1])));
1122       emit_insn (gen_sse2_loadld (operands[2], CONST0_RTX (V4SImode),
1123                                   gen_highpart (SImode, operands[1])));
1124       emit_insn (gen_vec_interleave_lowv4si (operands[0], operands[0],
1125                                              operands[2]));
1126    }
1127  else if (memory_operand (operands[1], DImode))
1128    {
1129      rtx tmp = gen_reg_rtx (V2DImode);
1130      emit_insn (gen_vec_concatv2di (tmp, operands[1], const0_rtx));
1131      emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp));
1132    }
1133  else
1134    gcc_unreachable ();
1137 (define_split
1138   [(set (match_operand:V4SF 0 "register_operand")
1139         (match_operand:V4SF 1 "zero_extended_scalar_load_operand"))]
1140   "TARGET_SSE && reload_completed"
1141   [(set (match_dup 0)
1142         (vec_merge:V4SF
1143           (vec_duplicate:V4SF (match_dup 1))
1144           (match_dup 2)
1145           (const_int 1)))]
1147   operands[1] = gen_lowpart (SFmode, operands[1]);
1148   operands[2] = CONST0_RTX (V4SFmode);
1151 (define_split
1152   [(set (match_operand:V2DF 0 "register_operand")
1153         (match_operand:V2DF 1 "zero_extended_scalar_load_operand"))]
1154   "TARGET_SSE2 && reload_completed"
1155   [(set (match_dup 0) (vec_concat:V2DF (match_dup 1) (match_dup 2)))]
1157   operands[1] = gen_lowpart (DFmode, operands[1]);
1158   operands[2] = CONST0_RTX (DFmode);
1161 (define_expand "movmisalign<mode>"
1162   [(set (match_operand:VMOVE 0 "nonimmediate_operand")
1163         (match_operand:VMOVE 1 "nonimmediate_operand"))]
1164   "TARGET_SSE"
1166   ix86_expand_vector_move_misalign (<MODE>mode, operands);
1167   DONE;
1170 ;; Merge movsd/movhpd to movupd for TARGET_SSE_UNALIGNED_LOAD_OPTIMAL targets.
1171 (define_peephole2
1172   [(set (match_operand:V2DF 0 "register_operand")
1173         (vec_concat:V2DF (match_operand:DF 1 "memory_operand")
1174                          (match_operand:DF 4 "const0_operand")))
1175    (set (match_operand:V2DF 2 "register_operand")
1176         (vec_concat:V2DF (vec_select:DF (match_dup 2)
1177                                         (parallel [(const_int 0)]))
1178                          (match_operand:DF 3 "memory_operand")))]
1179   "TARGET_SSE2 && TARGET_SSE_UNALIGNED_LOAD_OPTIMAL
1180    && ix86_operands_ok_for_move_multiple (operands, true, DFmode)"
1181   [(set (match_dup 2) (match_dup 4))]
1182   "operands[4] = adjust_address (operands[1], V2DFmode, 0);")
1184 ;; Merge movlpd/movhpd to movupd for TARGET_SSE_UNALIGNED_STORE_OPTIMAL targets.
1185 (define_peephole2
1186   [(set (match_operand:DF 0 "memory_operand")
1187         (vec_select:DF (match_operand:V2DF 1 "register_operand")
1188                        (parallel [(const_int 0)])))
1189    (set (match_operand:DF 2 "memory_operand")
1190         (vec_select:DF (match_operand:V2DF 3 "register_operand")
1191                        (parallel [(const_int 1)])))]
1192   "TARGET_SSE2 && TARGET_SSE_UNALIGNED_STORE_OPTIMAL
1193    && ix86_operands_ok_for_move_multiple (operands, false, DFmode)"
1194   [(set (match_dup 4) (match_dup 1))]
1195   "operands[4] = adjust_address (operands[0], V2DFmode, 0);")
1197 (define_insn "<sse3>_lddqu<avxsizesuffix>"
1198   [(set (match_operand:VI1 0 "register_operand" "=x")
1199         (unspec:VI1 [(match_operand:VI1 1 "memory_operand" "m")]
1200                     UNSPEC_LDDQU))]
1201   "TARGET_SSE3"
1202   "%vlddqu\t{%1, %0|%0, %1}"
1203   [(set_attr "type" "ssemov")
1204    (set_attr "movu" "1")
1205    (set (attr "prefix_data16")
1206      (if_then_else
1207        (match_test "TARGET_AVX")
1208      (const_string "*")
1209      (const_string "0")))
1210    (set (attr "prefix_rep")
1211      (if_then_else
1212        (match_test "TARGET_AVX")
1213      (const_string "*")
1214      (const_string "1")))
1215    (set_attr "prefix" "maybe_vex")
1216    (set_attr "mode" "<sseinsnmode>")])
1218 (define_insn "sse2_movnti<mode>"
1219   [(set (match_operand:SWI48 0 "memory_operand" "=m")
1220         (unspec:SWI48 [(match_operand:SWI48 1 "register_operand" "r")]
1221                       UNSPEC_MOVNT))]
1222   "TARGET_SSE2"
1223   "movnti\t{%1, %0|%0, %1}"
1224   [(set_attr "type" "ssemov")
1225    (set_attr "prefix_data16" "0")
1226    (set_attr "mode" "<MODE>")])
1228 (define_insn "<sse>_movnt<mode>"
1229   [(set (match_operand:VF 0 "memory_operand" "=m")
1230         (unspec:VF
1231           [(match_operand:VF 1 "register_operand" "v")]
1232           UNSPEC_MOVNT))]
1233   "TARGET_SSE"
1234   "%vmovnt<ssemodesuffix>\t{%1, %0|%0, %1}"
1235   [(set_attr "type" "ssemov")
1236    (set_attr "prefix" "maybe_vex")
1237    (set_attr "mode" "<MODE>")])
1239 (define_insn "<sse2>_movnt<mode>"
1240   [(set (match_operand:VI8 0 "memory_operand" "=m")
1241         (unspec:VI8 [(match_operand:VI8 1 "register_operand" "v")]
1242                     UNSPEC_MOVNT))]
1243   "TARGET_SSE2"
1244   "%vmovntdq\t{%1, %0|%0, %1}"
1245   [(set_attr "type" "ssecvt")
1246    (set (attr "prefix_data16")
1247      (if_then_else
1248        (match_test "TARGET_AVX")
1249      (const_string "*")
1250      (const_string "1")))
1251    (set_attr "prefix" "maybe_vex")
1252    (set_attr "mode" "<sseinsnmode>")])
1254 ; Expand patterns for non-temporal stores.  At the moment, only those
1255 ; that directly map to insns are defined; it would be possible to
1256 ; define patterns for other modes that would expand to several insns.
1258 ;; Modes handled by storent patterns.
1259 (define_mode_iterator STORENT_MODE
1260   [(DI "TARGET_SSE2 && TARGET_64BIT") (SI "TARGET_SSE2")
1261    (SF "TARGET_SSE4A") (DF "TARGET_SSE4A")
1262    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") (V2DI "TARGET_SSE2")
1263    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
1264    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") (V2DF "TARGET_SSE2")])
1266 (define_expand "storent<mode>"
1267   [(set (match_operand:STORENT_MODE 0 "memory_operand")
1268         (unspec:STORENT_MODE
1269           [(match_operand:STORENT_MODE 1 "register_operand")]
1270           UNSPEC_MOVNT))]
1271   "TARGET_SSE")
1273 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1275 ;; Parallel floating point arithmetic
1277 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1279 (define_expand "<code><mode>2"
1280   [(set (match_operand:VF 0 "register_operand")
1281         (absneg:VF
1282           (match_operand:VF 1 "register_operand")))]
1283   "TARGET_SSE"
1284   "ix86_expand_fp_absneg_operator (<CODE>, <MODE>mode, operands); DONE;")
1286 (define_insn_and_split "*absneg<mode>2"
1287   [(set (match_operand:VF 0 "register_operand" "=x,x,v,v")
1288         (match_operator:VF 3 "absneg_operator"
1289           [(match_operand:VF 1 "vector_operand" "0,  xBm,v, m")]))
1290    (use (match_operand:VF 2 "vector_operand"    "xBm,0,  vm,v"))]
1291   "TARGET_SSE"
1292   "#"
1293   "&& reload_completed"
1294   [(const_int 0)]
1296   enum rtx_code absneg_op;
1297   rtx op1, op2;
1298   rtx t;
1300   if (TARGET_AVX)
1301     {
1302       if (MEM_P (operands[1]))
1303         op1 = operands[2], op2 = operands[1];
1304       else
1305         op1 = operands[1], op2 = operands[2];
1306     }
1307   else
1308     {
1309       op1 = operands[0];
1310       if (rtx_equal_p (operands[0], operands[1]))
1311         op2 = operands[2];
1312       else
1313         op2 = operands[1];
1314     }
1316   absneg_op = GET_CODE (operands[3]) == NEG ? XOR : AND;
1317   t = gen_rtx_fmt_ee (absneg_op, <MODE>mode, op1, op2);
1318   t = gen_rtx_SET (operands[0], t);
1319   emit_insn (t);
1320   DONE;
1322   [(set_attr "isa" "noavx,noavx,avx,avx")])
1324 (define_expand "<plusminus_insn><mode>3<mask_name><round_name>"
1325   [(set (match_operand:VF 0 "register_operand")
1326         (plusminus:VF
1327           (match_operand:VF 1 "<round_nimm_predicate>")
1328           (match_operand:VF 2 "<round_nimm_predicate>")))]
1329   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1330   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
1332 (define_insn "*<plusminus_insn><mode>3<mask_name><round_name>"
1333   [(set (match_operand:VF 0 "register_operand" "=x,v")
1334         (plusminus:VF
1335           (match_operand:VF 1 "<round_nimm_predicate>" "<comm>0,v")
1336           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1337   "TARGET_SSE && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands) && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1338   "@
1339    <plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
1340    v<plusminus_mnemonic><ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1341   [(set_attr "isa" "noavx,avx")
1342    (set_attr "type" "sseadd")
1343    (set_attr "prefix" "<mask_prefix3>")
1344    (set_attr "mode" "<MODE>")])
1346 (define_insn "<sse>_vm<plusminus_insn><mode>3<round_name>"
1347   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1348         (vec_merge:VF_128
1349           (plusminus:VF_128
1350             (match_operand:VF_128 1 "register_operand" "0,v")
1351             (match_operand:VF_128 2 "vector_operand" "xBm,<round_constraint>"))
1352           (match_dup 1)
1353           (const_int 1)))]
1354   "TARGET_SSE"
1355   "@
1356    <plusminus_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
1357    v<plusminus_mnemonic><ssescalarmodesuffix>\t{<round_op3>%2, %1, %0|%0, %1, %<iptr>2<round_op3>}"
1358   [(set_attr "isa" "noavx,avx")
1359    (set_attr "type" "sseadd")
1360    (set_attr "prefix" "<round_prefix>")
1361    (set_attr "mode" "<ssescalarmode>")])
1363 (define_expand "mul<mode>3<mask_name><round_name>"
1364   [(set (match_operand:VF 0 "register_operand")
1365         (mult:VF
1366           (match_operand:VF 1 "<round_nimm_predicate>")
1367           (match_operand:VF 2 "<round_nimm_predicate>")))]
1368   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1369   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
1371 (define_insn "*mul<mode>3<mask_name><round_name>"
1372   [(set (match_operand:VF 0 "register_operand" "=x,v")
1373         (mult:VF
1374           (match_operand:VF 1 "<round_nimm_predicate>" "%0,v")
1375           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1376   "TARGET_SSE && ix86_binary_operator_ok (MULT, <MODE>mode, operands) && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1377   "@
1378    mul<ssemodesuffix>\t{%2, %0|%0, %2}
1379    vmul<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1380   [(set_attr "isa" "noavx,avx")
1381    (set_attr "type" "ssemul")
1382    (set_attr "prefix" "<mask_prefix3>")
1383    (set_attr "btver2_decode" "direct,double")
1384    (set_attr "mode" "<MODE>")])
1386 (define_insn "<sse>_vm<multdiv_mnemonic><mode>3<round_name>"
1387   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1388         (vec_merge:VF_128
1389           (multdiv:VF_128
1390             (match_operand:VF_128 1 "register_operand" "0,v")
1391             (match_operand:VF_128 2 "vector_operand" "xBm,<round_constraint>"))
1392           (match_dup 1)
1393           (const_int 1)))]
1394   "TARGET_SSE"
1395   "@
1396    <multdiv_mnemonic><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
1397    v<multdiv_mnemonic><ssescalarmodesuffix>\t{<round_op3>%2, %1, %0|%0, %1, %<iptr>2<round_op3>}"
1398   [(set_attr "isa" "noavx,avx")
1399    (set_attr "type" "sse<multdiv_mnemonic>")
1400    (set_attr "prefix" "<round_prefix>")
1401    (set_attr "btver2_decode" "direct,double")
1402    (set_attr "mode" "<ssescalarmode>")])
1404 (define_expand "div<mode>3"
1405   [(set (match_operand:VF2 0 "register_operand")
1406         (div:VF2 (match_operand:VF2 1 "register_operand")
1407                  (match_operand:VF2 2 "vector_operand")))]
1408   "TARGET_SSE2"
1409   "ix86_fixup_binary_operands_no_copy (DIV, <MODE>mode, operands);")
1411 (define_expand "div<mode>3"
1412   [(set (match_operand:VF1 0 "register_operand")
1413         (div:VF1 (match_operand:VF1 1 "register_operand")
1414                  (match_operand:VF1 2 "vector_operand")))]
1415   "TARGET_SSE"
1417   ix86_fixup_binary_operands_no_copy (DIV, <MODE>mode, operands);
1419   if (TARGET_SSE_MATH
1420       && TARGET_RECIP_VEC_DIV
1421       && !optimize_insn_for_size_p ()
1422       && flag_finite_math_only && !flag_trapping_math
1423       && flag_unsafe_math_optimizations)
1424     {
1425       ix86_emit_swdivsf (operands[0], operands[1], operands[2], <MODE>mode);
1426       DONE;
1427     }
1430 (define_insn "<sse>_div<mode>3<mask_name><round_name>"
1431   [(set (match_operand:VF 0 "register_operand" "=x,v")
1432         (div:VF
1433           (match_operand:VF 1 "register_operand" "0,v")
1434           (match_operand:VF 2 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1435   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1436   "@
1437    div<ssemodesuffix>\t{%2, %0|%0, %2}
1438    vdiv<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
1439   [(set_attr "isa" "noavx,avx")
1440    (set_attr "type" "ssediv")
1441    (set_attr "prefix" "<mask_prefix3>")
1442    (set_attr "mode" "<MODE>")])
1444 (define_insn "<sse>_rcp<mode>2"
1445   [(set (match_operand:VF1_128_256 0 "register_operand" "=x")
1446         (unspec:VF1_128_256
1447           [(match_operand:VF1_128_256 1 "vector_operand" "xBm")] UNSPEC_RCP))]
1448   "TARGET_SSE"
1449   "%vrcpps\t{%1, %0|%0, %1}"
1450   [(set_attr "type" "sse")
1451    (set_attr "atom_sse_attr" "rcp")
1452    (set_attr "btver2_sse_attr" "rcp")
1453    (set_attr "prefix" "maybe_vex")
1454    (set_attr "mode" "<MODE>")])
1456 (define_insn "sse_vmrcpv4sf2"
1457   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
1458         (vec_merge:V4SF
1459           (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,xm")]
1460                        UNSPEC_RCP)
1461           (match_operand:V4SF 2 "register_operand" "0,x")
1462           (const_int 1)))]
1463   "TARGET_SSE"
1464   "@
1465    rcpss\t{%1, %0|%0, %k1}
1466    vrcpss\t{%1, %2, %0|%0, %2, %k1}"
1467   [(set_attr "isa" "noavx,avx")
1468    (set_attr "type" "sse")
1469    (set_attr "atom_sse_attr" "rcp")
1470    (set_attr "btver2_sse_attr" "rcp")
1471    (set_attr "prefix" "orig,vex")
1472    (set_attr "mode" "SF")])
1474 (define_insn "<mask_codefor>rcp14<mode><mask_name>"
1475   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
1476         (unspec:VF_AVX512VL
1477           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")]
1478           UNSPEC_RCP14))]
1479   "TARGET_AVX512F"
1480   "vrcp14<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
1481   [(set_attr "type" "sse")
1482    (set_attr "prefix" "evex")
1483    (set_attr "mode" "<MODE>")])
1485 (define_insn "srcp14<mode>"
1486   [(set (match_operand:VF_128 0 "register_operand" "=v")
1487         (vec_merge:VF_128
1488           (unspec:VF_128
1489             [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1490             UNSPEC_RCP14)
1491           (match_operand:VF_128 2 "register_operand" "v")
1492           (const_int 1)))]
1493   "TARGET_AVX512F"
1494   "vrcp14<ssescalarmodesuffix>\t{%1, %2, %0|%0, %2, %<iptr>1}"
1495   [(set_attr "type" "sse")
1496    (set_attr "prefix" "evex")
1497    (set_attr "mode" "<MODE>")])
1499 (define_expand "sqrt<mode>2"
1500   [(set (match_operand:VF2 0 "register_operand")
1501         (sqrt:VF2 (match_operand:VF2 1 "vector_operand")))]
1502   "TARGET_SSE2")
1504 (define_expand "sqrt<mode>2"
1505   [(set (match_operand:VF1 0 "register_operand")
1506         (sqrt:VF1 (match_operand:VF1 1 "vector_operand")))]
1507   "TARGET_SSE"
1509   if (TARGET_SSE_MATH
1510       && TARGET_RECIP_VEC_SQRT
1511       && !optimize_insn_for_size_p ()
1512       && flag_finite_math_only && !flag_trapping_math
1513       && flag_unsafe_math_optimizations)
1514     {
1515       ix86_emit_swsqrtsf (operands[0], operands[1], <MODE>mode, false);
1516       DONE;
1517     }
1520 (define_insn "<sse>_sqrt<mode>2<mask_name><round_name>"
1521   [(set (match_operand:VF 0 "register_operand" "=x,v")
1522         (sqrt:VF (match_operand:VF 1 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
1523   "TARGET_SSE && <mask_mode512bit_condition> && <round_mode512bit_condition>"
1524   "@
1525    sqrt<ssemodesuffix>\t{%1, %0|%0, %1}
1526    vsqrt<ssemodesuffix>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
1527   [(set_attr "isa" "noavx,avx")
1528    (set_attr "type" "sse")
1529    (set_attr "atom_sse_attr" "sqrt")
1530    (set_attr "btver2_sse_attr" "sqrt")
1531    (set_attr "prefix" "maybe_vex")
1532    (set_attr "mode" "<MODE>")])
1534 (define_insn "<sse>_vmsqrt<mode>2<round_name>"
1535   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1536         (vec_merge:VF_128
1537           (sqrt:VF_128
1538             (match_operand:VF_128 1 "vector_operand" "xBm,<round_constraint>"))
1539           (match_operand:VF_128 2 "register_operand" "0,v")
1540           (const_int 1)))]
1541   "TARGET_SSE"
1542   "@
1543    sqrt<ssescalarmodesuffix>\t{%1, %0|%0, %<iptr>1}
1544    vsqrt<ssescalarmodesuffix>\t{<round_op3>%1, %2, %0|%0, %2, %<iptr>1<round_op3>}"
1545   [(set_attr "isa" "noavx,avx")
1546    (set_attr "type" "sse")
1547    (set_attr "atom_sse_attr" "sqrt")
1548    (set_attr "prefix" "<round_prefix>")
1549    (set_attr "btver2_sse_attr" "sqrt")
1550    (set_attr "mode" "<ssescalarmode>")])
1552 (define_expand "rsqrt<mode>2"
1553   [(set (match_operand:VF1_128_256 0 "register_operand")
1554         (unspec:VF1_128_256
1555           [(match_operand:VF1_128_256 1 "vector_operand")] UNSPEC_RSQRT))]
1556   "TARGET_SSE_MATH"
1558   ix86_emit_swsqrtsf (operands[0], operands[1], <MODE>mode, true);
1559   DONE;
1562 (define_insn "<sse>_rsqrt<mode>2"
1563   [(set (match_operand:VF1_128_256 0 "register_operand" "=x")
1564         (unspec:VF1_128_256
1565           [(match_operand:VF1_128_256 1 "vector_operand" "xBm")] UNSPEC_RSQRT))]
1566   "TARGET_SSE"
1567   "%vrsqrtps\t{%1, %0|%0, %1}"
1568   [(set_attr "type" "sse")
1569    (set_attr "prefix" "maybe_vex")
1570    (set_attr "mode" "<MODE>")])
1572 (define_insn "<mask_codefor>rsqrt14<mode><mask_name>"
1573   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
1574         (unspec:VF_AVX512VL
1575           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")]
1576           UNSPEC_RSQRT14))]
1577   "TARGET_AVX512F"
1578   "vrsqrt14<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
1579   [(set_attr "type" "sse")
1580    (set_attr "prefix" "evex")
1581    (set_attr "mode" "<MODE>")])
1583 (define_insn "rsqrt14<mode>"
1584   [(set (match_operand:VF_128 0 "register_operand" "=v")
1585         (vec_merge:VF_128
1586           (unspec:VF_128
1587             [(match_operand:VF_128 1 "nonimmediate_operand" "vm")]
1588             UNSPEC_RSQRT14)
1589           (match_operand:VF_128 2 "register_operand" "v")
1590           (const_int 1)))]
1591   "TARGET_AVX512F"
1592   "vrsqrt14<ssescalarmodesuffix>\t{%1, %2, %0|%0, %2, %<iptr>1}"
1593   [(set_attr "type" "sse")
1594    (set_attr "prefix" "evex")
1595    (set_attr "mode" "<MODE>")])
1597 (define_insn "sse_vmrsqrtv4sf2"
1598   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
1599         (vec_merge:V4SF
1600           (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,xm")]
1601                        UNSPEC_RSQRT)
1602           (match_operand:V4SF 2 "register_operand" "0,x")
1603           (const_int 1)))]
1604   "TARGET_SSE"
1605   "@
1606    rsqrtss\t{%1, %0|%0, %k1}
1607    vrsqrtss\t{%1, %2, %0|%0, %2, %k1}"
1608   [(set_attr "isa" "noavx,avx")
1609    (set_attr "type" "sse")
1610    (set_attr "prefix" "orig,vex")
1611    (set_attr "mode" "SF")])
1613 ;; ??? For !flag_finite_math_only, the representation with SMIN/SMAX
1614 ;; isn't really correct, as those rtl operators aren't defined when
1615 ;; applied to NaNs.  Hopefully the optimizers won't get too smart on us.
1617 (define_expand "<code><mode>3<mask_name><round_saeonly_name>"
1618   [(set (match_operand:VF 0 "register_operand")
1619         (smaxmin:VF
1620           (match_operand:VF 1 "<round_saeonly_nimm_predicate>")
1621           (match_operand:VF 2 "<round_saeonly_nimm_predicate>")))]
1622   "TARGET_SSE && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
1624   if (!flag_finite_math_only)
1625     operands[1] = force_reg (<MODE>mode, operands[1]);
1626   ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
1629 (define_insn "*<code><mode>3_finite<mask_name><round_saeonly_name>"
1630   [(set (match_operand:VF 0 "register_operand" "=x,v")
1631         (smaxmin:VF
1632           (match_operand:VF 1 "<round_saeonly_nimm_predicate>" "%0,v")
1633           (match_operand:VF 2 "<round_saeonly_nimm_predicate>" "xBm,<round_saeonly_constraint>")))]
1634   "TARGET_SSE && flag_finite_math_only
1635    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)
1636    && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
1637   "@
1638    <maxmin_float><ssemodesuffix>\t{%2, %0|%0, %2}
1639    v<maxmin_float><ssemodesuffix>\t{<round_saeonly_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_saeonly_mask_op3>}"
1640   [(set_attr "isa" "noavx,avx")
1641    (set_attr "type" "sseadd")
1642    (set_attr "btver2_sse_attr" "maxmin")
1643    (set_attr "prefix" "<mask_prefix3>")
1644    (set_attr "mode" "<MODE>")])
1646 (define_insn "*<code><mode>3<mask_name><round_saeonly_name>"
1647   [(set (match_operand:VF 0 "register_operand" "=x,v")
1648         (smaxmin:VF
1649           (match_operand:VF 1 "register_operand" "0,v")
1650           (match_operand:VF 2 "<round_saeonly_nimm_predicate>" "xBm,<round_saeonly_constraint>")))]
1651   "TARGET_SSE && !flag_finite_math_only
1652    && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
1653   "@
1654    <maxmin_float><ssemodesuffix>\t{%2, %0|%0, %2}
1655    v<maxmin_float><ssemodesuffix>\t{<round_saeonly_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_saeonly_mask_op3>}"
1656   [(set_attr "isa" "noavx,avx")
1657    (set_attr "type" "sseadd")
1658    (set_attr "btver2_sse_attr" "maxmin")
1659    (set_attr "prefix" "<mask_prefix3>")
1660    (set_attr "mode" "<MODE>")])
1662 (define_insn "<sse>_vm<code><mode>3<round_saeonly_name>"
1663   [(set (match_operand:VF_128 0 "register_operand" "=x,v")
1664         (vec_merge:VF_128
1665           (smaxmin:VF_128
1666             (match_operand:VF_128 1 "register_operand" "0,v")
1667             (match_operand:VF_128 2 "vector_operand" "xBm,<round_saeonly_constraint>"))
1668          (match_dup 1)
1669          (const_int 1)))]
1670   "TARGET_SSE"
1671   "@
1672    <maxmin_float><ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
1673    v<maxmin_float><ssescalarmodesuffix>\t{<round_saeonly_op3>%2, %1, %0|%0, %1, %<iptr>2<round_saeonly_op3>}"
1674   [(set_attr "isa" "noavx,avx")
1675    (set_attr "type" "sse")
1676    (set_attr "btver2_sse_attr" "maxmin")
1677    (set_attr "prefix" "<round_saeonly_prefix>")
1678    (set_attr "mode" "<ssescalarmode>")])
1680 ;; These versions of the min/max patterns implement exactly the operations
1681 ;;   min = (op1 < op2 ? op1 : op2)
1682 ;;   max = (!(op1 < op2) ? op1 : op2)
1683 ;; Their operands are not commutative, and thus they may be used in the
1684 ;; presence of -0.0 and NaN.
1686 (define_insn "*ieee_smin<mode>3"
1687   [(set (match_operand:VF 0 "register_operand" "=x,v")
1688         (unspec:VF
1689           [(match_operand:VF 1 "register_operand" "0,v")
1690            (match_operand:VF 2 "vector_operand" "xBm,vm")]
1691          UNSPEC_IEEE_MIN))]
1692   "TARGET_SSE"
1693   "@
1694    min<ssemodesuffix>\t{%2, %0|%0, %2}
1695    vmin<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
1696   [(set_attr "isa" "noavx,avx")
1697    (set_attr "type" "sseadd")
1698    (set_attr "prefix" "orig,vex")
1699    (set_attr "mode" "<MODE>")])
1701 (define_insn "*ieee_smax<mode>3"
1702   [(set (match_operand:VF 0 "register_operand" "=x,v")
1703         (unspec:VF
1704           [(match_operand:VF 1 "register_operand" "0,v")
1705            (match_operand:VF 2 "vector_operand" "xBm,vm")]
1706          UNSPEC_IEEE_MAX))]
1707   "TARGET_SSE"
1708   "@
1709    max<ssemodesuffix>\t{%2, %0|%0, %2}
1710    vmax<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
1711   [(set_attr "isa" "noavx,avx")
1712    (set_attr "type" "sseadd")
1713    (set_attr "prefix" "orig,vex")
1714    (set_attr "mode" "<MODE>")])
1716 (define_insn "avx_addsubv4df3"
1717   [(set (match_operand:V4DF 0 "register_operand" "=x")
1718         (vec_merge:V4DF
1719           (minus:V4DF
1720             (match_operand:V4DF 1 "register_operand" "x")
1721             (match_operand:V4DF 2 "nonimmediate_operand" "xm"))
1722           (plus:V4DF (match_dup 1) (match_dup 2))
1723           (const_int 5)))]
1724   "TARGET_AVX"
1725   "vaddsubpd\t{%2, %1, %0|%0, %1, %2}"
1726   [(set_attr "type" "sseadd")
1727    (set_attr "prefix" "vex")
1728    (set_attr "mode" "V4DF")])
1730 (define_insn "sse3_addsubv2df3"
1731   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
1732         (vec_merge:V2DF
1733           (minus:V2DF
1734             (match_operand:V2DF 1 "register_operand" "0,x")
1735             (match_operand:V2DF 2 "vector_operand" "xBm,xm"))
1736           (plus:V2DF (match_dup 1) (match_dup 2))
1737           (const_int 1)))]
1738   "TARGET_SSE3"
1739   "@
1740    addsubpd\t{%2, %0|%0, %2}
1741    vaddsubpd\t{%2, %1, %0|%0, %1, %2}"
1742   [(set_attr "isa" "noavx,avx")
1743    (set_attr "type" "sseadd")
1744    (set_attr "atom_unit" "complex")
1745    (set_attr "prefix" "orig,vex")
1746    (set_attr "mode" "V2DF")])
1748 (define_insn "avx_addsubv8sf3"
1749   [(set (match_operand:V8SF 0 "register_operand" "=x")
1750         (vec_merge:V8SF
1751           (minus:V8SF
1752             (match_operand:V8SF 1 "register_operand" "x")
1753             (match_operand:V8SF 2 "nonimmediate_operand" "xm"))
1754           (plus:V8SF (match_dup 1) (match_dup 2))
1755           (const_int 85)))]
1756   "TARGET_AVX"
1757   "vaddsubps\t{%2, %1, %0|%0, %1, %2}"
1758   [(set_attr "type" "sseadd")
1759    (set_attr "prefix" "vex")
1760    (set_attr "mode" "V8SF")])
1762 (define_insn "sse3_addsubv4sf3"
1763   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
1764         (vec_merge:V4SF
1765           (minus:V4SF
1766             (match_operand:V4SF 1 "register_operand" "0,x")
1767             (match_operand:V4SF 2 "vector_operand" "xBm,xm"))
1768           (plus:V4SF (match_dup 1) (match_dup 2))
1769           (const_int 5)))]
1770   "TARGET_SSE3"
1771   "@
1772    addsubps\t{%2, %0|%0, %2}
1773    vaddsubps\t{%2, %1, %0|%0, %1, %2}"
1774   [(set_attr "isa" "noavx,avx")
1775    (set_attr "type" "sseadd")
1776    (set_attr "prefix" "orig,vex")
1777    (set_attr "prefix_rep" "1,*")
1778    (set_attr "mode" "V4SF")])
1780 (define_split
1781   [(set (match_operand:VF_128_256 0 "register_operand")
1782         (match_operator:VF_128_256 6 "addsub_vm_operator"
1783           [(minus:VF_128_256
1784              (match_operand:VF_128_256 1 "register_operand")
1785              (match_operand:VF_128_256 2 "vector_operand"))
1786            (plus:VF_128_256
1787              (match_operand:VF_128_256 3 "vector_operand")
1788              (match_operand:VF_128_256 4 "vector_operand"))
1789            (match_operand 5 "const_int_operand")]))]
1790   "TARGET_SSE3
1791    && can_create_pseudo_p ()
1792    && ((rtx_equal_p (operands[1], operands[3])
1793         && rtx_equal_p (operands[2], operands[4]))
1794        || (rtx_equal_p (operands[1], operands[4])
1795            && rtx_equal_p (operands[2], operands[3])))"
1796   [(set (match_dup 0)
1797         (vec_merge:VF_128_256
1798           (minus:VF_128_256 (match_dup 1) (match_dup 2))
1799           (plus:VF_128_256 (match_dup 1) (match_dup 2))
1800           (match_dup 5)))])
1802 (define_split
1803   [(set (match_operand:VF_128_256 0 "register_operand")
1804         (match_operator:VF_128_256 6 "addsub_vm_operator"
1805           [(plus:VF_128_256
1806              (match_operand:VF_128_256 1 "vector_operand")
1807              (match_operand:VF_128_256 2 "vector_operand"))
1808            (minus:VF_128_256
1809              (match_operand:VF_128_256 3 "register_operand")
1810              (match_operand:VF_128_256 4 "vector_operand"))
1811            (match_operand 5 "const_int_operand")]))]
1812   "TARGET_SSE3
1813    && can_create_pseudo_p ()
1814    && ((rtx_equal_p (operands[1], operands[3])
1815         && rtx_equal_p (operands[2], operands[4]))
1816        || (rtx_equal_p (operands[1], operands[4])
1817            && rtx_equal_p (operands[2], operands[3])))"
1818   [(set (match_dup 0)
1819         (vec_merge:VF_128_256
1820           (minus:VF_128_256 (match_dup 3) (match_dup 4))
1821           (plus:VF_128_256 (match_dup 3) (match_dup 4))
1822           (match_dup 5)))]
1824   /* Negate mask bits to compensate for swapped PLUS and MINUS RTXes.  */
1825   operands[5]
1826     = GEN_INT (~INTVAL (operands[5])
1827                & ((HOST_WIDE_INT_1U << GET_MODE_NUNITS (<MODE>mode)) - 1));
1830 (define_split
1831   [(set (match_operand:VF_128_256 0 "register_operand")
1832         (match_operator:VF_128_256 7 "addsub_vs_operator"
1833           [(vec_concat:<ssedoublemode>
1834              (minus:VF_128_256
1835                (match_operand:VF_128_256 1 "register_operand")
1836                (match_operand:VF_128_256 2 "vector_operand"))
1837              (plus:VF_128_256
1838                (match_operand:VF_128_256 3 "vector_operand")
1839                (match_operand:VF_128_256 4 "vector_operand")))
1840            (match_parallel 5 "addsub_vs_parallel"
1841              [(match_operand 6 "const_int_operand")])]))]
1842   "TARGET_SSE3
1843    && can_create_pseudo_p ()
1844    && ((rtx_equal_p (operands[1], operands[3])
1845         && rtx_equal_p (operands[2], operands[4]))
1846        || (rtx_equal_p (operands[1], operands[4])
1847            && rtx_equal_p (operands[2], operands[3])))"
1848   [(set (match_dup 0)
1849         (vec_merge:VF_128_256
1850           (minus:VF_128_256 (match_dup 1) (match_dup 2))
1851           (plus:VF_128_256 (match_dup 1) (match_dup 2))
1852           (match_dup 5)))]
1854   int i, nelt = XVECLEN (operands[5], 0);
1855   HOST_WIDE_INT ival = 0;
1857   for (i = 0; i < nelt; i++)
1858     if (INTVAL (XVECEXP (operands[5], 0, i)) < GET_MODE_NUNITS (<MODE>mode))
1859       ival |= HOST_WIDE_INT_1 << i;
1861   operands[5] = GEN_INT (ival);
1864 (define_split
1865   [(set (match_operand:VF_128_256 0 "register_operand")
1866         (match_operator:VF_128_256 7 "addsub_vs_operator"
1867           [(vec_concat:<ssedoublemode>
1868              (plus:VF_128_256
1869                (match_operand:VF_128_256 1 "vector_operand")
1870                (match_operand:VF_128_256 2 "vector_operand"))
1871              (minus:VF_128_256
1872                (match_operand:VF_128_256 3 "register_operand")
1873                (match_operand:VF_128_256 4 "vector_operand")))
1874            (match_parallel 5 "addsub_vs_parallel"
1875              [(match_operand 6 "const_int_operand")])]))]
1876   "TARGET_SSE3
1877    && can_create_pseudo_p ()
1878    && ((rtx_equal_p (operands[1], operands[3])
1879         && rtx_equal_p (operands[2], operands[4]))
1880        || (rtx_equal_p (operands[1], operands[4])
1881            && rtx_equal_p (operands[2], operands[3])))"
1882   [(set (match_dup 0)
1883         (vec_merge:VF_128_256
1884           (minus:VF_128_256 (match_dup 3) (match_dup 4))
1885           (plus:VF_128_256 (match_dup 3) (match_dup 4))
1886           (match_dup 5)))]
1888   int i, nelt = XVECLEN (operands[5], 0);
1889   HOST_WIDE_INT ival = 0;
1891   for (i = 0; i < nelt; i++)
1892     if (INTVAL (XVECEXP (operands[5], 0, i)) >= GET_MODE_NUNITS (<MODE>mode))
1893       ival |= HOST_WIDE_INT_1 << i;
1895   operands[5] = GEN_INT (ival);
1898 (define_insn "avx_h<plusminus_insn>v4df3"
1899   [(set (match_operand:V4DF 0 "register_operand" "=x")
1900         (vec_concat:V4DF
1901           (vec_concat:V2DF
1902             (plusminus:DF
1903               (vec_select:DF
1904                 (match_operand:V4DF 1 "register_operand" "x")
1905                 (parallel [(const_int 0)]))
1906               (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
1907             (plusminus:DF
1908               (vec_select:DF
1909                 (match_operand:V4DF 2 "nonimmediate_operand" "xm")
1910                 (parallel [(const_int 0)]))
1911               (vec_select:DF (match_dup 2) (parallel [(const_int 1)]))))
1912           (vec_concat:V2DF
1913             (plusminus:DF
1914               (vec_select:DF (match_dup 1) (parallel [(const_int 2)]))
1915               (vec_select:DF (match_dup 1) (parallel [(const_int 3)])))
1916             (plusminus:DF
1917               (vec_select:DF (match_dup 2) (parallel [(const_int 2)]))
1918               (vec_select:DF (match_dup 2) (parallel [(const_int 3)]))))))]
1919   "TARGET_AVX"
1920   "vh<plusminus_mnemonic>pd\t{%2, %1, %0|%0, %1, %2}"
1921   [(set_attr "type" "sseadd")
1922    (set_attr "prefix" "vex")
1923    (set_attr "mode" "V4DF")])
1925 (define_expand "sse3_haddv2df3"
1926   [(set (match_operand:V2DF 0 "register_operand")
1927         (vec_concat:V2DF
1928           (plus:DF
1929             (vec_select:DF
1930               (match_operand:V2DF 1 "register_operand")
1931               (parallel [(const_int 0)]))
1932             (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
1933           (plus:DF
1934             (vec_select:DF
1935               (match_operand:V2DF 2 "vector_operand")
1936               (parallel [(const_int 0)]))
1937             (vec_select:DF (match_dup 2) (parallel [(const_int 1)])))))]
1938   "TARGET_SSE3")
1940 (define_insn "*sse3_haddv2df3"
1941   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
1942         (vec_concat:V2DF
1943           (plus:DF
1944             (vec_select:DF
1945               (match_operand:V2DF 1 "register_operand" "0,x")
1946               (parallel [(match_operand:SI 3 "const_0_to_1_operand")]))
1947             (vec_select:DF
1948               (match_dup 1)
1949               (parallel [(match_operand:SI 4 "const_0_to_1_operand")])))
1950           (plus:DF
1951             (vec_select:DF
1952               (match_operand:V2DF 2 "vector_operand" "xBm,xm")
1953               (parallel [(match_operand:SI 5 "const_0_to_1_operand")]))
1954             (vec_select:DF
1955               (match_dup 2)
1956               (parallel [(match_operand:SI 6 "const_0_to_1_operand")])))))]
1957   "TARGET_SSE3
1958    && INTVAL (operands[3]) != INTVAL (operands[4])
1959    && INTVAL (operands[5]) != INTVAL (operands[6])"
1960   "@
1961    haddpd\t{%2, %0|%0, %2}
1962    vhaddpd\t{%2, %1, %0|%0, %1, %2}"
1963   [(set_attr "isa" "noavx,avx")
1964    (set_attr "type" "sseadd")
1965    (set_attr "prefix" "orig,vex")
1966    (set_attr "mode" "V2DF")])
1968 (define_insn "sse3_hsubv2df3"
1969   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
1970         (vec_concat:V2DF
1971           (minus:DF
1972             (vec_select:DF
1973               (match_operand:V2DF 1 "register_operand" "0,x")
1974               (parallel [(const_int 0)]))
1975             (vec_select:DF (match_dup 1) (parallel [(const_int 1)])))
1976           (minus:DF
1977             (vec_select:DF
1978               (match_operand:V2DF 2 "vector_operand" "xBm,xm")
1979               (parallel [(const_int 0)]))
1980             (vec_select:DF (match_dup 2) (parallel [(const_int 1)])))))]
1981   "TARGET_SSE3"
1982   "@
1983    hsubpd\t{%2, %0|%0, %2}
1984    vhsubpd\t{%2, %1, %0|%0, %1, %2}"
1985   [(set_attr "isa" "noavx,avx")
1986    (set_attr "type" "sseadd")
1987    (set_attr "prefix" "orig,vex")
1988    (set_attr "mode" "V2DF")])
1990 (define_insn "*sse3_haddv2df3_low"
1991   [(set (match_operand:DF 0 "register_operand" "=x,x")
1992         (plus:DF
1993           (vec_select:DF
1994             (match_operand:V2DF 1 "register_operand" "0,x")
1995             (parallel [(match_operand:SI 2 "const_0_to_1_operand")]))
1996           (vec_select:DF
1997             (match_dup 1)
1998             (parallel [(match_operand:SI 3 "const_0_to_1_operand")]))))]
1999   "TARGET_SSE3
2000    && INTVAL (operands[2]) != INTVAL (operands[3])"
2001   "@
2002    haddpd\t{%0, %0|%0, %0}
2003    vhaddpd\t{%1, %1, %0|%0, %1, %1}"
2004   [(set_attr "isa" "noavx,avx")
2005    (set_attr "type" "sseadd1")
2006    (set_attr "prefix" "orig,vex")
2007    (set_attr "mode" "V2DF")])
2009 (define_insn "*sse3_hsubv2df3_low"
2010   [(set (match_operand:DF 0 "register_operand" "=x,x")
2011         (minus:DF
2012           (vec_select:DF
2013             (match_operand:V2DF 1 "register_operand" "0,x")
2014             (parallel [(const_int 0)]))
2015           (vec_select:DF
2016             (match_dup 1)
2017             (parallel [(const_int 1)]))))]
2018   "TARGET_SSE3"
2019   "@
2020    hsubpd\t{%0, %0|%0, %0}
2021    vhsubpd\t{%1, %1, %0|%0, %1, %1}"
2022   [(set_attr "isa" "noavx,avx")
2023    (set_attr "type" "sseadd1")
2024    (set_attr "prefix" "orig,vex")
2025    (set_attr "mode" "V2DF")])
2027 (define_insn "avx_h<plusminus_insn>v8sf3"
2028   [(set (match_operand:V8SF 0 "register_operand" "=x")
2029         (vec_concat:V8SF
2030           (vec_concat:V4SF
2031             (vec_concat:V2SF
2032               (plusminus:SF
2033                 (vec_select:SF
2034                   (match_operand:V8SF 1 "register_operand" "x")
2035                   (parallel [(const_int 0)]))
2036                 (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
2037               (plusminus:SF
2038                 (vec_select:SF (match_dup 1) (parallel [(const_int 2)]))
2039                 (vec_select:SF (match_dup 1) (parallel [(const_int 3)]))))
2040             (vec_concat:V2SF
2041               (plusminus:SF
2042                 (vec_select:SF
2043                   (match_operand:V8SF 2 "nonimmediate_operand" "xm")
2044                   (parallel [(const_int 0)]))
2045                 (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))
2046               (plusminus:SF
2047                 (vec_select:SF (match_dup 2) (parallel [(const_int 2)]))
2048                 (vec_select:SF (match_dup 2) (parallel [(const_int 3)])))))
2049           (vec_concat:V4SF
2050             (vec_concat:V2SF
2051               (plusminus:SF
2052                 (vec_select:SF (match_dup 1) (parallel [(const_int 4)]))
2053                 (vec_select:SF (match_dup 1) (parallel [(const_int 5)])))
2054               (plusminus:SF
2055                 (vec_select:SF (match_dup 1) (parallel [(const_int 6)]))
2056                 (vec_select:SF (match_dup 1) (parallel [(const_int 7)]))))
2057             (vec_concat:V2SF
2058               (plusminus:SF
2059                 (vec_select:SF (match_dup 2) (parallel [(const_int 4)]))
2060                 (vec_select:SF (match_dup 2) (parallel [(const_int 5)])))
2061               (plusminus:SF
2062                 (vec_select:SF (match_dup 2) (parallel [(const_int 6)]))
2063                 (vec_select:SF (match_dup 2) (parallel [(const_int 7)])))))))]
2064   "TARGET_AVX"
2065   "vh<plusminus_mnemonic>ps\t{%2, %1, %0|%0, %1, %2}"
2066   [(set_attr "type" "sseadd")
2067    (set_attr "prefix" "vex")
2068    (set_attr "mode" "V8SF")])
2070 (define_insn "sse3_h<plusminus_insn>v4sf3"
2071   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
2072         (vec_concat:V4SF
2073           (vec_concat:V2SF
2074             (plusminus:SF
2075               (vec_select:SF
2076                 (match_operand:V4SF 1 "register_operand" "0,x")
2077                 (parallel [(const_int 0)]))
2078               (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
2079             (plusminus:SF
2080               (vec_select:SF (match_dup 1) (parallel [(const_int 2)]))
2081               (vec_select:SF (match_dup 1) (parallel [(const_int 3)]))))
2082           (vec_concat:V2SF
2083             (plusminus:SF
2084               (vec_select:SF
2085                 (match_operand:V4SF 2 "vector_operand" "xBm,xm")
2086                 (parallel [(const_int 0)]))
2087               (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))
2088             (plusminus:SF
2089               (vec_select:SF (match_dup 2) (parallel [(const_int 2)]))
2090               (vec_select:SF (match_dup 2) (parallel [(const_int 3)]))))))]
2091   "TARGET_SSE3"
2092   "@
2093    h<plusminus_mnemonic>ps\t{%2, %0|%0, %2}
2094    vh<plusminus_mnemonic>ps\t{%2, %1, %0|%0, %1, %2}"
2095   [(set_attr "isa" "noavx,avx")
2096    (set_attr "type" "sseadd")
2097    (set_attr "atom_unit" "complex")
2098    (set_attr "prefix" "orig,vex")
2099    (set_attr "prefix_rep" "1,*")
2100    (set_attr "mode" "V4SF")])
2102 (define_expand "reduc_plus_scal_v8df"
2103   [(match_operand:DF 0 "register_operand")
2104    (match_operand:V8DF 1 "register_operand")]
2105   "TARGET_AVX512F"
2107   rtx tmp = gen_reg_rtx (V8DFmode);
2108   ix86_expand_reduc (gen_addv8df3, tmp, operands[1]);
2109   emit_insn (gen_vec_extractv8df (operands[0], tmp, const0_rtx));
2110   DONE;
2113 (define_expand "reduc_plus_scal_v4df"
2114   [(match_operand:DF 0 "register_operand")
2115    (match_operand:V4DF 1 "register_operand")]
2116   "TARGET_AVX"
2118   rtx tmp = gen_reg_rtx (V4DFmode);
2119   rtx tmp2 = gen_reg_rtx (V4DFmode);
2120   rtx vec_res = gen_reg_rtx (V4DFmode);
2121   emit_insn (gen_avx_haddv4df3 (tmp, operands[1], operands[1]));
2122   emit_insn (gen_avx_vperm2f128v4df3 (tmp2, tmp, tmp, GEN_INT (1)));
2123   emit_insn (gen_addv4df3 (vec_res, tmp, tmp2));
2124   emit_insn (gen_vec_extractv4df (operands[0], vec_res, const0_rtx));
2125   DONE;
2128 (define_expand "reduc_plus_scal_v2df"
2129   [(match_operand:DF 0 "register_operand")
2130    (match_operand:V2DF 1 "register_operand")]
2131   "TARGET_SSE3"
2133   rtx tmp = gen_reg_rtx (V2DFmode);
2134   emit_insn (gen_sse3_haddv2df3 (tmp, operands[1], operands[1]));
2135   emit_insn (gen_vec_extractv2df (operands[0], tmp, const0_rtx));
2136   DONE;
2139 (define_expand "reduc_plus_scal_v16sf"
2140   [(match_operand:SF 0 "register_operand")
2141    (match_operand:V16SF 1 "register_operand")]
2142   "TARGET_AVX512F"
2144   rtx tmp = gen_reg_rtx (V16SFmode);
2145   ix86_expand_reduc (gen_addv16sf3, tmp, operands[1]);
2146   emit_insn (gen_vec_extractv16sf (operands[0], tmp, const0_rtx));
2147   DONE;
2150 (define_expand "reduc_plus_scal_v8sf"
2151   [(match_operand:SF 0 "register_operand")
2152    (match_operand:V8SF 1 "register_operand")]
2153   "TARGET_AVX"
2155   rtx tmp = gen_reg_rtx (V8SFmode);
2156   rtx tmp2 = gen_reg_rtx (V8SFmode);
2157   rtx vec_res = gen_reg_rtx (V8SFmode);
2158   emit_insn (gen_avx_haddv8sf3 (tmp, operands[1], operands[1]));
2159   emit_insn (gen_avx_haddv8sf3 (tmp2, tmp, tmp));
2160   emit_insn (gen_avx_vperm2f128v8sf3 (tmp, tmp2, tmp2, GEN_INT (1)));
2161   emit_insn (gen_addv8sf3 (vec_res, tmp, tmp2));
2162   emit_insn (gen_vec_extractv8sf (operands[0], vec_res, const0_rtx));
2163   DONE;
2166 (define_expand "reduc_plus_scal_v4sf"
2167   [(match_operand:SF 0 "register_operand")
2168    (match_operand:V4SF 1 "register_operand")]
2169   "TARGET_SSE"
2171   rtx vec_res = gen_reg_rtx (V4SFmode);
2172   if (TARGET_SSE3)
2173     {
2174       rtx tmp = gen_reg_rtx (V4SFmode);
2175       emit_insn (gen_sse3_haddv4sf3 (tmp, operands[1], operands[1]));
2176       emit_insn (gen_sse3_haddv4sf3 (vec_res, tmp, tmp));
2177     }
2178   else
2179     ix86_expand_reduc (gen_addv4sf3, vec_res, operands[1]);
2180   emit_insn (gen_vec_extractv4sf (operands[0], vec_res, const0_rtx));
2181   DONE;
2184 ;; Modes handled by reduc_sm{in,ax}* patterns.
2185 (define_mode_iterator REDUC_SMINMAX_MODE
2186   [(V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
2187    (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")
2188    (V8SF "TARGET_AVX") (V4DF "TARGET_AVX")
2189    (V4SF "TARGET_SSE") (V64QI "TARGET_AVX512BW")
2190    (V32HI "TARGET_AVX512BW") (V16SI "TARGET_AVX512F")
2191    (V8DI "TARGET_AVX512F") (V16SF "TARGET_AVX512F")
2192    (V8DF "TARGET_AVX512F")])
2194 (define_expand "reduc_<code>_scal_<mode>"
2195   [(smaxmin:REDUC_SMINMAX_MODE
2196      (match_operand:<ssescalarmode> 0 "register_operand")
2197      (match_operand:REDUC_SMINMAX_MODE 1 "register_operand"))]
2198   ""
2200   rtx tmp = gen_reg_rtx (<MODE>mode);
2201   ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
2202   emit_insn (gen_vec_extract<mode> (operands[0], tmp, const0_rtx));
2203   DONE;
2206 (define_expand "reduc_<code>_scal_<mode>"
2207   [(umaxmin:VI_AVX512BW
2208      (match_operand:<ssescalarmode> 0 "register_operand")
2209      (match_operand:VI_AVX512BW 1 "register_operand"))]
2210   "TARGET_AVX512F"
2212   rtx tmp = gen_reg_rtx (<MODE>mode);
2213   ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
2214   emit_insn (gen_vec_extract<mode> (operands[0], tmp, const0_rtx));
2215   DONE;
2218 (define_expand "reduc_<code>_scal_<mode>"
2219   [(umaxmin:VI_256
2220      (match_operand:<ssescalarmode> 0 "register_operand")
2221      (match_operand:VI_256 1 "register_operand"))]
2222   "TARGET_AVX2"
2224   rtx tmp = gen_reg_rtx (<MODE>mode);
2225   ix86_expand_reduc (gen_<code><mode>3, tmp, operands[1]);
2226   emit_insn (gen_vec_extract<mode> (operands[0], tmp, const0_rtx));
2227   DONE;
2230 (define_expand "reduc_umin_scal_v8hi"
2231   [(umin:V8HI
2232      (match_operand:HI 0 "register_operand")
2233      (match_operand:V8HI 1 "register_operand"))]
2234   "TARGET_SSE4_1"
2236   rtx tmp = gen_reg_rtx (V8HImode);
2237   ix86_expand_reduc (gen_uminv8hi3, tmp, operands[1]);
2238   emit_insn (gen_vec_extractv8hi (operands[0], tmp, const0_rtx));
2239   DONE;
2242 (define_insn "<mask_codefor>reducep<mode><mask_name>"
2243   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
2244         (unspec:VF_AVX512VL
2245           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "vm")
2246            (match_operand:SI 2 "const_0_to_255_operand")]
2247           UNSPEC_REDUCE))]
2248   "TARGET_AVX512DQ"
2249   "vreduce<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
2250   [(set_attr "type" "sse")
2251    (set_attr "prefix" "evex")
2252    (set_attr "mode" "<MODE>")])
2254 (define_insn "reduces<mode>"
2255   [(set (match_operand:VF_128 0 "register_operand" "=v")
2256         (vec_merge:VF_128
2257           (unspec:VF_128
2258             [(match_operand:VF_128 1 "register_operand" "v")
2259              (match_operand:VF_128 2 "nonimmediate_operand" "vm")
2260              (match_operand:SI 3 "const_0_to_255_operand")]
2261             UNSPEC_REDUCE)
2262           (match_dup 1)
2263           (const_int 1)))]
2264   "TARGET_AVX512DQ"
2265   "vreduce<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
2266   [(set_attr "type" "sse")
2267    (set_attr "prefix" "evex")
2268    (set_attr "mode" "<MODE>")])
2270 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2272 ;; Parallel floating point comparisons
2274 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2276 (define_insn "avx_cmp<mode>3"
2277   [(set (match_operand:VF_128_256 0 "register_operand" "=x")
2278         (unspec:VF_128_256
2279           [(match_operand:VF_128_256 1 "register_operand" "x")
2280            (match_operand:VF_128_256 2 "nonimmediate_operand" "xm")
2281            (match_operand:SI 3 "const_0_to_31_operand" "n")]
2282           UNSPEC_PCMP))]
2283   "TARGET_AVX"
2284   "vcmp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
2285   [(set_attr "type" "ssecmp")
2286    (set_attr "length_immediate" "1")
2287    (set_attr "prefix" "vex")
2288    (set_attr "mode" "<MODE>")])
2290 (define_insn "avx_vmcmp<mode>3"
2291   [(set (match_operand:VF_128 0 "register_operand" "=x")
2292         (vec_merge:VF_128
2293           (unspec:VF_128
2294             [(match_operand:VF_128 1 "register_operand" "x")
2295              (match_operand:VF_128 2 "nonimmediate_operand" "xm")
2296              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2297             UNSPEC_PCMP)
2298          (match_dup 1)
2299          (const_int 1)))]
2300   "TARGET_AVX"
2301   "vcmp<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %3}"
2302   [(set_attr "type" "ssecmp")
2303    (set_attr "length_immediate" "1")
2304    (set_attr "prefix" "vex")
2305    (set_attr "mode" "<ssescalarmode>")])
2307 (define_insn "*<sse>_maskcmp<mode>3_comm"
2308   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
2309         (match_operator:VF_128_256 3 "sse_comparison_operator"
2310           [(match_operand:VF_128_256 1 "register_operand" "%0,x")
2311            (match_operand:VF_128_256 2 "vector_operand" "xBm,xm")]))]
2312   "TARGET_SSE
2313    && GET_RTX_CLASS (GET_CODE (operands[3])) == RTX_COMM_COMPARE"
2314   "@
2315    cmp%D3<ssemodesuffix>\t{%2, %0|%0, %2}
2316    vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2317   [(set_attr "isa" "noavx,avx")
2318    (set_attr "type" "ssecmp")
2319    (set_attr "length_immediate" "1")
2320    (set_attr "prefix" "orig,vex")
2321    (set_attr "mode" "<MODE>")])
2323 (define_insn "<sse>_maskcmp<mode>3"
2324   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x")
2325         (match_operator:VF_128_256 3 "sse_comparison_operator"
2326           [(match_operand:VF_128_256 1 "register_operand" "0,x")
2327            (match_operand:VF_128_256 2 "vector_operand" "xBm,xm")]))]
2328   "TARGET_SSE"
2329   "@
2330    cmp%D3<ssemodesuffix>\t{%2, %0|%0, %2}
2331    vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2332   [(set_attr "isa" "noavx,avx")
2333    (set_attr "type" "ssecmp")
2334    (set_attr "length_immediate" "1")
2335    (set_attr "prefix" "orig,vex")
2336    (set_attr "mode" "<MODE>")])
2338 (define_insn "<sse>_vmmaskcmp<mode>3"
2339   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
2340         (vec_merge:VF_128
2341          (match_operator:VF_128 3 "sse_comparison_operator"
2342            [(match_operand:VF_128 1 "register_operand" "0,x")
2343             (match_operand:VF_128 2 "vector_operand" "xBm,xm")])
2344          (match_dup 1)
2345          (const_int 1)))]
2346   "TARGET_SSE"
2347   "@
2348    cmp%D3<ssescalarmodesuffix>\t{%2, %0|%0, %<iptr>2}
2349    vcmp%D3<ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %<iptr>2}"
2350   [(set_attr "isa" "noavx,avx")
2351    (set_attr "type" "ssecmp")
2352    (set_attr "length_immediate" "1,*")
2353    (set_attr "prefix" "orig,vex")
2354    (set_attr "mode" "<ssescalarmode>")])
2356 (define_mode_attr cmp_imm_predicate
2357   [(V16SF "const_0_to_31_operand")  (V8DF "const_0_to_31_operand")
2358    (V16SI "const_0_to_7_operand")   (V8DI "const_0_to_7_operand")
2359    (V8SF "const_0_to_31_operand")   (V4DF "const_0_to_31_operand")
2360    (V8SI "const_0_to_7_operand")    (V4DI "const_0_to_7_operand")
2361    (V4SF "const_0_to_31_operand")   (V2DF "const_0_to_31_operand")
2362    (V4SI "const_0_to_7_operand")    (V2DI "const_0_to_7_operand")
2363    (V32HI "const_0_to_7_operand")   (V64QI "const_0_to_7_operand")
2364    (V16HI "const_0_to_7_operand")   (V32QI "const_0_to_7_operand")
2365    (V8HI "const_0_to_7_operand")    (V16QI "const_0_to_7_operand")])
2367 (define_insn "<avx512>_cmp<mode>3<mask_scalar_merge_name><round_saeonly_name>"
2368   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2369         (unspec:<avx512fmaskmode>
2370           [(match_operand:V48_AVX512VL 1 "register_operand" "v")
2371            (match_operand:V48_AVX512VL 2 "nonimmediate_operand" "<round_saeonly_constraint>")
2372            (match_operand:SI 3 "<cmp_imm_predicate>" "n")]
2373           UNSPEC_PCMP))]
2374   "TARGET_AVX512F && <round_saeonly_mode512bit_condition>"
2375   "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}"
2376   [(set_attr "type" "ssecmp")
2377    (set_attr "length_immediate" "1")
2378    (set_attr "prefix" "evex")
2379    (set_attr "mode" "<sseinsnmode>")])
2381 (define_insn "<avx512>_cmp<mode>3<mask_scalar_merge_name>"
2382   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2383         (unspec:<avx512fmaskmode>
2384           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
2385            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
2386            (match_operand:SI 3 "<cmp_imm_predicate>" "n")]
2387           UNSPEC_PCMP))]
2388   "TARGET_AVX512BW"
2389   "vpcmp<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2390   [(set_attr "type" "ssecmp")
2391    (set_attr "length_immediate" "1")
2392    (set_attr "prefix" "evex")
2393    (set_attr "mode" "<sseinsnmode>")])
2395 (define_insn "<avx512>_ucmp<mode>3<mask_scalar_merge_name>"
2396   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2397         (unspec:<avx512fmaskmode>
2398           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
2399            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")
2400            (match_operand:SI 3 "const_0_to_7_operand" "n")]
2401           UNSPEC_UNSIGNED_PCMP))]
2402   "TARGET_AVX512BW"
2403   "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2404   [(set_attr "type" "ssecmp")
2405    (set_attr "length_immediate" "1")
2406    (set_attr "prefix" "evex")
2407    (set_attr "mode" "<sseinsnmode>")])
2409 (define_insn "<avx512>_ucmp<mode>3<mask_scalar_merge_name>"
2410   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2411         (unspec:<avx512fmaskmode>
2412           [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
2413            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")
2414            (match_operand:SI 3 "const_0_to_7_operand" "n")]
2415           UNSPEC_UNSIGNED_PCMP))]
2416   "TARGET_AVX512F"
2417   "vpcmpu<ssemodesuffix>\t{%3, %2, %1, %0<mask_scalar_merge_operand4>|%0<mask_scalar_merge_operand4>, %1, %2, %3}"
2418   [(set_attr "type" "ssecmp")
2419    (set_attr "length_immediate" "1")
2420    (set_attr "prefix" "evex")
2421    (set_attr "mode" "<sseinsnmode>")])
2423 (define_insn "avx512f_vmcmp<mode>3<round_saeonly_name>"
2424   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2425         (and:<avx512fmaskmode>
2426           (unspec:<avx512fmaskmode>
2427             [(match_operand:VF_128 1 "register_operand" "v")
2428              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
2429              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2430             UNSPEC_PCMP)
2431           (const_int 1)))]
2432   "TARGET_AVX512F"
2433   "vcmp<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %2<round_saeonly_op4>, %3}"
2434   [(set_attr "type" "ssecmp")
2435    (set_attr "length_immediate" "1")
2436    (set_attr "prefix" "evex")
2437    (set_attr "mode" "<ssescalarmode>")])
2439 (define_insn "avx512f_vmcmp<mode>3_mask<round_saeonly_name>"
2440   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2441         (and:<avx512fmaskmode>
2442           (unspec:<avx512fmaskmode>
2443             [(match_operand:VF_128 1 "register_operand" "v")
2444              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
2445              (match_operand:SI 3 "const_0_to_31_operand" "n")]
2446             UNSPEC_PCMP)
2447           (and:<avx512fmaskmode>
2448             (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")
2449             (const_int 1))))]
2450   "TARGET_AVX512F"
2451   "vcmp<ssescalarmodesuffix>\t{%3, <round_saeonly_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_saeonly_op5>, %3}"
2452   [(set_attr "type" "ssecmp")
2453    (set_attr "length_immediate" "1")
2454    (set_attr "prefix" "evex")
2455    (set_attr "mode" "<ssescalarmode>")])
2457 (define_insn "avx512f_maskcmp<mode>3"
2458   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
2459         (match_operator:<avx512fmaskmode> 3 "sse_comparison_operator"
2460           [(match_operand:VF 1 "register_operand" "v")
2461            (match_operand:VF 2 "nonimmediate_operand" "vm")]))]
2462   "TARGET_AVX512F"
2463   "vcmp%D3<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
2464   [(set_attr "type" "ssecmp")
2465    (set_attr "length_immediate" "1")
2466    (set_attr "prefix" "evex")
2467    (set_attr "mode" "<sseinsnmode>")])
2469 (define_insn "<sse>_comi<round_saeonly_name>"
2470   [(set (reg:CCFP FLAGS_REG)
2471         (compare:CCFP
2472           (vec_select:MODEF
2473             (match_operand:<ssevecmode> 0 "register_operand" "v")
2474             (parallel [(const_int 0)]))
2475           (vec_select:MODEF
2476             (match_operand:<ssevecmode> 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
2477             (parallel [(const_int 0)]))))]
2478   "SSE_FLOAT_MODE_P (<MODE>mode)"
2479   "%vcomi<ssemodesuffix>\t{<round_saeonly_op2>%1, %0|%0, %<iptr>1<round_saeonly_op2>}"
2480   [(set_attr "type" "ssecomi")
2481    (set_attr "prefix" "maybe_vex")
2482    (set_attr "prefix_rep" "0")
2483    (set (attr "prefix_data16")
2484         (if_then_else (eq_attr "mode" "DF")
2485                       (const_string "1")
2486                       (const_string "0")))
2487    (set_attr "mode" "<MODE>")])
2489 (define_insn "<sse>_ucomi<round_saeonly_name>"
2490   [(set (reg:CCFPU FLAGS_REG)
2491         (compare:CCFPU
2492           (vec_select:MODEF
2493             (match_operand:<ssevecmode> 0 "register_operand" "v")
2494             (parallel [(const_int 0)]))
2495           (vec_select:MODEF
2496             (match_operand:<ssevecmode> 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
2497             (parallel [(const_int 0)]))))]
2498   "SSE_FLOAT_MODE_P (<MODE>mode)"
2499   "%vucomi<ssemodesuffix>\t{<round_saeonly_op2>%1, %0|%0, %<iptr>1<round_saeonly_op2>}"
2500   [(set_attr "type" "ssecomi")
2501    (set_attr "prefix" "maybe_vex")
2502    (set_attr "prefix_rep" "0")
2503    (set (attr "prefix_data16")
2504         (if_then_else (eq_attr "mode" "DF")
2505                       (const_string "1")
2506                       (const_string "0")))
2507    (set_attr "mode" "<MODE>")])
2509 (define_expand "vec_cmp<mode><avx512fmaskmodelower>"
2510   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2511         (match_operator:<avx512fmaskmode> 1 ""
2512           [(match_operand:V48_AVX512VL 2 "register_operand")
2513            (match_operand:V48_AVX512VL 3 "nonimmediate_operand")]))]
2514   "TARGET_AVX512F"
2516   bool ok = ix86_expand_mask_vec_cmp (operands);
2517   gcc_assert (ok);
2518   DONE;
2521 (define_expand "vec_cmp<mode><avx512fmaskmodelower>"
2522   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2523         (match_operator:<avx512fmaskmode> 1 ""
2524           [(match_operand:VI12_AVX512VL 2 "register_operand")
2525            (match_operand:VI12_AVX512VL 3 "nonimmediate_operand")]))]
2526   "TARGET_AVX512BW"
2528   bool ok = ix86_expand_mask_vec_cmp (operands);
2529   gcc_assert (ok);
2530   DONE;
2533 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2534   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2535         (match_operator:<sseintvecmode> 1 ""
2536           [(match_operand:VI_256 2 "register_operand")
2537            (match_operand:VI_256 3 "nonimmediate_operand")]))]
2538   "TARGET_AVX2"
2540   bool ok = ix86_expand_int_vec_cmp (operands);
2541   gcc_assert (ok);
2542   DONE;
2545 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2546   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2547         (match_operator:<sseintvecmode> 1 ""
2548           [(match_operand:VI124_128 2 "register_operand")
2549            (match_operand:VI124_128 3 "vector_operand")]))]
2550   "TARGET_SSE2"
2552   bool ok = ix86_expand_int_vec_cmp (operands);
2553   gcc_assert (ok);
2554   DONE;
2557 (define_expand "vec_cmpv2div2di"
2558   [(set (match_operand:V2DI 0 "register_operand")
2559         (match_operator:V2DI 1 ""
2560           [(match_operand:V2DI 2 "register_operand")
2561            (match_operand:V2DI 3 "vector_operand")]))]
2562   "TARGET_SSE4_2"
2564   bool ok = ix86_expand_int_vec_cmp (operands);
2565   gcc_assert (ok);
2566   DONE;
2569 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2570   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2571         (match_operator:<sseintvecmode> 1 ""
2572           [(match_operand:VF_256 2 "register_operand")
2573            (match_operand:VF_256 3 "nonimmediate_operand")]))]
2574   "TARGET_AVX"
2576   bool ok = ix86_expand_fp_vec_cmp (operands);
2577   gcc_assert (ok);
2578   DONE;
2581 (define_expand "vec_cmp<mode><sseintvecmodelower>"
2582   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2583         (match_operator:<sseintvecmode> 1 ""
2584           [(match_operand:VF_128 2 "register_operand")
2585            (match_operand:VF_128 3 "vector_operand")]))]
2586   "TARGET_SSE"
2588   bool ok = ix86_expand_fp_vec_cmp (operands);
2589   gcc_assert (ok);
2590   DONE;
2593 (define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
2594   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2595         (match_operator:<avx512fmaskmode> 1 ""
2596           [(match_operand:VI48_AVX512VL 2 "register_operand")
2597            (match_operand:VI48_AVX512VL 3 "nonimmediate_operand")]))]
2598   "TARGET_AVX512F"
2600   bool ok = ix86_expand_mask_vec_cmp (operands);
2601   gcc_assert (ok);
2602   DONE;
2605 (define_expand "vec_cmpu<mode><avx512fmaskmodelower>"
2606   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
2607         (match_operator:<avx512fmaskmode> 1 ""
2608           [(match_operand:VI12_AVX512VL 2 "register_operand")
2609            (match_operand:VI12_AVX512VL 3 "nonimmediate_operand")]))]
2610   "TARGET_AVX512BW"
2612   bool ok = ix86_expand_mask_vec_cmp (operands);
2613   gcc_assert (ok);
2614   DONE;
2617 (define_expand "vec_cmpu<mode><sseintvecmodelower>"
2618   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2619         (match_operator:<sseintvecmode> 1 ""
2620           [(match_operand:VI_256 2 "register_operand")
2621            (match_operand:VI_256 3 "nonimmediate_operand")]))]
2622   "TARGET_AVX2"
2624   bool ok = ix86_expand_int_vec_cmp (operands);
2625   gcc_assert (ok);
2626   DONE;
2629 (define_expand "vec_cmpu<mode><sseintvecmodelower>"
2630   [(set (match_operand:<sseintvecmode> 0 "register_operand")
2631         (match_operator:<sseintvecmode> 1 ""
2632           [(match_operand:VI124_128 2 "register_operand")
2633            (match_operand:VI124_128 3 "vector_operand")]))]
2634   "TARGET_SSE2"
2636   bool ok = ix86_expand_int_vec_cmp (operands);
2637   gcc_assert (ok);
2638   DONE;
2641 (define_expand "vec_cmpuv2div2di"
2642   [(set (match_operand:V2DI 0 "register_operand")
2643         (match_operator:V2DI 1 ""
2644           [(match_operand:V2DI 2 "register_operand")
2645            (match_operand:V2DI 3 "vector_operand")]))]
2646   "TARGET_SSE4_2"
2648   bool ok = ix86_expand_int_vec_cmp (operands);
2649   gcc_assert (ok);
2650   DONE;
2653 (define_expand "vcond<V_512:mode><VF_512:mode>"
2654   [(set (match_operand:V_512 0 "register_operand")
2655         (if_then_else:V_512
2656           (match_operator 3 ""
2657             [(match_operand:VF_512 4 "nonimmediate_operand")
2658              (match_operand:VF_512 5 "nonimmediate_operand")])
2659           (match_operand:V_512 1 "general_operand")
2660           (match_operand:V_512 2 "general_operand")))]
2661   "TARGET_AVX512F
2662    && (GET_MODE_NUNITS (<V_512:MODE>mode)
2663        == GET_MODE_NUNITS (<VF_512:MODE>mode))"
2665   bool ok = ix86_expand_fp_vcond (operands);
2666   gcc_assert (ok);
2667   DONE;
2670 (define_expand "vcond<V_256:mode><VF_256:mode>"
2671   [(set (match_operand:V_256 0 "register_operand")
2672         (if_then_else:V_256
2673           (match_operator 3 ""
2674             [(match_operand:VF_256 4 "nonimmediate_operand")
2675              (match_operand:VF_256 5 "nonimmediate_operand")])
2676           (match_operand:V_256 1 "general_operand")
2677           (match_operand:V_256 2 "general_operand")))]
2678   "TARGET_AVX
2679    && (GET_MODE_NUNITS (<V_256:MODE>mode)
2680        == GET_MODE_NUNITS (<VF_256:MODE>mode))"
2682   bool ok = ix86_expand_fp_vcond (operands);
2683   gcc_assert (ok);
2684   DONE;
2687 (define_expand "vcond<V_128:mode><VF_128:mode>"
2688   [(set (match_operand:V_128 0 "register_operand")
2689         (if_then_else:V_128
2690           (match_operator 3 ""
2691             [(match_operand:VF_128 4 "vector_operand")
2692              (match_operand:VF_128 5 "vector_operand")])
2693           (match_operand:V_128 1 "general_operand")
2694           (match_operand:V_128 2 "general_operand")))]
2695   "TARGET_SSE
2696    && (GET_MODE_NUNITS (<V_128:MODE>mode)
2697        == GET_MODE_NUNITS (<VF_128:MODE>mode))"
2699   bool ok = ix86_expand_fp_vcond (operands);
2700   gcc_assert (ok);
2701   DONE;
2704 (define_expand "vcond_mask_<mode><avx512fmaskmodelower>"
2705   [(set (match_operand:V48_AVX512VL 0 "register_operand")
2706         (vec_merge:V48_AVX512VL
2707           (match_operand:V48_AVX512VL 1 "nonimmediate_operand")
2708           (match_operand:V48_AVX512VL 2 "vector_move_operand")
2709           (match_operand:<avx512fmaskmode> 3 "register_operand")))]
2710   "TARGET_AVX512F")
2712 (define_expand "vcond_mask_<mode><avx512fmaskmodelower>"
2713   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
2714         (vec_merge:VI12_AVX512VL
2715           (match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
2716           (match_operand:VI12_AVX512VL 2 "vector_move_operand")
2717           (match_operand:<avx512fmaskmode> 3 "register_operand")))]
2718   "TARGET_AVX512BW")
2720 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
2721   [(set (match_operand:VI_256 0 "register_operand")
2722         (vec_merge:VI_256
2723           (match_operand:VI_256 1 "nonimmediate_operand")
2724           (match_operand:VI_256 2 "vector_move_operand")
2725           (match_operand:<sseintvecmode> 3 "register_operand")))]
2726   "TARGET_AVX2"
2728   ix86_expand_sse_movcc (operands[0], operands[3],
2729                          operands[1], operands[2]);
2730   DONE;
2733 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
2734   [(set (match_operand:VI124_128 0 "register_operand")
2735         (vec_merge:VI124_128
2736           (match_operand:VI124_128 1 "vector_operand")
2737           (match_operand:VI124_128 2 "vector_move_operand")
2738           (match_operand:<sseintvecmode> 3 "register_operand")))]
2739   "TARGET_SSE2"
2741   ix86_expand_sse_movcc (operands[0], operands[3],
2742                          operands[1], operands[2]);
2743   DONE;
2746 (define_expand "vcond_mask_v2div2di"
2747   [(set (match_operand:V2DI 0 "register_operand")
2748         (vec_merge:V2DI
2749           (match_operand:V2DI 1 "vector_operand")
2750           (match_operand:V2DI 2 "vector_move_operand")
2751           (match_operand:V2DI 3 "register_operand")))]
2752   "TARGET_SSE4_2"
2754   ix86_expand_sse_movcc (operands[0], operands[3],
2755                          operands[1], operands[2]);
2756   DONE;
2759 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
2760   [(set (match_operand:VF_256 0 "register_operand")
2761         (vec_merge:VF_256
2762           (match_operand:VF_256 1 "nonimmediate_operand")
2763           (match_operand:VF_256 2 "vector_move_operand")
2764           (match_operand:<sseintvecmode> 3 "register_operand")))]
2765   "TARGET_AVX"
2767   ix86_expand_sse_movcc (operands[0], operands[3],
2768                          operands[1], operands[2]);
2769   DONE;
2772 (define_expand "vcond_mask_<mode><sseintvecmodelower>"
2773   [(set (match_operand:VF_128 0 "register_operand")
2774         (vec_merge:VF_128
2775           (match_operand:VF_128 1 "vector_operand")
2776           (match_operand:VF_128 2 "vector_move_operand")
2777           (match_operand:<sseintvecmode> 3 "register_operand")))]
2778   "TARGET_SSE"
2780   ix86_expand_sse_movcc (operands[0], operands[3],
2781                          operands[1], operands[2]);
2782   DONE;
2785 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2787 ;; Parallel floating point logical operations
2789 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2791 (define_insn "<sse>_andnot<mode>3<mask_name>"
2792   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x,v,v")
2793         (and:VF_128_256
2794           (not:VF_128_256
2795             (match_operand:VF_128_256 1 "register_operand" "0,x,v,v"))
2796           (match_operand:VF_128_256 2 "vector_operand" "xBm,xm,vm,vm")))]
2797   "TARGET_SSE && <mask_avx512vl_condition>"
2799   static char buf[128];
2800   const char *ops;
2801   const char *suffix;
2803   switch (which_alternative)
2804     {
2805     case 0:
2806       ops = "andn%s\t{%%2, %%0|%%0, %%2}";
2807       break;
2808     case 1:
2809     case 2:
2810     case 3:
2811       ops = "vandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
2812       break;
2813     default:
2814       gcc_unreachable ();
2815     }
2817   switch (get_attr_mode (insn))
2818     {
2819     case MODE_V8SF:
2820     case MODE_V4SF:
2821       suffix = "ps";
2822       break;
2823     case MODE_OI:
2824     case MODE_TI:
2825       /* There is no vandnp[sd] in avx512f.  Use vpandn[qd].  */
2826       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
2827       ops = "vpandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
2828       break;
2829     default:
2830       suffix = "<ssemodesuffix>";
2831     }
2833   snprintf (buf, sizeof (buf), ops, suffix);
2834   return buf;
2836   [(set_attr "isa" "noavx,avx,avx512dq,avx512f")
2837    (set_attr "type" "sselog")
2838    (set_attr "prefix" "orig,maybe_vex,evex,evex")
2839    (set (attr "mode")
2840         (cond [(and (match_test "<mask_applied>")
2841                     (and (eq_attr "alternative" "1")
2842                          (match_test "!TARGET_AVX512DQ")))
2843                  (const_string "<sseintvecmode2>")
2844                (eq_attr "alternative" "3")
2845                  (const_string "<sseintvecmode2>")
2846                (and (match_test "<MODE_SIZE> == 16")
2847                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
2848                  (const_string "<ssePSmode>")
2849                (match_test "TARGET_AVX")
2850                  (const_string "<MODE>")
2851                (match_test "optimize_function_for_size_p (cfun)")
2852                  (const_string "V4SF")
2853                ]
2854                (const_string "<MODE>")))])
2857 (define_insn "<sse>_andnot<mode>3<mask_name>"
2858   [(set (match_operand:VF_512 0 "register_operand" "=v")
2859         (and:VF_512
2860           (not:VF_512
2861             (match_operand:VF_512 1 "register_operand" "v"))
2862           (match_operand:VF_512 2 "nonimmediate_operand" "vm")))]
2863   "TARGET_AVX512F"
2865   static char buf[128];
2866   const char *ops;
2867   const char *suffix;
2869   suffix = "<ssemodesuffix>";
2870   ops = "";
2872   /* There is no vandnp[sd] in avx512f.  Use vpandn[qd].  */
2873   if (!TARGET_AVX512DQ)
2874     {
2875       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
2876       ops = "p";
2877     }
2879   snprintf (buf, sizeof (buf),
2880             "v%sandn%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}",
2881             ops, suffix);
2882   return buf;
2884   [(set_attr "type" "sselog")
2885    (set_attr "prefix" "evex")
2886    (set (attr "mode")
2887         (if_then_else (match_test "TARGET_AVX512DQ")
2888                       (const_string "<sseinsnmode>")
2889                       (const_string "XI")))])
2891 (define_expand "<code><mode>3<mask_name>"
2892   [(set (match_operand:VF_128_256 0 "register_operand")
2893        (any_logic:VF_128_256
2894          (match_operand:VF_128_256 1 "vector_operand")
2895          (match_operand:VF_128_256 2 "vector_operand")))]
2896   "TARGET_SSE && <mask_avx512vl_condition>"
2897   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
2899 (define_expand "<code><mode>3<mask_name>"
2900   [(set (match_operand:VF_512 0 "register_operand")
2901        (any_logic:VF_512
2902          (match_operand:VF_512 1 "nonimmediate_operand")
2903          (match_operand:VF_512 2 "nonimmediate_operand")))]
2904   "TARGET_AVX512F"
2905   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
2907 (define_insn "*<code><mode>3<mask_name>"
2908   [(set (match_operand:VF_128_256 0 "register_operand" "=x,x,v,v")
2909         (any_logic:VF_128_256
2910           (match_operand:VF_128_256 1 "vector_operand" "%0,x,v,v")
2911           (match_operand:VF_128_256 2 "vector_operand" "xBm,xm,vm,vm")))]
2912   "TARGET_SSE && <mask_avx512vl_condition>
2913    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
2915   static char buf[128];
2916   const char *ops;
2917   const char *suffix;
2919   switch (which_alternative)
2920     {
2921     case 0:
2922       ops = "<logic>%s\t{%%2, %%0|%%0, %%2}";
2923       break;
2924     case 1:
2925     case 2:
2926     case 3:
2927       ops = "v<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
2928       break;
2929     default:
2930       gcc_unreachable ();
2931     }
2933   switch (get_attr_mode (insn))
2934     {
2935     case MODE_V8SF:
2936     case MODE_V4SF:
2937       suffix = "ps";
2938       break;
2939     case MODE_OI:
2940     case MODE_TI:
2941       /* There is no v<logic>p[sd] in avx512f.  Use vp<logic>[qd].  */
2942       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
2943       ops = "vp<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
2944       break;
2945     default:
2946       suffix = "<ssemodesuffix>";
2947     }
2949   snprintf (buf, sizeof (buf), ops, suffix);
2950   return buf;
2952   [(set_attr "isa" "noavx,avx,avx512dq,avx512f")
2953    (set_attr "type" "sselog")
2954    (set_attr "prefix" "orig,maybe_evex,evex,evex")
2955    (set (attr "mode")
2956         (cond [(and (match_test "<mask_applied>")
2957                     (and (eq_attr "alternative" "1")
2958                          (match_test "!TARGET_AVX512DQ")))
2959                  (const_string "<sseintvecmode2>")
2960                (eq_attr "alternative" "3")
2961                  (const_string "<sseintvecmode2>")
2962                (and (match_test "<MODE_SIZE> == 16")
2963                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
2964                  (const_string "<ssePSmode>")
2965                (match_test "TARGET_AVX")
2966                  (const_string "<MODE>")
2967                (match_test "optimize_function_for_size_p (cfun)")
2968                  (const_string "V4SF")
2969                ]
2970                (const_string "<MODE>")))])
2972 (define_insn "*<code><mode>3<mask_name>"
2973   [(set (match_operand:VF_512 0 "register_operand" "=v")
2974         (any_logic:VF_512
2975           (match_operand:VF_512 1 "nonimmediate_operand" "%v")
2976           (match_operand:VF_512 2 "nonimmediate_operand" "vm")))]
2977   "TARGET_AVX512F && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
2979   static char buf[128];
2980   const char *ops;
2981   const char *suffix;
2983   suffix = "<ssemodesuffix>";
2984   ops = "";
2986   /* There is no v<logic>p[sd] in avx512f.  Use vp<logic>[dq].  */
2987   if (!TARGET_AVX512DQ)
2988     {
2989       suffix = GET_MODE_INNER (<MODE>mode) == DFmode ? "q" : "d";
2990       ops = "p";
2991     }
2993   snprintf (buf, sizeof (buf),
2994            "v%s<logic>%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}",
2995            ops, suffix);
2996   return buf;
2998   [(set_attr "type" "sselog")
2999    (set_attr "prefix" "evex")
3000    (set (attr "mode")
3001         (if_then_else (match_test "TARGET_AVX512DQ")
3002                       (const_string "<sseinsnmode>")
3003                       (const_string "XI")))])
3005 (define_expand "copysign<mode>3"
3006   [(set (match_dup 4)
3007         (and:VF
3008           (not:VF (match_dup 3))
3009           (match_operand:VF 1 "vector_operand")))
3010    (set (match_dup 5)
3011         (and:VF (match_dup 3)
3012                 (match_operand:VF 2 "vector_operand")))
3013    (set (match_operand:VF 0 "register_operand")
3014         (ior:VF (match_dup 4) (match_dup 5)))]
3015   "TARGET_SSE"
3017   operands[3] = ix86_build_signbit_mask (<MODE>mode, 1, 0);
3019   operands[4] = gen_reg_rtx (<MODE>mode);
3020   operands[5] = gen_reg_rtx (<MODE>mode);
3023 ;; Also define scalar versions.  These are used for abs, neg, and
3024 ;; conditional move.  Using subregs into vector modes causes register
3025 ;; allocation lossage.  These patterns do not allow memory operands
3026 ;; because the native instructions read the full 128-bits.
3028 (define_insn "*andnot<mode>3"
3029   [(set (match_operand:MODEF 0 "register_operand" "=x,x,v,v")
3030         (and:MODEF
3031           (not:MODEF
3032             (match_operand:MODEF 1 "register_operand" "0,x,v,v"))
3033             (match_operand:MODEF 2 "register_operand" "x,x,v,v")))]
3034   "SSE_FLOAT_MODE_P (<MODE>mode)"
3036   static char buf[128];
3037   const char *ops;
3038   const char *suffix
3039     = (get_attr_mode (insn) == MODE_V4SF) ? "ps" : "<ssevecmodesuffix>";
3041   switch (which_alternative)
3042     {
3043     case 0:
3044       ops = "andn%s\t{%%2, %%0|%%0, %%2}";
3045       break;
3046     case 1:
3047       ops = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3048       break;
3049     case 2:
3050       if (TARGET_AVX512DQ)
3051         ops = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3052       else
3053         {
3054           suffix = <MODE>mode == DFmode ? "q" : "d";
3055           ops = "vpandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3056         }
3057       break;
3058     case 3:
3059       if (TARGET_AVX512DQ)
3060         ops = "vandn%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3061       else
3062         {
3063           suffix = <MODE>mode == DFmode ? "q" : "d";
3064           ops = "vpandn%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3065         }
3066       break;
3067     default:
3068       gcc_unreachable ();
3069     }
3071   snprintf (buf, sizeof (buf), ops, suffix);
3072   return buf;
3074   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3075    (set_attr "type" "sselog")
3076    (set_attr "prefix" "orig,vex,evex,evex")
3077    (set (attr "mode")
3078         (cond [(eq_attr "alternative" "2")
3079                  (if_then_else (match_test "TARGET_AVX512DQ")
3080                                (const_string "<ssevecmode>")
3081                                (const_string "TI"))
3082                (eq_attr "alternative" "3")
3083                  (if_then_else (match_test "TARGET_AVX512DQ")
3084                                (const_string "<avx512fvecmode>")
3085                                (const_string "XI"))
3086                (and (match_test "<MODE_SIZE> == 16")
3087                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3088                  (const_string "V4SF")
3089                (match_test "TARGET_AVX")
3090                  (const_string "<ssevecmode>")
3091                (match_test "optimize_function_for_size_p (cfun)")
3092                  (const_string "V4SF")
3093                ]
3094                (const_string "<ssevecmode>")))])
3096 (define_insn "*andnottf3"
3097   [(set (match_operand:TF 0 "register_operand" "=x,x,v,v")
3098         (and:TF
3099           (not:TF (match_operand:TF 1 "register_operand" "0,x,v,v"))
3100           (match_operand:TF 2 "vector_operand" "xBm,xm,vm,v")))]
3101   "TARGET_SSE"
3103   static char buf[128];
3104   const char *ops;
3105   const char *tmp
3106     = (which_alternative >= 2 ? "pandnq"
3107        : get_attr_mode (insn) == MODE_V4SF ? "andnps" : "pandn");
3109   switch (which_alternative)
3110     {
3111     case 0:
3112       ops = "%s\t{%%2, %%0|%%0, %%2}";
3113       break;
3114     case 1:
3115     case 2:
3116       ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3117       break;
3118     case 3:
3119       ops = "v%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3120       break;
3121     default:
3122       gcc_unreachable ();
3123     }
3125   snprintf (buf, sizeof (buf), ops, tmp);
3126   return buf;
3128   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3129    (set_attr "type" "sselog")
3130    (set (attr "prefix_data16")
3131      (if_then_else
3132        (and (eq_attr "alternative" "0")
3133             (eq_attr "mode" "TI"))
3134        (const_string "1")
3135        (const_string "*")))
3136    (set_attr "prefix" "orig,vex,evex,evex")
3137    (set (attr "mode")
3138         (cond [(eq_attr "alternative" "2")
3139                  (const_string "TI")
3140                (eq_attr "alternative" "3")
3141                  (const_string "XI")
3142                (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
3143                  (const_string "V4SF")
3144                (match_test "TARGET_AVX")
3145                  (const_string "TI")
3146                (ior (not (match_test "TARGET_SSE2"))
3147                     (match_test "optimize_function_for_size_p (cfun)"))
3148                  (const_string "V4SF")
3149                ]
3150                (const_string "TI")))])
3152 (define_insn "*<code><mode>3"
3153   [(set (match_operand:MODEF 0 "register_operand" "=x,x,v,v")
3154         (any_logic:MODEF
3155           (match_operand:MODEF 1 "register_operand" "%0,x,v,v")
3156           (match_operand:MODEF 2 "register_operand" "x,x,v,v")))]
3157   "SSE_FLOAT_MODE_P (<MODE>mode)"
3159   static char buf[128];
3160   const char *ops;
3161   const char *suffix
3162     = (get_attr_mode (insn) == MODE_V4SF) ? "ps" : "<ssevecmodesuffix>";
3164   switch (which_alternative)
3165     {
3166     case 0:
3167       ops = "<logic>%s\t{%%2, %%0|%%0, %%2}";
3168       break;
3169     case 2:
3170       if (!TARGET_AVX512DQ)
3171         {
3172           suffix = <MODE>mode == DFmode ? "q" : "d";
3173           ops = "vp<logic>%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3174           break;
3175         }
3176       /* FALLTHRU */
3177     case 1:
3178       ops = "v<logic>%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3179       break;
3180     case 3:
3181       if (TARGET_AVX512DQ)
3182         ops = "v<logic>%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3183       else
3184         {
3185           suffix = <MODE>mode == DFmode ? "q" : "d";
3186           ops = "vp<logic>%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3187         }
3188       break;
3189     default:
3190       gcc_unreachable ();
3191     }
3193   snprintf (buf, sizeof (buf), ops, suffix);
3194   return buf;
3196   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3197    (set_attr "type" "sselog")
3198    (set_attr "prefix" "orig,vex,evex,evex")
3199    (set (attr "mode")
3200         (cond [(eq_attr "alternative" "2")
3201                  (if_then_else (match_test "TARGET_AVX512DQ")
3202                                (const_string "<ssevecmode>")
3203                                (const_string "TI"))
3204                (eq_attr "alternative" "3")
3205                  (if_then_else (match_test "TARGET_AVX512DQ")
3206                                (const_string "<avx512fvecmode>")
3207                                (const_string "XI"))
3208                (and (match_test "<MODE_SIZE> == 16")
3209                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
3210                  (const_string "V4SF")
3211                (match_test "TARGET_AVX")
3212                  (const_string "<ssevecmode>")
3213                (match_test "optimize_function_for_size_p (cfun)")
3214                  (const_string "V4SF")
3215                ]
3216                (const_string "<ssevecmode>")))])
3218 (define_expand "<code>tf3"
3219   [(set (match_operand:TF 0 "register_operand")
3220         (any_logic:TF
3221           (match_operand:TF 1 "vector_operand")
3222           (match_operand:TF 2 "vector_operand")))]
3223   "TARGET_SSE"
3224   "ix86_fixup_binary_operands_no_copy (<CODE>, TFmode, operands);")
3226 (define_insn "*<code>tf3"
3227   [(set (match_operand:TF 0 "register_operand" "=x,x,v,v")
3228         (any_logic:TF
3229           (match_operand:TF 1 "vector_operand" "%0,x,v,v")
3230           (match_operand:TF 2 "vector_operand" "xBm,xm,vm,v")))]
3231   "TARGET_SSE
3232    && ix86_binary_operator_ok (<CODE>, TFmode, operands)"
3234   static char buf[128];
3235   const char *ops;
3236   const char *tmp
3237     = (which_alternative >= 2 ? "p<logic>q"
3238        : get_attr_mode (insn) == MODE_V4SF ? "<logic>ps" : "p<logic>");
3240   switch (which_alternative)
3241     {
3242     case 0:
3243       ops = "%s\t{%%2, %%0|%%0, %%2}";
3244       break;
3245     case 1:
3246     case 2:
3247       ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
3248       break;
3249     case 3:
3250       ops = "v%s\t{%%g2, %%g1, %%g0|%%g0, %%g1, %%g2}";
3251       break;
3252     default:
3253       gcc_unreachable ();
3254     }
3256   snprintf (buf, sizeof (buf), ops, tmp);
3257   return buf;
3259   [(set_attr "isa" "noavx,avx,avx512vl,avx512f")
3260    (set_attr "type" "sselog")
3261    (set (attr "prefix_data16")
3262      (if_then_else
3263        (and (eq_attr "alternative" "0")
3264             (eq_attr "mode" "TI"))
3265        (const_string "1")
3266        (const_string "*")))
3267    (set_attr "prefix" "orig,vex,evex,evex")
3268    (set (attr "mode")
3269         (cond [(eq_attr "alternative" "2")
3270                  (const_string "TI")
3271                (eq_attr "alternative" "3")
3272                  (const_string "QI")
3273                (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
3274                  (const_string "V4SF")
3275                (match_test "TARGET_AVX")
3276                  (const_string "TI")
3277                (ior (not (match_test "TARGET_SSE2"))
3278                     (match_test "optimize_function_for_size_p (cfun)"))
3279                  (const_string "V4SF")
3280                ]
3281                (const_string "TI")))])
3283 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3285 ;; FMA floating point multiply/accumulate instructions.  These include
3286 ;; scalar versions of the instructions as well as vector versions.
3288 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3290 ;; The standard names for scalar FMA are only available with SSE math enabled.
3291 ;; CPUID bit AVX512F enables evex encoded scalar and 512-bit fma.  It doesn't
3292 ;; care about FMA bit, so we enable fma for TARGET_AVX512F even when TARGET_FMA
3293 ;; and TARGET_FMA4 are both false.
3294 ;; TODO: In theory AVX512F does not automatically imply FMA, and without FMA
3295 ;; one must force the EVEX encoding of the fma insns.  Ideally we'd improve
3296 ;; GAS to allow proper prefix selection.  However, for the moment all hardware
3297 ;; that supports AVX512F also supports FMA so we can ignore this for now.
3298 (define_mode_iterator FMAMODEM
3299   [(SF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
3300    (DF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
3301    (V4SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3302    (V2DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3303    (V8SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3304    (V4DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3305    (V16SF "TARGET_AVX512F")
3306    (V8DF "TARGET_AVX512F")])
3308 (define_expand "fma<mode>4"
3309   [(set (match_operand:FMAMODEM 0 "register_operand")
3310         (fma:FMAMODEM
3311           (match_operand:FMAMODEM 1 "nonimmediate_operand")
3312           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3313           (match_operand:FMAMODEM 3 "nonimmediate_operand")))])
3315 (define_expand "fms<mode>4"
3316   [(set (match_operand:FMAMODEM 0 "register_operand")
3317         (fma:FMAMODEM
3318           (match_operand:FMAMODEM 1 "nonimmediate_operand")
3319           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3320           (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))])
3322 (define_expand "fnma<mode>4"
3323   [(set (match_operand:FMAMODEM 0 "register_operand")
3324         (fma:FMAMODEM
3325           (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
3326           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3327           (match_operand:FMAMODEM 3 "nonimmediate_operand")))])
3329 (define_expand "fnms<mode>4"
3330   [(set (match_operand:FMAMODEM 0 "register_operand")
3331         (fma:FMAMODEM
3332           (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
3333           (match_operand:FMAMODEM 2 "nonimmediate_operand")
3334           (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))])
3336 ;; The builtins for intrinsics are not constrained by SSE math enabled.
3337 (define_mode_iterator FMAMODE_AVX512
3338  [(SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
3339   (DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
3340   (V4SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3341   (V2DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3342   (V8SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3343   (V4DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512VL")
3344   (V16SF "TARGET_AVX512F")
3345   (V8DF "TARGET_AVX512F")])
3347 (define_mode_iterator FMAMODE
3348   [SF DF V4SF V2DF V8SF V4DF])
3350 (define_expand "fma4i_fmadd_<mode>"
3351   [(set (match_operand:FMAMODE_AVX512 0 "register_operand")
3352         (fma:FMAMODE_AVX512
3353           (match_operand:FMAMODE_AVX512 1 "nonimmediate_operand")
3354           (match_operand:FMAMODE_AVX512 2 "nonimmediate_operand")
3355           (match_operand:FMAMODE_AVX512 3 "nonimmediate_operand")))])
3357 (define_expand "<avx512>_fmadd_<mode>_maskz<round_expand_name>"
3358   [(match_operand:VF_AVX512VL 0 "register_operand")
3359    (match_operand:VF_AVX512VL 1 "<round_expand_nimm_predicate>")
3360    (match_operand:VF_AVX512VL 2 "<round_expand_nimm_predicate>")
3361    (match_operand:VF_AVX512VL 3 "<round_expand_nimm_predicate>")
3362    (match_operand:<avx512fmaskmode> 4 "register_operand")]
3363   "TARGET_AVX512F && <round_mode512bit_condition>"
3365   emit_insn (gen_fma_fmadd_<mode>_maskz_1<round_expand_name> (
3366     operands[0], operands[1], operands[2], operands[3],
3367     CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
3368   DONE;
3371 (define_insn "*fma_fmadd_<mode>"
3372   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3373         (fma:FMAMODE
3374           (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x")
3375           (match_operand:FMAMODE 2 "nonimmediate_operand" "vm,v,vm,x,m")
3376           (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x")))]
3377   "TARGET_FMA || TARGET_FMA4"
3378   "@
3379    vfmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3380    vfmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3381    vfmadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3382    vfmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3383    vfmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3384   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3385    (set_attr "type" "ssemuladd")
3386    (set_attr "mode" "<MODE>")])
3388 ;; Suppose AVX-512F as baseline
3389 (define_mode_iterator VF_SF_AVX512VL
3390   [SF V16SF (V8SF "TARGET_AVX512VL") (V4SF "TARGET_AVX512VL")
3391    DF V8DF (V4DF "TARGET_AVX512VL") (V2DF "TARGET_AVX512VL")])
3393 (define_insn "<sd_mask_codefor>fma_fmadd_<mode><sd_maskz_name><round_name>"
3394   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3395         (fma:VF_SF_AVX512VL
3396           (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v")
3397           (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3398           (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0")))]
3399   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3400   "@
3401    vfmadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3402    vfmadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3403    vfmadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3404   [(set_attr "type" "ssemuladd")
3405    (set_attr "mode" "<MODE>")])
3407 (define_insn "<avx512>_fmadd_<mode>_mask<round_name>"
3408   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3409         (vec_merge:VF_AVX512VL
3410           (fma:VF_AVX512VL
3411             (match_operand:VF_AVX512VL 1 "register_operand" "0,0")
3412             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3413             (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))
3414           (match_dup 1)
3415           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3416   "TARGET_AVX512F && <round_mode512bit_condition>"
3417   "@
3418    vfmadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3419    vfmadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3420   [(set_attr "isa" "fma_avx512f,fma_avx512f")
3421    (set_attr "type" "ssemuladd")
3422    (set_attr "mode" "<MODE>")])
3424 (define_insn "<avx512>_fmadd_<mode>_mask3<round_name>"
3425   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3426         (vec_merge:VF_AVX512VL
3427           (fma:VF_AVX512VL
3428             (match_operand:VF_AVX512VL 1 "register_operand" "v")
3429             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3430             (match_operand:VF_AVX512VL 3 "register_operand" "0"))
3431           (match_dup 3)
3432           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3433   "TARGET_AVX512F"
3434   "vfmadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3435   [(set_attr "isa" "fma_avx512f")
3436    (set_attr "type" "ssemuladd")
3437    (set_attr "mode" "<MODE>")])
3439 (define_insn "*fma_fmsub_<mode>"
3440   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3441         (fma:FMAMODE
3442           (match_operand:FMAMODE   1 "nonimmediate_operand" "%0,0,v,x,x")
3443           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
3444           (neg:FMAMODE
3445             (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x"))))]
3446   "TARGET_FMA || TARGET_FMA4"
3447   "@
3448    vfmsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3449    vfmsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3450    vfmsub231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3451    vfmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3452    vfmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3453   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3454    (set_attr "type" "ssemuladd")
3455    (set_attr "mode" "<MODE>")])
3457 (define_insn "<sd_mask_codefor>fma_fmsub_<mode><sd_maskz_name><round_name>"
3458   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3459         (fma:VF_SF_AVX512VL
3460           (match_operand:VF_SF_AVX512VL   1 "<round_nimm_predicate>" "%0,0,v")
3461           (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3462           (neg:VF_SF_AVX512VL
3463             (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))))]
3464   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3465   "@
3466    vfmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3467    vfmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3468    vfmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3469   [(set_attr "type" "ssemuladd")
3470    (set_attr "mode" "<MODE>")])
3472 (define_insn "<avx512>_fmsub_<mode>_mask<round_name>"
3473   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3474         (vec_merge:VF_AVX512VL
3475           (fma:VF_AVX512VL
3476             (match_operand:VF_AVX512VL 1 "register_operand" "0,0")
3477             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3478             (neg:VF_AVX512VL
3479               (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")))
3480           (match_dup 1)
3481           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3482   "TARGET_AVX512F"
3483   "@
3484    vfmsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3485    vfmsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3486   [(set_attr "isa" "fma_avx512f,fma_avx512f")
3487    (set_attr "type" "ssemuladd")
3488    (set_attr "mode" "<MODE>")])
3490 (define_insn "<avx512>_fmsub_<mode>_mask3<round_name>"
3491   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3492         (vec_merge:VF_AVX512VL
3493           (fma:VF_AVX512VL
3494             (match_operand:VF_AVX512VL 1 "register_operand" "v")
3495             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3496             (neg:VF_AVX512VL
3497               (match_operand:VF_AVX512VL 3 "register_operand" "0")))
3498           (match_dup 3)
3499           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3500   "TARGET_AVX512F && <round_mode512bit_condition>"
3501   "vfmsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3502   [(set_attr "isa" "fma_avx512f")
3503    (set_attr "type" "ssemuladd")
3504    (set_attr "mode" "<MODE>")])
3506 (define_insn "*fma_fnmadd_<mode>"
3507   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3508         (fma:FMAMODE
3509           (neg:FMAMODE
3510             (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x"))
3511           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
3512           (match_operand:FMAMODE   3 "nonimmediate_operand" "v,vm,0,xm,x")))]
3513   "TARGET_FMA || TARGET_FMA4"
3514   "@
3515    vfnmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3516    vfnmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3517    vfnmadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3518    vfnmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3519    vfnmadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3520   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3521    (set_attr "type" "ssemuladd")
3522    (set_attr "mode" "<MODE>")])
3524 (define_insn "<sd_mask_codefor>fma_fnmadd_<mode><sd_maskz_name><round_name>"
3525   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3526         (fma:VF_SF_AVX512VL
3527           (neg:VF_SF_AVX512VL
3528             (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v"))
3529           (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3530           (match_operand:VF_SF_AVX512VL   3 "<round_nimm_predicate>" "v,<round_constraint>,0")))]
3531   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3532   "@
3533    vfnmadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3534    vfnmadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3535    vfnmadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3536   [(set_attr "type" "ssemuladd")
3537    (set_attr "mode" "<MODE>")])
3539 (define_insn "<avx512>_fnmadd_<mode>_mask<round_name>"
3540   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3541         (vec_merge:VF_AVX512VL
3542           (fma:VF_AVX512VL
3543             (neg:VF_AVX512VL
3544               (match_operand:VF_AVX512VL 1 "register_operand" "0,0"))
3545             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3546             (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))
3547           (match_dup 1)
3548           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3549   "TARGET_AVX512F && <round_mode512bit_condition>"
3550   "@
3551    vfnmadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3552    vfnmadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3553   [(set_attr "isa" "fma_avx512f,fma_avx512f")
3554    (set_attr "type" "ssemuladd")
3555    (set_attr "mode" "<MODE>")])
3557 (define_insn "<avx512>_fnmadd_<mode>_mask3<round_name>"
3558   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3559         (vec_merge:VF_AVX512VL
3560           (fma:VF_AVX512VL
3561             (neg:VF_AVX512VL
3562               (match_operand:VF_AVX512VL 1 "register_operand" "v"))
3563             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3564             (match_operand:VF_AVX512VL 3 "register_operand" "0"))
3565           (match_dup 3)
3566           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3567   "TARGET_AVX512F && <round_mode512bit_condition>"
3568   "vfnmadd231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3569   [(set_attr "isa" "fma_avx512f")
3570    (set_attr "type" "ssemuladd")
3571    (set_attr "mode" "<MODE>")])
3573 (define_insn "*fma_fnmsub_<mode>"
3574   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
3575         (fma:FMAMODE
3576           (neg:FMAMODE
3577             (match_operand:FMAMODE 1 "nonimmediate_operand" "%0,0,v,x,x"))
3578           (match_operand:FMAMODE   2 "nonimmediate_operand" "vm,v,vm,x,m")
3579           (neg:FMAMODE
3580             (match_operand:FMAMODE 3 "nonimmediate_operand" "v,vm,0,xm,x"))))]
3581   "TARGET_FMA || TARGET_FMA4"
3582   "@
3583    vfnmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3584    vfnmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3585    vfnmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}
3586    vfnmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3587    vfnmsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3588   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3589    (set_attr "type" "ssemuladd")
3590    (set_attr "mode" "<MODE>")])
3592 (define_insn "<sd_mask_codefor>fma_fnmsub_<mode><sd_maskz_name><round_name>"
3593   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3594         (fma:VF_SF_AVX512VL
3595           (neg:VF_SF_AVX512VL
3596             (match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v"))
3597           (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3598           (neg:VF_SF_AVX512VL
3599             (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))))]
3600   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3601   "@
3602    vfnmsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3603    vfnmsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3604    vfnmsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3605   [(set_attr "type" "ssemuladd")
3606    (set_attr "mode" "<MODE>")])
3608 (define_insn "<avx512>_fnmsub_<mode>_mask<round_name>"
3609   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3610         (vec_merge:VF_AVX512VL
3611           (fma:VF_AVX512VL
3612             (neg:VF_AVX512VL
3613               (match_operand:VF_AVX512VL 1 "register_operand" "0,0"))
3614             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3615             (neg:VF_AVX512VL
3616               (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")))
3617           (match_dup 1)
3618           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3619   "TARGET_AVX512F && <round_mode512bit_condition>"
3620   "@
3621    vfnmsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3622    vfnmsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3623   [(set_attr "isa" "fma_avx512f,fma_avx512f")
3624    (set_attr "type" "ssemuladd")
3625    (set_attr "mode" "<MODE>")])
3627 (define_insn "<avx512>_fnmsub_<mode>_mask3<round_name>"
3628   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3629         (vec_merge:VF_AVX512VL
3630           (fma:VF_AVX512VL
3631             (neg:VF_AVX512VL
3632               (match_operand:VF_AVX512VL 1 "register_operand" "v"))
3633             (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3634             (neg:VF_AVX512VL
3635               (match_operand:VF_AVX512VL 3 "register_operand" "0")))
3636           (match_dup 3)
3637           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3638   "TARGET_AVX512F"
3639   "vfnmsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3640   [(set_attr "isa" "fma_avx512f")
3641    (set_attr "type" "ssemuladd")
3642    (set_attr "mode" "<MODE>")])
3644 ;; FMA parallel floating point multiply addsub and subadd operations.
3646 ;; It would be possible to represent these without the UNSPEC as
3648 ;; (vec_merge
3649 ;;   (fma op1 op2 op3)
3650 ;;   (fma op1 op2 (neg op3))
3651 ;;   (merge-const))
3653 ;; But this doesn't seem useful in practice.
3655 (define_expand "fmaddsub_<mode>"
3656   [(set (match_operand:VF 0 "register_operand")
3657         (unspec:VF
3658           [(match_operand:VF 1 "nonimmediate_operand")
3659            (match_operand:VF 2 "nonimmediate_operand")
3660            (match_operand:VF 3 "nonimmediate_operand")]
3661           UNSPEC_FMADDSUB))]
3662   "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
3664 (define_expand "<avx512>_fmaddsub_<mode>_maskz<round_expand_name>"
3665   [(match_operand:VF_AVX512VL 0 "register_operand")
3666    (match_operand:VF_AVX512VL 1 "<round_expand_nimm_predicate>")
3667    (match_operand:VF_AVX512VL 2 "<round_expand_nimm_predicate>")
3668    (match_operand:VF_AVX512VL 3 "<round_expand_nimm_predicate>")
3669    (match_operand:<avx512fmaskmode> 4 "register_operand")]
3670   "TARGET_AVX512F"
3672   emit_insn (gen_fma_fmaddsub_<mode>_maskz_1<round_expand_name> (
3673     operands[0], operands[1], operands[2], operands[3],
3674     CONST0_RTX (<MODE>mode), operands[4]<round_expand_operand>));
3675   DONE;
3678 (define_insn "*fma_fmaddsub_<mode>"
3679   [(set (match_operand:VF_128_256 0 "register_operand" "=v,v,v,x,x")
3680         (unspec:VF_128_256
3681           [(match_operand:VF_128_256 1 "nonimmediate_operand" "%0,0,v,x,x")
3682            (match_operand:VF_128_256 2 "nonimmediate_operand" "vm,v,vm,x,m")
3683            (match_operand:VF_128_256 3 "nonimmediate_operand" "v,vm,0,xm,x")]
3684           UNSPEC_FMADDSUB))]
3685   "TARGET_FMA || TARGET_FMA4"
3686   "@
3687    vfmaddsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3688    vfmaddsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3689    vfmaddsub231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3690    vfmaddsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3691    vfmaddsub<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3692   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3693    (set_attr "type" "ssemuladd")
3694    (set_attr "mode" "<MODE>")])
3696 (define_insn "<sd_mask_codefor>fma_fmaddsub_<mode><sd_maskz_name><round_name>"
3697   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3698         (unspec:VF_SF_AVX512VL
3699           [(match_operand:VF_SF_AVX512VL 1 "<round_nimm_predicate>" "%0,0,v")
3700            (match_operand:VF_SF_AVX512VL 2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3701            (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0")]
3702           UNSPEC_FMADDSUB))]
3703   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3704   "@
3705    vfmaddsub132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3706    vfmaddsub213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3707    vfmaddsub231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3708   [(set_attr "type" "ssemuladd")
3709    (set_attr "mode" "<MODE>")])
3711 (define_insn "<avx512>_fmaddsub_<mode>_mask<round_name>"
3712   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3713         (vec_merge:VF_AVX512VL
3714           (unspec:VF_AVX512VL
3715             [(match_operand:VF_AVX512VL 1 "register_operand" "0,0")
3716              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3717              (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>")]
3718             UNSPEC_FMADDSUB)
3719           (match_dup 1)
3720           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3721   "TARGET_AVX512F"
3722   "@
3723    vfmaddsub132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3724    vfmaddsub213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3725   [(set_attr "isa" "fma_avx512f,fma_avx512f")
3726    (set_attr "type" "ssemuladd")
3727    (set_attr "mode" "<MODE>")])
3729 (define_insn "<avx512>_fmaddsub_<mode>_mask3<round_name>"
3730   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3731         (vec_merge:VF_AVX512VL
3732           (unspec:VF_AVX512VL
3733             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
3734              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3735              (match_operand:VF_AVX512VL 3 "register_operand" "0")]
3736             UNSPEC_FMADDSUB)
3737           (match_dup 3)
3738           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3739   "TARGET_AVX512F"
3740   "vfmaddsub231<ssemodesuffix>\t{<round_op5>%2, %1, %0%{%4%}|%0%{%4%}, %1, %2<round_op5>}"
3741   [(set_attr "isa" "fma_avx512f")
3742    (set_attr "type" "ssemuladd")
3743    (set_attr "mode" "<MODE>")])
3745 (define_insn "*fma_fmsubadd_<mode>"
3746   [(set (match_operand:VF_128_256 0 "register_operand" "=v,v,v,x,x")
3747         (unspec:VF_128_256
3748           [(match_operand:VF_128_256   1 "nonimmediate_operand" "%0,0,v,x,x")
3749            (match_operand:VF_128_256   2 "nonimmediate_operand" "vm,v,vm,x,m")
3750            (neg:VF_128_256
3751              (match_operand:VF_128_256 3 "nonimmediate_operand" "v,vm,0,xm,x"))]
3752           UNSPEC_FMADDSUB))]
3753   "TARGET_FMA || TARGET_FMA4"
3754   "@
3755    vfmsubadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
3756    vfmsubadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
3757    vfmsubadd231<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
3758    vfmsubadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
3759    vfmsubadd<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
3760   [(set_attr "isa" "fma,fma,fma,fma4,fma4")
3761    (set_attr "type" "ssemuladd")
3762    (set_attr "mode" "<MODE>")])
3764 (define_insn "<sd_mask_codefor>fma_fmsubadd_<mode><sd_maskz_name><round_name>"
3765   [(set (match_operand:VF_SF_AVX512VL 0 "register_operand" "=v,v,v")
3766         (unspec:VF_SF_AVX512VL
3767           [(match_operand:VF_SF_AVX512VL   1 "<round_nimm_predicate>" "%0,0,v")
3768            (match_operand:VF_SF_AVX512VL   2 "<round_nimm_predicate>" "<round_constraint>,v,<round_constraint>")
3769            (neg:VF_SF_AVX512VL
3770              (match_operand:VF_SF_AVX512VL 3 "<round_nimm_predicate>" "v,<round_constraint>,0"))]
3771           UNSPEC_FMADDSUB))]
3772   "TARGET_AVX512F && <sd_mask_mode512bit_condition> && <round_mode512bit_condition>"
3773   "@
3774    vfmsubadd132<ssemodesuffix>\t{<round_sd_mask_op4>%2, %3, %0<sd_mask_op4>|%0<sd_mask_op4>, %3, %2<round_sd_mask_op4>}
3775    vfmsubadd213<ssemodesuffix>\t{<round_sd_mask_op4>%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3<round_sd_mask_op4>}
3776    vfmsubadd231<ssemodesuffix>\t{<round_sd_mask_op4>%2, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %2<round_sd_mask_op4>}"
3777   [(set_attr "type" "ssemuladd")
3778    (set_attr "mode" "<MODE>")])
3780 (define_insn "<avx512>_fmsubadd_<mode>_mask<round_name>"
3781   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v,v")
3782         (vec_merge:VF_AVX512VL
3783           (unspec:VF_AVX512VL
3784             [(match_operand:VF_AVX512VL 1 "register_operand" "0,0")
3785              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>,v")
3786              (neg:VF_AVX512VL
3787                (match_operand:VF_AVX512VL 3 "nonimmediate_operand" "v,<round_constraint>"))]
3788             UNSPEC_FMADDSUB)
3789           (match_dup 1)
3790           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk,Yk")))]
3791   "TARGET_AVX512F"
3792   "@
3793    vfmsubadd132<ssemodesuffix>\t{<round_op5>%2, %3, %0%{%4%}|%0%{%4%}, %3, %2<round_op5>}
3794    vfmsubadd213<ssemodesuffix>\t{<round_op5>%3, %2, %0%{%4%}|%0%{%4%}, %2, %3<round_op5>}"
3795   [(set_attr "isa" "fma_avx512f,fma_avx512f")
3796    (set_attr "type" "ssemuladd")
3797    (set_attr "mode" "<MODE>")])
3799 (define_insn "<avx512>_fmsubadd_<mode>_mask3<round_name>"
3800   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
3801         (vec_merge:VF_AVX512VL
3802           (unspec:VF_AVX512VL
3803             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
3804              (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")
3805              (neg:VF_AVX512VL
3806                (match_operand:VF_AVX512VL 3 "register_operand" "0"))]
3807             UNSPEC_FMADDSUB)
3808           (match_dup 3)
3809           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
3810   "TARGET_AVX512F"
3811   "vfmsubadd231<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 ;; FMA3 floating point scalar intrinsics. These merge result with
3817 ;; high-order elements from the destination register.
3819 (define_expand "fmai_vmfmadd_<mode><round_name>"
3820   [(set (match_operand:VF_128 0 "register_operand")
3821         (vec_merge:VF_128
3822           (fma:VF_128
3823             (match_operand:VF_128 1 "<round_nimm_predicate>")
3824             (match_operand:VF_128 2 "<round_nimm_predicate>")
3825             (match_operand:VF_128 3 "<round_nimm_predicate>"))
3826           (match_dup 1)
3827           (const_int 1)))]
3828   "TARGET_FMA")
3830 (define_insn "*fmai_fmadd_<mode>"
3831   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
3832         (vec_merge:VF_128
3833           (fma:VF_128
3834             (match_operand:VF_128 1 "<round_nimm_predicate>" " 0, 0")
3835             (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>, v")
3836             (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>"))
3837           (match_dup 1)
3838           (const_int 1)))]
3839   "TARGET_FMA || TARGET_AVX512F"
3840   "@
3841    vfmadd132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
3842    vfmadd213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
3843   [(set_attr "type" "ssemuladd")
3844    (set_attr "mode" "<MODE>")])
3846 (define_insn "*fmai_fmsub_<mode>"
3847   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
3848         (vec_merge:VF_128
3849           (fma:VF_128
3850             (match_operand:VF_128   1 "<round_nimm_predicate>" "0,0")
3851             (match_operand:VF_128   2 "<round_nimm_predicate>" "<round_constraint>,v")
3852             (neg:VF_128
3853               (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>")))
3854           (match_dup 1)
3855           (const_int 1)))]
3856   "TARGET_FMA || TARGET_AVX512F"
3857   "@
3858    vfmsub132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
3859    vfmsub213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
3860   [(set_attr "type" "ssemuladd")
3861    (set_attr "mode" "<MODE>")])
3863 (define_insn "*fmai_fnmadd_<mode><round_name>"
3864   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
3865         (vec_merge:VF_128
3866           (fma:VF_128
3867             (neg:VF_128
3868               (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>,v"))
3869             (match_operand:VF_128   1 "<round_nimm_predicate>" "0,0")
3870             (match_operand:VF_128   3 "<round_nimm_predicate>" "v,<round_constraint>"))
3871           (match_dup 1)
3872           (const_int 1)))]
3873   "TARGET_FMA || TARGET_AVX512F"
3874   "@
3875    vfnmadd132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
3876    vfnmadd213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
3877   [(set_attr "type" "ssemuladd")
3878    (set_attr "mode" "<MODE>")])
3880 (define_insn "*fmai_fnmsub_<mode><round_name>"
3881   [(set (match_operand:VF_128 0 "register_operand" "=v,v")
3882         (vec_merge:VF_128
3883           (fma:VF_128
3884             (neg:VF_128
3885               (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>, v"))
3886             (match_operand:VF_128   1 "<round_nimm_predicate>" " 0, 0")
3887             (neg:VF_128
3888               (match_operand:VF_128 3 "<round_nimm_predicate>" " v,<round_constraint>")))
3889           (match_dup 1)
3890           (const_int 1)))]
3891   "TARGET_FMA || TARGET_AVX512F"
3892   "@
3893    vfnmsub132<ssescalarmodesuffix>\t{<round_op4>%2, %3, %0|%0, %<iptr>3, %<iptr>2<round_op4>}
3894    vfnmsub213<ssescalarmodesuffix>\t{<round_op4>%3, %2, %0|%0, %<iptr>2, %<iptr>3<round_op4>}"
3895   [(set_attr "type" "ssemuladd")
3896    (set_attr "mode" "<MODE>")])
3898 ;; FMA4 floating point scalar intrinsics.  These write the
3899 ;; entire destination register, with the high-order elements zeroed.
3901 (define_expand "fma4i_vmfmadd_<mode>"
3902   [(set (match_operand:VF_128 0 "register_operand")
3903         (vec_merge:VF_128
3904           (fma:VF_128
3905             (match_operand:VF_128 1 "nonimmediate_operand")
3906             (match_operand:VF_128 2 "nonimmediate_operand")
3907             (match_operand:VF_128 3 "nonimmediate_operand"))
3908           (match_dup 4)
3909           (const_int 1)))]
3910   "TARGET_FMA4"
3911   "operands[4] = CONST0_RTX (<MODE>mode);")
3913 (define_insn "*fma4i_vmfmadd_<mode>"
3914   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
3915         (vec_merge:VF_128
3916           (fma:VF_128
3917             (match_operand:VF_128 1 "nonimmediate_operand" "%x,x")
3918             (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
3919             (match_operand:VF_128 3 "nonimmediate_operand" "xm,x"))
3920           (match_operand:VF_128 4 "const0_operand")
3921           (const_int 1)))]
3922   "TARGET_FMA4"
3923   "vfmadd<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
3924   [(set_attr "type" "ssemuladd")
3925    (set_attr "mode" "<MODE>")])
3927 (define_insn "*fma4i_vmfmsub_<mode>"
3928   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
3929         (vec_merge:VF_128
3930           (fma:VF_128
3931             (match_operand:VF_128 1 "nonimmediate_operand" "%x,x")
3932             (match_operand:VF_128 2 "nonimmediate_operand" " x,m")
3933             (neg:VF_128
3934               (match_operand:VF_128 3 "nonimmediate_operand" "xm,x")))
3935           (match_operand:VF_128 4 "const0_operand")
3936           (const_int 1)))]
3937   "TARGET_FMA4"
3938   "vfmsub<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
3939   [(set_attr "type" "ssemuladd")
3940    (set_attr "mode" "<MODE>")])
3942 (define_insn "*fma4i_vmfnmadd_<mode>"
3943   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
3944         (vec_merge:VF_128
3945           (fma:VF_128
3946             (neg:VF_128
3947               (match_operand:VF_128 1 "nonimmediate_operand" "%x,x"))
3948             (match_operand:VF_128   2 "nonimmediate_operand" " x,m")
3949             (match_operand:VF_128   3 "nonimmediate_operand" "xm,x"))
3950           (match_operand:VF_128 4 "const0_operand")
3951           (const_int 1)))]
3952   "TARGET_FMA4"
3953   "vfnmadd<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
3954   [(set_attr "type" "ssemuladd")
3955    (set_attr "mode" "<MODE>")])
3957 (define_insn "*fma4i_vmfnmsub_<mode>"
3958   [(set (match_operand:VF_128 0 "register_operand" "=x,x")
3959         (vec_merge:VF_128
3960           (fma:VF_128
3961             (neg:VF_128
3962               (match_operand:VF_128 1 "nonimmediate_operand" "%x,x"))
3963             (match_operand:VF_128   2 "nonimmediate_operand" " x,m")
3964             (neg:VF_128
3965               (match_operand:VF_128   3 "nonimmediate_operand" "xm,x")))
3966           (match_operand:VF_128 4 "const0_operand")
3967           (const_int 1)))]
3968   "TARGET_FMA4"
3969   "vfnmsub<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %<iptr>2, %<iptr>3}"
3970   [(set_attr "type" "ssemuladd")
3971    (set_attr "mode" "<MODE>")])
3973 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3975 ;; Parallel single-precision floating point conversion operations
3977 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3979 (define_insn "sse_cvtpi2ps"
3980   [(set (match_operand:V4SF 0 "register_operand" "=x")
3981         (vec_merge:V4SF
3982           (vec_duplicate:V4SF
3983             (float:V2SF (match_operand:V2SI 2 "nonimmediate_operand" "ym")))
3984           (match_operand:V4SF 1 "register_operand" "0")
3985           (const_int 3)))]
3986   "TARGET_SSE"
3987   "cvtpi2ps\t{%2, %0|%0, %2}"
3988   [(set_attr "type" "ssecvt")
3989    (set_attr "mode" "V4SF")])
3991 (define_insn "sse_cvtps2pi"
3992   [(set (match_operand:V2SI 0 "register_operand" "=y")
3993         (vec_select:V2SI
3994           (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
3995                        UNSPEC_FIX_NOTRUNC)
3996           (parallel [(const_int 0) (const_int 1)])))]
3997   "TARGET_SSE"
3998   "cvtps2pi\t{%1, %0|%0, %q1}"
3999   [(set_attr "type" "ssecvt")
4000    (set_attr "unit" "mmx")
4001    (set_attr "mode" "DI")])
4003 (define_insn "sse_cvttps2pi"
4004   [(set (match_operand:V2SI 0 "register_operand" "=y")
4005         (vec_select:V2SI
4006           (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
4007           (parallel [(const_int 0) (const_int 1)])))]
4008   "TARGET_SSE"
4009   "cvttps2pi\t{%1, %0|%0, %q1}"
4010   [(set_attr "type" "ssecvt")
4011    (set_attr "unit" "mmx")
4012    (set_attr "prefix_rep" "0")
4013    (set_attr "mode" "SF")])
4015 (define_insn "sse_cvtsi2ss<round_name>"
4016   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
4017         (vec_merge:V4SF
4018           (vec_duplicate:V4SF
4019             (float:SF (match_operand:SI 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
4020           (match_operand:V4SF 1 "register_operand" "0,0,v")
4021           (const_int 1)))]
4022   "TARGET_SSE"
4023   "@
4024    cvtsi2ss\t{%2, %0|%0, %2}
4025    cvtsi2ss\t{%2, %0|%0, %2}
4026    vcvtsi2ss\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4027   [(set_attr "isa" "noavx,noavx,avx")
4028    (set_attr "type" "sseicvt")
4029    (set_attr "athlon_decode" "vector,double,*")
4030    (set_attr "amdfam10_decode" "vector,double,*")
4031    (set_attr "bdver1_decode" "double,direct,*")
4032    (set_attr "btver2_decode" "double,double,double")
4033    (set_attr "znver1_decode" "double,double,double")
4034    (set_attr "prefix" "orig,orig,maybe_evex")
4035    (set_attr "mode" "SF")])
4037 (define_insn "sse_cvtsi2ssq<round_name>"
4038   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
4039         (vec_merge:V4SF
4040           (vec_duplicate:V4SF
4041             (float:SF (match_operand:DI 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
4042           (match_operand:V4SF 1 "register_operand" "0,0,v")
4043           (const_int 1)))]
4044   "TARGET_SSE && TARGET_64BIT"
4045   "@
4046    cvtsi2ssq\t{%2, %0|%0, %2}
4047    cvtsi2ssq\t{%2, %0|%0, %2}
4048    vcvtsi2ssq\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4049   [(set_attr "isa" "noavx,noavx,avx")
4050    (set_attr "type" "sseicvt")
4051    (set_attr "athlon_decode" "vector,double,*")
4052    (set_attr "amdfam10_decode" "vector,double,*")
4053    (set_attr "bdver1_decode" "double,direct,*")
4054    (set_attr "btver2_decode" "double,double,double")
4055    (set_attr "length_vex" "*,*,4")
4056    (set_attr "prefix_rex" "1,1,*")
4057    (set_attr "prefix" "orig,orig,maybe_evex")
4058    (set_attr "mode" "SF")])
4060 (define_insn "sse_cvtss2si<round_name>"
4061   [(set (match_operand:SI 0 "register_operand" "=r,r")
4062         (unspec:SI
4063           [(vec_select:SF
4064              (match_operand:V4SF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4065              (parallel [(const_int 0)]))]
4066           UNSPEC_FIX_NOTRUNC))]
4067   "TARGET_SSE"
4068   "%vcvtss2si\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
4069   [(set_attr "type" "sseicvt")
4070    (set_attr "athlon_decode" "double,vector")
4071    (set_attr "bdver1_decode" "double,double")
4072    (set_attr "prefix_rep" "1")
4073    (set_attr "prefix" "maybe_vex")
4074    (set_attr "mode" "SI")])
4076 (define_insn "sse_cvtss2si_2"
4077   [(set (match_operand:SI 0 "register_operand" "=r,r")
4078         (unspec:SI [(match_operand:SF 1 "nonimmediate_operand" "v,m")]
4079                    UNSPEC_FIX_NOTRUNC))]
4080   "TARGET_SSE"
4081   "%vcvtss2si\t{%1, %0|%0, %k1}"
4082   [(set_attr "type" "sseicvt")
4083    (set_attr "athlon_decode" "double,vector")
4084    (set_attr "amdfam10_decode" "double,double")
4085    (set_attr "bdver1_decode" "double,double")
4086    (set_attr "prefix_rep" "1")
4087    (set_attr "prefix" "maybe_vex")
4088    (set_attr "mode" "SI")])
4090 (define_insn "sse_cvtss2siq<round_name>"
4091   [(set (match_operand:DI 0 "register_operand" "=r,r")
4092         (unspec:DI
4093           [(vec_select:SF
4094              (match_operand:V4SF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4095              (parallel [(const_int 0)]))]
4096           UNSPEC_FIX_NOTRUNC))]
4097   "TARGET_SSE && TARGET_64BIT"
4098   "%vcvtss2si{q}\t{<round_op2>%1, %0|%0, %k1<round_op2>}"
4099   [(set_attr "type" "sseicvt")
4100    (set_attr "athlon_decode" "double,vector")
4101    (set_attr "bdver1_decode" "double,double")
4102    (set_attr "prefix_rep" "1")
4103    (set_attr "prefix" "maybe_vex")
4104    (set_attr "mode" "DI")])
4106 (define_insn "sse_cvtss2siq_2"
4107   [(set (match_operand:DI 0 "register_operand" "=r,r")
4108         (unspec:DI [(match_operand:SF 1 "nonimmediate_operand" "v,m")]
4109                    UNSPEC_FIX_NOTRUNC))]
4110   "TARGET_SSE && TARGET_64BIT"
4111   "%vcvtss2si{q}\t{%1, %0|%0, %k1}"
4112   [(set_attr "type" "sseicvt")
4113    (set_attr "athlon_decode" "double,vector")
4114    (set_attr "amdfam10_decode" "double,double")
4115    (set_attr "bdver1_decode" "double,double")
4116    (set_attr "prefix_rep" "1")
4117    (set_attr "prefix" "maybe_vex")
4118    (set_attr "mode" "DI")])
4120 (define_insn "sse_cvttss2si<round_saeonly_name>"
4121   [(set (match_operand:SI 0 "register_operand" "=r,r")
4122         (fix:SI
4123           (vec_select:SF
4124             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint2>")
4125             (parallel [(const_int 0)]))))]
4126   "TARGET_SSE"
4127   "%vcvttss2si\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
4128   [(set_attr "type" "sseicvt")
4129    (set_attr "athlon_decode" "double,vector")
4130    (set_attr "amdfam10_decode" "double,double")
4131    (set_attr "bdver1_decode" "double,double")
4132    (set_attr "prefix_rep" "1")
4133    (set_attr "prefix" "maybe_vex")
4134    (set_attr "mode" "SI")])
4136 (define_insn "sse_cvttss2siq<round_saeonly_name>"
4137   [(set (match_operand:DI 0 "register_operand" "=r,r")
4138         (fix:DI
4139           (vec_select:SF
4140             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint>")
4141             (parallel [(const_int 0)]))))]
4142   "TARGET_SSE && TARGET_64BIT"
4143   "%vcvttss2si{q}\t{<round_saeonly_op2>%1, %0|%0, %k1<round_saeonly_op2>}"
4144   [(set_attr "type" "sseicvt")
4145    (set_attr "athlon_decode" "double,vector")
4146    (set_attr "amdfam10_decode" "double,double")
4147    (set_attr "bdver1_decode" "double,double")
4148    (set_attr "prefix_rep" "1")
4149    (set_attr "prefix" "maybe_vex")
4150    (set_attr "mode" "DI")])
4152 (define_insn "cvtusi2<ssescalarmodesuffix>32<round_name>"
4153   [(set (match_operand:VF_128 0 "register_operand" "=v")
4154         (vec_merge:VF_128
4155           (vec_duplicate:VF_128
4156             (unsigned_float:<ssescalarmode>
4157               (match_operand:SI 2 "<round_nimm_predicate>" "<round_constraint3>")))
4158           (match_operand:VF_128 1 "register_operand" "v")
4159           (const_int 1)))]
4160   "TARGET_AVX512F && <round_modev4sf_condition>"
4161   "vcvtusi2<ssescalarmodesuffix>\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4162   [(set_attr "type" "sseicvt")
4163    (set_attr "prefix" "evex")
4164    (set_attr "mode" "<ssescalarmode>")])
4166 (define_insn "cvtusi2<ssescalarmodesuffix>64<round_name>"
4167   [(set (match_operand:VF_128 0 "register_operand" "=v")
4168         (vec_merge:VF_128
4169           (vec_duplicate:VF_128
4170             (unsigned_float:<ssescalarmode>
4171               (match_operand:DI 2 "<round_nimm_predicate>" "<round_constraint3>")))
4172           (match_operand:VF_128 1 "register_operand" "v")
4173           (const_int 1)))]
4174   "TARGET_AVX512F && TARGET_64BIT"
4175   "vcvtusi2<ssescalarmodesuffix>\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4176   [(set_attr "type" "sseicvt")
4177    (set_attr "prefix" "evex")
4178    (set_attr "mode" "<ssescalarmode>")])
4180 (define_insn "float<sseintvecmodelower><mode>2<mask_name><round_name>"
4181   [(set (match_operand:VF1 0 "register_operand" "=x,v")
4182         (float:VF1
4183           (match_operand:<sseintvecmode> 1 "<round_nimm_predicate>" "xBm,<round_constraint>")))]
4184   "TARGET_SSE2 && <mask_mode512bit_condition> && <round_mode512bit_condition>"
4185   "@
4186    cvtdq2ps\t{%1, %0|%0, %1}
4187    vcvtdq2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4188   [(set_attr "isa" "noavx,avx")
4189    (set_attr "type" "ssecvt")
4190    (set_attr "prefix" "maybe_vex")
4191    (set_attr "mode" "<sseinsnmode>")])
4193 (define_insn "ufloat<sseintvecmodelower><mode>2<mask_name><round_name>"
4194   [(set (match_operand:VF1_AVX512VL 0 "register_operand" "=v")
4195         (unsigned_float:VF1_AVX512VL
4196           (match_operand:<sseintvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
4197   "TARGET_AVX512F"
4198   "vcvtudq2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4199   [(set_attr "type" "ssecvt")
4200    (set_attr "prefix" "evex")
4201    (set_attr "mode" "<MODE>")])
4203 (define_expand "floatuns<sseintvecmodelower><mode>2"
4204   [(match_operand:VF1 0 "register_operand")
4205    (match_operand:<sseintvecmode> 1 "register_operand")]
4206   "TARGET_SSE2 && (<MODE>mode == V4SFmode || TARGET_AVX2)"
4208   if (<MODE>mode == V16SFmode)
4209     emit_insn (gen_ufloatv16siv16sf2 (operands[0], operands[1]));
4210   else
4211     if (TARGET_AVX512VL)
4212       {
4213         if (<MODE>mode == V4SFmode)
4214           emit_insn (gen_ufloatv4siv4sf2 (operands[0], operands[1]));
4215         else
4216           emit_insn (gen_ufloatv8siv8sf2 (operands[0], operands[1]));
4217       }
4218   else
4219     ix86_expand_vector_convert_uns_vsivsf (operands[0], operands[1]);
4221   DONE;
4225 ;; For <sse2_avx_avx512f>_fix_notrunc<sf2simodelower><mode> insn pattern
4226 (define_mode_attr sf2simodelower
4227   [(V16SI "v16sf") (V8SI "v8sf") (V4SI "v4sf")])
4229 (define_insn "<sse2_avx_avx512f>_fix_notrunc<sf2simodelower><mode><mask_name>"
4230   [(set (match_operand:VI4_AVX 0 "register_operand" "=v")
4231         (unspec:VI4_AVX
4232           [(match_operand:<ssePSmode> 1 "vector_operand" "vBm")]
4233           UNSPEC_FIX_NOTRUNC))]
4234   "TARGET_SSE2 && <mask_mode512bit_condition>"
4235   "%vcvtps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4236   [(set_attr "type" "ssecvt")
4237    (set (attr "prefix_data16")
4238      (if_then_else
4239        (match_test "TARGET_AVX")
4240      (const_string "*")
4241      (const_string "1")))
4242    (set_attr "prefix" "maybe_vex")
4243    (set_attr "mode" "<sseinsnmode>")])
4245 (define_insn "<mask_codefor>avx512f_fix_notruncv16sfv16si<mask_name><round_name>"
4246   [(set (match_operand:V16SI 0 "register_operand" "=v")
4247         (unspec:V16SI
4248           [(match_operand:V16SF 1 "<round_nimm_predicate>" "<round_constraint>")]
4249           UNSPEC_FIX_NOTRUNC))]
4250   "TARGET_AVX512F"
4251   "vcvtps2dq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4252   [(set_attr "type" "ssecvt")
4253    (set_attr "prefix" "evex")
4254    (set_attr "mode" "XI")])
4256 (define_insn "<mask_codefor><avx512>_ufix_notrunc<sf2simodelower><mode><mask_name><round_name>"
4257   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
4258         (unspec:VI4_AVX512VL
4259           [(match_operand:<ssePSmode> 1 "nonimmediate_operand" "<round_constraint>")]
4260           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4261   "TARGET_AVX512F"
4262   "vcvtps2udq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4263   [(set_attr "type" "ssecvt")
4264    (set_attr "prefix" "evex")
4265    (set_attr "mode" "<sseinsnmode>")])
4267 (define_insn "<mask_codefor>avx512dq_cvtps2qq<mode><mask_name><round_name>"
4268   [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
4269         (unspec:VI8_256_512 [(match_operand:<ssePSmode2> 1 "nonimmediate_operand" "<round_constraint>")]
4270                      UNSPEC_FIX_NOTRUNC))]
4271   "TARGET_AVX512DQ && <round_mode512bit_condition>"
4272   "vcvtps2qq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4273   [(set_attr "type" "ssecvt")
4274    (set_attr "prefix" "evex")
4275    (set_attr "mode" "<sseinsnmode>")])
4277 (define_insn "<mask_codefor>avx512dq_cvtps2qqv2di<mask_name>"
4278   [(set (match_operand:V2DI 0 "register_operand" "=v")
4279         (unspec:V2DI
4280           [(vec_select:V2SF
4281              (match_operand:V4SF 1 "nonimmediate_operand" "vm")
4282              (parallel [(const_int 0) (const_int 1)]))]
4283           UNSPEC_FIX_NOTRUNC))]
4284   "TARGET_AVX512DQ && TARGET_AVX512VL"
4285   "vcvtps2qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
4286   [(set_attr "type" "ssecvt")
4287    (set_attr "prefix" "evex")
4288    (set_attr "mode" "TI")])
4290 (define_insn "<mask_codefor>avx512dq_cvtps2uqq<mode><mask_name><round_name>"
4291   [(set (match_operand:VI8_256_512 0 "register_operand" "=v")
4292         (unspec:VI8_256_512 [(match_operand:<ssePSmode2> 1 "nonimmediate_operand" "<round_constraint>")]
4293                      UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4294   "TARGET_AVX512DQ && <round_mode512bit_condition>"
4295   "vcvtps2uqq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4296   [(set_attr "type" "ssecvt")
4297    (set_attr "prefix" "evex")
4298    (set_attr "mode" "<sseinsnmode>")])
4300 (define_insn "<mask_codefor>avx512dq_cvtps2uqqv2di<mask_name>"
4301   [(set (match_operand:V2DI 0 "register_operand" "=v")
4302         (unspec:V2DI
4303           [(vec_select:V2SF
4304              (match_operand:V4SF 1 "nonimmediate_operand" "vm")
4305              (parallel [(const_int 0) (const_int 1)]))]
4306           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4307   "TARGET_AVX512DQ && TARGET_AVX512VL"
4308   "vcvtps2uqq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
4309   [(set_attr "type" "ssecvt")
4310    (set_attr "prefix" "evex")
4311    (set_attr "mode" "TI")])
4313 (define_insn "<fixsuffix>fix_truncv16sfv16si2<mask_name><round_saeonly_name>"
4314   [(set (match_operand:V16SI 0 "register_operand" "=v")
4315         (any_fix:V16SI
4316           (match_operand:V16SF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
4317   "TARGET_AVX512F"
4318   "vcvttps2<fixsuffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
4319   [(set_attr "type" "ssecvt")
4320    (set_attr "prefix" "evex")
4321    (set_attr "mode" "XI")])
4323 (define_insn "fix_truncv8sfv8si2<mask_name>"
4324   [(set (match_operand:V8SI 0 "register_operand" "=v")
4325         (fix:V8SI (match_operand:V8SF 1 "nonimmediate_operand" "vm")))]
4326   "TARGET_AVX && <mask_avx512vl_condition>"
4327   "vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4328   [(set_attr "type" "ssecvt")
4329    (set_attr "prefix" "<mask_prefix>")
4330    (set_attr "mode" "OI")])
4332 (define_insn "fix_truncv4sfv4si2<mask_name>"
4333   [(set (match_operand:V4SI 0 "register_operand" "=v")
4334         (fix:V4SI (match_operand:V4SF 1 "vector_operand" "vBm")))]
4335   "TARGET_SSE2 && <mask_avx512vl_condition>"
4336   "%vcvttps2dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4337   [(set_attr "type" "ssecvt")
4338    (set (attr "prefix_rep")
4339      (if_then_else
4340        (match_test "TARGET_AVX")
4341      (const_string "*")
4342      (const_string "1")))
4343    (set (attr "prefix_data16")
4344      (if_then_else
4345        (match_test "TARGET_AVX")
4346      (const_string "*")
4347      (const_string "0")))
4348    (set_attr "prefix_data16" "0")
4349    (set_attr "prefix" "<mask_prefix2>")
4350    (set_attr "mode" "TI")])
4352 (define_expand "fixuns_trunc<mode><sseintvecmodelower>2"
4353   [(match_operand:<sseintvecmode> 0 "register_operand")
4354    (match_operand:VF1 1 "register_operand")]
4355   "TARGET_SSE2"
4357   if (<MODE>mode == V16SFmode)
4358     emit_insn (gen_ufix_truncv16sfv16si2 (operands[0],
4359                                           operands[1]));
4360   else
4361     {
4362       rtx tmp[3];
4363       tmp[0] = ix86_expand_adjust_ufix_to_sfix_si (operands[1], &tmp[2]);
4364       tmp[1] = gen_reg_rtx (<sseintvecmode>mode);
4365       emit_insn (gen_fix_trunc<mode><sseintvecmodelower>2 (tmp[1], tmp[0]));
4366       emit_insn (gen_xor<sseintvecmodelower>3 (operands[0], tmp[1], tmp[2]));
4367     }
4368   DONE;
4371 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4373 ;; Parallel double-precision floating point conversion operations
4375 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4377 (define_insn "sse2_cvtpi2pd"
4378   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
4379         (float:V2DF (match_operand:V2SI 1 "nonimmediate_operand" "y,m")))]
4380   "TARGET_SSE2"
4381   "cvtpi2pd\t{%1, %0|%0, %1}"
4382   [(set_attr "type" "ssecvt")
4383    (set_attr "unit" "mmx,*")
4384    (set_attr "prefix_data16" "1,*")
4385    (set_attr "mode" "V2DF")])
4387 (define_insn "sse2_cvtpd2pi"
4388   [(set (match_operand:V2SI 0 "register_operand" "=y")
4389         (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "xm")]
4390                      UNSPEC_FIX_NOTRUNC))]
4391   "TARGET_SSE2"
4392   "cvtpd2pi\t{%1, %0|%0, %1}"
4393   [(set_attr "type" "ssecvt")
4394    (set_attr "unit" "mmx")
4395    (set_attr "bdver1_decode" "double")
4396    (set_attr "btver2_decode" "direct")
4397    (set_attr "prefix_data16" "1")
4398    (set_attr "mode" "DI")])
4400 (define_insn "sse2_cvttpd2pi"
4401   [(set (match_operand:V2SI 0 "register_operand" "=y")
4402         (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "xm")))]
4403   "TARGET_SSE2"
4404   "cvttpd2pi\t{%1, %0|%0, %1}"
4405   [(set_attr "type" "ssecvt")
4406    (set_attr "unit" "mmx")
4407    (set_attr "bdver1_decode" "double")
4408    (set_attr "prefix_data16" "1")
4409    (set_attr "mode" "TI")])
4411 (define_insn "sse2_cvtsi2sd"
4412   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
4413         (vec_merge:V2DF
4414           (vec_duplicate:V2DF
4415             (float:DF (match_operand:SI 2 "nonimmediate_operand" "r,m,rm")))
4416           (match_operand:V2DF 1 "register_operand" "0,0,v")
4417           (const_int 1)))]
4418   "TARGET_SSE2"
4419   "@
4420    cvtsi2sd\t{%2, %0|%0, %2}
4421    cvtsi2sd\t{%2, %0|%0, %2}
4422    vcvtsi2sd\t{%2, %1, %0|%0, %1, %2}"
4423   [(set_attr "isa" "noavx,noavx,avx")
4424    (set_attr "type" "sseicvt")
4425    (set_attr "athlon_decode" "double,direct,*")
4426    (set_attr "amdfam10_decode" "vector,double,*")
4427    (set_attr "bdver1_decode" "double,direct,*")
4428    (set_attr "btver2_decode" "double,double,double")
4429    (set_attr "znver1_decode" "double,double,double")
4430    (set_attr "prefix" "orig,orig,maybe_evex")
4431    (set_attr "mode" "DF")])
4433 (define_insn "sse2_cvtsi2sdq<round_name>"
4434   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
4435         (vec_merge:V2DF
4436           (vec_duplicate:V2DF
4437             (float:DF (match_operand:DI 2 "<round_nimm_scalar_predicate>" "r,m,<round_constraint3>")))
4438           (match_operand:V2DF 1 "register_operand" "0,0,v")
4439           (const_int 1)))]
4440   "TARGET_SSE2 && TARGET_64BIT"
4441   "@
4442    cvtsi2sdq\t{%2, %0|%0, %2}
4443    cvtsi2sdq\t{%2, %0|%0, %2}
4444    vcvtsi2sdq\t{%2, <round_op3>%1, %0|%0, %1<round_op3>, %2}"
4445   [(set_attr "isa" "noavx,noavx,avx")
4446    (set_attr "type" "sseicvt")
4447    (set_attr "athlon_decode" "double,direct,*")
4448    (set_attr "amdfam10_decode" "vector,double,*")
4449    (set_attr "bdver1_decode" "double,direct,*")
4450    (set_attr "length_vex" "*,*,4")
4451    (set_attr "prefix_rex" "1,1,*")
4452    (set_attr "prefix" "orig,orig,maybe_evex")
4453    (set_attr "mode" "DF")])
4455 (define_insn "avx512f_vcvtss2usi<round_name>"
4456   [(set (match_operand:SI 0 "register_operand" "=r")
4457         (unspec:SI
4458           [(vec_select:SF
4459              (match_operand:V4SF 1 "<round_nimm_predicate>" "<round_constraint>")
4460              (parallel [(const_int 0)]))]
4461           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4462   "TARGET_AVX512F"
4463   "vcvtss2usi\t{<round_op2>%1, %0|%0, %1<round_op2>}"
4464   [(set_attr "type" "sseicvt")
4465    (set_attr "prefix" "evex")
4466    (set_attr "mode" "SI")])
4468 (define_insn "avx512f_vcvtss2usiq<round_name>"
4469   [(set (match_operand:DI 0 "register_operand" "=r")
4470         (unspec:DI
4471           [(vec_select:SF
4472              (match_operand:V4SF 1 "<round_nimm_predicate>" "<round_constraint>")
4473              (parallel [(const_int 0)]))]
4474           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4475   "TARGET_AVX512F && TARGET_64BIT"
4476   "vcvtss2usi\t{<round_op2>%1, %0|%0, %1<round_op2>}"
4477   [(set_attr "type" "sseicvt")
4478    (set_attr "prefix" "evex")
4479    (set_attr "mode" "DI")])
4481 (define_insn "avx512f_vcvttss2usi<round_saeonly_name>"
4482   [(set (match_operand:SI 0 "register_operand" "=r")
4483         (unsigned_fix:SI
4484           (vec_select:SF
4485             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4486             (parallel [(const_int 0)]))))]
4487   "TARGET_AVX512F"
4488   "vcvttss2usi\t{<round_saeonly_op2>%1, %0|%0, %1<round_saeonly_op2>}"
4489   [(set_attr "type" "sseicvt")
4490    (set_attr "prefix" "evex")
4491    (set_attr "mode" "SI")])
4493 (define_insn "avx512f_vcvttss2usiq<round_saeonly_name>"
4494   [(set (match_operand:DI 0 "register_operand" "=r")
4495         (unsigned_fix:DI
4496           (vec_select:SF
4497             (match_operand:V4SF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4498             (parallel [(const_int 0)]))))]
4499   "TARGET_AVX512F && TARGET_64BIT"
4500   "vcvttss2usi\t{<round_saeonly_op2>%1, %0|%0, %1<round_saeonly_op2>}"
4501   [(set_attr "type" "sseicvt")
4502    (set_attr "prefix" "evex")
4503    (set_attr "mode" "DI")])
4505 (define_insn "avx512f_vcvtsd2usi<round_name>"
4506   [(set (match_operand:SI 0 "register_operand" "=r")
4507         (unspec:SI
4508           [(vec_select:DF
4509              (match_operand:V2DF 1 "<round_nimm_predicate>" "<round_constraint>")
4510              (parallel [(const_int 0)]))]
4511           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4512   "TARGET_AVX512F"
4513   "vcvtsd2usi\t{<round_op2>%1, %0|%0, %1<round_op2>}"
4514   [(set_attr "type" "sseicvt")
4515    (set_attr "prefix" "evex")
4516    (set_attr "mode" "SI")])
4518 (define_insn "avx512f_vcvtsd2usiq<round_name>"
4519   [(set (match_operand:DI 0 "register_operand" "=r")
4520         (unspec:DI
4521           [(vec_select:DF
4522              (match_operand:V2DF 1 "<round_nimm_predicate>" "<round_constraint>")
4523              (parallel [(const_int 0)]))]
4524           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4525   "TARGET_AVX512F && TARGET_64BIT"
4526   "vcvtsd2usi\t{<round_op2>%1, %0|%0, %1<round_op2>}"
4527   [(set_attr "type" "sseicvt")
4528    (set_attr "prefix" "evex")
4529    (set_attr "mode" "DI")])
4531 (define_insn "avx512f_vcvttsd2usi<round_saeonly_name>"
4532   [(set (match_operand:SI 0 "register_operand" "=r")
4533         (unsigned_fix:SI
4534           (vec_select:DF
4535             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4536             (parallel [(const_int 0)]))))]
4537   "TARGET_AVX512F"
4538   "vcvttsd2usi\t{<round_saeonly_op2>%1, %0|%0, %1<round_saeonly_op2>}"
4539   [(set_attr "type" "sseicvt")
4540    (set_attr "prefix" "evex")
4541    (set_attr "mode" "SI")])
4543 (define_insn "avx512f_vcvttsd2usiq<round_saeonly_name>"
4544   [(set (match_operand:DI 0 "register_operand" "=r")
4545         (unsigned_fix:DI
4546           (vec_select:DF
4547             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "<round_saeonly_constraint>")
4548             (parallel [(const_int 0)]))))]
4549   "TARGET_AVX512F && TARGET_64BIT"
4550   "vcvttsd2usi\t{<round_saeonly_op2>%1, %0|%0, %1<round_saeonly_op2>}"
4551   [(set_attr "type" "sseicvt")
4552    (set_attr "prefix" "evex")
4553    (set_attr "mode" "DI")])
4555 (define_insn "sse2_cvtsd2si<round_name>"
4556   [(set (match_operand:SI 0 "register_operand" "=r,r")
4557         (unspec:SI
4558           [(vec_select:DF
4559              (match_operand:V2DF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4560              (parallel [(const_int 0)]))]
4561           UNSPEC_FIX_NOTRUNC))]
4562   "TARGET_SSE2"
4563   "%vcvtsd2si\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
4564   [(set_attr "type" "sseicvt")
4565    (set_attr "athlon_decode" "double,vector")
4566    (set_attr "bdver1_decode" "double,double")
4567    (set_attr "btver2_decode" "double,double")
4568    (set_attr "prefix_rep" "1")
4569    (set_attr "prefix" "maybe_vex")
4570    (set_attr "mode" "SI")])
4572 (define_insn "sse2_cvtsd2si_2"
4573   [(set (match_operand:SI 0 "register_operand" "=r,r")
4574         (unspec:SI [(match_operand:DF 1 "nonimmediate_operand" "v,m")]
4575                    UNSPEC_FIX_NOTRUNC))]
4576   "TARGET_SSE2"
4577   "%vcvtsd2si\t{%1, %0|%0, %q1}"
4578   [(set_attr "type" "sseicvt")
4579    (set_attr "athlon_decode" "double,vector")
4580    (set_attr "amdfam10_decode" "double,double")
4581    (set_attr "bdver1_decode" "double,double")
4582    (set_attr "prefix_rep" "1")
4583    (set_attr "prefix" "maybe_vex")
4584    (set_attr "mode" "SI")])
4586 (define_insn "sse2_cvtsd2siq<round_name>"
4587   [(set (match_operand:DI 0 "register_operand" "=r,r")
4588         (unspec:DI
4589           [(vec_select:DF
4590              (match_operand:V2DF 1 "<round_nimm_scalar_predicate>" "v,<round_constraint2>")
4591              (parallel [(const_int 0)]))]
4592           UNSPEC_FIX_NOTRUNC))]
4593   "TARGET_SSE2 && TARGET_64BIT"
4594   "%vcvtsd2si{q}\t{<round_op2>%1, %0|%0, %q1<round_op2>}"
4595   [(set_attr "type" "sseicvt")
4596    (set_attr "athlon_decode" "double,vector")
4597    (set_attr "bdver1_decode" "double,double")
4598    (set_attr "prefix_rep" "1")
4599    (set_attr "prefix" "maybe_vex")
4600    (set_attr "mode" "DI")])
4602 (define_insn "sse2_cvtsd2siq_2"
4603   [(set (match_operand:DI 0 "register_operand" "=r,r")
4604         (unspec:DI [(match_operand:DF 1 "nonimmediate_operand" "v,m")]
4605                    UNSPEC_FIX_NOTRUNC))]
4606   "TARGET_SSE2 && TARGET_64BIT"
4607   "%vcvtsd2si{q}\t{%1, %0|%0, %q1}"
4608   [(set_attr "type" "sseicvt")
4609    (set_attr "athlon_decode" "double,vector")
4610    (set_attr "amdfam10_decode" "double,double")
4611    (set_attr "bdver1_decode" "double,double")
4612    (set_attr "prefix_rep" "1")
4613    (set_attr "prefix" "maybe_vex")
4614    (set_attr "mode" "DI")])
4616 (define_insn "sse2_cvttsd2si<round_saeonly_name>"
4617   [(set (match_operand:SI 0 "register_operand" "=r,r")
4618         (fix:SI
4619           (vec_select:DF
4620             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint2>")
4621             (parallel [(const_int 0)]))))]
4622   "TARGET_SSE2"
4623   "%vcvttsd2si\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
4624   [(set_attr "type" "sseicvt")
4625    (set_attr "athlon_decode" "double,vector")
4626    (set_attr "amdfam10_decode" "double,double")
4627    (set_attr "bdver1_decode" "double,double")
4628    (set_attr "btver2_decode" "double,double")
4629    (set_attr "prefix_rep" "1")
4630    (set_attr "prefix" "maybe_vex")
4631    (set_attr "mode" "SI")])
4633 (define_insn "sse2_cvttsd2siq<round_saeonly_name>"
4634   [(set (match_operand:DI 0 "register_operand" "=r,r")
4635         (fix:DI
4636           (vec_select:DF
4637             (match_operand:V2DF 1 "<round_saeonly_nimm_scalar_predicate>" "v,<round_saeonly_constraint2>")
4638             (parallel [(const_int 0)]))))]
4639   "TARGET_SSE2 && TARGET_64BIT"
4640   "%vcvttsd2si{q}\t{<round_saeonly_op2>%1, %0|%0, %q1<round_saeonly_op2>}"
4641   [(set_attr "type" "sseicvt")
4642    (set_attr "athlon_decode" "double,vector")
4643    (set_attr "amdfam10_decode" "double,double")
4644    (set_attr "bdver1_decode" "double,double")
4645    (set_attr "prefix_rep" "1")
4646    (set_attr "prefix" "maybe_vex")
4647    (set_attr "mode" "DI")])
4649 ;; For float<si2dfmode><mode>2 insn pattern
4650 (define_mode_attr si2dfmode
4651   [(V8DF "V8SI") (V4DF "V4SI")])
4652 (define_mode_attr si2dfmodelower
4653   [(V8DF "v8si") (V4DF "v4si")])
4655 (define_insn "float<si2dfmodelower><mode>2<mask_name>"
4656   [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
4657         (float:VF2_512_256 (match_operand:<si2dfmode> 1 "nonimmediate_operand" "vm")))]
4658   "TARGET_AVX && <mask_mode512bit_condition>"
4659   "vcvtdq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4660   [(set_attr "type" "ssecvt")
4661    (set_attr "prefix" "maybe_vex")
4662    (set_attr "mode" "<MODE>")])
4664 (define_insn "<floatsuffix>float<sseintvecmodelower><mode>2<mask_name><round_name>"
4665   [(set (match_operand:VF2_AVX512VL 0 "register_operand" "=v")
4666         (any_float:VF2_AVX512VL
4667           (match_operand:<sseintvecmode> 1 "nonimmediate_operand" "vm")))]
4668   "TARGET_AVX512DQ"
4669   "vcvt<floatsuffix>qq2pd\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4670   [(set_attr "type" "ssecvt")
4671    (set_attr "prefix" "evex")
4672    (set_attr "mode" "<MODE>")])
4674 ;; For <floatsuffix>float<sselondveclower><mode> insn patterns
4675 (define_mode_attr qq2pssuff
4676   [(V8SF "") (V4SF "{y}")])
4678 (define_mode_attr sselongvecmode
4679   [(V8SF "V8DI") (V4SF  "V4DI")])
4681 (define_mode_attr sselongvecmodelower
4682   [(V8SF "v8di") (V4SF  "v4di")])
4684 (define_mode_attr sseintvecmode3
4685   [(V8SF "XI") (V4SF "OI")
4686    (V8DF "OI") (V4DF "TI")])
4688 (define_insn "<floatsuffix>float<sselongvecmodelower><mode>2<mask_name><round_name>"
4689   [(set (match_operand:VF1_128_256VL 0 "register_operand" "=v")
4690          (any_float:VF1_128_256VL
4691            (match_operand:<sselongvecmode> 1 "nonimmediate_operand" "<round_constraint>")))]
4692   "TARGET_AVX512DQ && <round_modev8sf_condition>"
4693   "vcvt<floatsuffix>qq2ps<qq2pssuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4694   [(set_attr "type" "ssecvt")
4695    (set_attr "prefix" "evex")
4696    (set_attr "mode" "<MODE>")])
4698 (define_insn "*<floatsuffix>floatv2div2sf2"
4699   [(set (match_operand:V4SF 0 "register_operand" "=v")
4700     (vec_concat:V4SF
4701             (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
4702             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
4703   "TARGET_AVX512DQ && TARGET_AVX512VL"
4704   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0|%0, %1}"
4705   [(set_attr "type" "ssecvt")
4706    (set_attr "prefix" "evex")
4707    (set_attr "mode" "V4SF")])
4709 (define_insn "<floatsuffix>floatv2div2sf2_mask"
4710   [(set (match_operand:V4SF 0 "register_operand" "=v")
4711     (vec_concat:V4SF
4712         (vec_merge:V2SF
4713                 (any_float:V2SF (match_operand:V2DI 1 "nonimmediate_operand" "vm"))
4714             (vec_select:V2SF
4715                 (match_operand:V4SF 2 "vector_move_operand" "0C")
4716                 (parallel [(const_int 0) (const_int 1)]))
4717             (match_operand:QI 3 "register_operand" "Yk"))
4718             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
4719   "TARGET_AVX512DQ && TARGET_AVX512VL"
4720   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
4721   [(set_attr "type" "ssecvt")
4722    (set_attr "prefix" "evex")
4723    (set_attr "mode" "V4SF")])
4725 (define_insn "*<floatsuffix>floatv2div2sf2_mask_1"
4726   [(set (match_operand:V4SF 0 "register_operand" "=v")
4727     (vec_concat:V4SF
4728         (vec_merge:V2SF
4729                 (any_float:V2SF (match_operand:V2DI 1
4730                                   "nonimmediate_operand" "vm"))
4731             (const_vector:V2SF [(const_int 0) (const_int 0)])
4732             (match_operand:QI 2 "register_operand" "Yk"))
4733             (const_vector:V2SF [(const_int 0) (const_int 0)])))]
4734   "TARGET_AVX512DQ && TARGET_AVX512VL"
4735   "vcvt<floatsuffix>qq2ps{x}\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
4736   [(set_attr "type" "ssecvt")
4737    (set_attr "prefix" "evex")
4738    (set_attr "mode" "V4SF")])
4740 (define_insn "ufloat<si2dfmodelower><mode>2<mask_name>"
4741   [(set (match_operand:VF2_512_256VL 0 "register_operand" "=v")
4742         (unsigned_float:VF2_512_256VL
4743           (match_operand:<si2dfmode> 1 "nonimmediate_operand" "vm")))]
4744    "TARGET_AVX512F"
4745    "vcvtudq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4746    [(set_attr "type" "ssecvt")
4747     (set_attr "prefix" "evex")
4748     (set_attr "mode" "<MODE>")])
4750 (define_insn "ufloatv2siv2df2<mask_name>"
4751   [(set (match_operand:V2DF 0 "register_operand" "=v")
4752         (unsigned_float:V2DF
4753           (vec_select:V2SI
4754             (match_operand:V4SI 1 "nonimmediate_operand" "vm")
4755             (parallel [(const_int 0) (const_int 1)]))))]
4756   "TARGET_AVX512VL"
4757   "vcvtudq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4758   [(set_attr "type" "ssecvt")
4759    (set_attr "prefix" "evex")
4760    (set_attr "mode" "V2DF")])
4762 (define_insn "avx512f_cvtdq2pd512_2"
4763   [(set (match_operand:V8DF 0 "register_operand" "=v")
4764         (float:V8DF
4765           (vec_select:V8SI
4766             (match_operand:V16SI 1 "nonimmediate_operand" "vm")
4767             (parallel [(const_int 0) (const_int 1)
4768                        (const_int 2) (const_int 3)
4769                        (const_int 4) (const_int 5)
4770                        (const_int 6) (const_int 7)]))))]
4771   "TARGET_AVX512F"
4772   "vcvtdq2pd\t{%t1, %0|%0, %t1}"
4773   [(set_attr "type" "ssecvt")
4774    (set_attr "prefix" "evex")
4775    (set_attr "mode" "V8DF")])
4777 (define_insn "avx_cvtdq2pd256_2"
4778   [(set (match_operand:V4DF 0 "register_operand" "=v")
4779         (float:V4DF
4780           (vec_select:V4SI
4781             (match_operand:V8SI 1 "nonimmediate_operand" "vm")
4782             (parallel [(const_int 0) (const_int 1)
4783                        (const_int 2) (const_int 3)]))))]
4784   "TARGET_AVX"
4785   "vcvtdq2pd\t{%x1, %0|%0, %x1}"
4786   [(set_attr "type" "ssecvt")
4787    (set_attr "prefix" "maybe_evex")
4788    (set_attr "mode" "V4DF")])
4790 (define_insn "sse2_cvtdq2pd<mask_name>"
4791   [(set (match_operand:V2DF 0 "register_operand" "=v")
4792         (float:V2DF
4793           (vec_select:V2SI
4794             (match_operand:V4SI 1 "nonimmediate_operand" "vm")
4795             (parallel [(const_int 0) (const_int 1)]))))]
4796   "TARGET_SSE2 && <mask_avx512vl_condition>"
4797   "%vcvtdq2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
4798   [(set_attr "type" "ssecvt")
4799    (set_attr "prefix" "maybe_vex")
4800    (set_attr "mode" "V2DF")])
4802 (define_insn "<mask_codefor>avx512f_cvtpd2dq512<mask_name><round_name>"
4803   [(set (match_operand:V8SI 0 "register_operand" "=v")
4804         (unspec:V8SI
4805           [(match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")]
4806           UNSPEC_FIX_NOTRUNC))]
4807   "TARGET_AVX512F"
4808   "vcvtpd2dq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4809   [(set_attr "type" "ssecvt")
4810    (set_attr "prefix" "evex")
4811    (set_attr "mode" "OI")])
4813 (define_insn "avx_cvtpd2dq256<mask_name>"
4814   [(set (match_operand:V4SI 0 "register_operand" "=v")
4815         (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")]
4816                      UNSPEC_FIX_NOTRUNC))]
4817   "TARGET_AVX && <mask_avx512vl_condition>"
4818   "vcvtpd2dq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4819   [(set_attr "type" "ssecvt")
4820    (set_attr "prefix" "<mask_prefix>")
4821    (set_attr "mode" "OI")])
4823 (define_expand "avx_cvtpd2dq256_2"
4824   [(set (match_operand:V8SI 0 "register_operand")
4825         (vec_concat:V8SI
4826           (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand")]
4827                        UNSPEC_FIX_NOTRUNC)
4828           (match_dup 2)))]
4829   "TARGET_AVX"
4830   "operands[2] = CONST0_RTX (V4SImode);")
4832 (define_insn "*avx_cvtpd2dq256_2"
4833   [(set (match_operand:V8SI 0 "register_operand" "=v")
4834         (vec_concat:V8SI
4835           (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")]
4836                        UNSPEC_FIX_NOTRUNC)
4837           (match_operand:V4SI 2 "const0_operand")))]
4838   "TARGET_AVX"
4839   "vcvtpd2dq{y}\t{%1, %x0|%x0, %1}"
4840   [(set_attr "type" "ssecvt")
4841    (set_attr "prefix" "vex")
4842    (set_attr "btver2_decode" "vector")
4843    (set_attr "mode" "OI")])
4845 (define_insn "sse2_cvtpd2dq<mask_name>"
4846   [(set (match_operand:V4SI 0 "register_operand" "=v")
4847         (vec_concat:V4SI
4848           (unspec:V2SI [(match_operand:V2DF 1 "vector_operand" "vBm")]
4849                        UNSPEC_FIX_NOTRUNC)
4850           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
4851   "TARGET_SSE2 && <mask_avx512vl_condition>"
4853   if (TARGET_AVX)
4854     return "vcvtpd2dq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
4855   else
4856     return "cvtpd2dq\t{%1, %0|%0, %1}";
4858   [(set_attr "type" "ssecvt")
4859    (set_attr "prefix_rep" "1")
4860    (set_attr "prefix_data16" "0")
4861    (set_attr "prefix" "maybe_vex")
4862    (set_attr "mode" "TI")
4863    (set_attr "amdfam10_decode" "double")
4864    (set_attr "athlon_decode" "vector")
4865    (set_attr "bdver1_decode" "double")])
4867 ;; For ufix_notrunc* insn patterns
4868 (define_mode_attr pd2udqsuff
4869   [(V8DF "") (V4DF "{y}")])
4871 (define_insn "ufix_notrunc<mode><si2dfmodelower>2<mask_name><round_name>"
4872   [(set (match_operand:<si2dfmode> 0 "register_operand" "=v")
4873         (unspec:<si2dfmode>
4874           [(match_operand:VF2_512_256VL 1 "nonimmediate_operand" "<round_constraint>")]
4875           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4876   "TARGET_AVX512F"
4877   "vcvtpd2udq<pd2udqsuff>\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4878   [(set_attr "type" "ssecvt")
4879    (set_attr "prefix" "evex")
4880    (set_attr "mode" "<sseinsnmode>")])
4882 (define_insn "ufix_notruncv2dfv2si2<mask_name>"
4883   [(set (match_operand:V4SI 0 "register_operand" "=v")
4884         (vec_concat:V4SI
4885           (unspec:V2SI
4886             [(match_operand:V2DF 1 "nonimmediate_operand" "vm")]
4887             UNSPEC_UNSIGNED_FIX_NOTRUNC)
4888           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
4889   "TARGET_AVX512VL"
4890   "vcvtpd2udq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4891   [(set_attr "type" "ssecvt")
4892    (set_attr "prefix" "evex")
4893    (set_attr "mode" "TI")])
4895 (define_insn "<fixsuffix>fix_truncv8dfv8si2<mask_name><round_saeonly_name>"
4896   [(set (match_operand:V8SI 0 "register_operand" "=v")
4897         (any_fix:V8SI
4898           (match_operand:V8DF 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
4899   "TARGET_AVX512F"
4900   "vcvttpd2<fixsuffix>dq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
4901   [(set_attr "type" "ssecvt")
4902    (set_attr "prefix" "evex")
4903    (set_attr "mode" "OI")])
4905 (define_insn "ufix_truncv2dfv2si2<mask_name>"
4906   [(set (match_operand:V4SI 0 "register_operand" "=v")
4907         (vec_concat:V4SI
4908           (unsigned_fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "vm"))
4909           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
4910   "TARGET_AVX512VL"
4911   "vcvttpd2udq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4912   [(set_attr "type" "ssecvt")
4913    (set_attr "prefix" "evex")
4914    (set_attr "mode" "TI")])
4916 (define_insn "fix_truncv4dfv4si2<mask_name>"
4917   [(set (match_operand:V4SI 0 "register_operand" "=v")
4918         (fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
4919   "TARGET_AVX || (TARGET_AVX512VL && TARGET_AVX512F)"
4920   "vcvttpd2dq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4921   [(set_attr "type" "ssecvt")
4922    (set_attr "prefix" "maybe_evex")
4923    (set_attr "mode" "OI")])
4925 (define_insn "ufix_truncv4dfv4si2<mask_name>"
4926   [(set (match_operand:V4SI 0 "register_operand" "=v")
4927         (unsigned_fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
4928   "TARGET_AVX512VL && TARGET_AVX512F"
4929   "vcvttpd2udq{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4930   [(set_attr "type" "ssecvt")
4931    (set_attr "prefix" "maybe_evex")
4932    (set_attr "mode" "OI")])
4934 (define_insn "<fixsuffix>fix_trunc<mode><sseintvecmodelower>2<mask_name><round_saeonly_name>"
4935   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
4936         (any_fix:<sseintvecmode>
4937           (match_operand:VF2_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
4938   "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
4939   "vcvttpd2<fixsuffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
4940   [(set_attr "type" "ssecvt")
4941    (set_attr "prefix" "evex")
4942    (set_attr "mode" "<sseintvecmode2>")])
4944 (define_insn "fix_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>"
4945   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
4946         (unspec:<sseintvecmode>
4947           [(match_operand:VF2_AVX512VL 1 "<round_nimm_predicate>" "<round_constraint>")]
4948           UNSPEC_FIX_NOTRUNC))]
4949   "TARGET_AVX512DQ && <round_mode512bit_condition>"
4950   "vcvtpd2qq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4951   [(set_attr "type" "ssecvt")
4952    (set_attr "prefix" "evex")
4953    (set_attr "mode" "<sseintvecmode2>")])
4955 (define_insn "ufix_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>"
4956   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
4957         (unspec:<sseintvecmode>
4958           [(match_operand:VF2_AVX512VL 1 "nonimmediate_operand" "<round_constraint>")]
4959           UNSPEC_UNSIGNED_FIX_NOTRUNC))]
4960   "TARGET_AVX512DQ && <round_mode512bit_condition>"
4961   "vcvtpd2uqq\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
4962   [(set_attr "type" "ssecvt")
4963    (set_attr "prefix" "evex")
4964    (set_attr "mode" "<sseintvecmode2>")])
4966 (define_insn "<fixsuffix>fix_trunc<mode><sselongvecmodelower>2<mask_name><round_saeonly_name>"
4967   [(set (match_operand:<sselongvecmode> 0 "register_operand" "=v")
4968         (any_fix:<sselongvecmode>
4969           (match_operand:VF1_128_256VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
4970   "TARGET_AVX512DQ && <round_saeonly_modev8sf_condition>"
4971   "vcvttps2<fixsuffix>qq\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
4972   [(set_attr "type" "ssecvt")
4973    (set_attr "prefix" "evex")
4974    (set_attr "mode" "<sseintvecmode3>")])
4976 (define_insn "<fixsuffix>fix_truncv2sfv2di2<mask_name>"
4977   [(set (match_operand:V2DI 0 "register_operand" "=v")
4978         (any_fix:V2DI
4979           (vec_select:V2SF
4980             (match_operand:V4SF 1 "nonimmediate_operand" "vm")
4981             (parallel [(const_int 0) (const_int 1)]))))]
4982   "TARGET_AVX512DQ && TARGET_AVX512VL"
4983   "vcvttps2<fixsuffix>qq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
4984   [(set_attr "type" "ssecvt")
4985    (set_attr "prefix" "evex")
4986    (set_attr "mode" "TI")])
4988 (define_insn "ufix_trunc<mode><sseintvecmodelower>2<mask_name>"
4989   [(set (match_operand:<sseintvecmode> 0 "register_operand" "=v")
4990         (unsigned_fix:<sseintvecmode>
4991           (match_operand:VF1_128_256VL 1 "nonimmediate_operand" "vm")))]
4992   "TARGET_AVX512VL"
4993   "vcvttps2udq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
4994   [(set_attr "type" "ssecvt")
4995    (set_attr "prefix" "evex")
4996    (set_attr "mode" "<sseintvecmode2>")])
4998 (define_expand "avx_cvttpd2dq256_2"
4999   [(set (match_operand:V8SI 0 "register_operand")
5000         (vec_concat:V8SI
5001           (fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand"))
5002           (match_dup 2)))]
5003   "TARGET_AVX"
5004   "operands[2] = CONST0_RTX (V4SImode);")
5006 (define_insn "sse2_cvttpd2dq<mask_name>"
5007   [(set (match_operand:V4SI 0 "register_operand" "=v")
5008         (vec_concat:V4SI
5009           (fix:V2SI (match_operand:V2DF 1 "vector_operand" "vBm"))
5010           (const_vector:V2SI [(const_int 0) (const_int 0)])))]
5011   "TARGET_SSE2 && <mask_avx512vl_condition>"
5013   if (TARGET_AVX)
5014     return "vcvttpd2dq{x}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}";
5015   else
5016     return "cvttpd2dq\t{%1, %0|%0, %1}";
5018   [(set_attr "type" "ssecvt")
5019    (set_attr "amdfam10_decode" "double")
5020    (set_attr "athlon_decode" "vector")
5021    (set_attr "bdver1_decode" "double")
5022    (set_attr "prefix" "maybe_vex")
5023    (set_attr "mode" "TI")])
5025 (define_insn "sse2_cvtsd2ss<round_name>"
5026   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
5027         (vec_merge:V4SF
5028           (vec_duplicate:V4SF
5029             (float_truncate:V2SF
5030               (match_operand:V2DF 2 "nonimmediate_operand" "x,m,<round_constraint>")))
5031           (match_operand:V4SF 1 "register_operand" "0,0,v")
5032           (const_int 1)))]
5033   "TARGET_SSE2"
5034   "@
5035    cvtsd2ss\t{%2, %0|%0, %2}
5036    cvtsd2ss\t{%2, %0|%0, %q2}
5037    vcvtsd2ss\t{<round_op3>%2, %1, %0|%0, %1, %q2<round_op3>}"
5038   [(set_attr "isa" "noavx,noavx,avx")
5039    (set_attr "type" "ssecvt")
5040    (set_attr "athlon_decode" "vector,double,*")
5041    (set_attr "amdfam10_decode" "vector,double,*")
5042    (set_attr "bdver1_decode" "direct,direct,*")
5043    (set_attr "btver2_decode" "double,double,double")
5044    (set_attr "prefix" "orig,orig,<round_prefix>")
5045    (set_attr "mode" "SF")])
5047 (define_insn "*sse2_vd_cvtsd2ss"
5048   [(set (match_operand:V4SF 0 "register_operand" "=x,x,v")
5049         (vec_merge:V4SF
5050           (vec_duplicate:V4SF
5051             (float_truncate:SF (match_operand:DF 2 "nonimmediate_operand" "x,m,vm")))
5052           (match_operand:V4SF 1 "register_operand" "0,0,v")
5053           (const_int 1)))]
5054   "TARGET_SSE2"
5055   "@
5056    cvtsd2ss\t{%2, %0|%0, %2}
5057    cvtsd2ss\t{%2, %0|%0, %2}
5058    vcvtsd2ss\t{%2, %1, %0|%0, %1, %2}"
5059   [(set_attr "isa" "noavx,noavx,avx")
5060    (set_attr "type" "ssecvt")
5061    (set_attr "athlon_decode" "vector,double,*")
5062    (set_attr "amdfam10_decode" "vector,double,*")
5063    (set_attr "bdver1_decode" "direct,direct,*")
5064    (set_attr "btver2_decode" "double,double,double")
5065    (set_attr "prefix" "orig,orig,vex")
5066    (set_attr "mode" "SF")])
5068 (define_insn "sse2_cvtss2sd<round_saeonly_name>"
5069   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
5070         (vec_merge:V2DF
5071           (float_extend:V2DF
5072             (vec_select:V2SF
5073               (match_operand:V4SF 2 "<round_saeonly_nimm_scalar_predicate>" "x,m,<round_saeonly_constraint>")
5074               (parallel [(const_int 0) (const_int 1)])))
5075           (match_operand:V2DF 1 "register_operand" "0,0,v")
5076           (const_int 1)))]
5077   "TARGET_SSE2"
5078   "@
5079    cvtss2sd\t{%2, %0|%0, %2}
5080    cvtss2sd\t{%2, %0|%0, %k2}
5081    vcvtss2sd\t{<round_saeonly_op3>%2, %1, %0|%0, %1, %k2<round_saeonly_op3>}"
5082   [(set_attr "isa" "noavx,noavx,avx")
5083    (set_attr "type" "ssecvt")
5084    (set_attr "amdfam10_decode" "vector,double,*")
5085    (set_attr "athlon_decode" "direct,direct,*")
5086    (set_attr "bdver1_decode" "direct,direct,*")
5087    (set_attr "btver2_decode" "double,double,double")
5088    (set_attr "prefix" "orig,orig,<round_saeonly_prefix>")
5089    (set_attr "mode" "DF")])
5091 (define_insn "*sse2_vd_cvtss2sd"
5092   [(set (match_operand:V2DF 0 "register_operand" "=x,x,v")
5093         (vec_merge:V2DF
5094           (vec_duplicate:V2DF
5095             (float_extend:DF (match_operand:SF 2 "nonimmediate_operand" "x,m,vm")))
5096           (match_operand:V2DF 1 "register_operand" "0,0,v")
5097           (const_int 1)))]
5098   "TARGET_SSE2"
5099   "@
5100    cvtss2sd\t{%2, %0|%0, %2}
5101    cvtss2sd\t{%2, %0|%0, %2}
5102    vcvtss2sd\t{%2, %1, %0|%0, %1, %2}"
5103   [(set_attr "isa" "noavx,noavx,avx")
5104    (set_attr "type" "ssecvt")
5105    (set_attr "amdfam10_decode" "vector,double,*")
5106    (set_attr "athlon_decode" "direct,direct,*")
5107    (set_attr "bdver1_decode" "direct,direct,*")
5108    (set_attr "btver2_decode" "double,double,double")
5109    (set_attr "prefix" "orig,orig,vex")
5110    (set_attr "mode" "DF")])
5112 (define_insn "<mask_codefor>avx512f_cvtpd2ps512<mask_name><round_name>"
5113   [(set (match_operand:V8SF 0 "register_operand" "=v")
5114         (float_truncate:V8SF
5115           (match_operand:V8DF 1 "<round_nimm_predicate>" "<round_constraint>")))]
5116   "TARGET_AVX512F"
5117   "vcvtpd2ps\t{<round_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_mask_op2>}"
5118   [(set_attr "type" "ssecvt")
5119    (set_attr "prefix" "evex")
5120    (set_attr "mode" "V8SF")])
5122 (define_insn "avx_cvtpd2ps256<mask_name>"
5123   [(set (match_operand:V4SF 0 "register_operand" "=v")
5124         (float_truncate:V4SF
5125           (match_operand:V4DF 1 "nonimmediate_operand" "vm")))]
5126   "TARGET_AVX && <mask_avx512vl_condition>"
5127   "vcvtpd2ps{y}\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
5128   [(set_attr "type" "ssecvt")
5129    (set_attr "prefix" "maybe_evex")
5130    (set_attr "btver2_decode" "vector")
5131    (set_attr "mode" "V4SF")])
5133 (define_expand "sse2_cvtpd2ps"
5134   [(set (match_operand:V4SF 0 "register_operand")
5135         (vec_concat:V4SF
5136           (float_truncate:V2SF
5137             (match_operand:V2DF 1 "vector_operand"))
5138           (match_dup 2)))]
5139   "TARGET_SSE2"
5140   "operands[2] = CONST0_RTX (V2SFmode);")
5142 (define_expand "sse2_cvtpd2ps_mask"
5143   [(set (match_operand:V4SF 0 "register_operand")
5144         (vec_merge:V4SF
5145           (vec_concat:V4SF
5146             (float_truncate:V2SF
5147               (match_operand:V2DF 1 "vector_operand"))
5148             (match_dup 4))
5149           (match_operand:V4SF 2 "register_operand")
5150           (match_operand:QI 3 "register_operand")))]
5151   "TARGET_SSE2"
5152   "operands[4] = CONST0_RTX (V2SFmode);")
5154 (define_insn "*sse2_cvtpd2ps<mask_name>"
5155   [(set (match_operand:V4SF 0 "register_operand" "=v")
5156         (vec_concat:V4SF
5157           (float_truncate:V2SF
5158             (match_operand:V2DF 1 "vector_operand" "vBm"))
5159           (match_operand:V2SF 2 "const0_operand")))]
5160   "TARGET_SSE2 && <mask_avx512vl_condition>"
5162   if (TARGET_AVX)
5163     return "vcvtpd2ps{x}\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}";
5164   else
5165     return "cvtpd2ps\t{%1, %0|%0, %1}";
5167   [(set_attr "type" "ssecvt")
5168    (set_attr "amdfam10_decode" "double")
5169    (set_attr "athlon_decode" "vector")
5170    (set_attr "bdver1_decode" "double")
5171    (set_attr "prefix_data16" "1")
5172    (set_attr "prefix" "maybe_vex")
5173    (set_attr "mode" "V4SF")])
5175 ;; For <sse2_avx_avx512f>_cvtps2pd<avxsizesuffix> insn pattern
5176 (define_mode_attr sf2dfmode
5177   [(V8DF "V8SF") (V4DF "V4SF")])
5179 (define_insn "<sse2_avx_avx512f>_cvtps2pd<avxsizesuffix><mask_name><round_saeonly_name>"
5180   [(set (match_operand:VF2_512_256 0 "register_operand" "=v")
5181         (float_extend:VF2_512_256
5182           (match_operand:<sf2dfmode> 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")))]
5183   "TARGET_AVX && <mask_mode512bit_condition> && <round_saeonly_mode512bit_condition>"
5184   "vcvtps2pd\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
5185   [(set_attr "type" "ssecvt")
5186    (set_attr "prefix" "maybe_vex")
5187    (set_attr "mode" "<MODE>")])
5189 (define_insn "*avx_cvtps2pd256_2"
5190   [(set (match_operand:V4DF 0 "register_operand" "=v")
5191         (float_extend:V4DF
5192           (vec_select:V4SF
5193             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
5194             (parallel [(const_int 0) (const_int 1)
5195                        (const_int 2) (const_int 3)]))))]
5196   "TARGET_AVX"
5197   "vcvtps2pd\t{%x1, %0|%0, %x1}"
5198   [(set_attr "type" "ssecvt")
5199    (set_attr "prefix" "vex")
5200    (set_attr "mode" "V4DF")])
5202 (define_insn "vec_unpacks_lo_v16sf"
5203   [(set (match_operand:V8DF 0 "register_operand" "=v")
5204         (float_extend:V8DF
5205           (vec_select:V8SF
5206             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
5207             (parallel [(const_int 0) (const_int 1)
5208                        (const_int 2) (const_int 3)
5209                        (const_int 4) (const_int 5)
5210                        (const_int 6) (const_int 7)]))))]
5211   "TARGET_AVX512F"
5212   "vcvtps2pd\t{%t1, %0|%0, %t1}"
5213   [(set_attr "type" "ssecvt")
5214    (set_attr "prefix" "evex")
5215    (set_attr "mode" "V8DF")])
5217 (define_insn "<avx512>_cvt<ssemodesuffix>2mask<mode>"
5218   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
5219         (unspec:<avx512fmaskmode>
5220          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")]
5221          UNSPEC_CVTINT2MASK))]
5222   "TARGET_AVX512BW"
5223   "vpmov<ssemodesuffix>2m\t{%1, %0|%0, %1}"
5224   [(set_attr "prefix" "evex")
5225    (set_attr "mode" "<sseinsnmode>")])
5227 (define_insn "<avx512>_cvt<ssemodesuffix>2mask<mode>"
5228   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
5229         (unspec:<avx512fmaskmode>
5230          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")]
5231          UNSPEC_CVTINT2MASK))]
5232   "TARGET_AVX512DQ"
5233   "vpmov<ssemodesuffix>2m\t{%1, %0|%0, %1}"
5234   [(set_attr "prefix" "evex")
5235    (set_attr "mode" "<sseinsnmode>")])
5237 (define_expand "<avx512>_cvtmask2<ssemodesuffix><mode>"
5238   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
5239         (vec_merge:VI12_AVX512VL
5240           (match_dup 2)
5241           (match_dup 3)
5242           (match_operand:<avx512fmaskmode> 1 "register_operand")))]
5243   "TARGET_AVX512BW"
5244   {
5245     operands[2] = CONSTM1_RTX (<MODE>mode);
5246     operands[3] = CONST0_RTX (<MODE>mode);
5247   })
5249 (define_insn "*<avx512>_cvtmask2<ssemodesuffix><mode>"
5250   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
5251         (vec_merge:VI12_AVX512VL
5252           (match_operand:VI12_AVX512VL 2 "vector_all_ones_operand")
5253           (match_operand:VI12_AVX512VL 3 "const0_operand")
5254           (match_operand:<avx512fmaskmode> 1 "register_operand" "Yk")))]
5255   "TARGET_AVX512BW"
5256   "vpmovm2<ssemodesuffix>\t{%1, %0|%0, %1}"
5257   [(set_attr "prefix" "evex")
5258    (set_attr "mode" "<sseinsnmode>")])
5260 (define_expand "<avx512>_cvtmask2<ssemodesuffix><mode>"
5261   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
5262         (vec_merge:VI48_AVX512VL
5263           (match_dup 2)
5264           (match_dup 3)
5265           (match_operand:<avx512fmaskmode> 1 "register_operand")))]
5266   "TARGET_AVX512DQ"
5267   "{
5268     operands[2] = CONSTM1_RTX (<MODE>mode);
5269     operands[3] = CONST0_RTX (<MODE>mode);
5270   }")
5272 (define_insn "*<avx512>_cvtmask2<ssemodesuffix><mode>"
5273   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
5274         (vec_merge:VI48_AVX512VL
5275           (match_operand:VI48_AVX512VL 2 "vector_all_ones_operand")
5276           (match_operand:VI48_AVX512VL 3 "const0_operand")
5277           (match_operand:<avx512fmaskmode> 1 "register_operand" "Yk")))]
5278   "TARGET_AVX512DQ"
5279   "vpmovm2<ssemodesuffix>\t{%1, %0|%0, %1}"
5280   [(set_attr "prefix" "evex")
5281    (set_attr "mode" "<sseinsnmode>")])
5283 (define_insn "sse2_cvtps2pd<mask_name>"
5284   [(set (match_operand:V2DF 0 "register_operand" "=v")
5285         (float_extend:V2DF
5286           (vec_select:V2SF
5287             (match_operand:V4SF 1 "vector_operand" "vm")
5288             (parallel [(const_int 0) (const_int 1)]))))]
5289   "TARGET_SSE2 && <mask_avx512vl_condition>"
5290   "%vcvtps2pd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
5291   [(set_attr "type" "ssecvt")
5292    (set_attr "amdfam10_decode" "direct")
5293    (set_attr "athlon_decode" "double")
5294    (set_attr "bdver1_decode" "double")
5295    (set_attr "prefix_data16" "0")
5296    (set_attr "prefix" "maybe_vex")
5297    (set_attr "mode" "V2DF")])
5299 (define_expand "vec_unpacks_hi_v4sf"
5300   [(set (match_dup 2)
5301    (vec_select:V4SF
5302      (vec_concat:V8SF
5303        (match_dup 2)
5304        (match_operand:V4SF 1 "vector_operand"))
5305      (parallel [(const_int 6) (const_int 7)
5306                 (const_int 2) (const_int 3)])))
5307   (set (match_operand:V2DF 0 "register_operand")
5308    (float_extend:V2DF
5309      (vec_select:V2SF
5310        (match_dup 2)
5311        (parallel [(const_int 0) (const_int 1)]))))]
5312   "TARGET_SSE2"
5313   "operands[2] = gen_reg_rtx (V4SFmode);")
5315 (define_expand "vec_unpacks_hi_v8sf"
5316   [(set (match_dup 2)
5317         (vec_select:V4SF
5318           (match_operand:V8SF 1 "register_operand")
5319           (parallel [(const_int 4) (const_int 5)
5320                      (const_int 6) (const_int 7)])))
5321    (set (match_operand:V4DF 0 "register_operand")
5322         (float_extend:V4DF
5323           (match_dup 2)))]
5324   "TARGET_AVX"
5325   "operands[2] = gen_reg_rtx (V4SFmode);")
5327 (define_expand "vec_unpacks_hi_v16sf"
5328   [(set (match_dup 2)
5329         (vec_select:V8SF
5330           (match_operand:V16SF 1 "register_operand")
5331           (parallel [(const_int 8) (const_int 9)
5332                      (const_int 10) (const_int 11)
5333                      (const_int 12) (const_int 13)
5334                      (const_int 14) (const_int 15)])))
5335    (set (match_operand:V8DF 0 "register_operand")
5336         (float_extend:V8DF
5337           (match_dup 2)))]
5338 "TARGET_AVX512F"
5339 "operands[2] = gen_reg_rtx (V8SFmode);")
5341 (define_expand "vec_unpacks_lo_v4sf"
5342   [(set (match_operand:V2DF 0 "register_operand")
5343         (float_extend:V2DF
5344           (vec_select:V2SF
5345             (match_operand:V4SF 1 "vector_operand")
5346             (parallel [(const_int 0) (const_int 1)]))))]
5347   "TARGET_SSE2")
5349 (define_expand "vec_unpacks_lo_v8sf"
5350   [(set (match_operand:V4DF 0 "register_operand")
5351         (float_extend:V4DF
5352           (vec_select:V4SF
5353             (match_operand:V8SF 1 "nonimmediate_operand")
5354             (parallel [(const_int 0) (const_int 1)
5355                        (const_int 2) (const_int 3)]))))]
5356   "TARGET_AVX")
5358 (define_mode_attr sseunpackfltmode
5359   [(V8HI "V4SF") (V4SI "V2DF") (V16HI "V8SF")
5360   (V8SI "V4DF") (V32HI "V16SF") (V16SI "V8DF")])
5362 (define_expand "vec_unpacks_float_hi_<mode>"
5363   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5364    (match_operand:VI2_AVX512F 1 "register_operand")]
5365   "TARGET_SSE2"
5367   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5369   emit_insn (gen_vec_unpacks_hi_<mode> (tmp, operands[1]));
5370   emit_insn (gen_rtx_SET (operands[0],
5371                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5372   DONE;
5375 (define_expand "vec_unpacks_float_lo_<mode>"
5376   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5377    (match_operand:VI2_AVX512F 1 "register_operand")]
5378   "TARGET_SSE2"
5380   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5382   emit_insn (gen_vec_unpacks_lo_<mode> (tmp, operands[1]));
5383   emit_insn (gen_rtx_SET (operands[0],
5384                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5385   DONE;
5388 (define_expand "vec_unpacku_float_hi_<mode>"
5389   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5390    (match_operand:VI2_AVX512F 1 "register_operand")]
5391   "TARGET_SSE2"
5393   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5395   emit_insn (gen_vec_unpacku_hi_<mode> (tmp, operands[1]));
5396   emit_insn (gen_rtx_SET (operands[0],
5397                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5398   DONE;
5401 (define_expand "vec_unpacku_float_lo_<mode>"
5402   [(match_operand:<sseunpackfltmode> 0 "register_operand")
5403    (match_operand:VI2_AVX512F 1 "register_operand")]
5404   "TARGET_SSE2"
5406   rtx tmp = gen_reg_rtx (<sseunpackmode>mode);
5408   emit_insn (gen_vec_unpacku_lo_<mode> (tmp, operands[1]));
5409   emit_insn (gen_rtx_SET (operands[0],
5410                           gen_rtx_FLOAT (<sseunpackfltmode>mode, tmp)));
5411   DONE;
5414 (define_expand "vec_unpacks_float_hi_v4si"
5415   [(set (match_dup 2)
5416         (vec_select:V4SI
5417           (match_operand:V4SI 1 "vector_operand")
5418           (parallel [(const_int 2) (const_int 3)
5419                      (const_int 2) (const_int 3)])))
5420    (set (match_operand:V2DF 0 "register_operand")
5421         (float:V2DF
5422           (vec_select:V2SI
5423           (match_dup 2)
5424             (parallel [(const_int 0) (const_int 1)]))))]
5425   "TARGET_SSE2"
5426   "operands[2] = gen_reg_rtx (V4SImode);")
5428 (define_expand "vec_unpacks_float_lo_v4si"
5429   [(set (match_operand:V2DF 0 "register_operand")
5430         (float:V2DF
5431           (vec_select:V2SI
5432             (match_operand:V4SI 1 "vector_operand")
5433             (parallel [(const_int 0) (const_int 1)]))))]
5434   "TARGET_SSE2")
5436 (define_expand "vec_unpacks_float_hi_v8si"
5437   [(set (match_dup 2)
5438         (vec_select:V4SI
5439           (match_operand:V8SI 1 "vector_operand")
5440           (parallel [(const_int 4) (const_int 5)
5441                      (const_int 6) (const_int 7)])))
5442    (set (match_operand:V4DF 0 "register_operand")
5443         (float:V4DF
5444           (match_dup 2)))]
5445   "TARGET_AVX"
5446   "operands[2] = gen_reg_rtx (V4SImode);")
5448 (define_expand "vec_unpacks_float_lo_v8si"
5449   [(set (match_operand:V4DF 0 "register_operand")
5450         (float:V4DF
5451           (vec_select:V4SI
5452             (match_operand:V8SI 1 "nonimmediate_operand")
5453             (parallel [(const_int 0) (const_int 1)
5454                        (const_int 2) (const_int 3)]))))]
5455   "TARGET_AVX")
5457 (define_expand "vec_unpacks_float_hi_v16si"
5458   [(set (match_dup 2)
5459         (vec_select:V8SI
5460           (match_operand:V16SI 1 "nonimmediate_operand")
5461           (parallel [(const_int 8) (const_int 9)
5462                      (const_int 10) (const_int 11)
5463                      (const_int 12) (const_int 13)
5464                      (const_int 14) (const_int 15)])))
5465    (set (match_operand:V8DF 0 "register_operand")
5466         (float:V8DF
5467           (match_dup 2)))]
5468   "TARGET_AVX512F"
5469   "operands[2] = gen_reg_rtx (V8SImode);")
5471 (define_expand "vec_unpacks_float_lo_v16si"
5472   [(set (match_operand:V8DF 0 "register_operand")
5473         (float:V8DF
5474           (vec_select:V8SI
5475             (match_operand:V16SI 1 "nonimmediate_operand")
5476             (parallel [(const_int 0) (const_int 1)
5477                        (const_int 2) (const_int 3)
5478                        (const_int 4) (const_int 5)
5479                        (const_int 6) (const_int 7)]))))]
5480   "TARGET_AVX512F")
5482 (define_expand "vec_unpacku_float_hi_v4si"
5483   [(set (match_dup 5)
5484         (vec_select:V4SI
5485           (match_operand:V4SI 1 "vector_operand")
5486           (parallel [(const_int 2) (const_int 3)
5487                      (const_int 2) (const_int 3)])))
5488    (set (match_dup 6)
5489         (float:V2DF
5490           (vec_select:V2SI
5491           (match_dup 5)
5492             (parallel [(const_int 0) (const_int 1)]))))
5493    (set (match_dup 7)
5494         (lt:V2DF (match_dup 6) (match_dup 3)))
5495    (set (match_dup 8)
5496         (and:V2DF (match_dup 7) (match_dup 4)))
5497    (set (match_operand:V2DF 0 "register_operand")
5498         (plus:V2DF (match_dup 6) (match_dup 8)))]
5499   "TARGET_SSE2"
5501   REAL_VALUE_TYPE TWO32r;
5502   rtx x;
5503   int i;
5505   real_ldexp (&TWO32r, &dconst1, 32);
5506   x = const_double_from_real_value (TWO32r, DFmode);
5508   operands[3] = force_reg (V2DFmode, CONST0_RTX (V2DFmode));
5509   operands[4] = force_reg (V2DFmode,
5510                            ix86_build_const_vector (V2DFmode, 1, x));
5512   operands[5] = gen_reg_rtx (V4SImode);
5514   for (i = 6; i < 9; i++)
5515     operands[i] = gen_reg_rtx (V2DFmode);
5518 (define_expand "vec_unpacku_float_lo_v4si"
5519   [(set (match_dup 5)
5520         (float:V2DF
5521           (vec_select:V2SI
5522             (match_operand:V4SI 1 "vector_operand")
5523             (parallel [(const_int 0) (const_int 1)]))))
5524    (set (match_dup 6)
5525         (lt:V2DF (match_dup 5) (match_dup 3)))
5526    (set (match_dup 7)
5527         (and:V2DF (match_dup 6) (match_dup 4)))
5528    (set (match_operand:V2DF 0 "register_operand")
5529         (plus:V2DF (match_dup 5) (match_dup 7)))]
5530   "TARGET_SSE2"
5532   REAL_VALUE_TYPE TWO32r;
5533   rtx x;
5534   int i;
5536   real_ldexp (&TWO32r, &dconst1, 32);
5537   x = const_double_from_real_value (TWO32r, DFmode);
5539   operands[3] = force_reg (V2DFmode, CONST0_RTX (V2DFmode));
5540   operands[4] = force_reg (V2DFmode,
5541                            ix86_build_const_vector (V2DFmode, 1, x));
5543   for (i = 5; i < 8; i++)
5544     operands[i] = gen_reg_rtx (V2DFmode);
5547 (define_expand "vec_unpacku_float_hi_v8si"
5548   [(match_operand:V4DF 0 "register_operand")
5549    (match_operand:V8SI 1 "register_operand")]
5550   "TARGET_AVX"
5552   REAL_VALUE_TYPE TWO32r;
5553   rtx x, tmp[6];
5554   int i;
5556   real_ldexp (&TWO32r, &dconst1, 32);
5557   x = const_double_from_real_value (TWO32r, DFmode);
5559   tmp[0] = force_reg (V4DFmode, CONST0_RTX (V4DFmode));
5560   tmp[1] = force_reg (V4DFmode, ix86_build_const_vector (V4DFmode, 1, x));
5561   tmp[5] = gen_reg_rtx (V4SImode);
5563   for (i = 2; i < 5; i++)
5564     tmp[i] = gen_reg_rtx (V4DFmode);
5565   emit_insn (gen_vec_extract_hi_v8si (tmp[5], operands[1]));
5566   emit_insn (gen_floatv4siv4df2 (tmp[2], tmp[5]));
5567   emit_insn (gen_rtx_SET (tmp[3], gen_rtx_LT (V4DFmode, tmp[2], tmp[0])));
5568   emit_insn (gen_andv4df3 (tmp[4], tmp[3], tmp[1]));
5569   emit_insn (gen_addv4df3 (operands[0], tmp[2], tmp[4]));
5570   DONE;
5573 (define_expand "vec_unpacku_float_hi_v16si"
5574   [(match_operand:V8DF 0 "register_operand")
5575    (match_operand:V16SI 1 "register_operand")]
5576   "TARGET_AVX512F"
5578   REAL_VALUE_TYPE TWO32r;
5579   rtx k, x, tmp[4];
5581   real_ldexp (&TWO32r, &dconst1, 32);
5582   x = const_double_from_real_value (TWO32r, DFmode);
5584   tmp[0] = force_reg (V8DFmode, CONST0_RTX (V8DFmode));
5585   tmp[1] = force_reg (V8DFmode, ix86_build_const_vector (V8DFmode, 1, x));
5586   tmp[2] = gen_reg_rtx (V8DFmode);
5587   tmp[3] = gen_reg_rtx (V8SImode);
5588   k = gen_reg_rtx (QImode);
5590   emit_insn (gen_vec_extract_hi_v16si (tmp[3], operands[1]));
5591   emit_insn (gen_floatv8siv8df2 (tmp[2], tmp[3]));
5592   emit_insn (gen_rtx_SET (k, gen_rtx_LT (QImode, tmp[2], tmp[0])));
5593   emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k));
5594   emit_move_insn (operands[0], tmp[2]);
5595   DONE;
5598 (define_expand "vec_unpacku_float_lo_v8si"
5599   [(match_operand:V4DF 0 "register_operand")
5600    (match_operand:V8SI 1 "nonimmediate_operand")]
5601   "TARGET_AVX"
5603   REAL_VALUE_TYPE TWO32r;
5604   rtx x, tmp[5];
5605   int i;
5607   real_ldexp (&TWO32r, &dconst1, 32);
5608   x = const_double_from_real_value (TWO32r, DFmode);
5610   tmp[0] = force_reg (V4DFmode, CONST0_RTX (V4DFmode));
5611   tmp[1] = force_reg (V4DFmode, ix86_build_const_vector (V4DFmode, 1, x));
5613   for (i = 2; i < 5; i++)
5614     tmp[i] = gen_reg_rtx (V4DFmode);
5615   emit_insn (gen_avx_cvtdq2pd256_2 (tmp[2], operands[1]));
5616   emit_insn (gen_rtx_SET (tmp[3], gen_rtx_LT (V4DFmode, tmp[2], tmp[0])));
5617   emit_insn (gen_andv4df3 (tmp[4], tmp[3], tmp[1]));
5618   emit_insn (gen_addv4df3 (operands[0], tmp[2], tmp[4]));
5619   DONE;
5622 (define_expand "vec_unpacku_float_lo_v16si"
5623   [(match_operand:V8DF 0 "register_operand")
5624    (match_operand:V16SI 1 "nonimmediate_operand")]
5625   "TARGET_AVX512F"
5627   REAL_VALUE_TYPE TWO32r;
5628   rtx k, x, tmp[3];
5630   real_ldexp (&TWO32r, &dconst1, 32);
5631   x = const_double_from_real_value (TWO32r, DFmode);
5633   tmp[0] = force_reg (V8DFmode, CONST0_RTX (V8DFmode));
5634   tmp[1] = force_reg (V8DFmode, ix86_build_const_vector (V8DFmode, 1, x));
5635   tmp[2] = gen_reg_rtx (V8DFmode);
5636   k = gen_reg_rtx (QImode);
5638   emit_insn (gen_avx512f_cvtdq2pd512_2 (tmp[2], operands[1]));
5639   emit_insn (gen_rtx_SET (k, gen_rtx_LT (QImode, tmp[2], tmp[0])));
5640   emit_insn (gen_addv8df3_mask (tmp[2], tmp[2], tmp[1], tmp[2], k));
5641   emit_move_insn (operands[0], tmp[2]);
5642   DONE;
5645 (define_expand "vec_pack_trunc_<mode>"
5646   [(set (match_dup 3)
5647         (float_truncate:<sf2dfmode>
5648           (match_operand:VF2_512_256 1 "nonimmediate_operand")))
5649    (set (match_dup 4)
5650         (float_truncate:<sf2dfmode>
5651           (match_operand:VF2_512_256 2 "nonimmediate_operand")))
5652    (set (match_operand:<ssePSmode> 0 "register_operand")
5653         (vec_concat:<ssePSmode>
5654           (match_dup 3)
5655           (match_dup 4)))]
5656   "TARGET_AVX"
5658   operands[3] = gen_reg_rtx (<sf2dfmode>mode);
5659   operands[4] = gen_reg_rtx (<sf2dfmode>mode);
5662 (define_expand "vec_pack_trunc_v2df"
5663   [(match_operand:V4SF 0 "register_operand")
5664    (match_operand:V2DF 1 "vector_operand")
5665    (match_operand:V2DF 2 "vector_operand")]
5666   "TARGET_SSE2"
5668   rtx tmp0, tmp1;
5670   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
5671     {
5672       tmp0 = gen_reg_rtx (V4DFmode);
5673       tmp1 = force_reg (V2DFmode, operands[1]);
5675       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
5676       emit_insn (gen_avx_cvtpd2ps256 (operands[0], tmp0));
5677     }
5678   else
5679     {
5680       tmp0 = gen_reg_rtx (V4SFmode);
5681       tmp1 = gen_reg_rtx (V4SFmode);
5683       emit_insn (gen_sse2_cvtpd2ps (tmp0, operands[1]));
5684       emit_insn (gen_sse2_cvtpd2ps (tmp1, operands[2]));
5685       emit_insn (gen_sse_movlhps (operands[0], tmp0, tmp1));
5686     }
5687   DONE;
5690 (define_expand "vec_pack_sfix_trunc_v8df"
5691   [(match_operand:V16SI 0 "register_operand")
5692    (match_operand:V8DF 1 "nonimmediate_operand")
5693    (match_operand:V8DF 2 "nonimmediate_operand")]
5694   "TARGET_AVX512F"
5696   rtx r1, r2;
5698   r1 = gen_reg_rtx (V8SImode);
5699   r2 = gen_reg_rtx (V8SImode);
5701   emit_insn (gen_fix_truncv8dfv8si2 (r1, operands[1]));
5702   emit_insn (gen_fix_truncv8dfv8si2 (r2, operands[2]));
5703   emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
5704   DONE;
5707 (define_expand "vec_pack_sfix_trunc_v4df"
5708   [(match_operand:V8SI 0 "register_operand")
5709    (match_operand:V4DF 1 "nonimmediate_operand")
5710    (match_operand:V4DF 2 "nonimmediate_operand")]
5711   "TARGET_AVX"
5713   rtx r1, r2;
5715   r1 = gen_reg_rtx (V4SImode);
5716   r2 = gen_reg_rtx (V4SImode);
5718   emit_insn (gen_fix_truncv4dfv4si2 (r1, operands[1]));
5719   emit_insn (gen_fix_truncv4dfv4si2 (r2, operands[2]));
5720   emit_insn (gen_avx_vec_concatv8si (operands[0], r1, r2));
5721   DONE;
5724 (define_expand "vec_pack_sfix_trunc_v2df"
5725   [(match_operand:V4SI 0 "register_operand")
5726    (match_operand:V2DF 1 "vector_operand")
5727    (match_operand:V2DF 2 "vector_operand")]
5728   "TARGET_SSE2"
5730   rtx tmp0, tmp1, tmp2;
5732   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
5733     {
5734       tmp0 = gen_reg_rtx (V4DFmode);
5735       tmp1 = force_reg (V2DFmode, operands[1]);
5737       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
5738       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp0));
5739     }
5740   else
5741     {
5742       tmp0 = gen_reg_rtx (V4SImode);
5743       tmp1 = gen_reg_rtx (V4SImode);
5744       tmp2 = gen_reg_rtx (V2DImode);
5746       emit_insn (gen_sse2_cvttpd2dq (tmp0, operands[1]));
5747       emit_insn (gen_sse2_cvttpd2dq (tmp1, operands[2]));
5748       emit_insn (gen_vec_interleave_lowv2di (tmp2,
5749                                              gen_lowpart (V2DImode, tmp0),
5750                                              gen_lowpart (V2DImode, tmp1)));
5751       emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp2));
5752     }
5753   DONE;
5756 (define_mode_attr ssepackfltmode
5757   [(V8DF "V16SI") (V4DF "V8SI") (V2DF "V4SI")])
5759 (define_expand "vec_pack_ufix_trunc_<mode>"
5760   [(match_operand:<ssepackfltmode> 0 "register_operand")
5761    (match_operand:VF2 1 "register_operand")
5762    (match_operand:VF2 2 "register_operand")]
5763   "TARGET_SSE2"
5765   if (<MODE>mode == V8DFmode)
5766     {
5767       rtx r1, r2;
5769       r1 = gen_reg_rtx (V8SImode);
5770       r2 = gen_reg_rtx (V8SImode);
5772       emit_insn (gen_ufix_truncv8dfv8si2 (r1, operands[1]));
5773       emit_insn (gen_ufix_truncv8dfv8si2 (r2, operands[2]));
5774       emit_insn (gen_avx_vec_concatv16si (operands[0], r1, r2));
5775     }
5776   else
5777     {
5778       rtx tmp[7];
5779       tmp[0] = ix86_expand_adjust_ufix_to_sfix_si (operands[1], &tmp[2]);
5780       tmp[1] = ix86_expand_adjust_ufix_to_sfix_si (operands[2], &tmp[3]);
5781       tmp[4] = gen_reg_rtx (<ssepackfltmode>mode);
5782       emit_insn (gen_vec_pack_sfix_trunc_<mode> (tmp[4], tmp[0], tmp[1]));
5783       if (<ssepackfltmode>mode == V4SImode || TARGET_AVX2)
5784         {
5785           tmp[5] = gen_reg_rtx (<ssepackfltmode>mode);
5786           ix86_expand_vec_extract_even_odd (tmp[5], tmp[2], tmp[3], 0);
5787         }
5788       else
5789         {
5790           tmp[5] = gen_reg_rtx (V8SFmode);
5791           ix86_expand_vec_extract_even_odd (tmp[5],
5792                                             gen_lowpart (V8SFmode, tmp[2]),
5793                                             gen_lowpart (V8SFmode, tmp[3]), 0);
5794           tmp[5] = gen_lowpart (V8SImode, tmp[5]);
5795         }
5796       tmp[6] = expand_simple_binop (<ssepackfltmode>mode, XOR, tmp[4], tmp[5],
5797                                     operands[0], 0, OPTAB_DIRECT);
5798       if (tmp[6] != operands[0])
5799         emit_move_insn (operands[0], tmp[6]);
5800     }
5802   DONE;
5805 (define_expand "vec_pack_sfix_v4df"
5806   [(match_operand:V8SI 0 "register_operand")
5807    (match_operand:V4DF 1 "nonimmediate_operand")
5808    (match_operand:V4DF 2 "nonimmediate_operand")]
5809   "TARGET_AVX"
5811   rtx r1, r2;
5813   r1 = gen_reg_rtx (V4SImode);
5814   r2 = gen_reg_rtx (V4SImode);
5816   emit_insn (gen_avx_cvtpd2dq256 (r1, operands[1]));
5817   emit_insn (gen_avx_cvtpd2dq256 (r2, operands[2]));
5818   emit_insn (gen_avx_vec_concatv8si (operands[0], r1, r2));
5819   DONE;
5822 (define_expand "vec_pack_sfix_v2df"
5823   [(match_operand:V4SI 0 "register_operand")
5824    (match_operand:V2DF 1 "vector_operand")
5825    (match_operand:V2DF 2 "vector_operand")]
5826   "TARGET_SSE2"
5828   rtx tmp0, tmp1, tmp2;
5830   if (TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
5831     {
5832       tmp0 = gen_reg_rtx (V4DFmode);
5833       tmp1 = force_reg (V2DFmode, operands[1]);
5835       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
5836       emit_insn (gen_avx_cvtpd2dq256 (operands[0], tmp0));
5837     }
5838   else
5839     {
5840       tmp0 = gen_reg_rtx (V4SImode);
5841       tmp1 = gen_reg_rtx (V4SImode);
5842       tmp2 = gen_reg_rtx (V2DImode);
5844       emit_insn (gen_sse2_cvtpd2dq (tmp0, operands[1]));
5845       emit_insn (gen_sse2_cvtpd2dq (tmp1, operands[2]));
5846       emit_insn (gen_vec_interleave_lowv2di (tmp2,
5847                                              gen_lowpart (V2DImode, tmp0),
5848                                              gen_lowpart (V2DImode, tmp1)));
5849       emit_move_insn (operands[0], gen_lowpart (V4SImode, tmp2));
5850     }
5851   DONE;
5854 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5856 ;; Parallel single-precision floating point element swizzling
5858 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5860 (define_expand "sse_movhlps_exp"
5861   [(set (match_operand:V4SF 0 "nonimmediate_operand")
5862         (vec_select:V4SF
5863           (vec_concat:V8SF
5864             (match_operand:V4SF 1 "nonimmediate_operand")
5865             (match_operand:V4SF 2 "nonimmediate_operand"))
5866           (parallel [(const_int 6)
5867                      (const_int 7)
5868                      (const_int 2)
5869                      (const_int 3)])))]
5870   "TARGET_SSE"
5872   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
5874   emit_insn (gen_sse_movhlps (dst, operands[1], operands[2]));
5876   /* Fix up the destination if needed.  */
5877   if (dst != operands[0])
5878     emit_move_insn (operands[0], dst);
5880   DONE;
5883 (define_insn "sse_movhlps"
5884   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,m")
5885         (vec_select:V4SF
5886           (vec_concat:V8SF
5887             (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
5888             (match_operand:V4SF 2 "nonimmediate_operand" " x,v,o,o,v"))
5889           (parallel [(const_int 6)
5890                      (const_int 7)
5891                      (const_int 2)
5892                      (const_int 3)])))]
5893   "TARGET_SSE && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
5894   "@
5895    movhlps\t{%2, %0|%0, %2}
5896    vmovhlps\t{%2, %1, %0|%0, %1, %2}
5897    movlps\t{%H2, %0|%0, %H2}
5898    vmovlps\t{%H2, %1, %0|%0, %1, %H2}
5899    %vmovhps\t{%2, %0|%q0, %2}"
5900   [(set_attr "isa" "noavx,avx,noavx,avx,*")
5901    (set_attr "type" "ssemov")
5902    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
5903    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
5905 (define_expand "sse_movlhps_exp"
5906   [(set (match_operand:V4SF 0 "nonimmediate_operand")
5907         (vec_select:V4SF
5908           (vec_concat:V8SF
5909             (match_operand:V4SF 1 "nonimmediate_operand")
5910             (match_operand:V4SF 2 "nonimmediate_operand"))
5911           (parallel [(const_int 0)
5912                      (const_int 1)
5913                      (const_int 4)
5914                      (const_int 5)])))]
5915   "TARGET_SSE"
5917   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
5919   emit_insn (gen_sse_movlhps (dst, operands[1], operands[2]));
5921   /* Fix up the destination if needed.  */
5922   if (dst != operands[0])
5923     emit_move_insn (operands[0], dst);
5925   DONE;
5928 (define_insn "sse_movlhps"
5929   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,o")
5930         (vec_select:V4SF
5931           (vec_concat:V8SF
5932             (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
5933             (match_operand:V4SF 2 "nonimmediate_operand" " x,v,m,v,v"))
5934           (parallel [(const_int 0)
5935                      (const_int 1)
5936                      (const_int 4)
5937                      (const_int 5)])))]
5938   "TARGET_SSE && ix86_binary_operator_ok (UNKNOWN, V4SFmode, operands)"
5939   "@
5940    movlhps\t{%2, %0|%0, %2}
5941    vmovlhps\t{%2, %1, %0|%0, %1, %2}
5942    movhps\t{%2, %0|%0, %q2}
5943    vmovhps\t{%2, %1, %0|%0, %1, %q2}
5944    %vmovlps\t{%2, %H0|%H0, %2}"
5945   [(set_attr "isa" "noavx,avx,noavx,avx,*")
5946    (set_attr "type" "ssemov")
5947    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
5948    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
5950 (define_insn "<mask_codefor>avx512f_unpckhps512<mask_name>"
5951   [(set (match_operand:V16SF 0 "register_operand" "=v")
5952         (vec_select:V16SF
5953           (vec_concat:V32SF
5954             (match_operand:V16SF 1 "register_operand" "v")
5955             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
5956           (parallel [(const_int 2) (const_int 18)
5957                      (const_int 3) (const_int 19)
5958                      (const_int 6) (const_int 22)
5959                      (const_int 7) (const_int 23)
5960                      (const_int 10) (const_int 26)
5961                      (const_int 11) (const_int 27)
5962                      (const_int 14) (const_int 30)
5963                      (const_int 15) (const_int 31)])))]
5964   "TARGET_AVX512F"
5965   "vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
5966   [(set_attr "type" "sselog")
5967    (set_attr "prefix" "evex")
5968    (set_attr "mode" "V16SF")])
5970 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
5971 (define_insn "avx_unpckhps256<mask_name>"
5972   [(set (match_operand:V8SF 0 "register_operand" "=v")
5973         (vec_select:V8SF
5974           (vec_concat:V16SF
5975             (match_operand:V8SF 1 "register_operand" "v")
5976             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
5977           (parallel [(const_int 2) (const_int 10)
5978                      (const_int 3) (const_int 11)
5979                      (const_int 6) (const_int 14)
5980                      (const_int 7) (const_int 15)])))]
5981   "TARGET_AVX && <mask_avx512vl_condition>"
5982   "vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
5983   [(set_attr "type" "sselog")
5984    (set_attr "prefix" "vex")
5985    (set_attr "mode" "V8SF")])
5987 (define_expand "vec_interleave_highv8sf"
5988   [(set (match_dup 3)
5989         (vec_select:V8SF
5990           (vec_concat:V16SF
5991             (match_operand:V8SF 1 "register_operand")
5992             (match_operand:V8SF 2 "nonimmediate_operand"))
5993           (parallel [(const_int 0) (const_int 8)
5994                      (const_int 1) (const_int 9)
5995                      (const_int 4) (const_int 12)
5996                      (const_int 5) (const_int 13)])))
5997    (set (match_dup 4)
5998         (vec_select:V8SF
5999           (vec_concat:V16SF
6000             (match_dup 1)
6001             (match_dup 2))
6002           (parallel [(const_int 2) (const_int 10)
6003                      (const_int 3) (const_int 11)
6004                      (const_int 6) (const_int 14)
6005                      (const_int 7) (const_int 15)])))
6006    (set (match_operand:V8SF 0 "register_operand")
6007         (vec_select:V8SF
6008           (vec_concat:V16SF
6009             (match_dup 3)
6010             (match_dup 4))
6011           (parallel [(const_int 4) (const_int 5)
6012                      (const_int 6) (const_int 7)
6013                      (const_int 12) (const_int 13)
6014                      (const_int 14) (const_int 15)])))]
6015  "TARGET_AVX"
6017   operands[3] = gen_reg_rtx (V8SFmode);
6018   operands[4] = gen_reg_rtx (V8SFmode);
6021 (define_insn "vec_interleave_highv4sf<mask_name>"
6022   [(set (match_operand:V4SF 0 "register_operand" "=x,v")
6023         (vec_select:V4SF
6024           (vec_concat:V8SF
6025             (match_operand:V4SF 1 "register_operand" "0,v")
6026             (match_operand:V4SF 2 "vector_operand" "xBm,vm"))
6027           (parallel [(const_int 2) (const_int 6)
6028                      (const_int 3) (const_int 7)])))]
6029   "TARGET_SSE && <mask_avx512vl_condition>"
6030   "@
6031    unpckhps\t{%2, %0|%0, %2}
6032    vunpckhps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6033   [(set_attr "isa" "noavx,avx")
6034    (set_attr "type" "sselog")
6035    (set_attr "prefix" "orig,vex")
6036    (set_attr "mode" "V4SF")])
6038 (define_insn "<mask_codefor>avx512f_unpcklps512<mask_name>"
6039   [(set (match_operand:V16SF 0 "register_operand" "=v")
6040         (vec_select:V16SF
6041           (vec_concat:V32SF
6042             (match_operand:V16SF 1 "register_operand" "v")
6043             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
6044           (parallel [(const_int 0) (const_int 16)
6045                      (const_int 1) (const_int 17)
6046                      (const_int 4) (const_int 20)
6047                      (const_int 5) (const_int 21)
6048                      (const_int 8) (const_int 24)
6049                      (const_int 9) (const_int 25)
6050                      (const_int 12) (const_int 28)
6051                      (const_int 13) (const_int 29)])))]
6052   "TARGET_AVX512F"
6053   "vunpcklps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6054   [(set_attr "type" "sselog")
6055    (set_attr "prefix" "evex")
6056    (set_attr "mode" "V16SF")])
6058 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
6059 (define_insn "avx_unpcklps256<mask_name>"
6060   [(set (match_operand:V8SF 0 "register_operand" "=v")
6061         (vec_select:V8SF
6062           (vec_concat:V16SF
6063             (match_operand:V8SF 1 "register_operand" "v")
6064             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6065           (parallel [(const_int 0) (const_int 8)
6066                      (const_int 1) (const_int 9)
6067                      (const_int 4) (const_int 12)
6068                      (const_int 5) (const_int 13)])))]
6069   "TARGET_AVX && <mask_avx512vl_condition>"
6070   "vunpcklps\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
6071   [(set_attr "type" "sselog")
6072    (set_attr "prefix" "vex")
6073    (set_attr "mode" "V8SF")])
6075 (define_insn "unpcklps128_mask"
6076   [(set (match_operand:V4SF 0 "register_operand" "=v")
6077         (vec_merge:V4SF
6078           (vec_select:V4SF
6079             (vec_concat:V8SF
6080               (match_operand:V4SF 1 "register_operand" "v")
6081               (match_operand:V4SF 2 "nonimmediate_operand" "vm"))
6082             (parallel [(const_int 0) (const_int 4)
6083                       (const_int 1) (const_int 5)]))
6084           (match_operand:V4SF 3 "vector_move_operand" "0C")
6085           (match_operand:QI 4 "register_operand" "Yk")))]
6086   "TARGET_AVX512VL"
6087   "vunpcklps\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
6088   [(set_attr "type" "sselog")
6089    (set_attr "prefix" "evex")
6090    (set_attr "mode" "V4SF")])
6092 (define_expand "vec_interleave_lowv8sf"
6093   [(set (match_dup 3)
6094         (vec_select:V8SF
6095           (vec_concat:V16SF
6096             (match_operand:V8SF 1 "register_operand")
6097             (match_operand:V8SF 2 "nonimmediate_operand"))
6098           (parallel [(const_int 0) (const_int 8)
6099                      (const_int 1) (const_int 9)
6100                      (const_int 4) (const_int 12)
6101                      (const_int 5) (const_int 13)])))
6102    (set (match_dup 4)
6103         (vec_select:V8SF
6104           (vec_concat:V16SF
6105             (match_dup 1)
6106             (match_dup 2))
6107           (parallel [(const_int 2) (const_int 10)
6108                      (const_int 3) (const_int 11)
6109                      (const_int 6) (const_int 14)
6110                      (const_int 7) (const_int 15)])))
6111    (set (match_operand:V8SF 0 "register_operand")
6112         (vec_select:V8SF
6113           (vec_concat:V16SF
6114             (match_dup 3)
6115             (match_dup 4))
6116           (parallel [(const_int 0) (const_int 1)
6117                      (const_int 2) (const_int 3)
6118                      (const_int 8) (const_int 9)
6119                      (const_int 10) (const_int 11)])))]
6120  "TARGET_AVX"
6122   operands[3] = gen_reg_rtx (V8SFmode);
6123   operands[4] = gen_reg_rtx (V8SFmode);
6126 (define_insn "vec_interleave_lowv4sf"
6127   [(set (match_operand:V4SF 0 "register_operand" "=x,v")
6128         (vec_select:V4SF
6129           (vec_concat:V8SF
6130             (match_operand:V4SF 1 "register_operand" "0,v")
6131             (match_operand:V4SF 2 "vector_operand" "xBm,vm"))
6132           (parallel [(const_int 0) (const_int 4)
6133                      (const_int 1) (const_int 5)])))]
6134   "TARGET_SSE"
6135   "@
6136    unpcklps\t{%2, %0|%0, %2}
6137    vunpcklps\t{%2, %1, %0|%0, %1, %2}"
6138   [(set_attr "isa" "noavx,avx")
6139    (set_attr "type" "sselog")
6140    (set_attr "prefix" "orig,maybe_evex")
6141    (set_attr "mode" "V4SF")])
6143 ;; These are modeled with the same vec_concat as the others so that we
6144 ;; capture users of shufps that can use the new instructions
6145 (define_insn "avx_movshdup256<mask_name>"
6146   [(set (match_operand:V8SF 0 "register_operand" "=v")
6147         (vec_select:V8SF
6148           (vec_concat:V16SF
6149             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
6150             (match_dup 1))
6151           (parallel [(const_int 1) (const_int 1)
6152                      (const_int 3) (const_int 3)
6153                      (const_int 5) (const_int 5)
6154                      (const_int 7) (const_int 7)])))]
6155   "TARGET_AVX && <mask_avx512vl_condition>"
6156   "vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6157   [(set_attr "type" "sse")
6158    (set_attr "prefix" "vex")
6159    (set_attr "mode" "V8SF")])
6161 (define_insn "sse3_movshdup<mask_name>"
6162   [(set (match_operand:V4SF 0 "register_operand" "=v")
6163         (vec_select:V4SF
6164           (vec_concat:V8SF
6165             (match_operand:V4SF 1 "vector_operand" "vBm")
6166             (match_dup 1))
6167           (parallel [(const_int 1)
6168                      (const_int 1)
6169                      (const_int 7)
6170                      (const_int 7)])))]
6171   "TARGET_SSE3 && <mask_avx512vl_condition>"
6172   "%vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6173   [(set_attr "type" "sse")
6174    (set_attr "prefix_rep" "1")
6175    (set_attr "prefix" "maybe_vex")
6176    (set_attr "mode" "V4SF")])
6178 (define_insn "<mask_codefor>avx512f_movshdup512<mask_name>"
6179   [(set (match_operand:V16SF 0 "register_operand" "=v")
6180         (vec_select:V16SF
6181           (vec_concat:V32SF
6182             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
6183             (match_dup 1))
6184           (parallel [(const_int 1) (const_int 1)
6185                      (const_int 3) (const_int 3)
6186                      (const_int 5) (const_int 5)
6187                      (const_int 7) (const_int 7)
6188                      (const_int 9) (const_int 9)
6189                      (const_int 11) (const_int 11)
6190                      (const_int 13) (const_int 13)
6191                      (const_int 15) (const_int 15)])))]
6192   "TARGET_AVX512F"
6193   "vmovshdup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6194   [(set_attr "type" "sse")
6195    (set_attr "prefix" "evex")
6196    (set_attr "mode" "V16SF")])
6198 (define_insn "avx_movsldup256<mask_name>"
6199   [(set (match_operand:V8SF 0 "register_operand" "=v")
6200         (vec_select:V8SF
6201           (vec_concat:V16SF
6202             (match_operand:V8SF 1 "nonimmediate_operand" "vm")
6203             (match_dup 1))
6204           (parallel [(const_int 0) (const_int 0)
6205                      (const_int 2) (const_int 2)
6206                      (const_int 4) (const_int 4)
6207                      (const_int 6) (const_int 6)])))]
6208   "TARGET_AVX && <mask_avx512vl_condition>"
6209   "vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6210   [(set_attr "type" "sse")
6211    (set_attr "prefix" "vex")
6212    (set_attr "mode" "V8SF")])
6214 (define_insn "sse3_movsldup<mask_name>"
6215   [(set (match_operand:V4SF 0 "register_operand" "=v")
6216         (vec_select:V4SF
6217           (vec_concat:V8SF
6218             (match_operand:V4SF 1 "vector_operand" "vBm")
6219             (match_dup 1))
6220           (parallel [(const_int 0)
6221                      (const_int 0)
6222                      (const_int 6)
6223                      (const_int 6)])))]
6224   "TARGET_SSE3 && <mask_avx512vl_condition>"
6225   "%vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6226   [(set_attr "type" "sse")
6227    (set_attr "prefix_rep" "1")
6228    (set_attr "prefix" "maybe_vex")
6229    (set_attr "mode" "V4SF")])
6231 (define_insn "<mask_codefor>avx512f_movsldup512<mask_name>"
6232   [(set (match_operand:V16SF 0 "register_operand" "=v")
6233         (vec_select:V16SF
6234           (vec_concat:V32SF
6235             (match_operand:V16SF 1 "nonimmediate_operand" "vm")
6236             (match_dup 1))
6237           (parallel [(const_int 0) (const_int 0)
6238                      (const_int 2) (const_int 2)
6239                      (const_int 4) (const_int 4)
6240                      (const_int 6) (const_int 6)
6241                      (const_int 8) (const_int 8)
6242                      (const_int 10) (const_int 10)
6243                      (const_int 12) (const_int 12)
6244                      (const_int 14) (const_int 14)])))]
6245   "TARGET_AVX512F"
6246   "vmovsldup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
6247   [(set_attr "type" "sse")
6248    (set_attr "prefix" "evex")
6249    (set_attr "mode" "V16SF")])
6251 (define_expand "avx_shufps256<mask_expand4_name>"
6252   [(match_operand:V8SF 0 "register_operand")
6253    (match_operand:V8SF 1 "register_operand")
6254    (match_operand:V8SF 2 "nonimmediate_operand")
6255    (match_operand:SI 3 "const_int_operand")]
6256   "TARGET_AVX"
6258   int mask = INTVAL (operands[3]);
6259   emit_insn (gen_avx_shufps256_1<mask_expand4_name> (operands[0],
6260                                                      operands[1],
6261                                                      operands[2],
6262                                                      GEN_INT ((mask >> 0) & 3),
6263                                                      GEN_INT ((mask >> 2) & 3),
6264                                                      GEN_INT (((mask >> 4) & 3) + 8),
6265                                                      GEN_INT (((mask >> 6) & 3) + 8),
6266                                                      GEN_INT (((mask >> 0) & 3) + 4),
6267                                                      GEN_INT (((mask >> 2) & 3) + 4),
6268                                                      GEN_INT (((mask >> 4) & 3) + 12),
6269                                                      GEN_INT (((mask >> 6) & 3) + 12)
6270                                                      <mask_expand4_args>));
6271   DONE;
6274 ;; One bit in mask selects 2 elements.
6275 (define_insn "avx_shufps256_1<mask_name>"
6276   [(set (match_operand:V8SF 0 "register_operand" "=v")
6277         (vec_select:V8SF
6278           (vec_concat:V16SF
6279             (match_operand:V8SF 1 "register_operand" "v")
6280             (match_operand:V8SF 2 "nonimmediate_operand" "vm"))
6281           (parallel [(match_operand 3  "const_0_to_3_operand"  )
6282                      (match_operand 4  "const_0_to_3_operand"  )
6283                      (match_operand 5  "const_8_to_11_operand" )
6284                      (match_operand 6  "const_8_to_11_operand" )
6285                      (match_operand 7  "const_4_to_7_operand"  )
6286                      (match_operand 8  "const_4_to_7_operand"  )
6287                      (match_operand 9  "const_12_to_15_operand")
6288                      (match_operand 10 "const_12_to_15_operand")])))]
6289   "TARGET_AVX
6290    && <mask_avx512vl_condition>
6291    && (INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
6292        && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
6293        && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4)
6294        && INTVAL (operands[6]) == (INTVAL (operands[10]) - 4))"
6296   int mask;
6297   mask = INTVAL (operands[3]);
6298   mask |= INTVAL (operands[4]) << 2;
6299   mask |= (INTVAL (operands[5]) - 8) << 4;
6300   mask |= (INTVAL (operands[6]) - 8) << 6;
6301   operands[3] = GEN_INT (mask);
6303   return "vshufps\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
6305   [(set_attr "type" "sseshuf")
6306    (set_attr "length_immediate" "1")
6307    (set_attr "prefix" "<mask_prefix>")
6308    (set_attr "mode" "V8SF")])
6310 (define_expand "sse_shufps<mask_expand4_name>"
6311   [(match_operand:V4SF 0 "register_operand")
6312    (match_operand:V4SF 1 "register_operand")
6313    (match_operand:V4SF 2 "vector_operand")
6314    (match_operand:SI 3 "const_int_operand")]
6315   "TARGET_SSE"
6317   int mask = INTVAL (operands[3]);
6318   emit_insn (gen_sse_shufps_v4sf<mask_expand4_name> (operands[0],
6319                                                      operands[1],
6320                                                      operands[2],
6321                                                      GEN_INT ((mask >> 0) & 3),
6322                                                      GEN_INT ((mask >> 2) & 3),
6323                                                      GEN_INT (((mask >> 4) & 3) + 4),
6324                                                      GEN_INT (((mask >> 6) & 3) + 4)
6325                                                      <mask_expand4_args>));
6326   DONE;
6329 (define_insn "sse_shufps_v4sf_mask"
6330   [(set (match_operand:V4SF 0 "register_operand" "=v")
6331     (vec_merge:V4SF
6332           (vec_select:V4SF
6333             (vec_concat:V8SF
6334               (match_operand:V4SF 1 "register_operand" "v")
6335               (match_operand:V4SF 2 "nonimmediate_operand" "vm"))
6336             (parallel [(match_operand 3 "const_0_to_3_operand")
6337                        (match_operand 4 "const_0_to_3_operand")
6338                        (match_operand 5 "const_4_to_7_operand")
6339                        (match_operand 6 "const_4_to_7_operand")]))
6340       (match_operand:V4SF 7 "vector_move_operand" "0C")
6341       (match_operand:QI 8 "register_operand" "Yk")))]
6342   "TARGET_AVX512VL"
6344   int mask = 0;
6345   mask |= INTVAL (operands[3]) << 0;
6346   mask |= INTVAL (operands[4]) << 2;
6347   mask |= (INTVAL (operands[5]) - 4) << 4;
6348   mask |= (INTVAL (operands[6]) - 4) << 6;
6349   operands[3] = GEN_INT (mask);
6351   return "vshufps\t{%3, %2, %1, %0%{%8%}%N7|%0%{%8%}%N7, %1, %2, %3}";
6353   [(set_attr "type" "sseshuf")
6354    (set_attr "length_immediate" "1")
6355    (set_attr "prefix" "evex")
6356    (set_attr "mode" "V4SF")])
6358 (define_insn "sse_shufps_<mode>"
6359   [(set (match_operand:VI4F_128 0 "register_operand" "=x,v")
6360         (vec_select:VI4F_128
6361           (vec_concat:<ssedoublevecmode>
6362             (match_operand:VI4F_128 1 "register_operand" "0,v")
6363             (match_operand:VI4F_128 2 "vector_operand" "xBm,vm"))
6364           (parallel [(match_operand 3 "const_0_to_3_operand")
6365                      (match_operand 4 "const_0_to_3_operand")
6366                      (match_operand 5 "const_4_to_7_operand")
6367                      (match_operand 6 "const_4_to_7_operand")])))]
6368   "TARGET_SSE"
6370   int mask = 0;
6371   mask |= INTVAL (operands[3]) << 0;
6372   mask |= INTVAL (operands[4]) << 2;
6373   mask |= (INTVAL (operands[5]) - 4) << 4;
6374   mask |= (INTVAL (operands[6]) - 4) << 6;
6375   operands[3] = GEN_INT (mask);
6377   switch (which_alternative)
6378     {
6379     case 0:
6380       return "shufps\t{%3, %2, %0|%0, %2, %3}";
6381     case 1:
6382       return "vshufps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
6383     default:
6384       gcc_unreachable ();
6385     }
6387   [(set_attr "isa" "noavx,avx")
6388    (set_attr "type" "sseshuf")
6389    (set_attr "length_immediate" "1")
6390    (set_attr "prefix" "orig,maybe_evex")
6391    (set_attr "mode" "V4SF")])
6393 (define_insn "sse_storehps"
6394   [(set (match_operand:V2SF 0 "nonimmediate_operand" "=m,v,v")
6395         (vec_select:V2SF
6396           (match_operand:V4SF 1 "nonimmediate_operand" "v,v,o")
6397           (parallel [(const_int 2) (const_int 3)])))]
6398   "TARGET_SSE"
6399   "@
6400    %vmovhps\t{%1, %0|%q0, %1}
6401    %vmovhlps\t{%1, %d0|%d0, %1}
6402    %vmovlps\t{%H1, %d0|%d0, %H1}"
6403   [(set_attr "type" "ssemov")
6404    (set_attr "prefix" "maybe_vex")
6405    (set_attr "mode" "V2SF,V4SF,V2SF")])
6407 (define_expand "sse_loadhps_exp"
6408   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6409         (vec_concat:V4SF
6410           (vec_select:V2SF
6411             (match_operand:V4SF 1 "nonimmediate_operand")
6412             (parallel [(const_int 0) (const_int 1)]))
6413           (match_operand:V2SF 2 "nonimmediate_operand")))]
6414   "TARGET_SSE"
6416   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6418   emit_insn (gen_sse_loadhps (dst, operands[1], operands[2]));
6420   /* Fix up the destination if needed.  */
6421   if (dst != operands[0])
6422     emit_move_insn (operands[0], dst);
6424   DONE;
6427 (define_insn "sse_loadhps"
6428   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,o")
6429         (vec_concat:V4SF
6430           (vec_select:V2SF
6431             (match_operand:V4SF 1 "nonimmediate_operand" " 0,v,0,v,0")
6432             (parallel [(const_int 0) (const_int 1)]))
6433           (match_operand:V2SF 2 "nonimmediate_operand"   " m,m,x,v,v")))]
6434   "TARGET_SSE"
6435   "@
6436    movhps\t{%2, %0|%0, %q2}
6437    vmovhps\t{%2, %1, %0|%0, %1, %q2}
6438    movlhps\t{%2, %0|%0, %2}
6439    vmovlhps\t{%2, %1, %0|%0, %1, %2}
6440    %vmovlps\t{%2, %H0|%H0, %2}"
6441   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6442    (set_attr "type" "ssemov")
6443    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
6444    (set_attr "mode" "V2SF,V2SF,V4SF,V4SF,V2SF")])
6446 (define_insn "sse_storelps"
6447   [(set (match_operand:V2SF 0 "nonimmediate_operand"   "=m,v,v")
6448         (vec_select:V2SF
6449           (match_operand:V4SF 1 "nonimmediate_operand" " v,v,m")
6450           (parallel [(const_int 0) (const_int 1)])))]
6451   "TARGET_SSE"
6452   "@
6453    %vmovlps\t{%1, %0|%q0, %1}
6454    %vmovaps\t{%1, %0|%0, %1}
6455    %vmovlps\t{%1, %d0|%d0, %q1}"
6456   [(set_attr "type" "ssemov")
6457    (set_attr "prefix" "maybe_vex")
6458    (set_attr "mode" "V2SF,V4SF,V2SF")])
6460 (define_expand "sse_loadlps_exp"
6461   [(set (match_operand:V4SF 0 "nonimmediate_operand")
6462         (vec_concat:V4SF
6463           (match_operand:V2SF 2 "nonimmediate_operand")
6464           (vec_select:V2SF
6465             (match_operand:V4SF 1 "nonimmediate_operand")
6466             (parallel [(const_int 2) (const_int 3)]))))]
6467   "TARGET_SSE"
6469   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V4SFmode, operands);
6471   emit_insn (gen_sse_loadlps (dst, operands[1], operands[2]));
6473   /* Fix up the destination if needed.  */
6474   if (dst != operands[0])
6475     emit_move_insn (operands[0], dst);
6477   DONE;
6480 (define_insn "sse_loadlps"
6481   [(set (match_operand:V4SF 0 "nonimmediate_operand"     "=x,v,x,v,m")
6482         (vec_concat:V4SF
6483           (match_operand:V2SF 2 "nonimmediate_operand"   " 0,v,m,m,v")
6484           (vec_select:V2SF
6485             (match_operand:V4SF 1 "nonimmediate_operand" " x,v,0,v,0")
6486             (parallel [(const_int 2) (const_int 3)]))))]
6487   "TARGET_SSE"
6488   "@
6489    shufps\t{$0xe4, %1, %0|%0, %1, 0xe4}
6490    vshufps\t{$0xe4, %1, %2, %0|%0, %2, %1, 0xe4}
6491    movlps\t{%2, %0|%0, %q2}
6492    vmovlps\t{%2, %1, %0|%0, %1, %q2}
6493    %vmovlps\t{%2, %0|%q0, %2}"
6494   [(set_attr "isa" "noavx,avx,noavx,avx,*")
6495    (set_attr "type" "sseshuf,sseshuf,ssemov,ssemov,ssemov")
6496    (set_attr "length_immediate" "1,1,*,*,*")
6497    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex")
6498    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF,V2SF")])
6500 (define_insn "sse_movss"
6501   [(set (match_operand:V4SF 0 "register_operand"   "=x,v")
6502         (vec_merge:V4SF
6503           (match_operand:V4SF 2 "register_operand" " x,v")
6504           (match_operand:V4SF 1 "register_operand" " 0,v")
6505           (const_int 1)))]
6506   "TARGET_SSE"
6507   "@
6508    movss\t{%2, %0|%0, %2}
6509    vmovss\t{%2, %1, %0|%0, %1, %2}"
6510   [(set_attr "isa" "noavx,avx")
6511    (set_attr "type" "ssemov")
6512    (set_attr "prefix" "orig,maybe_evex")
6513    (set_attr "mode" "SF")])
6515 (define_insn "avx2_vec_dup<mode>"
6516   [(set (match_operand:VF1_128_256 0 "register_operand" "=v")
6517         (vec_duplicate:VF1_128_256
6518           (vec_select:SF
6519             (match_operand:V4SF 1 "register_operand" "v")
6520             (parallel [(const_int 0)]))))]
6521   "TARGET_AVX2"
6522   "vbroadcastss\t{%1, %0|%0, %1}"
6523   [(set_attr "type" "sselog1")
6524     (set_attr "prefix" "maybe_evex")
6525     (set_attr "mode" "<MODE>")])
6527 (define_insn "avx2_vec_dupv8sf_1"
6528   [(set (match_operand:V8SF 0 "register_operand" "=v")
6529         (vec_duplicate:V8SF
6530           (vec_select:SF
6531             (match_operand:V8SF 1 "register_operand" "v")
6532             (parallel [(const_int 0)]))))]
6533   "TARGET_AVX2"
6534   "vbroadcastss\t{%x1, %0|%0, %x1}"
6535   [(set_attr "type" "sselog1")
6536     (set_attr "prefix" "maybe_evex")
6537     (set_attr "mode" "V8SF")])
6539 (define_insn "avx512f_vec_dup<mode>_1"
6540   [(set (match_operand:VF_512 0 "register_operand" "=v")
6541         (vec_duplicate:VF_512
6542           (vec_select:<ssescalarmode>
6543             (match_operand:VF_512 1 "register_operand" "v")
6544             (parallel [(const_int 0)]))))]
6545   "TARGET_AVX512F"
6546   "vbroadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}"
6547   [(set_attr "type" "sselog1")
6548     (set_attr "prefix" "evex")
6549     (set_attr "mode" "<MODE>")])
6551 ;; Although insertps takes register source, we prefer
6552 ;; unpcklps with register source since it is shorter.
6553 (define_insn "*vec_concatv2sf_sse4_1"
6554   [(set (match_operand:V2SF 0 "register_operand"
6555           "=Yr,*x, v,Yr,*x,v,v,*y ,*y")
6556         (vec_concat:V2SF
6557           (match_operand:SF 1 "nonimmediate_operand"
6558           "  0, 0,Yv, 0,0, v,m, 0 , m")
6559           (match_operand:SF 2 "vector_move_operand"
6560           " Yr,*x,Yv, m,m, m,C,*ym, C")))]
6561   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
6562   "@
6563    unpcklps\t{%2, %0|%0, %2}
6564    unpcklps\t{%2, %0|%0, %2}
6565    vunpcklps\t{%2, %1, %0|%0, %1, %2}
6566    insertps\t{$0x10, %2, %0|%0, %2, 0x10}
6567    insertps\t{$0x10, %2, %0|%0, %2, 0x10}
6568    vinsertps\t{$0x10, %2, %1, %0|%0, %1, %2, 0x10}
6569    %vmovss\t{%1, %0|%0, %1}
6570    punpckldq\t{%2, %0|%0, %2}
6571    movd\t{%1, %0|%0, %1}"
6572   [(set_attr "isa" "noavx,noavx,avx,noavx,noavx,avx,*,*,*")
6573    (set_attr "type" "sselog,sselog,sselog,sselog,sselog,sselog,ssemov,mmxcvt,mmxmov")
6574    (set_attr "prefix_data16" "*,*,*,1,1,*,*,*,*")
6575    (set_attr "prefix_extra" "*,*,*,1,1,1,*,*,*")
6576    (set_attr "length_immediate" "*,*,*,1,1,1,*,*,*")
6577    (set_attr "prefix" "orig,orig,maybe_evex,orig,orig,maybe_evex,maybe_vex,orig,orig")
6578    (set_attr "mode" "V4SF,V4SF,V4SF,V4SF,V4SF,V4SF,SF,DI,DI")])
6580 ;; ??? In theory we can match memory for the MMX alternative, but allowing
6581 ;; vector_operand for operand 2 and *not* allowing memory for the SSE
6582 ;; alternatives pretty much forces the MMX alternative to be chosen.
6583 (define_insn "*vec_concatv2sf_sse"
6584   [(set (match_operand:V2SF 0 "register_operand"     "=x,x,*y,*y")
6585         (vec_concat:V2SF
6586           (match_operand:SF 1 "nonimmediate_operand" " 0,m, 0, m")
6587           (match_operand:SF 2 "reg_or_0_operand"     " x,C,*y, C")))]
6588   "TARGET_SSE"
6589   "@
6590    unpcklps\t{%2, %0|%0, %2}
6591    movss\t{%1, %0|%0, %1}
6592    punpckldq\t{%2, %0|%0, %2}
6593    movd\t{%1, %0|%0, %1}"
6594   [(set_attr "type" "sselog,ssemov,mmxcvt,mmxmov")
6595    (set_attr "mode" "V4SF,SF,DI,DI")])
6597 (define_insn "*vec_concatv4sf"
6598   [(set (match_operand:V4SF 0 "register_operand"       "=x,v,x,v")
6599         (vec_concat:V4SF
6600           (match_operand:V2SF 1 "register_operand"     " 0,v,0,v")
6601           (match_operand:V2SF 2 "nonimmediate_operand" " x,v,m,m")))]
6602   "TARGET_SSE"
6603   "@
6604    movlhps\t{%2, %0|%0, %2}
6605    vmovlhps\t{%2, %1, %0|%0, %1, %2}
6606    movhps\t{%2, %0|%0, %q2}
6607    vmovhps\t{%2, %1, %0|%0, %1, %q2}"
6608   [(set_attr "isa" "noavx,avx,noavx,avx")
6609    (set_attr "type" "ssemov")
6610    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex")
6611    (set_attr "mode" "V4SF,V4SF,V2SF,V2SF")])
6613 (define_expand "vec_init<mode>"
6614   [(match_operand:V_128 0 "register_operand")
6615    (match_operand 1)]
6616   "TARGET_SSE"
6618   ix86_expand_vector_init (false, operands[0], operands[1]);
6619   DONE;
6622 ;; Avoid combining registers from different units in a single alternative,
6623 ;; see comment above inline_secondary_memory_needed function in i386.c
6624 (define_insn "vec_set<mode>_0"
6625   [(set (match_operand:VI4F_128 0 "nonimmediate_operand"
6626           "=Yr,*x,v,v,Yi,x,x,v,Yr ,*x ,x  ,m ,m   ,m")
6627         (vec_merge:VI4F_128
6628           (vec_duplicate:VI4F_128
6629             (match_operand:<ssescalarmode> 2 "general_operand"
6630           " Yr,*x,v,m,r ,m,x,v,*rm,*rm,*rm,!x,!*re,!*fF"))
6631           (match_operand:VI4F_128 1 "vector_move_operand"
6632           " C , C,C,C,C ,C,0,v,0  ,0  ,x  ,0 ,0   ,0")
6633           (const_int 1)))]
6634   "TARGET_SSE"
6635   "@
6636    insertps\t{$0xe, %2, %0|%0, %2, 0xe}
6637    insertps\t{$0xe, %2, %0|%0, %2, 0xe}
6638    vinsertps\t{$0xe, %2, %2, %0|%0, %2, %2, 0xe}
6639    %vmov<ssescalarmodesuffix>\t{%2, %0|%0, %2}
6640    %vmovd\t{%2, %0|%0, %2}
6641    movss\t{%2, %0|%0, %2}
6642    movss\t{%2, %0|%0, %2}
6643    vmovss\t{%2, %1, %0|%0, %1, %2}
6644    pinsrd\t{$0, %2, %0|%0, %2, 0}
6645    pinsrd\t{$0, %2, %0|%0, %2, 0}
6646    vpinsrd\t{$0, %2, %1, %0|%0, %1, %2, 0}
6647    #
6648    #
6649    #"
6650   [(set_attr "isa" "sse4_noavx,sse4_noavx,avx,sse2,sse2,noavx,noavx,avx,sse4_noavx,sse4_noavx,avx,*,*,*")
6651    (set (attr "type")
6652      (cond [(eq_attr "alternative" "0,1,2,8,9,10")
6653               (const_string "sselog")
6654             (eq_attr "alternative" "12")
6655               (const_string "imov")
6656             (eq_attr "alternative" "13")
6657               (const_string "fmov")
6658            ]
6659            (const_string "ssemov")))
6660    (set_attr "prefix_extra" "*,*,*,*,*,*,*,*,1,1,1,*,*,*")
6661    (set_attr "length_immediate" "*,*,*,*,*,*,*,*,1,1,1,*,*,*")
6662    (set_attr "prefix" "orig,orig,maybe_evex,maybe_vex,maybe_vex,orig,orig,vex,orig,orig,vex,*,*,*")
6663    (set_attr "mode" "SF,SF,SF,<ssescalarmode>,SI,SF,SF,SF,TI,TI,TI,*,*,*")])
6665 ;; A subset is vec_setv4sf.
6666 (define_insn "*vec_setv4sf_sse4_1"
6667   [(set (match_operand:V4SF 0 "register_operand" "=Yr,*x,v")
6668         (vec_merge:V4SF
6669           (vec_duplicate:V4SF
6670             (match_operand:SF 2 "nonimmediate_operand" "Yrm,*xm,vm"))
6671           (match_operand:V4SF 1 "register_operand" "0,0,v")
6672           (match_operand:SI 3 "const_int_operand")))]
6673   "TARGET_SSE4_1
6674    && ((unsigned) exact_log2 (INTVAL (operands[3]))
6675        < GET_MODE_NUNITS (V4SFmode))"
6677   operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])) << 4);
6678   switch (which_alternative)
6679     {
6680     case 0:
6681     case 1:
6682       return "insertps\t{%3, %2, %0|%0, %2, %3}";
6683     case 2:
6684       return "vinsertps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
6685     default:
6686       gcc_unreachable ();
6687     }
6689   [(set_attr "isa" "noavx,noavx,avx")
6690    (set_attr "type" "sselog")
6691    (set_attr "prefix_data16" "1,1,*")
6692    (set_attr "prefix_extra" "1")
6693    (set_attr "length_immediate" "1")
6694    (set_attr "prefix" "orig,orig,maybe_evex")
6695    (set_attr "mode" "V4SF")])
6697 (define_insn "sse4_1_insertps"
6698   [(set (match_operand:V4SF 0 "register_operand" "=Yr,*x,v")
6699         (unspec:V4SF [(match_operand:V4SF 2 "nonimmediate_operand" "Yrm,*xm,vm")
6700                       (match_operand:V4SF 1 "register_operand" "0,0,v")
6701                       (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
6702                      UNSPEC_INSERTPS))]
6703   "TARGET_SSE4_1"
6705   if (MEM_P (operands[2]))
6706     {
6707       unsigned count_s = INTVAL (operands[3]) >> 6;
6708       if (count_s)
6709         operands[3] = GEN_INT (INTVAL (operands[3]) & 0x3f);
6710       operands[2] = adjust_address_nv (operands[2], SFmode, count_s * 4);
6711     }
6712   switch (which_alternative)
6713     {
6714     case 0:
6715     case 1:
6716       return "insertps\t{%3, %2, %0|%0, %2, %3}";
6717     case 2:
6718       return "vinsertps\t{%3, %2, %1, %0|%0, %1, %2, %3}";
6719     default:
6720       gcc_unreachable ();
6721     }
6723   [(set_attr "isa" "noavx,noavx,avx")
6724    (set_attr "type" "sselog")
6725    (set_attr "prefix_data16" "1,1,*")
6726    (set_attr "prefix_extra" "1")
6727    (set_attr "length_immediate" "1")
6728    (set_attr "prefix" "orig,orig,maybe_evex")
6729    (set_attr "mode" "V4SF")])
6731 (define_split
6732   [(set (match_operand:VI4F_128 0 "memory_operand")
6733         (vec_merge:VI4F_128
6734           (vec_duplicate:VI4F_128
6735             (match_operand:<ssescalarmode> 1 "nonmemory_operand"))
6736           (match_dup 0)
6737           (const_int 1)))]
6738   "TARGET_SSE && reload_completed"
6739   [(set (match_dup 0) (match_dup 1))]
6740   "operands[0] = adjust_address (operands[0], <ssescalarmode>mode, 0);")
6742 (define_expand "vec_set<mode>"
6743   [(match_operand:V 0 "register_operand")
6744    (match_operand:<ssescalarmode> 1 "register_operand")
6745    (match_operand 2 "const_int_operand")]
6746   "TARGET_SSE"
6748   ix86_expand_vector_set (false, operands[0], operands[1],
6749                           INTVAL (operands[2]));
6750   DONE;
6753 (define_insn_and_split "*vec_extractv4sf_0"
6754   [(set (match_operand:SF 0 "nonimmediate_operand" "=v,m,f,r")
6755         (vec_select:SF
6756           (match_operand:V4SF 1 "nonimmediate_operand" "vm,v,m,m")
6757           (parallel [(const_int 0)])))]
6758   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
6759   "#"
6760   "&& reload_completed"
6761   [(set (match_dup 0) (match_dup 1))]
6762   "operands[1] = gen_lowpart (SFmode, operands[1]);")
6764 (define_insn_and_split "*sse4_1_extractps"
6765   [(set (match_operand:SF 0 "nonimmediate_operand" "=rm,rm,rm,v,v")
6766         (vec_select:SF
6767           (match_operand:V4SF 1 "register_operand" "Yr,*x,v,0,v")
6768           (parallel [(match_operand:SI 2 "const_0_to_3_operand" "n,n,n,n,n")])))]
6769   "TARGET_SSE4_1"
6770   "@
6771    extractps\t{%2, %1, %0|%0, %1, %2}
6772    extractps\t{%2, %1, %0|%0, %1, %2}
6773    vextractps\t{%2, %1, %0|%0, %1, %2}
6774    #
6775    #"
6776   "&& reload_completed && SSE_REG_P (operands[0])"
6777   [(const_int 0)]
6779   rtx dest = lowpart_subreg (V4SFmode, operands[0], SFmode);
6780   switch (INTVAL (operands[2]))
6781     {
6782     case 1:
6783     case 3:
6784       emit_insn (gen_sse_shufps_v4sf (dest, operands[1], operands[1],
6785                                       operands[2], operands[2],
6786                                       GEN_INT (INTVAL (operands[2]) + 4),
6787                                       GEN_INT (INTVAL (operands[2]) + 4)));
6788       break;
6789     case 2:
6790       emit_insn (gen_vec_interleave_highv4sf (dest, operands[1], operands[1]));
6791       break;
6792     default:
6793       /* 0 should be handled by the *vec_extractv4sf_0 pattern above.  */
6794       gcc_unreachable ();
6795     }
6796   DONE;
6798   [(set_attr "isa" "noavx,noavx,avx,noavx,avx")
6799    (set_attr "type" "sselog,sselog,sselog,*,*")
6800    (set_attr "prefix_data16" "1,1,1,*,*")
6801    (set_attr "prefix_extra" "1,1,1,*,*")
6802    (set_attr "length_immediate" "1,1,1,*,*")
6803    (set_attr "prefix" "orig,orig,maybe_evex,*,*")
6804    (set_attr "mode" "V4SF,V4SF,V4SF,*,*")])
6806 (define_insn_and_split "*vec_extractv4sf_mem"
6807   [(set (match_operand:SF 0 "register_operand" "=v,*r,f")
6808         (vec_select:SF
6809           (match_operand:V4SF 1 "memory_operand" "o,o,o")
6810           (parallel [(match_operand 2 "const_0_to_3_operand" "n,n,n")])))]
6811   "TARGET_SSE"
6812   "#"
6813   "&& reload_completed"
6814   [(set (match_dup 0) (match_dup 1))]
6816   operands[1] = adjust_address (operands[1], SFmode, INTVAL (operands[2]) * 4);
6819 (define_mode_attr extract_type
6820   [(V16SF "avx512f") (V16SI "avx512f") (V8DF "avx512dq") (V8DI "avx512dq")])
6822 (define_mode_attr extract_suf
6823   [(V16SF "32x4") (V16SI "32x4") (V8DF "64x2") (V8DI "64x2")])
6825 (define_mode_iterator AVX512_VEC
6826   [(V8DF "TARGET_AVX512DQ") (V8DI "TARGET_AVX512DQ") V16SF V16SI])
6828 (define_expand "<extract_type>_vextract<shuffletype><extract_suf>_mask"
6829   [(match_operand:<ssequartermode> 0 "nonimmediate_operand")
6830    (match_operand:AVX512_VEC 1 "register_operand")
6831    (match_operand:SI 2 "const_0_to_3_operand")
6832    (match_operand:<ssequartermode> 3 "nonimmediate_operand")
6833    (match_operand:QI 4 "register_operand")]
6834   "TARGET_AVX512F"
6836   int mask;
6837   mask = INTVAL (operands[2]);
6839   if (MEM_P (operands[0]) && GET_CODE (operands[3]) == CONST_VECTOR)
6840     operands[0] = force_reg (<ssequartermode>mode, operands[0]);
6842   if (<MODE>mode == V16SImode || <MODE>mode == V16SFmode)
6843     emit_insn (gen_avx512f_vextract<shuffletype>32x4_1_mask (operands[0],
6844         operands[1], GEN_INT (mask * 4), GEN_INT (mask * 4 + 1),
6845         GEN_INT (mask * 4 + 2), GEN_INT (mask * 4 + 3), operands[3],
6846         operands[4]));
6847   else
6848     emit_insn (gen_avx512dq_vextract<shuffletype>64x2_1_mask (operands[0],
6849         operands[1], GEN_INT (mask * 2), GEN_INT (mask * 2 + 1), operands[3],
6850         operands[4]));
6851   DONE;
6854 (define_insn "avx512dq_vextract<shuffletype>64x2_1_maskm"
6855   [(set (match_operand:<ssequartermode> 0 "memory_operand" "=m")
6856         (vec_merge:<ssequartermode>
6857           (vec_select:<ssequartermode>
6858             (match_operand:V8FI 1 "register_operand" "v")
6859             (parallel [(match_operand 2  "const_0_to_7_operand")
6860               (match_operand 3  "const_0_to_7_operand")]))
6861           (match_operand:<ssequartermode> 4 "memory_operand" "0")
6862           (match_operand:QI 5 "register_operand" "k")))]
6863   "TARGET_AVX512DQ
6864    && (INTVAL (operands[2]) % 2 == 0)
6865    && (INTVAL (operands[2]) == INTVAL (operands[3]) - 1)
6866    && rtx_equal_p (operands[4], operands[0])"
6868   operands[2] = GEN_INT ((INTVAL (operands[2])) >> 1);
6869   return "vextract<shuffletype>64x2\t{%2, %1, %0%{%5%}|%0%{%5%}, %1, %2}";
6871   [(set_attr "type" "sselog")
6872    (set_attr "prefix_extra" "1")
6873    (set_attr "length_immediate" "1")
6874    (set_attr "memory" "store")
6875    (set_attr "prefix" "evex")
6876    (set_attr "mode" "<sseinsnmode>")])
6878 (define_insn "avx512f_vextract<shuffletype>32x4_1_maskm"
6879   [(set (match_operand:<ssequartermode> 0 "memory_operand" "=m")
6880         (vec_merge:<ssequartermode>
6881           (vec_select:<ssequartermode>
6882             (match_operand:V16FI 1 "register_operand" "v")
6883             (parallel [(match_operand 2  "const_0_to_15_operand")
6884               (match_operand 3  "const_0_to_15_operand")
6885               (match_operand 4  "const_0_to_15_operand")
6886               (match_operand 5  "const_0_to_15_operand")]))
6887           (match_operand:<ssequartermode> 6 "memory_operand" "0")
6888           (match_operand:QI 7 "register_operand" "Yk")))]
6889   "TARGET_AVX512F
6890    && ((INTVAL (operands[2]) % 4 == 0)
6891        && INTVAL (operands[2]) == (INTVAL (operands[3]) - 1)
6892        && INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
6893        && INTVAL (operands[4]) == (INTVAL (operands[5]) - 1))
6894    && rtx_equal_p (operands[6], operands[0])"
6896   operands[2] = GEN_INT ((INTVAL (operands[2])) >> 2);
6897   return "vextract<shuffletype>32x4\t{%2, %1, %0%{%7%}|%0%{%7%}, %1, %2}";
6899   [(set_attr "type" "sselog")
6900    (set_attr "prefix_extra" "1")
6901    (set_attr "length_immediate" "1")
6902    (set_attr "memory" "store")
6903    (set_attr "prefix" "evex")
6904    (set_attr "mode" "<sseinsnmode>")])
6906 (define_insn "<mask_codefor>avx512dq_vextract<shuffletype>64x2_1<mask_name>"
6907   [(set (match_operand:<ssequartermode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
6908         (vec_select:<ssequartermode>
6909           (match_operand:V8FI 1 "register_operand" "v")
6910           (parallel [(match_operand 2  "const_0_to_7_operand")
6911             (match_operand 3  "const_0_to_7_operand")])))]
6912   "TARGET_AVX512DQ && (INTVAL (operands[2]) == INTVAL (operands[3]) - 1)"
6914   operands[2] = GEN_INT ((INTVAL (operands[2])) >> 1);
6915   return "vextract<shuffletype>64x2\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}";
6917   [(set_attr "type" "sselog1")
6918    (set_attr "prefix_extra" "1")
6919    (set_attr "length_immediate" "1")
6920    (set_attr "prefix" "evex")
6921    (set_attr "mode" "<sseinsnmode>")])
6923 (define_insn "<mask_codefor>avx512f_vextract<shuffletype>32x4_1<mask_name>"
6924   [(set (match_operand:<ssequartermode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
6925         (vec_select:<ssequartermode>
6926           (match_operand:V16FI 1 "register_operand" "v")
6927           (parallel [(match_operand 2  "const_0_to_15_operand")
6928             (match_operand 3  "const_0_to_15_operand")
6929             (match_operand 4  "const_0_to_15_operand")
6930             (match_operand 5  "const_0_to_15_operand")])))]
6931   "TARGET_AVX512F
6932    && (INTVAL (operands[2]) == (INTVAL (operands[3]) - 1)
6933        && INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
6934        && INTVAL (operands[4]) == (INTVAL (operands[5]) - 1))"
6936   operands[2] = GEN_INT ((INTVAL (operands[2])) >> 2);
6937   return "vextract<shuffletype>32x4\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
6939   [(set_attr "type" "sselog1")
6940    (set_attr "prefix_extra" "1")
6941    (set_attr "length_immediate" "1")
6942    (set_attr "prefix" "evex")
6943    (set_attr "mode" "<sseinsnmode>")])
6945 (define_mode_attr extract_type_2
6946   [(V16SF "avx512dq") (V16SI "avx512dq") (V8DF "avx512f") (V8DI "avx512f")])
6948 (define_mode_attr extract_suf_2
6949   [(V16SF "32x8") (V16SI "32x8") (V8DF "64x4") (V8DI "64x4")])
6951 (define_mode_iterator AVX512_VEC_2
6952   [(V16SF "TARGET_AVX512DQ") (V16SI "TARGET_AVX512DQ") V8DF V8DI])
6954 (define_expand "<extract_type_2>_vextract<shuffletype><extract_suf_2>_mask"
6955   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
6956    (match_operand:AVX512_VEC_2 1 "register_operand")
6957    (match_operand:SI 2 "const_0_to_1_operand")
6958    (match_operand:<ssehalfvecmode> 3 "nonimmediate_operand")
6959    (match_operand:QI 4 "register_operand")]
6960   "TARGET_AVX512F"
6962   rtx (*insn)(rtx, rtx, rtx, rtx);
6964   if (MEM_P (operands[0]) && GET_CODE (operands[3]) == CONST_VECTOR)
6965     operands[0] = force_reg (<ssequartermode>mode, operands[0]);
6967   switch (INTVAL (operands[2]))
6968     {
6969     case 0:
6970       insn = gen_vec_extract_lo_<mode>_mask;
6971       break;
6972     case 1:
6973       insn = gen_vec_extract_hi_<mode>_mask;
6974       break;
6975     default:
6976       gcc_unreachable ();
6977     }
6979   emit_insn (insn (operands[0], operands[1], operands[3], operands[4]));
6980   DONE;
6983 (define_split
6984   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
6985         (vec_select:<ssehalfvecmode>
6986           (match_operand:V8FI 1 "nonimmediate_operand")
6987           (parallel [(const_int 0) (const_int 1)
6988             (const_int 2) (const_int 3)])))]
6989   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))
6990    && reload_completed
6991    && (TARGET_AVX512VL
6992        || (REG_P (operands[0]) && !EXT_REX_SSE_REG_P (operands[1])))"
6993   [(set (match_dup 0) (match_dup 1))]
6994   "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
6996 (define_insn "vec_extract_lo_<mode>_maskm"
6997   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
6998         (vec_merge:<ssehalfvecmode>
6999           (vec_select:<ssehalfvecmode>
7000             (match_operand:V8FI 1 "register_operand" "v")
7001             (parallel [(const_int 0) (const_int 1)
7002               (const_int 2) (const_int 3)]))
7003           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7004           (match_operand:QI 3 "register_operand" "Yk")))]
7005   "TARGET_AVX512F
7006    && rtx_equal_p (operands[2], operands[0])"
7007   "vextract<shuffletype>64x4\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}"
7008   [(set_attr "type" "sselog1")
7009    (set_attr "prefix_extra" "1")
7010    (set_attr "length_immediate" "1")
7011    (set_attr "prefix" "evex")
7012    (set_attr "mode" "<sseinsnmode>")])
7014 (define_insn "vec_extract_lo_<mode><mask_name>"
7015   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>,v")
7016         (vec_select:<ssehalfvecmode>
7017           (match_operand:V8FI 1 "nonimmediate_operand" "v,m")
7018           (parallel [(const_int 0) (const_int 1)
7019             (const_int 2) (const_int 3)])))]
7020   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7022   if (<mask_applied> || !TARGET_AVX512VL)
7023     return "vextract<shuffletype>64x4\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7024   else
7025     return "#";
7027   [(set_attr "type" "sselog1")
7028    (set_attr "prefix_extra" "1")
7029    (set_attr "length_immediate" "1")
7030    (set_attr "prefix" "evex")
7031    (set_attr "mode" "<sseinsnmode>")])
7033 (define_insn "vec_extract_hi_<mode>_maskm"
7034   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7035         (vec_merge:<ssehalfvecmode>
7036           (vec_select:<ssehalfvecmode>
7037             (match_operand:V8FI 1 "register_operand" "v")
7038             (parallel [(const_int 4) (const_int 5)
7039               (const_int 6) (const_int 7)]))
7040           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7041           (match_operand:QI 3 "register_operand" "Yk")))]
7042   "TARGET_AVX512F
7043    && rtx_equal_p (operands[2], operands[0])"
7044   "vextract<shuffletype>64x4\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7045   [(set_attr "type" "sselog")
7046    (set_attr "prefix_extra" "1")
7047    (set_attr "length_immediate" "1")
7048    (set_attr "memory" "store")
7049    (set_attr "prefix" "evex")
7050    (set_attr "mode" "<sseinsnmode>")])
7052 (define_insn "vec_extract_hi_<mode><mask_name>"
7053   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7054         (vec_select:<ssehalfvecmode>
7055           (match_operand:V8FI 1 "register_operand" "v")
7056           (parallel [(const_int 4) (const_int 5)
7057             (const_int 6) (const_int 7)])))]
7058   "TARGET_AVX512F"
7059   "vextract<shuffletype>64x4\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}"
7060   [(set_attr "type" "sselog1")
7061    (set_attr "prefix_extra" "1")
7062    (set_attr "length_immediate" "1")
7063    (set_attr "prefix" "evex")
7064    (set_attr "mode" "<sseinsnmode>")])
7066 (define_insn "vec_extract_hi_<mode>_maskm"
7067    [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7068         (vec_merge:<ssehalfvecmode>
7069           (vec_select:<ssehalfvecmode>
7070             (match_operand:V16FI 1 "register_operand" "v")
7071             (parallel [(const_int 8) (const_int 9)
7072               (const_int 10) (const_int 11)
7073               (const_int 12) (const_int 13)
7074               (const_int 14) (const_int 15)]))
7075           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7076           (match_operand:QI 3 "register_operand" "k")))]
7077   "TARGET_AVX512DQ
7078    && rtx_equal_p (operands[2], operands[0])"
7079   "vextract<shuffletype>32x8\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7080   [(set_attr "type" "sselog1")
7081    (set_attr "prefix_extra" "1")
7082    (set_attr "length_immediate" "1")
7083    (set_attr "prefix" "evex")
7084    (set_attr "mode" "<sseinsnmode>")])
7086 (define_insn "vec_extract_hi_<mode><mask_name>"
7087   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>,vm")
7088         (vec_select:<ssehalfvecmode>
7089           (match_operand:V16FI 1 "register_operand" "v,v")
7090           (parallel [(const_int 8) (const_int 9)
7091             (const_int 10) (const_int 11)
7092             (const_int 12) (const_int 13)
7093             (const_int 14) (const_int 15)])))]
7094   "TARGET_AVX512F && <mask_avx512dq_condition>"
7095   "@
7096    vextract<shuffletype>32x8\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}
7097    vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7098   [(set_attr "type" "sselog1")
7099    (set_attr "prefix_extra" "1")
7100    (set_attr "isa" "avx512dq,noavx512dq")
7101    (set_attr "length_immediate" "1")
7102    (set_attr "prefix" "evex")
7103    (set_attr "mode" "<sseinsnmode>")])
7105 (define_expand "avx512vl_vextractf128<mode>"
7106   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7107    (match_operand:VI48F_256 1 "register_operand")
7108    (match_operand:SI 2 "const_0_to_1_operand")
7109    (match_operand:<ssehalfvecmode> 3 "vector_move_operand")
7110    (match_operand:QI 4 "register_operand")]
7111   "TARGET_AVX512DQ && TARGET_AVX512VL"
7113   rtx (*insn)(rtx, rtx, rtx, rtx);
7115   if (MEM_P (operands[0]) && GET_CODE (operands[3]) == CONST_VECTOR)
7116     operands[0] = force_reg (<ssehalfvecmode>mode, operands[0]);
7118   switch (INTVAL (operands[2]))
7119     {
7120     case 0:
7121       insn = gen_vec_extract_lo_<mode>_mask;
7122       break;
7123     case 1:
7124       insn = gen_vec_extract_hi_<mode>_mask;
7125       break;
7126     default:
7127       gcc_unreachable ();
7128     }
7130   emit_insn (insn (operands[0], operands[1], operands[3], operands[4]));
7131   DONE;
7134 (define_expand "avx_vextractf128<mode>"
7135   [(match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7136    (match_operand:V_256 1 "register_operand")
7137    (match_operand:SI 2 "const_0_to_1_operand")]
7138   "TARGET_AVX"
7140   rtx (*insn)(rtx, rtx);
7142   switch (INTVAL (operands[2]))
7143     {
7144     case 0:
7145       insn = gen_vec_extract_lo_<mode>;
7146       break;
7147     case 1:
7148       insn = gen_vec_extract_hi_<mode>;
7149       break;
7150     default:
7151       gcc_unreachable ();
7152     }
7154   emit_insn (insn (operands[0], operands[1]));
7155   DONE;
7158 (define_insn "vec_extract_lo_<mode><mask_name>"
7159   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,m")
7160         (vec_select:<ssehalfvecmode>
7161           (match_operand:V16FI 1 "nonimmediate_operand" "vm,v")
7162           (parallel [(const_int 0) (const_int 1)
7163                      (const_int 2) (const_int 3)
7164                      (const_int 4) (const_int 5)
7165                      (const_int 6) (const_int 7)])))]
7166   "TARGET_AVX512F
7167    && <mask_mode512bit_condition>
7168    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7170   if (<mask_applied>)
7171     return "vextract<shuffletype>32x8\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7172   else
7173     return "#";
7176 (define_split
7177   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7178         (vec_select:<ssehalfvecmode>
7179           (match_operand:V16FI 1 "nonimmediate_operand")
7180           (parallel [(const_int 0) (const_int 1)
7181             (const_int 2) (const_int 3)
7182             (const_int 4) (const_int 5)
7183             (const_int 6) (const_int 7)])))]
7184   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7185    && reload_completed"
7186   [(set (match_dup 0) (match_dup 1))]
7187   "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
7189 (define_insn "vec_extract_lo_<mode><mask_name>"
7190   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,m")
7191         (vec_select:<ssehalfvecmode>
7192           (match_operand:VI8F_256 1 "nonimmediate_operand" "vm,v")
7193           (parallel [(const_int 0) (const_int 1)])))]
7194   "TARGET_AVX
7195    && <mask_avx512vl_condition> && <mask_avx512dq_condition>
7196    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7198   if (<mask_applied>)
7199     return "vextract<shuffletype>64x2\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}";
7200   else
7201     return "#";
7203    [(set_attr "type" "sselog")
7204     (set_attr "prefix_extra" "1")
7205     (set_attr "length_immediate" "1")
7206     (set_attr "memory" "none,store")
7207     (set_attr "prefix" "evex")
7208     (set_attr "mode" "XI")])
7210 (define_split
7211   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7212         (vec_select:<ssehalfvecmode>
7213           (match_operand:VI8F_256 1 "nonimmediate_operand")
7214           (parallel [(const_int 0) (const_int 1)])))]
7215   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7216    && reload_completed"
7217   [(set (match_dup 0) (match_dup 1))]
7218   "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
7220 (define_insn "vec_extract_hi_<mode><mask_name>"
7221   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,<store_mask_constraint>")
7222         (vec_select:<ssehalfvecmode>
7223           (match_operand:VI8F_256 1 "register_operand" "v,v")
7224           (parallel [(const_int 2) (const_int 3)])))]
7225   "TARGET_AVX && <mask_avx512vl_condition> && <mask_avx512dq_condition>"
7227   if (TARGET_AVX512VL)
7228   {
7229     if (TARGET_AVX512DQ)
7230       return "vextract<shuffletype>64x2\t{$0x1, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x1}";
7231     else
7232       return "vextract<shuffletype>32x4\t{$0x1, %1, %0|%0, %1, 0x1}";
7233   }
7234   else
7235     return "vextract<i128>\t{$0x1, %1, %0|%0, %1, 0x1}";
7237   [(set_attr "type" "sselog")
7238    (set_attr "prefix_extra" "1")
7239    (set_attr "length_immediate" "1")
7240    (set_attr "memory" "none,store")
7241    (set_attr "prefix" "vex")
7242    (set_attr "mode" "<sseinsnmode>")])
7244 (define_split
7245   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand")
7246         (vec_select:<ssehalfvecmode>
7247           (match_operand:VI4F_256 1 "nonimmediate_operand")
7248           (parallel [(const_int 0) (const_int 1)
7249                      (const_int 2) (const_int 3)])))]
7250   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))
7251    && reload_completed"
7252   [(set (match_dup 0) (match_dup 1))]
7253   "operands[1] = gen_lowpart (<ssehalfvecmode>mode, operands[1]);")
7255 (define_insn "vec_extract_lo_<mode><mask_name>"
7256   [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>")
7257         (vec_select:<ssehalfvecmode>
7258           (match_operand:VI4F_256 1 "register_operand" "v")
7259           (parallel [(const_int 0) (const_int 1)
7260                      (const_int 2) (const_int 3)])))]
7261   "TARGET_AVX && <mask_avx512vl_condition> && <mask_avx512dq_condition>"
7263   if (<mask_applied>)
7264     return "vextract<shuffletype>32x4\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}";
7265   else
7266     return "#";
7268   [(set_attr "type" "sselog1")
7269    (set_attr "prefix_extra" "1")
7270    (set_attr "length_immediate" "1")
7271    (set_attr "prefix" "evex")
7272    (set_attr "mode" "<sseinsnmode>")])
7274 (define_insn "vec_extract_lo_<mode>_maskm"
7275   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7276         (vec_merge:<ssehalfvecmode>
7277           (vec_select:<ssehalfvecmode>
7278             (match_operand:VI4F_256 1 "register_operand" "v")
7279             (parallel [(const_int 0) (const_int 1)
7280                       (const_int 2) (const_int 3)]))
7281           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7282           (match_operand:QI 3 "register_operand" "k")))]
7283   "TARGET_AVX512VL && TARGET_AVX512F
7284    && rtx_equal_p (operands[2], operands[0])"
7285   "vextract<shuffletype>32x4\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}"
7286   [(set_attr "type" "sselog1")
7287    (set_attr "prefix_extra" "1")
7288    (set_attr "length_immediate" "1")
7289    (set_attr "prefix" "evex")
7290    (set_attr "mode" "<sseinsnmode>")])
7292 (define_insn "vec_extract_hi_<mode>_maskm"
7293   [(set (match_operand:<ssehalfvecmode> 0 "memory_operand" "=m")
7294         (vec_merge:<ssehalfvecmode>
7295           (vec_select:<ssehalfvecmode>
7296             (match_operand:VI4F_256 1 "register_operand" "v")
7297             (parallel [(const_int 4) (const_int 5)
7298                       (const_int 6) (const_int 7)]))
7299           (match_operand:<ssehalfvecmode> 2 "memory_operand" "0")
7300           (match_operand:<ssehalfvecmode> 3 "register_operand" "k")))]
7301   "TARGET_AVX512F && TARGET_AVX512VL
7302    && rtx_equal_p (operands[2], operands[0])"
7303   "vextract<shuffletype>32x4\t{$0x1, %1, %0%{%3%}|%0%{%3%}, %1, 0x1}"
7304   [(set_attr "type" "sselog1")
7305    (set_attr "length_immediate" "1")
7306    (set_attr "prefix" "evex")
7307    (set_attr "mode" "<sseinsnmode>")])
7309 (define_insn "vec_extract_hi_<mode>_mask"
7310   [(set (match_operand:<ssehalfvecmode> 0 "register_operand" "=v")
7311         (vec_merge:<ssehalfvecmode>
7312           (vec_select:<ssehalfvecmode>
7313             (match_operand:VI4F_256 1 "register_operand" "v")
7314             (parallel [(const_int 4) (const_int 5)
7315                        (const_int 6) (const_int 7)]))
7316           (match_operand:<ssehalfvecmode> 2 "vector_move_operand" "0C")
7317           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
7318   "TARGET_AVX512VL"
7319   "vextract<shuffletype>32x4\t{$0x1, %1, %0%{%3%}%N2|%0%{%3%}%N2, %1, 0x1}"
7320   [(set_attr "type" "sselog1")
7321    (set_attr "length_immediate" "1")
7322    (set_attr "prefix" "evex")
7323    (set_attr "mode" "<sseinsnmode>")])
7325 (define_insn "vec_extract_hi_<mode>"
7326   [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=xm, vm")
7327         (vec_select:<ssehalfvecmode>
7328           (match_operand:VI4F_256 1 "register_operand" "x, v")
7329           (parallel [(const_int 4) (const_int 5)
7330                      (const_int 6) (const_int 7)])))]
7331   "TARGET_AVX"
7332   "@
7333     vextract<i128>\t{$0x1, %1, %0|%0, %1, 0x1}
7334     vextract<shuffletype>32x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7335   [(set_attr "isa" "*, avx512vl")
7336    (set_attr "prefix" "vex, evex")
7337    (set_attr "type" "sselog1")
7338    (set_attr "length_immediate" "1")
7339    (set_attr "mode" "<sseinsnmode>")])
7341 (define_insn_and_split "vec_extract_lo_v32hi"
7342   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=v,m")
7343         (vec_select:V16HI
7344           (match_operand:V32HI 1 "nonimmediate_operand" "vm,v")
7345           (parallel [(const_int 0) (const_int 1)
7346                      (const_int 2) (const_int 3)
7347                      (const_int 4) (const_int 5)
7348                      (const_int 6) (const_int 7)
7349                      (const_int 8) (const_int 9)
7350                      (const_int 10) (const_int 11)
7351                      (const_int 12) (const_int 13)
7352                      (const_int 14) (const_int 15)])))]
7353   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7354   "#"
7355   "&& reload_completed"
7356   [(set (match_dup 0) (match_dup 1))]
7357   "operands[1] = gen_lowpart (V16HImode, operands[1]);")
7359 (define_insn "vec_extract_hi_v32hi"
7360   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=v,m")
7361         (vec_select:V16HI
7362           (match_operand:V32HI 1 "register_operand" "v,v")
7363           (parallel [(const_int 16) (const_int 17)
7364                      (const_int 18) (const_int 19)
7365                      (const_int 20) (const_int 21)
7366                      (const_int 22) (const_int 23)
7367                      (const_int 24) (const_int 25)
7368                      (const_int 26) (const_int 27)
7369                      (const_int 28) (const_int 29)
7370                      (const_int 30) (const_int 31)])))]
7371   "TARGET_AVX512F"
7372   "vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7373   [(set_attr "type" "sselog")
7374    (set_attr "prefix_extra" "1")
7375    (set_attr "length_immediate" "1")
7376    (set_attr "memory" "none,store")
7377    (set_attr "prefix" "evex")
7378    (set_attr "mode" "XI")])
7380 (define_insn_and_split "vec_extract_lo_v16hi"
7381   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=v,m")
7382         (vec_select:V8HI
7383           (match_operand:V16HI 1 "nonimmediate_operand" "vm,v")
7384           (parallel [(const_int 0) (const_int 1)
7385                      (const_int 2) (const_int 3)
7386                      (const_int 4) (const_int 5)
7387                      (const_int 6) (const_int 7)])))]
7388   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7389   "#"
7390   "&& reload_completed"
7391   [(set (match_dup 0) (match_dup 1))]
7392   "operands[1] = gen_lowpart (V8HImode, operands[1]);")
7394 (define_insn "vec_extract_hi_v16hi"
7395   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=x,m,v,m,v,m")
7396         (vec_select:V8HI
7397           (match_operand:V16HI 1 "register_operand" "x,x,v,v,v,v")
7398           (parallel [(const_int 8) (const_int 9)
7399                      (const_int 10) (const_int 11)
7400                      (const_int 12) (const_int 13)
7401                      (const_int 14) (const_int 15)])))]
7402   "TARGET_AVX"
7403   "@
7404    vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}
7405    vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}
7406    vextracti32x4\t{$0x1, %1, %0|%0, %1, 0x1}
7407    vextracti32x4\t{$0x1, %1, %0|%0, %1, 0x1}
7408    vextracti32x4\t{$0x1, %g1, %0|%0, %g1, 0x1}
7409    vextracti32x4\t{$0x1, %g1, %0|%0, %g1, 0x1}"
7410   [(set_attr "type" "sselog")
7411    (set_attr "prefix_extra" "1")
7412    (set_attr "length_immediate" "1")
7413    (set_attr "isa" "*,*,avx512dq,avx512dq,avx512f,avx512f")
7414    (set_attr "memory" "none,store,none,store,none,store")
7415    (set_attr "prefix" "vex,vex,evex,evex,evex,evex")
7416    (set_attr "mode" "OI")])
7418 (define_insn_and_split "vec_extract_lo_v64qi"
7419   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
7420         (vec_select:V32QI
7421           (match_operand:V64QI 1 "nonimmediate_operand" "vm,v")
7422           (parallel [(const_int 0) (const_int 1)
7423                      (const_int 2) (const_int 3)
7424                      (const_int 4) (const_int 5)
7425                      (const_int 6) (const_int 7)
7426                      (const_int 8) (const_int 9)
7427                      (const_int 10) (const_int 11)
7428                      (const_int 12) (const_int 13)
7429                      (const_int 14) (const_int 15)
7430                      (const_int 16) (const_int 17)
7431                      (const_int 18) (const_int 19)
7432                      (const_int 20) (const_int 21)
7433                      (const_int 22) (const_int 23)
7434                      (const_int 24) (const_int 25)
7435                      (const_int 26) (const_int 27)
7436                      (const_int 28) (const_int 29)
7437                      (const_int 30) (const_int 31)])))]
7438   "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7439   "#"
7440   "&& reload_completed"
7441   [(set (match_dup 0) (match_dup 1))]
7442   "operands[1] = gen_lowpart (V32QImode, operands[1]);")
7444 (define_insn "vec_extract_hi_v64qi"
7445   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
7446         (vec_select:V32QI
7447           (match_operand:V64QI 1 "register_operand" "v,v")
7448           (parallel [(const_int 32) (const_int 33)
7449                      (const_int 34) (const_int 35)
7450                      (const_int 36) (const_int 37)
7451                      (const_int 38) (const_int 39)
7452                      (const_int 40) (const_int 41)
7453                      (const_int 42) (const_int 43)
7454                      (const_int 44) (const_int 45)
7455                      (const_int 46) (const_int 47)
7456                      (const_int 48) (const_int 49)
7457                      (const_int 50) (const_int 51)
7458                      (const_int 52) (const_int 53)
7459                      (const_int 54) (const_int 55)
7460                      (const_int 56) (const_int 57)
7461                      (const_int 58) (const_int 59)
7462                      (const_int 60) (const_int 61)
7463                      (const_int 62) (const_int 63)])))]
7464   "TARGET_AVX512F"
7465   "vextracti64x4\t{$0x1, %1, %0|%0, %1, 0x1}"
7466   [(set_attr "type" "sselog")
7467    (set_attr "prefix_extra" "1")
7468    (set_attr "length_immediate" "1")
7469    (set_attr "memory" "none,store")
7470    (set_attr "prefix" "evex")
7471    (set_attr "mode" "XI")])
7473 (define_insn_and_split "vec_extract_lo_v32qi"
7474   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=v,m")
7475         (vec_select:V16QI
7476           (match_operand:V32QI 1 "nonimmediate_operand" "vm,v")
7477           (parallel [(const_int 0) (const_int 1)
7478                      (const_int 2) (const_int 3)
7479                      (const_int 4) (const_int 5)
7480                      (const_int 6) (const_int 7)
7481                      (const_int 8) (const_int 9)
7482                      (const_int 10) (const_int 11)
7483                      (const_int 12) (const_int 13)
7484                      (const_int 14) (const_int 15)])))]
7485   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
7486   "#"
7487   "&& reload_completed"
7488   [(set (match_dup 0) (match_dup 1))]
7489   "operands[1] = gen_lowpart (V16QImode, operands[1]);")
7491 (define_insn "vec_extract_hi_v32qi"
7492   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=x,m,v,m,v,m")
7493         (vec_select:V16QI
7494           (match_operand:V32QI 1 "register_operand" "x,x,v,v,v,v")
7495           (parallel [(const_int 16) (const_int 17)
7496                      (const_int 18) (const_int 19)
7497                      (const_int 20) (const_int 21)
7498                      (const_int 22) (const_int 23)
7499                      (const_int 24) (const_int 25)
7500                      (const_int 26) (const_int 27)
7501                      (const_int 28) (const_int 29)
7502                      (const_int 30) (const_int 31)])))]
7503   "TARGET_AVX"
7504   "@
7505    vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}
7506    vextract%~128\t{$0x1, %1, %0|%0, %1, 0x1}
7507    vextracti32x4\t{$0x1, %1, %0|%0, %1, 0x1}
7508    vextracti32x4\t{$0x1, %1, %0|%0, %1, 0x1}
7509    vextracti32x4\t{$0x1, %g1, %0|%0, %g1, 0x1}
7510    vextracti32x4\t{$0x1, %g1, %0|%0, %g1, 0x1}"
7511   [(set_attr "type" "sselog")
7512    (set_attr "prefix_extra" "1")
7513    (set_attr "length_immediate" "1")
7514    (set_attr "isa" "*,*,avx512dq,avx512dq,avx512f,avx512f")
7515    (set_attr "memory" "none,store,none,store,none,store")
7516    (set_attr "prefix" "vex,vex,evex,evex,evex,evex")
7517    (set_attr "mode" "OI")])
7519 ;; Modes handled by vec_extract patterns.
7520 (define_mode_iterator VEC_EXTRACT_MODE
7521   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX") V16QI
7522    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX") V8HI
7523    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX") V4SI
7524    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX") V2DI
7525    (V16SF "TARGET_AVX512F") (V8SF "TARGET_AVX") V4SF
7526    (V8DF "TARGET_AVX512F") (V4DF "TARGET_AVX") V2DF])
7528 (define_expand "vec_extract<mode>"
7529   [(match_operand:<ssescalarmode> 0 "register_operand")
7530    (match_operand:VEC_EXTRACT_MODE 1 "register_operand")
7531    (match_operand 2 "const_int_operand")]
7532   "TARGET_SSE"
7534   ix86_expand_vector_extract (false, operands[0], operands[1],
7535                               INTVAL (operands[2]));
7536   DONE;
7539 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7541 ;; Parallel double-precision floating point element swizzling
7543 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7545 (define_insn "<mask_codefor>avx512f_unpckhpd512<mask_name>"
7546   [(set (match_operand:V8DF 0 "register_operand" "=v")
7547         (vec_select:V8DF
7548           (vec_concat:V16DF
7549             (match_operand:V8DF 1 "register_operand" "v")
7550             (match_operand:V8DF 2 "nonimmediate_operand" "vm"))
7551           (parallel [(const_int 1) (const_int 9)
7552                      (const_int 3) (const_int 11)
7553                      (const_int 5) (const_int 13)
7554                      (const_int 7) (const_int 15)])))]
7555   "TARGET_AVX512F"
7556   "vunpckhpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
7557   [(set_attr "type" "sselog")
7558    (set_attr "prefix" "evex")
7559    (set_attr "mode" "V8DF")])
7561 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
7562 (define_insn "avx_unpckhpd256<mask_name>"
7563   [(set (match_operand:V4DF 0 "register_operand" "=v")
7564         (vec_select:V4DF
7565           (vec_concat:V8DF
7566             (match_operand:V4DF 1 "register_operand" "v")
7567             (match_operand:V4DF 2 "nonimmediate_operand" "vm"))
7568           (parallel [(const_int 1) (const_int 5)
7569                      (const_int 3) (const_int 7)])))]
7570   "TARGET_AVX && <mask_avx512vl_condition>"
7571   "vunpckhpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
7572   [(set_attr "type" "sselog")
7573    (set_attr "prefix" "vex")
7574    (set_attr "mode" "V4DF")])
7576 (define_expand "vec_interleave_highv4df"
7577   [(set (match_dup 3)
7578         (vec_select:V4DF
7579           (vec_concat:V8DF
7580             (match_operand:V4DF 1 "register_operand")
7581             (match_operand:V4DF 2 "nonimmediate_operand"))
7582           (parallel [(const_int 0) (const_int 4)
7583                      (const_int 2) (const_int 6)])))
7584    (set (match_dup 4)
7585         (vec_select:V4DF
7586           (vec_concat:V8DF
7587             (match_dup 1)
7588             (match_dup 2))
7589           (parallel [(const_int 1) (const_int 5)
7590                      (const_int 3) (const_int 7)])))
7591    (set (match_operand:V4DF 0 "register_operand")
7592         (vec_select:V4DF
7593           (vec_concat:V8DF
7594             (match_dup 3)
7595             (match_dup 4))
7596           (parallel [(const_int 2) (const_int 3)
7597                      (const_int 6) (const_int 7)])))]
7598  "TARGET_AVX"
7600   operands[3] = gen_reg_rtx (V4DFmode);
7601   operands[4] = gen_reg_rtx (V4DFmode);
7605 (define_insn "avx512vl_unpckhpd128_mask"
7606   [(set (match_operand:V2DF 0 "register_operand" "=v")
7607         (vec_merge:V2DF
7608           (vec_select:V2DF
7609             (vec_concat:V4DF
7610               (match_operand:V2DF 1 "register_operand" "v")
7611               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
7612             (parallel [(const_int 1) (const_int 3)]))
7613           (match_operand:V2DF 3 "vector_move_operand" "0C")
7614           (match_operand:QI 4 "register_operand" "Yk")))]
7615   "TARGET_AVX512VL"
7616   "vunpckhpd\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
7617   [(set_attr "type" "sselog")
7618    (set_attr "prefix" "evex")
7619    (set_attr "mode" "V2DF")])
7621 (define_expand "vec_interleave_highv2df"
7622   [(set (match_operand:V2DF 0 "register_operand")
7623         (vec_select:V2DF
7624           (vec_concat:V4DF
7625             (match_operand:V2DF 1 "nonimmediate_operand")
7626             (match_operand:V2DF 2 "nonimmediate_operand"))
7627           (parallel [(const_int 1)
7628                      (const_int 3)])))]
7629   "TARGET_SSE2"
7631   if (!ix86_vec_interleave_v2df_operator_ok (operands, 1))
7632     operands[2] = force_reg (V2DFmode, operands[2]);
7635 (define_insn "*vec_interleave_highv2df"
7636   [(set (match_operand:V2DF 0 "nonimmediate_operand"     "=x,v,v,x,v,m")
7637         (vec_select:V2DF
7638           (vec_concat:V4DF
7639             (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,o,o,o,v")
7640             (match_operand:V2DF 2 "nonimmediate_operand" " x,v,1,0,v,0"))
7641           (parallel [(const_int 1)
7642                      (const_int 3)])))]
7643   "TARGET_SSE2 && ix86_vec_interleave_v2df_operator_ok (operands, 1)"
7644   "@
7645    unpckhpd\t{%2, %0|%0, %2}
7646    vunpckhpd\t{%2, %1, %0|%0, %1, %2}
7647    %vmovddup\t{%H1, %0|%0, %H1}
7648    movlpd\t{%H1, %0|%0, %H1}
7649    vmovlpd\t{%H1, %2, %0|%0, %2, %H1}
7650    %vmovhpd\t{%1, %0|%q0, %1}"
7651   [(set_attr "isa" "noavx,avx,sse3,noavx,avx,*")
7652    (set_attr "type" "sselog,sselog,sselog,ssemov,ssemov,ssemov")
7653    (set_attr "prefix_data16" "*,*,*,1,*,1")
7654    (set_attr "prefix" "orig,maybe_evex,maybe_vex,orig,maybe_evex,maybe_vex")
7655    (set_attr "mode" "V2DF,V2DF,DF,V1DF,V1DF,V1DF")])
7657 (define_expand "avx512f_movddup512<mask_name>"
7658   [(set (match_operand:V8DF 0 "register_operand")
7659         (vec_select:V8DF
7660           (vec_concat:V16DF
7661             (match_operand:V8DF 1 "nonimmediate_operand")
7662             (match_dup 1))
7663           (parallel [(const_int 0) (const_int 8)
7664                      (const_int 2) (const_int 10)
7665                      (const_int 4) (const_int 12)
7666                      (const_int 6) (const_int 14)])))]
7667   "TARGET_AVX512F")
7669 (define_expand "avx512f_unpcklpd512<mask_name>"
7670   [(set (match_operand:V8DF 0 "register_operand")
7671         (vec_select:V8DF
7672           (vec_concat:V16DF
7673             (match_operand:V8DF 1 "register_operand")
7674             (match_operand:V8DF 2 "nonimmediate_operand"))
7675           (parallel [(const_int 0) (const_int 8)
7676                      (const_int 2) (const_int 10)
7677                      (const_int 4) (const_int 12)
7678                      (const_int 6) (const_int 14)])))]
7679   "TARGET_AVX512F")
7681 (define_insn "*avx512f_unpcklpd512<mask_name>"
7682   [(set (match_operand:V8DF 0 "register_operand" "=v,v")
7683         (vec_select:V8DF
7684           (vec_concat:V16DF
7685             (match_operand:V8DF 1 "nonimmediate_operand" "vm, v")
7686             (match_operand:V8DF 2 "nonimmediate_operand" "1 ,vm"))
7687           (parallel [(const_int 0) (const_int 8)
7688                      (const_int 2) (const_int 10)
7689                      (const_int 4) (const_int 12)
7690                      (const_int 6) (const_int 14)])))]
7691   "TARGET_AVX512F"
7692   "@
7693    vmovddup\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}
7694    vunpcklpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
7695   [(set_attr "type" "sselog")
7696    (set_attr "prefix" "evex")
7697    (set_attr "mode" "V8DF")])
7699 ;; Recall that the 256-bit unpck insns only shuffle within their lanes.
7700 (define_expand "avx_movddup256<mask_name>"
7701   [(set (match_operand:V4DF 0 "register_operand")
7702         (vec_select:V4DF
7703           (vec_concat:V8DF
7704             (match_operand:V4DF 1 "nonimmediate_operand")
7705             (match_dup 1))
7706           (parallel [(const_int 0) (const_int 4)
7707                      (const_int 2) (const_int 6)])))]
7708   "TARGET_AVX && <mask_avx512vl_condition>")
7710 (define_expand "avx_unpcklpd256<mask_name>"
7711   [(set (match_operand:V4DF 0 "register_operand")
7712         (vec_select:V4DF
7713           (vec_concat:V8DF
7714             (match_operand:V4DF 1 "register_operand")
7715             (match_operand:V4DF 2 "nonimmediate_operand"))
7716           (parallel [(const_int 0) (const_int 4)
7717                      (const_int 2) (const_int 6)])))]
7718   "TARGET_AVX && <mask_avx512vl_condition>")
7720 (define_insn "*avx_unpcklpd256<mask_name>"
7721   [(set (match_operand:V4DF 0 "register_operand"         "=v,v")
7722         (vec_select:V4DF
7723           (vec_concat:V8DF
7724             (match_operand:V4DF 1 "nonimmediate_operand" " v,m")
7725             (match_operand:V4DF 2 "nonimmediate_operand" "vm,1"))
7726           (parallel [(const_int 0) (const_int 4)
7727                      (const_int 2) (const_int 6)])))]
7728   "TARGET_AVX && <mask_avx512vl_condition>"
7729   "@
7730    vunpcklpd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
7731    vmovddup\t{%1, %0<mask_operand3>|%0<mask_operand3>, %1}"
7732   [(set_attr "type" "sselog")
7733    (set_attr "prefix" "vex")
7734    (set_attr "mode" "V4DF")])
7736 (define_expand "vec_interleave_lowv4df"
7737   [(set (match_dup 3)
7738         (vec_select:V4DF
7739           (vec_concat:V8DF
7740             (match_operand:V4DF 1 "register_operand")
7741             (match_operand:V4DF 2 "nonimmediate_operand"))
7742           (parallel [(const_int 0) (const_int 4)
7743                      (const_int 2) (const_int 6)])))
7744    (set (match_dup 4)
7745         (vec_select:V4DF
7746           (vec_concat:V8DF
7747             (match_dup 1)
7748             (match_dup 2))
7749           (parallel [(const_int 1) (const_int 5)
7750                      (const_int 3) (const_int 7)])))
7751    (set (match_operand:V4DF 0 "register_operand")
7752         (vec_select:V4DF
7753           (vec_concat:V8DF
7754             (match_dup 3)
7755             (match_dup 4))
7756           (parallel [(const_int 0) (const_int 1)
7757                      (const_int 4) (const_int 5)])))]
7758  "TARGET_AVX"
7760   operands[3] = gen_reg_rtx (V4DFmode);
7761   operands[4] = gen_reg_rtx (V4DFmode);
7764 (define_insn "avx512vl_unpcklpd128_mask"
7765   [(set (match_operand:V2DF 0 "register_operand" "=v")
7766         (vec_merge:V2DF
7767           (vec_select:V2DF
7768             (vec_concat:V4DF
7769               (match_operand:V2DF 1 "register_operand" "v")
7770               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
7771             (parallel [(const_int 0) (const_int 2)]))
7772           (match_operand:V2DF 3 "vector_move_operand" "0C")
7773           (match_operand:QI 4 "register_operand" "Yk")))]
7774   "TARGET_AVX512VL"
7775   "vunpcklpd\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
7776   [(set_attr "type" "sselog")
7777    (set_attr "prefix" "evex")
7778    (set_attr "mode" "V2DF")])
7780 (define_expand "vec_interleave_lowv2df"
7781   [(set (match_operand:V2DF 0 "register_operand")
7782         (vec_select:V2DF
7783           (vec_concat:V4DF
7784             (match_operand:V2DF 1 "nonimmediate_operand")
7785             (match_operand:V2DF 2 "nonimmediate_operand"))
7786           (parallel [(const_int 0)
7787                      (const_int 2)])))]
7788   "TARGET_SSE2"
7790   if (!ix86_vec_interleave_v2df_operator_ok (operands, 0))
7791     operands[1] = force_reg (V2DFmode, operands[1]);
7794 (define_insn "*vec_interleave_lowv2df"
7795   [(set (match_operand:V2DF 0 "nonimmediate_operand"     "=x,v,v,x,v,o")
7796         (vec_select:V2DF
7797           (vec_concat:V4DF
7798             (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,m,0,v,0")
7799             (match_operand:V2DF 2 "nonimmediate_operand" " x,v,1,m,m,v"))
7800           (parallel [(const_int 0)
7801                      (const_int 2)])))]
7802   "TARGET_SSE2 && ix86_vec_interleave_v2df_operator_ok (operands, 0)"
7803   "@
7804    unpcklpd\t{%2, %0|%0, %2}
7805    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
7806    %vmovddup\t{%1, %0|%0, %q1}
7807    movhpd\t{%2, %0|%0, %q2}
7808    vmovhpd\t{%2, %1, %0|%0, %1, %q2}
7809    %vmovlpd\t{%2, %H0|%H0, %2}"
7810   [(set_attr "isa" "noavx,avx,sse3,noavx,avx,*")
7811    (set_attr "type" "sselog,sselog,sselog,ssemov,ssemov,ssemov")
7812    (set_attr "prefix_data16" "*,*,*,1,*,1")
7813    (set_attr "prefix" "orig,maybe_evex,maybe_vex,orig,maybe_evex,maybe_vex")
7814    (set_attr "mode" "V2DF,V2DF,DF,V1DF,V1DF,V1DF")])
7816 (define_split
7817   [(set (match_operand:V2DF 0 "memory_operand")
7818         (vec_select:V2DF
7819           (vec_concat:V4DF
7820             (match_operand:V2DF 1 "register_operand")
7821             (match_dup 1))
7822           (parallel [(const_int 0)
7823                      (const_int 2)])))]
7824   "TARGET_SSE3 && reload_completed"
7825   [(const_int 0)]
7827   rtx low = gen_lowpart (DFmode, operands[1]);
7829   emit_move_insn (adjust_address (operands[0], DFmode, 0), low);
7830   emit_move_insn (adjust_address (operands[0], DFmode, 8), low);
7831   DONE;
7834 (define_split
7835   [(set (match_operand:V2DF 0 "register_operand")
7836         (vec_select:V2DF
7837           (vec_concat:V4DF
7838             (match_operand:V2DF 1 "memory_operand")
7839             (match_dup 1))
7840           (parallel [(match_operand:SI 2 "const_0_to_1_operand")
7841                      (match_operand:SI 3 "const_int_operand")])))]
7842   "TARGET_SSE3 && INTVAL (operands[2]) + 2 == INTVAL (operands[3])"
7843   [(set (match_dup 0) (vec_duplicate:V2DF (match_dup 1)))]
7845   operands[1] = adjust_address (operands[1], DFmode, INTVAL (operands[2]) * 8);
7848 (define_insn "avx512f_vmscalef<mode><round_name>"
7849   [(set (match_operand:VF_128 0 "register_operand" "=v")
7850         (vec_merge:VF_128
7851           (unspec:VF_128
7852             [(match_operand:VF_128 1 "register_operand" "v")
7853              (match_operand:VF_128 2 "<round_nimm_predicate>" "<round_constraint>")]
7854             UNSPEC_SCALEF)
7855           (match_dup 1)
7856           (const_int 1)))]
7857   "TARGET_AVX512F"
7858   "vscalef<ssescalarmodesuffix>\t{<round_op3>%2, %1, %0|%0, %1, %2<round_op3>}"
7859   [(set_attr "prefix" "evex")
7860    (set_attr "mode"  "<ssescalarmode>")])
7862 (define_insn "<avx512>_scalef<mode><mask_name><round_name>"
7863   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
7864         (unspec:VF_AVX512VL
7865           [(match_operand:VF_AVX512VL 1 "register_operand" "v")
7866            (match_operand:VF_AVX512VL 2 "nonimmediate_operand" "<round_constraint>")]
7867           UNSPEC_SCALEF))]
7868   "TARGET_AVX512F"
7869   "vscalef<ssemodesuffix>\t{<round_mask_op3>%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2<round_mask_op3>}"
7870   [(set_attr "prefix" "evex")
7871    (set_attr "mode"  "<MODE>")])
7873 (define_expand "<avx512>_vternlog<mode>_maskz"
7874   [(match_operand:VI48_AVX512VL 0 "register_operand")
7875    (match_operand:VI48_AVX512VL 1 "register_operand")
7876    (match_operand:VI48_AVX512VL 2 "register_operand")
7877    (match_operand:VI48_AVX512VL 3 "nonimmediate_operand")
7878    (match_operand:SI 4 "const_0_to_255_operand")
7879    (match_operand:<avx512fmaskmode> 5 "register_operand")]
7880   "TARGET_AVX512F"
7882   emit_insn (gen_<avx512>_vternlog<mode>_maskz_1 (
7883     operands[0], operands[1], operands[2], operands[3],
7884     operands[4], CONST0_RTX (<MODE>mode), operands[5]));
7885   DONE;
7888 (define_insn "<avx512>_vternlog<mode><sd_maskz_name>"
7889   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
7890         (unspec:VI48_AVX512VL
7891           [(match_operand:VI48_AVX512VL 1 "register_operand" "0")
7892            (match_operand:VI48_AVX512VL 2 "register_operand" "v")
7893            (match_operand:VI48_AVX512VL 3 "nonimmediate_operand" "vm")
7894            (match_operand:SI 4 "const_0_to_255_operand")]
7895           UNSPEC_VTERNLOG))]
7896   "TARGET_AVX512F"
7897   "vpternlog<ssemodesuffix>\t{%4, %3, %2, %0<sd_mask_op5>|%0<sd_mask_op5>, %2, %3, %4}"
7898   [(set_attr "type" "sselog")
7899    (set_attr "prefix" "evex")
7900    (set_attr "mode" "<sseinsnmode>")])
7902 (define_insn "<avx512>_vternlog<mode>_mask"
7903   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
7904         (vec_merge:VI48_AVX512VL
7905           (unspec:VI48_AVX512VL
7906             [(match_operand:VI48_AVX512VL 1 "register_operand" "0")
7907              (match_operand:VI48_AVX512VL 2 "register_operand" "v")
7908              (match_operand:VI48_AVX512VL 3 "nonimmediate_operand" "vm")
7909              (match_operand:SI 4 "const_0_to_255_operand")]
7910             UNSPEC_VTERNLOG)
7911           (match_dup 1)
7912           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
7913   "TARGET_AVX512F"
7914   "vpternlog<ssemodesuffix>\t{%4, %3, %2, %0%{%5%}|%0%{%5%}, %2, %3, %4}"
7915   [(set_attr "type" "sselog")
7916    (set_attr "prefix" "evex")
7917    (set_attr "mode" "<sseinsnmode>")])
7919 (define_insn "<avx512>_getexp<mode><mask_name><round_saeonly_name>"
7920   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
7921         (unspec:VF_AVX512VL [(match_operand:VF_AVX512VL 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
7922                         UNSPEC_GETEXP))]
7923    "TARGET_AVX512F"
7924    "vgetexp<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}";
7925     [(set_attr "prefix" "evex")
7926      (set_attr "mode" "<MODE>")])
7928 (define_insn "avx512f_sgetexp<mode><round_saeonly_name>"
7929   [(set (match_operand:VF_128 0 "register_operand" "=v")
7930         (vec_merge:VF_128
7931           (unspec:VF_128
7932             [(match_operand:VF_128 1 "register_operand" "v")
7933              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
7934             UNSPEC_GETEXP)
7935           (match_dup 1)
7936           (const_int 1)))]
7937    "TARGET_AVX512F"
7938    "vgetexp<ssescalarmodesuffix>\t{<round_saeonly_op3>%2, %1, %0|%0, %1, %2<round_saeonly_op3>}";
7939     [(set_attr "prefix" "evex")
7940      (set_attr "mode" "<ssescalarmode>")])
7942 (define_insn "<mask_codefor><avx512>_align<mode><mask_name>"
7943   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
7944         (unspec:VI48_AVX512VL [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
7945                                (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")
7946                                (match_operand:SI 3 "const_0_to_255_operand")]
7947                               UNSPEC_ALIGN))]
7948   "TARGET_AVX512F"
7949   "valign<ssemodesuffix>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}";
7950   [(set_attr "prefix" "evex")
7951    (set_attr "mode" "<sseinsnmode>")])
7953 (define_expand "avx512f_shufps512_mask"
7954   [(match_operand:V16SF 0 "register_operand")
7955    (match_operand:V16SF 1 "register_operand")
7956    (match_operand:V16SF 2 "nonimmediate_operand")
7957    (match_operand:SI 3 "const_0_to_255_operand")
7958    (match_operand:V16SF 4 "register_operand")
7959    (match_operand:HI 5 "register_operand")]
7960   "TARGET_AVX512F"
7962   int mask = INTVAL (operands[3]);
7963   emit_insn (gen_avx512f_shufps512_1_mask (operands[0], operands[1], operands[2],
7964                                           GEN_INT ((mask >> 0) & 3),
7965                                           GEN_INT ((mask >> 2) & 3),
7966                                           GEN_INT (((mask >> 4) & 3) + 16),
7967                                           GEN_INT (((mask >> 6) & 3) + 16),
7968                                           GEN_INT (((mask >> 0) & 3) + 4),
7969                                           GEN_INT (((mask >> 2) & 3) + 4),
7970                                           GEN_INT (((mask >> 4) & 3) + 20),
7971                                           GEN_INT (((mask >> 6) & 3) + 20),
7972                                           GEN_INT (((mask >> 0) & 3) + 8),
7973                                           GEN_INT (((mask >> 2) & 3) + 8),
7974                                           GEN_INT (((mask >> 4) & 3) + 24),
7975                                           GEN_INT (((mask >> 6) & 3) + 24),
7976                                           GEN_INT (((mask >> 0) & 3) + 12),
7977                                           GEN_INT (((mask >> 2) & 3) + 12),
7978                                           GEN_INT (((mask >> 4) & 3) + 28),
7979                                           GEN_INT (((mask >> 6) & 3) + 28),
7980                                           operands[4], operands[5]));
7981   DONE;
7985 (define_expand "<avx512>_fixupimm<mode>_maskz<round_saeonly_expand_name>"
7986   [(match_operand:VF_AVX512VL 0 "register_operand")
7987    (match_operand:VF_AVX512VL 1 "register_operand")
7988    (match_operand:VF_AVX512VL 2 "register_operand")
7989    (match_operand:<sseintvecmode> 3 "<round_saeonly_expand_nimm_predicate>")
7990    (match_operand:SI 4 "const_0_to_255_operand")
7991    (match_operand:<avx512fmaskmode> 5 "register_operand")]
7992   "TARGET_AVX512F"
7994   emit_insn (gen_<avx512>_fixupimm<mode>_maskz_1<round_saeonly_expand_name> (
7995         operands[0], operands[1], operands[2], operands[3],
7996         operands[4], CONST0_RTX (<MODE>mode), operands[5]
7997         <round_saeonly_expand_operand6>));
7998   DONE;
8001 (define_insn "<avx512>_fixupimm<mode><sd_maskz_name><round_saeonly_name>"
8002   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8003         (unspec:VF_AVX512VL
8004           [(match_operand:VF_AVX512VL 1 "register_operand" "0")
8005            (match_operand:VF_AVX512VL 2 "register_operand" "v")
8006            (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "<round_saeonly_constraint>")
8007            (match_operand:SI 4 "const_0_to_255_operand")]
8008            UNSPEC_FIXUPIMM))]
8009   "TARGET_AVX512F"
8010   "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}";
8011   [(set_attr "prefix" "evex")
8012    (set_attr "mode" "<MODE>")])
8014 (define_insn "<avx512>_fixupimm<mode>_mask<round_saeonly_name>"
8015   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8016         (vec_merge:VF_AVX512VL
8017           (unspec:VF_AVX512VL
8018             [(match_operand:VF_AVX512VL 1 "register_operand" "0")
8019              (match_operand:VF_AVX512VL 2 "register_operand" "v")
8020              (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "<round_saeonly_constraint>")
8021              (match_operand:SI 4 "const_0_to_255_operand")]
8022              UNSPEC_FIXUPIMM)
8023           (match_dup 1)
8024           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
8025   "TARGET_AVX512F"
8026   "vfixupimm<ssemodesuffix>\t{%4, <round_saeonly_op6>%3, %2, %0%{%5%}|%0%{%5%}, %2, %3<round_saeonly_op6>, %4}";
8027   [(set_attr "prefix" "evex")
8028    (set_attr "mode" "<MODE>")])
8030 (define_expand "avx512f_sfixupimm<mode>_maskz<round_saeonly_expand_name>"
8031   [(match_operand:VF_128 0 "register_operand")
8032    (match_operand:VF_128 1 "register_operand")
8033    (match_operand:VF_128 2 "register_operand")
8034    (match_operand:<sseintvecmode> 3 "<round_saeonly_expand_nimm_predicate>")
8035    (match_operand:SI 4 "const_0_to_255_operand")
8036    (match_operand:<avx512fmaskmode> 5 "register_operand")]
8037   "TARGET_AVX512F"
8039   emit_insn (gen_avx512f_sfixupimm<mode>_maskz_1<round_saeonly_expand_name> (
8040         operands[0], operands[1], operands[2], operands[3],
8041         operands[4], CONST0_RTX (<MODE>mode), operands[5]
8042         <round_saeonly_expand_operand6>));
8043   DONE;
8046 (define_insn "avx512f_sfixupimm<mode><sd_maskz_name><round_saeonly_name>"
8047   [(set (match_operand:VF_128 0 "register_operand" "=v")
8048         (vec_merge:VF_128
8049           (unspec:VF_128
8050             [(match_operand:VF_128 1 "register_operand" "0")
8051              (match_operand:VF_128 2 "register_operand" "v")
8052              (match_operand:<sseintvecmode> 3 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8053              (match_operand:SI 4 "const_0_to_255_operand")]
8054             UNSPEC_FIXUPIMM)
8055           (match_dup 1)
8056           (const_int 1)))]
8057    "TARGET_AVX512F"
8058    "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}";
8059    [(set_attr "prefix" "evex")
8060    (set_attr "mode" "<ssescalarmode>")])
8062 (define_insn "avx512f_sfixupimm<mode>_mask<round_saeonly_name>"
8063   [(set (match_operand:VF_128 0 "register_operand" "=v")
8064         (vec_merge:VF_128
8065           (vec_merge:VF_128
8066             (unspec:VF_128
8067                [(match_operand:VF_128 1 "register_operand" "0")
8068                 (match_operand:VF_128 2 "register_operand" "v")
8069                 (match_operand:<sseintvecmode> 3 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8070                 (match_operand:SI 4 "const_0_to_255_operand")]
8071                UNSPEC_FIXUPIMM)
8072             (match_dup 1)
8073             (const_int 1))
8074           (match_dup 1)
8075           (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
8076   "TARGET_AVX512F"
8077   "vfixupimm<ssescalarmodesuffix>\t{%4, <round_saeonly_op6>%3, %2, %0%{%5%}|%0%{%5%}, %2, %3<round_saeonly_op6>, %4}";
8078   [(set_attr "prefix" "evex")
8079    (set_attr "mode" "<ssescalarmode>")])
8081 (define_insn "<avx512>_rndscale<mode><mask_name><round_saeonly_name>"
8082   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
8083         (unspec:VF_AVX512VL
8084           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "<round_saeonly_constraint>")
8085            (match_operand:SI 2 "const_0_to_255_operand")]
8086           UNSPEC_ROUND))]
8087   "TARGET_AVX512F"
8088   "vrndscale<ssemodesuffix>\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}"
8089   [(set_attr "length_immediate" "1")
8090    (set_attr "prefix" "evex")
8091    (set_attr "mode" "<MODE>")])
8093 (define_insn "avx512f_rndscale<mode><round_saeonly_name>"
8094   [(set (match_operand:VF_128 0 "register_operand" "=v")
8095         (vec_merge:VF_128
8096           (unspec:VF_128
8097             [(match_operand:VF_128 1 "register_operand" "v")
8098              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
8099              (match_operand:SI 3 "const_0_to_255_operand")]
8100             UNSPEC_ROUND)
8101           (match_dup 1)
8102           (const_int 1)))]
8103   "TARGET_AVX512F"
8104   "vrndscale<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %2<round_saeonly_op4>, %3}"
8105   [(set_attr "length_immediate" "1")
8106    (set_attr "prefix" "evex")
8107    (set_attr "mode" "<MODE>")])
8109 ;; One bit in mask selects 2 elements.
8110 (define_insn "avx512f_shufps512_1<mask_name>"
8111   [(set (match_operand:V16SF 0 "register_operand" "=v")
8112         (vec_select:V16SF
8113           (vec_concat:V32SF
8114             (match_operand:V16SF 1 "register_operand" "v")
8115             (match_operand:V16SF 2 "nonimmediate_operand" "vm"))
8116           (parallel [(match_operand 3  "const_0_to_3_operand")
8117                      (match_operand 4  "const_0_to_3_operand")
8118                      (match_operand 5  "const_16_to_19_operand")
8119                      (match_operand 6  "const_16_to_19_operand")
8120                      (match_operand 7  "const_4_to_7_operand")
8121                      (match_operand 8  "const_4_to_7_operand")
8122                      (match_operand 9  "const_20_to_23_operand")
8123                      (match_operand 10  "const_20_to_23_operand")
8124                      (match_operand 11  "const_8_to_11_operand")
8125                      (match_operand 12  "const_8_to_11_operand")
8126                      (match_operand 13  "const_24_to_27_operand")
8127                      (match_operand 14  "const_24_to_27_operand")
8128                      (match_operand 15  "const_12_to_15_operand")
8129                      (match_operand 16  "const_12_to_15_operand")
8130                      (match_operand 17  "const_28_to_31_operand")
8131                      (match_operand 18  "const_28_to_31_operand")])))]
8132   "TARGET_AVX512F
8133    && (INTVAL (operands[3]) == (INTVAL (operands[7]) - 4)
8134        && INTVAL (operands[4]) == (INTVAL (operands[8]) - 4)
8135        && INTVAL (operands[5]) == (INTVAL (operands[9]) - 4)
8136        && INTVAL (operands[6]) == (INTVAL (operands[10]) - 4)
8137        && INTVAL (operands[3]) == (INTVAL (operands[11]) - 8)
8138        && INTVAL (operands[4]) == (INTVAL (operands[12]) - 8)
8139        && INTVAL (operands[5]) == (INTVAL (operands[13]) - 8)
8140        && INTVAL (operands[6]) == (INTVAL (operands[14]) - 8)
8141        && INTVAL (operands[3]) == (INTVAL (operands[15]) - 12)
8142        && INTVAL (operands[4]) == (INTVAL (operands[16]) - 12)
8143        && INTVAL (operands[5]) == (INTVAL (operands[17]) - 12)
8144        && INTVAL (operands[6]) == (INTVAL (operands[18]) - 12))"
8146   int mask;
8147   mask = INTVAL (operands[3]);
8148   mask |= INTVAL (operands[4]) << 2;
8149   mask |= (INTVAL (operands[5]) - 16) << 4;
8150   mask |= (INTVAL (operands[6]) - 16) << 6;
8151   operands[3] = GEN_INT (mask);
8153   return "vshufps\t{%3, %2, %1, %0<mask_operand19>|%0<mask_operand19>, %1, %2, %3}";
8155   [(set_attr "type" "sselog")
8156    (set_attr "length_immediate" "1")
8157    (set_attr "prefix" "evex")
8158    (set_attr "mode" "V16SF")])
8160 (define_expand "avx512f_shufpd512_mask"
8161   [(match_operand:V8DF 0 "register_operand")
8162    (match_operand:V8DF 1 "register_operand")
8163    (match_operand:V8DF 2 "nonimmediate_operand")
8164    (match_operand:SI 3 "const_0_to_255_operand")
8165    (match_operand:V8DF 4 "register_operand")
8166    (match_operand:QI 5 "register_operand")]
8167   "TARGET_AVX512F"
8169   int mask = INTVAL (operands[3]);
8170   emit_insn (gen_avx512f_shufpd512_1_mask (operands[0], operands[1], operands[2],
8171                                         GEN_INT (mask & 1),
8172                                         GEN_INT (mask & 2 ? 9 : 8),
8173                                         GEN_INT (mask & 4 ? 3 : 2),
8174                                         GEN_INT (mask & 8 ? 11 : 10),
8175                                         GEN_INT (mask & 16 ? 5 : 4),
8176                                         GEN_INT (mask & 32 ? 13 : 12),
8177                                         GEN_INT (mask & 64 ? 7 : 6),
8178                                         GEN_INT (mask & 128 ? 15 : 14),
8179                                         operands[4], operands[5]));
8180   DONE;
8183 (define_insn "avx512f_shufpd512_1<mask_name>"
8184   [(set (match_operand:V8DF 0 "register_operand" "=v")
8185         (vec_select:V8DF
8186           (vec_concat:V16DF
8187             (match_operand:V8DF 1 "register_operand" "v")
8188             (match_operand:V8DF 2 "nonimmediate_operand" "vm"))
8189           (parallel [(match_operand 3 "const_0_to_1_operand")
8190                      (match_operand 4 "const_8_to_9_operand")
8191                      (match_operand 5 "const_2_to_3_operand")
8192                      (match_operand 6 "const_10_to_11_operand")
8193                      (match_operand 7 "const_4_to_5_operand")
8194                      (match_operand 8 "const_12_to_13_operand")
8195                      (match_operand 9 "const_6_to_7_operand")
8196                      (match_operand 10 "const_14_to_15_operand")])))]
8197   "TARGET_AVX512F"
8199   int mask;
8200   mask = INTVAL (operands[3]);
8201   mask |= (INTVAL (operands[4]) - 8) << 1;
8202   mask |= (INTVAL (operands[5]) - 2) << 2;
8203   mask |= (INTVAL (operands[6]) - 10) << 3;
8204   mask |= (INTVAL (operands[7]) - 4) << 4;
8205   mask |= (INTVAL (operands[8]) - 12) << 5;
8206   mask |= (INTVAL (operands[9]) - 6) << 6;
8207   mask |= (INTVAL (operands[10]) - 14) << 7;
8208   operands[3] = GEN_INT (mask);
8210   return "vshufpd\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
8212   [(set_attr "type" "sselog")
8213    (set_attr "length_immediate" "1")
8214    (set_attr "prefix" "evex")
8215    (set_attr "mode" "V8DF")])
8217 (define_expand "avx_shufpd256<mask_expand4_name>"
8218   [(match_operand:V4DF 0 "register_operand")
8219    (match_operand:V4DF 1 "register_operand")
8220    (match_operand:V4DF 2 "nonimmediate_operand")
8221    (match_operand:SI 3 "const_int_operand")]
8222   "TARGET_AVX"
8224   int mask = INTVAL (operands[3]);
8225   emit_insn (gen_avx_shufpd256_1<mask_expand4_name> (operands[0],
8226                                                      operands[1],
8227                                                      operands[2],
8228                                                      GEN_INT (mask & 1),
8229                                                      GEN_INT (mask & 2 ? 5 : 4),
8230                                                      GEN_INT (mask & 4 ? 3 : 2),
8231                                                      GEN_INT (mask & 8 ? 7 : 6)
8232                                                      <mask_expand4_args>));
8233   DONE;
8236 (define_insn "avx_shufpd256_1<mask_name>"
8237   [(set (match_operand:V4DF 0 "register_operand" "=v")
8238         (vec_select:V4DF
8239           (vec_concat:V8DF
8240             (match_operand:V4DF 1 "register_operand" "v")
8241             (match_operand:V4DF 2 "nonimmediate_operand" "vm"))
8242           (parallel [(match_operand 3 "const_0_to_1_operand")
8243                      (match_operand 4 "const_4_to_5_operand")
8244                      (match_operand 5 "const_2_to_3_operand")
8245                      (match_operand 6 "const_6_to_7_operand")])))]
8246   "TARGET_AVX && <mask_avx512vl_condition>"
8248   int mask;
8249   mask = INTVAL (operands[3]);
8250   mask |= (INTVAL (operands[4]) - 4) << 1;
8251   mask |= (INTVAL (operands[5]) - 2) << 2;
8252   mask |= (INTVAL (operands[6]) - 6) << 3;
8253   operands[3] = GEN_INT (mask);
8255   return "vshufpd\t{%3, %2, %1, %0<mask_operand7>|%0<mask_operand7>, %1, %2, %3}";
8257   [(set_attr "type" "sseshuf")
8258    (set_attr "length_immediate" "1")
8259    (set_attr "prefix" "vex")
8260    (set_attr "mode" "V4DF")])
8262 (define_expand "sse2_shufpd<mask_expand4_name>"
8263   [(match_operand:V2DF 0 "register_operand")
8264    (match_operand:V2DF 1 "register_operand")
8265    (match_operand:V2DF 2 "vector_operand")
8266    (match_operand:SI 3 "const_int_operand")]
8267   "TARGET_SSE2"
8269   int mask = INTVAL (operands[3]);
8270   emit_insn (gen_sse2_shufpd_v2df<mask_expand4_name> (operands[0], operands[1],
8271                                                       operands[2], GEN_INT (mask & 1),
8272                                                       GEN_INT (mask & 2 ? 3 : 2)
8273                                                       <mask_expand4_args>));
8274   DONE;
8277 (define_insn "sse2_shufpd_v2df_mask"
8278   [(set (match_operand:V2DF 0 "register_operand" "=v")
8279     (vec_merge:V2DF
8280           (vec_select:V2DF
8281             (vec_concat:V4DF
8282               (match_operand:V2DF 1 "register_operand" "v")
8283               (match_operand:V2DF 2 "nonimmediate_operand" "vm"))
8284             (parallel [(match_operand 3 "const_0_to_1_operand")
8285                            (match_operand 4 "const_2_to_3_operand")]))
8286       (match_operand:V2DF 5 "vector_move_operand" "0C")
8287       (match_operand:QI 6 "register_operand" "Yk")))]
8288   "TARGET_AVX512VL"
8290   int mask;
8291   mask = INTVAL (operands[3]);
8292   mask |= (INTVAL (operands[4]) - 2) << 1;
8293   operands[3] = GEN_INT (mask);
8295   return "vshufpd\t{%3, %2, %1, %0%{%6%}%N5|%0%{6%}%N5, %1, %2, %3}";
8297   [(set_attr "type" "sseshuf")
8298    (set_attr "length_immediate" "1")
8299    (set_attr "prefix" "evex")
8300    (set_attr "mode" "V2DF")])
8302 ;; punpcklqdq and punpckhqdq are shorter than shufpd.
8303 (define_insn "avx2_interleave_highv4di<mask_name>"
8304   [(set (match_operand:V4DI 0 "register_operand" "=v")
8305         (vec_select:V4DI
8306           (vec_concat:V8DI
8307             (match_operand:V4DI 1 "register_operand" "v")
8308             (match_operand:V4DI 2 "nonimmediate_operand" "vm"))
8309           (parallel [(const_int 1)
8310                      (const_int 5)
8311                      (const_int 3)
8312                      (const_int 7)])))]
8313   "TARGET_AVX2 && <mask_avx512vl_condition>"
8314   "vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8315   [(set_attr "type" "sselog")
8316    (set_attr "prefix" "vex")
8317    (set_attr "mode" "OI")])
8319 (define_insn "<mask_codefor>avx512f_interleave_highv8di<mask_name>"
8320   [(set (match_operand:V8DI 0 "register_operand" "=v")
8321         (vec_select:V8DI
8322           (vec_concat:V16DI
8323             (match_operand:V8DI 1 "register_operand" "v")
8324             (match_operand:V8DI 2 "nonimmediate_operand" "vm"))
8325           (parallel [(const_int 1) (const_int 9)
8326                      (const_int 3) (const_int 11)
8327                      (const_int 5) (const_int 13)
8328                      (const_int 7) (const_int 15)])))]
8329   "TARGET_AVX512F"
8330   "vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8331   [(set_attr "type" "sselog")
8332    (set_attr "prefix" "evex")
8333    (set_attr "mode" "XI")])
8335 (define_insn "vec_interleave_highv2di<mask_name>"
8336   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
8337         (vec_select:V2DI
8338           (vec_concat:V4DI
8339             (match_operand:V2DI 1 "register_operand" "0,v")
8340             (match_operand:V2DI 2 "vector_operand" "xBm,vm"))
8341           (parallel [(const_int 1)
8342                      (const_int 3)])))]
8343   "TARGET_SSE2 && <mask_avx512vl_condition>"
8344   "@
8345    punpckhqdq\t{%2, %0|%0, %2}
8346    vpunpckhqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8347   [(set_attr "isa" "noavx,avx")
8348    (set_attr "type" "sselog")
8349    (set_attr "prefix_data16" "1,*")
8350    (set_attr "prefix" "orig,<mask_prefix>")
8351    (set_attr "mode" "TI")])
8353 (define_insn "avx2_interleave_lowv4di<mask_name>"
8354   [(set (match_operand:V4DI 0 "register_operand" "=v")
8355         (vec_select:V4DI
8356           (vec_concat:V8DI
8357             (match_operand:V4DI 1 "register_operand" "v")
8358             (match_operand:V4DI 2 "nonimmediate_operand" "vm"))
8359           (parallel [(const_int 0)
8360                      (const_int 4)
8361                      (const_int 2)
8362                      (const_int 6)])))]
8363   "TARGET_AVX2 && <mask_avx512vl_condition>"
8364   "vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8365   [(set_attr "type" "sselog")
8366    (set_attr "prefix" "vex")
8367    (set_attr "mode" "OI")])
8369 (define_insn "<mask_codefor>avx512f_interleave_lowv8di<mask_name>"
8370   [(set (match_operand:V8DI 0 "register_operand" "=v")
8371         (vec_select:V8DI
8372           (vec_concat:V16DI
8373             (match_operand:V8DI 1 "register_operand" "v")
8374             (match_operand:V8DI 2 "nonimmediate_operand" "vm"))
8375           (parallel [(const_int 0) (const_int 8)
8376                      (const_int 2) (const_int 10)
8377                      (const_int 4) (const_int 12)
8378                      (const_int 6) (const_int 14)])))]
8379   "TARGET_AVX512F"
8380   "vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8381   [(set_attr "type" "sselog")
8382    (set_attr "prefix" "evex")
8383    (set_attr "mode" "XI")])
8385 (define_insn "vec_interleave_lowv2di<mask_name>"
8386   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
8387         (vec_select:V2DI
8388           (vec_concat:V4DI
8389             (match_operand:V2DI 1 "register_operand" "0,v")
8390             (match_operand:V2DI 2 "vector_operand" "xBm,vm"))
8391           (parallel [(const_int 0)
8392                      (const_int 2)])))]
8393   "TARGET_SSE2 && <mask_avx512vl_condition>"
8394   "@
8395    punpcklqdq\t{%2, %0|%0, %2}
8396    vpunpcklqdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
8397   [(set_attr "isa" "noavx,avx")
8398    (set_attr "type" "sselog")
8399    (set_attr "prefix_data16" "1,*")
8400    (set_attr "prefix" "orig,vex")
8401    (set_attr "mode" "TI")])
8403 (define_insn "sse2_shufpd_<mode>"
8404   [(set (match_operand:VI8F_128 0 "register_operand" "=x,v")
8405         (vec_select:VI8F_128
8406           (vec_concat:<ssedoublevecmode>
8407             (match_operand:VI8F_128 1 "register_operand" "0,v")
8408             (match_operand:VI8F_128 2 "vector_operand" "xBm,vm"))
8409           (parallel [(match_operand 3 "const_0_to_1_operand")
8410                      (match_operand 4 "const_2_to_3_operand")])))]
8411   "TARGET_SSE2"
8413   int mask;
8414   mask = INTVAL (operands[3]);
8415   mask |= (INTVAL (operands[4]) - 2) << 1;
8416   operands[3] = GEN_INT (mask);
8418   switch (which_alternative)
8419     {
8420     case 0:
8421       return "shufpd\t{%3, %2, %0|%0, %2, %3}";
8422     case 1:
8423       return "vshufpd\t{%3, %2, %1, %0|%0, %1, %2, %3}";
8424     default:
8425       gcc_unreachable ();
8426     }
8428   [(set_attr "isa" "noavx,avx")
8429    (set_attr "type" "sseshuf")
8430    (set_attr "length_immediate" "1")
8431    (set_attr "prefix" "orig,maybe_evex")
8432    (set_attr "mode" "V2DF")])
8434 ;; Avoid combining registers from different units in a single alternative,
8435 ;; see comment above inline_secondary_memory_needed function in i386.c
8436 (define_insn "sse2_storehpd"
8437   [(set (match_operand:DF 0 "nonimmediate_operand"     "=m,x,Yv,x,*f,r")
8438         (vec_select:DF
8439           (match_operand:V2DF 1 "nonimmediate_operand" " v,0, v,o,o,o")
8440           (parallel [(const_int 1)])))]
8441   "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8442   "@
8443    %vmovhpd\t{%1, %0|%0, %1}
8444    unpckhpd\t%0, %0
8445    vunpckhpd\t{%d1, %0|%0, %d1}
8446    #
8447    #
8448    #"
8449   [(set_attr "isa" "*,noavx,avx,*,*,*")
8450    (set_attr "type" "ssemov,sselog1,sselog1,ssemov,fmov,imov")
8451    (set (attr "prefix_data16")
8452      (if_then_else
8453        (and (eq_attr "alternative" "0")
8454             (not (match_test "TARGET_AVX")))
8455        (const_string "1")
8456        (const_string "*")))
8457    (set_attr "prefix" "maybe_vex,orig,maybe_evex,*,*,*")
8458    (set_attr "mode" "V1DF,V1DF,V2DF,DF,DF,DF")])
8460 (define_split
8461   [(set (match_operand:DF 0 "register_operand")
8462         (vec_select:DF
8463           (match_operand:V2DF 1 "memory_operand")
8464           (parallel [(const_int 1)])))]
8465   "TARGET_SSE2 && reload_completed"
8466   [(set (match_dup 0) (match_dup 1))]
8467   "operands[1] = adjust_address (operands[1], DFmode, 8);")
8469 (define_insn "*vec_extractv2df_1_sse"
8470   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x")
8471         (vec_select:DF
8472           (match_operand:V2DF 1 "nonimmediate_operand" "x,x,o")
8473           (parallel [(const_int 1)])))]
8474   "!TARGET_SSE2 && TARGET_SSE
8475    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8476   "@
8477    movhps\t{%1, %0|%q0, %1}
8478    movhlps\t{%1, %0|%0, %1}
8479    movlps\t{%H1, %0|%0, %H1}"
8480   [(set_attr "type" "ssemov")
8481    (set_attr "mode" "V2SF,V4SF,V2SF")])
8483 ;; Avoid combining registers from different units in a single alternative,
8484 ;; see comment above inline_secondary_memory_needed function in i386.c
8485 (define_insn "sse2_storelpd"
8486   [(set (match_operand:DF 0 "nonimmediate_operand"     "=m,x,x,*f,r")
8487         (vec_select:DF
8488           (match_operand:V2DF 1 "nonimmediate_operand" " v,x,m,m,m")
8489           (parallel [(const_int 0)])))]
8490   "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8491   "@
8492    %vmovlpd\t{%1, %0|%0, %1}
8493    #
8494    #
8495    #
8496    #"
8497   [(set_attr "type" "ssemov,ssemov,ssemov,fmov,imov")
8498    (set_attr "prefix_data16" "1,*,*,*,*")
8499    (set_attr "prefix" "maybe_vex")
8500    (set_attr "mode" "V1DF,DF,DF,DF,DF")])
8502 (define_split
8503   [(set (match_operand:DF 0 "register_operand")
8504         (vec_select:DF
8505           (match_operand:V2DF 1 "nonimmediate_operand")
8506           (parallel [(const_int 0)])))]
8507   "TARGET_SSE2 && reload_completed"
8508   [(set (match_dup 0) (match_dup 1))]
8509   "operands[1] = gen_lowpart (DFmode, operands[1]);")
8511 (define_insn "*vec_extractv2df_0_sse"
8512   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,x,x")
8513         (vec_select:DF
8514           (match_operand:V2DF 1 "nonimmediate_operand" "x,x,m")
8515           (parallel [(const_int 0)])))]
8516   "!TARGET_SSE2 && TARGET_SSE
8517    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
8518   "@
8519    movlps\t{%1, %0|%0, %1}
8520    movaps\t{%1, %0|%0, %1}
8521    movlps\t{%1, %0|%0, %q1}"
8522   [(set_attr "type" "ssemov")
8523    (set_attr "mode" "V2SF,V4SF,V2SF")])
8525 (define_expand "sse2_loadhpd_exp"
8526   [(set (match_operand:V2DF 0 "nonimmediate_operand")
8527         (vec_concat:V2DF
8528           (vec_select:DF
8529             (match_operand:V2DF 1 "nonimmediate_operand")
8530             (parallel [(const_int 0)]))
8531           (match_operand:DF 2 "nonimmediate_operand")))]
8532   "TARGET_SSE2"
8534   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V2DFmode, operands);
8536   emit_insn (gen_sse2_loadhpd (dst, operands[1], operands[2]));
8538   /* Fix up the destination if needed.  */
8539   if (dst != operands[0])
8540     emit_move_insn (operands[0], dst);
8542   DONE;
8545 ;; Avoid combining registers from different units in a single alternative,
8546 ;; see comment above inline_secondary_memory_needed function in i386.c
8547 (define_insn "sse2_loadhpd"
8548   [(set (match_operand:V2DF 0 "nonimmediate_operand"
8549           "=x,v,x,v,o,o ,o")
8550         (vec_concat:V2DF
8551           (vec_select:DF
8552             (match_operand:V2DF 1 "nonimmediate_operand"
8553           " 0,v,0,v,0,0 ,0")
8554             (parallel [(const_int 0)]))
8555           (match_operand:DF 2 "nonimmediate_operand"
8556           " m,m,x,v,x,*f,r")))]
8557   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
8558   "@
8559    movhpd\t{%2, %0|%0, %2}
8560    vmovhpd\t{%2, %1, %0|%0, %1, %2}
8561    unpcklpd\t{%2, %0|%0, %2}
8562    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
8563    #
8564    #
8565    #"
8566   [(set_attr "isa" "noavx,avx,noavx,avx,*,*,*")
8567    (set_attr "type" "ssemov,ssemov,sselog,sselog,ssemov,fmov,imov")
8568    (set_attr "prefix_data16" "1,*,*,*,*,*,*")
8569    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,*,*,*")
8570    (set_attr "mode" "V1DF,V1DF,V2DF,V2DF,DF,DF,DF")])
8572 (define_split
8573   [(set (match_operand:V2DF 0 "memory_operand")
8574         (vec_concat:V2DF
8575           (vec_select:DF (match_dup 0) (parallel [(const_int 0)]))
8576           (match_operand:DF 1 "register_operand")))]
8577   "TARGET_SSE2 && reload_completed"
8578   [(set (match_dup 0) (match_dup 1))]
8579   "operands[0] = adjust_address (operands[0], DFmode, 8);")
8581 (define_expand "sse2_loadlpd_exp"
8582   [(set (match_operand:V2DF 0 "nonimmediate_operand")
8583         (vec_concat:V2DF
8584           (match_operand:DF 2 "nonimmediate_operand")
8585           (vec_select:DF
8586             (match_operand:V2DF 1 "nonimmediate_operand")
8587             (parallel [(const_int 1)]))))]
8588   "TARGET_SSE2"
8590   rtx dst = ix86_fixup_binary_operands (UNKNOWN, V2DFmode, operands);
8592   emit_insn (gen_sse2_loadlpd (dst, operands[1], operands[2]));
8594   /* Fix up the destination if needed.  */
8595   if (dst != operands[0])
8596     emit_move_insn (operands[0], dst);
8598   DONE;
8601 ;; Avoid combining registers from different units in a single alternative,
8602 ;; see comment above inline_secondary_memory_needed function in i386.c
8603 (define_insn "sse2_loadlpd"
8604   [(set (match_operand:V2DF 0 "nonimmediate_operand"
8605           "=v,x,v,x,v,x,x,v,m,m ,m")
8606         (vec_concat:V2DF
8607           (match_operand:DF 2 "nonimmediate_operand"
8608           "vm,m,m,x,v,0,0,v,x,*f,r")
8609           (vec_select:DF
8610             (match_operand:V2DF 1 "vector_move_operand"
8611           " C,0,v,0,v,x,o,o,0,0 ,0")
8612             (parallel [(const_int 1)]))))]
8613   "TARGET_SSE2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
8614   "@
8615    %vmovq\t{%2, %0|%0, %2}
8616    movlpd\t{%2, %0|%0, %2}
8617    vmovlpd\t{%2, %1, %0|%0, %1, %2}
8618    movsd\t{%2, %0|%0, %2}
8619    vmovsd\t{%2, %1, %0|%0, %1, %2}
8620    shufpd\t{$2, %1, %0|%0, %1, 2}
8621    movhpd\t{%H1, %0|%0, %H1}
8622    vmovhpd\t{%H1, %2, %0|%0, %2, %H1}
8623    #
8624    #
8625    #"
8626   [(set_attr "isa" "*,noavx,avx,noavx,avx,noavx,noavx,avx,*,*,*")
8627    (set (attr "type")
8628      (cond [(eq_attr "alternative" "5")
8629               (const_string "sselog")
8630             (eq_attr "alternative" "9")
8631               (const_string "fmov")
8632             (eq_attr "alternative" "10")
8633               (const_string "imov")
8634            ]
8635            (const_string "ssemov")))
8636    (set_attr "prefix_data16" "*,1,*,*,*,*,1,*,*,*,*")
8637    (set_attr "length_immediate" "*,*,*,*,*,1,*,*,*,*,*")
8638    (set_attr "prefix" "maybe_vex,orig,maybe_evex,orig,maybe_evex,orig,orig,maybe_evex,*,*,*")
8639    (set_attr "mode" "DF,V1DF,V1DF,V1DF,V1DF,V2DF,V1DF,V1DF,DF,DF,DF")])
8641 (define_split
8642   [(set (match_operand:V2DF 0 "memory_operand")
8643         (vec_concat:V2DF
8644           (match_operand:DF 1 "register_operand")
8645           (vec_select:DF (match_dup 0) (parallel [(const_int 1)]))))]
8646   "TARGET_SSE2 && reload_completed"
8647   [(set (match_dup 0) (match_dup 1))]
8648   "operands[0] = adjust_address (operands[0], DFmode, 0);")
8650 (define_insn "sse2_movsd"
8651   [(set (match_operand:V2DF 0 "nonimmediate_operand"   "=x,v,x,v,m,x,x,v,o")
8652         (vec_merge:V2DF
8653           (match_operand:V2DF 2 "nonimmediate_operand" " x,v,m,m,v,0,0,v,0")
8654           (match_operand:V2DF 1 "nonimmediate_operand" " 0,v,0,v,0,x,o,o,v")
8655           (const_int 1)))]
8656   "TARGET_SSE2"
8657   "@
8658    movsd\t{%2, %0|%0, %2}
8659    vmovsd\t{%2, %1, %0|%0, %1, %2}
8660    movlpd\t{%2, %0|%0, %q2}
8661    vmovlpd\t{%2, %1, %0|%0, %1, %q2}
8662    %vmovlpd\t{%2, %0|%q0, %2}
8663    shufpd\t{$2, %1, %0|%0, %1, 2}
8664    movhps\t{%H1, %0|%0, %H1}
8665    vmovhps\t{%H1, %2, %0|%0, %2, %H1}
8666    %vmovhps\t{%1, %H0|%H0, %1}"
8667   [(set_attr "isa" "noavx,avx,noavx,avx,*,noavx,noavx,avx,*")
8668    (set (attr "type")
8669      (if_then_else
8670        (eq_attr "alternative" "5")
8671        (const_string "sselog")
8672        (const_string "ssemov")))
8673    (set (attr "prefix_data16")
8674      (if_then_else
8675        (and (eq_attr "alternative" "2,4")
8676             (not (match_test "TARGET_AVX")))
8677        (const_string "1")
8678        (const_string "*")))
8679    (set_attr "length_immediate" "*,*,*,*,*,1,*,*,*")
8680    (set_attr "prefix" "orig,maybe_evex,orig,maybe_evex,maybe_vex,orig,orig,maybe_evex,maybe_vex")
8681    (set_attr "mode" "DF,DF,V1DF,V1DF,V1DF,V2DF,V1DF,V1DF,V1DF")])
8683 (define_insn "vec_dupv2df<mask_name>"
8684   [(set (match_operand:V2DF 0 "register_operand"     "=x,x,v")
8685         (vec_duplicate:V2DF
8686           (match_operand:DF 1 "nonimmediate_operand" " 0,xm,vm")))]
8687   "TARGET_SSE2 && <mask_avx512vl_condition>"
8688   "@
8689    unpcklpd\t%0, %0
8690    %vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}
8691    vmovddup\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
8692   [(set_attr "isa" "noavx,sse3,avx512vl")
8693    (set_attr "type" "sselog1")
8694    (set_attr "prefix" "orig,maybe_vex,evex")
8695    (set_attr "mode" "V2DF,DF,DF")])
8697 (define_insn "vec_concatv2df"
8698   [(set (match_operand:V2DF 0 "register_operand"     "=x,x,v,x,v,x,x, v,x,x")
8699         (vec_concat:V2DF
8700           (match_operand:DF 1 "nonimmediate_operand" " 0,x,v,m,m,0,x,xm,0,0")
8701           (match_operand:DF 2 "vector_move_operand"  " x,x,v,1,1,m,m, C,x,m")))]
8702   "TARGET_SSE
8703    && (!(MEM_P (operands[1]) && MEM_P (operands[2]))
8704        || (TARGET_SSE3 && rtx_equal_p (operands[1], operands[2])))"
8705   "@
8706    unpcklpd\t{%2, %0|%0, %2}
8707    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
8708    vunpcklpd\t{%2, %1, %0|%0, %1, %2}
8709    %vmovddup\t{%1, %0|%0, %1}
8710    vmovddup\t{%1, %0|%0, %1}
8711    movhpd\t{%2, %0|%0, %2}
8712    vmovhpd\t{%2, %1, %0|%0, %1, %2}
8713    %vmovq\t{%1, %0|%0, %1}
8714    movlhps\t{%2, %0|%0, %2}
8715    movhps\t{%2, %0|%0, %2}"
8716   [(set_attr "isa" "sse2_noavx,avx,avx512vl,sse3,avx512vl,sse2_noavx,avx,sse2,noavx,noavx")
8717    (set (attr "type")
8718      (if_then_else
8719        (eq_attr "alternative" "0,1,2,3,4")
8720        (const_string "sselog")
8721        (const_string "ssemov")))
8722    (set (attr "prefix_data16")
8723         (if_then_else (eq_attr "alternative" "5")
8724                       (const_string "1")
8725                       (const_string "*")))
8726    (set_attr "prefix" "orig,vex,evex,maybe_vex,evex,orig,vex,maybe_vex,orig,orig")
8727    (set_attr "mode" "V2DF,V2DF,V2DF, DF, DF, V1DF,V1DF,DF,V4SF,V2SF")])
8729 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8731 ;; Parallel integer down-conversion operations
8733 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8735 (define_mode_iterator PMOV_DST_MODE_1 [V16QI V16HI V8SI V8HI])
8736 (define_mode_attr pmov_src_mode
8737   [(V16QI "V16SI") (V16HI "V16SI") (V8SI "V8DI") (V8HI "V8DI")])
8738 (define_mode_attr pmov_src_lower
8739   [(V16QI "v16si") (V16HI "v16si") (V8SI "v8di") (V8HI "v8di")])
8740 (define_mode_attr pmov_suff_1
8741   [(V16QI "db") (V16HI "dw") (V8SI "qd") (V8HI "qw")])
8743 (define_insn "*avx512f_<code><pmov_src_lower><mode>2"
8744   [(set (match_operand:PMOV_DST_MODE_1 0 "nonimmediate_operand" "=v,m")
8745         (any_truncate:PMOV_DST_MODE_1
8746           (match_operand:<pmov_src_mode> 1 "register_operand" "v,v")))]
8747   "TARGET_AVX512F"
8748   "vpmov<trunsuffix><pmov_suff_1>\t{%1, %0|%0, %1}"
8749   [(set_attr "type" "ssemov")
8750    (set_attr "memory" "none,store")
8751    (set_attr "prefix" "evex")
8752    (set_attr "mode" "<sseinsnmode>")])
8754 (define_insn "avx512f_<code><pmov_src_lower><mode>2_mask"
8755   [(set (match_operand:PMOV_DST_MODE_1 0 "nonimmediate_operand" "=v,m")
8756     (vec_merge:PMOV_DST_MODE_1
8757       (any_truncate:PMOV_DST_MODE_1
8758         (match_operand:<pmov_src_mode> 1 "register_operand" "v,v"))
8759       (match_operand:PMOV_DST_MODE_1 2 "vector_move_operand" "0C,0")
8760       (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
8761   "TARGET_AVX512F"
8762   "vpmov<trunsuffix><pmov_suff_1>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
8763   [(set_attr "type" "ssemov")
8764    (set_attr "memory" "none,store")
8765    (set_attr "prefix" "evex")
8766    (set_attr "mode" "<sseinsnmode>")])
8768 (define_expand "avx512f_<code><pmov_src_lower><mode>2_mask_store"
8769   [(set (match_operand:PMOV_DST_MODE_1 0 "memory_operand")
8770     (vec_merge:PMOV_DST_MODE_1
8771       (any_truncate:PMOV_DST_MODE_1
8772         (match_operand:<pmov_src_mode> 1 "register_operand"))
8773       (match_dup 0)
8774       (match_operand:<avx512fmaskmode> 2 "register_operand")))]
8775   "TARGET_AVX512F")
8777 (define_insn "avx512bw_<code>v32hiv32qi2"
8778   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
8779         (any_truncate:V32QI
8780             (match_operand:V32HI 1 "register_operand" "v,v")))]
8781   "TARGET_AVX512BW"
8782   "vpmov<trunsuffix>wb\t{%1, %0|%0, %1}"
8783   [(set_attr "type" "ssemov")
8784    (set_attr "memory" "none,store")
8785    (set_attr "prefix" "evex")
8786    (set_attr "mode" "XI")])
8788 (define_insn "avx512bw_<code>v32hiv32qi2_mask"
8789   [(set (match_operand:V32QI 0 "nonimmediate_operand" "=v,m")
8790     (vec_merge:V32QI
8791       (any_truncate:V32QI
8792         (match_operand:V32HI 1 "register_operand" "v,v"))
8793       (match_operand:V32QI 2 "vector_move_operand" "0C,0")
8794       (match_operand:SI 3 "register_operand" "Yk,Yk")))]
8795   "TARGET_AVX512BW"
8796   "vpmov<trunsuffix>wb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
8797   [(set_attr "type" "ssemov")
8798    (set_attr "memory" "none,store")
8799    (set_attr "prefix" "evex")
8800    (set_attr "mode" "XI")])
8802 (define_expand "avx512bw_<code>v32hiv32qi2_mask_store"
8803   [(set (match_operand:V32QI 0 "nonimmediate_operand")
8804     (vec_merge:V32QI
8805       (any_truncate:V32QI
8806         (match_operand:V32HI 1 "register_operand"))
8807       (match_dup 0)
8808       (match_operand:SI 2 "register_operand")))]
8809   "TARGET_AVX512BW")
8811 (define_mode_iterator PMOV_DST_MODE_2
8812   [V4SI V8HI (V16QI "TARGET_AVX512BW")])
8813 (define_mode_attr pmov_suff_2
8814   [(V16QI "wb") (V8HI "dw") (V4SI "qd")])
8816 (define_insn "*avx512vl_<code><ssedoublemodelower><mode>2"
8817   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand" "=v,m")
8818         (any_truncate:PMOV_DST_MODE_2
8819             (match_operand:<ssedoublemode> 1 "register_operand" "v,v")))]
8820   "TARGET_AVX512VL"
8821   "vpmov<trunsuffix><pmov_suff_2>\t{%1, %0|%0, %1}"
8822   [(set_attr "type" "ssemov")
8823    (set_attr "memory" "none,store")
8824    (set_attr "prefix" "evex")
8825    (set_attr "mode" "<sseinsnmode>")])
8827 (define_insn "<avx512>_<code><ssedoublemodelower><mode>2_mask"
8828   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand" "=v,m")
8829     (vec_merge:PMOV_DST_MODE_2
8830       (any_truncate:PMOV_DST_MODE_2
8831         (match_operand:<ssedoublemode> 1 "register_operand" "v,v"))
8832       (match_operand:PMOV_DST_MODE_2 2 "vector_move_operand" "0C,0")
8833       (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")))]
8834   "TARGET_AVX512VL"
8835   "vpmov<trunsuffix><pmov_suff_2>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
8836   [(set_attr "type" "ssemov")
8837    (set_attr "memory" "none,store")
8838    (set_attr "prefix" "evex")
8839    (set_attr "mode" "<sseinsnmode>")])
8841 (define_expand "<avx512>_<code><ssedoublemodelower><mode>2_mask_store"
8842   [(set (match_operand:PMOV_DST_MODE_2 0 "nonimmediate_operand")
8843     (vec_merge:PMOV_DST_MODE_2
8844       (any_truncate:PMOV_DST_MODE_2
8845         (match_operand:<ssedoublemode> 1 "register_operand"))
8846       (match_dup 0)
8847       (match_operand:<avx512fmaskmode> 2 "register_operand")))]
8848   "TARGET_AVX512VL")
8850 (define_mode_iterator PMOV_SRC_MODE_3 [V4DI V2DI V8SI V4SI (V8HI "TARGET_AVX512BW")])
8851 (define_mode_attr pmov_dst_3
8852   [(V4DI "V4QI") (V2DI "V2QI") (V8SI "V8QI") (V4SI "V4QI") (V8HI "V8QI")])
8853 (define_mode_attr pmov_dst_zeroed_3
8854   [(V4DI "V12QI") (V2DI "V14QI") (V8SI "V8QI") (V4SI "V12QI") (V8HI "V8QI")])
8855 (define_mode_attr pmov_suff_3
8856   [(V4DI "qb") (V2DI "qb") (V8SI "db") (V4SI "db") (V8HI "wb")])
8858 (define_insn "*avx512vl_<code><mode>v<ssescalarnum>qi2"
8859   [(set (match_operand:V16QI 0 "register_operand" "=v")
8860     (vec_concat:V16QI
8861       (any_truncate:<pmov_dst_3>
8862               (match_operand:PMOV_SRC_MODE_3 1 "register_operand" "v"))
8863       (match_operand:<pmov_dst_zeroed_3> 2 "const0_operand")))]
8864   "TARGET_AVX512VL"
8865   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%0, %1}"
8866   [(set_attr "type" "ssemov")
8867    (set_attr "prefix" "evex")
8868    (set_attr "mode" "TI")])
8870 (define_insn "*avx512vl_<code>v2div2qi2_store"
8871   [(set (match_operand:V16QI 0 "memory_operand" "=m")
8872     (vec_concat:V16QI
8873       (any_truncate:V2QI
8874               (match_operand:V2DI 1 "register_operand" "v"))
8875       (vec_select:V14QI
8876         (match_dup 0)
8877         (parallel [(const_int 2) (const_int 3)
8878                    (const_int 4) (const_int 5)
8879                    (const_int 6) (const_int 7)
8880                    (const_int 8) (const_int 9)
8881                    (const_int 10) (const_int 11)
8882                    (const_int 12) (const_int 13)
8883                    (const_int 14) (const_int 15)]))))]
8884   "TARGET_AVX512VL"
8885   "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
8886   [(set_attr "type" "ssemov")
8887    (set_attr "memory" "store")
8888    (set_attr "prefix" "evex")
8889    (set_attr "mode" "TI")])
8891 (define_insn "avx512vl_<code>v2div2qi2_mask"
8892   [(set (match_operand:V16QI 0 "register_operand" "=v")
8893     (vec_concat:V16QI
8894       (vec_merge:V2QI
8895         (any_truncate:V2QI
8896           (match_operand:V2DI 1 "register_operand" "v"))
8897         (vec_select:V2QI
8898           (match_operand:V16QI 2 "vector_move_operand" "0C")
8899           (parallel [(const_int 0) (const_int 1)]))
8900         (match_operand:QI 3 "register_operand" "Yk"))
8901       (const_vector:V14QI [(const_int 0) (const_int 0)
8902                            (const_int 0) (const_int 0)
8903                            (const_int 0) (const_int 0)
8904                            (const_int 0) (const_int 0)
8905                            (const_int 0) (const_int 0)
8906                            (const_int 0) (const_int 0)
8907                            (const_int 0) (const_int 0)])))]
8908   "TARGET_AVX512VL"
8909   "vpmov<trunsuffix>qb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
8910   [(set_attr "type" "ssemov")
8911    (set_attr "prefix" "evex")
8912    (set_attr "mode" "TI")])
8914 (define_insn "*avx512vl_<code>v2div2qi2_mask_1"
8915   [(set (match_operand:V16QI 0 "register_operand" "=v")
8916     (vec_concat:V16QI
8917       (vec_merge:V2QI
8918         (any_truncate:V2QI
8919           (match_operand:V2DI 1 "register_operand" "v"))
8920         (const_vector:V2QI [(const_int 0) (const_int 0)])
8921         (match_operand:QI 2 "register_operand" "Yk"))
8922       (const_vector:V14QI [(const_int 0) (const_int 0)
8923                            (const_int 0) (const_int 0)
8924                            (const_int 0) (const_int 0)
8925                            (const_int 0) (const_int 0)
8926                            (const_int 0) (const_int 0)
8927                            (const_int 0) (const_int 0)
8928                            (const_int 0) (const_int 0)])))]
8929   "TARGET_AVX512VL"
8930   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
8931   [(set_attr "type" "ssemov")
8932    (set_attr "prefix" "evex")
8933    (set_attr "mode" "TI")])
8935 (define_insn "avx512vl_<code>v2div2qi2_mask_store"
8936   [(set (match_operand:V16QI 0 "memory_operand" "=m")
8937     (vec_concat:V16QI
8938       (vec_merge:V2QI
8939         (any_truncate:V2QI
8940           (match_operand:V2DI 1 "register_operand" "v"))
8941         (vec_select:V2QI
8942           (match_dup 0)
8943           (parallel [(const_int 0) (const_int 1)]))
8944         (match_operand:QI 2 "register_operand" "Yk"))
8945       (vec_select:V14QI
8946         (match_dup 0)
8947         (parallel [(const_int 2) (const_int 3)
8948                    (const_int 4) (const_int 5)
8949                    (const_int 6) (const_int 7)
8950                    (const_int 8) (const_int 9)
8951                    (const_int 10) (const_int 11)
8952                    (const_int 12) (const_int 13)
8953                    (const_int 14) (const_int 15)]))))]
8954   "TARGET_AVX512VL"
8955   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}|%w0%{%2%}, %1}"
8956   [(set_attr "type" "ssemov")
8957    (set_attr "memory" "store")
8958    (set_attr "prefix" "evex")
8959    (set_attr "mode" "TI")])
8961 (define_insn "*avx512vl_<code><mode>v4qi2_store"
8962   [(set (match_operand:V16QI 0 "memory_operand" "=m")
8963     (vec_concat:V16QI
8964       (any_truncate:V4QI
8965               (match_operand:VI4_128_8_256 1 "register_operand" "v"))
8966       (vec_select:V12QI
8967         (match_dup 0)
8968         (parallel [(const_int 4) (const_int 5)
8969                    (const_int 6) (const_int 7)
8970                    (const_int 8) (const_int 9)
8971                    (const_int 10) (const_int 11)
8972                    (const_int 12) (const_int 13)
8973                    (const_int 14) (const_int 15)]))))]
8974   "TARGET_AVX512VL"
8975   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%0, %1}"
8976   [(set_attr "type" "ssemov")
8977    (set_attr "memory" "store")
8978    (set_attr "prefix" "evex")
8979    (set_attr "mode" "TI")])
8981 (define_insn "avx512vl_<code><mode>v4qi2_mask"
8982   [(set (match_operand:V16QI 0 "register_operand" "=v")
8983     (vec_concat:V16QI
8984       (vec_merge:V4QI
8985         (any_truncate:V4QI
8986           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
8987         (vec_select:V4QI
8988           (match_operand:V16QI 2 "vector_move_operand" "0C")
8989           (parallel [(const_int 0) (const_int 1)
8990                      (const_int 2) (const_int 3)]))
8991         (match_operand:QI 3 "register_operand" "Yk"))
8992       (const_vector:V12QI [(const_int 0) (const_int 0)
8993                            (const_int 0) (const_int 0)
8994                            (const_int 0) (const_int 0)
8995                            (const_int 0) (const_int 0)
8996                            (const_int 0) (const_int 0)
8997                            (const_int 0) (const_int 0)])))]
8998   "TARGET_AVX512VL"
8999   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9000   [(set_attr "type" "ssemov")
9001    (set_attr "prefix" "evex")
9002    (set_attr "mode" "TI")])
9004 (define_insn "*avx512vl_<code><mode>v4qi2_mask_1"
9005   [(set (match_operand:V16QI 0 "register_operand" "=v")
9006     (vec_concat:V16QI
9007       (vec_merge:V4QI
9008         (any_truncate:V4QI
9009           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9010         (const_vector:V4QI [(const_int 0) (const_int 0)
9011                             (const_int 0) (const_int 0)])
9012         (match_operand:QI 2 "register_operand" "Yk"))
9013       (const_vector:V12QI [(const_int 0) (const_int 0)
9014                            (const_int 0) (const_int 0)
9015                            (const_int 0) (const_int 0)
9016                            (const_int 0) (const_int 0)
9017                            (const_int 0) (const_int 0)
9018                            (const_int 0) (const_int 0)])))]
9019   "TARGET_AVX512VL"
9020   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9021   [(set_attr "type" "ssemov")
9022    (set_attr "prefix" "evex")
9023    (set_attr "mode" "TI")])
9025 (define_insn "avx512vl_<code><mode>v4qi2_mask_store"
9026   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9027     (vec_concat:V16QI
9028       (vec_merge:V4QI
9029         (any_truncate:V4QI
9030           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9031         (vec_select:V4QI
9032           (match_dup 0)
9033           (parallel [(const_int 0) (const_int 1)
9034                      (const_int 2) (const_int 3)]))
9035         (match_operand:QI 2 "register_operand" "Yk"))
9036       (vec_select:V12QI
9037         (match_dup 0)
9038         (parallel [(const_int 4) (const_int 5)
9039                    (const_int 6) (const_int 7)
9040                    (const_int 8) (const_int 9)
9041                    (const_int 10) (const_int 11)
9042                    (const_int 12) (const_int 13)
9043                    (const_int 14) (const_int 15)]))))]
9044   "TARGET_AVX512VL"
9046   if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 8)
9047     return "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%k0%{%2%}, %1}";
9048   return "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%0%{%2%}, %g1}";
9050   [(set_attr "type" "ssemov")
9051    (set_attr "memory" "store")
9052    (set_attr "prefix" "evex")
9053    (set_attr "mode" "TI")])
9055 (define_mode_iterator VI2_128_BW_4_256
9056   [(V8HI "TARGET_AVX512BW") V8SI])
9058 (define_insn "*avx512vl_<code><mode>v8qi2_store"
9059   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9060     (vec_concat:V16QI
9061       (any_truncate:V8QI
9062               (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9063       (vec_select:V8QI
9064         (match_dup 0)
9065         (parallel [(const_int 8) (const_int 9)
9066                    (const_int 10) (const_int 11)
9067                    (const_int 12) (const_int 13)
9068                    (const_int 14) (const_int 15)]))))]
9069   "TARGET_AVX512VL"
9070   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0|%0, %1}"
9071   [(set_attr "type" "ssemov")
9072    (set_attr "memory" "store")
9073    (set_attr "prefix" "evex")
9074    (set_attr "mode" "TI")])
9076 (define_insn "avx512vl_<code><mode>v8qi2_mask"
9077   [(set (match_operand:V16QI 0 "register_operand" "=v")
9078     (vec_concat:V16QI
9079       (vec_merge:V8QI
9080         (any_truncate:V8QI
9081           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9082         (vec_select:V8QI
9083           (match_operand:V16QI 2 "vector_move_operand" "0C")
9084           (parallel [(const_int 0) (const_int 1)
9085                      (const_int 2) (const_int 3)
9086                      (const_int 4) (const_int 5)
9087                      (const_int 6) (const_int 7)]))
9088         (match_operand:QI 3 "register_operand" "Yk"))
9089       (const_vector:V8QI [(const_int 0) (const_int 0)
9090                           (const_int 0) (const_int 0)
9091                           (const_int 0) (const_int 0)
9092                           (const_int 0) (const_int 0)])))]
9093   "TARGET_AVX512VL"
9094   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9095   [(set_attr "type" "ssemov")
9096    (set_attr "prefix" "evex")
9097    (set_attr "mode" "TI")])
9099 (define_insn "*avx512vl_<code><mode>v8qi2_mask_1"
9100   [(set (match_operand:V16QI 0 "register_operand" "=v")
9101     (vec_concat:V16QI
9102       (vec_merge:V8QI
9103         (any_truncate:V8QI
9104           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9105         (const_vector:V8QI [(const_int 0) (const_int 0)
9106                             (const_int 0) (const_int 0)
9107                             (const_int 0) (const_int 0)
9108                             (const_int 0) (const_int 0)])
9109         (match_operand:QI 2 "register_operand" "Yk"))
9110       (const_vector:V8QI [(const_int 0) (const_int 0)
9111                           (const_int 0) (const_int 0)
9112                           (const_int 0) (const_int 0)
9113                           (const_int 0) (const_int 0)])))]
9114   "TARGET_AVX512VL"
9115   "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9116   [(set_attr "type" "ssemov")
9117    (set_attr "prefix" "evex")
9118    (set_attr "mode" "TI")])
9120 (define_insn "avx512vl_<code><mode>v8qi2_mask_store"
9121   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9122     (vec_concat:V16QI
9123       (vec_merge:V8QI
9124         (any_truncate:V8QI
9125           (match_operand:VI2_128_BW_4_256 1 "register_operand" "v"))
9126         (vec_select:V8QI
9127           (match_dup 0)
9128           (parallel [(const_int 0) (const_int 1)
9129                      (const_int 2) (const_int 3)
9130                      (const_int 4) (const_int 5)
9131                      (const_int 6) (const_int 7)]))
9132         (match_operand:QI 2 "register_operand" "Yk"))
9133       (vec_select:V8QI
9134         (match_dup 0)
9135         (parallel [(const_int 8) (const_int 9)
9136                    (const_int 10) (const_int 11)
9137                    (const_int 12) (const_int 13)
9138                    (const_int 14) (const_int 15)]))))]
9139   "TARGET_AVX512VL"
9141   if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 4)
9142     return "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%0%{%2%}, %g1}";
9143   return "vpmov<trunsuffix><pmov_suff_3>\t{%1, %0%{%2%}|%0%{%2%}, %1}";
9145   [(set_attr "type" "ssemov")
9146    (set_attr "memory" "store")
9147    (set_attr "prefix" "evex")
9148    (set_attr "mode" "TI")])
9150 (define_mode_iterator PMOV_SRC_MODE_4 [V4DI V2DI V4SI])
9151 (define_mode_attr pmov_dst_4
9152   [(V4DI "V4HI") (V2DI "V2HI") (V4SI "V4HI")])
9153 (define_mode_attr pmov_dst_zeroed_4
9154   [(V4DI "V4HI") (V2DI "V6HI") (V4SI "V4HI")])
9155 (define_mode_attr pmov_suff_4
9156   [(V4DI "qw") (V2DI "qw") (V4SI "dw")])
9158 (define_insn "*avx512vl_<code><mode>v<ssescalarnum>hi2"
9159   [(set (match_operand:V8HI 0 "register_operand" "=v")
9160     (vec_concat:V8HI
9161       (any_truncate:<pmov_dst_4>
9162               (match_operand:PMOV_SRC_MODE_4 1 "register_operand" "v"))
9163       (match_operand:<pmov_dst_zeroed_4> 2 "const0_operand")))]
9164   "TARGET_AVX512VL"
9165   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0|%0, %1}"
9166   [(set_attr "type" "ssemov")
9167    (set_attr "prefix" "evex")
9168    (set_attr "mode" "TI")])
9170 (define_insn "*avx512vl_<code><mode>v4hi2_store"
9171   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9172     (vec_concat:V8HI
9173       (any_truncate:V4HI
9174               (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9175       (vec_select:V4HI
9176         (match_dup 0)
9177         (parallel [(const_int 4) (const_int 5)
9178                    (const_int 6) (const_int 7)]))))]
9179   "TARGET_AVX512VL"
9180   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0|%0, %1}"
9181   [(set_attr "type" "ssemov")
9182    (set_attr "memory" "store")
9183    (set_attr "prefix" "evex")
9184    (set_attr "mode" "TI")])
9186 (define_insn "avx512vl_<code><mode>v4hi2_mask"
9187   [(set (match_operand:V8HI 0 "register_operand" "=v")
9188     (vec_concat:V8HI
9189       (vec_merge:V4HI
9190         (any_truncate:V4HI
9191           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9192         (vec_select:V4HI
9193           (match_operand:V8HI 2 "vector_move_operand" "0C")
9194           (parallel [(const_int 0) (const_int 1)
9195                      (const_int 2) (const_int 3)]))
9196         (match_operand:QI 3 "register_operand" "Yk"))
9197       (const_vector:V4HI [(const_int 0) (const_int 0)
9198                           (const_int 0) (const_int 0)])))]
9199   "TARGET_AVX512VL"
9200   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9201   [(set_attr "type" "ssemov")
9202    (set_attr "prefix" "evex")
9203    (set_attr "mode" "TI")])
9205 (define_insn "*avx512vl_<code><mode>v4hi2_mask_1"
9206   [(set (match_operand:V8HI 0 "register_operand" "=v")
9207     (vec_concat:V8HI
9208       (vec_merge:V4HI
9209         (any_truncate:V4HI
9210           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9211         (const_vector:V4HI [(const_int 0) (const_int 0)
9212                             (const_int 0) (const_int 0)])
9213         (match_operand:QI 2 "register_operand" "Yk"))
9214       (const_vector:V4HI [(const_int 0) (const_int 0)
9215                           (const_int 0) (const_int 0)])))]
9216   "TARGET_AVX512VL"
9217   "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9218   [(set_attr "type" "ssemov")
9219    (set_attr "prefix" "evex")
9220    (set_attr "mode" "TI")])
9222 (define_insn "avx512vl_<code><mode>v4hi2_mask_store"
9223   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9224     (vec_concat:V8HI
9225       (vec_merge:V4HI
9226         (any_truncate:V4HI
9227           (match_operand:VI4_128_8_256 1 "register_operand" "v"))
9228         (vec_select:V4HI
9229           (match_dup 0)
9230           (parallel [(const_int 0) (const_int 1)
9231                      (const_int 2) (const_int 3)]))
9232         (match_operand:QI 2 "register_operand" "Yk"))
9233       (vec_select:V4HI
9234         (match_dup 0)
9235         (parallel [(const_int 4) (const_int 5)
9236                    (const_int 6) (const_int 7)]))))]
9237   "TARGET_AVX512VL"
9239   if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 4)
9240     return "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}|%0%{%2%}, %t1}";
9241   return "vpmov<trunsuffix><pmov_suff_4>\t{%1, %0%{%2%}|%0%{%2%}, %g1}";
9243   [(set_attr "type" "ssemov")
9244    (set_attr "memory" "store")
9245    (set_attr "prefix" "evex")
9246    (set_attr "mode" "TI")])
9248 (define_insn "*avx512vl_<code>v2div2hi2_store"
9249   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9250     (vec_concat:V8HI
9251       (any_truncate:V2HI
9252               (match_operand:V2DI 1 "register_operand" "v"))
9253       (vec_select:V6HI
9254         (match_dup 0)
9255         (parallel [(const_int 2) (const_int 3)
9256                    (const_int 4) (const_int 5)
9257                    (const_int 6) (const_int 7)]))))]
9258   "TARGET_AVX512VL"
9259   "vpmov<trunsuffix>qw\t{%1, %0|%0, %1}"
9260   [(set_attr "type" "ssemov")
9261    (set_attr "memory" "store")
9262    (set_attr "prefix" "evex")
9263    (set_attr "mode" "TI")])
9265 (define_insn "avx512vl_<code>v2div2hi2_mask"
9266   [(set (match_operand:V8HI 0 "register_operand" "=v")
9267     (vec_concat:V8HI
9268       (vec_merge:V2HI
9269         (any_truncate:V2HI
9270           (match_operand:V2DI 1 "register_operand" "v"))
9271         (vec_select:V2HI
9272           (match_operand:V8HI 2 "vector_move_operand" "0C")
9273           (parallel [(const_int 0) (const_int 1)]))
9274         (match_operand:QI 3 "register_operand" "Yk"))
9275       (const_vector:V6HI [(const_int 0) (const_int 0)
9276                           (const_int 0) (const_int 0)
9277                           (const_int 0) (const_int 0)])))]
9278   "TARGET_AVX512VL"
9279   "vpmov<trunsuffix>qw\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9280   [(set_attr "type" "ssemov")
9281    (set_attr "prefix" "evex")
9282    (set_attr "mode" "TI")])
9284 (define_insn "*avx512vl_<code>v2div2hi2_mask_1"
9285   [(set (match_operand:V8HI 0 "register_operand" "=v")
9286     (vec_concat:V8HI
9287       (vec_merge:V2HI
9288         (any_truncate:V2HI
9289           (match_operand:V2DI 1 "register_operand" "v"))
9290         (const_vector:V2HI [(const_int 0) (const_int 0)])
9291         (match_operand:QI 2 "register_operand" "Yk"))
9292       (const_vector:V6HI [(const_int 0) (const_int 0)
9293                           (const_int 0) (const_int 0)
9294                           (const_int 0) (const_int 0)])))]
9295   "TARGET_AVX512VL"
9296   "vpmov<trunsuffix>qw\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9297   [(set_attr "type" "ssemov")
9298    (set_attr "prefix" "evex")
9299    (set_attr "mode" "TI")])
9301 (define_insn "avx512vl_<code>v2div2hi2_mask_store"
9302   [(set (match_operand:V8HI 0 "memory_operand" "=m")
9303     (vec_concat:V8HI
9304       (vec_merge:V2HI
9305         (any_truncate:V2HI
9306           (match_operand:V2DI 1 "register_operand" "v"))
9307         (vec_select:V2HI
9308           (match_dup 0)
9309           (parallel [(const_int 0) (const_int 1)]))
9310         (match_operand:QI 2 "register_operand" "Yk"))
9311       (vec_select:V6HI
9312         (match_dup 0)
9313         (parallel [(const_int 2) (const_int 3)
9314                    (const_int 4) (const_int 5)
9315                    (const_int 6) (const_int 7)]))))]
9316   "TARGET_AVX512VL"
9317   "vpmov<trunsuffix>qw\t{%1, %0%{%2%}|%0%{%2%}, %g1}"
9318   [(set_attr "type" "ssemov")
9319    (set_attr "memory" "store")
9320    (set_attr "prefix" "evex")
9321    (set_attr "mode" "TI")])
9323 (define_insn "*avx512vl_<code>v2div2si2"
9324   [(set (match_operand:V4SI 0 "register_operand" "=v")
9325     (vec_concat:V4SI
9326       (any_truncate:V2SI
9327               (match_operand:V2DI 1 "register_operand" "v"))
9328       (match_operand:V2SI 2 "const0_operand")))]
9329   "TARGET_AVX512VL"
9330   "vpmov<trunsuffix>qd\t{%1, %0|%0, %1}"
9331   [(set_attr "type" "ssemov")
9332    (set_attr "prefix" "evex")
9333    (set_attr "mode" "TI")])
9335 (define_insn "*avx512vl_<code>v2div2si2_store"
9336   [(set (match_operand:V4SI 0 "memory_operand" "=m")
9337     (vec_concat:V4SI
9338       (any_truncate:V2SI
9339               (match_operand:V2DI 1 "register_operand" "v"))
9340       (vec_select:V2SI
9341         (match_dup 0)
9342         (parallel [(const_int 2) (const_int 3)]))))]
9343   "TARGET_AVX512VL"
9344   "vpmov<trunsuffix>qd\t{%1, %0|%0, %1}"
9345   [(set_attr "type" "ssemov")
9346    (set_attr "memory" "store")
9347    (set_attr "prefix" "evex")
9348    (set_attr "mode" "TI")])
9350 (define_insn "avx512vl_<code>v2div2si2_mask"
9351   [(set (match_operand:V4SI 0 "register_operand" "=v")
9352     (vec_concat:V4SI
9353       (vec_merge:V2SI
9354         (any_truncate:V2SI
9355           (match_operand:V2DI 1 "register_operand" "v"))
9356         (vec_select:V2SI
9357           (match_operand:V4SI 2 "vector_move_operand" "0C")
9358           (parallel [(const_int 0) (const_int 1)]))
9359         (match_operand:QI 3 "register_operand" "Yk"))
9360       (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9361   "TARGET_AVX512VL"
9362   "vpmov<trunsuffix>qd\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9363   [(set_attr "type" "ssemov")
9364    (set_attr "prefix" "evex")
9365    (set_attr "mode" "TI")])
9367 (define_insn "*avx512vl_<code>v2div2si2_mask_1"
9368   [(set (match_operand:V4SI 0 "register_operand" "=v")
9369     (vec_concat:V4SI
9370       (vec_merge:V2SI
9371         (any_truncate:V2SI
9372           (match_operand:V2DI 1 "register_operand" "v"))
9373         (const_vector:V2SI [(const_int 0) (const_int 0)])
9374         (match_operand:QI 2 "register_operand" "Yk"))
9375       (const_vector:V2SI [(const_int 0) (const_int 0)])))]
9376   "TARGET_AVX512VL"
9377   "vpmov<trunsuffix>qd\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9378   [(set_attr "type" "ssemov")
9379    (set_attr "prefix" "evex")
9380    (set_attr "mode" "TI")])
9382 (define_insn "avx512vl_<code>v2div2si2_mask_store"
9383   [(set (match_operand:V4SI 0 "memory_operand" "=m")
9384     (vec_concat:V4SI
9385       (vec_merge:V2SI
9386         (any_truncate:V2SI
9387           (match_operand:V2DI 1 "register_operand" "v"))
9388         (vec_select:V2SI
9389           (match_dup 0)
9390           (parallel [(const_int 0) (const_int 1)]))
9391         (match_operand:QI 2 "register_operand" "Yk"))
9392       (vec_select:V2SI
9393         (match_dup 0)
9394         (parallel [(const_int 2) (const_int 3)]))))]
9395   "TARGET_AVX512VL"
9396   "vpmov<trunsuffix>qd\t{%1, %0%{%2%}|%0%{%2%}, %t1}"
9397   [(set_attr "type" "ssemov")
9398    (set_attr "memory" "store")
9399    (set_attr "prefix" "evex")
9400    (set_attr "mode" "TI")])
9402 (define_insn "*avx512f_<code>v8div16qi2"
9403   [(set (match_operand:V16QI 0 "register_operand" "=v")
9404         (vec_concat:V16QI
9405           (any_truncate:V8QI
9406             (match_operand:V8DI 1 "register_operand" "v"))
9407           (const_vector:V8QI [(const_int 0) (const_int 0)
9408                               (const_int 0) (const_int 0)
9409                               (const_int 0) (const_int 0)
9410                               (const_int 0) (const_int 0)])))]
9411   "TARGET_AVX512F"
9412   "vpmov<trunsuffix>qb\t{%1, %0|%0, %1}"
9413   [(set_attr "type" "ssemov")
9414    (set_attr "prefix" "evex")
9415    (set_attr "mode" "TI")])
9417 (define_insn "*avx512f_<code>v8div16qi2_store"
9418   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9419         (vec_concat:V16QI
9420           (any_truncate:V8QI
9421             (match_operand:V8DI 1 "register_operand" "v"))
9422           (vec_select:V8QI
9423             (match_dup 0)
9424             (parallel [(const_int 8) (const_int 9)
9425                        (const_int 10) (const_int 11)
9426                        (const_int 12) (const_int 13)
9427                        (const_int 14) (const_int 15)]))))]
9428   "TARGET_AVX512F"
9429   "vpmov<trunsuffix>qb\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 "avx512f_<code>v8div16qi2_mask"
9436   [(set (match_operand:V16QI 0 "register_operand" "=v")
9437     (vec_concat:V16QI
9438       (vec_merge:V8QI
9439         (any_truncate:V8QI
9440           (match_operand:V8DI 1 "register_operand" "v"))
9441         (vec_select:V8QI
9442           (match_operand:V16QI 2 "vector_move_operand" "0C")
9443           (parallel [(const_int 0) (const_int 1)
9444                      (const_int 2) (const_int 3)
9445                      (const_int 4) (const_int 5)
9446                      (const_int 6) (const_int 7)]))
9447         (match_operand:QI 3 "register_operand" "Yk"))
9448       (const_vector:V8QI [(const_int 0) (const_int 0)
9449                           (const_int 0) (const_int 0)
9450                           (const_int 0) (const_int 0)
9451                           (const_int 0) (const_int 0)])))]
9452   "TARGET_AVX512F"
9453   "vpmov<trunsuffix>qb\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
9454   [(set_attr "type" "ssemov")
9455    (set_attr "prefix" "evex")
9456    (set_attr "mode" "TI")])
9458 (define_insn "*avx512f_<code>v8div16qi2_mask_1"
9459   [(set (match_operand:V16QI 0 "register_operand" "=v")
9460     (vec_concat:V16QI
9461       (vec_merge:V8QI
9462         (any_truncate:V8QI
9463           (match_operand:V8DI 1 "register_operand" "v"))
9464         (const_vector:V8QI [(const_int 0) (const_int 0)
9465                             (const_int 0) (const_int 0)
9466                             (const_int 0) (const_int 0)
9467                             (const_int 0) (const_int 0)])
9468         (match_operand:QI 2 "register_operand" "Yk"))
9469       (const_vector:V8QI [(const_int 0) (const_int 0)
9470                           (const_int 0) (const_int 0)
9471                           (const_int 0) (const_int 0)
9472                           (const_int 0) (const_int 0)])))]
9473   "TARGET_AVX512F"
9474   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}%{z%}|%0%{%2%}%{z%}, %1}"
9475   [(set_attr "type" "ssemov")
9476    (set_attr "prefix" "evex")
9477    (set_attr "mode" "TI")])
9479 (define_insn "avx512f_<code>v8div16qi2_mask_store"
9480   [(set (match_operand:V16QI 0 "memory_operand" "=m")
9481     (vec_concat:V16QI
9482       (vec_merge:V8QI
9483         (any_truncate:V8QI
9484           (match_operand:V8DI 1 "register_operand" "v"))
9485         (vec_select:V8QI
9486           (match_dup 0)
9487           (parallel [(const_int 0) (const_int 1)
9488                      (const_int 2) (const_int 3)
9489                      (const_int 4) (const_int 5)
9490                      (const_int 6) (const_int 7)]))
9491         (match_operand:QI 2 "register_operand" "Yk"))
9492       (vec_select:V8QI
9493         (match_dup 0)
9494         (parallel [(const_int 8) (const_int 9)
9495                    (const_int 10) (const_int 11)
9496                    (const_int 12) (const_int 13)
9497                    (const_int 14) (const_int 15)]))))]
9498   "TARGET_AVX512F"
9499   "vpmov<trunsuffix>qb\t{%1, %0%{%2%}|%q0%{%2%}, %1}"
9500   [(set_attr "type" "ssemov")
9501    (set_attr "memory" "store")
9502    (set_attr "prefix" "evex")
9503    (set_attr "mode" "TI")])
9505 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9507 ;; Parallel integral arithmetic
9509 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9511 (define_expand "neg<mode>2"
9512   [(set (match_operand:VI_AVX2 0 "register_operand")
9513         (minus:VI_AVX2
9514           (match_dup 2)
9515           (match_operand:VI_AVX2 1 "vector_operand")))]
9516   "TARGET_SSE2"
9517   "operands[2] = force_reg (<MODE>mode, CONST0_RTX (<MODE>mode));")
9519 (define_expand "<plusminus_insn><mode>3"
9520   [(set (match_operand:VI_AVX2 0 "register_operand")
9521         (plusminus:VI_AVX2
9522           (match_operand:VI_AVX2 1 "vector_operand")
9523           (match_operand:VI_AVX2 2 "vector_operand")))]
9524   "TARGET_SSE2"
9525   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
9527 (define_expand "<plusminus_insn><mode>3_mask"
9528   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
9529         (vec_merge:VI48_AVX512VL
9530           (plusminus:VI48_AVX512VL
9531             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
9532             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
9533           (match_operand:VI48_AVX512VL 3 "vector_move_operand")
9534           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
9535   "TARGET_AVX512F"
9536   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
9538 (define_expand "<plusminus_insn><mode>3_mask"
9539   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
9540         (vec_merge:VI12_AVX512VL
9541           (plusminus:VI12_AVX512VL
9542             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand")
9543             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand"))
9544           (match_operand:VI12_AVX512VL 3 "vector_move_operand")
9545           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
9546   "TARGET_AVX512BW"
9547   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
9549 (define_insn "*<plusminus_insn><mode>3"
9550   [(set (match_operand:VI_AVX2 0 "register_operand" "=x,v")
9551         (plusminus:VI_AVX2
9552           (match_operand:VI_AVX2 1 "vector_operand" "<comm>0,v")
9553           (match_operand:VI_AVX2 2 "vector_operand" "xBm,vm")))]
9554   "TARGET_SSE2
9555    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
9556   "@
9557    p<plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
9558    vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9559   [(set_attr "isa" "noavx,avx")
9560    (set_attr "type" "sseiadd")
9561    (set_attr "prefix_data16" "1,*")
9562    (set_attr "prefix" "<mask_prefix3>")
9563    (set_attr "mode" "<sseinsnmode>")])
9565 (define_insn "*<plusminus_insn><mode>3_mask"
9566   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
9567         (vec_merge:VI48_AVX512VL
9568           (plusminus:VI48_AVX512VL
9569             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "<comm>v")
9570             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm"))
9571           (match_operand:VI48_AVX512VL 3 "vector_move_operand" "0C")
9572           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
9573   "TARGET_AVX512F
9574    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
9575   "vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
9576   [(set_attr "type" "sseiadd")
9577    (set_attr "prefix" "evex")
9578    (set_attr "mode" "<sseinsnmode>")])
9580 (define_insn "*<plusminus_insn><mode>3_mask"
9581   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
9582         (vec_merge:VI12_AVX512VL
9583           (plusminus:VI12_AVX512VL
9584             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "<comm>v")
9585             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm"))
9586           (match_operand:VI12_AVX512VL 3 "vector_move_operand" "0C")
9587           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
9588   "TARGET_AVX512BW && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
9589   "vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
9590   [(set_attr "type" "sseiadd")
9591    (set_attr "prefix" "evex")
9592    (set_attr "mode" "<sseinsnmode>")])
9594 (define_expand "<sse2_avx2>_<plusminus_insn><mode>3<mask_name>"
9595   [(set (match_operand:VI12_AVX2 0 "register_operand")
9596         (sat_plusminus:VI12_AVX2
9597           (match_operand:VI12_AVX2 1 "vector_operand")
9598           (match_operand:VI12_AVX2 2 "vector_operand")))]
9599   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
9600   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
9602 (define_insn "*<sse2_avx2>_<plusminus_insn><mode>3<mask_name>"
9603   [(set (match_operand:VI12_AVX2 0 "register_operand" "=x,v")
9604         (sat_plusminus:VI12_AVX2
9605           (match_operand:VI12_AVX2 1 "vector_operand" "<comm>0,v")
9606           (match_operand:VI12_AVX2 2 "vector_operand" "xBm,vm")))]
9607   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
9608    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
9609   "@
9610    p<plusminus_mnemonic><ssemodesuffix>\t{%2, %0|%0, %2}
9611    vp<plusminus_mnemonic><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9612   [(set_attr "isa" "noavx,avx")
9613    (set_attr "type" "sseiadd")
9614    (set_attr "prefix_data16" "1,*")
9615    (set_attr "prefix" "orig,maybe_evex")
9616    (set_attr "mode" "TI")])
9618 (define_expand "mul<mode>3<mask_name>"
9619   [(set (match_operand:VI1_AVX512 0 "register_operand")
9620         (mult:VI1_AVX512 (match_operand:VI1_AVX512 1 "register_operand")
9621                        (match_operand:VI1_AVX512 2 "register_operand")))]
9622   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
9624   ix86_expand_vecop_qihi (MULT, operands[0], operands[1], operands[2]);
9625   DONE;
9628 (define_expand "mul<mode>3<mask_name>"
9629   [(set (match_operand:VI2_AVX2 0 "register_operand")
9630         (mult:VI2_AVX2 (match_operand:VI2_AVX2 1 "vector_operand")
9631                        (match_operand:VI2_AVX2 2 "vector_operand")))]
9632   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
9633   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
9635 (define_insn "*mul<mode>3<mask_name>"
9636   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,v")
9637         (mult:VI2_AVX2 (match_operand:VI2_AVX2 1 "vector_operand" "%0,v")
9638                        (match_operand:VI2_AVX2 2 "vector_operand" "xBm,vm")))]
9639   "TARGET_SSE2
9640    && ix86_binary_operator_ok (MULT, <MODE>mode, operands)
9641    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
9642   "@
9643    pmullw\t{%2, %0|%0, %2}
9644    vpmullw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9645   [(set_attr "isa" "noavx,avx")
9646    (set_attr "type" "sseimul")
9647    (set_attr "prefix_data16" "1,*")
9648    (set_attr "prefix" "orig,vex")
9649    (set_attr "mode" "<sseinsnmode>")])
9651 (define_expand "<s>mul<mode>3_highpart<mask_name>"
9652   [(set (match_operand:VI2_AVX2 0 "register_operand")
9653         (truncate:VI2_AVX2
9654           (lshiftrt:<ssedoublemode>
9655             (mult:<ssedoublemode>
9656               (any_extend:<ssedoublemode>
9657                 (match_operand:VI2_AVX2 1 "vector_operand"))
9658               (any_extend:<ssedoublemode>
9659                 (match_operand:VI2_AVX2 2 "vector_operand")))
9660             (const_int 16))))]
9661   "TARGET_SSE2
9662    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
9663   "ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);")
9665 (define_insn "*<s>mul<mode>3_highpart<mask_name>"
9666   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,v")
9667         (truncate:VI2_AVX2
9668           (lshiftrt:<ssedoublemode>
9669             (mult:<ssedoublemode>
9670               (any_extend:<ssedoublemode>
9671                 (match_operand:VI2_AVX2 1 "vector_operand" "%0,v"))
9672               (any_extend:<ssedoublemode>
9673                 (match_operand:VI2_AVX2 2 "vector_operand" "xBm,vm")))
9674             (const_int 16))))]
9675   "TARGET_SSE2
9676    && ix86_binary_operator_ok (MULT, <MODE>mode, operands)
9677    && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
9678   "@
9679    pmulh<u>w\t{%2, %0|%0, %2}
9680    vpmulh<u>w\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9681   [(set_attr "isa" "noavx,avx")
9682    (set_attr "type" "sseimul")
9683    (set_attr "prefix_data16" "1,*")
9684    (set_attr "prefix" "orig,vex")
9685    (set_attr "mode" "<sseinsnmode>")])
9687 (define_expand "vec_widen_umult_even_v16si<mask_name>"
9688   [(set (match_operand:V8DI 0 "register_operand")
9689         (mult:V8DI
9690           (zero_extend:V8DI
9691             (vec_select:V8SI
9692               (match_operand:V16SI 1 "nonimmediate_operand")
9693               (parallel [(const_int 0) (const_int 2)
9694                          (const_int 4) (const_int 6)
9695                          (const_int 8) (const_int 10)
9696                          (const_int 12) (const_int 14)])))
9697           (zero_extend:V8DI
9698             (vec_select:V8SI
9699               (match_operand:V16SI 2 "nonimmediate_operand")
9700               (parallel [(const_int 0) (const_int 2)
9701                          (const_int 4) (const_int 6)
9702                          (const_int 8) (const_int 10)
9703                          (const_int 12) (const_int 14)])))))]
9704   "TARGET_AVX512F"
9705   "ix86_fixup_binary_operands_no_copy (MULT, V16SImode, operands);")
9707 (define_insn "*vec_widen_umult_even_v16si<mask_name>"
9708   [(set (match_operand:V8DI 0 "register_operand" "=v")
9709         (mult:V8DI
9710           (zero_extend:V8DI
9711             (vec_select:V8SI
9712               (match_operand:V16SI 1 "nonimmediate_operand" "%v")
9713               (parallel [(const_int 0) (const_int 2)
9714                          (const_int 4) (const_int 6)
9715                          (const_int 8) (const_int 10)
9716                          (const_int 12) (const_int 14)])))
9717           (zero_extend:V8DI
9718             (vec_select:V8SI
9719               (match_operand:V16SI 2 "nonimmediate_operand" "vm")
9720               (parallel [(const_int 0) (const_int 2)
9721                          (const_int 4) (const_int 6)
9722                          (const_int 8) (const_int 10)
9723                          (const_int 12) (const_int 14)])))))]
9724   "TARGET_AVX512F && ix86_binary_operator_ok (MULT, V16SImode, operands)"
9725   "vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9726   [(set_attr "isa" "avx512f")
9727    (set_attr "type" "sseimul")
9728    (set_attr "prefix_extra" "1")
9729    (set_attr "prefix" "evex")
9730    (set_attr "mode" "XI")])
9732 (define_expand "vec_widen_umult_even_v8si<mask_name>"
9733   [(set (match_operand:V4DI 0 "register_operand")
9734         (mult:V4DI
9735           (zero_extend:V4DI
9736             (vec_select:V4SI
9737               (match_operand:V8SI 1 "nonimmediate_operand")
9738               (parallel [(const_int 0) (const_int 2)
9739                          (const_int 4) (const_int 6)])))
9740           (zero_extend:V4DI
9741             (vec_select:V4SI
9742               (match_operand:V8SI 2 "nonimmediate_operand")
9743               (parallel [(const_int 0) (const_int 2)
9744                          (const_int 4) (const_int 6)])))))]
9745   "TARGET_AVX2 && <mask_avx512vl_condition>"
9746   "ix86_fixup_binary_operands_no_copy (MULT, V8SImode, operands);")
9748 (define_insn "*vec_widen_umult_even_v8si<mask_name>"
9749   [(set (match_operand:V4DI 0 "register_operand" "=v")
9750         (mult:V4DI
9751           (zero_extend:V4DI
9752             (vec_select:V4SI
9753               (match_operand:V8SI 1 "nonimmediate_operand" "%v")
9754               (parallel [(const_int 0) (const_int 2)
9755                          (const_int 4) (const_int 6)])))
9756           (zero_extend:V4DI
9757             (vec_select:V4SI
9758               (match_operand:V8SI 2 "nonimmediate_operand" "vm")
9759               (parallel [(const_int 0) (const_int 2)
9760                          (const_int 4) (const_int 6)])))))]
9761   "TARGET_AVX2 && <mask_avx512vl_condition>
9762    && ix86_binary_operator_ok (MULT, V8SImode, operands)"
9763   "vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9764   [(set_attr "type" "sseimul")
9765    (set_attr "prefix" "maybe_evex")
9766    (set_attr "mode" "OI")])
9768 (define_expand "vec_widen_umult_even_v4si<mask_name>"
9769   [(set (match_operand:V2DI 0 "register_operand")
9770         (mult:V2DI
9771           (zero_extend:V2DI
9772             (vec_select:V2SI
9773               (match_operand:V4SI 1 "vector_operand")
9774               (parallel [(const_int 0) (const_int 2)])))
9775           (zero_extend:V2DI
9776             (vec_select:V2SI
9777               (match_operand:V4SI 2 "vector_operand")
9778               (parallel [(const_int 0) (const_int 2)])))))]
9779   "TARGET_SSE2 && <mask_avx512vl_condition>"
9780   "ix86_fixup_binary_operands_no_copy (MULT, V4SImode, operands);")
9782 (define_insn "*vec_widen_umult_even_v4si<mask_name>"
9783   [(set (match_operand:V2DI 0 "register_operand" "=x,v")
9784         (mult:V2DI
9785           (zero_extend:V2DI
9786             (vec_select:V2SI
9787               (match_operand:V4SI 1 "vector_operand" "%0,v")
9788               (parallel [(const_int 0) (const_int 2)])))
9789           (zero_extend:V2DI
9790             (vec_select:V2SI
9791               (match_operand:V4SI 2 "vector_operand" "xBm,vm")
9792               (parallel [(const_int 0) (const_int 2)])))))]
9793   "TARGET_SSE2 && <mask_avx512vl_condition>
9794    && ix86_binary_operator_ok (MULT, V4SImode, operands)"
9795   "@
9796    pmuludq\t{%2, %0|%0, %2}
9797    vpmuludq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9798   [(set_attr "isa" "noavx,avx")
9799    (set_attr "type" "sseimul")
9800    (set_attr "prefix_data16" "1,*")
9801    (set_attr "prefix" "orig,maybe_evex")
9802    (set_attr "mode" "TI")])
9804 (define_expand "vec_widen_smult_even_v16si<mask_name>"
9805   [(set (match_operand:V8DI 0 "register_operand")
9806         (mult:V8DI
9807           (sign_extend:V8DI
9808             (vec_select:V8SI
9809               (match_operand:V16SI 1 "nonimmediate_operand")
9810               (parallel [(const_int 0) (const_int 2)
9811                          (const_int 4) (const_int 6)
9812                          (const_int 8) (const_int 10)
9813                          (const_int 12) (const_int 14)])))
9814           (sign_extend:V8DI
9815             (vec_select:V8SI
9816               (match_operand:V16SI 2 "nonimmediate_operand")
9817               (parallel [(const_int 0) (const_int 2)
9818                          (const_int 4) (const_int 6)
9819                          (const_int 8) (const_int 10)
9820                          (const_int 12) (const_int 14)])))))]
9821   "TARGET_AVX512F"
9822   "ix86_fixup_binary_operands_no_copy (MULT, V16SImode, operands);")
9824 (define_insn "*vec_widen_smult_even_v16si<mask_name>"
9825   [(set (match_operand:V8DI 0 "register_operand" "=v")
9826         (mult:V8DI
9827           (sign_extend:V8DI
9828             (vec_select:V8SI
9829               (match_operand:V16SI 1 "nonimmediate_operand" "%v")
9830               (parallel [(const_int 0) (const_int 2)
9831                          (const_int 4) (const_int 6)
9832                          (const_int 8) (const_int 10)
9833                          (const_int 12) (const_int 14)])))
9834           (sign_extend:V8DI
9835             (vec_select:V8SI
9836               (match_operand:V16SI 2 "nonimmediate_operand" "vm")
9837               (parallel [(const_int 0) (const_int 2)
9838                          (const_int 4) (const_int 6)
9839                          (const_int 8) (const_int 10)
9840                          (const_int 12) (const_int 14)])))))]
9841   "TARGET_AVX512F && ix86_binary_operator_ok (MULT, V16SImode, operands)"
9842   "vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9843   [(set_attr "isa" "avx512f")
9844    (set_attr "type" "sseimul")
9845    (set_attr "prefix_extra" "1")
9846    (set_attr "prefix" "evex")
9847    (set_attr "mode" "XI")])
9849 (define_expand "vec_widen_smult_even_v8si<mask_name>"
9850   [(set (match_operand:V4DI 0 "register_operand")
9851         (mult:V4DI
9852           (sign_extend:V4DI
9853             (vec_select:V4SI
9854               (match_operand:V8SI 1 "nonimmediate_operand")
9855               (parallel [(const_int 0) (const_int 2)
9856                          (const_int 4) (const_int 6)])))
9857           (sign_extend:V4DI
9858             (vec_select:V4SI
9859               (match_operand:V8SI 2 "nonimmediate_operand")
9860               (parallel [(const_int 0) (const_int 2)
9861                          (const_int 4) (const_int 6)])))))]
9862   "TARGET_AVX2 && <mask_avx512vl_condition>"
9863   "ix86_fixup_binary_operands_no_copy (MULT, V8SImode, operands);")
9865 (define_insn "*vec_widen_smult_even_v8si<mask_name>"
9866   [(set (match_operand:V4DI 0 "register_operand" "=v")
9867         (mult:V4DI
9868           (sign_extend:V4DI
9869             (vec_select:V4SI
9870               (match_operand:V8SI 1 "nonimmediate_operand" "%v")
9871               (parallel [(const_int 0) (const_int 2)
9872                          (const_int 4) (const_int 6)])))
9873           (sign_extend:V4DI
9874             (vec_select:V4SI
9875               (match_operand:V8SI 2 "nonimmediate_operand" "vm")
9876               (parallel [(const_int 0) (const_int 2)
9877                          (const_int 4) (const_int 6)])))))]
9878   "TARGET_AVX2
9879    && ix86_binary_operator_ok (MULT, V8SImode, operands)"
9880   "vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9881   [(set_attr "type" "sseimul")
9882    (set_attr "prefix_extra" "1")
9883    (set_attr "prefix" "vex")
9884    (set_attr "mode" "OI")])
9886 (define_expand "sse4_1_mulv2siv2di3<mask_name>"
9887   [(set (match_operand:V2DI 0 "register_operand")
9888         (mult:V2DI
9889           (sign_extend:V2DI
9890             (vec_select:V2SI
9891               (match_operand:V4SI 1 "vector_operand")
9892               (parallel [(const_int 0) (const_int 2)])))
9893           (sign_extend:V2DI
9894             (vec_select:V2SI
9895               (match_operand:V4SI 2 "vector_operand")
9896               (parallel [(const_int 0) (const_int 2)])))))]
9897   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
9898   "ix86_fixup_binary_operands_no_copy (MULT, V4SImode, operands);")
9900 (define_insn "*sse4_1_mulv2siv2di3<mask_name>"
9901   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
9902         (mult:V2DI
9903           (sign_extend:V2DI
9904             (vec_select:V2SI
9905               (match_operand:V4SI 1 "vector_operand" "%0,0,v")
9906               (parallel [(const_int 0) (const_int 2)])))
9907           (sign_extend:V2DI
9908             (vec_select:V2SI
9909               (match_operand:V4SI 2 "vector_operand" "YrBm,*xBm,vm")
9910               (parallel [(const_int 0) (const_int 2)])))))]
9911   "TARGET_SSE4_1 && <mask_avx512vl_condition>
9912    && ix86_binary_operator_ok (MULT, V4SImode, operands)"
9913   "@
9914    pmuldq\t{%2, %0|%0, %2}
9915    pmuldq\t{%2, %0|%0, %2}
9916    vpmuldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
9917   [(set_attr "isa" "noavx,noavx,avx")
9918    (set_attr "type" "sseimul")
9919    (set_attr "prefix_data16" "1,1,*")
9920    (set_attr "prefix_extra" "1")
9921    (set_attr "prefix" "orig,orig,vex")
9922    (set_attr "mode" "TI")])
9924 (define_insn "avx512bw_pmaddwd512<mode><mask_name>"
9925   [(set (match_operand:<sseunpackmode> 0 "register_operand" "=v")
9926           (unspec:<sseunpackmode>
9927             [(match_operand:VI2_AVX2 1 "register_operand" "v")
9928              (match_operand:VI2_AVX2 2 "nonimmediate_operand" "vm")]
9929              UNSPEC_PMADDWD512))]
9930    "TARGET_AVX512BW && <mask_mode512bit_condition>"
9931    "vpmaddwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}";
9932   [(set_attr "type" "sseiadd")
9933    (set_attr "prefix" "evex")
9934    (set_attr "mode" "XI")])
9936 (define_expand "avx2_pmaddwd"
9937   [(set (match_operand:V8SI 0 "register_operand")
9938         (plus:V8SI
9939           (mult:V8SI
9940             (sign_extend:V8SI
9941               (vec_select:V8HI
9942                 (match_operand:V16HI 1 "nonimmediate_operand")
9943                 (parallel [(const_int 0) (const_int 2)
9944                            (const_int 4) (const_int 6)
9945                            (const_int 8) (const_int 10)
9946                            (const_int 12) (const_int 14)])))
9947             (sign_extend:V8SI
9948               (vec_select:V8HI
9949                 (match_operand:V16HI 2 "nonimmediate_operand")
9950                 (parallel [(const_int 0) (const_int 2)
9951                            (const_int 4) (const_int 6)
9952                            (const_int 8) (const_int 10)
9953                            (const_int 12) (const_int 14)]))))
9954           (mult:V8SI
9955             (sign_extend:V8SI
9956               (vec_select:V8HI (match_dup 1)
9957                 (parallel [(const_int 1) (const_int 3)
9958                            (const_int 5) (const_int 7)
9959                            (const_int 9) (const_int 11)
9960                            (const_int 13) (const_int 15)])))
9961             (sign_extend:V8SI
9962               (vec_select:V8HI (match_dup 2)
9963                 (parallel [(const_int 1) (const_int 3)
9964                            (const_int 5) (const_int 7)
9965                            (const_int 9) (const_int 11)
9966                            (const_int 13) (const_int 15)]))))))]
9967   "TARGET_AVX2"
9968   "ix86_fixup_binary_operands_no_copy (MULT, V16HImode, operands);")
9970 (define_insn "*avx2_pmaddwd"
9971   [(set (match_operand:V8SI 0 "register_operand" "=x,v")
9972         (plus:V8SI
9973           (mult:V8SI
9974             (sign_extend:V8SI
9975               (vec_select:V8HI
9976                 (match_operand:V16HI 1 "nonimmediate_operand" "%x,v")
9977                 (parallel [(const_int 0) (const_int 2)
9978                            (const_int 4) (const_int 6)
9979                            (const_int 8) (const_int 10)
9980                            (const_int 12) (const_int 14)])))
9981             (sign_extend:V8SI
9982               (vec_select:V8HI
9983                 (match_operand:V16HI 2 "nonimmediate_operand" "xm,vm")
9984                 (parallel [(const_int 0) (const_int 2)
9985                            (const_int 4) (const_int 6)
9986                            (const_int 8) (const_int 10)
9987                            (const_int 12) (const_int 14)]))))
9988           (mult:V8SI
9989             (sign_extend:V8SI
9990               (vec_select:V8HI (match_dup 1)
9991                 (parallel [(const_int 1) (const_int 3)
9992                            (const_int 5) (const_int 7)
9993                            (const_int 9) (const_int 11)
9994                            (const_int 13) (const_int 15)])))
9995             (sign_extend:V8SI
9996               (vec_select:V8HI (match_dup 2)
9997                 (parallel [(const_int 1) (const_int 3)
9998                            (const_int 5) (const_int 7)
9999                            (const_int 9) (const_int 11)
10000                            (const_int 13) (const_int 15)]))))))]
10001   "TARGET_AVX2 && ix86_binary_operator_ok (MULT, V16HImode, operands)"
10002   "vpmaddwd\t{%2, %1, %0|%0, %1, %2}"
10003   [(set_attr "type" "sseiadd")
10004    (set_attr "isa" "*,avx512bw")
10005    (set_attr "prefix" "vex,evex")
10006    (set_attr "mode" "OI")])
10008 (define_expand "sse2_pmaddwd"
10009   [(set (match_operand:V4SI 0 "register_operand")
10010         (plus:V4SI
10011           (mult:V4SI
10012             (sign_extend:V4SI
10013               (vec_select:V4HI
10014                 (match_operand:V8HI 1 "vector_operand")
10015                 (parallel [(const_int 0) (const_int 2)
10016                            (const_int 4) (const_int 6)])))
10017             (sign_extend:V4SI
10018               (vec_select:V4HI
10019                 (match_operand:V8HI 2 "vector_operand")
10020                 (parallel [(const_int 0) (const_int 2)
10021                            (const_int 4) (const_int 6)]))))
10022           (mult:V4SI
10023             (sign_extend:V4SI
10024               (vec_select:V4HI (match_dup 1)
10025                 (parallel [(const_int 1) (const_int 3)
10026                            (const_int 5) (const_int 7)])))
10027             (sign_extend:V4SI
10028               (vec_select:V4HI (match_dup 2)
10029                 (parallel [(const_int 1) (const_int 3)
10030                            (const_int 5) (const_int 7)]))))))]
10031   "TARGET_SSE2"
10032   "ix86_fixup_binary_operands_no_copy (MULT, V8HImode, operands);")
10034 (define_insn "*sse2_pmaddwd"
10035   [(set (match_operand:V4SI 0 "register_operand" "=x,x,v")
10036         (plus:V4SI
10037           (mult:V4SI
10038             (sign_extend:V4SI
10039               (vec_select:V4HI
10040                 (match_operand:V8HI 1 "vector_operand" "%0,x,v")
10041                 (parallel [(const_int 0) (const_int 2)
10042                            (const_int 4) (const_int 6)])))
10043             (sign_extend:V4SI
10044               (vec_select:V4HI
10045                 (match_operand:V8HI 2 "vector_operand" "xBm,xm,vm")
10046                 (parallel [(const_int 0) (const_int 2)
10047                            (const_int 4) (const_int 6)]))))
10048           (mult:V4SI
10049             (sign_extend:V4SI
10050               (vec_select:V4HI (match_dup 1)
10051                 (parallel [(const_int 1) (const_int 3)
10052                            (const_int 5) (const_int 7)])))
10053             (sign_extend:V4SI
10054               (vec_select:V4HI (match_dup 2)
10055                 (parallel [(const_int 1) (const_int 3)
10056                            (const_int 5) (const_int 7)]))))))]
10057   "TARGET_SSE2 && ix86_binary_operator_ok (MULT, V8HImode, operands)"
10058   "@
10059    pmaddwd\t{%2, %0|%0, %2}
10060    vpmaddwd\t{%2, %1, %0|%0, %1, %2}
10061    vpmaddwd\t{%2, %1, %0|%0, %1, %2}"
10062   [(set_attr "isa" "noavx,avx,avx512bw")
10063    (set_attr "type" "sseiadd")
10064    (set_attr "atom_unit" "simul")
10065    (set_attr "prefix_data16" "1,*,*")
10066    (set_attr "prefix" "orig,vex,evex")
10067    (set_attr "mode" "TI")])
10069 (define_insn "avx512dq_mul<mode>3<mask_name>"
10070   [(set (match_operand:VI8 0 "register_operand" "=v")
10071         (mult:VI8
10072           (match_operand:VI8 1 "register_operand" "v")
10073           (match_operand:VI8 2 "nonimmediate_operand" "vm")))]
10074   "TARGET_AVX512DQ && <mask_mode512bit_condition>"
10075   "vpmullq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10076   [(set_attr "type" "sseimul")
10077    (set_attr "prefix" "evex")
10078    (set_attr "mode" "<sseinsnmode>")])
10080 (define_expand "mul<mode>3<mask_name>"
10081   [(set (match_operand:VI4_AVX512F 0 "register_operand")
10082         (mult:VI4_AVX512F
10083           (match_operand:VI4_AVX512F 1 "general_vector_operand")
10084           (match_operand:VI4_AVX512F 2 "general_vector_operand")))]
10085   "TARGET_SSE2 && <mask_mode512bit_condition>"
10087   if (TARGET_SSE4_1)
10088     {
10089       if (!vector_operand (operands[1], <MODE>mode))
10090         operands[1] = force_reg (<MODE>mode, operands[1]);
10091       if (!vector_operand (operands[2], <MODE>mode))
10092         operands[2] = force_reg (<MODE>mode, operands[2]);
10093       ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
10094     }
10095   else
10096     {
10097       ix86_expand_sse2_mulv4si3 (operands[0], operands[1], operands[2]);
10098       DONE;
10099     }
10102 (define_insn "*<sse4_1_avx2>_mul<mode>3<mask_name>"
10103   [(set (match_operand:VI4_AVX512F 0 "register_operand" "=Yr,*x,v")
10104         (mult:VI4_AVX512F
10105           (match_operand:VI4_AVX512F 1 "vector_operand" "%0,0,v")
10106           (match_operand:VI4_AVX512F 2 "vector_operand" "YrBm,*xBm,vm")))]
10107   "TARGET_SSE4_1 && ix86_binary_operator_ok (MULT, <MODE>mode, operands) && <mask_mode512bit_condition>"
10108   "@
10109    pmulld\t{%2, %0|%0, %2}
10110    pmulld\t{%2, %0|%0, %2}
10111    vpmulld\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10112   [(set_attr "isa" "noavx,noavx,avx")
10113    (set_attr "type" "sseimul")
10114    (set_attr "prefix_extra" "1")
10115    (set_attr "prefix" "<mask_prefix4>")
10116    (set_attr "btver2_decode" "vector,vector,vector")
10117    (set_attr "mode" "<sseinsnmode>")])
10119 (define_expand "mul<mode>3"
10120   [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand")
10121         (mult:VI8_AVX2_AVX512F
10122           (match_operand:VI8_AVX2_AVX512F 1 "register_operand")
10123           (match_operand:VI8_AVX2_AVX512F 2 "register_operand")))]
10124   "TARGET_SSE2"
10126   ix86_expand_sse2_mulvxdi3 (operands[0], operands[1], operands[2]);
10127   DONE;
10130 (define_expand "vec_widen_<s>mult_hi_<mode>"
10131   [(match_operand:<sseunpackmode> 0 "register_operand")
10132    (any_extend:<sseunpackmode>
10133      (match_operand:VI124_AVX2 1 "register_operand"))
10134    (match_operand:VI124_AVX2 2 "register_operand")]
10135   "TARGET_SSE2"
10137   ix86_expand_mul_widen_hilo (operands[0], operands[1], operands[2],
10138                               <u_bool>, true);
10139   DONE;
10142 (define_expand "vec_widen_<s>mult_lo_<mode>"
10143   [(match_operand:<sseunpackmode> 0 "register_operand")
10144    (any_extend:<sseunpackmode>
10145      (match_operand:VI124_AVX2 1 "register_operand"))
10146    (match_operand:VI124_AVX2 2 "register_operand")]
10147   "TARGET_SSE2"
10149   ix86_expand_mul_widen_hilo (operands[0], operands[1], operands[2],
10150                               <u_bool>, false);
10151   DONE;
10154 ;; Most widen_<s>mult_even_<mode> can be handled directly from other
10155 ;; named patterns, but signed V4SI needs special help for plain SSE2.
10156 (define_expand "vec_widen_smult_even_v4si"
10157   [(match_operand:V2DI 0 "register_operand")
10158    (match_operand:V4SI 1 "vector_operand")
10159    (match_operand:V4SI 2 "vector_operand")]
10160   "TARGET_SSE2"
10162   ix86_expand_mul_widen_evenodd (operands[0], operands[1], operands[2],
10163                                  false, false);
10164   DONE;
10167 (define_expand "vec_widen_<s>mult_odd_<mode>"
10168   [(match_operand:<sseunpackmode> 0 "register_operand")
10169    (any_extend:<sseunpackmode>
10170      (match_operand:VI4_AVX512F 1 "general_vector_operand"))
10171    (match_operand:VI4_AVX512F 2 "general_vector_operand")]
10172   "TARGET_SSE2"
10174   ix86_expand_mul_widen_evenodd (operands[0], operands[1], operands[2],
10175                                  <u_bool>, true);
10176   DONE;
10179 (define_mode_attr SDOT_PMADD_SUF
10180   [(V32HI "512v32hi") (V16HI "") (V8HI "")])
10182 (define_expand "sdot_prod<mode>"
10183   [(match_operand:<sseunpackmode> 0 "register_operand")
10184    (match_operand:VI2_AVX2 1 "register_operand")
10185    (match_operand:VI2_AVX2 2 "register_operand")
10186    (match_operand:<sseunpackmode> 3 "register_operand")]
10187   "TARGET_SSE2"
10189   rtx t = gen_reg_rtx (<sseunpackmode>mode);
10190   emit_insn (gen_<sse2_avx2>_pmaddwd<SDOT_PMADD_SUF> (t, operands[1], operands[2]));
10191   emit_insn (gen_rtx_SET (operands[0],
10192                           gen_rtx_PLUS (<sseunpackmode>mode,
10193                                         operands[3], t)));
10194   DONE;
10197 ;; Normally we use widen_mul_even/odd, but combine can't quite get it all
10198 ;; back together when madd is available.
10199 (define_expand "sdot_prodv4si"
10200   [(match_operand:V2DI 0 "register_operand")
10201    (match_operand:V4SI 1 "register_operand")
10202    (match_operand:V4SI 2 "register_operand")
10203    (match_operand:V2DI 3 "register_operand")]
10204   "TARGET_XOP"
10206   rtx t = gen_reg_rtx (V2DImode);
10207   emit_insn (gen_xop_pmacsdqh (t, operands[1], operands[2], operands[3]));
10208   emit_insn (gen_xop_pmacsdql (operands[0], operands[1], operands[2], t));
10209   DONE;
10212 (define_expand "usadv16qi"
10213   [(match_operand:V4SI 0 "register_operand")
10214    (match_operand:V16QI 1 "register_operand")
10215    (match_operand:V16QI 2 "vector_operand")
10216    (match_operand:V4SI 3 "vector_operand")]
10217   "TARGET_SSE2"
10219   rtx t1 = gen_reg_rtx (V2DImode);
10220   rtx t2 = gen_reg_rtx (V4SImode);
10221   emit_insn (gen_sse2_psadbw (t1, operands[1], operands[2]));
10222   convert_move (t2, t1, 0);
10223   emit_insn (gen_addv4si3 (operands[0], t2, operands[3]));
10224   DONE;
10227 (define_expand "usadv32qi"
10228   [(match_operand:V8SI 0 "register_operand")
10229    (match_operand:V32QI 1 "register_operand")
10230    (match_operand:V32QI 2 "nonimmediate_operand")
10231    (match_operand:V8SI 3 "nonimmediate_operand")]
10232   "TARGET_AVX2"
10234   rtx t1 = gen_reg_rtx (V4DImode);
10235   rtx t2 = gen_reg_rtx (V8SImode);
10236   emit_insn (gen_avx2_psadbw (t1, operands[1], operands[2]));
10237   convert_move (t2, t1, 0);
10238   emit_insn (gen_addv8si3 (operands[0], t2, operands[3]));
10239   DONE;
10242 (define_insn "<mask_codefor>ashr<mode>3<mask_name>"
10243   [(set (match_operand:VI24_AVX512BW_1 0 "register_operand" "=v,v")
10244         (ashiftrt:VI24_AVX512BW_1
10245           (match_operand:VI24_AVX512BW_1 1 "nonimmediate_operand" "v,vm")
10246           (match_operand:SI 2 "nonmemory_operand" "v,N")))]
10247   "TARGET_AVX512VL"
10248   "vpsra<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10249   [(set_attr "type" "sseishft")
10250    (set (attr "length_immediate")
10251      (if_then_else (match_operand 2 "const_int_operand")
10252        (const_string "1")
10253        (const_string "0")))
10254    (set_attr "mode" "<sseinsnmode>")])
10256 (define_insn "ashr<mode>3"
10257   [(set (match_operand:VI24_AVX2 0 "register_operand" "=x,x")
10258         (ashiftrt:VI24_AVX2
10259           (match_operand:VI24_AVX2 1 "register_operand" "0,x")
10260           (match_operand:SI 2 "nonmemory_operand" "xN,xN")))]
10261   "TARGET_SSE2"
10262   "@
10263    psra<ssemodesuffix>\t{%2, %0|%0, %2}
10264    vpsra<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10265   [(set_attr "isa" "noavx,avx")
10266    (set_attr "type" "sseishft")
10267    (set (attr "length_immediate")
10268      (if_then_else (match_operand 2 "const_int_operand")
10269        (const_string "1")
10270        (const_string "0")))
10271    (set_attr "prefix_data16" "1,*")
10272    (set_attr "prefix" "orig,vex")
10273    (set_attr "mode" "<sseinsnmode>")])
10275 (define_insn "<mask_codefor>ashrv2di3<mask_name>"
10276   [(set (match_operand:V2DI 0 "register_operand" "=v,v")
10277         (ashiftrt:V2DI
10278           (match_operand:V2DI 1 "nonimmediate_operand" "v,vm")
10279           (match_operand:DI 2 "nonmemory_operand" "v,N")))]
10280   "TARGET_AVX512VL"
10281   "vpsraq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10282   [(set_attr "type" "sseishft")
10283    (set (attr "length_immediate")
10284      (if_then_else (match_operand 2 "const_int_operand")
10285        (const_string "1")
10286        (const_string "0")))
10287    (set_attr "mode" "TI")])
10289 (define_insn "ashr<mode>3<mask_name>"
10290   [(set (match_operand:VI248_AVX512BW_AVX512VL 0 "register_operand" "=v,v")
10291         (ashiftrt:VI248_AVX512BW_AVX512VL
10292           (match_operand:VI248_AVX512BW_AVX512VL 1 "nonimmediate_operand" "v,vm")
10293           (match_operand:SI 2 "nonmemory_operand" "v,N")))]
10294   "TARGET_AVX512F"
10295   "vpsra<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10296   [(set_attr "type" "sseishft")
10297    (set (attr "length_immediate")
10298      (if_then_else (match_operand 2 "const_int_operand")
10299        (const_string "1")
10300        (const_string "0")))
10301    (set_attr "mode" "<sseinsnmode>")])
10303 (define_insn "<shift_insn><mode>3<mask_name>"
10304   [(set (match_operand:VI2_AVX2_AVX512BW 0 "register_operand" "=x,v")
10305         (any_lshift:VI2_AVX2_AVX512BW
10306           (match_operand:VI2_AVX2_AVX512BW 1 "register_operand" "0,v")
10307           (match_operand:SI 2 "nonmemory_operand" "xN,vN")))]
10308   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
10309   "@
10310    p<vshift><ssemodesuffix>\t{%2, %0|%0, %2}
10311    vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10312   [(set_attr "isa" "noavx,avx")
10313    (set_attr "type" "sseishft")
10314    (set (attr "length_immediate")
10315      (if_then_else (match_operand 2 "const_int_operand")
10316        (const_string "1")
10317        (const_string "0")))
10318    (set_attr "prefix_data16" "1,*")
10319    (set_attr "prefix" "orig,vex")
10320    (set_attr "mode" "<sseinsnmode>")])
10322 (define_insn "<shift_insn><mode>3<mask_name>"
10323   [(set (match_operand:VI48_AVX2 0 "register_operand" "=x,x,v")
10324         (any_lshift:VI48_AVX2
10325           (match_operand:VI48_AVX2 1 "register_operand" "0,x,v")
10326           (match_operand:SI 2 "nonmemory_operand" "xN,xN,vN")))]
10327   "TARGET_SSE2 && <mask_mode512bit_condition>"
10328   "@
10329    p<vshift><ssemodesuffix>\t{%2, %0|%0, %2}
10330    vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
10331    vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"  
10332   [(set_attr "isa" "noavx,avx,avx512bw")
10333    (set_attr "type" "sseishft")
10334    (set (attr "length_immediate")
10335      (if_then_else (match_operand 2 "const_int_operand")
10336        (const_string "1")
10337        (const_string "0")))
10338    (set_attr "prefix_data16" "1,*,*")
10339    (set_attr "prefix" "orig,vex,evex")
10340    (set_attr "mode" "<sseinsnmode>")])
10342 (define_insn "<shift_insn><mode>3<mask_name>"
10343   [(set (match_operand:VI48_512 0 "register_operand" "=v,v")
10344         (any_lshift:VI48_512
10345           (match_operand:VI48_512 1 "nonimmediate_operand" "v,m")
10346           (match_operand:SI 2 "nonmemory_operand" "vN,N")))]
10347   "TARGET_AVX512F && <mask_mode512bit_condition>"
10348   "vp<vshift><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10349   [(set_attr "isa" "avx512f")
10350    (set_attr "type" "sseishft")
10351    (set (attr "length_immediate")
10352      (if_then_else (match_operand 2 "const_int_operand")
10353        (const_string "1")
10354        (const_string "0")))
10355    (set_attr "prefix" "evex")
10356    (set_attr "mode" "<sseinsnmode>")])
10359 (define_expand "vec_shl_<mode>"
10360   [(set (match_dup 3)
10361         (ashift:V1TI
10362          (match_operand:VI_128 1 "register_operand")
10363          (match_operand:SI 2 "const_0_to_255_mul_8_operand")))
10364    (set (match_operand:VI_128 0 "register_operand") (match_dup 4))]
10365   "TARGET_SSE2"
10367   operands[1] = gen_lowpart (V1TImode, operands[1]);
10368   operands[3] = gen_reg_rtx (V1TImode);
10369   operands[4] = gen_lowpart (<MODE>mode, operands[3]);
10372 (define_insn "<sse2_avx2>_ashl<mode>3"
10373   [(set (match_operand:VIMAX_AVX2 0 "register_operand" "=x,v")
10374         (ashift:VIMAX_AVX2
10375          (match_operand:VIMAX_AVX2 1 "register_operand" "0,v")
10376          (match_operand:SI 2 "const_0_to_255_mul_8_operand" "n,n")))]
10377   "TARGET_SSE2"
10379   operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
10381   switch (which_alternative)
10382     {
10383     case 0:
10384       return "pslldq\t{%2, %0|%0, %2}";
10385     case 1:
10386       return "vpslldq\t{%2, %1, %0|%0, %1, %2}";
10387     default:
10388       gcc_unreachable ();
10389     }
10391   [(set_attr "isa" "noavx,avx")
10392    (set_attr "type" "sseishft")
10393    (set_attr "length_immediate" "1")
10394    (set_attr "prefix_data16" "1,*")
10395    (set_attr "prefix" "orig,vex")
10396    (set_attr "mode" "<sseinsnmode>")])
10398 (define_expand "vec_shr_<mode>"
10399   [(set (match_dup 3)
10400         (lshiftrt:V1TI
10401          (match_operand:VI_128 1 "register_operand")
10402          (match_operand:SI 2 "const_0_to_255_mul_8_operand")))
10403    (set (match_operand:VI_128 0 "register_operand") (match_dup 4))]
10404   "TARGET_SSE2"
10406   operands[1] = gen_lowpart (V1TImode, operands[1]);
10407   operands[3] = gen_reg_rtx (V1TImode);
10408   operands[4] = gen_lowpart (<MODE>mode, operands[3]);
10411 (define_insn "<sse2_avx2>_lshr<mode>3"
10412   [(set (match_operand:VIMAX_AVX2 0 "register_operand" "=x,v")
10413         (lshiftrt:VIMAX_AVX2
10414          (match_operand:VIMAX_AVX2 1 "register_operand" "0,v")
10415          (match_operand:SI 2 "const_0_to_255_mul_8_operand" "n,n")))]
10416   "TARGET_SSE2"
10418   operands[2] = GEN_INT (INTVAL (operands[2]) / 8);
10420   switch (which_alternative)
10421     {
10422     case 0:
10423       return "psrldq\t{%2, %0|%0, %2}";
10424     case 1:
10425       return "vpsrldq\t{%2, %1, %0|%0, %1, %2}";
10426     default:
10427       gcc_unreachable ();
10428     }
10430   [(set_attr "isa" "noavx,avx")
10431    (set_attr "type" "sseishft")
10432    (set_attr "length_immediate" "1")
10433    (set_attr "atom_unit" "sishuf")
10434    (set_attr "prefix_data16" "1,*")
10435    (set_attr "prefix" "orig,vex")
10436    (set_attr "mode" "<sseinsnmode>")])
10438 (define_insn "<avx512>_<rotate>v<mode><mask_name>"
10439   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10440         (any_rotate:VI48_AVX512VL
10441           (match_operand:VI48_AVX512VL 1 "register_operand" "v")
10442           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")))]
10443   "TARGET_AVX512F"
10444   "vp<rotate>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10445   [(set_attr "prefix" "evex")
10446    (set_attr "mode" "<sseinsnmode>")])
10448 (define_insn "<avx512>_<rotate><mode><mask_name>"
10449   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10450         (any_rotate:VI48_AVX512VL
10451           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")
10452           (match_operand:SI 2 "const_0_to_255_operand")))]
10453   "TARGET_AVX512F"
10454   "vp<rotate><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10455   [(set_attr "prefix" "evex")
10456    (set_attr "mode" "<sseinsnmode>")])
10458 (define_expand "<code><mode>3"
10459   [(set (match_operand:VI124_256_AVX512F_AVX512BW 0 "register_operand")
10460         (maxmin:VI124_256_AVX512F_AVX512BW
10461           (match_operand:VI124_256_AVX512F_AVX512BW 1 "nonimmediate_operand")
10462           (match_operand:VI124_256_AVX512F_AVX512BW 2 "nonimmediate_operand")))]
10463   "TARGET_AVX2"
10464   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10466 (define_insn "*avx2_<code><mode>3"
10467   [(set (match_operand:VI124_256 0 "register_operand" "=v")
10468         (maxmin:VI124_256
10469           (match_operand:VI124_256 1 "nonimmediate_operand" "%v")
10470           (match_operand:VI124_256 2 "nonimmediate_operand" "vm")))]
10471   "TARGET_AVX2 && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10472   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10473   [(set_attr "type" "sseiadd")
10474    (set_attr "prefix_extra" "1")
10475    (set_attr "prefix" "vex")
10476    (set_attr "mode" "OI")])
10478 (define_expand "<code><mode>3_mask"
10479   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
10480         (vec_merge:VI48_AVX512VL
10481           (maxmin:VI48_AVX512VL
10482             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand")
10483             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
10484           (match_operand:VI48_AVX512VL 3 "vector_move_operand")
10485           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
10486   "TARGET_AVX512F"
10487   "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
10489 (define_insn "*avx512bw_<code><mode>3<mask_name>"
10490   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
10491         (maxmin:VI48_AVX512VL
10492           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "%v")
10493           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")))]
10494   "TARGET_AVX512F && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10495   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10496   [(set_attr "type" "sseiadd")
10497    (set_attr "prefix_extra" "1")
10498    (set_attr "prefix" "maybe_evex")
10499    (set_attr "mode" "<sseinsnmode>")])
10501 (define_insn "<mask_codefor><code><mode>3<mask_name>"
10502   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
10503         (maxmin:VI12_AVX512VL
10504           (match_operand:VI12_AVX512VL 1 "register_operand" "v")
10505           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")))]
10506   "TARGET_AVX512BW"
10507   "vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10508   [(set_attr "type" "sseiadd")
10509    (set_attr "prefix" "evex")
10510    (set_attr "mode" "<sseinsnmode>")])
10512 (define_expand "<code><mode>3"
10513   [(set (match_operand:VI8_AVX2_AVX512BW 0 "register_operand")
10514         (maxmin:VI8_AVX2_AVX512BW
10515           (match_operand:VI8_AVX2_AVX512BW 1 "register_operand")
10516           (match_operand:VI8_AVX2_AVX512BW 2 "register_operand")))]
10517   "TARGET_SSE4_2"
10519   if (TARGET_AVX512F
10520       && (<MODE>mode == V8DImode || TARGET_AVX512VL))
10521     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
10522   else 
10523     {
10524       enum rtx_code code;
10525       rtx xops[6];
10526       bool ok;
10529       xops[0] = operands[0];
10531       if (<CODE> == SMAX || <CODE> == UMAX)
10532         {
10533           xops[1] = operands[1];
10534           xops[2] = operands[2];
10535         }
10536       else
10537         {
10538           xops[1] = operands[2];
10539           xops[2] = operands[1];
10540         }
10542       code = (<CODE> == UMAX || <CODE> == UMIN) ? GTU : GT;
10544       xops[3] = gen_rtx_fmt_ee (code, VOIDmode, operands[1], operands[2]);
10545       xops[4] = operands[1];
10546       xops[5] = operands[2];
10548       ok = ix86_expand_int_vcond (xops);
10549       gcc_assert (ok);
10550       DONE;
10551     }
10554 (define_expand "<code><mode>3"
10555   [(set (match_operand:VI124_128 0 "register_operand")
10556         (smaxmin:VI124_128
10557           (match_operand:VI124_128 1 "vector_operand")
10558           (match_operand:VI124_128 2 "vector_operand")))]
10559   "TARGET_SSE2"
10561   if (TARGET_SSE4_1 || <MODE>mode == V8HImode)
10562     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
10563   else
10564     {
10565       rtx xops[6];
10566       bool ok;
10568       xops[0] = operands[0];
10569       operands[1] = force_reg (<MODE>mode, operands[1]);
10570       operands[2] = force_reg (<MODE>mode, operands[2]);
10572       if (<CODE> == SMAX)
10573         {
10574           xops[1] = operands[1];
10575           xops[2] = operands[2];
10576         }
10577       else
10578         {
10579           xops[1] = operands[2];
10580           xops[2] = operands[1];
10581         }
10583       xops[3] = gen_rtx_GT (VOIDmode, operands[1], operands[2]);
10584       xops[4] = operands[1];
10585       xops[5] = operands[2];
10587       ok = ix86_expand_int_vcond (xops);
10588       gcc_assert (ok);
10589       DONE;
10590     }
10593 (define_insn "*sse4_1_<code><mode>3<mask_name>"
10594   [(set (match_operand:VI14_128 0 "register_operand" "=Yr,*x,v")
10595         (smaxmin:VI14_128
10596           (match_operand:VI14_128 1 "vector_operand" "%0,0,v")
10597           (match_operand:VI14_128 2 "vector_operand" "YrBm,*xBm,vm")))]
10598   "TARGET_SSE4_1
10599    && <mask_mode512bit_condition>
10600    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10601   "@
10602    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
10603    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
10604    vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10605   [(set_attr "isa" "noavx,noavx,avx")
10606    (set_attr "type" "sseiadd")
10607    (set_attr "prefix_extra" "1,1,*")
10608    (set_attr "prefix" "orig,orig,vex")
10609    (set_attr "mode" "TI")])
10611 (define_insn "*<code>v8hi3"
10612   [(set (match_operand:V8HI 0 "register_operand" "=x,x,v")
10613         (smaxmin:V8HI
10614           (match_operand:V8HI 1 "vector_operand" "%0,x,v")
10615           (match_operand:V8HI 2 "vector_operand" "xBm,xm,vm")))]
10616   "TARGET_SSE2 && ix86_binary_operator_ok (<CODE>, V8HImode, operands)"
10617   "@
10618    p<maxmin_int>w\t{%2, %0|%0, %2}
10619    vp<maxmin_int>w\t{%2, %1, %0|%0, %1, %2}
10620    vp<maxmin_int>w\t{%2, %1, %0|%0, %1, %2}"
10621   [(set_attr "isa" "noavx,avx,avx512bw")
10622    (set_attr "type" "sseiadd")
10623    (set_attr "prefix_data16" "1,*,*")
10624    (set_attr "prefix_extra" "*,1,1")
10625    (set_attr "prefix" "orig,vex,evex")
10626    (set_attr "mode" "TI")])
10628 (define_expand "<code><mode>3"
10629   [(set (match_operand:VI124_128 0 "register_operand")
10630         (umaxmin:VI124_128
10631           (match_operand:VI124_128 1 "vector_operand")
10632           (match_operand:VI124_128 2 "vector_operand")))]
10633   "TARGET_SSE2"
10635   if (TARGET_SSE4_1 || <MODE>mode == V16QImode)
10636     ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);
10637   else if (<CODE> == UMAX && <MODE>mode == V8HImode)
10638     {
10639       rtx op0 = operands[0], op2 = operands[2], op3 = op0;
10640       operands[1] = force_reg (<MODE>mode, operands[1]);
10641       if (rtx_equal_p (op3, op2))
10642         op3 = gen_reg_rtx (V8HImode);
10643       emit_insn (gen_sse2_ussubv8hi3 (op3, operands[1], op2));
10644       emit_insn (gen_addv8hi3 (op0, op3, op2));
10645       DONE;
10646     }
10647   else
10648     {
10649       rtx xops[6];
10650       bool ok;
10652       operands[1] = force_reg (<MODE>mode, operands[1]);
10653       operands[2] = force_reg (<MODE>mode, operands[2]);
10655       xops[0] = operands[0];
10657       if (<CODE> == UMAX)
10658         {
10659           xops[1] = operands[1];
10660           xops[2] = operands[2];
10661         }
10662       else
10663         {
10664           xops[1] = operands[2];
10665           xops[2] = operands[1];
10666         }
10668       xops[3] = gen_rtx_GTU (VOIDmode, operands[1], operands[2]);
10669       xops[4] = operands[1];
10670       xops[5] = operands[2];
10672       ok = ix86_expand_int_vcond (xops);
10673       gcc_assert (ok);
10674       DONE;
10675     }
10678 (define_insn "*sse4_1_<code><mode>3<mask_name>"
10679   [(set (match_operand:VI24_128 0 "register_operand" "=Yr,*x,v")
10680         (umaxmin:VI24_128
10681           (match_operand:VI24_128 1 "vector_operand" "%0,0,v")
10682           (match_operand:VI24_128 2 "vector_operand" "YrBm,*xBm,vm")))]
10683   "TARGET_SSE4_1
10684    && <mask_mode512bit_condition>
10685    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
10686   "@
10687    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
10688    p<maxmin_int><ssemodesuffix>\t{%2, %0|%0, %2}
10689    vp<maxmin_int><ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
10690   [(set_attr "isa" "noavx,noavx,avx")
10691    (set_attr "type" "sseiadd")
10692    (set_attr "prefix_extra" "1,1,*")
10693    (set_attr "prefix" "orig,orig,vex")
10694    (set_attr "mode" "TI")])
10696 (define_insn "*<code>v16qi3"
10697   [(set (match_operand:V16QI 0 "register_operand" "=x,x,v")
10698         (umaxmin:V16QI
10699           (match_operand:V16QI 1 "vector_operand" "%0,x,v")
10700           (match_operand:V16QI 2 "vector_operand" "xBm,xm,vm")))]
10701   "TARGET_SSE2 && ix86_binary_operator_ok (<CODE>, V16QImode, operands)"
10702   "@
10703    p<maxmin_int>b\t{%2, %0|%0, %2}
10704    vp<maxmin_int>b\t{%2, %1, %0|%0, %1, %2}
10705    vp<maxmin_int>b\t{%2, %1, %0|%0, %1, %2}"
10706   [(set_attr "isa" "noavx,avx,avx512bw")
10707    (set_attr "type" "sseiadd")
10708    (set_attr "prefix_data16" "1,*,*")
10709    (set_attr "prefix_extra" "*,1,1")
10710    (set_attr "prefix" "orig,vex,evex")
10711    (set_attr "mode" "TI")])
10713 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10715 ;; Parallel integral comparisons
10717 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10719 (define_expand "avx2_eq<mode>3"
10720   [(set (match_operand:VI_256 0 "register_operand")
10721         (eq:VI_256
10722           (match_operand:VI_256 1 "nonimmediate_operand")
10723           (match_operand:VI_256 2 "nonimmediate_operand")))]
10724   "TARGET_AVX2"
10725   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
10727 (define_insn "*avx2_eq<mode>3"
10728   [(set (match_operand:VI_256 0 "register_operand" "=x")
10729         (eq:VI_256
10730           (match_operand:VI_256 1 "nonimmediate_operand" "%x")
10731           (match_operand:VI_256 2 "nonimmediate_operand" "xm")))]
10732   "TARGET_AVX2 && ix86_binary_operator_ok (EQ, <MODE>mode, operands)"
10733   "vpcmpeq<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10734   [(set_attr "type" "ssecmp")
10735    (set_attr "prefix_extra" "1")
10736    (set_attr "prefix" "vex")
10737    (set_attr "mode" "OI")])
10739 (define_expand "<avx512>_eq<mode>3<mask_scalar_merge_name>"
10740   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
10741         (unspec:<avx512fmaskmode>
10742           [(match_operand:VI12_AVX512VL 1 "register_operand")
10743            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand")]
10744           UNSPEC_MASKED_EQ))]
10745   "TARGET_AVX512BW"
10746   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
10748 (define_expand "<avx512>_eq<mode>3<mask_scalar_merge_name>"
10749   [(set (match_operand:<avx512fmaskmode> 0 "register_operand")
10750         (unspec:<avx512fmaskmode>
10751           [(match_operand:VI48_AVX512VL 1 "register_operand")
10752            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand")]
10753           UNSPEC_MASKED_EQ))]
10754   "TARGET_AVX512F"
10755   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
10757 (define_insn "<avx512>_eq<mode>3<mask_scalar_merge_name>_1"
10758   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
10759         (unspec:<avx512fmaskmode>
10760           [(match_operand:VI12_AVX512VL 1 "register_operand" "%v")
10761            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")]
10762           UNSPEC_MASKED_EQ))]
10763   "TARGET_AVX512F && ix86_binary_operator_ok (EQ, <MODE>mode, operands)"
10764   "vpcmpeq<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
10765   [(set_attr "type" "ssecmp")
10766    (set_attr "prefix_extra" "1")
10767    (set_attr "prefix" "evex")
10768    (set_attr "mode" "<sseinsnmode>")])
10770 (define_insn "<avx512>_eq<mode>3<mask_scalar_merge_name>_1"
10771   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
10772         (unspec:<avx512fmaskmode>
10773           [(match_operand:VI48_AVX512VL 1 "register_operand" "%v")
10774            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")]
10775           UNSPEC_MASKED_EQ))]
10776   "TARGET_AVX512F && ix86_binary_operator_ok (EQ, <MODE>mode, operands)"
10777   "vpcmpeq<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
10778   [(set_attr "type" "ssecmp")
10779    (set_attr "prefix_extra" "1")
10780    (set_attr "prefix" "evex")
10781    (set_attr "mode" "<sseinsnmode>")])
10783 (define_insn "*sse4_1_eqv2di3"
10784   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,x")
10785         (eq:V2DI
10786           (match_operand:V2DI 1 "vector_operand" "%0,0,x")
10787           (match_operand:V2DI 2 "vector_operand" "YrBm,*xBm,xm")))]
10788   "TARGET_SSE4_1 && ix86_binary_operator_ok (EQ, V2DImode, operands)"
10789   "@
10790    pcmpeqq\t{%2, %0|%0, %2}
10791    pcmpeqq\t{%2, %0|%0, %2}
10792    vpcmpeqq\t{%2, %1, %0|%0, %1, %2}"
10793   [(set_attr "isa" "noavx,noavx,avx")
10794    (set_attr "type" "ssecmp")
10795    (set_attr "prefix_extra" "1")
10796    (set_attr "prefix" "orig,orig,vex")
10797    (set_attr "mode" "TI")])
10799 (define_insn "*sse2_eq<mode>3"
10800   [(set (match_operand:VI124_128 0 "register_operand" "=x,x")
10801         (eq:VI124_128
10802           (match_operand:VI124_128 1 "vector_operand" "%0,x")
10803           (match_operand:VI124_128 2 "vector_operand" "xBm,xm")))]
10804   "TARGET_SSE2 && !TARGET_XOP
10805    && ix86_binary_operator_ok (EQ, <MODE>mode, operands)"
10806   "@
10807    pcmpeq<ssemodesuffix>\t{%2, %0|%0, %2}
10808    vpcmpeq<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10809   [(set_attr "isa" "noavx,avx")
10810    (set_attr "type" "ssecmp")
10811    (set_attr "prefix_data16" "1,*")
10812    (set_attr "prefix" "orig,vex")
10813    (set_attr "mode" "TI")])
10815 (define_expand "sse2_eq<mode>3"
10816   [(set (match_operand:VI124_128 0 "register_operand")
10817         (eq:VI124_128
10818           (match_operand:VI124_128 1 "vector_operand")
10819           (match_operand:VI124_128 2 "vector_operand")))]
10820   "TARGET_SSE2 && !TARGET_XOP "
10821   "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
10823 (define_expand "sse4_1_eqv2di3"
10824   [(set (match_operand:V2DI 0 "register_operand")
10825         (eq:V2DI
10826           (match_operand:V2DI 1 "vector_operand")
10827           (match_operand:V2DI 2 "vector_operand")))]
10828   "TARGET_SSE4_1"
10829   "ix86_fixup_binary_operands_no_copy (EQ, V2DImode, operands);")
10831 (define_insn "sse4_2_gtv2di3"
10832   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,x")
10833         (gt:V2DI
10834           (match_operand:V2DI 1 "register_operand" "0,0,x")
10835           (match_operand:V2DI 2 "vector_operand" "YrBm,*xBm,xm")))]
10836   "TARGET_SSE4_2"
10837   "@
10838    pcmpgtq\t{%2, %0|%0, %2}
10839    pcmpgtq\t{%2, %0|%0, %2}
10840    vpcmpgtq\t{%2, %1, %0|%0, %1, %2}"
10841   [(set_attr "isa" "noavx,noavx,avx")
10842    (set_attr "type" "ssecmp")
10843    (set_attr "prefix_extra" "1")
10844    (set_attr "prefix" "orig,orig,vex")
10845    (set_attr "mode" "TI")])
10847 (define_insn "avx2_gt<mode>3"
10848   [(set (match_operand:VI_256 0 "register_operand" "=x")
10849         (gt:VI_256
10850           (match_operand:VI_256 1 "register_operand" "x")
10851           (match_operand:VI_256 2 "nonimmediate_operand" "xm")))]
10852   "TARGET_AVX2"
10853   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10854   [(set_attr "type" "ssecmp")
10855    (set_attr "prefix_extra" "1")
10856    (set_attr "prefix" "vex")
10857    (set_attr "mode" "OI")])
10859 (define_insn "<avx512>_gt<mode>3<mask_scalar_merge_name>"
10860   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
10861         (unspec:<avx512fmaskmode>
10862           [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
10863            (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")] UNSPEC_MASKED_GT))]
10864   "TARGET_AVX512F"
10865   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
10866   [(set_attr "type" "ssecmp")
10867    (set_attr "prefix_extra" "1")
10868    (set_attr "prefix" "evex")
10869    (set_attr "mode" "<sseinsnmode>")])
10871 (define_insn "<avx512>_gt<mode>3<mask_scalar_merge_name>"
10872   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
10873         (unspec:<avx512fmaskmode>
10874           [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
10875            (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")] UNSPEC_MASKED_GT))]
10876   "TARGET_AVX512BW"
10877   "vpcmpgt<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
10878   [(set_attr "type" "ssecmp")
10879    (set_attr "prefix_extra" "1")
10880    (set_attr "prefix" "evex")
10881    (set_attr "mode" "<sseinsnmode>")])
10883 (define_insn "sse2_gt<mode>3"
10884   [(set (match_operand:VI124_128 0 "register_operand" "=x,x")
10885         (gt:VI124_128
10886           (match_operand:VI124_128 1 "register_operand" "0,x")
10887           (match_operand:VI124_128 2 "vector_operand" "xBm,xm")))]
10888   "TARGET_SSE2 && !TARGET_XOP"
10889   "@
10890    pcmpgt<ssemodesuffix>\t{%2, %0|%0, %2}
10891    vpcmpgt<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
10892   [(set_attr "isa" "noavx,avx")
10893    (set_attr "type" "ssecmp")
10894    (set_attr "prefix_data16" "1,*")
10895    (set_attr "prefix" "orig,vex")
10896    (set_attr "mode" "TI")])
10898 (define_expand "vcond<V_512:mode><VI_512:mode>"
10899   [(set (match_operand:V_512 0 "register_operand")
10900         (if_then_else:V_512
10901           (match_operator 3 ""
10902             [(match_operand:VI_512 4 "nonimmediate_operand")
10903              (match_operand:VI_512 5 "general_operand")])
10904           (match_operand:V_512 1)
10905           (match_operand:V_512 2)))]
10906   "TARGET_AVX512F
10907    && (GET_MODE_NUNITS (<V_512:MODE>mode)
10908        == GET_MODE_NUNITS (<VI_512:MODE>mode))"
10910   bool ok = ix86_expand_int_vcond (operands);
10911   gcc_assert (ok);
10912   DONE;
10915 (define_expand "vcond<V_256:mode><VI_256:mode>"
10916   [(set (match_operand:V_256 0 "register_operand")
10917         (if_then_else:V_256
10918           (match_operator 3 ""
10919             [(match_operand:VI_256 4 "nonimmediate_operand")
10920              (match_operand:VI_256 5 "general_operand")])
10921           (match_operand:V_256 1)
10922           (match_operand:V_256 2)))]
10923   "TARGET_AVX2
10924    && (GET_MODE_NUNITS (<V_256:MODE>mode)
10925        == GET_MODE_NUNITS (<VI_256:MODE>mode))"
10927   bool ok = ix86_expand_int_vcond (operands);
10928   gcc_assert (ok);
10929   DONE;
10932 (define_expand "vcond<V_128:mode><VI124_128:mode>"
10933   [(set (match_operand:V_128 0 "register_operand")
10934         (if_then_else:V_128
10935           (match_operator 3 ""
10936             [(match_operand:VI124_128 4 "vector_operand")
10937              (match_operand:VI124_128 5 "general_operand")])
10938           (match_operand:V_128 1)
10939           (match_operand:V_128 2)))]
10940   "TARGET_SSE2
10941    && (GET_MODE_NUNITS (<V_128:MODE>mode)
10942        == GET_MODE_NUNITS (<VI124_128:MODE>mode))"
10944   bool ok = ix86_expand_int_vcond (operands);
10945   gcc_assert (ok);
10946   DONE;
10949 (define_expand "vcond<VI8F_128:mode>v2di"
10950   [(set (match_operand:VI8F_128 0 "register_operand")
10951         (if_then_else:VI8F_128
10952           (match_operator 3 ""
10953             [(match_operand:V2DI 4 "vector_operand")
10954              (match_operand:V2DI 5 "general_operand")])
10955           (match_operand:VI8F_128 1)
10956           (match_operand:VI8F_128 2)))]
10957   "TARGET_SSE4_2"
10959   bool ok = ix86_expand_int_vcond (operands);
10960   gcc_assert (ok);
10961   DONE;
10964 (define_expand "vcondu<V_512:mode><VI_512:mode>"
10965   [(set (match_operand:V_512 0 "register_operand")
10966         (if_then_else:V_512
10967           (match_operator 3 ""
10968             [(match_operand:VI_512 4 "nonimmediate_operand")
10969              (match_operand:VI_512 5 "nonimmediate_operand")])
10970           (match_operand:V_512 1 "general_operand")
10971           (match_operand:V_512 2 "general_operand")))]
10972   "TARGET_AVX512F
10973    && (GET_MODE_NUNITS (<V_512:MODE>mode)
10974        == GET_MODE_NUNITS (<VI_512:MODE>mode))"
10976   bool ok = ix86_expand_int_vcond (operands);
10977   gcc_assert (ok);
10978   DONE;
10981 (define_expand "vcondu<V_256:mode><VI_256:mode>"
10982   [(set (match_operand:V_256 0 "register_operand")
10983         (if_then_else:V_256
10984           (match_operator 3 ""
10985             [(match_operand:VI_256 4 "nonimmediate_operand")
10986              (match_operand:VI_256 5 "nonimmediate_operand")])
10987           (match_operand:V_256 1 "general_operand")
10988           (match_operand:V_256 2 "general_operand")))]
10989   "TARGET_AVX2
10990    && (GET_MODE_NUNITS (<V_256:MODE>mode)
10991        == GET_MODE_NUNITS (<VI_256:MODE>mode))"
10993   bool ok = ix86_expand_int_vcond (operands);
10994   gcc_assert (ok);
10995   DONE;
10998 (define_expand "vcondu<V_128:mode><VI124_128:mode>"
10999   [(set (match_operand:V_128 0 "register_operand")
11000         (if_then_else:V_128
11001           (match_operator 3 ""
11002             [(match_operand:VI124_128 4 "vector_operand")
11003              (match_operand:VI124_128 5 "vector_operand")])
11004           (match_operand:V_128 1 "general_operand")
11005           (match_operand:V_128 2 "general_operand")))]
11006   "TARGET_SSE2
11007    && (GET_MODE_NUNITS (<V_128:MODE>mode)
11008        == GET_MODE_NUNITS (<VI124_128:MODE>mode))"
11010   bool ok = ix86_expand_int_vcond (operands);
11011   gcc_assert (ok);
11012   DONE;
11015 (define_expand "vcondu<VI8F_128:mode>v2di"
11016   [(set (match_operand:VI8F_128 0 "register_operand")
11017         (if_then_else:VI8F_128
11018           (match_operator 3 ""
11019             [(match_operand:V2DI 4 "vector_operand")
11020              (match_operand:V2DI 5 "vector_operand")])
11021           (match_operand:VI8F_128 1 "general_operand")
11022           (match_operand:VI8F_128 2 "general_operand")))]
11023   "TARGET_SSE4_2"
11025   bool ok = ix86_expand_int_vcond (operands);
11026   gcc_assert (ok);
11027   DONE;
11030 (define_mode_iterator VEC_PERM_AVX2
11031   [V16QI V8HI V4SI V2DI V4SF V2DF
11032    (V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
11033    (V8SI "TARGET_AVX2") (V4DI "TARGET_AVX2")
11034    (V8SF "TARGET_AVX2") (V4DF "TARGET_AVX2")
11035    (V16SF "TARGET_AVX512F") (V8DF "TARGET_AVX512F")
11036    (V16SI "TARGET_AVX512F") (V8DI "TARGET_AVX512F")
11037    (V32HI "TARGET_AVX512BW") (V64QI "TARGET_AVX512VBMI")])
11039 (define_expand "vec_perm<mode>"
11040   [(match_operand:VEC_PERM_AVX2 0 "register_operand")
11041    (match_operand:VEC_PERM_AVX2 1 "register_operand")
11042    (match_operand:VEC_PERM_AVX2 2 "register_operand")
11043    (match_operand:<sseintvecmode> 3 "register_operand")]
11044   "TARGET_SSSE3 || TARGET_AVX || TARGET_XOP"
11046   ix86_expand_vec_perm (operands);
11047   DONE;
11050 (define_mode_iterator VEC_PERM_CONST
11051   [(V4SF "TARGET_SSE") (V4SI "TARGET_SSE")
11052    (V2DF "TARGET_SSE") (V2DI "TARGET_SSE")
11053    (V16QI "TARGET_SSE2") (V8HI "TARGET_SSE2")
11054    (V8SF "TARGET_AVX") (V4DF "TARGET_AVX")
11055    (V8SI "TARGET_AVX") (V4DI "TARGET_AVX")
11056    (V32QI "TARGET_AVX2") (V16HI "TARGET_AVX2")
11057    (V16SI "TARGET_AVX512F") (V8DI "TARGET_AVX512F")
11058    (V16SF "TARGET_AVX512F") (V8DF "TARGET_AVX512F")
11059    (V32HI "TARGET_AVX512BW") (V64QI "TARGET_AVX512BW")])
11061 (define_expand "vec_perm_const<mode>"
11062   [(match_operand:VEC_PERM_CONST 0 "register_operand")
11063    (match_operand:VEC_PERM_CONST 1 "register_operand")
11064    (match_operand:VEC_PERM_CONST 2 "register_operand")
11065    (match_operand:<sseintvecmode> 3)]
11066   ""
11068   if (ix86_expand_vec_perm_const (operands))
11069     DONE;
11070   else
11071     FAIL;
11074 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11076 ;; Parallel bitwise logical operations
11078 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11080 (define_expand "one_cmpl<mode>2"
11081   [(set (match_operand:VI 0 "register_operand")
11082         (xor:VI (match_operand:VI 1 "vector_operand")
11083                 (match_dup 2)))]
11084   "TARGET_SSE"
11086   int i, n = GET_MODE_NUNITS (<MODE>mode);
11087   rtvec v = rtvec_alloc (n);
11089   for (i = 0; i < n; ++i)
11090     RTVEC_ELT (v, i) = constm1_rtx;
11092   operands[2] = force_reg (<MODE>mode, gen_rtx_CONST_VECTOR (<MODE>mode, v));
11095 (define_expand "<sse2_avx2>_andnot<mode>3"
11096   [(set (match_operand:VI_AVX2 0 "register_operand")
11097         (and:VI_AVX2
11098           (not:VI_AVX2 (match_operand:VI_AVX2 1 "register_operand"))
11099           (match_operand:VI_AVX2 2 "vector_operand")))]
11100   "TARGET_SSE2")
11102 (define_expand "<sse2_avx2>_andnot<mode>3_mask"
11103   [(set (match_operand:VI48_AVX512VL 0 "register_operand")
11104         (vec_merge:VI48_AVX512VL
11105           (and:VI48_AVX512VL
11106             (not:VI48_AVX512VL
11107               (match_operand:VI48_AVX512VL 1 "register_operand"))
11108             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand"))
11109           (match_operand:VI48_AVX512VL 3 "vector_move_operand")
11110           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
11111   "TARGET_AVX512F")
11113 (define_expand "<sse2_avx2>_andnot<mode>3_mask"
11114   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
11115         (vec_merge:VI12_AVX512VL
11116           (and:VI12_AVX512VL
11117             (not:VI12_AVX512VL
11118               (match_operand:VI12_AVX512VL 1 "register_operand"))
11119             (match_operand:VI12_AVX512VL 2 "nonimmediate_operand"))
11120           (match_operand:VI12_AVX512VL 3 "vector_move_operand")
11121           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
11122   "TARGET_AVX512BW")
11124 (define_insn "*andnot<mode>3"
11125   [(set (match_operand:VI 0 "register_operand" "=x,v")
11126         (and:VI
11127           (not:VI (match_operand:VI 1 "register_operand" "0,v"))
11128           (match_operand:VI 2 "vector_operand" "xBm,vm")))]
11129   "TARGET_SSE"
11131   static char buf[64];
11132   const char *ops;
11133   const char *tmp;
11135   switch (get_attr_mode (insn))
11136     {
11137     case MODE_XI:
11138       gcc_assert (TARGET_AVX512F);
11139     case MODE_OI:
11140       gcc_assert (TARGET_AVX2);
11141     case MODE_TI:
11142       gcc_assert (TARGET_SSE2);
11143       switch (<MODE>mode)
11144         {
11145         case V64QImode:
11146         case V32HImode:
11147           /* There is no vpandnb or vpandnw instruction, nor vpandn for
11148              512-bit vectors. Use vpandnq instead.  */
11149           tmp = "pandnq";
11150           break;
11151         case V16SImode:
11152         case V8DImode:
11153           tmp = "pandn<ssemodesuffix>";
11154           break;
11155         case V8SImode:
11156         case V4DImode:
11157         case V4SImode:
11158         case V2DImode:
11159           tmp = TARGET_AVX512VL ? "pandn<ssemodesuffix>" : "pandn";
11160           break;
11161         default:
11162           tmp = TARGET_AVX512VL ? "pandnq" : "pandn";
11163           break;
11164         }
11165       break;
11167     case MODE_V16SF:
11168       gcc_assert (TARGET_AVX512F);
11169     case MODE_V8SF:
11170       gcc_assert (TARGET_AVX);
11171     case MODE_V4SF:
11172       gcc_assert (TARGET_SSE);
11174       tmp = "andnps";
11175       break;
11177     default:
11178       gcc_unreachable ();
11179     }
11181   switch (which_alternative)
11182     {
11183     case 0:
11184       ops = "%s\t{%%2, %%0|%%0, %%2}";
11185       break;
11186     case 1:
11187       ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
11188       break;
11189     default:
11190       gcc_unreachable ();
11191     }
11193   snprintf (buf, sizeof (buf), ops, tmp);
11194   return buf;
11196   [(set_attr "isa" "noavx,avx")
11197    (set_attr "type" "sselog")
11198    (set (attr "prefix_data16")
11199      (if_then_else
11200        (and (eq_attr "alternative" "0")
11201             (eq_attr "mode" "TI"))
11202        (const_string "1")
11203        (const_string "*")))
11204    (set_attr "prefix" "orig,vex")
11205    (set (attr "mode")
11206         (cond [(and (match_test "<MODE_SIZE> == 16")
11207                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
11208                  (const_string "<ssePSmode>")
11209                (match_test "TARGET_AVX2")
11210                  (const_string "<sseinsnmode>")
11211                (match_test "TARGET_AVX")
11212                  (if_then_else
11213                    (match_test "<MODE_SIZE> > 16")
11214                    (const_string "V8SF")
11215                    (const_string "<sseinsnmode>"))
11216                (ior (not (match_test "TARGET_SSE2"))
11217                     (match_test "optimize_function_for_size_p (cfun)"))
11218                  (const_string "V4SF")
11219               ]
11220               (const_string "<sseinsnmode>")))])
11222 (define_insn "*andnot<mode>3_mask"
11223   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
11224         (vec_merge:VI48_AVX512VL
11225           (and:VI48_AVX512VL
11226             (not:VI48_AVX512VL
11227               (match_operand:VI48_AVX512VL 1 "register_operand" "v"))
11228             (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm"))
11229           (match_operand:VI48_AVX512VL 3 "vector_move_operand" "0C")
11230           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
11231   "TARGET_AVX512F"
11232   "vpandn<ssemodesuffix>\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}";
11233   [(set_attr "type" "sselog")
11234    (set_attr "prefix" "evex")
11235    (set_attr "mode" "<sseinsnmode>")])
11237 (define_expand "<code><mode>3"
11238   [(set (match_operand:VI 0 "register_operand")
11239         (any_logic:VI
11240           (match_operand:VI 1 "nonimmediate_or_const_vector_operand")
11241           (match_operand:VI 2 "nonimmediate_or_const_vector_operand")))]
11242   "TARGET_SSE"
11244   ix86_expand_vector_logical_operator (<CODE>, <MODE>mode, operands);
11245   DONE;
11248 (define_insn "<mask_codefor><code><mode>3<mask_name>"
11249   [(set (match_operand:VI48_AVX_AVX512F 0 "register_operand" "=x,v")
11250         (any_logic:VI48_AVX_AVX512F
11251           (match_operand:VI48_AVX_AVX512F 1 "vector_operand" "%0,v")
11252           (match_operand:VI48_AVX_AVX512F 2 "vector_operand" "xBm,vm")))]
11253   "TARGET_SSE && <mask_mode512bit_condition>
11254    && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
11256   static char buf[64];
11257   const char *ops;
11258   const char *tmp;
11260   switch (get_attr_mode (insn))
11261     {
11262     case MODE_XI:
11263       gcc_assert (TARGET_AVX512F);
11264     case MODE_OI:
11265       gcc_assert (TARGET_AVX2 || TARGET_AVX512VL);
11266     case MODE_TI:
11267       gcc_assert (TARGET_SSE2 || TARGET_AVX512VL);
11268       switch (<MODE>mode)
11269       {
11270         case V16SImode:
11271         case V8DImode:
11272           if (TARGET_AVX512F)
11273           {
11274             tmp = "p<logic><ssemodesuffix>";
11275             break;
11276           }
11277         case V8SImode:
11278         case V4DImode:
11279         case V4SImode:
11280         case V2DImode:
11281           tmp = TARGET_AVX512VL ? "p<logic><ssemodesuffix>" : "p<logic>";
11282           break;
11283         default:
11284           gcc_unreachable ();
11285       }
11286       break;
11288    case MODE_V8SF:
11289       gcc_assert (TARGET_AVX);
11290    case MODE_V4SF:
11291       gcc_assert (TARGET_SSE);
11292       gcc_assert (!<mask_applied>);
11293       tmp = "<logic>ps";
11294       break;
11296    default:
11297       gcc_unreachable ();
11298    }
11300   switch (which_alternative)
11301     {
11302     case 0:
11303       if (<mask_applied>)
11304         ops = "v%s\t{%%2, %%0, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%0, %%2}";
11305       else
11306         ops = "%s\t{%%2, %%0|%%0, %%2}";
11307       break;
11308     case 1:
11309       ops = "v%s\t{%%2, %%1, %%0<mask_operand3_1>|%%0<mask_operand3_1>, %%1, %%2}";
11310       break;
11311     default:
11312       gcc_unreachable ();
11313     }
11315   snprintf (buf, sizeof (buf), ops, tmp);
11316   return buf;
11318   [(set_attr "isa" "noavx,avx")
11319    (set_attr "type" "sselog")
11320    (set (attr "prefix_data16")
11321      (if_then_else
11322        (and (eq_attr "alternative" "0")
11323             (eq_attr "mode" "TI"))
11324        (const_string "1")
11325        (const_string "*")))
11326    (set_attr "prefix" "<mask_prefix3>")
11327    (set (attr "mode")
11328         (cond [(and (match_test "<MODE_SIZE> == 16")
11329                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
11330                  (const_string "<ssePSmode>")
11331                (match_test "TARGET_AVX2")
11332                  (const_string "<sseinsnmode>")
11333                (match_test "TARGET_AVX")
11334                  (if_then_else
11335                    (match_test "<MODE_SIZE> > 16")
11336                    (const_string "V8SF")
11337                    (const_string "<sseinsnmode>"))
11338                (ior (not (match_test "TARGET_SSE2"))
11339                     (match_test "optimize_function_for_size_p (cfun)"))
11340                  (const_string "V4SF")
11341               ]
11342               (const_string "<sseinsnmode>")))])
11344 (define_insn "*<code><mode>3"
11345   [(set (match_operand:VI12_AVX_AVX512F 0 "register_operand" "=x,v")
11346         (any_logic: VI12_AVX_AVX512F
11347           (match_operand:VI12_AVX_AVX512F 1 "vector_operand" "%0,v")
11348           (match_operand:VI12_AVX_AVX512F 2 "vector_operand" "xBm,vm")))]
11349   "TARGET_SSE && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
11351   static char buf[64];
11352   const char *ops;
11353   const char *tmp;
11354   const char *ssesuffix;
11356   switch (get_attr_mode (insn))
11357     {
11358     case MODE_XI:
11359       gcc_assert (TARGET_AVX512F);
11360     case MODE_OI:
11361       gcc_assert (TARGET_AVX2 || TARGET_AVX512VL);
11362     case MODE_TI:
11363       gcc_assert (TARGET_SSE2 || TARGET_AVX512VL);
11364       switch (<MODE>mode)
11365         {
11366         case V64QImode:
11367         case V32HImode:
11368           if (TARGET_AVX512F)
11369           {
11370             tmp = "p<logic>";
11371             ssesuffix = "q";
11372             break;
11373           }
11374         case V32QImode:
11375         case V16HImode:
11376         case V16QImode:
11377         case V8HImode:
11378           if (TARGET_AVX512VL || TARGET_AVX2 || TARGET_SSE2)
11379           {
11380             tmp = "p<logic>";
11381             ssesuffix = TARGET_AVX512VL ? "q" : "";
11382             break;
11383           }
11384         default:
11385           gcc_unreachable ();
11386       }
11387       break;
11389    case MODE_V8SF:
11390       gcc_assert (TARGET_AVX);
11391    case MODE_V4SF:
11392       gcc_assert (TARGET_SSE);
11393       tmp = "<logic>ps";
11394       ssesuffix = "";
11395       break;
11397    default:
11398       gcc_unreachable ();
11399    }
11401   switch (which_alternative)
11402     {
11403     case 0:
11404       ops = "%s\t{%%2, %%0|%%0, %%2}";
11405       snprintf (buf, sizeof (buf), ops, tmp);
11406       break;
11407     case 1:
11408       ops = "v%s%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
11409       snprintf (buf, sizeof (buf), ops, tmp, ssesuffix);
11410       break;
11411     default:
11412       gcc_unreachable ();
11413     }
11415   return buf;
11417   [(set_attr "isa" "noavx,avx")
11418    (set_attr "type" "sselog")
11419    (set (attr "prefix_data16")
11420      (if_then_else
11421        (and (eq_attr "alternative" "0")
11422             (eq_attr "mode" "TI"))
11423        (const_string "1")
11424        (const_string "*")))
11425    (set_attr "prefix" "<mask_prefix3>")
11426    (set (attr "mode")
11427         (cond [(and (match_test "<MODE_SIZE> == 16")
11428                     (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL"))
11429                  (const_string "<ssePSmode>")
11430                (match_test "TARGET_AVX2")
11431                  (const_string "<sseinsnmode>")
11432                (match_test "TARGET_AVX")
11433                  (if_then_else
11434                    (match_test "<MODE_SIZE> > 16")
11435                    (const_string "V8SF")
11436                    (const_string "<sseinsnmode>"))
11437                (ior (not (match_test "TARGET_SSE2"))
11438                     (match_test "optimize_function_for_size_p (cfun)"))
11439                  (const_string "V4SF")
11440               ]
11441               (const_string "<sseinsnmode>")))])
11443 (define_insn "<avx512>_testm<mode>3<mask_scalar_merge_name>"
11444   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11445         (unspec:<avx512fmaskmode>
11446          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
11447           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")]
11448          UNSPEC_TESTM))]
11449   "TARGET_AVX512BW"
11450   "vptestm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11451   [(set_attr "prefix" "evex")
11452    (set_attr "mode"  "<sseinsnmode>")])
11454 (define_insn "<avx512>_testm<mode>3<mask_scalar_merge_name>"
11455   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11456         (unspec:<avx512fmaskmode>
11457          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
11458           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")]
11459          UNSPEC_TESTM))]
11460   "TARGET_AVX512F"
11461   "vptestm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11462   [(set_attr "prefix" "evex")
11463    (set_attr "mode"  "<sseinsnmode>")])
11465 (define_insn "<avx512>_testnm<mode>3<mask_scalar_merge_name>"
11466   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11467         (unspec:<avx512fmaskmode>
11468          [(match_operand:VI12_AVX512VL 1 "register_operand" "v")
11469           (match_operand:VI12_AVX512VL 2 "nonimmediate_operand" "vm")]
11470          UNSPEC_TESTNM))]
11471   "TARGET_AVX512BW"
11472   "vptestnm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11473   [(set_attr "prefix" "evex")
11474    (set_attr "mode"  "<sseinsnmode>")])
11476 (define_insn "<avx512>_testnm<mode>3<mask_scalar_merge_name>"
11477   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
11478         (unspec:<avx512fmaskmode>
11479          [(match_operand:VI48_AVX512VL 1 "register_operand" "v")
11480           (match_operand:VI48_AVX512VL 2 "nonimmediate_operand" "vm")]
11481          UNSPEC_TESTNM))]
11482   "TARGET_AVX512F"
11483   "vptestnm<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}"
11484   [(set_attr "prefix" "evex")
11485    (set_attr "mode"  "<sseinsnmode>")])
11487 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11489 ;; Parallel integral element swizzling
11491 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11493 (define_expand "vec_pack_trunc_<mode>"
11494   [(match_operand:<ssepackmode> 0 "register_operand")
11495    (match_operand:VI248_AVX2_8_AVX512F_24_AVX512BW 1 "register_operand")
11496    (match_operand:VI248_AVX2_8_AVX512F_24_AVX512BW 2 "register_operand")]
11497   "TARGET_SSE2"
11499   rtx op1 = gen_lowpart (<ssepackmode>mode, operands[1]);
11500   rtx op2 = gen_lowpart (<ssepackmode>mode, operands[2]);
11501   ix86_expand_vec_extract_even_odd (operands[0], op1, op2, 0);
11502   DONE;
11505 (define_expand "vec_pack_trunc_qi"
11506   [(set (match_operand:HI 0 ("register_operand"))
11507         (ior:HI (ashift:HI (zero_extend:HI (match_operand:QI 2 ("register_operand")))
11508                            (const_int 8))
11509                 (zero_extend:HI (match_operand:QI 1 ("register_operand")))))]
11510   "TARGET_AVX512F")
11512 (define_expand "vec_pack_trunc_<mode>"
11513   [(set (match_operand:<DOUBLEMASKMODE> 0 ("register_operand"))
11514         (ior:<DOUBLEMASKMODE> (ashift:<DOUBLEMASKMODE> (zero_extend:<DOUBLEMASKMODE> (match_operand:SWI24 2 ("register_operand")))
11515                            (match_dup 3))
11516                 (zero_extend:<DOUBLEMASKMODE> (match_operand:SWI24 1 ("register_operand")))))]
11517   "TARGET_AVX512BW"
11519   operands[3] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
11522 (define_insn "<sse2_avx2>_packsswb<mask_name>"
11523   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x,v")
11524         (vec_concat:VI1_AVX512
11525           (ss_truncate:<ssehalfvecmode>
11526             (match_operand:<sseunpackmode> 1 "register_operand" "0,x,v"))
11527           (ss_truncate:<ssehalfvecmode>
11528             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,xm,vm"))))]
11529   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
11530   "@
11531    packsswb\t{%2, %0|%0, %2}
11532    vpacksswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
11533    vpacksswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11534   [(set_attr "isa" "noavx,avx,avx512bw")
11535    (set_attr "type" "sselog")
11536    (set_attr "prefix_data16" "1,*,*")
11537    (set_attr "prefix" "orig,<mask_prefix>,evex")
11538    (set_attr "mode" "<sseinsnmode>")])
11540 (define_insn "<sse2_avx2>_packssdw<mask_name>"
11541   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,x,v")
11542         (vec_concat:VI2_AVX2
11543           (ss_truncate:<ssehalfvecmode>
11544             (match_operand:<sseunpackmode> 1 "register_operand" "0,x,v"))
11545           (ss_truncate:<ssehalfvecmode>
11546             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,xm,vm"))))]
11547   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
11548   "@
11549    packssdw\t{%2, %0|%0, %2}
11550    vpackssdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
11551    vpackssdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11552   [(set_attr "isa" "noavx,avx,avx512bw")
11553    (set_attr "type" "sselog")
11554    (set_attr "prefix_data16" "1,*,*")
11555    (set_attr "prefix" "orig,<mask_prefix>,evex")
11556    (set_attr "mode" "<sseinsnmode>")])
11558 (define_insn "<sse2_avx2>_packuswb<mask_name>"
11559   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x,v")
11560         (vec_concat:VI1_AVX512
11561           (us_truncate:<ssehalfvecmode>
11562             (match_operand:<sseunpackmode> 1 "register_operand" "0,x,v"))
11563           (us_truncate:<ssehalfvecmode>
11564             (match_operand:<sseunpackmode> 2 "vector_operand" "xBm,xm,vm"))))]
11565   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
11566   "@
11567    packuswb\t{%2, %0|%0, %2}
11568    vpackuswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
11569    vpackuswb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11570   [(set_attr "isa" "noavx,avx,avx512bw")
11571    (set_attr "type" "sselog")
11572    (set_attr "prefix_data16" "1,*,*")
11573    (set_attr "prefix" "orig,<mask_prefix>,evex")
11574    (set_attr "mode" "<sseinsnmode>")])
11576 (define_insn "avx512bw_interleave_highv64qi<mask_name>"
11577   [(set (match_operand:V64QI 0 "register_operand" "=v")
11578         (vec_select:V64QI
11579           (vec_concat:V128QI
11580             (match_operand:V64QI 1 "register_operand" "v")
11581             (match_operand:V64QI 2 "nonimmediate_operand" "vm"))
11582           (parallel [(const_int 8)  (const_int 72)
11583                      (const_int 9)  (const_int 73)
11584                      (const_int 10) (const_int 74)
11585                      (const_int 11) (const_int 75)
11586                      (const_int 12) (const_int 76)
11587                      (const_int 13) (const_int 77)
11588                      (const_int 14) (const_int 78)
11589                      (const_int 15) (const_int 79)
11590                      (const_int 24) (const_int 88)
11591                      (const_int 25) (const_int 89)
11592                      (const_int 26) (const_int 90)
11593                      (const_int 27) (const_int 91)
11594                      (const_int 28) (const_int 92)
11595                      (const_int 29) (const_int 93)
11596                      (const_int 30) (const_int 94)
11597                      (const_int 31) (const_int 95)
11598                      (const_int 40) (const_int 104)
11599                      (const_int 41) (const_int 105)
11600                      (const_int 42) (const_int 106)
11601                      (const_int 43) (const_int 107)
11602                      (const_int 44) (const_int 108)
11603                      (const_int 45) (const_int 109)
11604                      (const_int 46) (const_int 110)
11605                      (const_int 47) (const_int 111)
11606                      (const_int 56) (const_int 120)
11607                      (const_int 57) (const_int 121)
11608                      (const_int 58) (const_int 122)
11609                      (const_int 59) (const_int 123)
11610                      (const_int 60) (const_int 124)
11611                      (const_int 61) (const_int 125)
11612                      (const_int 62) (const_int 126)
11613                      (const_int 63) (const_int 127)])))]
11614   "TARGET_AVX512BW"
11615   "vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11616   [(set_attr "type" "sselog")
11617    (set_attr "prefix" "evex")
11618    (set_attr "mode" "XI")])
11620 (define_insn "avx2_interleave_highv32qi<mask_name>"
11621   [(set (match_operand:V32QI 0 "register_operand" "=v")
11622         (vec_select:V32QI
11623           (vec_concat:V64QI
11624             (match_operand:V32QI 1 "register_operand" "v")
11625             (match_operand:V32QI 2 "nonimmediate_operand" "vm"))
11626           (parallel [(const_int 8)  (const_int 40)
11627                      (const_int 9)  (const_int 41)
11628                      (const_int 10) (const_int 42)
11629                      (const_int 11) (const_int 43)
11630                      (const_int 12) (const_int 44)
11631                      (const_int 13) (const_int 45)
11632                      (const_int 14) (const_int 46)
11633                      (const_int 15) (const_int 47)
11634                      (const_int 24) (const_int 56)
11635                      (const_int 25) (const_int 57)
11636                      (const_int 26) (const_int 58)
11637                      (const_int 27) (const_int 59)
11638                      (const_int 28) (const_int 60)
11639                      (const_int 29) (const_int 61)
11640                      (const_int 30) (const_int 62)
11641                      (const_int 31) (const_int 63)])))]
11642   "TARGET_AVX2 && <mask_avx512vl_condition>"
11643   "vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11644   [(set_attr "type" "sselog")
11645    (set_attr "prefix" "<mask_prefix>")
11646    (set_attr "mode" "OI")])
11648 (define_insn "vec_interleave_highv16qi<mask_name>"
11649   [(set (match_operand:V16QI 0 "register_operand" "=x,v")
11650         (vec_select:V16QI
11651           (vec_concat:V32QI
11652             (match_operand:V16QI 1 "register_operand" "0,v")
11653             (match_operand:V16QI 2 "vector_operand" "xBm,vm"))
11654           (parallel [(const_int 8)  (const_int 24)
11655                      (const_int 9)  (const_int 25)
11656                      (const_int 10) (const_int 26)
11657                      (const_int 11) (const_int 27)
11658                      (const_int 12) (const_int 28)
11659                      (const_int 13) (const_int 29)
11660                      (const_int 14) (const_int 30)
11661                      (const_int 15) (const_int 31)])))]
11662   "TARGET_SSE2 && <mask_avx512vl_condition>"
11663   "@
11664    punpckhbw\t{%2, %0|%0, %2}
11665    vpunpckhbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11666   [(set_attr "isa" "noavx,avx")
11667    (set_attr "type" "sselog")
11668    (set_attr "prefix_data16" "1,*")
11669    (set_attr "prefix" "orig,<mask_prefix>")
11670    (set_attr "mode" "TI")])
11672 (define_insn "avx512bw_interleave_lowv64qi<mask_name>"
11673   [(set (match_operand:V64QI 0 "register_operand" "=v")
11674         (vec_select:V64QI
11675           (vec_concat:V128QI
11676             (match_operand:V64QI 1 "register_operand" "v")
11677             (match_operand:V64QI 2 "nonimmediate_operand" "vm"))
11678           (parallel [(const_int 0) (const_int 64)
11679                      (const_int 1) (const_int 65)
11680                      (const_int 2) (const_int 66)
11681                      (const_int 3) (const_int 67)
11682                      (const_int 4) (const_int 68)
11683                      (const_int 5) (const_int 69)
11684                      (const_int 6) (const_int 70)
11685                      (const_int 7) (const_int 71)
11686                      (const_int 16) (const_int 80)
11687                      (const_int 17) (const_int 81)
11688                      (const_int 18) (const_int 82)
11689                      (const_int 19) (const_int 83)
11690                      (const_int 20) (const_int 84)
11691                      (const_int 21) (const_int 85)
11692                      (const_int 22) (const_int 86)
11693                      (const_int 23) (const_int 87)
11694                      (const_int 32) (const_int 96)
11695                      (const_int 33) (const_int 97)
11696                      (const_int 34) (const_int 98)
11697                      (const_int 35) (const_int 99)
11698                      (const_int 36) (const_int 100)
11699                      (const_int 37) (const_int 101)
11700                      (const_int 38) (const_int 102)
11701                      (const_int 39) (const_int 103)
11702                      (const_int 48) (const_int 112)
11703                      (const_int 49) (const_int 113)
11704                      (const_int 50) (const_int 114)
11705                      (const_int 51) (const_int 115)
11706                      (const_int 52) (const_int 116)
11707                      (const_int 53) (const_int 117)
11708                      (const_int 54) (const_int 118)
11709                      (const_int 55) (const_int 119)])))]
11710   "TARGET_AVX512BW"
11711   "vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11712   [(set_attr "type" "sselog")
11713    (set_attr "prefix" "evex")
11714    (set_attr "mode" "XI")])
11716 (define_insn "avx2_interleave_lowv32qi<mask_name>"
11717   [(set (match_operand:V32QI 0 "register_operand" "=v")
11718         (vec_select:V32QI
11719           (vec_concat:V64QI
11720             (match_operand:V32QI 1 "register_operand" "v")
11721             (match_operand:V32QI 2 "nonimmediate_operand" "vm"))
11722           (parallel [(const_int 0) (const_int 32)
11723                      (const_int 1) (const_int 33)
11724                      (const_int 2) (const_int 34)
11725                      (const_int 3) (const_int 35)
11726                      (const_int 4) (const_int 36)
11727                      (const_int 5) (const_int 37)
11728                      (const_int 6) (const_int 38)
11729                      (const_int 7) (const_int 39)
11730                      (const_int 16) (const_int 48)
11731                      (const_int 17) (const_int 49)
11732                      (const_int 18) (const_int 50)
11733                      (const_int 19) (const_int 51)
11734                      (const_int 20) (const_int 52)
11735                      (const_int 21) (const_int 53)
11736                      (const_int 22) (const_int 54)
11737                      (const_int 23) (const_int 55)])))]
11738   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
11739   "vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11740   [(set_attr "type" "sselog")
11741    (set_attr "prefix" "maybe_vex")
11742    (set_attr "mode" "OI")])
11744 (define_insn "vec_interleave_lowv16qi<mask_name>"
11745   [(set (match_operand:V16QI 0 "register_operand" "=x,v")
11746         (vec_select:V16QI
11747           (vec_concat:V32QI
11748             (match_operand:V16QI 1 "register_operand" "0,v")
11749             (match_operand:V16QI 2 "vector_operand" "xBm,vm"))
11750           (parallel [(const_int 0) (const_int 16)
11751                      (const_int 1) (const_int 17)
11752                      (const_int 2) (const_int 18)
11753                      (const_int 3) (const_int 19)
11754                      (const_int 4) (const_int 20)
11755                      (const_int 5) (const_int 21)
11756                      (const_int 6) (const_int 22)
11757                      (const_int 7) (const_int 23)])))]
11758   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
11759   "@
11760    punpcklbw\t{%2, %0|%0, %2}
11761    vpunpcklbw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11762   [(set_attr "isa" "noavx,avx")
11763    (set_attr "type" "sselog")
11764    (set_attr "prefix_data16" "1,*")
11765    (set_attr "prefix" "orig,vex")
11766    (set_attr "mode" "TI")])
11768 (define_insn "avx512bw_interleave_highv32hi<mask_name>"
11769   [(set (match_operand:V32HI 0 "register_operand" "=v")
11770         (vec_select:V32HI
11771           (vec_concat:V64HI
11772             (match_operand:V32HI 1 "register_operand" "v")
11773             (match_operand:V32HI 2 "nonimmediate_operand" "vm"))
11774           (parallel [(const_int 4) (const_int 36)
11775                      (const_int 5) (const_int 37)
11776                      (const_int 6) (const_int 38)
11777                      (const_int 7) (const_int 39)
11778                      (const_int 12) (const_int 44)
11779                      (const_int 13) (const_int 45)
11780                      (const_int 14) (const_int 46)
11781                      (const_int 15) (const_int 47)
11782                      (const_int 20) (const_int 52)
11783                      (const_int 21) (const_int 53)
11784                      (const_int 22) (const_int 54)
11785                      (const_int 23) (const_int 55)
11786                      (const_int 28) (const_int 60)
11787                      (const_int 29) (const_int 61)
11788                      (const_int 30) (const_int 62)
11789                      (const_int 31) (const_int 63)])))]
11790   "TARGET_AVX512BW"
11791   "vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11792   [(set_attr "type" "sselog")
11793    (set_attr "prefix" "evex")
11794    (set_attr "mode" "XI")])
11796 (define_insn "avx2_interleave_highv16hi<mask_name>"
11797   [(set (match_operand:V16HI 0 "register_operand" "=v")
11798         (vec_select:V16HI
11799           (vec_concat:V32HI
11800             (match_operand:V16HI 1 "register_operand" "v")
11801             (match_operand:V16HI 2 "nonimmediate_operand" "vm"))
11802           (parallel [(const_int 4) (const_int 20)
11803                      (const_int 5) (const_int 21)
11804                      (const_int 6) (const_int 22)
11805                      (const_int 7) (const_int 23)
11806                      (const_int 12) (const_int 28)
11807                      (const_int 13) (const_int 29)
11808                      (const_int 14) (const_int 30)
11809                      (const_int 15) (const_int 31)])))]
11810   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
11811   "vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11812   [(set_attr "type" "sselog")
11813    (set_attr "prefix" "maybe_evex")
11814    (set_attr "mode" "OI")])
11816 (define_insn "vec_interleave_highv8hi<mask_name>"
11817   [(set (match_operand:V8HI 0 "register_operand" "=x,v")
11818         (vec_select:V8HI
11819           (vec_concat:V16HI
11820             (match_operand:V8HI 1 "register_operand" "0,v")
11821             (match_operand:V8HI 2 "vector_operand" "xBm,vm"))
11822           (parallel [(const_int 4) (const_int 12)
11823                      (const_int 5) (const_int 13)
11824                      (const_int 6) (const_int 14)
11825                      (const_int 7) (const_int 15)])))]
11826   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
11827   "@
11828    punpckhwd\t{%2, %0|%0, %2}
11829    vpunpckhwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11830   [(set_attr "isa" "noavx,avx")
11831    (set_attr "type" "sselog")
11832    (set_attr "prefix_data16" "1,*")
11833    (set_attr "prefix" "orig,maybe_vex")
11834    (set_attr "mode" "TI")])
11836 (define_insn "<mask_codefor>avx512bw_interleave_lowv32hi<mask_name>"
11837   [(set (match_operand:V32HI 0 "register_operand" "=v")
11838         (vec_select:V32HI
11839           (vec_concat:V64HI
11840             (match_operand:V32HI 1 "register_operand" "v")
11841             (match_operand:V32HI 2 "nonimmediate_operand" "vm"))
11842           (parallel [(const_int 0) (const_int 32)
11843                      (const_int 1) (const_int 33)
11844                      (const_int 2) (const_int 34)
11845                      (const_int 3) (const_int 35)
11846                      (const_int 8) (const_int 40)
11847                      (const_int 9) (const_int 41)
11848                      (const_int 10) (const_int 42)
11849                      (const_int 11) (const_int 43)
11850                      (const_int 16) (const_int 48)
11851                      (const_int 17) (const_int 49)
11852                      (const_int 18) (const_int 50)
11853                      (const_int 19) (const_int 51)
11854                      (const_int 24) (const_int 56)
11855                      (const_int 25) (const_int 57)
11856                      (const_int 26) (const_int 58)
11857                      (const_int 27) (const_int 59)])))]
11858   "TARGET_AVX512BW"
11859   "vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11860   [(set_attr "type" "sselog")
11861    (set_attr "prefix" "evex")
11862    (set_attr "mode" "XI")])
11864 (define_insn "avx2_interleave_lowv16hi<mask_name>"
11865   [(set (match_operand:V16HI 0 "register_operand" "=v")
11866         (vec_select:V16HI
11867           (vec_concat:V32HI
11868             (match_operand:V16HI 1 "register_operand" "v")
11869             (match_operand:V16HI 2 "nonimmediate_operand" "vm"))
11870           (parallel [(const_int 0) (const_int 16)
11871                      (const_int 1) (const_int 17)
11872                      (const_int 2) (const_int 18)
11873                      (const_int 3) (const_int 19)
11874                      (const_int 8) (const_int 24)
11875                      (const_int 9) (const_int 25)
11876                      (const_int 10) (const_int 26)
11877                      (const_int 11) (const_int 27)])))]
11878   "TARGET_AVX2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
11879   "vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11880   [(set_attr "type" "sselog")
11881    (set_attr "prefix" "maybe_evex")
11882    (set_attr "mode" "OI")])
11884 (define_insn "vec_interleave_lowv8hi<mask_name>"
11885   [(set (match_operand:V8HI 0 "register_operand" "=x,v")
11886         (vec_select:V8HI
11887           (vec_concat:V16HI
11888             (match_operand:V8HI 1 "register_operand" "0,v")
11889             (match_operand:V8HI 2 "vector_operand" "xBm,vm"))
11890           (parallel [(const_int 0) (const_int 8)
11891                      (const_int 1) (const_int 9)
11892                      (const_int 2) (const_int 10)
11893                      (const_int 3) (const_int 11)])))]
11894   "TARGET_SSE2 && <mask_avx512vl_condition> && <mask_avx512bw_condition>"
11895   "@
11896    punpcklwd\t{%2, %0|%0, %2}
11897    vpunpcklwd\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11898   [(set_attr "isa" "noavx,avx")
11899    (set_attr "type" "sselog")
11900    (set_attr "prefix_data16" "1,*")
11901    (set_attr "prefix" "orig,maybe_evex")
11902    (set_attr "mode" "TI")])
11904 (define_insn "avx2_interleave_highv8si<mask_name>"
11905   [(set (match_operand:V8SI 0 "register_operand" "=v")
11906         (vec_select:V8SI
11907           (vec_concat:V16SI
11908             (match_operand:V8SI 1 "register_operand" "v")
11909             (match_operand:V8SI 2 "nonimmediate_operand" "vm"))
11910           (parallel [(const_int 2) (const_int 10)
11911                      (const_int 3) (const_int 11)
11912                      (const_int 6) (const_int 14)
11913                      (const_int 7) (const_int 15)])))]
11914   "TARGET_AVX2 && <mask_avx512vl_condition>"
11915   "vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11916   [(set_attr "type" "sselog")
11917    (set_attr "prefix" "maybe_evex")
11918    (set_attr "mode" "OI")])
11920 (define_insn "<mask_codefor>avx512f_interleave_highv16si<mask_name>"
11921   [(set (match_operand:V16SI 0 "register_operand" "=v")
11922         (vec_select:V16SI
11923           (vec_concat:V32SI
11924             (match_operand:V16SI 1 "register_operand" "v")
11925             (match_operand:V16SI 2 "nonimmediate_operand" "vm"))
11926           (parallel [(const_int 2) (const_int 18)
11927                      (const_int 3) (const_int 19)
11928                      (const_int 6) (const_int 22)
11929                      (const_int 7) (const_int 23)
11930                      (const_int 10) (const_int 26)
11931                      (const_int 11) (const_int 27)
11932                      (const_int 14) (const_int 30)
11933                      (const_int 15) (const_int 31)])))]
11934   "TARGET_AVX512F"
11935   "vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11936   [(set_attr "type" "sselog")
11937    (set_attr "prefix" "evex")
11938    (set_attr "mode" "XI")])
11941 (define_insn "vec_interleave_highv4si<mask_name>"
11942   [(set (match_operand:V4SI 0 "register_operand" "=x,v")
11943         (vec_select:V4SI
11944           (vec_concat:V8SI
11945             (match_operand:V4SI 1 "register_operand" "0,v")
11946             (match_operand:V4SI 2 "vector_operand" "xBm,vm"))
11947           (parallel [(const_int 2) (const_int 6)
11948                      (const_int 3) (const_int 7)])))]
11949   "TARGET_SSE2 && <mask_avx512vl_condition>"
11950   "@
11951    punpckhdq\t{%2, %0|%0, %2}
11952    vpunpckhdq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11953   [(set_attr "isa" "noavx,avx")
11954    (set_attr "type" "sselog")
11955    (set_attr "prefix_data16" "1,*")
11956    (set_attr "prefix" "orig,maybe_vex")
11957    (set_attr "mode" "TI")])
11959 (define_insn "avx2_interleave_lowv8si<mask_name>"
11960   [(set (match_operand:V8SI 0 "register_operand" "=v")
11961         (vec_select:V8SI
11962           (vec_concat:V16SI
11963             (match_operand:V8SI 1 "register_operand" "v")
11964             (match_operand:V8SI 2 "nonimmediate_operand" "vm"))
11965           (parallel [(const_int 0) (const_int 8)
11966                      (const_int 1) (const_int 9)
11967                      (const_int 4) (const_int 12)
11968                      (const_int 5) (const_int 13)])))]
11969   "TARGET_AVX2 && <mask_avx512vl_condition>"
11970   "vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11971   [(set_attr "type" "sselog")
11972    (set_attr "prefix" "maybe_evex")
11973    (set_attr "mode" "OI")])
11975 (define_insn "<mask_codefor>avx512f_interleave_lowv16si<mask_name>"
11976   [(set (match_operand:V16SI 0 "register_operand" "=v")
11977         (vec_select:V16SI
11978           (vec_concat:V32SI
11979             (match_operand:V16SI 1 "register_operand" "v")
11980             (match_operand:V16SI 2 "nonimmediate_operand" "vm"))
11981           (parallel [(const_int 0) (const_int 16)
11982                      (const_int 1) (const_int 17)
11983                      (const_int 4) (const_int 20)
11984                      (const_int 5) (const_int 21)
11985                      (const_int 8) (const_int 24)
11986                      (const_int 9) (const_int 25)
11987                      (const_int 12) (const_int 28)
11988                      (const_int 13) (const_int 29)])))]
11989   "TARGET_AVX512F"
11990   "vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
11991   [(set_attr "type" "sselog")
11992    (set_attr "prefix" "evex")
11993    (set_attr "mode" "XI")])
11995 (define_insn "vec_interleave_lowv4si<mask_name>"
11996   [(set (match_operand:V4SI 0 "register_operand" "=x,v")
11997         (vec_select:V4SI
11998           (vec_concat:V8SI
11999             (match_operand:V4SI 1 "register_operand" "0,v")
12000             (match_operand:V4SI 2 "vector_operand" "xBm,vm"))
12001           (parallel [(const_int 0) (const_int 4)
12002                      (const_int 1) (const_int 5)])))]
12003   "TARGET_SSE2 && <mask_avx512vl_condition>"
12004   "@
12005    punpckldq\t{%2, %0|%0, %2}
12006    vpunpckldq\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12007   [(set_attr "isa" "noavx,avx")
12008    (set_attr "type" "sselog")
12009    (set_attr "prefix_data16" "1,*")
12010    (set_attr "prefix" "orig,vex")
12011    (set_attr "mode" "TI")])
12013 (define_expand "vec_interleave_high<mode>"
12014   [(match_operand:VI_256 0 "register_operand")
12015    (match_operand:VI_256 1 "register_operand")
12016    (match_operand:VI_256 2 "nonimmediate_operand")]
12017  "TARGET_AVX2"
12019   rtx t1 = gen_reg_rtx (<MODE>mode);
12020   rtx t2 = gen_reg_rtx (<MODE>mode);
12021   rtx t3 = gen_reg_rtx (V4DImode);
12022   emit_insn (gen_avx2_interleave_low<mode> (t1, operands[1], operands[2]));
12023   emit_insn (gen_avx2_interleave_high<mode> (t2,  operands[1], operands[2]));
12024   emit_insn (gen_avx2_permv2ti (t3, gen_lowpart (V4DImode, t1),
12025                                 gen_lowpart (V4DImode, t2),
12026                                 GEN_INT (1 + (3 << 4))));
12027   emit_move_insn (operands[0], gen_lowpart (<MODE>mode, t3));
12028   DONE;
12031 (define_expand "vec_interleave_low<mode>"
12032   [(match_operand:VI_256 0 "register_operand")
12033    (match_operand:VI_256 1 "register_operand")
12034    (match_operand:VI_256 2 "nonimmediate_operand")]
12035  "TARGET_AVX2"
12037   rtx t1 = gen_reg_rtx (<MODE>mode);
12038   rtx t2 = gen_reg_rtx (<MODE>mode);
12039   rtx t3 = gen_reg_rtx (V4DImode);
12040   emit_insn (gen_avx2_interleave_low<mode> (t1, operands[1], operands[2]));
12041   emit_insn (gen_avx2_interleave_high<mode> (t2, operands[1], operands[2]));
12042   emit_insn (gen_avx2_permv2ti (t3, gen_lowpart (V4DImode, t1),
12043                                 gen_lowpart (V4DImode, t2),
12044                                 GEN_INT (0 + (2 << 4))));
12045   emit_move_insn (operands[0], gen_lowpart (<MODE>mode, t3));
12046   DONE;
12049 ;; Modes handled by pinsr patterns.
12050 (define_mode_iterator PINSR_MODE
12051   [(V16QI "TARGET_SSE4_1") V8HI
12052    (V4SI "TARGET_SSE4_1")
12053    (V2DI "TARGET_SSE4_1 && TARGET_64BIT")])
12055 (define_mode_attr sse2p4_1
12056   [(V16QI "sse4_1") (V8HI "sse2")
12057    (V4SI "sse4_1") (V2DI "sse4_1")])
12059 (define_mode_attr pinsr_evex_isa
12060   [(V16QI "avx512bw") (V8HI "avx512bw")
12061    (V4SI "avx512dq") (V2DI "avx512dq")])
12063 ;; sse4_1_pinsrd must come before sse2_loadld since it is preferred.
12064 (define_insn "<sse2p4_1>_pinsr<ssemodesuffix>"
12065   [(set (match_operand:PINSR_MODE 0 "register_operand" "=x,x,x,x,v,v")
12066         (vec_merge:PINSR_MODE
12067           (vec_duplicate:PINSR_MODE
12068             (match_operand:<ssescalarmode> 2 "nonimmediate_operand" "r,m,r,m,r,m"))
12069           (match_operand:PINSR_MODE 1 "register_operand" "0,0,x,x,v,v")
12070           (match_operand:SI 3 "const_int_operand")))]
12071   "TARGET_SSE2
12072    && ((unsigned) exact_log2 (INTVAL (operands[3]))
12073        < GET_MODE_NUNITS (<MODE>mode))"
12075   operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])));
12077   switch (which_alternative)
12078     {
12079     case 0:
12080       if (GET_MODE_SIZE (<ssescalarmode>mode) < GET_MODE_SIZE (SImode))
12081         return "pinsr<ssemodesuffix>\t{%3, %k2, %0|%0, %k2, %3}";
12082       /* FALLTHRU */
12083     case 1:
12084       return "pinsr<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}";
12085     case 2:
12086     case 4:
12087       if (GET_MODE_SIZE (<ssescalarmode>mode) < GET_MODE_SIZE (SImode))
12088         return "vpinsr<ssemodesuffix>\t{%3, %k2, %1, %0|%0, %1, %k2, %3}";
12089       /* FALLTHRU */
12090     case 3:
12091     case 5:
12092       return "vpinsr<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
12093     default:
12094       gcc_unreachable ();
12095     }
12097   [(set_attr "isa" "noavx,noavx,avx,avx,<pinsr_evex_isa>,<pinsr_evex_isa>")
12098    (set_attr "type" "sselog")
12099    (set (attr "prefix_rex")
12100      (if_then_else
12101        (and (not (match_test "TARGET_AVX"))
12102             (eq (const_string "<MODE>mode") (const_string "V2DImode")))
12103        (const_string "1")
12104        (const_string "*")))
12105    (set (attr "prefix_data16")
12106      (if_then_else
12107        (and (not (match_test "TARGET_AVX"))
12108             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
12109        (const_string "1")
12110        (const_string "*")))
12111    (set (attr "prefix_extra")
12112      (if_then_else
12113        (and (not (match_test "TARGET_AVX"))
12114             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
12115        (const_string "*")
12116        (const_string "1")))
12117    (set_attr "length_immediate" "1")
12118    (set_attr "prefix" "orig,orig,vex,vex,evex,evex")
12119    (set_attr "mode" "TI")])
12121 (define_expand "<extract_type>_vinsert<shuffletype><extract_suf>_mask"
12122   [(match_operand:AVX512_VEC 0 "register_operand")
12123    (match_operand:AVX512_VEC 1 "register_operand")
12124    (match_operand:<ssequartermode> 2 "nonimmediate_operand")
12125    (match_operand:SI 3 "const_0_to_3_operand")
12126    (match_operand:AVX512_VEC 4 "register_operand")
12127    (match_operand:<avx512fmaskmode> 5 "register_operand")]
12128   "TARGET_AVX512F"
12130   int mask,selector;
12131   mask = INTVAL (operands[3]);
12132   selector = GET_MODE_UNIT_SIZE (<MODE>mode) == 4 ?
12133     0xFFFF ^ (0xF000 >> mask * 4)
12134     : 0xFF ^ (0xC0 >> mask * 2);
12135   emit_insn (gen_<extract_type>_vinsert<shuffletype><extract_suf>_1_mask
12136     (operands[0], operands[1], operands[2], GEN_INT (selector),
12137      operands[4], operands[5]));
12138   DONE;
12141 (define_insn "<mask_codefor><extract_type>_vinsert<shuffletype><extract_suf>_1<mask_name>"
12142   [(set (match_operand:AVX512_VEC 0 "register_operand" "=v")
12143         (vec_merge:AVX512_VEC
12144           (match_operand:AVX512_VEC 1 "register_operand" "v")
12145           (vec_duplicate:AVX512_VEC
12146                 (match_operand:<ssequartermode> 2 "nonimmediate_operand" "vm"))
12147           (match_operand:SI 3 "const_int_operand" "n")))]
12148   "TARGET_AVX512F"
12150   int mask;
12151   int selector = INTVAL (operands[3]);
12153   if (selector == 0xFFF || selector == 0x3F)
12154     mask = 0;
12155   else if ( selector == 0xF0FF || selector == 0xCF)
12156     mask = 1;
12157   else if ( selector == 0xFF0F || selector == 0xF3)
12158     mask = 2;
12159   else if ( selector == 0xFFF0 || selector == 0xFC)
12160     mask = 3;
12161   else
12162       gcc_unreachable ();
12164   operands[3] = GEN_INT (mask);
12166   return "vinsert<shuffletype><extract_suf>\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}";
12168   [(set_attr "type" "sselog")
12169    (set_attr "length_immediate" "1")
12170    (set_attr "prefix" "evex")
12171    (set_attr "mode" "<sseinsnmode>")])
12173 (define_expand "<extract_type_2>_vinsert<shuffletype><extract_suf_2>_mask"
12174   [(match_operand:AVX512_VEC_2 0 "register_operand")
12175    (match_operand:AVX512_VEC_2 1 "register_operand")
12176    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
12177    (match_operand:SI 3 "const_0_to_1_operand")
12178    (match_operand:AVX512_VEC_2 4 "register_operand")
12179    (match_operand:<avx512fmaskmode> 5 "register_operand")]
12180   "TARGET_AVX512F"
12182   int mask = INTVAL (operands[3]);
12183   if (mask == 0)
12184     emit_insn (gen_vec_set_lo_<mode>_mask (operands[0], operands[1],
12185                                            operands[2], operands[4],
12186                                            operands[5]));
12187   else
12188     emit_insn (gen_vec_set_hi_<mode>_mask (operands[0], operands[1],
12189                                            operands[2], operands[4],
12190                                            operands[5]));
12191   DONE;
12194 (define_insn "vec_set_lo_<mode><mask_name>"
12195   [(set (match_operand:V16FI 0 "register_operand" "=v")
12196         (vec_concat:V16FI
12197           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
12198           (vec_select:<ssehalfvecmode>
12199             (match_operand:V16FI 1 "register_operand" "v")
12200             (parallel [(const_int 8) (const_int 9)
12201                        (const_int 10) (const_int 11)
12202                        (const_int 12) (const_int 13)
12203                        (const_int 14) (const_int 15)]))))]
12204   "TARGET_AVX512DQ"
12205   "vinsert<shuffletype>32x8\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, $0x0}"
12206   [(set_attr "type" "sselog")
12207    (set_attr "length_immediate" "1")
12208    (set_attr "prefix" "evex")
12209    (set_attr "mode" "<sseinsnmode>")])
12211 (define_insn "vec_set_hi_<mode><mask_name>"
12212   [(set (match_operand:V16FI 0 "register_operand" "=v")
12213         (vec_concat:V16FI
12214           (vec_select:<ssehalfvecmode>
12215             (match_operand:V16FI 1 "register_operand" "v")
12216             (parallel [(const_int 0) (const_int 1)
12217                        (const_int 2) (const_int 3)
12218                        (const_int 4) (const_int 5)
12219                        (const_int 6) (const_int 7)]))
12220           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
12221   "TARGET_AVX512DQ"
12222   "vinsert<shuffletype>32x8\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, $0x1}"
12223   [(set_attr "type" "sselog")
12224    (set_attr "length_immediate" "1")
12225    (set_attr "prefix" "evex")
12226    (set_attr "mode" "<sseinsnmode>")])
12228 (define_insn "vec_set_lo_<mode><mask_name>"
12229   [(set (match_operand:V8FI 0 "register_operand" "=v")
12230         (vec_concat:V8FI
12231           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
12232           (vec_select:<ssehalfvecmode>
12233             (match_operand:V8FI 1 "register_operand" "v")
12234             (parallel [(const_int 4) (const_int 5)
12235                        (const_int 6) (const_int 7)]))))]
12236   "TARGET_AVX512F"
12237   "vinsert<shuffletype>64x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, $0x0}"
12238   [(set_attr "type" "sselog")
12239    (set_attr "length_immediate" "1")
12240    (set_attr "prefix" "evex")
12241    (set_attr "mode" "XI")])
12243 (define_insn "vec_set_hi_<mode><mask_name>"
12244   [(set (match_operand:V8FI 0 "register_operand" "=v")
12245         (vec_concat:V8FI
12246           (vec_select:<ssehalfvecmode>
12247             (match_operand:V8FI 1 "register_operand" "v")
12248             (parallel [(const_int 0) (const_int 1)
12249                        (const_int 2) (const_int 3)]))
12250           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
12251   "TARGET_AVX512F"
12252   "vinsert<shuffletype>64x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}"
12253   [(set_attr "type" "sselog")
12254    (set_attr "length_immediate" "1")
12255    (set_attr "prefix" "evex")
12256    (set_attr "mode" "XI")])
12258 (define_expand "avx512dq_shuf_<shuffletype>64x2_mask"
12259   [(match_operand:VI8F_256 0 "register_operand")
12260    (match_operand:VI8F_256 1 "register_operand")
12261    (match_operand:VI8F_256 2 "nonimmediate_operand")
12262    (match_operand:SI 3 "const_0_to_3_operand")
12263    (match_operand:VI8F_256 4 "register_operand")
12264    (match_operand:QI 5 "register_operand")]
12265   "TARGET_AVX512DQ"
12267   int mask = INTVAL (operands[3]);
12268   emit_insn (gen_avx512dq_shuf_<shuffletype>64x2_1_mask
12269       (operands[0], operands[1], operands[2],
12270        GEN_INT (((mask >> 0) & 1) * 2 + 0),
12271        GEN_INT (((mask >> 0) & 1) * 2 + 1),
12272        GEN_INT (((mask >> 1) & 1) * 2 + 4),
12273        GEN_INT (((mask >> 1) & 1) * 2 + 5),
12274        operands[4], operands[5]));
12275   DONE;
12278 (define_insn "<mask_codefor>avx512dq_shuf_<shuffletype>64x2_1<mask_name>"
12279   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
12280         (vec_select:VI8F_256
12281           (vec_concat:<ssedoublemode>
12282             (match_operand:VI8F_256 1 "register_operand" "v")
12283             (match_operand:VI8F_256 2 "nonimmediate_operand" "vm"))
12284           (parallel [(match_operand 3  "const_0_to_3_operand")
12285                      (match_operand 4  "const_0_to_3_operand")
12286                      (match_operand 5  "const_4_to_7_operand")
12287                      (match_operand 6  "const_4_to_7_operand")])))]
12288   "TARGET_AVX512VL
12289    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12290        && INTVAL (operands[5]) == (INTVAL (operands[6]) - 1))"
12292   int mask;
12293   mask = INTVAL (operands[3]) / 2;
12294   mask |= (INTVAL (operands[5]) - 4) / 2 << 1;
12295   operands[3] = GEN_INT (mask);
12296   return "vshuf<shuffletype>64x2\t{%3, %2, %1, %0<mask_operand7>|%0<mask_operand7>, %1, %2, %3}";
12298   [(set_attr "type" "sselog")
12299    (set_attr "length_immediate" "1")
12300    (set_attr "prefix" "evex")
12301    (set_attr "mode" "XI")])
12303 (define_expand "avx512f_shuf_<shuffletype>64x2_mask"
12304   [(match_operand:V8FI 0 "register_operand")
12305    (match_operand:V8FI 1 "register_operand")
12306    (match_operand:V8FI 2 "nonimmediate_operand")
12307    (match_operand:SI 3 "const_0_to_255_operand")
12308    (match_operand:V8FI 4 "register_operand")
12309    (match_operand:QI 5 "register_operand")]
12310   "TARGET_AVX512F"
12312   int mask = INTVAL (operands[3]);
12313   emit_insn (gen_avx512f_shuf_<shuffletype>64x2_1_mask
12314       (operands[0], operands[1], operands[2],
12315        GEN_INT (((mask >> 0) & 3) * 2),
12316        GEN_INT (((mask >> 0) & 3) * 2 + 1),
12317        GEN_INT (((mask >> 2) & 3) * 2),
12318        GEN_INT (((mask >> 2) & 3) * 2 + 1),
12319        GEN_INT (((mask >> 4) & 3) * 2 + 8),
12320        GEN_INT (((mask >> 4) & 3) * 2 + 9),
12321        GEN_INT (((mask >> 6) & 3) * 2 + 8),
12322        GEN_INT (((mask >> 6) & 3) * 2 + 9),
12323        operands[4], operands[5]));
12324   DONE;
12327 (define_insn "avx512f_shuf_<shuffletype>64x2_1<mask_name>"
12328   [(set (match_operand:V8FI 0 "register_operand" "=v")
12329         (vec_select:V8FI
12330           (vec_concat:<ssedoublemode>
12331             (match_operand:V8FI 1 "register_operand" "v")
12332             (match_operand:V8FI 2 "nonimmediate_operand" "vm"))
12333           (parallel [(match_operand 3  "const_0_to_7_operand")
12334                      (match_operand 4  "const_0_to_7_operand")
12335                      (match_operand 5  "const_0_to_7_operand")
12336                      (match_operand 6  "const_0_to_7_operand")
12337                      (match_operand 7  "const_8_to_15_operand")
12338                      (match_operand 8  "const_8_to_15_operand")
12339                      (match_operand 9  "const_8_to_15_operand")
12340                      (match_operand 10  "const_8_to_15_operand")])))]
12341   "TARGET_AVX512F
12342    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12343        && INTVAL (operands[5]) == (INTVAL (operands[6]) - 1)
12344        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
12345        && INTVAL (operands[9]) == (INTVAL (operands[10]) - 1))"
12347   int mask;
12348   mask = INTVAL (operands[3]) / 2;
12349   mask |= INTVAL (operands[5]) / 2 << 2;
12350   mask |= (INTVAL (operands[7]) - 8) / 2 << 4;
12351   mask |= (INTVAL (operands[9]) - 8) / 2 << 6;
12352   operands[3] = GEN_INT (mask);
12354   return "vshuf<shuffletype>64x2\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
12356   [(set_attr "type" "sselog")
12357    (set_attr "length_immediate" "1")
12358    (set_attr "prefix" "evex")
12359    (set_attr "mode" "<sseinsnmode>")])
12361 (define_expand "avx512vl_shuf_<shuffletype>32x4_mask"
12362   [(match_operand:VI4F_256 0 "register_operand")
12363    (match_operand:VI4F_256 1 "register_operand")
12364    (match_operand:VI4F_256 2 "nonimmediate_operand")
12365    (match_operand:SI 3 "const_0_to_3_operand")
12366    (match_operand:VI4F_256 4 "register_operand")
12367    (match_operand:QI 5 "register_operand")]
12368   "TARGET_AVX512VL"
12370   int mask = INTVAL (operands[3]);
12371   emit_insn (gen_avx512vl_shuf_<shuffletype>32x4_1_mask
12372       (operands[0], operands[1], operands[2],
12373        GEN_INT (((mask >> 0) & 1) * 4 + 0),
12374        GEN_INT (((mask >> 0) & 1) * 4 + 1),
12375        GEN_INT (((mask >> 0) & 1) * 4 + 2),
12376        GEN_INT (((mask >> 0) & 1) * 4 + 3),
12377        GEN_INT (((mask >> 1) & 1) * 4 + 8),
12378        GEN_INT (((mask >> 1) & 1) * 4 + 9),
12379        GEN_INT (((mask >> 1) & 1) * 4 + 10),
12380        GEN_INT (((mask >> 1) & 1) * 4 + 11),
12381        operands[4], operands[5]));
12382   DONE;
12385 (define_insn "<mask_codefor>avx512vl_shuf_<shuffletype>32x4_1<mask_name>"
12386   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
12387         (vec_select:VI4F_256
12388           (vec_concat:<ssedoublemode>
12389             (match_operand:VI4F_256 1 "register_operand" "v")
12390             (match_operand:VI4F_256 2 "nonimmediate_operand" "vm"))
12391           (parallel [(match_operand 3  "const_0_to_7_operand")
12392                      (match_operand 4  "const_0_to_7_operand")
12393                      (match_operand 5  "const_0_to_7_operand")
12394                      (match_operand 6  "const_0_to_7_operand")
12395                      (match_operand 7  "const_8_to_15_operand")
12396                      (match_operand 8  "const_8_to_15_operand")
12397                      (match_operand 9  "const_8_to_15_operand")
12398                      (match_operand 10 "const_8_to_15_operand")])))]
12399   "TARGET_AVX512VL
12400    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12401        && INTVAL (operands[3]) == (INTVAL (operands[5]) - 2)
12402        && INTVAL (operands[3]) == (INTVAL (operands[6]) - 3)
12403        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
12404        && INTVAL (operands[7]) == (INTVAL (operands[9]) - 2)
12405        && INTVAL (operands[7]) == (INTVAL (operands[10]) - 3))"
12407   int mask;
12408   mask = INTVAL (operands[3]) / 4;
12409   mask |= (INTVAL (operands[7]) - 8) / 4 << 1;
12410   operands[3] = GEN_INT (mask);
12412   return "vshuf<shuffletype>32x4\t{%3, %2, %1, %0<mask_operand11>|%0<mask_operand11>, %1, %2, %3}";
12414   [(set_attr "type" "sselog")
12415    (set_attr "length_immediate" "1")
12416    (set_attr "prefix" "evex")
12417    (set_attr "mode" "<sseinsnmode>")])
12419 (define_expand "avx512f_shuf_<shuffletype>32x4_mask"
12420   [(match_operand:V16FI 0 "register_operand")
12421    (match_operand:V16FI 1 "register_operand")
12422    (match_operand:V16FI 2 "nonimmediate_operand")
12423    (match_operand:SI 3 "const_0_to_255_operand")
12424    (match_operand:V16FI 4 "register_operand")
12425    (match_operand:HI 5 "register_operand")]
12426   "TARGET_AVX512F"
12428   int mask = INTVAL (operands[3]);
12429   emit_insn (gen_avx512f_shuf_<shuffletype>32x4_1_mask
12430       (operands[0], operands[1], operands[2],
12431        GEN_INT (((mask >> 0) & 3) * 4),
12432        GEN_INT (((mask >> 0) & 3) * 4 + 1),
12433        GEN_INT (((mask >> 0) & 3) * 4 + 2),
12434        GEN_INT (((mask >> 0) & 3) * 4 + 3),
12435        GEN_INT (((mask >> 2) & 3) * 4),
12436        GEN_INT (((mask >> 2) & 3) * 4 + 1),
12437        GEN_INT (((mask >> 2) & 3) * 4 + 2),
12438        GEN_INT (((mask >> 2) & 3) * 4 + 3),
12439        GEN_INT (((mask >> 4) & 3) * 4 + 16),
12440        GEN_INT (((mask >> 4) & 3) * 4 + 17),
12441        GEN_INT (((mask >> 4) & 3) * 4 + 18),
12442        GEN_INT (((mask >> 4) & 3) * 4 + 19),
12443        GEN_INT (((mask >> 6) & 3) * 4 + 16),
12444        GEN_INT (((mask >> 6) & 3) * 4 + 17),
12445        GEN_INT (((mask >> 6) & 3) * 4 + 18),
12446        GEN_INT (((mask >> 6) & 3) * 4 + 19),
12447        operands[4], operands[5]));
12448   DONE;
12451 (define_insn "avx512f_shuf_<shuffletype>32x4_1<mask_name>"
12452   [(set (match_operand:V16FI 0 "register_operand" "=v")
12453         (vec_select:V16FI
12454           (vec_concat:<ssedoublemode>
12455             (match_operand:V16FI 1 "register_operand" "v")
12456             (match_operand:V16FI 2 "nonimmediate_operand" "vm"))
12457           (parallel [(match_operand 3  "const_0_to_15_operand")
12458                      (match_operand 4  "const_0_to_15_operand")
12459                      (match_operand 5  "const_0_to_15_operand")
12460                      (match_operand 6  "const_0_to_15_operand")
12461                      (match_operand 7  "const_0_to_15_operand")
12462                      (match_operand 8  "const_0_to_15_operand")
12463                      (match_operand 9  "const_0_to_15_operand")
12464                      (match_operand 10  "const_0_to_15_operand")
12465                      (match_operand 11  "const_16_to_31_operand")
12466                      (match_operand 12  "const_16_to_31_operand")
12467                      (match_operand 13  "const_16_to_31_operand")
12468                      (match_operand 14  "const_16_to_31_operand")
12469                      (match_operand 15  "const_16_to_31_operand")
12470                      (match_operand 16  "const_16_to_31_operand")
12471                      (match_operand 17  "const_16_to_31_operand")
12472                      (match_operand 18  "const_16_to_31_operand")])))]
12473   "TARGET_AVX512F
12474    && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
12475        && INTVAL (operands[3]) == (INTVAL (operands[5]) - 2)
12476        && INTVAL (operands[3]) == (INTVAL (operands[6]) - 3)
12477        && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
12478        && INTVAL (operands[7]) == (INTVAL (operands[9]) - 2)
12479        && INTVAL (operands[7]) == (INTVAL (operands[10]) - 3)
12480        && INTVAL (operands[11]) == (INTVAL (operands[12]) - 1)
12481        && INTVAL (operands[11]) == (INTVAL (operands[13]) - 2)
12482        && INTVAL (operands[11]) == (INTVAL (operands[14]) - 3)
12483        && INTVAL (operands[15]) == (INTVAL (operands[16]) - 1)
12484        && INTVAL (operands[15]) == (INTVAL (operands[17]) - 2)
12485        && INTVAL (operands[15]) == (INTVAL (operands[18]) - 3))"
12487   int mask;
12488   mask = INTVAL (operands[3]) / 4;
12489   mask |= INTVAL (operands[7]) / 4 << 2;
12490   mask |= (INTVAL (operands[11]) - 16) / 4 << 4;
12491   mask |= (INTVAL (operands[15]) - 16) / 4 << 6;
12492   operands[3] = GEN_INT (mask);
12494   return "vshuf<shuffletype>32x4\t{%3, %2, %1, %0<mask_operand19>|%0<mask_operand19>, %1, %2, %3}";
12496   [(set_attr "type" "sselog")
12497    (set_attr "length_immediate" "1")
12498    (set_attr "prefix" "evex")
12499    (set_attr "mode" "<sseinsnmode>")])
12501 (define_expand "avx512f_pshufdv3_mask"
12502   [(match_operand:V16SI 0 "register_operand")
12503    (match_operand:V16SI 1 "nonimmediate_operand")
12504    (match_operand:SI 2 "const_0_to_255_operand")
12505    (match_operand:V16SI 3 "register_operand")
12506    (match_operand:HI 4 "register_operand")]
12507   "TARGET_AVX512F"
12509   int mask = INTVAL (operands[2]);
12510   emit_insn (gen_avx512f_pshufd_1_mask (operands[0], operands[1],
12511                                        GEN_INT ((mask >> 0) & 3),
12512                                        GEN_INT ((mask >> 2) & 3),
12513                                        GEN_INT ((mask >> 4) & 3),
12514                                        GEN_INT ((mask >> 6) & 3),
12515                                        GEN_INT (((mask >> 0) & 3) + 4),
12516                                        GEN_INT (((mask >> 2) & 3) + 4),
12517                                        GEN_INT (((mask >> 4) & 3) + 4),
12518                                        GEN_INT (((mask >> 6) & 3) + 4),
12519                                        GEN_INT (((mask >> 0) & 3) + 8),
12520                                        GEN_INT (((mask >> 2) & 3) + 8),
12521                                        GEN_INT (((mask >> 4) & 3) + 8),
12522                                        GEN_INT (((mask >> 6) & 3) + 8),
12523                                        GEN_INT (((mask >> 0) & 3) + 12),
12524                                        GEN_INT (((mask >> 2) & 3) + 12),
12525                                        GEN_INT (((mask >> 4) & 3) + 12),
12526                                        GEN_INT (((mask >> 6) & 3) + 12),
12527                                        operands[3], operands[4]));
12528   DONE;
12531 (define_insn "avx512f_pshufd_1<mask_name>"
12532   [(set (match_operand:V16SI 0 "register_operand" "=v")
12533         (vec_select:V16SI
12534           (match_operand:V16SI 1 "nonimmediate_operand" "vm")
12535           (parallel [(match_operand 2 "const_0_to_3_operand")
12536                      (match_operand 3 "const_0_to_3_operand")
12537                      (match_operand 4 "const_0_to_3_operand")
12538                      (match_operand 5 "const_0_to_3_operand")
12539                      (match_operand 6 "const_4_to_7_operand")
12540                      (match_operand 7 "const_4_to_7_operand")
12541                      (match_operand 8 "const_4_to_7_operand")
12542                      (match_operand 9 "const_4_to_7_operand")
12543                      (match_operand 10 "const_8_to_11_operand")
12544                      (match_operand 11 "const_8_to_11_operand")
12545                      (match_operand 12 "const_8_to_11_operand")
12546                      (match_operand 13 "const_8_to_11_operand")
12547                      (match_operand 14 "const_12_to_15_operand")
12548                      (match_operand 15 "const_12_to_15_operand")
12549                      (match_operand 16 "const_12_to_15_operand")
12550                      (match_operand 17 "const_12_to_15_operand")])))]
12551   "TARGET_AVX512F
12552    && INTVAL (operands[2]) + 4 == INTVAL (operands[6])
12553    && INTVAL (operands[3]) + 4 == INTVAL (operands[7])
12554    && INTVAL (operands[4]) + 4 == INTVAL (operands[8])
12555    && INTVAL (operands[5]) + 4 == INTVAL (operands[9])
12556    && INTVAL (operands[2]) + 8 == INTVAL (operands[10])
12557    && INTVAL (operands[3]) + 8 == INTVAL (operands[11])
12558    && INTVAL (operands[4]) + 8 == INTVAL (operands[12])
12559    && INTVAL (operands[5]) + 8 == INTVAL (operands[13])
12560    && INTVAL (operands[2]) + 12 == INTVAL (operands[14])
12561    && INTVAL (operands[3]) + 12 == INTVAL (operands[15])
12562    && INTVAL (operands[4]) + 12 == INTVAL (operands[16])
12563    && INTVAL (operands[5]) + 12 == INTVAL (operands[17])"
12565   int mask = 0;
12566   mask |= INTVAL (operands[2]) << 0;
12567   mask |= INTVAL (operands[3]) << 2;
12568   mask |= INTVAL (operands[4]) << 4;
12569   mask |= INTVAL (operands[5]) << 6;
12570   operands[2] = GEN_INT (mask);
12572   return "vpshufd\t{%2, %1, %0<mask_operand18>|%0<mask_operand18>, %1, %2}";
12574   [(set_attr "type" "sselog1")
12575    (set_attr "prefix" "evex")
12576    (set_attr "length_immediate" "1")
12577    (set_attr "mode" "XI")])
12579 (define_expand "avx512vl_pshufdv3_mask"
12580   [(match_operand:V8SI 0 "register_operand")
12581    (match_operand:V8SI 1 "nonimmediate_operand")
12582    (match_operand:SI 2 "const_0_to_255_operand")
12583    (match_operand:V8SI 3 "register_operand")
12584    (match_operand:QI 4 "register_operand")]
12585   "TARGET_AVX512VL"
12587   int mask = INTVAL (operands[2]);
12588   emit_insn (gen_avx2_pshufd_1_mask (operands[0], operands[1],
12589                                 GEN_INT ((mask >> 0) & 3),
12590                                 GEN_INT ((mask >> 2) & 3),
12591                                 GEN_INT ((mask >> 4) & 3),
12592                                 GEN_INT ((mask >> 6) & 3),
12593                                 GEN_INT (((mask >> 0) & 3) + 4),
12594                                 GEN_INT (((mask >> 2) & 3) + 4),
12595                                 GEN_INT (((mask >> 4) & 3) + 4),
12596                                 GEN_INT (((mask >> 6) & 3) + 4),
12597                 operands[3], operands[4]));
12598   DONE;
12601 (define_expand "avx2_pshufdv3"
12602   [(match_operand:V8SI 0 "register_operand")
12603    (match_operand:V8SI 1 "nonimmediate_operand")
12604    (match_operand:SI 2 "const_0_to_255_operand")]
12605   "TARGET_AVX2"
12607   int mask = INTVAL (operands[2]);
12608   emit_insn (gen_avx2_pshufd_1 (operands[0], operands[1],
12609                                 GEN_INT ((mask >> 0) & 3),
12610                                 GEN_INT ((mask >> 2) & 3),
12611                                 GEN_INT ((mask >> 4) & 3),
12612                                 GEN_INT ((mask >> 6) & 3),
12613                                 GEN_INT (((mask >> 0) & 3) + 4),
12614                                 GEN_INT (((mask >> 2) & 3) + 4),
12615                                 GEN_INT (((mask >> 4) & 3) + 4),
12616                                 GEN_INT (((mask >> 6) & 3) + 4)));
12617   DONE;
12620 (define_insn "avx2_pshufd_1<mask_name>"
12621   [(set (match_operand:V8SI 0 "register_operand" "=v")
12622         (vec_select:V8SI
12623           (match_operand:V8SI 1 "nonimmediate_operand" "vm")
12624           (parallel [(match_operand 2 "const_0_to_3_operand")
12625                      (match_operand 3 "const_0_to_3_operand")
12626                      (match_operand 4 "const_0_to_3_operand")
12627                      (match_operand 5 "const_0_to_3_operand")
12628                      (match_operand 6 "const_4_to_7_operand")
12629                      (match_operand 7 "const_4_to_7_operand")
12630                      (match_operand 8 "const_4_to_7_operand")
12631                      (match_operand 9 "const_4_to_7_operand")])))]
12632   "TARGET_AVX2
12633    && <mask_avx512vl_condition>
12634    && INTVAL (operands[2]) + 4 == INTVAL (operands[6])
12635    && INTVAL (operands[3]) + 4 == INTVAL (operands[7])
12636    && INTVAL (operands[4]) + 4 == INTVAL (operands[8])
12637    && INTVAL (operands[5]) + 4 == INTVAL (operands[9])"
12639   int mask = 0;
12640   mask |= INTVAL (operands[2]) << 0;
12641   mask |= INTVAL (operands[3]) << 2;
12642   mask |= INTVAL (operands[4]) << 4;
12643   mask |= INTVAL (operands[5]) << 6;
12644   operands[2] = GEN_INT (mask);
12646   return "vpshufd\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
12648   [(set_attr "type" "sselog1")
12649    (set_attr "prefix" "maybe_evex")
12650    (set_attr "length_immediate" "1")
12651    (set_attr "mode" "OI")])
12653 (define_expand "avx512vl_pshufd_mask"
12654   [(match_operand:V4SI 0 "register_operand")
12655    (match_operand:V4SI 1 "nonimmediate_operand")
12656    (match_operand:SI 2 "const_0_to_255_operand")
12657    (match_operand:V4SI 3 "register_operand")
12658    (match_operand:QI 4 "register_operand")]
12659   "TARGET_AVX512VL"
12661   int mask = INTVAL (operands[2]);
12662   emit_insn (gen_sse2_pshufd_1_mask (operands[0], operands[1],
12663                                 GEN_INT ((mask >> 0) & 3),
12664                                 GEN_INT ((mask >> 2) & 3),
12665                                 GEN_INT ((mask >> 4) & 3),
12666                                 GEN_INT ((mask >> 6) & 3),
12667                 operands[3], operands[4]));
12668   DONE;
12671 (define_expand "sse2_pshufd"
12672   [(match_operand:V4SI 0 "register_operand")
12673    (match_operand:V4SI 1 "vector_operand")
12674    (match_operand:SI 2 "const_int_operand")]
12675   "TARGET_SSE2"
12677   int mask = INTVAL (operands[2]);
12678   emit_insn (gen_sse2_pshufd_1 (operands[0], operands[1],
12679                                 GEN_INT ((mask >> 0) & 3),
12680                                 GEN_INT ((mask >> 2) & 3),
12681                                 GEN_INT ((mask >> 4) & 3),
12682                                 GEN_INT ((mask >> 6) & 3)));
12683   DONE;
12686 (define_insn "sse2_pshufd_1<mask_name>"
12687   [(set (match_operand:V4SI 0 "register_operand" "=v")
12688         (vec_select:V4SI
12689           (match_operand:V4SI 1 "vector_operand" "vBm")
12690           (parallel [(match_operand 2 "const_0_to_3_operand")
12691                      (match_operand 3 "const_0_to_3_operand")
12692                      (match_operand 4 "const_0_to_3_operand")
12693                      (match_operand 5 "const_0_to_3_operand")])))]
12694   "TARGET_SSE2 && <mask_avx512vl_condition>"
12696   int mask = 0;
12697   mask |= INTVAL (operands[2]) << 0;
12698   mask |= INTVAL (operands[3]) << 2;
12699   mask |= INTVAL (operands[4]) << 4;
12700   mask |= INTVAL (operands[5]) << 6;
12701   operands[2] = GEN_INT (mask);
12703   return "%vpshufd\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
12705   [(set_attr "type" "sselog1")
12706    (set_attr "prefix_data16" "1")
12707    (set_attr "prefix" "<mask_prefix2>")
12708    (set_attr "length_immediate" "1")
12709    (set_attr "mode" "TI")])
12711 (define_insn "<mask_codefor>avx512bw_pshuflwv32hi<mask_name>"
12712   [(set (match_operand:V32HI 0 "register_operand" "=v")
12713         (unspec:V32HI
12714           [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
12715            (match_operand:SI 2 "const_0_to_255_operand" "n")]
12716           UNSPEC_PSHUFLW))]
12717   "TARGET_AVX512BW"
12718   "vpshuflw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12719   [(set_attr "type" "sselog")
12720    (set_attr "prefix" "evex")
12721    (set_attr "mode" "XI")])
12723 (define_expand "avx512vl_pshuflwv3_mask"
12724   [(match_operand:V16HI 0 "register_operand")
12725    (match_operand:V16HI 1 "nonimmediate_operand")
12726    (match_operand:SI 2 "const_0_to_255_operand")
12727    (match_operand:V16HI 3 "register_operand")
12728    (match_operand:HI 4 "register_operand")]
12729   "TARGET_AVX512VL && TARGET_AVX512BW"
12731   int mask = INTVAL (operands[2]);
12732   emit_insn (gen_avx2_pshuflw_1_mask (operands[0], operands[1],
12733                                  GEN_INT ((mask >> 0) & 3),
12734                                  GEN_INT ((mask >> 2) & 3),
12735                                  GEN_INT ((mask >> 4) & 3),
12736                                  GEN_INT ((mask >> 6) & 3),
12737                                  GEN_INT (((mask >> 0) & 3) + 8),
12738                                  GEN_INT (((mask >> 2) & 3) + 8),
12739                                  GEN_INT (((mask >> 4) & 3) + 8),
12740                                  GEN_INT (((mask >> 6) & 3) + 8),
12741                  operands[3], operands[4]));
12742   DONE;
12745 (define_expand "avx2_pshuflwv3"
12746   [(match_operand:V16HI 0 "register_operand")
12747    (match_operand:V16HI 1 "nonimmediate_operand")
12748    (match_operand:SI 2 "const_0_to_255_operand")]
12749   "TARGET_AVX2"
12751   int mask = INTVAL (operands[2]);
12752   emit_insn (gen_avx2_pshuflw_1 (operands[0], operands[1],
12753                                  GEN_INT ((mask >> 0) & 3),
12754                                  GEN_INT ((mask >> 2) & 3),
12755                                  GEN_INT ((mask >> 4) & 3),
12756                                  GEN_INT ((mask >> 6) & 3),
12757                                  GEN_INT (((mask >> 0) & 3) + 8),
12758                                  GEN_INT (((mask >> 2) & 3) + 8),
12759                                  GEN_INT (((mask >> 4) & 3) + 8),
12760                                  GEN_INT (((mask >> 6) & 3) + 8)));
12761   DONE;
12764 (define_insn "avx2_pshuflw_1<mask_name>"
12765   [(set (match_operand:V16HI 0 "register_operand" "=v")
12766         (vec_select:V16HI
12767           (match_operand:V16HI 1 "nonimmediate_operand" "vm")
12768           (parallel [(match_operand 2 "const_0_to_3_operand")
12769                      (match_operand 3 "const_0_to_3_operand")
12770                      (match_operand 4 "const_0_to_3_operand")
12771                      (match_operand 5 "const_0_to_3_operand")
12772                      (const_int 4)
12773                      (const_int 5)
12774                      (const_int 6)
12775                      (const_int 7)
12776                      (match_operand 6 "const_8_to_11_operand")
12777                      (match_operand 7 "const_8_to_11_operand")
12778                      (match_operand 8 "const_8_to_11_operand")
12779                      (match_operand 9 "const_8_to_11_operand")
12780                      (const_int 12)
12781                      (const_int 13)
12782                      (const_int 14)
12783                      (const_int 15)])))]
12784   "TARGET_AVX2
12785    && <mask_avx512bw_condition> && <mask_avx512vl_condition>
12786    && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
12787    && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
12788    && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
12789    && INTVAL (operands[5]) + 8 == INTVAL (operands[9])"
12791   int mask = 0;
12792   mask |= INTVAL (operands[2]) << 0;
12793   mask |= INTVAL (operands[3]) << 2;
12794   mask |= INTVAL (operands[4]) << 4;
12795   mask |= INTVAL (operands[5]) << 6;
12796   operands[2] = GEN_INT (mask);
12798   return "vpshuflw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
12800   [(set_attr "type" "sselog")
12801    (set_attr "prefix" "maybe_evex")
12802    (set_attr "length_immediate" "1")
12803    (set_attr "mode" "OI")])
12805 (define_expand "avx512vl_pshuflw_mask"
12806   [(match_operand:V8HI 0 "register_operand")
12807    (match_operand:V8HI 1 "nonimmediate_operand")
12808    (match_operand:SI 2 "const_0_to_255_operand")
12809    (match_operand:V8HI 3 "register_operand")
12810    (match_operand:QI 4 "register_operand")]
12811   "TARGET_AVX512VL && TARGET_AVX512BW"
12813   int mask = INTVAL (operands[2]);
12814   emit_insn (gen_sse2_pshuflw_1_mask (operands[0], operands[1],
12815                                  GEN_INT ((mask >> 0) & 3),
12816                                  GEN_INT ((mask >> 2) & 3),
12817                                  GEN_INT ((mask >> 4) & 3),
12818                                  GEN_INT ((mask >> 6) & 3),
12819                  operands[3], operands[4]));
12820   DONE;
12823 (define_expand "sse2_pshuflw"
12824   [(match_operand:V8HI 0 "register_operand")
12825    (match_operand:V8HI 1 "vector_operand")
12826    (match_operand:SI 2 "const_int_operand")]
12827   "TARGET_SSE2"
12829   int mask = INTVAL (operands[2]);
12830   emit_insn (gen_sse2_pshuflw_1 (operands[0], operands[1],
12831                                  GEN_INT ((mask >> 0) & 3),
12832                                  GEN_INT ((mask >> 2) & 3),
12833                                  GEN_INT ((mask >> 4) & 3),
12834                                  GEN_INT ((mask >> 6) & 3)));
12835   DONE;
12838 (define_insn "sse2_pshuflw_1<mask_name>"
12839   [(set (match_operand:V8HI 0 "register_operand" "=v")
12840         (vec_select:V8HI
12841           (match_operand:V8HI 1 "vector_operand" "vBm")
12842           (parallel [(match_operand 2 "const_0_to_3_operand")
12843                      (match_operand 3 "const_0_to_3_operand")
12844                      (match_operand 4 "const_0_to_3_operand")
12845                      (match_operand 5 "const_0_to_3_operand")
12846                      (const_int 4)
12847                      (const_int 5)
12848                      (const_int 6)
12849                      (const_int 7)])))]
12850   "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
12852   int mask = 0;
12853   mask |= INTVAL (operands[2]) << 0;
12854   mask |= INTVAL (operands[3]) << 2;
12855   mask |= INTVAL (operands[4]) << 4;
12856   mask |= INTVAL (operands[5]) << 6;
12857   operands[2] = GEN_INT (mask);
12859   return "%vpshuflw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
12861   [(set_attr "type" "sselog")
12862    (set_attr "prefix_data16" "0")
12863    (set_attr "prefix_rep" "1")
12864    (set_attr "prefix" "maybe_vex")
12865    (set_attr "length_immediate" "1")
12866    (set_attr "mode" "TI")])
12868 (define_expand "avx2_pshufhwv3"
12869   [(match_operand:V16HI 0 "register_operand")
12870    (match_operand:V16HI 1 "nonimmediate_operand")
12871    (match_operand:SI 2 "const_0_to_255_operand")]
12872   "TARGET_AVX2"
12874   int mask = INTVAL (operands[2]);
12875   emit_insn (gen_avx2_pshufhw_1 (operands[0], operands[1],
12876                                  GEN_INT (((mask >> 0) & 3) + 4),
12877                                  GEN_INT (((mask >> 2) & 3) + 4),
12878                                  GEN_INT (((mask >> 4) & 3) + 4),
12879                                  GEN_INT (((mask >> 6) & 3) + 4),
12880                                  GEN_INT (((mask >> 0) & 3) + 12),
12881                                  GEN_INT (((mask >> 2) & 3) + 12),
12882                                  GEN_INT (((mask >> 4) & 3) + 12),
12883                                  GEN_INT (((mask >> 6) & 3) + 12)));
12884   DONE;
12887 (define_insn "<mask_codefor>avx512bw_pshufhwv32hi<mask_name>"
12888   [(set (match_operand:V32HI 0 "register_operand" "=v")
12889         (unspec:V32HI
12890           [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
12891            (match_operand:SI 2 "const_0_to_255_operand" "n")]
12892           UNSPEC_PSHUFHW))]
12893   "TARGET_AVX512BW"
12894   "vpshufhw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
12895   [(set_attr "type" "sselog")
12896    (set_attr "prefix" "evex")
12897    (set_attr "mode" "XI")])
12899 (define_expand "avx512vl_pshufhwv3_mask"
12900   [(match_operand:V16HI 0 "register_operand")
12901    (match_operand:V16HI 1 "nonimmediate_operand")
12902    (match_operand:SI 2 "const_0_to_255_operand")
12903    (match_operand:V16HI 3 "register_operand")
12904    (match_operand:HI 4 "register_operand")]
12905   "TARGET_AVX512VL && TARGET_AVX512BW"
12907   int mask = INTVAL (operands[2]);
12908   emit_insn (gen_avx2_pshufhw_1_mask (operands[0], operands[1],
12909                                  GEN_INT (((mask >> 0) & 3) + 4),
12910                                  GEN_INT (((mask >> 2) & 3) + 4),
12911                                  GEN_INT (((mask >> 4) & 3) + 4),
12912                                  GEN_INT (((mask >> 6) & 3) + 4),
12913                                  GEN_INT (((mask >> 0) & 3) + 12),
12914                                  GEN_INT (((mask >> 2) & 3) + 12),
12915                                  GEN_INT (((mask >> 4) & 3) + 12),
12916                                  GEN_INT (((mask >> 6) & 3) + 12),
12917                  operands[3], operands[4]));
12918   DONE;
12921 (define_insn "avx2_pshufhw_1<mask_name>"
12922   [(set (match_operand:V16HI 0 "register_operand" "=v")
12923         (vec_select:V16HI
12924           (match_operand:V16HI 1 "nonimmediate_operand" "vm")
12925           (parallel [(const_int 0)
12926                      (const_int 1)
12927                      (const_int 2)
12928                      (const_int 3)
12929                      (match_operand 2 "const_4_to_7_operand")
12930                      (match_operand 3 "const_4_to_7_operand")
12931                      (match_operand 4 "const_4_to_7_operand")
12932                      (match_operand 5 "const_4_to_7_operand")
12933                      (const_int 8)
12934                      (const_int 9)
12935                      (const_int 10)
12936                      (const_int 11)
12937                      (match_operand 6 "const_12_to_15_operand")
12938                      (match_operand 7 "const_12_to_15_operand")
12939                      (match_operand 8 "const_12_to_15_operand")
12940                      (match_operand 9 "const_12_to_15_operand")])))]
12941   "TARGET_AVX2
12942    && <mask_avx512bw_condition> && <mask_avx512vl_condition>
12943    && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
12944    && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
12945    && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
12946    && INTVAL (operands[5]) + 8 == INTVAL (operands[9])"
12948   int mask = 0;
12949   mask |= (INTVAL (operands[2]) - 4) << 0;
12950   mask |= (INTVAL (operands[3]) - 4) << 2;
12951   mask |= (INTVAL (operands[4]) - 4) << 4;
12952   mask |= (INTVAL (operands[5]) - 4) << 6;
12953   operands[2] = GEN_INT (mask);
12955   return "vpshufhw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
12957   [(set_attr "type" "sselog")
12958    (set_attr "prefix" "maybe_evex")
12959    (set_attr "length_immediate" "1")
12960    (set_attr "mode" "OI")])
12962 (define_expand "avx512vl_pshufhw_mask"
12963   [(match_operand:V8HI 0 "register_operand")
12964    (match_operand:V8HI 1 "nonimmediate_operand")
12965    (match_operand:SI 2 "const_0_to_255_operand")
12966    (match_operand:V8HI 3 "register_operand")
12967    (match_operand:QI 4 "register_operand")]
12968   "TARGET_AVX512VL && TARGET_AVX512BW"
12970   int mask = INTVAL (operands[2]);
12971   emit_insn (gen_sse2_pshufhw_1_mask (operands[0], operands[1],
12972                                  GEN_INT (((mask >> 0) & 3) + 4),
12973                                  GEN_INT (((mask >> 2) & 3) + 4),
12974                                  GEN_INT (((mask >> 4) & 3) + 4),
12975                                  GEN_INT (((mask >> 6) & 3) + 4),
12976                  operands[3], operands[4]));
12977   DONE;
12980 (define_expand "sse2_pshufhw"
12981   [(match_operand:V8HI 0 "register_operand")
12982    (match_operand:V8HI 1 "vector_operand")
12983    (match_operand:SI 2 "const_int_operand")]
12984   "TARGET_SSE2"
12986   int mask = INTVAL (operands[2]);
12987   emit_insn (gen_sse2_pshufhw_1 (operands[0], operands[1],
12988                                  GEN_INT (((mask >> 0) & 3) + 4),
12989                                  GEN_INT (((mask >> 2) & 3) + 4),
12990                                  GEN_INT (((mask >> 4) & 3) + 4),
12991                                  GEN_INT (((mask >> 6) & 3) + 4)));
12992   DONE;
12995 (define_insn "sse2_pshufhw_1<mask_name>"
12996   [(set (match_operand:V8HI 0 "register_operand" "=v")
12997         (vec_select:V8HI
12998           (match_operand:V8HI 1 "vector_operand" "vBm")
12999           (parallel [(const_int 0)
13000                      (const_int 1)
13001                      (const_int 2)
13002                      (const_int 3)
13003                      (match_operand 2 "const_4_to_7_operand")
13004                      (match_operand 3 "const_4_to_7_operand")
13005                      (match_operand 4 "const_4_to_7_operand")
13006                      (match_operand 5 "const_4_to_7_operand")])))]
13007   "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
13009   int mask = 0;
13010   mask |= (INTVAL (operands[2]) - 4) << 0;
13011   mask |= (INTVAL (operands[3]) - 4) << 2;
13012   mask |= (INTVAL (operands[4]) - 4) << 4;
13013   mask |= (INTVAL (operands[5]) - 4) << 6;
13014   operands[2] = GEN_INT (mask);
13016   return "%vpshufhw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
13018   [(set_attr "type" "sselog")
13019    (set_attr "prefix_rep" "1")
13020    (set_attr "prefix_data16" "0")
13021    (set_attr "prefix" "maybe_vex")
13022    (set_attr "length_immediate" "1")
13023    (set_attr "mode" "TI")])
13025 (define_expand "sse2_loadd"
13026   [(set (match_operand:V4SI 0 "register_operand")
13027         (vec_merge:V4SI
13028           (vec_duplicate:V4SI
13029             (match_operand:SI 1 "nonimmediate_operand"))
13030           (match_dup 2)
13031           (const_int 1)))]
13032   "TARGET_SSE"
13033   "operands[2] = CONST0_RTX (V4SImode);")
13035 (define_insn "sse2_loadld"
13036   [(set (match_operand:V4SI 0 "register_operand"       "=v,Yi,x,x,v")
13037         (vec_merge:V4SI
13038           (vec_duplicate:V4SI
13039             (match_operand:SI 2 "nonimmediate_operand" "m ,r ,m,x,v"))
13040           (match_operand:V4SI 1 "reg_or_0_operand"     "C ,C ,C,0,v")
13041           (const_int 1)))]
13042   "TARGET_SSE"
13043   "@
13044    %vmovd\t{%2, %0|%0, %2}
13045    %vmovd\t{%2, %0|%0, %2}
13046    movss\t{%2, %0|%0, %2}
13047    movss\t{%2, %0|%0, %2}
13048    vmovss\t{%2, %1, %0|%0, %1, %2}"
13049   [(set_attr "isa" "sse2,sse2,noavx,noavx,avx")
13050    (set_attr "type" "ssemov")
13051    (set_attr "prefix" "maybe_vex,maybe_vex,orig,orig,maybe_evex")
13052    (set_attr "mode" "TI,TI,V4SF,SF,SF")])
13054 ;; QI and HI modes handled by pextr patterns.
13055 (define_mode_iterator PEXTR_MODE12
13056   [(V16QI "TARGET_SSE4_1") V8HI])
13058 (define_insn "*vec_extract<mode>"
13059   [(set (match_operand:<ssescalarmode> 0 "register_sse4nonimm_operand" "=r,m,r,m")
13060         (vec_select:<ssescalarmode>
13061           (match_operand:PEXTR_MODE12 1 "register_operand" "x,x,v,v")
13062           (parallel
13063             [(match_operand:SI 2 "const_0_to_<ssescalarnummask>_operand")])))]
13064   "TARGET_SSE2"
13065   "@
13066    %vpextr<ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
13067    %vpextr<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
13068    vpextr<ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
13069    vpextr<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
13070   [(set_attr "isa" "*,sse4,avx512bw,avx512bw")
13071    (set_attr "type" "sselog1")
13072    (set_attr "prefix_data16" "1")
13073    (set (attr "prefix_extra")
13074      (if_then_else
13075        (and (eq_attr "alternative" "0,2")
13076             (eq (const_string "<MODE>mode") (const_string "V8HImode")))
13077        (const_string "*")
13078        (const_string "1")))
13079    (set_attr "length_immediate" "1")
13080    (set_attr "prefix" "maybe_vex,maybe_vex,evex,evex")
13081    (set_attr "mode" "TI")])
13083 (define_insn "*vec_extract<PEXTR_MODE12:mode>_zext"
13084   [(set (match_operand:SWI48 0 "register_operand" "=r,r")
13085         (zero_extend:SWI48
13086           (vec_select:<PEXTR_MODE12:ssescalarmode>
13087             (match_operand:PEXTR_MODE12 1 "register_operand" "x,v")
13088             (parallel
13089               [(match_operand:SI 2
13090                 "const_0_to_<PEXTR_MODE12:ssescalarnummask>_operand")]))))]
13091   "TARGET_SSE2"
13092   "@
13093    %vpextr<PEXTR_MODE12:ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}
13094    vpextr<PEXTR_MODE12:ssemodesuffix>\t{%2, %1, %k0|%k0, %1, %2}"
13095   [(set_attr "isa" "*,avx512bw")
13096    (set_attr "type" "sselog1")
13097    (set_attr "prefix_data16" "1")
13098    (set (attr "prefix_extra")
13099      (if_then_else
13100        (eq (const_string "<PEXTR_MODE12:MODE>mode") (const_string "V8HImode"))
13101        (const_string "*")
13102        (const_string "1")))
13103    (set_attr "length_immediate" "1")
13104    (set_attr "prefix" "maybe_vex")
13105    (set_attr "mode" "TI")])
13107 (define_insn "*vec_extract<mode>_mem"
13108   [(set (match_operand:<ssescalarmode> 0 "register_operand" "=r")
13109         (vec_select:<ssescalarmode>
13110           (match_operand:VI12_128 1 "memory_operand" "o")
13111           (parallel
13112             [(match_operand 2 "const_0_to_<ssescalarnummask>_operand")])))]
13113   "TARGET_SSE"
13114   "#")
13116 (define_insn "*vec_extract<ssevecmodelower>_0"
13117   [(set (match_operand:SWI48 0 "nonimmediate_operand"          "=r ,r,v ,m")
13118         (vec_select:SWI48
13119           (match_operand:<ssevecmode> 1 "nonimmediate_operand" "mYj,v,vm,v")
13120           (parallel [(const_int 0)])))]
13121   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13122   "#"
13123   [(set_attr "isa" "*,sse4,*,*")])
13125 (define_insn_and_split "*vec_extractv4si_0_zext"
13126   [(set (match_operand:DI 0 "register_operand" "=r")
13127         (zero_extend:DI
13128           (vec_select:SI
13129             (match_operand:V4SI 1 "register_operand" "v")
13130             (parallel [(const_int 0)]))))]
13131   "TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_FROM_VEC"
13132   "#"
13133   "&& reload_completed"
13134   [(set (match_dup 0) (zero_extend:DI (match_dup 1)))]
13135   "operands[1] = gen_lowpart (SImode, operands[1]);")
13137 (define_insn "*vec_extractv2di_0_sse"
13138   [(set (match_operand:DI 0 "nonimmediate_operand"     "=v,m")
13139         (vec_select:DI
13140           (match_operand:V2DI 1 "nonimmediate_operand" "vm,v")
13141           (parallel [(const_int 0)])))]
13142   "TARGET_SSE && !TARGET_64BIT
13143    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13144   "#")
13146 (define_split
13147   [(set (match_operand:SWI48x 0 "nonimmediate_operand")
13148         (vec_select:SWI48x
13149           (match_operand:<ssevecmode> 1 "register_operand")
13150           (parallel [(const_int 0)])))]
13151   "TARGET_SSE && reload_completed"
13152   [(set (match_dup 0) (match_dup 1))]
13153   "operands[1] = gen_lowpart (<MODE>mode, operands[1]);")
13155 (define_insn "*vec_extractv4si"
13156   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm,Yr,*x,x,Yv")
13157         (vec_select:SI
13158           (match_operand:V4SI 1 "register_operand" "x,v,0,0,x,v")
13159           (parallel [(match_operand:SI 2 "const_0_to_3_operand")])))]
13160   "TARGET_SSE4_1"
13162   switch (which_alternative)
13163     {
13164     case 0:
13165     case 1:
13166       return "%vpextrd\t{%2, %1, %0|%0, %1, %2}";
13168     case 2:
13169     case 3:
13170       operands[2] = GEN_INT (INTVAL (operands[2]) * 4);
13171       return "psrldq\t{%2, %0|%0, %2}";
13173     case 4:
13174     case 5:
13175       operands[2] = GEN_INT (INTVAL (operands[2]) * 4);
13176       return "vpsrldq\t{%2, %1, %0|%0, %1, %2}";
13178     default:
13179       gcc_unreachable ();
13180     }
13182   [(set_attr "isa" "*,avx512dq,noavx,noavx,avx,avx512bw")
13183    (set_attr "type" "sselog1,sselog1,sseishft1,sseishft1,sseishft1,sseishft1")
13184    (set_attr "prefix_extra" "1,1,*,*,*,*")
13185    (set_attr "length_immediate" "1")
13186    (set_attr "prefix" "maybe_vex,evex,orig,orig,vex,evex")
13187    (set_attr "mode" "TI")])
13189 (define_insn "*vec_extractv4si_zext"
13190   [(set (match_operand:DI 0 "register_operand" "=r,r")
13191         (zero_extend:DI
13192           (vec_select:SI
13193             (match_operand:V4SI 1 "register_operand" "x,v")
13194             (parallel [(match_operand:SI 2 "const_0_to_3_operand")]))))]
13195   "TARGET_64BIT && TARGET_SSE4_1"
13196   "%vpextrd\t{%2, %1, %k0|%k0, %1, %2}"
13197   [(set_attr "isa" "*,avx512dq")
13198    (set_attr "type" "sselog1")
13199    (set_attr "prefix_extra" "1")
13200    (set_attr "length_immediate" "1")
13201    (set_attr "prefix" "maybe_vex")
13202    (set_attr "mode" "TI")])
13204 (define_insn "*vec_extractv4si_mem"
13205   [(set (match_operand:SI 0 "register_operand" "=x,r")
13206         (vec_select:SI
13207           (match_operand:V4SI 1 "memory_operand" "o,o")
13208           (parallel [(match_operand 2 "const_0_to_3_operand")])))]
13209   "TARGET_SSE"
13210   "#")
13212 (define_insn_and_split "*vec_extractv4si_zext_mem"
13213   [(set (match_operand:DI 0 "register_operand" "=x,r")
13214         (zero_extend:DI
13215           (vec_select:SI
13216             (match_operand:V4SI 1 "memory_operand" "o,o")
13217             (parallel [(match_operand:SI 2 "const_0_to_3_operand")]))))]
13218   "TARGET_64BIT && TARGET_SSE"
13219   "#"
13220   "&& reload_completed"
13221   [(set (match_dup 0) (zero_extend:DI (match_dup 1)))]
13223   operands[1] = adjust_address (operands[1], SImode, INTVAL (operands[2]) * 4);
13226 (define_insn "*vec_extractv2di_1"
13227   [(set (match_operand:DI 0 "nonimmediate_operand"     "=rm,rm,m,x,x,Yv,x,v,r")
13228         (vec_select:DI
13229           (match_operand:V2DI 1 "nonimmediate_operand"  "x ,v ,v,0,x, v,x,o,o")
13230           (parallel [(const_int 1)])))]
13231   "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
13232   "@
13233    %vpextrq\t{$1, %1, %0|%0, %1, 1}
13234    vpextrq\t{$1, %1, %0|%0, %1, 1}
13235    %vmovhps\t{%1, %0|%0, %1}
13236    psrldq\t{$8, %0|%0, 8}
13237    vpsrldq\t{$8, %1, %0|%0, %1, 8}
13238    vpsrldq\t{$8, %1, %0|%0, %1, 8}
13239    movhlps\t{%1, %0|%0, %1}
13240    #
13241    #"
13242   [(set_attr "isa" "x64_sse4,x64_avx512dq,*,sse2_noavx,avx,avx512bw,noavx,*,x64")
13243    (set_attr "type" "sselog1,sselog1,ssemov,sseishft1,sseishft1,sseishft1,ssemov,ssemov,imov")
13244    (set_attr "length_immediate" "1,1,*,1,1,1,*,*,*")
13245    (set_attr "prefix_rex" "1,1,*,*,*,*,*,*,*")
13246    (set_attr "prefix_extra" "1,1,*,*,*,*,*,*,*")
13247    (set_attr "prefix" "maybe_vex,evex,maybe_vex,orig,vex,evex,orig,*,*")
13248    (set_attr "mode" "TI,TI,V2SF,TI,TI,TI,V4SF,DI,DI")])
13250 (define_split
13251   [(set (match_operand:<ssescalarmode> 0 "register_operand")
13252         (vec_select:<ssescalarmode>
13253           (match_operand:VI_128 1 "memory_operand")
13254           (parallel
13255             [(match_operand 2 "const_0_to_<ssescalarnummask>_operand")])))]
13256   "TARGET_SSE && reload_completed"
13257   [(set (match_dup 0) (match_dup 1))]
13259   int offs = INTVAL (operands[2]) * GET_MODE_SIZE (<ssescalarmode>mode);
13261   operands[1] = adjust_address (operands[1], <ssescalarmode>mode, offs);
13264 ;; Turn SImode or DImode extraction from arbitrary SSE/AVX/AVX512F
13265 ;; vector modes into vec_extract*.
13266 (define_split
13267   [(set (match_operand:SWI48x 0 "nonimmediate_operand")
13268         (match_operand:SWI48x 1 "register_operand"))]
13269   "can_create_pseudo_p ()
13270    && SUBREG_P (operands[1])
13271    && REG_P (SUBREG_REG (operands[1]))
13272    && (GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[1]))) == MODE_VECTOR_INT
13273        || (GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[1])))
13274            == MODE_VECTOR_FLOAT))
13275    && SUBREG_BYTE (operands[1]) == 0
13276    && TARGET_SSE
13277    && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[1]))) == 16
13278        || (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[1]))) == 32
13279            && TARGET_AVX)
13280        || (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[1]))) == 64
13281            && TARGET_AVX512F))
13282    && (<MODE>mode == SImode || TARGET_64BIT || MEM_P (operands[0]))"
13283   [(set (match_dup 0) (vec_select:SWI48x (match_dup 1)
13284                                          (parallel [(const_int 0)])))]
13286   rtx tmp;
13287   operands[1] = SUBREG_REG (operands[1]);
13288   switch (GET_MODE_SIZE (GET_MODE (operands[1])))
13289     {
13290     case 64:
13291       if (<MODE>mode == SImode)
13292         {
13293           tmp = gen_reg_rtx (V8SImode);
13294           emit_insn (gen_vec_extract_lo_v16si (tmp,
13295                                                gen_lowpart (V16SImode,
13296                                                             operands[1])));
13297         }
13298       else
13299         {
13300           tmp = gen_reg_rtx (V4DImode);
13301           emit_insn (gen_vec_extract_lo_v8di (tmp,
13302                                               gen_lowpart (V8DImode,
13303                                                            operands[1])));
13304         }
13305       operands[1] = tmp;
13306       /* FALLTHRU */
13307     case 32:
13308       tmp = gen_reg_rtx (<ssevecmode>mode);
13309       if (<MODE>mode == SImode)
13310         emit_insn (gen_vec_extract_lo_v8si (tmp, gen_lowpart (V8SImode,
13311                                                               operands[1])));
13312       else
13313         emit_insn (gen_vec_extract_lo_v4di (tmp, gen_lowpart (V4DImode,
13314                                                               operands[1])));
13315       operands[1] = tmp;
13316       break;
13317     case 16:
13318       operands[1] = gen_lowpart (<ssevecmode>mode, operands[1]);
13319       break;
13320     }
13323 (define_insn "*vec_concatv2si_sse4_1"
13324   [(set (match_operand:V2SI 0 "register_operand"
13325           "=Yr,*x,x, Yr,*x,x, x, *y,*y")
13326         (vec_concat:V2SI
13327           (match_operand:SI 1 "nonimmediate_operand"
13328           "  0, 0,x,  0,0, x,rm,  0,rm")
13329           (match_operand:SI 2 "vector_move_operand"
13330           " rm,rm,rm,Yr,*x,x, C,*ym, C")))]
13331   "TARGET_SSE4_1 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
13332   "@
13333    pinsrd\t{$1, %2, %0|%0, %2, 1}
13334    pinsrd\t{$1, %2, %0|%0, %2, 1}
13335    vpinsrd\t{$1, %2, %1, %0|%0, %1, %2, 1}
13336    punpckldq\t{%2, %0|%0, %2}
13337    punpckldq\t{%2, %0|%0, %2}
13338    vpunpckldq\t{%2, %1, %0|%0, %1, %2}
13339    %vmovd\t{%1, %0|%0, %1}
13340    punpckldq\t{%2, %0|%0, %2}
13341    movd\t{%1, %0|%0, %1}"
13342   [(set_attr "isa" "noavx,noavx,avx,noavx,noavx,avx,*,*,*")
13343    (set_attr "type" "sselog,sselog,sselog,sselog,sselog,sselog,ssemov,mmxcvt,mmxmov")
13344    (set_attr "prefix_extra" "1,1,1,*,*,*,*,*,*")
13345    (set_attr "length_immediate" "1,1,1,*,*,*,*,*,*")
13346    (set_attr "prefix" "orig,orig,vex,orig,orig,vex,maybe_vex,orig,orig")
13347    (set_attr "mode" "TI,TI,TI,TI,TI,TI,TI,DI,DI")])
13349 ;; ??? In theory we can match memory for the MMX alternative, but allowing
13350 ;; nonimmediate_operand for operand 2 and *not* allowing memory for the SSE
13351 ;; alternatives pretty much forces the MMX alternative to be chosen.
13352 (define_insn "*vec_concatv2si"
13353   [(set (match_operand:V2SI 0 "register_operand"     "=x,x ,*y,x,x,*y,*y")
13354         (vec_concat:V2SI
13355           (match_operand:SI 1 "nonimmediate_operand" " 0,rm,rm,0,m, 0,*rm")
13356           (match_operand:SI 2 "reg_or_0_operand"     " x,C ,C, x,C,*y,C")))]
13357   "TARGET_SSE && !TARGET_SSE4_1"
13358   "@
13359    punpckldq\t{%2, %0|%0, %2}
13360    movd\t{%1, %0|%0, %1}
13361    movd\t{%1, %0|%0, %1}
13362    unpcklps\t{%2, %0|%0, %2}
13363    movss\t{%1, %0|%0, %1}
13364    punpckldq\t{%2, %0|%0, %2}
13365    movd\t{%1, %0|%0, %1}"
13366   [(set_attr "isa" "sse2,sse2,sse2,*,*,*,*")
13367    (set_attr "type" "sselog,ssemov,mmxmov,sselog,ssemov,mmxcvt,mmxmov")
13368    (set_attr "mode" "TI,TI,DI,V4SF,SF,DI,DI")])
13370 (define_insn "*vec_concatv4si"
13371   [(set (match_operand:V4SI 0 "register_operand"       "=x,x,x,x,x")
13372         (vec_concat:V4SI
13373           (match_operand:V2SI 1 "register_operand"     " 0,x,0,0,x")
13374           (match_operand:V2SI 2 "nonimmediate_operand" " x,x,x,m,m")))]
13375   "TARGET_SSE"
13376   "@
13377    punpcklqdq\t{%2, %0|%0, %2}
13378    vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
13379    movlhps\t{%2, %0|%0, %2}
13380    movhps\t{%2, %0|%0, %q2}
13381    vmovhps\t{%2, %1, %0|%0, %1, %q2}"
13382   [(set_attr "isa" "sse2_noavx,avx,noavx,noavx,avx")
13383    (set_attr "type" "sselog,sselog,ssemov,ssemov,ssemov")
13384    (set_attr "prefix" "orig,vex,orig,orig,vex")
13385    (set_attr "mode" "TI,TI,V4SF,V2SF,V2SF")])
13387 ;; movd instead of movq is required to handle broken assemblers.
13388 (define_insn "vec_concatv2di"
13389   [(set (match_operand:V2DI 0 "register_operand"
13390           "=Yr,*x,x ,Yi,x ,!x,x,x,x,x,x")
13391         (vec_concat:V2DI
13392           (match_operand:DI 1 "nonimmediate_operand"
13393           "  0, 0,x ,r ,xm,*y,0,x,0,0,x")
13394           (match_operand:DI 2 "vector_move_operand"
13395           "*rm,rm,rm,C ,C ,C ,x,x,x,m,m")))]
13396   "TARGET_SSE"
13397   "@
13398    pinsrq\t{$1, %2, %0|%0, %2, 1}
13399    pinsrq\t{$1, %2, %0|%0, %2, 1}
13400    vpinsrq\t{$1, %2, %1, %0|%0, %1, %2, 1}
13401    * return HAVE_AS_IX86_INTERUNIT_MOVQ ? \"%vmovq\t{%1, %0|%0, %1}\" : \"%vmovd\t{%1, %0|%0, %1}\";
13402    %vmovq\t{%1, %0|%0, %1}
13403    movq2dq\t{%1, %0|%0, %1}
13404    punpcklqdq\t{%2, %0|%0, %2}
13405    vpunpcklqdq\t{%2, %1, %0|%0, %1, %2}
13406    movlhps\t{%2, %0|%0, %2}
13407    movhps\t{%2, %0|%0, %2}
13408    vmovhps\t{%2, %1, %0|%0, %1, %2}"
13409   [(set_attr "isa" "x64_sse4_noavx,x64_sse4_noavx,x64_avx,x64,sse2,sse2,sse2_noavx,avx,noavx,noavx,avx")
13410    (set (attr "type")
13411      (if_then_else
13412        (eq_attr "alternative" "0,1,2,6,7")
13413        (const_string "sselog")
13414        (const_string "ssemov")))
13415    (set_attr "prefix_rex" "1,1,1,1,*,*,*,*,*,*,*")
13416    (set_attr "prefix_extra" "1,1,1,*,*,*,*,*,*,*,*")
13417    (set_attr "length_immediate" "1,1,1,*,*,*,*,*,*,*,*")
13418    (set_attr "prefix" "orig,orig,vex,maybe_vex,maybe_vex,orig,orig,vex,orig,orig,vex")
13419    (set_attr "mode" "TI,TI,TI,TI,TI,TI,TI,TI,V4SF,V2SF,V2SF")])
13421 (define_expand "vec_unpacks_lo_<mode>"
13422   [(match_operand:<sseunpackmode> 0 "register_operand")
13423    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
13424   "TARGET_SSE2"
13425   "ix86_expand_sse_unpack (operands[0], operands[1], false, false); DONE;")
13427 (define_expand "vec_unpacks_hi_<mode>"
13428   [(match_operand:<sseunpackmode> 0 "register_operand")
13429    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
13430   "TARGET_SSE2"
13431   "ix86_expand_sse_unpack (operands[0], operands[1], false, true); DONE;")
13433 (define_expand "vec_unpacku_lo_<mode>"
13434   [(match_operand:<sseunpackmode> 0 "register_operand")
13435    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
13436   "TARGET_SSE2"
13437   "ix86_expand_sse_unpack (operands[0], operands[1], true, false); DONE;")
13439 (define_expand "vec_unpacks_lo_hi"
13440   [(set (subreg:HI (match_operand:QI 0 "register_operand") 0)
13441         (match_operand:HI 1 "register_operand"))]
13442   "TARGET_AVX512F")
13444 (define_expand "vec_unpacks_lo_si"
13445   [(set (match_operand:HI 0 "register_operand")
13446         (subreg:HI (match_operand:SI 1 "register_operand") 0))]
13447   "TARGET_AVX512F")
13449 (define_expand "vec_unpacks_lo_di"
13450   [(set (match_operand:SI 0 "register_operand")
13451         (subreg:SI (match_operand:DI 1 "register_operand") 0))]
13452   "TARGET_AVX512BW")
13454 (define_expand "vec_unpacku_hi_<mode>"
13455   [(match_operand:<sseunpackmode> 0 "register_operand")
13456    (match_operand:VI124_AVX2_24_AVX512F_1_AVX512BW 1 "register_operand")]
13457   "TARGET_SSE2"
13458   "ix86_expand_sse_unpack (operands[0], operands[1], true, true); DONE;")
13460 (define_expand "vec_unpacks_hi_hi"
13461   [(set (subreg:HI (match_operand:QI 0 "register_operand") 0)
13462         (lshiftrt:HI (match_operand:HI 1 "register_operand")
13463                      (const_int 8)))]
13464   "TARGET_AVX512F")
13466 (define_expand "vec_unpacks_hi_<mode>"
13467   [(set (subreg:SWI48x (match_operand:<HALFMASKMODE> 0 "register_operand") 0)
13468         (lshiftrt:SWI48x (match_operand:SWI48x 1 "register_operand")
13469                          (match_dup 2)))]
13470   "TARGET_AVX512BW"
13472   operands[2] = GEN_INT (GET_MODE_BITSIZE (<HALFMASKMODE>mode));
13475 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13477 ;; Miscellaneous
13479 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13481 (define_expand "<sse2_avx2>_uavg<mode>3<mask_name>"
13482   [(set (match_operand:VI12_AVX2 0 "register_operand")
13483         (truncate:VI12_AVX2
13484           (lshiftrt:<ssedoublemode>
13485             (plus:<ssedoublemode>
13486               (plus:<ssedoublemode>
13487                 (zero_extend:<ssedoublemode>
13488                   (match_operand:VI12_AVX2 1 "vector_operand"))
13489                 (zero_extend:<ssedoublemode>
13490                   (match_operand:VI12_AVX2 2 "vector_operand")))
13491               (match_dup <mask_expand_op3>))
13492             (const_int 1))))]
13493   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
13495   rtx tmp;
13496   if (<mask_applied>)
13497     tmp = operands[3];
13498   operands[3] = CONST1_RTX(<MODE>mode);
13499   ix86_fixup_binary_operands_no_copy (PLUS, <MODE>mode, operands);
13501   if (<mask_applied>)
13502     {
13503       operands[5] = operands[3];
13504       operands[3] = tmp;
13505     }
13508 (define_insn "*<sse2_avx2>_uavg<mode>3<mask_name>"
13509   [(set (match_operand:VI12_AVX2 0 "register_operand" "=x,v")
13510         (truncate:VI12_AVX2
13511           (lshiftrt:<ssedoublemode>
13512             (plus:<ssedoublemode>
13513               (plus:<ssedoublemode>
13514                 (zero_extend:<ssedoublemode>
13515                   (match_operand:VI12_AVX2 1 "vector_operand" "%0,v"))
13516                 (zero_extend:<ssedoublemode>
13517                   (match_operand:VI12_AVX2 2 "vector_operand" "xBm,vm")))
13518               (match_operand:VI12_AVX2 <mask_expand_op3> "const1_operand"))
13519             (const_int 1))))]
13520   "TARGET_SSE2 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
13521    && ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
13522   "@
13523    pavg<ssemodesuffix>\t{%2, %0|%0, %2}
13524    vpavg<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
13525   [(set_attr "isa" "noavx,avx")
13526    (set_attr "type" "sseiadd")
13527    (set_attr "prefix_data16" "1,*")
13528    (set_attr "prefix" "orig,<mask_prefix>")
13529    (set_attr "mode" "<sseinsnmode>")])
13531 ;; The correct representation for this is absolutely enormous, and
13532 ;; surely not generally useful.
13533 (define_insn "<sse2_avx2>_psadbw"
13534   [(set (match_operand:VI8_AVX2_AVX512BW 0 "register_operand" "=x,v")
13535         (unspec:VI8_AVX2_AVX512BW
13536           [(match_operand:<ssebytemode> 1 "register_operand" "0,v")
13537            (match_operand:<ssebytemode> 2 "vector_operand" "xBm,vm")]
13538           UNSPEC_PSADBW))]
13539   "TARGET_SSE2"
13540   "@
13541    psadbw\t{%2, %0|%0, %2}
13542    vpsadbw\t{%2, %1, %0|%0, %1, %2}"
13543   [(set_attr "isa" "noavx,avx")
13544    (set_attr "type" "sseiadd")
13545    (set_attr "atom_unit" "simul")
13546    (set_attr "prefix_data16" "1,*")
13547    (set_attr "prefix" "orig,maybe_evex")
13548    (set_attr "mode" "<sseinsnmode>")])
13550 (define_insn "<sse>_movmsk<ssemodesuffix><avxsizesuffix>"
13551   [(set (match_operand:SI 0 "register_operand" "=r")
13552         (unspec:SI
13553           [(match_operand:VF_128_256 1 "register_operand" "x")]
13554           UNSPEC_MOVMSK))]
13555   "TARGET_SSE"
13556   "%vmovmsk<ssemodesuffix>\t{%1, %0|%0, %1}"
13557   [(set_attr "type" "ssemov")
13558    (set_attr "prefix" "maybe_vex")
13559    (set_attr "mode" "<MODE>")])
13561 (define_insn "*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_zext"
13562   [(set (match_operand:DI 0 "register_operand" "=r")
13563         (zero_extend:DI
13564           (unspec:SI
13565             [(match_operand:VF_128_256 1 "register_operand" "x")]
13566             UNSPEC_MOVMSK)))]
13567   "TARGET_64BIT && TARGET_SSE"
13568   "%vmovmsk<ssemodesuffix>\t{%1, %k0|%k0, %1}"
13569   [(set_attr "type" "ssemov")
13570    (set_attr "prefix" "maybe_vex")
13571    (set_attr "mode" "<MODE>")])
13573 (define_insn "<sse2_avx2>_pmovmskb"
13574   [(set (match_operand:SI 0 "register_operand" "=r")
13575         (unspec:SI
13576           [(match_operand:VI1_AVX2 1 "register_operand" "x")]
13577           UNSPEC_MOVMSK))]
13578   "TARGET_SSE2"
13579   "%vpmovmskb\t{%1, %0|%0, %1}"
13580   [(set_attr "type" "ssemov")
13581    (set (attr "prefix_data16")
13582      (if_then_else
13583        (match_test "TARGET_AVX")
13584      (const_string "*")
13585      (const_string "1")))
13586    (set_attr "prefix" "maybe_vex")
13587    (set_attr "mode" "SI")])
13589 (define_insn "*<sse2_avx2>_pmovmskb_zext"
13590   [(set (match_operand:DI 0 "register_operand" "=r")
13591         (zero_extend:DI
13592           (unspec:SI
13593             [(match_operand:VI1_AVX2 1 "register_operand" "x")]
13594             UNSPEC_MOVMSK)))]
13595   "TARGET_64BIT && TARGET_SSE2"
13596   "%vpmovmskb\t{%1, %k0|%k0, %1}"
13597   [(set_attr "type" "ssemov")
13598    (set (attr "prefix_data16")
13599      (if_then_else
13600        (match_test "TARGET_AVX")
13601      (const_string "*")
13602      (const_string "1")))
13603    (set_attr "prefix" "maybe_vex")
13604    (set_attr "mode" "SI")])
13606 (define_expand "sse2_maskmovdqu"
13607   [(set (match_operand:V16QI 0 "memory_operand")
13608         (unspec:V16QI [(match_operand:V16QI 1 "register_operand")
13609                        (match_operand:V16QI 2 "register_operand")
13610                        (match_dup 0)]
13611                       UNSPEC_MASKMOV))]
13612   "TARGET_SSE2")
13614 (define_insn "*sse2_maskmovdqu"
13615   [(set (mem:V16QI (match_operand:P 0 "register_operand" "D"))
13616         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "x")
13617                        (match_operand:V16QI 2 "register_operand" "x")
13618                        (mem:V16QI (match_dup 0))]
13619                       UNSPEC_MASKMOV))]
13620   "TARGET_SSE2"
13622   /* We can't use %^ here due to ASM_OUTPUT_OPCODE processing
13623      that requires %v to be at the beginning of the opcode name.  */
13624   if (Pmode != word_mode)
13625     fputs ("\taddr32", asm_out_file);
13626   return "%vmaskmovdqu\t{%2, %1|%1, %2}";
13628   [(set_attr "type" "ssemov")
13629    (set_attr "prefix_data16" "1")
13630    (set (attr "length_address")
13631      (symbol_ref ("Pmode != word_mode")))
13632    ;; The implicit %rdi operand confuses default length_vex computation.
13633    (set (attr "length_vex")
13634      (symbol_ref ("3 + REX_SSE_REGNO_P (REGNO (operands[2]))")))
13635    (set_attr "prefix" "maybe_vex")
13636    (set_attr "znver1_decode" "vector")
13637    (set_attr "mode" "TI")])
13639 (define_insn "sse_ldmxcsr"
13640   [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m")]
13641                     UNSPECV_LDMXCSR)]
13642   "TARGET_SSE"
13643   "%vldmxcsr\t%0"
13644   [(set_attr "type" "sse")
13645    (set_attr "atom_sse_attr" "mxcsr")
13646    (set_attr "prefix" "maybe_vex")
13647    (set_attr "memory" "load")])
13649 (define_insn "sse_stmxcsr"
13650   [(set (match_operand:SI 0 "memory_operand" "=m")
13651         (unspec_volatile:SI [(const_int 0)] UNSPECV_STMXCSR))]
13652   "TARGET_SSE"
13653   "%vstmxcsr\t%0"
13654   [(set_attr "type" "sse")
13655    (set_attr "atom_sse_attr" "mxcsr")
13656    (set_attr "prefix" "maybe_vex")
13657    (set_attr "memory" "store")])
13659 (define_insn "sse2_clflush"
13660   [(unspec_volatile [(match_operand 0 "address_operand" "p")]
13661                     UNSPECV_CLFLUSH)]
13662   "TARGET_SSE2"
13663   "clflush\t%a0"
13664   [(set_attr "type" "sse")
13665    (set_attr "atom_sse_attr" "fence")
13666    (set_attr "memory" "unknown")])
13668 ;; As per AMD and Intel ISA manuals, the first operand is extensions
13669 ;; and it goes to %ecx. The second operand received is hints and it goes
13670 ;; to %eax.
13671 (define_insn "sse3_mwait"
13672   [(unspec_volatile [(match_operand:SI 0 "register_operand" "c")
13673                      (match_operand:SI 1 "register_operand" "a")]
13674                     UNSPECV_MWAIT)]
13675   "TARGET_SSE3"
13676 ;; 64bit version is "mwait %rax,%rcx". But only lower 32bits are used.
13677 ;; Since 32bit register operands are implicitly zero extended to 64bit,
13678 ;; we only need to set up 32bit registers.
13679   "mwait"
13680   [(set_attr "length" "3")])
13682 (define_insn "sse3_monitor_<mode>"
13683   [(unspec_volatile [(match_operand:P 0 "register_operand" "a")
13684                      (match_operand:SI 1 "register_operand" "c")
13685                      (match_operand:SI 2 "register_operand" "d")]
13686                     UNSPECV_MONITOR)]
13687   "TARGET_SSE3"
13688 ;; 64bit version is "monitor %rax,%rcx,%rdx". But only lower 32bits in
13689 ;; RCX and RDX are used.  Since 32bit register operands are implicitly
13690 ;; zero extended to 64bit, we only need to set up 32bit registers.
13691   "%^monitor"
13692   [(set (attr "length")
13693      (symbol_ref ("(Pmode != word_mode) + 3")))])
13695 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13697 ;; SSSE3 instructions
13699 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13701 (define_code_iterator ssse3_plusminus [plus ss_plus minus ss_minus])
13703 (define_insn "avx2_ph<plusminus_mnemonic>wv16hi3"
13704   [(set (match_operand:V16HI 0 "register_operand" "=x")
13705         (vec_concat:V16HI
13706           (vec_concat:V8HI
13707             (vec_concat:V4HI
13708               (vec_concat:V2HI
13709                 (ssse3_plusminus:HI
13710                   (vec_select:HI
13711                     (match_operand:V16HI 1 "register_operand" "x")
13712                     (parallel [(const_int 0)]))
13713                   (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
13714                 (ssse3_plusminus:HI
13715                   (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
13716                   (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
13717               (vec_concat:V2HI
13718                 (ssse3_plusminus:HI
13719                   (vec_select:HI (match_dup 1) (parallel [(const_int 4)]))
13720                   (vec_select:HI (match_dup 1) (parallel [(const_int 5)])))
13721                 (ssse3_plusminus:HI
13722                   (vec_select:HI (match_dup 1) (parallel [(const_int 6)]))
13723                   (vec_select:HI (match_dup 1) (parallel [(const_int 7)])))))
13724             (vec_concat:V4HI
13725               (vec_concat:V2HI
13726                 (ssse3_plusminus:HI
13727                   (vec_select:HI (match_dup 1) (parallel [(const_int 8)]))
13728                   (vec_select:HI (match_dup 1) (parallel [(const_int 9)])))
13729                 (ssse3_plusminus:HI
13730                   (vec_select:HI (match_dup 1) (parallel [(const_int 10)]))
13731                   (vec_select:HI (match_dup 1) (parallel [(const_int 11)]))))
13732               (vec_concat:V2HI
13733                 (ssse3_plusminus:HI
13734                   (vec_select:HI (match_dup 1) (parallel [(const_int 12)]))
13735                   (vec_select:HI (match_dup 1) (parallel [(const_int 13)])))
13736                 (ssse3_plusminus:HI
13737                   (vec_select:HI (match_dup 1) (parallel [(const_int 14)]))
13738                   (vec_select:HI (match_dup 1) (parallel [(const_int 15)]))))))
13739           (vec_concat:V8HI
13740             (vec_concat:V4HI
13741               (vec_concat:V2HI
13742                 (ssse3_plusminus:HI
13743                   (vec_select:HI
13744                     (match_operand:V16HI 2 "nonimmediate_operand" "xm")
13745                     (parallel [(const_int 0)]))
13746                   (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
13747                 (ssse3_plusminus:HI
13748                   (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
13749                   (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))
13750               (vec_concat:V2HI
13751                 (ssse3_plusminus:HI
13752                   (vec_select:HI (match_dup 2) (parallel [(const_int 4)]))
13753                   (vec_select:HI (match_dup 2) (parallel [(const_int 5)])))
13754                 (ssse3_plusminus:HI
13755                   (vec_select:HI (match_dup 2) (parallel [(const_int 6)]))
13756                   (vec_select:HI (match_dup 2) (parallel [(const_int 7)])))))
13757             (vec_concat:V4HI
13758               (vec_concat:V2HI
13759                 (ssse3_plusminus:HI
13760                   (vec_select:HI (match_dup 2) (parallel [(const_int 8)]))
13761                   (vec_select:HI (match_dup 2) (parallel [(const_int 9)])))
13762                 (ssse3_plusminus:HI
13763                   (vec_select:HI (match_dup 2) (parallel [(const_int 10)]))
13764                   (vec_select:HI (match_dup 2) (parallel [(const_int 11)]))))
13765               (vec_concat:V2HI
13766                 (ssse3_plusminus:HI
13767                   (vec_select:HI (match_dup 2) (parallel [(const_int 12)]))
13768                   (vec_select:HI (match_dup 2) (parallel [(const_int 13)])))
13769                 (ssse3_plusminus:HI
13770                   (vec_select:HI (match_dup 2) (parallel [(const_int 14)]))
13771                   (vec_select:HI (match_dup 2) (parallel [(const_int 15)]))))))))]
13772   "TARGET_AVX2"
13773   "vph<plusminus_mnemonic>w\t{%2, %1, %0|%0, %1, %2}"
13774   [(set_attr "type" "sseiadd")
13775    (set_attr "prefix_extra" "1")
13776    (set_attr "prefix" "vex")
13777    (set_attr "mode" "OI")])
13779 (define_insn "ssse3_ph<plusminus_mnemonic>wv8hi3"
13780   [(set (match_operand:V8HI 0 "register_operand" "=x,x")
13781         (vec_concat:V8HI
13782           (vec_concat:V4HI
13783             (vec_concat:V2HI
13784               (ssse3_plusminus:HI
13785                 (vec_select:HI
13786                   (match_operand:V8HI 1 "register_operand" "0,x")
13787                   (parallel [(const_int 0)]))
13788                 (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
13789               (ssse3_plusminus:HI
13790                 (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
13791                 (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
13792             (vec_concat:V2HI
13793               (ssse3_plusminus:HI
13794                 (vec_select:HI (match_dup 1) (parallel [(const_int 4)]))
13795                 (vec_select:HI (match_dup 1) (parallel [(const_int 5)])))
13796               (ssse3_plusminus:HI
13797                 (vec_select:HI (match_dup 1) (parallel [(const_int 6)]))
13798                 (vec_select:HI (match_dup 1) (parallel [(const_int 7)])))))
13799           (vec_concat:V4HI
13800             (vec_concat:V2HI
13801               (ssse3_plusminus:HI
13802                 (vec_select:HI
13803                   (match_operand:V8HI 2 "vector_operand" "xBm,xm")
13804                   (parallel [(const_int 0)]))
13805                 (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
13806               (ssse3_plusminus:HI
13807                 (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
13808                 (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))
13809             (vec_concat:V2HI
13810               (ssse3_plusminus:HI
13811                 (vec_select:HI (match_dup 2) (parallel [(const_int 4)]))
13812                 (vec_select:HI (match_dup 2) (parallel [(const_int 5)])))
13813               (ssse3_plusminus:HI
13814                 (vec_select:HI (match_dup 2) (parallel [(const_int 6)]))
13815                 (vec_select:HI (match_dup 2) (parallel [(const_int 7)])))))))]
13816   "TARGET_SSSE3"
13817   "@
13818    ph<plusminus_mnemonic>w\t{%2, %0|%0, %2}
13819    vph<plusminus_mnemonic>w\t{%2, %1, %0|%0, %1, %2}"
13820   [(set_attr "isa" "noavx,avx")
13821    (set_attr "type" "sseiadd")
13822    (set_attr "atom_unit" "complex")
13823    (set_attr "prefix_data16" "1,*")
13824    (set_attr "prefix_extra" "1")
13825    (set_attr "prefix" "orig,vex")
13826    (set_attr "mode" "TI")])
13828 (define_insn "ssse3_ph<plusminus_mnemonic>wv4hi3"
13829   [(set (match_operand:V4HI 0 "register_operand" "=y")
13830         (vec_concat:V4HI
13831           (vec_concat:V2HI
13832             (ssse3_plusminus:HI
13833               (vec_select:HI
13834                 (match_operand:V4HI 1 "register_operand" "0")
13835                 (parallel [(const_int 0)]))
13836               (vec_select:HI (match_dup 1) (parallel [(const_int 1)])))
13837             (ssse3_plusminus:HI
13838               (vec_select:HI (match_dup 1) (parallel [(const_int 2)]))
13839               (vec_select:HI (match_dup 1) (parallel [(const_int 3)]))))
13840           (vec_concat:V2HI
13841             (ssse3_plusminus:HI
13842               (vec_select:HI
13843                 (match_operand:V4HI 2 "nonimmediate_operand" "ym")
13844                 (parallel [(const_int 0)]))
13845               (vec_select:HI (match_dup 2) (parallel [(const_int 1)])))
13846             (ssse3_plusminus:HI
13847               (vec_select:HI (match_dup 2) (parallel [(const_int 2)]))
13848               (vec_select:HI (match_dup 2) (parallel [(const_int 3)]))))))]
13849   "TARGET_SSSE3"
13850   "ph<plusminus_mnemonic>w\t{%2, %0|%0, %2}"
13851   [(set_attr "type" "sseiadd")
13852    (set_attr "atom_unit" "complex")
13853    (set_attr "prefix_extra" "1")
13854    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
13855    (set_attr "mode" "DI")])
13857 (define_insn "avx2_ph<plusminus_mnemonic>dv8si3"
13858   [(set (match_operand:V8SI 0 "register_operand" "=x")
13859         (vec_concat:V8SI
13860           (vec_concat:V4SI
13861             (vec_concat:V2SI
13862               (plusminus:SI
13863                 (vec_select:SI
13864                   (match_operand:V8SI 1 "register_operand" "x")
13865                   (parallel [(const_int 0)]))
13866                 (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
13867               (plusminus:SI
13868                 (vec_select:SI (match_dup 1) (parallel [(const_int 2)]))
13869                 (vec_select:SI (match_dup 1) (parallel [(const_int 3)]))))
13870             (vec_concat:V2SI
13871               (plusminus:SI
13872                 (vec_select:SI (match_dup 1) (parallel [(const_int 4)]))
13873                 (vec_select:SI (match_dup 1) (parallel [(const_int 5)])))
13874               (plusminus:SI
13875                 (vec_select:SI (match_dup 1) (parallel [(const_int 6)]))
13876                 (vec_select:SI (match_dup 1) (parallel [(const_int 7)])))))
13877           (vec_concat:V4SI
13878             (vec_concat:V2SI
13879               (plusminus:SI
13880                 (vec_select:SI
13881                   (match_operand:V8SI 2 "nonimmediate_operand" "xm")
13882                   (parallel [(const_int 0)]))
13883                 (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))
13884               (plusminus:SI
13885                 (vec_select:SI (match_dup 2) (parallel [(const_int 2)]))
13886                 (vec_select:SI (match_dup 2) (parallel [(const_int 3)]))))
13887             (vec_concat:V2SI
13888               (plusminus:SI
13889                 (vec_select:SI (match_dup 2) (parallel [(const_int 4)]))
13890                 (vec_select:SI (match_dup 2) (parallel [(const_int 5)])))
13891               (plusminus:SI
13892                 (vec_select:SI (match_dup 2) (parallel [(const_int 6)]))
13893                 (vec_select:SI (match_dup 2) (parallel [(const_int 7)])))))))]
13894   "TARGET_AVX2"
13895   "vph<plusminus_mnemonic>d\t{%2, %1, %0|%0, %1, %2}"
13896   [(set_attr "type" "sseiadd")
13897    (set_attr "prefix_extra" "1")
13898    (set_attr "prefix" "vex")
13899    (set_attr "mode" "OI")])
13901 (define_insn "ssse3_ph<plusminus_mnemonic>dv4si3"
13902   [(set (match_operand:V4SI 0 "register_operand" "=x,x")
13903         (vec_concat:V4SI
13904           (vec_concat:V2SI
13905             (plusminus:SI
13906               (vec_select:SI
13907                 (match_operand:V4SI 1 "register_operand" "0,x")
13908                 (parallel [(const_int 0)]))
13909               (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
13910             (plusminus:SI
13911               (vec_select:SI (match_dup 1) (parallel [(const_int 2)]))
13912               (vec_select:SI (match_dup 1) (parallel [(const_int 3)]))))
13913           (vec_concat:V2SI
13914             (plusminus:SI
13915               (vec_select:SI
13916                 (match_operand:V4SI 2 "vector_operand" "xBm,xm")
13917                 (parallel [(const_int 0)]))
13918               (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))
13919             (plusminus:SI
13920               (vec_select:SI (match_dup 2) (parallel [(const_int 2)]))
13921               (vec_select:SI (match_dup 2) (parallel [(const_int 3)]))))))]
13922   "TARGET_SSSE3"
13923   "@
13924    ph<plusminus_mnemonic>d\t{%2, %0|%0, %2}
13925    vph<plusminus_mnemonic>d\t{%2, %1, %0|%0, %1, %2}"
13926   [(set_attr "isa" "noavx,avx")
13927    (set_attr "type" "sseiadd")
13928    (set_attr "atom_unit" "complex")
13929    (set_attr "prefix_data16" "1,*")
13930    (set_attr "prefix_extra" "1")
13931    (set_attr "prefix" "orig,vex")
13932    (set_attr "mode" "TI")])
13934 (define_insn "ssse3_ph<plusminus_mnemonic>dv2si3"
13935   [(set (match_operand:V2SI 0 "register_operand" "=y")
13936         (vec_concat:V2SI
13937           (plusminus:SI
13938             (vec_select:SI
13939               (match_operand:V2SI 1 "register_operand" "0")
13940               (parallel [(const_int 0)]))
13941             (vec_select:SI (match_dup 1) (parallel [(const_int 1)])))
13942           (plusminus:SI
13943             (vec_select:SI
13944               (match_operand:V2SI 2 "nonimmediate_operand" "ym")
13945               (parallel [(const_int 0)]))
13946             (vec_select:SI (match_dup 2) (parallel [(const_int 1)])))))]
13947   "TARGET_SSSE3"
13948   "ph<plusminus_mnemonic>d\t{%2, %0|%0, %2}"
13949   [(set_attr "type" "sseiadd")
13950    (set_attr "atom_unit" "complex")
13951    (set_attr "prefix_extra" "1")
13952    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
13953    (set_attr "mode" "DI")])
13955 (define_insn "avx2_pmaddubsw256"
13956   [(set (match_operand:V16HI 0 "register_operand" "=x,v")
13957         (ss_plus:V16HI
13958           (mult:V16HI
13959             (zero_extend:V16HI
13960               (vec_select:V16QI
13961                 (match_operand:V32QI 1 "register_operand" "x,v")
13962                 (parallel [(const_int 0) (const_int 2)
13963                            (const_int 4) (const_int 6)
13964                            (const_int 8) (const_int 10)
13965                            (const_int 12) (const_int 14)
13966                            (const_int 16) (const_int 18)
13967                            (const_int 20) (const_int 22)
13968                            (const_int 24) (const_int 26)
13969                            (const_int 28) (const_int 30)])))
13970             (sign_extend:V16HI
13971               (vec_select:V16QI
13972                 (match_operand:V32QI 2 "nonimmediate_operand" "xm,vm")
13973                 (parallel [(const_int 0) (const_int 2)
13974                            (const_int 4) (const_int 6)
13975                            (const_int 8) (const_int 10)
13976                            (const_int 12) (const_int 14)
13977                            (const_int 16) (const_int 18)
13978                            (const_int 20) (const_int 22)
13979                            (const_int 24) (const_int 26)
13980                            (const_int 28) (const_int 30)]))))
13981           (mult:V16HI
13982             (zero_extend:V16HI
13983               (vec_select:V16QI (match_dup 1)
13984                 (parallel [(const_int 1) (const_int 3)
13985                            (const_int 5) (const_int 7)
13986                            (const_int 9) (const_int 11)
13987                            (const_int 13) (const_int 15)
13988                            (const_int 17) (const_int 19)
13989                            (const_int 21) (const_int 23)
13990                            (const_int 25) (const_int 27)
13991                            (const_int 29) (const_int 31)])))
13992             (sign_extend:V16HI
13993               (vec_select:V16QI (match_dup 2)
13994                 (parallel [(const_int 1) (const_int 3)
13995                            (const_int 5) (const_int 7)
13996                            (const_int 9) (const_int 11)
13997                            (const_int 13) (const_int 15)
13998                            (const_int 17) (const_int 19)
13999                            (const_int 21) (const_int 23)
14000                            (const_int 25) (const_int 27)
14001                            (const_int 29) (const_int 31)]))))))]
14002   "TARGET_AVX2"
14003   "vpmaddubsw\t{%2, %1, %0|%0, %1, %2}"
14004   [(set_attr "isa" "*,avx512bw")
14005    (set_attr "type" "sseiadd")
14006    (set_attr "prefix_extra" "1")
14007    (set_attr "prefix" "vex,evex")
14008    (set_attr "mode" "OI")])
14010 ;; The correct representation for this is absolutely enormous, and
14011 ;; surely not generally useful.
14012 (define_insn "avx512bw_pmaddubsw512<mode><mask_name>"
14013   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
14014           (unspec:VI2_AVX512VL
14015             [(match_operand:<dbpsadbwmode> 1 "register_operand" "v")
14016              (match_operand:<dbpsadbwmode> 2 "nonimmediate_operand" "vm")]
14017              UNSPEC_PMADDUBSW512))]
14018    "TARGET_AVX512BW"
14019    "vpmaddubsw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}";
14020   [(set_attr "type" "sseiadd")
14021    (set_attr "prefix" "evex")
14022    (set_attr "mode" "XI")])
14024 (define_insn "avx512bw_umulhrswv32hi3<mask_name>"
14025   [(set (match_operand:V32HI 0 "register_operand" "=v")
14026         (truncate:V32HI
14027           (lshiftrt:V32SI
14028             (plus:V32SI
14029               (lshiftrt:V32SI
14030                 (mult:V32SI
14031                   (sign_extend:V32SI
14032                     (match_operand:V32HI 1 "nonimmediate_operand" "%v"))
14033                   (sign_extend:V32SI
14034                     (match_operand:V32HI 2 "nonimmediate_operand" "vm")))
14035                 (const_int 14))
14036               (const_vector:V32HI [(const_int 1) (const_int 1)
14037                                    (const_int 1) (const_int 1)
14038                                    (const_int 1) (const_int 1)
14039                                    (const_int 1) (const_int 1)
14040                                    (const_int 1) (const_int 1)
14041                                    (const_int 1) (const_int 1)
14042                                    (const_int 1) (const_int 1)
14043                                    (const_int 1) (const_int 1)
14044                                    (const_int 1) (const_int 1)
14045                                    (const_int 1) (const_int 1)
14046                                    (const_int 1) (const_int 1)
14047                                    (const_int 1) (const_int 1)
14048                                    (const_int 1) (const_int 1)
14049                                    (const_int 1) (const_int 1)
14050                                    (const_int 1) (const_int 1)
14051                                    (const_int 1) (const_int 1)]))
14052             (const_int 1))))]
14053   "TARGET_AVX512BW"
14054   "vpmulhrsw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14055   [(set_attr "type" "sseimul")
14056    (set_attr "prefix" "evex")
14057    (set_attr "mode" "XI")])
14059 (define_insn "ssse3_pmaddubsw128"
14060   [(set (match_operand:V8HI 0 "register_operand" "=x,x,v")
14061         (ss_plus:V8HI
14062           (mult:V8HI
14063             (zero_extend:V8HI
14064               (vec_select:V8QI
14065                 (match_operand:V16QI 1 "register_operand" "0,x,v")
14066                 (parallel [(const_int 0) (const_int 2)
14067                            (const_int 4) (const_int 6)
14068                            (const_int 8) (const_int 10)
14069                            (const_int 12) (const_int 14)])))
14070             (sign_extend:V8HI
14071               (vec_select:V8QI
14072                 (match_operand:V16QI 2 "vector_operand" "xBm,xm,vm")
14073                 (parallel [(const_int 0) (const_int 2)
14074                            (const_int 4) (const_int 6)
14075                            (const_int 8) (const_int 10)
14076                            (const_int 12) (const_int 14)]))))
14077           (mult:V8HI
14078             (zero_extend:V8HI
14079               (vec_select:V8QI (match_dup 1)
14080                 (parallel [(const_int 1) (const_int 3)
14081                            (const_int 5) (const_int 7)
14082                            (const_int 9) (const_int 11)
14083                            (const_int 13) (const_int 15)])))
14084             (sign_extend:V8HI
14085               (vec_select:V8QI (match_dup 2)
14086                 (parallel [(const_int 1) (const_int 3)
14087                            (const_int 5) (const_int 7)
14088                            (const_int 9) (const_int 11)
14089                            (const_int 13) (const_int 15)]))))))]
14090   "TARGET_SSSE3"
14091   "@
14092    pmaddubsw\t{%2, %0|%0, %2}
14093    vpmaddubsw\t{%2, %1, %0|%0, %1, %2}
14094    vpmaddubsw\t{%2, %1, %0|%0, %1, %2}"
14095   [(set_attr "isa" "noavx,avx,avx512bw")
14096    (set_attr "type" "sseiadd")
14097    (set_attr "atom_unit" "simul")
14098    (set_attr "prefix_data16" "1,*,*")
14099    (set_attr "prefix_extra" "1")
14100    (set_attr "prefix" "orig,vex,evex")
14101    (set_attr "mode" "TI")])
14103 (define_insn "ssse3_pmaddubsw"
14104   [(set (match_operand:V4HI 0 "register_operand" "=y")
14105         (ss_plus:V4HI
14106           (mult:V4HI
14107             (zero_extend:V4HI
14108               (vec_select:V4QI
14109                 (match_operand:V8QI 1 "register_operand" "0")
14110                 (parallel [(const_int 0) (const_int 2)
14111                            (const_int 4) (const_int 6)])))
14112             (sign_extend:V4HI
14113               (vec_select:V4QI
14114                 (match_operand:V8QI 2 "nonimmediate_operand" "ym")
14115                 (parallel [(const_int 0) (const_int 2)
14116                            (const_int 4) (const_int 6)]))))
14117           (mult:V4HI
14118             (zero_extend:V4HI
14119               (vec_select:V4QI (match_dup 1)
14120                 (parallel [(const_int 1) (const_int 3)
14121                            (const_int 5) (const_int 7)])))
14122             (sign_extend:V4HI
14123               (vec_select:V4QI (match_dup 2)
14124                 (parallel [(const_int 1) (const_int 3)
14125                            (const_int 5) (const_int 7)]))))))]
14126   "TARGET_SSSE3"
14127   "pmaddubsw\t{%2, %0|%0, %2}"
14128   [(set_attr "type" "sseiadd")
14129    (set_attr "atom_unit" "simul")
14130    (set_attr "prefix_extra" "1")
14131    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14132    (set_attr "mode" "DI")])
14134 (define_mode_iterator PMULHRSW
14135   [V4HI V8HI (V16HI "TARGET_AVX2")])
14137 (define_expand "<ssse3_avx2>_pmulhrsw<mode>3_mask"
14138   [(set (match_operand:PMULHRSW 0 "register_operand")
14139         (vec_merge:PMULHRSW
14140           (truncate:PMULHRSW
14141             (lshiftrt:<ssedoublemode>
14142               (plus:<ssedoublemode>
14143                 (lshiftrt:<ssedoublemode>
14144                   (mult:<ssedoublemode>
14145                     (sign_extend:<ssedoublemode>
14146                       (match_operand:PMULHRSW 1 "nonimmediate_operand"))
14147                     (sign_extend:<ssedoublemode>
14148                       (match_operand:PMULHRSW 2 "nonimmediate_operand")))
14149                   (const_int 14))
14150                 (match_dup 5))
14151               (const_int 1)))
14152           (match_operand:PMULHRSW 3 "register_operand")
14153           (match_operand:<avx512fmaskmode> 4 "register_operand")))]
14154   "TARGET_AVX512BW && TARGET_AVX512VL"
14156   operands[5] = CONST1_RTX(<MODE>mode);
14157   ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
14160 (define_expand "<ssse3_avx2>_pmulhrsw<mode>3"
14161   [(set (match_operand:PMULHRSW 0 "register_operand")
14162         (truncate:PMULHRSW
14163           (lshiftrt:<ssedoublemode>
14164             (plus:<ssedoublemode>
14165               (lshiftrt:<ssedoublemode>
14166                 (mult:<ssedoublemode>
14167                   (sign_extend:<ssedoublemode>
14168                     (match_operand:PMULHRSW 1 "nonimmediate_operand"))
14169                   (sign_extend:<ssedoublemode>
14170                     (match_operand:PMULHRSW 2 "nonimmediate_operand")))
14171                 (const_int 14))
14172               (match_dup 3))
14173             (const_int 1))))]
14174   "TARGET_AVX2"
14176   operands[3] = CONST1_RTX(<MODE>mode);
14177   ix86_fixup_binary_operands_no_copy (MULT, <MODE>mode, operands);
14180 (define_insn "*<ssse3_avx2>_pmulhrsw<mode>3<mask_name>"
14181   [(set (match_operand:VI2_AVX2 0 "register_operand" "=x,x,v")
14182         (truncate:VI2_AVX2
14183           (lshiftrt:<ssedoublemode>
14184             (plus:<ssedoublemode>
14185               (lshiftrt:<ssedoublemode>
14186                 (mult:<ssedoublemode>
14187                   (sign_extend:<ssedoublemode>
14188                     (match_operand:VI2_AVX2 1 "vector_operand" "%0,x,v"))
14189                   (sign_extend:<ssedoublemode>
14190                     (match_operand:VI2_AVX2 2 "vector_operand" "xBm,xm,vm")))
14191                 (const_int 14))
14192               (match_operand:VI2_AVX2 3 "const1_operand"))
14193             (const_int 1))))]
14194   "TARGET_SSSE3 && <mask_mode512bit_condition> && <mask_avx512bw_condition>
14195    && ix86_binary_operator_ok (MULT, <MODE>mode, operands)"
14196   "@
14197    pmulhrsw\t{%2, %0|%0, %2}
14198    vpmulhrsw\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}
14199    vpmulhrsw\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}"
14200   [(set_attr "isa" "noavx,avx,avx512bw")
14201    (set_attr "type" "sseimul")
14202    (set_attr "prefix_data16" "1,*,*")
14203    (set_attr "prefix_extra" "1")
14204    (set_attr "prefix" "orig,maybe_evex,evex")
14205    (set_attr "mode" "<sseinsnmode>")])
14207 (define_insn "*ssse3_pmulhrswv4hi3"
14208   [(set (match_operand:V4HI 0 "register_operand" "=y")
14209         (truncate:V4HI
14210           (lshiftrt:V4SI
14211             (plus:V4SI
14212               (lshiftrt:V4SI
14213                 (mult:V4SI
14214                   (sign_extend:V4SI
14215                     (match_operand:V4HI 1 "nonimmediate_operand" "%0"))
14216                   (sign_extend:V4SI
14217                     (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
14218                 (const_int 14))
14219               (match_operand:V4HI 3 "const1_operand"))
14220             (const_int 1))))]
14221   "TARGET_SSSE3 && ix86_binary_operator_ok (MULT, V4HImode, operands)"
14222   "pmulhrsw\t{%2, %0|%0, %2}"
14223   [(set_attr "type" "sseimul")
14224    (set_attr "prefix_extra" "1")
14225    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14226    (set_attr "mode" "DI")])
14228 (define_insn "<ssse3_avx2>_pshufb<mode>3<mask_name>"
14229   [(set (match_operand:VI1_AVX512 0 "register_operand" "=x,x,v")
14230         (unspec:VI1_AVX512
14231           [(match_operand:VI1_AVX512 1 "register_operand" "0,x,v")
14232            (match_operand:VI1_AVX512 2 "vector_operand" "xBm,xm,vm")]
14233           UNSPEC_PSHUFB))]
14234   "TARGET_SSSE3 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
14235   "@
14236    pshufb\t{%2, %0|%0, %2}
14237    vpshufb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
14238    vpshufb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14239   [(set_attr "isa" "noavx,avx,avx512bw")
14240    (set_attr "type" "sselog1")
14241    (set_attr "prefix_data16" "1,*,*")
14242    (set_attr "prefix_extra" "1")
14243    (set_attr "prefix" "orig,maybe_evex,evex")
14244    (set_attr "btver2_decode" "vector")
14245    (set_attr "mode" "<sseinsnmode>")])
14247 (define_insn "ssse3_pshufbv8qi3"
14248   [(set (match_operand:V8QI 0 "register_operand" "=y")
14249         (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "0")
14250                       (match_operand:V8QI 2 "nonimmediate_operand" "ym")]
14251                      UNSPEC_PSHUFB))]
14252   "TARGET_SSSE3"
14253   "pshufb\t{%2, %0|%0, %2}";
14254   [(set_attr "type" "sselog1")
14255    (set_attr "prefix_extra" "1")
14256    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14257    (set_attr "mode" "DI")])
14259 (define_insn "<ssse3_avx2>_psign<mode>3"
14260   [(set (match_operand:VI124_AVX2 0 "register_operand" "=x,x")
14261         (unspec:VI124_AVX2
14262           [(match_operand:VI124_AVX2 1 "register_operand" "0,x")
14263            (match_operand:VI124_AVX2 2 "vector_operand" "xBm,xm")]
14264           UNSPEC_PSIGN))]
14265   "TARGET_SSSE3"
14266   "@
14267    psign<ssemodesuffix>\t{%2, %0|%0, %2}
14268    vpsign<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
14269   [(set_attr "isa" "noavx,avx")
14270    (set_attr "type" "sselog1")
14271    (set_attr "prefix_data16" "1,*")
14272    (set_attr "prefix_extra" "1")
14273    (set_attr "prefix" "orig,vex")
14274    (set_attr "mode" "<sseinsnmode>")])
14276 (define_insn "ssse3_psign<mode>3"
14277   [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
14278         (unspec:MMXMODEI
14279           [(match_operand:MMXMODEI 1 "register_operand" "0")
14280            (match_operand:MMXMODEI 2 "nonimmediate_operand" "ym")]
14281           UNSPEC_PSIGN))]
14282   "TARGET_SSSE3"
14283   "psign<mmxvecsize>\t{%2, %0|%0, %2}";
14284   [(set_attr "type" "sselog1")
14285    (set_attr "prefix_extra" "1")
14286    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14287    (set_attr "mode" "DI")])
14289 (define_insn "<ssse3_avx2>_palignr<mode>_mask"
14290   [(set (match_operand:VI1_AVX512 0 "register_operand" "=v")
14291         (vec_merge:VI1_AVX512
14292           (unspec:VI1_AVX512
14293             [(match_operand:VI1_AVX512 1 "register_operand" "v")
14294              (match_operand:VI1_AVX512 2 "nonimmediate_operand" "vm")
14295              (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n")]
14296             UNSPEC_PALIGNR)
14297         (match_operand:VI1_AVX512 4 "vector_move_operand" "0C")
14298         (match_operand:<avx512fmaskmode> 5 "register_operand" "Yk")))]
14299   "TARGET_AVX512BW && (<MODE_SIZE> == 64 || TARGET_AVX512VL)"
14301   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
14302   return "vpalignr\t{%3, %2, %1, %0%{%5%}%N4|%0%{%5%}%N4, %1, %2, %3}";
14304   [(set_attr "type" "sseishft")
14305    (set_attr "atom_unit" "sishuf")
14306    (set_attr "prefix_extra" "1")
14307    (set_attr "length_immediate" "1")
14308    (set_attr "prefix" "evex")
14309    (set_attr "mode" "<sseinsnmode>")])
14311 (define_insn "<ssse3_avx2>_palignr<mode>"
14312   [(set (match_operand:SSESCALARMODE 0 "register_operand" "=x,x,v")
14313         (unspec:SSESCALARMODE
14314           [(match_operand:SSESCALARMODE 1 "register_operand" "0,x,v")
14315            (match_operand:SSESCALARMODE 2 "vector_operand" "xBm,xm,vm")
14316            (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n,n,n")]
14317           UNSPEC_PALIGNR))]
14318   "TARGET_SSSE3"
14320   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
14322   switch (which_alternative)
14323     {
14324     case 0:
14325       return "palignr\t{%3, %2, %0|%0, %2, %3}";
14326     case 1:
14327     case 2:
14328       return "vpalignr\t{%3, %2, %1, %0|%0, %1, %2, %3}";
14329     default:
14330       gcc_unreachable ();
14331     }
14333   [(set_attr "isa" "noavx,avx,avx512bw")
14334    (set_attr "type" "sseishft")
14335    (set_attr "atom_unit" "sishuf")
14336    (set_attr "prefix_data16" "1,*,*")
14337    (set_attr "prefix_extra" "1")
14338    (set_attr "length_immediate" "1")
14339    (set_attr "prefix" "orig,vex,evex")
14340    (set_attr "mode" "<sseinsnmode>")])
14342 (define_insn "ssse3_palignrdi"
14343   [(set (match_operand:DI 0 "register_operand" "=y")
14344         (unspec:DI [(match_operand:DI 1 "register_operand" "0")
14345                     (match_operand:DI 2 "nonimmediate_operand" "ym")
14346                     (match_operand:SI 3 "const_0_to_255_mul_8_operand" "n")]
14347                    UNSPEC_PALIGNR))]
14348   "TARGET_SSSE3"
14350   operands[3] = GEN_INT (INTVAL (operands[3]) / 8);
14351   return "palignr\t{%3, %2, %0|%0, %2, %3}";
14353   [(set_attr "type" "sseishft")
14354    (set_attr "atom_unit" "sishuf")
14355    (set_attr "prefix_extra" "1")
14356    (set_attr "length_immediate" "1")
14357    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14358    (set_attr "mode" "DI")])
14360 ;; Mode iterator to handle singularity w/ absence of V2DI and V4DI
14361 ;; modes for abs instruction on pre AVX-512 targets.
14362 (define_mode_iterator VI1248_AVX512VL_AVX512BW
14363   [(V64QI "TARGET_AVX512BW") (V32QI "TARGET_AVX2") V16QI
14364    (V32HI "TARGET_AVX512BW") (V16HI "TARGET_AVX2") V8HI
14365    (V16SI "TARGET_AVX512F") (V8SI "TARGET_AVX2") V4SI
14366    (V8DI "TARGET_AVX512F") (V4DI "TARGET_AVX512VL") (V2DI "TARGET_AVX512VL")])
14368 (define_insn "*abs<mode>2"
14369   [(set (match_operand:VI1248_AVX512VL_AVX512BW 0 "register_operand" "=v")
14370         (abs:VI1248_AVX512VL_AVX512BW
14371           (match_operand:VI1248_AVX512VL_AVX512BW 1 "vector_operand" "vBm")))]
14372   "TARGET_SSSE3"
14373   "%vpabs<ssemodesuffix>\t{%1, %0|%0, %1}"
14374   [(set_attr "type" "sselog1")
14375    (set_attr "prefix_data16" "1")
14376    (set_attr "prefix_extra" "1")
14377    (set_attr "prefix" "maybe_vex")
14378    (set_attr "mode" "<sseinsnmode>")])
14380 (define_insn "abs<mode>2_mask"
14381   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
14382         (vec_merge:VI48_AVX512VL
14383           (abs:VI48_AVX512VL
14384             (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm"))
14385           (match_operand:VI48_AVX512VL 2 "vector_move_operand" "0C")
14386           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
14387   "TARGET_AVX512F"
14388   "vpabs<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
14389   [(set_attr "type" "sselog1")
14390    (set_attr "prefix" "evex")
14391    (set_attr "mode" "<sseinsnmode>")])
14393 (define_insn "abs<mode>2_mask"
14394   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
14395         (vec_merge:VI12_AVX512VL
14396           (abs:VI12_AVX512VL
14397             (match_operand:VI12_AVX512VL 1 "nonimmediate_operand" "vm"))
14398           (match_operand:VI12_AVX512VL 2 "vector_move_operand" "0C")
14399           (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")))]
14400   "TARGET_AVX512BW"
14401   "vpabs<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
14402   [(set_attr "type" "sselog1")
14403    (set_attr "prefix" "evex")
14404    (set_attr "mode" "<sseinsnmode>")])
14406 (define_expand "abs<mode>2"
14407   [(set (match_operand:VI1248_AVX512VL_AVX512BW 0 "register_operand")
14408         (abs:VI1248_AVX512VL_AVX512BW
14409           (match_operand:VI1248_AVX512VL_AVX512BW 1 "vector_operand")))]
14410   "TARGET_SSE2"
14412   if (!TARGET_SSSE3)
14413     {
14414       ix86_expand_sse2_abs (operands[0], operands[1]);
14415       DONE;
14416     }
14419 (define_insn "abs<mode>2"
14420   [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
14421         (abs:MMXMODEI
14422           (match_operand:MMXMODEI 1 "nonimmediate_operand" "ym")))]
14423   "TARGET_SSSE3"
14424   "pabs<mmxvecsize>\t{%1, %0|%0, %1}";
14425   [(set_attr "type" "sselog1")
14426    (set_attr "prefix_rep" "0")
14427    (set_attr "prefix_extra" "1")
14428    (set (attr "prefix_rex") (symbol_ref "x86_extended_reg_mentioned_p (insn)"))
14429    (set_attr "mode" "DI")])
14431 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14433 ;; AMD SSE4A instructions
14435 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14437 (define_insn "sse4a_movnt<mode>"
14438   [(set (match_operand:MODEF 0 "memory_operand" "=m")
14439         (unspec:MODEF
14440           [(match_operand:MODEF 1 "register_operand" "x")]
14441           UNSPEC_MOVNT))]
14442   "TARGET_SSE4A"
14443   "movnt<ssemodesuffix>\t{%1, %0|%0, %1}"
14444   [(set_attr "type" "ssemov")
14445    (set_attr "mode" "<MODE>")])
14447 (define_insn "sse4a_vmmovnt<mode>"
14448   [(set (match_operand:<ssescalarmode> 0 "memory_operand" "=m")
14449         (unspec:<ssescalarmode>
14450           [(vec_select:<ssescalarmode>
14451              (match_operand:VF_128 1 "register_operand" "x")
14452              (parallel [(const_int 0)]))]
14453           UNSPEC_MOVNT))]
14454   "TARGET_SSE4A"
14455   "movnt<ssescalarmodesuffix>\t{%1, %0|%0, %1}"
14456   [(set_attr "type" "ssemov")
14457    (set_attr "mode" "<ssescalarmode>")])
14459 (define_insn "sse4a_extrqi"
14460   [(set (match_operand:V2DI 0 "register_operand" "=x")
14461         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
14462                       (match_operand 2 "const_0_to_255_operand")
14463                       (match_operand 3 "const_0_to_255_operand")]
14464                      UNSPEC_EXTRQI))]
14465   "TARGET_SSE4A"
14466   "extrq\t{%3, %2, %0|%0, %2, %3}"
14467   [(set_attr "type" "sse")
14468    (set_attr "prefix_data16" "1")
14469    (set_attr "length_immediate" "2")
14470    (set_attr "mode" "TI")])
14472 (define_insn "sse4a_extrq"
14473   [(set (match_operand:V2DI 0 "register_operand" "=x")
14474         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
14475                       (match_operand:V16QI 2 "register_operand" "x")]
14476                      UNSPEC_EXTRQ))]
14477   "TARGET_SSE4A"
14478   "extrq\t{%2, %0|%0, %2}"
14479   [(set_attr "type" "sse")
14480    (set_attr "prefix_data16" "1")
14481    (set_attr "mode" "TI")])
14483 (define_insn "sse4a_insertqi"
14484   [(set (match_operand:V2DI 0 "register_operand" "=x")
14485         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
14486                       (match_operand:V2DI 2 "register_operand" "x")
14487                       (match_operand 3 "const_0_to_255_operand")
14488                       (match_operand 4 "const_0_to_255_operand")]
14489                      UNSPEC_INSERTQI))]
14490   "TARGET_SSE4A"
14491   "insertq\t{%4, %3, %2, %0|%0, %2, %3, %4}"
14492   [(set_attr "type" "sseins")
14493    (set_attr "prefix_data16" "0")
14494    (set_attr "prefix_rep" "1")
14495    (set_attr "length_immediate" "2")
14496    (set_attr "mode" "TI")])
14498 (define_insn "sse4a_insertq"
14499   [(set (match_operand:V2DI 0 "register_operand" "=x")
14500         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
14501                       (match_operand:V2DI 2 "register_operand" "x")]
14502                      UNSPEC_INSERTQ))]
14503   "TARGET_SSE4A"
14504   "insertq\t{%2, %0|%0, %2}"
14505   [(set_attr "type" "sseins")
14506    (set_attr "prefix_data16" "0")
14507    (set_attr "prefix_rep" "1")
14508    (set_attr "mode" "TI")])
14510 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14512 ;; Intel SSE4.1 instructions
14514 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14516 ;; Mapping of immediate bits for blend instructions
14517 (define_mode_attr blendbits
14518   [(V8SF "255") (V4SF "15") (V4DF "15") (V2DF "3")])
14520 (define_insn "<sse4_1>_blend<ssemodesuffix><avxsizesuffix>"
14521   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
14522         (vec_merge:VF_128_256
14523           (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
14524           (match_operand:VF_128_256 1 "register_operand" "0,0,x")
14525           (match_operand:SI 3 "const_0_to_<blendbits>_operand")))]
14526   "TARGET_SSE4_1"
14527   "@
14528    blend<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
14529    blend<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
14530    vblend<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14531   [(set_attr "isa" "noavx,noavx,avx")
14532    (set_attr "type" "ssemov")
14533    (set_attr "length_immediate" "1")
14534    (set_attr "prefix_data16" "1,1,*")
14535    (set_attr "prefix_extra" "1")
14536    (set_attr "prefix" "orig,orig,vex")
14537    (set_attr "mode" "<MODE>")])
14539 (define_insn "<sse4_1>_blendv<ssemodesuffix><avxsizesuffix>"
14540   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
14541         (unspec:VF_128_256
14542           [(match_operand:VF_128_256 1 "register_operand" "0,0,x")
14543            (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
14544            (match_operand:VF_128_256 3 "register_operand" "Yz,Yz,x")]
14545           UNSPEC_BLENDV))]
14546   "TARGET_SSE4_1"
14547   "@
14548    blendv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
14549    blendv<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
14550    vblendv<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14551   [(set_attr "isa" "noavx,noavx,avx")
14552    (set_attr "type" "ssemov")
14553    (set_attr "length_immediate" "1")
14554    (set_attr "prefix_data16" "1,1,*")
14555    (set_attr "prefix_extra" "1")
14556    (set_attr "prefix" "orig,orig,vex")
14557    (set_attr "btver2_decode" "vector,vector,vector") 
14558    (set_attr "mode" "<MODE>")])
14560 (define_insn "<sse4_1>_dp<ssemodesuffix><avxsizesuffix>"
14561   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
14562         (unspec:VF_128_256
14563           [(match_operand:VF_128_256 1 "vector_operand" "%0,0,x")
14564            (match_operand:VF_128_256 2 "vector_operand" "YrBm,*xBm,xm")
14565            (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
14566           UNSPEC_DP))]
14567   "TARGET_SSE4_1"
14568   "@
14569    dp<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
14570    dp<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
14571    vdp<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14572   [(set_attr "isa" "noavx,noavx,avx")
14573    (set_attr "type" "ssemul")
14574    (set_attr "length_immediate" "1")
14575    (set_attr "prefix_data16" "1,1,*")
14576    (set_attr "prefix_extra" "1")
14577    (set_attr "prefix" "orig,orig,vex")
14578    (set_attr "btver2_decode" "vector,vector,vector")
14579    (set_attr "znver1_decode" "vector,vector,vector")
14580    (set_attr "mode" "<MODE>")])
14582 ;; Mode attribute used by `vmovntdqa' pattern
14583 (define_mode_attr vi8_sse4_1_avx2_avx512
14584    [(V2DI "sse4_1") (V4DI "avx2") (V8DI "avx512f")])
14586 (define_insn "<vi8_sse4_1_avx2_avx512>_movntdqa"
14587   [(set (match_operand:VI8_AVX2_AVX512F 0 "register_operand" "=Yr,*x,v")
14588         (unspec:VI8_AVX2_AVX512F [(match_operand:VI8_AVX2_AVX512F 1 "memory_operand" "m,m,m")]
14589                      UNSPEC_MOVNTDQA))]
14590   "TARGET_SSE4_1"
14591   "%vmovntdqa\t{%1, %0|%0, %1}"
14592   [(set_attr "isa" "noavx,noavx,avx")
14593    (set_attr "type" "ssemov")
14594    (set_attr "prefix_extra" "1,1,*")
14595    (set_attr "prefix" "orig,orig,maybe_evex")
14596    (set_attr "mode" "<sseinsnmode>")])
14598 (define_insn "<sse4_1_avx2>_mpsadbw"
14599   [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
14600         (unspec:VI1_AVX2
14601           [(match_operand:VI1_AVX2 1 "register_operand" "0,0,x")
14602            (match_operand:VI1_AVX2 2 "vector_operand" "YrBm,*xBm,xm")
14603            (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")]
14604           UNSPEC_MPSADBW))]
14605   "TARGET_SSE4_1"
14606   "@
14607    mpsadbw\t{%3, %2, %0|%0, %2, %3}
14608    mpsadbw\t{%3, %2, %0|%0, %2, %3}
14609    vmpsadbw\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14610   [(set_attr "isa" "noavx,noavx,avx")
14611    (set_attr "type" "sselog1")
14612    (set_attr "length_immediate" "1")
14613    (set_attr "prefix_extra" "1")
14614    (set_attr "prefix" "orig,orig,vex")
14615    (set_attr "btver2_decode" "vector,vector,vector")
14616    (set_attr "znver1_decode" "vector,vector,vector")
14617    (set_attr "mode" "<sseinsnmode>")])
14619 (define_insn "<sse4_1_avx2>_packusdw<mask_name>"
14620   [(set (match_operand:VI2_AVX2 0 "register_operand" "=Yr,*x,x,v")
14621         (vec_concat:VI2_AVX2
14622           (us_truncate:<ssehalfvecmode>
14623             (match_operand:<sseunpackmode> 1 "register_operand" "0,0,x,v"))
14624           (us_truncate:<ssehalfvecmode>
14625             (match_operand:<sseunpackmode> 2 "vector_operand" "YrBm,*xBm,xm,vm"))))]
14626   "TARGET_SSE4_1 && <mask_mode512bit_condition> && <mask_avx512bw_condition>"
14627   "@
14628    packusdw\t{%2, %0|%0, %2}
14629    packusdw\t{%2, %0|%0, %2}
14630    vpackusdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}
14631    vpackusdw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
14632   [(set_attr "isa" "noavx,noavx,avx,avx512bw")
14633    (set_attr "type" "sselog")
14634    (set_attr "prefix_extra" "1")
14635    (set_attr "prefix" "orig,orig,<mask_prefix>,evex")
14636    (set_attr "mode" "<sseinsnmode>")])
14638 (define_insn "<sse4_1_avx2>_pblendvb"
14639   [(set (match_operand:VI1_AVX2 0 "register_operand" "=Yr,*x,x")
14640         (unspec:VI1_AVX2
14641           [(match_operand:VI1_AVX2 1 "register_operand"  "0,0,x")
14642            (match_operand:VI1_AVX2 2 "vector_operand" "YrBm,*xBm,xm")
14643            (match_operand:VI1_AVX2 3 "register_operand" "Yz,Yz,x")]
14644           UNSPEC_BLENDV))]
14645   "TARGET_SSE4_1"
14646   "@
14647    pblendvb\t{%3, %2, %0|%0, %2, %3}
14648    pblendvb\t{%3, %2, %0|%0, %2, %3}
14649    vpblendvb\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14650   [(set_attr "isa" "noavx,noavx,avx")
14651    (set_attr "type" "ssemov")
14652    (set_attr "prefix_extra" "1")
14653    (set_attr "length_immediate" "*,*,1")
14654    (set_attr "prefix" "orig,orig,vex")
14655    (set_attr "btver2_decode" "vector,vector,vector")
14656    (set_attr "mode" "<sseinsnmode>")])
14658 (define_insn "sse4_1_pblendw"
14659   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,x")
14660         (vec_merge:V8HI
14661           (match_operand:V8HI 2 "vector_operand" "YrBm,*xBm,xm")
14662           (match_operand:V8HI 1 "register_operand" "0,0,x")
14663           (match_operand:SI 3 "const_0_to_255_operand" "n,n,n")))]
14664   "TARGET_SSE4_1"
14665   "@
14666    pblendw\t{%3, %2, %0|%0, %2, %3}
14667    pblendw\t{%3, %2, %0|%0, %2, %3}
14668    vpblendw\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14669   [(set_attr "isa" "noavx,noavx,avx")
14670    (set_attr "type" "ssemov")
14671    (set_attr "prefix_extra" "1")
14672    (set_attr "length_immediate" "1")
14673    (set_attr "prefix" "orig,orig,vex")
14674    (set_attr "mode" "TI")])
14676 ;; The builtin uses an 8-bit immediate.  Expand that.
14677 (define_expand "avx2_pblendw"
14678   [(set (match_operand:V16HI 0 "register_operand")
14679         (vec_merge:V16HI
14680           (match_operand:V16HI 2 "nonimmediate_operand")
14681           (match_operand:V16HI 1 "register_operand")
14682           (match_operand:SI 3 "const_0_to_255_operand")))]
14683   "TARGET_AVX2"
14685   HOST_WIDE_INT val = INTVAL (operands[3]) & 0xff;
14686   operands[3] = GEN_INT (val << 8 | val);
14689 (define_insn "*avx2_pblendw"
14690   [(set (match_operand:V16HI 0 "register_operand" "=x")
14691         (vec_merge:V16HI
14692           (match_operand:V16HI 2 "nonimmediate_operand" "xm")
14693           (match_operand:V16HI 1 "register_operand" "x")
14694           (match_operand:SI 3 "avx2_pblendw_operand" "n")))]
14695   "TARGET_AVX2"
14697   operands[3] = GEN_INT (INTVAL (operands[3]) & 0xff);
14698   return "vpblendw\t{%3, %2, %1, %0|%0, %1, %2, %3}";
14700   [(set_attr "type" "ssemov")
14701    (set_attr "prefix_extra" "1")
14702    (set_attr "length_immediate" "1")
14703    (set_attr "prefix" "vex")
14704    (set_attr "mode" "OI")])
14706 (define_insn "avx2_pblendd<mode>"
14707   [(set (match_operand:VI4_AVX2 0 "register_operand" "=x")
14708         (vec_merge:VI4_AVX2
14709           (match_operand:VI4_AVX2 2 "nonimmediate_operand" "xm")
14710           (match_operand:VI4_AVX2 1 "register_operand" "x")
14711           (match_operand:SI 3 "const_0_to_255_operand" "n")))]
14712   "TARGET_AVX2"
14713   "vpblendd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
14714   [(set_attr "type" "ssemov")
14715    (set_attr "prefix_extra" "1")
14716    (set_attr "length_immediate" "1")
14717    (set_attr "prefix" "vex")
14718    (set_attr "mode" "<sseinsnmode>")])
14720 (define_insn "sse4_1_phminposuw"
14721   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,x")
14722         (unspec:V8HI [(match_operand:V8HI 1 "vector_operand" "YrBm,*xBm,xm")]
14723                      UNSPEC_PHMINPOSUW))]
14724   "TARGET_SSE4_1"
14725   "%vphminposuw\t{%1, %0|%0, %1}"
14726   [(set_attr "isa" "noavx,noavx,avx")
14727    (set_attr "type" "sselog1")
14728    (set_attr "prefix_extra" "1")
14729    (set_attr "prefix" "orig,orig,vex")
14730    (set_attr "mode" "TI")])
14732 (define_insn "avx2_<code>v16qiv16hi2<mask_name>"
14733   [(set (match_operand:V16HI 0 "register_operand" "=v")
14734         (any_extend:V16HI
14735           (match_operand:V16QI 1 "nonimmediate_operand" "vm")))]
14736   "TARGET_AVX2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
14737   "vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
14738   [(set_attr "type" "ssemov")
14739    (set_attr "prefix_extra" "1")
14740    (set_attr "prefix" "maybe_evex")
14741    (set_attr "mode" "OI")])
14743 (define_insn "avx512bw_<code>v32qiv32hi2<mask_name>"
14744   [(set (match_operand:V32HI 0 "register_operand" "=v")
14745         (any_extend:V32HI
14746           (match_operand:V32QI 1 "nonimmediate_operand" "vm")))]
14747   "TARGET_AVX512BW"
14748   "vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
14749   [(set_attr "type" "ssemov")
14750    (set_attr "prefix_extra" "1")
14751    (set_attr "prefix" "evex")
14752    (set_attr "mode" "XI")])
14754 (define_insn "sse4_1_<code>v8qiv8hi2<mask_name>"
14755   [(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,v")
14756         (any_extend:V8HI
14757           (vec_select:V8QI
14758             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*xm,vm")
14759             (parallel [(const_int 0) (const_int 1)
14760                        (const_int 2) (const_int 3)
14761                        (const_int 4) (const_int 5)
14762                        (const_int 6) (const_int 7)]))))]
14763   "TARGET_SSE4_1 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
14764   "%vpmov<extsuffix>bw\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
14765   [(set_attr "isa" "noavx,noavx,avx")
14766    (set_attr "type" "ssemov")
14767    (set_attr "prefix_extra" "1")
14768    (set_attr "prefix" "orig,orig,maybe_evex")
14769    (set_attr "mode" "TI")])
14771 (define_insn "<mask_codefor>avx512f_<code>v16qiv16si2<mask_name>"
14772   [(set (match_operand:V16SI 0 "register_operand" "=v")
14773         (any_extend:V16SI
14774           (match_operand:V16QI 1 "nonimmediate_operand" "vm")))]
14775   "TARGET_AVX512F"
14776   "vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
14777   [(set_attr "type" "ssemov")
14778    (set_attr "prefix" "evex")
14779    (set_attr "mode" "XI")])
14781 (define_insn "avx2_<code>v8qiv8si2<mask_name>"
14782   [(set (match_operand:V8SI 0 "register_operand" "=v")
14783         (any_extend:V8SI
14784           (vec_select:V8QI
14785             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
14786             (parallel [(const_int 0) (const_int 1)
14787                        (const_int 2) (const_int 3)
14788                        (const_int 4) (const_int 5)
14789                        (const_int 6) (const_int 7)]))))]
14790   "TARGET_AVX2 && <mask_avx512vl_condition>"
14791   "vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
14792   [(set_attr "type" "ssemov")
14793    (set_attr "prefix_extra" "1")
14794    (set_attr "prefix" "maybe_evex")
14795    (set_attr "mode" "OI")])
14797 (define_insn "sse4_1_<code>v4qiv4si2<mask_name>"
14798   [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
14799         (any_extend:V4SI
14800           (vec_select:V4QI
14801             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*xm,vm")
14802             (parallel [(const_int 0) (const_int 1)
14803                        (const_int 2) (const_int 3)]))))]
14804   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
14805   "%vpmov<extsuffix>bd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
14806   [(set_attr "isa" "noavx,noavx,avx")
14807    (set_attr "type" "ssemov")
14808    (set_attr "prefix_extra" "1")
14809    (set_attr "prefix" "orig,orig,maybe_evex")
14810    (set_attr "mode" "TI")])
14812 (define_insn "avx512f_<code>v16hiv16si2<mask_name>"
14813   [(set (match_operand:V16SI 0 "register_operand" "=v")
14814         (any_extend:V16SI
14815           (match_operand:V16HI 1 "nonimmediate_operand" "vm")))]
14816   "TARGET_AVX512F"
14817   "vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
14818   [(set_attr "type" "ssemov")
14819    (set_attr "prefix" "evex")
14820    (set_attr "mode" "XI")])
14822 (define_insn "avx2_<code>v8hiv8si2<mask_name>"
14823   [(set (match_operand:V8SI 0 "register_operand" "=v")
14824         (any_extend:V8SI
14825             (match_operand:V8HI 1 "nonimmediate_operand" "vm")))]
14826   "TARGET_AVX2 && <mask_avx512vl_condition>"
14827   "vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
14828   [(set_attr "type" "ssemov")
14829    (set_attr "prefix_extra" "1")
14830    (set_attr "prefix" "maybe_evex")
14831    (set_attr "mode" "OI")])
14833 (define_insn "sse4_1_<code>v4hiv4si2<mask_name>"
14834   [(set (match_operand:V4SI 0 "register_operand" "=Yr,*x,v")
14835         (any_extend:V4SI
14836           (vec_select:V4HI
14837             (match_operand:V8HI 1 "nonimmediate_operand" "Yrm,*xm,vm")
14838             (parallel [(const_int 0) (const_int 1)
14839                        (const_int 2) (const_int 3)]))))]
14840   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
14841   "%vpmov<extsuffix>wd\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
14842   [(set_attr "isa" "noavx,noavx,avx")
14843    (set_attr "type" "ssemov")
14844    (set_attr "prefix_extra" "1")
14845    (set_attr "prefix" "orig,orig,maybe_evex")
14846    (set_attr "mode" "TI")])
14848 (define_insn "avx512f_<code>v8qiv8di2<mask_name>"
14849   [(set (match_operand:V8DI 0 "register_operand" "=v")
14850         (any_extend:V8DI
14851           (vec_select:V8QI
14852             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
14853             (parallel [(const_int 0) (const_int 1)
14854                        (const_int 2) (const_int 3)
14855                        (const_int 4) (const_int 5)
14856                        (const_int 6) (const_int 7)]))))]
14857   "TARGET_AVX512F"
14858   "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
14859   [(set_attr "type" "ssemov")
14860    (set_attr "prefix" "evex")
14861    (set_attr "mode" "XI")])
14863 (define_insn "avx2_<code>v4qiv4di2<mask_name>"
14864   [(set (match_operand:V4DI 0 "register_operand" "=v")
14865         (any_extend:V4DI
14866           (vec_select:V4QI
14867             (match_operand:V16QI 1 "nonimmediate_operand" "vm")
14868             (parallel [(const_int 0) (const_int 1)
14869                        (const_int 2) (const_int 3)]))))]
14870   "TARGET_AVX2 && <mask_avx512vl_condition>"
14871   "vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
14872   [(set_attr "type" "ssemov")
14873    (set_attr "prefix_extra" "1")
14874    (set_attr "prefix" "maybe_evex")
14875    (set_attr "mode" "OI")])
14877 (define_insn "sse4_1_<code>v2qiv2di2<mask_name>"
14878   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
14879         (any_extend:V2DI
14880           (vec_select:V2QI
14881             (match_operand:V16QI 1 "nonimmediate_operand" "Yrm,*xm,vm")
14882             (parallel [(const_int 0) (const_int 1)]))))]
14883   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
14884   "%vpmov<extsuffix>bq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %w1}"
14885   [(set_attr "isa" "noavx,noavx,avx")
14886    (set_attr "type" "ssemov")
14887    (set_attr "prefix_extra" "1")
14888    (set_attr "prefix" "orig,orig,maybe_evex")
14889    (set_attr "mode" "TI")])
14891 (define_insn "avx512f_<code>v8hiv8di2<mask_name>"
14892   [(set (match_operand:V8DI 0 "register_operand" "=v")
14893         (any_extend:V8DI
14894           (match_operand:V8HI 1 "nonimmediate_operand" "vm")))]
14895   "TARGET_AVX512F"
14896   "vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
14897   [(set_attr "type" "ssemov")
14898    (set_attr "prefix" "evex")
14899    (set_attr "mode" "XI")])
14901 (define_insn "avx2_<code>v4hiv4di2<mask_name>"
14902   [(set (match_operand:V4DI 0 "register_operand" "=v")
14903         (any_extend:V4DI
14904           (vec_select:V4HI
14905             (match_operand:V8HI 1 "nonimmediate_operand" "vm")
14906             (parallel [(const_int 0) (const_int 1)
14907                        (const_int 2) (const_int 3)]))))]
14908   "TARGET_AVX2 && <mask_avx512vl_condition>"
14909   "vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
14910   [(set_attr "type" "ssemov")
14911    (set_attr "prefix_extra" "1")
14912    (set_attr "prefix" "maybe_evex")
14913    (set_attr "mode" "OI")])
14915 (define_insn "sse4_1_<code>v2hiv2di2<mask_name>"
14916   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
14917         (any_extend:V2DI
14918           (vec_select:V2HI
14919             (match_operand:V8HI 1 "nonimmediate_operand" "Yrm,*xm,vm")
14920             (parallel [(const_int 0) (const_int 1)]))))]
14921   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
14922   "%vpmov<extsuffix>wq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
14923   [(set_attr "isa" "noavx,noavx,avx")
14924    (set_attr "type" "ssemov")
14925    (set_attr "prefix_extra" "1")
14926    (set_attr "prefix" "orig,orig,maybe_evex")
14927    (set_attr "mode" "TI")])
14929 (define_insn "avx512f_<code>v8siv8di2<mask_name>"
14930   [(set (match_operand:V8DI 0 "register_operand" "=v")
14931         (any_extend:V8DI
14932           (match_operand:V8SI 1 "nonimmediate_operand" "vm")))]
14933   "TARGET_AVX512F"
14934   "vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
14935   [(set_attr "type" "ssemov")
14936    (set_attr "prefix" "evex")
14937    (set_attr "mode" "XI")])
14939 (define_insn "avx2_<code>v4siv4di2<mask_name>"
14940   [(set (match_operand:V4DI 0 "register_operand" "=v")
14941         (any_extend:V4DI
14942             (match_operand:V4SI 1 "nonimmediate_operand" "vm")))]
14943   "TARGET_AVX2 && <mask_avx512vl_condition>"
14944   "vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
14945   [(set_attr "type" "ssemov")
14946    (set_attr "prefix" "maybe_evex")
14947    (set_attr "prefix_extra" "1")
14948    (set_attr "mode" "OI")])
14950 (define_insn "sse4_1_<code>v2siv2di2<mask_name>"
14951   [(set (match_operand:V2DI 0 "register_operand" "=Yr,*x,v")
14952         (any_extend:V2DI
14953           (vec_select:V2SI
14954             (match_operand:V4SI 1 "nonimmediate_operand" "Yrm,*xm,vm")
14955             (parallel [(const_int 0) (const_int 1)]))))]
14956   "TARGET_SSE4_1 && <mask_avx512vl_condition>"
14957   "%vpmov<extsuffix>dq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
14958   [(set_attr "isa" "noavx,noavx,avx")
14959    (set_attr "type" "ssemov")
14960    (set_attr "prefix_extra" "1")
14961    (set_attr "prefix" "orig,orig,maybe_evex")
14962    (set_attr "mode" "TI")])
14964 ;; ptestps/ptestpd are very similar to comiss and ucomiss when
14965 ;; setting FLAGS_REG. But it is not a really compare instruction.
14966 (define_insn "avx_vtest<ssemodesuffix><avxsizesuffix>"
14967   [(set (reg:CC FLAGS_REG)
14968         (unspec:CC [(match_operand:VF_128_256 0 "register_operand" "x")
14969                     (match_operand:VF_128_256 1 "nonimmediate_operand" "xm")]
14970                    UNSPEC_VTESTP))]
14971   "TARGET_AVX"
14972   "vtest<ssemodesuffix>\t{%1, %0|%0, %1}"
14973   [(set_attr "type" "ssecomi")
14974    (set_attr "prefix_extra" "1")
14975    (set_attr "prefix" "vex")
14976    (set_attr "mode" "<MODE>")])
14978 ;; ptest is very similar to comiss and ucomiss when setting FLAGS_REG.
14979 ;; But it is not a really compare instruction.
14980 (define_insn "<sse4_1>_ptest<mode>"
14981   [(set (reg:CC FLAGS_REG)
14982         (unspec:CC [(match_operand:V_AVX 0 "register_operand" "Yr, *x, x")
14983                     (match_operand:V_AVX 1 "vector_operand" "YrBm, *xBm, xm")]
14984                    UNSPEC_PTEST))]
14985   "TARGET_SSE4_1"
14986   "%vptest\t{%1, %0|%0, %1}"
14987   [(set_attr "isa" "noavx,noavx,avx")
14988    (set_attr "type" "ssecomi")
14989    (set_attr "prefix_extra" "1")
14990    (set_attr "prefix" "orig,orig,vex")
14991    (set (attr "btver2_decode")
14992      (if_then_else
14993        (match_test "<sseinsnmode>mode==OImode")
14994      (const_string "vector")
14995      (const_string "*")))
14996    (set_attr "mode" "<sseinsnmode>")])
14998 (define_insn "<sse4_1>_round<ssemodesuffix><avxsizesuffix>"
14999   [(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
15000         (unspec:VF_128_256
15001           [(match_operand:VF_128_256 1 "vector_operand" "YrBm,*xBm,xm")
15002            (match_operand:SI 2 "const_0_to_15_operand" "n,n,n")]
15003           UNSPEC_ROUND))]
15004   "TARGET_ROUND"
15005   "%vround<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
15006   [(set_attr "isa" "noavx,noavx,avx")
15007    (set_attr "type" "ssecvt")
15008    (set_attr "prefix_data16" "1,1,*")
15009    (set_attr "prefix_extra" "1")
15010    (set_attr "length_immediate" "1")
15011    (set_attr "prefix" "orig,orig,vex")
15012    (set_attr "mode" "<MODE>")])
15014 (define_expand "<sse4_1>_round<ssemodesuffix>_sfix<avxsizesuffix>"
15015   [(match_operand:<sseintvecmode> 0 "register_operand")
15016    (match_operand:VF1_128_256 1 "vector_operand")
15017    (match_operand:SI 2 "const_0_to_15_operand")]
15018   "TARGET_ROUND"
15020   rtx tmp = gen_reg_rtx (<MODE>mode);
15022   emit_insn
15023     (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp, operands[1],
15024                                                        operands[2]));
15025   emit_insn
15026     (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
15027   DONE;
15030 (define_expand "avx512f_roundpd512"
15031   [(match_operand:V8DF 0 "register_operand")
15032    (match_operand:V8DF 1 "nonimmediate_operand")
15033    (match_operand:SI 2 "const_0_to_15_operand")]
15034   "TARGET_AVX512F"
15036   emit_insn (gen_avx512f_rndscalev8df (operands[0], operands[1], operands[2]));
15037   DONE;
15040 (define_expand "<sse4_1>_round<ssemodesuffix>_vec_pack_sfix<avxsizesuffix>"
15041   [(match_operand:<ssepackfltmode> 0 "register_operand")
15042    (match_operand:VF2 1 "vector_operand")
15043    (match_operand:VF2 2 "vector_operand")
15044    (match_operand:SI 3 "const_0_to_15_operand")]
15045   "TARGET_ROUND"
15047   rtx tmp0, tmp1;
15049   if (<MODE>mode == V2DFmode
15050       && TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
15051     {
15052       rtx tmp2 = gen_reg_rtx (V4DFmode);
15054       tmp0 = gen_reg_rtx (V4DFmode);
15055       tmp1 = force_reg (V2DFmode, operands[1]);
15057       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
15058       emit_insn (gen_avx_roundpd256 (tmp2, tmp0, operands[3]));
15059       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp2));
15060     }
15061   else
15062     {
15063       tmp0 = gen_reg_rtx (<MODE>mode);
15064       tmp1 = gen_reg_rtx (<MODE>mode);
15066       emit_insn
15067        (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp0, operands[1],
15068                                                           operands[3]));
15069       emit_insn
15070        (gen_<sse4_1>_round<ssemodesuffix><avxsizesuffix> (tmp1, operands[2],
15071                                                           operands[3]));
15072       emit_insn
15073        (gen_vec_pack_sfix_trunc_<mode> (operands[0], tmp0, tmp1));
15074     }
15075   DONE;
15078 (define_insn "sse4_1_round<ssescalarmodesuffix>"
15079   [(set (match_operand:VF_128 0 "register_operand" "=Yr,*x,x,v")
15080         (vec_merge:VF_128
15081           (unspec:VF_128
15082             [(match_operand:VF_128 2 "register_operand" "Yr,*x,x,v")
15083              (match_operand:SI 3 "const_0_to_15_operand" "n,n,n,n")]
15084             UNSPEC_ROUND)
15085           (match_operand:VF_128 1 "register_operand" "0,0,x,v")
15086           (const_int 1)))]
15087   "TARGET_ROUND"
15088   "@
15089    round<ssescalarmodesuffix>\t{%3, %2, %0|%0, %2, %3}
15090    round<ssescalarmodesuffix>\t{%3, %2, %0|%0, %2, %3}
15091    vround<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}
15092    vrndscale<ssescalarmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15093   [(set_attr "isa" "noavx,noavx,avx,avx512f")
15094    (set_attr "type" "ssecvt")
15095    (set_attr "length_immediate" "1")
15096    (set_attr "prefix_data16" "1,1,*,*")
15097    (set_attr "prefix_extra" "1")
15098    (set_attr "prefix" "orig,orig,vex,evex")
15099    (set_attr "mode" "<MODE>")])
15101 (define_expand "round<mode>2"
15102   [(set (match_dup 4)
15103         (plus:VF
15104           (match_operand:VF 1 "register_operand")
15105           (match_dup 3)))
15106    (set (match_operand:VF 0 "register_operand")
15107         (unspec:VF
15108           [(match_dup 4) (match_dup 5)]
15109           UNSPEC_ROUND))]
15110   "TARGET_ROUND && !flag_trapping_math"
15112   machine_mode scalar_mode;
15113   const struct real_format *fmt;
15114   REAL_VALUE_TYPE pred_half, half_minus_pred_half;
15115   rtx half, vec_half;
15117   scalar_mode = GET_MODE_INNER (<MODE>mode);
15119   /* load nextafter (0.5, 0.0) */
15120   fmt = REAL_MODE_FORMAT (scalar_mode);
15121   real_2expN (&half_minus_pred_half, -(fmt->p) - 1, scalar_mode);
15122   real_arithmetic (&pred_half, MINUS_EXPR, &dconsthalf, &half_minus_pred_half);
15123   half = const_double_from_real_value (pred_half, scalar_mode);
15125   vec_half = ix86_build_const_vector (<MODE>mode, true, half);
15126   vec_half = force_reg (<MODE>mode, vec_half);
15128   operands[3] = gen_reg_rtx (<MODE>mode);
15129   emit_insn (gen_copysign<mode>3 (operands[3], vec_half, operands[1]));
15131   operands[4] = gen_reg_rtx (<MODE>mode);
15132   operands[5] = GEN_INT (ROUND_TRUNC);
15135 (define_expand "round<mode>2_sfix"
15136   [(match_operand:<sseintvecmode> 0 "register_operand")
15137    (match_operand:VF1_128_256 1 "register_operand")]
15138   "TARGET_ROUND && !flag_trapping_math"
15140   rtx tmp = gen_reg_rtx (<MODE>mode);
15142   emit_insn (gen_round<mode>2 (tmp, operands[1]));
15144   emit_insn
15145     (gen_fix_trunc<mode><sseintvecmodelower>2 (operands[0], tmp));
15146   DONE;
15149 (define_expand "round<mode>2_vec_pack_sfix"
15150   [(match_operand:<ssepackfltmode> 0 "register_operand")
15151    (match_operand:VF2 1 "register_operand")
15152    (match_operand:VF2 2 "register_operand")]
15153   "TARGET_ROUND && !flag_trapping_math"
15155   rtx tmp0, tmp1;
15157   if (<MODE>mode == V2DFmode
15158       && TARGET_AVX && !TARGET_PREFER_AVX128 && optimize_insn_for_speed_p ())
15159     {
15160       rtx tmp2 = gen_reg_rtx (V4DFmode);
15162       tmp0 = gen_reg_rtx (V4DFmode);
15163       tmp1 = force_reg (V2DFmode, operands[1]);
15165       emit_insn (gen_avx_vec_concatv4df (tmp0, tmp1, operands[2]));
15166       emit_insn (gen_roundv4df2 (tmp2, tmp0));
15167       emit_insn (gen_fix_truncv4dfv4si2 (operands[0], tmp2));
15168     }
15169   else
15170     {
15171       tmp0 = gen_reg_rtx (<MODE>mode);
15172       tmp1 = gen_reg_rtx (<MODE>mode);
15174       emit_insn (gen_round<mode>2 (tmp0, operands[1]));
15175       emit_insn (gen_round<mode>2 (tmp1, operands[2]));
15177       emit_insn
15178        (gen_vec_pack_sfix_trunc_<mode> (operands[0], tmp0, tmp1));
15179     }
15180   DONE;
15183 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15185 ;; Intel SSE4.2 string/text processing instructions
15187 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15189 (define_insn_and_split "sse4_2_pcmpestr"
15190   [(set (match_operand:SI 0 "register_operand" "=c,c")
15191         (unspec:SI
15192           [(match_operand:V16QI 2 "register_operand" "x,x")
15193            (match_operand:SI 3 "register_operand" "a,a")
15194            (match_operand:V16QI 4 "nonimmediate_operand" "x,m")
15195            (match_operand:SI 5 "register_operand" "d,d")
15196            (match_operand:SI 6 "const_0_to_255_operand" "n,n")]
15197           UNSPEC_PCMPESTR))
15198    (set (match_operand:V16QI 1 "register_operand" "=Yz,Yz")
15199         (unspec:V16QI
15200           [(match_dup 2)
15201            (match_dup 3)
15202            (match_dup 4)
15203            (match_dup 5)
15204            (match_dup 6)]
15205           UNSPEC_PCMPESTR))
15206    (set (reg:CC FLAGS_REG)
15207         (unspec:CC
15208           [(match_dup 2)
15209            (match_dup 3)
15210            (match_dup 4)
15211            (match_dup 5)
15212            (match_dup 6)]
15213           UNSPEC_PCMPESTR))]
15214   "TARGET_SSE4_2
15215    && can_create_pseudo_p ()"
15216   "#"
15217   "&& 1"
15218   [(const_int 0)]
15220   int ecx = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[0]));
15221   int xmm0 = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[1]));
15222   int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
15224   if (ecx)
15225     emit_insn (gen_sse4_2_pcmpestri (operands[0], operands[2],
15226                                      operands[3], operands[4],
15227                                      operands[5], operands[6]));
15228   if (xmm0)
15229     emit_insn (gen_sse4_2_pcmpestrm (operands[1], operands[2],
15230                                      operands[3], operands[4],
15231                                      operands[5], operands[6]));
15232   if (flags && !(ecx || xmm0))
15233     emit_insn (gen_sse4_2_pcmpestr_cconly (NULL, NULL,
15234                                            operands[2], operands[3],
15235                                            operands[4], operands[5],
15236                                            operands[6]));
15237   if (!(flags || ecx || xmm0))
15238     emit_note (NOTE_INSN_DELETED);
15240   DONE;
15242   [(set_attr "type" "sselog")
15243    (set_attr "prefix_data16" "1")
15244    (set_attr "prefix_extra" "1")
15245    (set_attr "length_immediate" "1")
15246    (set_attr "memory" "none,load")
15247    (set_attr "mode" "TI")])
15249 (define_insn "sse4_2_pcmpestri"
15250   [(set (match_operand:SI 0 "register_operand" "=c,c")
15251         (unspec:SI
15252           [(match_operand:V16QI 1 "register_operand" "x,x")
15253            (match_operand:SI 2 "register_operand" "a,a")
15254            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
15255            (match_operand:SI 4 "register_operand" "d,d")
15256            (match_operand:SI 5 "const_0_to_255_operand" "n,n")]
15257           UNSPEC_PCMPESTR))
15258    (set (reg:CC FLAGS_REG)
15259         (unspec:CC
15260           [(match_dup 1)
15261            (match_dup 2)
15262            (match_dup 3)
15263            (match_dup 4)
15264            (match_dup 5)]
15265           UNSPEC_PCMPESTR))]
15266   "TARGET_SSE4_2"
15267   "%vpcmpestri\t{%5, %3, %1|%1, %3, %5}"
15268   [(set_attr "type" "sselog")
15269    (set_attr "prefix_data16" "1")
15270    (set_attr "prefix_extra" "1")
15271    (set_attr "prefix" "maybe_vex")
15272    (set_attr "length_immediate" "1")
15273    (set_attr "btver2_decode" "vector")
15274    (set_attr "memory" "none,load")
15275    (set_attr "mode" "TI")])
15277 (define_insn "sse4_2_pcmpestrm"
15278   [(set (match_operand:V16QI 0 "register_operand" "=Yz,Yz")
15279         (unspec:V16QI
15280           [(match_operand:V16QI 1 "register_operand" "x,x")
15281            (match_operand:SI 2 "register_operand" "a,a")
15282            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
15283            (match_operand:SI 4 "register_operand" "d,d")
15284            (match_operand:SI 5 "const_0_to_255_operand" "n,n")]
15285           UNSPEC_PCMPESTR))
15286    (set (reg:CC FLAGS_REG)
15287         (unspec:CC
15288           [(match_dup 1)
15289            (match_dup 2)
15290            (match_dup 3)
15291            (match_dup 4)
15292            (match_dup 5)]
15293           UNSPEC_PCMPESTR))]
15294   "TARGET_SSE4_2"
15295   "%vpcmpestrm\t{%5, %3, %1|%1, %3, %5}"
15296   [(set_attr "type" "sselog")
15297    (set_attr "prefix_data16" "1")
15298    (set_attr "prefix_extra" "1")
15299    (set_attr "length_immediate" "1")
15300    (set_attr "prefix" "maybe_vex")
15301    (set_attr "btver2_decode" "vector")
15302    (set_attr "memory" "none,load")
15303    (set_attr "mode" "TI")])
15305 (define_insn "sse4_2_pcmpestr_cconly"
15306   [(set (reg:CC FLAGS_REG)
15307         (unspec:CC
15308           [(match_operand:V16QI 2 "register_operand" "x,x,x,x")
15309            (match_operand:SI 3 "register_operand" "a,a,a,a")
15310            (match_operand:V16QI 4 "nonimmediate_operand" "x,m,x,m")
15311            (match_operand:SI 5 "register_operand" "d,d,d,d")
15312            (match_operand:SI 6 "const_0_to_255_operand" "n,n,n,n")]
15313           UNSPEC_PCMPESTR))
15314    (clobber (match_scratch:V16QI 0 "=Yz,Yz,X,X"))
15315    (clobber (match_scratch:SI    1 "= X, X,c,c"))]
15316   "TARGET_SSE4_2"
15317   "@
15318    %vpcmpestrm\t{%6, %4, %2|%2, %4, %6}
15319    %vpcmpestrm\t{%6, %4, %2|%2, %4, %6}
15320    %vpcmpestri\t{%6, %4, %2|%2, %4, %6}
15321    %vpcmpestri\t{%6, %4, %2|%2, %4, %6}"
15322   [(set_attr "type" "sselog")
15323    (set_attr "prefix_data16" "1")
15324    (set_attr "prefix_extra" "1")
15325    (set_attr "length_immediate" "1")
15326    (set_attr "memory" "none,load,none,load")
15327    (set_attr "btver2_decode" "vector,vector,vector,vector") 
15328    (set_attr "prefix" "maybe_vex")
15329    (set_attr "mode" "TI")])
15331 (define_insn_and_split "sse4_2_pcmpistr"
15332   [(set (match_operand:SI 0 "register_operand" "=c,c")
15333         (unspec:SI
15334           [(match_operand:V16QI 2 "register_operand" "x,x")
15335            (match_operand:V16QI 3 "nonimmediate_operand" "x,m")
15336            (match_operand:SI 4 "const_0_to_255_operand" "n,n")]
15337           UNSPEC_PCMPISTR))
15338    (set (match_operand:V16QI 1 "register_operand" "=Yz,Yz")
15339         (unspec:V16QI
15340           [(match_dup 2)
15341            (match_dup 3)
15342            (match_dup 4)]
15343           UNSPEC_PCMPISTR))
15344    (set (reg:CC FLAGS_REG)
15345         (unspec:CC
15346           [(match_dup 2)
15347            (match_dup 3)
15348            (match_dup 4)]
15349           UNSPEC_PCMPISTR))]
15350   "TARGET_SSE4_2
15351    && can_create_pseudo_p ()"
15352   "#"
15353   "&& 1"
15354   [(const_int 0)]
15356   int ecx = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[0]));
15357   int xmm0 = !find_regno_note (curr_insn, REG_UNUSED, REGNO (operands[1]));
15358   int flags = !find_regno_note (curr_insn, REG_UNUSED, FLAGS_REG);
15360   if (ecx)
15361     emit_insn (gen_sse4_2_pcmpistri (operands[0], operands[2],
15362                                      operands[3], operands[4]));
15363   if (xmm0)
15364     emit_insn (gen_sse4_2_pcmpistrm (operands[1], operands[2],
15365                                      operands[3], operands[4]));
15366   if (flags && !(ecx || xmm0))
15367     emit_insn (gen_sse4_2_pcmpistr_cconly (NULL, NULL,
15368                                            operands[2], operands[3],
15369                                            operands[4]));
15370   if (!(flags || ecx || xmm0))
15371     emit_note (NOTE_INSN_DELETED);
15373   DONE;
15375   [(set_attr "type" "sselog")
15376    (set_attr "prefix_data16" "1")
15377    (set_attr "prefix_extra" "1")
15378    (set_attr "length_immediate" "1")
15379    (set_attr "memory" "none,load")
15380    (set_attr "mode" "TI")])
15382 (define_insn "sse4_2_pcmpistri"
15383   [(set (match_operand:SI 0 "register_operand" "=c,c")
15384         (unspec:SI
15385           [(match_operand:V16QI 1 "register_operand" "x,x")
15386            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
15387            (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
15388           UNSPEC_PCMPISTR))
15389    (set (reg:CC FLAGS_REG)
15390         (unspec:CC
15391           [(match_dup 1)
15392            (match_dup 2)
15393            (match_dup 3)]
15394           UNSPEC_PCMPISTR))]
15395   "TARGET_SSE4_2"
15396   "%vpcmpistri\t{%3, %2, %1|%1, %2, %3}"
15397   [(set_attr "type" "sselog")
15398    (set_attr "prefix_data16" "1")
15399    (set_attr "prefix_extra" "1")
15400    (set_attr "length_immediate" "1")
15401    (set_attr "prefix" "maybe_vex")
15402    (set_attr "memory" "none,load")
15403    (set_attr "btver2_decode" "vector")
15404    (set_attr "mode" "TI")])
15406 (define_insn "sse4_2_pcmpistrm"
15407   [(set (match_operand:V16QI 0 "register_operand" "=Yz,Yz")
15408         (unspec:V16QI
15409           [(match_operand:V16QI 1 "register_operand" "x,x")
15410            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
15411            (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
15412           UNSPEC_PCMPISTR))
15413    (set (reg:CC FLAGS_REG)
15414         (unspec:CC
15415           [(match_dup 1)
15416            (match_dup 2)
15417            (match_dup 3)]
15418           UNSPEC_PCMPISTR))]
15419   "TARGET_SSE4_2"
15420   "%vpcmpistrm\t{%3, %2, %1|%1, %2, %3}"
15421   [(set_attr "type" "sselog")
15422    (set_attr "prefix_data16" "1")
15423    (set_attr "prefix_extra" "1")
15424    (set_attr "length_immediate" "1")
15425    (set_attr "prefix" "maybe_vex")
15426    (set_attr "memory" "none,load")
15427    (set_attr "btver2_decode" "vector")
15428    (set_attr "mode" "TI")])
15430 (define_insn "sse4_2_pcmpistr_cconly"
15431   [(set (reg:CC FLAGS_REG)
15432         (unspec:CC
15433           [(match_operand:V16QI 2 "register_operand" "x,x,x,x")
15434            (match_operand:V16QI 3 "nonimmediate_operand" "x,m,x,m")
15435            (match_operand:SI 4 "const_0_to_255_operand" "n,n,n,n")]
15436           UNSPEC_PCMPISTR))
15437    (clobber (match_scratch:V16QI 0 "=Yz,Yz,X,X"))
15438    (clobber (match_scratch:SI    1 "= X, X,c,c"))]
15439   "TARGET_SSE4_2"
15440   "@
15441    %vpcmpistrm\t{%4, %3, %2|%2, %3, %4}
15442    %vpcmpistrm\t{%4, %3, %2|%2, %3, %4}
15443    %vpcmpistri\t{%4, %3, %2|%2, %3, %4}
15444    %vpcmpistri\t{%4, %3, %2|%2, %3, %4}"
15445   [(set_attr "type" "sselog")
15446    (set_attr "prefix_data16" "1")
15447    (set_attr "prefix_extra" "1")
15448    (set_attr "length_immediate" "1")
15449    (set_attr "memory" "none,load,none,load")
15450    (set_attr "prefix" "maybe_vex")
15451    (set_attr "btver2_decode" "vector,vector,vector,vector")
15452    (set_attr "mode" "TI")])
15454 ;; Packed float variants
15455 (define_mode_attr GATHER_SCATTER_SF_MEM_MODE
15456                       [(V8DI "V8SF") (V16SI "V16SF")])
15458 (define_expand "avx512pf_gatherpf<mode>sf"
15459   [(unspec
15460      [(match_operand:<avx512fmaskmode> 0 "register_operand")
15461       (mem:<GATHER_SCATTER_SF_MEM_MODE>
15462         (match_par_dup 5
15463           [(match_operand 2 "vsib_address_operand")
15464            (match_operand:VI48_512 1 "register_operand")
15465            (match_operand:SI 3 "const1248_operand")]))
15466       (match_operand:SI 4 "const_2_to_3_operand")]
15467      UNSPEC_GATHER_PREFETCH)]
15468   "TARGET_AVX512PF"
15470   operands[5]
15471     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
15472                                         operands[3]), UNSPEC_VSIBADDR);
15475 (define_insn "*avx512pf_gatherpf<mode>sf_mask"
15476   [(unspec
15477      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
15478       (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 5 "vsib_mem_operator"
15479         [(unspec:P
15480            [(match_operand:P 2 "vsib_address_operand" "Tv")
15481             (match_operand:VI48_512 1 "register_operand" "v")
15482             (match_operand:SI 3 "const1248_operand" "n")]
15483            UNSPEC_VSIBADDR)])
15484       (match_operand:SI 4 "const_2_to_3_operand" "n")]
15485      UNSPEC_GATHER_PREFETCH)]
15486   "TARGET_AVX512PF"
15488   switch (INTVAL (operands[4]))
15489     {
15490     case 3:
15491       return "vgatherpf0<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
15492     case 2:
15493       return "vgatherpf1<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
15494     default:
15495       gcc_unreachable ();
15496     }
15498   [(set_attr "type" "sse")
15499    (set_attr "prefix" "evex")
15500    (set_attr "mode" "XI")])
15502 ;; Packed double variants
15503 (define_expand "avx512pf_gatherpf<mode>df"
15504   [(unspec
15505      [(match_operand:<avx512fmaskmode> 0 "register_operand")
15506       (mem:V8DF
15507         (match_par_dup 5
15508           [(match_operand 2 "vsib_address_operand")
15509            (match_operand:VI4_256_8_512 1 "register_operand")
15510            (match_operand:SI 3 "const1248_operand")]))
15511       (match_operand:SI 4 "const_2_to_3_operand")]
15512      UNSPEC_GATHER_PREFETCH)]
15513   "TARGET_AVX512PF"
15515   operands[5]
15516     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
15517                                         operands[3]), UNSPEC_VSIBADDR);
15520 (define_insn "*avx512pf_gatherpf<mode>df_mask"
15521   [(unspec
15522      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
15523       (match_operator:V8DF 5 "vsib_mem_operator"
15524         [(unspec:P
15525            [(match_operand:P 2 "vsib_address_operand" "Tv")
15526             (match_operand:VI4_256_8_512 1 "register_operand" "v")
15527             (match_operand:SI 3 "const1248_operand" "n")]
15528            UNSPEC_VSIBADDR)])
15529       (match_operand:SI 4 "const_2_to_3_operand" "n")]
15530      UNSPEC_GATHER_PREFETCH)]
15531   "TARGET_AVX512PF"
15533   switch (INTVAL (operands[4]))
15534     {
15535     case 3:
15536       return "vgatherpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
15537     case 2:
15538       return "vgatherpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
15539     default:
15540       gcc_unreachable ();
15541     }
15543   [(set_attr "type" "sse")
15544    (set_attr "prefix" "evex")
15545    (set_attr "mode" "XI")])
15547 ;; Packed float variants
15548 (define_expand "avx512pf_scatterpf<mode>sf"
15549   [(unspec
15550      [(match_operand:<avx512fmaskmode> 0 "register_operand")
15551       (mem:<GATHER_SCATTER_SF_MEM_MODE>
15552         (match_par_dup 5
15553           [(match_operand 2 "vsib_address_operand")
15554            (match_operand:VI48_512 1 "register_operand")
15555            (match_operand:SI 3 "const1248_operand")]))
15556       (match_operand:SI 4 "const2367_operand")]
15557      UNSPEC_SCATTER_PREFETCH)]
15558   "TARGET_AVX512PF"
15560   operands[5]
15561     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
15562                                         operands[3]), UNSPEC_VSIBADDR);
15565 (define_insn "*avx512pf_scatterpf<mode>sf_mask"
15566   [(unspec
15567      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
15568       (match_operator:<GATHER_SCATTER_SF_MEM_MODE> 5 "vsib_mem_operator"
15569         [(unspec:P
15570            [(match_operand:P 2 "vsib_address_operand" "Tv")
15571             (match_operand:VI48_512 1 "register_operand" "v")
15572             (match_operand:SI 3 "const1248_operand" "n")]
15573            UNSPEC_VSIBADDR)])
15574       (match_operand:SI 4 "const2367_operand" "n")]
15575      UNSPEC_SCATTER_PREFETCH)]
15576   "TARGET_AVX512PF"
15578   switch (INTVAL (operands[4]))
15579     {
15580     case 3:
15581     case 7:
15582       return "vscatterpf0<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
15583     case 2:
15584     case 6:
15585       return "vscatterpf1<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
15586     default:
15587       gcc_unreachable ();
15588     }
15590   [(set_attr "type" "sse")
15591    (set_attr "prefix" "evex")
15592    (set_attr "mode" "XI")])
15594 ;; Packed double variants
15595 (define_expand "avx512pf_scatterpf<mode>df"
15596   [(unspec
15597      [(match_operand:<avx512fmaskmode> 0 "register_operand")
15598       (mem:V8DF
15599         (match_par_dup 5
15600           [(match_operand 2 "vsib_address_operand")
15601            (match_operand:VI4_256_8_512 1 "register_operand")
15602            (match_operand:SI 3 "const1248_operand")]))
15603       (match_operand:SI 4 "const2367_operand")]
15604      UNSPEC_SCATTER_PREFETCH)]
15605   "TARGET_AVX512PF"
15607   operands[5]
15608     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[1],
15609                                         operands[3]), UNSPEC_VSIBADDR);
15612 (define_insn "*avx512pf_scatterpf<mode>df_mask"
15613   [(unspec
15614      [(match_operand:<avx512fmaskmode> 0 "register_operand" "Yk")
15615       (match_operator:V8DF 5 "vsib_mem_operator"
15616         [(unspec:P
15617            [(match_operand:P 2 "vsib_address_operand" "Tv")
15618             (match_operand:VI4_256_8_512 1 "register_operand" "v")
15619             (match_operand:SI 3 "const1248_operand" "n")]
15620            UNSPEC_VSIBADDR)])
15621       (match_operand:SI 4 "const2367_operand" "n")]
15622      UNSPEC_SCATTER_PREFETCH)]
15623   "TARGET_AVX512PF"
15625   switch (INTVAL (operands[4]))
15626     {
15627     case 3:
15628     case 7:
15629       return "vscatterpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
15630     case 2:
15631     case 6:
15632       return "vscatterpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
15633     default:
15634       gcc_unreachable ();
15635     }
15637   [(set_attr "type" "sse")
15638    (set_attr "prefix" "evex")
15639    (set_attr "mode" "XI")])
15641 (define_insn "avx512er_exp2<mode><mask_name><round_saeonly_name>"
15642   [(set (match_operand:VF_512 0 "register_operand" "=v")
15643         (unspec:VF_512
15644           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
15645           UNSPEC_EXP2))]
15646   "TARGET_AVX512ER"
15647   "vexp2<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
15648   [(set_attr "prefix" "evex")
15649    (set_attr "type" "sse")
15650    (set_attr "mode" "<MODE>")])
15652 (define_insn "<mask_codefor>avx512er_rcp28<mode><mask_name><round_saeonly_name>"
15653   [(set (match_operand:VF_512 0 "register_operand" "=v")
15654         (unspec:VF_512
15655           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
15656           UNSPEC_RCP28))]
15657   "TARGET_AVX512ER"
15658   "vrcp28<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
15659   [(set_attr "prefix" "evex")
15660    (set_attr "type" "sse")
15661    (set_attr "mode" "<MODE>")])
15663 (define_insn "avx512er_vmrcp28<mode><round_saeonly_name>"
15664   [(set (match_operand:VF_128 0 "register_operand" "=v")
15665         (vec_merge:VF_128
15666           (unspec:VF_128
15667             [(match_operand:VF_128 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
15668             UNSPEC_RCP28)
15669           (match_operand:VF_128 2 "register_operand" "v")
15670           (const_int 1)))]
15671   "TARGET_AVX512ER"
15672   "vrcp28<ssescalarmodesuffix>\t{<round_saeonly_op3>%1, %2, %0|%0, %2, %1<round_saeonly_op3>}"
15673   [(set_attr "length_immediate" "1")
15674    (set_attr "prefix" "evex")
15675    (set_attr "type" "sse")
15676    (set_attr "mode" "<MODE>")])
15678 (define_insn "<mask_codefor>avx512er_rsqrt28<mode><mask_name><round_saeonly_name>"
15679   [(set (match_operand:VF_512 0 "register_operand" "=v")
15680         (unspec:VF_512
15681           [(match_operand:VF_512 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
15682           UNSPEC_RSQRT28))]
15683   "TARGET_AVX512ER"
15684   "vrsqrt28<ssemodesuffix>\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
15685   [(set_attr "prefix" "evex")
15686    (set_attr "type" "sse")
15687    (set_attr "mode" "<MODE>")])
15689 (define_insn "avx512er_vmrsqrt28<mode><round_saeonly_name>"
15690   [(set (match_operand:VF_128 0 "register_operand" "=v")
15691         (vec_merge:VF_128
15692           (unspec:VF_128
15693             [(match_operand:VF_128 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
15694             UNSPEC_RSQRT28)
15695           (match_operand:VF_128 2 "register_operand" "v")
15696           (const_int 1)))]
15697   "TARGET_AVX512ER"
15698   "vrsqrt28<ssescalarmodesuffix>\t{<round_saeonly_op3>%1, %2, %0|%0, %2, %1<round_saeonly_op3>}"
15699   [(set_attr "length_immediate" "1")
15700    (set_attr "type" "sse")
15701    (set_attr "prefix" "evex")
15702    (set_attr "mode" "<MODE>")])
15704 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15706 ;; XOP instructions
15708 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15710 (define_code_iterator xop_plus [plus ss_plus])
15712 (define_code_attr macs [(plus "macs") (ss_plus "macss")])
15713 (define_code_attr madcs [(plus "madcs") (ss_plus "madcss")])
15715 ;; XOP parallel integer multiply/add instructions.
15717 (define_insn "xop_p<macs><ssemodesuffix><ssemodesuffix>"
15718   [(set (match_operand:VI24_128 0 "register_operand" "=x")
15719         (xop_plus:VI24_128
15720          (mult:VI24_128
15721           (match_operand:VI24_128 1 "nonimmediate_operand" "%x")
15722           (match_operand:VI24_128 2 "nonimmediate_operand" "xm"))
15723          (match_operand:VI24_128 3 "register_operand" "x")))]
15724   "TARGET_XOP"
15725   "vp<macs><ssemodesuffix><ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15726   [(set_attr "type" "ssemuladd")
15727    (set_attr "mode" "TI")])
15729 (define_insn "xop_p<macs>dql"
15730   [(set (match_operand:V2DI 0 "register_operand" "=x")
15731         (xop_plus:V2DI
15732          (mult:V2DI
15733           (sign_extend:V2DI
15734            (vec_select:V2SI
15735             (match_operand:V4SI 1 "nonimmediate_operand" "%x")
15736             (parallel [(const_int 0) (const_int 2)])))
15737           (sign_extend:V2DI
15738            (vec_select:V2SI
15739             (match_operand:V4SI 2 "nonimmediate_operand" "xm")
15740             (parallel [(const_int 0) (const_int 2)]))))
15741          (match_operand:V2DI 3 "register_operand" "x")))]
15742   "TARGET_XOP"
15743   "vp<macs>dql\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15744   [(set_attr "type" "ssemuladd")
15745    (set_attr "mode" "TI")])
15747 (define_insn "xop_p<macs>dqh"
15748   [(set (match_operand:V2DI 0 "register_operand" "=x")
15749         (xop_plus:V2DI
15750          (mult:V2DI
15751           (sign_extend:V2DI
15752            (vec_select:V2SI
15753             (match_operand:V4SI 1 "nonimmediate_operand" "%x")
15754             (parallel [(const_int 1) (const_int 3)])))
15755           (sign_extend:V2DI
15756            (vec_select:V2SI
15757             (match_operand:V4SI 2 "nonimmediate_operand" "xm")
15758             (parallel [(const_int 1) (const_int 3)]))))
15759          (match_operand:V2DI 3 "register_operand" "x")))]
15760   "TARGET_XOP"
15761   "vp<macs>dqh\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15762   [(set_attr "type" "ssemuladd")
15763    (set_attr "mode" "TI")])
15765 ;; XOP parallel integer multiply/add instructions for the intrinisics
15766 (define_insn "xop_p<macs>wd"
15767   [(set (match_operand:V4SI 0 "register_operand" "=x")
15768         (xop_plus:V4SI
15769          (mult:V4SI
15770           (sign_extend:V4SI
15771            (vec_select:V4HI
15772             (match_operand:V8HI 1 "nonimmediate_operand" "%x")
15773             (parallel [(const_int 1) (const_int 3)
15774                        (const_int 5) (const_int 7)])))
15775           (sign_extend:V4SI
15776            (vec_select:V4HI
15777             (match_operand:V8HI 2 "nonimmediate_operand" "xm")
15778             (parallel [(const_int 1) (const_int 3)
15779                        (const_int 5) (const_int 7)]))))
15780          (match_operand:V4SI 3 "register_operand" "x")))]
15781   "TARGET_XOP"
15782   "vp<macs>wd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15783   [(set_attr "type" "ssemuladd")
15784    (set_attr "mode" "TI")])
15786 (define_insn "xop_p<madcs>wd"
15787   [(set (match_operand:V4SI 0 "register_operand" "=x")
15788         (xop_plus:V4SI
15789          (plus:V4SI
15790           (mult:V4SI
15791            (sign_extend:V4SI
15792             (vec_select:V4HI
15793              (match_operand:V8HI 1 "nonimmediate_operand" "%x")
15794              (parallel [(const_int 0) (const_int 2)
15795                         (const_int 4) (const_int 6)])))
15796            (sign_extend:V4SI
15797             (vec_select:V4HI
15798              (match_operand:V8HI 2 "nonimmediate_operand" "xm")
15799              (parallel [(const_int 0) (const_int 2)
15800                         (const_int 4) (const_int 6)]))))
15801           (mult:V4SI
15802            (sign_extend:V4SI
15803             (vec_select:V4HI
15804              (match_dup 1)
15805              (parallel [(const_int 1) (const_int 3)
15806                         (const_int 5) (const_int 7)])))
15807            (sign_extend:V4SI
15808             (vec_select:V4HI
15809              (match_dup 2)
15810              (parallel [(const_int 1) (const_int 3)
15811                         (const_int 5) (const_int 7)])))))
15812          (match_operand:V4SI 3 "register_operand" "x")))]
15813   "TARGET_XOP"
15814   "vp<madcs>wd\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15815   [(set_attr "type" "ssemuladd")
15816    (set_attr "mode" "TI")])
15818 ;; XOP parallel XMM conditional moves
15819 (define_insn "xop_pcmov_<mode><avxsizesuffix>"
15820   [(set (match_operand:V 0 "register_operand" "=x,x")
15821         (if_then_else:V
15822           (match_operand:V 3 "nonimmediate_operand" "x,m")
15823           (match_operand:V 1 "register_operand" "x,x")
15824           (match_operand:V 2 "nonimmediate_operand" "xm,x")))]
15825   "TARGET_XOP"
15826   "vpcmov\t{%3, %2, %1, %0|%0, %1, %2, %3}"
15827   [(set_attr "type" "sse4arg")])
15829 ;; XOP horizontal add/subtract instructions
15830 (define_insn "xop_phadd<u>bw"
15831   [(set (match_operand:V8HI 0 "register_operand" "=x")
15832         (plus:V8HI
15833          (any_extend:V8HI
15834           (vec_select:V8QI
15835            (match_operand:V16QI 1 "nonimmediate_operand" "xm")
15836            (parallel [(const_int 0) (const_int 2)
15837                       (const_int 4) (const_int 6)
15838                       (const_int 8) (const_int 10)
15839                       (const_int 12) (const_int 14)])))
15840          (any_extend:V8HI
15841           (vec_select:V8QI
15842            (match_dup 1)
15843            (parallel [(const_int 1) (const_int 3)
15844                       (const_int 5) (const_int 7)
15845                       (const_int 9) (const_int 11)
15846                       (const_int 13) (const_int 15)])))))]
15847   "TARGET_XOP"
15848   "vphadd<u>bw\t{%1, %0|%0, %1}"
15849   [(set_attr "type" "sseiadd1")])
15851 (define_insn "xop_phadd<u>bd"
15852   [(set (match_operand:V4SI 0 "register_operand" "=x")
15853         (plus:V4SI
15854          (plus:V4SI
15855           (any_extend:V4SI
15856            (vec_select:V4QI
15857             (match_operand:V16QI 1 "nonimmediate_operand" "xm")
15858             (parallel [(const_int 0) (const_int 4)
15859                        (const_int 8) (const_int 12)])))
15860           (any_extend:V4SI
15861            (vec_select:V4QI
15862             (match_dup 1)
15863             (parallel [(const_int 1) (const_int 5)
15864                        (const_int 9) (const_int 13)]))))
15865          (plus:V4SI
15866           (any_extend:V4SI
15867            (vec_select:V4QI
15868             (match_dup 1)
15869             (parallel [(const_int 2) (const_int 6)
15870                        (const_int 10) (const_int 14)])))
15871           (any_extend:V4SI
15872            (vec_select:V4QI
15873             (match_dup 1)
15874             (parallel [(const_int 3) (const_int 7)
15875                        (const_int 11) (const_int 15)]))))))]
15876   "TARGET_XOP"
15877   "vphadd<u>bd\t{%1, %0|%0, %1}"
15878   [(set_attr "type" "sseiadd1")])
15880 (define_insn "xop_phadd<u>bq"
15881   [(set (match_operand:V2DI 0 "register_operand" "=x")
15882         (plus:V2DI
15883          (plus:V2DI
15884           (plus:V2DI
15885            (any_extend:V2DI
15886             (vec_select:V2QI
15887              (match_operand:V16QI 1 "nonimmediate_operand" "xm")
15888              (parallel [(const_int 0) (const_int 8)])))
15889            (any_extend:V2DI
15890             (vec_select:V2QI
15891              (match_dup 1)
15892              (parallel [(const_int 1) (const_int 9)]))))
15893           (plus:V2DI
15894            (any_extend:V2DI
15895             (vec_select:V2QI
15896              (match_dup 1)
15897              (parallel [(const_int 2) (const_int 10)])))
15898            (any_extend:V2DI
15899             (vec_select:V2QI
15900              (match_dup 1)
15901              (parallel [(const_int 3) (const_int 11)])))))
15902          (plus:V2DI
15903           (plus:V2DI
15904            (any_extend:V2DI
15905             (vec_select:V2QI
15906              (match_dup 1)
15907              (parallel [(const_int 4) (const_int 12)])))
15908            (any_extend:V2DI
15909             (vec_select:V2QI
15910              (match_dup 1)
15911              (parallel [(const_int 5) (const_int 13)]))))
15912           (plus:V2DI
15913            (any_extend:V2DI
15914             (vec_select:V2QI
15915              (match_dup 1)
15916              (parallel [(const_int 6) (const_int 14)])))
15917            (any_extend:V2DI
15918             (vec_select:V2QI
15919              (match_dup 1)
15920              (parallel [(const_int 7) (const_int 15)])))))))]
15921   "TARGET_XOP"
15922   "vphadd<u>bq\t{%1, %0|%0, %1}"
15923   [(set_attr "type" "sseiadd1")])
15925 (define_insn "xop_phadd<u>wd"
15926   [(set (match_operand:V4SI 0 "register_operand" "=x")
15927         (plus:V4SI
15928          (any_extend:V4SI
15929           (vec_select:V4HI
15930            (match_operand:V8HI 1 "nonimmediate_operand" "xm")
15931            (parallel [(const_int 0) (const_int 2)
15932                       (const_int 4) (const_int 6)])))
15933          (any_extend:V4SI
15934           (vec_select:V4HI
15935            (match_dup 1)
15936            (parallel [(const_int 1) (const_int 3)
15937                       (const_int 5) (const_int 7)])))))]
15938   "TARGET_XOP"
15939   "vphadd<u>wd\t{%1, %0|%0, %1}"
15940   [(set_attr "type" "sseiadd1")])
15942 (define_insn "xop_phadd<u>wq"
15943   [(set (match_operand:V2DI 0 "register_operand" "=x")
15944         (plus:V2DI
15945          (plus:V2DI
15946           (any_extend:V2DI
15947            (vec_select:V2HI
15948             (match_operand:V8HI 1 "nonimmediate_operand" "xm")
15949             (parallel [(const_int 0) (const_int 4)])))
15950           (any_extend:V2DI
15951            (vec_select:V2HI
15952             (match_dup 1)
15953             (parallel [(const_int 1) (const_int 5)]))))
15954          (plus:V2DI
15955           (any_extend:V2DI
15956            (vec_select:V2HI
15957             (match_dup 1)
15958             (parallel [(const_int 2) (const_int 6)])))
15959           (any_extend:V2DI
15960            (vec_select:V2HI
15961             (match_dup 1)
15962             (parallel [(const_int 3) (const_int 7)]))))))]
15963   "TARGET_XOP"
15964   "vphadd<u>wq\t{%1, %0|%0, %1}"
15965   [(set_attr "type" "sseiadd1")])
15967 (define_insn "xop_phadd<u>dq"
15968   [(set (match_operand:V2DI 0 "register_operand" "=x")
15969         (plus:V2DI
15970          (any_extend:V2DI
15971           (vec_select:V2SI
15972            (match_operand:V4SI 1 "nonimmediate_operand" "xm")
15973            (parallel [(const_int 0) (const_int 2)])))
15974          (any_extend:V2DI
15975           (vec_select:V2SI
15976            (match_dup 1)
15977            (parallel [(const_int 1) (const_int 3)])))))]
15978   "TARGET_XOP"
15979   "vphadd<u>dq\t{%1, %0|%0, %1}"
15980   [(set_attr "type" "sseiadd1")])
15982 (define_insn "xop_phsubbw"
15983   [(set (match_operand:V8HI 0 "register_operand" "=x")
15984         (minus:V8HI
15985          (sign_extend:V8HI
15986           (vec_select:V8QI
15987            (match_operand:V16QI 1 "nonimmediate_operand" "xm")
15988            (parallel [(const_int 0) (const_int 2)
15989                       (const_int 4) (const_int 6)
15990                       (const_int 8) (const_int 10)
15991                       (const_int 12) (const_int 14)])))
15992          (sign_extend:V8HI
15993           (vec_select:V8QI
15994            (match_dup 1)
15995            (parallel [(const_int 1) (const_int 3)
15996                       (const_int 5) (const_int 7)
15997                       (const_int 9) (const_int 11)
15998                       (const_int 13) (const_int 15)])))))]
15999   "TARGET_XOP"
16000   "vphsubbw\t{%1, %0|%0, %1}"
16001   [(set_attr "type" "sseiadd1")])
16003 (define_insn "xop_phsubwd"
16004   [(set (match_operand:V4SI 0 "register_operand" "=x")
16005         (minus:V4SI
16006          (sign_extend:V4SI
16007           (vec_select:V4HI
16008            (match_operand:V8HI 1 "nonimmediate_operand" "xm")
16009            (parallel [(const_int 0) (const_int 2)
16010                       (const_int 4) (const_int 6)])))
16011          (sign_extend:V4SI
16012           (vec_select:V4HI
16013            (match_dup 1)
16014            (parallel [(const_int 1) (const_int 3)
16015                       (const_int 5) (const_int 7)])))))]
16016   "TARGET_XOP"
16017   "vphsubwd\t{%1, %0|%0, %1}"
16018   [(set_attr "type" "sseiadd1")])
16020 (define_insn "xop_phsubdq"
16021   [(set (match_operand:V2DI 0 "register_operand" "=x")
16022         (minus:V2DI
16023          (sign_extend:V2DI
16024           (vec_select:V2SI
16025            (match_operand:V4SI 1 "nonimmediate_operand" "xm")
16026            (parallel [(const_int 0) (const_int 2)])))
16027          (sign_extend:V2DI
16028           (vec_select:V2SI
16029            (match_dup 1)
16030            (parallel [(const_int 1) (const_int 3)])))))]
16031   "TARGET_XOP"
16032   "vphsubdq\t{%1, %0|%0, %1}"
16033   [(set_attr "type" "sseiadd1")])
16035 ;; XOP permute instructions
16036 (define_insn "xop_pperm"
16037   [(set (match_operand:V16QI 0 "register_operand" "=x,x")
16038         (unspec:V16QI
16039           [(match_operand:V16QI 1 "register_operand" "x,x")
16040            (match_operand:V16QI 2 "nonimmediate_operand" "x,m")
16041            (match_operand:V16QI 3 "nonimmediate_operand" "xm,x")]
16042           UNSPEC_XOP_PERMUTE))]
16043   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16044   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16045   [(set_attr "type" "sse4arg")
16046    (set_attr "mode" "TI")])
16048 ;; XOP pack instructions that combine two vectors into a smaller vector
16049 (define_insn "xop_pperm_pack_v2di_v4si"
16050   [(set (match_operand:V4SI 0 "register_operand" "=x,x")
16051         (vec_concat:V4SI
16052          (truncate:V2SI
16053           (match_operand:V2DI 1 "register_operand" "x,x"))
16054          (truncate:V2SI
16055           (match_operand:V2DI 2 "nonimmediate_operand" "x,m"))))
16056    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
16057   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16058   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16059   [(set_attr "type" "sse4arg")
16060    (set_attr "mode" "TI")])
16062 (define_insn "xop_pperm_pack_v4si_v8hi"
16063   [(set (match_operand:V8HI 0 "register_operand" "=x,x")
16064         (vec_concat:V8HI
16065          (truncate:V4HI
16066           (match_operand:V4SI 1 "register_operand" "x,x"))
16067          (truncate:V4HI
16068           (match_operand:V4SI 2 "nonimmediate_operand" "x,m"))))
16069    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
16070   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16071   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16072   [(set_attr "type" "sse4arg")
16073    (set_attr "mode" "TI")])
16075 (define_insn "xop_pperm_pack_v8hi_v16qi"
16076   [(set (match_operand:V16QI 0 "register_operand" "=x,x")
16077         (vec_concat:V16QI
16078          (truncate:V8QI
16079           (match_operand:V8HI 1 "register_operand" "x,x"))
16080          (truncate:V8QI
16081           (match_operand:V8HI 2 "nonimmediate_operand" "x,m"))))
16082    (use (match_operand:V16QI 3 "nonimmediate_operand" "xm,x"))]
16083   "TARGET_XOP && !(MEM_P (operands[2]) && MEM_P (operands[3]))"
16084   "vpperm\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16085   [(set_attr "type" "sse4arg")
16086    (set_attr "mode" "TI")])
16088 ;; XOP packed rotate instructions
16089 (define_expand "rotl<mode>3"
16090   [(set (match_operand:VI_128 0 "register_operand")
16091         (rotate:VI_128
16092          (match_operand:VI_128 1 "nonimmediate_operand")
16093          (match_operand:SI 2 "general_operand")))]
16094   "TARGET_XOP"
16096   /* If we were given a scalar, convert it to parallel */
16097   if (! const_0_to_<sserotatemax>_operand (operands[2], SImode))
16098     {
16099       rtvec vs = rtvec_alloc (<ssescalarnum>);
16100       rtx par = gen_rtx_PARALLEL (<MODE>mode, vs);
16101       rtx reg = gen_reg_rtx (<MODE>mode);
16102       rtx op2 = operands[2];
16103       int i;
16105       if (GET_MODE (op2) != <ssescalarmode>mode)
16106         {
16107           op2 = gen_reg_rtx (<ssescalarmode>mode);
16108           convert_move (op2, operands[2], false);
16109         }
16111       for (i = 0; i < <ssescalarnum>; i++)
16112         RTVEC_ELT (vs, i) = op2;
16114       emit_insn (gen_vec_init<mode> (reg, par));
16115       emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], reg));
16116       DONE;
16117     }
16120 (define_expand "rotr<mode>3"
16121   [(set (match_operand:VI_128 0 "register_operand")
16122         (rotatert:VI_128
16123          (match_operand:VI_128 1 "nonimmediate_operand")
16124          (match_operand:SI 2 "general_operand")))]
16125   "TARGET_XOP"
16127   /* If we were given a scalar, convert it to parallel */
16128   if (! const_0_to_<sserotatemax>_operand (operands[2], SImode))
16129     {
16130       rtvec vs = rtvec_alloc (<ssescalarnum>);
16131       rtx par = gen_rtx_PARALLEL (<MODE>mode, vs);
16132       rtx neg = gen_reg_rtx (<MODE>mode);
16133       rtx reg = gen_reg_rtx (<MODE>mode);
16134       rtx op2 = operands[2];
16135       int i;
16137       if (GET_MODE (op2) != <ssescalarmode>mode)
16138         {
16139           op2 = gen_reg_rtx (<ssescalarmode>mode);
16140           convert_move (op2, operands[2], false);
16141         }
16143       for (i = 0; i < <ssescalarnum>; i++)
16144         RTVEC_ELT (vs, i) = op2;
16146       emit_insn (gen_vec_init<mode> (reg, par));
16147       emit_insn (gen_neg<mode>2 (neg, reg));
16148       emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], neg));
16149       DONE;
16150     }
16153 (define_insn "xop_rotl<mode>3"
16154   [(set (match_operand:VI_128 0 "register_operand" "=x")
16155         (rotate:VI_128
16156          (match_operand:VI_128 1 "nonimmediate_operand" "xm")
16157          (match_operand:SI 2 "const_0_to_<sserotatemax>_operand" "n")))]
16158   "TARGET_XOP"
16159   "vprot<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16160   [(set_attr "type" "sseishft")
16161    (set_attr "length_immediate" "1")
16162    (set_attr "mode" "TI")])
16164 (define_insn "xop_rotr<mode>3"
16165   [(set (match_operand:VI_128 0 "register_operand" "=x")
16166         (rotatert:VI_128
16167          (match_operand:VI_128 1 "nonimmediate_operand" "xm")
16168          (match_operand:SI 2 "const_0_to_<sserotatemax>_operand" "n")))]
16169   "TARGET_XOP"
16171   operands[3]
16172     = GEN_INT (GET_MODE_BITSIZE (<ssescalarmode>mode) - INTVAL (operands[2]));
16173   return \"vprot<ssemodesuffix>\t{%3, %1, %0|%0, %1, %3}\";
16175   [(set_attr "type" "sseishft")
16176    (set_attr "length_immediate" "1")
16177    (set_attr "mode" "TI")])
16179 (define_expand "vrotr<mode>3"
16180   [(match_operand:VI_128 0 "register_operand")
16181    (match_operand:VI_128 1 "register_operand")
16182    (match_operand:VI_128 2 "register_operand")]
16183   "TARGET_XOP"
16185   rtx reg = gen_reg_rtx (<MODE>mode);
16186   emit_insn (gen_neg<mode>2 (reg, operands[2]));
16187   emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], reg));
16188   DONE;
16191 (define_expand "vrotl<mode>3"
16192   [(match_operand:VI_128 0 "register_operand")
16193    (match_operand:VI_128 1 "register_operand")
16194    (match_operand:VI_128 2 "register_operand")]
16195   "TARGET_XOP"
16197   emit_insn (gen_xop_vrotl<mode>3 (operands[0], operands[1], operands[2]));
16198   DONE;
16201 (define_insn "xop_vrotl<mode>3"
16202   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
16203         (if_then_else:VI_128
16204          (ge:VI_128
16205           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
16206           (const_int 0))
16207          (rotate:VI_128
16208           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
16209           (match_dup 2))
16210          (rotatert:VI_128
16211           (match_dup 1)
16212           (neg:VI_128 (match_dup 2)))))]
16213   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16214   "vprot<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16215   [(set_attr "type" "sseishft")
16216    (set_attr "prefix_data16" "0")
16217    (set_attr "prefix_extra" "2")
16218    (set_attr "mode" "TI")])
16220 ;; XOP packed shift instructions.
16221 (define_expand "vlshr<mode>3"
16222   [(set (match_operand:VI12_128 0 "register_operand")
16223         (lshiftrt:VI12_128
16224           (match_operand:VI12_128 1 "register_operand")
16225           (match_operand:VI12_128 2 "nonimmediate_operand")))]
16226   "TARGET_XOP"
16228   rtx neg = gen_reg_rtx (<MODE>mode);
16229   emit_insn (gen_neg<mode>2 (neg, operands[2]));
16230   emit_insn (gen_xop_shl<mode>3 (operands[0], operands[1], neg));
16231   DONE;
16234 (define_expand "vlshr<mode>3"
16235   [(set (match_operand:VI48_128 0 "register_operand")
16236         (lshiftrt:VI48_128
16237           (match_operand:VI48_128 1 "register_operand")
16238           (match_operand:VI48_128 2 "nonimmediate_operand")))]
16239   "TARGET_AVX2 || TARGET_XOP"
16241   if (!TARGET_AVX2)
16242     {
16243       rtx neg = gen_reg_rtx (<MODE>mode);
16244       emit_insn (gen_neg<mode>2 (neg, operands[2]));
16245       emit_insn (gen_xop_shl<mode>3 (operands[0], operands[1], neg));
16246       DONE;
16247     }
16250 (define_expand "vlshr<mode>3"
16251   [(set (match_operand:VI48_512 0 "register_operand")
16252         (lshiftrt:VI48_512
16253           (match_operand:VI48_512 1 "register_operand")
16254           (match_operand:VI48_512 2 "nonimmediate_operand")))]
16255   "TARGET_AVX512F")
16257 (define_expand "vlshr<mode>3"
16258   [(set (match_operand:VI48_256 0 "register_operand")
16259         (lshiftrt:VI48_256
16260           (match_operand:VI48_256 1 "register_operand")
16261           (match_operand:VI48_256 2 "nonimmediate_operand")))]
16262   "TARGET_AVX2")
16264 (define_expand "vashrv8hi3<mask_name>"
16265   [(set (match_operand:V8HI 0 "register_operand")
16266         (ashiftrt:V8HI
16267           (match_operand:V8HI 1 "register_operand")
16268           (match_operand:V8HI 2 "nonimmediate_operand")))]
16269   "TARGET_XOP || (TARGET_AVX512BW && TARGET_AVX512VL)"
16271   if (TARGET_XOP)
16272     {
16273       rtx neg = gen_reg_rtx (V8HImode);
16274       emit_insn (gen_negv8hi2 (neg, operands[2]));
16275       emit_insn (gen_xop_shav8hi3 (operands[0], operands[1], neg));
16276       DONE;
16277     }
16280 (define_expand "vashrv16qi3"
16281   [(set (match_operand:V16QI 0 "register_operand")
16282         (ashiftrt:V16QI
16283           (match_operand:V16QI 1 "register_operand")
16284           (match_operand:V16QI 2 "nonimmediate_operand")))]
16285   "TARGET_XOP"
16287    rtx neg = gen_reg_rtx (V16QImode);
16288    emit_insn (gen_negv16qi2 (neg, operands[2]));
16289    emit_insn (gen_xop_shav16qi3 (operands[0], operands[1], neg));
16290    DONE;
16293 (define_expand "vashrv2di3<mask_name>"
16294   [(set (match_operand:V2DI 0 "register_operand")
16295         (ashiftrt:V2DI
16296           (match_operand:V2DI 1 "register_operand")
16297           (match_operand:V2DI 2 "nonimmediate_operand")))]
16298   "TARGET_XOP || TARGET_AVX512VL"
16300   if (TARGET_XOP)
16301     {
16302       rtx neg = gen_reg_rtx (V2DImode);
16303       emit_insn (gen_negv2di2 (neg, operands[2]));
16304       emit_insn (gen_xop_shav2di3 (operands[0], operands[1], neg));
16305       DONE;
16306     }
16309 (define_expand "vashrv4si3"
16310   [(set (match_operand:V4SI 0 "register_operand")
16311         (ashiftrt:V4SI (match_operand:V4SI 1 "register_operand")
16312                        (match_operand:V4SI 2 "nonimmediate_operand")))]
16313   "TARGET_AVX2 || TARGET_XOP"
16315   if (!TARGET_AVX2)
16316     {
16317       rtx neg = gen_reg_rtx (V4SImode);
16318       emit_insn (gen_negv4si2 (neg, operands[2]));
16319       emit_insn (gen_xop_shav4si3 (operands[0], operands[1], neg));
16320       DONE;
16321     }
16324 (define_expand "vashrv16si3"
16325   [(set (match_operand:V16SI 0 "register_operand")
16326         (ashiftrt:V16SI (match_operand:V16SI 1 "register_operand")
16327                         (match_operand:V16SI 2 "nonimmediate_operand")))]
16328   "TARGET_AVX512F")
16330 (define_expand "vashrv8si3"
16331   [(set (match_operand:V8SI 0 "register_operand")
16332         (ashiftrt:V8SI (match_operand:V8SI 1 "register_operand")
16333                        (match_operand:V8SI 2 "nonimmediate_operand")))]
16334   "TARGET_AVX2")
16336 (define_expand "vashl<mode>3"
16337   [(set (match_operand:VI12_128 0 "register_operand")
16338         (ashift:VI12_128
16339           (match_operand:VI12_128 1 "register_operand")
16340           (match_operand:VI12_128 2 "nonimmediate_operand")))]
16341   "TARGET_XOP"
16343   emit_insn (gen_xop_sha<mode>3 (operands[0], operands[1], operands[2]));
16344   DONE;
16347 (define_expand "vashl<mode>3"
16348   [(set (match_operand:VI48_128 0 "register_operand")
16349         (ashift:VI48_128
16350           (match_operand:VI48_128 1 "register_operand")
16351           (match_operand:VI48_128 2 "nonimmediate_operand")))]
16352   "TARGET_AVX2 || TARGET_XOP"
16354   if (!TARGET_AVX2)
16355     {
16356       operands[2] = force_reg (<MODE>mode, operands[2]);
16357       emit_insn (gen_xop_sha<mode>3 (operands[0], operands[1], operands[2]));
16358       DONE;
16359     }
16362 (define_expand "vashl<mode>3"
16363   [(set (match_operand:VI48_512 0 "register_operand")
16364         (ashift:VI48_512
16365           (match_operand:VI48_512 1 "register_operand")
16366           (match_operand:VI48_512 2 "nonimmediate_operand")))]
16367   "TARGET_AVX512F")
16369 (define_expand "vashl<mode>3"
16370   [(set (match_operand:VI48_256 0 "register_operand")
16371         (ashift:VI48_256
16372           (match_operand:VI48_256 1 "register_operand")
16373           (match_operand:VI48_256 2 "nonimmediate_operand")))]
16374   "TARGET_AVX2")
16376 (define_insn "xop_sha<mode>3"
16377   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
16378         (if_then_else:VI_128
16379          (ge:VI_128
16380           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
16381           (const_int 0))
16382          (ashift:VI_128
16383           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
16384           (match_dup 2))
16385          (ashiftrt:VI_128
16386           (match_dup 1)
16387           (neg:VI_128 (match_dup 2)))))]
16388   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16389   "vpsha<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16390   [(set_attr "type" "sseishft")
16391    (set_attr "prefix_data16" "0")
16392    (set_attr "prefix_extra" "2")
16393    (set_attr "mode" "TI")])
16395 (define_insn "xop_shl<mode>3"
16396   [(set (match_operand:VI_128 0 "register_operand" "=x,x")
16397         (if_then_else:VI_128
16398          (ge:VI_128
16399           (match_operand:VI_128 2 "nonimmediate_operand" "x,m")
16400           (const_int 0))
16401          (ashift:VI_128
16402           (match_operand:VI_128 1 "nonimmediate_operand" "xm,x")
16403           (match_dup 2))
16404          (lshiftrt:VI_128
16405           (match_dup 1)
16406           (neg:VI_128 (match_dup 2)))))]
16407   "TARGET_XOP && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
16408   "vpshl<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16409   [(set_attr "type" "sseishft")
16410    (set_attr "prefix_data16" "0")
16411    (set_attr "prefix_extra" "2")
16412    (set_attr "mode" "TI")])
16414 (define_expand "<shift_insn><mode>3"
16415   [(set (match_operand:VI1_AVX512 0 "register_operand")
16416         (any_shift:VI1_AVX512
16417           (match_operand:VI1_AVX512 1 "register_operand")
16418           (match_operand:SI 2 "nonmemory_operand")))]
16419   "TARGET_SSE2"
16421   if (TARGET_XOP && <MODE>mode == V16QImode)
16422     {
16423       bool negate = false;
16424       rtx (*gen) (rtx, rtx, rtx);
16425       rtx tmp, par;
16426       int i;
16428       if (<CODE> != ASHIFT)
16429         {
16430           if (CONST_INT_P (operands[2]))
16431             operands[2] = GEN_INT (-INTVAL (operands[2]));
16432           else
16433             negate = true;
16434         }
16435       par = gen_rtx_PARALLEL (V16QImode, rtvec_alloc (16));
16436       for (i = 0; i < 16; i++)
16437         XVECEXP (par, 0, i) = operands[2];
16439       tmp = gen_reg_rtx (V16QImode);
16440       emit_insn (gen_vec_initv16qi (tmp, par));
16442       if (negate)
16443         emit_insn (gen_negv16qi2 (tmp, tmp));
16445       gen = (<CODE> == LSHIFTRT ? gen_xop_shlv16qi3 : gen_xop_shav16qi3);
16446       emit_insn (gen (operands[0], operands[1], tmp));
16447     }
16448   else
16449     ix86_expand_vecop_qihi (<CODE>, operands[0], operands[1], operands[2]);
16450   DONE;
16453 (define_expand "ashrv2di3"
16454   [(set (match_operand:V2DI 0 "register_operand")
16455         (ashiftrt:V2DI
16456           (match_operand:V2DI 1 "register_operand")
16457           (match_operand:DI 2 "nonmemory_operand")))]
16458   "TARGET_XOP || TARGET_AVX512VL"
16460   if (!TARGET_AVX512VL)
16461     {
16462       rtx reg = gen_reg_rtx (V2DImode);
16463       rtx par;
16464       bool negate = false;
16465       int i;
16467       if (CONST_INT_P (operands[2]))
16468         operands[2] = GEN_INT (-INTVAL (operands[2]));
16469       else
16470         negate = true;
16472       par = gen_rtx_PARALLEL (V2DImode, rtvec_alloc (2));
16473       for (i = 0; i < 2; i++)
16474         XVECEXP (par, 0, i) = operands[2];
16476       emit_insn (gen_vec_initv2di (reg, par));
16478       if (negate)
16479         emit_insn (gen_negv2di2 (reg, reg));
16481       emit_insn (gen_xop_shav2di3 (operands[0], operands[1], reg));
16482       DONE;
16483     }
16486 ;; XOP FRCZ support
16487 (define_insn "xop_frcz<mode>2"
16488   [(set (match_operand:FMAMODE 0 "register_operand" "=x")
16489         (unspec:FMAMODE
16490          [(match_operand:FMAMODE 1 "nonimmediate_operand" "xm")]
16491          UNSPEC_FRCZ))]
16492   "TARGET_XOP"
16493   "vfrcz<ssemodesuffix>\t{%1, %0|%0, %1}"
16494   [(set_attr "type" "ssecvt1")
16495    (set_attr "mode" "<MODE>")])
16497 (define_expand "xop_vmfrcz<mode>2"
16498   [(set (match_operand:VF_128 0 "register_operand")
16499         (vec_merge:VF_128
16500           (unspec:VF_128
16501            [(match_operand:VF_128 1 "nonimmediate_operand")]
16502            UNSPEC_FRCZ)
16503           (match_dup 2)
16504           (const_int 1)))]
16505   "TARGET_XOP"
16506   "operands[2] = CONST0_RTX (<MODE>mode);")
16508 (define_insn "*xop_vmfrcz<mode>2"
16509   [(set (match_operand:VF_128 0 "register_operand" "=x")
16510         (vec_merge:VF_128
16511           (unspec:VF_128
16512            [(match_operand:VF_128 1 "nonimmediate_operand" "xm")]
16513            UNSPEC_FRCZ)
16514           (match_operand:VF_128 2 "const0_operand")
16515           (const_int 1)))]
16516   "TARGET_XOP"
16517   "vfrcz<ssescalarmodesuffix>\t{%1, %0|%0, %<iptr>1}"
16518   [(set_attr "type" "ssecvt1")
16519    (set_attr "mode" "<MODE>")])
16521 (define_insn "xop_maskcmp<mode>3"
16522   [(set (match_operand:VI_128 0 "register_operand" "=x")
16523         (match_operator:VI_128 1 "ix86_comparison_int_operator"
16524          [(match_operand:VI_128 2 "register_operand" "x")
16525           (match_operand:VI_128 3 "nonimmediate_operand" "xm")]))]
16526   "TARGET_XOP"
16527   "vpcom%Y1<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
16528   [(set_attr "type" "sse4arg")
16529    (set_attr "prefix_data16" "0")
16530    (set_attr "prefix_rep" "0")
16531    (set_attr "prefix_extra" "2")
16532    (set_attr "length_immediate" "1")
16533    (set_attr "mode" "TI")])
16535 (define_insn "xop_maskcmp_uns<mode>3"
16536   [(set (match_operand:VI_128 0 "register_operand" "=x")
16537         (match_operator:VI_128 1 "ix86_comparison_uns_operator"
16538          [(match_operand:VI_128 2 "register_operand" "x")
16539           (match_operand:VI_128 3 "nonimmediate_operand" "xm")]))]
16540   "TARGET_XOP"
16541   "vpcom%Y1u<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
16542   [(set_attr "type" "ssecmp")
16543    (set_attr "prefix_data16" "0")
16544    (set_attr "prefix_rep" "0")
16545    (set_attr "prefix_extra" "2")
16546    (set_attr "length_immediate" "1")
16547    (set_attr "mode" "TI")])
16549 ;; Version of pcom*u* that is called from the intrinsics that allows pcomequ*
16550 ;; and pcomneu* not to be converted to the signed ones in case somebody needs
16551 ;; the exact instruction generated for the intrinsic.
16552 (define_insn "xop_maskcmp_uns2<mode>3"
16553   [(set (match_operand:VI_128 0 "register_operand" "=x")
16554         (unspec:VI_128
16555          [(match_operator:VI_128 1 "ix86_comparison_uns_operator"
16556           [(match_operand:VI_128 2 "register_operand" "x")
16557            (match_operand:VI_128 3 "nonimmediate_operand" "xm")])]
16558          UNSPEC_XOP_UNSIGNED_CMP))]
16559   "TARGET_XOP"
16560   "vpcom%Y1u<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}"
16561   [(set_attr "type" "ssecmp")
16562    (set_attr "prefix_data16" "0")
16563    (set_attr "prefix_extra" "2")
16564    (set_attr "length_immediate" "1")
16565    (set_attr "mode" "TI")])
16567 ;; Pcomtrue and pcomfalse support.  These are useless instructions, but are
16568 ;; being added here to be complete.
16569 (define_insn "xop_pcom_tf<mode>3"
16570   [(set (match_operand:VI_128 0 "register_operand" "=x")
16571         (unspec:VI_128
16572           [(match_operand:VI_128 1 "register_operand" "x")
16573            (match_operand:VI_128 2 "nonimmediate_operand" "xm")
16574            (match_operand:SI 3 "const_int_operand" "n")]
16575           UNSPEC_XOP_TRUEFALSE))]
16576   "TARGET_XOP"
16578   return ((INTVAL (operands[3]) != 0)
16579           ? "vpcomtrue<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
16580           : "vpcomfalse<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}");
16582   [(set_attr "type" "ssecmp")
16583    (set_attr "prefix_data16" "0")
16584    (set_attr "prefix_extra" "2")
16585    (set_attr "length_immediate" "1")
16586    (set_attr "mode" "TI")])
16588 (define_insn "xop_vpermil2<mode>3"
16589   [(set (match_operand:VF_128_256 0 "register_operand" "=x")
16590         (unspec:VF_128_256
16591           [(match_operand:VF_128_256 1 "register_operand" "x")
16592            (match_operand:VF_128_256 2 "nonimmediate_operand" "%x")
16593            (match_operand:<sseintvecmode> 3 "nonimmediate_operand" "xm")
16594            (match_operand:SI 4 "const_0_to_3_operand" "n")]
16595           UNSPEC_VPERMIL2))]
16596   "TARGET_XOP"
16597   "vpermil2<ssemodesuffix>\t{%4, %3, %2, %1, %0|%0, %1, %2, %3, %4}"
16598   [(set_attr "type" "sse4arg")
16599    (set_attr "length_immediate" "1")
16600    (set_attr "mode" "<MODE>")])
16602 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16604 (define_insn "aesenc"
16605   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
16606         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
16607                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
16608                       UNSPEC_AESENC))]
16609   "TARGET_AES"
16610   "@
16611    aesenc\t{%2, %0|%0, %2}
16612    vaesenc\t{%2, %1, %0|%0, %1, %2}"
16613   [(set_attr "isa" "noavx,avx")
16614    (set_attr "type" "sselog1")
16615    (set_attr "prefix_extra" "1")
16616    (set_attr "prefix" "orig,vex")
16617    (set_attr "btver2_decode" "double,double")
16618    (set_attr "mode" "TI")])
16620 (define_insn "aesenclast"
16621   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
16622         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
16623                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
16624                       UNSPEC_AESENCLAST))]
16625   "TARGET_AES"
16626   "@
16627    aesenclast\t{%2, %0|%0, %2}
16628    vaesenclast\t{%2, %1, %0|%0, %1, %2}"
16629   [(set_attr "isa" "noavx,avx")
16630    (set_attr "type" "sselog1")
16631    (set_attr "prefix_extra" "1")
16632    (set_attr "prefix" "orig,vex")
16633    (set_attr "btver2_decode" "double,double") 
16634    (set_attr "mode" "TI")])
16636 (define_insn "aesdec"
16637   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
16638         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
16639                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
16640                       UNSPEC_AESDEC))]
16641   "TARGET_AES"
16642   "@
16643    aesdec\t{%2, %0|%0, %2}
16644    vaesdec\t{%2, %1, %0|%0, %1, %2}"
16645   [(set_attr "isa" "noavx,avx")
16646    (set_attr "type" "sselog1")
16647    (set_attr "prefix_extra" "1")
16648    (set_attr "prefix" "orig,vex")
16649    (set_attr "btver2_decode" "double,double") 
16650    (set_attr "mode" "TI")])
16652 (define_insn "aesdeclast"
16653   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
16654         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
16655                        (match_operand:V2DI 2 "vector_operand" "xBm,xm")]
16656                       UNSPEC_AESDECLAST))]
16657   "TARGET_AES"
16658   "@
16659    aesdeclast\t{%2, %0|%0, %2}
16660    vaesdeclast\t{%2, %1, %0|%0, %1, %2}"
16661   [(set_attr "isa" "noavx,avx")
16662    (set_attr "type" "sselog1")
16663    (set_attr "prefix_extra" "1")
16664    (set_attr "prefix" "orig,vex")
16665    (set_attr "btver2_decode" "double,double")
16666    (set_attr "mode" "TI")])
16668 (define_insn "aesimc"
16669   [(set (match_operand:V2DI 0 "register_operand" "=x")
16670         (unspec:V2DI [(match_operand:V2DI 1 "vector_operand" "xBm")]
16671                       UNSPEC_AESIMC))]
16672   "TARGET_AES"
16673   "%vaesimc\t{%1, %0|%0, %1}"
16674   [(set_attr "type" "sselog1")
16675    (set_attr "prefix_extra" "1")
16676    (set_attr "prefix" "maybe_vex")
16677    (set_attr "mode" "TI")])
16679 (define_insn "aeskeygenassist"
16680   [(set (match_operand:V2DI 0 "register_operand" "=x")
16681         (unspec:V2DI [(match_operand:V2DI 1 "vector_operand" "xBm")
16682                       (match_operand:SI 2 "const_0_to_255_operand" "n")]
16683                      UNSPEC_AESKEYGENASSIST))]
16684   "TARGET_AES"
16685   "%vaeskeygenassist\t{%2, %1, %0|%0, %1, %2}"
16686   [(set_attr "type" "sselog1")
16687    (set_attr "prefix_extra" "1")
16688    (set_attr "length_immediate" "1")
16689    (set_attr "prefix" "maybe_vex")
16690    (set_attr "mode" "TI")])
16692 (define_insn "pclmulqdq"
16693   [(set (match_operand:V2DI 0 "register_operand" "=x,x")
16694         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0,x")
16695                       (match_operand:V2DI 2 "vector_operand" "xBm,xm")
16696                       (match_operand:SI 3 "const_0_to_255_operand" "n,n")]
16697                      UNSPEC_PCLMUL))]
16698   "TARGET_PCLMUL"
16699   "@
16700    pclmulqdq\t{%3, %2, %0|%0, %2, %3}
16701    vpclmulqdq\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16702   [(set_attr "isa" "noavx,avx")
16703    (set_attr "type" "sselog1")
16704    (set_attr "prefix_extra" "1")
16705    (set_attr "length_immediate" "1")
16706    (set_attr "prefix" "orig,vex")
16707    (set_attr "mode" "TI")])
16709 (define_expand "avx_vzeroall"
16710   [(match_par_dup 0 [(const_int 0)])]
16711   "TARGET_AVX"
16713   int nregs = TARGET_64BIT ? 16 : 8;
16714   int regno;
16716   operands[0] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs + 1));
16718   XVECEXP (operands[0], 0, 0)
16719     = gen_rtx_UNSPEC_VOLATILE (VOIDmode, gen_rtvec (1, const0_rtx),
16720                                UNSPECV_VZEROALL);
16722   for (regno = 0; regno < nregs; regno++)
16723     XVECEXP (operands[0], 0, regno + 1)
16724       = gen_rtx_SET (gen_rtx_REG (V8SImode, SSE_REGNO (regno)),
16725                      CONST0_RTX (V8SImode));
16728 (define_insn "*avx_vzeroall"
16729   [(match_parallel 0 "vzeroall_operation"
16730     [(unspec_volatile [(const_int 0)] UNSPECV_VZEROALL)])]
16731   "TARGET_AVX"
16732   "vzeroall"
16733   [(set_attr "type" "sse")
16734    (set_attr "modrm" "0")
16735    (set_attr "memory" "none")
16736    (set_attr "prefix" "vex")
16737    (set_attr "btver2_decode" "vector")
16738    (set_attr "mode" "OI")])
16740 ;; Clear the upper 128bits of AVX registers, equivalent to a NOP
16741 ;; if the upper 128bits are unused.
16742 (define_insn "avx_vzeroupper"
16743   [(unspec_volatile [(const_int 0)] UNSPECV_VZEROUPPER)]
16744   "TARGET_AVX"
16745   "vzeroupper"
16746   [(set_attr "type" "sse")
16747    (set_attr "modrm" "0")
16748    (set_attr "memory" "none")
16749    (set_attr "prefix" "vex")
16750    (set_attr "btver2_decode" "vector")
16751    (set_attr "mode" "OI")])
16753 (define_mode_attr pbroadcast_evex_isa
16754   [(V64QI "avx512bw") (V32QI "avx512bw") (V16QI "avx512bw")
16755    (V32HI "avx512bw") (V16HI "avx512bw") (V8HI "avx512bw")
16756    (V16SI "avx512f") (V8SI "avx512f") (V4SI "avx512f")
16757    (V8DI "avx512f") (V4DI "avx512f") (V2DI "avx512f")])
16759 (define_insn "avx2_pbroadcast<mode>"
16760   [(set (match_operand:VI 0 "register_operand" "=x,v")
16761         (vec_duplicate:VI
16762           (vec_select:<ssescalarmode>
16763             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "xm,vm")
16764             (parallel [(const_int 0)]))))]
16765   "TARGET_AVX2"
16766   "vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}"
16767   [(set_attr "isa" "*,<pbroadcast_evex_isa>")
16768    (set_attr "type" "ssemov")
16769    (set_attr "prefix_extra" "1")
16770    (set_attr "prefix" "vex,evex")
16771    (set_attr "mode" "<sseinsnmode>")])
16773 (define_insn "avx2_pbroadcast<mode>_1"
16774   [(set (match_operand:VI_256 0 "register_operand" "=x,x,v,v")
16775         (vec_duplicate:VI_256
16776           (vec_select:<ssescalarmode>
16777             (match_operand:VI_256 1 "nonimmediate_operand" "m,x,m,v")
16778             (parallel [(const_int 0)]))))]
16779   "TARGET_AVX2"
16780   "@
16781    vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}
16782    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}
16783    vpbroadcast<ssemodesuffix>\t{%1, %0|%0, %<iptr>1}
16784    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}"
16785   [(set_attr "isa" "*,*,<pbroadcast_evex_isa>,<pbroadcast_evex_isa>")
16786    (set_attr "type" "ssemov")
16787    (set_attr "prefix_extra" "1")
16788    (set_attr "prefix" "vex")
16789    (set_attr "mode" "<sseinsnmode>")])
16791 (define_insn "<avx2_avx512>_permvar<mode><mask_name>"
16792   [(set (match_operand:VI48F_256_512 0 "register_operand" "=v")
16793         (unspec:VI48F_256_512
16794           [(match_operand:VI48F_256_512 1 "nonimmediate_operand" "vm")
16795            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
16796           UNSPEC_VPERMVAR))]
16797   "TARGET_AVX2 && <mask_mode512bit_condition>"
16798   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
16799   [(set_attr "type" "sselog")
16800    (set_attr "prefix" "<mask_prefix2>")
16801    (set_attr "mode" "<sseinsnmode>")])
16803 (define_insn "<avx512>_permvar<mode><mask_name>"
16804   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
16805         (unspec:VI1_AVX512VL
16806           [(match_operand:VI1_AVX512VL 1 "nonimmediate_operand" "vm")
16807            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
16808           UNSPEC_VPERMVAR))]
16809   "TARGET_AVX512VBMI && <mask_mode512bit_condition>"
16810   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
16811   [(set_attr "type" "sselog")
16812    (set_attr "prefix" "<mask_prefix2>")
16813    (set_attr "mode" "<sseinsnmode>")])
16815 (define_insn "<avx512>_permvar<mode><mask_name>"
16816   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
16817         (unspec:VI2_AVX512VL
16818           [(match_operand:VI2_AVX512VL 1 "nonimmediate_operand" "vm")
16819            (match_operand:<sseintvecmode> 2 "register_operand" "v")]
16820           UNSPEC_VPERMVAR))]
16821   "TARGET_AVX512BW && <mask_mode512bit_condition>"
16822   "vperm<ssemodesuffix>\t{%1, %2, %0<mask_operand3>|%0<mask_operand3>, %2, %1}"
16823   [(set_attr "type" "sselog")
16824    (set_attr "prefix" "<mask_prefix2>")
16825    (set_attr "mode" "<sseinsnmode>")])
16827 (define_expand "<avx2_avx512>_perm<mode>"
16828   [(match_operand:VI8F_256_512 0 "register_operand")
16829    (match_operand:VI8F_256_512 1 "nonimmediate_operand")
16830    (match_operand:SI 2 "const_0_to_255_operand")]
16831   "TARGET_AVX2"
16833   int mask = INTVAL (operands[2]);
16834   emit_insn (gen_<avx2_avx512>_perm<mode>_1 (operands[0], operands[1],
16835                                               GEN_INT ((mask >> 0) & 3),
16836                                               GEN_INT ((mask >> 2) & 3),
16837                                               GEN_INT ((mask >> 4) & 3),
16838                                               GEN_INT ((mask >> 6) & 3)));
16839   DONE;
16842 (define_expand "<avx512>_perm<mode>_mask"
16843   [(match_operand:VI8F_256_512 0 "register_operand")
16844    (match_operand:VI8F_256_512 1 "nonimmediate_operand")
16845    (match_operand:SI 2 "const_0_to_255_operand")
16846    (match_operand:VI8F_256_512 3 "vector_move_operand")
16847    (match_operand:<avx512fmaskmode> 4 "register_operand")]
16848   "TARGET_AVX512F"
16850   int mask = INTVAL (operands[2]);
16851   emit_insn (gen_<avx2_avx512>_perm<mode>_1_mask (operands[0], operands[1],
16852                                                    GEN_INT ((mask >> 0) & 3),
16853                                                    GEN_INT ((mask >> 2) & 3),
16854                                                    GEN_INT ((mask >> 4) & 3),
16855                                                    GEN_INT ((mask >> 6) & 3),
16856                                                    operands[3], operands[4]));
16857   DONE;
16860 (define_insn "<avx2_avx512>_perm<mode>_1<mask_name>"
16861   [(set (match_operand:VI8F_256_512 0 "register_operand" "=v")
16862         (vec_select:VI8F_256_512
16863           (match_operand:VI8F_256_512 1 "nonimmediate_operand" "vm")
16864           (parallel [(match_operand 2 "const_0_to_3_operand")
16865                      (match_operand 3 "const_0_to_3_operand")
16866                      (match_operand 4 "const_0_to_3_operand")
16867                      (match_operand 5 "const_0_to_3_operand")])))]
16868   "TARGET_AVX2 && <mask_mode512bit_condition>"
16870   int mask = 0;
16871   mask |= INTVAL (operands[2]) << 0;
16872   mask |= INTVAL (operands[3]) << 2;
16873   mask |= INTVAL (operands[4]) << 4;
16874   mask |= INTVAL (operands[5]) << 6;
16875   operands[2] = GEN_INT (mask);
16876   return "vperm<ssemodesuffix>\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
16878   [(set_attr "type" "sselog")
16879    (set_attr "prefix" "<mask_prefix2>")
16880    (set_attr "mode" "<sseinsnmode>")])
16882 (define_insn "avx2_permv2ti"
16883   [(set (match_operand:V4DI 0 "register_operand" "=x")
16884         (unspec:V4DI
16885           [(match_operand:V4DI 1 "register_operand" "x")
16886            (match_operand:V4DI 2 "nonimmediate_operand" "xm")
16887            (match_operand:SI 3 "const_0_to_255_operand" "n")]
16888           UNSPEC_VPERMTI))]
16889   "TARGET_AVX2"
16890   "vperm2i128\t{%3, %2, %1, %0|%0, %1, %2, %3}"
16891   [(set_attr "type" "sselog")
16892    (set_attr "prefix" "vex")
16893    (set_attr "mode" "OI")])
16895 (define_insn "avx2_vec_dupv4df"
16896   [(set (match_operand:V4DF 0 "register_operand" "=v")
16897         (vec_duplicate:V4DF
16898           (vec_select:DF
16899             (match_operand:V2DF 1 "register_operand" "v")
16900             (parallel [(const_int 0)]))))]
16901   "TARGET_AVX2"
16902   "vbroadcastsd\t{%1, %0|%0, %1}"
16903   [(set_attr "type" "sselog1")
16904    (set_attr "prefix" "maybe_evex")
16905    (set_attr "mode" "V4DF")])
16907 (define_insn "<avx512>_vec_dup<mode>_1"
16908   [(set (match_operand:VI_AVX512BW 0 "register_operand" "=v,v")
16909         (vec_duplicate:VI_AVX512BW
16910           (vec_select:VI_AVX512BW
16911             (match_operand:VI_AVX512BW 1 "nonimmediate_operand" "v,m")
16912             (parallel [(const_int 0)]))))]
16913   "TARGET_AVX512F"
16914   "@
16915    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %x1}
16916    vpbroadcast<ssemodesuffix>\t{%x1, %0|%0, %<iptr>1}"
16917   [(set_attr "type" "ssemov")
16918    (set_attr "prefix" "evex")
16919    (set_attr "mode" "<sseinsnmode>")])
16921 (define_insn "<avx512>_vec_dup<mode><mask_name>"
16922   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v")
16923         (vec_duplicate:V48_AVX512VL
16924           (vec_select:<ssescalarmode>
16925             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
16926             (parallel [(const_int 0)]))))]
16927   "TARGET_AVX512F"
16929   /*  There is no DF broadcast (in AVX-512*) to 128b register.
16930       Mimic it with integer variant.  */
16931   if (<MODE>mode == V2DFmode)
16932     return "vpbroadcastq\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}";
16934   if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 4)
16935     return "v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %k1}";
16936   else
16937     return "v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}";
16939   [(set_attr "type" "ssemov")
16940    (set_attr "prefix" "evex")
16941    (set_attr "mode" "<sseinsnmode>")])
16943 (define_insn "<avx512>_vec_dup<mode><mask_name>"
16944   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v")
16945         (vec_duplicate:VI12_AVX512VL
16946           (vec_select:<ssescalarmode>
16947             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
16948             (parallel [(const_int 0)]))))]
16949   "TARGET_AVX512BW"
16950   "vpbroadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
16951   [(set_attr "type" "ssemov")
16952    (set_attr "prefix" "evex")
16953    (set_attr "mode" "<sseinsnmode>")])
16955 (define_insn "<mask_codefor>avx512f_broadcast<mode><mask_name>"
16956   [(set (match_operand:V16FI 0 "register_operand" "=v,v")
16957         (vec_duplicate:V16FI
16958           (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "v,m")))]
16959   "TARGET_AVX512F"
16960   "@
16961    vshuf<shuffletype>32x4\t{$0x0, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x0}
16962    vbroadcast<shuffletype>32x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
16963   [(set_attr "type" "ssemov")
16964    (set_attr "prefix" "evex")
16965    (set_attr "mode" "<sseinsnmode>")])
16967 (define_insn "<mask_codefor>avx512f_broadcast<mode><mask_name>"
16968   [(set (match_operand:V8FI 0 "register_operand" "=v,v")
16969         (vec_duplicate:V8FI
16970           (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "v,m")))]
16971   "TARGET_AVX512F"
16972   "@
16973    vshuf<shuffletype>64x2\t{$0x44, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x44}
16974    vbroadcast<shuffletype>64x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
16975   [(set_attr "type" "ssemov")
16976    (set_attr "prefix" "evex")
16977    (set_attr "mode" "<sseinsnmode>")])
16979 (define_insn "<mask_codefor><avx512>_vec_dup_gpr<mode><mask_name>"
16980   [(set (match_operand:VI12_AVX512VL 0 "register_operand" "=v,v")
16981         (vec_duplicate:VI12_AVX512VL
16982           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "vm,r")))]
16983   "TARGET_AVX512BW"
16984   "@
16985    vpbroadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}
16986    vpbroadcast<bcstscalarsuff>\t{%k1, %0<mask_operand2>|%0<mask_operand2>, %k1}"
16987   [(set_attr "type" "ssemov")
16988    (set_attr "prefix" "evex")
16989    (set_attr "mode" "<sseinsnmode>")])
16991 (define_insn "<mask_codefor><avx512>_vec_dup_gpr<mode><mask_name>"
16992   [(set (match_operand:V48_AVX512VL 0 "register_operand" "=v,v")
16993         (vec_duplicate:V48_AVX512VL
16994           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "vm,r")))]
16995   "TARGET_AVX512F"
16996   "v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
16997   [(set_attr "type" "ssemov")
16998    (set_attr "prefix" "evex")
16999    (set_attr "mode" "<sseinsnmode>")
17000    (set (attr "enabled")
17001      (if_then_else (eq_attr "alternative" "1")
17002         (symbol_ref "GET_MODE_CLASS (<ssescalarmode>mode) == MODE_INT
17003                      && (<ssescalarmode>mode != DImode || TARGET_64BIT)")
17004         (const_int 1)))])
17006 (define_insn "vec_dupv4sf"
17007   [(set (match_operand:V4SF 0 "register_operand" "=v,v,x")
17008         (vec_duplicate:V4SF
17009           (match_operand:SF 1 "nonimmediate_operand" "Yv,m,0")))]
17010   "TARGET_SSE"
17011   "@
17012    vshufps\t{$0, %1, %1, %0|%0, %1, %1, 0}
17013    vbroadcastss\t{%1, %0|%0, %1}
17014    shufps\t{$0, %0, %0|%0, %0, 0}"
17015   [(set_attr "isa" "avx,avx,noavx")
17016    (set_attr "type" "sseshuf1,ssemov,sseshuf1")
17017    (set_attr "length_immediate" "1,0,1")
17018    (set_attr "prefix_extra" "0,1,*")
17019    (set_attr "prefix" "maybe_evex,maybe_evex,orig")
17020    (set_attr "mode" "V4SF")])
17022 (define_insn "*vec_dupv4si"
17023   [(set (match_operand:V4SI 0 "register_operand"     "=v,v,x")
17024         (vec_duplicate:V4SI
17025           (match_operand:SI 1 "nonimmediate_operand" "Yv,m,0")))]
17026   "TARGET_SSE"
17027   "@
17028    %vpshufd\t{$0, %1, %0|%0, %1, 0}
17029    vbroadcastss\t{%1, %0|%0, %1}
17030    shufps\t{$0, %0, %0|%0, %0, 0}"
17031   [(set_attr "isa" "sse2,avx,noavx")
17032    (set_attr "type" "sselog1,ssemov,sselog1")
17033    (set_attr "length_immediate" "1,0,1")
17034    (set_attr "prefix_extra" "0,1,*")
17035    (set_attr "prefix" "maybe_vex,maybe_evex,orig")
17036    (set_attr "mode" "TI,V4SF,V4SF")])
17038 (define_insn "*vec_dupv2di"
17039   [(set (match_operand:V2DI 0 "register_operand"     "=x,v,v,x")
17040         (vec_duplicate:V2DI
17041           (match_operand:DI 1 "nonimmediate_operand" " 0,Yv,m,0")))]
17042   "TARGET_SSE"
17043   "@
17044    punpcklqdq\t%0, %0
17045    vpunpcklqdq\t{%d1, %0|%0, %d1}
17046    %vmovddup\t{%1, %0|%0, %1}
17047    movlhps\t%0, %0"
17048   [(set_attr "isa" "sse2_noavx,avx,sse3,noavx")
17049    (set_attr "type" "sselog1,sselog1,sselog1,ssemov")
17050    (set_attr "prefix" "orig,maybe_evex,maybe_vex,orig")
17051    (set_attr "mode" "TI,TI,DF,V4SF")])
17053 (define_insn "avx2_vbroadcasti128_<mode>"
17054   [(set (match_operand:VI_256 0 "register_operand" "=x,v,v")
17055         (vec_concat:VI_256
17056           (match_operand:<ssehalfvecmode> 1 "memory_operand" "m,m,m")
17057           (match_dup 1)))]
17058   "TARGET_AVX2"
17059   "@
17060    vbroadcasti128\t{%1, %0|%0, %1}
17061    vbroadcast<i128vldq>\t{%1, %0|%0, %1}
17062    vbroadcast<shuffletype>32x4\t{%1, %0|%0, %1}"
17063   [(set_attr "isa" "*,avx512dq,avx512vl")
17064    (set_attr "type" "ssemov")
17065    (set_attr "prefix_extra" "1")
17066    (set_attr "prefix" "vex,evex,evex")
17067    (set_attr "mode" "OI")])
17069 ;; Modes handled by AVX vec_dup patterns.
17070 (define_mode_iterator AVX_VEC_DUP_MODE
17071   [V8SI V8SF V4DI V4DF])
17072 ;; Modes handled by AVX2 vec_dup patterns.
17073 (define_mode_iterator AVX2_VEC_DUP_MODE
17074   [V32QI V16QI V16HI V8HI V8SI V4SI])
17076 (define_insn "*vec_dup<mode>"
17077   [(set (match_operand:AVX2_VEC_DUP_MODE 0 "register_operand" "=x,x,Yi")
17078         (vec_duplicate:AVX2_VEC_DUP_MODE
17079           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,x,$r")))]
17080   "TARGET_AVX2"
17081   "@
17082    v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0|%0, %1}
17083    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}
17084    #"
17085   [(set_attr "isa" "*,*,noavx512vl")
17086    (set_attr "type" "ssemov")
17087    (set_attr "prefix_extra" "1")
17088    (set_attr "prefix" "maybe_evex")
17089    (set_attr "mode" "<sseinsnmode>")])
17091 (define_insn "vec_dup<mode>"
17092   [(set (match_operand:AVX_VEC_DUP_MODE 0 "register_operand" "=x,x,x,v,x")
17093         (vec_duplicate:AVX_VEC_DUP_MODE
17094           (match_operand:<ssescalarmode> 1 "nonimmediate_operand" "m,m,x,v,?x")))]
17095   "TARGET_AVX"
17096   "@
17097    v<sseintprefix>broadcast<bcstscalarsuff>\t{%1, %0|%0, %1}
17098    vbroadcast<ssescalarmodesuffix>\t{%1, %0|%0, %1}
17099    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %0|%0, %x1}
17100    v<sseintprefix>broadcast<bcstscalarsuff>\t{%x1, %g0|%g0, %x1}
17101    #"
17102   [(set_attr "type" "ssemov")
17103    (set_attr "prefix_extra" "1")
17104    (set_attr "prefix" "maybe_evex")
17105    (set_attr "isa" "avx2,noavx2,avx2,avx512f,noavx2")
17106    (set_attr "mode" "<sseinsnmode>,V8SF,<sseinsnmode>,<sseinsnmode>,V8SF")])
17108 (define_split
17109   [(set (match_operand:AVX2_VEC_DUP_MODE 0 "register_operand")
17110         (vec_duplicate:AVX2_VEC_DUP_MODE
17111           (match_operand:<ssescalarmode> 1 "register_operand")))]
17112   "TARGET_AVX2
17113    /* Disable this splitter if avx512vl_vec_dup_gprv*[qhs]i insn is
17114       available, because then we can broadcast from GPRs directly.
17115       For V*[QH]I modes it requires both -mavx512vl and -mavx512bw,
17116       for V*SI mode it requires just -mavx512vl.  */
17117    && !(TARGET_AVX512VL
17118         && (TARGET_AVX512BW || <ssescalarmode>mode == SImode))
17119    && reload_completed && GENERAL_REG_P (operands[1])"
17120   [(const_int 0)]
17122   emit_insn (gen_vec_setv4si_0 (gen_lowpart (V4SImode, operands[0]),
17123                                 CONST0_RTX (V4SImode),
17124                                 gen_lowpart (SImode, operands[1])));
17125   emit_insn (gen_avx2_pbroadcast<mode> (operands[0],
17126                                         gen_lowpart (<ssexmmmode>mode,
17127                                                      operands[0])));
17128   DONE;
17131 (define_split
17132   [(set (match_operand:AVX_VEC_DUP_MODE 0 "register_operand")
17133         (vec_duplicate:AVX_VEC_DUP_MODE
17134           (match_operand:<ssescalarmode> 1 "register_operand")))]
17135   "TARGET_AVX && !TARGET_AVX2 && reload_completed"
17136   [(set (match_dup 2)
17137         (vec_duplicate:<ssehalfvecmode> (match_dup 1)))
17138    (set (match_dup 0)
17139         (vec_concat:AVX_VEC_DUP_MODE (match_dup 2) (match_dup 2)))]
17140   "operands[2] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);")
17142 (define_insn "avx_vbroadcastf128_<mode>"
17143   [(set (match_operand:V_256 0 "register_operand" "=x,x,x,v,v,v,v")
17144         (vec_concat:V_256
17145           (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "m,0,?x,m,0,m,0")
17146           (match_dup 1)))]
17147   "TARGET_AVX"
17148   "@
17149    vbroadcast<i128>\t{%1, %0|%0, %1}
17150    vinsert<i128>\t{$1, %1, %0, %0|%0, %0, %1, 1}
17151    vperm2<i128>\t{$0, %t1, %t1, %0|%0, %t1, %t1, 0}
17152    vbroadcast<i128vldq>\t{%1, %0|%0, %1}
17153    vinsert<i128vldq>\t{$1, %1, %0, %0|%0, %0, %1, 1}
17154    vbroadcast<shuffletype>32x4\t{%1, %0|%0, %1}
17155    vinsert<shuffletype>32x4\t{$1, %1, %0, %0|%0, %0, %1, 1}"
17156   [(set_attr "isa" "*,*,*,avx512dq,avx512dq,avx512vl,avx512vl")
17157    (set_attr "type" "ssemov,sselog1,sselog1,ssemov,sselog1,ssemov,sselog1")
17158    (set_attr "prefix_extra" "1")
17159    (set_attr "length_immediate" "0,1,1,0,1,0,1")
17160    (set_attr "prefix" "vex,vex,vex,evex,evex,evex,evex")
17161    (set_attr "mode" "<sseinsnmode>")])
17163 ;; For broadcast[i|f]32x2.  Yes there is no v4sf version, only v4si.
17164 (define_mode_iterator VI4F_BRCST32x2
17165   [V16SI (V8SI "TARGET_AVX512VL") (V4SI "TARGET_AVX512VL")
17166    V16SF (V8SF "TARGET_AVX512VL")])
17168 (define_mode_attr 64x2mode
17169   [(V8DF "V2DF") (V8DI "V2DI") (V4DI "V2DI") (V4DF "V2DF")])
17171 (define_mode_attr 32x2mode
17172   [(V16SF "V2SF") (V16SI "V2SI") (V8SI "V2SI")
17173   (V8SF "V2SF") (V4SI "V2SI")])
17175 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>"
17176   [(set (match_operand:VI4F_BRCST32x2 0 "register_operand" "=v")
17177         (vec_duplicate:VI4F_BRCST32x2
17178           (vec_select:<32x2mode>
17179             (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "vm")
17180             (parallel [(const_int 0) (const_int 1)]))))]
17181   "TARGET_AVX512DQ"
17182   "vbroadcast<shuffletype>32x2\t{%1, %0<mask_operand2>|%0<mask_operand2>, %q1}"
17183   [(set_attr "type" "ssemov")
17184    (set_attr "prefix_extra" "1")
17185    (set_attr "prefix" "evex")
17186    (set_attr "mode" "<sseinsnmode>")])
17188 (define_insn "<mask_codefor>avx512vl_broadcast<mode><mask_name>_1"
17189   [(set (match_operand:VI4F_256 0 "register_operand" "=v,v")
17190         (vec_duplicate:VI4F_256
17191          (match_operand:<ssexmmmode> 1 "nonimmediate_operand" "v,m")))]
17192   "TARGET_AVX512VL"
17193   "@
17194    vshuf<shuffletype>32x4\t{$0x0, %t1, %t1, %0<mask_operand2>|%0<mask_operand2>, %t1, %t1, 0x0}
17195    vbroadcast<shuffletype>32x4\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17196   [(set_attr "type" "ssemov")
17197    (set_attr "prefix_extra" "1")
17198    (set_attr "prefix" "evex")
17199    (set_attr "mode" "<sseinsnmode>")])
17201 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>_1"
17202   [(set (match_operand:V16FI 0 "register_operand" "=v,v")
17203        (vec_duplicate:V16FI
17204          (match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "v,m")))]
17205   "TARGET_AVX512DQ"
17206   "@
17207    vshuf<shuffletype>32x4\t{$0x44, %g1, %g1, %0<mask_operand2>|%0<mask_operand2>, %g1, %g1, 0x44}
17208    vbroadcast<shuffletype>32x8\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17209   [(set_attr "type" "ssemov")
17210    (set_attr "prefix_extra" "1")
17211    (set_attr "prefix" "evex")
17212    (set_attr "mode" "<sseinsnmode>")])
17214 ;; For broadcast[i|f]64x2
17215 (define_mode_iterator VI8F_BRCST64x2
17216   [V8DI V8DF (V4DI "TARGET_AVX512VL") (V4DF "TARGET_AVX512VL")])
17218 (define_insn "<mask_codefor>avx512dq_broadcast<mode><mask_name>_1"
17219   [(set (match_operand:VI8F_BRCST64x2 0 "register_operand" "=v,v")
17220        (vec_duplicate:VI8F_BRCST64x2
17221          (match_operand:<64x2mode> 1 "nonimmediate_operand" "v,m")))]
17222   "TARGET_AVX512DQ"
17223   "@
17224    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}
17225    vbroadcast<shuffletype>64x2\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
17226   [(set_attr "type" "ssemov")
17227    (set_attr "prefix_extra" "1")
17228    (set_attr "prefix" "evex")
17229    (set_attr "mode" "<sseinsnmode>")])
17231 (define_insn "avx512cd_maskb_vec_dup<mode>"
17232   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
17233         (vec_duplicate:VI8_AVX512VL
17234           (zero_extend:DI
17235             (match_operand:QI 1 "register_operand" "Yk"))))]
17236   "TARGET_AVX512CD"
17237   "vpbroadcastmb2q\t{%1, %0|%0, %1}"
17238   [(set_attr "type" "mskmov")
17239    (set_attr "prefix" "evex")
17240    (set_attr "mode" "XI")])
17242 (define_insn "avx512cd_maskw_vec_dup<mode>"
17243   [(set (match_operand:VI4_AVX512VL 0 "register_operand" "=v")
17244         (vec_duplicate:VI4_AVX512VL
17245           (zero_extend:SI
17246             (match_operand:HI 1 "register_operand" "Yk"))))]
17247   "TARGET_AVX512CD"
17248   "vpbroadcastmw2d\t{%1, %0|%0, %1}"
17249   [(set_attr "type" "mskmov")
17250    (set_attr "prefix" "evex")
17251    (set_attr "mode" "XI")])
17253 ;; Recognize broadcast as a vec_select as produced by builtin_vec_perm.
17254 ;; If it so happens that the input is in memory, use vbroadcast.
17255 ;; Otherwise use vpermilp (and in the case of 256-bit modes, vperm2f128).
17256 (define_insn "*avx_vperm_broadcast_v4sf"
17257   [(set (match_operand:V4SF 0 "register_operand" "=x,x,x")
17258         (vec_select:V4SF
17259           (match_operand:V4SF 1 "nonimmediate_operand" "m,o,x")
17260           (match_parallel 2 "avx_vbroadcast_operand"
17261             [(match_operand 3 "const_int_operand" "C,n,n")])))]
17262   "TARGET_AVX"
17264   int elt = INTVAL (operands[3]);
17265   switch (which_alternative)
17266     {
17267     case 0:
17268     case 1:
17269       operands[1] = adjust_address_nv (operands[1], SFmode, elt * 4);
17270       return "vbroadcastss\t{%1, %0|%0, %k1}";
17271     case 2:
17272       operands[2] = GEN_INT (elt * 0x55);
17273       return "vpermilps\t{%2, %1, %0|%0, %1, %2}";
17274     default:
17275       gcc_unreachable ();
17276     }
17278   [(set_attr "type" "ssemov,ssemov,sselog1")
17279    (set_attr "prefix_extra" "1")
17280    (set_attr "length_immediate" "0,0,1")
17281    (set_attr "prefix" "vex")
17282    (set_attr "mode" "SF,SF,V4SF")])
17284 (define_insn_and_split "*avx_vperm_broadcast_<mode>"
17285   [(set (match_operand:VF_256 0 "register_operand" "=x,x,x")
17286         (vec_select:VF_256
17287           (match_operand:VF_256 1 "nonimmediate_operand" "m,o,?x")
17288           (match_parallel 2 "avx_vbroadcast_operand"
17289             [(match_operand 3 "const_int_operand" "C,n,n")])))]
17290   "TARGET_AVX"
17291   "#"
17292   "&& reload_completed && (<MODE>mode != V4DFmode || !TARGET_AVX2)"
17293   [(set (match_dup 0) (vec_duplicate:VF_256 (match_dup 1)))]
17295   rtx op0 = operands[0], op1 = operands[1];
17296   int elt = INTVAL (operands[3]);
17298   if (REG_P (op1))
17299     {
17300       int mask;
17302       if (TARGET_AVX2 && elt == 0)
17303         {
17304           emit_insn (gen_vec_dup<mode> (op0, gen_lowpart (<ssescalarmode>mode,
17305                                                           op1)));
17306           DONE;
17307         }
17309       /* Shuffle element we care about into all elements of the 128-bit lane.
17310          The other lane gets shuffled too, but we don't care.  */
17311       if (<MODE>mode == V4DFmode)
17312         mask = (elt & 1 ? 15 : 0);
17313       else
17314         mask = (elt & 3) * 0x55;
17315       emit_insn (gen_avx_vpermil<mode> (op0, op1, GEN_INT (mask)));
17317       /* Shuffle the lane we care about into both lanes of the dest.  */
17318       mask = (elt / (<ssescalarnum> / 2)) * 0x11;
17319       emit_insn (gen_avx_vperm2f128<mode>3 (op0, op0, op0, GEN_INT (mask)));
17320       DONE;
17321     }
17323   operands[1] = adjust_address (op1, <ssescalarmode>mode,
17324                                 elt * GET_MODE_SIZE (<ssescalarmode>mode));
17327 (define_expand "<sse2_avx_avx512f>_vpermil<mode><mask_name>"
17328   [(set (match_operand:VF2 0 "register_operand")
17329         (vec_select:VF2
17330           (match_operand:VF2 1 "nonimmediate_operand")
17331           (match_operand:SI 2 "const_0_to_255_operand")))]
17332   "TARGET_AVX && <mask_mode512bit_condition>"
17334   int mask = INTVAL (operands[2]);
17335   rtx perm[<ssescalarnum>];
17337   int i;
17338   for (i = 0; i < <ssescalarnum>; i = i + 2)
17339     {
17340       perm[i]     = GEN_INT (((mask >> i)       & 1) + i);
17341       perm[i + 1] = GEN_INT (((mask >> (i + 1)) & 1) + i);
17342     }
17344   operands[2]
17345     = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (<ssescalarnum>, perm));
17348 (define_expand "<sse2_avx_avx512f>_vpermil<mode><mask_name>"
17349   [(set (match_operand:VF1 0 "register_operand")
17350         (vec_select:VF1
17351           (match_operand:VF1 1 "nonimmediate_operand")
17352           (match_operand:SI 2 "const_0_to_255_operand")))]
17353   "TARGET_AVX && <mask_mode512bit_condition>"
17355   int mask = INTVAL (operands[2]);
17356   rtx perm[<ssescalarnum>];
17358   int i;
17359   for (i = 0; i < <ssescalarnum>; i = i + 4)
17360     {
17361       perm[i]     = GEN_INT (((mask >> 0) & 3) + i);
17362       perm[i + 1] = GEN_INT (((mask >> 2) & 3) + i);
17363       perm[i + 2] = GEN_INT (((mask >> 4) & 3) + i);
17364       perm[i + 3] = GEN_INT (((mask >> 6) & 3) + i);
17365     }
17367   operands[2]
17368     = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (<ssescalarnum>, perm));
17371 (define_insn "*<sse2_avx_avx512f>_vpermilp<mode><mask_name>"
17372   [(set (match_operand:VF 0 "register_operand" "=v")
17373         (vec_select:VF
17374           (match_operand:VF 1 "nonimmediate_operand" "vm")
17375           (match_parallel 2 ""
17376             [(match_operand 3 "const_int_operand")])))]
17377   "TARGET_AVX && <mask_mode512bit_condition>
17378    && avx_vpermilp_parallel (operands[2], <MODE>mode)"
17380   int mask = avx_vpermilp_parallel (operands[2], <MODE>mode) - 1;
17381   operands[2] = GEN_INT (mask);
17382   return "vpermil<ssemodesuffix>\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}";
17384   [(set_attr "type" "sselog")
17385    (set_attr "prefix_extra" "1")
17386    (set_attr "length_immediate" "1")
17387    (set_attr "prefix" "<mask_prefix>")
17388    (set_attr "mode" "<sseinsnmode>")])
17390 (define_insn "<sse2_avx_avx512f>_vpermilvar<mode>3<mask_name>"
17391   [(set (match_operand:VF 0 "register_operand" "=v")
17392         (unspec:VF
17393           [(match_operand:VF 1 "register_operand" "v")
17394            (match_operand:<sseintvecmode> 2 "nonimmediate_operand" "vm")]
17395           UNSPEC_VPERMIL))]
17396   "TARGET_AVX && <mask_mode512bit_condition>"
17397   "vpermil<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
17398   [(set_attr "type" "sselog")
17399    (set_attr "prefix_extra" "1")
17400    (set_attr "btver2_decode" "vector")
17401    (set_attr "prefix" "<mask_prefix>")
17402    (set_attr "mode" "<sseinsnmode>")])
17404 (define_expand "<avx512>_vpermi2var<mode>3_maskz"
17405   [(match_operand:VI48F 0 "register_operand")
17406    (match_operand:VI48F 1 "register_operand")
17407    (match_operand:<sseintvecmode> 2 "register_operand")
17408    (match_operand:VI48F 3 "nonimmediate_operand")
17409    (match_operand:<avx512fmaskmode> 4 "register_operand")]
17410   "TARGET_AVX512F"
17412   emit_insn (gen_<avx512>_vpermi2var<mode>3_maskz_1 (
17413         operands[0], operands[1], operands[2], operands[3],
17414         CONST0_RTX (<MODE>mode), operands[4]));
17415   DONE;
17418 (define_expand "<avx512>_vpermi2var<mode>3_maskz"
17419   [(match_operand:VI1_AVX512VL 0 "register_operand")
17420    (match_operand:VI1_AVX512VL 1 "register_operand")
17421    (match_operand:<sseintvecmode> 2 "register_operand")
17422    (match_operand:VI1_AVX512VL 3 "nonimmediate_operand")
17423    (match_operand:<avx512fmaskmode> 4 "register_operand")]
17424   "TARGET_AVX512VBMI"
17426   emit_insn (gen_<avx512>_vpermi2var<mode>3_maskz_1 (
17427         operands[0], operands[1], operands[2], operands[3],
17428         CONST0_RTX (<MODE>mode), operands[4]));
17429   DONE;
17432 (define_expand "<avx512>_vpermi2var<mode>3_maskz"
17433   [(match_operand:VI2_AVX512VL 0 "register_operand")
17434    (match_operand:VI2_AVX512VL 1 "register_operand")
17435    (match_operand:<sseintvecmode> 2 "register_operand")
17436    (match_operand:VI2_AVX512VL 3 "nonimmediate_operand")
17437    (match_operand:<avx512fmaskmode> 4 "register_operand")]
17438   "TARGET_AVX512BW"
17440   emit_insn (gen_<avx512>_vpermi2var<mode>3_maskz_1 (
17441         operands[0], operands[1], operands[2], operands[3],
17442         CONST0_RTX (<MODE>mode), operands[4]));
17443   DONE;
17446 (define_insn "<avx512>_vpermi2var<mode>3<sd_maskz_name>"
17447   [(set (match_operand:VI48F 0 "register_operand" "=v")
17448         (unspec:VI48F
17449           [(match_operand:VI48F 1 "register_operand" "v")
17450            (match_operand:<sseintvecmode> 2 "register_operand" "0")
17451            (match_operand:VI48F 3 "nonimmediate_operand" "vm")]
17452           UNSPEC_VPERMI2))]
17453   "TARGET_AVX512F"
17454   "vpermi2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}"
17455   [(set_attr "type" "sselog")
17456    (set_attr "prefix" "evex")
17457    (set_attr "mode" "<sseinsnmode>")])
17459 (define_insn "<avx512>_vpermi2var<mode>3<sd_maskz_name>"
17460   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
17461         (unspec:VI1_AVX512VL
17462           [(match_operand:VI1_AVX512VL 1 "register_operand" "v")
17463            (match_operand:<sseintvecmode> 2 "register_operand" "0")
17464            (match_operand:VI1_AVX512VL 3 "nonimmediate_operand" "vm")]
17465           UNSPEC_VPERMI2))]
17466   "TARGET_AVX512VBMI"
17467   "vpermi2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}"
17468   [(set_attr "type" "sselog")
17469    (set_attr "prefix" "evex")
17470    (set_attr "mode" "<sseinsnmode>")])
17472 (define_insn "<avx512>_vpermi2var<mode>3<sd_maskz_name>"
17473   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17474         (unspec:VI2_AVX512VL
17475           [(match_operand:VI2_AVX512VL 1 "register_operand" "v")
17476            (match_operand:<sseintvecmode> 2 "register_operand" "0")
17477            (match_operand:VI2_AVX512VL 3 "nonimmediate_operand" "vm")]
17478           UNSPEC_VPERMI2))]
17479   "TARGET_AVX512BW"
17480   "vpermi2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}"
17481   [(set_attr "type" "sselog")
17482    (set_attr "prefix" "evex")
17483    (set_attr "mode" "<sseinsnmode>")])
17485 (define_insn "<avx512>_vpermi2var<mode>3_mask"
17486   [(set (match_operand:VI48F 0 "register_operand" "=v")
17487         (vec_merge:VI48F
17488           (unspec:VI48F
17489             [(match_operand:VI48F 1 "register_operand" "v")
17490             (match_operand:<sseintvecmode> 2 "register_operand" "0")
17491             (match_operand:VI48F 3 "nonimmediate_operand" "vm")]
17492             UNSPEC_VPERMI2_MASK)
17493           (match_dup 0)
17494           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
17495   "TARGET_AVX512F"
17496   "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
17497   [(set_attr "type" "sselog")
17498    (set_attr "prefix" "evex")
17499    (set_attr "mode" "<sseinsnmode>")])
17501 (define_insn "<avx512>_vpermi2var<mode>3_mask"
17502   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
17503         (vec_merge:VI1_AVX512VL
17504           (unspec:VI1_AVX512VL
17505             [(match_operand:VI1_AVX512VL 1 "register_operand" "v")
17506             (match_operand:<sseintvecmode> 2 "register_operand" "0")
17507             (match_operand:VI1_AVX512VL 3 "nonimmediate_operand" "vm")]
17508             UNSPEC_VPERMI2_MASK)
17509           (match_dup 0)
17510           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
17511   "TARGET_AVX512VBMI"
17512   "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
17513   [(set_attr "type" "sselog")
17514    (set_attr "prefix" "evex")
17515    (set_attr "mode" "<sseinsnmode>")])
17517 (define_insn "<avx512>_vpermi2var<mode>3_mask"
17518   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17519         (vec_merge:VI2_AVX512VL
17520           (unspec:VI2_AVX512VL
17521             [(match_operand:VI2_AVX512VL 1 "register_operand" "v")
17522             (match_operand:<sseintvecmode> 2 "register_operand" "0")
17523             (match_operand:VI2_AVX512VL 3 "nonimmediate_operand" "vm")]
17524             UNSPEC_VPERMI2_MASK)
17525           (match_dup 0)
17526           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
17527   "TARGET_AVX512BW"
17528   "vpermi2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
17529   [(set_attr "type" "sselog")
17530    (set_attr "prefix" "evex")
17531    (set_attr "mode" "<sseinsnmode>")])
17533 (define_expand "<avx512>_vpermt2var<mode>3_maskz"
17534   [(match_operand:VI48F 0 "register_operand")
17535    (match_operand:<sseintvecmode> 1 "register_operand")
17536    (match_operand:VI48F 2 "register_operand")
17537    (match_operand:VI48F 3 "nonimmediate_operand")
17538    (match_operand:<avx512fmaskmode> 4 "register_operand")]
17539   "TARGET_AVX512F"
17541   emit_insn (gen_<avx512>_vpermt2var<mode>3_maskz_1 (
17542         operands[0], operands[1], operands[2], operands[3],
17543         CONST0_RTX (<MODE>mode), operands[4]));
17544   DONE;
17547 (define_expand "<avx512>_vpermt2var<mode>3_maskz"
17548   [(match_operand:VI1_AVX512VL 0 "register_operand")
17549    (match_operand:<sseintvecmode> 1 "register_operand")
17550    (match_operand:VI1_AVX512VL 2 "register_operand")
17551    (match_operand:VI1_AVX512VL 3 "nonimmediate_operand")
17552    (match_operand:<avx512fmaskmode> 4 "register_operand")]
17553   "TARGET_AVX512VBMI"
17555   emit_insn (gen_<avx512>_vpermt2var<mode>3_maskz_1 (
17556         operands[0], operands[1], operands[2], operands[3],
17557         CONST0_RTX (<MODE>mode), operands[4]));
17558   DONE;
17561 (define_expand "<avx512>_vpermt2var<mode>3_maskz"
17562   [(match_operand:VI2_AVX512VL 0 "register_operand")
17563    (match_operand:<sseintvecmode> 1 "register_operand")
17564    (match_operand:VI2_AVX512VL 2 "register_operand")
17565    (match_operand:VI2_AVX512VL 3 "nonimmediate_operand")
17566    (match_operand:<avx512fmaskmode> 4 "register_operand")]
17567   "TARGET_AVX512BW"
17569   emit_insn (gen_<avx512>_vpermt2var<mode>3_maskz_1 (
17570         operands[0], operands[1], operands[2], operands[3],
17571         CONST0_RTX (<MODE>mode), operands[4]));
17572   DONE;
17575 (define_insn "<avx512>_vpermt2var<mode>3<sd_maskz_name>"
17576   [(set (match_operand:VI48F 0 "register_operand" "=v")
17577         (unspec:VI48F
17578           [(match_operand:<sseintvecmode> 1 "register_operand" "v")
17579            (match_operand:VI48F 2 "register_operand" "0")
17580            (match_operand:VI48F 3 "nonimmediate_operand" "vm")]
17581           UNSPEC_VPERMT2))]
17582   "TARGET_AVX512F"
17583   "vpermt2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}"
17584   [(set_attr "type" "sselog")
17585    (set_attr "prefix" "evex")
17586    (set_attr "mode" "<sseinsnmode>")])
17588 (define_insn "<avx512>_vpermt2var<mode>3<sd_maskz_name>"
17589   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
17590         (unspec:VI1_AVX512VL
17591           [(match_operand:<sseintvecmode> 1 "register_operand" "v")
17592            (match_operand:VI1_AVX512VL 2 "register_operand" "0")
17593            (match_operand:VI1_AVX512VL 3 "nonimmediate_operand" "vm")]
17594           UNSPEC_VPERMT2))]
17595   "TARGET_AVX512VBMI"
17596   "vpermt2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}"
17597   [(set_attr "type" "sselog")
17598    (set_attr "prefix" "evex")
17599    (set_attr "mode" "<sseinsnmode>")])
17601 (define_insn "<avx512>_vpermt2var<mode>3<sd_maskz_name>"
17602   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17603         (unspec:VI2_AVX512VL
17604           [(match_operand:<sseintvecmode> 1 "register_operand" "v")
17605            (match_operand:VI2_AVX512VL 2 "register_operand" "0")
17606            (match_operand:VI2_AVX512VL 3 "nonimmediate_operand" "vm")]
17607           UNSPEC_VPERMT2))]
17608   "TARGET_AVX512BW"
17609   "vpermt2<ssemodesuffix>\t{%3, %1, %0<sd_mask_op4>|%0<sd_mask_op4>, %1, %3}"
17610   [(set_attr "type" "sselog")
17611    (set_attr "prefix" "evex")
17612    (set_attr "mode" "<sseinsnmode>")])
17614 (define_insn "<avx512>_vpermt2var<mode>3_mask"
17615   [(set (match_operand:VI48F 0 "register_operand" "=v")
17616         (vec_merge:VI48F
17617           (unspec:VI48F
17618             [(match_operand:<sseintvecmode> 1 "register_operand" "v")
17619             (match_operand:VI48F 2 "register_operand" "0")
17620             (match_operand:VI48F 3 "nonimmediate_operand" "vm")]
17621             UNSPEC_VPERMT2)
17622           (match_dup 2)
17623           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
17624   "TARGET_AVX512F"
17625   "vpermt2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
17626   [(set_attr "type" "sselog")
17627    (set_attr "prefix" "evex")
17628    (set_attr "mode" "<sseinsnmode>")])
17630 (define_insn "<avx512>_vpermt2var<mode>3_mask"
17631   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
17632         (vec_merge:VI1_AVX512VL
17633           (unspec:VI1_AVX512VL
17634             [(match_operand:<sseintvecmode> 1 "register_operand" "v")
17635             (match_operand:VI1_AVX512VL 2 "register_operand" "0")
17636             (match_operand:VI1_AVX512VL 3 "nonimmediate_operand" "vm")]
17637             UNSPEC_VPERMT2)
17638           (match_dup 2)
17639           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
17640   "TARGET_AVX512VBMI"
17641   "vpermt2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
17642   [(set_attr "type" "sselog")
17643    (set_attr "prefix" "evex")
17644    (set_attr "mode" "<sseinsnmode>")])
17646 (define_insn "<avx512>_vpermt2var<mode>3_mask"
17647   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
17648         (vec_merge:VI2_AVX512VL
17649           (unspec:VI2_AVX512VL
17650             [(match_operand:<sseintvecmode> 1 "register_operand" "v")
17651             (match_operand:VI2_AVX512VL 2 "register_operand" "0")
17652             (match_operand:VI2_AVX512VL 3 "nonimmediate_operand" "vm")]
17653             UNSPEC_VPERMT2)
17654           (match_dup 2)
17655           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
17656   "TARGET_AVX512BW"
17657   "vpermt2<ssemodesuffix>\t{%3, %1, %0%{%4%}|%0%{%4%}, %1, %3}"
17658   [(set_attr "type" "sselog")
17659    (set_attr "prefix" "evex")
17660    (set_attr "mode" "<sseinsnmode>")])
17662 (define_expand "avx_vperm2f128<mode>3"
17663   [(set (match_operand:AVX256MODE2P 0 "register_operand")
17664         (unspec:AVX256MODE2P
17665           [(match_operand:AVX256MODE2P 1 "register_operand")
17666            (match_operand:AVX256MODE2P 2 "nonimmediate_operand")
17667            (match_operand:SI 3 "const_0_to_255_operand")]
17668           UNSPEC_VPERMIL2F128))]
17669   "TARGET_AVX"
17671   int mask = INTVAL (operands[3]);
17672   if ((mask & 0x88) == 0)
17673     {
17674       rtx perm[<ssescalarnum>], t1, t2;
17675       int i, base, nelt = <ssescalarnum>, nelt2 = nelt / 2;
17677       base = (mask & 3) * nelt2;
17678       for (i = 0; i < nelt2; ++i)
17679         perm[i] = GEN_INT (base + i);
17681       base = ((mask >> 4) & 3) * nelt2;
17682       for (i = 0; i < nelt2; ++i)
17683         perm[i + nelt2] = GEN_INT (base + i);
17685       t2 = gen_rtx_VEC_CONCAT (<ssedoublevecmode>mode,
17686                                operands[1], operands[2]);
17687       t1 = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (nelt, perm));
17688       t2 = gen_rtx_VEC_SELECT (<MODE>mode, t2, t1);
17689       t2 = gen_rtx_SET (operands[0], t2);
17690       emit_insn (t2);
17691       DONE;
17692     }
17695 ;; Note that bits 7 and 3 of the imm8 allow lanes to be zeroed, which
17696 ;; means that in order to represent this properly in rtl we'd have to
17697 ;; nest *another* vec_concat with a zero operand and do the select from
17698 ;; a 4x wide vector.  That doesn't seem very nice.
17699 (define_insn "*avx_vperm2f128<mode>_full"
17700   [(set (match_operand:AVX256MODE2P 0 "register_operand" "=x")
17701         (unspec:AVX256MODE2P
17702           [(match_operand:AVX256MODE2P 1 "register_operand" "x")
17703            (match_operand:AVX256MODE2P 2 "nonimmediate_operand" "xm")
17704            (match_operand:SI 3 "const_0_to_255_operand" "n")]
17705           UNSPEC_VPERMIL2F128))]
17706   "TARGET_AVX"
17707   "vperm2<i128>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
17708   [(set_attr "type" "sselog")
17709    (set_attr "prefix_extra" "1")
17710    (set_attr "length_immediate" "1")
17711    (set_attr "prefix" "vex")
17712    (set_attr "mode" "<sseinsnmode>")])
17714 (define_insn "*avx_vperm2f128<mode>_nozero"
17715   [(set (match_operand:AVX256MODE2P 0 "register_operand" "=x")
17716         (vec_select:AVX256MODE2P
17717           (vec_concat:<ssedoublevecmode>
17718             (match_operand:AVX256MODE2P 1 "register_operand" "x")
17719             (match_operand:AVX256MODE2P 2 "nonimmediate_operand" "xm"))
17720           (match_parallel 3 ""
17721             [(match_operand 4 "const_int_operand")])))]
17722   "TARGET_AVX
17723    && avx_vperm2f128_parallel (operands[3], <MODE>mode)"
17725   int mask = avx_vperm2f128_parallel (operands[3], <MODE>mode) - 1;
17726   if (mask == 0x12)
17727     return "vinsert<i128>\t{$0, %x2, %1, %0|%0, %1, %x2, 0}";
17728   if (mask == 0x20)
17729     return "vinsert<i128>\t{$1, %x2, %1, %0|%0, %1, %x2, 1}";
17730   operands[3] = GEN_INT (mask);
17731   return "vperm2<i128>\t{%3, %2, %1, %0|%0, %1, %2, %3}";
17733   [(set_attr "type" "sselog")
17734    (set_attr "prefix_extra" "1")
17735    (set_attr "length_immediate" "1")
17736    (set_attr "prefix" "vex")
17737    (set_attr "mode" "<sseinsnmode>")])
17739 (define_insn "*ssse3_palignr<mode>_perm"
17740   [(set (match_operand:V_128 0 "register_operand" "=x,x")
17741       (vec_select:V_128
17742         (match_operand:V_128 1 "register_operand" "0,x")
17743         (match_parallel 2 "palignr_operand"
17744           [(match_operand 3 "const_int_operand" "n, n")])))]
17745   "TARGET_SSSE3"
17747   operands[2] =
17748    GEN_INT (INTVAL (operands[3]) * GET_MODE_UNIT_SIZE (GET_MODE (operands[0])));
17750   switch (which_alternative)
17751     {
17752     case 0:
17753       return "palignr\t{%2, %1, %0|%0, %1, %2}";
17754     case 1:
17755       return "vpalignr\t{%2, %1, %1, %0|%0, %1, %1, %2}";
17756     default:
17757       gcc_unreachable ();
17758     }
17760   [(set_attr "isa" "noavx,avx")
17761    (set_attr "type" "sseishft")
17762    (set_attr "atom_unit" "sishuf")
17763    (set_attr "prefix_data16" "1,*")
17764    (set_attr "prefix_extra" "1")
17765    (set_attr "length_immediate" "1")
17766    (set_attr "prefix" "orig,vex")])
17768 (define_expand "avx512vl_vinsert<mode>"
17769   [(match_operand:VI48F_256 0 "register_operand")
17770    (match_operand:VI48F_256 1 "register_operand")
17771    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
17772    (match_operand:SI 3 "const_0_to_1_operand")
17773    (match_operand:VI48F_256 4 "register_operand")
17774    (match_operand:<avx512fmaskmode> 5 "register_operand")]
17775   "TARGET_AVX512VL"
17777   rtx (*insn)(rtx, rtx, rtx, rtx, rtx);
17779   switch (INTVAL (operands[3]))
17780     {
17781     case 0:
17782       insn = gen_vec_set_lo_<mode>_mask;
17783       break;
17784     case 1:
17785       insn = gen_vec_set_hi_<mode>_mask;
17786       break;
17787     default:
17788       gcc_unreachable ();
17789     }
17791   emit_insn (insn (operands[0], operands[1], operands[2], operands[4],
17792                    operands[5]));
17793   DONE;
17796 (define_expand "avx_vinsertf128<mode>"
17797   [(match_operand:V_256 0 "register_operand")
17798    (match_operand:V_256 1 "register_operand")
17799    (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand")
17800    (match_operand:SI 3 "const_0_to_1_operand")]
17801   "TARGET_AVX"
17803   rtx (*insn)(rtx, rtx, rtx);
17805   switch (INTVAL (operands[3]))
17806     {
17807     case 0:
17808       insn = gen_vec_set_lo_<mode>;
17809       break;
17810     case 1:
17811       insn = gen_vec_set_hi_<mode>;
17812       break;
17813     default:
17814       gcc_unreachable ();
17815     }
17817   emit_insn (insn (operands[0], operands[1], operands[2]));
17818   DONE;
17821 (define_insn "vec_set_lo_<mode><mask_name>"
17822   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
17823         (vec_concat:VI8F_256
17824           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
17825           (vec_select:<ssehalfvecmode>
17826             (match_operand:VI8F_256 1 "register_operand" "v")
17827             (parallel [(const_int 2) (const_int 3)]))))]
17828   "TARGET_AVX && <mask_avx512dq_condition>"
17830   if (TARGET_AVX512DQ)
17831     return "vinsert<shuffletype>64x2\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
17832   else if (TARGET_AVX512VL)
17833     return "vinsert<shuffletype>32x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
17834   else
17835     return "vinsert<i128>\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}";
17837   [(set_attr "type" "sselog")
17838    (set_attr "prefix_extra" "1")
17839    (set_attr "length_immediate" "1")
17840    (set_attr "prefix" "vex")
17841    (set_attr "mode" "<sseinsnmode>")])
17843 (define_insn "vec_set_hi_<mode><mask_name>"
17844   [(set (match_operand:VI8F_256 0 "register_operand" "=v")
17845         (vec_concat:VI8F_256
17846           (vec_select:<ssehalfvecmode>
17847             (match_operand:VI8F_256 1 "register_operand" "v")
17848             (parallel [(const_int 0) (const_int 1)]))
17849           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
17850   "TARGET_AVX && <mask_avx512dq_condition>"
17852   if (TARGET_AVX512DQ)
17853     return "vinsert<shuffletype>64x2\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
17854   else if (TARGET_AVX512VL)
17855     return "vinsert<shuffletype>32x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
17856   else
17857     return "vinsert<i128>\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}";
17859   [(set_attr "type" "sselog")
17860    (set_attr "prefix_extra" "1")
17861    (set_attr "length_immediate" "1")
17862    (set_attr "prefix" "vex")
17863    (set_attr "mode" "<sseinsnmode>")])
17865 (define_insn "vec_set_lo_<mode><mask_name>"
17866   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
17867         (vec_concat:VI4F_256
17868           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")
17869           (vec_select:<ssehalfvecmode>
17870             (match_operand:VI4F_256 1 "register_operand" "v")
17871             (parallel [(const_int 4) (const_int 5)
17872                        (const_int 6) (const_int 7)]))))]
17873   "TARGET_AVX"
17875   if (TARGET_AVX512VL)
17876     return "vinsert<shuffletype>32x4\t{$0x0, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x0}";
17877   else
17878     return "vinsert<i128>\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}";
17880   [(set_attr "type" "sselog")
17881    (set_attr "prefix_extra" "1")
17882    (set_attr "length_immediate" "1")
17883    (set_attr "prefix" "vex")
17884    (set_attr "mode" "<sseinsnmode>")])
17886 (define_insn "vec_set_hi_<mode><mask_name>"
17887   [(set (match_operand:VI4F_256 0 "register_operand" "=v")
17888         (vec_concat:VI4F_256
17889           (vec_select:<ssehalfvecmode>
17890             (match_operand:VI4F_256 1 "register_operand" "v")
17891             (parallel [(const_int 0) (const_int 1)
17892                        (const_int 2) (const_int 3)]))
17893           (match_operand:<ssehalfvecmode> 2 "nonimmediate_operand" "vm")))]
17894   "TARGET_AVX"
17896   if (TARGET_AVX512VL)
17897     return "vinsert<shuffletype>32x4\t{$0x1, %2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2, 0x1}";
17898   else
17899     return "vinsert<i128>\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}";
17901   [(set_attr "type" "sselog")
17902    (set_attr "prefix_extra" "1")
17903    (set_attr "length_immediate" "1")
17904    (set_attr "prefix" "vex")
17905    (set_attr "mode" "<sseinsnmode>")])
17907 (define_insn "vec_set_lo_v16hi"
17908   [(set (match_operand:V16HI 0 "register_operand" "=x,v")
17909         (vec_concat:V16HI
17910           (match_operand:V8HI 2 "nonimmediate_operand" "xm,vm")
17911           (vec_select:V8HI
17912             (match_operand:V16HI 1 "register_operand" "x,v")
17913             (parallel [(const_int 8) (const_int 9)
17914                        (const_int 10) (const_int 11)
17915                        (const_int 12) (const_int 13)
17916                        (const_int 14) (const_int 15)]))))]
17917   "TARGET_AVX"
17918   "@
17919    vinsert%~128\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}
17920    vinserti32x4\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}"
17921   [(set_attr "type" "sselog")
17922    (set_attr "prefix_extra" "1")
17923    (set_attr "length_immediate" "1")
17924    (set_attr "prefix" "vex,evex")
17925    (set_attr "mode" "OI")])
17927 (define_insn "vec_set_hi_v16hi"
17928   [(set (match_operand:V16HI 0 "register_operand" "=x,v")
17929         (vec_concat:V16HI
17930           (vec_select:V8HI
17931             (match_operand:V16HI 1 "register_operand" "x,v")
17932             (parallel [(const_int 0) (const_int 1)
17933                        (const_int 2) (const_int 3)
17934                        (const_int 4) (const_int 5)
17935                        (const_int 6) (const_int 7)]))
17936           (match_operand:V8HI 2 "nonimmediate_operand" "xm,vm")))]
17937   "TARGET_AVX"
17938   "@
17939    vinsert%~128\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}
17940    vinserti32x4\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}"
17941   [(set_attr "type" "sselog")
17942    (set_attr "prefix_extra" "1")
17943    (set_attr "length_immediate" "1")
17944    (set_attr "prefix" "vex,evex")
17945    (set_attr "mode" "OI")])
17947 (define_insn "vec_set_lo_v32qi"
17948   [(set (match_operand:V32QI 0 "register_operand" "=x,v")
17949         (vec_concat:V32QI
17950           (match_operand:V16QI 2 "nonimmediate_operand" "xm,v")
17951           (vec_select:V16QI
17952             (match_operand:V32QI 1 "register_operand" "x,v")
17953             (parallel [(const_int 16) (const_int 17)
17954                        (const_int 18) (const_int 19)
17955                        (const_int 20) (const_int 21)
17956                        (const_int 22) (const_int 23)
17957                        (const_int 24) (const_int 25)
17958                        (const_int 26) (const_int 27)
17959                        (const_int 28) (const_int 29)
17960                        (const_int 30) (const_int 31)]))))]
17961   "TARGET_AVX"
17962   "@
17963    vinsert%~128\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}
17964    vinserti32x4\t{$0x0, %2, %1, %0|%0, %1, %2, 0x0}"
17965   [(set_attr "type" "sselog")
17966    (set_attr "prefix_extra" "1")
17967    (set_attr "length_immediate" "1")
17968    (set_attr "prefix" "vex,evex")
17969    (set_attr "mode" "OI")])
17971 (define_insn "vec_set_hi_v32qi"
17972   [(set (match_operand:V32QI 0 "register_operand" "=x,v")
17973         (vec_concat:V32QI
17974           (vec_select:V16QI
17975             (match_operand:V32QI 1 "register_operand" "x,v")
17976             (parallel [(const_int 0) (const_int 1)
17977                        (const_int 2) (const_int 3)
17978                        (const_int 4) (const_int 5)
17979                        (const_int 6) (const_int 7)
17980                        (const_int 8) (const_int 9)
17981                        (const_int 10) (const_int 11)
17982                        (const_int 12) (const_int 13)
17983                        (const_int 14) (const_int 15)]))
17984           (match_operand:V16QI 2 "nonimmediate_operand" "xm,vm")))]
17985   "TARGET_AVX"
17986   "@
17987    vinsert%~128\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}
17988    vinserti32x4\t{$0x1, %2, %1, %0|%0, %1, %2, 0x1}"
17989   [(set_attr "type" "sselog")
17990    (set_attr "prefix_extra" "1")
17991    (set_attr "length_immediate" "1")
17992    (set_attr "prefix" "vex,evex")
17993    (set_attr "mode" "OI")])
17995 (define_insn "<avx_avx2>_maskload<ssemodesuffix><avxsizesuffix>"
17996   [(set (match_operand:V48_AVX2 0 "register_operand" "=x")
17997         (unspec:V48_AVX2
17998           [(match_operand:<sseintvecmode> 2 "register_operand" "x")
17999            (match_operand:V48_AVX2 1 "memory_operand" "m")]
18000           UNSPEC_MASKMOV))]
18001   "TARGET_AVX"
18002   "v<sseintprefix>maskmov<ssemodesuffix>\t{%1, %2, %0|%0, %2, %1}"
18003   [(set_attr "type" "sselog1")
18004    (set_attr "prefix_extra" "1")
18005    (set_attr "prefix" "vex")
18006    (set_attr "btver2_decode" "vector")
18007    (set_attr "mode" "<sseinsnmode>")])
18009 (define_insn "<avx_avx2>_maskstore<ssemodesuffix><avxsizesuffix>"
18010   [(set (match_operand:V48_AVX2 0 "memory_operand" "+m")
18011         (unspec:V48_AVX2
18012           [(match_operand:<sseintvecmode> 1 "register_operand" "x")
18013            (match_operand:V48_AVX2 2 "register_operand" "x")
18014            (match_dup 0)]
18015           UNSPEC_MASKMOV))]
18016   "TARGET_AVX"
18017   "v<sseintprefix>maskmov<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
18018   [(set_attr "type" "sselog1")
18019    (set_attr "prefix_extra" "1")
18020    (set_attr "prefix" "vex")
18021    (set_attr "btver2_decode" "vector") 
18022    (set_attr "mode" "<sseinsnmode>")])
18024 (define_expand "maskload<mode><sseintvecmodelower>"
18025   [(set (match_operand:V48_AVX2 0 "register_operand")
18026         (unspec:V48_AVX2
18027           [(match_operand:<sseintvecmode> 2 "register_operand")
18028            (match_operand:V48_AVX2 1 "memory_operand")]
18029           UNSPEC_MASKMOV))]
18030   "TARGET_AVX")
18032 (define_expand "maskload<mode><avx512fmaskmodelower>"
18033   [(set (match_operand:V48_AVX512VL 0 "register_operand")
18034         (vec_merge:V48_AVX512VL
18035           (match_operand:V48_AVX512VL 1 "memory_operand")
18036           (match_dup 0)
18037           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18038   "TARGET_AVX512F")
18040 (define_expand "maskload<mode><avx512fmaskmodelower>"
18041   [(set (match_operand:VI12_AVX512VL 0 "register_operand")
18042         (vec_merge:VI12_AVX512VL
18043           (match_operand:VI12_AVX512VL 1 "memory_operand")
18044           (match_dup 0)
18045           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18046   "TARGET_AVX512BW")
18048 (define_expand "maskstore<mode><sseintvecmodelower>"
18049   [(set (match_operand:V48_AVX2 0 "memory_operand")
18050         (unspec:V48_AVX2
18051           [(match_operand:<sseintvecmode> 2 "register_operand")
18052            (match_operand:V48_AVX2 1 "register_operand")
18053            (match_dup 0)]
18054           UNSPEC_MASKMOV))]
18055   "TARGET_AVX")
18057 (define_expand "maskstore<mode><avx512fmaskmodelower>"
18058   [(set (match_operand:V48_AVX512VL 0 "memory_operand")
18059         (vec_merge:V48_AVX512VL
18060           (match_operand:V48_AVX512VL 1 "register_operand")
18061           (match_dup 0)
18062           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18063   "TARGET_AVX512F")
18065 (define_expand "maskstore<mode><avx512fmaskmodelower>"
18066   [(set (match_operand:VI12_AVX512VL 0 "memory_operand")
18067         (vec_merge:VI12_AVX512VL
18068           (match_operand:VI12_AVX512VL 1 "register_operand")
18069           (match_dup 0)
18070           (match_operand:<avx512fmaskmode> 2 "register_operand")))]
18071   "TARGET_AVX512BW")
18073 (define_expand "cbranch<mode>4"
18074   [(set (reg:CC FLAGS_REG)
18075         (compare:CC (match_operand:VI48_AVX 1 "register_operand")
18076                     (match_operand:VI48_AVX 2 "nonimmediate_operand")))
18077    (set (pc) (if_then_else
18078                (match_operator 0 "bt_comparison_operator"
18079                 [(reg:CC FLAGS_REG) (const_int 0)])
18080                (label_ref (match_operand 3))
18081                (pc)))]
18082   "TARGET_SSE4_1"
18084   ix86_expand_branch (GET_CODE (operands[0]),
18085                       operands[1], operands[2], operands[3]);
18086   DONE;
18090 (define_insn_and_split "avx_<castmode><avxsizesuffix>_<castmode>"
18091   [(set (match_operand:AVX256MODE2P 0 "nonimmediate_operand" "=x,m")
18092         (unspec:AVX256MODE2P
18093           [(match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "xm,x")]
18094           UNSPEC_CAST))]
18095   "TARGET_AVX"
18096   "#"
18097   "&& reload_completed"
18098   [(set (match_dup 0) (match_dup 1))]
18100   if (REG_P (operands[0]))
18101     operands[0] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);
18102   else
18103     operands[1] = lowpart_subreg (<MODE>mode, operands[1],
18104                                   <ssehalfvecmode>mode);
18107 (define_expand "vec_init<mode>"
18108   [(match_operand:V_256 0 "register_operand")
18109    (match_operand 1)]
18110   "TARGET_AVX"
18112   ix86_expand_vector_init (false, operands[0], operands[1]);
18113   DONE;
18116 (define_expand "vec_init<mode>"
18117   [(match_operand:VF48_I1248 0 "register_operand")
18118    (match_operand 1)]
18119   "TARGET_AVX512F"
18121   ix86_expand_vector_init (false, operands[0], operands[1]);
18122   DONE;
18125 (define_insn "<avx2_avx512>_ashrv<mode><mask_name>"
18126   [(set (match_operand:VI48_AVX512F_AVX512VL 0 "register_operand" "=v")
18127         (ashiftrt:VI48_AVX512F_AVX512VL
18128           (match_operand:VI48_AVX512F_AVX512VL 1 "register_operand" "v")
18129           (match_operand:VI48_AVX512F_AVX512VL 2 "nonimmediate_operand" "vm")))]
18130   "TARGET_AVX2 && <mask_mode512bit_condition>"
18131   "vpsrav<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18132   [(set_attr "type" "sseishft")
18133    (set_attr "prefix" "maybe_evex")
18134    (set_attr "mode" "<sseinsnmode>")])
18136 (define_insn "<avx2_avx512>_ashrv<mode><mask_name>"
18137   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
18138         (ashiftrt:VI2_AVX512VL
18139           (match_operand:VI2_AVX512VL 1 "register_operand" "v")
18140           (match_operand:VI2_AVX512VL 2 "nonimmediate_operand" "vm")))]
18141   "TARGET_AVX512BW"
18142   "vpsravw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18143   [(set_attr "type" "sseishft")
18144    (set_attr "prefix" "maybe_evex")
18145    (set_attr "mode" "<sseinsnmode>")])
18147 (define_insn "<avx2_avx512>_<shift_insn>v<mode><mask_name>"
18148   [(set (match_operand:VI48_AVX512F 0 "register_operand" "=v")
18149         (any_lshift:VI48_AVX512F
18150           (match_operand:VI48_AVX512F 1 "register_operand" "v")
18151           (match_operand:VI48_AVX512F 2 "nonimmediate_operand" "vm")))]
18152   "TARGET_AVX2 && <mask_mode512bit_condition>"
18153   "vp<vshift>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18154   [(set_attr "type" "sseishft")
18155    (set_attr "prefix" "maybe_evex")
18156    (set_attr "mode" "<sseinsnmode>")])
18158 (define_insn "<avx2_avx512>_<shift_insn>v<mode><mask_name>"
18159   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
18160         (any_lshift:VI2_AVX512VL
18161           (match_operand:VI2_AVX512VL 1 "register_operand" "v")
18162           (match_operand:VI2_AVX512VL 2 "nonimmediate_operand" "vm")))]
18163   "TARGET_AVX512BW"
18164   "vp<vshift>v<ssemodesuffix>\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18165   [(set_attr "type" "sseishft")
18166    (set_attr "prefix" "maybe_evex")
18167    (set_attr "mode" "<sseinsnmode>")])
18169 (define_insn "avx_vec_concat<mode>"
18170   [(set (match_operand:V_256_512 0 "register_operand" "=x,x")
18171         (vec_concat:V_256_512
18172           (match_operand:<ssehalfvecmode> 1 "register_operand" "x,x")
18173           (match_operand:<ssehalfvecmode> 2 "vector_move_operand" "xm,C")))]
18174   "TARGET_AVX"
18176   switch (which_alternative)
18177     {
18178     case 0:
18179       return "vinsert<i128>\t{$0x1, %2, %<concat_tg_mode>1, %0|%0, %<concat_tg_mode>1, %2, 0x1}";
18180     case 1:
18181       switch (get_attr_mode (insn))
18182         {
18183         case MODE_V16SF:
18184           return "vmovaps\t{%1, %t0|%t0, %1}";
18185         case MODE_V8DF:
18186           return "vmovapd\t{%1, %t0|%t0, %1}";
18187         case MODE_V8SF:
18188           return "vmovaps\t{%1, %x0|%x0, %1}";
18189         case MODE_V4DF:
18190           return "vmovapd\t{%1, %x0|%x0, %1}";
18191         case MODE_XI:
18192           return "vmovdqa\t{%1, %t0|%t0, %1}";
18193         case MODE_OI:
18194           return "vmovdqa\t{%1, %x0|%x0, %1}";
18195         default:
18196           gcc_unreachable ();
18197         }
18198     default:
18199       gcc_unreachable ();
18200     }
18202   [(set_attr "type" "sselog,ssemov")
18203    (set_attr "prefix_extra" "1,*")
18204    (set_attr "length_immediate" "1,*")
18205    (set_attr "prefix" "maybe_evex")
18206    (set_attr "mode" "<sseinsnmode>")])
18208 (define_insn "vcvtph2ps<mask_name>"
18209   [(set (match_operand:V4SF 0 "register_operand" "=v")
18210         (vec_select:V4SF
18211           (unspec:V8SF [(match_operand:V8HI 1 "register_operand" "v")]
18212                        UNSPEC_VCVTPH2PS)
18213           (parallel [(const_int 0) (const_int 1)
18214                      (const_int 2) (const_int 3)])))]
18215   "TARGET_F16C || TARGET_AVX512VL"
18216   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18217   [(set_attr "type" "ssecvt")
18218    (set_attr "prefix" "maybe_evex")
18219    (set_attr "mode" "V4SF")])
18221 (define_insn "*vcvtph2ps_load<mask_name>"
18222   [(set (match_operand:V4SF 0 "register_operand" "=v")
18223         (unspec:V4SF [(match_operand:V4HI 1 "memory_operand" "m")]
18224                      UNSPEC_VCVTPH2PS))]
18225   "TARGET_F16C || TARGET_AVX512VL"
18226   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18227   [(set_attr "type" "ssecvt")
18228    (set_attr "prefix" "vex")
18229    (set_attr "mode" "V8SF")])
18231 (define_insn "vcvtph2ps256<mask_name>"
18232   [(set (match_operand:V8SF 0 "register_operand" "=v")
18233         (unspec:V8SF [(match_operand:V8HI 1 "nonimmediate_operand" "vm")]
18234                      UNSPEC_VCVTPH2PS))]
18235   "TARGET_F16C || TARGET_AVX512VL"
18236   "vcvtph2ps\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18237   [(set_attr "type" "ssecvt")
18238    (set_attr "prefix" "vex")
18239    (set_attr "btver2_decode" "double")
18240    (set_attr "mode" "V8SF")])
18242 (define_insn "<mask_codefor>avx512f_vcvtph2ps512<mask_name><round_saeonly_name>"
18243   [(set (match_operand:V16SF 0 "register_operand" "=v")
18244         (unspec:V16SF
18245           [(match_operand:V16HI 1 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")]
18246           UNSPEC_VCVTPH2PS))]
18247   "TARGET_AVX512F"
18248   "vcvtph2ps\t{<round_saeonly_mask_op2>%1, %0<mask_operand2>|%0<mask_operand2>, %1<round_saeonly_mask_op2>}"
18249   [(set_attr "type" "ssecvt")
18250    (set_attr "prefix" "evex")
18251    (set_attr "mode" "V16SF")])
18253 (define_expand "vcvtps2ph_mask"
18254   [(set (match_operand:V8HI 0 "register_operand")
18255         (vec_merge:V8HI
18256           (vec_concat:V8HI
18257             (unspec:V4HI [(match_operand:V4SF 1 "register_operand")
18258                           (match_operand:SI 2 "const_0_to_255_operand")]
18259                           UNSPEC_VCVTPS2PH)
18260             (match_dup 5))
18261            (match_operand:V8HI 3 "vector_move_operand")
18262            (match_operand:QI 4 "register_operand")))]
18263   "TARGET_AVX512VL"
18264   "operands[5] = CONST0_RTX (V4HImode);")
18266 (define_expand "vcvtps2ph"
18267   [(set (match_operand:V8HI 0 "register_operand")
18268         (vec_concat:V8HI
18269           (unspec:V4HI [(match_operand:V4SF 1 "register_operand")
18270                         (match_operand:SI 2 "const_0_to_255_operand")]
18271                        UNSPEC_VCVTPS2PH)
18272           (match_dup 3)))]
18273   "TARGET_F16C"
18274   "operands[3] = CONST0_RTX (V4HImode);")
18276 (define_insn "*vcvtps2ph<mask_name>"
18277   [(set (match_operand:V8HI 0 "register_operand" "=v")
18278         (vec_concat:V8HI
18279           (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "v")
18280                         (match_operand:SI 2 "const_0_to_255_operand" "N")]
18281                        UNSPEC_VCVTPS2PH)
18282           (match_operand:V4HI 3 "const0_operand")))]
18283   "(TARGET_F16C || TARGET_AVX512VL) && <mask_avx512vl_condition>"
18284   "vcvtps2ph\t{%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2}"
18285   [(set_attr "type" "ssecvt")
18286    (set_attr "prefix" "maybe_evex")
18287    (set_attr "mode" "V4SF")])
18289 (define_insn "*vcvtps2ph_store<mask_name>"
18290   [(set (match_operand:V4HI 0 "memory_operand" "=m")
18291         (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "x")
18292                       (match_operand:SI 2 "const_0_to_255_operand" "N")]
18293                      UNSPEC_VCVTPS2PH))]
18294   "TARGET_F16C || TARGET_AVX512VL"
18295   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18296   [(set_attr "type" "ssecvt")
18297    (set_attr "prefix" "maybe_evex")
18298    (set_attr "mode" "V4SF")])
18300 (define_insn "vcvtps2ph256<mask_name>"
18301   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=xm")
18302         (unspec:V8HI [(match_operand:V8SF 1 "register_operand" "x")
18303                       (match_operand:SI 2 "const_0_to_255_operand" "N")]
18304                      UNSPEC_VCVTPS2PH))]
18305   "TARGET_F16C || TARGET_AVX512VL"
18306   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18307   [(set_attr "type" "ssecvt")
18308    (set_attr "prefix" "maybe_evex")
18309    (set_attr "btver2_decode" "vector")
18310    (set_attr "mode" "V8SF")])
18312 (define_insn "<mask_codefor>avx512f_vcvtps2ph512<mask_name>"
18313   [(set (match_operand:V16HI 0 "nonimmediate_operand" "=vm")
18314         (unspec:V16HI
18315           [(match_operand:V16SF 1 "register_operand" "v")
18316            (match_operand:SI 2 "const_0_to_255_operand" "N")]
18317           UNSPEC_VCVTPS2PH))]
18318   "TARGET_AVX512F"
18319   "vcvtps2ph\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
18320   [(set_attr "type" "ssecvt")
18321    (set_attr "prefix" "evex")
18322    (set_attr "mode" "V16SF")])
18324 ;; For gather* insn patterns
18325 (define_mode_iterator VEC_GATHER_MODE
18326                       [V2DI V2DF V4DI V4DF V4SI V4SF V8SI V8SF])
18327 (define_mode_attr VEC_GATHER_IDXSI
18328                       [(V2DI "V4SI") (V4DI "V4SI") (V8DI "V8SI")
18329                        (V2DF "V4SI") (V4DF "V4SI") (V8DF "V8SI")
18330                        (V4SI "V4SI") (V8SI "V8SI") (V16SI "V16SI")
18331                        (V4SF "V4SI") (V8SF "V8SI") (V16SF "V16SI")])
18333 (define_mode_attr VEC_GATHER_IDXDI
18334                       [(V2DI "V2DI") (V4DI "V4DI") (V8DI "V8DI")
18335                        (V2DF "V2DI") (V4DF "V4DI") (V8DF "V8DI")
18336                        (V4SI "V2DI") (V8SI "V4DI") (V16SI "V8DI")
18337                        (V4SF "V2DI") (V8SF "V4DI") (V16SF "V8DI")])
18339 (define_mode_attr VEC_GATHER_SRCDI
18340                       [(V2DI "V2DI") (V4DI "V4DI") (V8DI "V8DI")
18341                        (V2DF "V2DF") (V4DF "V4DF") (V8DF "V8DF")
18342                        (V4SI "V4SI") (V8SI "V4SI") (V16SI "V8SI")
18343                        (V4SF "V4SF") (V8SF "V4SF") (V16SF "V8SF")])
18345 (define_expand "avx2_gathersi<mode>"
18346   [(parallel [(set (match_operand:VEC_GATHER_MODE 0 "register_operand")
18347                    (unspec:VEC_GATHER_MODE
18348                      [(match_operand:VEC_GATHER_MODE 1 "register_operand")
18349                       (mem:<ssescalarmode>
18350                         (match_par_dup 7
18351                           [(match_operand 2 "vsib_address_operand")
18352                            (match_operand:<VEC_GATHER_IDXSI>
18353                               3 "register_operand")
18354                            (match_operand:SI 5 "const1248_operand ")]))
18355                       (mem:BLK (scratch))
18356                       (match_operand:VEC_GATHER_MODE 4 "register_operand")]
18357                      UNSPEC_GATHER))
18358               (clobber (match_scratch:VEC_GATHER_MODE 6))])]
18359   "TARGET_AVX2"
18361   operands[7]
18362     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
18363                                         operands[5]), UNSPEC_VSIBADDR);
18366 (define_insn "*avx2_gathersi<mode>"
18367   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
18368         (unspec:VEC_GATHER_MODE
18369           [(match_operand:VEC_GATHER_MODE 2 "register_operand" "0")
18370            (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
18371              [(unspec:P
18372                 [(match_operand:P 3 "vsib_address_operand" "Tv")
18373                  (match_operand:<VEC_GATHER_IDXSI> 4 "register_operand" "x")
18374                  (match_operand:SI 6 "const1248_operand" "n")]
18375                 UNSPEC_VSIBADDR)])
18376            (mem:BLK (scratch))
18377            (match_operand:VEC_GATHER_MODE 5 "register_operand" "1")]
18378           UNSPEC_GATHER))
18379    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
18380   "TARGET_AVX2"
18381   "v<sseintprefix>gatherd<ssemodesuffix>\t{%1, %7, %0|%0, %7, %1}"
18382   [(set_attr "type" "ssemov")
18383    (set_attr "prefix" "vex")
18384    (set_attr "mode" "<sseinsnmode>")])
18386 (define_insn "*avx2_gathersi<mode>_2"
18387   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
18388         (unspec:VEC_GATHER_MODE
18389           [(pc)
18390            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
18391              [(unspec:P
18392                 [(match_operand:P 2 "vsib_address_operand" "Tv")
18393                  (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand" "x")
18394                  (match_operand:SI 5 "const1248_operand" "n")]
18395                 UNSPEC_VSIBADDR)])
18396            (mem:BLK (scratch))
18397            (match_operand:VEC_GATHER_MODE 4 "register_operand" "1")]
18398           UNSPEC_GATHER))
18399    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
18400   "TARGET_AVX2"
18401   "v<sseintprefix>gatherd<ssemodesuffix>\t{%1, %6, %0|%0, %6, %1}"
18402   [(set_attr "type" "ssemov")
18403    (set_attr "prefix" "vex")
18404    (set_attr "mode" "<sseinsnmode>")])
18406 (define_expand "avx2_gatherdi<mode>"
18407   [(parallel [(set (match_operand:VEC_GATHER_MODE 0 "register_operand")
18408                    (unspec:VEC_GATHER_MODE
18409                      [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand")
18410                       (mem:<ssescalarmode>
18411                         (match_par_dup 7
18412                           [(match_operand 2 "vsib_address_operand")
18413                            (match_operand:<VEC_GATHER_IDXDI>
18414                               3 "register_operand")
18415                            (match_operand:SI 5 "const1248_operand ")]))
18416                       (mem:BLK (scratch))
18417                       (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand")]
18418                      UNSPEC_GATHER))
18419               (clobber (match_scratch:VEC_GATHER_MODE 6))])]
18420   "TARGET_AVX2"
18422   operands[7]
18423     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
18424                                         operands[5]), UNSPEC_VSIBADDR);
18427 (define_insn "*avx2_gatherdi<mode>"
18428   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
18429         (unspec:VEC_GATHER_MODE
18430           [(match_operand:<VEC_GATHER_SRCDI> 2 "register_operand" "0")
18431            (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
18432              [(unspec:P
18433                 [(match_operand:P 3 "vsib_address_operand" "Tv")
18434                  (match_operand:<VEC_GATHER_IDXDI> 4 "register_operand" "x")
18435                  (match_operand:SI 6 "const1248_operand" "n")]
18436                 UNSPEC_VSIBADDR)])
18437            (mem:BLK (scratch))
18438            (match_operand:<VEC_GATHER_SRCDI> 5 "register_operand" "1")]
18439           UNSPEC_GATHER))
18440    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
18441   "TARGET_AVX2"
18442   "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %7, %2|%2, %7, %5}"
18443   [(set_attr "type" "ssemov")
18444    (set_attr "prefix" "vex")
18445    (set_attr "mode" "<sseinsnmode>")])
18447 (define_insn "*avx2_gatherdi<mode>_2"
18448   [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
18449         (unspec:VEC_GATHER_MODE
18450           [(pc)
18451            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
18452              [(unspec:P
18453                 [(match_operand:P 2 "vsib_address_operand" "Tv")
18454                  (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "x")
18455                  (match_operand:SI 5 "const1248_operand" "n")]
18456                 UNSPEC_VSIBADDR)])
18457            (mem:BLK (scratch))
18458            (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand" "1")]
18459           UNSPEC_GATHER))
18460    (clobber (match_scratch:VEC_GATHER_MODE 1 "=&x"))]
18461   "TARGET_AVX2"
18463   if (<MODE>mode != <VEC_GATHER_SRCDI>mode)
18464     return "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %x0|%x0, %6, %4}";
18465   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %0|%0, %6, %4}";
18467   [(set_attr "type" "ssemov")
18468    (set_attr "prefix" "vex")
18469    (set_attr "mode" "<sseinsnmode>")])
18471 (define_insn "*avx2_gatherdi<mode>_3"
18472   [(set (match_operand:<VEC_GATHER_SRCDI> 0 "register_operand" "=&x")
18473         (vec_select:<VEC_GATHER_SRCDI>
18474           (unspec:VI4F_256
18475             [(match_operand:<VEC_GATHER_SRCDI> 2 "register_operand" "0")
18476              (match_operator:<ssescalarmode> 7 "vsib_mem_operator"
18477                [(unspec:P
18478                   [(match_operand:P 3 "vsib_address_operand" "Tv")
18479                    (match_operand:<VEC_GATHER_IDXDI> 4 "register_operand" "x")
18480                    (match_operand:SI 6 "const1248_operand" "n")]
18481                   UNSPEC_VSIBADDR)])
18482              (mem:BLK (scratch))
18483              (match_operand:<VEC_GATHER_SRCDI> 5 "register_operand" "1")]
18484              UNSPEC_GATHER)
18485           (parallel [(const_int 0) (const_int 1)
18486                      (const_int 2) (const_int 3)])))
18487    (clobber (match_scratch:VI4F_256 1 "=&x"))]
18488   "TARGET_AVX2"
18489   "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %7, %0|%0, %7, %5}"
18490   [(set_attr "type" "ssemov")
18491    (set_attr "prefix" "vex")
18492    (set_attr "mode" "<sseinsnmode>")])
18494 (define_insn "*avx2_gatherdi<mode>_4"
18495   [(set (match_operand:<VEC_GATHER_SRCDI> 0 "register_operand" "=&x")
18496         (vec_select:<VEC_GATHER_SRCDI>
18497           (unspec:VI4F_256
18498             [(pc)
18499              (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
18500                [(unspec:P
18501                   [(match_operand:P 2 "vsib_address_operand" "Tv")
18502                    (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "x")
18503                    (match_operand:SI 5 "const1248_operand" "n")]
18504                   UNSPEC_VSIBADDR)])
18505              (mem:BLK (scratch))
18506              (match_operand:<VEC_GATHER_SRCDI> 4 "register_operand" "1")]
18507             UNSPEC_GATHER)
18508           (parallel [(const_int 0) (const_int 1)
18509                      (const_int 2) (const_int 3)])))
18510    (clobber (match_scratch:VI4F_256 1 "=&x"))]
18511   "TARGET_AVX2"
18512   "v<sseintprefix>gatherq<ssemodesuffix>\t{%4, %6, %0|%0, %6, %4}"
18513   [(set_attr "type" "ssemov")
18514    (set_attr "prefix" "vex")
18515    (set_attr "mode" "<sseinsnmode>")])
18517 (define_expand "<avx512>_gathersi<mode>"
18518   [(parallel [(set (match_operand:VI48F 0 "register_operand")
18519                    (unspec:VI48F
18520                      [(match_operand:VI48F 1 "register_operand")
18521                       (match_operand:<avx512fmaskmode> 4 "register_operand")
18522                       (mem:<ssescalarmode>
18523                         (match_par_dup 6
18524                           [(match_operand 2 "vsib_address_operand")
18525                            (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand")
18526                            (match_operand:SI 5 "const1248_operand")]))]
18527                      UNSPEC_GATHER))
18528               (clobber (match_scratch:<avx512fmaskmode> 7))])]
18529   "TARGET_AVX512F"
18531   operands[6]
18532     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
18533                                         operands[5]), UNSPEC_VSIBADDR);
18536 (define_insn "*avx512f_gathersi<mode>"
18537   [(set (match_operand:VI48F 0 "register_operand" "=&v")
18538         (unspec:VI48F
18539           [(match_operand:VI48F 1 "register_operand" "0")
18540            (match_operand:<avx512fmaskmode> 7 "register_operand" "2")
18541            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
18542              [(unspec:P
18543                 [(match_operand:P 4 "vsib_address_operand" "Tv")
18544                  (match_operand:<VEC_GATHER_IDXSI> 3 "register_operand" "v")
18545                  (match_operand:SI 5 "const1248_operand" "n")]
18546                 UNSPEC_VSIBADDR)])]
18547           UNSPEC_GATHER))
18548    (clobber (match_scratch:<avx512fmaskmode> 2 "=&Yk"))]
18549   "TARGET_AVX512F"
18550   "v<sseintprefix>gatherd<ssemodesuffix>\t{%6, %0%{%2%}|%0%{%2%}, %g6}"
18551   [(set_attr "type" "ssemov")
18552    (set_attr "prefix" "evex")
18553    (set_attr "mode" "<sseinsnmode>")])
18555 (define_insn "*avx512f_gathersi<mode>_2"
18556   [(set (match_operand:VI48F 0 "register_operand" "=&v")
18557         (unspec:VI48F
18558           [(pc)
18559            (match_operand:<avx512fmaskmode> 6 "register_operand" "1")
18560            (match_operator:<ssescalarmode> 5 "vsib_mem_operator"
18561              [(unspec:P
18562                 [(match_operand:P 3 "vsib_address_operand" "Tv")
18563                  (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand" "v")
18564                  (match_operand:SI 4 "const1248_operand" "n")]
18565                 UNSPEC_VSIBADDR)])]
18566           UNSPEC_GATHER))
18567    (clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
18568   "TARGET_AVX512F"
18569   "v<sseintprefix>gatherd<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %g5}"
18570   [(set_attr "type" "ssemov")
18571    (set_attr "prefix" "evex")
18572    (set_attr "mode" "<sseinsnmode>")])
18575 (define_expand "<avx512>_gatherdi<mode>"
18576   [(parallel [(set (match_operand:VI48F 0 "register_operand")
18577                    (unspec:VI48F
18578                      [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand")
18579                       (match_operand:QI 4 "register_operand")
18580                       (mem:<ssescalarmode>
18581                         (match_par_dup 6
18582                           [(match_operand 2 "vsib_address_operand")
18583                            (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand")
18584                            (match_operand:SI 5 "const1248_operand")]))]
18585                      UNSPEC_GATHER))
18586               (clobber (match_scratch:QI 7))])]
18587   "TARGET_AVX512F"
18589   operands[6]
18590     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[2], operands[3],
18591                                         operands[5]), UNSPEC_VSIBADDR);
18594 (define_insn "*avx512f_gatherdi<mode>"
18595   [(set (match_operand:VI48F 0 "register_operand" "=&v")
18596         (unspec:VI48F
18597           [(match_operand:<VEC_GATHER_SRCDI> 1 "register_operand" "0")
18598            (match_operand:QI 7 "register_operand" "2")
18599            (match_operator:<ssescalarmode> 6 "vsib_mem_operator"
18600              [(unspec:P
18601                 [(match_operand:P 4 "vsib_address_operand" "Tv")
18602                  (match_operand:<VEC_GATHER_IDXDI> 3 "register_operand" "v")
18603                  (match_operand:SI 5 "const1248_operand" "n")]
18604                 UNSPEC_VSIBADDR)])]
18605           UNSPEC_GATHER))
18606    (clobber (match_scratch:QI 2 "=&Yk"))]
18607   "TARGET_AVX512F"
18609   if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 4)
18610     return "v<sseintprefix>gatherq<ssemodesuffix>\t{%6, %1%{%2%}|%1%{%2%}, %t6}";
18611   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%6, %1%{%2%}|%1%{%2%}, %g6}";
18613   [(set_attr "type" "ssemov")
18614    (set_attr "prefix" "evex")
18615    (set_attr "mode" "<sseinsnmode>")])
18617 (define_insn "*avx512f_gatherdi<mode>_2"
18618   [(set (match_operand:VI48F 0 "register_operand" "=&v")
18619         (unspec:VI48F
18620           [(pc)
18621            (match_operand:QI 6 "register_operand" "1")
18622            (match_operator:<ssescalarmode> 5 "vsib_mem_operator"
18623              [(unspec:P
18624                 [(match_operand:P 3 "vsib_address_operand" "Tv")
18625                  (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand" "v")
18626                  (match_operand:SI 4 "const1248_operand" "n")]
18627                 UNSPEC_VSIBADDR)])]
18628           UNSPEC_GATHER))
18629    (clobber (match_scratch:QI 1 "=&Yk"))]
18630   "TARGET_AVX512F"
18632   if (<MODE>mode != <VEC_GATHER_SRCDI>mode)
18633     {
18634       if (<MODE_SIZE> != 64)
18635         return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %x0%{%1%}|%t0%{%1%}, %g5}";
18636       else
18637         return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %t0%{%1%}|%t0%{%1%}, %g5}";
18638     }
18639   return "v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %g5}";
18641   [(set_attr "type" "ssemov")
18642    (set_attr "prefix" "evex")
18643    (set_attr "mode" "<sseinsnmode>")])
18645 (define_expand "<avx512>_scattersi<mode>"
18646   [(parallel [(set (mem:VI48F
18647                      (match_par_dup 5
18648                        [(match_operand 0 "vsib_address_operand")
18649                         (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand")
18650                         (match_operand:SI 4 "const1248_operand")]))
18651                    (unspec:VI48F
18652                      [(match_operand:<avx512fmaskmode> 1 "register_operand")
18653                       (match_operand:VI48F 3 "register_operand")]
18654                      UNSPEC_SCATTER))
18655               (clobber (match_scratch:<avx512fmaskmode> 6))])]
18656   "TARGET_AVX512F"
18658   operands[5]
18659     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[0], operands[2],
18660                                         operands[4]), UNSPEC_VSIBADDR);
18663 (define_insn "*avx512f_scattersi<mode>"
18664   [(set (match_operator:VI48F 5 "vsib_mem_operator"
18665           [(unspec:P
18666              [(match_operand:P 0 "vsib_address_operand" "Tv")
18667               (match_operand:<VEC_GATHER_IDXSI> 2 "register_operand" "v")
18668               (match_operand:SI 4 "const1248_operand" "n")]
18669              UNSPEC_VSIBADDR)])
18670         (unspec:VI48F
18671           [(match_operand:<avx512fmaskmode> 6 "register_operand" "1")
18672            (match_operand:VI48F 3 "register_operand" "v")]
18673           UNSPEC_SCATTER))
18674    (clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
18675   "TARGET_AVX512F"
18676   "v<sseintprefix>scatterd<ssemodesuffix>\t{%3, %5%{%1%}|%5%{%1%}, %3}"
18677   [(set_attr "type" "ssemov")
18678    (set_attr "prefix" "evex")
18679    (set_attr "mode" "<sseinsnmode>")])
18681 (define_expand "<avx512>_scatterdi<mode>"
18682   [(parallel [(set (mem:VI48F
18683                      (match_par_dup 5
18684                        [(match_operand 0 "vsib_address_operand")
18685                         (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand")
18686                         (match_operand:SI 4 "const1248_operand")]))
18687                    (unspec:VI48F
18688                      [(match_operand:QI 1 "register_operand")
18689                       (match_operand:<VEC_GATHER_SRCDI> 3 "register_operand")]
18690                      UNSPEC_SCATTER))
18691               (clobber (match_scratch:QI 6))])]
18692   "TARGET_AVX512F"
18694   operands[5]
18695     = gen_rtx_UNSPEC (Pmode, gen_rtvec (3, operands[0], operands[2],
18696                                         operands[4]), UNSPEC_VSIBADDR);
18699 (define_insn "*avx512f_scatterdi<mode>"
18700   [(set (match_operator:VI48F 5 "vsib_mem_operator"
18701           [(unspec:P
18702              [(match_operand:P 0 "vsib_address_operand" "Tv")
18703               (match_operand:<VEC_GATHER_IDXDI> 2 "register_operand" "v")
18704               (match_operand:SI 4 "const1248_operand" "n")]
18705              UNSPEC_VSIBADDR)])
18706         (unspec:VI48F
18707           [(match_operand:QI 6 "register_operand" "1")
18708            (match_operand:<VEC_GATHER_SRCDI> 3 "register_operand" "v")]
18709           UNSPEC_SCATTER))
18710    (clobber (match_scratch:QI 1 "=&Yk"))]
18711   "TARGET_AVX512F"
18713   if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 8)
18714     return "v<sseintprefix>scatterq<ssemodesuffix>\t{%3, %5%{%1%}|%5%{%1%}, %3}";
18715   return "v<sseintprefix>scatterq<ssemodesuffix>\t{%3, %5%{%1%}|%t5%{%1%}, %3}";
18717   [(set_attr "type" "ssemov")
18718    (set_attr "prefix" "evex")
18719    (set_attr "mode" "<sseinsnmode>")])
18721 (define_insn "<avx512>_compress<mode>_mask"
18722   [(set (match_operand:VI48F 0 "register_operand" "=v")
18723         (unspec:VI48F
18724           [(match_operand:VI48F 1 "register_operand" "v")
18725            (match_operand:VI48F 2 "vector_move_operand" "0C")
18726            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk")]
18727           UNSPEC_COMPRESS))]
18728   "TARGET_AVX512F"
18729   "v<sseintprefix>compress<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
18730   [(set_attr "type" "ssemov")
18731    (set_attr "prefix" "evex")
18732    (set_attr "mode" "<sseinsnmode>")])
18734 (define_insn "<avx512>_compressstore<mode>_mask"
18735   [(set (match_operand:VI48F 0 "memory_operand" "=m")
18736         (unspec:VI48F
18737           [(match_operand:VI48F 1 "register_operand" "x")
18738            (match_dup 0)
18739            (match_operand:<avx512fmaskmode> 2 "register_operand" "Yk")]
18740           UNSPEC_COMPRESS_STORE))]
18741   "TARGET_AVX512F"
18742   "v<sseintprefix>compress<ssemodesuffix>\t{%1, %0%{%2%}|%0%{%2%}, %1}"
18743   [(set_attr "type" "ssemov")
18744    (set_attr "prefix" "evex")
18745    (set_attr "memory" "store")
18746    (set_attr "mode" "<sseinsnmode>")])
18748 (define_expand "<avx512>_expand<mode>_maskz"
18749   [(set (match_operand:VI48F 0 "register_operand")
18750         (unspec:VI48F
18751           [(match_operand:VI48F 1 "nonimmediate_operand")
18752            (match_operand:VI48F 2 "vector_move_operand")
18753            (match_operand:<avx512fmaskmode> 3 "register_operand")]
18754           UNSPEC_EXPAND))]
18755   "TARGET_AVX512F"
18756   "operands[2] = CONST0_RTX (<MODE>mode);")
18758 (define_insn "<avx512>_expand<mode>_mask"
18759   [(set (match_operand:VI48F 0 "register_operand" "=v,v")
18760         (unspec:VI48F
18761           [(match_operand:VI48F 1 "nonimmediate_operand" "v,m")
18762            (match_operand:VI48F 2 "vector_move_operand" "0C,0C")
18763            (match_operand:<avx512fmaskmode> 3 "register_operand" "Yk,Yk")]
18764           UNSPEC_EXPAND))]
18765   "TARGET_AVX512F"
18766   "v<sseintprefix>expand<ssemodesuffix>\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
18767   [(set_attr "type" "ssemov")
18768    (set_attr "prefix" "evex")
18769    (set_attr "memory" "none,load")
18770    (set_attr "mode" "<sseinsnmode>")])
18772 (define_insn "avx512dq_rangep<mode><mask_name><round_saeonly_name>"
18773   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
18774         (unspec:VF_AVX512VL
18775           [(match_operand:VF_AVX512VL 1 "register_operand" "v")
18776            (match_operand:VF_AVX512VL 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
18777            (match_operand:SI 3 "const_0_to_15_operand")]
18778           UNSPEC_RANGE))]
18779   "TARGET_AVX512DQ && <round_saeonly_mode512bit_condition>"
18780   "vrange<ssemodesuffix>\t{%3, <round_saeonly_mask_op4>%2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2<round_saeonly_mask_op4>, %3}"
18781   [(set_attr "type" "sse")
18782    (set_attr "prefix" "evex")
18783    (set_attr "mode" "<MODE>")])
18785 (define_insn "avx512dq_ranges<mode><round_saeonly_name>"
18786   [(set (match_operand:VF_128 0 "register_operand" "=v")
18787         (vec_merge:VF_128
18788           (unspec:VF_128
18789             [(match_operand:VF_128 1 "register_operand" "v")
18790              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
18791              (match_operand:SI 3 "const_0_to_15_operand")]
18792             UNSPEC_RANGE)
18793           (match_dup 1)
18794           (const_int 1)))]
18795   "TARGET_AVX512DQ"
18796   "vrange<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %2<round_saeonly_op4>, %3}"
18797   [(set_attr "type" "sse")
18798    (set_attr "prefix" "evex")
18799    (set_attr "mode" "<MODE>")])
18801 (define_insn "avx512dq_fpclass<mode><mask_scalar_merge_name>"
18802   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
18803           (unspec:<avx512fmaskmode>
18804             [(match_operand:VF_AVX512VL 1 "register_operand" "v")
18805              (match_operand:QI 2 "const_0_to_255_operand" "n")]
18806              UNSPEC_FPCLASS))]
18807    "TARGET_AVX512DQ"
18808    "vfpclass<ssemodesuffix>\t{%2, %1, %0<mask_scalar_merge_operand3>|%0<mask_scalar_merge_operand3>, %1, %2}";
18809   [(set_attr "type" "sse")
18810    (set_attr "length_immediate" "1")
18811    (set_attr "prefix" "evex")
18812    (set_attr "mode" "<MODE>")])
18814 (define_insn "avx512dq_vmfpclass<mode>"
18815   [(set (match_operand:<avx512fmaskmode> 0 "register_operand" "=Yk")
18816         (and:<avx512fmaskmode>
18817           (unspec:<avx512fmaskmode>
18818             [(match_operand:VF_128 1 "register_operand" "v")
18819              (match_operand:QI 2 "const_0_to_255_operand" "n")]
18820             UNSPEC_FPCLASS)
18821           (const_int 1)))]
18822    "TARGET_AVX512DQ"
18823    "vfpclass<ssescalarmodesuffix>\t{%2, %1, %0|%0, %1, %2}";
18824   [(set_attr "type" "sse")
18825    (set_attr "length_immediate" "1")
18826    (set_attr "prefix" "evex")
18827    (set_attr "mode" "<MODE>")])
18829 (define_insn "<avx512>_getmant<mode><mask_name><round_saeonly_name>"
18830   [(set (match_operand:VF_AVX512VL 0 "register_operand" "=v")
18831         (unspec:VF_AVX512VL
18832           [(match_operand:VF_AVX512VL 1 "nonimmediate_operand" "<round_saeonly_constraint>")
18833            (match_operand:SI 2 "const_0_to_15_operand")]
18834           UNSPEC_GETMANT))]
18835   "TARGET_AVX512F"
18836   "vgetmant<ssemodesuffix>\t{%2, <round_saeonly_mask_op3>%1, %0<mask_operand3>|%0<mask_operand3>, %1<round_saeonly_mask_op3>, %2}";
18837   [(set_attr "prefix" "evex")
18838    (set_attr "mode" "<MODE>")])
18840 (define_insn "avx512f_vgetmant<mode><round_saeonly_name>"
18841   [(set (match_operand:VF_128 0 "register_operand" "=v")
18842         (vec_merge:VF_128
18843           (unspec:VF_128
18844             [(match_operand:VF_128 1 "register_operand" "v")
18845              (match_operand:VF_128 2 "<round_saeonly_nimm_predicate>" "<round_saeonly_constraint>")
18846              (match_operand:SI 3 "const_0_to_15_operand")]
18847             UNSPEC_GETMANT)
18848           (match_dup 1)
18849           (const_int 1)))]
18850    "TARGET_AVX512F"
18851    "vgetmant<ssescalarmodesuffix>\t{%3, <round_saeonly_op4>%2, %1, %0|%0, %1, %2<round_saeonly_op4>, %3}";
18852    [(set_attr "prefix" "evex")
18853    (set_attr "mode" "<ssescalarmode>")])
18855 ;; The correct representation for this is absolutely enormous, and
18856 ;; surely not generally useful.
18857 (define_insn "<mask_codefor>avx512bw_dbpsadbw<mode><mask_name>"
18858   [(set (match_operand:VI2_AVX512VL 0 "register_operand" "=v")
18859         (unspec:VI2_AVX512VL
18860           [(match_operand:<dbpsadbwmode> 1 "register_operand" "v")
18861            (match_operand:<dbpsadbwmode> 2 "nonimmediate_operand" "vm")
18862            (match_operand:SI 3 "const_0_to_255_operand")]
18863           UNSPEC_DBPSADBW))]
18864    "TARGET_AVX512BW"
18865   "vdbpsadbw\t{%3, %2, %1, %0<mask_operand4>|%0<mask_operand4>, %1, %2, %3}"
18866   [(set_attr "isa" "avx")
18867    (set_attr "type" "sselog1")
18868    (set_attr "length_immediate" "1")
18869    (set_attr "prefix" "evex")
18870    (set_attr "mode" "<sseinsnmode>")])
18872 (define_insn "clz<mode>2<mask_name>"
18873   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
18874         (clz:VI48_AVX512VL
18875           (match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")))]
18876   "TARGET_AVX512CD"
18877   "vplzcnt<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18878   [(set_attr "type" "sse")
18879    (set_attr "prefix" "evex")
18880    (set_attr "mode" "<sseinsnmode>")])
18882 (define_insn "<mask_codefor>conflict<mode><mask_name>"
18883   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
18884         (unspec:VI48_AVX512VL
18885           [(match_operand:VI48_AVX512VL 1 "nonimmediate_operand" "vm")]
18886           UNSPEC_CONFLICT))]
18887   "TARGET_AVX512CD"
18888   "vpconflict<ssemodesuffix>\t{%1, %0<mask_operand2>|%0<mask_operand2>, %1}"
18889   [(set_attr "type" "sse")
18890    (set_attr "prefix" "evex")
18891    (set_attr "mode" "<sseinsnmode>")])
18893 (define_insn "sha1msg1"
18894   [(set (match_operand:V4SI 0 "register_operand" "=x")
18895         (unspec:V4SI
18896           [(match_operand:V4SI 1 "register_operand" "0")
18897            (match_operand:V4SI 2 "vector_operand" "xBm")]
18898           UNSPEC_SHA1MSG1))]
18899   "TARGET_SHA"
18900   "sha1msg1\t{%2, %0|%0, %2}"
18901   [(set_attr "type" "sselog1")
18902    (set_attr "mode" "TI")])
18904 (define_insn "sha1msg2"
18905   [(set (match_operand:V4SI 0 "register_operand" "=x")
18906         (unspec:V4SI
18907           [(match_operand:V4SI 1 "register_operand" "0")
18908            (match_operand:V4SI 2 "vector_operand" "xBm")]
18909           UNSPEC_SHA1MSG2))]
18910   "TARGET_SHA"
18911   "sha1msg2\t{%2, %0|%0, %2}"
18912   [(set_attr "type" "sselog1")
18913    (set_attr "mode" "TI")])
18915 (define_insn "sha1nexte"
18916   [(set (match_operand:V4SI 0 "register_operand" "=x")
18917         (unspec:V4SI
18918           [(match_operand:V4SI 1 "register_operand" "0")
18919            (match_operand:V4SI 2 "vector_operand" "xBm")]
18920           UNSPEC_SHA1NEXTE))]
18921   "TARGET_SHA"
18922   "sha1nexte\t{%2, %0|%0, %2}"
18923   [(set_attr "type" "sselog1")
18924    (set_attr "mode" "TI")])
18926 (define_insn "sha1rnds4"
18927   [(set (match_operand:V4SI 0 "register_operand" "=x")
18928         (unspec:V4SI
18929           [(match_operand:V4SI 1 "register_operand" "0")
18930            (match_operand:V4SI 2 "vector_operand" "xBm")
18931            (match_operand:SI 3 "const_0_to_3_operand" "n")]
18932           UNSPEC_SHA1RNDS4))]
18933   "TARGET_SHA"
18934   "sha1rnds4\t{%3, %2, %0|%0, %2, %3}"
18935   [(set_attr "type" "sselog1")
18936    (set_attr "length_immediate" "1")
18937    (set_attr "mode" "TI")])
18939 (define_insn "sha256msg1"
18940   [(set (match_operand:V4SI 0 "register_operand" "=x")
18941         (unspec:V4SI
18942           [(match_operand:V4SI 1 "register_operand" "0")
18943            (match_operand:V4SI 2 "vector_operand" "xBm")]
18944           UNSPEC_SHA256MSG1))]
18945   "TARGET_SHA"
18946   "sha256msg1\t{%2, %0|%0, %2}"
18947   [(set_attr "type" "sselog1")
18948    (set_attr "mode" "TI")])
18950 (define_insn "sha256msg2"
18951   [(set (match_operand:V4SI 0 "register_operand" "=x")
18952         (unspec:V4SI
18953           [(match_operand:V4SI 1 "register_operand" "0")
18954            (match_operand:V4SI 2 "vector_operand" "xBm")]
18955           UNSPEC_SHA256MSG2))]
18956   "TARGET_SHA"
18957   "sha256msg2\t{%2, %0|%0, %2}"
18958   [(set_attr "type" "sselog1")
18959    (set_attr "mode" "TI")])
18961 (define_insn "sha256rnds2"
18962   [(set (match_operand:V4SI 0 "register_operand" "=x")
18963         (unspec:V4SI
18964           [(match_operand:V4SI 1 "register_operand" "0")
18965            (match_operand:V4SI 2 "vector_operand" "xBm")
18966            (match_operand:V4SI 3 "register_operand" "Yz")]
18967           UNSPEC_SHA256RNDS2))]
18968   "TARGET_SHA"
18969   "sha256rnds2\t{%3, %2, %0|%0, %2, %3}"
18970   [(set_attr "type" "sselog1")
18971    (set_attr "length_immediate" "1")
18972    (set_attr "mode" "TI")])
18974 (define_insn_and_split "avx512f_<castmode><avxsizesuffix>_<castmode>"
18975   [(set (match_operand:AVX512MODE2P 0 "nonimmediate_operand" "=x,m")
18976         (unspec:AVX512MODE2P
18977           [(match_operand:<ssequartermode> 1 "nonimmediate_operand" "xm,x")]
18978           UNSPEC_CAST))]
18979   "TARGET_AVX512F"
18980   "#"
18981   "&& reload_completed"
18982   [(set (match_dup 0) (match_dup 1))]
18984   if (REG_P (operands[0]))
18985     operands[0] = gen_lowpart (<ssequartermode>mode, operands[0]);
18986   else
18987     operands[1] = lowpart_subreg (<MODE>mode, operands[1],
18988                                   <ssequartermode>mode);
18991 (define_insn_and_split "avx512f_<castmode><avxsizesuffix>_256<castmode>"
18992   [(set (match_operand:AVX512MODE2P 0 "nonimmediate_operand" "=x,m")
18993         (unspec:AVX512MODE2P
18994           [(match_operand:<ssehalfvecmode> 1 "nonimmediate_operand" "xm,x")]
18995           UNSPEC_CAST))]
18996   "TARGET_AVX512F"
18997   "#"
18998   "&& reload_completed"
18999   [(set (match_dup 0) (match_dup 1))]
19001   if (REG_P (operands[0]))
19002     operands[0] = gen_lowpart (<ssehalfvecmode>mode, operands[0]);
19003   else
19004     operands[1] = lowpart_subreg (<MODE>mode, operands[1],
19005                                   <ssehalfvecmode>mode);
19008 (define_int_iterator VPMADD52
19009         [UNSPEC_VPMADD52LUQ
19010          UNSPEC_VPMADD52HUQ])
19012 (define_int_attr vpmadd52type
19013   [(UNSPEC_VPMADD52LUQ "luq") (UNSPEC_VPMADD52HUQ "huq")])
19015 (define_expand "vpamdd52huq<mode>_maskz"
19016   [(match_operand:VI8_AVX512VL 0 "register_operand")
19017    (match_operand:VI8_AVX512VL 1 "register_operand")
19018    (match_operand:VI8_AVX512VL 2 "register_operand")
19019    (match_operand:VI8_AVX512VL 3 "nonimmediate_operand")
19020    (match_operand:<avx512fmaskmode> 4 "register_operand")]
19021   "TARGET_AVX512IFMA"
19023   emit_insn (gen_vpamdd52huq<mode>_maskz_1 (
19024     operands[0], operands[1], operands[2], operands[3],
19025     CONST0_RTX (<MODE>mode), operands[4]));
19026   DONE;
19029 (define_expand "vpamdd52luq<mode>_maskz"
19030   [(match_operand:VI8_AVX512VL 0 "register_operand")
19031    (match_operand:VI8_AVX512VL 1 "register_operand")
19032    (match_operand:VI8_AVX512VL 2 "register_operand")
19033    (match_operand:VI8_AVX512VL 3 "nonimmediate_operand")
19034    (match_operand:<avx512fmaskmode> 4 "register_operand")]
19035   "TARGET_AVX512IFMA"
19037   emit_insn (gen_vpamdd52luq<mode>_maskz_1 (
19038     operands[0], operands[1], operands[2], operands[3],
19039     CONST0_RTX (<MODE>mode), operands[4]));
19040   DONE;
19043 (define_insn "vpamdd52<vpmadd52type><mode><sd_maskz_name>"
19044   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
19045         (unspec:VI8_AVX512VL
19046           [(match_operand:VI8_AVX512VL 1 "register_operand" "0")
19047            (match_operand:VI8_AVX512VL 2 "register_operand" "v")
19048            (match_operand:VI8_AVX512VL 3 "nonimmediate_operand" "vm")]
19049           VPMADD52))]
19050   "TARGET_AVX512IFMA"
19051   "vpmadd52<vpmadd52type>\t{%3, %2, %0<sd_mask_op4>|%0<sd_mask_op4>, %2, %3}"
19052   [(set_attr "type" "ssemuladd")
19053    (set_attr "prefix" "evex")
19054    (set_attr "mode" "<sseinsnmode>")])
19056 (define_insn "vpamdd52<vpmadd52type><mode>_mask"
19057   [(set (match_operand:VI8_AVX512VL 0 "register_operand" "=v")
19058         (vec_merge:VI8_AVX512VL
19059           (unspec:VI8_AVX512VL
19060             [(match_operand:VI8_AVX512VL 1 "register_operand" "0")
19061              (match_operand:VI8_AVX512VL 2 "register_operand" "v")
19062              (match_operand:VI8_AVX512VL 3 "nonimmediate_operand" "vm")]
19063             VPMADD52)
19064           (match_dup 1)
19065           (match_operand:<avx512fmaskmode> 4 "register_operand" "Yk")))]
19066   "TARGET_AVX512IFMA"
19067   "vpmadd52<vpmadd52type>\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
19068   [(set_attr "type" "ssemuladd")
19069    (set_attr "prefix" "evex")
19070    (set_attr "mode" "<sseinsnmode>")])
19072 (define_insn "vpmultishiftqb<mode><mask_name>"
19073   [(set (match_operand:VI1_AVX512VL 0 "register_operand" "=v")
19074         (unspec:VI1_AVX512VL
19075           [(match_operand:VI1_AVX512VL 1 "register_operand" "v")
19076            (match_operand:VI1_AVX512VL 2 "nonimmediate_operand" "vm")]
19077           UNSPEC_VPMULTISHIFT))]
19078   "TARGET_AVX512VBMI"
19079   "vpmultishiftqb\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
19080   [(set_attr "type" "sselog")
19081    (set_attr "prefix" "evex")
19082    (set_attr "mode" "<sseinsnmode>")])