Add 469782 to NEWS
[valgrind.git] / memcheck / tests / common / pcmpgt.cpp
blob388d005119f480a2333f473fd6032467e23d37fe
1 /* https://bugs.kde.org/show_bug.cgi?id=432801 */
3 #include <signal.h>
4 #include <string.h>
5 #include <stdio.h>
6 #include <stdint.h>
7 #include <stdlib.h>
8 #include <math.h>
9 #include <ctype.h>
10 #include <immintrin.h>
12 #include "../../memcheck.h"
14 // This function fails when compiled on clang version 10 or greater with -O2.
15 // It's unused by the test but left here as a copy of the error in the bug
16 // report https://bugs.kde.org/show_bug.cgi?id=432801
17 void standalone() {
18 struct sigaction act;
19 if (sigaction(SIGTERM, 0, &act) == 1) {
20 return;
22 if (sigaction(SIGTERM, 0, &act) == 1) {
23 return;
26 char pattern[] = "\x1\x2\x3\x4\x5\x6\x7\x8\x9";
27 const unsigned long plen = strlen(pattern);
28 pattern[1] = 0;
29 size_t hp=0;
30 for (size_t i = 0; i < plen; ++i)
31 hp += pattern[i];
32 volatile size_t j = 0;
33 if (j == hp % 10) {
34 j++;
36 printf("%zd\n", hp);
39 typedef union V128 {
40 struct {
41 uint64_t w64[2]; /* Note: little-endian */
43 struct {
44 uint32_t w32[4]; /* Note: little-endian */
46 struct {
47 uint16_t w16[8]; /* Note: little-endian */
49 struct {
50 uint8_t w8[16]; /* Note: little-endian */
52 } V128;
54 template <typename T>
55 static T cmpGT(V128 x, V128 y, size_t element_select) = delete;
57 template <>
58 uint64_t cmpGT(V128 x, V128 y, size_t element_select) {
59 uint8_t x_data[16];
60 uint8_t y_data[16];
61 memcpy(x_data, &x, sizeof(V128));
62 memcpy(y_data, &y, sizeof(V128));
63 __asm__ __volatile__(
64 "movdqu (%1), %%xmm5 \n"
65 "movdqu (%0), %%xmm6 \n"
66 // order swapped for AT&T style which has destination second.
67 "pcmpgtq %%xmm5,%%xmm6 \n"
68 "movdqu %%xmm6, (%0) \n"
70 : "r"(x_data), "r"(y_data)
71 : "memory", "xmm5", "xmm6" /* clobbers */);
72 memcpy(&x, x_data, sizeof(V128));
74 return ((uint64_t*)&x)[element_select];
77 template <>
78 uint32_t cmpGT(V128 x, V128 y, size_t element_select) {
79 uint8_t x_data[16];
80 uint8_t y_data[16];
81 memcpy(x_data, &x, sizeof(V128));
82 memcpy(y_data, &y, sizeof(V128));
83 __asm__ __volatile__(
84 "movdqu (%1), %%xmm5 \n"
85 "movdqu (%0), %%xmm6 \n"
86 // order swapped for AT&T style which has destination second.
87 "pcmpgtd %%xmm5,%%xmm6 \n"
88 "movdqu %%xmm6, (%0) \n"
90 : "r"(x_data), "r"(y_data)
91 : "memory", "xmm5", "xmm6" /* clobbers */);
92 memcpy(&x, x_data, sizeof(V128));
94 return ((uint32_t*)&x)[element_select];
97 template <>
98 uint16_t cmpGT(V128 x, V128 y, size_t element_select) {
99 uint8_t x_data[16];
100 uint8_t y_data[16];
101 memcpy(x_data, &x, sizeof(V128));
102 memcpy(y_data, &y, sizeof(V128));
103 __asm__ __volatile__(
104 "movdqu (%1), %%xmm5 \n"
105 "movdqu (%0), %%xmm6 \n"
106 // order swapped for AT&T style which has destination second.
107 "pcmpgtw %%xmm5,%%xmm6 \n"
108 "movdqu %%xmm6, (%0) \n"
110 : "r"(x_data), "r"(y_data)
111 : "memory", "xmm5", "xmm6" /* clobbers */);
112 memcpy(&x, x_data, sizeof(V128));
114 return ((uint16_t*)&x)[element_select];
117 template <>
118 uint8_t cmpGT(V128 x, V128 y, size_t element_select) {
119 uint8_t x_data[16];
120 uint8_t y_data[16];
121 memcpy(x_data, &x, sizeof(V128));
122 memcpy(y_data, &y, sizeof(V128));
123 __asm__ __volatile__(
124 "movdqu (%1), %%xmm5 \n"
125 "movdqu (%0), %%xmm6 \n"
126 // order swapped for AT&T style which has destination second.
127 "pcmpgtb %%xmm5,%%xmm6 \n"
128 "movdqu %%xmm6, (%0) \n"
130 : "r"(x_data), "r"(y_data)
131 : "memory", "xmm5", "xmm6" /* clobbers */);
132 memcpy(&x, x_data, sizeof(V128));
134 return ((uint8_t*)&x)[element_select];
137 static void set_vbits(V128 *addr, V128 vbits)
139 for (size_t i=0 ; i<2 ; ++i) {
140 (void)VALGRIND_SET_VBITS(&addr->w64[i], &vbits.w64[i], sizeof(vbits.w64[i]));
144 // Convert a string like "123XXX45" to a value and vbits.
145 template <typename T>
146 static void string_to_vbits(const char *s, T *x, T *vx)
148 *x = 0;
149 *vx = 0;
151 for (; *s; s++) {
152 int lowered_c = tolower(*s);
153 *x <<= 4;
154 *vx <<= 4;
155 if (lowered_c == 'x') {
156 *vx |= 0xf;
157 } else if (isdigit(lowered_c)) {
158 *x |= lowered_c - '0';
159 } else if (lowered_c >= 'a' && lowered_c <= 'f') {
160 *x |= lowered_c - 'a' + 0xa;
161 } else {
162 fprintf(stderr, "Not a hex digit: %c\n", *s);
163 exit(1);
168 template <typename T>
169 static V128 string_to_vbits(const char *s, size_t lane) {
170 T x, vx;
171 string_to_vbits(s, &x, &vx);
173 V128 vx128 = {{0}};
174 vx128.w32[0] = 0xffffffff;
175 vx128.w32[1] = 0xffffffff;
176 vx128.w32[2] = 0xffffffff;
177 vx128.w32[3] = 0xffffffff;
178 V128 x128 = {{0}};
179 if (sizeof(T) == 8) {
180 vx128.w64[lane] = vx;
181 x128.w64[lane] = x;
182 } else if (sizeof(T) == 4) {
183 vx128.w32[lane] = vx;
184 x128.w32[lane] = x;
185 } else if (sizeof(T) == 2) {
186 vx128.w16[lane] = vx;
187 x128.w16[lane] = x;
188 } else {
189 vx128.w8[lane] = vx;
190 x128.w8[lane] = x;
192 set_vbits(&x128, vx128);
193 return x128;
196 template <typename T, int lane>
197 static void doit(const char *x, const char *y, bool expected_undefined, const char *err_msg) {
198 int result = cmpGT<T>(string_to_vbits<T>(x, lane),
199 string_to_vbits<T>(y, lane),
200 lane);
201 int undefined = VALGRIND_CHECK_VALUE_IS_DEFINED(result);
202 if (!!undefined != expected_undefined) {
203 fprintf(stderr, "ERROR: ");
205 // Force the result to be used.
206 if (result) {
207 fflush(stderr);
209 fprintf(stderr, "%s > %s, %s, %d == %d\n", x, y, err_msg, !!undefined, !!expected_undefined);
212 int main(int argc, char *argv[]) {
213 if (argc != 2) {
214 fprintf(stderr, "First and only argument ought to be \"amd64\" or \"x86\"\n");
215 exit(1);
217 bool amd64;
218 if (strcmp(argv[1], "amd64") == 0) {
219 amd64 = true;
220 } else if (strcmp(argv[1], "x86") == 0) {
221 amd64 = false;
222 } else {
223 fprintf(stderr, "First and only argument ought to be \"amd64\" or \"x86\"\n");
224 exit(1);
226 if (amd64) {
227 doit<uint64_t, 0>("xxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxx", true, "completely undefined, error above");
228 doit<uint64_t, 0>("0000000000000000", "0000000000000000", false, "completely defined");
229 doit<uint64_t, 0>("0000000000000000", "f000000000000000", false, "completely defined");
230 doit<uint64_t, 0>("f000000000000000", "0000000000000000", false, "completely defined");
231 doit<uint64_t, 0>("0000000000000000", "fxxxxxxxxxxxxxxx", false, "defined: 0 > all negatives");
232 doit<uint64_t, 0>("0xxxxxxxxxxxxxxx", "fxxxxxxxxxxxxxxx", false, "defined: non-negatives > all negatives");
233 doit<uint64_t, 0>("xxxxxxxxxxxxxxx0", "f000000000000000", true, "undefined, error above");
234 doit<uint64_t, 0>("xxxxxxxxxxxxxxx1", "8000000000000000", false, "defined: ends with 1 > MIN_INT");
235 doit<uint64_t, 0>("5xxxxxxxxxxxxxxx", "6xxxxxxxxxxxxxxx", false, "defined");
236 doit<uint64_t, 0>("8xxxxxxxxxxxxxxx", "9xxxxxxxxxxxxxxx", false, "defined");
237 doit<uint64_t, 0>("123456781234567x", "1234567812345678", true, "undefined, error above");
238 doit<uint64_t, 0>("123456781234567x", "123456781234567f", false, "defined: x can't be more than f");
239 doit<uint64_t, 0>("123456781234567x", "123456781234567e", true, "undefined: x can be more than e, error above");
241 doit<uint64_t, 1>("xxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxx", true, "completely undefined, error above");
242 doit<uint64_t, 1>("0000000000000000", "0000000000000000", false, "completely defined");
243 doit<uint64_t, 1>("0000000000000000", "f000000000000000", false, "completely defined");
244 doit<uint64_t, 1>("f000000000000000", "0000000000000000", false, "completely defined");
245 doit<uint64_t, 1>("0000000000000000", "fxxxxxxxxxxxxxxx", false, "defined: 0 > all negatives");
246 doit<uint64_t, 1>("0xxxxxxxxxxxxxxx", "fxxxxxxxxxxxxxxx", false, "defined: non-negatives > all negatives");
247 doit<uint64_t, 1>("xxxxxxxxxxxxxxx0", "f000000000000000", true, "undefined, error above");
248 doit<uint64_t, 1>("xxxxxxxxxxxxxxx1", "8000000000000000", false, "defined: ends with 1 > MIN_INT");
249 doit<uint64_t, 1>("5xxxxxxxxxxxxxxx", "6xxxxxxxxxxxxxxx", false, "defined");
250 doit<uint64_t, 1>("8xxxxxxxxxxxxxxx", "9xxxxxxxxxxxxxxx", false, "defined");
251 doit<uint64_t, 1>("123456781234567x", "1234567812345678", true, "undefined, error above");
252 doit<uint64_t, 1>("123456781234567x", "123456781234567f", false, "defined: x can't be more than f");
253 doit<uint64_t, 1>("123456781234567x", "123456781234567e", true, "undefined: x can be more than e, error above");
255 doit<uint32_t, 0>("xxxxxxxx", "xxxxxxxx", true, "completely undefined, error above");
256 doit<uint32_t, 0>("00000000", "00000000", false, "completely defined");
257 doit<uint32_t, 0>("00000000", "f0000000", false, "completely defined");
258 doit<uint32_t, 0>("f0000000", "00000000", false, "completely defined");
259 doit<uint32_t, 0>("00000000", "fxxxxxxx", false, "defined: 0 > all negatives");
260 doit<uint32_t, 0>("0xxxxxxx", "fxxxxxxx", false, "defined: non-negatives > all negatives");
261 doit<uint32_t, 0>("xxxxxxx0", "f0000000", true, "undefined, error above");
262 doit<uint32_t, 0>("xxxxxxx1", "80000000", false, "defined: ends with 1 > MIN_INT");
263 doit<uint32_t, 0>("5xxxxxxx", "6xxxxxxx", false, "defined");
264 doit<uint32_t, 0>("8xxxxxxx", "9xxxxxxx", false, "defined");
265 doit<uint32_t, 0>("1234567x", "12345678", true, "undefined, error above");
266 doit<uint32_t, 0>("1234567x", "1234567f", false, "defined: x can't be more than f");
267 doit<uint32_t, 0>("1234567x", "1234567e", true, "undefined: x can be more than e, error above");
269 doit<uint32_t, 1>("xxxxxxxx", "xxxxxxxx", true, "completely undefined, error above");
270 doit<uint32_t, 1>("00000000", "00000000", false, "completely defined");
271 doit<uint32_t, 1>("00000000", "f0000000", false, "completely defined");
272 doit<uint32_t, 1>("f0000000", "00000000", false, "completely defined");
273 doit<uint32_t, 1>("00000000", "fxxxxxxx", false, "defined: 0 > all negatives");
274 doit<uint32_t, 1>("0xxxxxxx", "fxxxxxxx", false, "defined: non-negatives > all negatives");
275 doit<uint32_t, 1>("xxxxxxx0", "f0000000", true, "undefined, error above");
276 doit<uint32_t, 1>("xxxxxxx1", "80000000", false, "defined: ends with 1 > MIN_INT");
277 doit<uint32_t, 1>("5xxxxxxx", "6xxxxxxx", false, "defined");
278 doit<uint32_t, 1>("8xxxxxxx", "9xxxxxxx", false, "defined");
279 doit<uint32_t, 1>("1234567x", "12345678", true, "undefined, error above");
280 doit<uint32_t, 1>("1234567x", "1234567f", false, "defined: x can't be more than f");
281 doit<uint32_t, 1>("1234567x", "1234567e", true, "undefined: x can be more than e, error above");
283 doit<uint32_t, 2>("xxxxxxxx", "xxxxxxxx", true, "completely undefined, error above");
284 doit<uint32_t, 2>("00000000", "00000000", false, "completely defined");
285 doit<uint32_t, 2>("00000000", "f0000000", false, "completely defined");
286 doit<uint32_t, 2>("f0000000", "00000000", false, "completely defined");
287 doit<uint32_t, 2>("00000000", "fxxxxxxx", false, "defined: 0 > all negatives");
288 doit<uint32_t, 2>("0xxxxxxx", "fxxxxxxx", false, "defined: non-negatives > all negatives");
289 doit<uint32_t, 2>("xxxxxxx0", "f0000000", true, "undefined, error above");
290 doit<uint32_t, 2>("xxxxxxx1", "80000000", false, "defined: ends with 1 > MIN_INT");
291 doit<uint32_t, 2>("5xxxxxxx", "6xxxxxxx", false, "defined");
292 doit<uint32_t, 2>("8xxxxxxx", "9xxxxxxx", false, "defined");
293 doit<uint32_t, 2>("1234567x", "12345678", true, "undefined, error above");
294 doit<uint32_t, 2>("1234567x", "1234567f", false, "defined: x can't be more than f");
295 doit<uint32_t, 2>("1234567x", "1234567e", true, "undefined: x can be more than e, error above");
297 doit<uint32_t, 3>("xxxxxxxx", "xxxxxxxx", true, "completely undefined, error above");
298 doit<uint32_t, 3>("00000000", "00000000", false, "completely defined");
299 doit<uint32_t, 3>("00000000", "f0000000", false, "completely defined");
300 doit<uint32_t, 3>("f0000000", "00000000", false, "completely defined");
301 doit<uint32_t, 3>("00000000", "fxxxxxxx", false, "defined: 0 > all negatives");
302 doit<uint32_t, 3>("0xxxxxxx", "fxxxxxxx", false, "defined: non-negatives > all negatives");
303 doit<uint32_t, 3>("xxxxxxx0", "f0000000", true, "undefined, error above");
304 doit<uint32_t, 3>("xxxxxxx1", "80000000", false, "defined: ends with 1 > MIN_INT");
305 doit<uint32_t, 3>("5xxxxxxx", "6xxxxxxx", false, "defined");
306 doit<uint32_t, 3>("8xxxxxxx", "9xxxxxxx", false, "defined");
307 doit<uint32_t, 3>("1234567x", "12345678", true, "undefined, error above");
308 doit<uint32_t, 3>("1234567x", "1234567f", false, "defined: x can't be more than f");
309 doit<uint32_t, 3>("1234567x", "1234567e", true, "undefined: x can be more than e, error above");
311 doit<uint16_t, 0>("xxxx", "xxxx", true, "completely undefined, error above");
312 doit<uint16_t, 0>("0000", "0000", false, "completely defined");
313 doit<uint16_t, 0>("0000", "f000", false, "completely defined");
314 doit<uint16_t, 0>("f000", "0000", false, "completely defined");
315 doit<uint16_t, 0>("0000", "fxxx", false, "defined: 0 > all negatives");
316 doit<uint16_t, 0>("0xxx", "fxxx", false, "defined: non-negatives > all negatives");
317 doit<uint16_t, 0>("xxx0", "f000", true, "undefined, error above");
318 doit<uint16_t, 0>("xxx1", "8000", false, "defined: ends with 1 > MIN_INT");
319 doit<uint16_t, 0>("5xxx", "6xxx", false, "defined");
320 doit<uint16_t, 0>("8xxx", "9xxx", false, "defined");
321 doit<uint16_t, 0>("123x", "1234", true, "undefined, error above");
322 doit<uint16_t, 0>("123x", "123f", false, "defined: x can't be more than f");
323 doit<uint16_t, 0>("123x", "123e", true, "undefined: x can be more than e, error above");
325 doit<uint16_t, 1>("xxxx", "xxxx", true, "completely undefined, error above");
326 doit<uint16_t, 1>("0000", "0000", false, "completely defined");
327 doit<uint16_t, 1>("0000", "f000", false, "completely defined");
328 doit<uint16_t, 1>("f000", "0000", false, "completely defined");
329 doit<uint16_t, 1>("0000", "fxxx", false, "defined: 0 > all negatives");
330 doit<uint16_t, 1>("0xxx", "fxxx", false, "defined: non-negatives > all negatives");
331 doit<uint16_t, 1>("xxx0", "f000", true, "undefined, error above");
332 doit<uint16_t, 1>("xxx1", "8000", false, "defined: ends with 1 > MIN_INT");
333 doit<uint16_t, 1>("5xxx", "6xxx", false, "defined");
334 doit<uint16_t, 1>("8xxx", "9xxx", false, "defined");
335 doit<uint16_t, 1>("123x", "1234", true, "undefined, error above");
336 doit<uint16_t, 1>("123x", "123f", false, "defined: x can't be more than f");
337 doit<uint16_t, 1>("123x", "123e", true, "undefined: x can be more than e, error above");
339 doit<uint16_t, 2>("xxxx", "xxxx", true, "completely undefined, error above");
340 doit<uint16_t, 2>("0000", "0000", false, "completely defined");
341 doit<uint16_t, 2>("0000", "f000", false, "completely defined");
342 doit<uint16_t, 2>("f000", "0000", false, "completely defined");
343 doit<uint16_t, 2>("0000", "fxxx", false, "defined: 0 > all negatives");
344 doit<uint16_t, 2>("0xxx", "fxxx", false, "defined: non-negatives > all negatives");
345 doit<uint16_t, 2>("xxx0", "f000", true, "undefined, error above");
346 doit<uint16_t, 2>("xxx1", "8000", false, "defined: ends with 1 > MIN_INT");
347 doit<uint16_t, 2>("5xxx", "6xxx", false, "defined");
348 doit<uint16_t, 2>("8xxx", "9xxx", false, "defined");
349 doit<uint16_t, 2>("123x", "1234", true, "undefined, error above");
350 doit<uint16_t, 2>("123x", "123f", false, "defined: x can't be more than f");
351 doit<uint16_t, 2>("123x", "123e", true, "undefined: x can be more than e, error above");
353 doit<uint16_t, 3>("xxxx", "xxxx", true, "completely undefined, error above");
354 doit<uint16_t, 3>("0000", "0000", false, "completely defined");
355 doit<uint16_t, 3>("0000", "f000", false, "completely defined");
356 doit<uint16_t, 3>("f000", "0000", false, "completely defined");
357 doit<uint16_t, 3>("0000", "fxxx", false, "defined: 0 > all negatives");
358 doit<uint16_t, 3>("0xxx", "fxxx", false, "defined: non-negatives > all negatives");
359 doit<uint16_t, 3>("xxx0", "f000", true, "undefined, error above");
360 doit<uint16_t, 3>("xxx1", "8000", false, "defined: ends with 1 > MIN_INT");
361 doit<uint16_t, 3>("5xxx", "6xxx", false, "defined");
362 doit<uint16_t, 3>("8xxx", "9xxx", false, "defined");
363 doit<uint16_t, 3>("123x", "1234", true, "undefined, error above");
364 doit<uint16_t, 3>("123x", "123f", false, "defined: x can't be more than f");
365 doit<uint16_t, 3>("123x", "123e", true, "undefined: x can be more than e, error above");
367 doit<uint16_t, 4>("xxxx", "xxxx", true, "completely undefined, error above");
368 doit<uint16_t, 4>("0000", "0000", false, "completely defined");
369 doit<uint16_t, 4>("0000", "f000", false, "completely defined");
370 doit<uint16_t, 4>("f000", "0000", false, "completely defined");
371 doit<uint16_t, 4>("0000", "fxxx", false, "defined: 0 > all negatives");
372 doit<uint16_t, 4>("0xxx", "fxxx", false, "defined: non-negatives > all negatives");
373 doit<uint16_t, 4>("xxx0", "f000", true, "undefined, error above");
374 doit<uint16_t, 4>("xxx1", "8000", false, "defined: ends with 1 > MIN_INT");
375 doit<uint16_t, 4>("5xxx", "6xxx", false, "defined");
376 doit<uint16_t, 4>("8xxx", "9xxx", false, "defined");
377 doit<uint16_t, 4>("123x", "1234", true, "undefined, error above");
378 doit<uint16_t, 4>("123x", "123f", false, "defined: x can't be more than f");
379 doit<uint16_t, 4>("123x", "123e", true, "undefined: x can be more than e, error above");
381 doit<uint16_t, 5>("xxxx", "xxxx", true, "completely undefined, error above");
382 doit<uint16_t, 5>("0000", "0000", false, "completely defined");
383 doit<uint16_t, 5>("0000", "f000", false, "completely defined");
384 doit<uint16_t, 5>("f000", "0000", false, "completely defined");
385 doit<uint16_t, 5>("0000", "fxxx", false, "defined: 0 > all negatives");
386 doit<uint16_t, 5>("0xxx", "fxxx", false, "defined: non-negatives > all negatives");
387 doit<uint16_t, 5>("xxx0", "f000", true, "undefined, error above");
388 doit<uint16_t, 5>("xxx1", "8000", false, "defined: ends with 1 > MIN_INT");
389 doit<uint16_t, 5>("5xxx", "6xxx", false, "defined");
390 doit<uint16_t, 5>("8xxx", "9xxx", false, "defined");
391 doit<uint16_t, 5>("123x", "1234", true, "undefined, error above");
392 doit<uint16_t, 5>("123x", "123f", false, "defined: x can't be more than f");
393 doit<uint16_t, 5>("123x", "123e", true, "undefined: x can be more than e, error above");
395 doit<uint16_t, 6>("xxxx", "xxxx", true, "completely undefined, error above");
396 doit<uint16_t, 6>("0000", "0000", false, "completely defined");
397 doit<uint16_t, 6>("0000", "f000", false, "completely defined");
398 doit<uint16_t, 6>("f000", "0000", false, "completely defined");
399 doit<uint16_t, 6>("0000", "fxxx", false, "defined: 0 > all negatives");
400 doit<uint16_t, 6>("0xxx", "fxxx", false, "defined: non-negatives > all negatives");
401 doit<uint16_t, 6>("xxx0", "f000", true, "undefined, error above");
402 doit<uint16_t, 6>("xxx1", "8000", false, "defined: ends with 1 > MIN_INT");
403 doit<uint16_t, 6>("5xxx", "6xxx", false, "defined");
404 doit<uint16_t, 6>("8xxx", "9xxx", false, "defined");
405 doit<uint16_t, 6>("123x", "1234", true, "undefined, error above");
406 doit<uint16_t, 6>("123x", "123f", false, "defined: x can't be more than f");
407 doit<uint16_t, 6>("123x", "123e", true, "undefined: x can be more than e, error above");
409 doit<uint16_t, 7>("xxxx", "xxxx", true, "completely undefined, error above");
410 doit<uint16_t, 7>("0000", "0000", false, "completely defined");
411 doit<uint16_t, 7>("0000", "f000", false, "completely defined");
412 doit<uint16_t, 7>("f000", "0000", false, "completely defined");
413 doit<uint16_t, 7>("0000", "fxxx", false, "defined: 0 > all negatives");
414 doit<uint16_t, 7>("0xxx", "fxxx", false, "defined: non-negatives > all negatives");
415 doit<uint16_t, 7>("xxx0", "f000", true, "undefined, error above");
416 doit<uint16_t, 7>("xxx1", "8000", false, "defined: ends with 1 > MIN_INT");
417 doit<uint16_t, 7>("5xxx", "6xxx", false, "defined");
418 doit<uint16_t, 7>("8xxx", "9xxx", false, "defined");
419 doit<uint16_t, 7>("123x", "1234", true, "undefined, error above");
420 doit<uint16_t, 7>("123x", "123f", false, "defined: x can't be more than f");
421 doit<uint16_t, 7>("123x", "123e", true, "undefined: x can be more than e, error above");
423 doit<uint8_t, 0>("xx", "xx", true, "completely undefined, error above");
424 doit<uint8_t, 0>("00", "00", false, "completely defined");
425 doit<uint8_t, 0>("00", "f0", false, "completely defined");
426 doit<uint8_t, 0>("f0", "00", false, "completely defined");
427 doit<uint8_t, 0>("00", "fx", false, "defined: 0 > all negatives");
428 doit<uint8_t, 0>("0x", "fx", false, "defined: non-negatives > all negatives");
429 doit<uint8_t, 0>("x0", "f0", true, "undefined, error above");
430 doit<uint8_t, 0>("x1", "80", false, "defined: ends with 1 > MIN_INT");
431 doit<uint8_t, 0>("5x", "6x", false, "defined");
432 doit<uint8_t, 0>("8x", "9x", false, "defined");
433 doit<uint8_t, 0>("1x", "12", true, "undefined, error above");
434 doit<uint8_t, 0>("1x", "1f", false, "defined: x can't be more than f");
435 doit<uint8_t, 0>("1x", "1e", true, "undefined: x can be more than e, error above");
437 doit<uint8_t, 1>("xx", "xx", true, "completely undefined, error above");
438 doit<uint8_t, 1>("00", "00", false, "completely defined");
439 doit<uint8_t, 1>("00", "f0", false, "completely defined");
440 doit<uint8_t, 1>("f0", "00", false, "completely defined");
441 doit<uint8_t, 1>("00", "fx", false, "defined: 0 > all negatives");
442 doit<uint8_t, 1>("0x", "fx", false, "defined: non-negatives > all negatives");
443 doit<uint8_t, 1>("x0", "f0", true, "undefined, error above");
444 doit<uint8_t, 1>("x1", "80", false, "defined: ends with 1 > MIN_INT");
445 doit<uint8_t, 1>("5x", "6x", false, "defined");
446 doit<uint8_t, 1>("8x", "9x", false, "defined");
447 doit<uint8_t, 1>("1x", "12", true, "undefined, error above");
448 doit<uint8_t, 1>("1x", "1f", false, "defined: x can't be more than f");
449 doit<uint8_t, 1>("1x", "1e", true, "undefined: x can be more than e, error above");
451 doit<uint8_t, 2>("xx", "xx", true, "completely undefined, error above");
452 doit<uint8_t, 2>("00", "00", false, "completely defined");
453 doit<uint8_t, 2>("00", "f0", false, "completely defined");
454 doit<uint8_t, 2>("f0", "00", false, "completely defined");
455 doit<uint8_t, 2>("00", "fx", false, "defined: 0 > all negatives");
456 doit<uint8_t, 2>("0x", "fx", false, "defined: non-negatives > all negatives");
457 doit<uint8_t, 2>("x0", "f0", true, "undefined, error above");
458 doit<uint8_t, 2>("x1", "80", false, "defined: ends with 1 > MIN_INT");
459 doit<uint8_t, 2>("5x", "6x", false, "defined");
460 doit<uint8_t, 2>("8x", "9x", false, "defined");
461 doit<uint8_t, 2>("1x", "12", true, "undefined, error above");
462 doit<uint8_t, 2>("1x", "1f", false, "defined: x can't be more than f");
463 doit<uint8_t, 2>("1x", "1e", true, "undefined: x can be more than e, error above");
465 doit<uint8_t, 3>("xx", "xx", true, "completely undefined, error above");
466 doit<uint8_t, 3>("00", "00", false, "completely defined");
467 doit<uint8_t, 3>("00", "f0", false, "completely defined");
468 doit<uint8_t, 3>("f0", "00", false, "completely defined");
469 doit<uint8_t, 3>("00", "fx", false, "defined: 0 > all negatives");
470 doit<uint8_t, 3>("0x", "fx", false, "defined: non-negatives > all negatives");
471 doit<uint8_t, 3>("x0", "f0", true, "undefined, error above");
472 doit<uint8_t, 3>("x1", "80", false, "defined: ends with 1 > MIN_INT");
473 doit<uint8_t, 3>("5x", "6x", false, "defined");
474 doit<uint8_t, 3>("8x", "9x", false, "defined");
475 doit<uint8_t, 3>("1x", "12", true, "undefined, error above");
476 doit<uint8_t, 3>("1x", "1f", false, "defined: x can't be more than f");
477 doit<uint8_t, 3>("1x", "1e", true, "undefined: x can be more than e, error above");
479 doit<uint8_t, 4>("xx", "xx", true, "completely undefined, error above");
480 doit<uint8_t, 4>("00", "00", false, "completely defined");
481 doit<uint8_t, 4>("00", "f0", false, "completely defined");
482 doit<uint8_t, 4>("f0", "00", false, "completely defined");
483 doit<uint8_t, 4>("00", "fx", false, "defined: 0 > all negatives");
484 doit<uint8_t, 4>("0x", "fx", false, "defined: non-negatives > all negatives");
485 doit<uint8_t, 4>("x0", "f0", true, "undefined, error above");
486 doit<uint8_t, 4>("x1", "80", false, "defined: ends with 1 > MIN_INT");
487 doit<uint8_t, 4>("5x", "6x", false, "defined");
488 doit<uint8_t, 4>("8x", "9x", false, "defined");
489 doit<uint8_t, 4>("1x", "12", true, "undefined, error above");
490 doit<uint8_t, 4>("1x", "1f", false, "defined: x can't be more than f");
491 doit<uint8_t, 4>("1x", "1e", true, "undefined: x can be more than e, error above");
493 doit<uint8_t, 5>("xx", "xx", true, "completely undefined, error above");
494 doit<uint8_t, 5>("00", "00", false, "completely defined");
495 doit<uint8_t, 5>("00", "f0", false, "completely defined");
496 doit<uint8_t, 5>("f0", "00", false, "completely defined");
497 doit<uint8_t, 5>("00", "fx", false, "defined: 0 > all negatives");
498 doit<uint8_t, 5>("0x", "fx", false, "defined: non-negatives > all negatives");
499 doit<uint8_t, 5>("x0", "f0", true, "undefined, error above");
500 doit<uint8_t, 5>("x1", "80", false, "defined: ends with 1 > MIN_INT");
501 doit<uint8_t, 5>("5x", "6x", false, "defined");
502 doit<uint8_t, 5>("8x", "9x", false, "defined");
503 doit<uint8_t, 5>("1x", "12", true, "undefined, error above");
504 doit<uint8_t, 5>("1x", "1f", false, "defined: x can't be more than f");
505 doit<uint8_t, 5>("1x", "1e", true, "undefined: x can be more than e, error above");
507 doit<uint8_t, 6>("xx", "xx", true, "completely undefined, error above");
508 doit<uint8_t, 6>("00", "00", false, "completely defined");
509 doit<uint8_t, 6>("00", "f0", false, "completely defined");
510 doit<uint8_t, 6>("f0", "00", false, "completely defined");
511 doit<uint8_t, 6>("00", "fx", false, "defined: 0 > all negatives");
512 doit<uint8_t, 6>("0x", "fx", false, "defined: non-negatives > all negatives");
513 doit<uint8_t, 6>("x0", "f0", true, "undefined, error above");
514 doit<uint8_t, 6>("x1", "80", false, "defined: ends with 1 > MIN_INT");
515 doit<uint8_t, 6>("5x", "6x", false, "defined");
516 doit<uint8_t, 6>("8x", "9x", false, "defined");
517 doit<uint8_t, 6>("1x", "12", true, "undefined, error above");
518 doit<uint8_t, 6>("1x", "1f", false, "defined: x can't be more than f");
519 doit<uint8_t, 6>("1x", "1e", true, "undefined: x can be more than e, error above");
521 doit<uint8_t, 7>("xx", "xx", true, "completely undefined, error above");
522 doit<uint8_t, 7>("00", "00", false, "completely defined");
523 doit<uint8_t, 7>("00", "f0", false, "completely defined");
524 doit<uint8_t, 7>("f0", "00", false, "completely defined");
525 doit<uint8_t, 7>("00", "fx", false, "defined: 0 > all negatives");
526 doit<uint8_t, 7>("0x", "fx", false, "defined: non-negatives > all negatives");
527 doit<uint8_t, 7>("x0", "f0", true, "undefined, error above");
528 doit<uint8_t, 7>("x1", "80", false, "defined: ends with 1 > MIN_INT");
529 doit<uint8_t, 7>("5x", "6x", false, "defined");
530 doit<uint8_t, 7>("8x", "9x", false, "defined");
531 doit<uint8_t, 7>("1x", "12", true, "undefined, error above");
532 doit<uint8_t, 7>("1x", "1f", false, "defined: x can't be more than f");
533 doit<uint8_t, 7>("1x", "1e", true, "undefined: x can be more than e, error above");
535 doit<uint8_t, 8>("xx", "xx", true, "completely undefined, error above");
536 doit<uint8_t, 8>("00", "00", false, "completely defined");
537 doit<uint8_t, 8>("00", "f0", false, "completely defined");
538 doit<uint8_t, 8>("f0", "00", false, "completely defined");
539 doit<uint8_t, 8>("00", "fx", false, "defined: 0 > all negatives");
540 doit<uint8_t, 8>("0x", "fx", false, "defined: non-negatives > all negatives");
541 doit<uint8_t, 8>("x0", "f0", true, "undefined, error above");
542 doit<uint8_t, 8>("x1", "80", false, "defined: ends with 1 > MIN_INT");
543 doit<uint8_t, 8>("5x", "6x", false, "defined");
544 doit<uint8_t, 8>("8x", "9x", false, "defined");
545 doit<uint8_t, 8>("1x", "12", true, "undefined, error above");
546 doit<uint8_t, 8>("1x", "1f", false, "defined: x can't be more than f");
547 doit<uint8_t, 8>("1x", "1e", true, "undefined: x can be more than e, error above");
549 doit<uint8_t, 9>("xx", "xx", true, "completely undefined, error above");
550 doit<uint8_t, 9>("00", "00", false, "completely defined");
551 doit<uint8_t, 9>("00", "f0", false, "completely defined");
552 doit<uint8_t, 9>("f0", "00", false, "completely defined");
553 doit<uint8_t, 9>("00", "fx", false, "defined: 0 > all negatives");
554 doit<uint8_t, 9>("0x", "fx", false, "defined: non-negatives > all negatives");
555 doit<uint8_t, 9>("x0", "f0", true, "undefined, error above");
556 doit<uint8_t, 9>("x1", "80", false, "defined: ends with 1 > MIN_INT");
557 doit<uint8_t, 9>("5x", "6x", false, "defined");
558 doit<uint8_t, 9>("8x", "9x", false, "defined");
559 doit<uint8_t, 9>("1x", "12", true, "undefined, error above");
560 doit<uint8_t, 9>("1x", "1f", false, "defined: x can't be more than f");
561 doit<uint8_t, 9>("1x", "1e", true, "undefined: x can be more than e, error above");
563 doit<uint8_t, 10>("xx", "xx", true, "completely undefined, error above");
564 doit<uint8_t, 10>("00", "00", false, "completely defined");
565 doit<uint8_t, 10>("00", "f0", false, "completely defined");
566 doit<uint8_t, 10>("f0", "00", false, "completely defined");
567 doit<uint8_t, 10>("00", "fx", false, "defined: 0 > all negatives");
568 doit<uint8_t, 10>("0x", "fx", false, "defined: non-negatives > all negatives");
569 doit<uint8_t, 10>("x0", "f0", true, "undefined, error above");
570 doit<uint8_t, 10>("x1", "80", false, "defined: ends with 1 > MIN_INT");
571 doit<uint8_t, 10>("5x", "6x", false, "defined");
572 doit<uint8_t, 10>("8x", "9x", false, "defined");
573 doit<uint8_t, 10>("1x", "12", true, "undefined, error above");
574 doit<uint8_t, 10>("1x", "1f", false, "defined: x can't be more than f");
575 doit<uint8_t, 10>("1x", "1e", true, "undefined: x can be more than e, error above");
577 doit<uint8_t, 11>("xx", "xx", true, "completely undefined, error above");
578 doit<uint8_t, 11>("00", "00", false, "completely defined");
579 doit<uint8_t, 11>("00", "f0", false, "completely defined");
580 doit<uint8_t, 11>("f0", "00", false, "completely defined");
581 doit<uint8_t, 11>("00", "fx", false, "defined: 0 > all negatives");
582 doit<uint8_t, 11>("0x", "fx", false, "defined: non-negatives > all negatives");
583 doit<uint8_t, 11>("x0", "f0", true, "undefined, error above");
584 doit<uint8_t, 11>("x1", "80", false, "defined: ends with 1 > MIN_INT");
585 doit<uint8_t, 11>("5x", "6x", false, "defined");
586 doit<uint8_t, 11>("8x", "9x", false, "defined");
587 doit<uint8_t, 11>("1x", "12", true, "undefined, error above");
588 doit<uint8_t, 11>("1x", "1f", false, "defined: x can't be more than f");
589 doit<uint8_t, 11>("1x", "1e", true, "undefined: x can be more than e, error above");
591 doit<uint8_t, 12>("xx", "xx", true, "completely undefined, error above");
592 doit<uint8_t, 12>("00", "00", false, "completely defined");
593 doit<uint8_t, 12>("00", "f0", false, "completely defined");
594 doit<uint8_t, 12>("f0", "00", false, "completely defined");
595 doit<uint8_t, 12>("00", "fx", false, "defined: 0 > all negatives");
596 doit<uint8_t, 12>("0x", "fx", false, "defined: non-negatives > all negatives");
597 doit<uint8_t, 12>("x0", "f0", true, "undefined, error above");
598 doit<uint8_t, 12>("x1", "80", false, "defined: ends with 1 > MIN_INT");
599 doit<uint8_t, 12>("5x", "6x", false, "defined");
600 doit<uint8_t, 12>("8x", "9x", false, "defined");
601 doit<uint8_t, 12>("1x", "12", true, "undefined, error above");
602 doit<uint8_t, 12>("1x", "1f", false, "defined: x can't be more than f");
603 doit<uint8_t, 12>("1x", "1e", true, "undefined: x can be more than e, error above");
605 doit<uint8_t, 13>("xx", "xx", true, "completely undefined, error above");
606 doit<uint8_t, 13>("00", "00", false, "completely defined");
607 doit<uint8_t, 13>("00", "f0", false, "completely defined");
608 doit<uint8_t, 13>("f0", "00", false, "completely defined");
609 doit<uint8_t, 13>("00", "fx", false, "defined: 0 > all negatives");
610 doit<uint8_t, 13>("0x", "fx", false, "defined: non-negatives > all negatives");
611 doit<uint8_t, 13>("x0", "f0", true, "undefined, error above");
612 doit<uint8_t, 13>("x1", "80", false, "defined: ends with 1 > MIN_INT");
613 doit<uint8_t, 13>("5x", "6x", false, "defined");
614 doit<uint8_t, 13>("8x", "9x", false, "defined");
615 doit<uint8_t, 13>("1x", "12", true, "undefined, error above");
616 doit<uint8_t, 13>("1x", "1f", false, "defined: x can't be more than f");
617 doit<uint8_t, 13>("1x", "1e", true, "undefined: x can be more than e, error above");
619 doit<uint8_t, 14>("xx", "xx", true, "completely undefined, error above");
620 doit<uint8_t, 14>("00", "00", false, "completely defined");
621 doit<uint8_t, 14>("00", "f0", false, "completely defined");
622 doit<uint8_t, 14>("f0", "00", false, "completely defined");
623 doit<uint8_t, 14>("00", "fx", false, "defined: 0 > all negatives");
624 doit<uint8_t, 14>("0x", "fx", false, "defined: non-negatives > all negatives");
625 doit<uint8_t, 14>("x0", "f0", true, "undefined, error above");
626 doit<uint8_t, 14>("x1", "80", false, "defined: ends with 1 > MIN_INT");
627 doit<uint8_t, 14>("5x", "6x", false, "defined");
628 doit<uint8_t, 14>("8x", "9x", false, "defined");
629 doit<uint8_t, 14>("1x", "12", true, "undefined, error above");
630 doit<uint8_t, 14>("1x", "1f", false, "defined: x can't be more than f");
631 doit<uint8_t, 14>("1x", "1e", true, "undefined: x can be more than e, error above");
633 doit<uint8_t, 15>("xx", "xx", true, "completely undefined, error above");
634 doit<uint8_t, 15>("00", "00", false, "completely defined");
635 doit<uint8_t, 15>("00", "f0", false, "completely defined");
636 doit<uint8_t, 15>("f0", "00", false, "completely defined");
637 doit<uint8_t, 15>("00", "fx", false, "defined: 0 > all negatives");
638 doit<uint8_t, 15>("0x", "fx", false, "defined: non-negatives > all negatives");
639 doit<uint8_t, 15>("x0", "f0", true, "undefined, error above");
640 doit<uint8_t, 15>("x1", "80", false, "defined: ends with 1 > MIN_INT");
641 doit<uint8_t, 15>("5x", "6x", false, "defined");
642 doit<uint8_t, 15>("8x", "9x", false, "defined");
643 doit<uint8_t, 15>("1x", "12", true, "undefined, error above");
644 doit<uint8_t, 15>("1x", "1f", false, "defined: x can't be more than f");
645 doit<uint8_t, 15>("1x", "1e", true, "undefined: x can be more than e, error above");
648 return 0;