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

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

Issue 815743002: Revert of [turbofan] simplify gap ordering (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 | « test/unittests/compiler/instruction-selector-unittest.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 "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 {
11 11
12 class MoveOptimizerTest : public InstructionSequenceTest { 12 class MoveOptimizerTest : public InstructionSequenceTest {
13 public: 13 public:
14 GapInstruction* LastGap() { 14 GapInstruction* LastGap() {
15 return GapInstruction::cast(*(sequence()->instructions().rbegin() + 1)); 15 auto instruction = sequence()->instructions().back();
16 if (!instruction->IsGapMoves()) {
17 instruction = *(sequence()->instructions().rbegin() + 1);
18 }
19 return GapInstruction::cast(instruction);
16 } 20 }
17 21
18 void AddMove(GapInstruction* gap, TestOperand from, TestOperand to, 22 void AddMove(GapInstruction* gap, TestOperand from, TestOperand to,
19 GapInstruction::InnerPosition pos = GapInstruction::START) { 23 GapInstruction::InnerPosition pos = GapInstruction::START) {
20 auto parallel_move = gap->GetOrCreateParallelMove(pos, zone()); 24 auto parallel_move = gap->GetOrCreateParallelMove(pos, zone());
21 parallel_move->AddMove(ConvertMoveArg(from), ConvertMoveArg(to), zone()); 25 parallel_move->AddMove(ConvertMoveArg(from), ConvertMoveArg(to), zone());
22 } 26 }
23 27
24 int NonRedundantSize(ParallelMove* move) { 28 int NonRedundantSize(ParallelMove* move) {
25 int i = 0; 29 int i = 0;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 break; 83 break;
80 } 84 }
81 CHECK(false); 85 CHECK(false);
82 return nullptr; 86 return nullptr;
83 } 87 }
84 }; 88 };
85 89
86 90
87 TEST_F(MoveOptimizerTest, RemovesRedundant) { 91 TEST_F(MoveOptimizerTest, RemovesRedundant) {
88 StartBlock(); 92 StartBlock();
89 EmitNop();
90 AddMove(LastGap(), Reg(0), Reg(1)); 93 AddMove(LastGap(), Reg(0), Reg(1));
91 EmitNop(); 94 EmitNop();
92 AddMove(LastGap(), Reg(1), Reg(0)); 95 AddMove(LastGap(), Reg(1), Reg(0));
96 EmitNop();
93 EndBlock(Last()); 97 EndBlock(Last());
94 98
95 Optimize(); 99 Optimize();
96 100
97 auto gap = LastGap(); 101 auto gap = LastGap();
98 auto move = gap->parallel_moves()[0]; 102 auto move = gap->parallel_moves()[0];
99 CHECK_EQ(1, NonRedundantSize(move)); 103 CHECK_EQ(1, NonRedundantSize(move));
100 CHECK(Contains(move, Reg(0), Reg(1))); 104 CHECK(Contains(move, Reg(0), Reg(1)));
101 } 105 }
102 106
(...skipping 17 matching lines...) Expand all
120 move = gap->parallel_moves()[1]; 124 move = gap->parallel_moves()[1];
121 CHECK_EQ(3, NonRedundantSize(move)); 125 CHECK_EQ(3, NonRedundantSize(move));
122 CHECK(Contains(move, Reg(0), Slot(0))); 126 CHECK(Contains(move, Reg(0), Slot(0)));
123 CHECK(Contains(move, Reg(0), Slot(1))); 127 CHECK(Contains(move, Reg(0), Slot(1)));
124 CHECK(Contains(move, Reg(0), Slot(2))); 128 CHECK(Contains(move, Reg(0), Slot(2)));
125 } 129 }
126 130
127 } // namespace compiler 131 } // namespace compiler
128 } // namespace internal 132 } // namespace internal
129 } // namespace v8 133 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/instruction-selector-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698