Index: src/mips64/macro-assembler-mips64.cc |
diff --git a/src/mips64/macro-assembler-mips64.cc b/src/mips64/macro-assembler-mips64.cc |
index 8dcd9d6c065739600ebaeafbe9f8bb45e042ea50..40c35c0092af5cb3f033e2474eadfde93d8846a8 100644 |
--- a/src/mips64/macro-assembler-mips64.cc |
+++ b/src/mips64/macro-assembler-mips64.cc |
@@ -1706,6 +1706,7 @@ void MacroAssembler::Trunc_ul_d(FPURegister fd, Register rs, |
if (result.is_valid()) { |
mov(result, zero_reg); |
Move(kDoubleRegZero, 0.0); |
+ // If fd < 0 or unordered, then the conversion fails. |
BranchF(&fail, &fail, lt, fd, kDoubleRegZero); |
} |
@@ -1715,8 +1716,7 @@ void MacroAssembler::Trunc_ul_d(FPURegister fd, Register rs, |
// Test if scratch > fd. |
// If fd < 2^63 we can convert it normally. |
- // If fd is unordered the conversion fails. |
- BranchF(&simple_convert, &fail, lt, fd, scratch); |
+ BranchF(&simple_convert, nullptr, lt, fd, scratch); |
// First we subtract 2^63 from fd, then trunc it to rs |
// and add 2^63 to rs. |
@@ -1733,9 +1733,12 @@ void MacroAssembler::Trunc_ul_d(FPURegister fd, Register rs, |
bind(&done); |
if (result.is_valid()) { |
- // Conversion is failed if the result is negative or unordered. |
- BranchF(&fail, &fail, lt, scratch, kDoubleRegZero); |
- li(result, Operand(1)); |
+ // Conversion is failed if the result is negative. |
+ addiu(at, zero_reg, -1); |
+ dsrl(at, at, 1); // Load 2^62. |
+ dmfc1(result, scratch); |
+ xor_(result, result, at); |
+ Slt(result, zero_reg, result); |
} |
bind(&fail); |
@@ -1761,7 +1764,6 @@ void MacroAssembler::Trunc_ul_s(FPURegister fd, Register rs, |
// Test if scratch > fd. |
// If fd < 2^63 we can convert it normally. |
- // // If fd is unordered the conversion fails. |
BranchF32(&simple_convert, nullptr, lt, fd, scratch); |
// First we subtract 2^63 from fd, then trunc it to rs |
@@ -1780,8 +1782,11 @@ void MacroAssembler::Trunc_ul_s(FPURegister fd, Register rs, |
bind(&done); |
if (result.is_valid()) { |
// Conversion is failed if the result is negative or unordered. |
- BranchF(&fail, &fail, lt, scratch, kDoubleRegZero); |
- li(result, Operand(1)); |
+ addiu(at, zero_reg, -1); |
+ dsrl(at, at, 1); // Load 2^62. |
+ dmfc1(result, scratch); |
+ xor_(result, result, at); |
+ Slt(result, zero_reg, result); |
} |
bind(&fail); |