public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Jeff Law <jeffreyalaw@gmail.com>
Cc: Andreas Schwab <schwab@suse.de>,
	Jonathan Wakely <jwakely@redhat.com>,
	libstdc++@gcc.gnu.org,  gcc-patches@gcc.gnu.org
Subject: Re: [PATCH][risc-v] libstdc++: Preserve signbit of nan when converting float to double [PR113578]
Date: Tue, 7 May 2024 17:45:56 +0100	[thread overview]
Message-ID: <CAH6eHdSm=tfUKyrpX1KOOoAFk4kFp1sbi51FEr7GwJvS4AtBcQ@mail.gmail.com> (raw)
In-Reply-To: <CAH6eHdTx-QdmcNvxEVQPSEM3wcKz98-prpzo3LZz8DyJGp3-jA@mail.gmail.com>

On Tue, 7 May 2024 at 17:39, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>
> On Tue, 7 May 2024 at 17:33, Jeff Law wrote:
> >
> >
> >
> > On 5/7/24 9:36 AM, Andreas Schwab wrote:
> > > On Mai 07 2024, Jonathan Wakely wrote:
> > >
> > >> +#ifdef __riscv
> > >> +    return _M_insert(__builtin_copysign((double)__f,
> > >> +                                        (double)-__builtin_signbit(__f));
> > >
> > > Should this use static_cast<double>?
>
> Meh. It wouldn't fit in 80 columns any more with static_cast, and it
> means exactly the same thing.
>
> > And it's missing a close paren.
>
> Now that's more important! Thanks.

Also, I've just realised that signbit might return a negative value if
the signbit is set. The spec only says it returns non-zero if the
signbit is set.

So maybe we want:

#ifdef __riscv
        const int __neg = __builtin_signbit(__f) ? -1 : 0;
        return _M_insert(__builtin_copysign(static_cast<double>(__f),
                                              static_cast<double>(__neg)));
#else
        return _M_insert(static_cast<double>(__f));
#endif

  reply	other threads:[~2024-05-07 16:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-07 13:49 Jonathan Wakely
2024-05-07 13:57 ` Jeff Law
2024-05-07 14:06   ` Jonathan Wakely
2024-05-07 14:11     ` Jonathan Wakely
2024-05-07 16:24       ` Palmer Dabbelt
2024-05-10 10:58       ` Jonathan Wakely
2024-05-07 15:25     ` Jeff Law
2024-05-07 15:36 ` Andreas Schwab
2024-05-07 16:31   ` Jeff Law
2024-05-07 16:39     ` Jonathan Wakely
2024-05-07 16:45       ` Jonathan Wakely [this message]
2024-05-08 10:32         ` Andrew Waterman
2024-05-08 10:40           ` Jonathan Wakely

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='CAH6eHdSm=tfUKyrpX1KOOoAFk4kFp1sbi51FEr7GwJvS4AtBcQ@mail.gmail.com' \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    --cc=schwab@suse.de \
    /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).