OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/base/utils/random-number-generator.h" | 5 #include "src/base/utils/random-number-generator.h" |
6 #include "src/codegen.h" | 6 #include "src/codegen.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/machine-operator-reducer.h" | 8 #include "src/compiler/machine-operator-reducer.h" |
9 #include "src/compiler/operator-properties.h" | 9 #include "src/compiler/operator-properties.h" |
10 #include "src/compiler/typer.h" | 10 #include "src/compiler/typer.h" |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 R.binop = R.machine.Float32Sub(); | 843 R.binop = R.machine.Float32Sub(); |
844 | 844 |
845 FOR_FLOAT32_INPUTS(pl) { | 845 FOR_FLOAT32_INPUTS(pl) { |
846 FOR_FLOAT32_INPUTS(pr) { | 846 FOR_FLOAT32_INPUTS(pr) { |
847 float x = *pl, y = *pr; | 847 float x = *pl, y = *pr; |
848 R.CheckFoldBinop<float>(x - y, x, y); | 848 R.CheckFoldBinop<float>(x - y, x, y); |
849 } | 849 } |
850 } | 850 } |
851 | 851 |
852 Node* x = R.Parameter(); | 852 Node* x = R.Parameter(); |
853 Node* zero = R.Constant<float>(0.0); | |
854 Node* nan = R.Constant<float>(std::numeric_limits<float>::quiet_NaN()); | 853 Node* nan = R.Constant<float>(std::numeric_limits<float>::quiet_NaN()); |
855 | 854 |
856 R.CheckBinop(x, x, zero); // x - 0 => x | 855 // nan - x => nan |
857 R.CheckBinop(nan, nan, x); // nan - x => nan | 856 R.CheckFoldBinop(std::numeric_limits<float>::quiet_NaN(), nan, x); |
858 R.CheckBinop(nan, x, nan); // x - nan => nan | 857 // x - nan => nan |
| 858 R.CheckFoldBinop(std::numeric_limits<float>::quiet_NaN(), x, nan); |
859 } | 859 } |
860 | 860 |
861 TEST(ReduceFloat64Sub) { | 861 TEST(ReduceFloat64Sub) { |
862 ReducerTester R; | 862 ReducerTester R; |
863 R.binop = R.machine.Float64Sub(); | 863 R.binop = R.machine.Float64Sub(); |
864 | 864 |
865 FOR_FLOAT64_INPUTS(pl) { | 865 FOR_FLOAT64_INPUTS(pl) { |
866 FOR_FLOAT64_INPUTS(pr) { | 866 FOR_FLOAT64_INPUTS(pr) { |
867 double x = *pl, y = *pr; | 867 double x = *pl, y = *pr; |
868 R.CheckFoldBinop<double>(x - y, x, y); | 868 R.CheckFoldBinop<double>(x - y, x, y); |
869 } | 869 } |
870 } | 870 } |
871 | 871 |
872 Node* x = R.Parameter(); | 872 Node* x = R.Parameter(); |
873 Node* zero = R.Constant<double>(0.0); | |
874 Node* nan = R.Constant<double>(std::numeric_limits<double>::quiet_NaN()); | 873 Node* nan = R.Constant<double>(std::numeric_limits<double>::quiet_NaN()); |
875 | 874 |
876 R.CheckBinop(x, x, zero); // x - 0 => x | 875 // nan - x => nan |
877 R.CheckBinop(nan, nan, x); // nan - x => nan | 876 R.CheckFoldBinop(std::numeric_limits<double>::quiet_NaN(), nan, x); |
878 R.CheckBinop(nan, x, nan); // x - nan => nan | 877 // x - nan => nan |
| 878 R.CheckFoldBinop(std::numeric_limits<double>::quiet_NaN(), x, nan); |
879 } | 879 } |
880 | 880 |
881 // TODO(titzer): test MachineOperatorReducer for Word64And | 881 // TODO(titzer): test MachineOperatorReducer for Word64And |
882 // TODO(titzer): test MachineOperatorReducer for Word64Or | 882 // TODO(titzer): test MachineOperatorReducer for Word64Or |
883 // TODO(titzer): test MachineOperatorReducer for Word64Xor | 883 // TODO(titzer): test MachineOperatorReducer for Word64Xor |
884 // TODO(titzer): test MachineOperatorReducer for Word64Equal | 884 // TODO(titzer): test MachineOperatorReducer for Word64Equal |
885 // TODO(titzer): test MachineOperatorReducer for Word64Not | 885 // TODO(titzer): test MachineOperatorReducer for Word64Not |
886 // TODO(titzer): test MachineOperatorReducer for Int64Mul | 886 // TODO(titzer): test MachineOperatorReducer for Int64Mul |
887 // TODO(titzer): test MachineOperatorReducer for Int64UMul | 887 // TODO(titzer): test MachineOperatorReducer for Int64UMul |
888 // TODO(titzer): test MachineOperatorReducer for Int64Div | 888 // TODO(titzer): test MachineOperatorReducer for Int64Div |
889 // TODO(titzer): test MachineOperatorReducer for Uint64Div | 889 // TODO(titzer): test MachineOperatorReducer for Uint64Div |
890 // TODO(titzer): test MachineOperatorReducer for Int64Mod | 890 // TODO(titzer): test MachineOperatorReducer for Int64Mod |
891 // TODO(titzer): test MachineOperatorReducer for Uint64Mod | 891 // TODO(titzer): test MachineOperatorReducer for Uint64Mod |
892 // TODO(titzer): test MachineOperatorReducer for Int64Neg | 892 // TODO(titzer): test MachineOperatorReducer for Int64Neg |
893 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64 | 893 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64 |
894 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32 | 894 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32 |
895 // TODO(titzer): test MachineOperatorReducer for Float64Compare | 895 // TODO(titzer): test MachineOperatorReducer for Float64Compare |
896 // TODO(titzer): test MachineOperatorReducer for Float64Add | 896 // TODO(titzer): test MachineOperatorReducer for Float64Add |
897 // TODO(titzer): test MachineOperatorReducer for Float64Sub | 897 // TODO(titzer): test MachineOperatorReducer for Float64Sub |
898 // TODO(titzer): test MachineOperatorReducer for Float64Mul | 898 // TODO(titzer): test MachineOperatorReducer for Float64Mul |
899 // TODO(titzer): test MachineOperatorReducer for Float64Div | 899 // TODO(titzer): test MachineOperatorReducer for Float64Div |
900 // TODO(titzer): test MachineOperatorReducer for Float64Mod | 900 // TODO(titzer): test MachineOperatorReducer for Float64Mod |
901 | 901 |
902 } // namespace compiler | 902 } // namespace compiler |
903 } // namespace internal | 903 } // namespace internal |
904 } // namespace v8 | 904 } // namespace v8 |
OLD | NEW |