| 1 |
/* Check reciprocal estimate functions for accuracy. */ |
| 2 |
|
| 3 |
#ifdef __LP64__ |
| 4 |
typedef unsigned long uns64_t; |
| 5 |
#define UNUM64(x) x ## L |
| 6 |
|
| 7 |
#else |
| 8 |
typedef unsigned long long uns64_t; |
| 9 |
#define UNUM64(x) x ## LL |
| 10 |
#endif |
| 11 |
|
| 12 |
typedef unsigned int uns32_t; |
| 13 |
|
| 14 |
#define TNAME2(x) #x |
| 15 |
#define TNAME(x) TNAME2(x) |
| 16 |
|
| 17 |
/* |
| 18 |
* Float functions. |
| 19 |
*/ |
| 20 |
|
| 21 |
#define TYPE float |
| 22 |
#define NAME(PREFIX) PREFIX ## _float |
| 23 |
#define UNS_TYPE uns32_t |
| 24 |
#define UNS_ABS __builtin_abs |
| 25 |
#define EXP_SIZE 8 |
| 26 |
#define MAN_SIZE 23 |
| 27 |
#define FABS __builtin_fabsf |
| 28 |
#define FMAX __builtin_fmaxf |
| 29 |
#define FMIN __builtin_fminf |
| 30 |
#define SQRT __builtin_sqrtf |
| 31 |
#define RMIN 1.0e-10 |
| 32 |
#define RMAX 1.0e+10 |
| 33 |
#define BDIV 1 |
| 34 |
#define BRSQRT 2 |
| 35 |
#define ASMDIV "fdivs" |
| 36 |
#define ASMSQRT "fsqrts" |
| 37 |
|
| 38 |
#define INIT_DIV \ |
| 39 |
{ \ |
| 40 |
{ 0x4fffffff }, /* 8589934080 */ \ |
| 41 |
{ 0x4effffff }, /* 2147483520 */ \ |
| 42 |
{ 0x40ffffff }, /* 7.99999952316284 */ \ |
| 43 |
{ 0x3fffffff }, /* 1.99999988079071 */ \ |
| 44 |
{ 0x417fffff }, /* 15.9999990463257 */ \ |
| 45 |
{ 0x42ffffff }, /* 127.999992370605 */ \ |
| 46 |
{ 0x3dffffff }, /* 0.124999992549419 */ \ |
| 47 |
{ 0x3effffff }, /* 0.499999970197678 */ \ |
| 48 |
} |
| 49 |
|
| 50 |
#define INIT_RSQRT \ |
| 51 |
{ \ |
| 52 |
{ 0x457ffffe }, /* 4096 - small amount */ \ |
| 53 |
{ 0x4c7fffff }, /* 6.71089e+07 */ \ |
| 54 |
{ 0x3d7fffff }, /* 0.0625 - small amount */ \ |
| 55 |
{ 0x307ffffe }, /* 9.31322e-10 */ \ |
| 56 |
{ 0x4c7ffffe }, /* 6.71089e+07 */ \ |
| 57 |
{ 0x397ffffe }, /* 0.000244141 */ \ |
| 58 |
{ 0x2e7fffff }, /* 5.82077e-11 */ \ |
| 59 |
{ 0x2f7fffff }, /* 2.32831e-10 */ \ |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
#include "recip-test2.h" |
| 64 |
|
| 65 |
/* |
| 66 |
* Double functions. |
| 67 |
*/ |
| 68 |
|
| 69 |
#undef TYPE |
| 70 |
#undef NAME |
| 71 |
#undef UNS_TYPE |
| 72 |
#undef UNS_ABS |
| 73 |
#undef EXP_SIZE |
| 74 |
#undef MAN_SIZE |
| 75 |
#undef FABS |
| 76 |
#undef FMAX |
| 77 |
#undef FMIN |
| 78 |
#undef SQRT |
| 79 |
#undef RMIN |
| 80 |
#undef RMAX |
| 81 |
#undef BDIV |
| 82 |
#undef BRSQRT |
| 83 |
#undef ASMDIV |
| 84 |
#undef ASMSQRT |
| 85 |
#undef INIT_DIV |
| 86 |
#undef INIT_RSQRT |
| 87 |
|
| 88 |
#define TYPE double |
| 89 |
#define NAME(PREFIX) PREFIX ## _double |
| 90 |
#define UNS_TYPE uns64_t |
| 91 |
#define UNS_ABS __builtin_imaxabs |
| 92 |
#define EXP_SIZE 11 |
| 93 |
#define MAN_SIZE 52 |
| 94 |
#define FABS __builtin_fabs |
| 95 |
#define FMAX __builtin_fmax |
| 96 |
#define FMIN __builtin_fmin |
| 97 |
#define SQRT __builtin_sqrt |
| 98 |
#define RMIN 1.0e-100 |
| 99 |
#define RMAX 1.0e+100 |
| 100 |
#define BDIV 1 |
| 101 |
#define BRSQRT 2 |
| 102 |
#define ASMDIV "fdiv" |
| 103 |
#define ASMSQRT "fsqrt" |
| 104 |
|
| 105 |
#define INIT_DIV \ |
| 106 |
{ \ |
| 107 |
{ UNUM64 (0x2b57be53f2a2f3a0) }, /* 6.78462e-100 */ \ |
| 108 |
{ UNUM64 (0x2b35f8e8ea553e52) }, /* 1.56963e-100 */ \ |
| 109 |
{ UNUM64 (0x2b5b9d861d2fe4fb) }, /* 7.89099e-100 */ \ |
| 110 |
{ UNUM64 (0x2b45dc44a084e682) }, /* 3.12327e-100 */ \ |
| 111 |
{ UNUM64 (0x2b424ce16945d777) }, /* 2.61463e-100 */ \ |
| 112 |
{ UNUM64 (0x2b20b5023d496b50) }, /* 5.96749e-101 */ \ |
| 113 |
{ UNUM64 (0x2b61170547f57caa) }, /* 9.76678e-100 */ \ |
| 114 |
{ UNUM64 (0x2b543b9d498aac37) }, /* 5.78148e-100 */ \ |
| 115 |
} |
| 116 |
|
| 117 |
#define INIT_RSQRT \ |
| 118 |
{ \ |
| 119 |
{ UNUM64 (0x2b616f2d8cbbc646) }, /* 9.96359e-100 */ \ |
| 120 |
{ UNUM64 (0x2b5c4db2da0a011d) }, /* 8.08764e-100 */ \ |
| 121 |
{ UNUM64 (0x2b55a82d5735b262) }, /* 6.1884e-100 */ \ |
| 122 |
{ UNUM64 (0x2b50b52908258cb8) }, /* 4.77416e-100 */ \ |
| 123 |
{ UNUM64 (0x2b363989a4fb29af) }, /* 1.58766e-100 */ \ |
| 124 |
{ UNUM64 (0x2b508b9f6f4180a9) }, /* 4.7278e-100 */ \ |
| 125 |
{ UNUM64 (0x2b4f7a1d48accb40) }, /* 4.49723e-100 */ \ |
| 126 |
{ UNUM64 (0x2b1146a37372a81f) }, /* 3.08534e-101 */ \ |
| 127 |
{ UNUM64 (0x2b33f876a8c48050) }, /* 1.42663e-100 */ \ |
| 128 |
} |
| 129 |
|
| 130 |
#include "recip-test2.h" |
| 131 |
|
| 132 |
int |
| 133 |
main (int argc __attribute__((__unused__)), |
| 134 |
char *argv[] __attribute__((__unused__))) |
| 135 |
{ |
| 136 |
srand48 (1); |
| 137 |
run_float (); |
| 138 |
|
| 139 |
#ifdef VERBOSE |
| 140 |
printf ("\n"); |
| 141 |
#endif |
| 142 |
|
| 143 |
run_double (); |
| 144 |
|
| 145 |
if (error_count_float != 0 || error_count_double != 0) |
| 146 |
abort (); |
| 147 |
|
| 148 |
return 0; |
| 149 |
} |