glibc/sysdeps/powerpc/powerpc64/power7
Alan Modra 466b039332 PowerPC LE memchr and memrchr
http://sourceware.org/ml/libc-alpha/2013-08/msg00105.html

Like strnlen, memchr and memrchr had a number of defects fixed by this
patch as well as adding little-endian support.  The first one I
noticed was that the entry to the main loop needlessly checked for
"are we done yet?" when we know the size is large enough that we can't
be done.  The second defect I noticed was that the main loop count was
wrong, which in turn meant that the small loop needed to handle an
extra word.  Thirdly, there is nothing to say that the string can't
wrap around zero, except of course that we'd normally hit a segfault
on trying to read from address zero.  Fixing that simplified a number
of places:

-	/* Are we done already?  */
-	addi    r9,r8,8
-	cmpld	r9,r7
-	bge	L(null)

becomes

+	cmpld	r8,r7
+	beqlr

However, the exit gets an extra test because I test for being on the
last word then if so whether the byte offset is less than the end.
Overall, the change is a win.

Lastly, memrchr used the wrong cache hint.

	* sysdeps/powerpc/powerpc64/power7/memchr.S: Replace rlwimi with
	insrdi.  Make better use of reg selection to speed exit slightly.
	Schedule entry path a little better.  Remove useless "are we done"
	checks on entry to main loop.  Handle wrapping around zero address.
	Correct main loop count.  Handle single left-over word from main
	loop inline rather than by using loop_small.  Remove extra word
	case in loop_small caused by wrong loop count.  Add little-endian
	support.
	* sysdeps/powerpc/powerpc32/power7/memchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memrchr.S: Likewise.  Use proper
	cache hint.
	* sysdeps/powerpc/powerpc32/power7/memrchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/rawmemchr.S: Add little-endian
	support.  Avoid rlwimi.
	* sysdeps/powerpc/powerpc32/power7/rawmemchr.S: Likewise.
2013-10-04 10:41:46 +09:30
..
fpu PowerPC floating point little-endian [12 of 15] 2013-10-04 10:35:43 +09:30
Implies powerpc: Re-work the Implies structure 2010-06-30 09:57:38 -07:00
Makefile Optimized strcasecmp for Power7 2011-12-17 20:32:59 -05:00
memchr.S PowerPC LE memchr and memrchr 2013-10-04 10:41:46 +09:30
memcmp.S PowerPC LE memcmp 2013-10-04 10:40:56 +09:30
memcpy.S PowerPC LE memcpy 2013-10-04 10:41:24 +09:30
mempcpy.S PowerPC LE memcpy 2013-10-04 10:41:24 +09:30
memrchr.S PowerPC LE memchr and memrchr 2013-10-04 10:41:46 +09:30
memset.S PowerPC LE memset 2013-10-04 10:41:35 +09:30
rawmemchr.S PowerPC LE memchr and memrchr 2013-10-04 10:41:46 +09:30
strcasecmp_l.S Optimized strcasecmp for Power7 2011-12-17 20:32:59 -05:00
strcasecmp.S Remove powerpc64 bounded-pointers code. 2013-03-06 00:10:21 +00:00
strchr.S PowerPC LE strchr 2013-10-04 10:40:22 +09:30
strchrnul.S PowerPC LE strchr 2013-10-04 10:40:22 +09:30
strlen.S PowerPC LE strlen 2013-10-04 10:39:32 +09:30
strncmp.S PowerPC LE strcmp and strncmp 2013-10-04 10:39:52 +09:30
strnlen.S PowerPC LE strnlen 2013-10-04 10:39:42 +09:30