From patchwork Mon Sep 30 13:51:57 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: 1169393 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-105475-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="LFLH85TG"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46hkNZ50LQz9s00 for ; Mon, 30 Sep 2019 23:52:14 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=vG40UB1J/VmFFcv0jkdqv143SE4Wz2EE46khevgJ1LRUHR7Q1dn07 REfj0EY/HyR5V7D1UirSPuQWdU/Mt/O50GfPx8jxEs481v3firqn/JxQNQUWWWDQ JFcZmXpwxEiLMGCF9SF15ziorSGO9solq/VRq4fFxq+ATUv9d7MDiM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=Vx1crlhwL23x+PJ5LaBfarDQgkc=; b=LFLH85TGQKHlLbWBGKi9AcexMAPP GV3xd9oZFC9WPu1cNPjAWtt2D5/eSZjP9ef3Kll6wb3Xr0/h3I72Zc68ZUBG9+XX WYuI6Pn7WqV6isHq8Y7NhMqGDiaxUGuO26PBCMtoXwpiAqO+Mb1+fwx1CyoYkC6U bH4bpEtOAMxS4CY= Received: (qmail 14946 invoked by alias); 30 Sep 2019 13:52:09 -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 14565 invoked by uid 89); 30 Sep 2019 13:52:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=clarke, xs, Brought X-HELO: mx0a-001b2d01.pphosted.com From: "Paul A. Clarke" To: libc-alpha@sourceware.org Cc: joseph@codesourcery.com Subject: [PATCH v2] Enable inlining issignalingf within glibc Date: Mon, 30 Sep 2019 08:51:57 -0500 Message-Id: <1569851517-5682-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. Create inline implementation for issignalingf. 2019-09-30 Paul A. Clarke * sysdeps/generic/math_private.h (GET_FLOAT_WORD, SET_FLOAT_WORD): Moved... * include/math.h (GET_FLOAT_WORD, SET_FLOAT_WORD): to here. (__issignalingf): New, copied from sysdeps/iee754/flt-32/s_issignalingf.c. --- v2: - New approach as suggested by Joseph Myers: no implementations in math_private.h, instead in include/math.h. - Moved GET_FLOAT_WORD from math_private.h to include/math.h in support. - Brought along matching SET_FLOAT_WORD for consistency. include/math.h | 53 ++++++++++++++++++++++++++++++++++++++++++ sysdeps/generic/math_private.h | 29 ----------------------- 2 files changed, 53 insertions(+), 29 deletions(-) diff --git a/include/math.h b/include/math.h index 79ebbae..a274f2b 100644 --- a/include/math.h +++ b/include/math.h @@ -54,6 +54,59 @@ libm_hidden_proto (__expf128) libm_hidden_proto (__expm1f128) # endif +#include +#include + +/* A union which permits us to convert between a float and a 32 bit + int. */ + +typedef union +{ + float value; + uint32_t word; +} ieee_float_shape_type; + +/* Get a 32 bit int from a float. */ +#ifndef GET_FLOAT_WORD +# define GET_FLOAT_WORD(i,d) \ +do { \ + ieee_float_shape_type gf_u; \ + gf_u.value = (d); \ + (i) = gf_u.word; \ +} while (0) +#endif + +/* Set a float from a 32 bit int. */ +#ifndef SET_FLOAT_WORD +# define SET_FLOAT_WORD(d,i) \ +do { \ + ieee_float_shape_type sf_u; \ + sf_u.word = (i); \ + (d) = sf_u.value; \ +} while (0) +#endif + +extern inline 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 +} + # if __HAVE_DISTINCT_FLOAT128 /* __builtin_isinf_sign is broken in GCC < 7 for float128. */ diff --git a/sysdeps/generic/math_private.h b/sysdeps/generic/math_private.h index d91b929..9296324 100644 --- a/sysdeps/generic/math_private.h +++ b/sysdeps/generic/math_private.h @@ -153,35 +153,6 @@ do { \ } while (0) #endif -/* A union which permits us to convert between a float and a 32 bit - int. */ - -typedef union -{ - float value; - uint32_t word; -} ieee_float_shape_type; - -/* Get a 32 bit int from a float. */ -#ifndef GET_FLOAT_WORD -# define GET_FLOAT_WORD(i,d) \ -do { \ - ieee_float_shape_type gf_u; \ - gf_u.value = (d); \ - (i) = gf_u.word; \ -} while (0) -#endif - -/* Set a float from a 32 bit int. */ -#ifndef SET_FLOAT_WORD -# define SET_FLOAT_WORD(d,i) \ -do { \ - ieee_float_shape_type sf_u; \ - sf_u.word = (i); \ - (d) = sf_u.value; \ -} while (0) -#endif - /* We need to guarantee an expansion of name when building ldbl-128 files as another type (e.g _Float128). */ #define mathx_hidden_def(name) hidden_def(name)