From 3ef7e4286155b70816c2393414b935751a39d685 Mon Sep 17 00:00:00 2001 From: Mahesh Bodapati Date: Tue, 19 Nov 2024 15:57:35 -0500 Subject: [PATCH] powerpc64le: Optimized strcat for POWER10 This patch adds an optimized strcat which makes use of the default strcat function which calls the Power10 strcpy and strlen routines. --- sysdeps/powerpc/powerpc64/multiarch/Makefile | 5 +-- .../powerpc64/multiarch/ifunc-impl-list.c | 5 +++ .../powerpc64/multiarch/strcat-power10.c | 33 +++++++++++++++++++ sysdeps/powerpc/powerpc64/multiarch/strcat.c | 22 +++++++++---- 4 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strcat-power10.c diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile index b847c19049..dc7c5b14ee 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/Makefile +++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile @@ -34,8 +34,9 @@ ifneq (,$(filter %le,$(config-machine))) sysdep_routines += memchr-power10 memcmp-power10 memcpy-power10 \ memmove-power10 memset-power10 rawmemchr-power9 \ rawmemchr-power10 strcmp-power9 strcmp-power10 \ - strncmp-power9 strncmp-power10 strcpy-power9 stpcpy-power9 \ - strlen-power9 strncpy-power9 stpncpy-power9 strlen-power10 + strncmp-power9 strncmp-power10 strcpy-power9 strcat-power10 \ + stpcpy-power9 strlen-power9 strncpy-power9 stpncpy-power9 \ + strlen-power10 endif 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 2bb47d3527..9a44ddb90e 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c +++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c @@ -406,6 +406,11 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, /* Support sysdeps/powerpc/powerpc64/multiarch/strcat.c. */ IFUNC_IMPL (i, name, strcat, +#ifdef __LITTLE_ENDIAN__ + IFUNC_IMPL_ADD (array, i, strcat, hwcap2 & PPC_FEATURE2_ARCH_3_1 + && hwcap & PPC_FEATURE_HAS_VSX, + __strcat_power10) +#endif IFUNC_IMPL_ADD (array, i, strcat, hwcap2 & PPC_FEATURE2_ARCH_2_07 && hwcap & PPC_FEATURE_HAS_VSX, diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcat-power10.c b/sysdeps/powerpc/powerpc64/multiarch/strcat-power10.c new file mode 100644 index 0000000000..ed7a20ccf7 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/multiarch/strcat-power10.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2024 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 + . */ + +#ifdef __LITTLE_ENDIAN__ +#include + +#define STRCAT __strcat_power10 + +#undef libc_hidden_def +#define libc_hidden_def(name) + +extern typeof (strcpy) __strcpy_power9; +extern typeof (strlen) __strlen_power10; + +#define strcpy __strcpy_power9 +#define strlen __strlen_power10 + +#include +#endif diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcat.c b/sysdeps/powerpc/powerpc64/multiarch/strcat.c index 27e636e0ff..9daec8ae6e 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/strcat.c +++ b/sysdeps/powerpc/powerpc64/multiarch/strcat.c @@ -25,14 +25,22 @@ extern __typeof (strcat) __strcat_ppc attribute_hidden; extern __typeof (strcat) __strcat_power7 attribute_hidden; extern __typeof (strcat) __strcat_power8 attribute_hidden; +#ifdef __LITTLE_ENDIAN__ +extern __typeof (strcat) __strcat_power10 attribute_hidden; +#endif # undef strcat libc_ifunc_redirected (__redirect_strcat, strcat, - (hwcap2 & PPC_FEATURE2_ARCH_2_07 - && hwcap & PPC_FEATURE_HAS_VSX) - ? __strcat_power8 - : (hwcap & PPC_FEATURE_ARCH_2_06 - && hwcap & PPC_FEATURE_HAS_VSX) - ? __strcat_power7 - : __strcat_ppc); +#ifdef __LITTLE_ENDIAN__ + (hwcap2 & PPC_FEATURE2_ARCH_3_1 + && hwcap & PPC_FEATURE_HAS_VSX) + ? __strcat_power10 : +#endif + (hwcap2 & PPC_FEATURE2_ARCH_2_07 + && hwcap & PPC_FEATURE_HAS_VSX) + ? __strcat_power8 + : (hwcap & PPC_FEATURE_ARCH_2_06 + && hwcap & PPC_FEATURE_HAS_VSX) + ? __strcat_power7 + : __strcat_ppc); #endif