Debian Codegraph @

gcc/config/aarch64/aarch64-simd.md

raw
1 ;; Machine description for AArch64 AdvSIMD architecture.
2 ;; Copyright (C) 2011-2025 Free Software Foundation, Inc.
3 ;; Contributed by ARM Ltd.
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 3, or (at your option)
10 ;; any later version.
11 ;;
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.
16 ;;
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
20
21 ;; The following define_subst rules are used to produce patterns representing
22 ;; the implicit zeroing effect of 64-bit Advanced SIMD operations, in effect
23 ;; a vec_concat with zeroes. The order of the vec_concat operands differs
24 ;; for big-endian so we have a separate define_subst rule for each endianness.
25 (define_subst "add_vec_concat_subst_le"
26 [(set (match_operand:VDZ 0)
27 (match_operand:VDZ 1))]
28 "!BYTES_BIG_ENDIAN"
29 [(set (match_operand:<VDBL> 0 "register_operand" "=w")
30 (vec_concat:<VDBL>
31 (match_dup 1)
32 (match_operand:VDZ 2 "aarch64_simd_or_scalar_imm_zero")))])
33
34 (define_subst "add_vec_concat_subst_be"
35 [(set (match_operand:VDZ 0)
36 (match_operand:VDZ 1))]
37 "BYTES_BIG_ENDIAN"
38 [(set (match_operand:<VDBL> 0 "register_operand" "=w")
39 (vec_concat:<VDBL>
40 (match_operand:VDZ 2 "aarch64_simd_or_scalar_imm_zero")
41 (match_dup 1)))])
42
43 ;; The subst_attr definitions used to annotate patterns further in the file.
44 ;; Patterns that need to have the above substitutions added to them should
45 ;; have <vczle><vczbe> added to their name.
46 (define_subst_attr "vczle" "add_vec_concat_subst_le" "" "_vec_concatz_le")
47 (define_subst_attr "vczbe" "add_vec_concat_subst_be" "" "_vec_concatz_be")
48
49 (define_expand "mov<mode>"
50 [(set (match_operand:VALL_F16 0 "nonimmediate_operand")
51 (match_operand:VALL_F16 1 "general_operand"))]
52 "TARGET_FLOAT"
53 "
54 /* Force the operand into a register if it is not an
55 immediate whose use can be replaced with xzr.
56 If the mode is 16 bytes wide, then we will be doing
57 a stp in DI mode, so we check the validity of that.
58 If the mode is 8 bytes wide, then we will do doing a
59 normal str, so the check need not apply. */
60 if (GET_CODE (operands[0]) == MEM
61 && !(aarch64_simd_imm_zero (operands[1], <MODE>mode)
62 && ((known_eq (GET_MODE_SIZE (<MODE>mode), 16)
63 && aarch64_mem_pair_operand (operands[0], DImode))
64 || known_eq (GET_MODE_SIZE (<MODE>mode), 8))))
65 operands[1] = force_reg (<MODE>mode, operands[1]);
66
67 /* If a constant is too complex to force to memory (e.g. because it
68 contains CONST_POLY_INTs), build it up from individual elements instead.
69 We should only need to do this before RA; aarch64_legitimate_constant_p
70 should ensure that we don't try to rematerialize the constant later. */
71 if (GET_CODE (operands[1]) == CONST_VECTOR
72 && targetm.cannot_force_const_mem (<MODE>mode, operands[1]))
73 {
74 aarch64_expand_vector_init (operands[0], operands[1]);
75 DONE;
76 }
77 "
78 )
79
80 (define_expand "movmisalign<mode>"
81 [(set (match_operand:VALL_F16 0 "nonimmediate_operand")
82 (match_operand:VALL_F16 1 "general_operand"))]
83 "TARGET_FLOAT && !STRICT_ALIGNMENT"
84 {
85 /* This pattern is not permitted to fail during expansion: if both arguments
86 are non-registers (e.g. memory := constant, which can be created by the
87 auto-vectorizer), force operand 1 into a register. */
88 if (!register_operand (operands[0], <MODE>mode)
89 && !register_operand (operands[1], <MODE>mode))
90 operands[1] = force_reg (<MODE>mode, operands[1]);
91 })
92
93 (define_insn "aarch64_simd_dup<mode>"
94 [(set (match_operand:VDQ_I 0 "register_operand")
95 (vec_duplicate:VDQ_I
96 (match_operand:<VEL> 1 "register_operand")))]
97 "TARGET_SIMD"
98 {@ [ cons: =0 , 1 ; attrs: type ]
99 [ w , w ; neon_dup<q> ] dup\t%0.<Vtype>, %1.<Vetype>[0]
100 [ w , ?r ; neon_from_gp<q> ] dup\t%0.<Vtype>, %<vwcore>1
101 }
102 )
103
104 (define_insn "aarch64_simd_dup<mode>"
105 [(set (match_operand:VDQF_F16 0 "register_operand")
106 (vec_duplicate:VDQF_F16
107 (match_operand:<VEL> 1 "register_operand")))]
108 "TARGET_SIMD"
109 {@ [ cons: =0 , 1 ; attrs: type ]
110 [ w , w ; neon_dup<q> ] dup\t%0.<Vtype>, %1.<Vetype>[0]
111 [ w , r ; neon_from_gp<q> ] dup\t%0.<Vtype>, %<vwcore>1
112 }
113 )
114
115 (define_insn "@aarch64_dup_lane<mode>"
116 [(set (match_operand:VALL_F16 0 "register_operand" "=w")
117 (vec_duplicate:VALL_F16
118 (vec_select:<VEL>
119 (match_operand:VALL_F16 1 "register_operand" "w")
120 (parallel [(match_operand:SI 2 "immediate_operand" "i")])
121 )))]
122 "TARGET_SIMD"
123 {
124 operands[2] = aarch64_endian_lane_rtx (<MODE>mode, INTVAL (operands[2]));
125 return "dup\\t%0.<Vtype>, %1.<Vetype>[%2]";
126 }
127 [(set_attr "type" "neon_dup<q>")]
128 )
129
130 (define_insn "@aarch64_dup_lane_<vswap_width_name><mode>"
131 [(set (match_operand:VALL_F16_NO_V2Q 0 "register_operand" "=w")
132 (vec_duplicate:VALL_F16_NO_V2Q
133 (vec_select:<VEL>
134 (match_operand:<VSWAP_WIDTH> 1 "register_operand" "w")
135 (parallel [(match_operand:SI 2 "immediate_operand" "i")])
136 )))]
137 "TARGET_SIMD"
138 {
139 operands[2] = aarch64_endian_lane_rtx (<VSWAP_WIDTH>mode, INTVAL (operands[2]));
140 return "dup\\t%0.<Vtype>, %1.<Vetype>[%2]";
141 }
142 [(set_attr "type" "neon_dup<q>")]
143 )
144
145 (define_insn_and_split "*aarch64_simd_mov<VDMOV:mode>"
146 [(set (match_operand:VDMOV 0 "nonimmediate_operand")
147 (match_operand:VDMOV 1 "general_operand"))]
148 "TARGET_FLOAT
149 && (register_operand (operands[0], <MODE>mode)
150 || aarch64_simd_reg_or_zero (operands[1], <MODE>mode))"
151 {@ [cons: =0, 1; attrs: type, arch, length]
152 [w , m ; neon_load1_1reg<q> , * , *] ldr\t%d0, %1
153 [r , m ; load_8 , * , *] ldr\t%x0, %1
154 [m , Dz; store_8 , * , *] str\txzr, %0
155 [m , w ; neon_store1_1reg<q>, * , *] str\t%d1, %0
156 [m , r ; store_8 , * , *] str\t%x1, %0
157 [w , w ; neon_logic<q> , simd , *] mov\t%0.<Vbtype>, %1.<Vbtype>
158 [w , w ; neon_logic<q> , * , *] fmov\t%d0, %d1
159 [?r, w ; neon_to_gp<q> , base_simd, *] umov\t%0, %1.d[0]
160 [?r, w ; neon_to_gp<q> , * , *] fmov\t%x0, %d1
161 [?w, r ; f_mcr , * , *] fmov\t%d0, %1
162 [?r, r ; mov_reg , * , *] mov\t%0, %1
163 [w , Dn; neon_move<q> , simd , *] << aarch64_output_simd_mov_imm (operands[1], 64);
164 [w , Dz; f_mcr , * , *] fmov\t%d0, xzr
165 [w , Dx; neon_move , simd , 8] #
166 }
167 "CONST_INT_P (operands[1])
168 && aarch64_simd_special_constant_p (operands[1], <MODE>mode)
169 && FP_REGNUM_P (REGNO (operands[0]))"
170 [(const_int 0)]
171 {
172 aarch64_maybe_generate_simd_constant (operands[0], operands[1], <MODE>mode);
173 DONE;
174 }
175 )
176
177 (define_insn_and_split "*aarch64_simd_mov<VQMOV:mode>"
178 [(set (match_operand:VQMOV 0 "nonimmediate_operand")
179 (match_operand:VQMOV 1 "general_operand"))]
180 "TARGET_FLOAT
181 && (register_operand (operands[0], <MODE>mode)
182 || aarch64_simd_reg_or_zero (operands[1], <MODE>mode))"
183 {@ [cons: =0, 1; attrs: type, arch, length]
184 [w , m ; neon_load1_1reg<q> , * , 4] ldr\t%q0, %1
185 [Umn, Dz; store_16 , * , 4] stp\txzr, xzr, %0
186 [m , w ; neon_store1_1reg<q>, * , 4] str\t%q1, %0
187 [w , w ; neon_logic<q> , simd, 4] mov\t%0.<Vbtype>, %1.<Vbtype>
188 [w , w ; * , sve , 4] mov\t%Z0.d, %Z1.d
189 [?r , w ; multiple , * , 8] #
190 [?w , r ; multiple , * , 8] #
191 [?r , r ; multiple , * , 8] #
192 [w , Dn; neon_move<q> , simd, 4] << aarch64_output_simd_mov_imm (operands[1], 128);
193 [w , Dz; fmov , * , 4] fmov\t%d0, xzr
194 [w , Dx; neon_move , simd, 8] #
195 }
196 "&& reload_completed
197 && ((REG_P (operands[0])
198 && REG_P (operands[1])
199 && !(FP_REGNUM_P (REGNO (operands[0]))
200 && FP_REGNUM_P (REGNO (operands[1]))))
201 || (aarch64_simd_special_constant_p (operands[1], <MODE>mode)
202 && FP_REGNUM_P (REGNO (operands[0]))))"
203 [(const_int 0)]
204 {
205 if (GP_REGNUM_P (REGNO (operands[0]))
206 && GP_REGNUM_P (REGNO (operands[1])))
207 aarch64_simd_emit_reg_reg_move (operands, DImode, 2);
208 else
209 {
210 if (FP_REGNUM_P (REGNO (operands[0]))
211 && aarch64_maybe_generate_simd_constant (operands[0], operands[1],
212 <MODE>mode))
213 ;
214 else
215 aarch64_split_simd_move (operands[0], operands[1]);
216 }
217 DONE;
218 }
219 )
220
221 ;; When storing lane zero we can use the normal STR and its more permissive
222 ;; addressing modes.
223
224 (define_insn "aarch64_store_lane0<mode>"
225 [(set (match_operand:<VEL> 0 "memory_operand" "=m")
226 (vec_select:<VEL> (match_operand:VALL_F16 1 "register_operand" "w")
227 (parallel [(match_operand 2 "const_int_operand" "n")])))]
228 "TARGET_FLOAT
229 && ENDIAN_LANE_N (<nunits>, INTVAL (operands[2])) == 0"
230 "str\\t%<Vetype>1, %0"
231 [(set_attr "type" "neon_store1_1reg<q>")]
232 )
233
234 (define_insn "aarch64_simd_stp<mode>"
235 [(set (match_operand:VP_2E 0 "aarch64_mem_pair_lanes_operand")
236 (vec_duplicate:VP_2E (match_operand:<VEL> 1 "register_operand")))]
237 "TARGET_SIMD"
238 {@ [ cons: =0 , 1 ; attrs: type ]
239 [ Umn , w ; neon_stp ] stp\t%<Vetype>1, %<Vetype>1, %y0
240 [ Umn , r ; store_<ldpstp_vel_sz> ] stp\t%<vwcore>1, %<vwcore>1, %y0
241 }
242 )
243
244 (define_expand "@aarch64_split_simd_mov<mode>"
245 [(set (match_operand:VQMOV 0)
246 (match_operand:VQMOV 1))]
247 "TARGET_FLOAT"
248 {
249 rtx dst = operands[0];
250 rtx src = operands[1];
251
252 if (GP_REGNUM_P (REGNO (src)))
253 {
254 rtx src_low_part = gen_lowpart (<VHALF>mode, src);
255 rtx src_high_part = gen_highpart (<VHALF>mode, src);
256 rtx dst_low_part = gen_lowpart (<VHALF>mode, dst);
257
258 emit_move_insn (dst_low_part, src_low_part);
259 emit_insn (gen_aarch64_combine<Vhalf> (dst, dst_low_part,
260 src_high_part));
261 }
262 else
263 {
264 rtx dst_low_part = gen_lowpart (<VHALF>mode, dst);
265 rtx dst_high_part = gen_highpart (<VHALF>mode, dst);
266 rtx lo = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, false);
267 rtx hi = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
268 emit_insn (gen_aarch64_get_half<mode> (dst_low_part, src, lo));
269 emit_insn (gen_aarch64_get_half<mode> (dst_high_part, src, hi));
270 }
271 DONE;
272 }
273 )
274
275 (define_expand "aarch64_get_half<mode>"
276 [(set (match_operand:<VHALF> 0 "register_operand")
277 (vec_select:<VHALF>
278 (match_operand:VQMOV 1 "register_operand")
279 (match_operand 2 "ascending_int_parallel")))]
280 "TARGET_FLOAT"
281 {
282 if (vect_par_cnst_lo_half (operands[2], <MODE>mode))
283 {
284 emit_move_insn (operands[0], gen_lowpart (<VHALF>mode, operands[1]));
285 DONE;
286 }
287 }
288 )
289
290 (define_insn_and_split "aarch64_simd_mov_from_<mode>low"
291 [(set (match_operand:<VHALF> 0 "register_operand")
292 (vec_select:<VHALF>
293 (match_operand:VQMOV_NO2E 1 "register_operand")
294 (match_operand:VQMOV_NO2E 2 "vect_par_cnst_lo_half")))]
295 "TARGET_FLOAT"
296 {@ [ cons: =0 , 1 ; attrs: type , arch ]
297 [ w , w ; mov_reg , simd ] #
298 [ ?r , w ; neon_to_gp<q> , base_simd ] umov\t%0, %1.d[0]
299 [ ?r , w ; f_mrc , * ] fmov\t%0, %d1
300 }
301 "&& reload_completed && aarch64_simd_register (operands[0], <VHALF>mode)"
302 [(set (match_dup 0) (match_dup 1))]
303 {
304 operands[1] = aarch64_replace_reg_mode (operands[1], <VHALF>mode);
305 }
306 [(set_attr "length" "4")]
307 )
308
309 (define_insn "aarch64_simd_mov_from_<mode>high"
310 [(set (match_operand:<VHALF> 0 "register_operand")
311 (vec_select:<VHALF>
312 (match_operand:VQMOV_NO2E 1 "register_operand")
313 (match_operand:VQMOV_NO2E 2 "vect_par_cnst_hi_half")))]
314 "TARGET_FLOAT"
315 {@ [ cons: =0 , 1 ; attrs: type , arch ]
316 [ w , w ; neon_dup<q> , simd ] dup\t%d0, %1.d[1]
317 [ w , w ; * , sve ] ext\t%Z0.b, %Z0.b, %Z0.b, #8
318 [ ?r , w ; neon_to_gp<q> , simd ] umov\t%0, %1.d[1]
319 [ ?r , w ; f_mrc , * ] fmov\t%0, %1.d[1]
320 }
321 [(set_attr "length" "4")]
322 )
323
324 (define_insn "iorn<mode>3<vczle><vczbe>"
325 [(set (match_operand:VDQ_I 0 "register_operand" "=w")
326 (ior:VDQ_I (not:VDQ_I (match_operand:VDQ_I 2 "register_operand" "w"))
327 (match_operand:VDQ_I 1 "register_operand" "w")))]
328 "TARGET_SIMD"
329 "orn\t%0.<Vbtype>, %1.<Vbtype>, %2.<Vbtype>"
330 [(set_attr "type" "neon_logic<q>")]
331 )
332
333 (define_insn "andn<mode>3<vczle><vczbe>"
334 [(set (match_operand:VDQ_I 0 "register_operand" "=w")
335 (and:VDQ_I (not:VDQ_I (match_operand:VDQ_I 2 "register_operand" "w"))
336 (match_operand:VDQ_I 1 "register_operand" "w")))]
337 "TARGET_SIMD"
338 "bic\t%0.<Vbtype>, %1.<Vbtype>, %2.<Vbtype>"
339 [(set_attr "type" "neon_logic<q>")]
340 )
341
342 (define_insn "add<mode>3<vczle><vczbe>"
343 [(set (match_operand:VDQ_I 0 "register_operand" "=w")
344 (plus:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w")
345 (match_operand:VDQ_I 2 "register_operand" "w")))]
346 "TARGET_SIMD"
347 "add\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
348 [(set_attr "type" "neon_add<q>")]
349 )
350
351 (define_insn "sub<mode>3<vczle><vczbe>"
352 [(set (match_operand:VDQ_I 0 "register_operand" "=w")
353 (minus:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w")
354 (match_operand:VDQ_I 2 "register_operand" "w")))]
355 "TARGET_SIMD"
356 "sub\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
357 [(set_attr "type" "neon_sub<q>")]
358 )
359
360 (define_insn "mul<mode>3<vczle><vczbe>"
361 [(set (match_operand:VDQ_BHSI 0 "register_operand" "=w")
362 (mult:VDQ_BHSI (match_operand:VDQ_BHSI 1 "register_operand" "w")
363 (match_operand:VDQ_BHSI 2 "register_operand" "w")))]
364 "TARGET_SIMD"
365 "mul\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
366 [(set_attr "type" "neon_mul_<Vetype><q>")]
367 )
368
369 (define_insn "bswap<mode>2"
370 [(set (match_operand:VDQHSD 0 "register_operand" "=w")
371 (bswap:VDQHSD (match_operand:VDQHSD 1 "register_operand" "w")))]
372 "TARGET_SIMD"
373 "rev<Vrevsuff>\\t%0.<Vbtype>, %1.<Vbtype>"
374 [(set_attr "type" "neon_rev<q>")]
375 )
376
377 (define_insn "aarch64_rbit<mode><vczle><vczbe>"
378 [(set (match_operand:VB 0 "register_operand" "=w")
379 (bitreverse:VB (match_operand:VB 1 "register_operand" "w")))]
380 "TARGET_SIMD"
381 "rbit\\t%0.<Vbtype>, %1.<Vbtype>"
382 [(set_attr "type" "neon_rbit")]
383 )
384
385 (define_expand "ctz<mode>2"
386 [(set (match_operand:VS 0 "register_operand")
387 (ctz:VS (match_operand:VS 1 "register_operand")))]
388 "TARGET_SIMD"
389 {
390 emit_insn (gen_bswap<mode>2 (operands[0], operands[1]));
391 rtx op0_castsi2qi = force_subreg (<VS:VSI2QI>mode, operands[0],
392 <MODE>mode, 0);
393 emit_insn (gen_aarch64_rbit<VS:vsi2qi> (op0_castsi2qi, op0_castsi2qi));
394 emit_insn (gen_clz<mode>2 (operands[0], operands[0]));
395 DONE;
396 }
397 )
398
399 (define_expand "@xorsign<mode>3"
400 [(match_operand:VHSDF 0 "register_operand")
401 (match_operand:VHSDF 1 "register_operand")
402 (match_operand:VHSDF 2 "register_operand")]
403 "TARGET_SIMD"
404 {
405
406 machine_mode imode = <V_INT_EQUIV>mode;
407 rtx v_bitmask = gen_reg_rtx (imode);
408 rtx op1x = gen_reg_rtx (imode);
409 rtx op2x = gen_reg_rtx (imode);
410
411 rtx arg1 = lowpart_subreg (imode, operands[1], <MODE>mode);
412 rtx arg2 = lowpart_subreg (imode, operands[2], <MODE>mode);
413
414 int bits = GET_MODE_UNIT_BITSIZE (<MODE>mode) - 1;
415
416 emit_move_insn (v_bitmask,
417 aarch64_simd_gen_const_vector_dup (<V_INT_EQUIV>mode,
418 HOST_WIDE_INT_M1U << bits));
419
420 emit_insn (gen_and<v_int_equiv>3 (op2x, v_bitmask, arg2));
421 emit_insn (gen_xor<v_int_equiv>3 (op1x, arg1, op2x));
422 emit_move_insn (operands[0],
423 lowpart_subreg (<MODE>mode, op1x, imode));
424 DONE;
425 }
426 )
427
428 ;; The fcadd and fcmla patterns are made UNSPEC for the explicitly due to the
429 ;; fact that their usage need to guarantee that the source vectors are
430 ;; contiguous. It would be wrong to describe the operation without being able
431 ;; to describe the permute that is also required, but even if that is done
432 ;; the permute would have been created as a LOAD_LANES which means the values
433 ;; in the registers are in the wrong order.
434 (define_insn "aarch64_fcadd<rot><mode><vczle><vczbe>"
435 [(set (match_operand:VHSDF 0 "register_operand" "=w")
436 (unspec:VHSDF [(match_operand:VHSDF 1 "register_operand" "w")
437 (match_operand:VHSDF 2 "register_operand" "w")]
438 FCADD))]
439 "TARGET_COMPLEX"
440 "fcadd\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>, #<rot>"
441 [(set_attr "type" "neon_fcadd")]
442 )
443
444 (define_expand "cadd<rot><mode>3"
445 [(set (match_operand:VHSDF 0 "register_operand")
446 (unspec:VHSDF [(match_operand:VHSDF 1 "register_operand")
447 (match_operand:VHSDF 2 "register_operand")]
448 FCADD))]
449 "TARGET_COMPLEX && !BYTES_BIG_ENDIAN"
450 )
451
452 (define_insn "aarch64_fcmla<rot><mode><vczle><vczbe>"
453 [(set (match_operand:VHSDF 0 "register_operand" "=w")
454 (plus:VHSDF (unspec:VHSDF [(match_operand:VHSDF 2 "register_operand" "w")
455 (match_operand:VHSDF 3 "register_operand" "w")]
456 FCMLA)
457 (match_operand:VHSDF 1 "register_operand" "0")))]
458 "TARGET_COMPLEX"
459 "fcmla\t%0.<Vtype>, %2.<Vtype>, %3.<Vtype>, #<rot>"
460 [(set_attr "type" "neon_fcmla")]
461 )
462
463
464 (define_insn "aarch64_fcmla_lane<rot><mode><vczle><vczbe>"
465 [(set (match_operand:VHSDF 0 "register_operand" "=w")
466 (plus:VHSDF (unspec:VHSDF [(match_operand:VHSDF 2 "register_operand" "w")
467 (match_operand:VHSDF 3 "register_operand" "w")
468 (match_operand:SI 4 "const_int_operand" "n")]
469 FCMLA)
470 (match_operand:VHSDF 1 "register_operand" "0")))]
471 "TARGET_COMPLEX"
472 {
473 operands[4] = aarch64_endian_lane_rtx (<VHALF>mode, INTVAL (operands[4]));
474 return "fcmla\t%0.<Vtype>, %2.<Vtype>, %3.<FCMLA_maybe_lane>, #<rot>";
475 }
476 [(set_attr "type" "neon_fcmla")]
477 )
478
479 (define_insn "aarch64_fcmla_laneq<rot>v4hf<vczle><vczbe>"
480 [(set (match_operand:V4HF 0 "register_operand" "=w")
481 (plus:V4HF (unspec:V4HF [(match_operand:V4HF 2 "register_operand" "w")
482 (match_operand:V8HF 3 "register_operand" "w")
483 (match_operand:SI 4 "const_int_operand" "n")]
484 FCMLA)
485 (match_operand:V4HF 1 "register_operand" "0")))]
486 "TARGET_COMPLEX"
487 {
488 operands[4] = aarch64_endian_lane_rtx (V4HFmode, INTVAL (operands[4]));
489 return "fcmla\t%0.4h, %2.4h, %3.h[%4], #<rot>";
490 }
491 [(set_attr "type" "neon_fcmla")]
492 )
493
494 (define_insn "aarch64_fcmlaq_lane<rot><mode>"
495 [(set (match_operand:VQ_HSF 0 "register_operand" "=w")
496 (plus:VQ_HSF (unspec:VQ_HSF [(match_operand:VQ_HSF 2 "register_operand" "w")
497 (match_operand:<VHALF> 3 "register_operand" "w")
498 (match_operand:SI 4 "const_int_operand" "n")]
499 FCMLA)
500 (match_operand:VQ_HSF 1 "register_operand" "0")))]
501 "TARGET_COMPLEX"
502 {
503 int nunits = GET_MODE_NUNITS (<VHALF>mode).to_constant ();
504 operands[4]
505 = gen_int_mode (ENDIAN_LANE_N (nunits / 2, INTVAL (operands[4])), SImode);
506 return "fcmla\t%0.<Vtype>, %2.<Vtype>, %3.<FCMLA_maybe_lane>, #<rot>";
507 }
508 [(set_attr "type" "neon_fcmla")]
509 )
510
511 ;; The complex mla/mls operations always need to expand to two instructions.
512 ;; The first operation does half the computation and the second does the
513 ;; remainder. Because of this, expand early.
514 (define_expand "cml<fcmac1><conj_op><mode>4"
515 [(set (match_operand:VHSDF 0 "register_operand")
516 (plus:VHSDF (unspec:VHSDF [(match_operand:VHSDF 1 "register_operand")
517 (match_operand:VHSDF 2 "register_operand")]
518 FCMLA_OP)
519 (match_operand:VHSDF 3 "register_operand")))]
520 "TARGET_COMPLEX && !BYTES_BIG_ENDIAN"
521 {
522 rtx tmp = gen_reg_rtx (<MODE>mode);
523 emit_insn (gen_aarch64_fcmla<rotsplit1><mode> (tmp, operands[3],
524 operands[2], operands[1]));
525 emit_insn (gen_aarch64_fcmla<rotsplit2><mode> (operands[0], tmp,
526 operands[2], operands[1]));
527 DONE;
528 })
529
530 ;; The complex mul operations always need to expand to two instructions.
531 ;; The first operation does half the computation and the second does the
532 ;; remainder. Because of this, expand early.
533 (define_expand "cmul<conj_op><mode>3"
534 [(set (match_operand:VHSDF 0 "register_operand")
535 (unspec:VHSDF [(match_operand:VHSDF 1 "register_operand")
536 (match_operand:VHSDF 2 "register_operand")]
537 FCMUL_OP))]
538 "TARGET_COMPLEX && !BYTES_BIG_ENDIAN"
539 {
540 rtx tmp = force_reg (<MODE>mode, CONST0_RTX (<MODE>mode));
541 rtx res1 = gen_reg_rtx (<MODE>mode);
542 emit_insn (gen_aarch64_fcmla<rotsplit1><mode> (res1, tmp,
543 operands[2], operands[1]));
544 emit_insn (gen_aarch64_fcmla<rotsplit2><mode> (operands[0], res1,
545 operands[2], operands[1]));
546 DONE;
547 })
548
549 ;; These expands map to the Dot Product optab the vectorizer checks for
550 ;; and to the intrinsics patttern.
551 ;; The auto-vectorizer expects a dot product builtin that also does an
552 ;; accumulation into the provided register.
553 ;; Given the following pattern
554 ;;
555 ;; for (i=0; i<len; i++) {
556 ;; c = a[i] * b[i];
557 ;; r += c;
558 ;; }
559 ;; return result;
560 ;;
561 ;; This can be auto-vectorized to
562 ;; r = a[0]*b[0] + a[1]*b[1] + a[2]*b[2] + a[3]*b[3];
563 ;;
564 ;; given enough iterations. However the vectorizer can keep unrolling the loop
565 ;; r += a[4]*b[4] + a[5]*b[5] + a[6]*b[6] + a[7]*b[7];
566 ;; r += a[8]*b[8] + a[9]*b[9] + a[10]*b[10] + a[11]*b[11];
567 ;; ...
568 ;;
569 ;; and so the vectorizer provides r, in which the result has to be accumulated.
570 (define_insn "<sur>dot_prod<mode><vsi2qi><vczle><vczbe>"
571 [(set (match_operand:VS 0 "register_operand" "=w")
572 (plus:VS
573 (unspec:VS [(match_operand:<VSI2QI> 1 "register_operand" "w")
574 (match_operand:<VSI2QI> 2 "register_operand" "w")]
575 DOTPROD)
576 (match_operand:VS 3 "register_operand" "0")))]
577 "TARGET_DOTPROD"
578 "<sur>dot\\t%0.<Vtype>, %1.<Vdottype>, %2.<Vdottype>"
579 [(set_attr "type" "neon_dot<q>")]
580 )
581
582 ;; These instructions map to the __builtins for the Armv8.6-a I8MM usdot
583 ;; (vector) Dot Product operation and the vectorized optab.
584 (define_insn "usdot_prod<mode><vsi2qi><vczle><vczbe>"
585 [(set (match_operand:VS 0 "register_operand" "=w")
586 (plus:VS
587 (unspec:VS [(match_operand:<VSI2QI> 1 "register_operand" "w")
588 (match_operand:<VSI2QI> 2 "register_operand" "w")]
589 UNSPEC_USDOT)
590 (match_operand:VS 3 "register_operand" "0")))]
591 "TARGET_I8MM"
592 "usdot\\t%0.<Vtype>, %1.<Vdottype>, %2.<Vdottype>"
593 [(set_attr "type" "neon_dot<q>")]
594 )
595
596 ;; These instructions map to the __builtins for the Dot Product
597 ;; indexed operations.
598 (define_insn "aarch64_<sur>dot_lane<vsi2qi><vczle><vczbe>"
599 [(set (match_operand:VS 0 "register_operand" "=w")
600 (plus:VS
601 (unspec:VS [(match_operand:<VSI2QI> 2 "register_operand" "w")
602 (match_operand:V8QI 3 "register_operand" "<h_con>")
603 (match_operand:SI 4 "immediate_operand" "i")]
604 DOTPROD)
605 (match_operand:VS 1 "register_operand" "0")))]
606 "TARGET_DOTPROD"
607 {
608 operands[4] = aarch64_endian_lane_rtx (V8QImode, INTVAL (operands[4]));
609 return "<sur>dot\\t%0.<Vtype>, %2.<Vdottype>, %3.4b[%4]";
610 }
611 [(set_attr "type" "neon_dot<q>")]
612 )
613
614 (define_insn "aarch64_<sur>dot_laneq<vsi2qi><vczle><vczbe>"
615 [(set (match_operand:VS 0 "register_operand" "=w")
616 (plus:VS
617 (unspec:VS [(match_operand:<VSI2QI> 2 "register_operand" "w")
618 (match_operand:V16QI 3 "register_operand" "<h_con>")
619 (match_operand:SI 4 "immediate_operand" "i")]
620 DOTPROD)
621 (match_operand:VS 1 "register_operand" "0")))]
622 "TARGET_DOTPROD"
623 {
624 operands[4] = aarch64_endian_lane_rtx (V16QImode, INTVAL (operands[4]));
625 return "<sur>dot\\t%0.<Vtype>, %2.<Vdottype>, %3.4b[%4]";
626 }
627 [(set_attr "type" "neon_dot<q>")]
628 )
629
630 ;; These instructions map to the __builtins for the armv8.6a I8MM usdot, sudot
631 ;; (by element) Dot Product operations.
632 (define_insn "aarch64_<DOTPROD_I8MM:sur>dot_lane<VB:isquadop><VS:vsi2qi><vczle><vczbe>"
633 [(set (match_operand:VS 0 "register_operand" "=w")
634 (plus:VS
635 (unspec:VS [(match_operand:<VS:VSI2QI> 2 "register_operand" "w")
636 (match_operand:VB 3 "register_operand" "w")
637 (match_operand:SI 4 "immediate_operand" "i")]
638 DOTPROD_I8MM)
639 (match_operand:VS 1 "register_operand" "0")))]
640 "TARGET_I8MM"
641 {
642 int nunits = GET_MODE_NUNITS (<VB:MODE>mode).to_constant ();
643 int lane = INTVAL (operands[4]);
644 operands[4] = gen_int_mode (ENDIAN_LANE_N (nunits / 4, lane), SImode);
645 return "<DOTPROD_I8MM:sur>dot\\t%0.<VS:Vtype>, %2.<VS:Vdottype>, %3.4b[%4]";
646 }
647 [(set_attr "type" "neon_dot<VS:q>")]
648 )
649
650 (define_expand "copysign<mode>3"
651 [(match_operand:VHSDF 0 "register_operand")
652 (match_operand:VHSDF 1 "register_operand")
653 (match_operand:VHSDF 2 "nonmemory_operand")]
654 "TARGET_SIMD"
655 {
656 machine_mode int_mode = <V_INT_EQUIV>mode;
657 rtx v_bitmask = gen_reg_rtx (int_mode);
658 int bits = GET_MODE_UNIT_BITSIZE (<MODE>mode) - 1;
659
660 emit_move_insn (v_bitmask,
661 aarch64_simd_gen_const_vector_dup (<V_INT_EQUIV>mode,
662 HOST_WIDE_INT_M1U << bits));
663
664 /* copysign (x, -1) should instead be expanded as orr with the sign
665 bit. */
666 if (!REG_P (operands[2]))
667 {
668 rtx op2_elt = unwrap_const_vec_duplicate (operands[2]);
669 if (GET_CODE (op2_elt) == CONST_DOUBLE
670 && real_isneg (CONST_DOUBLE_REAL_VALUE (op2_elt)))
671 {
672 emit_insn (gen_ior<v_int_equiv>3 (
673 lowpart_subreg (int_mode, operands[0], <MODE>mode),
674 lowpart_subreg (int_mode, operands[1], <MODE>mode), v_bitmask));
675 DONE;
676 }
677 }
678
679 operands[2] = force_reg (<MODE>mode, operands[2]);
680 emit_insn (gen_aarch64_simd_bsl<mode> (operands[0], v_bitmask,
681 operands[2], operands[1]));
682 DONE;
683 }
684 )
685
686 (define_insn "mul_lane<mode>3"
687 [(set (match_operand:VMULD 0 "register_operand" "=w")
688 (mult:VMULD
689 (vec_duplicate:VMULD
690 (vec_select:<VEL>
691 (match_operand:<VCOND> 2 "register_operand" "<h_con>")
692 (parallel [(match_operand:SI 3 "immediate_operand" "i")])))
693 (match_operand:VMULD 1 "register_operand" "w")))]
694 "TARGET_SIMD"
695 {
696 operands[3] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[3]));
697 return "<f>mul\\t%0.<Vtype>, %1.<Vtype>, %2.<Vetype>[%3]";
698 }
699 [(set_attr "type" "neon<fp>_mul_<stype>_scalar<q>")]
700 )
701
702 (define_insn "mul_laneq<mode>3"
703 [(set (match_operand:VMUL 0 "register_operand" "=w")
704 (mult:VMUL
705 (vec_duplicate:VMUL
706 (vec_select:<VEL>
707 (match_operand:<VCONQ> 2 "register_operand" "<h_con>")
708 (parallel [(match_operand:SI 3 "immediate_operand")])))
709 (match_operand:VMUL 1 "register_operand" "w")))]
710 "TARGET_SIMD"
711 {
712 operands[3] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[3]));
713 return "<f>mul\\t%0.<Vtype>, %1.<Vtype>, %2.<Vetype>[%3]";
714 }
715 [(set_attr "type" "neon<fp>_mul_<stype>_scalar<q>")]
716 )
717
718 (define_insn "mul_n<mode>3"
719 [(set (match_operand:VMUL 0 "register_operand" "=w")
720 (mult:VMUL
721 (vec_duplicate:VMUL
722 (match_operand:<VEL> 2 "register_operand" "<h_con>"))
723 (match_operand:VMUL 1 "register_operand" "w")))]
724 "TARGET_SIMD"
725 "<f>mul\t%0.<Vtype>, %1.<Vtype>, %2.<Vetype>[0]";
726 [(set_attr "type" "neon<fp>_mul_<stype>_scalar<q>")]
727 )
728
729 (define_insn "@aarch64_rsqrte<mode>"
730 [(set (match_operand:VHSDF_HSDF 0 "register_operand" "=w")
731 (unspec:VHSDF_HSDF [(match_operand:VHSDF_HSDF 1 "register_operand" "w")]
732 UNSPEC_RSQRTE))]
733 "TARGET_SIMD"
734 "frsqrte\\t%<v>0<Vmtype>, %<v>1<Vmtype>"
735 [(set_attr "type" "neon_fp_rsqrte_<stype><q>")])
736
737 (define_insn "@aarch64_rsqrts<mode>"
738 [(set (match_operand:VHSDF_HSDF 0 "register_operand" "=w")
739 (unspec:VHSDF_HSDF [(match_operand:VHSDF_HSDF 1 "register_operand" "w")
740 (match_operand:VHSDF_HSDF 2 "register_operand" "w")]
741 UNSPEC_RSQRTS))]
742 "TARGET_SIMD"
743 "frsqrts\\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>2<Vmtype>"
744 [(set_attr "type" "neon_fp_rsqrts_<stype><q>")])
745
746 (define_expand "rsqrt<mode>2"
747 [(set (match_operand:VALLF 0 "register_operand")
748 (unspec:VALLF [(match_operand:VALLF 1 "register_operand")]
749 UNSPEC_RSQRT))]
750 "TARGET_SIMD"
751 {
752 aarch64_emit_approx_sqrt (operands[0], operands[1], true);
753 DONE;
754 })
755
756 (define_insn "aarch64_ursqrte<mode>"
757 [(set (match_operand:VDQ_SI 0 "register_operand" "=w")
758 (unspec:VDQ_SI [(match_operand:VDQ_SI 1 "register_operand" "w")]
759 UNSPEC_RSQRTE))]
760 "TARGET_SIMD"
761 "ursqrte\\t%<v>0<Vmtype>, %<v>1<Vmtype>"
762 [(set_attr "type" "neon_fp_rsqrte_<stype><q>")])
763
764 (define_insn "*aarch64_mul3_elt_to_64v2df"
765 [(set (match_operand:DF 0 "register_operand" "=w")
766 (mult:DF
767 (vec_select:DF
768 (match_operand:V2DF 1 "register_operand" "w")
769 (parallel [(match_operand:SI 2 "immediate_operand")]))
770 (match_operand:DF 3 "register_operand" "w")))]
771 "TARGET_SIMD"
772 {
773 operands[2] = aarch64_endian_lane_rtx (V2DFmode, INTVAL (operands[2]));
774 return "fmul\\t%0.2d, %3.2d, %1.d[%2]";
775 }
776 [(set_attr "type" "neon_fp_mul_d_scalar_q")]
777 )
778
779 (define_insn "neg<mode>2<vczle><vczbe>"
780 [(set (match_operand:VDQ_I 0 "register_operand" "=w")
781 (neg:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w")))]
782 "TARGET_SIMD"
783 "neg\t%0.<Vtype>, %1.<Vtype>"
784 [(set_attr "type" "neon_neg<q>")]
785 )
786
787 (define_insn "abs<mode>2<vczle><vczbe>"
788 [(set (match_operand:VDQ_I 0 "register_operand" "=w")
789 (abs:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w")))]
790 "TARGET_SIMD"
791 "abs\t%0.<Vtype>, %1.<Vtype>"
792 [(set_attr "type" "neon_abs<q>")]
793 )
794
795 ;; The intrinsic version of integer ABS must not be allowed to
796 ;; combine with any operation with an integrated ABS step, such
797 ;; as SABD.
798 (define_insn "aarch64_abs<mode><vczle><vczbe>"
799 [(set (match_operand:VSDQ_I_DI 0 "register_operand" "=w")
800 (unspec:VSDQ_I_DI
801 [(match_operand:VSDQ_I_DI 1 "register_operand" "w")]
802 UNSPEC_ABS))]
803 "TARGET_SIMD"
804 "abs\t%<v>0<Vmtype>, %<v>1<Vmtype>"
805 [(set_attr "type" "neon_abs<q>")]
806 )
807
808 ;; It's tempting to represent SABD as ABS (MINUS op1 op2).
809 ;; This isn't accurate as ABS treats always its input as a signed value.
810 ;; So (ABS:QI (minus:QI 64 -128)) == (ABS:QI (192 or -64 signed)) == 64.
811 ;; Whereas SABD would return 192 (-64 signed) on the above example.
812 ;; Use MINUS ([us]max (op1, op2), [us]min (op1, op2)) instead.
813 (define_insn "aarch64_<su>abd<mode><vczle><vczbe>"
814 [(set (match_operand:VDQ_BHSI 0 "register_operand" "=w")
815 (minus:VDQ_BHSI
816 (USMAX:VDQ_BHSI
817 (match_operand:VDQ_BHSI 1 "register_operand" "w")
818 (match_operand:VDQ_BHSI 2 "register_operand" "w"))
819 (<max_opp>:VDQ_BHSI
820 (match_dup 1)
821 (match_dup 2))))]
822 "TARGET_SIMD"
823 "<su>abd\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
824 [(set_attr "type" "neon_abd<q>")]
825 )
826
827 (define_expand "<su>abd<mode>3"
828 [(match_operand:VDQ_BHSI 0 "register_operand")
829 (USMAX:VDQ_BHSI
830 (match_operand:VDQ_BHSI 1 "register_operand")
831 (match_operand:VDQ_BHSI 2 "register_operand"))]
832 "TARGET_SIMD"
833 {
834 emit_insn (gen_aarch64_<su>abd<mode> (operands[0], operands[1], operands[2]));
835 DONE;
836 }
837 )
838
839 (define_insn "aarch64_<su>abdl<mode>"
840 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
841 (zero_extend:<VWIDE>
842 (minus:VD_BHSI
843 (USMAX:VD_BHSI
844 (match_operand:VD_BHSI 1 "register_operand" "w")
845 (match_operand:VD_BHSI 2 "register_operand" "w"))
846 (<max_opp>:VD_BHSI
847 (match_dup 1)
848 (match_dup 2)))))]
849 "TARGET_SIMD"
850 "<su>abdl\t%0.<Vwtype>, %1.<Vtype>, %2.<Vtype>"
851 [(set_attr "type" "neon_abd<q>")]
852 )
853
854 (define_insn "aarch64_<su>abdl2<mode>_insn"
855 [(set (match_operand:<VDBLW> 0 "register_operand" "=w")
856 (zero_extend:<VDBLW>
857 (minus:<VHALF>
858 (USMAX:<VHALF>
859 (vec_select:<VHALF>
860 (match_operand:VQW 1 "register_operand" "w")
861 (match_operand:VQW 3 "vect_par_cnst_hi_half" ""))
862 (vec_select:<VHALF>
863 (match_operand:VQW 2 "register_operand" "w")
864 (match_dup 3)))
865 (<max_opp>:<VHALF>
866 (vec_select:<VHALF>
867 (match_dup 1)
868 (match_dup 3))
869 (vec_select:<VHALF>
870 (match_dup 2)
871 (match_dup 3))))))]
872
873 "TARGET_SIMD"
874 "<su>abdl2\t%0.<Vwtype>, %1.<Vtype>, %2.<Vtype>"
875 [(set_attr "type" "neon_abd<q>")]
876 )
877
878 (define_expand "aarch64_<su>abdl2<mode>"
879 [(match_operand:<VDBLW> 0 "register_operand")
880 (USMAX:VQW
881 (match_operand:VQW 1 "register_operand")
882 (match_operand:VQW 2 "register_operand"))]
883 "TARGET_SIMD"
884 {
885 rtx hi = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
886 emit_insn (gen_aarch64_<su>abdl2<mode>_insn (operands[0], operands[1],
887 operands[2], hi));
888 DONE;
889 }
890 )
891
892 (define_insn "aarch64_<su>abdl<mode>_hi_internal"
893 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
894 (abs:<VWIDE>
895 (minus:<VWIDE>
896 (ANY_EXTEND:<VWIDE>
897 (vec_select:<VHALF>
898 (match_operand:VQW 1 "register_operand" "w")
899 (match_operand:VQW 3 "vect_par_cnst_hi_half" "")))
900 (ANY_EXTEND:<VWIDE>
901 (vec_select:<VHALF>
902 (match_operand:VQW 2 "register_operand" "w")
903 (match_dup 3))))))]
904 "TARGET_SIMD"
905 "<su>abdl2\t%0.<Vwtype>, %1.<Vtype>, %2.<Vtype>"
906 [(set_attr "type" "neon_abd_long")]
907 )
908
909 (define_insn "aarch64_<su>abdl<mode>_lo_internal"
910 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
911 (abs:<VWIDE>
912 (minus:<VWIDE>
913 (ANY_EXTEND:<VWIDE>
914 (vec_select:<VHALF>
915 (match_operand:VQW 1 "register_operand" "w")
916 (match_operand:VQW 3 "vect_par_cnst_lo_half" "")))
917 (ANY_EXTEND:<VWIDE>
918 (vec_select:<VHALF>
919 (match_operand:VQW 2 "register_operand" "w")
920 (match_dup 3))))))]
921 "TARGET_SIMD"
922 "<su>abdl\t%0.<Vwtype>, %1.<Vhalftype>, %2.<Vhalftype>"
923 [(set_attr "type" "neon_abd_long")]
924 )
925
926 (define_expand "vec_widen_<su>abd_hi_<mode>"
927 [(match_operand:<VWIDE> 0 "register_operand")
928 (ANY_EXTEND:<VWIDE> (match_operand:VQW 1 "register_operand"))
929 (ANY_EXTEND:<VWIDE> (match_operand:VQW 2 "register_operand"))]
930 "TARGET_SIMD"
931 {
932 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
933 emit_insn (gen_aarch64_<su>abdl<mode>_hi_internal (operands[0], operands[1],
934 operands[2], p));
935 DONE;
936 }
937 )
938
939 (define_expand "vec_widen_<su>abd_lo_<mode>"
940 [(match_operand:<VWIDE> 0 "register_operand")
941 (ANY_EXTEND:<VWIDE> (match_operand:VQW 1 "register_operand"))
942 (ANY_EXTEND:<VWIDE> (match_operand:VQW 2 "register_operand"))]
943 "TARGET_SIMD"
944 {
945 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, false);
946 emit_insn (gen_aarch64_<su>abdl<mode>_lo_internal (operands[0], operands[1],
947 operands[2], p));
948 DONE;
949 }
950 )
951
952 (define_insn "aarch64_<su>abal<mode>"
953 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
954 (plus:<VWIDE>
955 (zero_extend:<VWIDE>
956 (minus:VD_BHSI
957 (USMAX:VD_BHSI
958 (match_operand:VD_BHSI 2 "register_operand" "w")
959 (match_operand:VD_BHSI 3 "register_operand" "w"))
960 (<max_opp>:VD_BHSI
961 (match_dup 2)
962 (match_dup 3))))
963 (match_operand:<VWIDE> 1 "register_operand" "0")))]
964 "TARGET_SIMD"
965 "<su>abal\t%0.<Vwtype>, %2.<Vtype>, %3.<Vtype>"
966 [(set_attr "type" "neon_arith_acc<q>")]
967 )
968
969 (define_insn "aarch64_<su>abal2<mode>_insn"
970 [(set (match_operand:<VDBLW> 0 "register_operand" "=w")
971 (plus:<VDBLW>
972 (zero_extend:<VDBLW>
973 (minus:<VHALF>
974 (USMAX:<VHALF>
975 (vec_select:<VHALF>
976 (match_operand:VQW 2 "register_operand" "w")
977 (match_operand:VQW 4 "vect_par_cnst_hi_half" ""))
978 (vec_select:<VHALF>
979 (match_operand:VQW 3 "register_operand" "w")
980 (match_dup 4)))
981 (<max_opp>:<VHALF>
982 (vec_select:<VHALF>
983 (match_dup 2)
984 (match_dup 4))
985 (vec_select:<VHALF>
986 (match_dup 3)
987 (match_dup 4)))))
988 (match_operand:<VDBLW> 1 "register_operand" "0")))]
989 "TARGET_SIMD"
990 "<su>abal2\t%0.<Vwtype>, %2.<Vtype>, %3.<Vtype>"
991 [(set_attr "type" "neon_arith_acc<q>")]
992 )
993
994 (define_expand "aarch64_<su>abal2<mode>"
995 [(match_operand:<VDBLW> 0 "register_operand")
996 (match_operand:<VDBLW> 1 "register_operand")
997 (USMAX:VQW
998 (match_operand:VQW 2 "register_operand")
999 (match_operand:VQW 3 "register_operand"))]
1000 "TARGET_SIMD"
1001 {
1002 rtx hi = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
1003 emit_insn (gen_aarch64_<su>abal2<mode>_insn (operands[0], operands[1],
1004 operands[2], operands[3], hi));
1005 DONE;
1006 }
1007 )
1008
1009 (define_expand "aarch64_<su>adalp<mode>"
1010 [(set (match_operand:<VDBLW> 0 "register_operand")
1011 (plus:<VDBLW>
1012 (plus:<VDBLW>
1013 (vec_select:<VDBLW>
1014 (ANY_EXTEND:<V2XWIDE>
1015 (match_operand:VDQV_L 2 "register_operand"))
1016 (match_dup 3))
1017 (vec_select:<VDBLW> (ANY_EXTEND:<V2XWIDE> (match_dup 2))
1018 (match_dup 4)))
1019 (match_operand:<VDBLW> 1 "register_operand")))]
1020 "TARGET_SIMD"
1021 {
1022 int nunits = GET_MODE_NUNITS (<MODE>mode).to_constant () / 2;
1023 operands[3] = aarch64_gen_stepped_int_parallel (nunits, 0, 2);
1024 operands[4] = aarch64_gen_stepped_int_parallel (nunits, 1, 2);
1025 }
1026 )
1027
1028 (define_insn "*aarch64_<su>adalp<mode><vczle><vczbe>_insn"
1029 [(set (match_operand:<VDBLW> 0 "register_operand" "=w")
1030 (plus:<VDBLW>
1031 (plus:<VDBLW>
1032 (vec_select:<VDBLW>
1033 (ANY_EXTEND:<V2XWIDE>
1034 (match_operand:VDQV_L 2 "register_operand" "w"))
1035 (match_operand:<V2XWIDE> 3 "vect_par_cnst_even_or_odd_half" ""))
1036 (vec_select:<VDBLW> (ANY_EXTEND:<V2XWIDE> (match_dup 2))
1037 (match_operand:<V2XWIDE> 4 "vect_par_cnst_even_or_odd_half" "")))
1038 (match_operand:<VDBLW> 1 "register_operand" "0")))]
1039 "TARGET_SIMD
1040 && !rtx_equal_p (operands[3], operands[4])"
1041 "<su>adalp\t%0.<Vwhalf>, %2.<Vtype>"
1042 [(set_attr "type" "neon_reduc_add<q>")]
1043 )
1044
1045 ;; Emit a sequence to produce a sum-of-absolute-differences of the V16QI
1046 ;; inputs in operands 1 and 2. The sequence also has to perform a widening
1047 ;; reduction of the difference into a V4SI vector and accumulate that into
1048 ;; operand 3 before copying that into the result operand 0.
1049 ;; Perform that with a sequence of:
1050 ;; UABDL2 tmp.8h, op1.16b, op2.16b
1051 ;; UABAL tmp.8h, op1.8b, op2.8b
1052 ;; UADALP op3.4s, tmp.8h
1053 ;; MOV op0, op3 // should be eliminated in later passes.
1054 ;;
1055 ;; For TARGET_DOTPROD we do:
1056 ;; MOV tmp1.16b, #1 // Can be CSE'd and hoisted out of loops.
1057 ;; UABD tmp2.16b, op1.16b, op2.16b
1058 ;; UDOT op3.4s, tmp2.16b, tmp1.16b
1059 ;; MOV op0, op3 // RA will tie the operands of UDOT appropriately.
1060 ;;
1061 ;; The signed version just uses the signed variants of the above instructions
1062 ;; but for TARGET_DOTPROD still emits a UDOT as the absolute difference is
1063 ;; unsigned.
1064
1065 (define_expand "<su>sadv16qi"
1066 [(use (match_operand:V4SI 0 "register_operand"))
1067 (USMAX:V16QI (match_operand:V16QI 1 "register_operand")
1068 (match_operand:V16QI 2 "register_operand"))
1069 (use (match_operand:V4SI 3 "register_operand"))]
1070 "TARGET_SIMD"
1071 {
1072 if (TARGET_DOTPROD)
1073 {
1074 rtx ones = force_reg (V16QImode, CONST1_RTX (V16QImode));
1075 rtx abd = gen_reg_rtx (V16QImode);
1076 emit_insn (gen_aarch64_<su>abdv16qi (abd, operands[1], operands[2]));
1077 emit_insn (gen_udot_prodv4siv16qi (operands[0], abd, ones,
1078 operands[3]));
1079 DONE;
1080 }
1081 rtx reduc = gen_reg_rtx (V8HImode);
1082 emit_insn (gen_aarch64_<su>abdl2v16qi (reduc, operands[1],
1083 operands[2]));
1084 emit_insn (gen_aarch64_<su>abalv8qi (reduc, reduc,
1085 gen_lowpart (V8QImode, operands[1]),
1086 gen_lowpart (V8QImode,
1087 operands[2])));
1088 emit_insn (gen_aarch64_<su>adalpv8hi (operands[3], operands[3], reduc));
1089 emit_move_insn (operands[0], operands[3]);
1090 DONE;
1091 }
1092 )
1093
1094 (define_insn "aarch64_<su>aba<mode><vczle><vczbe>"
1095 [(set (match_operand:VDQ_BHSI 0 "register_operand" "=w")
1096 (plus:VDQ_BHSI (minus:VDQ_BHSI
1097 (USMAX:VDQ_BHSI
1098 (match_operand:VDQ_BHSI 2 "register_operand" "w")
1099 (match_operand:VDQ_BHSI 3 "register_operand" "w"))
1100 (<max_opp>:VDQ_BHSI
1101 (match_dup 2)
1102 (match_dup 3)))
1103 (match_operand:VDQ_BHSI 1 "register_operand" "0")))]
1104 "TARGET_SIMD"
1105 "<su>aba\t%0.<Vtype>, %2.<Vtype>, %3.<Vtype>"
1106 [(set_attr "type" "neon_arith_acc<q>")]
1107 )
1108
1109 (define_insn "fabd<mode>3<vczle><vczbe>"
1110 [(set (match_operand:VHSDF_HSDF 0 "register_operand" "=w")
1111 (abs:VHSDF_HSDF
1112 (minus:VHSDF_HSDF
1113 (match_operand:VHSDF_HSDF 1 "register_operand" "w")
1114 (match_operand:VHSDF_HSDF 2 "register_operand" "w"))))]
1115 "TARGET_SIMD"
1116 "fabd\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>2<Vmtype>"
1117 [(set_attr "type" "neon_fp_abd_<stype><q>")]
1118 )
1119
1120 ;; For AND (vector, register) and BIC (vector, immediate)
1121 (define_insn "and<mode>3<vczle><vczbe>"
1122 [(set (match_operand:VDQ_I 0 "register_operand")
1123 (and:VDQ_I (match_operand:VDQ_I 1 "register_operand")
1124 (match_operand:VDQ_I 2 "aarch64_reg_or_and_imm")))]
1125 "TARGET_SIMD"
1126 {@ [ cons: =0 , 1 , 2 ]
1127 [ w , w , w ] and\t%0.<Vbtype>, %1.<Vbtype>, %2.<Vbtype>
1128 [ w , 0 , Db ] << aarch64_output_simd_and_imm (operands[2], <bitsize>);
1129 }
1130 [(set_attr "type" "neon_logic<q>")]
1131 )
1132
1133 ;; For ORR (vector, register) and ORR (vector, immediate)
1134 (define_insn "ior<mode>3<vczle><vczbe>"
1135 [(set (match_operand:VDQ_I 0 "register_operand")
1136 (ior:VDQ_I (match_operand:VDQ_I 1 "register_operand")
1137 (match_operand:VDQ_I 2 "aarch64_reg_or_orr_imm")))]
1138 "TARGET_SIMD"
1139 {@ [ cons: =0 , 1 , 2 ]
1140 [ w , w , w ] orr\t%0.<Vbtype>, %1.<Vbtype>, %2.<Vbtype>
1141 [ w , 0 , Do ] << aarch64_output_simd_orr_imm (operands[2], <bitsize>);
1142 }
1143 [(set_attr "type" "neon_logic<q>")]
1144 )
1145
1146 ;; For EOR (vector, register) and SVE EOR (vector, immediate)
1147 (define_insn "xor<mode>3<vczle><vczbe>"
1148 [(set (match_operand:VDQ_I 0 "register_operand")
1149 (xor:VDQ_I (match_operand:VDQ_I 1 "register_operand")
1150 (match_operand:VDQ_I 2 "aarch64_reg_or_xor_imm")))]
1151 "TARGET_SIMD"
1152 {@ [ cons: =0 , 1 , 2 ]
1153 [ w , w , w ] eor\t%0.<Vbtype>, %1.<Vbtype>, %2.<Vbtype>
1154 [ w , 0 , De ] << aarch64_output_simd_xor_imm (operands[2], <bitsize>);
1155 }
1156 [(set_attr "type" "neon_logic<q>")]
1157 )
1158
1159 (define_insn "one_cmpl<mode>2<vczle><vczbe>"
1160 [(set (match_operand:VDQ_I 0 "register_operand" "=w")
1161 (not:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w")))]
1162 "TARGET_SIMD"
1163 "not\t%0.<Vbtype>, %1.<Vbtype>"
1164 [(set_attr "type" "neon_logic<q>")]
1165 )
1166
1167 (define_insn "@aarch64_simd_vec_set<mode>"
1168 [(set (match_operand:VALL_F16 0 "register_operand" "=w,w,w")
1169 (vec_merge:VALL_F16
1170 (vec_duplicate:VALL_F16
1171 (match_operand:<VEL> 1 "aarch64_simd_nonimmediate_operand" "w,?r,Utv"))
1172 (match_operand:VALL_F16 3 "register_operand" "0,0,0")
1173 (match_operand:SI 2 "immediate_operand" "i,i,i")))]
1174 "TARGET_SIMD && exact_log2 (INTVAL (operands[2])) >= 0"
1175 {
1176 int elt = ENDIAN_LANE_N (<nunits>, exact_log2 (INTVAL (operands[2])));
1177 operands[2] = GEN_INT ((HOST_WIDE_INT) 1 << elt);
1178 switch (which_alternative)
1179 {
1180 case 0:
1181 return "ins\\t%0.<Vetype>[%p2], %1.<Vetype>[0]";
1182 case 1:
1183 return "ins\\t%0.<Vetype>[%p2], %<vwcore>1";
1184 case 2:
1185 return "ld1\\t{%0.<Vetype>}[%p2], %1";
1186 default:
1187 gcc_unreachable ();
1188 }
1189 }
1190 [(set_attr "type" "neon_ins<q>, neon_from_gp<q>, neon_load1_one_lane<q>")]
1191 )
1192
1193 (define_insn "aarch64_simd_vec_set_zero<mode>"
1194 [(set (match_operand:VALL_F16 0 "register_operand" "=w")
1195 (vec_merge:VALL_F16
1196 (match_operand:VALL_F16 1 "aarch64_simd_imm_zero" "")
1197 (match_operand:VALL_F16 3 "register_operand" "0")
1198 (match_operand:SI 2 "immediate_operand" "i")))]
1199 "TARGET_SIMD && exact_log2 (INTVAL (operands[2])) >= 0"
1200 {
1201 int elt = ENDIAN_LANE_N (<nunits>, exact_log2 (INTVAL (operands[2])));
1202 operands[2] = GEN_INT ((HOST_WIDE_INT) 1 << elt);
1203 return "ins\\t%0.<Vetype>[%p2], <vwcore>zr";
1204 }
1205 )
1206
1207 (define_insn "@aarch64_simd_vec_copy_lane<mode>"
1208 [(set (match_operand:VALL_F16 0 "register_operand" "=w")
1209 (vec_merge:VALL_F16
1210 (vec_duplicate:VALL_F16
1211 (vec_select:<VEL>
1212 (match_operand:VALL_F16 3 "register_operand" "w")
1213 (parallel
1214 [(match_operand:SI 4 "immediate_operand" "i")])))
1215 (match_operand:VALL_F16 1 "register_operand" "0")
1216 (match_operand:SI 2 "immediate_operand" "i")))]
1217 "TARGET_SIMD && exact_log2 (INTVAL (operands[2])) >= 0"
1218 {
1219 int elt = ENDIAN_LANE_N (<nunits>, exact_log2 (INTVAL (operands[2])));
1220 operands[2] = GEN_INT (HOST_WIDE_INT_1 << elt);
1221 operands[4] = aarch64_endian_lane_rtx (<MODE>mode, INTVAL (operands[4]));
1222
1223 return "ins\t%0.<Vetype>[%p2], %3.<Vetype>[%4]";
1224 }
1225 [(set_attr "type" "neon_ins<q>")]
1226 )
1227
1228 (define_insn "@aarch64_simd_vec_copy_lane_<vswap_width_name><mode>"
1229 [(set (match_operand:VALL_F16_NO_V2Q 0 "register_operand" "=w")
1230 (vec_merge:VALL_F16_NO_V2Q
1231 (vec_duplicate:VALL_F16_NO_V2Q
1232 (vec_select:<VEL>
1233 (match_operand:<VSWAP_WIDTH> 3 "register_operand" "w")
1234 (parallel
1235 [(match_operand:SI 4 "immediate_operand" "i")])))
1236 (match_operand:VALL_F16_NO_V2Q 1 "register_operand" "0")
1237 (match_operand:SI 2 "immediate_operand" "i")))]
1238 "TARGET_SIMD && exact_log2 (INTVAL (operands[2])) >= 0"
1239 {
1240 int elt = ENDIAN_LANE_N (<nunits>, exact_log2 (INTVAL (operands[2])));
1241 operands[2] = GEN_INT (HOST_WIDE_INT_1 << elt);
1242 operands[4] = aarch64_endian_lane_rtx (<VSWAP_WIDTH>mode,
1243 INTVAL (operands[4]));
1244
1245 return "ins\t%0.<Vetype>[%p2], %3.<Vetype>[%4]";
1246 }
1247 [(set_attr "type" "neon_ins<q>")]
1248 )
1249
1250 (define_expand "signbit<mode>2"
1251 [(use (match_operand:<V_INT_EQUIV> 0 "register_operand"))
1252 (use (match_operand:VDQSF 1 "register_operand"))]
1253 "TARGET_SIMD"
1254 {
1255 int shift_amount = GET_MODE_UNIT_BITSIZE (<V_INT_EQUIV>mode) - 1;
1256 rtx shift_vector = aarch64_simd_gen_const_vector_dup (<V_INT_EQUIV>mode,
1257 shift_amount);
1258 operands[1] = lowpart_subreg (<V_INT_EQUIV>mode, operands[1], <MODE>mode);
1259
1260 emit_insn (gen_aarch64_simd_lshr<v_int_equiv> (operands[0], operands[1],
1261 shift_vector));
1262 DONE;
1263 })
1264
1265 (define_insn "aarch64_simd_lshr<mode><vczle><vczbe>"
1266 [(set (match_operand:VDQ_I 0 "register_operand" "=w")
1267 (lshiftrt:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w")
1268 (match_operand:VDQ_I 2 "aarch64_simd_rshift_imm" "Dr")))]
1269 "TARGET_SIMD"
1270 "ushr\t%0.<Vtype>, %1.<Vtype>, %2"
1271 [(set_attr "type" "neon_shift_imm<q>")]
1272 )
1273
1274 (define_insn "aarch64_simd_ashr<mode><vczle><vczbe>"
1275 [(set (match_operand:VDQ_I 0 "register_operand")
1276 (ashiftrt:VDQ_I (match_operand:VDQ_I 1 "register_operand")
1277 (match_operand:VDQ_I 2 "aarch64_simd_rshift_imm")))]
1278 "TARGET_SIMD"
1279 {@ [ cons: =0 , 1 , 2 ; attrs: type ]
1280 [ w , w , D1 ; neon_compare<q> ] cmlt\t%0.<Vtype>, %1.<Vtype>, #0
1281 [ w , w , Dr ; neon_shift_imm<q> ] sshr\t%0.<Vtype>, %1.<Vtype>, %2
1282 }
1283 )
1284
1285 (define_insn "aarch64_<sra_op>sra_n<mode>_insn"
1286 [(set (match_operand:VDQ_I 0 "register_operand" "=w")
1287 (plus:VDQ_I
1288 (SHIFTRT:VDQ_I
1289 (match_operand:VDQ_I 2 "register_operand" "w")
1290 (match_operand:VDQ_I 3 "aarch64_simd_rshift_imm"))
1291 (match_operand:VDQ_I 1 "register_operand" "0")))]
1292 "TARGET_SIMD"
1293 "<sra_op>sra\t%<v>0<Vmtype>, %<v>2<Vmtype>, %3"
1294 [(set_attr "type" "neon_shift_acc<q>")]
1295 )
1296
1297 ;; After all the combinations and propagations of ROTATE have been
1298 ;; attempted split any remaining vector rotates into SHL + USRA sequences.
1299 ;; Don't match this after reload as the various possible sequence for this
1300 ;; require temporary registers.
1301 (define_insn_and_split "*aarch64_simd_rotate_imm<mode>"
1302 [(set (match_operand:VDQ_I 0 "register_operand" "=&w")
1303 (rotate:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w")
1304 (match_operand:VDQ_I 2 "aarch64_simd_lshift_imm")))]
1305 "TARGET_SIMD && can_create_pseudo_p ()"
1306 "#"
1307 "&& 1"
1308 [(set (match_dup 3)
1309 (ashift:VDQ_I (match_dup 1)
1310 (match_dup 2)))
1311 (set (match_dup 0)
1312 (plus:VDQ_I
1313 (lshiftrt:VDQ_I
1314 (match_dup 1)
1315 (match_dup 4))
1316 (match_dup 3)))]
1317 {
1318 if (aarch64_emit_opt_vec_rotate (operands[0], operands[1], operands[2]))
1319 DONE;
1320
1321 operands[3] = gen_reg_rtx (<MODE>mode);
1322 rtx shft_amnt = unwrap_const_vec_duplicate (operands[2]);
1323 int bitwidth = GET_MODE_UNIT_SIZE (<MODE>mode) * BITS_PER_UNIT;
1324 operands[4]
1325 = aarch64_simd_gen_const_vector_dup (<MODE>mode,
1326 bitwidth - INTVAL (shft_amnt));
1327 }
1328 [(set_attr "length" "8")]
1329 )
1330
1331 (define_insn "aarch64_<sra_op>rsra_n<mode>_insn"
1332 [(set (match_operand:VSDQ_I_DI 0 "register_operand" "=w")
1333 (plus:VSDQ_I_DI
1334 (truncate:VSDQ_I_DI
1335 (SHIFTRT:<V2XWIDE>
1336 (plus:<V2XWIDE>
1337 (<SHIFTEXTEND>:<V2XWIDE>
1338 (match_operand:VSDQ_I_DI 2 "register_operand" "w"))
1339 (match_operand:<V2XWIDE> 4 "aarch64_int_rnd_operand"))
1340 (match_operand:VSDQ_I_DI 3 "aarch64_simd_shift_imm_<vec_or_offset>_<Vel>")))
1341 (match_operand:VSDQ_I_DI 1 "register_operand" "0")))]
1342 "TARGET_SIMD
1343 && aarch64_const_vec_rnd_cst_p (operands[4], operands[3])"
1344 "<sra_op>rsra\\t%<v>0<Vmtype>, %<v>2<Vmtype>, %3"
1345 [(set_attr "type" "neon_shift_acc<q>")]
1346 )
1347
1348 (define_expand "aarch64_<sra_op>sra_n<mode>"
1349 [(set (match_operand:VDQ_I 0 "register_operand")
1350 (plus:VDQ_I
1351 (SHIFTRT:VDQ_I
1352 (match_operand:VDQ_I 2 "register_operand")
1353 (match_operand:SI 3 "aarch64_simd_shift_imm_offset_<ve_mode>"))
1354 (match_operand:VDQ_I 1 "register_operand")))]
1355 "TARGET_SIMD"
1356 {
1357 operands[3]
1358 = aarch64_simd_gen_const_vector_dup (<MODE>mode, UINTVAL (operands[3]));
1359 }
1360 )
1361
1362 (define_expand "aarch64_<sra_op>rsra_n<mode>"
1363 [(match_operand:VSDQ_I_DI 0 "register_operand")
1364 (match_operand:VSDQ_I_DI 1 "register_operand")
1365 (SHIFTRT:VSDQ_I_DI
1366 (match_operand:VSDQ_I_DI 2 "register_operand")
1367 (match_operand:SI 3 "aarch64_simd_shift_imm_offset_<ve_mode>"))]
1368 "TARGET_SIMD"
1369 {
1370 /* Use this expander to create the rounding constant vector, which is
1371 1 << (shift - 1). Use wide_int here to ensure that the right TImode
1372 RTL is generated when handling the DImode expanders. */
1373 int prec = GET_MODE_UNIT_PRECISION (<V2XWIDE>mode);
1374 wide_int rnd_wi = wi::set_bit_in_zero (INTVAL (operands[3]) - 1, prec);
1375 rtx shft = gen_int_mode (INTVAL (operands[3]), DImode);
1376 rtx rnd = immed_wide_int_const (rnd_wi, GET_MODE_INNER (<V2XWIDE>mode));
1377 if (VECTOR_MODE_P (<MODE>mode))
1378 {
1379 shft = gen_const_vec_duplicate (<MODE>mode, shft);
1380 rnd = gen_const_vec_duplicate (<V2XWIDE>mode, rnd);
1381 }
1382
1383 emit_insn (gen_aarch64_<sra_op>rsra_n<mode>_insn (operands[0], operands[1],
1384 operands[2], shft, rnd));
1385 DONE;
1386 }
1387 )
1388
1389 (define_insn "aarch64_simd_imm_shl<mode><vczle><vczbe>"
1390 [(set (match_operand:VDQ_I 0 "register_operand")
1391 (ashift:VDQ_I (match_operand:VDQ_I 1 "register_operand")
1392 (match_operand:VDQ_I 2 "aarch64_simd_lshift_imm")))]
1393 "TARGET_SIMD"
1394 {@ [ cons: =0, 1, 2 ; attrs: type ]
1395 [ w , w, vs1 ; neon_add<q> ] add\t%0.<Vtype>, %1.<Vtype>, %1.<Vtype>
1396 [ w , w, Dl ; neon_shift_imm<q> ] shl\t%0.<Vtype>, %1.<Vtype>, %2
1397 }
1398 )
1399
1400 (define_insn "aarch64_simd_reg_sshl<mode><vczle><vczbe>"
1401 [(set (match_operand:VDQ_I 0 "register_operand" "=w")
1402 (ashift:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w")
1403 (match_operand:VDQ_I 2 "register_operand" "w")))]
1404 "TARGET_SIMD"
1405 "sshl\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
1406 [(set_attr "type" "neon_shift_reg<q>")]
1407 )
1408
1409 (define_insn "aarch64_simd_reg_shl<mode>_unsigned<vczle><vczbe>"
1410 [(set (match_operand:VDQ_I 0 "register_operand" "=w")
1411 (unspec:VDQ_I [(match_operand:VDQ_I 1 "register_operand" "w")
1412 (match_operand:VDQ_I 2 "register_operand" "w")]
1413 UNSPEC_ASHIFT_UNSIGNED))]
1414 "TARGET_SIMD"
1415 "ushl\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
1416 [(set_attr "type" "neon_shift_reg<q>")]
1417 )
1418
1419 (define_insn "aarch64_simd_reg_shl<mode>_signed<vczle><vczbe>"
1420 [(set (match_operand:VDQ_I 0 "register_operand" "=w")
1421 (unspec:VDQ_I [(match_operand:VDQ_I 1 "register_operand" "w")
1422 (match_operand:VDQ_I 2 "register_operand" "w")]
1423 UNSPEC_ASHIFT_SIGNED))]
1424 "TARGET_SIMD"
1425 "sshl\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
1426 [(set_attr "type" "neon_shift_reg<q>")]
1427 )
1428
1429 (define_expand "ashl<mode>3"
1430 [(match_operand:VDQ_I 0 "register_operand")
1431 (match_operand:VDQ_I 1 "register_operand")
1432 (match_operand:SI 2 "general_operand")]
1433 "TARGET_SIMD"
1434 {
1435 int bit_width = GET_MODE_UNIT_SIZE (<MODE>mode) * BITS_PER_UNIT;
1436 int shift_amount;
1437
1438 if (CONST_INT_P (operands[2]))
1439 {
1440 shift_amount = INTVAL (operands[2]);
1441 if (shift_amount >= 0 && shift_amount < bit_width)
1442 {
1443 rtx tmp = aarch64_simd_gen_const_vector_dup (<MODE>mode,
1444 shift_amount);
1445 emit_insn (gen_aarch64_simd_imm_shl<mode> (operands[0],
1446 operands[1],
1447 tmp));
1448 DONE;
1449 }
1450 }
1451
1452 operands[2] = force_reg (SImode, operands[2]);
1453
1454 rtx tmp = gen_reg_rtx (<MODE>mode);
1455 emit_insn (gen_aarch64_simd_dup<mode> (tmp, convert_to_mode (<VEL>mode,
1456 operands[2],
1457 0)));
1458 emit_insn (gen_aarch64_simd_reg_sshl<mode> (operands[0], operands[1], tmp));
1459 DONE;
1460 })
1461
1462 (define_expand "lshr<mode>3"
1463 [(match_operand:VDQ_I 0 "register_operand")
1464 (match_operand:VDQ_I 1 "register_operand")
1465 (match_operand:SI 2 "general_operand")]
1466 "TARGET_SIMD"
1467 {
1468 int bit_width = GET_MODE_UNIT_SIZE (<MODE>mode) * BITS_PER_UNIT;
1469 int shift_amount;
1470
1471 if (CONST_INT_P (operands[2]))
1472 {
1473 shift_amount = INTVAL (operands[2]);
1474 if (shift_amount > 0 && shift_amount <= bit_width)
1475 {
1476 rtx tmp = aarch64_simd_gen_const_vector_dup (<MODE>mode,
1477 shift_amount);
1478 emit_insn (gen_aarch64_simd_lshr<mode> (operands[0],
1479 operands[1],
1480 tmp));
1481 DONE;
1482 }
1483 }
1484
1485 operands[2] = force_reg (SImode, operands[2]);
1486
1487 rtx tmp = gen_reg_rtx (SImode);
1488 rtx tmp1 = gen_reg_rtx (<MODE>mode);
1489 emit_insn (gen_negsi2 (tmp, operands[2]));
1490 emit_insn (gen_aarch64_simd_dup<mode> (tmp1,
1491 convert_to_mode (<VEL>mode, tmp, 0)));
1492 emit_insn (gen_aarch64_simd_reg_shl<mode>_unsigned (operands[0], operands[1],
1493 tmp1));
1494 DONE;
1495 })
1496
1497 (define_expand "ashr<mode>3"
1498 [(match_operand:VDQ_I 0 "register_operand")
1499 (match_operand:VDQ_I 1 "register_operand")
1500 (match_operand:SI 2 "general_operand")]
1501 "TARGET_SIMD"
1502 {
1503 int bit_width = GET_MODE_UNIT_SIZE (<MODE>mode) * BITS_PER_UNIT;
1504 int shift_amount;
1505
1506 if (CONST_INT_P (operands[2]))
1507 {
1508 shift_amount = INTVAL (operands[2]);
1509 if (shift_amount > 0 && shift_amount <= bit_width)
1510 {
1511 rtx tmp = aarch64_simd_gen_const_vector_dup (<MODE>mode,
1512 shift_amount);
1513 emit_insn (gen_aarch64_simd_ashr<mode> (operands[0],
1514 operands[1],
1515 tmp));
1516 DONE;
1517 }
1518 }
1519
1520 operands[2] = force_reg (SImode, operands[2]);
1521
1522 rtx tmp = gen_reg_rtx (SImode);
1523 rtx tmp1 = gen_reg_rtx (<MODE>mode);
1524 emit_insn (gen_negsi2 (tmp, operands[2]));
1525 emit_insn (gen_aarch64_simd_dup<mode> (tmp1, convert_to_mode (<VEL>mode,
1526 tmp, 0)));
1527 emit_insn (gen_aarch64_simd_reg_shl<mode>_signed (operands[0], operands[1],
1528 tmp1));
1529 DONE;
1530 })
1531
1532 (define_expand "vashl<mode>3"
1533 [(match_operand:VDQ_I 0 "register_operand")
1534 (match_operand:VDQ_I 1 "register_operand")
1535 (match_operand:VDQ_I 2 "register_operand")]
1536 "TARGET_SIMD"
1537 {
1538 emit_insn (gen_aarch64_simd_reg_sshl<mode> (operands[0], operands[1],
1539 operands[2]));
1540 DONE;
1541 })
1542
1543 (define_expand "vashr<mode>3"
1544 [(match_operand:VDQ_I 0 "register_operand")
1545 (match_operand:VDQ_I 1 "register_operand")
1546 (match_operand:VDQ_I 2 "register_operand")]
1547 "TARGET_SIMD"
1548 {
1549 rtx neg = gen_reg_rtx (<MODE>mode);
1550 emit (gen_neg<mode>2 (neg, operands[2]));
1551 emit_insn (gen_aarch64_simd_reg_shl<mode>_signed (operands[0], operands[1],
1552 neg));
1553 DONE;
1554 })
1555
1556 ;; DI vector shift
1557 (define_expand "aarch64_ashr_simddi"
1558 [(match_operand:DI 0 "register_operand")
1559 (match_operand:DI 1 "register_operand")
1560 (match_operand:SI 2 "aarch64_shift_imm64_di")]
1561 "TARGET_SIMD"
1562 {
1563 /* An arithmetic shift right by 64 fills the result with copies of the sign
1564 bit, just like asr by 63 - however the standard pattern does not handle
1565 a shift by 64. */
1566 if (INTVAL (operands[2]) == 64)
1567 operands[2] = GEN_INT (63);
1568 emit_insn (gen_ashrdi3 (operands[0], operands[1], operands[2]));
1569 DONE;
1570 }
1571 )
1572
1573 (define_expand "vlshr<mode>3"
1574 [(match_operand:VDQ_I 0 "register_operand")
1575 (match_operand:VDQ_I 1 "register_operand")
1576 (match_operand:VDQ_I 2 "register_operand")]
1577 "TARGET_SIMD"
1578 {
1579 rtx neg = gen_reg_rtx (<MODE>mode);
1580 emit (gen_neg<mode>2 (neg, operands[2]));
1581 emit_insn (gen_aarch64_simd_reg_shl<mode>_unsigned (operands[0], operands[1],
1582 neg));
1583 DONE;
1584 })
1585
1586 (define_expand "aarch64_lshr_simddi"
1587 [(match_operand:DI 0 "register_operand")
1588 (match_operand:DI 1 "register_operand")
1589 (match_operand:SI 2 "aarch64_shift_imm64_di")]
1590 "TARGET_SIMD"
1591 {
1592 if (INTVAL (operands[2]) == 64)
1593 emit_move_insn (operands[0], const0_rtx);
1594 else
1595 emit_insn (gen_lshrdi3 (operands[0], operands[1], operands[2]));
1596 DONE;
1597 }
1598 )
1599
1600 ;; For 64-bit modes we use ushl/r, as this does not require a SIMD zero.
1601 (define_insn "vec_shr_<mode><vczle><vczbe>"
1602 [(set (match_operand:VD 0 "register_operand" "=w")
1603 (unspec:VD [(match_operand:VD 1 "register_operand" "w")
1604 (match_operand:SI 2 "immediate_operand" "i")]
1605 UNSPEC_VEC_SHR))]
1606 "TARGET_SIMD"
1607 {
1608 if (BYTES_BIG_ENDIAN)
1609 return "shl %d0, %d1, %2";
1610 else
1611 return "ushr %d0, %d1, %2";
1612 }
1613 [(set_attr "type" "neon_shift_imm")]
1614 )
1615
1616 (define_expand "vec_set<mode>"
1617 [(match_operand:VALL_F16 0 "register_operand")
1618 (match_operand:<VEL> 1 "aarch64_simd_nonimmediate_operand")
1619 (match_operand:SI 2 "immediate_operand")]
1620 "TARGET_SIMD"
1621 {
1622 HOST_WIDE_INT elem = (HOST_WIDE_INT) 1 << INTVAL (operands[2]);
1623 emit_insn (gen_aarch64_simd_vec_set<mode> (operands[0], operands[1],
1624 GEN_INT (elem), operands[0]));
1625 DONE;
1626 }
1627 )
1628
1629
1630 (define_insn "aarch64_mla<mode><vczle><vczbe>"
1631 [(set (match_operand:VDQ_BHSI 0 "register_operand" "=w")
1632 (plus:VDQ_BHSI (mult:VDQ_BHSI
1633 (match_operand:VDQ_BHSI 2 "register_operand" "w")
1634 (match_operand:VDQ_BHSI 3 "register_operand" "w"))
1635 (match_operand:VDQ_BHSI 1 "register_operand" "0")))]
1636 "TARGET_SIMD"
1637 "mla\t%0.<Vtype>, %2.<Vtype>, %3.<Vtype>"
1638 [(set_attr "type" "neon_mla_<Vetype><q>")]
1639 )
1640
1641 (define_insn "*aarch64_mla_elt<mode><vczle><vczbe>"
1642 [(set (match_operand:VDQHS 0 "register_operand" "=w")
1643 (plus:VDQHS
1644 (mult:VDQHS
1645 (vec_duplicate:VDQHS
1646 (vec_select:<VEL>
1647 (match_operand:VDQHS 1 "register_operand" "<h_con>")
1648 (parallel [(match_operand:SI 2 "immediate_operand")])))
1649 (match_operand:VDQHS 3 "register_operand" "w"))
1650 (match_operand:VDQHS 4 "register_operand" "0")))]
1651 "TARGET_SIMD"
1652 {
1653 operands[2] = aarch64_endian_lane_rtx (<MODE>mode, INTVAL (operands[2]));
1654 return "mla\t%0.<Vtype>, %3.<Vtype>, %1.<Vetype>[%2]";
1655 }
1656 [(set_attr "type" "neon_mla_<Vetype>_scalar<q>")]
1657 )
1658
1659 (define_insn "*aarch64_mla_elt_<vswap_width_name><mode><vczle><vczbe>"
1660 [(set (match_operand:VDQHS 0 "register_operand" "=w")
1661 (plus:VDQHS
1662 (mult:VDQHS
1663 (vec_duplicate:VDQHS
1664 (vec_select:<VEL>
1665 (match_operand:<VSWAP_WIDTH> 1 "register_operand" "<h_con>")
1666 (parallel [(match_operand:SI 2 "immediate_operand")])))
1667 (match_operand:VDQHS 3 "register_operand" "w"))
1668 (match_operand:VDQHS 4 "register_operand" "0")))]
1669 "TARGET_SIMD"
1670 {
1671 operands[2] = aarch64_endian_lane_rtx (<VSWAP_WIDTH>mode, INTVAL (operands[2]));
1672 return "mla\t%0.<Vtype>, %3.<Vtype>, %1.<Vetype>[%2]";
1673 }
1674 [(set_attr "type" "neon_mla_<Vetype>_scalar<q>")]
1675 )
1676
1677 (define_insn "aarch64_mla_n<mode><vczle><vczbe>"
1678 [(set (match_operand:VDQHS 0 "register_operand" "=w")
1679 (plus:VDQHS
1680 (mult:VDQHS
1681 (vec_duplicate:VDQHS
1682 (match_operand:<VEL> 3 "register_operand" "<h_con>"))
1683 (match_operand:VDQHS 2 "register_operand" "w"))
1684 (match_operand:VDQHS 1 "register_operand" "0")))]
1685 "TARGET_SIMD"
1686 "mla\t%0.<Vtype>, %2.<Vtype>, %3.<Vetype>[0]"
1687 [(set_attr "type" "neon_mla_<Vetype>_scalar<q>")]
1688 )
1689
1690 (define_insn "aarch64_mls<mode><vczle><vczbe>"
1691 [(set (match_operand:VDQ_BHSI 0 "register_operand" "=w")
1692 (minus:VDQ_BHSI (match_operand:VDQ_BHSI 1 "register_operand" "0")
1693 (mult:VDQ_BHSI (match_operand:VDQ_BHSI 2 "register_operand" "w")
1694 (match_operand:VDQ_BHSI 3 "register_operand" "w"))))]
1695 "TARGET_SIMD"
1696 "mls\t%0.<Vtype>, %2.<Vtype>, %3.<Vtype>"
1697 [(set_attr "type" "neon_mla_<Vetype><q>")]
1698 )
1699
1700 (define_insn "*aarch64_mls_elt<mode><vczle><vczbe>"
1701 [(set (match_operand:VDQHS 0 "register_operand" "=w")
1702 (minus:VDQHS
1703 (match_operand:VDQHS 4 "register_operand" "0")
1704 (mult:VDQHS
1705 (vec_duplicate:VDQHS
1706 (vec_select:<VEL>
1707 (match_operand:VDQHS 1 "register_operand" "<h_con>")
1708 (parallel [(match_operand:SI 2 "immediate_operand")])))
1709 (match_operand:VDQHS 3 "register_operand" "w"))))]
1710 "TARGET_SIMD"
1711 {
1712 operands[2] = aarch64_endian_lane_rtx (<MODE>mode, INTVAL (operands[2]));
1713 return "mls\t%0.<Vtype>, %3.<Vtype>, %1.<Vetype>[%2]";
1714 }
1715 [(set_attr "type" "neon_mla_<Vetype>_scalar<q>")]
1716 )
1717
1718 (define_insn "*aarch64_mls_elt_<vswap_width_name><mode><vczle><vczbe>"
1719 [(set (match_operand:VDQHS 0 "register_operand" "=w")
1720 (minus:VDQHS
1721 (match_operand:VDQHS 4 "register_operand" "0")
1722 (mult:VDQHS
1723 (vec_duplicate:VDQHS
1724 (vec_select:<VEL>
1725 (match_operand:<VSWAP_WIDTH> 1 "register_operand" "<h_con>")
1726 (parallel [(match_operand:SI 2 "immediate_operand")])))
1727 (match_operand:VDQHS 3 "register_operand" "w"))))]
1728 "TARGET_SIMD"
1729 {
1730 operands[2] = aarch64_endian_lane_rtx (<VSWAP_WIDTH>mode, INTVAL (operands[2]));
1731 return "mls\t%0.<Vtype>, %3.<Vtype>, %1.<Vetype>[%2]";
1732 }
1733 [(set_attr "type" "neon_mla_<Vetype>_scalar<q>")]
1734 )
1735
1736 (define_insn "aarch64_mls_n<mode><vczle><vczbe>"
1737 [(set (match_operand:VDQHS 0 "register_operand" "=w")
1738 (minus:VDQHS
1739 (match_operand:VDQHS 1 "register_operand" "0")
1740 (mult:VDQHS
1741 (vec_duplicate:VDQHS
1742 (match_operand:<VEL> 3 "register_operand" "<h_con>"))
1743 (match_operand:VDQHS 2 "register_operand" "w"))))]
1744 "TARGET_SIMD"
1745 "mls\t%0.<Vtype>, %2.<Vtype>, %3.<Vetype>[0]"
1746 [(set_attr "type" "neon_mla_<Vetype>_scalar<q>")]
1747 )
1748
1749 ;; Max/Min operations.
1750 (define_insn "<su><maxmin><mode>3<vczle><vczbe>"
1751 [(set (match_operand:VDQ_BHSI 0 "register_operand" "=w")
1752 (MAXMIN:VDQ_BHSI (match_operand:VDQ_BHSI 1 "register_operand" "w")
1753 (match_operand:VDQ_BHSI 2 "register_operand" "w")))]
1754 "TARGET_SIMD"
1755 "<su><maxmin>\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
1756 [(set_attr "type" "neon_minmax<q>")]
1757 )
1758
1759 (define_expand "<su><maxmin>v2di3"
1760 [(set (match_operand:V2DI 0 "register_operand")
1761 (MAXMIN:V2DI (match_operand:V2DI 1 "register_operand")
1762 (match_operand:V2DI 2 "register_operand")))]
1763 "TARGET_SIMD"
1764 {
1765 enum rtx_code cmp_operator;
1766 rtx cmp_fmt;
1767
1768 switch (<CODE>)
1769 {
1770 case UMIN:
1771 cmp_operator = LTU;
1772 break;
1773 case SMIN:
1774 cmp_operator = LT;
1775 break;
1776 case UMAX:
1777 cmp_operator = GTU;
1778 break;
1779 case SMAX:
1780 cmp_operator = GT;
1781 break;
1782 default:
1783 gcc_unreachable ();
1784 }
1785
1786 rtx mask = gen_reg_rtx (V2DImode);
1787 cmp_fmt = gen_rtx_fmt_ee (cmp_operator, V2DImode, operands[1], operands[2]);
1788 emit_insn (gen_vec_cmpv2div2di (mask, cmp_fmt, operands[1], operands[2]));
1789 emit_insn (gen_vcond_mask_v2div2di (operands[0], operands[1],
1790 operands[2], mask));
1791 DONE;
1792 })
1793
1794 ;; Pairwise Integer Max/Min operations.
1795 (define_insn "aarch64_<optab>p<mode><vczle><vczbe>"
1796 [(set (match_operand:VDQ_BHSI 0 "register_operand" "=w")
1797 (unspec:VDQ_BHSI [(match_operand:VDQ_BHSI 1 "register_operand" "w")
1798 (match_operand:VDQ_BHSI 2 "register_operand" "w")]
1799 MAXMINV))]
1800 "TARGET_SIMD"
1801 "<maxmin_uns_op>p\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
1802 [(set_attr "type" "neon_minmax<q>")]
1803 )
1804
1805 ;; Pairwise FP Max/Min operations.
1806 (define_insn "aarch64_<optab>p<mode><vczle><vczbe>"
1807 [(set (match_operand:VHSDF 0 "register_operand" "=w")
1808 (unspec:VHSDF [(match_operand:VHSDF 1 "register_operand" "w")
1809 (match_operand:VHSDF 2 "register_operand" "w")]
1810 FMAXMINV))]
1811 "TARGET_SIMD"
1812 "<maxmin_uns_op>p\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
1813 [(set_attr "type" "neon_minmax<q>")]
1814 )
1815
1816 ;; vec_concat gives a new vector with the low elements from operand 1, and
1817 ;; the high elements from operand 2. That is to say, given op1 = { a, b }
1818 ;; op2 = { c, d }, vec_concat (op1, op2) = { a, b, c, d }.
1819 ;; What that means, is that the RTL descriptions of the below patterns
1820 ;; need to change depending on endianness.
1821
1822 ;; Narrowing operations.
1823
1824 (define_insn "aarch64_xtn2<mode>_insn_le"
1825 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
1826 (vec_concat:<VNARROWQ2>
1827 (match_operand:<VNARROWQ> 1 "register_operand" "0")
1828 (truncate:<VNARROWQ> (match_operand:VQN 2 "register_operand" "w"))))]
1829 "TARGET_SIMD && !BYTES_BIG_ENDIAN"
1830 "xtn2\t%0.<V2ntype>, %2.<Vtype>"
1831 [(set_attr "type" "neon_move_narrow_q")]
1832 )
1833
1834 (define_insn "aarch64_xtn2<mode>_insn_be"
1835 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
1836 (vec_concat:<VNARROWQ2>
1837 (truncate:<VNARROWQ> (match_operand:VQN 2 "register_operand" "w"))
1838 (match_operand:<VNARROWQ> 1 "register_operand" "0")))]
1839 "TARGET_SIMD && BYTES_BIG_ENDIAN"
1840 "xtn2\t%0.<V2ntype>, %2.<Vtype>"
1841 [(set_attr "type" "neon_move_narrow_q")]
1842 )
1843
1844 (define_expand "aarch64_xtn2<mode>"
1845 [(match_operand:<VNARROWQ2> 0 "register_operand")
1846 (match_operand:<VNARROWQ> 1 "register_operand")
1847 (truncate:<VNARROWQ> (match_operand:VQN 2 "register_operand"))]
1848 "TARGET_SIMD"
1849 {
1850 if (BYTES_BIG_ENDIAN)
1851 emit_insn (gen_aarch64_xtn2<mode>_insn_be (operands[0], operands[1],
1852 operands[2]));
1853 else
1854 emit_insn (gen_aarch64_xtn2<mode>_insn_le (operands[0], operands[1],
1855 operands[2]));
1856 DONE;
1857 }
1858 )
1859
1860 (define_insn "*aarch64_narrow_trunc<mode>"
1861 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
1862 (vec_concat:<VNARROWQ2>
1863 (truncate:<VNARROWQ>
1864 (match_operand:VQN 1 "register_operand" "w"))
1865 (truncate:<VNARROWQ>
1866 (match_operand:VQN 2 "register_operand" "w"))))]
1867 "TARGET_SIMD"
1868 {
1869 if (!BYTES_BIG_ENDIAN)
1870 return "uzp1\\t%0.<V2ntype>, %1.<V2ntype>, %2.<V2ntype>";
1871 else
1872 return "uzp1\\t%0.<V2ntype>, %2.<V2ntype>, %1.<V2ntype>";
1873 }
1874 [(set_attr "type" "neon_permute<q>")]
1875 )
1876
1877 (define_insn "*aarch64_trunc_concat<mode>"
1878 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
1879 (truncate:<VNARROWQ>
1880 (vec_concat:VQN
1881 (match_operand:<VHALF> 1 "register_operand" "w")
1882 (match_operand:<VHALF> 2 "register_operand" "w"))))]
1883 "TARGET_SIMD"
1884 {
1885 if (!BYTES_BIG_ENDIAN)
1886 return "uzp1\\t%0.<Vntype>, %1.<Vntype>, %2.<Vntype>";
1887 else
1888 return "uzp1\\t%0.<Vntype>, %2.<Vntype>, %1.<Vntype>";
1889 }
1890 [(set_attr "type" "neon_permute<q>")]
1891 )
1892
1893 ;; Packing doubles.
1894
1895 (define_expand "vec_pack_trunc_<mode>"
1896 [(match_operand:<VNARROWD> 0 "register_operand")
1897 (match_operand:VDN 1 "general_operand")
1898 (match_operand:VDN 2 "general_operand")]
1899 "TARGET_SIMD"
1900 {
1901 rtx tempreg = gen_reg_rtx (<VDBL>mode);
1902 emit_insn (gen_aarch64_vec_concat<mode> (tempreg, operands[1], operands[2]));
1903 emit_insn (gen_trunc<Vdbl><Vnarrowd>2 (operands[0], tempreg));
1904 DONE;
1905 })
1906
1907 ;; Packing quads.
1908
1909 (define_expand "vec_pack_trunc_<mode>"
1910 [(set (match_operand:<VNARROWQ2> 0 "register_operand")
1911 (vec_concat:<VNARROWQ2>
1912 (truncate:<VNARROWQ> (match_operand:VQN 1 "register_operand"))
1913 (truncate:<VNARROWQ> (match_operand:VQN 2 "register_operand"))))]
1914 "TARGET_SIMD"
1915 {
1916 rtx tmpreg = gen_reg_rtx (<VNARROWQ>mode);
1917 int lo = BYTES_BIG_ENDIAN ? 2 : 1;
1918 int hi = BYTES_BIG_ENDIAN ? 1 : 2;
1919
1920 emit_insn (gen_trunc<mode><Vnarrowq>2 (tmpreg, operands[lo]));
1921
1922 if (BYTES_BIG_ENDIAN)
1923 emit_insn (gen_aarch64_xtn2<mode>_insn_be (operands[0], tmpreg,
1924 operands[hi]));
1925 else
1926 emit_insn (gen_aarch64_xtn2<mode>_insn_le (operands[0], tmpreg,
1927 operands[hi]));
1928 DONE;
1929 }
1930 )
1931
1932 (define_insn "*aarch64_<srn_op>topbits_shuffle<mode>_le"
1933 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
1934 (vec_concat:<VNARROWQ2>
1935 (truncate:<VNARROWQ>
1936 (SHIFTRT:VQN (match_operand:VQN 1 "register_operand" "w")
1937 (match_operand:VQN 2 "aarch64_simd_shift_imm_vec_exact_top")))
1938 (truncate:<VNARROWQ>
1939 (SHIFTRT:VQN (match_operand:VQN 3 "register_operand" "w")
1940 (match_dup 2)))))]
1941 "TARGET_SIMD && !BYTES_BIG_ENDIAN"
1942 "uzp2\\t%0.<V2ntype>, %1.<V2ntype>, %3.<V2ntype>"
1943 [(set_attr "type" "neon_permute<q>")]
1944 )
1945
1946 (define_insn "*aarch64_<srn_op>topbits_shuffle<mode>_be"
1947 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
1948 (vec_concat:<VNARROWQ2>
1949 (truncate:<VNARROWQ>
1950 (SHIFTRT:VQN (match_operand:VQN 3 "register_operand" "w")
1951 (match_operand:VQN 2 "aarch64_simd_shift_imm_vec_exact_top")))
1952 (truncate:<VNARROWQ>
1953 (SHIFTRT:VQN (match_operand:VQN 1 "register_operand" "w")
1954 (match_dup 2)))))]
1955 "TARGET_SIMD && BYTES_BIG_ENDIAN"
1956 "uzp2\\t%0.<V2ntype>, %1.<V2ntype>, %3.<V2ntype>"
1957 [(set_attr "type" "neon_permute<q>")]
1958 )
1959
1960 ;; Widening operations.
1961
1962 (define_insn_and_split "aarch64_simd_vec_unpack<su>_hi_<mode>"
1963 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
1964 (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
1965 (match_operand:VQW 1 "register_operand" "w")
1966 (match_operand:VQW 2 "vect_par_cnst_hi_half" "")
1967 )))]
1968 "TARGET_SIMD"
1969 "<su>xtl2\t%0.<Vwtype>, %1.<Vtype>"
1970 "&& <CODE> == ZERO_EXTEND
1971 && aarch64_split_simd_shift_p (insn)"
1972 [(const_int 0)]
1973 {
1974 /* On many cores, it is cheaper to implement UXTL2 using a ZIP2 with zero,
1975 provided that the cost of the zero can be amortized over several
1976 operations. We'll later recombine the zero and zip if there are
1977 not sufficient uses of the zero to make the split worthwhile. */
1978 rtx res = simplify_gen_subreg (<MODE>mode, operands[0], <VWIDE>mode, 0);
1979 rtx zero = aarch64_gen_shareable_zero (<MODE>mode);
1980 emit_insn (gen_aarch64_zip2<mode> (res, operands[1], zero));
1981 DONE;
1982 }
1983 [(set_attr "type" "neon_shift_imm_long")]
1984 )
1985
1986 (define_expand "vec_unpack<su>_hi_<mode>"
1987 [(match_operand:<VWIDE> 0 "register_operand")
1988 (ANY_EXTEND:<VWIDE> (match_operand:VQW 1 "register_operand"))]
1989 "TARGET_SIMD"
1990 {
1991 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
1992 emit_insn (gen_aarch64_simd_vec_unpack<su>_hi_<mode> (operands[0],
1993 operands[1], p));
1994 DONE;
1995 }
1996 )
1997
1998 (define_expand "vec_unpack<su>_lo_<mode>"
1999 [(set (match_operand:<VWIDE> 0 "register_operand")
2000 (ANY_EXTEND:<VWIDE> (match_operand:VQW 1 "register_operand")))]
2001 "TARGET_SIMD"
2002 {
2003 operands[1] = lowpart_subreg (<VHALF>mode, operands[1], <MODE>mode);
2004 }
2005 )
2006
2007 ;; Widening arithmetic.
2008
2009 (define_insn "*aarch64_<su>mlal_lo<mode>"
2010 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2011 (plus:<VWIDE>
2012 (mult:<VWIDE>
2013 (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
2014 (match_operand:VQW 2 "register_operand" "w")
2015 (match_operand:VQW 3 "vect_par_cnst_lo_half" "")))
2016 (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
2017 (match_operand:VQW 4 "register_operand" "w")
2018 (match_dup 3))))
2019 (match_operand:<VWIDE> 1 "register_operand" "0")))]
2020 "TARGET_SIMD"
2021 "<su>mlal\t%0.<Vwtype>, %2.<Vhalftype>, %4.<Vhalftype>"
2022 [(set_attr "type" "neon_mla_<Vetype>_long")]
2023 )
2024
2025 (define_insn "aarch64_<su>mlal_hi<mode>_insn"
2026 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2027 (plus:<VWIDE>
2028 (mult:<VWIDE>
2029 (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
2030 (match_operand:VQW 2 "register_operand" "w")
2031 (match_operand:VQW 3 "vect_par_cnst_hi_half" "")))
2032 (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
2033 (match_operand:VQW 4 "register_operand" "w")
2034 (match_dup 3))))
2035 (match_operand:<VWIDE> 1 "register_operand" "0")))]
2036 "TARGET_SIMD"
2037 "<su>mlal2\t%0.<Vwtype>, %2.<Vtype>, %4.<Vtype>"
2038 [(set_attr "type" "neon_mla_<Vetype>_long")]
2039 )
2040
2041 (define_expand "aarch64_<su>mlal_hi<mode>"
2042 [(match_operand:<VWIDE> 0 "register_operand")
2043 (match_operand:<VWIDE> 1 "register_operand")
2044 (ANY_EXTEND:<VWIDE>(match_operand:VQW 2 "register_operand"))
2045 (match_operand:VQW 3 "register_operand")]
2046 "TARGET_SIMD"
2047 {
2048 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
2049 emit_insn (gen_aarch64_<su>mlal_hi<mode>_insn (operands[0], operands[1],
2050 operands[2], p, operands[3]));
2051 DONE;
2052 }
2053 )
2054
2055 (define_insn "aarch64_<su>mlal_hi_n<mode>_insn"
2056 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2057 (plus:<VWIDE>
2058 (mult:<VWIDE>
2059 (ANY_EXTEND:<VWIDE>
2060 (vec_select:<VHALF>
2061 (match_operand:VQ_HSI 2 "register_operand" "w")
2062 (match_operand:VQ_HSI 3 "vect_par_cnst_hi_half" "")))
2063 (vec_duplicate:<VWIDE>
2064 (ANY_EXTEND:<VWIDE_S>
2065 (match_operand:<VEL> 4 "register_operand" "<h_con>"))))
2066 (match_operand:<VWIDE> 1 "register_operand" "0")))]
2067 "TARGET_SIMD"
2068 "<su>mlal2\t%0.<Vwtype>, %2.<Vtype>, %4.<Vetype>[0]"
2069 [(set_attr "type" "neon_mla_<Vetype>_long")]
2070 )
2071
2072 (define_expand "aarch64_<su>mlal_hi_n<mode>"
2073 [(match_operand:<VWIDE> 0 "register_operand")
2074 (match_operand:<VWIDE> 1 "register_operand")
2075 (ANY_EXTEND:<VWIDE>(match_operand:VQ_HSI 2 "register_operand"))
2076 (match_operand:<VEL> 3 "register_operand")]
2077 "TARGET_SIMD"
2078 {
2079 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
2080 emit_insn (gen_aarch64_<su>mlal_hi_n<mode>_insn (operands[0],
2081 operands[1], operands[2], p, operands[3]));
2082 DONE;
2083 }
2084 )
2085
2086 (define_insn "*aarch64_<su>mlsl_lo<mode>"
2087 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2088 (minus:<VWIDE>
2089 (match_operand:<VWIDE> 1 "register_operand" "0")
2090 (mult:<VWIDE>
2091 (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
2092 (match_operand:VQW 2 "register_operand" "w")
2093 (match_operand:VQW 3 "vect_par_cnst_lo_half" "")))
2094 (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
2095 (match_operand:VQW 4 "register_operand" "w")
2096 (match_dup 3))))))]
2097 "TARGET_SIMD"
2098 "<su>mlsl\t%0.<Vwtype>, %2.<Vhalftype>, %4.<Vhalftype>"
2099 [(set_attr "type" "neon_mla_<Vetype>_long")]
2100 )
2101
2102 (define_insn "aarch64_<su>mlsl_hi<mode>_insn"
2103 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2104 (minus:<VWIDE>
2105 (match_operand:<VWIDE> 1 "register_operand" "0")
2106 (mult:<VWIDE>
2107 (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
2108 (match_operand:VQW 2 "register_operand" "w")
2109 (match_operand:VQW 3 "vect_par_cnst_hi_half" "")))
2110 (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
2111 (match_operand:VQW 4 "register_operand" "w")
2112 (match_dup 3))))))]
2113 "TARGET_SIMD"
2114 "<su>mlsl2\t%0.<Vwtype>, %2.<Vtype>, %4.<Vtype>"
2115 [(set_attr "type" "neon_mla_<Vetype>_long")]
2116 )
2117
2118 (define_expand "aarch64_<su>mlsl_hi<mode>"
2119 [(match_operand:<VWIDE> 0 "register_operand")
2120 (match_operand:<VWIDE> 1 "register_operand")
2121 (ANY_EXTEND:<VWIDE>(match_operand:VQW 2 "register_operand"))
2122 (match_operand:VQW 3 "register_operand")]
2123 "TARGET_SIMD"
2124 {
2125 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
2126 emit_insn (gen_aarch64_<su>mlsl_hi<mode>_insn (operands[0], operands[1],
2127 operands[2], p, operands[3]));
2128 DONE;
2129 }
2130 )
2131
2132 (define_insn "aarch64_<su>mlsl_hi_n<mode>_insn"
2133 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2134 (minus:<VWIDE>
2135 (match_operand:<VWIDE> 1 "register_operand" "0")
2136 (mult:<VWIDE>
2137 (ANY_EXTEND:<VWIDE>
2138 (vec_select:<VHALF>
2139 (match_operand:VQ_HSI 2 "register_operand" "w")
2140 (match_operand:VQ_HSI 3 "vect_par_cnst_hi_half" "")))
2141 (vec_duplicate:<VWIDE>
2142 (ANY_EXTEND:<VWIDE_S>
2143 (match_operand:<VEL> 4 "register_operand" "<h_con>"))))))]
2144 "TARGET_SIMD"
2145 "<su>mlsl2\t%0.<Vwtype>, %2.<Vtype>, %4.<Vetype>[0]"
2146 [(set_attr "type" "neon_mla_<Vetype>_long")]
2147 )
2148
2149 (define_expand "aarch64_<su>mlsl_hi_n<mode>"
2150 [(match_operand:<VWIDE> 0 "register_operand")
2151 (match_operand:<VWIDE> 1 "register_operand")
2152 (ANY_EXTEND:<VWIDE>(match_operand:VQ_HSI 2 "register_operand"))
2153 (match_operand:<VEL> 3 "register_operand")]
2154 "TARGET_SIMD"
2155 {
2156 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
2157 emit_insn (gen_aarch64_<su>mlsl_hi_n<mode>_insn (operands[0],
2158 operands[1], operands[2], p, operands[3]));
2159 DONE;
2160 }
2161 )
2162
2163 (define_insn "aarch64_<su>mlal<mode>"
2164 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2165 (plus:<VWIDE>
2166 (mult:<VWIDE>
2167 (ANY_EXTEND:<VWIDE>
2168 (match_operand:VD_BHSI 2 "register_operand" "w"))
2169 (ANY_EXTEND:<VWIDE>
2170 (match_operand:VD_BHSI 3 "register_operand" "w")))
2171 (match_operand:<VWIDE> 1 "register_operand" "0")))]
2172 "TARGET_SIMD"
2173 "<su>mlal\t%0.<Vwtype>, %2.<Vtype>, %3.<Vtype>"
2174 [(set_attr "type" "neon_mla_<Vetype>_long")]
2175 )
2176
2177 (define_insn "aarch64_<su>mlal_n<mode>"
2178 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2179 (plus:<VWIDE>
2180 (mult:<VWIDE>
2181 (ANY_EXTEND:<VWIDE>
2182 (match_operand:VD_HSI 2 "register_operand" "w"))
2183 (vec_duplicate:<VWIDE>
2184 (ANY_EXTEND:<VWIDE_S>
2185 (match_operand:<VEL> 3 "register_operand" "<h_con>"))))
2186 (match_operand:<VWIDE> 1 "register_operand" "0")))]
2187 "TARGET_SIMD"
2188 "<su>mlal\t%0.<Vwtype>, %2.<Vtype>, %3.<Vetype>[0]"
2189 [(set_attr "type" "neon_mla_<Vetype>_long")]
2190 )
2191
2192 (define_insn "aarch64_<su>mlsl<mode>"
2193 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2194 (minus:<VWIDE>
2195 (match_operand:<VWIDE> 1 "register_operand" "0")
2196 (mult:<VWIDE>
2197 (ANY_EXTEND:<VWIDE>
2198 (match_operand:VD_BHSI 2 "register_operand" "w"))
2199 (ANY_EXTEND:<VWIDE>
2200 (match_operand:VD_BHSI 3 "register_operand" "w")))))]
2201 "TARGET_SIMD"
2202 "<su>mlsl\t%0.<Vwtype>, %2.<Vtype>, %3.<Vtype>"
2203 [(set_attr "type" "neon_mla_<Vetype>_long")]
2204 )
2205
2206 (define_insn "aarch64_<su>mlsl_n<mode>"
2207 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2208 (minus:<VWIDE>
2209 (match_operand:<VWIDE> 1 "register_operand" "0")
2210 (mult:<VWIDE>
2211 (ANY_EXTEND:<VWIDE>
2212 (match_operand:VD_HSI 2 "register_operand" "w"))
2213 (vec_duplicate:<VWIDE>
2214 (ANY_EXTEND:<VWIDE_S>
2215 (match_operand:<VEL> 3 "register_operand" "<h_con>"))))))]
2216 "TARGET_SIMD"
2217 "<su>mlsl\t%0.<Vwtype>, %2.<Vtype>, %3.<Vetype>[0]"
2218 [(set_attr "type" "neon_mla_<Vetype>_long")]
2219 )
2220
2221 (define_insn "aarch64_simd_vec_<su>mult_lo_<mode>"
2222 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2223 (mult:<VWIDE> (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
2224 (match_operand:VQW 1 "register_operand" "w")
2225 (match_operand:VQW 3 "vect_par_cnst_lo_half" "")))
2226 (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
2227 (match_operand:VQW 2 "register_operand" "w")
2228 (match_dup 3)))))]
2229 "TARGET_SIMD"
2230 "<su>mull\\t%0.<Vwtype>, %1.<Vhalftype>, %2.<Vhalftype>"
2231 [(set_attr "type" "neon_mul_<Vetype>_long")]
2232 )
2233
2234 (define_insn "aarch64_intrinsic_vec_<su>mult_lo_<mode>"
2235 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2236 (mult:<VWIDE> (ANY_EXTEND:<VWIDE>
2237 (match_operand:VD_BHSI 1 "register_operand" "w"))
2238 (ANY_EXTEND:<VWIDE>
2239 (match_operand:VD_BHSI 2 "register_operand" "w"))))]
2240 "TARGET_SIMD"
2241 "<su>mull\\t%0.<Vwtype>, %1.<Vtype>, %2.<Vtype>"
2242 [(set_attr "type" "neon_mul_<Vetype>_long")]
2243 )
2244
2245 (define_expand "vec_widen_<su>mult_lo_<mode>"
2246 [(match_operand:<VWIDE> 0 "register_operand")
2247 (ANY_EXTEND:<VWIDE> (match_operand:VQW 1 "register_operand"))
2248 (ANY_EXTEND:<VWIDE> (match_operand:VQW 2 "register_operand"))]
2249 "TARGET_SIMD"
2250 {
2251 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, false);
2252 emit_insn (gen_aarch64_simd_vec_<su>mult_lo_<mode> (operands[0],
2253 operands[1],
2254 operands[2], p));
2255 DONE;
2256 }
2257 )
2258
2259 (define_insn "aarch64_simd_vec_<su>mult_hi_<mode>"
2260 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2261 (mult:<VWIDE> (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
2262 (match_operand:VQW 1 "register_operand" "w")
2263 (match_operand:VQW 3 "vect_par_cnst_hi_half" "")))
2264 (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
2265 (match_operand:VQW 2 "register_operand" "w")
2266 (match_dup 3)))))]
2267 "TARGET_SIMD"
2268 "<su>mull2\\t%0.<Vwtype>, %1.<Vtype>, %2.<Vtype>"
2269 [(set_attr "type" "neon_mul_<Vetype>_long")]
2270 )
2271
2272 (define_expand "vec_widen_<su>mult_hi_<mode>"
2273 [(match_operand:<VWIDE> 0 "register_operand")
2274 (ANY_EXTEND:<VWIDE> (match_operand:VQW 1 "register_operand"))
2275 (ANY_EXTEND:<VWIDE> (match_operand:VQW 2 "register_operand"))]
2276 "TARGET_SIMD"
2277 {
2278 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
2279 emit_insn (gen_aarch64_simd_vec_<su>mult_hi_<mode> (operands[0],
2280 operands[1],
2281 operands[2], p));
2282 DONE;
2283
2284 }
2285 )
2286
2287 ;; vmull_lane_s16 intrinsics
2288 (define_insn "aarch64_vec_<su>mult_lane<Qlane>"
2289 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2290 (mult:<VWIDE>
2291 (ANY_EXTEND:<VWIDE>
2292 (match_operand:<VCOND> 1 "register_operand" "w"))
2293 (vec_duplicate:<VWIDE>
2294 (ANY_EXTEND:<VWIDE_S>
2295 (vec_select:<VEL>
2296 (match_operand:VDQHS 2 "register_operand" "<vwx>")
2297 (parallel [(match_operand:SI 3 "immediate_operand" "i")]))))))]
2298 "TARGET_SIMD"
2299 {
2300 operands[3] = aarch64_endian_lane_rtx (<MODE>mode, INTVAL (operands[3]));
2301 return "<su>mull\\t%0.<Vwtype>, %1.<Vcondtype>, %2.<Vetype>[%3]";
2302 }
2303 [(set_attr "type" "neon_mul_<Vetype>_scalar_long")]
2304 )
2305
2306 (define_insn "aarch64_<su>mull_hi_lane<mode>_insn"
2307 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2308 (mult:<VWIDE>
2309 (ANY_EXTEND:<VWIDE>
2310 (vec_select:<VHALF>
2311 (match_operand:VQ_HSI 1 "register_operand" "w")
2312 (match_operand:VQ_HSI 2 "vect_par_cnst_hi_half" "")))
2313 (vec_duplicate:<VWIDE>
2314 (ANY_EXTEND:<VWIDE_S>
2315 (vec_select:<VEL>
2316 (match_operand:<VCOND> 3 "register_operand" "<vwx>")
2317 (parallel [(match_operand:SI 4 "immediate_operand" "i")]))))))]
2318 "TARGET_SIMD"
2319 {
2320 operands[4] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[4]));
2321 return "<su>mull2\\t%0.<Vwtype>, %1.<Vtype>, %3.<Vetype>[%4]";
2322 }
2323 [(set_attr "type" "neon_mul_<Vetype>_scalar_long")]
2324 )
2325
2326 (define_expand "aarch64_<su>mull_hi_lane<mode>"
2327 [(match_operand:<VWIDE> 0 "register_operand")
2328 (ANY_EXTEND:<VWIDE>(match_operand:VQ_HSI 1 "register_operand"))
2329 (match_operand:<VCOND> 2 "register_operand")
2330 (match_operand:SI 3 "immediate_operand")]
2331 "TARGET_SIMD"
2332 {
2333 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
2334 emit_insn (gen_aarch64_<su>mull_hi_lane<mode>_insn (operands[0],
2335 operands[1], p, operands[2], operands[3]));
2336 DONE;
2337 }
2338 )
2339
2340 (define_insn "aarch64_<su>mull_hi_laneq<mode>_insn"
2341 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2342 (mult:<VWIDE>
2343 (ANY_EXTEND:<VWIDE>
2344 (vec_select:<VHALF>
2345 (match_operand:VQ_HSI 1 "register_operand" "w")
2346 (match_operand:VQ_HSI 2 "vect_par_cnst_hi_half" "")))
2347 (vec_duplicate:<VWIDE>
2348 (ANY_EXTEND:<VWIDE_S>
2349 (vec_select:<VEL>
2350 (match_operand:<VCONQ> 3 "register_operand" "<vwx>")
2351 (parallel [(match_operand:SI 4 "immediate_operand" "i")]))))))]
2352 "TARGET_SIMD"
2353 {
2354 operands[4] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[4]));
2355 return "<su>mull2\\t%0.<Vwtype>, %1.<Vtype>, %3.<Vetype>[%4]";
2356 }
2357 [(set_attr "type" "neon_mul_<Vetype>_scalar_long")]
2358 )
2359
2360 (define_expand "aarch64_<su>mull_hi_laneq<mode>"
2361 [(match_operand:<VWIDE> 0 "register_operand")
2362 (ANY_EXTEND:<VWIDE>(match_operand:VQ_HSI 1 "register_operand"))
2363 (match_operand:<VCONQ> 2 "register_operand")
2364 (match_operand:SI 3 "immediate_operand")]
2365 "TARGET_SIMD"
2366 {
2367 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
2368 emit_insn (gen_aarch64_<su>mull_hi_laneq<mode>_insn (operands[0],
2369 operands[1], p, operands[2], operands[3]));
2370 DONE;
2371 }
2372 )
2373
2374 (define_insn "aarch64_<su>mull_n<mode>"
2375 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2376 (mult:<VWIDE>
2377 (ANY_EXTEND:<VWIDE>
2378 (match_operand:VD_HSI 1 "register_operand" "w"))
2379 (vec_duplicate:<VWIDE>
2380 (ANY_EXTEND:<VWIDE_S>
2381 (match_operand:<VEL> 2 "register_operand" "<h_con>")))))]
2382 "TARGET_SIMD"
2383 "<su>mull\t%0.<Vwtype>, %1.<Vtype>, %2.<Vetype>[0]"
2384 [(set_attr "type" "neon_mul_<Vetype>_scalar_long")]
2385 )
2386
2387 (define_insn "aarch64_<su>mull_hi_n<mode>_insn"
2388 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2389 (mult:<VWIDE>
2390 (ANY_EXTEND:<VWIDE>
2391 (vec_select:<VHALF>
2392 (match_operand:VQ_HSI 1 "register_operand" "w")
2393 (match_operand:VQ_HSI 3 "vect_par_cnst_hi_half" "")))
2394 (vec_duplicate:<VWIDE>
2395 (ANY_EXTEND:<VWIDE_S>
2396 (match_operand:<VEL> 2 "register_operand" "<h_con>")))))]
2397 "TARGET_SIMD"
2398 "<su>mull2\\t%0.<Vwtype>, %1.<Vtype>, %2.<Vetype>[0]"
2399 [(set_attr "type" "neon_mul_<Vetype>_scalar_long")]
2400 )
2401
2402 (define_expand "aarch64_<su>mull_hi_n<mode>"
2403 [(match_operand:<VWIDE> 0 "register_operand")
2404 (ANY_EXTEND:<VWIDE> (match_operand:VQ_HSI 1 "register_operand"))
2405 (match_operand:<VEL> 2 "register_operand")]
2406 "TARGET_SIMD"
2407 {
2408 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
2409 emit_insn (gen_aarch64_<su>mull_hi_n<mode>_insn (operands[0], operands[1],
2410 operands[2], p));
2411 DONE;
2412 }
2413 )
2414
2415 ;; vmlal_lane_s16 intrinsics
2416 (define_insn "aarch64_vec_<su>mlal_lane<Qlane>"
2417 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2418 (plus:<VWIDE>
2419 (mult:<VWIDE>
2420 (ANY_EXTEND:<VWIDE>
2421 (match_operand:<VCOND> 2 "register_operand" "w"))
2422 (vec_duplicate:<VWIDE>
2423 (ANY_EXTEND:<VWIDE_S>
2424 (vec_select:<VEL>
2425 (match_operand:VDQHS 3 "register_operand" "<vwx>")
2426 (parallel [(match_operand:SI 4 "immediate_operand" "i")])))))
2427 (match_operand:<VWIDE> 1 "register_operand" "0")))]
2428 "TARGET_SIMD"
2429 {
2430 operands[4] = aarch64_endian_lane_rtx (<MODE>mode, INTVAL (operands[4]));
2431 return "<su>mlal\\t%0.<Vwtype>, %2.<Vcondtype>, %3.<Vetype>[%4]";
2432 }
2433 [(set_attr "type" "neon_mla_<Vetype>_scalar_long")]
2434 )
2435
2436 (define_insn "aarch64_<su>mlal_hi_lane<mode>_insn"
2437 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2438 (plus:<VWIDE>
2439 (mult:<VWIDE>
2440 (ANY_EXTEND:<VWIDE>
2441 (vec_select:<VHALF>
2442 (match_operand:VQ_HSI 2 "register_operand" "w")
2443 (match_operand:VQ_HSI 3 "vect_par_cnst_hi_half" "")))
2444 (vec_duplicate:<VWIDE>
2445 (ANY_EXTEND:<VWIDE_S>
2446 (vec_select:<VEL>
2447 (match_operand:<VCOND> 4 "register_operand" "<vwx>")
2448 (parallel [(match_operand:SI 5 "immediate_operand" "i")])))))
2449 (match_operand:<VWIDE> 1 "register_operand" "0")))]
2450 "TARGET_SIMD"
2451 {
2452 operands[5] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[5]));
2453 return "<su>mlal2\\t%0.<Vwtype>, %2.<Vtype>, %4.<Vetype>[%5]";
2454 }
2455 [(set_attr "type" "neon_mla_<Vetype>_scalar_long")]
2456 )
2457
2458 (define_expand "aarch64_<su>mlal_hi_lane<mode>"
2459 [(match_operand:<VWIDE> 0 "register_operand")
2460 (match_operand:<VWIDE> 1 "register_operand")
2461 (ANY_EXTEND:<VWIDE>(match_operand:VQ_HSI 2 "register_operand"))
2462 (match_operand:<VCOND> 3 "register_operand")
2463 (match_operand:SI 4 "immediate_operand")]
2464 "TARGET_SIMD"
2465 {
2466 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
2467 emit_insn (gen_aarch64_<su>mlal_hi_lane<mode>_insn (operands[0],
2468 operands[1], operands[2], p, operands[3], operands[4]));
2469 DONE;
2470 }
2471 )
2472
2473 (define_insn "aarch64_<su>mlal_hi_laneq<mode>_insn"
2474 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2475 (plus:<VWIDE>
2476 (mult:<VWIDE>
2477 (ANY_EXTEND:<VWIDE>
2478 (vec_select:<VHALF>
2479 (match_operand:VQ_HSI 2 "register_operand" "w")
2480 (match_operand:VQ_HSI 3 "vect_par_cnst_hi_half" "")))
2481 (vec_duplicate:<VWIDE>
2482 (ANY_EXTEND:<VWIDE_S>
2483 (vec_select:<VEL>
2484 (match_operand:<VCONQ> 4 "register_operand" "<vwx>")
2485 (parallel [(match_operand:SI 5 "immediate_operand" "i")])))))
2486 (match_operand:<VWIDE> 1 "register_operand" "0")))]
2487 "TARGET_SIMD"
2488 {
2489 operands[5] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[5]));
2490 return "<su>mlal2\\t%0.<Vwtype>, %2.<Vtype>, %4.<Vetype>[%5]";
2491 }
2492 [(set_attr "type" "neon_mla_<Vetype>_scalar_long")]
2493 )
2494
2495 (define_expand "aarch64_<su>mlal_hi_laneq<mode>"
2496 [(match_operand:<VWIDE> 0 "register_operand")
2497 (match_operand:<VWIDE> 1 "register_operand")
2498 (ANY_EXTEND:<VWIDE>(match_operand:VQ_HSI 2 "register_operand"))
2499 (match_operand:<VCONQ> 3 "register_operand")
2500 (match_operand:SI 4 "immediate_operand")]
2501 "TARGET_SIMD"
2502 {
2503 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
2504 emit_insn (gen_aarch64_<su>mlal_hi_laneq<mode>_insn (operands[0],
2505 operands[1], operands[2], p, operands[3], operands[4]));
2506 DONE;
2507 }
2508 )
2509
2510 (define_insn "aarch64_vec_<su>mlsl_lane<Qlane>"
2511 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2512 (minus:<VWIDE>
2513 (match_operand:<VWIDE> 1 "register_operand" "0")
2514 (mult:<VWIDE>
2515 (ANY_EXTEND:<VWIDE>
2516 (match_operand:<VCOND> 2 "register_operand" "w"))
2517 (vec_duplicate:<VWIDE>
2518 (ANY_EXTEND:<VWIDE_S>
2519 (vec_select:<VEL>
2520 (match_operand:VDQHS 3 "register_operand" "<vwx>")
2521 (parallel [(match_operand:SI 4 "immediate_operand" "i")])))))))]
2522 "TARGET_SIMD"
2523 {
2524 operands[4] = aarch64_endian_lane_rtx (<MODE>mode, INTVAL (operands[4]));
2525 return "<su>mlsl\\t%0.<Vwtype>, %2.<Vcondtype>, %3.<Vetype>[%4]";
2526 }
2527 [(set_attr "type" "neon_mla_<Vetype>_scalar_long")]
2528 )
2529
2530 (define_insn "aarch64_<su>mlsl_hi_lane<mode>_insn"
2531 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2532 (minus:<VWIDE>
2533 (match_operand:<VWIDE> 1 "register_operand" "0")
2534 (mult:<VWIDE>
2535 (ANY_EXTEND:<VWIDE>
2536 (vec_select:<VHALF>
2537 (match_operand:VQ_HSI 2 "register_operand" "w")
2538 (match_operand:VQ_HSI 3 "vect_par_cnst_hi_half" "")))
2539 (vec_duplicate:<VWIDE>
2540 (ANY_EXTEND:<VWIDE_S>
2541 (vec_select:<VEL>
2542 (match_operand:<VCOND> 4 "register_operand" "<vwx>")
2543 (parallel [(match_operand:SI 5 "immediate_operand" "i")]))))
2544 )))]
2545 "TARGET_SIMD"
2546 {
2547 operands[5] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[5]));
2548 return "<su>mlsl2\\t%0.<Vwtype>, %2.<Vtype>, %4.<Vetype>[%5]";
2549 }
2550 [(set_attr "type" "neon_mla_<Vetype>_scalar_long")]
2551 )
2552
2553 (define_expand "aarch64_<su>mlsl_hi_lane<mode>"
2554 [(match_operand:<VWIDE> 0 "register_operand")
2555 (match_operand:<VWIDE> 1 "register_operand")
2556 (ANY_EXTEND:<VWIDE>(match_operand:VQ_HSI 2 "register_operand"))
2557 (match_operand:<VCOND> 3 "register_operand")
2558 (match_operand:SI 4 "immediate_operand")]
2559 "TARGET_SIMD"
2560 {
2561 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
2562 emit_insn (gen_aarch64_<su>mlsl_hi_lane<mode>_insn (operands[0],
2563 operands[1], operands[2], p, operands[3], operands[4]));
2564 DONE;
2565 }
2566 )
2567
2568 (define_insn "aarch64_<su>mlsl_hi_laneq<mode>_insn"
2569 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
2570 (minus:<VWIDE>
2571 (match_operand:<VWIDE> 1 "register_operand" "0")
2572 (mult:<VWIDE>
2573 (ANY_EXTEND:<VWIDE>
2574 (vec_select:<VHALF>
2575 (match_operand:VQ_HSI 2 "register_operand" "w")
2576 (match_operand:VQ_HSI 3 "vect_par_cnst_hi_half" "")))
2577 (vec_duplicate:<VWIDE>
2578 (ANY_EXTEND:<VWIDE_S>
2579 (vec_select:<VEL>
2580 (match_operand:<VCONQ> 4 "register_operand" "<vwx>")
2581 (parallel [(match_operand:SI 5 "immediate_operand" "i")]))))
2582 )))]
2583 "TARGET_SIMD"
2584 {
2585 operands[5] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[5]));
2586 return "<su>mlsl2\\t%0.<Vwtype>, %2.<Vtype>, %4.<Vetype>[%5]";
2587 }
2588 [(set_attr "type" "neon_mla_<Vetype>_scalar_long")]
2589 )
2590
2591 (define_expand "aarch64_<su>mlsl_hi_laneq<mode>"
2592 [(match_operand:<VWIDE> 0 "register_operand")
2593 (match_operand:<VWIDE> 1 "register_operand")
2594 (ANY_EXTEND:<VWIDE>(match_operand:VQ_HSI 2 "register_operand"))
2595 (match_operand:<VCONQ> 3 "register_operand")
2596 (match_operand:SI 4 "immediate_operand")]
2597 "TARGET_SIMD"
2598 {
2599 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
2600 emit_insn (gen_aarch64_<su>mlsl_hi_laneq<mode>_insn (operands[0],
2601 operands[1], operands[2], p, operands[3], operands[4]));
2602 DONE;
2603 }
2604 )
2605
2606 ;; FP vector operations.
2607 ;; AArch64 AdvSIMD supports single-precision (32-bit) and
2608 ;; double-precision (64-bit) floating-point data types and arithmetic as
2609 ;; defined by the IEEE 754-2008 standard. This makes them vectorizable
2610 ;; without the need for -ffast-math or -funsafe-math-optimizations.
2611 ;;
2612 ;; Floating-point operations can raise an exception. Vectorizing such
2613 ;; operations are safe because of reasons explained below.
2614 ;;
2615 ;; ARMv8 permits an extension to enable trapped floating-point
2616 ;; exception handling, however this is an optional feature. In the
2617 ;; event of a floating-point exception being raised by vectorised
2618 ;; code then:
2619 ;; 1. If trapped floating-point exceptions are available, then a trap
2620 ;; will be taken when any lane raises an enabled exception. A trap
2621 ;; handler may determine which lane raised the exception.
2622 ;; 2. Alternatively a sticky exception flag is set in the
2623 ;; floating-point status register (FPSR). Software may explicitly
2624 ;; test the exception flags, in which case the tests will either
2625 ;; prevent vectorisation, allowing precise identification of the
2626 ;; failing operation, or if tested outside of vectorisable regions
2627 ;; then the specific operation and lane are not of interest.
2628
2629 ;; FP arithmetic operations.
2630
2631 (define_insn "add<mode>3<vczle><vczbe>"
2632 [(set (match_operand:VHSDF 0 "register_operand" "=w")
2633 (plus:VHSDF (match_operand:VHSDF 1 "register_operand" "w")
2634 (match_operand:VHSDF 2 "register_operand" "w")))]
2635 "TARGET_SIMD"
2636 "fadd\\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
2637 [(set_attr "type" "neon_fp_addsub_<stype><q>")]
2638 )
2639
2640 (define_insn "sub<mode>3<vczle><vczbe>"
2641 [(set (match_operand:VHSDF 0 "register_operand" "=w")
2642 (minus:VHSDF (match_operand:VHSDF 1 "register_operand" "w")
2643 (match_operand:VHSDF 2 "register_operand" "w")))]
2644 "TARGET_SIMD"
2645 "fsub\\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
2646 [(set_attr "type" "neon_fp_addsub_<stype><q>")]
2647 )
2648
2649 (define_insn "mul<mode>3<vczle><vczbe>"
2650 [(set (match_operand:VHSDF 0 "register_operand" "=w")
2651 (mult:VHSDF (match_operand:VHSDF 1 "register_operand" "w")
2652 (match_operand:VHSDF 2 "register_operand" "w")))]
2653 "TARGET_SIMD"
2654 "fmul\\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
2655 [(set_attr "type" "neon_fp_mul_<stype><q>")]
2656 )
2657
2658 (define_expand "div<mode>3"
2659 [(set (match_operand:VHSDF 0 "register_operand")
2660 (div:VHSDF (match_operand:VHSDF 1 "register_operand")
2661 (match_operand:VHSDF 2 "register_operand")))]
2662 "TARGET_SIMD"
2663 {
2664 if (aarch64_emit_approx_div (operands[0], operands[1], operands[2]))
2665 DONE;
2666
2667 operands[1] = force_reg (<MODE>mode, operands[1]);
2668 })
2669
2670 (define_insn "*div<mode>3<vczle><vczbe>"
2671 [(set (match_operand:VHSDF 0 "register_operand" "=w")
2672 (div:VHSDF (match_operand:VHSDF 1 "register_operand" "w")
2673 (match_operand:VHSDF 2 "register_operand" "w")))]
2674 "TARGET_SIMD"
2675 "fdiv\\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
2676 [(set_attr "type" "neon_fp_div_<stype><q>")]
2677 )
2678
2679 (define_insn "neg<mode>2<vczle><vczbe>"
2680 [(set (match_operand:VHSDF 0 "register_operand" "=w")
2681 (neg:VHSDF (match_operand:VHSDF 1 "register_operand" "w")))]
2682 "TARGET_SIMD"
2683 "fneg\\t%0.<Vtype>, %1.<Vtype>"
2684 [(set_attr "type" "neon_fp_neg_<stype><q>")]
2685 )
2686
2687 (define_insn "aarch64_fnegv2di2<vczle><vczbe>"
2688 [(set (match_operand:V2DI 0 "register_operand" "=w")
2689 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "w")]
2690 UNSPEC_FNEG))]
2691 "TARGET_SIMD"
2692 "fneg\\t%0.2d, %1.2d"
2693 [(set_attr "type" "neon_fp_neg_d")]
2694 )
2695
2696 (define_insn "abs<mode>2<vczle><vczbe>"
2697 [(set (match_operand:VHSDF 0 "register_operand" "=w")
2698 (abs:VHSDF (match_operand:VHSDF 1 "register_operand" "w")))]
2699 "TARGET_SIMD"
2700 "fabs\\t%0.<Vtype>, %1.<Vtype>"
2701 [(set_attr "type" "neon_fp_abs_<stype><q>")]
2702 )
2703
2704 (define_expand "aarch64_float_mla<mode>"
2705 [(set (match_operand:VDQF_DF 0 "register_operand")
2706 (plus:VDQF_DF
2707 (mult:VDQF_DF
2708 (match_operand:VDQF_DF 2 "register_operand")
2709 (match_operand:VDQF_DF 3 "register_operand"))
2710 (match_operand:VDQF_DF 1 "register_operand")))]
2711 "TARGET_SIMD"
2712 {
2713 rtx scratch = gen_reg_rtx (<MODE>mode);
2714 emit_insn (gen_mul<mode>3 (scratch, operands[2], operands[3]));
2715 emit_insn (gen_add<mode>3 (operands[0], operands[1], scratch));
2716 DONE;
2717 }
2718 )
2719
2720 (define_expand "aarch64_float_mls<mode>"
2721 [(set (match_operand:VDQF_DF 0 "register_operand")
2722 (minus:VDQF_DF
2723 (match_operand:VDQF_DF 1 "register_operand")
2724 (mult:VDQF_DF
2725 (match_operand:VDQF_DF 2 "register_operand")
2726 (match_operand:VDQF_DF 3 "register_operand"))))]
2727 "TARGET_SIMD"
2728 {
2729 rtx scratch = gen_reg_rtx (<MODE>mode);
2730 emit_insn (gen_mul<mode>3 (scratch, operands[2], operands[3]));
2731 emit_insn (gen_sub<mode>3 (operands[0], operands[1], scratch));
2732 DONE;
2733 }
2734 )
2735
2736 (define_expand "aarch64_float_mla_n<mode>"
2737 [(set (match_operand:VDQSF 0 "register_operand")
2738 (plus:VDQSF
2739 (mult:VDQSF
2740 (vec_duplicate:VDQSF
2741 (match_operand:<VEL> 3 "register_operand"))
2742 (match_operand:VDQSF 2 "register_operand"))
2743 (match_operand:VDQSF 1 "register_operand")))]
2744 "TARGET_SIMD"
2745 {
2746 rtx scratch = gen_reg_rtx (<MODE>mode);
2747 emit_insn (gen_mul_n<mode>3 (scratch, operands[2], operands[3]));
2748 emit_insn (gen_add<mode>3 (operands[0], operands[1], scratch));
2749 DONE;
2750 }
2751 )
2752
2753 (define_expand "aarch64_float_mls_n<mode>"
2754 [(set (match_operand:VDQSF 0 "register_operand")
2755 (minus:VDQSF
2756 (match_operand:VDQSF 1 "register_operand")
2757 (mult:VDQSF
2758 (vec_duplicate:VDQSF
2759 (match_operand:<VEL> 3 "register_operand"))
2760 (match_operand:VDQSF 2 "register_operand"))))]
2761 "TARGET_SIMD"
2762 {
2763 rtx scratch = gen_reg_rtx (<MODE>mode);
2764 emit_insn (gen_mul_n<mode>3 (scratch, operands[2], operands[3]));
2765 emit_insn (gen_sub<mode>3 (operands[0], operands[1], scratch));
2766 DONE;
2767 }
2768 )
2769
2770 (define_expand "aarch64_float_mla_lane<mode>"
2771 [(set (match_operand:VDQSF 0 "register_operand")
2772 (plus:VDQSF
2773 (mult:VDQSF
2774 (vec_duplicate:VDQSF
2775 (vec_select:<VEL>
2776 (match_operand:V2SF 3 "register_operand")
2777 (parallel [(match_operand:SI 4 "immediate_operand")])))
2778 (match_operand:VDQSF 2 "register_operand"))
2779 (match_operand:VDQSF 1 "register_operand")))]
2780 "TARGET_SIMD"
2781 {
2782 rtx scratch = gen_reg_rtx (<MODE>mode);
2783 emit_insn (gen_mul_lane<mode>3 (scratch, operands[2],
2784 operands[3], operands[4]));
2785 emit_insn (gen_add<mode>3 (operands[0], operands[1], scratch));
2786 DONE;
2787 }
2788 )
2789
2790 (define_expand "aarch64_float_mls_lane<mode>"
2791 [(set (match_operand:VDQSF 0 "register_operand")
2792 (minus:VDQSF
2793 (match_operand:VDQSF 1 "register_operand")
2794 (mult:VDQSF
2795 (vec_duplicate:VDQSF
2796 (vec_select:<VEL>
2797 (match_operand:V2SF 3 "register_operand")
2798 (parallel [(match_operand:SI 4 "immediate_operand")])))
2799 (match_operand:VDQSF 2 "register_operand"))))]
2800 "TARGET_SIMD"
2801 {
2802 rtx scratch = gen_reg_rtx (<MODE>mode);
2803 emit_insn (gen_mul_lane<mode>3 (scratch, operands[2],
2804 operands[3], operands[4]));
2805 emit_insn (gen_sub<mode>3 (operands[0], operands[1], scratch));
2806 DONE;
2807 }
2808 )
2809
2810 (define_expand "aarch64_float_mla_laneq<mode>"
2811 [(set (match_operand:VDQSF 0 "register_operand")
2812 (plus:VDQSF
2813 (mult:VDQSF
2814 (vec_duplicate:VDQSF
2815 (vec_select:<VEL>
2816 (match_operand:V4SF 3 "register_operand")
2817 (parallel [(match_operand:SI 4 "immediate_operand")])))
2818 (match_operand:VDQSF 2 "register_operand"))
2819 (match_operand:VDQSF 1 "register_operand")))]
2820 "TARGET_SIMD"
2821 {
2822 rtx scratch = gen_reg_rtx (<MODE>mode);
2823 emit_insn (gen_mul_laneq<mode>3 (scratch, operands[2],
2824 operands[3], operands[4]));
2825 emit_insn (gen_add<mode>3 (operands[0], operands[1], scratch));
2826 DONE;
2827 }
2828 )
2829
2830 (define_expand "aarch64_float_mls_laneq<mode>"
2831 [(set (match_operand:VDQSF 0 "register_operand")
2832 (minus:VDQSF
2833 (match_operand:VDQSF 1 "register_operand")
2834 (mult:VDQSF
2835 (vec_duplicate:VDQSF
2836 (vec_select:<VEL>
2837 (match_operand:V4SF 3 "register_operand")
2838 (parallel [(match_operand:SI 4 "immediate_operand")])))
2839 (match_operand:VDQSF 2 "register_operand"))))]
2840 "TARGET_SIMD"
2841 {
2842 rtx scratch = gen_reg_rtx (<MODE>mode);
2843 emit_insn (gen_mul_laneq<mode>3 (scratch, operands[2],
2844 operands[3], operands[4]));
2845 emit_insn (gen_sub<mode>3 (operands[0], operands[1], scratch));
2846 DONE;
2847 }
2848 )
2849
2850 (define_insn "fma<mode>4<vczle><vczbe>"
2851 [(set (match_operand:VHSDF 0 "register_operand" "=w")
2852 (fma:VHSDF (match_operand:VHSDF 1 "register_operand" "w")
2853 (match_operand:VHSDF 2 "register_operand" "w")
2854 (match_operand:VHSDF 3 "register_operand" "0")))]
2855 "TARGET_SIMD"
2856 "fmla\\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
2857 [(set_attr "type" "neon_fp_mla_<stype><q>")]
2858 )
2859
2860 (define_insn "*aarch64_fma4_elt<mode><vczle><vczbe>"
2861 [(set (match_operand:VDQF 0 "register_operand" "=w")
2862 (fma:VDQF
2863 (vec_duplicate:VDQF
2864 (vec_select:<VEL>
2865 (match_operand:VDQF 1 "register_operand" "<h_con>")
2866 (parallel [(match_operand:SI 2 "immediate_operand")])))
2867 (match_operand:VDQF 3 "register_operand" "w")
2868 (match_operand:VDQF 4 "register_operand" "0")))]
2869 "TARGET_SIMD"
2870 {
2871 operands[2] = aarch64_endian_lane_rtx (<MODE>mode, INTVAL (operands[2]));
2872 return "fmla\\t%0.<Vtype>, %3.<Vtype>, %1.<Vetype>[%2]";
2873 }
2874 [(set_attr "type" "neon_fp_mla_<Vetype>_scalar<q>")]
2875 )
2876
2877 (define_insn "*aarch64_fma4_elt_<vswap_width_name><mode><vczle><vczbe>"
2878 [(set (match_operand:VDQSF 0 "register_operand" "=w")
2879 (fma:VDQSF
2880 (vec_duplicate:VDQSF
2881 (vec_select:<VEL>
2882 (match_operand:<VSWAP_WIDTH> 1 "register_operand" "<h_con>")
2883 (parallel [(match_operand:SI 2 "immediate_operand")])))
2884 (match_operand:VDQSF 3 "register_operand" "w")
2885 (match_operand:VDQSF 4 "register_operand" "0")))]
2886 "TARGET_SIMD"
2887 {
2888 operands[2] = aarch64_endian_lane_rtx (<VSWAP_WIDTH>mode, INTVAL (operands[2]));
2889 return "fmla\\t%0.<Vtype>, %3.<Vtype>, %1.<Vetype>[%2]";
2890 }
2891 [(set_attr "type" "neon_fp_mla_<Vetype>_scalar<q>")]
2892 )
2893
2894 (define_insn "*aarch64_fma4_elt_from_dup<mode><vczle><vczbe>"
2895 [(set (match_operand:VMUL 0 "register_operand" "=w")
2896 (fma:VMUL
2897 (vec_duplicate:VMUL
2898 (match_operand:<VEL> 1 "register_operand" "<h_con>"))
2899 (match_operand:VMUL 2 "register_operand" "w")
2900 (match_operand:VMUL 3 "register_operand" "0")))]
2901 "TARGET_SIMD"
2902 "fmla\t%0.<Vtype>, %2.<Vtype>, %1.<Vetype>[0]"
2903 [(set_attr "type" "neon<fp>_mla_<stype>_scalar<q>")]
2904 )
2905
2906 (define_insn "*aarch64_fma4_elt_to_64v2df"
2907 [(set (match_operand:DF 0 "register_operand" "=w")
2908 (fma:DF
2909 (vec_select:DF
2910 (match_operand:V2DF 1 "register_operand" "w")
2911 (parallel [(match_operand:SI 2 "immediate_operand")]))
2912 (match_operand:DF 3 "register_operand" "w")
2913 (match_operand:DF 4 "register_operand" "0")))]
2914 "TARGET_SIMD"
2915 {
2916 operands[2] = aarch64_endian_lane_rtx (V2DFmode, INTVAL (operands[2]));
2917 return "fmla\\t%0.2d, %3.2d, %1.d[%2]";
2918 }
2919 [(set_attr "type" "neon_fp_mla_d_scalar_q")]
2920 )
2921
2922 (define_insn "fnma<mode>4<vczle><vczbe>"
2923 [(set (match_operand:VHSDF 0 "register_operand" "=w")
2924 (fma:VHSDF
2925 (neg:VHSDF (match_operand:VHSDF 1 "register_operand" "w"))
2926 (match_operand:VHSDF 2 "register_operand" "w")
2927 (match_operand:VHSDF 3 "register_operand" "0")))]
2928 "TARGET_SIMD"
2929 "fmls\\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
2930 [(set_attr "type" "neon_fp_mla_<stype><q>")]
2931 )
2932
2933 (define_insn "*aarch64_fnma4_elt<mode><vczle><vczbe>"
2934 [(set (match_operand:VDQF 0 "register_operand" "=w")
2935 (fma:VDQF
2936 (neg:VDQF
2937 (match_operand:VDQF 3 "register_operand" "w"))
2938 (vec_duplicate:VDQF
2939 (vec_select:<VEL>
2940 (match_operand:VDQF 1 "register_operand" "<h_con>")
2941 (parallel [(match_operand:SI 2 "immediate_operand")])))
2942 (match_operand:VDQF 4 "register_operand" "0")))]
2943 "TARGET_SIMD"
2944 {
2945 operands[2] = aarch64_endian_lane_rtx (<MODE>mode, INTVAL (operands[2]));
2946 return "fmls\\t%0.<Vtype>, %3.<Vtype>, %1.<Vetype>[%2]";
2947 }
2948 [(set_attr "type" "neon_fp_mla_<Vetype>_scalar<q>")]
2949 )
2950
2951 (define_insn "*aarch64_fnma4_elt_<vswap_width_name><mode><vczle><vczbe>"
2952 [(set (match_operand:VDQSF 0 "register_operand" "=w")
2953 (fma:VDQSF
2954 (neg:VDQSF
2955 (match_operand:VDQSF 3 "register_operand" "w"))
2956 (vec_duplicate:VDQSF
2957 (vec_select:<VEL>
2958 (match_operand:<VSWAP_WIDTH> 1 "register_operand" "<h_con>")
2959 (parallel [(match_operand:SI 2 "immediate_operand")])))
2960 (match_operand:VDQSF 4 "register_operand" "0")))]
2961 "TARGET_SIMD"
2962 {
2963 operands[2] = aarch64_endian_lane_rtx (<VSWAP_WIDTH>mode, INTVAL (operands[2]));
2964 return "fmls\\t%0.<Vtype>, %3.<Vtype>, %1.<Vetype>[%2]";
2965 }
2966 [(set_attr "type" "neon_fp_mla_<Vetype>_scalar<q>")]
2967 )
2968
2969 (define_insn "*aarch64_fnma4_elt_from_dup<mode><vczle><vczbe>"
2970 [(set (match_operand:VMUL 0 "register_operand" "=w")
2971 (fma:VMUL
2972 (neg:VMUL
2973 (match_operand:VMUL 2 "register_operand" "w"))
2974 (vec_duplicate:VMUL
2975 (match_operand:<VEL> 1 "register_operand" "<h_con>"))
2976 (match_operand:VMUL 3 "register_operand" "0")))]
2977 "TARGET_SIMD"
2978 "fmls\t%0.<Vtype>, %2.<Vtype>, %1.<Vetype>[0]"
2979 [(set_attr "type" "neon<fp>_mla_<stype>_scalar<q>")]
2980 )
2981
2982 (define_insn "*aarch64_fnma4_elt_to_64v2df"
2983 [(set (match_operand:DF 0 "register_operand" "=w")
2984 (fma:DF
2985 (vec_select:DF
2986 (match_operand:V2DF 1 "register_operand" "w")
2987 (parallel [(match_operand:SI 2 "immediate_operand")]))
2988 (neg:DF
2989 (match_operand:DF 3 "register_operand" "w"))
2990 (match_operand:DF 4 "register_operand" "0")))]
2991 "TARGET_SIMD"
2992 {
2993 operands[2] = aarch64_endian_lane_rtx (V2DFmode, INTVAL (operands[2]));
2994 return "fmls\\t%0.2d, %3.2d, %1.d[%2]";
2995 }
2996 [(set_attr "type" "neon_fp_mla_d_scalar_q")]
2997 )
2998
2999 ;; Vector versions of the floating-point frint patterns.
3000 ;; Expands to btrunc, ceil, floor, nearbyint, rint, round, frintn.
3001 (define_insn "<frint_pattern><mode>2<vczle><vczbe>"
3002 [(set (match_operand:VHSDF 0 "register_operand" "=w")
3003 (unspec:VHSDF [(match_operand:VHSDF 1 "register_operand" "w")]
3004 FRINT))]
3005 "TARGET_SIMD"
3006 "frint<frint_suffix>\\t%0.<Vtype>, %1.<Vtype>"
3007 [(set_attr "type" "neon_fp_round_<stype><q>")]
3008 )
3009
3010 ;; Vector versions of the fcvt standard patterns.
3011 ;; Expands to lbtrunc, lround, lceil, lfloor
3012 (define_insn "l<fcvt_pattern><su_optab><VHSDF:mode><fcvt_target>2"
3013 [(set (match_operand:<FCVT_TARGET> 0 "register_operand" "=w")
3014 (FIXUORS:<FCVT_TARGET> (unspec:<FCVT_TARGET>
3015 [(match_operand:VHSDF 1 "register_operand" "w")]
3016 FCVT)))]
3017 "TARGET_SIMD"
3018 "fcvt<frint_suffix><su>\\t%0.<Vtype>, %1.<Vtype>"
3019 [(set_attr "type" "neon_fp_to_int_<stype><q>")]
3020 )
3021
3022 ;; HF Scalar variants of related SIMD instructions.
3023 (define_insn "l<fcvt_pattern><su_optab>hfhi2"
3024 [(set (match_operand:HI 0 "register_operand" "=w")
3025 (FIXUORS:HI (unspec:HF [(match_operand:HF 1 "register_operand" "w")]
3026 FCVT)))]
3027 "TARGET_SIMD_F16INST"
3028 "fcvt<frint_suffix><su>\t%h0, %h1"
3029 [(set_attr "type" "neon_fp_to_int_s")]
3030 )
3031
3032 (define_insn "<optab>_trunchfhi2"
3033 [(set (match_operand:HI 0 "register_operand" "=w")
3034 (FIXUORS:HI (match_operand:HF 1 "register_operand" "w")))]
3035 "TARGET_SIMD_F16INST"
3036 "fcvtz<su>\t%h0, %h1"
3037 [(set_attr "type" "neon_fp_to_int_s")]
3038 )
3039
3040 (define_insn "<optab>hihf2"
3041 [(set (match_operand:HF 0 "register_operand" "=w")
3042 (FLOATUORS:HF (match_operand:HI 1 "register_operand" "w")))]
3043 "TARGET_SIMD_F16INST"
3044 "<su_optab>cvtf\t%h0, %h1"
3045 [(set_attr "type" "neon_int_to_fp_s")]
3046 )
3047
3048 (define_insn "*aarch64_fcvt<su_optab><VDQF:mode><fcvt_target>2_mult"
3049 [(set (match_operand:<FCVT_TARGET> 0 "register_operand" "=w")
3050 (FIXUORS:<FCVT_TARGET> (unspec:<FCVT_TARGET>
3051 [(mult:VDQF
3052 (match_operand:VDQF 1 "register_operand" "w")
3053 (match_operand:VDQF 2 "aarch64_fp_vec_pow2" ""))]
3054 UNSPEC_FRINTZ)))]
3055 "TARGET_SIMD
3056 && IN_RANGE (aarch64_vec_fpconst_pow_of_2 (operands[2]), 1,
3057 GET_MODE_BITSIZE (GET_MODE_INNER (<VDQF:MODE>mode)))"
3058 {
3059 int fbits = aarch64_vec_fpconst_pow_of_2 (operands[2]);
3060 char buf[64];
3061 snprintf (buf, 64, "fcvtz<su>\\t%%0.<Vtype>, %%1.<Vtype>, #%d", fbits);
3062 output_asm_insn (buf, operands);
3063 return "";
3064 }
3065 [(set_attr "type" "neon_fp_to_int_<Vetype><q>")]
3066 )
3067
3068 (define_expand "<optab><VHSDF:mode><fcvt_target>2"
3069 [(set (match_operand:<FCVT_TARGET> 0 "register_operand")
3070 (FIXUORS:<FCVT_TARGET> (unspec:<FCVT_TARGET>
3071 [(match_operand:VHSDF 1 "register_operand")]
3072 UNSPEC_FRINTZ)))]
3073 "TARGET_SIMD"
3074 {})
3075
3076 (define_expand "<fix_trunc_optab><VHSDF:mode><fcvt_target>2"
3077 [(set (match_operand:<FCVT_TARGET> 0 "register_operand")
3078 (FIXUORS:<FCVT_TARGET> (unspec:<FCVT_TARGET>
3079 [(match_operand:VHSDF 1 "register_operand")]
3080 UNSPEC_FRINTZ)))]
3081 "TARGET_SIMD"
3082 {})
3083
3084 (define_expand "ftrunc<VHSDF:mode>2"
3085 [(set (match_operand:VHSDF 0 "register_operand")
3086 (unspec:VHSDF [(match_operand:VHSDF 1 "register_operand")]
3087 UNSPEC_FRINTZ))]
3088 "TARGET_SIMD"
3089 {})
3090
3091 (define_insn "<optab><fcvt_target><VHSDF:mode>2"
3092 [(set (match_operand:VHSDF 0 "register_operand" "=w")
3093 (FLOATUORS:VHSDF
3094 (match_operand:<FCVT_TARGET> 1 "register_operand" "w")))]
3095 "TARGET_SIMD"
3096 "<su_optab>cvtf\\t%0.<Vtype>, %1.<Vtype>"
3097 [(set_attr "type" "neon_int_to_fp_<stype><q>")]
3098 )
3099
3100 ;; Conversions between vectors of floats and doubles.
3101 ;; Contains a mix of patterns to match standard pattern names
3102 ;; and those for intrinsics.
3103
3104 ;; Float widening operations.
3105
3106 (define_insn "aarch64_simd_vec_unpacks_lo_<mode>"
3107 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
3108 (float_extend:<VWIDE> (vec_select:<VHALF>
3109 (match_operand:VQ_HSF 1 "register_operand" "w")
3110 (match_operand:VQ_HSF 2 "vect_par_cnst_lo_half" "")
3111 )))]
3112 "TARGET_SIMD"
3113 "fcvtl\\t%0.<Vwtype>, %1.<Vhalftype>"
3114 [(set_attr "type" "neon_fp_cvt_widen_s")]
3115 )
3116
3117 ;; Convert between fixed-point and floating-point (vector modes)
3118
3119 (define_insn "<FCVT_F2FIXED:fcvt_fixed_insn><VHSDF:mode>3"
3120 [(set (match_operand:<VHSDF:FCVT_TARGET> 0 "register_operand" "=w")
3121 (unspec:<VHSDF:FCVT_TARGET>
3122 [(match_operand:VHSDF 1 "register_operand" "w")
3123 (match_operand:SI 2 "immediate_operand" "i")]
3124 FCVT_F2FIXED))]
3125 "TARGET_SIMD"
3126 "<FCVT_F2FIXED:fcvt_fixed_insn>\t%<v>0<Vmtype>, %<v>1<Vmtype>, #%2"
3127 [(set_attr "type" "neon_fp_to_int_<VHSDF:stype><q>")]
3128 )
3129
3130 (define_insn "<FCVT_FIXED2F:fcvt_fixed_insn><VDQ_HSDI:mode>3"
3131 [(set (match_operand:<VDQ_HSDI:FCVT_TARGET> 0 "register_operand" "=w")
3132 (unspec:<VDQ_HSDI:FCVT_TARGET>
3133 [(match_operand:VDQ_HSDI 1 "register_operand" "w")
3134 (match_operand:SI 2 "immediate_operand" "i")]
3135 FCVT_FIXED2F))]
3136 "TARGET_SIMD"
3137 "<FCVT_FIXED2F:fcvt_fixed_insn>\t%<v>0<Vmtype>, %<v>1<Vmtype>, #%2"
3138 [(set_attr "type" "neon_int_to_fp_<VDQ_HSDI:stype><q>")]
3139 )
3140
3141 ;; ??? Note that the vectorizer usage of the vec_unpacks_[lo/hi] patterns
3142 ;; is inconsistent with vector ordering elsewhere in the compiler, in that
3143 ;; the meaning of HI and LO changes depending on the target endianness.
3144 ;; While elsewhere we map the higher numbered elements of a vector to
3145 ;; the lower architectural lanes of the vector, for these patterns we want
3146 ;; to always treat "hi" as referring to the higher architectural lanes.
3147 ;; Consequently, while the patterns below look inconsistent with our
3148 ;; other big-endian patterns their behavior is as required.
3149
3150 (define_expand "vec_unpacks_lo_<mode>"
3151 [(match_operand:<VWIDE> 0 "register_operand")
3152 (match_operand:VQ_HSF 1 "register_operand")]
3153 "TARGET_SIMD"
3154 {
3155 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, false);
3156 emit_insn (gen_aarch64_simd_vec_unpacks_lo_<mode> (operands[0],
3157 operands[1], p));
3158 DONE;
3159 }
3160 )
3161
3162 (define_insn "aarch64_simd_vec_unpacks_hi_<mode>"
3163 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
3164 (float_extend:<VWIDE> (vec_select:<VHALF>
3165 (match_operand:VQ_HSF 1 "register_operand" "w")
3166 (match_operand:VQ_HSF 2 "vect_par_cnst_hi_half" "")
3167 )))]
3168 "TARGET_SIMD"
3169 "fcvtl2\\t%0.<Vwtype>, %1.<Vtype>"
3170 [(set_attr "type" "neon_fp_cvt_widen_s")]
3171 )
3172
3173 (define_expand "vec_unpacks_hi_<mode>"
3174 [(match_operand:<VWIDE> 0 "register_operand")
3175 (match_operand:VQ_HSF 1 "register_operand")]
3176 "TARGET_SIMD"
3177 {
3178 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
3179 emit_insn (gen_aarch64_simd_vec_unpacks_lo_<mode> (operands[0],
3180 operands[1], p));
3181 DONE;
3182 }
3183 )
3184
3185 (define_insn "extend<mode><Vwide>2"
3186 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
3187 (float_extend:<VWIDE>
3188 (match_operand:VDF 1 "register_operand" "w")))]
3189 "TARGET_SIMD"
3190 "fcvtl\\t%0<Vmwtype>, %1<Vmtype>"
3191 [(set_attr "type" "neon_fp_cvt_widen_s")]
3192 )
3193
3194 /* A BF->SF is a shift left of 16, however shifts are expensive and the generic
3195 middle-end expansion would force through DI move. Instead use EXT to do the
3196 shift to get better throughput and don't go through GPRs. */
3197
3198 (define_expand "extendbfsf2"
3199 [(set (match_operand:SF 0 "register_operand" "=w")
3200 (float_extend:SF
3201 (match_operand:BF 1 "register_operand" "w")))]
3202 "TARGET_SIMD"
3203 {
3204 rtx tmp0 = aarch64_gen_shareable_zero (V8BFmode);
3205 rtx op0 = force_lowpart_subreg (V8BFmode, operands[1], BFmode);
3206 rtx res = gen_reg_rtx (V8BFmode);
3207 emit_insn (gen_aarch64_extv8bf (res, tmp0, op0, gen_int_mode (7, SImode)));
3208 /* Subregs between floating point modes aren't allowed to change size, so go
3209 through V4SFmode. */
3210 res = force_lowpart_subreg (V4SFmode, res, V8BFmode);
3211 res = force_lowpart_subreg (SFmode, res, V4SFmode);
3212 emit_move_insn (operands[0], res);
3213 DONE;
3214 })
3215
3216
3217 ;; Float narrowing operations.
3218
3219 (define_insn "aarch64_float_trunc_rodd_df"
3220 [(set (match_operand:SF 0 "register_operand" "=w")
3221 (unspec:SF [(match_operand:DF 1 "register_operand" "w")]
3222 UNSPEC_FCVTXN))]
3223 "TARGET_SIMD"
3224 "fcvtxn\\t%s0, %d1"
3225 [(set_attr "type" "neon_fp_cvt_narrow_d_q")]
3226 )
3227
3228 (define_insn "aarch64_float_trunc_rodd_lo_v2sf"
3229 [(set (match_operand:V2SF 0 "register_operand" "=w")
3230 (unspec:V2SF [(match_operand:V2DF 1 "register_operand" "w")]
3231 UNSPEC_FCVTXN))]
3232 "TARGET_SIMD"
3233 "fcvtxn\\t%0.2s, %1.2d"
3234 [(set_attr "type" "neon_fp_cvt_narrow_d_q")]
3235 )
3236
3237 (define_insn "aarch64_float_trunc_rodd_hi_v4sf_le"
3238 [(set (match_operand:V4SF 0 "register_operand" "=w")
3239 (vec_concat:V4SF
3240 (match_operand:V2SF 1 "register_operand" "0")
3241 (unspec:V2SF [(match_operand:V2DF 2 "register_operand" "w")]
3242 UNSPEC_FCVTXN)))]
3243 "TARGET_SIMD && !BYTES_BIG_ENDIAN"
3244 "fcvtxn2\\t%0.4s, %2.2d"
3245 [(set_attr "type" "neon_fp_cvt_narrow_d_q")]
3246 )
3247
3248 (define_insn "aarch64_float_trunc_rodd_hi_v4sf_be"
3249 [(set (match_operand:V4SF 0 "register_operand" "=w")
3250 (vec_concat:V4SF
3251 (unspec:V2SF [(match_operand:V2DF 2 "register_operand" "w")]
3252 UNSPEC_FCVTXN)
3253 (match_operand:V2SF 1 "register_operand" "0")))]
3254 "TARGET_SIMD && BYTES_BIG_ENDIAN"
3255 "fcvtxn2\\t%0.4s, %2.2d"
3256 [(set_attr "type" "neon_fp_cvt_narrow_d_q")]
3257 )
3258
3259 (define_expand "aarch64_float_trunc_rodd_hi_v4sf"
3260 [(match_operand:V4SF 0 "register_operand")
3261 (match_operand:V2SF 1 "register_operand")
3262 (match_operand:V2DF 2 "register_operand")]
3263 "TARGET_SIMD"
3264 {
3265 rtx (*gen) (rtx, rtx, rtx) = BYTES_BIG_ENDIAN
3266 ? gen_aarch64_float_trunc_rodd_hi_v4sf_be
3267 : gen_aarch64_float_trunc_rodd_hi_v4sf_le;
3268 emit_insn (gen (operands[0], operands[1], operands[2]));
3269 DONE;
3270 }
3271 )
3272
3273 (define_insn "trunc<Vwide><mode>2<vczle><vczbe>"
3274 [(set (match_operand:VDF 0 "register_operand" "=w")
3275 (float_truncate:VDF
3276 (match_operand:<VWIDE> 1 "register_operand" "w")))]
3277 "TARGET_SIMD"
3278 "fcvtn\\t%0.<Vtype>, %1<Vmwtype>"
3279 [(set_attr "type" "neon_fp_cvt_narrow_d_q")]
3280 )
3281
3282 (define_insn "aarch64_float_truncate_hi_<Vdbl>_le"
3283 [(set (match_operand:<VDBL> 0 "register_operand" "=w")
3284 (vec_concat:<VDBL>
3285 (match_operand:VDF 1 "register_operand" "0")
3286 (float_truncate:VDF
3287 (match_operand:<VWIDE> 2 "register_operand" "w"))))]
3288 "TARGET_SIMD && !BYTES_BIG_ENDIAN"
3289 "fcvtn2\\t%0.<Vdtype>, %2<Vmwtype>"
3290 [(set_attr "type" "neon_fp_cvt_narrow_d_q")]
3291 )
3292
3293 (define_insn "aarch64_float_truncate_hi_<Vdbl>_be"
3294 [(set (match_operand:<VDBL> 0 "register_operand" "=w")
3295 (vec_concat:<VDBL>
3296 (float_truncate:VDF
3297 (match_operand:<VWIDE> 2 "register_operand" "w"))
3298 (match_operand:VDF 1 "register_operand" "0")))]
3299 "TARGET_SIMD && BYTES_BIG_ENDIAN"
3300 "fcvtn2\\t%0.<Vdtype>, %2<Vmwtype>"
3301 [(set_attr "type" "neon_fp_cvt_narrow_d_q")]
3302 )
3303
3304 (define_expand "aarch64_float_truncate_hi_<Vdbl>"
3305 [(match_operand:<VDBL> 0 "register_operand")
3306 (match_operand:VDF 1 "register_operand")
3307 (match_operand:<VWIDE> 2 "register_operand")]
3308 "TARGET_SIMD"
3309 {
3310 rtx (*gen) (rtx, rtx, rtx) = BYTES_BIG_ENDIAN
3311 ? gen_aarch64_float_truncate_hi_<Vdbl>_be
3312 : gen_aarch64_float_truncate_hi_<Vdbl>_le;
3313 emit_insn (gen (operands[0], operands[1], operands[2]));
3314 DONE;
3315 }
3316 )
3317
3318 (define_expand "vec_pack_trunc_v2df"
3319 [(set (match_operand:V4SF 0 "register_operand")
3320 (vec_concat:V4SF
3321 (float_truncate:V2SF
3322 (match_operand:V2DF 1 "register_operand"))
3323 (float_truncate:V2SF
3324 (match_operand:V2DF 2 "register_operand"))
3325 ))]
3326 "TARGET_SIMD"
3327 {
3328 rtx tmp = gen_reg_rtx (V2SFmode);
3329 int lo = BYTES_BIG_ENDIAN ? 2 : 1;
3330 int hi = BYTES_BIG_ENDIAN ? 1 : 2;
3331
3332 emit_insn (gen_truncv2dfv2sf2 (tmp, operands[lo]));
3333 emit_insn (gen_aarch64_float_truncate_hi_v4sf (operands[0],
3334 tmp, operands[hi]));
3335 DONE;
3336 }
3337 )
3338
3339 (define_expand "vec_pack_trunc_df"
3340 [(set (match_operand:V2SF 0 "register_operand")
3341 (vec_concat:V2SF
3342 (float_truncate:SF (match_operand:DF 1 "general_operand"))
3343 (float_truncate:SF (match_operand:DF 2 "general_operand"))))]
3344 "TARGET_SIMD"
3345 {
3346 rtx tmp = gen_reg_rtx (V2SFmode);
3347 emit_insn (gen_aarch64_vec_concatdf (tmp, operands[1], operands[2]));
3348 emit_insn (gen_truncv2dfv2sf2 (operands[0], tmp));
3349 DONE;
3350 }
3351 )
3352
3353 ;; FP Max/Min
3354 ;; Max/Min are introduced by idiom recognition by GCC's mid-end. An
3355 ;; expression like:
3356 ;; a = (b < c) ? b : c;
3357 ;; is idiom-matched as MIN_EXPR<b,c> only if -ffinite-math-only and
3358 ;; -fno-signed-zeros are enabled either explicitly or indirectly via
3359 ;; -ffast-math.
3360 ;;
3361 ;; MIN_EXPR and MAX_EXPR eventually map to 'smin' and 'smax' in RTL.
3362 ;; The 'smax' and 'smin' RTL standard pattern names do not specify which
3363 ;; operand will be returned when both operands are zero (i.e. they may not
3364 ;; honour signed zeroes), or when either operand is NaN. Therefore GCC
3365 ;; only introduces MIN_EXPR/MAX_EXPR in fast math mode or when not honouring
3366 ;; NaNs.
3367
3368 (define_insn "<su><maxmin><mode>3"
3369 [(set (match_operand:VHSDF 0 "register_operand" "=w")
3370 (FMAXMIN:VHSDF (match_operand:VHSDF 1 "register_operand" "w")
3371 (match_operand:VHSDF 2 "register_operand" "w")))]
3372 "TARGET_SIMD"
3373 "f<maxmin>nm\\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
3374 [(set_attr "type" "neon_fp_minmax_<stype><q>")]
3375 )
3376
3377 ;; Vector forms for fmax, fmin, fmaxnm, fminnm.
3378 ;; fmaxnm and fminnm are used for the fmax<mode>3 standard pattern names,
3379 ;; which implement the IEEE fmax ()/fmin () functions.
3380 (define_insn "<fmaxmin><mode>3<vczle><vczbe>"
3381 [(set (match_operand:VHSDF 0 "register_operand" "=w")
3382 (unspec:VHSDF [(match_operand:VHSDF 1 "register_operand" "w")
3383 (match_operand:VHSDF 2 "register_operand" "w")]
3384 FMAXMIN_UNS))]
3385 "TARGET_SIMD"
3386 "<maxmin_uns_op>\\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
3387 [(set_attr "type" "neon_fp_minmax_<stype><q>")]
3388 )
3389
3390 ;; 'across lanes' add.
3391
3392 (define_insn "aarch64_faddp<mode><vczle><vczbe>"
3393 [(set (match_operand:VHSDF 0 "register_operand" "=w")
3394 (unspec:VHSDF [(match_operand:VHSDF 1 "register_operand" "w")
3395 (match_operand:VHSDF 2 "register_operand" "w")]
3396 UNSPEC_FADDV))]
3397 "TARGET_SIMD"
3398 "faddp\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
3399 [(set_attr "type" "neon_fp_reduc_add_<stype><q>")]
3400 )
3401
3402 (define_insn "reduc_plus_scal_<mode>"
3403 [(set (match_operand:<VEL> 0 "register_operand" "=w")
3404 (unspec:<VEL> [(match_operand:VDQV 1 "register_operand" "w")]
3405 UNSPEC_ADDV))]
3406 "TARGET_SIMD"
3407 "add<VDQV:vp>\\t%<Vetype>0, %1.<Vtype>"
3408 [(set_attr "type" "neon_reduc_add<q>")]
3409 )
3410
3411 (define_insn "reduc_plus_scal_v2si"
3412 [(set (match_operand:SI 0 "register_operand" "=w")
3413 (unspec:SI [(match_operand:V2SI 1 "register_operand" "w")]
3414 UNSPEC_ADDV))]
3415 "TARGET_SIMD"
3416 "addp\\t%0.2s, %1.2s, %1.2s"
3417 [(set_attr "type" "neon_reduc_add")]
3418 )
3419
3420 ;; ADDV with result zero-extended to SI/DImode (for popcount).
3421 (define_insn "aarch64_zero_extend<GPI:mode>_reduc_plus_<VDQV_E:mode>"
3422 [(set (match_operand:GPI 0 "register_operand" "=w")
3423 (zero_extend:GPI
3424 (unspec:<VDQV_E:VEL> [(match_operand:VDQV_E 1 "register_operand" "w")]
3425 UNSPEC_ADDV)))]
3426 "TARGET_SIMD"
3427 "add<VDQV_E:vp>\\t%<VDQV_E:Vetype>0, %1.<VDQV_E:Vtype>"
3428 [(set_attr "type" "neon_reduc_add<VDQV_E:q>")]
3429 )
3430
3431 (define_insn "reduc_plus_scal_<mode>"
3432 [(set (match_operand:<VEL> 0 "register_operand" "=w")
3433 (unspec:<VEL> [(match_operand:V2F 1 "register_operand" "w")]
3434 UNSPEC_FADDV))]
3435 "TARGET_SIMD"
3436 "faddp\\t%<Vetype>0, %1.<Vtype>"
3437 [(set_attr "type" "neon_fp_reduc_add_<Vetype><q>")]
3438 )
3439
3440 (define_expand "reduc_plus_scal_v4sf"
3441 [(set (match_operand:SF 0 "register_operand")
3442 (unspec:SF [(match_operand:V4SF 1 "register_operand")]
3443 UNSPEC_FADDV))]
3444 "TARGET_SIMD"
3445 {
3446 rtx elt = aarch64_endian_lane_rtx (V4SFmode, 0);
3447 rtx scratch = gen_reg_rtx (V4SFmode);
3448 emit_insn (gen_aarch64_faddpv4sf (scratch, operands[1], operands[1]));
3449 emit_insn (gen_aarch64_faddpv4sf (scratch, scratch, scratch));
3450 emit_insn (gen_aarch64_get_lanev4sf (operands[0], scratch, elt));
3451 DONE;
3452 })
3453
3454 ;; SADDLV and UADDLV can be expressed as an ADDV instruction that first
3455 ;; sign or zero-extends its elements.
3456 (define_insn "aarch64_<su>addlv<mode>"
3457 [(set (match_operand:<VWIDE_S> 0 "register_operand" "=w")
3458 (unspec:<VWIDE_S>
3459 [(ANY_EXTEND:<V2XWIDE>
3460 (match_operand:VDQV_L 1 "register_operand" "w"))]
3461 UNSPEC_ADDV))]
3462 "TARGET_SIMD"
3463 "<su>addl<vp>\\t%<Vwstype>0<Vwsuf>, %1.<Vtype>"
3464 [(set_attr "type" "neon_reduc_add<q>")]
3465 )
3466
3467 ;; An ADDV over a vector PLUS of elements extracted and widened all from the
3468 ;; same vector is the same as an [SU]ADDLV above, so long as all the elements
3469 ;; of that vector are used. We can greatly simplify the RTL expression using
3470 ;; this splitter.
3471 (define_insn_and_split "*aarch64_<su>addlv<mode>_reduction"
3472 [(set (match_operand:<VWIDE_S> 0 "register_operand")
3473 (unspec:<VWIDE_S>
3474 [(plus:<VDBLW>
3475 (vec_select:<VDBLW>
3476 (ANY_EXTEND:<V2XWIDE>
3477 (match_operand:VDQV_L 1 "register_operand"))
3478 (match_operand:<V2XWIDE> 2 "vect_par_cnst_select_half"))
3479 (vec_select:<VDBLW> (ANY_EXTEND:<V2XWIDE> (match_dup 1))
3480 (match_operand:<V2XWIDE> 3 "vect_par_cnst_select_half")))]
3481 UNSPEC_ADDV))]
3482 "TARGET_SIMD && !aarch64_pars_overlap_p (operands[2], operands[3])"
3483 "#"
3484 "&& 1"
3485 [(set (match_dup 0)
3486 (unspec:<VWIDE_S>
3487 [(ANY_EXTEND:<V2XWIDE>
3488 (match_dup 1))]
3489 UNSPEC_ADDV))]
3490 {}
3491 )
3492
3493 ;; Similar to the above but for two-step zero-widening reductions.
3494 ;; We can push the outer zero_extend outside the ADDV unspec and make
3495 ;; use of the implicit high-part zeroing semantics of UADDLV to do it all
3496 ;; in a single instruction.
3497 (define_insn_and_split "*aarch64_uaddlv<mode>_reduction_2"
3498 [(set (match_operand:<VWIDE2X_S> 0 "register_operand" "=w")
3499 (unspec:<VWIDE2X_S>
3500 [(zero_extend:<VQUADW>
3501 (plus:<VDBLW>
3502 (vec_select:<VDBLW>
3503 (zero_extend:<V2XWIDE>
3504 (match_operand:VDQQH 1 "register_operand" "w"))
3505 (match_operand:<V2XWIDE> 2 "vect_par_cnst_select_half"))
3506 (vec_select:<VDBLW> (zero_extend:<V2XWIDE> (match_dup 1))
3507 (match_operand:<V2XWIDE> 3 "vect_par_cnst_select_half"))))]
3508 UNSPEC_ADDV))]
3509 "TARGET_SIMD && !aarch64_pars_overlap_p (operands[2], operands[3])"
3510 "#"
3511 "&& 1"
3512 [(set (match_dup 0)
3513 (zero_extend:<VWIDE2X_S>
3514 (unspec:<VWIDE_S>
3515 [(zero_extend:<V2XWIDE>
3516 (match_dup 1))]
3517 UNSPEC_ADDV)))]
3518 {}
3519 )
3520
3521 ;; Zero-extending version of the above. As these intrinsics produce a scalar
3522 ;; value that may be used by further intrinsics we want to avoid moving the
3523 ;; result into GP regs to do a zero-extension that ADDLV/ADDLP gives for free.
3524
3525 (define_insn "*aarch64_<su>addlv<VDQV_L:mode>_ze<GPI:mode>"
3526 [(set (match_operand:GPI 0 "register_operand" "=w")
3527 (zero_extend:GPI
3528 (unspec:<VWIDE_S>
3529 [(ANY_EXTEND:<VDQV_L:V2XWIDE>
3530 (match_operand:VDQV_L 1 "register_operand" "w"))]
3531 UNSPEC_ADDV)))]
3532 "TARGET_SIMD
3533 && (GET_MODE_SIZE (<GPI:MODE>mode) > GET_MODE_SIZE (<VWIDE_S>mode))"
3534 "<su>addl<VDQV_L:vp>\\t%<VDQV_L:Vwstype>0<VDQV_L:Vwsuf>, %1.<VDQV_L:Vtype>"
3535 [(set_attr "type" "neon_reduc_add<VDQV_L:q>")]
3536 )
3537
3538 (define_expand "@aarch64_<su>addlp<mode>"
3539 [(set (match_operand:<VDBLW> 0 "register_operand")
3540 (plus:<VDBLW>
3541 (vec_select:<VDBLW>
3542 (ANY_EXTEND:<V2XWIDE>
3543 (match_operand:VDQV_L 1 "register_operand"))
3544 (match_dup 2))
3545 (vec_select:<VDBLW> (ANY_EXTEND:<V2XWIDE> (match_dup 1))
3546 (match_dup 3))))]
3547 "TARGET_SIMD"
3548 {
3549 int nunits = GET_MODE_NUNITS (<MODE>mode).to_constant () / 2;
3550 operands[2] = aarch64_gen_stepped_int_parallel (nunits, 0, 2);
3551 operands[3] = aarch64_gen_stepped_int_parallel (nunits, 1, 2);
3552 }
3553 )
3554
3555 (define_insn "*aarch64_<su>addlp<mode><vczle><vczbe>_insn"
3556 [(set (match_operand:<VDBLW> 0 "register_operand" "=w")
3557 (plus:<VDBLW>
3558 (vec_select:<VDBLW>
3559 (ANY_EXTEND:<V2XWIDE>
3560 (match_operand:VDQV_L 1 "register_operand" "w"))
3561 (match_operand:<V2XWIDE> 2 "vect_par_cnst_even_or_odd_half"))
3562 (vec_select:<VDBLW> (ANY_EXTEND:<V2XWIDE> (match_dup 1))
3563 (match_operand:<V2XWIDE> 3 "vect_par_cnst_even_or_odd_half"))))]
3564 "TARGET_SIMD
3565 && !rtx_equal_p (operands[2], operands[3])"
3566 "<su>addlp\\t%0.<Vwhalf>, %1.<Vtype>"
3567 [(set_attr "type" "neon_reduc_add<q>")]
3568 )
3569
3570 (define_insn "clrsb<mode>2<vczle><vczbe>"
3571 [(set (match_operand:VDQ_BHSI 0 "register_operand" "=w")
3572 (clrsb:VDQ_BHSI (match_operand:VDQ_BHSI 1 "register_operand" "w")))]
3573 "TARGET_SIMD"
3574 "cls\\t%0.<Vtype>, %1.<Vtype>"
3575 [(set_attr "type" "neon_cls<q>")]
3576 )
3577
3578 (define_insn "clz<mode>2<vczle><vczbe>"
3579 [(set (match_operand:VDQ_BHSI 0 "register_operand" "=w")
3580 (clz:VDQ_BHSI (match_operand:VDQ_BHSI 1 "register_operand" "w")))]
3581 "TARGET_SIMD"
3582 "clz\\t%0.<Vtype>, %1.<Vtype>"
3583 [(set_attr "type" "neon_cls<q>")]
3584 )
3585
3586 (define_insn "popcount<mode>2<vczle><vczbe>"
3587 [(set (match_operand:VB 0 "register_operand" "=w")
3588 (popcount:VB (match_operand:VB 1 "register_operand" "w")))]
3589 "TARGET_SIMD"
3590 "cnt\\t%0.<Vbtype>, %1.<Vbtype>"
3591 [(set_attr "type" "neon_cnt<q>")]
3592 )
3593
3594 (define_expand "popcount<mode>2"
3595 [(set (match_operand:VDQHSD_V1DI 0 "register_operand")
3596 (popcount:VDQHSD_V1DI
3597 (match_operand:VDQHSD_V1DI 1 "register_operand")))]
3598 "TARGET_SIMD"
3599 {
3600 if (TARGET_SVE)
3601 {
3602 rtx p = aarch64_ptrue_reg (<VPRED>mode, <bitsize> == 64 ? 8 : 16);
3603 emit_insn (gen_aarch64_pred_popcount<mode> (operands[0],
3604 p,
3605 operands[1]));
3606 DONE;
3607 }
3608
3609 if (<MODE>mode == V1DImode)
3610 {
3611 rtx out = gen_reg_rtx (DImode);
3612 emit_insn (gen_popcountdi2 (out, gen_lowpart (DImode, operands[1])));
3613 emit_move_insn (operands[0], gen_lowpart (<MODE>mode, out));
3614 DONE;
3615 }
3616
3617 /* Generate a byte popcount. */
3618 machine_mode mode = <bitsize> == 64 ? V8QImode : V16QImode;
3619 machine_mode mode2 = <bitsize> == 64 ? V2SImode : V4SImode;
3620 rtx tmp = gen_reg_rtx (mode);
3621 auto icode = optab_handler (popcount_optab, mode);
3622 emit_insn (GEN_FCN (icode) (tmp, gen_lowpart (mode, operands[1])));
3623
3624 if (TARGET_DOTPROD
3625 && (<VEL>mode == SImode || <VEL>mode == DImode))
3626 {
3627 /* For V4SI and V2SI, we can generate a UDOT with a 0 accumulator and a
3628 1 multiplicand. For V2DI, another UAADDLP is needed. */
3629 rtx ones = force_reg (mode, CONST1_RTX (mode));
3630 auto icode = convert_optab_handler (udot_prod_optab, mode2, mode);
3631 mode = <bitsize> == 64 ? V2SImode : V4SImode;
3632 rtx dest = mode == <MODE>mode ? operands[0] : gen_reg_rtx (mode);
3633 rtx zeros = force_reg (mode, CONST0_RTX (mode));
3634 emit_insn (GEN_FCN (icode) (dest, tmp, ones, zeros));
3635 tmp = dest;
3636 }
3637
3638 /* Use a sequence of UADDLPs to accumulate the counts. Each step doubles
3639 the element size and halves the number of elements. */
3640 while (mode != <MODE>mode)
3641 {
3642 auto icode = code_for_aarch64_addlp (ZERO_EXTEND, GET_MODE (tmp));
3643 mode = insn_data[icode].operand[0].mode;
3644 rtx dest = mode == <MODE>mode ? operands[0] : gen_reg_rtx (mode);
3645 emit_insn (GEN_FCN (icode) (dest, tmp));
3646 tmp = dest;
3647 }
3648 DONE;
3649 }
3650 )
3651
3652 ;; 'across lanes' max and min ops.
3653
3654 ;; Template for outputting a scalar, so we can create __builtins which can be
3655 ;; gimple_fold'd to the IFN_REDUC_(MAX|MIN) function. (This is FP smax/smin).
3656 (define_expand "reduc_<optab>_scal_<mode>"
3657 [(match_operand:<VEL> 0 "register_operand")
3658 (unspec:<VEL> [(match_operand:VHSDF 1 "register_operand")]
3659 FMAXMINV)]
3660 "TARGET_SIMD"
3661 {
3662 rtx elt = aarch64_endian_lane_rtx (<MODE>mode, 0);
3663 rtx scratch = gen_reg_rtx (<MODE>mode);
3664 emit_insn (gen_aarch64_reduc_<optab>_internal<mode> (scratch,
3665 operands[1]));
3666 emit_insn (gen_aarch64_get_lane<mode> (operands[0], scratch, elt));
3667 DONE;
3668 }
3669 )
3670
3671 (define_expand "reduc_<fmaxmin>_scal_<mode>"
3672 [(match_operand:<VEL> 0 "register_operand")
3673 (unspec:<VEL> [(match_operand:VHSDF 1 "register_operand")]
3674 FMAXMINNMV)]
3675 "TARGET_SIMD"
3676 {
3677 emit_insn (gen_reduc_<optab>_scal_<mode> (operands[0], operands[1]));
3678 DONE;
3679 }
3680 )
3681
3682 ;; Likewise for integer cases, signed and unsigned.
3683 (define_expand "reduc_<optab>_scal_<mode>"
3684 [(match_operand:<VEL> 0 "register_operand")
3685 (unspec:VDQ_BHSI [(match_operand:VDQ_BHSI 1 "register_operand")]
3686 MAXMINV)]
3687 "TARGET_SIMD"
3688 {
3689 rtx elt = aarch64_endian_lane_rtx (<MODE>mode, 0);
3690 rtx scratch = gen_reg_rtx (<MODE>mode);
3691 emit_insn (gen_aarch64_reduc_<optab>_internal<mode> (scratch,
3692 operands[1]));
3693 emit_insn (gen_aarch64_get_lane<mode> (operands[0], scratch, elt));
3694 DONE;
3695 }
3696 )
3697
3698 (define_insn "aarch64_reduc_<optab>_internal<mode>"
3699 [(set (match_operand:VDQV_S 0 "register_operand" "=w")
3700 (unspec:VDQV_S [(match_operand:VDQV_S 1 "register_operand" "w")]
3701 MAXMINV))]
3702 "TARGET_SIMD"
3703 "<maxmin_uns_op>v\\t%<Vetype>0, %1.<Vtype>"
3704 [(set_attr "type" "neon_reduc_minmax<q>")]
3705 )
3706
3707 (define_insn "aarch64_reduc_<optab>_internalv2si"
3708 [(set (match_operand:V2SI 0 "register_operand" "=w")
3709 (unspec:V2SI [(match_operand:V2SI 1 "register_operand" "w")]
3710 MAXMINV))]
3711 "TARGET_SIMD"
3712 "<maxmin_uns_op>p\\t%0.2s, %1.2s, %1.2s"
3713 [(set_attr "type" "neon_reduc_minmax")]
3714 )
3715
3716 (define_insn "aarch64_reduc_<optab>_internal<mode>"
3717 [(set (match_operand:VHSDF 0 "register_operand" "=w")
3718 (unspec:VHSDF [(match_operand:VHSDF 1 "register_operand" "w")]
3719 FMAXMINV))]
3720 "TARGET_SIMD"
3721 "<maxmin_uns_op><vp>\\t%<Vetype>0, %1.<Vtype>"
3722 [(set_attr "type" "neon_fp_reduc_minmax_<stype><q>")]
3723 )
3724
3725 ;; aarch64_simd_bsl may compile to any of bsl/bif/bit depending on register
3726 ;; allocation.
3727 ;; Operand 1 is the mask, operands 2 and 3 are the bitfields from which
3728 ;; to select.
3729 ;;
3730 ;; Thus our BSL is of the form:
3731 ;; op0 = bsl (mask, op2, op3)
3732 ;; We can use any of:
3733 ;;
3734 ;; if (op0 = mask)
3735 ;; bsl mask, op1, op2
3736 ;; if (op0 = op1) (so 1-bits in mask choose bits from op2, else op0)
3737 ;; bit op0, op2, mask
3738 ;; if (op0 = op2) (so 0-bits in mask choose bits from op1, else op0)
3739 ;; bif op0, op1, mask
3740 ;;
3741 ;; This pattern is expanded to by the aarch64_simd_bsl<mode> expander.
3742 ;; Some forms of straight-line code may generate the equivalent form
3743 ;; in *aarch64_simd_bsl<mode>_alt.
3744
3745 (define_insn "aarch64_simd_bsl<mode>_internal<vczle><vczbe>"
3746 [(set (match_operand:VDQ_I 0 "register_operand")
3747 (xor:VDQ_I
3748 (and:VDQ_I
3749 (xor:VDQ_I
3750 (match_operand:<V_INT_EQUIV> 3 "register_operand")
3751 (match_operand:VDQ_I 2 "register_operand"))
3752 (match_operand:VDQ_I 1 "register_operand"))
3753 (match_dup:<V_INT_EQUIV> 3)
3754 ))]
3755 "TARGET_SIMD"
3756 {@ [ cons: =0 , 1 , 2 , 3 ]
3757 [ w , 0 , w , w ] bsl\t%0.<Vbtype>, %2.<Vbtype>, %3.<Vbtype>
3758 [ w , w , w , 0 ] bit\t%0.<Vbtype>, %2.<Vbtype>, %1.<Vbtype>
3759 [ w , w , 0 , w ] bif\t%0.<Vbtype>, %3.<Vbtype>, %1.<Vbtype>
3760 }
3761 [(set_attr "type" "neon_bsl<q>")]
3762 )
3763
3764 ;; We need this form in addition to the above pattern to match the case
3765 ;; when combine tries merging three insns such that the second operand of
3766 ;; the outer XOR matches the second operand of the inner XOR rather than
3767 ;; the first. The two are equivalent but since recog doesn't try all
3768 ;; permutations of commutative operations, we have to have a separate pattern.
3769
3770 (define_insn "*aarch64_simd_bsl<mode>_alt<vczle><vczbe>"
3771 [(set (match_operand:VDQ_I 0 "register_operand")
3772 (xor:VDQ_I
3773 (and:VDQ_I
3774 (xor:VDQ_I
3775 (match_operand:VDQ_I 3 "register_operand")
3776 (match_operand:<V_INT_EQUIV> 2 "register_operand"))
3777 (match_operand:VDQ_I 1 "register_operand"))
3778 (match_dup:<V_INT_EQUIV> 2)))]
3779 "TARGET_SIMD"
3780 {@ [ cons: =0 , 1 , 2 , 3 ]
3781 [ w , 0 , w , w ] bsl\t%0.<Vbtype>, %3.<Vbtype>, %2.<Vbtype>
3782 [ w , w , 0 , w ] bit\t%0.<Vbtype>, %3.<Vbtype>, %1.<Vbtype>
3783 [ w , w , w , 0 ] bif\t%0.<Vbtype>, %2.<Vbtype>, %1.<Vbtype>
3784 }
3785 [(set_attr "type" "neon_bsl<q>")]
3786 )
3787
3788 ;; DImode is special, we want to avoid computing operations which are
3789 ;; more naturally computed in general purpose registers in the vector
3790 ;; registers. If we do that, we need to move all three operands from general
3791 ;; purpose registers to vector registers, then back again. However, we
3792 ;; don't want to make this pattern an UNSPEC as we'd lose scope for
3793 ;; optimizations based on the component operations of a BSL.
3794 ;;
3795 ;; That means we need a splitter back to the individual operations, if they
3796 ;; would be better calculated on the integer side.
3797
3798 (define_insn_and_split "aarch64_simd_bsldi_internal"
3799 [(set (match_operand:DI 0 "register_operand")
3800 (xor:DI
3801 (and:DI
3802 (xor:DI
3803 (match_operand:DI 3 "register_operand")
3804 (match_operand:DI 2 "register_operand"))
3805 (match_operand:DI 1 "register_operand"))
3806 (match_dup:DI 3)
3807 ))]
3808 "TARGET_SIMD"
3809 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: type , length ]
3810 [ w , 0 , w , w ; neon_bsl , 4 ] bsl\t%0.8b, %2.8b, %3.8b
3811 [ w , w , w , 0 ; neon_bsl , 4 ] bit\t%0.8b, %2.8b, %1.8b
3812 [ w , w , 0 , w ; neon_bsl , 4 ] bif\t%0.8b, %3.8b, %1.8b
3813 [ &r , r , r , r ; multiple , 12 ] #
3814 }
3815 "&& REG_P (operands[0]) && GP_REGNUM_P (REGNO (operands[0]))"
3816 [(match_dup 1) (match_dup 1) (match_dup 2) (match_dup 3)]
3817 {
3818 /* Split back to individual operations. If we're before reload, and
3819 able to create a temporary register, do so. If we're after reload,
3820 we've got an early-clobber destination register, so use that.
3821 Otherwise, we can't create pseudos and we can't yet guarantee that
3822 operands[0] is safe to write, so FAIL to split. */
3823
3824 rtx scratch;
3825 if (reload_completed)
3826 scratch = operands[0];
3827 else if (can_create_pseudo_p ())
3828 scratch = gen_reg_rtx (DImode);
3829 else
3830 FAIL;
3831
3832 emit_insn (gen_xordi3 (scratch, operands[2], operands[3]));
3833 emit_insn (gen_anddi3 (scratch, scratch, operands[1]));
3834 emit_insn (gen_xordi3 (operands[0], scratch, operands[3]));
3835 DONE;
3836 }
3837 )
3838
3839 (define_insn_and_split "aarch64_simd_bsldi_alt"
3840 [(set (match_operand:DI 0 "register_operand")
3841 (xor:DI
3842 (and:DI
3843 (xor:DI
3844 (match_operand:DI 3 "register_operand")
3845 (match_operand:DI 2 "register_operand"))
3846 (match_operand:DI 1 "register_operand"))
3847 (match_dup:DI 2)
3848 ))]
3849 "TARGET_SIMD"
3850 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: type , length ]
3851 [ w , 0 , w , w ; neon_bsl , 4 ] bsl\t%0.8b, %3.8b, %2.8b
3852 [ w , w , 0 , w ; neon_bsl , 4 ] bit\t%0.8b, %3.8b, %1.8b
3853 [ w , w , w , 0 ; neon_bsl , 4 ] bif\t%0.8b, %2.8b, %1.8b
3854 [ &r , r , r , r ; multiple , 12 ] #
3855 }
3856 "&& REG_P (operands[0]) && GP_REGNUM_P (REGNO (operands[0]))"
3857 [(match_dup 0) (match_dup 1) (match_dup 2) (match_dup 3)]
3858 {
3859 /* Split back to individual operations. If we're before reload, and
3860 able to create a temporary register, do so. If we're after reload,
3861 we've got an early-clobber destination register, so use that.
3862 Otherwise, we can't create pseudos and we can't yet guarantee that
3863 operands[0] is safe to write, so FAIL to split. */
3864
3865 rtx scratch;
3866 if (reload_completed)
3867 scratch = operands[0];
3868 else if (can_create_pseudo_p ())
3869 scratch = gen_reg_rtx (DImode);
3870 else
3871 FAIL;
3872
3873 emit_insn (gen_xordi3 (scratch, operands[2], operands[3]));
3874 emit_insn (gen_anddi3 (scratch, scratch, operands[1]));
3875 emit_insn (gen_xordi3 (operands[0], scratch, operands[2]));
3876 DONE;
3877 }
3878 )
3879
3880 (define_expand "@aarch64_simd_bsl<mode>"
3881 [(match_operand:VALLDIF 0 "register_operand")
3882 (match_operand:<V_INT_EQUIV> 1 "register_operand")
3883 (match_operand:VALLDIF 2 "register_operand")
3884 (match_operand:VALLDIF 3 "register_operand")]
3885 "TARGET_SIMD"
3886 {
3887 /* We can't alias operands together if they have different modes. */
3888 rtx tmp = operands[0];
3889 if (FLOAT_MODE_P (<MODE>mode))
3890 {
3891 operands[2] = gen_lowpart (<V_INT_EQUIV>mode, operands[2]);
3892 operands[3] = gen_lowpart (<V_INT_EQUIV>mode, operands[3]);
3893 tmp = gen_reg_rtx (<V_INT_EQUIV>mode);
3894 }
3895 operands[1] = gen_lowpart (<V_INT_EQUIV>mode, operands[1]);
3896 emit_insn (gen_aarch64_simd_bsl<v_int_equiv>_internal (tmp,
3897 operands[1],
3898 operands[2],
3899 operands[3]));
3900 if (tmp != operands[0])
3901 emit_move_insn (operands[0], gen_lowpart (<MODE>mode, tmp));
3902
3903 DONE;
3904 })
3905
3906 (define_expand "vcond_mask_<mode><v_int_equiv>"
3907 [(match_operand:VALLDI 0 "register_operand")
3908 (match_operand:VALLDI 1 "nonmemory_operand")
3909 (match_operand:VALLDI 2 "nonmemory_operand")
3910 (match_operand:<V_INT_EQUIV> 3 "register_operand")]
3911 "TARGET_SIMD"
3912 {
3913 /* If we have (a = (P) ? -1 : 0);
3914 Then we can simply move the generated mask (result must be int). */
3915 if (operands[1] == CONSTM1_RTX (<MODE>mode)
3916 && operands[2] == CONST0_RTX (<MODE>mode))
3917 emit_move_insn (operands[0], operands[3]);
3918 /* Similarly, (a = (P) ? 0 : -1) is just inverting the generated mask. */
3919 else if (operands[1] == CONST0_RTX (<MODE>mode)
3920 && operands[2] == CONSTM1_RTX (<MODE>mode))
3921 emit_insn (gen_one_cmpl<v_int_equiv>2 (operands[0], operands[3]));
3922 else
3923 {
3924 if (!REG_P (operands[1]))
3925 operands[1] = force_reg (<MODE>mode, operands[1]);
3926 if (!REG_P (operands[2]))
3927 operands[2] = force_reg (<MODE>mode, operands[2]);
3928 emit_insn (gen_aarch64_simd_bsl<mode> (operands[0], operands[3],
3929 operands[1], operands[2]));
3930 }
3931
3932 DONE;
3933 })
3934
3935 ;; Patterns comparing two vectors and conditionally jump
3936
3937 (define_expand "cbranch<mode>4"
3938 [(set (pc)
3939 (if_then_else
3940 (match_operator 0 "aarch64_equality_operator"
3941 [(match_operand:VDQ_I 1 "register_operand")
3942 (match_operand:VDQ_I 2 "aarch64_simd_reg_or_zero")])
3943 (label_ref (match_operand 3 ""))
3944 (pc)))]
3945 "TARGET_SIMD"
3946 {
3947 auto code = GET_CODE (operands[0]);
3948 rtx tmp = operands[1];
3949
3950 /* If comparing against a non-zero vector we have to do a comparison first
3951 so we can have a != 0 comparison with the result. */
3952 if (operands[2] != CONST0_RTX (<MODE>mode))
3953 {
3954 tmp = gen_reg_rtx (<MODE>mode);
3955 emit_insn (gen_xor<mode>3 (tmp, operands[1], operands[2]));
3956 }
3957
3958 /* For 64-bit vectors we need no reductions. */
3959 if (known_eq (128, GET_MODE_BITSIZE (<MODE>mode)))
3960 {
3961 /* Always reduce using a V4SI. */
3962 rtx reduc = gen_lowpart (V4SImode, tmp);
3963 rtx res = gen_reg_rtx (V4SImode);
3964 emit_insn (gen_aarch64_umaxpv4si (res, reduc, reduc));
3965 emit_move_insn (tmp, gen_lowpart (<MODE>mode, res));
3966 }
3967
3968 rtx val = gen_reg_rtx (DImode);
3969 emit_move_insn (val, gen_lowpart (DImode, tmp));
3970
3971 rtx cc_reg = aarch64_gen_compare_reg (code, val, const0_rtx);
3972 rtx cmp_rtx = gen_rtx_fmt_ee (code, DImode, cc_reg, const0_rtx);
3973 emit_jump_insn (gen_condjump (cmp_rtx, cc_reg, operands[3]));
3974 DONE;
3975 })
3976
3977 ;; Patterns comparing two vectors to produce a mask.
3978
3979 (define_expand "vec_cmp<mode><mode>"
3980 [(set (match_operand:VSDQ_I_DI 0 "register_operand")
3981 (match_operator 1 "comparison_operator"
3982 [(match_operand:VSDQ_I_DI 2 "register_operand")
3983 (match_operand:VSDQ_I_DI 3 "nonmemory_operand")]))]
3984 "TARGET_SIMD"
3985 {
3986 rtx mask = operands[0];
3987 enum rtx_code code = GET_CODE (operands[1]);
3988
3989 switch (code)
3990 {
3991 case NE:
3992 case LE:
3993 case LT:
3994 case GE:
3995 case GT:
3996 case EQ:
3997 if (operands[3] == CONST0_RTX (<MODE>mode))
3998 break;
3999
4000 /* Fall through. */
4001 default:
4002 if (!REG_P (operands[3]))
4003 operands[3] = force_reg (<MODE>mode, operands[3]);
4004
4005 break;
4006 }
4007
4008 switch (code)
4009 {
4010 case LT:
4011 emit_insn (gen_aarch64_cmlt<mode> (mask, operands[2], operands[3]));
4012 break;
4013
4014 case GE:
4015 emit_insn (gen_aarch64_cmge<mode> (mask, operands[2], operands[3]));
4016 break;
4017
4018 case LE:
4019 emit_insn (gen_aarch64_cmle<mode> (mask, operands[2], operands[3]));
4020 break;
4021
4022 case GT:
4023 emit_insn (gen_aarch64_cmgt<mode> (mask, operands[2], operands[3]));
4024 break;
4025
4026 case LTU:
4027 emit_insn (gen_aarch64_cmgtu<mode> (mask, operands[3], operands[2]));
4028 break;
4029
4030 case GEU:
4031 emit_insn (gen_aarch64_cmgeu<mode> (mask, operands[2], operands[3]));
4032 break;
4033
4034 case LEU:
4035 emit_insn (gen_aarch64_cmgeu<mode> (mask, operands[3], operands[2]));
4036 break;
4037
4038 case GTU:
4039 emit_insn (gen_aarch64_cmgtu<mode> (mask, operands[2], operands[3]));
4040 break;
4041
4042 case NE:
4043 /* Handle NE as !EQ. */
4044 emit_insn (gen_aarch64_cmeq<mode> (mask, operands[2], operands[3]));
4045 emit_insn (gen_one_cmpl<v_int_equiv>2 (mask, mask));
4046 break;
4047
4048 case EQ:
4049 emit_insn (gen_aarch64_cmeq<mode> (mask, operands[2], operands[3]));
4050 break;
4051
4052 default:
4053 gcc_unreachable ();
4054 }
4055
4056 DONE;
4057 })
4058
4059 (define_expand "vec_cmp<mode><v_int_equiv>"
4060 [(set (match_operand:<V_INT_EQUIV> 0 "register_operand")
4061 (match_operator 1 "comparison_operator"
4062 [(match_operand:VDQF 2 "register_operand")
4063 (match_operand:VDQF 3 "nonmemory_operand")]))]
4064 "TARGET_SIMD"
4065 {
4066 int use_zero_form = 0;
4067 enum rtx_code code = GET_CODE (operands[1]);
4068 rtx tmp = gen_reg_rtx (<V_INT_EQUIV>mode);
4069
4070 rtx (*comparison) (rtx, rtx, rtx) = NULL;
4071
4072 switch (code)
4073 {
4074 case LE:
4075 case LT:
4076 case GE:
4077 case GT:
4078 case EQ:
4079 if (operands[3] == CONST0_RTX (<MODE>mode))
4080 {
4081 use_zero_form = 1;
4082 break;
4083 }
4084 /* Fall through. */
4085 default:
4086 if (!REG_P (operands[3]))
4087 operands[3] = force_reg (<MODE>mode, operands[3]);
4088
4089 break;
4090 }
4091
4092 switch (code)
4093 {
4094 case LT:
4095 if (use_zero_form)
4096 {
4097 comparison = gen_aarch64_cmlt<mode>;
4098 break;
4099 }
4100 /* Fall through. */
4101 case UNLT:
4102 std::swap (operands[2], operands[3]);
4103 /* Fall through. */
4104 case UNGT:
4105 case GT:
4106 comparison = gen_aarch64_cmgt<mode>;
4107 break;
4108 case LE:
4109 if (use_zero_form)
4110 {
4111 comparison = gen_aarch64_cmle<mode>;
4112 break;
4113 }
4114 /* Fall through. */
4115 case UNLE:
4116 std::swap (operands[2], operands[3]);
4117 /* Fall through. */
4118 case UNGE:
4119 case GE:
4120 comparison = gen_aarch64_cmge<mode>;
4121 break;
4122 case NE:
4123 case EQ:
4124 comparison = gen_aarch64_cmeq<mode>;
4125 break;
4126 case UNEQ:
4127 case ORDERED:
4128 case UNORDERED:
4129 case LTGT:
4130 break;
4131 default:
4132 gcc_unreachable ();
4133 }
4134
4135 switch (code)
4136 {
4137 case UNGE:
4138 case UNGT:
4139 case UNLE:
4140 case UNLT:
4141 {
4142 /* All of the above must not raise any FP exceptions. Thus we first
4143 check each operand for NaNs and force any elements containing NaN to
4144 zero before using them in the compare.
4145 Example: UN<cc> (a, b) -> UNORDERED (a, b) |
4146 (cm<cc> (isnan (a) ? 0.0 : a,
4147 isnan (b) ? 0.0 : b))
4148 We use the following transformations for doing the comparisions:
4149 a UNGE b -> a GE b
4150 a UNGT b -> a GT b
4151 a UNLE b -> b GE a
4152 a UNLT b -> b GT a. */
4153
4154 rtx tmp0 = gen_reg_rtx (<V_INT_EQUIV>mode);
4155 rtx tmp1 = gen_reg_rtx (<V_INT_EQUIV>mode);
4156 rtx tmp2 = gen_reg_rtx (<V_INT_EQUIV>mode);
4157 emit_insn (gen_aarch64_cmeq<mode> (tmp0, operands[2], operands[2]));
4158 emit_insn (gen_aarch64_cmeq<mode> (tmp1, operands[3], operands[3]));
4159 emit_insn (gen_and<v_int_equiv>3 (tmp2, tmp0, tmp1));
4160 emit_insn (gen_and<v_int_equiv>3 (tmp0, tmp0,
4161 lowpart_subreg (<V_INT_EQUIV>mode,
4162 operands[2],
4163 <MODE>mode)));
4164 emit_insn (gen_and<v_int_equiv>3 (tmp1, tmp1,
4165 lowpart_subreg (<V_INT_EQUIV>mode,
4166 operands[3],
4167 <MODE>mode)));
4168 gcc_assert (comparison != NULL);
4169 emit_insn (comparison (operands[0],
4170 lowpart_subreg (<MODE>mode,
4171 tmp0, <V_INT_EQUIV>mode),
4172 lowpart_subreg (<MODE>mode,
4173 tmp1, <V_INT_EQUIV>mode)));
4174 emit_insn (gen_iorn<v_int_equiv>3 (operands[0], operands[0], tmp2));
4175 }
4176 break;
4177
4178 case LT:
4179 case LE:
4180 case GT:
4181 case GE:
4182 case EQ:
4183 case NE:
4184 /* The easy case. Here we emit one of FCMGE, FCMGT or FCMEQ.
4185 As a LT b <=> b GE a && a LE b <=> b GT a. Our transformations are:
4186 a GE b -> a GE b
4187 a GT b -> a GT b
4188 a LE b -> b GE a
4189 a LT b -> b GT a
4190 a EQ b -> a EQ b
4191 a NE b -> ~(a EQ b) */
4192 gcc_assert (comparison != NULL);
4193 emit_insn (comparison (operands[0], operands[2], operands[3]));
4194 if (code == NE)
4195 emit_insn (gen_one_cmpl<v_int_equiv>2 (operands[0], operands[0]));
4196 break;
4197
4198 case LTGT:
4199 /* LTGT is not guranteed to not generate a FP exception. So let's
4200 go the faster way : ((a > b) || (b > a)). */
4201 emit_insn (gen_aarch64_cmgt<mode> (operands[0],
4202 operands[2], operands[3]));
4203 emit_insn (gen_aarch64_cmgt<mode> (tmp, operands[3], operands[2]));
4204 emit_insn (gen_ior<v_int_equiv>3 (operands[0], operands[0], tmp));
4205 break;
4206
4207 case ORDERED:
4208 case UNORDERED:
4209 case UNEQ:
4210 /* cmeq (a, a) & cmeq (b, b). */
4211 emit_insn (gen_aarch64_cmeq<mode> (operands[0],
4212 operands[2], operands[2]));
4213 emit_insn (gen_aarch64_cmeq<mode> (tmp, operands[3], operands[3]));
4214 emit_insn (gen_and<v_int_equiv>3 (operands[0], operands[0], tmp));
4215
4216 if (code == UNORDERED)
4217 emit_insn (gen_one_cmpl<v_int_equiv>2 (operands[0], operands[0]));
4218 else if (code == UNEQ)
4219 {
4220 emit_insn (gen_aarch64_cmeq<mode> (tmp, operands[2], operands[3]));
4221 emit_insn (gen_iorn<v_int_equiv>3 (operands[0], tmp, operands[0]));
4222 }
4223 break;
4224
4225 default:
4226 gcc_unreachable ();
4227 }
4228
4229 DONE;
4230 })
4231
4232 (define_expand "vec_cmpu<mode><mode>"
4233 [(set (match_operand:VSDQ_I_DI 0 "register_operand")
4234 (match_operator 1 "comparison_operator"
4235 [(match_operand:VSDQ_I_DI 2 "register_operand")
4236 (match_operand:VSDQ_I_DI 3 "nonmemory_operand")]))]
4237 "TARGET_SIMD"
4238 {
4239 emit_insn (gen_vec_cmp<mode><mode> (operands[0], operands[1],
4240 operands[2], operands[3]));
4241 DONE;
4242 })
4243
4244 ;; Patterns for AArch64 SIMD Intrinsics.
4245
4246 ;; Lane extraction with sign extension to general purpose register.
4247 (define_insn "*aarch64_get_lane_extend<GPI:mode><VDQQH:mode>"
4248 [(set (match_operand:GPI 0 "register_operand" "=r")
4249 (sign_extend:GPI
4250 (vec_select:<VDQQH:VEL>
4251 (match_operand:VDQQH 1 "register_operand" "w")
4252 (parallel [(match_operand:SI 2 "immediate_operand" "i")]))))]
4253 "TARGET_SIMD"
4254 {
4255 operands[2] = aarch64_endian_lane_rtx (<VDQQH:MODE>mode,
4256 INTVAL (operands[2]));
4257 return "smov\\t%<GPI:w>0, %1.<VDQQH:Vetype>[%2]";
4258 }
4259 [(set_attr "type" "neon_to_gp<VDQQH:q>")]
4260 )
4261
4262 (define_insn "*aarch64_get_lane_zero_extend<GPI:mode><VDQQH:mode>"
4263 [(set (match_operand:GPI 0 "register_operand" "=r")
4264 (zero_extend:GPI
4265 (vec_select:<VDQQH:VEL>
4266 (match_operand:VDQQH 1 "register_operand" "w")
4267 (parallel [(match_operand:SI 2 "immediate_operand" "i")]))))]
4268 "TARGET_SIMD"
4269 {
4270 operands[2] = aarch64_endian_lane_rtx (<VDQQH:MODE>mode,
4271 INTVAL (operands[2]));
4272 return "umov\\t%w0, %1.<VDQQH:Vetype>[%2]";
4273 }
4274 [(set_attr "type" "neon_to_gp<VDQQH:q>")]
4275 )
4276
4277 ;; Lane extraction of a value, neither sign nor zero extension
4278 ;; is guaranteed so upper bits should be considered undefined.
4279 ;; RTL uses GCC vector extension indices throughout so flip only for assembly.
4280 ;; Extracting lane zero is split into a simple move when it is between SIMD
4281 ;; registers or a store.
4282 (define_insn_and_split "@aarch64_get_lane<mode>"
4283 [(set (match_operand:<VEL> 0 "aarch64_simd_nonimmediate_operand" "=?r, w, Utv")
4284 (vec_select:<VEL>
4285 (match_operand:VALL_F16 1 "register_operand" "w, w, w")
4286 (parallel [(match_operand:SI 2 "immediate_operand" "i, i, i")])))]
4287 "TARGET_SIMD"
4288 {
4289 operands[2] = aarch64_endian_lane_rtx (<MODE>mode, INTVAL (operands[2]));
4290 switch (which_alternative)
4291 {
4292 case 0:
4293 return "umov\\t%<vwcore>0, %1.<Vetype>[%2]";
4294 case 1:
4295 return "dup\\t%<Vetype>0, %1.<Vetype>[%2]";
4296 case 2:
4297 return "st1\\t{%1.<Vetype>}[%2], %0";
4298 default:
4299 gcc_unreachable ();
4300 }
4301 }
4302 "&& reload_completed
4303 && ENDIAN_LANE_N (<nunits>, INTVAL (operands[2])) == 0"
4304 [(set (match_dup 0) (match_dup 1))]
4305 {
4306 operands[1] = aarch64_replace_reg_mode (operands[1], <VEL>mode);
4307 }
4308 [(set_attr "type" "neon_to_gp<q>, neon_dup<q>, neon_store1_one_lane<q>")]
4309 )
4310
4311 (define_insn "*aarch64_get_high<mode>"
4312 [(set (match_operand:<VEL> 0 "aarch64_simd_nonimmediate_operand" "=r")
4313 (vec_select:<VEL>
4314 (match_operand:VQ_2E 1 "register_operand" "w")
4315 (parallel [(match_operand:SI 2 "immediate_operand")])))]
4316 "TARGET_FLOAT && ENDIAN_LANE_N (<nunits>, INTVAL (operands[2])) == 1"
4317 "fmov\t%0, %1.d[1]"
4318 [(set_attr "type" "f_mrc")]
4319 )
4320
4321 (define_insn "load_pair_lanes<mode>"
4322 [(set (match_operand:<VDBL> 0 "register_operand" "=w")
4323 (vec_concat:<VDBL>
4324 (match_operand:VDCSIF 1 "memory_operand" "Utq")
4325 (match_operand:VDCSIF 2 "memory_operand" "m")))]
4326 "TARGET_FLOAT
4327 && aarch64_mergeable_load_pair_p (<VDBL>mode, operands[1], operands[2])"
4328 "ldr\\t%<single_dtype>0, %1"
4329 [(set_attr "type" "neon_load1_1reg<dblq>")]
4330 )
4331
4332 ;; This STP pattern is a partial duplicate of the general vec_concat patterns
4333 ;; below. The reason for having both of them is that the alternatives of
4334 ;; the later patterns do not have consistent register preferences: the STP
4335 ;; alternatives have no preference between GPRs and FPRs (and if anything,
4336 ;; the GPR form is more natural for scalar integers) whereas the other
4337 ;; alternatives *require* an FPR for operand 1 and prefer one for operand 2.
4338 ;;
4339 ;; Using "*" to hide the STP alternatives from the RA penalizes cases in
4340 ;; which the destination was always memory. On the other hand, expressing
4341 ;; the true preferences makes GPRs seem more palatable than they really are
4342 ;; for register destinations.
4343 ;;
4344 ;; Despite that, we do still want the general form to have STP alternatives,
4345 ;; in order to handle cases where a register destination is spilled.
4346 ;;
4347 ;; The best compromise therefore seemed to be to have a dedicated STP
4348 ;; pattern to catch cases in which the destination was always memory.
4349 ;; This dedicated pattern must come first.
4350
4351 (define_insn "store_pair_lanes<mode>"
4352 [(set (match_operand:<VDBL> 0 "aarch64_mem_pair_lanes_operand")
4353 (vec_concat:<VDBL>
4354 (match_operand:VDCSIF 1 "register_operand")
4355 (match_operand:VDCSIF 2 "register_operand")))]
4356 "TARGET_FLOAT"
4357 {@ [ cons: =0 , 1 , 2 ; attrs: type ]
4358 [ Umn , w , w ; neon_stp ] stp\t%<single_type>1, %<single_type>2, %y0
4359 [ Umn , r , r ; store_16 ] stp\t%<single_wx>1, %<single_wx>2, %y0
4360 }
4361 )
4362
4363 ;; Form a vector whose least significant half comes from operand 1 and whose
4364 ;; most significant half comes from operand 2. The register alternatives
4365 ;; tie the least significant half to the same register as the destination,
4366 ;; so that only the other half needs to be handled explicitly. For the
4367 ;; reasons given above, the STP alternatives use ? for constraints that
4368 ;; the register alternatives either don't accept or themselves disparage.
4369
4370 (define_insn "*aarch64_combine_internal<mode>"
4371 [(set (match_operand:<VDBL> 0 "aarch64_reg_or_mem_pair_operand")
4372 (vec_concat:<VDBL>
4373 (match_operand:VDCSIF 1 "register_operand")
4374 (match_operand:VDCSIF 2 "aarch64_simd_nonimmediate_operand")))]
4375 "TARGET_FLOAT
4376 && !BYTES_BIG_ENDIAN
4377 && (register_operand (operands[0], <VDBL>mode)
4378 || register_operand (operands[2], <MODE>mode))"
4379 {@ [ cons: =0 , 1 , 2 ; attrs: type , arch ]
4380 [ w , w , w ; neon_permute<dblq> , simd ] uzp1\t%0.2<single_type>, %1.2<single_type>, %2.2<single_type>
4381 [ w , 0 , ?r ; neon_from_gp<dblq> , simd ] ins\t%0.<single_type>[1], %<single_wx>2
4382 [ w , 0 , ?r ; f_mcr , * ] fmov\t%0.d[1], %2
4383 [ w , 0 , Utv ; neon_load1_one_lane<dblq> , simd ] ld1\t{%0.<single_type>}[1], %2
4384 [ Umn , ?w , w ; neon_stp , * ] stp\t%<single_type>1, %<single_type>2, %y0
4385 [ Umn , ?r , ?r ; store_16 , * ] stp\t%<single_wx>1, %<single_wx>2, %y0
4386 }
4387 )
4388
4389 (define_insn "*aarch64_combine_internal_be<mode>"
4390 [(set (match_operand:<VDBL> 0 "aarch64_reg_or_mem_pair_operand")
4391 (vec_concat:<VDBL>
4392 (match_operand:VDCSIF 2 "aarch64_simd_nonimmediate_operand")
4393 (match_operand:VDCSIF 1 "register_operand")))]
4394 "TARGET_FLOAT
4395 && BYTES_BIG_ENDIAN
4396 && (register_operand (operands[0], <VDBL>mode)
4397 || register_operand (operands[2], <MODE>mode))"
4398 {@ [ cons: =0 , 1 , 2 ; attrs: type , arch ]
4399 [ w , w , w ; neon_permute<dblq> , simd ] uzp1\t%0.2<single_type>, %1.2<single_type>, %2.2<single_type>
4400 [ w , 0 , ?r ; neon_from_gp<dblq> , simd ] ins\t%0.<single_type>[1], %<single_wx>2
4401 [ w , 0 , ?r ; f_mcr , * ] fmov\t%0.d[1], %2
4402 [ w , 0 , Utv ; neon_load1_one_lane<dblq> , simd ] ld1\t{%0.<single_type>}[1], %2
4403 [ Umn , ?w , ?w ; neon_stp , * ] stp\t%<single_type>2, %<single_type>1, %y0
4404 [ Umn , ?r , ?r ; store_16 , * ] stp\t%<single_wx>2, %<single_wx>1, %y0
4405 }
4406 )
4407
4408 ;; In this insn, operand 1 should be low, and operand 2 the high part of the
4409 ;; dest vector.
4410
4411 (define_insn "*aarch64_combinez<mode>"
4412 [(set (match_operand:<VDBL> 0 "register_operand")
4413 (vec_concat:<VDBL>
4414 (match_operand:VDCSIF 1 "nonimmediate_operand")
4415 (match_operand:VDCSIF 2 "aarch64_simd_or_scalar_imm_zero")))]
4416 "TARGET_FLOAT && !BYTES_BIG_ENDIAN"
4417 {@ [ cons: =0 , 1 ; attrs: type ]
4418 [ w , w ; neon_move<q> ] fmov\t%<single_type>0, %<single_type>1
4419 [ w , ?r ; neon_from_gp ] fmov\t%<single_type>0, %<single_wx>1
4420 [ w , m ; neon_load1_1reg ] ldr\t%<single_type>0, %1
4421 }
4422 )
4423
4424 (define_insn "*aarch64_combinez_be<mode>"
4425 [(set (match_operand:<VDBL> 0 "register_operand")
4426 (vec_concat:<VDBL>
4427 (match_operand:VDCSIF 2 "aarch64_simd_or_scalar_imm_zero")
4428 (match_operand:VDCSIF 1 "nonimmediate_operand")))]
4429 "TARGET_FLOAT && BYTES_BIG_ENDIAN"
4430 {@ [ cons: =0 , 1 ; attrs: type ]
4431 [ w , w ; neon_move<q> ] fmov\t%<single_type>0, %<single_type>1
4432 [ w , ?r ; neon_from_gp ] fmov\t%<single_type>0, %<single_wx>1
4433 [ w , m ; neon_load1_1reg ] ldr\t%<single_type>0, %1
4434 }
4435 )
4436
4437 ;; Form a vector whose first half (in array order) comes from operand 1
4438 ;; and whose second half (in array order) comes from operand 2.
4439 ;; This operand order follows the RTL vec_concat operation.
4440 (define_expand "@aarch64_vec_concat<mode>"
4441 [(set (match_operand:<VDBL> 0 "register_operand")
4442 (vec_concat:<VDBL>
4443 (match_operand:VDCSIF 1 "general_operand")
4444 (match_operand:VDCSIF 2 "general_operand")))]
4445 "TARGET_FLOAT"
4446 {
4447 int lo = BYTES_BIG_ENDIAN ? 2 : 1;
4448 int hi = BYTES_BIG_ENDIAN ? 1 : 2;
4449
4450 if (MEM_P (operands[1])
4451 && MEM_P (operands[2])
4452 && aarch64_mergeable_load_pair_p (<VDBL>mode, operands[1], operands[2]))
4453 /* Use load_pair_lanes<mode>. */
4454 ;
4455 else if (operands[hi] == CONST0_RTX (<MODE>mode))
4456 {
4457 /* Use *aarch64_combinez<mode>. */
4458 if (!nonimmediate_operand (operands[lo], <MODE>mode))
4459 operands[lo] = force_reg (<MODE>mode, operands[lo]);
4460 }
4461 else
4462 {
4463 /* Use *aarch64_combine_internal<mode>. */
4464 operands[lo] = force_reg (<MODE>mode, operands[lo]);
4465 if (!aarch64_simd_nonimmediate_operand (operands[hi], <MODE>mode))
4466 {
4467 if (MEM_P (operands[hi]))
4468 {
4469 rtx addr = force_reg (Pmode, XEXP (operands[hi], 0));
4470 operands[hi] = replace_equiv_address (operands[hi], addr);
4471 }
4472 else
4473 operands[hi] = force_reg (<MODE>mode, operands[hi]);
4474 }
4475 }
4476 })
4477
4478 ;; Form a vector whose least significant half comes from operand 1 and whose
4479 ;; most significant half comes from operand 2. This operand order follows
4480 ;; arm_neon.h vcombine* intrinsics.
4481 (define_expand "@aarch64_combine<mode>"
4482 [(match_operand:<VDBL> 0 "register_operand")
4483 (match_operand:VDC 1 "general_operand")
4484 (match_operand:VDC 2 "general_operand")]
4485 "TARGET_FLOAT"
4486 {
4487 if (BYTES_BIG_ENDIAN)
4488 std::swap (operands[1], operands[2]);
4489 emit_insn (gen_aarch64_vec_concat<mode> (operands[0], operands[1],
4490 operands[2]));
4491 DONE;
4492 }
4493 )
4494
4495 ;; <su><addsub>l<q>.
4496
4497 (define_insn "aarch64_<ANY_EXTEND:su><ADDSUB:optab>l<mode>_hi_internal"
4498 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
4499 (ADDSUB:<VWIDE> (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
4500 (match_operand:VQW 1 "register_operand" "w")
4501 (match_operand:VQW 3 "vect_par_cnst_hi_half" "")))
4502 (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
4503 (match_operand:VQW 2 "register_operand" "w")
4504 (match_dup 3)))))]
4505 "TARGET_SIMD"
4506 "<ANY_EXTEND:su><ADDSUB:optab>l2\t%0.<Vwtype>, %1.<Vtype>, %2.<Vtype>"
4507 [(set_attr "type" "neon_<ADDSUB:optab>_long")]
4508 )
4509
4510 (define_insn "aarch64_<ANY_EXTEND:su><ADDSUB:optab>l<mode>_lo_internal"
4511 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
4512 (ADDSUB:<VWIDE> (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
4513 (match_operand:VQW 1 "register_operand" "w")
4514 (match_operand:VQW 3 "vect_par_cnst_lo_half" "")))
4515 (ANY_EXTEND:<VWIDE> (vec_select:<VHALF>
4516 (match_operand:VQW 2 "register_operand" "w")
4517 (match_dup 3)))))]
4518 "TARGET_SIMD"
4519 "<ANY_EXTEND:su><ADDSUB:optab>l\t%0.<Vwtype>, %1.<Vhalftype>, %2.<Vhalftype>"
4520 [(set_attr "type" "neon_<ADDSUB:optab>_long")]
4521 )
4522
4523 (define_expand "vec_widen_<su>add_lo_<mode>"
4524 [(match_operand:<VWIDE> 0 "register_operand")
4525 (ANY_EXTEND:<VWIDE> (match_operand:VQW 1 "register_operand"))
4526 (ANY_EXTEND:<VWIDE> (match_operand:VQW 2 "register_operand"))]
4527 "TARGET_SIMD"
4528 {
4529 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, false);
4530 emit_insn (gen_aarch64_<su>addl<mode>_lo_internal (operands[0], operands[1],
4531 operands[2], p));
4532 DONE;
4533 })
4534
4535 (define_expand "vec_widen_<su>add_hi_<mode>"
4536 [(match_operand:<VWIDE> 0 "register_operand")
4537 (ANY_EXTEND:<VWIDE> (match_operand:VQW 1 "register_operand"))
4538 (ANY_EXTEND:<VWIDE> (match_operand:VQW 2 "register_operand"))]
4539 "TARGET_SIMD"
4540 {
4541 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
4542 emit_insn (gen_aarch64_<su>addl<mode>_hi_internal (operands[0], operands[1],
4543 operands[2], p));
4544 DONE;
4545 })
4546
4547 (define_expand "vec_widen_<su>sub_lo_<mode>"
4548 [(match_operand:<VWIDE> 0 "register_operand")
4549 (ANY_EXTEND:<VWIDE> (match_operand:VQW 1 "register_operand"))
4550 (ANY_EXTEND:<VWIDE> (match_operand:VQW 2 "register_operand"))]
4551 "TARGET_SIMD"
4552 {
4553 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, false);
4554 emit_insn (gen_aarch64_<su>subl<mode>_lo_internal (operands[0], operands[1],
4555 operands[2], p));
4556 DONE;
4557 })
4558
4559 (define_expand "vec_widen_<su>sub_hi_<mode>"
4560 [(match_operand:<VWIDE> 0 "register_operand")
4561 (ANY_EXTEND:<VWIDE> (match_operand:VQW 1 "register_operand"))
4562 (ANY_EXTEND:<VWIDE> (match_operand:VQW 2 "register_operand"))]
4563 "TARGET_SIMD"
4564 {
4565 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
4566 emit_insn (gen_aarch64_<su>subl<mode>_hi_internal (operands[0], operands[1],
4567 operands[2], p));
4568 DONE;
4569 })
4570
4571 (define_expand "aarch64_saddl2<mode>"
4572 [(match_operand:<VWIDE> 0 "register_operand")
4573 (match_operand:VQW 1 "register_operand")
4574 (match_operand:VQW 2 "register_operand")]
4575 "TARGET_SIMD"
4576 {
4577 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
4578 emit_insn (gen_aarch64_saddl<mode>_hi_internal (operands[0], operands[1],
4579 operands[2], p));
4580 DONE;
4581 })
4582
4583 (define_expand "aarch64_uaddl2<mode>"
4584 [(match_operand:<VWIDE> 0 "register_operand")
4585 (match_operand:VQW 1 "register_operand")
4586 (match_operand:VQW 2 "register_operand")]
4587 "TARGET_SIMD"
4588 {
4589 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
4590 emit_insn (gen_aarch64_uaddl<mode>_hi_internal (operands[0], operands[1],
4591 operands[2], p));
4592 DONE;
4593 })
4594
4595 (define_expand "aarch64_ssubl2<mode>"
4596 [(match_operand:<VWIDE> 0 "register_operand")
4597 (match_operand:VQW 1 "register_operand")
4598 (match_operand:VQW 2 "register_operand")]
4599 "TARGET_SIMD"
4600 {
4601 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
4602 emit_insn (gen_aarch64_ssubl<mode>_hi_internal (operands[0], operands[1],
4603 operands[2], p));
4604 DONE;
4605 })
4606
4607 (define_expand "aarch64_usubl2<mode>"
4608 [(match_operand:<VWIDE> 0 "register_operand")
4609 (match_operand:VQW 1 "register_operand")
4610 (match_operand:VQW 2 "register_operand")]
4611 "TARGET_SIMD"
4612 {
4613 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
4614 emit_insn (gen_aarch64_usubl<mode>_hi_internal (operands[0], operands[1],
4615 operands[2], p));
4616 DONE;
4617 })
4618
4619 (define_insn "aarch64_<ANY_EXTEND:su><ADDSUB:optab>l<mode>"
4620 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
4621 (ADDSUB:<VWIDE> (ANY_EXTEND:<VWIDE>
4622 (match_operand:VD_BHSI 1 "register_operand" "w"))
4623 (ANY_EXTEND:<VWIDE>
4624 (match_operand:VD_BHSI 2 "register_operand" "w"))))]
4625 "TARGET_SIMD"
4626 "<ANY_EXTEND:su><ADDSUB:optab>l\t%0.<Vwtype>, %1.<Vtype>, %2.<Vtype>"
4627 [(set_attr "type" "neon_<ADDSUB:optab>_long")]
4628 )
4629
4630 ;; <su><addsub>w<q>.
4631
4632 (define_expand "widen_ssum<mode>3"
4633 [(set (match_operand:<VDBLW> 0 "register_operand")
4634 (plus:<VDBLW> (sign_extend:<VDBLW>
4635 (match_operand:VQW 1 "register_operand"))
4636 (match_operand:<VDBLW> 2 "register_operand")))]
4637 "TARGET_SIMD"
4638 {
4639 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, false);
4640 rtx temp = gen_reg_rtx (GET_MODE (operands[0]));
4641
4642 emit_insn (gen_aarch64_saddw<mode>_internal (temp, operands[2],
4643 operands[1], p));
4644 emit_insn (gen_aarch64_saddw2<mode> (operands[0], temp, operands[1]));
4645 DONE;
4646 }
4647 )
4648
4649 (define_expand "widen_ssum<mode>3"
4650 [(set (match_operand:<VWIDE> 0 "register_operand")
4651 (plus:<VWIDE> (sign_extend:<VWIDE>
4652 (match_operand:VD_BHSI 1 "register_operand"))
4653 (match_operand:<VWIDE> 2 "register_operand")))]
4654 "TARGET_SIMD"
4655 {
4656 emit_insn (gen_aarch64_saddw<mode> (operands[0], operands[2], operands[1]));
4657 DONE;
4658 })
4659
4660 (define_expand "widen_usum<mode>3"
4661 [(set (match_operand:<VDBLW> 0 "register_operand")
4662 (plus:<VDBLW> (zero_extend:<VDBLW>
4663 (match_operand:VQW 1 "register_operand"))
4664 (match_operand:<VDBLW> 2 "register_operand")))]
4665 "TARGET_SIMD"
4666 {
4667 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, false);
4668 rtx temp = gen_reg_rtx (GET_MODE (operands[0]));
4669
4670 emit_insn (gen_aarch64_uaddw<mode>_internal (temp, operands[2],
4671 operands[1], p));
4672 emit_insn (gen_aarch64_uaddw2<mode> (operands[0], temp, operands[1]));
4673 DONE;
4674 }
4675 )
4676
4677 (define_expand "widen_usum<mode>3"
4678 [(set (match_operand:<VWIDE> 0 "register_operand")
4679 (plus:<VWIDE> (zero_extend:<VWIDE>
4680 (match_operand:VD_BHSI 1 "register_operand"))
4681 (match_operand:<VWIDE> 2 "register_operand")))]
4682 "TARGET_SIMD"
4683 {
4684 emit_insn (gen_aarch64_uaddw<mode> (operands[0], operands[2], operands[1]));
4685 DONE;
4686 })
4687
4688 (define_insn "aarch64_<ANY_EXTEND:su>subw<mode>"
4689 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
4690 (minus:<VWIDE> (match_operand:<VWIDE> 1 "register_operand" "w")
4691 (ANY_EXTEND:<VWIDE>
4692 (match_operand:VD_BHSI 2 "register_operand" "w"))))]
4693 "TARGET_SIMD"
4694 "<ANY_EXTEND:su>subw\\t%0.<Vwtype>, %1.<Vwtype>, %2.<Vtype>"
4695 [(set_attr "type" "neon_sub_widen")]
4696 )
4697
4698 (define_insn "aarch64_<ANY_EXTEND:su>subw<mode>_internal"
4699 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
4700 (minus:<VWIDE> (match_operand:<VWIDE> 1 "register_operand" "w")
4701 (ANY_EXTEND:<VWIDE>
4702 (vec_select:<VHALF>
4703 (match_operand:VQW 2 "register_operand" "w")
4704 (match_operand:VQW 3 "vect_par_cnst_lo_half" "")))))]
4705 "TARGET_SIMD"
4706 "<ANY_EXTEND:su>subw\\t%0.<Vwtype>, %1.<Vwtype>, %2.<Vhalftype>"
4707 [(set_attr "type" "neon_sub_widen")]
4708 )
4709
4710 (define_insn "aarch64_<ANY_EXTEND:su>subw2<mode>_internal"
4711 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
4712 (minus:<VWIDE> (match_operand:<VWIDE> 1 "register_operand" "w")
4713 (ANY_EXTEND:<VWIDE>
4714 (vec_select:<VHALF>
4715 (match_operand:VQW 2 "register_operand" "w")
4716 (match_operand:VQW 3 "vect_par_cnst_hi_half" "")))))]
4717 "TARGET_SIMD"
4718 "<ANY_EXTEND:su>subw2\\t%0.<Vwtype>, %1.<Vwtype>, %2.<Vtype>"
4719 [(set_attr "type" "neon_sub_widen")]
4720 )
4721
4722 (define_insn "aarch64_<ANY_EXTEND:su>addw<mode>"
4723 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
4724 (plus:<VWIDE>
4725 (ANY_EXTEND:<VWIDE> (match_operand:VD_BHSI 2 "register_operand" "w"))
4726 (match_operand:<VWIDE> 1 "register_operand" "w")))]
4727 "TARGET_SIMD"
4728 "<ANY_EXTEND:su>addw\\t%0.<Vwtype>, %1.<Vwtype>, %2.<Vtype>"
4729 [(set_attr "type" "neon_add_widen")]
4730 )
4731
4732 (define_insn "aarch64_<ANY_EXTEND:su>addw<mode>_internal"
4733 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
4734 (plus:<VWIDE>
4735 (ANY_EXTEND:<VWIDE>
4736 (vec_select:<VHALF>
4737 (match_operand:VQW 2 "register_operand" "w")
4738 (match_operand:VQW 3 "vect_par_cnst_lo_half" "")))
4739 (match_operand:<VWIDE> 1 "register_operand" "w")))]
4740 "TARGET_SIMD"
4741 "<ANY_EXTEND:su>addw\\t%0.<Vwtype>, %1.<Vwtype>, %2.<Vhalftype>"
4742 [(set_attr "type" "neon_add_widen")]
4743 )
4744
4745 (define_insn "aarch64_<ANY_EXTEND:su>addw2<mode>_internal"
4746 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
4747 (plus:<VWIDE>
4748 (ANY_EXTEND:<VWIDE>
4749 (vec_select:<VHALF>
4750 (match_operand:VQW 2 "register_operand" "w")
4751 (match_operand:VQW 3 "vect_par_cnst_hi_half" "")))
4752 (match_operand:<VWIDE> 1 "register_operand" "w")))]
4753 "TARGET_SIMD"
4754 "<ANY_EXTEND:su>addw2\\t%0.<Vwtype>, %1.<Vwtype>, %2.<Vtype>"
4755 [(set_attr "type" "neon_add_widen")]
4756 )
4757
4758 (define_expand "aarch64_<ANY_EXTEND:su><ADDSUB:optab>w2<mode>"
4759 [(set (match_operand:<VWIDE> 0 "register_operand")
4760 (ADDSUB:<VWIDE>
4761 (ANY_EXTEND:<VWIDE>
4762 (vec_select:<VHALF>
4763 (match_operand:VQW 2 "register_operand")
4764 (match_dup 3)))
4765 (match_operand:<VWIDE> 1 "register_operand")))]
4766 "TARGET_SIMD"
4767 {
4768 /* We still do an emit_insn rather than relying on the pattern above
4769 because for the MINUS case the operands would need to be swapped
4770 around. */
4771 operands[3]
4772 = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
4773 emit_insn (gen_aarch64_<ANY_EXTEND:su><ADDSUB:optab>w2<mode>_internal(
4774 operands[0],
4775 operands[1],
4776 operands[2],
4777 operands[3]));
4778 DONE;
4779 })
4780
4781 ;; <su><r>h<addsub>.
4782
4783 (define_expand "<su_optab>avg<mode>3_floor"
4784 [(set (match_operand:VDQ_BHSI 0 "register_operand")
4785 (truncate:VDQ_BHSI
4786 (ashiftrt:<V2XWIDE>
4787 (plus:<V2XWIDE>
4788 (ANY_EXTEND:<V2XWIDE>
4789 (match_operand:VDQ_BHSI 1 "register_operand"))
4790 (ANY_EXTEND:<V2XWIDE>
4791 (match_operand:VDQ_BHSI 2 "register_operand")))
4792 (match_dup 3))))]
4793 "TARGET_SIMD"
4794 {
4795 operands[3] = CONST1_RTX (<V2XWIDE>mode);
4796 }
4797 )
4798
4799 (define_expand "<su_optab>avg<mode>3_ceil"
4800 [(set (match_operand:VDQ_BHSI 0 "register_operand")
4801 (truncate:VDQ_BHSI
4802 (ashiftrt:<V2XWIDE>
4803 (plus:<V2XWIDE>
4804 (plus:<V2XWIDE>
4805 (ANY_EXTEND:<V2XWIDE>
4806 (match_operand:VDQ_BHSI 1 "register_operand"))
4807 (ANY_EXTEND:<V2XWIDE>
4808 (match_operand:VDQ_BHSI 2 "register_operand")))
4809 (match_dup 3))
4810 (match_dup 3))))]
4811 "TARGET_SIMD"
4812 {
4813 operands[3] = CONST1_RTX (<V2XWIDE>mode);
4814 }
4815 )
4816
4817 (define_expand "aarch64_<su>hsub<mode>"
4818 [(set (match_operand:VDQ_BHSI 0 "register_operand")
4819 (truncate:VDQ_BHSI
4820 (ashiftrt:<V2XWIDE>
4821 (minus:<V2XWIDE>
4822 (ANY_EXTEND:<V2XWIDE>
4823 (match_operand:VDQ_BHSI 1 "register_operand"))
4824 (ANY_EXTEND:<V2XWIDE>
4825 (match_operand:VDQ_BHSI 2 "register_operand")))
4826 (match_dup 3))))]
4827 "TARGET_SIMD"
4828 {
4829 operands[3] = CONST1_RTX (<V2XWIDE>mode);
4830 }
4831 )
4832
4833 (define_insn "*aarch64_<su>h<ADDSUB:optab><mode><vczle><vczbe>_insn"
4834 [(set (match_operand:VDQ_BHSI 0 "register_operand" "=w")
4835 (truncate:VDQ_BHSI
4836 (ashiftrt:<V2XWIDE>
4837 (ADDSUB:<V2XWIDE>
4838 (ANY_EXTEND:<V2XWIDE>
4839 (match_operand:VDQ_BHSI 1 "register_operand" "w"))
4840 (ANY_EXTEND:<V2XWIDE>
4841 (match_operand:VDQ_BHSI 2 "register_operand" "w")))
4842 (match_operand:<V2XWIDE> 3 "aarch64_simd_imm_one"))))]
4843 "TARGET_SIMD"
4844 "<su>h<ADDSUB:optab>\\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
4845 [(set_attr "type" "neon_<ADDSUB:optab>_halve<q>")]
4846 )
4847
4848 (define_insn "*aarch64_<su>rhadd<mode><vczle><vczbe>_insn"
4849 [(set (match_operand:VDQ_BHSI 0 "register_operand" "=w")
4850 (truncate:VDQ_BHSI
4851 (ashiftrt:<V2XWIDE>
4852 (plus:<V2XWIDE>
4853 (plus:<V2XWIDE>
4854 (ANY_EXTEND:<V2XWIDE>
4855 (match_operand:VDQ_BHSI 1 "register_operand" "w"))
4856 (ANY_EXTEND:<V2XWIDE>
4857 (match_operand:VDQ_BHSI 2 "register_operand" "w")))
4858 (match_operand:<V2XWIDE> 3 "aarch64_simd_imm_one"))
4859 (match_dup 3))))]
4860 "TARGET_SIMD"
4861 "<su>rhadd\\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
4862 [(set_attr "type" "neon_add_halve<q>")]
4863 )
4864
4865 ;; <r><addsub>hn<q>.
4866
4867 (define_insn "aarch64_<optab>hn<mode>_insn<vczle><vczbe>"
4868 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
4869 (truncate:<VNARROWQ>
4870 (ashiftrt:VQN
4871 (ADDSUB:VQN (match_operand:VQN 1 "register_operand" "w")
4872 (match_operand:VQN 2 "register_operand" "w"))
4873 (match_operand:VQN 3 "aarch64_simd_shift_imm_vec_exact_top"))))]
4874 "TARGET_SIMD"
4875 "<optab>hn\\t%0.<Vntype>, %1.<Vtype>, %2.<Vtype>"
4876 [(set_attr "type" "neon_<optab>_halve_narrow_q")]
4877 )
4878
4879 (define_insn "aarch64_r<optab>hn<mode>_insn<vczle><vczbe>"
4880 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
4881 (truncate:<VNARROWQ>
4882 (ashiftrt:VQN
4883 (plus:VQN
4884 (ADDSUB:VQN (match_operand:VQN 1 "register_operand" "w")
4885 (match_operand:VQN 2 "register_operand" "w"))
4886 (match_operand:VQN 3 "aarch64_simd_raddsubhn_imm_vec"))
4887 (match_operand:VQN 4 "aarch64_simd_shift_imm_vec_exact_top"))))]
4888 "TARGET_SIMD"
4889 "r<optab>hn\\t%0.<Vntype>, %1.<Vtype>, %2.<Vtype>"
4890 [(set_attr "type" "neon_<optab>_halve_narrow_q")]
4891 )
4892
4893 (define_expand "aarch64_<optab>hn<mode>"
4894 [(set (match_operand:<VNARROWQ> 0 "register_operand")
4895 (ADDSUB:VQN (match_operand:VQN 1 "register_operand")
4896 (match_operand:VQN 2 "register_operand")))]
4897 "TARGET_SIMD"
4898 {
4899 rtx shft
4900 = aarch64_simd_gen_const_vector_dup (<MODE>mode,
4901 GET_MODE_UNIT_BITSIZE (<MODE>mode) / 2);
4902 emit_insn (gen_aarch64_<optab>hn<mode>_insn (operands[0], operands[1],
4903 operands[2], shft));
4904 DONE;
4905 }
4906 )
4907
4908 (define_expand "aarch64_r<optab>hn<mode>"
4909 [(set (match_operand:<VNARROWQ> 0 "register_operand")
4910 (ADDSUB:VQN (match_operand:VQN 1 "register_operand")
4911 (match_operand:VQN 2 "register_operand")))]
4912 "TARGET_SIMD"
4913 {
4914 rtx shft
4915 = aarch64_simd_gen_const_vector_dup (<MODE>mode,
4916 GET_MODE_UNIT_BITSIZE (<MODE>mode) / 2);
4917 rtx rnd
4918 = aarch64_simd_gen_const_vector_dup (<MODE>mode,
4919 HOST_WIDE_INT_1U << (GET_MODE_UNIT_BITSIZE (<MODE>mode) / 2 - 1));
4920 emit_insn (gen_aarch64_r<optab>hn<mode>_insn (operands[0], operands[1],
4921 operands[2], rnd, shft));
4922 DONE;
4923 }
4924 )
4925
4926 (define_insn "aarch64_<optab>hn2<mode>_insn_le"
4927 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
4928 (vec_concat:<VNARROWQ2>
4929 (match_operand:<VNARROWQ> 1 "register_operand" "0")
4930 (truncate:<VNARROWQ>
4931 (ashiftrt:VQN
4932 (ADDSUB:VQN (match_operand:VQN 2 "register_operand" "w")
4933 (match_operand:VQN 3 "register_operand" "w"))
4934 (match_operand:VQN 4 "aarch64_simd_shift_imm_vec_exact_top")))))]
4935 "TARGET_SIMD && !BYTES_BIG_ENDIAN"
4936 "<optab>hn2\\t%0.<V2ntype>, %2.<Vtype>, %3.<Vtype>"
4937 [(set_attr "type" "neon_<optab>_halve_narrow_q")]
4938 )
4939
4940 (define_insn "aarch64_r<optab>hn2<mode>_insn_le"
4941 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
4942 (vec_concat:<VNARROWQ2>
4943 (match_operand:<VNARROWQ> 1 "register_operand" "0")
4944 (truncate:<VNARROWQ>
4945 (ashiftrt:VQN
4946 (plus:VQN
4947 (ADDSUB:VQN (match_operand:VQN 2 "register_operand" "w")
4948 (match_operand:VQN 3 "register_operand" "w"))
4949 (match_operand:VQN 4 "aarch64_simd_raddsubhn_imm_vec"))
4950 (match_operand:VQN 5 "aarch64_simd_shift_imm_vec_exact_top")))))]
4951 "TARGET_SIMD && !BYTES_BIG_ENDIAN"
4952 "r<optab>hn2\\t%0.<V2ntype>, %2.<Vtype>, %3.<Vtype>"
4953 [(set_attr "type" "neon_<optab>_halve_narrow_q")]
4954 )
4955
4956 (define_insn "aarch64_<optab>hn2<mode>_insn_be"
4957 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
4958 (vec_concat:<VNARROWQ2>
4959 (truncate:<VNARROWQ>
4960 (ashiftrt:VQN
4961 (ADDSUB:VQN (match_operand:VQN 2 "register_operand" "w")
4962 (match_operand:VQN 3 "register_operand" "w"))
4963 (match_operand:VQN 4 "aarch64_simd_shift_imm_vec_exact_top")))
4964 (match_operand:<VNARROWQ> 1 "register_operand" "0")))]
4965 "TARGET_SIMD && BYTES_BIG_ENDIAN"
4966 "<optab>hn2\\t%0.<V2ntype>, %2.<Vtype>, %3.<Vtype>"
4967 [(set_attr "type" "neon_<optab>_halve_narrow_q")]
4968 )
4969
4970 (define_insn "aarch64_r<optab>hn2<mode>_insn_be"
4971 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
4972 (vec_concat:<VNARROWQ2>
4973 (truncate:<VNARROWQ>
4974 (ashiftrt:VQN
4975 (plus:VQN
4976 (ADDSUB:VQN (match_operand:VQN 2 "register_operand" "w")
4977 (match_operand:VQN 3 "register_operand" "w"))
4978 (match_operand:VQN 4 "aarch64_simd_raddsubhn_imm_vec"))
4979 (match_operand:VQN 5 "aarch64_simd_shift_imm_vec_exact_top")))
4980 (match_operand:<VNARROWQ> 1 "register_operand" "0")))]
4981 "TARGET_SIMD && BYTES_BIG_ENDIAN"
4982 "r<optab>hn2\\t%0.<V2ntype>, %2.<Vtype>, %3.<Vtype>"
4983 [(set_attr "type" "neon_<optab>_halve_narrow_q")]
4984 )
4985
4986 (define_expand "aarch64_<optab>hn2<mode>"
4987 [(match_operand:<VNARROWQ2> 0 "register_operand")
4988 (match_operand:<VNARROWQ> 1 "register_operand")
4989 (ADDSUB:VQN (match_operand:VQN 2 "register_operand")
4990 (match_operand:VQN 3 "register_operand"))]
4991 "TARGET_SIMD"
4992 {
4993 rtx shft
4994 = aarch64_simd_gen_const_vector_dup (<MODE>mode,
4995 GET_MODE_UNIT_BITSIZE (<MODE>mode) / 2);
4996 if (BYTES_BIG_ENDIAN)
4997 emit_insn (gen_aarch64_<optab>hn2<mode>_insn_be (operands[0],
4998 operands[1], operands[2], operands[3], shft));
4999 else
5000 emit_insn (gen_aarch64_<optab>hn2<mode>_insn_le (operands[0],
5001 operands[1], operands[2], operands[3], shft));
5002 DONE;
5003 }
5004 )
5005
5006 (define_expand "aarch64_r<optab>hn2<mode>"
5007 [(match_operand:<VNARROWQ2> 0 "register_operand")
5008 (match_operand:<VNARROWQ> 1 "register_operand")
5009 (ADDSUB:VQN (match_operand:VQN 2 "register_operand")
5010 (match_operand:VQN 3 "register_operand"))]
5011 "TARGET_SIMD"
5012 {
5013 rtx shft
5014 = aarch64_simd_gen_const_vector_dup (<MODE>mode,
5015 GET_MODE_UNIT_BITSIZE (<MODE>mode) / 2);
5016 rtx rnd
5017 = aarch64_simd_gen_const_vector_dup (<MODE>mode,
5018 HOST_WIDE_INT_1U << (GET_MODE_UNIT_BITSIZE (<MODE>mode) / 2 - 1));
5019 if (BYTES_BIG_ENDIAN)
5020 emit_insn (gen_aarch64_r<optab>hn2<mode>_insn_be (operands[0],
5021 operands[1], operands[2], operands[3], rnd, shft));
5022 else
5023 emit_insn (gen_aarch64_r<optab>hn2<mode>_insn_le (operands[0],
5024 operands[1], operands[2], operands[3], rnd, shft));
5025 DONE;
5026 }
5027 )
5028
5029 ;; Optimize ((a + b) >> n) + c where n is half the bitsize of the vector
5030 (define_insn_and_split "*bitmask_shift_plus<mode>"
5031 [(set (match_operand:VQN 0 "register_operand" "=&w")
5032 (plus:VQN
5033 (lshiftrt:VQN
5034 (plus:VQN (match_operand:VQN 1 "register_operand" "w")
5035 (match_operand:VQN 2 "register_operand" "w"))
5036 (match_operand:VQN 3 "aarch64_simd_shift_imm_vec_exact_top" ""))
5037 (match_operand:VQN 4 "register_operand" "w")))]
5038 "TARGET_SIMD"
5039 "#"
5040 "&& true"
5041 [(const_int 0)]
5042 {
5043 rtx tmp;
5044 if (can_create_pseudo_p ())
5045 tmp = gen_reg_rtx (<VNARROWQ>mode);
5046 else
5047 tmp = gen_rtx_REG (<VNARROWQ>mode, REGNO (operands[0]));
5048 emit_insn (gen_aarch64_addhn<mode> (tmp, operands[1], operands[2]));
5049 emit_insn (gen_aarch64_uaddw<Vnarrowq> (operands[0], operands[4], tmp));
5050 DONE;
5051 })
5052
5053 ;; pmul.
5054
5055 (define_insn "aarch64_pmul<mode>"
5056 [(set (match_operand:VB 0 "register_operand" "=w")
5057 (unspec:VB [(match_operand:VB 1 "register_operand" "w")
5058 (match_operand:VB 2 "register_operand" "w")]
5059 UNSPEC_PMUL))]
5060 "TARGET_SIMD"
5061 "pmul\\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
5062 [(set_attr "type" "neon_mul_<Vetype><q>")]
5063 )
5064
5065 (define_insn "aarch64_pmullv8qi"
5066 [(set (match_operand:V8HI 0 "register_operand" "=w")
5067 (unspec:V8HI [(match_operand:V8QI 1 "register_operand" "w")
5068 (match_operand:V8QI 2 "register_operand" "w")]
5069 UNSPEC_PMULL))]
5070 "TARGET_SIMD"
5071 "pmull\\t%0.8h, %1.8b, %2.8b"
5072 [(set_attr "type" "neon_mul_b_long")]
5073 )
5074
5075 (define_insn "aarch64_pmull_hiv16qi_insn"
5076 [(set (match_operand:V8HI 0 "register_operand" "=w")
5077 (unspec:V8HI
5078 [(vec_select:V8QI
5079 (match_operand:V16QI 1 "register_operand" "w")
5080 (match_operand:V16QI 3 "vect_par_cnst_hi_half" ""))
5081 (vec_select:V8QI
5082 (match_operand:V16QI 2 "register_operand" "w")
5083 (match_dup 3))]
5084 UNSPEC_PMULL))]
5085 "TARGET_SIMD"
5086 "pmull2\\t%0.8h, %1.16b, %2.16b"
5087 [(set_attr "type" "neon_mul_b_long")]
5088 )
5089
5090 (define_expand "aarch64_pmull_hiv16qi"
5091 [(match_operand:V8HI 0 "register_operand")
5092 (match_operand:V16QI 1 "register_operand")
5093 (match_operand:V16QI 2 "register_operand")]
5094 "TARGET_SIMD"
5095 {
5096 rtx p = aarch64_simd_vect_par_cnst_half (V16QImode, 16, true);
5097 emit_insn (gen_aarch64_pmull_hiv16qi_insn (operands[0], operands[1],
5098 operands[2], p));
5099 DONE;
5100 }
5101 )
5102
5103 ;; fmulx.
5104
5105 (define_insn "aarch64_fmulx<mode>"
5106 [(set (match_operand:VHSDF_HSDF 0 "register_operand" "=w")
5107 (unspec:VHSDF_HSDF
5108 [(match_operand:VHSDF_HSDF 1 "register_operand" "w")
5109 (match_operand:VHSDF_HSDF 2 "register_operand" "w")]
5110 UNSPEC_FMULX))]
5111 "TARGET_SIMD"
5112 "fmulx\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>2<Vmtype>"
5113 [(set_attr "type" "neon_fp_mul_<stype>")]
5114 )
5115
5116 ;; vmulxq_lane_f32, and vmulx_laneq_f32
5117
5118 (define_insn "*aarch64_mulx_elt_<vswap_width_name><mode>"
5119 [(set (match_operand:VDQSF 0 "register_operand" "=w")
5120 (unspec:VDQSF
5121 [(match_operand:VDQSF 1 "register_operand" "w")
5122 (vec_duplicate:VDQSF
5123 (vec_select:<VEL>
5124 (match_operand:<VSWAP_WIDTH> 2 "register_operand" "w")
5125 (parallel [(match_operand:SI 3 "immediate_operand" "i")])))]
5126 UNSPEC_FMULX))]
5127 "TARGET_SIMD"
5128 {
5129 operands[3] = aarch64_endian_lane_rtx (<VSWAP_WIDTH>mode, INTVAL (operands[3]));
5130 return "fmulx\t%<v>0<Vmtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]";
5131 }
5132 [(set_attr "type" "neon_fp_mul_<Vetype>_scalar<q>")]
5133 )
5134
5135 ;; vmulxq_laneq_f32, vmulxq_laneq_f64, vmulx_lane_f32
5136
5137 (define_insn "*aarch64_mulx_elt<mode>"
5138 [(set (match_operand:VDQF 0 "register_operand" "=w")
5139 (unspec:VDQF
5140 [(match_operand:VDQF 1 "register_operand" "w")
5141 (vec_duplicate:VDQF
5142 (vec_select:<VEL>
5143 (match_operand:VDQF 2 "register_operand" "w")
5144 (parallel [(match_operand:SI 3 "immediate_operand" "i")])))]
5145 UNSPEC_FMULX))]
5146 "TARGET_SIMD"
5147 {
5148 operands[3] = aarch64_endian_lane_rtx (<MODE>mode, INTVAL (operands[3]));
5149 return "fmulx\t%<v>0<Vmtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]";
5150 }
5151 [(set_attr "type" "neon_fp_mul_<Vetype><q>")]
5152 )
5153
5154 ;; vmulxq_lane
5155
5156 (define_insn "*aarch64_mulx_elt_from_dup<mode>"
5157 [(set (match_operand:VHSDF 0 "register_operand" "=w")
5158 (unspec:VHSDF
5159 [(match_operand:VHSDF 1 "register_operand" "w")
5160 (vec_duplicate:VHSDF
5161 (match_operand:<VEL> 2 "register_operand" "<h_con>"))]
5162 UNSPEC_FMULX))]
5163 "TARGET_SIMD"
5164 "fmulx\t%0.<Vtype>, %1.<Vtype>, %2.<Vetype>[0]";
5165 [(set_attr "type" "neon<fp>_mul_<stype>_scalar<q>")]
5166 )
5167
5168 ;; vmulxs_lane_f32, vmulxs_laneq_f32
5169 ;; vmulxd_lane_f64 == vmulx_lane_f64
5170 ;; vmulxd_laneq_f64 == vmulx_laneq_f64
5171
5172 (define_insn "*aarch64_vgetfmulx<mode>"
5173 [(set (match_operand:<VEL> 0 "register_operand" "=w")
5174 (unspec:<VEL>
5175 [(match_operand:<VEL> 1 "register_operand" "w")
5176 (vec_select:<VEL>
5177 (match_operand:VDQF 2 "register_operand" "w")
5178 (parallel [(match_operand:SI 3 "immediate_operand" "i")]))]
5179 UNSPEC_FMULX))]
5180 "TARGET_SIMD"
5181 {
5182 operands[3] = aarch64_endian_lane_rtx (<MODE>mode, INTVAL (operands[3]));
5183 return "fmulx\t%<Vetype>0, %<Vetype>1, %2.<Vetype>[%3]";
5184 }
5185 [(set_attr "type" "fmul<Vetype>")]
5186 )
5187 ;; <su>q<addsub>
5188
5189 (define_insn "<su_optab>s<addsub><mode>3<vczle><vczbe>"
5190 [(set (match_operand:VSDQ_I_QI_HI 0 "register_operand" "=w")
5191 (BINQOPS:VSDQ_I_QI_HI
5192 (match_operand:VSDQ_I_QI_HI 1 "register_operand" "w")
5193 (match_operand:VSDQ_I_QI_HI 2 "register_operand" "w")))]
5194 "TARGET_SIMD"
5195 "<su_optab>q<addsub>\\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>2<Vmtype>"
5196 [(set_attr "type" "neon_q<addsub><q>")]
5197 )
5198
5199 (define_expand "<su_optab>s<addsub><mode>3"
5200 [(parallel
5201 [(set (match_operand:GPI 0 "register_operand")
5202 (SBINQOPS:GPI (match_operand:GPI 1 "register_operand")
5203 (match_operand:GPI 2 "aarch64_plus_operand")))
5204 (clobber (scratch:GPI))
5205 (clobber (reg:CC CC_REGNUM))])]
5206 )
5207
5208 ;; Introducing a temporary GP reg allows signed saturating arithmetic with GPR
5209 ;; operands to be calculated without the use of costly transfers to and from FP
5210 ;; registers. For example, saturating addition usually uses three FMOVs:
5211 ;;
5212 ;; fmov d0, x0
5213 ;; fmov d1, x1
5214 ;; sqadd d0, d0, d1
5215 ;; fmov x0, d0
5216 ;;
5217 ;; Using a temporary register results in three cheaper instructions being used
5218 ;; in place of the three FMOVs, which calculate the saturating limit accounting
5219 ;; for the signedness of operand2:
5220 ;;
5221 ;; asr x2, x1, 63
5222 ;; adds x0, x0, x1
5223 ;; eor x2, x2, 0x8000000000000000
5224 ;; csinv x0, x0, x2, vc
5225 ;;
5226 ;; If operand2 is a constant value, the temporary register can be used to store
5227 ;; the saturating limit without the need for asr, xor to calculate said limit.
5228
5229 (define_insn_and_split "aarch64_<su_optab>s<addsub><mode>3<vczle><vczbe>"
5230 [(set (match_operand:GPI 0 "register_operand")
5231 (SBINQOPS:GPI (match_operand:GPI 1 "register_operand")
5232 (match_operand:GPI 2 "aarch64_plus_operand")))
5233 (clobber (match_scratch:GPI 3))
5234 (clobber (reg:CC CC_REGNUM))]
5235 ""
5236 {@ [ cons: =0, 1 , 2 , =3 ; attrs: type , arch , length ]
5237 [ w , w , w , X ; neon_q<addsub><q> , simd , 4 ] <su_optab>q<addsub>\\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>2<Vmtype>
5238 [ r , r , JIr , &r ; * , * , 8 ] #
5239 }
5240 "&& reload_completed && GP_REGNUM_P (REGNO (operands[0]))"
5241 [(set (match_dup 0)
5242 (if_then_else:GPI
5243 (match_dup 4)
5244 (match_dup 5)
5245 (match_dup 6)))]
5246 {
5247 if (REG_P (operands[2]))
5248 {
5249 rtx shift_constant = gen_int_mode (GET_MODE_BITSIZE (<MODE>mode) - 1,
5250 <MODE>mode);
5251 auto limit = HOST_WIDE_INT_1U << (GET_MODE_BITSIZE (<MODE>mode) - 1);
5252 rtx limit_constant = gen_int_mode (limit, <MODE>mode);
5253 emit_insn (gen_ashr<mode>3 (operands[3], operands[2], shift_constant));
5254 emit_insn (gen_xor<mode>3 (operands[3], operands[3], limit_constant));
5255
5256 switch (<CODE>)
5257 {
5258 case SS_MINUS:
5259 emit_insn (gen_sub<mode>3_compare1 (operands[0], operands[1],
5260 operands[2]));
5261 break;
5262 case SS_PLUS:
5263 emit_insn (gen_add<mode>3_compare0 (operands[0], operands[1],
5264 operands[2]));
5265 break;
5266 default:
5267 gcc_unreachable ();
5268 }
5269
5270 rtx ccin = gen_rtx_REG (E_CC_Vmode, CC_REGNUM);
5271 switch (<CODE>)
5272 {
5273 case SS_PLUS:
5274 operands[4] = gen_rtx_NE (<MODE>mode, ccin, const0_rtx);
5275 operands[5] = gen_rtx_NOT (<MODE>mode, operands[3]);
5276 operands[6] = operands[0];
5277 break;
5278 case SS_MINUS:
5279 operands[4] = gen_rtx_EQ (<MODE>mode, ccin, const0_rtx);
5280 operands[5] = operands[0];
5281 operands[6] = operands[3];
5282 break;
5283 default:
5284 gcc_unreachable ();
5285 }
5286 }
5287 else
5288 {
5289 auto imm = INTVAL (operands[2]);
5290 rtx neg_imm = gen_int_mode (-imm, <MODE>mode);
5291 wide_int limit;
5292
5293 switch (<CODE>)
5294 {
5295 case SS_MINUS:
5296 emit_insn (gen_sub<mode>3_compare1_imm (operands[0], operands[1],
5297 operands[2], neg_imm));
5298 limit = imm >= 0 ? wi::min_value (<MODE>mode, SIGNED)
5299 : wi::max_value (<MODE>mode, SIGNED);
5300 break;
5301 case SS_PLUS:
5302 emit_insn (gen_sub<mode>3_compare1_imm (operands[0], operands[1],
5303 neg_imm, operands[2]));
5304 limit = imm >= 0 ? wi::max_value (<MODE>mode, SIGNED)
5305 : wi::min_value (<MODE>mode, SIGNED);
5306 break;
5307 default:
5308 gcc_unreachable ();
5309 }
5310
5311 rtx sat_limit = immed_wide_int_const (limit, <MODE>mode);
5312 emit_insn (gen_rtx_SET (operands[3], sat_limit));
5313
5314 rtx ccin = gen_rtx_REG (E_CC_Vmode, CC_REGNUM);
5315 operands[4] = gen_rtx_EQ (<MODE>mode, ccin, const0_rtx);
5316 operands[5] = operands[0];
5317 operands[6] = operands[3];
5318 }
5319 }
5320 )
5321
5322 ;; Unsigned saturating arithmetic with GPR operands can be optimised similarly
5323 ;; to the signed case, albeit without the need for a temporary register as the
5324 ;; saturating limit can be inferred from the <addsub> code. This applies only
5325 ;; to SImode and DImode.
5326
5327 (define_insn_and_split "<su_optab>s<addsub><mode>3<vczle><vczbe>"
5328 [(set (match_operand:GPI 0 "register_operand")
5329 (UBINQOPS:GPI (match_operand:GPI 1 "register_operand")
5330 (match_operand:GPI 2 "aarch64_plus_operand")))
5331 (clobber (reg:CC CC_REGNUM))]
5332 ""
5333 {@ [ cons: =0, 1 , 2 ; attrs: type , arch , length ]
5334 [ w , w , w ; neon_q<addsub><q> , simd , 4 ] <su_optab>q<addsub>\\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>2<Vmtype>
5335 [ r , r , JIr ; * , * , 8 ] #
5336 }
5337 "&& reload_completed && GP_REGNUM_P (REGNO (operands[0]))"
5338 [(set (match_dup 0)
5339 (if_then_else:GPI
5340 (match_dup 3)
5341 (match_dup 0)
5342 (match_dup 4)))]
5343 {
5344
5345 if (REG_P (operands[2]))
5346 {
5347 switch (<CODE>)
5348 {
5349 case US_MINUS:
5350 emit_insn (gen_sub<mode>3_compare1 (operands[0], operands[1],
5351 operands[2]));
5352 break;
5353 case US_PLUS:
5354 emit_insn (gen_add<mode>3_compare0 (operands[0], operands[1],
5355 operands[2]));
5356 break;
5357 default:
5358 gcc_unreachable ();
5359 }
5360 }
5361 else
5362 {
5363 auto imm = UINTVAL (operands[2]);
5364 rtx neg_imm = gen_int_mode (-imm, <MODE>mode);
5365 switch (<CODE>)
5366 {
5367 case US_MINUS:
5368 emit_insn (gen_sub<mode>3_compare1_imm (operands[0], operands[1],
5369 operands[2], neg_imm));
5370 break;
5371 case US_PLUS:
5372 emit_insn (gen_sub<mode>3_compare1_imm (operands[0], operands[1],
5373 neg_imm, operands[2]));
5374 break;
5375 default:
5376 gcc_unreachable ();
5377 }
5378 }
5379
5380 rtx ccin = gen_rtx_REG (CCmode, CC_REGNUM);
5381 switch (<CODE>)
5382 {
5383 case US_PLUS:
5384 operands[3] = gen_rtx_LTU (<MODE>mode, ccin, const0_rtx);
5385 operands[4] = gen_int_mode (-1, <MODE>mode);
5386 break;
5387 case US_MINUS:
5388 operands[3] = gen_rtx_GEU (<MODE>mode, ccin, const0_rtx);
5389 operands[4] = const0_rtx;
5390 break;
5391 default:
5392 gcc_unreachable ();
5393 }
5394 }
5395 )
5396
5397 ;; suqadd and usqadd
5398
5399 (define_insn "aarch64_<sur>qadd<mode><vczle><vczbe>"
5400 [(set (match_operand:VSDQ_I 0 "register_operand" "=w")
5401 (unspec:VSDQ_I [(match_operand:VSDQ_I 1 "register_operand" "0")
5402 (match_operand:VSDQ_I 2 "register_operand" "w")]
5403 USSUQADD))]
5404 "TARGET_SIMD"
5405 "<sur>qadd\\t%<v>0<Vmtype>, %<v>2<Vmtype>"
5406 [(set_attr "type" "neon_qadd<q>")]
5407 )
5408
5409 ;; sqmovn and uqmovn
5410
5411 (define_insn "aarch64_<su>qmovn<mode><vczle><vczbe>"
5412 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
5413 (SAT_TRUNC:<VNARROWQ>
5414 (match_operand:SD_HSDI 1 "register_operand" "w")))]
5415 "TARGET_SIMD"
5416 "<su>qxtn\\t%<vn2>0<Vmntype>, %<v>1<Vmtype>"
5417 [(set_attr "type" "neon_sat_shift_imm_narrow_q")]
5418 )
5419
5420 (define_insn "aarch64_<su>qmovn<mode><vczle><vczbe>"
5421 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
5422 (SAT_TRUNC:<VNARROWQ>
5423 (match_operand:VQN 1 "register_operand" "w")))]
5424 "TARGET_SIMD"
5425 "<su>qxtn\\t%<vn2>0<Vmntype>, %<v>1<Vmtype>"
5426 [(set_attr "type" "neon_sat_shift_imm_narrow_q")]
5427 )
5428
5429 (define_insn "aarch64_<su>qxtn2<mode>_le"
5430 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
5431 (vec_concat:<VNARROWQ2>
5432 (match_operand:<VNARROWQ> 1 "register_operand" "0")
5433 (SAT_TRUNC:<VNARROWQ>
5434 (match_operand:VQN 2 "register_operand" "w"))))]
5435 "TARGET_SIMD && !BYTES_BIG_ENDIAN"
5436 "<su>qxtn2\\t%0.<V2ntype>, %2.<Vtype>"
5437 [(set_attr "type" "neon_sat_shift_imm_narrow_q")]
5438 )
5439
5440 (define_insn "aarch64_<su>qxtn2<mode>_be"
5441 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
5442 (vec_concat:<VNARROWQ2>
5443 (SAT_TRUNC:<VNARROWQ>
5444 (match_operand:VQN 2 "register_operand" "w"))
5445 (match_operand:<VNARROWQ> 1 "register_operand" "0")))]
5446 "TARGET_SIMD && BYTES_BIG_ENDIAN"
5447 "<su>qxtn2\\t%0.<V2ntype>, %2.<Vtype>"
5448 [(set_attr "type" "neon_sat_shift_imm_narrow_q")]
5449 )
5450
5451 (define_expand "aarch64_<su>qxtn2<mode>"
5452 [(match_operand:<VNARROWQ2> 0 "register_operand")
5453 (match_operand:<VNARROWQ> 1 "register_operand")
5454 (SAT_TRUNC:<VNARROWQ>
5455 (match_operand:VQN 2 "register_operand"))]
5456 "TARGET_SIMD"
5457 {
5458 if (BYTES_BIG_ENDIAN)
5459 emit_insn (gen_aarch64_<su>qxtn2<mode>_be (operands[0], operands[1],
5460 operands[2]));
5461 else
5462 emit_insn (gen_aarch64_<su>qxtn2<mode>_le (operands[0], operands[1],
5463 operands[2]));
5464 DONE;
5465 }
5466 )
5467
5468 ;; sqmovun
5469
5470 (define_insn "aarch64_sqmovun<mode>"
5471 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
5472 (truncate:<VNARROWQ>
5473 (smin:SD_HSDI
5474 (smax:SD_HSDI
5475 (match_operand:SD_HSDI 1 "register_operand" "w")
5476 (const_int 0))
5477 (const_int <half_mask>))))]
5478 "TARGET_SIMD"
5479 "sqxtun\\t%<vn2>0<Vmntype>, %<v>1<Vmtype>"
5480 [(set_attr "type" "neon_sat_shift_imm_narrow_q")]
5481 )
5482
5483 (define_insn "*aarch64_sqmovun<mode>_insn<vczle><vczbe>"
5484 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
5485 (truncate:<VNARROWQ>
5486 (smin:VQN
5487 (smax:VQN (match_operand:VQN 1 "register_operand" "w")
5488 (match_operand:VQN 2 "aarch64_simd_or_scalar_imm_zero"))
5489 (match_operand:VQN 3 "aarch64_simd_umax_half_mode"))))]
5490 "TARGET_SIMD"
5491 "sqxtun\\t%<vn2>0<Vmntype>, %<v>1<Vmtype>"
5492 [(set_attr "type" "neon_sat_shift_imm_narrow_q")]
5493 )
5494
5495 (define_expand "aarch64_sqmovun<mode>"
5496 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
5497 (truncate:<VNARROWQ>
5498 (smin:VQN
5499 (smax:VQN (match_operand:VQN 1 "register_operand" "w")
5500 (match_dup 2))
5501 (match_dup 3))))]
5502 "TARGET_SIMD"
5503 {
5504 operands[2] = CONST0_RTX (<MODE>mode);
5505 operands[3]
5506 = aarch64_simd_gen_const_vector_dup (<MODE>mode,
5507 GET_MODE_MASK (GET_MODE_INNER (<VNARROWQ>mode)));
5508 }
5509 )
5510
5511 (define_insn "aarch64_sqxtun2<mode>_le"
5512 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
5513 (vec_concat:<VNARROWQ2>
5514 (match_operand:<VNARROWQ> 1 "register_operand" "0")
5515 (truncate:<VNARROWQ>
5516 (smin:VQN
5517 (smax:VQN
5518 (match_operand:VQN 2 "register_operand" "w")
5519 (match_operand:VQN 3 "aarch64_simd_or_scalar_imm_zero"))
5520 (match_operand:VQN 4 "aarch64_simd_umax_half_mode")))))]
5521 "TARGET_SIMD && !BYTES_BIG_ENDIAN"
5522 "sqxtun2\\t%0.<V2ntype>, %2.<Vtype>"
5523 [(set_attr "type" "neon_sat_shift_imm_narrow_q")]
5524 )
5525
5526 (define_insn "aarch64_sqxtun2<mode>_be"
5527 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
5528 (vec_concat:<VNARROWQ2>
5529 (truncate:<VNARROWQ>
5530 (smin:VQN
5531 (smax:VQN
5532 (match_operand:VQN 2 "register_operand" "w")
5533 (match_operand:VQN 3 "aarch64_simd_or_scalar_imm_zero"))
5534 (match_operand:VQN 4 "aarch64_simd_umax_half_mode")))
5535 (match_operand:<VNARROWQ> 1 "register_operand" "0")))]
5536 "TARGET_SIMD && BYTES_BIG_ENDIAN"
5537 "sqxtun2\\t%0.<V2ntype>, %2.<Vtype>"
5538 [(set_attr "type" "neon_sat_shift_imm_narrow_q")]
5539 )
5540
5541 (define_expand "aarch64_sqxtun2<mode>"
5542 [(match_operand:<VNARROWQ2> 0 "register_operand")
5543 (match_operand:<VNARROWQ> 1 "register_operand")
5544 (match_operand:VQN 2 "register_operand")]
5545 "TARGET_SIMD"
5546 {
5547 rtx zeros = CONST0_RTX (<MODE>mode);
5548 rtx half_umax = aarch64_simd_gen_const_vector_dup (<MODE>mode,
5549 GET_MODE_MASK (GET_MODE_INNER (<VNARROWQ>mode)));
5550 if (BYTES_BIG_ENDIAN)
5551 emit_insn (gen_aarch64_sqxtun2<mode>_be (operands[0], operands[1],
5552 operands[2], zeros, half_umax));
5553 else
5554 emit_insn (gen_aarch64_sqxtun2<mode>_le (operands[0], operands[1],
5555 operands[2], zeros, half_umax));
5556 DONE;
5557 }
5558 )
5559
5560 ;; <su>q<absneg>
5561
5562 (define_insn "aarch64_s<optab><mode><vczle><vczbe>"
5563 [(set (match_operand:VSDQ_I 0 "register_operand" "=w")
5564 (UNQOPS:VSDQ_I
5565 (match_operand:VSDQ_I 1 "register_operand" "w")))]
5566 "TARGET_SIMD"
5567 "s<optab>\\t%<v>0<Vmtype>, %<v>1<Vmtype>"
5568 [(set_attr "type" "neon_<optab><q>")]
5569 )
5570
5571 ;; sq<r>dmulh.
5572
5573 (define_insn "aarch64_sq<r>dmulh<mode><vczle><vczbe>"
5574 [(set (match_operand:VSDQ_HSI 0 "register_operand" "=w")
5575 (unspec:VSDQ_HSI
5576 [(match_operand:VSDQ_HSI 1 "register_operand" "w")
5577 (match_operand:VSDQ_HSI 2 "register_operand" "w")]
5578 VQDMULH))]
5579 "TARGET_SIMD"
5580 "sq<r>dmulh\\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>2<Vmtype>"
5581 [(set_attr "type" "neon_sat_mul_<Vetype><q>")]
5582 )
5583
5584 (define_insn "aarch64_sq<r>dmulh_n<mode><vczle><vczbe>"
5585 [(set (match_operand:VDQHS 0 "register_operand" "=w")
5586 (unspec:VDQHS
5587 [(match_operand:VDQHS 1 "register_operand" "w")
5588 (vec_duplicate:VDQHS
5589 (match_operand:<VEL> 2 "register_operand" "<h_con>"))]
5590 VQDMULH))]
5591 "TARGET_SIMD"
5592 "sq<r>dmulh\\t%0.<Vtype>, %1.<Vtype>, %2.<Vetype>[0]"
5593 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar<q>")]
5594 )
5595
5596 ;; sq<r>dmulh_lane
5597
5598 (define_insn "aarch64_sq<r>dmulh_lane<mode><vczle><vczbe>"
5599 [(set (match_operand:VDQHS 0 "register_operand" "=w")
5600 (unspec:VDQHS
5601 [(match_operand:VDQHS 1 "register_operand" "w")
5602 (vec_select:<VEL>
5603 (match_operand:<VCOND> 2 "register_operand" "<vwx>")
5604 (parallel [(match_operand:SI 3 "immediate_operand" "i")]))]
5605 VQDMULH))]
5606 "TARGET_SIMD"
5607 "*
5608 operands[3] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[3]));
5609 return \"sq<r>dmulh\\t%0.<Vtype>, %1.<Vtype>, %2.<Vetype>[%3]\";"
5610 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar<q>")]
5611 )
5612
5613 (define_insn "aarch64_sq<r>dmulh_laneq<mode><vczle><vczbe>"
5614 [(set (match_operand:VDQHS 0 "register_operand" "=w")
5615 (unspec:VDQHS
5616 [(match_operand:VDQHS 1 "register_operand" "w")
5617 (vec_select:<VEL>
5618 (match_operand:<VCONQ> 2 "register_operand" "<vwx>")
5619 (parallel [(match_operand:SI 3 "immediate_operand" "i")]))]
5620 VQDMULH))]
5621 "TARGET_SIMD"
5622 "*
5623 operands[3] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[3]));
5624 return \"sq<r>dmulh\\t%0.<Vtype>, %1.<Vtype>, %2.<Vetype>[%3]\";"
5625 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar<q>")]
5626 )
5627
5628 (define_insn "aarch64_sq<r>dmulh_lane<mode>"
5629 [(set (match_operand:SD_HSI 0 "register_operand" "=w")
5630 (unspec:SD_HSI
5631 [(match_operand:SD_HSI 1 "register_operand" "w")
5632 (vec_select:<VEL>
5633 (match_operand:<VCOND> 2 "register_operand" "<vwx>")
5634 (parallel [(match_operand:SI 3 "immediate_operand" "i")]))]
5635 VQDMULH))]
5636 "TARGET_SIMD"
5637 "*
5638 operands[3] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[3]));
5639 return \"sq<r>dmulh\\t%<v>0, %<v>1, %2.<v>[%3]\";"
5640 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar<q>")]
5641 )
5642
5643 (define_insn "aarch64_sq<r>dmulh_laneq<mode>"
5644 [(set (match_operand:SD_HSI 0 "register_operand" "=w")
5645 (unspec:SD_HSI
5646 [(match_operand:SD_HSI 1 "register_operand" "w")
5647 (vec_select:<VEL>
5648 (match_operand:<VCONQ> 2 "register_operand" "<vwx>")
5649 (parallel [(match_operand:SI 3 "immediate_operand" "i")]))]
5650 VQDMULH))]
5651 "TARGET_SIMD"
5652 "*
5653 operands[3] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[3]));
5654 return \"sq<r>dmulh\\t%<v>0, %<v>1, %2.<v>[%3]\";"
5655 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar<q>")]
5656 )
5657
5658 ;; sqrdml[as]h.
5659
5660 (define_insn "aarch64_sqrdml<SQRDMLH_AS:rdma_as>h<mode><vczle><vczbe>"
5661 [(set (match_operand:VSDQ_HSI 0 "register_operand" "=w")
5662 (unspec:VSDQ_HSI
5663 [(match_operand:VSDQ_HSI 1 "register_operand" "0")
5664 (match_operand:VSDQ_HSI 2 "register_operand" "w")
5665 (match_operand:VSDQ_HSI 3 "register_operand" "w")]
5666 SQRDMLH_AS))]
5667 "TARGET_SIMD_RDMA"
5668 "sqrdml<SQRDMLH_AS:rdma_as>h\\t%<v>0<Vmtype>, %<v>2<Vmtype>, %<v>3<Vmtype>"
5669 [(set_attr "type" "neon_sat_mla_<Vetype>_long")]
5670 )
5671
5672 ;; sqrdml[as]h_lane.
5673
5674 (define_insn "aarch64_sqrdml<SQRDMLH_AS:rdma_as>h_lane<mode><vczle><vczbe>"
5675 [(set (match_operand:VDQHS 0 "register_operand" "=w")
5676 (unspec:VDQHS
5677 [(match_operand:VDQHS 1 "register_operand" "0")
5678 (match_operand:VDQHS 2 "register_operand" "w")
5679 (vec_select:<VEL>
5680 (match_operand:<VCOND> 3 "register_operand" "<vwx>")
5681 (parallel [(match_operand:SI 4 "immediate_operand" "i")]))]
5682 SQRDMLH_AS))]
5683 "TARGET_SIMD_RDMA"
5684 {
5685 operands[4] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[4]));
5686 return
5687 "sqrdml<SQRDMLH_AS:rdma_as>h\\t%0.<Vtype>, %2.<Vtype>, %3.<Vetype>[%4]";
5688 }
5689 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
5690 )
5691
5692 (define_insn "aarch64_sqrdml<SQRDMLH_AS:rdma_as>h_lane<mode><vczle><vczbe>"
5693 [(set (match_operand:SD_HSI 0 "register_operand" "=w")
5694 (unspec:SD_HSI
5695 [(match_operand:SD_HSI 1 "register_operand" "0")
5696 (match_operand:SD_HSI 2 "register_operand" "w")
5697 (vec_select:<VEL>
5698 (match_operand:<VCOND> 3 "register_operand" "<vwx>")
5699 (parallel [(match_operand:SI 4 "immediate_operand" "i")]))]
5700 SQRDMLH_AS))]
5701 "TARGET_SIMD_RDMA"
5702 {
5703 operands[4] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[4]));
5704 return
5705 "sqrdml<SQRDMLH_AS:rdma_as>h\\t%<v>0, %<v>2, %3.<Vetype>[%4]";
5706 }
5707 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
5708 )
5709
5710 ;; sqrdml[as]h_laneq.
5711
5712 (define_insn "aarch64_sqrdml<SQRDMLH_AS:rdma_as>h_laneq<mode><vczle><vczbe>"
5713 [(set (match_operand:VDQHS 0 "register_operand" "=w")
5714 (unspec:VDQHS
5715 [(match_operand:VDQHS 1 "register_operand" "0")
5716 (match_operand:VDQHS 2 "register_operand" "w")
5717 (vec_select:<VEL>
5718 (match_operand:<VCONQ> 3 "register_operand" "<vwx>")
5719 (parallel [(match_operand:SI 4 "immediate_operand" "i")]))]
5720 SQRDMLH_AS))]
5721 "TARGET_SIMD_RDMA"
5722 {
5723 operands[4] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[4]));
5724 return
5725 "sqrdml<SQRDMLH_AS:rdma_as>h\\t%0.<Vtype>, %2.<Vtype>, %3.<Vetype>[%4]";
5726 }
5727 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
5728 )
5729
5730 (define_insn "aarch64_sqrdml<SQRDMLH_AS:rdma_as>h_laneq<mode><vczle><vczbe>"
5731 [(set (match_operand:SD_HSI 0 "register_operand" "=w")
5732 (unspec:SD_HSI
5733 [(match_operand:SD_HSI 1 "register_operand" "0")
5734 (match_operand:SD_HSI 2 "register_operand" "w")
5735 (vec_select:<VEL>
5736 (match_operand:<VCONQ> 3 "register_operand" "<vwx>")
5737 (parallel [(match_operand:SI 4 "immediate_operand" "i")]))]
5738 SQRDMLH_AS))]
5739 "TARGET_SIMD_RDMA"
5740 {
5741 operands[4] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[4]));
5742 return
5743 "sqrdml<SQRDMLH_AS:rdma_as>h\\t%<v>0, %<v>2, %3.<v>[%4]";
5744 }
5745 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
5746 )
5747
5748 ;; vqdml[sa]l
5749
5750 (define_insn "aarch64_sqdmlal<mode>"
5751 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
5752 (ss_plus:<VWIDE>
5753 (ss_ashift:<VWIDE>
5754 (mult:<VWIDE>
5755 (sign_extend:<VWIDE>
5756 (match_operand:VSD_HSI 2 "register_operand" "w"))
5757 (sign_extend:<VWIDE>
5758 (match_operand:VSD_HSI 3 "register_operand" "w")))
5759 (const_int 1))
5760 (match_operand:<VWIDE> 1 "register_operand" "0")))]
5761 "TARGET_SIMD"
5762 "sqdmlal\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %<v>3<Vmtype>"
5763 [(set_attr "type" "neon_sat_mla_<Vetype>_long")]
5764 )
5765
5766 (define_insn "aarch64_sqdmlsl<mode>"
5767 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
5768 (ss_minus:<VWIDE>
5769 (match_operand:<VWIDE> 1 "register_operand" "0")
5770 (ss_ashift:<VWIDE>
5771 (mult:<VWIDE>
5772 (sign_extend:<VWIDE>
5773 (match_operand:VSD_HSI 2 "register_operand" "w"))
5774 (sign_extend:<VWIDE>
5775 (match_operand:VSD_HSI 3 "register_operand" "w")))
5776 (const_int 1))))]
5777 "TARGET_SIMD"
5778 "sqdmlsl\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %<v>3<Vmtype>"
5779 [(set_attr "type" "neon_sat_mla_<Vetype>_long")]
5780 )
5781
5782 ;; vqdml[sa]l_lane
5783
5784 (define_insn "aarch64_sqdmlal_lane<mode>"
5785 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
5786 (ss_plus:<VWIDE>
5787 (ss_ashift:<VWIDE>
5788 (mult:<VWIDE>
5789 (sign_extend:<VWIDE>
5790 (match_operand:VD_HSI 2 "register_operand" "w"))
5791 (vec_duplicate:<VWIDE>
5792 (sign_extend:<VWIDE_S>
5793 (vec_select:<VEL>
5794 (match_operand:<VCOND> 3 "register_operand" "<vwx>")
5795 (parallel [(match_operand:SI 4 "immediate_operand" "i")])))
5796 ))
5797 (const_int 1))
5798 (match_operand:<VWIDE> 1 "register_operand" "0")))]
5799 "TARGET_SIMD"
5800 {
5801 operands[4] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[4]));
5802 return
5803 "sqdmlal\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]";
5804 }
5805 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
5806 )
5807
5808 (define_insn "aarch64_sqdmlsl_lane<mode>"
5809 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
5810 (ss_minus:<VWIDE>
5811 (match_operand:<VWIDE> 1 "register_operand" "0")
5812 (ss_ashift:<VWIDE>
5813 (mult:<VWIDE>
5814 (sign_extend:<VWIDE>
5815 (match_operand:VD_HSI 2 "register_operand" "w"))
5816 (vec_duplicate:<VWIDE>
5817 (sign_extend:<VWIDE_S>
5818 (vec_select:<VEL>
5819 (match_operand:<VCOND> 3 "register_operand" "<vwx>")
5820 (parallel [(match_operand:SI 4 "immediate_operand" "i")])))
5821 ))
5822 (const_int 1))))]
5823 "TARGET_SIMD"
5824 {
5825 operands[4] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[4]));
5826 return
5827 "sqdmlsl\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]";
5828 }
5829 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
5830 )
5831
5832
5833 (define_insn "aarch64_sqdmlsl_laneq<mode>"
5834 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
5835 (ss_minus:<VWIDE>
5836 (match_operand:<VWIDE> 1 "register_operand" "0")
5837 (ss_ashift:<VWIDE>
5838 (mult:<VWIDE>
5839 (sign_extend:<VWIDE>
5840 (match_operand:VD_HSI 2 "register_operand" "w"))
5841 (vec_duplicate:<VWIDE>
5842 (sign_extend:<VWIDE_S>
5843 (vec_select:<VEL>
5844 (match_operand:<VCONQ> 3 "register_operand" "<vwx>")
5845 (parallel [(match_operand:SI 4 "immediate_operand" "i")])))
5846 ))
5847 (const_int 1))))]
5848 "TARGET_SIMD"
5849 {
5850 operands[4] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[4]));
5851 return
5852 "sqdmlsl\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]";
5853 }
5854 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
5855 )
5856
5857 (define_insn "aarch64_sqdmlal_laneq<mode>"
5858 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
5859 (ss_plus:<VWIDE>
5860 (ss_ashift:<VWIDE>
5861 (mult:<VWIDE>
5862 (sign_extend:<VWIDE>
5863 (match_operand:VD_HSI 2 "register_operand" "w"))
5864 (vec_duplicate:<VWIDE>
5865 (sign_extend:<VWIDE_S>
5866 (vec_select:<VEL>
5867 (match_operand:<VCONQ> 3 "register_operand" "<vwx>")
5868 (parallel [(match_operand:SI 4 "immediate_operand" "i")])))
5869 ))
5870 (const_int 1))
5871 (match_operand:<VWIDE> 1 "register_operand" "0")))]
5872 "TARGET_SIMD"
5873 {
5874 operands[4] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[4]));
5875 return
5876 "sqdmlal\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]";
5877 }
5878 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
5879 )
5880
5881
5882 (define_insn "aarch64_sqdmlal_lane<mode>"
5883 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
5884 (ss_plus:<VWIDE>
5885 (ss_ashift:<VWIDE>
5886 (mult:<VWIDE>
5887 (sign_extend:<VWIDE>
5888 (match_operand:SD_HSI 2 "register_operand" "w"))
5889 (sign_extend:<VWIDE>
5890 (vec_select:<VEL>
5891 (match_operand:<VCOND> 3 "register_operand" "<vwx>")
5892 (parallel [(match_operand:SI 4 "immediate_operand" "i")])))
5893 )
5894 (const_int 1))
5895 (match_operand:<VWIDE> 1 "register_operand" "0")))]
5896 "TARGET_SIMD"
5897 {
5898 operands[4] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[4]));
5899 return
5900 "sqdmlal\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]";
5901 }
5902 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
5903 )
5904
5905 (define_insn "aarch64_sqdmlsl_lane<mode>"
5906 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
5907 (ss_minus:<VWIDE>
5908 (match_operand:<VWIDE> 1 "register_operand" "0")
5909 (ss_ashift:<VWIDE>
5910 (mult:<VWIDE>
5911 (sign_extend:<VWIDE>
5912 (match_operand:SD_HSI 2 "register_operand" "w"))
5913 (sign_extend:<VWIDE>
5914 (vec_select:<VEL>
5915 (match_operand:<VCOND> 3 "register_operand" "<vwx>")
5916 (parallel [(match_operand:SI 4 "immediate_operand" "i")])))
5917 )
5918 (const_int 1))))]
5919 "TARGET_SIMD"
5920 {
5921 operands[4] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[4]));
5922 return
5923 "sqdmlsl\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]";
5924 }
5925 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
5926 )
5927
5928
5929 (define_insn "aarch64_sqdmlal_laneq<mode>"
5930 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
5931 (ss_plus:<VWIDE>
5932 (ss_ashift:<VWIDE>
5933 (mult:<VWIDE>
5934 (sign_extend:<VWIDE>
5935 (match_operand:SD_HSI 2 "register_operand" "w"))
5936 (sign_extend:<VWIDE>
5937 (vec_select:<VEL>
5938 (match_operand:<VCONQ> 3 "register_operand" "<vwx>")
5939 (parallel [(match_operand:SI 4 "immediate_operand" "i")])))
5940 )
5941 (const_int 1))
5942 (match_operand:<VWIDE> 1 "register_operand" "0")))]
5943 "TARGET_SIMD"
5944 {
5945 operands[4] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[4]));
5946 return
5947 "sqdmlal\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]";
5948 }
5949 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
5950 )
5951
5952 (define_insn "aarch64_sqdmlsl_laneq<mode>"
5953 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
5954 (ss_minus:<VWIDE>
5955 (match_operand:<VWIDE> 1 "register_operand" "0")
5956 (ss_ashift:<VWIDE>
5957 (mult:<VWIDE>
5958 (sign_extend:<VWIDE>
5959 (match_operand:SD_HSI 2 "register_operand" "w"))
5960 (sign_extend:<VWIDE>
5961 (vec_select:<VEL>
5962 (match_operand:<VCONQ> 3 "register_operand" "<vwx>")
5963 (parallel [(match_operand:SI 4 "immediate_operand" "i")])))
5964 )
5965 (const_int 1))))]
5966 "TARGET_SIMD"
5967 {
5968 operands[4] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[4]));
5969 return
5970 "sqdmlsl\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]";
5971 }
5972 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
5973 )
5974
5975 ;; vqdml[sa]l_n
5976
5977 (define_insn "aarch64_sqdmlsl_n<mode>"
5978 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
5979 (ss_minus:<VWIDE>
5980 (match_operand:<VWIDE> 1 "register_operand" "0")
5981 (ss_ashift:<VWIDE>
5982 (mult:<VWIDE>
5983 (sign_extend:<VWIDE>
5984 (match_operand:VD_HSI 2 "register_operand" "w"))
5985 (vec_duplicate:<VWIDE>
5986 (sign_extend:<VWIDE_S>
5987 (match_operand:<VEL> 3 "register_operand" "<vwx>"))))
5988 (const_int 1))))]
5989 "TARGET_SIMD"
5990 "sqdmlsl\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[0]"
5991 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
5992 )
5993
5994 (define_insn "aarch64_sqdmlal_n<mode>"
5995 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
5996 (ss_plus:<VWIDE>
5997 (ss_ashift:<VWIDE>
5998 (mult:<VWIDE>
5999 (sign_extend:<VWIDE>
6000 (match_operand:VD_HSI 2 "register_operand" "w"))
6001 (vec_duplicate:<VWIDE>
6002 (sign_extend:<VWIDE_S>
6003 (match_operand:<VEL> 3 "register_operand" "<vwx>"))))
6004 (const_int 1))
6005 (match_operand:<VWIDE> 1 "register_operand" "0")))]
6006 "TARGET_SIMD"
6007 "sqdmlal\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[0]"
6008 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
6009 )
6010
6011
6012 ;; sqdml[as]l2
6013
6014 (define_insn "aarch64_sqdmlal2<mode>_internal"
6015 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6016 (ss_plus:<VWIDE>
6017 (ss_ashift:<VWIDE>
6018 (mult:<VWIDE>
6019 (sign_extend:<VWIDE>
6020 (vec_select:<VHALF>
6021 (match_operand:VQ_HSI 2 "register_operand" "w")
6022 (match_operand:VQ_HSI 4 "vect_par_cnst_hi_half" "")))
6023 (sign_extend:<VWIDE>
6024 (vec_select:<VHALF>
6025 (match_operand:VQ_HSI 3 "register_operand" "w")
6026 (match_dup 4))))
6027 (const_int 1))
6028 (match_operand:<VWIDE> 1 "register_operand" "0")))]
6029 "TARGET_SIMD"
6030 "sqdmlal2\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %<v>3<Vmtype>"
6031 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
6032 )
6033
6034 (define_insn "aarch64_sqdmlsl2<mode>_internal"
6035 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6036 (ss_minus:<VWIDE>
6037 (match_operand:<VWIDE> 1 "register_operand" "0")
6038 (ss_ashift:<VWIDE>
6039 (mult:<VWIDE>
6040 (sign_extend:<VWIDE>
6041 (vec_select:<VHALF>
6042 (match_operand:VQ_HSI 2 "register_operand" "w")
6043 (match_operand:VQ_HSI 4 "vect_par_cnst_hi_half" "")))
6044 (sign_extend:<VWIDE>
6045 (vec_select:<VHALF>
6046 (match_operand:VQ_HSI 3 "register_operand" "w")
6047 (match_dup 4))))
6048 (const_int 1))))]
6049 "TARGET_SIMD"
6050 "sqdmlsl2\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %<v>3<Vmtype>"
6051 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
6052 )
6053
6054 (define_expand "aarch64_sqdml<SBINQOPS:as>l2<mode>"
6055 [(match_operand:<VWIDE> 0 "register_operand")
6056 (SBINQOPS:<VWIDE>
6057 (match_operand:<VWIDE> 1 "register_operand")
6058 (match_dup 1))
6059 (match_operand:VQ_HSI 2 "register_operand")
6060 (match_operand:VQ_HSI 3 "register_operand")]
6061 "TARGET_SIMD"
6062 {
6063 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
6064 emit_insn (gen_aarch64_sqdml<SBINQOPS:as>l2<mode>_internal (operands[0],
6065 operands[1], operands[2],
6066 operands[3], p));
6067 DONE;
6068 })
6069
6070 ;; vqdml[sa]l2_lane
6071
6072 (define_insn "aarch64_sqdmlsl2_lane<mode>_internal"
6073 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6074 (ss_minus:<VWIDE>
6075 (match_operand:<VWIDE> 1 "register_operand" "0")
6076 (ss_ashift:<VWIDE>
6077 (mult:<VWIDE>
6078 (sign_extend:<VWIDE>
6079 (vec_select:<VHALF>
6080 (match_operand:VQ_HSI 2 "register_operand" "w")
6081 (match_operand:VQ_HSI 5 "vect_par_cnst_hi_half" "")))
6082 (vec_duplicate:<VWIDE>
6083 (sign_extend:<VWIDE_S>
6084 (vec_select:<VEL>
6085 (match_operand:<VCOND> 3 "register_operand" "<vwx>")
6086 (parallel [(match_operand:SI 4 "immediate_operand" "i")])
6087 ))))
6088 (const_int 1))))]
6089 "TARGET_SIMD"
6090 {
6091 operands[4] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[4]));
6092 return
6093 "sqdmlsl2\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]";
6094 }
6095 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
6096 )
6097
6098 (define_insn "aarch64_sqdmlal2_lane<mode>_internal"
6099 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6100 (ss_plus:<VWIDE>
6101 (ss_ashift:<VWIDE>
6102 (mult:<VWIDE>
6103 (sign_extend:<VWIDE>
6104 (vec_select:<VHALF>
6105 (match_operand:VQ_HSI 2 "register_operand" "w")
6106 (match_operand:VQ_HSI 5 "vect_par_cnst_hi_half" "")))
6107 (vec_duplicate:<VWIDE>
6108 (sign_extend:<VWIDE_S>
6109 (vec_select:<VEL>
6110 (match_operand:<VCOND> 3 "register_operand" "<vwx>")
6111 (parallel [(match_operand:SI 4 "immediate_operand" "i")])
6112 ))))
6113 (const_int 1))
6114 (match_operand:<VWIDE> 1 "register_operand" "0")))]
6115 "TARGET_SIMD"
6116 {
6117 operands[4] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[4]));
6118 return
6119 "sqdmlal2\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]";
6120 }
6121 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
6122 )
6123
6124 (define_insn "aarch64_sqdmlsl2_laneq<mode>_internal"
6125 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6126 (ss_minus:<VWIDE>
6127 (match_operand:<VWIDE> 1 "register_operand" "0")
6128 (ss_ashift:<VWIDE>
6129 (mult:<VWIDE>
6130 (sign_extend:<VWIDE>
6131 (vec_select:<VHALF>
6132 (match_operand:VQ_HSI 2 "register_operand" "w")
6133 (match_operand:VQ_HSI 5 "vect_par_cnst_hi_half" "")))
6134 (vec_duplicate:<VWIDE>
6135 (sign_extend:<VWIDE_S>
6136 (vec_select:<VEL>
6137 (match_operand:<VCONQ> 3 "register_operand" "<vwx>")
6138 (parallel [(match_operand:SI 4 "immediate_operand" "i")])
6139 ))))
6140 (const_int 1))))]
6141 "TARGET_SIMD"
6142 {
6143 operands[4] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[4]));
6144 return
6145 "sqdmlsl2\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]";
6146 }
6147 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
6148 )
6149
6150 (define_insn "aarch64_sqdmlal2_laneq<mode>_internal"
6151 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6152 (ss_plus:<VWIDE>
6153 (ss_ashift:<VWIDE>
6154 (mult:<VWIDE>
6155 (sign_extend:<VWIDE>
6156 (vec_select:<VHALF>
6157 (match_operand:VQ_HSI 2 "register_operand" "w")
6158 (match_operand:VQ_HSI 5 "vect_par_cnst_hi_half" "")))
6159 (vec_duplicate:<VWIDE>
6160 (sign_extend:<VWIDE_S>
6161 (vec_select:<VEL>
6162 (match_operand:<VCONQ> 3 "register_operand" "<vwx>")
6163 (parallel [(match_operand:SI 4 "immediate_operand" "i")])
6164 ))))
6165 (const_int 1))
6166 (match_operand:<VWIDE> 1 "register_operand" "0")))]
6167 "TARGET_SIMD"
6168 {
6169 operands[4] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[4]));
6170 return
6171 "sqdmlal2\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[%4]";
6172 }
6173 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
6174 )
6175
6176 (define_expand "aarch64_sqdml<SBINQOPS:as>l2_lane<mode>"
6177 [(match_operand:<VWIDE> 0 "register_operand")
6178 (SBINQOPS:<VWIDE>
6179 (match_operand:<VWIDE> 1 "register_operand")
6180 (match_dup 1))
6181 (match_operand:VQ_HSI 2 "register_operand")
6182 (match_operand:<VCOND> 3 "register_operand")
6183 (match_operand:SI 4 "immediate_operand")]
6184 "TARGET_SIMD"
6185 {
6186 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
6187 emit_insn (gen_aarch64_sqdml<SBINQOPS:as>l2_lane<mode>_internal (operands[0],
6188 operands[1], operands[2],
6189 operands[3], operands[4], p));
6190 DONE;
6191 })
6192
6193 (define_expand "aarch64_sqdml<SBINQOPS:as>l2_laneq<mode>"
6194 [(match_operand:<VWIDE> 0 "register_operand")
6195 (SBINQOPS:<VWIDE>
6196 (match_operand:<VWIDE> 1 "register_operand")
6197 (match_dup 1))
6198 (match_operand:VQ_HSI 2 "register_operand")
6199 (match_operand:<VCONQ> 3 "register_operand")
6200 (match_operand:SI 4 "immediate_operand")]
6201 "TARGET_SIMD"
6202 {
6203 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
6204 emit_insn (gen_aarch64_sqdml<SBINQOPS:as>l2_laneq<mode>_internal (operands[0],
6205 operands[1], operands[2],
6206 operands[3], operands[4], p));
6207 DONE;
6208 })
6209
6210 (define_insn "aarch64_sqdmlsl2_n<mode>_internal"
6211 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6212 (ss_minus:<VWIDE>
6213 (match_operand:<VWIDE> 1 "register_operand" "0")
6214 (ss_ashift:<VWIDE>
6215 (mult:<VWIDE>
6216 (sign_extend:<VWIDE>
6217 (vec_select:<VHALF>
6218 (match_operand:VQ_HSI 2 "register_operand" "w")
6219 (match_operand:VQ_HSI 4 "vect_par_cnst_hi_half" "")))
6220 (vec_duplicate:<VWIDE>
6221 (sign_extend:<VWIDE_S>
6222 (match_operand:<VEL> 3 "register_operand" "<vwx>"))))
6223 (const_int 1))))]
6224 "TARGET_SIMD"
6225 "sqdmlsl2\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[0]"
6226 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
6227 )
6228
6229 (define_insn "aarch64_sqdmlal2_n<mode>_internal"
6230 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6231 (ss_plus:<VWIDE>
6232 (ss_ashift:<VWIDE>
6233 (mult:<VWIDE>
6234 (sign_extend:<VWIDE>
6235 (vec_select:<VHALF>
6236 (match_operand:VQ_HSI 2 "register_operand" "w")
6237 (match_operand:VQ_HSI 4 "vect_par_cnst_hi_half" "")))
6238 (vec_duplicate:<VWIDE>
6239 (sign_extend:<VWIDE_S>
6240 (match_operand:<VEL> 3 "register_operand" "<vwx>"))))
6241 (const_int 1))
6242 (match_operand:<VWIDE> 1 "register_operand" "0")))]
6243 "TARGET_SIMD"
6244 "sqdmlal2\\t%<vw2>0<Vmwtype>, %<v>2<Vmtype>, %3.<Vetype>[0]"
6245 [(set_attr "type" "neon_sat_mla_<Vetype>_scalar_long")]
6246 )
6247
6248 (define_expand "aarch64_sqdml<SBINQOPS:as>l2_n<mode>"
6249 [(match_operand:<VWIDE> 0 "register_operand")
6250 (SBINQOPS:<VWIDE>
6251 (match_operand:<VWIDE> 1 "register_operand")
6252 (match_dup 1))
6253 (match_operand:VQ_HSI 2 "register_operand")
6254 (match_operand:<VEL> 3 "register_operand")]
6255 "TARGET_SIMD"
6256 {
6257 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
6258 emit_insn (gen_aarch64_sqdml<SBINQOPS:as>l2_n<mode>_internal (operands[0],
6259 operands[1], operands[2],
6260 operands[3], p));
6261 DONE;
6262 })
6263
6264 ;; vqdmull
6265
6266 (define_insn "aarch64_sqdmull<mode>"
6267 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6268 (ss_ashift:<VWIDE>
6269 (mult:<VWIDE>
6270 (sign_extend:<VWIDE>
6271 (match_operand:VSD_HSI 1 "register_operand" "w"))
6272 (sign_extend:<VWIDE>
6273 (match_operand:VSD_HSI 2 "register_operand" "w")))
6274 (const_int 1)))]
6275 "TARGET_SIMD"
6276 "sqdmull\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %<v>2<Vmtype>"
6277 [(set_attr "type" "neon_sat_mul_<Vetype>_long")]
6278 )
6279
6280 ;; vqdmull_lane
6281
6282 (define_insn "aarch64_sqdmull_lane<mode>"
6283 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6284 (ss_ashift:<VWIDE>
6285 (mult:<VWIDE>
6286 (sign_extend:<VWIDE>
6287 (match_operand:VD_HSI 1 "register_operand" "w"))
6288 (vec_duplicate:<VWIDE>
6289 (sign_extend:<VWIDE_S>
6290 (vec_select:<VEL>
6291 (match_operand:<VCOND> 2 "register_operand" "<vwx>")
6292 (parallel [(match_operand:SI 3 "immediate_operand" "i")])))
6293 ))
6294 (const_int 1)))]
6295 "TARGET_SIMD"
6296 {
6297 operands[3] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[3]));
6298 return "sqdmull\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]";
6299 }
6300 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar_long")]
6301 )
6302
6303 (define_insn "aarch64_sqdmull_laneq<mode>"
6304 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6305 (ss_ashift:<VWIDE>
6306 (mult:<VWIDE>
6307 (sign_extend:<VWIDE>
6308 (match_operand:VD_HSI 1 "register_operand" "w"))
6309 (vec_duplicate:<VWIDE>
6310 (sign_extend:<VWIDE_S>
6311 (vec_select:<VEL>
6312 (match_operand:<VCONQ> 2 "register_operand" "<vwx>")
6313 (parallel [(match_operand:SI 3 "immediate_operand" "i")])))
6314 ))
6315 (const_int 1)))]
6316 "TARGET_SIMD"
6317 {
6318 operands[3] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[3]));
6319 return "sqdmull\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]";
6320 }
6321 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar_long")]
6322 )
6323
6324 (define_insn "aarch64_sqdmull_lane<mode>"
6325 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6326 (ss_ashift:<VWIDE>
6327 (mult:<VWIDE>
6328 (sign_extend:<VWIDE>
6329 (match_operand:SD_HSI 1 "register_operand" "w"))
6330 (sign_extend:<VWIDE>
6331 (vec_select:<VEL>
6332 (match_operand:<VCOND> 2 "register_operand" "<vwx>")
6333 (parallel [(match_operand:SI 3 "immediate_operand" "i")]))
6334 ))
6335 (const_int 1)))]
6336 "TARGET_SIMD"
6337 {
6338 operands[3] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[3]));
6339 return "sqdmull\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]";
6340 }
6341 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar_long")]
6342 )
6343
6344 (define_insn "aarch64_sqdmull_laneq<mode>"
6345 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6346 (ss_ashift:<VWIDE>
6347 (mult:<VWIDE>
6348 (sign_extend:<VWIDE>
6349 (match_operand:SD_HSI 1 "register_operand" "w"))
6350 (sign_extend:<VWIDE>
6351 (vec_select:<VEL>
6352 (match_operand:<VCONQ> 2 "register_operand" "<vwx>")
6353 (parallel [(match_operand:SI 3 "immediate_operand" "i")]))
6354 ))
6355 (const_int 1)))]
6356 "TARGET_SIMD"
6357 {
6358 operands[3] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[3]));
6359 return "sqdmull\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]";
6360 }
6361 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar_long")]
6362 )
6363
6364 ;; vqdmull_n
6365
6366 (define_insn "aarch64_sqdmull_n<mode>"
6367 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6368 (ss_ashift:<VWIDE>
6369 (mult:<VWIDE>
6370 (sign_extend:<VWIDE>
6371 (match_operand:VD_HSI 1 "register_operand" "w"))
6372 (vec_duplicate:<VWIDE>
6373 (sign_extend:<VWIDE_S>
6374 (match_operand:<VEL> 2 "register_operand" "<vwx>")))
6375 )
6376 (const_int 1)))]
6377 "TARGET_SIMD"
6378 "sqdmull\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[0]"
6379 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar_long")]
6380 )
6381
6382 ;; vqdmull2
6383
6384 (define_insn "aarch64_sqdmull2<mode>_internal"
6385 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6386 (ss_ashift:<VWIDE>
6387 (mult:<VWIDE>
6388 (sign_extend:<VWIDE>
6389 (vec_select:<VHALF>
6390 (match_operand:VQ_HSI 1 "register_operand" "w")
6391 (match_operand:VQ_HSI 3 "vect_par_cnst_hi_half" "")))
6392 (sign_extend:<VWIDE>
6393 (vec_select:<VHALF>
6394 (match_operand:VQ_HSI 2 "register_operand" "w")
6395 (match_dup 3)))
6396 )
6397 (const_int 1)))]
6398 "TARGET_SIMD"
6399 "sqdmull2\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %<v>2<Vmtype>"
6400 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar_long")]
6401 )
6402
6403 (define_expand "aarch64_sqdmull2<mode>"
6404 [(match_operand:<VWIDE> 0 "register_operand")
6405 (match_operand:VQ_HSI 1 "register_operand")
6406 (match_operand:VQ_HSI 2 "register_operand")]
6407 "TARGET_SIMD"
6408 {
6409 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
6410 emit_insn (gen_aarch64_sqdmull2<mode>_internal (operands[0], operands[1],
6411 operands[2], p));
6412 DONE;
6413 })
6414
6415 ;; vqdmull2_lane
6416
6417 (define_insn "aarch64_sqdmull2_lane<mode>_internal"
6418 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6419 (ss_ashift:<VWIDE>
6420 (mult:<VWIDE>
6421 (sign_extend:<VWIDE>
6422 (vec_select:<VHALF>
6423 (match_operand:VQ_HSI 1 "register_operand" "w")
6424 (match_operand:VQ_HSI 4 "vect_par_cnst_hi_half" "")))
6425 (vec_duplicate:<VWIDE>
6426 (sign_extend:<VWIDE_S>
6427 (vec_select:<VEL>
6428 (match_operand:<VCOND> 2 "register_operand" "<vwx>")
6429 (parallel [(match_operand:SI 3 "immediate_operand" "i")])))
6430 ))
6431 (const_int 1)))]
6432 "TARGET_SIMD"
6433 {
6434 operands[3] = aarch64_endian_lane_rtx (<VCOND>mode, INTVAL (operands[3]));
6435 return "sqdmull2\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]";
6436 }
6437 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar_long")]
6438 )
6439
6440 (define_insn "aarch64_sqdmull2_laneq<mode>_internal"
6441 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6442 (ss_ashift:<VWIDE>
6443 (mult:<VWIDE>
6444 (sign_extend:<VWIDE>
6445 (vec_select:<VHALF>
6446 (match_operand:VQ_HSI 1 "register_operand" "w")
6447 (match_operand:VQ_HSI 4 "vect_par_cnst_hi_half" "")))
6448 (vec_duplicate:<VWIDE>
6449 (sign_extend:<VWIDE_S>
6450 (vec_select:<VEL>
6451 (match_operand:<VCONQ> 2 "register_operand" "<vwx>")
6452 (parallel [(match_operand:SI 3 "immediate_operand" "i")])))
6453 ))
6454 (const_int 1)))]
6455 "TARGET_SIMD"
6456 {
6457 operands[3] = aarch64_endian_lane_rtx (<VCONQ>mode, INTVAL (operands[3]));
6458 return "sqdmull2\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[%3]";
6459 }
6460 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar_long")]
6461 )
6462
6463 (define_expand "aarch64_sqdmull2_lane<mode>"
6464 [(match_operand:<VWIDE> 0 "register_operand")
6465 (match_operand:VQ_HSI 1 "register_operand")
6466 (match_operand:<VCOND> 2 "register_operand")
6467 (match_operand:SI 3 "immediate_operand")]
6468 "TARGET_SIMD"
6469 {
6470 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
6471 emit_insn (gen_aarch64_sqdmull2_lane<mode>_internal (operands[0], operands[1],
6472 operands[2], operands[3],
6473 p));
6474 DONE;
6475 })
6476
6477 (define_expand "aarch64_sqdmull2_laneq<mode>"
6478 [(match_operand:<VWIDE> 0 "register_operand")
6479 (match_operand:VQ_HSI 1 "register_operand")
6480 (match_operand:<VCONQ> 2 "register_operand")
6481 (match_operand:SI 3 "immediate_operand")]
6482 "TARGET_SIMD"
6483 {
6484 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
6485 emit_insn (gen_aarch64_sqdmull2_laneq<mode>_internal (operands[0], operands[1],
6486 operands[2], operands[3],
6487 p));
6488 DONE;
6489 })
6490
6491 ;; vqdmull2_n
6492
6493 (define_insn "aarch64_sqdmull2_n<mode>_internal"
6494 [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
6495 (ss_ashift:<VWIDE>
6496 (mult:<VWIDE>
6497 (sign_extend:<VWIDE>
6498 (vec_select:<VHALF>
6499 (match_operand:VQ_HSI 1 "register_operand" "w")
6500 (match_operand:VQ_HSI 3 "vect_par_cnst_hi_half" "")))
6501 (vec_duplicate:<VWIDE>
6502 (sign_extend:<VWIDE_S>
6503 (match_operand:<VEL> 2 "register_operand" "<vwx>")))
6504 )
6505 (const_int 1)))]
6506 "TARGET_SIMD"
6507 "sqdmull2\\t%<vw2>0<Vmwtype>, %<v>1<Vmtype>, %2.<Vetype>[0]"
6508 [(set_attr "type" "neon_sat_mul_<Vetype>_scalar_long")]
6509 )
6510
6511 (define_expand "aarch64_sqdmull2_n<mode>"
6512 [(match_operand:<VWIDE> 0 "register_operand")
6513 (match_operand:VQ_HSI 1 "register_operand")
6514 (match_operand:<VEL> 2 "register_operand")]
6515 "TARGET_SIMD"
6516 {
6517 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
6518 emit_insn (gen_aarch64_sqdmull2_n<mode>_internal (operands[0], operands[1],
6519 operands[2], p));
6520 DONE;
6521 })
6522
6523 ;; vshl
6524
6525 (define_insn "aarch64_<sur>shl<mode><vczle><vczbe>"
6526 [(set (match_operand:VSDQ_I_DI 0 "register_operand" "=w")
6527 (unspec:VSDQ_I_DI
6528 [(match_operand:VSDQ_I_DI 1 "register_operand" "w")
6529 (match_operand:VSDQ_I_DI 2 "register_operand" "w")]
6530 VSHL))]
6531 "TARGET_SIMD"
6532 "<sur>shl\\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>2<Vmtype>";
6533 [(set_attr "type" "neon_shift_reg<q>")]
6534 )
6535
6536
6537 ;; vqshl
6538
6539 (define_insn "aarch64_<sur>q<r>shl<mode><vczle><vczbe>"
6540 [(set (match_operand:VSDQ_I 0 "register_operand" "=w")
6541 (unspec:VSDQ_I
6542 [(match_operand:VSDQ_I 1 "register_operand" "w")
6543 (match_operand:VSDQ_I 2 "register_operand" "w")]
6544 VQSHL))]
6545 "TARGET_SIMD"
6546 "<sur>q<r>shl\\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>2<Vmtype>";
6547 [(set_attr "type" "neon_sat_shift_reg<q>")]
6548 )
6549
6550 ;; vshll_n
6551
6552 (define_insn "aarch64_<su>shll<mode>"
6553 [(set (match_operand:<VWIDE> 0 "register_operand")
6554 (ashift:<VWIDE> (ANY_EXTEND:<VWIDE>
6555 (match_operand:VD_BHSI 1 "register_operand"))
6556 (match_operand:<VWIDE> 2
6557 "aarch64_simd_shll_imm_vec")))]
6558 "TARGET_SIMD"
6559 {@ [cons: =0, 1, 2]
6560 [w, w, D2] shll\t%0.<Vwtype>, %1.<Vtype>, %I2
6561 [w, w, DL] <su>shll\t%0.<Vwtype>, %1.<Vtype>, %I2
6562 }
6563 [(set_attr "type" "neon_shift_imm_long")]
6564 )
6565
6566 (define_expand "aarch64_<sur>shll_n<mode>"
6567 [(set (match_operand:<VWIDE> 0 "register_operand")
6568 (unspec:<VWIDE> [(match_operand:VD_BHSI 1 "register_operand")
6569 (match_operand:SI 2
6570 "aarch64_simd_shift_imm_bitsize_<ve_mode>")]
6571 VSHLL))]
6572 "TARGET_SIMD"
6573 {
6574 rtx shft = gen_const_vec_duplicate (<VWIDE>mode, operands[2]);
6575 emit_insn (gen_aarch64_<sur>shll<mode> (operands[0], operands[1], shft));
6576 DONE;
6577 }
6578 )
6579
6580 ;; vshll_high_n
6581
6582 (define_insn "aarch64_<su>shll2<mode>"
6583 [(set (match_operand:<VWIDE> 0 "register_operand")
6584 (ashift:<VWIDE> (ANY_EXTEND:<VWIDE>
6585 (vec_select:<VHALF>
6586 (match_operand:VQW 1 "register_operand")
6587 (match_operand:VQW 2 "vect_par_cnst_hi_half")))
6588 (match_operand:<VWIDE> 3
6589 "aarch64_simd_shll_imm_vec")))]
6590 "TARGET_SIMD"
6591 {@ [cons: =0, 1, 2, 3]
6592 [w, w, , D2] shll2\t%0.<Vwtype>, %1.<Vtype>, %I3
6593 [w, w, , DL] <su>shll2\t%0.<Vwtype>, %1.<Vtype>, %I3
6594 }
6595 [(set_attr "type" "neon_shift_imm_long")]
6596 )
6597
6598 (define_expand "aarch64_<sur>shll2_n<mode>"
6599 [(set (match_operand:<VWIDE> 0 "register_operand")
6600 (unspec:<VWIDE> [(match_operand:VQW 1 "register_operand")
6601 (match_operand:SI 2
6602 "aarch64_simd_shift_imm_bitsize_<ve_mode>")]
6603 VSHLL))]
6604 "TARGET_SIMD"
6605 {
6606 rtx shft = gen_const_vec_duplicate (<VWIDE>mode, operands[2]);
6607 rtx p = aarch64_simd_vect_par_cnst_half (<MODE>mode, <nunits>, true);
6608 emit_insn (gen_aarch64_<sur>shll2<mode> (operands[0], operands[1], p, shft));
6609 DONE;
6610 }
6611 )
6612
6613 ;; vrshr_n
6614
6615 (define_insn "aarch64_<sra_op>rshr_n<mode><vczle><vczbe>_insn"
6616 [(set (match_operand:VSDQ_I_DI 0 "register_operand" "=w")
6617 (truncate:VSDQ_I_DI
6618 (SHIFTRT:<V2XWIDE>
6619 (plus:<V2XWIDE>
6620 (<SHIFTEXTEND>:<V2XWIDE>
6621 (match_operand:VSDQ_I_DI 1 "register_operand" "w"))
6622 (match_operand:<V2XWIDE> 3 "aarch64_int_rnd_operand"))
6623 (match_operand:VSDQ_I_DI 2 "aarch64_simd_shift_imm_<vec_or_offset>_<Vel>"))))]
6624 "TARGET_SIMD
6625 && aarch64_const_vec_rnd_cst_p (operands[3], operands[2])"
6626 "<sra_op>rshr\t%<v>0<Vmtype>, %<v>1<Vmtype>, %2"
6627 [(set_attr "type" "neon_sat_shift_imm<q>")]
6628 )
6629
6630 (define_expand "aarch64_<sra_op>rshr_n<mode>"
6631 [(match_operand:VSDQ_I_DI 0 "register_operand")
6632 (SHIFTRT:VSDQ_I_DI
6633 (match_operand:VSDQ_I_DI 1 "register_operand")
6634 (match_operand:SI 2 "aarch64_simd_shift_imm_offset_<ve_mode>"))]
6635 "TARGET_SIMD"
6636 {
6637 /* Use this expander to create the rounding constant vector, which is
6638 1 << (shift - 1). Use wide_int here to ensure that the right TImode
6639 RTL is generated when handling the DImode expanders. */
6640 int prec = GET_MODE_UNIT_PRECISION (<V2XWIDE>mode);
6641 wide_int rnd_wi = wi::set_bit_in_zero (INTVAL (operands[2]) - 1, prec);
6642 rtx shft = gen_int_mode (INTVAL (operands[2]), DImode);
6643 rtx rnd = immed_wide_int_const (rnd_wi, GET_MODE_INNER (<V2XWIDE>mode));
6644 if (VECTOR_MODE_P (<MODE>mode))
6645 {
6646 shft = gen_const_vec_duplicate (<MODE>mode, shft);
6647 rnd = gen_const_vec_duplicate (<V2XWIDE>mode, rnd);
6648 }
6649
6650 emit_insn (gen_aarch64_<sra_op>rshr_n<mode>_insn (operands[0], operands[1],
6651 shft, rnd));
6652 DONE;
6653 }
6654 )
6655
6656 ;; v(r)sra_n
6657
6658 (define_insn "aarch64_<sur>sra_ndi"
6659 [(set (match_operand:DI 0 "register_operand" "=w")
6660 (unspec:DI [(match_operand:DI 1 "register_operand" "0")
6661 (match_operand:DI 2 "register_operand" "w")
6662 (match_operand:SI 3
6663 "aarch64_simd_shift_imm_offset_di" "i")]
6664 VSRA))]
6665 "TARGET_SIMD"
6666 "<sur>sra\\t%d0, %d2, %3"
6667 [(set_attr "type" "neon_shift_acc")]
6668 )
6669
6670 ;; vs<lr>i_n
6671
6672 (define_insn "aarch64_<sur>s<lr>i_n<mode>"
6673 [(set (match_operand:VSDQ_I_DI 0 "register_operand" "=w")
6674 (unspec:VSDQ_I_DI [(match_operand:VSDQ_I_DI 1 "register_operand" "0")
6675 (match_operand:VSDQ_I_DI 2 "register_operand" "w")
6676 (match_operand:SI 3
6677 "aarch64_simd_shift_imm_<offsetlr><ve_mode>" "i")]
6678 VSLRI))]
6679 "TARGET_SIMD"
6680 "s<lr>i\\t%<v>0<Vmtype>, %<v>2<Vmtype>, %3"
6681 [(set_attr "type" "neon_shift_imm<q>")]
6682 )
6683
6684 ;; vqshl(u)
6685
6686 (define_insn "aarch64_<sur>qshl<u>_n<mode>"
6687 [(set (match_operand:VSDQ_I 0 "register_operand" "=w")
6688 (unspec:VSDQ_I [(match_operand:VSDQ_I 1 "register_operand" "w")
6689 (match_operand:SI 2
6690 "aarch64_simd_shift_imm_<ve_mode>" "i")]
6691 VQSHL_N))]
6692 "TARGET_SIMD"
6693 "<sur>qshl<u>\\t%<v>0<Vmtype>, %<v>1<Vmtype>, %2"
6694 [(set_attr "type" "neon_sat_shift_imm<q>")]
6695 )
6696
6697
6698 ;; vq(r)shr(u)n_n
6699
6700 (define_insn "aarch64_<shrn_op>shrn_n<mode>"
6701 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
6702 (SAT_TRUNC:<VNARROWQ>
6703 (<TRUNC_SHIFT>:SD_HSDI
6704 (match_operand:SD_HSDI 1 "register_operand" "w")
6705 (match_operand:SI 2 "aarch64_simd_shift_imm_offset_<vn_mode>"))))]
6706 "TARGET_SIMD"
6707 "<shrn_op>shrn\t%<vn2>0<Vmntype>, %<v>1<Vmtype>, %2"
6708 [(set_attr "type" "neon_shift_imm_narrow_q")]
6709 )
6710
6711 (define_insn "*aarch64_<shrn_op><shrn_s>shrn_n<mode>_insn<vczle><vczbe>"
6712 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
6713 (ALL_TRUNC:<VNARROWQ>
6714 (SHIFTRT:VQN
6715 (match_operand:VQN 1 "register_operand" "w")
6716 (match_operand:VQN 2 "aarch64_simd_shift_imm_vec_<vn_mode>"))))]
6717 "TARGET_SIMD && AARCH64_VALID_SHRN_OP (<ALL_TRUNC:CODE>, <SHIFTRT:CODE>)"
6718 "<shrn_op>shrn\t%<vn2>0<Vmntype>, %<v>1<Vmtype>, %2"
6719 [(set_attr "type" "neon_shift_imm_narrow_q")]
6720 )
6721
6722 (define_expand "aarch64_<shrn_op>shrn_n<mode>"
6723 [(set (match_operand:<VNARROWQ> 0 "register_operand")
6724 (ALL_TRUNC:<VNARROWQ>
6725 (<TRUNC_SHIFT>:VQN
6726 (match_operand:VQN 1 "register_operand")
6727 (match_operand:SI 2 "aarch64_simd_shift_imm_offset_<vn_mode>"))))]
6728 "TARGET_SIMD"
6729 {
6730 operands[2] = aarch64_simd_gen_const_vector_dup (<MODE>mode,
6731 INTVAL (operands[2]));
6732 }
6733 )
6734
6735 (define_insn "*aarch64_<shrn_op>rshrn_n<mode>_insn<vczle><vczbe>"
6736 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
6737 (ALL_TRUNC:<VNARROWQ>
6738 (<TRUNC_SHIFT>:<V2XWIDE>
6739 (plus:<V2XWIDE>
6740 (<TRUNCEXTEND>:<V2XWIDE>
6741 (match_operand:VQN 1 "register_operand" "w"))
6742 (match_operand:<V2XWIDE> 3 "aarch64_int_rnd_operand"))
6743 (match_operand:VQN 2 "aarch64_simd_shift_imm_vec_<vn_mode>"))))]
6744 "TARGET_SIMD
6745 && aarch64_const_vec_rnd_cst_p (operands[3], operands[2])"
6746 "<shrn_op>rshrn\t%<vn2>0<Vmntype>, %<v>1<Vmtype>, %2"
6747 [(set_attr "type" "neon_shift_imm_narrow_q")]
6748 )
6749
6750 (define_insn "*aarch64_<shrn_op>rshrn_n<mode>_insn"
6751 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
6752 (SAT_TRUNC:<VNARROWQ>
6753 (<TRUNC_SHIFT>:<DWI>
6754 (plus:<DWI>
6755 (<TRUNCEXTEND>:<DWI>
6756 (match_operand:SD_HSDI 1 "register_operand" "w"))
6757 (match_operand:<DWI> 3 "aarch64_int_rnd_operand"))
6758 (match_operand:SI 2 "aarch64_simd_shift_imm_offset_<vn_mode>"))))]
6759 "TARGET_SIMD
6760 && aarch64_const_vec_rnd_cst_p (operands[3], operands[2])"
6761 "<shrn_op>rshrn\t%<vn2>0<Vmntype>, %<v>1<Vmtype>, %2"
6762 [(set_attr "type" "neon_shift_imm_narrow_q")]
6763 )
6764
6765 (define_expand "aarch64_<shrn_op>rshrn_n<mode>"
6766 [(set (match_operand:<VNARROWQ> 0 "register_operand")
6767 (SAT_TRUNC:<VNARROWQ>
6768 (<TRUNC_SHIFT>:<V2XWIDE>
6769 (plus:<V2XWIDE>
6770 (<TRUNCEXTEND>:<V2XWIDE>
6771 (match_operand:SD_HSDI 1 "register_operand"))
6772 (match_dup 3))
6773 (match_operand:SI 2 "aarch64_simd_shift_imm_offset_<vn_mode>"))))]
6774 "TARGET_SIMD"
6775 {
6776 /* Use this expander to create the rounding constant vector, which is
6777 1 << (shift - 1). Use wide_int here to ensure that the right TImode
6778 RTL is generated when handling the DImode expanders. */
6779 int prec = GET_MODE_UNIT_PRECISION (<V2XWIDE>mode);
6780 wide_int rnd_wi = wi::set_bit_in_zero (INTVAL (operands[2]) - 1, prec);
6781 operands[3] = immed_wide_int_const (rnd_wi, GET_MODE_INNER (<V2XWIDE>mode));
6782 }
6783 )
6784
6785 (define_expand "aarch64_<shrn_op>rshrn_n<mode>"
6786 [(set (match_operand:<VNARROWQ> 0 "register_operand")
6787 (ALL_TRUNC:<VNARROWQ>
6788 (<TRUNC_SHIFT>:<V2XWIDE>
6789 (plus:<V2XWIDE>
6790 (<TRUNCEXTEND>:<V2XWIDE>
6791 (match_operand:VQN 1 "register_operand"))
6792 (match_dup 3))
6793 (match_operand:SI 2 "aarch64_simd_shift_imm_offset_<vn_mode>"))))]
6794 "TARGET_SIMD"
6795 {
6796 if (<CODE> == TRUNCATE
6797 && INTVAL (operands[2]) == GET_MODE_UNIT_BITSIZE (<VNARROWQ>mode))
6798 {
6799 rtx tmp0 = aarch64_gen_shareable_zero (<MODE>mode);
6800 emit_insn (gen_aarch64_raddhn<mode> (operands[0], operands[1], tmp0));
6801 DONE;
6802 }
6803 /* Use this expander to create the rounding constant vector, which is
6804 1 << (shift - 1). Use wide_int here to ensure that the right TImode
6805 RTL is generated when handling the DImode expanders. */
6806 int prec = GET_MODE_UNIT_PRECISION (<V2XWIDE>mode);
6807 wide_int rnd_wi = wi::set_bit_in_zero (INTVAL (operands[2]) - 1, prec);
6808 operands[3] = immed_wide_int_const (rnd_wi, GET_MODE_INNER (<V2XWIDE>mode));
6809 operands[3] = gen_const_vec_duplicate (<V2XWIDE>mode, operands[3]);
6810 operands[2] = gen_const_vec_duplicate (<MODE>mode, operands[2]);
6811 }
6812 )
6813
6814 (define_insn "*aarch64_sqshrun_n<mode>_insn<vczle><vczbe>"
6815 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
6816 (truncate:<VNARROWQ>
6817 (smin:VQN
6818 (smax:VQN
6819 (ashiftrt:VQN
6820 (match_operand:VQN 1 "register_operand" "w")
6821 (match_operand:VQN 2 "aarch64_simd_shift_imm_vec_<vn_mode>"))
6822 (match_operand:VQN 3 "aarch64_simd_imm_zero"))
6823 (match_operand:VQN 4 "aarch64_simd_umax_half_mode"))))]
6824 "TARGET_SIMD"
6825 "sqshrun\t%<vn2>0<Vmntype>, %<v>1<Vmtype>, %2"
6826 [(set_attr "type" "neon_shift_imm_narrow_q")]
6827 )
6828
6829 (define_insn "aarch64_sqshrun_n<mode>_insn"
6830 [(set (match_operand:SD_HSDI 0 "register_operand" "=w")
6831 (smin:SD_HSDI
6832 (smax:SD_HSDI
6833 (ashiftrt:SD_HSDI
6834 (match_operand:SD_HSDI 1 "register_operand" "w")
6835 (match_operand:SI 2 "aarch64_simd_shift_imm_offset_<vn_mode>"))
6836 (const_int 0))
6837 (const_int <half_mask>)))]
6838 "TARGET_SIMD"
6839 "sqshrun\t%<vn2>0<Vmntype>, %<v>1<Vmtype>, %2"
6840 [(set_attr "type" "neon_shift_imm_narrow_q")]
6841 )
6842
6843 (define_expand "aarch64_sqshrun_n<mode>"
6844 [(match_operand:<VNARROWQ> 0 "register_operand")
6845 (match_operand:SD_HSDI 1 "register_operand")
6846 (match_operand:SI 2 "aarch64_simd_shift_imm_offset_<vn_mode>")]
6847 "TARGET_SIMD"
6848 {
6849 rtx dst = gen_reg_rtx (<MODE>mode);
6850 emit_insn (gen_aarch64_sqshrun_n<mode>_insn (dst, operands[1],
6851 operands[2]));
6852 emit_move_insn (operands[0], gen_lowpart (<VNARROWQ>mode, dst));
6853 DONE;
6854 }
6855 )
6856
6857 (define_expand "aarch64_sqshrun_n<mode>"
6858 [(set (match_operand:<VNARROWQ> 0 "register_operand")
6859 (truncate:<VNARROWQ>
6860 (smin:VQN
6861 (smax:VQN
6862 (ashiftrt:VQN
6863 (match_operand:VQN 1 "register_operand")
6864 (match_operand:SI 2 "aarch64_simd_shift_imm_offset_<vn_mode>"))
6865 (match_dup 3))
6866 (match_dup 4))))]
6867 "TARGET_SIMD"
6868 {
6869 operands[2] = aarch64_simd_gen_const_vector_dup (<MODE>mode,
6870 INTVAL (operands[2]));
6871 operands[3] = CONST0_RTX (<MODE>mode);
6872 operands[4]
6873 = aarch64_simd_gen_const_vector_dup (<MODE>mode,
6874 GET_MODE_MASK (GET_MODE_INNER (<VNARROWQ>mode)));
6875 }
6876 )
6877
6878 (define_insn "*aarch64_sqrshrun_n<mode>_insn<vczle><vczbe>"
6879 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
6880 (truncate:<VNARROWQ>
6881 (smin:<V2XWIDE>
6882 (smax:<V2XWIDE>
6883 (ashiftrt:<V2XWIDE>
6884 (plus:<V2XWIDE>
6885 (sign_extend:<V2XWIDE>
6886 (match_operand:VQN 1 "register_operand" "w"))
6887 (match_operand:<V2XWIDE> 3 "aarch64_int_rnd_operand"))
6888 (match_operand:VQN 2 "aarch64_simd_shift_imm_vec_<vn_mode>"))
6889 (match_operand:<V2XWIDE> 4 "aarch64_simd_imm_zero"))
6890 (match_operand:<V2XWIDE> 5 "aarch64_simd_umax_quarter_mode"))))]
6891 "TARGET_SIMD
6892 && aarch64_const_vec_rnd_cst_p (operands[3], operands[2])"
6893 "sqrshrun\t%<vn2>0<Vmntype>, %<v>1<Vmtype>, %2"
6894 [(set_attr "type" "neon_shift_imm_narrow_q")]
6895 )
6896
6897 (define_insn "aarch64_sqrshrun_n<mode>_insn"
6898 [(set (match_operand:<DWI> 0 "register_operand" "=w")
6899 (smin:<DWI>
6900 (smax:<DWI>
6901 (ashiftrt:<DWI>
6902 (plus:<DWI>
6903 (sign_extend:<DWI>
6904 (match_operand:SD_HSDI 1 "register_operand" "w"))
6905 (match_operand:<DWI> 3 "aarch64_int_rnd_operand"))
6906 (match_operand:SI 2 "aarch64_simd_shift_imm_offset_<vn_mode>"))
6907 (const_int 0))
6908 (const_int <half_mask>)))]
6909 "TARGET_SIMD
6910 && aarch64_const_vec_rnd_cst_p (operands[3], operands[2])"
6911 "sqrshrun\t%<vn2>0<Vmntype>, %<v>1<Vmtype>, %2"
6912 [(set_attr "type" "neon_shift_imm_narrow_q")]
6913 )
6914
6915 (define_expand "aarch64_sqrshrun_n<mode>"
6916 [(match_operand:<VNARROWQ> 0 "register_operand")
6917 (match_operand:SD_HSDI 1 "register_operand")
6918 (match_operand:SI 2 "aarch64_simd_shift_imm_offset_<vn_mode>")]
6919 "TARGET_SIMD"
6920 {
6921 int prec = GET_MODE_UNIT_PRECISION (<DWI>mode);
6922 wide_int rnd_wi = wi::set_bit_in_zero (INTVAL (operands[2]) - 1, prec);
6923 rtx rnd = immed_wide_int_const (rnd_wi, <DWI>mode);
6924 rtx dst = gen_reg_rtx (<DWI>mode);
6925 emit_insn (gen_aarch64_sqrshrun_n<mode>_insn (dst, operands[1], operands[2], rnd));
6926 emit_move_insn (operands[0], gen_lowpart (<VNARROWQ>mode, dst));
6927 DONE;
6928 }
6929 )
6930
6931 (define_expand "aarch64_sqrshrun_n<mode>"
6932 [(set (match_operand:<VNARROWQ> 0 "register_operand")
6933 (truncate:<VNARROWQ>
6934 (smin:<V2XWIDE>
6935 (smax:<V2XWIDE>
6936 (ashiftrt:<V2XWIDE>
6937 (plus:<V2XWIDE>
6938 (sign_extend:<V2XWIDE>
6939 (match_operand:VQN 1 "register_operand"))
6940 (match_dup 3))
6941 (match_operand:SI 2 "aarch64_simd_shift_imm_offset_<vn_mode>"))
6942 (match_dup 4))
6943 (match_dup 5))))]
6944 "TARGET_SIMD"
6945 {
6946 int prec = GET_MODE_UNIT_PRECISION (<V2XWIDE>mode);
6947 wide_int rnd_wi = wi::set_bit_in_zero (INTVAL (operands[2]) - 1, prec);
6948 operands[3] = immed_wide_int_const (rnd_wi, GET_MODE_INNER (<V2XWIDE>mode));
6949 operands[3] = gen_const_vec_duplicate (<V2XWIDE>mode, operands[3]);
6950 operands[2] = gen_const_vec_duplicate (<MODE>mode, operands[2]);
6951 operands[4] = CONST0_RTX (<V2XWIDE>mode);
6952 operands[5]
6953 = gen_int_mode (GET_MODE_MASK (GET_MODE_INNER (<VNARROWQ>mode)), DImode);
6954 operands[5] = gen_const_vec_duplicate (<V2XWIDE>mode, operands[5]);
6955 }
6956 )
6957
6958 (define_insn "aarch64_<shrn_op><sra_op>shrn2_n<mode>_insn_le"
6959 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
6960 (vec_concat:<VNARROWQ2>
6961 (match_operand:<VNARROWQ> 1 "register_operand" "0")
6962 (ALL_TRUNC:<VNARROWQ>
6963 (SHIFTRT:VQN
6964 (match_operand:VQN 2 "register_operand" "w")
6965 (match_operand:VQN 3 "aarch64_simd_shift_imm_vec_<vn_mode>")))))]
6966 "TARGET_SIMD && !BYTES_BIG_ENDIAN
6967 && AARCH64_VALID_SHRN_OP (<ALL_TRUNC:CODE>, <SHIFTRT:CODE>)"
6968 "<shrn_op>shrn2\t%<vn2>0.<V2ntype>, %<v>2.<Vtype>, %3"
6969 [(set_attr "type" "neon_shift_imm_narrow_q")]
6970 )
6971
6972 (define_insn "aarch64_<shrn_op><sra_op>shrn2_n<mode>_insn_be"
6973 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
6974 (vec_concat:<VNARROWQ2>
6975 (ALL_TRUNC:<VNARROWQ>
6976 (SHIFTRT:VQN
6977 (match_operand:VQN 2 "register_operand" "w")
6978 (match_operand:VQN 3 "aarch64_simd_shift_imm_vec_<vn_mode>")))
6979 (match_operand:<VNARROWQ> 1 "register_operand" "0")))]
6980 "TARGET_SIMD && BYTES_BIG_ENDIAN
6981 && AARCH64_VALID_SHRN_OP (<ALL_TRUNC:CODE>, <SHIFTRT:CODE>)"
6982 "<shrn_op>shrn2\t%<vn2>0.<V2ntype>, %<v>2.<Vtype>, %3"
6983 [(set_attr "type" "neon_shift_imm_narrow_q")]
6984 )
6985
6986 (define_expand "aarch64_<shrn_op><sra_op>shrn2_n<mode>"
6987 [(match_operand:<VNARROWQ2> 0 "register_operand")
6988 (match_operand:<VNARROWQ> 1 "register_operand")
6989 (ALL_TRUNC:<VNARROWQ>
6990 (SHIFTRT:VQN (match_operand:VQN 2 "register_operand")))
6991 (match_operand:SI 3 "aarch64_simd_shift_imm_offset_<vn_mode>")]
6992 "TARGET_SIMD && AARCH64_VALID_SHRN_OP (<ALL_TRUNC:CODE>, <SHIFTRT:CODE>)"
6993 {
6994 operands[3] = aarch64_simd_gen_const_vector_dup (<MODE>mode,
6995 INTVAL (operands[3]));
6996
6997 if (BYTES_BIG_ENDIAN)
6998 emit_insn (gen_aarch64_<shrn_op><sra_op>shrn2_n<mode>_insn_be (
6999 operands[0], operands[1], operands[2], operands[3]));
7000 else
7001 emit_insn (gen_aarch64_<shrn_op><sra_op>shrn2_n<mode>_insn_le (
7002 operands[0], operands[1], operands[2], operands[3]));
7003 DONE;
7004 }
7005 )
7006
7007 (define_insn "aarch64_<shrn_op>rshrn2_n<mode>_insn_le"
7008 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
7009 (vec_concat:<VNARROWQ2>
7010 (match_operand:<VNARROWQ> 1 "register_operand" "0")
7011 (ALL_TRUNC:<VNARROWQ>
7012 (<TRUNC_SHIFT>:<V2XWIDE>
7013 (plus:<V2XWIDE>
7014 (<TRUNCEXTEND>:<V2XWIDE>
7015 (match_operand:VQN 2 "register_operand" "w"))
7016 (match_operand:<V2XWIDE> 4 "aarch64_int_rnd_operand"))
7017 (match_operand:VQN 3 "aarch64_simd_shift_imm_vec_<vn_mode>")))))]
7018 "TARGET_SIMD && !BYTES_BIG_ENDIAN
7019 && aarch64_const_vec_rnd_cst_p (operands[4], operands[3])"
7020 "<shrn_op>rshrn2\t%<vn2>0.<V2ntype>, %<v>2.<Vtype>, %3"
7021 [(set_attr "type" "neon_shift_imm_narrow_q")]
7022 )
7023
7024 (define_insn "aarch64_<shrn_op>rshrn2_n<mode>_insn_be"
7025 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
7026 (vec_concat:<VNARROWQ2>
7027 (ALL_TRUNC:<VNARROWQ>
7028 (<TRUNC_SHIFT>:<V2XWIDE>
7029 (plus:<V2XWIDE>
7030 (<TRUNCEXTEND>:<V2XWIDE>
7031 (match_operand:VQN 2 "register_operand" "w"))
7032 (match_operand:<V2XWIDE> 4 "aarch64_int_rnd_operand"))
7033 (match_operand:VQN 3 "aarch64_simd_shift_imm_vec_<vn_mode>")))
7034 (match_operand:<VNARROWQ> 1 "register_operand" "0")))]
7035 "TARGET_SIMD && BYTES_BIG_ENDIAN
7036 && aarch64_const_vec_rnd_cst_p (operands[4], operands[3])"
7037 "<shrn_op>rshrn2\t%<vn2>0.<V2ntype>, %<v>2.<Vtype>, %3"
7038 [(set_attr "type" "neon_shift_imm_narrow_q")]
7039 )
7040
7041 (define_expand "aarch64_<shrn_op>rshrn2_n<mode>"
7042 [(match_operand:<VNARROWQ2> 0 "register_operand")
7043 (match_operand:<VNARROWQ> 1 "register_operand")
7044 (ALL_TRUNC:<VNARROWQ> (match_operand:VQN 2 "register_operand"))
7045 (match_operand:SI 3 "aarch64_simd_shift_imm_offset_<vn_mode>")]
7046 "TARGET_SIMD"
7047 {
7048 if (<CODE> == TRUNCATE
7049 && INTVAL (operands[3]) == GET_MODE_UNIT_BITSIZE (<VNARROWQ>mode))
7050 {
7051 rtx tmp = aarch64_gen_shareable_zero (<MODE>mode);
7052 emit_insn (gen_aarch64_raddhn2<mode> (operands[0], operands[1],
7053 operands[2], tmp));
7054 DONE;
7055 }
7056 /* Use this expander to create the rounding constant vector, which is
7057 1 << (shift - 1). Use wide_int here to ensure that the right TImode
7058 RTL is generated when handling the DImode expanders. */
7059 int prec = GET_MODE_UNIT_PRECISION (<V2XWIDE>mode);
7060 wide_int rnd_wi = wi::set_bit_in_zero (INTVAL (operands[3]) - 1, prec);
7061 rtx rnd = immed_wide_int_const (rnd_wi, GET_MODE_INNER (<V2XWIDE>mode));
7062 rnd = gen_const_vec_duplicate (<V2XWIDE>mode, rnd);
7063 operands[3] = gen_const_vec_duplicate (<MODE>mode, operands[3]);
7064 if (BYTES_BIG_ENDIAN)
7065 emit_insn (gen_aarch64_<shrn_op>rshrn2_n<mode>_insn_be (operands[0],
7066 operands[1],
7067 operands[2],
7068 operands[3],
7069 rnd));
7070 else
7071 emit_insn (gen_aarch64_<shrn_op>rshrn2_n<mode>_insn_le (operands[0],
7072 operands[1],
7073 operands[2],
7074 operands[3],
7075 rnd));
7076 DONE;
7077 }
7078 )
7079
7080 (define_insn "aarch64_sqshrun2_n<mode>_insn_le"
7081 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
7082 (vec_concat:<VNARROWQ2>
7083 (match_operand:<VNARROWQ> 1 "register_operand" "0")
7084 (truncate:<VNARROWQ>
7085 (smin:VQN
7086 (smax:VQN
7087 (ashiftrt:VQN
7088 (match_operand:VQN 2 "register_operand" "w")
7089 (match_operand:VQN 3 "aarch64_simd_shift_imm_vec_<vn_mode>"))
7090 (match_operand:VQN 4 "aarch64_simd_imm_zero"))
7091 (match_operand:VQN 5 "aarch64_simd_umax_half_mode")))))]
7092 "TARGET_SIMD && !BYTES_BIG_ENDIAN"
7093 "sqshrun2\t%<vn2>0.<V2ntype>, %<v>2.<Vtype>, %3"
7094 [(set_attr "type" "neon_shift_imm_narrow_q")]
7095 )
7096
7097 (define_insn "aarch64_sqshrun2_n<mode>_insn_be"
7098 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
7099 (vec_concat:<VNARROWQ2>
7100 (truncate:<VNARROWQ>
7101 (smin:VQN
7102 (smax:VQN
7103 (ashiftrt:VQN
7104 (match_operand:VQN 2 "register_operand" "w")
7105 (match_operand:VQN 3 "aarch64_simd_shift_imm_vec_<vn_mode>"))
7106 (match_operand:VQN 4 "aarch64_simd_imm_zero"))
7107 (match_operand:VQN 5 "aarch64_simd_umax_half_mode")))
7108 (match_operand:<VNARROWQ> 1 "register_operand" "0")))]
7109 "TARGET_SIMD && BYTES_BIG_ENDIAN"
7110 "sqshrun2\t%<vn2>0.<V2ntype>, %<v>2.<Vtype>, %3"
7111 [(set_attr "type" "neon_shift_imm_narrow_q")]
7112 )
7113
7114 (define_expand "aarch64_sqshrun2_n<mode>"
7115 [(match_operand:<VNARROWQ2> 0 "register_operand")
7116 (match_operand:<VNARROWQ> 1 "register_operand")
7117 (match_operand:VQN 2 "register_operand")
7118 (match_operand:SI 3 "aarch64_simd_shift_imm_offset_<vn_mode>")]
7119 "TARGET_SIMD"
7120 {
7121 operands[3] = aarch64_simd_gen_const_vector_dup (<MODE>mode,
7122 INTVAL (operands[3]));
7123 rtx zeros = CONST0_RTX (<MODE>mode);
7124 rtx half_umax
7125 = aarch64_simd_gen_const_vector_dup (<MODE>mode,
7126 GET_MODE_MASK (GET_MODE_INNER (<VNARROWQ>mode)));
7127 if (BYTES_BIG_ENDIAN)
7128 emit_insn (gen_aarch64_sqshrun2_n<mode>_insn_be (operands[0],
7129 operands[1], operands[2], operands[3],
7130 zeros, half_umax));
7131 else
7132 emit_insn (gen_aarch64_sqshrun2_n<mode>_insn_le (operands[0],
7133 operands[1], operands[2], operands[3],
7134 zeros, half_umax));
7135 DONE;
7136 }
7137 )
7138
7139 (define_insn "aarch64_sqrshrun2_n<mode>_insn_le"
7140 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
7141 (vec_concat:<VNARROWQ2>
7142 (match_operand:<VNARROWQ> 1 "register_operand" "0")
7143 (truncate:<VNARROWQ>
7144 (smin:<V2XWIDE>
7145 (smax:<V2XWIDE>
7146 (ashiftrt:<V2XWIDE>
7147 (plus:<V2XWIDE>
7148 (sign_extend:<V2XWIDE>
7149 (match_operand:VQN 2 "register_operand" "w"))
7150 (match_operand:<V2XWIDE> 4 "aarch64_int_rnd_operand"))
7151 (match_operand:VQN 3 "aarch64_simd_shift_imm_vec_<vn_mode>"))
7152 (match_operand:<V2XWIDE> 5 "aarch64_simd_imm_zero"))
7153 (match_operand:<V2XWIDE> 6 "aarch64_simd_umax_quarter_mode")))))]
7154 "TARGET_SIMD && !BYTES_BIG_ENDIAN
7155 && aarch64_const_vec_rnd_cst_p (operands[4], operands[3])"
7156 "sqrshrun2\t%<vn2>0.<V2ntype>, %<v>2.<Vtype>, %3"
7157 [(set_attr "type" "neon_shift_imm_narrow_q")]
7158 )
7159
7160 (define_insn "aarch64_sqrshrun2_n<mode>_insn_be"
7161 [(set (match_operand:<VNARROWQ2> 0 "register_operand" "=w")
7162 (vec_concat:<VNARROWQ2>
7163 (truncate:<VNARROWQ>
7164 (smin:<V2XWIDE>
7165 (smax:<V2XWIDE>
7166 (ashiftrt:<V2XWIDE>
7167 (plus:<V2XWIDE>
7168 (sign_extend:<V2XWIDE>
7169 (match_operand:VQN 2 "register_operand" "w"))
7170 (match_operand:<V2XWIDE> 4 "aarch64_int_rnd_operand"))
7171 (match_operand:VQN 3 "aarch64_simd_shift_imm_vec_<vn_mode>"))
7172 (match_operand:<V2XWIDE> 5 "aarch64_simd_imm_zero"))
7173 (match_operand:<V2XWIDE> 6 "aarch64_simd_umax_quarter_mode")))
7174 (match_operand:<VNARROWQ> 1 "register_operand" "0")))]
7175 "TARGET_SIMD && BYTES_BIG_ENDIAN
7176 && aarch64_const_vec_rnd_cst_p (operands[4], operands[3])"
7177 "sqrshrun2\t%<vn2>0.<V2ntype>, %<v>2.<Vtype>, %3"
7178 [(set_attr "type" "neon_shift_imm_narrow_q")]
7179 )
7180
7181 (define_expand "aarch64_sqrshrun2_n<mode>"
7182 [(match_operand:<VNARROWQ2> 0 "register_operand")
7183 (match_operand:<VNARROWQ> 1 "register_operand")
7184 (match_operand:VQN 2 "register_operand")
7185 (match_operand:SI 3 "aarch64_simd_shift_imm_offset_<vn_mode>")]
7186 "TARGET_SIMD"
7187 {
7188 int prec = GET_MODE_UNIT_PRECISION (<V2XWIDE>mode);
7189 wide_int rnd_wi = wi::set_bit_in_zero (INTVAL (operands[3]) - 1, prec);
7190 rtx rnd = immed_wide_int_const (rnd_wi, GET_MODE_INNER (<V2XWIDE>mode));
7191 rnd = gen_const_vec_duplicate (<V2XWIDE>mode, rnd);
7192 rtx zero = CONST0_RTX (<V2XWIDE>mode);
7193 rtx half_umax
7194 = aarch64_simd_gen_const_vector_dup (<V2XWIDE>mode,
7195 GET_MODE_MASK (GET_MODE_INNER (<VNARROWQ>mode)));
7196 operands[3] = gen_const_vec_duplicate (<MODE>mode, operands[3]);
7197 if (BYTES_BIG_ENDIAN)
7198 emit_insn (gen_aarch64_sqrshrun2_n<mode>_insn_be (operands[0],
7199 operands[1], operands[2], operands[3], rnd,
7200 zero, half_umax));
7201 else
7202 emit_insn (gen_aarch64_sqrshrun2_n<mode>_insn_le (operands[0],
7203 operands[1], operands[2], operands[3], rnd,
7204 zero, half_umax));
7205 DONE;
7206 }
7207 )
7208
7209 ;; cm(eq|ge|gt|lt|le)
7210 ;; Note, we have constraints for Dz and Z as different expanders
7211 ;; have different ideas of what should be passed to this pattern.
7212
7213 (define_insn "@aarch64_cm<optab><mode><vczle><vczbe>"
7214 [(set (match_operand:<V_INT_EQUIV> 0 "register_operand")
7215 (neg:<V_INT_EQUIV>
7216 (COMPARISONS:<V_INT_EQUIV>
7217 (match_operand:VDQ_I 1 "register_operand")
7218 (match_operand:VDQ_I 2 "aarch64_simd_reg_or_zero")
7219 )))]
7220 "TARGET_SIMD"
7221 {@ [ cons: =0 , 1 , 2 ; attrs: type ]
7222 [ w , w , w ; neon_compare<q> ] cm<n_optab>\t%<v>0<Vmtype>, %<v><cmp_1><Vmtype>, %<v><cmp_2><Vmtype>
7223 [ w , w , ZDz ; neon_compare_zero<q> ] cm<optab>\t%<v>0<Vmtype>, %<v>1<Vmtype>, #0
7224 }
7225 )
7226
7227 (define_insn_and_split "aarch64_cm<optab>di"
7228 [(set (match_operand:DI 0 "register_operand" "=w,w,r")
7229 (neg:DI
7230 (COMPARISONS:DI
7231 (match_operand:DI 1 "register_operand" "w,w,r")
7232 (match_operand:DI 2 "aarch64_simd_reg_or_zero" "w,ZDz,r")
7233 )))
7234 (clobber (reg:CC CC_REGNUM))]
7235 "TARGET_SIMD"
7236 "#"
7237 "&& reload_completed"
7238 [(set (match_operand:DI 0 "register_operand")
7239 (neg:DI
7240 (COMPARISONS:DI
7241 (match_operand:DI 1 "register_operand")
7242 (match_operand:DI 2 "aarch64_simd_reg_or_zero")
7243 )))]
7244 {
7245 /* If we are in the general purpose register file,
7246 we split to a sequence of comparison and store. */
7247 if (GP_REGNUM_P (REGNO (operands[0]))
7248 && GP_REGNUM_P (REGNO (operands[1])))
7249 {
7250 machine_mode mode = SELECT_CC_MODE (<CMP>, operands[1], operands[2]);
7251 rtx cc_reg = aarch64_gen_compare_reg (<CMP>, operands[1], operands[2]);
7252 rtx comparison = gen_rtx_<CMP> (mode, operands[1], operands[2]);
7253 emit_insn (gen_cstoredi_neg (operands[0], comparison, cc_reg));
7254 DONE;
7255 }
7256 /* Otherwise, we expand to a similar pattern which does not
7257 clobber CC_REGNUM. */
7258 }
7259 [(set_attr "type" "neon_compare, neon_compare_zero, multiple")]
7260 )
7261
7262 (define_insn "*aarch64_cm<optab>di"
7263 [(set (match_operand:DI 0 "register_operand")
7264 (neg:DI
7265 (COMPARISONS:DI
7266 (match_operand:DI 1 "register_operand")
7267 (match_operand:DI 2 "aarch64_simd_reg_or_zero")
7268 )))]
7269 "TARGET_SIMD && reload_completed"
7270 {@ [ cons: =0 , 1 , 2 ; attrs: type ]
7271 [ w , w , w ; neon_compare ] cm<n_optab>\t%d0, %d<cmp_1>, %d<cmp_2>
7272 [ w , w , ZDz ; neon_compare_zero ] cm<optab>\t%d0, %d1, #0
7273 }
7274 )
7275
7276 ;; cm(hs|hi)
7277
7278 (define_insn "@aarch64_cm<optab><mode><vczle><vczbe>"
7279 [(set (match_operand:<V_INT_EQUIV> 0 "register_operand" "=w")
7280 (neg:<V_INT_EQUIV>
7281 (UCOMPARISONS:<V_INT_EQUIV>
7282 (match_operand:VDQ_I 1 "register_operand" "w")
7283 (match_operand:VDQ_I 2 "register_operand" "w")
7284 )))]
7285 "TARGET_SIMD"
7286 "cm<n_optab>\t%<v>0<Vmtype>, %<v><cmp_1><Vmtype>, %<v><cmp_2><Vmtype>"
7287 [(set_attr "type" "neon_compare<q>")]
7288 )
7289
7290 (define_insn_and_split "aarch64_cm<optab>di"
7291 [(set (match_operand:DI 0 "register_operand" "=w,r")
7292 (neg:DI
7293 (UCOMPARISONS:DI
7294 (match_operand:DI 1 "register_operand" "w,r")
7295 (match_operand:DI 2 "aarch64_simd_reg_or_zero" "w,r")
7296 )))
7297 (clobber (reg:CC CC_REGNUM))]
7298 "TARGET_SIMD"
7299 "#"
7300 "&& reload_completed"
7301 [(set (match_operand:DI 0 "register_operand")
7302 (neg:DI
7303 (UCOMPARISONS:DI
7304 (match_operand:DI 1 "register_operand")
7305 (match_operand:DI 2 "aarch64_simd_reg_or_zero")
7306 )))]
7307 {
7308 /* If we are in the general purpose register file,
7309 we split to a sequence of comparison and store. */
7310 if (GP_REGNUM_P (REGNO (operands[0]))
7311 && GP_REGNUM_P (REGNO (operands[1])))
7312 {
7313 machine_mode mode = CCmode;
7314 rtx cc_reg = aarch64_gen_compare_reg (<CMP>, operands[1], operands[2]);
7315 rtx comparison = gen_rtx_<CMP> (mode, operands[1], operands[2]);
7316 emit_insn (gen_cstoredi_neg (operands[0], comparison, cc_reg));
7317 DONE;
7318 }
7319 /* Otherwise, we expand to a similar pattern which does not
7320 clobber CC_REGNUM. */
7321 }
7322 [(set_attr "type" "neon_compare,multiple")]
7323 )
7324
7325 (define_insn "*aarch64_cm<optab>di"
7326 [(set (match_operand:DI 0 "register_operand" "=w")
7327 (neg:DI
7328 (UCOMPARISONS:DI
7329 (match_operand:DI 1 "register_operand" "w")
7330 (match_operand:DI 2 "aarch64_simd_reg_or_zero" "w")
7331 )))]
7332 "TARGET_SIMD && reload_completed"
7333 "cm<n_optab>\t%d0, %d<cmp_1>, %d<cmp_2>"
7334 [(set_attr "type" "neon_compare")]
7335 )
7336
7337 ;; cmtst
7338
7339 ;; Although neg (ne (and x y) 0) is the natural way of expressing a cmtst,
7340 ;; we don't have any insns using ne, and aarch64_vcond outputs
7341 ;; not (neg (eq (and x y) 0))
7342 ;; which is rewritten by simplify_rtx as
7343 ;; plus (eq (and x y) 0) -1.
7344
7345 (define_insn "aarch64_cmtst<mode><vczle><vczbe>"
7346 [(set (match_operand:<V_INT_EQUIV> 0 "register_operand" "=w")
7347 (plus:<V_INT_EQUIV>
7348 (eq:<V_INT_EQUIV>
7349 (and:VDQ_I
7350 (match_operand:VDQ_I 1 "register_operand" "w")
7351 (match_operand:VDQ_I 2 "register_operand" "w"))
7352 (match_operand:VDQ_I 3 "aarch64_simd_imm_zero"))
7353 (match_operand:<V_INT_EQUIV> 4 "aarch64_simd_imm_minus_one")))
7354 ]
7355 "TARGET_SIMD"
7356 "cmtst\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>2<Vmtype>"
7357 [(set_attr "type" "neon_tst<q>")]
7358 )
7359
7360 ;; One can also get a cmtsts by having to combine a
7361 ;; not (neq (eq x 0)) in which case you rewrite it to
7362 ;; a comparison against itself
7363
7364 (define_insn "*aarch64_cmtst_same_<mode><vczle><vczbe>"
7365 [(set (match_operand:<V_INT_EQUIV> 0 "register_operand" "=w")
7366 (plus:<V_INT_EQUIV>
7367 (eq:<V_INT_EQUIV>
7368 (match_operand:VDQ_I 1 "register_operand" "w")
7369 (match_operand:VDQ_I 2 "aarch64_simd_imm_zero"))
7370 (match_operand:<V_INT_EQUIV> 3 "aarch64_simd_imm_minus_one")))
7371 ]
7372 "TARGET_SIMD"
7373 "cmtst\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>1<Vmtype>"
7374 [(set_attr "type" "neon_tst<q>")]
7375 )
7376
7377 (define_insn_and_split "aarch64_cmtstdi"
7378 [(set (match_operand:DI 0 "register_operand" "=w,r")
7379 (neg:DI
7380 (ne:DI
7381 (and:DI
7382 (match_operand:DI 1 "register_operand" "w,r")
7383 (match_operand:DI 2 "register_operand" "w,r"))
7384 (const_int 0))))
7385 (clobber (reg:CC CC_REGNUM))]
7386 "TARGET_SIMD"
7387 "#"
7388 "&& reload_completed"
7389 [(set (match_operand:DI 0 "register_operand")
7390 (neg:DI
7391 (ne:DI
7392 (and:DI
7393 (match_operand:DI 1 "register_operand")
7394 (match_operand:DI 2 "register_operand"))
7395 (const_int 0))))]
7396 {
7397 /* If we are in the general purpose register file,
7398 we split to a sequence of comparison and store. */
7399 if (GP_REGNUM_P (REGNO (operands[0]))
7400 && GP_REGNUM_P (REGNO (operands[1])))
7401 {
7402 rtx and_tree = gen_rtx_AND (DImode, operands[1], operands[2]);
7403 machine_mode mode = SELECT_CC_MODE (NE, and_tree, const0_rtx);
7404 rtx cc_reg = aarch64_gen_compare_reg (NE, and_tree, const0_rtx);
7405 rtx comparison = gen_rtx_NE (mode, and_tree, const0_rtx);
7406 emit_insn (gen_cstoredi_neg (operands[0], comparison, cc_reg));
7407 DONE;
7408 }
7409 /* Otherwise, we expand to a similar pattern which does not
7410 clobber CC_REGNUM. */
7411 }
7412 [(set_attr "type" "neon_tst,multiple")]
7413 )
7414
7415 (define_insn "*aarch64_cmtstdi<vczle><vczbe>"
7416 [(set (match_operand:DI 0 "register_operand" "=w")
7417 (neg:DI
7418 (ne:DI
7419 (and:DI
7420 (match_operand:DI 1 "register_operand" "w")
7421 (match_operand:DI 2 "register_operand" "w"))
7422 (const_int 0))))]
7423 "TARGET_SIMD"
7424 "cmtst\t%d0, %d1, %d2"
7425 [(set_attr "type" "neon_tst")]
7426 )
7427
7428 ;; fcm(eq|ge|gt|le|lt)
7429
7430 (define_insn "@aarch64_cm<optab><mode><vczle><vczbe>"
7431 [(set (match_operand:<V_INT_EQUIV> 0 "register_operand")
7432 (neg:<V_INT_EQUIV>
7433 (COMPARISONS:<V_INT_EQUIV>
7434 (match_operand:VHSDF_HSDF 1 "register_operand")
7435 (match_operand:VHSDF_HSDF 2 "aarch64_simd_reg_or_zero")
7436 )))]
7437 "TARGET_SIMD"
7438 {@ [ cons: =0 , 1 , 2 ]
7439 [ w , w , w ] fcm<n_optab>\t%<v>0<Vmtype>, %<v><cmp_1><Vmtype>, %<v><cmp_2><Vmtype>
7440 [ w , w , YDz ] fcm<optab>\t%<v>0<Vmtype>, %<v>1<Vmtype>, 0
7441 }
7442 [(set_attr "type" "neon_fp_compare_<stype><q>")]
7443 )
7444
7445 ;; fac(ge|gt)
7446 ;; Note we can also handle what would be fac(le|lt) by
7447 ;; generating fac(ge|gt).
7448
7449 (define_insn "aarch64_fac<optab><mode><vczle><vczbe>"
7450 [(set (match_operand:<V_INT_EQUIV> 0 "register_operand" "=w")
7451 (neg:<V_INT_EQUIV>
7452 (FAC_COMPARISONS:<V_INT_EQUIV>
7453 (abs:VHSDF_HSDF
7454 (match_operand:VHSDF_HSDF 1 "register_operand" "w"))
7455 (abs:VHSDF_HSDF
7456 (match_operand:VHSDF_HSDF 2 "register_operand" "w"))
7457 )))]
7458 "TARGET_SIMD"
7459 "fac<n_optab>\t%<v>0<Vmtype>, %<v><cmp_1><Vmtype>, %<v><cmp_2><Vmtype>"
7460 [(set_attr "type" "neon_fp_compare_<stype><q>")]
7461 )
7462
7463 ;; addp
7464
7465 ;; ADDP with two registers semantically concatenates them and performs
7466 ;; a pairwise addition on the result. For 128-bit input modes represent this
7467 ;; as a concatentation of the pairwise addition results of the two input
7468 ;; registers. This allow us to avoid using intermediate 256-bit modes.
7469 (define_insn "aarch64_addp<mode>_insn"
7470 [(set (match_operand:VQ_I 0 "register_operand" "=w")
7471 (vec_concat:VQ_I
7472 (plus:<VHALF>
7473 (vec_select:<VHALF>
7474 (match_operand:VQ_I 1 "register_operand" "w")
7475 (match_operand:VQ_I 3 "vect_par_cnst_even_or_odd_half"))
7476 (vec_select:<VHALF>
7477 (match_dup 1)
7478 (match_operand:VQ_I 4 "vect_par_cnst_even_or_odd_half")))
7479 (plus:<VHALF>
7480 (vec_select:<VHALF>
7481 (match_operand:VQ_I 2 "register_operand" "w")
7482 (match_dup 3))
7483 (vec_select:<VHALF>
7484 (match_dup 2)
7485 (match_dup 4)))))]
7486 "TARGET_SIMD && !rtx_equal_p (operands[3], operands[4])"
7487 "addp\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>2<Vmtype>"
7488 [(set_attr "type" "neon_reduc_add<q>")]
7489 )
7490
7491 ;; For 64-bit input modes an ADDP is represented as a concatentation
7492 ;; of the input registers into an 128-bit register which is then fed
7493 ;; into a pairwise add. That way we avoid having to create intermediate
7494 ;; 32-bit vector modes.
7495 (define_insn "aarch64_addp<mode><vczle><vczbe>_insn"
7496 [(set (match_operand:VD_BHSI 0 "register_operand" "=w")
7497 (plus:VD_BHSI
7498 (vec_select:VD_BHSI
7499 (vec_concat:<VDBL>
7500 (match_operand:VD_BHSI 1 "register_operand" "w")
7501 (match_operand:VD_BHSI 2 "register_operand" "w"))
7502 (match_operand:<VDBL> 3 "vect_par_cnst_even_or_odd_half"))
7503 (vec_select:VD_BHSI
7504 (vec_concat:<VDBL>
7505 (match_dup 1)
7506 (match_dup 2))
7507 (match_operand:<VDBL> 4 "vect_par_cnst_even_or_odd_half"))))]
7508 "TARGET_SIMD && !rtx_equal_p (operands[3], operands[4])"
7509 "addp\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>2<Vmtype>"
7510 [(set_attr "type" "neon_reduc_add<q>")]
7511 )
7512
7513 ;; A common usecase of 64-bit ADDP is to have both operands come from the same
7514 ;; 128-bit vector and produce the pairwise addition results in the lower half.
7515 ;; Split into the 128-bit ADDP form and extract the low half.
7516 (define_insn_and_split "*aarch64_addp_same_reg<mode>"
7517 [(set (match_operand:<VHALF> 0 "register_operand" "=w")
7518 (plus:<VHALF>
7519 (vec_select:<VHALF>
7520 (match_operand:VQ_I 1 "register_operand" "w")
7521 (match_operand:VQ_I 2 "vect_par_cnst_even_or_odd_half"))
7522 (vec_select:<VHALF>
7523 (match_dup 1)
7524 (match_operand:VQ_I 3 "vect_par_cnst_even_or_odd_half"))))]
7525 "TARGET_SIMD && !rtx_equal_p (operands[2], operands[3])"
7526 "#"
7527 "&& 1"
7528 [(const_int 0)]
7529 {
7530 rtx scratch;
7531 if (can_create_pseudo_p ())
7532 scratch = gen_reg_rtx (<MODE>mode);
7533 else
7534 scratch = lowpart_subreg (<MODE>mode, operands[0], <VHALF>mode);
7535
7536 emit_insn (gen_aarch64_addp<mode>_insn (scratch, operands[1], operands[1],
7537 operands[2], operands[3]));
7538 emit_move_insn (operands[0], gen_lowpart (<VHALF>mode, scratch));
7539 DONE;
7540 }
7541 )
7542
7543 (define_expand "aarch64_addp<mode>"
7544 [(match_operand:VDQ_I 0 "register_operand")
7545 (match_operand:VDQ_I 1 "register_operand")
7546 (match_operand:VDQ_I 2 "register_operand")]
7547 "TARGET_SIMD"
7548 {
7549 int nunits = GET_MODE_NUNITS (<MODE>mode).to_constant ();
7550 if (known_eq (GET_MODE_BITSIZE (<MODE>mode), 128))
7551 nunits /= 2;
7552 rtx par_even = aarch64_gen_stepped_int_parallel (nunits, 0, 2);
7553 rtx par_odd = aarch64_gen_stepped_int_parallel (nunits, 1, 2);
7554 emit_insn (gen_aarch64_addp<mode>_insn (operands[0], operands[1],
7555 operands[2], par_even, par_odd));
7556 DONE;
7557 }
7558 )
7559
7560 ;; sqrt
7561
7562 (define_expand "sqrt<mode>2"
7563 [(set (match_operand:VHSDF 0 "register_operand")
7564 (sqrt:VHSDF (match_operand:VHSDF 1 "register_operand")))]
7565 "TARGET_SIMD"
7566 {
7567 if (aarch64_emit_approx_sqrt (operands[0], operands[1], false))
7568 DONE;
7569 })
7570
7571 (define_insn "*sqrt<mode>2<vczle><vczbe>"
7572 [(set (match_operand:VHSDF 0 "register_operand" "=w")
7573 (sqrt:VHSDF (match_operand:VHSDF 1 "register_operand" "w")))]
7574 "TARGET_SIMD"
7575 "fsqrt\\t%0.<Vtype>, %1.<Vtype>"
7576 [(set_attr "type" "neon_fp_sqrt_<stype><q>")]
7577 )
7578
7579 ;; Patterns for vector struct loads and stores.
7580
7581 (define_insn "aarch64_simd_ld2<vstruct_elt>"
7582 [(set (match_operand:VSTRUCT_2Q 0 "register_operand" "=w")
7583 (unspec:VSTRUCT_2Q [
7584 (match_operand:VSTRUCT_2Q 1 "aarch64_simd_struct_operand" "Utv")]
7585 UNSPEC_LD2))]
7586 "TARGET_SIMD"
7587 "ld2\\t{%S0.<Vtype> - %T0.<Vtype>}, %1"
7588 [(set_attr "type" "neon_load2_2reg<q>")]
7589 )
7590
7591 (define_insn "@aarch64_simd_ld2r<vstruct_elt>"
7592 [(set (match_operand:VSTRUCT_2QD 0 "register_operand" "=w")
7593 (unspec:VSTRUCT_2QD [
7594 (match_operand:BLK 1 "aarch64_simd_struct_operand" "Utv")]
7595 UNSPEC_LD2_DUP))]
7596 "TARGET_SIMD"
7597 "ld2r\\t{%S0.<Vtype> - %T0.<Vtype>}, %1"
7598 [(set_attr "type" "neon_load2_all_lanes<q>")]
7599 )
7600
7601 (define_insn "@aarch64_vec_load_lanes<mode>_lane<vstruct_elt>"
7602 [(set (match_operand:VSTRUCT_2QD 0 "register_operand" "=w")
7603 (unspec:VSTRUCT_2QD [
7604 (match_operand:BLK 1 "aarch64_simd_struct_operand" "Utv")
7605 (match_operand:VSTRUCT_2QD 2 "register_operand" "0")
7606 (match_operand:SI 3 "immediate_operand" "i")]
7607 UNSPEC_LD2_LANE))]
7608 "TARGET_SIMD"
7609 {
7610 operands[3] = aarch64_endian_lane_rtx (<VSTRUCT_ELT>mode,
7611 INTVAL (operands[3]));
7612 return "ld2\\t{%S0.<Vetype> - %T0.<Vetype>}[%3], %1";
7613 }
7614 [(set_attr "type" "neon_load2_one_lane")]
7615 )
7616
7617 (define_expand "vec_load_lanes<mode><vstruct_elt>"
7618 [(set (match_operand:VSTRUCT_2Q 0 "register_operand")
7619 (unspec:VSTRUCT_2Q [
7620 (match_operand:VSTRUCT_2Q 1 "aarch64_simd_struct_operand")]
7621 UNSPEC_LD2))]
7622 "TARGET_SIMD"
7623 {
7624 if (BYTES_BIG_ENDIAN)
7625 {
7626 rtx tmp = gen_reg_rtx (<MODE>mode);
7627 rtx mask = aarch64_reverse_mask (<VSTRUCT_ELT>mode,
7628 GET_MODE_NUNITS (<MODE>mode).to_constant () / <nregs>);
7629 emit_insn (gen_aarch64_simd_ld2<vstruct_elt> (tmp, operands[1]));
7630 emit_insn (gen_aarch64_rev_reglist<mode> (operands[0], tmp, mask));
7631 }
7632 else
7633 emit_insn (gen_aarch64_simd_ld2<vstruct_elt> (operands[0], operands[1]));
7634 DONE;
7635 })
7636
7637 (define_insn "aarch64_simd_st2<vstruct_elt>"
7638 [(set (match_operand:VSTRUCT_2Q 0 "aarch64_simd_struct_operand" "=Utv")
7639 (unspec:VSTRUCT_2Q [
7640 (match_operand:VSTRUCT_2Q 1 "register_operand" "w")]
7641 UNSPEC_ST2))]
7642 "TARGET_SIMD"
7643 "st2\\t{%S1.<Vtype> - %T1.<Vtype>}, %0"
7644 [(set_attr "type" "neon_store2_2reg<q>")]
7645 )
7646
7647 ;; RTL uses GCC vector extension indices, so flip only for assembly.
7648 (define_insn "aarch64_vec_store_lanes<mode>_lane<vstruct_elt>"
7649 [(set (match_operand:BLK 0 "aarch64_simd_struct_operand" "=Utv")
7650 (unspec:BLK [(match_operand:VSTRUCT_2QD 1 "register_operand" "w")
7651 (match_operand:SI 2 "immediate_operand" "i")]
7652 UNSPEC_ST2_LANE))]
7653 "TARGET_SIMD"
7654 {
7655 operands[2] = aarch64_endian_lane_rtx (<VSTRUCT_ELT>mode,
7656 INTVAL (operands[2]));
7657 return "st2\\t{%S1.<Vetype> - %T1.<Vetype>}[%2], %0";
7658 }
7659 [(set_attr "type" "neon_store2_one_lane<q>")]
7660 )
7661
7662 (define_expand "vec_store_lanes<mode><vstruct_elt>"
7663 [(set (match_operand:VSTRUCT_2Q 0 "aarch64_simd_struct_operand")
7664 (unspec:VSTRUCT_2Q [(match_operand:VSTRUCT_2Q 1 "register_operand")]
7665 UNSPEC_ST2))]
7666 "TARGET_SIMD"
7667 {
7668 if (BYTES_BIG_ENDIAN)
7669 {
7670 rtx tmp = gen_reg_rtx (<MODE>mode);
7671 rtx mask = aarch64_reverse_mask (<VSTRUCT_ELT>mode,
7672 GET_MODE_NUNITS (<MODE>mode).to_constant () / <nregs>);
7673 emit_insn (gen_aarch64_rev_reglist<mode> (tmp, operands[1], mask));
7674 emit_insn (gen_aarch64_simd_st2<vstruct_elt> (operands[0], tmp));
7675 }
7676 else
7677 emit_insn (gen_aarch64_simd_st2<vstruct_elt> (operands[0], operands[1]));
7678 DONE;
7679 })
7680
7681 (define_insn "aarch64_simd_ld3<vstruct_elt>"
7682 [(set (match_operand:VSTRUCT_3Q 0 "register_operand" "=w")
7683 (unspec:VSTRUCT_3Q [
7684 (match_operand:VSTRUCT_3Q 1 "aarch64_simd_struct_operand" "Utv")]
7685 UNSPEC_LD3))]
7686 "TARGET_SIMD"
7687 "ld3\\t{%S0.<Vtype> - %U0.<Vtype>}, %1"
7688 [(set_attr "type" "neon_load3_3reg<q>")]
7689 )
7690
7691 (define_insn "@aarch64_simd_ld3r<vstruct_elt>"
7692 [(set (match_operand:VSTRUCT_3QD 0 "register_operand" "=w")
7693 (unspec:VSTRUCT_3QD [
7694 (match_operand:BLK 1 "aarch64_simd_struct_operand" "Utv")]
7695 UNSPEC_LD3_DUP))]
7696 "TARGET_SIMD"
7697 "ld3r\\t{%S0.<Vtype> - %U0.<Vtype>}, %1"
7698 [(set_attr "type" "neon_load3_all_lanes<q>")]
7699 )
7700
7701 (define_insn "aarch64_vec_load_lanes<mode>_lane<vstruct_elt>"
7702 [(set (match_operand:VSTRUCT_3QD 0 "register_operand" "=w")
7703 (unspec:VSTRUCT_3QD [
7704 (match_operand:BLK 1 "aarch64_simd_struct_operand" "Utv")
7705 (match_operand:VSTRUCT_3QD 2 "register_operand" "0")
7706 (match_operand:SI 3 "immediate_operand" "i")]
7707 UNSPEC_LD3_LANE))]
7708 "TARGET_SIMD"
7709 {
7710 operands[3] = aarch64_endian_lane_rtx (<VSTRUCT_ELT>mode,
7711 INTVAL (operands[3]));
7712 return "ld3\\t{%S0.<Vetype> - %U0.<Vetype>}[%3], %1";
7713 }
7714 [(set_attr "type" "neon_load3_one_lane")]
7715 )
7716
7717 (define_expand "vec_load_lanes<mode><vstruct_elt>"
7718 [(set (match_operand:VSTRUCT_3Q 0 "register_operand")
7719 (unspec:VSTRUCT_3Q [
7720 (match_operand:VSTRUCT_3Q 1 "aarch64_simd_struct_operand")]
7721 UNSPEC_LD3))]
7722 "TARGET_SIMD"
7723 {
7724 if (BYTES_BIG_ENDIAN)
7725 {
7726 rtx tmp = gen_reg_rtx (<MODE>mode);
7727 rtx mask = aarch64_reverse_mask (<VSTRUCT_ELT>mode,
7728 GET_MODE_NUNITS (<MODE>mode).to_constant () / <nregs>);
7729 emit_insn (gen_aarch64_simd_ld3<vstruct_elt> (tmp, operands[1]));
7730 emit_insn (gen_aarch64_rev_reglist<mode> (operands[0], tmp, mask));
7731 }
7732 else
7733 emit_insn (gen_aarch64_simd_ld3<vstruct_elt> (operands[0], operands[1]));
7734 DONE;
7735 })
7736
7737 (define_insn "aarch64_simd_st3<vstruct_elt>"
7738 [(set (match_operand:VSTRUCT_3Q 0 "aarch64_simd_struct_operand" "=Utv")
7739 (unspec:VSTRUCT_3Q [(match_operand:VSTRUCT_3Q 1 "register_operand" "w")]
7740 UNSPEC_ST3))]
7741 "TARGET_SIMD"
7742 "st3\\t{%S1.<Vtype> - %U1.<Vtype>}, %0"
7743 [(set_attr "type" "neon_store3_3reg<q>")]
7744 )
7745
7746 ;; RTL uses GCC vector extension indices, so flip only for assembly.
7747 (define_insn "aarch64_vec_store_lanes<mode>_lane<vstruct_elt>"
7748 [(set (match_operand:BLK 0 "aarch64_simd_struct_operand" "=Utv")
7749 (unspec:BLK [(match_operand:VSTRUCT_3QD 1 "register_operand" "w")
7750 (match_operand:SI 2 "immediate_operand" "i")]
7751 UNSPEC_ST3_LANE))]
7752 "TARGET_SIMD"
7753 {
7754 operands[2] = aarch64_endian_lane_rtx (<VSTRUCT_ELT>mode,
7755 INTVAL (operands[2]));
7756 return "st3\\t{%S1.<Vetype> - %U1.<Vetype>}[%2], %0";
7757 }
7758 [(set_attr "type" "neon_store3_one_lane<q>")]
7759 )
7760
7761 (define_expand "vec_store_lanes<mode><vstruct_elt>"
7762 [(set (match_operand:VSTRUCT_3Q 0 "aarch64_simd_struct_operand")
7763 (unspec:VSTRUCT_3Q [
7764 (match_operand:VSTRUCT_3Q 1 "register_operand")]
7765 UNSPEC_ST3))]
7766 "TARGET_SIMD"
7767 {
7768 if (BYTES_BIG_ENDIAN)
7769 {
7770 rtx tmp = gen_reg_rtx (<MODE>mode);
7771 rtx mask = aarch64_reverse_mask (<VSTRUCT_ELT>mode,
7772 GET_MODE_NUNITS (<MODE>mode).to_constant () / <nregs>);
7773 emit_insn (gen_aarch64_rev_reglist<mode> (tmp, operands[1], mask));
7774 emit_insn (gen_aarch64_simd_st3<vstruct_elt> (operands[0], tmp));
7775 }
7776 else
7777 emit_insn (gen_aarch64_simd_st3<vstruct_elt> (operands[0], operands[1]));
7778 DONE;
7779 })
7780
7781 (define_insn "aarch64_simd_ld4<vstruct_elt>"
7782 [(set (match_operand:VSTRUCT_4Q 0 "register_operand" "=w")
7783 (unspec:VSTRUCT_4Q [
7784 (match_operand:VSTRUCT_4Q 1 "aarch64_simd_struct_operand" "Utv")]
7785 UNSPEC_LD4))]
7786 "TARGET_SIMD"
7787 "ld4\\t{%S0.<Vtype> - %V0.<Vtype>}, %1"
7788 [(set_attr "type" "neon_load4_4reg<q>")]
7789 )
7790
7791 (define_insn "@aarch64_simd_ld4r<vstruct_elt>"
7792 [(set (match_operand:VSTRUCT_4QD 0 "register_operand" "=w")
7793 (unspec:VSTRUCT_4QD [
7794 (match_operand:BLK 1 "aarch64_simd_struct_operand" "Utv")]
7795 UNSPEC_LD4_DUP))]
7796 "TARGET_SIMD"
7797 "ld4r\\t{%S0.<Vtype> - %V0.<Vtype>}, %1"
7798 [(set_attr "type" "neon_load4_all_lanes<q>")]
7799 )
7800
7801 (define_insn "aarch64_vec_load_lanes<mode>_lane<vstruct_elt>"
7802 [(set (match_operand:VSTRUCT_4QD 0 "register_operand" "=w")
7803 (unspec:VSTRUCT_4QD [
7804 (match_operand:BLK 1 "aarch64_simd_struct_operand" "Utv")
7805 (match_operand:VSTRUCT_4QD 2 "register_operand" "0")
7806 (match_operand:SI 3 "immediate_operand" "i")]
7807 UNSPEC_LD4_LANE))]
7808 "TARGET_SIMD"
7809 {
7810 operands[3] = aarch64_endian_lane_rtx (<VSTRUCT_ELT>mode,
7811 INTVAL (operands[3]));
7812 return "ld4\\t{%S0.<Vetype> - %V0.<Vetype>}[%3], %1";
7813 }
7814 [(set_attr "type" "neon_load4_one_lane")]
7815 )
7816
7817 (define_expand "vec_load_lanes<mode><vstruct_elt>"
7818 [(set (match_operand:VSTRUCT_4Q 0 "register_operand")
7819 (unspec:VSTRUCT_4Q [
7820 (match_operand:VSTRUCT_4Q 1 "aarch64_simd_struct_operand")]
7821 UNSPEC_LD4))]
7822 "TARGET_SIMD"
7823 {
7824 if (BYTES_BIG_ENDIAN)
7825 {
7826 rtx tmp = gen_reg_rtx (<MODE>mode);
7827 rtx mask = aarch64_reverse_mask (<VSTRUCT_ELT>mode,
7828 GET_MODE_NUNITS (<MODE>mode).to_constant () / <nregs>);
7829 emit_insn (gen_aarch64_simd_ld4<vstruct_elt> (tmp, operands[1]));
7830 emit_insn (gen_aarch64_rev_reglist<mode> (operands[0], tmp, mask));
7831 }
7832 else
7833 emit_insn (gen_aarch64_simd_ld4<vstruct_elt> (operands[0], operands[1]));
7834 DONE;
7835 })
7836
7837 (define_insn "aarch64_simd_st4<vstruct_elt>"
7838 [(set (match_operand:VSTRUCT_4Q 0 "aarch64_simd_struct_operand" "=Utv")
7839 (unspec:VSTRUCT_4Q [
7840 (match_operand:VSTRUCT_4Q 1 "register_operand" "w")]
7841 UNSPEC_ST4))]
7842 "TARGET_SIMD"
7843 "st4\\t{%S1.<Vtype> - %V1.<Vtype>}, %0"
7844 [(set_attr "type" "neon_store4_4reg<q>")]
7845 )
7846
7847 ;; RTL uses GCC vector extension indices, so flip only for assembly.
7848 (define_insn "aarch64_vec_store_lanes<mode>_lane<vstruct_elt>"
7849 [(set (match_operand:BLK 0 "aarch64_simd_struct_operand" "=Utv")
7850 (unspec:BLK [(match_operand:VSTRUCT_4QD 1 "register_operand" "w")
7851 (match_operand:SI 2 "immediate_operand" "i")]
7852 UNSPEC_ST4_LANE))]
7853 "TARGET_SIMD"
7854 {
7855 operands[2] = aarch64_endian_lane_rtx (<VSTRUCT_ELT>mode,
7856 INTVAL (operands[2]));
7857 return "st4\\t{%S1.<Vetype> - %V1.<Vetype>}[%2], %0";
7858 }
7859 [(set_attr "type" "neon_store4_one_lane<q>")]
7860 )
7861
7862 (define_expand "vec_store_lanes<mode><vstruct_elt>"
7863 [(set (match_operand:VSTRUCT_4Q 0 "aarch64_simd_struct_operand")
7864 (unspec:VSTRUCT_4Q [(match_operand:VSTRUCT_4Q 1 "register_operand")]
7865 UNSPEC_ST4))]
7866 "TARGET_SIMD"
7867 {
7868 if (BYTES_BIG_ENDIAN)
7869 {
7870 rtx tmp = gen_reg_rtx (<MODE>mode);
7871 rtx mask = aarch64_reverse_mask (<VSTRUCT_ELT>mode,
7872 GET_MODE_NUNITS (<MODE>mode).to_constant () / <nregs>);
7873 emit_insn (gen_aarch64_rev_reglist<mode> (tmp, operands[1], mask));
7874 emit_insn (gen_aarch64_simd_st4<vstruct_elt> (operands[0], tmp));
7875 }
7876 else
7877 emit_insn (gen_aarch64_simd_st4<vstruct_elt> (operands[0], operands[1]));
7878 DONE;
7879 })
7880
7881 ;; Patterns for rcpc3 vector lane loads and stores.
7882
7883 (define_insn "aarch64_vec_stl1_lanes<mode>_lane<Vel>"
7884 [(set (match_operand:BLK 0 "aarch64_simd_struct_operand" "=Q")
7885 (unspec:BLK [(match_operand:V12DIF 1 "register_operand" "w")
7886 (match_operand:SI 2 "immediate_operand" "i")]
7887 UNSPEC_STL1_LANE))]
7888 "TARGET_RCPC3"
7889 {
7890 operands[2] = aarch64_endian_lane_rtx (<MODE>mode,
7891 INTVAL (operands[2]));
7892 return "stl1\\t{%S1.<Vetype>}[%2], %0";
7893 }
7894 [(set_attr "type" "neon_store2_one_lane")]
7895 )
7896
7897 (define_expand "aarch64_vec_stl1_lane<mode>"
7898 [(match_operand:DI 0 "register_operand")
7899 (match_operand:V12DIF 1 "register_operand")
7900 (match_operand:SI 2 "immediate_operand")]
7901 "TARGET_RCPC3"
7902 {
7903 rtx mem = gen_rtx_MEM (BLKmode, operands[0]);
7904 set_mem_size (mem, GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)));
7905
7906 aarch64_simd_lane_bounds (operands[2], 0,
7907 GET_MODE_NUNITS (<MODE>mode).to_constant (), NULL);
7908 emit_insn (gen_aarch64_vec_stl1_lanes<mode>_lane<Vel> (mem,
7909 operands[1], operands[2]));
7910 DONE;
7911 })
7912
7913 (define_insn "aarch64_vec_ldap1_lanes<mode>_lane<Vel>"
7914 [(set (match_operand:V12DIF 0 "register_operand" "=w")
7915 (unspec:V12DIF [
7916 (match_operand:BLK 1 "aarch64_simd_struct_operand" "Q")
7917 (match_operand:V12DIF 2 "register_operand" "0")
7918 (match_operand:SI 3 "immediate_operand" "i")]
7919 UNSPEC_LDAP1_LANE))]
7920 "TARGET_RCPC3"
7921 {
7922 operands[3] = aarch64_endian_lane_rtx (<MODE>mode,
7923 INTVAL (operands[3]));
7924 return "ldap1\\t{%S0.<Vetype>}[%3], %1";
7925 }
7926 [(set_attr "type" "neon_load2_one_lane")]
7927 )
7928
7929 (define_expand "aarch64_vec_ldap1_lane<mode>"
7930 [(match_operand:V12DIF 0 "register_operand")
7931 (match_operand:DI 1 "register_operand")
7932 (match_operand:V12DIF 2 "register_operand")
7933 (match_operand:SI 3 "immediate_operand")]
7934 "TARGET_RCPC3"
7935 {
7936 rtx mem = gen_rtx_MEM (BLKmode, operands[1]);
7937 set_mem_size (mem, GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)));
7938
7939 aarch64_simd_lane_bounds (operands[3], 0,
7940 GET_MODE_NUNITS (<MODE>mode).to_constant (), NULL);
7941 emit_insn (gen_aarch64_vec_ldap1_lanes<mode>_lane<Vel> (operands[0],
7942 mem, operands[2], operands[3]));
7943 DONE;
7944 })
7945
7946 (define_insn_and_split "aarch64_rev_reglist<mode>"
7947 [(set (match_operand:VSTRUCT_QD 0 "register_operand" "=&w")
7948 (unspec:VSTRUCT_QD
7949 [(match_operand:VSTRUCT_QD 1 "register_operand" "w")
7950 (match_operand:V16QI 2 "register_operand" "w")]
7951 UNSPEC_REV_REGLIST))]
7952 "TARGET_SIMD"
7953 "#"
7954 "&& reload_completed"
7955 [(const_int 0)]
7956 {
7957 int i;
7958 int nregs = GET_MODE_SIZE (<MODE>mode).to_constant () / UNITS_PER_VREG;
7959 for (i = 0; i < nregs; i++)
7960 {
7961 rtx op0 = gen_rtx_REG (V16QImode, REGNO (operands[0]) + i);
7962 rtx op1 = gen_rtx_REG (V16QImode, REGNO (operands[1]) + i);
7963 emit_insn (gen_aarch64_qtbl1v16qi (op0, op1, operands[2]));
7964 }
7965 DONE;
7966 }
7967 [(set_attr "type" "neon_tbl1_q")
7968 (set_attr "length" "<insn_count>")]
7969 )
7970
7971 ;; Reload patterns for AdvSIMD register list operands.
7972
7973 (define_expand "mov<mode>"
7974 [(set (match_operand:VSTRUCT_QD 0 "nonimmediate_operand")
7975 (match_operand:VSTRUCT_QD 1 "general_operand"))]
7976 "TARGET_FLOAT"
7977 {
7978 if (known_eq (GET_MODE_SIZE (<MODE>mode), 16)
7979 && operands[1] == CONST0_RTX (<MODE>mode)
7980 && MEM_P (operands[0])
7981 && (can_create_pseudo_p ()
7982 || memory_address_p (TImode, XEXP (operands[0], 0))))
7983 {
7984 operands[0] = adjust_address (operands[0], TImode, 0);
7985 operands[1] = CONST0_RTX (TImode);
7986 }
7987 else if (can_create_pseudo_p ())
7988 {
7989 if (GET_CODE (operands[0]) != REG)
7990 operands[1] = force_reg (<MODE>mode, operands[1]);
7991 }
7992 })
7993
7994 (define_expand "mov<mode>"
7995 [(set (match_operand:VSTRUCT 0 "nonimmediate_operand")
7996 (match_operand:VSTRUCT 1 "general_operand"))]
7997 "TARGET_FLOAT"
7998 {
7999 if (can_create_pseudo_p ())
8000 {
8001 if (GET_CODE (operands[0]) != REG)
8002 operands[1] = force_reg (<MODE>mode, operands[1]);
8003 }
8004 })
8005
8006 (define_expand "movv8di"
8007 [(set (match_operand:V8DI 0 "nonimmediate_operand")
8008 (match_operand:V8DI 1 "general_operand"))]
8009 ""
8010 {
8011 if (can_create_pseudo_p () && MEM_P (operands[0]))
8012 operands[1] = force_reg (V8DImode, operands[1]);
8013 })
8014
8015 (define_expand "@aarch64_ld1x3<vstruct_elt>"
8016 [(match_operand:VSTRUCT_3QD 0 "register_operand")
8017 (match_operand:DI 1 "register_operand")]
8018 "TARGET_SIMD"
8019 {
8020 rtx mem = gen_rtx_MEM (<MODE>mode, operands[1]);
8021 emit_insn (gen_aarch64_ld1_x3_<vstruct_elt> (operands[0], mem));
8022 DONE;
8023 })
8024
8025 (define_insn "aarch64_ld1_x3_<vstruct_elt>"
8026 [(set (match_operand:VSTRUCT_3QD 0 "register_operand" "=w")
8027 (unspec:VSTRUCT_3QD
8028 [(match_operand:VSTRUCT_3QD 1 "aarch64_simd_struct_operand" "Utv")]
8029 UNSPEC_LD1))]
8030 "TARGET_SIMD"
8031 "ld1\\t{%S0.<Vtype> - %U0.<Vtype>}, %1"
8032 [(set_attr "type" "neon_load1_3reg<q>")]
8033 )
8034
8035 (define_expand "@aarch64_ld1x4<vstruct_elt>"
8036 [(match_operand:VSTRUCT_4QD 0 "register_operand" "=w")
8037 (match_operand:DI 1 "register_operand" "r")]
8038 "TARGET_SIMD"
8039 {
8040 rtx mem = gen_rtx_MEM (<MODE>mode, operands[1]);
8041 emit_insn (gen_aarch64_ld1_x4_<vstruct_elt> (operands[0], mem));
8042 DONE;
8043 })
8044
8045 (define_insn "aarch64_ld1_x4_<vstruct_elt>"
8046 [(set (match_operand:VSTRUCT_4QD 0 "register_operand" "=w")
8047 (unspec:VSTRUCT_4QD
8048 [(match_operand:VSTRUCT_4QD 1 "aarch64_simd_struct_operand" "Utv")]
8049 UNSPEC_LD1))]
8050 "TARGET_SIMD"
8051 "ld1\\t{%S0.<Vtype> - %V0.<Vtype>}, %1"
8052 [(set_attr "type" "neon_load1_4reg<q>")]
8053 )
8054
8055 (define_expand "@aarch64_st1x2<vstruct_elt>"
8056 [(match_operand:DI 0 "register_operand")
8057 (match_operand:VSTRUCT_2QD 1 "register_operand")]
8058 "TARGET_SIMD"
8059 {
8060 rtx mem = gen_rtx_MEM (<MODE>mode, operands[0]);
8061 emit_insn (gen_aarch64_st1_x2_<vstruct_elt> (mem, operands[1]));
8062 DONE;
8063 })
8064
8065 (define_insn "aarch64_st1_x2_<vstruct_elt>"
8066 [(set (match_operand:VSTRUCT_2QD 0 "aarch64_simd_struct_operand" "=Utv")
8067 (unspec:VSTRUCT_2QD
8068 [(match_operand:VSTRUCT_2QD 1 "register_operand" "w")]
8069 UNSPEC_ST1))]
8070 "TARGET_SIMD"
8071 "st1\\t{%S1.<Vtype> - %T1.<Vtype>}, %0"
8072 [(set_attr "type" "neon_store1_2reg<q>")]
8073 )
8074
8075 (define_expand "@aarch64_st1x3<vstruct_elt>"
8076 [(match_operand:DI 0 "register_operand")
8077 (match_operand:VSTRUCT_3QD 1 "register_operand")]
8078 "TARGET_SIMD"
8079 {
8080 rtx mem = gen_rtx_MEM (<MODE>mode, operands[0]);
8081 emit_insn (gen_aarch64_st1_x3_<vstruct_elt> (mem, operands[1]));
8082 DONE;
8083 })
8084
8085 (define_insn "aarch64_st1_x3_<vstruct_elt>"
8086 [(set (match_operand:VSTRUCT_3QD 0 "aarch64_simd_struct_operand" "=Utv")
8087 (unspec:VSTRUCT_3QD
8088 [(match_operand:VSTRUCT_3QD 1 "register_operand" "w")]
8089 UNSPEC_ST1))]
8090 "TARGET_SIMD"
8091 "st1\\t{%S1.<Vtype> - %U1.<Vtype>}, %0"
8092 [(set_attr "type" "neon_store1_3reg<q>")]
8093 )
8094
8095 (define_expand "@aarch64_st1x4<vstruct_elt>"
8096 [(match_operand:DI 0 "register_operand" "")
8097 (match_operand:VSTRUCT_4QD 1 "register_operand" "")]
8098 "TARGET_SIMD"
8099 {
8100 rtx mem = gen_rtx_MEM (<MODE>mode, operands[0]);
8101 emit_insn (gen_aarch64_st1_x4_<vstruct_elt> (mem, operands[1]));
8102 DONE;
8103 })
8104
8105 (define_insn "aarch64_st1_x4_<vstruct_elt>"
8106 [(set (match_operand:VSTRUCT_4QD 0 "aarch64_simd_struct_operand" "=Utv")
8107 (unspec:VSTRUCT_4QD
8108 [(match_operand:VSTRUCT_4QD 1 "register_operand" "w")]
8109 UNSPEC_ST1))]
8110 "TARGET_SIMD"
8111 "st1\\t{%S1.<Vtype> - %V1.<Vtype>}, %0"
8112 [(set_attr "type" "neon_store1_4reg<q>")]
8113 )
8114
8115 (define_insn "*aarch64_movv8di"
8116 [(set (match_operand:V8DI 0 "nonimmediate_operand" "=r,m,r")
8117 (match_operand:V8DI 1 "general_operand" " r,r,m"))]
8118 "(register_operand (operands[0], V8DImode)
8119 || register_operand (operands[1], V8DImode))"
8120 "#"
8121 [(set_attr "type" "multiple,multiple,multiple")
8122 (set_attr "length" "32,16,16")]
8123 )
8124
8125 (define_insn "aarch64_be_ld1<mode>"
8126 [(set (match_operand:VALLDI_F16 0 "register_operand" "=w")
8127 (unspec:VALLDI_F16 [(match_operand:VALLDI_F16 1
8128 "aarch64_simd_struct_operand" "Utv")]
8129 UNSPEC_LD1))]
8130 "TARGET_SIMD"
8131 "ld1\\t{%0<Vmtype>}, %1"
8132 [(set_attr "type" "neon_load1_1reg<q>")]
8133 )
8134
8135 (define_insn "aarch64_be_st1<mode>"
8136 [(set (match_operand:VALLDI_F16 0 "aarch64_simd_struct_operand" "=Utv")
8137 (unspec:VALLDI_F16 [(match_operand:VALLDI_F16 1 "register_operand" "w")]
8138 UNSPEC_ST1))]
8139 "TARGET_SIMD"
8140 "st1\\t{%1<Vmtype>}, %0"
8141 [(set_attr "type" "neon_store1_1reg<q>")]
8142 )
8143
8144 (define_insn "*aarch64_mov<mode>"
8145 [(set (match_operand:VSTRUCT_2D 0 "nonimmediate_operand")
8146 (match_operand:VSTRUCT_2D 1 "general_operand"))]
8147 "TARGET_FLOAT
8148 && (register_operand (operands[0], <MODE>mode)
8149 || register_operand (operands[1], <MODE>mode))"
8150 {@ [ cons: =0 , 1 ; attrs: type , length ]
8151 [ w , w ; multiple , 8 ] #
8152 [ m , w ; neon_stp , 4 ] stp\t%d1, %R1, %0
8153 [ w , m ; neon_ldp , 4 ] ldp\t%d0, %R0, %1
8154 }
8155 )
8156
8157 (define_insn "*aarch64_mov<mode>"
8158 [(set (match_operand:VSTRUCT_2Q 0 "nonimmediate_operand")
8159 (match_operand:VSTRUCT_2Q 1 "general_operand"))]
8160 "TARGET_FLOAT
8161 && (register_operand (operands[0], <MODE>mode)
8162 || register_operand (operands[1], <MODE>mode))"
8163 {@ [ cons: =0 , 1 ; attrs: type , arch , length ]
8164 [ w , w ; multiple , simd , 8 ] #
8165 [ m , w ; neon_stp_q , * , 4 ] stp\t%q1, %R1, %0
8166 [ w , m ; neon_ldp_q , * , 4 ] ldp\t%q0, %R0, %1
8167 }
8168 )
8169
8170 (define_insn "*aarch64_movoi"
8171 [(set (match_operand:OI 0 "nonimmediate_operand")
8172 (match_operand:OI 1 "general_operand"))]
8173 "TARGET_FLOAT
8174 && (register_operand (operands[0], OImode)
8175 || register_operand (operands[1], OImode))"
8176 {@ [ cons: =0 , 1 ; attrs: type , arch , length ]
8177 [ w , w ; multiple , simd , 8 ] #
8178 [ m , w ; neon_stp_q , * , 4 ] stp\t%q1, %R1, %0
8179 [ w , m ; neon_ldp_q , * , 4 ] ldp\t%q0, %R0, %1
8180 }
8181 )
8182
8183 (define_insn "*aarch64_mov<mode>"
8184 [(set (match_operand:VSTRUCT_3QD 0 "nonimmediate_operand" "=w,o,w")
8185 (match_operand:VSTRUCT_3QD 1 "general_operand" " w,w,o"))]
8186 "TARGET_FLOAT
8187 && (register_operand (operands[0], <MODE>mode)
8188 || register_operand (operands[1], <MODE>mode))"
8189 "#"
8190 [(set_attr "type" "multiple")
8191 (set_attr "arch" "fp<q>,*,*")
8192 (set_attr "length" "12,8,8")]
8193 )
8194
8195 (define_insn "*aarch64_movci"
8196 [(set (match_operand:CI 0 "nonimmediate_operand" "=w,o,w")
8197 (match_operand:CI 1 "general_operand" " w,w,o"))]
8198 "TARGET_FLOAT
8199 && (register_operand (operands[0], CImode)
8200 || register_operand (operands[1], CImode))"
8201 "#"
8202 [(set_attr "type" "multiple")
8203 (set_attr "arch" "simd,*,*")
8204 (set_attr "length" "12,8,8")]
8205 )
8206
8207 (define_insn "*aarch64_mov<mode>"
8208 [(set (match_operand:VSTRUCT_4QD 0 "nonimmediate_operand" "=w,o,w")
8209 (match_operand:VSTRUCT_4QD 1 "general_operand" " w,w,o"))]
8210 "TARGET_FLOAT
8211 && (register_operand (operands[0], <MODE>mode)
8212 || register_operand (operands[1], <MODE>mode))"
8213 "#"
8214 [(set_attr "type" "multiple")
8215 (set_attr "arch" "fp<q>,*,*")
8216 (set_attr "length" "16,8,8")]
8217 )
8218
8219 (define_insn "*aarch64_movxi"
8220 [(set (match_operand:XI 0 "nonimmediate_operand" "=w,o,w")
8221 (match_operand:XI 1 "general_operand" " w,w,o"))]
8222 "TARGET_FLOAT
8223 && (register_operand (operands[0], XImode)
8224 || register_operand (operands[1], XImode))"
8225 "#"
8226 [(set_attr "type" "multiple")
8227 (set_attr "arch" "simd,*,*")
8228 (set_attr "length" "16,8,8")]
8229 )
8230
8231 (define_split
8232 [(set (match_operand:VSTRUCT_2QD 0 "register_operand")
8233 (match_operand:VSTRUCT_2QD 1 "register_operand"))]
8234 "TARGET_FLOAT && reload_completed"
8235 [(const_int 0)]
8236 {
8237 aarch64_simd_emit_reg_reg_move (operands, <VSTRUCT_ELT>mode, 2);
8238 DONE;
8239 })
8240
8241 (define_split
8242 [(set (match_operand:OI 0 "register_operand")
8243 (match_operand:OI 1 "register_operand"))]
8244 "TARGET_FLOAT && reload_completed"
8245 [(const_int 0)]
8246 {
8247 aarch64_simd_emit_reg_reg_move (operands, TImode, 2);
8248 DONE;
8249 })
8250
8251 (define_split
8252 [(set (match_operand:VSTRUCT_3QD 0 "nonimmediate_operand")
8253 (match_operand:VSTRUCT_3QD 1 "general_operand"))]
8254 "TARGET_FLOAT && reload_completed"
8255 [(const_int 0)]
8256 {
8257 if (register_operand (operands[0], <MODE>mode)
8258 && register_operand (operands[1], <MODE>mode))
8259 aarch64_simd_emit_reg_reg_move (operands, <VSTRUCT_ELT>mode, 3);
8260 else
8261 {
8262 int elt_size = GET_MODE_SIZE (<MODE>mode).to_constant () / <nregs>;
8263 machine_mode pair_mode = elt_size == 16 ? V2x16QImode : V2x8QImode;
8264 emit_move_insn (simplify_gen_subreg (pair_mode, operands[0],
8265 <MODE>mode, 0),
8266 simplify_gen_subreg (pair_mode, operands[1],
8267 <MODE>mode, 0));
8268 emit_move_insn (gen_lowpart (<VSTRUCT_ELT>mode,
8269 simplify_gen_subreg (<VSTRUCT_ELT>mode,
8270 operands[0],
8271 <MODE>mode,
8272 2 * elt_size)),
8273 gen_lowpart (<VSTRUCT_ELT>mode,
8274 simplify_gen_subreg (<VSTRUCT_ELT>mode,
8275 operands[1],
8276 <MODE>mode,
8277 2 * elt_size)));
8278 }
8279 DONE;
8280 })
8281
8282 (define_split
8283 [(set (match_operand:CI 0 "nonimmediate_operand")
8284 (match_operand:CI 1 "general_operand"))]
8285 "TARGET_FLOAT && reload_completed"
8286 [(const_int 0)]
8287 {
8288 if (register_operand (operands[0], CImode)
8289 && register_operand (operands[1], CImode))
8290 aarch64_simd_emit_reg_reg_move (operands, TImode, 3);
8291 else
8292 {
8293 emit_move_insn (simplify_gen_subreg (OImode, operands[0], CImode, 0),
8294 simplify_gen_subreg (OImode, operands[1], CImode, 0));
8295 emit_move_insn (gen_lowpart (V16QImode,
8296 simplify_gen_subreg (TImode, operands[0],
8297 CImode, 32)),
8298 gen_lowpart (V16QImode,
8299 simplify_gen_subreg (TImode, operands[1],
8300 CImode, 32)));
8301 }
8302 DONE;
8303 })
8304
8305 (define_split
8306 [(set (match_operand:VSTRUCT_4QD 0 "nonimmediate_operand")
8307 (match_operand:VSTRUCT_4QD 1 "general_operand"))]
8308 "TARGET_FLOAT && reload_completed"
8309 [(const_int 0)]
8310 {
8311 if (register_operand (operands[0], <MODE>mode)
8312 && register_operand (operands[1], <MODE>mode))
8313 aarch64_simd_emit_reg_reg_move (operands, <VSTRUCT_ELT>mode, 4);
8314 else
8315 {
8316 int elt_size = GET_MODE_SIZE (<MODE>mode).to_constant () / <nregs>;
8317 machine_mode pair_mode = elt_size == 16 ? V2x16QImode : V2x8QImode;
8318 emit_move_insn (simplify_gen_subreg (pair_mode, operands[0],
8319 <MODE>mode, 0),
8320 simplify_gen_subreg (pair_mode, operands[1],
8321 <MODE>mode, 0));
8322 emit_move_insn (simplify_gen_subreg (pair_mode, operands[0],
8323 <MODE>mode, 2 * elt_size),
8324 simplify_gen_subreg (pair_mode, operands[1],
8325 <MODE>mode, 2 * elt_size));
8326 }
8327 DONE;
8328 })
8329
8330 (define_split
8331 [(set (match_operand:XI 0 "nonimmediate_operand")
8332 (match_operand:XI 1 "general_operand"))]
8333 "TARGET_FLOAT && reload_completed"
8334 [(const_int 0)]
8335 {
8336 if (register_operand (operands[0], XImode)
8337 && register_operand (operands[1], XImode))
8338 aarch64_simd_emit_reg_reg_move (operands, TImode, 4);
8339 else
8340 {
8341 emit_move_insn (simplify_gen_subreg (OImode, operands[0], XImode, 0),
8342 simplify_gen_subreg (OImode, operands[1], XImode, 0));
8343 emit_move_insn (simplify_gen_subreg (OImode, operands[0], XImode, 32),
8344 simplify_gen_subreg (OImode, operands[1], XImode, 32));
8345 }
8346 DONE;
8347 })
8348
8349 (define_split
8350 [(set (match_operand:V8DI 0 "nonimmediate_operand")
8351 (match_operand:V8DI 1 "general_operand"))]
8352 "reload_completed"
8353 [(const_int 0)]
8354 {
8355 if (register_operand (operands[0], V8DImode)
8356 && register_operand (operands[1], V8DImode))
8357 {
8358 aarch64_simd_emit_reg_reg_move (operands, DImode, 8);
8359 DONE;
8360 }
8361 else if ((register_operand (operands[0], V8DImode)
8362 && memory_operand (operands[1], V8DImode))
8363 || (memory_operand (operands[0], V8DImode)
8364 && register_operand (operands[1], V8DImode)))
8365 {
8366 /* V8DI only guarantees 8-byte alignment, whereas TImode requires 16. */
8367 auto mode = STRICT_ALIGNMENT ? DImode : TImode;
8368 int increment = GET_MODE_SIZE (mode);
8369 std::pair<rtx, rtx> last_pair = {};
8370 for (int offset = 0; offset < 64; offset += increment)
8371 {
8372 std::pair<rtx, rtx> pair = {
8373 simplify_gen_subreg (mode, operands[0], V8DImode, offset),
8374 simplify_gen_subreg (mode, operands[1], V8DImode, offset)
8375 };
8376 if (register_operand (pair.first, mode)
8377 && reg_overlap_mentioned_p (pair.first, pair.second))
8378 last_pair = pair;
8379 else
8380 emit_move_insn (pair.first, pair.second);
8381 }
8382 if (last_pair.first)
8383 emit_move_insn (last_pair.first, last_pair.second);
8384 DONE;
8385 }
8386 else
8387 FAIL;
8388 })
8389
8390 (define_expand "aarch64_ld<nregs>r<vstruct_elt>"
8391 [(match_operand:VSTRUCT_QD 0 "register_operand")
8392 (match_operand:DI 1 "register_operand")]
8393 "TARGET_SIMD"
8394 {
8395 rtx mem = gen_rtx_MEM (BLKmode, operands[1]);
8396 set_mem_size (mem, GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) * <nregs>);
8397
8398 emit_insn (gen_aarch64_simd_ld<nregs>r<vstruct_elt> (operands[0], mem));
8399 DONE;
8400 })
8401
8402 (define_insn "aarch64_ld2<vstruct_elt>_dreg"
8403 [(set (match_operand:VSTRUCT_2DNX 0 "register_operand" "=w")
8404 (unspec:VSTRUCT_2DNX [
8405 (match_operand:VSTRUCT_2DNX 1 "aarch64_simd_struct_operand" "Utv")]
8406 UNSPEC_LD2_DREG))]
8407 "TARGET_SIMD"
8408 "ld2\\t{%S0.<Vtype> - %T0.<Vtype>}, %1"
8409 [(set_attr "type" "neon_load2_2reg<q>")]
8410 )
8411
8412 (define_insn "aarch64_ld2<vstruct_elt>_dreg"
8413 [(set (match_operand:VSTRUCT_2DX 0 "register_operand" "=w")
8414 (unspec:VSTRUCT_2DX [
8415 (match_operand:VSTRUCT_2DX 1 "aarch64_simd_struct_operand" "Utv")]
8416 UNSPEC_LD2_DREG))]
8417 "TARGET_SIMD"
8418 "ld1\\t{%S0.1d - %T0.1d}, %1"
8419 [(set_attr "type" "neon_load1_2reg<q>")]
8420 )
8421
8422 (define_insn "aarch64_ld3<vstruct_elt>_dreg"
8423 [(set (match_operand:VSTRUCT_3DNX 0 "register_operand" "=w")
8424 (unspec:VSTRUCT_3DNX [
8425 (match_operand:VSTRUCT_3DNX 1 "aarch64_simd_struct_operand" "Utv")]
8426 UNSPEC_LD3_DREG))]
8427 "TARGET_SIMD"
8428 "ld3\\t{%S0.<Vtype> - %U0.<Vtype>}, %1"
8429 [(set_attr "type" "neon_load3_3reg<q>")]
8430 )
8431
8432 (define_insn "aarch64_ld3<vstruct_elt>_dreg"
8433 [(set (match_operand:VSTRUCT_3DX 0 "register_operand" "=w")
8434 (unspec:VSTRUCT_3DX [
8435 (match_operand:VSTRUCT_3DX 1 "aarch64_simd_struct_operand" "Utv")]
8436 UNSPEC_LD3_DREG))]
8437 "TARGET_SIMD"
8438 "ld1\\t{%S0.1d - %U0.1d}, %1"
8439 [(set_attr "type" "neon_load1_3reg<q>")]
8440 )
8441
8442 (define_insn "aarch64_ld4<vstruct_elt>_dreg"
8443 [(set (match_operand:VSTRUCT_4DNX 0 "register_operand" "=w")
8444 (unspec:VSTRUCT_4DNX [
8445 (match_operand:VSTRUCT_4DNX 1 "aarch64_simd_struct_operand" "Utv")]
8446 UNSPEC_LD4_DREG))]
8447 "TARGET_SIMD"
8448 "ld4\\t{%S0.<Vtype> - %V0.<Vtype>}, %1"
8449 [(set_attr "type" "neon_load4_4reg<q>")]
8450 )
8451
8452 (define_insn "aarch64_ld4<vstruct_elt>_dreg"
8453 [(set (match_operand:VSTRUCT_4DX 0 "register_operand" "=w")
8454 (unspec:VSTRUCT_4DX [
8455 (match_operand:VSTRUCT_4DX 1 "aarch64_simd_struct_operand" "Utv")]
8456 UNSPEC_LD4_DREG))]
8457 "TARGET_SIMD"
8458 "ld1\\t{%S0.1d - %V0.1d}, %1"
8459 [(set_attr "type" "neon_load1_4reg<q>")]
8460 )
8461
8462 (define_expand "@aarch64_ld<nregs><vstruct_elt>"
8463 [(match_operand:VSTRUCT_D 0 "register_operand")
8464 (match_operand:DI 1 "register_operand")]
8465 "TARGET_SIMD"
8466 {
8467 rtx mem = gen_rtx_MEM (<MODE>mode, operands[1]);
8468 emit_insn (gen_aarch64_ld<nregs><vstruct_elt>_dreg (operands[0], mem));
8469 DONE;
8470 })
8471
8472 (define_expand "@aarch64_ld1<VALL_F16:mode>"
8473 [(match_operand:VALL_F16 0 "register_operand")
8474 (match_operand:DI 1 "register_operand")]
8475 "TARGET_SIMD"
8476 {
8477 machine_mode mode = <VALL_F16:MODE>mode;
8478 rtx mem = gen_rtx_MEM (mode, operands[1]);
8479
8480 if (BYTES_BIG_ENDIAN)
8481 emit_insn (gen_aarch64_be_ld1<VALL_F16:mode> (operands[0], mem));
8482 else
8483 emit_move_insn (operands[0], mem);
8484 DONE;
8485 })
8486
8487 (define_expand "@aarch64_ld<nregs><vstruct_elt>"
8488 [(match_operand:VSTRUCT_Q 0 "register_operand")
8489 (match_operand:DI 1 "register_operand")]
8490 "TARGET_SIMD"
8491 {
8492 rtx mem = gen_rtx_MEM (<MODE>mode, operands[1]);
8493 emit_insn (gen_aarch64_simd_ld<nregs><vstruct_elt> (operands[0], mem));
8494 DONE;
8495 })
8496
8497 (define_expand "@aarch64_ld1x2<vstruct_elt>"
8498 [(match_operand:VSTRUCT_2QD 0 "register_operand")
8499 (match_operand:DI 1 "register_operand")]
8500 "TARGET_SIMD"
8501 {
8502 machine_mode mode = <MODE>mode;
8503 rtx mem = gen_rtx_MEM (mode, operands[1]);
8504
8505 emit_insn (gen_aarch64_simd_ld1<vstruct_elt>_x2 (operands[0], mem));
8506 DONE;
8507 })
8508
8509 (define_expand "@aarch64_ld<nregs>_lane<vstruct_elt>"
8510 [(match_operand:VSTRUCT_QD 0 "register_operand")
8511 (match_operand:DI 1 "register_operand")
8512 (match_operand:VSTRUCT_QD 2 "register_operand")
8513 (match_operand:SI 3 "immediate_operand")]
8514 "TARGET_SIMD"
8515 {
8516 rtx mem = gen_rtx_MEM (BLKmode, operands[1]);
8517 set_mem_size (mem, GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) * <nregs>);
8518
8519 aarch64_simd_lane_bounds (operands[3], 0,
8520 GET_MODE_NUNITS (<MODE>mode).to_constant () / <nregs>, NULL);
8521 emit_insn (gen_aarch64_vec_load_lanes<mode>_lane<vstruct_elt> (operands[0],
8522 mem, operands[2], operands[3]));
8523 DONE;
8524 })
8525
8526 ;; Permuted-store expanders for neon intrinsics.
8527
8528 ;; Permute instructions
8529
8530 ;; vec_perm support
8531
8532 (define_expand "vec_perm<mode>"
8533 [(match_operand:VB 0 "register_operand")
8534 (match_operand:VB 1 "register_operand")
8535 (match_operand:VB 2 "register_operand")
8536 (match_operand:VB 3 "register_operand")]
8537 "TARGET_SIMD"
8538 {
8539 aarch64_expand_vec_perm (operands[0], operands[1],
8540 operands[2], operands[3], <nunits>);
8541 DONE;
8542 })
8543
8544 (define_insn "aarch64_qtbl1<mode>"
8545 [(set (match_operand:VB 0 "register_operand" "=w")
8546 (unspec:VB [(match_operand:V16QI 1 "register_operand" "w")
8547 (match_operand:VB 2 "register_operand" "w")]
8548 UNSPEC_TBL))]
8549 "TARGET_SIMD"
8550 "tbl\\t%0.<Vtype>, {%1.16b}, %2.<Vtype>"
8551 [(set_attr "type" "neon_tbl1<q>")]
8552 )
8553
8554 (define_insn "aarch64_qtbx1<mode>"
8555 [(set (match_operand:VB 0 "register_operand" "=w")
8556 (unspec:VB [(match_operand:VB 1 "register_operand" "0")
8557 (match_operand:V16QI 2 "register_operand" "w")
8558 (match_operand:VB 3 "register_operand" "w")]
8559 UNSPEC_TBX))]
8560 "TARGET_SIMD"
8561 "tbx\\t%0.<Vtype>, {%2.16b}, %3.<Vtype>"
8562 [(set_attr "type" "neon_tbl1<q>")]
8563 )
8564
8565 ;; Two source registers.
8566
8567 (define_insn "aarch64_qtbl2<mode>"
8568 [(set (match_operand:VB 0 "register_operand" "=w")
8569 (unspec:VB [(match_operand:V2x16QI 1 "register_operand" "w")
8570 (match_operand:VB 2 "register_operand" "w")]
8571 UNSPEC_TBL))]
8572 "TARGET_SIMD"
8573 "tbl\\t%S0.<Vbtype>, {%S1.16b - %T1.16b}, %S2.<Vbtype>"
8574 [(set_attr "type" "neon_tbl2")]
8575 )
8576
8577 (define_insn "aarch64_qtbx2<mode>"
8578 [(set (match_operand:VB 0 "register_operand" "=w")
8579 (unspec:VB [(match_operand:VB 1 "register_operand" "0")
8580 (match_operand:V2x16QI 2 "register_operand" "w")
8581 (match_operand:VB 3 "register_operand" "w")]
8582 UNSPEC_TBX))]
8583 "TARGET_SIMD"
8584 "tbx\\t%S0.<Vbtype>, {%S2.16b - %T2.16b}, %S3.<Vbtype>"
8585 [(set_attr "type" "neon_tbl2")]
8586 )
8587
8588 ;; Three source registers.
8589
8590 (define_insn "aarch64_qtbl3<mode>"
8591 [(set (match_operand:VB 0 "register_operand" "=w")
8592 (unspec:VB [(match_operand:V3x16QI 1 "register_operand" "w")
8593 (match_operand:VB 2 "register_operand" "w")]
8594 UNSPEC_TBL))]
8595 "TARGET_SIMD"
8596 "tbl\\t%S0.<Vbtype>, {%S1.16b - %U1.16b}, %S2.<Vbtype>"
8597 [(set_attr "type" "neon_tbl3")]
8598 )
8599
8600 (define_insn "aarch64_qtbx3<mode>"
8601 [(set (match_operand:VB 0 "register_operand" "=w")
8602 (unspec:VB [(match_operand:VB 1 "register_operand" "0")
8603 (match_operand:V3x16QI 2 "register_operand" "w")
8604 (match_operand:VB 3 "register_operand" "w")]
8605 UNSPEC_TBX))]
8606 "TARGET_SIMD"
8607 "tbx\\t%S0.<Vbtype>, {%S2.16b - %U2.16b}, %S3.<Vbtype>"
8608 [(set_attr "type" "neon_tbl3")]
8609 )
8610
8611 ;; Four source registers.
8612
8613 (define_insn "aarch64_qtbl4<mode>"
8614 [(set (match_operand:VB 0 "register_operand" "=w")
8615 (unspec:VB [(match_operand:V4x16QI 1 "register_operand" "w")
8616 (match_operand:VB 2 "register_operand" "w")]
8617 UNSPEC_TBL))]
8618 "TARGET_SIMD"
8619 "tbl\\t%S0.<Vbtype>, {%S1.16b - %V1.16b}, %S2.<Vbtype>"
8620 [(set_attr "type" "neon_tbl4")]
8621 )
8622
8623 (define_insn "aarch64_qtbx4<mode>"
8624 [(set (match_operand:VB 0 "register_operand" "=w")
8625 (unspec:VB [(match_operand:VB 1 "register_operand" "0")
8626 (match_operand:V4x16QI 2 "register_operand" "w")
8627 (match_operand:VB 3 "register_operand" "w")]
8628 UNSPEC_TBX))]
8629 "TARGET_SIMD"
8630 "tbx\\t%S0.<Vbtype>, {%S2.16b - %V2.16b}, %S3.<Vbtype>"
8631 [(set_attr "type" "neon_tbl4")]
8632 )
8633
8634 (define_insn_and_split "aarch64_combinev16qi"
8635 [(set (match_operand:V2x16QI 0 "register_operand" "=w")
8636 (unspec:V2x16QI [(match_operand:V16QI 1 "register_operand" "w")
8637 (match_operand:V16QI 2 "register_operand" "w")]
8638 UNSPEC_CONCAT))]
8639 "TARGET_SIMD"
8640 "#"
8641 "&& 1"
8642 [(const_int 0)]
8643 {
8644 aarch64_split_combinev16qi (operands);
8645 DONE;
8646 }
8647 [(set_attr "type" "multiple")]
8648 )
8649
8650 ;; This instruction's pattern is generated directly by
8651 ;; aarch64_expand_vec_perm_const, so any changes to the pattern would
8652 ;; need corresponding changes there.
8653 (define_insn "@aarch64_<PERMUTE:perm_insn><mode><vczle><vczbe>"
8654 [(set (match_operand:VALL_F16 0 "register_operand" "=w")
8655 (unspec:VALL_F16 [(match_operand:VALL_F16 1 "register_operand" "w")
8656 (match_operand:VALL_F16 2 "register_operand" "w")]
8657 PERMUTE))]
8658 "TARGET_SIMD"
8659 "<PERMUTE:perm_insn>\\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
8660 [(set_attr "type" "neon_permute<q>")]
8661 )
8662
8663 ;; ZIP1 ignores the contents of the upper halves of the registers,
8664 ;; so we can describe 128-bit operations in terms of 64-bit inputs.
8665 (define_insn "aarch64_zip1<mode>_low"
8666 [(set (match_operand:VQ 0 "register_operand" "=w")
8667 (unspec:VQ [(match_operand:<VHALF> 1 "register_operand" "w")
8668 (match_operand:<VHALF> 2 "register_operand" "w")]
8669 UNSPEC_ZIP1))]
8670 "TARGET_SIMD"
8671 "zip1\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
8672 [(set_attr "type" "neon_permute_q")]
8673 )
8674
8675 ;; This instruction's pattern is generated directly by
8676 ;; aarch64_expand_vec_perm_const, so any changes to the pattern would
8677 ;; need corresponding changes there. Note that the immediate (third)
8678 ;; operand is a lane index not a byte index.
8679 (define_insn "@aarch64_ext<mode>"
8680 [(set (match_operand:VALL_F16 0 "register_operand" "=w")
8681 (unspec:VALL_F16 [(match_operand:VALL_F16 1 "register_operand" "w")
8682 (match_operand:VALL_F16 2 "register_operand" "w")
8683 (match_operand:SI 3 "immediate_operand" "i")]
8684 UNSPEC_EXT))]
8685 "TARGET_SIMD"
8686 {
8687 operands[3] = GEN_INT (INTVAL (operands[3])
8688 * GET_MODE_UNIT_SIZE (<MODE>mode));
8689 return "ext\\t%0.<Vbtype>, %1.<Vbtype>, %2.<Vbtype>, #%3";
8690 }
8691 [(set_attr "type" "neon_ext<q>")]
8692 )
8693
8694 ;; This instruction's pattern is generated directly by
8695 ;; aarch64_expand_vec_perm_const, so any changes to the pattern would
8696 ;; need corresponding changes there.
8697 (define_insn "@aarch64_rev<REVERSE:rev_op><mode><vczle><vczbe>"
8698 [(set (match_operand:VALL_F16 0 "register_operand" "=w")
8699 (unspec:VALL_F16 [(match_operand:VALL_F16 1 "register_operand" "w")]
8700 REVERSE))]
8701 "TARGET_SIMD"
8702 "rev<REVERSE:rev_op>\\t%0.<Vtype>, %1.<Vtype>"
8703 [(set_attr "type" "neon_rev<q>")]
8704 )
8705
8706 (define_insn "aarch64_st2<vstruct_elt>_dreg"
8707 [(set (match_operand:VSTRUCT_2DNX 0 "aarch64_simd_struct_operand" "=Utv")
8708 (unspec:VSTRUCT_2DNX [
8709 (match_operand:VSTRUCT_2DNX 1 "register_operand" "w")]
8710 UNSPEC_ST2))]
8711 "TARGET_SIMD"
8712 "st2\\t{%S1.<Vtype> - %T1.<Vtype>}, %0"
8713 [(set_attr "type" "neon_store2_2reg")]
8714 )
8715
8716 (define_insn "aarch64_st2<vstruct_elt>_dreg"
8717 [(set (match_operand:VSTRUCT_2DX 0 "aarch64_simd_struct_operand" "=Utv")
8718 (unspec:VSTRUCT_2DX [
8719 (match_operand:VSTRUCT_2DX 1 "register_operand" "w")]
8720 UNSPEC_ST2))]
8721 "TARGET_SIMD"
8722 "st1\\t{%S1.1d - %T1.1d}, %0"
8723 [(set_attr "type" "neon_store1_2reg")]
8724 )
8725
8726 (define_insn "aarch64_st3<vstruct_elt>_dreg"
8727 [(set (match_operand:VSTRUCT_3DNX 0 "aarch64_simd_struct_operand" "=Utv")
8728 (unspec:VSTRUCT_3DNX [
8729 (match_operand:VSTRUCT_3DNX 1 "register_operand" "w")]
8730 UNSPEC_ST3))]
8731 "TARGET_SIMD"
8732 "st3\\t{%S1.<Vtype> - %U1.<Vtype>}, %0"
8733 [(set_attr "type" "neon_store3_3reg")]
8734 )
8735
8736 (define_insn "aarch64_st3<vstruct_elt>_dreg"
8737 [(set (match_operand:VSTRUCT_3DX 0 "aarch64_simd_struct_operand" "=Utv")
8738 (unspec:VSTRUCT_3DX [
8739 (match_operand:VSTRUCT_3DX 1 "register_operand" "w")]
8740 UNSPEC_ST3))]
8741 "TARGET_SIMD"
8742 "st1\\t{%S1.1d - %U1.1d}, %0"
8743 [(set_attr "type" "neon_store1_3reg")]
8744 )
8745
8746 (define_insn "aarch64_st4<vstruct_elt>_dreg"
8747 [(set (match_operand:VSTRUCT_4DNX 0 "aarch64_simd_struct_operand" "=Utv")
8748 (unspec:VSTRUCT_4DNX [
8749 (match_operand:VSTRUCT_4DNX 1 "register_operand" "w")]
8750 UNSPEC_ST4))]
8751 "TARGET_SIMD"
8752 "st4\\t{%S1.<Vtype> - %V1.<Vtype>}, %0"
8753 [(set_attr "type" "neon_store4_4reg")]
8754 )
8755
8756 (define_insn "aarch64_st4<vstruct_elt>_dreg"
8757 [(set (match_operand:VSTRUCT_4DX 0 "aarch64_simd_struct_operand" "=Utv")
8758 (unspec:VSTRUCT_4DX [
8759 (match_operand:VSTRUCT_4DX 1 "register_operand" "w")]
8760 UNSPEC_ST4))]
8761 "TARGET_SIMD"
8762 "st1\\t{%S1.1d - %V1.1d}, %0"
8763 [(set_attr "type" "neon_store1_4reg")]
8764 )
8765
8766 (define_expand "@aarch64_st<nregs><vstruct_elt>"
8767 [(match_operand:DI 0 "register_operand")
8768 (match_operand:VSTRUCT_D 1 "register_operand")]
8769 "TARGET_SIMD"
8770 {
8771 rtx mem = gen_rtx_MEM (<MODE>mode, operands[0]);
8772 emit_insn (gen_aarch64_st<nregs><vstruct_elt>_dreg (mem, operands[1]));
8773 DONE;
8774 })
8775
8776 (define_expand "@aarch64_st<nregs><vstruct_elt>"
8777 [(match_operand:DI 0 "register_operand")
8778 (match_operand:VSTRUCT_Q 1 "register_operand")]
8779 "TARGET_SIMD"
8780 {
8781 rtx mem = gen_rtx_MEM (<MODE>mode, operands[0]);
8782 emit_insn (gen_aarch64_simd_st<nregs><vstruct_elt> (mem, operands[1]));
8783 DONE;
8784 })
8785
8786 (define_expand "@aarch64_st<nregs>_lane<vstruct_elt>"
8787 [(match_operand:DI 0 "register_operand")
8788 (match_operand:VSTRUCT_QD 1 "register_operand")
8789 (match_operand:SI 2 "immediate_operand")]
8790 "TARGET_SIMD"
8791 {
8792 rtx mem = gen_rtx_MEM (BLKmode, operands[0]);
8793 set_mem_size (mem, GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) * <nregs>);
8794
8795 aarch64_simd_lane_bounds (operands[2], 0,
8796 GET_MODE_NUNITS (<MODE>mode).to_constant () / <nregs>, NULL);
8797 emit_insn (gen_aarch64_vec_store_lanes<mode>_lane<vstruct_elt> (mem,
8798 operands[1], operands[2]));
8799 DONE;
8800 })
8801
8802 (define_expand "@aarch64_st1<VALL_F16:mode>"
8803 [(match_operand:DI 0 "register_operand")
8804 (match_operand:VALL_F16 1 "register_operand")]
8805 "TARGET_SIMD"
8806 {
8807 machine_mode mode = <VALL_F16:MODE>mode;
8808 rtx mem = gen_rtx_MEM (mode, operands[0]);
8809
8810 if (BYTES_BIG_ENDIAN)
8811 emit_insn (gen_aarch64_be_st1<VALL_F16:mode> (mem, operands[1]));
8812 else
8813 emit_move_insn (mem, operands[1]);
8814 DONE;
8815 })
8816
8817 ;; Standard pattern name vec_init<mode><Vel>.
8818
8819 (define_expand "vec_init<mode><Vel>"
8820 [(match_operand:VALL_F16 0 "register_operand")
8821 (match_operand 1 "" "")]
8822 "TARGET_SIMD"
8823 {
8824 aarch64_expand_vector_init (operands[0], operands[1]);
8825 DONE;
8826 })
8827
8828 (define_expand "vec_init<mode><Vhalf>"
8829 [(match_operand:VQ_NO2E 0 "register_operand")
8830 (match_operand 1 "" "")]
8831 "TARGET_SIMD"
8832 {
8833 aarch64_expand_vector_init (operands[0], operands[1]);
8834 DONE;
8835 })
8836
8837 (define_insn "*aarch64_simd_ld1r<mode>"
8838 [(set (match_operand:VALL_F16 0 "register_operand" "=w")
8839 (vec_duplicate:VALL_F16
8840 (match_operand:<VEL> 1 "aarch64_simd_struct_operand" "Utv")))]
8841 "TARGET_SIMD"
8842 "ld1r\\t{%0.<Vtype>}, %1"
8843 [(set_attr "type" "neon_load1_all_lanes")]
8844 )
8845
8846 (define_insn "aarch64_simd_ld1<vstruct_elt>_x2"
8847 [(set (match_operand:VSTRUCT_2QD 0 "register_operand" "=w")
8848 (unspec:VSTRUCT_2QD [
8849 (match_operand:VSTRUCT_2QD 1 "aarch64_simd_struct_operand" "Utv")]
8850 UNSPEC_LD1))]
8851 "TARGET_SIMD"
8852 "ld1\\t{%S0.<Vtype> - %T0.<Vtype>}, %1"
8853 [(set_attr "type" "neon_load1_2reg<q>")]
8854 )
8855
8856
8857 (define_insn "@aarch64_frecpe<mode>"
8858 [(set (match_operand:VHSDF_HSDF 0 "register_operand" "=w")
8859 (unspec:VHSDF_HSDF
8860 [(match_operand:VHSDF_HSDF 1 "register_operand" "w")]
8861 UNSPEC_FRECPE))]
8862 "TARGET_SIMD"
8863 "frecpe\t%<v>0<Vmtype>, %<v>1<Vmtype>"
8864 [(set_attr "type" "neon_fp_recpe_<stype><q>")]
8865 )
8866
8867 (define_insn "aarch64_frecpx<mode>"
8868 [(set (match_operand:GPF_F16 0 "register_operand" "=w")
8869 (unspec:GPF_F16 [(match_operand:GPF_F16 1 "register_operand" "w")]
8870 UNSPEC_FRECPX))]
8871 "TARGET_SIMD"
8872 "frecpx\t%<s>0, %<s>1"
8873 [(set_attr "type" "neon_fp_recpx_<GPF_F16:stype>")]
8874 )
8875
8876 (define_insn "@aarch64_frecps<mode>"
8877 [(set (match_operand:VHSDF_HSDF 0 "register_operand" "=w")
8878 (unspec:VHSDF_HSDF
8879 [(match_operand:VHSDF_HSDF 1 "register_operand" "w")
8880 (match_operand:VHSDF_HSDF 2 "register_operand" "w")]
8881 UNSPEC_FRECPS))]
8882 "TARGET_SIMD"
8883 "frecps\\t%<v>0<Vmtype>, %<v>1<Vmtype>, %<v>2<Vmtype>"
8884 [(set_attr "type" "neon_fp_recps_<stype><q>")]
8885 )
8886
8887 (define_insn "aarch64_urecpe<mode>"
8888 [(set (match_operand:VDQ_SI 0 "register_operand" "=w")
8889 (unspec:VDQ_SI [(match_operand:VDQ_SI 1 "register_operand" "w")]
8890 UNSPEC_URECPE))]
8891 "TARGET_SIMD"
8892 "urecpe\\t%0.<Vtype>, %1.<Vtype>"
8893 [(set_attr "type" "neon_fp_recpe_<Vetype><q>")])
8894
8895 ;; Standard pattern name vec_extract<mode><Vel>.
8896
8897 (define_expand "vec_extract<mode><Vel>"
8898 [(match_operand:<VEL> 0 "aarch64_simd_nonimmediate_operand")
8899 (match_operand:VALL_F16 1 "register_operand")
8900 (match_operand:SI 2 "immediate_operand")]
8901 "TARGET_SIMD"
8902 {
8903 emit_insn
8904 (gen_aarch64_get_lane<mode> (operands[0], operands[1], operands[2]));
8905 DONE;
8906 })
8907
8908 ;; Extract a 64-bit vector from one half of a 128-bit vector.
8909 (define_expand "vec_extract<mode><Vhalf>"
8910 [(match_operand:<VHALF> 0 "register_operand")
8911 (match_operand:VQMOV_NO2E 1 "register_operand")
8912 (match_operand 2 "immediate_operand")]
8913 "TARGET_SIMD"
8914 {
8915 int start = INTVAL (operands[2]);
8916 gcc_assert (start == 0 || start == 1);
8917 start *= <nunits> / 2;
8918 rtx sel = aarch64_gen_stepped_int_parallel (<nunits> / 2, start, 1);
8919 emit_insn (gen_aarch64_get_half<mode> (operands[0], operands[1], sel));
8920 DONE;
8921 })
8922
8923 ;; Extract a single-element 64-bit vector from one half of a 128-bit vector.
8924 (define_expand "vec_extract<mode><V1half>"
8925 [(match_operand:<V1HALF> 0 "register_operand")
8926 (match_operand:VQ_2E 1 "register_operand")
8927 (match_operand 2 "immediate_operand")]
8928 "TARGET_SIMD"
8929 {
8930 /* V1DI and V1DF are rarely used by other patterns, so it should be better
8931 to hide it in a subreg destination of a normal DI or DF op. */
8932 rtx scalar0 = gen_lowpart (<VHALF>mode, operands[0]);
8933 emit_insn (gen_vec_extract<mode><Vhalf> (scalar0, operands[1], operands[2]));
8934 DONE;
8935 })
8936
8937 ;; aes
8938
8939 (define_insn "aarch64_crypto_aes<aes_op>v16qi"
8940 [(set (match_operand:V16QI 0 "register_operand" "=w")
8941 (unspec:V16QI
8942 [(xor:V16QI
8943 (match_operand:V16QI 1 "register_operand" "%0")
8944 (match_operand:V16QI 2 "register_operand" "w"))]
8945 CRYPTO_AES))]
8946 "TARGET_AES"
8947 "aes<aes_op>\\t%0.16b, %2.16b"
8948 [(set_attr "type" "crypto_aese")]
8949 )
8950
8951 (define_insn "aarch64_crypto_aes<aesmc_op>v16qi"
8952 [(set (match_operand:V16QI 0 "register_operand" "=w")
8953 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "w")]
8954 CRYPTO_AESMC))]
8955 "TARGET_AES"
8956 "aes<aesmc_op>\\t%0.16b, %1.16b"
8957 [(set_attr "type" "crypto_aesmc")]
8958 )
8959
8960 ;; When AESE/AESMC fusion is enabled we really want to keep the two together
8961 ;; and enforce the register dependency without scheduling or register
8962 ;; allocation messing up the order or introducing moves inbetween.
8963 ;; Mash the two together during combine.
8964
8965 (define_insn "*aarch64_crypto_aese_fused"
8966 [(set (match_operand:V16QI 0 "register_operand" "=w")
8967 (unspec:V16QI
8968 [(unspec:V16QI
8969 [(xor:V16QI
8970 (match_operand:V16QI 1 "register_operand" "%0")
8971 (match_operand:V16QI 2 "register_operand" "w"))]
8972 UNSPEC_AESE)]
8973 UNSPEC_AESMC))]
8974 "TARGET_AES
8975 && aarch64_fusion_enabled_p (AARCH64_FUSE_AES_AESMC)"
8976 "aese\\t%0.16b, %2.16b\;aesmc\\t%0.16b, %0.16b"
8977 [(set_attr "type" "crypto_aese")
8978 (set_attr "length" "8")]
8979 )
8980
8981 ;; When AESD/AESIMC fusion is enabled we really want to keep the two together
8982 ;; and enforce the register dependency without scheduling or register
8983 ;; allocation messing up the order or introducing moves inbetween.
8984 ;; Mash the two together during combine.
8985
8986 (define_insn "*aarch64_crypto_aesd_fused"
8987 [(set (match_operand:V16QI 0 "register_operand" "=w")
8988 (unspec:V16QI
8989 [(unspec:V16QI
8990 [(xor:V16QI
8991 (match_operand:V16QI 1 "register_operand" "%0")
8992 (match_operand:V16QI 2 "register_operand" "w"))]
8993 UNSPEC_AESD)]
8994 UNSPEC_AESIMC))]
8995 "TARGET_AES
8996 && aarch64_fusion_enabled_p (AARCH64_FUSE_AES_AESMC)"
8997 "aesd\\t%0.16b, %2.16b\;aesimc\\t%0.16b, %0.16b"
8998 [(set_attr "type" "crypto_aese")
8999 (set_attr "length" "8")]
9000 )
9001
9002 ;; sha1
9003
9004 (define_insn "aarch64_crypto_sha1hsi"
9005 [(set (match_operand:SI 0 "register_operand" "=w")
9006 (unspec:SI [(match_operand:SI 1
9007 "register_operand" "w")]
9008 UNSPEC_SHA1H))]
9009 "TARGET_SHA2"
9010 "sha1h\\t%s0, %s1"
9011 [(set_attr "type" "crypto_sha1_fast")]
9012 )
9013
9014 (define_insn "aarch64_crypto_sha1hv4si"
9015 [(set (match_operand:SI 0 "register_operand" "=w")
9016 (unspec:SI [(vec_select:SI (match_operand:V4SI 1 "register_operand" "w")
9017 (parallel [(const_int 0)]))]
9018 UNSPEC_SHA1H))]
9019 "TARGET_SHA2 && !BYTES_BIG_ENDIAN"
9020 "sha1h\\t%s0, %s1"
9021 [(set_attr "type" "crypto_sha1_fast")]
9022 )
9023
9024 (define_insn "aarch64_be_crypto_sha1hv4si"
9025 [(set (match_operand:SI 0 "register_operand" "=w")
9026 (unspec:SI [(vec_select:SI (match_operand:V4SI 1 "register_operand" "w")
9027 (parallel [(const_int 3)]))]
9028 UNSPEC_SHA1H))]
9029 "TARGET_SHA2 && BYTES_BIG_ENDIAN"
9030 "sha1h\\t%s0, %s1"
9031 [(set_attr "type" "crypto_sha1_fast")]
9032 )
9033
9034 (define_insn "aarch64_crypto_sha1su1v4si"
9035 [(set (match_operand:V4SI 0 "register_operand" "=w")
9036 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "0")
9037 (match_operand:V4SI 2 "register_operand" "w")]
9038 UNSPEC_SHA1SU1))]
9039 "TARGET_SHA2"
9040 "sha1su1\\t%0.4s, %2.4s"
9041 [(set_attr "type" "crypto_sha1_fast")]
9042 )
9043
9044 (define_insn "aarch64_crypto_sha1<sha1_op>v4si"
9045 [(set (match_operand:V4SI 0 "register_operand" "=w")
9046 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "0")
9047 (match_operand:SI 2 "register_operand" "w")
9048 (match_operand:V4SI 3 "register_operand" "w")]
9049 CRYPTO_SHA1))]
9050 "TARGET_SHA2"
9051 "sha1<sha1_op>\\t%q0, %s2, %3.4s"
9052 [(set_attr "type" "crypto_sha1_slow")]
9053 )
9054
9055 (define_insn "aarch64_crypto_sha1su0v4si"
9056 [(set (match_operand:V4SI 0 "register_operand" "=w")
9057 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "0")
9058 (match_operand:V4SI 2 "register_operand" "w")
9059 (match_operand:V4SI 3 "register_operand" "w")]
9060 UNSPEC_SHA1SU0))]
9061 "TARGET_SHA2"
9062 "sha1su0\\t%0.4s, %2.4s, %3.4s"
9063 [(set_attr "type" "crypto_sha1_xor")]
9064 )
9065
9066 ;; sha256
9067
9068 (define_insn "aarch64_crypto_sha256h<sha256_op>v4si"
9069 [(set (match_operand:V4SI 0 "register_operand" "=w")
9070 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "0")
9071 (match_operand:V4SI 2 "register_operand" "w")
9072 (match_operand:V4SI 3 "register_operand" "w")]
9073 CRYPTO_SHA256))]
9074 "TARGET_SHA2"
9075 "sha256h<sha256_op>\\t%q0, %q2, %3.4s"
9076 [(set_attr "type" "crypto_sha256_slow")]
9077 )
9078
9079 (define_insn "aarch64_crypto_sha256su0v4si"
9080 [(set (match_operand:V4SI 0 "register_operand" "=w")
9081 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "0")
9082 (match_operand:V4SI 2 "register_operand" "w")]
9083 UNSPEC_SHA256SU0))]
9084 "TARGET_SHA2"
9085 "sha256su0\\t%0.4s, %2.4s"
9086 [(set_attr "type" "crypto_sha256_fast")]
9087 )
9088
9089 (define_insn "aarch64_crypto_sha256su1v4si"
9090 [(set (match_operand:V4SI 0 "register_operand" "=w")
9091 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "0")
9092 (match_operand:V4SI 2 "register_operand" "w")
9093 (match_operand:V4SI 3 "register_operand" "w")]
9094 UNSPEC_SHA256SU1))]
9095 "TARGET_SHA2"
9096 "sha256su1\\t%0.4s, %2.4s, %3.4s"
9097 [(set_attr "type" "crypto_sha256_slow")]
9098 )
9099
9100 ;; sha512
9101
9102 (define_insn "aarch64_crypto_sha512h<sha512_op>qv2di"
9103 [(set (match_operand:V2DI 0 "register_operand" "=w")
9104 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
9105 (match_operand:V2DI 2 "register_operand" "w")
9106 (match_operand:V2DI 3 "register_operand" "w")]
9107 CRYPTO_SHA512))]
9108 "TARGET_SHA3"
9109 "sha512h<sha512_op>\\t%q0, %q2, %3.2d"
9110 [(set_attr "type" "crypto_sha512")]
9111 )
9112
9113 (define_insn "aarch64_crypto_sha512su0qv2di"
9114 [(set (match_operand:V2DI 0 "register_operand" "=w")
9115 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
9116 (match_operand:V2DI 2 "register_operand" "w")]
9117 UNSPEC_SHA512SU0))]
9118 "TARGET_SHA3"
9119 "sha512su0\\t%0.2d, %2.2d"
9120 [(set_attr "type" "crypto_sha512")]
9121 )
9122
9123 (define_insn "aarch64_crypto_sha512su1qv2di"
9124 [(set (match_operand:V2DI 0 "register_operand" "=w")
9125 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
9126 (match_operand:V2DI 2 "register_operand" "w")
9127 (match_operand:V2DI 3 "register_operand" "w")]
9128 UNSPEC_SHA512SU1))]
9129 "TARGET_SHA3"
9130 "sha512su1\\t%0.2d, %2.2d, %3.2d"
9131 [(set_attr "type" "crypto_sha512")]
9132 )
9133
9134 ;; sha3
9135
9136 (define_insn "eor3q<mode>4"
9137 [(set (match_operand:VQ_I 0 "register_operand" "=w")
9138 (xor:VQ_I
9139 (xor:VQ_I
9140 (match_operand:VQ_I 2 "register_operand" "w")
9141 (match_operand:VQ_I 3 "register_operand" "w"))
9142 (match_operand:VQ_I 1 "register_operand" "w")))]
9143 "TARGET_SHA3"
9144 "eor3\\t%0.16b, %1.16b, %2.16b, %3.16b"
9145 [(set_attr "type" "crypto_sha3")]
9146 )
9147
9148 (define_insn "aarch64_rax1qv2di"
9149 [(set (match_operand:V2DI 0 "register_operand" "=w")
9150 (xor:V2DI
9151 (rotate:V2DI
9152 (match_operand:V2DI 2 "register_operand" "w")
9153 (const_int 1))
9154 (match_operand:V2DI 1 "register_operand" "w")))]
9155 "TARGET_SHA3"
9156 "rax1\\t%0.2d, %1.2d, %2.2d"
9157 [(set_attr "type" "crypto_sha3")]
9158 )
9159
9160 (define_insn "*aarch64_xarqv2di_insn"
9161 [(set (match_operand:V2DI 0 "register_operand" "=w")
9162 (rotate:V2DI
9163 (xor:V2DI
9164 (match_operand:V2DI 1 "register_operand" "%w")
9165 (match_operand:V2DI 2 "register_operand" "w"))
9166 (match_operand:V2DI 3 "aarch64_simd_lshift_imm" "Dl")))]
9167 "TARGET_SHA3"
9168 {
9169 /* Translate the RTL left-rotate amount into the assembly right-rotate
9170 amount. Modulo by 64 to ensure that a left-rotate of 0 is emitted
9171 as a right-rotate of 0 as accepted by the assembly instruction. */
9172 operands[3]
9173 = GEN_INT ((64 - INTVAL (unwrap_const_vec_duplicate (operands[3])))
9174 % 64);
9175 return "xar\\t%0.2d, %1.2d, %2.2d, #%3";
9176 }
9177 [(set_attr "type" "crypto_sha3")]
9178 )
9179
9180 ;; The semantics of the vxarq_u64 intrinsics treat the immediate argument as a
9181 ;; right-rotate amount but the recommended representation of rotates by a
9182 ;; constant in RTL is with the left ROTATE code. Translate between the
9183 ;; intrinsic-provided amount and the RTL operands in the expander here.
9184 ;; The define_insn for XAR will translate back to instruction semantics in its
9185 ;; output logic.
9186 (define_expand "aarch64_xarqv2di"
9187 [(set (match_operand:V2DI 0 "register_operand")
9188 (rotate:V2DI
9189 (xor:V2DI
9190 (match_operand:V2DI 1 "register_operand")
9191 (match_operand:V2DI 2 "register_operand"))
9192 (match_operand:SI 3 "aarch64_simd_shift_imm_di")))]
9193 "TARGET_SHA3"
9194 {
9195 operands[3]
9196 = aarch64_simd_gen_const_vector_dup (V2DImode,
9197 /* In the edge case of a 0 rotate
9198 amount leave as is. */
9199 operands[3] == CONST0_RTX (SImode)
9200 ? 0 : 64 - INTVAL (operands[3]));
9201 }
9202 )
9203
9204 (define_insn "bcaxq<mode>4"
9205 [(set (match_operand:VQ_I 0 "register_operand" "=w")
9206 (xor:VQ_I
9207 (and:VQ_I
9208 (not:VQ_I (match_operand:VQ_I 3 "register_operand" "w"))
9209 (match_operand:VQ_I 2 "register_operand" "w"))
9210 (match_operand:VQ_I 1 "register_operand" "w")))]
9211 "TARGET_SHA3"
9212 "bcax\\t%0.16b, %1.16b, %2.16b, %3.16b"
9213 [(set_attr "type" "crypto_sha3")]
9214 )
9215
9216 ;; SM3
9217
9218 (define_insn "aarch64_sm3ss1qv4si"
9219 [(set (match_operand:V4SI 0 "register_operand" "=w")
9220 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "w")
9221 (match_operand:V4SI 2 "register_operand" "w")
9222 (match_operand:V4SI 3 "register_operand" "w")]
9223 UNSPEC_SM3SS1))]
9224 "TARGET_SM4"
9225 "sm3ss1\\t%0.4s, %1.4s, %2.4s, %3.4s"
9226 [(set_attr "type" "crypto_sm3")]
9227 )
9228
9229
9230 (define_insn "aarch64_sm3tt<sm3tt_op>qv4si"
9231 [(set (match_operand:V4SI 0 "register_operand" "=w")
9232 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "0")
9233 (match_operand:V4SI 2 "register_operand" "w")
9234 (match_operand:V4SI 3 "register_operand" "w")
9235 (match_operand:SI 4 "aarch64_imm2" "Ui2")]
9236 CRYPTO_SM3TT))]
9237 "TARGET_SM4"
9238 "sm3tt<sm3tt_op>\\t%0.4s, %2.4s, %3.4s[%4]"
9239 [(set_attr "type" "crypto_sm3")]
9240 )
9241
9242 (define_insn "aarch64_sm3partw<sm3part_op>qv4si"
9243 [(set (match_operand:V4SI 0 "register_operand" "=w")
9244 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "0")
9245 (match_operand:V4SI 2 "register_operand" "w")
9246 (match_operand:V4SI 3 "register_operand" "w")]
9247 CRYPTO_SM3PART))]
9248 "TARGET_SM4"
9249 "sm3partw<sm3part_op>\\t%0.4s, %2.4s, %3.4s"
9250 [(set_attr "type" "crypto_sm3")]
9251 )
9252
9253 ;; SM4
9254
9255 (define_insn "aarch64_sm4eqv4si"
9256 [(set (match_operand:V4SI 0 "register_operand" "=w")
9257 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "0")
9258 (match_operand:V4SI 2 "register_operand" "w")]
9259 UNSPEC_SM4E))]
9260 "TARGET_SM4"
9261 "sm4e\\t%0.4s, %2.4s"
9262 [(set_attr "type" "crypto_sm4")]
9263 )
9264
9265 (define_insn "aarch64_sm4ekeyqv4si"
9266 [(set (match_operand:V4SI 0 "register_operand" "=w")
9267 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "w")
9268 (match_operand:V4SI 2 "register_operand" "w")]
9269 UNSPEC_SM4EKEY))]
9270 "TARGET_SM4"
9271 "sm4ekey\\t%0.4s, %1.4s, %2.4s"
9272 [(set_attr "type" "crypto_sm4")]
9273 )
9274
9275 ;; fp16fml
9276
9277 (define_expand "aarch64_fml<f16mac1>l<f16quad>_low<mode>"
9278 [(set (match_operand:VDQSF 0 "register_operand")
9279 (unspec:VDQSF
9280 [(match_operand:VDQSF 1 "register_operand")
9281 (match_operand:<VFMLA_W> 2 "register_operand")
9282 (match_operand:<VFMLA_W> 3 "register_operand")]
9283 VFMLA16_LOW))]
9284 "TARGET_F16FML"
9285 {
9286 rtx p1 = aarch64_simd_vect_par_cnst_half (<VFMLA_W>mode,
9287 <nunits> * 2, false);
9288 rtx p2 = aarch64_simd_vect_par_cnst_half (<VFMLA_W>mode,
9289 <nunits> * 2, false);
9290
9291 emit_insn (gen_aarch64_simd_fml<f16mac1>l<f16quad>_low<mode> (operands[0],
9292 operands[1],
9293 operands[2],
9294 operands[3],
9295 p1, p2));
9296 DONE;
9297
9298 })
9299
9300 (define_expand "aarch64_fml<f16mac1>l<f16quad>_high<mode>"
9301 [(set (match_operand:VDQSF 0 "register_operand")
9302 (unspec:VDQSF
9303 [(match_operand:VDQSF 1 "register_operand")
9304 (match_operand:<VFMLA_W> 2 "register_operand")
9305 (match_operand:<VFMLA_W> 3 "register_operand")]
9306 VFMLA16_HIGH))]
9307 "TARGET_F16FML"
9308 {
9309 rtx p1 = aarch64_simd_vect_par_cnst_half (<VFMLA_W>mode, <nunits> * 2, true);
9310 rtx p2 = aarch64_simd_vect_par_cnst_half (<VFMLA_W>mode, <nunits> * 2, true);
9311
9312 emit_insn (gen_aarch64_simd_fml<f16mac1>l<f16quad>_high<mode> (operands[0],
9313 operands[1],
9314 operands[2],
9315 operands[3],
9316 p1, p2));
9317 DONE;
9318 })
9319
9320 (define_insn "aarch64_simd_fmlal<f16quad>_low<mode>"
9321 [(set (match_operand:VDQSF 0 "register_operand" "=w")
9322 (fma:VDQSF
9323 (float_extend:VDQSF
9324 (vec_select:<VFMLA_SEL_W>
9325 (match_operand:<VFMLA_W> 2 "register_operand" "w")
9326 (match_operand:<VFMLA_W> 4 "vect_par_cnst_lo_half" "")))
9327 (float_extend:VDQSF
9328 (vec_select:<VFMLA_SEL_W>
9329 (match_operand:<VFMLA_W> 3 "register_operand" "w")
9330 (match_operand:<VFMLA_W> 5 "vect_par_cnst_lo_half" "")))
9331 (match_operand:VDQSF 1 "register_operand" "0")))]
9332 "TARGET_F16FML"
9333 "fmlal\\t%0.<nunits>s, %2.<nunits>h, %3.<nunits>h"
9334 [(set_attr "type" "neon_fp_mul_s")]
9335 )
9336
9337 (define_insn "aarch64_simd_fmlsl<f16quad>_low<mode>"
9338 [(set (match_operand:VDQSF 0 "register_operand" "=w")
9339 (fma:VDQSF
9340 (float_extend:VDQSF
9341 (neg:<VFMLA_SEL_W>
9342 (vec_select:<VFMLA_SEL_W>
9343 (match_operand:<VFMLA_W> 2 "register_operand" "w")
9344 (match_operand:<VFMLA_W> 4 "vect_par_cnst_lo_half" ""))))
9345 (float_extend:VDQSF
9346 (vec_select:<VFMLA_SEL_W>
9347 (match_operand:<VFMLA_W> 3 "register_operand" "w")
9348 (match_operand:<VFMLA_W> 5 "vect_par_cnst_lo_half" "")))
9349 (match_operand:VDQSF 1 "register_operand" "0")))]
9350 "TARGET_F16FML"
9351 "fmlsl\\t%0.<nunits>s, %2.<nunits>h, %3.<nunits>h"
9352 [(set_attr "type" "neon_fp_mul_s")]
9353 )
9354
9355 (define_insn "aarch64_simd_fmlal<f16quad>_high<mode>"
9356 [(set (match_operand:VDQSF 0 "register_operand" "=w")
9357 (fma:VDQSF
9358 (float_extend:VDQSF
9359 (vec_select:<VFMLA_SEL_W>
9360 (match_operand:<VFMLA_W> 2 "register_operand" "w")
9361 (match_operand:<VFMLA_W> 4 "vect_par_cnst_hi_half" "")))
9362 (float_extend:VDQSF
9363 (vec_select:<VFMLA_SEL_W>
9364 (match_operand:<VFMLA_W> 3 "register_operand" "w")
9365 (match_operand:<VFMLA_W> 5 "vect_par_cnst_hi_half" "")))
9366 (match_operand:VDQSF 1 "register_operand" "0")))]
9367 "TARGET_F16FML"
9368 "fmlal2\\t%0.<nunits>s, %2.<nunits>h, %3.<nunits>h"
9369 [(set_attr "type" "neon_fp_mul_s")]
9370 )
9371
9372 (define_insn "aarch64_simd_fmlsl<f16quad>_high<mode>"
9373 [(set (match_operand:VDQSF 0 "register_operand" "=w")
9374 (fma:VDQSF
9375 (float_extend:VDQSF
9376 (neg:<VFMLA_SEL_W>
9377 (vec_select:<VFMLA_SEL_W>
9378 (match_operand:<VFMLA_W> 2 "register_operand" "w")
9379 (match_operand:<VFMLA_W> 4 "vect_par_cnst_hi_half" ""))))
9380 (float_extend:VDQSF
9381 (vec_select:<VFMLA_SEL_W>
9382 (match_operand:<VFMLA_W> 3 "register_operand" "w")
9383 (match_operand:<VFMLA_W> 5 "vect_par_cnst_hi_half" "")))
9384 (match_operand:VDQSF 1 "register_operand" "0")))]
9385 "TARGET_F16FML"
9386 "fmlsl2\\t%0.<nunits>s, %2.<nunits>h, %3.<nunits>h"
9387 [(set_attr "type" "neon_fp_mul_s")]
9388 )
9389
9390 (define_expand "aarch64_fml<f16mac1>l_lane_lowv2sf"
9391 [(set (match_operand:V2SF 0 "register_operand")
9392 (unspec:V2SF [(match_operand:V2SF 1 "register_operand")
9393 (match_operand:V4HF 2 "register_operand")
9394 (match_operand:V4HF 3 "register_operand")
9395 (match_operand:SI 4 "aarch64_imm2")]
9396 VFMLA16_LOW))]
9397 "TARGET_F16FML"
9398 {
9399 rtx p1 = aarch64_simd_vect_par_cnst_half (V4HFmode, 4, false);
9400 rtx lane = aarch64_endian_lane_rtx (V4HFmode, INTVAL (operands[4]));
9401
9402 emit_insn (gen_aarch64_simd_fml<f16mac1>l_lane_lowv2sf (operands[0],
9403 operands[1],
9404 operands[2],
9405 operands[3],
9406 p1, lane));
9407 DONE;
9408 }
9409 )
9410
9411 (define_expand "aarch64_fml<f16mac1>l_lane_highv2sf"
9412 [(set (match_operand:V2SF 0 "register_operand")
9413 (unspec:V2SF [(match_operand:V2SF 1 "register_operand")
9414 (match_operand:V4HF 2 "register_operand")
9415 (match_operand:V4HF 3 "register_operand")
9416 (match_operand:SI 4 "aarch64_imm2")]
9417 VFMLA16_HIGH))]
9418 "TARGET_F16FML"
9419 {
9420 rtx p1 = aarch64_simd_vect_par_cnst_half (V4HFmode, 4, true);
9421 rtx lane = aarch64_endian_lane_rtx (V4HFmode, INTVAL (operands[4]));
9422
9423 emit_insn (gen_aarch64_simd_fml<f16mac1>l_lane_highv2sf (operands[0],
9424 operands[1],
9425 operands[2],
9426 operands[3],
9427 p1, lane));
9428 DONE;
9429 })
9430
9431 (define_insn "aarch64_simd_fmlal_lane_lowv2sf"
9432 [(set (match_operand:V2SF 0 "register_operand" "=w")
9433 (fma:V2SF
9434 (float_extend:V2SF
9435 (vec_select:V2HF
9436 (match_operand:V4HF 2 "register_operand" "w")
9437 (match_operand:V4HF 4 "vect_par_cnst_lo_half" "")))
9438 (float_extend:V2SF
9439 (vec_duplicate:V2HF
9440 (vec_select:HF
9441 (match_operand:V4HF 3 "register_operand" "x")
9442 (parallel [(match_operand:SI 5 "aarch64_imm2" "Ui2")]))))
9443 (match_operand:V2SF 1 "register_operand" "0")))]
9444 "TARGET_F16FML"
9445 "fmlal\\t%0.2s, %2.2h, %3.h[%5]"
9446 [(set_attr "type" "neon_fp_mul_s")]
9447 )
9448
9449 (define_insn "aarch64_simd_fmlsl_lane_lowv2sf"
9450 [(set (match_operand:V2SF 0 "register_operand" "=w")
9451 (fma:V2SF
9452 (float_extend:V2SF
9453 (neg:V2HF
9454 (vec_select:V2HF
9455 (match_operand:V4HF 2 "register_operand" "w")
9456 (match_operand:V4HF 4 "vect_par_cnst_lo_half" ""))))
9457 (float_extend:V2SF
9458 (vec_duplicate:V2HF
9459 (vec_select:HF
9460 (match_operand:V4HF 3 "register_operand" "x")
9461 (parallel [(match_operand:SI 5 "aarch64_imm2" "Ui2")]))))
9462 (match_operand:V2SF 1 "register_operand" "0")))]
9463 "TARGET_F16FML"
9464 "fmlsl\\t%0.2s, %2.2h, %3.h[%5]"
9465 [(set_attr "type" "neon_fp_mul_s")]
9466 )
9467
9468 (define_insn "aarch64_simd_fmlal_lane_highv2sf"
9469 [(set (match_operand:V2SF 0 "register_operand" "=w")
9470 (fma:V2SF
9471 (float_extend:V2SF
9472 (vec_select:V2HF
9473 (match_operand:V4HF 2 "register_operand" "w")
9474 (match_operand:V4HF 4 "vect_par_cnst_hi_half" "")))
9475 (float_extend:V2SF
9476 (vec_duplicate:V2HF
9477 (vec_select:HF
9478 (match_operand:V4HF 3 "register_operand" "x")
9479 (parallel [(match_operand:SI 5 "aarch64_imm2" "Ui2")]))))
9480 (match_operand:V2SF 1 "register_operand" "0")))]
9481 "TARGET_F16FML"
9482 "fmlal2\\t%0.2s, %2.2h, %3.h[%5]"
9483 [(set_attr "type" "neon_fp_mul_s")]
9484 )
9485
9486 (define_insn "aarch64_simd_fmlsl_lane_highv2sf"
9487 [(set (match_operand:V2SF 0 "register_operand" "=w")
9488 (fma:V2SF
9489 (float_extend:V2SF
9490 (neg:V2HF
9491 (vec_select:V2HF
9492 (match_operand:V4HF 2 "register_operand" "w")
9493 (match_operand:V4HF 4 "vect_par_cnst_hi_half" ""))))
9494 (float_extend:V2SF
9495 (vec_duplicate:V2HF
9496 (vec_select:HF
9497 (match_operand:V4HF 3 "register_operand" "x")
9498 (parallel [(match_operand:SI 5 "aarch64_imm2" "Ui2")]))))
9499 (match_operand:V2SF 1 "register_operand" "0")))]
9500 "TARGET_F16FML"
9501 "fmlsl2\\t%0.2s, %2.2h, %3.h[%5]"
9502 [(set_attr "type" "neon_fp_mul_s")]
9503 )
9504
9505 (define_expand "aarch64_fml<f16mac1>lq_laneq_lowv4sf"
9506 [(set (match_operand:V4SF 0 "register_operand")
9507 (unspec:V4SF [(match_operand:V4SF 1 "register_operand")
9508 (match_operand:V8HF 2 "register_operand")
9509 (match_operand:V8HF 3 "register_operand")
9510 (match_operand:SI 4 "aarch64_lane_imm3")]
9511 VFMLA16_LOW))]
9512 "TARGET_F16FML"
9513 {
9514 rtx p1 = aarch64_simd_vect_par_cnst_half (V8HFmode, 8, false);
9515 rtx lane = aarch64_endian_lane_rtx (V8HFmode, INTVAL (operands[4]));
9516
9517 emit_insn (gen_aarch64_simd_fml<f16mac1>lq_laneq_lowv4sf (operands[0],
9518 operands[1],
9519 operands[2],
9520 operands[3],
9521 p1, lane));
9522 DONE;
9523 })
9524
9525 (define_expand "aarch64_fml<f16mac1>lq_laneq_highv4sf"
9526 [(set (match_operand:V4SF 0 "register_operand")
9527 (unspec:V4SF [(match_operand:V4SF 1 "register_operand")
9528 (match_operand:V8HF 2 "register_operand")
9529 (match_operand:V8HF 3 "register_operand")
9530 (match_operand:SI 4 "aarch64_lane_imm3")]
9531 VFMLA16_HIGH))]
9532 "TARGET_F16FML"
9533 {
9534 rtx p1 = aarch64_simd_vect_par_cnst_half (V8HFmode, 8, true);
9535 rtx lane = aarch64_endian_lane_rtx (V8HFmode, INTVAL (operands[4]));
9536
9537 emit_insn (gen_aarch64_simd_fml<f16mac1>lq_laneq_highv4sf (operands[0],
9538 operands[1],
9539 operands[2],
9540 operands[3],
9541 p1, lane));
9542 DONE;
9543 })
9544
9545 (define_insn "aarch64_simd_fmlalq_laneq_lowv4sf"
9546 [(set (match_operand:V4SF 0 "register_operand" "=w")
9547 (fma:V4SF
9548 (float_extend:V4SF
9549 (vec_select:V4HF
9550 (match_operand:V8HF 2 "register_operand" "w")
9551 (match_operand:V8HF 4 "vect_par_cnst_lo_half" "")))
9552 (float_extend:V4SF
9553 (vec_duplicate:V4HF
9554 (vec_select:HF
9555 (match_operand:V8HF 3 "register_operand" "x")
9556 (parallel [(match_operand:SI 5 "aarch64_lane_imm3" "Ui7")]))))
9557 (match_operand:V4SF 1 "register_operand" "0")))]
9558 "TARGET_F16FML"
9559 "fmlal\\t%0.4s, %2.4h, %3.h[%5]"
9560 [(set_attr "type" "neon_fp_mul_s")]
9561 )
9562
9563 (define_insn "aarch64_simd_fmlslq_laneq_lowv4sf"
9564 [(set (match_operand:V4SF 0 "register_operand" "=w")
9565 (fma:V4SF
9566 (float_extend:V4SF
9567 (neg:V4HF
9568 (vec_select:V4HF
9569 (match_operand:V8HF 2 "register_operand" "w")
9570 (match_operand:V8HF 4 "vect_par_cnst_lo_half" ""))))
9571 (float_extend:V4SF
9572 (vec_duplicate:V4HF
9573 (vec_select:HF
9574 (match_operand:V8HF 3 "register_operand" "x")
9575 (parallel [(match_operand:SI 5 "aarch64_lane_imm3" "Ui7")]))))
9576 (match_operand:V4SF 1 "register_operand" "0")))]
9577 "TARGET_F16FML"
9578 "fmlsl\\t%0.4s, %2.4h, %3.h[%5]"
9579 [(set_attr "type" "neon_fp_mul_s")]
9580 )
9581
9582 (define_insn "aarch64_simd_fmlalq_laneq_highv4sf"
9583 [(set (match_operand:V4SF 0 "register_operand" "=w")
9584 (fma:V4SF
9585 (float_extend:V4SF
9586 (vec_select:V4HF
9587 (match_operand:V8HF 2 "register_operand" "w")
9588 (match_operand:V8HF 4 "vect_par_cnst_hi_half" "")))
9589 (float_extend:V4SF
9590 (vec_duplicate:V4HF
9591 (vec_select:HF
9592 (match_operand:V8HF 3 "register_operand" "x")
9593 (parallel [(match_operand:SI 5 "aarch64_lane_imm3" "Ui7")]))))
9594 (match_operand:V4SF 1 "register_operand" "0")))]
9595 "TARGET_F16FML"
9596 "fmlal2\\t%0.4s, %2.4h, %3.h[%5]"
9597 [(set_attr "type" "neon_fp_mul_s")]
9598 )
9599
9600 (define_insn "aarch64_simd_fmlslq_laneq_highv4sf"
9601 [(set (match_operand:V4SF 0 "register_operand" "=w")
9602 (fma:V4SF
9603 (float_extend:V4SF
9604 (neg:V4HF
9605 (vec_select:V4HF
9606 (match_operand:V8HF 2 "register_operand" "w")
9607 (match_operand:V8HF 4 "vect_par_cnst_hi_half" ""))))
9608 (float_extend:V4SF
9609 (vec_duplicate:V4HF
9610 (vec_select:HF
9611 (match_operand:V8HF 3 "register_operand" "x")
9612 (parallel [(match_operand:SI 5 "aarch64_lane_imm3" "Ui7")]))))
9613 (match_operand:V4SF 1 "register_operand" "0")))]
9614 "TARGET_F16FML"
9615 "fmlsl2\\t%0.4s, %2.4h, %3.h[%5]"
9616 [(set_attr "type" "neon_fp_mul_s")]
9617 )
9618
9619 (define_expand "aarch64_fml<f16mac1>l_laneq_lowv2sf"
9620 [(set (match_operand:V2SF 0 "register_operand")
9621 (unspec:V2SF [(match_operand:V2SF 1 "register_operand")
9622 (match_operand:V4HF 2 "register_operand")
9623 (match_operand:V8HF 3 "register_operand")
9624 (match_operand:SI 4 "aarch64_lane_imm3")]
9625 VFMLA16_LOW))]
9626 "TARGET_F16FML"
9627 {
9628 rtx p1 = aarch64_simd_vect_par_cnst_half (V4HFmode, 4, false);
9629 rtx lane = aarch64_endian_lane_rtx (V8HFmode, INTVAL (operands[4]));
9630
9631 emit_insn (gen_aarch64_simd_fml<f16mac1>l_laneq_lowv2sf (operands[0],
9632 operands[1],
9633 operands[2],
9634 operands[3],
9635 p1, lane));
9636 DONE;
9637
9638 })
9639
9640 (define_expand "aarch64_fml<f16mac1>l_laneq_highv2sf"
9641 [(set (match_operand:V2SF 0 "register_operand")
9642 (unspec:V2SF [(match_operand:V2SF 1 "register_operand")
9643 (match_operand:V4HF 2 "register_operand")
9644 (match_operand:V8HF 3 "register_operand")
9645 (match_operand:SI 4 "aarch64_lane_imm3")]
9646 VFMLA16_HIGH))]
9647 "TARGET_F16FML"
9648 {
9649 rtx p1 = aarch64_simd_vect_par_cnst_half (V4HFmode, 4, true);
9650 rtx lane = aarch64_endian_lane_rtx (V8HFmode, INTVAL (operands[4]));
9651
9652 emit_insn (gen_aarch64_simd_fml<f16mac1>l_laneq_highv2sf (operands[0],
9653 operands[1],
9654 operands[2],
9655 operands[3],
9656 p1, lane));
9657 DONE;
9658
9659 })
9660
9661 (define_insn "aarch64_simd_fmlal_laneq_lowv2sf"
9662 [(set (match_operand:V2SF 0 "register_operand" "=w")
9663 (fma:V2SF
9664 (float_extend:V2SF
9665 (vec_select:V2HF
9666 (match_operand:V4HF 2 "register_operand" "w")
9667 (match_operand:V4HF 4 "vect_par_cnst_lo_half" "")))
9668 (float_extend:V2SF
9669 (vec_duplicate:V2HF
9670 (vec_select:HF
9671 (match_operand:V8HF 3 "register_operand" "x")
9672 (parallel [(match_operand:SI 5 "aarch64_lane_imm3" "Ui7")]))))
9673 (match_operand:V2SF 1 "register_operand" "0")))]
9674 "TARGET_F16FML"
9675 "fmlal\\t%0.2s, %2.2h, %3.h[%5]"
9676 [(set_attr "type" "neon_fp_mul_s")]
9677 )
9678
9679 (define_insn "aarch64_simd_fmlsl_laneq_lowv2sf"
9680 [(set (match_operand:V2SF 0 "register_operand" "=w")
9681 (fma:V2SF
9682 (float_extend:V2SF
9683 (neg:V2HF
9684 (vec_select:V2HF
9685 (match_operand:V4HF 2 "register_operand" "w")
9686 (match_operand:V4HF 4 "vect_par_cnst_lo_half" ""))))
9687 (float_extend:V2SF
9688 (vec_duplicate:V2HF
9689 (vec_select:HF
9690 (match_operand:V8HF 3 "register_operand" "x")
9691 (parallel [(match_operand:SI 5 "aarch64_lane_imm3" "Ui7")]))))
9692 (match_operand:V2SF 1 "register_operand" "0")))]
9693 "TARGET_F16FML"
9694 "fmlsl\\t%0.2s, %2.2h, %3.h[%5]"
9695 [(set_attr "type" "neon_fp_mul_s")]
9696 )
9697
9698 (define_insn "aarch64_simd_fmlal_laneq_highv2sf"
9699 [(set (match_operand:V2SF 0 "register_operand" "=w")
9700 (fma:V2SF
9701 (float_extend:V2SF
9702 (vec_select:V2HF
9703 (match_operand:V4HF 2 "register_operand" "w")
9704 (match_operand:V4HF 4 "vect_par_cnst_hi_half" "")))
9705 (float_extend:V2SF
9706 (vec_duplicate:V2HF
9707 (vec_select:HF
9708 (match_operand:V8HF 3 "register_operand" "x")
9709 (parallel [(match_operand:SI 5 "aarch64_lane_imm3" "Ui7")]))))
9710 (match_operand:V2SF 1 "register_operand" "0")))]
9711 "TARGET_F16FML"
9712 "fmlal2\\t%0.2s, %2.2h, %3.h[%5]"
9713 [(set_attr "type" "neon_fp_mul_s")]
9714 )
9715
9716 (define_insn "aarch64_simd_fmlsl_laneq_highv2sf"
9717 [(set (match_operand:V2SF 0 "register_operand" "=w")
9718 (fma:V2SF
9719 (float_extend:V2SF
9720 (neg:V2HF
9721 (vec_select:V2HF
9722 (match_operand:V4HF 2 "register_operand" "w")
9723 (match_operand:V4HF 4 "vect_par_cnst_hi_half" ""))))
9724 (float_extend:V2SF
9725 (vec_duplicate:V2HF
9726 (vec_select:HF
9727 (match_operand:V8HF 3 "register_operand" "x")
9728 (parallel [(match_operand:SI 5 "aarch64_lane_imm3" "Ui7")]))))
9729 (match_operand:V2SF 1 "register_operand" "0")))]
9730 "TARGET_F16FML"
9731 "fmlsl2\\t%0.2s, %2.2h, %3.h[%5]"
9732 [(set_attr "type" "neon_fp_mul_s")]
9733 )
9734
9735 (define_expand "aarch64_fml<f16mac1>lq_lane_lowv4sf"
9736 [(set (match_operand:V4SF 0 "register_operand")
9737 (unspec:V4SF [(match_operand:V4SF 1 "register_operand")
9738 (match_operand:V8HF 2 "register_operand")
9739 (match_operand:V4HF 3 "register_operand")
9740 (match_operand:SI 4 "aarch64_imm2")]
9741 VFMLA16_LOW))]
9742 "TARGET_F16FML"
9743 {
9744 rtx p1 = aarch64_simd_vect_par_cnst_half (V8HFmode, 8, false);
9745 rtx lane = aarch64_endian_lane_rtx (V4HFmode, INTVAL (operands[4]));
9746
9747 emit_insn (gen_aarch64_simd_fml<f16mac1>lq_lane_lowv4sf (operands[0],
9748 operands[1],
9749 operands[2],
9750 operands[3],
9751 p1, lane));
9752 DONE;
9753 })
9754
9755 (define_expand "aarch64_fml<f16mac1>lq_lane_highv4sf"
9756 [(set (match_operand:V4SF 0 "register_operand")
9757 (unspec:V4SF [(match_operand:V4SF 1 "register_operand")
9758 (match_operand:V8HF 2 "register_operand")
9759 (match_operand:V4HF 3 "register_operand")
9760 (match_operand:SI 4 "aarch64_imm2")]
9761 VFMLA16_HIGH))]
9762 "TARGET_F16FML"
9763 {
9764 rtx p1 = aarch64_simd_vect_par_cnst_half (V8HFmode, 8, true);
9765 rtx lane = aarch64_endian_lane_rtx (V4HFmode, INTVAL (operands[4]));
9766
9767 emit_insn (gen_aarch64_simd_fml<f16mac1>lq_lane_highv4sf (operands[0],
9768 operands[1],
9769 operands[2],
9770 operands[3],
9771 p1, lane));
9772 DONE;
9773 })
9774
9775 (define_insn "aarch64_simd_fmlalq_lane_lowv4sf"
9776 [(set (match_operand:V4SF 0 "register_operand" "=w")
9777 (fma:V4SF
9778 (float_extend:V4SF
9779 (vec_select:V4HF
9780 (match_operand:V8HF 2 "register_operand" "w")
9781 (match_operand:V8HF 4 "vect_par_cnst_lo_half" "")))
9782 (float_extend:V4SF
9783 (vec_duplicate:V4HF
9784 (vec_select:HF
9785 (match_operand:V4HF 3 "register_operand" "x")
9786 (parallel [(match_operand:SI 5 "aarch64_imm2" "Ui2")]))))
9787 (match_operand:V4SF 1 "register_operand" "0")))]
9788 "TARGET_F16FML"
9789 "fmlal\\t%0.4s, %2.4h, %3.h[%5]"
9790 [(set_attr "type" "neon_fp_mul_s")]
9791 )
9792
9793 (define_insn "aarch64_simd_fmlslq_lane_lowv4sf"
9794 [(set (match_operand:V4SF 0 "register_operand" "=w")
9795 (fma:V4SF
9796 (float_extend:V4SF
9797 (neg:V4HF
9798 (vec_select:V4HF
9799 (match_operand:V8HF 2 "register_operand" "w")
9800 (match_operand:V8HF 4 "vect_par_cnst_lo_half" ""))))
9801 (float_extend:V4SF
9802 (vec_duplicate:V4HF
9803 (vec_select:HF
9804 (match_operand:V4HF 3 "register_operand" "x")
9805 (parallel [(match_operand:SI 5 "aarch64_imm2" "Ui2")]))))
9806 (match_operand:V4SF 1 "register_operand" "0")))]
9807 "TARGET_F16FML"
9808 "fmlsl\\t%0.4s, %2.4h, %3.h[%5]"
9809 [(set_attr "type" "neon_fp_mul_s")]
9810 )
9811
9812 (define_insn "aarch64_simd_fmlalq_lane_highv4sf"
9813 [(set (match_operand:V4SF 0 "register_operand" "=w")
9814 (fma:V4SF
9815 (float_extend:V4SF
9816 (vec_select:V4HF
9817 (match_operand:V8HF 2 "register_operand" "w")
9818 (match_operand:V8HF 4 "vect_par_cnst_hi_half" "")))
9819 (float_extend:V4SF
9820 (vec_duplicate:V4HF
9821 (vec_select:HF
9822 (match_operand:V4HF 3 "register_operand" "x")
9823 (parallel [(match_operand:SI 5 "aarch64_imm2" "Ui2")]))))
9824 (match_operand:V4SF 1 "register_operand" "0")))]
9825 "TARGET_F16FML"
9826 "fmlal2\\t%0.4s, %2.4h, %3.h[%5]"
9827 [(set_attr "type" "neon_fp_mul_s")]
9828 )
9829
9830 (define_insn "aarch64_simd_fmlslq_lane_highv4sf"
9831 [(set (match_operand:V4SF 0 "register_operand" "=w")
9832 (fma:V4SF
9833 (float_extend:V4SF
9834 (neg:V4HF
9835 (vec_select:V4HF
9836 (match_operand:V8HF 2 "register_operand" "w")
9837 (match_operand:V8HF 4 "vect_par_cnst_hi_half" ""))))
9838 (float_extend:V4SF
9839 (vec_duplicate:V4HF
9840 (vec_select:HF
9841 (match_operand:V4HF 3 "register_operand" "x")
9842 (parallel [(match_operand:SI 5 "aarch64_imm2" "Ui2")]))))
9843 (match_operand:V4SF 1 "register_operand" "0")))]
9844 "TARGET_F16FML"
9845 "fmlsl2\\t%0.4s, %2.4h, %3.h[%5]"
9846 [(set_attr "type" "neon_fp_mul_s")]
9847 )
9848
9849 ;; pmull
9850
9851 (define_insn "aarch64_crypto_pmulldi"
9852 [(set (match_operand:TI 0 "register_operand" "=w")
9853 (unspec:TI [(match_operand:DI 1 "register_operand" "w")
9854 (match_operand:DI 2 "register_operand" "w")]
9855 UNSPEC_PMULL))]
9856 "TARGET_AES"
9857 "pmull\\t%0.1q, %1.1d, %2.1d"
9858 [(set_attr "type" "crypto_pmull")]
9859 )
9860
9861 (define_insn "aarch64_crypto_pmullv2di"
9862 [(set (match_operand:TI 0 "register_operand" "=w")
9863 (unspec:TI [(match_operand:V2DI 1 "register_operand" "w")
9864 (match_operand:V2DI 2 "register_operand" "w")]
9865 UNSPEC_PMULL2))]
9866 "TARGET_AES"
9867 "pmull2\\t%0.1q, %1.2d, %2.2d"
9868 [(set_attr "type" "crypto_pmull")]
9869 )
9870
9871 ;; Sign- or zero-extend a 64-bit integer vector to a 128-bit vector.
9872 (define_insn_and_split "<optab><Vnarrowq><mode>2"
9873 [(set (match_operand:VQN 0 "register_operand" "=w")
9874 (ANY_EXTEND:VQN (match_operand:<VNARROWQ> 1 "register_operand" "w")))]
9875 "TARGET_SIMD"
9876 "<su>xtl\t%0.<Vtype>, %1.<Vntype>"
9877 "&& <CODE> == ZERO_EXTEND
9878 && aarch64_split_simd_shift_p (insn)"
9879 [(const_int 0)]
9880 {
9881 /* On many cores, it is cheaper to implement UXTL using a ZIP1 with zero,
9882 provided that the cost of the zero can be amortized over several
9883 operations. We'll later recombine the zero and zip if there are
9884 not sufficient uses of the zero to make the split worthwhile. */
9885 rtx res = simplify_gen_subreg (<VNARROWQ2>mode, operands[0],
9886 <MODE>mode, 0);
9887 rtx zero = aarch64_gen_shareable_zero (<VNARROWQ>mode);
9888 emit_insn (gen_aarch64_zip1<Vnarrowq2>_low (res, operands[1], zero));
9889 DONE;
9890 }
9891 [(set_attr "type" "neon_shift_imm_long")]
9892 )
9893
9894 (define_expand "aarch64_<su>xtl<mode>"
9895 [(set (match_operand:VQN 0 "register_operand" "=w")
9896 (ANY_EXTEND:VQN (match_operand:<VNARROWQ> 1 "register_operand" "w")))]
9897 "TARGET_SIMD"
9898 ""
9899 )
9900
9901 ;; Truncate a 128-bit integer vector to a 64-bit vector.
9902 (define_insn "trunc<mode><Vnarrowq>2<vczle><vczbe>"
9903 [(set (match_operand:<VNARROWQ> 0 "register_operand" "=w")
9904 (truncate:<VNARROWQ> (match_operand:VQN 1 "register_operand" "w")))]
9905 "TARGET_SIMD"
9906 "xtn\t%0.<Vntype>, %1.<Vtype>"
9907 [(set_attr "type" "neon_move_narrow_q")]
9908 )
9909
9910 ;; Expander for the intrinsics that only takes one mode unlike the two-mode
9911 ;; trunc optab.
9912 (define_expand "aarch64_xtn<mode>"
9913 [(set (match_operand:<VNARROWQ> 0 "register_operand")
9914 (truncate:<VNARROWQ> (match_operand:VQN 1 "register_operand")))]
9915 "TARGET_SIMD"
9916 {}
9917 )
9918
9919 (define_insn "aarch64_bfdot<mode>"
9920 [(set (match_operand:VDQSF 0 "register_operand" "=w")
9921 (plus:VDQSF
9922 (unspec:VDQSF
9923 [(match_operand:<VBFMLA_W> 2 "register_operand" "w")
9924 (match_operand:<VBFMLA_W> 3 "register_operand" "w")]
9925 UNSPEC_BFDOT)
9926 (match_operand:VDQSF 1 "register_operand" "0")))]
9927 "TARGET_BF16_SIMD"
9928 "bfdot\t%0.<Vtype>, %2.<Vbfdottype>, %3.<Vbfdottype>"
9929 [(set_attr "type" "neon_dot<q>")]
9930 )
9931
9932 (define_insn "aarch64_bfdot_lane<VBF:isquadop><VDQSF:mode>"
9933 [(set (match_operand:VDQSF 0 "register_operand" "=w")
9934 (plus:VDQSF
9935 (unspec:VDQSF
9936 [(match_operand:<VDQSF:VBFMLA_W> 2 "register_operand" "w")
9937 (match_operand:VBF 3 "register_operand" "w")
9938 (match_operand:SI 4 "const_int_operand" "n")]
9939 UNSPEC_BFDOT)
9940 (match_operand:VDQSF 1 "register_operand" "0")))]
9941 "TARGET_BF16_SIMD"
9942 {
9943 int nunits = GET_MODE_NUNITS (<VBF:MODE>mode).to_constant ();
9944 int lane = INTVAL (operands[4]);
9945 operands[4] = gen_int_mode (ENDIAN_LANE_N (nunits / 2, lane), SImode);
9946 return "bfdot\t%0.<VDQSF:Vtype>, %2.<VDQSF:Vbfdottype>, %3.2h[%4]";
9947 }
9948 [(set_attr "type" "neon_dot<VDQSF:q>")]
9949 )
9950
9951 ;; bfmmla
9952 (define_insn "aarch64_bfmmlaqv4sf"
9953 [(set (match_operand:V4SF 0 "register_operand" "=w")
9954 (plus:V4SF (match_operand:V4SF 1 "register_operand" "0")
9955 (unspec:V4SF [(match_operand:V8BF 2 "register_operand" "w")
9956 (match_operand:V8BF 3 "register_operand" "w")]
9957 UNSPEC_BFMMLA)))]
9958 "TARGET_BF16_SIMD"
9959 "bfmmla\\t%0.4s, %2.8h, %3.8h"
9960 [(set_attr "type" "neon_fp_mla_s_q")]
9961 )
9962
9963 ;; bfmlal<bt>
9964 (define_insn "aarch64_bfmlal<bt>v4sf"
9965 [(set (match_operand:V4SF 0 "register_operand" "=w")
9966 (plus: V4SF (match_operand:V4SF 1 "register_operand" "0")
9967 (unspec:V4SF [(match_operand:V8BF 2 "register_operand" "w")
9968 (match_operand:V8BF 3 "register_operand" "w")]
9969 BF_MLA)))]
9970 "TARGET_BF16_SIMD"
9971 "bfmlal<bt>\\t%0.4s, %2.8h, %3.8h"
9972 [(set_attr "type" "neon_fp_mla_s_q")]
9973 )
9974
9975 (define_insn "aarch64_bfmlal<bt>_lane<q>v4sf"
9976 [(set (match_operand:V4SF 0 "register_operand" "=w")
9977 (plus: V4SF (match_operand:V4SF 1 "register_operand" "0")
9978 (unspec:V4SF [(match_operand:V8BF 2 "register_operand" "w")
9979 (match_operand:VBF 3 "register_operand" "x")
9980 (match_operand:SI 4 "const_int_operand" "n")]
9981 BF_MLA)))]
9982 "TARGET_BF16_SIMD"
9983 {
9984 operands[4] = aarch64_endian_lane_rtx (<MODE>mode, INTVAL (operands[4]));
9985 return "bfmlal<bt>\\t%0.4s, %2.8h, %3.h[%4]";
9986 }
9987 [(set_attr "type" "neon_fp_mla_s_scalar_q")]
9988 )
9989
9990 ;; 8-bit integer matrix multiply-accumulate
9991 (define_insn "aarch64_simd_<sur>mmlav16qi"
9992 [(set (match_operand:V4SI 0 "register_operand" "=w")
9993 (plus:V4SI
9994 (unspec:V4SI [(match_operand:V16QI 2 "register_operand" "w")
9995 (match_operand:V16QI 3 "register_operand" "w")] MATMUL)
9996 (match_operand:V4SI 1 "register_operand" "0")))]
9997 "TARGET_I8MM"
9998 "<sur>mmla\\t%0.4s, %2.16b, %3.16b"
9999 [(set_attr "type" "neon_mla_s_q")]
10000 )
10001
10002 ;; bfcvtn
10003 (define_insn "aarch64_bfcvtn<q><mode>"
10004 [(set (match_operand:V4SF_TO_BF 0 "register_operand" "=w")
10005 (unspec:V4SF_TO_BF [(match_operand:V4SF 1 "register_operand" "w")]
10006 UNSPEC_BFCVTN))]
10007 "TARGET_BF16_SIMD"
10008 "bfcvtn\\t%0.4h, %1.4s"
10009 [(set_attr "type" "neon_fp_cvt_narrow_s_q")]
10010 )
10011
10012 (define_insn "aarch64_bfcvtn2v8bf"
10013 [(set (match_operand:V8BF 0 "register_operand" "=w")
10014 (unspec:V8BF [(match_operand:V8BF 1 "register_operand" "0")
10015 (match_operand:V4SF 2 "register_operand" "w")]
10016 UNSPEC_BFCVTN2))]
10017 "TARGET_BF16_SIMD"
10018 "bfcvtn2\\t%0.8h, %2.4s"
10019 [(set_attr "type" "neon_fp_cvt_narrow_s_q")]
10020 )
10021
10022 (define_insn "aarch64_bfcvtbf"
10023 [(set (match_operand:BF 0 "register_operand" "=w")
10024 (unspec:BF [(match_operand:SF 1 "register_operand" "w")]
10025 UNSPEC_BFCVT))]
10026 "TARGET_BF16_FP"
10027 "bfcvt\\t%h0, %s1"
10028 [(set_attr "type" "f_cvt")]
10029 )
10030
10031 ;; Use shl/shll/shll2 to convert BF scalar/vector modes to SF modes.
10032 (define_insn "aarch64_vbfcvt<mode>"
10033 [(set (match_operand:V4SF 0 "register_operand" "=w")
10034 (unspec:V4SF [(match_operand:VBF 1 "register_operand" "w")]
10035 UNSPEC_BFCVTN))]
10036 "TARGET_BF16_SIMD"
10037 "shll\\t%0.4s, %1.4h, #16"
10038 [(set_attr "type" "neon_shift_imm_long")]
10039 )
10040
10041 (define_insn "aarch64_vbfcvt_highv8bf"
10042 [(set (match_operand:V4SF 0 "register_operand" "=w")
10043 (unspec:V4SF [(match_operand:V8BF 1 "register_operand" "w")]
10044 UNSPEC_BFCVTN2))]
10045 "TARGET_BF16_SIMD"
10046 "shll2\\t%0.4s, %1.8h, #16"
10047 [(set_attr "type" "neon_shift_imm_long")]
10048 )
10049
10050 (define_insn "aarch64_bfcvtsf"
10051 [(set (match_operand:SF 0 "register_operand" "=w")
10052 (unspec:SF [(match_operand:BF 1 "register_operand" "w")]
10053 UNSPEC_BFCVT))]
10054 "TARGET_BF16_FP"
10055 "shl\\t%d0, %d1, #16"
10056 [(set_attr "type" "neon_shift_imm")]
10057 )
10058
10059 ;; faminmax
10060 (define_insn "@aarch64_<faminmax_uns_op><mode>"
10061 [(set (match_operand:VHSDF 0 "register_operand" "=w")
10062 (unspec:VHSDF [(match_operand:VHSDF 1 "register_operand" "w")
10063 (match_operand:VHSDF 2 "register_operand" "w")]
10064 FAMINMAX_UNS))]
10065 "TARGET_FAMINMAX"
10066 "<faminmax_uns_op>\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
10067 )
10068
10069 (define_insn "*aarch64_faminmax_fused"
10070 [(set (match_operand:VHSDF 0 "register_operand" "=w")
10071 (FMAXMIN:VHSDF
10072 (abs:VHSDF (match_operand:VHSDF 1 "register_operand" "w"))
10073 (abs:VHSDF (match_operand:VHSDF 2 "register_operand" "w"))))]
10074 "TARGET_FAMINMAX"
10075 "<faminmax_op>\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
10076 )
10077
10078 (define_insn "@aarch64_lut<VLUT:mode><VB:mode>"
10079 [(set (match_operand:<VLUT:VCONQ> 0 "register_operand" "=w")
10080 (unspec:<VLUT:VCONQ>
10081 [(match_operand:VLUT 1 "register_operand" "w")
10082 (match_operand:VB 2 "register_operand" "w")
10083 (match_operand:SI 3 "const_int_operand")
10084 (match_operand:SI 4 "const_int_operand")]
10085 UNSPEC_LUTI))]
10086 "TARGET_LUT && INTVAL (operands[4]) <= exact_log2 (<VLUT:nunits>)"
10087 "luti%4\t%0<VLUT:Vconqtype>, {%1<VLUT:Vconqtype>}, %2[%3]"
10088 )
10089
10090 ;; lutx2
10091 (define_insn "@aarch64_lut<VLUTx2:mode><VB:mode>"
10092 [(set (match_operand:<VSTRUCT_ELT> 0 "register_operand" "=w")
10093 (unspec:<VSTRUCT_ELT>
10094 [(match_operand:VLUTx2 1 "register_operand" "w")
10095 (match_operand:VB 2 "register_operand" "w")
10096 (match_operand:SI 3 "const_int_operand")
10097 (match_operand:SI 4 "const_int_operand")]
10098 UNSPEC_LUTI))]
10099 "TARGET_LUT && INTVAL (operands[4]) == 4"
10100 "luti%4\t%0.8h, {%S1.8h, %T1.8h}, %2[%3]"
10101 )
10102
10103 ;; fpm unary instructions (low part).
10104 (define_insn "@aarch64_<insn><mode>"
10105 [(set (match_operand:VQ_BHF 0 "register_operand" "=w")
10106 (unspec:VQ_BHF
10107 [(match_operand:V8QI 1 "register_operand" "w")
10108 (reg:DI FPM_REGNUM)]
10109 FPM_UNARY_UNS))]
10110 "TARGET_FP8"
10111 "<b><insn>\t%0.<Vtype>, %1.8b"
10112 )
10113
10114 ;; fpm unary instructions (high part).
10115 (define_insn "@aarch64_<insn><mode>_high"
10116 [(set (match_operand:VQ_BHF 0 "register_operand" "=w")
10117 (unspec:VQ_BHF
10118 [(vec_select:V8QI
10119 (match_operand:V16QI 1 "register_operand" "w")
10120 (match_operand:V16QI 2 "vect_par_cnst_hi_half"))
10121 (reg:DI FPM_REGNUM)]
10122 FPM_UNARY_UNS))]
10123 "TARGET_FP8"
10124 "<b><insn>2\t%0.<Vtype>, %1.16b"
10125 )
10126
10127 ;; fpm binary instructions.
10128 (define_insn "@aarch64_<insn><mode>"
10129 [(set (match_operand:<VPACKB> 0 "register_operand" "=w")
10130 (unspec:<VPACKB>
10131 [(match_operand:VCVTFPM 1 "register_operand" "w")
10132 (match_operand:VCVTFPM 2 "register_operand" "w")
10133 (reg:DI FPM_REGNUM)]
10134 FPM_BINARY_UNS))]
10135 "TARGET_FP8"
10136 "<insn>\t%0.<VPACKBtype>, %1.<Vtype>, %2.<Vtype>"
10137 )
10138
10139 ;; fpm binary instructions & merge with low.
10140 (define_insn "@aarch64_<insn><mode>_high_le"
10141 [(set (match_operand:V16QI 0 "register_operand" "=w")
10142 (vec_concat:V16QI
10143 (match_operand:V8QI 1 "register_operand" "0")
10144 (unspec:V8QI
10145 [(match_operand:V4SF_ONLY 2 "register_operand" "w")
10146 (match_operand:V4SF_ONLY 3 "register_operand" "w")
10147 (reg:DI FPM_REGNUM)]
10148 FPM_BINARY_UNS)))]
10149 "TARGET_FP8 && !BYTES_BIG_ENDIAN"
10150 "<insn>2\t%1.16b, %2.<V4SF_ONLY:Vtype>, %3.<V4SF_ONLY:Vtype>";
10151 )
10152
10153 (define_insn "@aarch64_<insn><mode>_high_be"
10154 [(set (match_operand:V16QI 0 "register_operand" "=w")
10155 (vec_concat:V16QI
10156 (unspec:V8QI
10157 [(match_operand:V4SF_ONLY 2 "register_operand" "w")
10158 (match_operand:V4SF_ONLY 3 "register_operand" "w")
10159 (reg:DI FPM_REGNUM)]
10160 FPM_BINARY_UNS)
10161 (match_operand:V8QI 1 "register_operand" "0")))]
10162 "TARGET_FP8 && BYTES_BIG_ENDIAN"
10163 "<insn>2\t%1.16b, %2.<V4SF_ONLY:Vtype>, %3.<V4SF_ONLY:Vtype>";
10164 )
10165
10166 ;; fscale instructions
10167 (define_insn "@aarch64_<insn><mode>"
10168 [(set (match_operand:VHSDF 0 "register_operand" "=w")
10169 (unspec:VHSDF [(match_operand:VHSDF 1 "register_operand" "w")
10170 (match_operand:<FCVT_TARGET> 2 "register_operand" "w")]
10171 FSCALE_UNS))]
10172 "TARGET_FP8"
10173 "<insn>\t%0.<Vtype>, %1.<Vtype>, %2.<Vtype>"
10174 )
10175
10176 ;; fpm vdot instructions. The target requirements are enforced by
10177 ;; VDQ_HSF_FDOT.
10178 (define_insn "@aarch64_<insn><mode>"
10179 [(set (match_operand:VDQ_HSF_FDOT 0 "register_operand" "=w")
10180 (unspec:VDQ_HSF_FDOT
10181 [(match_operand:VDQ_HSF_FDOT 1 "register_operand" "0")
10182 (match_operand:<VNARROWB> 2 "register_operand" "w")
10183 (match_operand:<VNARROWB> 3 "register_operand" "w")
10184 (reg:DI FPM_REGNUM)]
10185 FPM_FDOT))]
10186 ""
10187 "<insn>\t%1.<Vtype>, %2.<Vnbtype>, %3.<Vnbtype>"
10188 )
10189
10190 (define_insn "@aarch64_<insn>_lane<VDQ_HSF_FDOT:mode><VB:mode>"
10191 [(set (match_operand:VDQ_HSF_FDOT 0 "register_operand" "=w")
10192 (unspec:VDQ_HSF_FDOT
10193 [(match_operand:VDQ_HSF_FDOT 1 "register_operand" "0")
10194 (match_operand:<VDQ_HSF_FDOT:VNARROWB> 2 "register_operand" "w")
10195 (match_operand:VB 3 "register_operand" "w")
10196 (match_operand 4 "const_int_operand")
10197 (reg:DI FPM_REGNUM)]
10198 FPM_FDOT_LANE))]
10199 ""
10200 "<insn>\t%1.<VDQ_HSF_FDOT:Vtype>, %2.<VDQ_HSF_FDOT:Vnbtype>, %3.<VDQ_HSF_FDOT:Vnbsubtype>[%4]"
10201 )
10202
10203 ;; fpm fma instructions.
10204 (define_insn "@aarch64_<insn><mode>"
10205 [(set (match_operand:V8HF_ONLY 0 "register_operand" "=w")
10206 (unspec:V8HF_ONLY
10207 [(match_operand:V8HF_ONLY 1 "register_operand" "0")
10208 (match_operand:V16QI 2 "register_operand" "w")
10209 (match_operand:V16QI 3 "register_operand" "w")
10210 (reg:DI FPM_REGNUM)]
10211 FMLAL_FP8_HF))]
10212 "TARGET_FP8FMA"
10213 "<insn>\t%0.<Vtype>, %2.16b, %3.16b"
10214 )
10215
10216 (define_insn "@aarch64_<insn>_lane<V8HF_ONLY:mode><VB:mode>"
10217 [(set (match_operand:V8HF_ONLY 0 "register_operand" "=w")
10218 (unspec:V8HF_ONLY
10219 [(match_operand:V8HF_ONLY 1 "register_operand" "0")
10220 (match_operand:V16QI 2 "register_operand" "w")
10221 (vec_duplicate:V16QI
10222 (vec_select:QI
10223 (match_operand:VB 3 "register_operand" "w")
10224 (parallel [(match_operand:SI 4 "immediate_operand")])))
10225 (reg:DI FPM_REGNUM)]
10226 FMLAL_FP8_HF))]
10227 "TARGET_FP8FMA"
10228 {
10229 operands[4] = aarch64_endian_lane_rtx (<VB:MODE>mode,
10230 INTVAL (operands[4]));
10231 return "<insn>\t%0.<V8HF_ONLY:Vtype>, %2.16b, %3.b[%4]";
10232 }
10233 )
10234
10235 (define_insn "@aarch64_<insn><mode>"
10236 [(set (match_operand:V4SF_ONLY 0 "register_operand" "=w")
10237 (unspec:V4SF_ONLY
10238 [(match_operand:V4SF_ONLY 1 "register_operand" "0")
10239 (match_operand:V16QI 2 "register_operand" "w")
10240 (match_operand:V16QI 3 "register_operand" "w")
10241 (reg:DI FPM_REGNUM)]
10242 FMLALL_FP8_SF))]
10243 "TARGET_FP8FMA"
10244 "<insn>\t%0.<Vtype>, %2.16b, %3.16b"
10245 )
10246
10247 (define_insn "@aarch64_<insn>_lane<V4SF_ONLY:mode><VB:mode>"
10248 [(set (match_operand:V4SF_ONLY 0 "register_operand" "=w")
10249 (unspec:V4SF_ONLY
10250 [(match_operand:V4SF_ONLY 1 "register_operand" "0")
10251 (match_operand:V16QI 2 "register_operand" "w")
10252 (vec_duplicate:V16QI
10253 (vec_select:QI
10254 (match_operand:VB 3 "register_operand" "w")
10255 (parallel [(match_operand:SI 4 "immediate_operand")])))
10256 (reg:DI FPM_REGNUM)]
10257 FMLALL_FP8_SF))]
10258 "TARGET_FP8FMA"
10259 {
10260 operands[4] = aarch64_endian_lane_rtx (<VB:MODE>mode,
10261 INTVAL (operands[4]));
10262 return "<insn>\t%0.<V4SF_ONLY:Vtype>, %2.16b, %3.b[%4]";
10263 }
10264 )