[Gmp-commit] /var/hg/gmp: Use mov rather than push and pop. Earlier load of d...

mercurial at gmplib.org mercurial at gmplib.org
Tue Mar 29 11:47:17 CEST 2011


details:   /var/hg/gmp/rev/d3c3f6917806
changeset: 14107:d3c3f6917806
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Tue Mar 29 11:43:43 2011 +0200
description:
Use mov rather than push and pop. Earlier load of divisor from stack.

diffstat:

 ChangeLog                  |   5 +++++
 mpn/x86/k7/invert_limb.asm |  24 ++++++++++--------------
 2 files changed, 15 insertions(+), 14 deletions(-)

diffs (66 lines):

diff -r b8313129fdab -r d3c3f6917806 ChangeLog
--- a/ChangeLog	Mon Mar 28 14:26:11 2011 +0200
+++ b/ChangeLog	Tue Mar 29 11:43:43 2011 +0200
@@ -1,3 +1,8 @@
+2011-03-29  Niels Möller  <nisse at lysator.liu.se>
+
+	* mpn/x86/k7/invert_limb.asm: Use mov rather than push and pop.
+	 Earlier load of divisor from stack.
+
 2011-03-28  Torbjorn Granlund  <tege at gmplib.org>
 
 	* mpn/x86/k7/invert_limb.asm: Protect movzwl register parameters from
diff -r b8313129fdab -r d3c3f6917806 mpn/x86/k7/invert_limb.asm
--- a/mpn/x86/k7/invert_limb.asm	Mon Mar 28 14:26:11 2011 +0200
+++ b/mpn/x86/k7/invert_limb.asm	Tue Mar 29 11:43:43 2011 +0200
@@ -32,13 +32,12 @@
 C P4 model 3  (Prescott)	 ?
 C P4 model 4  (Nocona)		 ?
 C AMD K6			 ?
-C AMD K7			46		53
+C AMD K7			41		53
 C AMD K8			 ?
 
 C TODO
 C  * These c/l numbers are for a non-PIC build.  Consider falling back to using
 C    the 'div' instruction for PIC builds.
-C  * Avoid push/pop on k7.
 C  * Perhaps use this file--or at least the algorithm--for more machines than k7.
 
 C Register usage:
@@ -60,16 +59,13 @@
 	ALIGN(16)
 PROLOGUE(mpn_invert_limb)
 deflit(`FRAME', 0)
-	C Adding the unnecessary push of %ebp and the corresponding pop seems
-	C to *reduce* running time from 46 to 43 cycles on K7.  Don't know if
-	C this is a benchmark artefact or some alignment issue.
+	mov	PARAM_DIVISOR, %eax
+	C Avoid push/pop on k7.	
+	subl	$8, %esp	FRAME_subl_esp(8)
+	mov	%ebx, (%esp)
+	mov	%edi, 4(%esp)
 
-	push	%ebx	FRAME_pushl()
-	C push	%ebp	FRAME_pushl()
-	push	%edi	FRAME_pushl()
-
-	mov	PARAM_DIVISOR, %edi
-	mov	%edi, %eax
+	mov	%eax, %edi
 	shr	$22, %eax
 ifdef(`PIC',`
 	LEA(	approx_tab, %ebx)
@@ -110,9 +106,9 @@
 	adc	%edi, %edx
 	sub	%edx, %eax				C %eax = v3
 
-	pop	%edi
-	C pop	%ebp
-	pop	%ebx
+	mov	(%esp), %ebx
+	mov	4(%esp), %edi
+	addl	$8, %esp
 
 	ret
 


More information about the gmp-commit mailing list