1 /* strrchr SSE2 without bsf and bsr
2 Copyright (C) 2011-2024 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)
35 # define ENTRANCE PUSH(%edi);
36 # define RETURN POP(%edi); ret; CFI_PUSH(%edi);
42 ENTRY (__strrchr_sse2)
46 movd STR2(%esp), %xmm1
50 punpcklbw %xmm1, %xmm1
51 punpcklbw %xmm1, %xmm1
55 pshufd $0, %xmm1, %xmm1
58 /* unaligned string. */
62 /* Find where NULL is. */
64 /* Check if there is a match. */
69 jnz L(unaligned_match1)
88 jnz L(prolog_find_zero_1)
103 /* Hancle unaligned string. */
110 /* Find where NULL is. */
112 /* Check if there is a match. */
114 /* Remove the leading bytes. */
120 jnz L(unaligned_match)
137 jnz L(prolog_find_zero)
143 lea (%edi, %ecx), %esi
145 /* Loop start on aligned string. */
234 and $1 << 4 - 1, %eax
252 and $1 << 8 - 1, %eax
266 jz L(find_zero_high_8)
270 jnz L(FindZeroExit10)
272 jnz L(FindZeroExit11)
273 and $1 << 12 - 1, %eax
286 jnz L(FindZeroExit13)
288 jnz L(FindZeroExit14)
290 jnz L(FindZeroExit15)
291 and $1 << 16 - 1, %eax
315 and $1 << 2 - 1, %eax
327 and $1 << 3 - 1, %eax
339 and $1 << 5 - 1, %eax
351 and $1 << 6 - 1, %eax
363 and $1 << 7 - 1, %eax
375 and $1 << 9 - 1, %eax
387 and $1 << 10 - 1, %eax
399 and $1 << 11 - 1, %eax
411 and $1 << 13 - 1, %eax
423 and $1 << 14 - 1, %eax
435 and $1 << 15 - 1, %eax
444 jnz L(match_exit_high)
472 jnz L(match_exit_high_8)
483 L(match_exit_high_8):
563 L(prolog_find_zero_1):
565 jz L(prolog_find_zero_high)
568 jz L(prolog_find_zero_8)
570 jnz L(PrologFindZeroExit1)
572 jnz L(PrologFindZeroExit2)
574 jnz L(PrologFindZeroExit3)
575 and $1 << 4 - 1, %eax
581 L(prolog_find_zero_8):
583 jnz L(PrologFindZeroExit5)
585 jnz L(PrologFindZeroExit6)
587 jnz L(PrologFindZeroExit7)
588 and $1 << 8 - 1, %eax
594 L(prolog_find_zero_high):
597 jz L(prolog_find_zero_high_8)
599 jnz L(PrologFindZeroExit9)
601 jnz L(PrologFindZeroExit10)
603 jnz L(PrologFindZeroExit11)
604 and $1 << 12 - 1, %eax
610 L(prolog_find_zero_high_8):
612 jnz L(PrologFindZeroExit13)
614 jnz L(PrologFindZeroExit14)
616 jnz L(PrologFindZeroExit15)
617 and $1 << 16 - 1, %eax
623 L(PrologFindZeroExit1):
630 L(PrologFindZeroExit2):
631 and $1 << 2 - 1, %eax
637 L(PrologFindZeroExit3):
638 and $1 << 3 - 1, %eax
644 L(PrologFindZeroExit5):
645 and $1 << 5 - 1, %eax
651 L(PrologFindZeroExit6):
652 and $1 << 6 - 1, %eax
658 L(PrologFindZeroExit7):
659 and $1 << 7 - 1, %eax
665 L(PrologFindZeroExit9):
666 and $1 << 9 - 1, %eax
672 L(PrologFindZeroExit10):
673 and $1 << 10 - 1, %eax
679 L(PrologFindZeroExit11):
680 and $1 << 11 - 1, %eax
686 L(PrologFindZeroExit13):
687 and $1 << 13 - 1, %eax
693 L(PrologFindZeroExit14):
694 and $1 << 14 - 1, %eax
700 L(PrologFindZeroExit15):
701 and $1 << 15 - 1, %eax