public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: GCC patches <gcc-patches@gcc.gnu.org>,
	Andrew MacLeod <amacleod@redhat.com>,
	 Xi Ruoyao <xry111@xry111.site>
Subject: Re: [COMMITTED] Implement op[12]_range operators for PLUS_EXPR and MINUS_EXPR.
Date: Wed, 9 Nov 2022 16:43:56 +0100	[thread overview]
Message-ID: <CAGm3qMUCZdo5n_CscMms5h6OgfRx36cDTjaUOayo290No9JSXA@mail.gmail.com> (raw)
In-Reply-To: <Y2vAH9C955dvyDSg@tucnak>

[-- Attachment #1: Type: text/plain, Size: 1466 bytes --]

On Wed, Nov 9, 2022 at 3:58 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Wed, Nov 09, 2022 at 10:02:46AM +0100, Aldy Hernandez wrote:
> > We can implement the op[12]_range entries for plus and minus in terms
> > of each other.  These are adapted from the integer versions.
>
> I think for NANs the op[12]_range shouldn't act this way.
> For the forward binary operations, we have the (maybe/known) NAN handling
> of one or both NAN operands resulting in VARYING sign (maybe/known) NAN
> result, that is the somehow the case for the reverse binary operations too,
> if result is (maybe/known) NAN and the other op is not NAN, op is
> VARYING sign (maybe/known) NAN, if other op is (maybe/known) NAN,
> then op is VARYING sign maybe NAN (always maybe, never known).
> But then for + we have the -INF + INF or vice versa into NAN, and that
> is something that shouldn't be considered.  If result isn't NAN, then
> neither operand can be NAN, regardless of whether result can be
> +/- INF and the other op -/+ INF.

Heh.  I just ran into this while debugging the problem reported by Xi.

We are solving NAN = op1 - VARYING, and trying to do it with op1 = NAN
+ VARYING, which returns op1 = NAN (incorrectly).

I suppose in the above case op1 should ideally be
[-INF,-INF][+INF,+INF]+-NAN, but since we can't represent that then
[-INF,+INF] +-NAN, which is actually VARYING.  Do you agree?

I'm reverting this patch as attached, while I sort this out.

Thanks.
Aldy

[-- Attachment #2: 0001-Revert-op-12-_range-operators-for-PLUS_EXPR-and-MINU.patch --]
[-- Type: text/x-patch, Size: 2781 bytes --]

From f8ac2b15d1ce8cbb2f4a4ba89afbd87a8aa5c4e6 Mon Sep 17 00:00:00 2001
From: Aldy Hernandez <aldyh@redhat.com>
Date: Wed, 9 Nov 2022 16:35:40 +0100
Subject: [PATCH] Revert op[12]_range operators for PLUS_EXPR and MINUS_EXPR.

Revert the patch below until issues are resolved:

	commit 4287e8168f89e90b3dff3a50f3ada40be53e0e01
	Author: Aldy Hernandez <aldyh@redhat.com>
	Date:   Wed Nov 9 01:00:57 2022 +0100

	    Implement op[12]_range operators for PLUS_EXPR and MINUS_EXPR.

	    We can implement the op[12]_range entries for plus and minus in terms
	    of each other.  These are adapted from the integer versions.

gcc/ChangeLog:

	* range-op-float.cc (class foperator_plus): Remove op[12]_range.
	(class foperator_minus): Same.
---
 gcc/range-op-float.cc | 45 -------------------------------------------
 1 file changed, 45 deletions(-)

diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index cc806438a19..380142b4c14 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -1863,29 +1863,6 @@ foperator_unordered_equal::op1_range (frange &r, tree type,
 
 class foperator_plus : public range_operator_float
 {
-  using range_operator_float::op1_range;
-  using range_operator_float::op2_range;
-public:
-  virtual bool op1_range (frange &r, tree type,
-			  const frange &lhs,
-			  const frange &op2,
-			  relation_trio = TRIO_VARYING) const final override
-  {
-    if (lhs.undefined_p ())
-      return false;
-    range_op_handler minus (MINUS_EXPR, type);
-    if (!minus)
-      return false;
-    return minus.fold_range (r, type, lhs, op2);
-  }
-  virtual bool op2_range (frange &r, tree type,
-			  const frange &lhs,
-			  const frange &op1,
-			  relation_trio = TRIO_VARYING) const final override
-  {
-    return op1_range (r, type, lhs, op1);
-  }
-private:
   void rv_fold (REAL_VALUE_TYPE &lb, REAL_VALUE_TYPE &ub, bool &maybe_nan,
 		tree type,
 		const REAL_VALUE_TYPE &lh_lb,
@@ -1910,28 +1887,6 @@ private:
 
 class foperator_minus : public range_operator_float
 {
-  using range_operator_float::op1_range;
-  using range_operator_float::op2_range;
-public:
-  virtual bool op1_range (frange &r, tree type,
-			  const frange &lhs,
-			  const frange &op2,
-			  relation_trio = TRIO_VARYING) const final override
-  {
-    if (lhs.undefined_p ())
-      return false;
-    return fop_plus.fold_range (r, type, lhs, op2);
-  }
-  virtual bool op2_range (frange &r, tree type,
-			  const frange &lhs,
-			  const frange &op1,
-			  relation_trio = TRIO_VARYING) const final override
-  {
-    if (lhs.undefined_p ())
-      return false;
-    return fold_range (r, type, op1, lhs);
-  }
-private:
   void rv_fold (REAL_VALUE_TYPE &lb, REAL_VALUE_TYPE &ub, bool &maybe_nan,
 		tree type,
 		const REAL_VALUE_TYPE &lh_lb,
-- 
2.38.1


  reply	other threads:[~2022-11-09 15:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09  9:02 Aldy Hernandez
2022-11-09 14:58 ` Jakub Jelinek
2022-11-09 15:43   ` Aldy Hernandez [this message]
2022-11-09 15:53     ` Jakub Jelinek
2022-11-11 11:50     ` [PATCH] range-op: Implement op[12]_range operators for {PLUS,MINUS,MULT,RDIV}_EXPR Jakub Jelinek
2022-11-11 14:22       ` Aldy Hernandez
2022-11-11 14:58         ` Andrew MacLeod

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=CAGm3qMUCZdo5n_CscMms5h6OgfRx36cDTjaUOayo290No9JSXA@mail.gmail.com \
    --to=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=xry111@xry111.site \
    /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).