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:38:14 +0200	[thread overview]
Message-ID: <CAGm3qMVUtauWEkCgEjbk6CPsuTuGnJveO_NcOLW+HwRdvqTMbg@mail.gmail.com> (raw)
In-Reply-To: <3ad62c30-5daa-bf7d-43e4-a2027d54d367@gmail.com>

On Fri, Aug 26, 2022 at 6:34 PM Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
>
> On 8/26/2022 10:24 AM, Aldy Hernandez wrote:
> > On Fri, Aug 26, 2022 at 6:08 PM Jeff Law via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> >>
> >>
> >> On 8/23/2022 4:33 AM, Aldy Hernandez via Gcc-patches wrote:
> >>> For the frange implementation with endpoints I'm about to contribute,
> >>> we need to set REAL_VALUE_TYPEs with negative infinity.  The support
> >>> is already there in real.cc, but it is awkward to get at.  One could
> >>> call real_inf() and then negate the value, but I've added the ability
> >>> to pass the sign argument like many of the existing real.* functions.
> >>>
> >>> I've declared the functions in such a way to avoid changes to the
> >>> existing code base:
> >>>
> >>> // Unchanged function returning true for either +-INF.
> >>> bool real_isinf (const REAL_VALUE_TYPE *r);
> >>> // New overload to be able to specify the sign.
> >>> bool real_isinf (const REAL_VALUE_TYPE *r, int sign);
> >>> // Replacement function for setting INF, defaults to +INF.
> >>> void real_inf (REAL_VALUE_TYPE *, int sign = 0);
> >>>
> >>> Tested on x86-64 Linux.
> >>>
> >>> OK?
> >>>
> >>> gcc/ChangeLog:
> >>>
> >>>        * real.cc (real_isinf): New overload.
> >>>        (real_inf): Add sign argument.
> >>>        * real.h (real_isinf): New overload.
> >>>        (real_inf): Add sign argument.
> >> Funny in that I've fairly recently had the desire to do something a bit
> >> similar.  Let's consider 0.5, which we have a dconsthalf, but we don't
> >> have dconstmhalf for -0.5.  To get that value I create a dconsthalf
> >> object and flip its sign.  Similarly for a variety of other special
> >> constants (particularly powers of two, but a few others as well).
> > Ugh, yeah.  I've been doing a lot of gymnastics in this space because
> > frange's will have REAL_VALUE_TYPE endpoints.
> In our case we have instructions that can make of various FP constants,
> some of which may be negative.  So we need to be able to recognize those
> constants.  Leading to having to do similar gymnastics as what you're doing.

It seems real.* needs some minor TLC.  For one, a lot of these
functions should be inlined.  I suppose it wasn't meant to be abused
the way we're about to in range-op-float.cc :-).

Thanks.
Aldy


      reply	other threads:[~2022-08-26 16:38 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
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 [this message]

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=CAGm3qMVUtauWEkCgEjbk6CPsuTuGnJveO_NcOLW+HwRdvqTMbg@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).