Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: test/cctest/compiler/test-run-machops.cc

Issue 2252863003: [turbofan] Add Float32(Max|Min) machine operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3772 matching lines...) Expand 10 before | Expand all | Expand 10 after
3783 Float64BinopTester bt(&m); 3783 Float64BinopTester bt(&m);
3784 bt.AddReturn(m.Float64Min(bt.param0, bt.param1)); 3784 bt.AddReturn(m.Float64Min(bt.param0, bt.param1));
3785 3785
3786 FOR_FLOAT64_INPUTS(pl) { 3786 FOR_FLOAT64_INPUTS(pl) {
3787 FOR_FLOAT64_INPUTS(pr) { 3787 FOR_FLOAT64_INPUTS(pr) {
3788 CHECK_DOUBLE_EQ(fmin(*pl, *pr), bt.call(*pl, *pr)); 3788 CHECK_DOUBLE_EQ(fmin(*pl, *pr), bt.call(*pl, *pr));
3789 } 3789 }
3790 } 3790 }
3791 } 3791 }
3792 3792
3793 namespace {
3794
3795 float fmax(float x, float y) {
titzer 2016/08/17 11:26:09 Can you move this to a common place so that it can
ahaas 2016/08/18 07:13:20 Done.
3796 if (std::isnan(x)) return x;
3797 if (std::isnan(y)) return y;
3798 if (std::signbit(x) < std::signbit(y)) return x;
3799 return std::max(x, y);
3800 }
3801
3802 float fmin(float x, float y) {
3803 if (std::isnan(x)) return x;
3804 if (std::isnan(y)) return y;
3805 if (std::signbit(x) < std::signbit(y)) return y;
3806 return std::min(x, y);
3807 }
3808
3809 } // namespace
3810
3811 TEST(RunFloat32Max) {
3812 RawMachineAssemblerTester<int32_t> m;
3813 Float32BinopTester bt(&m);
3814 bt.AddReturn(m.Float32Max(bt.param0, bt.param1));
3815
3816 FOR_FLOAT32_INPUTS(pl) {
3817 FOR_FLOAT32_INPUTS(pr) {
3818 CHECK_FLOAT_EQ(fmax(*pl, *pr), bt.call(*pl, *pr));
3819 }
3820 }
3821 }
3822
3823 TEST(RunFloat32Min) {
3824 RawMachineAssemblerTester<int32_t> m;
3825 Float32BinopTester bt(&m);
3826 bt.AddReturn(m.Float32Min(bt.param0, bt.param1));
3827
3828 FOR_FLOAT32_INPUTS(pl) {
3829 FOR_FLOAT32_INPUTS(pr) {
3830 CHECK_FLOAT_EQ(fmin(*pl, *pr), bt.call(*pl, *pr));
3831 }
3832 }
3833 }
3793 3834
3794 TEST(RunFloat32SubP) { 3835 TEST(RunFloat32SubP) {
3795 RawMachineAssemblerTester<int32_t> m; 3836 RawMachineAssemblerTester<int32_t> m;
3796 Float32BinopTester bt(&m); 3837 Float32BinopTester bt(&m);
3797 3838
3798 bt.AddReturn(m.Float32Sub(bt.param0, bt.param1)); 3839 bt.AddReturn(m.Float32Sub(bt.param0, bt.param1));
3799 3840
3800 FOR_FLOAT32_INPUTS(pl) { 3841 FOR_FLOAT32_INPUTS(pl) {
3801 FOR_FLOAT32_INPUTS(pr) { CHECK_FLOAT_EQ(*pl - *pr, bt.call(*pl, *pr)); } 3842 FOR_FLOAT32_INPUTS(pr) { CHECK_FLOAT_EQ(*pl - *pr, bt.call(*pl, *pr)); }
3802 } 3843 }
(...skipping 2762 matching lines...) Expand 10 before | Expand all | Expand 10 after
6565 r.Goto(&merge); 6606 r.Goto(&merge);
6566 r.Bind(&merge); 6607 r.Bind(&merge);
6567 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); 6608 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb);
6568 r.Return(phi); 6609 r.Return(phi);
6569 CHECK_EQ(1, r.Call(1)); 6610 CHECK_EQ(1, r.Call(1));
6570 } 6611 }
6571 6612
6572 } // namespace compiler 6613 } // namespace compiler
6573 } // namespace internal 6614 } // namespace internal
6574 } // namespace v8 6615 } // namespace v8
OLDNEW
« src/compiler/machine-operator.cc ('K') | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698