Blame SOURCES/glibc-rh695963.patch

b40826
2010-08-27  Ulrich Drepper  <drepper@redhat.com>
b40826
b40826
	* sysdeps/x86_64/multiarch/strlen-no-bsf.S: Move to .text.slow section.
b40826
b40826
	* sysdeps/x86_64/strlen.S: Minimal code improvement.
b40826
b40826
2010-08-26  H.J. Lu  <hongjiu.lu@intel.com>
b40826
b40826
	* sysdeps/x86_64/strlen.S: Unroll the loop.
b40826
	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
b40826
	strlen-sse2 strlen-sse2-bsf.
b40826
	* sysdeps/x86_64/multiarch/strlen.S ((strlen): Return
b40826
	__strlen_no_bsf if bit_Slow_BSF is set.
b40826
	(__strlen_sse42): Removed.
b40826
	* sysdeps/x86_64/multiarch/strlen-no-bsf.S: New file.
b40826
	* sysdeps/x86_64/multiarch/strlen-sse4.S: New file.
b40826
b40826
2010-08-25  H.J. Lu  <hongjiu.lu@intel.com>
b40826
b40826
	* sysdeps/i386/i686/multiarch/Makefile (sysdep_routines): Add
b40826
	strlen-sse2 strlen-sse2-bsf.
b40826
	* sysdeps/i386/i686/multiarch/strlen.S (strlen): Return
b40826
	__strlen_sse2_bsf if bit_Slow_BSF is unset.
b40826
	(__strlen_sse2): Removed.
b40826
	* sysdeps/i386/i686/multiarch/strlen-sse2-bsf.S: New file.
b40826
	* sysdeps/i386/i686/multiarch/strlen-sse2.S: New file.
b40826
	* sysdeps/x86_64/multiarch/init-arch.c (__init_cpu_features): Set
b40826
	bit_Slow_BSF for Atom.
b40826
	* sysdeps/x86_64/multiarch/init-arch.h (bit_Slow_BSF): Define.
b40826
	(index_Slow_BSF): Define.
b40826
	(HAS_SLOW_BSF): Define.
b40826
b40826
Index: glibc-2.12-2-gc4ccff1/sysdeps/i386/i686/multiarch/Makefile
b40826
===================================================================
b40826
--- glibc-2.12-2-gc4ccff1.orig/sysdeps/i386/i686/multiarch/Makefile
b40826
+++ glibc-2.12-2-gc4ccff1/sysdeps/i386/i686/multiarch/Makefile
b40826
@@ -9,7 +9,8 @@ sysdep_routines += bzero-sse2 memset-sse
b40826
 		   memmove-ssse3-rep bcopy-ssse3 bcopy-ssse3-rep \
b40826
 		   memset-sse2-rep bzero-sse2-rep strcmp-ssse3 \
b40826
 		   strcmp-sse4 strncmp-c strncmp-ssse3 strncmp-sse4 \
b40826
-		   memcmp-ssse3 memcmp-sse4 strcasestr-nonascii
b40826
+		   memcmp-ssse3 memcmp-sse4 strcasestr-nonascii \
b40826
+		   strlen-sse2 strlen-sse2-bsf
b40826
 ifeq (yes,$(config-cflags-sse4))
b40826
 sysdep_routines += strcspn-c strpbrk-c strspn-c strstr-c strcasestr-c
b40826
 CFLAGS-strcspn-c.c += -msse4
b40826
Index: glibc-2.12-2-gc4ccff1/sysdeps/i386/i686/multiarch/strlen-sse2-bsf.S
b40826
===================================================================
b40826
--- /dev/null
b40826
+++ glibc-2.12-2-gc4ccff1/sysdeps/i386/i686/multiarch/strlen-sse2-bsf.S
b40826
@@ -0,0 +1,127 @@
b40826
+/* strlen with SSE2 and BSF
b40826
+   Copyright (C) 2010 Free Software Foundation, Inc.
b40826
+   Contributed by Intel Corporation.
b40826
+   This file is part of the GNU C Library.
b40826
+
b40826
+   The GNU C Library is free software; you can redistribute it and/or
b40826
+   modify it under the terms of the GNU Lesser General Public
b40826
+   License as published by the Free Software Foundation; either
b40826
+   version 2.1 of the License, or (at your option) any later version.
b40826
+
b40826
+   The GNU C Library is distributed in the hope that it will be useful,
b40826
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
b40826
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
b40826
+   Lesser General Public License for more details.
b40826
+
b40826
+   You should have received a copy of the GNU Lesser General Public
b40826
+   License along with the GNU C Library; if not, write to the Free
b40826
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
b40826
+   02111-1307 USA.  */
b40826
+
b40826
+#if defined SHARED && !defined NOT_IN_libc
b40826
+
b40826
+#include <sysdep.h>
b40826
+#include "asm-syntax.h"
b40826
+
b40826
+#define CFI_PUSH(REG)						\
b40826
+  cfi_adjust_cfa_offset (4);					\
b40826
+  cfi_rel_offset (REG, 0)
b40826
+
b40826
+#define CFI_POP(REG)						\
b40826
+  cfi_adjust_cfa_offset (-4);					\
b40826
+  cfi_restore (REG)
b40826
+
b40826
+#define PUSH(REG)	pushl REG; CFI_PUSH (REG)
b40826
+#define POP(REG)	popl REG; CFI_POP (REG)
b40826
+#define PARMS		4 + 8	/* Preserve ESI and EDI.  */
b40826
+#define	STR		PARMS
b40826
+#define ENTRANCE	PUSH (%esi); PUSH (%edi); cfi_remember_state
b40826
+#define RETURN		POP (%edi); POP (%esi); ret; \
b40826
+			cfi_restore_state; cfi_remember_state
b40826
+
b40826
+	.text
b40826
+ENTRY ( __strlen_sse2_bsf)
b40826
+	ENTRANCE
b40826
+	mov	STR(%esp), %edi
b40826
+	xor	%eax, %eax
b40826
+	mov	%edi, %ecx
b40826
+	and	$0x3f, %ecx
b40826
+	pxor	%xmm0, %xmm0
b40826
+	cmp	$0x30, %ecx
b40826
+	ja	L(next)
b40826
+	movdqu	(%edi), %xmm1
b40826
+	pcmpeqb	%xmm1, %xmm0
b40826
+	pmovmskb %xmm0, %edx
b40826
+	test	%edx, %edx
b40826
+	jnz	L(exit_less16)
b40826
+	mov	%edi, %eax
b40826
+	and	$-16, %eax
b40826
+	jmp	L(align16_start)
b40826
+L(next):
b40826
+
b40826
+	mov	%edi, %eax
b40826
+	and	$-16, %eax
b40826
+	pcmpeqb	(%eax), %xmm0
b40826
+	mov	$-1, %esi
b40826
+	sub	%eax, %ecx
b40826
+	shl	%cl, %esi
b40826
+	pmovmskb %xmm0, %edx
b40826
+	and	%esi, %edx
b40826
+	jnz	L(exit)
b40826
+L(align16_start):
b40826
+	pxor	%xmm0, %xmm0
b40826
+	pxor	%xmm1, %xmm1
b40826
+	pxor	%xmm2, %xmm2
b40826
+	pxor	%xmm3, %xmm3
b40826
+	.p2align 4
b40826
+L(align16_loop):
b40826
+	pcmpeqb	16(%eax), %xmm0
b40826
+	pmovmskb %xmm0, %edx
b40826
+	test	%edx, %edx
b40826
+	jnz	L(exit16)
b40826
+
b40826
+	pcmpeqb	32(%eax), %xmm1
b40826
+	pmovmskb %xmm1, %edx
b40826
+	test	%edx, %edx
b40826
+	jnz	L(exit32)
b40826
+
b40826
+	pcmpeqb	48(%eax), %xmm2
b40826
+	pmovmskb %xmm2, %edx
b40826
+	test	%edx, %edx
b40826
+	jnz	L(exit48)
b40826
+
b40826
+	pcmpeqb	64(%eax), %xmm3
b40826
+	pmovmskb %xmm3, %edx
b40826
+	lea	64(%eax), %eax
b40826
+	test	%edx, %edx
b40826
+	jz	L(align16_loop)
b40826
+L(exit):
b40826
+	sub	%edi, %eax
b40826
+L(exit_less16):
b40826
+	bsf	%edx, %edx
b40826
+	add	%edx, %eax
b40826
+	RETURN
b40826
+L(exit16):
b40826
+	sub	%edi, %eax
b40826
+	bsf	%edx, %edx
b40826
+	add	%edx, %eax
b40826
+	add	$16, %eax
b40826
+	RETURN
b40826
+L(exit32):
b40826
+	sub	%edi, %eax
b40826
+	bsf	%edx, %edx
b40826
+	add	%edx, %eax
b40826
+	add	$32, %eax
b40826
+	RETURN
b40826
+L(exit48):
b40826
+	sub	%edi, %eax
b40826
+	bsf	%edx, %edx
b40826
+	add	%edx, %eax
b40826
+	add	$48, %eax
b40826
+	POP (%edi)
b40826
+	POP (%esi)
b40826
+	ret
b40826
+
b40826
+END ( __strlen_sse2_bsf)
b40826
+
b40826
+#endif
b40826
Index: glibc-2.12-2-gc4ccff1/sysdeps/i386/i686/multiarch/strlen-sse2.S
b40826
===================================================================
b40826
--- /dev/null
b40826
+++ glibc-2.12-2-gc4ccff1/sysdeps/i386/i686/multiarch/strlen-sse2.S
b40826
@@ -0,0 +1,347 @@
b40826
+/* strlen with SSE2
b40826
+   Copyright (C) 2010 Free Software Foundation, Inc.
b40826
+   Contributed by Intel Corporation.
b40826
+   This file is part of the GNU C Library.
b40826
+
b40826
+   The GNU C Library is free software; you can redistribute it and/or
b40826
+   modify it under the terms of the GNU Lesser General Public
b40826
+   License as published by the Free Software Foundation; either
b40826
+   version 2.1 of the License, or (at your option) any later version.
b40826
+
b40826
+   The GNU C Library is distributed in the hope that it will be useful,
b40826
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
b40826
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
b40826
+   Lesser General Public License for more details.
b40826
+
b40826
+   You should have received a copy of the GNU Lesser General Public
b40826
+   License along with the GNU C Library; if not, write to the Free
b40826
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
b40826
+   02111-1307 USA.  */
b40826
+
b40826
+#if defined SHARED && !defined NOT_IN_libc
b40826
+
b40826
+#include <sysdep.h>
b40826
+#include "asm-syntax.h"
b40826
+
b40826
+#define CFI_PUSH(REG)						\
b40826
+  cfi_adjust_cfa_offset (4);					\
b40826
+  cfi_rel_offset (REG, 0)
b40826
+
b40826
+#define CFI_POP(REG)						\
b40826
+  cfi_adjust_cfa_offset (-4);					\
b40826
+  cfi_restore (REG)
b40826
+
b40826
+#define PUSH(REG)	pushl REG; CFI_PUSH (REG)
b40826
+#define POP(REG)	popl REG; CFI_POP (REG)
b40826
+#define PARMS		4
b40826
+#define	STR		PARMS
b40826
+#define ENTRANCE
b40826
+#define RETURN		ret
b40826
+
b40826
+	.text
b40826
+ENTRY (__strlen_sse2)
b40826
+	ENTRANCE
b40826
+	mov	STR(%esp), %edx
b40826
+	xor	%eax, %eax
b40826
+	cmpb	$0, (%edx)
b40826
+	jz	L(exit_tail0)
b40826
+	cmpb	$0, 1(%edx)
b40826
+	jz	L(exit_tail1)
b40826
+	cmpb	$0, 2(%edx)
b40826
+	jz	L(exit_tail2)
b40826
+	cmpb	$0, 3(%edx)
b40826
+	jz	L(exit_tail3)
b40826
+	cmpb	$0, 4(%edx)
b40826
+	jz	L(exit_tail4)
b40826
+	cmpb	$0, 5(%edx)
b40826
+	jz	L(exit_tail5)
b40826
+	cmpb	$0, 6(%edx)
b40826
+	jz	L(exit_tail6)
b40826
+	cmpb	$0, 7(%edx)
b40826
+	jz	L(exit_tail7)
b40826
+	cmpb	$0, 8(%edx)
b40826
+	jz	L(exit_tail8)
b40826
+	cmpb	$0, 9(%edx)
b40826
+	jz	L(exit_tail9)
b40826
+	cmpb	$0, 10(%edx)
b40826
+	jz	L(exit_tail10)
b40826
+	cmpb	$0, 11(%edx)
b40826
+	jz	L(exit_tail11)
b40826
+	cmpb	$0, 12(%edx)
b40826
+	jz	L(exit_tail12)
b40826
+	cmpb	$0, 13(%edx)
b40826
+	jz	L(exit_tail13)
b40826
+	cmpb	$0, 14(%edx)
b40826
+	jz	L(exit_tail14)
b40826
+	cmpb	$0, 15(%edx)
b40826
+	jz	L(exit_tail15)
b40826
+	pxor	%xmm0, %xmm0
b40826
+	mov	%edx, %eax
b40826
+	mov	%edx, %ecx
b40826
+	and	$-16, %eax
b40826
+	add	$16, %ecx
b40826
+	add	$16, %eax
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm0
b40826
+	pmovmskb %xmm0, %edx
b40826
+	pxor	%xmm1, %xmm1
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm1
b40826
+	pmovmskb %xmm1, %edx
b40826
+	pxor	%xmm2, %xmm2
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm2
b40826
+	pmovmskb %xmm2, %edx
b40826
+	pxor	%xmm3, %xmm3
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm3
b40826
+	pmovmskb %xmm3, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm0
b40826
+	pmovmskb %xmm0, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm1
b40826
+	pmovmskb %xmm1, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm2
b40826
+	pmovmskb %xmm2, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm3
b40826
+	pmovmskb %xmm3, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm0
b40826
+	pmovmskb %xmm0, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm1
b40826
+	pmovmskb %xmm1, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm2
b40826
+	pmovmskb %xmm2, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm3
b40826
+	pmovmskb %xmm3, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm0
b40826
+	pmovmskb %xmm0, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm1
b40826
+	pmovmskb %xmm1, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm2
b40826
+	pmovmskb %xmm2, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%eax), %xmm3
b40826
+	pmovmskb %xmm3, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%eax), %eax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	and	$-0x40, %eax
b40826
+	PUSH (%esi)
b40826
+	PUSH (%edi)
b40826
+	PUSH (%ebx)
b40826
+	PUSH (%ebp)
b40826
+	xor	%ebp, %ebp
b40826
+L(aligned_64):
b40826
+	pcmpeqb	(%eax), %xmm0
b40826
+	pcmpeqb	16(%eax), %xmm1
b40826
+	pcmpeqb	32(%eax), %xmm2
b40826
+	pcmpeqb	48(%eax), %xmm3
b40826
+	pmovmskb %xmm0, %edx
b40826
+	pmovmskb %xmm1, %esi
b40826
+	pmovmskb %xmm2, %edi
b40826
+	pmovmskb %xmm3, %ebx
b40826
+	or	%edx, %ebp
b40826
+	or	%esi, %ebp
b40826
+	or	%edi, %ebp
b40826
+	or	%ebx, %ebp
b40826
+	lea	64(%eax), %eax
b40826
+	jz	L(aligned_64)
b40826
+L(48leave):
b40826
+	test	%edx, %edx
b40826
+	jnz	L(aligned_64_exit_16)
b40826
+	test	%esi, %esi
b40826
+	jnz	L(aligned_64_exit_32)
b40826
+	test	%edi, %edi
b40826
+	jnz	L(aligned_64_exit_48)
b40826
+	mov	%ebx, %edx
b40826
+	lea	(%eax), %eax
b40826
+	jmp	L(aligned_64_exit)
b40826
+L(aligned_64_exit_48):
b40826
+	lea	-16(%eax), %eax
b40826
+	mov	%edi, %edx
b40826
+	jmp	L(aligned_64_exit)
b40826
+L(aligned_64_exit_32):
b40826
+	lea	-32(%eax), %eax
b40826
+	mov	%esi, %edx
b40826
+	jmp	L(aligned_64_exit)
b40826
+L(aligned_64_exit_16):
b40826
+	lea	-48(%eax), %eax
b40826
+L(aligned_64_exit):
b40826
+	POP (%ebp)
b40826
+	POP (%ebx)
b40826
+	POP (%edi)
b40826
+	POP (%esi)
b40826
+L(exit):
b40826
+	sub	%ecx, %eax
b40826
+	test	%dl, %dl
b40826
+	jz	L(exit_high)
b40826
+	test	$0x01, %dl
b40826
+	jnz	L(exit_tail0)
b40826
+
b40826
+	test	$0x02, %dl
b40826
+	jnz	L(exit_tail1)
b40826
+
b40826
+	test	$0x04, %dl
b40826
+	jnz	L(exit_tail2)
b40826
+
b40826
+	test	$0x08, %dl
b40826
+	jnz	L(exit_tail3)
b40826
+
b40826
+	test	$0x10, %dl
b40826
+	jnz	L(exit_tail4)
b40826
+
b40826
+	test	$0x20, %dl
b40826
+	jnz	L(exit_tail5)
b40826
+
b40826
+	test	$0x40, %dl
b40826
+	jnz	L(exit_tail6)
b40826
+	add	$7, %eax
b40826
+L(exit_tail0):
b40826
+	RETURN
b40826
+
b40826
+L(exit_high):
b40826
+	add	$8, %eax
b40826
+	test	$0x01, %dh
b40826
+	jnz	L(exit_tail0)
b40826
+
b40826
+	test	$0x02, %dh
b40826
+	jnz	L(exit_tail1)
b40826
+
b40826
+	test	$0x04, %dh
b40826
+	jnz	L(exit_tail2)
b40826
+
b40826
+	test	$0x08, %dh
b40826
+	jnz	L(exit_tail3)
b40826
+
b40826
+	test	$0x10, %dh
b40826
+	jnz	L(exit_tail4)
b40826
+
b40826
+	test	$0x20, %dh
b40826
+	jnz	L(exit_tail5)
b40826
+
b40826
+	test	$0x40, %dh
b40826
+	jnz	L(exit_tail6)
b40826
+	add	$7, %eax
b40826
+	RETURN
b40826
+
b40826
+	.p2align 4
b40826
+L(exit_tail1):
b40826
+	add	$1, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail2):
b40826
+	add	$2, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail3):
b40826
+	add	$3, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail4):
b40826
+	add	$4, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail5):
b40826
+	add	$5, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail6):
b40826
+	add	$6, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail7):
b40826
+	add	$7, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail8):
b40826
+	add	$8, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail9):
b40826
+	add	$9, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail10):
b40826
+	add	$10, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail11):
b40826
+	add	$11, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail12):
b40826
+	add	$12, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail13):
b40826
+	add	$13, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail14):
b40826
+	add	$14, %eax
b40826
+	RETURN
b40826
+
b40826
+L(exit_tail15):
b40826
+	add	$15, %eax
b40826
+	ret
b40826
+
b40826
+END (__strlen_sse2)
b40826
+
b40826
+#endif
b40826
Index: glibc-2.12-2-gc4ccff1/sysdeps/i386/i686/multiarch/strlen.S
b40826
===================================================================
b40826
--- glibc-2.12-2-gc4ccff1.orig/sysdeps/i386/i686/multiarch/strlen.S
b40826
+++ glibc-2.12-2-gc4ccff1/sysdeps/i386/i686/multiarch/strlen.S
b40826
@@ -48,6 +48,9 @@ ENTRY(strlen)
b40826
 1:	leal	__strlen_ia32@GOTOFF(%ebx), %eax
b40826
 	testl	$bit_SSE2, CPUID_OFFSET+index_SSE2+__cpu_features@GOTOFF(%ebx)
b40826
 	jz	2f
b40826
+	leal	__strlen_sse2_bsf@GOTOFF(%ebx), %eax
b40826
+	testl	$bit_Slow_BSF, FEATURE_OFFSET+index_Slow_BSF+__cpu_features@GOTOFF(%ebx)
b40826
+	jz	2f
b40826
 	leal	__strlen_sse2@GOTOFF(%ebx), %eax
b40826
 2:	popl	%ebx
b40826
 	cfi_adjust_cfa_offset (-4);
b40826
@@ -55,84 +58,6 @@ ENTRY(strlen)
b40826
 	ret
b40826
 END(strlen)
b40826
 
b40826
-#define CFI_POP(REG)						\
b40826
-  cfi_adjust_cfa_offset (-4);					\
b40826
-  cfi_restore (REG)
b40826
-
b40826
-#define RETURN		popl %esi; CFI_POP (esi); ret
b40826
-
b40826
-	.text
b40826
-ENTRY (__strlen_sse2)
b40826
-/*
b40826
- * This implementation uses SSE instructions to compare up to 16 bytes
b40826
- * at a time looking for the end of string (null char).
b40826
- */
b40826
-	pushl	%esi
b40826
-	cfi_adjust_cfa_offset (4)
b40826
-	cfi_rel_offset (%esi, 0)
b40826
-	mov	8(%esp), %eax
b40826
-	mov	%eax, %ecx
b40826
-	pxor	%xmm0, %xmm0		/* 16 null chars */
b40826
-	mov	%eax, %esi
b40826
-	and	$15, %ecx
b40826
-	jz	1f			/* string is 16 byte aligned */
b40826
-
b40826
-	/*
b40826
-	* Unaligned case. Round down to 16-byte boundary before comparing
b40826
-	* 16 bytes for a null char. The code then compensates for any extra chars
b40826
-	* preceding the start of the string.
b40826
-	*/
b40826
-	and	$-16, %esi
b40826
-
b40826
-	pcmpeqb	(%esi), %xmm0
b40826
-	lea	16(%eax), %esi
b40826
-	pmovmskb %xmm0, %edx
b40826
-
b40826
-	shr	%cl, %edx		/* Compensate for bytes preceding the string */
b40826
-	test	%edx, %edx
b40826
-	jnz	2f
b40826
-	sub	%ecx, %esi		/* no null, adjust to next 16-byte boundary */
b40826
-	pxor	%xmm0, %xmm0		/* clear xmm0, may have been changed... */
b40826
-
b40826
-	.p2align 4
b40826
-1:					/* 16 byte aligned */
b40826
-	pcmpeqb	(%esi), %xmm0		/* look for null bytes */
b40826
-	pmovmskb %xmm0, %edx		/* move each byte mask of %xmm0 to edx */
b40826
-
b40826
-	add	$16, %esi		/* prepare to search next 16 bytes */
b40826
-	test	%edx, %edx		/* if no null byte, %edx must be 0 */
b40826
-	jnz	2f			/* found a null */
b40826
-
b40826
-	pcmpeqb	(%esi), %xmm0
b40826
-	pmovmskb %xmm0, %edx
b40826
-	add	$16, %esi
b40826
-	test	%edx, %edx
b40826
-	jnz	2f
b40826
-
b40826
-	pcmpeqb	(%esi), %xmm0
b40826
-	pmovmskb %xmm0, %edx
b40826
-	add	$16, %esi
b40826
-	test	%edx, %edx
b40826
-	jnz	2f
b40826
-
b40826
-	pcmpeqb	(%esi), %xmm0
b40826
-	pmovmskb %xmm0, %edx
b40826
-	add	$16, %esi
b40826
-	test	%edx, %edx
b40826
-	jz	1b
b40826
-
b40826
-2:
b40826
-	neg	%eax
b40826
-	lea	-16(%eax, %esi), %eax	/* calculate exact offset */
b40826
-	bsf	%edx, %ecx		/* Least significant 1 bit is index of null */
b40826
-	add	%ecx, %eax
b40826
-	popl	%esi
b40826
-	cfi_adjust_cfa_offset (-4)
b40826
-	cfi_restore (%esi)
b40826
-	ret
b40826
-
b40826
-END (__strlen_sse2)
b40826
-
b40826
 # undef ENTRY
b40826
 # define ENTRY(name) \
b40826
 	.type __strlen_ia32, @function; \
b40826
--- a/sysdeps/x86_64/multiarch/Makefile	2012-03-01 10:43:30.060487726 -0700
b40826
+++ b/sysdeps/x86_64/multiarch/Makefile	2012-03-01 10:45:57.894692115 -0700
b40826
@@ -7,7 +7,7 @@ ifeq ($(subdir),string)
b40826
 sysdep_routines += stpncpy-c strncpy-c strcmp-ssse3 strncmp-ssse3 \
b40826
 		   strend-sse4 memcmp-sse4 \
b40826
 		   strcasestr-nonascii strcasecmp_l-ssse3 \
b40826
-		   strncase_l-ssse3 \
b40826
+		   strncase_l-ssse3 strlen-sse4 strlen-no-bsf \
b40826
 		   memset-x86-64
b40826
 ifeq (yes,$(config-cflags-sse4))
b40826
 sysdep_routines += strcspn-c strpbrk-c strspn-c strstr-c strcasestr-c
b40826
Index: glibc-2.12-2-gc4ccff1/sysdeps/x86_64/multiarch/init-arch.c
b40826
===================================================================
b40826
--- glibc-2.12-2-gc4ccff1.orig/sysdeps/x86_64/multiarch/init-arch.c
b40826
+++ glibc-2.12-2-gc4ccff1/sysdeps/x86_64/multiarch/init-arch.c
b40826
@@ -77,6 +77,12 @@ __init_cpu_features (void)
b40826
 	  model += extended_model;
b40826
 	  switch (model)
b40826
 	    {
b40826
+	    case 0x1c:
b40826
+	    case 0x26:
b40826
+	      /* BSF is slow on Atom.  */
b40826
+	      __cpu_features.feature[index_Slow_BSF] |= bit_Slow_BSF;
b40826
+	      break;
b40826
+
b40826
 	    case 0x1a:
b40826
 	    case 0x1e:
b40826
 	    case 0x1f:
b40826
--- a/sysdeps/x86_64/multiarch/init-arch.h	2012-03-01 10:43:30.061487720 -0700
b40826
+++ b/sysdeps/x86_64/multiarch/init-arch.h	2012-03-01 10:48:13.371963005 -0700
b40826
@@ -17,6 +17,7 @@
b40826
    02111-1307 USA.  */
b40826
 
b40826
 #define bit_Fast_Rep_String		(1 << 0)
b40826
+#define bit_Slow_BSF                   (1 << 2)
b40826
 #define bit_Prefer_SSE_for_memop	(1 << 3)
b40826
 
b40826
 #ifdef	__ASSEMBLER__
b40826
@@ -34,6 +35,7 @@
b40826
 # define index_SSE4_2	COMMON_CPUID_INDEX_1*CPUID_SIZE+CPUID_ECX_OFFSET
b40826
 
b40826
 #define index_Fast_Rep_String	FEATURE_INDEX_1*FEATURE_SIZE
b40826
+# define index_Slow_BSF                        FEATURE_INDEX_1*FEATURE_SIZE
b40826
 # define index_Prefer_SSE_for_memop	FEATURE_INDEX_1*FEATURE_SIZE
b40826
 
b40826
 #else	/* __ASSEMBLER__ */
b40826
@@ -105,11 +107,15 @@ extern const struct cpu_features *__get_
b40826
 # define HAS_FMA	HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, 12)
b40826
 
b40826
 # define index_Fast_Rep_String	FEATURE_INDEX_1
b40826
+# define index_Slow_BSF                        FEATURE_INDEX_1
b40826
 # define index_Prefer_SSE_for_memop	FEATURE_INDEX_1
b40826
 
b40826
 #define HAS_ARCH_FEATURE(idx, bit) \
b40826
   ((__get_cpu_features ()->feature[idx] & (bit)) != 0)
b40826
 
b40826
+#define HAS_SLOW_BSF \
b40826
+  HAS_ARCH_FEATURE (index_Slow_BSF, bit_Slow_BSF)
b40826
+
b40826
 #define HAS_PREFER_SSE_FOR_MEMOP \
b40826
   HAS_ARCH_FEATURE (index_Prefer_SSE_for_memop, bit_Prefer_SSE_for_memop)
b40826
 
b40826
Index: glibc-2.12-2-gc4ccff1/sysdeps/x86_64/multiarch/strlen-no-bsf.S
b40826
===================================================================
b40826
--- /dev/null
b40826
+++ glibc-2.12-2-gc4ccff1/sysdeps/x86_64/multiarch/strlen-no-bsf.S
b40826
@@ -0,0 +1,309 @@
b40826
+/* strlen without BSF
b40826
+   Copyright (C) 2010 Free Software Foundation, Inc.
b40826
+   Contributed by Intel Corporation.
b40826
+   This file is part of the GNU C Library.
b40826
+
b40826
+   The GNU C Library is free software; you can redistribute it and/or
b40826
+   modify it under the terms of the GNU Lesser General Public
b40826
+   License as published by the Free Software Foundation; either
b40826
+   version 2.1 of the License, or (at your option) any later version.
b40826
+
b40826
+   The GNU C Library is distributed in the hope that it will be useful,
b40826
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
b40826
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
b40826
+   Lesser General Public License for more details.
b40826
+
b40826
+   You should have received a copy of the GNU Lesser General Public
b40826
+   License along with the GNU C Library; if not, write to the Free
b40826
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
b40826
+   02111-1307 USA.  */
b40826
+
b40826
+#if defined SHARED && !defined NOT_IN_libc
b40826
+
b40826
+#include <sysdep.h>
b40826
+
b40826
+	.section .text.slow,"ax",@progbits
b40826
+ENTRY (__strlen_no_bsf)
b40826
+	xor	%eax, %eax
b40826
+	cmpb	$0, (%rdi)
b40826
+	jz	L(exit_tail0)
b40826
+	cmpb	$0, 1(%rdi)
b40826
+	jz	L(exit_tail1)
b40826
+	cmpb	$0, 2(%rdi)
b40826
+	jz	L(exit_tail2)
b40826
+	cmpb	$0, 3(%rdi)
b40826
+	jz	L(exit_tail3)
b40826
+	cmpb	$0, 4(%rdi)
b40826
+	jz	L(exit_tail4)
b40826
+	cmpb	$0, 5(%rdi)
b40826
+	jz	L(exit_tail5)
b40826
+	cmpb	$0, 6(%rdi)
b40826
+	jz	L(exit_tail6)
b40826
+	cmpb	$0, 7(%rdi)
b40826
+	jz	L(exit_tail7)
b40826
+	cmpb	$0, 8(%rdi)
b40826
+	jz	L(exit_tail8)
b40826
+	cmpb	$0, 9(%rdi)
b40826
+	jz	L(exit_tail9)
b40826
+	cmpb	$0, 10(%rdi)
b40826
+	jz	L(exit_tail10)
b40826
+	cmpb	$0, 11(%rdi)
b40826
+	jz	L(exit_tail11)
b40826
+	cmpb	$0, 12(%rdi)
b40826
+	jz	L(exit_tail12)
b40826
+	cmpb	$0, 13(%rdi)
b40826
+	jz	L(exit_tail13)
b40826
+	cmpb	$0, 14(%rdi)
b40826
+	jz	L(exit_tail14)
b40826
+	cmpb	$0, 15(%rdi)
b40826
+	jz	L(exit_tail15)
b40826
+	pxor	%xmm0, %xmm0
b40826
+	mov	%rdi, %rcx
b40826
+	mov	%rdi, %rax
b40826
+	and	$-16, %rax
b40826
+	add	$16, %rax
b40826
+	add	$16, %rcx
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm0
b40826
+	pmovmskb %xmm0, %edx
b40826
+	pxor	%xmm1, %xmm1
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm1
b40826
+	pmovmskb %xmm1, %edx
b40826
+	pxor	%xmm2, %xmm2
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm2
b40826
+	pmovmskb %xmm2, %edx
b40826
+	pxor	%xmm3, %xmm3
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm3
b40826
+	pmovmskb %xmm3, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm0
b40826
+	pmovmskb %xmm0, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm1
b40826
+	pmovmskb %xmm1, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm2
b40826
+	pmovmskb %xmm2, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm3
b40826
+	pmovmskb %xmm3, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm0
b40826
+	pmovmskb %xmm0, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm1
b40826
+	pmovmskb %xmm1, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm2
b40826
+	pmovmskb %xmm2, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm3
b40826
+	pmovmskb %xmm3, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm0
b40826
+	pmovmskb %xmm0, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm1
b40826
+	pmovmskb %xmm1, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm2
b40826
+	pmovmskb %xmm2, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	pcmpeqb	(%rax), %xmm3
b40826
+	pmovmskb %xmm3, %edx
b40826
+	test	%edx, %edx
b40826
+	lea	16(%rax), %rax
b40826
+	jnz	L(exit)
b40826
+
b40826
+	and	$-0x40, %rax
b40826
+	xor	%r8d, %r8d
b40826
+L(aligned_64):
b40826
+	pcmpeqb	(%rax), %xmm0
b40826
+	pcmpeqb	16(%rax), %xmm1
b40826
+	pcmpeqb	32(%rax), %xmm2
b40826
+	pcmpeqb	48(%rax), %xmm3
b40826
+	pmovmskb %xmm0, %edx
b40826
+	pmovmskb %xmm1, %esi
b40826
+	pmovmskb %xmm2, %edi
b40826
+	pmovmskb %xmm3, %r9d
b40826
+	or	%edx, %r8d
b40826
+	or	%esi, %r8d
b40826
+	or	%edi, %r8d
b40826
+	or	%r9d, %r8d
b40826
+	lea	64(%rax), %rax
b40826
+	jz	L(aligned_64)
b40826
+
b40826
+	test	%edx, %edx
b40826
+	jnz	L(aligned_64_exit_16)
b40826
+	test	%esi, %esi
b40826
+	jnz	L(aligned_64_exit_32)
b40826
+	test	%edi, %edi
b40826
+	jnz	L(aligned_64_exit_48)
b40826
+L(aligned_64_exit_64):
b40826
+	mov	%r9d, %edx
b40826
+	jmp	L(aligned_64_exit)
b40826
+L(aligned_64_exit_48):
b40826
+	lea	-16(%rax), %rax
b40826
+	mov	%edi, %edx
b40826
+	jmp	L(aligned_64_exit)
b40826
+L(aligned_64_exit_32):
b40826
+	lea	-32(%rax), %rax
b40826
+	mov	%esi, %edx
b40826
+	jmp	L(aligned_64_exit)
b40826
+L(aligned_64_exit_16):
b40826
+	lea	-48(%rax), %rax
b40826
+L(aligned_64_exit):
b40826
+L(exit):
b40826
+	sub	%rcx, %rax
b40826
+	test	%dl, %dl
b40826
+	jz	L(exit_high)
b40826
+	test	$0x01, %dl
b40826
+	jnz	L(exit_tail0)
b40826
+
b40826
+	test	$0x02, %dl
b40826
+	jnz	L(exit_tail1)
b40826
+
b40826
+	test	$0x04, %dl
b40826
+	jnz	L(exit_tail2)
b40826
+
b40826
+	test	$0x08, %dl
b40826
+	jnz	L(exit_tail3)
b40826
+
b40826
+	test	$0x10, %dl
b40826
+	jnz	L(exit_tail4)
b40826
+
b40826
+	test	$0x20, %dl
b40826
+	jnz	L(exit_tail5)
b40826
+
b40826
+	test	$0x40, %dl
b40826
+	jnz	L(exit_tail6)
b40826
+	add	$7, %eax
b40826
+L(exit_tail0):
b40826
+	ret
b40826
+
b40826
+L(exit_high):
b40826
+	add	$8, %eax
b40826
+	test	$0x01, %dh
b40826
+	jnz	L(exit_tail0)
b40826
+
b40826
+	test	$0x02, %dh
b40826
+	jnz	L(exit_tail1)
b40826
+
b40826
+	test	$0x04, %dh
b40826
+	jnz	L(exit_tail2)
b40826
+
b40826
+	test	$0x08, %dh
b40826
+	jnz	L(exit_tail3)
b40826
+
b40826
+	test	$0x10, %dh
b40826
+	jnz	L(exit_tail4)
b40826
+
b40826
+	test	$0x20, %dh
b40826
+	jnz	L(exit_tail5)
b40826
+
b40826
+	test	$0x40, %dh
b40826
+	jnz	L(exit_tail6)
b40826
+	add	$7, %eax
b40826
+	ret
b40826
+	.p2align 4
b40826
+L(exit_tail1):
b40826
+	add	$1, %eax
b40826
+	ret
b40826
+
b40826
+L(exit_tail2):
b40826
+	add	$2, %eax
b40826
+	ret
b40826
+
b40826
+L(exit_tail3):
b40826
+	add	$3, %eax
b40826
+	ret
b40826
+
b40826
+L(exit_tail4):
b40826
+	add	$4, %eax
b40826
+	ret
b40826
+
b40826
+L(exit_tail5):
b40826
+	add	$5, %eax
b40826
+	ret
b40826
+L(exit_tail6):
b40826
+	add	$6, %eax
b40826
+	ret
b40826
+L(exit_tail7):
b40826
+	add	$7, %eax
b40826
+	ret
b40826
+L(exit_tail8):
b40826
+	add	$8, %eax
b40826
+	ret
b40826
+L(exit_tail9):
b40826
+	add	$9, %eax
b40826
+	ret
b40826
+L(exit_tail10):
b40826
+	add	$10, %eax
b40826
+	ret
b40826
+L(exit_tail11):
b40826
+	add	$11, %eax
b40826
+	ret
b40826
+L(exit_tail12):
b40826
+	add	$12, %eax
b40826
+	ret
b40826
+L(exit_tail13):
b40826
+	add	$13, %eax
b40826
+	ret
b40826
+L(exit_tail14):
b40826
+	add	$14, %eax
b40826
+	ret
b40826
+L(exit_tail15):
b40826
+	add	$15, %eax
b40826
+	ret
b40826
+END (__strlen_no_bsf)
b40826
+
b40826
+#endif
b40826
Index: glibc-2.12-2-gc4ccff1/sysdeps/x86_64/multiarch/strlen-sse4.S
b40826
===================================================================
b40826
--- /dev/null
b40826
+++ glibc-2.12-2-gc4ccff1/sysdeps/x86_64/multiarch/strlen-sse4.S
b40826
@@ -0,0 +1,85 @@
b40826
+/* strlen with SSE4
b40826
+   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
b40826
+   Contributed by Ulrich Drepper <drepper@redhat.com>.
b40826
+   This file is part of the GNU C Library.
b40826
+
b40826
+   The GNU C Library is free software; you can redistribute it and/or
b40826
+   modify it under the terms of the GNU Lesser General Public
b40826
+   License as published by the Free Software Foundation; either
b40826
+   version 2.1 of the License, or (at your option) any later version.
b40826
+
b40826
+   The GNU C Library is distributed in the hope that it will be useful,
b40826
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
b40826
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
b40826
+   Lesser General Public License for more details.
b40826
+
b40826
+   You should have received a copy of the GNU Lesser General Public
b40826
+   License along with the GNU C Library; if not, write to the Free
b40826
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
b40826
+   02111-1307 USA.  */
b40826
+
b40826
+#if defined SHARED && !defined NOT_IN_libc
b40826
+
b40826
+#include <sysdep.h>
b40826
+
b40826
+	.section .text.sse4.2,"ax",@progbits
b40826
+ENTRY (__strlen_sse42)
b40826
+	pxor	%xmm1, %xmm1
b40826
+	movl	%edi, %ecx
b40826
+	movq	%rdi, %r8
b40826
+	andq	$~15, %rdi
b40826
+	xor	%edi, %ecx
b40826
+	pcmpeqb	(%rdi), %xmm1
b40826
+	pmovmskb %xmm1, %edx
b40826
+	shrl	%cl, %edx
b40826
+	shll	%cl, %edx
b40826
+	andl	%edx, %edx
b40826
+	jnz	L(less16bytes)
b40826
+	pxor	%xmm1, %xmm1
b40826
+
b40826
+	.p2align 4
b40826
+L(more64bytes_loop):
b40826
+	pcmpistri $0x08, 16(%rdi), %xmm1
b40826
+	jz	L(more32bytes)
b40826
+
b40826
+	pcmpistri $0x08, 32(%rdi), %xmm1
b40826
+	jz	L(more48bytes)
b40826
+
b40826
+	pcmpistri $0x08, 48(%rdi), %xmm1
b40826
+	jz	L(more64bytes)
b40826
+
b40826
+	add	$64, %rdi
b40826
+	pcmpistri $0x08, (%rdi), %xmm1
b40826
+	jnz	L(more64bytes_loop)
b40826
+	leaq	(%rdi,%rcx), %rax
b40826
+	subq	%r8, %rax
b40826
+	ret
b40826
+
b40826
+	.p2align 4
b40826
+L(more32bytes):
b40826
+	leaq	16(%rdi,%rcx, 1), %rax
b40826
+	subq	%r8, %rax
b40826
+	ret
b40826
+
b40826
+	.p2align 4
b40826
+L(more48bytes):
b40826
+	leaq	32(%rdi,%rcx, 1), %rax
b40826
+	subq	%r8, %rax
b40826
+	ret
b40826
+
b40826
+	.p2align 4
b40826
+L(more64bytes):
b40826
+	leaq	48(%rdi,%rcx, 1), %rax
b40826
+	subq	%r8, %rax
b40826
+	ret
b40826
+
b40826
+	.p2align 4
b40826
+L(less16bytes):
b40826
+	subq	%r8, %rdi
b40826
+	bsfl	%edx, %eax
b40826
+	addq	%rdi, %rax
b40826
+	ret
b40826
+
b40826
+END (__strlen_sse42)
b40826
+
b40826
+#endif
b40826
Index: glibc-2.12-2-gc4ccff1/sysdeps/x86_64/multiarch/strlen.S
b40826
===================================================================
b40826
--- glibc-2.12-2-gc4ccff1.orig/sysdeps/x86_64/multiarch/strlen.S
b40826
+++ glibc-2.12-2-gc4ccff1/sysdeps/x86_64/multiarch/strlen.S
b40826
@@ -36,74 +36,12 @@ ENTRY(strlen)
b40826
 	testl	$bit_SSE4_2, __cpu_features+CPUID_OFFSET+index_SSE4_2(%rip)
b40826
 	jz	2f
b40826
 	leaq	__strlen_sse42(%rip), %rax
b40826
-2:	ret
b40826
-END(strlen)
b40826
-
b40826
-
b40826
-	.section .text.sse4.2,"ax",@progbits
b40826
-	.align 	16
b40826
-	.type	__strlen_sse42, @function
b40826
-__strlen_sse42:
b40826
-	cfi_startproc
b40826
-	CALL_MCOUNT
b40826
-	pxor	%xmm1, %xmm1
b40826
-	movl	%edi, %ecx
b40826
-	movq	%rdi, %r8
b40826
-	andq	$~15, %rdi
b40826
-	xor	%edi, %ecx
b40826
-	pcmpeqb	(%rdi), %xmm1
b40826
-	pmovmskb %xmm1, %edx
b40826
-	shrl	%cl, %edx
b40826
-	shll	%cl, %edx
b40826
-	andl	%edx, %edx
b40826
-	jnz	L(less16bytes)
b40826
-	pxor	%xmm1, %xmm1
b40826
-
b40826
-	.p2align 4
b40826
-L(more64bytes_loop):
b40826
-	pcmpistri $0x08, 16(%rdi), %xmm1
b40826
-	jz	L(more32bytes)
b40826
-
b40826
-	pcmpistri $0x08, 32(%rdi), %xmm1
b40826
-	jz	L(more48bytes)
b40826
-
b40826
-	pcmpistri $0x08, 48(%rdi), %xmm1
b40826
-	jz	L(more64bytes)
b40826
-
b40826
-	add	$64, %rdi
b40826
-	pcmpistri $0x08, (%rdi), %xmm1
b40826
-	jnz	L(more64bytes_loop)
b40826
-	leaq	(%rdi,%rcx), %rax
b40826
-	subq	%r8, %rax
b40826
-	ret
b40826
-
b40826
-	.p2align 4
b40826
-L(more32bytes):
b40826
-	leaq	16(%rdi,%rcx, 1), %rax
b40826
-	subq	%r8, %rax
b40826
-	ret
b40826
-
b40826
-	.p2align 4
b40826
-L(more48bytes):
b40826
-	leaq	32(%rdi,%rcx, 1), %rax
b40826
-	subq	%r8, %rax
b40826
-	ret
b40826
-
b40826
-	.p2align 4
b40826
-L(more64bytes):
b40826
-	leaq	48(%rdi,%rcx, 1), %rax
b40826
-	subq	%r8, %rax
b40826
 	ret
b40826
-
b40826
-	.p2align 4
b40826
-L(less16bytes):
b40826
-	subq	%r8, %rdi
b40826
-	bsfl	%edx, %eax
b40826
-	addq	%rdi, %rax
b40826
-	ret
b40826
-	cfi_endproc
b40826
-	.size	__strlen_sse42, .-__strlen_sse42
b40826
-
b40826
+2:	testl	$bit_Slow_BSF, __cpu_features+FEATURE_OFFSET+index_Slow_BSF(%rip)
b40826
+	jz	3f
b40826
+	leaq    __strlen_no_bsf(%rip), %rax
b40826
+3:	ret
b40826
+END(strlen)
b40826
 
b40826
 # undef ENTRY
b40826
 # define ENTRY(name) \
b40826
Index: glibc-2.12-2-gc4ccff1/sysdeps/x86_64/strlen.S
b40826
===================================================================
b40826
--- glibc-2.12-2-gc4ccff1.orig/sysdeps/x86_64/strlen.S
b40826
+++ glibc-2.12-2-gc4ccff1/sysdeps/x86_64/strlen.S
b40826
@@ -23,29 +23,80 @@
b40826
 
b40826
 	.text
b40826
 ENTRY(strlen)
b40826
-	pxor	%xmm2, %xmm2
b40826
-	movq	%rdi, %rcx
b40826
-	movq	%rdi, %r8
b40826
-	andq	$~15, %rdi
b40826
-	movdqa	%xmm2, %xmm1
b40826
-	pcmpeqb	(%rdi), %xmm2
b40826
-	orl	$0xffffffff, %esi
b40826
-	subq	%rdi, %rcx
b40826
-	shll	%cl, %esi
b40826
-	pmovmskb %xmm2, %edx
b40826
-	andl	%esi, %edx
b40826
-	jnz	1f
b40826
-
b40826
-2:	movdqa	16(%rdi), %xmm0
b40826
-	leaq	16(%rdi), %rdi
b40826
+	xor	%rax, %rax
b40826
+	mov	%edi, %ecx
b40826
+	and	$0x3f, %ecx
b40826
+	pxor	%xmm0, %xmm0
b40826
+	cmp	$0x30, %ecx
b40826
+	ja	L(next)
b40826
+	movdqu	(%rdi), %xmm1
b40826
 	pcmpeqb	%xmm1, %xmm0
b40826
 	pmovmskb %xmm0, %edx
b40826
-	testl	%edx, %edx
b40826
-	jz	2b
b40826
+	test	%edx, %edx
b40826
+	jnz	L(exit_less16)
b40826
+	mov	%rdi, %rax
b40826
+	and	$-16, %rax
b40826
+	jmp	L(align16_start)
b40826
+L(next):
b40826
+	mov	%rdi, %rax
b40826
+	and	$-16, %rax
b40826
+	pcmpeqb	(%rax), %xmm0
b40826
+	mov	$-1, %esi
b40826
+	sub	%rax, %rcx
b40826
+	shl	%cl, %esi
b40826
+	pmovmskb %xmm0, %edx
b40826
+	and	%esi, %edx
b40826
+	jnz	L(exit)
b40826
+L(align16_start):
b40826
+	pxor	%xmm0, %xmm0
b40826
+	pxor	%xmm1, %xmm1
b40826
+	pxor	%xmm2, %xmm2
b40826
+	pxor	%xmm3, %xmm3
b40826
+	.p2align 4
b40826
+L(align16_loop):
b40826
+	pcmpeqb	16(%rax), %xmm0
b40826
+	pmovmskb %xmm0, %edx
b40826
+	test	%edx, %edx
b40826
+	jnz	L(exit16)
b40826
 
b40826
-1:	subq	%r8, %rdi
b40826
-	bsfl	%edx, %eax
b40826
-	addq	%rdi, %rax
b40826
+	pcmpeqb	32(%rax), %xmm1
b40826
+	pmovmskb %xmm1, %edx
b40826
+	test	%edx, %edx
b40826
+	jnz	L(exit32)
b40826
+
b40826
+	pcmpeqb	48(%rax), %xmm2
b40826
+	pmovmskb %xmm2, %edx
b40826
+	test	%edx, %edx
b40826
+	jnz	L(exit48)
b40826
+
b40826
+	pcmpeqb	64(%rax), %xmm3
b40826
+	pmovmskb %xmm3, %edx
b40826
+	lea	64(%rax), %rax
b40826
+	test	%edx, %edx
b40826
+	jz	L(align16_loop)
b40826
+L(exit):
b40826
+	sub	%rdi, %rax
b40826
+L(exit_less16):
b40826
+	bsf	%rdx, %rdx
b40826
+	add	%rdx, %rax
b40826
+	ret
b40826
+	.p2align 4
b40826
+L(exit16):
b40826
+	sub	%rdi, %rax
b40826
+	bsf	%rdx, %rdx
b40826
+	lea	16(%rdx,%rax), %rax
b40826
+	ret
b40826
+	.p2align 4
b40826
+L(exit32):
b40826
+	sub	%rdi, %rax
b40826
+	bsf	%rdx, %rdx
b40826
+	lea	32(%rdx,%rax), %rax
b40826
+	ret
b40826
+	.p2align 4
b40826
+L(exit48):
b40826
+	sub	%rdi, %rax
b40826
+	bsf	%rdx, %rdx
b40826
+	lea	48(%rdx,%rax), %rax
b40826
 	ret
b40826
 END(strlen)
b40826
 libc_hidden_builtin_def (strlen)