Index: src/crankshaft/mips/lithium-codegen-mips.cc |
diff --git a/src/crankshaft/mips/lithium-codegen-mips.cc b/src/crankshaft/mips/lithium-codegen-mips.cc |
index 0bcf64a74a95d93606977a3a23f541262f81a4ab..33c9afa9e2cffe6f78ea9b9b8fdba8458304c29c 100644 |
--- a/src/crankshaft/mips/lithium-codegen-mips.cc |
+++ b/src/crankshaft/mips/lithium-codegen-mips.cc |
@@ -1728,13 +1728,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); |
@@ -1749,43 +1749,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); |
} |
} |