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

Side by Side Diff: test/cctest/compiler/test-simplified-lowering.cc

Issue 636283009: [turbofan] Use range types to type and lower arithmetic ops. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rename MaybeWeaken and rebase Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/types.h ('k') | test/cctest/compiler/test-typer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/generic-node-inl.h" 10 #include "src/compiler/generic-node-inl.h"
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 t.simplified()->NumberEqual()); 940 t.simplified()->NumberEqual());
941 t.CheckLoweringBinop(IrOpcode::kFloat64LessThan, 941 t.CheckLoweringBinop(IrOpcode::kFloat64LessThan,
942 t.simplified()->NumberLessThan()); 942 t.simplified()->NumberLessThan());
943 t.CheckLoweringBinop(IrOpcode::kFloat64LessThanOrEqual, 943 t.CheckLoweringBinop(IrOpcode::kFloat64LessThanOrEqual,
944 t.simplified()->NumberLessThanOrEqual()); 944 t.simplified()->NumberLessThanOrEqual());
945 } 945 }
946 } 946 }
947 947
948 948
949 TEST(LowerNumberAddSub_to_int32) { 949 TEST(LowerNumberAddSub_to_int32) {
950 TestingGraph t(Type::Signed32(), Type::Signed32()); 950 HandleAndZoneScope scope;
951 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Add, 951 Factory* f = scope.main_zone()->isolate()->factory();
952 t.simplified()->NumberAdd(), 952 Type* small_range =
953 t.simplified()->NumberToInt32()); 953 Type::Range(f->NewNumber(1), f->NewNumber(10), scope.main_zone());
954 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Sub, 954 Type* large_range =
955 t.simplified()->NumberSubtract(), 955 Type::Range(f->NewNumber(-1e+13), f->NewNumber(1e+14), scope.main_zone());
956 t.simplified()->NumberToInt32()); 956 static Type* types[] = {Type::Signed32(), Type::Integral32(), small_range,
957 large_range};
958
959 for (size_t i = 0; i < arraysize(types); i++) {
960 for (size_t j = 0; j < arraysize(types); j++) {
961 TestingGraph t(types[i], types[j]);
962 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Add,
963 t.simplified()->NumberAdd(),
964 t.simplified()->NumberToInt32());
965 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Sub,
966 t.simplified()->NumberSubtract(),
967 t.simplified()->NumberToInt32());
968 }
969 }
957 } 970 }
958 971
959 972
960 TEST(LowerNumberAddSub_to_uint32) { 973 TEST(LowerNumberAddSub_to_uint32) {
961 TestingGraph t(Type::Unsigned32(), Type::Unsigned32()); 974 HandleAndZoneScope scope;
962 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Add, 975 Factory* f = scope.main_zone()->isolate()->factory();
963 t.simplified()->NumberAdd(), 976 Type* small_range =
964 t.simplified()->NumberToUint32()); 977 Type::Range(f->NewNumber(1), f->NewNumber(10), scope.main_zone());
965 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Sub, 978 Type* large_range =
966 t.simplified()->NumberSubtract(), 979 Type::Range(f->NewNumber(-1e+13), f->NewNumber(1e+14), scope.main_zone());
967 t.simplified()->NumberToUint32()); 980 static Type* types[] = {Type::Signed32(), Type::Integral32(), small_range,
981 large_range};
982
983 for (size_t i = 0; i < arraysize(types); i++) {
984 for (size_t j = 0; j < arraysize(types); j++) {
985 TestingGraph t(types[i], types[j]);
986 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Add,
987 t.simplified()->NumberAdd(),
988 t.simplified()->NumberToUint32());
989 t.CheckLoweringTruncatedBinop(IrOpcode::kInt32Sub,
990 t.simplified()->NumberSubtract(),
991 t.simplified()->NumberToUint32());
992 }
993 }
968 } 994 }
969 995
970 996
971 TEST(LowerNumberAddSub_to_float64) { 997 TEST(LowerNumberAddSub_to_float64) {
972 for (size_t i = 0; i < arraysize(test_types); i++) { 998 for (size_t i = 0; i < arraysize(test_types); i++) {
973 TestingGraph t(test_types[i], test_types[i]); 999 TestingGraph t(test_types[i], test_types[i]);
974 1000
975 t.CheckLoweringBinop(IrOpcode::kFloat64Add, t.simplified()->NumberAdd()); 1001 t.CheckLoweringBinop(IrOpcode::kFloat64Add, t.simplified()->NumberAdd());
976 t.CheckLoweringBinop(IrOpcode::kFloat64Sub, 1002 t.CheckLoweringBinop(IrOpcode::kFloat64Sub,
977 t.simplified()->NumberSubtract()); 1003 t.simplified()->NumberSubtract());
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 TestingGraph t(Type::Unsigned32()); 1951 TestingGraph t(Type::Unsigned32());
1926 Node* k = t.jsgraph.Constant(0); 1952 Node* k = t.jsgraph.Constant(0);
1927 Node* mod = t.graph()->NewNode(t.simplified()->NumberModulus(), t.p0, k); 1953 Node* mod = t.graph()->NewNode(t.simplified()->NumberModulus(), t.p0, k);
1928 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), mod); 1954 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), mod);
1929 t.Return(trunc); 1955 t.Return(trunc);
1930 t.Lower(); 1956 t.Lower();
1931 1957
1932 CHECK_EQ(IrOpcode::kFloat64Mod, mod->opcode()); 1958 CHECK_EQ(IrOpcode::kFloat64Mod, mod->opcode());
1933 } 1959 }
1934 } 1960 }
OLDNEW
« no previous file with comments | « src/types.h ('k') | test/cctest/compiler/test-typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698