Debian Codegraph @

gcc/config/aarch64/aarch64-sve2.md

raw
1 ;; Machine description for AArch64 SVE2.
2 ;; Copyright (C) 2019-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 file is organised into the following sections (search for the full
22 ;; line):
23 ;;
24 ;; == Moves
25 ;; ---- Predicate to vector moves
26 ;; ---- Vector to predicate moves
27 ;;
28 ;; == Loads
29 ;; ---- 128-bit extending loads
30 ;; ---- 128-bit structure loads
31 ;; ---- Multi-register loads predicated by a counter
32 ;; ---- 128-bit gather loads
33 ;; ---- Non-temporal gather loads
34 ;;
35 ;; == Stores
36 ;; ---- 128-bit truncating stores
37 ;; ---- 128-bit structure stores
38 ;; ---- Multi-register stores predicated by a counter
39 ;; ---- 128-bit scatter stores
40 ;; ---- Non-temporal scatter stores
41 ;;
42 ;; == Predicate manipulation
43 ;; ---- [PRED] Predicate-as-counter PTRUE
44 ;; ---- [PRED] Predicate extraction
45 ;; ---- [PRED] Predicate selection
46 ;; ---- [PRED] Predicate count
47 ;;
48 ;; == Uniform unary arithmnetic
49 ;; ---- [FP] Multi-register unary operations
50 ;;
51 ;; == Uniform binary arithmnetic
52 ;; ---- [INT] Multi-register operations
53 ;; ---- [INT] Clamp to minimum/maximum
54 ;; ---- [INT] Multiplication
55 ;; ---- [INT] Scaled high-part multiplication
56 ;; ---- [INT] General binary arithmetic that maps to unspecs
57 ;; ---- [INT] Saturating binary arithmetic
58 ;; ---- [INT] Saturating left shifts
59 ;; ---- [FP] Non-widening bfloat16 arithmetic
60 ;; ---- [FP] Clamp to minimum/maximum
61 ;;
62 ;; == Uniform ternary arithmnetic
63 ;; ---- [INT] General ternary arithmetic that maps to unspecs
64 ;; ---- [INT] Multiply-and-accumulate operations
65 ;; ---- [INT] Binary logic operations with rotation
66 ;; ---- [INT] Ternary logic operations
67 ;; ---- [INT] Shift-and-accumulate operations
68 ;; ---- [INT] Shift-and-insert operations
69 ;; ---- [INT] Sum of absolute differences
70 ;; ---- [FP] Mfloat8 Multiply-and-accumulate operations
71 ;; ---- [FP] Mfloat8 dot products
72 ;;
73 ;; == Extending arithmetic
74 ;; ---- [INT] Multi-register widening conversions
75 ;; ---- [INT] Wide binary arithmetic
76 ;; ---- [INT] Long binary arithmetic
77 ;; ---- [INT] Long left shifts
78 ;; ---- [INT] Long binary arithmetic with accumulation
79 ;; ---- [FP] Multi-register operations
80 ;; ---- [FP] Long multiplication with accumulation
81 ;;
82 ;; == Narrowing arithnetic
83 ;; ---- [INT] Narrowing unary arithmetic
84 ;; ---- [INT] Multi-vector narrowing unary arithmetic
85 ;; ---- [INT] Narrowing binary arithmetic
86 ;; ---- [INT] Narrowing right shifts
87 ;; ---- [INT] Multi-vector narrowing right shifts
88 ;;
89 ;; == Pairwise arithmetic
90 ;; ---- [INT] Pairwise arithmetic
91 ;; ---- [FP] Pairwise arithmetic
92 ;; ---- [INT] Pairwise arithmetic with accumulation
93 ;;
94 ;; == Complex arithmetic
95 ;; ---- [INT] Complex binary operations
96 ;; ---- [INT] Complex ternary operations
97 ;; ---- [INT] Complex dot product
98 ;;
99 ;; == Conversions
100 ;; ---- [FP<-FP] Widening conversions
101 ;; ---- [FP<-FP] Narrowing conversions
102 ;; ---- [FP<-FP] Multi-vector widening conversions
103 ;; ---- [FP<-FP] Multi-vector narrowing conversions
104 ;; ---- [FP<-INT] Multi-vector conversions
105 ;; ---- [INT<-FP] Multi-vector conversions
106 ;;
107 ;; == Other arithmetic
108 ;; ---- [INT] Reciprocal approximation
109 ;; ---- [INT<-FP] Base-2 logarithm
110 ;; ---- [INT] Polynomial multiplication
111 ;;
112 ;; == Comparisons and selects
113 ;; ---- [INT,FP] Select based on predicates as counters
114 ;; ---- [INT] While tests
115 ;;
116 ;; == Reductions
117 ;; ---- [INT] Reduction to 128-bit vector
118 ;; ---- [FP] Reduction to 128-bit vector
119 ;;
120 ;; == Permutation
121 ;; ---- [INT,FP] Reversal
122 ;; ---- [INT,FP] HVLA permutes
123 ;; ---- [INT,FP] General permutes
124 ;; ---- [INT,FP] Multi-register permutes
125 ;; ---- [INT] Optional bit-permute extensions
126 ;;
127 ;; == General
128 ;; ---- Check for aliases between pointers
129 ;; ---- Histogram processing
130 ;; ---- String matching
131 ;; ---- Table lookup
132 ;;
133 ;; == Cryptographic extensions
134 ;; ---- Optional AES extensions
135 ;; ---- Optional SHA-3 extensions
136 ;; ---- Optional SM4 extensions
137
138 ;; =========================================================================
139 ;; == Moves
140 ;; =========================================================================
141
142 ;; -------------------------------------------------------------------------
143 ;; ---- Predicate to vector moves
144 ;; -------------------------------------------------------------------------
145 ;; Includes:
146 ;; - PMOV (to vector) (SVE2p1)
147 ;; -------------------------------------------------------------------------
148
149 (define_insn "@aarch64_pmov_to_<mode>"
150 [(set (match_operand:SVE_FULL_I 0 "register_operand" "=w")
151 (unspec:SVE_FULL_I
152 [(match_operand:<VPRED> 1 "register_operand" "Upa")]
153 UNSPEC_PMOV_UNPACK))]
154 "TARGET_SVE2p1 && TARGET_NON_STREAMING"
155 "pmov\t%0, %1.<Vetype>"
156 )
157
158 (define_insn "@aarch64_pmov_lane_to_<mode>"
159 [(set (match_operand:SVE_FULL_I 0 "register_operand" "=w")
160 (unspec:SVE_FULL_I
161 [(match_operand:SVE_FULL_I 1 "register_operand" "0")
162 (match_operand:<VPRED> 2 "register_operand" "Upa")
163 (match_operand:DI 3 "immediate_operand")]
164 UNSPEC_PMOV_UNPACK_LANE))]
165 "TARGET_SVE2p1 && TARGET_NON_STREAMING"
166 "pmov\t%0[%3], %2.<Vetype>"
167 )
168
169 ;; -------------------------------------------------------------------------
170 ;; ---- Vector to predicate moves
171 ;; -------------------------------------------------------------------------
172 ;; Includes:
173 ;; - PMOV (from vector) (SVE2p1)
174 ;; -------------------------------------------------------------------------
175
176 (define_insn "@aarch64_pmov_from_<mode>"
177 [(set (match_operand:VNx16BI 0 "register_operand" "=Upa")
178 (unspec:VNx16BI
179 [(match_operand:SVE_FULL_I 1 "register_operand" "w")]
180 UNSPEC_PMOV_PACK))]
181 "TARGET_SVE2p1 && TARGET_NON_STREAMING"
182 "pmov\t%0.<Vetype>, %1"
183 )
184
185 (define_insn "@aarch64_pmov_lane_from_<mode>"
186 [(set (match_operand:VNx16BI 0 "register_operand" "=Upa")
187 (unspec:VNx16BI
188 [(match_operand:SVE_FULL_I 1 "register_operand" "w")
189 (match_operand:DI 2 "immediate_operand")]
190 UNSPEC_PMOV_PACK_LANE))]
191 "TARGET_SVE2p1 && TARGET_NON_STREAMING"
192 "pmov\t%0.<Vetype>, %1[%2]"
193 )
194
195 ;; =========================================================================
196 ;; == Loads
197 ;; =========================================================================
198
199 ;; -------------------------------------------------------------------------
200 ;; ---- 128-bit extending loads
201 ;; -------------------------------------------------------------------------
202 ;; Includes:
203 ;; - LD1W (to .Q) (SVE2p1)
204 ;; - LD1D (to .Q) (SVE2p1)
205 ;; -------------------------------------------------------------------------
206
207 ;; There isn't really a natural way of representing these instructions
208 ;; with the modes that we normally use:
209 ;;
210 ;; (1) It doesn't really make sense to use VNx1TI (or similar) for the
211 ;; result, since there's nothing that can be done with such a mode
212 ;; other than to cast it to another mode. It also isn't how the
213 ;; ACLE represents it (for similar reasons).
214 ;;
215 ;; (2) Only the lowest bit of each 16 in the predicate is significant,
216 ;; but it doesn't really make sense to use VNx1BI to represent it,
217 ;; since there is no "PTRUE Pn.Q, ..." instruction.
218 ;;
219 ;; (3) We do however need to use VNx1DI and VNx1SI to represent the
220 ;; source memories, since none of the normal register modes would
221 ;; give the right extent and alignment information (with the alignment
222 ;; mattering only for -mstrict-align).
223 (define_insn "@aarch64_sve_ld1_extendq<mode>"
224 [(set (match_operand:SVE_FULL_SD 0 "register_operand" "=w")
225 (unspec:SVE_FULL_SD
226 [(match_operand:<VPRED> 2 "register_operand" "Upl")
227 (match_operand:<LD1_EXTENDQ_MEM> 1 "memory_operand" "m")]
228 UNSPEC_LD1_EXTENDQ))]
229 "TARGET_SVE2p1 && TARGET_NON_STREAMING"
230 "ld1<Vesize>\t{%0.q}, %2/z, %1"
231 )
232
233 ;; -------------------------------------------------------------------------
234 ;; ---- 128-bit structure loads
235 ;; -------------------------------------------------------------------------
236 ;; Includes:
237 ;; - LD2Q (SVE2p1)
238 ;; - LD3Q (SVE2p1)
239 ;; - LD4Q (SVE2p1)
240 ;; -------------------------------------------------------------------------
241
242 ;; Predicated LD[234]Q.
243 (define_insn "@aarch64_sve_ldnq<mode>"
244 [(set (match_operand:SVE_STRUCT 0 "register_operand" "=w")
245 (unspec:SVE_STRUCT
246 [(match_operand:<VPRED> 2 "register_operand" "Upl")
247 (match_operand:<VNxTI> 1 "memory_operand" "m")]
248 UNSPEC_LDNQ))]
249 "TARGET_SVE2p1 && TARGET_NON_STREAMING"
250 "ld<vector_count>q\t{%S0.q - %<Vendreg>0.q}, %2/z, %1"
251 )
252
253 ;; -------------------------------------------------------------------------
254 ;; ---- Multi-register loads predicated by a counter
255 ;; -------------------------------------------------------------------------
256 ;; Includes:
257 ;; - LD1B
258 ;; - LD1D
259 ;; - LD1H
260 ;; - LD1W
261 ;; - LDNT1B
262 ;; - LDNT1D
263 ;; - LDNT1H
264 ;; - LDNT1W
265 ;; -------------------------------------------------------------------------
266
267 ;; Predicated LD1 (multi), with a count as predicate.
268 (define_insn "@aarch64_<optab><mode>"
269 [(set (match_operand:SVE_FULLx24 0 "aligned_register_operand" "=Uw<vector_count>")
270 (unspec:SVE_FULLx24
271 [(match_operand:VNx16BI 2 "register_operand" "Uph")
272 (match_operand:SVE_FULLx24 1 "memory_operand" "m")
273 (match_operand:SVE_FULLx24 3 "aarch64_maskload_else_operand")]
274 LD1_COUNT))]
275 "TARGET_SVE2p1_OR_SME2"
276 "<optab><Vesize>\t%0, %K2/z, %1"
277 [(set_attr "stride_type" "ld1_consecutive")]
278 )
279
280 (define_insn "@aarch64_<optab><mode>_strided2"
281 [(set (match_operand:<VSINGLE> 0 "aarch64_simd_register" "=Uwd")
282 (unspec:<VSINGLE>
283 [(match_operand:VNx16BI 3 "register_operand" "Uph")
284 (match_operand:SVE_FULLx2 2 "memory_operand" "m")
285 (const_int 0)]
286 LD1_COUNT))
287 (set (match_operand:<VSINGLE> 1 "aarch64_simd_register" "=w")
288 (unspec:<VSINGLE>
289 [(match_dup 3)
290 (match_dup 2)
291 (const_int 1)]
292 LD1_COUNT))]
293 "TARGET_STREAMING_SME2
294 && aarch64_strided_registers_p (operands, 2, 8)"
295 "<optab><Vesize>\t{%0.<Vetype>, %1.<Vetype>}, %K3/z, %2"
296 [(set_attr "stride_type" "ld1_strided")]
297 )
298
299 (define_insn "@aarch64_<optab><mode>_strided4"
300 [(set (match_operand:<VSINGLE> 0 "aarch64_simd_register" "=Uwt")
301 (unspec:<VSINGLE>
302 [(match_operand:VNx16BI 5 "register_operand" "Uph")
303 (match_operand:SVE_FULLx4 4 "memory_operand" "m")
304 (const_int 0)]
305 LD1_COUNT))
306 (set (match_operand:<VSINGLE> 1 "aarch64_simd_register" "=w")
307 (unspec:<VSINGLE>
308 [(match_dup 5)
309 (match_dup 4)
310 (const_int 1)]
311 LD1_COUNT))
312 (set (match_operand:<VSINGLE> 2 "aarch64_simd_register" "=w")
313 (unspec:<VSINGLE>
314 [(match_dup 5)
315 (match_dup 4)
316 (const_int 2)]
317 LD1_COUNT))
318 (set (match_operand:<VSINGLE> 3 "aarch64_simd_register" "=w")
319 (unspec:<VSINGLE>
320 [(match_dup 5)
321 (match_dup 4)
322 (const_int 3)]
323 LD1_COUNT))]
324 "TARGET_STREAMING_SME2
325 && aarch64_strided_registers_p (operands, 4, 4)"
326 "<optab><Vesize>\t{%0.<Vetype>, %1.<Vetype>, %2.<Vetype>, %3.<Vetype>}, %K5/z, %4"
327 [(set_attr "stride_type" "ld1_strided")]
328 )
329
330 ;; -------------------------------------------------------------------------
331 ;; ---- 128-bit gather loads
332 ;; -------------------------------------------------------------------------
333 ;; Includes gather forms of:
334 ;; - LD1Q (SVE2p1)
335 ;; -------------------------------------------------------------------------
336
337 ;; For little-endian targets, it would be enough to use a single pattern,
338 ;; with a subreg to bitcast the result to whatever mode is needed.
339 ;; However, on big-endian targets, the bitcast would need to be an
340 ;; aarch64_sve_reinterpret instruction. That would interact badly
341 ;; with the "&" and "?" constraints in this pattern: if the result
342 ;; of the reinterpret needs to be in the same register as the index,
343 ;; the RA would tend to prefer to allocate a separate register for the
344 ;; intermediate (uncast) result, even if the reinterpret prefers tying.
345 ;;
346 ;; The index is logically VNx1DI rather than VNx2DI, but introducing
347 ;; and using VNx1DI would just create more bitcasting. The ACLE intrinsic
348 ;; uses svuint64_t, which corresponds to VNx2DI.
349 (define_insn "@aarch64_gather_ld1q<mode>"
350 [(set (match_operand:SVE_FULL 0 "register_operand")
351 (unspec:SVE_FULL
352 [(match_operand:VNx2BI 1 "register_operand")
353 (match_operand:DI 2 "aarch64_reg_or_zero")
354 (match_operand:VNx2DI 3 "register_operand")
355 (mem:BLK (scratch))]
356 UNSPEC_LD1_GATHER))]
357 "TARGET_SVE2p1 && TARGET_NON_STREAMING"
358 {@ [cons: =0, 1, 2, 3]
359 [&w, Upl, Z, w] ld1q\t{%0.q}, %1/z, [%3.d]
360 [?w, Upl, Z, 0] ^
361 [&w, Upl, r, w] ld1q\t{%0.q}, %1/z, [%3.d, %2]
362 [?w, Upl, r, 0] ^
363 }
364 )
365
366 ;; -------------------------------------------------------------------------
367 ;; ---- Non-temporal gather loads
368 ;; -------------------------------------------------------------------------
369 ;; Includes gather forms of:
370 ;; - LDNT1B
371 ;; - LDNT1D
372 ;; - LDNT1H
373 ;; - LDNT1W
374 ;; -------------------------------------------------------------------------
375
376 ;; Non-extending loads.
377 (define_insn "@aarch64_gather_ldnt<mode>"
378 [(set (match_operand:SVE_FULL_SD 0 "register_operand")
379 (unspec:SVE_FULL_SD
380 [(match_operand:<VPRED> 1 "register_operand")
381 (match_operand:DI 2 "aarch64_reg_or_zero")
382 (match_operand:<V_INT_EQUIV> 3 "register_operand")
383 (mem:BLK (scratch))]
384 UNSPEC_LDNT1_GATHER))]
385 "TARGET_SVE2 && TARGET_NON_STREAMING"
386 {@ [cons: =0, 1, 2, 3]
387 [&w, Upl, Z, w ] ldnt1<Vesize>\t%0.<Vetype>, %1/z, [%3.<Vetype>]
388 [?w, Upl, Z, 0 ] ^
389 [&w, Upl, r, w ] ldnt1<Vesize>\t%0.<Vetype>, %1/z, [%3.<Vetype>, %2]
390 [?w, Upl, r, 0 ] ^
391 }
392 )
393
394 ;; Extending loads.
395 (define_insn_and_rewrite "@aarch64_gather_ldnt_<ANY_EXTEND:optab><SVE_FULL_SDI:mode><SVE_PARTIAL_I:mode>"
396 [(set (match_operand:SVE_FULL_SDI 0 "register_operand")
397 (unspec:SVE_FULL_SDI
398 [(match_operand:<SVE_FULL_SDI:VPRED> 4 "general_operand")
399 (ANY_EXTEND:SVE_FULL_SDI
400 (unspec:SVE_PARTIAL_I
401 [(match_operand:<SVE_FULL_SDI:VPRED> 1 "register_operand")
402 (match_operand:DI 2 "aarch64_reg_or_zero")
403 (match_operand:<SVE_FULL_SDI:V_INT_EQUIV> 3 "register_operand")
404 (mem:BLK (scratch))]
405 UNSPEC_LDNT1_GATHER))]
406 UNSPEC_PRED_X))]
407 "TARGET_SVE2
408 && TARGET_NON_STREAMING
409 && (~<SVE_FULL_SDI:narrower_mask> & <SVE_PARTIAL_I:self_mask>) == 0"
410 {@ [cons: =0, 1, 2, 3, 4]
411 [&w, Upl, Z, w, UplDnm] ldnt1<ANY_EXTEND:s><SVE_PARTIAL_I:Vesize>\t%0.<SVE_FULL_SDI:Vetype>, %1/z, [%3.<SVE_FULL_SDI:Vetype>]
412 [?w, Upl, Z, 0, UplDnm] ^
413 [&w, Upl, r, w, UplDnm] ldnt1<ANY_EXTEND:s><SVE_PARTIAL_I:Vesize>\t%0.<SVE_FULL_SDI:Vetype>, %1/z, [%3.<SVE_FULL_SDI:Vetype>, %2]
414 [?w, Upl, r, 0, UplDnm] ^
415 }
416 "&& !CONSTANT_P (operands[4])"
417 {
418 operands[4] = CONSTM1_RTX (<SVE_FULL_SDI:VPRED>mode);
419 }
420 )
421
422 ;; =========================================================================
423 ;; == Stores
424 ;; =========================================================================
425
426 ;; -------------------------------------------------------------------------
427 ;; ---- 128-bit truncating stores
428 ;; -------------------------------------------------------------------------
429 ;; Includes:
430 ;; - ST1W (from .Q) (SVE2p1)
431 ;; - ST1D (from .Q) (SVE2p1)
432 ;; -------------------------------------------------------------------------
433
434 ;; See the comment above the corresponding loads for a discussion about the
435 ;; choice of modes.
436 (define_insn "@aarch64_sve_st1_truncq<mode>"
437 [(set (match_operand:<LD1_EXTENDQ_MEM> 0 "memory_operand" "+m")
438 (unspec:<LD1_EXTENDQ_MEM>
439 [(match_operand:<VPRED> 2 "register_operand" "Upl")
440 (match_operand:SVE_FULL_SD 1 "register_operand" "w")
441 (match_dup 0)]
442 UNSPEC_ST1_TRUNCQ))]
443 "TARGET_SVE2p1 && TARGET_NON_STREAMING"
444 "st1<Vesize>\t{%1.q}, %2, %0"
445 )
446
447 ;; -------------------------------------------------------------------------
448 ;; ---- 128-bit structure stores
449 ;; -------------------------------------------------------------------------
450 ;; Includes:
451 ;; - ST2Q (SVE2p1)
452 ;; - ST3Q (SVE2p1)
453 ;; - ST4Q (SVE2p1)
454 ;; -------------------------------------------------------------------------
455
456 ;; Predicated ST[234].
457 (define_insn "@aarch64_sve_stnq<mode>"
458 [(set (match_operand:<VNxTI> 0 "memory_operand" "+m")
459 (unspec:<VNxTI>
460 [(match_operand:<VPRED> 2 "register_operand" "Upl")
461 (match_operand:SVE_STRUCT 1 "register_operand" "w")
462 (match_dup 0)]
463 UNSPEC_STNQ))]
464 "TARGET_SVE2p1 && TARGET_NON_STREAMING"
465 "st<vector_count>q\t{%S1.q - %<Vendreg>1.q}, %2, %0"
466 )
467
468 ;; -------------------------------------------------------------------------
469 ;; ---- Multi-register stores predicated by a counter
470 ;; -------------------------------------------------------------------------
471 ;; Includes:
472 ;; - ST1B
473 ;; - ST1D
474 ;; - ST1H
475 ;; - ST1W
476 ;; - STNT1B
477 ;; - STNT1D
478 ;; - STNT1H
479 ;; - STNT1W
480 ;; -------------------------------------------------------------------------
481
482 (define_insn "@aarch64_<optab><mode>"
483 [(set (match_operand:SVE_FULLx24 0 "memory_operand" "+m")
484 (unspec:SVE_FULLx24
485 [(match_operand:VNx16BI 2 "register_operand" "Uph")
486 (match_operand:SVE_FULLx24 1 "aligned_register_operand" "Uw<vector_count>")
487 (match_dup 0)]
488 ST1_COUNT))]
489 "TARGET_SVE2p1_OR_SME2"
490 "<optab><Vesize>\t%1, %K2, %0"
491 [(set_attr "stride_type" "st1_consecutive")]
492 )
493
494 (define_insn "@aarch64_<optab><mode>_strided2"
495 [(set (match_operand:SVE_FULLx24 0 "memory_operand" "+m")
496 (unspec:SVE_FULLx24
497 [(match_operand:VNx16BI 1 "register_operand" "Uph")
498 (match_operand:<VSINGLE> 2 "aarch64_simd_register" "Uwd")
499 (match_operand:<VSINGLE> 3 "aarch64_simd_register" "w")
500 (match_dup 0)]
501 ST1_COUNT))]
502 "TARGET_STREAMING_SME2
503 && aarch64_strided_registers_p (operands + 2, 2, 8)"
504 "<optab><Vesize>\t{%2.<Vetype>, %3.<Vetype>}, %K1, %0"
505 [(set_attr "stride_type" "st1_strided")]
506 )
507
508 (define_insn "@aarch64_<optab><mode>_strided4"
509 [(set (match_operand:SVE_FULLx24 0 "memory_operand" "+m")
510 (unspec:SVE_FULLx24
511 [(match_operand:VNx16BI 1 "register_operand" "Uph")
512 (match_operand:<VSINGLE> 2 "aarch64_simd_register" "Uwt")
513 (match_operand:<VSINGLE> 3 "aarch64_simd_register" "w")
514 (match_operand:<VSINGLE> 4 "aarch64_simd_register" "w")
515 (match_operand:<VSINGLE> 5 "aarch64_simd_register" "w")
516 (match_dup 0)]
517 ST1_COUNT))]
518 "TARGET_STREAMING_SME2
519 && aarch64_strided_registers_p (operands + 2, 4, 4)"
520 "<optab><Vesize>\t{%2.<Vetype>, %3.<Vetype>, %4.<Vetype>, %5.<Vetype>}, %K1, %0"
521 [(set_attr "stride_type" "st1_strided")]
522 )
523
524 ;; -------------------------------------------------------------------------
525 ;; ---- 128-bit scatter stores
526 ;; -------------------------------------------------------------------------
527 ;; Includes scatter form of:
528 ;; - ST1Q (SVE2p1)
529 ;; -------------------------------------------------------------------------
530
531 (define_insn "aarch64_scatter_st1q"
532 [(set (mem:BLK (scratch))
533 (unspec:BLK
534 [(match_operand:VNx2BI 0 "register_operand")
535 (match_operand:DI 1 "aarch64_reg_or_zero")
536 (match_operand:VNx2DI 2 "register_operand")
537 (match_operand:VNx2DI 3 "register_operand")]
538 UNSPEC_ST1Q_SCATTER))]
539 "TARGET_SVE2p1 && TARGET_NON_STREAMING"
540 {@ [ cons: 0 , 1 , 2 , 3 ]
541 [ Upl , Z , w , w ] st1q\t{%3.q}, %0, [%2.d]
542 [ Upl , r , w , w ] st1q\t{%3.q}, %0, [%2.d, %1]
543 }
544 )
545
546 ;; -------------------------------------------------------------------------
547 ;; ---- Non-temporal scatter stores
548 ;; -------------------------------------------------------------------------
549 ;; Includes scatter forms of:
550 ;; - STNT1B
551 ;; - STNT1D
552 ;; - STNT1H
553 ;; - STNT1W
554 ;; -------------------------------------------------------------------------
555
556 ;; Non-truncating stores.
557 (define_insn "@aarch64_scatter_stnt<mode>"
558 [(set (mem:BLK (scratch))
559 (unspec:BLK
560 [(match_operand:<VPRED> 0 "register_operand")
561 (match_operand:DI 1 "aarch64_reg_or_zero")
562 (match_operand:<V_INT_EQUIV> 2 "register_operand")
563 (match_operand:SVE_FULL_SD 3 "register_operand")]
564
565 UNSPEC_STNT1_SCATTER))]
566 "TARGET_SVE && TARGET_NON_STREAMING"
567 {@ [ cons: 0 , 1 , 2 , 3 ]
568 [ Upl , Z , w , w ] stnt1<Vesize>\t%3.<Vetype>, %0, [%2.<Vetype>]
569 [ Upl , r , w , w ] stnt1<Vesize>\t%3.<Vetype>, %0, [%2.<Vetype>, %1]
570 }
571 )
572
573 ;; Truncating stores.
574 (define_insn "@aarch64_scatter_stnt_<SVE_FULL_SDI:mode><SVE_PARTIAL_I:mode>"
575 [(set (mem:BLK (scratch))
576 (unspec:BLK
577 [(match_operand:<SVE_FULL_SDI:VPRED> 0 "register_operand")
578 (match_operand:DI 1 "aarch64_reg_or_zero")
579 (match_operand:<SVE_FULL_SDI:V_INT_EQUIV> 2 "register_operand")
580 (truncate:SVE_PARTIAL_I
581 (match_operand:SVE_FULL_SDI 3 "register_operand"))]
582 UNSPEC_STNT1_SCATTER))]
583 "TARGET_SVE2
584 && TARGET_NON_STREAMING
585 && (~<SVE_FULL_SDI:narrower_mask> & <SVE_PARTIAL_I:self_mask>) == 0"
586 {@ [ cons: 0 , 1 , 2 , 3 ]
587 [ Upl , Z , w , w ] stnt1<SVE_PARTIAL_I:Vesize>\t%3.<SVE_FULL_SDI:Vetype>, %0, [%2.<SVE_FULL_SDI:Vetype>]
588 [ Upl , r , w , w ] stnt1<SVE_PARTIAL_I:Vesize>\t%3.<SVE_FULL_SDI:Vetype>, %0, [%2.<SVE_FULL_SDI:Vetype>, %1]
589 }
590 )
591
592 ;; =========================================================================
593 ;; == Predicate manipulation
594 ;; =========================================================================
595
596 ;; -------------------------------------------------------------------------
597 ;; ---- [PRED] Predicate-as-counter PTRUE
598 ;; -------------------------------------------------------------------------
599 ;; - PTRUE (predicate-as-counter form)
600 ;; -------------------------------------------------------------------------
601
602 (define_insn "@aarch64_sve_ptrue_c<BHSD_BITS>"
603 [(set (match_operand:VNx16BI 0 "register_operand" "=Uph")
604 (unspec:VNx16BI [(const_int BHSD_BITS)] UNSPEC_PTRUE_C))]
605 "TARGET_SVE2p1_OR_SME2"
606 "ptrue\t%K0.<bits_etype>"
607 )
608
609 ;; -------------------------------------------------------------------------
610 ;; ---- [PRED] Predicate extraction
611 ;; -------------------------------------------------------------------------
612 ;; Includes
613 ;; - PEXT
614 ;; -------------------------------------------------------------------------
615
616 (define_insn "@aarch64_sve_pext<BHSD_BITS>"
617 [(set (match_operand:VNx16BI 0 "register_operand" "=Upa")
618 (unspec:VNx16BI
619 [(match_operand:VNx16BI 1 "register_operand" "Uph")
620 (match_operand:DI 2 "const_int_operand")
621 (const_int BHSD_BITS)]
622 UNSPEC_PEXT))]
623 "TARGET_SVE2p1_OR_SME2"
624 "pext\t%0.<bits_etype>, %K1[%2]"
625 )
626
627 (define_insn "@aarch64_sve_pext<BHSD_BITS>x2"
628 [(set (match_operand:VNx32BI 0 "register_operand" "=Up2")
629 (unspec:VNx32BI
630 [(match_operand:VNx16BI 1 "register_operand" "Uph")
631 (match_operand:DI 2 "const_int_operand")
632 (const_int BHSD_BITS)]
633 UNSPEC_PEXTx2))]
634 "TARGET_SVE2p1_OR_SME2"
635 "pext\t{%S0.<bits_etype>, %T0.<bits_etype>}, %K1[%2]"
636 )
637
638 ;; -------------------------------------------------------------------------
639 ;; ---- [PRED] Predicate selection
640 ;; -------------------------------------------------------------------------
641 ;; Includes
642 ;; - PSEL
643 ;; -------------------------------------------------------------------------
644
645 (define_insn "@aarch64_sve_psel<BHSD_BITS>"
646 [(set (match_operand:VNx16BI 0 "register_operand" "=Upa")
647 (unspec:VNx16BI
648 [(match_operand:VNx16BI 1 "register_operand" "Upa")
649 (match_operand:VNx16BI 2 "register_operand" "Upa")
650 (match_operand:SI 3 "register_operand" "Ucj")
651 (const_int BHSD_BITS)]
652 UNSPEC_PSEL))]
653 "TARGET_SVE2p1_OR_SME"
654 "psel\t%0, %1, %2.<bits_etype>[%w3, 0]"
655 )
656
657 (define_insn "*aarch64_sve_psel<BHSD_BITS>_plus"
658 [(set (match_operand:VNx16BI 0 "register_operand" "=Upa")
659 (unspec:VNx16BI
660 [(match_operand:VNx16BI 1 "register_operand" "Upa")
661 (match_operand:VNx16BI 2 "register_operand" "Upa")
662 (plus:SI
663 (match_operand:SI 3 "register_operand" "Ucj")
664 (match_operand:SI 4 "const_int_operand"))
665 (const_int BHSD_BITS)]
666 UNSPEC_PSEL))]
667 "TARGET_SVE2p1_OR_SME
668 && UINTVAL (operands[4]) < 128 / <BHSD_BITS>"
669 "psel\t%0, %1, %2.<bits_etype>[%w3, %4]"
670 )
671
672 ;; -------------------------------------------------------------------------
673 ;; ---- [PRED] Predicate count
674 ;; -------------------------------------------------------------------------
675 ;; Includes
676 ;; - CNTP (predicate as counter)
677 ;; -------------------------------------------------------------------------
678
679 (define_insn "@aarch64_sve_cntp_c<BHSD_BITS>"
680 [(set (match_operand:DI 0 "register_operand" "=r")
681 (unspec:DI
682 [(match_operand:VNx16BI 1 "register_operand" "Upa")
683 (match_operand:DI 2 "const_int_operand")
684 (const_int BHSD_BITS)]
685 UNSPEC_CNTP_C))]
686 "TARGET_SVE2p1_OR_SME2"
687 "cntp\t%x0, %K1.<bits_etype>, vlx%2"
688 )
689
690 ;; =========================================================================
691 ;; == Uniform unary arithmnetic
692 ;; =========================================================================
693
694 ;; -------------------------------------------------------------------------
695 ;; ---- [FP] Multi-register unary operations
696 ;; -------------------------------------------------------------------------
697 ;; Includes:
698 ;; - FRINTA
699 ;; - FRINTM
700 ;; - FRINTN
701 ;; - FRINTP
702 ;; -------------------------------------------------------------------------
703
704 (define_insn "<frint_pattern><mode>2"
705 [(set (match_operand:SVE_SFx24 0 "aligned_register_operand" "=Uw<vector_count>")
706 (unspec:SVE_SFx24
707 [(match_operand:SVE_SFx24 1 "aligned_register_operand" "Uw<vector_count>")]
708 SVE2_SFx24_UNARY))]
709 "TARGET_STREAMING_SME2"
710 "frint<frint_suffix>\t%0, %1"
711 )
712
713 ;; =========================================================================
714 ;; == Uniform binary arithmnetic
715 ;; =========================================================================
716
717 ;; -------------------------------------------------------------------------
718 ;; ---- [INT] Multi-register operations
719 ;; -------------------------------------------------------------------------
720 ;; Includes the multi-register forms of:
721 ;; - ADD
722 ;; - SMAX
723 ;; - SMIN
724 ;; - SQMULH
725 ;; - SRSHL
726 ;; - UMAX
727 ;; - UMIN
728 ;; - URSHL
729 ;; -------------------------------------------------------------------------
730
731 (define_expand "<optab><mode>3"
732 [(set (match_operand:SVE_Ix24 0 "aligned_register_operand" "=Uw<vector_count>")
733 (SVE_INT_BINARY_MULTI:SVE_Ix24
734 (match_operand:SVE_Ix24 1 "aligned_register_operand" "Uw<vector_count>")
735 (match_operand:SVE_Ix24 2 "aligned_register_operand" "Uw<vector_count>")))]
736 "TARGET_STREAMING_SME2"
737 )
738
739 (define_insn "*<optab><mode>3"
740 [(set (match_operand:SVE_Ix24 0 "aligned_register_operand" "=Uw<vector_count>")
741 (SVE_INT_BINARY_MULTI:SVE_Ix24
742 (match_operand:SVE_Ix24 1 "aligned_register_operand" "%0")
743 (match_operand:SVE_Ix24 2 "aligned_register_operand" "Uw<vector_count>")))]
744 "TARGET_STREAMING_SME2"
745 "<sve_int_op>\t%0, %0, %2"
746 )
747
748 (define_insn "@aarch64_sve_single_<optab><mode>"
749 [(set (match_operand:SVE_Ix24 0 "aligned_register_operand" "=Uw<vector_count>")
750 (SVE_INT_BINARY_SINGLE:SVE_Ix24
751 (match_operand:SVE_Ix24 1 "aligned_register_operand" "0")
752 (vec_duplicate:SVE_Ix24
753 (match_operand:<VSINGLE> 2 "register_operand" "x"))))]
754 "TARGET_STREAMING_SME2"
755 "<sve_int_op>\t%0, %0, %2.<Vetype>"
756 )
757
758 (define_insn "@aarch64_sve_<sve_int_op><mode>"
759 [(set (match_operand:SVE_Ix24 0 "aligned_register_operand" "=Uw<vector_count>")
760 (unspec:SVE_Ix24
761 [(match_operand:SVE_Ix24 1 "aligned_register_operand" "%0")
762 (match_operand:SVE_Ix24 2 "aligned_register_operand" "Uw<vector_count>")]
763 SVE_INT_BINARY_MULTI))]
764 "TARGET_STREAMING_SME2"
765 "<sve_int_op>\t%0, %0, %2"
766 )
767
768 (define_insn "@aarch64_sve_single_<sve_int_op><mode>"
769 [(set (match_operand:SVE_Ix24 0 "aligned_register_operand" "=Uw<vector_count>")
770 (unspec:SVE_Ix24
771 [(match_operand:SVE_Ix24 1 "aligned_register_operand" "0")
772 (vec_duplicate:SVE_Ix24
773 (match_operand:<VSINGLE> 2 "register_operand" "x"))]
774 SVE_INT_BINARY_MULTI))]
775 "TARGET_STREAMING_SME2"
776 "<sve_int_op>\t%0, %0, %2.<Vetype>"
777 )
778
779 ;; -------------------------------------------------------------------------
780 ;; ---- [INT] Clamp to minimum/maximum
781 ;; -------------------------------------------------------------------------
782 ;; - SCLAMP
783 ;; - UCLAMP
784 ;; -------------------------------------------------------------------------
785
786 ;; The minimum is applied after the maximum, which matters if the maximum
787 ;; bound is (unexpectedly) less than the minimum bound.
788 (define_insn "@aarch64_sve_<su>clamp<mode>"
789 [(set (match_operand:SVE_FULL_I 0 "register_operand")
790 (<max_opp>:SVE_FULL_I
791 (USMAX:SVE_FULL_I
792 (match_operand:SVE_FULL_I 1 "register_operand")
793 (match_operand:SVE_FULL_I 2 "register_operand"))
794 (match_operand:SVE_FULL_I 3 "register_operand")))]
795 "TARGET_SVE2p1_OR_SME"
796 {@ [cons: =0, %1, 2, 3; attrs: movprfx]
797 [ w, 0, w, w; * ] <su>clamp\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>
798 [ ?&w, w, w, w; yes ] movprfx\t%0, %1\;<su>clamp\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>
799 }
800 )
801
802 (define_insn_and_split "*aarch64_sve_<su>clamp<mode>_x"
803 [(set (match_operand:SVE_FULL_I 0 "register_operand")
804 (unspec:SVE_FULL_I
805 [(match_operand 4)
806 (<max_opp>:SVE_FULL_I
807 (unspec:SVE_FULL_I
808 [(match_operand 5)
809 (USMAX:SVE_FULL_I
810 (match_operand:SVE_FULL_I 1 "register_operand")
811 (match_operand:SVE_FULL_I 2 "register_operand"))]
812 UNSPEC_PRED_X)
813 (match_operand:SVE_FULL_I 3 "register_operand"))]
814 UNSPEC_PRED_X))]
815 "TARGET_SVE2p1_OR_SME"
816 {@ [cons: =0, %1, 2, 3; attrs: movprfx]
817 [ w, 0, w, w; * ] #
818 [ ?&w, w, w, w; yes ] #
819 }
820 "&& true"
821 [(set (match_dup 0)
822 (<max_opp>:SVE_FULL_I
823 (USMAX:SVE_FULL_I
824 (match_dup 1)
825 (match_dup 2))
826 (match_dup 3)))]
827 )
828
829 (define_insn "@aarch64_sve_<su>clamp_single<mode>"
830 [(set (match_operand:SVE_Ix24 0 "register_operand" "=Uw<vector_count>")
831 (<max_opp>:SVE_Ix24
832 (USMAX:SVE_Ix24
833 (match_operand:SVE_Ix24 1 "register_operand" "0")
834 (vec_duplicate:SVE_Ix24
835 (match_operand:<VSINGLE> 2 "register_operand" "w")))
836 (vec_duplicate:SVE_Ix24
837 (match_operand:<VSINGLE> 3 "register_operand" "w"))))]
838 "TARGET_STREAMING_SME2"
839 "<su>clamp\t%0, %2.<Vetype>, %3.<Vetype>"
840 )
841
842 ;; -------------------------------------------------------------------------
843 ;; ---- [INT] Multiplication
844 ;; -------------------------------------------------------------------------
845 ;; Includes the lane and unpredicated forms of:
846 ;; - MUL
847 ;; -------------------------------------------------------------------------
848
849 (define_insn "@aarch64_mul_lane_<mode>"
850 [(set (match_operand:SVE_FULL_HSDI_SIMD_DI 0 "register_operand" "=w")
851 (mult:SVE_FULL_HSDI_SIMD_DI
852 (unspec:SVE_FULL_HSDI_SIMD_DI
853 [(match_operand:SVE_FULL_HSDI_SIMD_DI 2 "register_operand" "<sve_lane_con>")
854 (match_operand:SI 3 "const_int_operand")]
855 UNSPEC_SVE_LANE_SELECT)
856 (match_operand:SVE_FULL_HSDI_SIMD_DI 1 "register_operand" "w")))]
857 "TARGET_SVE2"
858 "mul\t%Z0.<Vetype>, %Z1.<Vetype>, %Z2.<Vetype>[%3]"
859 )
860
861 ;; The 2nd and 3rd alternatives are valid for just TARGET_SVE as well but
862 ;; we include them here to allow matching simpler, unpredicated RTL.
863 (define_insn "*aarch64_mul_unpredicated_<mode>"
864 [(set (match_operand:SVE_I_SIMD_DI 0 "register_operand")
865 (mult:SVE_I_SIMD_DI
866 (match_operand:SVE_I_SIMD_DI 1 "register_operand")
867 (match_operand:SVE_I_SIMD_DI 2 "aarch64_sve_vsm_operand")))]
868 "TARGET_SVE2"
869 {@ [ cons: =0 , 1 , 2 ; attrs: movprfx ]
870 [ w , w , w ; * ] mul\t%Z0.<Vetype>, %Z1.<Vetype>, %Z2.<Vetype>
871 [ w , 0 , vsm ; * ] mul\t%Z0.<Vetype>, %Z0.<Vetype>, #%2
872 [ ?&w , w , vsm ; yes ] movprfx\t%Z0, %Z1\;mul\t%Z0.<Vetype>, %Z0.<Vetype>, #%2
873 }
874 )
875
876 ;; -------------------------------------------------------------------------
877 ;; ---- [INT] Scaled high-part multiplication
878 ;; -------------------------------------------------------------------------
879 ;; The patterns in this section are synthetic.
880 ;; -------------------------------------------------------------------------
881
882 ;; Unpredicated integer multiply-high-with-(round-and-)scale.
883 (define_expand "<su>mulh<r>s<mode>3"
884 [(set (match_operand:SVE_FULL_BHSI 0 "register_operand")
885 (unspec:SVE_FULL_BHSI
886 [(match_dup 3)
887 (unspec:SVE_FULL_BHSI
888 [(match_operand:SVE_FULL_BHSI 1 "register_operand")
889 (match_operand:SVE_FULL_BHSI 2 "register_operand")]
890 MULHRS)]
891 UNSPEC_PRED_X))]
892 "TARGET_SVE2"
893 {
894 operands[3] = aarch64_ptrue_reg (<VPRED>mode);
895
896 rtx prod_b = gen_reg_rtx (<VWIDE>mode);
897 rtx prod_t = gen_reg_rtx (<VWIDE>mode);
898 emit_insn (gen_aarch64_sve_<su>mullb<Vwide> (prod_b, operands[1],
899 operands[2]));
900 emit_insn (gen_aarch64_sve_<su>mullt<Vwide> (prod_t, operands[1],
901 operands[2]));
902
903 rtx shift = GEN_INT (GET_MODE_UNIT_BITSIZE (<MODE>mode) - 1);
904 emit_insn (gen_aarch64_sve_<r>shrnb<Vwide> (operands[0], prod_b, shift));
905 emit_insn (gen_aarch64_sve_<r>shrnt<Vwide> (operands[0], operands[0],
906 prod_t, shift));
907
908 DONE;
909 }
910 )
911
912 ;; -------------------------------------------------------------------------
913 ;; ---- [INT] General binary arithmetic that maps to unspecs
914 ;; -------------------------------------------------------------------------
915 ;; Includes:
916 ;; - SHADD
917 ;; - SHSUB
918 ;; - SHSUBR
919 ;; - SQRSHL
920 ;; - SQRSHLR
921 ;; - SRHADD
922 ;; - SRSHL
923 ;; - SRSHLR
924 ;; - SUQADD
925 ;; - UHADD
926 ;; - UHSUB
927 ;; - UHSUBR
928 ;; - UQRSHL
929 ;; - UQRSHLR
930 ;; - URHADD
931 ;; - URSHL
932 ;; - URSHLR
933 ;; - USQADD
934 ;; -------------------------------------------------------------------------
935
936 ;; Integer average (floor).
937 (define_expand "<u>avg<mode>3_floor"
938 [(set (match_operand:SVE_FULL_I 0 "register_operand")
939 (unspec:SVE_FULL_I
940 [(match_dup 3)
941 (unspec:SVE_FULL_I
942 [(match_operand:SVE_FULL_I 1 "register_operand")
943 (match_operand:SVE_FULL_I 2 "register_operand")]
944 HADD)]
945 UNSPEC_PRED_X))]
946 "TARGET_SVE2"
947 {
948 operands[3] = force_reg (<VPRED>mode, CONSTM1_RTX (<VPRED>mode));
949 }
950 )
951
952 ;; Integer average (rounding).
953 (define_expand "<u>avg<mode>3_ceil"
954 [(set (match_operand:SVE_FULL_I 0 "register_operand")
955 (unspec:SVE_FULL_I
956 [(match_dup 3)
957 (unspec:SVE_FULL_I
958 [(match_operand:SVE_FULL_I 1 "register_operand")
959 (match_operand:SVE_FULL_I 2 "register_operand")]
960 RHADD)]
961 UNSPEC_PRED_X))]
962 "TARGET_SVE2"
963 {
964 operands[3] = force_reg (<VPRED>mode, CONSTM1_RTX (<VPRED>mode));
965 }
966 )
967
968 ;; The immediate form of SQADD acts as an immediate form of SUQADD
969 ;; over its full range. In contrast to the ss_plus pattern, we do
970 ;; not need to treat byte immediates specially. E.g.:
971 ;;
972 ;; SQADD Z0.B, Z0.B, #128
973 ;;
974 ;; is equivalent to:
975 ;;
976 ;; MOV Z1.B, #128
977 ;; SUQADD Z0.B, P0/M, Z0.B, Z1.B
978 ;;
979 ;; even though it's not equivalent to:
980 ;;
981 ;; MOV Z1.B, #128
982 ;; SQADD Z0.B, P0/M, Z0.B, Z1.B // Saturating subtraction of 128
983 (define_insn "@aarch64_sve_suqadd<mode>_const"
984 [(set (match_operand:SVE_FULL_I 0 "register_operand" "=w, ?&w")
985 (unspec:SVE_FULL_I
986 [(match_operand:SVE_FULL_I 1 "register_operand" "0, w")
987 (match_operand:SVE_FULL_I 2 "aarch64_sve_arith_immediate")]
988 UNSPEC_SUQADD))]
989 "TARGET_SVE2"
990 "@
991 sqadd\t%0.<Vetype>, %0.<Vetype>, #%D2
992 movprfx\t%0, %1\;sqadd\t%0.<Vetype>, %0.<Vetype>, #%D2"
993 [(set_attr "movprfx" "*,yes")]
994 )
995
996 ;; General predicated binary arithmetic. All operations handled here
997 ;; are commutative or have a reversed form.
998 (define_insn "@aarch64_pred_<sve_int_op><mode>"
999 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1000 (unspec:SVE_FULL_I
1001 [(match_operand:<VPRED> 1 "register_operand")
1002 (unspec:SVE_FULL_I
1003 [(match_operand:SVE_FULL_I 2 "register_operand")
1004 (match_operand:SVE_FULL_I 3 "register_operand")]
1005 SVE2_COND_INT_BINARY_REV)]
1006 UNSPEC_PRED_X))]
1007 "TARGET_SVE2"
1008 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1009 [ w , Upl , 0 , w ; * ] <sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1010 [ w , Upl , w , 0 ; * ] <sve_int_op_rev>\t%0.<Vetype>, %1/m, %0.<Vetype>, %2.<Vetype>
1011 [ ?&w , Upl , w , w ; yes ] movprfx\t%0, %2\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1012 }
1013 )
1014
1015 ;; Predicated binary arithmetic with merging.
1016 (define_expand "@cond_<sve_int_op><mode>"
1017 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1018 (unspec:SVE_FULL_I
1019 [(match_operand:<VPRED> 1 "register_operand")
1020 (unspec:SVE_FULL_I
1021 [(match_dup 5)
1022 (unspec:SVE_FULL_I
1023 [(match_operand:SVE_FULL_I 2 "register_operand")
1024 (match_operand:SVE_FULL_I 3 "register_operand")]
1025 SVE2_COND_INT_BINARY)]
1026 UNSPEC_PRED_X)
1027 (match_operand:SVE_FULL_I 4 "aarch64_simd_reg_or_zero")]
1028 UNSPEC_SEL))]
1029 "TARGET_SVE2"
1030 {
1031 operands[5] = CONSTM1_RTX (<MODE>mode);
1032 }
1033 )
1034
1035 ;; Predicated binary arithmetic, merging with the first input.
1036 (define_insn_and_rewrite "*cond_<sve_int_op><mode>_2"
1037 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1038 (unspec:SVE_FULL_I
1039 [(match_operand:<VPRED> 1 "register_operand")
1040 (unspec:SVE_FULL_I
1041 [(match_operand 4)
1042 (unspec:SVE_FULL_I
1043 [(match_operand:SVE_FULL_I 2 "register_operand")
1044 (match_operand:SVE_FULL_I 3 "register_operand")]
1045 SVE2_COND_INT_BINARY)]
1046 UNSPEC_PRED_X)
1047 (match_dup 2)]
1048 UNSPEC_SEL))]
1049 "TARGET_SVE2"
1050 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1051 [ w , Upl , 0 , w ; * ] <sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1052 [ ?&w , Upl , w , w ; yes ] movprfx\t%0, %2\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1053 }
1054 "&& !CONSTANT_P (operands[4])"
1055 {
1056 operands[4] = CONSTM1_RTX (<VPRED>mode);
1057 }
1058 )
1059
1060 ;; Predicated binary arithmetic, merging with the second input.
1061 (define_insn_and_rewrite "*cond_<sve_int_op><mode>_3"
1062 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1063 (unspec:SVE_FULL_I
1064 [(match_operand:<VPRED> 1 "register_operand")
1065 (unspec:SVE_FULL_I
1066 [(match_operand 4)
1067 (unspec:SVE_FULL_I
1068 [(match_operand:SVE_FULL_I 2 "register_operand")
1069 (match_operand:SVE_FULL_I 3 "register_operand")]
1070 SVE2_COND_INT_BINARY_REV)]
1071 UNSPEC_PRED_X)
1072 (match_dup 3)]
1073 UNSPEC_SEL))]
1074 "TARGET_SVE2"
1075 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1076 [ w , Upl , w , 0 ; * ] <sve_int_op_rev>\t%0.<Vetype>, %1/m, %0.<Vetype>, %2.<Vetype>
1077 [ ?&w , Upl , w , w ; yes ] movprfx\t%0, %3\;<sve_int_op_rev>\t%0.<Vetype>, %1/m, %0.<Vetype>, %2.<Vetype>
1078 }
1079 "&& !CONSTANT_P (operands[4])"
1080 {
1081 operands[4] = CONSTM1_RTX (<VPRED>mode);
1082 }
1083 )
1084
1085 ;; Predicated binary operations, merging with an independent value.
1086 (define_insn_and_rewrite "*cond_<sve_int_op><mode>_any"
1087 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1088 (unspec:SVE_FULL_I
1089 [(match_operand:<VPRED> 1 "register_operand")
1090 (unspec:SVE_FULL_I
1091 [(match_operand 5)
1092 (unspec:SVE_FULL_I
1093 [(match_operand:SVE_FULL_I 2 "register_operand")
1094 (match_operand:SVE_FULL_I 3 "register_operand")]
1095 SVE2_COND_INT_BINARY_REV)]
1096 UNSPEC_PRED_X)
1097 (match_operand:SVE_FULL_I 4 "aarch64_simd_reg_or_zero")]
1098 UNSPEC_SEL))]
1099 "TARGET_SVE2
1100 && !rtx_equal_p (operands[2], operands[4])
1101 && !rtx_equal_p (operands[3], operands[4])"
1102 {@ [ cons: =0 , 1 , 2 , 3 , 4 ]
1103 [ &w , Upl , 0 , w , Dz ] movprfx\t%0.<Vetype>, %1/z, %0.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1104 [ &w , Upl , w , 0 , Dz ] movprfx\t%0.<Vetype>, %1/z, %0.<Vetype>\;<sve_int_op_rev>\t%0.<Vetype>, %1/m, %0.<Vetype>, %2.<Vetype>
1105 [ &w , Upl , w , w , Dz ] movprfx\t%0.<Vetype>, %1/z, %2.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1106 [ &w , Upl , w , w , 0 ] movprfx\t%0.<Vetype>, %1/m, %2.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1107 [ ?&w , Upl , w , w , w ] #
1108 }
1109 "&& 1"
1110 {
1111 if (reload_completed
1112 && register_operand (operands[4], <MODE>mode)
1113 && !rtx_equal_p (operands[0], operands[4]))
1114 {
1115 emit_insn (gen_vcond_mask_<mode><vpred> (operands[0], operands[2],
1116 operands[4], operands[1]));
1117 operands[4] = operands[2] = operands[0];
1118 }
1119 else if (!CONSTANT_P (operands[5]))
1120 operands[5] = CONSTM1_RTX (<VPRED>mode);
1121 else
1122 FAIL;
1123 }
1124 [(set_attr "movprfx" "yes")]
1125 )
1126
1127 ;; Predicated binary operations with no reverse form, merging with zero.
1128 ;; At present we don't generate these patterns via a cond_* optab,
1129 ;; so there's no correctness requirement to handle merging with an
1130 ;; independent value.
1131 (define_insn_and_rewrite "*cond_<sve_int_op><mode>_z"
1132 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1133 (unspec:SVE_FULL_I
1134 [(match_operand:<VPRED> 1 "register_operand")
1135 (unspec:SVE_FULL_I
1136 [(match_operand 5)
1137 (unspec:SVE_FULL_I
1138 [(match_operand:SVE_FULL_I 2 "register_operand")
1139 (match_operand:SVE_FULL_I 3 "register_operand")]
1140 SVE2_COND_INT_BINARY_NOREV)]
1141 UNSPEC_PRED_X)
1142 (match_operand:SVE_FULL_I 4 "aarch64_simd_imm_zero")]
1143 UNSPEC_SEL))]
1144 "TARGET_SVE2"
1145 {@ [ cons: =0 , 1 , 2 , 3 ]
1146 [ &w , Upl , 0 , w ] movprfx\t%0.<Vetype>, %1/z, %0.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1147 [ &w , Upl , w , w ] movprfx\t%0.<Vetype>, %1/z, %2.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1148 }
1149 "&& !CONSTANT_P (operands[5])"
1150 {
1151 operands[5] = CONSTM1_RTX (<VPRED>mode);
1152 }
1153 [(set_attr "movprfx" "yes")]
1154 )
1155
1156 ;; -------------------------------------------------------------------------
1157 ;; ---- [INT] Saturating binary arithmetic
1158 ;; -------------------------------------------------------------------------
1159 ;; Includes:
1160 ;; - SQDMULH
1161 ;; - SQRDMULH
1162 ;; -------------------------------------------------------------------------
1163
1164 (define_insn "@aarch64_sve_<sve_int_op><mode>"
1165 [(set (match_operand:SVE_FULL_I 0 "register_operand" "=w")
1166 (unspec:SVE_FULL_I
1167 [(match_operand:SVE_FULL_I 1 "register_operand" "w")
1168 (match_operand:SVE_FULL_I 2 "register_operand" "w")]
1169 SVE2_INT_BINARY))]
1170 "TARGET_SVE2"
1171 "<sve_int_op>\t%0.<Vetype>, %1.<Vetype>, %2.<Vetype>"
1172 )
1173
1174 (define_insn "@aarch64_sve_<sve_int_op>_lane_<mode>"
1175 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand" "=w")
1176 (unspec:SVE_FULL_HSDI
1177 [(match_operand:SVE_FULL_HSDI 1 "register_operand" "w")
1178 (unspec:SVE_FULL_HSDI
1179 [(match_operand:SVE_FULL_HSDI 2 "register_operand" "<sve_lane_con>")
1180 (match_operand:SI 3 "const_int_operand")]
1181 UNSPEC_SVE_LANE_SELECT)]
1182 SVE2_INT_BINARY_LANE))]
1183 "TARGET_SVE2"
1184 "<sve_int_op>\t%0.<Vetype>, %1.<Vetype>, %2.<Vetype>[%3]"
1185 )
1186
1187 ;; -------------------------------------------------------------------------
1188 ;; ---- [INT] Saturating left shifts
1189 ;; -------------------------------------------------------------------------
1190 ;; Includes:
1191 ;; - SQSHL
1192 ;; - SQSHLR
1193 ;; - UQSHL
1194 ;; - UQSHLR
1195 ;; -------------------------------------------------------------------------
1196
1197 ;; Predicated left shifts.
1198 (define_insn "@aarch64_pred_<sve_int_op><mode>"
1199 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1200 (unspec:SVE_FULL_I
1201 [(match_operand:<VPRED> 1 "register_operand")
1202 (unspec:SVE_FULL_I
1203 [(match_operand:SVE_FULL_I 2 "register_operand")
1204 (match_operand:SVE_FULL_I 3 "aarch64_sve_<lr>shift_operand")]
1205 SVE2_COND_INT_SHIFT)]
1206 UNSPEC_PRED_X))]
1207 "TARGET_SVE2"
1208 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1209 [ w , Upl , 0 , D<lr> ; * ] <sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, #%3
1210 [ w , Upl , 0 , w ; * ] <sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1211 [ w , Upl , w , 0 ; * ] <sve_int_op>r\t%0.<Vetype>, %1/m, %0.<Vetype>, %2.<Vetype>
1212 [ ?&w , Upl , w , D<lr> ; yes ] movprfx\t%0, %2\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, #%3
1213 [ ?&w , Upl , w , w ; yes ] movprfx\t%0, %2\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1214 }
1215 )
1216
1217 ;; Predicated left shifts with merging.
1218 (define_expand "@cond_<sve_int_op><mode>"
1219 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1220 (unspec:SVE_FULL_I
1221 [(match_operand:<VPRED> 1 "register_operand")
1222 (unspec:SVE_FULL_I
1223 [(match_dup 5)
1224 (unspec:SVE_FULL_I
1225 [(match_operand:SVE_FULL_I 2 "register_operand")
1226 (match_operand:SVE_FULL_I 3 "aarch64_sve_<lr>shift_operand")]
1227 SVE2_COND_INT_SHIFT)]
1228 UNSPEC_PRED_X)
1229 (match_operand:SVE_FULL_I 4 "register_operand")]
1230 UNSPEC_SEL))]
1231 "TARGET_SVE2"
1232 {
1233 operands[5] = CONSTM1_RTX (<VPRED>mode);
1234 }
1235 )
1236
1237 ;; Predicated left shifts, merging with the first input.
1238 (define_insn_and_rewrite "*cond_<sve_int_op><mode>_2"
1239 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1240 (unspec:SVE_FULL_I
1241 [(match_operand:<VPRED> 1 "register_operand")
1242 (unspec:SVE_FULL_I
1243 [(match_operand 4)
1244 (unspec:SVE_FULL_I
1245 [(match_operand:SVE_FULL_I 2 "register_operand")
1246 (match_operand:SVE_FULL_I 3 "aarch64_sve_<lr>shift_operand")]
1247 SVE2_COND_INT_SHIFT)]
1248 UNSPEC_PRED_X)
1249 (match_dup 2)]
1250 UNSPEC_SEL))]
1251 "TARGET_SVE2"
1252 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1253 [ w , Upl , 0 , D<lr> ; * ] <sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, #%3
1254 [ w , Upl , 0 , w ; * ] <sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1255 [ ?&w , Upl , w , D<lr> ; yes ] movprfx\t%0, %2\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, #%3
1256 [ ?&w , Upl , w , w ; yes ] movprfx\t%0, %2\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1257 }
1258 "&& !CONSTANT_P (operands[4])"
1259 {
1260 operands[4] = CONSTM1_RTX (<VPRED>mode);
1261 }
1262 )
1263
1264 ;; Predicated left shifts, merging with the second input.
1265 (define_insn_and_rewrite "*cond_<sve_int_op><mode>_3"
1266 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1267 (unspec:SVE_FULL_I
1268 [(match_operand:<VPRED> 1 "register_operand")
1269 (unspec:SVE_FULL_I
1270 [(match_operand 4)
1271 (unspec:SVE_FULL_I
1272 [(match_operand:SVE_FULL_I 2 "register_operand")
1273 (match_operand:SVE_FULL_I 3 "register_operand")]
1274 SVE2_COND_INT_SHIFT)]
1275 UNSPEC_PRED_X)
1276 (match_dup 3)]
1277 UNSPEC_SEL))]
1278 "TARGET_SVE2"
1279 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1280 [ w , Upl , w , 0 ; * ] <sve_int_op>r\t%0.<Vetype>, %1/m, %0.<Vetype>, %2.<Vetype>
1281 [ ?&w , Upl , w , w ; yes ] movprfx\t%0, %3\;<sve_int_op>r\t%0.<Vetype>, %1/m, %0.<Vetype>, %2.<Vetype>
1282 }
1283 "&& !CONSTANT_P (operands[4])"
1284 {
1285 operands[4] = CONSTM1_RTX (<VPRED>mode);
1286 }
1287 )
1288
1289 ;; Predicated left shifts, merging with an independent value.
1290 (define_insn_and_rewrite "*cond_<sve_int_op><mode>_any"
1291 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1292 (unspec:SVE_FULL_I
1293 [(match_operand:<VPRED> 1 "register_operand")
1294 (unspec:SVE_FULL_I
1295 [(match_operand 5)
1296 (unspec:SVE_FULL_I
1297 [(match_operand:SVE_FULL_I 2 "register_operand")
1298 (match_operand:SVE_FULL_I 3 "aarch64_sve_<lr>shift_operand")]
1299 SVE2_COND_INT_SHIFT)]
1300 UNSPEC_PRED_X)
1301 (match_operand:SVE_FULL_I 4 "aarch64_simd_reg_or_zero")]
1302 UNSPEC_SEL))]
1303 "TARGET_SVE2
1304 && !rtx_equal_p (operands[2], operands[4])
1305 && (CONSTANT_P (operands[4]) || !rtx_equal_p (operands[3], operands[4]))"
1306 {@ [ cons: =0 , 1 , 2 , 3 , 4 ]
1307 [ &w , Upl , 0 , D<lr> , Dz ] movprfx\t%0.<Vetype>, %1/z, %0.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, #%3
1308 [ &w , Upl , 0 , w , Dz ] movprfx\t%0.<Vetype>, %1/z, %0.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1309 [ &w , Upl , w , 0 , Dz ] movprfx\t%0.<Vetype>, %1/z, %0.<Vetype>\;<sve_int_op>r\t%0.<Vetype>, %1/m, %0.<Vetype>, %2.<Vetype>
1310 [ &w , Upl , w , D<lr> , Dz ] movprfx\t%0.<Vetype>, %1/z, %2.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, #%3
1311 [ &w , Upl , w , w , Dz ] movprfx\t%0.<Vetype>, %1/z, %2.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1312 [ &w , Upl , w , D<lr> , 0 ] movprfx\t%0.<Vetype>, %1/m, %2.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, #%3
1313 [ &w , Upl , w , w , 0 ] movprfx\t%0.<Vetype>, %1/m, %2.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1314 [ ?&w , Upl , w , D<lr> , w ] #
1315 [ ?&w , Upl , w , w , w ] #
1316 }
1317 "&& 1"
1318 {
1319 if (reload_completed
1320 && register_operand (operands[4], <MODE>mode)
1321 && !rtx_equal_p (operands[0], operands[4]))
1322 {
1323 emit_insn (gen_vcond_mask_<mode><vpred> (operands[0], operands[2],
1324 operands[4], operands[1]));
1325 operands[4] = operands[2] = operands[0];
1326 }
1327 else if (!CONSTANT_P (operands[5]))
1328 operands[5] = CONSTM1_RTX (<VPRED>mode);
1329 else
1330 FAIL;
1331 }
1332 [(set_attr "movprfx" "yes")]
1333 )
1334
1335 ;; -------------------------------------------------------------------------
1336 ;; ---- [FP] Non-widening bfloat16 arithmetic
1337 ;; -------------------------------------------------------------------------
1338 ;; Includes:
1339 ;; - BFADD (SVE_B16B16)
1340 ;; - BFMAX (SVE_B16B16)
1341 ;; - BFMAXNM (SVE_B16B16)
1342 ;; - BFMIN (SVE_B16B16)
1343 ;; - BFMINNM (SVE_B16B16)
1344 ;; - BFMUL (SVE_B16B16)
1345 ;; -------------------------------------------------------------------------
1346
1347 ;; Predicated B16B16 binary operations.
1348 (define_insn "@aarch64_pred_<optab><mode>"
1349 [(set (match_operand:VNx8BF_ONLY 0 "register_operand")
1350 (unspec:VNx8BF_ONLY
1351 [(match_operand:<VPRED> 1 "register_operand")
1352 (match_operand:SI 4 "aarch64_sve_gp_strictness")
1353 (match_operand:VNx8BF_ONLY 2 "register_operand")
1354 (match_operand:VNx8BF_ONLY 3 "register_operand")]
1355 SVE_COND_FP_BINARY_OPTAB))]
1356 "TARGET_SSVE_B16B16 && <supports_bf16>"
1357 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx , is_rev ]
1358 [ w , Upl , 0 , w ; * , * ] <b><sve_fp_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1359 [ w , Upl , w , 0 ; * , true ] <b><sve_fp_op_rev>\t%0.<Vetype>, %1/m, %0.<Vetype>, %2.<Vetype>
1360 [ ?&w , Upl , w , w ; yes , * ] movprfx\t%0, %2\;<b><sve_fp_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
1361 }
1362 [(set_attr "is_bf16" "<is_bf16>")
1363 (set_attr "supports_bf16_rev" "<supports_bf16_rev>")]
1364 )
1365
1366 ;; -------------------------------------------------------------------------
1367 ;; ---- [FP] Clamp to minimum/maximum
1368 ;; -------------------------------------------------------------------------
1369 ;; - BFCLAMP (SVE_B16B16)
1370 ;; - FCLAMP
1371 ;; -------------------------------------------------------------------------
1372
1373 ;; The minimum is applied after the maximum, which matters if the maximum
1374 ;; bound is (unexpectedly) less than the minimum bound.
1375 (define_insn "@aarch64_sve_fclamp<mode>"
1376 [(set (match_operand:SVE_CLAMP_F 0 "register_operand")
1377 (unspec:SVE_CLAMP_F
1378 [(unspec:SVE_CLAMP_F
1379 [(match_operand:SVE_CLAMP_F 1 "register_operand")
1380 (match_operand:SVE_CLAMP_F 2 "register_operand")]
1381 UNSPEC_FMAXNM)
1382 (match_operand:SVE_CLAMP_F 3 "register_operand")]
1383 UNSPEC_FMINNM))]
1384 ""
1385 {@ [cons: =0, %1, 2, 3; attrs: movprfx]
1386 [ w, 0, w, w; * ] <b>fclamp\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>
1387 [ ?&w, w, w, w; yes ] movprfx\t%0, %1\;<b>fclamp\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>
1388 }
1389 )
1390
1391 (define_insn_and_split "*aarch64_sve_fclamp<mode>_x"
1392 [(set (match_operand:SVE_CLAMP_F 0 "register_operand")
1393 (unspec:SVE_CLAMP_F
1394 [(match_operand 4)
1395 (const_int SVE_RELAXED_GP)
1396 (unspec:SVE_CLAMP_F
1397 [(match_operand 5)
1398 (const_int SVE_RELAXED_GP)
1399 (match_operand:SVE_CLAMP_F 1 "register_operand")
1400 (match_operand:SVE_CLAMP_F 2 "register_operand")]
1401 UNSPEC_COND_FMAXNM)
1402 (match_operand:SVE_CLAMP_F 3 "register_operand")]
1403 UNSPEC_COND_FMINNM))]
1404 ""
1405 {@ [cons: =0, %1, 2, 3; attrs: movprfx]
1406 [ w, 0, w, w; * ] #
1407 [ ?&w, w, w, w; yes ] #
1408 }
1409 "&& true"
1410 [(set (match_dup 0)
1411 (unspec:SVE_CLAMP_F
1412 [(unspec:SVE_CLAMP_F
1413 [(match_dup 1)
1414 (match_dup 2)]
1415 UNSPEC_FMAXNM)
1416 (match_dup 3)]
1417 UNSPEC_FMINNM))]
1418 )
1419
1420 (define_insn "@aarch64_sve_fclamp_single<mode>"
1421 [(set (match_operand:SVE_Fx24 0 "register_operand" "=Uw<vector_count>")
1422 (unspec:SVE_Fx24
1423 [(unspec:SVE_Fx24
1424 [(match_operand:SVE_Fx24 1 "register_operand" "0")
1425 (vec_duplicate:SVE_Fx24
1426 (match_operand:<VSINGLE> 2 "register_operand" "w"))]
1427 UNSPEC_FMAXNM)
1428 (vec_duplicate:SVE_Fx24
1429 (match_operand:<VSINGLE> 3 "register_operand" "w"))]
1430 UNSPEC_FMINNM))]
1431 "TARGET_STREAMING_SME2"
1432 "<b>fclamp\t%0, %2.<Vetype>, %3.<Vetype>"
1433 )
1434
1435 ;; =========================================================================
1436 ;; == Uniform ternary arithmnetic
1437 ;; =========================================================================
1438
1439 ;; -------------------------------------------------------------------------
1440 ;; ---- [INT] General ternary arithmetic that maps to unspecs
1441 ;; -------------------------------------------------------------------------
1442 ;; Includes:
1443 ;; - ADCLB
1444 ;; - ADCLT
1445 ;; - EORBT
1446 ;; - EORTB
1447 ;; - SBCLB
1448 ;; - SBCLT
1449 ;; - SQRDMLAH
1450 ;; - SQRDMLSH
1451 ;; -------------------------------------------------------------------------
1452
1453 (define_insn "@aarch64_sve_<sve_int_op><mode>"
1454 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1455 (unspec:SVE_FULL_I
1456 [(match_operand:SVE_FULL_I 2 "register_operand")
1457 (match_operand:SVE_FULL_I 3 "register_operand")
1458 (match_operand:SVE_FULL_I 1 "register_operand")]
1459 SVE2_INT_TERNARY))]
1460 "TARGET_SVE2"
1461 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1462 [ w , 0 , w , w ; * ] <sve_int_op>\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>
1463 [ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;<sve_int_op>\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>
1464 }
1465 )
1466
1467 (define_insn "@aarch64_sve_<sve_int_op>_lane_<mode>"
1468 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand")
1469 (unspec:SVE_FULL_HSDI
1470 [(match_operand:SVE_FULL_HSDI 2 "register_operand")
1471 (unspec:SVE_FULL_HSDI
1472 [(match_operand:SVE_FULL_HSDI 3 "register_operand")
1473 (match_operand:SI 4 "const_int_operand")]
1474 UNSPEC_SVE_LANE_SELECT)
1475 (match_operand:SVE_FULL_HSDI 1 "register_operand")]
1476 SVE2_INT_TERNARY_LANE))]
1477 "TARGET_SVE2"
1478 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1479 [ w , 0 , w , <sve_lane_con> ; * ] <sve_int_op>\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>[%4]
1480 [ ?&w , w , w , <sve_lane_con> ; yes ] movprfx\t%0, %1\;<sve_int_op>\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>[%4]
1481 }
1482 )
1483
1484 ;; -------------------------------------------------------------------------
1485 ;; ---- [INT] Multiply-and-accumulate operations
1486 ;; -------------------------------------------------------------------------
1487 ;; Includes the lane forms of:
1488 ;; - MLA
1489 ;; - MLS
1490 ;; -------------------------------------------------------------------------
1491
1492 (define_insn "@aarch64_sve_add_mul_lane_<mode>"
1493 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand")
1494 (plus:SVE_FULL_HSDI
1495 (mult:SVE_FULL_HSDI
1496 (unspec:SVE_FULL_HSDI
1497 [(match_operand:SVE_FULL_HSDI 3 "register_operand")
1498 (match_operand:SI 4 "const_int_operand")]
1499 UNSPEC_SVE_LANE_SELECT)
1500 (match_operand:SVE_FULL_HSDI 2 "register_operand"))
1501 (match_operand:SVE_FULL_HSDI 1 "register_operand")))]
1502 "TARGET_SVE2"
1503 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1504 [ w , 0 , w , <sve_lane_con> ; * ] mla\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>[%4]
1505 [ ?&w , w , w , <sve_lane_con> ; yes ] movprfx\t%0, %1\;mla\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>[%4]
1506 }
1507 )
1508
1509 (define_insn "@aarch64_sve_sub_mul_lane_<mode>"
1510 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand")
1511 (minus:SVE_FULL_HSDI
1512 (match_operand:SVE_FULL_HSDI 1 "register_operand")
1513 (mult:SVE_FULL_HSDI
1514 (unspec:SVE_FULL_HSDI
1515 [(match_operand:SVE_FULL_HSDI 3 "register_operand")
1516 (match_operand:SI 4 "const_int_operand")]
1517 UNSPEC_SVE_LANE_SELECT)
1518 (match_operand:SVE_FULL_HSDI 2 "register_operand"))))]
1519 "TARGET_SVE2"
1520 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1521 [ w , 0 , w , <sve_lane_con> ; * ] mls\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>[%4]
1522 [ ?&w , w , w , <sve_lane_con> ; yes ] movprfx\t%0, %1\;mls\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>[%4]
1523 }
1524 )
1525
1526 ;; -------------------------------------------------------------------------
1527 ;; ---- [INT] Binary logic operations with rotation
1528 ;; -------------------------------------------------------------------------
1529 ;; Includes:
1530 ;; - XAR
1531 ;; -------------------------------------------------------------------------
1532
1533 ;; Also allow the Advanced SIMD modes as the the SVE2 XAR instruction
1534 ;; can handle more element sizes than the TARGET_SHA3 one from Advanced SIMD.
1535 ;; Don't allow the V2DImode use here unless !TARGET_SHA3 as the Advanced SIMD
1536 ;; version should be preferred when available as it is non-destructive on its
1537 ;; input.
1538 (define_insn "@aarch64_sve2_xar<mode>"
1539 [(set (match_operand:SVE_ASIMD_FULL_I 0 "register_operand" "=w,?&w")
1540 (rotate:SVE_ASIMD_FULL_I
1541 (xor:SVE_ASIMD_FULL_I
1542 (match_operand:SVE_ASIMD_FULL_I 1 "register_operand" "%0,w")
1543 (match_operand:SVE_ASIMD_FULL_I 2 "register_operand" "w,w"))
1544 (match_operand:SVE_ASIMD_FULL_I 3 "aarch64_simd_lshift_imm")))]
1545 "TARGET_SVE2 && !(<MODE>mode == V2DImode && TARGET_SHA3)"
1546 {
1547 operands[3]
1548 = GEN_INT (GET_MODE_UNIT_BITSIZE (<MODE>mode)
1549 - INTVAL (unwrap_const_vec_duplicate (operands[3])));
1550 if (which_alternative == 0)
1551 return "xar\t%Z0.<Vetype>, %Z0.<Vetype>, %Z2.<Vetype>, #%3";
1552 return "movprfx\t%Z0, %Z1\;xar\t%Z0.<Vetype>, %Z0.<Vetype>, %Z2.<Vetype>, #%3";
1553 }
1554 [(set_attr "movprfx" "*,yes")]
1555 )
1556
1557 ;; -------------------------------------------------------------------------
1558 ;; ---- [INT] Ternary logic operations
1559 ;; -------------------------------------------------------------------------
1560 ;; Includes:
1561 ;; - BCAX
1562 ;; - BSL
1563 ;; - BSL1N
1564 ;; - BSL2N
1565 ;; - EOR3
1566 ;; - NBSL
1567 ;; -------------------------------------------------------------------------
1568
1569 ;; Unpredicated exclusive OR of AND.
1570 (define_expand "@aarch64_sve2_bcax<mode>"
1571 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1572 (xor:SVE_FULL_I
1573 (and:SVE_FULL_I
1574 (unspec:SVE_FULL_I
1575 [(match_dup 4)
1576 (not:SVE_FULL_I
1577 (match_operand:SVE_FULL_I 3 "register_operand"))]
1578 UNSPEC_PRED_X)
1579 (match_operand:SVE_FULL_I 2 "register_operand"))
1580 (match_operand:SVE_FULL_I 1 "register_operand")))]
1581 "TARGET_SVE2"
1582 {
1583 operands[4] = CONSTM1_RTX (<VPRED>mode);
1584 }
1585 )
1586
1587 (define_insn_and_rewrite "*aarch64_sve2_bcax<mode>"
1588 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1589 (xor:SVE_FULL_I
1590 (and:SVE_FULL_I
1591 (unspec:SVE_FULL_I
1592 [(match_operand 4)
1593 (not:SVE_FULL_I
1594 (match_operand:SVE_FULL_I 3 "register_operand"))]
1595 UNSPEC_PRED_X)
1596 (match_operand:SVE_FULL_I 2 "register_operand"))
1597 (match_operand:SVE_FULL_I 1 "register_operand")))]
1598 "TARGET_SVE2"
1599 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1600 [ w , 0 , w , w ; * ] bcax\t%0.d, %0.d, %2.d, %3.d
1601 [ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;bcax\t%0.d, %0.d, %2.d, %3.d
1602 }
1603 "&& !CONSTANT_P (operands[4])"
1604 {
1605 operands[4] = CONSTM1_RTX (<VPRED>mode);
1606 }
1607 )
1608
1609 ;; Unpredicated 3-way exclusive OR.
1610 (define_insn "@aarch64_sve2_eor3<mode>"
1611 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1612 (xor:SVE_FULL_I
1613 (xor:SVE_FULL_I
1614 (match_operand:SVE_FULL_I 1 "register_operand")
1615 (match_operand:SVE_FULL_I 2 "register_operand"))
1616 (match_operand:SVE_FULL_I 3 "register_operand")))]
1617 "TARGET_SVE2"
1618 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1619 [ w , 0 , w , w ; * ] eor3\t%0.d, %0.d, %2.d, %3.d
1620 [ w , w , 0 , w ; * ] eor3\t%0.d, %0.d, %1.d, %3.d
1621 [ w , w , w , 0 ; * ] eor3\t%0.d, %0.d, %1.d, %2.d
1622 [ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;eor3\t%0.d, %0.d, %2.d, %3.d
1623 }
1624 )
1625
1626 ;; Use NBSL for vector NOR.
1627 (define_insn_and_rewrite "*aarch64_sve2_nor<mode>"
1628 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1629 (unspec:SVE_FULL_I
1630 [(match_operand 3)
1631 (and:SVE_FULL_I
1632 (not:SVE_FULL_I
1633 (match_operand:SVE_FULL_I 1 "register_operand"))
1634 (not:SVE_FULL_I
1635 (match_operand:SVE_FULL_I 2 "register_operand")))]
1636 UNSPEC_PRED_X))]
1637 "TARGET_SVE2"
1638 {@ [ cons: =0 , %1 , 2 ; attrs: movprfx ]
1639 [ w , 0 , w ; * ] nbsl\t%0.d, %0.d, %2.d, %0.d
1640 [ ?&w , w , w ; yes ] movprfx\t%0, %1\;nbsl\t%0.d, %0.d, %2.d, %1.d
1641 }
1642 "&& !CONSTANT_P (operands[3])"
1643 {
1644 operands[3] = CONSTM1_RTX (<VPRED>mode);
1645 }
1646 )
1647
1648 ;; Use NBSL for vector NAND.
1649 (define_insn_and_rewrite "*aarch64_sve2_nand<mode>"
1650 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1651 (unspec:SVE_FULL_I
1652 [(match_operand 3)
1653 (ior:SVE_FULL_I
1654 (not:SVE_FULL_I
1655 (match_operand:SVE_FULL_I 1 "register_operand"))
1656 (not:SVE_FULL_I
1657 (match_operand:SVE_FULL_I 2 "register_operand")))]
1658 UNSPEC_PRED_X))]
1659 "TARGET_SVE2"
1660 {@ [ cons: =0 , %1 , 2 ; attrs: movprfx ]
1661 [ w , 0 , w ; * ] nbsl\t%0.d, %0.d, %2.d, %2.d
1662 [ ?&w , w , w ; yes ] movprfx\t%0, %1\;nbsl\t%0.d, %0.d, %2.d, %2.d
1663 }
1664 "&& !CONSTANT_P (operands[3])"
1665 {
1666 operands[3] = CONSTM1_RTX (<VPRED>mode);
1667 }
1668 )
1669
1670 ;; Unpredicated bitwise select.
1671 ;; (op3 ? bsl_mov : bsl_dup) == (((bsl_mov ^ bsl_dup) & op3) ^ bsl_dup)
1672 (define_expand "@aarch64_sve2_bsl<mode>"
1673 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1674 (xor:SVE_FULL_I
1675 (and:SVE_FULL_I
1676 (xor:SVE_FULL_I
1677 (match_operand:SVE_FULL_I 1 "register_operand")
1678 (match_operand:SVE_FULL_I 2 "register_operand"))
1679 (match_operand:SVE_FULL_I 3 "register_operand"))
1680 (match_dup 2)))]
1681 "TARGET_SVE2"
1682 )
1683
1684 (define_insn "*aarch64_sve2_bsl<mode>"
1685 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1686 (xor:SVE_FULL_I
1687 (and:SVE_FULL_I
1688 (xor:SVE_FULL_I
1689 (match_operand:SVE_FULL_I 1 "register_operand")
1690 (match_operand:SVE_FULL_I 2 "register_operand"))
1691 (match_operand:SVE_FULL_I 3 "register_operand"))
1692 (match_dup BSL_DUP)))]
1693 "TARGET_SVE2"
1694 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1695 [ w , <bsl_1st> , <bsl_2nd> , w ; * ] bsl\t%0.d, %0.d, %<bsl_dup>.d, %3.d
1696 [ ?&w , w , w , w ; yes ] movprfx\t%0, %<bsl_mov>\;bsl\t%0.d, %0.d, %<bsl_dup>.d, %3.d
1697 }
1698 )
1699
1700 ;; Unpredicated bitwise inverted select.
1701 ;; (~(op3 ? bsl_mov : bsl_dup)) == (~(((bsl_mov ^ bsl_dup) & op3) ^ bsl_dup))
1702 (define_expand "@aarch64_sve2_nbsl<mode>"
1703 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1704 (unspec:SVE_FULL_I
1705 [(match_dup 4)
1706 (not:SVE_FULL_I
1707 (xor:SVE_FULL_I
1708 (and:SVE_FULL_I
1709 (xor:SVE_FULL_I
1710 (match_operand:SVE_FULL_I 1 "register_operand")
1711 (match_operand:SVE_FULL_I 2 "register_operand"))
1712 (match_operand:SVE_FULL_I 3 "register_operand"))
1713 (match_dup 2)))]
1714 UNSPEC_PRED_X))]
1715 "TARGET_SVE2"
1716 {
1717 operands[4] = CONSTM1_RTX (<VPRED>mode);
1718 }
1719 )
1720
1721 (define_insn_and_rewrite "*aarch64_sve2_nbsl<mode>"
1722 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1723 (unspec:SVE_FULL_I
1724 [(match_operand 4)
1725 (not:SVE_FULL_I
1726 (xor:SVE_FULL_I
1727 (and:SVE_FULL_I
1728 (xor:SVE_FULL_I
1729 (match_operand:SVE_FULL_I 1 "register_operand")
1730 (match_operand:SVE_FULL_I 2 "register_operand"))
1731 (match_operand:SVE_FULL_I 3 "register_operand"))
1732 (match_dup BSL_DUP)))]
1733 UNSPEC_PRED_X))]
1734 "TARGET_SVE2"
1735 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1736 [ w , <bsl_1st> , <bsl_2nd> , w ; * ] nbsl\t%0.d, %0.d, %<bsl_dup>.d, %3.d
1737 [ ?&w , w , w , w ; yes ] movprfx\t%0, %<bsl_mov>\;nbsl\t%0.d, %0.d, %<bsl_dup>.d, %3.d
1738 }
1739 "&& !CONSTANT_P (operands[4])"
1740 {
1741 operands[4] = CONSTM1_RTX (<VPRED>mode);
1742 }
1743 )
1744
1745 (define_insn "*aarch64_sve2_nbsl_unpred<mode>"
1746 [(set (match_operand:VDQ_I 0 "register_operand")
1747 (not:VDQ_I
1748 (xor:VDQ_I
1749 (and:VDQ_I
1750 (xor:VDQ_I
1751 (match_operand:VDQ_I 1 "register_operand")
1752 (match_operand:VDQ_I 2 "register_operand"))
1753 (match_operand:VDQ_I 3 "register_operand"))
1754 (match_dup BSL_DUP))))]
1755 "TARGET_SVE2"
1756 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1757 [ w , <bsl_1st> , <bsl_2nd> , w ; * ] nbsl\t%Z0.d, %Z0.d, %Z<bsl_dup>.d, %Z3.d
1758 [ ?&w , w , w , w ; yes ] movprfx\t%Z0, %Z<bsl_mov>\;nbsl\t%Z0.d, %Z0.d, %Z<bsl_dup>.d, %Z3.d
1759 }
1760 )
1761
1762 ;; Unpredicated bitwise select with inverted first operand.
1763 ;; (op3 ? ~bsl_mov : bsl_dup) == ((~(bsl_mov ^ bsl_dup) & op3) ^ bsl_dup)
1764 (define_expand "@aarch64_sve2_bsl1n<mode>"
1765 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1766 (xor:SVE_FULL_I
1767 (and:SVE_FULL_I
1768 (unspec:SVE_FULL_I
1769 [(match_dup 4)
1770 (not:SVE_FULL_I
1771 (xor:SVE_FULL_I
1772 (match_operand:SVE_FULL_I 1 "register_operand")
1773 (match_operand:SVE_FULL_I 2 "register_operand")))]
1774 UNSPEC_PRED_X)
1775 (match_operand:SVE_FULL_I 3 "register_operand"))
1776 (match_dup 2)))]
1777 "TARGET_SVE2"
1778 {
1779 operands[4] = CONSTM1_RTX (<VPRED>mode);
1780 }
1781 )
1782
1783 (define_insn_and_rewrite "*aarch64_sve2_bsl1n<mode>"
1784 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1785 (xor:SVE_FULL_I
1786 (and:SVE_FULL_I
1787 (unspec:SVE_FULL_I
1788 [(match_operand 4)
1789 (not:SVE_FULL_I
1790 (xor:SVE_FULL_I
1791 (match_operand:SVE_FULL_I 1 "register_operand")
1792 (match_operand:SVE_FULL_I 2 "register_operand")))]
1793 UNSPEC_PRED_X)
1794 (match_operand:SVE_FULL_I 3 "register_operand"))
1795 (match_dup BSL_DUP)))]
1796 "TARGET_SVE2"
1797 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1798 [ w , <bsl_1st> , <bsl_2nd> , w ; * ] bsl1n\t%0.d, %0.d, %<bsl_dup>.d, %3.d
1799 [ ?&w , w , w , w ; yes ] movprfx\t%0, %<bsl_mov>\;bsl1n\t%0.d, %0.d, %<bsl_dup>.d, %3.d
1800 }
1801 "&& !CONSTANT_P (operands[4])"
1802 {
1803 operands[4] = CONSTM1_RTX (<VPRED>mode);
1804 }
1805 )
1806
1807 (define_insn "*aarch64_sve2_bsl1n_unpred<mode>"
1808 [(set (match_operand:VDQ_I 0 "register_operand")
1809 (xor:VDQ_I
1810 (and:VDQ_I
1811 (not:VDQ_I
1812 (xor:VDQ_I
1813 (match_operand:VDQ_I 1 "register_operand")
1814 (match_operand:VDQ_I 2 "register_operand")))
1815 (match_operand:VDQ_I 3 "register_operand"))
1816 (match_dup BSL_DUP)))]
1817 "TARGET_SVE2"
1818 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1819 [ w , <bsl_1st> , <bsl_2nd> , w ; * ] bsl1n\t%Z0.d, %Z0.d, %Z<bsl_dup>.d, %Z3.d
1820 [ ?&w , w , w , w ; yes ] movprfx\t%Z0, %Z<bsl_mov>\;bsl1n\t%Z0.d, %Z0.d, %Z<bsl_dup>.d, %Z3.d
1821 }
1822 )
1823
1824 ;; Unpredicated bitwise select with inverted second operand.
1825 ;; (bsl_dup ? bsl_mov : ~op3) == ((bsl_dup & bsl_mov) | (~op3 & ~bsl_dup))
1826 (define_expand "@aarch64_sve2_bsl2n<mode>"
1827 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1828 (ior:SVE_FULL_I
1829 (and:SVE_FULL_I
1830 (match_operand:SVE_FULL_I 1 "register_operand")
1831 (match_operand:SVE_FULL_I 3 "register_operand"))
1832 (unspec:SVE_FULL_I
1833 [(match_dup 4)
1834 (and:SVE_FULL_I
1835 (not:SVE_FULL_I
1836 (match_operand:SVE_FULL_I 2 "register_operand"))
1837 (not:SVE_FULL_I
1838 (match_dup 3)))]
1839 UNSPEC_PRED_X)))]
1840 "TARGET_SVE2"
1841 {
1842 operands[4] = CONSTM1_RTX (<VPRED>mode);
1843 }
1844 )
1845
1846 (define_insn_and_rewrite "*aarch64_sve2_bsl2n<mode>"
1847 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1848 (ior:SVE_FULL_I
1849 (and:SVE_FULL_I
1850 (match_operand:SVE_FULL_I 1 "register_operand")
1851 (match_operand:SVE_FULL_I 2 "register_operand"))
1852 (unspec:SVE_FULL_I
1853 [(match_operand 4)
1854 (and:SVE_FULL_I
1855 (not:SVE_FULL_I
1856 (match_operand:SVE_FULL_I 3 "register_operand"))
1857 (not:SVE_FULL_I
1858 (match_dup BSL_DUP)))]
1859 UNSPEC_PRED_X)))]
1860 "TARGET_SVE2"
1861 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1862 [ w , <bsl_1st> , <bsl_2nd> , w ; * ] bsl2n\t%0.d, %0.d, %3.d, %<bsl_dup>.d
1863 [ ?&w , w , w , w ; yes ] movprfx\t%0, %<bsl_mov>\;bsl2n\t%0.d, %0.d, %3.d, %<bsl_dup>.d
1864 }
1865 "&& !CONSTANT_P (operands[4])"
1866 {
1867 operands[4] = CONSTM1_RTX (<VPRED>mode);
1868 }
1869 )
1870
1871 ;; Unpredicated bitwise select with inverted second operand, alternative form.
1872 ;; (bsl_dup ? bsl_mov : ~op3) == ((bsl_dup & bsl_mov) | (~bsl_dup & ~op3))
1873 (define_insn_and_rewrite "*aarch64_sve2_bsl2n<mode>"
1874 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1875 (ior:SVE_FULL_I
1876 (and:SVE_FULL_I
1877 (match_operand:SVE_FULL_I 1 "register_operand")
1878 (match_operand:SVE_FULL_I 2 "register_operand"))
1879 (unspec:SVE_FULL_I
1880 [(match_operand 4)
1881 (and:SVE_FULL_I
1882 (not:SVE_FULL_I
1883 (match_dup BSL_DUP))
1884 (not:SVE_FULL_I
1885 (match_operand:SVE_FULL_I 3 "register_operand")))]
1886 UNSPEC_PRED_X)))]
1887 "TARGET_SVE2"
1888 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1889 [ w , <bsl_1st> , <bsl_2nd> , w ; * ] bsl2n\t%0.d, %0.d, %3.d, %<bsl_dup>.d
1890 [ ?&w , w , w , w ; yes ] movprfx\t%0, %<bsl_mov>\;bsl2n\t%0.d, %0.d, %3.d, %<bsl_dup>.d
1891 }
1892 "&& !CONSTANT_P (operands[4])"
1893 {
1894 operands[4] = CONSTM1_RTX (<VPRED>mode);
1895 }
1896 )
1897
1898 (define_insn "*aarch64_sve2_bsl2n_unpred<mode>"
1899 [(set (match_operand:VDQ_I 0 "register_operand")
1900 (ior:VDQ_I
1901 (and:VDQ_I
1902 (match_operand:VDQ_I 1 "register_operand")
1903 (match_operand:VDQ_I 2 "register_operand"))
1904 (and:VDQ_I
1905 (not:VDQ_I (match_operand:VDQ_I 3 "register_operand"))
1906 (not:VDQ_I (match_dup BSL_DUP)))))]
1907 "TARGET_SVE2"
1908 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1909 [ w , <bsl_1st> , <bsl_2nd> , w ; * ] bsl2n\t%Z0.d, %Z0.d, %Z3.d, %Z<bsl_dup>.d
1910 [ ?&w , w , w , w ; yes ] movprfx\t%Z0, %Z<bsl_mov>\;bsl2n\t%Z0.d, %Z0.d, %Z3.d, %Z<bsl_dup>.d
1911 }
1912 )
1913
1914 (define_insn "*aarch64_sve2_bsl2n_unpred<mode>"
1915 [(set (match_operand:VDQ_I 0 "register_operand")
1916 (ior:VDQ_I
1917 (and:VDQ_I
1918 (match_operand:VDQ_I 1 "register_operand")
1919 (match_operand:VDQ_I 2 "register_operand"))
1920 (and:VDQ_I
1921 (not:VDQ_I (match_dup BSL_DUP))
1922 (not:VDQ_I (match_operand:VDQ_I 3 "register_operand")))))]
1923 "TARGET_SVE2"
1924 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
1925 [ w , <bsl_1st> , <bsl_2nd> , w ; * ] bsl2n\t%Z0.d, %Z0.d, %Z3.d, %Z<bsl_dup>.d
1926 [ ?&w , w , w , w ; yes ] movprfx\t%Z0, %Z<bsl_mov>\;bsl2n\t%Z0.d, %Z0.d, %Z3.d, %Z<bsl_dup>.d
1927 }
1928 )
1929
1930 ;; -------------------------------------------------------------------------
1931 ;; ---- [INT] Shift-and-accumulate operations
1932 ;; -------------------------------------------------------------------------
1933 ;; Includes:
1934 ;; - SRSRA
1935 ;; - SSRA
1936 ;; - URSRA
1937 ;; - USRA
1938 ;; -------------------------------------------------------------------------
1939
1940 ;; Provide the natural unpredicated interface for SSRA and USRA.
1941 (define_expand "@aarch64_sve_add_<sve_int_op><mode>"
1942 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1943 (plus:SVE_FULL_I
1944 (unspec:SVE_FULL_I
1945 [(match_dup 4)
1946 (SHIFTRT:SVE_FULL_I
1947 (match_operand:SVE_FULL_I 2 "register_operand")
1948 (match_operand:SVE_FULL_I 3 "aarch64_simd_rshift_imm"))]
1949 UNSPEC_PRED_X)
1950 (match_operand:SVE_FULL_I 1 "register_operand")))]
1951 "TARGET_SVE2"
1952 {
1953 operands[4] = CONSTM1_RTX (<VPRED>mode);
1954 }
1955 )
1956
1957 ;; Pattern-match SSRA and USRA as a predicated operation whose predicate
1958 ;; isn't needed.
1959 (define_insn_and_rewrite "*aarch64_sve2_sra<mode>"
1960 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1961 (plus:SVE_FULL_I
1962 (unspec:SVE_FULL_I
1963 [(match_operand 4)
1964 (SHIFTRT:SVE_FULL_I
1965 (match_operand:SVE_FULL_I 2 "register_operand")
1966 (match_operand:SVE_FULL_I 3 "aarch64_simd_rshift_imm"))]
1967 UNSPEC_PRED_X)
1968 (match_operand:SVE_FULL_I 1 "register_operand")))]
1969 "TARGET_SVE2"
1970 {@ [ cons: =0 , 1 , 2 ; attrs: movprfx ]
1971 [ w , 0 , w ; * ] <sra_op>sra\t%0.<Vetype>, %2.<Vetype>, #%3
1972 [ ?&w , w , w ; yes ] movprfx\t%0, %1\;<sra_op>sra\t%0.<Vetype>, %2.<Vetype>, #%3
1973 }
1974 "&& !CONSTANT_P (operands[4])"
1975 {
1976 operands[4] = CONSTM1_RTX (<VPRED>mode);
1977 }
1978 )
1979
1980 ;; SRSRA and URSRA.
1981 (define_insn "@aarch64_sve_add_<sve_int_op><mode>"
1982 [(set (match_operand:SVE_FULL_I 0 "register_operand")
1983 (plus:SVE_FULL_I
1984 (unspec:SVE_FULL_I
1985 [(match_operand:SVE_FULL_I 2 "register_operand")
1986 (match_operand:SVE_FULL_I 3 "aarch64_simd_rshift_imm")]
1987 VRSHR_N)
1988 (match_operand:SVE_FULL_I 1 "register_operand")))]
1989 "TARGET_SVE2"
1990 {@ [ cons: =0 , 1 , 2 ; attrs: movprfx ]
1991 [ w , 0 , w ; * ] <sur>sra\t%0.<Vetype>, %2.<Vetype>, #%3
1992 [ ?&w , w , w ; yes ] movprfx\t%0, %1\;<sur>sra\t%0.<Vetype>, %2.<Vetype>, #%3
1993 }
1994 )
1995
1996 ;; -------------------------------------------------------------------------
1997 ;; ---- [INT] Shift-and-insert operations
1998 ;; -------------------------------------------------------------------------
1999 ;; Includes:
2000 ;; - SLI
2001 ;; - SRI
2002 ;; -------------------------------------------------------------------------
2003
2004 ;; These instructions do not take MOVPRFX.
2005 (define_insn "@aarch64_sve_<sve_int_op><mode>"
2006 [(set (match_operand:SVE_FULL_I 0 "register_operand" "=w")
2007 (unspec:SVE_FULL_I
2008 [(match_operand:SVE_FULL_I 1 "register_operand" "0")
2009 (match_operand:SVE_FULL_I 2 "register_operand" "w")
2010 (match_operand:SVE_FULL_I 3 "aarch64_simd_<lr>shift_imm")]
2011 SVE2_INT_SHIFT_INSERT))]
2012 "TARGET_SVE2"
2013 "<sve_int_op>\t%0.<Vetype>, %2.<Vetype>, #%3"
2014 )
2015
2016 ;; -------------------------------------------------------------------------
2017 ;; ---- [INT] Sum of absolute differences
2018 ;; -------------------------------------------------------------------------
2019 ;; Includes:
2020 ;; - SABA
2021 ;; - UABA
2022 ;; -------------------------------------------------------------------------
2023
2024 ;; Provide the natural unpredicated interface for SABA and UABA.
2025 (define_expand "@aarch64_sve2_<su>aba<mode>"
2026 [(set (match_operand:SVE_FULL_I 0 "register_operand" "=w, ?&w")
2027 (plus:SVE_FULL_I
2028 (minus:SVE_FULL_I
2029 (unspec:SVE_FULL_I
2030 [(match_dup 4)
2031 (USMAX:SVE_FULL_I
2032 (match_operand:SVE_FULL_I 2 "register_operand" "w, w")
2033 (match_operand:SVE_FULL_I 3 "register_operand" "w, w"))]
2034 UNSPEC_PRED_X)
2035 (unspec:SVE_FULL_I
2036 [(match_dup 4)
2037 (<max_opp>:SVE_FULL_I
2038 (match_dup 2)
2039 (match_dup 3))]
2040 UNSPEC_PRED_X))
2041 (match_operand:SVE_FULL_I 1 "register_operand" "0, w")))]
2042 "TARGET_SVE2"
2043 {
2044 operands[4] = CONSTM1_RTX (<VPRED>mode);
2045 }
2046 )
2047
2048 ;; Pattern-match SABA and UABA as an absolute-difference-and-accumulate
2049 ;; operation whose predicates aren't needed.
2050 (define_insn "*aarch64_sve2_<su>aba<mode>"
2051 [(set (match_operand:SVE_FULL_I 0 "register_operand")
2052 (plus:SVE_FULL_I
2053 (minus:SVE_FULL_I
2054 (unspec:SVE_FULL_I
2055 [(match_operand 4)
2056 (USMAX:SVE_FULL_I
2057 (match_operand:SVE_FULL_I 2 "register_operand")
2058 (match_operand:SVE_FULL_I 3 "register_operand"))]
2059 UNSPEC_PRED_X)
2060 (unspec:SVE_FULL_I
2061 [(match_operand 5)
2062 (<max_opp>:SVE_FULL_I
2063 (match_dup 2)
2064 (match_dup 3))]
2065 UNSPEC_PRED_X))
2066 (match_operand:SVE_FULL_I 1 "register_operand")))]
2067 "TARGET_SVE2"
2068 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2069 [ w , 0 , w , w ; * ] <su>aba\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>
2070 [ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;<su>aba\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>
2071 }
2072 )
2073
2074 ;; -------------------------------------------------------------------------
2075 ;; ---- [FP] Mfloat8 Multiply-and-accumulate operations
2076 ;; -------------------------------------------------------------------------
2077 ;; Includes:
2078 ;; - FMLALB (vectors, FP8 to FP16) (FP8FMA)
2079 ;; - FMLALT (vectors, FP8 to FP16) (FP8FMA)
2080 ;; - FMLALB (indexed, FP8 to FP16) (FP8FMA)
2081 ;; - FMLALT (indexed, FP8 to FP16) (FP8FMA)
2082 ;; - FMLALLBB (vectors) (FP8FMA)
2083 ;; - FMLALLBB (indexed) (FP8FMA)
2084 ;; - FMLALLBT (vectors) (FP8FMA)
2085 ;; - FMLALLBT (indexed) (FP8FMA)
2086 ;; - FMLALLTB (vectors) (FP8FMA)
2087 ;; - FMLALLTB (indexed) (FP8FMA)
2088 ;; - FMLALLTT (vectors) (FP8FMA)
2089 ;; - FMLALLTT (indexed) (FP8FMA)
2090 ;; -------------------------------------------------------------------------
2091
2092 (define_insn "@aarch64_sve_add_<insn><mode>"
2093 [(set (match_operand:VNx8HF_ONLY 0 "register_operand")
2094 (unspec:VNx8HF_ONLY
2095 [(match_operand:VNx8HF 1 "register_operand")
2096 (match_operand:VNx16QI 2 "register_operand")
2097 (match_operand:VNx16QI 3 "register_operand")
2098 (reg:DI FPM_REGNUM)]
2099 FMLAL_FP8_HF))]
2100 "TARGET_SSVE_FP8FMA"
2101 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2102 [ w , 0 , w , w ; * ] <insn>\t%0.h, %2.b, %3.b
2103 [ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;<insn>\t%0.h, %2.b, %3.b
2104 }
2105 )
2106
2107 (define_insn "@aarch64_sve_add_<insn><mode>"
2108 [(set (match_operand:VNx4SF_ONLY 0 "register_operand")
2109 (unspec:VNx4SF_ONLY
2110 [(match_operand:VNx4SF 1 "register_operand")
2111 (match_operand:VNx16QI 2 "register_operand")
2112 (match_operand:VNx16QI 3 "register_operand")
2113 (reg:DI FPM_REGNUM)]
2114 FMLALL_FP8_SF))]
2115 "TARGET_SSVE_FP8FMA"
2116 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2117 [ w , 0 , w , w ; * ] <insn>\t%0.s, %2.b, %3.b
2118 [ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;<insn>\t%0.s, %2.b, %3.b
2119 }
2120 )
2121
2122 (define_insn "@aarch64_sve_add_lane_<insn><mode>"
2123 [(set (match_operand:VNx8HF_ONLY 0 "register_operand")
2124 (unspec:VNx8HF_ONLY
2125 [(match_operand:VNx8HF 1 "register_operand")
2126 (match_operand:VNx16QI 2 "register_operand")
2127 (match_operand:VNx16QI 3 "register_operand")
2128 (match_operand:SI 4 "const_int_operand")
2129 (reg:DI FPM_REGNUM)]
2130 FMLAL_FP8_HF))]
2131 "TARGET_SSVE_FP8FMA"
2132 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2133 [ w , 0 , w , y ; * ] <insn>\t%0.h, %2.b, %3.b[%4]
2134 [ ?&w , w , w , y ; yes ] movprfx\t%0, %1\;<insn>\t%0.h, %2.b, %3.b[%4]
2135 }
2136 )
2137
2138 (define_insn "@aarch64_sve_add_lane_<insn><mode>"
2139 [(set (match_operand:VNx4SF_ONLY 0 "register_operand")
2140 (unspec:VNx4SF_ONLY
2141 [(match_operand:VNx4SF 1 "register_operand")
2142 (match_operand:VNx16QI 2 "register_operand")
2143 (match_operand:VNx16QI 3 "register_operand")
2144 (match_operand:SI 4 "const_int_operand")
2145 (reg:DI FPM_REGNUM)]
2146 FMLALL_FP8_SF))]
2147 "TARGET_SSVE_FP8FMA"
2148 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2149 [ w , 0 , w , y ; * ] <insn>\t%0.s, %2.b, %3.b[%4]
2150 [ ?&w , w , w , y ; yes ] movprfx\t%0, %1\;<insn>\t%0.s, %2.b, %3.b[%4]
2151 }
2152 )
2153
2154 ;; -------------------------------------------------------------------------
2155 ;; ---- [FP] Mfloat8 dot products
2156 ;; -------------------------------------------------------------------------
2157 ;; Includes:
2158 ;; - FDOT (4-way, vectors) (FP8DOT4)
2159 ;; - FDOT (4-way, indexed) (FP8DOT4)
2160 ;; - FDOT (2-way, vectors) (FP8DOT2)
2161 ;; - FDOT (2-way, indexed) (FP8DOT2)
2162 ;; -------------------------------------------------------------------------
2163 (define_insn "@aarch64_sve_dot<mode>"
2164 [(set (match_operand:SVE_FULL_HSF_FP8_FDOT 0 "register_operand")
2165 (unspec:SVE_FULL_HSF_FP8_FDOT
2166 [(match_operand:SVE_FULL_HSF_FP8_FDOT 1 "register_operand")
2167 (match_operand:VNx16QI 2 "register_operand")
2168 (match_operand:VNx16QI 3 "register_operand")
2169 (reg:DI FPM_REGNUM)]
2170 UNSPEC_DOT_FP8))]
2171 ""
2172 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2173 [ w , 0 , w , w ; * ] fdot\t%0.<Vetype>, %2.b, %3.b
2174 [ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;fdot\t%0.<Vetype>, %2.b, %3.b
2175 }
2176 )
2177
2178 (define_insn "@aarch64_sve_dot_lane<mode>"
2179 [(set (match_operand:SVE_FULL_HSF_FP8_FDOT 0 "register_operand")
2180 (unspec:SVE_FULL_HSF_FP8_FDOT
2181 [(match_operand:SVE_FULL_HSF_FP8_FDOT 1 "register_operand")
2182 (match_operand:VNx16QI 2 "register_operand")
2183 (match_operand:VNx16QI 3 "register_operand")
2184 (match_operand:SI 4 "const_int_operand")
2185 (reg:DI FPM_REGNUM)]
2186 UNSPEC_DOT_LANE_FP8))]
2187 ""
2188 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2189 [ w , 0 , w , y ; * ] fdot\t%0.<Vetype>, %2.b, %3.b[%4]
2190 [ ?&w , w , w , y ; yes ] movprfx\t%0, %1\;fdot\t%0.<Vetype>, %2.b, %3.b[%4]
2191 }
2192 )
2193
2194 ;; =========================================================================
2195 ;; == Extending arithmetic
2196 ;; =========================================================================
2197
2198 ;; -------------------------------------------------------------------------
2199 ;; ---- [INT] Multi-register widening conversions
2200 ;; -------------------------------------------------------------------------
2201 ;; Includes:
2202 ;; - SUNPK
2203 ;; - UUNPK
2204 ;; -------------------------------------------------------------------------
2205
2206 (define_insn "<optab><mode><v2xwide>2"
2207 [(set (match_operand:<V2XWIDE> 0 "aligned_register_operand" "=Uw2")
2208 (ANY_EXTEND:<V2XWIDE>
2209 (match_operand:SVE_FULL_BHSI 1 "register_operand" "w")))]
2210 "TARGET_STREAMING_SME2"
2211 "<su>unpk\t%0, %1.<Vetype>"
2212 )
2213
2214 (define_insn "<optab><mode><v2xwide>2"
2215 [(set (match_operand:<V2XWIDE> 0 "aligned_register_operand" "=Uw4")
2216 (ANY_EXTEND:<V2XWIDE>
2217 (match_operand:SVE_FULL_BHSIx2 1 "aligned_register_operand" "Uw2")))]
2218 "TARGET_STREAMING_SME2"
2219 "<su>unpk\t%0, %1"
2220 )
2221
2222 ;; -------------------------------------------------------------------------
2223 ;; ---- [INT] Wide binary arithmetic
2224 ;; -------------------------------------------------------------------------
2225 ;; Includes:
2226 ;; - SADDWB
2227 ;; - SADDWT
2228 ;; - SSUBWB
2229 ;; - SSUBWT
2230 ;; - UADDWB
2231 ;; - UADDWT
2232 ;; - USUBWB
2233 ;; - USUBWT
2234 ;; -------------------------------------------------------------------------
2235
2236 (define_insn "@aarch64_sve_<sve_int_op><mode>"
2237 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand" "=w")
2238 (unspec:SVE_FULL_HSDI
2239 [(match_operand:SVE_FULL_HSDI 1 "register_operand" "w")
2240 (match_operand:<VNARROW> 2 "register_operand" "w")]
2241 SVE2_INT_BINARY_WIDE))]
2242 "TARGET_SVE2"
2243 "<sve_int_op>\t%0.<Vetype>, %1.<Vetype>, %2.<Ventype>"
2244 )
2245
2246 ;; -------------------------------------------------------------------------
2247 ;; ---- [INT] Long binary arithmetic
2248 ;; -------------------------------------------------------------------------
2249 ;; Includes:
2250 ;; - SABDLB
2251 ;; - SABDLT
2252 ;; - SADDLB
2253 ;; - SADDLBT
2254 ;; - SADDLT
2255 ;; - SMULLB
2256 ;; - SMULLT
2257 ;; - SQDMULLB
2258 ;; - SQDMULLT
2259 ;; - SSUBLB
2260 ;; - SSUBLBT
2261 ;; - SSUBLT
2262 ;; - SSUBLTB
2263 ;; - UABDLB
2264 ;; - UABDLT
2265 ;; - UADDLB
2266 ;; - UADDLT
2267 ;; - UMULLB
2268 ;; - UMULLT
2269 ;; - USUBLB
2270 ;; - USUBLT
2271 ;; -------------------------------------------------------------------------
2272
2273 (define_insn "@aarch64_sve_<sve_int_op><mode>"
2274 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand" "=w")
2275 (unspec:SVE_FULL_HSDI
2276 [(match_operand:<VNARROW> 1 "register_operand" "w")
2277 (match_operand:<VNARROW> 2 "register_operand" "w")]
2278 SVE2_INT_BINARY_LONG))]
2279 "TARGET_SVE2"
2280 "<sve_int_op>\t%0.<Vetype>, %1.<Ventype>, %2.<Ventype>"
2281 )
2282
2283 (define_insn "@aarch64_sve_<sve_int_op>_lane_<mode>"
2284 [(set (match_operand:SVE_FULL_SDI 0 "register_operand" "=w")
2285 (unspec:SVE_FULL_SDI
2286 [(match_operand:<VNARROW> 1 "register_operand" "w")
2287 (unspec:<VNARROW>
2288 [(match_operand:<VNARROW> 2 "register_operand" "<sve_lane_con>")
2289 (match_operand:SI 3 "const_int_operand")]
2290 UNSPEC_SVE_LANE_SELECT)]
2291 SVE2_INT_BINARY_LONG_LANE))]
2292 "TARGET_SVE2"
2293 "<sve_int_op>\t%0.<Vetype>, %1.<Ventype>, %2.<Ventype>[%3]"
2294 )
2295
2296 ;; -------------------------------------------------------------------------
2297 ;; ---- [INT] Long left shifts
2298 ;; -------------------------------------------------------------------------
2299 ;; Includes:
2300 ;; - SSHLLB
2301 ;; - SSHLLT
2302 ;; - USHLLB
2303 ;; - USHLLT
2304 ;; -------------------------------------------------------------------------
2305
2306 ;; The immediate range is enforced before generating the instruction.
2307 (define_insn "@aarch64_sve_<sve_int_op><mode>"
2308 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand" "=w")
2309 (unspec:SVE_FULL_HSDI
2310 [(match_operand:<VNARROW> 1 "register_operand" "w")
2311 (match_operand:DI 2 "const_int_operand")]
2312 SVE2_INT_SHIFT_IMM_LONG))]
2313 "TARGET_SVE2"
2314 "<sve_int_op>\t%0.<Vetype>, %1.<Ventype>, #%2"
2315 )
2316
2317 ;; -------------------------------------------------------------------------
2318 ;; ---- [INT] Long binary arithmetic with accumulation
2319 ;; -------------------------------------------------------------------------
2320 ;; Includes:
2321 ;; - SABALB
2322 ;; - SABALT
2323 ;; - SDOT (SME2 or SVE2p1)
2324 ;; - SMLALB
2325 ;; - SMLALT
2326 ;; - SMLSLB
2327 ;; - SMLSLT
2328 ;; - SQDMLALB
2329 ;; - SQDMLALBT
2330 ;; - SQDMLALT
2331 ;; - SQDMLSLB
2332 ;; - SQDMLSLBT
2333 ;; - SQDMLSLT
2334 ;; - UABALB
2335 ;; - UABALT
2336 ;; - UDOT (SME2 or SVE2p1)
2337 ;; - UMLALB
2338 ;; - UMLALT
2339 ;; - UMLSLB
2340 ;; - UMLSLT
2341 ;; -------------------------------------------------------------------------
2342
2343 ;; Non-saturating MLA operations.
2344 (define_insn "@aarch64_sve_add_<sve_int_op><mode>"
2345 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand")
2346 (plus:SVE_FULL_HSDI
2347 (unspec:SVE_FULL_HSDI
2348 [(match_operand:<VNARROW> 2 "register_operand")
2349 (match_operand:<VNARROW> 3 "register_operand")]
2350 SVE2_INT_ADD_BINARY_LONG)
2351 (match_operand:SVE_FULL_HSDI 1 "register_operand")))]
2352 "TARGET_SVE2"
2353 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2354 [ w , 0 , w , w ; * ] <sve_int_add_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>
2355 [ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;<sve_int_add_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>
2356 }
2357 )
2358
2359 ;; Non-saturating MLA operations with lane select.
2360 (define_insn "@aarch64_sve_add_<sve_int_op>_lane_<mode>"
2361 [(set (match_operand:SVE_FULL_SDI 0 "register_operand")
2362 (plus:SVE_FULL_SDI
2363 (unspec:SVE_FULL_SDI
2364 [(match_operand:<VNARROW> 2 "register_operand")
2365 (unspec:<VNARROW>
2366 [(match_operand:<VNARROW> 3 "register_operand")
2367 (match_operand:SI 4 "const_int_operand")]
2368 UNSPEC_SVE_LANE_SELECT)]
2369 SVE2_INT_ADD_BINARY_LONG_LANE)
2370 (match_operand:SVE_FULL_SDI 1 "register_operand")))]
2371 "TARGET_SVE2"
2372 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2373 [ w , 0 , w , <sve_lane_con> ; * ] <sve_int_add_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>[%4]
2374 [ ?&w , w , w , <sve_lane_con> ; yes ] movprfx\t%0, %1\;<sve_int_add_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>[%4]
2375 }
2376 )
2377
2378 ;; Saturating MLA operations.
2379 (define_insn "@aarch64_sve_qadd_<sve_int_op><mode>"
2380 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand")
2381 (ss_plus:SVE_FULL_HSDI
2382 (unspec:SVE_FULL_HSDI
2383 [(match_operand:<VNARROW> 2 "register_operand")
2384 (match_operand:<VNARROW> 3 "register_operand")]
2385 SVE2_INT_QADD_BINARY_LONG)
2386 (match_operand:SVE_FULL_HSDI 1 "register_operand")))]
2387 "TARGET_SVE2"
2388 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2389 [ w , 0 , w , w ; * ] <sve_int_qadd_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>
2390 [ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;<sve_int_qadd_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>
2391 }
2392 )
2393
2394 ;; Saturating MLA operations with lane select.
2395 (define_insn "@aarch64_sve_qadd_<sve_int_op>_lane_<mode>"
2396 [(set (match_operand:SVE_FULL_SDI 0 "register_operand")
2397 (ss_plus:SVE_FULL_SDI
2398 (unspec:SVE_FULL_SDI
2399 [(match_operand:<VNARROW> 2 "register_operand")
2400 (unspec:<VNARROW>
2401 [(match_operand:<VNARROW> 3 "register_operand")
2402 (match_operand:SI 4 "const_int_operand")]
2403 UNSPEC_SVE_LANE_SELECT)]
2404 SVE2_INT_QADD_BINARY_LONG_LANE)
2405 (match_operand:SVE_FULL_SDI 1 "register_operand")))]
2406 "TARGET_SVE2"
2407 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2408 [ w , 0 , w , <sve_lane_con> ; * ] <sve_int_qadd_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>[%4]
2409 [ ?&w , w , w , <sve_lane_con> ; yes ] movprfx\t%0, %1\;<sve_int_qadd_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>[%4]
2410 }
2411 )
2412
2413 ;; Non-saturating MLS operations.
2414 (define_insn "@aarch64_sve_sub_<sve_int_op><mode>"
2415 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand")
2416 (minus:SVE_FULL_HSDI
2417 (match_operand:SVE_FULL_HSDI 1 "register_operand")
2418 (unspec:SVE_FULL_HSDI
2419 [(match_operand:<VNARROW> 2 "register_operand")
2420 (match_operand:<VNARROW> 3 "register_operand")]
2421 SVE2_INT_SUB_BINARY_LONG)))]
2422 "TARGET_SVE2"
2423 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2424 [ w , 0 , w , w ; * ] <sve_int_sub_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>
2425 [ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;<sve_int_sub_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>
2426 }
2427 )
2428
2429 ;; Non-saturating MLS operations with lane select.
2430 (define_insn "@aarch64_sve_sub_<sve_int_op>_lane_<mode>"
2431 [(set (match_operand:SVE_FULL_SDI 0 "register_operand")
2432 (minus:SVE_FULL_SDI
2433 (match_operand:SVE_FULL_SDI 1 "register_operand")
2434 (unspec:SVE_FULL_SDI
2435 [(match_operand:<VNARROW> 2 "register_operand")
2436 (unspec:<VNARROW>
2437 [(match_operand:<VNARROW> 3 "register_operand")
2438 (match_operand:SI 4 "const_int_operand")]
2439 UNSPEC_SVE_LANE_SELECT)]
2440 SVE2_INT_SUB_BINARY_LONG_LANE)))]
2441 "TARGET_SVE2"
2442 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2443 [ w , 0 , w , <sve_lane_con> ; * ] <sve_int_sub_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>[%4]
2444 [ ?&w , w , w , <sve_lane_con> ; yes ] movprfx\t%0, %1\;<sve_int_sub_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>[%4]
2445 }
2446 )
2447
2448 ;; Saturating MLS operations.
2449 (define_insn "@aarch64_sve_qsub_<sve_int_op><mode>"
2450 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand")
2451 (ss_minus:SVE_FULL_HSDI
2452 (match_operand:SVE_FULL_HSDI 1 "register_operand")
2453 (unspec:SVE_FULL_HSDI
2454 [(match_operand:<VNARROW> 2 "register_operand")
2455 (match_operand:<VNARROW> 3 "register_operand")]
2456 SVE2_INT_QSUB_BINARY_LONG)))]
2457 "TARGET_SVE2"
2458 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2459 [ w , 0 , w , w ; * ] <sve_int_qsub_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>
2460 [ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;<sve_int_qsub_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>
2461 }
2462 )
2463
2464 ;; Saturating MLS operations with lane select.
2465 (define_insn "@aarch64_sve_qsub_<sve_int_op>_lane_<mode>"
2466 [(set (match_operand:SVE_FULL_SDI 0 "register_operand")
2467 (ss_minus:SVE_FULL_SDI
2468 (match_operand:SVE_FULL_SDI 1 "register_operand")
2469 (unspec:SVE_FULL_SDI
2470 [(match_operand:<VNARROW> 2 "register_operand")
2471 (unspec:<VNARROW>
2472 [(match_operand:<VNARROW> 3 "register_operand")
2473 (match_operand:SI 4 "const_int_operand")]
2474 UNSPEC_SVE_LANE_SELECT)]
2475 SVE2_INT_QSUB_BINARY_LONG_LANE)))]
2476 "TARGET_SVE2"
2477 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2478 [ w , 0 , w , <sve_lane_con> ; * ] <sve_int_qsub_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>[%4]
2479 [ ?&w , w , w , <sve_lane_con> ; yes ] movprfx\t%0, %1\;<sve_int_qsub_op>\t%0.<Vetype>, %2.<Ventype>, %3.<Ventype>[%4]
2480 }
2481 )
2482
2483 ;; Two-way dot-product.
2484 (define_insn "<sur>dot_prodvnx4sivnx8hi"
2485 [(set (match_operand:VNx4SI 0 "register_operand")
2486 (plus:VNx4SI
2487 (unspec:VNx4SI
2488 [(match_operand:VNx8HI 1 "register_operand")
2489 (match_operand:VNx8HI 2 "register_operand")]
2490 DOTPROD)
2491 (match_operand:VNx4SI 3 "register_operand")))]
2492 "TARGET_SVE2p1_OR_SME2"
2493 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2494 [ w , w , w , 0 ; * ] <sur>dot\t%0.s, %1.h, %2.h
2495 [ ?&w , w , w , w ; yes ] movprfx\t%0, %3\;<sur>dot\t%0.s, %1.h, %2.h
2496 }
2497 )
2498
2499 ;; -------------------------------------------------------------------------
2500 ;; ---- [FP] Multi-register operations
2501 ;; -------------------------------------------------------------------------
2502 ;; Includes the multi-register forms of:
2503 ;; - FMAX
2504 ;; - FMAXNM
2505 ;; - FMIN
2506 ;; - FMINNM
2507 ;; -------------------------------------------------------------------------
2508
2509 (define_expand "@aarch64_sve_<maxmin_uns_op><mode>"
2510 [(set (match_operand:SVE_Fx24 0 "aligned_register_operand" "=Uw<vector_count>")
2511 (unspec:SVE_Fx24
2512 [(match_operand:SVE_Fx24 1 "aligned_register_operand" "Uw<vector_count>")
2513 (match_operand:SVE_Fx24 2 "aligned_register_operand" "Uw<vector_count>")]
2514 SVE_FP_BINARY_MULTI))]
2515 "TARGET_STREAMING_SME2"
2516 )
2517
2518 (define_insn "*aarch64_sve_<maxmin_uns_op><mode>"
2519 [(set (match_operand:SVE_Fx24 0 "aligned_register_operand" "=Uw<vector_count>")
2520 (unspec:SVE_Fx24
2521 [(match_operand:SVE_Fx24 1 "aligned_register_operand" "%0")
2522 (match_operand:SVE_Fx24 2 "aligned_register_operand" "Uw<vector_count>")]
2523 SVE_FP_BINARY_MULTI))]
2524 "TARGET_STREAMING_SME2"
2525 "<b><maxmin_uns_op>\t%0, %0, %2"
2526 )
2527
2528 (define_insn "@aarch64_sve_single_<maxmin_uns_op><mode>"
2529 [(set (match_operand:SVE_Fx24 0 "aligned_register_operand" "=Uw<vector_count>")
2530 (unspec:SVE_Fx24
2531 [(match_operand:SVE_Fx24 1 "aligned_register_operand" "0")
2532 (vec_duplicate:SVE_Fx24
2533 (match_operand:<VSINGLE> 2 "register_operand" "x"))]
2534 SVE_FP_BINARY_MULTI))]
2535 "TARGET_STREAMING_SME2"
2536 "<b><maxmin_uns_op>\t%0, %0, %2.<Vetype>"
2537 )
2538
2539 ;; -------------------------------------------------------------------------
2540 ;; ---- [FP] Long multiplication with accumulation
2541 ;; -------------------------------------------------------------------------
2542 ;; Includes:
2543 ;; - FDOT (SME2 or SVE2p1)
2544 ;; - FMLALB
2545 ;; - FMLALT
2546 ;; - FMLSLB
2547 ;; - FMLSLT
2548 ;; -------------------------------------------------------------------------
2549
2550 (define_insn "@aarch64_sve_<sve_fp_op><mode>"
2551 [(set (match_operand:VNx4SF_ONLY 0 "register_operand")
2552 (unspec:VNx4SF_ONLY
2553 [(match_operand:<VNARROW> 1 "register_operand")
2554 (match_operand:<VNARROW> 2 "register_operand")
2555 (match_operand:VNx4SF_ONLY 3 "register_operand")]
2556 SVE2_FP_TERNARY_LONG))]
2557 "TARGET_SVE2"
2558 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2559 [ w , w , w , 0 ; * ] <sve_fp_op>\t%0.<Vetype>, %1.<Ventype>, %2.<Ventype>
2560 [ ?&w , w , w , w ; yes ] movprfx\t%0, %3\;<sve_fp_op>\t%0.<Vetype>, %1.<Ventype>, %2.<Ventype>
2561 }
2562 )
2563
2564 (define_insn "@aarch64_<sve_fp_op>_lane_<mode>"
2565 [(set (match_operand:VNx4SF_ONLY 0 "register_operand")
2566 (unspec:VNx4SF_ONLY
2567 [(match_operand:<VNARROW> 1 "register_operand")
2568 (unspec:<VNARROW>
2569 [(match_operand:<VNARROW> 2 "register_operand")
2570 (match_operand:SI 3 "const_int_operand")]
2571 UNSPEC_SVE_LANE_SELECT)
2572 (match_operand:VNx4SF_ONLY 4 "register_operand")]
2573 SVE2_FP_TERNARY_LONG_LANE))]
2574 "TARGET_SVE2"
2575 {@ [ cons: =0 , 1 , 2 , 4 ; attrs: movprfx ]
2576 [ w , w , <sve_lane_con> , 0 ; * ] <sve_fp_op>\t%0.<Vetype>, %1.<Ventype>, %2.<Ventype>[%3]
2577 [ ?&w , w , <sve_lane_con> , w ; yes ] movprfx\t%0, %4\;<sve_fp_op>\t%0.<Vetype>, %1.<Ventype>, %2.<Ventype>[%3]
2578 }
2579 )
2580
2581 ;; Two-way dot-product.
2582 (define_insn "aarch64_sve_fdotvnx4sfvnx8hf"
2583 [(set (match_operand:VNx4SF 0 "register_operand")
2584 (plus:VNx4SF
2585 (unspec:VNx4SF
2586 [(match_operand:VNx8HF 1 "register_operand")
2587 (match_operand:VNx8HF 2 "register_operand")]
2588 UNSPEC_FDOT)
2589 (match_operand:VNx4SF 3 "register_operand")))]
2590 "TARGET_SVE2p1_OR_SME2"
2591 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2592 [ w , w , w , 0 ; * ] fdot\t%0.s, %1.h, %2.h
2593 [ ?&w , w , w , w ; yes ] movprfx\t%0, %3\;fdot\t%0.s, %1.h, %2.h
2594 }
2595 )
2596
2597 (define_insn "aarch64_fdot_prod_lanevnx4sfvnx8hf"
2598 [(set (match_operand:VNx4SF 0 "register_operand")
2599 (plus:VNx4SF
2600 (unspec:VNx4SF
2601 [(match_operand:VNx8HF 1 "register_operand")
2602 (unspec:VNx8HF
2603 [(match_operand:VNx8HF 2 "register_operand")
2604 (match_operand:SI 3 "const_int_operand")]
2605 UNSPEC_SVE_LANE_SELECT)]
2606 UNSPEC_FDOT)
2607 (match_operand:VNx4SF 4 "register_operand")))]
2608 "TARGET_SVE2p1_OR_SME2"
2609 {@ [ cons: =0 , 1 , 2 , 4 ; attrs: movprfx ]
2610 [ w , w , y , 0 ; * ] fdot\t%0.s, %1.h, %2.h[%3]
2611 [ ?&w , w , y , w ; yes ] movprfx\t%0, %4\;fdot\t%0.s, %1.h, %2.h[%3]
2612 }
2613 )
2614
2615 ;; =========================================================================
2616 ;; == Narrowing arithnetic
2617 ;; =========================================================================
2618
2619 ;; -------------------------------------------------------------------------
2620 ;; ---- [INT] Narrowing unary arithmetic
2621 ;; -------------------------------------------------------------------------
2622 ;; Includes:
2623 ;; - SQXTNB
2624 ;; - SQXTNT
2625 ;; - SQXTUNB
2626 ;; - SQXTUNT
2627 ;; - UQXTNB
2628 ;; - UQXTNT
2629 ;; -------------------------------------------------------------------------
2630
2631 (define_insn "@aarch64_sve_<sve_int_op><mode>"
2632 [(set (match_operand:<VNARROW> 0 "register_operand" "=w")
2633 (unspec:<VNARROW>
2634 [(match_operand:SVE_FULL_HSDI 1 "register_operand" "w")]
2635 SVE2_INT_UNARY_NARROWB))]
2636 "TARGET_SVE2"
2637 "<sve_int_op>\t%0.<Ventype>, %1.<Vetype>"
2638 )
2639
2640 ;; These instructions do not take MOVPRFX.
2641 (define_insn "@aarch64_sve_<sve_int_op><mode>"
2642 [(set (match_operand:<VNARROW> 0 "register_operand" "=w")
2643 (unspec:<VNARROW>
2644 [(match_operand:<VNARROW> 1 "register_operand" "0")
2645 (match_operand:SVE_FULL_HSDI 2 "register_operand" "w")]
2646 SVE2_INT_UNARY_NARROWT))]
2647 "TARGET_SVE2"
2648 "<sve_int_op>\t%0.<Ventype>, %2.<Vetype>"
2649 )
2650
2651 ;; -------------------------------------------------------------------------
2652 ;; ---- [INT] Multi-vector narrowing unary arithmetic
2653 ;; -------------------------------------------------------------------------
2654 ;; Includes:
2655 ;; - SQCVT (SME2)
2656 ;; - SQCVTN (SME2)
2657 ;; - UQCVT (SME2)
2658 ;; - UQCVTN (SME2)
2659 ;; -------------------------------------------------------------------------
2660
2661 (define_insn "@aarch64_sve_<optab><VNx16QI_ONLY:mode><VNx16SI_ONLY:mode>"
2662 [(set (match_operand:VNx16QI_ONLY 0 "register_operand" "=w")
2663 (unspec:VNx16QI_ONLY
2664 [(match_operand:VNx16SI_ONLY 1 "aligned_register_operand" "Uw<vector_count>")]
2665 SVE_QCVTxN))]
2666 "TARGET_STREAMING_SME2"
2667 "<optab>\t%0.b, %1"
2668 )
2669
2670 (define_insn "@aarch64_sve_<optab><VNx8HI_ONLY:mode><VNx8SI_ONLY:mode>"
2671 [(set (match_operand:VNx8HI_ONLY 0 "register_operand" "=w")
2672 (unspec:VNx8HI_ONLY
2673 [(match_operand:VNx8SI_ONLY 1 "aligned_register_operand" "Uw<vector_count>")]
2674 SVE_QCVTxN))]
2675 ""
2676 "<optab>\t%0.h, %1"
2677 )
2678
2679 (define_insn "@aarch64_sve_<optab><VNx8HI_ONLY:mode><VNx8DI_ONLY:mode>"
2680 [(set (match_operand:VNx8HI_ONLY 0 "register_operand" "=w")
2681 (unspec:VNx8HI_ONLY
2682 [(match_operand:VNx8DI_ONLY 1 "aligned_register_operand" "Uw<vector_count>")]
2683 SVE_QCVTxN))]
2684 "TARGET_STREAMING_SME2"
2685 "<optab>\t%0.h, %1"
2686 )
2687
2688 ;; -------------------------------------------------------------------------
2689 ;; ---- [INT] Narrowing binary arithmetic
2690 ;; -------------------------------------------------------------------------
2691 ;; Includes:
2692 ;; - ADDHNB
2693 ;; - ADDHNT
2694 ;; - RADDHNB
2695 ;; - RADDHNT
2696 ;; - RSUBHNB
2697 ;; - RSUBHNT
2698 ;; - SUBHNB
2699 ;; - SUBHNT
2700 ;; -------------------------------------------------------------------------
2701
2702 (define_insn "@aarch64_sve_<sve_int_op><mode>"
2703 [(set (match_operand:<VNARROW> 0 "register_operand" "=w")
2704 (unspec:<VNARROW>
2705 [(match_operand:SVE_FULL_HSDI 1 "register_operand" "w")
2706 (match_operand:SVE_FULL_HSDI 2 "register_operand" "w")]
2707 SVE2_INT_BINARY_NARROWB))]
2708 "TARGET_SVE2"
2709 "<sve_int_op>\t%0.<Ventype>, %1.<Vetype>, %2.<Vetype>"
2710 )
2711
2712 ;; These instructions do not take MOVPRFX.
2713 (define_insn "@aarch64_sve_<sve_int_op><mode>"
2714 [(set (match_operand:<VNARROW> 0 "register_operand" "=w")
2715 (unspec:<VNARROW>
2716 [(match_operand:<VNARROW> 1 "register_operand" "0")
2717 (match_operand:SVE_FULL_HSDI 2 "register_operand" "w")
2718 (match_operand:SVE_FULL_HSDI 3 "register_operand" "w")]
2719 SVE2_INT_BINARY_NARROWT))]
2720 "TARGET_SVE2"
2721 "<sve_int_op>\t%0.<Ventype>, %2.<Vetype>, %3.<Vetype>"
2722 )
2723
2724 ;; Optimize ((a + b) >> n) where n is half the bitsize of the vector
2725 (define_insn "*bitmask_shift_plus<mode>"
2726 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand" "=w")
2727 (unspec:SVE_FULL_HSDI
2728 [(match_operand:<VPRED> 1)
2729 (lshiftrt:SVE_FULL_HSDI
2730 (plus:SVE_FULL_HSDI
2731 (match_operand:SVE_FULL_HSDI 2 "register_operand" "w")
2732 (match_operand:SVE_FULL_HSDI 3 "register_operand" "w"))
2733 (match_operand:SVE_FULL_HSDI 4
2734 "aarch64_simd_shift_imm_vec_exact_top" ""))]
2735 UNSPEC_PRED_X))]
2736 "TARGET_SVE2"
2737 "addhnb\t%0.<Ventype>, %2.<Vetype>, %3.<Vetype>"
2738 )
2739
2740 ;; -------------------------------------------------------------------------
2741 ;; ---- [INT] Narrowing right shifts
2742 ;; -------------------------------------------------------------------------
2743 ;; Includes:
2744 ;; - RSHRNB
2745 ;; - RSHRNT
2746 ;; - SHRNB
2747 ;; - SHRNT
2748 ;; - SQRSHRNB
2749 ;; - SQRSHRNT
2750 ;; - SQRSHRUNB
2751 ;; - SQRSHRUNT
2752 ;; - SQSHRNB
2753 ;; - SQSHRNT
2754 ;; - SQSHRUNB
2755 ;; - SQSHRUNT
2756 ;; - UQRSHRNB
2757 ;; - UQRSHRNT
2758 ;; - UQSHRNB
2759 ;; - UQSHRNT
2760 ;; -------------------------------------------------------------------------
2761
2762 ;; The immediate range is enforced before generating the instruction.
2763 (define_insn "@aarch64_sve_<sve_int_op><mode>"
2764 [(set (match_operand:<VNARROW> 0 "register_operand" "=w")
2765 (unspec:<VNARROW>
2766 [(match_operand:SVE_FULL_HSDI 1 "register_operand" "w")
2767 (match_operand:DI 2 "const_int_operand")]
2768 SVE2_INT_SHIFT_IMM_NARROWB))]
2769 "TARGET_SVE2"
2770 "<sve_int_op>\t%0.<Ventype>, %1.<Vetype>, #%2"
2771 )
2772
2773 ;; The immediate range is enforced before generating the instruction.
2774 ;; These instructions do not take MOVPRFX.
2775 (define_insn "@aarch64_sve_<sve_int_op><mode>"
2776 [(set (match_operand:<VNARROW> 0 "register_operand" "=w")
2777 (unspec:<VNARROW>
2778 [(match_operand:<VNARROW> 1 "register_operand" "0")
2779 (match_operand:SVE_FULL_HSDI 2 "register_operand" "w")
2780 (match_operand:DI 3 "const_int_operand")]
2781 SVE2_INT_SHIFT_IMM_NARROWT))]
2782 "TARGET_SVE2"
2783 "<sve_int_op>\t%0.<Ventype>, %2.<Vetype>, #%3"
2784 )
2785
2786 ;; -------------------------------------------------------------------------
2787 ;; ---- [INT] Multi-vector narrowing right shifts
2788 ;; -------------------------------------------------------------------------
2789 ;; Includes:
2790 ;; - SQRSHR (SME2)
2791 ;; - SQRSHRN (SVE2p1, SME2)
2792 ;; - SQRSHRU (SME2)
2793 ;; - SQRSHRUN (SVE2p1, SME2)
2794 ;; - UQRSHR (SME2)
2795 ;; - UQRSHRN (SVE2p1, SME2)
2796 ;; -------------------------------------------------------------------------
2797
2798 (define_insn "@aarch64_sve_<sve_int_op><mode>"
2799 [(set (match_operand:<VNARROW> 0 "register_operand" "=w")
2800 (unspec:<VNARROW>
2801 [(match_operand:SVE_FULL_SIx2_SDIx4 1 "register_operand" "Uw<vector_count>")
2802 (match_operand:DI 2 "const_int_operand")]
2803 SVE2_INT_SHIFT_IMM_NARROWxN))]
2804 "(<MODE>mode == VNx8SImode || TARGET_STREAMING_SME2)"
2805 "<sve_int_op>\t%0.<Ventype>, %1, #%2"
2806 )
2807
2808 ;; =========================================================================
2809 ;; == Pairwise arithmetic
2810 ;; =========================================================================
2811
2812 ;; -------------------------------------------------------------------------
2813 ;; ---- [INT] Pairwise arithmetic
2814 ;; -------------------------------------------------------------------------
2815 ;; Includes:
2816 ;; - ADDP
2817 ;; - SMAXP
2818 ;; - SMINP
2819 ;; - UMAXP
2820 ;; - UMINP
2821 ;; -------------------------------------------------------------------------
2822
2823 (define_insn "@aarch64_pred_<sve_int_op><mode>"
2824 [(set (match_operand:SVE_FULL_I 0 "register_operand")
2825 (unspec:SVE_FULL_I
2826 [(match_operand:<VPRED> 1 "register_operand")
2827 (match_operand:SVE_FULL_I 2 "register_operand")
2828 (match_operand:SVE_FULL_I 3 "register_operand")]
2829 SVE2_INT_BINARY_PAIR))]
2830 "TARGET_SVE2"
2831 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2832 [ w , Upl , 0 , w ; * ] <sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
2833 [ ?&w , Upl , w , w ; yes ] movprfx\t%0, %2\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
2834 }
2835 )
2836
2837 ;; -------------------------------------------------------------------------
2838 ;; ---- [FP] Pairwise arithmetic
2839 ;; -------------------------------------------------------------------------
2840 ;; Includes:
2841 ;; - FADDP
2842 ;; - FMAXP
2843 ;; - FMAXNMP
2844 ;; - FMINP
2845 ;; - FMINNMP
2846 ;; -------------------------------------------------------------------------
2847
2848 (define_insn "@aarch64_pred_<sve_fp_op><mode>"
2849 [(set (match_operand:SVE_FULL_F 0 "register_operand")
2850 (unspec:SVE_FULL_F
2851 [(match_operand:<VPRED> 1 "register_operand")
2852 (match_operand:SVE_FULL_F 2 "register_operand")
2853 (match_operand:SVE_FULL_F 3 "register_operand")]
2854 SVE2_FP_BINARY_PAIR))]
2855 "TARGET_SVE2"
2856 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2857 [ w , Upl , 0 , w ; * ] <sve_fp_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
2858 [ ?&w , Upl , w , w ; yes ] movprfx\t%0, %2\;<sve_fp_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
2859 }
2860 )
2861
2862 ;; -------------------------------------------------------------------------
2863 ;; ---- [INT] Pairwise arithmetic with accumulation
2864 ;; -------------------------------------------------------------------------
2865 ;; Includes:
2866 ;; - SADALP
2867 ;; - UADALP
2868 ;; -------------------------------------------------------------------------
2869
2870 ;; Predicated pairwise absolute difference and accumulate with merging.
2871 (define_expand "@cond_<sve_int_op><mode>"
2872 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand")
2873 (unspec:SVE_FULL_HSDI
2874 [(match_operand:<VPRED> 1 "register_operand")
2875 (unspec:SVE_FULL_HSDI
2876 [(match_dup 1)
2877 (match_operand:SVE_FULL_HSDI 2 "register_operand")
2878 (match_operand:<VNARROW> 3 "register_operand")]
2879 SVE2_INT_BINARY_PAIR_LONG)
2880 (match_operand:SVE_FULL_HSDI 4 "aarch64_simd_reg_or_zero")]
2881 UNSPEC_SEL))]
2882 "TARGET_SVE2"
2883 {
2884 /* Only target code is aware of these operations, so we don't need
2885 to handle the fully-general case. */
2886 gcc_assert (rtx_equal_p (operands[2], operands[4])
2887 || CONSTANT_P (operands[4]));
2888 })
2889
2890 ;; Predicated pairwise absolute difference and accumulate, merging with
2891 ;; the first input.
2892 (define_insn_and_rewrite "*cond_<sve_int_op><mode>_2"
2893 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand")
2894 (unspec:SVE_FULL_HSDI
2895 [(match_operand:<VPRED> 1 "register_operand")
2896 (unspec:SVE_FULL_HSDI
2897 [(match_operand 4)
2898 (match_operand:SVE_FULL_HSDI 2 "register_operand")
2899 (match_operand:<VNARROW> 3 "register_operand")]
2900 SVE2_INT_BINARY_PAIR_LONG)
2901 (match_dup 2)]
2902 UNSPEC_SEL))]
2903 "TARGET_SVE2"
2904 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
2905 [ w , Upl , 0 , w ; * ] <sve_int_op>\t%0.<Vetype>, %1/m, %3.<Ventype>
2906 [ ?&w , Upl , w , w ; yes ] movprfx\t%0, %2\;<sve_int_op>\t%0.<Vetype>, %1/m, %3.<Ventype>
2907 }
2908 "&& !CONSTANT_P (operands[4])"
2909 {
2910 operands[4] = CONSTM1_RTX (<VPRED>mode);
2911 }
2912 )
2913
2914 ;; Predicated pairwise absolute difference and accumulate, merging with zero.
2915 (define_insn_and_rewrite "*cond_<sve_int_op><mode>_z"
2916 [(set (match_operand:SVE_FULL_HSDI 0 "register_operand")
2917 (unspec:SVE_FULL_HSDI
2918 [(match_operand:<VPRED> 1 "register_operand")
2919 (unspec:SVE_FULL_HSDI
2920 [(match_operand 5)
2921 (match_operand:SVE_FULL_HSDI 2 "register_operand")
2922 (match_operand:<VNARROW> 3 "register_operand")]
2923 SVE2_INT_BINARY_PAIR_LONG)
2924 (match_operand:SVE_FULL_HSDI 4 "aarch64_simd_imm_zero")]
2925 UNSPEC_SEL))]
2926 "TARGET_SVE2"
2927 {@ [ cons: =0 , 1 , 2 , 3 ]
2928 [ &w , Upl , 0 , w ] movprfx\t%0.<Vetype>, %1/z, %0.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %3.<Ventype>
2929 [ &w , Upl , w , w ] movprfx\t%0.<Vetype>, %1/z, %2.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %3.<Ventype>
2930 }
2931 "&& !CONSTANT_P (operands[5])"
2932 {
2933 operands[5] = CONSTM1_RTX (<VPRED>mode);
2934 }
2935 [(set_attr "movprfx" "yes")]
2936 )
2937
2938 ;; -------------------------------------------------------------------------
2939 ;; -- [FP] Absolute maximum and minimum
2940 ;; -------------------------------------------------------------------------
2941 ;; Includes:
2942 ;; - FAMAX
2943 ;; - FAMIN
2944 ;; -------------------------------------------------------------------------
2945 ;; Predicated floating-point absolute maximum and minimum.
2946 (define_insn_and_rewrite "*aarch64_pred_faminmax_fused"
2947 [(set (match_operand:SVE_FULL_F 0 "register_operand")
2948 (unspec:SVE_FULL_F
2949 [(match_operand:<VPRED> 1 "register_operand")
2950 (match_operand:SI 4 "aarch64_sve_gp_strictness")
2951 (unspec:SVE_FULL_F
2952 [(match_operand 5)
2953 (const_int SVE_RELAXED_GP)
2954 (match_operand:SVE_FULL_F 2 "register_operand")]
2955 UNSPEC_COND_FABS)
2956 (unspec:SVE_FULL_F
2957 [(match_operand 6)
2958 (const_int SVE_RELAXED_GP)
2959 (match_operand:SVE_FULL_F 3 "register_operand")]
2960 UNSPEC_COND_FABS)]
2961 SVE_COND_SMAXMIN))]
2962 "TARGET_FAMINMAX && TARGET_SVE2_OR_SME2"
2963 {@ [ cons: =0 , 1 , %2 , 3 ; attrs: movprfx ]
2964 [ w , Upl , 0 , w ; * ] <faminmax_cond_uns_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
2965 [ ?&w , Upl , w , w ; yes ] movprfx\t%0, %2\;<faminmax_cond_uns_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
2966 }
2967 "&& (!rtx_equal_p (operands[1], operands[5])
2968 || !rtx_equal_p (operands[1], operands[6]))"
2969 {
2970 operands[5] = copy_rtx (operands[1]);
2971 operands[6] = copy_rtx (operands[1]);
2972 }
2973 )
2974
2975 ;; =========================================================================
2976 ;; == Complex arithmetic
2977 ;; =========================================================================
2978
2979 ;; -------------------------------------------------------------------------
2980 ;; ---- [INT] Complex binary operations
2981 ;; -------------------------------------------------------------------------
2982 ;; Includes:
2983 ;; - CADD
2984 ;; - SQCADD
2985 ;; -------------------------------------------------------------------------
2986
2987 (define_insn "@aarch64_sve_<optab><mode>"
2988 [(set (match_operand:SVE_FULL_I 0 "register_operand")
2989 (unspec:SVE_FULL_I
2990 [(match_operand:SVE_FULL_I 1 "register_operand")
2991 (match_operand:SVE_FULL_I 2 "register_operand")]
2992 SVE2_INT_CADD))]
2993 "TARGET_SVE2"
2994 {@ [ cons: =0 , 1 , 2 ; attrs: movprfx ]
2995 [ w , 0 , w ; * ] <sve_int_op>\t%0.<Vetype>, %0.<Vetype>, %2.<Vetype>, #<rot>
2996 [ ?&w , w , w ; yes ] movprfx\t%0, %1\;<sve_int_op>\t%0.<Vetype>, %0.<Vetype>, %2.<Vetype>, #<rot>
2997 }
2998 )
2999
3000 ;; unpredicated optab pattern for auto-vectorizer
3001 (define_expand "cadd<rot><mode>3"
3002 [(set (match_operand:SVE_FULL_I 0 "register_operand")
3003 (unspec:SVE_FULL_I
3004 [(match_operand:SVE_FULL_I 1 "register_operand")
3005 (match_operand:SVE_FULL_I 2 "register_operand")]
3006 SVE2_INT_CADD_OP))]
3007 "TARGET_SVE2"
3008 )
3009
3010 ;; -------------------------------------------------------------------------
3011 ;; ---- [INT] Complex ternary operations
3012 ;; -------------------------------------------------------------------------
3013 ;; Includes:
3014 ;; - CMLA
3015 ;; - SQRDCMLA
3016 ;; -------------------------------------------------------------------------
3017
3018 (define_insn "@aarch64_sve_<optab><mode>"
3019 [(set (match_operand:SVE_FULL_I 0 "register_operand")
3020 (unspec:SVE_FULL_I
3021 [(match_operand:SVE_FULL_I 1 "register_operand")
3022 (match_operand:SVE_FULL_I 2 "register_operand")
3023 (match_operand:SVE_FULL_I 3 "register_operand")]
3024 SVE2_INT_CMLA))]
3025 "TARGET_SVE2"
3026 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
3027 [ w , 0 , w , w ; * ] <sve_int_op>\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>, #<rot>
3028 [ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;<sve_int_op>\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>, #<rot>
3029 }
3030 )
3031
3032 (define_insn "@aarch64_<optab>_lane_<mode>"
3033 [(set (match_operand:SVE_FULL_HSI 0 "register_operand")
3034 (unspec:SVE_FULL_HSI
3035 [(match_operand:SVE_FULL_HSI 1 "register_operand")
3036 (match_operand:SVE_FULL_HSI 2 "register_operand")
3037 (unspec:SVE_FULL_HSI
3038 [(match_operand:SVE_FULL_HSI 3 "register_operand")
3039 (match_operand:SI 4 "const_int_operand")]
3040 UNSPEC_SVE_LANE_SELECT)]
3041 SVE2_INT_CMLA))]
3042 "TARGET_SVE2"
3043 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
3044 [ w , 0 , w , <sve_lane_con> ; * ] <sve_int_op>\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>[%4], #<rot>
3045 [ ?&w , w , w , <sve_lane_con> ; yes ] movprfx\t%0, %1\;<sve_int_op>\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>[%4], #<rot>
3046 }
3047 )
3048
3049 ;; unpredicated optab pattern for auto-vectorizer
3050 ;; The complex mla/mls operations always need to expand to two instructions.
3051 ;; The first operation does half the computation and the second does the
3052 ;; remainder. Because of this, expand early.
3053 (define_expand "cml<fcmac1><conj_op><mode>4"
3054 [(set (match_operand:SVE_FULL_I 0 "register_operand")
3055 (plus:SVE_FULL_I (match_operand:SVE_FULL_I 1 "register_operand")
3056 (unspec:SVE_FULL_I
3057 [(match_operand:SVE_FULL_I 2 "register_operand")
3058 (match_operand:SVE_FULL_I 3 "register_operand")]
3059 SVE2_INT_CMLA_OP)))]
3060 "TARGET_SVE2"
3061 {
3062 rtx tmp = gen_reg_rtx (<MODE>mode);
3063 emit_insn (gen_aarch64_sve_cmla<sve_rot1><mode> (tmp, operands[1],
3064 operands[3], operands[2]));
3065 emit_insn (gen_aarch64_sve_cmla<sve_rot2><mode> (operands[0], tmp,
3066 operands[3], operands[2]));
3067 DONE;
3068 })
3069
3070 ;; unpredicated optab pattern for auto-vectorizer
3071 ;; The complex mul operations always need to expand to two instructions.
3072 ;; The first operation does half the computation and the second does the
3073 ;; remainder. Because of this, expand early.
3074 (define_expand "cmul<conj_op><mode>3"
3075 [(set (match_operand:SVE_FULL_I 0 "register_operand")
3076 (unspec:SVE_FULL_I
3077 [(match_operand:SVE_FULL_I 1 "register_operand")
3078 (match_operand:SVE_FULL_I 2 "register_operand")]
3079 SVE2_INT_CMUL_OP))]
3080 "TARGET_SVE2"
3081 {
3082 rtx accum = force_reg (<MODE>mode, CONST0_RTX (<MODE>mode));
3083 rtx tmp = gen_reg_rtx (<MODE>mode);
3084 emit_insn (gen_aarch64_sve_cmla<sve_rot1><mode> (tmp, accum,
3085 operands[2], operands[1]));
3086 emit_insn (gen_aarch64_sve_cmla<sve_rot2><mode> (operands[0], tmp,
3087 operands[2], operands[1]));
3088 DONE;
3089 })
3090
3091 ;; -------------------------------------------------------------------------
3092 ;; ---- [INT] Complex dot product
3093 ;; -------------------------------------------------------------------------
3094 ;; Includes:
3095 ;; - CDOT
3096 ;; -------------------------------------------------------------------------
3097
3098 (define_insn "@aarch64_sve_<optab><mode>"
3099 [(set (match_operand:SVE_FULL_SDI 0 "register_operand")
3100 (unspec:SVE_FULL_SDI
3101 [(match_operand:SVE_FULL_SDI 1 "register_operand")
3102 (match_operand:<VSI2QI> 2 "register_operand")
3103 (match_operand:<VSI2QI> 3 "register_operand")]
3104 SVE2_INT_CDOT))]
3105 "TARGET_SVE2"
3106 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
3107 [ w , 0 , w , w ; * ] <sve_int_op>\t%0.<Vetype>, %2.<Vetype_fourth>, %3.<Vetype_fourth>, #<rot>
3108 [ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;<sve_int_op>\t%0.<Vetype>, %2.<Vetype_fourth>, %3.<Vetype_fourth>, #<rot>
3109 }
3110 )
3111
3112 (define_insn "@aarch64_<optab>_lane_<mode>"
3113 [(set (match_operand:SVE_FULL_SDI 0 "register_operand")
3114 (unspec:SVE_FULL_SDI
3115 [(match_operand:SVE_FULL_SDI 1 "register_operand")
3116 (match_operand:<VSI2QI> 2 "register_operand")
3117 (unspec:<VSI2QI>
3118 [(match_operand:<VSI2QI> 3 "register_operand")
3119 (match_operand:SI 4 "const_int_operand")]
3120 UNSPEC_SVE_LANE_SELECT)]
3121 SVE2_INT_CDOT))]
3122 "TARGET_SVE2"
3123 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
3124 [ w , 0 , w , <sve_lane_con> ; * ] <sve_int_op>\t%0.<Vetype>, %2.<Vetype_fourth>, %3.<Vetype_fourth>[%4], #<rot>
3125 [ ?&w , w , w , <sve_lane_con> ; yes ] movprfx\t%0, %1\;<sve_int_op>\t%0.<Vetype>, %2.<Vetype_fourth>, %3.<Vetype_fourth>[%4], #<rot>
3126 }
3127 )
3128
3129 ;; =========================================================================
3130 ;; == Conversions
3131 ;; =========================================================================
3132
3133 ;; -------------------------------------------------------------------------
3134 ;; ---- [FP<-FP] Widening conversions
3135 ;; -------------------------------------------------------------------------
3136 ;; Includes:
3137 ;; - BF1CVT (FP8)
3138 ;; - BF1CVTLT (FP8)
3139 ;; - BF2CVT (FP8)
3140 ;; - BF2CVTLT (FP8)
3141 ;; - F1CVT (FP8)
3142 ;; - F1CVTLT (FP8)
3143 ;; - F2CVT (FP8)
3144 ;; - F2CVTLT (FP8)
3145 ;; - FCVTLT
3146 ;; -------------------------------------------------------------------------
3147
3148 ;; Predicated convert long top.
3149 (define_insn "@aarch64_pred_<sve_fp_op><mode>"
3150 [(set (match_operand:SVE_FULL_SDF 0 "register_operand" "=w")
3151 (unspec:SVE_FULL_SDF
3152 [(match_operand:<VPRED> 1 "register_operand" "Upl")
3153 (match_operand:SI 3 "aarch64_sve_gp_strictness")
3154 (match_operand:<VNARROW> 2 "register_operand" "0")]
3155 SVE2_COND_FP_UNARY_LONG))]
3156 "TARGET_SVE2"
3157 "<sve_fp_op>\t%0.<Vetype>, %1/m, %0.<Ventype>"
3158 )
3159
3160 ;; Predicated convert long top with merging.
3161 (define_expand "@cond_<sve_fp_op><mode>"
3162 [(set (match_operand:SVE_FULL_SDF 0 "register_operand")
3163 (unspec:SVE_FULL_SDF
3164 [(match_operand:<VPRED> 1 "register_operand")
3165 (unspec:SVE_FULL_SDF
3166 [(match_dup 1)
3167 (const_int SVE_STRICT_GP)
3168 (match_operand:<VNARROW> 2 "register_operand")]
3169 SVE2_COND_FP_UNARY_LONG)
3170 (match_operand:SVE_FULL_SDF 3 "register_operand")]
3171 UNSPEC_SEL))]
3172 "TARGET_SVE2"
3173 )
3174
3175 ;; These instructions do not take MOVPRFX.
3176 (define_insn_and_rewrite "*cond_<sve_fp_op><mode>_relaxed"
3177 [(set (match_operand:SVE_FULL_SDF 0 "register_operand" "=w")
3178 (unspec:SVE_FULL_SDF
3179 [(match_operand:<VPRED> 1 "register_operand" "Upl")
3180 (unspec:SVE_FULL_SDF
3181 [(match_operand 4)
3182 (const_int SVE_RELAXED_GP)
3183 (match_operand:<VNARROW> 2 "register_operand" "w")]
3184 SVE2_COND_FP_UNARY_LONG)
3185 (match_operand:SVE_FULL_SDF 3 "register_operand" "0")]
3186 UNSPEC_SEL))]
3187 "TARGET_SVE2"
3188 "<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Ventype>"
3189 "&& !rtx_equal_p (operands[1], operands[4])"
3190 {
3191 operands[4] = copy_rtx (operands[1]);
3192 }
3193 )
3194
3195 (define_insn "*cond_<sve_fp_op><mode>_strict"
3196 [(set (match_operand:SVE_FULL_SDF 0 "register_operand" "=w")
3197 (unspec:SVE_FULL_SDF
3198 [(match_operand:<VPRED> 1 "register_operand" "Upl")
3199 (unspec:SVE_FULL_SDF
3200 [(match_dup 1)
3201 (const_int SVE_STRICT_GP)
3202 (match_operand:<VNARROW> 2 "register_operand" "w")]
3203 SVE2_COND_FP_UNARY_LONG)
3204 (match_operand:SVE_FULL_SDF 3 "register_operand" "0")]
3205 UNSPEC_SEL))]
3206 "TARGET_SVE2"
3207 "<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Ventype>"
3208 )
3209
3210 (define_insn "@aarch64_sve2_fp8_cvt_<fp8_cvt_uns_op><mode>"
3211 [(set (match_operand:SVE_FULL_HF 0 "register_operand" "=w")
3212 (unspec:SVE_FULL_HF
3213 [(match_operand:VNx16QI 1 "register_operand" "w")
3214 (reg:DI FPM_REGNUM)]
3215 FP8CVT_UNS))]
3216 "TARGET_SSVE_FP8"
3217 "<b><fp8_cvt_uns_op>\t%0.h, %1.b"
3218 )
3219
3220 ;; -------------------------------------------------------------------------
3221 ;; ---- [FP<-FP] Narrowing conversions
3222 ;; -------------------------------------------------------------------------
3223 ;; Includes:
3224 ;; - FCVTNT
3225 ;; - FCVTX
3226 ;; - FCVTXNT
3227 ;; -------------------------------------------------------------------------
3228
3229 ;; Predicated FCVTNT. This doesn't give a natural aarch64_pred_*/cond_*
3230 ;; pair because the even elements always have to be supplied for active
3231 ;; elements, even if the inactive elements don't matter.
3232 ;;
3233 ;; These instructions do not take MOVPRFX.
3234 (define_insn "@aarch64_sve_cvtnt<mode>"
3235 [(set (match_operand:SVE_FULL_HSF 0 "register_operand" "=w")
3236 (unspec:SVE_FULL_HSF
3237 [(match_operand:<VWIDE_PRED> 2 "register_operand" "Upl")
3238 (const_int SVE_STRICT_GP)
3239 (match_operand:SVE_FULL_HSF 1 "register_operand" "0")
3240 (match_operand:<VWIDE> 3 "register_operand" "w")]
3241 UNSPEC_COND_FCVTNT))]
3242 "TARGET_SVE2"
3243 "fcvtnt\t%0.<Vetype>, %2/m, %3.<Vewtype>"
3244 )
3245
3246 ;; Predicated FCVTX (equivalent to what would be FCVTXNB, except that
3247 ;; it supports MOVPRFX).
3248 (define_insn "@aarch64_pred_<sve_fp_op><mode>"
3249 [(set (match_operand:VNx4SF_ONLY 0 "register_operand")
3250 (unspec:VNx4SF_ONLY
3251 [(match_operand:<VWIDE_PRED> 1 "register_operand")
3252 (match_operand:SI 3 "aarch64_sve_gp_strictness")
3253 (match_operand:<VWIDE> 2 "register_operand")]
3254 SVE2_COND_FP_UNARY_NARROWB))]
3255 "TARGET_SVE2"
3256 {@ [ cons: =0 , 1 , 2 ; attrs: movprfx ]
3257 [ w , Upl , 0 ; * ] <sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vewtype>
3258 [ ?&w , Upl , w ; yes ] movprfx\t%0, %2\;<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vewtype>
3259 }
3260 )
3261
3262 ;; Predicated FCVTX with merging.
3263 (define_expand "@cond_<sve_fp_op><mode>"
3264 [(set (match_operand:VNx4SF_ONLY 0 "register_operand")
3265 (unspec:VNx4SF_ONLY
3266 [(match_operand:<VWIDE_PRED> 1 "register_operand")
3267 (unspec:VNx4SF_ONLY
3268 [(match_dup 1)
3269 (const_int SVE_STRICT_GP)
3270 (match_operand:<VWIDE> 2 "register_operand")]
3271 SVE2_COND_FP_UNARY_NARROWB)
3272 (match_operand:VNx4SF_ONLY 3 "aarch64_simd_reg_or_zero")]
3273 UNSPEC_SEL))]
3274 "TARGET_SVE2"
3275 )
3276
3277 (define_insn_and_rewrite "*cond_<sve_fp_op><mode>_any_relaxed"
3278 [(set (match_operand:VNx4SF_ONLY 0 "register_operand")
3279 (unspec:VNx4SF_ONLY
3280 [(match_operand:<VWIDE_PRED> 1 "register_operand")
3281 (unspec:VNx4SF_ONLY
3282 [(match_operand 4)
3283 (const_int SVE_RELAXED_GP)
3284 (match_operand:<VWIDE> 2 "register_operand")]
3285 SVE2_COND_FP_UNARY_NARROWB)
3286 (match_operand:VNx4SF_ONLY 3 "aarch64_simd_reg_or_zero")]
3287 UNSPEC_SEL))]
3288 "TARGET_SVE2 && !rtx_equal_p (operands[2], operands[3])"
3289 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
3290 [ &w , Upl , w , 0 ; * ] <sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vewtype>
3291 [ &w , Upl , w , Dz ; yes ] movprfx\t%0.<Vewtype>, %1/z, %2.<Vewtype>\;<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vewtype>
3292 [ &w , Upl , w , w ; yes ] movprfx\t%0, %3\;<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vewtype>
3293 }
3294 "&& !rtx_equal_p (operands[1], operands[4])"
3295 {
3296 operands[4] = copy_rtx (operands[1]);
3297 }
3298 )
3299
3300 (define_insn "*cond_<sve_fp_op><mode>_any_strict"
3301 [(set (match_operand:VNx4SF_ONLY 0 "register_operand")
3302 (unspec:VNx4SF_ONLY
3303 [(match_operand:<VWIDE_PRED> 1 "register_operand")
3304 (unspec:VNx4SF_ONLY
3305 [(match_dup 1)
3306 (const_int SVE_STRICT_GP)
3307 (match_operand:<VWIDE> 2 "register_operand")]
3308 SVE2_COND_FP_UNARY_NARROWB)
3309 (match_operand:VNx4SF_ONLY 3 "aarch64_simd_reg_or_zero")]
3310 UNSPEC_SEL))]
3311 "TARGET_SVE2 && !rtx_equal_p (operands[2], operands[3])"
3312 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
3313 [ &w , Upl , w , 0 ; * ] <sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vewtype>
3314 [ &w , Upl , w , Dz ; yes ] movprfx\t%0.<Vewtype>, %1/z, %2.<Vewtype>\;<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vewtype>
3315 [ &w , Upl , w , w ; yes ] movprfx\t%0, %3\;<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vewtype>
3316 }
3317 )
3318
3319 ;; Predicated FCVTXNT. This doesn't give a natural aarch64_pred_*/cond_*
3320 ;; pair because the even elements always have to be supplied for active
3321 ;; elements, even if the inactive elements don't matter.
3322 ;;
3323 ;; These instructions do not take MOVPRFX.
3324 (define_insn "@aarch64_sve2_cvtxnt<mode>"
3325 [(set (match_operand:<VNARROW> 0 "register_operand" "=w")
3326 (unspec:<VNARROW>
3327 [(match_operand:<VPRED> 2 "register_operand" "Upl")
3328 (const_int SVE_STRICT_GP)
3329 (match_operand:<VNARROW> 1 "register_operand" "0")
3330 (match_operand:VNx2DF_ONLY 3 "register_operand" "w")]
3331 UNSPEC_COND_FCVTXNT))]
3332 "TARGET_SVE2"
3333 "fcvtxnt\t%0.<Ventype>, %2/m, %3.<Vetype>"
3334 )
3335
3336 ;; -------------------------------------------------------------------------
3337 ;; ---- [FP<-FP] Multi-vector widening conversions
3338 ;; -------------------------------------------------------------------------
3339 ;; Includes the multi-register forms of:
3340 ;; - FCVT (SME_F16F16)
3341 ;; - FCVTL (SME_F16F16)
3342 ;; -------------------------------------------------------------------------
3343
3344 (define_insn "extendvnx8hfvnx8sf2"
3345 [(set (match_operand:VNx8SF 0 "aligned_register_operand" "=Uw2")
3346 (float_extend:VNx8SF
3347 (match_operand:VNx8HF 1 "register_operand" "w")))]
3348 "TARGET_STREAMING_SME_F16F16"
3349 "fcvt\t%0, %1.h"
3350 )
3351
3352 (define_insn "@aarch64_sve_cvtl<mode>"
3353 [(set (match_operand:VNx8SF_ONLY 0 "aligned_register_operand" "=Uw2")
3354 (unspec:VNx8SF_ONLY
3355 [(match_operand:VNx8HF 1 "register_operand" "w")]
3356 UNSPEC_FCVTL))]
3357 "TARGET_STREAMING_SME_F16F16"
3358 "fcvtl\t%0, %1.h"
3359 )
3360
3361 ;; -------------------------------------------------------------------------
3362 ;; ---- [FP<-FP] Multi-vector narrowing conversions
3363 ;; -------------------------------------------------------------------------
3364 ;; Includes the multi-register forms of:
3365 ;; - BFCVT (SME2)
3366 ;; - BFCVTN (SME2)
3367 ;; - FCVT (SME2)
3368 ;; - FCVTN (SME2)
3369 ;; - FCVTNB (FP8)
3370 ;; - FCVTNT (FP8)
3371 ;; -------------------------------------------------------------------------
3372
3373 (define_insn "truncvnx8sf<mode>2"
3374 [(set (match_operand:SVE_FULL_HF 0 "register_operand" "=w")
3375 (float_truncate:SVE_FULL_HF
3376 (match_operand:VNx8SF 1 "aligned_register_operand" "Uw2")))]
3377 "TARGET_STREAMING_SME2"
3378 "<b>fcvt\t%0.h, %1"
3379 )
3380
3381 (define_insn "@aarch64_sve_cvtn<mode>"
3382 [(set (match_operand:SVE_FULL_HF 0 "register_operand" "=w")
3383 (unspec:SVE_FULL_HF
3384 [(match_operand:VNx8SF 1 "aligned_register_operand" "Uw2")]
3385 UNSPEC_FCVTN))]
3386 "TARGET_STREAMING_SME2"
3387 "<b>fcvtn\t%0.h, %1"
3388 )
3389
3390 (define_insn "@aarch64_sve2_fp8_cvtn<mode>"
3391 [(set (match_operand:VNx16QI 0 "register_operand" "=w")
3392 (unspec:VNx16QI
3393 [(match_operand:SVE_FULL_HFx2 1 "aligned_register_operand" "Uw2")
3394 (reg:DI FPM_REGNUM)]
3395 UNSPEC_FP8FCVTN))]
3396 "TARGET_SSVE_FP8"
3397 "<b>fcvtn\t%0.b, %1"
3398 )
3399
3400 (define_insn "@aarch64_sve2_fp8_cvtnb<mode>"
3401 [(set (match_operand:VNx16QI_ONLY 0 "register_operand" "=w")
3402 (unspec:VNx16QI_ONLY
3403 [(match_operand:VNx8SF 1 "aligned_register_operand" "Uw2")
3404 (reg:DI FPM_REGNUM)]
3405 UNSPEC_FCVTNB))]
3406 "TARGET_SSVE_FP8"
3407 "fcvtnb\t%0.b, %1"
3408 )
3409
3410 (define_insn "@aarch64_sve_cvtnt<mode>"
3411 [(set (match_operand:VNx16QI_ONLY 0 "register_operand" "=w")
3412 (unspec:VNx16QI_ONLY
3413 [(match_operand:VNx16QI_ONLY 1 "register_operand" "0")
3414 (match_operand:VNx8SF 2 "aligned_register_operand" "Uw2")
3415 (reg:DI FPM_REGNUM)]
3416 UNSPEC_FCVTNT))]
3417 "TARGET_SSVE_FP8"
3418 "fcvtnt\t%0.b, %2"
3419 )
3420
3421 ;; -------------------------------------------------------------------------
3422 ;; ---- [FP<-INT] Multi-vector conversions
3423 ;; -------------------------------------------------------------------------
3424 ;; Includes the multi-register forms of:
3425 ;; - SCVTF (SME2)
3426 ;; - UCVTF (SME2)
3427 ;; -------------------------------------------------------------------------
3428
3429 (define_insn "<optab><v_int_equiv><mode>2"
3430 [(set (match_operand:SVE_SFx24 0 "aligned_register_operand" "=Uw<vector_count>")
3431 (FLOATUORS:SVE_SFx24
3432 (match_operand:<V_INT_EQUIV> 1 "aligned_register_operand" "Uw<vector_count>")))]
3433 "TARGET_STREAMING_SME2"
3434 "<su_optab>cvtf\t%0, %1"
3435 )
3436
3437 ;; -------------------------------------------------------------------------
3438 ;; ---- [INT<-FP] Multi-vector conversions
3439 ;; -------------------------------------------------------------------------
3440 ;; Includes the multi-register forms of:
3441 ;; - FCVTZS (SME2)
3442 ;; - FCVTZU (SME2)
3443 ;; -------------------------------------------------------------------------
3444
3445 (define_insn "<optab><mode><v_int_equiv>2"
3446 [(set (match_operand:<V_INT_EQUIV> 0 "aligned_register_operand" "=Uw<vector_count>")
3447 (FIXUORS:<V_INT_EQUIV>
3448 (match_operand:SVE_SFx24 1 "aligned_register_operand" "Uw<vector_count>")))]
3449 "TARGET_STREAMING_SME2"
3450 "fcvtz<su>\t%0, %1"
3451 )
3452
3453 ;; =========================================================================
3454 ;; == Other arithmetic
3455 ;; =========================================================================
3456
3457 ;; -------------------------------------------------------------------------
3458 ;; ---- [INT] Reciprocal approximation
3459 ;; -------------------------------------------------------------------------
3460 ;; Includes:
3461 ;; - URECPE
3462 ;; - URSQRTE
3463 ;; -------------------------------------------------------------------------
3464
3465 ;; Predicated integer unary operations.
3466 (define_insn "@aarch64_pred_<sve_int_op><mode>"
3467 [(set (match_operand:VNx4SI_ONLY 0 "register_operand")
3468 (unspec:VNx4SI_ONLY
3469 [(match_operand:<VPRED> 1 "register_operand")
3470 (unspec:VNx4SI_ONLY
3471 [(match_operand:VNx4SI_ONLY 2 "register_operand")]
3472 SVE2_U32_UNARY)]
3473 UNSPEC_PRED_X))]
3474 "TARGET_SVE2"
3475 {@ [ cons: =0 , 1 , 2 ; attrs: movprfx ]
3476 [ w , Upl , 0 ; * ] <sve_int_op>\t%0.<Vetype>, %1/m, %2.<Vetype>
3477 [ ?&w , Upl , w ; yes ] movprfx\t%0, %2\;<sve_int_op>\t%0.<Vetype>, %1/m, %2.<Vetype>
3478 }
3479 )
3480
3481 ;; Predicated integer unary operations with merging.
3482 (define_expand "@cond_<sve_int_op><mode>"
3483 [(set (match_operand:VNx4SI_ONLY 0 "register_operand")
3484 (unspec:VNx4SI_ONLY
3485 [(match_operand:<VPRED> 1 "register_operand")
3486 (unspec:VNx4SI_ONLY
3487 [(match_dup 4)
3488 (unspec:VNx4SI_ONLY
3489 [(match_operand:VNx4SI_ONLY 2 "register_operand")]
3490 SVE2_U32_UNARY)]
3491 UNSPEC_PRED_X)
3492 (match_operand:VNx4SI_ONLY 3 "aarch64_simd_reg_or_zero")]
3493 UNSPEC_SEL))]
3494 "TARGET_SVE2"
3495 {
3496 operands[4] = CONSTM1_RTX (<MODE>mode);
3497 }
3498 )
3499
3500 (define_insn_and_rewrite "*cond_<sve_int_op><mode>"
3501 [(set (match_operand:VNx4SI_ONLY 0 "register_operand")
3502 (unspec:VNx4SI_ONLY
3503 [(match_operand:<VPRED> 1 "register_operand")
3504 (unspec:VNx4SI_ONLY
3505 [(match_operand 4)
3506 (unspec:VNx4SI_ONLY
3507 [(match_operand:VNx4SI_ONLY 2 "register_operand")]
3508 SVE2_U32_UNARY)]
3509 UNSPEC_PRED_X)
3510 (match_operand:VNx4SI_ONLY 3 "aarch64_simd_reg_or_zero")]
3511 UNSPEC_SEL))]
3512 "TARGET_SVE2"
3513 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
3514 [ w , Upl , w , 0 ; * ] <sve_int_op>\t%0.<Vetype>, %1/m, %2.<Vetype>
3515 [ ?&w , Upl , w , Dz ; yes ] movprfx\t%0.<Vetype>, %1/z, %2.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %2.<Vetype>
3516 [ ?&w , Upl , w , w ; yes ] movprfx\t%0, %3\;<sve_int_op>\t%0.<Vetype>, %1/m, %2.<Vetype>
3517 }
3518 "&& !CONSTANT_P (operands[4])"
3519 {
3520 operands[4] = CONSTM1_RTX (<VPRED>mode);
3521 }
3522 )
3523
3524 ;; -------------------------------------------------------------------------
3525 ;; ---- [INT<-FP] Base-2 logarithm
3526 ;; -------------------------------------------------------------------------
3527 ;; Includes:
3528 ;; - FLOGB
3529 ;; -------------------------------------------------------------------------
3530
3531 ;; Predicated FLOGB.
3532 (define_insn "@aarch64_pred_<sve_fp_op><mode>"
3533 [(set (match_operand:<V_INT_EQUIV> 0 "register_operand")
3534 (unspec:<V_INT_EQUIV>
3535 [(match_operand:<VPRED> 1 "register_operand")
3536 (match_operand:SI 3 "aarch64_sve_gp_strictness")
3537 (match_operand:SVE_FULL_F 2 "register_operand")]
3538 SVE2_COND_INT_UNARY_FP))]
3539 "TARGET_SVE2"
3540 {@ [ cons: =0 , 1 , 2 ; attrs: movprfx ]
3541 [ w , Upl , 0 ; * ] <sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vetype>
3542 [ ?&w , Upl , w ; yes ] movprfx\t%0, %2\;<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vetype>
3543 }
3544 )
3545
3546 ;; Predicated FLOGB with merging.
3547 (define_expand "@cond_<sve_fp_op><mode>"
3548 [(set (match_operand:<V_INT_EQUIV> 0 "register_operand")
3549 (unspec:<V_INT_EQUIV>
3550 [(match_operand:<VPRED> 1 "register_operand")
3551 (unspec:<V_INT_EQUIV>
3552 [(match_dup 1)
3553 (const_int SVE_STRICT_GP)
3554 (match_operand:SVE_FULL_F 2 "register_operand")]
3555 SVE2_COND_INT_UNARY_FP)
3556 (match_operand:<V_INT_EQUIV> 3 "aarch64_simd_reg_or_zero")]
3557 UNSPEC_SEL))]
3558 "TARGET_SVE2"
3559 )
3560
3561 (define_insn_and_rewrite "*cond_<sve_fp_op><mode>"
3562 [(set (match_operand:<V_INT_EQUIV> 0 "register_operand")
3563 (unspec:<V_INT_EQUIV>
3564 [(match_operand:<VPRED> 1 "register_operand")
3565 (unspec:<V_INT_EQUIV>
3566 [(match_operand 4)
3567 (const_int SVE_RELAXED_GP)
3568 (match_operand:SVE_FULL_F 2 "register_operand")]
3569 SVE2_COND_INT_UNARY_FP)
3570 (match_operand:<V_INT_EQUIV> 3 "aarch64_simd_reg_or_zero")]
3571 UNSPEC_SEL))]
3572 "TARGET_SVE2 && !rtx_equal_p (operands[2], operands[3])"
3573 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
3574 [ &w , Upl , w , 0 ; * ] <sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vetype>
3575 [ ?&w , Upl , w , Dz ; yes ] movprfx\t%0.<Vetype>, %1/z, %2.<Vetype>\;<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vetype>
3576 [ ?&w , Upl , w , w ; yes ] movprfx\t%0, %3\;<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vetype>
3577 }
3578 "&& !rtx_equal_p (operands[1], operands[4])"
3579 {
3580 operands[4] = copy_rtx (operands[1]);
3581 }
3582 )
3583
3584 (define_insn "*cond_<sve_fp_op><mode>_strict"
3585 [(set (match_operand:<V_INT_EQUIV> 0 "register_operand")
3586 (unspec:<V_INT_EQUIV>
3587 [(match_operand:<VPRED> 1 "register_operand")
3588 (unspec:<V_INT_EQUIV>
3589 [(match_dup 1)
3590 (const_int SVE_STRICT_GP)
3591 (match_operand:SVE_FULL_F 2 "register_operand")]
3592 SVE2_COND_INT_UNARY_FP)
3593 (match_operand:<V_INT_EQUIV> 3 "aarch64_simd_reg_or_zero")]
3594 UNSPEC_SEL))]
3595 "TARGET_SVE2 && !rtx_equal_p (operands[2], operands[3])"
3596 {@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
3597 [ &w , Upl , w , 0 ; * ] <sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vetype>
3598 [ ?&w , Upl , w , Dz ; yes ] movprfx\t%0.<Vetype>, %1/z, %2.<Vetype>\;<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vetype>
3599 [ ?&w , Upl , w , w ; yes ] movprfx\t%0, %3\;<sve_fp_op>\t%0.<Vetype>, %1/m, %2.<Vetype>
3600 }
3601 )
3602
3603 ;; -------------------------------------------------------------------------
3604 ;; ---- [INT] Polynomial multiplication
3605 ;; -------------------------------------------------------------------------
3606 ;; Includes:
3607 ;; - PMUL
3608 ;; - PMULLB
3609 ;; - PMULLT
3610 ;; -------------------------------------------------------------------------
3611
3612 ;; Uniform PMUL.
3613 (define_insn "@aarch64_sve2_pmul<mode>"
3614 [(set (match_operand:VNx16QI_ONLY 0 "register_operand" "=w")
3615 (unspec:VNx16QI_ONLY
3616 [(match_operand:VNx16QI_ONLY 1 "register_operand" "w")
3617 (match_operand:VNx16QI_ONLY 2 "register_operand" "w")]
3618 UNSPEC_PMUL))]
3619 "TARGET_SVE2"
3620 "pmul\t%0.<Vetype>, %1.<Vetype>, %2.<Vetype>"
3621 )
3622
3623 ;; Extending PMUL, with the results modeled as wider vectors.
3624 ;; This representation is only possible for .H and .D, not .Q.
3625 (define_insn "@aarch64_sve_<optab><mode>"
3626 [(set (match_operand:SVE_FULL_HDI 0 "register_operand" "=w")
3627 (unspec:SVE_FULL_HDI
3628 [(match_operand:<VNARROW> 1 "register_operand" "w")
3629 (match_operand:<VNARROW> 2 "register_operand" "w")]
3630 SVE2_PMULL))]
3631 "TARGET_SVE2"
3632 "<sve_int_op>\t%0.<Vetype>, %1.<Ventype>, %2.<Ventype>"
3633 )
3634
3635 ;; Extending PMUL, with the results modeled as pairs of values.
3636 ;; This representation works for .H, .D and .Q, with .Q requiring
3637 ;; the AES extension. (This is enforced by the mode iterator.)
3638 (define_insn "@aarch64_sve_<optab><mode>"
3639 [(set (match_operand:SVE2_PMULL_PAIR_I 0 "register_operand" "=w")
3640 (unspec:SVE2_PMULL_PAIR_I
3641 [(match_operand:SVE2_PMULL_PAIR_I 1 "register_operand" "w")
3642 (match_operand:SVE2_PMULL_PAIR_I 2 "register_operand" "w")]
3643 SVE2_PMULL_PAIR))]
3644 "TARGET_SVE2"
3645 "<sve_int_op>\t%0.<Vewtype>, %1.<Vetype>, %2.<Vetype>"
3646 )
3647
3648 ;; =========================================================================
3649 ;; == Comparisons and selects
3650 ;; =========================================================================
3651
3652 ;; -------------------------------------------------------------------------
3653 ;; ---- [INT,FP] Select based on predicates as counters
3654 ;; -------------------------------------------------------------------------
3655
3656 (define_insn "@aarch64_sve_sel<mode>"
3657 [(set (match_operand:SVE_FULLx24 0 "register_operand" "=Uw<vector_count>")
3658 (unspec:SVE_FULLx24
3659 [(match_operand:<VPRED> 3 "register_operand" "Uph")
3660 (match_operand:SVE_FULLx24 1 "aligned_register_operand" "Uw<vector_count>")
3661 (match_operand:SVE_FULLx24 2 "aligned_register_operand" "Uw<vector_count>")]
3662 UNSPEC_SEL))]
3663 "TARGET_STREAMING_SME2"
3664 "sel\t%0, %K3, %1, %2"
3665 )
3666
3667 ;; -------------------------------------------------------------------------
3668 ;; ---- [INT] While tests
3669 ;; -------------------------------------------------------------------------
3670 ;; Includes the x2 and count versions of:
3671 ;; - WHILEGE
3672 ;; - WHILEGT
3673 ;; - WHILEHI
3674 ;; - WHILEHS
3675 ;; - WHILELE
3676 ;; - WHILELO
3677 ;; - WHILELS
3678 ;; - WHILELT
3679 ;; -------------------------------------------------------------------------
3680
3681 (define_insn "@aarch64_sve_while<while_optab_cmp>_b<BHSD_BITS>_x2"
3682 [(set (match_operand:VNx32BI 0 "register_operand" "=Up2")
3683 (unspec:VNx32BI
3684 [(const_int SVE_WHILE_B_X2)
3685 (match_operand:DI 1 "aarch64_reg_or_zero" "rZ")
3686 (match_operand:DI 2 "aarch64_reg_or_zero" "rZ")
3687 (const_int BHSD_BITS)]
3688 SVE_WHILE_ORDER))
3689 (clobber (reg:CC_NZC CC_REGNUM))]
3690 "TARGET_SVE2p1_OR_SME2"
3691 "while<cmp_op>\t{%S0.<bits_etype>, %T0.<bits_etype>}, %x1, %x2"
3692 )
3693
3694 (define_insn "@aarch64_sve_while<while_optab_cmp>_c<BHSD_BITS>"
3695 [(set (match_operand:VNx16BI 0 "register_operand" "=Uph")
3696 (unspec:VNx16BI
3697 [(const_int SVE_WHILE_C)
3698 (match_operand:DI 1 "aarch64_reg_or_zero" "rZ")
3699 (match_operand:DI 2 "aarch64_reg_or_zero" "rZ")
3700 (const_int BHSD_BITS)
3701 (match_operand:DI 3 "const_int_operand")]
3702 SVE_WHILE_ORDER))
3703 (clobber (reg:CC_NZC CC_REGNUM))]
3704 "TARGET_SVE2p1_OR_SME2"
3705 "while<cmp_op>\t%K0.<bits_etype>, %x1, %x2, vlx%3"
3706 )
3707
3708 ;; =========================================================================
3709 ;; == Reductions
3710 ;; =========================================================================
3711
3712 ;; -------------------------------------------------------------------------
3713 ;; ---- [INT] Reduction to 128-bit vector
3714 ;; -------------------------------------------------------------------------
3715 ;; Includes:
3716 ;; - ADDQV (SVE2p1)
3717 ;; - ANDQV (SVE2p1)
3718 ;; - EORQV (SVE2p1)
3719 ;; - ORQV (SVE2p1)
3720 ;; - SMAXQV (SVE2p1)
3721 ;; - SMINQV (SVE2p1)
3722 ;; - UMAXQV (SVE2p1)
3723 ;; - UMINQV (SVE2p1)
3724 ;; -------------------------------------------------------------------------
3725
3726 (define_insn "@aarch64_pred_reduc_<optab>_<mode>"
3727 [(set (match_operand:<V128> 0 "register_operand" "=w")
3728 (unspec:<V128>
3729 [(match_operand:<VPRED> 1 "register_operand" "Upl")
3730 (match_operand:SVE_FULL_I 2 "register_operand" "w")]
3731 SVE_INT_REDUCTION_128))]
3732 "TARGET_SVE2p1 && TARGET_NON_STREAMING"
3733 "<optab>\t%0.<Vtype>, %1, %2.<Vetype>"
3734 )
3735
3736 ;; -------------------------------------------------------------------------
3737 ;; ---- [FP] Reduction to 128-bit vector
3738 ;; -------------------------------------------------------------------------
3739 ;; Includes:
3740 ;; - FADDQV (SVE2p1)
3741 ;; - FMAXNMQV (SVE2p1)
3742 ;; - FMAXQV (SVE2p1)
3743 ;; - FMINNMQV (SVE2p1)
3744 ;; - FMINQV (SVE2p1)
3745 ;; -------------------------------------------------------------------------
3746
3747 (define_insn "@aarch64_pred_reduc_<optab>_<mode>"
3748 [(set (match_operand:<V128> 0 "register_operand" "=w")
3749 (unspec:<V128>
3750 [(match_operand:<VPRED> 1 "register_operand" "Upl")
3751 (match_operand:SVE_FULL_F 2 "register_operand" "w")]
3752 SVE_FP_REDUCTION_128))]
3753 "TARGET_SVE2p1 && TARGET_NON_STREAMING"
3754 "<optab>\t%0.<Vtype>, %1, %2.<Vetype>"
3755 )
3756
3757 ;; =========================================================================
3758 ;; == Permutation
3759 ;; =========================================================================
3760
3761 ;; -------------------------------------------------------------------------
3762 ;; ---- [INT,FP] Reversal
3763 ;; -------------------------------------------------------------------------
3764 ;; Includes:
3765 ;; - REVD
3766 ;; -------------------------------------------------------------------------
3767
3768 (define_insn "@aarch64_pred_<optab><mode>"
3769 [(set (match_operand:SVE_FULL 0 "register_operand")
3770 (unspec:SVE_FULL
3771 [(match_operand:VNx2BI 1 "register_operand")
3772 (unspec:SVE_FULL
3773 [(match_operand:SVE_FULL 2 "register_operand")]
3774 UNSPEC_REVD_ONLY)]
3775 UNSPEC_PRED_X))]
3776 "TARGET_SVE2p1_OR_SME"
3777 {@ [ cons: =0 , 1 , 2 ]
3778 [ w , Upl , 0 ] revd\t%0.q, %1/m, %2.q
3779 }
3780 )
3781
3782 (define_insn "@cond_<optab><mode>"
3783 [(set (match_operand:SVE_FULL 0 "register_operand")
3784 (unspec:SVE_FULL
3785 [(match_operand:VNx2BI 1 "register_operand")
3786 (unspec:SVE_FULL
3787 [(match_operand:SVE_FULL 2 "register_operand")]
3788 UNSPEC_REVD_ONLY)
3789 (match_operand:SVE_FULL 3 "register_operand")]
3790 UNSPEC_SEL))]
3791 "TARGET_SVE2p1_OR_SME"
3792 {@ [ cons: =0 , 1 , 2 , 3 ]
3793 [ w , Upl , w , 0 ] revd\t%0.q, %1/m, %2.q
3794 }
3795 )
3796
3797 ;; -------------------------------------------------------------------------
3798 ;; ---- [INT,FP] HVLA permutes
3799 ;; -------------------------------------------------------------------------
3800 ;; Includes:
3801 ;; - DUPQ (SVE2p1)
3802 ;; - EXTQ (SVE2p1)
3803 ;; -------------------------------------------------------------------------
3804
3805 (define_insn "@aarch64_sve_dupq<mode>"
3806 [(set (match_operand:SVE_FULL 0 "register_operand" "=w")
3807 (unspec:SVE_FULL
3808 [(match_operand:SVE_FULL 1 "register_operand" "w")
3809 (match_operand:SI 2 "const_int_operand")]
3810 UNSPEC_DUPQ))]
3811 "TARGET_SVE2p1
3812 && TARGET_NON_STREAMING
3813 && IN_RANGE (INTVAL (operands[2]) * (<elem_bits> / 8), 0, 15)"
3814 "dupq\t%0.<Vetype>, %1.<Vetype>[%2]"
3815 )
3816
3817 (define_insn "@aarch64_sve_extq<mode>"
3818 [(set (match_operand:SVE_FULL 0 "register_operand" "=w, ?&w")
3819 (unspec:SVE_FULL
3820 [(match_operand:SVE_FULL 1 "register_operand" "0, w")
3821 (match_operand:SVE_FULL 2 "register_operand" "w, w")
3822 (match_operand:SI 3 "const_int_operand")]
3823 UNSPEC_EXTQ))]
3824 "TARGET_SVE2p1
3825 && TARGET_NON_STREAMING
3826 && IN_RANGE (INTVAL (operands[3]) * (<elem_bits> / 8), 0, 15)"
3827 {
3828 operands[3] = GEN_INT (INTVAL (operands[3]) * (<elem_bits> / 8));
3829 return (which_alternative == 0
3830 ? "extq\\t%0.b, %0.b, %2.b, #%3"
3831 : "movprfx\t%0, %1\;extq\\t%0.b, %0.b, %2.b, #%3");
3832 }
3833 [(set_attr "movprfx" "*,yes")]
3834 )
3835
3836 ;; -------------------------------------------------------------------------
3837 ;; ---- [INT,FP] General permutes
3838 ;; -------------------------------------------------------------------------
3839 ;; Includes:
3840 ;; - TBL (vector pair form)
3841 ;; - TBX
3842 ;; - TBXQ (SVE2p1)
3843 ;; -------------------------------------------------------------------------
3844
3845 ;; TBL on a pair of data vectors.
3846 (define_insn "@aarch64_sve2_tbl2<mode>"
3847 [(set (match_operand:SVE_FULL 0 "register_operand" "=w")
3848 (unspec:SVE_FULL
3849 [(match_operand:<VDOUBLE> 1 "register_operand" "w")
3850 (match_operand:<V_INT_EQUIV> 2 "register_operand" "w")]
3851 UNSPEC_TBL2))]
3852 "TARGET_SVE2"
3853 "tbl\t%0.<Vetype>, %1, %2.<Vetype>"
3854 )
3855
3856 ;; TBX(Q). These instructions do not take MOVPRFX.
3857 (define_insn "@aarch64_sve_<perm_insn><mode>"
3858 [(set (match_operand:SVE_FULL 0 "register_operand" "=w")
3859 (unspec:SVE_FULL
3860 [(match_operand:SVE_FULL 1 "register_operand" "0")
3861 (match_operand:SVE_FULL 2 "register_operand" "w")
3862 (match_operand:<V_INT_EQUIV> 3 "register_operand" "w")]
3863 SVE_TBX))]
3864 "TARGET_SVE2"
3865 "<perm_insn>\t%0.<Vetype>, %2.<Vetype>, %3.<Vetype>"
3866 )
3867
3868 ;; -------------------------------------------------------------------------
3869 ;; ---- [INT,FP] Multi-register permutes
3870 ;; -------------------------------------------------------------------------
3871 ;; Includes:
3872 ;; - ZIP
3873 ;; - UZP
3874 ;; -------------------------------------------------------------------------
3875
3876 (define_insn "@aarch64_sve_<optab><mode>"
3877 [(set (match_operand:SVE_FULLx2 0 "aligned_register_operand" "=Uw2")
3878 (unspec:SVE_FULLx2
3879 [(match_operand:<VSINGLE> 1 "register_operand" "w")
3880 (match_operand:<VSINGLE> 2 "register_operand" "w")]
3881 SVE2_x24_PERMUTE))]
3882 "TARGET_STREAMING_SME2"
3883 "<perm_insn>\t%0, %1.<Vetype>, %2.<Vetype>"
3884 )
3885
3886 (define_insn "@aarch64_sve_<optab><mode>"
3887 [(set (match_operand:SVE_FULLx2 0 "aligned_register_operand" "=Uw2")
3888 (unspec:SVE_FULLx2
3889 [(match_operand:<VSINGLE> 1 "register_operand" "w")
3890 (match_operand:<VSINGLE> 2 "register_operand" "w")]
3891 SVE2_x24_PERMUTEQ))]
3892 "TARGET_STREAMING_SME2"
3893 "<perm_insn>\t{%S0.q - %T0.q}, %1.q, %2.q"
3894 )
3895
3896 (define_insn "@aarch64_sve_<optab><mode>"
3897 [(set (match_operand:SVE_FULLx4 0 "aligned_register_operand" "=Uw4")
3898 (unspec:SVE_FULLx4
3899 [(match_operand:SVE_FULLx4 1 "aligned_register_operand" "Uw4")]
3900 SVE2_x24_PERMUTE))]
3901 "TARGET_STREAMING_SME2"
3902 "<perm_insn>\t%0, %1"
3903 )
3904
3905 (define_insn "@aarch64_sve_<optab><mode>"
3906 [(set (match_operand:SVE_FULLx4 0 "aligned_register_operand" "=Uw4")
3907 (unspec:SVE_FULLx4
3908 [(match_operand:SVE_FULLx4 1 "aligned_register_operand" "Uw4")]
3909 SVE2_x24_PERMUTEQ))]
3910 "TARGET_STREAMING_SME2"
3911 "<perm_insn>\t{%S0.q - %V0.q}, {%S1.q - %V1.q}"
3912 )
3913
3914 ;; -------------------------------------------------------------------------
3915 ;; ---- [INT] Optional bit-permute extensions
3916 ;; -------------------------------------------------------------------------
3917 ;; Includes:
3918 ;; - BDEP
3919 ;; - BEXT
3920 ;; - BGRP
3921 ;; -------------------------------------------------------------------------
3922
3923 (define_insn "@aarch64_sve_<sve_int_op><mode>"
3924 [(set (match_operand:SVE_FULL_I 0 "register_operand" "=w")
3925 (unspec:SVE_FULL_I
3926 [(match_operand:SVE_FULL_I 1 "register_operand" "w")
3927 (match_operand:SVE_FULL_I 2 "register_operand" "w")]
3928 SVE2_INT_BITPERM))]
3929 "TARGET_SVE2_BITPERM"
3930 "<sve_int_op>\t%0.<Vetype>, %1.<Vetype>, %2.<Vetype>"
3931 )
3932
3933 ;; =========================================================================
3934 ;; == General
3935 ;; =========================================================================
3936
3937 ;; -------------------------------------------------------------------------
3938 ;; ---- Check for aliases between pointers
3939 ;; -------------------------------------------------------------------------
3940 ;; The patterns in this section are synthetic: WHILERW and WHILEWR are
3941 ;; defined in aarch64-sve.md instead.
3942 ;; -------------------------------------------------------------------------
3943
3944 ;; Use WHILERW and WHILEWR to accelerate alias checks. This is only
3945 ;; possible if the accesses we're checking are exactly the same size
3946 ;; as an SVE vector.
3947 (define_expand "check_<raw_war>_ptrs<mode>"
3948 [(match_operand:GPI 0 "register_operand")
3949 (unspec:VNx16BI
3950 [(match_operand:GPI 1 "register_operand")
3951 (match_operand:GPI 2 "register_operand")
3952 (match_operand:GPI 3 "aarch64_bytes_per_sve_vector_operand")
3953 (match_operand:GPI 4 "const_int_operand")]
3954 SVE2_WHILE_PTR)]
3955 "TARGET_SVE2"
3956 {
3957 /* Use the widest predicate mode we can. */
3958 unsigned int align = INTVAL (operands[4]);
3959 if (align > 8)
3960 align = 8;
3961 machine_mode pred_mode = aarch64_sve_pred_mode (align).require ();
3962
3963 /* Emit a WHILERW or WHILEWR, setting the condition codes based on
3964 the result. */
3965 emit_insn (gen_while_ptest
3966 (<SVE2_WHILE_PTR:unspec>, <MODE>mode, pred_mode,
3967 gen_rtx_SCRATCH (pred_mode), operands[1], operands[2],
3968 CONSTM1_RTX (VNx16BImode), CONSTM1_RTX (pred_mode)));
3969
3970 /* Set operand 0 to true if the last bit of the predicate result is set,
3971 i.e. if all elements are free of dependencies. */
3972 rtx cc_reg = gen_rtx_REG (CC_NZCmode, CC_REGNUM);
3973 rtx cmp = gen_rtx_LTU (<MODE>mode, cc_reg, const0_rtx);
3974 emit_insn (gen_aarch64_cstore<mode> (operands[0], cmp, cc_reg));
3975 DONE;
3976 })
3977
3978 ;; -------------------------------------------------------------------------
3979 ;; ---- Histogram processing
3980 ;; -------------------------------------------------------------------------
3981 ;; Includes:
3982 ;; - HISTCNT
3983 ;; - HISTSEG
3984 ;; -------------------------------------------------------------------------
3985
3986 (define_insn "@aarch64_sve2_histcnt<mode>"
3987 [(set (match_operand:SVE_FULL_SDI 0 "register_operand" "=w")
3988 (unspec:SVE_FULL_SDI
3989 [(match_operand:<VPRED> 1 "register_operand" "Upl")
3990 (match_operand:SVE_FULL_SDI 2 "register_operand" "w")
3991 (match_operand:SVE_FULL_SDI 3 "register_operand" "w")]
3992 UNSPEC_HISTCNT))]
3993 "TARGET_SVE2 && TARGET_NON_STREAMING"
3994 "histcnt\t%0.<Vetype>, %1/z, %2.<Vetype>, %3.<Vetype>"
3995 )
3996
3997 (define_insn "@aarch64_sve2_histseg<mode>"
3998 [(set (match_operand:VNx16QI_ONLY 0 "register_operand" "=w")
3999 (unspec:VNx16QI_ONLY
4000 [(match_operand:VNx16QI_ONLY 1 "register_operand" "w")
4001 (match_operand:VNx16QI_ONLY 2 "register_operand" "w")]
4002 UNSPEC_HISTSEG))]
4003 "TARGET_SVE2 && TARGET_NON_STREAMING"
4004 "histseg\t%0.<Vetype>, %1.<Vetype>, %2.<Vetype>"
4005 )
4006
4007 ;; -------------------------------------------------------------------------
4008 ;; ---- String matching
4009 ;; -------------------------------------------------------------------------
4010 ;; Includes:
4011 ;; - MATCH
4012 ;; - NMATCH
4013 ;; -------------------------------------------------------------------------
4014
4015 ;; Predicated string matching.
4016 (define_insn "@aarch64_pred_<sve_int_op><mode>"
4017 [(set (match_operand:<VPRED> 0 "register_operand")
4018 (unspec:<VPRED>
4019 [(match_operand:<VPRED> 1 "register_operand")
4020 (match_operand:SI 2 "aarch64_sve_ptrue_flag")
4021 (unspec:<VPRED>
4022 [(match_operand:SVE_FULL_BHI 3 "register_operand")
4023 (match_operand:SVE_FULL_BHI 4 "register_operand")]
4024 SVE2_MATCH)]
4025 UNSPEC_PRED_Z))
4026 (clobber (reg:CC_NZC CC_REGNUM))]
4027 "TARGET_SVE2 && TARGET_NON_STREAMING"
4028 {@ [ cons: =0, 1 , 3, 4; attrs: pred_clobber ]
4029 [ &Upa , Upl, w, w; yes ] <sve_int_op>\t%0.<Vetype>, %1/z, %3.<Vetype>, %4.<Vetype>
4030 [ ?Upl , 0 , w, w; yes ] ^
4031 [ Upa , Upl, w, w; no ] ^
4032 }
4033 )
4034
4035 ;; Predicated string matching in which both the flag and predicate results
4036 ;; are interesting.
4037 (define_insn_and_rewrite "*aarch64_pred_<sve_int_op><mode>_cc"
4038 [(set (reg:CC_NZC CC_REGNUM)
4039 (unspec:CC_NZC
4040 [(match_operand:VNx16BI 1 "register_operand" "Upl")
4041 (match_operand 4)
4042 (match_operand:SI 5 "aarch64_sve_ptrue_flag")
4043 (unspec:<VPRED>
4044 [(match_operand 6)
4045 (match_operand:SI 7 "aarch64_sve_ptrue_flag")
4046 (unspec:<VPRED>
4047 [(match_operand:SVE_FULL_BHI 2 "register_operand" "w")
4048 (match_operand:SVE_FULL_BHI 3 "register_operand" "w")]
4049 SVE2_MATCH)]
4050 UNSPEC_PRED_Z)]
4051 UNSPEC_PTEST))
4052 (set (match_operand:<VPRED> 0 "register_operand" "=Upa")
4053 (unspec:<VPRED>
4054 [(match_dup 6)
4055 (match_dup 7)
4056 (unspec:<VPRED>
4057 [(match_dup 2)
4058 (match_dup 3)]
4059 SVE2_MATCH)]
4060 UNSPEC_PRED_Z))]
4061 "TARGET_SVE2
4062 && TARGET_NON_STREAMING
4063 && aarch64_sve_same_pred_for_ptest_p (&operands[4], &operands[6])"
4064 "<sve_int_op>\t%0.<Vetype>, %1/z, %2.<Vetype>, %3.<Vetype>"
4065 "&& !rtx_equal_p (operands[4], operands[6])"
4066 {
4067 operands[6] = copy_rtx (operands[4]);
4068 operands[7] = operands[5];
4069 }
4070 )
4071
4072 ;; Predicated string matching in which only the flags result is interesting.
4073 (define_insn_and_rewrite "*aarch64_pred_<sve_int_op><mode>_ptest"
4074 [(set (reg:CC_NZC CC_REGNUM)
4075 (unspec:CC_NZC
4076 [(match_operand:VNx16BI 1 "register_operand" "Upl")
4077 (match_operand 4)
4078 (match_operand:SI 5 "aarch64_sve_ptrue_flag")
4079 (unspec:<VPRED>
4080 [(match_operand 6)
4081 (match_operand:SI 7 "aarch64_sve_ptrue_flag")
4082 (unspec:<VPRED>
4083 [(match_operand:SVE_FULL_BHI 2 "register_operand" "w")
4084 (match_operand:SVE_FULL_BHI 3 "register_operand" "w")]
4085 SVE2_MATCH)]
4086 UNSPEC_PRED_Z)]
4087 UNSPEC_PTEST))
4088 (clobber (match_scratch:<VPRED> 0 "=Upa"))]
4089 "TARGET_SVE2
4090 && TARGET_NON_STREAMING
4091 && aarch64_sve_same_pred_for_ptest_p (&operands[4], &operands[6])"
4092 "<sve_int_op>\t%0.<Vetype>, %1/z, %2.<Vetype>, %3.<Vetype>"
4093 "&& !rtx_equal_p (operands[4], operands[6])"
4094 {
4095 operands[6] = copy_rtx (operands[4]);
4096 operands[7] = operands[5];
4097 }
4098 )
4099
4100 ;; -------------------------------------------------------------------------
4101 ;; ---- Table lookup
4102 ;; -------------------------------------------------------------------------
4103 ;; Includes:
4104 ;; - LUTI2
4105 ;; - LUTI4
4106 ;; -------------------------------------------------------------------------
4107
4108 (define_insn "@aarch64_sve_luti<LUTI_BITS><mode>"
4109 [(set (match_operand:SVE_FULL_BH 0 "register_operand" "=w")
4110 (unspec:SVE_FULL_BH
4111 [(match_operand:SVE_FULL_BH 1 "register_operand" "w")
4112 (match_operand:VNx16QI 2 "register_operand" "w")
4113 (match_operand:DI 3 "const_int_operand")
4114 (const_int LUTI_BITS)]
4115 UNSPEC_SVE_LUTI))]
4116 "TARGET_LUT && TARGET_SVE2_OR_SME2"
4117 "luti<LUTI_BITS>\t%0.<Vetype>, { %1.<Vetype> }, %2[%3]"
4118 )
4119
4120 (define_insn "@aarch64_sve_luti<LUTI_BITS><mode>"
4121 [(set (match_operand:<VSINGLE> 0 "register_operand" "=w")
4122 (unspec:<VSINGLE>
4123 [(match_operand:SVE_FULL_Hx2 1 "register_operand" "w")
4124 (match_operand:VNx16QI 2 "register_operand" "w")
4125 (match_operand:DI 3 "const_int_operand")
4126 (const_int LUTI_BITS)]
4127 UNSPEC_SVE_LUTI))]
4128 "TARGET_LUT && TARGET_SVE2_OR_SME2"
4129 "luti<LUTI_BITS>\t%0.<Vetype>, %1, %2[%3]"
4130 )
4131
4132 ;; =========================================================================
4133 ;; == Cryptographic extensions
4134 ;; =========================================================================
4135
4136 ;; -------------------------------------------------------------------------
4137 ;; ---- Optional AES extensions
4138 ;; -------------------------------------------------------------------------
4139 ;; Includes:
4140 ;; - AESD
4141 ;; - AESE
4142 ;; - AESIMC
4143 ;; - AESMC
4144 ;; -------------------------------------------------------------------------
4145
4146 ;; AESD and AESE.
4147 (define_insn "aarch64_sve2_aes<aes_op>"
4148 [(set (match_operand:VNx16QI 0 "register_operand" "=w")
4149 (unspec:VNx16QI
4150 [(xor:VNx16QI
4151 (match_operand:VNx16QI 1 "register_operand" "%0")
4152 (match_operand:VNx16QI 2 "register_operand" "w"))]
4153 CRYPTO_AES))]
4154 "TARGET_SVE2_AES"
4155 "aes<aes_op>\t%0.b, %0.b, %2.b"
4156 [(set_attr "type" "crypto_aese")]
4157 )
4158
4159 ;; AESMC and AESIMC. These instructions do not take MOVPRFX.
4160 (define_insn "aarch64_sve2_aes<aesmc_op>"
4161 [(set (match_operand:VNx16QI 0 "register_operand" "=w")
4162 (unspec:VNx16QI
4163 [(match_operand:VNx16QI 1 "register_operand" "0")]
4164 CRYPTO_AESMC))]
4165 "TARGET_SVE2_AES"
4166 "aes<aesmc_op>\t%0.b, %0.b"
4167 [(set_attr "type" "crypto_aesmc")]
4168 )
4169
4170 ;; When AESE/AESMC and AESD/AESIMC fusion is enabled, we really want
4171 ;; to keep the two together and enforce the register dependency without
4172 ;; scheduling or register allocation messing up the order or introducing
4173 ;; moves inbetween. Mash the two together during combine.
4174
4175 (define_insn "*aarch64_sve2_aese_fused"
4176 [(set (match_operand:VNx16QI 0 "register_operand" "=w")
4177 (unspec:VNx16QI
4178 [(unspec:VNx16QI
4179 [(xor:VNx16QI
4180 (match_operand:VNx16QI 1 "register_operand" "%0")
4181 (match_operand:VNx16QI 2 "register_operand" "w"))]
4182 UNSPEC_AESE)]
4183 UNSPEC_AESMC))]
4184 "TARGET_SVE2_AES && aarch64_fusion_enabled_p (AARCH64_FUSE_AES_AESMC)"
4185 "aese\t%0.b, %0.b, %2.b\;aesmc\t%0.b, %0.b"
4186 [(set_attr "type" "crypto_aese")
4187 (set_attr "length" "8")]
4188 )
4189
4190 (define_insn "*aarch64_sve2_aesd_fused"
4191 [(set (match_operand:VNx16QI 0 "register_operand" "=w")
4192 (unspec:VNx16QI
4193 [(unspec:VNx16QI
4194 [(xor:VNx16QI
4195 (match_operand:VNx16QI 1 "register_operand" "%0")
4196 (match_operand:VNx16QI 2 "register_operand" "w"))]
4197 UNSPEC_AESD)]
4198 UNSPEC_AESIMC))]
4199 "TARGET_SVE2_AES && aarch64_fusion_enabled_p (AARCH64_FUSE_AES_AESMC)"
4200 "aesd\t%0.b, %0.b, %2.b\;aesimc\t%0.b, %0.b"
4201 [(set_attr "type" "crypto_aese")
4202 (set_attr "length" "8")]
4203 )
4204
4205 ;; -------------------------------------------------------------------------
4206 ;; ---- Optional SHA-3 extensions
4207 ;; -------------------------------------------------------------------------
4208 ;; Includes:
4209 ;; - RAX1
4210 ;; -------------------------------------------------------------------------
4211
4212 (define_insn "aarch64_sve2_rax1"
4213 [(set (match_operand:VNx2DI 0 "register_operand" "=w")
4214 (xor:VNx2DI
4215 (rotate:VNx2DI
4216 (match_operand:VNx2DI 2 "register_operand" "w")
4217 (const_int 1))
4218 (match_operand:VNx2DI 1 "register_operand" "w")))]
4219 "TARGET_SVE2_SHA3"
4220 "rax1\t%0.d, %1.d, %2.d"
4221 [(set_attr "type" "crypto_sha3")]
4222 )
4223
4224 ;; -------------------------------------------------------------------------
4225 ;; ---- Optional SM4 extensions
4226 ;; -------------------------------------------------------------------------
4227 ;; Includes:
4228 ;; - SM4E
4229 ;; - SM4EKEY
4230 ;; -------------------------------------------------------------------------
4231
4232 ;; These instructions do not take MOVPRFX.
4233 (define_insn "aarch64_sve2_sm4e"
4234 [(set (match_operand:VNx4SI 0 "register_operand" "=w")
4235 (unspec:VNx4SI
4236 [(match_operand:VNx4SI 1 "register_operand" "0")
4237 (match_operand:VNx4SI 2 "register_operand" "w")]
4238 UNSPEC_SM4E))]
4239 "TARGET_SVE2_SM4"
4240 "sm4e\t%0.s, %0.s, %2.s"
4241 [(set_attr "type" "crypto_sm4")]
4242 )
4243
4244 (define_insn "aarch64_sve2_sm4ekey"
4245 [(set (match_operand:VNx4SI 0 "register_operand" "=w")
4246 (unspec:VNx4SI
4247 [(match_operand:VNx4SI 1 "register_operand" "w")
4248 (match_operand:VNx4SI 2 "register_operand" "w")]
4249 UNSPEC_SM4EKEY))]
4250 "TARGET_SVE2_SM4"
4251 "sm4ekey\t%0.s, %1.s, %2.s"
4252 [(set_attr "type" "crypto_sm4")]
4253 )