public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mikael Morin <morin-mikael@orange.fr>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Rewrite NAN and sign handling in frange
Date: Tue, 27 Sep 2022 15:00:14 +0200	[thread overview]
Message-ID: <46a9380d-2cd5-7bfb-ecc7-a33a8369338b@orange.fr> (raw)
In-Reply-To: <CAGm3qMXtoe4N1nh=Td4sUMX2xA=7Y2i4HT+2QjrSuf=j1yXE+w@mail.gmail.com>

Hello,

Le 16/09/2022 à 15:26, Aldy Hernandez via Gcc-patches a écrit :
> diff --git a/gcc/value-range.cc b/gcc/value-range.cc
> index d759fcf178c..55a216efd8b 100644
> --- a/gcc/value-range.cc
> +++ b/gcc/value-range.cc
> @@ -617,21 +602,24 @@ frange::contains_p (tree cst) const
>    if (varying_p ())
>      return true;
>  
  (...)
>  
>    if (real_compare (GE_EXPR, rv, &m_min) && real_compare (LE_EXPR, rv, &m_max))
>      {
> +      // Make sure the signs are equal for signed zeros.
>        if (HONOR_SIGNED_ZEROS (m_type) && real_iszero (rv))
> -	{
> -	  // FIXME: This is still using get_signbit() instead of
> -	  // known_signbit() because the latter bails on possible NANs
> -	  // (for now).
> -	  if (get_signbit ().yes_p ())
> -	    return real_isneg (rv);
> -	  else if (get_signbit ().no_p ())
> -	    return !real_isneg (rv);
> -	  else
> -	    return true;
> -	}
> +	return m_min.sign == m_max.sign && m_min.sign == rv->sign;
>        return true;
>      }
>    return false;

It seems that this won't report any range with mismatching bound signs 
as containing zero.
Maybe a selftest explains it better: the following fails.

diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 9ca442478c9..8fc909171bc 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -3780,6 +3780,14 @@ range_tests_signed_zeros ()
    ASSERT_TRUE (r0.contains_p (neg_zero));
    ASSERT_FALSE (r0.contains_p (zero));

+  r0 = frange_float ("-3", "5");
+  ASSERT_TRUE (r0.contains_p (neg_zero));
+  ASSERT_TRUE (r0.contains_p (zero));
+
+  r0 = frange (neg_zero, zero);
+  ASSERT_TRUE (r0.contains_p (neg_zero));
+  ASSERT_TRUE (r0.contains_p (zero));
+
    // The intersection of zeros that differ in sign is a NAN (or
    // undefined if not honoring NANs).
    r0 = frange (neg_zero, neg_zero);


  parent reply	other threads:[~2022-09-27 13:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15  5:40 Aldy Hernandez
2022-09-15  7:06 ` Richard Biener
2022-09-15 20:44   ` Aldy Hernandez
2022-09-16  8:33     ` Richard Sandiford
2022-09-16 13:26       ` Aldy Hernandez
2022-09-18  7:10         ` Aldy Hernandez
2022-09-27 13:00         ` Mikael Morin [this message]
2022-11-02 13:35           ` Aldy Hernandez

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=46a9380d-2cd5-7bfb-ecc7-a33a8369338b@orange.fr \
    --to=morin-mikael@orange.fr \
    --cc=gcc-patches@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).