From patchwork Sat May 22 00:22:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6Kyd5piH6YGUKFNoZW4tVGEgSHNpZWgp?= X-Patchwork-Id: 43535 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B88AA3AA8CB0; Sat, 22 May 2021 00:23:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B88AA3AA8CB0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621643023; bh=GHf5rky+120FCY77zRFbgoJS7Qmt+ntdaCxe95KKrdc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=jpER512QzD5wHFBNULhBxoy28o+ecrsP1QrqLWMtrRwjh1KycVSfRVXBAsWsdzBrZ jFs7T2ZpJJjQr6auCsxsEdB0DFbgn2ut9sHaFg0xxfiA3WdvON2qGronDgoY1VrBEY ZUzT4ECluLASXdmRIvup3Vn4J42R6jiv08P7dJsM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id A64E13847837 for ; Sat, 22 May 2021 00:23:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A64E13847837 Received: by mail-pj1-x1035.google.com with SMTP id b15-20020a17090a550fb029015dad75163dso8055440pji.0 for ; Fri, 21 May 2021 17:23:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GHf5rky+120FCY77zRFbgoJS7Qmt+ntdaCxe95KKrdc=; b=URfPeS59nLHSCkFz/B23Yc0HTDHCUTwhgNjFMafHw3GVmKui2MXW6guS95Q/3xS6Ad 8zzONQJnBDCg3cDuJ8y66nIxan02g/kvbkKbHGVKb3/S82ZtGPP4hyCSINyljg5HPR/b UNH0cHHmEtHPWQkZYbqPCsx4UXKRx5yDz7LraH8eIgFCRjeNZwGKS4AkXucbW+HU+we0 wypV22Fs/gY11lWMRjCjg3MEMLq1/qwXZyRncgGwmmLtth9gVRbibm3/aUeIw6AeYc/9 QKQozHMKTGjIRMExDbXtT+Mx2kzQjC0FT/H0x3JEqncihtG5ccqbbKBsQtNpQxGJLWu4 Fykg== X-Gm-Message-State: AOAM530pZxc4ayiC9Vv86J/NRurtIk+5YyBOxvmbHD7opq/OEzCnWL20 Ocsy/eQvvNBsWMu7pfbRaSmm3NKkjOYY7w== X-Google-Smtp-Source: ABdhPJxxYmTGoDaowoS4WJNtx6RuOwFODzVwSwQHK48bM9amntuHYYLg0MvP15wQPU6NexOeYtK/0w== X-Received: by 2002:a17:90a:174e:: with SMTP id 14mr12896009pjm.187.1621643019008; Fri, 21 May 2021 17:23:39 -0700 (PDT) Received: from fragrant.. (220-135-3-239.HINET-IP.hinet.net. [220.135.3.239]) by smtp.gmail.com with ESMTPSA id d3sm9256156pjw.35.2021.05.21.17.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 17:23:38 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v6 1/3] math: redirect roundeven function Date: Sat, 22 May 2021 08:22:25 +0800 Message-Id: <20210522002227.2234377-1-ibmibmibm.tw@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Shen-Ta Hsieh via Libc-alpha From: =?utf-8?b?6Kyd5piH6YGUKFNoZW4tVGEgSHNpZWgp?= Reply-To: Shen-Ta Hsieh Cc: Shen-Ta Hsieh Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This patch redirect roundeven function for futhermore changes. Signed-off-by: Shen-Ta Hsieh --- include/math.h | 2 +- sysdeps/ieee754/dbl-64/s_roundeven.c | 4 +++- sysdeps/ieee754/float128/s_roundevenf128.c | 1 + sysdeps/ieee754/flt-32/s_roundevenf.c | 3 +++ sysdeps/ieee754/ldbl-128/s_roundevenl.c | 1 + sysdeps/ieee754/ldbl-96/s_roundevenl.c | 1 + 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/math.h b/include/math.h index e1c2a4eb64..b4772d3d3b 100644 --- a/include/math.h +++ b/include/math.h @@ -38,7 +38,6 @@ libm_hidden_proto (__issignaling) libm_hidden_proto (__issignalingf) libm_hidden_proto (__exp) libm_hidden_proto (__expf) -libm_hidden_proto (__roundeven) # if !defined __NO_LONG_DOUBLE_MATH \ && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0 @@ -159,6 +158,7 @@ fabsf128 (_Float128 x) MATH_REDIRECT (sqrt, "__ieee754_", MATH_REDIRECT_UNARY_ARGS) MATH_REDIRECT (ceil, "__", MATH_REDIRECT_UNARY_ARGS) MATH_REDIRECT (floor, "__", MATH_REDIRECT_UNARY_ARGS) +MATH_REDIRECT (roundeven, "__", MATH_REDIRECT_UNARY_ARGS) MATH_REDIRECT (rint, "__", MATH_REDIRECT_UNARY_ARGS) MATH_REDIRECT (trunc, "__", MATH_REDIRECT_UNARY_ARGS) MATH_REDIRECT (round, "__", MATH_REDIRECT_UNARY_ARGS) diff --git a/sysdeps/ieee754/dbl-64/s_roundeven.c b/sysdeps/ieee754/dbl-64/s_roundeven.c index 943b2c634c..5deff3bb8a 100644 --- a/sysdeps/ieee754/dbl-64/s_roundeven.c +++ b/sysdeps/ieee754/dbl-64/s_roundeven.c @@ -16,6 +16,7 @@ License along with the GNU C Library; if not, see . */ +#define NO_MATH_REDIRECT #include #include #include @@ -66,5 +67,6 @@ __roundeven (double x) INSERT_WORDS64 (x, ix); return x; } -hidden_def (__roundeven) +#ifndef __roundeven libm_alias_double (__roundeven, roundeven) +#endif diff --git a/sysdeps/ieee754/float128/s_roundevenf128.c b/sysdeps/ieee754/float128/s_roundevenf128.c index 5a9b3f395f..e0faf727f6 100644 --- a/sysdeps/ieee754/float128/s_roundevenf128.c +++ b/sysdeps/ieee754/float128/s_roundevenf128.c @@ -1,2 +1,3 @@ +#define NO_MATH_REDIRECT #include #include "../ldbl-128/s_roundevenl.c" diff --git a/sysdeps/ieee754/flt-32/s_roundevenf.c b/sysdeps/ieee754/flt-32/s_roundevenf.c index ae54365bbe..2cc0d7b001 100644 --- a/sysdeps/ieee754/flt-32/s_roundevenf.c +++ b/sysdeps/ieee754/flt-32/s_roundevenf.c @@ -17,6 +17,7 @@ License along with the GNU C Library; if not, see . */ +#define NO_MATH_REDIRECT #include #include #include @@ -67,4 +68,6 @@ __roundevenf (float x) SET_FLOAT_WORD (x, ix); return x; } +#ifndef __roundevenf libm_alias_float (__roundeven, roundeven) +#endif diff --git a/sysdeps/ieee754/ldbl-128/s_roundevenl.c b/sysdeps/ieee754/ldbl-128/s_roundevenl.c index 02765be0e0..7c9c11fad2 100644 --- a/sysdeps/ieee754/ldbl-128/s_roundevenl.c +++ b/sysdeps/ieee754/ldbl-128/s_roundevenl.c @@ -17,6 +17,7 @@ License along with the GNU C Library; if not, see . */ +#define NO_MATH_REDIRECT #include #include #include diff --git a/sysdeps/ieee754/ldbl-96/s_roundevenl.c b/sysdeps/ieee754/ldbl-96/s_roundevenl.c index 8340116ed8..f826829c31 100644 --- a/sysdeps/ieee754/ldbl-96/s_roundevenl.c +++ b/sysdeps/ieee754/ldbl-96/s_roundevenl.c @@ -17,6 +17,7 @@ License along with the GNU C Library; if not, see . */ +#define NO_MATH_REDIRECT #include #include #include From patchwork Sat May 22 00:22:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6Kyd5piH6YGUKFNoZW4tVGEgSHNpZWgp?= X-Patchwork-Id: 43536 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 53B223AA9412; Sat, 22 May 2021 00:23:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53B223AA9412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621643025; bh=umFtr/i4aJGcfNvku+ERvpAYvAFeSsZ+u2aXSWdLzFc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Yq5U9/L8sO+CcQhR4IhxIKmNi2Oa0ugbjAlQpDXbI61336bNFXobe+xG7I9WEfNPc RaRK9agIeU1Thrrf15Abm6CAgdV5LWnhWQueCWnli+FkyWws5lJniucvOE7j1XSHe2 LScZe5Abr/UeEu9Nu3jq0+z3RuOPfmHQ/Bk/tFyY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 7B6E8383F41A for ; Sat, 22 May 2021 00:23:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7B6E8383F41A Received: by mail-pf1-x42d.google.com with SMTP id y15so4710789pfn.13 for ; Fri, 21 May 2021 17:23:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=umFtr/i4aJGcfNvku+ERvpAYvAFeSsZ+u2aXSWdLzFc=; b=cYiAFNeJVOiiHFKeZFRJKXegx3Tuv6WfP9/aIPCGQdiVAZgOIYOJCR3XoTiRgIoswl LrgqYJlop6IdkALmKOP2Khr3RY1vl4I3rkVT5hQBItJAvbQWwjCXi8QO0YGAwfqq0yR/ 4LJmJpUyQ1Klx85rPyZa8fTAJ45ACqI/hkQR9DRRf4dmzntkzdK9+5VaOfVDB6WLdXDy nnTPGxjuYyrW4MXCW+b/M0foVHfUL/Z9O/vgeW+uZuPBD5Iesm9EqhyebhaIr/ClHIP4 D0UgcsIruX1qVztesGcQuGBxiY6yHYFjHK532bt96FBEnhn3DRoxXlkkNkrdUAI0iRu/ /keA== X-Gm-Message-State: AOAM532UiMDg5TWfwmmTknfZ+Ix3K7rdCYZXFLROgXwoN2K7znw2qFnz wRbDQOmF9uWS3wUMSG4sibhAbPl1CjY9cg== X-Google-Smtp-Source: ABdhPJzWi6SkRtteSP6lrRRnIYV3eHSmKgj7Q+lRvdTd45GkMwiBQuaKik9uPuSmR9LSPq2BYtXXSg== X-Received: by 2002:a62:d447:0:b029:291:19f7:ddcd with SMTP id u7-20020a62d4470000b029029119f7ddcdmr12794785pfl.54.1621643020237; Fri, 21 May 2021 17:23:40 -0700 (PDT) Received: from fragrant.. (220-135-3-239.HINET-IP.hinet.net. [220.135.3.239]) by smtp.gmail.com with ESMTPSA id d3sm9256156pjw.35.2021.05.21.17.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 17:23:39 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v6 2/3] x86_64: roundeven with sse4.1 support Date: Sat, 22 May 2021 08:22:26 +0800 Message-Id: <20210522002227.2234377-2-ibmibmibm.tw@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210522002227.2234377-1-ibmibmibm.tw@gmail.com> References: <20210522002227.2234377-1-ibmibmibm.tw@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Shen-Ta Hsieh via Libc-alpha From: =?utf-8?b?6Kyd5piH6YGUKFNoZW4tVGEgSHNpZWgp?= Reply-To: Shen-Ta Hsieh Cc: Shen-Ta Hsieh Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This patch adds support for the sse4.1 hardware floating point roundeven. Here is a benchmark result on my AMD Ryzen 9 3900X system: * benchmark result before this commit | | roundeven | roundevenf | |------------|--------------|--------------| | duration | 3.77659e+09 | 3.77504e+09 | | iterations | 3.97043e+08 | 4.36752e+08 | | max | 83.714 | 58.861 | | min | 7.144 | 6.27 | | mean | 9.51179 | 8.64345 | * benchmark result after this commit | | roundeven | roundevenf | |------------|--------------|--------------| | duration | 3.76913e+09 | 3.76923e+09 | | iterations | 5.55921e+08 | 5.64822e+08 | | max | 211.698 | 439.09 | | min | 6.498 | 6.422 | | mean | 6.77998 | 6.6733 | Signed-off-by: Shen-Ta Hsieh Reviewed-by: H.J. Lu --- sysdeps/x86_64/fpu/multiarch/Makefile | 5 +-- sysdeps/x86_64/fpu/multiarch/s_roundeven-c.c | 2 ++ .../x86_64/fpu/multiarch/s_roundeven-sse4_1.S | 24 ++++++++++++++ sysdeps/x86_64/fpu/multiarch/s_roundeven.c | 31 +++++++++++++++++++ sysdeps/x86_64/fpu/multiarch/s_roundevenf-c.c | 3 ++ .../fpu/multiarch/s_roundevenf-sse4_1.S | 24 ++++++++++++++ sysdeps/x86_64/fpu/multiarch/s_roundevenf.c | 31 +++++++++++++++++++ 7 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 sysdeps/x86_64/fpu/multiarch/s_roundeven-c.c create mode 100644 sysdeps/x86_64/fpu/multiarch/s_roundeven-sse4_1.S create mode 100644 sysdeps/x86_64/fpu/multiarch/s_roundeven.c create mode 100644 sysdeps/x86_64/fpu/multiarch/s_roundevenf-c.c create mode 100644 sysdeps/x86_64/fpu/multiarch/s_roundevenf-sse4_1.S create mode 100644 sysdeps/x86_64/fpu/multiarch/s_roundevenf.c diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile index 57892c56bb..d425ffd6d3 100644 --- a/sysdeps/x86_64/fpu/multiarch/Makefile +++ b/sysdeps/x86_64/fpu/multiarch/Makefile @@ -1,11 +1,12 @@ ifeq ($(subdir),math) libm-sysdep_routines += s_floor-c s_ceil-c s_floorf-c s_ceilf-c \ s_rint-c s_rintf-c s_nearbyint-c s_nearbyintf-c \ - s_trunc-c s_truncf-c + s_roundeven-c s_roundevenf-c s_trunc-c s_truncf-c libm-sysdep_routines += s_ceil-sse4_1 s_ceilf-sse4_1 s_floor-sse4_1 \ s_floorf-sse4_1 s_nearbyint-sse4_1 \ - s_nearbyintf-sse4_1 s_rint-sse4_1 s_rintf-sse4_1 \ + s_nearbyintf-sse4_1 s_roundeven-sse4_1 \ + s_roundevenf-sse4_1 s_rint-sse4_1 s_rintf-sse4_1 \ s_trunc-sse4_1 s_truncf-sse4_1 libm-sysdep_routines += e_exp-fma e_log-fma e_pow-fma s_atan-fma \ diff --git a/sysdeps/x86_64/fpu/multiarch/s_roundeven-c.c b/sysdeps/x86_64/fpu/multiarch/s_roundeven-c.c new file mode 100644 index 0000000000..c7be43cb22 --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_roundeven-c.c @@ -0,0 +1,2 @@ +#define __roundeven __roundeven_c +#include diff --git a/sysdeps/x86_64/fpu/multiarch/s_roundeven-sse4_1.S b/sysdeps/x86_64/fpu/multiarch/s_roundeven-sse4_1.S new file mode 100644 index 0000000000..6ae8f6b1d3 --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_roundeven-sse4_1.S @@ -0,0 +1,24 @@ +/* Copyright (C) 2021 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 + + .section .text.sse4.1,"ax",@progbits +ENTRY(__roundeven_sse41) + roundsd $8, %xmm0, %xmm0 + ret +END(__roundeven_sse41) diff --git a/sysdeps/x86_64/fpu/multiarch/s_roundeven.c b/sysdeps/x86_64/fpu/multiarch/s_roundeven.c new file mode 100644 index 0000000000..d92eda652a --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_roundeven.c @@ -0,0 +1,31 @@ +/* Multiple versions of __roundeven. + Copyright (C) 2021 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 + +#define roundeven __redirect_roundeven +#define __roundeven __redirect___roundeven +#include +#undef roundeven +#undef __roundeven + +#define SYMBOL_NAME roundeven +#include "ifunc-sse4_1.h" + +libc_ifunc_redirected (__redirect_roundeven, __roundeven, IFUNC_SELECTOR ()); +libm_alias_double (__roundeven, roundeven) diff --git a/sysdeps/x86_64/fpu/multiarch/s_roundevenf-c.c b/sysdeps/x86_64/fpu/multiarch/s_roundevenf-c.c new file mode 100644 index 0000000000..72a6e7d1fb --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_roundevenf-c.c @@ -0,0 +1,3 @@ +#undef __roundevenf +#define __roundevenf __roundevenf_c +#include diff --git a/sysdeps/x86_64/fpu/multiarch/s_roundevenf-sse4_1.S b/sysdeps/x86_64/fpu/multiarch/s_roundevenf-sse4_1.S new file mode 100644 index 0000000000..a76e10807e --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_roundevenf-sse4_1.S @@ -0,0 +1,24 @@ +/* Copyright (C) 2021 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 + + .section .text.sse4.1,"ax",@progbits +ENTRY(__roundevenf_sse41) + roundss $8, %xmm0, %xmm0 + ret +END(__roundevenf_sse41) diff --git a/sysdeps/x86_64/fpu/multiarch/s_roundevenf.c b/sysdeps/x86_64/fpu/multiarch/s_roundevenf.c new file mode 100644 index 0000000000..2ee196e68f --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_roundevenf.c @@ -0,0 +1,31 @@ +/* Multiple versions of __roundevenf. + Copyright (C) 2021 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 + +#define roundevenf __redirect_roundevenf +#define __roundevenf __redirect___roundevenf +#include +#undef roundevenf +#undef __roundevenf + +#define SYMBOL_NAME roundevenf +#include "ifunc-sse4_1.h" + +libc_ifunc_redirected (__redirect_roundevenf, __roundevenf, IFUNC_SELECTOR ()); +libm_alias_float (__roundeven, roundeven) From patchwork Sat May 22 00:22:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6Kyd5piH6YGUKFNoZW4tVGEgSHNpZWgp?= X-Patchwork-Id: 43537 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 54FDA3AA9420; Sat, 22 May 2021 00:23:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 54FDA3AA9420 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621643027; bh=beOzclESHCA7i6M29KjCpbFrO6Mzb31pxLzL0wN3cow=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=T54f5WVSHdJQEn+X9NnaePkDHlmMeF7lGVMBSWD5Y7lmjW46G/IKTxss9LmvAX78C RyOTTyKQeKcpL4izSbtm3FVySU+cagvLA/UFLobbmH9P9HKmmbC+fWg67i5qR2eINa 8WWYMPNGqsIoJU/gU+4crG3KVJaxqkY0N81NP3tg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 90E0E3847837 for ; Sat, 22 May 2021 00:23:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 90E0E3847837 Received: by mail-pf1-x436.google.com with SMTP id e17so5496438pfl.5 for ; Fri, 21 May 2021 17:23:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=beOzclESHCA7i6M29KjCpbFrO6Mzb31pxLzL0wN3cow=; b=JCxGBs1L7hThj0FtzSN1uBbJzpgEuAAAteL2aZcwevg9k6YbW4bA5w7kPRCWDCqH+q fimGXfcYMYb10HjzVG80ZnAdF3/RqRaTSm3fIQvxs5srNQxcAmq6I08zm9Vl5XdSdk9J xfFuNXCncfbHtdUHHyjJieJxQx2yScs4doc5iNKTI7BW+fsDtRn4Z+GLszi7GKObbaYf MpX6sNAXQ9Qjm+aCFV/4Q7M84Yntv0OKnGySXjI4GaWXeD/f5iPzG8nqWPWEd/gXmSL4 ED8jbbJMGTjaQkwQGBRHYDKBQFrn707uwwGqLf1LGRrktKQVJldDebHXap4iTkfYoC3c fNBg== X-Gm-Message-State: AOAM531eDlwHZ8+gOdpUUNgaK+zIpoXMjLJKHv2Ex5SYf2D6D79UBw7B RNYIxCfC3cRqvGz0/jpaCIl2o1q8GuunSw== X-Google-Smtp-Source: ABdhPJww/ivhkvJFbr2tNRxLj0a+TprAb91M1RPqojfAxwN+1ZJJloEX4ViYWbVehquXAKVMqgnrMA== X-Received: by 2002:a62:ae19:0:b029:2d9:11cf:5da7 with SMTP id q25-20020a62ae190000b02902d911cf5da7mr13009071pff.18.1621643021461; Fri, 21 May 2021 17:23:41 -0700 (PDT) Received: from fragrant.. (220-135-3-239.HINET-IP.hinet.net. [220.135.3.239]) by smtp.gmail.com with ESMTPSA id d3sm9256156pjw.35.2021.05.21.17.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 17:23:41 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v6 3/3] Use GCC builtins for roundeven functions if desired. Date: Sat, 22 May 2021 08:22:27 +0800 Message-Id: <20210522002227.2234377-3-ibmibmibm.tw@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210522002227.2234377-1-ibmibmibm.tw@gmail.com> References: <20210522002227.2234377-1-ibmibmibm.tw@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Shen-Ta Hsieh via Libc-alpha From: =?utf-8?b?6Kyd5piH6YGUKFNoZW4tVGEgSHNpZWgp?= Reply-To: Shen-Ta Hsieh Cc: Shen-Ta Hsieh Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This patch is using the corresponding GCC builtin for roundevenf, roundeven and roundevenl if the USE_FUNCTION_BUILTIN macros are defined to one in math-use-builtins.h. These builtin functions is supported since GCC 10. The code of the generic implementation is not changed. Signed-off-by: Shen-Ta Hsieh --- sysdeps/generic/math-use-builtins-roundeven.h | 4 ++++ sysdeps/generic/math-use-builtins.h | 1 + sysdeps/ieee754/dbl-64/s_roundeven.c | 5 +++++ sysdeps/ieee754/flt-32/s_roundevenf.c | 5 +++++ sysdeps/ieee754/ldbl-128/s_roundevenl.c | 5 +++++ 5 files changed, 20 insertions(+) create mode 100644 sysdeps/generic/math-use-builtins-roundeven.h diff --git a/sysdeps/generic/math-use-builtins-roundeven.h b/sysdeps/generic/math-use-builtins-roundeven.h new file mode 100644 index 0000000000..bd2e84c93f --- /dev/null +++ b/sysdeps/generic/math-use-builtins-roundeven.h @@ -0,0 +1,4 @@ +#define USE_ROUNDEVEN_BUILTIN 0 +#define USE_ROUNDEVENF_BUILTIN 0 +#define USE_ROUNDEVENL_BUILTIN 0 +#define USE_ROUNDEVENF128_BUILTIN 0 diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h index cc3e9f2201..19d2d1cf3c 100644 --- a/sysdeps/generic/math-use-builtins.h +++ b/sysdeps/generic/math-use-builtins.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/sysdeps/ieee754/dbl-64/s_roundeven.c b/sysdeps/ieee754/dbl-64/s_roundeven.c index 5deff3bb8a..88c051e9fe 100644 --- a/sysdeps/ieee754/dbl-64/s_roundeven.c +++ b/sysdeps/ieee754/dbl-64/s_roundeven.c @@ -21,6 +21,7 @@ #include #include #include +#include #define BIAS 0x3ff #define MANT_DIG 53 @@ -29,6 +30,9 @@ double __roundeven (double x) { +#if USE_ROUNDEVEN_BUILTIN + return __builtin_roundeven (x); +#else uint64_t ix, ux; EXTRACT_WORDS64 (ix, x); ux = ix & 0x7fffffffffffffffULL; @@ -66,6 +70,7 @@ __roundeven (double x) ix &= 0x8000000000000000ULL; INSERT_WORDS64 (x, ix); return x; +#endif /* ! USE_ROUNDEVEN_BUILTIN */ } #ifndef __roundeven libm_alias_double (__roundeven, roundeven) diff --git a/sysdeps/ieee754/flt-32/s_roundevenf.c b/sysdeps/ieee754/flt-32/s_roundevenf.c index 2cc0d7b001..4f568579d8 100644 --- a/sysdeps/ieee754/flt-32/s_roundevenf.c +++ b/sysdeps/ieee754/flt-32/s_roundevenf.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #define BIAS 0x7f @@ -30,6 +31,9 @@ float __roundevenf (float x) { +#if USE_ROUNDEVENF_BUILTIN + return __builtin_roundevenf (x); +#else uint32_t ix, ux; GET_FLOAT_WORD (ix, x); ux = ix & 0x7fffffff; @@ -67,6 +71,7 @@ __roundevenf (float x) ix &= 0x80000000; SET_FLOAT_WORD (x, ix); return x; +#endif /* ! USE_ROUNDEVENF_BUILTIN */ } #ifndef __roundevenf libm_alias_float (__roundeven, roundeven) diff --git a/sysdeps/ieee754/ldbl-128/s_roundevenl.c b/sysdeps/ieee754/ldbl-128/s_roundevenl.c index 7c9c11fad2..afbf13d4f2 100644 --- a/sysdeps/ieee754/ldbl-128/s_roundevenl.c +++ b/sysdeps/ieee754/ldbl-128/s_roundevenl.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #define BIAS 0x3fff @@ -30,6 +31,9 @@ _Float128 __roundevenl (_Float128 x) { +#if USE_ROUNDEVENL_BUILTIN + return __builtin_roundevenl (x); +#else uint64_t hx, lx, uhx; GET_LDOUBLE_WORDS64 (hx, lx, x); uhx = hx & 0x7fffffffffffffffULL; @@ -101,5 +105,6 @@ __roundevenl (_Float128 x) } SET_LDOUBLE_WORDS64 (x, hx, lx); return x; +#endif /* ! USE_ROUNDEVENL_BUILTIN */ } libm_alias_ldouble (__roundeven, roundeven)