summary refs log tree commit diff stats
path: root/fpu
diff options
context:
space:
mode:
authorMatus Kysel <mkysel@tachyum.com>2019-10-17 16:21:33 +0200
committerRichard Henderson <richard.henderson@linaro.org>2019-10-30 19:03:37 +0100
commit21381dcf0ca8fc822328e30570c8465ec4e52be9 (patch)
tree65e6a2231d65b5d80a64d6c9937d32e56cd36601 /fpu
parent16884391c750d0c5e863f55ad7aaaa146fc5181e (diff)
downloadfocaccia-qemu-21381dcf0ca8fc822328e30570c8465ec4e52be9.tar.gz
focaccia-qemu-21381dcf0ca8fc822328e30570c8465ec4e52be9.zip
softfp: Added hardfloat conversion from float32 to float64
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

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matus Kysel <mkysel@tachyum.com>
Message-Id: <20191017142133.59439-1-mkysel@tachyum.com>
[rth: Add comment about impossible inexact exceptions.]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'fpu')
-rw-r--r--fpu/softfloat.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 0638c9f4e0..301ce3b537 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 *s)
+{
+    if (likely(float32_is_normal(a))) {
+        /* Widening conversion can never produce inexact results.  */
+        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, s);
+    }
+}
+
 float16 float64_to_float16(float64 a, bool ieee, float_status *s)
 {
     const FloatFmt *fmt16 = ieee ? &float16_params : &float16_params_ahp;