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

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

Issue 1634093002: [turbofan] fine grained in-block move optimization (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « src/compiler/register-allocator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "src/compiler/pipeline.h"
6 #include "test/unittests/compiler/instruction-sequence-unittest.h" 7 #include "test/unittests/compiler/instruction-sequence-unittest.h"
7 8
8 namespace v8 { 9 namespace v8 {
9 namespace internal { 10 namespace internal {
10 namespace compiler { 11 namespace compiler {
11 12
12 class MoveOptimizerTest : public InstructionSequenceTest { 13 class MoveOptimizerTest : public InstructionSequenceTest {
13 public: 14 public:
14 Instruction* LastInstruction() { return sequence()->instructions().back(); } 15 Instruction* LastInstruction() { return sequence()->instructions().back(); }
15 16
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 AddMove(last, Reg(0), Reg(1)); 221 AddMove(last, Reg(0), Reg(1));
221 EndBlock(Last()); 222 EndBlock(Last());
222 Optimize(); 223 Optimize();
223 224
224 ParallelMove* inst1_start = 225 ParallelMove* inst1_start =
225 ctant_def->GetParallelMove(Instruction::GapPosition::START); 226 ctant_def->GetParallelMove(Instruction::GapPosition::START);
226 ParallelMove* inst1_end = 227 ParallelMove* inst1_end =
227 ctant_def->GetParallelMove(Instruction::GapPosition::END); 228 ctant_def->GetParallelMove(Instruction::GapPosition::END);
228 ParallelMove* last_start = 229 ParallelMove* last_start =
229 last->GetParallelMove(Instruction::GapPosition::START); 230 last->GetParallelMove(Instruction::GapPosition::START);
230 CHECK(inst1_start == nullptr || inst1_start->size() == 0); 231 CHECK(inst1_start == nullptr || NonRedundantSize(inst1_start) == 0);
231 CHECK(inst1_end == nullptr || inst1_end->size() == 0); 232 CHECK(inst1_end == nullptr || NonRedundantSize(inst1_end) == 0);
232 CHECK(last_start->size() == 2); 233 CHECK(last_start->size() == 2);
233 int redundants = 0; 234 int redundants = 0;
234 int assignment = 0; 235 int assignment = 0;
235 for (MoveOperands* move : *last_start) { 236 for (MoveOperands* move : *last_start) {
236 if (move->IsRedundant()) { 237 if (move->IsRedundant()) {
237 ++redundants; 238 ++redundants;
238 } else { 239 } else {
239 ++assignment; 240 ++assignment;
240 CHECK(move->destination().IsRegister()); 241 CHECK(move->destination().IsRegister());
241 CHECK(move->source().IsConstant()); 242 CHECK(move->source().IsConstant());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 ParallelMove* b1_move = last_move_b1->parallel_moves()[0]; 315 ParallelMove* b1_move = last_move_b1->parallel_moves()[0];
315 CHECK_EQ(2, NonRedundantSize(b1_move)); 316 CHECK_EQ(2, NonRedundantSize(b1_move));
316 CHECK(Contains(b1_move, Reg(0), Reg(1))); 317 CHECK(Contains(b1_move, Reg(0), Reg(1)));
317 CHECK(Contains(b1_move, Reg(2), Reg(0))); 318 CHECK(Contains(b1_move, Reg(2), Reg(0)));
318 319
319 ParallelMove* b2_move = last_move_b2->parallel_moves()[0]; 320 ParallelMove* b2_move = last_move_b2->parallel_moves()[0];
320 CHECK_EQ(1, NonRedundantSize(b2_move)); 321 CHECK_EQ(1, NonRedundantSize(b2_move));
321 CHECK(Contains(b1_move, Reg(0), Reg(1))); 322 CHECK(Contains(b1_move, Reg(0), Reg(1)));
322 } 323 }
323 324
325 TEST_F(MoveOptimizerTest, ClobberedDestinationsAreEliminated) {
326 StartBlock();
327 EmitNop();
328 Instruction* first_instr = LastInstruction();
329 AddMove(first_instr, Reg(0), Reg(1));
330 EmitOI(Reg(1), 0, nullptr);
331 Instruction* last_instr = LastInstruction();
332 EndBlock();
333 Optimize();
334
335 ParallelMove* first_move = first_instr->parallel_moves()[0];
336 CHECK_EQ(0, NonRedundantSize(first_move));
337
338 ParallelMove* last_move = last_instr->parallel_moves()[0];
339 CHECK_EQ(0, NonRedundantSize(last_move));
340 }
324 341
325 } // namespace compiler 342 } // namespace compiler
326 } // namespace internal 343 } // namespace internal
327 } // namespace v8 344 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/register-allocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698