Debian Codegraph @

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

raw
1 #include <arm_neon.h>
2 #include "arm-neon-ref.h"
3 #include "compute-ref-data.h"
4
5 /* Expected results for vtbl1. */
6 VECT_VAR_DECL(expected_vtbl1,int,8,8) [] = { 0x0, 0xf2, 0xf2, 0xf2,
7 0x0, 0x0, 0xf2, 0xf2 };
8 VECT_VAR_DECL(expected_vtbl1,uint,8,8) [] = { 0x0, 0xf3, 0xf3, 0xf3,
9 0x0, 0x0, 0xf3, 0xf3 };
10 VECT_VAR_DECL(expected_vtbl1,poly,8,8) [] = { 0x0, 0xf3, 0xf3, 0xf3,
11 0x0, 0x0, 0xf3, 0xf3 };
12 #if MFLOAT8_SUPPORTED
13 VECT_VAR_DECL(expected_vtbl1,hmfloat,8,8) [] = { 0x0, 0xf3, 0xf3, 0xf3,
14 0x0, 0x0, 0xf3, 0xf3 };
15 #endif
16
17 /* Expected results for vtbl2. */
18 VECT_VAR_DECL(expected_vtbl2,int,8,8) [] = { 0xf6, 0xf3, 0xf3, 0xf3,
19 0x0, 0x0, 0xf3, 0xf3 };
20 VECT_VAR_DECL(expected_vtbl2,uint,8,8) [] = { 0xf6, 0xf5, 0xf5, 0xf5,
21 0x0, 0x0, 0xf5, 0xf5 };
22 VECT_VAR_DECL(expected_vtbl2,poly,8,8) [] = { 0xf6, 0xf5, 0xf5, 0xf5,
23 0x0, 0x0, 0xf5, 0xf5 };
24 #if MFLOAT8_SUPPORTED
25 VECT_VAR_DECL(expected_vtbl2,hmfloat,8,8) [] = { 0xf6, 0xf5, 0xf5, 0xf5,
26 0x0, 0x0, 0xf5, 0xf5 };
27 #endif
28
29 /* Expected results for vtbl3. */
30 VECT_VAR_DECL(expected_vtbl3,int,8,8) [] = { 0xf8, 0xf4, 0xf4, 0xf4,
31 0xff, 0x0, 0xf4, 0xf4 };
32 VECT_VAR_DECL(expected_vtbl3,uint,8,8) [] = { 0xf8, 0xf7, 0xf7, 0xf7,
33 0xff, 0x0, 0xf7, 0xf7 };
34 VECT_VAR_DECL(expected_vtbl3,poly,8,8) [] = { 0xf8, 0xf7, 0xf7, 0xf7,
35 0xff, 0x0, 0xf7, 0xf7 };
36 #if MFLOAT8_SUPPORTED
37 VECT_VAR_DECL(expected_vtbl3,hmfloat,8,8) [] = { 0xf8, 0xf7, 0xf7, 0xf7,
38 0xff, 0x0, 0xf7, 0xf7 };
39 #endif
40
41 /* Expected results for vtbl4. */
42 VECT_VAR_DECL(expected_vtbl4,int,8,8) [] = { 0xfa, 0xf5, 0xf5, 0xf5,
43 0x3, 0x0, 0xf5, 0xf5 };
44 VECT_VAR_DECL(expected_vtbl4,uint,8,8) [] = { 0xfa, 0xf9, 0xf9, 0xf9,
45 0x3, 0x0, 0xf9, 0xf9 };
46 VECT_VAR_DECL(expected_vtbl4,poly,8,8) [] = { 0xfa, 0xf9, 0xf9, 0xf9,
47 0x3, 0x0, 0xf9, 0xf9 };
48 #if MFLOAT8_SUPPORTED
49 VECT_VAR_DECL(expected_vtbl4,hmfloat,8,8) [] = { 0xfa, 0xf9, 0xf9, 0xf9,
50 0x3, 0x0, 0xf9, 0xf9 };
51 #endif
52
53 /* Expected results for vtbx1. */
54 VECT_VAR_DECL(expected_vtbx1,int,8,8) [] = { 0x33, 0xf2, 0xf2, 0xf2,
55 0x33, 0x33, 0xf2, 0xf2 };
56 VECT_VAR_DECL(expected_vtbx1,uint,8,8) [] = { 0xcc, 0xf3, 0xf3, 0xf3,
57 0xcc, 0xcc, 0xf3, 0xf3 };
58 VECT_VAR_DECL(expected_vtbx1,poly,8,8) [] = { 0xcc, 0xf3, 0xf3, 0xf3,
59 0xcc, 0xcc, 0xf3, 0xf3 };
60 #if MFLOAT8_SUPPORTED
61 VECT_VAR_DECL(expected_vtbx1,hmfloat,8,8) [] = { 0x55, 0xf3, 0xf3, 0xf3,
62 0x55, 0x55, 0xf3, 0xf3 };
63 #endif
64
65 /* Expected results for vtbx2. */
66 VECT_VAR_DECL(expected_vtbx2,int,8,8) [] = { 0xf6, 0xf3, 0xf3, 0xf3,
67 0x33, 0x33, 0xf3, 0xf3 };
68 VECT_VAR_DECL(expected_vtbx2,uint,8,8) [] = { 0xf6, 0xf5, 0xf5, 0xf5,
69 0xcc, 0xcc, 0xf5, 0xf5 };
70 VECT_VAR_DECL(expected_vtbx2,poly,8,8) [] = { 0xf6, 0xf5, 0xf5, 0xf5,
71 0xcc, 0xcc, 0xf5, 0xf5 };
72 #if MFLOAT8_SUPPORTED
73 VECT_VAR_DECL(expected_vtbx2,hmfloat,8,8) [] = { 0xf6, 0xf5, 0xf5, 0xf5,
74 0x55, 0x55, 0xf5, 0xf5 };
75 #endif
76
77 /* Expected results for vtbx3. */
78 VECT_VAR_DECL(expected_vtbx3,int,8,8) [] = { 0xf8, 0xf4, 0xf4, 0xf4,
79 0xff, 0x33, 0xf4, 0xf4 };
80 VECT_VAR_DECL(expected_vtbx3,uint,8,8) [] = { 0xf8, 0xf7, 0xf7, 0xf7,
81 0xff, 0xcc, 0xf7, 0xf7 };
82 VECT_VAR_DECL(expected_vtbx3,poly,8,8) [] = { 0xf8, 0xf7, 0xf7, 0xf7,
83 0xff, 0xcc, 0xf7, 0xf7 };
84 #if MFLOAT8_SUPPORTED
85 VECT_VAR_DECL(expected_vtbx3,hmfloat,8,8) [] = { 0xf8, 0xf7, 0xf7, 0xf7,
86 0xff, 0x55, 0xf7, 0xf7 };
87 #endif
88
89 /* Expected results for vtbx4. */
90 VECT_VAR_DECL(expected_vtbx4,int,8,8) [] = { 0xfa, 0xf5, 0xf5, 0xf5,
91 0x3, 0x33, 0xf5, 0xf5 };
92 VECT_VAR_DECL(expected_vtbx4,uint,8,8) [] = { 0xfa, 0xf9, 0xf9, 0xf9,
93 0x3, 0xcc, 0xf9, 0xf9 };
94 VECT_VAR_DECL(expected_vtbx4,poly,8,8) [] = { 0xfa, 0xf9, 0xf9, 0xf9,
95 0x3, 0xcc, 0xf9, 0xf9 };
96 #if MFLOAT8_SUPPORTED
97 VECT_VAR_DECL(expected_vtbx4,hmfloat,8,8) [] = { 0xfa, 0xf9, 0xf9, 0xf9,
98 0x3, 0x55, 0xf9, 0xf9 };
99 #endif
100
101 void exec_vtbX (void)
102 {
103 int i;
104
105 /* In this case, input variables are arrays of vectors. */
106 #define DECL_VTBX(T1, W, N, X) \
107 VECT_ARRAY_TYPE(T1, W, N, X) VECT_ARRAY_VAR(table_vector, T1, W, N, X)
108
109 /* The vtbl1 variant is different from vtbl{2,3,4} because it takes a
110 vector as 1st param, instead of an array of vectors. */
111 #define TEST_VTBL1(T1, T2, T3, W, N) \
112 VECT_VAR(table_vector, T1, W, N) = \
113 vld1##_##T2##W((T1##W##_t *)lookup_table); \
114 \
115 VECT_VAR(vector_res, T1, W, N) = \
116 vtbl1_##T2##W(VECT_VAR(table_vector, T1, W, N), \
117 VECT_VAR(vector, T3, W, N)); \
118 vst1_##T2##W(VECT_VAR(result, T1, W, N), \
119 VECT_VAR(vector_res, T1, W, N));
120
121 #define TEST_VTBLX(T1, T2, T3, W, N, X) \
122 VECT_ARRAY_VAR(table_vector, T1, W, N, X) = \
123 vld##X##_##T2##W((T1##W##_t *)lookup_table); \
124 \
125 VECT_VAR(vector_res, T1, W, N) = \
126 vtbl##X##_##T2##W(VECT_ARRAY_VAR(table_vector, T1, W, N, X), \
127 VECT_VAR(vector, T3, W, N)); \
128 vst1_##T2##W(VECT_VAR(result, T1, W, N), \
129 VECT_VAR(vector_res, T1, W, N));
130
131 /* We need to define a lookup table. */
132 uint8_t lookup_table[32];
133
134 DECL_VARIABLE(vector, int, 8, 8);
135 DECL_VARIABLE(vector, uint, 8, 8);
136 DECL_VARIABLE(vector, poly, 8, 8);
137 DECL_VARIABLE(vector_res, int, 8, 8);
138 DECL_VARIABLE(vector_res, uint, 8, 8);
139 DECL_VARIABLE(vector_res, poly, 8, 8);
140 MFLOAT8_ONLY(DECL_VARIABLE(vector_res, mfloat, 8, 8));
141
142 /* For vtbl1. */
143 DECL_VARIABLE(table_vector, int, 8, 8);
144 DECL_VARIABLE(table_vector, uint, 8, 8);
145 DECL_VARIABLE(table_vector, poly, 8, 8);
146 MFLOAT8_ONLY(DECL_VARIABLE(table_vector, mfloat, 8, 8));
147
148 /* For vtbx*. */
149 DECL_VARIABLE(default_vector, int, 8, 8);
150 DECL_VARIABLE(default_vector, uint, 8, 8);
151 DECL_VARIABLE(default_vector, poly, 8, 8);
152 MFLOAT8_ONLY(DECL_VARIABLE(default_vector, mfloat, 8, 8));
153
154 /* We need only 8 bits variants. */
155 #define DECL_ALL_VTBLX(X) \
156 DECL_VTBX(int, 8, 8, X); \
157 DECL_VTBX(uint, 8, 8, X); \
158 DECL_VTBX(poly, 8, 8, X); \
159 MFLOAT8_ONLY(DECL_VTBX(mfloat, 8, 8, X))
160
161 #define TEST_ALL_VTBL1() \
162 TEST_VTBL1(int, s, int, 8, 8); \
163 TEST_VTBL1(uint, u, uint, 8, 8); \
164 TEST_VTBL1(poly, p, uint, 8, 8); \
165 MFLOAT8_ONLY(TEST_VTBL1(mfloat, mf, uint, 8, 8))
166
167 #define TEST_ALL_VTBLX(X) \
168 TEST_VTBLX(int, s, int, 8, 8, X); \
169 TEST_VTBLX(uint, u, uint, 8, 8, X); \
170 TEST_VTBLX(poly, p, uint, 8, 8, X); \
171 MFLOAT8_ONLY(TEST_VTBLX(mfloat, mf, uint, 8, 8, X))
172
173 /* Declare the temporary buffers / variables. */
174 DECL_ALL_VTBLX(2);
175 DECL_ALL_VTBLX(3);
176 DECL_ALL_VTBLX(4);
177
178 /* Fill the lookup table. */
179 for (i=0; i<32; i++) {
180 lookup_table[i] = i-15;
181 }
182
183 /* Choose init value arbitrarily, will be used as table index. */
184 VDUP(vector, , int, s, 8, 8, 1);
185 VDUP(vector, , uint, u, 8, 8, 2);
186 VDUP(vector, , poly, p, 8, 8, 2);
187
188 /* To ensure coverage, add some indexes larger than 8, 16 and 32
189 except: lane 0 (by 10), lane 4 (by 20) and lane 5 (by 40). */
190 VSET_LANE(vector, , int, s, 8, 8, 0, 10);
191 VSET_LANE(vector, , int, s, 8, 8, 4, 20);
192 VSET_LANE(vector, , int, s, 8, 8, 5, 40);
193 VSET_LANE(vector, , uint, u, 8, 8, 0, 10);
194 VSET_LANE(vector, , uint, u, 8, 8, 4, 20);
195 VSET_LANE(vector, , uint, u, 8, 8, 5, 40);
196 VSET_LANE(vector, , poly, p, 8, 8, 0, 10);
197 VSET_LANE(vector, , poly, p, 8, 8, 4, 20);
198 VSET_LANE(vector, , poly, p, 8, 8, 5, 40);
199
200
201 /* Check vtbl1. */
202 clean_results ();
203 #define TEST_MSG "VTBL1"
204 TEST_ALL_VTBL1();
205
206 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vtbl1, "");
207 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vtbl1, "");
208 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vtbl1, "");
209 MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 8, PRIx8, expected_vtbl1, ""));
210
211 /* Check vtbl2. */
212 clean_results ();
213 #undef TEST_MSG
214 #define TEST_MSG "VTBL2"
215 TEST_ALL_VTBLX(2);
216
217 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vtbl2, "");
218 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vtbl2, "");
219 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vtbl2, "");
220 MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 8, PRIx8, expected_vtbl2, ""));
221
222 /* Check vtbl3. */
223 clean_results ();
224 #undef TEST_MSG
225 #define TEST_MSG "VTBL3"
226 TEST_ALL_VTBLX(3);
227
228 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vtbl3, "");
229 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vtbl3, "");
230 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vtbl3, "");
231 MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 8, PRIx8, expected_vtbl3, ""));
232
233 /* Check vtbl4. */
234 clean_results ();
235 #undef TEST_MSG
236 #define TEST_MSG "VTBL4"
237 TEST_ALL_VTBLX(4);
238
239 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vtbl4, "");
240 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vtbl4, "");
241 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vtbl4, "");
242 MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 8, PRIx8, expected_vtbl4, ""));
243
244
245 /* Now test VTBX. */
246
247 /* The vtbx1 variant is different from vtbx{2,3,4} because it takes a
248 vector as 1st param, instead of an array of vectors. */
249 #define TEST_VTBX1(T1, T2, T3, W, N) \
250 VECT_VAR(table_vector, T1, W, N) = \
251 vld1##_##T2##W((T1##W##_t *)lookup_table); \
252 \
253 VECT_VAR(vector_res, T1, W, N) = \
254 vtbx1_##T2##W(VECT_VAR(default_vector, T1, W, N), \
255 VECT_VAR(table_vector, T1, W, N), \
256 VECT_VAR(vector, T3, W, N)); \
257 vst1_##T2##W(VECT_VAR(result, T1, W, N), \
258 VECT_VAR(vector_res, T1, W, N));
259
260 #define TEST_VTBXX(T1, T2, T3, W, N, X) \
261 VECT_ARRAY_VAR(table_vector, T1, W, N, X) = \
262 vld##X##_##T2##W((T1##W##_t *)lookup_table); \
263 \
264 VECT_VAR(vector_res, T1, W, N) = \
265 vtbx##X##_##T2##W(VECT_VAR(default_vector, T1, W, N), \
266 VECT_ARRAY_VAR(table_vector, T1, W, N, X), \
267 VECT_VAR(vector, T3, W, N)); \
268 vst1_##T2##W(VECT_VAR(result, T1, W, N), \
269 VECT_VAR(vector_res, T1, W, N));
270
271 #define TEST_ALL_VTBX1() \
272 TEST_VTBX1(int, s, int, 8, 8); \
273 TEST_VTBX1(uint, u, uint, 8, 8); \
274 TEST_VTBX1(poly, p, uint, 8, 8); \
275 MFLOAT8_ONLY(TEST_VTBX1(mfloat, mf, uint, 8, 8))
276
277 #define TEST_ALL_VTBXX(X) \
278 TEST_VTBXX(int, s, int, 8, 8, X); \
279 TEST_VTBXX(uint, u, uint, 8, 8, X); \
280 TEST_VTBXX(poly, p, uint, 8, 8, X); \
281 MFLOAT8_ONLY(TEST_VTBXX(mfloat, mf, uint, 8, 8, X))
282
283 /* Choose init value arbitrarily, will be used as default value. */
284 VDUP(default_vector, , int, s, 8, 8, 0x33);
285 VDUP(default_vector, , uint, u, 8, 8, 0xCC);
286 VDUP(default_vector, , poly, p, 8, 8, 0xCC);
287 MFLOAT8_ONLY(VDUP(default_vector, , mfloat, mf, 8, 8, MFLOAT8(0x55)));
288
289 /* Check vtbx1. */
290 clean_results ();
291 #undef TEST_MSG
292 #define TEST_MSG "VTBX1"
293 TEST_ALL_VTBX1();
294
295 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vtbx1, "");
296 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vtbx1, "");
297 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vtbx1, "");
298 MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 8, PRIx8, expected_vtbx1, ""));
299
300 /* Check vtbx2. */
301 clean_results ();
302 #undef TEST_MSG
303 #define TEST_MSG "VTBX2"
304 TEST_ALL_VTBXX(2);
305
306 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vtbx2, "");
307 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vtbx2, "");
308 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vtbx2, "");
309 MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 8, PRIx8, expected_vtbx2, ""));
310
311 /* Check vtbx3. */
312 clean_results ();
313 #undef TEST_MSG
314 #define TEST_MSG "VTBX3"
315 TEST_ALL_VTBXX(3);
316
317 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vtbx3, "");
318 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vtbx3, "");
319 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vtbx3, "");
320 MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 8, PRIx8, expected_vtbx3, ""));
321
322 /* Check vtbx4. */
323 clean_results ();
324 #undef TEST_MSG
325 #define TEST_MSG "VTBX4"
326 TEST_ALL_VTBXX(4);
327
328 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vtbx4, "");
329 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vtbx4, "");
330 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vtbx4, "");
331 MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 8, PRIx8, expected_vtbx4, ""));
332 }
333
334 int main (void)
335 {
336 exec_vtbX ();
337 return 0;
338 }