OLD | NEW |
---|---|
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/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
(...skipping 4118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4129 m.Return(m.TruncateFloat32ToInt32(m.Parameter(0))); | 4129 m.Return(m.TruncateFloat32ToInt32(m.Parameter(0))); |
4130 FOR_FLOAT32_INPUTS(i) { | 4130 FOR_FLOAT32_INPUTS(i) { |
4131 if (*i <= static_cast<float>(std::numeric_limits<int32_t>::max()) && | 4131 if (*i <= static_cast<float>(std::numeric_limits<int32_t>::max()) && |
4132 *i >= static_cast<float>(std::numeric_limits<int32_t>::min())) { | 4132 *i >= static_cast<float>(std::numeric_limits<int32_t>::min())) { |
4133 CheckFloatEq(static_cast<int32_t>(*i), m.Call(*i)); | 4133 CheckFloatEq(static_cast<int32_t>(*i), m.Call(*i)); |
4134 } | 4134 } |
4135 } | 4135 } |
4136 } | 4136 } |
4137 | 4137 |
4138 | 4138 |
4139 TEST(RunTruncateFloat32ToUint32) { | |
4140 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float32()); | |
4141 m.Return(m.TruncateFloat32ToUint32(m.Parameter(0))); | |
4142 | |
4143 FOR_UINT32_INPUTS(i) { | |
ahaas
2016/01/29 10:45:08
Could you also run tests for FOR_FLOAT32_INPUTS wh
| |
4144 float input = static_cast<float>(*i); | |
4145 // This condition on 'input' is required because | |
4146 // static_cast<float>(UINT32_MAX) results in a value outside uint32 range. | |
4147 if (input < static_cast<float>(UINT32_MAX)) { | |
4148 CHECK_EQ(static_cast<uint32_t>(input), m.Call(input)); | |
4149 } | |
4150 } | |
4151 } | |
4152 | |
4153 | |
4139 TEST(RunChangeFloat64ToInt32_A) { | 4154 TEST(RunChangeFloat64ToInt32_A) { |
4140 BufferedRawMachineAssemblerTester<int32_t> m; | 4155 BufferedRawMachineAssemblerTester<int32_t> m; |
4141 double magic = 11.1; | 4156 double magic = 11.1; |
4142 m.Return(m.ChangeFloat64ToInt32(m.Float64Constant(magic))); | 4157 m.Return(m.ChangeFloat64ToInt32(m.Float64Constant(magic))); |
4143 CHECK_EQ(static_cast<int32_t>(magic), m.Call()); | 4158 CHECK_EQ(static_cast<int32_t>(magic), m.Call()); |
4144 } | 4159 } |
4145 | 4160 |
4146 | 4161 |
4147 TEST(RunChangeFloat64ToInt32_B) { | 4162 TEST(RunChangeFloat64ToInt32_B) { |
4148 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Float64()); | 4163 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Float64()); |
(...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6083 Node* call = r.AddNode(r.common()->Call(desc), phi); | 6098 Node* call = r.AddNode(r.common()->Call(desc), phi); |
6084 r.Return(call); | 6099 r.Return(call); |
6085 | 6100 |
6086 CHECK_EQ(33, r.Call(1)); | 6101 CHECK_EQ(33, r.Call(1)); |
6087 CHECK_EQ(44, r.Call(0)); | 6102 CHECK_EQ(44, r.Call(0)); |
6088 } | 6103 } |
6089 | 6104 |
6090 } // namespace compiler | 6105 } // namespace compiler |
6091 } // namespace internal | 6106 } // namespace internal |
6092 } // namespace v8 | 6107 } // namespace v8 |
OLD | NEW |