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

Unified Diff: test/cctest/compiler/test-simplified-lowering.cc

Issue 681133004: [turbofan] Complete support for integer division/modulus in simplified lowering. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixes Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | test/unittests/compiler/machine-operator-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-simplified-lowering.cc
diff --git a/test/cctest/compiler/test-simplified-lowering.cc b/test/cctest/compiler/test-simplified-lowering.cc
index 47acbe1a9b02d4a88f58e76ea80988860c6068e2..e77f57a318cb54735ca08c2f2c7b3bbae661889d 100644
--- a/test/cctest/compiler/test-simplified-lowering.cc
+++ b/test/cctest/compiler/test-simplified-lowering.cc
@@ -1720,11 +1720,11 @@ TEST(NumberDivide_TruncatingToInt32) {
TestingGraph t(Type::Signed32());
Node* k = t.jsgraph.Constant(constants[i]);
Node* div = t.graph()->NewNode(t.simplified()->NumberDivide(), t.p0, k);
- Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), div);
- t.Return(trunc);
+ Node* use = t.Use(div, kMachInt32);
+ t.Return(use);
t.Lower();
- CHECK_EQ(IrOpcode::kInt32Div, div->opcode());
+ CHECK_EQ(IrOpcode::kInt32Div, use->InputAt(0)->opcode());
}
}
@@ -1761,11 +1761,11 @@ TEST(NumberDivide_TruncatingToUint32) {
TestingGraph t(Type::Unsigned32());
Node* k = t.jsgraph.Constant(constants[i]);
Node* div = t.graph()->NewNode(t.simplified()->NumberDivide(), t.p0, k);
- Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), div);
- t.Return(trunc);
+ Node* use = t.Use(div, kMachUint32);
+ t.Return(use);
t.Lower();
- CHECK_EQ(IrOpcode::kUint32Div, div->opcode());
+ CHECK_EQ(IrOpcode::kUint32Div, use->InputAt(0)->opcode());
}
}
@@ -1795,28 +1795,39 @@ TEST(RunNumberDivide_TruncatingToUint32) {
TEST(NumberDivide_BadConstants) {
- int32_t constants[] = {-1, 0};
+ {
+ TestingGraph t(Type::Signed32());
+ Node* k = t.jsgraph.Constant(-1);
+ Node* div = t.graph()->NewNode(t.simplified()->NumberDivide(), t.p0, k);
+ Node* use = t.Use(div, kMachInt32);
+ t.Return(use);
+ t.Lower();
- for (size_t i = 0; i < arraysize(constants); i++) {
+ CHECK_EQ(IrOpcode::kInt32Sub, use->InputAt(0)->opcode());
+ }
+
+ {
TestingGraph t(Type::Signed32());
- Node* k = t.jsgraph.Constant(constants[i]);
+ Node* k = t.jsgraph.Constant(0);
Node* div = t.graph()->NewNode(t.simplified()->NumberDivide(), t.p0, k);
- Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), div);
- t.Return(trunc);
+ Node* use = t.Use(div, kMachInt32);
+ t.Return(use);
t.Lower();
- CHECK_EQ(IrOpcode::kFloat64Div, div->opcode());
+ CHECK_EQ(IrOpcode::kInt32Constant, use->InputAt(0)->opcode());
+ CHECK_EQ(0, OpParameter<int32_t>(use->InputAt(0)));
}
{
TestingGraph t(Type::Unsigned32());
Node* k = t.jsgraph.Constant(0);
Node* div = t.graph()->NewNode(t.simplified()->NumberDivide(), t.p0, k);
- Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), div);
- t.Return(trunc);
+ Node* use = t.Use(div, kMachUint32);
+ t.Return(use);
t.Lower();
- CHECK_EQ(IrOpcode::kFloat64Div, div->opcode());
+ CHECK_EQ(IrOpcode::kInt32Constant, use->InputAt(0)->opcode());
+ CHECK_EQ(0, OpParameter<int32_t>(use->InputAt(0)));
}
}
@@ -1828,11 +1839,11 @@ TEST(NumberModulus_TruncatingToInt32) {
TestingGraph t(Type::Signed32());
Node* k = t.jsgraph.Constant(constants[i]);
Node* mod = t.graph()->NewNode(t.simplified()->NumberModulus(), t.p0, k);
- Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), mod);
- t.Return(trunc);
+ Node* use = t.Use(mod, kMachInt32);
+ t.Return(use);
t.Lower();
- CHECK_EQ(IrOpcode::kInt32Mod, mod->opcode());
+ CHECK_EQ(IrOpcode::kInt32Mod, use->InputAt(0)->opcode());
}
}
@@ -1870,10 +1881,10 @@ TEST(NumberModulus_TruncatingToUint32) {
Node* k = t.jsgraph.Constant(constants[i]);
Node* mod = t.graph()->NewNode(t.simplified()->NumberModulus(), t.p0, k);
Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), mod);
- t.Return(trunc);
+ Node* ret = t.Return(trunc);
t.Lower();
- CHECK_EQ(IrOpcode::kUint32Mod, mod->opcode());
+ CHECK_EQ(IrOpcode::kUint32Mod, ret->InputAt(0)->opcode());
}
}
@@ -1916,45 +1927,3 @@ TEST(NumberModulus_Int32) {
CHECK_EQ(IrOpcode::kFloat64Mod, mod->opcode()); // Pesky -0 behavior.
}
}
-
-
-TEST(NumberModulus_Uint32) {
- double constants[] = {1, 3, 100, 1000, 100998348};
-
- for (size_t i = 0; i < arraysize(constants); i++) {
- TestingGraph t(Type::Unsigned32());
- Node* k = t.jsgraph.Constant(constants[i]);
- Node* mod = t.graph()->NewNode(t.simplified()->NumberModulus(), t.p0, k);
- t.Return(mod);
- t.Lower();
-
- CHECK_EQ(IrOpcode::kUint32Mod, mod->opcode());
- }
-}
-
-
-TEST(NumberModulus_BadConstants) {
- int32_t constants[] = {-1, 0};
-
- for (size_t i = 0; i < arraysize(constants); i++) {
- TestingGraph t(Type::Signed32());
- Node* k = t.jsgraph.Constant(constants[i]);
- Node* mod = t.graph()->NewNode(t.simplified()->NumberModulus(), t.p0, k);
- Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), mod);
- t.Return(trunc);
- t.Lower();
-
- CHECK_EQ(IrOpcode::kFloat64Mod, mod->opcode());
- }
-
- {
- TestingGraph t(Type::Unsigned32());
- Node* k = t.jsgraph.Constant(0);
- Node* mod = t.graph()->NewNode(t.simplified()->NumberModulus(), t.p0, k);
- Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), mod);
- t.Return(trunc);
- t.Lower();
-
- CHECK_EQ(IrOpcode::kFloat64Mod, mod->opcode());
- }
-}
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | test/unittests/compiler/machine-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698