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

Side by Side Diff: test/cctest/compiler/test-run-machops.cc

Issue 2428443002: [wasm] Trim graph before scheduling. (Closed)
Patch Set: Use proper temp registers if Projection(1) does not exist. Created 4 years, 2 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
« no previous file with comments | « src/compiler/pipeline.cc ('k') | test/cctest/wasm/test-run-wasm.cc » ('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. Use of this 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 #include <functional> 6 #include <functional>
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/ieee754.h" 10 #include "src/base/ieee754.h"
(...skipping 4143 matching lines...) Expand 10 before | Expand all | Expand 10 after
4154 FOR_UINT64_INPUTS(j) { 4154 FOR_UINT64_INPUTS(j) {
4155 m.Call(static_cast<uint32_t>(*i & 0xffffffff), 4155 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4156 static_cast<uint32_t>(*i >> 32), 4156 static_cast<uint32_t>(*i >> 32),
4157 static_cast<uint32_t>(*j & 0xffffffff), 4157 static_cast<uint32_t>(*j & 0xffffffff),
4158 static_cast<uint32_t>(*j >> 32)); 4158 static_cast<uint32_t>(*j >> 32));
4159 CHECK_EQ(*i + *j, ToInt64(low, high)); 4159 CHECK_EQ(*i + *j, ToInt64(low, high));
4160 } 4160 }
4161 } 4161 }
4162 } 4162 }
4163 4163
4164 TEST(RunInt32PairAddUseOnlyHighWord) {
4165 BufferedRawMachineAssemblerTester<int32_t> m(
4166 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32(),
4167 MachineType::Uint32());
4168
4169 m.Return(m.Projection(1, m.Int32PairAdd(m.Parameter(0), m.Parameter(1),
4170 m.Parameter(2), m.Parameter(3))));
4171
4172 FOR_UINT64_INPUTS(i) {
4173 FOR_UINT64_INPUTS(j) {
4174 CHECK_EQ(static_cast<uint32_t>((*i + *j) >> 32),
4175 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4176 static_cast<uint32_t>(*i >> 32),
4177 static_cast<uint32_t>(*j & 0xffffffff),
4178 static_cast<uint32_t>(*j >> 32)));
4179 }
4180 }
4181 }
4182
4164 void TestInt32PairAddWithSharedInput(int a, int b, int c, int d) { 4183 void TestInt32PairAddWithSharedInput(int a, int b, int c, int d) {
4165 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(), 4184 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
4166 MachineType::Uint32()); 4185 MachineType::Uint32());
4167 4186
4168 uint32_t high; 4187 uint32_t high;
4169 uint32_t low; 4188 uint32_t low;
4170 4189
4171 Node* PairAdd = m.Int32PairAdd(m.Parameter(a), m.Parameter(b), m.Parameter(c), 4190 Node* PairAdd = m.Int32PairAdd(m.Parameter(a), m.Parameter(b), m.Parameter(c),
4172 m.Parameter(d)); 4191 m.Parameter(d));
4173 4192
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
4217 FOR_UINT64_INPUTS(j) { 4236 FOR_UINT64_INPUTS(j) {
4218 m.Call(static_cast<uint32_t>(*i & 0xffffffff), 4237 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4219 static_cast<uint32_t>(*i >> 32), 4238 static_cast<uint32_t>(*i >> 32),
4220 static_cast<uint32_t>(*j & 0xffffffff), 4239 static_cast<uint32_t>(*j & 0xffffffff),
4221 static_cast<uint32_t>(*j >> 32)); 4240 static_cast<uint32_t>(*j >> 32));
4222 CHECK_EQ(*i - *j, ToInt64(low, high)); 4241 CHECK_EQ(*i - *j, ToInt64(low, high));
4223 } 4242 }
4224 } 4243 }
4225 } 4244 }
4226 4245
4246 TEST(RunInt32PairSubUseOnlyHighWord) {
4247 BufferedRawMachineAssemblerTester<int32_t> m(
4248 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32(),
4249 MachineType::Uint32());
4250
4251 m.Return(m.Projection(1, m.Int32PairSub(m.Parameter(0), m.Parameter(1),
4252 m.Parameter(2), m.Parameter(3))));
4253
4254 FOR_UINT64_INPUTS(i) {
4255 FOR_UINT64_INPUTS(j) {
4256 CHECK_EQ(static_cast<uint32_t>((*i - *j) >> 32),
4257 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4258 static_cast<uint32_t>(*i >> 32),
4259 static_cast<uint32_t>(*j & 0xffffffff),
4260 static_cast<uint32_t>(*j >> 32)));
4261 }
4262 }
4263 }
4264
4227 void TestInt32PairSubWithSharedInput(int a, int b, int c, int d) { 4265 void TestInt32PairSubWithSharedInput(int a, int b, int c, int d) {
4228 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(), 4266 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
4229 MachineType::Uint32()); 4267 MachineType::Uint32());
4230 4268
4231 uint32_t high; 4269 uint32_t high;
4232 uint32_t low; 4270 uint32_t low;
4233 4271
4234 Node* PairSub = m.Int32PairSub(m.Parameter(a), m.Parameter(b), m.Parameter(c), 4272 Node* PairSub = m.Int32PairSub(m.Parameter(a), m.Parameter(b), m.Parameter(c),
4235 m.Parameter(d)); 4273 m.Parameter(d));
4236 4274
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
4280 FOR_UINT64_INPUTS(j) { 4318 FOR_UINT64_INPUTS(j) {
4281 m.Call(static_cast<uint32_t>(*i & 0xffffffff), 4319 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4282 static_cast<uint32_t>(*i >> 32), 4320 static_cast<uint32_t>(*i >> 32),
4283 static_cast<uint32_t>(*j & 0xffffffff), 4321 static_cast<uint32_t>(*j & 0xffffffff),
4284 static_cast<uint32_t>(*j >> 32)); 4322 static_cast<uint32_t>(*j >> 32));
4285 CHECK_EQ(*i * *j, ToInt64(low, high)); 4323 CHECK_EQ(*i * *j, ToInt64(low, high));
4286 } 4324 }
4287 } 4325 }
4288 } 4326 }
4289 4327
4328 TEST(RunInt32PairMulUseOnlyHighWord) {
4329 BufferedRawMachineAssemblerTester<int32_t> m(
4330 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32(),
4331 MachineType::Uint32());
4332
4333 m.Return(m.Projection(1, m.Int32PairMul(m.Parameter(0), m.Parameter(1),
4334 m.Parameter(2), m.Parameter(3))));
4335
4336 FOR_UINT64_INPUTS(i) {
4337 FOR_UINT64_INPUTS(j) {
4338 CHECK_EQ(static_cast<uint32_t>((*i * *j) >> 32),
4339 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4340 static_cast<uint32_t>(*i >> 32),
4341 static_cast<uint32_t>(*j & 0xffffffff),
4342 static_cast<uint32_t>(*j >> 32)));
4343 }
4344 }
4345 }
4346
4290 void TestInt32PairMulWithSharedInput(int a, int b, int c, int d) { 4347 void TestInt32PairMulWithSharedInput(int a, int b, int c, int d) {
4291 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(), 4348 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
4292 MachineType::Uint32()); 4349 MachineType::Uint32());
4293 4350
4294 uint32_t high; 4351 uint32_t high;
4295 uint32_t low; 4352 uint32_t low;
4296 4353
4297 Node* PairMul = m.Int32PairMul(m.Parameter(a), m.Parameter(b), m.Parameter(c), 4354 Node* PairMul = m.Int32PairMul(m.Parameter(a), m.Parameter(b), m.Parameter(c),
4298 m.Parameter(d)); 4355 m.Parameter(d));
4299 4356
(...skipping 23 matching lines...) Expand all
4323 TestInt32PairMulWithSharedInput(0, 1, 1, 0); 4380 TestInt32PairMulWithSharedInput(0, 1, 1, 0);
4324 } 4381 }
4325 4382
4326 TEST(RunWord32PairShl) { 4383 TEST(RunWord32PairShl) {
4327 BufferedRawMachineAssemblerTester<int32_t> m( 4384 BufferedRawMachineAssemblerTester<int32_t> m(
4328 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); 4385 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
4329 4386
4330 uint32_t high; 4387 uint32_t high;
4331 uint32_t low; 4388 uint32_t low;
4332 4389
4333 Node* PairAdd = 4390 Node* PairShl =
4334 m.Word32PairShl(m.Parameter(0), m.Parameter(1), m.Parameter(2)); 4391 m.Word32PairShl(m.Parameter(0), m.Parameter(1), m.Parameter(2));
4335 4392
4336 m.StoreToPointer(&low, MachineRepresentation::kWord32, 4393 m.StoreToPointer(&low, MachineRepresentation::kWord32,
4337 m.Projection(0, PairAdd)); 4394 m.Projection(0, PairShl));
4338 m.StoreToPointer(&high, MachineRepresentation::kWord32, 4395 m.StoreToPointer(&high, MachineRepresentation::kWord32,
4339 m.Projection(1, PairAdd)); 4396 m.Projection(1, PairShl));
4340 m.Return(m.Int32Constant(74)); 4397 m.Return(m.Int32Constant(74));
4341 4398
4342 FOR_UINT64_INPUTS(i) { 4399 FOR_UINT64_INPUTS(i) {
4343 for (uint32_t j = 0; j < 64; j++) { 4400 for (uint32_t j = 0; j < 64; j++) {
4344 m.Call(static_cast<uint32_t>(*i & 0xffffffff), 4401 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4345 static_cast<uint32_t>(*i >> 32), j); 4402 static_cast<uint32_t>(*i >> 32), j);
4346 CHECK_EQ(*i << j, ToInt64(low, high)); 4403 CHECK_EQ(*i << j, ToInt64(low, high));
4347 } 4404 }
4348 } 4405 }
4349 } 4406 }
4350 4407
4408 TEST(RunWord32PairShlUseOnlyHighWord) {
4409 BufferedRawMachineAssemblerTester<int32_t> m(
4410 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
4411
4412 m.Return(m.Projection(
4413 1, m.Word32PairShl(m.Parameter(0), m.Parameter(1), m.Parameter(2))));
4414
4415 FOR_UINT64_INPUTS(i) {
4416 for (uint32_t j = 0; j < 64; j++) {
4417 CHECK_EQ(static_cast<uint32_t>((*i << j) >> 32),
4418 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4419 static_cast<uint32_t>(*i >> 32), j));
4420 }
4421 }
4422 }
4423
4351 void TestWord32PairShlWithSharedInput(int a, int b) { 4424 void TestWord32PairShlWithSharedInput(int a, int b) {
4352 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(), 4425 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
4353 MachineType::Uint32()); 4426 MachineType::Uint32());
4354 4427
4355 uint32_t high; 4428 uint32_t high;
4356 uint32_t low; 4429 uint32_t low;
4357 4430
4358 Node* PairAdd = 4431 Node* PairAdd =
4359 m.Word32PairShl(m.Parameter(a), m.Parameter(b), m.Parameter(1)); 4432 m.Word32PairShl(m.Parameter(a), m.Parameter(b), m.Parameter(1));
4360 4433
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4398 4471
4399 FOR_UINT64_INPUTS(i) { 4472 FOR_UINT64_INPUTS(i) {
4400 for (uint32_t j = 0; j < 64; j++) { 4473 for (uint32_t j = 0; j < 64; j++) {
4401 m.Call(static_cast<uint32_t>(*i & 0xffffffff), 4474 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4402 static_cast<uint32_t>(*i >> 32), j); 4475 static_cast<uint32_t>(*i >> 32), j);
4403 CHECK_EQ(*i >> j, ToInt64(low, high)); 4476 CHECK_EQ(*i >> j, ToInt64(low, high));
4404 } 4477 }
4405 } 4478 }
4406 } 4479 }
4407 4480
4481 TEST(RunWord32PairShrUseOnlyHighWord) {
4482 BufferedRawMachineAssemblerTester<int32_t> m(
4483 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
4484
4485 m.Return(m.Projection(
4486 1, m.Word32PairShr(m.Parameter(0), m.Parameter(1), m.Parameter(2))));
4487
4488 FOR_UINT64_INPUTS(i) {
4489 for (uint32_t j = 0; j < 64; j++) {
4490 CHECK_EQ(static_cast<uint32_t>((*i >> j) >> 32),
4491 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4492 static_cast<uint32_t>(*i >> 32), j));
4493 }
4494 }
4495 }
4496
4408 TEST(RunWord32PairSar) { 4497 TEST(RunWord32PairSar) {
4409 BufferedRawMachineAssemblerTester<int32_t> m( 4498 BufferedRawMachineAssemblerTester<int32_t> m(
4410 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32()); 4499 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
4411 4500
4412 uint32_t high; 4501 uint32_t high;
4413 uint32_t low; 4502 uint32_t low;
4414 4503
4415 Node* PairAdd = 4504 Node* PairAdd =
4416 m.Word32PairSar(m.Parameter(0), m.Parameter(1), m.Parameter(2)); 4505 m.Word32PairSar(m.Parameter(0), m.Parameter(1), m.Parameter(2));
4417 4506
4418 m.StoreToPointer(&low, MachineRepresentation::kWord32, 4507 m.StoreToPointer(&low, MachineRepresentation::kWord32,
4419 m.Projection(0, PairAdd)); 4508 m.Projection(0, PairAdd));
4420 m.StoreToPointer(&high, MachineRepresentation::kWord32, 4509 m.StoreToPointer(&high, MachineRepresentation::kWord32,
4421 m.Projection(1, PairAdd)); 4510 m.Projection(1, PairAdd));
4422 m.Return(m.Int32Constant(74)); 4511 m.Return(m.Int32Constant(74));
4423 4512
4424 FOR_INT64_INPUTS(i) { 4513 FOR_INT64_INPUTS(i) {
4425 for (uint32_t j = 0; j < 64; j++) { 4514 for (uint32_t j = 0; j < 64; j++) {
4426 m.Call(static_cast<uint32_t>(*i & 0xffffffff), 4515 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4427 static_cast<uint32_t>(*i >> 32), j); 4516 static_cast<uint32_t>(*i >> 32), j);
4428 CHECK_EQ(*i >> j, ToInt64(low, high)); 4517 CHECK_EQ(*i >> j, ToInt64(low, high));
4429 } 4518 }
4430 } 4519 }
4431 } 4520 }
4432 4521
4522 TEST(RunWord32PairSarUseOnlyHighWord) {
4523 BufferedRawMachineAssemblerTester<int32_t> m(
4524 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
4525
4526 m.Return(m.Projection(
4527 1, m.Word32PairSar(m.Parameter(0), m.Parameter(1), m.Parameter(2))));
4528
4529 FOR_INT64_INPUTS(i) {
4530 for (uint32_t j = 0; j < 64; j++) {
4531 CHECK_EQ(static_cast<uint32_t>((*i >> j) >> 32),
4532 m.Call(static_cast<uint32_t>(*i & 0xffffffff),
4533 static_cast<uint32_t>(*i >> 32), j));
4534 }
4535 }
4536 }
4433 #endif 4537 #endif
4434 4538
4435 TEST(RunDeadChangeFloat64ToInt32) { 4539 TEST(RunDeadChangeFloat64ToInt32) {
4436 RawMachineAssemblerTester<int32_t> m; 4540 RawMachineAssemblerTester<int32_t> m;
4437 const int magic = 0x88abcda4; 4541 const int magic = 0x88abcda4;
4438 m.ChangeFloat64ToInt32(m.Float64Constant(999.78)); 4542 m.ChangeFloat64ToInt32(m.Float64Constant(999.78));
4439 m.Return(m.Int32Constant(magic)); 4543 m.Return(m.Int32Constant(magic));
4440 CHECK_EQ(magic, m.Call()); 4544 CHECK_EQ(magic, m.Call());
4441 } 4545 }
4442 4546
(...skipping 2128 matching lines...) Expand 10 before | Expand all | Expand 10 after
6571 r.Goto(&merge); 6675 r.Goto(&merge);
6572 r.Bind(&merge); 6676 r.Bind(&merge);
6573 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); 6677 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb);
6574 r.Return(phi); 6678 r.Return(phi);
6575 CHECK_EQ(1, r.Call(1)); 6679 CHECK_EQ(1, r.Call(1));
6576 } 6680 }
6577 6681
6578 } // namespace compiler 6682 } // namespace compiler
6579 } // namespace internal 6683 } // namespace internal
6580 } // namespace v8 6684 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/pipeline.cc ('k') | test/cctest/wasm/test-run-wasm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698