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

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

Issue 1846933002: [turbofan] Handle dead diamonds in scheduling and add a test. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
« src/compiler/scheduler.cc ('K') | « test/cctest/wasm/test-run-wasm.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/schedule.h"
5 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
6 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/graph-visualizer.h"
7 #include "src/compiler/graph.h" 9 #include "src/compiler/graph.h"
8 #include "src/compiler/graph-visualizer.h"
9 #include "src/compiler/js-operator.h" 10 #include "src/compiler/js-operator.h"
11 #include "src/compiler/machine-operator.h"
10 #include "src/compiler/node.h" 12 #include "src/compiler/node.h"
11 #include "src/compiler/opcodes.h" 13 #include "src/compiler/opcodes.h"
12 #include "src/compiler/operator.h" 14 #include "src/compiler/operator.h"
13 #include "src/compiler/schedule.h"
14 #include "src/compiler/scheduler.h" 15 #include "src/compiler/scheduler.h"
15 #include "src/compiler/simplified-operator.h" 16 #include "src/compiler/simplified-operator.h"
16 #include "src/compiler/source-position.h" 17 #include "src/compiler/source-position.h"
17 #include "src/compiler/verifier.h" 18 #include "src/compiler/verifier.h"
18 #include "test/unittests/compiler/compiler-test-utils.h" 19 #include "test/unittests/compiler/compiler-test-utils.h"
19 #include "test/unittests/test-utils.h" 20 #include "test/unittests/test-utils.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
21 22
22 using testing::AnyOf; 23 using testing::AnyOf;
23 24
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 130 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
130 Node* d1 = CreateDiamond(graph(), common(), p0); 131 Node* d1 = CreateDiamond(graph(), common(), p0);
131 Node* ret = graph()->NewNode(common()->Return(), d1, start, start); 132 Node* ret = graph()->NewNode(common()->Return(), d1, start, start);
132 Node* end = graph()->NewNode(common()->End(1), ret); 133 Node* end = graph()->NewNode(common()->End(1), ret);
133 134
134 graph()->SetEnd(end); 135 graph()->SetEnd(end);
135 136
136 ComputeAndVerifySchedule(13); 137 ComputeAndVerifySchedule(13);
137 } 138 }
138 139
140 TARGET_TEST_F(SchedulerTest, FloatingDeadDiamond1) {
141 Node* start = graph()->NewNode(common()->Start(1));
142 graph()->SetStart(start);
143
144 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
145 Node* d1 = CreateDiamond(graph(), common(), p0);
146 USE(d1);
147 Node* ret = graph()->NewNode(common()->Return(), p0, start, start);
148 Node* end = graph()->NewNode(common()->End(1), ret);
149
150 graph()->SetEnd(end);
151
152 ComputeAndVerifySchedule(4);
153 }
154
155 TARGET_TEST_F(SchedulerTest, FloatingDeadDiamond2) {
156 Graph* g = graph();
157 Node* start = g->NewNode(common()->Start(1));
158 g->SetStart(start);
159
160 Node* n1 = g->NewNode(common()->Parameter(1), start);
161
162 Node* n2 = g->NewNode(common()->Branch(), n1, start);
163 Node* n3 = g->NewNode(common()->IfTrue(), n2);
164 Node* n4 = g->NewNode(common()->IfFalse(), n2);
165 Node* n5 = g->NewNode(common()->Int32Constant(-100));
166 Node* n6 = g->NewNode(common()->Return(), n5, start, n4);
167 Node* n7 = g->NewNode(common()->Int32Constant(0));
168 Node* n8 = g->NewNode(common()->Return(), n7, start, n3);
169 Node* n9 = g->NewNode(common()->End(2), n6, n8);
170
171 Zone zone;
172 MachineOperatorBuilder machine(&zone);
173
174 // Dead nodes
175 Node* n10 = g->NewNode(common()->Branch(), n1, n3);
176 Node* n11 = g->NewNode(common()->IfTrue(), n10);
177 Node* n12 = g->NewNode(common()->IfFalse(), n10);
178 Node* n13 = g->NewNode(common()->Merge(2), n11, n12);
179 Node* n14 =
180 g->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), n1, n7, n13);
181
182 USE(n14);
183
184 g->SetEnd(n9);
185
186 ComputeAndVerifySchedule(10);
187 }
139 188
140 TARGET_TEST_F(SchedulerTest, FloatingDiamond2) { 189 TARGET_TEST_F(SchedulerTest, FloatingDiamond2) {
141 Node* start = graph()->NewNode(common()->Start(2)); 190 Node* start = graph()->NewNode(common()->Start(2));
142 graph()->SetStart(start); 191 graph()->SetStart(start);
143 192
144 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 193 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
145 Node* p1 = graph()->NewNode(common()->Parameter(1), start); 194 Node* p1 = graph()->NewNode(common()->Parameter(1), start);
146 Node* d1 = CreateDiamond(graph(), common(), p0); 195 Node* d1 = CreateDiamond(graph(), common(), p0);
147 Node* d2 = CreateDiamond(graph(), common(), p1); 196 Node* d2 = CreateDiamond(graph(), common(), p1);
148 Node* add = graph()->NewNode(&kIntAdd, d1, d2); 197 Node* add = graph()->NewNode(&kIntAdd, d1, d2);
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 658
610 Schedule* schedule = ComputeAndVerifySchedule(6); 659 Schedule* schedule = ComputeAndVerifySchedule(6);
611 BasicBlock* block = schedule->block(loop); 660 BasicBlock* block = schedule->block(loop);
612 EXPECT_EQ(block, schedule->block(effect)); 661 EXPECT_EQ(block, schedule->block(effect));
613 EXPECT_GE(block->rpo_number(), 0); 662 EXPECT_GE(block->rpo_number(), 0);
614 } 663 }
615 664
616 } // namespace compiler 665 } // namespace compiler
617 } // namespace internal 666 } // namespace internal
618 } // namespace v8 667 } // namespace v8
OLDNEW
« src/compiler/scheduler.cc ('K') | « test/cctest/wasm/test-run-wasm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698