More small optimizations for x86-64 strlen.

This commit is contained in:
Ulrich Drepper 2009-06-04 16:45:35 -07:00
parent 747785f2b3
commit 2f3f7b9da2
2 changed files with 8 additions and 10 deletions

View File

@ -1,6 +1,6 @@
2009-06-04 Ulrich Drepper <drepper@redhat.com> 2009-06-04 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/strlen.S: Remove useless instruction. * sysdeps/x86_64/strlen.S: Minor optimizations.
2009-06-02 H.J. Lu <hongjiu.lu@intel.com> 2009-06-02 H.J. Lu <hongjiu.lu@intel.com>

View File

@ -23,29 +23,27 @@
.text .text
ENTRY(strlen) ENTRY(strlen)
pxor %xmm2, %xmm2
movq %rdi, %rcx movq %rdi, %rcx
movq %rdi, %r8 movq %rdi, %r8
andq $~15, %rdi andq $~15, %rdi
pxor %xmm1, %xmm1 movdqa %xmm2, %xmm1
pcmpeqb (%rdi), %xmm2
orl $0xffffffff, %esi orl $0xffffffff, %esi
movdqa (%rdi), %xmm0
subq %rdi, %rcx subq %rdi, %rcx
leaq 16(%rdi), %rdi shll %cl, %esi
pcmpeqb %xmm1, %xmm0 pmovmskb %xmm2, %edx
shl %cl, %esi
pmovmskb %xmm0, %edx
negq %r8
andl %esi, %edx andl %esi, %edx
jnz 1f jnz 1f
2: movdqa (%rdi), %xmm0 2: movdqa 16(%rdi), %xmm0
leaq 16(%rdi), %rdi leaq 16(%rdi), %rdi
pcmpeqb %xmm1, %xmm0 pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %edx pmovmskb %xmm0, %edx
testl %edx, %edx testl %edx, %edx
jz 2b jz 2b
1: leaq -16(%rdi,%r8), %rdi 1: subq %r8, %rdi
bsfl %edx, %eax bsfl %edx, %eax
addq %rdi, %rax addq %rdi, %rax
ret ret