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 9a31d2f770753d3bc17f318431cfb2b09df83b05..66eb9abc4f802b17e70df84c1dbf97b58f3f6244 100644 |
--- a/test/unittests/compiler/move-optimizer-unittest.cc |
+++ b/test/unittests/compiler/move-optimizer-unittest.cc |
@@ -207,6 +207,45 @@ TEST_F(MoveOptimizerTest, SimpleMergeCycle) { |
CHECK(Contains(move, Reg(1), Reg(0))); |
} |
+ |
+TEST_F(MoveOptimizerTest, GapsCanMoveOverInstruction) { |
+ StartBlock(); |
+ int const_index = 1; |
+ DefineConstant(const_index); |
+ Instruction* ctant_def = LastInstruction(); |
+ AddMove(ctant_def, Reg(1), Reg(0)); |
+ |
+ Instruction* last = EmitNop(); |
+ AddMove(last, Const(const_index), Reg(0)); |
+ AddMove(last, Reg(0), Reg(1)); |
+ EndBlock(Last()); |
+ Optimize(); |
+ |
+ ParallelMove* inst1_start = |
+ ctant_def->GetParallelMove(Instruction::GapPosition::START); |
+ ParallelMove* inst1_end = |
+ ctant_def->GetParallelMove(Instruction::GapPosition::END); |
+ ParallelMove* last_start = |
+ last->GetParallelMove(Instruction::GapPosition::START); |
+ CHECK(inst1_start == nullptr || inst1_start->size() == 0); |
Jarin
2015/10/29 14:53:14
Nit: In unit tests, we should always use EXPECT (o
|
+ CHECK(inst1_end == nullptr || inst1_end->size() == 0); |
+ CHECK(last_start->size() == 2); |
+ int redundants = 0; |
+ int assignment = 0; |
+ for (MoveOperands* move : *last_start) { |
+ if (move->IsRedundant()) { |
+ ++redundants; |
+ } else { |
+ ++assignment; |
+ CHECK(move->destination().IsRegister()); |
+ CHECK(move->source().IsConstant()); |
+ } |
+ } |
+ CHECK_EQ(1, redundants); |
+ CHECK_EQ(1, assignment); |
+} |
+ |
+ |
} // namespace compiler |
} // namespace internal |
} // namespace v8 |