提交 41602807 编写于 作者: J Joseph Myers 提交者: Richard Henderson

softfloat: fix floatx80 pseudo-denormal addition / subtraction

The softfloat function addFloatx80Sigs, used for addition of values
with the same sign and subtraction of values with opposite sign, fails
to handle the case where the two values both have biased exponent zero
and there is a carry resulting from adding the significands, which can
occur if one or both values are pseudo-denormals (biased exponent
zero, explicit integer bit 1).  Add a check for that case, so making
the results match those seen on x86 hardware for pseudo-denormals.
Signed-off-by: NJoseph Myers <joseph@codesourcery.com>
Message-Id: <alpine.DEB.2.21.2005042337570.22972@digraph.polyomino.org.uk>
Signed-off-by: NRichard Henderson <richard.henderson@linaro.org>
上级 7537c2b4
......@@ -5866,6 +5866,12 @@ static floatx80 addFloatx80Sigs(floatx80 a, floatx80 b, flag zSign,
zSig1 = 0;
zSig0 = aSig + bSig;
if ( aExp == 0 ) {
if ((aSig | bSig) & UINT64_C(0x8000000000000000) && zSig0 < aSig) {
/* At least one of the values is a pseudo-denormal,
* and there is a carry out of the result. */
zExp = 1;
goto shiftRight1;
}
if (zSig0 == 0) {
return packFloatx80(zSign, 0, 0);
}
......
/* Test pseudo-denormal operations. */
#include <stdint.h>
#include <stdio.h>
union u {
struct { uint64_t sig; uint16_t sign_exp; } s;
long double ld;
};
volatile union u ld_pseudo_m16382 = { .s = { UINT64_C(1) << 63, 0 } };
volatile long double ld_res;
int main(void)
{
int ret = 0;
ld_res = ld_pseudo_m16382.ld + ld_pseudo_m16382.ld;
if (ld_res != 0x1p-16381L) {
printf("FAIL: pseudo-denormal add\n");
ret = 1;
}
return ret;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册