This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: Minor improvement to i386/i686/strcmp.S




This patch is for a minor performance improvement to the strcmp
implementation used for i686.  The original implementation contains
an unconditional jump to a return instruction.  The patch below
changes this to instead return directly, saving the cost of the
unconditional jump at the expense of duplicating the function
epilogue [as would be performed by GCC].

I also take the opportunity to fix a typo in the comment describing
i386/i586/strlen.S; "length og NUL terminated string" should read
"length of NUL terminated string".


Tested by "make" and "make check" on i686-pc-linux-gnu without any
problems.  Is this patch OK?



2002-01-16  Roger Sayle <roger@eyesopen.com>
	* sysdeps/i386/i686/strcmp.S: Avoid unconditional jump to a ret.
	* sysdeps/i386/i586/strlen.S: Fix typo in comment.


diff -c3pr libc/sysdeps/i386/i586/strlen.S patch2/sysdeps/i386/i586/strlen.S
*** libc/sysdeps/i386/i586/strlen.S	Thu Jul  5 22:55:53 2001
--- patch2/sysdeps/i386/i586/strlen.S	Sun Jan 13 14:38:58 2002
***************
*** 1,6 ****
! /* strlen -- Compute length og NUL terminated string.
     Highly optimized version for ix86, x>=5.
!    Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
     Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.

--- 1,7 ----
! /* strlen -- Compute length of NUL terminated string.
     Highly optimized version for ix86, x>=5.
!    Copyright (C) 1995, 1996, 1997, 2000, 2002
!    Free Software Foundation, Inc.
     This file is part of the GNU C Library.
     Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.

diff -c3pr libc/sysdeps/i386/i686/strcmp.S patch2/sysdeps/i386/i686/strcmp.S
*** libc/sysdeps/i386/i686/strcmp.S	Thu Jul  5 22:55:53 2001
--- patch2/sysdeps/i386/i686/strcmp.S	Sun Jan 13 14:39:43 2002
***************
*** 1,5 ****
  /* Highly optimized version for ix86, x>=6.
!    Copyright (C) 1999, 2000 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
     Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.

--- 1,5 ----
  /* Highly optimized version for ix86, x>=6.
!    Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
     Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.

*************** L(oop):	movb	(%ecx), %al
*** 49,55 ****
  	   the end of the NUL terminators.  */
  	CHECK_BOUNDS_HIGH (%ecx, STR1(%esp), jbe)
  	CHECK_BOUNDS_HIGH (%edx, STR2(%esp), jbe)
! 	jmp	L(out)

  #ifndef __BOUNDED_POINTERS__
  L(neq):	movl	$1, %eax
--- 49,56 ----
  	   the end of the NUL terminators.  */
  	CHECK_BOUNDS_HIGH (%ecx, STR1(%esp), jbe)
  	CHECK_BOUNDS_HIGH (%edx, STR2(%esp), jbe)
! 	LEAVE
! 	ret

  #ifndef __BOUNDED_POINTERS__
  L(neq):	movl	$1, %eax
*************** L(chk):	CHECK_BOUNDS_HIGH (%ecx, STR1(%e
*** 65,70 ****
  	CHECK_BOUNDS_HIGH (%edx, STR2(%esp), jb)
  #endif

! L(out):	LEAVE
  	ret
  END (BP_SYM (strcmp))
--- 66,71 ----
  	CHECK_BOUNDS_HIGH (%edx, STR2(%esp), jb)
  #endif

! 	LEAVE
  	ret
  END (BP_SYM (strcmp))


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-438-3470


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]