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/all-nodes.h" | 9 #include "src/compiler/all-nodes.h" |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 ControlReducerTester R; | 895 ControlReducerTester R; |
896 Diamond d1(R, R.p0); | 896 Diamond d1(R, R.p0); |
897 Diamond d2(R, R.p0); | 897 Diamond d2(R, R.p0); |
898 d2.chain(d1); | 898 d2.chain(d1); |
899 R.ReduceBranch(kUnknown, d2.branch); | 899 R.ReduceBranch(kUnknown, d2.branch); |
900 } | 900 } |
901 | 901 |
902 | 902 |
903 TEST(CBranchReduce_true) { | 903 TEST(CBranchReduce_true) { |
904 ControlReducerTester R; | 904 ControlReducerTester R; |
905 Node* true_values[] = { | 905 Node* true_values[] = {R.jsgraph.Int32Constant(2), |
906 R.one, R.jsgraph.Int32Constant(2), | 906 R.jsgraph.Int64Constant(0x7fffffff), |
907 R.jsgraph.Int32Constant(0x7fffffff), R.jsgraph.Constant(1.0), | 907 R.jsgraph.TrueConstant()}; |
908 R.jsgraph.Constant(22.1), R.jsgraph.TrueConstant()}; | |
909 | |
910 for (size_t i = 0; i < arraysize(true_values); i++) { | 908 for (size_t i = 0; i < arraysize(true_values); i++) { |
911 Diamond d(R, true_values[i]); | 909 Diamond d(R, true_values[i]); |
912 R.ReduceBranch(kTrue, d.branch); | 910 R.ReduceBranch(kTrue, d.branch); |
913 } | 911 } |
914 } | 912 } |
915 | 913 |
916 | 914 |
917 TEST(CBranchReduce_false) { | 915 TEST(CBranchReduce_false) { |
918 ControlReducerTester R; | 916 ControlReducerTester R; |
919 Node* false_values[] = {R.zero, R.jsgraph.Constant(0.0), | 917 Node* false_values[] = {R.jsgraph.Int32Constant(0), |
920 R.jsgraph.Constant(-0.0), R.jsgraph.FalseConstant()}; | 918 R.jsgraph.Int64Constant(0), |
921 | 919 R.jsgraph.FalseConstant()}; |
922 for (size_t i = 0; i < arraysize(false_values); i++) { | 920 for (size_t i = 0; i < arraysize(false_values); i++) { |
923 Diamond d(R, false_values[i]); | 921 Diamond d(R, false_values[i]); |
924 R.ReduceBranch(kFalse, d.branch); | 922 R.ReduceBranch(kFalse, d.branch); |
925 } | 923 } |
926 } | 924 } |
927 | 925 |
928 | 926 |
929 TEST(CDiamondReduce_true) { | 927 TEST(CDiamondReduce_true) { |
930 ControlReducerTester R; | 928 ControlReducerTester R; |
931 Diamond d1(R, R.one); | 929 Diamond d1(R, R.jsgraph.TrueConstant()); |
932 R.ReduceMergeIterative(R.start, d1.merge); | 930 R.ReduceMergeIterative(R.start, d1.merge); |
933 } | 931 } |
934 | 932 |
935 | 933 |
936 TEST(CDiamondReduce_false) { | 934 TEST(CDiamondReduce_false) { |
937 ControlReducerTester R; | 935 ControlReducerTester R; |
938 Diamond d2(R, R.zero); | 936 Diamond d2(R, R.jsgraph.FalseConstant()); |
939 R.ReduceMergeIterative(R.start, d2.merge); | 937 R.ReduceMergeIterative(R.start, d2.merge); |
940 } | 938 } |
941 | 939 |
942 | 940 |
943 TEST(CChainedDiamondsReduce_true_false) { | 941 TEST(CChainedDiamondsReduce_true_false) { |
944 ControlReducerTester R; | 942 ControlReducerTester R; |
945 Diamond d1(R, R.one); | 943 Diamond d1(R, R.jsgraph.TrueConstant()); |
946 Diamond d2(R, R.zero); | 944 Diamond d2(R, R.jsgraph.FalseConstant()); |
947 d2.chain(d1); | 945 d2.chain(d1); |
948 | 946 |
949 R.ReduceMergeIterative(R.start, d2.merge); | 947 R.ReduceMergeIterative(R.start, d2.merge); |
950 } | 948 } |
951 | 949 |
952 | 950 |
953 TEST(CChainedDiamondsReduce_x_false) { | 951 TEST(CChainedDiamondsReduce_x_false) { |
954 ControlReducerTester R; | 952 ControlReducerTester R; |
955 Diamond d1(R, R.p0); | 953 Diamond d1(R, R.p0); |
956 Diamond d2(R, R.zero); | 954 Diamond d2(R, R.jsgraph.FalseConstant()); |
957 d2.chain(d1); | 955 d2.chain(d1); |
958 | 956 |
959 R.ReduceMergeIterative(R.start, d2.merge); | 957 R.ReduceMergeIterative(R.start, d2.merge); |
960 } | 958 } |
961 | 959 |
962 | 960 |
963 TEST(CChainedDiamondsReduce_false_x) { | 961 TEST(CChainedDiamondsReduce_false_x) { |
964 ControlReducerTester R; | 962 ControlReducerTester R; |
965 Diamond d1(R, R.zero); | 963 Diamond d1(R, R.zero); |
966 Diamond d2(R, R.p0); | 964 Diamond d2(R, R.p0); |
967 d2.chain(d1); | 965 d2.chain(d1); |
968 | 966 |
969 R.ReduceMergeIterative(R.start, d2.merge); | 967 R.ReduceMergeIterative(R.start, d2.merge); |
970 } | 968 } |
971 | 969 |
972 | 970 |
973 TEST(CChainedDiamondsReduce_phi1) { | 971 TEST(CChainedDiamondsReduce_phi1) { |
974 ControlReducerTester R; | 972 ControlReducerTester R; |
975 Diamond d1(R, R.zero, R.one, R.zero); // foldable branch, phi. | 973 Diamond d1(R, R.zero, R.one, R.zero); // foldable branch, phi. |
976 Diamond d2(R, d1.phi); | 974 Diamond d2(R, d1.phi); |
977 d2.chain(d1); | 975 d2.chain(d1); |
978 | 976 |
979 R.ReduceMergeIterative(R.start, d2.merge); | 977 R.ReduceMergeIterative(R.start, d2.merge); |
980 } | 978 } |
981 | 979 |
982 | 980 |
983 TEST(CChainedDiamondsReduce_phi2) { | 981 TEST(CChainedDiamondsReduce_phi2) { |
984 ControlReducerTester R; | 982 ControlReducerTester R; |
985 Diamond d1(R, R.p0, R.one, R.one); // redundant phi. | 983 Diamond d1(R, R.p0, R.jsgraph.TrueConstant(), |
| 984 R.jsgraph.TrueConstant()); // redundant phi. |
986 Diamond d2(R, d1.phi); | 985 Diamond d2(R, d1.phi); |
987 d2.chain(d1); | 986 d2.chain(d1); |
988 | 987 |
989 R.ReduceMergeIterative(d1.merge, d2.merge); | 988 R.ReduceMergeIterative(d1.merge, d2.merge); |
990 } | 989 } |
991 | 990 |
992 | 991 |
993 TEST(CNestedDiamondsReduce_true_true_false) { | 992 TEST(CNestedDiamondsReduce_true_true_false) { |
994 ControlReducerTester R; | 993 ControlReducerTester R; |
995 Diamond d1(R, R.one); | 994 Diamond d1(R, R.jsgraph.TrueConstant()); |
996 Diamond d2(R, R.zero); | 995 Diamond d2(R, R.jsgraph.FalseConstant()); |
997 d2.nest(d1, true); | 996 d2.nest(d1, true); |
998 | 997 |
999 R.ReduceMergeIterative(R.start, d1.merge); | 998 R.ReduceMergeIterative(R.start, d1.merge); |
1000 } | 999 } |
1001 | 1000 |
1002 | 1001 |
1003 TEST(CNestedDiamondsReduce_false_true_false) { | 1002 TEST(CNestedDiamondsReduce_false_true_false) { |
1004 ControlReducerTester R; | 1003 ControlReducerTester R; |
1005 Diamond d1(R, R.one); | 1004 Diamond d1(R, R.jsgraph.TrueConstant()); |
1006 Diamond d2(R, R.zero); | 1005 Diamond d2(R, R.jsgraph.FalseConstant()); |
1007 d2.nest(d1, false); | 1006 d2.nest(d1, false); |
1008 | 1007 |
1009 R.ReduceMergeIterative(R.start, d1.merge); | 1008 R.ReduceMergeIterative(R.start, d1.merge); |
1010 } | 1009 } |
1011 | 1010 |
1012 | 1011 |
1013 TEST(CNestedDiamonds_xyz) { | 1012 TEST(CNestedDiamonds_xyz) { |
1014 ControlReducerTester R; | 1013 ControlReducerTester R; |
1015 | 1014 |
1016 for (int a = 0; a < 2; a++) { | 1015 for (int a = 0; a < 2; a++) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 ControlReducerTester R; | 1069 ControlReducerTester R; |
1071 Node* ret = R.Return(R.one, R.start, R.start); | 1070 Node* ret = R.Return(R.one, R.start, R.start); |
1072 R.ReduceGraph(); | 1071 R.ReduceGraph(); |
1073 CheckInputs(R.graph.end(), ret); | 1072 CheckInputs(R.graph.end(), ret); |
1074 CheckInputs(ret, R.one, R.start, R.start); | 1073 CheckInputs(ret, R.one, R.start, R.start); |
1075 } | 1074 } |
1076 | 1075 |
1077 | 1076 |
1078 TEST(Return2) { | 1077 TEST(Return2) { |
1079 ControlReducerTester R; | 1078 ControlReducerTester R; |
1080 Diamond d(R, R.one); | 1079 Diamond d(R, R.jsgraph.TrueConstant()); |
1081 Node* ret = R.Return(R.half, R.start, d.merge); | 1080 Node* ret = R.Return(R.half, R.start, d.merge); |
1082 R.ReduceGraph(); | 1081 R.ReduceGraph(); |
1083 | 1082 |
1084 DeadChecker dead(&R.graph); | 1083 DeadChecker dead(&R.graph); |
1085 dead.Check(d.branch); | 1084 dead.Check(d.branch); |
1086 dead.Check(d.if_true); | 1085 dead.Check(d.if_true); |
1087 dead.Check(d.if_false); | 1086 dead.Check(d.if_false); |
1088 dead.Check(d.merge); | 1087 dead.Check(d.merge); |
1089 | 1088 |
1090 CheckInputs(R.graph.end(), ret); | 1089 CheckInputs(R.graph.end(), ret); |
1091 CheckInputs(ret, R.half, R.start, R.start); | 1090 CheckInputs(ret, R.half, R.start, R.start); |
1092 } | 1091 } |
1093 | 1092 |
1094 | 1093 |
1095 TEST(Return_true1) { | 1094 TEST(Return_true1) { |
1096 ControlReducerTester R; | 1095 ControlReducerTester R; |
1097 Diamond d(R, R.one, R.half, R.zero); | 1096 Diamond d(R, R.jsgraph.TrueConstant(), R.half, R.zero); |
1098 Node* ret = R.Return(d.phi, R.start, d.merge); | 1097 Node* ret = R.Return(d.phi, R.start, d.merge); |
1099 R.ReduceGraph(); | 1098 R.ReduceGraph(); |
1100 | 1099 |
1101 DeadChecker dead(&R.graph); | 1100 DeadChecker dead(&R.graph); |
1102 dead.Check(d.branch); | 1101 dead.Check(d.branch); |
1103 dead.Check(d.if_true); | 1102 dead.Check(d.if_true); |
1104 dead.Check(d.if_false); | 1103 dead.Check(d.if_false); |
1105 dead.Check(d.merge); | 1104 dead.Check(d.merge); |
1106 dead.Check(d.phi); | 1105 dead.Check(d.phi); |
1107 | 1106 |
1108 CheckInputs(R.graph.end(), ret); | 1107 CheckInputs(R.graph.end(), ret); |
1109 CheckInputs(ret, R.half, R.start, R.start); | 1108 CheckInputs(ret, R.half, R.start, R.start); |
1110 } | 1109 } |
1111 | 1110 |
1112 | 1111 |
1113 TEST(Return_false1) { | 1112 TEST(Return_false1) { |
1114 ControlReducerTester R; | 1113 ControlReducerTester R; |
1115 Diamond d(R, R.zero, R.one, R.half); | 1114 Diamond d(R, R.jsgraph.FalseConstant(), R.one, R.half); |
1116 Node* ret = R.Return(d.phi, R.start, d.merge); | 1115 Node* ret = R.Return(d.phi, R.start, d.merge); |
1117 R.ReduceGraph(); | 1116 R.ReduceGraph(); |
1118 | 1117 |
1119 DeadChecker dead(&R.graph); | 1118 DeadChecker dead(&R.graph); |
1120 dead.Check(d.branch); | 1119 dead.Check(d.branch); |
1121 dead.Check(d.if_true); | 1120 dead.Check(d.if_true); |
1122 dead.Check(d.if_false); | 1121 dead.Check(d.if_false); |
1123 dead.Check(d.merge); | 1122 dead.Check(d.merge); |
1124 dead.Check(d.phi); | 1123 dead.Check(d.phi); |
1125 | 1124 |
1126 CheckInputs(R.graph.end(), ret); | 1125 CheckInputs(R.graph.end(), ret); |
1127 CheckInputs(ret, R.half, R.start, R.start); | 1126 CheckInputs(ret, R.half, R.start, R.start); |
1128 } | 1127 } |
1129 | 1128 |
1130 | 1129 |
1131 TEST(Return_effect1) { | 1130 TEST(Return_effect1) { |
1132 ControlReducerTester R; | 1131 ControlReducerTester R; |
1133 Diamond d(R, R.one); | 1132 Diamond d(R, R.jsgraph.TrueConstant()); |
1134 Node* e1 = R.jsgraph.Float64Constant(-100.1); | 1133 Node* e1 = R.jsgraph.Float64Constant(-100.1); |
1135 Node* e2 = R.jsgraph.Float64Constant(+100.1); | 1134 Node* e2 = R.jsgraph.Float64Constant(+100.1); |
1136 Node* effect = R.graph.NewNode(R.common.EffectPhi(2), e1, e2, d.merge); | 1135 Node* effect = R.graph.NewNode(R.common.EffectPhi(2), e1, e2, d.merge); |
1137 Node* ret = R.Return(R.p0, effect, d.merge); | 1136 Node* ret = R.Return(R.p0, effect, d.merge); |
1138 R.ReduceGraph(); | 1137 R.ReduceGraph(); |
1139 | 1138 |
1140 DeadChecker dead(&R.graph); | 1139 DeadChecker dead(&R.graph); |
1141 dead.Check(d); | 1140 dead.Check(d); |
1142 dead.Check(effect); | 1141 dead.Check(effect); |
1143 | 1142 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 | 1210 |
1212 DeadChecker dead(&R.graph); | 1211 DeadChecker dead(&R.graph); |
1213 dead.Check(d2); | 1212 dead.Check(d2); |
1214 dead.Check(d3); | 1213 dead.Check(d3); |
1215 } | 1214 } |
1216 | 1215 |
1217 | 1216 |
1218 TEST(Return_nested_diamonds_true1) { | 1217 TEST(Return_nested_diamonds_true1) { |
1219 ControlReducerTester R; | 1218 ControlReducerTester R; |
1220 Diamond d2(R, R.p0, R.one, R.zero); | 1219 Diamond d2(R, R.p0, R.one, R.zero); |
1221 Diamond d1(R, R.one, d2.phi, R.zero); | 1220 Diamond d1(R, R.jsgraph.TrueConstant(), d2.phi, R.zero); |
1222 Diamond d3(R, R.p0); | 1221 Diamond d3(R, R.p0); |
1223 | 1222 |
1224 d2.nest(d1, true); | 1223 d2.nest(d1, true); |
1225 d3.nest(d1, false); | 1224 d3.nest(d1, false); |
1226 | 1225 |
1227 Node* ret = R.Return(d1.phi, R.start, d1.merge); | 1226 Node* ret = R.Return(d1.phi, R.start, d1.merge); |
1228 | 1227 |
1229 R.ReduceGraph(); // d1 gets folded true. | 1228 R.ReduceGraph(); // d1 gets folded true. |
1230 | 1229 |
1231 CheckInputs(ret, d2.phi, R.start, d2.merge); | 1230 CheckInputs(ret, d2.phi, R.start, d2.merge); |
(...skipping 24 matching lines...) Expand all Loading... |
1256 | 1255 |
1257 DeadChecker dead(&R.graph); | 1256 DeadChecker dead(&R.graph); |
1258 dead.Check(d1); | 1257 dead.Check(d1); |
1259 dead.Check(d2); | 1258 dead.Check(d2); |
1260 dead.CheckLive(d3); | 1259 dead.CheckLive(d3); |
1261 } | 1260 } |
1262 | 1261 |
1263 | 1262 |
1264 TEST(Return_nested_diamonds_true_true1) { | 1263 TEST(Return_nested_diamonds_true_true1) { |
1265 ControlReducerTester R; | 1264 ControlReducerTester R; |
1266 Diamond d1(R, R.one, R.one, R.zero); | 1265 Diamond d1(R, R.jsgraph.TrueConstant(), R.one, R.zero); |
1267 Diamond d2(R, R.one); | 1266 Diamond d2(R, R.jsgraph.TrueConstant()); |
1268 Diamond d3(R, R.p0); | 1267 Diamond d3(R, R.p0); |
1269 | 1268 |
1270 d2.nest(d1, true); | 1269 d2.nest(d1, true); |
1271 d3.nest(d1, false); | 1270 d3.nest(d1, false); |
1272 | 1271 |
1273 Node* ret = R.Return(d1.phi, R.start, d1.merge); | 1272 Node* ret = R.Return(d1.phi, R.start, d1.merge); |
1274 | 1273 |
1275 R.ReduceGraph(); // d1 and d2 both get folded true. | 1274 R.ReduceGraph(); // d1 and d2 both get folded true. |
1276 | 1275 |
1277 CheckInputs(ret, R.one, R.start, R.start); | 1276 CheckInputs(ret, R.one, R.start, R.start); |
1278 | 1277 |
1279 DeadChecker dead(&R.graph); | 1278 DeadChecker dead(&R.graph); |
1280 dead.Check(d1); | 1279 dead.Check(d1); |
1281 dead.Check(d2); | 1280 dead.Check(d2); |
1282 dead.Check(d3); | 1281 dead.Check(d3); |
1283 } | 1282 } |
1284 | 1283 |
1285 | 1284 |
1286 TEST(Return_nested_diamonds_true_false1) { | 1285 TEST(Return_nested_diamonds_true_false1) { |
1287 ControlReducerTester R; | 1286 ControlReducerTester R; |
1288 Diamond d1(R, R.one, R.one, R.zero); | 1287 Diamond d1(R, R.jsgraph.TrueConstant(), R.one, R.zero); |
1289 Diamond d2(R, R.zero); | 1288 Diamond d2(R, R.jsgraph.FalseConstant()); |
1290 Diamond d3(R, R.p0); | 1289 Diamond d3(R, R.p0); |
1291 | 1290 |
1292 d2.nest(d1, true); | 1291 d2.nest(d1, true); |
1293 d3.nest(d1, false); | 1292 d3.nest(d1, false); |
1294 | 1293 |
1295 Node* ret = R.Return(d1.phi, R.start, d1.merge); | 1294 Node* ret = R.Return(d1.phi, R.start, d1.merge); |
1296 | 1295 |
1297 R.ReduceGraph(); // d1 gets folded true and d2 gets folded false. | 1296 R.ReduceGraph(); // d1 gets folded true and d2 gets folded false. |
1298 | 1297 |
1299 CheckInputs(ret, R.one, R.start, R.start); | 1298 CheckInputs(ret, R.one, R.start, R.start); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 | 1334 |
1336 TEST(Return_nested_diamonds_true2) { | 1335 TEST(Return_nested_diamonds_true2) { |
1337 ControlReducerTester R; | 1336 ControlReducerTester R; |
1338 Node* x2 = R.jsgraph.Float64Constant(11.1); | 1337 Node* x2 = R.jsgraph.Float64Constant(11.1); |
1339 Node* y2 = R.jsgraph.Float64Constant(22.2); | 1338 Node* y2 = R.jsgraph.Float64Constant(22.2); |
1340 Node* x3 = R.jsgraph.Float64Constant(33.3); | 1339 Node* x3 = R.jsgraph.Float64Constant(33.3); |
1341 Node* y3 = R.jsgraph.Float64Constant(44.4); | 1340 Node* y3 = R.jsgraph.Float64Constant(44.4); |
1342 | 1341 |
1343 Diamond d2(R, R.p0, x2, y2); | 1342 Diamond d2(R, R.p0, x2, y2); |
1344 Diamond d3(R, R.p0, x3, y3); | 1343 Diamond d3(R, R.p0, x3, y3); |
1345 Diamond d1(R, R.one, d2.phi, d3.phi); | 1344 Diamond d1(R, R.jsgraph.TrueConstant(), d2.phi, d3.phi); |
1346 | 1345 |
1347 d2.nest(d1, true); | 1346 d2.nest(d1, true); |
1348 d3.nest(d1, false); | 1347 d3.nest(d1, false); |
1349 | 1348 |
1350 Node* ret = R.Return(d1.phi, R.start, d1.merge); | 1349 Node* ret = R.Return(d1.phi, R.start, d1.merge); |
1351 | 1350 |
1352 R.ReduceGraph(); // d1 gets folded true. | 1351 R.ReduceGraph(); // d1 gets folded true. |
1353 | 1352 |
1354 CheckInputs(ret, d2.phi, R.start, d2.merge); | 1353 CheckInputs(ret, d2.phi, R.start, d2.merge); |
1355 CheckInputs(d2.branch, R.p0, R.start); | 1354 CheckInputs(d2.branch, R.p0, R.start); |
1356 | 1355 |
1357 DeadChecker dead(&R.graph); | 1356 DeadChecker dead(&R.graph); |
1358 dead.Check(d1); | 1357 dead.Check(d1); |
1359 dead.CheckLive(d2); | 1358 dead.CheckLive(d2); |
1360 dead.Check(d3); | 1359 dead.Check(d3); |
1361 } | 1360 } |
1362 | 1361 |
1363 | 1362 |
1364 TEST(Return_nested_diamonds_true_true2) { | 1363 TEST(Return_nested_diamonds_true_true2) { |
1365 ControlReducerTester R; | 1364 ControlReducerTester R; |
1366 Node* x2 = R.jsgraph.Float64Constant(11.1); | 1365 Node* x2 = R.jsgraph.Float64Constant(11.1); |
1367 Node* y2 = R.jsgraph.Float64Constant(22.2); | 1366 Node* y2 = R.jsgraph.Float64Constant(22.2); |
1368 Node* x3 = R.jsgraph.Float64Constant(33.3); | 1367 Node* x3 = R.jsgraph.Float64Constant(33.3); |
1369 Node* y3 = R.jsgraph.Float64Constant(44.4); | 1368 Node* y3 = R.jsgraph.Float64Constant(44.4); |
1370 | 1369 |
1371 Diamond d2(R, R.one, x2, y2); | 1370 Diamond d2(R, R.jsgraph.TrueConstant(), x2, y2); |
1372 Diamond d3(R, R.p0, x3, y3); | 1371 Diamond d3(R, R.p0, x3, y3); |
1373 Diamond d1(R, R.one, d2.phi, d3.phi); | 1372 Diamond d1(R, R.jsgraph.TrueConstant(), d2.phi, d3.phi); |
1374 | 1373 |
1375 d2.nest(d1, true); | 1374 d2.nest(d1, true); |
1376 d3.nest(d1, false); | 1375 d3.nest(d1, false); |
1377 | 1376 |
1378 Node* ret = R.Return(d1.phi, R.start, d1.merge); | 1377 Node* ret = R.Return(d1.phi, R.start, d1.merge); |
1379 | 1378 |
1380 R.ReduceGraph(); // d1 gets folded true. | 1379 R.ReduceGraph(); // d1 gets folded true. |
1381 | 1380 |
1382 CheckInputs(ret, x2, R.start, R.start); | 1381 CheckInputs(ret, x2, R.start, R.start); |
1383 | 1382 |
1384 DeadChecker dead(&R.graph); | 1383 DeadChecker dead(&R.graph); |
1385 dead.Check(d1); | 1384 dead.Check(d1); |
1386 dead.Check(d2); | 1385 dead.Check(d2); |
1387 dead.Check(d3); | 1386 dead.Check(d3); |
1388 } | 1387 } |
1389 | 1388 |
1390 | 1389 |
1391 TEST(Return_nested_diamonds_true_false2) { | 1390 TEST(Return_nested_diamonds_true_false2) { |
1392 ControlReducerTester R; | 1391 ControlReducerTester R; |
1393 Node* x2 = R.jsgraph.Float64Constant(11.1); | 1392 Node* x2 = R.jsgraph.Float64Constant(11.1); |
1394 Node* y2 = R.jsgraph.Float64Constant(22.2); | 1393 Node* y2 = R.jsgraph.Float64Constant(22.2); |
1395 Node* x3 = R.jsgraph.Float64Constant(33.3); | 1394 Node* x3 = R.jsgraph.Float64Constant(33.3); |
1396 Node* y3 = R.jsgraph.Float64Constant(44.4); | 1395 Node* y3 = R.jsgraph.Float64Constant(44.4); |
1397 | 1396 |
1398 Diamond d2(R, R.zero, x2, y2); | 1397 Diamond d2(R, R.jsgraph.FalseConstant(), x2, y2); |
1399 Diamond d3(R, R.p0, x3, y3); | 1398 Diamond d3(R, R.p0, x3, y3); |
1400 Diamond d1(R, R.one, d2.phi, d3.phi); | 1399 Diamond d1(R, R.jsgraph.TrueConstant(), d2.phi, d3.phi); |
1401 | 1400 |
1402 d2.nest(d1, true); | 1401 d2.nest(d1, true); |
1403 d3.nest(d1, false); | 1402 d3.nest(d1, false); |
1404 | 1403 |
1405 Node* ret = R.Return(d1.phi, R.start, d1.merge); | 1404 Node* ret = R.Return(d1.phi, R.start, d1.merge); |
1406 | 1405 |
1407 R.ReduceGraph(); // d1 gets folded true. | 1406 R.ReduceGraph(); // d1 gets folded true. |
1408 | 1407 |
1409 CheckInputs(ret, y2, R.start, R.start); | 1408 CheckInputs(ret, y2, R.start, R.start); |
1410 | 1409 |
1411 DeadChecker dead(&R.graph); | 1410 DeadChecker dead(&R.graph); |
1412 dead.Check(d1); | 1411 dead.Check(d1); |
1413 dead.Check(d2); | 1412 dead.Check(d2); |
1414 dead.Check(d3); | 1413 dead.Check(d3); |
1415 } | 1414 } |
OLD | NEW |