From: Xi Ruoyao <xry111@xry111.site>
To: Aldy Hernandez <aldyh@redhat.com>, GCC patches <gcc-patches@gcc.gnu.org>
Cc: Jakub Jelinek <jakub@redhat.com>, Andrew MacLeod <amacleod@redhat.com>
Subject: Re: [COMMITTED] [range-op-float] Implement MINUS_EXPR.
Date: Wed, 09 Nov 2022 21:49:35 +0800 [thread overview]
Message-ID: <8b9f17ccf291b5391ff5a872748b64d94682c8fb.camel@xry111.site> (raw)
In-Reply-To: <20221109070758.1030615-2-aldyh@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2618 bytes --]
Hi Aldy,
This commit breaks the attached test case at -O2 on x86_64-linux-gnu and
loongarch64-linux-gnu :(.
The code is simplified from Glibc: the breakage causes two Glibc test
failures on loongarch64-linux-gnu.
Reverting the commit can fix the breakage.
On Wed, 2022-11-09 at 08:07 +0100, Aldy Hernandez via Gcc-patches wrote:
> Now that the generic parts of the binary operators have been
> abstracted, implementing MINUS_EXPR is a cinch.
>
> The op[12]_range entries will be submitted as a follow-up.
>
> gcc/ChangeLog:
>
> * range-op-float.cc (class foperator_minus): New.
> (floating_op_table::floating_op_table): Add MINUS_EXPR entry.
> ---
> gcc/range-op-float.cc | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
> index 7075c25442a..d52e971f84e 100644
> --- a/gcc/range-op-float.cc
> +++ b/gcc/range-op-float.cc
> @@ -1884,6 +1884,29 @@ class foperator_plus : public
> range_operator_float
> } fop_plus;
>
>
> +class foperator_minus : public range_operator_float
> +{
> + void rv_fold (REAL_VALUE_TYPE &lb, REAL_VALUE_TYPE &ub, bool
> &maybe_nan,
> + tree type,
> + const REAL_VALUE_TYPE &lh_lb,
> + const REAL_VALUE_TYPE &lh_ub,
> + const REAL_VALUE_TYPE &rh_lb,
> + const REAL_VALUE_TYPE &rh_ub) const final override
> + {
> + frange_arithmetic (MINUS_EXPR, type, lb, lh_lb, rh_ub,
> dconstninf);
> + frange_arithmetic (MINUS_EXPR, type, ub, lh_ub, rh_lb,
> dconstinf);
> +
> + // [+INF] - [+INF] = NAN
> + if (real_isinf (&lh_ub, false) && real_isinf (&rh_ub, false))
> + maybe_nan = true;
> + // [-INF] - [-INF] = NAN
> + else if (real_isinf (&lh_lb, true) && real_isinf (&rh_lb, true))
> + maybe_nan = true;
> + else
> + maybe_nan = false;
> + }
> +} fop_minus;
> +
> // Instantiate a range_op_table for floating point operations.
> static floating_op_table global_floating_table;
>
> @@ -1917,6 +1940,7 @@ floating_op_table::floating_op_table ()
> set (ABS_EXPR, fop_abs);
> set (NEGATE_EXPR, fop_negate);
> set (PLUS_EXPR, fop_plus);
> + set (MINUS_EXPR, fop_minus);
> }
>
> // Return a pointer to the range_operator_float instance, if there is
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
[-- Attachment #2: test1.c --]
[-- Type: text/x-csrc, Size: 417 bytes --]
__attribute__((noipa,noinline))
int t(double a, double b)
{
double c = a - b;
if (!__builtin_isfinite(c)) {
if (__builtin_isnan(c)) {
if (!__builtin_isnan(a) && !__builtin_isnan(b))
return 1;
} else if (__builtin_isfinite(a) && __builtin_isfinite(b))
return 2;
} else if (c == 0 && a != b)
return 3;
return 4;
}
int main()
{
double a = __builtin_inf();
if (t(a, a) != 1)
__builtin_abort();
}
next prev parent reply other threads:[~2022-11-09 13:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-09 7:07 [COMMITTED] [range-op-float] Abstract out binary operator code out of PLUS_EXPR entry Aldy Hernandez
2022-11-09 7:07 ` [COMMITTED] [range-op-float] Implement MINUS_EXPR Aldy Hernandez
2022-11-09 13:49 ` Xi Ruoyao [this message]
2022-11-09 13:58 ` Xi Ruoyao
2022-11-09 15:45 ` Aldy Hernandez
2022-11-09 12:48 ` [COMMITTED] [range-op-float] Abstract out binary operator code out of PLUS_EXPR entry Jakub Jelinek
2022-11-09 13:14 ` Aldy Hernandez
2022-11-09 13:32 ` Jakub Jelinek
2022-11-09 14:19 ` Jakub Jelinek
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=8b9f17ccf291b5391ff5a872748b64d94682c8fb.camel@xry111.site \
--to=xry111@xry111.site \
--cc=aldyh@redhat.com \
--cc=amacleod@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.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).