diff options
Diffstat (limited to 'compiler/optimizing')
| -rw-r--r-- | compiler/optimizing/dead_code_elimination.cc | 12 | ||||
| -rw-r--r-- | compiler/optimizing/load_store_elimination.cc | 8 | ||||
| -rw-r--r-- | compiler/optimizing/load_store_elimination_test.cc | 17 | ||||
| -rw-r--r-- | compiler/optimizing/nodes.cc | 15 | ||||
| -rw-r--r-- | compiler/optimizing/nodes.h | 1 |
5 files changed, 20 insertions, 33 deletions
diff --git a/compiler/optimizing/dead_code_elimination.cc b/compiler/optimizing/dead_code_elimination.cc index 8e6b6db236..5a7b83603f 100644 --- a/compiler/optimizing/dead_code_elimination.cc +++ b/compiler/optimizing/dead_code_elimination.cc @@ -312,9 +312,7 @@ bool HDeadCodeElimination::SimplifyAlwaysThrows() { // We need to re-analyze the graph in order to run DCE afterwards. if (rerun_dominance_and_loop_analysis) { - graph_->ClearLoopInformation(); - graph_->ClearDominanceInformation(); - graph_->BuildDominatorTree(); + graph_->RecomputeDominatorTree(); return true; } return false; @@ -438,9 +436,7 @@ bool HDeadCodeElimination::SimplifyIfs() { // We need to re-analyze the graph in order to run DCE afterwards. if (simplified_one_or_more_ifs) { if (rerun_dominance_and_loop_analysis) { - graph_->ClearLoopInformation(); - graph_->ClearDominanceInformation(); - graph_->BuildDominatorTree(); + graph_->RecomputeDominatorTree(); } else { graph_->ClearDominanceInformation(); // We have introduced critical edges, remove them. @@ -808,9 +804,7 @@ bool HDeadCodeElimination::RemoveDeadBlocks(bool force_recomputation, // dominator tree and try block membership. if (removed_one_or_more_blocks || force_recomputation) { if (rerun_dominance_and_loop_analysis || force_loop_recomputation) { - graph_->ClearLoopInformation(); - graph_->ClearDominanceInformation(); - graph_->BuildDominatorTree(); + graph_->RecomputeDominatorTree(); } else { graph_->ClearDominanceInformation(); graph_->ComputeDominanceInformation(); diff --git a/compiler/optimizing/load_store_elimination.cc b/compiler/optimizing/load_store_elimination.cc index 58fdd1cd05..36c3770c42 100644 --- a/compiler/optimizing/load_store_elimination.cc +++ b/compiler/optimizing/load_store_elimination.cc @@ -1364,7 +1364,9 @@ class LSEVisitor final : private HGraphDelegateVisitor { } bool ShouldPerformPartialLSE() const { - return perform_partial_lse_ && !GetGraph()->IsCompilingOsr(); + return perform_partial_lse_ && + !GetGraph()->IsCompilingOsr() && + !GetGraph()->HasIrreducibleLoops(); } bool perform_partial_lse_; @@ -3072,10 +3074,8 @@ class PartialLoadStoreEliminationHelper { Handle<mirror::DexCache>(), /* is_first_run= */ false); rtp_fixup.Visit(ArrayRef<HInstruction* const>(new_ref_phis_)); - GetGraph()->ClearLoopInformation(); - GetGraph()->ClearDominanceInformation(); GetGraph()->ClearReachabilityInformation(); - GetGraph()->BuildDominatorTree(); + GetGraph()->RecomputeDominatorTree(); GetGraph()->ComputeReachabilityInformation(); } diff --git a/compiler/optimizing/load_store_elimination_test.cc b/compiler/optimizing/load_store_elimination_test.cc index d3cf8bfa2a..eb0711343d 100644 --- a/compiler/optimizing/load_store_elimination_test.cc +++ b/compiler/optimizing/load_store_elimination_test.cc @@ -8111,21 +8111,10 @@ TEST_F(LoadStoreEliminationTest, PartialIrreducibleLoop) { EXPECT_TRUE(loop_header->IsLoopHeader()); EXPECT_TRUE(loop_header->GetLoopInformation()->IsIrreducible()); + // Partial LSE cannot run with irreducible loops. EXPECT_INS_RETAINED(left_set); - EXPECT_INS_REMOVED(write_start); - EXPECT_INS_REMOVED(read_end); - - HPredicatedInstanceFieldGet* pred_get = - FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_, breturn); - ASSERT_NE(pred_get, nullptr); - ASSERT_TRUE(pred_get->GetDefaultValue()->IsPhi()) << pred_get->DumpWithArgs(); - EXPECT_INS_EQ(pred_get->GetDefaultValue()->InputAt(0), c11); - EXPECT_INS_EQ(pred_get->GetDefaultValue()->InputAt(1), graph_->GetIntConstant(0)); - ASSERT_TRUE(pred_get->GetTarget()->IsPhi()) << pred_get->DumpWithArgs(); - EXPECT_INS_EQ(pred_get->GetTarget()->InputAt(0), graph_->GetNullConstant()); - HNewInstance* mat = FindSingleInstruction<HNewInstance>(graph_, right->GetSinglePredecessor()); - ASSERT_NE(mat, nullptr); - EXPECT_INS_EQ(pred_get->GetTarget()->InputAt(1), mat); + EXPECT_INS_RETAINED(write_start); + EXPECT_INS_RETAINED(read_end); } enum class UsesOrder { kDefaultOrder, kReverseOrder }; diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 5795ea7ca9..53ed49a307 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -255,6 +255,14 @@ GraphAnalysisResult HGraph::BuildDominatorTree() { return kAnalysisSuccess; } +GraphAnalysisResult HGraph::RecomputeDominatorTree() { + DCHECK(!HasIrreducibleLoops()) << "Recomputing loop information in graphs with irreducible loops " + << "is unsupported, as it could lead to loop header changes"; + ClearLoopInformation(); + ClearDominanceInformation(); + return BuildDominatorTree(); +} + void HGraph::ClearDominanceInformation() { for (HBasicBlock* block : GetActiveBlocks()) { block->ClearDominanceInformation(); @@ -3001,12 +3009,7 @@ HInstruction* HGraph::InlineInto(HGraph* outer_graph, HInvoke* invoke) { } } if (rerun_loop_analysis) { - DCHECK(!outer_graph->HasIrreducibleLoops()) - << "Recomputing loop information in graphs with irreducible loops " - << "is unsupported, as it could lead to loop header changes"; - outer_graph->ClearLoopInformation(); - outer_graph->ClearDominanceInformation(); - outer_graph->BuildDominatorTree(); + outer_graph->RecomputeDominatorTree(); } else if (rerun_dominance) { outer_graph->ClearDominanceInformation(); outer_graph->ComputeDominanceInformation(); diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 9cf52183b8..3613b9519b 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -467,6 +467,7 @@ class HGraph : public ArenaObject<kArenaAllocGraph> { void ClearLoopInformation(); void FindBackEdges(ArenaBitVector* visited); GraphAnalysisResult BuildDominatorTree(); + GraphAnalysisResult RecomputeDominatorTree(); void SimplifyCFG(); void SimplifyCatchBlocks(); |