mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-22 09:32:40 -06:00
fpu: Check for default_nan_mode before calling pickNaNMulAdd
If the target sets default_nan_mode then we're always going to return the default NaN, and pickNaNMulAdd() no longer has any side effects. For consistency with pickNaN(), check for default_nan_mode before calling pickNaNMulAdd(). When we convert pickNaNMulAdd() to allow runtime selection of the NaN propagation rule, this means we won't have to make the targets which use default_nan_mode also set a propagation rule. Since RiscV always uses default_nan_mode, this allows us to remove its ifdef case from pickNaNMulAdd(). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20241202131347.498124-3-peter.maydell@linaro.org
This commit is contained in:
parent
8adcff4ae7
commit
ed885e3069
2 changed files with 13 additions and 4 deletions
|
@ -77,9 +77,13 @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
|
||||||
float_raise(float_flag_invalid | float_flag_invalid_imz, s);
|
float_raise(float_flag_invalid | float_flag_invalid_imz, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s->default_nan_mode) {
|
||||||
|
which = 3;
|
||||||
|
} else {
|
||||||
which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s);
|
which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s);
|
||||||
|
}
|
||||||
|
|
||||||
if (s->default_nan_mode || which == 3) {
|
if (which == 3) {
|
||||||
parts_default_nan(a, s);
|
parts_default_nan(a, s);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,6 +475,13 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
|
||||||
static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
|
static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
|
||||||
bool infzero, float_status *status)
|
bool infzero, float_status *status)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* We guarantee not to require the target to tell us how to
|
||||||
|
* pick a NaN if we're always returning the default NaN.
|
||||||
|
* But if we're not in default-NaN mode then the target must
|
||||||
|
* specify.
|
||||||
|
*/
|
||||||
|
assert(!status->default_nan_mode);
|
||||||
#if defined(TARGET_ARM)
|
#if defined(TARGET_ARM)
|
||||||
/* For ARM, the (inf,zero,qnan) case sets InvalidOp and returns
|
/* For ARM, the (inf,zero,qnan) case sets InvalidOp and returns
|
||||||
* the default NaN
|
* the default NaN
|
||||||
|
@ -578,8 +585,6 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#elif defined(TARGET_RISCV)
|
|
||||||
return 3; /* default NaN */
|
|
||||||
#elif defined(TARGET_S390X)
|
#elif defined(TARGET_S390X)
|
||||||
if (infzero) {
|
if (infzero) {
|
||||||
return 3;
|
return 3;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue