Blame SOURCES/glibc-rh1385004-14.patch

147e83
From f4f918430b6b74f1801ebe39a8824cc5437ba9d4 Mon Sep 17 00:00:00 2001
147e83
From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>
147e83
Date: Mon, 25 Apr 2016 09:11:02 -0500
147e83
Subject: [PATCH] powerpc: Add optimized strcspn for P8
147e83
147e83
A few minor adjustments to the P8 strspn gives us
147e83
an almost equally optimized P8 strcspn.
147e83
147e83
(cherry picked from commit 8f1b841e452dbb083112fd036033b7f4af506ba0)
147e83
---
147e83
 ChangeLog                                          | 25 ++++++++++++
147e83
 sysdeps/powerpc/powerpc64/multiarch/Makefile       |  4 +-
147e83
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |  8 ++++
147e83
 .../powerpc/powerpc64/multiarch/strcspn-power8.S   | 25 ++++++++++++
147e83
 .../powerpc/powerpc64/multiarch/strcspn-ppc64.c    | 26 +++++++++++++
147e83
 sysdeps/powerpc/powerpc64/multiarch/strcspn.c      | 35 +++++++++++++++++
147e83
 .../powerpc/powerpc64/multiarch/strspn-power8.S    | 17 +-------
147e83
 sysdeps/powerpc/powerpc64/power8/strcspn.S         | 20 ++++++++++
147e83
 sysdeps/powerpc/powerpc64/power8/strspn.S          | 45 ++++++++++++++++------
147e83
 9 files changed, 176 insertions(+), 29 deletions(-)
147e83
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strcspn-power8.S
147e83
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strcspn-ppc64.c
147e83
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strcspn.c
147e83
 create mode 100644 sysdeps/powerpc/powerpc64/power8/strcspn.S
147e83
147e83
diff --git a/ChangeLog b/ChangeLog
147e83
index 6677ea2..5537fc6 100644
147e83
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
147e83
index 7f70ceb..9ee9bc2 100644
147e83
--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
147e83
+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
147e83
@@ -20,6 +20,7 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
147e83
                   strcat-power8 strcat-power7 strcat-ppc64 \
147e83
                   strcmp-power8 strcmp-power7 strcmp-ppc64 \
147e83
                   strcpy-power8 strcpy-power7 strcpy-ppc64 \
147e83
+                  strcspn-power8 strcspn-ppc64 \
147e83
                   stpncpy-power8 stpncpy-power7 stpncpy-ppc64 \
147e83
                   strncpy-power8 strncpy-power7 strncpy-ppc64 \
147e83
                   strncat-power7 \
147e83
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
147e83
index 994e852..228891f 100644
147e83
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
147e83
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
147e83
@@ -332,6 +332,14 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
147e83
              IFUNC_IMPL_ADD (array, i, strspn, 1,
147e83
                              __strspn_ppc))
147e83
 
147e83
+  /* Support sysdeps/powerpc/powerpc64/multiarch/strcspn.c.  */
147e83
+  IFUNC_IMPL (i, name, strcspn,
147e83
+             IFUNC_IMPL_ADD (array, i, strcspn,
147e83
+                             hwcap2 & PPC_FEATURE2_ARCH_2_07,
147e83
+                             __strcspn_power8)
147e83
+             IFUNC_IMPL_ADD (array, i, strcspn, 1,
147e83
+                             __strcspn_ppc))
147e83
+
147e83
   /* Support sysdeps/powerpc/powerpc64/multiarch/strstr.c.  */
147e83
   IFUNC_IMPL (i, name, strstr,
147e83
              IFUNC_IMPL_ADD (array, i, strstr,
147e83
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcspn-power8.S b/sysdeps/powerpc/powerpc64/multiarch/strcspn-power8.S
147e83
new file mode 100644
147e83
index 0000000..25545f8
147e83
--- /dev/null
147e83
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcspn-power8.S
147e83
@@ -0,0 +1,25 @@
147e83
+/* Optimized strcspn implementation for POWER8.
147e83
+   Copyright (C) 2016 Free Software Foundation, Inc.
147e83
+   This file is part of the GNU C Library.
147e83
+
147e83
+   The GNU C Library is free software; you can redistribute it and/or
147e83
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#include <sysdep.h>
147e83
+
147e83
+#define STRSPN __strcspn_power8
147e83
+#undef libc_hidden_builtin_def
147e83
+#define libc_hidden_builtin_def(name)
147e83
+
147e83
+#include <sysdeps/powerpc/powerpc64/power8/strcspn.S>
147e83
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcspn-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/strcspn-ppc64.c
147e83
new file mode 100644
147e83
index 0000000..4c16386
147e83
--- /dev/null
147e83
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcspn-ppc64.c
147e83
@@ -0,0 +1,26 @@
147e83
+/* Default strcspn implementation for PowerPC64.
147e83
+   Copyright (C) 2016 Free Software Foundation, Inc.
147e83
+   This file is part of the GNU C Library.
147e83
+
147e83
+   The GNU C Library is free software; you can redistribute it and/or
147e83
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#define STRCSPN __strcspn_ppc
147e83
+
147e83
+#ifdef SHARED
147e83
+#  undef libc_hidden_def
147e83
+#  define libc_hidden_def(name)
147e83
+#endif
147e83
+
147e83
+#include <string/strcspn.c>
147e83
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strcspn.c b/sysdeps/powerpc/powerpc64/multiarch/strcspn.c
147e83
new file mode 100644
147e83
index 0000000..e7343ee
147e83
--- /dev/null
147e83
+++ b/sysdeps/powerpc/powerpc64/multiarch/strcspn.c
147e83
@@ -0,0 +1,35 @@
147e83
+/* Multiple versions of strcspn. PowerPC64 version.
147e83
+   Copyright (C) 2016 Free Software Foundation, Inc.
147e83
+   This file is part of the GNU C Library.
147e83
+
147e83
+   The GNU C Library is free software; you can redistribute it and/or
147e83
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#include <string.h>
147e83
+#include <shlib-compat.h>
147e83
+#include "init-arch.h"
147e83
+
147e83
+#undef strcspn
147e83
+extern __typeof (strcspn) __libc_strcspn;
147e83
+
147e83
+extern __typeof (strcspn) __strcspn_ppc attribute_hidden;
147e83
+extern __typeof (strcspn) __strcspn_power8 attribute_hidden;
147e83
+
147e83
+libc_ifunc (__libc_strcspn,
147e83
+	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
147e83
+	    ? __strcspn_power8
147e83
+	    : __strcspn_ppc);
147e83
+
147e83
+weak_alias (__libc_strcspn, strcspn)
147e83
+libc_hidden_builtin_def (strcspn)
147e83
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strspn-power8.S b/sysdeps/powerpc/powerpc64/multiarch/strspn-power8.S
147e83
index 86a4e09..27d25e0 100644
147e83
--- a/sysdeps/powerpc/powerpc64/multiarch/strspn-power8.S
147e83
+++ b/sysdeps/powerpc/powerpc64/multiarch/strspn-power8.S
147e83
@@ -18,22 +18,7 @@
147e83
 
147e83
 #include <sysdep.h>
147e83
 
147e83
-#undef EALIGN
147e83
-#define EALIGN(name, alignt, words)				\
147e83
-  .section ".text";						\
147e83
-  ENTRY_2(__strspn_power8)					\
147e83
-  .align ALIGNARG(alignt);					\
147e83
-  EALIGN_W_##words;						\
147e83
-  BODY_LABEL(__strspn_power8):					\
147e83
-  cfi_startproc;						\
147e83
-  LOCALENTRY(__strspn_power8)
147e83
-
147e83
-#undef END
147e83
-#define END(name)						\
147e83
-  cfi_endproc;							\
147e83
-  TRACEBACK(__strspn_power8)					\
147e83
-  END_2(__strspn_power8)
147e83
-
147e83
+#define STRSPN __strspn_power8
147e83
 #undef libc_hidden_builtin_def
147e83
 #define libc_hidden_builtin_def(name)
147e83
 
147e83
diff --git a/sysdeps/powerpc/powerpc64/power8/strcspn.S b/sysdeps/powerpc/powerpc64/power8/strcspn.S
147e83
new file mode 100644
147e83
index 0000000..bfc58a8
147e83
--- /dev/null
147e83
+++ b/sysdeps/powerpc/powerpc64/power8/strcspn.S
147e83
@@ -0,0 +1,20 @@
147e83
+/* Optimized strcspn implementation for PowerPC64/POWER8.
147e83
+   Copyright (C) 2016 Free Software Foundation, Inc.
147e83
+   This file is part of the GNU C Library.
147e83
+
147e83
+   The GNU C Library is free software; you can redistribute it and/or
147e83
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#define USE_AS_STRCSPN 1
147e83
+#include <sysdeps/powerpc/powerpc64/power8/strspn.S>
147e83
diff --git a/sysdeps/powerpc/powerpc64/power8/strspn.S b/sysdeps/powerpc/powerpc64/power8/strspn.S
147e83
index 0dda437..011081d 100644
147e83
--- a/sysdeps/powerpc/powerpc64/power8/strspn.S
147e83
+++ b/sysdeps/powerpc/powerpc64/power8/strspn.S
147e83
@@ -33,6 +33,21 @@
147e83
 
147e83
 #include "sysdep.h"
147e83
 
147e83
+#ifndef USE_AS_STRCSPN
147e83
+#  define USE_AS_STRCSPN 0
147e83
+#  ifndef STRSPN
147e83
+#    define STRSPN strspn
147e83
+#  endif
147e83
+#  define INITIAL_MASK 0
147e83
+#  define UPDATE_MASK(RA, RS, RB) or	RA, RS, RB
147e83
+#else
147e83
+#  ifndef STRSPN
147e83
+#    define STRSPN strcspn
147e83
+#  endif
147e83
+#  define INITIAL_MASK -1
147e83
+#  define UPDATE_MASK(RA, RS, RB) andc	RA, RS, RB
147e83
+#endif
147e83
+
147e83
 /* Simple macro to use VSX instructions in overlapping VR's.  */
147e83
 #define XXVR(insn, vrt, vra, vrb) \
147e83
 	insn 32+vrt, 32+vra, 32+vrb
147e83
@@ -53,7 +68,7 @@
147e83
 	/* This can be updated to power8 once the minimum version of
147e83
 	   binutils supports power8 and the above instructions.  */
147e83
 	.machine power7
147e83
-EALIGN(strspn, 4, 0)
147e83
+EALIGN(STRSPN, 4, 0)
147e83
 	CALL_MCOUNT 2
147e83
 
147e83
 	/* Generate useful constants for later on.  */
147e83
@@ -66,10 +81,18 @@ EALIGN(strspn, 4, 0)
147e83
 
147e83
 	/* Prepare to compute 256b mask.  */
147e83
 	addi	r4, r4, -1
147e83
-	li	r5, 0
147e83
-	li	r6, 0
147e83
-	li	r7, 0
147e83
-	li	r8, 0
147e83
+	li	r5, INITIAL_MASK
147e83
+	li	r6, INITIAL_MASK
147e83
+	li	r7, INITIAL_MASK
147e83
+	li	r8, INITIAL_MASK
147e83
+
147e83
+#if USE_AS_STRCSPN
147e83
+	/* Ensure the null character never matches by clearing ISA bit 0 in
147e83
+	   in r5 which is the bit which will check for it in the later usage
147e83
+	   of vbpermq.  */
147e83
+	srdi	r5, r5, 1
147e83
+#endif
147e83
+
147e83
 	li	r11, 1
147e83
 	sldi	r11, r11, 63
147e83
 
147e83
@@ -97,14 +120,14 @@ L(next_needle):
147e83
 
147e83
 	/* Now, or the value into the correct GPR.  */
147e83
 	bge cr1,L(needle_gt128)
147e83
-	or	r5, r5, r10	/* 0 - 63.  */
147e83
-	or	r6, r6, r12	/* 64 - 127.  */
147e83
+	UPDATE_MASK (r5, r5, r10)	/* 0 - 63.  */
147e83
+	UPDATE_MASK (r6, r6, r12)	/* 64 - 127.  */
147e83
 	b L(next_needle)
147e83
 
147e83
 	.align 4
147e83
 L(needle_gt128):
147e83
-	or	r7, r7, r10	/* 128 - 191.  */
147e83
-	or	r8, r8, r12	/* 192 - 255.  */
147e83
+	UPDATE_MASK (r7, r7, r10)	/* 128 - 191.  */
147e83
+	UPDATE_MASK (r8, r8, r12)	/* 192 - 255.  */
147e83
 	b L(next_needle)
147e83
 
147e83
 
147e83
@@ -175,5 +198,5 @@ L(done):
147e83
 	add	r3, r3, r10
147e83
 	blr
147e83
 
147e83
-END(strspn)
147e83
-libc_hidden_builtin_def (strspn)
147e83
+END(STRSPN)
147e83
+libc_hidden_builtin_def (STRSPN)
147e83
-- 
147e83
2.1.0
147e83