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

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

Issue 1066393002: [turbofan] Add new Float32Abs and Float64Abs operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix comment. Created 5 years, 8 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/math.js ('k') | test/cctest/compiler/value-helper.h » ('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 4927 matching lines...) Expand 10 before | Expand all | Expand 10 after
4938 input = bit_cast<uint64_t>(*i); 4938 input = bit_cast<uint64_t>(*i);
4939 uint64_t expected = (input & ~(V8_UINT64_C(0xFFFFFFFF) << 32)) | 4939 uint64_t expected = (input & ~(V8_UINT64_C(0xFFFFFFFF) << 32)) |
4940 (static_cast<uint64_t>(bit_cast<uint32_t>(*j)) << 32); 4940 (static_cast<uint64_t>(bit_cast<uint32_t>(*j)) << 32);
4941 CHECK_EQ(0, m.Call(*j)); 4941 CHECK_EQ(0, m.Call(*j));
4942 CHECK_EQ(expected, result); 4942 CHECK_EQ(expected, result);
4943 } 4943 }
4944 } 4944 }
4945 } 4945 }
4946 4946
4947 4947
4948 TEST(RunFloat32Abs) {
4949 float input = -1.0;
4950 float result = 0.0;
4951 RawMachineAssemblerTester<int32_t> m;
4952 if (!m.machine()->HasFloat32Abs()) return;
4953 m.StoreToPointer(&result, kMachFloat32,
4954 m.Float32Abs(m.LoadFromPointer(&input, kMachFloat32)));
4955 m.Return(m.Int32Constant(0));
4956 FOR_FLOAT32_INPUTS(i) {
4957 input = *i;
4958 float expected = std::abs(input);
4959 CHECK_EQ(0, m.Call());
4960 CheckFloatEq(expected, result);
4961 }
4962 }
4963
4964
4965 TEST(RunFloat64Abs) {
4966 double input = -1.0;
4967 double result = 0.0;
4968 RawMachineAssemblerTester<int32_t> m;
4969 if (!m.machine()->HasFloat64Abs()) return;
4970 m.StoreToPointer(&result, kMachFloat64,
4971 m.Float64Abs(m.LoadFromPointer(&input, kMachFloat64)));
4972 m.Return(m.Int32Constant(0));
4973 FOR_FLOAT64_INPUTS(i) {
4974 input = *i;
4975 double expected = std::abs(input);
4976 CHECK_EQ(0, m.Call());
4977 CheckDoubleEq(expected, result);
4978 }
4979 }
4980
4981
4948 static double two_30 = 1 << 30; // 2^30 is a smi boundary. 4982 static double two_30 = 1 << 30; // 2^30 is a smi boundary.
4949 static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary. 4983 static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary.
4950 static double kValues[] = {0.1, 4984 static double kValues[] = {0.1,
4951 0.2, 4985 0.2,
4952 0.49999999999999994, 4986 0.49999999999999994,
4953 0.5, 4987 0.5,
4954 0.7, 4988 0.7,
4955 1.0 - std::numeric_limits<double>::epsilon(), 4989 1.0 - std::numeric_limits<double>::epsilon(),
4956 -0.1, 4990 -0.1,
4957 -0.49999999999999994, 4991 -0.49999999999999994,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
5109 m.Return(m.Int32Constant(0)); 5143 m.Return(m.Int32Constant(0));
5110 for (size_t i = 0; i < arraysize(kValues); ++i) { 5144 for (size_t i = 0; i < arraysize(kValues); ++i) {
5111 input = kValues[i]; 5145 input = kValues[i];
5112 CHECK_EQ(0, m.Call()); 5146 CHECK_EQ(0, m.Call());
5113 double expected = round(kValues[i]); 5147 double expected = round(kValues[i]);
5114 CHECK_EQ(expected, result); 5148 CHECK_EQ(expected, result);
5115 } 5149 }
5116 } 5150 }
5117 5151
5118 #endif // V8_TURBOFAN_TARGET 5152 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « src/math.js ('k') | test/cctest/compiler/value-helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698