public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-3272] Add op1_op2_relation for float operands.
Date: Thu, 13 Oct 2022 12:17:10 +0000 (GMT)	[thread overview]
Message-ID: <20221013121710.56A853858C55@sourceware.org> (raw)

https://gcc.gnu.org/g:5364b425934436b9ba52bd95ed8a8a19ce7af207

commit r13-3272-g5364b425934436b9ba52bd95ed8a8a19ce7af207
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Thu Oct 13 08:08:26 2022 +0200

    Add op1_op2_relation for float operands.
    
    op1_op2_relation can be called for relops (bool = a < b) as well as
    regular binary operators (z = a + b).  This patch adds the overloaded
    method for floating point results.
    
    gcc/ChangeLog:
    
            * range-op-float.cc (range_operator_float::op1_op2_relation): New.
            (class foperator_equal): Add using.
            (class foperator_not_equal): Same.
            (class foperator_lt): Same.
            (class foperator_le): Same.
            (class foperator_gt): Same.
            (class foperator_ge): Same.
            * range-op.cc (range_op_handler::op1_op2_relation): New.
            * range-op.h (range_operator_float::op1_op2_relation): New.

Diff:
---
 gcc/range-op-float.cc | 12 ++++++++++++
 gcc/range-op.cc       |  4 +++-
 gcc/range-op.h        |  1 +
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index 229b9d23351..23e0f5ef4e2 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -160,6 +160,12 @@ range_operator_float::op1_op2_relation (const irange &lhs ATTRIBUTE_UNUSED) cons
   return VREL_VARYING;
 }
 
+relation_kind
+range_operator_float::op1_op2_relation (const frange &lhs ATTRIBUTE_UNUSED) const
+{
+  return VREL_VARYING;
+}
+
 // Return TRUE if OP1 is known to be free of NANs.
 
 static inline bool
@@ -338,6 +344,7 @@ class foperator_equal : public range_operator_float
   using range_operator_float::fold_range;
   using range_operator_float::op1_range;
   using range_operator_float::op2_range;
+  using range_operator_float::op1_op2_relation;
 public:
   bool fold_range (irange &r, tree type,
 		   const frange &op1, const frange &op2,
@@ -444,6 +451,7 @@ class foperator_not_equal : public range_operator_float
 {
   using range_operator_float::fold_range;
   using range_operator_float::op1_range;
+  using range_operator_float::op1_op2_relation;
 public:
   bool fold_range (irange &r, tree type,
 		   const frange &op1, const frange &op2,
@@ -545,6 +553,7 @@ class foperator_lt : public range_operator_float
   using range_operator_float::fold_range;
   using range_operator_float::op1_range;
   using range_operator_float::op2_range;
+  using range_operator_float::op1_op2_relation;
 public:
   bool fold_range (irange &r, tree type,
 		   const frange &op1, const frange &op2,
@@ -660,6 +669,7 @@ class foperator_le : public range_operator_float
   using range_operator_float::fold_range;
   using range_operator_float::op1_range;
   using range_operator_float::op2_range;
+  using range_operator_float::op1_op2_relation;
 public:
   bool fold_range (irange &r, tree type,
 		   const frange &op1, const frange &op2,
@@ -767,6 +777,7 @@ class foperator_gt : public range_operator_float
   using range_operator_float::fold_range;
   using range_operator_float::op1_range;
   using range_operator_float::op2_range;
+  using range_operator_float::op1_op2_relation;
 public:
   bool fold_range (irange &r, tree type,
 		   const frange &op1, const frange &op2,
@@ -882,6 +893,7 @@ class foperator_ge : public range_operator_float
   using range_operator_float::fold_range;
   using range_operator_float::op1_range;
   using range_operator_float::op2_range;
+  using range_operator_float::op1_op2_relation;
 public:
   bool fold_range (irange &r, tree type,
 		   const frange &op1, const frange &op2,
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 16fa1f4f46d..f8255dd10a1 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -4476,7 +4476,9 @@ range_op_handler::op1_op2_relation (const vrange &lhs) const
   gcc_checking_assert (m_valid);
   if (m_int)
     return m_int->op1_op2_relation (as_a <irange> (lhs));
-  return m_float->op1_op2_relation (as_a <irange> (lhs));
+  if (is_a <irange> (lhs))
+    return m_float->op1_op2_relation (as_a <irange> (lhs));
+  return m_float->op1_op2_relation (as_a <frange> (lhs));
 }
 
 // Cast the range in R to TYPE.
diff --git a/gcc/range-op.h b/gcc/range-op.h
index b2f063afb07..48adcecc7c6 100644
--- a/gcc/range-op.h
+++ b/gcc/range-op.h
@@ -160,6 +160,7 @@ public:
 					  const frange &op2,
 					  relation_kind = VREL_VARYING) const;
   virtual relation_kind op1_op2_relation (const irange &lhs) const;
+  virtual relation_kind op1_op2_relation (const frange &lhs) const;
 };
 
 class range_op_handler

                 reply	other threads:[~2022-10-13 12:17 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=20221013121710.56A853858C55@sourceware.org \
    --to=aldyh@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).