From patchwork Wed Jun 27 14:51:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 28072 Received: (qmail 47576 invoked by alias); 27 Jun 2018 14:52:14 -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 47562 invoked by uid 89); 27 Jun 2018 14:52:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=(unknown) X-HELO: EUR02-AM5-obe.outbound.protection.outlook.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/huWh+4EgJ71iRK71sxsc8XuHo74hadXnxyNbGIqaW8=; b=CgC4k3t/F43coUbcvawEvlUckuY7vIA4daF62a0GuxB5jN8kFcdF64/3alCuhkvXEmqq4K6jNG6DzWINrA+JKaBBc63+ouGtuVxe2qhJwh3XgxETVf50hXjWmBRJf1tUfHEWkFdKyfcL4uc5o9EYSt4tXmNmlXZx3uIK1EyHO4Y= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs.Nagy@arm.com; Cc: nd@arm.com To: GNU C Library From: Szabolcs Nagy Subject: [PATCH 1/6] Use uint32_t sign in single precision math error handling, functions Message-ID: Date: Wed, 27 Jun 2018 15:51:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 Return-Path: szabolcs.nagy@arm.com Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) Ideally sign should be bool, but sometimes (e.g. in powf) it's more efficient to pass a non-zero value than 1 to indicate that the sign should be set. The fixed size int is less ambigous than unsigned long. 2018-06-27 Szabolcs Nagy * sysdeps/ieee754/flt-32/e_powf.c (__powf): Use uint32_t. (exp2f_inline): Likewise. * sysdeps/ieee754/flt-32/math_config.h (__math_oflowf): Likewise. (__math_uflowf): Likewise. (__math_may_uflowf): Likewise. (__math_divzerof): Likewise. (__math_invalidf): Likewise. * sysdeps/ieee754/flt-32/math_errf.c (xflowf): Likewise. (__math_oflowf): Likewise. (__math_uflowf): Likewise. (__math_may_uflowf): Likewise. (__math_divzerof): Likewise. (__math_invalidf): Likewise. --- sysdeps/ieee754/flt-32/e_powf.c | 4 ++-- sysdeps/ieee754/flt-32/math_config.h | 8 ++++---- sysdeps/ieee754/flt-32/math_errf.c | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sysdeps/ieee754/flt-32/e_powf.c b/sysdeps/ieee754/flt-32/e_powf.c index 90661e2216..ece83f0dd2 100644 --- a/sysdeps/ieee754/flt-32/e_powf.c +++ b/sysdeps/ieee754/flt-32/e_powf.c @@ -84,7 +84,7 @@ log2_inline (uint32_t ix) (in case of fast toint intrinsics) or not. The unscaled xd must be in [-1021,1023], sign_bias sets the sign of the result. */ static inline double_t -exp2_inline (double_t xd, unsigned long sign_bias) +exp2_inline (double_t xd, uint32_t sign_bias) { uint64_t ki, ski, t; /* double_t for better performance on targets with FLT_EVAL_METHOD==2. */ @@ -143,7 +143,7 @@ zeroinfnan (uint32_t ix) float __powf (float x, float y) { - unsigned long sign_bias = 0; + uint32_t sign_bias = 0; uint32_t ix, iy; ix = asuint (x); diff --git a/sysdeps/ieee754/flt-32/math_config.h b/sysdeps/ieee754/flt-32/math_config.h index c4def9bbc1..9c4ef30173 100644 --- a/sysdeps/ieee754/flt-32/math_config.h +++ b/sysdeps/ieee754/flt-32/math_config.h @@ -102,10 +102,10 @@ issignalingf_inline (float x) #define NOINLINE __attribute__ ((noinline)) -attribute_hidden float __math_oflowf (unsigned long); -attribute_hidden float __math_uflowf (unsigned long); -attribute_hidden float __math_may_uflowf (unsigned long); -attribute_hidden float __math_divzerof (unsigned long); +attribute_hidden float __math_oflowf (uint32_t); +attribute_hidden float __math_uflowf (uint32_t); +attribute_hidden float __math_may_uflowf (uint32_t); +attribute_hidden float __math_divzerof (uint32_t); attribute_hidden float __math_invalidf (float); /* Shared between expf, exp2f and powf. */ diff --git a/sysdeps/ieee754/flt-32/math_errf.c b/sysdeps/ieee754/flt-32/math_errf.c index 7d58c0b855..5bc7ac6ef5 100644 --- a/sysdeps/ieee754/flt-32/math_errf.c +++ b/sysdeps/ieee754/flt-32/math_errf.c @@ -33,14 +33,14 @@ with_errnof (float y, int e) /* NOINLINE prevents fenv semantics breaking optimizations. */ NOINLINE static float -xflowf (unsigned long sign, float y) +xflowf (uint32_t sign, float y) { y = (sign ? -y : y) * y; return with_errnof (y, ERANGE); } attribute_hidden float -__math_uflowf (unsigned long sign) +__math_uflowf (uint32_t sign) { return xflowf (sign, 0x1p-95f); } @@ -49,20 +49,20 @@ __math_uflowf (unsigned long sign) /* Underflows to zero in some non-nearest rounding mode, setting errno is valid even if the result is non-zero, but in the subnormal range. */ attribute_hidden float -__math_may_uflowf (unsigned long sign) +__math_may_uflowf (uint32_t sign) { return xflowf (sign, 0x1.4p-75f); } #endif attribute_hidden float -__math_oflowf (unsigned long sign) +__math_oflowf (uint32_t sign) { return xflowf (sign, 0x1p97f); } attribute_hidden float -__math_divzerof (unsigned long sign) +__math_divzerof (uint32_t sign) { float y = 0; return with_errnof ((sign ? -1 : 1) / y, ERANGE);