about summary refs log tree commit diff
path: root/sysdeps/powerpc/powerpc64/multiarch
diff options
context:
space:
mode:
authorAnton Blanchard <anton@ozlabs.org>2020-05-14 21:49:16 +1000
committerPaul E. Murphy <murphyp@linux.vnet.ibm.com>2020-05-18 17:08:54 -0500
commit765de945efc5d5602999b2999fe8abdf04881370 (patch)
tree8c252731dcf3fc61ae700a5dba120c1eafc8f41f /sysdeps/powerpc/powerpc64/multiarch
parent9e38f455a6c602be86b7b5a8d6523cbdcd7ec051 (diff)
downloadglibc-765de945efc5d5602999b2999fe8abdf04881370.tar.gz
glibc-765de945efc5d5602999b2999fe8abdf04881370.tar.xz
glibc-765de945efc5d5602999b2999fe8abdf04881370.zip
powerpc: Optimized rawmemchr for POWER9
This version uses vector instructions and is up to 60% faster on medium
matches and up to 90% faster on long matches, compared to the POWER7
version. A few examples:

                            __rawmemchr_power9  __rawmemchr_power7
Length   32, alignment  0:   2.27566             3.77765
Length   64, alignment  2:   2.46231             3.51064
Length 1024, alignment  0:  17.3059             32.6678
Diffstat (limited to 'sysdeps/powerpc/powerpc64/multiarch')
-rw-r--r--sysdeps/powerpc/powerpc64/multiarch/Makefile3
-rw-r--r--sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c5
-rw-r--r--sysdeps/powerpc/powerpc64/multiarch/rawmemchr-power9.S21
-rw-r--r--sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c12
4 files changed, 38 insertions, 3 deletions
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
index 61a6901f7d..fc2268f6b5 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
@@ -32,7 +32,8 @@ sysdep_routines += memcpy-power8-cached memcpy-power7 memcpy-a2 memcpy-power6 \
 		   strncase-power8
 
 ifneq (,$(filter %le,$(config-machine)))
-sysdep_routines += strcmp-power9 strncmp-power9 strcpy-power9 stpcpy-power9
+sysdep_routines += strcmp-power9 strncmp-power9 strcpy-power9 stpcpy-power9 \
+		   rawmemchr-power9
 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 8021d8d8fa..59a227ee22 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
@@ -216,6 +216,11 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 
   /* Support sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c.  */
   IFUNC_IMPL (i, name, rawmemchr,
+#ifdef __LITTLE_ENDIAN__
+	      IFUNC_IMPL_ADD (array, i, rawmemchr,
+			      hwcap2 & PPC_FEATURE2_ARCH_3_00,
+			      __rawmemchr_power9)
+#endif
 	      IFUNC_IMPL_ADD (array, i, rawmemchr,
 			      hwcap & PPC_FEATURE_HAS_VSX,
 			      __rawmemchr_power7)
diff --git a/sysdeps/powerpc/powerpc64/multiarch/rawmemchr-power9.S b/sysdeps/powerpc/powerpc64/multiarch/rawmemchr-power9.S
new file mode 100644
index 0000000000..bac0a9090e
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/multiarch/rawmemchr-power9.S
@@ -0,0 +1,21 @@
+/* Optimized rawmemchr implementation for PowerPC64/POWER9.
+   Copyright (C) 2020 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/>.  */
+
+#define RAWMEMCHR __rawmemchr_power9
+
+#include <sysdeps/powerpc/powerpc64/le/power9/rawmemchr.S>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c b/sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c
index 847157e5f0..c49c0c51ff 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c
@@ -24,13 +24,21 @@
 
 extern __typeof (__rawmemchr) __rawmemchr_ppc attribute_hidden;
 extern __typeof (__rawmemchr) __rawmemchr_power7 attribute_hidden;
+# ifdef __LITTLE_ENDIAN__
+extern __typeof (__rawmemchr) __rawmemchr_power9 attribute_hidden;
+# endif
+
 # undef __rawmemchr
 
 /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
    ifunc symbol properly.  */
 libc_ifunc_redirected (__redirect___rawmemchr, __rawmemchr,
-		       (hwcap & PPC_FEATURE_HAS_VSX)
-		       ? __rawmemchr_power7
+# ifdef __LITTLE_ENDIAN__
+		       (hwcap2 & PPC_FEATURE2_ARCH_3_00)
+		       ? __rawmemchr_power9 :
+# endif
+		         (hwcap & PPC_FEATURE_HAS_VSX)
+		         ? __rawmemchr_power7
 		       : __rawmemchr_ppc);
 
 weak_alias (__rawmemchr, rawmemchr)