From eca1c35e5be967478c8fe9381c6f4652b6645d5e Mon Sep 17 00:00:00 2001 From: nsz Date: Mon, 19 Mar 2012 18:52:17 +0100 Subject: [PATCH] remove long double const workarounds Some long double consts were stored in two doubles as a workaround for x86_64 and i386 with the following comment: /* Long double constants are slow on these arches, and broken on i386. */ This is most likely old gcc bug related to the default x87 fpu precision setting (it's double instead of double extended on BSD). --- src/math/__cosl.c | 9 --------- src/math/__rem_pio2l.h | 19 ------------------- src/math/__sinl.c | 9 --------- src/math/__tanl.c | 20 -------------------- src/math/acosl.c | 14 +------------- src/math/atan2l.c | 10 +--------- 6 files changed, 2 insertions(+), 79 deletions(-) diff --git a/src/math/__cosl.c b/src/math/__cosl.c index 9ea51ecf..80036ddb 100644 --- a/src/math/__cosl.c +++ b/src/math/__cosl.c @@ -43,17 +43,8 @@ */ static const double one = 1.0; -// FIXME -/* Long double constants are slow on these arches, and broken on i386. */ -static const volatile double -C1hi = 0.041666666666666664, /* 0x15555555555555.0p-57 */ -C1lo = 2.2598839032744733e-18; /* 0x14d80000000000.0p-111 */ -#define C1 ((long double)C1hi + C1lo) - -#if 0 static const long double C1 = 0.0416666666666666666136L; /* 0xaaaaaaaaaaaaaa9b.0p-68 */ -#endif static const double C2 = -0.0013888888888888874, /* -0x16c16c16c16c10.0p-62 */ diff --git a/src/math/__rem_pio2l.h b/src/math/__rem_pio2l.h index 37f3bd28..11123c3f 100644 --- a/src/math/__rem_pio2l.h +++ b/src/math/__rem_pio2l.h @@ -38,30 +38,11 @@ pio2_1 = 1.57079632679597125389e+00, /* 0x3FF921FB, 0x54444000 */ pio2_2 = -1.07463465549783099519e-12, /* -0x12e7b967674000.0p-92 */ pio2_3 = 6.36831716351370313614e-25; /* 0x18a2e037074000.0p-133 */ -// FIXME: this should be verified (maybe old gcc specific hack) -//#if defined(__amd64__) || defined(__i386__) -/* Long double constants are slow on these arches, and broken on i386. */ -static const volatile double -invpio2hi = 6.3661977236758138e-01, /* 0x145f306dc9c883.0p-53 */ -invpio2lo = -3.9356538861223811e-17, /* -0x16b00000000000.0p-107 */ -pio2_1thi = -1.0746346554971943e-12, /* -0x12e7b9676733af.0p-92 */ -pio2_1tlo = 8.8451028997905949e-29, /* 0x1c080000000000.0p-146 */ -pio2_2thi = 6.3683171635109499e-25, /* 0x18a2e03707344a.0p-133 */ -pio2_2tlo = 2.3183081793789774e-41, /* 0x10280000000000.0p-187 */ -pio2_3thi = -2.7529965190440717e-37, /* -0x176b7ed8fbbacc.0p-174 */ -pio2_3tlo = -4.2006647512740502e-54; /* -0x19c00000000000.0p-230 */ -#define invpio2 ((long double)invpio2hi + invpio2lo) -#define pio2_1t ((long double)pio2_1thi + pio2_1tlo) -#define pio2_2t ((long double)pio2_2thi + pio2_2tlo) -#define pio2_3t ((long double)pio2_3thi + pio2_3tlo) -//#else -#if 0 static const long double invpio2 = 6.36619772367581343076e-01L, /* 0xa2f9836e4e44152a.0p-64 */ pio2_1t = -1.07463465549719416346e-12L, /* -0x973dcb3b399d747f.0p-103 */ pio2_2t = 6.36831716351095013979e-25L, /* 0xc51701b839a25205.0p-144 */ pio2_3t = -2.75299651904407171810e-37L; /* -0xbb5bf6c7ddd660ce.0p-185 */ -#endif static inline int __rem_pio2l(long double x, long double *y) { diff --git a/src/math/__sinl.c b/src/math/__sinl.c index 71851d81..67c4bdc5 100644 --- a/src/math/__sinl.c +++ b/src/math/__sinl.c @@ -26,17 +26,8 @@ static const double half = 0.5; -// FIXME -/* Long double constants are slow on these arches, and broken on i386. */ -static const volatile double -S1hi = -0.16666666666666666, /* -0x15555555555555.0p-55 */ -S1lo = -9.2563760475949941e-18; /* -0x15580000000000.0p-109 */ -#define S1 ((long double)S1hi + S1lo) - -#if 0 static const long double S1 = -0.166666666666666666671L; /* -0xaaaaaaaaaaaaaaab.0p-66 */ -#endif static const double S2 = 0.0083333333333333332, /* 0x11111111111111.0p-59 */ diff --git a/src/math/__tanl.c b/src/math/__tanl.c index f842543e..e39e9df4 100644 --- a/src/math/__tanl.c +++ b/src/math/__tanl.c @@ -23,32 +23,12 @@ * See __cosl.c for more details about the polynomial. */ -/* Long double constants are slow on these arches, and broken on i386. */ -static const volatile double -T3hi = 0.33333333333333331, /* 0x15555555555555.0p-54 */ -T3lo = 1.8350121769317163e-17, /* 0x15280000000000.0p-108 */ -T5hi = 0.13333333333333336, /* 0x11111111111112.0p-55 */ -T5lo = 1.3051083651294260e-17, /* 0x1e180000000000.0p-109 */ -T7hi = 0.053968253968250494, /* 0x1ba1ba1ba1b827.0p-57 */ -T7lo = 3.1509625637859973e-18, /* 0x1d100000000000.0p-111 */ -pio4_hi = 0.78539816339744828, /* 0x1921fb54442d18.0p-53 */ -pio4_lo = 3.0628711372715500e-17, /* 0x11a80000000000.0p-107 */ -pio4lo_hi = -1.2541394031670831e-20, /* -0x1d9cceba3f91f2.0p-119 */ -pio4lo_lo = 6.1493048227390915e-37; /* 0x1a280000000000.0p-173 */ -#define T3 ((long double)T3hi + T3lo) -#define T5 ((long double)T5hi + T5lo) -#define T7 ((long double)T7hi + T7lo) -#define pio4 ((long double)pio4_hi + pio4_lo) -#define pio4lo ((long double)pio4lo_hi + pio4lo_lo) - -#if 0 static const long double T3 = 0.333333333333333333180L, /* 0xaaaaaaaaaaaaaaa5.0p-65 */ T5 = 0.133333333333333372290L, /* 0x88888888888893c3.0p-66 */ T7 = 0.0539682539682504975744L, /* 0xdd0dd0dd0dc13ba2.0p-68 */ pio4 = 0.785398163397448309628L, /* 0xc90fdaa22168c235.0p-64 */ pio4lo = -1.25413940316708300586e-20L; /* -0xece675d1fc8f8cbb.0p-130 */ -#endif static const double T9 = 0.021869488536312216, /* 0x1664f4882cc1c2.0p-58 */ diff --git a/src/math/acosl.c b/src/math/acosl.c index 510e16f1..170520fe 100644 --- a/src/math/acosl.c +++ b/src/math/acosl.c @@ -25,20 +25,8 @@ long double acosl(long double x) #include "__invtrigl.h" static const long double -one = 1.00000000000000000000e+00; - -// FIXME -//#ifdef __i386__ -/* XXX Work around the fact that gcc truncates long double constants on i386 */ -static const volatile double -pi1 = 3.14159265358979311600e+00, /* 0x1.921fb54442d18p+1 */ -pi2 = 1.22514845490862001043e-16; /* 0x1.1a80000000000p-53 */ -#define pi ((long double)pi1 + pi2) -//#else -#if 0 -static const long double +one = 1.00000000000000000000e+00, pi = 3.14159265358979323846264338327950280e+00L; -#endif long double acosl(long double x) { diff --git a/src/math/atan2l.c b/src/math/atan2l.c index d5a7a5ac..48abc058 100644 --- a/src/math/atan2l.c +++ b/src/math/atan2l.c @@ -27,16 +27,8 @@ long double atan2l(long double y, long double x) static const volatile long double tiny = 1.0e-300; static const long double -zero = 0.0; -/* XXX Work around the fact that gcc truncates long double constants on i386 */ -static const volatile double -pi1 = 3.14159265358979311600e+00, /* 0x1.921fb54442d18p+1 */ -pi2 = 1.22514845490862001043e-16; /* 0x1.1a80000000000p-53 */ -#define pi ((long double)pi1 + pi2) -#if 0 -static const long double +zero = 0.0, pi = 3.14159265358979323846264338327950280e+00L; -#endif long double atan2l(long double y, long double x) { -- 2.20.1