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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 ++assignment; | 239 ++assignment; |
240 CHECK(move->destination().IsRegister()); | 240 CHECK(move->destination().IsRegister()); |
241 CHECK(move->source().IsConstant()); | 241 CHECK(move->source().IsConstant()); |
242 } | 242 } |
243 } | 243 } |
244 CHECK_EQ(1, redundants); | 244 CHECK_EQ(1, redundants); |
245 CHECK_EQ(1, assignment); | 245 CHECK_EQ(1, assignment); |
246 } | 246 } |
247 | 247 |
248 | 248 |
| 249 TEST_F(MoveOptimizerTest, SubsetMovesMerge) { |
| 250 StartBlock(); |
| 251 EndBlock(Branch(Imm(), 1, 2)); |
| 252 |
| 253 StartBlock(); |
| 254 EndBlock(Jump(2)); |
| 255 Instruction* last_move_b1 = LastInstruction(); |
| 256 AddMove(last_move_b1, Reg(0), Reg(1)); |
| 257 AddMove(last_move_b1, Reg(2), Reg(3)); |
| 258 |
| 259 StartBlock(); |
| 260 EndBlock(Jump(1)); |
| 261 Instruction* last_move_b2 = LastInstruction(); |
| 262 AddMove(last_move_b2, Reg(0), Reg(1)); |
| 263 AddMove(last_move_b2, Reg(4), Reg(5)); |
| 264 |
| 265 StartBlock(); |
| 266 EndBlock(Last()); |
| 267 |
| 268 Instruction* last = LastInstruction(); |
| 269 |
| 270 Optimize(); |
| 271 |
| 272 ParallelMove* last_move = last->parallel_moves()[0]; |
| 273 CHECK_EQ(1, NonRedundantSize(last_move)); |
| 274 CHECK(Contains(last_move, Reg(0), Reg(1))); |
| 275 |
| 276 ParallelMove* b1_move = last_move_b1->parallel_moves()[0]; |
| 277 CHECK_EQ(1, NonRedundantSize(b1_move)); |
| 278 CHECK(Contains(b1_move, Reg(2), Reg(3))); |
| 279 |
| 280 ParallelMove* b2_move = last_move_b2->parallel_moves()[0]; |
| 281 CHECK_EQ(1, NonRedundantSize(b2_move)); |
| 282 CHECK(Contains(b2_move, Reg(4), Reg(5))); |
| 283 } |
| 284 |
| 285 |
| 286 TEST_F(MoveOptimizerTest, GapConflictSubsetMovesDoNotMerge) { |
| 287 StartBlock(); |
| 288 EndBlock(Branch(Imm(), 1, 2)); |
| 289 |
| 290 StartBlock(); |
| 291 EndBlock(Jump(2)); |
| 292 Instruction* last_move_b1 = LastInstruction(); |
| 293 AddMove(last_move_b1, Reg(0), Reg(1)); |
| 294 AddMove(last_move_b1, Reg(2), Reg(0)); |
| 295 AddMove(last_move_b1, Reg(4), Reg(5)); |
| 296 |
| 297 StartBlock(); |
| 298 EndBlock(Jump(1)); |
| 299 Instruction* last_move_b2 = LastInstruction(); |
| 300 AddMove(last_move_b2, Reg(0), Reg(1)); |
| 301 AddMove(last_move_b2, Reg(4), Reg(5)); |
| 302 |
| 303 StartBlock(); |
| 304 EndBlock(Last()); |
| 305 |
| 306 Instruction* last = LastInstruction(); |
| 307 |
| 308 Optimize(); |
| 309 |
| 310 ParallelMove* last_move = last->parallel_moves()[0]; |
| 311 CHECK_EQ(1, NonRedundantSize(last_move)); |
| 312 CHECK(Contains(last_move, Reg(4), Reg(5))); |
| 313 |
| 314 ParallelMove* b1_move = last_move_b1->parallel_moves()[0]; |
| 315 CHECK_EQ(2, NonRedundantSize(b1_move)); |
| 316 CHECK(Contains(b1_move, Reg(0), Reg(1))); |
| 317 CHECK(Contains(b1_move, Reg(2), Reg(0))); |
| 318 |
| 319 ParallelMove* b2_move = last_move_b2->parallel_moves()[0]; |
| 320 CHECK_EQ(1, NonRedundantSize(b2_move)); |
| 321 CHECK(Contains(b1_move, Reg(0), Reg(1))); |
| 322 } |
| 323 |
| 324 |
249 } // namespace compiler | 325 } // namespace compiler |
250 } // namespace internal | 326 } // namespace internal |
251 } // namespace v8 | 327 } // namespace v8 |
OLD | NEW |