gcc/
[official-gcc.git] / gcc / config / arm / neon.md
blobc62ffc3cff674665f622003de8a4d5ce2ad20c96
1 ;; ARM NEON coprocessor Machine Description
2 ;; Copyright (C) 2006 Free Software Foundation, Inc.
3 ;; Written by CodeSourcery.
4 ;;
5 ;; This file is part of GCC.
6 ;;
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
12 ;; GCC is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 ;; General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING.  If not, write to the Free
19 ;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20 ;; 02110-1301, USA.
22 ;; Constants for unspecs.
23 (define_constants
24   [(UNSPEC_ASHIFT_SIGNED        65)
25    (UNSPEC_ASHIFT_UNSIGNED      66)
26    (UNSPEC_VABA                 67)
27    (UNSPEC_VABAL                68)
28    (UNSPEC_VABD                 69)
29    (UNSPEC_VABDL                70)
30    (UNSPEC_VABS                 71)
31    (UNSPEC_VADD                 72)
32    (UNSPEC_VADDHN               73)
33    (UNSPEC_VADDL                74)
34    (UNSPEC_VADDW                75)
35    (UNSPEC_VAND                 76)
36    (UNSPEC_VBIC                 77)
37    (UNSPEC_VBSL                 78)
38    (UNSPEC_VCAGE                79)
39    (UNSPEC_VCAGT                80)
40    (UNSPEC_VCEQ                 81)
41    (UNSPEC_VCGE                 82)
42    (UNSPEC_VCGT                 83)
43    (UNSPEC_VCLS                 84)
44    (UNSPEC_VCLZ                 85)
45    (UNSPEC_VCNT                 86)
46    (UNSPEC_VCOMBINE             87)
47    (UNSPEC_VCVT                 88)
48    (UNSPEC_VCVT_N               89)
49    (UNSPEC_VDUP_LANE            90)
50    (UNSPEC_VDUP_N               91)
51    (UNSPEC_VEOR                 92)
52    (UNSPEC_VEXT                 93)
53    (UNSPEC_VGET_HIGH            94)
54    (UNSPEC_VGET_LANE            95)
55    (UNSPEC_VGET_LOW             96)
56    (UNSPEC_VHADD                97)
57    (UNSPEC_VHSUB                98)
58    (UNSPEC_VLD1                 99)
59    (UNSPEC_VLD1_DUP             100)
60    (UNSPEC_VLD1_LANE            101)
61    (UNSPEC_VLD2                 102)
62    (UNSPEC_VLD2_DUP             103)
63    (UNSPEC_VLD2_LANE            104)
64    (UNSPEC_VLD3                 105)
65    (UNSPEC_VLD3A                106)
66    (UNSPEC_VLD3B                107)
67    (UNSPEC_VLD3_DUP             108)
68    (UNSPEC_VLD3_LANE            109)
69    (UNSPEC_VLD4                 110)
70    (UNSPEC_VLD4A                111)
71    (UNSPEC_VLD4B                112)
72    (UNSPEC_VLD4_DUP             113)
73    (UNSPEC_VLD4_LANE            114)
74    (UNSPEC_VMAX                 115)
75    (UNSPEC_VMIN                 116)
76    (UNSPEC_VMLA                 117)
77    (UNSPEC_VMLAL                118)
78    (UNSPEC_VMLA_LANE            119)
79    (UNSPEC_VMLAL_LANE           120)
80    (UNSPEC_VMLS                 121)
81    (UNSPEC_VMLSL                122)
82    (UNSPEC_VMLS_LANE            123)
83    (UNSPEC_VMLSL_LANE           124)
84    (UNSPEC_VMOVL                125)
85    (UNSPEC_VMOVN                126)
86    (UNSPEC_VMUL                 127)
87    (UNSPEC_VMULL                128)
88    (UNSPEC_VMUL_LANE            129)
89    (UNSPEC_VMULL_LANE           130)
90    (UNSPEC_VMUL_N               131)
91    (UNSPEC_VMVN                 132)
92    (UNSPEC_VORN                 133)
93    (UNSPEC_VORR                 134)
94    (UNSPEC_VPADAL               135)
95    (UNSPEC_VPADD                136)
96    (UNSPEC_VPADDL               137)
97    (UNSPEC_VPMAX                138)
98    (UNSPEC_VPMIN                139)
99    (UNSPEC_VPSMAX               140)
100    (UNSPEC_VPSMIN               141)
101    (UNSPEC_VPUMAX               142)
102    (UNSPEC_VPUMIN               143)
103    (UNSPEC_VQABS                144)
104    (UNSPEC_VQADD                145)
105    (UNSPEC_VQDMLAL              146)
106    (UNSPEC_VQDMLAL_LANE         147)
107    (UNSPEC_VQDMLSL              148)
108    (UNSPEC_VQDMLSL_LANE         149)
109    (UNSPEC_VQDMULH              150)
110    (UNSPEC_VQDMULH_LANE         151)
111    (UNSPEC_VQDMULL              152)
112    (UNSPEC_VQDMULL_LANE         153)
113    (UNSPEC_VQMOVN               154)
114    (UNSPEC_VQMOVUN              155)
115    (UNSPEC_VQNEG                156)
116    (UNSPEC_VQSHL                157)
117    (UNSPEC_VQSHL_N              158)
118    (UNSPEC_VQSHLU_N             159)
119    (UNSPEC_VQSHRN_N             160)
120    (UNSPEC_VQSHRUN_N            161)
121    (UNSPEC_VQSUB                162)
122    (UNSPEC_VRECPE               163)
123    (UNSPEC_VRECPS               164)
124    (UNSPEC_VREV16               165)
125    (UNSPEC_VREV32               166)
126    (UNSPEC_VREV64               167)
127    (UNSPEC_VRSQRTE              168)
128    (UNSPEC_VRSQRTS              169)
129    (UNSPEC_VSET_LANE            170)
130    (UNSPEC_VSHL                 171)
131    (UNSPEC_VSHLL_N              172)
132    (UNSPEC_VSHL_N               173)
133    (UNSPEC_VSHR_N               174)
134    (UNSPEC_VSHRN_N              175)
135    (UNSPEC_VSLI                 176)
136    (UNSPEC_VSRA_N               177)
137    (UNSPEC_VSRI                 178)
138    (UNSPEC_VST1                 179)
139    (UNSPEC_VST1_LANE            180)
140    (UNSPEC_VST2                 181)
141    (UNSPEC_VST2_LANE            182)
142    (UNSPEC_VST3                 183)
143    (UNSPEC_VST3A                184)
144    (UNSPEC_VST3B                185)
145    (UNSPEC_VST3_LANE            186)
146    (UNSPEC_VST4                 187)
147    (UNSPEC_VST4A                188)
148    (UNSPEC_VST4B                189)
149    (UNSPEC_VST4_LANE            190)
150    (UNSPEC_VSTRUCTDUMMY         191)
151    (UNSPEC_VSUB                 192)
152    (UNSPEC_VSUBHN               193)
153    (UNSPEC_VSUBL                194)
154    (UNSPEC_VSUBW                195)
155    (UNSPEC_VTBL                 196)
156    (UNSPEC_VTBX                 197)
157    (UNSPEC_VTRN1                198)
158    (UNSPEC_VTRN2                199)
159    (UNSPEC_VTST                 200)
160    (UNSPEC_VUZP1                201)
161    (UNSPEC_VUZP2                202)
162    (UNSPEC_VZIP1                203)
163    (UNSPEC_VZIP2                204)])
165 ;; Double-width vector modes.
166 (define_mode_macro VD [V8QI V4HI V2SI V2SF])
168 ;; Double-width vector modes plus 64-bit elements.
169 (define_mode_macro VDX [V8QI V4HI V2SI V2SF DI])
171 ;; Same, without floating-point elements.
172 (define_mode_macro VDI [V8QI V4HI V2SI])
174 ;; Quad-width vector modes.
175 (define_mode_macro VQ [V16QI V8HI V4SI V4SF])
177 ;; Quad-width vector modes plus 64-bit elements.
178 (define_mode_macro VQX [V16QI V8HI V4SI V4SF V2DI])
180 ;; Same, without floating-point elements.
181 (define_mode_macro VQI [V16QI V8HI V4SI])
183 ;; Same, with TImode added, for moves.
184 (define_mode_macro VQXMOV [V16QI V8HI V4SI V4SF V2DI TI])
186 ;; Opaque structure types wider than TImode.
187 (define_mode_macro VSTRUCT [EI OI CI XI])
189 ;; Number of instructions needed to load/store struct elements. FIXME!
190 (define_mode_attr V_slen [(EI "2") (OI "2") (CI "3") (XI "4")])
192 ;; Opaque structure types used in table lookups (except vtbl1/vtbx1).
193 (define_mode_macro VTAB [TI EI OI])
195 ;; vtbl<n> suffix for above modes.
196 (define_mode_attr VTAB_n [(TI "2") (EI "3") (OI "4")])
198 ;; Widenable modes.
199 (define_mode_macro VW [V8QI V4HI V2SI])
201 ;; Narrowable modes.
202 (define_mode_macro VN [V8HI V4SI V2DI])
204 ;; All supported vector modes (except singleton DImode).
205 (define_mode_macro VDQ [V8QI V16QI V4HI V8HI V2SI V4SI V2SF V4SF V2DI])
207 ;; All supported vector modes (except those with 64-bit integer elements).
208 (define_mode_macro VDQW [V8QI V16QI V4HI V8HI V2SI V4SI V2SF V4SF])
210 ;; Supported integer vector modes (not 64 bit elements).
211 (define_mode_macro VDQIW [V8QI V16QI V4HI V8HI V2SI V4SI])
213 ;; Supported integer vector modes (not singleton DI)
214 (define_mode_macro VDQI [V8QI V16QI V4HI V8HI V2SI V4SI V2DI])
216 ;; Vector modes, including 64-bit integer elements.
217 (define_mode_macro VDQX [V8QI V16QI V4HI V8HI V2SI V4SI V2SF V4SF DI V2DI])
219 ;; Vector modes including 64-bit integer elements, but no floats.
220 (define_mode_macro VDQIX [V8QI V16QI V4HI V8HI V2SI V4SI DI V2DI])
222 ;; Vector modes for float->int conversions.
223 (define_mode_macro VCVTF [V2SF V4SF])
225 ;; Vector modes form int->float conversions.
226 (define_mode_macro VCVTI [V2SI V4SI])
228 ;; Vector modes for doubleword multiply-accumulate, etc. insns.
229 (define_mode_macro VMD [V4HI V2SI V2SF])
231 ;; Vector modes for quadword multiply-accumulate, etc. insns.
232 (define_mode_macro VMQ [V8HI V4SI V4SF])
234 ;; Above modes combined.
235 (define_mode_macro VMDQ [V4HI V2SI V2SF V8HI V4SI V4SF])
237 ;; As VMD, but integer modes only.
238 (define_mode_macro VMDI [V4HI V2SI])
240 ;; As VMQ, but integer modes only.
241 (define_mode_macro VMQI [V8HI V4SI])
243 ;; Above modes combined.
244 (define_mode_macro VMDQI [V4HI V2SI V8HI V4SI])
246 ;; Modes with 8-bit and 16-bit elements.
247 (define_mode_macro VX [V8QI V4HI V16QI V8HI])
249 ;; Modes with 8-bit elements.
250 (define_mode_macro VE [V8QI V16QI])
252 ;; Modes with 64-bit elements only.
253 (define_mode_macro V64 [DI V2DI])
255 ;; Modes with 32-bit elements only.
256 (define_mode_macro V32 [V2SI V2SF V4SI V4SF])
258 ;; (Opposite) mode to convert to/from for above conversions.
259 (define_mode_attr V_CVTTO [(V2SI "V2SF") (V2SF "V2SI")
260                            (V4SI "V4SF") (V4SF "V4SI")])
262 ;; Define element mode for each vector mode.
263 (define_mode_attr V_elem [(V8QI "QI") (V16QI "QI")
264                           (V4HI "HI") (V8HI "HI")
265                           (V2SI "SI") (V4SI "SI")
266                           (V2SF "SF") (V4SF "SF")
267                           (DI "DI")   (V2DI "DI")])
269 ;; Mode of pair of elements for each vector mode, to define transfer
270 ;; size for structure lane/dup loads and stores.
271 (define_mode_attr V_two_elem [(V8QI "HI") (V16QI "HI")
272                               (V4HI "SI") (V8HI "SI")
273                               (V2SI "V2SI") (V4SI "V2SI")
274                               (V2SF "V2SF") (V4SF "V2SF")
275                               (DI "V2DI")   (V2DI "V2DI")])
277 ;; Similar, for three elements.
278 ;; ??? Should we define extra modes so that sizes of all three-element
279 ;; accesses can be accurately represented?
280 (define_mode_attr V_three_elem [(V8QI "SI")   (V16QI "SI")
281                                 (V4HI "V4HI") (V8HI "V4HI")
282                                 (V2SI "V4SI") (V4SI "V4SI")
283                                 (V2SF "V4SF") (V4SF "V4SF")
284                                 (DI "EI")     (V2DI "EI")])
286 ;; Similar, for four elements.
287 (define_mode_attr V_four_elem [(V8QI "SI")   (V16QI "SI")
288                                (V4HI "V4HI") (V8HI "V4HI")
289                                (V2SI "V4SI") (V4SI "V4SI")
290                                (V2SF "V4SF") (V4SF "V4SF")
291                                (DI "OI")     (V2DI "OI")])
293 ;; Register width from element mode
294 (define_mode_attr V_reg [(V8QI "P") (V16QI "q")
295                          (V4HI "P") (V8HI  "q")
296                          (V2SI "P") (V4SI  "q")
297                          (V2SF "P") (V4SF  "q")
298                          (DI   "P") (V2DI  "q")])
300 ;; Wider modes with the same number of elements.
301 (define_mode_attr V_widen [(V8QI "V8HI") (V4HI "V4SI") (V2SI "V2DI")])
303 ;; Narrower modes with the same number of elements.
304 (define_mode_attr V_narrow [(V8HI "V8QI") (V4SI "V4HI") (V2DI "V2SI")])
306 ;; Modes with half the number of equal-sized elements.
307 (define_mode_attr V_HALF [(V16QI "V8QI") (V8HI "V4HI")
308                           (V4SI  "V2SI") (V4SF "V2SF")
309                           (V2DI "DI")])
311 ;; Same, but lower-case.
312 (define_mode_attr V_half [(V16QI "v8qi") (V8HI "v4hi")
313                           (V4SI  "v2si") (V4SF "v2sf")
314                           (V2DI "di")])
316 ;; Modes with twice the number of equal-sized elements.
317 (define_mode_attr V_DOUBLE [(V8QI "V16QI") (V4HI "V8HI")
318                             (V2SI "V4SI") (V2SF "V4SF")
319                             (DI "V2DI")])
321 ;; Same, but lower-case.
322 (define_mode_attr V_double [(V8QI "v16qi") (V4HI "v8hi")
323                             (V2SI "v4si") (V2SF "v4sf")
324                             (DI "v2di")])
326 ;; Modes with double-width elements.
327 (define_mode_attr V_double_width [(V8QI "V4HI") (V16QI "V8HI")
328                                   (V4HI "V2SI") (V8HI "V4SI")
329                                   (V2SI "DI")   (V4SI "V2DI")])
331 ;; Mode of result of comparison operations (and bit-select operand 1).
332 (define_mode_attr V_cmp_result [(V8QI "V8QI") (V16QI "V16QI")
333                                 (V4HI "V4HI") (V8HI  "V8HI")
334                                 (V2SI "V2SI") (V4SI  "V4SI")
335                                 (V2SF "V2SI") (V4SF  "V4SI")
336                                 (DI   "DI")   (V2DI  "V2DI")])
338 ;; Get element type from double-width mode, for operations where we don't care
339 ;; about signedness.
340 (define_mode_attr V_if_elem [(V8QI "i8")  (V16QI "i8")
341                              (V4HI "i16") (V8HI  "i16")
342                              (V2SI "i32") (V4SI  "i32")
343                              (DI   "i64") (V2DI  "i64")
344                              (V2SF "f32") (V4SF  "f32")])
346 ;; Same, but for operations which work on signed values.
347 (define_mode_attr V_s_elem [(V8QI "s8")  (V16QI "s8")
348                             (V4HI "s16") (V8HI  "s16")
349                             (V2SI "s32") (V4SI  "s32")
350                             (DI   "s64") (V2DI  "s64")
351                             (V2SF "f32") (V4SF  "f32")])
353 ;; Same, but for operations which work on unsigned values.
354 (define_mode_attr V_u_elem [(V8QI "u8")  (V16QI "u8")
355                             (V4HI "u16") (V8HI  "u16")
356                             (V2SI "u32") (V4SI  "u32")
357                             (DI   "u64") (V2DI  "u64")
358                             (V2SF "f32") (V4SF  "f32")])
360 ;; Element types for extraction of unsigned scalars.
361 (define_mode_attr V_uf_sclr [(V8QI "u8")  (V16QI "u8")
362                              (V4HI "u16") (V8HI "u16")
363                              (V2SI "32") (V4SI "32")
364                              (V2SF "32") (V4SF "32")])
366 (define_mode_attr V_sz_elem [(V8QI "8")  (V16QI "8")
367                              (V4HI "16") (V8HI  "16")
368                              (V2SI "32") (V4SI  "32")
369                              (DI   "64") (V2DI  "64")
370                              (V2SF "32") (V4SF  "32")])
372 ;; Element sizes for duplicating ARM registers to all elements of a vector.
373 (define_mode_attr VD_dup [(V8QI "8") (V4HI "16") (V2SI "32") (V2SF "32")])
375 ;; Opaque integer types for results of pair-forming intrinsics (vtrn, etc.)
376 (define_mode_attr V_PAIR [(V8QI "TI") (V16QI "OI")
377                           (V4HI "TI") (V8HI  "OI")
378                           (V2SI "TI") (V4SI  "OI")
379                           (V2SF "TI") (V4SF  "OI")
380                           (DI   "TI") (V2DI  "OI")])
382 ;; Same, but lower-case.
383 (define_mode_attr V_pair [(V8QI "ti") (V16QI "oi")
384                           (V4HI "ti") (V8HI  "oi")
385                           (V2SI "ti") (V4SI  "oi")
386                           (V2SF "ti") (V4SF  "oi")
387                           (DI   "ti") (V2DI  "oi")])
389 ;; Operations on two halves of a quadword vector.
390 (define_code_macro vqh_ops [plus smin smax umin umax])
392 ;; Same, without unsigned variants (for use with *SFmode pattern).
393 (define_code_macro vqhs_ops [plus smin smax])
395 ;; Assembler mnemonics for above codes.
396 (define_code_attr VQH_mnem [(plus "vadd") (smin "vmin") (smax "vmax")
397                             (umin "vmin") (umax "vmax")])
399 ;; Signs of above, where relevant.
400 (define_code_attr VQH_sign [(plus "i") (smin "s") (smax "s") (umin "u")
401                             (umax "u")])
403 ;; Extra suffix on some 64-bit insn names (to avoid collision with standard
404 ;; names which we don't want to define).
405 (define_mode_attr V_suf64 [(V8QI "") (V16QI "")
406                            (V4HI "") (V8HI "")
407                            (V2SI "") (V4SI "")
408                            (V2SF "") (V4SF "")
409                            (DI "_neon") (V2DI "")])
411 ;; Scalars to be presented to scalar multiplication instructions
412 ;; must satisfy the following constraints.
413 ;; 1. If the mode specifies 16-bit elements, the scalar must be in D0-D7.
414 ;; 2. If the mode specifies 32-bit elements, the scalar must be in D0-D15.
415 ;; This mode attribute is used to obtain the correct register constraints.
416 (define_mode_attr scalar_mul_constraint [(V4HI "x") (V2SI "t") (V2SF "t")
417                                          (V8HI "x") (V4SI "t") (V4SF "t")])
419 ;; Attribute used to permit string comparisons against <VQH_mnem> in
420 ;; neon_type attribute definitions.
421 (define_attr "vqh_mnem" "vadd,vmin,vmax" (const_string "vadd"))
423 ;; Classification of NEON instructions for scheduling purposes.
424 ;; Do not set this attribute and the "type" attribute together in
425 ;; any one instruction pattern.
426 (define_attr "neon_type"
427    "neon_int_1,\
428    neon_int_2,\
429    neon_int_3,\
430    neon_int_4,\
431    neon_int_5,\
432    neon_vqneg_vqabs,\
433    neon_vmov,\
434    neon_vaba,\
435    neon_vsma,\
436    neon_vaba_qqq,\
437    neon_mul_ddd_8_16_qdd_16_8_long_32_16_long,\
438    neon_mul_qqq_8_16_32_ddd_32,\
439    neon_mul_qdd_64_32_long_qqd_16_ddd_32_scalar_64_32_long_scalar,\
440    neon_mla_ddd_8_16_qdd_16_8_long_32_16_long,\
441    neon_mla_qqq_8_16,\
442    neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long,\
443    neon_mla_qqq_32_qqd_32_scalar,\
444    neon_mul_ddd_16_scalar_32_16_long_scalar,\
445    neon_mul_qqd_32_scalar,\
446    neon_mla_ddd_16_scalar_qdd_32_16_long_scalar,\
447    neon_shift_1,\
448    neon_shift_2,\
449    neon_shift_3,\
450    neon_vshl_ddd,\
451    neon_vqshl_vrshl_vqrshl_qqq,\
452    neon_vsra_vrsra,\
453    neon_fp_vadd_ddd_vabs_dd,\
454    neon_fp_vadd_qqq_vabs_qq,\
455    neon_fp_vsum,\
456    neon_fp_vmul_ddd,\
457    neon_fp_vmul_qqd,\
458    neon_fp_vmla_ddd,\
459    neon_fp_vmla_qqq,\
460    neon_fp_vmla_ddd_scalar,\
461    neon_fp_vmla_qqq_scalar,\
462    neon_fp_vrecps_vrsqrts_ddd,\
463    neon_fp_vrecps_vrsqrts_qqq,\
464    neon_bp_simple,\
465    neon_bp_2cycle,\
466    neon_bp_3cycle,\
467    neon_ldr,\
468    neon_str,\
469    neon_vld1_1_2_regs,\
470    neon_vld1_3_4_regs,\
471    neon_vld2_2_regs_vld1_vld2_all_lanes,\
472    neon_vld2_4_regs,\
473    neon_vld3_vld4,\
474    neon_vst1_1_2_regs_vst2_2_regs,\
475    neon_vst1_3_4_regs,\
476    neon_vst2_4_regs_vst3_vst4,\
477    neon_vst3_vst4,\
478    neon_vld1_vld2_lane,\
479    neon_vld3_vld4_lane,\
480    neon_vst1_vst2_lane,\
481    neon_vst3_vst4_lane,\
482    neon_vld3_vld4_all_lanes,\
483    neon_mcr,\
484    neon_mcr_2_mcrr,\
485    neon_mrc,\
486    neon_mrrc,\
487    neon_ldm_2,\
488    neon_stm_2,\
489    none"
490  (const_string "none"))
492 ;; Predicates used for setting the above attribute.
494 (define_mode_attr Is_float_mode [(V8QI "false") (V16QI "false")
495                                  (V4HI "false") (V8HI "false")
496                                  (V2SI "false") (V4SI "false")
497                                  (V2SF "true") (V4SF "true")
498                                  (DI "false") (V2DI "false")])
500 (define_mode_attr Scalar_mul_8_16 [(V8QI "true") (V16QI "true")
501                                    (V4HI "true") (V8HI "true")
502                                    (V2SI "false") (V4SI "false")
503                                    (V2SF "false") (V4SF "false")
504                                    (DI "false") (V2DI "false")])
507 (define_mode_attr Is_d_reg [(V8QI "true") (V16QI "false")
508                             (V4HI "true") (V8HI  "false")
509                             (V2SI "true") (V4SI  "false")
510                             (V2SF "true") (V4SF  "false")
511                             (DI   "true") (V2DI  "false")])
513 (define_mode_attr V_mode_nunits [(V8QI "8") (V16QI "16")
514                                  (V4HI "4") (V8HI "8")
515                                  (V2SI "2") (V4SI "4")
516                                  (V2SF "2") (V4SF "4")
517                                  (DI "1")   (V2DI "2")])
519 (define_insn "*neon_mov<mode>"
520   [(set (match_operand:VD 0 "nonimmediate_operand"
521           "=w,Uv,w, w,  ?r,?w,?r,?r, ?Us")
522         (match_operand:VD 1 "general_operand"
523           " w,w, Dn,Uvi, w, r, r, Usi,r"))]
524   "TARGET_NEON"
526   if (which_alternative == 2)
527     {
528       int width, is_valid;
529       static char templ[40];
531       is_valid = neon_immediate_valid_for_move (operands[1], <MODE>mode,
532         &operands[1], &width);
534       gcc_assert (is_valid != 0);
536       if (width == 0)
537         return "vmov.f32\t%P0, %1  @ <mode>";
538       else
539         sprintf (templ, "vmov.i%d\t%%P0, %%1  @ <mode>", width);
541       return templ;
542     }
544   /* FIXME: If the memory layout is changed in big-endian mode, output_move_vfp
545      below must be changed to output_move_neon (which will use the
546      element/structure loads/stores), and the constraint changed to 'Un' instead
547      of 'Uv'.  */
549   switch (which_alternative)
550     {
551     case 0: return "vmov\t%P0, %P1  @ <mode>";
552     case 1: case 3: return output_move_vfp (operands);
553     case 2: gcc_unreachable ();
554     case 4: return "vmov\t%Q0, %R0, %P1  @ <mode>";
555     case 5: return "vmov\t%P0, %Q1, %R1  @ <mode>";
556     default: return output_move_double (operands);
557     }
559  [(set_attr "neon_type" "neon_int_1,*,neon_vmov,*,neon_mrrc,neon_mcr_2_mcrr,*,*,*")
560   (set_attr "type" "*,f_stored,*,f_loadd,*,*,alu,load2,store2")
561   (set_attr "insn" "*,*,*,*,*,*,mov,*,*")
562   (set_attr "length" "4,4,4,4,4,4,8,8,8")
563   (set_attr "pool_range"     "*,*,*,1020,*,*,*,1020,*")
564   (set_attr "neg_pool_range" "*,*,*,1008,*,*,*,1008,*")])
566 (define_insn "*neon_mov<mode>"
567   [(set (match_operand:VQXMOV 0 "nonimmediate_operand"
568           "=w,Un,w, w,  ?r,?w,?r,?r,  ?Us")
569         (match_operand:VQXMOV 1 "general_operand"
570           " w,w, Dn,Uni, w, r, r, Usi, r"))]
571   "TARGET_NEON"
573   if (which_alternative == 2)
574     {
575       int width, is_valid;
576       static char templ[40];
578       is_valid = neon_immediate_valid_for_move (operands[1], <MODE>mode,
579         &operands[1], &width);
581       gcc_assert (is_valid != 0);
583       if (width == 0)
584         return "vmov.f32\t%q0, %1  @ <mode>";
585       else
586         sprintf (templ, "vmov.i%d\t%%q0, %%1  @ <mode>", width);
588       return templ;
589     }
591   switch (which_alternative)
592     {
593     case 0: return "vmov\t%q0, %q1  @ <mode>";
594     case 1: case 3: return output_move_neon (operands);
595     case 2: gcc_unreachable ();
596     case 4: return "vmov\t%Q0, %R0, %e1  @ <mode>\;vmov\t%J0, %K0, %f1";
597     case 5: return "vmov\t%e0, %Q1, %R1  @ <mode>\;vmov\t%f0, %J1, %K1";
598     default: return output_move_quad (operands);
599     }
601   [(set_attr "neon_type" "neon_int_1,neon_stm_2,neon_vmov,neon_ldm_2,\
602                           neon_mrrc,neon_mcr_2_mcrr,*,*,*")
603    (set_attr "type" "*,*,*,*,*,*,alu,load4,store4")
604    (set_attr "insn" "*,*,*,*,*,*,mov,*,*")
605    (set_attr "length" "4,8,4,8,8,8,16,8,16")
606    (set_attr "pool_range" "*,*,*,1020,*,*,*,1020,*")
607    (set_attr "neg_pool_range" "*,*,*,1008,*,*,*,1008,*")])
609 (define_expand "movti"
610   [(set (match_operand:TI 0 "nonimmediate_operand" "")
611         (match_operand:TI 1 "general_operand" ""))]
612   "TARGET_NEON"
616 (define_expand "mov<mode>"
617   [(set (match_operand:VSTRUCT 0 "nonimmediate_operand" "")
618         (match_operand:VSTRUCT 1 "general_operand" ""))]
619   "TARGET_NEON"
623 (define_insn "*neon_mov<mode>"
624   [(set (match_operand:VSTRUCT 0 "nonimmediate_operand" "=w,Ut,w")
625         (match_operand:VSTRUCT 1 "general_operand"      " w,w, Ut"))]
626   "TARGET_NEON"
628   switch (which_alternative)
629     {
630     case 0: return "#";
631     case 1: case 2: return output_move_neon (operands);
632     default: gcc_unreachable ();
633     }
635   [(set_attr "length" "<V_slen>,<V_slen>,<V_slen>")])
637 (define_split
638   [(set (match_operand:EI 0 "s_register_operand" "")
639         (match_operand:EI 1 "s_register_operand" ""))]
640   "TARGET_NEON && reload_completed"
641   [(set (match_dup 0) (match_dup 1))
642    (set (match_dup 2) (match_dup 3))]
644   int rdest = REGNO (operands[0]);
645   int rsrc = REGNO (operands[1]);
646   rtx dest[2], src[2];
648   dest[0] = gen_rtx_REG (TImode, rdest);
649   src[0] = gen_rtx_REG (TImode, rsrc);
650   dest[1] = gen_rtx_REG (DImode, rdest + 4);
651   src[1] = gen_rtx_REG (DImode, rsrc + 4);
653   neon_disambiguate_copy (operands, dest, src, 2);
656 (define_split
657   [(set (match_operand:OI 0 "s_register_operand" "")
658         (match_operand:OI 1 "s_register_operand" ""))]
659   "TARGET_NEON && reload_completed"
660   [(set (match_dup 0) (match_dup 1))
661    (set (match_dup 2) (match_dup 3))]
663   int rdest = REGNO (operands[0]);
664   int rsrc = REGNO (operands[1]);
665   rtx dest[2], src[2];
667   dest[0] = gen_rtx_REG (TImode, rdest);
668   src[0] = gen_rtx_REG (TImode, rsrc);
669   dest[1] = gen_rtx_REG (TImode, rdest + 4);
670   src[1] = gen_rtx_REG (TImode, rsrc + 4);
672   neon_disambiguate_copy (operands, dest, src, 2);
675 (define_split
676   [(set (match_operand:CI 0 "s_register_operand" "")
677         (match_operand:CI 1 "s_register_operand" ""))]
678   "TARGET_NEON && reload_completed"
679   [(set (match_dup 0) (match_dup 1))
680    (set (match_dup 2) (match_dup 3))
681    (set (match_dup 4) (match_dup 5))]
683   int rdest = REGNO (operands[0]);
684   int rsrc = REGNO (operands[1]);
685   rtx dest[3], src[3];
687   dest[0] = gen_rtx_REG (TImode, rdest);
688   src[0] = gen_rtx_REG (TImode, rsrc);
689   dest[1] = gen_rtx_REG (TImode, rdest + 4);
690   src[1] = gen_rtx_REG (TImode, rsrc + 4);
691   dest[2] = gen_rtx_REG (TImode, rdest + 8);
692   src[2] = gen_rtx_REG (TImode, rsrc + 8);
694   neon_disambiguate_copy (operands, dest, src, 3);
697 (define_split
698   [(set (match_operand:XI 0 "s_register_operand" "")
699         (match_operand:XI 1 "s_register_operand" ""))]
700   "TARGET_NEON && reload_completed"
701   [(set (match_dup 0) (match_dup 1))
702    (set (match_dup 2) (match_dup 3))
703    (set (match_dup 4) (match_dup 5))
704    (set (match_dup 6) (match_dup 7))]
706   int rdest = REGNO (operands[0]);
707   int rsrc = REGNO (operands[1]);
708   rtx dest[4], src[4];
710   dest[0] = gen_rtx_REG (TImode, rdest);
711   src[0] = gen_rtx_REG (TImode, rsrc);
712   dest[1] = gen_rtx_REG (TImode, rdest + 4);
713   src[1] = gen_rtx_REG (TImode, rsrc + 4);
714   dest[2] = gen_rtx_REG (TImode, rdest + 8);
715   src[2] = gen_rtx_REG (TImode, rsrc + 8);
716   dest[3] = gen_rtx_REG (TImode, rdest + 12);
717   src[3] = gen_rtx_REG (TImode, rsrc + 12);
719   neon_disambiguate_copy (operands, dest, src, 4);
722 (define_insn "vec_set<mode>"
723   [(set (match_operand:VD 0 "s_register_operand" "+w")
724         (vec_merge:VD
725           (match_operand:VD 3 "s_register_operand" "0")
726           (vec_duplicate:VD
727             (match_operand:<V_elem> 1 "s_register_operand" "r"))
728           (ashift:SI (const_int 1)
729                      (match_operand:SI 2 "immediate_operand" "i"))))]
730   "TARGET_NEON"
731   "vmov%?.<V_uf_sclr>\t%P0[%c2], %1"
732   [(set_attr "predicable" "yes")
733    (set_attr "neon_type" "neon_mcr")]
736 (define_insn "vec_set<mode>"
737   [(set (match_operand:VQ 0 "s_register_operand" "+w")
738         (vec_merge:VQ
739           (match_operand:VQ 3 "s_register_operand" "0")
740           (vec_duplicate:VQ
741             (match_operand:<V_elem> 1 "s_register_operand" "r"))
742           (ashift:SI (const_int 1)
743                      (match_operand:SI 2 "immediate_operand" "i"))))]
744   "TARGET_NEON"
746   int half_elts = GET_MODE_NUNITS (<MODE>mode) / 2;
747   int elt = INTVAL (operands[2]) % half_elts;
748   int hi = (INTVAL (operands[2]) / half_elts) * 2;
749   int regno = REGNO (operands[0]);
751   operands[0] = gen_rtx_REG (<V_HALF>mode, regno + hi);
752   operands[2] = GEN_INT (elt);
754   return "vmov%?.<V_uf_sclr>\t%P0[%c2], %1";
756   [(set_attr "predicable" "yes")
757    (set_attr "neon_type" "neon_mcr")]
760 (define_insn "vec_setv2di"
761   [(set (match_operand:V2DI 0 "s_register_operand" "+w")
762         (vec_merge:V2DI
763           (match_operand:V2DI 3 "s_register_operand" "0")
764           (vec_duplicate:V2DI
765             (match_operand:DI 1 "s_register_operand" "r"))
766           (ashift:SI (const_int 1)
767                      (match_operand:SI 2 "immediate_operand" "i"))))]
768   "TARGET_NEON"
770   int regno = REGNO (operands[0]) + INTVAL (operands[2]);
772   operands[0] = gen_rtx_REG (DImode, regno);
774   return "vmov%?.64\t%P0, %Q1, %R1";
776   [(set_attr "predicable" "yes")
777    (set_attr "neon_type" "neon_mcr_2_mcrr")]
780 (define_insn "vec_extract<mode>"
781   [(set (match_operand:<V_elem> 0 "s_register_operand" "=r")
782         (vec_select:<V_elem>
783           (match_operand:VD 1 "s_register_operand" "w")
784           (parallel [(match_operand:SI 2 "immediate_operand" "i")])))]
785   "TARGET_NEON"
786   "vmov%?.<V_uf_sclr>\t%0, %P1[%c2]"
787   [(set_attr "predicable" "yes")
788    (set_attr "neon_type" "neon_bp_simple")]
791 (define_insn "vec_extract<mode>"
792   [(set (match_operand:<V_elem> 0 "s_register_operand" "=r")
793         (vec_select:<V_elem>
794           (match_operand:VQ 1 "s_register_operand" "w")
795           (parallel [(match_operand:SI 2 "immediate_operand" "i")])))]
796   "TARGET_NEON"
798   int half_elts = GET_MODE_NUNITS (<MODE>mode) / 2;
799   int elt = INTVAL (operands[2]) % half_elts;
800   int hi = (INTVAL (operands[2]) / half_elts) * 2;
801   int regno = REGNO (operands[1]);
803   operands[1] = gen_rtx_REG (<V_HALF>mode, regno + hi);
804   operands[2] = GEN_INT (elt);
806   return "vmov%?.<V_uf_sclr>\t%0, %P1[%c2]";
808   [(set_attr "predicable" "yes")
809    (set_attr "neon_type" "neon_bp_simple")]
812 (define_insn "vec_extractv2di"
813   [(set (match_operand:DI 0 "s_register_operand" "=r")
814         (vec_select:DI
815           (match_operand:V2DI 1 "s_register_operand" "w")
816           (parallel [(match_operand:SI 2 "immediate_operand" "i")])))]
817   "TARGET_NEON"
819   int regno = REGNO (operands[1]) + INTVAL (operands[2]);
821   operands[1] = gen_rtx_REG (DImode, regno);
823   return "vmov%?.64\t%Q0, %R0, %P1";
825   [(set_attr "predicable" "yes")
826    (set_attr "neon_type" "neon_int_1")]
829 (define_expand "vec_init<mode>"
830   [(match_operand:VDQ 0 "s_register_operand" "")
831    (match_operand 1 "" "")]
832   "TARGET_NEON"
834   neon_expand_vector_init (operands[0], operands[1]);
835   DONE;
838 ;; Doubleword and quadword arithmetic.
840 ;; NOTE: vadd/vsub and some other instructions also support 64-bit integer
841 ;; element size, which we could potentially use for "long long" operations. We
842 ;; don't want to do this at present though, because moving values from the
843 ;; vector unit to the ARM core is currently slow and 64-bit addition (etc.) is
844 ;; easy to do with ARM instructions anyway.
846 (define_insn "*add<mode>3_neon"
847   [(set (match_operand:VDQ 0 "s_register_operand" "=w")
848         (plus:VDQ (match_operand:VDQ 1 "s_register_operand" "w")
849                   (match_operand:VDQ 2 "s_register_operand" "w")))]
850   "TARGET_NEON"
851   "vadd.<V_if_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
852   [(set (attr "neon_type")
853       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
854                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
855                                   (const_string "neon_fp_vadd_ddd_vabs_dd")
856                                   (const_string "neon_fp_vadd_qqq_vabs_qq"))
857                     (const_string "neon_int_1")))]
860 (define_insn "*sub<mode>3_neon"
861   [(set (match_operand:VDQ 0 "s_register_operand" "=w")
862         (minus:VDQ (match_operand:VDQ 1 "s_register_operand" "w")
863                    (match_operand:VDQ 2 "s_register_operand" "w")))]
864   "TARGET_NEON"
865   "vsub.<V_if_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
866   [(set (attr "neon_type")
867       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
868                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
869                                   (const_string "neon_fp_vadd_ddd_vabs_dd")
870                                   (const_string "neon_fp_vadd_qqq_vabs_qq"))
871                     (const_string "neon_int_2")))]
874 (define_insn "*mul<mode>3_neon"
875   [(set (match_operand:VDQ 0 "s_register_operand" "=w")
876         (mult:VDQ (match_operand:VDQ 1 "s_register_operand" "w")
877                   (match_operand:VDQ 2 "s_register_operand" "w")))]
878   "TARGET_NEON"
879   "vmul.<V_if_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
880   [(set (attr "neon_type")
881       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
882                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
883                                   (const_string "neon_fp_vadd_ddd_vabs_dd")
884                                   (const_string "neon_fp_vadd_qqq_vabs_qq"))
885                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
886                                   (if_then_else
887                                     (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
888                                     (const_string "neon_mul_ddd_8_16_qdd_16_8_long_32_16_long")
889                                     (const_string "neon_mul_qqq_8_16_32_ddd_32"))
890                                   (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
891                                     (const_string "neon_mul_qqq_8_16_32_ddd_32")
892                                     (const_string "neon_mul_qqq_8_16_32_ddd_32")))))]
895 (define_insn "ior<mode>3"
896   [(set (match_operand:VDQ 0 "s_register_operand" "=w,w")
897         (ior:VDQ (match_operand:VDQ 1 "s_register_operand" "w,0")
898                  (match_operand:VDQ 2 "neon_logic_op2" "w,Dl")))]
899   "TARGET_NEON"
901   switch (which_alternative)
902     {
903     case 0: return "vorr\t%<V_reg>0, %<V_reg>1, %<V_reg>2";
904     case 1: return neon_output_logic_immediate ("vorr", &operands[2],
905                      <MODE>mode, 0, VALID_NEON_QREG_MODE (<MODE>mode));
906     default: gcc_unreachable ();
907     }
909   [(set_attr "neon_type" "neon_int_1")]
912 (define_insn "iordi3_neon"
913   [(set (match_operand:DI 0 "s_register_operand" "=w,w")
914         (unspec:DI [(match_operand:DI 1 "s_register_operand" "w,0")
915                     (match_operand:DI 2 "neon_logic_op2" "w,Dl")]
916                     UNSPEC_VORR))]
917   "TARGET_NEON"
919   switch (which_alternative)
920     {
921     case 0: return "vorr\t%P0, %P1, %P2";
922     case 1: return neon_output_logic_immediate ("vorr", &operands[2],
923                      DImode, 0, VALID_NEON_QREG_MODE (DImode));
924     default: gcc_unreachable ();
925     }
927   [(set_attr "neon_type" "neon_int_1")]
930 ;; The concrete forms of the Neon immediate-logic instructions are vbic and
931 ;; vorr. We support the pseudo-instruction vand instead, because that
932 ;; corresponds to the canonical form the middle-end expects to use for
933 ;; immediate bitwise-ANDs.
935 (define_insn "and<mode>3"
936   [(set (match_operand:VDQ 0 "s_register_operand" "=w,w")
937         (and:VDQ (match_operand:VDQ 1 "s_register_operand" "w,0")
938                  (match_operand:VDQ 2 "neon_inv_logic_op2" "w,DL")))]
939   "TARGET_NEON"
941   switch (which_alternative)
942     {
943     case 0: return "vand\t%<V_reg>0, %<V_reg>1, %<V_reg>2";
944     case 1: return neon_output_logic_immediate ("vand", &operands[2],
945                      <MODE>mode, 1, VALID_NEON_QREG_MODE (<MODE>mode));
946     default: gcc_unreachable ();
947     }
949   [(set_attr "neon_type" "neon_int_1")]
952 (define_insn "anddi3_neon"
953   [(set (match_operand:DI 0 "s_register_operand" "=w,w")
954         (unspec:DI [(match_operand:DI 1 "s_register_operand" "w,0")
955                     (match_operand:DI 2 "neon_inv_logic_op2" "w,DL")]
956                     UNSPEC_VAND))]
957   "TARGET_NEON"
959   switch (which_alternative)
960     {
961     case 0: return "vand\t%P0, %P1, %P2";
962     case 1: return neon_output_logic_immediate ("vand", &operands[2],
963                      DImode, 1, VALID_NEON_QREG_MODE (DImode));
964     default: gcc_unreachable ();
965     }
967   [(set_attr "neon_type" "neon_int_1")]
970 (define_insn "orn<mode>3_neon"
971   [(set (match_operand:VDQ 0 "s_register_operand" "=w")
972         (ior:VDQ (match_operand:VDQ 1 "s_register_operand" "w")
973                  (not:VDQ (match_operand:VDQ 2 "s_register_operand" "w"))))]
974   "TARGET_NEON"
975   "vorn\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
976   [(set_attr "neon_type" "neon_int_1")]
979 (define_insn "orndi3_neon"
980   [(set (match_operand:DI 0 "s_register_operand" "=w")
981         (unspec:DI [(match_operand:DI 1 "s_register_operand" "w")
982                     (match_operand:DI 2 "s_register_operand" "w")]
983                     UNSPEC_VORN))]
984   "TARGET_NEON"
985   "vorn\t%P0, %P1, %P2"
986   [(set_attr "neon_type" "neon_int_1")]
989 (define_insn "bic<mode>3_neon"
990   [(set (match_operand:VDQ 0 "s_register_operand" "=w")
991         (and:VDQ (match_operand:VDQ 1 "s_register_operand" "w")
992                   (not:VDQ (match_operand:VDQ 2 "s_register_operand" "w"))))]
993   "TARGET_NEON"
994   "vbic\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
995   [(set_attr "neon_type" "neon_int_1")]
998 (define_insn "bicdi3_neon"
999   [(set (match_operand:DI 0 "s_register_operand" "=w")
1000         (unspec:DI [(match_operand:DI 1 "s_register_operand" "w")
1001                      (match_operand:DI 2 "s_register_operand" "w")]
1002                     UNSPEC_VBIC))]
1003   "TARGET_NEON"
1004   "vbic\t%P0, %P1, %P2"
1005   [(set_attr "neon_type" "neon_int_1")]
1008 (define_insn "xor<mode>3"
1009   [(set (match_operand:VDQ 0 "s_register_operand" "=w")
1010         (xor:VDQ (match_operand:VDQ 1 "s_register_operand" "w")
1011                  (match_operand:VDQ 2 "s_register_operand" "w")))]
1012   "TARGET_NEON"
1013   "veor\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1014   [(set_attr "neon_type" "neon_int_1")]
1017 (define_insn "xordi3_neon"
1018   [(set (match_operand:DI 0 "s_register_operand" "=w")
1019         (unspec:DI [(match_operand:DI 1 "s_register_operand" "w")
1020                      (match_operand:DI 2 "s_register_operand" "w")]
1021                     UNSPEC_VEOR))]
1022   "TARGET_NEON"
1023   "veor\t%P0, %P1, %P2"
1024   [(set_attr "neon_type" "neon_int_1")]
1027 (define_insn "one_cmpl<mode>2"
1028   [(set (match_operand:VDQ 0 "s_register_operand" "=w")
1029         (not:VDQ (match_operand:VDQ 1 "s_register_operand" "w")))]
1030   "TARGET_NEON"
1031   "vmvn\t%<V_reg>0, %<V_reg>1"
1032   [(set_attr "neon_type" "neon_int_1")]
1035 (define_insn "abs<mode>2"
1036   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
1037         (abs:VDQW (match_operand:VDQW 1 "s_register_operand" "w")))]
1038   "TARGET_NEON"
1039   "vabs.<V_s_elem>\t%<V_reg>0, %<V_reg>1"
1040   [(set (attr "neon_type")
1041       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
1042                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1043                                   (const_string "neon_fp_vadd_ddd_vabs_dd")
1044                                   (const_string "neon_fp_vadd_qqq_vabs_qq"))
1045                     (const_string "neon_int_3")))]
1048 (define_insn "neg<mode>2"
1049   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
1050         (neg:VDQW (match_operand:VDQW 1 "s_register_operand" "w")))]
1051   "TARGET_NEON"
1052   "vneg.<V_s_elem>\t%<V_reg>0, %<V_reg>1"
1053   [(set (attr "neon_type")
1054       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
1055                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1056                                   (const_string "neon_fp_vadd_ddd_vabs_dd")
1057                                   (const_string "neon_fp_vadd_qqq_vabs_qq"))
1058                     (const_string "neon_int_3")))]
1061 (define_insn "*umin<mode>3_neon"
1062   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
1063         (umin:VDQIW (match_operand:VDQIW 1 "s_register_operand" "w")
1064                     (match_operand:VDQIW 2 "s_register_operand" "w")))]
1065   "TARGET_NEON"
1066   "vmin.<V_u_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1067   [(set_attr "neon_type" "neon_int_5")]
1070 (define_insn "*umax<mode>3_neon"
1071   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
1072         (umax:VDQIW (match_operand:VDQIW 1 "s_register_operand" "w")
1073                     (match_operand:VDQIW 2 "s_register_operand" "w")))]
1074   "TARGET_NEON"
1075   "vmax.<V_u_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1076   [(set_attr "neon_type" "neon_int_5")]
1079 (define_insn "*smin<mode>3_neon"
1080   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
1081         (smin:VDQW (match_operand:VDQW 1 "s_register_operand" "w")
1082                    (match_operand:VDQW 2 "s_register_operand" "w")))]
1083   "TARGET_NEON"
1084   "vmin.<V_s_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1085   [(set (attr "neon_type")
1086       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
1087                     (const_string "neon_fp_vadd_ddd_vabs_dd")
1088                     (const_string "neon_int_5")))]
1091 (define_insn "*smax<mode>3_neon"
1092   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
1093         (smax:VDQW (match_operand:VDQW 1 "s_register_operand" "w")
1094                    (match_operand:VDQW 2 "s_register_operand" "w")))]
1095   "TARGET_NEON"
1096   "vmax.<V_s_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1097   [(set (attr "neon_type")
1098       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
1099                     (const_string "neon_fp_vadd_ddd_vabs_dd")
1100                     (const_string "neon_int_5")))]
1103 ; TODO: V2DI shifts are current disabled because there are bugs in the
1104 ; generic vectorizer code.  It ends up creating a V2DI constructor with
1105 ; SImode elements.
1107 (define_insn "ashl<mode>3"
1108   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
1109         (ashift:VDQIW (match_operand:VDQIW 1 "s_register_operand" "w")
1110                       (match_operand:VDQIW 2 "s_register_operand" "w")))]
1111   "TARGET_NEON"
1112   "vshl.<V_s_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1113   [(set (attr "neon_type")
1114       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1115                     (const_string "neon_vshl_ddd")
1116                     (const_string "neon_shift_3")))]
1119 ; Used for implementing logical shift-right, which is a left-shift by a negative
1120 ; amount, with signed operands. This is essentially the same as ashl<mode>3
1121 ; above, but using an unspec in case GCC tries anything tricky with negative
1122 ; shift amounts.
1124 (define_insn "ashl<mode>3_signed"
1125   [(set (match_operand:VDQI 0 "s_register_operand" "=w")
1126         (unspec:VDQI [(match_operand:VDQI 1 "s_register_operand" "w")
1127                       (match_operand:VDQI 2 "s_register_operand" "w")]
1128                      UNSPEC_ASHIFT_SIGNED))]
1129   "TARGET_NEON"
1130   "vshl.<V_s_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1131   [(set (attr "neon_type")
1132       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1133                     (const_string "neon_vshl_ddd")
1134                     (const_string "neon_shift_3")))]
1137 ; Used for implementing logical shift-right, which is a left-shift by a negative
1138 ; amount, with unsigned operands.
1140 (define_insn "ashl<mode>3_unsigned"
1141   [(set (match_operand:VDQI 0 "s_register_operand" "=w")
1142         (unspec:VDQI [(match_operand:VDQI 1 "s_register_operand" "w")
1143                       (match_operand:VDQI 2 "s_register_operand" "w")]
1144                      UNSPEC_ASHIFT_UNSIGNED))]
1145   "TARGET_NEON"
1146   "vshl.<V_u_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1147   [(set (attr "neon_type")
1148       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1149                     (const_string "neon_vshl_ddd")
1150                     (const_string "neon_shift_3")))]
1153 (define_expand "ashr<mode>3"
1154   [(set (match_operand:VDQIW 0 "s_register_operand" "")
1155         (ashiftrt:VDQIW (match_operand:VDQIW 1 "s_register_operand" "")
1156                         (match_operand:VDQIW 2 "s_register_operand" "")))]
1157   "TARGET_NEON"
1159   rtx neg = gen_reg_rtx (<MODE>mode);
1161   emit_insn (gen_neg<mode>2 (neg, operands[2]));
1162   emit_insn (gen_ashl<mode>3_signed (operands[0], operands[1], neg));
1164   DONE;
1167 (define_expand "lshr<mode>3"
1168   [(set (match_operand:VDQIW 0 "s_register_operand" "")
1169         (lshiftrt:VDQIW (match_operand:VDQIW 1 "s_register_operand" "")
1170                         (match_operand:VDQIW 2 "s_register_operand" "")))]
1171   "TARGET_NEON"
1173   rtx neg = gen_reg_rtx (<MODE>mode);
1175   emit_insn (gen_neg<mode>2 (neg, operands[2]));
1176   emit_insn (gen_ashl<mode>3_unsigned (operands[0], operands[1], neg));
1178   DONE;
1181 ;; Widening operations
1183 (define_insn "widen_ssum<mode>3"
1184   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
1185         (plus:<V_widen> (sign_extend:<V_widen>
1186                           (match_operand:VW 1 "s_register_operand" "%w"))
1187                         (match_operand:<V_widen> 2 "s_register_operand" "w")))]
1188   "TARGET_NEON"
1189   "vaddw.<V_s_elem>\t%q0, %q2, %P1"
1190   [(set_attr "neon_type" "neon_int_3")]
1193 (define_insn "widen_usum<mode>3"
1194   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
1195         (plus:<V_widen> (zero_extend:<V_widen>
1196                           (match_operand:VW 1 "s_register_operand" "%w"))
1197                         (match_operand:<V_widen> 2 "s_register_operand" "w")))]
1198   "TARGET_NEON"
1199   "vaddw.<V_u_elem>\t%q0, %q2, %P1"
1200   [(set_attr "neon_type" "neon_int_3")]
1203 ;; VEXT can be used to synthesize coarse whole-vector shifts with 8-bit
1204 ;; shift-count granularity. That's good enough for the middle-end's current
1205 ;; needs.
1207 (define_expand "vec_shr_<mode>"
1208   [(match_operand:VDQ 0 "s_register_operand" "")
1209    (match_operand:VDQ 1 "s_register_operand" "")
1210    (match_operand:SI 2 "const_multiple_of_8_operand" "")]
1211   "TARGET_NEON"
1213   rtx zero_reg;
1214   HOST_WIDE_INT num_bits = INTVAL (operands[2]);
1215   const int width = GET_MODE_BITSIZE (<MODE>mode);
1216   const enum machine_mode bvecmode = (width == 128) ? V16QImode : V8QImode;
1217   rtx (*gen_ext) (rtx, rtx, rtx, rtx) =
1218     (width == 128) ? gen_neon_vextv16qi : gen_neon_vextv8qi;
1220   if (num_bits == width)
1221     {
1222       emit_move_insn (operands[0], operands[1]);
1223       DONE;
1224     }
1226   zero_reg = force_reg (bvecmode, CONST0_RTX (bvecmode));
1227   operands[0] = gen_lowpart (bvecmode, operands[0]);
1228   operands[1] = gen_lowpart (bvecmode, operands[1]);
1230   emit_insn (gen_ext (operands[0], operands[1], zero_reg,
1231                       GEN_INT (num_bits / BITS_PER_UNIT)));
1232   DONE;
1235 (define_expand "vec_shl_<mode>"
1236   [(match_operand:VDQ 0 "s_register_operand" "")
1237    (match_operand:VDQ 1 "s_register_operand" "")
1238    (match_operand:SI 2 "const_multiple_of_8_operand" "")]
1239   "TARGET_NEON"
1241   rtx zero_reg;
1242   HOST_WIDE_INT num_bits = INTVAL (operands[2]);
1243   const int width = GET_MODE_BITSIZE (<MODE>mode);
1244   const enum machine_mode bvecmode = (width == 128) ? V16QImode : V8QImode;
1245   rtx (*gen_ext) (rtx, rtx, rtx, rtx) =
1246     (width == 128) ? gen_neon_vextv16qi : gen_neon_vextv8qi;
1248   if (num_bits == 0)
1249     {
1250       emit_move_insn (operands[0], CONST0_RTX (<MODE>mode));
1251       DONE;
1252     }
1254   num_bits = width - num_bits;
1256   zero_reg = force_reg (bvecmode, CONST0_RTX (bvecmode));
1257   operands[0] = gen_lowpart (bvecmode, operands[0]);
1258   operands[1] = gen_lowpart (bvecmode, operands[1]);
1260   emit_insn (gen_ext (operands[0], zero_reg, operands[1],
1261                       GEN_INT (num_bits / BITS_PER_UNIT)));
1262   DONE;
1265 ;; Helpers for quad-word reduction operations
1267 ; Add (or smin, smax...) the low N/2 elements of the N-element vector
1268 ; operand[1] to the high N/2 elements of same. Put the result in operand[0], an
1269 ; N/2-element vector.
1271 (define_insn "quad_halves_<code>v4si"
1272   [(set (match_operand:V2SI 0 "s_register_operand" "=w")
1273         (vqh_ops:V2SI
1274           (vec_select:V2SI (match_operand:V4SI 1 "s_register_operand" "w")
1275                            (parallel [(const_int 0) (const_int 1)]))
1276           (vec_select:V2SI (match_dup 1)
1277                            (parallel [(const_int 2) (const_int 3)]))))]
1278   "TARGET_NEON"
1279   "<VQH_mnem>.<VQH_sign>32\t%P0, %e1, %f1"
1280   [(set_attr "vqh_mnem" "<VQH_mnem>")
1281    (set (attr "neon_type")
1282       (if_then_else (eq_attr "vqh_mnem" "vadd")
1283                     (const_string "neon_int_1") (const_string "neon_int_5")))]
1286 (define_insn "quad_halves_<code>v4sf"
1287   [(set (match_operand:V2SF 0 "s_register_operand" "=w")
1288         (vqhs_ops:V2SF
1289           (vec_select:V2SF (match_operand:V4SF 1 "s_register_operand" "w")
1290                            (parallel [(const_int 0) (const_int 1)]))
1291           (vec_select:V2SF (match_dup 1)
1292                            (parallel [(const_int 2) (const_int 3)]))))]
1293   "TARGET_NEON"
1294   "<VQH_mnem>.f32\t%P0, %e1, %f1"
1295   [(set_attr "vqh_mnem" "<VQH_mnem>")
1296    (set (attr "neon_type")
1297       (if_then_else (eq_attr "vqh_mnem" "vadd")
1298                     (const_string "neon_int_1") (const_string "neon_int_5")))]
1301 (define_insn "quad_halves_<code>v8hi"
1302   [(set (match_operand:V4HI 0 "s_register_operand" "+w")
1303         (vqh_ops:V4HI
1304           (vec_select:V4HI (match_operand:V8HI 1 "s_register_operand" "w")
1305                            (parallel [(const_int 0) (const_int 1)
1306                                       (const_int 2) (const_int 3)]))
1307           (vec_select:V4HI (match_dup 1)
1308                            (parallel [(const_int 4) (const_int 5)
1309                                       (const_int 6) (const_int 7)]))))]
1310   "TARGET_NEON"
1311   "<VQH_mnem>.<VQH_sign>16\t%P0, %e1, %f1"
1312   [(set_attr "vqh_mnem" "<VQH_mnem>")
1313    (set (attr "neon_type")
1314       (if_then_else (eq_attr "vqh_mnem" "vadd")
1315                     (const_string "neon_int_1") (const_string "neon_int_5")))]
1318 (define_insn "quad_halves_<code>v16qi"
1319   [(set (match_operand:V8QI 0 "s_register_operand" "+w")
1320         (vqh_ops:V8QI
1321           (vec_select:V8QI (match_operand:V16QI 1 "s_register_operand" "w")
1322                            (parallel [(const_int 0) (const_int 1)
1323                                       (const_int 2) (const_int 3)
1324                                       (const_int 4) (const_int 5)
1325                                       (const_int 6) (const_int 7)]))
1326           (vec_select:V8QI (match_dup 1)
1327                            (parallel [(const_int 8) (const_int 9)
1328                                       (const_int 10) (const_int 11)
1329                                       (const_int 12) (const_int 13)
1330                                       (const_int 14) (const_int 15)]))))]
1331   "TARGET_NEON"
1332   "<VQH_mnem>.<VQH_sign>8\t%P0, %e1, %f1"
1333   [(set_attr "vqh_mnem" "<VQH_mnem>")
1334    (set (attr "neon_type")
1335       (if_then_else (eq_attr "vqh_mnem" "vadd")
1336                     (const_string "neon_int_1") (const_string "neon_int_5")))]
1339 ; FIXME: We wouldn't need the following insns if we could write subregs of
1340 ; vector registers. Make an attempt at removing unnecessary moves, though
1341 ; we're really at the mercy of the register allocator.
1343 (define_insn "move_lo_quad_v4si"
1344   [(set (match_operand:V4SI 0 "s_register_operand" "+w")
1345         (vec_concat:V4SI
1346           (match_operand:V2SI 1 "s_register_operand" "w")
1347           (vec_select:V2SI (match_dup 0)
1348                            (parallel [(const_int 2) (const_int 3)]))))]
1349   "TARGET_NEON"
1351   int dest = REGNO (operands[0]);
1352   int src = REGNO (operands[1]);
1354   if (dest != src)
1355     return "vmov\t%e0, %P1";
1356   else
1357     return "";
1359   [(set_attr "neon_type" "neon_bp_simple")]
1362 (define_insn "move_lo_quad_v4sf"
1363   [(set (match_operand:V4SF 0 "s_register_operand" "+w")
1364         (vec_concat:V4SF
1365           (match_operand:V2SF 1 "s_register_operand" "w")
1366           (vec_select:V2SF (match_dup 0)
1367                            (parallel [(const_int 2) (const_int 3)]))))]
1368   "TARGET_NEON"
1370   int dest = REGNO (operands[0]);
1371   int src = REGNO (operands[1]);
1373   if (dest != src)
1374     return "vmov\t%e0, %P1";
1375   else
1376     return "";
1378   [(set_attr "neon_type" "neon_bp_simple")]
1381 (define_insn "move_lo_quad_v8hi"
1382   [(set (match_operand:V8HI 0 "s_register_operand" "+w")
1383         (vec_concat:V8HI
1384           (match_operand:V4HI 1 "s_register_operand" "w")
1385           (vec_select:V4HI (match_dup 0)
1386                            (parallel [(const_int 4) (const_int 5)
1387                                       (const_int 6) (const_int 7)]))))]
1388   "TARGET_NEON"
1390   int dest = REGNO (operands[0]);
1391   int src = REGNO (operands[1]);
1393   if (dest != src)
1394     return "vmov\t%e0, %P1";
1395   else
1396     return "";
1398   [(set_attr "neon_type" "neon_bp_simple")]
1401 (define_insn "move_lo_quad_v16qi"
1402   [(set (match_operand:V16QI 0 "s_register_operand" "+w")
1403         (vec_concat:V16QI
1404           (match_operand:V8QI 1 "s_register_operand" "w")
1405           (vec_select:V8QI (match_dup 0)
1406                            (parallel [(const_int 8)  (const_int 9)
1407                                       (const_int 10) (const_int 11)
1408                                       (const_int 12) (const_int 13)
1409                                       (const_int 14) (const_int 15)]))))]
1410   "TARGET_NEON"
1412   int dest = REGNO (operands[0]);
1413   int src = REGNO (operands[1]);
1415   if (dest != src)
1416     return "vmov\t%e0, %P1";
1417   else
1418     return "";
1420   [(set_attr "neon_type" "neon_bp_simple")]
1423 ;; Reduction operations
1425 (define_expand "reduc_splus_<mode>"
1426   [(match_operand:VD 0 "s_register_operand" "")
1427    (match_operand:VD 1 "s_register_operand" "")]
1428   "TARGET_NEON"
1430   neon_pairwise_reduce (operands[0], operands[1], <MODE>mode,
1431                         &gen_neon_vpadd_internal<mode>);
1432   DONE;
1435 (define_expand "reduc_splus_<mode>"
1436   [(match_operand:VQ 0 "s_register_operand" "")
1437    (match_operand:VQ 1 "s_register_operand" "")]
1438   "TARGET_NEON"
1440   rtx step1 = gen_reg_rtx (<V_HALF>mode);
1441   rtx res_d = gen_reg_rtx (<V_HALF>mode);
1443   emit_insn (gen_quad_halves_plus<mode> (step1, operands[1]));
1444   emit_insn (gen_reduc_splus_<V_half> (res_d, step1));
1445   emit_insn (gen_move_lo_quad_<mode> (operands[0], res_d));
1447   DONE;
1450 (define_insn "reduc_splus_v2di"
1451   [(set (match_operand:V2DI 0 "s_register_operand" "=w")
1452         (unspec:V2DI [(match_operand:V2DI 1 "s_register_operand" "w")]
1453                      UNSPEC_VPADD))]
1454   "TARGET_NEON"
1455   "vadd.i64\t%e0, %e1, %f1"
1456   [(set_attr "neon_type" "neon_int_1")]
1459 ;; NEON does not distinguish between signed and unsigned addition except on
1460 ;; widening operations.
1461 (define_expand "reduc_uplus_<mode>"
1462   [(match_operand:VDQI 0 "s_register_operand" "")
1463    (match_operand:VDQI 1 "s_register_operand" "")]
1464   "TARGET_NEON"
1466   emit_insn (gen_reduc_splus_<mode> (operands[0], operands[1]));
1467   DONE;
1470 (define_expand "reduc_smin_<mode>"
1471   [(match_operand:VD 0 "s_register_operand" "")
1472    (match_operand:VD 1 "s_register_operand" "")]
1473   "TARGET_NEON"
1475   neon_pairwise_reduce (operands[0], operands[1], <MODE>mode,
1476                         &gen_neon_vpsmin<mode>);
1477   DONE;
1480 (define_expand "reduc_smin_<mode>"
1481   [(match_operand:VQ 0 "s_register_operand" "")
1482    (match_operand:VQ 1 "s_register_operand" "")]
1483   "TARGET_NEON"
1485   rtx step1 = gen_reg_rtx (<V_HALF>mode);
1486   rtx res_d = gen_reg_rtx (<V_HALF>mode);
1488   emit_insn (gen_quad_halves_smin<mode> (step1, operands[1]));
1489   emit_insn (gen_reduc_smin_<V_half> (res_d, step1));
1490   emit_insn (gen_move_lo_quad_<mode> (operands[0], res_d));
1492   DONE;
1495 (define_expand "reduc_smax_<mode>"
1496   [(match_operand:VD 0 "s_register_operand" "")
1497    (match_operand:VD 1 "s_register_operand" "")]
1498   "TARGET_NEON"
1500   neon_pairwise_reduce (operands[0], operands[1], <MODE>mode,
1501                         &gen_neon_vpsmax<mode>);
1502   DONE;
1505 (define_expand "reduc_smax_<mode>"
1506   [(match_operand:VQ 0 "s_register_operand" "")
1507    (match_operand:VQ 1 "s_register_operand" "")]
1508   "TARGET_NEON"
1510   rtx step1 = gen_reg_rtx (<V_HALF>mode);
1511   rtx res_d = gen_reg_rtx (<V_HALF>mode);
1513   emit_insn (gen_quad_halves_smax<mode> (step1, operands[1]));
1514   emit_insn (gen_reduc_smax_<V_half> (res_d, step1));
1515   emit_insn (gen_move_lo_quad_<mode> (operands[0], res_d));
1517   DONE;
1520 (define_expand "reduc_umin_<mode>"
1521   [(match_operand:VDI 0 "s_register_operand" "")
1522    (match_operand:VDI 1 "s_register_operand" "")]
1523   "TARGET_NEON"
1525   neon_pairwise_reduce (operands[0], operands[1], <MODE>mode,
1526                         &gen_neon_vpumin<mode>);
1527   DONE;
1530 (define_expand "reduc_umin_<mode>"
1531   [(match_operand:VQI 0 "s_register_operand" "")
1532    (match_operand:VQI 1 "s_register_operand" "")]
1533   "TARGET_NEON"
1535   rtx step1 = gen_reg_rtx (<V_HALF>mode);
1536   rtx res_d = gen_reg_rtx (<V_HALF>mode);
1538   emit_insn (gen_quad_halves_umin<mode> (step1, operands[1]));
1539   emit_insn (gen_reduc_umin_<V_half> (res_d, step1));
1540   emit_insn (gen_move_lo_quad_<mode> (operands[0], res_d));
1542   DONE;
1545 (define_expand "reduc_umax_<mode>"
1546   [(match_operand:VDI 0 "s_register_operand" "")
1547    (match_operand:VDI 1 "s_register_operand" "")]
1548   "TARGET_NEON"
1550   neon_pairwise_reduce (operands[0], operands[1], <MODE>mode,
1551                         &gen_neon_vpumax<mode>);
1552   DONE;
1555 (define_expand "reduc_umax_<mode>"
1556   [(match_operand:VQI 0 "s_register_operand" "")
1557    (match_operand:VQI 1 "s_register_operand" "")]
1558   "TARGET_NEON"
1560   rtx step1 = gen_reg_rtx (<V_HALF>mode);
1561   rtx res_d = gen_reg_rtx (<V_HALF>mode);
1563   emit_insn (gen_quad_halves_umax<mode> (step1, operands[1]));
1564   emit_insn (gen_reduc_umax_<V_half> (res_d, step1));
1565   emit_insn (gen_move_lo_quad_<mode> (operands[0], res_d));
1567   DONE;
1570 (define_insn "neon_vpadd_internal<mode>"
1571   [(set (match_operand:VD 0 "s_register_operand" "=w")
1572         (unspec:VD [(match_operand:VD 1 "s_register_operand" "w")
1573                     (match_operand:VD 2 "s_register_operand" "w")]
1574                    UNSPEC_VPADD))]
1575   "TARGET_NEON"
1576   "vpadd.<V_if_elem>\t%P0, %P1, %P2"
1577   ;; Assume this schedules like vadd.
1578   [(set (attr "neon_type")
1579       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
1580                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1581                                   (const_string "neon_fp_vadd_ddd_vabs_dd")
1582                                   (const_string "neon_fp_vadd_qqq_vabs_qq"))
1583                     (const_string "neon_int_1")))]
1586 (define_insn "neon_vpsmin<mode>"
1587   [(set (match_operand:VD 0 "s_register_operand" "=w")
1588         (unspec:VD [(match_operand:VD 1 "s_register_operand" "w")
1589                     (match_operand:VD 2 "s_register_operand" "w")]
1590                    UNSPEC_VPSMIN))]
1591   "TARGET_NEON"
1592   "vpmin.<V_s_elem>\t%P0, %P1, %P2"
1593   ;; Assume this schedules like vmin.
1594   [(set (attr "neon_type")
1595       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
1596                     (const_string "neon_fp_vadd_ddd_vabs_dd")
1597                     (const_string "neon_int_5")))]
1600 (define_insn "neon_vpsmax<mode>"
1601   [(set (match_operand:VD 0 "s_register_operand" "=w")
1602         (unspec:VD [(match_operand:VD 1 "s_register_operand" "w")
1603                     (match_operand:VD 2 "s_register_operand" "w")]
1604                    UNSPEC_VPSMAX))]
1605   "TARGET_NEON"
1606   "vpmax.<V_s_elem>\t%P0, %P1, %P2"
1607   ;; Assume this schedules like vmax.
1608   [(set (attr "neon_type")
1609       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
1610                     (const_string "neon_fp_vadd_ddd_vabs_dd")
1611                     (const_string "neon_int_5")))]
1614 (define_insn "neon_vpumin<mode>"
1615   [(set (match_operand:VDI 0 "s_register_operand" "=w")
1616         (unspec:VDI [(match_operand:VDI 1 "s_register_operand" "w")
1617                      (match_operand:VDI 2 "s_register_operand" "w")]
1618                    UNSPEC_VPUMIN))]
1619   "TARGET_NEON"
1620   "vpmin.<V_u_elem>\t%P0, %P1, %P2"
1621   ;; Assume this schedules like umin.
1622   [(set_attr "neon_type" "neon_int_5")]
1625 (define_insn "neon_vpumax<mode>"
1626   [(set (match_operand:VDI 0 "s_register_operand" "=w")
1627         (unspec:VDI [(match_operand:VDI 1 "s_register_operand" "w")
1628                      (match_operand:VDI 2 "s_register_operand" "w")]
1629                    UNSPEC_VPUMAX))]
1630   "TARGET_NEON"
1631   "vpmax.<V_u_elem>\t%P0, %P1, %P2"
1632   ;; Assume this schedules like umax.
1633   [(set_attr "neon_type" "neon_int_5")]
1636 ;; Saturating arithmetic
1638 ; NOTE: Neon supports many more saturating variants of instructions than the
1639 ; following, but these are all GCC currently understands.
1640 ; FIXME: Actually, GCC doesn't know how to create saturating add/sub by itself
1641 ; yet either, although these patterns may be used by intrinsics when they're
1642 ; added.
1644 (define_insn "*ss_add<mode>_neon"
1645   [(set (match_operand:VD 0 "s_register_operand" "=w")
1646        (ss_plus:VD (match_operand:VD 1 "s_register_operand" "w")
1647                    (match_operand:VD 2 "s_register_operand" "w")))]
1648   "TARGET_NEON"
1649   "vqadd.<V_s_elem>\t%P0, %P1, %P2"
1650   [(set_attr "neon_type" "neon_int_4")]
1653 (define_insn "*us_add<mode>_neon"
1654   [(set (match_operand:VD 0 "s_register_operand" "=w")
1655        (us_plus:VD (match_operand:VD 1 "s_register_operand" "w")
1656                    (match_operand:VD 2 "s_register_operand" "w")))]
1657   "TARGET_NEON"
1658   "vqadd.<V_u_elem>\t%P0, %P1, %P2"
1659   [(set_attr "neon_type" "neon_int_4")]
1662 (define_insn "*ss_sub<mode>_neon"
1663   [(set (match_operand:VD 0 "s_register_operand" "=w")
1664        (ss_minus:VD (match_operand:VD 1 "s_register_operand" "w")
1665                     (match_operand:VD 2 "s_register_operand" "w")))]
1666   "TARGET_NEON"
1667   "vqsub.<V_s_elem>\t%P0, %P1, %P2"
1668   [(set_attr "neon_type" "neon_int_5")]
1671 (define_insn "*us_sub<mode>_neon"
1672   [(set (match_operand:VD 0 "s_register_operand" "=w")
1673        (us_minus:VD (match_operand:VD 1 "s_register_operand" "w")
1674                     (match_operand:VD 2 "s_register_operand" "w")))]
1675   "TARGET_NEON"
1676   "vqsub.<V_u_elem>\t%P0, %P1, %P2"
1677   [(set_attr "neon_type" "neon_int_5")]
1680 ;; Patterns for builtins.
1682 ; good for plain vadd, vaddq.
1684 (define_insn "neon_vadd<mode>"
1685   [(set (match_operand:VDQX 0 "s_register_operand" "=w")
1686         (unspec:VDQX [(match_operand:VDQX 1 "s_register_operand" "w")
1687                       (match_operand:VDQX 2 "s_register_operand" "w")
1688                       (match_operand:SI 3 "immediate_operand" "i")]
1689                      UNSPEC_VADD))]
1690   "TARGET_NEON"
1691   "vadd.<V_if_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1692   [(set (attr "neon_type")
1693       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
1694                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1695                                   (const_string "neon_fp_vadd_ddd_vabs_dd")
1696                                   (const_string "neon_fp_vadd_qqq_vabs_qq"))
1697                     (const_string "neon_int_1")))]
1700 ; operand 3 represents in bits:
1701 ;  bit 0: signed (vs unsigned).
1702 ;  bit 1: rounding (vs none).
1704 (define_insn "neon_vaddl<mode>"
1705   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
1706         (unspec:<V_widen> [(match_operand:VDI 1 "s_register_operand" "w")
1707                            (match_operand:VDI 2 "s_register_operand" "w")
1708                            (match_operand:SI 3 "immediate_operand" "i")]
1709                           UNSPEC_VADDL))]
1710   "TARGET_NEON"
1711   "vaddl.%T3%#<V_sz_elem>\t%q0, %P1, %P2"
1712   [(set_attr "neon_type" "neon_int_3")]
1715 (define_insn "neon_vaddw<mode>"
1716   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
1717         (unspec:<V_widen> [(match_operand:<V_widen> 1 "s_register_operand" "w")
1718                            (match_operand:VDI 2 "s_register_operand" "w")
1719                            (match_operand:SI 3 "immediate_operand" "i")]
1720                           UNSPEC_VADDW))]
1721   "TARGET_NEON"
1722   "vaddw.%T3%#<V_sz_elem>\t%q0, %q1, %P2"
1723   [(set_attr "neon_type" "neon_int_2")]
1726 ; vhadd and vrhadd.
1728 (define_insn "neon_vhadd<mode>"
1729   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
1730         (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
1731                        (match_operand:VDQIW 2 "s_register_operand" "w")
1732                        (match_operand:SI 3 "immediate_operand" "i")]
1733                       UNSPEC_VHADD))]
1734   "TARGET_NEON"
1735   "v%O3hadd.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1736   [(set_attr "neon_type" "neon_int_4")]
1739 (define_insn "neon_vqadd<mode>"
1740   [(set (match_operand:VDQIX 0 "s_register_operand" "=w")
1741         (unspec:VDQIX [(match_operand:VDQIX 1 "s_register_operand" "w")
1742                        (match_operand:VDQIX 2 "s_register_operand" "w")
1743                        (match_operand:SI 3 "immediate_operand" "i")]
1744                      UNSPEC_VQADD))]
1745   "TARGET_NEON"
1746   "vqadd.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1747   [(set_attr "neon_type" "neon_int_4")]
1750 (define_insn "neon_vaddhn<mode>"
1751   [(set (match_operand:<V_narrow> 0 "s_register_operand" "=w")
1752         (unspec:<V_narrow> [(match_operand:VN 1 "s_register_operand" "w")
1753                             (match_operand:VN 2 "s_register_operand" "w")
1754                             (match_operand:SI 3 "immediate_operand" "i")]
1755                            UNSPEC_VADDHN))]
1756   "TARGET_NEON"
1757   "v%O3addhn.<V_if_elem>\t%P0, %q1, %q2"
1758   [(set_attr "neon_type" "neon_int_4")]
1761 (define_insn "neon_vmul<mode>"
1762   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
1763         (unspec:VDQW [(match_operand:VDQW 1 "s_register_operand" "w")
1764                       (match_operand:VDQW 2 "s_register_operand" "w")
1765                       (match_operand:SI 3 "immediate_operand" "i")]
1766                      UNSPEC_VMUL))]
1767   "TARGET_NEON"
1768   "vmul.%F3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1769   [(set (attr "neon_type")
1770       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
1771                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1772                                   (const_string "neon_fp_vadd_ddd_vabs_dd")
1773                                   (const_string "neon_fp_vadd_qqq_vabs_qq"))
1774                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1775                                   (if_then_else
1776                                     (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1777                                     (const_string "neon_mul_ddd_8_16_qdd_16_8_long_32_16_long")
1778                                     (const_string "neon_mul_qqq_8_16_32_ddd_32"))
1779                                   (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1780                                     (const_string "neon_mul_qqq_8_16_32_ddd_32")
1781                                     (const_string "neon_mul_qqq_8_16_32_ddd_32")))))]
1784 (define_insn "neon_vmla<mode>"
1785   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
1786         (unspec:VDQW [(match_operand:VDQW 1 "s_register_operand" "0")
1787                       (match_operand:VDQW 2 "s_register_operand" "w")
1788                       (match_operand:VDQW 3 "s_register_operand" "w")
1789                      (match_operand:SI 4 "immediate_operand" "i")]
1790                     UNSPEC_VMLA))]
1791   "TARGET_NEON"
1792   "vmla.<V_if_elem>\t%<V_reg>0, %<V_reg>2, %<V_reg>3"
1793   [(set (attr "neon_type")
1794       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
1795                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1796                                   (const_string "neon_fp_vmla_ddd")
1797                                   (const_string "neon_fp_vmla_qqq"))
1798                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1799                                   (if_then_else
1800                                     (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1801                                     (const_string "neon_mla_ddd_8_16_qdd_16_8_long_32_16_long")
1802                                     (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long"))
1803                                   (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1804                                     (const_string "neon_mla_qqq_8_16")
1805                                     (const_string "neon_mla_qqq_32_qqd_32_scalar")))))]
1808 (define_insn "neon_vmlal<mode>"
1809   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
1810         (unspec:<V_widen> [(match_operand:<V_widen> 1 "s_register_operand" "0")
1811                            (match_operand:VW 2 "s_register_operand" "w")
1812                            (match_operand:VW 3 "s_register_operand" "w")
1813                            (match_operand:SI 4 "immediate_operand" "i")]
1814                           UNSPEC_VMLAL))]
1815   "TARGET_NEON"
1816   "vmlal.%T4%#<V_sz_elem>\t%q0, %P2, %P3"
1817   [(set (attr "neon_type")
1818      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1819                    (const_string "neon_mla_ddd_8_16_qdd_16_8_long_32_16_long")
1820                    (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long")))]
1823 (define_insn "neon_vmls<mode>"
1824   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
1825         (unspec:VDQW [(match_operand:VDQW 1 "s_register_operand" "0")
1826                       (match_operand:VDQW 2 "s_register_operand" "w")
1827                       (match_operand:VDQW 3 "s_register_operand" "w")
1828                      (match_operand:SI 4 "immediate_operand" "i")]
1829                     UNSPEC_VMLS))]
1830   "TARGET_NEON"
1831   "vmls.<V_if_elem>\t%<V_reg>0, %<V_reg>2, %<V_reg>3"
1832   [(set (attr "neon_type")
1833       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
1834                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1835                                   (const_string "neon_fp_vmla_ddd")
1836                                   (const_string "neon_fp_vmla_qqq"))
1837                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1838                                   (if_then_else
1839                                     (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1840                                     (const_string "neon_mla_ddd_8_16_qdd_16_8_long_32_16_long")
1841                                     (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long"))
1842                                   (if_then_else
1843                                     (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1844                                     (const_string "neon_mla_qqq_8_16")
1845                                     (const_string "neon_mla_qqq_32_qqd_32_scalar")))))]
1848 (define_insn "neon_vmlsl<mode>"
1849   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
1850         (unspec:<V_widen> [(match_operand:<V_widen> 1 "s_register_operand" "0")
1851                            (match_operand:VW 2 "s_register_operand" "w")
1852                            (match_operand:VW 3 "s_register_operand" "w")
1853                            (match_operand:SI 4 "immediate_operand" "i")]
1854                           UNSPEC_VMLSL))]
1855   "TARGET_NEON"
1856   "vmlsl.%T4%#<V_sz_elem>\t%q0, %P2, %P3"
1857   [(set (attr "neon_type")
1858      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1859                    (const_string "neon_mla_ddd_8_16_qdd_16_8_long_32_16_long")
1860                    (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long")))]
1863 (define_insn "neon_vqdmulh<mode>"
1864   [(set (match_operand:VMDQI 0 "s_register_operand" "=w")
1865         (unspec:VMDQI [(match_operand:VMDQI 1 "s_register_operand" "w")
1866                        (match_operand:VMDQI 2 "s_register_operand" "w")
1867                        (match_operand:SI 3 "immediate_operand" "i")]
1868                       UNSPEC_VQDMULH))]
1869   "TARGET_NEON"
1870   "vq%O3dmulh.<V_s_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1871   [(set (attr "neon_type")
1872      (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1873         (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1874                       (const_string "neon_mul_ddd_8_16_qdd_16_8_long_32_16_long")
1875                       (const_string "neon_mul_qqq_8_16_32_ddd_32"))
1876         (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1877                       (const_string "neon_mul_qqq_8_16_32_ddd_32")
1878                       (const_string "neon_mul_qqq_8_16_32_ddd_32"))))]
1881 (define_insn "neon_vqdmlal<mode>"
1882   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
1883         (unspec:<V_widen> [(match_operand:<V_widen> 1 "s_register_operand" "0")
1884                            (match_operand:VMDI 2 "s_register_operand" "w")
1885                            (match_operand:VMDI 3 "s_register_operand" "w")
1886                            (match_operand:SI 4 "immediate_operand" "i")]
1887                           UNSPEC_VQDMLAL))]
1888   "TARGET_NEON"
1889   "vqdmlal.<V_s_elem>\t%q0, %P2, %P3"
1890   [(set (attr "neon_type")
1891      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1892                    (const_string "neon_mla_ddd_8_16_qdd_16_8_long_32_16_long")
1893                    (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long")))]
1896 (define_insn "neon_vqdmlsl<mode>"
1897   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
1898         (unspec:<V_widen> [(match_operand:<V_widen> 1 "s_register_operand" "0")
1899                            (match_operand:VMDI 2 "s_register_operand" "w")
1900                            (match_operand:VMDI 3 "s_register_operand" "w")
1901                            (match_operand:SI 4 "immediate_operand" "i")]
1902                           UNSPEC_VQDMLSL))]
1903   "TARGET_NEON"
1904   "vqdmlsl.<V_s_elem>\t%q0, %P2, %P3"
1905   [(set (attr "neon_type")
1906      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1907                    (const_string "neon_mla_ddd_8_16_qdd_16_8_long_32_16_long")
1908                    (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long")))]
1911 (define_insn "neon_vmull<mode>"
1912   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
1913         (unspec:<V_widen> [(match_operand:VW 1 "s_register_operand" "w")
1914                            (match_operand:VW 2 "s_register_operand" "w")
1915                            (match_operand:SI 3 "immediate_operand" "i")]
1916                           UNSPEC_VMULL))]
1917   "TARGET_NEON"
1918   "vmull.%T3%#<V_sz_elem>\t%q0, %P1, %P2"
1919   [(set (attr "neon_type")
1920      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1921                    (const_string "neon_mul_ddd_8_16_qdd_16_8_long_32_16_long")
1922                    (const_string "neon_mul_qdd_64_32_long_qqd_16_ddd_32_scalar_64_32_long_scalar")))]
1925 (define_insn "neon_vqdmull<mode>"
1926   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
1927         (unspec:<V_widen> [(match_operand:VMDI 1 "s_register_operand" "w")
1928                            (match_operand:VMDI 2 "s_register_operand" "w")
1929                            (match_operand:SI 3 "immediate_operand" "i")]
1930                           UNSPEC_VQDMULL))]
1931   "TARGET_NEON"
1932   "vqdmull.<V_s_elem>\t%q0, %P1, %P2"
1933   [(set (attr "neon_type")
1934      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
1935                    (const_string "neon_mul_ddd_8_16_qdd_16_8_long_32_16_long")
1936                    (const_string "neon_mul_qdd_64_32_long_qqd_16_ddd_32_scalar_64_32_long_scalar")))]
1939 (define_insn "neon_vsub<mode>"
1940   [(set (match_operand:VDQX 0 "s_register_operand" "=w")
1941         (unspec:VDQX [(match_operand:VDQX 1 "s_register_operand" "w")
1942                       (match_operand:VDQX 2 "s_register_operand" "w")
1943                       (match_operand:SI 3 "immediate_operand" "i")]
1944                      UNSPEC_VSUB))]
1945   "TARGET_NEON"
1946   "vsub.<V_if_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1947   [(set (attr "neon_type")
1948       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
1949                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
1950                                   (const_string "neon_fp_vadd_ddd_vabs_dd")
1951                                   (const_string "neon_fp_vadd_qqq_vabs_qq"))
1952                     (const_string "neon_int_2")))]
1955 (define_insn "neon_vsubl<mode>"
1956   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
1957         (unspec:<V_widen> [(match_operand:VDI 1 "s_register_operand" "w")
1958                            (match_operand:VDI 2 "s_register_operand" "w")
1959                            (match_operand:SI 3 "immediate_operand" "i")]
1960                           UNSPEC_VSUBL))]
1961   "TARGET_NEON"
1962   "vsubl.%T3%#<V_sz_elem>\t%q0, %P1, %P2"
1963   [(set_attr "neon_type" "neon_int_2")]
1966 (define_insn "neon_vsubw<mode>"
1967   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
1968         (unspec:<V_widen> [(match_operand:<V_widen> 1 "s_register_operand" "w")
1969                            (match_operand:VDI 2 "s_register_operand" "w")
1970                            (match_operand:SI 3 "immediate_operand" "i")]
1971                           UNSPEC_VSUBW))]
1972   "TARGET_NEON"
1973   "vsubw.%T3%#<V_sz_elem>\t%q0, %q1, %P2"
1974   [(set_attr "neon_type" "neon_int_2")]
1977 (define_insn "neon_vqsub<mode>"
1978   [(set (match_operand:VDQIX 0 "s_register_operand" "=w")
1979         (unspec:VDQIX [(match_operand:VDQIX 1 "s_register_operand" "w")
1980                        (match_operand:VDQIX 2 "s_register_operand" "w")
1981                        (match_operand:SI 3 "immediate_operand" "i")]
1982                       UNSPEC_VQSUB))]
1983   "TARGET_NEON"
1984   "vqsub.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1985   [(set_attr "neon_type" "neon_int_5")]
1988 (define_insn "neon_vhsub<mode>"
1989   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
1990         (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
1991                        (match_operand:VDQIW 2 "s_register_operand" "w")
1992                        (match_operand:SI 3 "immediate_operand" "i")]
1993                       UNSPEC_VHSUB))]
1994   "TARGET_NEON"
1995   "vhsub.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
1996   [(set_attr "neon_type" "neon_int_5")]
1999 (define_insn "neon_vsubhn<mode>"
2000   [(set (match_operand:<V_narrow> 0 "s_register_operand" "=w")
2001         (unspec:<V_narrow> [(match_operand:VN 1 "s_register_operand" "w")
2002                             (match_operand:VN 2 "s_register_operand" "w")
2003                             (match_operand:SI 3 "immediate_operand" "i")]
2004                            UNSPEC_VSUBHN))]
2005   "TARGET_NEON"
2006   "v%O3subhn.<V_if_elem>\t%P0, %q1, %q2"
2007   [(set_attr "neon_type" "neon_int_4")]
2010 (define_insn "neon_vceq<mode>"
2011   [(set (match_operand:<V_cmp_result> 0 "s_register_operand" "=w")
2012         (unspec:<V_cmp_result> [(match_operand:VDQW 1 "s_register_operand" "w")
2013                                 (match_operand:VDQW 2 "s_register_operand" "w")
2014                                 (match_operand:SI 3 "immediate_operand" "i")]
2015                                UNSPEC_VCEQ))]
2016   "TARGET_NEON"
2017   "vceq.<V_if_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
2018   [(set (attr "neon_type")
2019       (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2020                     (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2021                                   (const_string "neon_fp_vadd_ddd_vabs_dd")
2022                                   (const_string "neon_fp_vadd_qqq_vabs_qq"))
2023                     (const_string "neon_int_5")))]
2026 (define_insn "neon_vcge<mode>"
2027   [(set (match_operand:<V_cmp_result> 0 "s_register_operand" "=w")
2028         (unspec:<V_cmp_result> [(match_operand:VDQW 1 "s_register_operand" "w")
2029                                 (match_operand:VDQW 2 "s_register_operand" "w")
2030                                 (match_operand:SI 3 "immediate_operand" "i")]
2031                                UNSPEC_VCGE))]
2032   "TARGET_NEON"
2033   "vcge.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
2034   [(set (attr "neon_type")
2035      (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2036                    (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2037                                  (const_string "neon_fp_vadd_ddd_vabs_dd")
2038                                  (const_string "neon_fp_vadd_qqq_vabs_qq"))
2039                    (const_string "neon_int_5")))]
2042 (define_insn "neon_vcgt<mode>"
2043   [(set (match_operand:<V_cmp_result> 0 "s_register_operand" "=w")
2044         (unspec:<V_cmp_result> [(match_operand:VDQW 1 "s_register_operand" "w")
2045                                 (match_operand:VDQW 2 "s_register_operand" "w")
2046                                 (match_operand:SI 3 "immediate_operand" "i")]
2047                                UNSPEC_VCGT))]
2048   "TARGET_NEON"
2049   "vcgt.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
2050   [(set (attr "neon_type")
2051      (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2052                    (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2053                                  (const_string "neon_fp_vadd_ddd_vabs_dd")
2054                                  (const_string "neon_fp_vadd_qqq_vabs_qq"))
2055                    (const_string "neon_int_5")))]
2058 (define_insn "neon_vcage<mode>"
2059   [(set (match_operand:<V_cmp_result> 0 "s_register_operand" "=w")
2060         (unspec:<V_cmp_result> [(match_operand:VCVTF 1 "s_register_operand" "w")
2061                                 (match_operand:VCVTF 2 "s_register_operand" "w")
2062                                 (match_operand:SI 3 "immediate_operand" "i")]
2063                                UNSPEC_VCAGE))]
2064   "TARGET_NEON"
2065   "vacge.<V_if_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
2066   [(set (attr "neon_type")
2067      (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2068                    (const_string "neon_fp_vadd_ddd_vabs_dd")
2069                    (const_string "neon_fp_vadd_qqq_vabs_qq")))]
2072 (define_insn "neon_vcagt<mode>"
2073   [(set (match_operand:<V_cmp_result> 0 "s_register_operand" "=w")
2074         (unspec:<V_cmp_result> [(match_operand:VCVTF 1 "s_register_operand" "w")
2075                                 (match_operand:VCVTF 2 "s_register_operand" "w")
2076                                 (match_operand:SI 3 "immediate_operand" "i")]
2077                                UNSPEC_VCAGT))]
2078   "TARGET_NEON"
2079   "vacgt.<V_if_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
2080   [(set (attr "neon_type")
2081      (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2082                    (const_string "neon_fp_vadd_ddd_vabs_dd")
2083                    (const_string "neon_fp_vadd_qqq_vabs_qq")))]
2086 (define_insn "neon_vtst<mode>"
2087   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
2088         (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
2089                        (match_operand:VDQIW 2 "s_register_operand" "w")
2090                        (match_operand:SI 3 "immediate_operand" "i")]
2091                       UNSPEC_VTST))]
2092   "TARGET_NEON"
2093   "vtst.<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
2094   [(set_attr "neon_type" "neon_int_4")]
2097 (define_insn "neon_vabd<mode>"
2098   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
2099         (unspec:VDQW [(match_operand:VDQW 1 "s_register_operand" "w")
2100                       (match_operand:VDQW 2 "s_register_operand" "w")
2101                       (match_operand:SI 3 "immediate_operand" "i")]
2102                      UNSPEC_VABD))]
2103   "TARGET_NEON"
2104   "vabd.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
2105   [(set (attr "neon_type")
2106      (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2107                    (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2108                                  (const_string "neon_fp_vadd_ddd_vabs_dd")
2109                                  (const_string "neon_fp_vadd_qqq_vabs_qq"))
2110                    (const_string "neon_int_5")))]
2113 (define_insn "neon_vabdl<mode>"
2114   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
2115         (unspec:<V_widen> [(match_operand:VW 1 "s_register_operand" "w")
2116                            (match_operand:VW 2 "s_register_operand" "w")
2117                            (match_operand:SI 3 "immediate_operand" "i")]
2118                           UNSPEC_VABDL))]
2119   "TARGET_NEON"
2120   "vabdl.%T3%#<V_sz_elem>\t%q0, %P1, %P2"
2121   [(set_attr "neon_type" "neon_int_5")]
2124 (define_insn "neon_vaba<mode>"
2125   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
2126         (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "0")
2127                        (match_operand:VDQIW 2 "s_register_operand" "w")
2128                        (match_operand:VDQIW 3 "s_register_operand" "w")
2129                        (match_operand:SI 4 "immediate_operand" "i")]
2130                       UNSPEC_VABA))]
2131   "TARGET_NEON"
2132   "vaba.%T4%#<V_sz_elem>\t%<V_reg>0, %<V_reg>2, %<V_reg>3"
2133   [(set (attr "neon_type")
2134      (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2135                    (const_string "neon_vaba") (const_string "neon_vaba_qqq")))]
2138 (define_insn "neon_vabal<mode>"
2139   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
2140         (unspec:<V_widen> [(match_operand:<V_widen> 1 "s_register_operand" "0")
2141                            (match_operand:VW 2 "s_register_operand" "w")
2142                            (match_operand:VW 3 "s_register_operand" "w")
2143                            (match_operand:SI 4 "immediate_operand" "i")]
2144                           UNSPEC_VABAL))]
2145   "TARGET_NEON"
2146   "vabal.%T4%#<V_sz_elem>\t%q0, %P2, %P3"
2147   [(set_attr "neon_type" "neon_vaba")]
2150 (define_insn "neon_vmax<mode>"
2151   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
2152         (unspec:VDQW [(match_operand:VDQW 1 "s_register_operand" "w")
2153                       (match_operand:VDQW 2 "s_register_operand" "w")
2154                       (match_operand:SI 3 "immediate_operand" "i")]
2155                      UNSPEC_VMAX))]
2156   "TARGET_NEON"
2157   "vmax.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
2158   [(set (attr "neon_type")
2159     (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2160                   (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2161                                 (const_string "neon_fp_vadd_ddd_vabs_dd")
2162                                 (const_string "neon_fp_vadd_qqq_vabs_qq"))
2163                   (const_string "neon_int_5")))]
2166 (define_insn "neon_vmin<mode>"
2167   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
2168         (unspec:VDQW [(match_operand:VDQW 1 "s_register_operand" "w")
2169                       (match_operand:VDQW 2 "s_register_operand" "w")
2170                       (match_operand:SI 3 "immediate_operand" "i")]
2171                      UNSPEC_VMIN))]
2172   "TARGET_NEON"
2173   "vmin.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
2174   [(set (attr "neon_type")
2175     (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2176                   (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2177                                 (const_string "neon_fp_vadd_ddd_vabs_dd")
2178                                 (const_string "neon_fp_vadd_qqq_vabs_qq"))
2179                   (const_string "neon_int_5")))]
2182 (define_expand "neon_vpadd<mode>"
2183   [(match_operand:VD 0 "s_register_operand" "=w")
2184    (match_operand:VD 1 "s_register_operand" "w")
2185    (match_operand:VD 2 "s_register_operand" "w")
2186    (match_operand:SI 3 "immediate_operand" "i")]
2187   "TARGET_NEON"
2189   emit_insn (gen_neon_vpadd_internal<mode> (operands[0], operands[1],
2190                                             operands[2]));
2191   DONE;
2194 (define_insn "neon_vpaddl<mode>"
2195   [(set (match_operand:<V_double_width> 0 "s_register_operand" "=w")
2196         (unspec:<V_double_width> [(match_operand:VDQIW 1 "s_register_operand" "w")
2197                                   (match_operand:SI 2 "immediate_operand" "i")]
2198                                  UNSPEC_VPADDL))]
2199   "TARGET_NEON"
2200   "vpaddl.%T2%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1"
2201   ;; Assume this schedules like vaddl.
2202   [(set_attr "neon_type" "neon_int_3")]
2205 (define_insn "neon_vpadal<mode>"
2206   [(set (match_operand:<V_double_width> 0 "s_register_operand" "=w")
2207         (unspec:<V_double_width> [(match_operand:<V_double_width> 1 "s_register_operand" "0")
2208                                   (match_operand:VDQIW 2 "s_register_operand" "w")
2209                                   (match_operand:SI 3 "immediate_operand" "i")]
2210                                  UNSPEC_VPADAL))]
2211   "TARGET_NEON"
2212   "vpadal.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>2"
2213   ;; Assume this schedules like vpadd.
2214   [(set_attr "neon_type" "neon_int_1")]
2217 (define_insn "neon_vpmax<mode>"
2218   [(set (match_operand:VD 0 "s_register_operand" "=w")
2219         (unspec:VD [(match_operand:VD 1 "s_register_operand" "w")
2220                     (match_operand:VD 2 "s_register_operand" "w")
2221                     (match_operand:SI 3 "immediate_operand" "i")]
2222                    UNSPEC_VPMAX))]
2223   "TARGET_NEON"
2224   "vpmax.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
2225   ;; Assume this schedules like vmax.
2226   [(set (attr "neon_type")
2227     (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2228                   (const_string "neon_fp_vadd_ddd_vabs_dd")
2229                   (const_string "neon_int_5")))]
2232 (define_insn "neon_vpmin<mode>"
2233   [(set (match_operand:VD 0 "s_register_operand" "=w")
2234         (unspec:VD [(match_operand:VD 1 "s_register_operand" "w")
2235                     (match_operand:VD 2 "s_register_operand" "w")
2236                     (match_operand:SI 3 "immediate_operand" "i")]
2237                    UNSPEC_VPMIN))]
2238   "TARGET_NEON"
2239   "vpmin.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
2240   ;; Assume this schedules like vmin.
2241   [(set (attr "neon_type")
2242     (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2243                   (const_string "neon_fp_vadd_ddd_vabs_dd")
2244                   (const_string "neon_int_5")))]
2247 (define_insn "neon_vrecps<mode>"
2248   [(set (match_operand:VCVTF 0 "s_register_operand" "=w")
2249         (unspec:VCVTF [(match_operand:VCVTF 1 "s_register_operand" "w")
2250                        (match_operand:VCVTF 2 "s_register_operand" "w")
2251                        (match_operand:SI 3 "immediate_operand" "i")]
2252                       UNSPEC_VRECPS))]
2253   "TARGET_NEON"
2254   "vrecps.<V_if_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
2255   [(set (attr "neon_type")
2256       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2257                     (const_string "neon_fp_vrecps_vrsqrts_ddd")
2258                     (const_string "neon_fp_vrecps_vrsqrts_qqq")))]
2261 (define_insn "neon_vrsqrts<mode>"
2262   [(set (match_operand:VCVTF 0 "s_register_operand" "=w")
2263         (unspec:VCVTF [(match_operand:VCVTF 1 "s_register_operand" "w")
2264                        (match_operand:VCVTF 2 "s_register_operand" "w")
2265                        (match_operand:SI 3 "immediate_operand" "i")]
2266                       UNSPEC_VRSQRTS))]
2267   "TARGET_NEON"
2268   "vrsqrts.<V_if_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
2269   [(set (attr "neon_type")
2270       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2271                     (const_string "neon_fp_vrecps_vrsqrts_ddd")
2272                     (const_string "neon_fp_vrecps_vrsqrts_qqq")))]
2275 (define_insn "neon_vabs<mode>"
2276   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
2277         (unspec:VDQW [(match_operand:VDQW 1 "s_register_operand" "w")
2278                       (match_operand:SI 2 "immediate_operand" "i")]
2279                      UNSPEC_VABS))]
2280   "TARGET_NEON"
2281   "vabs.<V_s_elem>\t%<V_reg>0, %<V_reg>1"
2282   [(set (attr "neon_type")
2283      (if_then_else (ior (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2284                         (ne (symbol_ref "<Is_float_mode>") (const_int 0)))
2285                    (if_then_else
2286                       (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2287                       (const_string "neon_fp_vadd_ddd_vabs_dd")
2288                       (const_string "neon_fp_vadd_qqq_vabs_qq"))
2289                    (const_string "neon_vqneg_vqabs")))]
2292 (define_insn "neon_vqabs<mode>"
2293   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
2294         (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
2295                        (match_operand:SI 2 "immediate_operand" "i")]
2296                       UNSPEC_VQABS))]
2297   "TARGET_NEON"
2298   "vqabs.<V_s_elem>\t%<V_reg>0, %<V_reg>1"
2299   [(set_attr "neon_type" "neon_vqneg_vqabs")]
2302 (define_expand "neon_vneg<mode>"
2303   [(match_operand:VDQW 0 "s_register_operand" "")
2304    (match_operand:VDQW 1 "s_register_operand" "")
2305    (match_operand:SI 2 "immediate_operand" "")]
2306   "TARGET_NEON"
2308   emit_insn (gen_neg<mode>2 (operands[0], operands[1]));
2309   DONE;
2312 (define_insn "neon_vqneg<mode>"
2313   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
2314         (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
2315                        (match_operand:SI 2 "immediate_operand" "i")]
2316                       UNSPEC_VQNEG))]
2317   "TARGET_NEON"
2318   "vqneg.<V_s_elem>\t%<V_reg>0, %<V_reg>1"
2319   [(set_attr "neon_type" "neon_vqneg_vqabs")]
2322 (define_insn "neon_vcls<mode>"
2323   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
2324         (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
2325                        (match_operand:SI 2 "immediate_operand" "i")]
2326                       UNSPEC_VCLS))]
2327   "TARGET_NEON"
2328   "vcls.<V_s_elem>\t%<V_reg>0, %<V_reg>1"
2329   [(set_attr "neon_type" "neon_int_1")]
2332 (define_insn "neon_vclz<mode>"
2333   [(set (match_operand:VDQIW 0 "s_register_operand" "=w")
2334         (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w")
2335                        (match_operand:SI 2 "immediate_operand" "i")]
2336                       UNSPEC_VCLZ))]
2337   "TARGET_NEON"
2338   "vclz.<V_if_elem>\t%<V_reg>0, %<V_reg>1"
2339   [(set_attr "neon_type" "neon_int_1")]
2342 (define_insn "neon_vcnt<mode>"
2343   [(set (match_operand:VE 0 "s_register_operand" "=w")
2344         (unspec:VE [(match_operand:VE 1 "s_register_operand" "w")
2345                     (match_operand:SI 2 "immediate_operand" "i")]
2346                    UNSPEC_VCNT))]
2347   "TARGET_NEON"
2348   "vcnt.<V_sz_elem>\t%<V_reg>0, %<V_reg>1"
2349   [(set_attr "neon_type" "neon_int_1")]
2352 (define_insn "neon_vrecpe<mode>"
2353   [(set (match_operand:V32 0 "s_register_operand" "=w")
2354         (unspec:V32 [(match_operand:V32 1 "s_register_operand" "w")
2355                      (match_operand:SI 2 "immediate_operand" "i")]
2356                     UNSPEC_VRECPE))]
2357   "TARGET_NEON"
2358   "vrecpe.<V_u_elem>\t%<V_reg>0, %<V_reg>1"
2359   [(set (attr "neon_type")
2360       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2361                     (const_string "neon_fp_vadd_ddd_vabs_dd")
2362                     (const_string "neon_fp_vadd_qqq_vabs_qq")))]
2365 (define_insn "neon_vrsqrte<mode>"
2366   [(set (match_operand:V32 0 "s_register_operand" "=w")
2367         (unspec:V32 [(match_operand:V32 1 "s_register_operand" "w")
2368                      (match_operand:SI 2 "immediate_operand" "i")]
2369                     UNSPEC_VRSQRTE))]
2370   "TARGET_NEON"
2371   "vrsqrte.<V_u_elem>\t%<V_reg>0, %<V_reg>1"
2372   [(set (attr "neon_type")
2373       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2374                     (const_string "neon_fp_vadd_ddd_vabs_dd")
2375                     (const_string "neon_fp_vadd_qqq_vabs_qq")))]
2378 (define_expand "neon_vmvn<mode>"
2379   [(match_operand:VDQIW 0 "s_register_operand" "")
2380    (match_operand:VDQIW 1 "s_register_operand" "")
2381    (match_operand:SI 2 "immediate_operand" "")]
2382   "TARGET_NEON"
2384   emit_insn (gen_one_cmpl<mode>2 (operands[0], operands[1]));
2385   DONE;
2388 ;; FIXME: 32-bit element sizes are a bit funky (should be output as .32 not
2389 ;; .u32), but the assembler should cope with that.
2391 (define_insn "neon_vget_lane<mode>"
2392   [(set (match_operand:<V_elem> 0 "s_register_operand" "=r")
2393         (unspec:<V_elem> [(match_operand:VD 1 "s_register_operand" "w")
2394                           (match_operand:SI 2 "immediate_operand" "i")
2395                           (match_operand:SI 3 "immediate_operand" "i")]
2396                          UNSPEC_VGET_LANE))]
2397   "TARGET_NEON"
2398   "vmov%?.%t3%#<V_sz_elem>\t%0, %P1[%c2]"
2399   [(set_attr "predicable" "yes")
2400    (set_attr "neon_type" "neon_bp_simple")]
2403 ; Operand 2 (lane number) is ignored because we can only extract the zeroth lane
2404 ; with this insn. Operand 3 (info word) is ignored because it does nothing
2405 ; useful with 64-bit elements.
2407 (define_insn "neon_vget_lanedi"
2408   [(set (match_operand:DI 0 "s_register_operand" "=r")
2409        (unspec:DI [(match_operand:DI 1 "s_register_operand" "w")
2410                    (match_operand:SI 2 "immediate_operand" "i")
2411                    (match_operand:SI 3 "immediate_operand" "i")]
2412                   UNSPEC_VGET_LANE))]
2413   "TARGET_NEON"
2414   "vmov%?\t%Q0, %R0, %P1  @ di"
2415   [(set_attr "predicable" "yes")
2416    (set_attr "neon_type" "neon_bp_simple")]
2419 (define_insn "neon_vget_lane<mode>"
2420   [(set (match_operand:<V_elem> 0 "s_register_operand" "=r")
2421        (unspec:<V_elem> [(match_operand:VQ 1 "s_register_operand" "w")
2422                          (match_operand:SI 2 "immediate_operand" "i")
2423                          (match_operand:SI 3 "immediate_operand" "i")]
2424                         UNSPEC_VGET_LANE))]
2425   "TARGET_NEON"
2427   rtx ops[4];
2428   int regno = REGNO (operands[1]);
2429   unsigned int halfelts = GET_MODE_NUNITS (<MODE>mode) / 2;
2430   unsigned int elt = INTVAL (operands[2]);
2432   ops[0] = operands[0];
2433   ops[1] = gen_rtx_REG (<V_HALF>mode, regno + 2 * (elt / halfelts));
2434   ops[2] = GEN_INT (elt % halfelts);
2435   ops[3] = operands[3];
2436   output_asm_insn ("vmov%?.%t3%#<V_sz_elem>\t%0, %P1[%c2]", ops);
2438   return "";
2440   [(set_attr "predicable" "yes")
2441    (set_attr "neon_type" "neon_bp_simple")]
2444 (define_insn "neon_vget_lanev2di"
2445   [(set (match_operand:DI 0 "s_register_operand" "=r")
2446        (unspec:DI [(match_operand:V2DI 1 "s_register_operand" "w")
2447                    (match_operand:SI 2 "immediate_operand" "i")
2448                    (match_operand:SI 3 "immediate_operand" "i")]
2449                   UNSPEC_VGET_LANE))]
2450   "TARGET_NEON"
2452   rtx ops[2];
2453   unsigned int regno = REGNO (operands[1]);
2454   unsigned int elt = INTVAL (operands[2]);
2456   ops[0] = operands[0];
2457   ops[1] = gen_rtx_REG (DImode, regno + 2 * elt);
2458   output_asm_insn ("vmov%?\t%Q0, %R0, %P1  @ v2di", ops);
2460   return "";
2462   [(set_attr "predicable" "yes")
2463    (set_attr "neon_type" "neon_bp_simple")]
2466 (define_insn "neon_vset_lane<mode>"
2467   [(set (match_operand:VD 0 "s_register_operand" "=w")
2468         (unspec:VD [(match_operand:<V_elem> 1 "s_register_operand" "r")
2469                     (match_operand:VD 2 "s_register_operand" "0")
2470                     (match_operand:SI 3 "immediate_operand" "i")]
2471                    UNSPEC_VSET_LANE))]
2472   "TARGET_NEON"
2473   "vmov%?.<V_sz_elem>\t%P0[%c3], %1"
2474   [(set_attr "predicable" "yes")
2475    (set_attr "neon_type" "neon_bp_simple")]
2478 ; See neon_vget_lanedi comment for reasons operands 2 & 3 are ignored.
2480 (define_insn "neon_vset_lanedi"
2481   [(set (match_operand:DI 0 "s_register_operand" "=w")
2482         (unspec:DI [(match_operand:DI 1 "s_register_operand" "r")
2483                     (match_operand:DI 2 "s_register_operand" "0")
2484                     (match_operand:SI 3 "immediate_operand" "i")]
2485                    UNSPEC_VSET_LANE))]
2486   "TARGET_NEON"
2487   "vmov%?\t%P0, %Q1, %R1  @ di"
2488   [(set_attr "predicable" "yes")
2489    (set_attr "neon_type" "neon_bp_simple")]
2492 (define_insn "neon_vset_lane<mode>"
2493   [(set (match_operand:VQ 0 "s_register_operand" "=w")
2494         (unspec:VQ [(match_operand:<V_elem> 1 "s_register_operand" "r")
2495                     (match_operand:VQ 2 "s_register_operand" "0")
2496                     (match_operand:SI 3 "immediate_operand" "i")]
2497                    UNSPEC_VSET_LANE))]
2498   "TARGET_NEON"
2500   rtx ops[4];
2501   unsigned int regno = REGNO (operands[0]);
2502   unsigned int halfelts = GET_MODE_NUNITS (<MODE>mode) / 2;
2503   unsigned int elt = INTVAL (operands[3]);
2505   ops[0] = gen_rtx_REG (<V_HALF>mode, regno + 2 * (elt / halfelts));
2506   ops[1] = operands[1];
2507   ops[2] = GEN_INT (elt % halfelts);
2508   output_asm_insn ("vmov%?.<V_sz_elem>\t%P0[%c2], %1", ops);
2510   return "";
2512   [(set_attr "predicable" "yes")
2513    (set_attr "neon_type" "neon_bp_simple")]
2516 (define_insn "neon_vset_lanev2di"
2517   [(set (match_operand:V2DI 0 "s_register_operand" "=w")
2518         (unspec:V2DI [(match_operand:DI 1 "s_register_operand" "r")
2519                       (match_operand:V2DI 2 "s_register_operand" "0")
2520                       (match_operand:SI 3 "immediate_operand" "i")]
2521                    UNSPEC_VSET_LANE))]
2522   "TARGET_NEON"
2524   rtx ops[2];
2525   unsigned int regno = REGNO (operands[0]);
2526   unsigned int elt = INTVAL (operands[3]);
2528   ops[0] = gen_rtx_REG (DImode, regno + 2 * elt);
2529   ops[1] = operands[1];
2530   output_asm_insn ("vmov%?\t%P0, %Q1, %R1  @ v2di", ops);
2532   return "";
2534   [(set_attr "predicable" "yes")
2535    (set_attr "neon_type" "neon_bp_simple")]
2538 (define_expand "neon_vcreate<mode>"
2539   [(match_operand:VDX 0 "s_register_operand" "")
2540    (match_operand:DI 1 "general_operand" "")]
2541   "TARGET_NEON"
2543   rtx src = gen_lowpart (<MODE>mode, operands[1]);
2544   emit_move_insn (operands[0], src);
2545   DONE;
2548 (define_insn "neon_vdup_n<mode>"
2549   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
2550         (unspec:VDQW [(match_operand:<V_elem> 1 "s_register_operand" "r")]
2551                     UNSPEC_VDUP_N))]
2552   "TARGET_NEON"
2553   "vdup%?.<V_sz_elem>\t%<V_reg>0, %1"
2554   ;; Assume this schedules like vmov.
2555   [(set_attr "predicable" "yes")
2556    (set_attr "neon_type" "neon_bp_simple")]
2559 (define_insn "neon_vdup_ndi"
2560   [(set (match_operand:DI 0 "s_register_operand" "=w")
2561         (unspec:DI [(match_operand:DI 1 "s_register_operand" "r")]
2562                    UNSPEC_VDUP_N))]
2563   "TARGET_NEON"
2564   "vmov%?\t%P0, %Q1, %R1"
2565   [(set_attr "predicable" "yes")
2566    (set_attr "neon_type" "neon_bp_simple")]
2569 (define_insn "neon_vdup_nv2di"
2570   [(set (match_operand:V2DI 0 "s_register_operand" "=w")
2571         (unspec:V2DI [(match_operand:DI 1 "s_register_operand" "r")]
2572                      UNSPEC_VDUP_N))]
2573   "TARGET_NEON"
2574   "vmov%?\t%e0, %Q1, %R1\;vmov%?\t%f0, %Q1, %R1"
2575   [(set_attr "predicable" "yes")
2576    (set_attr "length" "8")
2577    (set_attr "neon_type" "neon_bp_simple")]
2580 (define_insn "neon_vdup_lane<mode>"
2581   [(set (match_operand:VD 0 "s_register_operand" "=w")
2582         (unspec:VD [(match_operand:VD 1 "s_register_operand" "w")
2583                     (match_operand:SI 2 "immediate_operand" "i")]
2584                    UNSPEC_VDUP_LANE))]
2585   "TARGET_NEON"
2586   "vdup.<V_sz_elem>\t%P0, %P1[%c2]"
2587   ;; Assume this schedules like vmov.
2588   [(set_attr "neon_type" "neon_bp_simple")]
2591 (define_insn "neon_vdup_lane<mode>"
2592   [(set (match_operand:VQ 0 "s_register_operand" "=w")
2593         (unspec:VQ [(match_operand:<V_HALF> 1 "s_register_operand" "w")
2594                     (match_operand:SI 2 "immediate_operand" "i")]
2595                    UNSPEC_VDUP_LANE))]
2596   "TARGET_NEON"
2597   "vdup.<V_sz_elem>\t%q0, %P1[%c2]"
2598   ;; Assume this schedules like vmov.
2599   [(set_attr "neon_type" "neon_bp_simple")]
2602 ; Scalar index is ignored, since only zero is valid here.
2603 (define_expand "neon_vdup_lanedi"
2604   [(set (match_operand:DI 0 "s_register_operand" "=w")
2605         (unspec:DI [(match_operand:DI 1 "s_register_operand" "w")
2606                     (match_operand:SI 2 "immediate_operand" "i")]
2607                    UNSPEC_VDUP_LANE))]
2608   "TARGET_NEON"
2610   emit_move_insn (operands[0], operands[1]);
2611   DONE;
2614 ; Likewise.
2615 (define_insn "neon_vdup_lanev2di"
2616   [(set (match_operand:V2DI 0 "s_register_operand" "=w")
2617         (unspec:V2DI [(match_operand:DI 1 "s_register_operand" "w")
2618                       (match_operand:SI 2 "immediate_operand" "i")]
2619                      UNSPEC_VDUP_LANE))]
2620   "TARGET_NEON"
2621   "vmov\t%e0, %P1\;vmov\t%f0, %P1"
2622   [(set_attr "length" "8")
2623    (set_attr "neon_type" "neon_bp_simple")]
2626 ;; In this insn, operand 1 should be low, and operand 2 the high part of the
2627 ;; dest vector.
2628 ;; FIXME: A different implementation of this builtin could make it much
2629 ;; more likely that we wouldn't actually need to output anything (we could make
2630 ;; it so that the reg allocator puts things in the right places magically
2631 ;; instead). Lack of subregs for vectors makes that tricky though, I think.
2633 (define_insn "neon_vcombine<mode>"
2634   [(set (match_operand:<V_DOUBLE> 0 "s_register_operand" "=w")
2635         (unspec:<V_DOUBLE> [(match_operand:VDX 1 "s_register_operand" "w")
2636                             (match_operand:VDX 2 "s_register_operand" "w")]
2637                            UNSPEC_VCOMBINE))]
2638   "TARGET_NEON"
2640   int dest = REGNO (operands[0]);
2641   int src1 = REGNO (operands[1]);
2642   int src2 = REGNO (operands[2]);
2643   rtx destlo;
2645   if (src1 == dest && src2 == dest + 2)
2646     return "";
2647   else if (src2 == dest && src1 == dest + 2)
2648     /* Special case of reversed high/low parts.  */
2649     return "vswp\t%P1, %P2";
2651   destlo = gen_rtx_REG (<MODE>mode, dest);
2653   if (!reg_overlap_mentioned_p (operands[2], destlo))
2654     {
2655       /* Try to avoid unnecessary moves if part of the result is in the right
2656          place already.  */
2657       if (src1 != dest)
2658         output_asm_insn ("vmov\t%e0, %P1", operands);
2659       if (src2 != dest + 2)
2660         output_asm_insn ("vmov\t%f0, %P2", operands);
2661     }
2662   else
2663     {
2664       if (src2 != dest + 2)
2665         output_asm_insn ("vmov\t%f0, %P2", operands);
2666       if (src1 != dest)
2667         output_asm_insn ("vmov\t%e0, %P1", operands);
2668     }
2670   return "";
2672   ;; We set the neon_type attribute based on the vmov instructions above.
2673   [(set_attr "length" "8")
2674    (set_attr "neon_type" "neon_bp_simple")]
2677 (define_insn "neon_vget_high<mode>"
2678   [(set (match_operand:<V_HALF> 0 "s_register_operand" "=w")
2679         (unspec:<V_HALF> [(match_operand:VQX 1 "s_register_operand" "w")]
2680                          UNSPEC_VGET_HIGH))]
2681   "TARGET_NEON"
2683   int dest = REGNO (operands[0]);
2684   int src = REGNO (operands[1]);
2686   if (dest != src + 2)
2687     return "vmov\t%P0, %f1";
2688   else
2689     return "";
2691   [(set_attr "neon_type" "neon_bp_simple")]
2694 (define_insn "neon_vget_low<mode>"
2695   [(set (match_operand:<V_HALF> 0 "s_register_operand" "=w")
2696         (unspec:<V_HALF> [(match_operand:VQX 1 "s_register_operand" "w")]
2697                          UNSPEC_VGET_LOW))]
2698   "TARGET_NEON"
2700   int dest = REGNO (operands[0]);
2701   int src = REGNO (operands[1]);
2703   if (dest != src)
2704     return "vmov\t%P0, %e1";
2705   else
2706     return "";
2708   [(set_attr "neon_type" "neon_bp_simple")]
2711 (define_insn "neon_vcvt<mode>"
2712   [(set (match_operand:<V_CVTTO> 0 "s_register_operand" "=w")
2713         (unspec:<V_CVTTO> [(match_operand:VCVTF 1 "s_register_operand" "w")
2714                            (match_operand:SI 2 "immediate_operand" "i")]
2715                           UNSPEC_VCVT))]
2716   "TARGET_NEON"
2717   "vcvt.%T2%#32.f32\t%<V_reg>0, %<V_reg>1"
2718   [(set (attr "neon_type")
2719      (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2720                    (const_string "neon_fp_vadd_ddd_vabs_dd")
2721                    (const_string "neon_fp_vadd_qqq_vabs_qq")))]
2724 (define_insn "neon_vcvt<mode>"
2725   [(set (match_operand:<V_CVTTO> 0 "s_register_operand" "=w")
2726         (unspec:<V_CVTTO> [(match_operand:VCVTI 1 "s_register_operand" "w")
2727                            (match_operand:SI 2 "immediate_operand" "i")]
2728                           UNSPEC_VCVT))]
2729   "TARGET_NEON"
2730   "vcvt.f32.%T2%#32\t%<V_reg>0, %<V_reg>1"
2731   [(set (attr "neon_type")
2732      (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2733                    (const_string "neon_fp_vadd_ddd_vabs_dd")
2734                    (const_string "neon_fp_vadd_qqq_vabs_qq")))]
2737 (define_insn "neon_vcvt_n<mode>"
2738   [(set (match_operand:<V_CVTTO> 0 "s_register_operand" "=w")
2739         (unspec:<V_CVTTO> [(match_operand:VCVTF 1 "s_register_operand" "w")
2740                            (match_operand:SI 2 "immediate_operand" "i")
2741                            (match_operand:SI 3 "immediate_operand" "i")]
2742                           UNSPEC_VCVT_N))]
2743   "TARGET_NEON"
2744   "vcvt.%T3%#32.f32\t%<V_reg>0, %<V_reg>1, %2"
2745   [(set (attr "neon_type")
2746      (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2747                    (const_string "neon_fp_vadd_ddd_vabs_dd")
2748                    (const_string "neon_fp_vadd_qqq_vabs_qq")))]
2751 (define_insn "neon_vcvt_n<mode>"
2752   [(set (match_operand:<V_CVTTO> 0 "s_register_operand" "=w")
2753         (unspec:<V_CVTTO> [(match_operand:VCVTI 1 "s_register_operand" "w")
2754                            (match_operand:SI 2 "immediate_operand" "i")
2755                            (match_operand:SI 3 "immediate_operand" "i")]
2756                           UNSPEC_VCVT_N))]
2757   "TARGET_NEON"
2758   "vcvt.f32.%T3%#32\t%<V_reg>0, %<V_reg>1, %2"
2759   [(set (attr "neon_type")
2760      (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
2761                    (const_string "neon_fp_vadd_ddd_vabs_dd")
2762                    (const_string "neon_fp_vadd_qqq_vabs_qq")))]
2765 (define_insn "neon_vmovn<mode>"
2766   [(set (match_operand:<V_narrow> 0 "s_register_operand" "=w")
2767         (unspec:<V_narrow> [(match_operand:VN 1 "s_register_operand" "w")
2768                             (match_operand:SI 2 "immediate_operand" "i")]
2769                            UNSPEC_VMOVN))]
2770   "TARGET_NEON"
2771   "vmovn.<V_if_elem>\t%P0, %q1"
2772   [(set_attr "neon_type" "neon_bp_simple")]
2775 (define_insn "neon_vqmovn<mode>"
2776   [(set (match_operand:<V_narrow> 0 "s_register_operand" "=w")
2777         (unspec:<V_narrow> [(match_operand:VN 1 "s_register_operand" "w")
2778                             (match_operand:SI 2 "immediate_operand" "i")]
2779                            UNSPEC_VQMOVN))]
2780   "TARGET_NEON"
2781   "vqmovn.%T2%#<V_sz_elem>\t%P0, %q1"
2782   [(set_attr "neon_type" "neon_shift_2")]
2785 (define_insn "neon_vqmovun<mode>"
2786   [(set (match_operand:<V_narrow> 0 "s_register_operand" "=w")
2787         (unspec:<V_narrow> [(match_operand:VN 1 "s_register_operand" "w")
2788                             (match_operand:SI 2 "immediate_operand" "i")]
2789                            UNSPEC_VQMOVUN))]
2790   "TARGET_NEON"
2791   "vqmovun.<V_s_elem>\t%P0, %q1"
2792   [(set_attr "neon_type" "neon_shift_2")]
2795 (define_insn "neon_vmovl<mode>"
2796   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
2797         (unspec:<V_widen> [(match_operand:VW 1 "s_register_operand" "w")
2798                            (match_operand:SI 2 "immediate_operand" "i")]
2799                           UNSPEC_VMOVL))]
2800   "TARGET_NEON"
2801   "vmovl.%T2%#<V_sz_elem>\t%q0, %P1"
2802   [(set_attr "neon_type" "neon_shift_1")]
2805 (define_insn "neon_vmul_lane<mode>"
2806   [(set (match_operand:VMD 0 "s_register_operand" "=w")
2807         (unspec:VMD [(match_operand:VMD 1 "s_register_operand" "w")
2808                      (match_operand:VMD 2 "s_register_operand"
2809                                         "<scalar_mul_constraint>")
2810                      (match_operand:SI 3 "immediate_operand" "i")
2811                      (match_operand:SI 4 "immediate_operand" "i")]
2812                     UNSPEC_VMUL_LANE))]
2813   "TARGET_NEON"
2814   "vmul.<V_if_elem>\t%P0, %P1, %P2[%c3]"
2815   [(set (attr "neon_type")
2816      (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2817                    (const_string "neon_fp_vmul_ddd")
2818                    (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
2819                                  (const_string "neon_mul_ddd_16_scalar_32_16_long_scalar")
2820                                  (const_string "neon_mul_qdd_64_32_long_qqd_16_ddd_32_scalar_64_32_long_scalar"))))]
2823 (define_insn "neon_vmul_lane<mode>"
2824   [(set (match_operand:VMQ 0 "s_register_operand" "=w")
2825         (unspec:VMQ [(match_operand:VMQ 1 "s_register_operand" "w")
2826                      (match_operand:<V_HALF> 2 "s_register_operand"
2827                                              "<scalar_mul_constraint>")
2828                      (match_operand:SI 3 "immediate_operand" "i")
2829                      (match_operand:SI 4 "immediate_operand" "i")]
2830                     UNSPEC_VMUL_LANE))]
2831   "TARGET_NEON"
2832   "vmul.<V_if_elem>\t%q0, %q1, %P2[%c3]"
2833   [(set (attr "neon_type")
2834      (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2835                    (const_string "neon_fp_vmul_qqd")
2836                    (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
2837                                  (const_string "neon_mul_qdd_64_32_long_qqd_16_ddd_32_scalar_64_32_long_scalar")
2838                                  (const_string "neon_mul_qqd_32_scalar"))))]
2841 (define_insn "neon_vmull_lane<mode>"
2842   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
2843         (unspec:<V_widen> [(match_operand:VMDI 1 "s_register_operand" "w")
2844                            (match_operand:VMDI 2 "s_register_operand"
2845                                                "<scalar_mul_constraint>")
2846                            (match_operand:SI 3 "immediate_operand" "i")
2847                            (match_operand:SI 4 "immediate_operand" "i")]
2848                           UNSPEC_VMULL_LANE))]
2849   "TARGET_NEON"
2850   "vmull.%T4%#<V_sz_elem>\t%q0, %P1, %P2[%c3]"
2851   [(set (attr "neon_type")
2852      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
2853                    (const_string "neon_mul_ddd_16_scalar_32_16_long_scalar")
2854                    (const_string "neon_mul_qdd_64_32_long_qqd_16_ddd_32_scalar_64_32_long_scalar")))]
2857 (define_insn "neon_vqdmull_lane<mode>"
2858   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
2859         (unspec:<V_widen> [(match_operand:VMDI 1 "s_register_operand" "w")
2860                            (match_operand:VMDI 2 "s_register_operand"
2861                                                "<scalar_mul_constraint>")
2862                            (match_operand:SI 3 "immediate_operand" "i")
2863                            (match_operand:SI 4 "immediate_operand" "i")]
2864                           UNSPEC_VQDMULL_LANE))]
2865   "TARGET_NEON"
2866   "vqdmull.<V_s_elem>\t%q0, %P1, %P2[%c3]"
2867   [(set (attr "neon_type")
2868      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
2869                    (const_string "neon_mul_ddd_16_scalar_32_16_long_scalar")
2870                    (const_string "neon_mul_qdd_64_32_long_qqd_16_ddd_32_scalar_64_32_long_scalar")))]
2873 (define_insn "neon_vqdmulh_lane<mode>"
2874   [(set (match_operand:VMQI 0 "s_register_operand" "=w")
2875         (unspec:VMQI [(match_operand:VMQI 1 "s_register_operand" "w")
2876                       (match_operand:<V_HALF> 2 "s_register_operand"
2877                                               "<scalar_mul_constraint>")
2878                       (match_operand:SI 3 "immediate_operand" "i")
2879                       (match_operand:SI 4 "immediate_operand" "i")]
2880                       UNSPEC_VQDMULH_LANE))]
2881   "TARGET_NEON"
2882   "vq%O4dmulh.%T4%#<V_sz_elem>\t%q0, %q1, %P2[%c3]"
2883   [(set (attr "neon_type")
2884      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
2885                    (const_string "neon_mul_qdd_64_32_long_qqd_16_ddd_32_scalar_64_32_long_scalar")
2886                    (const_string "neon_mul_qqd_32_scalar")))]
2889 (define_insn "neon_vqdmulh_lane<mode>"
2890   [(set (match_operand:VMDI 0 "s_register_operand" "=w")
2891         (unspec:VMDI [(match_operand:VMDI 1 "s_register_operand" "w")
2892                       (match_operand:VMDI 2 "s_register_operand"
2893                                           "<scalar_mul_constraint>")
2894                       (match_operand:SI 3 "immediate_operand" "i")
2895                       (match_operand:SI 4 "immediate_operand" "i")]
2896                       UNSPEC_VQDMULH_LANE))]
2897   "TARGET_NEON"
2898   "vq%O4dmulh.%T4%#<V_sz_elem>\t%P0, %P1, %P2[%c3]"
2899   [(set (attr "neon_type")
2900      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
2901                    (const_string "neon_mul_ddd_16_scalar_32_16_long_scalar")
2902                    (const_string "neon_mul_qdd_64_32_long_qqd_16_ddd_32_scalar_64_32_long_scalar")))]
2905 (define_insn "neon_vmla_lane<mode>"
2906   [(set (match_operand:VMD 0 "s_register_operand" "=w")
2907         (unspec:VMD [(match_operand:VMD 1 "s_register_operand" "0")
2908                      (match_operand:VMD 2 "s_register_operand" "w")
2909                      (match_operand:VMD 3 "s_register_operand"
2910                                         "<scalar_mul_constraint>")
2911                      (match_operand:SI 4 "immediate_operand" "i")
2912                      (match_operand:SI 5 "immediate_operand" "i")]
2913                      UNSPEC_VMLA_LANE))]
2914   "TARGET_NEON"
2915   "vmla.<V_if_elem>\t%P0, %P2, %P3[%c4]"
2916   [(set (attr "neon_type")
2917      (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2918                    (const_string "neon_fp_vmla_ddd_scalar")
2919                    (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
2920                                  (const_string "neon_mla_ddd_16_scalar_qdd_32_16_long_scalar")
2921                                  (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long"))))]
2924 (define_insn "neon_vmla_lane<mode>"
2925   [(set (match_operand:VMQ 0 "s_register_operand" "=w")
2926         (unspec:VMQ [(match_operand:VMQ 1 "s_register_operand" "0")
2927                      (match_operand:VMQ 2 "s_register_operand" "w")
2928                      (match_operand:<V_HALF> 3 "s_register_operand"
2929                                              "<scalar_mul_constraint>")
2930                      (match_operand:SI 4 "immediate_operand" "i")
2931                      (match_operand:SI 5 "immediate_operand" "i")]
2932                      UNSPEC_VMLA_LANE))]
2933   "TARGET_NEON"
2934   "vmla.<V_if_elem>\t%q0, %q2, %P3[%c4]"
2935   [(set (attr "neon_type")
2936      (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2937                    (const_string "neon_fp_vmla_qqq_scalar")
2938                    (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
2939                                  (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long")
2940                                  (const_string "neon_mla_qqq_32_qqd_32_scalar"))))]
2943 (define_insn "neon_vmlal_lane<mode>"
2944   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
2945         (unspec:<V_widen> [(match_operand:<V_widen> 1 "s_register_operand" "0")
2946                            (match_operand:VMDI 2 "s_register_operand" "w")
2947                            (match_operand:VMDI 3 "s_register_operand"
2948                                                "<scalar_mul_constraint>")
2949                            (match_operand:SI 4 "immediate_operand" "i")
2950                            (match_operand:SI 5 "immediate_operand" "i")]
2951                           UNSPEC_VMLAL_LANE))]
2952   "TARGET_NEON"
2953   "vmlal.%T5%#<V_sz_elem>\t%q0, %P2, %P3[%c4]"
2954   [(set (attr "neon_type")
2955      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
2956                    (const_string "neon_mla_ddd_16_scalar_qdd_32_16_long_scalar")
2957                    (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long")))]
2960 (define_insn "neon_vqdmlal_lane<mode>"
2961   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
2962         (unspec:<V_widen> [(match_operand:<V_widen> 1 "s_register_operand" "0")
2963                            (match_operand:VMDI 2 "s_register_operand" "w")
2964                            (match_operand:VMDI 3 "s_register_operand"
2965                                                "<scalar_mul_constraint>")
2966                            (match_operand:SI 4 "immediate_operand" "i")
2967                            (match_operand:SI 5 "immediate_operand" "i")]
2968                           UNSPEC_VQDMLAL_LANE))]
2969   "TARGET_NEON"
2970   "vqdmlal.<V_s_elem>\t%q0, %P2, %P3[%c4]"
2971   [(set (attr "neon_type")
2972      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
2973                    (const_string "neon_mla_ddd_16_scalar_qdd_32_16_long_scalar")
2974                    (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long")))]
2977 (define_insn "neon_vmls_lane<mode>"
2978   [(set (match_operand:VMD 0 "s_register_operand" "=w")
2979         (unspec:VMD [(match_operand:VMD 1 "s_register_operand" "0")
2980                      (match_operand:VMD 2 "s_register_operand" "w")
2981                      (match_operand:VMD 3 "s_register_operand"
2982                                         "<scalar_mul_constraint>")
2983                      (match_operand:SI 4 "immediate_operand" "i")
2984                      (match_operand:SI 5 "immediate_operand" "i")]
2985                     UNSPEC_VMLS_LANE))]
2986   "TARGET_NEON"
2987   "vmls.<V_if_elem>\t%P0, %P2, %P3[%c4]"
2988   [(set (attr "neon_type")
2989      (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
2990                    (const_string "neon_fp_vmla_ddd_scalar")
2991                    (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
2992                                  (const_string "neon_mla_ddd_16_scalar_qdd_32_16_long_scalar")
2993                                  (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long"))))]
2996 (define_insn "neon_vmls_lane<mode>"
2997   [(set (match_operand:VMQ 0 "s_register_operand" "=w")
2998         (unspec:VMQ [(match_operand:VMQ 1 "s_register_operand" "0")
2999                      (match_operand:VMQ 2 "s_register_operand" "w")
3000                      (match_operand:<V_HALF> 3 "s_register_operand"
3001                                              "<scalar_mul_constraint>")
3002                      (match_operand:SI 4 "immediate_operand" "i")
3003                      (match_operand:SI 5 "immediate_operand" "i")]
3004                     UNSPEC_VMLS_LANE))]
3005   "TARGET_NEON"
3006   "vmls.<V_if_elem>\t%q0, %q2, %P3[%c4]"
3007   [(set (attr "neon_type")
3008      (if_then_else (ne (symbol_ref "<Is_float_mode>") (const_int 0))
3009                    (const_string "neon_fp_vmla_qqq_scalar")
3010                    (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
3011                                  (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long")
3012                                  (const_string "neon_mla_qqq_32_qqd_32_scalar"))))]
3015 (define_insn "neon_vmlsl_lane<mode>"
3016   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
3017         (unspec:<V_widen> [(match_operand:<V_widen> 1 "s_register_operand" "0")
3018                            (match_operand:VMDI 2 "s_register_operand" "w")
3019                            (match_operand:VMDI 3 "s_register_operand"
3020                                                "<scalar_mul_constraint>")
3021                            (match_operand:SI 4 "immediate_operand" "i")
3022                            (match_operand:SI 5 "immediate_operand" "i")]
3023                           UNSPEC_VMLSL_LANE))]
3024   "TARGET_NEON"
3025   "vmlsl.%T5%#<V_sz_elem>\t%q0, %P2, %P3[%c4]"
3026   [(set (attr "neon_type")
3027      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
3028                    (const_string "neon_mla_ddd_16_scalar_qdd_32_16_long_scalar")
3029                    (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long")))]
3032 (define_insn "neon_vqdmlsl_lane<mode>"
3033   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
3034         (unspec:<V_widen> [(match_operand:<V_widen> 1 "s_register_operand" "0")
3035                            (match_operand:VMDI 2 "s_register_operand" "w")
3036                            (match_operand:VMDI 3 "s_register_operand"
3037                                                "<scalar_mul_constraint>")
3038                            (match_operand:SI 4 "immediate_operand" "i")
3039                            (match_operand:SI 5 "immediate_operand" "i")]
3040                           UNSPEC_VQDMLSL_LANE))]
3041   "TARGET_NEON"
3042   "vqdmlsl.<V_s_elem>\t%q0, %P2, %P3[%c4]"
3043   [(set (attr "neon_type")
3044      (if_then_else (ne (symbol_ref "<Scalar_mul_8_16>") (const_int 0))
3045                    (const_string "neon_mla_ddd_16_scalar_qdd_32_16_long_scalar")
3046                    (const_string "neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long")))]
3049 ; FIXME: For the "_n" multiply/multiply-accumulate insns, we copy a value in a
3050 ; core register into a temp register, then use a scalar taken from that. This
3051 ; isn't an optimal solution if e.g. the scalar has just been read from memory
3052 ; or extracted from another vector. The latter case it's currently better to
3053 ; use the "_lane" variant, and the former case can probably be implemented
3054 ; using vld1_lane, but that hasn't been done yet.
3056 (define_expand "neon_vmul_n<mode>"
3057   [(match_operand:VMD 0 "s_register_operand" "")
3058    (match_operand:VMD 1 "s_register_operand" "")
3059    (match_operand:<V_elem> 2 "s_register_operand" "")
3060    (match_operand:SI 3 "immediate_operand" "")]
3061   "TARGET_NEON"
3063   rtx tmp = gen_reg_rtx (<MODE>mode);
3064   emit_insn (gen_neon_vset_lane<mode> (tmp, operands[2], tmp, const0_rtx));
3065   emit_insn (gen_neon_vmul_lane<mode> (operands[0], operands[1], tmp,
3066                                        const0_rtx, const0_rtx));
3067   DONE;
3070 (define_expand "neon_vmul_n<mode>"
3071   [(match_operand:VMQ 0 "s_register_operand" "")
3072    (match_operand:VMQ 1 "s_register_operand" "")
3073    (match_operand:<V_elem> 2 "s_register_operand" "")
3074    (match_operand:SI 3 "immediate_operand" "")]
3075   "TARGET_NEON"
3077   rtx tmp = gen_reg_rtx (<V_HALF>mode);
3078   emit_insn (gen_neon_vset_lane<V_half> (tmp, operands[2], tmp, const0_rtx));
3079   emit_insn (gen_neon_vmul_lane<mode> (operands[0], operands[1], tmp,
3080                                        const0_rtx, const0_rtx));
3081   DONE;
3084 (define_expand "neon_vmull_n<mode>"
3085   [(match_operand:<V_widen> 0 "s_register_operand" "")
3086    (match_operand:VMDI 1 "s_register_operand" "")
3087    (match_operand:<V_elem> 2 "s_register_operand" "")
3088    (match_operand:SI 3 "immediate_operand" "")]
3089   "TARGET_NEON"
3091   rtx tmp = gen_reg_rtx (<MODE>mode);
3092   emit_insn (gen_neon_vset_lane<mode> (tmp, operands[2], tmp, const0_rtx));
3093   emit_insn (gen_neon_vmull_lane<mode> (operands[0], operands[1], tmp,
3094                                         const0_rtx, operands[3]));
3095   DONE;
3098 (define_expand "neon_vqdmull_n<mode>"
3099   [(match_operand:<V_widen> 0 "s_register_operand" "")
3100    (match_operand:VMDI 1 "s_register_operand" "")
3101    (match_operand:<V_elem> 2 "s_register_operand" "")
3102    (match_operand:SI 3 "immediate_operand" "")]
3103   "TARGET_NEON"
3105   rtx tmp = gen_reg_rtx (<MODE>mode);
3106   emit_insn (gen_neon_vset_lane<mode> (tmp, operands[2], tmp, const0_rtx));
3107   emit_insn (gen_neon_vqdmull_lane<mode> (operands[0], operands[1], tmp,
3108                                           const0_rtx, const0_rtx));
3109   DONE;
3112 (define_expand "neon_vqdmulh_n<mode>"
3113   [(match_operand:VMDI 0 "s_register_operand" "")
3114    (match_operand:VMDI 1 "s_register_operand" "")
3115    (match_operand:<V_elem> 2 "s_register_operand" "")
3116    (match_operand:SI 3 "immediate_operand" "")]
3117   "TARGET_NEON"
3119   rtx tmp = gen_reg_rtx (<MODE>mode);
3120   emit_insn (gen_neon_vset_lane<mode> (tmp, operands[2], tmp, const0_rtx));
3121   emit_insn (gen_neon_vqdmulh_lane<mode> (operands[0], operands[1], tmp,
3122                                           const0_rtx, operands[3]));
3123   DONE;
3126 (define_expand "neon_vqdmulh_n<mode>"
3127   [(match_operand:VMQI 0 "s_register_operand" "")
3128    (match_operand:VMQI 1 "s_register_operand" "")
3129    (match_operand:<V_elem> 2 "s_register_operand" "")
3130    (match_operand:SI 3 "immediate_operand" "")]
3131   "TARGET_NEON"
3133   rtx tmp = gen_reg_rtx (<V_HALF>mode);
3134   emit_insn (gen_neon_vset_lane<V_half> (tmp, operands[2], tmp, const0_rtx));
3135   emit_insn (gen_neon_vqdmulh_lane<mode> (operands[0], operands[1], tmp,
3136                                           const0_rtx, operands[3]));
3137   DONE;
3140 (define_expand "neon_vmla_n<mode>"
3141   [(match_operand:VMD 0 "s_register_operand" "")
3142    (match_operand:VMD 1 "s_register_operand" "")
3143    (match_operand:VMD 2 "s_register_operand" "")
3144    (match_operand:<V_elem> 3 "s_register_operand" "")
3145    (match_operand:SI 4 "immediate_operand" "")]
3146   "TARGET_NEON"
3148   rtx tmp = gen_reg_rtx (<MODE>mode);
3149   emit_insn (gen_neon_vset_lane<mode> (tmp, operands[3], tmp, const0_rtx));
3150   emit_insn (gen_neon_vmla_lane<mode> (operands[0], operands[1], operands[2],
3151                                        tmp, const0_rtx, operands[4]));
3152   DONE;
3155 (define_expand "neon_vmla_n<mode>"
3156   [(match_operand:VMQ 0 "s_register_operand" "")
3157    (match_operand:VMQ 1 "s_register_operand" "")
3158    (match_operand:VMQ 2 "s_register_operand" "")
3159    (match_operand:<V_elem> 3 "s_register_operand" "")
3160    (match_operand:SI 4 "immediate_operand" "")]
3161   "TARGET_NEON"
3163   rtx tmp = gen_reg_rtx (<V_HALF>mode);
3164   emit_insn (gen_neon_vset_lane<V_half> (tmp, operands[3], tmp, const0_rtx));
3165   emit_insn (gen_neon_vmla_lane<mode> (operands[0], operands[1], operands[2],
3166                                        tmp, const0_rtx, operands[4]));
3167   DONE;
3170 (define_expand "neon_vmlal_n<mode>"
3171   [(match_operand:<V_widen> 0 "s_register_operand" "")
3172    (match_operand:<V_widen> 1 "s_register_operand" "")
3173    (match_operand:VMDI 2 "s_register_operand" "")
3174    (match_operand:<V_elem> 3 "s_register_operand" "")
3175    (match_operand:SI 4 "immediate_operand" "")]
3176   "TARGET_NEON"
3178   rtx tmp = gen_reg_rtx (<MODE>mode);
3179   emit_insn (gen_neon_vset_lane<mode> (tmp, operands[3], tmp, const0_rtx));
3180   emit_insn (gen_neon_vmlal_lane<mode> (operands[0], operands[1], operands[2],
3181                                         tmp, const0_rtx, operands[4]));
3182   DONE;
3185 (define_expand "neon_vqdmlal_n<mode>"
3186   [(match_operand:<V_widen> 0 "s_register_operand" "")
3187    (match_operand:<V_widen> 1 "s_register_operand" "")
3188    (match_operand:VMDI 2 "s_register_operand" "")
3189    (match_operand:<V_elem> 3 "s_register_operand" "")
3190    (match_operand:SI 4 "immediate_operand" "")]
3191   "TARGET_NEON"
3193   rtx tmp = gen_reg_rtx (<MODE>mode);
3194   emit_insn (gen_neon_vset_lane<mode> (tmp, operands[3], tmp, const0_rtx));
3195   emit_insn (gen_neon_vqdmlal_lane<mode> (operands[0], operands[1], operands[2],
3196                                           tmp, const0_rtx, operands[4]));
3197   DONE;
3200 (define_expand "neon_vmls_n<mode>"
3201   [(match_operand:VMD 0 "s_register_operand" "")
3202    (match_operand:VMD 1 "s_register_operand" "")
3203    (match_operand:VMD 2 "s_register_operand" "")
3204    (match_operand:<V_elem> 3 "s_register_operand" "")
3205    (match_operand:SI 4 "immediate_operand" "")]
3206   "TARGET_NEON"
3208   rtx tmp = gen_reg_rtx (<MODE>mode);
3209   emit_insn (gen_neon_vset_lane<mode> (tmp, operands[3], tmp, const0_rtx));
3210   emit_insn (gen_neon_vmls_lane<mode> (operands[0], operands[1], operands[2],
3211                                        tmp, const0_rtx, operands[4]));
3212   DONE;
3215 (define_expand "neon_vmls_n<mode>"
3216   [(match_operand:VMQ 0 "s_register_operand" "")
3217    (match_operand:VMQ 1 "s_register_operand" "")
3218    (match_operand:VMQ 2 "s_register_operand" "")
3219    (match_operand:<V_elem> 3 "s_register_operand" "")
3220    (match_operand:SI 4 "immediate_operand" "")]
3221   "TARGET_NEON"
3223   rtx tmp = gen_reg_rtx (<V_HALF>mode);
3224   emit_insn (gen_neon_vset_lane<V_half> (tmp, operands[3], tmp, const0_rtx));
3225   emit_insn (gen_neon_vmls_lane<mode> (operands[0], operands[1], operands[2],
3226                                        tmp, const0_rtx, operands[4]));
3227   DONE;
3230 (define_expand "neon_vmlsl_n<mode>"
3231   [(match_operand:<V_widen> 0 "s_register_operand" "")
3232    (match_operand:<V_widen> 1 "s_register_operand" "")
3233    (match_operand:VMDI 2 "s_register_operand" "")
3234    (match_operand:<V_elem> 3 "s_register_operand" "")
3235    (match_operand:SI 4 "immediate_operand" "")]
3236   "TARGET_NEON"
3238   rtx tmp = gen_reg_rtx (<MODE>mode);
3239   emit_insn (gen_neon_vset_lane<mode> (tmp, operands[3], tmp, const0_rtx));
3240   emit_insn (gen_neon_vmlsl_lane<mode> (operands[0], operands[1], operands[2],
3241                                         tmp, const0_rtx, operands[4]));
3242   DONE;
3245 (define_expand "neon_vqdmlsl_n<mode>"
3246   [(match_operand:<V_widen> 0 "s_register_operand" "")
3247    (match_operand:<V_widen> 1 "s_register_operand" "")
3248    (match_operand:VMDI 2 "s_register_operand" "")
3249    (match_operand:<V_elem> 3 "s_register_operand" "")
3250    (match_operand:SI 4 "immediate_operand" "")]
3251   "TARGET_NEON"
3253   rtx tmp = gen_reg_rtx (<MODE>mode);
3254   emit_insn (gen_neon_vset_lane<mode> (tmp, operands[3], tmp, const0_rtx));
3255   emit_insn (gen_neon_vqdmlsl_lane<mode> (operands[0], operands[1], operands[2],
3256                                           tmp, const0_rtx, operands[4]));
3257   DONE;
3260 (define_insn "neon_vext<mode>"
3261   [(set (match_operand:VDQX 0 "s_register_operand" "=w")
3262         (unspec:VDQX [(match_operand:VDQX 1 "s_register_operand" "w")
3263                       (match_operand:VDQX 2 "s_register_operand" "w")
3264                       (match_operand:SI 3 "immediate_operand" "i")]
3265                      UNSPEC_VEXT))]
3266   "TARGET_NEON"
3267   "vext.<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2, %3"
3268   [(set (attr "neon_type")
3269       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
3270                     (const_string "neon_bp_simple")
3271                     (const_string "neon_bp_2cycle")))]
3274 (define_insn "neon_vrev64<mode>"
3275   [(set (match_operand:VDQ 0 "s_register_operand" "=w")
3276         (unspec:VDQ [(match_operand:VDQ 1 "s_register_operand" "w")
3277                      (match_operand:SI 2 "immediate_operand" "i")]
3278                     UNSPEC_VREV64))]
3279   "TARGET_NEON"
3280   "vrev64.<V_sz_elem>\t%<V_reg>0, %<V_reg>1"
3281   [(set_attr "neon_type" "neon_bp_simple")]
3284 (define_insn "neon_vrev32<mode>"
3285   [(set (match_operand:VX 0 "s_register_operand" "=w")
3286         (unspec:VX [(match_operand:VX 1 "s_register_operand" "w")
3287                     (match_operand:SI 2 "immediate_operand" "i")]
3288                    UNSPEC_VREV32))]
3289   "TARGET_NEON"
3290   "vrev32.<V_sz_elem>\t%<V_reg>0, %<V_reg>1"
3291   [(set_attr "neon_type" "neon_bp_simple")]
3294 (define_insn "neon_vrev16<mode>"
3295   [(set (match_operand:VE 0 "s_register_operand" "=w")
3296         (unspec:VE [(match_operand:VE 1 "s_register_operand" "w")
3297                     (match_operand:SI 2 "immediate_operand" "i")]
3298                    UNSPEC_VREV16))]
3299   "TARGET_NEON"
3300   "vrev16.<V_sz_elem>\t%<V_reg>0, %<V_reg>1"
3301   [(set_attr "neon_type" "neon_bp_simple")]
3304 ; vbsl_* intrinsics may compile to any of vbsl/vbif/vbit depending on register
3305 ; allocation. For an intrinsic of form:
3306 ;   rD = vbsl_* (rS, rN, rM)
3307 ; We can use any of:
3308 ;   vbsl rS, rN, rM  (if D = S)
3309 ;   vbit rD, rN, rS  (if D = M, so 1-bits in rS choose bits from rN, else rM)
3310 ;   vbif rD, rM, rS  (if D = N, so 0-bits in rS choose bits from rM, else rN)
3312 (define_insn "neon_vbsl<mode>_internal"
3313   [(set (match_operand:VDQX 0 "s_register_operand"               "=w,w,w")
3314         (unspec:VDQX [(match_operand:VDQX 1 "s_register_operand" " 0,w,w")
3315                       (match_operand:VDQX 2 "s_register_operand" " w,w,0")
3316                       (match_operand:VDQX 3 "s_register_operand" " w,0,w")]
3317                      UNSPEC_VBSL))]
3318   "TARGET_NEON"
3319   "@
3320   vbsl\t%<V_reg>0, %<V_reg>2, %<V_reg>3
3321   vbit\t%<V_reg>0, %<V_reg>2, %<V_reg>1
3322   vbif\t%<V_reg>0, %<V_reg>3, %<V_reg>1"
3323   [(set_attr "neon_type" "neon_int_1")]
3326 (define_expand "neon_vbsl<mode>"
3327   [(set (match_operand:VDQX 0 "s_register_operand" "")
3328         (unspec:VDQX [(match_operand:<V_cmp_result> 1 "s_register_operand" "")
3329                       (match_operand:VDQX 2 "s_register_operand" "")
3330                       (match_operand:VDQX 3 "s_register_operand" "")]
3331                      UNSPEC_VBSL))]
3332   "TARGET_NEON"
3334   /* We can't alias operands together if they have different modes.  */
3335   operands[1] = gen_lowpart (<MODE>mode, operands[1]);
3338 (define_insn "neon_vshl<mode>"
3339   [(set (match_operand:VDQIX 0 "s_register_operand" "=w")
3340         (unspec:VDQIX [(match_operand:VDQIX 1 "s_register_operand" "w")
3341                        (match_operand:VDQIX 2 "s_register_operand" "w")
3342                        (match_operand:SI 3 "immediate_operand" "i")]
3343                       UNSPEC_VSHL))]
3344   "TARGET_NEON"
3345   "v%O3shl.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
3346   [(set (attr "neon_type")
3347       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
3348                     (const_string "neon_vshl_ddd")
3349                     (const_string "neon_shift_3")))]
3352 (define_insn "neon_vqshl<mode>"
3353   [(set (match_operand:VDQIX 0 "s_register_operand" "=w")
3354         (unspec:VDQIX [(match_operand:VDQIX 1 "s_register_operand" "w")
3355                        (match_operand:VDQIX 2 "s_register_operand" "w")
3356                        (match_operand:SI 3 "immediate_operand" "i")]
3357                       UNSPEC_VQSHL))]
3358   "TARGET_NEON"
3359   "vq%O3shl.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2"
3360   [(set (attr "neon_type")
3361       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
3362                     (const_string "neon_shift_2")
3363                     (const_string "neon_vqshl_vrshl_vqrshl_qqq")))]
3366 (define_insn "neon_vshr_n<mode>"
3367   [(set (match_operand:VDQIX 0 "s_register_operand" "=w")
3368         (unspec:VDQIX [(match_operand:VDQIX 1 "s_register_operand" "w")
3369                        (match_operand:SI 2 "immediate_operand" "i")
3370                        (match_operand:SI 3 "immediate_operand" "i")]
3371                       UNSPEC_VSHR_N))]
3372   "TARGET_NEON"
3373   "v%O3shr.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %2"
3374   [(set_attr "neon_type" "neon_shift_1")]
3377 (define_insn "neon_vshrn_n<mode>"
3378   [(set (match_operand:<V_narrow> 0 "s_register_operand" "=w")
3379         (unspec:<V_narrow> [(match_operand:VN 1 "s_register_operand" "w")
3380                             (match_operand:SI 2 "immediate_operand" "i")
3381                             (match_operand:SI 3 "immediate_operand" "i")]
3382                            UNSPEC_VSHRN_N))]
3383   "TARGET_NEON"
3384   "v%O3shrn.<V_if_elem>\t%P0, %q1, %2"
3385   [(set_attr "neon_type" "neon_shift_1")]
3388 (define_insn "neon_vqshrn_n<mode>"
3389   [(set (match_operand:<V_narrow> 0 "s_register_operand" "=w")
3390         (unspec:<V_narrow> [(match_operand:VN 1 "s_register_operand" "w")
3391                             (match_operand:SI 2 "immediate_operand" "i")
3392                             (match_operand:SI 3 "immediate_operand" "i")]
3393                            UNSPEC_VQSHRN_N))]
3394   "TARGET_NEON"
3395   "vq%O3shrn.%T3%#<V_sz_elem>\t%P0, %q1, %2"
3396   [(set_attr "neon_type" "neon_shift_2")]
3399 (define_insn "neon_vqshrun_n<mode>"
3400   [(set (match_operand:<V_narrow> 0 "s_register_operand" "=w")
3401         (unspec:<V_narrow> [(match_operand:VN 1 "s_register_operand" "w")
3402                             (match_operand:SI 2 "immediate_operand" "i")
3403                             (match_operand:SI 3 "immediate_operand" "i")]
3404                            UNSPEC_VQSHRUN_N))]
3405   "TARGET_NEON"
3406   "vq%O3shrun.%T3%#<V_sz_elem>\t%P0, %q1, %2"
3407   [(set_attr "neon_type" "neon_shift_2")]
3410 (define_insn "neon_vshl_n<mode>"
3411   [(set (match_operand:VDQIX 0 "s_register_operand" "=w")
3412         (unspec:VDQIX [(match_operand:VDQIX 1 "s_register_operand" "w")
3413                        (match_operand:SI 2 "immediate_operand" "i")
3414                        (match_operand:SI 3 "immediate_operand" "i")]
3415                       UNSPEC_VSHL_N))]
3416   "TARGET_NEON"
3417   "vshl.<V_if_elem>\t%<V_reg>0, %<V_reg>1, %2"
3418   [(set_attr "neon_type" "neon_shift_1")]
3421 (define_insn "neon_vqshl_n<mode>"
3422   [(set (match_operand:VDQIX 0 "s_register_operand" "=w")
3423         (unspec:VDQIX [(match_operand:VDQIX 1 "s_register_operand" "w")
3424                        (match_operand:SI 2 "immediate_operand" "i")
3425                        (match_operand:SI 3 "immediate_operand" "i")]
3426                       UNSPEC_VQSHL_N))]
3427   "TARGET_NEON"
3428   "vqshl.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %2"
3429   [(set_attr "neon_type" "neon_shift_2")]
3432 (define_insn "neon_vqshlu_n<mode>"
3433   [(set (match_operand:VDQIX 0 "s_register_operand" "=w")
3434         (unspec:VDQIX [(match_operand:VDQIX 1 "s_register_operand" "w")
3435                        (match_operand:SI 2 "immediate_operand" "i")
3436                        (match_operand:SI 3 "immediate_operand" "i")]
3437                       UNSPEC_VQSHLU_N))]
3438   "TARGET_NEON"
3439   "vqshlu.%T3%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %2"
3440   [(set_attr "neon_type" "neon_shift_2")]
3443 (define_insn "neon_vshll_n<mode>"
3444   [(set (match_operand:<V_widen> 0 "s_register_operand" "=w")
3445         (unspec:<V_widen> [(match_operand:VW 1 "s_register_operand" "w")
3446                            (match_operand:SI 2 "immediate_operand" "i")
3447                            (match_operand:SI 3 "immediate_operand" "i")]
3448                           UNSPEC_VSHLL_N))]
3449   "TARGET_NEON"
3450   "vshll.%T3%#<V_sz_elem>\t%q0, %P1, %2"
3451   [(set_attr "neon_type" "neon_shift_1")]
3454 (define_insn "neon_vsra_n<mode>"
3455   [(set (match_operand:VDQIX 0 "s_register_operand" "=w")
3456         (unspec:VDQIX [(match_operand:VDQIX 1 "s_register_operand" "0")
3457                        (match_operand:VDQIX 2 "s_register_operand" "w")
3458                        (match_operand:SI 3 "immediate_operand" "i")
3459                        (match_operand:SI 4 "immediate_operand" "i")]
3460                       UNSPEC_VSRA_N))]
3461   "TARGET_NEON"
3462   "v%O4sra.%T4%#<V_sz_elem>\t%<V_reg>0, %<V_reg>2, %3"
3463   [(set_attr "neon_type" "neon_vsra_vrsra")]
3466 (define_insn "neon_vsri_n<mode>"
3467   [(set (match_operand:VDQIX 0 "s_register_operand" "=w")
3468         (unspec:VDQIX [(match_operand:VDQIX 1 "s_register_operand" "0")
3469                        (match_operand:VDQIX 2 "s_register_operand" "w")
3470                        (match_operand:SI 3 "immediate_operand" "i")]
3471                       UNSPEC_VSRI))]
3472   "TARGET_NEON"
3473   "vsri.<V_sz_elem>\t%<V_reg>0, %<V_reg>2, %3"
3474   [(set (attr "neon_type")
3475       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
3476                     (const_string "neon_shift_1")
3477                     (const_string "neon_shift_3")))]
3480 (define_insn "neon_vsli_n<mode>"
3481   [(set (match_operand:VDQIX 0 "s_register_operand" "=w")
3482         (unspec:VDQIX [(match_operand:VDQIX 1 "s_register_operand" "0")
3483                        (match_operand:VDQIX 2 "s_register_operand" "w")
3484                        (match_operand:SI 3 "immediate_operand" "i")]
3485                       UNSPEC_VSLI))]
3486   "TARGET_NEON"
3487   "vsli.<V_sz_elem>\t%<V_reg>0, %<V_reg>2, %3"
3488   [(set (attr "neon_type")
3489       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
3490                     (const_string "neon_shift_1")
3491                     (const_string "neon_shift_3")))]
3494 (define_insn "neon_vtbl1v8qi"
3495   [(set (match_operand:V8QI 0 "s_register_operand" "=w")
3496         (unspec:V8QI [(match_operand:V8QI 1 "s_register_operand" "w")
3497                       (match_operand:V8QI 2 "s_register_operand" "w")]
3498                      UNSPEC_VTBL))]
3499   "TARGET_NEON"
3500   "vtbl.8\t%P0, {%P1}, %P2"
3501   [(set_attr "neon_type" "neon_bp_2cycle")]
3504 (define_insn "neon_vtbl2v8qi"
3505   [(set (match_operand:V8QI 0 "s_register_operand" "=w")
3506         (unspec:V8QI [(match_operand:TI 1 "s_register_operand" "w")
3507                       (match_operand:V8QI 2 "s_register_operand" "w")]
3508                      UNSPEC_VTBL))]
3509   "TARGET_NEON"
3511   rtx ops[4];
3512   int tabbase = REGNO (operands[1]);
3514   ops[0] = operands[0];
3515   ops[1] = gen_rtx_REG (V8QImode, tabbase);
3516   ops[2] = gen_rtx_REG (V8QImode, tabbase + 2);
3517   ops[3] = operands[2];
3518   output_asm_insn ("vtbl.8\t%P0, {%P1, %P2}, %P3", ops);
3520   return "";
3522   [(set_attr "neon_type" "neon_bp_2cycle")]
3525 (define_insn "neon_vtbl3v8qi"
3526   [(set (match_operand:V8QI 0 "s_register_operand" "=w")
3527         (unspec:V8QI [(match_operand:EI 1 "s_register_operand" "w")
3528                       (match_operand:V8QI 2 "s_register_operand" "w")]
3529                      UNSPEC_VTBL))]
3530   "TARGET_NEON"
3532   rtx ops[5];
3533   int tabbase = REGNO (operands[1]);
3535   ops[0] = operands[0];
3536   ops[1] = gen_rtx_REG (V8QImode, tabbase);
3537   ops[2] = gen_rtx_REG (V8QImode, tabbase + 2);
3538   ops[3] = gen_rtx_REG (V8QImode, tabbase + 4);
3539   ops[4] = operands[2];
3540   output_asm_insn ("vtbl.8\t%P0, {%P1, %P2, %P3}, %P4", ops);
3542   return "";
3544   [(set_attr "neon_type" "neon_bp_3cycle")]
3547 (define_insn "neon_vtbl4v8qi"
3548   [(set (match_operand:V8QI 0 "s_register_operand" "=w")
3549         (unspec:V8QI [(match_operand:OI 1 "s_register_operand" "w")
3550                       (match_operand:V8QI 2 "s_register_operand" "w")]
3551                      UNSPEC_VTBL))]
3552   "TARGET_NEON"
3554   rtx ops[6];
3555   int tabbase = REGNO (operands[1]);
3557   ops[0] = operands[0];
3558   ops[1] = gen_rtx_REG (V8QImode, tabbase);
3559   ops[2] = gen_rtx_REG (V8QImode, tabbase + 2);
3560   ops[3] = gen_rtx_REG (V8QImode, tabbase + 4);
3561   ops[4] = gen_rtx_REG (V8QImode, tabbase + 6);
3562   ops[5] = operands[2];
3563   output_asm_insn ("vtbl.8\t%P0, {%P1, %P2, %P3, %P4}, %P5", ops);
3565   return "";
3567   [(set_attr "neon_type" "neon_bp_3cycle")]
3570 (define_insn "neon_vtbx1v8qi"
3571   [(set (match_operand:V8QI 0 "s_register_operand" "=w")
3572         (unspec:V8QI [(match_operand:V8QI 1 "s_register_operand" "0")
3573                       (match_operand:V8QI 2 "s_register_operand" "w")
3574                       (match_operand:V8QI 3 "s_register_operand" "w")]
3575                      UNSPEC_VTBX))]
3576   "TARGET_NEON"
3577   "vtbx.8\t%P0, {%P2}, %P3"
3578   [(set_attr "neon_type" "neon_bp_2cycle")]
3581 (define_insn "neon_vtbx2v8qi"
3582   [(set (match_operand:V8QI 0 "s_register_operand" "=w")
3583         (unspec:V8QI [(match_operand:V8QI 1 "s_register_operand" "0")
3584                       (match_operand:TI 2 "s_register_operand" "w")
3585                       (match_operand:V8QI 3 "s_register_operand" "w")]
3586                      UNSPEC_VTBX))]
3587   "TARGET_NEON"
3589   rtx ops[4];
3590   int tabbase = REGNO (operands[2]);
3592   ops[0] = operands[0];
3593   ops[1] = gen_rtx_REG (V8QImode, tabbase);
3594   ops[2] = gen_rtx_REG (V8QImode, tabbase + 2);
3595   ops[3] = operands[3];
3596   output_asm_insn ("vtbx.8\t%P0, {%P1, %P2}, %P3", ops);
3598   return "";
3600   [(set_attr "neon_type" "neon_bp_2cycle")]
3603 (define_insn "neon_vtbx3v8qi"
3604   [(set (match_operand:V8QI 0 "s_register_operand" "=w")
3605         (unspec:V8QI [(match_operand:V8QI 1 "s_register_operand" "0")
3606                       (match_operand:EI 2 "s_register_operand" "w")
3607                       (match_operand:V8QI 3 "s_register_operand" "w")]
3608                      UNSPEC_VTBX))]
3609   "TARGET_NEON"
3611   rtx ops[5];
3612   int tabbase = REGNO (operands[2]);
3614   ops[0] = operands[0];
3615   ops[1] = gen_rtx_REG (V8QImode, tabbase);
3616   ops[2] = gen_rtx_REG (V8QImode, tabbase + 2);
3617   ops[3] = gen_rtx_REG (V8QImode, tabbase + 4);
3618   ops[4] = operands[3];
3619   output_asm_insn ("vtbx.8\t%P0, {%P1, %P2, %P3}, %P4", ops);
3621   return "";
3623   [(set_attr "neon_type" "neon_bp_3cycle")]
3626 (define_insn "neon_vtbx4v8qi"
3627   [(set (match_operand:V8QI 0 "s_register_operand" "=w")
3628         (unspec:V8QI [(match_operand:V8QI 1 "s_register_operand" "0")
3629                       (match_operand:OI 2 "s_register_operand" "w")
3630                       (match_operand:V8QI 3 "s_register_operand" "w")]
3631                      UNSPEC_VTBX))]
3632   "TARGET_NEON"
3634   rtx ops[6];
3635   int tabbase = REGNO (operands[2]);
3637   ops[0] = operands[0];
3638   ops[1] = gen_rtx_REG (V8QImode, tabbase);
3639   ops[2] = gen_rtx_REG (V8QImode, tabbase + 2);
3640   ops[3] = gen_rtx_REG (V8QImode, tabbase + 4);
3641   ops[4] = gen_rtx_REG (V8QImode, tabbase + 6);
3642   ops[5] = operands[3];
3643   output_asm_insn ("vtbx.8\t%P0, {%P1, %P2, %P3, %P4}, %P5", ops);
3645   return "";
3647   [(set_attr "neon_type" "neon_bp_3cycle")]
3650 (define_insn "neon_vtrn<mode>_internal"
3651   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
3652         (unspec:VDQW [(match_operand:VDQW 1 "s_register_operand" "0")]
3653                      UNSPEC_VTRN1))
3654    (set (match_operand:VDQW 2 "s_register_operand" "=w")
3655         (unspec:VDQW [(match_operand:VDQW 3 "s_register_operand" "2")]
3656                      UNSPEC_VTRN2))]
3657   "TARGET_NEON"
3658   "vtrn.<V_sz_elem>\t%<V_reg>0, %<V_reg>2"
3659   [(set (attr "neon_type")
3660       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
3661                     (const_string "neon_bp_simple")
3662                     (const_string "neon_bp_3cycle")))]
3665 (define_expand "neon_vtrn<mode>"
3666   [(match_operand:SI 0 "s_register_operand" "r")
3667    (match_operand:VDQW 1 "s_register_operand" "w")
3668    (match_operand:VDQW 2 "s_register_operand" "w")]
3669   "TARGET_NEON"
3671   neon_emit_pair_result_insn (<MODE>mode, gen_neon_vtrn<mode>_internal,
3672                               operands[0], operands[1], operands[2]);
3673   DONE;
3676 (define_insn "neon_vzip<mode>_internal"
3677   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
3678         (unspec:VDQW [(match_operand:VDQW 1 "s_register_operand" "0")]
3679                      UNSPEC_VZIP1))
3680    (set (match_operand:VDQW 2 "s_register_operand" "=w")
3681         (unspec:VDQW [(match_operand:VDQW 3 "s_register_operand" "2")]
3682                      UNSPEC_VZIP2))]
3683   "TARGET_NEON"
3684   "vzip.<V_sz_elem>\t%<V_reg>0, %<V_reg>2"
3685   [(set (attr "neon_type")
3686       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
3687                     (const_string "neon_bp_simple")
3688                     (const_string "neon_bp_3cycle")))]
3691 (define_expand "neon_vzip<mode>"
3692   [(match_operand:SI 0 "s_register_operand" "r")
3693    (match_operand:VDQW 1 "s_register_operand" "w")
3694    (match_operand:VDQW 2 "s_register_operand" "w")]
3695   "TARGET_NEON"
3697   neon_emit_pair_result_insn (<MODE>mode, gen_neon_vzip<mode>_internal,
3698                               operands[0], operands[1], operands[2]);
3699   DONE;
3702 (define_insn "neon_vuzp<mode>_internal"
3703   [(set (match_operand:VDQW 0 "s_register_operand" "=w")
3704         (unspec:VDQW [(match_operand:VDQW 1 "s_register_operand" "0")]
3705                      UNSPEC_VUZP1))
3706    (set (match_operand:VDQW 2 "s_register_operand" "=w")
3707         (unspec:VDQW [(match_operand:VDQW 3 "s_register_operand" "2")]
3708                      UNSPEC_VUZP2))]
3709   "TARGET_NEON"
3710   "vuzp.<V_sz_elem>\t%<V_reg>0, %<V_reg>2"
3711   [(set (attr "neon_type")
3712       (if_then_else (ne (symbol_ref "<Is_d_reg>") (const_int 0))
3713                     (const_string "neon_bp_simple")
3714                     (const_string "neon_bp_3cycle")))]
3717 (define_expand "neon_vuzp<mode>"
3718   [(match_operand:SI 0 "s_register_operand" "r")
3719    (match_operand:VDQW 1 "s_register_operand" "w")
3720    (match_operand:VDQW 2 "s_register_operand" "w")]
3721   "TARGET_NEON"
3723   neon_emit_pair_result_insn (<MODE>mode, gen_neon_vuzp<mode>_internal,
3724                               operands[0], operands[1], operands[2]);
3725   DONE;
3728 (define_expand "neon_vreinterpretv8qi<mode>"
3729   [(match_operand:V8QI 0 "s_register_operand" "")
3730    (match_operand:VDX 1 "s_register_operand" "")]
3731   "TARGET_NEON"
3733   neon_reinterpret (operands[0], operands[1]);
3734   DONE;
3737 (define_expand "neon_vreinterpretv4hi<mode>"
3738   [(match_operand:V4HI 0 "s_register_operand" "")
3739    (match_operand:VDX 1 "s_register_operand" "")]
3740   "TARGET_NEON"
3742   neon_reinterpret (operands[0], operands[1]);
3743   DONE;
3746 (define_expand "neon_vreinterpretv2si<mode>"
3747   [(match_operand:V2SI 0 "s_register_operand" "")
3748    (match_operand:VDX 1 "s_register_operand" "")]
3749   "TARGET_NEON"
3751   neon_reinterpret (operands[0], operands[1]);
3752   DONE;
3755 (define_expand "neon_vreinterpretv2sf<mode>"
3756   [(match_operand:V2SF 0 "s_register_operand" "")
3757    (match_operand:VDX 1 "s_register_operand" "")]
3758   "TARGET_NEON"
3760   neon_reinterpret (operands[0], operands[1]);
3761   DONE;
3764 (define_expand "neon_vreinterpretdi<mode>"
3765   [(match_operand:DI 0 "s_register_operand" "")
3766    (match_operand:VDX 1 "s_register_operand" "")]
3767   "TARGET_NEON"
3769   neon_reinterpret (operands[0], operands[1]);
3770   DONE;
3773 (define_expand "neon_vreinterpretv16qi<mode>"
3774   [(match_operand:V16QI 0 "s_register_operand" "")
3775    (match_operand:VQX 1 "s_register_operand" "")]
3776   "TARGET_NEON"
3778   neon_reinterpret (operands[0], operands[1]);
3779   DONE;
3782 (define_expand "neon_vreinterpretv8hi<mode>"
3783   [(match_operand:V8HI 0 "s_register_operand" "")
3784    (match_operand:VQX 1 "s_register_operand" "")]
3785   "TARGET_NEON"
3787   neon_reinterpret (operands[0], operands[1]);
3788   DONE;
3791 (define_expand "neon_vreinterpretv4si<mode>"
3792   [(match_operand:V4SI 0 "s_register_operand" "")
3793    (match_operand:VQX 1 "s_register_operand" "")]
3794   "TARGET_NEON"
3796   neon_reinterpret (operands[0], operands[1]);
3797   DONE;
3800 (define_expand "neon_vreinterpretv4sf<mode>"
3801   [(match_operand:V4SF 0 "s_register_operand" "")
3802    (match_operand:VQX 1 "s_register_operand" "")]
3803   "TARGET_NEON"
3805   neon_reinterpret (operands[0], operands[1]);
3806   DONE;
3809 (define_expand "neon_vreinterpretv2di<mode>"
3810   [(match_operand:V2DI 0 "s_register_operand" "")
3811    (match_operand:VQX 1 "s_register_operand" "")]
3812   "TARGET_NEON"
3814   neon_reinterpret (operands[0], operands[1]);
3815   DONE;
3818 (define_insn "neon_vld1<mode>"
3819   [(set (match_operand:VDQX 0 "s_register_operand" "=w")
3820         (unspec:VDQX [(mem:VDQX (match_operand:SI 1 "s_register_operand" "r"))]
3821                     UNSPEC_VLD1))]
3822   "TARGET_NEON"
3823   "vld1.<V_sz_elem>\t%h0, [%1]"
3824   [(set_attr "neon_type" "neon_vld1_1_2_regs")]
3827 (define_insn "neon_vld1_lane<mode>"
3828   [(set (match_operand:VDX 0 "s_register_operand" "=w")
3829         (unspec:VDX [(mem:<V_elem> (match_operand:SI 1 "s_register_operand" "r"))
3830                      (match_operand:VDX 2 "s_register_operand" "0")
3831                      (match_operand:SI 3 "immediate_operand" "i")]
3832                     UNSPEC_VLD1_LANE))]
3833   "TARGET_NEON"
3835   HOST_WIDE_INT lane = INTVAL (operands[3]);
3836   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
3837   if (lane < 0 || lane >= max)
3838     error ("lane out of range");
3839   if (max == 1)
3840     return "vld1.<V_sz_elem>\t%P0, [%1]";
3841   else
3842     return "vld1.<V_sz_elem>\t{%P0[%c3]}, [%1]";
3844   [(set (attr "neon_type")
3845       (if_then_else (eq (const_string "<V_mode_nunits>") (const_int 2))
3846                     (const_string "neon_vld1_1_2_regs")
3847                     (const_string "neon_vld1_vld2_lane")))]
3850 (define_insn "neon_vld1_lane<mode>"
3851   [(set (match_operand:VQX 0 "s_register_operand" "=w")
3852         (unspec:VQX [(mem:<V_elem> (match_operand:SI 1 "s_register_operand" "r"))
3853                      (match_operand:VQX 2 "s_register_operand" "0")
3854                      (match_operand:SI 3 "immediate_operand" "i")]
3855                     UNSPEC_VLD1_LANE))]
3856   "TARGET_NEON"
3858   HOST_WIDE_INT lane = INTVAL (operands[3]);
3859   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
3860   int regno = REGNO (operands[0]);
3861   if (lane < 0 || lane >= max)
3862     error ("lane out of range");
3863   else if (lane >= max / 2)
3864     {
3865       lane -= max / 2;
3866       regno += 2;
3867       operands[3] = GEN_INT (lane);
3868     }
3869   operands[0] = gen_rtx_REG (<V_HALF>mode, regno);
3870   if (max == 2)
3871     return "vld1.<V_sz_elem>\t%P0, [%1]";
3872   else
3873     return "vld1.<V_sz_elem>\t{%P0[%c3]}, [%1]";
3875   [(set (attr "neon_type")
3876       (if_then_else (eq (const_string "<V_mode_nunits>") (const_int 2))
3877                     (const_string "neon_vld1_1_2_regs")
3878                     (const_string "neon_vld1_vld2_lane")))]
3881 (define_insn "neon_vld1_dup<mode>"
3882   [(set (match_operand:VDX 0 "s_register_operand" "=w")
3883         (unspec:VDX [(mem:<V_elem> (match_operand:SI 1 "s_register_operand" "r"))]
3884                     UNSPEC_VLD1_DUP))]
3885   "TARGET_NEON"
3887   if (GET_MODE_NUNITS (<MODE>mode) > 1)
3888     return "vld1.<V_sz_elem>\t{%P0[]}, [%1]";
3889   else
3890     return "vld1.<V_sz_elem>\t%h0, [%1]";
3892   [(set (attr "neon_type")
3893       (if_then_else (gt (const_string "<V_mode_nunits>") (const_string "1"))
3894                     (const_string "neon_vld2_2_regs_vld1_vld2_all_lanes")
3895                     (const_string "neon_vld1_1_2_regs")))]
3898 (define_insn "neon_vld1_dup<mode>"
3899   [(set (match_operand:VQX 0 "s_register_operand" "=w")
3900         (unspec:VQX [(mem:<V_elem> (match_operand:SI 1 "s_register_operand" "r"))]
3901                     UNSPEC_VLD1_DUP))]
3902   "TARGET_NEON"
3904   if (GET_MODE_NUNITS (<MODE>mode) > 2)
3905     return "vld1.<V_sz_elem>\t{%e0[], %f0[]}, [%1]";
3906   else
3907     return "vld1.<V_sz_elem>\t%h0, [%1]";
3909   [(set (attr "neon_type")
3910       (if_then_else (gt (const_string "<V_mode_nunits>") (const_string "1"))
3911                     (const_string "neon_vld2_2_regs_vld1_vld2_all_lanes")
3912                     (const_string "neon_vld1_1_2_regs")))]
3915 (define_insn "neon_vst1<mode>"
3916   [(set (mem:VDQX (match_operand:SI 0 "s_register_operand" "r"))
3917         (unspec:VDQX [(match_operand:VDQX 1 "s_register_operand" "w")]
3918                      UNSPEC_VST1))]
3919   "TARGET_NEON"
3920   "vst1.<V_sz_elem>\t%h1, [%0]"
3921   [(set_attr "neon_type" "neon_vst1_1_2_regs_vst2_2_regs")])
3923 (define_insn "neon_vst1_lane<mode>"
3924   [(set (mem:<V_elem> (match_operand:SI 0 "s_register_operand" "r"))
3925         (vec_select:<V_elem>
3926           (match_operand:VDX 1 "s_register_operand" "w")
3927           (parallel [(match_operand:SI 2 "neon_lane_number" "i")])))]
3928   "TARGET_NEON"
3930   HOST_WIDE_INT lane = INTVAL (operands[2]);
3931   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
3932   if (lane < 0 || lane >= max)
3933     error ("lane out of range");
3934   if (max == 1)
3935     return "vst1.<V_sz_elem>\t{%P1}, [%0]";
3936   else
3937     return "vst1.<V_sz_elem>\t{%P1[%c2]}, [%0]";
3939   [(set (attr "neon_type")
3940       (if_then_else (eq (const_string "<V_mode_nunits>") (const_int 1))
3941                     (const_string "neon_vst1_1_2_regs_vst2_2_regs")
3942                     (const_string "neon_vst1_vst2_lane")))])
3944 (define_insn "neon_vst1_lane<mode>"
3945   [(set (mem:<V_elem> (match_operand:SI 0 "s_register_operand" "r"))
3946         (vec_select:<V_elem>
3947            (match_operand:VQX 1 "s_register_operand" "w")
3948            (parallel [(match_operand:SI 2 "neon_lane_number" "i")])))]
3949   "TARGET_NEON"
3951   HOST_WIDE_INT lane = INTVAL (operands[2]);
3952   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
3953   int regno = REGNO (operands[1]);
3954   if (lane < 0 || lane >= max)
3955     error ("lane out of range");
3956   else if (lane >= max / 2)
3957     {
3958       lane -= max / 2;
3959       regno += 2;
3960       operands[2] = GEN_INT (lane);
3961     }
3962   operands[1] = gen_rtx_REG (<V_HALF>mode, regno);
3963   if (max == 2)
3964     return "vst1.<V_sz_elem>\t{%P1}, [%0]";
3965   else
3966     return "vst1.<V_sz_elem>\t{%P1[%c2]}, [%0]";
3968   [(set_attr "neon_type" "neon_vst1_vst2_lane")]
3971 (define_insn "neon_vld2<mode>"
3972   [(set (match_operand:TI 0 "s_register_operand" "=w")
3973         (unspec:TI [(mem:TI (match_operand:SI 1 "s_register_operand" "r"))
3974                     (unspec:VDX [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
3975                    UNSPEC_VLD2))]
3976   "TARGET_NEON"
3978   if (<V_sz_elem> == 64)
3979     return "vld1.64\t%h0, [%1]";
3980   else
3981     return "vld2.<V_sz_elem>\t%h0, [%1]";
3983   [(set (attr "neon_type")
3984       (if_then_else (eq (const_string "<V_sz_elem>") (const_string "64"))
3985                     (const_string "neon_vld1_1_2_regs")
3986                     (const_string "neon_vld2_2_regs_vld1_vld2_all_lanes")))]
3989 (define_insn "neon_vld2<mode>"
3990   [(set (match_operand:OI 0 "s_register_operand" "=w")
3991         (unspec:OI [(mem:OI (match_operand:SI 1 "s_register_operand" "r"))
3992                     (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
3993                    UNSPEC_VLD2))]
3994   "TARGET_NEON"
3995   "vld2.<V_sz_elem>\t%h0, [%1]"
3996   [(set_attr "neon_type" "neon_vld2_2_regs_vld1_vld2_all_lanes")])
3998 (define_insn "neon_vld2_lane<mode>"
3999   [(set (match_operand:TI 0 "s_register_operand" "=w")
4000         (unspec:TI [(mem:<V_two_elem> (match_operand:SI 1 "s_register_operand" "r"))
4001                     (match_operand:TI 2 "s_register_operand" "0")
4002                     (match_operand:SI 3 "immediate_operand" "i")
4003                     (unspec:VD [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4004                    UNSPEC_VLD2_LANE))]
4005   "TARGET_NEON"
4007   HOST_WIDE_INT lane = INTVAL (operands[3]);
4008   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
4009   int regno = REGNO (operands[0]);
4010   rtx ops[4];
4011   if (lane < 0 || lane >= max)
4012     error ("lane out of range");
4013   ops[0] = gen_rtx_REG (DImode, regno);
4014   ops[1] = gen_rtx_REG (DImode, regno + 2);
4015   ops[2] = operands[1];
4016   ops[3] = operands[3];
4017   output_asm_insn ("vld2.<V_sz_elem>\t{%P0[%c3], %P1[%c3]}, [%2]", ops);
4018   return "";
4020   [(set_attr "neon_type" "neon_vld1_vld2_lane")]
4023 (define_insn "neon_vld2_lane<mode>"
4024   [(set (match_operand:OI 0 "s_register_operand" "=w")
4025         (unspec:OI [(mem:<V_two_elem> (match_operand:SI 1 "s_register_operand" "r"))
4026                     (match_operand:OI 2 "s_register_operand" "0")
4027                     (match_operand:SI 3 "immediate_operand" "i")
4028                     (unspec:VMQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4029                    UNSPEC_VLD2_LANE))]
4030   "TARGET_NEON"
4032   HOST_WIDE_INT lane = INTVAL (operands[3]);
4033   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
4034   int regno = REGNO (operands[0]);
4035   rtx ops[4];
4036   if (lane < 0 || lane >= max)
4037     error ("lane out of range");
4038   else if (lane >= max / 2)
4039     {
4040       lane -= max / 2;
4041       regno += 2;
4042     }
4043   ops[0] = gen_rtx_REG (DImode, regno);
4044   ops[1] = gen_rtx_REG (DImode, regno + 4);
4045   ops[2] = operands[1];
4046   ops[3] = GEN_INT (lane);
4047   output_asm_insn ("vld2.<V_sz_elem>\t{%P0[%c3], %P1[%c3]}, [%2]", ops);
4048   return "";
4050   [(set_attr "neon_type" "neon_vld1_vld2_lane")]
4053 (define_insn "neon_vld2_dup<mode>"
4054   [(set (match_operand:TI 0 "s_register_operand" "=w")
4055         (unspec:TI [(mem:<V_two_elem> (match_operand:SI 1 "s_register_operand" "r"))
4056                     (unspec:VDX [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4057                    UNSPEC_VLD2_DUP))]
4058   "TARGET_NEON"
4060   if (GET_MODE_NUNITS (<MODE>mode) > 1)
4061     return "vld2.<V_sz_elem>\t{%e0[], %f0[]}, [%1]";
4062   else
4063     return "vld1.<V_sz_elem>\t%h0, [%1]";
4065   [(set (attr "neon_type")
4066       (if_then_else (gt (const_string "<V_mode_nunits>") (const_string "1"))
4067                     (const_string "neon_vld2_2_regs_vld1_vld2_all_lanes")
4068                     (const_string "neon_vld1_1_2_regs")))]
4071 (define_insn "neon_vst2<mode>"
4072   [(set (mem:TI (match_operand:SI 0 "s_register_operand" "r"))
4073         (unspec:TI [(match_operand:TI 1 "s_register_operand" "w")
4074                     (unspec:VDX [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4075                    UNSPEC_VST2))]
4076   "TARGET_NEON"
4078   if (<V_sz_elem> == 64)
4079     return "vst1.64\t%h1, [%0]";
4080   else
4081     return "vst2.<V_sz_elem>\t%h1, [%0]";
4083   [(set (attr "neon_type")
4084       (if_then_else (eq (const_string "<V_sz_elem>") (const_string "64"))
4085                     (const_string "neon_vst1_1_2_regs_vst2_2_regs")
4086                     (const_string "neon_vst1_1_2_regs_vst2_2_regs")))]
4089 (define_insn "neon_vst2<mode>"
4090   [(set (mem:OI (match_operand:SI 0 "s_register_operand" "r"))
4091         (unspec:OI [(match_operand:OI 1 "s_register_operand" "w")
4092                     (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4093                    UNSPEC_VST2))]
4094   "TARGET_NEON"
4095   "vst2.<V_sz_elem>\t%h1, [%0]"
4096   [(set_attr "neon_type" "neon_vst1_1_2_regs_vst2_2_regs")]
4099 (define_insn "neon_vst2_lane<mode>"
4100   [(set (mem:<V_two_elem> (match_operand:SI 0 "s_register_operand" "r"))
4101         (unspec:<V_two_elem>
4102           [(match_operand:TI 1 "s_register_operand" "w")
4103            (match_operand:SI 2 "immediate_operand" "i")
4104            (unspec:VD [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4105           UNSPEC_VST2_LANE))]
4106   "TARGET_NEON"
4108   HOST_WIDE_INT lane = INTVAL (operands[2]);
4109   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
4110   int regno = REGNO (operands[1]);
4111   rtx ops[4];
4112   if (lane < 0 || lane >= max)
4113     error ("lane out of range");
4114   ops[0] = operands[0];
4115   ops[1] = gen_rtx_REG (DImode, regno);
4116   ops[2] = gen_rtx_REG (DImode, regno + 2);
4117   ops[3] = operands[2];
4118   output_asm_insn ("vst2.<V_sz_elem>\t{%P1[%c3], %P2[%c3]}, [%0]", ops);
4119   return "";
4121   [(set_attr "neon_type" "neon_vst1_vst2_lane")]
4124 (define_insn "neon_vst2_lane<mode>"
4125   [(set (mem:<V_two_elem> (match_operand:SI 0 "s_register_operand" "r"))
4126         (unspec:<V_two_elem>
4127            [(match_operand:OI 1 "s_register_operand" "w")
4128             (match_operand:SI 2 "immediate_operand" "i")
4129             (unspec:VMQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4130            UNSPEC_VST2_LANE))]
4131   "TARGET_NEON"
4133   HOST_WIDE_INT lane = INTVAL (operands[2]);
4134   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
4135   int regno = REGNO (operands[1]);
4136   rtx ops[4];
4137   if (lane < 0 || lane >= max)
4138     error ("lane out of range");
4139   else if (lane >= max / 2)
4140     {
4141       lane -= max / 2;
4142       regno += 2;
4143     }
4144   ops[0] = operands[0];
4145   ops[1] = gen_rtx_REG (DImode, regno);
4146   ops[2] = gen_rtx_REG (DImode, regno + 4);
4147   ops[3] = GEN_INT (lane);
4148   output_asm_insn ("vst2.<V_sz_elem>\t{%P1[%c3], %P2[%c3]}, [%0]", ops);
4149   return "";
4151   [(set_attr "neon_type" "neon_vst1_vst2_lane")]
4154 (define_insn "neon_vld3<mode>"
4155   [(set (match_operand:EI 0 "s_register_operand" "=w")
4156         (unspec:EI [(mem:EI (match_operand:SI 1 "s_register_operand" "r"))
4157                     (unspec:VDX [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4158                    UNSPEC_VLD3))]
4159   "TARGET_NEON"
4161   if (<V_sz_elem> == 64)
4162     return "vld1.64\t%h0, [%1]";
4163   else
4164     return "vld3.<V_sz_elem>\t%h0, [%1]";
4166   [(set (attr "neon_type")
4167       (if_then_else (eq (const_string "<V_sz_elem>") (const_string "64"))
4168                     (const_string "neon_vld1_1_2_regs")
4169                     (const_string "neon_vld3_vld4")))]
4172 (define_expand "neon_vld3<mode>"
4173   [(match_operand:CI 0 "s_register_operand" "=w")
4174    (match_operand:SI 1 "s_register_operand" "+r")
4175    (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4176   "TARGET_NEON"
4178   emit_insn (gen_neon_vld3qa<mode> (operands[0], operands[0],
4179                                     operands[1], operands[1]));
4180   emit_insn (gen_neon_vld3qb<mode> (operands[0], operands[0],
4181                                     operands[1], operands[1]));
4182   DONE;
4185 (define_insn "neon_vld3qa<mode>"
4186   [(set (match_operand:CI 0 "s_register_operand" "=w")
4187         (unspec:CI [(mem:CI (match_operand:SI 3 "s_register_operand" "2"))
4188                     (match_operand:CI 1 "s_register_operand" "0")
4189                     (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4190                    UNSPEC_VLD3A))
4191    (set (match_operand:SI 2 "s_register_operand" "=r")
4192         (plus:SI (match_dup 3)
4193                  (const_int 24)))]
4194   "TARGET_NEON"
4196   int regno = REGNO (operands[0]);
4197   rtx ops[4];
4198   ops[0] = gen_rtx_REG (DImode, regno);
4199   ops[1] = gen_rtx_REG (DImode, regno + 4);
4200   ops[2] = gen_rtx_REG (DImode, regno + 8);
4201   ops[3] = operands[2];
4202   output_asm_insn ("vld3.<V_sz_elem>\t{%P0, %P1, %P2}, [%3]!", ops);
4203   return "";
4205   [(set_attr "neon_type" "neon_vld3_vld4")]
4208 (define_insn "neon_vld3qb<mode>"
4209   [(set (match_operand:CI 0 "s_register_operand" "=w")
4210         (unspec:CI [(mem:CI (match_operand:SI 3 "s_register_operand" "2"))
4211                     (match_operand:CI 1 "s_register_operand" "0")
4212                     (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4213                    UNSPEC_VLD3B))
4214    (set (match_operand:SI 2 "s_register_operand" "=r")
4215         (plus:SI (match_dup 3)
4216                  (const_int 24)))]
4217   "TARGET_NEON"
4219   int regno = REGNO (operands[0]);
4220   rtx ops[4];
4221   ops[0] = gen_rtx_REG (DImode, regno + 2);
4222   ops[1] = gen_rtx_REG (DImode, regno + 6);
4223   ops[2] = gen_rtx_REG (DImode, regno + 10);
4224   ops[3] = operands[2];
4225   output_asm_insn ("vld3.<V_sz_elem>\t{%P0, %P1, %P2}, [%3]!", ops);
4226   return "";
4228   [(set_attr "neon_type" "neon_vld3_vld4")]
4231 (define_insn "neon_vld3_lane<mode>"
4232   [(set (match_operand:EI 0 "s_register_operand" "=w")
4233         (unspec:EI [(mem:<V_three_elem> (match_operand:SI 1 "s_register_operand" "r"))
4234                     (match_operand:EI 2 "s_register_operand" "0")
4235                     (match_operand:SI 3 "immediate_operand" "i")
4236                     (unspec:VD [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4237                    UNSPEC_VLD3_LANE))]
4238   "TARGET_NEON"
4240   HOST_WIDE_INT lane = INTVAL (operands[3]);
4241   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
4242   int regno = REGNO (operands[0]);
4243   rtx ops[5];
4244   if (lane < 0 || lane >= max)
4245     error ("lane out of range");
4246   ops[0] = gen_rtx_REG (DImode, regno);
4247   ops[1] = gen_rtx_REG (DImode, regno + 2);
4248   ops[2] = gen_rtx_REG (DImode, regno + 4);
4249   ops[3] = operands[1];
4250   ops[4] = operands[3];
4251   output_asm_insn ("vld3.<V_sz_elem>\t{%P0[%c4], %P1[%c4], %P2[%c4]}, [%3]",
4252                    ops);
4253   return "";
4255   [(set_attr "neon_type" "neon_vld3_vld4_lane")]
4258 (define_insn "neon_vld3_lane<mode>"
4259   [(set (match_operand:CI 0 "s_register_operand" "=w")
4260         (unspec:CI [(mem:<V_three_elem> (match_operand:SI 1 "s_register_operand" "r"))
4261                     (match_operand:CI 2 "s_register_operand" "0")
4262                     (match_operand:SI 3 "immediate_operand" "i")
4263                     (unspec:VMQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4264                    UNSPEC_VLD3_LANE))]
4265   "TARGET_NEON"
4267   HOST_WIDE_INT lane = INTVAL (operands[3]);
4268   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
4269   int regno = REGNO (operands[0]);
4270   rtx ops[5];
4271   if (lane < 0 || lane >= max)
4272     error ("lane out of range");
4273   else if (lane >= max / 2)
4274     {
4275       lane -= max / 2;
4276       regno += 2;
4277     }
4278   ops[0] = gen_rtx_REG (DImode, regno);
4279   ops[1] = gen_rtx_REG (DImode, regno + 4);
4280   ops[2] = gen_rtx_REG (DImode, regno + 8);
4281   ops[3] = operands[1];
4282   ops[4] = GEN_INT (lane);
4283   output_asm_insn ("vld3.<V_sz_elem>\t{%P0[%c4], %P1[%c4], %P2[%c4]}, [%3]",
4284                    ops);
4285   return "";
4287   [(set_attr "neon_type" "neon_vld3_vld4_lane")]
4290 (define_insn "neon_vld3_dup<mode>"
4291   [(set (match_operand:EI 0 "s_register_operand" "=w")
4292         (unspec:EI [(mem:<V_three_elem> (match_operand:SI 1 "s_register_operand" "r"))
4293                     (unspec:VDX [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4294                    UNSPEC_VLD3_DUP))]
4295   "TARGET_NEON"
4297   if (GET_MODE_NUNITS (<MODE>mode) > 1)
4298     {
4299       int regno = REGNO (operands[0]);
4300       rtx ops[4];
4301       ops[0] = gen_rtx_REG (DImode, regno);
4302       ops[1] = gen_rtx_REG (DImode, regno + 2);
4303       ops[2] = gen_rtx_REG (DImode, regno + 4);
4304       ops[3] = operands[1];
4305       output_asm_insn ("vld3.<V_sz_elem>\t{%P0[], %P1[], %P2[]}, [%3]", ops);
4306       return "";
4307     }
4308   else
4309     return "vld1.<V_sz_elem>\t%h0, [%1]";
4311   [(set (attr "neon_type")
4312       (if_then_else (gt (const_string "<V_mode_nunits>") (const_string "1"))
4313                     (const_string "neon_vld3_vld4_all_lanes")
4314                     (const_string "neon_vld1_1_2_regs")))])
4316 (define_insn "neon_vst3<mode>"
4317   [(set (mem:EI (match_operand:SI 0 "s_register_operand" "r"))
4318         (unspec:EI [(match_operand:EI 1 "s_register_operand" "w")
4319                     (unspec:VDX [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4320                    UNSPEC_VST3))]
4321   "TARGET_NEON"
4323   if (<V_sz_elem> == 64)
4324     return "vst1.64\t%h1, [%0]";
4325   else
4326     return "vst3.<V_sz_elem>\t%h1, [%0]";
4328   [(set (attr "neon_type")
4329       (if_then_else (eq (const_string "<V_sz_elem>") (const_string "64"))
4330                     (const_string "neon_vst1_1_2_regs_vst2_2_regs")
4331                     (const_string "neon_vst2_4_regs_vst3_vst4")))])
4333 (define_expand "neon_vst3<mode>"
4334   [(match_operand:SI 0 "s_register_operand" "+r")
4335    (match_operand:CI 1 "s_register_operand" "w")
4336    (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4337   "TARGET_NEON"
4339   emit_insn (gen_neon_vst3qa<mode> (operands[0], operands[0], operands[1]));
4340   emit_insn (gen_neon_vst3qb<mode> (operands[0], operands[0], operands[1]));
4341   DONE;
4344 (define_insn "neon_vst3qa<mode>"
4345   [(set (mem:EI (match_operand:SI 1 "s_register_operand" "0"))
4346         (unspec:EI [(match_operand:CI 2 "s_register_operand" "w")
4347                     (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4348                    UNSPEC_VST3A))
4349    (set (match_operand:SI 0 "s_register_operand" "=r")
4350         (plus:SI (match_dup 1)
4351                  (const_int 24)))]
4352   "TARGET_NEON"
4354   int regno = REGNO (operands[2]);
4355   rtx ops[4];
4356   ops[0] = operands[0];
4357   ops[1] = gen_rtx_REG (DImode, regno);
4358   ops[2] = gen_rtx_REG (DImode, regno + 4);
4359   ops[3] = gen_rtx_REG (DImode, regno + 8);
4360   output_asm_insn ("vst3.<V_sz_elem>\t{%P1, %P2, %P3}, [%0]!", ops);
4361   return "";
4363   [(set_attr "neon_type" "neon_vst2_4_regs_vst3_vst4")]
4366 (define_insn "neon_vst3qb<mode>"
4367   [(set (mem:EI (match_operand:SI 1 "s_register_operand" "0"))
4368         (unspec:EI [(match_operand:CI 2 "s_register_operand" "w")
4369                     (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4370                    UNSPEC_VST3B))
4371    (set (match_operand:SI 0 "s_register_operand" "=r")
4372         (plus:SI (match_dup 1)
4373                  (const_int 24)))]
4374   "TARGET_NEON"
4376   int regno = REGNO (operands[2]);
4377   rtx ops[4];
4378   ops[0] = operands[0];
4379   ops[1] = gen_rtx_REG (DImode, regno + 2);
4380   ops[2] = gen_rtx_REG (DImode, regno + 6);
4381   ops[3] = gen_rtx_REG (DImode, regno + 10);
4382   output_asm_insn ("vst3.<V_sz_elem>\t{%P1, %P2, %P3}, [%0]!", ops);
4383   return "";
4385   [(set_attr "neon_type" "neon_vst2_4_regs_vst3_vst4")]
4388 (define_insn "neon_vst3_lane<mode>"
4389   [(set (mem:<V_three_elem> (match_operand:SI 0 "s_register_operand" "r"))
4390         (unspec:<V_three_elem>
4391            [(match_operand:EI 1 "s_register_operand" "w")
4392             (match_operand:SI 2 "immediate_operand" "i")
4393             (unspec:VD [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4394            UNSPEC_VST3_LANE))]
4395   "TARGET_NEON"
4397   HOST_WIDE_INT lane = INTVAL (operands[2]);
4398   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
4399   int regno = REGNO (operands[1]);
4400   rtx ops[5];
4401   if (lane < 0 || lane >= max)
4402     error ("lane out of range");
4403   ops[0] = operands[0];
4404   ops[1] = gen_rtx_REG (DImode, regno);
4405   ops[2] = gen_rtx_REG (DImode, regno + 2);
4406   ops[3] = gen_rtx_REG (DImode, regno + 4);
4407   ops[4] = operands[2];
4408   output_asm_insn ("vst3.<V_sz_elem>\t{%P1[%c4], %P2[%c4], %P3[%c4]}, [%0]",
4409                    ops);
4410   return "";
4412   [(set_attr "neon_type" "neon_vst3_vst4_lane")]
4415 (define_insn "neon_vst3_lane<mode>"
4416   [(set (mem:<V_three_elem> (match_operand:SI 0 "s_register_operand" "r"))
4417         (unspec:<V_three_elem>
4418            [(match_operand:CI 1 "s_register_operand" "w")
4419             (match_operand:SI 2 "immediate_operand" "i")
4420             (unspec:VMQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4421            UNSPEC_VST3_LANE))]
4422   "TARGET_NEON"
4424   HOST_WIDE_INT lane = INTVAL (operands[2]);
4425   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
4426   int regno = REGNO (operands[1]);
4427   rtx ops[5];
4428   if (lane < 0 || lane >= max)
4429     error ("lane out of range");
4430   else if (lane >= max / 2)
4431     {
4432       lane -= max / 2;
4433       regno += 2;
4434     }
4435   ops[0] = operands[0];
4436   ops[1] = gen_rtx_REG (DImode, regno);
4437   ops[2] = gen_rtx_REG (DImode, regno + 4);
4438   ops[3] = gen_rtx_REG (DImode, regno + 8);
4439   ops[4] = GEN_INT (lane);
4440   output_asm_insn ("vst3.<V_sz_elem>\t{%P1[%c4], %P2[%c4], %P3[%c4]}, [%0]",
4441                    ops);
4442   return "";
4444 [(set_attr "neon_type" "neon_vst3_vst4_lane")])
4446 (define_insn "neon_vld4<mode>"
4447   [(set (match_operand:OI 0 "s_register_operand" "=w")
4448         (unspec:OI [(mem:OI (match_operand:SI 1 "s_register_operand" "r"))
4449                     (unspec:VDX [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4450                    UNSPEC_VLD4))]
4451   "TARGET_NEON"
4453   if (<V_sz_elem> == 64)
4454     return "vld1.64\t%h0, [%1]";
4455   else
4456     return "vld4.<V_sz_elem>\t%h0, [%1]";
4458   [(set (attr "neon_type")
4459       (if_then_else (eq (const_string "<V_sz_elem>") (const_string "64"))
4460                     (const_string "neon_vld1_1_2_regs")
4461                     (const_string "neon_vld3_vld4")))]
4464 (define_expand "neon_vld4<mode>"
4465   [(match_operand:XI 0 "s_register_operand" "=w")
4466    (match_operand:SI 1 "s_register_operand" "+r")
4467    (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4468   "TARGET_NEON"
4470   emit_insn (gen_neon_vld4qa<mode> (operands[0], operands[0],
4471                                     operands[1], operands[1]));
4472   emit_insn (gen_neon_vld4qb<mode> (operands[0], operands[0],
4473                                     operands[1], operands[1]));
4474   DONE;
4477 (define_insn "neon_vld4qa<mode>"
4478   [(set (match_operand:XI 0 "s_register_operand" "=w")
4479         (unspec:XI [(mem:XI (match_operand:SI 3 "s_register_operand" "2"))
4480                     (match_operand:XI 1 "s_register_operand" "0")
4481                     (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4482                    UNSPEC_VLD4A))
4483    (set (match_operand:SI 2 "s_register_operand" "=r")
4484         (plus:SI (match_dup 3)
4485                  (const_int 32)))]
4486   "TARGET_NEON"
4488   int regno = REGNO (operands[0]);
4489   rtx ops[5];
4490   ops[0] = gen_rtx_REG (DImode, regno);
4491   ops[1] = gen_rtx_REG (DImode, regno + 4);
4492   ops[2] = gen_rtx_REG (DImode, regno + 8);
4493   ops[3] = gen_rtx_REG (DImode, regno + 12);
4494   ops[4] = operands[2];
4495   output_asm_insn ("vld4.<V_sz_elem>\t{%P0, %P1, %P2, %P3}, [%4]!", ops);
4496   return "";
4498   [(set_attr "neon_type" "neon_vld3_vld4")]
4501 (define_insn "neon_vld4qb<mode>"
4502   [(set (match_operand:XI 0 "s_register_operand" "=w")
4503         (unspec:XI [(mem:XI (match_operand:SI 3 "s_register_operand" "2"))
4504                     (match_operand:XI 1 "s_register_operand" "0")
4505                     (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4506                    UNSPEC_VLD4B))
4507    (set (match_operand:SI 2 "s_register_operand" "=r")
4508         (plus:SI (match_dup 3)
4509                  (const_int 32)))]
4510   "TARGET_NEON"
4512   int regno = REGNO (operands[0]);
4513   rtx ops[5];
4514   ops[0] = gen_rtx_REG (DImode, regno + 2);
4515   ops[1] = gen_rtx_REG (DImode, regno + 6);
4516   ops[2] = gen_rtx_REG (DImode, regno + 10);
4517   ops[3] = gen_rtx_REG (DImode, regno + 14);
4518   ops[4] = operands[2];
4519   output_asm_insn ("vld4.<V_sz_elem>\t{%P0, %P1, %P2, %P3}, [%4]!", ops);
4520   return "";
4522   [(set_attr "neon_type" "neon_vld3_vld4")]
4525 (define_insn "neon_vld4_lane<mode>"
4526   [(set (match_operand:OI 0 "s_register_operand" "=w")
4527         (unspec:OI [(mem:<V_four_elem> (match_operand:SI 1 "s_register_operand" "r"))
4528                     (match_operand:OI 2 "s_register_operand" "0")
4529                     (match_operand:SI 3 "immediate_operand" "i")
4530                     (unspec:VD [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4531                    UNSPEC_VLD4_LANE))]
4532   "TARGET_NEON"
4534   HOST_WIDE_INT lane = INTVAL (operands[3]);
4535   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
4536   int regno = REGNO (operands[0]);
4537   rtx ops[6];
4538   if (lane < 0 || lane >= max)
4539     error ("lane out of range");
4540   ops[0] = gen_rtx_REG (DImode, regno);
4541   ops[1] = gen_rtx_REG (DImode, regno + 2);
4542   ops[2] = gen_rtx_REG (DImode, regno + 4);
4543   ops[3] = gen_rtx_REG (DImode, regno + 6);
4544   ops[4] = operands[1];
4545   ops[5] = operands[3];
4546   output_asm_insn ("vld4.<V_sz_elem>\t{%P0[%c5], %P1[%c5], %P2[%c5], %P3[%c5]}, [%4]",
4547                    ops);
4548   return "";
4550   [(set_attr "neon_type" "neon_vld3_vld4_lane")]
4553 (define_insn "neon_vld4_lane<mode>"
4554   [(set (match_operand:XI 0 "s_register_operand" "=w")
4555         (unspec:XI [(mem:<V_four_elem> (match_operand:SI 1 "s_register_operand" "r"))
4556                     (match_operand:XI 2 "s_register_operand" "0")
4557                     (match_operand:SI 3 "immediate_operand" "i")
4558                     (unspec:VMQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4559                    UNSPEC_VLD4_LANE))]
4560   "TARGET_NEON"
4562   HOST_WIDE_INT lane = INTVAL (operands[3]);
4563   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
4564   int regno = REGNO (operands[0]);
4565   rtx ops[6];
4566   if (lane < 0 || lane >= max)
4567     error ("lane out of range");
4568   else if (lane >= max / 2)
4569     {
4570       lane -= max / 2;
4571       regno += 2;
4572     }
4573   ops[0] = gen_rtx_REG (DImode, regno);
4574   ops[1] = gen_rtx_REG (DImode, regno + 4);
4575   ops[2] = gen_rtx_REG (DImode, regno + 8);
4576   ops[3] = gen_rtx_REG (DImode, regno + 12);
4577   ops[4] = operands[1];
4578   ops[5] = GEN_INT (lane);
4579   output_asm_insn ("vld4.<V_sz_elem>\t{%P0[%c5], %P1[%c5], %P2[%c5], %P3[%c5]}, [%4]",
4580                    ops);
4581   return "";
4583   [(set_attr "neon_type" "neon_vld3_vld4_lane")]
4586 (define_insn "neon_vld4_dup<mode>"
4587   [(set (match_operand:OI 0 "s_register_operand" "=w")
4588         (unspec:OI [(mem:<V_four_elem> (match_operand:SI 1 "s_register_operand" "r"))
4589                     (unspec:VDX [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4590                    UNSPEC_VLD4_DUP))]
4591   "TARGET_NEON"
4593   if (GET_MODE_NUNITS (<MODE>mode) > 1)
4594     {
4595       int regno = REGNO (operands[0]);
4596       rtx ops[5];
4597       ops[0] = gen_rtx_REG (DImode, regno);
4598       ops[1] = gen_rtx_REG (DImode, regno + 2);
4599       ops[2] = gen_rtx_REG (DImode, regno + 4);
4600       ops[3] = gen_rtx_REG (DImode, regno + 6);
4601       ops[4] = operands[1];
4602       output_asm_insn ("vld4.<V_sz_elem>\t{%P0[], %P1[], %P2[], %P3[]}, [%4]",
4603                        ops);
4604       return "";
4605     }
4606   else
4607     return "vld1.<V_sz_elem>\t%h0, [%1]";
4609   [(set (attr "neon_type")
4610       (if_then_else (gt (const_string "<V_mode_nunits>") (const_string "1"))
4611                     (const_string "neon_vld3_vld4_all_lanes")
4612                     (const_string "neon_vld1_1_2_regs")))]
4615 (define_insn "neon_vst4<mode>"
4616   [(set (mem:OI (match_operand:SI 0 "s_register_operand" "r"))
4617         (unspec:OI [(match_operand:OI 1 "s_register_operand" "w")
4618                     (unspec:VDX [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4619                    UNSPEC_VST4))]
4620   "TARGET_NEON"
4622   if (<V_sz_elem> == 64)
4623     return "vst1.64\t%h1, [%0]";
4624   else
4625     return "vst4.<V_sz_elem>\t%h1, [%0]";
4627   [(set (attr "neon_type")
4628       (if_then_else (eq (const_string "<V_sz_elem>") (const_string "64"))
4629                     (const_string "neon_vst1_1_2_regs_vst2_2_regs")
4630                     (const_string "neon_vst2_4_regs_vst3_vst4")))]
4633 (define_expand "neon_vst4<mode>"
4634   [(match_operand:SI 0 "s_register_operand" "+r")
4635    (match_operand:XI 1 "s_register_operand" "w")
4636    (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4637   "TARGET_NEON"
4639   emit_insn (gen_neon_vst4qa<mode> (operands[0], operands[0], operands[1]));
4640   emit_insn (gen_neon_vst4qb<mode> (operands[0], operands[0], operands[1]));
4641   DONE;
4644 (define_insn "neon_vst4qa<mode>"
4645   [(set (mem:OI (match_operand:SI 1 "s_register_operand" "0"))
4646         (unspec:OI [(match_operand:XI 2 "s_register_operand" "w")
4647                     (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4648                    UNSPEC_VST4A))
4649    (set (match_operand:SI 0 "s_register_operand" "=r")
4650         (plus:SI (match_dup 1)
4651                  (const_int 32)))]
4652   "TARGET_NEON"
4654   int regno = REGNO (operands[2]);
4655   rtx ops[5];
4656   ops[0] = operands[0];
4657   ops[1] = gen_rtx_REG (DImode, regno);
4658   ops[2] = gen_rtx_REG (DImode, regno + 4);
4659   ops[3] = gen_rtx_REG (DImode, regno + 8);
4660   ops[4] = gen_rtx_REG (DImode, regno + 12);
4661   output_asm_insn ("vst4.<V_sz_elem>\t{%P1, %P2, %P3, %P4}, [%0]!", ops);
4662   return "";
4664   [(set_attr "neon_type" "neon_vst2_4_regs_vst3_vst4")]
4667 (define_insn "neon_vst4qb<mode>"
4668   [(set (mem:OI (match_operand:SI 1 "s_register_operand" "0"))
4669         (unspec:OI [(match_operand:XI 2 "s_register_operand" "w")
4670                     (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4671                    UNSPEC_VST4B))
4672    (set (match_operand:SI 0 "s_register_operand" "=r")
4673         (plus:SI (match_dup 1)
4674                  (const_int 32)))]
4675   "TARGET_NEON"
4677   int regno = REGNO (operands[2]);
4678   rtx ops[5];
4679   ops[0] = operands[0];
4680   ops[1] = gen_rtx_REG (DImode, regno + 2);
4681   ops[2] = gen_rtx_REG (DImode, regno + 6);
4682   ops[3] = gen_rtx_REG (DImode, regno + 10);
4683   ops[4] = gen_rtx_REG (DImode, regno + 14);
4684   output_asm_insn ("vst4.<V_sz_elem>\t{%P1, %P2, %P3, %P4}, [%0]!", ops);
4685   return "";
4687   [(set_attr "neon_type" "neon_vst2_4_regs_vst3_vst4")]
4690 (define_insn "neon_vst4_lane<mode>"
4691   [(set (mem:<V_four_elem> (match_operand:SI 0 "s_register_operand" "r"))
4692         (unspec:<V_four_elem>
4693            [(match_operand:OI 1 "s_register_operand" "w")
4694             (match_operand:SI 2 "immediate_operand" "i")
4695             (unspec:VD [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4696            UNSPEC_VST4_LANE))]
4697   "TARGET_NEON"
4699   HOST_WIDE_INT lane = INTVAL (operands[2]);
4700   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
4701   int regno = REGNO (operands[1]);
4702   rtx ops[6];
4703   if (lane < 0 || lane >= max)
4704     error ("lane out of range");
4705   ops[0] = operands[0];
4706   ops[1] = gen_rtx_REG (DImode, regno);
4707   ops[2] = gen_rtx_REG (DImode, regno + 2);
4708   ops[3] = gen_rtx_REG (DImode, regno + 4);
4709   ops[4] = gen_rtx_REG (DImode, regno + 6);
4710   ops[5] = operands[2];
4711   output_asm_insn ("vst4.<V_sz_elem>\t{%P1[%c5], %P2[%c5], %P3[%c5], %P4[%c5]}, [%0]",
4712                    ops);
4713   return "";
4715   [(set_attr "neon_type" "neon_vst3_vst4_lane")]
4718 (define_insn "neon_vst4_lane<mode>"
4719   [(set (mem:<V_four_elem> (match_operand:SI 0 "s_register_operand" "r"))
4720         (unspec:<V_four_elem>
4721            [(match_operand:XI 1 "s_register_operand" "w")
4722             (match_operand:SI 2 "immediate_operand" "i")
4723             (unspec:VMQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
4724            UNSPEC_VST4_LANE))]
4725   "TARGET_NEON"
4727   HOST_WIDE_INT lane = INTVAL (operands[2]);
4728   HOST_WIDE_INT max = GET_MODE_NUNITS (<MODE>mode);
4729   int regno = REGNO (operands[1]);
4730   rtx ops[6];
4731   if (lane < 0 || lane >= max)
4732     error ("lane out of range");
4733   else if (lane >= max / 2)
4734     {
4735       lane -= max / 2;
4736       regno += 2;
4737     }
4738   ops[0] = operands[0];
4739   ops[1] = gen_rtx_REG (DImode, regno);
4740   ops[2] = gen_rtx_REG (DImode, regno + 4);
4741   ops[3] = gen_rtx_REG (DImode, regno + 8);
4742   ops[4] = gen_rtx_REG (DImode, regno + 12);
4743   ops[5] = GEN_INT (lane);
4744   output_asm_insn ("vst4.<V_sz_elem>\t{%P1[%c5], %P2[%c5], %P3[%c5], %P4[%c5]}, [%0]",
4745                    ops);
4746   return "";
4748   [(set_attr "neon_type" "neon_vst3_vst4_lane")]
4751 (define_expand "neon_vand<mode>"
4752   [(match_operand:VDQX 0 "s_register_operand" "")
4753    (match_operand:VDQX 1 "s_register_operand" "")
4754    (match_operand:VDQX 2 "neon_inv_logic_op2" "")
4755    (match_operand:SI 3 "immediate_operand" "")]
4756   "TARGET_NEON"
4758   emit_insn (gen_and<mode>3<V_suf64> (operands[0], operands[1], operands[2]));
4759   DONE;
4762 (define_expand "neon_vorr<mode>"
4763   [(match_operand:VDQX 0 "s_register_operand" "")
4764    (match_operand:VDQX 1 "s_register_operand" "")
4765    (match_operand:VDQX 2 "neon_logic_op2" "")
4766    (match_operand:SI 3 "immediate_operand" "")]
4767   "TARGET_NEON"
4769   emit_insn (gen_ior<mode>3<V_suf64> (operands[0], operands[1], operands[2]));
4770   DONE;
4773 (define_expand "neon_veor<mode>"
4774   [(match_operand:VDQX 0 "s_register_operand" "")
4775    (match_operand:VDQX 1 "s_register_operand" "")
4776    (match_operand:VDQX 2 "s_register_operand" "")
4777    (match_operand:SI 3 "immediate_operand" "")]
4778   "TARGET_NEON"
4780   emit_insn (gen_xor<mode>3<V_suf64> (operands[0], operands[1], operands[2]));
4781   DONE;
4784 (define_expand "neon_vbic<mode>"
4785   [(match_operand:VDQX 0 "s_register_operand" "")
4786    (match_operand:VDQX 1 "s_register_operand" "")
4787    (match_operand:VDQX 2 "neon_logic_op2" "")
4788    (match_operand:SI 3 "immediate_operand" "")]
4789   "TARGET_NEON"
4791   emit_insn (gen_bic<mode>3_neon (operands[0], operands[1], operands[2]));
4792   DONE;
4795 (define_expand "neon_vorn<mode>"
4796   [(match_operand:VDQX 0 "s_register_operand" "")
4797    (match_operand:VDQX 1 "s_register_operand" "")
4798    (match_operand:VDQX 2 "neon_inv_logic_op2" "")
4799    (match_operand:SI 3 "immediate_operand" "")]
4800   "TARGET_NEON"
4802   emit_insn (gen_orn<mode>3_neon (operands[0], operands[1], operands[2]));
4803   DONE;