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

mercurial at gmplib.org mercurial at gmplib.org
Thu Jun 11 20:39:24 UTC 2015


details:   /var/hg/gmp/rev/791d4ef59986
changeset: 16705:791d4ef59986
user:      Torbjorn Granlund <torbjorng at google.com>
date:      Thu Jun 11 22:36:42 2015 +0200
description:
Amend last change: align for PIC and non-PIC.

details:   /var/hg/gmp/rev/52124a7fe175
changeset: 16706:52124a7fe175
user:      Torbjorn Granlund <torbjorng at google.com>
date:      Thu Jun 11 22:37:07 2015 +0200
description:
Align stack for calls.

details:   /var/hg/gmp/rev/7ef7eae70ab5
changeset: 16707:7ef7eae70ab5
user:      Torbjorn Granlund <torbjorng at google.com>
date:      Thu Jun 11 22:37:42 2015 +0200
description:
Whitespace cleanup.

details:   /var/hg/gmp/rev/dd01fd5eaae6
changeset: 16708:dd01fd5eaae6
user:      Torbjorn Granlund <torbjorng at google.com>
date:      Thu Jun 11 22:38:09 2015 +0200
description:
Whitespace cleanup.

details:   /var/hg/gmp/rev/ee40d9adce70
changeset: 16709:ee40d9adce70
user:      Torbjorn Granlund <torbjorng at google.com>
date:      Thu Jun 11 22:38:27 2015 +0200
description:
ChangeLog

details:   /var/hg/gmp/rev/cbb469061603
changeset: 16710:cbb469061603
user:      Torbjorn Granlund <torbjorng at google.com>
date:      Thu Jun 11 22:39:22 2015 +0200
description:
Trivial merge.

diffstat:

 ChangeLog             |   7 +++++++
 mpn/generic/rootrem.c |   2 +-
 mpn/generic/sqrtrem.c |  40 ++++++++++++++++++++++++++--------------
 mpn/x86/k7/gcd_1.asm  |   9 ++++++---
 mpn/x86/p6/gcd_1.asm  |   8 +++++---
 5 files changed, 45 insertions(+), 21 deletions(-)

diffs (186 lines):

diff -r a9aebe3c9bfb -r cbb469061603 ChangeLog
--- a/ChangeLog	Thu Jun 11 16:01:42 2015 +0200
+++ b/ChangeLog	Thu Jun 11 22:39:22 2015 +0200
@@ -1,5 +1,12 @@
+2015-06-11  Torbjörn Granlund  <torbjorng at google.com>
+
+	* mpn/x86/k7/gcd_1.asm: Align stack for calls.
+	* mpn/x86/p6/gcd_1.asm: Amend last change: align for PIC and non-PIC.
+
 2015-06-10 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
+	* mpn/generic/sqrtrem.c: Use sqrtrem1 for single limb operands.
+
 	* tests/mpz/t-root.c: Check also mpz_root retunr value.
 	* mpn/generic/rootrem.c: Shorten first and last loop.
 
diff -r a9aebe3c9bfb -r cbb469061603 mpn/generic/rootrem.c
--- a/mpn/generic/rootrem.c	Thu Jun 11 16:01:42 2015 +0200
+++ b/mpn/generic/rootrem.c	Thu Jun 11 22:39:22 2015 +0200
@@ -214,7 +214,7 @@
 					 of R/(k*S^(k-1)), and S^k */
 		     wp, un + EXTRA); /* will contain S^(k-1), k*S^(k-1),
 					 and temporary for mpn_pow_1 */
-		     
+
   if (remp == NULL)
     rp = scratch;     /* will contain the remainder */
   else
diff -r a9aebe3c9bfb -r cbb469061603 mpn/generic/sqrtrem.c
--- a/mpn/generic/sqrtrem.c	Thu Jun 11 16:01:42 2015 +0200
+++ b/mpn/generic/sqrtrem.c	Thu Jun 11 22:39:22 2015 +0200
@@ -8,8 +8,8 @@
    INTERFACES.  IN FACT, IT IS ALMOST GUARANTEED THAT THEY WILL CHANGE OR
    DISAPPEAR IN A FUTURE GMP RELEASE.
 
-Copyright 1999-2002, 2004, 2005, 2008, 2010, 2012 Free Software Foundation,
-Inc.
+Copyright 1999-2002, 2004, 2005, 2008, 2010, 2012, 2015 Free Software
+Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -132,7 +132,7 @@
 
 #if GMP_NUMB_BITS > 32
   a1 = a0 >> (GMP_LIMB_BITS - 1 - 32);
-  t = (mp_limb_signed_t) (CNST_LIMB(0x2000000000000) - 0x30000  - a1 * x0 * x0) >> 16;
+  t = (mp_limb_signed_t) (CNST_LIMB(0x2000000000000) - 0x30000 - a1 * x0 * x0) >> 16;
   x0 = (x0 << 16) + ((mp_limb_signed_t) (x0 * t) >> (16+2));
 
   /* x0 is now a 16 bits approximation of 1/sqrt(a0) */
@@ -195,7 +195,7 @@
   /* now we have (initial rp0)<<Prec + np0>>Prec = (qhl<<Prec + q) * (2sp0) + u */
   sp0 = ((sp0 + qhl) << Prec) + q;
   cc = u >> Prec;
-  rp0 = ((u << Prec) & GMP_NUMB_MASK) + (np0 & (((mp_limb_t) 1 << Prec) - 1));
+  rp0 = ((u << Prec) & GMP_NUMB_MASK) + (np0 & ((CNST_LIMB (1) << Prec) - 1));
   /* subtract q * q or qhl*2^(2*Prec) from rp */
   q2 = q * q;
   cc -= (rp0 < q2) + qhl;
@@ -242,7 +242,7 @@
       h = n - l;
       q = mpn_dc_sqrtrem (sp + l, np + 2 * l, h);
       if (q != 0)
-	mpn_sub_n (np + 2 * l, np + 2 * l, sp + l, h);
+	ASSERT_CARRY (mpn_sub_n (np + 2 * l, np + 2 * l, sp + l, h));
       q += mpn_divrem (sp, 0, np + l, n, sp + l, h);
       c = sp[0] & 1;
       mpn_rshift (sp, sp, l, 1);
@@ -292,14 +292,26 @@
   ASSERT (! MPN_OVERLAP_P (sp, (nn + 1) / 2, np, nn));
 
   high = np[nn - 1];
-  if (nn == 1 && (high & GMP_NUMB_HIGHBIT))
-    {
-      mp_limb_t r;
-      sp[0] = mpn_sqrtrem1 (&r, high);
-      if (rp != NULL)
-	rp[0] = r;
-      return r != 0;
-    }
+  if (nn == 1)
+    if (high & (GMP_NUMB_HIGHBIT | (GMP_NUMB_HIGHBIT >> 1)))
+      {
+	sp[0] = mpn_sqrtrem1 (&rl, high);
+	if (rp != NULL)
+	  rp[0] = rl;
+	return rl != 0;
+      }
+    else
+      {
+	count_leading_zeros (c, high);
+	c -= GMP_NAIL_BITS;
+
+	c = c / 2; /* we have to shift left by 2c bits to normalize {np, nn} */
+	cc = mpn_sqrtrem1 (&rl, high << (2*c)) >> c;
+	sp[0] = cc;
+	if (rp != NULL)
+	  rp[0] = rl = high - cc*cc;
+	return rl != 0;
+      }
   count_leading_zeros (c, high);
   c -= GMP_NAIL_BITS;
 
@@ -319,7 +331,7 @@
       /* We have 2^(2k)*N = S^2 + R where k = c + (2tn-nn)*GMP_NUMB_BITS/2,
 	 thus 2^(2k)*N = (S-s0)^2 + 2*S*s0 - s0^2 + R where s0=S mod 2^k */
       c += (nn % 2) * GMP_NUMB_BITS / 2;		/* c now represents k */
-      s0[0] = sp[0] & (((mp_limb_t) 1 << c) - 1);	/* S mod 2^k */
+      s0[0] = sp[0] & ((CNST_LIMB (1) << c) - 1);	/* S mod 2^k */
       rl += mpn_addmul_1 (tp, sp, tn, 2 * s0[0]);	/* R = R + 2*s0*S */
       cc = mpn_submul_1 (tp, s0, 1, s0[0]);
       rl -= (tn > 1) ? mpn_sub_1 (tp + 1, tp + 1, tn - 1, cc) : cc;
diff -r a9aebe3c9bfb -r cbb469061603 mpn/x86/k7/gcd_1.asm
--- a/mpn/x86/k7/gcd_1.asm	Thu Jun 11 16:01:42 2015 +0200
+++ b/mpn/x86/k7/gcd_1.asm	Thu Jun 11 22:39:22 2015 +0200
@@ -3,7 +3,7 @@
 dnl  Contributed to the GNU project by by Kevin Ryde.  Rehacked by Torbjorn
 dnl  Granlund.
 
-dnl  Copyright 2000-2002, 2005, 2009, 2011, 2012, 2014 Free Software
+dnl  Copyright 2000-2002, 2005, 2009, 2011, 2012, 2014, 2015 Free Software
 dnl  Foundation, Inc.
 
 dnl  This file is part of the GNU MP Library.
@@ -129,6 +129,7 @@
 L(reduce_nby1):
 ifdef(`PIC_WITH_EBX',`dnl
 	push	%ebx
+	add	$-4, %esp
 	call	L(movl_eip_ebx)
 	add	$_GLOBAL_OFFSET_TABLE_, %ebx
 ')
@@ -143,9 +144,11 @@
 	CALL(	mpn_modexact_1_odd)
 
 L(called):
+ifdef(`PIC_WITH_EBX',`dnl
+	add	$16, %esp	C deallocate params
+	pop	%ebx
+',`
 	add	$12, %esp		C deallocate params
-ifdef(`PIC_WITH_EBX',`dnl
-	pop	%ebx
 ')
 L(reduced):
 	pop	%edx
diff -r a9aebe3c9bfb -r cbb469061603 mpn/x86/p6/gcd_1.asm
--- a/mpn/x86/p6/gcd_1.asm	Thu Jun 11 16:01:42 2015 +0200
+++ b/mpn/x86/p6/gcd_1.asm	Thu Jun 11 22:39:22 2015 +0200
@@ -97,10 +97,10 @@
 	jl	L(bmod)
 ifdef(`PIC_WITH_EBX',`dnl
 	push	%ebx
+	add	$-4, %esp
 	call	L(movl_eip_to_ebx)
 	add	$_GLOBAL_OFFSET_TABLE_, %ebx
 ')
-	add	$-4, %esp
 	push	v0		C param 3
 	push	n		C param 2
 	push	up		C param 1
@@ -110,19 +110,21 @@
 L(bmod):
 ifdef(`PIC_WITH_EBX',`dnl
 	push	%ebx
+	add	$-4, %esp
 	call	L(movl_eip_to_ebx)
 	add	$_GLOBAL_OFFSET_TABLE_, %ebx
 ')
-	add	$-4, %esp
 	push	v0		C param 3
 	push	n		C param 2
 	push	up		C param 1
 	CALL(	mpn_modexact_1_odd)
 
 L(called):
+ifdef(`PIC_WITH_EBX',`dnl
 	add	$16, %esp	C deallocate params
-ifdef(`PIC_WITH_EBX',`dnl
 	pop	%ebx
+',`
+	add	$12, %esp	C deallocate params
 ')
 L(reduced):
 	pop	%edx


More information about the gmp-commit mailing list