From patchwork Sat May 30 02:00:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 1301113 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=FkveX9k3; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Yl636PvJz9sSJ for ; Sat, 30 May 2020 12:01:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CE0EB388E80C; Sat, 30 May 2020 02:00:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE0EB388E80C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1590804059; bh=6LC8SGj5ehOCCH1p1NEwRteTJ4DL6x8N9f2nCm5Ap+8=; 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=FkveX9k3v0rnQ4+jT+0BV3YiHELjL4rbeXmsBxOELdQoHTx/cABewHheYsz3oytt2 Q3KQnP+qhGvRaJMvY/bl2lgXjw7xIhRGTPuN/v3RXHMalc78dds/MsYntue+liB4DV yHEu95yTOoR223upQOx8aQ+6J7Z6b0xjRleVrePY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtprelay-out1.synopsys.com (smtprelay-out1.synopsys.com [149.117.73.133]) by sourceware.org (Postfix) with ESMTPS id 7A0F838708D3 for ; Sat, 30 May 2020 02:00:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7A0F838708D3 Received: from mailhost.synopsys.com (sv1-mailhost2.synopsys.com [10.205.2.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id B24F04095F; Sat, 30 May 2020 02:00:51 +0000 (UTC) Received: from vineetg-Latitude-7400.internal.synopsys.com (unknown [10.13.183.89]) by mailhost.synopsys.com (Postfix) with ESMTP id 7CA31A023C; Sat, 30 May 2020 02:00:51 +0000 (UTC) X-SNPS-Relay: synopsys.com To: libc-alpha@sourceware.org Subject: [PATCH 3/5] iee754: prvoide gcc builtins based generic fma functions Date: Fri, 29 May 2020 19:00:45 -0700 Message-Id: <20200530020047.5490-4-vgupta@synopsys.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200530020047.5490-1-vgupta@synopsys.com> References: <20200530020047.5490-1-vgupta@synopsys.com> MIME-Version: 1.0 X-Spam-Status: No, score=-16.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: Vineet Gupta via Libc-alpha From: Vineet Gupta Reply-To: Vineet Gupta Cc: Vineet Gupta , linux-snps-arc@lists.infradead.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" --- sysdeps/generic/math-use-builtins.h | 4 ++++ sysdeps/ieee754/dbl-64/s_fma.c | 6 ++++++ sysdeps/ieee754/dbl-64/s_fmaf.c | 6 ++++++ sysdeps/ieee754/float128/float128_private.h | 2 ++ sysdeps/ieee754/ldbl-128/s_fmal.c | 5 +++++ 5 files changed, 23 insertions(+) Reviewed-by: Adhemerval Zanella diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h index fc724c824a17..9e96807a3370 100644 --- a/sysdeps/generic/math-use-builtins.h +++ b/sysdeps/generic/math-use-builtins.h @@ -63,4 +63,8 @@ #define USE_SQRT_BUILTIN 0 #define USE_SQRTF_BUILTIN 0 +#define USE_FMA_BUILTIN 0 +#define USE_FMAF_BUILTIN 0 +#define USE_FMAL_BUILTIN 0 + #endif /* math-use-builtins.h */ diff --git a/sysdeps/ieee754/dbl-64/s_fma.c b/sysdeps/ieee754/dbl-64/s_fma.c index 876df6e78bdc..1e4b2da1511d 100644 --- a/sysdeps/ieee754/dbl-64/s_fma.c +++ b/sysdeps/ieee754/dbl-64/s_fma.c @@ -25,6 +25,7 @@ #include #include #include +#include /* This implementation uses rounding to odd to avoid problems with double rounding. See a paper by Boldo and Melquiond: @@ -33,6 +34,10 @@ double __fma (double x, double y, double z) { +#if USE_FMA_BUILTIN + return __builtin_fma (x); +#else + /* Use generic implementation. */ union ieee754_double u, v, w; int adjust = 0; u.d = x; @@ -292,6 +297,7 @@ __fma (double x, double y, double z) v.ieee.mantissa1 |= j; return v.d * 0x1p-108; } +#endif /* ! USE_FMA_BUILTIN */ } #ifndef __fma libm_alias_double (__fma, fma) diff --git a/sysdeps/ieee754/dbl-64/s_fmaf.c b/sysdeps/ieee754/dbl-64/s_fmaf.c index 57329d0a87fe..f15b18262124 100644 --- a/sysdeps/ieee754/dbl-64/s_fmaf.c +++ b/sysdeps/ieee754/dbl-64/s_fmaf.c @@ -23,6 +23,7 @@ #include #include #include +#include /* This implementation relies on double being more than twice as precise as float and uses rounding to odd in order to avoid problems @@ -33,6 +34,10 @@ float __fmaf (float x, float y, float z) { +#if USE_FMAF_BUILTIN + return __builtin_fmaf (x); +#else + /* Use generic implementation. */ fenv_t env; /* Multiplication is always exact. */ @@ -60,6 +65,7 @@ __fmaf (float x, float y, float z) /* And finally truncation with round to nearest. */ return (float) u.d; +#endif /* ! USE_FMAF_BUILTIN */ } #ifndef __fmaf libm_alias_float (__fma, fma) diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h index f97463d9dc1b..a697a7c29038 100644 --- a/sysdeps/ieee754/float128/float128_private.h +++ b/sysdeps/ieee754/float128/float128_private.h @@ -154,6 +154,8 @@ #define USE_ROUNDL_BUILTIN USE_ROUNDF128_BUILTIN #undef USE_COPYSIGNL_BUILTIN #define USE_COPYSIGNL_BUILTIN USE_COPYSIGNF128_BUILTIN +#undef USE_FMAL_BUILTIN +#define USE_FMAL_BUILTIN USE_FMA128_BUILTIN /* IEEE function renames. */ #define __ieee754_acoshl __ieee754_acoshf128 diff --git a/sysdeps/ieee754/ldbl-128/s_fmal.c b/sysdeps/ieee754/ldbl-128/s_fmal.c index 7475015bcec6..1403734a5aeb 100644 --- a/sysdeps/ieee754/ldbl-128/s_fmal.c +++ b/sysdeps/ieee754/ldbl-128/s_fmal.c @@ -25,6 +25,7 @@ #include #include #include +#include /* This implementation uses rounding to odd to avoid problems with double rounding. See a paper by Boldo and Melquiond: @@ -33,6 +34,9 @@ _Float128 __fmal (_Float128 x, _Float128 y, _Float128 z) { +#if USE_FMAL_BUILTIN + return __builtin_fmal (x); +#else union ieee854_long_double u, v, w; int adjust = 0; u.d = x; @@ -296,5 +300,6 @@ __fmal (_Float128 x, _Float128 y, _Float128 z) v.ieee.mantissa3 |= j; return v.d * L(0x1p-228); } +#endif /* ! USE_FMAL_BUILTIN */ } libm_alias_ldouble (__fma, fma)