| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 Optimize(); | 200 Optimize(); |
| 201 | 201 |
| 202 CHECK(gap_0->AreMovesRedundant()); | 202 CHECK(gap_0->AreMovesRedundant()); |
| 203 CHECK(gap_1->AreMovesRedundant()); | 203 CHECK(gap_1->AreMovesRedundant()); |
| 204 auto move = last->parallel_moves()[0]; | 204 auto move = last->parallel_moves()[0]; |
| 205 CHECK_EQ(2, NonRedundantSize(move)); | 205 CHECK_EQ(2, NonRedundantSize(move)); |
| 206 CHECK(Contains(move, Reg(0), Reg(1))); | 206 CHECK(Contains(move, Reg(0), Reg(1))); |
| 207 CHECK(Contains(move, Reg(1), Reg(0))); | 207 CHECK(Contains(move, Reg(1), Reg(0))); |
| 208 } | 208 } |
| 209 | 209 |
| 210 |
| 211 TEST_F(MoveOptimizerTest, GapsCanMoveOverInstruction) { |
| 212 StartBlock(); |
| 213 int const_index = 1; |
| 214 DefineConstant(const_index); |
| 215 Instruction* ctant_def = LastInstruction(); |
| 216 AddMove(ctant_def, Reg(1), Reg(0)); |
| 217 |
| 218 Instruction* last = EmitNop(); |
| 219 AddMove(last, Const(const_index), Reg(0)); |
| 220 AddMove(last, Reg(0), Reg(1)); |
| 221 EndBlock(Last()); |
| 222 Optimize(); |
| 223 |
| 224 ParallelMove* inst1_start = |
| 225 ctant_def->GetParallelMove(Instruction::GapPosition::START); |
| 226 ParallelMove* inst1_end = |
| 227 ctant_def->GetParallelMove(Instruction::GapPosition::END); |
| 228 ParallelMove* last_start = |
| 229 last->GetParallelMove(Instruction::GapPosition::START); |
| 230 CHECK(inst1_start == nullptr || inst1_start->size() == 0); |
| 231 CHECK(inst1_end == nullptr || inst1_end->size() == 0); |
| 232 CHECK(last_start->size() == 2); |
| 233 int redundants = 0; |
| 234 int assignment = 0; |
| 235 for (MoveOperands* move : *last_start) { |
| 236 if (move->IsRedundant()) { |
| 237 ++redundants; |
| 238 } else { |
| 239 ++assignment; |
| 240 CHECK(move->destination().IsRegister()); |
| 241 CHECK(move->source().IsConstant()); |
| 242 } |
| 243 } |
| 244 CHECK_EQ(1, redundants); |
| 245 CHECK_EQ(1, assignment); |
| 246 } |
| 247 |
| 248 |
| 210 } // namespace compiler | 249 } // namespace compiler |
| 211 } // namespace internal | 250 } // namespace internal |
| 212 } // namespace v8 | 251 } // namespace v8 |
| OLD | NEW |