1 /* Optimized memchr with sse2 without bsf
2 Copyright (C) 2011-2014 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)
125 jnz L(match_case1_prolog1)
131 # ifndef USE_AS_RAWMEMCHR
144 # ifndef USE_AS_RAWMEMCHR
145 movdqa 16(%edi), %xmm2
147 movdqa 16(%edx), %xmm2
155 # ifndef USE_AS_RAWMEMCHR
156 movdqa 32(%edi), %xmm3
158 movdqa 32(%edx), %xmm3
166 # ifndef USE_AS_RAWMEMCHR
167 movdqa 48(%edi), %xmm4
169 movdqa 48(%edx), %xmm4
177 # ifndef USE_AS_RAWMEMCHR
193 # ifndef USE_AS_RAWMEMCHR
194 movdqa 16(%edi), %xmm2
196 movdqa 16(%edx), %xmm2
204 # ifndef USE_AS_RAWMEMCHR
205 movdqa 32(%edi), %xmm3
207 movdqa 32(%edx), %xmm3
215 # ifndef USE_AS_RAWMEMCHR
216 movdqa 48(%edi), %xmm4
218 movdqa 48(%edx), %xmm4
226 # ifndef USE_AS_RAWMEMCHR
240 # ifndef USE_AS_RAWMEMCHR
244 movdqa 16(%edi), %xmm2
245 movdqa 32(%edi), %xmm3
246 movdqa 48(%edi), %xmm4
249 movdqa 16(%edx), %xmm2
250 movdqa 32(%edx), %xmm3
251 movdqa 48(%edx), %xmm4
261 # ifndef USE_AS_RAWMEMCHR
271 # ifndef USE_AS_RAWMEMCHR
287 # ifndef USE_AS_RAWMEMCHR
288 movdqa 32(%edi), %xmm3
290 movdqa 32(%edx), %xmm3
298 # ifndef USE_AS_RAWMEMCHR
299 pcmpeqb 48(%edi), %xmm1
301 pcmpeqb 48(%edx), %xmm1
308 # ifndef USE_AS_RAWMEMCHR
311 L(match_case1_prolog1):
313 L(match_case1_prolog):
316 jz L(match_case1_high)
326 # ifndef USE_AS_RAWMEMCHR
342 # ifndef USE_AS_RAWMEMCHR
354 jz L(match_case1_high_8)
361 # ifndef USE_AS_RAWMEMCHR
370 L(match_case1_high_8):
377 # ifndef USE_AS_RAWMEMCHR
385 # ifndef USE_AS_RAWMEMCHR
399 movdqa 16(%edi), %xmm2
408 movdqa 32(%edi), %xmm3
417 pcmpeqb 48(%edi), %xmm1
429 # ifndef USE_AS_RAWMEMCHR
439 # ifndef USE_AS_RAWMEMCHR
449 # ifndef USE_AS_RAWMEMCHR
459 # ifndef USE_AS_RAWMEMCHR
469 # ifndef USE_AS_RAWMEMCHR
479 # ifndef USE_AS_RAWMEMCHR
489 # ifndef USE_AS_RAWMEMCHR
499 # ifndef USE_AS_RAWMEMCHR
509 # ifndef USE_AS_RAWMEMCHR
519 # ifndef USE_AS_RAWMEMCHR
529 # ifndef USE_AS_RAWMEMCHR
539 # ifndef USE_AS_RAWMEMCHR
547 # ifndef USE_AS_RAWMEMCHR
551 L(match_case2_prolog1):
553 L(match_case2_prolog):
555 jz L(match_case2_high)
587 jz L(match_case2_high_8)
600 L(match_case2_high_8):
698 # ifndef USE_AS_RAWMEMCHR