mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-25 05:06:46 +00: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. Backports commit ce8d4082054519f2eaac39958edde502860a7fc6 from qemu
This commit is contained in:
parent
af6a0b7c14
commit
76e343ef55
|
@ -1878,6 +1878,12 @@ static FloatParts scalbn_decomposed(FloatParts a, int n, float_status *s)
|
|||
return return_nan(a, s);
|
||||
}
|
||||
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;
|
||||
}
|
||||
return a;
|
||||
|
|
Loading…
Reference in a new issue