1 /* Optimized rawmemchr implementation for PowerPC64/POWER9.
2 Copyright (C) 2020-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/>. */
22 # define RAWMEMCHR __rawmemchr
25 /* Implements the function
27 int [r3] rawmemchr (void *s [r3], int c [r4])
29 The implementation can load bytes past a matching byte, but only
30 up to the next 16B boundary, so it never crosses a page. */
33 ENTRY_TOCLESS (RAWMEMCHR, 4)
38 mtvsrd v18+32,r4 /* matching char in v18 */
39 mtvsrd v19+32,r5 /* non matching char in v19 */
41 vspltb v18,v18,7 /* replicate */
42 vspltb v19,v19,7 /* replicate */
45 rldicl r9,r5,0,60 /* How many bytes to get source 16B aligned? */
47 /* Align data and fill bytes not loaded with non matching char */
52 vcmpequb. v6,v0,v18 /* 0xff if byte matches, 0x00 otherwise */
64 vcmpequb. v6,v0,v18 /* 0xff if byte matches, 0x00 otherwise */
68 vcmpequb. v6,v0,v18 /* 0xff if byte matches, 0x00 otherwise */
72 vcmpequb. v6,v0,v18 /* 0xff if byte matches, 0x00 otherwise */
76 vcmpequb. v6,v0,v18 /* 0xff if byte matches, 0x00 otherwise */
106 weak_alias (__rawmemchr,rawmemchr)
107 libc_hidden_builtin_def (__rawmemchr)