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

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

Issue 1000883003: [turbofan] Remove unused diamonds during control reduction. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 ControlReducerTester R; 687 ControlReducerTester R;
688 688
689 Node* merge = R.graph.NewNode(R.common.Merge(2), R.start, R.start); 689 Node* merge = R.graph.NewNode(R.common.Merge(2), R.start, R.start);
690 R.ReduceMerge(merge, merge); 690 R.ReduceMerge(merge, merge);
691 } 691 }
692 692
693 693
694 TEST(CMergeReduce_none2) { 694 TEST(CMergeReduce_none2) {
695 ControlReducerTester R; 695 ControlReducerTester R;
696 696
697 Node* t = R.graph.NewNode(R.common.IfTrue(), R.start); 697 Node* t1 = R.graph.NewNode(R.common.IfTrue(), R.start);
698 Node* f = R.graph.NewNode(R.common.IfFalse(), R.start); 698 Node* t2 = R.graph.NewNode(R.common.IfTrue(), R.start);
699 Node* merge = R.graph.NewNode(R.common.Merge(2), t, f); 699 Node* merge = R.graph.NewNode(R.common.Merge(2), t1, t2);
700 R.ReduceMerge(merge, merge); 700 R.ReduceMerge(merge, merge);
701 } 701 }
702 702
703 703
704 TEST(CMergeReduce_self3) { 704 TEST(CMergeReduce_self3) {
705 ControlReducerTester R; 705 ControlReducerTester R;
706 706
707 Node* merge = 707 Node* merge =
708 R.SetSelfReferences(R.graph.NewNode(R.common.Merge(2), R.start, R.self)); 708 R.SetSelfReferences(R.graph.NewNode(R.common.Merge(2), R.start, R.self));
709 R.ReduceMerge(merge, merge); 709 R.ReduceMerge(merge, merge);
(...skipping 27 matching lines...) Expand all
737 R.ReduceMerge(merge, merge); 737 R.ReduceMerge(merge, merge);
738 CheckMerge(merge, R.start, R.start); 738 CheckMerge(merge, R.start, R.start);
739 } 739 }
740 } 740 }
741 741
742 742
743 TEST(CMergeReduce_dead_rm1b) { 743 TEST(CMergeReduce_dead_rm1b) {
744 ControlReducerTester R; 744 ControlReducerTester R;
745 745
746 Node* t = R.graph.NewNode(R.common.IfTrue(), R.start); 746 Node* t = R.graph.NewNode(R.common.IfTrue(), R.start);
747 Node* f = R.graph.NewNode(R.common.IfFalse(), R.start); 747 Node* f = R.graph.NewNode(R.common.IfTrue(), R.start);
748 for (int i = 0; i < 2; i++) { 748 for (int i = 0; i < 2; i++) {
749 Node* merge = R.graph.NewNode(R.common.Merge(3), R.dead, R.dead, R.dead); 749 Node* merge = R.graph.NewNode(R.common.Merge(3), R.dead, R.dead, R.dead);
750 for (int j = i + 1; j < 3; j++) { 750 for (int j = i + 1; j < 3; j++) {
751 merge->ReplaceInput(i, t); 751 merge->ReplaceInput(i, t);
752 merge->ReplaceInput(j, f); 752 merge->ReplaceInput(j, f);
753 R.ReduceMerge(merge, merge); 753 R.ReduceMerge(merge, merge);
754 CheckMerge(merge, t, f); 754 CheckMerge(merge, t, f);
755 } 755 }
756 } 756 }
757 } 757 }
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 R.ReduceMergeIterative(R.start, d2.merge); 1111 R.ReduceMergeIterative(R.start, d2.merge);
1112 } 1112 }
1113 1113
1114 1114
1115 TEST(CChainedDiamondsReduce_x_false) { 1115 TEST(CChainedDiamondsReduce_x_false) {
1116 ControlReducerTester R; 1116 ControlReducerTester R;
1117 Diamond d1(R, R.p0); 1117 Diamond d1(R, R.p0);
1118 Diamond d2(R, R.zero); 1118 Diamond d2(R, R.zero);
1119 d2.chain(d1); 1119 d2.chain(d1);
1120 1120
1121 R.ReduceMergeIterative(d1.merge, d2.merge); 1121 R.ReduceMergeIterative(R.start, d2.merge);
1122 } 1122 }
1123 1123
1124 1124
1125 TEST(CChainedDiamondsReduce_false_x) { 1125 TEST(CChainedDiamondsReduce_false_x) {
1126 ControlReducerTester R; 1126 ControlReducerTester R;
1127 Diamond d1(R, R.zero); 1127 Diamond d1(R, R.zero);
1128 Diamond d2(R, R.p0); 1128 Diamond d2(R, R.p0);
1129 d2.chain(d1); 1129 d2.chain(d1);
1130 1130
1131 R.ReduceMergeIterative(d2.merge, d2.merge); 1131 R.ReduceMergeIterative(R.start, d2.merge);
1132 CheckInputs(d2.branch, R.p0, R.start);
1133 } 1132 }
1134 1133
1135 1134
1136 TEST(CChainedDiamondsReduce_phi1) { 1135 TEST(CChainedDiamondsReduce_phi1) {
1137 ControlReducerTester R; 1136 ControlReducerTester R;
1138 Diamond d1(R, R.zero, R.one, R.zero); // foldable branch, phi. 1137 Diamond d1(R, R.zero, R.one, R.zero); // foldable branch, phi.
1139 Diamond d2(R, d1.phi); 1138 Diamond d2(R, d1.phi);
1140 d2.chain(d1); 1139 d2.chain(d1);
1141 1140
1142 R.ReduceMergeIterative(R.start, d2.merge); 1141 R.ReduceMergeIterative(R.start, d2.merge);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 Diamond d2(R, R.jsgraph.Int32Constant(b)); 1182 Diamond d2(R, R.jsgraph.Int32Constant(b));
1184 d2.nest(d1, c); 1183 d2.nest(d1, c);
1185 1184
1186 R.ReduceMergeIterative(R.start, d1.merge); 1185 R.ReduceMergeIterative(R.start, d1.merge);
1187 } 1186 }
1188 } 1187 }
1189 } 1188 }
1190 } 1189 }
1191 1190
1192 1191
1192 TEST(CDeadDiamond) {
1193 ControlReducerTester R;
1194 // if (p0) { } else { }
1195 Diamond d(R, R.p0);
1196 R.ReduceMergeIterative(R.start, d.merge);
1197 }
1198
1199
1193 TEST(CDeadLoop1) { 1200 TEST(CDeadLoop1) {
1194 ControlReducerTester R; 1201 ControlReducerTester R;
1195 1202
1196 Node* loop = R.graph.NewNode(R.common.Loop(1), R.start); 1203 Node* loop = R.graph.NewNode(R.common.Loop(1), R.start);
1197 Branch b(R, R.p0, loop); 1204 Branch b(R, R.p0, loop);
1198 loop->ReplaceInput(0, b.if_true); // loop is not connected to start. 1205 loop->ReplaceInput(0, b.if_true); // loop is not connected to start.
1199 Node* merge = R.graph.NewNode(R.common.Merge(2), R.start, b.if_false); 1206 Node* merge = R.graph.NewNode(R.common.Merge(2), R.start, b.if_false);
1200 R.ReduceMergeIterative(R.start, merge); 1207 R.ReduceMergeIterative(R.start, merge);
1201 CHECK(b.if_true->IsDead()); 1208 CHECK(b.if_true->IsDead());
1202 CHECK(b.if_false->IsDead()); 1209 CHECK(b.if_false->IsDead());
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 1329
1323 d2.nest(d1, true); 1330 d2.nest(d1, true);
1324 d3.nest(d1, false); 1331 d3.nest(d1, false);
1325 1332
1326 Node* ret = R.Return(d1.phi, R.start, d1.merge); 1333 Node* ret = R.Return(d1.phi, R.start, d1.merge);
1327 1334
1328 R.ReduceGraph(); // nothing should happen. 1335 R.ReduceGraph(); // nothing should happen.
1329 1336
1330 CheckInputs(ret, d1.phi, R.start, d1.merge); 1337 CheckInputs(ret, d1.phi, R.start, d1.merge);
1331 CheckInputs(d1.phi, R.one, R.zero, d1.merge); 1338 CheckInputs(d1.phi, R.one, R.zero, d1.merge);
1332 CheckInputs(d1.merge, d2.merge, d3.merge); 1339 CheckInputs(d1.merge, d1.if_true, d1.if_false);
1333 CheckLiveDiamond(d2);
1334 CheckLiveDiamond(d3);
1335 } 1340 }
1336 1341
1337 1342
1338 TEST(Return_nested_diamonds_true1) { 1343 TEST(Return_nested_diamonds_true1) {
1339 ControlReducerTester R; 1344 ControlReducerTester R;
1340 Diamond d1(R, R.one, R.one, R.zero); 1345 Diamond d1(R, R.one, R.one, R.zero);
1341 Diamond d2(R, R.p0); 1346 Diamond d2(R, R.p0);
1342 Diamond d3(R, R.p0); 1347 Diamond d3(R, R.p0);
1343 1348
1344 d2.nest(d1, true); 1349 d2.nest(d1, true);
1345 d3.nest(d1, false); 1350 d3.nest(d1, false);
1346 1351
1347 Node* ret = R.Return(d1.phi, R.start, d1.merge); 1352 Node* ret = R.Return(d1.phi, R.start, d1.merge);
1348 1353
1349 R.ReduceGraph(); // d1 gets folded true. 1354 R.ReduceGraph(); // d1 gets folded true.
1350 1355
1351 CheckInputs(ret, R.one, R.start, d2.merge); 1356 CheckInputs(ret, R.one, R.start, R.start);
1352 CheckInputs(d2.branch, R.p0, R.start);
1353 CheckDeadDiamond(d1);
1354 CheckLiveDiamond(d2);
1355 CheckDeadDiamond(d3);
1356 } 1357 }
1357 1358
1358 1359
1359 TEST(Return_nested_diamonds_false1) { 1360 TEST(Return_nested_diamonds_false1) {
1360 ControlReducerTester R; 1361 ControlReducerTester R;
1361 Diamond d1(R, R.zero, R.one, R.zero); 1362 Diamond d1(R, R.zero, R.one, R.zero);
1362 Diamond d2(R, R.p0); 1363 Diamond d2(R, R.p0);
1363 Diamond d3(R, R.p0); 1364 Diamond d3(R, R.p0);
1364 1365
1365 d2.nest(d1, true); 1366 d2.nest(d1, true);
1366 d3.nest(d1, false); 1367 d3.nest(d1, false);
1367 1368
1368 Node* ret = R.Return(d1.phi, R.start, d1.merge); 1369 Node* ret = R.Return(d1.phi, R.start, d1.merge);
1369 1370
1370 R.ReduceGraph(); // d1 gets folded false. 1371 R.ReduceGraph(); // d1 gets folded false.
1371 1372
1372 CheckInputs(ret, R.zero, R.start, d3.merge); 1373 CheckInputs(ret, R.zero, R.start, R.start);
1373 CheckInputs(d3.branch, R.p0, R.start);
1374 CheckDeadDiamond(d1);
1375 CheckDeadDiamond(d2);
1376 CheckLiveDiamond(d3);
1377 } 1374 }
1378 1375
1379 1376
1380 TEST(Return_nested_diamonds_true_true1) { 1377 TEST(Return_nested_diamonds_true_true1) {
1381 ControlReducerTester R; 1378 ControlReducerTester R;
1382 Diamond d1(R, R.one, R.one, R.zero); 1379 Diamond d1(R, R.one, R.one, R.zero);
1383 Diamond d2(R, R.one); 1380 Diamond d2(R, R.one);
1384 Diamond d3(R, R.p0); 1381 Diamond d3(R, R.p0);
1385 1382
1386 d2.nest(d1, true); 1383 d2.nest(d1, true);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 1507
1511 Node* ret = R.Return(d1.phi, R.start, d1.merge); 1508 Node* ret = R.Return(d1.phi, R.start, d1.merge);
1512 1509
1513 R.ReduceGraph(); // d1 gets folded true. 1510 R.ReduceGraph(); // d1 gets folded true.
1514 1511
1515 CheckInputs(ret, y2, R.start, R.start); 1512 CheckInputs(ret, y2, R.start, R.start);
1516 CheckDeadDiamond(d1); 1513 CheckDeadDiamond(d1);
1517 CheckDeadDiamond(d2); 1514 CheckDeadDiamond(d2);
1518 CheckDeadDiamond(d3); 1515 CheckDeadDiamond(d3);
1519 } 1516 }
OLDNEW
« src/compiler/control-reducer.cc ('K') | « src/compiler/control-reducer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698