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 3999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4010 *i >= static_cast<float>(std::numeric_limits<int32_t>::min())) { | 4010 *i >= static_cast<float>(std::numeric_limits<int32_t>::min())) { |
4011 CHECK_FLOAT_EQ(static_cast<int32_t>(*i), m.Call(*i)); | 4011 CHECK_FLOAT_EQ(static_cast<int32_t>(*i), m.Call(*i)); |
4012 } | 4012 } |
4013 } | 4013 } |
4014 } | 4014 } |
4015 | 4015 |
4016 | 4016 |
4017 TEST(RunTruncateFloat32ToUint32) { | 4017 TEST(RunTruncateFloat32ToUint32) { |
4018 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float32()); | 4018 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float32()); |
4019 m.Return(m.TruncateFloat32ToUint32(m.Parameter(0))); | 4019 m.Return(m.TruncateFloat32ToUint32(m.Parameter(0))); |
4020 { | 4020 {FOR_UINT32_INPUTS(i){volatile float input = static_cast<float>(*i); |
titzer
2016/04/21 07:09:00
This somehow got formatted strangely. Maybe disabl
| |
4021 FOR_UINT32_INPUTS(i) { | 4021 // This condition on 'input' is required because |
4022 float input = static_cast<float>(*i); | 4022 // static_cast<float>(std::numeric_limits<uint32_t>::max()) results in a |
4023 // This condition on 'input' is required because | 4023 // value outside uint32 range. |
4024 // static_cast<float>(std::numeric_limits<uint32_t>::max()) results in a | 4024 if (input < static_cast<float>(std::numeric_limits<uint32_t>::max())) { |
4025 // value outside uint32 range. | 4025 CHECK_EQ(static_cast<uint32_t>(input), m.Call(input)); |
4026 if (input < static_cast<float>(std::numeric_limits<uint32_t>::max())) { | |
4027 CHECK_EQ(static_cast<uint32_t>(input), m.Call(input)); | |
4028 } | 4026 } |
4029 } | 4027 } |
4030 } | 4028 } |
4031 { | 4029 { |
4032 FOR_FLOAT32_INPUTS(i) { | 4030 FOR_FLOAT32_INPUTS(i) { |
4033 if (*i <= static_cast<float>(std::numeric_limits<uint32_t>::max()) && | 4031 if (*i <= static_cast<float>(std::numeric_limits<uint32_t>::max()) && |
4034 *i >= static_cast<float>(std::numeric_limits<uint32_t>::min())) { | 4032 *i >= static_cast<float>(std::numeric_limits<uint32_t>::min())) { |
4035 CHECK_FLOAT_EQ(static_cast<uint32_t>(*i), m.Call(*i)); | 4033 CHECK_FLOAT_EQ(static_cast<uint32_t>(*i), m.Call(*i)); |
4036 } | 4034 } |
4037 } | 4035 } |
(...skipping 2204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6242 r.Goto(&merge); | 6240 r.Goto(&merge); |
6243 r.Bind(&merge); | 6241 r.Bind(&merge); |
6244 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); | 6242 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); |
6245 r.Return(phi); | 6243 r.Return(phi); |
6246 CHECK_EQ(1, r.Call(1)); | 6244 CHECK_EQ(1, r.Call(1)); |
6247 } | 6245 } |
6248 | 6246 |
6249 } // namespace compiler | 6247 } // namespace compiler |
6250 } // namespace internal | 6248 } // namespace internal |
6251 } // namespace v8 | 6249 } // namespace v8 |
OLD | NEW |