From patchwork Fri Mar 29 13:35:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 161432 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2050982jan; Fri, 29 Mar 2019 06:37:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzc7Dh+Iv7RjSxDuJ5uFAkY/1YxWPVfHJxdvZXPkkItGX2h8xoFQBZvJwTuO09Mlb3GW7Sv X-Received: by 2002:a63:ef07:: with SMTP id u7mr23153210pgh.0.1553866677577; Fri, 29 Mar 2019 06:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553866677; cv=none; d=google.com; s=arc-20160816; b=GqgtYod9cSZTIyfmJFBtSt8sSclCaH8s3CVp0eacdAZa8eJ1qhrYQ9so+FZMIhW02c Svbn1MPni0CRBIka7lfOmD/KmXy2FN3fsgXNBC8Q6FD+zOPQzBKVq8qjxzArsgI/fud5 7cbIP9jnKk0C7vUSbfqKIXbfGHEkvlY2IS9O79ugn2TAaiCSt53GqZw46vbMCZFUZ46w 6QpLG1vHYSBf5U2Fow4SaeVjTJM38/AAx2PxenAYprUH1y0GfAmkG+42VVvZq2ClWh25 LbndzWd6qwqIzH247UBS1cklIhV75A9aZ6GyQw02i2lh0te8u0Nul9+ga9xcGOeartev Dtmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=DWDej6seHh/v1iAxbqOy8/sxbX16lnbFOYkBs0vzzaY=; b=TpIerUwczsu70QcVF4FMoL1rq7njSJtKdjqrmISoswVHNtLUWQUvuWwV8OBX7qrpID IF91ADFiSI39s7REJom5Lgedmevx6RQmiZlaPbrv7A3Hz/AQec2b/NNMgvFYmkBgGMJe f/+t5lU0W6xDIQfIczGKsMDPysr9v1BKMB0J4xXRV0/zHocSeE0bhQUNuDOCes03sqG5 3bb3kfa2zDPjBcdBkW6Xhd8c4ysN3WYncbykuhlcfU+2IsiHuwaH7LQBk1vAMHKHNmNp t1Y05aph1Pd2fqYgri9y/uf8VD9wTwFSwu7VWECA8YjWubXg8ilig4ewNZOQF0zTPJOW GwNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=QcNkhKrt; dkim=pass header.i=@linaro.org header.s=google header.b="VjCR/geW"; spf=pass (google.com: domain of libc-alpha-return-101001-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-101001-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r59si2009645plb.257.2019.03.29.06.37.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 06:37:57 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-101001-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=QcNkhKrt; dkim=pass header.i=@linaro.org header.s=google header.b="VjCR/geW"; spf=pass (google.com: domain of libc-alpha-return-101001-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-101001-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Dr55aSY2u9Ub2EWsKH4T+P8JyrGbxJZ M1gQ4xPYM23nHKe1AJz3JFlursNt1HH/xP7X0XJZenGeDwn+Ot6Vl3r+QKEYFxLH VXIDTDXGoGE1vYK8iZd1wcX9S/HOIQ+TrnpDzV0iCBLSrKcK9DNRGJkn0qQZd95v Hht8MKw85A6E= 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:subject:date:message-id:in-reply-to :references; s=default; bh=belEw2usYgDp47AH12yqqTGyYfc=; b=QcNkh KrtoUPSZIcP/CwaXEJWruG9wnsFY2kE3ZwOso1l47nWlW6NsBlawGevfTJw80Arc rAOdnjNX7faLjdT0Guv6ne4oshOqv/h3LXl23hZBw9p8YJ3ImWXr6Pi/P0uChD0Y GGJOUDDnIct1AkDU3lQktcPy2ytxvky2pJ+DtM= Received: (qmail 119830 invoked by alias); 29 Mar 2019 13:35:58 -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 119537 invoked by uid 89); 29 Mar 2019 13:35:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Nearest, lc0, a, b, ab X-HELO: mail-ua1-f65.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=DWDej6seHh/v1iAxbqOy8/sxbX16lnbFOYkBs0vzzaY=; b=VjCR/geWZcHW5l5OaFcwdAh4Qw3jYdlBu2WUgUxPkTrM4KuJb+t5299qcHYv6s3LgM b1Bm2oPqbO7DiY3iamGvb6Uwp4e1bnjXJV1OLZA15GiuohvbAyAqkqE2Ekm7pKWmE57/ p2rhhlkGlNhqCzq1abqQG0tJ6+6/VmSkOD3jcFXKYOOYbTFRbFpWGVh9PfbOCgeOyUBe ZjaYaAtPb3JII90BNDU9b4Rksda671jiJ3Li9ShQsleB5GgDtdarO/WTWCyXPXHGFZIf +a3VDGBOh/aIA9vPImIvgwB+Bknirss5q+YMwmxT4T3ywFkiEH5kzclNbebi555z2vxa tiag== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 06/28] powerpc: round/roundf refactor Date: Fri, 29 Mar 2019 10:35:07 -0300 Message-Id: <20190329133529.22523-7-adhemerval.zanella@linaro.org> In-Reply-To: <20190329133529.22523-1-adhemerval.zanella@linaro.org> References: <20190329133529.22523-1-adhemerval.zanella@linaro.org> This patches consolidates all the powerpc round{f} implementations on the generic sysdeps/powerpc/fpu/s_round{f}. The generic implementation uses either the compiler builts for ISA 2.03+ (which generates the frim instruction) or a generic implementation which uses FP only operations. The IFUNC organization for powerpc64 is also change to be enabled only for powerpc64 and not for powerpc64le. Checked on powerpc-linux-gnu (built without --with-cpu, with --with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch), powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+ and --disable-multi-arch). * sysdeps/powerpc/fpu/round_to_integer.h (set_rounding_mode): Add ROUND handling. (round_to_integer_float): Likewise. * sysdeps/powerpc/fpu/s_round.c: New file. * sysdeps/powerpc/fpu/s_roundf.c: New file. * sysdeps/powerpc/powerpc32/fpu/s_round.S: Remove file. * sysdeps/powerpc/powerpc32/fpu/s_roundf.S: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_round-power5+.S: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_round-ppc32.S: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_roundf-power5+.S: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_roundf-ppc32.S: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_round-power5+.c: New file. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_round-ppc32.c: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_roundf-power5+.c: Likewise. * sysdep/powerpc/powepc32/power4/fpu/multiarch/s_roundf-ppc32.c: Likewise. * sysdep/powerpc/powerpc32/power5+/fpu/s_round.S: Remove file. * sysdep/powerpc/powerpc32/power5+/fpu/s_roundf.S: Likewise. * sysdep/powerpc/powerpc64/be/fpu/multiarch/Makefile (libm-sysdep_routines): Add s_round-power5+, s_round-ppc64, s_roundf-power5+, and s_roundf-ppc64. (CFLAGS-s_round-power5+.c, CFLAGS-s_roundf-power5+.c): New rule. * sysdep/powerpc/powercp64/be/fpu/multiarch/s_round-power5+.c: New file. * sysdep/powerpc/powercp64/be/fpu/multiarch/s_round-ppc64.c: Likewise. * sysdeps/powerpc/powerpc64/fpu/multiarch/s_round.c: Move to ... * sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round.c: ... here. * sysdep/powerpc/powercp64/be/fpu/multiarch/s_roundf-power5+.c: New file. * sysdep/powerpc/powercp64/be/fpu/multiarch/s_roundf-ppc64.c: Likewise. * sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf.c: Move to ... * sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c: ... here. * sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile (libm-sysdep_routines): Remove s_round-power5+, s_round-ppc64, s_roundf-power5+, and s_roundf-ppc64. * sysdep/powerpc/powerpc64/fpu/multiarch/s_round-power5+.S: Remove file. * sysdep/powerpc/powerpc64/fpu/multiarch/s_round-ppc64.S: Likewise. * sysdep/powerpc/powerpc64/fpu/multiarch/s_roundf-power5+.S: Likewise. * sysdep/powerpc/powerpc64/fpu/multiarch/s_roundf-ppc64.S: Likewise. * sysdeps/powerpc/powerpc64/fpu/s_round.S: Likewise. * sysdeps/powerpc/powerpc64/fpu/s_roundf.S: Likewise. * sysdep/powerpc/powerpc64/power5+/fpu/s_round.S: Likewise. * sysdep/powerpc/powerpc64/power5+/fpu/s_roundf.S: Likewise. --- sysdeps/powerpc/fpu/round_to_integer.h | 17 ++++ sysdeps/powerpc/fpu/s_round.c | 35 +++++++ sysdeps/powerpc/fpu/s_roundf.c | 35 +++++++ sysdeps/powerpc/powerpc32/fpu/s_round.S | 97 ------------------- sysdeps/powerpc/powerpc32/fpu/s_roundf.S | 96 ------------------ .../power4/fpu/multiarch/s_round-power5+.S | 33 ------- .../power4/fpu/multiarch/s_round-power5+.c | 3 + .../power4/fpu/multiarch/s_round-ppc32.S | 31 ------ .../power4/fpu/multiarch/s_round-ppc32.c | 3 + .../power4/fpu/multiarch/s_roundf-power5+.S | 26 ----- .../power4/fpu/multiarch/s_roundf-power5+.c | 3 + .../power4/fpu/multiarch/s_roundf-ppc32.S | 27 ------ .../power4/fpu/multiarch/s_roundf-ppc32.c | 3 + .../powerpc/powerpc32/power5+/fpu/s_round.S | 29 ------ .../powerpc/powerpc32/power5+/fpu/s_roundf.S | 30 ------ .../powerpc64/be/fpu/multiarch/Makefile | 8 +- .../be/fpu/multiarch/s_round-power5+.c | 3 + .../be/fpu/multiarch/s_round-ppc64.c | 3 + .../{ => be}/fpu/multiarch/s_round.c | 0 .../be/fpu/multiarch/s_roundf-power5+.c | 3 + .../be/fpu/multiarch/s_roundf-ppc64.c | 3 + .../{ => be}/fpu/multiarch/s_roundf.c | 0 .../powerpc/powerpc64/fpu/multiarch/Makefile | 3 +- .../powerpc64/fpu/multiarch/s_round-power5+.S | 30 ------ .../powerpc64/fpu/multiarch/s_round-ppc64.S | 30 ------ .../fpu/multiarch/s_roundf-power5+.S | 24 ----- .../powerpc64/fpu/multiarch/s_roundf-ppc64.S | 24 ----- sysdeps/powerpc/powerpc64/fpu/s_round.S | 80 --------------- sysdeps/powerpc/powerpc64/fpu/s_roundf.S | 82 ---------------- .../powerpc/powerpc64/power5+/fpu/s_round.S | 30 ------ .../powerpc/powerpc64/power5+/fpu/s_roundf.S | 31 ------ 31 files changed, 119 insertions(+), 703 deletions(-) create mode 100644 sysdeps/powerpc/fpu/s_round.c create mode 100644 sysdeps/powerpc/fpu/s_roundf.c delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_round.S delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_roundf.S delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.S create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.c delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.S create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.c delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.S create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.c delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.S create mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.c delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_round.S delete mode 100644 sysdeps/powerpc/powerpc32/power5+/fpu/s_roundf.S create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-power5+.c create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-ppc64.c rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_round.c (100%) create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-power5+.c create mode 100644 sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-ppc64.c rename sysdeps/powerpc/powerpc64/{ => be}/fpu/multiarch/s_roundf.c (100%) delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-power5+.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-ppc64.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-power5+.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-ppc64.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_round.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_roundf.S delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_round.S delete mode 100644 sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S -- 2.17.1 Reviewed-by: Gabriel F. T. Gomes diff --git a/sysdeps/powerpc/fpu/round_to_integer.h b/sysdeps/powerpc/fpu/round_to_integer.h index 77d9fc1f86..3fa2b77b6d 100644 --- a/sysdeps/powerpc/fpu/round_to_integer.h +++ b/sysdeps/powerpc/fpu/round_to_integer.h @@ -38,6 +38,7 @@ set_fenv_mode (enum round_mode mode) { case CEIL: rmode = FE_UPWARD; break; case FLOOR: rmode = FE_DOWNWARD; break; + case ROUND: rmode = FE_TOWARDZERO; break; default: rmode = FE_TONEAREST; break; } __fesetround_inline_nocheck (rmode); @@ -60,12 +61,24 @@ round_to_integer_float (enum round_mode mode, float x) set_fenv_mode (mode); if (x > 0.0) { + /* IEEE 1003.1 round function. IEEE specifies "round to the nearest + integer value, rounding halfway cases away from zero, regardless of + the current rounding mode." However PowerPC Architecture defines + "Round to Nearest" as "Choose the best approximation. In case of a + tie, choose the one that is even (least significant bit o).". + So we can't use the PowerPC "Round to Nearest" mode. Instead we set + "Round toward Zero" mode and round by adding +-0.5 before rounding + to the integer value. */ + if (mode == ROUND) + r += 0.5f; r += 0x1p+23; r -= 0x1p+23; r = fabs (r); } else if (x < 0.0) { + if (mode == ROUND) + r -= 0.5f; r -= 0x1p+23; r += 0x1p+23; r = -fabs (r); @@ -92,12 +105,16 @@ round_to_integer_double (enum round_mode mode, double x) set_fenv_mode (mode); if (x > 0.0) { + if (mode == ROUND) + r += 0.5; r += 0x1p+52; r -= 0x1p+52; r = fabs (r); } else if (x < 0.0) { + if (mode == ROUND) + r -= 0.5; r -= 0x1p+52; r += 0x1p+52; r = -fabs (r); diff --git a/sysdeps/powerpc/fpu/s_round.c b/sysdeps/powerpc/fpu/s_round.c new file mode 100644 index 0000000000..cd105567ef --- /dev/null +++ b/sysdeps/powerpc/fpu/s_round.c @@ -0,0 +1,35 @@ +/* Largest integral value not greater than argument. PowerPC 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, see . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +double +__round (double x) +{ +#ifdef _ARCH_PWR5X + return __builtin_round (x); +#else + return round_to_integer_double (ROUND, x); +#endif +} +#ifndef __round +libm_alias_double (__round, round) +#endif diff --git a/sysdeps/powerpc/fpu/s_roundf.c b/sysdeps/powerpc/fpu/s_roundf.c new file mode 100644 index 0000000000..418062adba --- /dev/null +++ b/sysdeps/powerpc/fpu/s_roundf.c @@ -0,0 +1,35 @@ +/* Smallest integral value not less than argument. PowerPC 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, see . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +float +__roundf (float x) +{ +#ifdef _ARCH_PWR5X + return __builtin_roundf (x); +#else + return round_to_integer_float (ROUND, x); +#endif +} +#ifndef __roundf +libm_alias_float (__round, round) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_round.S b/sysdeps/powerpc/powerpc32/fpu/s_round.S deleted file mode 100644 index 26c7516458..0000000000 --- a/sysdeps/powerpc/powerpc32/fpu/s_round.S +++ /dev/null @@ -1,97 +0,0 @@ -/* round function. PowerPC32 version. - Copyright (C) 2004-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 - . */ - -#include -#include -#include - - .section .rodata.cst8,"aM",@progbits,8 - .align 2 -.LC0: /* 2**52 */ - .long 0x59800000 -.LC1: /* 0.5 */ - .long 0x3f000000 - -/* double [fp1] round (double x [fp1]) - IEEE 1003.1 round function. IEEE specifies "round to the nearest - integer value, rounding halfway cases away from zero, regardless of - the current rounding mode." However PowerPC Architecture defines - "Round to Nearest" as "Choose the best approximation. In case of a - tie, choose the one that is even (least significant bit o).". - So we can't use the PowerPC "Round to Nearest" mode. Instead we set - "Round toward Zero" mode and round by adding +-0.5 before rounding - to the integer value. */ - - .section ".text" -ENTRY (__round) -#ifdef SHARED - mflr r11 - cfi_register(lr,r11) - SETUP_GOT_ACCESS(r9,got_label) - addis r9,r9,.LC0-got_label@ha - addi r9,r9,.LC0-got_label@l - mtlr r11 - cfi_same_value (lr) - lfs fp13,0(r9) -#else - lis r9,.LC0@ha - lfs fp13,.LC0@l(r9) -#endif - fabs fp0,fp1 - fsub fp12,fp13,fp13 /* generate 0.0 */ - fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ - mffs fp11 /* Save current FPU rounding mode and - "inexact" state. */ - fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ - bnl- cr7,.L10 - mtfsfi 7,1 /* Set rounding mode toward 0. */ -#ifdef SHARED - lfs fp10,.LC1-.LC0(r9) -#else - lis r9,.LC1@ha - lfs fp10,.LC1@l(r9) -#endif - ble- cr6,.L4 - fadd fp1,fp1,fp10 /* x+= 0.5; */ - fadd fp1,fp1,fp13 /* x+= TWO52; */ - fsub fp1,fp1,fp13 /* x-= TWO52; */ - fabs fp1,fp1 /* if (x == 0.0) */ - /* x = 0.0; */ - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L4: - fsub fp9,fp1,fp10 /* x+= 0.5; */ - bge- cr6,.L9 /* if (x < 0.0) */ - fsub fp1,fp9,fp13 /* x-= TWO52; */ - fadd fp1,fp1,fp13 /* x+= TWO52; */ - fnabs fp1,fp1 /* if (x == 0.0) */ - /* x = -0.0; */ -.L9: - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L10: - /* Ensure sNaN input is converted to qNaN. */ - fcmpu cr7,fp1,fp1 - beqlr cr7 - fadd fp1,fp1,fp1 - blr - END (__round) - -libm_alias_double (__round, round) diff --git a/sysdeps/powerpc/powerpc32/fpu/s_roundf.S b/sysdeps/powerpc/powerpc32/fpu/s_roundf.S deleted file mode 100644 index cb59a2ba51..0000000000 --- a/sysdeps/powerpc/powerpc32/fpu/s_roundf.S +++ /dev/null @@ -1,96 +0,0 @@ -/* roundf function. PowerPC32 version. - Copyright (C) 2004-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 - . */ - -#include -#include - - .section .rodata.cst8,"aM",@progbits,8 - .align 3 -.LC0: /* 2**23 */ - .long 0x4b000000 -.LC1: /* 0.5 */ - .long 0x3f000000 - -/* float [fp1] roundf (float x [fp1]) - IEEE 1003.1 round function. IEEE specifies "round to the nearest - integer value, rounding halfway cases away from zero, regardless of - the current rounding mode." However PowerPC Architecture defines - "Round to Nearest" as "Choose the best approximation. In case of a - tie, choose the one that is even (least significant bit o).". - So we can't use the PowerPC "Round to Nearest" mode. Instead we set - "Round toward Zero" mode and round by adding +-0.5 before rounding - to the integer value. */ - - .section ".text" -ENTRY (__roundf ) -#ifdef SHARED - mflr r11 - cfi_register(lr,r11) - SETUP_GOT_ACCESS(r9,got_label) - addis r9,r9,.LC0-got_label@ha - addi r9,r9,.LC0-got_label@l - mtlr r11 - cfi_same_value (lr) - lfs fp13,0(r9) -#else - lis r9,.LC0@ha - lfs fp13,.LC0@l(r9) -#endif - fabs fp0,fp1 - fsubs fp12,fp13,fp13 /* generate 0.0 */ - fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO23) */ - mffs fp11 /* Save current FPU rounding mode and - "inexact" state. */ - fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ - bnl- cr7,.L10 - mtfsfi 7,1 /* Set rounding mode toward 0. */ -#ifdef SHARED - lfs fp10,.LC1-.LC0(r9) -#else - lfs fp10,.LC1@l(r9) -#endif - ble- cr6,.L4 - fadds fp1,fp1,fp10 /* x+= 0.5; */ - fadds fp1,fp1,fp13 /* x+= TWO23; */ - fsubs fp1,fp1,fp13 /* x-= TWO23; */ - fabs fp1,fp1 /* if (x == 0.0) */ - /* x = 0.0; */ - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L4: - fsubs fp9,fp1,fp10 /* x+= 0.5; */ - bge- cr6,.L9 /* if (x < 0.0) */ - fsubs fp1,fp9,fp13 /* x-= TWO23; */ - fadds fp1,fp1,fp13 /* x+= TWO23; */ - fnabs fp1,fp1 /* if (x == 0.0) */ - /* x = -0.0; */ -.L9: - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L10: - /* Ensure sNaN input is converted to qNaN. */ - fcmpu cr7,fp1,fp1 - beqlr cr7 - fadds fp1,fp1,fp1 - blr - END (__roundf) - -libm_alias_float (__round, round) - diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.S deleted file mode 100644 index eab96dbba7..0000000000 --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.S +++ /dev/null @@ -1,33 +0,0 @@ -/* round function. PowerPC32/power5+ version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -#undef hidden_def -#define hidden_def(name) -#undef weak_alias -#define weak_alias(name, alias) -#undef strong_alias -#define strong_alias(name, alias) -#undef compat_symbol -#define compat_symbol(lib, name, alias, ver) - -#define __round __round_power5plus - -#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.c new file mode 100644 index 0000000000..3f6f87b4e2 --- /dev/null +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-power5+.c @@ -0,0 +1,3 @@ +#include +#define __round __round_power5plus +#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.S deleted file mode 100644 index c2208c18fe..0000000000 --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.S +++ /dev/null @@ -1,31 +0,0 @@ -/* round function. PowerPC32 default version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -#undef weak_alias -#define weak_alias(a,b) -#undef strong_alias -#define strong_alias(a,b) -#undef compat_symbol -#define compat_symbol(a,b,c,d) - -#define __round __round_ppc32 - -#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.c new file mode 100644 index 0000000000..92fbadf789 --- /dev/null +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round-ppc32.c @@ -0,0 +1,3 @@ +#include +#define __round __round_ppc32 +#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.S deleted file mode 100644 index ce4d89c669..0000000000 --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.S +++ /dev/null @@ -1,26 +0,0 @@ -/* roundf function. PowerPC32/power5+ version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -#undef weak_alias -#define weak_alias(name, alias) - -#define __roundf __roundf_power5plus - -#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.c new file mode 100644 index 0000000000..b0cb5c5190 --- /dev/null +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-power5+.c @@ -0,0 +1,3 @@ +#include +#define __roundf __roundf_power5plus +#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.S b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.S deleted file mode 100644 index 30f4e3f7cd..0000000000 --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.S +++ /dev/null @@ -1,27 +0,0 @@ -/* roundf function. PowerPC32 default version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -#undef weak_alias -#define weak_alias(a,b) - -#define __roundf __roundf_ppc32 - -#include diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.c new file mode 100644 index 0000000000..44023bbefd --- /dev/null +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf-ppc32.c @@ -0,0 +1,3 @@ +#include +#define __roundf __roundf_ppc32 +#include diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_round.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_round.S deleted file mode 100644 index 327d970b02..0000000000 --- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_round.S +++ /dev/null @@ -1,29 +0,0 @@ -/* round function. PowerPC32/power5+ version. - Copyright (C) 2006-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 - . */ - -#include -#include -#include - - .machine "power5" -EALIGN (__round, 4, 0) - frin fp1, fp1 - blr - END (__round) - -libm_alias_double (__round, round) diff --git a/sysdeps/powerpc/powerpc32/power5+/fpu/s_roundf.S b/sysdeps/powerpc/powerpc32/power5+/fpu/s_roundf.S deleted file mode 100644 index 59a21708f5..0000000000 --- a/sysdeps/powerpc/powerpc32/power5+/fpu/s_roundf.S +++ /dev/null @@ -1,30 +0,0 @@ -/* roundf function. PowerPC32/power5+ version. - Copyright (C) 2006-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 - . */ - -#include -#include - - .machine "power5" -EALIGN (__roundf, 4, 0) - frin fp1, fp1 /* The rounding instructions are double. */ - frsp fp1, fp1 /* But we need to set ooverflow for float. */ - blr - END (__roundf) - -libm_alias_float (__round, round) - diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile index 8bb06e5cc0..722f974cfb 100644 --- a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile @@ -6,10 +6,16 @@ libm-sysdep_routines += s_ceil-power5+ \ s_floor-power5+ \ s_floor-ppc64 \ s_floorf-power5+ \ - s_floorf-ppc64 + s_floorf-ppc64 \ + s_round-power5+ \ + s_round-ppc64 \ + s_roundf-power5+ \ + s_roundf-ppc64 CFLAGS-s_ceil-power5+.c = -mcpu=power5+ CFLAGS-s_ceilf-power5+.c = -mcpu=power5+ CFLAGS-s_floor-power5+.c = -mcpu=power5+ CFLAGS-s_floorf-power5+.c = -mcpu=power5+ +CFLAGS-s_round-power5+.c = -mcpu=power5+ +CFLAGS-s_roundf-power5+.c = -mcpu=power5+ endif diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-power5+.c new file mode 100644 index 0000000000..3f6f87b4e2 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-power5+.c @@ -0,0 +1,3 @@ +#include +#define __round __round_power5plus +#include diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-ppc64.c new file mode 100644 index 0000000000..cb122e6afc --- /dev/null +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round-ppc64.c @@ -0,0 +1,3 @@ +#include +#define __round __round_ppc64 +#include diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round.c similarity index 100% rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_round.c rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_round.c diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-power5+.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-power5+.c new file mode 100644 index 0000000000..b0cb5c5190 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-power5+.c @@ -0,0 +1,3 @@ +#include +#define __roundf __roundf_power5plus +#include diff --git a/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-ppc64.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-ppc64.c new file mode 100644 index 0000000000..3e1de69147 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf-ppc64.c @@ -0,0 +1,3 @@ +#include +#define __roundf __roundf_ppc64 +#include diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf.c b/sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c similarity index 100% rename from sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf.c rename to sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_roundf.c diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile index 8a73108e4c..11c39f4b35 100644 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile +++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile @@ -15,8 +15,7 @@ sysdep_calls := s_copysign-power6 s_copysign-ppc64 \ sysdep_routines += $(sysdep_calls) libm-sysdep_routines += s_llround-power6x \ s_llround-power5+ s_llround-ppc64 \ - s_round-power5+ s_round-ppc64 \ - s_roundf-power5+ s_roundf-ppc64 s_trunc-power5+ \ + s_trunc-power5+ \ s_trunc-ppc64 s_truncf-power5+ s_truncf-ppc64 \ s_llrint-power6x s_llrint-ppc64 \ s_logb-power7 s_logbf-power7 \ diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-power5+.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-power5+.S deleted file mode 100644 index 8c38759d3f..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-power5+.S +++ /dev/null @@ -1,30 +0,0 @@ -/* round function. PowerPC64/power5+ version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -#undef weak_alias -#define weak_alias(a,b) -#undef strong_alias -#define strong_alias(a,b) -#undef compat_symbol -#define compat_symbol(a,b,c,d) - -#define __round __round_power5plus - -#include diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-ppc64.S deleted file mode 100644 index 5ea616d429..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_round-ppc64.S +++ /dev/null @@ -1,30 +0,0 @@ -/* round function. PowerPC64 default version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -#undef weak_alias -#define weak_alias(a,b) -#undef strong_alias -#define strong_alias(a,b) -#undef compat_symbol -#define compat_symbol(a,b,c,d) - -#define __round __round_ppc64 - -#include diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-power5+.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-power5+.S deleted file mode 100644 index c29c31785e..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-power5+.S +++ /dev/null @@ -1,24 +0,0 @@ -/* roundf function. PowerPC64/power5+ version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#undef weak_alias -#define weak_alias(a,b) - -#define __roundf __roundf_power5plus - -#include diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-ppc64.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-ppc64.S deleted file mode 100644 index ced4241b2b..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf-ppc64.S +++ /dev/null @@ -1,24 +0,0 @@ -/* roundf function. PowerPC64 default version. - Copyright (C) 2013-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#undef weak_alias -#define weak_alias(a,b) - -#define __roundf __roundf_ppc64 - -#include diff --git a/sysdeps/powerpc/powerpc64/fpu/s_round.S b/sysdeps/powerpc/powerpc64/fpu/s_round.S deleted file mode 100644 index 0b06a52d09..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/s_round.S +++ /dev/null @@ -1,80 +0,0 @@ -/* round function. PowerPC64 version. - Copyright (C) 2004-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 - . */ - -#include -#include -#include - - .section ".toc","aw" -.LC0: /* 2**52 */ - .tc FD_43300000_0[TC],0x4330000000000000 -.LC1: /* 0.5 */ - .tc FD_3fe00000_0[TC],0x3fe0000000000000 - .section ".text" - -/* double [fp1] round (double x [fp1]) - IEEE 1003.1 round function. IEEE specifies "round to the nearest - integer value, rounding halfway cases away from zero, regardless of - the current rounding mode." However PowerPC Architecture defines - "Round to Nearest" as "Choose the best approximation. In case of a - tie, choose the one that is even (least significant bit o).". - So we can't use the PowerPC "Round to Nearest" mode. Instead we set - "Round toward Zero" mode and round by adding +-0.5 before rounding - to the integer value. */ - -ENTRY (__round, 4) - CALL_MCOUNT 0 - lfd fp13,.LC0@toc(2) - fabs fp0,fp1 - fsub fp12,fp13,fp13 /* generate 0.0 */ - fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ - mffs fp11 /* Save current FPU rounding mode and - "inexact" state. */ - fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ - bnl- cr7,.L10 - mtfsfi 7,1 /* Set rounding mode toward 0. */ - lfd fp10,.LC1@toc(2) - ble- cr6,.L4 - fadd fp1,fp1,fp10 /* x+= 0.5; */ - fadd fp1,fp1,fp13 /* x+= TWO52; */ - fsub fp1,fp1,fp13 /* x-= TWO52; */ - fabs fp1,fp1 /* if (x == 0.0) */ - /* x = 0.0; */ - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L4: - fsub fp9,fp1,fp10 /* x+= 0.5; */ - bge- cr6,.L9 /* if (x < 0.0) */ - fsub fp1,fp9,fp13 /* x-= TWO52; */ - fadd fp1,fp1,fp13 /* x+= TWO52; */ - fnabs fp1,fp1 /* if (x == 0.0) */ - /* x = -0.0; */ -.L9: - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L10: - /* Ensure sNaN input is converted to qNaN. */ - fcmpu cr7,fp1,fp1 - beqlr cr7 - fadd fp1,fp1,fp1 - blr - END (__round) - -libm_alias_double (__round, round) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_roundf.S b/sysdeps/powerpc/powerpc64/fpu/s_roundf.S deleted file mode 100644 index a9c32c5774..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/s_roundf.S +++ /dev/null @@ -1,82 +0,0 @@ -/* roundf function. PowerPC64 version. - Copyright (C) 2004-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 - . */ - -#include -#include - - .section ".toc","aw" - .p2align 3 -.LC0: /* 2**23 */ - .long 0x4b000000 -.LC1: /* 0.5 */ - .long 0x3f000000 - - .section ".text" - -/* float [fp1] roundf (float x [fp1]) - IEEE 1003.1 round function. IEEE specifies "round to the nearest - integer value, rounding halfway cases away from zero, regardless of - the current rounding mode." However PowerPC Architecture defines - "Round to Nearest" as "Choose the best approximation. In case of a - tie, choose the one that is even (least significant bit o).". - So we can't use the PowerPC "Round to Nearest" mode. Instead we set - "Round toward Zero" mode and round by adding +-0.5 before rounding - to the integer value. */ - -ENTRY (__roundf, 4) - CALL_MCOUNT 0 - lfs fp13,.LC0@toc(2) - fabs fp0,fp1 - fsubs fp12,fp13,fp13 /* generate 0.0 */ - fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO23) */ - mffs fp11 /* Save current FPU rounding mode and - "inexact" state. */ - fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ - bnl- cr7,.L10 - mtfsfi 7,1 /* Set rounding mode toward 0. */ - lfs fp10,.LC1@toc(2) - ble- cr6,.L4 - fadds fp1,fp1,fp10 /* x+= 0.5; */ - fadds fp1,fp1,fp13 /* x+= TWO23; */ - fsubs fp1,fp1,fp13 /* x-= TWO23; */ - fabs fp1,fp1 /* if (x == 0.0) */ - /* x = 0.0; */ - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L4: - fsubs fp9,fp1,fp10 /* x+= 0.5; */ - bge- cr6,.L9 /* if (x < 0.0) */ - fsubs fp1,fp9,fp13 /* x-= TWO23; */ - fadds fp1,fp1,fp13 /* x+= TWO23; */ - fnabs fp1,fp1 /* if (x == 0.0) */ - /* x = -0.0; */ -.L9: - mtfsf 0xff,fp11 /* Restore previous rounding mode and - "inexact" state. */ - blr -.L10: - /* Ensure sNaN input is converted to qNaN. */ - fcmpu cr7,fp1,fp1 - beqlr cr7 - fadds fp1,fp1,fp1 - blr - END (__roundf) - -libm_alias_float (__round, round) - diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_round.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_round.S deleted file mode 100644 index 45d010a919..0000000000 --- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_round.S +++ /dev/null @@ -1,30 +0,0 @@ -/* round function. PowerPC64/power5+ version. - Copyright (C) 2006-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 - . */ - -#include -#include -#include - - .machine "power5" -ENTRY_TOCLESS (__round, 4) - CALL_MCOUNT 0 - frin fp1, fp1 - blr - END (__round) - -libm_alias_double (__round, round) diff --git a/sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S b/sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S deleted file mode 100644 index 69fad1069f..0000000000 --- a/sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S +++ /dev/null @@ -1,31 +0,0 @@ -/* roundf function. PowerPC64/power5+ version. - Copyright (C) 2006-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 - . */ - -#include -#include - - .machine "power5" -ENTRY_TOCLESS (__roundf, 4) - CALL_MCOUNT 0 - frin fp1, fp1 /* The rounding instructions are double. */ - frsp fp1, fp1 /* But we need to set ooverflow for float. */ - blr - END (__roundf) - -libm_alias_float (__round, round) -