OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "src/base/adapters.h" | 7 #include "src/base/adapters.h" |
8 #include "src/compiler/instruction-selector-impl.h" | 8 #include "src/compiler/instruction-selector-impl.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1442 Node* value = branch->InputAt(0); | 1442 Node* value = branch->InputAt(0); |
1443 | 1443 |
1444 FlagsContinuation cont(kNotEqual, tbranch, fbranch); | 1444 FlagsContinuation cont(kNotEqual, tbranch, fbranch); |
1445 | 1445 |
1446 // Try to combine the branch with a comparison. | 1446 // Try to combine the branch with a comparison. |
1447 while (CanCover(user, value)) { | 1447 while (CanCover(user, value)) { |
1448 switch (value->opcode()) { | 1448 switch (value->opcode()) { |
1449 case IrOpcode::kWord32Equal: | 1449 case IrOpcode::kWord32Equal: |
1450 case IrOpcode::kWord64Equal: { | 1450 case IrOpcode::kWord64Equal: { |
1451 Int64BinopMatcher m(value); | 1451 Int64BinopMatcher m(value); |
1452 bool is_word64 = value->opcode() == IrOpcode::kWord64Equal; | |
1452 if (m.right().Is(0)) { | 1453 if (m.right().Is(0)) { |
1453 user = value; | 1454 user = value; |
1454 value = m.left().node(); | 1455 value = m.left().node(); |
1455 cont.Negate(); | 1456 switch (value->opcode()) { |
1456 continue; | 1457 case IrOpcode::kLoad: |
Benedikt Meurer
2016/02/11 05:13:53
This looks rather hacky to me, esp. hunting for Lo
epertoso
2016/02/11 13:47:47
Yeah, I traced back the issue to the use of Word64
| |
1458 case IrOpcode::kPhi: | |
1459 cont.OverwriteAndNegateIfEqual(kEqual); | |
1460 return VisitCompareZero(this, value, | |
1461 is_word64 ? kX64Cmp : kX64Cmp32, &cont); | |
1462 default: | |
1463 cont.Negate(); | |
1464 continue; | |
1465 } | |
1457 } | 1466 } |
1458 cont.OverwriteAndNegateIfEqual(kEqual); | 1467 cont.OverwriteAndNegateIfEqual(kEqual); |
1459 return VisitWordCompare( | 1468 if (is_word64) { |
1460 this, value, | 1469 return VisitWord64Compare(this, value, &cont); |
1461 value->opcode() == IrOpcode::kWord64Equal ? kX64Cmp : kX64Cmp32, | 1470 } |
1462 &cont); | 1471 return VisitWordCompare(this, value, kX64Cmp32, &cont); |
1463 } | 1472 } |
1464 case IrOpcode::kInt32LessThan: | 1473 case IrOpcode::kInt32LessThan: |
1465 cont.OverwriteAndNegateIfEqual(kSignedLessThan); | 1474 cont.OverwriteAndNegateIfEqual(kSignedLessThan); |
1466 return VisitWordCompare(this, value, kX64Cmp32, &cont); | 1475 return VisitWordCompare(this, value, kX64Cmp32, &cont); |
1467 case IrOpcode::kInt32LessThanOrEqual: | 1476 case IrOpcode::kInt32LessThanOrEqual: |
1468 cont.OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); | 1477 cont.OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); |
1469 return VisitWordCompare(this, value, kX64Cmp32, &cont); | 1478 return VisitWordCompare(this, value, kX64Cmp32, &cont); |
1470 case IrOpcode::kUint32LessThan: | 1479 case IrOpcode::kUint32LessThan: |
1471 cont.OverwriteAndNegateIfEqual(kUnsignedLessThan); | 1480 cont.OverwriteAndNegateIfEqual(kUnsignedLessThan); |
1472 return VisitWordCompare(this, value, kX64Cmp32, &cont); | 1481 return VisitWordCompare(this, value, kX64Cmp32, &cont); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1535 } | 1544 } |
1536 break; | 1545 break; |
1537 case IrOpcode::kInt32Sub: | 1546 case IrOpcode::kInt32Sub: |
1538 return VisitWordCompare(this, value, kX64Cmp32, &cont); | 1547 return VisitWordCompare(this, value, kX64Cmp32, &cont); |
1539 case IrOpcode::kInt64Sub: | 1548 case IrOpcode::kInt64Sub: |
1540 return VisitWord64Compare(this, value, &cont); | 1549 return VisitWord64Compare(this, value, &cont); |
1541 case IrOpcode::kWord32And: | 1550 case IrOpcode::kWord32And: |
1542 return VisitWordCompare(this, value, kX64Test32, &cont); | 1551 return VisitWordCompare(this, value, kX64Test32, &cont); |
1543 case IrOpcode::kWord64And: | 1552 case IrOpcode::kWord64And: |
1544 return VisitWordCompare(this, value, kX64Test, &cont); | 1553 return VisitWordCompare(this, value, kX64Test, &cont); |
1545 case IrOpcode::kLoad: | |
1546 if (LoadRepresentationOf(value->op()).representation() == | |
1547 MachineRepresentation::kWord64) { | |
1548 return VisitCompareZero(this, value, kX64Cmp, &cont); | |
1549 } | |
1550 break; | |
1551 default: | 1554 default: |
1552 break; | 1555 break; |
1553 } | 1556 } |
1554 break; | 1557 break; |
1555 } | 1558 } |
1556 | 1559 |
1557 // Branch could not be combined with a compare, emit compare against 0. | 1560 // Branch could not be combined with a compare, emit compare against 0. |
1558 VisitCompareZero(this, value, kX64Cmp32, &cont); | 1561 VisitCompareZero(this, value, kX64Cmp, &cont); |
1559 } | 1562 } |
1560 | 1563 |
1561 | 1564 |
1562 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { | 1565 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { |
1563 X64OperandGenerator g(this); | 1566 X64OperandGenerator g(this); |
1564 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); | 1567 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); |
1565 | 1568 |
1566 // Emit either ArchTableSwitch or ArchLookupSwitch. | 1569 // Emit either ArchTableSwitch or ArchLookupSwitch. |
1567 size_t table_space_cost = 4 + sw.value_range; | 1570 size_t table_space_cost = 4 + sw.value_range; |
1568 size_t table_time_cost = 3; | 1571 size_t table_time_cost = 3; |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1812 MachineOperatorBuilder::kFloat64RoundTruncate | | 1815 MachineOperatorBuilder::kFloat64RoundTruncate | |
1813 MachineOperatorBuilder::kFloat32RoundTiesEven | | 1816 MachineOperatorBuilder::kFloat32RoundTiesEven | |
1814 MachineOperatorBuilder::kFloat64RoundTiesEven; | 1817 MachineOperatorBuilder::kFloat64RoundTiesEven; |
1815 } | 1818 } |
1816 return flags; | 1819 return flags; |
1817 } | 1820 } |
1818 | 1821 |
1819 } // namespace compiler | 1822 } // namespace compiler |
1820 } // namespace internal | 1823 } // namespace internal |
1821 } // namespace v8 | 1824 } // namespace v8 |
OLD | NEW |