public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libquadmath/114140] different results for std::fmin/std::fmax and quadmath fminq/fmaxq if one argument=signaling_NaN
Date: Wed, 28 Feb 2024 12:35:00 +0000	[thread overview]
Message-ID: <bug-114140-4-gFsX10qmsi@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114140-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114140

--- Comment #17 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Xi Ruoyao from comment #16)
> (In reply to Richard Biener from comment #15)
> > It's the old argument on whether isnan(NaN) should return true or false with
> > -ffinite-math-only.  With what we currently do "constant folding" sNaN into
> > NaN would be correct with -fno-signalling-nans, likewise constant folding
> > Inf into 42.0 is "correct" for -ffinite-math-only.
> > 
> > You are basically invoking undefined beavior when introducing sNaN into a
> > program without using -fsignalling-nans.
> 
> Then we should make it more clear in invoke.texi.  Currently the doc is
> implying the worst consequence using sNaN with -fno-signalling-nans is
> "changing the number of raised exceptions."

Yeah, the options that are not enabled by default (-fno-signalling-nans,
-fno-trapping-math) could see improvement here.

Usually -fno-X enables optimizations that would be invalid when X happens/is
present.  But that is nothing else than giving a free ticked to undefined
behavior, maybe "constrained undefined behavior", but I'm not 100% sure we'd
live up to that.

Aka isnan (NaN) is optimized to false with -ffinite-math-only, something
that's not valid when non-finite numbers are present.  Whether doing
so for literal NaN is "nice" remains questionable, but it's at least
consistent with the behavior of x = NaN; isnan (x);

So similarly -fno-signaling-nans enables optimizations that are not
valid when sNaNs are present.  Indeed "optimizations that may change the number
of exceptions visible with signaling NaNs" is over-promising even if
effectively this is all that happens.

      parent reply	other threads:[~2024-02-28 12:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 21:09 [Bug libquadmath/114140] New: quadmath fminq/fmaxq with signaling_NaN not work g.peterhoff@t-online.de
2024-02-27 22:14 ` [Bug libquadmath/114140] " jakub at gcc dot gnu.org
2024-02-27 22:20 ` jsm28 at gcc dot gnu.org
2024-02-27 22:36 ` [Bug middle-end/114140] " pinskia at gcc dot gnu.org
2024-02-27 22:40 ` [Bug middle-end/114140] fmin/fmax " pinskia at gcc dot gnu.org
2024-02-27 22:41 ` jakub at gcc dot gnu.org
2024-02-27 22:48 ` pinskia at gcc dot gnu.org
2024-02-28  0:59 ` [Bug middle-end/114140] different results for std::fmin/std::fmax and quadmath fminq/fmaxq if one argument=signaling_NaN g.peterhoff@t-online.de
2024-02-28  1:02 ` [Bug libquadmath/114140] " pinskia at gcc dot gnu.org
2024-02-28  1:04 ` pinskia at gcc dot gnu.org
2024-02-28  1:06 ` pinskia at gcc dot gnu.org
2024-02-28  1:07 ` pinskia at gcc dot gnu.org
2024-02-28  1:09 ` pinskia at gcc dot gnu.org
2024-02-28  1:55 ` g.peterhoff@t-online.de
2024-02-28  2:00 ` pinskia at gcc dot gnu.org
2024-02-28  8:12 ` rguenth at gcc dot gnu.org
2024-02-28 11:36 ` xry111 at gcc dot gnu.org
2024-02-28 12:35 ` rguenth at gcc dot gnu.org [this message]

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=bug-114140-4-gFsX10qmsi@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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).