On Fri, 24 Jan 2025 at 17:15, Alex Bennée <alex.ben...@linaro.org> wrote: > > Peter Maydell <peter.mayd...@linaro.org> writes: > > > Add a test case which tests some corner case behaviour of > > fused-multiply-add on x86: > > * 0 * Inf + SNaN should raise Invalid > > * 0 * Inf + QNaN shouldh not raise Invalid > > * tininess should be detected after rounding
> > +static testdata tests[] = { > > + { 0, 0x7ff0000000000000, 0x7ff000000000aaaa, false, /* 0 * Inf + SNaN > > */ > > + 0x7ff800000000aaaa, 1 }, /* Should be QNaN and does raise Invalid */ > > + { 0, 0x7ff0000000000000, 0x7ff800000000aaaa, false, /* 0 * Inf + QNaN > > */ > > + 0x7ff800000000aaaa, 0 }, /* Should be QNaN and does *not* raise > > Invalid */ > > + /* > > + * These inputs give a result which is tiny before rounding but which > > + * becomes non-tiny after rounding. x86 is a "detect tininess after > > + * rounding" architecture, so it should give a non-denormal result and > > + * not set the Underflow flag (only the Precision flag for an inexact > > + * result). > > + */ > > + { 0x3fdfffffffffffff, 0x001fffffffffffff, 0x801fffffffffffff, false, > > + 0x8010000000000000, 0x20 }, > > + /* > > + * Flushing of denormal outputs to zero should also happen after > > + * rounding, so setting FTZ should not affect the result or the flags. > > + * QEMU currently does not emulate this correctly because we do the > > + * flush-to-zero check before rounding, so we incorrectly produce a > > + * zero result and set Underflow as well as Precision. > > + */ > > +#ifdef ENABLE_FAILING_TESTS > > + { 0x3fdfffffffffffff, 0x001fffffffffffff, 0x801fffffffffffff, true, > > + 0x8010000000000000, 0x20 }, /* Enabling FTZ shouldn't change flags */ > > +#endif > > We could extend the multiarch/float_madds test to handle doubles as well > (or create a new multiarch test). This test case is specifically testing a corner case of x86 semantics -- on Arm, for instance, you would not get the same result/flags, because Arm does tininess and flushing-of-denormal before rounding, and Arm does raise Invalid for 0 * Inf + QNaN. So I'm not sure that a multiarch test would be possible. -- PMM