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

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

Issue 1155683004: [turbofan] Connect loops to end via Terminate during graph building. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Also remove redundant EffectPhis now. 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 | « test/unittests/compiler/common-operator-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 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 OFStream os(stdout); 46 OFStream os(stdout);
47 os << "-- Graph after control reduction" << std::endl; 47 os << "-- Graph after control reduction" << std::endl;
48 os << AsRPO(*graph()); 48 os << AsRPO(*graph());
49 } 49 }
50 } 50 }
51 51
52 JSGraph* jsgraph() { return &jsgraph_; } 52 JSGraph* jsgraph() { return &jsgraph_; }
53 }; 53 };
54 54
55 55
56 TEST_F(ControlReducerTest, NonTerminatingLoop) {
57 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
58 loop->AppendInput(graph()->zone(), loop);
59 ReduceGraph();
60 EXPECT_THAT(graph()->end(),
61 IsEnd(graph()->start(),
62 IsTerminate(graph()->start(),
63 AllOf(loop, IsLoop(graph()->start(), loop)))));
64 }
65
66
67 TEST_F(ControlReducerTest, NonTerminatingLoopWithEffectPhi) {
68 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
69 loop->AppendInput(graph()->zone(), loop);
70 Node* ephi = graph()->NewNode(common()->EffectPhi(2), graph()->start());
71 ephi->AppendInput(graph()->zone(), ephi);
72 ephi->AppendInput(graph()->zone(), loop);
73 ReduceGraph();
74 EXPECT_THAT(
75 graph()->end(),
76 IsEnd(graph()->start(),
77 IsTerminate(AllOf(ephi, IsEffectPhi(graph()->start(), ephi, loop)),
78 AllOf(loop, IsLoop(graph()->start(), loop)))));
79 }
80
81
82 TEST_F(ControlReducerTest, NonTerminatingLoopWithTwoEffectPhis) {
83 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
84 loop->AppendInput(graph()->zone(), loop);
85 Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), graph()->start());
86 ephi1->AppendInput(graph()->zone(), ephi1);
87 ephi1->AppendInput(graph()->zone(), loop);
88 Node* ephi2 = graph()->NewNode(common()->EffectPhi(2), graph()->start());
89 ephi2->AppendInput(graph()->zone(), ephi2);
90 ephi2->AppendInput(graph()->zone(), loop);
91 ReduceGraph();
92 EXPECT_THAT(
93 graph()->end(),
94 IsEnd(graph()->start(),
95 IsTerminate(
96 IsEffectSet(
97 AllOf(ephi1, IsEffectPhi(graph()->start(), ephi1, loop)),
98 AllOf(ephi2, IsEffectPhi(graph()->start(), ephi2, loop))),
99 AllOf(loop, IsLoop(graph()->start(), loop)))));
100 }
101
102
103 TEST_F(ControlReducerTest, NonTerminatingLoopWithDeadEnd) {
104 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
105 loop->AppendInput(graph()->zone(), loop);
106 graph()->end()->ReplaceInput(0, graph()->NewNode(common()->Dead()));
107 ReduceGraph();
108 EXPECT_THAT(graph()->end(),
109 IsEnd(IsTerminate(graph()->start(),
110 AllOf(loop, IsLoop(graph()->start(), loop)))));
111 }
112
113
114 TEST_F(ControlReducerTest, PhiAsInputToBranch_true) { 56 TEST_F(ControlReducerTest, PhiAsInputToBranch_true) {
115 Node* p0 = Parameter(0); 57 Node* p0 = Parameter(0);
116 Node* branch1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); 58 Node* branch1 = graph()->NewNode(common()->Branch(), p0, graph()->start());
117 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1); 59 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
118 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1); 60 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
119 Node* merge1 = graph()->NewNode(common()->Merge(2), if_true1, if_false1); 61 Node* merge1 = graph()->NewNode(common()->Merge(2), if_true1, if_false1);
120 Node* phi1 = graph()->NewNode(common()->Phi(kMachInt32, 2), 62 Node* phi1 = graph()->NewNode(common()->Phi(kMachInt32, 2),
121 jsgraph()->Int32Constant(1), 63 jsgraph()->Int32Constant(1),
122 jsgraph()->Int32Constant(2), merge1); 64 jsgraph()->Int32Constant(2), merge1);
123 65
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 IsReturn(IsInt32Add( 255 IsReturn(IsInt32Add(
314 IsSelect(kType, p0, IsInt32Constant(1), IsInt32Constant(2)), 256 IsSelect(kType, p0, IsInt32Constant(1), IsInt32Constant(2)),
315 IsSelect(kType, p0, IsInt32Constant(2), IsInt32Constant(3))), 257 IsSelect(kType, p0, IsInt32Constant(2), IsInt32Constant(3))),
316 graph()->start(), graph()->start())); 258 graph()->start(), graph()->start()));
317 EXPECT_THAT(graph()->end(), IsEnd(ret)); 259 EXPECT_THAT(graph()->end(), IsEnd(ret));
318 } 260 }
319 261
320 } // namespace compiler 262 } // namespace compiler
321 } // namespace internal 263 } // namespace internal
322 } // namespace v8 264 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/common-operator-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698