On Wed, 20 May 2026 at 19:20, Peter Maydell <[email protected]> wrote:
>
> On Wed, 20 May 2026 at 18:18, Richard Henderson
> <[email protected]> wrote:
> >
> > There is only one NaN fractional encoding for E4M3. Retain the
> > incoming sign, but force the outgoing fraction to the unique value.
> >
> > Reported-by: Peter Maydell <[email protected]>
> > Signed-off-by: Richard Henderson <[email protected]>
> > @@ -507,10 +512,24 @@ static void partsN(uncanon)(FloatPartsN *p,
> > float_status *s,
> > return;
> > case float_class_qnan:
> > case float_class_snan:
> > - assert(fmt->exp_max_kind != float_expmax_normal);
> > p->exp = fmt->exp_max;
> > - fracN(shr)(p, fmt->frac_shift);
> > - return;
> > + switch (fmt->exp_max_kind) {
> > + case float_expmax_e4m3:
> > + /*
> > + * There is only one NaN encoding for E4M3, and with a
> > + * conversion from another format, the input NaN fraction
> > + * may not apply.
> > + */
> > + assert(N == 64);
> > + p->frac_hi = E4M3_NAN_FRAC;
> > + /* fall through */
> > + case float_expmax_ieee:
> > + fracN(shr)(p, fmt->frac_shift);
> > + return;
> > + case float_expmax_normal:
>
> We used to assert() that exp_max_kind wasn't "expmax_normal",
> but now we don't. What does it mean to have a FloatPartsN that
> says it's a NaN when the format says there isn't a NaN
> representation ? Either way, the "break" here means we
> won't treat it like we do NaNs and we won't treat it
> like we do normals either...
>
> > + break;
> > + }
> > + g_assert_not_reached();
...ah, I misread it. I think it would be clearer to
have the float_expmax_normal case be "g_assert_not_reached()"
rather than "break, and rely on the thing immediately next
after the switch to be g_assert_not_reached()", because
it more obviously says "this case can't occur".
-- PMM