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

mercurial at gmplib.org mercurial at gmplib.org
Sun Feb 20 20:30:40 CET 2011


details:   /var/hg/gmp/rev/e02b6120e071
changeset: 13867:e02b6120e071
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Feb 20 20:00:13 2011 +0100
description:
New file.

details:   /var/hg/gmp/rev/99de8405bf26
changeset: 13868:99de8405bf26
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Feb 20 20:01:09 2011 +0100
description:
(mpn_divexact_by7): Relax inclusion condition.

details:   /var/hg/gmp/rev/7cb2e3095d30
changeset: 13869:7cb2e3095d30
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Feb 20 20:04:55 2011 +0100
description:
Rewrite to remove redundant division.

details:   /var/hg/gmp/rev/96409f347970
changeset: 13870:96409f347970
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Feb 20 20:06:46 2011 +0100
description:
Normalise mnemonic usage.

details:   /var/hg/gmp/rev/9923bb7a4c09
changeset: 13871:9923bb7a4c09
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Feb 20 20:09:07 2011 +0100
description:
(mpz_divexact_gcd): Rewrite.

details:   /var/hg/gmp/rev/32090a8bebb1
changeset: 13872:32090a8bebb1
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Feb 20 20:13:18 2011 +0100
description:
*** empty log message ***

diffstat:

 ChangeLog               |   15 ++++++
 gmp-impl.h              |    2 +-
 mpn/x86/atom/lshift.asm |  107 ++++++++++++++++++++++++++++++++++++++++++++++-
 mpn/x86/atom/rshift.asm |   26 +++++-----
 mpq/aors.c              |   12 ++--
 mpz/divegcd.c           |   55 ++++++++++++++++++++++-
 6 files changed, 190 insertions(+), 27 deletions(-)

diffs (truncated from 363 to 300 lines):

diff -r 3c0dbda7f526 -r 32090a8bebb1 ChangeLog
--- a/ChangeLog	Sun Feb 20 15:40:56 2011 +0100
+++ b/ChangeLog	Sun Feb 20 20:13:18 2011 +0100
@@ -1,5 +1,20 @@
 2011-02-20  Torbjorn Granlund  <tege at gmplib.org>
 
+2011-02-20  Marc Glisse  <marc.glisse at inria.fr>
+
+	* mpq/aors.c: Rewrite to remove redundant division.
+
+2011-02-20  Torbjorn Granlund  <tege at gmplib.org>
+
+	* mpn/x86/atom/lshift.asm: New file.
+	* mpn/x86/atom/rshift.asm: Normalise mnemonic usage.
+
+	* gmp-impl.h (mpn_divexact_by7): Relax inclusion condition.
+
+	* mpz/divegcd.c (mpz_divexact_by5): New conditionally enabled function.
+	(mpz_divexact_by3): Wrap inside appropriate conditions.
+	(mpz_divexact_gcd): Rewrite.
+
 	* mpn/x86/bdiv_dbm1c.asm: Save a jump.
 
 2011-02-20 Marco Bodrato <bodrato at mail.dm.unipi.it>
diff -r 3c0dbda7f526 -r 32090a8bebb1 gmp-impl.h
--- a/gmp-impl.h	Sun Feb 20 15:40:56 2011 +0100
+++ b/gmp-impl.h	Sun Feb 20 20:13:18 2011 +0100
@@ -1371,7 +1371,7 @@
   (7 & 3 * mpn_bdiv_dbm1 (dst, src, size, __GMP_CAST (mp_limb_t, GMP_NUMB_MASK / 5)))
 #endif
 
-#if GMP_NUMB_BITS % 6 == 0
+#if GMP_NUMB_BITS % 3 == 0
 #define mpn_divexact_by7(dst,src,size) \
   (7 & 1 * mpn_bdiv_dbm1 (dst, src, size, __GMP_CAST (mp_limb_t, GMP_NUMB_MASK / 7)))
 #endif
diff -r 3c0dbda7f526 -r 32090a8bebb1 mpn/x86/atom/lshift.asm
--- a/mpn/x86/atom/lshift.asm	Sun Feb 20 15:40:56 2011 +0100
+++ b/mpn/x86/atom/lshift.asm	Sun Feb 20 20:13:18 2011 +0100
@@ -1,7 +1,9 @@
 dnl  Intel Atom mpn_lshift -- mpn left shift.
 
 dnl  Copyright 2011 Free Software Foundation, Inc.
-dnl
+
+dnl  Converted from AMD64 by Marco Bodrato.
+
 dnl  This file is part of the GNU MP Library.
 dnl
 dnl  The GNU MP Library is free software; you can redistribute it and/or
@@ -19,5 +21,104 @@
 
 include(`../config.m4')
 
-MULFUNC_PROLOGUE(mpn_lshift)
-include_mpn(`x86/pentium/lshift.asm')
+defframe(PARAM_CNT, 16)
+defframe(PARAM_SIZE,12)
+defframe(PARAM_SRC,  8)
+defframe(PARAM_DST,  4)
+
+dnl  re-use parameter space
+define(SAVE_UP,`PARAM_CNT')
+define(VAR_COUNT,`PARAM_SIZE')
+define(SAVE_EBX,`PARAM_SRC')
+define(SAVE_EBP,`PARAM_DST')
+
+define(`rp',  `%edi')
+define(`up',  `%esi')
+define(`cnt',  `%ecx')
+
+ASM_START()
+	TEXT
+	ALIGN(8)
+deflit(`FRAME',0)
+PROLOGUE(mpn_lshift)
+	mov	PARAM_CNT, cnt
+	mov	PARAM_SIZE, %edx
+	mov	up, SAVE_UP
+	mov	PARAM_SRC, up
+	push	rp			FRAME_pushl()
+	mov	PARAM_DST, rp
+	mov	%ebx, SAVE_EBX
+	lea	-4(up,%edx,4), up
+	lea	-4(rp,%edx,4), rp
+
+	shr	%edx
+	mov	(up), %eax
+	mov	%edx, VAR_COUNT
+	jnc	L(evn)
+
+	mov	%eax, %ebx
+	shl	%cl, %ebx
+	neg	cnt
+	shr	%cl, %eax
+	test	%edx, %edx
+	jnz	L(gt1)
+	mov	%ebx, (rp)
+	jmp	L(quit)
+
+L(gt1):	mov	%ebp, SAVE_EBP
+	push	%eax
+	mov	-4(up), %eax
+	mov	%eax, %ebp
+	shr	%cl, %eax
+	jmp	L(lo1)
+
+L(evn):	mov	%ebp, SAVE_EBP
+	neg	cnt
+	mov	%eax, %ebp
+	mov	-4(up), %edx
+	shr	%cl, %eax
+	mov	%edx, %ebx
+	shr	%cl, %edx
+	neg	cnt
+	decl	VAR_COUNT
+	lea	4(rp), rp
+	lea	-4(up), up
+	jz	L(end)
+	push	%eax			FRAME_pushl()
+
+	ALIGN(8)
+L(top):	shl	%cl, %ebp
+	or	%ebp, %edx
+	shl	%cl, %ebx
+	neg	cnt
+	mov	-4(up), %eax
+	mov	%eax, %ebp
+	mov	%edx, -4(rp)
+	shr	%cl, %eax
+	lea	-8(rp), rp
+L(lo1):	mov	-8(up), %edx
+	or	%ebx, %eax
+	mov	%edx, %ebx
+	shr	%cl, %edx
+	lea	-8(up), up
+	neg	cnt
+	mov	%eax, (rp)
+	decl	VAR_COUNT
+	jg	L(top)
+
+	pop	%eax			FRAME_popl()
+L(end):
+	shl	%cl, %ebp
+	shl	%cl, %ebx
+	or	%ebp, %edx
+	mov	SAVE_EBP, %ebp
+	mov	%edx, -4(rp)
+	mov	%ebx, -8(rp)
+
+L(quit):
+	mov	SAVE_UP, up
+	mov	SAVE_EBX, %ebx
+	pop	rp			FRAME_popl()
+	ret
+EPILOGUE()
+ASM_END()
diff -r 3c0dbda7f526 -r 32090a8bebb1 mpn/x86/atom/rshift.asm
--- a/mpn/x86/atom/rshift.asm	Sun Feb 20 15:40:56 2011 +0100
+++ b/mpn/x86/atom/rshift.asm	Sun Feb 20 20:13:18 2011 +0100
@@ -41,17 +41,17 @@
 	ALIGN(8)
 deflit(`FRAME',0)
 PROLOGUE(mpn_rshift)
-	movl	PARAM_CNT, cnt
-	movl	PARAM_SIZE, %edx
-	movl	up, SAVE_UP
-	movl	PARAM_SRC, up
+	mov	PARAM_CNT, cnt
+	mov	PARAM_SIZE, %edx
+	mov	up, SAVE_UP
+	mov	PARAM_SRC, up
 	push	rp			FRAME_pushl()
-	movl	PARAM_DST, rp
-	movl	%ebx, SAVE_EBX
+	mov	PARAM_DST, rp
+	mov	%ebx, SAVE_EBX
 
 	shr	%edx
 	mov	(up), %eax
-	movl	%edx, VAR_COUNT
+	mov	%edx, VAR_COUNT
 	jnc	L(evn)
 
 	mov	%eax, %ebx
@@ -63,14 +63,14 @@
 	mov	%ebx, (rp)
 	jmp	L(quit)
 
-L(gt1):	movl	%ebp, SAVE_EBP
+L(gt1):	mov	%ebp, SAVE_EBP
 	push	%eax
 	mov	4(up), %eax
 	mov	%eax, %ebp
 	shl	%cl, %eax
 	jmp	L(lo1)
 
-L(evn):	movl	%ebp, SAVE_EBP
+L(evn):	mov	%ebp, SAVE_EBP
 	neg	cnt
 	mov	%eax, %ebp
 	mov	4(up), %edx
@@ -84,7 +84,7 @@
 	jz	L(end)
 	push	%eax			FRAME_pushl()
 
-	ALIGN(16)
+	ALIGN(8)
 L(top):	shr	%cl, %ebp
 	or	%ebp, %edx
 	shr	%cl, %ebx
@@ -109,13 +109,13 @@
 	shr	%cl, %ebp
 	shr	%cl, %ebx
 	or	%ebp, %edx
-	movl	SAVE_EBP, %ebp
+	mov	SAVE_EBP, %ebp
 	mov	%edx, 4(rp)
 	mov	%ebx, 8(rp)
 
 L(quit):
-	movl	SAVE_UP, up
-	movl	SAVE_EBX, %ebx
+	mov	SAVE_UP, up
+	mov	SAVE_EBX, %ebx
 	pop	rp			FRAME_popl()
 	ret
 EPILOGUE()
diff -r 3c0dbda7f526 -r 32090a8bebb1 mpq/aors.c
--- a/mpq/aors.c	Sun Feb 20 15:40:56 2011 +0100
+++ b/mpq/aors.c	Sun Feb 20 20:13:18 2011 +0100
@@ -52,16 +52,16 @@
     {
       mpz_t t;
 
-      mpz_divexact_gcd (tmp1, &(op2->_mp_den), gcd);
-      mpz_mul (tmp1, &(op1->_mp_num), tmp1);
+      MPZ_TMP_INIT (t, MAX (op1_num_size + op2_den_size,
+	     op2_num_size + op1_den_size) + 2 - gcd->_mp_size);
 
+      mpz_divexact_gcd (t, &(op2->_mp_den), gcd);
       mpz_divexact_gcd (tmp2, &(op1->_mp_den), gcd);
-      mpz_mul (tmp2, &(op2->_mp_num), tmp2);
 
-      MPZ_TMP_INIT (t, MAX (ABS (tmp1->_mp_size), ABS (tmp2->_mp_size)) + 1);
+      mpz_mul (tmp1, &(op1->_mp_num), t);
+      mpz_mul (t, &(op2->_mp_num), tmp2);
 
-      (*fun) (t, tmp1, tmp2);
-      mpz_divexact_gcd (tmp2, &(op1->_mp_den), gcd);
+      (*fun) (t, tmp1, t);
 
       mpz_gcd (gcd, t, gcd);
       if (MPZ_EQUAL_1_P (gcd))
diff -r 3c0dbda7f526 -r 32090a8bebb1 mpz/divegcd.c
--- a/mpz/divegcd.c	Sun Feb 20 15:40:56 2011 +0100
+++ b/mpz/divegcd.c	Sun Feb 20 20:13:18 2011 +0100
@@ -3,7 +3,7 @@
    THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE AND ARE ALMOST CERTAIN TO
    BE SUBJECT TO INCOMPATIBLE CHANGES IN FUTURE GNU MP RELEASES.
 
-Copyright 2000, 2005 Free Software Foundation, Inc.
+Copyright 2000, 2005, 2011 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -44,6 +44,7 @@
    implementation.  */
 
 
+#if GMP_NUMB_BITS % 2 == 0
 static void
 mpz_divexact_by3 (mpz_ptr q, mpz_srcptr a)
 {
@@ -61,12 +62,38 @@
       MPZ_REALLOC (q, abs_size);
 
       qp = PTR(q);
-      mpn_divexact_by3 (qp, PTR(a), abs_size);
+      mpn_bdiv_dbm1 (qp, PTR(a), abs_size, GMP_NUMB_MASK / 3);
 
       abs_size -= (qp[abs_size-1] == 0);
       SIZ(q) = (size>0 ? abs_size : -abs_size);
     }
 }
+#endif
+#if GMP_NUMB_BITS % 4 == 0
+static void
+mpz_divexact_by5 (mpz_ptr q, mpz_srcptr a)
+{
+  mp_size_t  size = SIZ(a);
+  if (size == 0)
+    {
+      SIZ(q) = 0;
+      return;
+    }
+  else
+    {
+      mp_size_t  abs_size = ABS(size);
+      mp_ptr     qp;


More information about the gmp-commit mailing list