public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Roger Sayle <roger@nextmovesoftware.com>,
	gcc-patches@gcc.gnu.org, "'Richard Biener'" <rguenther@suse.de>,
	"'Joseph S. Myers'" <joseph@codesourcery.com>
Subject: Re: [PATCH] fold-const: Don't consider NaN non-negative [PR97965]
Date: Thu, 26 Nov 2020 15:20:43 +0100	[thread overview]
Message-ID: <20201126142043.GZ3788@tucnak> (raw)
In-Reply-To: <20201126141322.GY3788@tucnak>

On Thu, Nov 26, 2020 at 03:13:22PM +0100, Jakub Jelinek via Gcc-patches wrote:
> On Thu, Nov 26, 2020 at 01:56:03PM -0000, Roger Sayle wrote:
> > My completely untested solution is the attached patch.  My apologies, I'm
> > not
> > even set up to compile things on the laptop that I'm composing this e-mail
> > on,
> > but my notes/proposals on tackling PR97965 are easier expressed as the
> > actual
> > suggested changes/edits.  [Forgive me if I've made a typo].
> 
> Ah, thanks, I wasn't aware of that function.
> Looking at the tree_expr_maybe_nan_p implementation, I wonder if:
>     case PLUS_EXPR:
>     case MINUS_EXPR:
>     case MULT_EXPR:
>       return !tree_expr_finite_p (TREE_OPERAND (x, 0))
>              || !tree_expr_finite_p (TREE_OPERAND (x, 1));
> shouldn't try harder, for + and minus, isn't
>       return (tree_expr_maybe_nan_p (TREE_OPERAND (x, 0))
> 	      || tree_expr_maybe_nan_p (TREE_OPERAND (x, 1))
> 	      || (!tree_expr_finite_p (TREE_OPERAND (x, 0))
> 		  && !tree_expr_finite_p (TREE_OPERAND (x, 1))));
> what we want to test?  I mean, if neither operand is a NaN and
> one of the operands is finite, then the result will be either finite
> or inf or -inf, but not NaN.  MULT_EXPR would presumably also need to
> rule out zeros (i.e. use the *nonzero* APIs too, on the other side
> +-inf * +-inf is not NaN).
> 
> Another thing, tree_expr_nonzero_warnv_p handles not just trees, but also
> GIMPLE, shouldn't these tree_expr_finite_p and tree_expr_maybe_nan_p APIs
> be also rewritten so that they can also handle SSA_NAMEs by walking the def
> chains?

Though, of course, both of this can be done incrementally later on.

I'll test your patch tonight.

	Jakub


  reply	other threads:[~2020-11-26 14:20 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
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 [this message]
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=20201126142043.GZ3788@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=rguenther@suse.de \
    --cc=roger@nextmovesoftware.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).