[PATCH v2] Added hardfloat conversion from float32 to float64

Matus Kysel posted 1 patch 4 years, 6 months ago
Test FreeBSD passed
Test asan passed
Test checkpatch passed
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
Test docker-clang@ubuntu passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20191017142133.59439-1-mkysel@tachyum.com
Maintainers: Aurelien Jarno <aurelien@aurel32.net>, Peter Maydell <peter.maydell@linaro.org>, "Alex Bennée" <alex.bennee@linaro.org>
fpu/softfloat.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
[PATCH v2] Added hardfloat conversion from float32 to float64
Posted by Matus Kysel 4 years, 6 months ago
Reintroduce float32_to_float64 that was removed here:
https://lists.gnu.org/archive/html/qemu-devel/2018-04/msg00455.html

 - nbench test it not actually calling this function at all
 - SPECS 2006 significat number of tests impoved their runtime, just
   few of them showed small slowdown

Signed-off-by: Matus Kysel <mkysel@tachyum.com>
---
 fpu/softfloat.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 0638c9f4e0..4bc7c38668 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -1920,13 +1920,30 @@ float16 float32_to_float16(float32 a, bool ieee, float_status *s)
     return float16a_round_pack_canonical(pr, s, fmt16);
 }
 
-float64 float32_to_float64(float32 a, float_status *s)
+static float64 QEMU_SOFTFLOAT_ATTR
+soft_float32_to_float64(float32 a, float_status * s)
 {
     FloatParts p = float32_unpack_canonical(a, s);
     FloatParts pr = float_to_float(p, &float64_params, s);
     return float64_round_pack_canonical(pr, s);
 }
 
+float64 float32_to_float64(float32 a, float_status * status)
+{
+    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, status);
+    }
+}
+
 float16 float64_to_float16(float64 a, bool ieee, float_status *s)
 {
     const FloatFmt *fmt16 = ieee ? &float16_params : &float16_params_ahp;
-- 
2.17.1


Re: [PATCH v2] Added hardfloat conversion from float32 to float64
Posted by Richard Henderson 4 years, 6 months ago
On 10/17/19 4:21 PM, Matus Kysel wrote:
> Reintroduce float32_to_float64 that was removed here:
> https://lists.gnu.org/archive/html/qemu-devel/2018-04/msg00455.html
> 
>  - nbench test it not actually calling this function at all
>  - SPECS 2006 significat number of tests impoved their runtime, just
>    few of them showed small slowdown
> 
> Signed-off-by: Matus Kysel <mkysel@tachyum.com>
> ---
>  fpu/softfloat.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Queued.


r~