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

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

Issue 677433002: Add floor, ceil, round (truncate) instructions for ia32, x64 (if SSE4.1) and (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address changes and fix compilation on mac. 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/compiler/codegen-tester.h ('k') | test/mjsunit/asm/math-ceil.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 <cmath>
5 #include <functional> 6 #include <functional>
6 #include <limits> 7 #include <limits>
7 8
8 #include "src/base/bits.h" 9 #include "src/base/bits.h"
9 #include "src/codegen.h" 10 #include "src/codegen.h"
10 #include "src/compiler/generic-node-inl.h" 11 #include "src/compiler/generic-node-inl.h"
11 #include "test/cctest/cctest.h" 12 #include "test/cctest/cctest.h"
12 #include "test/cctest/compiler/codegen-tester.h" 13 #include "test/cctest/compiler/codegen-tester.h"
13 #include "test/cctest/compiler/value-helper.h" 14 #include "test/cctest/compiler/value-helper.h"
14 15
(...skipping 4514 matching lines...) Expand 10 before | Expand all | Expand 10 after
4529 float expected = *i; 4530 float expected = *i;
4530 float actual = *i; 4531 float actual = *i;
4531 RawMachineAssemblerTester<int32_t> m; 4532 RawMachineAssemblerTester<int32_t> m;
4532 m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected)); 4533 m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected));
4533 m.Return(m.Int32Constant(0)); 4534 m.Return(m.Int32Constant(0));
4534 CHECK_EQ(0, m.Call()); 4535 CHECK_EQ(0, m.Call());
4535 CHECK_EQ(expected, actual); 4536 CHECK_EQ(expected, actual);
4536 } 4537 }
4537 } 4538 }
4538 4539
4540
4541 static double two_30 = 1 << 30; // 2^30 is a smi boundary.
4542 static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary.
4543 static double kValues[] = {0.1,
4544 0.2,
4545 0.49999999999999994,
4546 0.5,
4547 0.7,
4548 1.0 - std::numeric_limits<double>::epsilon(),
4549 -0.1,
4550 -0.49999999999999994,
4551 -0.5,
4552 -0.7,
4553 1.1,
4554 1.0 + std::numeric_limits<double>::epsilon(),
4555 1.5,
4556 1.7,
4557 -1,
4558 -1 + std::numeric_limits<double>::epsilon(),
4559 -1 - std::numeric_limits<double>::epsilon(),
4560 -1.1,
4561 -1.5,
4562 -1.7,
4563 std::numeric_limits<double>::min(),
4564 -std::numeric_limits<double>::min(),
4565 std::numeric_limits<double>::max(),
4566 -std::numeric_limits<double>::max(),
4567 std::numeric_limits<double>::infinity(),
4568 -std::numeric_limits<double>::infinity(),
4569 two_30,
4570 two_30 + 0.1,
4571 two_30 + 0.5,
4572 two_30 + 0.7,
4573 two_30 - 1,
4574 two_30 - 1 + 0.1,
4575 two_30 - 1 + 0.5,
4576 two_30 - 1 + 0.7,
4577 -two_30,
4578 -two_30 + 0.1,
4579 -two_30 + 0.5,
4580 -two_30 + 0.7,
4581 -two_30 + 1,
4582 -two_30 + 1 + 0.1,
4583 -two_30 + 1 + 0.5,
4584 -two_30 + 1 + 0.7,
4585 two_52,
4586 two_52 + 0.1,
4587 two_52 + 0.5,
4588 two_52 + 0.5,
4589 two_52 + 0.7,
4590 two_52 + 0.7,
4591 two_52 - 1,
4592 two_52 - 1 + 0.1,
4593 two_52 - 1 + 0.5,
4594 two_52 - 1 + 0.7,
4595 -two_52,
4596 -two_52 + 0.1,
4597 -two_52 + 0.5,
4598 -two_52 + 0.7,
4599 -two_52 + 1,
4600 -two_52 + 1 + 0.1,
4601 -two_52 + 1 + 0.5,
4602 -two_52 + 1 + 0.7,
4603 two_30,
4604 two_30 - 0.1,
4605 two_30 - 0.5,
4606 two_30 - 0.7,
4607 two_30 - 1,
4608 two_30 - 1 - 0.1,
4609 two_30 - 1 - 0.5,
4610 two_30 - 1 - 0.7,
4611 -two_30,
4612 -two_30 - 0.1,
4613 -two_30 - 0.5,
4614 -two_30 - 0.7,
4615 -two_30 + 1,
4616 -two_30 + 1 - 0.1,
4617 -two_30 + 1 - 0.5,
4618 -two_30 + 1 - 0.7,
4619 two_52,
4620 two_52 - 0.1,
4621 two_52 - 0.5,
4622 two_52 - 0.5,
4623 two_52 - 0.7,
4624 two_52 - 0.7,
4625 two_52 - 1,
4626 two_52 - 1 - 0.1,
4627 two_52 - 1 - 0.5,
4628 two_52 - 1 - 0.7,
4629 -two_52,
4630 -two_52 - 0.1,
4631 -two_52 - 0.5,
4632 -two_52 - 0.7,
4633 -two_52 + 1,
4634 -two_52 + 1 - 0.1,
4635 -two_52 + 1 - 0.5,
4636 -two_52 + 1 - 0.7};
4637
4638
4639 TEST(RunFloat64Floor) {
4640 double input = -1.0;
4641 double result = 0.0;
4642 RawMachineAssemblerTester<int32_t> m;
4643 if (!m.machine()->HasFloat64Floor()) return;
4644 m.StoreToPointer(&result, kMachFloat64,
4645 m.Float64Floor(m.LoadFromPointer(&input, kMachFloat64)));
4646 m.Return(m.Int32Constant(0));
4647 for (size_t i = 0; i < arraysize(kValues); ++i) {
4648 input = kValues[i];
4649 CHECK_EQ(0, m.Call());
4650 double expected = std::floor(kValues[i]);
4651 CHECK_EQ(expected, result);
4652 }
4653 }
4654
4655
4656 TEST(RunFloat64Ceil) {
4657 double input = -1.0;
4658 double result = 0.0;
4659 RawMachineAssemblerTester<int32_t> m;
4660 if (!m.machine()->HasFloat64Ceil()) return;
4661 m.StoreToPointer(&result, kMachFloat64,
4662 m.Float64Ceil(m.LoadFromPointer(&input, kMachFloat64)));
4663 m.Return(m.Int32Constant(0));
4664 for (size_t i = 0; i < arraysize(kValues); ++i) {
4665 input = kValues[i];
4666 CHECK_EQ(0, m.Call());
4667 double expected = std::ceil(kValues[i]);
4668 CHECK_EQ(expected, result);
4669 }
4670 }
4671
4672
4673 TEST(RunFloat64RoundTruncate) {
4674 double input = -1.0;
4675 double result = 0.0;
4676 RawMachineAssemblerTester<int32_t> m;
4677 if (!m.machine()->HasFloat64Ceil()) return;
4678 m.StoreToPointer(
4679 &result, kMachFloat64,
4680 m.Float64RoundTruncate(m.LoadFromPointer(&input, kMachFloat64)));
4681 m.Return(m.Int32Constant(0));
4682 for (size_t i = 0; i < arraysize(kValues); ++i) {
4683 input = kValues[i];
4684 CHECK_EQ(0, m.Call());
4685 double expected = trunc(kValues[i]);
4686 CHECK_EQ(expected, result);
4687 }
4688 }
4689
4690
4691 TEST(RunFloat64RoundTiesAway) {
4692 double input = -1.0;
4693 double result = 0.0;
4694 RawMachineAssemblerTester<int32_t> m;
4695 if (!m.machine()->HasFloat64RoundTiesAway()) return;
4696 m.StoreToPointer(
4697 &result, kMachFloat64,
4698 m.Float64RoundTiesAway(m.LoadFromPointer(&input, kMachFloat64)));
4699 m.Return(m.Int32Constant(0));
4700 for (size_t i = 0; i < arraysize(kValues); ++i) {
4701 input = kValues[i];
4702 CHECK_EQ(0, m.Call());
4703 double expected = round(kValues[i]);
4704 CHECK_EQ(expected, result);
4705 }
4706 }
4539 #endif // V8_TURBOFAN_TARGET 4707 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « test/cctest/compiler/codegen-tester.h ('k') | test/mjsunit/asm/math-ceil.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698