[Gmp-commit] /var/hg/gmp: Minor optimization to x86_64 mpn_mod_1_1p_cps

mercurial at gmplib.org mercurial at gmplib.org
Tue Mar 1 22:24:01 CET 2011


details:   /var/hg/gmp/rev/27c645229583
changeset: 13965:27c645229583
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Tue Mar 01 22:23:50 2011 +0100
description:
Minor optimization to x86_64 mpn_mod_1_1p_cps

diffstat:

 ChangeLog              |  5 ++++-
 mpn/x86_64/mod_1_1.asm |  8 ++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diffs (48 lines):

diff -r 7c4473db3190 -r 27c645229583 ChangeLog
--- a/ChangeLog	Tue Mar 01 22:19:44 2011 +0100
+++ b/ChangeLog	Tue Mar 01 22:23:50 2011 +0100
@@ -1,7 +1,10 @@
 2011-03-01  Niels Möller  <nisse at lysator.liu.se>
 
+	* mpn/x86_64/mod_1_1.asm (mpn_mod_1_1p_cps): Eliminated a neg and
+	two mov instructions.
+
 	* mpn/x86/k7/mod_1_1.asm (mpn_mod_1_1p_cps): Simplified
-	computation, analogous to x86_64//mod_1_1.asm.
+	computation, analogous to recent x86_64/mod_1_1.asm changes.
 	(mpn_mod_1_1p): Corresponding changes. Don't shift b.
 
 2011-03-01  Torbjorn Granlund  <tege at gmplib.org>
diff -r 7c4473db3190 -r 27c645229583 mpn/x86_64/mod_1_1.asm
--- a/mpn/x86_64/mod_1_1.asm	Tue Mar 01 22:19:44 2011 +0100
+++ b/mpn/x86_64/mod_1_1.asm	Tue Mar 01 22:23:50 2011 +0100
@@ -181,25 +181,25 @@
 	sal	R8(%rcx), %r12
 	mov	%r12, %rdi
 	CALL(	mpn_invert_limb)
+	neg	%r12
 	mov	%r12, %r8
 	mov	%rax, (%rbx)		C store bi
 	mov	%rbp, 8(%rbx)		C store cnt
 	imul	%rax, %r12
-	neg	%r12
 	mov	%r12, 24(%rbx)		C store B2modb
 	mov	R32(%rbp), R32(%rcx)
 	test	R32(%rcx), R32(%rcx)
 	jz	L(z)
-	neg	%r8
 
 	mov	$1, R32(%rdx)
 ifdef(`SHLD_SLOW',`
+	C Destroys %rax, unlike shld. Otherwise, we could do B1modb
+	C before B2modb, and get rid of the move %r12, %r8 above.
+
 	shl	R8(%rcx), %rdx
 	neg	R32(%rcx)
-	mov	%rax, %rbp
 	shr	R8(%rcx), %rax
 	or	%rax, %rdx
-	mov	%rbp, %rax
 	neg	R32(%rcx)
 ',`
 	shld	R8(%rcx), %rax, %rdx


More information about the gmp-commit mailing list