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

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

Issue 920573004: [turbofan] Fix control reducer for dead loops. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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/osr.cc ('k') | test/cctest/compiler/test-osr.cc » ('j') | 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/v8.h" 5 #include "src/v8.h"
6 #include "test/cctest/cctest.h" 6 #include "test/cctest/cctest.h"
7 7
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/compiler/common-operator.h" 9 #include "src/compiler/common-operator.h"
10 #include "src/compiler/control-reducer.h" 10 #include "src/compiler/control-reducer.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 p0->ReplaceInput(0, start); // hack: parameters may be trimmed. 157 p0->ReplaceInput(0, start); // hack: parameters may be trimmed.
158 Node* ret = graph.NewNode(common.Return(), phi, start, start); 158 Node* ret = graph.NewNode(common.Return(), phi, start, start);
159 Node* end = graph.NewNode(common.End(), ret); 159 Node* end = graph.NewNode(common.End(), ret);
160 graph.SetEnd(end); 160 graph.SetEnd(end);
161 ControlReducer::ReduceGraph(main_zone(), &jsgraph, &common); 161 ControlReducer::ReduceGraph(main_zone(), &jsgraph, &common);
162 CheckInputs(end, ret); 162 CheckInputs(end, ret);
163 CheckInputs(ret, expect, start, start); 163 CheckInputs(ret, expect, start, start);
164 } 164 }
165 165
166 void ReduceMerge(Node* expect, Node* merge) { 166 void ReduceMerge(Node* expect, Node* merge) {
167 Node* result = 167 Node* result = ControlReducer::ReduceMerge(&jsgraph, &common, merge);
168 ControlReducer::ReduceMergeForTesting(&jsgraph, &common, merge);
169 CHECK_EQ(expect, result); 168 CHECK_EQ(expect, result);
170 } 169 }
171 170
172 void ReduceMergeIterative(Node* expect, Node* merge) { 171 void ReduceMergeIterative(Node* expect, Node* merge) {
173 p0->ReplaceInput(0, start); // hack: parameters may be trimmed. 172 p0->ReplaceInput(0, start); // hack: parameters may be trimmed.
174 Node* end = graph.NewNode(common.End(), merge); 173 Node* end = graph.NewNode(common.End(), merge);
175 graph.SetEnd(end); 174 graph.SetEnd(end);
176 ReduceGraph(); 175 ReduceGraph();
177 CheckInputs(end, expect); 176 CheckInputs(end, expect);
178 } 177 }
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 Node* phi_use = 866 Node* phi_use =
868 R.graph.NewNode(R.common.Phi(kMachAnyTagged, 1), phi, R.start); 867 R.graph.NewNode(R.common.Phi(kMachAnyTagged, 1), phi, R.start);
869 Node* ephi_use = R.graph.NewNode(R.common.EffectPhi(1), ephi, R.start); 868 Node* ephi_use = R.graph.NewNode(R.common.EffectPhi(1), ephi, R.start);
870 869
871 Selector selector(mask); 870 Selector selector(mask);
872 871
873 for (int i = 0; i < kSelectorSize; i++) { // set up dead merge inputs. 872 for (int i = 0; i < kSelectorSize; i++) { // set up dead merge inputs.
874 if (!selector.is_selected(i)) merge->ReplaceInput(i, R.dead); 873 if (!selector.is_selected(i)) merge->ReplaceInput(i, R.dead);
875 } 874 }
876 875
877 Node* result = 876 Node* result = ControlReducer::ReduceMerge(&R.jsgraph, &R.common, merge);
878 ControlReducer::ReduceMergeForTesting(&R.jsgraph, &R.common, merge);
879 877
880 int count = selector.count; 878 int count = selector.count;
881 if (count == 0) { 879 if (count == 0) {
882 // result should be dead. 880 // result should be dead.
883 CHECK_EQ(IrOpcode::kDead, result->opcode()); 881 CHECK_EQ(IrOpcode::kDead, result->opcode());
884 } else if (count == 1) { 882 } else if (count == 1) {
885 // merge should be replaced with one of the controls. 883 // merge should be replaced with one of the controls.
886 CHECK_EQ(controls[selector.single_index()], result); 884 CHECK_EQ(controls[selector.single_index()], result);
887 // Phis should have been directly replaced. 885 // Phis should have been directly replaced.
888 CHECK_EQ(values[selector.single_index()], phi_use->InputAt(0)); 886 CHECK_EQ(values[selector.single_index()], phi_use->InputAt(0));
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 1504
1507 Node* ret = R.Return(d1.phi, R.start, d1.merge); 1505 Node* ret = R.Return(d1.phi, R.start, d1.merge);
1508 1506
1509 R.ReduceGraph(); // d1 gets folded true. 1507 R.ReduceGraph(); // d1 gets folded true.
1510 1508
1511 CheckInputs(ret, y2, R.start, R.start); 1509 CheckInputs(ret, y2, R.start, R.start);
1512 CheckDeadDiamond(d1); 1510 CheckDeadDiamond(d1);
1513 CheckDeadDiamond(d2); 1511 CheckDeadDiamond(d2);
1514 CheckDeadDiamond(d3); 1512 CheckDeadDiamond(d3);
1515 } 1513 }
OLDNEW
« no previous file with comments | « src/compiler/osr.cc ('k') | test/cctest/compiler/test-osr.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698