Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vclz.c

raw
1 #include <arm_neon.h>
2 #include "arm-neon-ref.h"
3 #include "compute-ref-data.h"
4
5 /* Expected results. */
6 VECT_VAR_DECL(expected,int,8,8) [] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
7 VECT_VAR_DECL(expected,int,16,4) [] = { 0x3, 0x3, 0x3, 0x3 };
8 VECT_VAR_DECL(expected,int,32,2) [] = { 0x11, 0x11 };
9 VECT_VAR_DECL(expected,uint,8,8) [] = { 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2 };
10 VECT_VAR_DECL(expected,uint,16,4) [] = { 0x0, 0x0, 0x0, 0x0 };
11 VECT_VAR_DECL(expected,uint,32,2) [] = { 0x5, 0x5 };
12 VECT_VAR_DECL(expected,int,8,16) [] = { 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2,
13 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2 };
14 VECT_VAR_DECL(expected,int,16,8) [] = { 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3 };
15 VECT_VAR_DECL(expected,int,32,4) [] = { 0x3, 0x3, 0x3, 0x3 };
16 VECT_VAR_DECL(expected,uint,8,16) [] = { 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3,
17 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3 };
18 VECT_VAR_DECL(expected,uint,16,8) [] = { 0xd, 0xd, 0xd, 0xd,
19 0xd, 0xd, 0xd, 0xd };
20 VECT_VAR_DECL(expected,uint,32,4) [] = { 0x1f, 0x1f, 0x1f, 0x1f };
21
22
23 /* Expected results with input=0. */
24 VECT_VAR_DECL(expected_with_0,int,8,8) [] = { 0x8, 0x8, 0x8, 0x8,
25 0x8, 0x8, 0x8, 0x8 };
26 VECT_VAR_DECL(expected_with_0,int,16,4) [] = { 0x10, 0x10, 0x10, 0x10 };
27 VECT_VAR_DECL(expected_with_0,int,32,2) [] = { 0x20, 0x20 };
28 VECT_VAR_DECL(expected_with_0,uint,8,8) [] = { 0x8, 0x8, 0x8, 0x8,
29 0x8, 0x8, 0x8, 0x8 };
30 VECT_VAR_DECL(expected_with_0,uint,16,4) [] = { 0x10, 0x10, 0x10, 0x10 };
31 VECT_VAR_DECL(expected_with_0,uint,32,2) [] = { 0x20, 0x20 };
32 VECT_VAR_DECL(expected_with_0,int,8,16) [] = { 0x8, 0x8, 0x8, 0x8,
33 0x8, 0x8, 0x8, 0x8,
34 0x8, 0x8, 0x8, 0x8,
35 0x8, 0x8, 0x8, 0x8 };
36 VECT_VAR_DECL(expected_with_0,int,16,8) [] = { 0x10, 0x10, 0x10, 0x10,
37 0x10, 0x10, 0x10, 0x10 };
38 VECT_VAR_DECL(expected_with_0,int,32,4) [] = { 0x20, 0x20, 0x20, 0x20 };
39 VECT_VAR_DECL(expected_with_0,uint,8,16) [] = { 0x8, 0x8, 0x8, 0x8,
40 0x8, 0x8, 0x8, 0x8,
41 0x8, 0x8, 0x8, 0x8,
42 0x8, 0x8, 0x8, 0x8 };
43 VECT_VAR_DECL(expected_with_0,uint,16,8) [] = { 0x10, 0x10, 0x10, 0x10,
44 0x10, 0x10, 0x10, 0x10 };
45 VECT_VAR_DECL(expected_with_0,uint,32,4) [] = { 0x20, 0x20, 0x20, 0x20 };
46
47 #define INSN_NAME vclz
48 #define TEST_MSG "VCLZ/VCLZQ"
49
50 #define FNNAME1(NAME) void exec_ ## NAME (void)
51 #define FNNAME(NAME) FNNAME1(NAME)
52
53 FNNAME (INSN_NAME)
54 {
55 /* Basic test: y=vclz(x), then store the result. */
56 #define TEST_UNARY_OP1(INSN, Q, T1, T2, W, N) \
57 VECT_VAR(vector_res, T1, W, N) = \
58 INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N)); \
59 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
60
61 #define TEST_UNARY_OP(INSN, Q, T1, T2, W, N) \
62 TEST_UNARY_OP1(INSN, Q, T1, T2, W, N) \
63
64 /* No need for 64 bits variants */
65 DECL_VARIABLE(vector, int, 8, 8);
66 DECL_VARIABLE(vector, int, 16, 4);
67 DECL_VARIABLE(vector, int, 32, 2);
68 DECL_VARIABLE(vector, uint, 8, 8);
69 DECL_VARIABLE(vector, uint, 16, 4);
70 DECL_VARIABLE(vector, uint, 32, 2);
71 DECL_VARIABLE(vector, int, 8, 16);
72 DECL_VARIABLE(vector, int, 16, 8);
73 DECL_VARIABLE(vector, int, 32, 4);
74 DECL_VARIABLE(vector, uint, 8, 16);
75 DECL_VARIABLE(vector, uint, 16, 8);
76 DECL_VARIABLE(vector, uint, 32, 4);
77
78 DECL_VARIABLE(vector_res, int, 8, 8);
79 DECL_VARIABLE(vector_res, int, 16, 4);
80 DECL_VARIABLE(vector_res, int, 32, 2);
81 DECL_VARIABLE(vector_res, uint, 8, 8);
82 DECL_VARIABLE(vector_res, uint, 16, 4);
83 DECL_VARIABLE(vector_res, uint, 32, 2);
84 DECL_VARIABLE(vector_res, int, 8, 16);
85 DECL_VARIABLE(vector_res, int, 16, 8);
86 DECL_VARIABLE(vector_res, int, 32, 4);
87 DECL_VARIABLE(vector_res, uint, 8, 16);
88 DECL_VARIABLE(vector_res, uint, 16, 8);
89 DECL_VARIABLE(vector_res, uint, 32, 4);
90
91 clean_results ();
92
93 /* Fill input vector with arbitrary values. */
94 VDUP(vector, , int, s, 8, 8, 0x84);
95 VDUP(vector, , int, s, 16, 4, 0x1234);
96 VDUP(vector, , int, s, 32, 2, 0x5678);
97 VDUP(vector, , uint, u, 8, 8, 0x34);
98 VDUP(vector, , uint, u, 16, 4, 0x8234);
99 VDUP(vector, , uint, u, 32, 2, 0x7654321);
100 VDUP(vector, q, int, s, 8, 16, 0x34);
101 VDUP(vector, q, int, s, 16, 8, 0x1234);
102 VDUP(vector, q, int, s, 32, 4, 0x12345678);
103 VDUP(vector, q, uint, u, 8, 16, 0x13);
104 VDUP(vector, q, uint, u, 16, 8, 0x4);
105 VDUP(vector, q, uint, u, 32, 4, 0x1);
106
107 /* Apply a unary operator named INSN_NAME. */
108 TEST_UNARY_OP(INSN_NAME, , int, s, 8, 8);
109 TEST_UNARY_OP(INSN_NAME, , int, s, 16, 4);
110 TEST_UNARY_OP(INSN_NAME, , int, s, 32, 2);
111 TEST_UNARY_OP(INSN_NAME, , uint, u, 8, 8);
112 TEST_UNARY_OP(INSN_NAME, , uint, u, 16, 4);
113 TEST_UNARY_OP(INSN_NAME, , uint, u, 32, 2);
114 TEST_UNARY_OP(INSN_NAME, q, int, s, 8, 16);
115 TEST_UNARY_OP(INSN_NAME, q, int, s, 16, 8);
116 TEST_UNARY_OP(INSN_NAME, q, int, s, 32, 4);
117 TEST_UNARY_OP(INSN_NAME, q, uint, u, 8, 16);
118 TEST_UNARY_OP(INSN_NAME, q, uint, u, 16, 8);
119 TEST_UNARY_OP(INSN_NAME, q, uint, u, 32, 4);
120
121 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected, "");
122 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, "");
123 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, "");
124 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected, "");
125 CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected, "");
126 CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected, "");
127 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, "");
128 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, "");
129 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, "");
130 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, "");
131 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, "");
132 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, "");
133
134 /* Test with zero as input. */
135 VDUP(vector, , int, s, 8, 8, 0);
136 VDUP(vector, , int, s, 16, 4, 0);
137 VDUP(vector, , int, s, 32, 2, 0);
138 VDUP(vector, , uint, u, 8, 8, 0);
139 VDUP(vector, , uint, u, 16, 4, 0);
140 VDUP(vector, , uint, u, 32, 2, 0);
141 VDUP(vector, q, int, s, 8, 16, 0);
142 VDUP(vector, q, int, s, 16, 8, 0);
143 VDUP(vector, q, int, s, 32, 4, 0);
144 VDUP(vector, q, uint, u, 8, 16, 0);
145 VDUP(vector, q, uint, u, 16, 8, 0);
146 VDUP(vector, q, uint, u, 32, 4, 0);
147
148 /* Apply a unary operator named INSN_NAME. */
149 TEST_UNARY_OP(INSN_NAME, , int, s, 8, 8);
150 TEST_UNARY_OP(INSN_NAME, , int, s, 16, 4);
151 TEST_UNARY_OP(INSN_NAME, , int, s, 32, 2);
152 TEST_UNARY_OP(INSN_NAME, , uint, u, 8, 8);
153 TEST_UNARY_OP(INSN_NAME, , uint, u, 16, 4);
154 TEST_UNARY_OP(INSN_NAME, , uint, u, 32, 2);
155 TEST_UNARY_OP(INSN_NAME, q, int, s, 8, 16);
156 TEST_UNARY_OP(INSN_NAME, q, int, s, 16, 8);
157 TEST_UNARY_OP(INSN_NAME, q, int, s, 32, 4);
158 TEST_UNARY_OP(INSN_NAME, q, uint, u, 8, 16);
159 TEST_UNARY_OP(INSN_NAME, q, uint, u, 16, 8);
160 TEST_UNARY_OP(INSN_NAME, q, uint, u, 32, 4);
161
162 #define MSG_ZERO " (input=0)"
163 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_with_0, MSG_ZERO);
164 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_with_0, MSG_ZERO);
165 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_with_0, MSG_ZERO);
166 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_with_0, MSG_ZERO);
167 CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected_with_0, MSG_ZERO);
168 CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_with_0, MSG_ZERO);
169 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_with_0, MSG_ZERO);
170 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_with_0, MSG_ZERO);
171 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_with_0, MSG_ZERO);
172 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_with_0, MSG_ZERO);
173 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_with_0, MSG_ZERO);
174 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_with_0, MSG_ZERO);
175 }
176
177 int main (void)
178 {
179 exec_vclz ();
180 return 0;
181 }