diff options
author | raji <raji@oc4354787705.ibm.com> | 2016-06-14 14:51:16 +0530 |
---|---|---|
committer | raji <raji@oc4354787705.ibm.com> | 2016-06-14 14:51:16 +0530 |
commit | c8376f3e07602aaef9cb843bb73cb5f2b860634a (patch) | |
tree | 9ba0710f8398c1299412ddefbf9a01c23c6a43ea /sysdeps/powerpc/powerpc64/multiarch | |
parent | a2ae1696f7c6cf269b3a734bce4d9d3620745854 (diff) | |
download | glibc-c8376f3e07602aaef9cb843bb73cb5f2b860634a.tar.gz glibc-c8376f3e07602aaef9cb843bb73cb5f2b860634a.tar.xz glibc-c8376f3e07602aaef9cb843bb73cb5f2b860634a.zip |
powerpc: strcasecmp/strncasecmp optmization for power8
This implementation utilizes vectors to improve performance compared to current byte by byte implementation for POWER7. The performance improvement is upto 4x. This patch is tested on powerpc64 and powerpc64le.
Diffstat (limited to 'sysdeps/powerpc/powerpc64/multiarch')
9 files changed, 132 insertions, 49 deletions
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile index 9ee9bc2044..e3ac285e00 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/Makefile +++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile @@ -21,7 +21,9 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \ memmove-power7 memmove-ppc64 wordcopy-ppc64 bcopy-ppc64 \ strncpy-power8 strstr-power7 strstr-ppc64 \ strspn-power8 strspn-ppc64 strcspn-power8 strcspn-ppc64 \ - strlen-power8 strcasestr-power8 strcasestr-ppc64 + strlen-power8 strcasestr-power8 strcasestr-ppc64 \ + strcasecmp-ppc64 strcasecmp-power8 strncase-ppc64 \ + strncase-power8 CFLAGS-strncase-power7.c += -mcpu=power7 -funroll-loops CFLAGS-strncase_l-power7.c += -mcpu=power7 -funroll-loops diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c index a0dc8ad4c4..9f6bd7cd98 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c +++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c @@ -204,6 +204,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, /* Support sysdeps/powerpc/powerpc64/multiarch/strcasecmp.c. */ IFUNC_IMPL (i, name, strcasecmp, IFUNC_IMPL_ADD (array, i, strcasecmp, + hwcap2 & PPC_FEATURE2_ARCH_2_07, + __strcasecmp_power8) + IFUNC_IMPL_ADD (array, i, strcasecmp, hwcap & PPC_FEATURE_HAS_VSX, __strcasecmp_power7) IFUNC_IMPL_ADD (array, i, strcasecmp, 1, __strcasecmp_ppc)) @@ -219,6 +222,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, /* Support sysdeps/powerpc/powerpc64/multiarch/strncase.c. */ IFUNC_IMPL (i, name, strncasecmp, IFUNC_IMPL_ADD (array, i, strncasecmp, + hwcap2 & PPC_FEATURE2_ARCH_2_07, + __strncasecmp_power8) + IFUNC_IMPL_ADD (array, i, strncasecmp, hwcap & PPC_FEATURE_HAS_VSX, __strncasecmp_power7) IFUNC_IMPL_ADD (array, i, strncasecmp, 1, __strncasecmp_ppc)) diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcasecmp-power7.S b/sysdeps/powerpc/powerpc64/multiarch/strcasecmp-power7.S index 013dc62867..99cd7bd4df 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/strcasecmp-power7.S +++ b/sysdeps/powerpc/powerpc64/multiarch/strcasecmp-power7.S @@ -1,4 +1,4 @@ -/* Optimized strcasecmp implementation foOWER7. +/* Optimized strcasecmp implementation for POWER7. Copyright (C) 2013-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -18,21 +18,7 @@ #include <sysdep.h> -#undef ENTRY -#define ENTRY(name) \ - .section ".text"; \ - ENTRY_2(__strcasecmp_power7) \ - .align ALIGNARG(2); \ - BODY_LABEL(__strcasecmp_power7): \ - cfi_startproc; \ - LOCALENTRY(__strcasecmp_power7) - -#undef END -#define END(name) \ - cfi_endproc; \ - TRACEBACK(__strcasecmp_power7) \ - END_2(__strcasecmp_power7) - +#define __strcasecmp __strcasecmp_power7 #undef weak_alias #define weak_alias(name, alias) diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcasecmp-power8.S b/sysdeps/powerpc/powerpc64/multiarch/strcasecmp-power8.S new file mode 100644 index 0000000000..492047a603 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/multiarch/strcasecmp-power8.S @@ -0,0 +1,28 @@ +/* Optimized strcasecmp implementation for POWER8. + Copyright (C) 2016 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 __strcasecmp __strcasecmp_power8 +#undef weak_alias +#define weak_alias(name, alias) + +#undef libc_hidden_builtin_def +#define libc_hidden_builtin_def(name) + +#include <sysdeps/powerpc/powerpc64/power8/strcasecmp.S> diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcasecmp-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/strcasecmp-ppc64.c new file mode 100644 index 0000000000..6318b4a428 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/multiarch/strcasecmp-ppc64.c @@ -0,0 +1,21 @@ +/* Multiarch strcasecmp for PPC64. + Copyright (C) 2016 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/>. */ + +#define strcasecmp __strcasecmp_ppc + +#include <string/strcasecmp.c> diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcasecmp.c b/sysdeps/powerpc/powerpc64/multiarch/strcasecmp.c index 1f22336d49..5ec6885dfc 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/strcasecmp.c +++ b/sysdeps/powerpc/powerpc64/multiarch/strcasecmp.c @@ -1,4 +1,4 @@ -/* Multiple versions of strcasecmp. +/* Multiple versions of strcasecmp Copyright (C) 2013-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -16,25 +16,21 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#if IS_IN (libc) -# include <string.h> -# define strcasecmp __strcasecmp_ppc -extern __typeof (__strcasecmp) __strcasecmp_ppc attribute_hidden; -extern __typeof (__strcasecmp) __strcasecmp_power7 attribute_hidden; -#endif +#include <string.h> +#include <shlib-compat.h> +#include "init-arch.h" -#include <string/strcasecmp.c> -#undef strcasecmp +extern __typeof (__strcasecmp) __libc_strcasecmp; -#if IS_IN (libc) -# include <shlib-compat.h> -# include "init-arch.h" +extern __typeof (__strcasecmp) __strcasecmp_ppc attribute_hidden; +extern __typeof (__strcasecmp) __strcasecmp_power7 attribute_hidden; +extern __typeof (__strcasecmp) __strcasecmp_power8 attribute_hidden; -extern __typeof (__strcasecmp) __libc_strcasecmp; libc_ifunc (__libc_strcasecmp, - (hwcap & PPC_FEATURE_HAS_VSX) - ? __strcasecmp_power7 - : __strcasecmp_ppc); + (hwcap2 & PPC_FEATURE2_ARCH_2_07) + ? __strcasecmp_power8: + (hwcap & PPC_FEATURE_HAS_VSX) + ? __strcasecmp_power7 + : __strcasecmp_ppc); weak_alias (__libc_strcasecmp, strcasecmp) -#endif diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncase-power8.S b/sysdeps/powerpc/powerpc64/multiarch/strncase-power8.S new file mode 100644 index 0000000000..01a63b5ba4 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/multiarch/strncase-power8.S @@ -0,0 +1,28 @@ +/* Optimized strncasecmp implementation for POWER8. + Copyright (C) 2016 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 __strncasecmp __strncasecmp_power8 +#undef weak_alias +#define weak_alias(name, alias) + +#undef libc_hidden_builtin_def +#define libc_hidden_builtin_def(name) + +#include <sysdeps/powerpc/powerpc64/power8/strncase.S> diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncase-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/strncase-ppc64.c new file mode 100644 index 0000000000..c245d775b9 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/multiarch/strncase-ppc64.c @@ -0,0 +1,21 @@ +/* Multiarch strncasecmp for PPC64. + Copyright (C) 2016 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/>. */ + +#define strncasecmp __strncasecmp_ppc + +#include <string/strncase.c> diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncase.c b/sysdeps/powerpc/powerpc64/multiarch/strncase.c index 2729fcea83..0bfb25c381 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/strncase.c +++ b/sysdeps/powerpc/powerpc64/multiarch/strncase.c @@ -16,26 +16,21 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#if IS_IN (libc) -# include <string.h> -# define strncasecmp __strncasecmp_ppc -extern __typeof (__strncasecmp) __strncasecmp_ppc attribute_hidden; -extern __typeof (__strncasecmp) __strncasecmp_power7 attribute_hidden; -#endif +#include <string.h> +#include <shlib-compat.h> +#include "init-arch.h" -#include <string/strncase.c> -#undef strncasecmp +extern __typeof (__strncasecmp) __libc_strncasecmp; -#if IS_IN (libc) -# include <shlib-compat.h> -# include "init-arch.h" +extern __typeof (__strncasecmp) __strncasecmp_ppc attribute_hidden; +extern __typeof (__strncasecmp) __strncasecmp_power7 attribute_hidden; +extern __typeof (__strncasecmp) __strncasecmp_power8 attribute_hidden; -/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle - ifunc symbol properly. */ -extern __typeof (__strncasecmp) __libc_strncasecmp; libc_ifunc (__libc_strncasecmp, + (hwcap2 & PPC_FEATURE2_ARCH_2_07) + ? __strncasecmp_power8: (hwcap & PPC_FEATURE_HAS_VSX) ? __strncasecmp_power7 : __strncasecmp_ppc); + weak_alias (__libc_strncasecmp, strncasecmp) -#endif |