[Gmp-commit] /var/hg/gmp: Delay quotient limb stores in order to allow quotie...

mercurial at gmplib.org mercurial at gmplib.org
Sat Dec 10 19:05:09 CET 2011


details:   /var/hg/gmp/rev/276dc26a6181
changeset: 14544:276dc26a6181
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sat Dec 10 19:04:56 2011 +0100
description:
Delay quotient limb stores in order to allow quotient and dividend to completely overlap.

diffstat:

 mpn/generic/sbpi1_bdiv_q.c  |  10 ++++++----
 mpn/generic/sbpi1_bdiv_qr.c |  10 +++++-----
 2 files changed, 11 insertions(+), 9 deletions(-)

diffs (85 lines):

diff -r 9e8cfe3cac07 -r 276dc26a6181 mpn/generic/sbpi1_bdiv_q.c
--- a/mpn/generic/sbpi1_bdiv_q.c	Thu Dec 08 16:38:41 2011 +0100
+++ b/mpn/generic/sbpi1_bdiv_q.c	Sat Dec 10 19:04:56 2011 +0100
@@ -7,7 +7,7 @@
    IT IS ONLY SAFE TO REACH THEM THROUGH DOCUMENTED INTERFACES.  IN FACT, IT IS
    ALMOST GUARANTEED THAT THEY'LL CHANGE OR DISAPPEAR IN A FUTURE GMP RELEASE.
 
-Copyright 2005, 2006, 2009 Free Software Foundation, Inc.
+Copyright 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -58,14 +58,16 @@
   ASSERT (dn > 0);
   ASSERT (nn >= dn);
   ASSERT ((dp[0] & 1) != 0);
+  /* FIXME: Add ASSERTs for allowable overlapping; i.e., that qp = np is OK,
+     but some over N/Q overlaps will not work.  */
 
   for (i = nn - dn; i > 0; i--)
     {
       q = dinv * np[0];
+      cy = mpn_addmul_1 (np, dp, dn, q);
+      mpn_add_1 (np + dn, np + dn, i, cy);
       qp[0] = ~q;
       qp++;
-      cy = mpn_addmul_1 (np, dp, dn, q);
-      mpn_add_1 (np + dn, np + dn, i, cy);
       ASSERT (np[0] == 0);
       np++;
     }
@@ -73,9 +75,9 @@
   for (i = dn; i > 1; i--)
     {
       q = dinv * np[0];
+      mpn_addmul_1 (np, dp, i, q);
       qp[0] = ~q;
       qp++;
-      mpn_addmul_1 (np, dp, i, q);
       ASSERT (np[0] == 0);
       np++;
     }
diff -r 9e8cfe3cac07 -r 276dc26a6181 mpn/generic/sbpi1_bdiv_qr.c
--- a/mpn/generic/sbpi1_bdiv_qr.c	Thu Dec 08 16:38:41 2011 +0100
+++ b/mpn/generic/sbpi1_bdiv_qr.c	Sat Dec 10 19:04:56 2011 +0100
@@ -7,7 +7,7 @@
    IT IS ONLY SAFE TO REACH THEM THROUGH DOCUMENTED INTERFACES.  IN FACT, IT IS
    ALMOST GUARANTEED THAT THEY'LL CHANGE OR DISAPPEAR IN A FUTURE GMP RELEASE.
 
-Copyright 2006, 2009 Free Software Foundation, Inc.
+Copyright 2006, 2009, 2011 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -53,6 +53,8 @@
   ASSERT (dn > 0);
   ASSERT (nn > dn);
   ASSERT ((dp[0] & 1) != 0);
+  /* FIXME: Add ASSERTs for allowable overlapping; i.e., that qp = np is OK,
+     but some over N/Q overlaps will not work.  */
 
   qn = nn - dn;
 
@@ -67,9 +69,8 @@
 	  mp_limb_t q;
 
 	  q = dinv * np[i];
+	  np[i] = mpn_addmul_1 (np + i, dp, dn, q);
 	  qp[i] = ~q;
-
-	  np[i] = mpn_addmul_1 (np + i, dp, dn, q);
 	}
       rh += mpn_add (np + dn, np + dn, qn, np, dn);
       ql = mpn_add_1 (qp, qp, dn, ql);
@@ -83,9 +84,8 @@
       mp_limb_t q;
 
       q = dinv * np[i];
+      np[i] = mpn_addmul_1 (np + i, dp, dn, q);
       qp[i] = ~q;
-
-      np[i] = mpn_addmul_1 (np + i, dp, dn, q);
     }
 
   rh += mpn_add_n (np + dn, np + dn, np, qn);


More information about the gmp-commit mailing list