CellSPU:
[oota-llvm.git] / test / CodeGen / CellSPU / useful-harnesses / i64operations.c
1 #include <stdio.h>
2 #include "i64operations.h"
3
4 int64_t         tval_a = 1234567890003LL;
5 int64_t         tval_b = 2345678901235LL;
6 int64_t         tval_c = 1234567890001LL;
7 int64_t         tval_d = 10001LL;
8 int64_t         tval_e = 10000LL;
9 uint64_t        tval_f = 0xffffff0750135eb9;
10
11 /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
12
13 int
14 i64_eq(int64_t a, int64_t b)
15 {
16   return (a == b);
17 }
18
19 int
20 i64_neq(int64_t a, int64_t b)
21 {
22   return (a != b);
23 }
24
25 int
26 i64_gt(int64_t a, int64_t b)
27 {
28   return (a > b);
29 }
30
31 int
32 i64_le(int64_t a, int64_t b)
33 {
34   return (a <= b);
35 }
36
37 int
38 i64_ge(int64_t a, int64_t b) {
39   return (a >= b);
40 }
41
42 int
43 i64_lt(int64_t a, int64_t b) {
44   return (a < b);
45 }
46
47 int
48 i64_uge(uint64_t a, uint64_t b)
49 {
50   return (a >= b);
51 }
52
53 int
54 i64_ult(uint64_t a, uint64_t b)
55 {
56   return (a < b);
57 }
58
59 int
60 i64_ugt(uint64_t a, uint64_t b)
61 {
62   return (a > b);
63 }
64
65 int
66 i64_ule(uint64_t a, uint64_t b)
67 {
68   return (a <= b);
69 }
70
71 int64_t
72 i64_eq_select(int64_t a, int64_t b, int64_t c, int64_t d)
73 {
74   return ((a == b) ? c : d);
75 }
76
77 int64_t
78 i64_neq_select(int64_t a, int64_t b, int64_t c, int64_t d)
79 {
80   return ((a != b) ? c : d);
81 }
82
83 int64_t
84 i64_gt_select(int64_t a, int64_t b, int64_t c, int64_t d) {
85   return ((a > b) ? c : d);
86 }
87
88 int64_t
89 i64_le_select(int64_t a, int64_t b, int64_t c, int64_t d) {
90   return ((a <= b) ? c : d);
91 }
92
93 int64_t
94 i64_ge_select(int64_t a, int64_t b, int64_t c, int64_t d) {
95   return ((a >= b) ? c : d);
96 }
97
98 int64_t
99 i64_lt_select(int64_t a, int64_t b, int64_t c, int64_t d) {
100   return ((a < b) ? c : d);
101 }
102
103 uint64_t
104 i64_ugt_select(uint64_t a, uint64_t b, uint64_t c, uint64_t d)
105 {
106   return ((a > b) ? c : d);
107 }
108
109 uint64_t
110 i64_ule_select(uint64_t a, uint64_t b, uint64_t c, uint64_t d)
111 {
112   return ((a <= b) ? c : d);
113 }
114
115 uint64_t
116 i64_uge_select(uint64_t a, uint64_t b, uint64_t c, uint64_t d) {
117   return ((a >= b) ? c : d);
118 }
119
120 uint64_t
121 i64_ult_select(uint64_t a, uint64_t b, uint64_t c, uint64_t d) {
122   return ((a < b) ? c : d);
123 }
124
125 /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
126
127 struct harness_int64_pred int64_tests_eq[] = {
128   {"a %s a", &tval_a, &tval_a, &tval_c, &tval_d, TRUE_VAL, &tval_c},
129   {"a %s b", &tval_a, &tval_b, &tval_c, &tval_d, FALSE_VAL, &tval_d},
130   {"a %s c", &tval_a, &tval_c, &tval_c, &tval_d, FALSE_VAL, &tval_d},
131   {"d %s e", &tval_d, &tval_e, &tval_c, &tval_d, FALSE_VAL, &tval_d},
132   {"e %s e", &tval_e, &tval_e, &tval_c, &tval_d, TRUE_VAL, &tval_c}
133 };
134
135 struct harness_int64_pred int64_tests_neq[] = {
136   {"a %s a", &tval_a, &tval_a, &tval_c, &tval_d, FALSE_VAL, &tval_d},
137   {"a %s b", &tval_a, &tval_b, &tval_c, &tval_d, TRUE_VAL, &tval_c},
138   {"a %s c", &tval_a, &tval_c, &tval_c, &tval_d, TRUE_VAL, &tval_c},
139   {"d %s e", &tval_d, &tval_e, &tval_c, &tval_d, TRUE_VAL, &tval_c},
140   {"e %s e", &tval_e, &tval_e, &tval_c, &tval_d, FALSE_VAL, &tval_d}
141 };
142
143 struct harness_int64_pred int64_tests_sgt[] = {
144   {"a %s a", &tval_a, &tval_a, &tval_c, &tval_d, FALSE_VAL, &tval_d},
145   {"a %s b", &tval_a, &tval_b, &tval_c, &tval_d, FALSE_VAL, &tval_d},
146   {"a %s c", &tval_a, &tval_c, &tval_c, &tval_d, TRUE_VAL, &tval_c},
147   {"d %s e", &tval_d, &tval_e, &tval_c, &tval_d, TRUE_VAL, &tval_c},
148   {"e %s e", &tval_e, &tval_e, &tval_c, &tval_d, FALSE_VAL, &tval_d}
149 };
150
151 struct harness_int64_pred int64_tests_sle[] = {
152   {"a %s a", &tval_a, &tval_a, &tval_c, &tval_d, TRUE_VAL, &tval_c},
153   {"a %s b", &tval_a, &tval_b, &tval_c, &tval_d, TRUE_VAL, &tval_c},
154   {"a %s c", &tval_a, &tval_c, &tval_c, &tval_d, FALSE_VAL, &tval_d},
155   {"d %s e", &tval_d, &tval_e, &tval_c, &tval_d, FALSE_VAL, &tval_d},
156   {"e %s e", &tval_e, &tval_e, &tval_c, &tval_d, TRUE_VAL, &tval_c}
157 };
158
159 struct harness_int64_pred int64_tests_sge[] = {
160   {"a %s a", &tval_a, &tval_a, &tval_c, &tval_d, TRUE_VAL, &tval_c},
161   {"a %s b", &tval_a, &tval_b, &tval_c, &tval_d, FALSE_VAL, &tval_d},
162   {"a %s c", &tval_a, &tval_c, &tval_c, &tval_d, TRUE_VAL, &tval_c},
163   {"d %s e", &tval_d, &tval_e, &tval_c, &tval_d, TRUE_VAL, &tval_c},
164   {"e %s e", &tval_e, &tval_e, &tval_c, &tval_d, TRUE_VAL, &tval_c}
165 };
166
167 struct harness_int64_pred int64_tests_slt[] = {
168   {"a %s a", &tval_a, &tval_a, &tval_c, &tval_d, FALSE_VAL, &tval_d},
169   {"a %s b", &tval_a, &tval_b, &tval_c, &tval_d, TRUE_VAL, &tval_c},
170   {"a %s c", &tval_a, &tval_c, &tval_c, &tval_d, FALSE_VAL, &tval_d},
171   {"d %s e", &tval_d, &tval_e, &tval_c, &tval_d, FALSE_VAL, &tval_d},
172   {"e %s e", &tval_e, &tval_e, &tval_c, &tval_d, FALSE_VAL, &tval_d}
173 };
174
175 struct int64_pred_s int64_preds[] = {
176   {"eq", i64_eq, i64_eq_select,
177      int64_tests_eq, ARR_SIZE(int64_tests_eq)},
178   {"neq", i64_neq, i64_neq_select,
179      int64_tests_neq, ARR_SIZE(int64_tests_neq)},
180   {"gt", i64_gt, i64_gt_select,
181      int64_tests_sgt, ARR_SIZE(int64_tests_sgt)},
182   {"le", i64_le, i64_le_select,
183      int64_tests_sle, ARR_SIZE(int64_tests_sle)},
184   {"ge", i64_ge, i64_ge_select,
185      int64_tests_sge, ARR_SIZE(int64_tests_sge)},
186   {"lt", i64_lt, i64_lt_select,
187      int64_tests_slt, ARR_SIZE(int64_tests_slt)}
188 };
189
190 /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
191
192 struct harness_uint64_pred uint64_tests_ugt[] = {
193   {"a %s a", (uint64_t *) &tval_a, (uint64_t *) &tval_a, (uint64_t *) &tval_c,
194      (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
195   {"a %s b", (uint64_t *) &tval_a, (uint64_t *) &tval_b, (uint64_t *) &tval_c,
196      (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d },
197   {"a %s c", (uint64_t *) &tval_a, (uint64_t *) &tval_c, (uint64_t *) &tval_c,
198      (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c },
199   {"d %s e", (uint64_t *) &tval_d, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
200      (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c },
201   {"e %s e", (uint64_t *) &tval_e, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
202      (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d }
203 };
204
205 struct harness_uint64_pred uint64_tests_ule[] = {
206   {"a %s a", (uint64_t *) &tval_a, (uint64_t *) &tval_a, (uint64_t *) &tval_c,
207      (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c},
208   {"a %s b", (uint64_t *) &tval_a, (uint64_t *) &tval_b, (uint64_t *) &tval_c,
209      (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c},
210   {"a %s c", (uint64_t *) &tval_a, (uint64_t *) &tval_c, (uint64_t *) &tval_c,
211      (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
212   {"d %s e", (uint64_t *) &tval_d, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
213      (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
214   {"e %s e", (uint64_t *) &tval_e, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
215      (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c}
216 };
217
218 struct harness_uint64_pred uint64_tests_uge[] = {
219   {"a %s a", (uint64_t *) &tval_a, (uint64_t *) &tval_a, (uint64_t *) &tval_c,
220      (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c},
221   {"a %s b", (uint64_t *) &tval_a, (uint64_t *) &tval_b, (uint64_t *) &tval_c,
222      (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
223   {"a %s c", (uint64_t *) &tval_a, (uint64_t *) &tval_c, (uint64_t *) &tval_c,
224      (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c},
225   {"d %s e", (uint64_t *) &tval_d, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
226      (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c},
227   {"e %s e", (uint64_t *) &tval_e, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
228      (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c}
229 };
230
231 struct harness_uint64_pred uint64_tests_ult[] = {
232   {"a %s a", (uint64_t *) &tval_a, (uint64_t *) &tval_a, (uint64_t *) &tval_c,
233      (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
234   {"a %s b", (uint64_t *) &tval_a, (uint64_t *) &tval_b, (uint64_t *) &tval_c,
235      (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c},
236   {"a %s c", (uint64_t *) &tval_a, (uint64_t *) &tval_c, (uint64_t *) &tval_c,
237      (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
238   {"d %s e", (uint64_t *) &tval_d, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
239      (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
240   {"e %s e", (uint64_t *) &tval_e, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
241      (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d}
242 };
243
244 struct uint64_pred_s uint64_preds[] = {
245   {"ugt", i64_ugt, i64_ugt_select,
246      uint64_tests_ugt, ARR_SIZE(uint64_tests_ugt)},
247   {"ule", i64_ule, i64_ule_select,
248      uint64_tests_ule, ARR_SIZE(uint64_tests_ule)},
249   {"uge", i64_uge, i64_uge_select,
250      uint64_tests_uge, ARR_SIZE(uint64_tests_uge)},
251   {"ult", i64_ult, i64_ult_select,
252      uint64_tests_ult, ARR_SIZE(uint64_tests_ult)}
253 };
254
255 int
256 compare_expect_int64(const struct int64_pred_s * pred)
257 {
258   int             j, failed = 0;
259
260   for (j = 0; j < pred->n_tests; ++j) {
261     int             pred_result;
262
263     pred_result = (*pred->predfunc) (*pred->tests[j].lhs, *pred->tests[j].rhs);
264
265     if (pred_result != pred->tests[j].expected) {
266       char            str[64];
267
268       sprintf(str, pred->tests[j].fmt_string, pred->name);
269       printf("%s: returned value is %d, expecting %d\n", str,
270              pred_result, pred->tests[j].expected);
271       printf("  lhs = %19lld (0x%016llx)\n", *pred->tests[j].lhs,
272              *pred->tests[j].lhs);
273       printf("  rhs = %19lld (0x%016llx)\n", *pred->tests[j].rhs,
274              *pred->tests[j].rhs);
275       ++failed;
276     } else {
277       int64_t         selresult;
278
279       selresult = (pred->selfunc) (*pred->tests[j].lhs, *pred->tests[j].rhs,
280                                    *pred->tests[j].select_a,
281                                    *pred->tests[j].select_b);
282
283       if (selresult != *pred->tests[j].select_expected) {
284         char            str[64];
285
286         sprintf(str, pred->tests[j].fmt_string, pred->name);
287         printf("%s select: returned value is %d, expecting %d\n", str,
288                pred_result, pred->tests[j].expected);
289         printf("  lhs   = %19lld (0x%016llx)\n", *pred->tests[j].lhs,
290                *pred->tests[j].lhs);
291         printf("  rhs   = %19lld (0x%016llx)\n", *pred->tests[j].rhs,
292                *pred->tests[j].rhs);
293         printf("  true  = %19lld (0x%016llx)\n", *pred->tests[j].select_a,
294                *pred->tests[j].select_a);
295         printf("  false = %19lld (0x%016llx)\n", *pred->tests[j].select_b,
296                *pred->tests[j].select_b);
297         ++failed;
298       }
299     }
300   }
301
302   printf("  %d tests performed, should be %d.\n", j, pred->n_tests);
303
304   return failed;
305 }
306
307 int
308 compare_expect_uint64(const struct uint64_pred_s * pred)
309 {
310   int             j, failed = 0;
311
312   for (j = 0; j < pred->n_tests; ++j) {
313     int             pred_result;
314
315     pred_result = (*pred->predfunc) (*pred->tests[j].lhs, *pred->tests[j].rhs);
316     if (pred_result != pred->tests[j].expected) {
317       char            str[64];
318
319       sprintf(str, pred->tests[j].fmt_string, pred->name);
320       printf("%s: returned value is %d, expecting %d\n", str,
321              pred_result, pred->tests[j].expected);
322       printf("  lhs = %19llu (0x%016llx)\n", *pred->tests[j].lhs,
323              *pred->tests[j].lhs);
324       printf("  rhs = %19llu (0x%016llx)\n", *pred->tests[j].rhs,
325              *pred->tests[j].rhs);
326       ++failed;
327     } else {
328       uint64_t        selresult;
329
330       selresult = (pred->selfunc) (*pred->tests[j].lhs, *pred->tests[j].rhs,
331                                    *pred->tests[j].select_a,
332                                    *pred->tests[j].select_b);
333       if (selresult != *pred->tests[j].select_expected) {
334         char            str[64];
335
336         sprintf(str, pred->tests[j].fmt_string, pred->name);
337         printf("%s select: returned value is %d, expecting %d\n", str,
338                pred_result, pred->tests[j].expected);
339         printf("  lhs   = %19llu (0x%016llx)\n", *pred->tests[j].lhs,
340                *pred->tests[j].lhs);
341         printf("  rhs   = %19llu (0x%016llx)\n", *pred->tests[j].rhs,
342                *pred->tests[j].rhs);
343         printf("  true  = %19llu (0x%016llx)\n", *pred->tests[j].select_a,
344                *pred->tests[j].select_a);
345         printf("  false = %19llu (0x%016llx)\n", *pred->tests[j].select_b,
346                *pred->tests[j].select_b);
347         ++failed;
348       }
349     }
350   }
351
352   printf("  %d tests performed, should be %d.\n", j, pred->n_tests);
353
354   return failed;
355 }
356
357 /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
358
359 int
360 test_i64_sext_i32(int in, int64_t expected) {
361   int64_t result = (int64_t) in;
362
363   if (result != expected) {
364     char str[64];
365     sprintf(str, "i64_sext_i32(%d) returns %lld\n", in, result);
366     return 1;
367   }
368
369   return 0;
370 }
371
372 int
373 test_i64_sext_i16(short in, int64_t expected) {
374   int64_t result = (int64_t) in;
375
376   if (result != expected) {
377     char str[64];
378     sprintf(str, "i64_sext_i16(%hd) returns %lld\n", in, result);
379     return 1;
380   }
381
382   return 0;
383 }
384
385 int
386 test_i64_sext_i8(signed char in, int64_t expected) {
387   int64_t result = (int64_t) in;
388
389   if (result != expected) {
390     char str[64];
391     sprintf(str, "i64_sext_i8(%d) returns %lld\n", in, result);
392     return 1;
393   }
394
395   return 0;
396 }
397
398 int
399 test_i64_zext_i32(unsigned int in, uint64_t expected) {
400   uint64_t result = (uint64_t) in;
401
402   if (result != expected) {
403     char str[64];
404     sprintf(str, "i64_zext_i32(%u) returns %llu\n", in, result);
405     return 1;
406   }
407
408   return 0;
409 }
410
411 int
412 test_i64_zext_i16(unsigned short in, uint64_t expected) {
413   uint64_t result = (uint64_t) in;
414
415   if (result != expected) {
416     char str[64];
417     sprintf(str, "i64_zext_i16(%hu) returns %llu\n", in, result);
418     return 1;
419   }
420
421   return 0;
422 }
423
424 int
425 test_i64_zext_i8(unsigned char in, uint64_t expected) {
426   uint64_t result = (uint64_t) in;
427
428   if (result != expected) {
429     char str[64];
430     sprintf(str, "i64_zext_i8(%u) returns %llu\n", in, result);
431     return 1;
432   }
433
434   return 0;
435 }
436
437 /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
438
439 int64_t
440 i64_shl_const(int64_t a) {
441   return a << 10;
442 }
443
444 int64_t
445 i64_shl(int64_t a, int amt) {
446   return a << amt;
447 }
448
449 uint64_t
450 u64_shl_const(uint64_t a) {
451   return a << 10;
452 }
453
454 uint64_t
455 u64_shl(uint64_t a, int amt) {
456   return a << amt;
457 }
458
459 int64_t
460 i64_srl_const(int64_t a) {
461   return a >> 10;
462 }
463
464 int64_t
465 i64_srl(int64_t a, int amt) {
466   return a >> amt;
467 }
468
469 uint64_t
470 u64_srl_const(uint64_t a) {
471   return a >> 10;
472 }
473
474 uint64_t
475 u64_srl(uint64_t a, int amt) {
476   return a >> amt;
477 }
478
479 int64_t
480 i64_sra_const(int64_t a) {
481   return a >> 10;
482 }
483
484 int64_t
485 i64_sra(int64_t a, int amt) {
486   return a >> amt;
487 }
488
489 uint64_t
490 u64_sra_const(uint64_t a) {
491   return a >> 10;
492 }
493
494 uint64_t
495 u64_sra(uint64_t a, int amt) {
496   return a >> amt;
497 }
498
499 int
500 test_u64_constant_shift(const char *func_name, uint64_t (*func)(uint64_t), uint64_t a, uint64_t expected) {
501   uint64_t result = (*func)(a);
502
503   if (result != expected) {
504     printf("%s(0x%016llx) returns 0x%016llx, expected 0x%016llx\n", func_name, a, result, expected);
505     return 1;
506   }
507
508   return 0;
509 }
510
511 int
512 test_i64_constant_shift(const char *func_name, int64_t (*func)(int64_t), int64_t a, int64_t expected) {
513   int64_t result = (*func)(a);
514
515   if (result != expected) {
516     printf("%s(0x%016llx) returns 0x%016llx, expected 0x%016llx\n", func_name, a, result, expected);
517     return 1;
518   }
519
520   return 0;
521 }
522
523 int
524 test_u64_variable_shift(const char *func_name, uint64_t (*func)(uint64_t, int), uint64_t a, unsigned int b, uint64_t expected) {
525   uint64_t result = (*func)(a, b);
526
527   if (result != expected) {
528     printf("%s(0x%016llx, %d) returns 0x%016llx, expected 0x%016llx\n", func_name, a, b, result, expected);
529     return 1;
530   }
531
532   return 0;
533 }
534
535 int
536 test_i64_variable_shift(const char *func_name, int64_t (*func)(int64_t, int), int64_t a, unsigned int b, int64_t expected) {
537   int64_t result = (*func)(a, b);
538
539   if (result != expected) {
540     printf("%s(0x%016llx, %d) returns 0x%016llx, expected 0x%016llx\n", func_name, a, b, result, expected);
541     return 1;
542   }
543
544   return 0;
545 }
546
547 /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
548
549 int
550 main(void)
551 {
552   int             i, j, failed = 0;
553   const char     *something_failed = "  %d tests failed.\n";
554   const char     *all_tests_passed = "  All tests passed.\n";
555
556   printf("tval_a = %20lld (0x%020llx)\n", tval_a, tval_a);
557   printf("tval_b = %20lld (0x%020llx)\n", tval_b, tval_b);
558   printf("tval_c = %20lld (0x%020llx)\n", tval_c, tval_c);
559   printf("tval_d = %20lld (0x%020llx)\n", tval_d, tval_d);
560   printf("tval_e = %20lld (0x%020llx)\n", tval_e, tval_e);
561   printf("tval_f = %20llu (0x%020llx)\n", tval_f, tval_f);
562   printf("----------------------------------------\n");
563
564   for (i = 0; i < ARR_SIZE(int64_preds); ++i) {
565     printf("%s series:\n", int64_preds[i].name);
566     if ((failed = compare_expect_int64(int64_preds + i)) > 0) {
567       printf(something_failed, failed);
568     } else {
569       printf(all_tests_passed);
570     }
571
572     printf("----------------------------------------\n");
573   }
574
575   for (i = 0; i < ARR_SIZE(uint64_preds); ++i) {
576     printf("%s series:\n", uint64_preds[i].name);
577     if ((failed = compare_expect_uint64(uint64_preds + i)) > 0) {
578       printf(something_failed, failed);
579     } else {
580       printf(all_tests_passed);
581     }
582
583     printf("----------------------------------------\n");
584   }
585
586   /*----------------------------------------------------------------------*/
587
588   puts("signed/zero-extend tests:");
589
590   failed = 0;
591   failed += test_i64_sext_i32(-1, -1LL);
592   failed += test_i64_sext_i32(10, 10LL);
593   failed += test_i64_sext_i32(0x7fffffff, 0x7fffffffLL);
594   failed += test_i64_sext_i16(-1, -1LL);
595   failed += test_i64_sext_i16(10, 10LL);
596   failed += test_i64_sext_i16(0x7fff, 0x7fffLL);
597   failed += test_i64_sext_i8(-1, -1LL);
598   failed += test_i64_sext_i8(10, 10LL);
599   failed += test_i64_sext_i8(0x7f, 0x7fLL);
600
601   failed += test_i64_zext_i32(0xffffffff, 0x00000000ffffffffLLU);
602   failed += test_i64_zext_i32(0x01234567, 0x0000000001234567LLU);
603   failed += test_i64_zext_i16(0xffff,     0x000000000000ffffLLU);
604   failed += test_i64_zext_i16(0x569a,     0x000000000000569aLLU);
605   failed += test_i64_zext_i8(0xff,        0x00000000000000ffLLU);
606   failed += test_i64_zext_i8(0xa0,        0x00000000000000a0LLU);
607
608   if (failed > 0) {
609     printf("  %d tests failed.\n", failed);
610   } else {
611     printf("  All tests passed.\n");
612   }
613
614   printf("----------------------------------------\n");
615
616   failed = 0;
617   puts("signed left/right shift tests:");
618   failed += test_i64_constant_shift("i64_shl_const", i64_shl_const, tval_a,     0x00047dc7ec114c00LL);
619   failed += test_i64_variable_shift("i64_shl",       i64_shl,       tval_a, 10, 0x00047dc7ec114c00LL);
620   failed += test_i64_constant_shift("i64_srl_const", i64_srl_const, tval_a,     0x0000000047dc7ec1LL);
621   failed += test_i64_variable_shift("i64_srl",       i64_srl,       tval_a, 10, 0x0000000047dc7ec1LL);
622   failed += test_i64_constant_shift("i64_sra_const", i64_sra_const, tval_a,     0x0000000047dc7ec1LL);
623   failed += test_i64_variable_shift("i64_sra",       i64_sra,       tval_a, 10, 0x0000000047dc7ec1LL);
624
625   if (failed > 0) {
626     printf("  %d tests ailed.\n", failed);
627   } else {
628     printf("  All tests passed.\n");
629   }
630
631   printf("----------------------------------------\n");
632
633   failed = 0;
634   puts("unsigned left/right shift tests:");
635   failed += test_u64_constant_shift("u64_shl_const", u64_shl_const,  tval_f,     0xfffc1d404d7ae400LL);
636   failed += test_u64_variable_shift("u64_shl",       u64_shl,        tval_f, 10, 0xfffc1d404d7ae400LL);
637   failed += test_u64_constant_shift("u64_srl_const", u64_srl_const,  tval_f,     0x003fffffc1d404d7LL);
638   failed += test_u64_variable_shift("u64_srl",       u64_srl,        tval_f, 10, 0x003fffffc1d404d7LL);
639   failed += test_i64_constant_shift("i64_sra_const", i64_sra_const,  tval_f,     0xffffffffc1d404d7LL);
640   failed += test_i64_variable_shift("i64_sra",       i64_sra,        tval_f, 10, 0xffffffffc1d404d7LL);
641   failed += test_u64_constant_shift("u64_sra_const", u64_sra_const,  tval_f,     0x003fffffc1d404d7LL);
642   failed += test_u64_variable_shift("u64_sra",       u64_sra,        tval_f, 10, 0x003fffffc1d404d7LL);
643
644   if (failed > 0) {
645     printf("  %d tests ailed.\n", failed);
646   } else {
647     printf("  All tests passed.\n");
648   }
649
650   printf("----------------------------------------\n");
651
652   return 0;
653 }