]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
powerpc: Optimized strncat for POWER8
authorRajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
Thu, 13 Apr 2017 05:59:20 +0000 (11:29 +0530)
committerRajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
Thu, 13 Apr 2017 05:59:20 +0000 (11:29 +0530)
With new optimized strnlen for POWER8 [1], this patch adds
strncat for power8 to make use of optimized strlen and strnlen.
This is faster than POWER7 current implementation for larger strings.

Tested on powerpc64 and powerpc64le.

[1] https://sourceware.org/ml/libc-alpha/2017-03/msg00491.html

* sysdeps/powerpc/powerpc64/multiarch/Makefile (sysdep_routines): Add
strncat-power8.
* sysdeps/powerpc/powerpc64/multiarch/strncat.c (strncat): Add
__strncat_power8 to ifunc list.
* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
(strncat): Add __strncat_power8 to list of strncat functions.
* sysdeps/powerpc/powerpc64/multiarch/strncat-power8.c: New file.

ChangeLog
sysdeps/powerpc/powerpc64/multiarch/Makefile
sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
sysdeps/powerpc/powerpc64/multiarch/strncat-power8.c [new file with mode: 0644]
sysdeps/powerpc/powerpc64/multiarch/strncat.c

index 52b8d410a00a3f20408580dc306fbce1e8e026da..b310214c74ce2674ef8f40873a8383d58cae9d5b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2017-04-13  Rajalakshmi Srinivasaraghavan  <raji@linux.vnet.ibm.com>
+
+       * sysdeps/powerpc/powerpc64/multiarch/Makefile (sysdep_routines): Add
+       strncat-power8.
+       * sysdeps/powerpc/powerpc64/multiarch/strncat.c (strncat): Add
+       __strncat_power8 to ifunc list.
+       * sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+       (strncat): Add __strncat_power8 to list of strncat functions.
+       * sysdeps/powerpc/powerpc64/multiarch/strncat-power8.c: New file.
+
 2017-04-11  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
        [BZ #21270]
index 38233a72c0918f929094b194830080a1fa610875..0eb3d0710d28b1ec79b62f0fb8cb503b27b5c72b 100644 (file)
@@ -15,7 +15,8 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
                   strchrnul-power8 strchrnul-power7 strchrnul-ppc64 \
                   strcpy-power8 strcpy-power7 strcpy-ppc64 stpcpy-power8 \
                   stpcpy-power7 stpcpy-ppc64 \
-                  strrchr-power7 strrchr-ppc64 strncat-power7 strncat-ppc64 \
+                  strrchr-power7 strrchr-ppc64 \
+                  strncat-power8 strncat-power7 strncat-ppc64 \
                   strncpy-power7 strncpy-ppc64 \
                   stpncpy-power8 stpncpy-power7 stpncpy-ppc64 \
                   strcmp-power9 strcmp-power8 strcmp-power7 strcmp-ppc64 \
index 30a013320b4661258436c856f3b5f81f39a0e18a..bddec1a6f8048fead5a8b392bde1a9717a6b2711 100644 (file)
@@ -291,6 +291,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 
   /* Support sysdeps/powerpc/powerpc64/multiarch/strncat.c.  */
   IFUNC_IMPL (i, name, strncat,
+             IFUNC_IMPL_ADD (array, i, strncat,
+                             hwcap2 & PPC_FEATURE2_ARCH_2_07,
+                             __strncat_power8)
              IFUNC_IMPL_ADD (array, i, strncat,
                              hwcap & PPC_FEATURE_HAS_VSX,
                              __strncat_power7)
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncat-power8.c b/sysdeps/powerpc/powerpc64/multiarch/strncat-power8.c
new file mode 100644 (file)
index 0000000..1ec1259
--- /dev/null
@@ -0,0 +1,31 @@
+/* Copyright (C) 2017 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 <string.h>
+
+#define STRNCAT __strncat_power8
+
+extern __typeof (strncat) __strncat_power8 attribute_hidden;
+extern __typeof (strlen) __strlen_power8 attribute_hidden;
+extern __typeof (strnlen) __strnlen_power8 attribute_hidden;
+extern __typeof (memcpy) __memcpy_power7 attribute_hidden;
+
+#define strlen    __strlen_power8
+#define __strnlen __strnlen_power8
+#define memcpy    __memcpy_power7
+
+#include <string/strncat.c>
index 1aa5c11ea41e2780e1834e947f9cfaf11bea2082..ba3fe5cac470b9af30f9f7f19ba41e0fef2e1e15 100644 (file)
 
 extern __typeof (strncat) __strncat_ppc attribute_hidden;
 extern __typeof (strncat) __strncat_power7 attribute_hidden;
+extern __typeof (strncat) __strncat_power8 attribute_hidden;
 
 libc_ifunc (strncat,
-            (hwcap & PPC_FEATURE_HAS_VSX)
+           (hwcap & PPC_FEATURE2_ARCH_2_07)
+           ? __strncat_power8
+           : (hwcap & PPC_FEATURE_HAS_VSX)
             ? __strncat_power7
             : __strncat_ppc);
 #endif