mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-10 19:14:58 -06:00
fpu: Bound increment for scalbn
Without bounding the increment, we can overflow exp either here in scalbn_decomposed or when adding the bias in round_canonical. This can result in e.g. underflowing to 0 instead of overflowing to infinity. The old softfloat code did bound the increment. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Tested-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
1b2503fcf7
commit
ce8d408205
1 changed files with 6 additions and 0 deletions
|
@ -1878,6 +1878,12 @@ static FloatParts scalbn_decomposed(FloatParts a, int n, float_status *s)
|
||||||
return return_nan(a, s);
|
return return_nan(a, s);
|
||||||
}
|
}
|
||||||
if (a.cls == float_class_normal) {
|
if (a.cls == float_class_normal) {
|
||||||
|
/* The largest float type (even though not supported by FloatParts)
|
||||||
|
* is float128, which has a 15 bit exponent. Bounding N to 16 bits
|
||||||
|
* still allows rounding to infinity, without allowing overflow
|
||||||
|
* within the int32_t that backs FloatParts.exp.
|
||||||
|
*/
|
||||||
|
n = MIN(MAX(n, -0x10000), 0x10000);
|
||||||
a.exp += n;
|
a.exp += n;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue