OLD | NEW |
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 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 return; | 1386 return; |
1387 } | 1387 } |
1388 } | 1388 } |
1389 VisitWordCompare(selector, node, kIA32Cmp, cont); | 1389 VisitWordCompare(selector, node, kIA32Cmp, cont); |
1390 } | 1390 } |
1391 | 1391 |
1392 | 1392 |
1393 // Shared routine for word comparison with zero. | 1393 // Shared routine for word comparison with zero. |
1394 void VisitWordCompareZero(InstructionSelector* selector, Node* user, | 1394 void VisitWordCompareZero(InstructionSelector* selector, Node* user, |
1395 Node* value, FlagsContinuation* cont) { | 1395 Node* value, FlagsContinuation* cont) { |
1396 // Try to combine the branch with a comparison. | 1396 // Try to combine with comparisons against 0 by simply inverting the branch. |
1397 while (selector->CanCover(user, value)) { | 1397 while (value->opcode() == IrOpcode::kWord32Equal && |
| 1398 selector->CanCover(user, value)) { |
| 1399 Int32BinopMatcher m(value); |
| 1400 if (!m.right().Is(0)) break; |
| 1401 |
| 1402 user = value; |
| 1403 value = m.left().node(); |
| 1404 cont->Negate(); |
| 1405 } |
| 1406 |
| 1407 if (selector->CanCover(user, value)) { |
1398 switch (value->opcode()) { | 1408 switch (value->opcode()) { |
1399 case IrOpcode::kWord32Equal: { | 1409 case IrOpcode::kWord32Equal: |
1400 // Try to combine with comparisons against 0 by simply inverting the | |
1401 // continuation. | |
1402 Int32BinopMatcher m(value); | |
1403 if (m.right().Is(0)) { | |
1404 user = value; | |
1405 value = m.left().node(); | |
1406 cont->Negate(); | |
1407 continue; | |
1408 } | |
1409 cont->OverwriteAndNegateIfEqual(kEqual); | 1410 cont->OverwriteAndNegateIfEqual(kEqual); |
1410 return VisitWordCompare(selector, value, cont); | 1411 return VisitWordCompare(selector, value, cont); |
1411 } | |
1412 case IrOpcode::kInt32LessThan: | 1412 case IrOpcode::kInt32LessThan: |
1413 cont->OverwriteAndNegateIfEqual(kSignedLessThan); | 1413 cont->OverwriteAndNegateIfEqual(kSignedLessThan); |
1414 return VisitWordCompare(selector, value, cont); | 1414 return VisitWordCompare(selector, value, cont); |
1415 case IrOpcode::kInt32LessThanOrEqual: | 1415 case IrOpcode::kInt32LessThanOrEqual: |
1416 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); | 1416 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); |
1417 return VisitWordCompare(selector, value, cont); | 1417 return VisitWordCompare(selector, value, cont); |
1418 case IrOpcode::kUint32LessThan: | 1418 case IrOpcode::kUint32LessThan: |
1419 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); | 1419 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); |
1420 return VisitWordCompare(selector, value, cont); | 1420 return VisitWordCompare(selector, value, cont); |
1421 case IrOpcode::kUint32LessThanOrEqual: | 1421 case IrOpcode::kUint32LessThanOrEqual: |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1467 } | 1467 } |
1468 } | 1468 } |
1469 break; | 1469 break; |
1470 case IrOpcode::kInt32Sub: | 1470 case IrOpcode::kInt32Sub: |
1471 return VisitWordCompare(selector, value, cont); | 1471 return VisitWordCompare(selector, value, cont); |
1472 case IrOpcode::kWord32And: | 1472 case IrOpcode::kWord32And: |
1473 return VisitWordCompare(selector, value, kIA32Test, cont); | 1473 return VisitWordCompare(selector, value, kIA32Test, cont); |
1474 default: | 1474 default: |
1475 break; | 1475 break; |
1476 } | 1476 } |
1477 break; | |
1478 } | 1477 } |
1479 | 1478 |
1480 // Continuation could not be combined with a compare, emit compare against 0. | 1479 // Continuation could not be combined with a compare, emit compare against 0. |
1481 IA32OperandGenerator g(selector); | 1480 IA32OperandGenerator g(selector); |
1482 VisitCompare(selector, kIA32Cmp, g.Use(value), g.TempImmediate(0), cont); | 1481 VisitCompare(selector, kIA32Cmp, g.Use(value), g.TempImmediate(0), cont); |
1483 } | 1482 } |
1484 | 1483 |
1485 } // namespace | 1484 } // namespace |
1486 | 1485 |
1487 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, | 1486 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 // static | 1747 // static |
1749 MachineOperatorBuilder::AlignmentRequirements | 1748 MachineOperatorBuilder::AlignmentRequirements |
1750 InstructionSelector::AlignmentRequirements() { | 1749 InstructionSelector::AlignmentRequirements() { |
1751 return MachineOperatorBuilder::AlignmentRequirements:: | 1750 return MachineOperatorBuilder::AlignmentRequirements:: |
1752 FullUnalignedAccessSupport(); | 1751 FullUnalignedAccessSupport(); |
1753 } | 1752 } |
1754 | 1753 |
1755 } // namespace compiler | 1754 } // namespace compiler |
1756 } // namespace internal | 1755 } // namespace internal |
1757 } // namespace v8 | 1756 } // namespace v8 |
OLD | NEW |