Debian Codegraph @

gcc/config/arm/vec-common.md

raw
1 ;; Machine Description for shared bits common to IWMMXT and Neon.
2 ;; Copyright (C) 2006-2025 Free Software Foundation, Inc.
3 ;; Written by CodeSourcery.
4 ;;
5 ;; This file is part of GCC.
6 ;;
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 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 ;; Vector Moves
22
23 (define_expand "mov<mode>"
24 [(set (match_operand:VNIM1 0 "nonimmediate_operand")
25 (match_operand:VNIM1 1 "general_operand"))]
26 "TARGET_NEON
27 || (TARGET_REALLY_IWMMXT && VALID_IWMMXT_REG_MODE (<MODE>mode))
28 || (TARGET_HAVE_MVE && VALID_MVE_SI_MODE (<MODE>mode))
29 || (TARGET_HAVE_MVE_FLOAT && VALID_MVE_SF_MODE (<MODE>mode))"
30 {
31 gcc_checking_assert (aligned_operand (operands[0], <MODE>mode));
32 gcc_checking_assert (aligned_operand (operands[1], <MODE>mode));
33 if (can_create_pseudo_p ())
34 {
35 if (!REG_P (operands[0]))
36 operands[1] = force_reg (<MODE>mode, operands[1]);
37 else if ((TARGET_NEON || TARGET_HAVE_MVE || TARGET_HAVE_MVE_FLOAT)
38 && (CONSTANT_P (operands[1])))
39 {
40 operands[1] = neon_make_constant (operands[1]);
41 gcc_assert (operands[1] != NULL_RTX);
42 }
43 }
44 })
45
46 (define_expand "mov<mode>"
47 [(set (match_operand:VNINOTM1 0 "nonimmediate_operand")
48 (match_operand:VNINOTM1 1 "general_operand"))]
49 "TARGET_NEON
50 || (TARGET_REALLY_IWMMXT && VALID_IWMMXT_REG_MODE (<MODE>mode))"
51 {
52 gcc_checking_assert (aligned_operand (operands[0], <MODE>mode));
53 gcc_checking_assert (aligned_operand (operands[1], <MODE>mode));
54 if (can_create_pseudo_p ())
55 {
56 if (!REG_P (operands[0]))
57 operands[1] = force_reg (<MODE>mode, operands[1]);
58 else if (TARGET_NEON && CONSTANT_P (operands[1]))
59 {
60 operands[1] = neon_make_constant (operands[1]);
61 gcc_assert (operands[1] != NULL_RTX);
62 }
63 }
64 })
65
66 (define_expand "movv8hf"
67 [(set (match_operand:V8HF 0 "s_register_operand")
68 (match_operand:V8HF 1 "s_register_operand"))]
69 "TARGET_NEON || TARGET_HAVE_MVE_FLOAT"
70 {
71 gcc_checking_assert (aligned_operand (operands[0], E_V8HFmode));
72 gcc_checking_assert (aligned_operand (operands[1], E_V8HFmode));
73 if (can_create_pseudo_p ())
74 {
75 if (!REG_P (operands[0]))
76 operands[1] = force_reg (E_V8HFmode, operands[1]);
77 else if (TARGET_HAVE_MVE_FLOAT && CONSTANT_P (operands[1]))
78 {
79 operands[1] = neon_make_constant (operands[1]);
80 gcc_assert (operands[1] != NULL_RTX);
81 }
82 }
83 })
84
85 ;; Vector arithmetic. Expanders are blank, then unnamed insns implement
86 ;; patterns separately for Neon, IWMMXT and MVE.
87
88 (define_expand "add<mode>3"
89 [(set (match_operand:VDQ 0 "s_register_operand")
90 (plus:VDQ (match_operand:VDQ 1 "s_register_operand")
91 (match_operand:VDQ 2 "s_register_operand")))]
92 "ARM_HAVE_<MODE>_ARITH"
93 )
94
95 (define_expand "sub<mode>3"
96 [(set (match_operand:VDQ 0 "s_register_operand")
97 (minus:VDQ (match_operand:VDQ 1 "s_register_operand")
98 (match_operand:VDQ 2 "s_register_operand")))]
99 "ARM_HAVE_<MODE>_ARITH"
100 )
101
102 (define_expand "mul<mode>3"
103 [(set (match_operand:VDQWH 0 "s_register_operand")
104 (mult:VDQWH (match_operand:VDQWH 1 "s_register_operand")
105 (match_operand:VDQWH 2 "s_register_operand")))]
106 "ARM_HAVE_<MODE>_ARITH
107 && (!TARGET_REALLY_IWMMXT
108 || <MODE>mode == V4HImode
109 || <MODE>mode == V2SImode)"
110 )
111
112 (define_expand "smin<mode>3"
113 [(set (match_operand:VDQWH 0 "s_register_operand")
114 (smin:VDQWH (match_operand:VDQWH 1 "s_register_operand")
115 (match_operand:VDQWH 2 "s_register_operand")))]
116 "ARM_HAVE_<MODE>_ARITH"
117 )
118
119 (define_expand "umin<mode>3"
120 [(set (match_operand:VINTW 0 "s_register_operand")
121 (umin:VINTW (match_operand:VINTW 1 "s_register_operand")
122 (match_operand:VINTW 2 "s_register_operand")))]
123 "ARM_HAVE_<MODE>_ARITH"
124 )
125
126 (define_expand "smax<mode>3"
127 [(set (match_operand:VDQWH 0 "s_register_operand")
128 (smax:VDQWH (match_operand:VDQWH 1 "s_register_operand")
129 (match_operand:VDQWH 2 "s_register_operand")))]
130 "ARM_HAVE_<MODE>_ARITH"
131 )
132
133 (define_expand "umax<mode>3"
134 [(set (match_operand:VINTW 0 "s_register_operand")
135 (umax:VINTW (match_operand:VINTW 1 "s_register_operand")
136 (match_operand:VINTW 2 "s_register_operand")))]
137 "ARM_HAVE_<MODE>_ARITH"
138 )
139
140 ;; Vector forms for the IEEE-754 fmax()/fmin() functions
141 ;; Fixme: Should be enabled for MVE as well, but currently that uses an
142 ;; incompatible expasion.
143 (define_expand "<fmaxmin><mode>3"
144 [(set (match_operand:VF 0 "s_register_operand" "")
145 (unspec:VF [(match_operand:VF 1 "s_register_operand")
146 (match_operand:VF 2 "s_register_operand")]
147 VMAXMINFNM))]
148 "TARGET_NEON && TARGET_VFP5 && ARM_HAVE_<MODE>_ARITH"
149 )
150
151 (define_expand "vec_perm<mode>"
152 [(match_operand:VE 0 "s_register_operand")
153 (match_operand:VE 1 "s_register_operand")
154 (match_operand:VE 2 "s_register_operand")
155 (match_operand:VE 3 "s_register_operand")]
156 "TARGET_NEON && !BYTES_BIG_ENDIAN"
157 {
158 arm_expand_vec_perm (operands[0], operands[1], operands[2], operands[3]);
159 DONE;
160 })
161
162 (define_expand "vec_extract<mode><V_elem_l>"
163 [(match_operand:<V_elem> 0 "nonimmediate_operand")
164 (match_operand:VQX_NOBF 1 "s_register_operand")
165 (match_operand:SI 2 "immediate_operand")]
166 "TARGET_NEON || TARGET_HAVE_MVE"
167 {
168 if (TARGET_NEON)
169 emit_insn (gen_neon_vec_extract<mode><V_elem_l> (operands[0], operands[1],
170 operands[2]));
171 else if (TARGET_HAVE_MVE)
172 emit_insn (gen_mve_vec_extract<mode><V_elem_l> (operands[0], operands[1],
173 operands[2]));
174 else
175 gcc_unreachable ();
176 DONE;
177 })
178
179 (define_expand "vec_set<mode>"
180 [(match_operand:VQX_NOBF 0 "s_register_operand" "")
181 (match_operand:<V_elem> 1 "s_register_operand" "")
182 (match_operand:SI 2 "immediate_operand" "")]
183 "TARGET_NEON || TARGET_HAVE_MVE"
184 {
185 HOST_WIDE_INT elem = HOST_WIDE_INT_1 << INTVAL (operands[2]);
186 if (TARGET_NEON)
187 emit_insn (gen_vec_set<mode>_internal (operands[0], operands[1],
188 GEN_INT (elem), operands[0]));
189 else
190 emit_insn (gen_mve_vec_set<mode>_internal (operands[0], operands[1],
191 GEN_INT (elem), operands[0]));
192 DONE;
193 })
194
195 (define_expand "and<mode>3"
196 [(set (match_operand:VDQ 0 "s_register_operand" "")
197 (and:VDQ (match_operand:VDQ 1 "s_register_operand" "")
198 (match_operand:VDQ 2 "neon_inv_logic_op2" "")))]
199 "ARM_HAVE_<MODE>_ARITH"
200 )
201
202 (define_expand "ior<mode>3"
203 [(set (match_operand:VDQ 0 "s_register_operand" "")
204 (ior:VDQ (match_operand:VDQ 1 "s_register_operand" "")
205 (match_operand:VDQ 2 "neon_logic_op2" "")))]
206 "ARM_HAVE_<MODE>_ARITH"
207 )
208
209 (define_expand "xor<mode>3"
210 [(set (match_operand:VDQ 0 "s_register_operand" "")
211 (xor:VDQ (match_operand:VDQ 1 "s_register_operand" "")
212 (match_operand:VDQ 2 "s_register_operand" "")))]
213 "ARM_HAVE_<MODE>_ARITH"
214 )
215
216 (define_expand "one_cmpl<mode>2"
217 [(set (match_operand:VDQ 0 "s_register_operand")
218 (not:VDQ (match_operand:VDQ 1 "s_register_operand")))]
219 "ARM_HAVE_<MODE>_ARITH && !TARGET_REALLY_IWMMXT"
220 )
221
222 (define_expand "<absneg_str><mode>2"
223 [(set (match_operand:VDQWH 0 "s_register_operand" "")
224 (ABSNEG:VDQWH (match_operand:VDQWH 1 "s_register_operand" "")))]
225 "ARM_HAVE_<MODE>_ARITH && !TARGET_REALLY_IWMMXT"
226 )
227
228 (define_expand "cadd<rot><mode>3"
229 [(set (match_operand:VF 0 "register_operand")
230 (unspec:VF [(match_operand:VF 1 "register_operand")
231 (match_operand:VF 2 "register_operand")]
232 VCADD))]
233 "(TARGET_COMPLEX || (TARGET_HAVE_MVE && TARGET_HAVE_MVE_FLOAT
234 && ARM_HAVE_<MODE>_ARITH)) && !BYTES_BIG_ENDIAN"
235 )
236
237 ;; The complex mul operations always need to expand to two instructions.
238 ;; The first operation does half the computation and the second does the
239 ;; remainder. Because of this, expand early.
240 (define_expand "cmul<conj_op><mode>3"
241 [(set (match_operand:VQ_HSF 0 "register_operand")
242 (unspec:VQ_HSF [(match_operand:VQ_HSF 1 "register_operand")
243 (match_operand:VQ_HSF 2 "register_operand")]
244 VCMUL_OP))]
245 "(TARGET_COMPLEX || (TARGET_HAVE_MVE && TARGET_HAVE_MVE_FLOAT))
246 && !BYTES_BIG_ENDIAN"
247 {
248 rtx res1 = gen_reg_rtx (<MODE>mode);
249 if (TARGET_COMPLEX)
250 {
251 rtx tmp = force_reg (<MODE>mode, CONST0_RTX (<MODE>mode));
252 emit_insn (gen_arm_vcmla<rotsplit1><mode> (res1, tmp,
253 operands[2], operands[1]));
254 }
255 else
256 emit_insn (gen_arm_vcmla<rotsplit1><mode> (res1, CONST0_RTX (<MODE>mode),
257 operands[2], operands[1]));
258
259 emit_insn (gen_arm_vcmla<rotsplit2><mode> (operands[0], res1,
260 operands[2], operands[1]));
261 DONE;
262 })
263
264 (define_expand "arm_vcmla<rot><mode>"
265 [(set (match_operand:VF 0 "register_operand")
266 (plus:VF (match_operand:VF 1 "register_operand")
267 (unspec:VF [(match_operand:VF 2 "register_operand")
268 (match_operand:VF 3 "register_operand")]
269 VCMLA)))]
270 "(TARGET_COMPLEX || (TARGET_HAVE_MVE && TARGET_HAVE_MVE_FLOAT
271 && ARM_HAVE_<MODE>_ARITH)) && !BYTES_BIG_ENDIAN"
272 )
273
274 ;; The complex mla/mls operations always need to expand to two instructions.
275 ;; The first operation does half the computation and the second does the
276 ;; remainder. Because of this, expand early.
277 (define_expand "cml<fcmac1><conj_op><mode>4"
278 [(set (match_operand:VF 0 "register_operand")
279 (plus:VF (unspec:VF [(match_operand:VF 1 "register_operand")
280 (match_operand:VF 2 "register_operand")]
281 VCMLA_OP)
282 (match_operand:VF 3 "register_operand")))]
283 "(TARGET_COMPLEX || (TARGET_HAVE_MVE && TARGET_HAVE_MVE_FLOAT
284 && ARM_HAVE_<MODE>_ARITH)) && !BYTES_BIG_ENDIAN"
285 {
286 rtx tmp = gen_reg_rtx (<MODE>mode);
287 emit_insn (gen_arm_vcmla<rotsplit1><mode> (tmp, operands[3],
288 operands[2], operands[1]));
289 emit_insn (gen_arm_vcmla<rotsplit2><mode> (operands[0], tmp,
290 operands[2], operands[1]));
291 DONE;
292 })
293
294 (define_expand "@movmisalign<mode>"
295 [(set (match_operand:VDQ 0 "nonimmediate_operand")
296 (unspec:VDQ [(match_operand:VDQ 1 "general_operand")]
297 UNSPEC_MISALIGNED_ACCESS))]
298 "ARM_HAVE_<MODE>_LDST && !BYTES_BIG_ENDIAN
299 && unaligned_access && !TARGET_REALLY_IWMMXT"
300 {
301 rtx *memloc;
302 bool for_store = false;
303 /* This pattern is not permitted to fail during expansion: if both arguments
304 are non-registers (e.g. memory := constant, which can be created by the
305 auto-vectorizer), force operand 1 into a register. */
306 if (!s_register_operand (operands[0], <MODE>mode)
307 && !s_register_operand (operands[1], <MODE>mode))
308 operands[1] = force_reg (<MODE>mode, operands[1]);
309
310 if (s_register_operand (operands[0], <MODE>mode))
311 memloc = &operands[1];
312 else
313 {
314 memloc = &operands[0];
315 for_store = true;
316 }
317
318 /* For MVE, vector loads/stores must be aligned to the element size. If the
319 alignment is less than that convert the load/store to a suitable mode. */
320 if (TARGET_HAVE_MVE
321 && (MEM_ALIGN (*memloc)
322 < GET_MODE_ALIGNMENT (GET_MODE_INNER (<MODE>mode))))
323 {
324 scalar_mode new_smode;
325 switch (MEM_ALIGN (*memloc))
326 {
327 case 64:
328 case 32:
329 new_smode = SImode;
330 break;
331 case 16:
332 new_smode = HImode;
333 break;
334 default:
335 new_smode = QImode;
336 break;
337 }
338 machine_mode new_mode
339 = mode_for_vector (new_smode,
340 GET_MODE_SIZE (<MODE>mode)
341 / GET_MODE_SIZE (new_smode)).require ();
342 rtx new_mem = adjust_address (*memloc, new_mode, 0);
343
344 if (!for_store)
345 {
346 rtx reg = gen_reg_rtx (new_mode);
347 emit_insn (gen_movmisalign (new_mode, reg, new_mem));
348 emit_move_insn (operands[0], gen_lowpart (<MODE>mode, reg));
349 DONE;
350 }
351 emit_insn (gen_movmisalign (new_mode, new_mem,
352 gen_lowpart (new_mode, operands[1])));
353 DONE;
354 }
355
356 /* Legitimize address. */
357 if ((TARGET_HAVE_MVE
358 && !mve_vector_mem_operand (<MODE>mode, XEXP (*memloc, 0), false))
359 || (!TARGET_HAVE_MVE
360 && !neon_vector_mem_operand (*memloc, 2, false)))
361 {
362 rtx new_mem
363 = replace_equiv_address (*memloc,
364 force_reg (Pmode, XEXP (*memloc, 0)),
365 false);
366 gcc_assert (MEM_ALIGN (new_mem) == MEM_ALIGN (*memloc));
367 *memloc = new_mem;
368 }
369 })
370
371 (define_insn "@mve_<mve_insn>q_<supf><mode>"
372 [(set (match_operand:VDQIW 0 "s_register_operand" "=w,w")
373 (unspec:VDQIW [(match_operand:VDQIW 1 "s_register_operand" "w,w")
374 (match_operand:VDQIW 2 "imm_lshift_or_reg_neon" "w,Ds")]
375 VSHLQ))]
376 "ARM_HAVE_<MODE>_ARITH && !TARGET_REALLY_IWMMXT"
377 "@
378 <mve_insn>.<supf>%#<V_sz_elem>\t%<V_reg>0, %<V_reg>1, %<V_reg>2
379 * return neon_output_shift_immediate (\"vshl\", 'i', &operands[2], <MODE>mode, VALID_NEON_QREG_MODE (<MODE>mode), true);"
380 [(set (attr "mve_unpredicated_insn") (symbol_ref "CODE_FOR_mve_<mve_insn>q_<supf><mode>"))
381 (set_attr "type" "neon_shift_reg<q>, neon_shift_imm<q>")]
382 )
383
384 (define_expand "vashl<mode>3"
385 [(set (match_operand:VDQIW 0 "s_register_operand" "")
386 (ashift:VDQIW (match_operand:VDQIW 1 "s_register_operand" "")
387 (match_operand:VDQIW 2 "imm_lshift_or_reg_neon" "")))]
388 "ARM_HAVE_<MODE>_ARITH && !TARGET_REALLY_IWMMXT"
389 {
390 emit_insn (gen_mve_vshlq_u<mode> (operands[0], operands[1], operands[2]));
391 DONE;
392 })
393
394 ;; When operand 2 is an immediate, use the normal expansion to match
395 ;; gen_vashr<mode>3_imm for Neon and gen_mve_vshrq_n_s<mode>_imm for
396 ;; MVE.
397 (define_expand "vashr<mode>3"
398 [(set (match_operand:VDQIW 0 "s_register_operand")
399 (ashiftrt:VDQIW (match_operand:VDQIW 1 "s_register_operand")
400 (match_operand:VDQIW 2 "imm_rshift_or_reg_neon")))]
401 "ARM_HAVE_<MODE>_ARITH && !TARGET_REALLY_IWMMXT"
402 {
403 if (s_register_operand (operands[2], <MODE>mode))
404 {
405 rtx neg = gen_reg_rtx (<MODE>mode);
406 emit_insn (gen_neg<mode>2 (neg, operands[2]));
407 emit_insn (gen_mve_vshlq_s<mode> (operands[0], operands[1], neg));
408 DONE;
409 }
410 })
411
412 ;; When operand 2 is an immediate, use the normal expansion to match
413 ;; gen_vashr<mode>3_imm for Neon and gen_mve_vshrq_n_u<mode>_imm for
414 ;; MVE.
415 (define_expand "vlshr<mode>3"
416 [(set (match_operand:VDQIW 0 "s_register_operand")
417 (lshiftrt:VDQIW (match_operand:VDQIW 1 "s_register_operand")
418 (match_operand:VDQIW 2 "imm_rshift_or_reg_neon")))]
419 "ARM_HAVE_<MODE>_ARITH && !TARGET_REALLY_IWMMXT"
420 {
421 if (s_register_operand (operands[2], <MODE>mode))
422 {
423 rtx neg = gen_reg_rtx (<MODE>mode);
424 emit_insn (gen_neg<mode>2 (neg, operands[2]));
425 emit_insn (gen_mve_vshlq_u<mode> (operands[0], operands[1], neg));
426 DONE;
427 }
428 })
429
430 (define_expand "vec_load_lanesoi<mode>"
431 [(set (match_operand:OI 0 "s_register_operand")
432 (unspec:OI [(match_operand:OI 1 "neon_struct_operand")
433 (unspec:VQ2 [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
434 UNSPEC_VLD2))]
435 "TARGET_NEON"
436 {
437 emit_insn (gen_neon_vld2<mode> (operands[0], operands[1]));
438 DONE;
439 })
440
441 ;;; On MVE we use V2xYYY modes instead of OI
442 (define_expand "vec_load_lanes<MVE_vld2_vst2><mode>"
443 [(set (match_operand:<MVE_VLD2_VST2> 0 "s_register_operand")
444 (unspec:<MVE_VLD2_VST2> [(match_operand:<MVE_VLD2_VST2> 1 "neon_struct_operand")
445 (unspec:MVE_VLD_ST [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
446 UNSPEC_VLD2))]
447 "(TARGET_HAVE_MVE && VALID_MVE_STRUCT_MODE (<MVE_VLD2_VST2>mode))"
448 {
449 emit_insn (gen_mve_vld2q<mode> (operands[0], operands[1]));
450 DONE;
451 })
452
453 (define_expand "vec_store_lanesoi<mode>"
454 [(set (match_operand:OI 0 "neon_struct_operand")
455 (unspec:OI [(match_operand:OI 1 "s_register_operand")
456 (unspec:VQ2 [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
457 UNSPEC_VST2))]
458 "TARGET_NEON"
459 {
460 emit_insn (gen_neon_vst2<mode> (operands[0], operands[1]));
461 DONE;
462 })
463
464 ;;; On MVE we use V2xYYY modes instead of OI
465 (define_expand "vec_store_lanes<MVE_vld2_vst2><mode>"
466 [(set (match_operand:<MVE_VLD2_VST2> 0 "neon_struct_operand")
467 (unspec:<MVE_VLD2_VST2> [(match_operand:<MVE_VLD2_VST2> 1 "s_register_operand")
468 (unspec:MVE_VLD_ST [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
469 UNSPEC_VST2))]
470 "(TARGET_HAVE_MVE && VALID_MVE_STRUCT_MODE (<MVE_VLD2_VST2>mode))"
471 {
472 emit_insn (gen_mve_vst2q<mode> (operands[0], operands[1]));
473 DONE;
474 })
475
476 (define_expand "vec_load_lanesxi<mode>"
477 [(match_operand:XI 0 "s_register_operand")
478 (match_operand:XI 1 "neon_struct_operand")
479 (unspec:VQ2 [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
480 "TARGET_NEON"
481 {
482 emit_insn (gen_neon_vld4<mode> (operands[0], operands[1]));
483 DONE;
484 })
485
486 ;;; On MVE we use V4xYYY modes instead of XI
487 (define_expand "vec_load_lanes<MVE_vld4_vst4><mode>"
488 [(set (match_operand:<MVE_VLD4_VST4> 0 "s_register_operand")
489 (unspec:<MVE_VLD4_VST4> [(match_operand:<MVE_VLD4_VST4> 1 "neon_struct_operand")
490 (unspec:MVE_VLD_ST [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
491 UNSPEC_VLD4))]
492 "(TARGET_HAVE_MVE && VALID_MVE_STRUCT_MODE (<MVE_VLD4_VST4>mode))"
493 {
494 emit_insn (gen_mve_vld4q<mode> (operands[0], operands[1]));
495 DONE;
496 })
497
498 (define_expand "vec_store_lanesxi<mode>"
499 [(match_operand:XI 0 "neon_struct_operand")
500 (match_operand:XI 1 "s_register_operand")
501 (unspec:VQ2 [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
502 "TARGET_NEON"
503 {
504 emit_insn (gen_neon_vst4<mode> (operands[0], operands[1]));
505 DONE;
506 })
507
508 ;;; On MVE we use V4xYYY modes instead of XI
509 (define_expand "vec_store_lanes<MVE_vld4_vst4><mode>"
510 [(set (match_operand:<MVE_VLD4_VST4> 0 "neon_struct_operand")
511 (unspec:<MVE_VLD4_VST4> [(match_operand:<MVE_VLD4_VST4> 1 "s_register_operand")
512 (unspec:MVE_VLD_ST [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
513 UNSPEC_VST4))]
514 "(TARGET_HAVE_MVE && VALID_MVE_STRUCT_MODE (<MVE_VLD4_VST4>mode))"
515 {
516 emit_insn (gen_mve_vst4q<mode> (operands[0], operands[1]));
517 DONE;
518 })
519
520 (define_expand "reduc_plus_scal_<mode>"
521 [(match_operand:<V_elem> 0 "nonimmediate_operand")
522 (match_operand:VQ 1 "s_register_operand")]
523 "ARM_HAVE_<MODE>_ARITH
524 && !(TARGET_HAVE_MVE && FLOAT_MODE_P (<MODE>mode))
525 && !BYTES_BIG_ENDIAN"
526 {
527 if (TARGET_NEON)
528 {
529 rtx step1 = gen_reg_rtx (<V_HALF>mode);
530
531 emit_insn (gen_quad_halves_plus<mode> (step1, operands[1]));
532 emit_insn (gen_reduc_plus_scal_<V_half> (operands[0], step1));
533 }
534 else
535 {
536 /* vaddv generates a 32 bits accumulator. */
537 rtx op0 = gen_reg_rtx (SImode);
538
539 emit_insn (gen_mve_q (VADDVQ_S, VADDVQ_S, <MODE>mode, op0, operands[1]));
540 emit_move_insn (operands[0], gen_lowpart (<V_elem>mode, op0));
541 }
542
543 DONE;
544 })
545
546 (define_expand "avg<mode>3_floor"
547 [(match_operand:MVE_2 0 "s_register_operand")
548 (match_operand:MVE_2 1 "s_register_operand")
549 (match_operand:MVE_2 2 "s_register_operand")]
550 "ARM_HAVE_<MODE>_ARITH"
551 {
552 if (TARGET_HAVE_MVE)
553 emit_insn (gen_mve_q (VHADDQ_S, VHADDQ_S, <MODE>mode,
554 operands[0], operands[1], operands[2]));
555 else
556 emit_insn (gen_neon_vhadd (UNSPEC_VHADD_S, UNSPEC_VHADD_S, <MODE>mode,
557 operands[0], operands[1], operands[2]));
558 DONE;
559 })
560
561 (define_expand "uavg<mode>3_floor"
562 [(match_operand:MVE_2 0 "s_register_operand")
563 (match_operand:MVE_2 1 "s_register_operand")
564 (match_operand:MVE_2 2 "s_register_operand")]
565 "ARM_HAVE_<MODE>_ARITH"
566 {
567 if (TARGET_HAVE_MVE)
568 emit_insn (gen_mve_q (VHADDQ_U, VHADDQ_U, <MODE>mode,
569 operands[0], operands[1], operands[2]));
570 else
571 emit_insn (gen_neon_vhadd (UNSPEC_VHADD_U, UNSPEC_VHADD_U, <MODE>mode,
572 operands[0], operands[1], operands[2]));
573 DONE;
574 })
575
576 (define_expand "avg<mode>3_ceil"
577 [(match_operand:MVE_2 0 "s_register_operand")
578 (match_operand:MVE_2 1 "s_register_operand")
579 (match_operand:MVE_2 2 "s_register_operand")]
580 "ARM_HAVE_<MODE>_ARITH"
581 {
582 if (TARGET_HAVE_MVE)
583 emit_insn (gen_mve_q (VRHADDQ_S, VRHADDQ_S, <MODE>mode,
584 operands[0], operands[1], operands[2]));
585 else
586 emit_insn (gen_neon_vhadd (UNSPEC_VRHADD_S, UNSPEC_VRHADD_S, <MODE>mode,
587 operands[0], operands[1], operands[2]));
588 DONE;
589 })
590
591 (define_expand "uavg<mode>3_ceil"
592 [(match_operand:MVE_2 0 "s_register_operand")
593 (match_operand:MVE_2 1 "s_register_operand")
594 (match_operand:MVE_2 2 "s_register_operand")]
595 "ARM_HAVE_<MODE>_ARITH"
596 {
597 if (TARGET_HAVE_MVE)
598 emit_insn (gen_mve_q (VRHADDQ_U, VRHADDQ_U, <MODE>mode,
599 operands[0], operands[1], operands[2]));
600 else
601 emit_insn (gen_neon_vhadd (UNSPEC_VRHADD_U, UNSPEC_VRHADD_U, <MODE>mode,
602 operands[0], operands[1], operands[2]));
603 DONE;
604 })
605
606 (define_expand "clz<mode>2"
607 [(set (match_operand:VDQIW 0 "s_register_operand")
608 (clz:VDQIW (match_operand:VDQIW 1 "s_register_operand")))]
609 "ARM_HAVE_<MODE>_ARITH
610 && !TARGET_REALLY_IWMMXT"
611 )
612 (define_expand "vec_init<mode><V_elem_l>"
613 [(match_operand:VDQX 0 "s_register_operand")
614 (match_operand 1 "" "")]
615 "TARGET_NEON || (TARGET_HAVE_MVE && VALID_MVE_MODE (<MODE>mode))"
616 {
617 neon_expand_vector_init (operands[0], operands[1]);
618 DONE;
619 })