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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 CHECK_EQ(1, NonRedundantSize(move)); 117 CHECK_EQ(1, NonRedundantSize(move));
118 CHECK(Contains(move, Const(1), Reg(0))); 118 CHECK(Contains(move, Const(1), Reg(0)));
119 119
120 move = gap->parallel_moves()[1]; 120 move = gap->parallel_moves()[1];
121 CHECK_EQ(3, NonRedundantSize(move)); 121 CHECK_EQ(3, NonRedundantSize(move));
122 CHECK(Contains(move, Reg(0), Slot(0))); 122 CHECK(Contains(move, Reg(0), Slot(0)));
123 CHECK(Contains(move, Reg(0), Slot(1))); 123 CHECK(Contains(move, Reg(0), Slot(1)));
124 CHECK(Contains(move, Reg(0), Slot(2))); 124 CHECK(Contains(move, Reg(0), Slot(2)));
125 } 125 }
126 126
127
128 TEST_F(MoveOptimizerTest, SimpleMerge) {
129 StartBlock();
130 EndBlock(Branch(Imm(), 1, 2));
131
132 StartBlock();
133 EndBlock(Jump(2));
134 AddMove(LastGap(), Reg(0), Reg(1));
135
136 StartBlock();
137 EndBlock(Jump(1));
138 AddMove(LastGap(), Reg(0), Reg(1));
139
140 StartBlock();
141 EndBlock(Last());
142
143 Optimize();
144
145 auto move = LastGap()->parallel_moves()[0];
146 CHECK_EQ(1, NonRedundantSize(move));
147 CHECK(Contains(move, Reg(0), Reg(1)));
148 }
149
150
151 TEST_F(MoveOptimizerTest, SimpleMergeCycle) {
152 StartBlock();
153 EndBlock(Branch(Imm(), 1, 2));
154
155 StartBlock();
156 EndBlock(Jump(2));
157 auto gap_0 = LastGap();
158 AddMove(gap_0, Reg(0), Reg(1));
159 AddMove(LastGap(), Reg(1), Reg(0));
160
161 StartBlock();
162 EndBlock(Jump(1));
163 auto gap_1 = LastGap();
164 AddMove(gap_1, Reg(0), Reg(1));
165 AddMove(gap_1, Reg(1), Reg(0));
166
167 StartBlock();
168 EndBlock(Last());
169
170 Optimize();
171
172 CHECK(gap_0->IsRedundant());
173 CHECK(gap_1->IsRedundant());
174 auto move = LastGap()->parallel_moves()[0];
175 CHECK_EQ(2, NonRedundantSize(move));
176 CHECK(Contains(move, Reg(0), Reg(1)));
177 CHECK(Contains(move, Reg(1), Reg(0)));
178 }
179
127 } // namespace compiler 180 } // namespace compiler
128 } // namespace internal 181 } // namespace internal
129 } // namespace v8 182 } // namespace v8
OLDNEW
« 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