Blame sysdeps/x86_64/wcschr.S

Packit 6c4009
/* wcschr with SSSE3
Packit 6c4009
   Copyright (C) 2011-2018 Free Software Foundation, Inc.
Packit 6c4009
   Contributed by Intel Corporation.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
Packit 6c4009
	.text
Packit 6c4009
ENTRY (__wcschr)
Packit 6c4009
Packit 6c4009
	movd	%rsi, %xmm1
Packit 6c4009
	pxor	%xmm2, %xmm2
Packit 6c4009
	mov	%rdi, %rcx
Packit 6c4009
	punpckldq %xmm1, %xmm1
Packit 6c4009
	punpckldq %xmm1, %xmm1
Packit 6c4009
Packit 6c4009
	and	$63, %rcx
Packit 6c4009
	cmp	$48, %rcx
Packit 6c4009
	ja	L(cross_cache)
Packit 6c4009
Packit 6c4009
	movdqu	(%rdi), %xmm0
Packit 6c4009
	pcmpeqd	%xmm0, %xmm2
Packit 6c4009
	add	$16, %rdi
Packit 6c4009
	pcmpeqd	%xmm1, %xmm0
Packit 6c4009
	pmovmskb %xmm2, %rdx
Packit 6c4009
	pmovmskb %xmm0, %rax
Packit 6c4009
	or	%rax, %rdx
Packit 6c4009
	jnz	L(matches)
Packit 6c4009
Packit 6c4009
	and	$-16, %rdi
Packit 6c4009
Packit 6c4009
	movdqa	(%rdi), %xmm0
Packit 6c4009
	pcmpeqd	%xmm0, %xmm2
Packit 6c4009
	add	$16, %rdi
Packit 6c4009
	pcmpeqd	%xmm1, %xmm0
Packit 6c4009
	pmovmskb %xmm2, %rdx
Packit 6c4009
	pmovmskb %xmm0, %rax
Packit 6c4009
	or	%rax, %rdx
Packit 6c4009
	jnz	L(matches)
Packit 6c4009
Packit 6c4009
	jmp	L(loop)
Packit 6c4009
Packit 6c4009
L(cross_cache):
Packit 6c4009
	and	$15, %rcx
Packit 6c4009
	and	$-16, %rdi
Packit 6c4009
	movdqa	(%rdi), %xmm0
Packit 6c4009
	pcmpeqd	%xmm0, %xmm2
Packit 6c4009
	pcmpeqd	%xmm1, %xmm0
Packit 6c4009
	pmovmskb %xmm2, %rdx
Packit 6c4009
	pmovmskb %xmm0, %rax
Packit 6c4009
Packit 6c4009
	sar	%cl, %rdx
Packit 6c4009
	sar	%cl, %rax
Packit 6c4009
	test	%rax, %rax
Packit 6c4009
	je	L(unaligned_no_match)
Packit 6c4009
Packit 6c4009
	bsf	%rax, %rax
Packit 6c4009
	test	%rdx, %rdx
Packit 6c4009
	je	L(unaligned_match)
Packit 6c4009
	bsf	%rdx, %rdx
Packit 6c4009
	cmp	%rdx, %rax
Packit 6c4009
	ja	L(return_null)
Packit 6c4009
Packit 6c4009
L(unaligned_match):
Packit 6c4009
	add	%rdi, %rax
Packit 6c4009
	add	%rcx, %rax
Packit 6c4009
	ret
Packit 6c4009
Packit 6c4009
	.p2align 4
Packit 6c4009
L(unaligned_no_match):
Packit 6c4009
	test	%rdx, %rdx
Packit 6c4009
	jne	L(return_null)
Packit 6c4009
	pxor	%xmm2, %xmm2
Packit 6c4009
Packit 6c4009
	add	$16, %rdi
Packit 6c4009
Packit 6c4009
	.p2align 4
Packit 6c4009
/* Loop start on aligned string.  */
Packit 6c4009
L(loop):
Packit 6c4009
	movdqa	(%rdi), %xmm0
Packit 6c4009
	pcmpeqd	%xmm0, %xmm2
Packit 6c4009
	add	$16, %rdi
Packit 6c4009
	pcmpeqd	%xmm1, %xmm0
Packit 6c4009
	pmovmskb %xmm2, %rdx
Packit 6c4009
	pmovmskb %xmm0, %rax
Packit 6c4009
	or	%rax, %rdx
Packit 6c4009
	jnz	L(matches)
Packit 6c4009
Packit 6c4009
	movdqa	(%rdi), %xmm0
Packit 6c4009
	pcmpeqd	%xmm0, %xmm2
Packit 6c4009
	add	$16, %rdi
Packit 6c4009
	pcmpeqd	%xmm1, %xmm0
Packit 6c4009
	pmovmskb %xmm2, %rdx
Packit 6c4009
	pmovmskb %xmm0, %rax
Packit 6c4009
	or	%rax, %rdx
Packit 6c4009
	jnz	L(matches)
Packit 6c4009
Packit 6c4009
	movdqa	(%rdi), %xmm0
Packit 6c4009
	pcmpeqd	%xmm0, %xmm2
Packit 6c4009
	add	$16, %rdi
Packit 6c4009
	pcmpeqd	%xmm1, %xmm0
Packit 6c4009
	pmovmskb %xmm2, %rdx
Packit 6c4009
	pmovmskb %xmm0, %rax
Packit 6c4009
	or	%rax, %rdx
Packit 6c4009
	jnz	L(matches)
Packit 6c4009
Packit 6c4009
	movdqa	(%rdi), %xmm0
Packit 6c4009
	pcmpeqd	%xmm0, %xmm2
Packit 6c4009
	add	$16, %rdi
Packit 6c4009
	pcmpeqd	%xmm1, %xmm0
Packit 6c4009
	pmovmskb %xmm2, %rdx
Packit 6c4009
	pmovmskb %xmm0, %rax
Packit 6c4009
	or	%rax, %rdx
Packit 6c4009
	jnz	L(matches)
Packit 6c4009
	jmp	L(loop)
Packit 6c4009
Packit 6c4009
	.p2align 4
Packit 6c4009
L(matches):
Packit 6c4009
	pmovmskb %xmm2, %rdx
Packit 6c4009
	test	%rax, %rax
Packit 6c4009
	jz	L(return_null)
Packit 6c4009
	bsf	%rax, %rax
Packit 6c4009
	test	%rdx, %rdx
Packit 6c4009
	je	L(match)
Packit 6c4009
	bsf	%rdx, %rcx
Packit 6c4009
	cmp	%rcx, %rax
Packit 6c4009
	ja	L(return_null)
Packit 6c4009
L(match):
Packit 6c4009
	sub	$16, %rdi
Packit 6c4009
	add	%rdi, %rax
Packit 6c4009
	ret
Packit 6c4009
Packit 6c4009
	.p2align 4
Packit 6c4009
L(return_null):
Packit 6c4009
	xor	%rax, %rax
Packit 6c4009
	ret
Packit 6c4009
Packit 6c4009
END (__wcschr)
Packit 6c4009
Packit 6c4009
libc_hidden_def(__wcschr)
Packit 6c4009
weak_alias (__wcschr, wcschr)
Packit 6c4009
libc_hidden_weak (wcschr)