1 /* Optimized memchr with sse2 without bsf
2 Copyright (C) 2011-2021 Free Software Foundation, Inc.
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/>. */
23 # define CFI_PUSH(REG) \
24 cfi_adjust_cfa_offset (4); \
25 cfi_rel_offset (REG, 0)
27 # define CFI_POP(REG) \
28 cfi_adjust_cfa_offset (-4); \
31 # define PUSH(REG) pushl REG; CFI_PUSH (REG)
32 # define POP(REG) popl REG; CFI_POP (REG)
34 # ifndef USE_AS_RAWMEMCHR
35 # define ENTRANCE PUSH(%edi);
37 # define RETURN POP(%edi); ret; CFI_PUSH(%edi);
46 # ifndef USE_AS_RAWMEMCHR
51 # define MEMCHR __memchr_sse2
58 movd STR2(%esp), %xmm1
59 # ifndef USE_AS_RAWMEMCHR
65 punpcklbw %xmm1, %xmm1
66 # ifndef USE_AS_RAWMEMCHR
71 punpcklbw %xmm1, %xmm1
74 pshufd $0, %xmm1, %xmm1
78 # ifndef USE_AS_RAWMEMCHR
86 # ifndef USE_AS_RAWMEMCHR
87 jnz L(match_case2_prolog)
96 jnz L(match_case1_prolog)
105 # ifndef USE_AS_RAWMEMCHR
117 # ifndef USE_AS_RAWMEMCHR
118 jnz L(match_case2_prolog1)
119 /* "ecx" is less than 16. Calculate "edx + ecx - 16" by using
120 "edx - (16 - ecx)" instead of "(edx + ecx) - 16" to void
121 possible addition overflow. */
128 jnz L(match_case1_prolog1)
134 # ifndef USE_AS_RAWMEMCHR
147 # ifndef USE_AS_RAWMEMCHR
148 movdqa 16(%edi), %xmm2
150 movdqa 16(%edx), %xmm2
158 # ifndef USE_AS_RAWMEMCHR
159 movdqa 32(%edi), %xmm3
161 movdqa 32(%edx), %xmm3
169 # ifndef USE_AS_RAWMEMCHR
170 movdqa 48(%edi), %xmm4
172 movdqa 48(%edx), %xmm4
180 # ifndef USE_AS_RAWMEMCHR
196 # ifndef USE_AS_RAWMEMCHR
197 movdqa 16(%edi), %xmm2
199 movdqa 16(%edx), %xmm2
207 # ifndef USE_AS_RAWMEMCHR
208 movdqa 32(%edi), %xmm3
210 movdqa 32(%edx), %xmm3
218 # ifndef USE_AS_RAWMEMCHR
219 movdqa 48(%edi), %xmm4
221 movdqa 48(%edx), %xmm4
229 # ifndef USE_AS_RAWMEMCHR
243 # ifndef USE_AS_RAWMEMCHR
247 movdqa 16(%edi), %xmm2
248 movdqa 32(%edi), %xmm3
249 movdqa 48(%edi), %xmm4
252 movdqa 16(%edx), %xmm2
253 movdqa 32(%edx), %xmm3
254 movdqa 48(%edx), %xmm4
264 # ifndef USE_AS_RAWMEMCHR
274 # ifndef USE_AS_RAWMEMCHR
290 # ifndef USE_AS_RAWMEMCHR
291 movdqa 32(%edi), %xmm3
293 movdqa 32(%edx), %xmm3
301 # ifndef USE_AS_RAWMEMCHR
302 pcmpeqb 48(%edi), %xmm1
304 pcmpeqb 48(%edx), %xmm1
311 # ifndef USE_AS_RAWMEMCHR
314 L(match_case1_prolog1):
316 L(match_case1_prolog):
319 jz L(match_case1_high)
329 # ifndef USE_AS_RAWMEMCHR
345 # ifndef USE_AS_RAWMEMCHR
357 jz L(match_case1_high_8)
364 # ifndef USE_AS_RAWMEMCHR
373 L(match_case1_high_8):
380 # ifndef USE_AS_RAWMEMCHR
388 # ifndef USE_AS_RAWMEMCHR
402 movdqa 16(%edi), %xmm2
411 movdqa 32(%edi), %xmm3
420 pcmpeqb 48(%edi), %xmm1
432 # ifndef USE_AS_RAWMEMCHR
442 # ifndef USE_AS_RAWMEMCHR
452 # ifndef USE_AS_RAWMEMCHR
462 # ifndef USE_AS_RAWMEMCHR
472 # ifndef USE_AS_RAWMEMCHR
482 # ifndef USE_AS_RAWMEMCHR
492 # ifndef USE_AS_RAWMEMCHR
502 # ifndef USE_AS_RAWMEMCHR
512 # ifndef USE_AS_RAWMEMCHR
522 # ifndef USE_AS_RAWMEMCHR
532 # ifndef USE_AS_RAWMEMCHR
542 # ifndef USE_AS_RAWMEMCHR
550 # ifndef USE_AS_RAWMEMCHR
554 L(match_case2_prolog1):
556 L(match_case2_prolog):
558 jz L(match_case2_high)
590 jz L(match_case2_high_8)
603 L(match_case2_high_8):
701 # ifndef USE_AS_RAWMEMCHR