Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vrshr_n.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) [] = { 0xf8, 0xf9, 0xf9, 0xfa,
7 0xfa, 0xfb, 0xfb, 0xfc };
8 VECT_VAR_DECL(expected,int,16,4) [] = { 0x0, 0x0, 0x0, 0x0 };
9 VECT_VAR_DECL(expected,int,32,2) [] = { 0xfffffffc, 0xfffffffc };
10 VECT_VAR_DECL(expected,int,64,1) [] = { 0x0 };
11 VECT_VAR_DECL(expected,uint,8,8) [] = { 0x3c, 0x3c, 0x3d, 0x3d,
12 0x3d, 0x3d, 0x3e, 0x3e };
13 VECT_VAR_DECL(expected,uint,16,4) [] = { 0x1ffe, 0x1ffe, 0x1ffe, 0x1ffe };
14 VECT_VAR_DECL(expected,uint,32,2) [] = { 0x8000000, 0x8000000 };
15 VECT_VAR_DECL(expected,uint,64,1) [] = { 0x80000000 };
16 VECT_VAR_DECL(expected,int,8,16) [] = { 0xf8, 0xf9, 0xf9, 0xfa,
17 0xfa, 0xfb, 0xfb, 0xfc,
18 0xfc, 0xfd, 0xfd, 0xfe,
19 0xfe, 0xff, 0xff, 0x0 };
20 VECT_VAR_DECL(expected,int,16,8) [] = { 0x0, 0x0, 0x0, 0x0,
21 0x0, 0x0, 0x0, 0x0 };
22 VECT_VAR_DECL(expected,int,32,4) [] = { 0xfffffffc, 0xfffffffc,
23 0xfffffffd, 0xfffffffd };
24 VECT_VAR_DECL(expected,int,64,2) [] = { 0x0, 0x0 };
25 VECT_VAR_DECL(expected,uint,8,16) [] = { 0x3c, 0x3c, 0x3d, 0x3d,
26 0x3d, 0x3d, 0x3e, 0x3e,
27 0x3e, 0x3e, 0x3f, 0x3f,
28 0x3f, 0x3f, 0x40, 0x40 };
29 VECT_VAR_DECL(expected,uint,16,8) [] = { 0x1ffe, 0x1ffe, 0x1ffe, 0x1ffe,
30 0x1fff, 0x1fff, 0x1fff, 0x1fff };
31 VECT_VAR_DECL(expected,uint,32,4) [] = { 0x8000000, 0x8000000,
32 0x8000000, 0x8000000 };
33 VECT_VAR_DECL(expected,uint,64,2) [] = { 0x80000000, 0x80000000 };
34
35 /* Expected results with maximum input and max shift amount. */
36 VECT_VAR_DECL(expected_max_sh_max,int,8,8) [] = { 0x0, 0x0, 0x0, 0x0,
37 0x0, 0x0, 0x0, 0x0 };
38 VECT_VAR_DECL(expected_max_sh_max,int,16,4) [] = { 0x0, 0x0, 0x0, 0x0 };
39 VECT_VAR_DECL(expected_max_sh_max,int,32,2) [] = { 0x0, 0x0 };
40 VECT_VAR_DECL(expected_max_sh_max,int,64,1) [] = { 0x0 };
41 VECT_VAR_DECL(expected_max_sh_max,uint,8,8) [] = { 0x1, 0x1, 0x1, 0x1,
42 0x1, 0x1, 0x1, 0x1 };
43 VECT_VAR_DECL(expected_max_sh_max,uint,16,4) [] = { 0x1, 0x1, 0x1, 0x1 };
44 VECT_VAR_DECL(expected_max_sh_max,uint,32,2) [] = { 0x1, 0x1 };
45 VECT_VAR_DECL(expected_max_sh_max,uint,64,1) [] = { 0x1 };
46 VECT_VAR_DECL(expected_max_sh_max,int,8,16) [] = { 0x0, 0x0, 0x0, 0x0,
47 0x0, 0x0, 0x0, 0x0,
48 0x0, 0x0, 0x0, 0x0,
49 0x0, 0x0, 0x0, 0x0 };
50 VECT_VAR_DECL(expected_max_sh_max,int,16,8) [] = { 0x0, 0x0, 0x0, 0x0,
51 0x0, 0x0, 0x0, 0x0 };
52 VECT_VAR_DECL(expected_max_sh_max,int,32,4) [] = { 0x0, 0x0, 0x0, 0x0 };
53 VECT_VAR_DECL(expected_max_sh_max,int,64,2) [] = { 0x0, 0x0 };
54 VECT_VAR_DECL(expected_max_sh_max,uint,8,16) [] = { 0x1, 0x1, 0x1, 0x1,
55 0x1, 0x1, 0x1, 0x1,
56 0x1, 0x1, 0x1, 0x1,
57 0x1, 0x1, 0x1, 0x1 };
58 VECT_VAR_DECL(expected_max_sh_max,uint,16,8) [] = { 0x1, 0x1, 0x1, 0x1,
59 0x1, 0x1, 0x1, 0x1 };
60 VECT_VAR_DECL(expected_max_sh_max,uint,32,4) [] = { 0x1, 0x1, 0x1, 0x1 };
61 VECT_VAR_DECL(expected_max_sh_max,uint,64,2) [] = { 0x1, 0x1 };
62
63 /* Expected results with maximum input and shift by 1. */
64 VECT_VAR_DECL(expected_max_sh_1,int,8,8) [] = { 0x40, 0x40, 0x40, 0x40,
65 0x40, 0x40, 0x40, 0x40 };
66 VECT_VAR_DECL(expected_max_sh_1,int,16,4) [] = { 0x4000, 0x4000,
67 0x4000, 0x4000 };
68 VECT_VAR_DECL(expected_max_sh_1,int,32,2) [] = { 0x40000000, 0x40000000 };
69 VECT_VAR_DECL(expected_max_sh_1,int,64,1) [] = { 0x4000000000000000 };
70 VECT_VAR_DECL(expected_max_sh_1,uint,8,8) [] = { 0x80, 0x80, 0x80, 0x80,
71 0x80, 0x80, 0x80, 0x80 };
72 VECT_VAR_DECL(expected_max_sh_1,uint,16,4) [] = { 0x8000, 0x8000,
73 0x8000, 0x8000 };
74 VECT_VAR_DECL(expected_max_sh_1,uint,32,2) [] = { 0x80000000, 0x80000000 };
75 VECT_VAR_DECL(expected_max_sh_1,uint,64,1) [] = { 0x8000000000000000 };
76 VECT_VAR_DECL(expected_max_sh_1,int,8,16) [] = { 0x40, 0x40, 0x40, 0x40,
77 0x40, 0x40, 0x40, 0x40,
78 0x40, 0x40, 0x40, 0x40,
79 0x40, 0x40, 0x40, 0x40 };
80 VECT_VAR_DECL(expected_max_sh_1,int,16,8) [] = { 0x4000, 0x4000,
81 0x4000, 0x4000,
82 0x4000, 0x4000,
83 0x4000, 0x4000 };
84 VECT_VAR_DECL(expected_max_sh_1,int,32,4) [] = { 0x40000000, 0x40000000,
85 0x40000000, 0x40000000 };
86 VECT_VAR_DECL(expected_max_sh_1,int,64,2) [] = { 0x4000000000000000,
87 0x4000000000000000 };
88 VECT_VAR_DECL(expected_max_sh_1,uint,8,16) [] = { 0x80, 0x80, 0x80, 0x80,
89 0x80, 0x80, 0x80, 0x80,
90 0x80, 0x80, 0x80, 0x80,
91 0x80, 0x80, 0x80, 0x80 };
92 VECT_VAR_DECL(expected_max_sh_1,uint,16,8) [] = { 0x8000, 0x8000,
93 0x8000, 0x8000,
94 0x8000, 0x8000,
95 0x8000, 0x8000 };
96 VECT_VAR_DECL(expected_max_sh_1,uint,32,4) [] = { 0x80000000, 0x80000000,
97 0x80000000, 0x80000000 };
98 VECT_VAR_DECL(expected_max_sh_1,uint,64,2) [] = { 0x8000000000000000,
99 0x8000000000000000 };
100
101 /* Expected results with maximum input and shift by 3. */
102 VECT_VAR_DECL(expected_max_sh_3,int,8,8) [] = { 0x10, 0x10, 0x10, 0x10,
103 0x10, 0x10, 0x10, 0x10 };
104 VECT_VAR_DECL(expected_max_sh_3,int,16,4) [] = { 0x1000, 0x1000,
105 0x1000, 0x1000 };
106 VECT_VAR_DECL(expected_max_sh_3,int,32,2) [] = { 0x10000000, 0x10000000 };
107 VECT_VAR_DECL(expected_max_sh_3,int,64,1) [] = { 0x1000000000000000 };
108 VECT_VAR_DECL(expected_max_sh_3,uint,8,8) [] = { 0x20, 0x20, 0x20, 0x20,
109 0x20, 0x20, 0x20, 0x20 };
110 VECT_VAR_DECL(expected_max_sh_3,uint,16,4) [] = { 0x2000, 0x2000,
111 0x2000, 0x2000 };
112 VECT_VAR_DECL(expected_max_sh_3,uint,32,2) [] = { 0x20000000, 0x20000000 };
113 VECT_VAR_DECL(expected_max_sh_3,uint,64,1) [] = { 0x2000000000000000 };
114 VECT_VAR_DECL(expected_max_sh_3,int,8,16) [] = { 0x10, 0x10, 0x10, 0x10,
115 0x10, 0x10, 0x10, 0x10,
116 0x10, 0x10, 0x10, 0x10,
117 0x10, 0x10, 0x10, 0x10 };
118 VECT_VAR_DECL(expected_max_sh_3,int,16,8) [] = { 0x1000, 0x1000,
119 0x1000, 0x1000,
120 0x1000, 0x1000,
121 0x1000, 0x1000 };
122 VECT_VAR_DECL(expected_max_sh_3,int,32,4) [] = { 0x10000000, 0x10000000,
123 0x10000000, 0x10000000 };
124 VECT_VAR_DECL(expected_max_sh_3,int,64,2) [] = { 0x1000000000000000,
125 0x1000000000000000 };
126 VECT_VAR_DECL(expected_max_sh_3,uint,8,16) [] = { 0x20, 0x20, 0x20, 0x20,
127 0x20, 0x20, 0x20, 0x20,
128 0x20, 0x20, 0x20, 0x20,
129 0x20, 0x20, 0x20, 0x20 };
130 VECT_VAR_DECL(expected_max_sh_3,uint,16,8) [] = { 0x2000, 0x2000,
131 0x2000, 0x2000,
132 0x2000, 0x2000,
133 0x2000, 0x2000 };
134 VECT_VAR_DECL(expected_max_sh_3,uint,32,4) [] = { 0x20000000, 0x20000000,
135 0x20000000, 0x20000000 };
136 VECT_VAR_DECL(expected_max_sh_3,uint,64,2) [] = { 0x2000000000000000,
137 0x2000000000000000 };
138
139 /* Expected results with max negative input (for signed types, shift
140 by 1. */
141 VECT_VAR_DECL(expected_max_neg_sh_1,int,8,8) [] = { 0xc0, 0xc0, 0xc0, 0xc0,
142 0xc0, 0xc0, 0xc0, 0xc0 };
143 VECT_VAR_DECL(expected_max_neg_sh_1,int,16,4) [] = { 0xc000, 0xc000,
144 0xc000, 0xc000 };
145 VECT_VAR_DECL(expected_max_neg_sh_1,int,32,2) [] = { 0xc0000000, 0xc0000000 };
146 VECT_VAR_DECL(expected_max_neg_sh_1,int,64,1) [] = { 0xc000000000000000 };
147 VECT_VAR_DECL(expected_max_neg_sh_1,uint,8,8) [] = { 0x80, 0x80, 0x80, 0x80,
148 0x80, 0x80, 0x80, 0x80 };
149 VECT_VAR_DECL(expected_max_neg_sh_1,uint,16,4) [] = { 0x8000, 0x8000,
150 0x8000, 0x8000 };
151 VECT_VAR_DECL(expected_max_neg_sh_1,uint,32,2) [] = { 0x80000000, 0x80000000 };
152 VECT_VAR_DECL(expected_max_neg_sh_1,uint,64,1) [] = { 0x8000000000000000 };
153 VECT_VAR_DECL(expected_max_neg_sh_1,int,8,16) [] = { 0xc0, 0xc0, 0xc0, 0xc0,
154 0xc0, 0xc0, 0xc0, 0xc0,
155 0xc0, 0xc0, 0xc0, 0xc0,
156 0xc0, 0xc0, 0xc0, 0xc0 };
157 VECT_VAR_DECL(expected_max_neg_sh_1,int,16,8) [] = { 0xc000, 0xc000,
158 0xc000, 0xc000,
159 0xc000, 0xc000,
160 0xc000, 0xc000 };
161 VECT_VAR_DECL(expected_max_neg_sh_1,int,32,4) [] = { 0xc0000000, 0xc0000000,
162 0xc0000000, 0xc0000000 };
163 VECT_VAR_DECL(expected_max_neg_sh_1,int,64,2) [] = { 0xc000000000000000,
164 0xc000000000000000 };
165 VECT_VAR_DECL(expected_max_neg_sh_1,uint,8,16) [] = { 0x80, 0x80, 0x80, 0x80,
166 0x80, 0x80, 0x80, 0x80,
167 0x80, 0x80, 0x80, 0x80,
168 0x80, 0x80, 0x80, 0x80 };
169 VECT_VAR_DECL(expected_max_neg_sh_1,uint,16,8) [] = { 0x8000, 0x8000,
170 0x8000, 0x8000,
171 0x8000, 0x8000,
172 0x8000, 0x8000 };
173 VECT_VAR_DECL(expected_max_neg_sh_1,uint,32,4) [] = { 0x80000000, 0x80000000,
174 0x80000000, 0x80000000 };
175 VECT_VAR_DECL(expected_max_neg_sh_1,uint,64,2) [] = { 0x8000000000000000,
176 0x8000000000000000 };
177
178 /* Expected results with max negative input (for signed types, shift
179 by 3. */
180 VECT_VAR_DECL(expected_max_neg_sh_3,int,8,8) [] = { 0xf0, 0xf0, 0xf0, 0xf0,
181 0xf0, 0xf0, 0xf0, 0xf0 };
182 VECT_VAR_DECL(expected_max_neg_sh_3,int,16,4) [] = { 0xf000, 0xf000,
183 0xf000, 0xf000 };
184 VECT_VAR_DECL(expected_max_neg_sh_3,int,32,2) [] = { 0xf0000000, 0xf0000000 };
185 VECT_VAR_DECL(expected_max_neg_sh_3,int,64,1) [] = { 0xf000000000000000 };
186 VECT_VAR_DECL(expected_max_neg_sh_3,uint,8,8) [] = { 0x20, 0x20, 0x20, 0x20,
187 0x20, 0x20, 0x20, 0x20 };
188 VECT_VAR_DECL(expected_max_neg_sh_3,uint,16,4) [] = { 0x2000, 0x2000,
189 0x2000, 0x2000 };
190 VECT_VAR_DECL(expected_max_neg_sh_3,uint,32,2) [] = { 0x20000000, 0x20000000 };
191 VECT_VAR_DECL(expected_max_neg_sh_3,uint,64,1) [] = { 0x2000000000000000 };
192 VECT_VAR_DECL(expected_max_neg_sh_3,int,8,16) [] = { 0xf0, 0xf0, 0xf0, 0xf0,
193 0xf0, 0xf0, 0xf0, 0xf0,
194 0xf0, 0xf0, 0xf0, 0xf0,
195 0xf0, 0xf0, 0xf0, 0xf0 };
196 VECT_VAR_DECL(expected_max_neg_sh_3,int,16,8) [] = { 0xf000, 0xf000,
197 0xf000, 0xf000,
198 0xf000, 0xf000,
199 0xf000, 0xf000 };
200 VECT_VAR_DECL(expected_max_neg_sh_3,int,32,4) [] = { 0xf0000000, 0xf0000000,
201 0xf0000000, 0xf0000000 };
202 VECT_VAR_DECL(expected_max_neg_sh_3,int,64,2) [] = { 0xf000000000000000,
203 0xf000000000000000 };
204 VECT_VAR_DECL(expected_max_neg_sh_3,uint,8,16) [] = { 0x20, 0x20, 0x20, 0x20,
205 0x20, 0x20, 0x20, 0x20,
206 0x20, 0x20, 0x20, 0x20,
207 0x20, 0x20, 0x20, 0x20 };
208 VECT_VAR_DECL(expected_max_neg_sh_3,uint,16,8) [] = { 0x2000, 0x2000,
209 0x2000, 0x2000,
210 0x2000, 0x2000,
211 0x2000, 0x2000 };
212 VECT_VAR_DECL(expected_max_neg_sh_3,uint,32,4) [] = { 0x20000000, 0x20000000,
213 0x20000000, 0x20000000 };
214 VECT_VAR_DECL(expected_max_neg_sh_3,uint,64,2) [] = { 0x2000000000000000,
215 0x2000000000000000 };
216
217 #define TEST_MSG "VRSHR_N"
218 void exec_vrshr_n (void)
219 {
220 /* Basic test: y=vrshr_n(x,v), then store the result. */
221 #define TEST_VRSHR_N(Q, T1, T2, W, N, V) \
222 VECT_VAR(vector_res, T1, W, N) = \
223 vrshr##Q##_n_##T2##W(VECT_VAR(vector, T1, W, N), \
224 V); \
225 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
226
227 DECL_VARIABLE_ALL_VARIANTS(vector);
228 DECL_VARIABLE_ALL_VARIANTS(vector_res);
229
230 clean_results ();
231
232 /* Initialize input "vector" from "buffer". */
233 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer);
234
235 /* Choose shift amount arbitrarily. */
236 TEST_VRSHR_N(, int, s, 8, 8, 1);
237 TEST_VRSHR_N(, int, s, 16, 4, 12);
238 TEST_VRSHR_N(, int, s, 32, 2, 2);
239 TEST_VRSHR_N(, int, s, 64, 1, 32);
240 TEST_VRSHR_N(, uint, u, 8, 8, 2);
241 TEST_VRSHR_N(, uint, u, 16, 4, 3);
242 TEST_VRSHR_N(, uint, u, 32, 2, 5);
243 TEST_VRSHR_N(, uint, u, 64, 1, 33);
244
245 TEST_VRSHR_N(q, int, s, 8, 16, 1);
246 TEST_VRSHR_N(q, int, s, 16, 8, 12);
247 TEST_VRSHR_N(q, int, s, 32, 4, 2);
248 TEST_VRSHR_N(q, int, s, 64, 2, 32);
249 TEST_VRSHR_N(q, uint, u, 8, 16, 2);
250 TEST_VRSHR_N(q, uint, u, 16, 8, 3);
251 TEST_VRSHR_N(q, uint, u, 32, 4, 5);
252 TEST_VRSHR_N(q, uint, u, 64, 2, 33);
253
254 #define CMT ""
255 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected, CMT);
256 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, CMT);
257 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, CMT);
258 CHECK(TEST_MSG, int, 64, 1, PRIx64, expected, CMT);
259 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected, CMT);
260 CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected, CMT);
261 CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected, CMT);
262 CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected, CMT);
263 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, CMT);
264 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, CMT);
265 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, CMT);
266 CHECK(TEST_MSG, int, 64, 2, PRIx64, expected, CMT);
267 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, CMT);
268 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, CMT);
269 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, CMT);
270 CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected, CMT);
271
272
273 /* Use maximum positive input value. */
274 VDUP(vector, , int, s, 8, 8, 0x7F);
275 VDUP(vector, , int, s, 16, 4, 0x7FFF);
276 VDUP(vector, , int, s, 32, 2, 0x7FFFFFFF);
277 VDUP(vector, , int, s, 64, 1, 0x7FFFFFFFFFFFFFFFLL);
278 VDUP(vector, , uint, u, 8, 8, 0xFF);
279 VDUP(vector, , uint, u, 16, 4, 0xFFFF);
280 VDUP(vector, , uint, u, 32, 2, 0xFFFFFFFF);
281 VDUP(vector, , uint, u, 64, 1, 0xFFFFFFFFFFFFFFFFULL);
282 VDUP(vector, q, int, s, 8, 16, 0x7F);
283 VDUP(vector, q, int, s, 16, 8, 0x7FFF);
284 VDUP(vector, q, int, s, 32, 4, 0x7FFFFFFF);
285 VDUP(vector, q, int, s, 64, 2, 0x7FFFFFFFFFFFFFFFLL);
286 VDUP(vector, q, uint, u, 8, 16, 0xFF);
287 VDUP(vector, q, uint, u, 16, 8, 0xFFFF);
288 VDUP(vector, q, uint, u, 32, 4, 0xFFFFFFFF);
289 VDUP(vector, q, uint, u, 64, 2, 0xFFFFFFFFFFFFFFFFULL);
290
291 /* Use max shift amount, to exercise saturation. */
292 TEST_VRSHR_N(, int, s, 8, 8, 8);
293 TEST_VRSHR_N(, int, s, 16, 4, 16);
294 TEST_VRSHR_N(, int, s, 32, 2, 32);
295 TEST_VRSHR_N(, int, s, 64, 1, 64);
296 TEST_VRSHR_N(, uint, u, 8, 8, 8);
297 TEST_VRSHR_N(, uint, u, 16, 4, 16);
298 TEST_VRSHR_N(, uint, u, 32, 2, 32);
299 TEST_VRSHR_N(, uint, u, 64, 1, 64);
300 TEST_VRSHR_N(q, int, s, 8, 16, 8);
301 TEST_VRSHR_N(q, int, s, 16, 8, 16);
302 TEST_VRSHR_N(q, int, s, 32, 4, 32);
303 TEST_VRSHR_N(q, int, s, 64, 2, 64);
304 TEST_VRSHR_N(q, uint, u, 8, 16, 8);
305 TEST_VRSHR_N(q, uint, u, 16, 8, 16);
306 TEST_VRSHR_N(q, uint, u, 32, 4, 32);
307 TEST_VRSHR_N(q, uint, u, 64, 2, 64);
308
309 #undef CMT
310 #define CMT " (overflow test: max shift amount, max positive input)"
311 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_max_sh_max, CMT);
312 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_max_sh_max, CMT);
313 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_max_sh_max, CMT);
314 CHECK(TEST_MSG, int, 64, 1, PRIx64, expected_max_sh_max, CMT);
315 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_max_sh_max, CMT);
316 CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected_max_sh_max, CMT);
317 CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_max_sh_max, CMT);
318 CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected_max_sh_max, CMT);
319 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_max_sh_max, CMT);
320 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_max_sh_max, CMT);
321 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_max_sh_max, CMT);
322 CHECK(TEST_MSG, int, 64, 2, PRIx64, expected_max_sh_max, CMT);
323 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_max_sh_max, CMT);
324 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_max_sh_max, CMT);
325 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_max_sh_max, CMT);
326 CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected_max_sh_max, CMT);
327
328
329 /* Use 1 as shift amount, to exercise saturation. */
330 TEST_VRSHR_N(, int, s, 8, 8, 1);
331 TEST_VRSHR_N(, int, s, 16, 4, 1);
332 TEST_VRSHR_N(, int, s, 32, 2, 1);
333 TEST_VRSHR_N(, int, s, 64, 1, 1);
334 TEST_VRSHR_N(, uint, u, 8, 8, 1);
335 TEST_VRSHR_N(, uint, u, 16, 4, 1);
336 TEST_VRSHR_N(, uint, u, 32, 2, 1);
337 TEST_VRSHR_N(, uint, u, 64, 1, 1);
338 TEST_VRSHR_N(q, int, s, 8, 16, 1);
339 TEST_VRSHR_N(q, int, s, 16, 8, 1);
340 TEST_VRSHR_N(q, int, s, 32, 4, 1);
341 TEST_VRSHR_N(q, int, s, 64, 2, 1);
342 TEST_VRSHR_N(q, uint, u, 8, 16, 1);
343 TEST_VRSHR_N(q, uint, u, 16, 8, 1);
344 TEST_VRSHR_N(q, uint, u, 32, 4, 1);
345 TEST_VRSHR_N(q, uint, u, 64, 2, 1);
346
347 #undef CMT
348 #define CMT " (overflow test: shift by 1, with max input)"
349 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_max_sh_1, CMT);
350 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_max_sh_1, CMT);
351 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_max_sh_1, CMT);
352 CHECK(TEST_MSG, int, 64, 1, PRIx64, expected_max_sh_1, CMT);
353 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_max_sh_1, CMT);
354 CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected_max_sh_1, CMT);
355 CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_max_sh_1, CMT);
356 CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected_max_sh_1, CMT);
357 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_max_sh_1, CMT);
358 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_max_sh_1, CMT);
359 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_max_sh_1, CMT);
360 CHECK(TEST_MSG, int, 64, 2, PRIx64, expected_max_sh_1, CMT);
361 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_max_sh_1, CMT);
362 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_max_sh_1, CMT);
363 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_max_sh_1, CMT);
364 CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected_max_sh_1, CMT);
365
366
367 /* Use 3 as shift amount, to exercise saturation. */
368 TEST_VRSHR_N(, int, s, 8, 8, 3);
369 TEST_VRSHR_N(, int, s, 16, 4, 3);
370 TEST_VRSHR_N(, int, s, 32, 2, 3);
371 TEST_VRSHR_N(, int, s, 64, 1, 3);
372 TEST_VRSHR_N(, uint, u, 8, 8, 3);
373 TEST_VRSHR_N(, uint, u, 16, 4, 3);
374 TEST_VRSHR_N(, uint, u, 32, 2, 3);
375 TEST_VRSHR_N(, uint, u, 64, 1, 3);
376 TEST_VRSHR_N(q, int, s, 8, 16, 3);
377 TEST_VRSHR_N(q, int, s, 16, 8, 3);
378 TEST_VRSHR_N(q, int, s, 32, 4, 3);
379 TEST_VRSHR_N(q, int, s, 64, 2, 3);
380 TEST_VRSHR_N(q, uint, u, 8, 16, 3);
381 TEST_VRSHR_N(q, uint, u, 16, 8, 3);
382 TEST_VRSHR_N(q, uint, u, 32, 4, 3);
383 TEST_VRSHR_N(q, uint, u, 64, 2, 3);
384
385 #undef CMT
386 #define CMT " (overflow test: shift by 3, with max input)"
387 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_max_sh_3, CMT);
388 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_max_sh_3, CMT);
389 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_max_sh_3, CMT);
390 CHECK(TEST_MSG, int, 64, 1, PRIx64, expected_max_sh_3, CMT);
391 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_max_sh_3, CMT);
392 CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected_max_sh_3, CMT);
393 CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_max_sh_3, CMT);
394 CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected_max_sh_3, CMT);
395 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_max_sh_3, CMT);
396 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_max_sh_3, CMT);
397 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_max_sh_3, CMT);
398 CHECK(TEST_MSG, int, 64, 2, PRIx64, expected_max_sh_3, CMT);
399 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_max_sh_3, CMT);
400 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_max_sh_3, CMT);
401 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_max_sh_3, CMT);
402 CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected_max_sh_3, CMT);
403
404
405 /* Use minimum negative input for signed types. */
406 VDUP(vector, , int, s, 8, 8, 0x80);
407 VDUP(vector, , int, s, 16, 4, 0x8000);
408 VDUP(vector, , int, s, 32, 2, 0x80000000);
409 VDUP(vector, , int, s, 64, 1, 0x8000000000000000LL);
410 VDUP(vector, , uint, u, 8, 8, 0xFF);
411 VDUP(vector, , uint, u, 16, 4, 0xFFFF);
412 VDUP(vector, , uint, u, 32, 2, 0xFFFFFFFF);
413 VDUP(vector, , uint, u, 64, 1, 0xFFFFFFFFFFFFFFFFULL);
414 VDUP(vector, q, int, s, 8, 16, 0x80);
415 VDUP(vector, q, int, s, 16, 8, 0x8000);
416 VDUP(vector, q, int, s, 32, 4, 0x80000000);
417 VDUP(vector, q, int, s, 64, 2, 0x8000000000000000LL);
418 VDUP(vector, q, uint, u, 8, 16, 0xFF);
419 VDUP(vector, q, uint, u, 16, 8, 0xFFFF);
420 VDUP(vector, q, uint, u, 32, 4, 0xFFFFFFFF);
421 VDUP(vector, q, uint, u, 64, 2, 0xFFFFFFFFFFFFFFFFULL);
422
423
424 /* Use 1 as shift amount, to exercise saturation code. */
425 TEST_VRSHR_N(, int, s, 8, 8, 1);
426 TEST_VRSHR_N(, int, s, 16, 4, 1);
427 TEST_VRSHR_N(, int, s, 32, 2, 1);
428 TEST_VRSHR_N(, int, s, 64, 1, 1);
429 TEST_VRSHR_N(, uint, u, 8, 8, 1);
430 TEST_VRSHR_N(, uint, u, 16, 4, 1);
431 TEST_VRSHR_N(, uint, u, 32, 2, 1);
432 TEST_VRSHR_N(, uint, u, 64, 1, 1);
433 TEST_VRSHR_N(q, int, s, 8, 16, 1);
434 TEST_VRSHR_N(q, int, s, 16, 8, 1);
435 TEST_VRSHR_N(q, int, s, 32, 4, 1);
436 TEST_VRSHR_N(q, int, s, 64, 2, 1);
437 TEST_VRSHR_N(q, uint, u, 8, 16, 1);
438 TEST_VRSHR_N(q, uint, u, 16, 8, 1);
439 TEST_VRSHR_N(q, uint, u, 32, 4, 1);
440 TEST_VRSHR_N(q, uint, u, 64, 2, 1);
441
442 #undef CMT
443 #define CMT " (overflow test: shift by 1, with negative input)"
444 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_max_neg_sh_1, CMT);
445 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_max_neg_sh_1, CMT);
446 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_max_neg_sh_1, CMT);
447 CHECK(TEST_MSG, int, 64, 1, PRIx64, expected_max_neg_sh_1, CMT);
448 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_max_neg_sh_1, CMT);
449 CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected_max_neg_sh_1, CMT);
450 CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_max_neg_sh_1, CMT);
451 CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected_max_neg_sh_1, CMT);
452 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_max_neg_sh_1, CMT);
453 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_max_neg_sh_1, CMT);
454 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_max_neg_sh_1, CMT);
455 CHECK(TEST_MSG, int, 64, 2, PRIx64, expected_max_neg_sh_1, CMT);
456 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_max_neg_sh_1, CMT);
457 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_max_neg_sh_1, CMT);
458 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_max_neg_sh_1, CMT);
459 CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected_max_neg_sh_1, CMT);
460
461
462 /* Use 3 as shift amount, to exercise saturation code. */
463 TEST_VRSHR_N(, int, s, 8, 8, 3);
464 TEST_VRSHR_N(, int, s, 16, 4, 3);
465 TEST_VRSHR_N(, int, s, 32, 2, 3);
466 TEST_VRSHR_N(, int, s, 64, 1, 3);
467 TEST_VRSHR_N(, uint, u, 8, 8, 3);
468 TEST_VRSHR_N(, uint, u, 16, 4, 3);
469 TEST_VRSHR_N(, uint, u, 32, 2, 3);
470 TEST_VRSHR_N(, uint, u, 64, 1, 3);
471 TEST_VRSHR_N(q, int, s, 8, 16, 3);
472 TEST_VRSHR_N(q, int, s, 16, 8, 3);
473 TEST_VRSHR_N(q, int, s, 32, 4, 3);
474 TEST_VRSHR_N(q, int, s, 64, 2, 3);
475 TEST_VRSHR_N(q, uint, u, 8, 16, 3);
476 TEST_VRSHR_N(q, uint, u, 16, 8, 3);
477 TEST_VRSHR_N(q, uint, u, 32, 4, 3);
478 TEST_VRSHR_N(q, uint, u, 64, 2, 3);
479
480 #undef CMT
481 #define CMT " (overflow test: shift by 3, with negative input)"
482 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_max_neg_sh_3, CMT);
483 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_max_neg_sh_3, CMT);
484 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_max_neg_sh_3, CMT);
485 CHECK(TEST_MSG, int, 64, 1, PRIx64, expected_max_neg_sh_3, CMT);
486 CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected_max_neg_sh_3, CMT);
487 CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected_max_neg_sh_3, CMT);
488 CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected_max_neg_sh_3, CMT);
489 CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected_max_neg_sh_3, CMT);
490 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_max_neg_sh_3, CMT);
491 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_max_neg_sh_3, CMT);
492 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_max_neg_sh_3, CMT);
493 CHECK(TEST_MSG, int, 64, 2, PRIx64, expected_max_neg_sh_3, CMT);
494 CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_max_neg_sh_3, CMT);
495 CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_max_neg_sh_3, CMT);
496 CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_max_neg_sh_3, CMT);
497 CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected_max_neg_sh_3, CMT);
498 }
499
500 int main (void)
501 {
502 exec_vrshr_n ();
503 return 0;
504 }