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>
This commit is contained in:
Max Chou
2026-02-26 15:18:14 +08:00
committed by Alistair Francis
parent f2af8f0d5d
commit 053e913aad

View File

@@ -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: