1 /* Optimized memchr with sse2 without bsf
2 Copyright (C) 2011-2019 Free Software Foundation, Inc.
3 Contributed by Intel Corporation.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
24 # define CFI_PUSH(REG) \
25 cfi_adjust_cfa_offset (4); \
26 cfi_rel_offset (REG, 0)
28 # define CFI_POP(REG) \
29 cfi_adjust_cfa_offset (-4); \
32 # define PUSH(REG) pushl REG; CFI_PUSH (REG)
33 # define POP(REG) popl REG; CFI_POP (REG)
35 # ifndef USE_AS_RAWMEMCHR
36 # define ENTRANCE PUSH(%edi);
38 # define RETURN POP(%edi); ret; CFI_PUSH(%edi);
47 # ifndef USE_AS_RAWMEMCHR
52 # define MEMCHR __memchr_sse2
59 movd STR2(%esp), %xmm1
60 # ifndef USE_AS_RAWMEMCHR
66 punpcklbw %xmm1, %xmm1
67 # ifndef USE_AS_RAWMEMCHR
72 punpcklbw %xmm1, %xmm1
75 pshufd $0, %xmm1, %xmm1
79 # ifndef USE_AS_RAWMEMCHR
87 # ifndef USE_AS_RAWMEMCHR
88 jnz L(match_case2_prolog)
97 jnz L(match_case1_prolog)
106 # ifndef USE_AS_RAWMEMCHR
118 # ifndef USE_AS_RAWMEMCHR
119 jnz L(match_case2_prolog1)
120 /* "ecx" is less than 16. Calculate "edx + ecx - 16" by using
121 "edx - (16 - ecx)" instead of "(edx + ecx) - 16" to void
122 possible addition overflow. */
129 jnz L(match_case1_prolog1)
135 # ifndef USE_AS_RAWMEMCHR
148 # ifndef USE_AS_RAWMEMCHR
149 movdqa 16(%edi), %xmm2
151 movdqa 16(%edx), %xmm2
159 # ifndef USE_AS_RAWMEMCHR
160 movdqa 32(%edi), %xmm3
162 movdqa 32(%edx), %xmm3
170 # ifndef USE_AS_RAWMEMCHR
171 movdqa 48(%edi), %xmm4
173 movdqa 48(%edx), %xmm4
181 # ifndef USE_AS_RAWMEMCHR
197 # ifndef USE_AS_RAWMEMCHR
198 movdqa 16(%edi), %xmm2
200 movdqa 16(%edx), %xmm2
208 # ifndef USE_AS_RAWMEMCHR
209 movdqa 32(%edi), %xmm3
211 movdqa 32(%edx), %xmm3
219 # ifndef USE_AS_RAWMEMCHR
220 movdqa 48(%edi), %xmm4
222 movdqa 48(%edx), %xmm4
230 # ifndef USE_AS_RAWMEMCHR
244 # ifndef USE_AS_RAWMEMCHR
248 movdqa 16(%edi), %xmm2
249 movdqa 32(%edi), %xmm3
250 movdqa 48(%edi), %xmm4
253 movdqa 16(%edx), %xmm2
254 movdqa 32(%edx), %xmm3
255 movdqa 48(%edx), %xmm4
265 # ifndef USE_AS_RAWMEMCHR
275 # ifndef USE_AS_RAWMEMCHR
291 # ifndef USE_AS_RAWMEMCHR
292 movdqa 32(%edi), %xmm3
294 movdqa 32(%edx), %xmm3
302 # ifndef USE_AS_RAWMEMCHR
303 pcmpeqb 48(%edi), %xmm1
305 pcmpeqb 48(%edx), %xmm1
312 # ifndef USE_AS_RAWMEMCHR
315 L(match_case1_prolog1):
317 L(match_case1_prolog):
320 jz L(match_case1_high)
330 # ifndef USE_AS_RAWMEMCHR
346 # ifndef USE_AS_RAWMEMCHR
358 jz L(match_case1_high_8)
365 # ifndef USE_AS_RAWMEMCHR
374 L(match_case1_high_8):
381 # ifndef USE_AS_RAWMEMCHR
389 # ifndef USE_AS_RAWMEMCHR
403 movdqa 16(%edi), %xmm2
412 movdqa 32(%edi), %xmm3
421 pcmpeqb 48(%edi), %xmm1
433 # ifndef USE_AS_RAWMEMCHR
443 # ifndef USE_AS_RAWMEMCHR
453 # ifndef USE_AS_RAWMEMCHR
463 # ifndef USE_AS_RAWMEMCHR
473 # ifndef USE_AS_RAWMEMCHR
483 # ifndef USE_AS_RAWMEMCHR
493 # ifndef USE_AS_RAWMEMCHR
503 # ifndef USE_AS_RAWMEMCHR
513 # ifndef USE_AS_RAWMEMCHR
523 # ifndef USE_AS_RAWMEMCHR
533 # ifndef USE_AS_RAWMEMCHR
543 # ifndef USE_AS_RAWMEMCHR
551 # ifndef USE_AS_RAWMEMCHR
555 L(match_case2_prolog1):
557 L(match_case2_prolog):
559 jz L(match_case2_high)
591 jz L(match_case2_high_8)
604 L(match_case2_high_8):
702 # ifndef USE_AS_RAWMEMCHR