qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Matus Kysel <mkysel@tachyum.com>
To: Richard Henderson <richard.henderson@linaro.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Aurelien Jarno" <aurelien@aurel32.net>
Subject: RE: [PATCH] Added hardfloat conversion from float32 to float64
Date: Wed, 30 Oct 2019 08:42:59 +0000	[thread overview]
Message-ID: <507d38e8542842b983d097cf83ff4fc8@tachyum.com> (raw)
In-Reply-To: <34960708-32a9-53d6-a719-fa98b8be517c@linaro.org>

Hi,

I have send patch v2 with proposed changes, please have a look https://lists.nongnu.org/archive/html/qemu-devel/2019-10/msg04264.html

Matus

-----Original Message-----
From: Richard Henderson <richard.henderson@linaro.org> 
Sent: streda 16. októbra 2019 17:38
To: Matus Kysel <mkysel@tachyum.com>; qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>; Alex Bennée <alex.bennee@linaro.org>; Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [PATCH] Added hardfloat conversion from float32 to float64

On 10/16/19 12:32 AM, Matus Kysel wrote:
> +float64 float32_to_float64(float32 a, float_status *status) {
> +    if (unlikely(!float32_is_normal(a))) {
> +        return soft_float32_to_float64(a, status);
> +    } else if (float32_is_zero(a)) {
> +        return float64_set_sign(float64_zero, float32_is_neg(a));
> +    } else {
> +        double r = *(float *)&a;
> +        return *(float64 *)&r;
> +    }
> +}

This is a good idea, since there are no issues with inexact or rounding when converting in this direction.

Please use union_float{32,64} instead of casting.

Your special case for 0 won't fire, since it is already filtered by !float32_is_normal.

So I think this could be written as

    if (likely(float32_is_normal(a))) {
        union_float32 uf;
        union_float64 ud;

        uf.s = a;
        ud.h = uf.h;
        return ud.s;
    } else if (float32_is_zero(a)) {
        return float64_set_sign(float64_zero, float32_is_neg(a));
    } else {
        return soft_float32_to_float64(a);
    }


r~

  reply	other threads:[~2019-10-30  8:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16  7:32 [PATCH] Added hardfloat conversion from float32 to float64 Matus Kysel
2019-10-16 15:38 ` Richard Henderson
2019-10-30  8:42   ` Matus Kysel [this message]
2019-10-16 16:59 ` no-reply

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=507d38e8542842b983d097cf83ff4fc8@tachyum.com \
    --to=mkysel@tachyum.com \
    --cc=alex.bennee@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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 NNTP newsgroup(s).