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

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

Issue 1206773002: [x64] Fix instruction selection for Word64Equal(Word64And, 0). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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 | test/cctest/compiler/test-run-intrinsics.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 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 return VisitWordCompare(this, value, kX64Cmp32, &cont); 1306 return VisitWordCompare(this, value, kX64Cmp32, &cont);
1307 case IrOpcode::kInt32LessThanOrEqual: 1307 case IrOpcode::kInt32LessThanOrEqual:
1308 cont.OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); 1308 cont.OverwriteAndNegateIfEqual(kSignedLessThanOrEqual);
1309 return VisitWordCompare(this, value, kX64Cmp32, &cont); 1309 return VisitWordCompare(this, value, kX64Cmp32, &cont);
1310 case IrOpcode::kUint32LessThan: 1310 case IrOpcode::kUint32LessThan:
1311 cont.OverwriteAndNegateIfEqual(kUnsignedLessThan); 1311 cont.OverwriteAndNegateIfEqual(kUnsignedLessThan);
1312 return VisitWordCompare(this, value, kX64Cmp32, &cont); 1312 return VisitWordCompare(this, value, kX64Cmp32, &cont);
1313 case IrOpcode::kUint32LessThanOrEqual: 1313 case IrOpcode::kUint32LessThanOrEqual:
1314 cont.OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); 1314 cont.OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual);
1315 return VisitWordCompare(this, value, kX64Cmp32, &cont); 1315 return VisitWordCompare(this, value, kX64Cmp32, &cont);
1316 case IrOpcode::kWord64Equal: 1316 case IrOpcode::kWord64Equal: {
1317 cont.OverwriteAndNegateIfEqual(kEqual); 1317 cont.OverwriteAndNegateIfEqual(kEqual);
1318 Int64BinopMatcher m(value);
1319 if (m.right().Is(0)) {
1320 // Try to combine the branch with a comparison.
1321 Node* const user = m.node();
1322 Node* const value = m.left().node();
Jarin 2015/06/24 07:35:59 Could you avoid shadowing the 'user' and 'value' v
Benedikt Meurer 2015/06/24 07:38:18 Done.
1323 if (CanCover(user, value)) {
1324 switch (value->opcode()) {
1325 case IrOpcode::kInt64Sub:
1326 return VisitWord64Compare(this, value, &cont);
1327 case IrOpcode::kWord64And:
1328 return VisitWordCompare(this, value, kX64Test, &cont);
1329 default:
1330 break;
1331 }
1332 }
1333 return VisitCompareZero(this, value, kX64Cmp, &cont);
1334 }
1318 return VisitWord64Compare(this, value, &cont); 1335 return VisitWord64Compare(this, value, &cont);
1336 }
1319 case IrOpcode::kInt64LessThan: 1337 case IrOpcode::kInt64LessThan:
1320 cont.OverwriteAndNegateIfEqual(kSignedLessThan); 1338 cont.OverwriteAndNegateIfEqual(kSignedLessThan);
1321 return VisitWord64Compare(this, value, &cont); 1339 return VisitWord64Compare(this, value, &cont);
1322 case IrOpcode::kInt64LessThanOrEqual: 1340 case IrOpcode::kInt64LessThanOrEqual:
1323 cont.OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); 1341 cont.OverwriteAndNegateIfEqual(kSignedLessThanOrEqual);
1324 return VisitWord64Compare(this, value, &cont); 1342 return VisitWord64Compare(this, value, &cont);
1325 case IrOpcode::kUint64LessThan: 1343 case IrOpcode::kUint64LessThan:
1326 cont.OverwriteAndNegateIfEqual(kUnsignedLessThan); 1344 cont.OverwriteAndNegateIfEqual(kUnsignedLessThan);
1327 return VisitWord64Compare(this, value, &cont); 1345 return VisitWord64Compare(this, value, &cont);
1328 case IrOpcode::kFloat32Equal: 1346 case IrOpcode::kFloat32Equal:
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 } 1489 }
1472 1490
1473 1491
1474 void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) { 1492 void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) {
1475 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); 1493 FlagsContinuation cont(kUnsignedLessThanOrEqual, node);
1476 VisitWordCompare(this, node, kX64Cmp32, &cont); 1494 VisitWordCompare(this, node, kX64Cmp32, &cont);
1477 } 1495 }
1478 1496
1479 1497
1480 void InstructionSelector::VisitWord64Equal(Node* const node) { 1498 void InstructionSelector::VisitWord64Equal(Node* const node) {
1481 Node* user = node;
1482 FlagsContinuation cont(kEqual, node); 1499 FlagsContinuation cont(kEqual, node);
1483 Int64BinopMatcher m(user); 1500 Int64BinopMatcher m(node);
1484 if (m.right().Is(0)) { 1501 if (m.right().Is(0)) {
1485 Node* value = m.left().node(); 1502 // Try to combine the equality check with a comparison.
1486 1503 Node* const user = m.node();
1487 // Try to combine with comparisons against 0 by simply inverting the branch. 1504 Node* const value = m.left().node();
1488 while (CanCover(user, value) && value->opcode() == IrOpcode::kWord64Equal) {
1489 Int64BinopMatcher m(value);
1490 if (m.right().Is(0)) {
1491 user = value;
1492 value = m.left().node();
1493 cont.Negate();
1494 } else {
1495 break;
1496 }
1497 }
1498
1499 // Try to combine the branch with a comparison.
1500 if (CanCover(user, value)) { 1505 if (CanCover(user, value)) {
1501 switch (value->opcode()) { 1506 switch (value->opcode()) {
1502 case IrOpcode::kInt64Sub: 1507 case IrOpcode::kInt64Sub:
1503 return VisitWord64Compare(this, value, &cont); 1508 return VisitWord64Compare(this, value, &cont);
1504 case IrOpcode::kWord64And: 1509 case IrOpcode::kWord64And:
1505 return VisitWordCompare(this, value, kX64Test, &cont); 1510 return VisitWordCompare(this, value, kX64Test, &cont);
1506 default: 1511 default:
1507 break; 1512 break;
1508 } 1513 }
1509 } 1514 }
1510 return VisitCompareZero(this, value, kX64Cmp, &cont);
1511 } 1515 }
1512 VisitWord64Compare(this, node, &cont); 1516 VisitWord64Compare(this, node, &cont);
1513 } 1517 }
1514 1518
1515 1519
1516 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { 1520 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) {
1517 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { 1521 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
1518 FlagsContinuation cont(kOverflow, ovf); 1522 FlagsContinuation cont(kOverflow, ovf);
1519 VisitBinop(this, node, kX64Add32, &cont); 1523 VisitBinop(this, node, kX64Add32, &cont);
1520 } 1524 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 if (CpuFeatures::IsSupported(SSE4_1)) { 1640 if (CpuFeatures::IsSupported(SSE4_1)) {
1637 flags |= MachineOperatorBuilder::kFloat64RoundDown | 1641 flags |= MachineOperatorBuilder::kFloat64RoundDown |
1638 MachineOperatorBuilder::kFloat64RoundTruncate; 1642 MachineOperatorBuilder::kFloat64RoundTruncate;
1639 } 1643 }
1640 return flags; 1644 return flags;
1641 } 1645 }
1642 1646
1643 } // namespace compiler 1647 } // namespace compiler
1644 } // namespace internal 1648 } // namespace internal
1645 } // namespace v8 1649 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/compiler/test-run-intrinsics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698