public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: LIU Hao <lh_mouse@126.com>
Cc: Andrew Pinski <pinskia@gmail.com>,
	GCC Mailing List <gcc@gcc.gnu.org>,
	 "Joseph S. Myers" <joseph@codesourcery.com>
Subject: Re: MIN/MAX and trapping math and NANs
Date: Tue, 11 Apr 2023 10:46:56 +0000 (UTC)	[thread overview]
Message-ID: <nycvar.YFH.7.77.849.2304111041500.4466@jbgna.fhfr.qr> (raw)
In-Reply-To: <e242b744-4f4c-7453-737e-b0e352572d81@126.com>

On Tue, 11 Apr 2023, LIU Hao wrote:

> ? 2023/4/11 16:00, Richard Biener via Gcc ??:
> > I think without NaNs MIN/MAX cannot raise any exceptions (I'm not
> > even sure whether MIN/MAX involving NaN will set invalid, but
> > most certainly with sNaN it will trap and return a quiet NaN?).
> > The C standard doesn't
> > document any exceptions for fmax/fmin (even with NaN), but
> > meanwhile there's a plethora of min/max function variants ...
> 
> My interpretation is that if one argument is a SNaN and the other is not,
> `fmax()` shall return the SNaN unchanged, without converting it to a QNaN.
> (F.10.9.2 The fmax functions, ISO/IEC 9899:2017)

I see.  I'll note that the x86 maxpd instruction (which doesn't
conform to IEEE with its handling of NaN) raises INVALID on sNaN
and qNaN operands and apperantly also DENORMAL.

In the case we ever implement conforming FP exception support
either targets would need to be fixed to mask unexpected exceptions
or we have to refrain from moving instructions where the target
implementation may rise exceptions across operations that might
raise exceptions as originally written in source (and across
points of FP exception state inspection).

That said, the effect to the FP exception state according to IEEE
is still unanswered.  The NaN handling then possibly allows
implementation with unordered compare + mask ops.

Richard.

  parent reply	other threads:[~2023-04-11 10:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-01 22:29 Andrew Pinski
2023-04-11  8:00 ` Richard Biener
2023-04-11  8:51   ` LIU Hao
2023-04-11  8:58     ` LIU Hao
2023-04-11 10:46     ` Richard Biener [this message]
2023-04-11 15:27       ` Michael Matz
2023-04-11 17:50         ` Joseph Myers

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=nycvar.YFH.7.77.849.2304111041500.4466@jbgna.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=lh_mouse@126.com \
    --cc=pinskia@gmail.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.
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).