OLD | NEW |
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 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 Diamond d2(R, R.jsgraph.Int32Constant(b)); | 1182 Diamond d2(R, R.jsgraph.Int32Constant(b)); |
1183 d2.nest(d1, c); | 1183 d2.nest(d1, c); |
1184 | 1184 |
1185 R.ReduceMergeIterative(R.start, d1.merge); | 1185 R.ReduceMergeIterative(R.start, d1.merge); |
1186 } | 1186 } |
1187 } | 1187 } |
1188 } | 1188 } |
1189 } | 1189 } |
1190 | 1190 |
1191 | 1191 |
1192 TEST(CDeadDiamond) { | 1192 TEST(CUnusedDiamond1) { |
1193 ControlReducerTester R; | 1193 ControlReducerTester R; |
1194 // if (p0) { } else { } | 1194 // if (p0) { } else { } |
1195 Diamond d(R, R.p0); | 1195 Node* branch = R.graph.NewNode(R.common.Branch(), R.p0, R.start); |
1196 R.ReduceMergeIterative(R.start, d.merge); | 1196 Node* if_true = R.graph.NewNode(R.common.IfTrue(), branch); |
| 1197 Node* if_false = R.graph.NewNode(R.common.IfFalse(), branch); |
| 1198 Node* merge = R.graph.NewNode(R.common.Merge(2), if_true, if_false); |
| 1199 R.ReduceMergeIterative(R.start, merge); |
1197 } | 1200 } |
1198 | 1201 |
1199 | 1202 |
| 1203 TEST(CUnusedDiamond2) { |
| 1204 ControlReducerTester R; |
| 1205 // if (p0) { } else { } |
| 1206 Node* branch = R.graph.NewNode(R.common.Branch(), R.p0, R.start); |
| 1207 Node* if_true = R.graph.NewNode(R.common.IfTrue(), branch); |
| 1208 Node* if_false = R.graph.NewNode(R.common.IfFalse(), branch); |
| 1209 Node* merge = R.graph.NewNode(R.common.Merge(2), if_false, if_true); |
| 1210 R.ReduceMergeIterative(R.start, merge); |
| 1211 } |
| 1212 |
| 1213 |
1200 TEST(CDeadLoop1) { | 1214 TEST(CDeadLoop1) { |
1201 ControlReducerTester R; | 1215 ControlReducerTester R; |
1202 | 1216 |
1203 Node* loop = R.graph.NewNode(R.common.Loop(1), R.start); | 1217 Node* loop = R.graph.NewNode(R.common.Loop(1), R.start); |
1204 Branch b(R, R.p0, loop); | 1218 Branch b(R, R.p0, loop); |
1205 loop->ReplaceInput(0, b.if_true); // loop is not connected to start. | 1219 loop->ReplaceInput(0, b.if_true); // loop is not connected to start. |
1206 Node* merge = R.graph.NewNode(R.common.Merge(2), R.start, b.if_false); | 1220 Node* merge = R.graph.NewNode(R.common.Merge(2), R.start, b.if_false); |
1207 R.ReduceMergeIterative(R.start, merge); | 1221 R.ReduceMergeIterative(R.start, merge); |
1208 CHECK(b.if_true->IsDead()); | 1222 CHECK(b.if_true->IsDead()); |
1209 CHECK(b.if_false->IsDead()); | 1223 CHECK(b.if_false->IsDead()); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 | 1521 |
1508 Node* ret = R.Return(d1.phi, R.start, d1.merge); | 1522 Node* ret = R.Return(d1.phi, R.start, d1.merge); |
1509 | 1523 |
1510 R.ReduceGraph(); // d1 gets folded true. | 1524 R.ReduceGraph(); // d1 gets folded true. |
1511 | 1525 |
1512 CheckInputs(ret, y2, R.start, R.start); | 1526 CheckInputs(ret, y2, R.start, R.start); |
1513 CheckDeadDiamond(d1); | 1527 CheckDeadDiamond(d1); |
1514 CheckDeadDiamond(d2); | 1528 CheckDeadDiamond(d2); |
1515 CheckDeadDiamond(d3); | 1529 CheckDeadDiamond(d3); |
1516 } | 1530 } |
OLD | NEW |