| 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 5401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5412 TEST(RunFloat32RoundDown) { | 5412 TEST(RunFloat32RoundDown) { |
| 5413 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); | 5413 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); |
| 5414 if (!m.machine()->Float32RoundDown().IsSupported()) return; | 5414 if (!m.machine()->Float32RoundDown().IsSupported()) return; |
| 5415 | 5415 |
| 5416 m.Return(m.Float32RoundDown(m.Parameter(0))); | 5416 m.Return(m.Float32RoundDown(m.Parameter(0))); |
| 5417 | 5417 |
| 5418 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(floorf(*i), m.Call(*i)); } | 5418 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(floorf(*i), m.Call(*i)); } |
| 5419 } | 5419 } |
| 5420 | 5420 |
| 5421 | 5421 |
| 5422 TEST(RunFloat32RoundDownMinusZero) { |
| 5423 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32()); |
| 5424 if (!m.machine()->Float32RoundDown().IsSupported()) return; |
| 5425 |
| 5426 m.Return(m.Float32RoundDown(m.Parameter(0))); |
| 5427 int32_t expected = bit_cast<int32_t>(-0.0f); |
| 5428 int32_t result = bit_cast<int32_t>(m.Call(-0.0f)); |
| 5429 CHECK_EQ(expected, result); |
| 5430 } |
| 5431 |
| 5432 |
| 5433 TEST(RunFloat64RoundDownMinusZero) { |
| 5434 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); |
| 5435 if (!m.machine()->Float64RoundDown().IsSupported()) return; |
| 5436 |
| 5437 m.Return(m.Float64RoundDown(m.Parameter(0))); |
| 5438 int64_t expected = bit_cast<int64_t>(-0.0); |
| 5439 int64_t result = bit_cast<int64_t>(m.Call(-0.0)); |
| 5440 CHECK_EQ(expected, result); |
| 5441 } |
| 5442 |
| 5443 |
| 5422 TEST(RunFloat64RoundDown1) { | 5444 TEST(RunFloat64RoundDown1) { |
| 5423 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); | 5445 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); |
| 5424 if (!m.machine()->Float64RoundDown().IsSupported()) return; | 5446 if (!m.machine()->Float64RoundDown().IsSupported()) return; |
| 5425 | 5447 |
| 5426 m.Return(m.Float64RoundDown(m.Parameter(0))); | 5448 m.Return(m.Float64RoundDown(m.Parameter(0))); |
| 5427 | 5449 |
| 5428 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(floor(*i), m.Call(*i)); } | 5450 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(floor(*i), m.Call(*i)); } |
| 5429 } | 5451 } |
| 5430 | 5452 |
| 5431 | 5453 |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6083 Node* call = r.AddNode(r.common()->Call(desc), phi); | 6105 Node* call = r.AddNode(r.common()->Call(desc), phi); |
| 6084 r.Return(call); | 6106 r.Return(call); |
| 6085 | 6107 |
| 6086 CHECK_EQ(33, r.Call(1)); | 6108 CHECK_EQ(33, r.Call(1)); |
| 6087 CHECK_EQ(44, r.Call(0)); | 6109 CHECK_EQ(44, r.Call(0)); |
| 6088 } | 6110 } |
| 6089 | 6111 |
| 6090 } // namespace compiler | 6112 } // namespace compiler |
| 6091 } // namespace internal | 6113 } // namespace internal |
| 6092 } // namespace v8 | 6114 } // namespace v8 |
| OLD | NEW |