public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: HAO CHEN GUI <guihaoc@linux.ibm.com>
Cc: "Kewen.Lin" <linkw@linux.ibm.com>,
	Richard Biener <richard.guenther@gmail.com>,
	Peter Bergner <bergner@linux.ibm.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>, David <dje.gcc@gmail.com>
Subject: Re: [PATCH] Skip constant folding for fmin/max when either argument is sNaN [PR105414]
Date: Thu, 5 May 2022 08:23:11 -0500	[thread overview]
Message-ID: <20220505132311.GA25951@gate.crashing.org> (raw)
In-Reply-To: <0aa8c058-5dd3-c7bf-935a-8df4947ebab0@linux.ibm.com>

Hi!

On Thu, May 05, 2022 at 05:30:58PM +0800, HAO CHEN GUI wrote:
> On 5/5/2022 下午 4:30, Kewen.Lin wrote:
> > on 2022/5/5 16:09, Richard Biener via Gcc-patches wrote:
> >> On Thu, May 5, 2022 at 10:07 AM HAO CHEN GUI via Gcc-patches
> >> <gcc-patches@gcc.gnu.org> wrote:
> >>>    This patch skips constant folding for fmin/max when either argument
> >>> is sNaN. According to C standard,
> >>>    fmin(sNaN, sNaN)= qNaN, fmin(sNaN, NaN) = qNaN
> >>>    So signaling NaN should be tested and skipped for fmin/max in match.pd.
> >>>
> >>>    Bootstrapped and tested on ppc64 Linux BE and LE with no regressions.

The C standard does not talk about sNaNs *at all*, in any released
version of the standard.  And the C2x drafts do not talk about signaling
arguments for fmin/fmax specifically, so it should just raise an error
like any other floating operation with an sNaN arg will.  This means we
have to make sure to not optimise away all operations if there may be
an sNaN (and we have HONOR_SNANS for the mode in use).

You never have to convert to a qNaN manually.   Instead, any normal
operation on the sNaN will raise the exception, and convert to the qNaN.
There is no sane way you can raise the exception manually, so you should
make sure we end up with a real operation in the RTL, and then generate
proper machine code for it as well.  See rs6000 extendsfdf2 for example,
for that last part.

And of course both the gimple min_expr and the RTL smin are not defined
for NaN inputs at all anyway :-P


Segher

      reply	other threads:[~2022-05-05 13:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05  8:06 HAO CHEN GUI
2022-05-05  8:09 ` Richard Biener
2022-05-05  8:30   ` Kewen.Lin
2022-05-05  8:35     ` Richard Biener
2022-05-05 17:11       ` Joseph Myers
2022-05-06  6:17         ` Richard Biener
2022-05-05  9:30     ` HAO CHEN GUI
2022-05-05 13:23       ` Segher Boessenkool [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=20220505132311.GA25951@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=bergner@linux.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=guihaoc@linux.ibm.com \
    --cc=linkw@linux.ibm.com \
    --cc=richard.guenther@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).