comparison gcc/testsuite/gcc.target/aarch64/sve/pcs/struct_1_128.c @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents
children
comparison
equal deleted inserted replaced
18:1830386684a0 19:2b5abeee2509
1 /* { dg-do run { target { aarch64_sve128_hw } } } */
2 /* { dg-require-effective-target aarch64_little_endian } */
3 /* { dg-options "-msve-vector-bits=128" } */
4
5 #include "struct.h"
6
7 struct pst1
8 {
9 fixed_int8_t v[8];
10 fixed_bool_t p[4];
11 };
12
13 ASM_FUNCTION (make_pst1_asm, struct pst1, (),
14 "mov z0.b, #1\n\t"
15 "mov z1.b, #4\n\t"
16 "mov z2.b, #5\n\t"
17 "mov z3.b, #9\n\t"
18 "mov z4.b, #14\n\t"
19 "mov z5.b, #23\n\t"
20 "mov z6.b, #37\n\t"
21 "mov z7.b, #60\n\t"
22 "ptrue p0.b, vl1\n\t"
23 "ptrue p1.b, vl2\n\t"
24 "ptrue p2.b, vl3\n\t"
25 "ptrue p3.b, vl4");
26
27 #define LOAD_PST1(PTR) \
28 "ld1b z0.b, p0/z, [" PTR ", #0, mul vl]\n\t" \
29 "ld1b z1.b, p0/z, [" PTR ", #1, mul vl]\n\t" \
30 "ld1b z2.b, p0/z, [" PTR ", #2, mul vl]\n\t" \
31 "ld1b z3.b, p0/z, [" PTR ", #3, mul vl]\n\t" \
32 "ld1b z4.b, p0/z, [" PTR ", #4, mul vl]\n\t" \
33 "ld1b z5.b, p0/z, [" PTR ", #5, mul vl]\n\t" \
34 "ld1b z6.b, p0/z, [" PTR ", #6, mul vl]\n\t" \
35 "ld1b z7.b, p0/z, [" PTR ", #7, mul vl]\n\t" \
36 "incb " PTR ", all, mul #8\n\t" \
37 "ldr p0, [" PTR ", #0, mul vl]\n\t" \
38 "ldr p1, [" PTR ", #1, mul vl]\n\t" \
39 "ldr p2, [" PTR ", #2, mul vl]\n\t" \
40 "ldr p3, [" PTR ", #3, mul vl]"
41
42 ASM_FUNCTION (passthru_pst1_x0_a,
43 struct pst1, (svbool_t, struct pst1),
44 "incp x0, p0.b\n\t"
45 "sub x0, x0, #11\n\t"
46 "ptrue p0.b\n\t"
47 LOAD_PST1 ("x0"));
48
49 ASM_FUNCTION (passthru_pst1_x0_b,
50 struct pst1, (svbool_t, struct pst1, uint64_t),
51 "incp x0, p0.b\n\t"
52 "add x0, x0, x1\n\t"
53 "sub x0, x0, #52\n\t"
54 "ptrue p0.b\n\t"
55 LOAD_PST1 ("x0"));
56
57 ASM_FUNCTION (passthru_pst1_x0_c,
58 struct pst1, (svbool_t, struct pst1, svbool_t,
59 svbool_t, svbool_t, svbool_t),
60 "incp x0, p0.b\n\t"
61 "ldr p0, [x1]\n\t"
62 "incp x0, p1.b\n\t"
63 "incp x0, p2.b\n\t"
64 "incp x0, p3.b\n\t"
65 "incp x0, p0.b\n\t"
66 "sub x0, x0, #27\n\t"
67 "ptrue p0.b\n\t"
68 LOAD_PST1 ("x0"));
69
70 ASM_FUNCTION (passthru_pst1_x0_d,
71 struct pst1, (svfloat32_t, struct pst1),
72 "ptrue p0.b\n\t"
73 "fmov z1.s, #1.0\n\t"
74 "fcmeq p0.s, p0/z, z0.s, z1.s\n\t"
75 "uzp1 p0.b, p0.b, p0.b\n\t"
76 "uzp1 p0.b, p0.b, p0.b\n\t"
77 LOAD_PST1 ("x0"));
78
79 ASM_FUNCTION (passthru_pst1_x0_e,
80 struct pst1, (svfloat32_t, struct pst1, svint32_t,
81 svint32_t, svint32_t, svint32_t,
82 svint32_t, svint32_t, svint32_t),
83 "ptrue p0.b\n\t"
84 "fmov z24.s, #4.0\n\t"
85 "fcmeq p0.s, p0/z, z0.s, z24.s\n\t"
86 "cmpeq p0.s, p0/z, z1.s, #-4\n\t"
87 "cmpeq p0.s, p0/z, z2.s, #-9\n\t"
88 "cmpeq p0.s, p0/z, z3.s, #-14\n\t"
89 "cmpeq p0.s, p0/z, z4.s, #11\n\t"
90 "cmpeq p0.s, p0/z, z5.s, #10\n\t"
91 "cmpeq p0.s, p0/z, z6.s, #8\n\t"
92 "cmpeq p0.s, p0/z, z7.s, #-1\n\t"
93 "uzp1 p0.b, p0.b, p0.b\n\t"
94 "uzp1 p0.b, p0.b, p0.b\n\t"
95 LOAD_PST1 ("x0"));
96
97 ASM_FUNCTION (passthru_pst1_x7_a,
98 struct pst1, (svbool_t,
99 uint64_t, uint64_t, uint64_t, uint64_t,
100 uint64_t, uint64_t, uint64_t, struct pst1),
101 "add x0, x0, x1\n\t"
102 "add x2, x2, x3\n\t"
103 "add x4, x4, x5\n\t"
104 "add x0, x0, x2\n\t"
105 "add x4, x4, x6\n\t"
106 "add x0, x0, x4\n\t"
107 "add x7, x7, x0\n\t"
108 "sub x7, x7, #127\n\t"
109 "ptrue p0.b\n\t"
110 LOAD_PST1 ("x7"));
111
112 ASM_FUNCTION (passthru_pst1_x7_b,
113 struct pst1, (svbool_t, svbool_t, svbool_t, svbool_t,
114 svbool_t, svbool_t, svbool_t, svbool_t,
115 svbool_t, svbool_t, svbool_t,
116 struct pst1),
117 "and p0.b, p1/z, p0.b, p2.b\n\t"
118 "ldr p2, [x0]\n\t"
119 "and p0.b, p2/z, p0.b, p3.b\n\t"
120 "ldr p2, [x1]\n\t"
121 "ldr p3, [x2]\n\t"
122 "and p0.b, p2/z, p0.b, p3.b\n\t"
123 "ldr p2, [x3]\n\t"
124 "ldr p3, [x4]\n\t"
125 "and p0.b, p2/z, p0.b, p3.b\n\t"
126 "ldr p2, [x5]\n\t"
127 "ldr p3, [x6]\n\t"
128 "and p0.b, p2/z, p0.b, p3.b\n\t"
129 LOAD_PST1 ("x7"));
130
131 ASM_FUNCTION (passthru_pst1_sp_a,
132 struct pst1, (svbool_t, svbool_t, svbool_t, svbool_t,
133 svbool_t, svbool_t, svbool_t, svbool_t,
134 svbool_t, svbool_t, svbool_t, svbool_t,
135 struct pst1),
136 "and p0.b, p1/z, p0.b, p2.b\n\t"
137 "ldr p2, [x0]\n\t"
138 "and p0.b, p2/z, p0.b, p3.b\n\t"
139 "ldr p2, [x1]\n\t"
140 "ldr p3, [x2]\n\t"
141 "and p0.b, p2/z, p0.b, p3.b\n\t"
142 "ldr p2, [x3]\n\t"
143 "ldr p3, [x4]\n\t"
144 "and p0.b, p2/z, p0.b, p3.b\n\t"
145 "ldr p2, [x5]\n\t"
146 "ldr p3, [x6]\n\t"
147 "and p0.b, p2/z, p0.b, p3.b\n\t"
148 "ldr p2, [x7]\n\t"
149 "and p0.b, p2/z, p0.b, p0.b\n\t"
150 "ldr x5, [sp]\n\t"
151 #if __ILP32__
152 "uxtw x5, w5\n\t"
153 #endif
154 LOAD_PST1 ("x5"));
155
156 void
157 test_vl (svbool_t p0, unsigned int vl)
158 {
159 svbool_t pg = svptrue_b8 ();
160 if (svptest_any (pg, sveor_z (pg, p0, svwhilelt_b8 (0U, vl))))
161 __builtin_abort ();
162 }
163
164 void
165 test_pst1 (struct pst1 *x)
166 {
167 svbool_t pg = svptrue_b8 ();
168 if (svptest_any (pg, svcmpne (pg, x->v[0], 1))
169 || svptest_any (pg, svcmpne (pg, x->v[1], 4))
170 || svptest_any (pg, svcmpne (pg, x->v[2], 5))
171 || svptest_any (pg, svcmpne (pg, x->v[3], 9))
172 || svptest_any (pg, svcmpne (pg, x->v[4], 14))
173 || svptest_any (pg, svcmpne (pg, x->v[5], 23))
174 || svptest_any (pg, svcmpne (pg, x->v[6], 37))
175 || svptest_any (pg, svcmpne (pg, x->v[7], 60))
176 || svptest_any (pg, sveor_z (pg, x->p[0], svptrue_pat_b8 (SV_VL1)))
177 || svptest_any (pg, sveor_z (pg, x->p[1], svptrue_pat_b8 (SV_VL2)))
178 || svptest_any (pg, sveor_z (pg, x->p[2], svptrue_pat_b8 (SV_VL3)))
179 || svptest_any (pg, sveor_z (pg, x->p[3], svptrue_pat_b8 (SV_VL4))))
180 __builtin_abort ();
181 }
182
183 struct pst1
184 make_pst1 (void)
185 {
186 struct pst1 res;
187 res.v[0] = svdup_s8 (1);
188 res.v[1] = svdup_s8 (4);
189 res.v[2] = svdup_s8 (5);
190 res.v[3] = svdup_s8 (9);
191 res.v[4] = svdup_s8 (14);
192 res.v[5] = svdup_s8 (23);
193 res.v[6] = svdup_s8 (37);
194 res.v[7] = svdup_s8 (60);
195 res.p[0] = svptrue_pat_b8 (SV_VL1);
196 res.p[1] = svptrue_pat_b8 (SV_VL2);
197 res.p[2] = svptrue_pat_b8 (SV_VL3);
198 res.p[3] = svptrue_pat_b8 (SV_VL4);
199 return res;
200 }
201
202 struct pst1
203 deref_pst1 (struct pst1 *ptr)
204 {
205 return *ptr;
206 }
207
208 void
209 consume_pst1 (struct pst1 x)
210 {
211 test_pst1 (&x);
212 }
213
214 void
215 consume_pst1_x0_a (svbool_t p0, struct pst1 x0)
216 {
217 test_vl (p0, 11);
218 test_pst1 (&x0);
219 }
220
221 void
222 consume_pst1_x0_b (svbool_t p0, struct pst1 x0, uint64_t x1)
223 {
224 test_vl (p0, 10);
225 test_pst1 (&x0);
226 if (x1 != 42)
227 __builtin_abort ();
228 }
229
230 void
231 consume_pst1_x0_c (svbool_t p0, struct pst1 x0, svbool_t p1,
232 svbool_t p2, svbool_t p3, svbool_t x1)
233 {
234 test_vl (p0, 9);
235 test_pst1 (&x0);
236 test_vl (p1, 7);
237 test_vl (p2, 6);
238 test_vl (p3, 3);
239 test_vl (x1, 2);
240 }
241
242 void
243 consume_pst1_x0_d (svfloat32_t z0, struct pst1 x0)
244 {
245 svbool_t pg = svptrue_b8 ();
246 if (svptest_any (pg, svcmpne (pg, z0, 1.0)))
247 __builtin_abort ();
248 test_pst1 (&x0);
249 }
250
251 void
252 consume_pst1_x0_e (svfloat32_t z0, struct pst1 x0,
253 svint32_t z1, svint32_t z2, svint32_t z3, svint32_t z4,
254 svint32_t z5, svint32_t z6, svint32_t z7)
255 {
256 svbool_t pg = svptrue_b8 ();
257 if (svptest_any (pg, svcmpne (pg, z0, 4.0))
258 || svptest_any (pg, svcmpne (pg, z1, -4))
259 || svptest_any (pg, svcmpne (pg, z2, -9))
260 || svptest_any (pg, svcmpne (pg, z3, -14))
261 || svptest_any (pg, svcmpne (pg, z4, 11))
262 || svptest_any (pg, svcmpne (pg, z5, 10))
263 || svptest_any (pg, svcmpne (pg, z6, 8))
264 || svptest_any (pg, svcmpne (pg, z7, -1)))
265 __builtin_abort ();
266 test_pst1 (&x0);
267 }
268
269 void
270 consume_pst1_x7_a (svbool_t p0, uint64_t x0, uint64_t x1, uint64_t x2,
271 uint64_t x3, uint64_t x4, uint64_t x5, uint64_t x6,
272 struct pst1 x7)
273 {
274 test_vl (p0, __ARM_FEATURE_SVE_BITS);
275 if (x0 != 1
276 || x1 != 2
277 || x2 != 4
278 || x3 != 8
279 || x4 != 16
280 || x5 != 32
281 || x6 != 64)
282 __builtin_abort ();
283 test_pst1 (&x7);
284 }
285
286 void
287 consume_pst1_x7_b (svbool_t p0, svbool_t p1, svbool_t p2, svbool_t p3,
288 svbool_t x0, svbool_t x1, svbool_t x2, svbool_t x3,
289 svbool_t x4, svbool_t x5, svbool_t x6, struct pst1 x7)
290 {
291 test_vl (p0, __ARM_FEATURE_SVE_BITS);
292 test_vl (p1, __ARM_FEATURE_SVE_BITS);
293 test_vl (p2, __ARM_FEATURE_SVE_BITS);
294 test_vl (p3, __ARM_FEATURE_SVE_BITS);
295 test_vl (x0, __ARM_FEATURE_SVE_BITS);
296 test_vl (x1, __ARM_FEATURE_SVE_BITS);
297 test_vl (x2, __ARM_FEATURE_SVE_BITS);
298 test_vl (x3, __ARM_FEATURE_SVE_BITS);
299 test_vl (x4, __ARM_FEATURE_SVE_BITS);
300 test_vl (x5, __ARM_FEATURE_SVE_BITS);
301 test_vl (x6, __ARM_FEATURE_SVE_BITS);
302 test_pst1 (&x7);
303 }
304
305 void
306 consume_pst1_sp_a (svbool_t p0, svbool_t p1, svbool_t p2, svbool_t p3,
307 svbool_t x0, svbool_t x1, svbool_t x2, svbool_t x3,
308 svbool_t x4, svbool_t x5, svbool_t x6, svbool_t x7,
309 struct pst1 sp)
310 {
311 test_vl (p0, __ARM_FEATURE_SVE_BITS);
312 test_vl (p1, __ARM_FEATURE_SVE_BITS);
313 test_vl (p2, __ARM_FEATURE_SVE_BITS);
314 test_vl (p3, __ARM_FEATURE_SVE_BITS);
315 test_vl (x0, __ARM_FEATURE_SVE_BITS);
316 test_vl (x1, __ARM_FEATURE_SVE_BITS);
317 test_vl (x2, __ARM_FEATURE_SVE_BITS);
318 test_vl (x3, __ARM_FEATURE_SVE_BITS);
319 test_vl (x4, __ARM_FEATURE_SVE_BITS);
320 test_vl (x5, __ARM_FEATURE_SVE_BITS);
321 test_vl (x6, __ARM_FEATURE_SVE_BITS);
322 test_vl (x7, __ARM_FEATURE_SVE_BITS);
323 test_pst1 (&sp);
324 }
325
326 int
327 main (void)
328 {
329 svbool_t pg = svptrue_b8 ();
330 svbool_t vl2 = svptrue_pat_b8 (SV_VL2);
331 svbool_t vl3 = svptrue_pat_b8 (SV_VL3);
332 svbool_t vl6 = svptrue_pat_b8 (SV_VL6);
333 svbool_t vl7 = svptrue_pat_b8 (SV_VL7);
334 svbool_t vl9 = svwhilelt_b8 (0, 9);
335 svbool_t vl10 = svwhilelt_b8 (0, 10);
336 svbool_t vl11 = svwhilelt_b8 (0, 11);
337
338 CLEANSE; struct pst1 res1 = make_pst1_asm ();
339 CLEANSE; test_pst1 (&res1);
340 CLEANSE; consume_pst1 (make_pst1 ());
341
342 CLEANSE; struct pst1 res2 = deref_pst1 (&res1);
343 CLEANSE; test_pst1 (&res2);
344 CLEANSE; consume_pst1 (res2);
345
346 CLEANSE; struct pst1 res3 = passthru_pst1_x0_a (vl11, res1);
347 CLEANSE; test_pst1 (&res3);
348 CLEANSE; consume_pst1_x0_a (vl11, res3);
349
350 CLEANSE; struct pst1 res4 = passthru_pst1_x0_b (vl10, res1, 42);
351 CLEANSE; test_pst1 (&res4);
352 CLEANSE; consume_pst1_x0_b (vl10, res4, 42);
353
354 CLEANSE; struct pst1 res5 = passthru_pst1_x0_c (vl9, res1, vl7,
355 vl6, vl3, vl2);
356 CLEANSE; test_pst1 (&res5);
357 CLEANSE; consume_pst1_x0_c (vl9, res5, vl7,
358 vl6, vl3, vl2);
359
360 CLEANSE; struct pst1 res6 = passthru_pst1_x0_d (svdup_f32 (1.0), res1);
361 CLEANSE; test_pst1 (&res6);
362 CLEANSE; consume_pst1_x0_d (svdup_f32 (1.0), res6);
363
364 CLEANSE; struct pst1 res7 = passthru_pst1_x0_e (svdup_f32 (4.0), res1,
365 svdup_s32 (-4),
366 svdup_s32 (-9),
367 svdup_s32 (-14),
368 svdup_s32 (11),
369 svdup_s32 (10),
370 svdup_s32 (8),
371 svdup_s32 (-1));
372 CLEANSE; test_pst1 (&res7);
373 CLEANSE; consume_pst1_x0_e (svdup_f32 (4.0), res1,
374 svdup_s32 (-4),
375 svdup_s32 (-9),
376 svdup_s32 (-14),
377 svdup_s32 (11),
378 svdup_s32 (10),
379 svdup_s32 (8),
380 svdup_s32 (-1));
381
382 CLEANSE; struct pst1 res8 = passthru_pst1_x7_a (pg, 1, 2, 4, 8,
383 16, 32, 64, res1);
384 CLEANSE; test_pst1 (&res8);
385 CLEANSE; consume_pst1_x7_a (pg, 1, 2, 4, 8,
386 16, 32, 64, res8);
387
388 CLEANSE; struct pst1 res9 = passthru_pst1_x7_b (pg, pg, pg, pg,
389 pg, pg, pg, pg,
390 pg, pg, pg, res1);
391 CLEANSE; test_pst1 (&res9);
392 CLEANSE; consume_pst1_x7_b (pg, pg, pg, pg,
393 pg, pg, pg, pg,
394 pg, pg, pg, res9);
395
396 CLEANSE; struct pst1 res10 = passthru_pst1_sp_a (pg, pg, pg, pg,
397 pg, pg, pg, pg,
398 pg, pg, pg, pg, res1);
399 CLEANSE; test_pst1 (&res10);
400 CLEANSE; consume_pst1_sp_a (pg, pg, pg, pg,
401 pg, pg, pg, pg,
402 pg, pg, pg, pg, res10);
403
404 return 0;
405 }