1 /* strrchr SSE2 without bsf and bsr
2 Copyright (C) 2011 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)
36 # define ENTRANCE PUSH(%edi);
37 # define RETURN POP(%edi); ret; CFI_PUSH(%edi);
43 ENTRY (__strrchr_sse2)
47 movd STR2(%esp), %xmm1
51 punpcklbw %xmm1, %xmm1
52 punpcklbw %xmm1, %xmm1
56 pshufd $0, %xmm1, %xmm1
59 /* unaligned string. */
63 /* Find where NULL is. */
65 /* Check if there is a match. */
70 jnz L(unaligned_match1)
89 jnz L(prolog_find_zero_1)
104 /* Hancle unaligned string. */
111 /* Find where NULL is. */
113 /* Check if there is a match. */
115 /* Remove the leading bytes. */
121 jnz L(unaligned_match)
138 jnz L(prolog_find_zero)
144 lea (%edi, %ecx), %esi
146 /* Loop start on aligned string. */
235 and $1 << 4 - 1, %eax
253 and $1 << 8 - 1, %eax
267 jz L(find_zero_high_8)
271 jnz L(FindZeroExit10)
273 jnz L(FindZeroExit11)
274 and $1 << 12 - 1, %eax
287 jnz L(FindZeroExit13)
289 jnz L(FindZeroExit14)
291 jnz L(FindZeroExit15)
292 and $1 << 16 - 1, %eax
316 and $1 << 2 - 1, %eax
328 and $1 << 3 - 1, %eax
340 and $1 << 5 - 1, %eax
352 and $1 << 6 - 1, %eax
364 and $1 << 7 - 1, %eax
376 and $1 << 9 - 1, %eax
388 and $1 << 10 - 1, %eax
400 and $1 << 11 - 1, %eax
412 and $1 << 13 - 1, %eax
424 and $1 << 14 - 1, %eax
436 and $1 << 15 - 1, %eax
445 jnz L(match_exit_high)
473 jnz L(match_exit_high_8)
484 L(match_exit_high_8):
564 L(prolog_find_zero_1):
566 jz L(prolog_find_zero_high)
569 jz L(prolog_find_zero_8)
571 jnz L(PrologFindZeroExit1)
573 jnz L(PrologFindZeroExit2)
575 jnz L(PrologFindZeroExit3)
576 and $1 << 4 - 1, %eax
582 L(prolog_find_zero_8):
584 jnz L(PrologFindZeroExit5)
586 jnz L(PrologFindZeroExit6)
588 jnz L(PrologFindZeroExit7)
589 and $1 << 8 - 1, %eax
595 L(prolog_find_zero_high):
598 jz L(prolog_find_zero_high_8)
600 jnz L(PrologFindZeroExit9)
602 jnz L(PrologFindZeroExit10)
604 jnz L(PrologFindZeroExit11)
605 and $1 << 12 - 1, %eax
611 L(prolog_find_zero_high_8):
613 jnz L(PrologFindZeroExit13)
615 jnz L(PrologFindZeroExit14)
617 jnz L(PrologFindZeroExit15)
618 and $1 << 16 - 1, %eax
624 L(PrologFindZeroExit1):
631 L(PrologFindZeroExit2):
632 and $1 << 2 - 1, %eax
638 L(PrologFindZeroExit3):
639 and $1 << 3 - 1, %eax
645 L(PrologFindZeroExit5):
646 and $1 << 5 - 1, %eax
652 L(PrologFindZeroExit6):
653 and $1 << 6 - 1, %eax
659 L(PrologFindZeroExit7):
660 and $1 << 7 - 1, %eax
666 L(PrologFindZeroExit9):
667 and $1 << 9 - 1, %eax
673 L(PrologFindZeroExit10):
674 and $1 << 10 - 1, %eax
680 L(PrologFindZeroExit11):
681 and $1 << 11 - 1, %eax
687 L(PrologFindZeroExit13):
688 and $1 << 13 - 1, %eax
694 L(PrologFindZeroExit14):
695 and $1 << 14 - 1, %eax
701 L(PrologFindZeroExit15):
702 and $1 << 15 - 1, %eax