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 "test/cctest/cctest.h" | 5 #include "test/cctest/cctest.h" |
6 | 6 |
7 #include "src/base/utils/random-number-generator.h" | 7 #include "src/base/utils/random-number-generator.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/machine-operator-reducer.h" | 10 #include "src/compiler/machine-operator-reducer.h" |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 R.CheckFoldBinop<int32_t>(1, zero, x); // 0 <= x => 1 | 696 R.CheckFoldBinop<int32_t>(1, zero, x); // 0 <= x => 1 |
697 R.CheckFoldBinop<int32_t>(1, x, x); // x <= x => 1 | 697 R.CheckFoldBinop<int32_t>(1, x, x); // x <= x => 1 |
698 } | 698 } |
699 | 699 |
700 | 700 |
701 TEST(ReduceLoadStore) { | 701 TEST(ReduceLoadStore) { |
702 ReducerTester R; | 702 ReducerTester R; |
703 | 703 |
704 Node* base = R.Constant<int32_t>(11); | 704 Node* base = R.Constant<int32_t>(11); |
705 Node* index = R.Constant<int32_t>(4); | 705 Node* index = R.Constant<int32_t>(4); |
706 Node* load = R.graph.NewNode(R.machine.Load(kMachInt32), base, index); | 706 Node* load = R.graph.NewNode(R.machine.Load(kMachInt32), base, index, |
| 707 R.graph.start(), R.graph.start()); |
707 | 708 |
708 { | 709 { |
709 MachineOperatorReducer reducer(&R.jsgraph); | 710 MachineOperatorReducer reducer(&R.jsgraph); |
710 Reduction reduction = reducer.Reduce(load); | 711 Reduction reduction = reducer.Reduce(load); |
711 CHECK(!reduction.Changed()); // loads should not be reduced. | 712 CHECK(!reduction.Changed()); // loads should not be reduced. |
712 } | 713 } |
713 | 714 |
714 { | 715 { |
715 Node* store = R.graph.NewNode( | 716 Node* store = R.graph.NewNode( |
716 R.machine.Store(StoreRepresentation(kMachInt32, kNoWriteBarrier)), base, | 717 R.machine.Store(StoreRepresentation(kMachInt32, kNoWriteBarrier)), base, |
717 index, load); | 718 index, load, load, load); |
718 MachineOperatorReducer reducer(&R.jsgraph); | 719 MachineOperatorReducer reducer(&R.jsgraph); |
719 Reduction reduction = reducer.Reduce(store); | 720 Reduction reduction = reducer.Reduce(store); |
720 CHECK(!reduction.Changed()); // stores should not be reduced. | 721 CHECK(!reduction.Changed()); // stores should not be reduced. |
721 } | 722 } |
722 } | 723 } |
723 | 724 |
724 | 725 |
725 // TODO(titzer): test MachineOperatorReducer for Word64And | 726 // TODO(titzer): test MachineOperatorReducer for Word64And |
726 // TODO(titzer): test MachineOperatorReducer for Word64Or | 727 // TODO(titzer): test MachineOperatorReducer for Word64Or |
727 // TODO(titzer): test MachineOperatorReducer for Word64Xor | 728 // TODO(titzer): test MachineOperatorReducer for Word64Xor |
(...skipping 12 matching lines...) Expand all Loading... |
740 // TODO(titzer): test MachineOperatorReducer for Uint64Mod | 741 // TODO(titzer): test MachineOperatorReducer for Uint64Mod |
741 // TODO(titzer): test MachineOperatorReducer for Int64Neg | 742 // TODO(titzer): test MachineOperatorReducer for Int64Neg |
742 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64 | 743 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64 |
743 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32 | 744 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32 |
744 // TODO(titzer): test MachineOperatorReducer for Float64Compare | 745 // TODO(titzer): test MachineOperatorReducer for Float64Compare |
745 // TODO(titzer): test MachineOperatorReducer for Float64Add | 746 // TODO(titzer): test MachineOperatorReducer for Float64Add |
746 // TODO(titzer): test MachineOperatorReducer for Float64Sub | 747 // TODO(titzer): test MachineOperatorReducer for Float64Sub |
747 // TODO(titzer): test MachineOperatorReducer for Float64Mul | 748 // TODO(titzer): test MachineOperatorReducer for Float64Mul |
748 // TODO(titzer): test MachineOperatorReducer for Float64Div | 749 // TODO(titzer): test MachineOperatorReducer for Float64Div |
749 // TODO(titzer): test MachineOperatorReducer for Float64Mod | 750 // TODO(titzer): test MachineOperatorReducer for Float64Mod |
OLD | NEW |