diff options
author | kargl <kargl@FreeBSD.org> | 2013-06-03 17:51:08 +0000 |
---|---|---|
committer | kargl <kargl@FreeBSD.org> | 2013-06-03 17:51:08 +0000 |
commit | 0ded3d37df30ac90468c725aca63495d1380d443 (patch) | |
tree | d0212f828a1fb3d59a1050ba792cd3c3cd767467 /lib/msun | |
parent | fbe58039391c863167ca77024f95b85e67f14ce5 (diff) | |
download | FreeBSD-src-0ded3d37df30ac90468c725aca63495d1380d443.zip FreeBSD-src-0ded3d37df30ac90468c725aca63495d1380d443.tar.gz |
Introduce the macro LOG2_INTERVAL, which is log2(number of intervals).
Use the macroi as a micro-optimization to convert a subtraction and
division to a shift.
Obtained from: bde
Diffstat (limited to 'lib/msun')
-rw-r--r-- | lib/msun/ld128/s_expl.c | 3 | ||||
-rw-r--r-- | lib/msun/ld80/s_expl.c | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/msun/ld128/s_expl.c b/lib/msun/ld128/s_expl.c index 9614530..60e6425 100644 --- a/lib/msun/ld128/s_expl.c +++ b/lib/msun/ld128/s_expl.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include "math_private.h" #define INTERVALS 128 +#define LOG2_INTERVALS 7 #define BIAS (LDBL_MAX_EXP - 1) static volatile const long double tiny = 0x1p-10000L; @@ -229,7 +230,7 @@ expl(long double x) fn = x * INV_L + 0x1.8p112 - 0x1.8p112; n = (int)fn; n2 = (unsigned)n % INTERVALS; - k = (n - n2) / INTERVALS; + k = n >> LOG2_INTERVALS; r1 = x - fn * L1; r2 = -fn * L2; diff --git a/lib/msun/ld80/s_expl.c b/lib/msun/ld80/s_expl.c index 38568f2..c7d923d 100644 --- a/lib/msun/ld80/s_expl.c +++ b/lib/msun/ld80/s_expl.c @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include "math_private.h" #define INTERVALS 128 +#define LOG2_INTERVALS 7 #define BIAS (LDBL_MAX_EXP - 1) static const long double @@ -269,7 +270,8 @@ expl(long double x) n = (int)fn; #endif n2 = (unsigned)n % INTERVALS; - k = (n - n2) / INTERVALS; + /* Depend on the sign bit being propagated: */ + k = n >> LOG2_INTERVALS; r1 = x - fn * L1; r2 = -fn * L2; |