Debian Codegraph @

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

raw
1 /* { dg-skip-if "" { arm*-*-* } } */
2
3 #include <arm_neon.h>
4 #include "arm-neon-ref.h"
5 #include "compute-ref-data.h"
6
7 /* Expected results for vqtbl1. */
8 VECT_VAR_DECL(expected_vqtbl1,int,8,8) [] = { 0xfb, 0xf3, 0xf3, 0xf3,
9 0x0, 0x0, 0xf3, 0xf3 };
10 VECT_VAR_DECL(expected_vqtbl1,uint,8,8) [] = { 0xfb, 0xf3, 0xf3, 0xf3,
11 0x0, 0x0, 0xf3, 0xf3 };
12 VECT_VAR_DECL(expected_vqtbl1,poly,8,8) [] = { 0xfb, 0xf3, 0xf3, 0xf3,
13 0x0, 0x0, 0xf3, 0xf3 };
14
15 /* Expected results for vqtbl2. */
16 VECT_VAR_DECL(expected_vqtbl2,int,8,8) [] = { 0x5, 0xf5, 0xf5, 0xf5,
17 0xfa, 0x0, 0xf5, 0xf5 };
18 VECT_VAR_DECL(expected_vqtbl2,uint,8,8) [] = { 0x5, 0xf5, 0xf5, 0xf5,
19 0xfa, 0x0, 0xf5, 0xf5 };
20 VECT_VAR_DECL(expected_vqtbl2,poly,8,8) [] = { 0x5, 0xf5, 0xf5, 0xf5,
21 0xfa, 0x0, 0xf5, 0xf5 };
22
23 /* Expected results for vqtbl3. */
24 VECT_VAR_DECL(expected_vqtbl3,int,8,8) [] = { 0xf, 0xf7, 0xf7, 0xf7,
25 0xfe, 0xb, 0xf7, 0xf7 };
26 VECT_VAR_DECL(expected_vqtbl3,uint,8,8) [] = { 0xf, 0xf7, 0xf7, 0xf7,
27 0xfe, 0xb, 0xf7, 0xf7 };
28 VECT_VAR_DECL(expected_vqtbl3,poly,8,8) [] = { 0xf, 0xf7, 0xf7, 0xf7,
29 0xfe, 0xb, 0xf7, 0xf7 };
30
31 /* Expected results for vqtbl4. */
32 VECT_VAR_DECL(expected_vqtbl4,int,8,8) [] = { 0x19, 0xf9, 0xf9, 0xf9,
33 0x2, 0x13, 0xf9, 0xf9 };
34 VECT_VAR_DECL(expected_vqtbl4,uint,8,8) [] = { 0x19, 0xf9, 0xf9, 0xf9,
35 0x2, 0x13, 0xf9, 0xf9 };
36 VECT_VAR_DECL(expected_vqtbl4,poly,8,8) [] = { 0x19, 0xf9, 0xf9, 0xf9,
37 0x2, 0x13, 0xf9, 0xf9 };
38
39 /* Expected results for vqtbx1. */
40 VECT_VAR_DECL(expected_vqtbx1,int,8,8) [] = { 0xfb, 0xf3, 0xf3, 0xf3,
41 0x33, 0x33, 0xf3, 0xf3 };
42 VECT_VAR_DECL(expected_vqtbx1,uint,8,8) [] = { 0xfb, 0xf3, 0xf3, 0xf3,
43 0xcc, 0xcc, 0xf3, 0xf3 };
44 VECT_VAR_DECL(expected_vqtbx1,poly,8,8) [] = { 0xfb, 0xf3, 0xf3, 0xf3,
45 0xcc, 0xcc, 0xf3, 0xf3 };
46
47 /* Expected results for vqtbx2. */
48 VECT_VAR_DECL(expected_vqtbx2,int,8,8) [] = { 0x5, 0xf5, 0xf5, 0xf5,
49 0xfa, 0x33, 0xf5, 0xf5 };
50 VECT_VAR_DECL(expected_vqtbx2,uint,8,8) [] = { 0x5, 0xf5, 0xf5, 0xf5,
51 0xfa, 0xcc, 0xf5, 0xf5 };
52 VECT_VAR_DECL(expected_vqtbx2,poly,8,8) [] = { 0x5, 0xf5, 0xf5, 0xf5,
53 0xfa, 0xcc, 0xf5, 0xf5 };
54
55 /* Expected results for vqtbx3. */
56 VECT_VAR_DECL(expected_vqtbx3,int,8,8) [] = { 0xf, 0xf7, 0xf7, 0xf7,
57 0xfe, 0xb, 0xf7, 0xf7 };
58 VECT_VAR_DECL(expected_vqtbx3,uint,8,8) [] = { 0xf, 0xf7, 0xf7, 0xf7,
59 0xfe, 0xb, 0xf7, 0xf7 };
60 VECT_VAR_DECL(expected_vqtbx3,poly,8,8) [] = { 0xf, 0xf7, 0xf7, 0xf7,
61 0xfe, 0xb, 0xf7, 0xf7 };
62
63 /* Expected results for vqtbx4. */
64 VECT_VAR_DECL(expected_vqtbx4,int,8,8) [] = { 0x19, 0xf9, 0xf9, 0xf9,
65 0x2, 0x13, 0xf9, 0xf9 };
66 VECT_VAR_DECL(expected_vqtbx4,uint,8,8) [] = { 0x19, 0xf9, 0xf9, 0xf9,
67 0x2, 0x13, 0xf9, 0xf9 };
68 VECT_VAR_DECL(expected_vqtbx4,poly,8,8) [] = { 0x19, 0xf9, 0xf9, 0xf9,
69 0x2, 0x13, 0xf9, 0xf9 };
70
71 /* Expected results for vqtbl1q. */
72 VECT_VAR_DECL(expected_vqtbl1q,int,8,16) [] = { 0xfb, 0xf3, 0xf3, 0xf3,
73 0x0, 0x0, 0xf3, 0xf3,
74 0xf3, 0xf3, 0xf3, 0xf3,
75 0xf3, 0xf3, 0xf3, 0xf3 };
76 VECT_VAR_DECL(expected_vqtbl1q,uint,8,16) [] = { 0xfb, 0xf3, 0xf3, 0xf3,
77 0x0, 0x0, 0xf3, 0xf3,
78 0xf3, 0xf3, 0xf3, 0xf3,
79 0xf3, 0xf3, 0xf3, 0xf3 };
80 VECT_VAR_DECL(expected_vqtbl1q,poly,8,16) [] = { 0xfb, 0xf3, 0xf3, 0xf3,
81 0x0, 0x0, 0xf3, 0xf3,
82 0xf3, 0xf3, 0xf3, 0xf3,
83 0xf3, 0xf3, 0xf3, 0xf3 };
84
85 /* Expected results for vqtbl2q. */
86 VECT_VAR_DECL(expected_vqtbl2q,int,8,16) [] = { 0x5, 0xf5, 0xf5, 0xf5,
87 0xfa, 0x0, 0xf5, 0xf5,
88 0xf5, 0xf5, 0xf5, 0xf5,
89 0xf5, 0xf5, 0xf5, 0xf5 };
90 VECT_VAR_DECL(expected_vqtbl2q,uint,8,16) [] = { 0x5, 0xf5, 0xf5, 0xf5,
91 0xfa, 0x0, 0xf5, 0xf5,
92 0xf5, 0xf5, 0xf5, 0xf5,
93 0xf5, 0xf5, 0xf5, 0xf5 };
94 VECT_VAR_DECL(expected_vqtbl2q,poly,8,16) [] = { 0x5, 0xf5, 0xf5, 0xf5,
95 0xfa, 0x0, 0xf5, 0xf5,
96 0xf5, 0xf5, 0xf5, 0xf5,
97 0xf5, 0xf5, 0xf5, 0xf5 };
98
99 /* Expected results for vqtbl3q. */
100 VECT_VAR_DECL(expected_vqtbl3q,int,8,16) [] = { 0xf, 0xf7, 0xf7, 0xf7,
101 0xfe, 0xb, 0xf7, 0xf7,
102 0xf7, 0xf7, 0xf7, 0xf7,
103 0xf7, 0xf7, 0xf7, 0xf7 };
104 VECT_VAR_DECL(expected_vqtbl3q,uint,8,16) [] = { 0xf, 0xf7, 0xf7, 0xf7,
105 0xfe, 0xb, 0xf7, 0xf7,
106 0xf7, 0xf7, 0xf7, 0xf7,
107 0xf7, 0xf7, 0xf7, 0xf7 };
108 VECT_VAR_DECL(expected_vqtbl3q,poly,8,16) [] = { 0xf, 0xf7, 0xf7, 0xf7,
109 0xfe, 0xb, 0xf7, 0xf7,
110 0xf7, 0xf7, 0xf7, 0xf7,
111 0xf7, 0xf7, 0xf7, 0xf7 };
112
113 /* Expected results for vqtbl4q. */
114 VECT_VAR_DECL(expected_vqtbl4q,int,8,16) [] = { 0x19, 0xf9, 0xf9, 0xf9,
115 0x2, 0x13, 0xf9, 0xf9,
116 0xf9, 0xf9, 0xf9, 0xf9,
117 0xf9, 0xf9, 0xf9, 0xf9 };
118 VECT_VAR_DECL(expected_vqtbl4q,uint,8,16) [] = { 0x19, 0xf9, 0xf9, 0xf9,
119 0x2, 0x13, 0xf9, 0xf9,
120 0xf9, 0xf9, 0xf9, 0xf9,
121 0xf9, 0xf9, 0xf9, 0xf9 };
122 VECT_VAR_DECL(expected_vqtbl4q,poly,8,16) [] = { 0x19, 0xf9, 0xf9, 0xf9,
123 0x2, 0x13, 0xf9, 0xf9,
124 0xf9, 0xf9, 0xf9, 0xf9,
125 0xf9, 0xf9, 0xf9, 0xf9 };
126
127 /* Expected results for vqtbx1q. */
128 VECT_VAR_DECL(expected_vqtbx1q,int,8,16) [] = { 0xfb, 0xf3, 0xf3, 0xf3,
129 0x33, 0x33, 0xf3, 0xf3,
130 0xf3, 0xf3, 0xf3, 0xf3,
131 0xf3, 0xf3, 0xf3, 0xf3 };
132 VECT_VAR_DECL(expected_vqtbx1q,uint,8,16) [] = { 0xfb, 0xf3, 0xf3, 0xf3,
133 0xcc, 0xcc, 0xf3, 0xf3,
134 0xf3, 0xf3, 0xf3, 0xf3,
135 0xf3, 0xf3, 0xf3, 0xf3 };
136 VECT_VAR_DECL(expected_vqtbx1q,poly,8,16) [] = { 0xfb, 0xf3, 0xf3, 0xf3,
137 0xcc, 0xcc, 0xf3, 0xf3,
138 0xf3, 0xf3, 0xf3, 0xf3,
139 0xf3, 0xf3, 0xf3, 0xf3 };
140
141 /* Expected results for vqtbx2q. */
142 VECT_VAR_DECL(expected_vqtbx2q,int,8,16) [] = { 0x5, 0xf5, 0xf5, 0xf5,
143 0xfa, 0x33, 0xf5, 0xf5,
144 0xf5, 0xf5, 0xf5, 0xf5,
145 0xf5, 0xf5, 0xf5, 0xf5 };
146 VECT_VAR_DECL(expected_vqtbx2q,uint,8,16) [] = { 0x5, 0xf5, 0xf5, 0xf5,
147 0xfa, 0xcc, 0xf5, 0xf5,
148 0xf5, 0xf5, 0xf5, 0xf5,
149 0xf5, 0xf5, 0xf5, 0xf5 };
150 VECT_VAR_DECL(expected_vqtbx2q,poly,8,16) [] = { 0x5, 0xf5, 0xf5, 0xf5,
151 0xfa, 0xcc, 0xf5, 0xf5,
152 0xf5, 0xf5, 0xf5, 0xf5,
153 0xf5, 0xf5, 0xf5, 0xf5 };
154
155 /* Expected results for vqtbx3q. */
156 VECT_VAR_DECL(expected_vqtbx3q,int,8,16) [] = { 0xf, 0xf7, 0xf7, 0xf7,
157 0xfe, 0xb, 0xf7, 0xf7,
158 0xf7, 0xf7, 0xf7, 0xf7,
159 0xf7, 0xf7, 0xf7, 0xf7 };
160 VECT_VAR_DECL(expected_vqtbx3q,uint,8,16) [] = { 0xf, 0xf7, 0xf7, 0xf7,
161 0xfe, 0xb, 0xf7, 0xf7,
162 0xf7, 0xf7, 0xf7, 0xf7,
163 0xf7, 0xf7, 0xf7, 0xf7 };
164 VECT_VAR_DECL(expected_vqtbx3q,poly,8,16) [] = { 0xf, 0xf7, 0xf7, 0xf7,
165 0xfe, 0xb, 0xf7, 0xf7,
166 0xf7, 0xf7, 0xf7, 0xf7,
167 0xf7, 0xf7, 0xf7, 0xf7 };
168
169 /* Expected results for vqtbx4q. */
170 VECT_VAR_DECL(expected_vqtbx4q,int,8,16) [] = { 0x19, 0xf9, 0xf9, 0xf9,
171 0x2, 0x13, 0xf9, 0xf9,
172 0xf9, 0xf9, 0xf9, 0xf9,
173 0xf9, 0xf9, 0xf9, 0xf9 };
174 VECT_VAR_DECL(expected_vqtbx4q,uint,8,16) [] = { 0x19, 0xf9, 0xf9, 0xf9,
175 0x2, 0x13, 0xf9, 0xf9,
176 0xf9, 0xf9, 0xf9, 0xf9,
177 0xf9, 0xf9, 0xf9, 0xf9 };
178 VECT_VAR_DECL(expected_vqtbx4q,poly,8,16) [] = { 0x19, 0xf9, 0xf9, 0xf9,
179 0x2, 0x13, 0xf9, 0xf9,
180 0xf9, 0xf9, 0xf9, 0xf9,
181 0xf9, 0xf9, 0xf9, 0xf9 };
182
183 void exec_vqtbX (void)
184 {
185 int i;
186
187 /* In this case, input variables are arrays of vectors. */
188 #define DECL_VQTBX(T1, W, N, X) \
189 VECT_ARRAY_TYPE(T1, W, N, X) VECT_ARRAY_VAR(table_vector, T1, W, N, X)
190
191 /* The vqtbl1 variant is different from vqtbl{2,3,4} because it takes a
192 vector as 1st param, instead of an array of vectors. */
193 #define TEST_VQTBL1(T1, T2, T3, W, N1, N2) \
194 VECT_VAR(table_vector, T1, W, N2) = \
195 vld1##q_##T2##W((T1##W##_t *)lookup_table); \
196 \
197 VECT_VAR(vector_res, T1, W, N1) = \
198 vqtbl1_##T2##W(VECT_VAR(table_vector, T1, W, N2), \
199 VECT_VAR(vector, T3, W, N1)); \
200 vst1_##T2##W(VECT_VAR(result, T1, W, N1), \
201 VECT_VAR(vector_res, T1, W, N1));
202
203 #define TEST_VQTBL1Q(T1, T2, T3, W, N1, N2) \
204 VECT_VAR(table_vector, T1, W, N2) = \
205 vld1##q_##T2##W((T1##W##_t *)lookup_table); \
206 \
207 VECT_VAR(vector_res, T1, W, N1) = \
208 vqtbl1q_##T2##W(VECT_VAR(table_vector, T1, W, N2), \
209 VECT_VAR(vector, T3, W, N1)); \
210 vst1q_##T2##W(VECT_VAR(result, T1, W, N1), \
211 VECT_VAR(vector_res, T1, W, N1));
212
213 #define TEST_VQTBLX(T1, T2, T3, W, N1, N2, X) \
214 VECT_ARRAY_VAR(table_vector, T1, W, N2, X) = \
215 vld##X##q_##T2##W((T1##W##_t *)lookup_table); \
216 \
217 VECT_VAR(vector_res, T1, W, N1) = \
218 vqtbl##X##_##T2##W(VECT_ARRAY_VAR(table_vector, T1, W, N2, X), \
219 VECT_VAR(vector, T3, W, N1)); \
220 vst1_##T2##W(VECT_VAR(result, T1, W, N1), \
221 VECT_VAR(vector_res, T1, W, N1));
222
223 #define TEST_VQTBLXQ(T1, T2, T3, W, N1, N2, X) \
224 VECT_ARRAY_VAR(table_vector, T1, W, N2, X) = \
225 vld##X##q_##T2##W((T1##W##_t *)lookup_table); \
226 \
227 VECT_VAR(vector_res, T1, W, N1) = \
228 vqtbl##X##q_##T2##W(VECT_ARRAY_VAR(table_vector, T1, W, N2, X), \
229 VECT_VAR(vector, T3, W, N1)); \
230 vst1q_##T2##W(VECT_VAR(result, T1, W, N1), \
231 VECT_VAR(vector_res, T1, W, N1));
232
233 /* We need to define a lookup table large enough. */
234 int8_t lookup_table[4*16];
235
236 /* For vqtblX. */
237 DECL_VARIABLE(vector, int, 8, 8);
238 DECL_VARIABLE(vector, uint, 8, 8);
239 DECL_VARIABLE(vector, poly, 8, 8);
240 DECL_VARIABLE(vector_res, int, 8, 8);
241 DECL_VARIABLE(vector_res, uint, 8, 8);
242 DECL_VARIABLE(vector_res, poly, 8, 8);
243
244 /* For vqtblXq. */
245 DECL_VARIABLE(vector, int, 8, 16);
246 DECL_VARIABLE(vector, uint, 8, 16);
247 DECL_VARIABLE(vector, poly, 8, 16);
248 DECL_VARIABLE(vector_res, int, 8, 16);
249 DECL_VARIABLE(vector_res, uint, 8, 16);
250 DECL_VARIABLE(vector_res, poly, 8, 16);
251
252 /* For vqtbl1. */
253 DECL_VARIABLE(table_vector, int, 8, 16);
254 DECL_VARIABLE(table_vector, uint, 8, 16);
255 DECL_VARIABLE(table_vector, poly, 8, 16);
256
257 /* For vqtbx*. */
258 DECL_VARIABLE(default_vector, int, 8, 8);
259 DECL_VARIABLE(default_vector, uint, 8, 8);
260 DECL_VARIABLE(default_vector, poly, 8, 8);
261
262 /* For vqtbx*q. */
263 DECL_VARIABLE(default_vector, int, 8, 16);
264 DECL_VARIABLE(default_vector, uint, 8, 16);
265 DECL_VARIABLE(default_vector, poly, 8, 16);
266
267 /* We need only 8 bits variants. */
268 #define DECL_ALL_VQTBLX(X) \
269 DECL_VQTBX(int, 8, 16, X); \
270 DECL_VQTBX(uint, 8, 16, X); \
271 DECL_VQTBX(poly, 8, 16, X)
272
273 #define TEST_ALL_VQTBL1() \
274 TEST_VQTBL1(int, s, uint, 8, 8, 16); \
275 TEST_VQTBL1(uint, u, uint, 8, 8, 16); \
276 TEST_VQTBL1(poly, p, uint, 8, 8, 16); \
277 TEST_VQTBL1Q(int, s, uint, 8, 16, 16); \
278 TEST_VQTBL1Q(uint, u, uint, 8, 16, 16); \
279 TEST_VQTBL1Q(poly, p, uint, 8, 16, 16)
280
281 #define TEST_ALL_VQTBLX(X) \
282 TEST_VQTBLX(int, s, uint, 8, 8, 16, X); \
283 TEST_VQTBLX(uint, u, uint, 8, 8, 16, X); \
284 TEST_VQTBLX(poly, p, uint, 8, 8, 16, X); \
285 TEST_VQTBLXQ(int, s, uint, 8, 16, 16, X); \
286 TEST_VQTBLXQ(uint, u, uint, 8, 16, 16, X); \
287 TEST_VQTBLXQ(poly, p, uint, 8, 16, 16, X)
288
289 /* Declare the temporary buffers / variables. */
290 DECL_ALL_VQTBLX(2);
291 DECL_ALL_VQTBLX(3);
292 DECL_ALL_VQTBLX(4);
293
294 /* Fill the lookup table. */
295 for (i=0; i<4*16; i++) {
296 lookup_table[i] = i-15;
297 }
298
299 /* Choose init value arbitrarily, will be used as table index. */
300 VDUP(vector, , uint, u, 8, 8, 2);
301 VDUP(vector, q, uint, u, 8, 16, 2);
302
303 /* To ensure coverage, add some indexes larger than 8, 16 and 32
304 except: lane 0 (index 10), lane 4 (index 20) and lane 5 (index
305 40). */
306 VSET_LANE(vector, , uint, u, 8, 8, 0, 10);
307 VSET_LANE(vector, , uint, u, 8, 8, 4, 20);
308 VSET_LANE(vector, , uint, u, 8, 8, 5, 40);
309
310 VSET_LANE(vector, q, uint, u, 8, 16, 0, 10);
311 VSET_LANE(vector, q, uint, u, 8, 16, 4, 20);
312 VSET_LANE(vector, q, uint, u, 8, 16, 5, 40);
313
314 /* Check vqtbl1. */
315 clean_results ();
316 #define TEST_MSG "VQTBL1"
317 TEST_ALL_VQTBL1();
318
319 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbl1, "");
320 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbl1, "");
321 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbl1, "");
322
323 #undef TEST_MSG
324 #define TEST_MSG "VQTBL1Q"
325 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbl1q, "");
326 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbl1q, "");
327 CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbl1q, "");
328
329 /* Check vqtbl2. */
330 clean_results ();
331 #undef TEST_MSG
332 #define TEST_MSG "VQTBL2"
333 TEST_ALL_VQTBLX(2);
334
335 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbl2, "");
336 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbl2, "");
337 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbl2, "");
338
339 #undef TEST_MSG
340 #define TEST_MSG "VQTBL2Q"
341 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbl2q, "");
342 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbl2q, "");
343 CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbl2q, "");
344
345 /* Check vqtbl3. */
346 clean_results ();
347 #undef TEST_MSG
348 #define TEST_MSG "VQTBL3"
349 TEST_ALL_VQTBLX(3);
350
351 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbl3, "");
352 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbl3, "");
353 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbl3, "");
354
355 #undef TEST_MSG
356 #define TEST_MSG "VQTBL3Q"
357 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbl3q, "");
358 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbl3q, "");
359 CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbl3q, "");
360
361 /* Check vqtbl4. */
362 clean_results ();
363 #undef TEST_MSG
364 #define TEST_MSG "VQTBL4"
365 TEST_ALL_VQTBLX(4);
366
367 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbl4, "");
368 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbl4, "");
369 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbl4, "");
370
371 #undef TEST_MSG
372 #define TEST_MSG "VQTBL4Q"
373 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbl4q, "");
374 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbl4q, "");
375 CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbl4q, "");
376
377
378 /* Now test VQTBX. */
379
380 /* The vqtbx1 variant is different from vqtbx{2,3,4} because it takes a
381 vector as 1st param, instead of an array of vectors. */
382 #define TEST_VQTBX1(T1, T2, T3, W, N1, N2) \
383 VECT_VAR(table_vector, T1, W, N2) = \
384 vld1##q_##T2##W((T1##W##_t *)lookup_table); \
385 \
386 VECT_VAR(vector_res, T1, W, N1) = \
387 vqtbx1_##T2##W(VECT_VAR(default_vector, T1, W, N1), \
388 VECT_VAR(table_vector, T1, W, N2), \
389 VECT_VAR(vector, T3, W, N1)); \
390 vst1_##T2##W(VECT_VAR(result, T1, W, N1), \
391 VECT_VAR(vector_res, T1, W, N1));
392
393 #define TEST_VQTBX1Q(T1, T2, T3, W, N1, N2) \
394 VECT_VAR(table_vector, T1, W, N2) = \
395 vld1##q_##T2##W((T1##W##_t *)lookup_table); \
396 \
397 VECT_VAR(vector_res, T1, W, N1) = \
398 vqtbx1q_##T2##W(VECT_VAR(default_vector, T1, W, N1),\
399 VECT_VAR(table_vector, T1, W, N2), \
400 VECT_VAR(vector, T3, W, N1)); \
401 vst1q_##T2##W(VECT_VAR(result, T1, W, N1), \
402 VECT_VAR(vector_res, T1, W, N1));
403
404 #define TEST_VQTBXX(T1, T2, T3, W, N1, N2, X) \
405 VECT_ARRAY_VAR(table_vector, T1, W, N2, X) = \
406 vld##X##q_##T2##W((T1##W##_t *)lookup_table); \
407 \
408 VECT_VAR(vector_res, T1, W, N1) = \
409 vqtbx##X##_##T2##W(VECT_VAR(default_vector, T1, W, N1), \
410 VECT_ARRAY_VAR(table_vector, T1, W, N2, X), \
411 VECT_VAR(vector, T3, W, N1)); \
412 vst1_##T2##W(VECT_VAR(result, T1, W, N1), \
413 VECT_VAR(vector_res, T1, W, N1));
414
415 #define TEST_VQTBXXQ(T1, T2, T3, W, N1, N2, X) \
416 VECT_ARRAY_VAR(table_vector, T1, W, N2, X) = \
417 vld##X##q_##T2##W((T1##W##_t *)lookup_table); \
418 \
419 VECT_VAR(vector_res, T1, W, N1) = \
420 vqtbx##X##q_##T2##W(VECT_VAR(default_vector, T1, W, N1), \
421 VECT_ARRAY_VAR(table_vector, T1, W, N2, X), \
422 VECT_VAR(vector, T3, W, N1)); \
423 vst1q_##T2##W(VECT_VAR(result, T1, W, N1), \
424 VECT_VAR(vector_res, T1, W, N1));
425
426 #define TEST_ALL_VQTBX1() \
427 TEST_VQTBX1(int, s, uint, 8, 8, 16); \
428 TEST_VQTBX1(uint, u, uint, 8, 8, 16); \
429 TEST_VQTBX1(poly, p, uint, 8, 8, 16); \
430 TEST_VQTBX1Q(int, s, uint, 8, 16, 16); \
431 TEST_VQTBX1Q(uint, u, uint, 8, 16, 16); \
432 TEST_VQTBX1Q(poly, p, uint, 8, 16, 16)
433
434 #define TEST_ALL_VQTBXX(X) \
435 TEST_VQTBXX(int, s, uint, 8, 8, 16, X); \
436 TEST_VQTBXX(uint, u, uint, 8, 8, 16, X); \
437 TEST_VQTBXX(poly, p, uint, 8, 8, 16, X); \
438 TEST_VQTBXXQ(int, s, uint, 8, 16, 16, X); \
439 TEST_VQTBXXQ(uint, u, uint, 8, 16, 16, X); \
440 TEST_VQTBXXQ(poly, p, uint, 8, 16, 16, X)
441
442 /* Choose init value arbitrarily, will be used as default value. */
443 VDUP(default_vector, , int, s, 8, 8, 0x33);
444 VDUP(default_vector, , uint, u, 8, 8, 0xCC);
445 VDUP(default_vector, , poly, p, 8, 8, 0xCC);
446 VDUP(default_vector, q, int, s, 8, 16, 0x33);
447 VDUP(default_vector, q, uint, u, 8, 16, 0xCC);
448 VDUP(default_vector, q, poly, p, 8, 16, 0xCC);
449
450 /* Check vqtbx1. */
451 clean_results ();
452 #undef TEST_MSG
453 #define TEST_MSG "VQTBX1"
454 TEST_ALL_VQTBX1();
455
456 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbx1, "");
457 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbx1, "");
458 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbx1, "");
459
460 #undef TEST_MSG
461 #define TEST_MSG "VQTBX1Q"
462 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbx1q, "");
463 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbx1q, "");
464 CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbx1q, "");
465
466 /* Check vqtbx2. */
467 clean_results ();
468 #undef TEST_MSG
469 #define TEST_MSG "VQTBX2"
470 TEST_ALL_VQTBXX(2);
471
472 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbx2, "");
473 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbx2, "");
474 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbx2, "");
475
476 #undef TEST_MSG
477 #define TEST_MSG "VQTBX2Q"
478 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbx2q, "");
479 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbx2q, "");
480 CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbx2q, "");
481
482 /* Check vqtbx3. */
483 clean_results ();
484 #undef TEST_MSG
485 #define TEST_MSG "VQTBX3"
486 TEST_ALL_VQTBXX(3);
487
488 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbx3, "");
489 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbx3, "");
490 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbx3, "");
491
492 #undef TEST_MSG
493 #define TEST_MSG "VQTBX3Q"
494 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbx3q, "");
495 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbx3q, "");
496 CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbx3q, "");
497
498 /* Check vqtbx4. */
499 clean_results ();
500 #undef TEST_MSG
501 #define TEST_MSG "VQTBX4"
502 TEST_ALL_VQTBXX(4);
503
504 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vqtbx4, "");
505 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vqtbx4, "");
506 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vqtbx4, "");
507
508 #undef TEST_MSG
509 #define TEST_MSG "VQTBX4Q"
510 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vqtbx4q, "");
511 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vqtbx4q, "");
512 CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected_vqtbx4q, "");
513 }
514
515 int main (void)
516 {
517 exec_vqtbX ();
518 return 0;
519 }