From patchwork Fri Sep 27 21:26:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul A. Clarke" X-Patchwork-Id: 34705 X-Patchwork-Delegate: joseph@codesourcery.com Received: (qmail 120295 invoked by alias); 27 Sep 2019 21:27:05 -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 119883 invoked by uid 89); 27 Sep 2019 21:27:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy= X-HELO: mx0b-001b2d01.pphosted.com From: "Paul A. Clarke" To: libc-alpha@sourceware.org Cc: tuliom@ascii.art.br Subject: [PATCH v2] Enable inlining issignalingf within glibc Date: Fri, 27 Sep 2019 16:26:55 -0500 Message-Id: <1569619615-11714-1-git-send-email-pc@us.ibm.com> From: "Paul A. Clarke" issignalingf is a very small function used in some areas where better performance (and smaller code) might be helpful. Establish a means to inline issignalingf, and use that for powerpc. 2019-09-25 Paul A. Clarke * math/s_canonicalize_template.c: Include math_private.h * math/s_fmin_template.c: Likewise. * math/s_fmax_template.c: Likewise. * math/s_fmaxmag_template.c: Likewise. * math/s_fminmag_template.c: Likewise. * sysdeps/ieee754/flt-32/s_issignalingf.c: Move code body to __issignalingf_inline. Undefine __issignalingf. Include s_issignalingf_inline.h. * sysdeps/ieee754/flt-32/s_issignalingf_inline.h: New. * sysdeps/powerpc/fpu/math_private.h: (__issignalingf): New. Include s_issignalingf_inline.h. --- v2: Oops. Forgot to include in s_signalingf.c so other arches will continue to work as before. math/s_canonicalize_template.c | 1 + math/s_fmax_template.c | 1 + math/s_fmaxmag_template.c | 1 + math/s_fmin_template.c | 2 +- math/s_fminmag_template.c | 1 + sysdeps/ieee754/flt-32/s_issignalingf.c | 20 +++-------- sysdeps/ieee754/flt-32/s_issignalingf_inline.h | 47 ++++++++++++++++++++++++++ sysdeps/powerpc/fpu/math_private.h | 3 ++ 8 files changed, 59 insertions(+), 17 deletions(-) create mode 100644 sysdeps/ieee754/flt-32/s_issignalingf_inline.h diff --git a/math/s_canonicalize_template.c b/math/s_canonicalize_template.c index 81a74a7..4689963 100644 --- a/math/s_canonicalize_template.c +++ b/math/s_canonicalize_template.c @@ -17,6 +17,7 @@ . */ #include +#include int M_DECL_FUNC (__canonicalize) (FLOAT *cx, const FLOAT *x) diff --git a/math/s_fmax_template.c b/math/s_fmax_template.c index 098c1e5..394c418 100644 --- a/math/s_fmax_template.c +++ b/math/s_fmax_template.c @@ -18,6 +18,7 @@ . */ #include +#include FLOAT M_DECL_FUNC (__fmax) (FLOAT x, FLOAT y) diff --git a/math/s_fmaxmag_template.c b/math/s_fmaxmag_template.c index 1ebe4cc..41f33aa 100644 --- a/math/s_fmaxmag_template.c +++ b/math/s_fmaxmag_template.c @@ -17,6 +17,7 @@ . */ #include +#include FLOAT M_DECL_FUNC (__fmaxmag) (FLOAT x, FLOAT y) diff --git a/math/s_fmin_template.c b/math/s_fmin_template.c index 259e280..63edcaa 100644 --- a/math/s_fmin_template.c +++ b/math/s_fmin_template.c @@ -18,7 +18,7 @@ . */ #include - +#include FLOAT M_DECL_FUNC (__fmin) (FLOAT x, FLOAT y) diff --git a/math/s_fminmag_template.c b/math/s_fminmag_template.c index 8f1b3d4..4a7a3ba 100644 --- a/math/s_fminmag_template.c +++ b/math/s_fminmag_template.c @@ -17,6 +17,7 @@ . */ #include +#include FLOAT M_DECL_FUNC (__fminmag) (FLOAT x, FLOAT y) diff --git a/sysdeps/ieee754/flt-32/s_issignalingf.c b/sysdeps/ieee754/flt-32/s_issignalingf.c index 50da641..5532474 100644 --- a/sysdeps/ieee754/flt-32/s_issignalingf.c +++ b/sysdeps/ieee754/flt-32/s_issignalingf.c @@ -19,25 +19,13 @@ #include #include #include +#include + +#undef __issignalingf int __issignalingf (float x) { - uint32_t xi; - GET_FLOAT_WORD (xi, x); -#if HIGH_ORDER_BIT_IS_SET_FOR_SNAN - /* We only have to care about the high-order bit of x's significand, because - having it set (sNaN) already makes the significand different from that - used to designate infinity. */ - return (xi & 0x7fc00000) == 0x7fc00000; -#else - /* To keep the following comparison simple, toggle the quiet/signaling bit, - so that it is set for sNaNs. This is inverse to IEEE 754-2008 (as well as - common practice for IEEE 754-1985). */ - xi ^= 0x00400000; - /* We have to compare for greater (instead of greater or equal), because x's - significand being all-zero designates infinity not NaN. */ - return (xi & 0x7fffffff) > 0x7fc00000; -#endif + return __issignalingf_inline (x); } libm_hidden_def (__issignalingf) diff --git a/sysdeps/ieee754/flt-32/s_issignalingf_inline.h b/sysdeps/ieee754/flt-32/s_issignalingf_inline.h new file mode 100644 index 0000000..130eace --- /dev/null +++ b/sysdeps/ieee754/flt-32/s_issignalingf_inline.h @@ -0,0 +1,47 @@ +/* Test for signaling NaN. + Copyright (C) 2013-2019 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 + . */ + +#ifndef _S_ISSIGNALING_INLINE_H +#define _S_ISSIGNALING_INLINE_H + +#include +#include +#include + +extern __always_inline int +__issignalingf_inline (float x) +{ + uint32_t xi; + GET_FLOAT_WORD (xi, x); +#if HIGH_ORDER_BIT_IS_SET_FOR_SNAN + /* We only have to care about the high-order bit of x's significand, because + having it set (sNaN) already makes the significand different from that + used to designate infinity. */ + return (xi & 0x7fc00000) == 0x7fc00000; +#else + /* To keep the following comparison simple, toggle the quiet/signaling bit, + so that it is set for sNaNs. This is inverse to IEEE 754-2008 (as well as + common practice for IEEE 754-1985). */ + xi ^= 0x00400000; + /* We have to compare for greater (instead of greater or equal), because x's + significand being all-zero designates infinity not NaN. */ + return (xi & 0x7fffffff) > 0x7fc00000; +#endif +} + +#endif diff --git a/sysdeps/powerpc/fpu/math_private.h b/sysdeps/powerpc/fpu/math_private.h index 9b9391a..809d77e 100644 --- a/sysdeps/powerpc/fpu/math_private.h +++ b/sysdeps/powerpc/fpu/math_private.h @@ -35,4 +35,7 @@ __ieee754_sqrtf128 (_Float128 __x) } #endif +#define __issignalingf __issignalingf_inline +#include + #endif /* _PPC_MATH_PRIVATE_H_ */