From patchwork Mon Dec 9 12:45:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206170 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107827-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="clnagsV1"; 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 47WjdB2F4cz9sNH for ; Mon, 9 Dec 2019 23:47:10 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=Y/VQ1dOqnAirPDSvqOkxQAE1sMfIONB J15cz58ZCakjLEA8jLB/HO74WqElSi96SERLQnxdJ3p2gEif04/UAUk/RN8K9d2d soMA/Ks7gruCUgLimTUpXVhiz77Yuuc8/eIYhFKt/AOjeJLVoVVh4h3LoYmU4nPf dQNBlLYZFj0c= 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:in-reply-to:references :message-id; s=default; bh=sRaXYX5zj2HiC0nFtnbWenjWBnU=; b=clnag sV1IvdEulYgILVX3pKcKSY9LpXYKg1N6SGTqQYXQeFZLsj0Yd2l8rosPnvznJ4y0 cZL83AT2Grgmncx1B0ZbsD0q2lOkVE43YU1BiY1gIMuUp3kewXozSUODUQ9qffi7 /+pfKn1kDW8ce+eGHMnFqLIIF89JDSOWlvUygA= Received: (qmail 79484 invoked by alias); 9 Dec 2019 12:47:04 -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 79472 invoked by uid 89); 9 Dec 2019 12:47:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=freely, granted, 1.8, HX-Languages-Length:4930 X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 01/18] Always use wordsize-64 version of s_nearbyint.c. Date: Mon, 9 Dec 2019 13:45:51 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0008-0000-0000-0000033F1B22 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0009-0000-0000-00004A5E47B6 Message-Id: <1575895568-26473-2-git-send-email-stli@linux.ibm.com> This patch replaces s_nearbyint.c in sysdeps/dbl-64 with the one in sysdeps/dbl-64/wordsize-64 and removes the latter one. The code is not changed except changes in code style. Also adjusted the include path in x86_64 file. --- sysdeps/ieee754/dbl-64/s_nearbyint.c | 38 +++++------ .../ieee754/dbl-64/wordsize-64/s_nearbyint.c | 65 ------------------- sysdeps/x86_64/fpu/multiarch/s_nearbyint-c.c | 2 +- 3 files changed, 17 insertions(+), 88 deletions(-) delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c diff --git a/sysdeps/ieee754/dbl-64/s_nearbyint.c b/sysdeps/ieee754/dbl-64/s_nearbyint.c index 4ce570ac7f..c261885c5a 100644 --- a/sysdeps/ieee754/dbl-64/s_nearbyint.c +++ b/sysdeps/ieee754/dbl-64/s_nearbyint.c @@ -10,10 +10,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_rint.c,v 1.8 1995/05/10 20:48:04 jtc Exp $"; -#endif - /* * rint(x) * Return x rounded to integral value according to the prevailing @@ -32,44 +28,42 @@ static char rcsid[] = "$NetBSD: s_rint.c,v 1.8 1995/05/10 20:48:04 jtc Exp $"; #include static const double - TWO52[2] = { - 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ - -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ +TWO52[2] = { + 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ + -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ }; double __nearbyint (double x) { fenv_t env; - int32_t i0, j0, sx; - double w, t; - GET_HIGH_WORD (i0, x); - sx = (i0 >> 31) & 1; - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; - if (j0 < 52) + int64_t i0, sx; + int32_t j0; + EXTRACT_WORDS64 (i0, x); + sx = (i0 >> 63) & 1; + j0 = ((i0 >> 52) & 0x7ff) - 0x3ff; + if (__glibc_likely (j0 < 52)) { if (j0 < 0) { libc_feholdexcept (&env); - w = TWO52[sx] + math_opt_barrier (x); - t = w - TWO52[sx]; + double w = TWO52[sx] + math_opt_barrier (x); + double t = w - TWO52[sx]; math_force_eval (t); libc_fesetenv (&env); - GET_HIGH_WORD (i0, t); - SET_HIGH_WORD (t, (i0 & 0x7fffffff) | (sx << 31)); - return t; + return copysign (t, x); } } else { if (j0 == 0x400) - return x + x; /* inf or NaN */ + return x + x; /* inf or NaN */ else - return x; /* x is integral */ + return x; /* x is integral */ } libc_feholdexcept (&env); - w = TWO52[sx] + math_opt_barrier (x); - t = w - TWO52[sx]; + double w = TWO52[sx] + math_opt_barrier (x); + double t = w - TWO52[sx]; math_force_eval (t); libc_fesetenv (&env); return t; diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c deleted file mode 100644 index 92fa72af59..0000000000 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c +++ /dev/null @@ -1,65 +0,0 @@ -/* Adapted for use as nearbyint by Ulrich Drepper . */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* - * rint(x) - * Return x rounded to integral value according to the prevailing - * rounding mode. - * Method: - * Using floating addition. - * Exception: - * Inexact flag raised if x not equal to rint(x). - */ - -#include -#include -#include -#include -#include -#include - -static const double -TWO52[2]={ - 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ - -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ -}; - -double -__nearbyint(double x) -{ - fenv_t env; - int64_t i0,sx; - int32_t j0; - EXTRACT_WORDS64(i0,x); - sx = (i0>>63)&1; - j0 = ((i0>>52)&0x7ff)-0x3ff; - if(__builtin_expect(j0<52, 1)) { - if(j0<0) { - libc_feholdexcept (&env); - double w = TWO52[sx] + math_opt_barrier (x); - double t = w-TWO52[sx]; - math_force_eval (t); - libc_fesetenv (&env); - return copysign (t, x); - } - } else { - if(j0==0x400) return x+x; /* inf or NaN */ - else return x; /* x is integral */ - } - libc_feholdexcept (&env); - double w = TWO52[sx] + math_opt_barrier (x); - double t = w-TWO52[sx]; - math_force_eval (t); - libc_fesetenv (&env); - return t; -} -libm_alias_double (__nearbyint, nearbyint) diff --git a/sysdeps/x86_64/fpu/multiarch/s_nearbyint-c.c b/sysdeps/x86_64/fpu/multiarch/s_nearbyint-c.c index f897a2a6a6..4fdeb11291 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_nearbyint-c.c +++ b/sysdeps/x86_64/fpu/multiarch/s_nearbyint-c.c @@ -1,3 +1,3 @@ #undef __nearbyint #define __nearbyint __nearbyint_c -#include +#include From patchwork Mon Dec 9 12:45:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107828-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="DqV71OPx"; 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 47Wjdl1gn9z9sNH for ; Mon, 9 Dec 2019 23:47:39 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=TsqhbQzZXkSHpvgdtOZDT05P2bqNlUS WYRcK2XGhMY+hADSaL9k6kr2UDKn76OVuJ39xmDHOBlMWOli54wZ4bxTW9L+wcMM MyIsD8hvJUGT8FGotdTSRszEUeUJi8Q53QBX/YF8Tnblzc7t4QbJTXViogSL0w3L 4uu3+8ZhtNq0= 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:in-reply-to:references :message-id; s=default; bh=TV1jyfhO1wKqxIw4H3TV5UTJdP8=; b=DqV71 OPxYVnJX93I4AR5hb2+YlsPzA5qPr5qK+lNuWE2YodlAn4s7ih1A57j3whVHfESN hxruc4HPUy/oF1LXYXdZLd7r2EgzPmbRcodMVZkwxMeVHW8BeTnUI0sX/JQVto7I qcHzS5IaG1SRKFVcNw1wpuDg2AGBwZ/VhFmQ74= Received: (qmail 81563 invoked by alias); 9 Dec 2019 12:47:20 -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 81500 invoked by uid 89); 9 Dec 2019 12:47:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=51, 5.1 X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 02/18] Always use wordsize-64 version of s_rint.c. Date: Mon, 9 Dec 2019 13:45:52 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-4275-0000-0000-0000038D4068 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-4276-0000-0000-000038A0ED76 Message-Id: <1575895568-26473-3-git-send-email-stli@linux.ibm.com> This patch replaces s_rint.c in sysdeps/dbl-64 with the one in sysdeps/dbl-64/wordsize-64 and removes the latter one. The code is not changed except changes in code style. Also adjusted the include path in x86_64 file. --- sysdeps/ieee754/dbl-64/s_rint.c | 32 ++++++------ sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c | 58 --------------------- sysdeps/x86_64/fpu/multiarch/s_rint-c.c | 2 +- 3 files changed, 17 insertions(+), 75 deletions(-) delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c diff --git a/sysdeps/ieee754/dbl-64/s_rint.c b/sysdeps/ieee754/dbl-64/s_rint.c index dd01a84176..66c9196473 100644 --- a/sysdeps/ieee754/dbl-64/s_rint.c +++ b/sysdeps/ieee754/dbl-64/s_rint.c @@ -1,4 +1,3 @@ -/* @(#)s_rint.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -26,38 +25,39 @@ #include static const double - TWO52[2] = { - 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ - -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ +TWO52[2] = { + 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ + -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ }; double __rint (double x) { - int32_t i0, j0, sx; - double w, t; - GET_HIGH_WORD (i0, x); - sx = (i0 >> 31) & 1; - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + int64_t i0, sx; + int32_t j0; + EXTRACT_WORDS64 (i0, x); + sx = (i0 >> 63) & 1; + j0 = ((i0 >> 52) & 0x7ff) - 0x3ff; if (j0 < 52) { if (j0 < 0) { - w = TWO52[sx] + x; - t = w - TWO52[sx]; - GET_HIGH_WORD (i0, t); - SET_HIGH_WORD (t, (i0 & 0x7fffffff) | (sx << 31)); + double w = TWO52[sx] + x; + double t = w - TWO52[sx]; + EXTRACT_WORDS64 (i0, t); + INSERT_WORDS64 (t, (i0 & UINT64_C (0x7fffffffffffffff)) + | (sx << 63)); return t; } } else { if (j0 == 0x400) - return x + x; /* inf or NaN */ + return x + x; /* inf or NaN */ else - return x; /* x is integral */ + return x; /* x is integral */ } - w = TWO52[sx] + x; + double w = TWO52[sx] + x; return w - TWO52[sx]; } #ifndef __rint diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c deleted file mode 100644 index 378b73a544..0000000000 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* - * rint(x) - * Return x rounded to integral value according to the prevailing - * rounding mode. - * Method: - * Using floating addition. - * Exception: - * Inexact flag raised if x not equal to rint(x). - */ - -#define NO_MATH_REDIRECT -#include -#include -#include - -static const double -TWO52[2]={ - 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ - -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ -}; - -double -__rint(double x) -{ - int64_t i0,sx; - int32_t j0; - EXTRACT_WORDS64(i0,x); - sx = (i0>>63)&1; - j0 = ((i0>>52)&0x7ff)-0x3ff; - if(j0<52) { - if(j0<0) { - double w = TWO52[sx]+x; - double t = w-TWO52[sx]; - EXTRACT_WORDS64(i0,t); - INSERT_WORDS64(t,(i0&UINT64_C(0x7fffffffffffffff))|(sx<<63)); - return t; - } - } else { - if(j0==0x400) return x+x; /* inf or NaN */ - else return x; /* x is integral */ - } - double w = TWO52[sx]+x; - return w-TWO52[sx]; -} -#ifndef __rint -libm_alias_double (__rint, rint) -#endif diff --git a/sysdeps/x86_64/fpu/multiarch/s_rint-c.c b/sysdeps/x86_64/fpu/multiarch/s_rint-c.c index 162a630ff9..b010150f52 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_rint-c.c +++ b/sysdeps/x86_64/fpu/multiarch/s_rint-c.c @@ -1,3 +1,3 @@ #undef __rint #define __rint __rint_c -#include +#include From patchwork Mon Dec 9 12:45:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206174 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107829-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="PWRjv8j+"; 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 47Wjfc5Hhgz9sNH for ; Mon, 9 Dec 2019 23:48:24 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=K65mOCV7yhnwtcMGzvBLy9Q7J08+u0n C5y5iu7jNMfEaX7LKUnL9SXnKZUj4CxcwASbO22AppovHNhD0PfXg9amZnuE1GXW Pljv2hnxlDDcEirhr1RqRsmbvEX9A7ee6Ogoi/m3CiiMd4Hz5p8hZ7FUm68U9KD+ kLXoAt4SSdMY= 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:in-reply-to:references :message-id; s=default; bh=POVxjJ5lh2mj9u88ssdtJiJjNvs=; b=PWRjv 8j+nJL3AvXprBKTK3lthqXLoGaLtdnkHFRbgFEoto5ZEzAqx3O+q80HIMu6VeV0/ CQvcvdb9QFTi/WVLwVLPl5dXiIwKXehsrdUt7ctFpIP0laXruNewZdnVLxKVLAsi 5jm45/WOYBnjlwSiXhFPiXgf0PbposXiwOpjoM= Received: (qmail 85202 invoked by alias); 9 Dec 2019 12:48:18 -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 85172 invoked by uid 89); 9 Dec 2019 12:48:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 03/18] Always use wordsize-64 version of s_floor.c. Date: Mon, 9 Dec 2019 13:45:53 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0016-0000-0000-000002D31FEB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0017-0000-0000-00003335316B Message-Id: <1575895568-26473-4-git-send-email-stli@linux.ibm.com> This patch replaces s_floor.c in sysdeps/dbl-64 with the one in sysdeps/dbl-64/wordsize-64 and removes the latter one. The code is not changed except changes in code style. Also adjusted the include path in x86_64 and sparc64 files. --- sysdeps/ieee754/dbl-64/s_floor.c | 93 +++++++++---------- sysdeps/ieee754/dbl-64/wordsize-64/s_floor.c | 72 -------------- .../sparc64/fpu/multiarch/s_floor-generic.c | 2 +- .../sparc64/fpu/multiarch/s_floor-vis3.c | 2 +- sysdeps/x86_64/fpu/multiarch/s_floor-c.c | 2 +- 5 files changed, 46 insertions(+), 125 deletions(-) delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_floor.c diff --git a/sysdeps/ieee754/dbl-64/s_floor.c b/sysdeps/ieee754/dbl-64/s_floor.c index bebc018658..ce0c42bdb6 100644 --- a/sysdeps/ieee754/dbl-64/s_floor.c +++ b/sysdeps/ieee754/dbl-64/s_floor.c @@ -1,4 +1,24 @@ -/* @(#)s_floor.c 5.1 93/09/24 */ +/* Round double to integer away from zero. + Copyright (C) 2011-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2011. + + 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 + . */ + +/* Based on a version which carries the following copyright: */ + /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,6 +30,12 @@ * ==================================================== */ +#define NO_MATH_REDIRECT +#include +#include +#include +#include + /* * floor(x) * Return x rounded toward -inf to integral value @@ -17,69 +43,36 @@ * Bit twiddling. */ -#define NO_MATH_REDIRECT -#include -#include -#include double __floor (double x) { - int32_t i0, i1, j0; - uint32_t i, j; - EXTRACT_WORDS (i0, i1, x); - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; - if (j0 < 20) + int64_t i0; + EXTRACT_WORDS64 (i0, x); + int32_t j0 = ((i0 >> 52) & 0x7ff) - 0x3ff; + if (__glibc_likely (j0 < 52)) { if (j0 < 0) { - /* return 0*sign(x) if |x|<1 */ + /* return 0 * sign (x) if |x| < 1 */ if (i0 >= 0) - { - i0 = i1 = 0; - } - else if (((i0 & 0x7fffffff) | i1) != 0) - { - i0 = 0xbff00000; i1 = 0; - } + i0 = 0; + else if ((i0 & 0x7fffffffffffffffl) != 0) + i0 = 0xbff0000000000000l; } else { - i = (0x000fffff) >> j0; - if (((i0 & i) | i1) == 0) - return x; /* x is integral */ + uint64_t i = 0x000fffffffffffffl >> j0; + if ((i0 & i) == 0) + return x; /* x is integral */ if (i0 < 0) - i0 += (0x00100000) >> j0; - i0 &= (~i); i1 = 0; - } - } - else if (j0 > 51) - { - if (j0 == 0x400) - return x + x; /* inf or NaN */ - else - return x; /* x is integral */ - } - else - { - i = ((uint32_t) (0xffffffff)) >> (j0 - 20); - if ((i1 & i) == 0) - return x; /* x is integral */ - if (i0 < 0) - { - if (j0 == 20) - i0 += 1; - else - { - j = i1 + (1 << (52 - j0)); - if (j < i1) - i0 += 1; /* got a carry */ - i1 = j; - } + i0 += 0x0010000000000000l >> j0; + i0 &= ~i; } - i1 &= (~i); + INSERT_WORDS64 (x, i0); } - INSERT_WORDS (x, i0, i1); + else if (j0 == 0x400) + return x + x; /* inf or NaN */ return x; } #ifndef __floor diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_floor.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_floor.c deleted file mode 100644 index b60f15bf00..0000000000 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_floor.c +++ /dev/null @@ -1,72 +0,0 @@ -/* Round double to integer away from zero. - Copyright (C) 2011-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2011. - - 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 - . */ - -/* Based on a version which carries the following copyright: */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#define NO_MATH_REDIRECT -#include -#include -#include -#include - -/* - * floor(x) - * Return x rounded toward -inf to integral value - * Method: - * Bit twiddling. - */ - - -double -__floor (double x) -{ - int64_t i0; - EXTRACT_WORDS64(i0,x); - int32_t j0 = ((i0>>52)&0x7ff)-0x3ff; - if(__builtin_expect(j0<52, 1)) { - if(j0<0) { - /* return 0*sign(x) if |x|<1 */ - if(i0>=0) {i0=0;} - else if((i0&0x7fffffffffffffffl)!=0) - { i0=0xbff0000000000000l;} - } else { - uint64_t i = (0x000fffffffffffffl)>>j0; - if((i0&i)==0) return x; /* x is integral */ - if(i0<0) i0 += (0x0010000000000000l)>>j0; - i0 &= (~i); - } - INSERT_WORDS64(x,i0); - } else if (j0==0x400) - return x+x; /* inf or NaN */ - return x; -} -#ifndef __floor -libm_alias_double (__floor, floor) -#endif diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_floor-generic.c b/sysdeps/sparc/sparc64/fpu/multiarch/s_floor-generic.c index 0f3361a9fb..c92b600df1 100644 --- a/sysdeps/sparc/sparc64/fpu/multiarch/s_floor-generic.c +++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_floor-generic.c @@ -1,2 +1,2 @@ #define __floor __floor_generic -#include +#include diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_floor-vis3.c b/sysdeps/sparc/sparc64/fpu/multiarch/s_floor-vis3.c index ccac0e46af..4f3d53c0e3 100644 --- a/sysdeps/sparc/sparc64/fpu/multiarch/s_floor-vis3.c +++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_floor-vis3.c @@ -20,4 +20,4 @@ #define __floor __floor_vis3 -#include +#include diff --git a/sysdeps/x86_64/fpu/multiarch/s_floor-c.c b/sysdeps/x86_64/fpu/multiarch/s_floor-c.c index 68733b69ef..002d12247e 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_floor-c.c +++ b/sysdeps/x86_64/fpu/multiarch/s_floor-c.c @@ -1,3 +1,3 @@ #undef __floor #define __floor __floor_c -#include +#include From patchwork Mon Dec 9 12:45:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206175 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107830-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="QY4YB8tw"; 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 47Wjfx2gTxz9sR1 for ; Mon, 9 Dec 2019 23:48:41 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=bHsWVRQ0uz/wOVHOSVgFERtE2rV5dz5 da5Ju2dIw4IEjNP6csHgW4zwaY4T+yra9/7wJZ1YlrCMZLGXY4byDdBLbqr5BtbC 0U65L5B6ZOBG+t+ifKzwd9GyYuiHmY+FUpzkeoLsRZ9TxToUvnmS2ItMPjQ+7c5U iAeZHeLAUq3o= 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:in-reply-to:references :message-id; s=default; bh=30970IeExWcx5WlguoTom4HZQJU=; b=QY4YB 8tw6uprSyrrU3pfCuRrxNX1a0nsg+5Q/8yCH77bIxreG9qGpIBo+pAYlzobI5aaQ R6/AuAiwSTJWZV8T3ivZd8VAKA3TWrNnpb9iXmCc5NPcolrtuP5IJpgtbJtchx+v CuGswlQMK+OpkGz3xCNYhAzscH16RCdZTo/WOI= Received: (qmail 86588 invoked by alias); 9 Dec 2019 12:48:35 -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 86572 invoked by uid 89); 9 Dec 2019 12:48:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 04/18] Always use wordsize-64 version of s_ceil.c. Date: Mon, 9 Dec 2019 13:45:54 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0012-0000-0000-000003731F46 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0013-0000-0000-000021AEED91 Message-Id: <1575895568-26473-5-git-send-email-stli@linux.ibm.com> This patch replaces s_ceil.c in sysdeps/dbl-64 with the one in sysdeps/dbl-64/wordsize-64 and removes the latter one. The code is not changed except changes in code style. Also adjusted the include path in x86_64 and sparc64 files. --- sysdeps/ieee754/dbl-64/s_ceil.c | 59 ++++++------------- sysdeps/ieee754/dbl-64/wordsize-64/s_ceil.c | 52 ---------------- .../sparc64/fpu/multiarch/s_ceil-generic.c | 2 +- .../sparc/sparc64/fpu/multiarch/s_ceil-vis3.c | 2 +- sysdeps/x86_64/fpu/multiarch/s_ceil-c.c | 2 +- 5 files changed, 21 insertions(+), 96 deletions(-) delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_ceil.c diff --git a/sysdeps/ieee754/dbl-64/s_ceil.c b/sysdeps/ieee754/dbl-64/s_ceil.c index 4c96286c69..8d66f027e7 100644 --- a/sysdeps/ieee754/dbl-64/s_ceil.c +++ b/sysdeps/ieee754/dbl-64/s_ceil.c @@ -25,61 +25,38 @@ double __ceil (double x) { - int32_t i0, i1, j0; - uint32_t i, j; - EXTRACT_WORDS (i0, i1, x); - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; - if (j0 < 20) + int64_t i0, i; + int32_t j0; + EXTRACT_WORDS64 (i0, x); + j0 = ((i0 >> 52) & 0x7ff) - 0x3ff; + if (j0 <= 51) { if (j0 < 0) { - /* return 0*sign(x) if |x|<1 */ + /* return 0 * sign(x) if |x| < 1 */ if (i0 < 0) - { - i0 = 0x80000000; i1 = 0; - } - else if ((i0 | i1) != 0) - { - i0 = 0x3ff00000; i1 = 0; - } + i0 = INT64_C (0x8000000000000000); + else if (i0 != 0) + i0 = INT64_C (0x3ff0000000000000); } else { - i = (0x000fffff) >> j0; - if (((i0 & i) | i1) == 0) - return x; /* x is integral */ + i = INT64_C (0x000fffffffffffff) >> j0; + if ((i0 & i) == 0) + return x; /* x is integral */ if (i0 > 0) - i0 += (0x00100000) >> j0; - i0 &= (~i); i1 = 0; + i0 += UINT64_C (0x0010000000000000) >> j0; + i0 &= ~i; } } - else if (j0 > 51) + else { if (j0 == 0x400) - return x + x; /* inf or NaN */ + return x + x; /* inf or NaN */ else - return x; /* x is integral */ - } - else - { - i = ((uint32_t) (0xffffffff)) >> (j0 - 20); - if ((i1 & i) == 0) - return x; /* x is integral */ - if (i0 > 0) - { - if (j0 == 20) - i0 += 1; - else - { - j = i1 + (1 << (52 - j0)); - if (j < i1) - i0 += 1; /* got a carry */ - i1 = j; - } - } - i1 &= (~i); + return x; /* x is integral */ } - INSERT_WORDS (x, i0, i1); + INSERT_WORDS64 (x, i0); return x; } #ifndef __ceil diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_ceil.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_ceil.c deleted file mode 100644 index 4bb93d0633..0000000000 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_ceil.c +++ /dev/null @@ -1,52 +0,0 @@ -/* @(#)s_ceil.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* - * ceil(x) - * Return x rounded toward -inf to integral value - * Method: - * Bit twiddling. - */ - -#define NO_MATH_REDIRECT -#include -#include -#include - -double -__ceil(double x) -{ - int64_t i0,i; - int32_t j0; - EXTRACT_WORDS64(i0,x); - j0 = ((i0>>52)&0x7ff)-0x3ff; - if(j0<=51) { - if(j0<0) { - /* return 0*sign(x) if |x|<1 */ - if(i0<0) {i0=INT64_C(0x8000000000000000);} - else if(i0!=0) { i0=INT64_C(0x3ff0000000000000);} - } else { - i = INT64_C(0x000fffffffffffff)>>j0; - if((i0&i)==0) return x; /* x is integral */ - if(i0>0) i0 += UINT64_C(0x0010000000000000)>>j0; - i0 &= (~i); - } - } else { - if(j0==0x400) return x+x; /* inf or NaN */ - else return x; /* x is integral */ - } - INSERT_WORDS64(x,i0); - return x; -} -#ifndef __ceil -libm_alias_double (__ceil, ceil) -#endif diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-generic.c b/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-generic.c index febea745e1..80f68b6766 100644 --- a/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-generic.c +++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-generic.c @@ -1,2 +1,2 @@ #define __ceil __ceil_generic -#include +#include diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-vis3.c b/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-vis3.c index 9c17809da4..2b89199c62 100644 --- a/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-vis3.c +++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_ceil-vis3.c @@ -20,4 +20,4 @@ #define __ceil __ceil_vis3 -#include +#include diff --git a/sysdeps/x86_64/fpu/multiarch/s_ceil-c.c b/sysdeps/x86_64/fpu/multiarch/s_ceil-c.c index 6a5ea3ff27..ada28baa1a 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_ceil-c.c +++ b/sysdeps/x86_64/fpu/multiarch/s_ceil-c.c @@ -1,2 +1,2 @@ #define __ceil __ceil_c -#include +#include From patchwork Mon Dec 9 12:45:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206176 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107831-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Eu/S5OjC"; 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 47WjgZ2NLsz9sNH for ; Mon, 9 Dec 2019 23:49:14 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=gBsEEowlJyPhP3ZLqSvTZnuP7kUOIjz 8vHasbgkB0/1VXDsjcfLcFqgjNfMncWTEKQMnBAyNKppU6ysxBHdBE1IcYaeq9i0 85MnH3WktnR8B1NgAjsEoLSPWOxFYGYj+xKXyr+ijT1r2gnMvuMiFlGbI7YMm/+5 YOup3fD5pESg= 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:in-reply-to:references :message-id; s=default; bh=RNro4ej5TCWE7cgkpUnIPP3lqY8=; b=Eu/S5 OjCoRHSr+aTGtDVoRTrB4EJwCcNr52oV49lYnwcrMvqddOu+zTgnkTqO+j8EvlIt cwaa5ZBrK1eO7IiL5ZuWoT9WhfEkKbS4FdjBCAGcCbd/9qu825OhbN5PXgjU03Xh rmpBDGjNv9RiY+QnhI2qctwUq6LD1aXC8GW9H0= Received: (qmail 89954 invoked by alias); 9 Dec 2019 12:49:07 -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 89893 invoked by uid 89); 9 Dec 2019 12:49:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 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, SPF_PASS autolearn=ham version=3.3.1 spammy=nearest X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 05/18] Always use wordsize-64 version of s_trunc.c. Date: Mon, 9 Dec 2019 13:45:55 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0012-0000-0000-000003731F4F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0013-0000-0000-000021AEED9B Message-Id: <1575895568-26473-6-git-send-email-stli@linux.ibm.com> This patch replaces s_trunc.c in sysdeps/dbl-64 with the one in sysdeps/dbl-64/wordsize-64 and removes the latter one. The code is not changed except changes in code style. Also adjusted the include path in x86_64 and sparc64 files. --- sysdeps/ieee754/dbl-64/s_trunc.c | 25 ++++----- sysdeps/ieee754/dbl-64/wordsize-64/s_trunc.c | 55 ------------------- .../sparc64/fpu/multiarch/s_trunc-generic.c | 2 +- .../sparc64/fpu/multiarch/s_trunc-vis3.c | 2 +- sysdeps/x86_64/fpu/multiarch/s_trunc-c.c | 2 +- 5 files changed, 13 insertions(+), 73 deletions(-) delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_trunc.c diff --git a/sysdeps/ieee754/dbl-64/s_trunc.c b/sysdeps/ieee754/dbl-64/s_trunc.c index 154feb9aa3..0de68ce298 100644 --- a/sysdeps/ieee754/dbl-64/s_trunc.c +++ b/sysdeps/ieee754/dbl-64/s_trunc.c @@ -27,31 +27,26 @@ double __trunc (double x) { - int32_t i0, j0; - uint32_t i1; - int sx; - - EXTRACT_WORDS (i0, i1, x); - sx = i0 & 0x80000000; - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; - if (j0 < 20) + int64_t i0, j0; + int64_t sx; + + EXTRACT_WORDS64 (i0, x); + sx = i0 & UINT64_C (0x8000000000000000); + j0 = ((i0 >> 52) & 0x7ff) - 0x3ff; + if (j0 < 52) { if (j0 < 0) /* The magnitude of the number is < 1 so the result is +-0. */ - INSERT_WORDS (x, sx, 0); + INSERT_WORDS64 (x, sx); else - INSERT_WORDS (x, sx | (i0 & ~(0x000fffff >> j0)), 0); + INSERT_WORDS64 (x, sx | (i0 & ~(UINT64_C (0x000fffffffffffff) >> j0))); } - else if (j0 > 51) + else { if (j0 == 0x400) /* x is inf or NaN. */ return x + x; } - else - { - INSERT_WORDS (x, i0, i1 & ~(0xffffffffu >> (j0 - 20))); - } return x; } diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_trunc.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_trunc.c deleted file mode 100644 index 3f040bbf83..0000000000 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_trunc.c +++ /dev/null @@ -1,55 +0,0 @@ -/* Truncate argument to nearest integral value not larger than the argument. - Copyright (C) 1997-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - 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 - . */ - -#define NO_MATH_REDIRECT -#include - -#include -#include - - -double -__trunc (double x) -{ - int64_t i0, j0; - int64_t sx; - - EXTRACT_WORDS64 (i0, x); - sx = i0 & UINT64_C(0x8000000000000000); - j0 = ((i0 >> 52) & 0x7ff) - 0x3ff; - if (j0 < 52) - { - if (j0 < 0) - /* The magnitude of the number is < 1 so the result is +-0. */ - INSERT_WORDS64 (x, sx); - else - INSERT_WORDS64 (x, sx | (i0 & ~(UINT64_C(0x000fffffffffffff) >> j0))); - } - else - { - if (j0 == 0x400) - /* x is inf or NaN. */ - return x + x; - } - - return x; -} -#ifndef __trunc -libm_alias_double (__trunc, trunc) -#endif diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_trunc-generic.c b/sysdeps/sparc/sparc64/fpu/multiarch/s_trunc-generic.c index 00abd2a643..c198ebb3d5 100644 --- a/sysdeps/sparc/sparc64/fpu/multiarch/s_trunc-generic.c +++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_trunc-generic.c @@ -1,2 +1,2 @@ #define __trunc __trunc_generic -#include +#include diff --git a/sysdeps/sparc/sparc64/fpu/multiarch/s_trunc-vis3.c b/sysdeps/sparc/sparc64/fpu/multiarch/s_trunc-vis3.c index 45646c5d66..321a9eded6 100644 --- a/sysdeps/sparc/sparc64/fpu/multiarch/s_trunc-vis3.c +++ b/sysdeps/sparc/sparc64/fpu/multiarch/s_trunc-vis3.c @@ -20,4 +20,4 @@ #define __trunc __trunc_vis3 -#include +#include diff --git a/sysdeps/x86_64/fpu/multiarch/s_trunc-c.c b/sysdeps/x86_64/fpu/multiarch/s_trunc-c.c index 6204ae3c77..8aa499fbb8 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_trunc-c.c +++ b/sysdeps/x86_64/fpu/multiarch/s_trunc-c.c @@ -1,2 +1,2 @@ #define __trunc __trunc_c -#include +#include From patchwork Mon Dec 9 12:45:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206177 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107832-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="dF5qZ63+"; 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 47Wjgy2H2zz9sNH for ; Mon, 9 Dec 2019 23:49:34 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=g1Hf4Q16ZM96SeRN/LGXgfeI/MkBrpY /TVB5/yzMubeVVAGRggUUZ/No+FCWDMaqailE8psPe0GzDA9oHRtwVgTkpdZMCx/ PGBI8C7AfpeoobZqRcT281HHHF531aYCwbWeixGZJ7MP2NM+6V4pif/0Y51fwyaw zkEu8BUGzkkQ= 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:in-reply-to:references :message-id; s=default; bh=ZocN8Dtpr6UDinfLh1WnCovsOWw=; b=dF5qZ 63+Aiz32W11LYROzPfjJqlwo0WNKEA/tCnvkYgpLkZmsj+IQfb1Gd8a5WqCvA9k5 UwQT3J2YLQrqk1TAcc/j+bZPUjzU42+tTEOeDnMLwpYMMJasvDnwDsh6zBA+G4Pi ArKwwPlwI4ez5eufUjT6FMZKUAAIbv/gvnYji4= Received: (qmail 91416 invoked by alias); 9 Dec 2019 12:49: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 91407 invoked by uid 89); 9 Dec 2019 12:49:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 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, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 06/18] Always use wordsize-64 version of s_round.c. Date: Mon, 9 Dec 2019 13:45:56 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0008-0000-0000-0000033F1B45 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0009-0000-0000-00004A5E47DA Message-Id: <1575895568-26473-7-git-send-email-stli@linux.ibm.com> This patch replaces s_round.c in sysdeps/dbl-64 with the one in sysdeps/dbl-64/wordsize-64 and removes the latter one. --- sysdeps/ieee754/dbl-64/s_round.c | 39 ++++-------- sysdeps/ieee754/dbl-64/wordsize-64/s_round.c | 66 -------------------- 2 files changed, 12 insertions(+), 93 deletions(-) delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_round.c diff --git a/sysdeps/ieee754/dbl-64/s_round.c b/sysdeps/ieee754/dbl-64/s_round.c index 1793e575e9..8f4b7cff86 100644 --- a/sysdeps/ieee754/dbl-64/s_round.c +++ b/sysdeps/ieee754/dbl-64/s_round.c @@ -22,38 +22,36 @@ #include #include +#include double __round (double x) { - int32_t i0, j0; - uint32_t i1; + int64_t i0, j0; - EXTRACT_WORDS (i0, i1, x); - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; - if (j0 < 20) + EXTRACT_WORDS64 (i0, x); + j0 = ((i0 >> 52) & 0x7ff) - 0x3ff; + if (__glibc_likely (j0 < 52)) { if (j0 < 0) { - i0 &= 0x80000000; + i0 &= UINT64_C (0x8000000000000000); if (j0 == -1) - i0 |= 0x3ff00000; - i1 = 0; + i0 |= UINT64_C (0x3ff0000000000000); } else { - uint32_t i = 0x000fffff >> j0; - if (((i0 & i) | i1) == 0) + uint64_t i = UINT64_C (0x000fffffffffffff) >> j0; + if ((i0 & i) == 0) /* X is integral. */ return x; - i0 += 0x00080000 >> j0; + i0 += UINT64_C (0x0008000000000000) >> j0; i0 &= ~i; - i1 = 0; } } - else if (j0 > 51) + else { if (j0 == 0x400) /* Inf or NaN. */ @@ -61,21 +59,8 @@ __round (double x) else return x; } - else - { - uint32_t i = 0xffffffff >> (j0 - 20); - if ((i1 & i) == 0) - /* X is integral. */ - return x; - - uint32_t j = i1 + (1 << (51 - j0)); - if (j < i1) - i0 += 1; - i1 = j; - i1 &= ~i; - } - INSERT_WORDS (x, i0, i1); + INSERT_WORDS64 (x, i0); return x; } libm_alias_double (__round, round) diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_round.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_round.c deleted file mode 100644 index 1c3fc7f50e..0000000000 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_round.c +++ /dev/null @@ -1,66 +0,0 @@ -/* Round double to integer away from zero. - Copyright (C) 1997-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - 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 - . */ - -#define NO_MATH_REDIRECT -#include - -#include -#include -#include - - -double -__round (double x) -{ - int64_t i0, j0; - - EXTRACT_WORDS64 (i0, x); - j0 = ((i0 >> 52) & 0x7ff) - 0x3ff; - if (__glibc_likely (j0 < 52)) - { - if (j0 < 0) - { - i0 &= UINT64_C(0x8000000000000000); - if (j0 == -1) - i0 |= UINT64_C(0x3ff0000000000000); - } - else - { - uint64_t i = UINT64_C(0x000fffffffffffff) >> j0; - if ((i0 & i) == 0) - /* X is integral. */ - return x; - - i0 += UINT64_C(0x0008000000000000) >> j0; - i0 &= ~i; - } - } - else - { - if (j0 == 0x400) - /* Inf or NaN. */ - return x + x; - else - return x; - } - - INSERT_WORDS64 (x, i0); - return x; -} -libm_alias_double (__round, round) From patchwork Mon Dec 9 12:45:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206178 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107833-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="ahrgMoF6"; 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 47WjhR23XPz9sNH for ; Mon, 9 Dec 2019 23:49:59 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=USRJ5MYaSOVtikKQKGd0Kvk+rHTO0+r YYgGfTHjEGwSiLZRqkOXrNRv4qrNIRmNEvnd+P7uhbHZr76gJjmPDPUz3s/nD+D9 M7VUlmqGOpaDebiisSuClQQ5jmh/fGzH4PfoodcnCCqXj/pYRkJtwGZDdZb7leEy gQ79JRKIg7FU= 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:in-reply-to:references :message-id; s=default; bh=TEev8oYH04456FyYPeA9+3sRXZc=; b=ahrgM oF6Jg3v8uEU5Acj3AyJ7MrDzvbqL7QvB8b6U/aAVFa9GGrFmKeUTm+Qs/Kl7ESxT Dmnpgzb8RPwXhePq3H7dbWkBDOO9qjbe79Y9zf/9F8McrabKW7AZK2LAudNos0y1 +L0fOM6UX1aX2Txpkk4yg8J56rA5CKCa+wBBkE= Received: (qmail 92781 invoked by alias); 9 Dec 2019 12:49:53 -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 92771 invoked by uid 89); 9 Dec 2019 12:49:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 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, SPF_PASS autolearn=ham version=3.3.1 spammy=wt X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 07/18] Use GCC builtins for nearbyint functions if desired. Date: Mon, 9 Dec 2019 13:45:57 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-4275-0000-0000-0000038D408E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-4276-0000-0000-000038A0EDA1 Message-Id: <1575895568-26473-8-git-send-email-stli@linux.ibm.com> This patch is using the corresponding GCC builtin for nearbyintf, nearbyint, nearbintl and nearbyintf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. This is the case for s390 if build with at least --march=z196 --mzarch. Otherwise the generic implementation is used. The code of the generic implementation is not changed. Reviewed-by: Adhemerval Zanella --- sysdeps/generic/math-use-builtins.h | 29 ++++++++++++ sysdeps/ieee754/dbl-64/s_nearbyint.c | 17 ++++--- sysdeps/ieee754/float128/float128_private.h | 4 ++ sysdeps/ieee754/flt-32/s_nearbyintf.c | 17 ++++--- sysdeps/ieee754/ldbl-128/s_nearbyintl.c | 17 ++++--- sysdeps/s390/fpu/math-use-builtins.h | 49 +++++++++++++++++++++ 6 files changed, 115 insertions(+), 18 deletions(-) create mode 100644 sysdeps/generic/math-use-builtins.h create mode 100644 sysdeps/s390/fpu/math-use-builtins.h diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h new file mode 100644 index 0000000000..e12490ed41 --- /dev/null +++ b/sysdeps/generic/math-use-builtins.h @@ -0,0 +1,29 @@ +/* Using math gcc builtins instead of generic implementation. Generic version. + Copyright (C) 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 MATH_USE_BUILTINS_H +#define MATH_USE_BUILTINS_H 1 + +/* Define these macros to 1 to use __builtin_xyz instead of the + generic implementation. */ +#define USE_NEARBYINT_BUILTIN 0 +#define USE_NEARBYINTF_BUILTIN 0 +#define USE_NEARBYINTL_BUILTIN 0 +#define USE_NEARBYINTF128_BUILTIN 0 + +#endif /* math-use-builtins.h */ diff --git a/sysdeps/ieee754/dbl-64/s_nearbyint.c b/sysdeps/ieee754/dbl-64/s_nearbyint.c index c261885c5a..2deaeb2568 100644 --- a/sysdeps/ieee754/dbl-64/s_nearbyint.c +++ b/sysdeps/ieee754/dbl-64/s_nearbyint.c @@ -26,16 +26,20 @@ #include #include #include - -static const double -TWO52[2] = { - 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ - -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ -}; +#include double __nearbyint (double x) { +#if USE_NEARBYINT_BUILTIN + return __builtin_nearbyint (x); +#else + /* Use generic implementation. */ + static const double + TWO52[2] = { + 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ + -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ + }; fenv_t env; int64_t i0, sx; int32_t j0; @@ -67,5 +71,6 @@ __nearbyint (double x) math_force_eval (t); libc_fesetenv (&env); return t; +#endif /* ! USE_NEARBYINT_BUILTIN */ } libm_alias_double (__nearbyint, nearbyint) diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h index 4e31ef365b..e96986a968 100644 --- a/sysdeps/ieee754/float128/float128_private.h +++ b/sysdeps/ieee754/float128/float128_private.h @@ -139,6 +139,9 @@ #undef libm_alias_double_ldouble #define libm_alias_double_ldouble(func) libm_alias_float64_float128 (func) +#include +#undef USE_NEARBYINTL_BUILTIN +#define USE_NEARBYINTL_BUILTIN USE_NEARBYINTF128_BUILTIN /* IEEE function renames. */ #define __ieee754_acoshl __ieee754_acoshf128 @@ -342,6 +345,7 @@ /* Builtin renames. */ #define __builtin_copysignl __builtin_copysignf128 #define __builtin_signbitl __builtin_signbit +#define __builtin_nearbyintl __builtin_nearbyintf128 /* Get the constant suffix from bits/floatn-compat.h. */ #define L(x) __f128 (x) diff --git a/sysdeps/ieee754/flt-32/s_nearbyintf.c b/sysdeps/ieee754/flt-32/s_nearbyintf.c index acedf34c90..b37e003e12 100644 --- a/sysdeps/ieee754/flt-32/s_nearbyintf.c +++ b/sysdeps/ieee754/flt-32/s_nearbyintf.c @@ -21,16 +21,20 @@ #include #include #include - -static const float -TWO23[2]={ - 8.3886080000e+06, /* 0x4b000000 */ - -8.3886080000e+06, /* 0xcb000000 */ -}; +#include float __nearbyintf(float x) { +#if USE_NEARBYINTF_BUILTIN + return __builtin_nearbyintf (x); +#else + /* Use generic implementation. */ + static const float + TWO23[2] = { + 8.3886080000e+06, /* 0x4b000000 */ + -8.3886080000e+06, /* 0xcb000000 */ + }; fenv_t env; int32_t i0,j0,sx; float w,t; @@ -58,5 +62,6 @@ __nearbyintf(float x) math_force_eval (t); libc_fesetenvf (&env); return t; +#endif /* ! USE_NEARBYINT_BUILTIN */ } libm_alias_float (__nearbyint, nearbyint) diff --git a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c index f044cb4334..a4ad8e82e5 100644 --- a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c +++ b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c @@ -28,15 +28,19 @@ #include #include #include - -static const _Float128 -TWO112[2]={ - L(5.19229685853482762853049632922009600E+33), /* 0x406F000000000000, 0 */ - L(-5.19229685853482762853049632922009600E+33) /* 0xC06F000000000000, 0 */ -}; +#include _Float128 __nearbyintl(_Float128 x) { +#if USE_NEARBYINTL_BUILTIN + return __builtin_nearbyintl (x); +#else + /* Use generic implementation. */ + static const _Float128 + TWO112[2] = { + L(5.19229685853482762853049632922009600E+33), /* 0x406F000000000000, 0 */ + L(-5.19229685853482762853049632922009600E+33) /* 0xC06F000000000000, 0 */ + }; fenv_t env; int64_t i0,j0,sx; uint64_t i1 __attribute__ ((unused)); @@ -65,5 +69,6 @@ _Float128 __nearbyintl(_Float128 x) math_force_eval (t); fesetenv (&env); return t; +#endif /* ! USE_NEARBYINTL_BUILTIN */ } libm_alias_ldouble (__nearbyint, nearbyint) diff --git a/sysdeps/s390/fpu/math-use-builtins.h b/sysdeps/s390/fpu/math-use-builtins.h new file mode 100644 index 0000000000..7abbfb3b50 --- /dev/null +++ b/sysdeps/s390/fpu/math-use-builtins.h @@ -0,0 +1,49 @@ +/* Using math gcc builtins instead of generic implementation. s390/s390x version. + Copyright (C) 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 MATH_USE_BUILTINS_S390_H +#define MATH_USE_BUILTINS_S390_H 1 + +#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT + +# include /* For __GNUC_PREREQ. */ + +/* GCC emits the z196 zarch "load fp integer" instructions for these + builtins if build with at least --march=z196 -mzarch. Otherwise a + function call to libc is emitted. */ +# define USE_NEARBYINT_BUILTIN 1 +# define USE_NEARBYINTF_BUILTIN 1 +# define USE_NEARBYINTL_BUILTIN 1 + +# if __GNUC_PREREQ (8, 0) +# define USE_NEARBYINTF128_BUILTIN 1 +# else +# define USE_NEARBYINTF128_BUILTIN 0 +# endif + +#else + +/* Disable the builtins if we do not have the z196 zarch instructions. */ +# define USE_NEARBYINT_BUILTIN 0 +# define USE_NEARBYINTF_BUILTIN 0 +# define USE_NEARBYINTL_BUILTIN 0 +# define USE_NEARBYINTF128_BUILTIN 0 + +#endif /* ! HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT */ + +#endif /* math-use-builtins.h */ From patchwork Mon Dec 9 12:45:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206179 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107834-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="MwVvn3Ff"; 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 47Wjhn42nVz9sNH for ; Mon, 9 Dec 2019 23:50:17 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=vI/Br9hX+84v7XFQEh38bAWrXZIkwMg msfwif/pmsIdWrxdd3eWUuxrjRVQ5Hp4aYGn3mreIUnkGFdIyNHeYGHl1FF14Ipo eoo27jtZTYgASe+Ds84oUIG1ll0ISF2H41Mgay0HbIfYiH8GlBtPho1w5KTTpLRB FEHY7jjjMv9Y= 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:in-reply-to:references :message-id; s=default; bh=RA+AyTanUQkk8O39eAspuNHDteg=; b=MwVvn 3FfsfBpW+cBCrsmPr5YRbm/GIJ50aNTyFWGzbwFz94NIlokkpUCfDCQx/cF404s6 WRjAZSD7CcBaXY+5YdW+7oVS69l4Hp3rutSM34ALaSpBhIOkGuOK4pLo/17f3cp7 eDMffTHn2nHIvlPtlbFpiOqDfQxdvnI4yYaOuA= Received: (qmail 94088 invoked by alias); 9 Dec 2019 12:50:11 -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 94079 invoked by uid 89); 9 Dec 2019 12:50:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 08/18] Use GCC builtins for rint functions if desired. Date: Mon, 9 Dec 2019 13:45:58 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0008-0000-0000-0000033F1B4E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0009-0000-0000-00004A5E47E3 Message-Id: <1575895568-26473-9-git-send-email-stli@linux.ibm.com> This patch is using the corresponding GCC builtin for rintf, rint, rintl and rintf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. This is the case for s390 if build with at least --march=z196 --mzarch. Otherwise the generic implementation is used. The code of the generic implementation is not changed. Reviewed-by: Adhemerval Zanella --- sysdeps/generic/math-use-builtins.h | 5 +++++ sysdeps/ieee754/dbl-64/s_rint.c | 17 +++++++++++------ sysdeps/ieee754/float128/float128_private.h | 3 +++ sysdeps/ieee754/flt-32/s_rintf.c | 17 +++++++++++------ sysdeps/ieee754/ldbl-128/s_rintl.c | 17 +++++++++++------ sysdeps/s390/fpu/math-use-builtins.h | 11 +++++++++++ 6 files changed, 52 insertions(+), 18 deletions(-) diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h index e12490ed41..64b4a4bb5b 100644 --- a/sysdeps/generic/math-use-builtins.h +++ b/sysdeps/generic/math-use-builtins.h @@ -26,4 +26,9 @@ #define USE_NEARBYINTL_BUILTIN 0 #define USE_NEARBYINTF128_BUILTIN 0 +#define USE_RINT_BUILTIN 0 +#define USE_RINTF_BUILTIN 0 +#define USE_RINTL_BUILTIN 0 +#define USE_RINTF128_BUILTIN 0 + #endif /* math-use-builtins.h */ diff --git a/sysdeps/ieee754/dbl-64/s_rint.c b/sysdeps/ieee754/dbl-64/s_rint.c index 66c9196473..8604733ef9 100644 --- a/sysdeps/ieee754/dbl-64/s_rint.c +++ b/sysdeps/ieee754/dbl-64/s_rint.c @@ -23,16 +23,20 @@ #include #include #include - -static const double -TWO52[2] = { - 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ - -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ -}; +#include double __rint (double x) { +#if USE_RINT_BUILTIN + return __builtin_rint (x); +#else + /* Use generic implementation. */ + static const double + TWO52[2] = { + 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ + -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ + }; int64_t i0, sx; int32_t j0; EXTRACT_WORDS64 (i0, x); @@ -59,6 +63,7 @@ __rint (double x) } double w = TWO52[sx] + x; return w - TWO52[sx]; +#endif /* ! USE_RINT_BUILTIN */ } #ifndef __rint libm_alias_double (__rint, rint) diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h index e96986a968..f458e7b85f 100644 --- a/sysdeps/ieee754/float128/float128_private.h +++ b/sysdeps/ieee754/float128/float128_private.h @@ -142,6 +142,8 @@ #include #undef USE_NEARBYINTL_BUILTIN #define USE_NEARBYINTL_BUILTIN USE_NEARBYINTF128_BUILTIN +#undef USE_RINTL_BUILTIN +#define USE_RINTL_BUILTIN USE_RINTF128_BUILTIN /* IEEE function renames. */ #define __ieee754_acoshl __ieee754_acoshf128 @@ -346,6 +348,7 @@ #define __builtin_copysignl __builtin_copysignf128 #define __builtin_signbitl __builtin_signbit #define __builtin_nearbyintl __builtin_nearbyintf128 +#define __builtin_rintl __builtin_rintf128 /* Get the constant suffix from bits/floatn-compat.h. */ #define L(x) __f128 (x) diff --git a/sysdeps/ieee754/flt-32/s_rintf.c b/sysdeps/ieee754/flt-32/s_rintf.c index 0306dc21f4..34c16ea164 100644 --- a/sysdeps/ieee754/flt-32/s_rintf.c +++ b/sysdeps/ieee754/flt-32/s_rintf.c @@ -17,16 +17,20 @@ #include #include #include - -static const float -TWO23[2]={ - 8.3886080000e+06, /* 0x4b000000 */ - -8.3886080000e+06, /* 0xcb000000 */ -}; +#include float __rintf(float x) { +#if USE_RINTF_BUILTIN + return __builtin_rintf (x); +#else + /* Use generic implementation. */ + static const float + TWO23[2] = { + 8.3886080000e+06, /* 0x4b000000 */ + -8.3886080000e+06, /* 0xcb000000 */ + }; int32_t i0,j0,sx; float w,t; GET_FLOAT_WORD(i0,x); @@ -46,6 +50,7 @@ __rintf(float x) } w = TWO23[sx]+x; return w-TWO23[sx]; +#endif /* ! USE_RINTF_BUILTIN */ } #ifndef __rintf libm_alias_float (__rint, rint) diff --git a/sysdeps/ieee754/ldbl-128/s_rintl.c b/sysdeps/ieee754/ldbl-128/s_rintl.c index b6337e1d8a..3340c35ee1 100644 --- a/sysdeps/ieee754/ldbl-128/s_rintl.c +++ b/sysdeps/ieee754/ldbl-128/s_rintl.c @@ -31,15 +31,19 @@ static char rcsid[] = "$NetBSD: $"; #include #include #include - -static const _Float128 -TWO112[2]={ - 5.19229685853482762853049632922009600E+33L, /* 0x406F000000000000, 0 */ - -5.19229685853482762853049632922009600E+33L /* 0xC06F000000000000, 0 */ -}; +#include _Float128 __rintl(_Float128 x) { +#if USE_RINTL_BUILTIN + return __builtin_rintl (x); +#else + /* Use generic implementation. */ + static const _Float128 + TWO112[2] = { + 5.19229685853482762853049632922009600E+33L, /* 0x406F000000000000, 0 */ + -5.19229685853482762853049632922009600E+33L /* 0xC06F000000000000, 0 */ + }; int64_t i0,j0,sx; uint64_t i1 __attribute__ ((unused)); _Float128 w,t; @@ -60,5 +64,6 @@ _Float128 __rintl(_Float128 x) } w = TWO112[sx]+x; return w-TWO112[sx]; +#endif /* ! USE_RINTL_BUILTIN */ } libm_alias_ldouble (__rint, rint) diff --git a/sysdeps/s390/fpu/math-use-builtins.h b/sysdeps/s390/fpu/math-use-builtins.h index 7abbfb3b50..8b702a6a90 100644 --- a/sysdeps/s390/fpu/math-use-builtins.h +++ b/sysdeps/s390/fpu/math-use-builtins.h @@ -30,10 +30,16 @@ # define USE_NEARBYINTF_BUILTIN 1 # define USE_NEARBYINTL_BUILTIN 1 +# define USE_RINT_BUILTIN 1 +# define USE_RINTF_BUILTIN 1 +# define USE_RINTL_BUILTIN 1 + # if __GNUC_PREREQ (8, 0) # define USE_NEARBYINTF128_BUILTIN 1 +# define USE_RINTF128_BUILTIN 1 # else # define USE_NEARBYINTF128_BUILTIN 0 +# define USE_RINTF128_BUILTIN 0 # endif #else @@ -44,6 +50,11 @@ # define USE_NEARBYINTL_BUILTIN 0 # define USE_NEARBYINTF128_BUILTIN 0 +# define USE_RINT_BUILTIN 0 +# define USE_RINTF_BUILTIN 0 +# define USE_RINTL_BUILTIN 0 +# define USE_RINTF128_BUILTIN 0 + #endif /* ! HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT */ #endif /* math-use-builtins.h */ From patchwork Mon Dec 9 12:45:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206180 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107835-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="wWLO/QEU"; 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 47Wjj45gVCz9sPc for ; Mon, 9 Dec 2019 23:50:32 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=ISsWnKkQUw9JsUCq/VOsiI3NABN+bQN J/T5iuPGW1C+vj2gpRVRu8a+H9MdPIGNHCkqONTed6ds/jmrY5M6Ndor04Grq2+a /rXOTES0bXYha+UK3XTBbVkJRlLEHy4g2HLr3XmPA/g3aHGs9tQHRgfv6v9AOMUY fzeMgvk9DC/Y= 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:in-reply-to:references :message-id; s=default; bh=HvJrU1TfsMf82Q2P4Orz1zRzbbI=; b=wWLO/ QEU9YEUDV2kBb91SSMzb7uPST2wmBUugRisGPNBl5uZZLTdeJqhCogKQV77ZUQDF MTiNbJRCF01OwLKALkrVCFVzduF4VFVOxftKZ9hgT2tCdktcE1MpGXq9cTFkdhEV xDaRggbFpH1rIcAODAccmZFcw61H3G+IHAh+ow= Received: (qmail 95334 invoked by alias); 9 Dec 2019 12:50:26 -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 95321 invoked by uid 89); 9 Dec 2019 12:50:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 09/18] Use GCC builtins for floor functions if desired. Date: Mon, 9 Dec 2019 13:45:59 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0020-0000-0000-00000395D579 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0021-0000-0000-000021ED1049 Message-Id: <1575895568-26473-10-git-send-email-stli@linux.ibm.com> This patch is using the corresponding GCC builtin for floorf, floor, floorl and floorf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. This is the case for s390 if build with at least --march=z196 --mzarch. Otherwise the generic implementation is used. The code of the generic implementation is not changed. Reviewed-by: Adhemerval Zanella --- sysdeps/generic/math-use-builtins.h | 5 +++++ sysdeps/ieee754/dbl-64/s_floor.c | 6 ++++++ sysdeps/ieee754/float128/float128_private.h | 3 +++ sysdeps/ieee754/flt-32/s_floorf.c | 6 ++++++ sysdeps/ieee754/ldbl-128/s_floorl.c | 6 ++++++ sysdeps/s390/fpu/math-use-builtins.h | 11 +++++++++++ 6 files changed, 37 insertions(+) diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h index 64b4a4bb5b..e1c5df62e4 100644 --- a/sysdeps/generic/math-use-builtins.h +++ b/sysdeps/generic/math-use-builtins.h @@ -31,4 +31,9 @@ #define USE_RINTL_BUILTIN 0 #define USE_RINTF128_BUILTIN 0 +#define USE_FLOOR_BUILTIN 0 +#define USE_FLOORF_BUILTIN 0 +#define USE_FLOORL_BUILTIN 0 +#define USE_FLOORF128_BUILTIN 0 + #endif /* math-use-builtins.h */ diff --git a/sysdeps/ieee754/dbl-64/s_floor.c b/sysdeps/ieee754/dbl-64/s_floor.c index ce0c42bdb6..78325214f4 100644 --- a/sysdeps/ieee754/dbl-64/s_floor.c +++ b/sysdeps/ieee754/dbl-64/s_floor.c @@ -35,6 +35,7 @@ #include #include #include +#include /* * floor(x) @@ -47,6 +48,10 @@ double __floor (double x) { +#if USE_FLOOR_BUILTIN + return __builtin_floor (x); +#else + /* Use generic implementation. */ int64_t i0; EXTRACT_WORDS64 (i0, x); int32_t j0 = ((i0 >> 52) & 0x7ff) - 0x3ff; @@ -74,6 +79,7 @@ __floor (double x) else if (j0 == 0x400) return x + x; /* inf or NaN */ return x; +#endif /* ! USE_FLOOR_BUILTIN */ } #ifndef __floor libm_alias_double (__floor, floor) diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h index f458e7b85f..8c8a74a12c 100644 --- a/sysdeps/ieee754/float128/float128_private.h +++ b/sysdeps/ieee754/float128/float128_private.h @@ -144,6 +144,8 @@ #define USE_NEARBYINTL_BUILTIN USE_NEARBYINTF128_BUILTIN #undef USE_RINTL_BUILTIN #define USE_RINTL_BUILTIN USE_RINTF128_BUILTIN +#undef USE_FLOORL_BUILTIN +#define USE_FLOORL_BUILTIN USE_FLOORF128_BUILTIN /* IEEE function renames. */ #define __ieee754_acoshl __ieee754_acoshf128 @@ -349,6 +351,7 @@ #define __builtin_signbitl __builtin_signbit #define __builtin_nearbyintl __builtin_nearbyintf128 #define __builtin_rintl __builtin_rintf128 +#define __builtin_floorl __builtin_floorf128 /* Get the constant suffix from bits/floatn-compat.h. */ #define L(x) __f128 (x) diff --git a/sysdeps/ieee754/flt-32/s_floorf.c b/sysdeps/ieee754/flt-32/s_floorf.c index b34d967f01..afe02a1693 100644 --- a/sysdeps/ieee754/flt-32/s_floorf.c +++ b/sysdeps/ieee754/flt-32/s_floorf.c @@ -24,10 +24,15 @@ #include #include #include +#include float __floorf(float x) { +#if USE_FLOORF_BUILTIN + return __builtin_floorf (x); +#else + /* Use generic implementation. */ int32_t i0,j0; uint32_t i; GET_FLOAT_WORD(i0,x); @@ -50,6 +55,7 @@ __floorf(float x) } SET_FLOAT_WORD(x,i0); return x; +#endif /* ! USE_FLOORF_BUILTIN */ } #ifndef __floorf libm_alias_float (__floor, floor) diff --git a/sysdeps/ieee754/ldbl-128/s_floorl.c b/sysdeps/ieee754/ldbl-128/s_floorl.c index f340a3fbca..cfe008392a 100644 --- a/sysdeps/ieee754/ldbl-128/s_floorl.c +++ b/sysdeps/ieee754/ldbl-128/s_floorl.c @@ -28,9 +28,14 @@ static char rcsid[] = "$NetBSD: $"; #include #include #include +#include _Float128 __floorl(_Float128 x) { +#if USE_FLOORL_BUILTIN + return __builtin_floorl (x); +#else + /* Use generic implementation. */ int64_t i0,i1,j0; uint64_t i,j; GET_LDOUBLE_WORDS64(i0,i1,x); @@ -65,5 +70,6 @@ _Float128 __floorl(_Float128 x) } SET_LDOUBLE_WORDS64(x,i0,i1); return x; +#endif /* ! USE_FLOORL_BUILTIN */ } libm_alias_ldouble (__floor, floor) diff --git a/sysdeps/s390/fpu/math-use-builtins.h b/sysdeps/s390/fpu/math-use-builtins.h index 8b702a6a90..c213c16c6f 100644 --- a/sysdeps/s390/fpu/math-use-builtins.h +++ b/sysdeps/s390/fpu/math-use-builtins.h @@ -34,12 +34,18 @@ # define USE_RINTF_BUILTIN 1 # define USE_RINTL_BUILTIN 1 +# define USE_FLOOR_BUILTIN 1 +# define USE_FLOORF_BUILTIN 1 +# define USE_FLOORL_BUILTIN 1 + # if __GNUC_PREREQ (8, 0) # define USE_NEARBYINTF128_BUILTIN 1 # define USE_RINTF128_BUILTIN 1 +# define USE_FLOORF128_BUILTIN 1 # else # define USE_NEARBYINTF128_BUILTIN 0 # define USE_RINTF128_BUILTIN 0 +# define USE_FLOORF128_BUILTIN 0 # endif #else @@ -55,6 +61,11 @@ # define USE_RINTL_BUILTIN 0 # define USE_RINTF128_BUILTIN 0 +# define USE_FLOOR_BUILTIN 0 +# define USE_FLOORF_BUILTIN 0 +# define USE_FLOORL_BUILTIN 0 +# define USE_FLOORF128_BUILTIN 0 + #endif /* ! HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT */ #endif /* math-use-builtins.h */ From patchwork Mon Dec 9 12:46:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206181 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107836-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="bGq+4WwZ"; 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 47WjjM6hlyz9sPh for ; Mon, 9 Dec 2019 23:50:47 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=W3v30jo4vnscDI24M8G2R0O5+Uqjz8o k2AG8+IOMSLTqI7T2JOlyu2QjUTbukTtjjKJA0szFNynIHaarWk92IIplO5uA66z 1CxtJgPecrbzHfTzPPHmVrH9LXVuxLOue8mBSgpppeVh20rToEYZxmpGmCWqxgYe pNzWHDcixGu4= 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:in-reply-to:references :message-id; s=default; bh=7ZFuURye+WKWr9Y4LZuzKppZNlU=; b=bGq+4 WwZf7sxrQImvay2YdSUvVf/WYgrN3freuuxEgAcRbFJfqAxsuFMQUGzC40WdZKrC IMm/KZFY4DHQlqgZqvNALpcWhg89P0XEOWkkxWJTKCwZ+vJ+VY5qXMwaJnX6oWuV XbAcr7fRA7uKPX6cOOMWAPygFU8oRAmD8v7uJs= Received: (qmail 96631 invoked by alias); 9 Dec 2019 12:50:42 -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 96623 invoked by uid 89); 9 Dec 2019 12:50:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=1468 X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 10/18] Use GCC builtins for ceil functions if desired. Date: Mon, 9 Dec 2019 13:46:00 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0012-0000-0000-000003731F6A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0013-0000-0000-000021AEEDB6 Message-Id: <1575895568-26473-11-git-send-email-stli@linux.ibm.com> This patch is using the corresponding GCC builtin for ceilf, ceil, ceill and ceilf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. This is the case for s390 if build with at least --march=z196 --mzarch. Otherwise the generic implementation is used. The code of the generic implementation is not changed. Reviewed-by: Adhemerval Zanella --- sysdeps/generic/math-use-builtins.h | 5 +++++ sysdeps/ieee754/dbl-64/s_ceil.c | 6 ++++++ sysdeps/ieee754/float128/float128_private.h | 3 +++ sysdeps/ieee754/flt-32/s_ceilf.c | 7 ++++++- sysdeps/ieee754/ldbl-128/s_ceill.c | 6 ++++++ sysdeps/s390/fpu/math-use-builtins.h | 11 +++++++++++ 6 files changed, 37 insertions(+), 1 deletion(-) diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h index e1c5df62e4..076ec661b0 100644 --- a/sysdeps/generic/math-use-builtins.h +++ b/sysdeps/generic/math-use-builtins.h @@ -36,4 +36,9 @@ #define USE_FLOORL_BUILTIN 0 #define USE_FLOORF128_BUILTIN 0 +#define USE_CEIL_BUILTIN 0 +#define USE_CEILF_BUILTIN 0 +#define USE_CEILL_BUILTIN 0 +#define USE_CEILF128_BUILTIN 0 + #endif /* math-use-builtins.h */ diff --git a/sysdeps/ieee754/dbl-64/s_ceil.c b/sysdeps/ieee754/dbl-64/s_ceil.c index 8d66f027e7..3738211360 100644 --- a/sysdeps/ieee754/dbl-64/s_ceil.c +++ b/sysdeps/ieee754/dbl-64/s_ceil.c @@ -21,10 +21,15 @@ #include #include #include +#include double __ceil (double x) { +#if USE_CEIL_BUILTIN + return __builtin_ceil (x); +#else + /* Use generic implementation. */ int64_t i0, i; int32_t j0; EXTRACT_WORDS64 (i0, x); @@ -58,6 +63,7 @@ __ceil (double x) } INSERT_WORDS64 (x, i0); return x; +#endif /* ! USE_CEIL_BUILTIN */ } #ifndef __ceil libm_alias_double (__ceil, ceil) diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h index 8c8a74a12c..01881b574a 100644 --- a/sysdeps/ieee754/float128/float128_private.h +++ b/sysdeps/ieee754/float128/float128_private.h @@ -146,6 +146,8 @@ #define USE_RINTL_BUILTIN USE_RINTF128_BUILTIN #undef USE_FLOORL_BUILTIN #define USE_FLOORL_BUILTIN USE_FLOORF128_BUILTIN +#undef USE_CEILL_BUILTIN +#define USE_CEILL_BUILTIN USE_CEILF128_BUILTIN /* IEEE function renames. */ #define __ieee754_acoshl __ieee754_acoshf128 @@ -352,6 +354,7 @@ #define __builtin_nearbyintl __builtin_nearbyintf128 #define __builtin_rintl __builtin_rintf128 #define __builtin_floorl __builtin_floorf128 +#define __builtin_ceill __builtin_ceilf128 /* Get the constant suffix from bits/floatn-compat.h. */ #define L(x) __f128 (x) diff --git a/sysdeps/ieee754/flt-32/s_ceilf.c b/sysdeps/ieee754/flt-32/s_ceilf.c index 25cba0807c..7d4990f3ff 100644 --- a/sysdeps/ieee754/flt-32/s_ceilf.c +++ b/sysdeps/ieee754/flt-32/s_ceilf.c @@ -17,11 +17,15 @@ #include #include #include - +#include float __ceilf(float x) { +#if USE_CEILF_BUILTIN + return __builtin_ceilf (x); +#else + /* Use generic implementation. */ int32_t i0,j0; uint32_t i; @@ -44,6 +48,7 @@ __ceilf(float x) } SET_FLOAT_WORD(x,i0); return x; +#endif /* ! USE_CEILF_BUILTIN */ } #ifndef __ceilf libm_alias_float (__ceil, ceil) diff --git a/sysdeps/ieee754/ldbl-128/s_ceill.c b/sysdeps/ieee754/ldbl-128/s_ceill.c index 2ec55de25a..02ffa7af2b 100644 --- a/sysdeps/ieee754/ldbl-128/s_ceill.c +++ b/sysdeps/ieee754/ldbl-128/s_ceill.c @@ -28,9 +28,14 @@ static char rcsid[] = "$NetBSD: $"; #include #include #include +#include _Float128 __ceill(_Float128 x) { +#if USE_CEILL_BUILTIN + return __builtin_ceill (x); +#else + /* Use generic implementation. */ int64_t i0,i1,j0; uint64_t i,j; GET_LDOUBLE_WORDS64(i0,i1,x); @@ -64,5 +69,6 @@ _Float128 __ceill(_Float128 x) } SET_LDOUBLE_WORDS64(x,i0,i1); return x; +#endif /* ! USE_CEILL_BUILTIN */ } libm_alias_ldouble (__ceil, ceil) diff --git a/sysdeps/s390/fpu/math-use-builtins.h b/sysdeps/s390/fpu/math-use-builtins.h index c213c16c6f..5435cbb65f 100644 --- a/sysdeps/s390/fpu/math-use-builtins.h +++ b/sysdeps/s390/fpu/math-use-builtins.h @@ -38,14 +38,20 @@ # define USE_FLOORF_BUILTIN 1 # define USE_FLOORL_BUILTIN 1 +# define USE_CEIL_BUILTIN 1 +# define USE_CEILF_BUILTIN 1 +# define USE_CEILL_BUILTIN 1 + # if __GNUC_PREREQ (8, 0) # define USE_NEARBYINTF128_BUILTIN 1 # define USE_RINTF128_BUILTIN 1 # define USE_FLOORF128_BUILTIN 1 +# define USE_CEILF128_BUILTIN 1 # else # define USE_NEARBYINTF128_BUILTIN 0 # define USE_RINTF128_BUILTIN 0 # define USE_FLOORF128_BUILTIN 0 +# define USE_CEILF128_BUILTIN 0 # endif #else @@ -66,6 +72,11 @@ # define USE_FLOORL_BUILTIN 0 # define USE_FLOORF128_BUILTIN 0 +# define USE_CEIL_BUILTIN 0 +# define USE_CEILF_BUILTIN 0 +# define USE_CEILL_BUILTIN 0 +# define USE_CEILF128_BUILTIN 0 + #endif /* ! HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT */ #endif /* math-use-builtins.h */ From patchwork Mon Dec 9 12:46:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206182 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107837-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="jNYjhfFy"; 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 47Wjjc3fYVz9sR1 for ; Mon, 9 Dec 2019 23:51:00 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=PAKlgZ6XS/0+J5dnsdCzS3lsw6cHiO7 ZLtm4WGkpNWg9VYHDhLhWdIxFasV+FRw0o9QULzmbbuUUifitlaosPC2+8BHlND8 dnj+VxYZoQWT04h76ryMkOpjmTP2iFGBeA63W+hhF2AHxQaqM8R+XO/1ODTXuX/8 IWplCuu1Dqe4= 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:in-reply-to:references :message-id; s=default; bh=zzzDq76X9v+7iJNys8bmzxAcMpM=; b=jNYjh fFyzA1kQNgUYzE6zZ5MTyFkaBi2/8W8Vec93madZD8ZCTPMwxdY2vNegJiiDTmVb Cglz3JMmeNUfatH6DXWwqlrfpTUYzARI8IrfPJ1BSELthG1M0OezxUBUfgK29Dxv qZ1llk7dLj+uhJb1PA6zKPQ2nlnfEJ44QyFlEg= Received: (qmail 97968 invoked by alias); 9 Dec 2019 12:50:55 -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 97957 invoked by uid 89); 9 Dec 2019 12:50:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 11/18] Use GCC builtins for trunc functions if desired. Date: Mon, 9 Dec 2019 13:46:01 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0012-0000-0000-000003731F6D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0013-0000-0000-000021AEEDBC Message-Id: <1575895568-26473-12-git-send-email-stli@linux.ibm.com> This patch is using the corresponding GCC builtin for truncf, trunc, truncl and truncf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. This is the case for s390 if build with at least --march=z196 --mzarch. Otherwise the generic implementation is used. The code of the generic implementation is not changed. Reviewed-by: Adhemerval Zanella --- sysdeps/generic/math-use-builtins.h | 5 +++++ sysdeps/ieee754/dbl-64/s_trunc.c | 6 ++++++ sysdeps/ieee754/float128/float128_private.h | 3 +++ sysdeps/ieee754/flt-32/s_truncf.c | 6 ++++++ sysdeps/ieee754/ldbl-128/s_truncl.c | 6 ++++++ sysdeps/s390/fpu/math-use-builtins.h | 11 +++++++++++ 6 files changed, 37 insertions(+) diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h index 076ec661b0..ab379f45ba 100644 --- a/sysdeps/generic/math-use-builtins.h +++ b/sysdeps/generic/math-use-builtins.h @@ -41,4 +41,9 @@ #define USE_CEILL_BUILTIN 0 #define USE_CEILF128_BUILTIN 0 +#define USE_TRUNC_BUILTIN 0 +#define USE_TRUNCF_BUILTIN 0 +#define USE_TRUNCL_BUILTIN 0 +#define USE_TRUNCF128_BUILTIN 0 + #endif /* math-use-builtins.h */ diff --git a/sysdeps/ieee754/dbl-64/s_trunc.c b/sysdeps/ieee754/dbl-64/s_trunc.c index 0de68ce298..c3129fea7b 100644 --- a/sysdeps/ieee754/dbl-64/s_trunc.c +++ b/sysdeps/ieee754/dbl-64/s_trunc.c @@ -22,11 +22,16 @@ #include #include +#include double __trunc (double x) { +#if USE_TRUNC_BUILTIN + return __builtin_trunc (x); +#else + /* Use generic implementation. */ int64_t i0, j0; int64_t sx; @@ -49,6 +54,7 @@ __trunc (double x) } return x; +#endif /* ! USE_TRUNC_BUILTIN */ } #ifndef __trunc libm_alias_double (__trunc, trunc) diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h index 01881b574a..9cd3a63f11 100644 --- a/sysdeps/ieee754/float128/float128_private.h +++ b/sysdeps/ieee754/float128/float128_private.h @@ -148,6 +148,8 @@ #define USE_FLOORL_BUILTIN USE_FLOORF128_BUILTIN #undef USE_CEILL_BUILTIN #define USE_CEILL_BUILTIN USE_CEILF128_BUILTIN +#undef USE_TRUNCL_BUILTIN +#define USE_TRUNCL_BUILTIN USE_TRUNCF128_BUILTIN /* IEEE function renames. */ #define __ieee754_acoshl __ieee754_acoshf128 @@ -355,6 +357,7 @@ #define __builtin_rintl __builtin_rintf128 #define __builtin_floorl __builtin_floorf128 #define __builtin_ceill __builtin_ceilf128 +#define __builtin_truncl __builtin_truncf128 /* Get the constant suffix from bits/floatn-compat.h. */ #define L(x) __f128 (x) diff --git a/sysdeps/ieee754/flt-32/s_truncf.c b/sysdeps/ieee754/flt-32/s_truncf.c index e587706b5b..274638820e 100644 --- a/sysdeps/ieee754/flt-32/s_truncf.c +++ b/sysdeps/ieee754/flt-32/s_truncf.c @@ -22,11 +22,16 @@ #include #include +#include float __truncf (float x) { +#if USE_TRUNCF_BUILTIN + return __builtin_truncf (x); +#else + /* Use generic implementation. */ int32_t i0, j0; int sx; @@ -49,6 +54,7 @@ __truncf (float x) } return x; +#endif /* ! USE_TRUNCF_BUILTIN */ } #ifndef __truncf libm_alias_float (__trunc, trunc) diff --git a/sysdeps/ieee754/ldbl-128/s_truncl.c b/sysdeps/ieee754/ldbl-128/s_truncl.c index de4dd34d59..d11ab937e2 100644 --- a/sysdeps/ieee754/ldbl-128/s_truncl.c +++ b/sysdeps/ieee754/ldbl-128/s_truncl.c @@ -23,11 +23,16 @@ #include #include +#include _Float128 __truncl (_Float128 x) { +#if USE_TRUNCL_BUILTIN + return __builtin_truncl (x); +#else + /* Use generic implementation. */ int32_t j0; uint64_t i0, i1, sx; @@ -54,5 +59,6 @@ __truncl (_Float128 x) } return x; +#endif /* ! USE_TRUNCL_BUILTIN */ } libm_alias_ldouble (__trunc, trunc) diff --git a/sysdeps/s390/fpu/math-use-builtins.h b/sysdeps/s390/fpu/math-use-builtins.h index 5435cbb65f..a39715c612 100644 --- a/sysdeps/s390/fpu/math-use-builtins.h +++ b/sysdeps/s390/fpu/math-use-builtins.h @@ -42,16 +42,22 @@ # define USE_CEILF_BUILTIN 1 # define USE_CEILL_BUILTIN 1 +# define USE_TRUNC_BUILTIN 1 +# define USE_TRUNCF_BUILTIN 1 +# define USE_TRUNCL_BUILTIN 1 + # if __GNUC_PREREQ (8, 0) # define USE_NEARBYINTF128_BUILTIN 1 # define USE_RINTF128_BUILTIN 1 # define USE_FLOORF128_BUILTIN 1 # define USE_CEILF128_BUILTIN 1 +# define USE_TRUNCF128_BUILTIN 1 # else # define USE_NEARBYINTF128_BUILTIN 0 # define USE_RINTF128_BUILTIN 0 # define USE_FLOORF128_BUILTIN 0 # define USE_CEILF128_BUILTIN 0 +# define USE_TRUNCF128_BUILTIN 0 # endif #else @@ -77,6 +83,11 @@ # define USE_CEILL_BUILTIN 0 # define USE_CEILF128_BUILTIN 0 +# define USE_TRUNC_BUILTIN 0 +# define USE_TRUNCF_BUILTIN 0 +# define USE_TRUNCL_BUILTIN 0 +# define USE_TRUNCF128_BUILTIN 0 + #endif /* ! HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT */ #endif /* math-use-builtins.h */ From patchwork Mon Dec 9 12:46:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206183 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107838-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="h5OhCxK+"; 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 47Wjjt5mNlz9sPh for ; Mon, 9 Dec 2019 23:51:14 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=nHjVZIJ1OgaxRlbziSskvZtuUnipAHN oMl0EL/wvRABpIWFjNXHcLhwtGCrr0BanbBZMx0P4DdoG7ntABSsPkLdvoP+vhIT kVWRDM3l4xg3TH4rNqKDkoOgGFIp7Re//znVnxSKnLAEy8d9xiQdmacl3gTp//hv Tjz5BriWWt2Q= 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:in-reply-to:references :message-id; s=default; bh=vwV42X7nFFK1uN+Ke7WZBMTe4OA=; b=h5OhC xK+XMSCSaQ5KJcohlvBxuPAxAdaWhkbBVAG7qVRtL4txbabj3W/czhepVrlTUTGW EaEcQnEzgDgKNzf65katzk/zOsl/n/FTMdEqOItzblP2kAfwEqCb1Zv091uQrjut VqnNPPQ/6WcJqDpGezeyPaMScyKQsnBhWwkfW8= Received: (qmail 99225 invoked by alias); 9 Dec 2019 12:51:08 -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 99217 invoked by uid 89); 9 Dec 2019 12:51:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 12/18] Use GCC builtins for round functions if desired. Date: Mon, 9 Dec 2019 13:46:02 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0020-0000-0000-00000395D581 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0021-0000-0000-000021ED1056 Message-Id: <1575895568-26473-13-git-send-email-stli@linux.ibm.com> This patch is using the corresponding GCC builtin for roundf, round, roundl and roundf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. This is the case for s390 if build with at least --march=z196 --mzarch. Otherwise the generic implementation is used. The code of the generic implementation is not changed. Reviewed-by: Adhemerval Zanella --- sysdeps/generic/math-use-builtins.h | 5 +++++ sysdeps/ieee754/dbl-64/s_round.c | 6 ++++++ sysdeps/ieee754/float128/float128_private.h | 3 +++ sysdeps/ieee754/flt-32/s_roundf.c | 6 ++++++ sysdeps/ieee754/ldbl-128/s_roundl.c | 6 ++++++ sysdeps/s390/fpu/math-use-builtins.h | 11 +++++++++++ 6 files changed, 37 insertions(+) diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h index ab379f45ba..34ca438a8c 100644 --- a/sysdeps/generic/math-use-builtins.h +++ b/sysdeps/generic/math-use-builtins.h @@ -46,4 +46,9 @@ #define USE_TRUNCL_BUILTIN 0 #define USE_TRUNCF128_BUILTIN 0 +#define USE_ROUND_BUILTIN 0 +#define USE_ROUNDF_BUILTIN 0 +#define USE_ROUNDL_BUILTIN 0 +#define USE_ROUNDF128_BUILTIN 0 + #endif /* math-use-builtins.h */ diff --git a/sysdeps/ieee754/dbl-64/s_round.c b/sysdeps/ieee754/dbl-64/s_round.c index 8f4b7cff86..7eb1ecb482 100644 --- a/sysdeps/ieee754/dbl-64/s_round.c +++ b/sysdeps/ieee754/dbl-64/s_round.c @@ -23,11 +23,16 @@ #include #include #include +#include double __round (double x) { +#if USE_ROUND_BUILTIN + return __builtin_round (x); +#else + /* Use generic implementation. */ int64_t i0, j0; EXTRACT_WORDS64 (i0, x); @@ -62,5 +67,6 @@ __round (double x) INSERT_WORDS64 (x, i0); return x; +#endif /* ! USE_ROUND_BUILTIN */ } libm_alias_double (__round, round) diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h index 9cd3a63f11..a6c76ce364 100644 --- a/sysdeps/ieee754/float128/float128_private.h +++ b/sysdeps/ieee754/float128/float128_private.h @@ -150,6 +150,8 @@ #define USE_CEILL_BUILTIN USE_CEILF128_BUILTIN #undef USE_TRUNCL_BUILTIN #define USE_TRUNCL_BUILTIN USE_TRUNCF128_BUILTIN +#undef USE_ROUNDL_BUILTIN +#define USE_ROUNDL_BUILTIN USE_ROUNDF128_BUILTIN /* IEEE function renames. */ #define __ieee754_acoshl __ieee754_acoshf128 @@ -358,6 +360,7 @@ #define __builtin_floorl __builtin_floorf128 #define __builtin_ceill __builtin_ceilf128 #define __builtin_truncl __builtin_truncf128 +#define __builtin_roundl __builtin_roundf128 /* Get the constant suffix from bits/floatn-compat.h. */ #define L(x) __f128 (x) diff --git a/sysdeps/ieee754/flt-32/s_roundf.c b/sysdeps/ieee754/flt-32/s_roundf.c index cddab7b505..5d91239d6e 100644 --- a/sysdeps/ieee754/flt-32/s_roundf.c +++ b/sysdeps/ieee754/flt-32/s_roundf.c @@ -22,11 +22,16 @@ #include #include +#include float __roundf (float x) { +#if USE_ROUNDF_BUILTIN + return __builtin_roundf (x); +#else + /* Use generic implementation. */ int32_t i0, j0; GET_FLOAT_WORD (i0, x); @@ -61,5 +66,6 @@ __roundf (float x) SET_FLOAT_WORD (x, i0); return x; +#endif /* ! USE_ROUNDF_BUILTIN */ } libm_alias_float (__round, round) diff --git a/sysdeps/ieee754/ldbl-128/s_roundl.c b/sysdeps/ieee754/ldbl-128/s_roundl.c index d41c9a04dc..8c7ae82217 100644 --- a/sysdeps/ieee754/ldbl-128/s_roundl.c +++ b/sysdeps/ieee754/ldbl-128/s_roundl.c @@ -23,11 +23,16 @@ #include #include +#include _Float128 __roundl (_Float128 x) { +#if USE_ROUNDL_BUILTIN + return __builtin_roundl (x); +#else + /* Use generic implementation. */ int32_t j0; uint64_t i1, i0; @@ -78,5 +83,6 @@ __roundl (_Float128 x) SET_LDOUBLE_WORDS64 (x, i0, i1); return x; +#endif /* ! USE_ROUNDL_BUILTIN */ } libm_alias_ldouble (__round, round) diff --git a/sysdeps/s390/fpu/math-use-builtins.h b/sysdeps/s390/fpu/math-use-builtins.h index a39715c612..51cb9f91ab 100644 --- a/sysdeps/s390/fpu/math-use-builtins.h +++ b/sysdeps/s390/fpu/math-use-builtins.h @@ -46,18 +46,24 @@ # define USE_TRUNCF_BUILTIN 1 # define USE_TRUNCL_BUILTIN 1 +# define USE_ROUND_BUILTIN 1 +# define USE_ROUNDF_BUILTIN 1 +# define USE_ROUNDL_BUILTIN 1 + # if __GNUC_PREREQ (8, 0) # define USE_NEARBYINTF128_BUILTIN 1 # define USE_RINTF128_BUILTIN 1 # define USE_FLOORF128_BUILTIN 1 # define USE_CEILF128_BUILTIN 1 # define USE_TRUNCF128_BUILTIN 1 +# define USE_ROUNDF128_BUILTIN 1 # else # define USE_NEARBYINTF128_BUILTIN 0 # define USE_RINTF128_BUILTIN 0 # define USE_FLOORF128_BUILTIN 0 # define USE_CEILF128_BUILTIN 0 # define USE_TRUNCF128_BUILTIN 0 +# define USE_ROUNDF128_BUILTIN 0 # endif #else @@ -88,6 +94,11 @@ # define USE_TRUNCL_BUILTIN 0 # define USE_TRUNCF128_BUILTIN 0 +# define USE_ROUND_BUILTIN 0 +# define USE_ROUNDF_BUILTIN 0 +# define USE_ROUNDL_BUILTIN 0 +# define USE_ROUNDF128_BUILTIN 0 + #endif /* ! HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT */ #endif /* math-use-builtins.h */ From patchwork Mon Dec 9 12:46:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206184 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107839-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="X+mc/iyB"; 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 47Wjk61y1kz9sNH for ; Mon, 9 Dec 2019 23:51:26 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=ML3BwKlmf5aZDpJ0JTQS5Yj1Gxhg3NQ LmCFDHdtrtmF59cynAWogeM6GfmID+xzUNiGt2PVawHZOAh7Yoj0gtPi5ZudLAqp N6YC5h55ClNQUAXxWxd2PMxMlqM9aDW9wdNIphcTTuEBb8l0LyqlVueLDuCOG9UJ 4cOOvzvIBW8U= 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:in-reply-to:references :message-id; s=default; bh=prnsSegdK3aeafu9KuUxYmfTdIA=; b=X+mc/ iyBwdZ74VH6qs52kNA+EiBCNZl+OxDlfNVBHJz5J+tPe/IT3guNSpqJ3WHDHzIxj twM9oQrUhIZUkYuY6zEfLmIuz51sU54wyT5P0iotDxAKscRjNZDMyDgXUux/7boc ifCMeYOdIl2WQweS4+zCCT/7u5FXJ37m2DCpP0= Received: (qmail 100394 invoked by alias); 9 Dec 2019 12:51:20 -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 100385 invoked by uid 89); 9 Dec 2019 12:51:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 13/18] Use GCC builtins for copysign functions if desired. Date: Mon, 9 Dec 2019 13:46:03 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0028-0000-0000-000003C6D82B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0029-0000-0000-0000248A0357 Message-Id: <1575895568-26473-14-git-send-email-stli@linux.ibm.com> This patch is always using the corresponding GCC builtin for copysignf, copysign, and is using the builtin for copysignl, copysignf128 if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. Altough the long double version is enabled by default we still need the macro and the alternative implementation as the _Float128 version of the builtin is not available with all supported GCC versions. Reviewed-by: Adhemerval Zanella --- sysdeps/generic/math-use-builtins.h | 9 +++++++++ sysdeps/ieee754/dbl-64/s_copysign.c | 9 ++------- sysdeps/ieee754/float128/float128_private.h | 3 +++ sysdeps/ieee754/flt-32/s_copysignf.c | 12 ++++-------- sysdeps/ieee754/ldbl-128/s_copysignl.c | 6 ++++++ sysdeps/s390/fpu/math-use-builtins.h | 7 +++++++ 6 files changed, 31 insertions(+), 15 deletions(-) diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h index 34ca438a8c..770b54ce61 100644 --- a/sysdeps/generic/math-use-builtins.h +++ b/sysdeps/generic/math-use-builtins.h @@ -19,6 +19,8 @@ #ifndef MATH_USE_BUILTINS_H #define MATH_USE_BUILTINS_H 1 +#include /* For __GNUC_PREREQ. */ + /* Define these macros to 1 to use __builtin_xyz instead of the generic implementation. */ #define USE_NEARBYINT_BUILTIN 0 @@ -51,4 +53,11 @@ #define USE_ROUNDL_BUILTIN 0 #define USE_ROUNDF128_BUILTIN 0 +#define USE_COPYSIGNL_BUILTIN 1 +#if __GNUC_PREREQ (7, 0) +# define USE_COPYSIGNF128_BUILTIN 1 +#else +# define USE_COPYSIGNF128_BUILTIN 0 +#endif + #endif /* math-use-builtins.h */ diff --git a/sysdeps/ieee754/dbl-64/s_copysign.c b/sysdeps/ieee754/dbl-64/s_copysign.c index 589b088c95..94025b7854 100644 --- a/sysdeps/ieee754/dbl-64/s_copysign.c +++ b/sysdeps/ieee754/dbl-64/s_copysign.c @@ -10,7 +10,7 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) +#if defined (LIBM_SCCS) && ! defined (lint) static char rcsid[] = "$NetBSD: s_copysign.c,v 1.8 1995/05/10 20:46:57 jtc Exp $"; #endif @@ -22,16 +22,11 @@ static char rcsid[] = "$NetBSD: s_copysign.c,v 1.8 1995/05/10 20:46:57 jtc Exp $ #define NO_MATH_REDIRECT #include -#include #include double __copysign (double x, double y) { - uint32_t hx, hy; - GET_HIGH_WORD (hx, x); - GET_HIGH_WORD (hy, y); - SET_HIGH_WORD (x, (hx & 0x7fffffff) | (hy & 0x80000000)); - return x; + return __builtin_copysign (x, y); } libm_alias_double (__copysign, copysign) diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h index a6c76ce364..7f7f904152 100644 --- a/sysdeps/ieee754/float128/float128_private.h +++ b/sysdeps/ieee754/float128/float128_private.h @@ -152,6 +152,8 @@ #define USE_TRUNCL_BUILTIN USE_TRUNCF128_BUILTIN #undef USE_ROUNDL_BUILTIN #define USE_ROUNDL_BUILTIN USE_ROUNDF128_BUILTIN +#undef USE_COPYSIGNL_BUILTIN +#define USE_COPYSIGNL_BUILTIN USE_COPYSIGNF128_BUILTIN /* IEEE function renames. */ #define __ieee754_acoshl __ieee754_acoshf128 @@ -361,6 +363,7 @@ #define __builtin_ceill __builtin_ceilf128 #define __builtin_truncl __builtin_truncf128 #define __builtin_roundl __builtin_roundf128 +#define __builtin_copysignl __builtin_copysignf128 /* Get the constant suffix from bits/floatn-compat.h. */ #define L(x) __f128 (x) diff --git a/sysdeps/ieee754/flt-32/s_copysignf.c b/sysdeps/ieee754/flt-32/s_copysignf.c index 77d1d90e92..1c097d313f 100644 --- a/sysdeps/ieee754/flt-32/s_copysignf.c +++ b/sysdeps/ieee754/flt-32/s_copysignf.c @@ -13,7 +13,7 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) +#if defined (LIBM_SCCS) && ! defined (lint) static char rcsid[] = "$NetBSD: s_copysignf.c,v 1.4 1995/05/10 20:46:59 jtc Exp $"; #endif @@ -25,15 +25,11 @@ static char rcsid[] = "$NetBSD: s_copysignf.c,v 1.4 1995/05/10 20:46:59 jtc Exp #define NO_MATH_REDIRECT #include -#include #include -float __copysignf(float x, float y) +float +__copysignf (float x, float y) { - uint32_t ix,iy; - GET_FLOAT_WORD(ix,x); - GET_FLOAT_WORD(iy,y); - SET_FLOAT_WORD(x,(ix&0x7fffffff)|(iy&0x80000000)); - return x; + return __builtin_copysignf (x, y); } libm_alias_float (__copysign, copysign) diff --git a/sysdeps/ieee754/ldbl-128/s_copysignl.c b/sysdeps/ieee754/ldbl-128/s_copysignl.c index a501139f71..848a184524 100644 --- a/sysdeps/ieee754/ldbl-128/s_copysignl.c +++ b/sysdeps/ieee754/ldbl-128/s_copysignl.c @@ -27,14 +27,20 @@ static char rcsid[] = "$NetBSD: $"; #include #include #include +#include _Float128 __copysignl(_Float128 x, _Float128 y) { +#if USE_COPYSIGNL_BUILTIN + return __builtin_copysignl (x, y); +#else + /* Use generic implementation. */ uint64_t hx,hy; GET_LDOUBLE_MSW64(hx,x); GET_LDOUBLE_MSW64(hy,y); SET_LDOUBLE_MSW64(x,(hx&0x7fffffffffffffffULL) |(hy&0x8000000000000000ULL)); return x; +#endif /* ! USE_COPYSIGNL_BUILTIN */ } libm_alias_ldouble (__copysign, copysign) diff --git a/sysdeps/s390/fpu/math-use-builtins.h b/sysdeps/s390/fpu/math-use-builtins.h index 51cb9f91ab..4c4aad2ab5 100644 --- a/sysdeps/s390/fpu/math-use-builtins.h +++ b/sysdeps/s390/fpu/math-use-builtins.h @@ -101,4 +101,11 @@ #endif /* ! HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT */ +#define USE_COPYSIGNL_BUILTIN 1 +#if __GNUC_PREREQ (7, 0) +# define USE_COPYSIGNF128_BUILTIN 1 +#else +# define USE_COPYSIGNF128_BUILTIN 0 +#endif + #endif /* math-use-builtins.h */ From patchwork Mon Dec 9 12:46:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107840-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="yugVm8WB"; 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 47WjkM3MSWz9sNH for ; Mon, 9 Dec 2019 23:51:39 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=KQ22wKBeymhl0NfpQ+EOa/KM1ymgH+g 8AfyJDg0VYAIePmfqf0mCDO4gns54fkupw/eUYwnMQJN2JiHL0RxjHojXCmRvFlP rEQSCl1+NVA1Is41Zk5ZgdXPIpEOGNlrz/SmoBs33jc2FLxFc2BH9UEcAFi0j9x8 b+C9TF2nBBmE= 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:in-reply-to:references :message-id; s=default; bh=n4mLcKqIQWv4nzNGIaUuteDhFpY=; b=yugVm 8WBkxozARMI4E4+oq5cY2UzTacY9IzO+Y26eEEsXUt8sFuccv3qeOSpQIjcAUv28 ik+TN+IT54iwTH56Ucvjc/WAFE1YsKivcI+HAefkJ0fz8idcYZ9YzH3G+G80BTb6 6F7Rq/q4aoBLHoUYJdRv34p+L+9InxdW13NRxw= Received: (qmail 101622 invoked by alias); 9 Dec 2019 12:51:33 -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 101610 invoked by uid 89); 9 Dec 2019 12:51:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 14/18] Adjust s_nearbyintf.c and s_nearbyintl.c regarding code style. Date: Mon, 9 Dec 2019 13:46:04 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0028-0000-0000-000003C6D830 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0029-0000-0000-0000248A035D Message-Id: <1575895568-26473-15-git-send-email-stli@linux.ibm.com> This patch just adjusts the generic implementation regarding code style. No functional change. Reviewed-by: Adhemerval Zanella --- sysdeps/ieee754/flt-32/s_nearbyintf.c | 60 ++++++++++++----------- sysdeps/ieee754/ldbl-128/s_nearbyintl.c | 63 ++++++++++++++----------- 2 files changed, 68 insertions(+), 55 deletions(-) diff --git a/sysdeps/ieee754/flt-32/s_nearbyintf.c b/sysdeps/ieee754/flt-32/s_nearbyintf.c index b37e003e12..2a79907168 100644 --- a/sysdeps/ieee754/flt-32/s_nearbyintf.c +++ b/sysdeps/ieee754/flt-32/s_nearbyintf.c @@ -24,7 +24,7 @@ #include float -__nearbyintf(float x) +__nearbyintf (float x) { #if USE_NEARBYINTF_BUILTIN return __builtin_nearbyintf (x); @@ -35,33 +35,39 @@ __nearbyintf(float x) 8.3886080000e+06, /* 0x4b000000 */ -8.3886080000e+06, /* 0xcb000000 */ }; - fenv_t env; - int32_t i0,j0,sx; - float w,t; - GET_FLOAT_WORD(i0,x); - sx = (i0>>31)&1; - j0 = ((i0>>23)&0xff)-0x7f; - if(j0<23) { - if(j0<0) { - libc_feholdexceptf (&env); - w = TWO23[sx] + math_opt_barrier (x); - t = w-TWO23[sx]; - math_force_eval (t); - libc_fesetenvf (&env); - GET_FLOAT_WORD(i0,t); - SET_FLOAT_WORD(t,(i0&0x7fffffff)|(sx<<31)); - return t; - } - } else { - if(__builtin_expect(j0==0x80, 0)) return x+x; /* inf or NaN */ - else return x; /* x is integral */ + fenv_t env; + int32_t i0, j0, sx; + float w, t; + GET_FLOAT_WORD (i0, x); + sx = (i0 >> 31) & 1; + j0 = ((i0 >> 23) & 0xff) - 0x7f; + if (j0 < 23) + { + if (j0 < 0) + { + libc_feholdexceptf (&env); + w = TWO23[sx] + math_opt_barrier (x); + t = w - TWO23[sx]; + math_force_eval (t); + libc_fesetenvf (&env); + GET_FLOAT_WORD (i0, t); + SET_FLOAT_WORD (t, (i0 & 0x7fffffff) | (sx << 31)); + return t; } - libc_feholdexceptf (&env); - w = TWO23[sx] + math_opt_barrier (x); - t = w-TWO23[sx]; - math_force_eval (t); - libc_fesetenvf (&env); - return t; + } + else + { + if (__glibc_unlikely (j0 == 0x80)) + return x + x; /* inf or NaN */ + else + return x; /* x is integral */ + } + libc_feholdexceptf (&env); + w = TWO23[sx] + math_opt_barrier (x); + t = w - TWO23[sx]; + math_force_eval (t); + libc_fesetenvf (&env); + return t; #endif /* ! USE_NEARBYINT_BUILTIN */ } libm_alias_float (__nearbyint, nearbyint) diff --git a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c index a4ad8e82e5..8d26786f78 100644 --- a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c +++ b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c @@ -30,7 +30,8 @@ #include #include -_Float128 __nearbyintl(_Float128 x) +_Float128 +__nearbyintl (_Float128 x) { #if USE_NEARBYINTL_BUILTIN return __builtin_nearbyintl (x); @@ -41,34 +42,40 @@ _Float128 __nearbyintl(_Float128 x) L(5.19229685853482762853049632922009600E+33), /* 0x406F000000000000, 0 */ L(-5.19229685853482762853049632922009600E+33) /* 0xC06F000000000000, 0 */ }; - fenv_t env; - int64_t i0,j0,sx; - uint64_t i1 __attribute__ ((unused)); - _Float128 w,t; - GET_LDOUBLE_WORDS64(i0,i1,x); - sx = (((uint64_t)i0)>>63); - j0 = ((i0>>48)&0x7fff)-0x3fff; - if(j0<112) { - if(j0<0) { - feholdexcept (&env); - w = TWO112[sx] + math_opt_barrier (x); - t = w-TWO112[sx]; - math_force_eval (t); - fesetenv (&env); - GET_LDOUBLE_MSW64(i0,t); - SET_LDOUBLE_MSW64(t,(i0&0x7fffffffffffffffLL)|(sx<<63)); - return t; - } - } else { - if(j0==0x4000) return x+x; /* inf or NaN */ - else return x; /* x is integral */ + fenv_t env; + int64_t i0, j0, sx; + uint64_t i1 __attribute__ ((unused)); + _Float128 w, t; + GET_LDOUBLE_WORDS64 (i0, i1, x); + sx = (((uint64_t) i0) >> 63); + j0 = ((i0 >> 48) & 0x7fff) - 0x3fff; + if (j0 < 112) + { + if (j0 < 0) + { + feholdexcept (&env); + w = TWO112[sx] + math_opt_barrier (x); + t = w - TWO112[sx]; + math_force_eval (t); + fesetenv (&env); + GET_LDOUBLE_MSW64 (i0, t); + SET_LDOUBLE_MSW64 (t, (i0 & 0x7fffffffffffffffLL) | (sx << 63)); + return t; } - feholdexcept (&env); - w = TWO112[sx] + math_opt_barrier (x); - t = w-TWO112[sx]; - math_force_eval (t); - fesetenv (&env); - return t; + } + else + { + if (j0 == 0x4000) + return x + x; /* inf or NaN */ + else + return x; /* x is integral */ + } + feholdexcept (&env); + w = TWO112[sx] + math_opt_barrier (x); + t = w - TWO112[sx]; + math_force_eval (t); + fesetenv (&env); + return t; #endif /* ! USE_NEARBYINTL_BUILTIN */ } libm_alias_ldouble (__nearbyint, nearbyint) From patchwork Mon Dec 9 12:46:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107841-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Z/CL2Otx"; 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 47Wjkf0Sqmz9sNH for ; Mon, 9 Dec 2019 23:51:53 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=N5HW+qGyfhTzAyr3cATaS3GXiqQnor1 tJwcegpK/LAQ1BSCGwouqussB3YyjCZp20BKs+kao8+V1bQMSJd34V0CmUo/THM8 kRjO67YMTEQpE1msS0e9llYS7K9NsSlEGiIAfqvSEH4GNa6MdKcFQXT5wG+DK9Fy 8M7N4WFLxQXY= 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:in-reply-to:references :message-id; s=default; bh=GLbBMvPzqZ9YU6tQ6HPv+Ha7fDA=; b=Z/CL2 OtxC4UcdvBaKyUKCA6j9QuhFxhU+3OWLKEoxuoCgKaksgYdU52Ud+/Hq6rBVjQsJ DpDc4j9ZqmA7tbEmX1oGbs6H4Jw4C0kxd4X9rh4tUNw3pbtkXQBqpR32u1mSeymV DofMC+gGeqe8Eoi9BToxwGx6ryHcePHfSznHj0= Received: (qmail 102865 invoked by alias); 9 Dec 2019 12:51:48 -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 102857 invoked by uid 89); 9 Dec 2019 12:51:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 15/18] Adjust s_rintf.c and s_rintl.c regarding code style. Date: Mon, 9 Dec 2019 13:46:05 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0028-0000-0000-000003C6D837 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0029-0000-0000-0000248A0363 Message-Id: <1575895568-26473-16-git-send-email-stli@linux.ibm.com> This patch just adjusts the generic implementation regarding code style. No functional change. Reviewed-by: Adhemerval Zanella --- sysdeps/ieee754/flt-32/s_rintf.c | 44 +++++++++++++++------------ sysdeps/ieee754/ldbl-128/s_rintl.c | 49 +++++++++++++++++------------- 2 files changed, 53 insertions(+), 40 deletions(-) diff --git a/sysdeps/ieee754/flt-32/s_rintf.c b/sysdeps/ieee754/flt-32/s_rintf.c index 34c16ea164..627bada566 100644 --- a/sysdeps/ieee754/flt-32/s_rintf.c +++ b/sysdeps/ieee754/flt-32/s_rintf.c @@ -20,7 +20,7 @@ #include float -__rintf(float x) +__rintf (float x) { #if USE_RINTF_BUILTIN return __builtin_rintf (x); @@ -31,25 +31,31 @@ __rintf(float x) 8.3886080000e+06, /* 0x4b000000 */ -8.3886080000e+06, /* 0xcb000000 */ }; - int32_t i0,j0,sx; - float w,t; - GET_FLOAT_WORD(i0,x); - sx = (i0>>31)&1; - j0 = ((i0>>23)&0xff)-0x7f; - if(j0<23) { - if(j0<0) { - w = TWO23[sx]+x; - t = w-TWO23[sx]; - GET_FLOAT_WORD(i0,t); - SET_FLOAT_WORD(t,(i0&0x7fffffff)|(sx<<31)); - return t; - } - } else { - if(j0==0x80) return x+x; /* inf or NaN */ - else return x; /* x is integral */ + int32_t i0, j0, sx; + float w, t; + GET_FLOAT_WORD (i0, x); + sx = (i0 >> 31) & 1; + j0 = ((i0 >> 23) & 0xff) - 0x7f; + if (j0 < 23) + { + if(j0 < 0) + { + w = TWO23[sx] + x; + t = w - TWO23[sx]; + GET_FLOAT_WORD (i0, t); + SET_FLOAT_WORD (t, (i0 & 0x7fffffff) | (sx << 31)); + return t; } - w = TWO23[sx]+x; - return w-TWO23[sx]; + } + else + { + if (j0 == 0x80) + return x + x; /* inf or NaN */ + else + return x; /* x is integral */ + } + w = TWO23[sx] + x; + return w - TWO23[sx]; #endif /* ! USE_RINTF_BUILTIN */ } #ifndef __rintf diff --git a/sysdeps/ieee754/ldbl-128/s_rintl.c b/sysdeps/ieee754/ldbl-128/s_rintl.c index 3340c35ee1..16965f9582 100644 --- a/sysdeps/ieee754/ldbl-128/s_rintl.c +++ b/sysdeps/ieee754/ldbl-128/s_rintl.c @@ -13,7 +13,7 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) +#if defined (LIBM_SCCS) && ! defined (lint) static char rcsid[] = "$NetBSD: $"; #endif @@ -33,7 +33,8 @@ static char rcsid[] = "$NetBSD: $"; #include #include -_Float128 __rintl(_Float128 x) +_Float128 +__rintl (_Float128 x) { #if USE_RINTL_BUILTIN return __builtin_rintl (x); @@ -44,26 +45,32 @@ _Float128 __rintl(_Float128 x) 5.19229685853482762853049632922009600E+33L, /* 0x406F000000000000, 0 */ -5.19229685853482762853049632922009600E+33L /* 0xC06F000000000000, 0 */ }; - int64_t i0,j0,sx; - uint64_t i1 __attribute__ ((unused)); - _Float128 w,t; - GET_LDOUBLE_WORDS64(i0,i1,x); - sx = (((uint64_t)i0)>>63); - j0 = ((i0>>48)&0x7fff)-0x3fff; - if(j0<112) { - if(j0<0) { - w = TWO112[sx]+x; - t = w-TWO112[sx]; - GET_LDOUBLE_MSW64(i0,t); - SET_LDOUBLE_MSW64(t,(i0&0x7fffffffffffffffLL)|(sx<<63)); - return t; - } - } else { - if(j0==0x4000) return x+x; /* inf or NaN */ - else return x; /* x is integral */ + int64_t i0, j0, sx; + uint64_t i1 __attribute__ ((unused)); + _Float128 w, t; + GET_LDOUBLE_WORDS64 (i0, i1, x); + sx = (((uint64_t) i0) >> 63); + j0 = ((i0 >> 48) & 0x7fff) - 0x3fff; + if (j0 < 112) + { + if (j0 < 0) + { + w = TWO112[sx] + x; + t = w - TWO112[sx]; + GET_LDOUBLE_MSW64 (i0, t); + SET_LDOUBLE_MSW64 (t, (i0 & 0x7fffffffffffffffLL) | (sx << 63)); + return t; } - w = TWO112[sx]+x; - return w-TWO112[sx]; + } + else + { + if (j0 == 0x4000) + return x + x; /* inf or NaN */ + else + return x; /* x is integral */ + } + w = TWO112[sx] + x; + return w - TWO112[sx]; #endif /* ! USE_RINTL_BUILTIN */ } libm_alias_ldouble (__rint, rint) From patchwork Mon Dec 9 12:46:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206187 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107842-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="i18vfjgw"; 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 47Wjks3yjDz9sNH for ; Mon, 9 Dec 2019 23:52:05 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=VFr9zsP/ZzvmG7Za2GmZQK9itATAV9t J2UCwkyOzNCw7blevxR3liH/o4ywO1FVdJhXpv5gsBP/yHYKbT/DKxodsue8dn69 3jGgfIMhmqmx4K/jDekpANMcaW6jL576u5TjYv86X52G/gf0Ps3MJCDi1kC5ch8k tquuLeo7jslg= 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:in-reply-to:references :message-id; s=default; bh=vfeI9kyT4C3Gnn0smdYhcRxh1DI=; b=i18vf jgw8hkmECt/ubG0HCPMaHIees3BJYor50AoV9gcrmwbLaiZXXsx0OYtZgP23ymod wPVoXZUDPmA244ZvWCFNixjlrL91hwNQriDerJ2NP+D88gt7Mg9/QYxdXImCjl5s vVDTxaGvrqRkRNxraCqhyCLqmTIKa14I94DQfs= Received: (qmail 103979 invoked by alias); 9 Dec 2019 12:51:59 -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 103970 invoked by uid 89); 9 Dec 2019 12:51:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=3046 X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 16/18] Adjust s_floorf.c and s_floorl.c regarding code style. Date: Mon, 9 Dec 2019 13:46:06 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0016-0000-0000-000002D3202D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0017-0000-0000-0000333531B5 Message-Id: <1575895568-26473-17-git-send-email-stli@linux.ibm.com> This patch just adjusts the generic implementation regarding code style. No functional change. Reviewed-by: Adhemerval Zanella --- sysdeps/ieee754/flt-32/s_floorf.c | 55 +++++++++++------- sysdeps/ieee754/ldbl-128/s_floorl.c | 89 ++++++++++++++++++----------- 2 files changed, 90 insertions(+), 54 deletions(-) diff --git a/sysdeps/ieee754/flt-32/s_floorf.c b/sysdeps/ieee754/flt-32/s_floorf.c index afe02a1693..da6c6dfa8a 100644 --- a/sysdeps/ieee754/flt-32/s_floorf.c +++ b/sysdeps/ieee754/flt-32/s_floorf.c @@ -27,34 +27,45 @@ #include float -__floorf(float x) +__floorf (float x) { #if USE_FLOORF_BUILTIN return __builtin_floorf (x); #else /* Use generic implementation. */ - int32_t i0,j0; - uint32_t i; - GET_FLOAT_WORD(i0,x); - j0 = ((i0>>23)&0xff)-0x7f; - if(j0<23) { - if(j0<0) { - /* return 0*sign(x) if |x|<1 */ - if(i0>=0) {i0=0;} - else if((i0&0x7fffffff)!=0) - { i0=0xbf800000;} - } else { - i = (0x007fffff)>>j0; - if((i0&i)==0) return x; /* x is integral */ - if(i0<0) i0 += (0x00800000)>>j0; - i0 &= (~i); - } - } else { - if(__builtin_expect(j0==0x80, 0)) return x+x; /* inf or NaN */ - else return x; /* x is integral */ + int32_t i0, j0; + uint32_t i; + GET_FLOAT_WORD (i0, x); + j0 = ((i0 >> 23) & 0xff) - 0x7f; + if (j0 < 23) + { + if (j0 < 0) + { + /* return 0 * sign (x) if |x| < 1 */ + if (i0 >= 0) + i0 = 0; + else if ((i0 & 0x7fffffff) != 0) + i0 = 0xbf800000; } - SET_FLOAT_WORD(x,i0); - return x; + else + { + i = (0x007fffff) >> j0; + if ((i0 & i) == 0) + return x; /* x is integral */ + if (i0 < 0) + i0 += (0x00800000) >> j0; + i0 &= (~i); + } + } + else + { + if (__glibc_unlikely (j0 == 0x80)) + return x + x; /* inf or NaN */ + else + return x; /* x is integral */ + } + SET_FLOAT_WORD (x, i0); + return x; #endif /* ! USE_FLOORF_BUILTIN */ } #ifndef __floorf diff --git a/sysdeps/ieee754/ldbl-128/s_floorl.c b/sysdeps/ieee754/ldbl-128/s_floorl.c index cfe008392a..0475120d7e 100644 --- a/sysdeps/ieee754/ldbl-128/s_floorl.c +++ b/sysdeps/ieee754/ldbl-128/s_floorl.c @@ -30,46 +30,71 @@ static char rcsid[] = "$NetBSD: $"; #include #include -_Float128 __floorl(_Float128 x) +_Float128 +__floorl (_Float128 x) { #if USE_FLOORL_BUILTIN return __builtin_floorl (x); #else /* Use generic implementation. */ - int64_t i0,i1,j0; - uint64_t i,j; - GET_LDOUBLE_WORDS64(i0,i1,x); - j0 = ((i0>>48)&0x7fff)-0x3fff; - if(j0<48) { - if(j0<0) { - /* return 0*sign(x) if |x|<1 */ - if(i0>=0) {i0=i1=0;} - else if(((i0&0x7fffffffffffffffLL)|i1)!=0) - { i0=0xbfff000000000000ULL;i1=0;} - } else { - i = (0x0000ffffffffffffULL)>>j0; - if(((i0&i)|i1)==0) return x; /* x is integral */ - if(i0<0) i0 += (0x0001000000000000LL)>>j0; - i0 &= (~i); i1=0; + int64_t i0, i1, j0; + uint64_t i, j; + GET_LDOUBLE_WORDS64 (i0, i1, x); + j0 = ((i0 >> 48) & 0x7fff) - 0x3fff; + if (j0 < 48) + { + if (j0 < 0) + { + /* return 0 * sign (x) if |x| < 1 */ + if (i0 >= 0) + { + i0 = i1 = 0; } - } else if (j0>111) { - if(j0==0x4000) return x+x; /* inf or NaN */ - else return x; /* x is integral */ - } else { - i = -1ULL>>(j0-48); - if((i1&i)==0) return x; /* x is integral */ - if(i0<0) { - if(j0==48) i0+=1; - else { - j = i1+(1LL<<(112-j0)); - if(j> j0; + if (((i0 & i) | i1) == 0) + return x; /* x is integral */ + if (i0 < 0) + i0 += (0x0001000000000000LL) >> j0; + i0 &= (~i); + i1 = 0; + } + } + else if (j0 > 111) + { + if (j0 == 0x4000) + return x + x; /* inf or NaN */ + else + return x; /* x is integral */ + } + else + { + i = -1ULL >> (j0 - 48); + if ((i1 & i) == 0) + return x; /* x is integral */ + if (i0 < 0) + { + if (j0 == 48) + i0 += 1; + else + { + j = i1 + (1LL << (112 - j0)); + if (j < i1) + i0 += 1 ; /* got a carry */ + i1 = j; + } + } + i1 &= (~i); + } + SET_LDOUBLE_WORDS64 (x, i0, i1); + return x; #endif /* ! USE_FLOORL_BUILTIN */ } libm_alias_ldouble (__floor, floor) From patchwork Mon Dec 9 12:46:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206188 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107843-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="v56Gyf0T"; 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 47WjlQ0brlz9sNH for ; Mon, 9 Dec 2019 23:52:33 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=rnGq0X6yAnB64eJiTIPzqJ+n4lFvQdK kNWjDC/wRq+g16CzVtahklewJHwhiEMfn19VtMNRhu4HEEZTmCBV3GCNnGmPBceu MiixzafGM7JSfhFXVV5gfRDWxEWwgkTlO9dAcAhZtzQKGtNVd4mAeINgy4hJ5KQ5 W2dDPbbG61I4= 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:in-reply-to:references :message-id; s=default; bh=jYzIWG8S6rd2CbTlIiQUOr+6P34=; b=v56Gy f0T22jQkIgxpvQufq1mocSVTMICi5NWqcdTHgX6EEw2sVASeJnq4JQOt8hujePwW XuoA0wwEDx1ZvrI5E+cTVLNNg2THD7f8y5yz+64tAjYhMqRFslb+RkqqFitFW4X4 Uf4/FfOUxqzM41B0NXGhSAcgFWT2jSDktg6S8o= Received: (qmail 105279 invoked by alias); 9 Dec 2019 12:52:27 -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 105270 invoked by uid 89); 9 Dec 2019 12:52:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 17/18] Adjust s_ceilf.c and s_ceill.c regarding code style. Date: Mon, 9 Dec 2019 13:46:07 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0020-0000-0000-00000395D59E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0021-0000-0000-000021ED1074 Message-Id: <1575895568-26473-18-git-send-email-stli@linux.ibm.com> This patch just adjusts the generic implementation regarding code style. No functional change. Reviewed-by: Adhemerval Zanella --- sysdeps/ieee754/flt-32/s_ceilf.c | 54 +++++++++++------- sysdeps/ieee754/ldbl-128/s_ceill.c | 91 +++++++++++++++++++----------- 2 files changed, 92 insertions(+), 53 deletions(-) diff --git a/sysdeps/ieee754/flt-32/s_ceilf.c b/sysdeps/ieee754/flt-32/s_ceilf.c index 7d4990f3ff..5c4abfe145 100644 --- a/sysdeps/ieee754/flt-32/s_ceilf.c +++ b/sysdeps/ieee754/flt-32/s_ceilf.c @@ -20,34 +20,46 @@ #include float -__ceilf(float x) +__ceilf (float x) { #if USE_CEILF_BUILTIN return __builtin_ceilf (x); #else /* Use generic implementation. */ - int32_t i0,j0; - uint32_t i; + int32_t i0, j0; + uint32_t i; - GET_FLOAT_WORD(i0,x); - j0 = ((i0>>23)&0xff)-0x7f; - if(j0<23) { - if(j0<0) { - /* return 0*sign(x) if |x|<1 */ - if(i0<0) {i0=0x80000000;} - else if(i0!=0) { i0=0x3f800000;} - } else { - i = (0x007fffff)>>j0; - if((i0&i)==0) return x; /* x is integral */ - if(i0>0) i0 += (0x00800000)>>j0; - i0 &= (~i); - } - } else { - if(__builtin_expect(j0==0x80, 0)) return x+x; /* inf or NaN */ - else return x; /* x is integral */ + GET_FLOAT_WORD (i0, x); + j0 = ((i0 >> 23) & 0xff) - 0x7f; + if (j0 < 23) + { + if (j0 < 0) + { + /* return 0 * sign (x) if |x| < 1 */ + if (i0 < 0) + i0 = 0x80000000; + else if (i0 != 0) + i0 = 0x3f800000; } - SET_FLOAT_WORD(x,i0); - return x; + else + { + i = (0x007fffff) >> j0; + if ((i0 & i) == 0) + return x; /* x is integral */ + if (i0 > 0) + i0 += (0x00800000) >> j0; + i0 &= (~i); + } + } + else + { + if (__glibc_unlikely (j0 == 0x80)) + return x + x; /* inf or NaN */ + else + return x; /* x is integral */ + } + SET_FLOAT_WORD (x, i0); + return x; #endif /* ! USE_CEILF_BUILTIN */ } #ifndef __ceilf diff --git a/sysdeps/ieee754/ldbl-128/s_ceill.c b/sysdeps/ieee754/ldbl-128/s_ceill.c index 02ffa7af2b..c5d98e1e37 100644 --- a/sysdeps/ieee754/ldbl-128/s_ceill.c +++ b/sysdeps/ieee754/ldbl-128/s_ceill.c @@ -13,7 +13,7 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) +#if defined (LIBM_SCCS) && ! defined (lint) static char rcsid[] = "$NetBSD: $"; #endif @@ -30,45 +30,72 @@ static char rcsid[] = "$NetBSD: $"; #include #include -_Float128 __ceill(_Float128 x) +_Float128 +__ceill (_Float128 x) { #if USE_CEILL_BUILTIN return __builtin_ceill (x); #else /* Use generic implementation. */ - int64_t i0,i1,j0; - uint64_t i,j; - GET_LDOUBLE_WORDS64(i0,i1,x); - j0 = ((i0>>48)&0x7fff)-0x3fff; - if(j0<48) { - if(j0<0) { - /* return 0*sign(x) if |x|<1 */ - if(i0<0) {i0=0x8000000000000000ULL;i1=0;} - else if((i0|i1)!=0) { i0=0x3fff000000000000ULL;i1=0;} - } else { - i = (0x0000ffffffffffffULL)>>j0; - if(((i0&i)|i1)==0) return x; /* x is integral */ - if(i0>0) i0 += (0x0001000000000000LL)>>j0; - i0 &= (~i); i1=0; + int64_t i0, i1, j0; + uint64_t i, j; + GET_LDOUBLE_WORDS64 (i0, i1, x); + j0 = ((i0 >> 48) & 0x7fff) - 0x3fff; + if (j0 < 48) + { + if (j0 < 0) + { + /* return 0 * sign (x) if |x| < 1 */ + if (i0 < 0) + { + i0 = 0x8000000000000000ULL; + i1 = 0; } - } else if (j0>111) { - if(j0==0x4000) return x+x; /* inf or NaN */ - else return x; /* x is integral */ - } else { - i = -1ULL>>(j0-48); - if((i1&i)==0) return x; /* x is integral */ - if(i0>0) { - if(j0==48) i0+=1; - else { - j = i1+(1LL<<(112-j0)); - if(j> j0; + if (((i0 & i) | i1) == 0) + return x; /* x is integral */ + if (i0 > 0) + i0 += (0x0001000000000000LL) >> j0; + i0 &= (~i); + i1 = 0; + } + } + else if (j0 > 111) + { + if (j0 == 0x4000) + return x + x; /* inf or NaN */ + else + return x; /* x is integral */ + } + else + { + i = -1ULL >> (j0 - 48); + if ((i1 & i) == 0) + return x; /* x is integral */ + if (i0 > 0) + { + if (j0 == 48) + i0 += 1; + else + { + j = i1 + (1LL << (112 - j0)); + if (j < i1) + i0 += 1; /* got a carry */ + i1 = j; + } + } + i1 &= (~i); + } + SET_LDOUBLE_WORDS64 (x, i0, i1); + return x; #endif /* ! USE_CEILL_BUILTIN */ } libm_alias_ldouble (__ceil, ceil) From patchwork Mon Dec 9 12:46:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1206189 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107844-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Wx6fmmAt"; 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 47Wjlg5N9Dz9sNH for ; Mon, 9 Dec 2019 23:52:47 +1100 (AEDT) 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:in-reply-to:references :message-id; q=dns; s=default; b=NA7/VjOfW9emi3IM/4sftmudUFWF62R QUqbOgmR5/1GpFuHRhlI8EZw5CSuh+wT0n0GP/WujR4NDntVl4SCHu2yG/xrpg9q rlvyeLSsMPmm9aJJHtF2YlEAgA9P/pctsq0U67R6xKfTr5BzIFEdwXEny9y8/R/h j5Pq6/2at4nU= 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:in-reply-to:references :message-id; s=default; bh=qtwzPUx/bQjpE2EHaOp0VvB70vA=; b=Wx6fm mAthSr1shcQJjW04RyLtvNSNTLPBnP1IADh1RF+t0ALVkdXr5NubpqEYjsZtwBmP WARJn1pyLhEGTXOqcetgOKe3n75QYP9uhg/TYqEqTcbRakLvX7cDCUF1CeMqspok axb2k5qktgeofPhfMvzghtibLX2TR/5EWPwM5k= Received: (qmail 106720 invoked by alias); 9 Dec 2019 12:52:42 -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 106701 invoked by uid 89); 9 Dec 2019 12:52:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH v2 18/18] Adjust s_copysignl.c regarding code style. Date: Mon, 9 Dec 2019 13:46:08 +0100 In-Reply-To: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> References: <1575895568-26473-1-git-send-email-stli@linux.ibm.com> x-cbid: 19120912-0028-0000-0000-000003C6D844 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120912-0029-0000-0000-0000248A0371 Message-Id: <1575895568-26473-19-git-send-email-stli@linux.ibm.com> This patch just adjusts the generic implementation regarding code style. No functional change. Reviewed-by: Adhemerval Zanella --- sysdeps/ieee754/ldbl-128/s_copysignl.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sysdeps/ieee754/ldbl-128/s_copysignl.c b/sysdeps/ieee754/ldbl-128/s_copysignl.c index 848a184524..a8b0639d2e 100644 --- a/sysdeps/ieee754/ldbl-128/s_copysignl.c +++ b/sysdeps/ieee754/ldbl-128/s_copysignl.c @@ -13,7 +13,7 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) +#if defined (LIBM_SCCS) && ! defined (lint) static char rcsid[] = "$NetBSD: $"; #endif @@ -29,18 +29,19 @@ static char rcsid[] = "$NetBSD: $"; #include #include -_Float128 __copysignl(_Float128 x, _Float128 y) +_Float128 +__copysignl (_Float128 x, _Float128 y) { #if USE_COPYSIGNL_BUILTIN return __builtin_copysignl (x, y); #else /* Use generic implementation. */ - uint64_t hx,hy; - GET_LDOUBLE_MSW64(hx,x); - GET_LDOUBLE_MSW64(hy,y); - SET_LDOUBLE_MSW64(x,(hx&0x7fffffffffffffffULL) - |(hy&0x8000000000000000ULL)); - return x; + uint64_t hx, hy; + GET_LDOUBLE_MSW64 (hx, x); + GET_LDOUBLE_MSW64 (hy, y); + SET_LDOUBLE_MSW64 (x, (hx & 0x7fffffffffffffffULL) + | (hy & 0x8000000000000000ULL)); + return x; #endif /* ! USE_COPYSIGNL_BUILTIN */ } libm_alias_ldouble (__copysign, copysign)