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/ieee754.h" | 10 #include "src/base/ieee754.h" |
(...skipping 4012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4023 *i >= static_cast<float>(std::numeric_limits<int32_t>::min())) { | 4023 *i >= static_cast<float>(std::numeric_limits<int32_t>::min())) { |
4024 CHECK_FLOAT_EQ(static_cast<int32_t>(*i), m.Call(*i)); | 4024 CHECK_FLOAT_EQ(static_cast<int32_t>(*i), m.Call(*i)); |
4025 } | 4025 } |
4026 } | 4026 } |
4027 } | 4027 } |
4028 | 4028 |
4029 | 4029 |
4030 TEST(RunTruncateFloat32ToUint32) { | 4030 TEST(RunTruncateFloat32ToUint32) { |
4031 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float32()); | 4031 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float32()); |
4032 m.Return(m.TruncateFloat32ToUint32(m.Parameter(0))); | 4032 m.Return(m.TruncateFloat32ToUint32(m.Parameter(0))); |
4033 { | |
4034 FOR_UINT32_INPUTS(i) { | 4033 FOR_UINT32_INPUTS(i) { |
4035 volatile float input = static_cast<float>(*i); | 4034 volatile float input = static_cast<float>(*i); |
4036 // This condition on 'input' is required because | 4035 // This condition on 'input' is required because |
4037 // static_cast<float>(std::numeric_limits<uint32_t>::max()) results in a | 4036 // static_cast<float>(UINT32_MAX) results in a value outside uint32 range. |
4038 // value outside uint32 range. | 4037 if (input < (static_cast<float>(static_cast<uint64_t>(UINT32_MAX) + 1))) { |
4039 if (input < static_cast<float>(std::numeric_limits<uint32_t>::max())) { | |
4040 CHECK_EQ(static_cast<uint32_t>(input), m.Call(input)); | 4038 CHECK_EQ(static_cast<uint32_t>(input), m.Call(input)); |
4041 } | 4039 } |
4042 } | 4040 } |
4043 } | 4041 FOR_FLOAT32_INPUTS(j) { |
4044 { | 4042 if (*j < (static_cast<float>(static_cast<uint64_t>(UINT32_MAX) + 1)) && |
4045 FOR_FLOAT32_INPUTS(i) { | 4043 *j > -1) { |
4046 if (*i <= static_cast<float>(std::numeric_limits<uint32_t>::max()) && | 4044 CHECK_FLOAT_EQ(static_cast<uint32_t>(*j), m.Call(*j)); |
4047 *i >= static_cast<float>(std::numeric_limits<uint32_t>::min())) { | |
4048 CHECK_FLOAT_EQ(static_cast<uint32_t>(*i), m.Call(*i)); | |
4049 } | 4045 } |
4050 } | 4046 } |
4051 } | |
4052 } | 4047 } |
4053 | 4048 |
4054 | 4049 |
4055 TEST(RunChangeFloat64ToInt32_A) { | 4050 TEST(RunChangeFloat64ToInt32_A) { |
4056 BufferedRawMachineAssemblerTester<int32_t> m; | 4051 BufferedRawMachineAssemblerTester<int32_t> m; |
4057 double magic = 11.1; | 4052 double magic = 11.1; |
4058 m.Return(m.ChangeFloat64ToInt32(m.Float64Constant(magic))); | 4053 m.Return(m.ChangeFloat64ToInt32(m.Float64Constant(magic))); |
4059 CHECK_EQ(static_cast<int32_t>(magic), m.Call()); | 4054 CHECK_EQ(static_cast<int32_t>(magic), m.Call()); |
4060 } | 4055 } |
4061 | 4056 |
(...skipping 2347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6409 r.Goto(&merge); | 6404 r.Goto(&merge); |
6410 r.Bind(&merge); | 6405 r.Bind(&merge); |
6411 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); | 6406 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); |
6412 r.Return(phi); | 6407 r.Return(phi); |
6413 CHECK_EQ(1, r.Call(1)); | 6408 CHECK_EQ(1, r.Call(1)); |
6414 } | 6409 } |
6415 | 6410 |
6416 } // namespace compiler | 6411 } // namespace compiler |
6417 } // namespace internal | 6412 } // namespace internal |
6418 } // namespace v8 | 6413 } // namespace v8 |
OLD | NEW |