On 5/19/26 06:41, Peter Maydell wrote:
+static void fp8_mul_finish(CPUARMState *env, FP8MulContext *c)
+{
+ /*
+ * FP8 multiplies don't update FPSR.{IDC,IOC,IXC,UFC}.
+ * Since this is multiply-add, DZC does not apply and only OFC remains.
+ */
+ fp8_finish_fpst(&env->vfp.fp_status[FPST_A64], &c->stat,
+ float_flag_overflow);
Looking at the A1.5.5 text a bit more carefully I don't think
we should propagate OFC either for FP8 mul:
"When the rounded result with unbounded exponent has an absolute value that
is greater than the maximum normalized number for the output precision:
— Generate one of the following outputs with the sign of the result:
— When FPMR.OSM is 1, the maximum normalized number.
— When FPMR.OSM is 0, an Infinity.
— Do not update FPSR.OFC. "
Huh. What an odd way to define things. AFAICS, this means no exception bits are updated
at all. Why not just say that.
Also, I realized that this squashing mechanic means we can't do
the handling of invalid input formats the way we do at the moment.
The float_raise() operations done by fp8_invalid_input() will
get squashed for multiplies. I think the fp8_invalid_output() part
is still OK because we only use it in the FP8 convert operations.
We could perhaps have fp8_mul_start() explicitly check for fmt1
or fmt2 being fp8_invalid_input -- it has access to the real
fp_status so can raise Invalid and InvalidSNaN there.
Here's the thing:
FP8Unpack doesn't raise an exception itself, just sets fptype = FPType_SNaN.
For FP8ConvertFP, we then explicitly raise invalid and return default nan.
For FP8DotAddFP, we notice nans within a loop, setting any_nan; after the loop, if any_nan
is set, we return default nan but do not raise invalid.
So I guess we don't need to do anything special during fp8_mul_start.
One thing I could do that might be slightly clearer is
static FloatParts64 fp8_invalid_input(uint8_t x, float_status *s)
{
/*
* Invalid input format is treated as snan, then one of the uses
* will convert to default nan and raise invalid.
*/
return (FloatParts64){ .cls = float_class_snan };
}
What do you think?
r~