[Gmp-commit] /var/hg/gmp-5.0: Make toom63 handle slightly more unbalanced ope...

mercurial at gmplib.org mercurial at gmplib.org
Thu Feb 2 20:19:50 CET 2012


details:   /var/hg/gmp-5.0/rev/20645f1adb64
changeset: 13535:20645f1adb64
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Thu Feb 02 20:19:43 2012 +0100
description:
Make toom63 handle slightly more unbalanced operands.

diffstat:

 ChangeLog                           |  3 +++
 mpn/generic/toom63_mul.c            |  6 +++---
 mpn/generic/toom_interpolate_8pts.c |  5 ++++-
 3 files changed, 10 insertions(+), 4 deletions(-)

diffs (48 lines):

diff -r a466f9fab370 -r 20645f1adb64 ChangeLog
--- a/ChangeLog	Thu Feb 02 14:34:34 2012 +0100
+++ b/ChangeLog	Thu Feb 02 20:19:43 2012 +0100
@@ -1,5 +1,8 @@
 2012-02-02  Torbjorn Granlund  <tege at gmplib.org>
 
+	* mpn/generic/toom63_mul.c: Allow s+t==n by adjusting an ASSERT.
+	* mpn/generic/toom_interpolate_8pts.c: Perform final incr iff s+t!=n.
+
 	* tests/mpn/t-toom6h.c (MIN_BN): Make more consistent with ASSERT in
 	tested function.
 
diff -r a466f9fab370 -r 20645f1adb64 mpn/generic/toom63_mul.c
--- a/mpn/generic/toom63_mul.c	Thu Feb 02 14:34:34 2012 +0100
+++ b/mpn/generic/toom63_mul.c	Thu Feb 02 20:19:43 2012 +0100
@@ -6,7 +6,7 @@
    SAFE TO REACH IT THROUGH DOCUMENTED INTERFACES.  IN FACT, IT IS ALMOST
    GUARANTEED THAT IT WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE.
 
-Copyright 2009 Free Software Foundation, Inc.
+Copyright 2009, 2012 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -105,8 +105,8 @@
 
   ASSERT (0 < s && s <= n);
   ASSERT (0 < t && t <= n);
-  /* WARNING! it assumes s+t>n */
-  ASSERT ( s + t > n );
+  /* WARNING! it assumes s+t>=n */
+  ASSERT ( s + t >= n );
   ASSERT ( s + t > 4);
   /* WARNING! it assumes n>1 */
   ASSERT ( n > 2);
diff -r a466f9fab370 -r 20645f1adb64 mpn/generic/toom_interpolate_8pts.c
--- a/mpn/generic/toom_interpolate_8pts.c	Thu Feb 02 14:34:34 2012 +0100
+++ b/mpn/generic/toom_interpolate_8pts.c	Thu Feb 02 20:19:43 2012 +0100
@@ -188,5 +188,8 @@
   cy = mpn_add_1 (pp + 6*n, r3 + n, n, pp[6*n]);
   MPN_INCR_U (r3 + 2*n, n + 1, cy);
   cy = r3[3*n] + mpn_add_n (pp + 7*n, pp + 7*n, r3 + 2*n, n);
-  MPN_INCR_U (pp + 8*n, spt - n, cy);
+  if (LIKELY(spt != n))
+    MPN_INCR_U (pp + 8*n, spt - n, cy);
+  else
+    ASSERT (cy == 0);
 }


More information about the gmp-commit mailing list