OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 "src/base/adapters.h" | 5 #include "src/base/adapters.h" |
6 #include "src/compiler/instruction-selector-impl.h" | 6 #include "src/compiler/instruction-selector-impl.h" |
7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
9 #include "src/s390/frames-s390.h" | 9 #include "src/s390/frames-s390.h" |
10 | 10 |
(...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 Node* left = node->InputAt(0); | 1600 Node* left = node->InputAt(0); |
1601 Node* right = node->InputAt(1); | 1601 Node* right = node->InputAt(1); |
1602 VisitCompare(selector, kS390_CmpDouble, g.UseRegister(left), | 1602 VisitCompare(selector, kS390_CmpDouble, g.UseRegister(left), |
1603 g.UseRegister(right), cont); | 1603 g.UseRegister(right), cont); |
1604 } | 1604 } |
1605 | 1605 |
1606 // Shared routine for word comparisons against zero. | 1606 // Shared routine for word comparisons against zero. |
1607 void VisitWordCompareZero(InstructionSelector* selector, Node* user, | 1607 void VisitWordCompareZero(InstructionSelector* selector, Node* user, |
1608 Node* value, InstructionCode opcode, | 1608 Node* value, InstructionCode opcode, |
1609 FlagsContinuation* cont) { | 1609 FlagsContinuation* cont) { |
1610 while (selector->CanCover(user, value)) { | 1610 // Try to combine with comparisons against 0 by simply inverting the branch. |
| 1611 while (value->opcode() == IrOpcode::kWord32Equal && |
| 1612 selector->CanCover(user, value)) { |
| 1613 Int32BinopMatcher m(value); |
| 1614 if (!m.right().Is(0)) break; |
| 1615 |
| 1616 user = value; |
| 1617 value = m.left().node(); |
| 1618 cont->Negate(); |
| 1619 } |
| 1620 |
| 1621 if (selector->CanCover(user, value)) { |
1611 switch (value->opcode()) { | 1622 switch (value->opcode()) { |
1612 case IrOpcode::kWord32Equal: { | 1623 case IrOpcode::kWord32Equal: |
1613 // Combine with comparisons against 0 by simply inverting the | |
1614 // continuation. | |
1615 Int32BinopMatcher m(value); | |
1616 if (m.right().Is(0)) { | |
1617 user = value; | |
1618 value = m.left().node(); | |
1619 cont->Negate(); | |
1620 continue; | |
1621 } | |
1622 cont->OverwriteAndNegateIfEqual(kEqual); | 1624 cont->OverwriteAndNegateIfEqual(kEqual); |
1623 return VisitWord32Compare(selector, value, cont); | 1625 return VisitWord32Compare(selector, value, cont); |
1624 } | |
1625 case IrOpcode::kInt32LessThan: | 1626 case IrOpcode::kInt32LessThan: |
1626 cont->OverwriteAndNegateIfEqual(kSignedLessThan); | 1627 cont->OverwriteAndNegateIfEqual(kSignedLessThan); |
1627 return VisitWord32Compare(selector, value, cont); | 1628 return VisitWord32Compare(selector, value, cont); |
1628 case IrOpcode::kInt32LessThanOrEqual: | 1629 case IrOpcode::kInt32LessThanOrEqual: |
1629 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); | 1630 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); |
1630 return VisitWord32Compare(selector, value, cont); | 1631 return VisitWord32Compare(selector, value, cont); |
1631 case IrOpcode::kUint32LessThan: | 1632 case IrOpcode::kUint32LessThan: |
1632 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); | 1633 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); |
1633 return VisitWord32Compare(selector, value, cont); | 1634 return VisitWord32Compare(selector, value, cont); |
1634 case IrOpcode::kUint32LessThanOrEqual: | 1635 case IrOpcode::kUint32LessThanOrEqual: |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1733 // case IrOpcode::kWord64Or: | 1734 // case IrOpcode::kWord64Or: |
1734 // case IrOpcode::kWord64Xor: | 1735 // case IrOpcode::kWord64Xor: |
1735 // case IrOpcode::kWord64Sar: | 1736 // case IrOpcode::kWord64Sar: |
1736 // case IrOpcode::kWord64Shl: | 1737 // case IrOpcode::kWord64Shl: |
1737 // case IrOpcode::kWord64Shr: | 1738 // case IrOpcode::kWord64Shr: |
1738 // case IrOpcode::kWord64Ror: | 1739 // case IrOpcode::kWord64Ror: |
1739 #endif | 1740 #endif |
1740 default: | 1741 default: |
1741 break; | 1742 break; |
1742 } | 1743 } |
1743 break; | |
1744 } | 1744 } |
1745 | 1745 |
1746 // Branch could not be combined with a compare, emit compare against 0. | 1746 // Branch could not be combined with a compare, emit compare against 0. |
1747 S390OperandGenerator g(selector); | 1747 S390OperandGenerator g(selector); |
1748 VisitCompare(selector, opcode, g.UseRegister(value), g.TempImmediate(0), | 1748 VisitCompare(selector, opcode, g.UseRegister(value), g.TempImmediate(0), |
1749 cont); | 1749 cont); |
1750 } | 1750 } |
1751 | 1751 |
1752 void VisitWord32CompareZero(InstructionSelector* selector, Node* user, | 1752 void VisitWord32CompareZero(InstructionSelector* selector, Node* user, |
1753 Node* value, FlagsContinuation* cont) { | 1753 Node* value, FlagsContinuation* cont) { |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2063 // static | 2063 // static |
2064 MachineOperatorBuilder::AlignmentRequirements | 2064 MachineOperatorBuilder::AlignmentRequirements |
2065 InstructionSelector::AlignmentRequirements() { | 2065 InstructionSelector::AlignmentRequirements() { |
2066 return MachineOperatorBuilder::AlignmentRequirements:: | 2066 return MachineOperatorBuilder::AlignmentRequirements:: |
2067 FullUnalignedAccessSupport(); | 2067 FullUnalignedAccessSupport(); |
2068 } | 2068 } |
2069 | 2069 |
2070 } // namespace compiler | 2070 } // namespace compiler |
2071 } // namespace internal | 2071 } // namespace internal |
2072 } // namespace v8 | 2072 } // namespace v8 |
OLD | NEW |