From patchwork Fri Mar 29 13:35:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 161427 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2049687jan; Fri, 29 Mar 2019 06:36:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyytetLr2XwrztqhwVai8MvVwZPIFUVdbPeIBkBiSCbeea1zaX/gzsW029OEc6KgUVcQFDW X-Received: by 2002:a17:902:7206:: with SMTP id ba6mr11250630plb.301.1553866609652; Fri, 29 Mar 2019 06:36:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553866609; cv=none; d=google.com; s=arc-20160816; b=uM16R5OsdH4oQhmeNZfUahHf8zbygRAaIEpKcIhhAqRQS4LJC5rl8ovPOTHnC+FOpJ wJUUYxe65doiKRBjtus5VT+O/m+bXQ+cb+Xmy01kE9GgtYLs6set+N7YizfC4/B8qVVy BTPLaXEJU1oTVtk1C4SgLvWN1s3OGfjWa48GyA/ZS92ZIGxry7fIG74QTTVf0xUaIze+ J11GsU9ZR/EhNs6N29HMYF0eOt2wuZAODDLbtlKoUQLPnq/Z93jcd28kFq88Fu6gyEqP 7akw3u9HZd3TK/wd4/ORofJ//Hg0Sjqb/Js14TdYWlj5b0qdpgZLc6zOjRR2WaGwnx5W XVEg== 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=YOfJpX8aFO+6NBbMNlYw1JrhmlQwaiujyMc/jiHOBs8=; b=xfHIvLIQJvV3C6+1Q9r3365dSJgNXkhsyy+sD14lb3ZYuHygJ4nvsslSAYpldvCX4n nPYFvzjDoXQfI6Tn/fphv9eDBO3GqdWbPTPkUXmuFnGWX1K4zrn+9tmgXeUoNHZRzvMe qi4VDihyaf+vJomUKfyKr05rFHHUMCLEcuGSA0h/MSVUV5Lmcgok1jKQ/K3XD++hhFKE QH2u4BjQLZdegWHoWSRA/z3GIwJDm+ZHxMj0jqc8TPs9glh1Xp/AlgPE155pOPyhwApk knDhrygXc74EUUV0KvUbexdorf5cABe4p9JJVwKKH/CYCNVrT4NOdrHWF25is5lYgUnO wbEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=n12y6Vqw; dkim=pass header.i=@linaro.org header.s=google header.b="EvUSV/6x"; spf=pass (google.com: domain of libc-alpha-return-100996-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-100996-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 t17si1945435pgi.180.2019.03.29.06.36.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 06:36:49 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-100996-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=n12y6Vqw; dkim=pass header.i=@linaro.org header.s=google header.b="EvUSV/6x"; spf=pass (google.com: domain of libc-alpha-return-100996-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-100996-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=uPXF6kW0iSTfCPWEBpGmFXyz9VHaJbh mE2vb5sx3roUy446GKLkDx2qbtCsWLjbAF1QUmdvNM3TMLe3iszgjrZi4nriGSLq t65pEtIl6WBAl91QQfisz3TlpCgV8fAGReYqv5uIc4bypRfk8WAN9myr1/qjvGq4 0F4PNrayxOgQ= 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=+ua6PtBlBIdudzwNMjAYKYbt42U=; b=n12y6 Vqw664SImBO6LgaHM/ndELDnIpugsgE1XQd2MjznPxb1a12Iab+SvcI5edig3V3X gs9gQLHhNyZyntawzfZ2Z8pGu4jhvQY8DwCPFbfgYcEHYRdb2KajhRAVm3LTZwlb nr/agTPPJCWTHAmxNz58rimPBKQfT0w5uTX3Bk= Received: (qmail 119107 invoked by alias); 29 Mar 2019 13:35:51 -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 119020 invoked by uid 89); 29 Mar 2019 13:35:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.5 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=2011, lc0, ble, Largest X-HELO: mail-vs1-f54.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=YOfJpX8aFO+6NBbMNlYw1JrhmlQwaiujyMc/jiHOBs8=; b=EvUSV/6xe1sPsdc5vdMJ+Krp67K7uS03BfqjbsAXedpUEjf7cIn7SwDjRvyrxwCZDz Mb6E93oU6aXkExtGnY1fiBpUGf5Si1QqFyopduIBe6sA4VWei0uFNnwkrKk9bqHsQ2Ap 7kscu+b5h1KbHE+9pnUMgTrRWaiMr2RHAaIzcx8OnKhcpuJno9OTw2Zq5eflcs4Nk/wL zKpHRIr0xUgS547GRBe1I9QZhFwJn47lvqHA7V/1g114DDSdiNj151yj42g3KrVS6AGc dGwX63dgL2dsAGXZtkKviX2ESdIFXiEitO3dghwjOKADLcq4LdmIk1F697soA0OYcm23 dwOg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 08/28] powerpc: generic nearbyint/nearbyintf Date: Fri, 29 Mar 2019 10:35:09 -0300 Message-Id: <20190329133529.22523-9-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 nearbyint{f} implementations on the generic sysdeps/powerpc/fpu/s_nearbyint{f}. 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_fenv_mode): Add NEARBYINT handling. * sysdeps/powerpc/fpu/s_nearbyint.c: New file. * sysdeps/powerpc/fpu/s_nearbyintf.c: Likewise. * sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S: Remove file. * sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S: Likewise. * sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S: Likewise. * sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S: Likewise. --- sysdeps/powerpc/fpu/round_to_integer.h | 19 +++-- sysdeps/powerpc/fpu/s_nearbyint.c | 30 ++++++++ sysdeps/powerpc/fpu/s_nearbyintf.c | 30 ++++++++ sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S | 80 -------------------- sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S | 79 ------------------- sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S | 68 ----------------- sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S | 69 ----------------- 7 files changed, 73 insertions(+), 302 deletions(-) create mode 100644 sysdeps/powerpc/fpu/s_nearbyint.c create mode 100644 sysdeps/powerpc/fpu/s_nearbyintf.c delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S -- 2.17.1 diff --git a/sysdeps/powerpc/fpu/round_to_integer.h b/sysdeps/powerpc/fpu/round_to_integer.h index ba2d355fb0..5d4378063a 100644 --- a/sysdeps/powerpc/fpu/round_to_integer.h +++ b/sysdeps/powerpc/fpu/round_to_integer.h @@ -33,16 +33,23 @@ enum round_mode static inline void set_fenv_mode (enum round_mode mode) { - int rmode; switch (mode) { - case CEIL: rmode = FE_UPWARD; break; - case FLOOR: rmode = FE_DOWNWARD; break; + case CEIL: + __fesetround_inline_nocheck (FE_UPWARD); + break; + case FLOOR: + __fesetround_inline_nocheck (FE_DOWNWARD); + break; case TRUNC: - case ROUND: rmode = FE_TOWARDZERO; break; - default: rmode = FE_TONEAREST; break; + case ROUND: + __fesetround_inline_nocheck (FE_TOWARDZERO); + break; + case NEARBYINT: + /* Disable FE_INEXACT exception */ + reset_fpscr_bit (FPSCR_XE); + break; } - __fesetround_inline_nocheck (rmode); } static inline float diff --git a/sysdeps/powerpc/fpu/s_nearbyint.c b/sysdeps/powerpc/fpu/s_nearbyint.c new file mode 100644 index 0000000000..48bcd86f04 --- /dev/null +++ b/sysdeps/powerpc/fpu/s_nearbyint.c @@ -0,0 +1,30 @@ +/* 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 +#include + +double +__nearbyint (double x) +{ + return round_to_integer_double (NEARBYINT, x); +} +libm_alias_double (__nearbyint, nearbyint) diff --git a/sysdeps/powerpc/fpu/s_nearbyintf.c b/sysdeps/powerpc/fpu/s_nearbyintf.c new file mode 100644 index 0000000000..db8a3cdac7 --- /dev/null +++ b/sysdeps/powerpc/fpu/s_nearbyintf.c @@ -0,0 +1,30 @@ +/* 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 +#include + +float +__nearbyintf (float x) +{ + return round_to_integer_float (NEARBYINT, x); +} +libm_alias_float (__nearbyint, nearbyint) diff --git a/sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S b/sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S deleted file mode 100644 index 4ed5d702f1..0000000000 --- a/sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S +++ /dev/null @@ -1,80 +0,0 @@ -/* Round to int floating-point values. PowerPC32 version. - Copyright (C) 2011-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Adhemerval Zanella , 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 - . */ - -/* This has been coded in assembler because GCC makes such a mess of it - when it's coded in C. */ - -#include -#include -#include - - -/* double [fp1] nearbyint(double [fp1] x) */ - - .section .rodata.cst4,"aM",@progbits,4 - .align 2 -.LC0: /* 2**52 */ - .long 0x59800000 /* TWO52: 2**52 */ - - .section ".text" -ENTRY (__nearbyint) -#ifdef SHARED - mflr r11 - cfi_register(lr,r11) - bcl 20,31,1f -1: mflr r9 - addis r9,r9,.LC0-1b@ha - lfs fp13,.LC0-1b@l(r9) - mtlr r11 - cfi_same_value (lr) -#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 */ - bge cr7,.L10 - fcmpu cr7,fp1,fp12 /* if (x > 0.0 */ - ble cr7,L(lessthanzero) - mffs fp11 - mtfsb0 4*cr7+lt /* Disable FE_INEXACT exception */ - fadd fp1,fp1,fp13 /* x += TWO52 */ - fsub fp1,fp1,fp13 /* x -= TWO52 */ - fabs fp1,fp1 /* if (x == 0.0 */ - mtfsf 0xff,fp11 /* Restore FE_INEXACT state. */ - blr -L(lessthanzero): - bgelr cr7 - mffs fp11 - mtfsb0 4*cr7+lt /* Disable FE_INEXACT exception */ - fsub fp1,fp1,fp13 /* x -= TWO52 */ - fadd fp1,fp1,fp13 /* x += TWO52 */ - fnabs fp1,fp1 /* if (x == 0.0) */ - mtfsf 0xff,fp11 /* Restore FE_INEXACT state. */ - blr -.L10: - /* Ensure sNaN input is converted to qNaN. */ - fcmpu cr7,fp1,fp1 - beqlr cr7 - fadd fp1,fp1,fp1 - blr -END (__nearbyint) - -libm_alias_double (__nearbyint, nearbyint) diff --git a/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S b/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S deleted file mode 100644 index b1895f9d10..0000000000 --- a/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S +++ /dev/null @@ -1,79 +0,0 @@ -/* Round to int floating-point values. PowerPC32 version. - Copyright (C) 2011-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Adhemerval Zanella , 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 - . */ - -/* This has been coded in assembler because GCC makes such a mess of it - when it's coded in C. */ - -#include -#include - - -/* float [fp1] nearbyintf(float [fp1] x) */ - - .section .rodata.cst4,"aM",@progbits,4 - .align 2 -.LC0: - .long 0x4B000000 /* TWO23: 2**23 */ - - .section ".text" -ENTRY (__nearbyintf) -#ifdef SHARED - mflr r11 - cfi_register(lr,r11) - bcl 20,31,1f -1: mflr r9 - addis r9,r9,.LC0-1b@ha - lfs fp13,.LC0-1b@l(r9) - mtlr r11 - cfi_same_value (lr) -#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) > TWO23 */ - bge cr7,.L10 - fcmpu cr7,fp1,fp12 /* if (x > 0.0 */ - ble cr7,L(lessthanzero) - mffs fp11 - mtfsb0 4*cr7+lt /* Disable FE_INEXACT exception */ - fadds fp1,fp1,fp13 /* x += TWO23 */ - fsubs fp1,fp1,fp13 /* x -= TWO23 */ - fabs fp1,fp1 /* if (x == 0.0) */ - mtfsf 0xff,fp11 /* Restore FE_INEXACT state. */ - blr -L(lessthanzero): - bgelr cr7 - mffs fp11 - mtfsb0 4*cr7+lt /* Disable FE_INEXACT exception */ - fsubs fp1,fp1,fp13 /* x -= TWO23 */ - fadds fp1,fp1,fp13 /* x += TWO23 */ - fnabs fp1,fp1 /* if (x == 0.0) */ - mtfsf 0xff,fp11 /* Restore FE_INEXACT state. */ - blr -.L10: - /* Ensure sNaN input is converted to qNaN. */ - fcmpu cr7,fp1,fp1 - beqlr cr7 - fadds fp1,fp1,fp1 - blr -END (__nearbyintf) - -libm_alias_float (__nearbyint, nearbyint) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S b/sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S deleted file mode 100644 index 4065af8fe3..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S +++ /dev/null @@ -1,68 +0,0 @@ -/* Round to int floating-point values. PowerPC64 version. - Copyright (C) 2011-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Adhemerval Zanella , 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 - . */ - -/* This has been coded in assembler because GCC makes such a mess of it - when it's coded in C. */ - -#include -#include -#include - - -/* double [fp1] nearbyint(double [fp1] x) */ - - .section ".toc","aw" -.LC0: /* 2**52 */ - .tc FD_43300000_0[TC],0x4330000000000000 - .section ".text" - -ENTRY (__nearbyint, 4) - CALL_MCOUNT 0 - fabs fp0,fp1 - lfd fp13,.LC0@toc(2) - fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ - bge cr7,.L10 - fsub fp12,fp13,fp13 /* generate 0.0 */ - fcmpu cr7,fp1,fp12 /* if (x > 0.0) */ - ble cr7, L(lessthanzero) - mffs fp11 - mtfsb0 4*cr7+lt /* Disable FE_INEXACT exception */ - fadd fp1,fp1,fp13 /* x+= TWO52 */ - fsub fp1,fp1,fp13 /* x-= TWO52 */ - fabs fp1,fp1 /* if (x == 0.0) */ - mtfsf 0xff,fp11 /* Restore FE_INEXACT state. */ - blr /* x = 0.0; */ -L(lessthanzero): - bgelr cr7 /* if (x < 0.0) */ - mffs fp11 - mtfsb0 4*cr7+lt - fsub fp1,fp1,fp13 /* x -= TWO52 */ - fadd fp1,fp1,fp13 /* x += TWO52 */ - fnabs fp1,fp1 /* if (x == 0.0) */ - mtfsf 0xff,fp11 /* Restore FE_INEXACT state. */ - blr /* x = -0.0; */ -.L10: - /* Ensure sNaN input is converted to qNaN. */ - fcmpu cr7,fp1,fp1 - beqlr cr7 - fadd fp1,fp1,fp1 - blr -END (__nearbyint) - -libm_alias_double (__nearbyint, nearbyint) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S b/sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S deleted file mode 100644 index 69949028a3..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S +++ /dev/null @@ -1,69 +0,0 @@ -/* Round to int floating-point values. PowerPC64 version. - Copyright (C) 2011-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Adhemerval Zanella , 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 - . */ - -/* This has been coded in assembler because GCC makes such a mess of it - when it's coded in C. */ - -#include -#include - - -/* float [fp1] nearbyintf(float [fp1]) */ - - .section ".toc","aw" - .p2align 3 -.LC0: /* 2**23 */ - .long 0x4b000000 - .long 0x0 - .section ".text" - -ENTRY (__nearbyintf, 4) - CALL_MCOUNT 0 - fabs fp0,fp1 - lfs fp13,.LC0@toc(2) - fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ - bge cr7,.L10 - fsubs fp12,fp13,fp13 /* generate 0.0 */ - fcmpu cr7,fp1,fp12 /* if (x > 0.0) */ - ble cr7, L(lessthanzero) - mffs fp11 - mtfsb0 4*cr7+lt /* Disable FE_INEXACT exception */ - fadds fp1,fp1,fp13 /* x += TWO23 */ - fsubs fp1,fp1,fp13 /* x -= TWO23 */ - fabs fp1,fp1 /* if (x == 0.0) */ - mtfsf 0xff,fp11 /* Restore FE_INEXACT state. */ - blr /* x = 0.0; */ -L(lessthanzero): - bgelr cr7 /* if (x < 0.0) */ - mffs fp11 - mtfsb0 4*cr7+lt /* Disable FE_INEXACT exception */ - fsubs fp1,fp1,fp13 /* x -= TWO23 */ - fadds fp1,fp1,fp13 /* x += TWO23 */ - fnabs fp1,fp1 /* if (x == 0.0) */ - mtfsf 0xff,fp11 /* Restore FE_INEXACT state. */ - blr /* x = -0.0; */ -.L10: - /* Ensure sNaN input is converted to qNaN. */ - fcmpu cr7,fp1,fp1 - beqlr cr7 - fadds fp1,fp1,fp1 - blr -END (__nearbyintf) - -libm_alias_float (__nearbyint, nearbyint)