[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH] Added hardfloat conversion from float32 to float64
From: |
Matus Kysel |
Subject: |
RE: [PATCH] Added hardfloat conversion from float32 to float64 |
Date: |
Wed, 30 Oct 2019 08:42:59 +0000 |
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 <address@hidden>
Sent: streda 16. októbra 2019 17:38
To: Matus Kysel <address@hidden>; address@hidden
Cc: Peter Maydell <address@hidden>; Alex Bennée <address@hidden>; Aurelien
Jarno <address@hidden>
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~