public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>
Cc: "Joseph S. Myers" <joseph@codesourcery.com>,
	Jason Merrill <jason@redhat.com>,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] fold-const: Don't consider NaN non-negative [PR97965]
Date: Thu, 26 Nov 2020 10:49:03 +0100	[thread overview]
Message-ID: <20201126094903.GV3788@tucnak> (raw)
In-Reply-To: <nycvar.YFH.7.77.849.2011260912160.7048@jbgna.fhfr.qr>

On Thu, Nov 26, 2020 at 09:16:29AM +0000, Richard Biener wrote:
> > So, I really don't know if we want this or not, posting it for discussions.
> 
> Is copysign (x, NaN) supposed to be well-defined?  We'd stop folding
> this then, no?

Yes, we'd stop folding several cases with NaNs.

>  I think the ABS_EXPR<x> < 0 to false folding is
> simply incomplete and should first check whether the operands are
> ordered?  That said, NaN is nonnegative but NaN < 0 isn't false(?)
> 
> So I don't think the patch is good.

Another possibility (if we have this optimization already in match.pd too)
would be to only optimize the < 0 case in GENERIC if !HONOR_NANS like
the >= 0 case is and only optimize it in GIMPLE.  Though with the
default -ftrapping-math I think even optimizing qNaN < 0 to 0 is incorrect,
even that should raise invalid exception, shouldn't it?
So perhaps add a defaulted argument to the *nonnegative* APIs that would
say whether unordered is ok or not?

	Jakub


  reply	other threads:[~2020-11-26  9:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-26  8:31 Jakub Jelinek
2020-11-26  9:16 ` Richard Biener
2020-11-26  9:49   ` Jakub Jelinek [this message]
2020-11-26 10:03     ` Richard Biener
2020-11-26 13:56       ` Roger Sayle
2020-11-26 14:13         ` Jakub Jelinek
2020-11-26 14:20           ` Jakub Jelinek
2020-11-26 22:43         ` Jakub Jelinek
2020-11-27 10:51           ` Roger Sayle
2020-11-27 10:56           ` Roger Sayle
2020-11-27 20:39         ` Joseph Myers
2020-11-27 20:31   ` 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=20201126094903.GV3788@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=rguenther@suse.de \
    /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).