Debian Codegraph @

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

raw
1 #include <arm_neon.h>
2 #include "arm-neon-ref.h"
3 #include "compute-ref-data.h"
4
5 /* Expected results for vrev16. */
6 VECT_VAR_DECL(expected_vrev16,int,8,8) [] = { 0xf1, 0xf0, 0xf3, 0xf2,
7 0xf5, 0xf4, 0xf7, 0xf6 };
8 VECT_VAR_DECL(expected_vrev16,uint,8,8) [] = { 0xf1, 0xf0, 0xf3, 0xf2,
9 0xf5, 0xf4, 0xf7, 0xf6 };
10 VECT_VAR_DECL(expected_vrev16,poly,8,8) [] = { 0xf1, 0xf0, 0xf3, 0xf2,
11 0xf5, 0xf4, 0xf7, 0xf6 };
12 VECT_VAR_DECL(expected_vrev16,int,8,16) [] = { 0xf1, 0xf0, 0xf3, 0xf2,
13 0xf5, 0xf4, 0xf7, 0xf6,
14 0xf9, 0xf8, 0xfb, 0xfa,
15 0xfd, 0xfc, 0xff, 0xfe };
16 VECT_VAR_DECL(expected_vrev16,uint,8,16) [] = { 0xf1, 0xf0, 0xf3, 0xf2,
17 0xf5, 0xf4, 0xf7, 0xf6,
18 0xf9, 0xf8, 0xfb, 0xfa,
19 0xfd, 0xfc, 0xff, 0xfe };
20 VECT_VAR_DECL(expected_vrev16,poly,8,16) [] = { 0xf1, 0xf0, 0xf3, 0xf2,
21 0xf5, 0xf4, 0xf7, 0xf6,
22 0xf9, 0xf8, 0xfb, 0xfa,
23 0xfd, 0xfc, 0xff, 0xfe };
24 #if MFLOAT8_SUPPORTED
25 VECT_VAR_DECL(expected_vrev16,hmfloat,8,8) [] = { 0xf1, 0xf0, 0xf3, 0xf2,
26 0xf5, 0xf4, 0xf7, 0xf6 };
27 #endif
28
29 /* Expected results for vrev32. */
30 VECT_VAR_DECL(expected_vrev32,int,8,8) [] = { 0xf3, 0xf2, 0xf1, 0xf0,
31 0xf7, 0xf6, 0xf5, 0xf4 };
32 VECT_VAR_DECL(expected_vrev32,int,16,4) [] = { 0xfff1, 0xfff0, 0xfff3, 0xfff2 };
33 VECT_VAR_DECL(expected_vrev32,uint,8,8) [] = { 0xf3, 0xf2, 0xf1, 0xf0,
34 0xf7, 0xf6, 0xf5, 0xf4 };
35 VECT_VAR_DECL(expected_vrev32,uint,16,4) [] = { 0xfff1, 0xfff0, 0xfff3, 0xfff2 };
36 VECT_VAR_DECL(expected_vrev32,poly,8,8) [] = { 0xf3, 0xf2, 0xf1, 0xf0,
37 0xf7, 0xf6, 0xf5, 0xf4 };
38 VECT_VAR_DECL(expected_vrev32,poly,16,4) [] = { 0xfff1, 0xfff0, 0xfff3, 0xfff2 };
39 #if MFLOAT8_SUPPORTED
40 VECT_VAR_DECL(expected_vrev32,hmfloat,8,8) [] = { 0xf3, 0xf2, 0xf1, 0xf0,
41 0xf7, 0xf6, 0xf5, 0xf4 };
42 #endif
43 VECT_VAR_DECL(expected_vrev32,int,8,16) [] = { 0xf3, 0xf2, 0xf1, 0xf0,
44 0xf7, 0xf6, 0xf5, 0xf4,
45 0xfb, 0xfa, 0xf9, 0xf8,
46 0xff, 0xfe, 0xfd, 0xfc };
47 VECT_VAR_DECL(expected_vrev32,int,16,8) [] = { 0xfff1, 0xfff0, 0xfff3, 0xfff2,
48 0xfff5, 0xfff4, 0xfff7, 0xfff6 };
49 VECT_VAR_DECL(expected_vrev32,uint,8,16) [] = { 0xf3, 0xf2, 0xf1, 0xf0,
50 0xf7, 0xf6, 0xf5, 0xf4,
51 0xfb, 0xfa, 0xf9, 0xf8,
52 0xff, 0xfe, 0xfd, 0xfc };
53 VECT_VAR_DECL(expected_vrev32,uint,16,8) [] = { 0xfff1, 0xfff0, 0xfff3, 0xfff2,
54 0xfff5, 0xfff4, 0xfff7, 0xfff6 };
55 VECT_VAR_DECL(expected_vrev32,poly,8,16) [] = { 0xf3, 0xf2, 0xf1, 0xf0,
56 0xf7, 0xf6, 0xf5, 0xf4,
57 0xfb, 0xfa, 0xf9, 0xf8,
58 0xff, 0xfe, 0xfd, 0xfc };
59 VECT_VAR_DECL(expected_vrev32,poly,16,8) [] = { 0xfff1, 0xfff0, 0xfff3, 0xfff2,
60 0xfff5, 0xfff4, 0xfff7, 0xfff6 };
61 #if MFLOAT8_SUPPORTED
62 VECT_VAR_DECL(expected_vrev32,hmfloat,8,16) [] = { 0xf3, 0xf2, 0xf1, 0xf0,
63 0xf7, 0xf6, 0xf5, 0xf4,
64 0xfb, 0xfa, 0xf9, 0xf8,
65 0xff, 0xfe, 0xfd, 0xfc };
66 #endif
67
68 /* Expected results for vrev64. */
69 VECT_VAR_DECL(expected_vrev64,int,8,8) [] = { 0xf7, 0xf6, 0xf5, 0xf4,
70 0xf3, 0xf2, 0xf1, 0xf0 };
71 VECT_VAR_DECL(expected_vrev64,int,16,4) [] = { 0xfff3, 0xfff2, 0xfff1, 0xfff0 };
72 VECT_VAR_DECL(expected_vrev64,int,32,2) [] = { 0xfffffff1, 0xfffffff0 };
73 VECT_VAR_DECL(expected_vrev64,uint,8,8) [] = { 0xf7, 0xf6, 0xf5, 0xf4, 0xf3,
74 0xf2, 0xf1, 0xf0 };
75 VECT_VAR_DECL(expected_vrev64,uint,16,4) [] = { 0xfff3, 0xfff2, 0xfff1, 0xfff0 };
76 VECT_VAR_DECL(expected_vrev64,uint,32,2) [] = { 0xfffffff1, 0xfffffff0 };
77 VECT_VAR_DECL(expected_vrev64,poly,8,8) [] = { 0xf7, 0xf6, 0xf5, 0xf4,
78 0xf3, 0xf2, 0xf1, 0xf0 };
79 VECT_VAR_DECL(expected_vrev64,poly,16,4) [] = { 0xfff3, 0xfff2, 0xfff1, 0xfff0 };
80 #if MFLOAT8_SUPPORTED
81 VECT_VAR_DECL(expected_vrev64,hmfloat,8,8) [] = { 0xf7, 0xf6, 0xf5, 0xf4,
82 0xf3, 0xf2, 0xf1, 0xf0 };
83 #endif
84 #if defined (FP16_SUPPORTED)
85 VECT_VAR_DECL (expected_vrev64, hfloat, 16, 4) [] = { 0xca80, 0xcb00,
86 0xcb80, 0xcc00 };
87 #endif
88 VECT_VAR_DECL(expected_vrev64,hfloat,32,2) [] = { 0xc1700000, 0xc1800000 };
89 VECT_VAR_DECL(expected_vrev64,int,8,16) [] = { 0xf7, 0xf6, 0xf5, 0xf4,
90 0xf3, 0xf2, 0xf1, 0xf0,
91 0xff, 0xfe, 0xfd, 0xfc,
92 0xfb, 0xfa, 0xf9, 0xf8 };
93 VECT_VAR_DECL(expected_vrev64,int,16,8) [] = { 0xfff3, 0xfff2, 0xfff1, 0xfff0,
94 0xfff7, 0xfff6, 0xfff5, 0xfff4 };
95 VECT_VAR_DECL(expected_vrev64,int,32,4) [] = { 0xfffffff1, 0xfffffff0,
96 0xfffffff3, 0xfffffff2 };
97 VECT_VAR_DECL(expected_vrev64,uint,8,16) [] = { 0xf7, 0xf6, 0xf5, 0xf4,
98 0xf3, 0xf2, 0xf1, 0xf0,
99 0xff, 0xfe, 0xfd, 0xfc,
100 0xfb, 0xfa, 0xf9, 0xf8 };
101 VECT_VAR_DECL(expected_vrev64,uint,16,8) [] = { 0xfff3, 0xfff2, 0xfff1, 0xfff0,
102 0xfff7, 0xfff6, 0xfff5, 0xfff4 };
103 VECT_VAR_DECL(expected_vrev64,uint,32,4) [] = { 0xfffffff1, 0xfffffff0,
104 0xfffffff3, 0xfffffff2 };
105 VECT_VAR_DECL(expected_vrev64,poly,8,16) [] = { 0xf7, 0xf6, 0xf5, 0xf4,
106 0xf3, 0xf2, 0xf1, 0xf0,
107 0xff, 0xfe, 0xfd, 0xfc,
108 0xfb, 0xfa, 0xf9, 0xf8 };
109 VECT_VAR_DECL(expected_vrev64,poly,16,8) [] = { 0xfff3, 0xfff2, 0xfff1, 0xfff0,
110 0xfff7, 0xfff6, 0xfff5, 0xfff4 };
111 #if MFLOAT8_SUPPORTED
112 VECT_VAR_DECL(expected_vrev64,hmfloat,8,16) [] = { 0xf7, 0xf6, 0xf5, 0xf4,
113 0xf3, 0xf2, 0xf1, 0xf0,
114 0xff, 0xfe, 0xfd, 0xfc,
115 0xfb, 0xfa, 0xf9, 0xf8 };
116 #endif
117 #if defined (FP16_SUPPORTED)
118 VECT_VAR_DECL (expected_vrev64, hfloat, 16, 8) [] = { 0xca80, 0xcb00,
119 0xcb80, 0xcc00,
120 0xc880, 0xc900,
121 0xc980, 0xca00 };
122 #endif
123 VECT_VAR_DECL(expected_vrev64,hfloat,32,4) [] = { 0xc1700000, 0xc1800000,
124 0xc1500000, 0xc1600000 };
125
126 void exec_vrev (void)
127 {
128 /* Basic test: y=vrev(x), then store the result. */
129 #define TEST_VREV(Q, T1, T2, W, N, W2) \
130 VECT_VAR(vector_res, T1, W, N) = \
131 vrev##W2##Q##_##T2##W(VECT_VAR(vector, T1, W, N)); \
132 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
133
134 DECL_VARIABLE_ALL_VARIANTS(vector);
135 DECL_VARIABLE_ALL_VARIANTS(vector_res);
136
137 clean_results ();
138
139 /* Initialize input "vector" from "buffer". */
140 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer);
141 #if MFLOAT8_SUPPORTED
142 VLOAD (vector, buffer, , mfloat, mf, 8, 8);
143 VLOAD (vector, buffer, q, mfloat, mf, 8, 16);
144 #endif
145 #if defined (FP16_SUPPORTED)
146 VLOAD (vector, buffer, , float, f, 16, 4);
147 VLOAD (vector, buffer, q, float, f, 16, 8);
148 #endif
149 VLOAD(vector, buffer, , float, f, 32, 2);
150 VLOAD(vector, buffer, q, float, f, 32, 4);
151
152 /* Check vrev in each of the existing combinations. */
153 #define TEST_MSG "VREV16"
154 TEST_VREV(, int, s, 8, 8, 16);
155 TEST_VREV(, uint, u, 8, 8, 16);
156 TEST_VREV(, poly, p, 8, 8, 16);
157 TEST_VREV(q, int, s, 8, 16, 16);
158 TEST_VREV(q, uint, u, 8, 16, 16);
159 TEST_VREV(q, poly, p, 8, 16, 16);
160 MFLOAT8_ONLY(TEST_VREV(, mfloat, mf, 8, 8, 16));
161
162 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vrev16, "");
163 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vrev16, "");
164 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vrev16, "");
165 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vrev16, "");
166 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vrev16, "");
167 CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected_vrev16, "");
168 MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 8, PRIx8, expected_vrev16, ""));
169
170 #undef TEST_MSG
171 #define TEST_MSG "VREV32"
172 TEST_VREV(, int, s, 8, 8, 32);
173 TEST_VREV(, int, s, 16, 4, 32);
174 TEST_VREV(, uint, u, 8, 8, 32);
175 TEST_VREV(, uint, u, 16, 4, 32);
176 TEST_VREV(, poly, p, 8, 8, 32);
177 TEST_VREV(, poly, p, 16, 4, 32);
178 MFLOAT8_ONLY(TEST_VREV(, mfloat, mf, 8, 8, 32));
179 TEST_VREV(q, int, s, 8, 16, 32);
180 TEST_VREV(q, int, s, 16, 8, 32);
181 TEST_VREV(q, uint, u, 8, 16, 32);
182 TEST_VREV(q, uint, u, 16, 8, 32);
183 TEST_VREV(q, poly, p, 8, 16, 32);
184 TEST_VREV(q, poly, p, 16, 8, 32);
185 MFLOAT8_ONLY(TEST_VREV(q, mfloat, mf, 8, 16, 32));
186
187 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vrev32, "");
188 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_vrev32, "");
189 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vrev32, "");
190 CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected_vrev32, "");
191 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vrev32, "");
192 CHECK_POLY(TEST_MSG, poly, 16, 4, PRIx16, expected_vrev32, "");
193 MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 8, PRIx8, expected_vrev32, ""));
194 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vrev32, "");
195 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_vrev32, "");
196 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vrev32, "");
197 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_vrev32, "");
198 CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected_vrev32, "");
199 CHECK_POLY(TEST_MSG, poly, 16, 8, PRIx16, expected_vrev32, "");
200 MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 16, PRIx8, expected_vrev32, ""));
201
202 #undef TEST_MSG
203 #define TEST_MSG "VREV64"
204 TEST_VREV(, int, s, 8, 8, 64);
205 TEST_VREV(, int, s, 16, 4, 64);
206 TEST_VREV(, int, s, 32, 2, 64);
207 TEST_VREV(, uint, u, 8, 8, 64);
208 TEST_VREV(, uint, u, 16, 4, 64);
209 TEST_VREV(, uint, u, 32, 2, 64);
210 TEST_VREV(, poly, p, 8, 8, 64);
211 TEST_VREV(, poly, p, 16, 4, 64);
212 MFLOAT8_ONLY(TEST_VREV(, mfloat, mf, 8, 8, 64));
213 TEST_VREV(q, int, s, 8, 16, 64);
214 TEST_VREV(q, int, s, 16, 8, 64);
215 TEST_VREV(q, int, s, 32, 4, 64);
216 TEST_VREV(q, uint, u, 8, 16, 64);
217 TEST_VREV(q, uint, u, 16, 8, 64);
218 TEST_VREV(q, uint, u, 32, 4, 64);
219 TEST_VREV(q, poly, p, 8, 16, 64);
220 TEST_VREV(q, poly, p, 16, 8, 64);
221 MFLOAT8_ONLY(TEST_VREV(q, mfloat, mf, 8, 16, 64));
222
223 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_vrev64, "");
224 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_vrev64, "");
225 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_vrev64, "");
226 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_vrev64, "");
227 CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected_vrev64, "");
228 CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_vrev64, "");
229 CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected_vrev64, "");
230 CHECK_POLY(TEST_MSG, poly, 16, 4, PRIx16, expected_vrev64, "");
231 MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 8, PRIx8, expected_vrev64, ""));
232 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_vrev64, "");
233 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_vrev64, "");
234 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_vrev64, "");
235 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_vrev64, "");
236 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_vrev64, "");
237 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_vrev64, "");
238 CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected_vrev64, "");
239 CHECK_POLY(TEST_MSG, poly, 16, 8, PRIx16, expected_vrev64, "");
240 MFLOAT8_ONLY(CHECK_FP(TEST_MSG, mfloat, 8, 16, PRIx8, expected_vrev64, ""));
241
242 #if defined (FP16_SUPPORTED)
243 TEST_VREV (, float, f, 16, 4, 64);
244 TEST_VREV (q, float, f, 16, 8, 64);
245 CHECK_FP(TEST_MSG, float, 16, 4, PRIx32, expected_vrev64, "");
246 CHECK_FP(TEST_MSG, float, 16, 8, PRIx32, expected_vrev64, "");
247 #endif
248 TEST_VREV(, float, f, 32, 2, 64);
249 TEST_VREV(q, float, f, 32, 4, 64);
250 CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected_vrev64, "");
251 CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_vrev64, "");
252 }
253
254 int main (void)
255 {
256 exec_vrev ();
257 return 0;
258 }