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

Unified Diff: test/unittests/compiler/machine-operator-reducer-unittest.cc

Issue 697663003: [turbofan] Also optimize unsigned division by constant. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Slight improvement 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 side-by-side diff with in-line comments
Download patch
Index: test/unittests/compiler/machine-operator-reducer-unittest.cc
diff --git a/test/unittests/compiler/machine-operator-reducer-unittest.cc b/test/unittests/compiler/machine-operator-reducer-unittest.cc
index be22bfdb3c841560c2d679411979dee4c2ee2ed6..51697163ae6f17fda9213e0adf7b98f34c9cbb7c 100644
--- a/test/unittests/compiler/machine-operator-reducer-unittest.cc
+++ b/test/unittests/compiler/machine-operator-reducer-unittest.cc
@@ -680,26 +680,26 @@ TEST_F(MachineOperatorReducerTest, Word32ShlWithWord32Shr) {
TEST_F(MachineOperatorReducerTest, Int32DivWithConstant) {
Node* const p0 = Parameter(0);
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Int32Div(), p0, Int32Constant(0)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Int32Div(), p0, Int32Constant(0), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Constant(0));
}
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Int32Div(), p0, Int32Constant(1)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Int32Div(), p0, Int32Constant(1), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_EQ(r.replacement(), p0);
}
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Int32Div(), p0, Int32Constant(-1)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Int32Div(), p0, Int32Constant(-1), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Sub(IsInt32Constant(0), p0));
}
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Int32Div(), p0, Int32Constant(2)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Int32Div(), p0, Int32Constant(2), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(
r.replacement(),
@@ -707,8 +707,8 @@ TEST_F(MachineOperatorReducerTest, Int32DivWithConstant) {
IsInt32Constant(1)));
}
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Int32Div(), p0, Int32Constant(-2)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Int32Div(), p0, Int32Constant(-2), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(
r.replacement(),
@@ -718,8 +718,9 @@ TEST_F(MachineOperatorReducerTest, Int32DivWithConstant) {
IsInt32Constant(1))));
}
TRACED_FORRANGE(int32_t, shift, 2, 30) {
- Reduction const r = Reduce(
- graph()->NewNode(machine()->Int32Div(), p0, Int32Constant(1 << shift)));
+ Reduction const r =
+ Reduce(graph()->NewNode(machine()->Int32Div(), p0,
+ Int32Constant(1 << shift), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(
r.replacement(),
@@ -731,7 +732,8 @@ TEST_F(MachineOperatorReducerTest, Int32DivWithConstant) {
TRACED_FORRANGE(int32_t, shift, 2, 31) {
Reduction const r = Reduce(graph()->NewNode(
machine()->Int32Div(), p0,
- Uint32Constant(bit_cast<uint32_t, int32_t>(-1) << shift)));
+ Uint32Constant(bit_cast<uint32_t, int32_t>(-1) << shift),
+ graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(
r.replacement(),
@@ -746,15 +748,15 @@ TEST_F(MachineOperatorReducerTest, Int32DivWithConstant) {
TRACED_FOREACH(int32_t, divisor, kInt32Values) {
if (divisor < 0) {
if (base::bits::IsPowerOfTwo32(-divisor)) continue;
- Reduction const r = Reduce(
- graph()->NewNode(machine()->Int32Div(), p0, Int32Constant(divisor)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Int32Div(), p0, Int32Constant(divisor), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Sub(IsInt32Constant(0),
IsTruncatingDiv(p0, -divisor)));
} else if (divisor > 0) {
if (base::bits::IsPowerOfTwo32(divisor)) continue;
- Reduction const r = Reduce(
- graph()->NewNode(machine()->Int32Div(), p0, Int32Constant(divisor)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Int32Div(), p0, Int32Constant(divisor), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsTruncatingDiv(p0, divisor));
}
@@ -764,7 +766,8 @@ TEST_F(MachineOperatorReducerTest, Int32DivWithConstant) {
TEST_F(MachineOperatorReducerTest, Int32DivWithParameters) {
Node* const p0 = Parameter(0);
- Reduction const r = Reduce(graph()->NewNode(machine()->Int32Div(), p0, p0));
+ Reduction const r =
+ Reduce(graph()->NewNode(machine()->Int32Div(), p0, p0, graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(
r.replacement(),
@@ -779,28 +782,28 @@ TEST_F(MachineOperatorReducerTest, Int32DivWithParameters) {
TEST_F(MachineOperatorReducerTest, Uint32DivWithConstant) {
Node* const p0 = Parameter(0);
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Uint32Div(), Int32Constant(0), p0));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Uint32Div(), Int32Constant(0), p0, graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Constant(0));
}
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Uint32Div(), p0, Int32Constant(0)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Uint32Div(), p0, Int32Constant(0), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Constant(0));
}
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Uint32Div(), p0, Int32Constant(1)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Uint32Div(), p0, Int32Constant(1), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_EQ(r.replacement(), p0);
}
TRACED_FOREACH(uint32_t, dividend, kUint32Values) {
TRACED_FOREACH(uint32_t, divisor, kUint32Values) {
- Reduction const r = Reduce(graph()->NewNode(machine()->Uint32Div(),
- Uint32Constant(dividend),
- Uint32Constant(divisor)));
+ Reduction const r = Reduce(
+ graph()->NewNode(machine()->Uint32Div(), Uint32Constant(dividend),
+ Uint32Constant(divisor), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsInt32Constant(bit_cast<int32_t>(
@@ -808,8 +811,9 @@ TEST_F(MachineOperatorReducerTest, Uint32DivWithConstant) {
}
}
TRACED_FORRANGE(uint32_t, shift, 1, 31) {
- Reduction const r = Reduce(graph()->NewNode(machine()->Uint32Div(), p0,
- Uint32Constant(1u << shift)));
+ Reduction const r =
+ Reduce(graph()->NewNode(machine()->Uint32Div(), p0,
+ Uint32Constant(1u << shift), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsWord32Shr(p0, IsInt32Constant(bit_cast<int32_t>(shift))));
@@ -819,7 +823,8 @@ TEST_F(MachineOperatorReducerTest, Uint32DivWithConstant) {
TEST_F(MachineOperatorReducerTest, Uint32DivWithParameters) {
Node* const p0 = Parameter(0);
- Reduction const r = Reduce(graph()->NewNode(machine()->Uint32Div(), p0, p0));
+ Reduction const r = Reduce(
+ graph()->NewNode(machine()->Uint32Div(), p0, p0, graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(
r.replacement(),
@@ -834,42 +839,43 @@ TEST_F(MachineOperatorReducerTest, Uint32DivWithParameters) {
TEST_F(MachineOperatorReducerTest, Int32ModWithConstant) {
Node* const p0 = Parameter(0);
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Int32Mod(), Int32Constant(0), p0));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Int32Mod(), Int32Constant(0), p0, graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Constant(0));
}
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Int32Mod(), p0, Int32Constant(0)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Int32Mod(), p0, Int32Constant(0), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Constant(0));
}
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Int32Mod(), p0, Int32Constant(1)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Int32Mod(), p0, Int32Constant(1), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Constant(0));
}
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Int32Mod(), p0, Int32Constant(-1)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Int32Mod(), p0, Int32Constant(-1), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Constant(0));
}
TRACED_FOREACH(int32_t, dividend, kInt32Values) {
TRACED_FOREACH(int32_t, divisor, kInt32Values) {
- Reduction const r = Reduce(graph()->NewNode(machine()->Int32Mod(),
- Int32Constant(dividend),
- Int32Constant(divisor)));
+ Reduction const r = Reduce(
+ graph()->NewNode(machine()->Int32Mod(), Int32Constant(dividend),
+ Int32Constant(divisor), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsInt32Constant(base::bits::SignedMod32(dividend, divisor)));
}
}
TRACED_FORRANGE(int32_t, shift, 1, 30) {
- Reduction const r = Reduce(
- graph()->NewNode(machine()->Int32Mod(), p0, Int32Constant(1 << shift)));
+ Reduction const r =
+ Reduce(graph()->NewNode(machine()->Int32Mod(), p0,
+ Int32Constant(1 << shift), graph()->start()));
ASSERT_TRUE(r.Changed());
Capture<Node*> branch;
@@ -890,7 +896,8 @@ TEST_F(MachineOperatorReducerTest, Int32ModWithConstant) {
TRACED_FORRANGE(int32_t, shift, 1, 31) {
Reduction const r = Reduce(graph()->NewNode(
machine()->Int32Mod(), p0,
- Uint32Constant(bit_cast<uint32_t, int32_t>(-1) << shift)));
+ Uint32Constant(bit_cast<uint32_t, int32_t>(-1) << shift),
+ graph()->start()));
ASSERT_TRUE(r.Changed());
Capture<Node*> branch;
@@ -910,8 +917,8 @@ TEST_F(MachineOperatorReducerTest, Int32ModWithConstant) {
}
TRACED_FOREACH(int32_t, divisor, kInt32Values) {
if (divisor == 0 || base::bits::IsPowerOfTwo32(Abs(divisor))) continue;
- Reduction const r = Reduce(
- graph()->NewNode(machine()->Int32Mod(), p0, Int32Constant(divisor)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Int32Mod(), p0, Int32Constant(divisor), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsInt32Sub(p0, IsInt32Mul(IsTruncatingDiv(p0, Abs(divisor)),
@@ -922,7 +929,8 @@ TEST_F(MachineOperatorReducerTest, Int32ModWithConstant) {
TEST_F(MachineOperatorReducerTest, Int32ModWithParameters) {
Node* const p0 = Parameter(0);
- Reduction const r = Reduce(graph()->NewNode(machine()->Int32Mod(), p0, p0));
+ Reduction const r =
+ Reduce(graph()->NewNode(machine()->Int32Mod(), p0, p0, graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Constant(0));
}
@@ -935,28 +943,28 @@ TEST_F(MachineOperatorReducerTest, Int32ModWithParameters) {
TEST_F(MachineOperatorReducerTest, Uint32ModWithConstant) {
Node* const p0 = Parameter(0);
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Uint32Mod(), p0, Int32Constant(0)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Uint32Mod(), p0, Int32Constant(0), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Constant(0));
}
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Uint32Mod(), Int32Constant(0), p0));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Uint32Mod(), Int32Constant(0), p0, graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Constant(0));
}
{
- Reduction const r =
- Reduce(graph()->NewNode(machine()->Uint32Mod(), p0, Int32Constant(1)));
+ Reduction const r = Reduce(graph()->NewNode(
+ machine()->Uint32Mod(), p0, Int32Constant(1), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Constant(0));
}
TRACED_FOREACH(uint32_t, dividend, kUint32Values) {
TRACED_FOREACH(uint32_t, divisor, kUint32Values) {
- Reduction const r = Reduce(graph()->NewNode(machine()->Uint32Mod(),
- Uint32Constant(dividend),
- Uint32Constant(divisor)));
+ Reduction const r = Reduce(
+ graph()->NewNode(machine()->Uint32Mod(), Uint32Constant(dividend),
+ Uint32Constant(divisor), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsInt32Constant(bit_cast<int32_t>(
@@ -964,8 +972,9 @@ TEST_F(MachineOperatorReducerTest, Uint32ModWithConstant) {
}
}
TRACED_FORRANGE(uint32_t, shift, 1, 31) {
- Reduction const r = Reduce(graph()->NewNode(machine()->Uint32Mod(), p0,
- Uint32Constant(1u << shift)));
+ Reduction const r =
+ Reduce(graph()->NewNode(machine()->Uint32Mod(), p0,
+ Uint32Constant(1u << shift), graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsWord32And(p0, IsInt32Constant(
@@ -976,7 +985,8 @@ TEST_F(MachineOperatorReducerTest, Uint32ModWithConstant) {
TEST_F(MachineOperatorReducerTest, Uint32ModWithParameters) {
Node* const p0 = Parameter(0);
- Reduction const r = Reduce(graph()->NewNode(machine()->Uint32Mod(), p0, p0));
+ Reduction const r = Reduce(
+ graph()->NewNode(machine()->Uint32Mod(), p0, p0, graph()->start()));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Constant(0));
}
« no previous file with comments | « test/unittests/compiler/change-lowering-unittest.cc ('k') | test/unittests/compiler/x64/instruction-selector-x64-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698