[mips] Fix floating-point rounding ops

The RoundFloat/RoundDouble functions should return the Canonical
NaN if the input is a NaN.

Change-Id: I19928a8a3d78770757c6fe2e240254efe9944bdc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2475493
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70530}
This commit is contained in:
Zhao Jiazhong 2020-10-15 06:41:50 -04:00 committed by Commit Bot
parent 10dbddd1e8
commit a58de79c4f
2 changed files with 6 additions and 3 deletions

View File

@ -2091,7 +2091,8 @@ void TurboAssembler::RoundFloat(FPURegister dst, FPURegister src,
Ext(at, scratch, kFloat32MantissaBits, kFloat32ExponentBits);
Branch(USE_DELAY_SLOT, &done, hs, at,
Operand(kFloat32ExponentBias + kFloat32MantissaBits));
mov_s(dst, src);
// Canonicalize the result.
sub_s(dst, src, kDoubleRegZero);
round(this, dst, src);
mfc1(at, dst);
Branch(USE_DELAY_SLOT, &done, ne, at, Operand(zero_reg));

View File

@ -2513,7 +2513,8 @@ void TurboAssembler::RoundDouble(FPURegister dst, FPURegister src,
Ext(at, scratch, HeapNumber::kExponentShift, HeapNumber::kExponentBits);
Branch(USE_DELAY_SLOT, &done, hs, at,
Operand(HeapNumber::kExponentBias + HeapNumber::kMantissaBits));
mov_d(dst, src);
// Canonicalize the result.
sub_d(dst, src, kDoubleRegZero);
round(this, dst, src);
dmfc1(at, dst);
Branch(USE_DELAY_SLOT, &done, ne, at, Operand(zero_reg));
@ -2573,7 +2574,8 @@ void TurboAssembler::RoundFloat(FPURegister dst, FPURegister src,
Ext(at, scratch, kFloat32MantissaBits, kFloat32ExponentBits);
Branch(USE_DELAY_SLOT, &done, hs, at,
Operand(kFloat32ExponentBias + kFloat32MantissaBits));
mov_s(dst, src);
// Canonicalize the result.
sub_s(dst, src, kDoubleRegZero);
round(this, dst, src);
mfc1(at, dst);
Branch(USE_DELAY_SLOT, &done, ne, at, Operand(zero_reg));