Index: src/mips/macro-assembler-mips.cc |
diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc |
index 3b8d8b1772a2eb40a3807549c01e371cd6542ee9..83436ee4aa14ac81868accab9d78e1175fe79bc8 100644 |
--- a/src/mips/macro-assembler-mips.cc |
+++ b/src/mips/macro-assembler-mips.cc |
@@ -5493,11 +5493,14 @@ void MacroAssembler::AddBranchOvf(Register dst, Register left, Register right, |
DCHECK(!right.is(scratch)); |
if (left.is(right) && dst.is(left)) { |
- mov(overflow_dst, right); |
- right = overflow_dst; |
- } |
- |
- if (dst.is(left)) { |
+ mov(scratch, left); // Preserve left and right. |
+ addu(dst, left, right); // Both are overwritten. |
+ xor_(overflow_dst, dst, scratch); // Left and right are equal. |
+ Label done; // Restore inputs if overflow. |
+ Branch(&done, ge, overflow_dst, Operand(zero_reg)); |
+ mov(left, scratch); // Original left and right. |
+ bind(&done); |
+ } else if (dst.is(left)) { |
mov(scratch, left); // Preserve left. |
addu(dst, left, right); // Left is overwritten. |
xor_(scratch, dst, scratch); // Original left. |