From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Vineet Gupta <Vineet.Gupta1@synopsys.com>, libc-alpha@sourceware.org
Cc: linux-snps-arc@lists.infradead.org
Subject: Re: [PATCH 3/5] iee754: prvoide gcc builtins based generic fma functions
Date: Mon, 1 Jun 2020 11:20:06 -0300 [thread overview]
Message-ID: <a2fc9a69-1e40-f121-7ca5-d783dba93918@linaro.org> (raw)
In-Reply-To: <20200530020047.5490-4-vgupta@synopsys.com>
On 29/05/2020 23:00, Vineet Gupta wrote:
Ok with the fixes below.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> 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(+)
>
> 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 */
For float128 support it should also contain a:
#define USE_FMAF128_BUILTIN
> 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 <fenv_private.h>
> #include <libm-alias-double.h>
> #include <tininess.h>
> +#include <math-use-builtins.h>
>
> /* 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);
It should be:
return __builtin_fma (x, y, z);
Same for float and long double variant.
> +#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 <math-barriers.h>
> #include <fenv_private.h>
> #include <libm-alias-float.h>
> +#include <math-use-builtins.h>
>
> /* 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
Ok.
> 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 <math_private.h>
> #include <libm-alias-ldouble.h>
> #include <tininess.h>
> +#include <math-use-builtins.h>
>
> /* 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)
>
next prev parent reply other threads:[~2020-06-01 14:20 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-30 2:00 [PATCH 0/5] use gcc builtins for sqrt and " Vineet Gupta
2020-05-30 2:00 ` [PATCH 1/5] ARC/dl-runtime helper macros Vineet Gupta
2020-05-30 2:17 ` Vineet Gupta
2020-05-30 2:00 ` [PATCH 2/5] iee754: prvoide gcc builtins based generic sqrt functions Vineet Gupta
2020-06-01 14:13 ` Adhemerval Zanella
2020-06-01 14:42 ` Adhemerval Zanella
2020-06-01 18:12 ` Vineet Gupta
2020-06-01 18:32 ` Adhemerval Zanella
2020-06-01 14:18 ` Florian Weimer
2020-06-01 18:12 ` Vineet Gupta
2020-05-30 2:00 ` [PATCH 3/5] iee754: prvoide gcc builtins based generic fma functions Vineet Gupta
2020-06-01 14:20 ` Adhemerval Zanella [this message]
2020-06-01 16:13 ` Florian Weimer
2020-05-30 2:00 ` [PATCH 4/5] aarch/fpu: use generic sqrt, " Vineet Gupta
2020-06-01 16:38 ` Adhemerval Zanella
2020-06-01 21:44 ` Vineet Gupta
2020-06-01 22:08 ` Ramana Radhakrishnan
2020-06-02 18:12 ` Joseph Myers
2020-05-30 2:00 ` [PATCH 5/5] powerpc/fpu: use generic " Vineet Gupta
2020-06-01 17:10 ` Adhemerval Zanella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a2fc9a69-1e40-f121-7ca5-d783dba93918@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=Vineet.Gupta1@synopsys.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-snps-arc@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).