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/move-optimizer.h" | 5 #include "src/compiler/move-optimizer.h" |
6 #include "test/unittests/compiler/instruction-sequence-unittest.h" | 6 #include "test/unittests/compiler/instruction-sequence-unittest.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 namespace compiler { | 10 namespace compiler { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 Optimize(); | 97 Optimize(); |
98 | 98 |
99 CHECK_EQ(0, NonRedundantSize(first_instr->parallel_moves()[0])); | 99 CHECK_EQ(0, NonRedundantSize(first_instr->parallel_moves()[0])); |
100 auto move = last_instr->parallel_moves()[0]; | 100 auto move = last_instr->parallel_moves()[0]; |
101 CHECK_EQ(1, NonRedundantSize(move)); | 101 CHECK_EQ(1, NonRedundantSize(move)); |
102 CHECK(Contains(move, Reg(0), Reg(1))); | 102 CHECK(Contains(move, Reg(0), Reg(1))); |
103 } | 103 } |
104 | 104 |
105 | 105 |
106 TEST_F(MoveOptimizerTest, RemovesRedundantExplicit) { | 106 TEST_F(MoveOptimizerTest, RemovesRedundantExplicit) { |
| 107 int first_reg_index = |
| 108 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) |
| 109 ->GetAllocatableGeneralCode(0); |
| 110 int second_reg_index = |
| 111 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) |
| 112 ->GetAllocatableGeneralCode(1); |
| 113 |
107 StartBlock(); | 114 StartBlock(); |
108 auto first_instr = EmitNop(); | 115 auto first_instr = EmitNop(); |
109 AddMove(first_instr, Reg(0), ExplicitReg(1)); | 116 AddMove(first_instr, Reg(first_reg_index), ExplicitReg(second_reg_index)); |
110 auto last_instr = EmitNop(); | 117 auto last_instr = EmitNop(); |
111 AddMove(last_instr, Reg(1), Reg(0)); | 118 AddMove(last_instr, Reg(second_reg_index), Reg(first_reg_index)); |
112 EndBlock(Last()); | 119 EndBlock(Last()); |
113 | 120 |
114 Optimize(); | 121 Optimize(); |
115 | 122 |
116 CHECK_EQ(0, NonRedundantSize(first_instr->parallel_moves()[0])); | 123 CHECK_EQ(0, NonRedundantSize(first_instr->parallel_moves()[0])); |
117 auto move = last_instr->parallel_moves()[0]; | 124 auto move = last_instr->parallel_moves()[0]; |
118 CHECK_EQ(1, NonRedundantSize(move)); | 125 CHECK_EQ(1, NonRedundantSize(move)); |
119 CHECK(Contains(move, Reg(0), ExplicitReg(1))); | 126 CHECK(Contains(move, Reg(first_reg_index), ExplicitReg(second_reg_index))); |
120 } | 127 } |
121 | 128 |
122 | 129 |
123 TEST_F(MoveOptimizerTest, SplitsConstants) { | 130 TEST_F(MoveOptimizerTest, SplitsConstants) { |
124 StartBlock(); | 131 StartBlock(); |
125 EndBlock(Last()); | 132 EndBlock(Last()); |
126 | 133 |
127 auto gap = LastInstruction(); | 134 auto gap = LastInstruction(); |
128 AddMove(gap, Const(1), Slot(0)); | 135 AddMove(gap, Const(1), Slot(0)); |
129 AddMove(gap, Const(1), Slot(1)); | 136 AddMove(gap, Const(1), Slot(1)); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 CHECK(gap_1->AreMovesRedundant()); | 203 CHECK(gap_1->AreMovesRedundant()); |
197 auto move = last->parallel_moves()[0]; | 204 auto move = last->parallel_moves()[0]; |
198 CHECK_EQ(2, NonRedundantSize(move)); | 205 CHECK_EQ(2, NonRedundantSize(move)); |
199 CHECK(Contains(move, Reg(0), Reg(1))); | 206 CHECK(Contains(move, Reg(0), Reg(1))); |
200 CHECK(Contains(move, Reg(1), Reg(0))); | 207 CHECK(Contains(move, Reg(1), Reg(0))); |
201 } | 208 } |
202 | 209 |
203 } // namespace compiler | 210 } // namespace compiler |
204 } // namespace internal | 211 } // namespace internal |
205 } // namespace v8 | 212 } // namespace v8 |
OLD | NEW |