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 <[email protected]> Sent: streda 16. októbra 2019 17:38 To: Matus Kysel <[email protected]>; [email protected] Cc: Peter Maydell <[email protected]>; Alex Bennée <[email protected]>; Aurelien Jarno <[email protected]> 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~
