Skip to contentSkip to conversation

target/arm: Use float_round_to_odd in helper_fcvtx_f64_to_f32

PATCH Applied Richard Henderson 2 participants 2 messages Dec 6, 2024 – Dec 13, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm: Use float_round_to_odd in helper_fcvtx_f64_to_f32

Softfloat has native support for round-to-odd. Use it.

---
 target/arm/tcg/helper-a64.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
target/arm/tcg/helper-a64.c +4 -14
index 1daf3f27c0..ff48bac1a8 100644
@@ -386,23 +386,13 @@ float64 HELPER(frecpx_f64)(float64 a, float_status *fpst)
 
 float32 HELPER(fcvtx_f64_to_f32)(float64 a, CPUARMState *env)
 {
-    /* Von Neumann rounding is implemented by using round-to-zero
-     * and then setting the LSB of the result if Inexact was raised.
-     */
     float32 r;
     float_status *fpst = &env->vfp.fp_status;
-    float_status tstat = *fpst;
-    int exflags;
+    int old = get_float_rounding_mode(fpst);
 
-    set_float_rounding_mode(float_round_to_zero, &tstat);
-    set_float_exception_flags(0, &tstat);
-    r = float64_to_float32(a, &tstat);
-    exflags = get_float_exception_flags(&tstat);
-    if (exflags & float_flag_inexact) {
-        r = make_float32(float32_val(r) | 1);
-    }
-    exflags |= get_float_exception_flags(fpst);
-    set_float_exception_flags(exflags, fpst);
+    set_float_rounding_mode(float_round_to_odd, fpst);
+    r = float64_to_float32(a, fpst);
+    set_float_rounding_mode(old, fpst);
     return r;
 }
 
Signature · 1 line
2.43.0