Blame sysdeps/x86_64/rawmemchr.S
|
Packit Service |
82fcde |
/* fast SSE2 memchr with 64 byte loop and pmaxub instruction using
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
Copyright (C) 2011-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
Contributed by Intel Corporation.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <sysdep.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.text
|
|
Packit Service |
82fcde |
ENTRY (__rawmemchr)
|
|
Packit Service |
82fcde |
movd %rsi, %xmm1
|
|
Packit Service |
82fcde |
mov %rdi, %rcx
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
punpcklbw %xmm1, %xmm1
|
|
Packit Service |
82fcde |
punpcklbw %xmm1, %xmm1
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
and $63, %rcx
|
|
Packit Service |
82fcde |
pshufd $0, %xmm1, %xmm1
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
cmp $48, %rcx
|
|
Packit Service |
82fcde |
ja L(crosscache)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
movdqu (%rdi), %xmm0
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm0
|
|
Packit Service |
82fcde |
/* Check if there is a match. */
|
|
Packit Service |
82fcde |
pmovmskb %xmm0, %eax
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
jnz L(matches)
|
|
Packit Service |
82fcde |
add $16, %rdi
|
|
Packit Service |
82fcde |
and $-16, %rdi
|
|
Packit Service |
82fcde |
jmp L(loop_prolog)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.p2align 4
|
|
Packit Service |
82fcde |
L(crosscache):
|
|
Packit Service |
82fcde |
and $15, %rcx
|
|
Packit Service |
82fcde |
and $-16, %rdi
|
|
Packit Service |
82fcde |
movdqa (%rdi), %xmm0
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm0
|
|
Packit Service |
82fcde |
/* Check if there is a match. */
|
|
Packit Service |
82fcde |
pmovmskb %xmm0, %eax
|
|
Packit Service |
82fcde |
/* Remove the leading bytes. */
|
|
Packit Service |
82fcde |
sar %cl, %eax
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
je L(unaligned_no_match)
|
|
Packit Service |
82fcde |
/* Check which byte is a match. */
|
|
Packit Service |
82fcde |
bsf %eax, %eax
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
add %rdi, %rax
|
|
Packit Service |
82fcde |
add %rcx, %rax
|
|
Packit Service |
82fcde |
ret
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.p2align 4
|
|
Packit Service |
82fcde |
L(unaligned_no_match):
|
|
Packit Service |
82fcde |
add $16, %rdi
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.p2align 4
|
|
Packit Service |
82fcde |
L(loop_prolog):
|
|
Packit Service |
82fcde |
movdqa (%rdi), %xmm0
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm0
|
|
Packit Service |
82fcde |
pmovmskb %xmm0, %eax
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
jnz L(matches)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
movdqa 16(%rdi), %xmm2
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm2
|
|
Packit Service |
82fcde |
pmovmskb %xmm2, %eax
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
jnz L(matches16)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
movdqa 32(%rdi), %xmm3
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm3
|
|
Packit Service |
82fcde |
pmovmskb %xmm3, %eax
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
jnz L(matches32)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
movdqa 48(%rdi), %xmm4
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm4
|
|
Packit Service |
82fcde |
add $64, %rdi
|
|
Packit Service |
82fcde |
pmovmskb %xmm4, %eax
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
jnz L(matches0)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
test $0x3f, %rdi
|
|
Packit Service |
82fcde |
jz L(align64_loop)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
movdqa (%rdi), %xmm0
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm0
|
|
Packit Service |
82fcde |
pmovmskb %xmm0, %eax
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
jnz L(matches)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
movdqa 16(%rdi), %xmm2
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm2
|
|
Packit Service |
82fcde |
pmovmskb %xmm2, %eax
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
jnz L(matches16)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
movdqa 32(%rdi), %xmm3
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm3
|
|
Packit Service |
82fcde |
pmovmskb %xmm3, %eax
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
jnz L(matches32)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
movdqa 48(%rdi), %xmm3
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm3
|
|
Packit Service |
82fcde |
pmovmskb %xmm3, %eax
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
add $64, %rdi
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
jnz L(matches0)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
and $-64, %rdi
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.p2align 4
|
|
Packit Service |
82fcde |
L(align64_loop):
|
|
Packit Service |
82fcde |
movdqa (%rdi), %xmm0
|
|
Packit Service |
82fcde |
movdqa 16(%rdi), %xmm2
|
|
Packit Service |
82fcde |
movdqa 32(%rdi), %xmm3
|
|
Packit Service |
82fcde |
movdqa 48(%rdi), %xmm4
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm0
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm2
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm3
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm4
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
pmaxub %xmm0, %xmm3
|
|
Packit Service |
82fcde |
pmaxub %xmm2, %xmm4
|
|
Packit Service |
82fcde |
pmaxub %xmm3, %xmm4
|
|
Packit Service |
82fcde |
pmovmskb %xmm4, %eax
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
add $64, %rdi
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
jz L(align64_loop)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
sub $64, %rdi
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
pmovmskb %xmm0, %eax
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
jnz L(matches)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
pmovmskb %xmm2, %eax
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
jnz L(matches16)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
movdqa 32(%rdi), %xmm3
|
|
Packit Service |
82fcde |
pcmpeqb %xmm1, %xmm3
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
pcmpeqb 48(%rdi), %xmm1
|
|
Packit Service |
82fcde |
pmovmskb %xmm3, %eax
|
|
Packit Service |
82fcde |
test %eax, %eax
|
|
Packit Service |
82fcde |
jnz L(matches32)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
pmovmskb %xmm1, %eax
|
|
Packit Service |
82fcde |
bsf %eax, %eax
|
|
Packit Service |
82fcde |
lea 48(%rdi, %rax), %rax
|
|
Packit Service |
82fcde |
ret
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.p2align 4
|
|
Packit Service |
82fcde |
L(matches0):
|
|
Packit Service |
82fcde |
bsf %eax, %eax
|
|
Packit Service |
82fcde |
lea -16(%rax, %rdi), %rax
|
|
Packit Service |
82fcde |
ret
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.p2align 4
|
|
Packit Service |
82fcde |
L(matches):
|
|
Packit Service |
82fcde |
bsf %eax, %eax
|
|
Packit Service |
82fcde |
add %rdi, %rax
|
|
Packit Service |
82fcde |
ret
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.p2align 4
|
|
Packit Service |
82fcde |
L(matches16):
|
|
Packit Service |
82fcde |
bsf %eax, %eax
|
|
Packit Service |
82fcde |
lea 16(%rax, %rdi), %rax
|
|
Packit Service |
82fcde |
ret
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.p2align 4
|
|
Packit Service |
82fcde |
L(matches32):
|
|
Packit Service |
82fcde |
bsf %eax, %eax
|
|
Packit Service |
82fcde |
lea 32(%rax, %rdi), %rax
|
|
Packit Service |
82fcde |
ret
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
END (__rawmemchr)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
weak_alias (__rawmemchr, rawmemchr)
|
|
Packit Service |
82fcde |
libc_hidden_builtin_def (__rawmemchr)
|