Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 19 Mar 2017 10:12:49 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] fix underflow exception in fma and fmal

On Sun, Mar 19, 2017 at 04:36:14AM +0100, Szabolcs Nagy wrote:
> another corner case in the freebsd fma code where signaling underflow
> may be missed for an inexact subnormal result.
> (fmaf and x86 fma are not affected)
> ---
>  src/math/fma.c  | 7 +++++++
>  src/math/fmal.c | 8 ++++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/src/math/fma.c b/src/math/fma.c
> index 741ccd75..c69918d1 100644
> --- a/src/math/fma.c
> +++ b/src/math/fma.c
> @@ -279,6 +279,13 @@ static inline double add_and_denormalize(double a, double b, int scale)
>  			uhi.i += 1 - (((uhi.i ^ ulo.i) >> 62) & 2);
>  			sum.hi = uhi.f;
>  		}
> +#ifdef FE_UNDERFLOW
> +		/*
> +		 * Raise underflow manually because scalbn won't do it if all
> +		 * lost bits are 0: fma(-0x1p-1000, 0x1.000001p-74, 0x1p-1022)
> +		 */
> +		feraiseexcept(FE_UNDERFLOW);
> +#endif

Can you explain why it should happen if all lost bits are zero
(usually that's an exact case). I imagine it's something specific to
fma or its implementation but it's not obvious to me.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.