diff options
author | Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com> | 2017-06-21 10:44:18 +0530 |
---|---|---|
committer | Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com> | 2017-06-21 10:44:18 +0530 |
commit | 99c3eb0f73f8d111efefa82a40910a75691983c6 (patch) | |
tree | 073c01d3ec8b2f42d6e6f03813fbc8c59983ed72 | |
parent | 8082d91e1c449e0cb137468b731004a5e605c8c6 (diff) | |
download | glibc-99c3eb0f73f8d111efefa82a40910a75691983c6.zip glibc-99c3eb0f73f8d111efefa82a40910a75691983c6.tar.gz glibc-99c3eb0f73f8d111efefa82a40910a75691983c6.tar.bz2 |
powerpc: Add optimized version of [l]lrintf
This patch makes use of optimized double version of llrint for single
precision as both the versions return [long] long type.
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrintf.c | 46 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/fpu/s_llrint.S | 7 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/fpu/s_llrintf.S | 37 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S | 7 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S | 7 |
6 files changed, 80 insertions, 36 deletions
@@ -1,3 +1,15 @@ +2017-06-21 Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com> + + * sysdeps/powerpc/powerpc64/fpu/s_llrint.S + (__llrintf): Define as strong alias of __llrint. + (llrintf): Define as weak alias of __llrint. + (__lrintf): Define as strong alias of __llrint. + (lrintf): Define as weak alias of __llrint. + * sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S: Likewise. + * sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S: Likewise. + * sysdeps/powerpc/powerpc64/fpu/s_llrintf.S: Remove file content. + * sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrintf.c: New file. + 2017-06-20 Zack Weinberg <zackw@panix.com> * bits/signum-generic.h: Renamed from bits/signum.h. diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrintf.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrintf.c new file mode 100644 index 0000000..330fe96 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrintf.c @@ -0,0 +1,46 @@ +/* Multiple versions of llrintf. + Copyright (C) 2017 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/>. */ +/* Redefine lrintf/__lrintf so that the compiler won't complain about the type + mismatch with the IFUNC selector in strong_alias below. */ +#define lrintf __hidden_lrintf +#define __lrintf __hidden___lrintf + +#include <math.h> +#undef lrintf +#undef __lrintf +#include "init-arch.h" + +extern __typeof (__llrintf) __llrint_ppc64 attribute_hidden; +extern __typeof (__llrintf) __llrint_power6x attribute_hidden; +extern __typeof (__llrintf) __llrint_power8 attribute_hidden; + +/* The ppc64 ABI passes float and double parameters in 64bit floating point + registers (at least up to a point) as IEEE binary64 format, so effectively + of "double" type. Both l[l]rint and l[l]rintf return long type. So these + functions have identical signatures and functionality, and can use a + single implementation. */ +libc_ifunc (__llrintf, + (hwcap2 & PPC_FEATURE2_ARCH_2_07) + ? __llrint_power8 : + (hwcap & PPC_FEATURE_POWER6_EXT) + ? __llrint_power6x + : __llrint_ppc64); + +weak_alias (__llrintf, llrintf) +strong_alias (__llrintf, __lrintf) +weak_alias (__lrintf, lrintf) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llrint.S b/sysdeps/powerpc/powerpc64/fpu/s_llrint.S index 6893285..9fe0b22 100644 --- a/sysdeps/powerpc/powerpc64/fpu/s_llrint.S +++ b/sysdeps/powerpc/powerpc64/fpu/s_llrint.S @@ -34,6 +34,13 @@ ENTRY_TOCLESS (__llrint) strong_alias (__llrint, __lrint) weak_alias (__llrint, llrint) weak_alias (__lrint, lrint) +/* The double version also works for single-precision as both float and + double parameters are passed in 64bit FPRs and both versions are expected + to return [long] long type. */ +strong_alias (__llrint, __llrintf) +weak_alias (__llrint, llrintf) +strong_alias (__lrint, __lrintf) +weak_alias (__lrint, lrintf) #ifdef NO_LONG_DOUBLE strong_alias (__llrint, __llrintl) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llrintf.S b/sysdeps/powerpc/powerpc64/fpu/s_llrintf.S index 95d437e..ba77523 100644 --- a/sysdeps/powerpc/powerpc64/fpu/s_llrintf.S +++ b/sysdeps/powerpc/powerpc64/fpu/s_llrintf.S @@ -1,36 +1 @@ -/* Round double to long int. PowerPC64 version. - Copyright (C) 2004-2017 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> - -/* long long int[r3] __llrintf (float x[fp1]) */ -ENTRY_TOCLESS (__llrintf) - CALL_MCOUNT 0 - fctid fp13,fp1 - stfd fp13,-16(r1) - nop /* Insure the following load is in a different dispatch group */ - nop /* to avoid pipe stall on POWER4&5. */ - nop - ld r3,-16(r1) - blr - END (__llrintf) - -strong_alias (__llrintf, __lrintf) -weak_alias (__llrintf, llrintf) -weak_alias (__lrintf, lrintf) - +/* __llrintf is in s_llrint.S. */ diff --git a/sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S b/sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S index f60d62f..61abdd1 100644 --- a/sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S +++ b/sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S @@ -31,6 +31,13 @@ ENTRY_TOCLESS (__llrint) strong_alias (__llrint, __lrint) weak_alias (__llrint, llrint) weak_alias (__lrint, lrint) +/* The double version also works for single-precision as both float and + double parameters are passed in 64bit FPRs and both versions are expected + to return [long] long type. */ +strong_alias (__llrint, __llrintf) +weak_alias (__llrint, llrintf) +strong_alias (__lrint, __lrintf) +weak_alias (__lrint, lrintf) #ifdef NO_LONG_DOUBLE strong_alias (__llrint, __llrintl) diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S b/sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S index 6980abc..f1476de 100644 --- a/sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S +++ b/sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S @@ -32,6 +32,13 @@ END (__llrint) strong_alias (__llrint, __lrint) weak_alias (__llrint, llrint) weak_alias (__lrint, lrint) +/* The double version also works for single-precision as both float and + double parameters are passed in 64bit FPRs and both versions are expected + to return [long] long type. */ +strong_alias (__llrint, __llrintf) +weak_alias (__llrint, llrintf) +strong_alias (__lrint, __lrintf) +weak_alias (__lrint, lrintf) #ifdef NO_LONG_DOUBLE strong_alias (__llrint, __llrintl) |