2009-07-27  Aurelien Jarno  <aurelien@aurel32.net>

	* sysdeps/alpha/memchr.S: Use prefetch load.
	* sysdeps/alpha/alphaev6/memchr.S: Likewise.

diff -durN glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/alphaev6/memchr.S glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/alphaev6/memchr.S
--- glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/alphaev6/memchr.S	2009-05-16 10:36:20.000000000 +0200
+++ glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/alphaev6/memchr.S	2009-11-13 00:51:15.000000000 +0100
@@ -127,7 +127,7 @@
         cmpbge  $31, $1, $2	# E :
         bne     $2, $found_it	# U :
 	# At least one byte left to process.
-	ldq	$1, 8($0)	# L :
+	ldq	$31, 8($0)	# L :
 	subq	$5, 1, $18	# E : U L U L
 
 	addq	$0, 8, $0	# E :
@@ -143,38 +143,38 @@
 	and	$4, 8, $4	# E : odd number of quads?
 	bne	$4, $odd_quad_count # U :
 	# At least three quads remain to be accessed
-	mov	$1, $4		# E : L U L U : move prefetched value to correct reg
+	nop			# E : L U L U : move prefetched value to correct reg
 
 	.align	4
 $unrolled_loop:
-	ldq	$1, 8($0)	# L : prefetch $1
-	xor	$17, $4, $2	# E :
-	cmpbge	$31, $2, $2	# E :
-	bne	$2, $found_it	# U : U L U L
+	ldq	$1, 0($0)	# L : load quad
+	xor	$17, $1, $2	# E :
+	ldq	$31, 8($0)	# L : prefetch next quad
+	cmpbge	$31, $2, $2	# E : U L U L
 
+	bne	$2, $found_it	# U :
 	addq	$0, 8, $0	# E :
 	nop			# E :
 	nop			# E :
-	nop			# E :
 
 $odd_quad_count:
+	ldq	$1, 0($0)	# L : load quad
 	xor	$17, $1, $2	# E :
-	ldq	$4, 8($0)	# L : prefetch $4
+	ldq	$31, 8($0)	# L : prefetch $4
 	cmpbge	$31, $2, $2	# E :
-	addq	$0, 8, $6	# E :
 
+	addq	$0, 8, $6	# E :
 	bne	$2, $found_it	# U :
 	cmpult	$6, $18, $6	# E :
 	addq	$0, 8, $0	# E :
-	nop			# E :
 
 	bne	$6, $unrolled_loop # U :
-	mov	$4, $1		# E : move prefetched value into $1
 	nop			# E :
 	nop			# E :
-
-$final:	subq	$5, $0, $18	# E : $18 <- number of bytes left to do
 	nop			# E :
+
+$final:	ldq	$1, 0($0)	# L : load last quad
+	subq	$5, $0, $18	# E : $18 <- number of bytes left to do
 	nop			# E :
 	bne	$18, $last_quad	# U :
 
diff -durN glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/memchr.S glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/memchr.S
--- glibc-2.10.1.orig/glibc-ports-2.10.1/sysdeps/alpha/memchr.S	2009-05-16 10:36:20.000000000 +0200
+++ glibc-2.10.1/glibc-ports-2.10.1/sysdeps/alpha/memchr.S	2009-11-13 00:51:15.000000000 +0100
@@ -119,7 +119,7 @@
 
 	# At least one byte left to process.
 
-	ldq	t0, 8(v0)	# e0	:
+	ldq	zero, 8(v0)	# e0	: prefetch next quad
 	subq	t4, 1, a2	# .. e1 :
 	addq	v0, 8, v0	#-e0	:
 
@@ -138,19 +138,19 @@
 
 	# At least three quads remain to be accessed
 
-	mov	t0, t3		# e0	: move prefetched value to correct reg
-
 	.align	4
 $unrolled_loop:
-	ldq	t0, 8(v0)	#-e0	: prefetch t0
-	xor	a1, t3, t1	# .. e1 :
-	cmpbge	zero, t1, t1	# e0	:
-	bne	t1, $found_it	# .. e1 :
+	ldq	t0, 0(v0)	# e0	: load quad
+	xor	a1, t0, t1	# .. e1 :
+	ldq	zero, 8(v0)	# e0	: prefetch next quad
+	cmpbge	zero, t1, t1	# .. e1:
+	bne	t1, $found_it	# e0    :
 
-	addq	v0, 8, v0	#-e0	:
+	addq	v0, 8, v0	#    e1	:
 $odd_quad_count:
+	ldq	t0, 0(v0)	# e0	: load quad
 	xor	a1, t0, t1	# .. e1 :
-	ldq	t3, 8(v0)	# e0	: prefetch t3
+	ldq	zero, 8(v0)	# e0	: prefetch next quad
 	cmpbge	zero, t1, t1	# .. e1 :
 	addq	v0, 8, t5	#-e0	:
 	bne	t1, $found_it	# .. e1	:
@@ -159,8 +159,8 @@
 	addq	v0, 8, v0	# .. e1 :
 	bne	t5, $unrolled_loop #-e1 :
 
-	mov	t3, t0		# e0	: move prefetched value into t0
-$final:	subq	t4, v0, a2	# .. e1	: a2 <- number of bytes left to do
+$final:	ldq	t0, 0(v0)	# e0	: load last quad
+	subq	t4, v0, a2	# .. e1	: a2 <- number of bytes left to do
 	bne	a2, $last_quad	# e1	:
 
 $not_found:
diff -durN glibc-2.10.1.orig/ports/sysdeps/alpha/alphaev6/memchr.S glibc-2.10.1/ports/sysdeps/alpha/alphaev6/memchr.S
diff -durN glibc-2.10.1.orig/ports/sysdeps/alpha/memchr.S glibc-2.10.1/ports/sysdeps/alpha/memchr.S
