1 /* Copyright (C) 2011-2018 Free Software Foundation, Inc.
2 Contributed by Intel Corporation.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
22 # define MEMCHR wmemchr
23 # define PCMPEQ pcmpeqd
25 # define MEMCHR memchr
26 # define PCMPEQ pcmpeqb
29 /* fast SSE2 version with using pmaxub and 64 byte loop */
41 punpcklbw %xmm1, %xmm1
44 punpcklbw %xmm1, %xmm1
48 pshufd $0, %xmm1, %xmm1
76 /* Check if there is a match. */
78 /* Remove the leading bytes. */
81 je L(unaligned_no_match)
82 /* Check which byte is a match. */
92 L(unaligned_no_match):
93 /* "rcx" is less than 16. Calculate "rdx + rcx - 16" by using
94 "rdx - (16 - rcx)" instead of "(rdx + rcx) - 16" to void
95 possible addition overflow. */
112 movdqa 16(%rdi), %xmm2
118 movdqa 32(%rdi), %xmm3
124 movdqa 48(%rdi), %xmm4
143 movdqa 16(%rdi), %xmm2
149 movdqa 32(%rdi), %xmm3
155 movdqa 48(%rdi), %xmm3
173 movdqa 16(%rdi), %xmm2
174 movdqa 32(%rdi), %xmm3
175 movdqa 48(%rdi), %xmm4
202 movdqa 32(%rdi), %xmm3
205 PCMPEQ 48(%rdi), %xmm1
212 lea 48(%rdi, %rax), %rax
226 movdqa 16(%rdi), %xmm2
232 movdqa 32(%rdi), %xmm3
240 PCMPEQ 48(%rdi), %xmm1
258 PCMPEQ 16(%rdi), %xmm1
268 lea -16(%rax, %rdi), %rax
280 lea 16(%rax, %rdi), %rax
286 lea 32(%rax, %rdi), %rax
302 lea 16(%rdi, %rax), %rax
310 lea 32(%rdi, %rax), %rax
318 lea 48(%rdi, %rax), %rax
327 #ifndef USE_AS_WMEMCHR
328 strong_alias (memchr, __memchr)
329 libc_hidden_builtin_def(memchr)