Skip to content

Commit

Permalink
powerpc: Optimized strncmp for POWER8/PPC64
Browse files Browse the repository at this point in the history
This patch adds an optimized POWER8 strncmp.  The implementation focus
on speeding up unaligned cases follwing the ideas of power8 strcmp.

The algorithm first check the initial 16 bytes, then align the first
function source and uses unaligned loads on second argument only.
Aditional checks for page boundaries are done for unaligned cases
(where sources alignment are different).
  • Loading branch information
Adhemerval Zanella committed Jan 13, 2015
1 parent 72607db commit d3b00f4
Show file tree
Hide file tree
Showing 7 changed files with 387 additions and 7 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2015-01-13 Adhemerval Zanella <azanella@linux.vnet.ibm.com>

* sysdeps/powerpc/powerpc64/multiarch/strncmp-power8.S: New file.
* sysdeps/powerpc/powerpc64/power8/strncmp.S: New file.
* sysdeps/powerpc/powerpc64/multiarch/Makefile [sysdep_routines]: Add
strncmp-power8 object.
* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Add __strncmp_power8 implementation.
* sysdeps/powerpc/powerpc64/multiarch/strncmp.c (strncmp): Likewise.
* NEWS: Update.

2015-01-13 Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
Adhemerval Zanella <azanella@linux.vnet.ibm.com>

Expand Down
4 changes: 2 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Version 2.21
17744, 17745, 17746, 17747, 17748, 17775, 17777, 17780, 17781, 17782,
17791, 17793, 17796, 17797, 17803, 17806, 17834

* Optimized strcpy, stpcpy, strncpy, stpncpy, and strcmp implementations for
powerpc64/powerpc64le.
* Optimized strcpy, stpcpy, strncpy, stpncpy, strcmp, and strncmp
implementations for powerpc64/powerpc64le.
Implemented by Adhemerval Zanella (IBM).

* Added support for TSX lock elision of pthread mutexes on powerpc32, powerpc64
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 @@ -7,8 +7,9 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
memrchr-power7 memrchr-ppc64 rawmemchr-power7 \
rawmemchr-ppc64 strlen-power7 strlen-ppc64 strnlen-power7 \
strnlen-ppc64 strcasecmp-power7 strcasecmp_l-power7 \
strncase-power7 strncase_l-power7 strncmp-power7 \
strncmp-power4 strncmp-ppc64 strchr-power7 strchr-ppc64 \
strncase-power7 strncase_l-power7 \
strncmp-power8 strncmp-power7 strncmp-power4 strncmp-ppc64 \
strchr-power7 strchr-ppc64 \
strchrnul-power7 strchrnul-ppc64 wcschr-power7 \
wcschr-power6 wcschr-ppc64 wcsrchr-power7 wcsrchr-power6 \
wcsrchr-ppc64 wcscpy-power7 wcscpy-power6 wcscpy-ppc64 \
Expand Down
2 changes: 2 additions & 0 deletions sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,

/* Support sysdeps/powerpc/powerpc64/multiarch/strncmp.c. */
IFUNC_IMPL (i, name, strncmp,
IFUNC_IMPL_ADD (array, i, strncmp, hwcap2 & PPC_FEATURE2_ARCH_2_07,
__strncmp_power8)
IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_HAS_VSX,
__strncmp_power7)
IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_POWER4,
Expand Down
40 changes: 40 additions & 0 deletions sysdeps/powerpc/powerpc64/multiarch/strncmp-power8.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* Copyright (C) 2015 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>

#undef EALIGN
#define EALIGN(name,alignt,words) \
.section ".text"; \
ENTRY_2(__strncmp_power8) \
.align ALIGNARG(alignt); \
EALIGN_W_##words; \
BODY_LABEL(__strncmp_power8): \
cfi_startproc; \
LOCALENTRY(__strncmp_power8)

#undef END
#define END(name) \
cfi_endproc; \
TRACEBACK(__strncmp_power8) \
END_2(__strncmp_power8)


#undef libc_hidden_builtin_def
#define libc_hidden_builtin_def(name)

#include <sysdeps/powerpc/powerpc64/power8/strncmp.S>
9 changes: 6 additions & 3 deletions sysdeps/powerpc/powerpc64/multiarch/strncmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
extern __typeof (strncmp) __strncmp_ppc attribute_hidden;
extern __typeof (strncmp) __strncmp_power4 attribute_hidden;
extern __typeof (strncmp) __strncmp_power7 attribute_hidden;
extern __typeof (strncmp) __strncmp_power8 attribute_hidden;

/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
ifunc symbol properly. */
libc_ifunc (strncmp,
(hwcap & PPC_FEATURE_HAS_VSX)
? __strncmp_power7 :
(hwcap & PPC_FEATURE_POWER4)
(hwcap2 & PPC_FEATURE2_ARCH_2_07)
? __strncmp_power8 :
(hwcap & PPC_FEATURE_HAS_VSX)
? __strncmp_power7 :
(hwcap & PPC_FEATURE_POWER4)
? __strncmp_power4
: __strncmp_ppc);
#endif
Loading

0 comments on commit d3b00f4

Please sign in to comment.