1 /* wcsrchr with SSE2, without using bsf instructions.
2 Copyright (C) 2011-2015 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/>. */
22 # define CFI_PUSH(REG) \
23 cfi_adjust_cfa_offset (4); \
24 cfi_rel_offset (REG, 0)
26 # define CFI_POP(REG) \
27 cfi_adjust_cfa_offset (-4); \
30 # define PUSH(REG) pushl REG; CFI_PUSH (REG)
31 # define POP(REG) popl REG; CFI_POP (REG)
34 # define ENTRANCE PUSH (%edi);
35 # define RETURN POP (%edi); ret; CFI_PUSH (%edi);
40 ENTRY (__wcsrchr_sse2)
44 movd STR2(%esp), %xmm1
47 punpckldq %xmm1, %xmm1
49 punpckldq %xmm1, %xmm1
56 /* unaligned string. */
60 /* Find where NULL is. */
62 /* Check if there is a match. */
67 jnz L(unaligned_match1)
84 jnz L(prolog_find_zero_1)
88 /* Save current match */
98 /* Hancle unaligned string. */
105 /* Find where NULL is. */
107 /* Check if there is a match. */
109 /* Remove the leading bytes. */
115 jnz L(unaligned_match)
130 jnz L(prolog_find_zero)
135 lea (%edi, %ecx), %esi
137 /* Loop start on aligned string. */
189 jnz L(match_third_or_fourth_wchar)
191 jnz L(match_second_wchar)
211 /* save match info */
219 jz L(find_zero_in_third_or_fourth_wchar)
221 jz L(find_zero_in_second_wchar)
233 L(find_zero_in_second_wchar):
234 and $1 << 5 - 1, %eax
240 jnz L(match_second_wchar)
247 L(find_zero_in_third_or_fourth_wchar):
249 jz L(find_zero_in_fourth_wchar)
250 and $1 << 9 - 1, %eax
256 jnz L(match_third_wchar)
258 jnz L(match_second_wchar)
265 L(find_zero_in_fourth_wchar):
270 jnz L(match_third_or_fourth_wchar)
272 jnz L(match_second_wchar)
279 L(match_second_wchar):
284 L(match_third_or_fourth_wchar):
286 jnz L(match_fourth_wchar)
291 L(match_third_wchar):
296 L(match_fourth_wchar):
309 L(prolog_find_zero_1):
311 jz L(prolog_find_zero_in_third_or_fourth_wchar)
313 jz L(prolog_find_zero_in_second_wchar)
321 L(prolog_find_zero_in_second_wchar):
322 and $1 << 5 - 1, %eax
326 jnz L(match_second_wchar)
331 L(prolog_find_zero_in_third_or_fourth_wchar):
333 jz L(prolog_find_zero_in_fourth_wchar)
334 and $1 << 9 - 1, %eax
338 jnz L(match_third_wchar)
340 jnz L(match_second_wchar)
345 L(prolog_find_zero_in_fourth_wchar):
347 jnz L(match_third_or_fourth_wchar)
349 jnz L(match_second_wchar)