[PATCH] Make __mpexp_twomm1 an array of doubles
Andreas Jaeger
aj@suse.com
Wed Jan 9 19:17:00 GMT 2013
On 01/09/2013 04:41 PM, Siddhesh Poyarekar wrote:
> Hi,
>
> __mpexp_twomm1 is currently written as an array of `number` which has
> to be represented differently in code for big and little-endian
> machines. This is completely unnecessary since we never use the
> integer halves and only need the double variant. Attached patch gets
> rid of this cruft and replaces it with a simple array of doubles.
> Verified on x86_64 that this does not cause any regressions. OK to
> commit?
>
> Siddhesh
>
> * sysdeps/ieee754/dbl-64/mpexp.c (__mpexp): Adjust for change
> in type of __mpexp_twomm1.
> * sysdeps/ieee754/dbl-64/mpexp.h (__mpexp_twomm1): Convert to
> an array of doubles.
>
> diff --git a/sysdeps/ieee754/dbl-64/mpexp.c b/sysdeps/ieee754/dbl-64/mpexp.c
> index c404820..44bbcf1 100644
> --- a/sysdeps/ieee754/dbl-64/mpexp.c
> +++ b/sysdeps/ieee754/dbl-64/mpexp.c
> @@ -63,7 +63,7 @@ __mpexp(mp_no *x, mp_no *y, int p) {
> mp_no mps,mpak,mpt1,mpt2;
>
> /* Choose m,n and compute a=2**(-m) */
> - n = np[p]; m1 = m1p[p]; a = __mpexp_twomm1[p].d;
> + n = np[p]; m1 = m1p[p]; a = __mpexp_twomm1[p];
> for (i=0; i<EX; i++) a *= RADIXI;
> for ( ; i>EX; i--) a *= RADIX;
> b = X[1]*RADIXI; m2 = 24*EX;
> diff --git a/sysdeps/ieee754/dbl-64/mpexp.h b/sysdeps/ieee754/dbl-64/mpexp.h
> index 2b26386..b604b97 100644
> --- a/sysdeps/ieee754/dbl-64/mpexp.h
> +++ b/sysdeps/ieee754/dbl-64/mpexp.h
> @@ -27,88 +27,21 @@
> #ifndef MPEXP_H
> #define MPEXP_H
>
> -extern const number __mpexp_twomm1[33] attribute_hidden;
> +extern const double __mpexp_twomm1[] attribute_hidden;
>
> #ifndef AVOID_MPEXP_H
> -#ifdef BIG_ENDI
> - const number
> - __mpexp_twomm1[33] = { /* 2**-m1 */
> -/**/ {{0x3ff00000, 0x00000000} }, /* 1 */
> -/**/ {{0x3ff00000, 0x00000000} }, /* 1 */
> -/**/ {{0x3ff00000, 0x00000000} }, /* 1 */
> -/**/ {{0x3ff00000, 0x00000000} }, /* 1 */
> -/**/ {{0x3ee00000, 0x00000000} }, /* 2**-17 */
> -/**/ {{0x3e800000, 0x00000000} }, /* 2**-23 */
> -/**/ {{0x3e800000, 0x00000000} }, /* 2**-23 */
> -/**/ {{0x3e300000, 0x00000000} }, /* 2**-28 */
> -/**/ {{0x3e400000, 0x00000000} }, /* 2**-27 */
> -/**/ {{0x3d900000, 0x00000000} }, /* 2**-38 */
> -/**/ {{0x3d500000, 0x00000000} }, /* 2**-42 */
> -/**/ {{0x3d800000, 0x00000000} }, /* 2**-39 */
> -/**/ {{0x3d400000, 0x00000000} }, /* 2**-43 */
> -/**/ {{0x3d000000, 0x00000000} }, /* 2**-47 */
> -/**/ {{0x3d400000, 0x00000000} }, /* 2**-43 */
> -/**/ {{0x3d000000, 0x00000000} }, /* 2**-47 */
> -/**/ {{0x3cd00000, 0x00000000} }, /* 2**-50 */
> -/**/ {{0x3c900000, 0x00000000} }, /* 2**-54 */
> -/**/ {{0x3c600000, 0x00000000} }, /* 2**-57 */
> -/**/ {{0x3c300000, 0x00000000} }, /* 2**-60 */
> -/**/ {{0x3bf00000, 0x00000000} }, /* 2**-64 */
> -/**/ {{0x3bc00000, 0x00000000} }, /* 2**-67 */
> -/**/ {{0x3b800000, 0x00000000} }, /* 2**-71 */
> -/**/ {{0x3b500000, 0x00000000} }, /* 2**-74 */
> -/**/ {{0x3bb00000, 0x00000000} }, /* 2**-68 */
> -/**/ {{0x3b800000, 0x00000000} }, /* 2**-71 */
> -/**/ {{0x3b500000, 0x00000000} }, /* 2**-74 */
> -/**/ {{0x3b200000, 0x00000000} }, /* 2**-77 */
> -/**/ {{0x3b900000, 0x00000000} }, /* 2**-70 */
> -/**/ {{0x3b600000, 0x00000000} }, /* 2**-73 */
> -/**/ {{0x3b300000, 0x00000000} }, /* 2**-76 */
> -/**/ {{0x3b100000, 0x00000000} }, /* 2**-78 */
> -/**/ {{0x3ae00000, 0x00000000} }, /* 2**-81 */
Please add a comment describing __mpexp_twomm1. There was a comment
that you deleted - but I think this could be a bit more verbose.
Andreas
> +const double __mpexp_twomm1[] =
> + {
> + 0x1.0p0, 0x1.0p0, 0x1.0p0, 0x1.0p0,
> + 0x1.0p-17, 0x1.0p-23, 0x1.0p-23, 0x1.0p-28,
> + 0x1.0p-27, 0x1.0p-38, 0x1.0p-42, 0x1.0p-39,
> + 0x1.0p-43, 0x1.0p-47, 0x1.0p-43, 0x1.0p-47,
> + 0x1.0p-50, 0x1.0p-54, 0x1.0p-57, 0x1.0p-60,
> + 0x1.0p-64, 0x1.0p-67, 0x1.0p-71, 0x1.0p-74,
> + 0x1.0p-68, 0x1.0p-71, 0x1.0p-74, 0x1.0p-77,
> + 0x1.0p-70, 0x1.0p-73, 0x1.0p-76, 0x1.0p-78,
> + 0x1.0p-81
> };
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126
More information about the Libc-alpha
mailing list