[Gmp-commit] /var/hg/gmp: 2 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Mon Sep 9 22:06:08 UTC 2019


details:   /var/hg/gmp/rev/8f48be003407
changeset: 17888:8f48be003407
user:      Torbjorn Granlund <tg at gmplib.org>
date:      Mon Sep 09 23:47:38 2019 +0200
description:
Call mpn_mul_basecase early when in range. Never call mpn_sqr.

details:   /var/hg/gmp/rev/ed6ddbb7a15b
changeset: 17889:ed6ddbb7a15b
user:      Torbjorn Granlund <tg at gmplib.org>
date:      Tue Sep 10 00:00:35 2019 +0200
description:
Use canonical branch syntax.

diffstat:

 mpn/arm64/gcd_22.asm |   2 +-
 mpn/generic/mul.c    |  21 +++++++++++----------
 2 files changed, 12 insertions(+), 11 deletions(-)

diffs (60 lines):

diff -r 5e446d7c533c -r ed6ddbb7a15b mpn/arm64/gcd_22.asm
--- a/mpn/arm64/gcd_22.asm	Mon Sep 09 23:38:45 2019 +0200
+++ b/mpn/arm64/gcd_22.asm	Tue Sep 10 00:00:35 2019 +0200
@@ -100,7 +100,7 @@
 	C 1. If v1 - u1 = 0, then gcd is u = v.
 	C 2. Else compute gcd_21({v1,v0}, |u1-v1|)
 	subs	t0, u1, v1
-	beq	L(end)
+	b.eq	L(end)
 	mov	t1, #0
 	rbit	cnt, t0			C 1
 	cneg	t0, t0, cc		C 2
diff -r 5e446d7c533c -r ed6ddbb7a15b mpn/generic/mul.c
--- a/mpn/generic/mul.c	Mon Sep 09 23:38:45 2019 +0200
+++ b/mpn/generic/mul.c	Tue Sep 10 00:00:35 2019 +0200
@@ -3,7 +3,7 @@
    Contributed to the GNU project by Torbjorn Granlund.
 
 Copyright 1991, 1993, 1994, 1996, 1997, 1999-2003, 2005-2007, 2009, 2010, 2012,
-2014 Free Software Foundation, Inc.
+2014, 2019 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -108,12 +108,8 @@
 
   * That problem is even more prevalent for toomX3.  We therefore use special
     THRESHOLD variables there.
-
-  * Is our ITCH allocation correct?
 */
 
-#define ITCH (16*vn + 100)
-
 mp_limb_t
 mpn_mul (mp_ptr prodp,
 	 mp_srcptr up, mp_size_t un,
@@ -124,12 +120,17 @@
   ASSERT (! MPN_OVERLAP_P (prodp, un+vn, up, un));
   ASSERT (! MPN_OVERLAP_P (prodp, un+vn, vp, vn));
 
-  if (un == vn)
+  if (BELOW_THRESHOLD (un, MUL_TOOM22_THRESHOLD))
     {
-      if (up == vp)
-	mpn_sqr (prodp, up, un);
-      else
-	mpn_mul_n (prodp, up, vp, un);
+      /* When un (and thus vn) is below the toom22 range, do mul_basecase.
+	 Test un and not vn here not to thwart the un >> vn code below.
+	 This special case is not necessary, but cuts the overhead for the
+	 smallest operands. */
+      mpn_mul_basecase (prodp, up, un, vp, vn);
+    }
+  else if (un == vn)
+    {
+      mpn_mul_n (prodp, up, vp, un);
     }
   else if (vn < MUL_TOOM22_THRESHOLD)
     { /* plain schoolbook multiplication */


More information about the gmp-commit mailing list