Blame SOURCES/glibc-rh695963.patch

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