Skip to content

Commit

Permalink
powerpc: Optimize memrchr for power8
Browse files Browse the repository at this point in the history
Vectorized loops are used for sizes greater than 32B to improve
performance over power7 optimization.  This shows as an average
of 25% improvement depending on the position of search
character.  The performance is same for shorter strings.
  • Loading branch information
RajalakshmiS committed Oct 2, 2017
1 parent 397286e commit 59ba2d2
Show file tree
Hide file tree
Showing 6 changed files with 380 additions and 3 deletions.
12 changes: 12 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
2017-10-02 Rajalakshmi Srinivasaraghavan <[email protected]>

* sysdeps/powerpc/powerpc64/multiarch/Makefile
(sysdep_routines): Add memrchr_power8.
* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
(memrchr): Add __memrchr_power8 to list of memrchr functions.
* sysdeps/powerpc/powerpc64/multiarch/memrchr-power8.S:
New file.
* sysdeps/powerpc/powerpc64/multiarch/memrchr.c
(memrchr): Add __memrchr_power8 to ifunc list.
* sysdeps/powerpc/powerpc64/power8/memrchr.S: New file.

2017-10-01 H.J. Lu <[email protected]>

[BZ #18822]
Expand Down
5 changes: 3 additions & 2 deletions sysdeps/powerpc/powerpc64/multiarch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
memset-ppc64 memset-power8 \
mempcpy-power7 mempcpy-ppc64 \
memchr-power8 memchr-power7 memchr-ppc64 \
memrchr-power7 memrchr-ppc64 rawmemchr-power7 \
rawmemchr-ppc64 strlen-power7 strlen-ppc64 \
memrchr-power8 memrchr-power7 memrchr-ppc64 \
rawmemchr-power7 rawmemchr-ppc64 \
strlen-power7 strlen-ppc64 \
strnlen-power8 strnlen-power7 strnlen-ppc64 \
strcasecmp-power7 strcasecmp_l-power7 \
strncase-power7 strncase_l-power7 \
Expand Down
3 changes: 3 additions & 0 deletions sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,

/* Support sysdeps/powerpc/powerpc64/multiarch/memrchr.c. */
IFUNC_IMPL (i, name, memrchr,
IFUNC_IMPL_ADD (array, i, memrchr,
hwcap2 & PPC_FEATURE2_ARCH_2_07,
__memrchr_power8)
IFUNC_IMPL_ADD (array, i, memrchr,
hwcap & PPC_FEATURE_HAS_VSX,
__memrchr_power7)
Expand Down
28 changes: 28 additions & 0 deletions sysdeps/powerpc/powerpc64/multiarch/memrchr-power8.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* Optimized memrchr implementation for PowerPC64/POWER8.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#include <sysdep.h>

#define MEMRCHR __memrchr_power8

#undef libc_hidden_builtin_def
#define libc_hidden_builtin_def(name)
#undef weak_alias
#define weak_alias(name,alias)

#include <sysdeps/powerpc/powerpc64/power8/memrchr.S>
14 changes: 13 additions & 1 deletion sysdeps/powerpc/powerpc64/multiarch/memrchr-ppc64.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#include <sysdeps/powerpc/powerpc32/power4/multiarch/memrchr-ppc32.c>
#include <string.h>

#define MEMRCHR __memrchr_ppc

#undef weak_alias
#define weak_alias(a, b)

#undef libc_hidden_builtin_def
#define libc_hidden_builtin_def(name)

extern __typeof (memrchr) __memrchr_ppc attribute_hidden;

#include <string/memrchr.c>
Loading

0 comments on commit 59ba2d2

Please sign in to comment.