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 siddhesh/libm-mpa updated. glibc-2.17-175-g5e41e91


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, siddhesh/libm-mpa has been updated
       via  5e41e91fa150c44b2a729488b649c5463f520768 (commit)
      from  21b0d2d025b3949198a246ac183bfcc1b9fcb5bb (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=5e41e91fa150c44b2a729488b649c5463f520768

commit 5e41e91fa150c44b2a729488b649c5463f520768
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Wed Feb 13 20:03:38 2013 +0530

    Optimize iterations in __mul and __sqr
    
    Iterations may run only till i and j have not crossed each other.  The
    test against lim is not required; in fact lim is not required since
    for even K, the terminating condition is i == j.

diff --git a/sysdeps/ieee754/dbl-64/mpa.c b/sysdeps/ieee754/dbl-64/mpa.c
index f9e2488..a3c0fb9 100644
--- a/sysdeps/ieee754/dbl-64/mpa.c
+++ b/sysdeps/ieee754/dbl-64/mpa.c
@@ -605,19 +605,14 @@ __mul (const mp_no *x, const mp_no *y, mp_no *z, int p2)
      multiplying zeroes.  */
   while (k > p)
     {
-      long lim = k / 2;
-
-      if (k % 2 == 0)
-        {
-	  /* We want to add this only once, but since we subtract it in the sum
-	     of products above, we add twice.  */
-          zk += 2 * X[lim] * Y[lim];
-	  lim--;
-	}
-
-      for (i = k - p, j = p; i <= lim; i++, j--)
+      for (i = k - p, j = p; i < j; i++, j--)
 	zk += (int64_t) (X[i] + X[j]) * (Y[i] + Y[j]);
 
+      if (i == j)
+	/* We want to add this only once, but since we subtract it in the sum
+	   of products above, we add twice.  */
+        zk += 2 * X[i] * Y[i];
+
       zk -= diag[k - 1];
 
       Z[k--] = zk % I_RADIX;
@@ -639,19 +634,14 @@ __mul (const mp_no *x, const mp_no *y, mp_no *z, int p2)
      used in the loop below.  */
   while (k > 1)
     {
-      long lim = k / 2;
-
-      if (k % 2 == 0)
-        {
-	  /* We want to add this only once, but since we subtract it in the sum
-	     of products above, we add twice.  */
-          zk += 2 * X[lim] * Y[lim];
-	  lim--;
-	}
-
-      for (i = 1, j = k - 1; i <= lim; i++, j--)
+      for (i = 1, j = k - 1; i < j; i++, j--)
 	zk += (int64_t) (X[i] + X[j]) * (Y[i] + Y[j]);
 
+      if (i == j)
+	/* We want to add this only once, but since we subtract it in the sum
+	   of products above, we add twice.  */
+        zk += 2 * X[i] * Y[i];
+
       zk -= diag[k - 1];
 
       Z[k--] = zk % I_RADIX;
@@ -708,12 +698,9 @@ __sqr (const mp_no *x, mp_no *y, int p)
       long lim = k / 2;
 
       if (k % 2 == 0)
-        {
-	  yk += X[lim] * X[lim];
-	  lim--;
-	}
+	yk += X[lim] * X[lim];
 
-      for (i = k - p, j = p; i <= lim; i++, j--)
+      for (i = k - p, j = p; i < j; i++, j--)
 	yk2 += X[i] * X[j];
 
       yk += yk2 * 2;
@@ -728,12 +715,9 @@ __sqr (const mp_no *x, mp_no *y, int p)
       long lim = k / 2;
 
       if (k % 2 == 0)
-        {
-	  yk += X[lim] * X[lim];
-	  lim--;
-	}
+	yk += X[lim] * X[lim];
 
-      for (i = 1, j = k - 1; i <= lim; i++, j--)
+      for (i = 1, j = k - 1; i < j; i++, j--)
 	yk2 += X[i] * X[j];
 
       yk += yk2 * 2;

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

Summary of changes:
 sysdeps/ieee754/dbl-64/mpa.c |   48 ++++++++++++++----------------------------
 1 files changed, 16 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]