public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@redhat.com>
To: Jeff Law <jeffreyalaw@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Add set/get functions for negative infinity in real.*
Date: Fri, 26 Aug 2022 18:25:28 +0200	[thread overview]
Message-ID: <CAGm3qMVejPSSTq+mb34zFKSjqYfStF_ioad0TLPnJiYD=_9+rg@mail.gmail.com> (raw)
In-Reply-To: <3f27ee05-39b4-e906-ed11-fa16c8ba2d37@gmail.com>

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

On Fri, Aug 26, 2022 at 6:09 PM Jeff Law via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
>
>
> On 8/26/2022 9:43 AM, Aldy Hernandez via Gcc-patches wrote:
> > Another real.* tweak.  This time, adding a real_iszero() entry point
> > to match the real_isnegzero.  I could combine this patch with the
> > negative infinity one in this thread if y'all would prefer.
> >
> > OK pending tests?
> >
> > p.s. I'd really like to go and benchmark all this real.* stuff
> > (later), because I think we could inline a bunch of these functions in
> > the header file.
> Same comments as the INF patch.

OK pending tests?
Aldy

[-- Attachment #2: 0002-Add-real_iszero-to-real.patch --]
[-- Type: text/x-patch, Size: 1851 bytes --]

From 23338ea7f2f079a35df52b240e7422ca2d449acd Mon Sep 17 00:00:00 2001
From: Aldy Hernandez <aldyh@redhat.com>
Date: Fri, 26 Aug 2022 16:57:09 +0200
Subject: [PATCH] Add real_iszero to real.*

We have real_isnegzero but no real_iszero.  We could memcmp with 0,
but that's just ugly.

gcc/ChangeLog:

	* real.cc (real_iszero): New.
	* real.h (real_iszero): New.
---
 gcc/real.cc | 16 ++++++++++++++++
 gcc/real.h  |  6 ++++++
 2 files changed, 22 insertions(+)

diff --git a/gcc/real.cc b/gcc/real.cc
index dcf41b79f60..96f05ec68ca 100644
--- a/gcc/real.cc
+++ b/gcc/real.cc
@@ -1272,6 +1272,22 @@ real_isneg (const REAL_VALUE_TYPE *r)
   return r->sign;
 }
 
+/* Determine whether a floating-point value X is plus or minus zero.  */
+
+bool
+real_iszero (const REAL_VALUE_TYPE *r)
+{
+  return r->cl == rvc_zero;
+}
+
+/* Determine whether a floating-point value X is zero with SIGN.  */
+
+bool
+real_iszero (const REAL_VALUE_TYPE *r, bool sign)
+{
+  return real_iszero (r) && r->sign == sign;
+}
+
 /* Determine whether a floating-point value X is minus zero.  */
 
 bool
diff --git a/gcc/real.h b/gcc/real.h
index e01f9ed7282..ec78e8a8932 100644
--- a/gcc/real.h
+++ b/gcc/real.h
@@ -295,6 +295,12 @@ extern bool real_isneg (const REAL_VALUE_TYPE *);
 /* Determine whether a floating-point value X is minus zero.  */
 extern bool real_isnegzero (const REAL_VALUE_TYPE *);
 
+/* Determine whether a floating-point value X is plus or minus zero.  */
+extern bool real_iszero (const REAL_VALUE_TYPE *);
+
+/* Determine whether a floating-point value X is zero with SIGN.  */
+extern bool real_iszero (const REAL_VALUE_TYPE *, bool sign);
+
 /* Test relationships between reals.  */
 extern bool real_identical (const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *);
 extern bool real_equal (const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *);
-- 
2.37.1


  reply	other threads:[~2022-08-26 16:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 10:33 Aldy Hernandez
2022-08-26 15:43 ` Aldy Hernandez
2022-08-26 15:43   ` Aldy Hernandez
2022-08-26 16:08   ` Jeff Law
2022-08-26 16:25     ` Aldy Hernandez [this message]
2022-08-26 16:34       ` Jeff Law
2022-08-26 16:07 ` Jeff Law
2022-08-26 16:24   ` Aldy Hernandez
2022-08-26 16:33     ` Jeff Law
2022-08-26 16:38       ` 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='CAGm3qMVejPSSTq+mb34zFKSjqYfStF_ioad0TLPnJiYD=_9+rg@mail.gmail.com' \
    --to=aldyh@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.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).