Skip loop optimization if there is no loop in the graph.
LinearizeGraph() does quite some allocations.
Also add some comments on the possible false positives of
some flags.
Test: m test-art-host
Change-Id: I80ef89a2dc031d601e7621d0b22060cd8c17fae3
diff --git a/compiler/optimizing/loop_optimization.cc b/compiler/optimizing/loop_optimization.cc
index 9583838..26c9ab8 100644
--- a/compiler/optimizing/loop_optimization.cc
+++ b/compiler/optimizing/loop_optimization.cc
@@ -71,7 +71,7 @@
void HLoopOptimization::Run() {
// Well-behaved loops only.
// TODO: make this less of a sledgehammer.
- if (graph_->HasTryCatch() || graph_->HasIrreducibleLoops()) {
+ if (!graph_->HasLoops() || graph_->HasTryCatch() || graph_->HasIrreducibleLoops()) {
return;
}
@@ -84,6 +84,10 @@
// Perform loop optimizations.
LocalRun();
+ if (top_loop_ == nullptr) {
+ graph_->SetHasLoops(false);
+ }
+
// Detach.
loop_allocator_ = nullptr;
last_loop_ = top_loop_ = nullptr;