From 1ad8950a3ea4056ed343d681b5146f4b4aa27e10 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Tue, 18 Feb 2014 09:29:29 -0500 Subject: [PATCH] PowerPC: llrint/llrintf POWER8 optimization 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 | 11 ++++++ sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile | 3 +- .../powerpc64/fpu/multiarch/s_llrint-power8.S | 31 +++++++++++++++ sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint.c | 7 +++- sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S | 45 ++++++++++++++++++++++ 5 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power8.S create mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S diff --git a/ChangeLog b/ChangeLog index ee2ed4e..8912bb7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2014-02-27 Adhemerval Zanella + * 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 + * sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile: Add finite power8 implementation. * sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power8.S: New file: diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile index 52bbd4b..f882478 100644 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile +++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile @@ -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 index 0000000..3962b7d --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint-power8.S @@ -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 + . */ + +#include +#include + +#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 diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint.c index 5818b53..cf1b2e4 100644 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint.c +++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint.c @@ -30,10 +30,13 @@ 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 index 0000000..476d76b --- /dev/null +++ b/sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S @@ -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 + . */ + +#include +#include + +#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 -- 2.7.4