1 /* strrchr with 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/>. */
20 #if defined SHARED && !defined NOT_IN_libc
23 # include "asm-syntax.h"
26 ENTRY (__strrchr_sse2_no_bsf)
31 punpcklbw %xmm1, %xmm1
32 punpcklbw %xmm1, %xmm1
36 pshufd $0, %xmm1, %xmm1
39 /* unaligned string. */
43 /* Find where NULL is. */
45 /* Check if there is a match. */
50 jnz L(unaligned_match1)
62 jnz L(prolog_find_zero_1)
71 /* Hancle unaligned string. */
78 /* Find where NULL is. */
80 /* Check if there is a match. */
82 /* Remove the leading bytes. */
88 jnz L(unaligned_match)
99 jnz L(prolog_find_zero)
102 lea (%rdi, %rcx), %rsi
104 /* Loop start on aligned string. */
175 and $1 << 4 - 1, %rax
187 and $1 << 8 - 1, %rax
195 jz L(find_zero_high_8)
199 jnz L(FindZeroExit10)
201 jnz L(FindZeroExit11)
202 and $1 << 12 - 1, %rax
209 jnz L(FindZeroExit13)
211 jnz L(FindZeroExit14)
213 jnz L(FindZeroExit15)
214 and $1 << 16 - 1, %rax
226 and $1 << 2 - 1, %rax
232 and $1 << 3 - 1, %rax
238 and $1 << 5 - 1, %rax
244 and $1 << 6 - 1, %rax
250 and $1 << 7 - 1, %rax
256 and $1 << 9 - 1, %rax
262 and $1 << 10 - 1, %rax
268 and $1 << 11 - 1, %rax
274 and $1 << 13 - 1, %rax
280 and $1 << 14 - 1, %rax
286 and $1 << 15 - 1, %rax
292 jnz L(match_exit_high)
320 jnz L(match_exit_high_8)
331 L(match_exit_high_8):
411 L(prolog_find_zero_1):
413 jz L(prolog_find_zero_high)
416 jz L(prolog_find_zero_8)
418 jnz L(PrologFindZeroExit1)
420 jnz L(PrologFindZeroExit2)
422 jnz L(PrologFindZeroExit3)
423 and $1 << 4 - 1, %rax
429 L(prolog_find_zero_8):
431 jnz L(PrologFindZeroExit5)
433 jnz L(PrologFindZeroExit6)
435 jnz L(PrologFindZeroExit7)
436 and $1 << 8 - 1, %rax
442 L(prolog_find_zero_high):
445 jz L(prolog_find_zero_high_8)
447 jnz L(PrologFindZeroExit9)
449 jnz L(PrologFindZeroExit10)
451 jnz L(PrologFindZeroExit11)
452 and $1 << 12 - 1, %rax
458 L(prolog_find_zero_high_8):
460 jnz L(PrologFindZeroExit13)
462 jnz L(PrologFindZeroExit14)
464 jnz L(PrologFindZeroExit15)
465 and $1 << 16 - 1, %rax
471 L(PrologFindZeroExit1):
478 L(PrologFindZeroExit2):
479 and $1 << 2 - 1, %rax
485 L(PrologFindZeroExit3):
486 and $1 << 3 - 1, %rax
492 L(PrologFindZeroExit5):
493 and $1 << 5 - 1, %rax
499 L(PrologFindZeroExit6):
500 and $1 << 6 - 1, %rax
506 L(PrologFindZeroExit7):
507 and $1 << 7 - 1, %rax
513 L(PrologFindZeroExit9):
514 and $1 << 9 - 1, %rax
520 L(PrologFindZeroExit10):
521 and $1 << 10 - 1, %rax
527 L(PrologFindZeroExit11):
528 and $1 << 11 - 1, %rax
534 L(PrologFindZeroExit13):
535 and $1 << 13 - 1, %rax
541 L(PrologFindZeroExit14):
542 and $1 << 14 - 1, %rax
548 L(PrologFindZeroExit15):
549 and $1 << 15 - 1, %rax
554 END (__strrchr_sse2_no_bsf)