]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
powerpc64le: Optimized strcat for POWER10
authorMahesh Bodapati <bmahi496@linux.ibm.com>
Tue, 19 Nov 2024 20:57:35 +0000 (15:57 -0500)
committerPeter Bergner <bergner@linux.ibm.com>
Tue, 19 Nov 2024 20:59:15 +0000 (15:59 -0500)
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
sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
sysdeps/powerpc/powerpc64/multiarch/strcat-power10.c [new file with mode: 0644]
sysdeps/powerpc/powerpc64/multiarch/strcat.c

index b847c1904989e27e18cfc05eb7cbb23d392b00a1..dc7c5b14ee615f1004dcb8563ff1d16b4252f87f 100644 (file)
@@ -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
index 2bb47d352778d404a1ac78eaca8dbca532b46c60..9a44ddb90e2f7c1fc16835045da9dac5ba70493d 100644 (file)
@@ -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 (file)
index 0000000..ed7a20c
--- /dev/null
@@ -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
+   <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
index 27e636e0ff342b2887feba725055c90bf3afe175..9daec8ae6ea670010561d451bb80ac85a503cad5 100644 (file)
 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