1 /* Copyright (C) 2011-2020 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 <https://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 */
42 /* Clear the upper 32 bits. */
45 punpcklbw %xmm1, %xmm1
48 punpcklbw %xmm1, %xmm1
52 pshufd $0, %xmm1, %xmm1
80 /* Check if there is a match. */
82 /* Remove the leading bytes. */
85 je L(unaligned_no_match)
86 /* Check which byte is a match. */
96 L(unaligned_no_match):
97 /* "rcx" is less than 16. Calculate "rdx + rcx - 16" by using
98 "rdx - (16 - rcx)" instead of "(rdx + rcx) - 16" to void
99 possible addition overflow. */
116 movdqa 16(%rdi), %xmm2
122 movdqa 32(%rdi), %xmm3
128 movdqa 48(%rdi), %xmm4
147 movdqa 16(%rdi), %xmm2
153 movdqa 32(%rdi), %xmm3
159 movdqa 48(%rdi), %xmm3
177 movdqa 16(%rdi), %xmm2
178 movdqa 32(%rdi), %xmm3
179 movdqa 48(%rdi), %xmm4
206 movdqa 32(%rdi), %xmm3
209 PCMPEQ 48(%rdi), %xmm1
216 lea 48(%rdi, %rax), %rax
230 movdqa 16(%rdi), %xmm2
236 movdqa 32(%rdi), %xmm3
244 PCMPEQ 48(%rdi), %xmm1
262 PCMPEQ 16(%rdi), %xmm1
272 lea -16(%rax, %rdi), %rax
284 lea 16(%rax, %rdi), %rax
290 lea 32(%rax, %rdi), %rax
306 lea 16(%rdi, %rax), %rax
314 lea 32(%rdi, %rax), %rax
322 lea 48(%rdi, %rax), %rax
331 #ifndef USE_AS_WMEMCHR
332 strong_alias (memchr, __memchr)
333 libc_hidden_builtin_def(memchr)