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

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

Issue 990963003: [turbofan] Unify Math.floor / Math.ceil optimization. (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
« no previous file with comments | « src/x64/lithium-codegen-x64.cc ('k') | test/unittests/compiler/js-builtin-reducer-unittest.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. 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 <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/codegen.h" 10 #include "src/codegen.h"
(...skipping 4793 matching lines...) Expand 10 before | Expand all | Expand 10 after
4804 -two_52, 4804 -two_52,
4805 -two_52 - 0.1, 4805 -two_52 - 0.1,
4806 -two_52 - 0.5, 4806 -two_52 - 0.5,
4807 -two_52 - 0.7, 4807 -two_52 - 0.7,
4808 -two_52 + 1, 4808 -two_52 + 1,
4809 -two_52 + 1 - 0.1, 4809 -two_52 + 1 - 0.1,
4810 -two_52 + 1 - 0.5, 4810 -two_52 + 1 - 0.5,
4811 -two_52 + 1 - 0.7}; 4811 -two_52 + 1 - 0.7};
4812 4812
4813 4813
4814 TEST(RunFloat64Floor) { 4814 TEST(RunFloat64RoundDown1) {
4815 double input = -1.0; 4815 double input = -1.0;
4816 double result = 0.0; 4816 double result = 0.0;
4817 RawMachineAssemblerTester<int32_t> m; 4817 RawMachineAssemblerTester<int32_t> m;
4818 if (!m.machine()->HasFloat64Floor()) return; 4818 if (!m.machine()->HasFloat64RoundDown()) return;
4819 m.StoreToPointer(&result, kMachFloat64, 4819 m.StoreToPointer(&result, kMachFloat64,
4820 m.Float64Floor(m.LoadFromPointer(&input, kMachFloat64))); 4820 m.Float64RoundDown(m.LoadFromPointer(&input, kMachFloat64)));
4821 m.Return(m.Int32Constant(0)); 4821 m.Return(m.Int32Constant(0));
4822 for (size_t i = 0; i < arraysize(kValues); ++i) { 4822 for (size_t i = 0; i < arraysize(kValues); ++i) {
4823 input = kValues[i]; 4823 input = kValues[i];
4824 CHECK_EQ(0, m.Call()); 4824 CHECK_EQ(0, m.Call());
4825 double expected = std::floor(kValues[i]); 4825 double expected = std::floor(kValues[i]);
4826 CHECK_EQ(expected, result); 4826 CHECK_EQ(expected, result);
4827 } 4827 }
4828 } 4828 }
4829 4829
4830 4830
4831 TEST(RunFloat64Ceil) { 4831 TEST(RunFloat64RoundDown2) {
4832 double input = -1.0; 4832 double input = -1.0;
4833 double result = 0.0; 4833 double result = 0.0;
4834 RawMachineAssemblerTester<int32_t> m; 4834 RawMachineAssemblerTester<int32_t> m;
4835 if (!m.machine()->HasFloat64Ceil()) return; 4835 if (!m.machine()->HasFloat64RoundDown()) return;
4836 m.StoreToPointer(&result, kMachFloat64, 4836 m.StoreToPointer(&result, kMachFloat64,
4837 m.Float64Ceil(m.LoadFromPointer(&input, kMachFloat64))); 4837 m.Float64Sub(m.Float64Constant(-0.0),
4838 m.Float64RoundDown(m.Float64Sub(
4839 m.Float64Constant(-0.0),
4840 m.LoadFromPointer(&input, kMachFloat64)))));
4838 m.Return(m.Int32Constant(0)); 4841 m.Return(m.Int32Constant(0));
4839 for (size_t i = 0; i < arraysize(kValues); ++i) { 4842 for (size_t i = 0; i < arraysize(kValues); ++i) {
4840 input = kValues[i]; 4843 input = kValues[i];
4841 CHECK_EQ(0, m.Call()); 4844 CHECK_EQ(0, m.Call());
4842 double expected = std::ceil(kValues[i]); 4845 double expected = std::ceil(kValues[i]);
4843 CHECK_EQ(expected, result); 4846 CHECK_EQ(expected, result);
4844 } 4847 }
4845 } 4848 }
4846 4849
4847 4850
4848 TEST(RunFloat64RoundTruncate) { 4851 TEST(RunFloat64RoundTruncate) {
4849 double input = -1.0; 4852 double input = -1.0;
4850 double result = 0.0; 4853 double result = 0.0;
4851 RawMachineAssemblerTester<int32_t> m; 4854 RawMachineAssemblerTester<int32_t> m;
4852 if (!m.machine()->HasFloat64Ceil()) return; 4855 if (!m.machine()->HasFloat64RoundTruncate()) return;
4853 m.StoreToPointer( 4856 m.StoreToPointer(
4854 &result, kMachFloat64, 4857 &result, kMachFloat64,
4855 m.Float64RoundTruncate(m.LoadFromPointer(&input, kMachFloat64))); 4858 m.Float64RoundTruncate(m.LoadFromPointer(&input, kMachFloat64)));
4856 m.Return(m.Int32Constant(0)); 4859 m.Return(m.Int32Constant(0));
4857 for (size_t i = 0; i < arraysize(kValues); ++i) { 4860 for (size_t i = 0; i < arraysize(kValues); ++i) {
4858 input = kValues[i]; 4861 input = kValues[i];
4859 CHECK_EQ(0, m.Call()); 4862 CHECK_EQ(0, m.Call());
4860 double expected = trunc(kValues[i]); 4863 double expected = trunc(kValues[i]);
4861 CHECK_EQ(expected, result); 4864 CHECK_EQ(expected, result);
4862 } 4865 }
(...skipping 11 matching lines...) Expand all
4874 m.Return(m.Int32Constant(0)); 4877 m.Return(m.Int32Constant(0));
4875 for (size_t i = 0; i < arraysize(kValues); ++i) { 4878 for (size_t i = 0; i < arraysize(kValues); ++i) {
4876 input = kValues[i]; 4879 input = kValues[i];
4877 CHECK_EQ(0, m.Call()); 4880 CHECK_EQ(0, m.Call());
4878 double expected = round(kValues[i]); 4881 double expected = round(kValues[i]);
4879 CHECK_EQ(expected, result); 4882 CHECK_EQ(expected, result);
4880 } 4883 }
4881 } 4884 }
4882 4885
4883 #endif // V8_TURBOFAN_TARGET 4886 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.cc ('k') | test/unittests/compiler/js-builtin-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698