Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vtrn_half.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. */
8 VECT_VAR_DECL(expected,int,8,8) [] = { 0xf0, 0x11, 0xf2, 0x11,
9 0xf4, 0x11, 0xf6, 0x11 };
10 VECT_VAR_DECL(expected,int,16,4) [] = { 0xfff0, 0x22, 0xfff2, 0x22 };
11 VECT_VAR_DECL(expected,int,32,2) [] = { 0xfffffff0, 0x33 };
12 VECT_VAR_DECL(expected,int,64,1) [] = { 0xfffffffffffffff0 };
13 VECT_VAR_DECL(expected,uint,8,8) [] = { 0xf0, 0x55, 0xf2, 0x55,
14 0xf4, 0x55, 0xf6, 0x55 };
15 VECT_VAR_DECL(expected,uint,16,4) [] = { 0xfff0, 0x66, 0xfff2, 0x66 };
16 VECT_VAR_DECL(expected,uint,32,2) [] = { 0xfffffff0, 0x77 };
17 VECT_VAR_DECL(expected,uint,64,1) [] = { 0xfffffffffffffff0 };
18 VECT_VAR_DECL(expected,poly,8,8) [] = { 0xf0, 0x55, 0xf2, 0x55,
19 0xf4, 0x55, 0xf6, 0x55 };
20 VECT_VAR_DECL(expected,poly,16,4) [] = { 0xfff0, 0x66, 0xfff2, 0x66 };
21 VECT_VAR_DECL(expected,hfloat,32,2) [] = { 0xc1800000, 0x42066666 };
22 #if MFLOAT8_SUPPORTED
23 VECT_VAR_DECL(expected,hmfloat,8,8) [] = { 0xf0, 0x29, 0xf2, 0x29,
24 0xf4, 0x29, 0xf6, 0x29 };
25 #endif
26 #if defined (FP16_SUPPORTED)
27 VECT_VAR_DECL (expected, hfloat, 16, 4) [] = { 0xcc00, 0x4b4d,
28 0xcb00, 0x4b4d };
29 #endif
30 VECT_VAR_DECL(expected,int,8,16) [] = { 0xf0, 0x11, 0xf2, 0x11,
31 0xf4, 0x11, 0xf6, 0x11,
32 0xf8, 0x11, 0xfa, 0x11,
33 0xfc, 0x11, 0xfe, 0x11 };
34 VECT_VAR_DECL(expected,int,16,8) [] = { 0xfff0, 0x22, 0xfff2, 0x22,
35 0xfff4, 0x22, 0xfff6, 0x22 };
36 VECT_VAR_DECL(expected,int,32,4) [] = { 0xfffffff0, 0x33,
37 0xfffffff2, 0x33 };
38 VECT_VAR_DECL(expected,int,64,2) [] = { 0xfffffffffffffff0,
39 0x44 };
40 VECT_VAR_DECL(expected,uint,8,16) [] = { 0xf0, 0x55, 0xf2, 0x55,
41 0xf4, 0x55, 0xf6, 0x55,
42 0xf8, 0x55, 0xfa, 0x55,
43 0xfc, 0x55, 0xfe, 0x55 };
44 VECT_VAR_DECL(expected,uint,16,8) [] = { 0xfff0, 0x66, 0xfff2, 0x66,
45 0xfff4, 0x66, 0xfff6, 0x66 };
46 VECT_VAR_DECL(expected,uint,32,4) [] = { 0xfffffff0, 0x77,
47 0xfffffff2, 0x77 };
48 VECT_VAR_DECL(expected,uint,64,2) [] = { 0xfffffffffffffff0,
49 0x88 };
50 VECT_VAR_DECL(expected,poly,8,16) [] = { 0xf0, 0x55, 0xf2, 0x55,
51 0xf4, 0x55, 0xf6, 0x55,
52 0xf8, 0x55, 0xfa, 0x55,
53 0xfc, 0x55, 0xfe, 0x55 };
54 VECT_VAR_DECL(expected,poly,16,8) [] = { 0xfff0, 0x66, 0xfff2, 0x66,
55 0xfff4, 0x66, 0xfff6, 0x66 };
56 #if MFLOAT8_SUPPORTED
57 VECT_VAR_DECL(expected,hmfloat,8,16) [] = { 0xf0, 0xea, 0xf2, 0xea,
58 0xf4, 0xea, 0xf6, 0xea,
59 0xf8, 0xea, 0xfa, 0xea,
60 0xfc, 0xea, 0xfe, 0xea };
61 #endif
62 #if defined (FP16_SUPPORTED)
63 VECT_VAR_DECL (expected, hfloat, 16, 8) [] = { 0xcc00, 0x4b4d,
64 0xcb00, 0x4b4d,
65 0xca00, 0x4b4d,
66 0xc900, 0x4b4d };
67 #endif
68 VECT_VAR_DECL(expected,hfloat,32,4) [] = { 0xc1800000, 0x42073333,
69 0xc1600000, 0x42073333 };
70
71 #define TEST_MSG "VTRN1"
72 void exec_vtrn_half (void)
73 {
74 #define TEST_VTRN(PART, Q, T1, T2, W, N) \
75 VECT_VAR(vector_res, T1, W, N) = \
76 vtrn##PART##Q##_##T2##W(VECT_VAR(vector, T1, W, N), \
77 VECT_VAR(vector2, T1, W, N)); \
78 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
79
80 #define TEST_VTRN1(Q, T1, T2, W, N) TEST_VTRN(1, Q, T1, T2, W, N)
81
82 /* Input vector can only have 64 bits. */
83 DECL_VARIABLE_ALL_VARIANTS(vector);
84 DECL_VARIABLE_ALL_VARIANTS(vector2);
85
86 DECL_VARIABLE_ALL_VARIANTS(vector_res);
87
88 clean_results ();
89 /* We don't have vtrn1_T64x1, so set expected to the clean value. */
90 CLEAN(expected, int, 64, 1);
91 CLEAN(expected, uint, 64, 1);
92
93 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer);
94 #if MFLOAT8_SUPPORTED
95 VLOAD(vector, buffer, , mfloat, mf, 8, 8);
96 VLOAD(vector, buffer, q, mfloat, mf, 8, 16);
97 #endif
98 #if defined (FP16_SUPPORTED)
99 VLOAD(vector, buffer, , float, f, 16, 4);
100 VLOAD(vector, buffer, q, float, f, 16, 8);
101 #endif
102 VLOAD(vector, buffer, , float, f, 32, 2);
103 VLOAD(vector, buffer, q, float, f, 32, 4);
104 VLOAD(vector, buffer, q, float, f, 64, 2);
105
106 /* Choose arbitrary initialization values. */
107 VDUP(vector2, , int, s, 8, 8, 0x11);
108 VDUP(vector2, , int, s, 16, 4, 0x22);
109 VDUP(vector2, , int, s, 32, 2, 0x33);
110 VDUP(vector2, , uint, u, 8, 8, 0x55);
111 VDUP(vector2, , uint, u, 16, 4, 0x66);
112 VDUP(vector2, , uint, u, 32, 2, 0x77);
113 VDUP(vector2, , poly, p, 8, 8, 0x55);
114 VDUP(vector2, , poly, p, 16, 4, 0x66);
115 MFLOAT8_ONLY(VDUP(vector2, , mfloat, mf, 8, 8, MFLOAT8(0x29)));
116 #if defined (FP16_SUPPORTED)
117 VDUP (vector2, , float, f, 16, 4, 14.6f); /* 14.6f is 0x4b4d. */
118 #endif
119 VDUP(vector2, , float, f, 32, 2, 33.6f);
120
121 VDUP(vector2, q, int, s, 8, 16, 0x11);
122 VDUP(vector2, q, int, s, 16, 8, 0x22);
123 VDUP(vector2, q, int, s, 32, 4, 0x33);
124 VDUP(vector2, q, int, s, 64, 2, 0x44);
125 VDUP(vector2, q, uint, u, 8, 16, 0x55);
126 VDUP(vector2, q, uint, u, 16, 8, 0x66);
127 VDUP(vector2, q, uint, u, 32, 4, 0x77);
128 VDUP(vector2, q, uint, u, 64, 2, 0x88);
129 VDUP(vector2, q, poly, p, 8, 16, 0x55);
130 VDUP(vector2, q, poly, p, 16, 8, 0x66);
131 MFLOAT8_ONLY(VDUP(vector2, q, mfloat, mf, 8, 16, MFLOAT8(0xea)));
132 #if defined (FP16_SUPPORTED)
133 VDUP (vector2, q, float, f, 16, 8, 14.6f);
134 #endif
135 VDUP(vector2, q, float, f, 32, 4, 33.8f);
136 VDUP(vector2, q, float, f, 64, 2, 33.8f);
137
138 TEST_VTRN1(, int, s, 8, 8);
139 TEST_VTRN1(, int, s, 16, 4);
140 TEST_VTRN1(, int, s, 32, 2);
141 TEST_VTRN1(, uint, u, 8, 8);
142 TEST_VTRN1(, uint, u, 16, 4);
143 TEST_VTRN1(, uint, u, 32, 2);
144 TEST_VTRN1(, poly, p, 8, 8);
145 TEST_VTRN1(, poly, p, 16, 4);
146 MFLOAT8_ONLY(TEST_VTRN1(, mfloat, mf, 8, 8));
147 #if defined (FP16_SUPPORTED)
148 TEST_VTRN1(, float, f, 16, 4);
149 #endif
150 TEST_VTRN1(, float, f, 32, 2);
151
152 TEST_VTRN1(q, int, s, 8, 16);
153 TEST_VTRN1(q, int, s, 16, 8);
154 TEST_VTRN1(q, int, s, 32, 4);
155 TEST_VTRN1(q, int, s, 64, 2);
156 TEST_VTRN1(q, uint, u, 8, 16);
157 TEST_VTRN1(q, uint, u, 16, 8);
158 TEST_VTRN1(q, uint, u, 32, 4);
159 TEST_VTRN1(q, uint, u, 64, 2);
160 TEST_VTRN1(q, poly, p, 8, 16);
161 TEST_VTRN1(q, poly, p, 16, 8);
162 MFLOAT8_ONLY(TEST_VTRN1(q, mfloat, mf, 8, 16));
163 #if defined (FP16_SUPPORTED)
164 TEST_VTRN1(q, float, f, 16, 8);
165 #endif
166 TEST_VTRN1(q, float, f, 32, 4);
167 TEST_VTRN1(q, float, f, 64, 2);
168
169 #if defined (FP16_SUPPORTED)
170 CHECK_RESULTS (TEST_MSG, "");
171 #else
172 CHECK_RESULTS_NO_FP16 (TEST_MSG, "");
173 #endif
174
175 #undef TEST_MSG
176 #define TEST_MSG "VTRN2"
177
178 #define TEST_VTRN2(Q, T1, T2, W, N) TEST_VTRN(2, Q, T1, T2, W, N)
179
180 /* Expected results. */
181 VECT_VAR_DECL(expected2,int,8,8) [] = { 0xf1, 0x11, 0xf3, 0x11,
182 0xf5, 0x11, 0xf7, 0x11 };
183 VECT_VAR_DECL(expected2,int,16,4) [] = { 0xfff1, 0x22, 0xfff3, 0x22 };
184 VECT_VAR_DECL(expected2,int,32,2) [] = { 0xfffffff1, 0x33 };
185 VECT_VAR_DECL(expected2,int,64,1) [] = { 0xfffffffffffffff1 };
186 VECT_VAR_DECL(expected2,uint,8,8) [] = { 0xf1, 0x55, 0xf3, 0x55,
187 0xf5, 0x55, 0xf7, 0x55 };
188 VECT_VAR_DECL(expected2,uint,16,4) [] = { 0xfff1, 0x66, 0xfff3, 0x66 };
189 VECT_VAR_DECL(expected2,uint,32,2) [] = { 0xfffffff1, 0x77 };
190 VECT_VAR_DECL(expected2,uint,64,1) [] = { 0xfffffffffffffff1 };
191 VECT_VAR_DECL(expected2,poly,8,8) [] = { 0xf1, 0x55, 0xf3, 0x55,
192 0xf5, 0x55, 0xf7, 0x55 };
193 VECT_VAR_DECL(expected2,poly,16,4) [] = { 0xfff1, 0x66, 0xfff3, 0x66 };
194 #if MFLOAT8_SUPPORTED
195 VECT_VAR_DECL(expected2,hmfloat,8,8) [] = { 0xf1, 0x29, 0xf3, 0x29,
196 0xf5, 0x29, 0xf7, 0x29 };
197 #endif
198 VECT_VAR_DECL(expected2,hfloat,32,2) [] = { 0xc1700000, 0x42066666 };
199 #if defined (FP16_SUPPORTED)
200 VECT_VAR_DECL (expected2, hfloat, 16, 4) [] = { 0xcb80, 0x4b4d,
201 0xca80, 0x4b4d };
202 #endif
203 VECT_VAR_DECL(expected2,int,8,16) [] = { 0xf1, 0x11, 0xf3, 0x11,
204 0xf5, 0x11, 0xf7, 0x11,
205 0xf9, 0x11, 0xfb, 0x11,
206 0xfd, 0x11, 0xff, 0x11 };
207 VECT_VAR_DECL(expected2,int,16,8) [] = { 0xfff1, 0x22, 0xfff3, 0x22,
208 0xfff5, 0x22, 0xfff7, 0x22 };
209 VECT_VAR_DECL(expected2,int,32,4) [] = { 0xfffffff1, 0x33,
210 0xfffffff3, 0x33 };
211 VECT_VAR_DECL(expected2,int,64,2) [] = { 0xfffffffffffffff1,
212 0x44 };
213 VECT_VAR_DECL(expected2,uint,8,16) [] = { 0xf1, 0x55, 0xf3, 0x55,
214 0xf5, 0x55, 0xf7, 0x55,
215 0xf9, 0x55, 0xfb, 0x55,
216 0xfd, 0x55, 0xff, 0x55 };
217 VECT_VAR_DECL(expected2,uint,16,8) [] = { 0xfff1, 0x66, 0xfff3, 0x66,
218 0xfff5, 0x66, 0xfff7, 0x66 };
219 VECT_VAR_DECL(expected2,uint,32,4) [] = { 0xfffffff1, 0x77,
220 0xfffffff3, 0x77 };
221 VECT_VAR_DECL(expected2,uint,64,2) [] = { 0xfffffffffffffff1,
222 0x88 };
223 VECT_VAR_DECL(expected2,poly,8,16) [] = { 0xf1, 0x55, 0xf3, 0x55,
224 0xf5, 0x55, 0xf7, 0x55,
225 0xf9, 0x55, 0xfb, 0x55,
226 0xfd, 0x55, 0xff, 0x55 };
227 VECT_VAR_DECL(expected2,poly,16,8) [] = { 0xfff1, 0x66, 0xfff3, 0x66,
228 0xfff5, 0x66, 0xfff7, 0x66 };
229 #if MFLOAT8_SUPPORTED
230 VECT_VAR_DECL(expected2,hmfloat,8,16) [] = { 0xf1, 0xea, 0xf3, 0xea,
231 0xf5, 0xea, 0xf7, 0xea,
232 0xf9, 0xea, 0xfb, 0xea,
233 0xfd, 0xea, 0xff, 0xea };
234 #endif
235 #if defined (FP16_SUPPORTED)
236 VECT_VAR_DECL (expected2, hfloat, 16, 8) [] = { 0xcb80, 0x4b4d,
237 0xca80, 0x4b4d,
238 0xc980, 0x4b4d,
239 0xc880, 0x4b4d };
240 #endif
241 VECT_VAR_DECL(expected2,hfloat,32,4) [] = { 0xc1700000, 0x42073333,
242 0xc1500000, 0x42073333 };
243 clean_results ();
244 CLEAN(expected2, int, 64, 1);
245 CLEAN(expected2, uint, 64, 1);
246
247 TEST_VTRN2(, int, s, 8, 8);
248 TEST_VTRN2(, int, s, 16, 4);
249 TEST_VTRN2(, int, s, 32, 2);
250 TEST_VTRN2(, uint, u, 8, 8);
251 TEST_VTRN2(, uint, u, 16, 4);
252 TEST_VTRN2(, uint, u, 32, 2);
253 TEST_VTRN2(, poly, p, 8, 8);
254 TEST_VTRN2(, poly, p, 16, 4);
255 MFLOAT8_ONLY(TEST_VTRN2(, mfloat, mf, 8, 8));
256 #if defined (FP16_SUPPORTED)
257 TEST_VTRN2(, float, f, 16, 4);
258 #endif
259 TEST_VTRN2(, float, f, 32, 2);
260
261 TEST_VTRN2(q, int, s, 8, 16);
262 TEST_VTRN2(q, int, s, 16, 8);
263 TEST_VTRN2(q, int, s, 32, 4);
264 TEST_VTRN2(q, int, s, 64, 2);
265 TEST_VTRN2(q, uint, u, 8, 16);
266 TEST_VTRN2(q, uint, u, 16, 8);
267 TEST_VTRN2(q, uint, u, 32, 4);
268 TEST_VTRN2(q, uint, u, 64, 2);
269 TEST_VTRN2(q, poly, p, 8, 16);
270 TEST_VTRN2(q, poly, p, 16, 8);
271 MFLOAT8_ONLY(TEST_VTRN2(q, mfloat, mf, 8, 16));
272 #if defined (FP16_SUPPORTED)
273 TEST_VTRN2(q, float, f, 16, 8);
274 #endif
275 TEST_VTRN2(q, float, f, 32, 4);
276 TEST_VTRN2(q, float, f, 64, 2);
277
278 CHECK_RESULTS_NAMED (TEST_MSG, expected2, "");
279 #if defined (FP16_SUPPORTED)
280 CHECK_FP(TEST_MSG, float, 16, 4, PRIx16, expected2, "");
281 CHECK_FP(TEST_MSG, float, 16, 8, PRIx16, expected2, "");
282 #endif
283 }
284
285 int main (void)
286 {
287 exec_vtrn_half ();
288 return 0;
289 }