Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: test/unittests/compiler/move-optimizer-unittest.cc

Issue 755323011: [turbofan] optimize moves into merges (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 b8375fab10ad5267db5889fd03d227c75070ac2e..da887fe88a4a40f370cb4551f19ac120f35824d9 100644
--- a/test/unittests/compiler/move-optimizer-unittest.cc
+++ b/test/unittests/compiler/move-optimizer-unittest.cc
@@ -124,6 +124,59 @@ TEST_F(MoveOptimizerTest, SplitsConstants) {
CHECK(Contains(move, Reg(0), Slot(2)));
}
+
+TEST_F(MoveOptimizerTest, SimpleMerge) {
+ StartBlock();
+ EndBlock(Branch(Imm(), 1, 2));
+
+ StartBlock();
+ EndBlock(Jump(2));
+ AddMove(LastGap(), Reg(0), Reg(1));
+
+ StartBlock();
+ EndBlock(Jump(1));
+ AddMove(LastGap(), Reg(0), Reg(1));
+
+ StartBlock();
+ EndBlock(Last());
+
+ Optimize();
+
+ auto move = LastGap()->parallel_moves()[0];
+ CHECK_EQ(1, NonRedundantSize(move));
+ CHECK(Contains(move, Reg(0), Reg(1)));
+}
+
+
+TEST_F(MoveOptimizerTest, SimpleMergeCycle) {
+ StartBlock();
+ EndBlock(Branch(Imm(), 1, 2));
+
+ StartBlock();
+ EndBlock(Jump(2));
+ auto gap_0 = LastGap();
+ AddMove(gap_0, Reg(0), Reg(1));
+ AddMove(LastGap(), Reg(1), Reg(0));
+
+ StartBlock();
+ EndBlock(Jump(1));
+ auto gap_1 = LastGap();
+ AddMove(gap_1, Reg(0), Reg(1));
+ AddMove(gap_1, Reg(1), Reg(0));
+
+ StartBlock();
+ EndBlock(Last());
+
+ Optimize();
+
+ CHECK(gap_0->IsRedundant());
+ CHECK(gap_1->IsRedundant());
+ auto move = LastGap()->parallel_moves()[0];
+ CHECK_EQ(2, NonRedundantSize(move));
+ CHECK(Contains(move, Reg(0), Reg(1)));
+ CHECK(Contains(move, Reg(1), Reg(0)));
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8
« src/compiler/move-optimizer.cc ('K') | « src/compiler/register-allocator-verifier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698