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

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

Issue 1189963002: [turbofan] Remove ineffective optimization from ControlReducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove bogus tests. Created 5 years, 6 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/control-reducer.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/control-reducer.h" 5 #include "src/compiler/control-reducer.h"
6 #include "src/compiler/diamond.h" 6 #include "src/compiler/diamond.h"
7 #include "src/compiler/graph-visualizer.h" 7 #include "src/compiler/graph-visualizer.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/js-operator.h" 9 #include "src/compiler/js-operator.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 ReduceGraph(); 138 ReduceGraph();
139 139
140 // Branch should not be folded. 140 // Branch should not be folded.
141 EXPECT_THAT(phi1, 141 EXPECT_THAT(phi1,
142 IsPhi(kMachInt32, IsInt32Constant(111), IsInt32Constant(222), 142 IsPhi(kMachInt32, IsInt32Constant(111), IsInt32Constant(222),
143 IsMerge(IsIfTrue(branch1), IsIfFalse(branch1)))); 143 IsMerge(IsIfTrue(branch1), IsIfFalse(branch1))));
144 EXPECT_THAT(graph()->end(), IsEnd(IsReturn(phi1, graph()->start(), merge1))); 144 EXPECT_THAT(graph()->end(), IsEnd(IsReturn(phi1, graph()->start(), merge1)));
145 } 145 }
146 146
147 147
148 TEST_F(ControlReducerTest, RangeAsInputToBranch_true1) {
149 Node* p0 = Parameter(Type::Range(1, 2, zone()), 0);
150 Node* branch1 = graph()->NewNode(common()->Branch(), p0, graph()->start());
151 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
152 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
153 Node* merge1 = graph()->NewNode(common()->Merge(1), if_true1, if_false1);
154 Node* result = graph()->NewNode(common()->Phi(kMachInt32, 2),
155 jsgraph()->Int32Constant(11),
156 jsgraph()->Int32Constant(44), merge1);
157
158 Node* ret =
159 graph()->NewNode(common()->Return(), result, graph()->start(), merge1);
160 graph()->end()->ReplaceInput(0, ret);
161
162 ReduceGraph();
163
164 // Diamond should be folded away.
165 EXPECT_THAT(
166 graph()->end(),
167 IsEnd(IsReturn(IsInt32Constant(11), graph()->start(), graph()->start())));
168 }
169
170
171 TEST_F(ControlReducerTest, RangeAsInputToBranch_true2) {
172 Node* p0 = Parameter(Type::Range(-2, -1, zone()), 0);
173 Node* branch1 = graph()->NewNode(common()->Branch(), p0, graph()->start());
174 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
175 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
176 Node* merge1 = graph()->NewNode(common()->Merge(1), if_true1, if_false1);
177 Node* result = graph()->NewNode(common()->Phi(kMachInt32, 2),
178 jsgraph()->Int32Constant(11),
179 jsgraph()->Int32Constant(44), merge1);
180
181 Node* ret =
182 graph()->NewNode(common()->Return(), result, graph()->start(), merge1);
183 graph()->end()->ReplaceInput(0, ret);
184
185 ReduceGraph();
186
187 // Diamond should be folded away.
188 EXPECT_THAT(
189 graph()->end(),
190 IsEnd(IsReturn(IsInt32Constant(11), graph()->start(), graph()->start())));
191 }
192
193
194 TEST_F(ControlReducerTest, SelectPhi) { 148 TEST_F(ControlReducerTest, SelectPhi) {
195 Node* p0 = Parameter(0); 149 Node* p0 = Parameter(0);
196 const MachineType kType = kMachInt32; 150 const MachineType kType = kMachInt32;
197 Diamond d(graph(), common(), p0); 151 Diamond d(graph(), common(), p0);
198 Node* phi = 152 Node* phi =
199 d.Phi(kType, jsgraph()->Int32Constant(1), jsgraph()->Int32Constant(2)); 153 d.Phi(kType, jsgraph()->Int32Constant(1), jsgraph()->Int32Constant(2));
200 154
201 Node* ret = 155 Node* ret =
202 graph()->NewNode(common()->Return(), phi, graph()->start(), d.merge); 156 graph()->NewNode(common()->Return(), phi, graph()->start(), d.merge);
203 graph()->end()->ReplaceInput(0, ret); 157 graph()->end()->ReplaceInput(0, ret);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 IsReturn(IsInt32Add( 209 IsReturn(IsInt32Add(
256 IsSelect(kType, p0, IsInt32Constant(1), IsInt32Constant(2)), 210 IsSelect(kType, p0, IsInt32Constant(1), IsInt32Constant(2)),
257 IsSelect(kType, p0, IsInt32Constant(2), IsInt32Constant(3))), 211 IsSelect(kType, p0, IsInt32Constant(2), IsInt32Constant(3))),
258 graph()->start(), graph()->start())); 212 graph()->start(), graph()->start()));
259 EXPECT_THAT(graph()->end(), IsEnd(ret)); 213 EXPECT_THAT(graph()->end(), IsEnd(ret));
260 } 214 }
261 215
262 } // namespace compiler 216 } // namespace compiler
263 } // namespace internal 217 } // namespace internal
264 } // namespace v8 218 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/control-reducer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698