1 /* wcsrchr with SSE2, without using bsf instructions.
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/>. */
21 # define CFI_PUSH(REG) \
22 cfi_adjust_cfa_offset (4); \
23 cfi_rel_offset (REG, 0)
25 # define CFI_POP(REG) \
26 cfi_adjust_cfa_offset (-4); \
29 # define PUSH(REG) pushl REG; CFI_PUSH (REG)
30 # define POP(REG) popl REG; CFI_POP (REG)
33 # define ENTRANCE PUSH (%edi);
34 # define RETURN POP (%edi); ret; CFI_PUSH (%edi);
39 ENTRY (__wcsrchr_sse2)
43 movd STR2(%esp), %xmm1
46 punpckldq %xmm1, %xmm1
48 punpckldq %xmm1, %xmm1
55 /* unaligned string. */
59 /* Find where NULL is. */
61 /* Check if there is a match. */
66 jnz L(unaligned_match1)
83 jnz L(prolog_find_zero_1)
87 /* Save current match */
97 /* Hancle unaligned string. */
104 /* Find where NULL is. */
106 /* Check if there is a match. */
108 /* Remove the leading bytes. */
114 jnz L(unaligned_match)
129 jnz L(prolog_find_zero)
134 lea (%edi, %ecx), %esi
136 /* Loop start on aligned string. */
188 jnz L(match_third_or_fourth_wchar)
190 jnz L(match_second_wchar)
210 /* save match info */
218 jz L(find_zero_in_third_or_fourth_wchar)
220 jz L(find_zero_in_second_wchar)
232 L(find_zero_in_second_wchar):
233 and $1 << 5 - 1, %eax
239 jnz L(match_second_wchar)
246 L(find_zero_in_third_or_fourth_wchar):
248 jz L(find_zero_in_fourth_wchar)
249 and $1 << 9 - 1, %eax
255 jnz L(match_third_wchar)
257 jnz L(match_second_wchar)
264 L(find_zero_in_fourth_wchar):
269 jnz L(match_third_or_fourth_wchar)
271 jnz L(match_second_wchar)
278 L(match_second_wchar):
283 L(match_third_or_fourth_wchar):
285 jnz L(match_fourth_wchar)
290 L(match_third_wchar):
295 L(match_fourth_wchar):
308 L(prolog_find_zero_1):
310 jz L(prolog_find_zero_in_third_or_fourth_wchar)
312 jz L(prolog_find_zero_in_second_wchar)
320 L(prolog_find_zero_in_second_wchar):
321 and $1 << 5 - 1, %eax
325 jnz L(match_second_wchar)
330 L(prolog_find_zero_in_third_or_fourth_wchar):
332 jz L(prolog_find_zero_in_fourth_wchar)
333 and $1 << 9 - 1, %eax
337 jnz L(match_third_wchar)
339 jnz L(match_second_wchar)
344 L(prolog_find_zero_in_fourth_wchar):
346 jnz L(match_third_or_fourth_wchar)
348 jnz L(match_second_wchar)