Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: src/arm/lithium-codegen-arm.cc

Issue 10829169: Refactor Math.min/max to be a single HInstruction. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 ASSERT(right->IsRegister() || right->IsConstantOperand()); 1642 ASSERT(right->IsRegister() || right->IsConstantOperand());
1643 __ add(ToRegister(result), ToRegister(left), ToOperand(right), set_cond); 1643 __ add(ToRegister(result), ToRegister(left), ToOperand(right), set_cond);
1644 } 1644 }
1645 1645
1646 if (can_overflow) { 1646 if (can_overflow) {
1647 DeoptimizeIf(vs, instr->environment()); 1647 DeoptimizeIf(vs, instr->environment());
1648 } 1648 }
1649 } 1649 }
1650 1650
1651 1651
1652 void LCodeGen::DoMathMinMax(LMathMinMax* instr) {
1653 LOperand* left = instr->InputAt(0);
1654 LOperand* right = instr->InputAt(1);
1655 HMathMinMax::Operation operation = instr->hydrogen()->operation();
1656 Condition condition = (operation == HMathMinMax::kMathMin) ? le : ge;
1657 if (instr->hydrogen()->representation().IsInteger32()) {
1658 Register left_reg = ToRegister(left);
1659 Operand right_op = (right->IsRegister() || right->IsConstantOperand())
1660 ? ToOperand(right)
1661 : Operand(EmitLoadRegister(right, ip));
1662 Register result_reg = ToRegister(instr->result());
1663 __ cmp(left_reg, right_op);
1664 if (!result_reg.is(left_reg)) {
1665 __ mov(result_reg, left_reg, LeaveCC, condition);
1666 }
1667 __ mov(result_reg, right_op, LeaveCC, NegateCondition(condition));
1668 } else {
1669 ASSERT(instr->hydrogen()->representation().IsDouble());
1670 DoubleRegister left_reg = ToDoubleRegister(left);
1671 DoubleRegister right_reg = ToDoubleRegister(right);
1672 DoubleRegister result_reg = ToDoubleRegister(instr->result());
1673 Label check_nan_left, check_zero, return_left, return_right, done;
1674 __ VFPCompareAndSetFlags(left_reg, right_reg);
1675 __ b(vs, &check_nan_left);
1676 __ b(eq, &check_zero);
1677 __ b(condition, &return_left);
1678 __ b(al, &return_right);
1679
1680 __ bind(&check_zero);
1681 __ VFPCompareAndSetFlags(left_reg, 0.0);
1682 __ b(ne, &return_left); // left == right != 0.
1683 // At this point, both left and right are either 0 or -0.
1684 if (operation == HMathMinMax::kMathMin) {
1685 __ vorr(result_reg, left_reg, right_reg);
1686 } else {
1687 __ vadd(result_reg, left_reg, right_reg);
Erik Corry 2012/08/06 10:44:40 Should this be vand?
Yang 2012/08/06 10:50:41 I think vadd would work equally well here: -0 + -0
Jakob Kummerow 2012/08/06 14:08:43 Added a comment explaining why "vadd" is not a typ
1688 }
1689 __ b(al, &done);
1690
1691 __ bind(&check_nan_left);
1692 __ VFPCompareAndSetFlags(left_reg, left_reg);
1693 __ b(vs, &return_left); // left == NaN.
1694 __ bind(&return_right);
1695 if (!right_reg.is(result_reg)) {
1696 __ vmov(result_reg, right_reg);
1697 }
1698 __ b(al, &done);
1699
1700 __ bind(&return_left);
1701 if (!left_reg.is(result_reg)) {
1702 __ vmov(result_reg, left_reg);
1703 }
1704 __ bind(&done);
1705 }
1706 }
1707
1708
1652 void LCodeGen::DoArithmeticD(LArithmeticD* instr) { 1709 void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
1653 DoubleRegister left = ToDoubleRegister(instr->InputAt(0)); 1710 DoubleRegister left = ToDoubleRegister(instr->InputAt(0));
1654 DoubleRegister right = ToDoubleRegister(instr->InputAt(1)); 1711 DoubleRegister right = ToDoubleRegister(instr->InputAt(1));
1655 DoubleRegister result = ToDoubleRegister(instr->result()); 1712 DoubleRegister result = ToDoubleRegister(instr->result());
1656 switch (instr->op()) { 1713 switch (instr->op()) {
1657 case Token::ADD: 1714 case Token::ADD:
1658 __ vadd(result, left, right); 1715 __ vadd(result, left, right);
1659 break; 1716 break;
1660 case Token::SUB: 1717 case Token::SUB:
1661 __ vsub(result, left, right); 1718 __ vsub(result, left, right);
(...skipping 3802 matching lines...) Expand 10 before | Expand all | Expand 10 after
5464 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); 5521 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize));
5465 __ ldr(result, FieldMemOperand(scratch, 5522 __ ldr(result, FieldMemOperand(scratch,
5466 FixedArray::kHeaderSize - kPointerSize)); 5523 FixedArray::kHeaderSize - kPointerSize));
5467 __ bind(&done); 5524 __ bind(&done);
5468 } 5525 }
5469 5526
5470 5527
5471 #undef __ 5528 #undef __
5472 5529
5473 } } // namespace v8::internal 5530 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698