public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-6898] range-op-float: Only flush_denormals_to_zero for +-*/ [PR109154]
Date: Tue, 28 Mar 2023 09:01:04 +0000 (GMT)	[thread overview]
Message-ID: <20230328090105.0044E3858D39@sourceware.org> (raw)

https://gcc.gnu.org/g:ce3974e5962b0e1f72a1f71ebda39d53a77b7cc9

commit r13-6898-gce3974e5962b0e1f72a1f71ebda39d53a77b7cc9
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Mar 28 11:00:32 2023 +0200

    range-op-float: Only flush_denormals_to_zero for +-*/ [PR109154]
    
    As discussed in the PR, flushing denormals to zero on every frange::set
    might be harmful for e.g. x < 0.0 comparisons, because we then on both
    sides use ranges that include zero [-Inf, -0.0] on the true side, and
    [-0.0, +Inf] NAN on the false side, rather than [-Inf, nextafter (-0.0, -Inf)]
    on the true side.
    
    The following patch does it only in range_operator_float::fold_range
    which is right now used for +-*/ (both normal and reverse ops of those).
    
    Though, I don't see any difference on the testcase in the PR, but not sure
    what I should be looking at and the reduced testcase there has undefined
    behavior.
    
    2023-03-28  Jakub Jelinek  <jakub@redhat.com>
    
            PR tree-optimization/109154
            * value-range.h (frange::flush_denormals_to_zero): Make it public
            rather than private.
            * value-range.cc (frange::set): Don't call flush_denormals_to_zero
            here.
            * range-op-float.cc (range_operator_float::fold_range): Call
            flush_denormals_to_zero.

Diff:
---
 gcc/range-op-float.cc | 2 ++
 gcc/value-range.cc    | 2 --
 gcc/value-range.h     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index dc9789b4ffd..d212e64a624 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -112,6 +112,8 @@ range_operator_float::fold_range (frange &r, tree type,
 	}
     }
 
+  r.flush_denormals_to_zero ();
+
   return true;
 }
 
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index ec97e765c46..ec826c2fe1b 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -361,8 +361,6 @@ frange::set (tree type,
 
   normalize_kind ();
 
-  flush_denormals_to_zero ();
-
   if (flag_checking)
     verify_range ();
 }
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 2b4f6e91997..969b2b68418 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -373,6 +373,7 @@ public:
   void update_nan (tree) = delete; // Disallow silent conversion to bool.
   void update_nan (const nan_state &);
   void clear_nan ();
+  void flush_denormals_to_zero ();
 
   // fpclassify like API
   bool known_isfinite () const;
@@ -389,7 +390,6 @@ private:
   bool union_nans (const frange &);
   bool intersect_nans (const frange &);
   bool combine_zeros (const frange &, bool union_p);
-  void flush_denormals_to_zero ();
 
   tree m_type;
   REAL_VALUE_TYPE m_min;

                 reply	other threads:[~2023-03-28  9:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230328090105.0044E3858D39@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@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).