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 5997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6008 input = *i; | 6008 input = *i; |
6009 int32_t expected = bit_cast<int32_t>(input); | 6009 int32_t expected = bit_cast<int32_t>(input); |
6010 CHECK_EQ(expected, m.Call()); | 6010 CHECK_EQ(expected, m.Call()); |
6011 } | 6011 } |
6012 } | 6012 } |
6013 | 6013 |
6014 | 6014 |
6015 TEST(RunRoundInt32ToFloat32) { | 6015 TEST(RunRoundInt32ToFloat32) { |
6016 BufferedRawMachineAssemblerTester<float> m(MachineType::Int32()); | 6016 BufferedRawMachineAssemblerTester<float> m(MachineType::Int32()); |
6017 m.Return(m.RoundInt32ToFloat32(m.Parameter(0))); | 6017 m.Return(m.RoundInt32ToFloat32(m.Parameter(0))); |
6018 FOR_INT32_INPUTS(i) { CHECK_EQ(static_cast<float>(*i), m.Call(*i)); } | 6018 FOR_INT32_INPUTS(i) { |
| 6019 volatile float expected = static_cast<float>(*i); |
| 6020 CHECK_EQ(expected, m.Call(*i)); |
| 6021 } |
6019 } | 6022 } |
6020 | 6023 |
6021 | 6024 |
6022 TEST(RunBitcastInt32ToFloat32) { | 6025 TEST(RunBitcastInt32ToFloat32) { |
6023 int32_t input = 1; | 6026 int32_t input = 1; |
6024 float output = 0.0; | 6027 float output = 0.0; |
6025 RawMachineAssemblerTester<int32_t> m; | 6028 RawMachineAssemblerTester<int32_t> m; |
6026 m.StoreToPointer( | 6029 m.StoreToPointer( |
6027 &output, MachineRepresentation::kFloat32, | 6030 &output, MachineRepresentation::kFloat32, |
6028 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, MachineType::Int32()))); | 6031 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, MachineType::Int32()))); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6082 Node* call = r.AddNode(r.common()->Call(desc), phi); | 6085 Node* call = r.AddNode(r.common()->Call(desc), phi); |
6083 r.Return(call); | 6086 r.Return(call); |
6084 | 6087 |
6085 CHECK_EQ(33, r.Call(1)); | 6088 CHECK_EQ(33, r.Call(1)); |
6086 CHECK_EQ(44, r.Call(0)); | 6089 CHECK_EQ(44, r.Call(0)); |
6087 } | 6090 } |
6088 | 6091 |
6089 } // namespace compiler | 6092 } // namespace compiler |
6090 } // namespace internal | 6093 } // namespace internal |
6091 } // namespace v8 | 6094 } // namespace v8 |
OLD | NEW |