arrfab / rpms / glibc

Forked from rpms/glibc 4 years ago
Clone

Blame SOURCES/glibc-rh1240351-2.patch

147e83
    Backport of:
147e83
    commit 487972aea52004f604c2878c8c9d3e77670f2c32
147e83
    Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
147e83
    Date:   Thu Feb 27 09:43:51 2014 -0600
147e83
    
147e83
        PowerPC: Optimized isnan/isnanf for POWER8
147e83
    
147e83
        This patch add a optimized isnan/isnanf implementation for POWER8
147e83
        using the new Move From VSR Doubleword instruction to gains some
147e83
        cycles from FP to GRP register move.
147e83
    
147e83
        ChangeLog:
147e83
    	2014-02-27  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
147e83
    
147e83
    	* sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h (INIT_ARCH):
147e83
    	Add hwcap2 initialization.
147e83
    	* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile: Add isnan power8
147e83
    	implementation.
147e83
    	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power8.S: New file:
147e83
    	POWER8 isnan ifunc implementation.
147e83
    	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c (__isnan): Add
147e83
    	POWER8 implementation.
147e83
    	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnanf.c (__isnanf):
147e83
    	Likewise.
147e83
    	* sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S: New file:
147e83
    	POWER8 isnan implementation.
147e83
    	* sysdeps/powerpc/powerpc64/power8/fpu/s_isnanf.S: New file.
147e83
147e83
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h b/sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h
147e83
index 51a34f2..72d720d 100644
147e83
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h
147e83
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h
147e83
@@ -36,6 +36,7 @@
147e83
    and fills the previous ones.  */
147e83
 #define INIT_ARCH() \
147e83
   unsigned long int hwcap = __GLRO(dl_hwcap); 			\
147e83
+  unsigned long int __attribute__((unused)) hwcap2 = __GLRO(dl_hwcap2); \
147e83
   if (hwcap & PPC_FEATURE_ARCH_2_06)				\
147e83
     hwcap |= PPC_FEATURE_ARCH_2_05 |				\
147e83
 	     PPC_FEATURE_POWER5_PLUS |				\
147e83
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
147e83
index 1e04f21..4cd1c5d 100644
147e83
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
147e83
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
147e83
@@ -4,7 +4,7 @@ sysdep_routines += s_isnan-power7 s_isnan-power6x s_isnan-power6 \
147e83
                   s_copysign-ppc64 s_finite-power7 s_finite-ppc64 \
147e83
                   s_finitef-ppc64 s_isinff-ppc64 s_isinf-power7 \
147e83
                   s_isinf-ppc64 s_modf-power5+ s_modf-ppc64 \
147e83
-                  s_modff-power5+ s_modff-ppc64
147e83
+                  s_modff-power5+ s_modff-ppc64 s_isnan-power8
147e83
 
147e83
 libm-sysdep_routines += s_isnan-power7 s_isnan-power6x s_isnan-power6 \
147e83
                        s_isnan-power5 s_isnan-ppc64 s_llround-power6x \
147e83
@@ -21,7 +21,8 @@ libm-sysdep_routines += s_isnan-power7 s_isnan-power6x s_isnan-power6 \
147e83
                        s_logbl-power7 s_logb-ppc64 s_logbf-ppc64 \
147e83
                        s_logbl-ppc64 s_modf-power5+ s_modf-ppc64 \
147e83
                        s_modff-power5+ s_modff-ppc64 e_hypot-ppc64 \
147e83
-                       e_hypot-power7 e_hypotf-ppc64 e_hypotf-power7
147e83
+                       e_hypot-power7 e_hypotf-ppc64 e_hypotf-power7 \
147e83
+                       s_isnan-power8
147e83
 
147e83
 CFLAGS-s_logbf-power7.c = -mcpu=power7
147e83
 CFLAGS-s_logbl-power7.c = -mcpu=power7
147e83
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power8.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power8.S
147e83
new file mode 100644
147e83
index 0000000..c176d5a
147e83
--- /dev/null
147e83
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan-power8.S
147e83
@@ -0,0 +1,33 @@
147e83
+/* isnan().  PowerPC64/POWER7 version.
147e83
+   Copyright (C) 2014 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
+#include <math_ldbl_opt.h>
147e83
+
147e83
+#undef hidden_def
147e83
+#define hidden_def(name)
147e83
+#undef weak_alias
147e83
+#define weak_alias(name, alias)
147e83
+#undef strong_alias
147e83
+#define strong_alias(name, alias)
147e83
+#undef compat_symbol
147e83
+#define compat_symbol(lib, name, symbol, ver)
147e83
+
147e83
+#define __isnan __isnan_power8
147e83
+
147e83
+#include <sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S>
147e83
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c
147e83
index 0de833e..65a5ca0 100644
147e83
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c
147e83
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c
147e83
@@ -26,16 +26,19 @@ extern __typeof (__isnan) __isnan_power5 attribute_hidden;
147e83
 extern __typeof (__isnan) __isnan_power6 attribute_hidden;
147e83
 extern __typeof (__isnan) __isnan_power6x attribute_hidden;
147e83
 extern __typeof (__isnan) __isnan_power7 attribute_hidden;
147e83
+extern __typeof (__isnan) __isnan_power8 attribute_hidden;
147e83
 
147e83
 libc_ifunc (__isnan,
147e83
-	    (hwcap & PPC_FEATURE_ARCH_2_06)
147e83
-	    ? __isnan_power7 :
147e83
-	      (hwcap & PPC_FEATURE_POWER6_EXT)
147e83
+	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
147e83
+	    ? __isnan_power8 :
147e83
+	      (hwcap & PPC_FEATURE_ARCH_2_06)
147e83
+	      ? __isnan_power7 :
147e83
+		(hwcap & PPC_FEATURE_POWER6_EXT)
147e83
 		? __isnan_power6x :
147e83
-		(hwcap & PPC_FEATURE_ARCH_2_05)
147e83
-		  ? __isnan_power6 :
147e83
-		  (hwcap & PPC_FEATURE_POWER5)
147e83
-		    ? __isnan_power5
147e83
+		  (hwcap & PPC_FEATURE_ARCH_2_05)
147e83
+		    ? __isnan_power6 :
147e83
+		    (hwcap & PPC_FEATURE_POWER5)
147e83
+		      ? __isnan_power5
147e83
             : __isnan_ppc64);
147e83
 
147e83
 weak_alias (__isnan, isnan)
147e83
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnanf.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnanf.c
147e83
index b237455..eb68a50 100644
147e83
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnanf.c
147e83
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnanf.c
147e83
@@ -25,16 +25,19 @@ extern __typeof (__isnanf) __isnan_power5 attribute_hidden;
147e83
 extern __typeof (__isnanf) __isnan_power6 attribute_hidden;
147e83
 extern __typeof (__isnanf) __isnan_power6x attribute_hidden;
147e83
 extern __typeof (__isnanf) __isnan_power7 attribute_hidden;
147e83
+extern __typeof (__isnanf) __isnan_power8 attribute_hidden;
147e83
 
147e83
 libc_ifunc (__isnanf,
147e83
-	    (hwcap & PPC_FEATURE_ARCH_2_06)
147e83
-	    ? __isnan_power7 :
147e83
-	      (hwcap & PPC_FEATURE_POWER6_EXT)
147e83
-		? __isnan_power6x :
147e83
-		(hwcap & PPC_FEATURE_ARCH_2_05)
147e83
-		  ? __isnan_power6 :
147e83
-		  (hwcap & PPC_FEATURE_POWER5)
147e83
-		    ? __isnan_power5
147e83
+	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
147e83
+	    ? __isnan_power8 :
147e83
+	      (hwcap & PPC_FEATURE_ARCH_2_06)
147e83
+	      ? __isnan_power7 :
147e83
+		(hwcap & PPC_FEATURE_POWER6_EXT)
147e83
+		  ? __isnan_power6x :
147e83
+		  (hwcap & PPC_FEATURE_ARCH_2_05)
147e83
+		    ? __isnan_power6 :
147e83
+		    (hwcap & PPC_FEATURE_POWER5)
147e83
+		      ? __isnan_power5
147e83
             : __isnan_ppc64);
147e83
 
147e83
 weak_alias (__isnanf, isnanf)
147e83
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S b/sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S
147e83
new file mode 100644
147e83
index 0000000..c1ca9a5
147e83
--- /dev/null
147e83
+++ b/sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S
147e83
@@ -0,0 +1,53 @@
147e83
+/* isnan().  PowerPC64/POWER8 version.
147e83
+   Copyright (C) 2014 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
+#include <math_ldbl_opt.h>
147e83
+
147e83
+#define MFVSRD_R3_V1  .byte 0x7c,0x23,0x00,0x66     /* mfvsrd  r3,vs1  */
147e83
+
147e83
+/* int [r3] __isnan([f1] x)  */
147e83
+
147e83
+EALIGN (__isnan, 4, 0)
147e83
+	CALL_MCOUNT 0
147e83
+	MFVSRD_R3_V1
147e83
+	lis     r9,0x7ff0
147e83
+	clrldi  r3,r3,1       /* r3 = r3 & 0x8000000000000000  */
147e83
+	rldicr  r9,r9,32,31   /* r9 = (r9 << 32) & 0xffffffff  */
147e83
+	subf    r3,r3,r9
147e83
+	rldicl  r3,r3,1,63
147e83
+	blr
147e83
+END (__isnan)
147e83
+
147e83
+/* It turns out that the 'double' version will also always work for
147e83
+   single-precision.  */
147e83
+strong_alias (__isnan, __isnanf)
147e83
+hidden_def (__isnanf)
147e83
+weak_alias (__isnanf, isnanf)
147e83
+
147e83
+#ifdef NO_LONG_DOUBLE
147e83
+strong_alias (__isnan, __isnanl)
147e83
+weak_alias (__isnan, isnanl)
147e83
+#endif
147e83
+
147e83
+#ifndef IS_IN_libm
147e83
+# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
147e83
+compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
147e83
+compat_symbol (libc, isnan, isnanl, GLIBC_2_0);
147e83
+# endif
147e83
+#endif
147e83
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/s_isnanf.S b/sysdeps/powerpc/powerpc64/power8/fpu/s_isnanf.S
147e83
new file mode 100644
147e83
index 0000000..b48c85e
147e83
--- /dev/null
147e83
+++ b/sysdeps/powerpc/powerpc64/power8/fpu/s_isnanf.S
147e83
@@ -0,0 +1 @@
147e83
+/* This function uses the same code as s_isnan.S.  */