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

Side by Side Diff: test/cctest/compiler/test-js-typed-lowering.cc

Issue 721723004: [turbofan] Remove int32 add/subtract narrowing during typed lowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 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
« no previous file with comments | « src/compiler/js-typed-lowering.cc ('k') | test/mjsunit/regress/regress-unsigned-mul-add.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/compiler/graph-inl.h" 8 #include "src/compiler/graph-inl.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 R.CheckEffectInput(orig, effect_use); 1206 R.CheckEffectInput(orig, effect_use);
1207 } else { 1207 } else {
1208 // effect should have been removed from this node. 1208 // effect should have been removed from this node.
1209 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); 1209 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode());
1210 R.CheckEffectInput(R.start(), effect_use); 1210 R.CheckEffectInput(R.start(), effect_use);
1211 } 1211 }
1212 } 1212 }
1213 } 1213 }
1214 1214
1215 1215
1216 TEST(Int32AddNarrowing) { 1216 TEST(Int32AddLowering) {
titzer 2014/11/14 14:26:20 I think we should keep these tests but assert now
1217 {
1218 JSBitwiseTypedLoweringTester R;
1219
1220 for (int o = 0; o < R.kNumberOps; o += 2) {
1221 for (size_t i = 0; i < arraysize(kInt32Types); i++) {
1222 Node* n0 = R.Parameter(kInt32Types[i]);
1223 for (size_t j = 0; j < arraysize(kInt32Types); j++) {
1224 Node* n1 = R.Parameter(kInt32Types[j]);
1225 Node* one = R.graph.NewNode(R.common.NumberConstant(1));
1226
1227 for (int l = 0; l < 2; l++) {
1228 Node* add_node = R.Binop(R.simplified.NumberAdd(), n0, n1);
1229 Node* or_node =
1230 R.Binop(R.ops[o], l ? add_node : one, l ? one : add_node);
1231 Node* r = R.reduce(or_node);
1232
1233 CHECK_EQ(R.ops[o + 1]->opcode(), r->op()->opcode());
1234 CHECK_EQ(IrOpcode::kInt32Add, add_node->opcode());
1235 bool is_signed = l ? R.signedness[o] : R.signedness[o + 1];
1236
1237 Type* add_type = NodeProperties::GetBounds(add_node).upper;
1238 CHECK(add_type->Is(I32Type(is_signed)));
1239 }
1240 }
1241 }
1242 }
1243 }
1244 {
1245 JSBitwiseShiftTypedLoweringTester R;
1246
1247 for (int o = 0; o < R.kNumberOps; o += 2) {
1248 for (size_t i = 0; i < arraysize(kInt32Types); i++) {
1249 Node* n0 = R.Parameter(kInt32Types[i]);
1250 for (size_t j = 0; j < arraysize(kInt32Types); j++) {
1251 Node* n1 = R.Parameter(kInt32Types[j]);
1252 Node* one = R.graph.NewNode(R.common.NumberConstant(1));
1253
1254 for (int l = 0; l < 2; l++) {
1255 Node* add_node = R.Binop(R.simplified.NumberAdd(), n0, n1);
1256 Node* or_node =
1257 R.Binop(R.ops[o], l ? add_node : one, l ? one : add_node);
1258 Node* r = R.reduce(or_node);
1259
1260 CHECK_EQ(R.ops[o + 1]->opcode(), r->op()->opcode());
1261 CHECK_EQ(IrOpcode::kInt32Add, add_node->opcode());
1262 bool is_signed = l ? R.signedness[o] : R.signedness[o + 1];
1263
1264 Type* add_type = NodeProperties::GetBounds(add_node).upper;
1265 CHECK(add_type->Is(I32Type(is_signed)));
1266 }
1267 }
1268 }
1269 }
1270 }
1271 }
1272
1273
1274 TEST(Int32AddNarrowingNotOwned) {
1275 JSBitwiseTypedLoweringTester R; 1217 JSBitwiseTypedLoweringTester R;
1276 1218
1277 for (int o = 0; o < R.kNumberOps; o += 2) { 1219 for (int o = 0; o < R.kNumberOps; o += 2) {
1278 Node* n0 = R.Parameter(I32Type(R.signedness[o])); 1220 Node* n0 = R.Parameter(I32Type(R.signedness[o]));
1279 Node* n1 = R.Parameter(I32Type(R.signedness[o + 1])); 1221 Node* n1 = R.Parameter(I32Type(R.signedness[o + 1]));
1280 Node* one = R.graph.NewNode(R.common.NumberConstant(1)); 1222 Node* one = R.graph.NewNode(R.common.NumberConstant(1));
1281 1223
1282 Node* add_node = R.Binop(R.simplified.NumberAdd(), n0, n1); 1224 Node* add_node = R.Binop(R.simplified.NumberAdd(), n0, n1);
1283 Node* or_node = R.Binop(R.ops[o], add_node, one); 1225 Node* or_node = R.Binop(R.ops[o], add_node, one);
1284 Node* other_use = R.Binop(R.simplified.NumberAdd(), add_node, one); 1226 Node* other_use = R.Binop(R.simplified.NumberAdd(), add_node, one);
1285 Node* r = R.reduce(or_node); 1227 Node* r = R.reduce(or_node);
1286 CHECK_EQ(R.ops[o + 1]->opcode(), r->op()->opcode()); 1228 CHECK_EQ(R.ops[o + 1]->opcode(), r->op()->opcode());
1287 // Should not be reduced to Int32Add because of the other number add.
1288 CHECK_EQ(IrOpcode::kNumberAdd, add_node->opcode()); 1229 CHECK_EQ(IrOpcode::kNumberAdd, add_node->opcode());
1289 // Conversion to int32 should be done. 1230 // Conversion to int32 should be done.
1290 CheckToI32(add_node, r->InputAt(0), R.signedness[o]); 1231 CheckToI32(add_node, r->InputAt(0), R.signedness[o]);
1291 CheckToI32(one, r->InputAt(1), R.signedness[o + 1]); 1232 CheckToI32(one, r->InputAt(1), R.signedness[o + 1]);
1292 // The other use should also not be touched. 1233 // The other use should also not be touched.
1293 CHECK_EQ(add_node, other_use->InputAt(0)); 1234 CHECK_EQ(add_node, other_use->InputAt(0));
1294 CHECK_EQ(one, other_use->InputAt(1)); 1235 CHECK_EQ(one, other_use->InputAt(1));
1295 } 1236 }
1296 } 1237 }
1297 1238
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 CHECK_EQ(p1, r->InputAt(0)); 1285 CHECK_EQ(p1, r->InputAt(0));
1345 CHECK_EQ(p0, r->InputAt(1)); 1286 CHECK_EQ(p0, r->InputAt(1));
1346 } else { 1287 } else {
1347 CHECK_EQ(p0, r->InputAt(0)); 1288 CHECK_EQ(p0, r->InputAt(0));
1348 CHECK_EQ(p1, r->InputAt(1)); 1289 CHECK_EQ(p1, r->InputAt(1));
1349 } 1290 }
1350 } 1291 }
1351 } 1292 }
1352 } 1293 }
1353 } 1294 }
OLDNEW
« no previous file with comments | « src/compiler/js-typed-lowering.cc ('k') | test/mjsunit/regress/regress-unsigned-mul-add.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698