@samitouri / QOSamiQemu / commits / 9d090fe440

fpu: Fix unexpected exception flags when converting infinity to OCP E4M3

Infinity is a special case distinct from numeric overflow: - Numeric overflow: finite value exceeds format's max normal -> overflow|inexact - Infinity conversion: input is already infinite -> no flags This commit fixes the unexpect exception flags by relocating the float exception flag update flow to be outside the uncanon_e4m3_overflow. And raising the overflow|inexact for numeric overflow in uncanon_normal. Fixes: 27e989f99c ("fpu: Add conversion routines for OCP FP8 E4M3") Reviewed-by: Chao Liu <chao.liu.zevorn@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Max Chou <max.chou@sifive.com> Message-ID: <20260226071817.1417875-3-max.chou@sifive.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Max Chou committed Feb 26, 2026 at 15:18 UTC 9d090fe440435eebcd5e0a058f164e8cfe29451b
1 file changed +1 -1
fpu/softfloat-parts.c.inc
+1 -1
@@ -277,7 +277,6 @@ static void partsN(uncanon_e4m3_overflow)(FloatPartsN *p, float_status *s,
277 const FloatFmt *fmt, bool saturate)
278 {
279 assert(N == 64);
280 - float_raise(float_flag_overflow | float_flag_inexact, s);
280 if (saturate) {
281 p->exp = fmt->exp_max;
282 p->frac_hi = E4M3_NORMAL_FRAC_MAX;
@@ -388,6 +387,7 @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s,
387 if (exp > exp_max || p->frac_hi > E4M3_NORMAL_FRAC_MAX) {
388 partsN(uncanon_e4m3_overflow)(p, s, fmt, overflow_norm);
389 exp = p->exp;
390 + flags |= (float_flag_overflow | float_flag_inexact);
391 }
392 break;
393