| 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 <limits> | 5 #include <limits> |
| 6 | 6 |
| 7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
| 8 #include "src/compiler/change-lowering.h" | 8 #include "src/compiler/change-lowering.h" |
| 9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
| 10 #include "src/compiler/graph-reducer.h" | 10 #include "src/compiler/graph-reducer.h" |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 t.CheckLoweringBinop(IrOpcode::kFloat64LessThan, | 965 t.CheckLoweringBinop(IrOpcode::kFloat64LessThan, |
| 966 t.simplified()->NumberLessThan()); | 966 t.simplified()->NumberLessThan()); |
| 967 t.CheckLoweringBinop(IrOpcode::kFloat64LessThanOrEqual, | 967 t.CheckLoweringBinop(IrOpcode::kFloat64LessThanOrEqual, |
| 968 t.simplified()->NumberLessThanOrEqual()); | 968 t.simplified()->NumberLessThanOrEqual()); |
| 969 } | 969 } |
| 970 } | 970 } |
| 971 | 971 |
| 972 | 972 |
| 973 TEST(LowerNumberAddSub_to_int32) { | 973 TEST(LowerNumberAddSub_to_int32) { |
| 974 HandleAndZoneScope scope; | 974 HandleAndZoneScope scope; |
| 975 Factory* f = scope.main_isolate()->factory(); | 975 Type* small_range = Type::Range(1, 10, scope.main_zone()); |
| 976 Type* small_range = | 976 Type* large_range = Type::Range(-1e+13, 1e+14, scope.main_zone()); |
| 977 Type::Range(f->NewNumber(1), f->NewNumber(10), scope.main_zone()); | |
| 978 Type* large_range = | |
| 979 Type::Range(f->NewNumber(-1e+13), f->NewNumber(1e+14), scope.main_zone()); | |
| 980 static Type* types[] = {Type::Signed32(), Type::Integral32(), small_range, | 977 static Type* types[] = {Type::Signed32(), Type::Integral32(), small_range, |
| 981 large_range}; | 978 large_range}; |
| 982 | 979 |
| 983 for (size_t i = 0; i < arraysize(types); i++) { | 980 for (size_t i = 0; i < arraysize(types); i++) { |
| 984 for (size_t j = 0; j < arraysize(types); j++) { | 981 for (size_t j = 0; j < arraysize(types); j++) { |
| 985 TestingGraph t(types[i], types[j]); | 982 TestingGraph t(types[i], types[j]); |
| 986 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Add, | 983 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Add, |
| 987 t.simplified()->NumberAdd(), | 984 t.simplified()->NumberAdd(), |
| 988 t.simplified()->NumberToInt32()); | 985 t.simplified()->NumberToInt32()); |
| 989 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Sub, | 986 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Sub, |
| 990 t.simplified()->NumberSubtract(), | 987 t.simplified()->NumberSubtract(), |
| 991 t.simplified()->NumberToInt32()); | 988 t.simplified()->NumberToInt32()); |
| 992 } | 989 } |
| 993 } | 990 } |
| 994 } | 991 } |
| 995 | 992 |
| 996 | 993 |
| 997 TEST(LowerNumberAddSub_to_uint32) { | 994 TEST(LowerNumberAddSub_to_uint32) { |
| 998 HandleAndZoneScope scope; | 995 HandleAndZoneScope scope; |
| 999 Factory* f = scope.main_isolate()->factory(); | 996 Type* small_range = Type::Range(1, 10, scope.main_zone()); |
| 1000 Type* small_range = | 997 Type* large_range = Type::Range(-1e+13, 1e+14, scope.main_zone()); |
| 1001 Type::Range(f->NewNumber(1), f->NewNumber(10), scope.main_zone()); | |
| 1002 Type* large_range = | |
| 1003 Type::Range(f->NewNumber(-1e+13), f->NewNumber(1e+14), scope.main_zone()); | |
| 1004 static Type* types[] = {Type::Signed32(), Type::Integral32(), small_range, | 998 static Type* types[] = {Type::Signed32(), Type::Integral32(), small_range, |
| 1005 large_range}; | 999 large_range}; |
| 1006 | 1000 |
| 1007 for (size_t i = 0; i < arraysize(types); i++) { | 1001 for (size_t i = 0; i < arraysize(types); i++) { |
| 1008 for (size_t j = 0; j < arraysize(types); j++) { | 1002 for (size_t j = 0; j < arraysize(types); j++) { |
| 1009 TestingGraph t(types[i], types[j]); | 1003 TestingGraph t(types[i], types[j]); |
| 1010 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Add, | 1004 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Add, |
| 1011 t.simplified()->NumberAdd(), | 1005 t.simplified()->NumberAdd(), |
| 1012 t.simplified()->NumberToUint32()); | 1006 t.simplified()->NumberToUint32()); |
| 1013 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Sub, | 1007 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Sub, |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 Bounds phi_bounds = Bounds::Either(Bounds(d.arg1), Bounds(d.arg2), z); | 2038 Bounds phi_bounds = Bounds::Either(Bounds(d.arg1), Bounds(d.arg2), z); |
| 2045 NodeProperties::SetBounds(phi, phi_bounds); | 2039 NodeProperties::SetBounds(phi, phi_bounds); |
| 2046 | 2040 |
| 2047 Node* use = t.Use(phi, d.use); | 2041 Node* use = t.Use(phi, d.use); |
| 2048 t.Return(use); | 2042 t.Return(use); |
| 2049 t.Lower(); | 2043 t.Lower(); |
| 2050 | 2044 |
| 2051 CHECK_EQ(d.expected, OpParameter<MachineType>(phi)); | 2045 CHECK_EQ(d.expected, OpParameter<MachineType>(phi)); |
| 2052 } | 2046 } |
| 2053 } | 2047 } |
| OLD | NEW |