Commit 053e913aad for qemu.org

commit 053e913aadbe1184e4be691883fea0ab38fd7888
Author: Max Chou <max.chou@sifive.com>
Date:   Thu Feb 26 15:18:14 2026 +0800

    fpu: Fix repacking issues in the uncanonical step for E4M3 overflow

    In the uncanonical step, the input FloatParts will be repacked to the
    target FloatFmt. This commit fixes following issues after calling
    uncanon_e4m3_overflow in the uncanon/uncanon_normal functions.

    - Add the local exp update after calling uncanon_e4m3_overflow in the
      parts_uncanon_normal function.
    - Add the fraction shift after calling uncanon_e4m3_overflow in the
      parts_uncanon function.

    Fixes: 27e989f99c ("fpu: Add conversion routines for OCP FP8 E4M3")
    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
    Reviewed-by: Chao Liu <chao.liu.zevorn@gmail.com>
    Signed-off-by: Max Chou <max.chou@sifive.com>
    Message-ID: <20260226071817.1417875-2-max.chou@sifive.com>
    Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index 61b07307bf..a738758aee 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -387,6 +387,7 @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s,
             case float_expmax_e4m3:
                 if (exp > exp_max || p->frac_hi > E4M3_NORMAL_FRAC_MAX) {
                     partsN(uncanon_e4m3_overflow)(p, s, fmt, overflow_norm);
+                    exp = p->exp;
                 }
                 break;

@@ -496,6 +497,7 @@ static void partsN(uncanon)(FloatPartsN *p, float_status *s,
                 break;
             case float_expmax_e4m3:
                 partsN(uncanon_e4m3_overflow)(p, s, fmt, saturate);
+                frac_shr(p, fmt->frac_shift);
                 break;
             case float_expmax_normal:
             default: