From patchwork Fri May 26 06:23:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajalakshmi S X-Patchwork-Id: 20592 X-Patchwork-Delegate: tuliom@linux.vnet.ibm.com Received: (qmail 50669 invoked by alias); 26 May 2017 06:25:28 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 56835 invoked by uid 89); 26 May 2017 06:24:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Rajalakshmi Srinivasaraghavan To: libc-alpha@sourceware.org Cc: Rajalakshmi Srinivasaraghavan Subject: [PATCH] powerpc: Add optimized version of [l]lrintf Date: Fri, 26 May 2017 11:53:04 +0530 X-TM-AS-MML: disable x-cbid: 17052606-0052-0000-0000-000002451540 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052606-0053-0000-0000-00000821B074 Message-Id: <1495779784-3339-1-git-send-email-raji@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-26_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=4 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705260117 This patch makes use of optimized double version of llrint for single precision as both the versions return [long] long type. 2017-05-26 Rajalakshmi Srinivasaraghavan * 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. * sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrintf.c: New file. --- .../powerpc/powerpc64/fpu/multiarch/s_llrintf.c | 46 ++++++++++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_llrint.S | 7 ++++ sysdeps/powerpc/powerpc64/fpu/s_llrintf.S | 36 ----------------- sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S | 7 ++++ sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S | 7 ++++ 5 files changed, 67 insertions(+), 36 deletions(-) create mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrintf.c delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrintf.S 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 + . */ +/* 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 +#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 39e7654..e68b378 100644 --- a/sysdeps/powerpc/powerpc64/fpu/s_llrint.S +++ b/sysdeps/powerpc/powerpc64/fpu/s_llrint.S @@ -34,6 +34,13 @@ ENTRY (__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 deleted file mode 100644 index 4050be6..0000000 --- a/sysdeps/powerpc/powerpc64/fpu/s_llrintf.S +++ /dev/null @@ -1,36 +0,0 @@ -/* 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 - . */ - -#include - -/* long long int[r3] __llrintf (float x[fp1]) */ -ENTRY (__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) - diff --git a/sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S b/sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S index 37aa690..f5853e6 100644 --- a/sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S +++ b/sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S @@ -31,6 +31,13 @@ ENTRY (__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 aa180b6..5b1f20b 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)