[v2] powerpc64le: Optimized strcat for POWER10

Message ID 20241112063555.27287-1-bmahi496@linux.ibm.com
State Accepted
Headers
Series [v2] powerpc64le: Optimized strcat for POWER10 |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed

Commit Message

Mahesh Bodapati Nov. 12, 2024, 6:35 a.m. UTC
  With the new optimized strcpy and strlen implementation, this patch adds
an optimized strcat which uses it along with default implementation at
strings.
---
 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
  

Comments

Peter Bergner Nov. 19, 2024, 9:33 p.m. UTC | #1
On 11/12/24 12:35 AM, Mahesh Bodapati wrote:
> With the new optimized strcpy and strlen implementation, this patch adds
> an optimized strcat which uses it along with default implementation at
> strings.
> ---
>  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

This LGTM, modulo some small whitespace issues which I cleaned up
and the copyright date for the new file should just be 2024 which
I fixed.

Thanks and pushed.

Peter
  

Patch

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..8d653ab500
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcat-power10.c
@@ -0,0 +1,33 @@ 
+/* Copyright (C) 2015-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
+   <https://www.gnu.org/licenses/ >.  */
+
+#ifdef __LITTLE_ENDIAN__
+#include <string.h>
+
+#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 <string/strcat.c>
+#endif
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcat.c b/sysdeps/powerpc/powerpc64/multiarch/strcat.c
index 27e636e0ff..20daeff38b 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