mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] fix underflow exception in fma and fmal
Date: Sun, 19 Mar 2017 10:12:49 -0400	[thread overview]
Message-ID: <20170319141249.GR1693@brightrain.aerifal.cx> (raw)
In-Reply-To: <20170319033613.GO2082@port70.net>

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


  reply	other threads:[~2017-03-19 14:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-19  3:36 Szabolcs Nagy
2017-03-19 14:12 ` Rich Felker [this message]
2017-03-19 14:39   ` Szabolcs Nagy
2017-03-19 14:53     ` Rich Felker
2017-03-19 17:06       ` Szabolcs Nagy

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=20170319141249.GR1693@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).