1 /* { dg-options "-O -msve-vector-bits=128" } */
2 /* { dg-require-effective-target aarch64_little_endian }
3 /* { dg-final { check-function-bodies "**" "" } } */
4 
5 #include "struct.h"
6 
7 #define CONSUME(VAR)				\
8   {						\
9     register void *ptr_ asm ("x7") = &(VAR);	\
10     asm volatile ("" :: "r" (ptr_) : "memory");	\
11   }
12 
13 #define SEL2(TAG, TYPE)				\
14   TAG TYPE					\
15   sel2_##TYPE (TAG TYPE x, TAG TYPE y)		\
16   {						\
17     return y;					\
18   }
19 
20 #define WRAP(TYPE)				\
21   struct wrap_##TYPE				\
22   {						\
23     TYPE data;					\
24   };						\
25   SEL2 (struct, wrap_##TYPE)
26 
27 /*
28 ** sel2_wrap_fixed_int8_t:
29 **	mov	z0\.d, z1\.d
30 **	ret
31 */
32 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_wrap_fixed_int8_t\n} } } */
33 WRAP (fixed_int8_t);
34 
35 /*
36 ** sel2_wrap_fixed_int16_t:
37 **	mov	z0\.d, z1\.d
38 **	ret
39 */
40 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_wrap_fixed_int16_t\n} } } */
41 WRAP (fixed_int16_t);
42 
43 /*
44 ** sel2_wrap_fixed_int32_t:
45 **	mov	z0\.d, z1\.d
46 **	ret
47 */
48 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_wrap_fixed_int32_t\n} } } */
49 WRAP (fixed_int32_t);
50 
51 /*
52 ** sel2_wrap_fixed_int64_t:
53 **	mov	z0\.d, z1\.d
54 **	ret
55 */
56 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_wrap_fixed_int64_t\n} } } */
57 WRAP (fixed_int64_t);
58 
59 /*
60 ** sel2_wrap_fixed_uint8_t:
61 **	mov	z0\.d, z1\.d
62 **	ret
63 */
64 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_wrap_fixed_uint8_t\n} } } */
65 WRAP (fixed_uint8_t);
66 
67 /*
68 ** sel2_wrap_fixed_uint16_t:
69 **	mov	z0\.d, z1\.d
70 **	ret
71 */
72 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_wrap_fixed_uint16_t\n} } } */
73 WRAP (fixed_uint16_t);
74 
75 /*
76 ** sel2_wrap_fixed_uint32_t:
77 **	mov	z0\.d, z1\.d
78 **	ret
79 */
80 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_wrap_fixed_uint32_t\n} } } */
81 WRAP (fixed_uint32_t);
82 
83 /*
84 ** sel2_wrap_fixed_uint64_t:
85 **	mov	z0\.d, z1\.d
86 **	ret
87 */
88 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_wrap_fixed_uint64_t\n} } } */
89 WRAP (fixed_uint64_t);
90 
91 /*
92 ** sel2_wrap_fixed_bfloat16_t:
93 **	mov	z0\.d, z1\.d
94 **	ret
95 */
96 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_wrap_fixed_bfloat16_t\n} } } */
97 WRAP (fixed_bfloat16_t);
98 
99 /*
100 ** sel2_wrap_fixed_float16_t:
101 **	mov	z0\.d, z1\.d
102 **	ret
103 */
104 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_wrap_fixed_float16_t\n} } } */
105 WRAP (fixed_float16_t);
106 
107 /*
108 ** sel2_wrap_fixed_float32_t:
109 **	mov	z0\.d, z1\.d
110 **	ret
111 */
112 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_wrap_fixed_float32_t\n} } } */
113 WRAP (fixed_float32_t);
114 
115 /*
116 ** sel2_wrap_fixed_float64_t:
117 **	mov	z0\.d, z1\.d
118 **	ret
119 */
120 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_wrap_fixed_float64_t\n} } } */
121 WRAP (fixed_float64_t);
122 
123 /*
124 ** sel2_wrap_fixed_bool_t:
125 **	mov	p0\.b, p1\.b
126 **	ret
127 */
128 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_wrap_fixed_bool_t\n} } } */
129 WRAP (fixed_bool_t);
130 
131 struct pst_arr1
132 {
133   fixed_uint8_t u8[1];
134 };
135 
136 /*
137 ** sel2_pst_arr1:
138 **	mov	z0\.d, z1\.d
139 **	ret
140 */
141 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_arr1\n} } } */
SEL2(struct,pst_arr1)142 SEL2 (struct, pst_arr1)
143 
144 /*
145 ** test_pst_arr1:
146 **	eor	z0\.b, z0\.b, #(?:0x)?1
147 **	ret
148 */
149 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_arr1\n} } } */
150 svuint8_t
151 test_pst_arr1 (struct pst_arr1 x)
152 {
153   return sveor_x (svptrue_b8 (), x.u8[0], 1);
154 }
155 
156 struct pst_arr2
157 {
158   fixed_uint8_t u8[2];
159 };
160 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_arr2\n} } } */
SEL2(struct,pst_arr2)161 SEL2 (struct, pst_arr2)
162 
163 /*
164 ** test_pst_arr2:
165 **	sub	z0\.b, z0\.b, z1\.b
166 **	ret
167 */
168 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_arr2\n} } } */
169 svuint8_t
170 test_pst_arr2 (struct pst_arr2 x)
171 {
172   return svsub_x (svptrue_b8 (), x.u8[0], x.u8[1]);
173 }
174 
175 struct pst_arr3
176 {
177   fixed_uint16_t u16[3];
178 };
179 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_arr3\n} } } */
SEL2(struct,pst_arr3)180 SEL2 (struct, pst_arr3)
181 
182 /*
183 ** test_pst_arr3:
184 **	sub	z0\.h, z0\.h, z2\.h
185 **	ret
186 */
187 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_arr3\n} } } */
188 svuint16_t
189 test_pst_arr3 (struct pst_arr3 x)
190 {
191   return svsub_x (svptrue_b8 (), x.u16[0], x.u16[2]);
192 }
193 
194 struct pst_arr4
195 {
196   fixed_uint32_t u32[4];
197 };
198 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_arr4\n} } } */
SEL2(struct,pst_arr4)199 SEL2 (struct, pst_arr4)
200 
201 /*
202 ** test_pst_arr4:
203 **	sub	z0\.s, z0\.s, z3\.s
204 **	ret
205 */
206 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_arr4\n} } } */
207 svuint32_t
208 test_pst_arr4 (struct pst_arr4 x)
209 {
210   return svsub_x (svptrue_b8 (), x.u32[0], x.u32[3]);
211 }
212 
213 struct pst_arr5
214 {
215   fixed_uint64_t u64[2][2][2];
216 };
217 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_arr5\n} } } */
SEL2(struct,pst_arr5)218 SEL2 (struct, pst_arr5)
219 
220 /*
221 ** test_pst_arr5:
222 **	sub	sp, sp, #128
223 **	str	z0, \[sp\]
224 **	str	z1, \[sp, #1, mul vl\]
225 **	str	z2, \[sp, #2, mul vl\]
226 **	str	z3, \[sp, #3, mul vl\]
227 **	str	z4, \[sp, #4, mul vl\]
228 **	str	z5, \[sp, #5, mul vl\]
229 **	str	z6, \[sp, #6, mul vl\]
230 **	str	z7, \[sp, #7, mul vl\]
231 **	mov	(x7, sp|w7, wsp)
232 **	add	sp, sp, #?128
233 **	ret
234 */
235 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_arr5\n} } } */
236 void
237 test_pst_arr5 (struct pst_arr5 x)
238 {
239   CONSUME (x);
240 }
241 
242 /*
243 ** test_pst_arr5_x0:
244 ** (
245 **	mov	z0\.d, z7\.d
246 **	mov	(x7, x0|w7, w0)
247 ** |
248 **	mov	(x7, x0|w7, w0)
249 **	mov	z0\.d, z7\.d
250 ** )
251 **	ret
252 */
253 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_arr5_x0\n} } } */
254 svint32_t
test_pst_arr5_x0(svint32_t z0,struct pst_arr5 x,svint32_t z1,svint32_t z2,svint32_t z3,svint32_t z4,svint32_t z5,svint32_t z6,svint32_t z7)255 test_pst_arr5_x0 (svint32_t z0, struct pst_arr5 x,
256 		  svint32_t z1, svint32_t z2, svint32_t z3, svint32_t z4,
257 		  svint32_t z5, svint32_t z6, svint32_t z7)
258 {
259   CONSUME (x);
260   return z7;
261 }
262 
263 /*
264 ** test_pst_arr5_x7:
265 **	ret
266 */
267 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_arr5_x7\n} } } */
268 svint32_t
test_pst_arr5_x7(svint32_t z0,int x0,int x1,int x2,int x3,int x4,int x5,int x6,struct pst_arr5 x)269 test_pst_arr5_x7 (svint32_t z0, int x0, int x1, int x2, int x3, int x4,
270 		  int x5, int x6, struct pst_arr5 x)
271 {
272   CONSUME (x);
273   return z0;
274 }
275 
276 /*
277 ** test_pst_arr5_sp: { target lp64 }
278 **	ldr	x7, \[sp\]
279 **	ret
280 */
281 /*
282 ** test_pst_arr5_sp: { target ilp32 }
283 **	ldr	w7, \[sp\]
284 **	ret
285 */
286 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_arr5_sp\n} } } */
287 svint32_t
test_pst_arr5_sp(svint32_t z0,int x0,int x1,int x2,int x3,int x4,int x5,int x6,int x7,struct pst_arr5 x)288 test_pst_arr5_sp (svint32_t z0, int x0, int x1, int x2, int x3, int x4,
289 		  int x5, int x6, int x7, struct pst_arr5 x)
290 {
291   CONSUME (x);
292   return z0;
293 }
294 
295 struct pst_arr6
296 {
297   fixed_bool_t b[2][2];
298 };
299 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_arr6\n} } } */
SEL2(struct,pst_arr6)300 SEL2 (struct, pst_arr6)
301 
302 /*
303 ** test_pst_arr6:
304 **	...
305 **	brkpa	p0\.b, p0/z, p2\.b, p3\.b
306 **	...
307 */
308 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_arr6\n} } } */
309 fixed_bool_t
310 test_pst_arr6 (struct pst_arr6 x)
311 {
312   return svbrkpa_z (x.b[0][0], x.b[1][0], x.b[1][1]);
313 }
314 
315 /*
316 ** test_pst_arr6_x0:
317 ** (
318 **	mov	p0\.b, p3\.b
319 **	mov	(x7, x0|w7, w0)
320 ** |
321 **	mov	(x7, x0|w7, w0)
322 **	mov	p0\.b, p3\.b
323 ** )
324 **	ret
325 */
326 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_arr6_x0\n} } } */
327 fixed_bool_t
test_pst_arr6_x0(svbool_t p0,struct pst_arr6 x,svbool_t p1,svbool_t p2,svbool_t p3)328 test_pst_arr6_x0 (svbool_t p0, struct pst_arr6 x, svbool_t p1, svbool_t p2,
329 		  svbool_t p3)
330 {
331   CONSUME (x);
332   return p3;
333 }
334 
335 /*
336 ** test_pst_arr6_x7:
337 **	ret
338 */
339 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_arr6_x7\n} } } */
340 fixed_bool_t
test_pst_arr6_x7(svbool_t p0,int x0,int x1,int x2,int x3,int x4,int x5,int x6,struct pst_arr6 x)341 test_pst_arr6_x7 (svbool_t p0, int x0, int x1, int x2, int x3, int x4,
342 		  int x5, int x6, struct pst_arr6 x)
343 {
344   CONSUME (x);
345   return p0;
346 }
347 
348 /*
349 ** test_pst_arr6_sp: { target lp64 }
350 **	ldr	x7, \[sp\]
351 **	ret
352 */
353 /*
354 ** test_pst_arr6_sp: { target ilp32 }
355 **	ldr	w7, \[sp\]
356 **	ret
357 */
358 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_arr6_sp\n} } } */
359 fixed_bool_t
test_pst_arr6_sp(svbool_t p0,int x0,int x1,int x2,int x3,int x4,int x5,int x6,int x7,struct pst_arr6 x)360 test_pst_arr6_sp (svbool_t p0, int x0, int x1, int x2, int x3, int x4,
361 		  int x5, int x6, int x7, struct pst_arr6 x)
362 {
363   CONSUME (x);
364   return p0;
365 }
366 
367 struct pst_uniform1
368 {
369   fixed_int8_t a, b;
370 };
371 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_uniform1\n} } } */
SEL2(struct,pst_uniform1)372 SEL2 (struct, pst_uniform1)
373 
374 /*
375 ** test_pst_uniform1:
376 **	sub	sp, sp, #32
377 **	str	z0, \[sp\]
378 **	str	z1, \[sp, #1, mul vl\]
379 **	mov	(x7, sp|w7, wsp)
380 **	add	sp, sp, #?32
381 **	ret
382 */
383 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_uniform1\n} } } */
384 void
385 test_pst_uniform1 (struct pst_uniform1 x)
386 {
387   CONSUME (x);
388 }
389 
390 struct pst_uniform2
391 {
392   fixed_int16_t a;
393   fixed_int16_t b[2];
394 };
395 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_uniform2\n} } } */
SEL2(struct,pst_uniform2)396 SEL2 (struct, pst_uniform2)
397 
398 /*
399 ** test_pst_uniform2:
400 **	sub	sp, sp, #48
401 **	str	z0, \[sp\]
402 **	str	z1, \[sp, #1, mul vl\]
403 **	str	z2, \[sp, #2, mul vl\]
404 **	mov	(x7, sp|w7, wsp)
405 **	add	sp, sp, #?48
406 **	ret
407 */
408 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_uniform2\n} } } */
409 void
410 test_pst_uniform2 (struct pst_uniform2 x)
411 {
412   CONSUME (x);
413 }
414 
415 struct pst_uniform3
416 {
417   fixed_int32_t a;
418   fixed_int32_t b[2];
419   fixed_int32_t c;
420 };
421 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_uniform3\n} } } */
SEL2(struct,pst_uniform3)422 SEL2 (struct, pst_uniform3)
423 
424 /*
425 ** test_pst_uniform3:
426 **	sub	sp, sp, #64
427 **	str	z0, \[sp\]
428 **	str	z1, \[sp, #1, mul vl\]
429 **	str	z2, \[sp, #2, mul vl\]
430 **	str	z3, \[sp, #3, mul vl\]
431 **	mov	(x7, sp|w7, wsp)
432 **	add	sp, sp, #?64
433 **	ret
434 */
435 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_uniform3\n} } } */
436 void
437 test_pst_uniform3 (struct pst_uniform3 x)
438 {
439   CONSUME (x);
440 }
441 
442 struct pst_uniform4
443 {
444   fixed_int32_t a __attribute__((aligned(SVE_BYTES * 2)));
445   fixed_int32_t b[3] __attribute__((aligned(SVE_BYTES * 2)));
446   fixed_int32_t c __attribute__((aligned(SVE_BYTES * 2)));
447 };
448 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_uniform4\n} } } */
SEL2(struct,pst_uniform4)449 SEL2 (struct, pst_uniform4)
450 
451 /*
452 ** test_pst_uniform4:
453 **	sub	sp, sp, #144
454 **	add	(x[0-9]+), sp, #?31
455 **	and	x7, \1, #?(?:-32|4294967264)
456 **	ptrue	(p[0-7])\.b, vl16
457 **	st1w	z0\.s, \2, \[x7\]
458 **	add	(x[0-9]+), x7, #?32
459 **	str	z1, \[\3\]
460 **	str	z2, \[\3, #1, mul vl\]
461 **	str	z3, \[\3, #2, mul vl\]
462 **	st1w	z4\.s, \2, \[x7, #6, mul vl\]
463 **	add	sp, sp, #?144
464 **	ret
465 */
466 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_uniform4\n} } } */
467 void
468 test_pst_uniform4 (struct pst_uniform4 x)
469 {
470   CONSUME (x);
471 }
472 
473 struct pst_mixed1
474 {
475   fixed_bool_t p0;
476   fixed_bfloat16_t z0;
477   fixed_float16_t z1;
478   fixed_float32_t z2;
479   fixed_float64_t z3;
480   fixed_bool_t p1;
481   fixed_bool_t p2;
482   fixed_int8_t z4;
483   fixed_int16_t z5;
484   fixed_int32_t z6;
485   fixed_int64_t z7;
486   fixed_bool_t p3;
487 };
488 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_mixed1\n} } } */
SEL2(struct,pst_mixed1)489 SEL2 (struct, pst_mixed1)
490 
491 /*
492 ** test_pst_mixed1:
493 **	sub	sp, sp, #176
494 **	str	p0, \[sp\]
495 **	ptrue	p0\.b, vl16
496 **	st1h	z0\.h, p0, \[sp, #1, mul vl\]
497 **	st1h	z1\.h, p0, \[sp, #2, mul vl\]
498 **	st1w	z2\.s, p0, \[sp, #3, mul vl\]
499 **	st1d	z3\.d, p0, \[sp, #4, mul vl\]
500 **	str	p1, \[sp, #40, mul vl\]
501 **	str	p2, \[sp, #41, mul vl\]
502 **	st1b	z4\.b, p0, \[sp, #6, mul vl\]
503 **	st1h	z5\.h, p0, \[sp, #7, mul vl\]
504 **	...
505 **	st1w	z6\.s, p0, [^\n]*
506 **	...
507 **	st1d	z7\.d, p0, [^\n]*
508 **	...
509 **	str	p3, \[sp, #80, mul vl\]
510 **	mov	(x7, sp|w7, wsp)
511 **	add	sp, sp, #?176
512 **	ret
513 */
514 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_mixed1\n} } } */
515 void
516 test_pst_mixed1 (struct pst_mixed1 x)
517 {
518   CONSUME (x);
519 }
520 
521 struct pst_mixed2
522 {
523   struct __attribute__ ((packed)) {
524     fixed_bool_t p;
525     fixed_int8_t z;
526   } a[3];
527   fixed_int16_t b[1][1][1][4];
528 };
529 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_mixed2\n} } } */
SEL2(struct,pst_mixed2)530 SEL2 (struct, pst_mixed2)
531 
532 /*
533 ** test_pst_mixed2:
534 **	sub	sp, sp, #128
535 **	str	p0, \[sp\]
536 **	ptrue	(p[03])\.b, vl16
537 **	add	(x[0-9]+), sp, #?2
538 **	st1b	z0\.b, \1, \[\2\]
539 **	str	p1, \[sp, #9, mul vl\]
540 **	add	(x[0-9]+), sp, #?20
541 **	st1b	z1\.b, \1, \[\3\]
542 **	str	p2, \[sp, #18, mul vl\]
543 **	add	(x[0-9]+), sp, #?38
544 **	st1b	z2\.b, \1, \[\4\]
545 **	str	z3, \[sp, #4, mul vl\]
546 **	str	z4, \[sp, #5, mul vl\]
547 **	str	z5, \[sp, #6, mul vl\]
548 **	str	z6, \[sp, #7, mul vl\]
549 **	mov	(x7, sp|w7, wsp)
550 **	add	sp, sp, #?128
551 **	ret
552 */
553 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_mixed2\n} } } */
554 void
555 test_pst_mixed2 (struct pst_mixed2 x)
556 {
557   CONSUME (x);
558 }
559 
560 struct pst_big1
561 {
562   fixed_int8_t a[9];
563 };
564 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tsel2_pst_big1\n} } } */
SEL2(struct,pst_big1)565 SEL2 (struct, pst_big1)
566 
567 /*
568 ** test_pst_big1_a: { target lp64 }
569 **	ptrue	(p[0-7])\.b, vl16
570 **	ld1b	z0\.b, \1/z, \[x0\]
571 **	ret
572 */
573 /*
574 ** test_pst_big1_a: { target ilp32 }
575 **	uxtw	x0, w0
576 **	ptrue	(p[0-7])\.b, vl16
577 **	ld1b	z0\.b, \1/z, \[x0\]
578 **	ret
579 */
580 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_big1_a\n} } } */
581 svint8_t
582 test_pst_big1_a (struct pst_big1 x)
583 {
584   return x.a[0];
585 }
586 
587 /*
588 ** test_pst_big1_b: { target lp64 }
589 **	add	x7, x0, #?128
590 **	ret
591 */
592 /*
593 ** test_pst_big1_b: { target ilp32 }
594 **	add	w7, w0, #?128
595 **	ret
596 */
597 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_big1_b\n} } } */
598 svint8_t
test_pst_big1_b(struct pst_big1 x)599 test_pst_big1_b (struct pst_big1 x)
600 {
601   CONSUME (x.a[8]);
602 }
603 
604 struct pst_big2
605 {
606   fixed_bool_t a[5];
607 };
608 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tsel2_pst_big2\n} } } */
SEL2(struct,pst_big2)609 SEL2 (struct, pst_big2)
610 
611 /*
612 ** test_pst_big2_a: { target lp64 }
613 **	ldr	p0, \[x0\]
614 **	ret
615 */
616 /*
617 ** test_pst_big2_a: { target ilp32 }
618 **	uxtw	x0, w0
619 **	ldr	p0, \[x0\]
620 **	ret
621 */
622 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_big2_a\n} } } */
623 svbool_t
624 test_pst_big2_a (struct pst_big2 x)
625 {
626   return x.a[0];
627 }
628 
629 /*
630 ** test_pst_big2_b: { target lp64 }
631 **	ldr	p0, \[x0, #4, mul vl\]
632 **	ret
633 */
634 /*
635 ** test_pst_big2_b: { target ilp32 }
636 **	uxtw	x0, w0
637 **	ldr	p0, \[x0, #4, mul vl\]
638 **	ret
639 */
640 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_big2_b\n} } } */
641 svbool_t
test_pst_big2_b(struct pst_big2 x)642 test_pst_big2_b (struct pst_big2 x)
643 {
644   return x.a[4];
645 }
646 
647 struct pst_big3
648 {
649   fixed_bool_t p0;
650   fixed_int8_t a[2];
651   fixed_bool_t p1;
652   fixed_bool_t p2;
653   fixed_bool_t p3;
654   fixed_int8_t b[6];
655   fixed_bool_t p4;
656 };
657 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tsel2_pst_big3\n} } } */
SEL2(struct,pst_big3)658 SEL2 (struct, pst_big3)
659 
660 /*
661 ** test_pst_big3_a: { target lp64 }
662 **	ldr	p0, \[x0\]
663 **	ret
664 */
665 /*
666 ** test_pst_big3_a: { target ilp32 }
667 **	uxtw	x0, w0
668 **	ldr	p0, \[x0\]
669 **	ret
670 */
671 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_big3_a\n} } } */
672 svbool_t
673 test_pst_big3_a (struct pst_big3 x)
674 {
675   return x.p0;
676 }
677 
678 /*
679 ** test_pst_big3_b: { target lp64 }
680 **	ldr	p0, \[x0, #24, mul vl\]
681 **	ret
682 */
683 /*
684 ** test_pst_big3_b: { target ilp32 }
685 **	uxtw	x0, w0
686 **	ldr	p0, \[x0, #24, mul vl\]
687 **	ret
688 */
689 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_big3_b\n} } } */
690 svbool_t
test_pst_big3_b(struct pst_big3 x)691 test_pst_big3_b (struct pst_big3 x)
692 {
693   return x.p1;
694 }
695 
696 /*
697 ** test_pst_big3_c: { target lp64 }
698 **	ldr	p0, \[x0, #25, mul vl\]
699 **	ret
700 */
701 /*
702 ** test_pst_big3_c: { target ilp32 }
703 **	uxtw	x0, w0
704 **	ldr	p0, \[x0, #25, mul vl\]
705 **	ret
706 */
707 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_big3_c\n} } } */
708 svbool_t
test_pst_big3_c(struct pst_big3 x)709 test_pst_big3_c (struct pst_big3 x)
710 {
711   return x.p2;
712 }
713 
714 /*
715 ** test_pst_big3_d: { target lp64 }
716 **	ldr	p0, \[x0, #80, mul vl\]
717 **	ret
718 */
719 /*
720 ** test_pst_big3_d: { target ilp32 }
721 **	uxtw	x0, w0
722 **	ldr	p0, \[x0, #80, mul vl\]
723 **	ret
724 */
725 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_big3_d\n} } } */
726 svbool_t
test_pst_big3_d(struct pst_big3 x)727 test_pst_big3_d (struct pst_big3 x)
728 {
729   return x.p4;
730 }
731 
732 /*
733 ** test_pst_big3_e: { target lp64 }
734 **	ptrue	(p[0-7])\.b, vl16
735 **	ld1b	z0\.b, \1/z, \[x0, #1, mul vl\]
736 **	ret
737 */
738 /*
739 ** test_pst_big3_e: { target ilp32 }
740 **	uxtw	x0, w0
741 **	ptrue	(p[0-7])\.b, vl16
742 **	ld1b	z0\.b, \1/z, \[x0, #1, mul vl\]
743 **	ret
744 */
745 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_big3_e\n} } } */
746 svint8_t
test_pst_big3_e(struct pst_big3 x)747 test_pst_big3_e (struct pst_big3 x)
748 {
749   return x.a[0];
750 }
751 
752 /*
753 ** test_pst_big3_f: { target lp64 }
754 **	ptrue	(p[0-7])\.b, vl16
755 **	ld1b	z0\.b, \1/z, \[x0, #5, mul vl\]
756 **	ret
757 */
758 /*
759 ** test_pst_big3_f: { target ilp32 }
760 **	uxtw	x0, w0
761 **	ptrue	(p[0-7])\.b, vl16
762 **	ld1b	z0\.b, \1/z, \[x0, #5, mul vl\]
763 **	ret
764 */
765 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_big3_f\n} } } */
766 svint8_t
test_pst_big3_f(struct pst_big3 x)767 test_pst_big3_f (struct pst_big3 x)
768 {
769   return x.b[1];
770 }
771 
772 struct pst_zero1
773 {
774   fixed_bool_t a[0];
775   fixed_int32_t b;
776 };
777 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_zero1\n} } } */
SEL2(struct,pst_zero1)778 SEL2 (struct, pst_zero1)
779 
780 /*
781 ** test_pst_zero1:
782 **	ret
783 */
784 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_zero1\n} } } */
785 svint32_t
786 test_pst_zero1 (struct pst_zero1 x)
787 {
788   return x.b;
789 }
790 
791 struct pst_zero2
792 {
793   unsigned int : 0;
794   fixed_bool_t b;
795 };
796 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_zero2\n} } } */
SEL2(struct,pst_zero2)797 SEL2 (struct, pst_zero2)
798 
799 /*
800 ** test_pst_zero2:
801 ** (
802 **	sub	sp, sp, #16
803 **	add	sp, sp, #?16
804 ** |
805 ** )
806 **	ret
807 */
808 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_zero2\n} } } */
809 svbool_t
810 test_pst_zero2 (struct pst_zero2 x)
811 {
812   return x.b;
813 }
814 
815 struct pst_zero3
816 {
817   struct {} empty;
818   fixed_uint64_t b;
819 };
820 /* { dg-final { scan-assembler {\t\.variant_pcs\tsel2_pst_zero3\n} } } */
SEL2(struct,pst_zero3)821 SEL2 (struct, pst_zero3)
822 
823 /*
824 ** test_pst_zero3:
825 **	ret
826 */
827 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_pst_zero3\n} } } */
828 svuint64_t
829 test_pst_zero3 (struct pst_zero3 x)
830 {
831   return x.b;
832 }
833 
834 typedef unsigned char small_vec __attribute__((vector_size(SVE_BYTES / 4)));
835 
836 struct nonpst1
837 {
838   small_vec a[4];
839 };
840 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tsel2_pst_nonpst1\n} } } */
SEL2(struct,nonpst1)841 SEL2 (struct, nonpst1)
842 
843 /*
844 ** test_nonpst1:
845 **	...
846 **	lsr	x0, x1, #?32
847 **	...
848 **	ret
849 */
850 /* { dg-final { scan-assembler-not {\t\.variant_pcs\ttest_nonpst1\n} } } */
851 small_vec
852 test_nonpst1 (struct nonpst1 x)
853 {
854   return x.a[3];
855 }
856 
857 union nonpst2
858 {
859   struct {
860     fixed_bool_t a[0];
861     fixed_int32_t b;
862   };
863 };
864 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tsel2_pst_nonpst2\n} } } */
SEL2(union,nonpst2)865 SEL2 (union, nonpst2)
866 
867 /*
868 ** test_nonpst2:
869 **	sub	sp, sp, #16
870 **	stp	x0, x1, \[sp\]
871 **	...
872 **	ldr	z0, \[sp\]
873 **	add	sp, sp, #?16
874 **	ret
875 */
876 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_nonpst2\n} } } */
877 svint32_t
878 test_nonpst2 (union nonpst2 x)
879 {
880   return x.b;
881 }
882 
883 /*
884 ** ret_nonpst2:
885 **	mov	x0, #?1
886 **	movk	x0, #?0x3, lsl #?32
887 **	mov	x1, #?5
888 **	movk	x1, #?0x7, lsl #?32
889 **	ret
890 */
891 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tret_nonpst2\n} } } */
892 union nonpst2
ret_nonpst2(void)893 ret_nonpst2 (void)
894 {
895   return (union nonpst2) { { {}, 1, 3, 5, 7 } };
896 }
897 
898 union nonpst3
899 {
900   struct {
901     unsigned int : 0;
902     fixed_bool_t b;
903   };
904 };
905 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tsel2_pst_nonpst3\n} } } */
SEL2(union,nonpst3)906 SEL2 (union, nonpst3)
907 
908 /*
909 ** test_nonpst3:
910 **	sub	sp, sp, #16
911 **	strh	w0, \[sp, #?6\]
912 **	ldr	p0, \[sp, #3, mul vl\]
913 **	add	sp, sp, #?16
914 **	ret
915 */
916 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_nonpst3\n} } } */
917 svbool_t
918 test_nonpst3 (union nonpst3 x)
919 {
920   return x.b;
921 }
922 
923 /*
924 ** ret_nonpst3: { xfail *-*-* }
925 **	mov	w0, #?(?:0xffff|65535)
926 **	ret
927 */
928 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tret_nonpst3\n} } } */
929 union nonpst3
ret_nonpst3(void)930 ret_nonpst3 (void)
931 {
932   return (union nonpst3) { { svptrue_b8 () } };
933 }
934 
935 union nonpst4
936 {
937   struct {
938     struct {} empty;
939     fixed_uint64_t b;
940   };
941 };
942 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tsel2_pst_nonpst4\n} } } */
SEL2(union,nonpst4)943 SEL2 (union, nonpst4)
944 
945 /*
946 ** test_nonpst4:
947 **	sub	sp, sp, #16
948 **	stp	x0, x1, \[sp\]
949 **	...
950 **	ldr	z0, \[sp\]
951 **	add	sp, sp, #?16
952 **	ret
953 */
954 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_nonpst4\n} } } */
955 svuint64_t
956 test_nonpst4 (union nonpst4 x)
957 {
958   return x.b;
959 }
960 
961 /*
962 ** ret_nonpst4:
963 **	mov	x0, 1
964 **	mov	x1, 2
965 **	ret
966 */
967 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tret_nonpst4\n} } } */
968 union nonpst4
ret_nonpst4(void)969 ret_nonpst4 (void)
970 {
971   return (union nonpst4) { { {}, 1, 2 } };
972 }
973 
974 struct nonpst5
975 {
976   union {
977     fixed_uint16_t b;
978   };
979 };
980 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tsel2_pst_nonpst5\n} } } */
SEL2(struct,nonpst5)981 SEL2 (struct, nonpst5)
982 
983 /*
984 ** test_nonpst5:
985 **	sub	sp, sp, #16
986 **	stp	x0, x1, \[sp\]
987 **	...
988 **	ldr	z0, \[sp\]
989 **	add	sp, sp, #?16
990 **	ret
991 */
992 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_nonpst5\n} } } */
993 svuint16_t
994 test_nonpst5 (struct nonpst5 x)
995 {
996   return x.b;
997 }
998 
999 struct nonpst6
1000 {
1001   fixed_uint64_t b;
1002   fixed_uint64_t *ptr;
1003 };
1004 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tsel2_pst_nonpst6\n} } } */
SEL2(struct,nonpst6)1005 SEL2 (struct, nonpst6)
1006 
1007 /*
1008 ** test_nonpst6: { target lp64 }
1009 **	ptrue	(p[0-3])\.b, vl16
1010 **	ld1d	z0\.d, \1/z, \[x0\]
1011 **	ret
1012 */
1013 /*
1014 ** test_nonpst6: { target ilp32 }
1015 **	uxtw	x0, w0
1016 **	ptrue	(p[0-3])\.b, vl16
1017 **	ld1d	z0\.d, \1/z, \[x0\]
1018 **	ret
1019 */
1020 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_nonpst6\n} } } */
1021 svuint64_t
1022 test_nonpst6 (struct nonpst6 x)
1023 {
1024   return x.b;
1025 }
1026 
1027 struct nonpst7
1028 {
1029   fixed_uint64_t b;
1030   uint32_t foo __attribute__((vector_size(SVE_BYTES)));
1031 };
1032 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tsel2_pst_nonpst7\n} } } */
SEL2(struct,nonpst7)1033 SEL2 (struct, nonpst7)
1034 
1035 /*
1036 ** test_nonpst7: { target lp64 }
1037 **	ptrue	(p[0-3])\.b, vl16
1038 **	ld1d	z0\.d, \1/z, \[x0\]
1039 **	ret
1040 */
1041 /*
1042 ** test_nonpst7: { target ilp32 }
1043 **	uxtw	x0, w0
1044 **	ptrue	(p[0-3])\.b, vl16
1045 **	ld1d	z0\.d, \1/z, \[x0\]
1046 **	ret
1047 */
1048 /* { dg-final { scan-assembler {\t\.variant_pcs\ttest_nonpst7\n} } } */
1049 svuint64_t
1050 test_nonpst7 (struct nonpst7 x)
1051 {
1052   return x.b;
1053 }
1054 
1055 typedef unsigned char tiny_vec __attribute__((vector_size(SVE_BYTES / 8)));
1056 
1057 struct nonpst8
1058 {
1059   tiny_vec a;
1060 };
1061 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tsel2_pst_nonpst8\n} } } */
SEL2(struct,nonpst8)1062 SEL2 (struct, nonpst8)
1063 
1064 /*
1065 ** test_nonpst8:
1066 **	ubfx	x0, x0, 8, 8
1067 **	ret
1068 */
1069 /* { dg-final { scan-assembler-not {\t\.variant_pcs\ttest_nonpst8\n} } } */
1070 unsigned int
1071 test_nonpst8 (struct nonpst8 x)
1072 {
1073   return x.a[1];
1074 }
1075 
1076 /*
1077 ** ret_nonpst8:
1078 ** (
1079 **	sub	sp, sp, #16
1080 **	mov	w0, #?513
1081 **	add	sp, sp, #?16
1082 ** |
1083 **	mov	w0, #?513
1084 ** )
1085 **	ret
1086 */
1087 /* { dg-final { scan-assembler-not {\t\.variant_pcs\tret_nonpst8\n} } } */
1088 struct nonpst8
ret_nonpst8(void)1089 ret_nonpst8 (void)
1090 {
1091   return (struct nonpst8) { { 1, 2 } };
1092 }
1093