summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMingyao Yang <mingyao@google.com>2015-03-04 19:30:50 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-03-04 19:30:50 +0000
commitd8de6f2f6083c119a56b6d4abe537a67c070ebea (patch)
tree5c911a6d55bbfb1b7da1a4cb5d4f14343e9c4784
parentdc68bafc29a457b1cc5b29a03f2ef5f2af77865d (diff)
parente4335eb5bcbca6927e51c10cf0de3516d94ef599 (diff)
downloadart-d8de6f2f6083c119a56b6d4abe537a67c070ebea.tar.gz
art-d8de6f2f6083c119a56b6d4abe537a67c070ebea.tar.bz2
art-d8de6f2f6083c119a56b6d4abe537a67c070ebea.zip
Merge "Make BCE a no-op if there is no array access."
-rw-r--r--compiler/optimizing/bounds_check_elimination.cc4
-rw-r--r--compiler/optimizing/builder.cc1
-rw-r--r--compiler/optimizing/inliner.cc4
-rw-r--r--compiler/optimizing/nodes.h12
4 files changed, 21 insertions, 0 deletions
diff --git a/compiler/optimizing/bounds_check_elimination.cc b/compiler/optimizing/bounds_check_elimination.cc
index 4ca364867d..1d167949f4 100644
--- a/compiler/optimizing/bounds_check_elimination.cc
+++ b/compiler/optimizing/bounds_check_elimination.cc
@@ -944,6 +944,10 @@ class BCEVisitor : public HGraphVisitor {
};
void BoundsCheckElimination::Run() {
+ if (!graph_->HasArrayAccesses()) {
+ return;
+ }
+
BCEVisitor visitor(graph_);
// Reverse post order guarantees a node's dominators are visited first.
// We want to visit in the dominator-based order since if a value is known to
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index 20a1b03a67..2cac93dd8c 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -840,6 +840,7 @@ void HGraphBuilder::BuildArrayAccess(const Instruction& instruction,
current_block_->AddInstruction(new (arena_) HArrayGet(object, index, anticipated_type));
UpdateLocal(source_or_dest_reg, current_block_->GetLastInstruction());
}
+ graph_->SetHasArrayAccesses(true);
}
void HGraphBuilder::BuildFilledNewArray(uint32_t dex_pc,
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index d55a3ca00b..b34957a17e 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -216,6 +216,10 @@ bool HInliner::TryInline(HInvoke* invoke_instruction,
callee_graph->InlineInto(graph_, invoke_instruction);
+ if (callee_graph->HasArrayAccesses()) {
+ graph_->SetHasArrayAccesses(true);
+ }
+
// Now that we have inlined the callee, we need to update the next
// instruction id of the caller, so that new instructions added
// after optimizations get a unique id.
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 98076a05f2..b7dd756452 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -113,6 +113,7 @@ class HGraph : public ArenaObject<kArenaAllocMisc> {
number_of_vregs_(0),
number_of_in_vregs_(0),
temporaries_vreg_slots_(0),
+ has_array_accesses_(false),
current_instruction_id_(start_instruction_id) {}
ArenaAllocator* GetArena() const { return arena_; }
@@ -199,6 +200,14 @@ class HGraph : public ArenaObject<kArenaAllocMisc> {
return reverse_post_order_;
}
+ bool HasArrayAccesses() const {
+ return has_array_accesses_;
+ }
+
+ void SetHasArrayAccesses(bool value) {
+ has_array_accesses_ = value;
+ }
+
HNullConstant* GetNullConstant();
private:
@@ -236,6 +245,9 @@ class HGraph : public ArenaObject<kArenaAllocMisc> {
// Number of vreg size slots that the temporaries use (used in baseline compiler).
size_t temporaries_vreg_slots_;
+ // Has array accesses. We can totally skip BCE if it's false.
+ bool has_array_accesses_;
+
// The current id to assign to a newly added instruction. See HInstruction.id_.
int32_t current_instruction_id_;