summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2015-01-26 15:17:44 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-01-26 15:17:45 +0000
commitf90eec005997f98c1a9f874fbbf68414e5f9c766 (patch)
treeb69c22e07b26938118e35c665b77d7f743300ffa
parent3c40d38eadeb5ea7c0733f6a40816061db8c86f8 (diff)
parente6f171514c9c499bd0a137aff6bd8a7a79d2682a (diff)
downloadart-f90eec005997f98c1a9f874fbbf68414e5f9c766.zip
art-f90eec005997f98c1a9f874fbbf68414e5f9c766.tar.gz
art-f90eec005997f98c1a9f874fbbf68414e5f9c766.tar.bz2
Merge "Fix build breakage after GVN change."
-rw-r--r--compiler/optimizing/bounds_check_elimination_test.cc52
-rw-r--r--compiler/optimizing/gvn_test.cc54
2 files changed, 62 insertions, 44 deletions
diff --git a/compiler/optimizing/bounds_check_elimination_test.cc b/compiler/optimizing/bounds_check_elimination_test.cc
index f650ff2..d5de3ef 100644
--- a/compiler/optimizing/bounds_check_elimination_test.cc
+++ b/compiler/optimizing/bounds_check_elimination_test.cc
@@ -25,6 +25,12 @@
namespace art {
+static void RunGvn(HGraph* graph) {
+ SideEffectsAnalysis side_effects(graph);
+ side_effects.Run();
+ GlobalValueNumberer(graph->GetArena(), graph, side_effects).Run();
+}
+
// if (i < 0) { array[i] = 1; // Can't eliminate. }
// else if (i >= array.length) { array[i] = 1; // Can't eliminate. }
// else { array[i] = 1; // Can eliminate. }
@@ -120,7 +126,7 @@ TEST(BoundsCheckEliminationTest, NarrowingRangeArrayBoundsElimination) {
block3->AddSuccessor(block4); // False successor
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination(graph);
bounds_check_elimination.Run();
ASSERT_FALSE(IsRemoved(bounds_check2));
@@ -195,7 +201,7 @@ TEST(BoundsCheckEliminationTest, OverflowArrayBoundsElimination) {
block3->AddSuccessor(exit);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination(graph);
bounds_check_elimination.Run();
ASSERT_FALSE(IsRemoved(bounds_check));
@@ -270,7 +276,7 @@ TEST(BoundsCheckEliminationTest, UnderflowArrayBoundsElimination) {
block3->AddSuccessor(exit);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination(graph);
bounds_check_elimination.Run();
ASSERT_FALSE(IsRemoved(bounds_check));
@@ -344,7 +350,7 @@ TEST(BoundsCheckEliminationTest, ConstantArrayBoundsElimination) {
exit->AddInstruction(new (&allocator) HExit());
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination(graph);
bounds_check_elimination.Run();
ASSERT_FALSE(IsRemoved(bounds_check5));
@@ -443,7 +449,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination1) {
// HArrayLength which uses the null check as its input.
graph = BuildSSAGraph1(&allocator, &bounds_check, 0, 1);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_after_gvn(graph);
bounds_check_elimination_after_gvn.Run();
ASSERT_TRUE(IsRemoved(bounds_check));
@@ -451,7 +457,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination1) {
// for (int i=1; i<array.length; i++) { array[i] = 10; // Can eliminate. }
graph = BuildSSAGraph1(&allocator, &bounds_check, 1, 1);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_with_initial_1(graph);
bounds_check_elimination_with_initial_1.Run();
ASSERT_TRUE(IsRemoved(bounds_check));
@@ -459,7 +465,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination1) {
// for (int i=-1; i<array.length; i++) { array[i] = 10; // Can't eliminate. }
graph = BuildSSAGraph1(&allocator, &bounds_check, -1, 1);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_with_initial_minus_1(graph);
bounds_check_elimination_with_initial_minus_1.Run();
ASSERT_FALSE(IsRemoved(bounds_check));
@@ -467,7 +473,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination1) {
// for (int i=0; i<=array.length; i++) { array[i] = 10; // Can't eliminate. }
graph = BuildSSAGraph1(&allocator, &bounds_check, 0, 1, kCondGT);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_with_greater_than(graph);
bounds_check_elimination_with_greater_than.Run();
ASSERT_FALSE(IsRemoved(bounds_check));
@@ -476,7 +482,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination1) {
// array[i] = 10; // Can't eliminate due to overflow concern. }
graph = BuildSSAGraph1(&allocator, &bounds_check, 0, 2);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_with_increment_2(graph);
bounds_check_elimination_with_increment_2.Run();
ASSERT_FALSE(IsRemoved(bounds_check));
@@ -484,7 +490,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination1) {
// for (int i=1; i<array.length; i += 2) { array[i] = 10; // Can eliminate. }
graph = BuildSSAGraph1(&allocator, &bounds_check, 1, 2);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_with_increment_2_from_1(graph);
bounds_check_elimination_with_increment_2_from_1.Run();
ASSERT_TRUE(IsRemoved(bounds_check));
@@ -584,7 +590,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination2) {
// HArrayLength which uses the null check as its input.
graph = BuildSSAGraph2(&allocator, &bounds_check, 0);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_after_gvn(graph);
bounds_check_elimination_after_gvn.Run();
ASSERT_TRUE(IsRemoved(bounds_check));
@@ -592,7 +598,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination2) {
// for (int i=array.length; i>1; i--) { array[i-1] = 10; // Can eliminate. }
graph = BuildSSAGraph2(&allocator, &bounds_check, 1);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_with_initial_1(graph);
bounds_check_elimination_with_initial_1.Run();
ASSERT_TRUE(IsRemoved(bounds_check));
@@ -600,7 +606,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination2) {
// for (int i=array.length; i>-1; i--) { array[i-1] = 10; // Can't eliminate. }
graph = BuildSSAGraph2(&allocator, &bounds_check, -1);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_with_initial_minus_1(graph);
bounds_check_elimination_with_initial_minus_1.Run();
ASSERT_FALSE(IsRemoved(bounds_check));
@@ -608,7 +614,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination2) {
// for (int i=array.length; i>=0; i--) { array[i-1] = 10; // Can't eliminate. }
graph = BuildSSAGraph2(&allocator, &bounds_check, 0, -1, kCondLT);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_with_less_than(graph);
bounds_check_elimination_with_less_than.Run();
ASSERT_FALSE(IsRemoved(bounds_check));
@@ -616,7 +622,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination2) {
// for (int i=array.length; i>0; i-=2) { array[i-1] = 10; // Can eliminate. }
graph = BuildSSAGraph2(&allocator, &bounds_check, 0, -2);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_increment_minus_2(graph);
bounds_check_elimination_increment_minus_2.Run();
ASSERT_TRUE(IsRemoved(bounds_check));
@@ -703,7 +709,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination3) {
HInstruction* bounds_check = nullptr;
HGraph* graph = BuildSSAGraph3(&allocator, &bounds_check, 0, 1, kCondGE);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_after_gvn(graph);
bounds_check_elimination_after_gvn.Run();
ASSERT_TRUE(IsRemoved(bounds_check));
@@ -712,7 +718,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination3) {
// for (int i=1; i<10; i++) { array[i] = 10; // Can eliminate. }
graph = BuildSSAGraph3(&allocator, &bounds_check, 1, 1, kCondGE);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_with_initial_1(graph);
bounds_check_elimination_with_initial_1.Run();
ASSERT_TRUE(IsRemoved(bounds_check));
@@ -721,7 +727,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination3) {
// for (int i=0; i<=10; i++) { array[i] = 10; // Can't eliminate. }
graph = BuildSSAGraph3(&allocator, &bounds_check, 0, 1, kCondGT);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_with_greater_than(graph);
bounds_check_elimination_with_greater_than.Run();
ASSERT_FALSE(IsRemoved(bounds_check));
@@ -730,7 +736,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination3) {
// for (int i=1; i<10; i+=8) { array[i] = 10; // Can eliminate. }
graph = BuildSSAGraph3(&allocator, &bounds_check, 1, 8, kCondGE);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_increment_8(graph);
bounds_check_elimination_increment_8.Run();
ASSERT_TRUE(IsRemoved(bounds_check));
@@ -831,7 +837,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination4) {
// HArrayLength which uses the null check as its input.
graph = BuildSSAGraph4(&allocator, &bounds_check, 0);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_after_gvn(graph);
bounds_check_elimination_after_gvn.Run();
ASSERT_TRUE(IsRemoved(bounds_check));
@@ -839,7 +845,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination4) {
// for (int i=1; i<array.length; i++) { array[array.length-i-1] = 10; // Can eliminate. }
graph = BuildSSAGraph4(&allocator, &bounds_check, 1);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_with_initial_1(graph);
bounds_check_elimination_with_initial_1.Run();
ASSERT_TRUE(IsRemoved(bounds_check));
@@ -847,7 +853,7 @@ TEST(BoundsCheckEliminationTest, LoopArrayBoundsElimination4) {
// for (int i=0; i<=array.length; i++) { array[array.length-i] = 10; // Can't eliminate. }
graph = BuildSSAGraph4(&allocator, &bounds_check, 0, kCondGT);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
BoundsCheckElimination bounds_check_elimination_with_greater_than(graph);
bounds_check_elimination_with_greater_than.Run();
ASSERT_FALSE(IsRemoved(bounds_check));
@@ -1023,7 +1029,7 @@ TEST(BoundsCheckEliminationTest, BubbleSortArrayBoundsElimination) {
outer_body_add->AddSuccessor(outer_header);
graph->BuildDominatorTree();
- GlobalValueNumberer(&allocator, graph).Run();
+ RunGvn(graph);
// gvn should remove the same bounds check.
ASSERT_FALSE(IsRemoved(bounds_check1));
ASSERT_FALSE(IsRemoved(bounds_check2));
diff --git a/compiler/optimizing/gvn_test.cc b/compiler/optimizing/gvn_test.cc
index 48f1ea9..9e630a7 100644
--- a/compiler/optimizing/gvn_test.cc
+++ b/compiler/optimizing/gvn_test.cc
@@ -64,7 +64,9 @@ TEST(GVNTest, LocalFieldElimination) {
ASSERT_EQ(use_after_kill->GetBlock(), block);
graph->TryBuildingSsa();
- GlobalValueNumberer(&allocator, graph).Run();
+ SideEffectsAnalysis side_effects(graph);
+ side_effects.Run();
+ GlobalValueNumberer(&allocator, graph, side_effects).Run();
ASSERT_TRUE(to_remove->GetBlock() == nullptr);
ASSERT_EQ(different_offset->GetBlock(), block);
@@ -116,7 +118,9 @@ TEST(GVNTest, GlobalFieldElimination) {
join->AddInstruction(new (&allocator) HExit());
graph->TryBuildingSsa();
- GlobalValueNumberer(&allocator, graph).Run();
+ SideEffectsAnalysis side_effects(graph);
+ side_effects.Run();
+ GlobalValueNumberer(&allocator, graph, side_effects).Run();
// Check that all field get instructions have been GVN'ed.
ASSERT_TRUE(then->GetFirstInstruction()->IsGoto());
@@ -184,7 +188,11 @@ TEST(GVNTest, LoopFieldElimination) {
ASSERT_EQ(field_get_in_exit->GetBlock(), exit);
graph->TryBuildingSsa();
- GlobalValueNumberer(&allocator, graph).Run();
+ {
+ SideEffectsAnalysis side_effects(graph);
+ side_effects.Run();
+ GlobalValueNumberer(&allocator, graph, side_effects).Run();
+ }
// Check that all field get instructions are still there.
ASSERT_EQ(field_get_in_loop_header->GetBlock(), loop_header);
@@ -195,7 +203,11 @@ TEST(GVNTest, LoopFieldElimination) {
// Now remove the field set, and check that all field get instructions have been GVN'ed.
loop_body->RemoveInstruction(field_set);
- GlobalValueNumberer(&allocator, graph).Run();
+ {
+ SideEffectsAnalysis side_effects(graph);
+ side_effects.Run();
+ GlobalValueNumberer(&allocator, graph, side_effects).Run();
+ }
ASSERT_TRUE(field_get_in_loop_header->GetBlock() == nullptr);
ASSERT_TRUE(field_get_in_loop_body->GetBlock() == nullptr);
@@ -256,12 +268,12 @@ TEST(GVNTest, LoopSideEffects) {
entry->AddInstruction(new (&allocator) HInstanceFieldSet(
parameter, parameter, Primitive::kPrimNot, MemberOffset(42), false));
- GlobalValueNumberer gvn(&allocator, graph);
- gvn.Run();
+ SideEffectsAnalysis side_effects(graph);
+ side_effects.Run();
- ASSERT_TRUE(gvn.GetBlockEffects(entry).HasSideEffects());
- ASSERT_FALSE(gvn.GetLoopEffects(outer_loop_header).HasSideEffects());
- ASSERT_FALSE(gvn.GetLoopEffects(inner_loop_header).HasSideEffects());
+ ASSERT_TRUE(side_effects.GetBlockEffects(entry).HasSideEffects());
+ ASSERT_FALSE(side_effects.GetLoopEffects(outer_loop_header).HasSideEffects());
+ ASSERT_FALSE(side_effects.GetLoopEffects(inner_loop_header).HasSideEffects());
}
// Check that the side effects of the outer loop does not affect the inner loop.
@@ -271,13 +283,13 @@ TEST(GVNTest, LoopSideEffects) {
parameter, parameter, Primitive::kPrimNot, MemberOffset(42), false),
outer_loop_body->GetLastInstruction());
- GlobalValueNumberer gvn(&allocator, graph);
- gvn.Run();
+ SideEffectsAnalysis side_effects(graph);
+ side_effects.Run();
- ASSERT_TRUE(gvn.GetBlockEffects(entry).HasSideEffects());
- ASSERT_TRUE(gvn.GetBlockEffects(outer_loop_body).HasSideEffects());
- ASSERT_TRUE(gvn.GetLoopEffects(outer_loop_header).HasSideEffects());
- ASSERT_FALSE(gvn.GetLoopEffects(inner_loop_header).HasSideEffects());
+ ASSERT_TRUE(side_effects.GetBlockEffects(entry).HasSideEffects());
+ ASSERT_TRUE(side_effects.GetBlockEffects(outer_loop_body).HasSideEffects());
+ ASSERT_TRUE(side_effects.GetLoopEffects(outer_loop_header).HasSideEffects());
+ ASSERT_FALSE(side_effects.GetLoopEffects(inner_loop_header).HasSideEffects());
}
// Check that the side effects of the inner loop affects the outer loop.
@@ -288,13 +300,13 @@ TEST(GVNTest, LoopSideEffects) {
parameter, parameter, Primitive::kPrimNot, MemberOffset(42), false),
inner_loop_body->GetLastInstruction());
- GlobalValueNumberer gvn(&allocator, graph);
- gvn.Run();
+ SideEffectsAnalysis side_effects(graph);
+ side_effects.Run();
- ASSERT_TRUE(gvn.GetBlockEffects(entry).HasSideEffects());
- ASSERT_FALSE(gvn.GetBlockEffects(outer_loop_body).HasSideEffects());
- ASSERT_TRUE(gvn.GetLoopEffects(outer_loop_header).HasSideEffects());
- ASSERT_TRUE(gvn.GetLoopEffects(inner_loop_header).HasSideEffects());
+ ASSERT_TRUE(side_effects.GetBlockEffects(entry).HasSideEffects());
+ ASSERT_FALSE(side_effects.GetBlockEffects(outer_loop_body).HasSideEffects());
+ ASSERT_TRUE(side_effects.GetLoopEffects(outer_loop_header).HasSideEffects());
+ ASSERT_TRUE(side_effects.GetLoopEffects(inner_loop_header).HasSideEffects());
}
}
} // namespace art