target/i386: Do not raise Invalid for 0 * Inf + QNaN
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 16 Jan 2025 11:25:35 +0000 (11:25 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 7 Feb 2025 14:51:01 +0000 (15:51 +0100)
commit2b3bfbb21b08bfd9aa49b665b66851e9ebf62802
treeb5b8b1f6be228b438ac764d229f3db018efc7c1a
parent6b03c038067f2171110425593f722df8f4d19d17
target/i386: Do not raise Invalid for 0 * Inf + QNaN

In commit 8adcff4ae7 ("fpu: handle raising Invalid for infzero in
pick_nan_muladd") we changed the handling of 0 * Inf + QNaN to always
raise the Invalid exception regardless of target architecture.  (This
was a change affecting hppa, i386, sh4 and tricore.) However, this
was incorrect for i386, which documents in the SDM section 14.5.2
that for the 0 * Inf + NaN case that it will only raise the Invalid
exception when the input is an SNaN.  (This is permitted by the IEEE
754-2008 specification, which documents that whether we raise Invalid
for 0 * Inf + QNaN is implementation defined.)

Adjust the softfloat pick_nan_muladd code to allow the target to
suppress the raising of Invalid for the inf * zero + NaN case (as an
extra flag orthogonal to its choice for when to use the default NaN),
and enable that for x86.

We do not revert here the behaviour change for hppa, sh4 or tricore:
 * The sh4 manual is clear that it should signal Invalid
 * The tricore manual is a bit vague but doesn't say it shouldn't
 * The hppa manual doesn't talk about fused multiply-add corner
   cases at all

Cc: qemu-stable@nongnu.org
Fixes: 8adcff4ae7 (""fpu: handle raising Invalid for infzero in pick_nan_muladd")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Link: https://lore.kernel.org/r/20250116112536.4117889-2-peter.maydell@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
fpu/softfloat-parts.c.inc
include/fpu/softfloat-types.h
target/i386/tcg/fpu_helper.c