fpu/softfloat: Replace float_class_dnan with parts_default_nan

With a canonical representation of NaNs, we can return the
default nan directly rather than delay the expansion until
the final format is known.

Note one case where we uselessly assigned to a.sign, which was
overwritten/ignored later when expanding float_class_dnan.

Tested-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2018-05-10 13:09:49 -07:00
parent 298b468e43
commit f7e598e264
2 changed files with 48 additions and 27 deletions

View file

@ -101,6 +101,43 @@ static bool parts_is_snan_frac(uint64_t frac, float_status *status)
#endif
}
/*----------------------------------------------------------------------------
| The pattern for a default generated deconstructed floating-point NaN.
*----------------------------------------------------------------------------*/
static FloatParts parts_default_nan(float_status *status)
{
bool sign = 0;
uint64_t frac;
#if defined(TARGET_SPARC) || defined(TARGET_M68K)
frac = (1ULL << DECOMPOSED_BINARY_POINT) - 1;
#elif defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA) || \
defined(TARGET_S390X) || defined(TARGET_RISCV)
frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1);
#elif defined(TARGET_HPPA)
frac = 1ULL << (DECOMPOSED_BINARY_POINT - 2);
#else
if (status->snan_bit_is_one) {
frac = (1ULL << (DECOMPOSED_BINARY_POINT - 1)) - 1;
} else {
#if defined(TARGET_MIPS)
frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1);
#else
frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1);
sign = 1;
#endif
}
#endif
return (FloatParts) {
.cls = float_class_qnan,
.sign = sign,
.exp = INT_MAX,
.frac = frac
};
}
/*----------------------------------------------------------------------------
| The pattern for a default generated half-precision NaN.
*----------------------------------------------------------------------------*/