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/compiler/machine-operator-reducer.h" | 5 #include "src/compiler/machine-operator-reducer.h" |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/compiler/diamond.h" | 10 #include "src/compiler/diamond.h" |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 Float64Matcher m(node->InputAt(0)); | 441 Float64Matcher m(node->InputAt(0)); |
442 if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value())); | 442 if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value())); |
443 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0)); | 443 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0)); |
444 break; | 444 break; |
445 } | 445 } |
446 case IrOpcode::kFloat64InsertLowWord32: | 446 case IrOpcode::kFloat64InsertLowWord32: |
447 return ReduceFloat64InsertLowWord32(node); | 447 return ReduceFloat64InsertLowWord32(node); |
448 case IrOpcode::kFloat64InsertHighWord32: | 448 case IrOpcode::kFloat64InsertHighWord32: |
449 return ReduceFloat64InsertHighWord32(node); | 449 return ReduceFloat64InsertHighWord32(node); |
450 case IrOpcode::kStore: | 450 case IrOpcode::kStore: |
| 451 case IrOpcode::kCheckedStore: |
451 return ReduceStore(node); | 452 return ReduceStore(node); |
452 case IrOpcode::kFloat64Equal: | 453 case IrOpcode::kFloat64Equal: |
453 case IrOpcode::kFloat64LessThan: | 454 case IrOpcode::kFloat64LessThan: |
454 case IrOpcode::kFloat64LessThanOrEqual: | 455 case IrOpcode::kFloat64LessThanOrEqual: |
455 return ReduceFloat64Compare(node); | 456 return ReduceFloat64Compare(node); |
456 default: | 457 default: |
457 break; | 458 break; |
458 } | 459 } |
459 return NoChange(); | 460 return NoChange(); |
460 } | 461 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 node->TrimInputCount(2); | 650 node->TrimInputCount(2); |
650 NodeProperties::ChangeOp(node, machine()->Int32Sub()); | 651 NodeProperties::ChangeOp(node, machine()->Int32Sub()); |
651 } | 652 } |
652 return Changed(node); | 653 return Changed(node); |
653 } | 654 } |
654 return NoChange(); | 655 return NoChange(); |
655 } | 656 } |
656 | 657 |
657 | 658 |
658 Reduction MachineOperatorReducer::ReduceStore(Node* node) { | 659 Reduction MachineOperatorReducer::ReduceStore(Node* node) { |
659 MachineRepresentation const rep = | 660 NodeMatcher nm(node); |
660 StoreRepresentationOf(node->op()).representation(); | 661 MachineRepresentation rep; |
661 Node* const value = node->InputAt(2); | 662 int value_input; |
| 663 if (nm.IsCheckedStore()) { |
| 664 rep = CheckedStoreRepresentationOf(node->op()); |
| 665 value_input = 3; |
| 666 } else { |
| 667 rep = StoreRepresentationOf(node->op()).representation(); |
| 668 value_input = 2; |
| 669 } |
| 670 |
| 671 Node* const value = node->InputAt(value_input); |
| 672 |
662 switch (value->opcode()) { | 673 switch (value->opcode()) { |
663 case IrOpcode::kWord32And: { | 674 case IrOpcode::kWord32And: { |
664 Uint32BinopMatcher m(value); | 675 Uint32BinopMatcher m(value); |
665 if (m.right().HasValue() && ((rep == MachineRepresentation::kWord8 && | 676 if (m.right().HasValue() && ((rep == MachineRepresentation::kWord8 && |
666 (m.right().Value() & 0xff) == 0xff) || | 677 (m.right().Value() & 0xff) == 0xff) || |
667 (rep == MachineRepresentation::kWord16 && | 678 (rep == MachineRepresentation::kWord16 && |
668 (m.right().Value() & 0xffff) == 0xffff))) { | 679 (m.right().Value() & 0xffff) == 0xffff))) { |
669 node->ReplaceInput(2, m.left().node()); | 680 node->ReplaceInput(value_input, m.left().node()); |
670 return Changed(node); | 681 return Changed(node); |
671 } | 682 } |
672 break; | 683 break; |
673 } | 684 } |
674 case IrOpcode::kWord32Sar: { | 685 case IrOpcode::kWord32Sar: { |
675 Int32BinopMatcher m(value); | 686 Int32BinopMatcher m(value); |
676 if (m.left().IsWord32Shl() && ((rep == MachineRepresentation::kWord8 && | 687 if (m.left().IsWord32Shl() && ((rep == MachineRepresentation::kWord8 && |
677 m.right().IsInRange(1, 24)) || | 688 m.right().IsInRange(1, 24)) || |
678 (rep == MachineRepresentation::kWord16 && | 689 (rep == MachineRepresentation::kWord16 && |
679 m.right().IsInRange(1, 16)))) { | 690 m.right().IsInRange(1, 16)))) { |
680 Int32BinopMatcher mleft(m.left().node()); | 691 Int32BinopMatcher mleft(m.left().node()); |
681 if (mleft.right().Is(m.right().Value())) { | 692 if (mleft.right().Is(m.right().Value())) { |
682 node->ReplaceInput(2, mleft.left().node()); | 693 node->ReplaceInput(value_input, mleft.left().node()); |
683 return Changed(node); | 694 return Changed(node); |
684 } | 695 } |
685 } | 696 } |
686 break; | 697 break; |
687 } | 698 } |
688 default: | 699 default: |
689 break; | 700 break; |
690 } | 701 } |
691 return NoChange(); | 702 return NoChange(); |
692 } | 703 } |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 MachineOperatorBuilder* MachineOperatorReducer::machine() const { | 1072 MachineOperatorBuilder* MachineOperatorReducer::machine() const { |
1062 return jsgraph()->machine(); | 1073 return jsgraph()->machine(); |
1063 } | 1074 } |
1064 | 1075 |
1065 | 1076 |
1066 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } | 1077 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } |
1067 | 1078 |
1068 } // namespace compiler | 1079 } // namespace compiler |
1069 } // namespace internal | 1080 } // namespace internal |
1070 } // namespace v8 | 1081 } // namespace v8 |
OLD | NEW |