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

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

Issue 2485033002: X87: [turbofan] Refactor the compare-zero folding in instruction selector. (Closed)
Patch Set: Created 4 years, 1 month 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 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 return; 1426 return;
1427 } 1427 }
1428 } 1428 }
1429 VisitWordCompare(selector, node, kX87Cmp, cont); 1429 VisitWordCompare(selector, node, kX87Cmp, cont);
1430 } 1430 }
1431 1431
1432 1432
1433 // Shared routine for word comparison with zero. 1433 // Shared routine for word comparison with zero.
1434 void VisitWordCompareZero(InstructionSelector* selector, Node* user, 1434 void VisitWordCompareZero(InstructionSelector* selector, Node* user,
1435 Node* value, FlagsContinuation* cont) { 1435 Node* value, FlagsContinuation* cont) {
1436 // Try to combine the branch with a comparison. 1436 // Try to combine with comparisons against 0 by simply inverting the branch.
1437 while (selector->CanCover(user, value)) { 1437 while (value->opcode() == IrOpcode::kWord32Equal &&
1438 selector->CanCover(user, value)) {
1439 Int32BinopMatcher m(value);
1440 if (!m.right().Is(0)) break;
1441
1442 user = value;
1443 value = m.left().node();
1444 cont->Negate();
1445 }
1446
1447 if (selector->CanCover(user, value)) {
1438 switch (value->opcode()) { 1448 switch (value->opcode()) {
1439 case IrOpcode::kWord32Equal: { 1449 case IrOpcode::kWord32Equal:
1440 // Try to combine with comparisons against 0 by simply inverting the
1441 // continuation.
1442 Int32BinopMatcher m(value);
1443 if (m.right().Is(0)) {
1444 user = value;
1445 value = m.left().node();
1446 cont->Negate();
1447 continue;
1448 }
1449 cont->OverwriteAndNegateIfEqual(kEqual); 1450 cont->OverwriteAndNegateIfEqual(kEqual);
1450 return VisitWordCompare(selector, value, cont); 1451 return VisitWordCompare(selector, value, cont);
1451 }
1452 case IrOpcode::kInt32LessThan: 1452 case IrOpcode::kInt32LessThan:
1453 cont->OverwriteAndNegateIfEqual(kSignedLessThan); 1453 cont->OverwriteAndNegateIfEqual(kSignedLessThan);
1454 return VisitWordCompare(selector, value, cont); 1454 return VisitWordCompare(selector, value, cont);
1455 case IrOpcode::kInt32LessThanOrEqual: 1455 case IrOpcode::kInt32LessThanOrEqual:
1456 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); 1456 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual);
1457 return VisitWordCompare(selector, value, cont); 1457 return VisitWordCompare(selector, value, cont);
1458 case IrOpcode::kUint32LessThan: 1458 case IrOpcode::kUint32LessThan:
1459 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); 1459 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan);
1460 return VisitWordCompare(selector, value, cont); 1460 return VisitWordCompare(selector, value, cont);
1461 case IrOpcode::kUint32LessThanOrEqual: 1461 case IrOpcode::kUint32LessThanOrEqual:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 } 1507 }
1508 } 1508 }
1509 break; 1509 break;
1510 case IrOpcode::kInt32Sub: 1510 case IrOpcode::kInt32Sub:
1511 return VisitWordCompare(selector, value, cont); 1511 return VisitWordCompare(selector, value, cont);
1512 case IrOpcode::kWord32And: 1512 case IrOpcode::kWord32And:
1513 return VisitWordCompare(selector, value, kX87Test, cont); 1513 return VisitWordCompare(selector, value, kX87Test, cont);
1514 default: 1514 default:
1515 break; 1515 break;
1516 } 1516 }
1517 break;
1518 } 1517 }
1519 1518
1520 // Continuation could not be combined with a compare, emit compare against 0. 1519 // Continuation could not be combined with a compare, emit compare against 0.
1521 X87OperandGenerator g(selector); 1520 X87OperandGenerator g(selector);
1522 VisitCompare(selector, kX87Cmp, g.Use(value), g.TempImmediate(0), cont); 1521 VisitCompare(selector, kX87Cmp, g.Use(value), g.TempImmediate(0), cont);
1523 } 1522 }
1524 1523
1525 } // namespace 1524 } // namespace
1526 1525
1527 1526
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 // static 1781 // static
1783 MachineOperatorBuilder::AlignmentRequirements 1782 MachineOperatorBuilder::AlignmentRequirements
1784 InstructionSelector::AlignmentRequirements() { 1783 InstructionSelector::AlignmentRequirements() {
1785 return MachineOperatorBuilder::AlignmentRequirements:: 1784 return MachineOperatorBuilder::AlignmentRequirements::
1786 FullUnalignedAccessSupport(); 1785 FullUnalignedAccessSupport();
1787 } 1786 }
1788 1787
1789 } // namespace compiler 1788 } // namespace compiler
1790 } // namespace internal 1789 } // namespace internal
1791 } // namespace v8 1790 } // 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