Index: src/crankshaft/mips64/lithium-codegen-mips64.cc |
diff --git a/src/crankshaft/mips64/lithium-codegen-mips64.cc b/src/crankshaft/mips64/lithium-codegen-mips64.cc |
index 55499973150c88d3fee8e48b645ef1981d3d7bec..972d50dfd0539a2df31db59fb7cc00fec8322e85 100644 |
--- a/src/crankshaft/mips64/lithium-codegen-mips64.cc |
+++ b/src/crankshaft/mips64/lithium-codegen-mips64.cc |
@@ -1846,13 +1846,13 @@ void LCodeGen::DoMathMinMax(LMathMinMax* instr) { |
LOperand* left = instr->left(); |
LOperand* right = instr->right(); |
HMathMinMax::Operation operation = instr->hydrogen()->operation(); |
- Condition condition = (operation == HMathMinMax::kMathMin) ? le : ge; |
+ Register scratch = scratch1(); |
if (instr->hydrogen()->representation().IsSmiOrInteger32()) { |
+ Condition condition = (operation == HMathMinMax::kMathMin) ? le : ge; |
Register left_reg = ToRegister(left); |
Register right_reg = EmitLoadRegister(right, scratch0()); |
Register result_reg = ToRegister(instr->result()); |
Label return_right, done; |
- Register scratch = scratch1(); |
__ Slt(scratch, left_reg, Operand(right_reg)); |
if (condition == ge) { |
__ Movz(result_reg, left_reg, scratch); |
@@ -1867,43 +1867,19 @@ void LCodeGen::DoMathMinMax(LMathMinMax* instr) { |
FPURegister left_reg = ToDoubleRegister(left); |
FPURegister right_reg = ToDoubleRegister(right); |
FPURegister result_reg = ToDoubleRegister(instr->result()); |
- Label check_nan_left, check_zero, return_left, return_right, done; |
- __ BranchF(&check_zero, &check_nan_left, eq, left_reg, right_reg); |
- __ BranchF(&return_left, NULL, condition, left_reg, right_reg); |
- __ Branch(&return_right); |
- |
- __ bind(&check_zero); |
- // left == right != 0. |
- __ BranchF(&return_left, NULL, ne, left_reg, kDoubleRegZero); |
- // At this point, both left and right are either 0 or -0. |
- if (operation == HMathMinMax::kMathMin) { |
- // The algorithm is: -((-L) + (-R)), which in case of L and R being |
- // different registers is most efficiently expressed as -((-L) - R). |
- __ neg_d(left_reg, left_reg); |
- if (left_reg.is(right_reg)) { |
- __ add_d(result_reg, left_reg, right_reg); |
- } else { |
- __ sub_d(result_reg, left_reg, right_reg); |
- } |
- __ neg_d(result_reg, result_reg); |
+ Label nan, done; |
+ if (operation == HMathMinMax::kMathMax) { |
+ __ MaxNaNCheck_d(result_reg, left_reg, right_reg, &nan); |
} else { |
- __ add_d(result_reg, left_reg, right_reg); |
+ DCHECK(operation == HMathMinMax::kMathMin); |
+ __ MinNaNCheck_d(result_reg, left_reg, right_reg, &nan); |
} |
__ Branch(&done); |
- __ bind(&check_nan_left); |
- // left == NaN. |
- __ BranchF(NULL, &return_left, eq, left_reg, left_reg); |
- __ bind(&return_right); |
- if (!right_reg.is(result_reg)) { |
- __ mov_d(result_reg, right_reg); |
- } |
- __ Branch(&done); |
+ __ bind(&nan); |
+ __ LoadRoot(scratch, Heap::kNanValueRootIndex); |
+ __ ldc1(result_reg, FieldMemOperand(scratch, HeapNumber::kValueOffset)); |
- __ bind(&return_left); |
- if (!left_reg.is(result_reg)) { |
- __ mov_d(result_reg, left_reg); |
- } |
__ bind(&done); |
} |
} |