| 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 3697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3708 RawMachineAssemblerTester<int32_t> m; | 3708 RawMachineAssemblerTester<int32_t> m; |
| 3709 Float64BinopTester bt(&m); | 3709 Float64BinopTester bt(&m); |
| 3710 | 3710 |
| 3711 bt.AddReturn(m.Float64Add(bt.param0, bt.param1)); | 3711 bt.AddReturn(m.Float64Add(bt.param0, bt.param1)); |
| 3712 | 3712 |
| 3713 FOR_FLOAT64_INPUTS(pl) { | 3713 FOR_FLOAT64_INPUTS(pl) { |
| 3714 FOR_FLOAT64_INPUTS(pr) { CHECK_DOUBLE_EQ(*pl + *pr, bt.call(*pl, *pr)); } | 3714 FOR_FLOAT64_INPUTS(pr) { CHECK_DOUBLE_EQ(*pl + *pr, bt.call(*pl, *pr)); } |
| 3715 } | 3715 } |
| 3716 } | 3716 } |
| 3717 | 3717 |
| 3718 namespace { |
| 3718 | 3719 |
| 3719 TEST(RunFloa32MaxP) { | 3720 double fmax(double x, double y) { |
| 3720 RawMachineAssemblerTester<int32_t> m; | 3721 if (std::isnan(x)) return x; |
| 3721 Float32BinopTester bt(&m); | 3722 if (std::isnan(y)) return y; |
| 3722 if (!m.machine()->Float32Max().IsSupported()) return; | 3723 if (std::signbit(x) < std::signbit(y)) return x; |
| 3723 | 3724 return std::max(x, y); |
| 3724 bt.AddReturn(m.Float32Max(bt.param0, bt.param1)); | |
| 3725 | |
| 3726 FOR_FLOAT32_INPUTS(pl) { | |
| 3727 FOR_FLOAT32_INPUTS(pr) { | |
| 3728 CHECK_DOUBLE_EQ(*pl > *pr ? *pl : *pr, bt.call(*pl, *pr)); | |
| 3729 } | |
| 3730 } | |
| 3731 } | 3725 } |
| 3732 | 3726 |
| 3727 double fmin(double x, double y) { |
| 3728 if (std::isnan(x)) return x; |
| 3729 if (std::isnan(y)) return y; |
| 3730 if (std::signbit(x) < std::signbit(y)) return y; |
| 3731 return std::min(x, y); |
| 3732 } |
| 3733 |
| 3734 } // namespace |
| 3733 | 3735 |
| 3734 TEST(RunFloat64MaxP) { | 3736 TEST(RunFloat64MaxP) { |
| 3735 RawMachineAssemblerTester<int32_t> m; | 3737 RawMachineAssemblerTester<int32_t> m; |
| 3736 Float64BinopTester bt(&m); | 3738 Float64BinopTester bt(&m); |
| 3737 if (!m.machine()->Float64Max().IsSupported()) return; | |
| 3738 | |
| 3739 bt.AddReturn(m.Float64Max(bt.param0, bt.param1)); | 3739 bt.AddReturn(m.Float64Max(bt.param0, bt.param1)); |
| 3740 | 3740 |
| 3741 FOR_FLOAT64_INPUTS(pl) { | 3741 FOR_FLOAT64_INPUTS(pl) { |
| 3742 FOR_FLOAT64_INPUTS(pr) { | 3742 FOR_FLOAT64_INPUTS(pr) { |
| 3743 CHECK_DOUBLE_EQ(*pl > *pr ? *pl : *pr, bt.call(*pl, *pr)); | 3743 CHECK_DOUBLE_EQ(fmax(*pl, *pr), bt.call(*pl, *pr)); |
| 3744 } | 3744 } |
| 3745 } | 3745 } |
| 3746 } | 3746 } |
| 3747 | |
| 3748 | |
| 3749 TEST(RunFloat32MinP) { | |
| 3750 RawMachineAssemblerTester<int32_t> m; | |
| 3751 Float32BinopTester bt(&m); | |
| 3752 if (!m.machine()->Float32Min().IsSupported()) return; | |
| 3753 | |
| 3754 bt.AddReturn(m.Float32Min(bt.param0, bt.param1)); | |
| 3755 | |
| 3756 FOR_FLOAT32_INPUTS(pl) { | |
| 3757 FOR_FLOAT32_INPUTS(pr) { | |
| 3758 CHECK_DOUBLE_EQ(*pl < *pr ? *pl : *pr, bt.call(*pl, *pr)); | |
| 3759 } | |
| 3760 } | |
| 3761 } | |
| 3762 | 3747 |
| 3763 | 3748 |
| 3764 TEST(RunFloat64MinP) { | 3749 TEST(RunFloat64MinP) { |
| 3765 RawMachineAssemblerTester<int32_t> m; | 3750 RawMachineAssemblerTester<int32_t> m; |
| 3766 Float64BinopTester bt(&m); | 3751 Float64BinopTester bt(&m); |
| 3767 if (!m.machine()->Float64Min().IsSupported()) return; | |
| 3768 | |
| 3769 bt.AddReturn(m.Float64Min(bt.param0, bt.param1)); | 3752 bt.AddReturn(m.Float64Min(bt.param0, bt.param1)); |
| 3770 | 3753 |
| 3771 FOR_FLOAT64_INPUTS(pl) { | 3754 FOR_FLOAT64_INPUTS(pl) { |
| 3772 FOR_FLOAT64_INPUTS(pr) { | 3755 FOR_FLOAT64_INPUTS(pr) { |
| 3773 CHECK_DOUBLE_EQ(*pl < *pr ? *pl : *pr, bt.call(*pl, *pr)); | 3756 CHECK_DOUBLE_EQ(fmin(*pl, *pr), bt.call(*pl, *pr)); |
| 3774 } | 3757 } |
| 3775 } | 3758 } |
| 3776 } | 3759 } |
| 3777 | 3760 |
| 3778 | 3761 |
| 3779 TEST(RunFloat32SubP) { | 3762 TEST(RunFloat32SubP) { |
| 3780 RawMachineAssemblerTester<int32_t> m; | 3763 RawMachineAssemblerTester<int32_t> m; |
| 3781 Float32BinopTester bt(&m); | 3764 Float32BinopTester bt(&m); |
| 3782 | 3765 |
| 3783 bt.AddReturn(m.Float32Sub(bt.param0, bt.param1)); | 3766 bt.AddReturn(m.Float32Sub(bt.param0, bt.param1)); |
| (...skipping 2766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6550 r.Goto(&merge); | 6533 r.Goto(&merge); |
| 6551 r.Bind(&merge); | 6534 r.Bind(&merge); |
| 6552 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); | 6535 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); |
| 6553 r.Return(phi); | 6536 r.Return(phi); |
| 6554 CHECK_EQ(1, r.Call(1)); | 6537 CHECK_EQ(1, r.Call(1)); |
| 6555 } | 6538 } |
| 6556 | 6539 |
| 6557 } // namespace compiler | 6540 } // namespace compiler |
| 6558 } // namespace internal | 6541 } // namespace internal |
| 6559 } // namespace v8 | 6542 } // namespace v8 |
| OLD | NEW |