Index: test/unittests/compiler/move-optimizer-unittest.cc |
diff --git a/test/unittests/compiler/move-optimizer-unittest.cc b/test/unittests/compiler/move-optimizer-unittest.cc |
index 413c58b6feb48684bd1a50974896e219ef3326d6..a28580b16494a9671e5bbe0e04e9ce058f21f8db 100644 |
--- a/test/unittests/compiler/move-optimizer-unittest.cc |
+++ b/test/unittests/compiler/move-optimizer-unittest.cc |
@@ -246,6 +246,82 @@ TEST_F(MoveOptimizerTest, GapsCanMoveOverInstruction) { |
} |
+TEST_F(MoveOptimizerTest, SubsetMovesMerge) { |
+ StartBlock(); |
+ EndBlock(Branch(Imm(), 1, 2)); |
+ |
+ StartBlock(); |
+ EndBlock(Jump(2)); |
+ Instruction* last_move_b1 = LastInstruction(); |
+ AddMove(last_move_b1, Reg(0), Reg(1)); |
+ AddMove(last_move_b1, Reg(2), Reg(3)); |
+ |
+ StartBlock(); |
+ EndBlock(Jump(1)); |
+ Instruction* last_move_b2 = LastInstruction(); |
+ AddMove(last_move_b2, Reg(0), Reg(1)); |
+ AddMove(last_move_b2, Reg(4), Reg(5)); |
+ |
+ StartBlock(); |
+ EndBlock(Last()); |
+ |
+ Instruction* last = LastInstruction(); |
+ |
+ Optimize(); |
+ |
+ ParallelMove* last_move = last->parallel_moves()[0]; |
+ CHECK_EQ(1, NonRedundantSize(last_move)); |
+ CHECK(Contains(last_move, Reg(0), Reg(1))); |
+ |
+ ParallelMove* b1_move = last_move_b1->parallel_moves()[0]; |
+ CHECK_EQ(1, NonRedundantSize(b1_move)); |
+ CHECK(Contains(b1_move, Reg(2), Reg(3))); |
+ |
+ ParallelMove* b2_move = last_move_b2->parallel_moves()[0]; |
+ CHECK_EQ(1, NonRedundantSize(b2_move)); |
+ CHECK(Contains(b2_move, Reg(4), Reg(5))); |
+} |
+ |
+ |
+TEST_F(MoveOptimizerTest, GapConflictSubsetMovesDoNotMerge) { |
+ StartBlock(); |
+ EndBlock(Branch(Imm(), 1, 2)); |
+ |
+ StartBlock(); |
+ EndBlock(Jump(2)); |
+ Instruction* last_move_b1 = LastInstruction(); |
+ AddMove(last_move_b1, Reg(0), Reg(1)); |
+ AddMove(last_move_b1, Reg(2), Reg(0)); |
+ AddMove(last_move_b1, Reg(4), Reg(5)); |
+ |
+ StartBlock(); |
+ EndBlock(Jump(1)); |
+ Instruction* last_move_b2 = LastInstruction(); |
+ AddMove(last_move_b2, Reg(0), Reg(1)); |
+ AddMove(last_move_b2, Reg(4), Reg(5)); |
+ |
+ StartBlock(); |
+ EndBlock(Last()); |
+ |
+ Instruction* last = LastInstruction(); |
+ |
+ Optimize(); |
+ |
+ ParallelMove* last_move = last->parallel_moves()[0]; |
+ CHECK_EQ(1, NonRedundantSize(last_move)); |
+ CHECK(Contains(last_move, Reg(4), Reg(5))); |
+ |
+ ParallelMove* b1_move = last_move_b1->parallel_moves()[0]; |
+ CHECK_EQ(2, NonRedundantSize(b1_move)); |
+ CHECK(Contains(b1_move, Reg(0), Reg(1))); |
+ CHECK(Contains(b1_move, Reg(2), Reg(0))); |
+ |
+ ParallelMove* b2_move = last_move_b2->parallel_moves()[0]; |
+ CHECK_EQ(1, NonRedundantSize(b2_move)); |
+ CHECK(Contains(b1_move, Reg(0), Reg(1))); |
+} |
+ |
+ |
} // namespace compiler |
} // namespace internal |
} // namespace v8 |