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

Side by Side Diff: src/compiler/x64/instruction-selector-x64.cc

Issue 2605863002: [turbofan] Improve codegen for 8- and 16-bit memory comparisons on Intel platforms (Closed)
Patch Set: Fix assert Created 3 years, 11 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
« no previous file with comments | « src/compiler/ia32/instruction-selector-ia32.cc ('k') | src/x64/assembler-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, 1720 void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
1721 Node* left, Node* right, FlagsContinuation* cont, 1721 Node* left, Node* right, FlagsContinuation* cont,
1722 bool commutative) { 1722 bool commutative) {
1723 X64OperandGenerator g(selector); 1723 X64OperandGenerator g(selector);
1724 if (commutative && g.CanBeBetterLeftOperand(right)) { 1724 if (commutative && g.CanBeBetterLeftOperand(right)) {
1725 std::swap(left, right); 1725 std::swap(left, right);
1726 } 1726 }
1727 VisitCompare(selector, opcode, g.UseRegister(left), g.Use(right), cont); 1727 VisitCompare(selector, opcode, g.UseRegister(left), g.Use(right), cont);
1728 } 1728 }
1729 1729
1730 MachineType MachineTypeForNarrow(Node* node, Node* hint_node) {
1731 if (hint_node->opcode() == IrOpcode::kLoad) {
1732 MachineType hint = LoadRepresentationOf(hint_node->op());
1733 if (node->opcode() == IrOpcode::kInt32Constant ||
1734 node->opcode() == IrOpcode::kInt64Constant) {
1735 int64_t constant = node->opcode() == IrOpcode::kInt32Constant
1736 ? OpParameter<int32_t>(node)
1737 : OpParameter<int64_t>(node);
1738 if (hint == MachineType::Int8()) {
1739 if (constant >= std::numeric_limits<int8_t>::min() &&
1740 constant <= std::numeric_limits<int8_t>::max()) {
1741 return hint;
1742 }
1743 } else if (hint == MachineType::Uint8()) {
1744 if (constant >= std::numeric_limits<uint8_t>::min() &&
1745 constant <= std::numeric_limits<uint8_t>::max()) {
1746 return hint;
1747 }
1748 } else if (hint == MachineType::Int16()) {
1749 if (constant >= std::numeric_limits<int16_t>::min() &&
1750 constant <= std::numeric_limits<int16_t>::max()) {
1751 return hint;
1752 }
1753 } else if (hint == MachineType::Uint16()) {
1754 if (constant >= std::numeric_limits<uint16_t>::min() &&
1755 constant <= std::numeric_limits<uint16_t>::max()) {
1756 return hint;
1757 }
1758 } else if (hint == MachineType::Int32()) {
1759 return hint;
1760 } else if (hint == MachineType::Uint32()) {
1761 if (constant >= 0) return hint;
1762 }
1763 }
1764 }
1765 return node->opcode() == IrOpcode::kLoad ? LoadRepresentationOf(node->op())
1766 : MachineType::None();
1767 }
1768
1730 // Tries to match the size of the given opcode to that of the operands, if 1769 // Tries to match the size of the given opcode to that of the operands, if
1731 // possible. 1770 // possible.
1732 InstructionCode TryNarrowOpcodeSize(InstructionCode opcode, Node* left, 1771 InstructionCode TryNarrowOpcodeSize(InstructionCode opcode, Node* left,
1733 Node* right, FlagsContinuation* cont) { 1772 Node* right, FlagsContinuation* cont) {
1734 // Currently, if one of the two operands is not a Load, we don't know what its 1773 // TODO(epertoso): we can probably get some size information out phi nodes.
1735 // machine representation is, so we bail out.
1736 // TODO(epertoso): we can probably get some size information out of immediates
1737 // and phi nodes.
1738 if (left->opcode() != IrOpcode::kLoad || right->opcode() != IrOpcode::kLoad) {
1739 return opcode;
1740 }
1741 // If the load representations don't match, both operands will be 1774 // If the load representations don't match, both operands will be
1742 // zero/sign-extended to 32bit. 1775 // zero/sign-extended to 32bit.
1743 MachineType left_type = LoadRepresentationOf(left->op()); 1776 MachineType left_type = MachineTypeForNarrow(left, right);
1744 MachineType right_type = LoadRepresentationOf(right->op()); 1777 MachineType right_type = MachineTypeForNarrow(right, left);
1745 if (left_type == right_type) { 1778 if (left_type == right_type) {
1746 switch (left_type.representation()) { 1779 switch (left_type.representation()) {
1747 case MachineRepresentation::kBit: 1780 case MachineRepresentation::kBit:
1748 case MachineRepresentation::kWord8: { 1781 case MachineRepresentation::kWord8: {
1749 if (opcode == kX64Test32) return kX64Test8; 1782 if (opcode == kX64Test32) return kX64Test8;
1750 if (opcode == kX64Cmp32) { 1783 if (opcode == kX64Cmp32) {
1751 if (left_type.semantic() == MachineSemantic::kUint32) { 1784 if (left_type.semantic() == MachineSemantic::kUint32) {
1752 cont->OverwriteUnsignedIfSigned(); 1785 cont->OverwriteUnsignedIfSigned();
1753 } else { 1786 } else {
1754 CHECK_EQ(MachineSemantic::kInt32, left_type.semantic()); 1787 CHECK_EQ(MachineSemantic::kInt32, left_type.semantic());
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 // static 2481 // static
2449 MachineOperatorBuilder::AlignmentRequirements 2482 MachineOperatorBuilder::AlignmentRequirements
2450 InstructionSelector::AlignmentRequirements() { 2483 InstructionSelector::AlignmentRequirements() {
2451 return MachineOperatorBuilder::AlignmentRequirements:: 2484 return MachineOperatorBuilder::AlignmentRequirements::
2452 FullUnalignedAccessSupport(); 2485 FullUnalignedAccessSupport();
2453 } 2486 }
2454 2487
2455 } // namespace compiler 2488 } // namespace compiler
2456 } // namespace internal 2489 } // namespace internal
2457 } // namespace v8 2490 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ia32/instruction-selector-ia32.cc ('k') | src/x64/assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698