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

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

Issue 2612503002: X87: [turbofan] Improve codegen for 8- and 16-bit memory comparisons on Intel platforms. (Closed)
Patch Set: 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 | « no previous file | no next file » | 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 "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 9
10 namespace v8 { 10 namespace v8 {
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, 1254 void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
1255 Node* left, Node* right, FlagsContinuation* cont, 1255 Node* left, Node* right, FlagsContinuation* cont,
1256 bool commutative) { 1256 bool commutative) {
1257 X87OperandGenerator g(selector); 1257 X87OperandGenerator g(selector);
1258 if (commutative && g.CanBeBetterLeftOperand(right)) { 1258 if (commutative && g.CanBeBetterLeftOperand(right)) {
1259 std::swap(left, right); 1259 std::swap(left, right);
1260 } 1260 }
1261 VisitCompare(selector, opcode, g.UseRegister(left), g.Use(right), cont); 1261 VisitCompare(selector, opcode, g.UseRegister(left), g.Use(right), cont);
1262 } 1262 }
1263 1263
1264 MachineType MachineTypeForNarrow(Node* node, Node* hint_node) {
1265 if (hint_node->opcode() == IrOpcode::kLoad) {
1266 MachineType hint = LoadRepresentationOf(hint_node->op());
1267 if (node->opcode() == IrOpcode::kInt32Constant ||
1268 node->opcode() == IrOpcode::kInt64Constant) {
1269 int64_t constant = node->opcode() == IrOpcode::kInt32Constant
1270 ? OpParameter<int32_t>(node)
1271 : OpParameter<int64_t>(node);
1272 if (hint == MachineType::Int8()) {
1273 if (constant >= std::numeric_limits<int8_t>::min() &&
1274 constant <= std::numeric_limits<int8_t>::max()) {
1275 return hint;
1276 }
1277 } else if (hint == MachineType::Uint8()) {
1278 if (constant >= std::numeric_limits<uint8_t>::min() &&
1279 constant <= std::numeric_limits<uint8_t>::max()) {
1280 return hint;
1281 }
1282 } else if (hint == MachineType::Int16()) {
1283 if (constant >= std::numeric_limits<int16_t>::min() &&
1284 constant <= std::numeric_limits<int16_t>::max()) {
1285 return hint;
1286 }
1287 } else if (hint == MachineType::Uint16()) {
1288 if (constant >= std::numeric_limits<uint16_t>::min() &&
1289 constant <= std::numeric_limits<uint16_t>::max()) {
1290 return hint;
1291 }
1292 } else if (hint == MachineType::Int32()) {
1293 return hint;
1294 } else if (hint == MachineType::Uint32()) {
1295 if (constant >= 0) return hint;
1296 }
1297 }
1298 }
1299 return node->opcode() == IrOpcode::kLoad ? LoadRepresentationOf(node->op())
1300 : MachineType::None();
1301 }
1302
1264 // Tries to match the size of the given opcode to that of the operands, if 1303 // Tries to match the size of the given opcode to that of the operands, if
1265 // possible. 1304 // possible.
1266 InstructionCode TryNarrowOpcodeSize(InstructionCode opcode, Node* left, 1305 InstructionCode TryNarrowOpcodeSize(InstructionCode opcode, Node* left,
1267 Node* right, FlagsContinuation* cont) { 1306 Node* right, FlagsContinuation* cont) {
1268 // Currently, if one of the two operands is not a Load, we don't know what its 1307 // TODO(epertoso): we can probably get some size information out of phi nodes.
1269 // machine representation is, so we bail out.
1270 // TODO(epertoso): we can probably get some size information out of immediates
1271 // and phi nodes.
1272 if (left->opcode() != IrOpcode::kLoad || right->opcode() != IrOpcode::kLoad) {
1273 return opcode;
1274 }
1275 // If the load representations don't match, both operands will be 1308 // If the load representations don't match, both operands will be
1276 // zero/sign-extended to 32bit. 1309 // zero/sign-extended to 32bit.
1277 MachineType left_type = LoadRepresentationOf(left->op()); 1310 MachineType left_type = MachineTypeForNarrow(left, right);
1278 MachineType right_type = LoadRepresentationOf(right->op()); 1311 MachineType right_type = MachineTypeForNarrow(right, left);
1279 if (left_type == right_type) { 1312 if (left_type == right_type) {
1280 switch (left_type.representation()) { 1313 switch (left_type.representation()) {
1281 case MachineRepresentation::kBit: 1314 case MachineRepresentation::kBit:
1282 case MachineRepresentation::kWord8: { 1315 case MachineRepresentation::kWord8: {
1283 if (opcode == kX87Test) return kX87Test8; 1316 if (opcode == kX87Test) return kX87Test8;
1284 if (opcode == kX87Cmp) { 1317 if (opcode == kX87Cmp) {
1285 if (left_type.semantic() == MachineSemantic::kUint32) { 1318 if (left_type.semantic() == MachineSemantic::kUint32) {
1286 cont->OverwriteUnsignedIfSigned(); 1319 cont->OverwriteUnsignedIfSigned();
1287 } else { 1320 } else {
1288 CHECK_EQ(MachineSemantic::kInt32, left_type.semantic()); 1321 CHECK_EQ(MachineSemantic::kInt32, left_type.semantic());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 // if one of the two inputs is a memory operand, make sure it's on the left. 1403 // if one of the two inputs is a memory operand, make sure it's on the left.
1371 if ((!g.CanBeImmediate(right) && g.CanBeImmediate(left)) || 1404 if ((!g.CanBeImmediate(right) && g.CanBeImmediate(left)) ||
1372 (g.CanBeMemoryOperand(narrowed_opcode, node, right, effect_level) && 1405 (g.CanBeMemoryOperand(narrowed_opcode, node, right, effect_level) &&
1373 !g.CanBeMemoryOperand(narrowed_opcode, node, left, effect_level))) { 1406 !g.CanBeMemoryOperand(narrowed_opcode, node, left, effect_level))) {
1374 if (!node->op()->HasProperty(Operator::kCommutative)) cont->Commute(); 1407 if (!node->op()->HasProperty(Operator::kCommutative)) cont->Commute();
1375 std::swap(left, right); 1408 std::swap(left, right);
1376 } 1409 }
1377 1410
1378 // Match immediates on right side of comparison. 1411 // Match immediates on right side of comparison.
1379 if (g.CanBeImmediate(right)) { 1412 if (g.CanBeImmediate(right)) {
1380 if (g.CanBeMemoryOperand(opcode, node, left, effect_level)) { 1413 if (g.CanBeMemoryOperand(narrowed_opcode, node, left, effect_level)) {
1381 // TODO(epertoso): we should use `narrowed_opcode' here once we match 1414 return VisitCompareWithMemoryOperand(selector, narrowed_opcode, left,
1382 // immediates too.
1383 return VisitCompareWithMemoryOperand(selector, opcode, left,
1384 g.UseImmediate(right), cont); 1415 g.UseImmediate(right), cont);
1385 } 1416 }
1386 return VisitCompare(selector, opcode, g.Use(left), g.UseImmediate(right), 1417 return VisitCompare(selector, opcode, g.Use(left), g.UseImmediate(right),
1387 cont); 1418 cont);
1388 } 1419 }
1389 1420
1390 // Match memory operands on left side of comparison. 1421 // Match memory operands on left side of comparison.
1391 if (g.CanBeMemoryOperand(narrowed_opcode, node, left, effect_level)) { 1422 if (g.CanBeMemoryOperand(narrowed_opcode, node, left, effect_level)) {
1392 bool needs_byte_register = 1423 bool needs_byte_register =
1393 narrowed_opcode == kX87Test8 || narrowed_opcode == kX87Cmp8; 1424 narrowed_opcode == kX87Test8 || narrowed_opcode == kX87Cmp8;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 // static 1826 // static
1796 MachineOperatorBuilder::AlignmentRequirements 1827 MachineOperatorBuilder::AlignmentRequirements
1797 InstructionSelector::AlignmentRequirements() { 1828 InstructionSelector::AlignmentRequirements() {
1798 return MachineOperatorBuilder::AlignmentRequirements:: 1829 return MachineOperatorBuilder::AlignmentRequirements::
1799 FullUnalignedAccessSupport(); 1830 FullUnalignedAccessSupport();
1800 } 1831 }
1801 1832
1802 } // namespace compiler 1833 } // namespace compiler
1803 } // namespace internal 1834 } // namespace internal
1804 } // namespace v8 1835 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698