PowerPC: llrint/llrintf POWER8 optimization
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Tue, 18 Feb 2014 14:29:29 +0000 (09:29 -0500)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Thu, 27 Feb 2014 18:58:33 +0000 (12:58 -0600)
This patch add a optimized llrint/llrintf implementation for POWER8
using the new Move From VSR Doubleword instruction to gains some
cycles from FP to GRP register move.

ChangeLog
sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power8.S [new file with mode: 0644]
sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint.c
sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S [new file with mode: 0644]

index ee2ed4e..8912bb7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2014-02-27  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
 
+       * sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile: Add llrint power8
+       implementation.
+       * sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power8.S: New file:
+       POWER8 llrint ifunc implementation.
+       * sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint.c (__lllrint): Add
+       POWER8 implementation.
+       * sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S: New file:
+       POWER8 llrint implementation.
+
+2014-02-27  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
+
        * sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile: Add finite power8
        implementation.
        * sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power8.S: New file:
index 52bbd4b..f882478 100644 (file)
@@ -23,7 +23,8 @@ libm-sysdep_routines += s_isnan-power7 s_isnan-power6x s_isnan-power6 \
                        s_logbl-ppc64 s_modf-power5+ s_modf-ppc64 \
                        s_modff-power5+ s_modff-ppc64 e_hypot-ppc64 \
                        e_hypot-power7 e_hypotf-ppc64 e_hypotf-power7 \
-                       s_isnan-power8 s_isinf-power8 s_finite-power8
+                       s_isnan-power8 s_isinf-power8 s_finite-power8 \
+                       s_llrint-power8
 
 CFLAGS-s_logbf-power7.c = -mcpu=power7
 CFLAGS-s_logbl-power7.c = -mcpu=power7
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power8.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power8.S
new file mode 100644 (file)
index 0000000..3962b7d
--- /dev/null
@@ -0,0 +1,31 @@
+/* Round double to long int.  PowerPC64/POWER6X default version.
+   Copyright (C) 2014 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 <sysdep.h>
+#include <math_ldbl_opt.h>
+
+#undef weak_alias
+#define weak_alias(a,b)
+#undef strong_alias
+#define strong_alias(a,b)
+#undef compat_symbol
+#define compat_symbol(a,b,c,d)
+
+#define __llrint __llrint_power8
+
+#include <sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S>
index 5818b53..cf1b2e4 100644 (file)
 
 extern __typeof (__llrint) __llrint_ppc64 attribute_hidden;
 extern __typeof (__llrint) __llrint_power6x attribute_hidden;
+extern __typeof (__llrint) __llrint_power8 attribute_hidden;
 
 libc_ifunc (__llrint,
-           (hwcap & PPC_FEATURE_POWER6_EXT)
-           ? __llrint_power6x
+           (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+           ? __llrint_power8 :
+             (hwcap & PPC_FEATURE_POWER6_EXT)
+             ? __llrint_power6x
             : __llrint_ppc64);
 
 weak_alias (__llrint, llrint)
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S b/sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S
new file mode 100644 (file)
index 0000000..476d76b
--- /dev/null
@@ -0,0 +1,45 @@
+/* Round double to long int.  POWER8 PowerPC64 version.
+   Copyright (C) 2014 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 <sysdep.h>
+#include <math_ldbl_opt.h>
+
+#define MFVSRD_R3_V1  .byte 0x7c,0x23,0x00,0x66     /* mfvsrd  r3,vs1  */
+
+/* long long int[r3] __llrint (double x[fp1])  */
+ENTRY (__llrint)
+       CALL_MCOUNT 0
+       fctid   fp1,fp1
+       MFVSRD_R3_V1
+       blr
+END (__llrint)
+
+strong_alias (__llrint, __lrint)
+weak_alias (__llrint, llrint)
+weak_alias (__lrint, lrint)
+
+#ifdef NO_LONG_DOUBLE
+strong_alias (__llrint, __llrintl)
+weak_alias (__llrint, llrintl)
+strong_alias (__lrint, __lrintl)
+weak_alias (__lrint, lrintl)
+#endif
+#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
+compat_symbol (libm, __llrint, llrintl, GLIBC_2_1)
+compat_symbol (libm, __lrint, lrintl, GLIBC_2_1)
+#endif