This is the mail archive of the glibc-cvs@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]

GNU C Library master sources branch master updated. glibc-2.17-144-gcaa99d0


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  caa99d06e7f1403887294442af520b0f8c6f3de0 (commit)
       via  d3b9ea614822b66f88ba6815a2d2c6cf63922cd7 (commit)
      from  1dbaee3c12d6a1310b45a390edc2d06df61493fa (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=caa99d06e7f1403887294442af520b0f8c6f3de0

commit caa99d06e7f1403887294442af520b0f8c6f3de0
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Fri Jan 18 11:18:13 2013 +0530

    Simplify calculation of 2^-m in __mpexp

diff --git a/ChangeLog b/ChangeLog
index 1d17c4d..52a9542 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2013-01-18  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
+	* sysdeps/ieee754/dbl-64/mpa.h (__pow_mp): New function to get an
+	mp_no from a power of two.
+	* sysdeps/ieee754/dbl-64/mpexp.c (__mpexp): Remove
+	__mpexp_twomm1.  Use __pow_mp.
+
 	* sysdeps/ieee754/dbl-64/mpexp.c (__mpexp): Remove unnecessary
 	multiplication.
 
diff --git a/sysdeps/ieee754/dbl-64/mpa.h b/sysdeps/ieee754/dbl-64/mpa.h
index debb3b2..06343d4 100644
--- a/sysdeps/ieee754/dbl-64/mpa.h
+++ b/sysdeps/ieee754/dbl-64/mpa.h
@@ -123,3 +123,33 @@ extern void __mpsqrt (mp_no *, mp_no *, int);
 extern void __mpexp (mp_no *, mp_no *, int);
 extern void __c32 (mp_no *, mp_no *, mp_no *, int);
 extern int __mpranred (double, mp_no *, int);
+
+/* Given a power POW, build a multiprecision number 2^POW.  */
+static inline void
+__pow_mp (int pow, mp_no *y, int p)
+{
+  int i, rem;
+
+  /* The exponent is E such that E is a factor of 2^24.  The remainder (of the
+     form 2^x) goes entirely into the first digit of the mantissa as it is
+     always less than 2^24.  */
+  EY = pow / 24;
+  rem = pow - EY * 24;
+  EY++;
+
+  /* If the remainder is negative, it means that POW was negative since
+     |EY * 24| <= |pow|.  Adjust so that REM is positive and still less than
+     24 because of which, the mantissa digit is less than 2^24.  */
+  if (rem < 0)
+    {
+      EY--;
+      rem += 24;
+    }
+  /* The sign of any 2^x is always positive.  */
+  Y[0] = ONE;
+  Y[1] = 1 << rem;
+
+  /* Everything else is ZERO.  */
+  for (i = 2; i <= p; i++)
+    Y[i] = ZERO;
+}
diff --git a/sysdeps/ieee754/dbl-64/mpexp.c b/sysdeps/ieee754/dbl-64/mpexp.c
index 811fb46..8d288ff 100644
--- a/sysdeps/ieee754/dbl-64/mpexp.c
+++ b/sysdeps/ieee754/dbl-64/mpexp.c
@@ -43,7 +43,7 @@ SECTION
 __mpexp (mp_no *x, mp_no *y, int p)
 {
   int i, j, k, m, m1, m2, n;
-  double a, b;
+  double 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,
@@ -61,19 +61,6 @@ __mpexp (mp_no *x, mp_no *y, int p)
       70, 73, 76, 78,
       81
     };
-  /* Stored values for 2^-m, where values of m are defined in M1P above.   */
-  static const double __mpexp_twomm1[33] =
-    {
-      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},
@@ -98,18 +85,10 @@ __mpexp (mp_no *x, mp_no *y, int p)
   /* Choose m,n and compute a=2**(-m).  */
   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];
   m2 = 24 * EX;
   for (; b < HALFRAD; m2--)
-    {
-      a *= TWO;
-      b *= TWO;
-    }
+    b *= TWO;
   if (b == HALFRAD)
     {
       for (i = 2; i <= p; i++)
@@ -118,10 +97,7 @@ __mpexp (mp_no *x, mp_no *y, int p)
 	    break;
 	}
       if (i == p + 1)
-	{
-	  m2--;
-	  a *= TWO;
-	}
+	m2--;
     }
 
   m = m1 + m2;
@@ -134,14 +110,13 @@ __mpexp (mp_no *x, mp_no *y, int p)
 	 than 2^-55.  */
       assert (p < 18);
       m = 0;
-      a = ONE;
       for (i = n - 1; i > 0; i--, n--)
 	if (m1np[i][p] + m2 > 0)
 	  break;
     }
 
   /* Compute s=x*2**(-m). Put result in mps.  */
-  __dbl_mp (a, &mpt1, p);
+  __pow_mp (-m, &mpt1, p);
   __mul (x, &mpt1, &mps, p);
 
   /* Evaluate the polynomial. Put result in mpt2.  */

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d3b9ea614822b66f88ba6815a2d2c6cf63922cd7

commit d3b9ea614822b66f88ba6815a2d2c6cf63922cd7
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Fri Jan 18 11:14:34 2013 +0530

    Remove unnecessary multiplication with RADIXI

diff --git a/ChangeLog b/ChangeLog
index 6ca7a8b..1d17c4d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-01-18  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	* sysdeps/ieee754/dbl-64/mpexp.c (__mpexp): Remove unnecessary
+	multiplication.
+
 2013-01-17  David S. Miller  <davem@davemloft.net>
 
 	* sysdeps/sparc/fpu/libm-test-ulps: Update.
diff --git a/sysdeps/ieee754/dbl-64/mpexp.c b/sysdeps/ieee754/dbl-64/mpexp.c
index aca6bf6..811fb46 100644
--- a/sysdeps/ieee754/dbl-64/mpexp.c
+++ b/sysdeps/ieee754/dbl-64/mpexp.c
@@ -103,14 +103,14 @@ __mpexp (mp_no *x, mp_no *y, int p)
     a *= RADIXI;
   for (; i > EX; i--)
     a *= RADIX;
-  b = X[1] * RADIXI;
+  b = X[1];
   m2 = 24 * EX;
-  for (; b < HALF; m2--)
+  for (; b < HALFRAD; m2--)
     {
       a *= TWO;
       b *= TWO;
     }
-  if (b == HALF)
+  if (b == HALFRAD)
     {
       for (i = 2; i <= p; i++)
 	{

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                      |   10 ++++++++++
 sysdeps/ieee754/dbl-64/mpa.h   |   30 ++++++++++++++++++++++++++++++
 sysdeps/ieee754/dbl-64/mpexp.c |   39 +++++++--------------------------------
 3 files changed, 47 insertions(+), 32 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


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