Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/vec-rot-exec.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3
4 typedef char __attribute__ ((vector_size (16))) v16qi;
5 typedef unsigned short __attribute__ ((vector_size (16))) v8hi;
6 typedef unsigned int __attribute__ ((vector_size (16))) v4si;
7 typedef unsigned long long __attribute__ ((vector_size (16))) v2di;
8 typedef char __attribute__ ((vector_size (8))) v8qi;
9 typedef unsigned short __attribute__ ((vector_size (8))) v4hi;
10 typedef unsigned int __attribute__ ((vector_size (8))) v2si;
11 #define VEC_ELTS(X) (sizeof (X) / (sizeof (X[0])))
12
13 static const char __attribute__ ((aligned (16))) *str = "abcdefghijklmnopqrstuvwxyz";
14
15 unsigned long long
16 __attribute__((noipa,noinline))
17 rot_64_one (unsigned long long x, unsigned amt)
18 {
19 return (x << amt) | (x >> (64 - amt));
20 }
21 unsigned int
22 __attribute__((noipa,noinline))
23 rot_32_one (unsigned int x, unsigned amt)
24 {
25 return (x << amt) | (x >> (32 - amt));
26 }
27
28 unsigned short
29 __attribute__((noipa,noinline))
30 rot_16_one (unsigned short x, unsigned short amt)
31 {
32 return (x << amt) | (x >> (16 - amt));
33 }
34
35
36 #define ROTFUNC(M,S,A) \
37 M \
38 __attribute__((noipa,noinline)) \
39 rot_##M##_##S##_##A (M x) \
40 { \
41 return (x << A) | (x >> (S - A)); \
42 } \
43 \
44 void \
45 test_rot_##M##_##S##_##A (void) \
46 { \
47 M vec = *(M *)str; \
48 M res = rot_##M##_##S##_##A (vec); \
49 for (__SIZE_TYPE__ i = 0; i < VEC_ELTS (vec); i++) \
50 if (res[i] != rot_##S##_one (vec[i], A)) \
51 __builtin_abort (); \
52 }
53
54 ROTFUNC (v2di, 64, 56)
55 ROTFUNC (v2di, 64, 48)
56 ROTFUNC (v2di, 64, 40)
57 ROTFUNC (v2di, 64, 32)
58 ROTFUNC (v2di, 64, 24)
59 ROTFUNC (v2di, 64, 16)
60 ROTFUNC (v2di, 64, 8)
61
62 ROTFUNC (v4si, 32, 24)
63 ROTFUNC (v4si, 32, 16)
64 ROTFUNC (v4si, 32, 8)
65
66 ROTFUNC (v8hi, 16, 8)
67
68 ROTFUNC (v2si, 32, 24)
69 ROTFUNC (v2si, 32, 16)
70 ROTFUNC (v2si, 32, 8)
71
72 ROTFUNC (v4hi, 16, 8)
73
74 #define CALL_TEST(M,S,A) test_rot_##M##_##S##_##A ()
75
76 int
77 main (void)
78 {
79 CALL_TEST (v2di, 64, 56);
80 CALL_TEST (v2di, 64, 48);
81 CALL_TEST (v2di, 64, 40);
82 CALL_TEST (v2di, 64, 32);
83 CALL_TEST (v2di, 64, 24);
84 CALL_TEST (v2di, 64, 16);
85 CALL_TEST (v2di, 64, 8);
86
87 CALL_TEST (v4si, 32, 24);
88 CALL_TEST (v4si, 32, 16);
89 CALL_TEST (v4si, 32, 8);
90
91 CALL_TEST (v8hi, 16, 8);
92
93 CALL_TEST (v2si, 32, 24);
94 CALL_TEST (v2si, 32, 16);
95 CALL_TEST (v2si, 32, 8);
96
97 CALL_TEST (v4hi, 16, 8);
98
99 return 0;
100 }
101