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

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

Issue 2446543002: [turbofan] Support variable size argument popping in TF-generated functions (Closed)
Patch Set: Fix tests and arm64 Created 4 years, 1 month 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
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/branch-elimination.h" 5 #include "src/compiler/branch-elimination.h"
6 #include "src/compiler/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/linkage.h" 7 #include "src/compiler/linkage.h"
8 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
9 #include "test/unittests/compiler/compiler-test-utils.h" 9 #include "test/unittests/compiler/compiler-test-utils.h"
10 #include "test/unittests/compiler/graph-unittest.h" 10 #include "test/unittests/compiler/graph-unittest.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), 58 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2),
59 Int32Constant(1), Int32Constant(2), inner_merge); 59 Int32Constant(1), Int32Constant(2), inner_merge);
60 60
61 Node* outer_if_false = graph()->NewNode(common()->IfFalse(), outer_branch); 61 Node* outer_if_false = graph()->NewNode(common()->IfFalse(), outer_branch);
62 Node* outer_merge = 62 Node* outer_merge =
63 graph()->NewNode(common()->Merge(2), inner_merge, outer_if_false); 63 graph()->NewNode(common()->Merge(2), inner_merge, outer_if_false);
64 Node* outer_phi = 64 Node* outer_phi =
65 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), 65 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2),
66 inner_phi, Int32Constant(3), outer_merge); 66 inner_phi, Int32Constant(3), outer_merge);
67 67
68 Node* ret = graph()->NewNode(common()->Return(), outer_phi, graph()->start(), 68 Node* zero = graph()->NewNode(common()->Int32Constant(0));
69 outer_merge); 69 Node* ret = graph()->NewNode(common()->Return(), zero, outer_phi,
70 graph()->start(), outer_merge);
70 graph()->SetEnd(graph()->NewNode(common()->End(1), ret)); 71 graph()->SetEnd(graph()->NewNode(common()->End(1), ret));
71 72
72 Reduce(); 73 Reduce();
73 74
74 // Outer branch should not be rewritten, the inner branch should be discarded. 75 // Outer branch should not be rewritten, the inner branch should be discarded.
75 EXPECT_THAT(outer_branch, IsBranch(condition, graph()->start())); 76 EXPECT_THAT(outer_branch, IsBranch(condition, graph()->start()));
76 EXPECT_THAT(inner_phi, 77 EXPECT_THAT(inner_phi,
77 IsPhi(MachineRepresentation::kWord32, IsInt32Constant(1), 78 IsPhi(MachineRepresentation::kWord32, IsInt32Constant(1),
78 IsInt32Constant(2), IsMerge(outer_if_true, IsDead()))); 79 IsInt32Constant(2), IsMerge(outer_if_true, IsDead())));
79 } 80 }
(...skipping 19 matching lines...) Expand all
99 Node* inner_phi = 100 Node* inner_phi =
100 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), 101 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2),
101 Int32Constant(2), Int32Constant(3), inner_merge); 102 Int32Constant(2), Int32Constant(3), inner_merge);
102 103
103 Node* outer_merge = 104 Node* outer_merge =
104 graph()->NewNode(common()->Merge(2), outer_if_true, inner_merge); 105 graph()->NewNode(common()->Merge(2), outer_if_true, inner_merge);
105 Node* outer_phi = 106 Node* outer_phi =
106 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), 107 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2),
107 Int32Constant(1), inner_phi, outer_merge); 108 Int32Constant(1), inner_phi, outer_merge);
108 109
109 Node* ret = graph()->NewNode(common()->Return(), outer_phi, graph()->start(), 110 Node* zero = graph()->NewNode(common()->Int32Constant(0));
110 outer_merge); 111 Node* ret = graph()->NewNode(common()->Return(), zero, outer_phi,
112 graph()->start(), outer_merge);
111 graph()->SetEnd(graph()->NewNode(common()->End(1), ret)); 113 graph()->SetEnd(graph()->NewNode(common()->End(1), ret));
112 114
113 Reduce(); 115 Reduce();
114 116
115 // Outer branch should not be rewritten, the inner branch should be discarded. 117 // Outer branch should not be rewritten, the inner branch should be discarded.
116 EXPECT_THAT(outer_branch, IsBranch(condition, graph()->start())); 118 EXPECT_THAT(outer_branch, IsBranch(condition, graph()->start()));
117 EXPECT_THAT(inner_phi, 119 EXPECT_THAT(inner_phi,
118 IsPhi(MachineRepresentation::kWord32, IsInt32Constant(2), 120 IsPhi(MachineRepresentation::kWord32, IsInt32Constant(2),
119 IsInt32Constant(3), IsMerge(IsDead(), outer_if_false))); 121 IsInt32Constant(3), IsMerge(IsDead(), outer_if_false)));
120 } 122 }
(...skipping 16 matching lines...) Expand all
137 Node* branch2 = graph()->NewNode(common()->Branch(), condition, merge1); 139 Node* branch2 = graph()->NewNode(common()->Branch(), condition, merge1);
138 Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2); 140 Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2);
139 Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2); 141 Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2);
140 Node* merge2 = graph()->NewNode(common()->Merge(2), if_true2, if_false2); 142 Node* merge2 = graph()->NewNode(common()->Merge(2), if_true2, if_false2);
141 Node* phi2 = 143 Node* phi2 =
142 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), 144 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2),
143 Int32Constant(3), Int32Constant(4), merge1); 145 Int32Constant(3), Int32Constant(4), merge1);
144 146
145 147
146 Node* add = graph()->NewNode(machine()->Int32Add(), phi1, phi2); 148 Node* add = graph()->NewNode(machine()->Int32Add(), phi1, phi2);
149 Node* zero = graph()->NewNode(common()->Int32Constant(0));
147 Node* ret = 150 Node* ret =
148 graph()->NewNode(common()->Return(), add, graph()->start(), merge2); 151 graph()->NewNode(common()->Return(), zero, add, graph()->start(), merge2);
149 graph()->SetEnd(graph()->NewNode(common()->End(1), ret)); 152 graph()->SetEnd(graph()->NewNode(common()->End(1), ret));
150 153
151 Reduce(); 154 Reduce();
152 155
153 // Outer branch should not be rewritten, the inner branch condition should 156 // Outer branch should not be rewritten, the inner branch condition should
154 // be true. 157 // be true.
155 EXPECT_THAT(branch1, IsBranch(condition, graph()->start())); 158 EXPECT_THAT(branch1, IsBranch(condition, graph()->start()));
156 EXPECT_THAT(branch2, IsBranch(condition, merge1)); 159 EXPECT_THAT(branch2, IsBranch(condition, merge1));
157 } 160 }
158 161
(...skipping 10 matching lines...) Expand all
169 Node* outer_if_true = graph()->NewNode(common()->IfTrue(), outer_branch); 172 Node* outer_if_true = graph()->NewNode(common()->IfTrue(), outer_branch);
170 173
171 174
172 Node* loop = graph()->NewNode(common()->Loop(1), outer_if_true); 175 Node* loop = graph()->NewNode(common()->Loop(1), outer_if_true);
173 Node* effect = 176 Node* effect =
174 graph()->NewNode(common()->EffectPhi(1), graph()->start(), loop); 177 graph()->NewNode(common()->EffectPhi(1), graph()->start(), loop);
175 178
176 Node* inner_branch = graph()->NewNode(common()->Branch(), condition, loop); 179 Node* inner_branch = graph()->NewNode(common()->Branch(), condition, loop);
177 180
178 Node* inner_if_true = graph()->NewNode(common()->IfTrue(), inner_branch); 181 Node* inner_if_true = graph()->NewNode(common()->IfTrue(), inner_branch);
179 Node* ret1 = graph()->NewNode(common()->Return(), Int32Constant(2), effect, 182 Node* zero = graph()->NewNode(common()->Int32Constant(0));
180 inner_if_true); 183 Node* ret1 = graph()->NewNode(common()->Return(), zero, Int32Constant(2),
184 effect, inner_if_true);
181 185
182 Node* inner_if_false = graph()->NewNode(common()->IfFalse(), inner_branch); 186 Node* inner_if_false = graph()->NewNode(common()->IfFalse(), inner_branch);
183 loop->AppendInput(zone(), inner_if_false); 187 loop->AppendInput(zone(), inner_if_false);
184 NodeProperties::ChangeOp(loop, common()->Loop(2)); 188 NodeProperties::ChangeOp(loop, common()->Loop(2));
185 effect->InsertInput(zone(), 1, effect); 189 effect->InsertInput(zone(), 1, effect);
186 NodeProperties::ChangeOp(effect, common()->EffectPhi(2)); 190 NodeProperties::ChangeOp(effect, common()->EffectPhi(2));
187 191
188 Node* outer_if_false = graph()->NewNode(common()->IfFalse(), outer_branch); 192 Node* outer_if_false = graph()->NewNode(common()->IfFalse(), outer_branch);
189 Node* outer_merge = 193 Node* outer_merge =
190 graph()->NewNode(common()->Merge(2), loop, outer_if_false); 194 graph()->NewNode(common()->Merge(2), loop, outer_if_false);
191 Node* outer_ephi = graph()->NewNode(common()->EffectPhi(2), effect, 195 Node* outer_ephi = graph()->NewNode(common()->EffectPhi(2), effect,
192 graph()->start(), outer_merge); 196 graph()->start(), outer_merge);
193 197
194 Node* ret2 = graph()->NewNode(common()->Return(), Int32Constant(1), 198 Node* ret2 = graph()->NewNode(common()->Return(), zero, Int32Constant(1),
195 outer_ephi, outer_merge); 199 outer_ephi, outer_merge);
196 200
197 Node* terminate = graph()->NewNode(common()->Terminate(), effect, loop); 201 Node* terminate = graph()->NewNode(common()->Terminate(), effect, loop);
198 graph()->SetEnd(graph()->NewNode(common()->End(3), ret1, ret2, terminate)); 202 graph()->SetEnd(graph()->NewNode(common()->End(3), ret1, ret2, terminate));
199 203
200 Reduce(); 204 Reduce();
201 205
202 // Outer branch should not be rewritten, the inner branch should be discarded. 206 // Outer branch should not be rewritten, the inner branch should be discarded.
203 EXPECT_THAT(outer_branch, IsBranch(condition, graph()->start())); 207 EXPECT_THAT(outer_branch, IsBranch(condition, graph()->start()));
204 EXPECT_THAT(ret1, IsReturn(IsInt32Constant(2), effect, loop)); 208 EXPECT_THAT(ret1, IsReturn(IsInt32Constant(2), effect, loop));
205 } 209 }
206 210
207 } // namespace compiler 211 } // namespace compiler
208 } // namespace internal 212 } // namespace internal
209 } // namespace v8 213 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/wasm/wasm-run-utils.h ('k') | test/unittests/compiler/common-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698