This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Make __mpexp_twomm1 an array of doubles


On Wed, Jan 09, 2013 at 08:17:29PM +0100, Andreas Jaeger wrote:
> Please add a comment describing  __mpexp_twomm1. There was a comment
> that you deleted - but I think this could be a bit more verbose.
> 

I guess I could just move __mpexp_twomm1 into mpexp.c since there's no
real need to have it as an shared constant - it is only used in
mpexp.c.  That way I can describe what it is much more clearly, like
in the patch below.  I formatted m1p like I did so that its
association with __mpexp_twomm1 is easier to read.  In future there's
a good opportunity to remote __mpexp_twomm1 completely once I have the
patchset to convert mantissa to int (and supporting benchmark results)
ready.

I'm not removing mpexp.h completely yet since I want to do a round of
consolidation of all of the common constants to get them under a
single header.  How does this look now?

Siddhesh

	* sysdeps/ieee754/dbl-64/mpexp.c (__mpexp): New array of
	doubles __mpexp_twomm1.  Adjust usage.
	* sysdeps/ieee754/dbl-64/mpexp.h (__mpexp_twomm1): Remove.

diff --git a/sysdeps/ieee754/dbl-64/mpexp.c b/sysdeps/ieee754/dbl-64/mpexp.c
index c404820..6937097 100644
--- a/sysdeps/ieee754/dbl-64/mpexp.c
+++ b/sysdeps/ieee754/dbl-64/mpexp.c
@@ -47,8 +47,31 @@ __mpexp(mp_no *x, mp_no *y, int p) {
   double a,b;
   static const int np[33] = {0,0,0,0,3,3,4,4,5,4,4,5,5,5,6,6,6,6,6,6,
 			     6,6,6,6,7,7,7,7,8,8,8,8,8};
-  static const int m1p[33]= {0,0,0,0,17,23,23,28,27,38,42,39,43,47,43,47,50,54,
-			       57,60,64,67,71,74,68,71,74,77,70,73,76,78,81};
+  static const int m1p[33]=
+    {
+      0, 0, 0, 0,
+      17, 23, 23, 28,
+      27, 38, 42, 39,
+      43, 47, 43, 47,
+      50, 54, 57, 60,
+      64, 67, 71, 74,
+      68, 71, 74, 77,
+      70, 73, 76, 78,
+      81
+    };
+  /* Stored values for 2^-m, where values of m are defined in M1P above.   */
+  static 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
+    };
   static const int m1np[7][18] = {
 		 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 		 { 0, 0, 0, 0,36,48,60,72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
@@ -63,7 +86,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..401de58 100644
--- a/sysdeps/ieee754/dbl-64/mpexp.h
+++ b/sysdeps/ieee754/dbl-64/mpexp.h
@@ -27,90 +27,6 @@
 #ifndef MPEXP_H
 #define MPEXP_H
 
-extern const number __mpexp_twomm1[33] 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 */
-  };
-
-#else
-#ifdef LITTLE_ENDI
-  const number
-	__mpexp_twomm1[33] = {                     /* 2**-m1 */
-/**/                  {{0x00000000, 0x3ff00000} }, /* 1      */
-/**/                  {{0x00000000, 0x3ff00000} }, /* 1      */
-/**/                  {{0x00000000, 0x3ff00000} }, /* 1      */
-/**/                  {{0x00000000, 0x3ff00000} }, /* 1      */
-/**/                  {{0x00000000, 0x3ee00000} }, /* 2**-17 */
-/**/                  {{0x00000000, 0x3e800000} }, /* 2**-23 */
-/**/                  {{0x00000000, 0x3e800000} }, /* 2**-23 */
-/**/                  {{0x00000000, 0x3e300000} }, /* 2**-28 */
-/**/                  {{0x00000000, 0x3e400000} }, /* 2**-27 */
-/**/                  {{0x00000000, 0x3d900000} }, /* 2**-38 */
-/**/                  {{0x00000000, 0x3d500000} }, /* 2**-42 */
-/**/                  {{0x00000000, 0x3d800000} }, /* 2**-39 */
-/**/                  {{0x00000000, 0x3d400000} }, /* 2**-43 */
-/**/                  {{0x00000000, 0x3d000000} }, /* 2**-47 */
-/**/                  {{0x00000000, 0x3d400000} }, /* 2**-43 */
-/**/                  {{0x00000000, 0x3d000000} }, /* 2**-47 */
-/**/                  {{0x00000000, 0x3cd00000} }, /* 2**-50 */
-/**/                  {{0x00000000, 0x3c900000} }, /* 2**-54 */
-/**/                  {{0x00000000, 0x3c600000} }, /* 2**-57 */
-/**/                  {{0x00000000, 0x3c300000} }, /* 2**-60 */
-/**/                  {{0x00000000, 0x3bf00000} }, /* 2**-64 */
-/**/                  {{0x00000000, 0x3bc00000} }, /* 2**-67 */
-/**/                  {{0x00000000, 0x3b800000} }, /* 2**-71 */
-/**/                  {{0x00000000, 0x3b500000} }, /* 2**-74 */
-/**/                  {{0x00000000, 0x3bb00000} }, /* 2**-68 */
-/**/                  {{0x00000000, 0x3b800000} }, /* 2**-71 */
-/**/                  {{0x00000000, 0x3b500000} }, /* 2**-74 */
-/**/                  {{0x00000000, 0x3b200000} }, /* 2**-77 */
-/**/                  {{0x00000000, 0x3b900000} }, /* 2**-70 */
-/**/                  {{0x00000000, 0x3b600000} }, /* 2**-73 */
-/**/                  {{0x00000000, 0x3b300000} }, /* 2**-76 */
-/**/                  {{0x00000000, 0x3b100000} }, /* 2**-78 */
-/**/                  {{0x00000000, 0x3ae00000} }, /* 2**-81 */
-  };
-
-#endif
-#endif
-#endif
-
 #define  RADIX     0x1.0p24		/* 2^24 */
 #define  RADIXI    0x1.0p-24		/* 2^-24 */
 #define  ZERO      0.0			/* 0 */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]